{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stepper",
  "title": "Number stepper",
  "description": "A value on a readout between minus and plus keys, with MIN and MAX tags.",
  "dependencies": [
    "@ui-sdk/react@0.1.0-beta.5",
    "lucide-react@1.73.0"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/cyber.json"
  ],
  "files": [
    {
      "path": "registry/cyber/ui/stepper.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Field, FieldDescription, FieldError, FieldLabel } from \"@ui-sdk/react/field\"\nimport {\n  NumberInput,\n  NumberInputControl,\n  NumberInputDecrement,\n  NumberInputGroup,\n  NumberInputIncrement,\n  type NumberInputValueChangeReason,\n} from \"@ui-sdk/react/number-input\"\nimport { Minus, Plus } from \"lucide-react\"\nimport { haptic } from \"@/registry/cyber/lib/haptics\"\nimport { createAdjustmentSound, sfx } from \"@/registry/cyber/lib/sound\"\nimport \"@/registry/cyber/ui/cyber/stepper.css\"\n\n// Typing already has its own sound, and resets and controller updates are\n// not the person's hand. Buttons and keys get a directional sample; wheel\n// and scrub movement use the same ticking as sliders and resize handles.\nconst steps: ReadonlySet<NumberInputValueChangeReason> = new Set([\"step-key\", \"increment-press\", \"decrement-press\", \"wheel\", \"scrub\"])\n\n// A number set one step at a time: a minus key, the value on a readout, a\n// plus key. Each step sounds in its direction. With both bounds set, a rail\n// along the foot of the readout shows how far through the range the value\n// is, and a MIN or MAX tag prints beside the label when it gets there; the\n// key that can't go further is hatched.\n//\n// The readout is a text input, so a number can be typed too; arrow keys,\n// Page Up and Down, Home and End step it. The keys stay out of the Tab\n// order, since the focused readout already has them on its arrows.\n//\n// - `hint` describes the field; `error` marks it invalid with a message.\n// - Everything else goes to the SDK root: `value`, `defaultValue`,\n//   `onValueChange`, `onValueCommit`, `min`, `max`, `step`, `format`,\n//   `name`, a `controller`.\nfunction Stepper({\n  label,\n  hint,\n  error,\n  disabled,\n  min,\n  max,\n  onValueChange,\n  onValueCommit,\n  ...props\n}: Omit<React.ComponentProps<typeof NumberInput>, \"children\"> & {\n  label: string\n  hint?: React.ReactNode\n  error?: string\n}) {\n  const adjustment = React.useMemo(createAdjustmentSound, [])\n  React.useEffect(() => adjustment.stop, [adjustment])\n  React.useEffect(() => {\n    if (disabled || props.readOnly) adjustment.stop()\n  }, [adjustment, disabled, props.readOnly])\n\n  return (\n    <Field data-kit=\"field\" disabled={disabled} invalid={error ? true : undefined}>\n      <NumberInput\n        data-kit=\"stepper\"\n        min={min}\n        max={max}\n        {...props}\n        onValueChange={(value, details) => {\n          onValueChange?.(value, details)\n          if (details.canceled) return adjustment.stop()\n          if (!steps.has(details.reason)) return adjustment.stop()\n          if (details.reason === \"wheel\" || details.reason === \"scrub\") {\n            adjustment.move()\n          } else {\n            adjustment.stop()\n            // Use the action itself, including keys that jump to a bound.\n            // An empty or partly typed input has no useful prior value.\n            const key = details.event && \"key\" in details.event ? details.event.key : undefined\n            const increment = details.reason === \"increment-press\" || (details.reason === \"step-key\" && (key === \"ArrowUp\" || key === \"PageUp\" || key === \"End\"))\n            sfx(increment ? \"increment\" : \"decrement\")\n          }\n          haptic(\"selection\")\n        }}\n        onValueCommit={(value, details) => {\n          adjustment.stop()\n          onValueCommit?.(value, details)\n        }}\n        onBlur={(event) => {\n          adjustment.stop()\n          props.onBlur?.(event)\n        }}\n        onPointerCancel={(event) => {\n          adjustment.stop()\n          props.onPointerCancel?.(event)\n        }}\n        onLostPointerCapture={(event) => {\n          adjustment.stop()\n          props.onLostPointerCapture?.(event)\n        }}\n      >\n        {(state) => {\n          const atMin = min != null && state.value != null && state.value <= min\n          const atMax = max != null && state.value != null && state.value >= max\n          const ranged = min != null && max != null && max > min\n          const through = ranged && state.value != null ? Math.min(1, Math.max(0, (state.value - min) / (max - min))) : 0\n          return (\n            <>\n              <div data-kit=\"stepper-head\">\n                <FieldLabel data-kit=\"label\">{label}</FieldLabel>\n                {(atMin || atMax) && (\n                  <span data-kit=\"stepper-tag\" aria-hidden>\n                    {atMin ? \"MIN\" : \"MAX\"}\n                  </span>\n                )}\n              </div>\n              <NumberInputGroup data-kit=\"stepper-row\">\n                {/* Accepted changes play the directional sound themselves. */}\n                <NumberInputDecrement data-kit=\"stepper-key\" data-frame=\"bl\" data-press-flash=\"\" data-sfx=\"none\" aria-label={`Decrease ${label}`}>\n                  <Minus aria-hidden />\n                </NumberInputDecrement>\n                <div data-kit=\"control\" data-frame=\"\" data-frame-focus=\"within\">\n                  <NumberInputControl data-kit=\"stepper-value\" />\n                  {ranged && <span data-kit=\"stepper-rail\" aria-hidden style={{ \"--through\": through } as React.CSSProperties} />}\n                </div>\n                <NumberInputIncrement data-kit=\"stepper-key\" data-frame=\"br\" data-press-flash=\"\" data-sfx=\"none\" aria-label={`Increase ${label}`}>\n                  <Plus aria-hidden />\n                </NumberInputIncrement>\n              </NumberInputGroup>\n              {/* The readout is a plain text input, with no range for a\n                  screen reader to hear, so reaching a bound is said. */}\n              <span data-sr-only role=\"status\">\n                {atMin ? \"Minimum.\" : atMax ? \"Maximum.\" : \"\"}\n              </span>\n            </>\n          )\n        }}\n      </NumberInput>\n      {hint && <FieldDescription data-kit=\"hint\">{hint}</FieldDescription>}\n      {error ? (\n        <FieldError data-kit=\"field-error\" match>\n          {error}\n        </FieldError>\n      ) : (\n        <FieldError data-kit=\"field-error\" />\n      )}\n    </Field>\n  )\n}\n\nexport { Stepper }\n",
      "type": "registry:ui",
      "target": "@ui/stepper.tsx"
    },
    {
      "path": "registry/cyber/ui/cyber/stepper.css",
      "content": "@layer ui-sdk, cyber.tokens, cyber.base, cyber.ui, cyber.blocks, cyber.fx, cyber.a11y;\n\n/* A stepper is three boxes in a row that read as one cut shape: a minus key\n   cut at its outer foot, the shared field box (field.css) uncut between\n   them as the readout, and a plus key cut at its outer foot. */\n@layer cyber.ui {\n  /* The SDK's root: the label's row over the keys and the readout. */\n  [data-skin=\"cyber\"] [data-kit=\"stepper\"] {\n    position: relative;\n    display: grid;\n    gap: 6px;\n    min-width: 0;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"stepper-head\"] {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    gap: 12px;\n    min-width: 0;\n    min-height: 18px;\n\n    & [data-kit=\"label\"][data-disabled] {\n      color: var(--cy-ink-mute);\n    }\n  }\n\n  /* MIN / MAX: an outlined tag, printed when the value is at a bound, so\n     the hatched key beside the readout is explained in a word. */\n  [data-skin=\"cyber\"] [data-kit=\"stepper-tag\"] {\n    flex: none;\n    padding: 3px 5px 2px;\n    border: 1px solid var(--cy-line-ctl);\n    font-family: var(--cy-mono);\n    font-size: 9px;\n    font-weight: 500;\n    letter-spacing: 0.08em;\n    line-height: 1;\n    color: var(--cy-ink);\n    background: var(--cy-fill-hover);\n    animation: var(--cy-fx-in) 200ms var(--cy-ease-snap) backwards;\n\n    [data-kit=\"stepper\"][data-disabled] & {\n      border-color: var(--cy-line-deco);\n      color: var(--cy-ink-mute);\n      background: none;\n    }\n  }\n\n  /* Keys, readout, keys: three to four to three, and never narrower than a\n     target. */\n  [data-skin=\"cyber\"] [data-kit=\"stepper-row\"] {\n    display: grid;\n    grid-template-columns: minmax(var(--cy-h), 3fr) minmax(56px, 4fr) minmax(var(--cy-h), 3fr);\n    gap: 4px;\n    min-width: 0;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"stepper-key\"] {\n    --frame-cut: var(--cy-cut-sm);\n    --frame-line: var(--cy-line-ctl);\n    --frame-fill: var(--cy-panel);\n\n    display: grid;\n    place-items: center;\n    min-width: 0;\n    min-height: var(--cy-h);\n    padding: 0;\n    color: var(--cy-ink);\n    cursor: pointer;\n    transition:\n      background-color var(--cy-t-fast) linear,\n      border-color var(--cy-t-fast) linear,\n      color var(--cy-t-fast) linear;\n\n    & svg {\n      width: 16px;\n      height: 16px;\n    }\n\n    @media (hover: hover) {\n      &:hover:not([data-disabled]) {\n        --frame-line: var(--cy-line-hot);\n        --frame-fill: var(--cy-fill-hover);\n      }\n    }\n\n    &:active:not([data-disabled]) {\n      --frame-line: var(--cy-line-hot);\n      --frame-fill: var(--cy-fill-active);\n      color: var(--cy-ink-hi);\n    }\n\n    /* Can't step: the field is disabled, or the value is at this key's\n       bound. Hatched either way, as everything unavailable is. */\n    &[data-disabled] {\n      --frame-line: var(--cy-line-deco);\n      --frame-image: repeating-linear-gradient(135deg, transparent 0 5px, var(--cy-line-deco) 5px 6px);\n      color: var(--cy-ink-mute);\n      cursor: not-allowed;\n    }\n  }\n\n  /* The readout's box sits between two cut keys, so it keeps its corners. */\n  [data-skin=\"cyber\"] [data-kit=\"stepper-row\"] > [data-kit=\"control\"] {\n    --frame-cut: 0px;\n\n    padding-inline: 4px;\n  }\n\n  /* The value: a readout, so mono and the signal color. Named with its\n     element so the color wins over the shared box's own input rule. */\n  [data-skin=\"cyber\"] [data-kit=\"control\"] input[data-kit=\"stepper-value\"] {\n    font-family: var(--cy-mono);\n    font-size: var(--cy-text-lg);\n    font-weight: 500;\n    font-variant-numeric: tabular-nums;\n    text-align: center;\n    color: var(--cy-signal);\n\n    /* The box shows focus for the input (data-frame-focus=\"within\"), so the\n       input's own ring is cut off rather than drawn twice. */\n    clip-path: inset(0);\n\n    &[data-disabled] {\n      color: var(--cy-ink-mute);\n    }\n  }\n\n  /* How far through its range the value is: a rail along the foot of the\n     readout, filled from the leading end. It moves in steps, as the value\n     does. */\n  [data-skin=\"cyber\"] [data-kit=\"stepper-rail\"] {\n    position: absolute;\n    inset: auto 4px 3px;\n    height: 2px;\n    background: var(--cy-signal-dim);\n    pointer-events: none;\n\n    &::after {\n      content: \"\";\n      position: absolute;\n      inset: 0;\n      background: var(--cy-signal);\n      transform-origin: 0 50%;\n      scale: var(--through, 0) 1;\n      transition: scale var(--cy-t) var(--cy-ease-step);\n    }\n\n    :dir(rtl) &::after {\n      transform-origin: 100% 50%;\n    }\n\n    [data-kit=\"stepper\"][data-disabled] & {\n      background: var(--cy-line-deco);\n\n      &::after {\n        background: var(--cy-ink-mute);\n      }\n    }\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/cyber/stepper.css"
    }
  ],
  "type": "registry:ui"
}
