{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "wheel-picker",
  "title": "Wheel Picker",
  "description": "An iOS-style scroll wheel that coasts with inertia and settles on a row, with a detent tick and a haptic tap for every row that passes the centre.",
  "dependencies": [
    "@rexa-developer/tiks",
    "motion",
    "web-haptics"
  ],
  "files": [
    {
      "path": "src/registry/components/wheel-picker/wheel-picker.tsx",
      "content": "\"use client\";\n\nimport { useTiks } from \"@rexa-developer/tiks/react\";\nimport {\n\ttype AnimationPlaybackControls,\n\tanimate,\n\tuseMotionValue,\n\tuseReducedMotion,\n} from \"motion/react\";\nimport {\n\tChildren,\n\ttype CSSProperties,\n\tcreateContext,\n\tisValidElement,\n\ttype KeyboardEvent,\n\ttype PointerEvent,\n\ttype ReactNode,\n\tuseContext,\n\tuseEffect,\n\tuseId,\n\tuseLayoutEffect,\n\tuseReducer,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport { useWebHaptics } from \"web-haptics/react\";\nimport { cn } from \"@/lib/utils\";\n\n/** Critically damped: it only overshoots when a flick lands fast. */\nconst settleSpring = {\n\ttype: \"spring\",\n\tstiffness: 320,\n\tdamping: 36,\n\trestDelta: 0.002,\n\trestSpeed: 0.05,\n} as const;\nconst reducedSnap = { duration: 0.12, ease: \"easeOut\" } as const;\n\n/** Minimum ms between detent clicks. */\nconst TICK_THROTTLE_MS = 28;\n/** Minimum ms between selection haptics. */\nconst HAPTIC_THROTTLE_MS = 45;\n/** Ms of pointer samples used for the release velocity. */\nconst VELOCITY_WINDOW_MS = 80;\n/** Fastest coast, in px/s, so a jumpy pointer event can't fling a long list. */\nconst MAX_VELOCITY_PX = 5000;\n/** Rows/s below which a coast hands over to the snap spring. */\nconst SNAP_SPEED = 6;\n/** Fastest rows/s carried into the bounce at a non-looping end. */\nconst EDGE_SPEED = 12;\n/** Ms without wheel events before a trackpad scroll settles. */\nconst WHEEL_IDLE_MS = 120;\n/** Wheel deltas at least this large, in px, count as one notch. */\nconst WHEEL_NOTCH_PX = 50;\n/** Pointer travel, in px, below which a press counts as a tap. */\nconst TAP_SLOP = 5;\n/** Ms after the last key before type-ahead starts a new search. */\nconst TYPEAHEAD_RESET_MS = 500;\n/** Opacity lost by a row turned 90 degrees away. */\nconst EDGE_FADE = 0.5;\n\nconst sizes = {\n\tsm: { rowHeight: 32, text: \"text-sm\", padding: \"px-3\" },\n\tmd: { rowHeight: 40, text: \"text-base\", padding: \"px-4\" },\n\tlg: { rowHeight: 48, text: \"text-lg\", padding: \"px-5\" },\n} as const;\n\nexport interface WheelPickerOption {\n\t/** Unique value reported by `onValueChange`. */\n\tvalue: string;\n\t/** What the row shows. */\n\tlabel: ReactNode;\n\t/** Text for type-ahead and screen readers when `label` is not a string. */\n\ttextValue?: string;\n\t/** Shown muted; the wheel never settles on it. */\n\tdisabled?: boolean;\n}\n\nexport interface WheelPickerProps {\n\toptions: WheelPickerOption[];\n\t/** Controlled value. */\n\tvalue?: string;\n\t/** Initial value when uncontrolled. */\n\tdefaultValue?: string;\n\t/** Called once each time the wheel settles on a new value, and on each key that moves it. */\n\tonValueChange?: (value: string) => void;\n\t/** Called for each enabled row that crosses the centre while the user scrolls. */\n\tonScrollValue?: (value: string) => void;\n\t/** Wrap the list endlessly. Ignored when there are fewer options than `visibleCount`. */\n\tloop?: boolean;\n\t/** Rows shown on the drum. */\n\tvisibleCount?: 3 | 5 | 7 | 9;\n\t/** Row height in px. Defaults by `size`: 32, 40, and 48. */\n\trowHeight?: number;\n\tsize?: keyof typeof sizes;\n\t/** Share of speed kept per 16 ms frame while coasting, from 0.8 to 0.98. */\n\tfriction?: number;\n\t/** Play a click per row and a pop when the wheel settles. */\n\tsound?: boolean;\n\t/** Trigger haptics on supported devices. */\n\thaptics?: boolean;\n\tdisabled?: boolean;\n\t\"aria-label\"?: string;\n\t\"aria-labelledby\"?: string;\n\tclassName?: string;\n\t/** `highlight` styles the band of a standalone wheel; in a group the group draws it. */\n\tclassNames?: {\n\t\troot?: string;\n\t\thighlight?: string;\n\t\toption?: string;\n\t\toptionSelected?: string;\n\t};\n}\n\nexport interface WheelPickerGroupProps {\n\t/** `WheelPicker` elements, laid out in document direction. */\n\tchildren?: ReactNode;\n\t\"aria-label\"?: string;\n\t\"aria-labelledby\"?: string;\n\tclassName?: string;\n}\n\ntype Phase = \"idle\" | \"dragging\" | \"coasting\" | \"scrolling\" | \"settling\";\n\ntype Geometry = {\n\tcount: number;\n\tloop: boolean;\n\trowHeight: number;\n\t/** Drum radius in px. */\n\tradius: number;\n\t/** Radians per row. */\n\tangle: number;\n\tperspective: number;\n\t/** Furthest row offset that is drawn. */\n\treach: number;\n\tflat: boolean;\n};\n\ntype MoveOptions = {\n\tsilent?: boolean;\n\tvelocity?: number;\n\tmode?: \"spring\" | \"ease\" | \"instant\";\n\t/** Commit the landing row; key moves commit up front instead. */\n\tcommitOnDone?: boolean;\n\t/** Pop and tap when a gesture lands after crossing rows. */\n\tcue?: boolean;\n};\n\nfunction clamp(value: number, min: number, max: number) {\n\treturn Math.min(Math.max(value, min), max);\n}\n\nfunction mod(value: number, size: number) {\n\treturn ((value % size) + size) % size;\n}\n\nfunction getGeometry(\n\tcount: number,\n\tloop: boolean,\n\trowHeight: number,\n\tvisibleCount: number,\n\tflat: boolean,\n): Geometry {\n\t// The drum spans the frame, and the centre row keeps its full height.\n\tconst radius = (visibleCount * rowHeight) / 2;\n\tconst angle = rowHeight / radius;\n\treturn {\n\t\tcount,\n\t\tloop,\n\t\trowHeight,\n\t\tradius,\n\t\tangle,\n\t\tperspective: radius * 5,\n\t\treach: flat ? visibleCount / 2 + 1 : Math.PI / 2 / angle,\n\t\tflat,\n\t};\n}\n\nfunction rowTransform(offset: number, geometry: Geometry) {\n\tif (geometry.flat) {\n\t\treturn `translateY(${(offset * geometry.rowHeight).toFixed(2)}px)`;\n\t}\n\tconst { radius } = geometry;\n\tconst angle = (-offset * geometry.angle).toFixed(4);\n\treturn `translateZ(${-radius}px) rotateX(${angle}rad) translateZ(${radius}px)`;\n}\n\nfunction rowOpacity(offset: number, geometry: Geometry) {\n\tconst t = Math.min(Math.abs(offset) / geometry.reach, 1);\n\treturn (1 - EDGE_FADE * t * t).toFixed(3);\n}\n\n/** Where a row's centre lands on screen, in px from the drum centre. */\nfunction projectY(offset: number, geometry: Geometry) {\n\tif (geometry.flat) return offset * geometry.rowHeight;\n\tconst { radius, perspective } = geometry;\n\tconst phi = offset * geometry.angle;\n\tconst depth = radius * Math.cos(phi) - radius;\n\treturn (radius * Math.sin(phi) * perspective) / (perspective - depth);\n}\n\nfunction textOf(option: WheelPickerOption) {\n\tif (option.textValue !== undefined) return option.textValue;\n\tif (typeof option.label === \"string\" || typeof option.label === \"number\") {\n\t\treturn String(option.label);\n\t}\n\treturn option.value;\n}\n\n/** Ends of the drag range, pulled back so they never pass `limit` rows. */\nfunction rubberBand(raw: number, lower: number, upper: number, limit: number) {\n\tif (raw < lower) {\n\t\tconst over = lower - raw;\n\t\treturn lower - (limit * over) / (over + limit);\n\t}\n\tif (raw > upper) {\n\t\tconst over = raw - upper;\n\t\treturn upper + (limit * over) / (over + limit);\n\t}\n\treturn raw;\n}\n\nconst WheelPickerGroupContext = createContext(false);\n\nexport function WheelPicker({\n\toptions,\n\tvalue: valueProp,\n\tdefaultValue,\n\tonValueChange,\n\tonScrollValue,\n\tloop = false,\n\tvisibleCount = 5,\n\trowHeight: rowHeightProp,\n\tsize = \"md\",\n\tfriction: frictionProp = 0.92,\n\tsound = true,\n\thaptics = true,\n\tdisabled = false,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledBy,\n\tclassName,\n\tclassNames,\n}: WheelPickerProps) {\n\tconst inGroup = useContext(WheelPickerGroupContext);\n\tconst sizeStyle = sizes[size];\n\tconst rowHeight = Math.max(1, rowHeightProp ?? sizeStyle.rowHeight);\n\tconst friction = clamp(frictionProp, 0.8, 0.98);\n\tconst count = options.length;\n\t// Wrapping fewer rows than the drum shows would draw duplicates.\n\tconst looping = loop && count >= visibleCount;\n\tconst shouldReduceMotion = useReducedMotion() ?? false;\n\tconst geometry = getGeometry(\n\t\tcount,\n\t\tlooping,\n\t\trowHeight,\n\t\tvisibleCount,\n\t\tshouldReduceMotion,\n\t);\n\n\tlet firstEnabled = -1;\n\tlet lastEnabled = -1;\n\toptions.forEach((option, index) => {\n\t\tif (option.disabled) return;\n\t\tif (firstEnabled < 0) firstEnabled = index;\n\t\tlastEnabled = index;\n\t});\n\tconst interactive = !disabled && count > 1 && firstEnabled >= 0;\n\n\tconst controlled = valueProp !== undefined;\n\tconst [internalValue, setInternalValue] = useState(defaultValue);\n\tconst value = controlled ? valueProp : internalValue;\n\tconst matched = options.findIndex(\n\t\t(option) => option.value === value && !option.disabled,\n\t);\n\t// A value that isn't an enabled option shows the first enabled one.\n\tconst selectedIndex =\n\t\tmatched >= 0 ? matched : firstEnabled >= 0 ? firstEnabled : count ? 0 : -1;\n\tconst restIndex = Math.max(selectedIndex, 0);\n\n\tconst [, forceRender] = useReducer((n: number) => n + 1, 0);\n\tconst { trigger: haptic } = useWebHaptics();\n\tconst { click: playClick, pop: playPop } = useTiks({\n\t\t// Sound stays on under reduced motion; only movement is reduced.\n\t\trespectReducedMotion: false,\n\t});\n\n\tconst id = useId();\n\tconst rootRef = useRef<HTMLDivElement>(null);\n\tconst drumRowRefs = useRef<(HTMLDivElement | null)[]>([]);\n\tconst bandRowRefs = useRef<(HTMLDivElement | null)[]>([]);\n\tconst position = useMotionValue(restIndex);\n\tconst geometryRef = useRef(geometry);\n\tconst selectedRef = useRef(selectedIndex);\n\tconst syncedRef = useRef(selectedIndex);\n\tconst reportedRef = useRef(options[selectedIndex]?.value);\n\t/** Absolute row the wheel rests on or is heading to; null while free. */\n\tconst targetRef = useRef<number | null>(restIndex);\n\tconst phaseRef = useRef<Phase>(\"idle\");\n\tconst sourceRef = useRef<\"user\" | \"program\">(\"program\");\n\tconst animationRef = useRef<AnimationPlaybackControls | null>(null);\n\tconst frameRef = useRef(0);\n\tconst mountedRef = useRef(false);\n\tconst normalizingRef = useRef(false);\n\tconst centreRef = useRef(restIndex);\n\tconst crossedRef = useRef(false);\n\tconst overEdgeRef = useRef(false);\n\tconst lastTickAtRef = useRef(Number.NEGATIVE_INFINITY);\n\tconst lastHapticAtRef = useRef(Number.NEGATIVE_INFINITY);\n\tconst stampsRef = useRef<number[]>([]);\n\tconst generationRef = useRef(0);\n\tconst shownRef = useRef<number[]>([]);\n\tconst wheelRef = useRef<{\n\t\tactive: boolean;\n\t\traw: number;\n\t\ttimer?: ReturnType<typeof setTimeout>;\n\t}>({ active: false, raw: 0 });\n\tconst typeaheadRef = useRef<{\n\t\ttext: string;\n\t\ttimer?: ReturnType<typeof setTimeout>;\n\t}>({ text: \"\" });\n\tconst dragRef = useRef<{\n\t\tpointerId: number;\n\t\tstartY: number;\n\t\tstartPosition: number;\n\t\tscale: number;\n\t\tmoved: boolean;\n\t\twasMoving: boolean;\n\t\tsamples: { t: number; p: number }[];\n\t} | null>(null);\n\n\tconst wrap = (row: number) => (looping ? mod(row, count) : row);\n\tconst isEnabled = (row: number) => {\n\t\tconst index = wrap(row);\n\t\treturn index >= 0 && index < count && !options[index].disabled;\n\t};\n\tconst quiet = () =>\n\t\ttypeof document !== \"undefined\" && document.visibilityState === \"hidden\";\n\n\t/** Closest enabled row to a resting point. */\n\tconst nearestEnabled = (point: number) => {\n\t\tconst anchor = looping ? point : clamp(point, firstEnabled, lastEnabled);\n\t\tconst centre = Math.round(anchor);\n\t\tfor (let step = 0; step <= count; step++) {\n\t\t\tconst below = centre - step;\n\t\t\tconst above = centre + step;\n\t\t\tconst pair =\n\t\t\t\tMath.abs(below - anchor) <= Math.abs(above - anchor)\n\t\t\t\t\t? [below, above]\n\t\t\t\t\t: [above, below];\n\t\t\tfor (const row of pair) if (isEnabled(row)) return row;\n\t\t}\n\t\treturn centre;\n\t};\n\n\t/** Moves `rows` rows in `direction`, then on to the next enabled row. */\n\tconst stepEnabled = (from: number, direction: number, rows: number) => {\n\t\tlet start = from + direction * rows;\n\t\tif (!looping) start = clamp(start, firstEnabled, lastEnabled);\n\t\tfor (let step = 0; step < count; step++) {\n\t\t\tconst row = start + direction * step;\n\t\t\tif (!looping && (row < firstEnabled || row > lastEnabled)) break;\n\t\t\tif (isEnabled(row)) return row;\n\t\t}\n\t\tfor (let step = 1; step < count; step++) {\n\t\t\tconst row = start - direction * step;\n\t\t\tif (direction * (row - from) <= 0) break;\n\t\t\tif (isEnabled(row)) return row;\n\t\t}\n\t\treturn from;\n\t};\n\n\t/** The absolute row for `index` along the shortest way round. */\n\tconst nearestRowFor = (index: number) => {\n\t\tif (!looping) return index;\n\t\tconst base = Math.round(position.get());\n\t\tlet delta = mod(index - base, count);\n\t\tif (delta > count / 2) delta -= count;\n\t\treturn base + delta;\n\t};\n\n\tconst setPhase = (phase: Phase) => {\n\t\tphaseRef.current = phase;\n\t\tif (rootRef.current) rootRef.current.dataset.state = phase;\n\t};\n\n\t// Rows are drawn imperatively so drag and coast never re-render.\n\tconst placeRows = (pos: number, all: boolean) => {\n\t\tconst geo = geometryRef.current;\n\t\tconst drumRows = drumRowRefs.current;\n\t\tconst bandRows = bandRowRefs.current;\n\t\tconst stamps = stampsRef.current;\n\t\tconst generation = ++generationRef.current;\n\t\tconst shown: number[] = [];\n\t\tconst centre = Math.round(pos);\n\t\tconst span = Math.ceil(geo.reach) * 2;\n\t\t// Nearest rows first, so a short looping list draws each row once.\n\t\tfor (let step = 0; step <= span && geo.count; step++) {\n\t\t\tconst row = centre + (step % 2 ? (step + 1) / 2 : -step / 2);\n\t\t\tconst offset = row - pos;\n\t\t\tif (Math.abs(offset) > geo.reach) continue;\n\t\t\tconst index = geo.loop ? mod(row, geo.count) : row;\n\t\t\tif (index < 0 || index >= geo.count || stamps[index] === generation) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tstamps[index] = generation;\n\t\t\tshown.push(index);\n\t\t\tconst transform = rowTransform(offset, geo);\n\t\t\tconst drumRow = drumRows[index];\n\t\t\tif (drumRow) {\n\t\t\t\tdrumRow.style.transform = transform;\n\t\t\t\tdrumRow.style.opacity = rowOpacity(offset, geo);\n\t\t\t\tdrumRow.style.visibility = \"\";\n\t\t\t\tdrumRow.removeAttribute(\"aria-hidden\");\n\t\t\t}\n\t\t\tconst bandRow = bandRows[index];\n\t\t\tif (bandRow) {\n\t\t\t\tconst inBand = Math.abs(offset) < 1;\n\t\t\t\tbandRow.style.visibility = inBand ? \"\" : \"hidden\";\n\t\t\t\tif (inBand) bandRow.style.transform = transform;\n\t\t\t}\n\t\t}\n\t\t// The selected option stays in the accessibility tree for\n\t\t// aria-activedescendant, even while a long jump carries it off the drum.\n\t\tconst selected = selectedRef.current;\n\t\tif (\n\t\t\tselected >= 0 &&\n\t\t\tselected < geo.count &&\n\t\t\tstamps[selected] !== generation\n\t\t) {\n\t\t\tstamps[selected] = generation;\n\t\t\tshown.push(selected);\n\t\t\tconst drumRow = drumRows[selected];\n\t\t\tif (drumRow) {\n\t\t\t\tdrumRow.style.visibility = \"\";\n\t\t\t\tdrumRow.style.opacity = \"0\";\n\t\t\t\tdrumRow.removeAttribute(\"aria-hidden\");\n\t\t\t}\n\t\t\tconst bandRow = bandRows[selected];\n\t\t\tif (bandRow) bandRow.style.visibility = \"hidden\";\n\t\t}\n\t\tconst previous = all ? drumRows.map((_, index) => index) : shownRef.current;\n\t\tfor (const index of previous) {\n\t\t\tif (stamps[index] === generation) continue;\n\t\t\tconst drumRow = drumRows[index];\n\t\t\tif (drumRow) {\n\t\t\t\tdrumRow.style.visibility = \"hidden\";\n\t\t\t\tdrumRow.setAttribute(\"aria-hidden\", \"true\");\n\t\t\t}\n\t\t\tconst bandRow = bandRows[index];\n\t\t\tif (bandRow) bandRow.style.visibility = \"hidden\";\n\t\t}\n\t\tshownRef.current = shown;\n\t};\n\n\tconst cueTick = () => {\n\t\tif (quiet()) return;\n\t\tconst now = performance.now();\n\t\t// Ticks that come too fast are dropped, never queued, like a ratchet.\n\t\tif (sound && now - lastTickAtRef.current >= TICK_THROTTLE_MS) {\n\t\t\tlastTickAtRef.current = now;\n\t\t\tplayClick();\n\t\t}\n\t\tif (haptics && now - lastHapticAtRef.current >= HAPTIC_THROTTLE_MS) {\n\t\t\tlastHapticAtRef.current = now;\n\t\t\tvoid haptic(\"selection\");\n\t\t}\n\t};\n\n\tconst cueSettle = () => {\n\t\tif (quiet()) return;\n\t\tif (sound) playPop();\n\t\tif (haptics) void haptic(\"light\");\n\t};\n\n\tconst cueEdge = (over: boolean) => {\n\t\tif (over && !overEdgeRef.current && haptics && !quiet()) {\n\t\t\tvoid haptic(\"rigid\");\n\t\t}\n\t\toverEdgeRef.current = over;\n\t};\n\n\t// The one place that reacts to movement: rows, ticks, and onScrollValue.\n\tconst sync = (pos: number) => {\n\t\tplaceRows(pos, false);\n\t\tif (!count) return;\n\t\tconst centre = looping\n\t\t\t? Math.round(pos)\n\t\t\t: clamp(Math.round(pos), 0, count - 1);\n\t\tif (normalizingRef.current) {\n\t\t\tcentreRef.current = centre;\n\t\t\treturn;\n\t\t}\n\t\tconst previous = centreRef.current;\n\t\tif (centre === previous) return;\n\t\tcentreRef.current = centre;\n\t\tif (sourceRef.current !== \"user\") return;\n\t\tcrossedRef.current = true;\n\t\tif (onScrollValue) {\n\t\t\tconst direction = Math.sign(centre - previous);\n\t\t\tconst crossed = Math.min(Math.abs(centre - previous), count);\n\t\t\tfor (let step = crossed - 1; step >= 0; step--) {\n\t\t\t\tconst option = options[wrap(centre - direction * step)];\n\t\t\t\tif (option && !option.disabled) onScrollValue(option.value);\n\t\t\t}\n\t\t}\n\t\tcueTick();\n\t};\n\n\tconst stopAnimation = () => {\n\t\tanimationRef.current?.stop();\n\t\tanimationRef.current = null;\n\t\tcancelAnimationFrame(frameRef.current);\n\t};\n\n\tconst resetWheel = () => {\n\t\tclearTimeout(wheelRef.current.timer);\n\t\twheelRef.current.active = false;\n\t};\n\n\tconst commit = (row: number) => {\n\t\tconst option = options[wrap(row)];\n\t\tif (!option || option.disabled) return;\n\t\tif (!controlled) setInternalValue(option.value);\n\t\t// Re-render even when unchanged, so a parent that ignores the change\n\t\t// pulls the wheel back to its value.\n\t\tforceRender();\n\t\tif (option.value === reportedRef.current) return;\n\t\treportedRef.current = option.value;\n\t\tonValueChange?.(option.value);\n\t};\n\n\tconst moveTo = (\n\t\ttarget: number,\n\t\t{\n\t\t\tsilent = false,\n\t\t\tvelocity = 0,\n\t\t\tmode = \"spring\",\n\t\t\tcommitOnDone = true,\n\t\t\tcue = false,\n\t\t}: MoveOptions = {},\n\t) => {\n\t\tstopAnimation();\n\t\tresetWheel();\n\t\ttargetRef.current = target;\n\t\tsourceRef.current = silent ? \"program\" : \"user\";\n\t\tconst done = () => {\n\t\t\tanimationRef.current = null;\n\t\t\tif (!mountedRef.current) return;\n\t\t\tsetPhase(\"idle\");\n\t\t\t// Keep a looping wheel's position near zero; the rows look the same.\n\t\t\tconst wrapped = wrap(target);\n\t\t\tif (wrapped !== target) {\n\t\t\t\tnormalizingRef.current = true;\n\t\t\t\tposition.jump(wrapped);\n\t\t\t\tnormalizingRef.current = false;\n\t\t\t\ttargetRef.current = wrapped;\n\t\t\t}\n\t\t\tif (silent) return;\n\t\t\tif (cue && crossedRef.current) cueSettle();\n\t\t\tif (commitOnDone) commit(target);\n\t\t\telse forceRender();\n\t\t};\n\t\tif (mode === \"instant\" || position.get() === target) {\n\t\t\tposition.jump(target);\n\t\t\tdone();\n\t\t\treturn;\n\t\t}\n\t\tsetPhase(\"settling\");\n\t\tanimationRef.current = animate(\n\t\t\tposition,\n\t\t\ttarget,\n\t\t\tmode === \"ease\"\n\t\t\t\t? { ...reducedSnap, onComplete: done }\n\t\t\t\t: { ...settleSpring, velocity, onComplete: done },\n\t\t);\n\t};\n\n\t/** Milliseconds over which coasting speed falls by a factor of e. */\n\tconst decayMs = -16 / Math.log(friction);\n\n\tconst settleNear = (point: number, velocity = 0) => {\n\t\tmoveTo(nearestEnabled(point), {\n\t\t\tvelocity,\n\t\t\tmode: shouldReduceMotion ? \"ease\" : \"spring\",\n\t\t\tcue: true,\n\t\t});\n\t};\n\n\tconst coast = (initial: number) => {\n\t\tsetPhase(\"coasting\");\n\t\ttargetRef.current = null;\n\t\tlet velocity = initial;\n\t\tlet last = performance.now();\n\t\tconst step = (now: number) => {\n\t\t\tconst elapsed = Math.min(now - last, 50);\n\t\t\tlast = now;\n\t\t\tconst decay = friction ** (elapsed / 16);\n\t\t\t// Exact distance covered by exponential friction over the frame.\n\t\t\tconst next = position.get() + velocity * decayMs * (1 - decay);\n\t\t\tvelocity *= decay;\n\t\t\tif (!looping && (next < firstEnabled || next > lastEnabled)) {\n\t\t\t\t// Hit an end: bounce off it with a capped speed.\n\t\t\t\tconst edge = next < firstEnabled ? firstEnabled : lastEnabled;\n\t\t\t\tposition.set(edge);\n\t\t\t\tcueEdge(true);\n\t\t\t\tmoveTo(edge, {\n\t\t\t\t\tvelocity: clamp(velocity * 1000, -EDGE_SPEED, EDGE_SPEED),\n\t\t\t\t\tcue: true,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tposition.set(next);\n\t\t\tif (Math.abs(velocity) * 1000 < SNAP_SPEED) {\n\t\t\t\tsettleNear(next + velocity * decayMs, velocity * 1000);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tframeRef.current = requestAnimationFrame(step);\n\t\t};\n\t\tframeRef.current = requestAnimationFrame(step);\n\t};\n\n\tconst release = (velocity: number) => {\n\t\tconst pos = position.get();\n\t\tif (shouldReduceMotion) {\n\t\t\tsettleNear(pos);\n\t\t\treturn;\n\t\t}\n\t\tconst limit = MAX_VELOCITY_PX / rowHeight / 1000;\n\t\tconst capped = clamp(velocity, -limit, limit);\n\t\tif (!looping && (pos < firstEnabled || pos > lastEnabled)) {\n\t\t\tsettleNear(pos);\n\t\t\treturn;\n\t\t}\n\t\tif (Math.abs(capped) * 1000 < SNAP_SPEED) {\n\t\t\tsettleNear(pos + capped * decayMs, capped * 1000);\n\t\t\treturn;\n\t\t}\n\t\tcoast(capped);\n\t};\n\n\tconst scrollTo = (raw: number) => {\n\t\tif (looping) {\n\t\t\tposition.set(raw);\n\t\t\treturn;\n\t\t}\n\t\tcueEdge(raw < firstEnabled || raw > lastEnabled);\n\t\tposition.set(rubberBand(raw, firstEnabled, lastEnabled, visibleCount / 4));\n\t};\n\n\t/** Row under a point `y` px from the drum centre. */\n\tconst rowAt = (y: number) => {\n\t\tconst pos = position.get();\n\t\tconst centre = Math.round(pos);\n\t\tconst reach = Math.ceil(geometry.reach);\n\t\tlet best: number | null = null;\n\t\tlet bestDistance = rowHeight;\n\t\tfor (let row = centre - reach; row <= centre + reach; row++) {\n\t\t\tconst offset = row - pos;\n\t\t\tif (Math.abs(offset) > geometry.reach) continue;\n\t\t\tif (!looping && (row < 0 || row >= count)) continue;\n\t\t\tconst distance = Math.abs(projectY(offset, geometry) - y);\n\t\t\tif (distance < bestDistance) {\n\t\t\t\tbest = row;\n\t\t\t\tbestDistance = distance;\n\t\t\t}\n\t\t}\n\t\treturn best;\n\t};\n\n\tconst handlePointerDown = (event: PointerEvent<HTMLDivElement>) => {\n\t\tif (!interactive || event.button !== 0) return;\n\t\tconst root = event.currentTarget;\n\t\troot.setPointerCapture(event.pointerId);\n\t\troot.focus({ preventScroll: true });\n\t\tconst wasMoving = phaseRef.current !== \"idle\";\n\t\t// Touching a moving wheel stops it under the finger.\n\t\tstopAnimation();\n\t\tresetWheel();\n\t\tif (wasMoving) {\n\t\t\ttargetRef.current = null;\n\t\t\tsetPhase(\"idle\");\n\t\t}\n\t\tsourceRef.current = \"user\";\n\t\tcrossedRef.current = false;\n\t\toverEdgeRef.current = false;\n\t\tconst rect = root.getBoundingClientRect();\n\t\t// CSS zoom and transforms scale client coordinates; work in local px.\n\t\tconst scale = rect.height / (root.offsetHeight || 1) || 1;\n\t\tdragRef.current = {\n\t\t\tpointerId: event.pointerId,\n\t\t\tstartY: event.clientY,\n\t\t\tstartPosition: position.get(),\n\t\t\tscale,\n\t\t\tmoved: false,\n\t\t\twasMoving,\n\t\t\tsamples: [{ t: event.timeStamp, p: position.get() }],\n\t\t};\n\t};\n\n\tconst handlePointerMove = (event: PointerEvent<HTMLDivElement>) => {\n\t\tconst drag = dragRef.current;\n\t\tif (!drag || drag.pointerId !== event.pointerId) return;\n\t\tconst delta = (event.clientY - drag.startY) / drag.scale;\n\t\tif (!drag.moved) {\n\t\t\tif (Math.abs(delta) < TAP_SLOP) return;\n\t\t\tdrag.moved = true;\n\t\t\ttargetRef.current = null;\n\t\t\tsetPhase(\"dragging\");\n\t\t}\n\t\tconst raw = drag.startPosition - delta / rowHeight;\n\t\tdrag.samples.push({ t: event.timeStamp, p: raw });\n\t\twhile (\n\t\t\tdrag.samples.length > 2 &&\n\t\t\tevent.timeStamp - drag.samples[0].t > VELOCITY_WINDOW_MS\n\t\t) {\n\t\t\tdrag.samples.shift();\n\t\t}\n\t\tscrollTo(raw);\n\t};\n\n\tconst handlePointerUp = (event: PointerEvent<HTMLDivElement>) => {\n\t\tconst drag = dragRef.current;\n\t\tif (!drag || drag.pointerId !== event.pointerId) return;\n\t\tdragRef.current = null;\n\t\tconst root = event.currentTarget;\n\t\tif (root.hasPointerCapture(event.pointerId)) {\n\t\t\troot.releasePointerCapture(event.pointerId);\n\t\t}\n\n\t\tif (!drag.moved) {\n\t\t\tif (drag.wasMoving) {\n\t\t\t\tsettleNear(position.get());\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Tap: scroll the tapped row to the centre.\n\t\t\tconst rect = root.getBoundingClientRect();\n\t\t\tconst y = (event.clientY - rect.top) / drag.scale - root.offsetHeight / 2;\n\t\t\tconst row = rowAt(y);\n\t\t\tif (row === null || !isEnabled(row) || row === targetRef.current) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tmoveTo(row, { mode: shouldReduceMotion ? \"ease\" : \"spring\", cue: true });\n\t\t\treturn;\n\t\t}\n\n\t\tconst recent = drag.samples.filter(\n\t\t\t(sample) => event.timeStamp - sample.t <= VELOCITY_WINDOW_MS,\n\t\t);\n\t\tconst first = recent[0];\n\t\tconst last = recent[recent.length - 1];\n\t\t// A finger that stopped before lifting releases with no speed.\n\t\tconst held = !last || event.timeStamp - last.t > VELOCITY_WINDOW_MS / 2;\n\t\tconst velocity =\n\t\t\theld || recent.length < 2 || last.t === first.t\n\t\t\t\t? 0\n\t\t\t\t: (last.p - first.p) / (last.t - first.t);\n\t\trelease(velocity);\n\t};\n\n\tconst handlePointerCancel = (event: PointerEvent<HTMLDivElement>) => {\n\t\tif (dragRef.current?.pointerId !== event.pointerId) return;\n\t\tdragRef.current = null;\n\t\tsettleNear(position.get());\n\t};\n\n\tconst typeahead = (key: string, base: number) => {\n\t\tconst search = typeaheadRef.current;\n\t\tclearTimeout(search.timer);\n\t\tsearch.text += key.toLowerCase();\n\t\tsearch.timer = setTimeout(() => {\n\t\t\tsearch.text = \"\";\n\t\t}, TYPEAHEAD_RESET_MS);\n\t\tconst from = wrap(base);\n\t\tconst find = (query: string, skip: number) => {\n\t\t\tfor (let step = skip; step < count + skip; step++) {\n\t\t\t\tconst index = mod(from + step, count);\n\t\t\t\tconst option = options[index];\n\t\t\t\tif (\n\t\t\t\t\t!option.disabled &&\n\t\t\t\t\ttextOf(option).toLowerCase().startsWith(query)\n\t\t\t\t) {\n\t\t\t\t\treturn looping ? base + mod(index - from, count) : index;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tconst { text } = search;\n\t\tconst found = find(text, text.length === 1 ? 1 : 0);\n\t\tif (found !== null) return found;\n\t\t// Repeating one letter cycles through the options that start with it.\n\t\tconst repeated = text.split(\"\").every((char) => char === text[0]);\n\t\treturn repeated ? find(text[0], 1) : null;\n\t};\n\n\tconst handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n\t\tif (!interactive || dragRef.current) return;\n\t\t// Repeated keys build on the pending target, not the moving wheel.\n\t\tconst base = targetRef.current ?? nearestEnabled(position.get());\n\t\tlet target: number | null = null;\n\t\tswitch (event.key) {\n\t\t\tcase \"ArrowUp\":\n\t\t\t\ttarget = stepEnabled(base, -1, 1);\n\t\t\t\tbreak;\n\t\t\tcase \"ArrowDown\":\n\t\t\t\ttarget = stepEnabled(base, 1, 1);\n\t\t\t\tbreak;\n\t\t\tcase \"PageUp\":\n\t\t\t\ttarget = stepEnabled(base, -1, visibleCount);\n\t\t\t\tbreak;\n\t\t\tcase \"PageDown\":\n\t\t\t\ttarget = stepEnabled(base, 1, visibleCount);\n\t\t\t\tbreak;\n\t\t\tcase \"Home\":\n\t\t\t\ttarget = nearestRowFor(firstEnabled);\n\t\t\t\tbreak;\n\t\t\tcase \"End\":\n\t\t\t\ttarget = nearestRowFor(lastEnabled);\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tconst printable =\n\t\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t\t!event.ctrlKey &&\n\t\t\t\t\t!event.metaKey &&\n\t\t\t\t\t!event.altKey;\n\t\t\t\tif (!printable) return;\n\t\t\t\tif (event.key === \" \" && !typeaheadRef.current.text) return;\n\t\t\t\ttarget = typeahead(event.key, base);\n\t\t\t}\n\t\t}\n\t\tevent.preventDefault();\n\t\tif (target === null) return;\n\t\tif (target === base && phaseRef.current === \"idle\") return;\n\t\tcrossedRef.current = false;\n\t\tmoveTo(target, {\n\t\t\tmode: shouldReduceMotion ? \"instant\" : \"spring\",\n\t\t\tcommitOnDone: false,\n\t\t});\n\t\tcommit(target);\n\t};\n\n\tconst handleWheel = (event: WheelEvent) => {\n\t\tif (!interactive) return;\n\t\t// Sideways scrolling belongs to the page.\n\t\tif (Math.abs(event.deltaX) > Math.abs(event.deltaY) || !event.deltaY) {\n\t\t\treturn;\n\t\t}\n\t\tevent.preventDefault();\n\t\tif (dragRef.current) return;\n\t\tconst wheel = wheelRef.current;\n\t\tconst notch =\n\t\t\tevent.deltaMode !== 0 || Math.abs(event.deltaY) >= WHEEL_NOTCH_PX;\n\t\tif (notch && !wheel.active) {\n\t\t\t// One notch, one row.\n\t\t\tconst base = targetRef.current ?? nearestEnabled(position.get());\n\t\t\tconst target = stepEnabled(base, Math.sign(event.deltaY), 1);\n\t\t\tif (target === base) return;\n\t\t\tmoveTo(target, { mode: shouldReduceMotion ? \"instant\" : \"spring\" });\n\t\t\treturn;\n\t\t}\n\t\tif (!wheel.active) {\n\t\t\tstopAnimation();\n\t\t\twheel.active = true;\n\t\t\twheel.raw = position.get();\n\t\t\ttargetRef.current = null;\n\t\t\tsourceRef.current = \"user\";\n\t\t\tcrossedRef.current = false;\n\t\t\toverEdgeRef.current = false;\n\t\t\tsetPhase(\"scrolling\");\n\t\t}\n\t\t// Trackpads scroll like a drag and settle once the deltas stop.\n\t\twheel.raw += event.deltaY / rowHeight;\n\t\tscrollTo(wheel.raw);\n\t\tclearTimeout(wheel.timer);\n\t\twheel.timer = setTimeout(() => settleNear(position.get()), WHEEL_IDLE_MS);\n\t};\n\n\t// Imperative listeners call through refs so they always see the latest render.\n\tconst syncRef = useRef(sync);\n\tconst wheelHandlerRef = useRef(handleWheel);\n\tconst moveToRef = useRef(moveTo);\n\tuseLayoutEffect(() => {\n\t\tsyncRef.current = sync;\n\t\twheelHandlerRef.current = handleWheel;\n\t\tmoveToRef.current = moveTo;\n\t\tgeometryRef.current = geometry;\n\t\tselectedRef.current = selectedIndex;\n\t\treportedRef.current = options[selectedIndex]?.value;\n\t\t// React may have rewritten row styles; redraw them from the motion value.\n\t\tplaceRows(position.get(), true);\n\n\t\t// Follow the value prop silently, unless the user holds the wheel.\n\t\tconst previous = syncedRef.current;\n\t\tsyncedRef.current = selectedIndex;\n\t\tif (selectedIndex < 0 || dragRef.current) return;\n\t\tconst target = targetRef.current;\n\t\tif (target !== null && wrap(target) === selectedIndex) return;\n\t\t// A gesture in flight keeps going unless the value prop changed.\n\t\tif (phaseRef.current !== \"idle\" && selectedIndex === previous) return;\n\t\tmoveTo(nearestRowFor(selectedIndex), {\n\t\t\tsilent: true,\n\t\t\tmode: shouldReduceMotion ? \"instant\" : \"spring\",\n\t\t});\n\t});\n\n\tuseEffect(\n\t\t() => position.on(\"change\", (latest) => syncRef.current(latest)),\n\t\t[position],\n\t);\n\n\tuseEffect(() => {\n\t\tmountedRef.current = true;\n\t\tconst wheel = wheelRef.current;\n\t\tconst search = typeaheadRef.current;\n\t\treturn () => {\n\t\t\tmountedRef.current = false;\n\t\t\tanimationRef.current?.stop();\n\t\t\tcancelAnimationFrame(frameRef.current);\n\t\t\tclearTimeout(wheel.timer);\n\t\t\tclearTimeout(search.timer);\n\t\t};\n\t}, []);\n\n\t// Wheel needs a non-passive listener to keep the page from scrolling, and\n\t// only fires while the pointer is over the wheel.\n\tuseEffect(() => {\n\t\tconst root = rootRef.current;\n\t\tif (!root) return;\n\t\tconst onWheel = (event: WheelEvent) => wheelHandlerRef.current(event);\n\t\troot.addEventListener(\"wheel\", onWheel, { passive: false });\n\t\treturn () => root.removeEventListener(\"wheel\", onWheel);\n\t}, []);\n\n\t// iOS can still scroll the page under a captured pointer; block it mid-drag.\n\tuseEffect(() => {\n\t\tconst root = rootRef.current;\n\t\tif (!root) return;\n\t\tconst onTouchMove = (event: TouchEvent) => {\n\t\t\tif (dragRef.current?.moved) event.preventDefault();\n\t\t};\n\t\troot.addEventListener(\"touchmove\", onTouchMove, { passive: false });\n\t\treturn () => root.removeEventListener(\"touchmove\", onTouchMove);\n\t}, []);\n\n\t// Disabling mid-gesture settles the wheel where it is.\n\tuseEffect(() => {\n\t\tif (interactive || phaseRef.current === \"idle\") return;\n\t\tdragRef.current = null;\n\t\tmoveToRef.current(Math.round(position.get()), { silent: true });\n\t}, [interactive, position]);\n\n\tconst bandTop = `calc(50% - ${rowHeight / 2}px)`;\n\tconst fade = rowHeight / 2;\n\t// Fade the drum's ends and cut out the band, where the selection layer draws.\n\tconst mask = `linear-gradient(to bottom, transparent, #000 ${fade}px, #000 ${bandTop}, transparent ${bandTop}, transparent calc(50% + ${rowHeight / 2}px), #000 calc(50% + ${rowHeight / 2}px), #000 calc(100% - ${fade}px), transparent)`;\n\tconst optionId = (index: number) => `${id}-option-${index}`;\n\n\t// First paint, before effects take over the row styles.\n\tconst initialStyle = (index: number, band: boolean): CSSProperties => {\n\t\tconst offset = looping\n\t\t\t? index - restIndex - count * Math.round((index - restIndex) / count)\n\t\t\t: index - restIndex;\n\t\tconst shown = band\n\t\t\t? Math.abs(offset) < 1\n\t\t\t: Math.abs(offset) <= geometry.reach;\n\t\treturn {\n\t\t\ttransform: rowTransform(offset, geometry),\n\t\t\topacity: band ? undefined : rowOpacity(offset, geometry),\n\t\t\tvisibility: shown ? undefined : \"hidden\",\n\t\t};\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tref={rootRef}\n\t\t\trole=\"listbox\"\n\t\t\ttabIndex={interactive ? 0 : -1}\n\t\t\taria-label={ariaLabelledBy ? ariaLabel : (ariaLabel ?? \"Value\")}\n\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\taria-activedescendant={\n\t\t\t\tselectedIndex >= 0 ? optionId(selectedIndex) : undefined\n\t\t\t}\n\t\t\taria-disabled={disabled || undefined}\n\t\t\tdata-slot=\"wheel-picker\"\n\t\t\tdata-state=\"idle\"\n\t\t\tdata-size={size}\n\t\t\tdata-disabled={disabled || undefined}\n\t\t\tonPointerDown={handlePointerDown}\n\t\t\tonPointerMove={handlePointerMove}\n\t\t\tonPointerUp={handlePointerUp}\n\t\t\tonPointerCancel={handlePointerCancel}\n\t\t\tonKeyDown={handleKeyDown}\n\t\t\tstyle={{ height: visibleCount * rowHeight }}\n\t\t\tclassName={cn(\n\t\t\t\t\"relative inline-block min-w-12 shrink-0 cursor-grab touch-none select-none overflow-hidden rounded-md font-medium tabular-nums outline-none focus-visible:ring-3 focus-visible:ring-ring/50 data-[state=dragging]:cursor-grabbing data-disabled:cursor-not-allowed data-disabled:opacity-50\",\n\t\t\t\tsizeStyle.text,\n\t\t\t\tclassNames?.root,\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t>\n\t\t\t{inGroup ? null : (\n\t\t\t\t<div\n\t\t\t\t\taria-hidden\n\t\t\t\t\tdata-slot=\"wheel-picker-highlight\"\n\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\"pointer-events-none absolute inset-x-0 rounded-md bg-muted\",\n\t\t\t\t\t\tclassNames?.highlight,\n\t\t\t\t\t)}\n\t\t\t\t\tstyle={{ top: bandTop, height: rowHeight }}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t<div\n\t\t\t\tdata-slot=\"wheel-picker-drum\"\n\t\t\t\tclassName=\"absolute inset-0\"\n\t\t\t\tstyle={{\n\t\t\t\t\tperspective: geometry.perspective,\n\t\t\t\t\tmaskImage: mask,\n\t\t\t\t\tWebkitMaskImage: mask,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{options.map((option, index) => {\n\t\t\t\t\tconst selected = index === selectedIndex;\n\t\t\t\t\tconst style = initialStyle(index, false);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t// biome-ignore lint/a11y/useFocusableInteractive: the listbox keeps focus and points here with aria-activedescendant\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tkey={option.value}\n\t\t\t\t\t\t\tref={(node) => {\n\t\t\t\t\t\t\t\tdrumRowRefs.current[index] = node;\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tid={optionId(index)}\n\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\taria-selected={selected}\n\t\t\t\t\t\t\taria-disabled={option.disabled || undefined}\n\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\ttypeof option.label === \"string\" ? undefined : textOf(option)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taria-posinset={index + 1}\n\t\t\t\t\t\t\taria-setsize={count}\n\t\t\t\t\t\t\taria-hidden={style.visibility === \"hidden\" || undefined}\n\t\t\t\t\t\t\tdata-slot=\"wheel-picker-option\"\n\t\t\t\t\t\t\tdata-selected={selected || undefined}\n\t\t\t\t\t\t\tdata-disabled={option.disabled || undefined}\n\t\t\t\t\t\t\tsuppressHydrationWarning\n\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t\"absolute inset-x-0 flex items-center justify-center whitespace-nowrap text-muted-foreground [backface-visibility:hidden]\",\n\t\t\t\t\t\t\t\tsizeStyle.padding,\n\t\t\t\t\t\t\t\toption.disabled && \"text-muted-foreground/45\",\n\t\t\t\t\t\t\t\tclassNames?.option,\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\tstyle={{ top: bandTop, height: rowHeight, ...style }}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{option.label}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</div>\n\n\t\t\t<div\n\t\t\t\taria-hidden\n\t\t\t\tdata-slot=\"wheel-picker-selection\"\n\t\t\t\tclassName=\"pointer-events-none absolute inset-x-0 overflow-hidden\"\n\t\t\t\tstyle={{\n\t\t\t\t\ttop: bandTop,\n\t\t\t\t\theight: rowHeight,\n\t\t\t\t\tperspective: geometry.perspective,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{options.map((option, index) => (\n\t\t\t\t\t<div\n\t\t\t\t\t\tkey={option.value}\n\t\t\t\t\t\tref={(node) => {\n\t\t\t\t\t\t\tbandRowRefs.current[index] = node;\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tdata-disabled={option.disabled || undefined}\n\t\t\t\t\t\tsuppressHydrationWarning\n\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\"absolute inset-x-0 top-0 flex items-center justify-center whitespace-nowrap text-foreground [backface-visibility:hidden]\",\n\t\t\t\t\t\t\tsizeStyle.padding,\n\t\t\t\t\t\t\toption.disabled && \"text-muted-foreground/60\",\n\t\t\t\t\t\t\tclassNames?.option,\n\t\t\t\t\t\t\tclassNames?.optionSelected,\n\t\t\t\t\t\t)}\n\t\t\t\t\t\tstyle={{ height: rowHeight, ...initialStyle(index, true) }}\n\t\t\t\t\t>\n\t\t\t\t\t\t{option.label}\n\t\t\t\t\t</div>\n\t\t\t\t))}\n\t\t\t</div>\n\n\t\t\t{/* Sizes the wheel to its widest label. */}\n\t\t\t<div\n\t\t\t\taria-hidden\n\t\t\t\tclassName={cn(\"invisible grid h-0 overflow-hidden\", sizeStyle.padding)}\n\t\t\t>\n\t\t\t\t{options.map((option) => (\n\t\t\t\t\t<span\n\t\t\t\t\t\tkey={option.value}\n\t\t\t\t\t\tclassName=\"col-start-1 row-start-1 whitespace-nowrap\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{option.label}\n\t\t\t\t\t</span>\n\t\t\t\t))}\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nfunction groupRowHeight(children: ReactNode) {\n\tlet height = 0;\n\tChildren.forEach(children, (child) => {\n\t\tif (\n\t\t\t!isValidElement<WheelPickerProps>(child) ||\n\t\t\tchild.type !== WheelPicker\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst { rowHeight, size = \"md\" } = child.props;\n\t\theight = Math.max(height, rowHeight ?? sizes[size].rowHeight);\n\t});\n\treturn height || sizes.md.rowHeight;\n}\n\nexport function WheelPickerGroup({\n\tchildren,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledBy,\n\tclassName,\n}: WheelPickerGroupProps) {\n\tconst rowHeight = groupRowHeight(children);\n\treturn (\n\t\t<div\n\t\t\trole=\"group\"\n\t\t\taria-label={ariaLabel}\n\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\tdata-slot=\"wheel-picker-group\"\n\t\t\tclassName={cn(\"relative isolate inline-flex items-center\", className)}\n\t\t>\n\t\t\t<div\n\t\t\t\taria-hidden\n\t\t\t\tdata-slot=\"wheel-picker-highlight\"\n\t\t\t\tclassName=\"pointer-events-none absolute inset-x-0 -z-10 rounded-md bg-muted\"\n\t\t\t\tstyle={{ top: `calc(50% - ${rowHeight / 2}px)`, height: rowHeight }}\n\t\t\t/>\n\t\t\t<WheelPickerGroupContext.Provider value>\n\t\t\t\t{children}\n\t\t\t</WheelPickerGroupContext.Provider>\n\t\t</div>\n\t);\n}\n\nexport default WheelPicker;\n",
      "type": "registry:component",
      "target": "@components/wheel-picker.tsx"
    }
  ],
  "meta": {
    "createdAt": "2026-10-31",
    "image": "https://cdn.tentui.com/images/components/wheel-picker",
    "video": "https://cdn.tentui.com/videos/components/wheel-picker"
  },
  "docs": "https://tentui.com/components/wheel-picker",
  "categories": [
    "inputs"
  ],
  "type": "registry:component"
}