{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stepper",
  "title": "Stepper",
  "description": "The steps of a multi-step flow with complete, current and upcoming states, horizontal or vertical.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "@corsair-ui/utils"
  ],
  "files": [
    {
      "path": "registry/default/ui/stepper.tsx",
      "content": "\"use client\";\n\nimport { CheckIcon } from \"lucide-react\";\nimport { createContext, useContext, useState, type ComponentProps } from \"react\";\nimport { cn } from \"@/registry/default/lib/utils\";\n\ntype StepperOrientation = \"horizontal\" | \"vertical\";\ntype StepperState = \"complete\" | \"current\" | \"upcoming\";\n\ninterface StepperLabels {\n  /** Read after the number of a finished step. */\n  complete: string;\n  /** Read after the number of the step in progress. */\n  current: string;\n  /** Read after the number of a step not reached yet. An empty string reads nothing. */\n  upcoming: string;\n}\n\nconst defaultLabels: StepperLabels = {\n  complete: \"Completed\",\n  current: \"Current\",\n  upcoming: \"Upcoming\",\n};\n\ninterface StepperContextValue {\n  value: number;\n  setValue: (value: number) => void;\n  orientation: StepperOrientation;\n  linear: boolean;\n  labels: StepperLabels;\n}\n\nconst StepperContext = createContext<StepperContextValue | null>(null);\n\nfunction useStepper(part: string) {\n  const context = useContext(StepperContext);\n  if (!context) throw new Error(`${part} must be used inside <Stepper>.`);\n  return context;\n}\n\ninterface StepperItemContextValue {\n  step: number;\n  state: StepperState;\n}\n\nconst StepperItemContext = createContext<StepperItemContextValue | null>(null);\n\nfunction useStepperItem(part: string) {\n  const context = useContext(StepperItemContext);\n  if (!context) throw new Error(`${part} must be used inside <StepperItem>.`);\n  return context;\n}\n\n/** True inside a `StepperTrigger`, which then carries `aria-current` instead of the indicator. */\nconst StepperTriggerContext = createContext(false);\n\ninterface StepperProps extends Omit<ComponentProps<\"nav\">, \"defaultValue\"> {\n  /** The current step, as a 0-based index. Steps before it are complete. */\n  value?: number;\n  /** The first current step when uncontrolled. */\n  defaultValue?: number;\n  /** Called with the index of the step a `StepperTrigger` asks for. */\n  onValueChange?: (value: number) => void;\n  orientation?: StepperOrientation;\n  /**\n   * When true (the default), a `StepperTrigger` on a step not reached yet is\n   * disabled, so steps are taken in order. Set it to false to let people jump\n   * to any step.\n   */\n  linear?: boolean;\n  /** Accessible name of the `<nav>` landmark. */\n  label?: string;\n  /** State text read by screen readers after each step's number. */\n  labels?: Partial<StepperLabels>;\n}\n\n/**\n * The steps of a multi-step flow (checkout, onboarding, a long form) and\n * where the user is in it. It is a `<nav>` landmark named by `label`\n * (\"Progress\") around an ordered list, so screen readers announce the number\n * of steps. The current step is marked with `aria-current=\"step\"`, and each\n * indicator reads its state (\"Completed\", \"Current\", from `labels`) after the\n * number, since the check mark and colours are not read. Put a\n * `StepperTrigger` in a step to make it a button that moves to it: Tab\n * reaches it and Enter or Space activates it; with `linear` (the default)\n * steps not reached yet stay disabled. Controlled with `value` /\n * `onValueChange` or uncontrolled with `defaultValue`. Colour changes are a\n * transition, turned off with reduced motion.\n *\n * @example\n * <Stepper value={step} onValueChange={setStep}>\n *   <StepperItem step={0}>\n *     <StepperTrigger>\n *       <StepperIndicator />\n *       <StepperTitle>Crew</StepperTitle>\n *     </StepperTrigger>\n *     <StepperSeparator />\n *   </StepperItem>\n *   <StepperItem step={1}>\n *     <StepperTrigger>\n *       <StepperIndicator />\n *       <StepperTitle>Route</StepperTitle>\n *     </StepperTrigger>\n *   </StepperItem>\n * </Stepper>\n */\nfunction Stepper({\n  value: valueProp,\n  defaultValue = 0,\n  onValueChange,\n  orientation = \"horizontal\",\n  linear = true,\n  label = \"Progress\",\n  labels: labelsProp,\n  className,\n  children,\n  ...props\n}: StepperProps) {\n  const [internal, setInternal] = useState(defaultValue);\n  const value = valueProp ?? internal;\n  const setValue = (next: number) => {\n    if (valueProp === undefined) setInternal(next);\n    onValueChange?.(next);\n  };\n  const labels = { ...defaultLabels, ...labelsProp };\n  return (\n    <nav\n      data-slot=\"stepper\"\n      data-orientation={orientation}\n      aria-label={label}\n      className={className}\n      {...props}\n    >\n      <ol\n        data-slot=\"stepper-list\"\n        data-orientation={orientation}\n        className={cn(\n          \"flex\",\n          orientation === \"vertical\" ? \"flex-col\" : \"items-center gap-1.5 sm:gap-2\"\n        )}\n      >\n        <StepperContext.Provider value={{ value, setValue, orientation, linear, labels }}>\n          {children}\n        </StepperContext.Provider>\n      </ol>\n    </nav>\n  );\n}\n\ninterface StepperItemProps extends ComponentProps<\"li\"> {\n  /** This step's 0-based index. */\n  step: number;\n}\n\n/** One step. Its state is `data-state`: \"complete\", \"current\" or \"upcoming\". */\nfunction StepperItem({ step, className, ...props }: StepperItemProps) {\n  const { value, orientation } = useStepper(\"StepperItem\");\n  const state: StepperState = step < value ? \"complete\" : step === value ? \"current\" : \"upcoming\";\n  return (\n    <StepperItemContext.Provider value={{ step, state }}>\n      <li\n        data-slot=\"stepper-item\"\n        data-state={state}\n        data-orientation={orientation}\n        className={cn(\n          \"group/stepper-item\",\n          orientation === \"vertical\"\n            ? \"relative flex flex-col pb-6 last:pb-0\"\n            : // On small screens steps start from their content's width, as only\n              // the current one shows its title, and the lines share what is left.\n              \"flex items-center gap-1.5 sm:gap-2 [&:not(:last-child)]:flex-1 max-sm:[&:not(:last-child)]:flex-auto\",\n          // The step that gives way when even that does not fit: its title is cut short.\n          orientation === \"horizontal\" && state === \"current\" && \"min-w-0\",\n          className\n        )}\n        {...props}\n      />\n    </StepperItemContext.Provider>\n  );\n}\n\n/**\n * Makes the step a button that moves to it. Disabled for steps not reached\n * yet while the Stepper is `linear`; pass `disabled` to lock any step.\n */\nfunction StepperTrigger({\n  className,\n  disabled,\n  onClick,\n  type = \"button\",\n  ...props\n}: ComponentProps<\"button\">) {\n  const { setValue, linear } = useStepper(\"StepperTrigger\");\n  const { step, state } = useStepperItem(\"StepperTrigger\");\n  return (\n    <StepperTriggerContext.Provider value={true}>\n      <button\n        data-slot=\"stepper-trigger\"\n        data-state={state}\n        type={type}\n        aria-current={state === \"current\" ? \"step\" : undefined}\n        disabled={disabled ?? (linear && state === \"upcoming\")}\n        onClick={(event) => {\n          onClick?.(event);\n          if (!event.defaultPrevented) setValue(step);\n        }}\n        className={cn(\n          \"inline-flex min-w-0 cursor-pointer items-center gap-2 rounded-md text-left\",\n          \"transition-[color,box-shadow] outline-none motion-reduce:transition-none\",\n          \"focus-visible:ring-ring/50 focus-visible:ring-[3px]\",\n          \"disabled:cursor-not-allowed disabled:opacity-50\",\n          className\n        )}\n        {...props}\n      />\n    </StepperTriggerContext.Provider>\n  );\n}\n\n/**\n * The round marker with the step's number, or a check mark once complete.\n * Pass children to show something else (an icon) instead of the number.\n */\nfunction StepperIndicator({ className, children, ...props }: ComponentProps<\"span\">) {\n  const { labels } = useStepper(\"StepperIndicator\");\n  const { step, state } = useStepperItem(\"StepperIndicator\");\n  const inTrigger = useContext(StepperTriggerContext);\n  const stateLabel = labels[state];\n  return (\n    <span\n      data-slot=\"stepper-indicator\"\n      data-state={state}\n      aria-current={!inTrigger && state === \"current\" ? \"step\" : undefined}\n      className={cn(\n        \"flex size-8 shrink-0 items-center justify-center rounded-full border text-sm font-medium\",\n        \"transition-[color,background-color,border-color] motion-reduce:transition-none\",\n        \"data-[state=upcoming]:bg-muted data-[state=upcoming]:text-muted-foreground\",\n        \"data-[state=current]:border-primary data-[state=current]:bg-background data-[state=current]:text-primary\",\n        \"data-[state=complete]:border-primary data-[state=complete]:bg-primary data-[state=complete]:text-primary-foreground\",\n        \"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n        className\n      )}\n      {...props}\n    >\n      {state === \"complete\" ? (\n        <>\n          <CheckIcon aria-hidden=\"true\" />\n          <span className=\"sr-only\">{step + 1}</span>\n        </>\n      ) : (\n        (children ?? step + 1)\n      )}\n      {stateLabel ? <span className=\"sr-only\">{`, ${stateLabel}`}</span> : null}\n    </span>\n  );\n}\n\n/**\n * The step's name. In a horizontal Stepper on small screens only the current\n * step shows its title, cut short if it still does not fit, so the row fits\n * a phone; the others are still read out, and still name their `StepperTrigger`.\n */\nfunction StepperTitle({ className, ...props }: ComponentProps<\"span\">) {\n  const stepper = useContext(StepperContext);\n  const item = useContext(StepperItemContext);\n  const horizontal = stepper?.orientation === \"horizontal\" && item !== null;\n  return (\n    <span\n      data-slot=\"stepper-title\"\n      className={cn(\n        \"group-data-[state=upcoming]/stepper-item:text-muted-foreground block text-sm font-medium\",\n        horizontal && (item.state === \"current\" ? \"max-sm:truncate\" : \"max-sm:sr-only\"),\n        className\n      )}\n      {...props}\n    />\n  );\n}\n\nfunction StepperDescription({ className, ...props }: ComponentProps<\"span\">) {\n  return (\n    <span\n      data-slot=\"stepper-description\"\n      className={cn(\"text-muted-foreground block text-xs\", className)}\n      {...props}\n    />\n  );\n}\n\n/**\n * The line to the next step, coloured once this step is complete. Decorative:\n * hidden from screen readers, and not drawn on the last step.\n */\nfunction StepperSeparator({ className, ...props }: ComponentProps<\"span\">) {\n  const { orientation } = useStepper(\"StepperSeparator\");\n  return (\n    <span\n      data-slot=\"stepper-separator\"\n      data-orientation={orientation}\n      aria-hidden=\"true\"\n      className={cn(\n        \"bg-border block shrink-0 group-last/stepper-item:hidden\",\n        \"group-data-[state=complete]/stepper-item:bg-primary transition-colors motion-reduce:transition-none\",\n        orientation === \"vertical\"\n          ? \"absolute top-10 bottom-2 left-[calc(1rem-0.5px)] w-px\"\n          : \"h-px min-w-2 flex-1 sm:min-w-4\",\n        className\n      )}\n      {...props}\n    />\n  );\n}\n\nexport {\n  Stepper,\n  StepperDescription,\n  StepperIndicator,\n  StepperItem,\n  StepperSeparator,\n  StepperTitle,\n  StepperTrigger,\n  type StepperItemProps,\n  type StepperLabels,\n  type StepperOrientation,\n  type StepperProps,\n  type StepperState,\n};\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}