{"version":3,"file":"Stepper-BzSM_g3W.cjs","sources":["../src/components/Stepper/Stepper.tsx"],"sourcesContent":["'use client';\nimport { forwardRef, useEffect, useRef } from 'react';\nimport type { HTMLAttributes, ReactNode } from 'react';\nimport { AlertCircle, Check } from 'lucide-react';\nimport { cx } from '../../utils/cx';\nimport { withSx } from '../../utils/withSx';\nimport type { SxProp } from '../Layout/sx';\n\nexport interface StepperStep {\n  label: ReactNode;\n  description?: ReactNode;\n  icon?: ReactNode;\n  /** Mark this step as failed (red marker, `aria-invalid`). Wins over complete/active styling. */\n  error?: boolean;\n}\n\nexport interface StepperProps extends Omit<HTMLAttributes<HTMLOListElement>, 'children'> {\n  steps: StepperStep[];\n  /** Active step index (0-based). Steps before this are marked complete. */\n  active: number;\n  orientation?: 'horizontal' | 'vertical';\n  size?: 'sm' | 'md';\n  /** Fired when a clickable step is clicked. By default only completed steps are clickable. */\n  onStepClick?: (index: number) => void;\n  /** Let every step (including upcoming ones) fire `onStepClick`. Default: false. */\n  clickable?: boolean;\n  /**\n   * One-off CSS, same as `Box`'s `sx`: each value may be a scalar or a\n   * responsive breakpoint map (`{ base, sm, md, lg, xl }`). Scalar-only sx\n   * merges into inline style; responsive sx injects a scoped class.\n   */\n  sx?: SxProp;\n}\n\nexport const Stepper = forwardRef<HTMLOListElement, StepperProps>(function Stepper(\n  { steps, active, orientation = 'horizontal', size = 'md', onStepClick, clickable: allClickable = false, className, style, sx, ...rest },\n  ref,\n) {\n  const { className: classes, style: mergedStyle, styleTag } = withSx(\n    sx, style, 'cny-stepper', `cny-stepper-${orientation}`, `cny-stepper-${size}`, className,\n  );\n  const listRef = useRef<HTMLOListElement | null>(null);\n  const setRefs = (node: HTMLOListElement | null) => {\n    listRef.current = node;\n    if (typeof ref === 'function') ref(node);\n    else if (ref) (ref as React.MutableRefObject<HTMLOListElement | null>).current = node;\n  };\n  // A trail wider than its container scrolls sideways: keep the active step in view.\n  useEffect(() => {\n    const el = listRef.current?.querySelector<HTMLElement>('.cny-stepper-step.is-active');\n    if (!el || typeof el.scrollIntoView !== 'function') return;\n    const reduce = typeof window !== 'undefined' && typeof window.matchMedia === 'function'\n      && window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n    el.scrollIntoView({ inline: orientation === 'horizontal' ? 'center' : 'nearest', block: 'nearest', behavior: reduce ? 'auto' : 'smooth' });\n  }, [active, orientation, steps.length]);\n\n  return (\n    <ol\n      ref={setRefs}\n      className={classes}\n      style={mergedStyle}\n      aria-label=\"Progress\"\n      {...rest}\n    >\n      {styleTag}\n      {steps.map((step, i) => {\n        const state = i < active ? 'complete' : i === active ? 'active' : 'upcoming';\n        const clickable = (allClickable || state === 'complete') && Boolean(onStepClick);\n        return (\n          <li key={i} className={cx('cny-stepper-step', `is-${state}`, step.error && 'is-error')}>\n            <button\n              type=\"button\"\n              className=\"cny-stepper-step-row\"\n              onClick={clickable ? () => onStepClick?.(i) : undefined}\n              disabled={!clickable}\n              aria-current={state === 'active' ? 'step' : undefined}\n              aria-invalid={step.error || undefined}\n            >\n              <span className=\"cny-stepper-marker\" aria-hidden=\"true\">\n                {step.error ? <AlertCircle size={14} /> : state === 'complete' ? <Check size={14} /> : step.icon ?? i + 1}\n              </span>\n              <span className=\"cny-stepper-text\">\n                <span className=\"cny-stepper-label\">{step.label}</span>\n                {step.description && <span className=\"cny-stepper-desc\">{step.description}</span>}\n              </span>\n            </button>\n            {i < steps.length - 1 && <span className=\"cny-stepper-connector\" aria-hidden=\"true\" />}\n          </li>\n        );\n      })}\n    </ol>\n  );\n});\n"],"names":["Stepper","forwardRef","steps","active","orientation","size","onStepClick","allClickable","className","style","sx","rest","ref","classes","mergedStyle","styleTag","withSx","listRef","useRef","setRefs","node","useEffect","el","_a","reduce","jsxs","step","i","state","clickable","cx","jsx","AlertCircle","Check"],"mappings":"gMAkCaA,EAAUC,EAAAA,WAA2C,SAChE,CAAE,MAAAC,EAAO,OAAAC,EAAQ,YAAAC,EAAc,aAAc,KAAAC,EAAO,KAAM,YAAA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