{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "step",
  "title": "Step",
  "description": "What a step looks like by its status, so the Timeline and the Stepper read the same: its mark, an Icon tile that is soft when done, solid when current, subtle while to come and destructive on an error, with a tick, a cross in an octagon or a dash that says so; the line that fills once a step is done; and the timing that lets a move of several steps fill one line after another.",
  "dependencies": [],
  "registryDependencies": [
    "https://kinoui.com/r/icon-tile.json",
    "https://kinoui.com/r/choice.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/lib/step.tsx",
      "content": "import { IconTile } from '@/registry/components/kino/icon-tile'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { choiceWipeClassName } from '@/registry/lib/choice'\nimport type { ReactNode } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * What a step's mark looks like by its status, shared by the Timeline and the\n * Stepper so a step reads the same in both: an Icon tile, soft when done,\n * solid primary when current, subtle while upcoming or skipped and soft\n * destructive on an error, never outlined, with a glyph that says the status\n * so it isn't told by colour alone. Each reads `data-status` on the step that\n * carries `group/step`, and waits `--step-wait` before it changes, so a mark\n * lights once the line reaching it has filled. Nothing changes size.\n */\n\ntype StepStatus = 'complete' | 'current' | 'upcoming' | 'error' | 'skipped'\n\n/** What a step's status reads as, before its title; the current one is `aria-current='step'` instead. */\nconst stepStatusText: Partial<Record<StepStatus, string>> = {\n  complete: 'Completed',\n  upcoming: 'Upcoming',\n  error: 'Error',\n  skipped: 'Skipped',\n}\n\n/** Its colours move on `morph` after `--step-wait`; one that arrives grows into place on `enter` (`starting:` in the component). */\nconst stepMarkerTransition =\n  '[transition:background-color_var(--motion-morph-duration)_var(--motion-morph-fade-easing)_var(--step-wait,0s),color_var(--motion-morph-duration)_var(--motion-morph-fade-easing)_var(--step-wait,0s),scale_var(--motion-enter-duration)_var(--motion-enter-easing)] motion-reduce:[transition-property:background-color,color]'\n\n/** How a step's Icon tile looks by its status. */\nconst stepTileLook = {\n  none: { tone: 'neutral', weight: 'soft' },\n  complete: { tone: 'neutral', weight: 'soft' },\n  current: { tone: 'primary', weight: 'solid' },\n  upcoming: { tone: 'neutral', weight: 'subtle' },\n  error: { tone: 'destructive', weight: 'soft' },\n  skipped: { tone: 'neutral', weight: 'subtle' },\n} as const satisfies Record<\n  StepStatus | 'none',\n  {\n    tone: 'neutral' | 'primary' | 'destructive'\n    weight: 'subtle' | 'soft' | 'solid'\n  }\n>\n\nconst glyphLayerClassName =\n  'col-start-1 row-start-1 flex items-center justify-center transition-opacity duration-(--motion-morph-duration) ease-(--motion-morph-easing) [transition-delay:var(--step-wait,0s)]'\n\n/** The Checkbox's tick, and the other glyphs drawn the same way. */\nfunction Glyph({ children }: { children: ReactNode }) {\n  return (\n    <svg\n      viewBox='0 0 14 14'\n      fill='none'\n      stroke='currentColor'\n      strokeWidth={2}\n      strokeLinecap='round'\n      strokeLinejoin='round'\n      aria-hidden\n      className='size-3.5 overflow-visible'\n    >\n      {children}\n    </svg>\n  )\n}\n\n/**\n * A step's mark by its status: `children` (a number, or a dot) while it is\n * current or upcoming, the Checkbox's tick, wiped in on `draw`, once it is\n * done, a cross in an octagon on an error and a dash when skipped. Decorative:\n * the step's title and status text say what it is.\n */\nfunction StepMark({\n  status,\n  className,\n  children,\n}: {\n  status: StepStatus | undefined\n  className?: string\n  children: ReactNode\n}) {\n  return (\n    <IconTile\n      {...stepTileLook[status ?? 'none']}\n      size='xs'\n      className={cn('grid', stepMarkerTransition, className)}\n    >\n      <span\n        className={cn(\n          glyphLayerClassName,\n          'group-data-[status=complete]/step:opacity-0 group-data-[status=error]/step:opacity-0 group-data-[status=skipped]/step:opacity-0',\n        )}\n      >\n        {children}\n      </span>\n      <span className={glyphLayerClassName}>\n        <Glyph>\n          <path\n            d='M3 7.4 5.8 10.2 11 4.2'\n            className={cn(\n              choiceWipeClassName,\n              '[transition-delay:var(--step-wait,0s)] group-data-[status=complete]/step:[clip-path:inset(0_0_0_0)]!',\n            )}\n          />\n        </Glyph>\n      </span>\n      <span\n        className={cn(\n          glyphLayerClassName,\n          'opacity-0 group-data-[status=error]/step:opacity-100',\n        )}\n      >\n        <IconPlaceholder\n          lucide='OctagonXIcon'\n          tabler='IconCircleX'\n          hugeicons='OctagonXIcon'\n          phosphor='XCircleIcon'\n          remixicon='RiSpam3Line'\n          aria-hidden\n        />\n      </span>\n      <span\n        className={cn(\n          glyphLayerClassName,\n          'opacity-0 group-data-[status=skipped]/step:opacity-100',\n        )}\n      >\n        <Glyph>\n          <path d='M4 7h6' />\n        </Glyph>\n      </span>\n    </IconTile>\n  )\n}\n\n/** The hairline between two steps, and the fill that draws along it once the first is done. */\nconst stepLineClassName = 'bg-border pointer-events-none forced-colors:bg-[CanvasText]'\nconst stepLineFillClassName =\n  'bg-primary absolute inset-0 transition-[scale] duration-(--motion-draw-duration) ease-(--motion-draw-easing) motion-reduce:transition-none forced-colors:bg-[Highlight]'\n\n/**\n * A line on `draw` looks arrived about halfway through the role's duration,\n * which runs on to when its spring is at rest, so what follows it starts then.\n */\nconst STEP_ARRIVAL = 0.5\n\n/**\n * How a step joins a move from step `from` to step `to`, in fractions of the\n * `draw` role's duration, so a move of any length takes as long as one step:\n * each line between the two fills (or, going back, empties from the far end)\n * in its share of the time, starting as the one before it arrives, and each\n * marker on the way changes once the line reaching it has arrived (or, going\n * back, the line out of it has gone). A step outside the move, and every\n * step when nothing moved, waits for nothing.\n */\nfunction stepTiming(\n  step: number,\n  from: number,\n  to: number,\n): { lineDelay: number; lineSpan: number; markerWait: number } {\n  const count = Math.abs(to - from)\n  if (count === 0) return { lineDelay: 0, lineSpan: 1, markerWait: 0 }\n  const lineSpan = 1 / count\n  const turn = STEP_ARRIVAL / count\n  const low = Math.min(from, to)\n  const high = Math.max(from, to)\n  const lineMoves = step >= low && step < high\n  if (to > from) {\n    return {\n      lineDelay: lineMoves ? (step - from) * turn : 0,\n      lineSpan: lineMoves ? lineSpan : 1,\n      markerWait: step > from && step <= to ? (step - from) * turn : 0,\n    }\n  }\n  return {\n    lineDelay: lineMoves ? (from - 1 - step) * turn : 0,\n    lineSpan: lineMoves ? lineSpan : 1,\n    markerWait: step >= to && step < from ? (from - step) * turn : 0,\n  }\n}\n\nexport {\n  StepMark,\n  stepLineClassName,\n  stepLineFillClassName,\n  stepMarkerTransition,\n  stepStatusText,\n  stepTileLook,\n  stepTiming,\n}\nexport type { StepStatus }\n",
      "type": "registry:lib",
      "target": "@lib/step.tsx"
    }
  ],
  "type": "registry:lib"
}