{
  "name": "stepper",
  "type": "ui:component",
  "title": "Stepper & yield* runWizard()",
  "description": "Responsive multi-step progress indicator plus Aster-native yield* runWizard() generator flow.",
  "dependencies": [
    "@lucide/icons"
  ],
  "registryDependencies": [
    "theme",
    "icon",
    "button"
  ],
  "files": [
    {
      "path": "src/ui/stepper.tsx",
      "target": "src/ui/stepper.tsx",
      "sha256": "da3f6b275c9ae68e40f04a1e79d9fbab60c0aac093919c7ffe85d5caea63f7d4",
      "content": "import './theme.css';\nimport { Check } from '@lucide/icons';\nimport { scope, signal, type View } from '@fierst/aster';\nimport { Icon } from './icon';\nimport { Button } from './button';\n\nconst stepScope = scope`\n  :scope {\n    display: flex;\n    flex-direction: column;\n    gap: 0.75rem;\n    list-style: none;\n    margin: 0;\n    padding: 0;\n    font-family: var(--aster-font-sans);\n  }\n  @media (min-width: 640px) {\n    :scope {\n      flex-direction: row;\n      align-items: flex-start;\n      gap: 0;\n    }\n  }\n  .st-item {\n    display: flex;\n    align-items: flex-start;\n    gap: 0.65rem;\n    flex: 1;\n    min-width: 0;\n    position: relative;\n  }\n  @media (min-width: 640px) {\n    .st-item {\n      flex-direction: column;\n      align-items: flex-start;\n      padding-right: 1rem;\n    }\n    .st-item:not(:last-child)::after {\n      content: '';\n      position: absolute;\n      top: 13px;\n      left: 34px;\n      right: 10px;\n      height: 1px;\n      background: var(--aster-border);\n    }\n    .st-item.is-done:not(:last-child)::after { background: var(--aster-primary); }\n  }\n  .st-dot {\n    width: 28px;\n    height: 28px;\n    border-radius: 9999px;\n    border: 1.5px solid var(--aster-border-strong);\n    background: var(--aster-surface);\n    color: var(--aster-on-surface-muted);\n    font-size: 0.78rem;\n    font-weight: 600;\n    display: inline-grid;\n    place-items: center;\n    flex-shrink: 0;\n    position: relative;\n    z-index: 1;\n    transition: background-color var(--aster-dur-fast), border-color var(--aster-dur-fast), color var(--aster-dur-fast);\n  }\n  .st-item.is-active .st-dot {\n    border-color: var(--aster-primary);\n    color: var(--aster-primary);\n    background: var(--aster-primary-subtle);\n  }\n  .st-item.is-done .st-dot {\n    border-color: var(--aster-primary);\n    background: var(--aster-primary);\n    color: var(--aster-on-primary);\n  }\n  .st-copy { display: grid; gap: 0.1rem; min-width: 0; }\n  .st-title { font-size: 0.84rem; font-weight: 600; color: var(--aster-on-surface); }\n  .st-item.is-upcoming .st-title { color: var(--aster-on-surface-muted); font-weight: 500; }\n  .st-desc { font-size: 0.76rem; color: var(--aster-on-surface-muted); }\n`;\n\nconst wizScope = scope`\n  :scope {\n    display: grid;\n    gap: 1.15rem;\n    padding: 1.25rem;\n    border-radius: var(--aster-radius-lg);\n    border: 1px solid var(--aster-border);\n    background: var(--aster-surface);\n    box-shadow: var(--aster-shadow-xs);\n  }\n  .wiz-footer {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    gap: 0.5rem;\n    padding-top: 0.85rem;\n    border-top: 1px solid var(--aster-border);\n  }\n`;\n\nexport interface StepItem {\n  id: string;\n  title: string;\n  description?: string;\n}\n\nexport function Stepper({\n  steps,\n  currentStep,\n  onStepClick,\n  class: extraClass,\n}: {\n  steps: readonly StepItem[];\n  currentStep: number;\n  onStepClick?: (index: number) => void;\n  class?: string;\n}) {\n  return (\n    <ol class={[stepScope, extraClass].filter(Boolean).join(' ')} aria-label=\"Progress steps\">\n      {steps.map((step, idx) => {\n        const done = idx < currentStep;\n        const active = idx === currentStep;\n        const upcoming = idx > currentStep;\n        return (\n          <li\n            key={step.id}\n            aria-current={active ? 'step' : undefined}\n            class={[\n              'st-item',\n              done ? 'is-done' : '',\n              active ? 'is-active' : '',\n              upcoming ? 'is-upcoming' : '',\n            ]\n              .filter(Boolean)\n              .join(' ')}\n          >\n            <button\n              type=\"button\"\n              class=\"st-dot\"\n              disabled={!onStepClick || upcoming}\n              style={onStepClick && !upcoming ? 'cursor:pointer' : 'cursor:default'}\n              aria-label={`Step ${idx + 1}: ${step.title}`}\n              onClick={() => onStepClick && !upcoming && onStepClick(idx)}\n            >\n              {done ? <Icon icon={Check} size={14} strokeWidth={2.5} /> : idx + 1}\n            </button>\n            <div class=\"st-copy\">\n              <span class=\"st-title\">{step.title}</span>\n              {step.description ? <span class=\"st-desc\">{step.description}</span> : null}\n            </div>\n          </li>\n        );\n      })}\n    </ol>\n  );\n}\n\nexport interface WizardStepDef<TState> {\n  id: string;\n  title: string;\n  description?: string;\n  render: (state: TState, update: (patch: Partial<TState>) => void) => View;\n  canProceed?: (state: TState) => boolean;\n}\n\n/**\n * Aster-native `yield*` Multi-Step Wizard Flow!\n * Walks the user through typed steps and returns the completed state (or `null` if cancelled):\n *   const config = yield* runWizard(steps, { name: '', region: 'pdx' });\n */\nexport function* runWizard<TState extends Record<string, any>>(\n  steps: readonly WizardStepDef<TState>[],\n  initial: TState,\n  opts: { finishLabel?: string; cancelLabel?: string } = {},\n): Generator<View, TState | null, any> {\n  const stepIdx = signal(0);\n  const state = signal<TState>({ ...initial });\n  const status = signal<'active' | 'done' | 'cancelled'>('active');\n\n  const update = (patch: Partial<TState>) => {\n    state.update((prev) => ({ ...prev, ...patch }));\n  };\n\n  while (status() === 'active') {\n    const idx = stepIdx();\n    const curState = state();\n    const cur = steps[idx];\n    const isLast = idx === steps.length - 1;\n    const ok = cur?.canProceed ? cur.canProceed(curState) : true;\n\n    yield (\n      <div class={wizScope}>\n        <Stepper steps={steps} currentStep={idx} onStepClick={(i) => stepIdx.set(i)} />\n        <div>{cur ? cur.render(curState, update) : null}</div>\n        <div class=\"wiz-footer\">\n          <Button\n            variant=\"ghost\"\n            onClick={() => {\n              if (idx === 0) status.set('cancelled');\n              else stepIdx.set(idx - 1);\n            }}\n          >\n            {idx === 0 ? (opts.cancelLabel ?? 'Cancel') : 'Back'}\n          </Button>\n          <Button\n            variant=\"primary\"\n            disabled={!ok}\n            onClick={() => {\n              if (isLast) status.set('done');\n              else stepIdx.set(idx + 1);\n            }}\n          >\n            {isLast ? (opts.finishLabel ?? 'Complete') : 'Continue'}\n          </Button>\n        </div>\n      </div>\n    );\n  }\n\n  return status() === 'cancelled' ? null : state();\n}\n"
    }
  ]
}
