{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "components-stepper",
  "type": "registry:component",
  "title": "Stepper",
  "description": "Progress through named steps, from one value",
  "author": "sudo-kw <https://github.com/sudo-kw>",
  "dependencies": [
    "@gpuix/native@0.11.0",
    "@gpuix/react@0.11.0",
    "effect@4.1.2",
    "react@^19.2.4"
  ],
  "registryDependencies": [
    "https://gpuixui.sudokw.com/gpuix-primitives.json",
    "https://gpuixui.sudokw.com/gpuix-tokens.json",
    "https://gpuixui.sudokw.com/gpuix-tw.json"
  ],
  "files": [
    {
      "path": "packages/components/src/internal/parts.ts",
      "target": "@ui/gpuixui/components/internal/parts.ts",
      "type": "registry:lib",
      "content": "import * as Arr from \"effect/Array\";\nimport * as P from \"effect/Predicate\";\nimport {\n  Children,\n  Fragment,\n  isValidElement,\n  type ReactElement,\n  type ReactNode,\n} from \"react\";\n\nexport type PartComponent = (props: never) => ReactNode;\n\nexport type PartChildren =\n  | ReactElement<unknown>\n  | boolean\n  | null\n  | undefined\n  | ReadonlyArray<PartChildren>;\n\nexport interface PartsContract {\n  readonly parent: string;\n\n  readonly family: ReadonlyArray<PartComponent>;\n\n  readonly accepts: ReadonlyArray<PartComponent>;\n\n  readonly hint?: string;\n}\n\nconst componentName = (type: unknown): string =>\n  P.isString(type)\n    ? type\n    : P.isFunction(type)\n      ? type.name || \"anonymous\"\n      : \"element\";\n\nconst fragmentChildren = (element: ReactElement<unknown>): ReactNode =>\n  hasChildren(element.props) ? element.props.children : undefined;\n\nconst hasChildren = (\n  value: unknown,\n): value is { readonly children?: ReactNode } =>\n  P.isObject(value) && \"children\" in value;\n\nconst leaves = (children: ReactNode): ReadonlyArray<unknown> =>\n  Arr.flatMap(Children.toArray(children), (child) =>\n    isValidElement<unknown>(child) && child.type === Fragment\n      ? leaves(fragmentChildren(child))\n      : [child],\n  );\n\nexport const assertParts = (\n  contract: PartsContract,\n  children: ReactNode,\n): void => {\n  Arr.forEach(leaves(children), (leaf) => {\n    if (!isValidElement(leaf)) return;\n    if (Arr.some(contract.accepts, (part) => part === leaf.type)) return;\n    if (!Arr.some(contract.family, (part) => part === leaf.type)) return;\n\n    throw new Error(\n      `${componentName(leaf.type)} cannot be used inside ${contract.parent}.` +\n        (contract.hint === undefined ? \"\" : ` ${contract.hint}`),\n    );\n  });\n};\n"
    },
    {
      "path": "packages/components/src/internal/recipe.ts",
      "target": "@ui/gpuixui/components/internal/recipe.ts",
      "type": "registry:lib",
      "content": "import type { StyleDesc } from \"@gpuix/react\";\nimport { createRecipeCache } from \"../../tw/index.js\";\nimport type { Theme } from \"./theme.js\";\n\nexport const recipeStyle: (recipe: string, theme: Theme) => StyleDesc =\n  createRecipeCache(512);\n"
    },
    {
      "path": "packages/components/src/internal/text.ts",
      "target": "@ui/gpuixui/components/internal/text.ts",
      "type": "registry:lib",
      "content": "import { pipe } from \"effect\";\nimport * as Option from \"effect/Option\";\nimport * as Str from \"effect/String\";\n\nexport const textOf = (value: unknown): string =>\n  typeof value === \"string\" ? value : \"\";\n\nexport const nameOf = (value: unknown): string | undefined =>\n  pipe(\n    Option.some(textOf(value)),\n    Option.map(Str.trim),\n    Option.filter(Str.isNonEmpty),\n    Option.getOrUndefined,\n  );\n"
    },
    {
      "path": "packages/components/src/internal/theme.ts",
      "target": "@ui/gpuixui/components/internal/theme.ts",
      "type": "registry:lib",
      "content": "import type { StyleDesc } from \"@gpuix/react\";\nimport * as Schema from \"effect/Schema\";\nimport {\n  alpha,\n  avatarPixels,\n  avatarSize,\n  brandTextOn,\n  controlFocusRing,\n  controlHeight,\n  controlPaddingX,\n  currentPlatform,\n  darkTheme,\n  disabledAction,\n  disabledOpacity,\n  elevationShadow,\n  filledHover,\n  filledPressed,\n  findHighlight,\n  focusRing,\n  keyboardFocusRing,\n  lightTheme,\n  nativeTextTheme,\n  pointerWash,\n  selectionOn,\n  statusTone,\n  syntaxColors,\n  targetSize,\n  textStyle,\n  type BoxShadow,\n  type ElevationLevel,\n  type FindHighlightSource,\n  type NativeTextFill,\n  type PlatformName,\n  type PointerWashSurface,\n  type StatusTone,\n  type SyntaxColors,\n  type SyntaxRole,\n  type TextRole,\n  type Theme,\n  type ThemeColors,\n} from \"../../tokens/index.js\";\n\nexport {\n  alpha,\n  avatarPixels,\n  avatarSize,\n  controlFocusRing,\n  controlHeight,\n  controlPaddingX,\n  currentPlatform,\n  darkTheme,\n  disabledAction,\n  disabledOpacity,\n  elevationShadow,\n  filledHover,\n  filledPressed,\n  findHighlight,\n  focusRing,\n  keyboardFocusRing,\n  lightTheme,\n  nativeTextTheme,\n  statusTone,\n  syntaxColors,\n  targetSize,\n  textStyle,\n};\nexport type {\n  BoxShadow,\n  ElevationLevel,\n  FindHighlightSource,\n  NativeTextFill,\n  PlatformName,\n  StatusTone,\n  SyntaxColors,\n  SyntaxRole,\n  TextRole,\n  Theme,\n};\nexport { ThemeProvider, useTheme } from \"../../tokens/react.js\";\n\nexport const keyboardRing = (theme: Theme, invalid = false): StyleDesc =>\n  controlFocusRing(theme, { invalid }) ?? {};\n\nexport interface ControlRingState {\n  readonly disabled?: boolean;\n\n  readonly invalid?: boolean;\n}\n\nexport const controlRing = (\n  theme: Theme,\n  state: ControlRingState = {},\n): StyleDesc => controlFocusRing(theme, state) ?? {};\n\nexport const pressWash = (theme: Theme, replaced: PointerWashSurface): string =>\n  pointerWash(theme, \"active\", replaced) ?? theme.colors.active;\n\nexport const selectionWash = (theme: Theme): StyleDesc => ({\n  selectionColor: theme.colors.selection,\n});\n\nexport const keepContent: StyleDesc = { keyboardFocusDim: false };\n\nexport const disabledFade = (\n  disabled: boolean,\n): { readonly opacity: number } | undefined =>\n  disabled ? { opacity: disabledOpacity } : undefined;\n\nconst Tones = Schema.Literals([\"info\", \"success\", \"warning\", \"danger\"]);\n\nexport type Tone = typeof Tones.Type;\n\nexport const toneOf = (value: unknown): Tone =>\n  Schema.is(Tones)(value) ? value : \"info\";\n\nexport interface ToneStyle {\n  readonly fg: string;\n  readonly bg: string;\n  readonly border: string;\n}\n\nconst TOKEN_TONE: Readonly<Record<Tone, StatusTone>> = {\n  info: \"info\",\n  success: \"success\",\n  warning: \"warning\",\n  danger: \"destructive\",\n};\n\nexport const tone = (theme: Theme, value: Tone): ToneStyle => {\n  const { background, border, foreground } = statusTone(\n    theme,\n    TOKEN_TONE[value],\n  );\n  return { bg: background, border, fg: foreground };\n};\n\nconst softRoles: Readonly<Record<Tone, keyof ThemeColors>> = {\n  info: \"infoSoft\",\n  success: \"successSoft\",\n  warning: \"warningSoft\",\n  danger: \"destructiveSoft\",\n};\n\nexport const messageLink = (theme: Theme, value: Tone): string =>\n  brandTextOn(theme, softRoles[value]);\n\nexport const messageSelection = (theme: Theme, value: Tone): string =>\n  selectionOn(theme, softRoles[value]);\n\nexport const toneSurface = (theme: Theme, value: Tone): StyleDesc => {\n  const { bg, border, fg } = tone(theme, value);\n  return {\n    backgroundColor: bg,\n    color: fg,\n    borderWidth: theme.borderWidth.thin,\n    borderColor: border,\n  };\n};\n"
    },
    {
      "path": "packages/components/src/stepper.tsx",
      "target": "@ui/gpuixui/components/stepper.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type { Props } from \"@gpuix/react\";\nimport {\n  mergeStyles,\n  resolveStyle,\n  type StateStyle,\n} from \"@gpuix/react/floating\";\nimport { accessibleName, visibleCopy } from \"../primitives/core/index.js\";\nimport {\n  cn,\n  STEPPER_DESCRIPTION,\n  STEPPER_LABEL,\n  STEPPER_MARKER,\n  STEPPER_MARKER_TEXT,\n  STEPPER_ORIENTATION,\n  STEPPER_ROOT,\n  STEPPER_STEP,\n  STEPPER_TEXT,\n} from \"../tw/index.js\";\nimport { Match } from \"effect\";\nimport { createContext, useContext } from \"react\";\nimport {\n  assertParts,\n  type PartChildren,\n  type PartComponent,\n  type PartsContract,\n} from \"./internal/parts.js\";\nimport { recipeStyle } from \"./internal/recipe.js\";\nimport { textOf } from \"./internal/text.js\";\nimport { controlHeight, useTheme, type Theme } from \"./internal/theme.js\";\nimport {\n  currentStep,\n  orientationOf,\n  statusOf,\n  stepName,\n  type StepperOrientation,\n  type StepperStatus,\n} from \"./stepper/logic.js\";\n\nexport type { StepperStatus } from \"./stepper/logic.js\";\n\nexport type { StepperOrientation } from \"./stepper/logic.js\";\n\ninterface StepperContextValue {\n  readonly value: number;\n  readonly orientation: StepperOrientation;\n}\n\nconst StepperContext = createContext<StepperContextValue | undefined>(\n  undefined,\n);\n\nconst useStepper = (): StepperContextValue => {\n  const value = useContext(StepperContext);\n  if (value === undefined) {\n    throw new Error(\"Stepper parts must be used inside Stepper\");\n  }\n  return value;\n};\n\nconst markerPalette = (\n  theme: Theme,\n  status: StepperStatus,\n): { readonly backgroundColor: string; readonly color: string } =>\n  Match.value(status).pipe(\n    Match.when(\"complete\", () => ({\n      backgroundColor: theme.colors.secondary,\n      color: theme.colors.secondaryForeground,\n    })),\n    Match.when(\"current\", () => ({\n      backgroundColor: theme.colors.primary,\n      color: theme.colors.primaryForeground,\n    })),\n    Match.when(\"upcoming\", () => ({\n      backgroundColor: theme.colors.muted,\n      color: theme.colors.mutedForeground,\n    })),\n    Match.exhaustive,\n  );\n\nexport interface StepperProps extends Omit<Props, \"children\"> {\n  readonly value: number;\n\n  readonly orientation?: StepperOrientation;\n\n  readonly label?: string;\n  readonly className?: string;\n  readonly children?: PartChildren;\n}\n\nexport const Stepper = ({\n  value,\n  orientation: requestedOrientation = \"horizontal\",\n  label,\n  className,\n  children,\n  style,\n  ...rest\n}: StepperProps) => {\n  const theme = useTheme();\n\n  const orientation = orientationOf(requestedOrientation);\n\n  const name = accessibleName(textOf(label));\n  assertParts(stepperRoot, children);\n\n  return (\n    <StepperContext.Provider value={{ value: currentStep(value), orientation }}>\n      <div\n        role=\"list\"\n        {...(name === undefined ? {} : { \"aria-label\": name })}\n        {...rest}\n        style={mergeStyles(\n          recipeStyle(\n            cn(STEPPER_ROOT, STEPPER_ORIENTATION[orientation], className),\n            theme,\n          ),\n          style,\n        )}\n      >\n        {children}\n      </div>\n    </StepperContext.Provider>\n  );\n};\n\nexport interface StepperStepProps extends Omit<Props, \"children\" | \"style\"> {\n  readonly value: number;\n\n  readonly label: string;\n\n  readonly description?: string;\n\n  readonly className?: string;\n\n  readonly style?: StateStyle<StepperStepState>;\n}\n\nexport interface StepperStepState {\n  readonly status: StepperStatus;\n}\n\nexport const StepperStep = ({\n  value,\n  label,\n  description,\n  className,\n  style,\n  ...rest\n}: StepperStepProps) => {\n  const theme = useTheme();\n  const { value: current } = useStepper();\n  const status = statusOf(current, value);\n  const marker = markerPalette(theme, status);\n  const side = controlHeight(theme, \"md\");\n\n  const name = stepName(label, value);\n  const detail = visibleCopy(textOf(description));\n\n  return (\n    <div\n      role=\"listitem\"\n      aria-label={name}\n      aria-selected={status === \"current\"}\n      {...rest}\n      style={mergeStyles(\n        recipeStyle(cn(STEPPER_STEP, className), theme),\n        resolveStyle(style, { status }),\n      )}\n    >\n      <div\n        style={mergeStyles(recipeStyle(STEPPER_MARKER, theme), {\n          width: side,\n          height: side,\n          backgroundColor: marker.backgroundColor,\n        })}\n      >\n        <text\n          style={mergeStyles(recipeStyle(STEPPER_MARKER_TEXT, theme), {\n            color: marker.color,\n          })}\n        >\n          {String(value)}\n        </text>\n      </div>\n      <div style={recipeStyle(STEPPER_TEXT, theme)}>\n        <text\n          style={mergeStyles(recipeStyle(STEPPER_LABEL, theme), {\n            color:\n              status === \"upcoming\"\n                ? theme.colors.mutedForeground\n                : theme.colors.foreground,\n          })}\n        >\n          {name}\n        </text>\n        {detail === undefined ? null : (\n          <text style={recipeStyle(STEPPER_DESCRIPTION, theme)}>{detail}</text>\n        )}\n      </div>\n    </div>\n  );\n};\n\nconst stepperParts: ReadonlyArray<PartComponent> = [Stepper, StepperStep];\n\nconst stepperRoot: PartsContract = {\n  parent: \"Stepper\",\n  family: stepperParts,\n  accepts: [StepperStep],\n  hint: \"Put StepperStep directly inside Stepper.\",\n};\n\nexport const stepperMeta = {\n  name: \"Stepper\",\n  tier: 2,\n  status: \"done\",\n  gpuixSupport: \"partial\",\n  limitations: [\n    \"no aria-current in 0.11.0; the current step carries aria-selected\",\n    \"display-only by design: there is no step click, disabled policy or onValueChange\",\n    \"no connector line between steps\",\n  ],\n  docs: \"docs/stepper.mdx\",\n  example: \"examples/stepper.example.tsx\",\n  testFile: \"src/behaviour/stepper.test.tsx\",\n} as const;\n"
    },
    {
      "path": "packages/components/src/stepper/logic.ts",
      "target": "@ui/gpuixui/components/stepper/logic.ts",
      "type": "registry:lib",
      "content": "import { accessibleName } from \"../../primitives/core/index.js\";\nimport * as Schema from \"effect/Schema\";\nimport { textOf } from \"../internal/text.js\";\n\nexport type StepperStatus = \"complete\" | \"current\" | \"upcoming\";\n\nexport const StepperOrientations = Schema.Literals([\"horizontal\", \"vertical\"]);\n\nexport type StepperOrientation = typeof StepperOrientations.Type;\n\nexport const orientationOf = (value: unknown): StepperOrientation =>\n  Schema.is(StepperOrientations)(value) ? value : \"horizontal\";\n\nexport const stepName = (title: unknown, position: number): string =>\n  accessibleName(textOf(title)) ??\n  `Step ${Number.isFinite(position) ? Math.max(1, Math.floor(position)) : 1}`;\n\nexport const currentStep = (value: number): number =>\n  Number.isFinite(value) ? value : 1;\n\nexport const statusOf = (current: number, step: number): StepperStatus => {\n  const at = currentStep(current);\n  return step < at ? \"complete\" : step === at ? \"current\" : \"upcoming\";\n};\n"
    }
  ],
  "docs": "[Stepper](https://gpuixui.sudokw.com/components/stepper) — These are GPUix native components: the files render through GPUix's reconciler against `@gpuix/react`, not the DOM, and need the per-platform `@gpuix/native` binding. The CLI installs the `@gpuixui/*` runtime the components import as registry items, so the copied tree resolves on its own; wrap it in `ThemeProvider` before it renders.",
  "meta": {
    "url": "/components/stepper",
    "kind": "component",
    "runtime": "gpuix",
    "registry": "gpuixui"
  }
}