{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "number-input",
  "title": "Number Input",
  "description": "Numeric spinbutton with split, end or stacked steppers, press-and-hold acceleration, min/max/step and large steps, Intl currency, percent and unit formatting over a raw value, arrow, PageUp/PageDown, Home/End and focused-wheel stepping, slide or pop step feedback and an invalid state, in the six input variants with tones, sizes, shapes and shadows.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json",
    "https://goodui.dev/r/locale.json",
    "https://goodui.dev/r/sounds.json"
  ],
  "files": [
    {
      "path": "registry/components/core/number-input.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { ChevronDown, ChevronUp, Minus, Plus } from \"lucide-react\"\nimport { cn } from \"@/lib/utils\"\nimport { useGooduiLocale, useLabels } from \"@/lib/goodui-locale\"\nimport type { SoundName } from \"@/lib/goodui-sounds\"\nimport { GooduiTokens } from \"@/lib/goodui-motion\"\n\n/*\n * A numeric field, independent layers: every axis combines with every other.\n *   variant    how it is painted (same six as input)     tone           focus and stepper color\n *   steppers   split (− value +), end, stacked, none      stepAnimation  how the value reacts to a step\n *   animation  how focus looks                            shape, size, shadow\n * The value is always a raw number (or null). Intl formatting (currency, percent, units) shows while the field is not\n * being edited; while focused the field shows the plain number so it is easy to type.\n * Keyboard: ↑ ↓ step, PageUp / PageDown large step, Home / End jump to min / max, Enter commits, Esc reverts.\n * Press and hold a stepper to repeat, faster the longer you hold. The wheel steps only while the field has focus.\n */\n\nexport type NumberInputVariant = \"outline\" | \"filled\" | \"underline\" | \"ghost\" | \"neo\" | \"glass\"\nexport type NumberInputTone = \"primary\" | \"neutral\" | \"success\" | \"warning\" | \"danger\" | \"info\"\nexport type NumberInputSize = \"sm\" | \"md\" | \"lg\"\nexport type NumberInputShape = \"square\" | \"rounded\" | \"pill\"\nexport type NumberInputShadow = \"none\" | \"sm\" | \"md\" | \"inner\"\nexport type NumberInputAnimation = \"none\" | \"ring\" | \"glow\" | \"lift\"\nexport type NumberInputStepAnimation = \"none\" | \"slide\" | \"pop\"\nexport type NumberInputSteppers = \"split\" | \"end\" | \"stacked\" | \"none\"\n\nexport type NumberInputLabels = { increment: string; decrement: string }\nconst DEFAULT_LABELS: NumberInputLabels = { increment: \"Increase\", decrement: \"Decrease\" }\n\ntype Native = Omit<React.ComponentProps<\"input\">, \"size\" | \"value\" | \"defaultValue\" | \"onChange\" | \"type\" | \"min\" | \"max\" | \"step\" | \"prefix\">\n\nexport type NumberInputProps = Native & {\n  /** Raw numeric value (controlled); null when empty. Formatting never changes it. */\n  value?: number | null\n  /** Initial value when uncontrolled. */\n  defaultValue?: number | null\n  /** Called with the raw number (or null) while typing, on every step and when the value is clamped on blur. */\n  onValueChange?: (value: number | null) => void\n  /** Native change event of the text field (fires while typing only). */\n  onChange?: React.ChangeEventHandler<HTMLInputElement>\n  min?: number\n  max?: number\n  /** Amount added by a stepper, ↑ / ↓ or the wheel. */\n  step?: number\n  /** Amount added by PageUp / PageDown and Shift + wheel. Defaults to step × 10. */\n  largeStep?: number\n  /** Intl.NumberFormat options for the display, e.g. { style: \"currency\", currency: \"EUR\" } or { style: \"percent\" }.\n   * Percent values are fractions (0.15 shows as 15%); you type 15 while editing. */\n  format?: Intl.NumberFormatOptions\n  /** BCP 47 locale for formatting and parsing. Defaults to the GooduiLocaleProvider language, else the browser's language after mount (\"en-US\" on the server). */\n  locale?: string\n  /** Snap out-of-range values back to min / max when the field loses focus. false keeps them and marks the field invalid. */\n  clampOnBlur?: boolean\n  /** Repeat while a stepper is held down, accelerating the longer it is held. */\n  holdToRepeat?: boolean\n  /** Step with the mouse wheel while the field has focus. */\n  wheel?: boolean\n  /** Plays a \"tick\" on every step (a little higher for +, lower for −) when the visitor has sounds on (lib/goodui-sounds); pass a sound name to pick another. Off by default. */\n  sound?: boolean | SoundName\n  /** Stepper buttons: split puts − and + on either side, end groups them after the value, stacked shows ▲ ▼. */\n  steppers?: NumberInputSteppers\n  /** Text alignment of the value. Defaults to center for split steppers, start otherwise. */\n  align?: \"start\" | \"center\" | \"end\"\n  /** Field style: outline (default), filled, underline, ghost, neo-brutalist or frosted glass. */\n  variant?: NumberInputVariant\n  /** Focus color and stepper hover color. */\n  tone?: NumberInputTone\n  size?: NumberInputSize\n  shape?: NumberInputShape\n  /** Field shadow; inner draws an inset shadow. Ignored by neo, which has its own offset shadow. */\n  shadow?: NumberInputShadow\n  /** How the field reacts to focus. */\n  animation?: NumberInputAnimation\n  /** How the value reacts to a step: slide (up or down with the direction), pop (scale bump) or none. */\n  stepAnimation?: NumberInputStepAnimation\n  /** Visible label above the field. */\n  label?: React.ReactNode\n  /** Helper text under the field (hidden while a message shows). */\n  description?: React.ReactNode\n  /** Error text under the field; shown when invalid. */\n  message?: React.ReactNode\n  /** Red field and aria-invalid. Also set automatically for out-of-range values when clampOnBlur is false. */\n  invalid?: boolean\n  /** Icon or short text before the value. */\n  leading?: React.ReactNode\n  /** Icon or short text after the value (e.g. \"guests\"). */\n  trailing?: React.ReactNode\n  /** Stretch to the container. By default the field is 12rem wide (override with className). */\n  fullWidth?: boolean\n  /** Class for the field box (the root gets className). */\n  fieldClassName?: string\n  /** Text for built-in controls and screen readers; pass translations here. */\n  labels?: Partial<NumberInputLabels>\n}\n\nconst tones = (c: string) => `\n.${c}{--pc-c:var(--primary);--pc-fg:var(--primary-foreground)}\n.${c}[data-tone=neutral]{--pc-c:var(--foreground);--pc-fg:var(--background)}\n.${c}[data-tone=success]{--pc-c:oklch(0.53 0.13 155);--pc-fg:#fff}\n.${c}[data-tone=warning]{--pc-c:oklch(0.75 0.16 70);--pc-fg:oklch(0.25 0.05 70)}\n.${c}[data-tone=danger]{--pc-c:oklch(0.56 0.21 27);--pc-fg:#fff}\n.${c}[data-tone=info]{--pc-c:oklch(0.55 0.17 250);--pc-fg:#fff}\n.dark .${c}[data-tone=success]{--pc-c:oklch(0.7 0.16 155);--pc-fg:oklch(0.2 0.05 155)}\n.dark .${c}[data-tone=danger]{--pc-c:oklch(0.68 0.2 25);--pc-fg:oklch(0.2 0.05 25)}\n.dark .${c}[data-tone=info]{--pc-c:oklch(0.7 0.15 245);--pc-fg:oklch(0.2 0.05 245)}\n.${c}{--pc-tint:color-mix(in oklab,var(--pc-c) 14%,transparent);--pc-ink:color-mix(in oklab,var(--pc-c) 82%,var(--foreground))}\n.${c}[data-tone=warning]{--pc-ink:color-mix(in oklab,var(--pc-c) 62%,var(--foreground))}\n`\n\nconst R = \".pc-num\"\nconst F = \".pc-num-field\"\nconst CSS = `${tones(\"pc-num\")}\n${R}{--pc-muted:color-mix(in oklab,var(--muted-foreground) 80%,var(--foreground));--pc-sep:var(--input)}\n${R}[data-invalid]{--pc-c:oklch(0.56 0.21 27);--pc-s:var(--pc-c);--pc-ink:color-mix(in oklab,var(--pc-c) 82%,var(--foreground))}\n.dark ${R}[data-invalid]{--pc-c:oklch(0.68 0.2 25)}\n\n${F}{position:relative;isolation:isolate;border:1px solid transparent;box-shadow:var(--pc-nv,0 0 #0000),var(--pc-nsh,0 0 #0000),var(--pc-nf,0 0 #0000)}\n${R}[data-variant=outline] ${F}{background:var(--background);border-color:var(--pc-s,var(--input))}\n${R}[data-variant=outline] ${F}:hover{border-color:var(--pc-s,color-mix(in oklab,var(--foreground) 25%,var(--input)))}\n${R}[data-variant=filled] ${F}{background:var(--muted);border-color:var(--pc-s,transparent);--pc-sep:color-mix(in oklab,var(--foreground) 8%,transparent)}\n${R}[data-variant=filled] ${F}:focus-within{background:var(--background)}\n${R}[data-variant=underline] ${F}{border-width:0 0 1px;border-radius:0!important;border-color:var(--pc-s,var(--input));background:transparent;--pc-sep:transparent}\n${R}[data-variant=ghost] ${F}{background:transparent;border-color:var(--pc-s,transparent);--pc-sep:transparent}\n${R}[data-variant=ghost] ${F}:hover{background:color-mix(in oklab,var(--muted) 60%,transparent)}\n${R}[data-variant=ghost] ${F}:focus-within{background:var(--muted)}\n${R}[data-variant=neo] ${F}{background:var(--background);border:2px solid var(--foreground);--pc-nv:3px 3px 0 var(--pc-s,var(--foreground));--pc-sep:var(--foreground)}\n${R}[data-variant=glass] ${F}{background:color-mix(in oklab,var(--background) 45%,transparent);border-color:var(--pc-s,color-mix(in oklab,var(--foreground) 14%,transparent));-webkit-backdrop-filter:blur(14px) saturate(1.6);backdrop-filter:blur(14px) saturate(1.6);--pc-nv:inset 0 1px 0 color-mix(in oklab,white 40%,transparent);--pc-sep:color-mix(in oklab,var(--foreground) 12%,transparent)}\n${R} ${F}:focus-within{border-color:var(--pc-c)}\n${R}[data-variant=neo] ${F}:focus-within{border-color:var(--foreground)}\n\n${R}[data-shadow=sm] ${F}{--pc-nsh:0 1px 2px rgb(0 0 0/.08)}\n${R}[data-shadow=md] ${F}{--pc-nsh:0 4px 14px -4px rgb(0 0 0/.16)}\n${R}[data-shadow=inner] ${F}{--pc-nsh:inset 0 2px 4px rgb(0 0 0/.08)}\n\n${R}[data-anim=ring] ${F}{transition:box-shadow .2s,border-color .2s,background-color .2s}\n${R}[data-anim=ring] ${F}:focus-within{--pc-nf:0 0 0 3px color-mix(in oklab,var(--pc-c) 24%,transparent)}\n${R}[data-anim=glow] ${F}{transition:box-shadow .3s,border-color .2s,background-color .2s}\n${R}[data-anim=glow] ${F}:focus-within{--pc-nf:0 0 0 1px color-mix(in oklab,var(--pc-c) 50%,transparent),0 0 22px -2px color-mix(in oklab,var(--pc-c) 55%,transparent)}\n${R}[data-anim=lift] ${F}{transition:transform .2s var(--pc-ease-out),box-shadow .2s,border-color .2s,background-color .2s}\n${R}[data-anim=lift] ${F}:focus-within{transform:translateY(-2px);--pc-nf:0 10px 22px -12px color-mix(in oklab,var(--pc-c) 70%,rgb(0 0 0/.4))}\n${R}[data-variant=neo][data-anim=lift] ${F}:focus-within{transform:translate(-1px,-1px);--pc-nv:5px 5px 0 var(--pc-s,var(--foreground));--pc-nf:0 0 #0000}\n\n.pc-num-control{background:transparent;outline:none;min-width:0;width:100%;color:inherit;font-variant-numeric:tabular-nums}\n.pc-num-control::placeholder{color:color-mix(in oklab,var(--muted-foreground) 88%,var(--foreground));opacity:1}\n.pc-num-control:disabled{cursor:not-allowed}\n.pc-num-btn{color:color-mix(in oklab,var(--pc-ink) 65%,var(--pc-muted));border-color:var(--pc-sep);transition:background-color .15s,color .15s;-webkit-tap-highlight-color:transparent;touch-action:manipulation}\n.pc-num-btn:hover:not(:disabled){background:var(--pc-tint);color:var(--pc-ink)}\n.pc-num-btn:active:not(:disabled){background:color-mix(in oklab,var(--pc-c) 24%,transparent)}\n.pc-num-btn:disabled{opacity:.35;cursor:not-allowed}\n.pc-num-desc{color:color-mix(in oklab,var(--muted-foreground) 85%,var(--foreground))}\n${R}[data-invalid] .pc-num-msg{color:var(--pc-ink)}\n@media (prefers-reduced-motion:reduce){\n  ${R} *{transition:none!important;animation:none!important}\n  ${R} ${F}:focus-within{transform:none!important}\n}\n`\n\nconst H: Record<NumberInputSize, string> = { sm: \"h-8 text-sm\", md: \"h-10 text-sm\", lg: \"h-12 text-base\" }\nconst PAD: Record<NumberInputSize, string> = { sm: \"px-2.5 gap-1.5\", md: \"px-3 gap-2\", lg: \"px-4 gap-2.5\" }\nconst BTN: Record<NumberInputSize, string> = { sm: \"w-8 [&_svg]:size-3.5\", md: \"w-10 [&_svg]:size-4\", lg: \"w-12 [&_svg]:size-[18px]\" }\nconst STACK: Record<NumberInputSize, string> = { sm: \"w-6 [&_svg]:size-3\", md: \"w-7 [&_svg]:size-3.5\", lg: \"w-8 [&_svg]:size-4\" }\nconst SVG: Record<NumberInputSize, string> = { sm: \"[&_svg]:size-3.5\", md: \"[&_svg]:size-4\", lg: \"[&_svg]:size-[18px]\" }\nconst SHAPES: Record<NumberInputShape, string> = { square: \"rounded-none\", rounded: \"rounded-lg\", pill: \"rounded-full\" }\nconst WIDTH: Record<NumberInputSize, string> = { sm: \"w-40\", md: \"w-48\", lg: \"w-56\" }\n\nconst decimals = (n: number) => {\n  if (!Number.isFinite(n)) return 0\n  const s = String(n)\n  const e = s.match(/e-(\\d+)$/)\n  if (e) return Number(e[1])\n  const i = s.indexOf(\".\")\n  return i < 0 ? 0 : s.length - i - 1\n}\nconst addExact = (a: number, b: number) => {\n  const d = Math.min(12, Math.max(decimals(a), decimals(b)))\n  const f = 10 ** d\n  return Math.round(a * f + b * f) / f\n}\n\n// Optional UI sound: the sound module is loaded only when `sound` is on, so silent apps pay nothing.\nfunction useCue(sound: boolean | SoundName | undefined) {\n  React.useEffect(() => {\n    if (sound) void import(\"@/lib/goodui-sounds\")\n  }, [sound])\n  return React.useCallback(\n    (fallback: SoundName, o?: { rate?: number; exact?: boolean }) => {\n      if (!sound) return\n      void import(\"@/lib/goodui-sounds\").then((m) => m.play(sound === true || o?.exact ? fallback : sound, { rate: o?.rate }))\n    },\n    [sound],\n  )\n}\n\nexport function NumberInput({\n  value: valueProp,\n  defaultValue = null,\n  onValueChange,\n  onChange,\n  min,\n  max,\n  step = 1,\n  largeStep,\n  format,\n  locale: localeProp,\n  clampOnBlur = true,\n  holdToRepeat = true,\n  wheel = true,\n  sound,\n  steppers = \"end\",\n  align,\n  variant = \"outline\",\n  tone = \"primary\",\n  size = \"md\",\n  shape = \"rounded\",\n  shadow = \"none\",\n  animation = \"ring\",\n  stepAnimation = \"slide\",\n  label,\n  description,\n  message,\n  invalid: invalidProp,\n  leading,\n  trailing,\n  fullWidth,\n  className,\n  fieldClassName,\n  labels,\n  id,\n  name,\n  disabled,\n  readOnly,\n  placeholder,\n  onFocus,\n  onBlur,\n  onKeyDown,\n  ref: refProp,\n  \"aria-label\": ariaLabel,\n  ...props\n}: NumberInputProps) {\n  const l = useLabels(\"number-input\", DEFAULT_LABELS, labels)\n  const autoId = React.useId()\n  const inputId = id ?? autoId\n  const msgId = `${inputId}-msg`\n  const ref = React.useRef<HTMLInputElement>(null)\n  const setRef = React.useCallback(\n    (el: HTMLInputElement | null) => {\n      ref.current = el\n      if (typeof refProp === \"function\") refProp(el)\n      else if (refProp) refProp.current = el\n    },\n    [refProp],\n  )\n\n  // The browser locale is only known after mount; render \"en-US\" first so server and client markup match.\n  const [browserLocale, setBrowserLocale] = React.useState<string | undefined>(undefined)\n  React.useEffect(() => setBrowserLocale(navigator.language), [])\n  const provider = useGooduiLocale()\n  const locale = localeProp ?? (provider.provided ? provider.lang : browserLocale) ?? \"en-US\"\n  const percent = format?.style === \"percent\"\n  const fmt = React.useMemo(() => {\n    try {\n      return new Intl.NumberFormat(locale, format)\n    } catch {\n      return new Intl.NumberFormat(\"en-US\", format)\n    }\n  }, [locale, format])\n  const plain = React.useMemo(() => new Intl.NumberFormat(locale, { useGrouping: false, maximumFractionDigits: 10 }), [locale])\n  const decimalSep = React.useMemo(() => plain.formatToParts(1.5).find((p) => p.type === \"decimal\")?.value ?? \".\", [plain])\n\n  const [inner, setInner] = React.useState<number | null>(defaultValue)\n  const value = valueProp !== undefined ? valueProp : inner\n  const valueRef = React.useRef(value)\n  valueRef.current = value\n  const [draft, setDraft] = React.useState<string | null>(null)\n  const focusValue = React.useRef<number | null>(null)\n\n  const clamp = (n: number) => Math.min(max ?? Infinity, Math.max(min ?? -Infinity, n))\n  const toEdit = (n: number | null) => (n == null ? \"\" : plain.format(percent ? Number((n * 100).toPrecision(12)) : n))\n  const parse = (text: string): number | null => {\n    let t = text.replace(/[\\s  ]/g, \"\").replace(/−/g, \"-\")\n    if (decimalSep !== \".\" && !t.includes(decimalSep) && /\\.\\d{1,2}$/.test(t)) t = t.replace(\".\", decimalSep)\n    t = t.split(decimalSep).map((part) => part.replace(/[^\\d-]/g, \"\")).join(\".\")\n    if (!t || t === \"-\" || t === \".\") return null\n    const n = Number.parseFloat(t)\n    if (!Number.isFinite(n)) return null\n    return percent ? Number((n / 100).toPrecision(12)) : n\n  }\n\n  const set = (n: number | null) => {\n    valueRef.current = n\n    if (valueProp === undefined) setInner(n)\n    onValueChange?.(n)\n  }\n\n  const cue = useCue(sound)\n\n  const bump = (dir: 1 | -1) => {\n    const el = ref.current\n    if (stepAnimation === \"none\" || !el || typeof el.animate !== \"function\") return\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return\n    const frames =\n      stepAnimation === \"slide\"\n        ? [{ transform: `translateY(${dir > 0 ? 7 : -7}px)`, opacity: 0.25 }, { transform: \"translateY(0)\", opacity: 1 }]\n        : [{ transform: \"scale(1)\" }, { transform: \"scale(1.09)\" }, { transform: \"scale(1)\" }]\n    el.animate(frames, { duration: stepAnimation === \"slide\" ? 170 : 220, easing: \"cubic-bezier(.23,1,.32,1)\" })\n  }\n\n  /** Steps from the current (or typed) value; returns false when nothing changed (at a bound). */\n  const stepBy = (dir: 1 | -1, amount = step): boolean => {\n    if (disabled || readOnly) return false\n    const typed = draft != null ? parse(draft) : null\n    const cur = typed ?? valueRef.current\n    const next = cur == null ? clamp(min != null && min > 0 ? min : 0) : clamp(addExact(cur, dir * amount))\n    if (cur != null && next === cur) return false\n    set(next)\n    if (draft != null) setDraft(toEdit(next))\n    bump(dir)\n    cue(\"tick\", { rate: dir > 0 ? 1.08 : 0.92 })\n    return true\n  }\n  const stepRef = React.useRef(stepBy)\n  stepRef.current = stepBy\n\n  // Press-and-hold: one step at once, then repeat after 400 ms, speeding up from ~7 to ~35 steps per second.\n  const hold = React.useRef<{ t?: ReturnType<typeof setTimeout>; n: number; stop?: () => void }>({ n: 0 })\n  const stopHold = React.useCallback(() => {\n    clearTimeout(hold.current.t)\n    hold.current.t = undefined\n    hold.current.stop?.()\n    hold.current.stop = undefined\n  }, [])\n  React.useEffect(() => stopHold, [stopHold])\n  const startHold = (dir: 1 | -1) => {\n    stopHold()\n    if (!stepRef.current(dir) || !holdToRepeat) return\n    hold.current.n = 0\n    const end = () => stopHold()\n    window.addEventListener(\"pointerup\", end)\n    window.addEventListener(\"pointercancel\", end)\n    window.addEventListener(\"blur\", end)\n    hold.current.stop = () => {\n      window.removeEventListener(\"pointerup\", end)\n      window.removeEventListener(\"pointercancel\", end)\n      window.removeEventListener(\"blur\", end)\n    }\n    const tick = () => {\n      const n = ++hold.current.n\n      if (!stepRef.current(dir)) return stopHold()\n      hold.current.t = setTimeout(tick, Math.max(28, 140 * 0.9 ** n))\n    }\n    hold.current.t = setTimeout(tick, 400)\n  }\n\n  // React's onWheel is passive, so preventDefault needs a native listener. Only while focused, so pages still scroll.\n  React.useEffect(() => {\n    const el = ref.current\n    if (!el || !wheel) return\n    const onWheel = (e: WheelEvent) => {\n      if (document.activeElement !== el || e.deltaY === 0) return\n      e.preventDefault()\n      stepRef.current(e.deltaY < 0 ? 1 : -1, e.shiftKey ? (largeStep ?? step * 10) : step)\n    }\n    el.addEventListener(\"wheel\", onWheel, { passive: false })\n    return () => el.removeEventListener(\"wheel\", onWheel)\n  }, [wheel, largeStep, step])\n\n  const commit = (keepEditing: boolean) => {\n    if (draft == null) return\n    let n = parse(draft)\n    if (n != null && clampOnBlur) n = clamp(n)\n    if (n !== valueRef.current) set(n)\n    setDraft(keepEditing ? toEdit(n) : null)\n  }\n\n  const outOfRange = value != null && ((min != null && value < min) || (max != null && value > max))\n  const invalid = !!invalidProp || outOfRange\n  const formatted = value == null ? \"\" : fmt.format(value)\n  const shown = draft ?? formatted\n  const atMin = value != null && min != null && value <= min\n  const atMax = value != null && max != null && value >= max\n  const alignment = align ?? (steppers === \"split\" ? \"center\" : \"start\")\n  const hasMsg = invalid && !!message\n\n  const btn = (dir: 1 | -1, extra: string, icon: React.ReactNode) => (\n    <button\n      type=\"button\"\n      tabIndex={-1}\n      aria-label={dir > 0 ? l.increment : l.decrement}\n      aria-controls={inputId}\n      disabled={disabled || readOnly || (dir > 0 ? atMax : atMin)}\n      data-slot={dir > 0 ? \"increment\" : \"decrement\"}\n      onPointerDown={(e) => {\n        if (e.button !== 0) return\n        e.preventDefault()\n        startHold(dir)\n      }}\n      onPointerLeave={stopHold}\n      onClick={(e) => {\n        // Keyboard and assistive-tech activation (no pointer) still steps once.\n        if (e.detail === 0) stepBy(dir)\n      }}\n      onContextMenu={(e) => e.preventDefault()}\n      className={cn(\"pc-press pc-num-btn grid shrink-0 cursor-pointer place-items-center outline-none select-none\", extra)}\n    >\n      {icon}\n    </button>\n  )\n\n  const side = (node: React.ReactNode, slot: string) =>\n    node ? (\n      <span data-slot={slot} className=\"inline-flex shrink-0 items-center whitespace-nowrap text-[var(--pc-muted)]\">\n        {node}\n      </span>\n    ) : null\n\n  return (\n    <>\n      <GooduiTokens />\n      <style href=\"pc-number-input\" precedence=\"default\">\n        {CSS}\n      </style>\n      <div\n        data-slot=\"number-input\"\n        data-variant={variant}\n        data-tone={tone}\n        data-anim={animation}\n        data-shadow={variant === \"neo\" ? \"none\" : shadow}\n        data-steppers={steppers}\n        data-invalid={invalid ? \"\" : undefined}\n        className={cn(\"pc-num flex max-w-full flex-col gap-1.5\", fullWidth ? \"w-full\" : WIDTH[size], disabled && \"opacity-60\", className)}\n      >\n        {label && (\n          <label htmlFor={inputId} className=\"text-sm leading-none font-medium\">\n            {label}\n          </label>\n        )}\n        <div\n          data-slot=\"field\"\n          onPointerDown={(e) => {\n            if (e.target === e.currentTarget) {\n              e.preventDefault()\n              ref.current?.focus()\n            }\n          }}\n          className={cn(\"pc-num-field flex cursor-text items-stretch overflow-hidden\", H[size], SHAPES[shape], fieldClassName)}\n        >\n          {steppers === \"split\" && btn(-1, cn(BTN[size], \"border-e\", variant === \"neo\" && \"border-e-2\"), <Minus />)}\n          <div className={cn(\"flex min-w-0 flex-1 items-center\", PAD[size], SVG[size], \"[&_svg]:shrink-0\", steppers === \"split\" && shape === \"pill\" && \"px-1\")}>\n            {side(leading, \"leading\")}\n            <input\n              {...props}\n              ref={setRef}\n              id={inputId}\n              type=\"text\"\n              role=\"spinbutton\"\n              inputMode={step % 1 === 0 && (min ?? -1) >= 0 && !percent ? \"numeric\" : \"decimal\"}\n              autoComplete=\"off\"\n              autoCorrect=\"off\"\n              spellCheck={false}\n              value={shown}\n              placeholder={placeholder}\n              disabled={disabled}\n              readOnly={readOnly}\n              aria-label={ariaLabel}\n              aria-valuenow={value ?? undefined}\n              aria-valuemin={min}\n              aria-valuemax={max}\n              aria-valuetext={formatted || undefined}\n              aria-invalid={invalid || undefined}\n              aria-describedby={hasMsg || description ? msgId : undefined}\n              onFocus={(e) => {\n                focusValue.current = valueRef.current\n                if (!readOnly) setDraft(toEdit(valueRef.current))\n                onFocus?.(e)\n              }}\n              onBlur={(e) => {\n                commit(false)\n                onBlur?.(e)\n              }}\n              onChange={(e) => {\n                const text = e.target.value.replace(/[^\\d.,\\-−\\s]/g, \"\")\n                setDraft(text)\n                const n = parse(text)\n                if (n !== valueRef.current && (n != null || text.trim() === \"\")) set(n)\n                onChange?.(e)\n              }}\n              onKeyDown={(e) => {\n                onKeyDown?.(e)\n                if (e.defaultPrevented) return\n                const large = largeStep ?? step * 10\n                const run = (fn: () => void) => {\n                  e.preventDefault()\n                  fn()\n                }\n                if (e.key === \"ArrowUp\") run(() => stepBy(1, e.shiftKey ? large : step))\n                else if (e.key === \"ArrowDown\") run(() => stepBy(-1, e.shiftKey ? large : step))\n                else if (e.key === \"PageUp\") run(() => stepBy(1, large))\n                else if (e.key === \"PageDown\") run(() => stepBy(-1, large))\n                else if (e.key === \"Home\" && min != null && !readOnly) {\n                  run(() => {\n                    set(min)\n                    setDraft(toEdit(min))\n                  })\n                } else if (e.key === \"End\" && max != null && !readOnly) {\n                  run(() => {\n                    set(max)\n                    setDraft(toEdit(max))\n                  })\n                } else if (e.key === \"Enter\") commit(true)\n                else if (e.key === \"Escape\" && draft != null) {\n                  run(() => {\n                    set(focusValue.current)\n                    setDraft(toEdit(focusValue.current))\n                  })\n                }\n              }}\n              className={cn(\"pc-num-control self-stretch\", alignment === \"center\" ? \"text-center\" : alignment === \"end\" ? \"text-end\" : \"text-start\")}\n            />\n            {side(trailing, \"trailing\")}\n          </div>\n          {steppers === \"split\" && btn(1, cn(BTN[size], \"border-s\", variant === \"neo\" && \"border-s-2\"), <Plus />)}\n          {steppers === \"end\" && (\n            <>\n              {btn(-1, cn(BTN[size], \"border-s\", variant === \"neo\" && \"border-s-2\"), <Minus />)}\n              {btn(1, cn(BTN[size], \"border-s\", variant === \"neo\" && \"border-s-2\"), <Plus />)}\n            </>\n          )}\n          {steppers === \"stacked\" && (\n            <div className={cn(\"flex shrink-0 flex-col border-s border-[var(--pc-sep)]\", variant === \"neo\" && \"border-s-2\")}>\n              {btn(1, cn(STACK[size], \"flex-1 border-b\", variant === \"neo\" && \"border-b-2\"), <ChevronUp />)}\n              {btn(-1, cn(STACK[size], \"flex-1\"), <ChevronDown />)}\n            </div>\n          )}\n        </div>\n        {(hasMsg || description) && (\n          <p id={msgId} aria-live=\"polite\" className={cn(\"text-xs\", hasMsg ? \"pc-num-msg font-medium\" : \"pc-num-desc\")}>\n            {hasMsg ? message : description}\n          </p>\n        )}\n        {name && <input type=\"hidden\" name={name} value={value ?? \"\"} />}\n      </div>\n    </>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/number-input.tsx"
    }
  ],
  "categories": [
    "components",
    "core"
  ],
  "type": "registry:component"
}