{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "seat-picker",
  "type": "registry:item",
  "title": "Seat Picker",
  "description": "A seat counter: armchairs that fill as you add seats, a rolling stepper and a badge of seats left.",
  "categories": [
    "input"
  ],
  "dependencies": [
    "@shopify/react-native-skia",
    "react-native-reanimated",
    "react-native-worklets"
  ],
  "registryDependencies": [
    "https://kinetik-ui.dev/r/kinetik-tokens.json",
    "https://kinetik-ui.dev/r/kinetik-motion.json",
    "https://kinetik-ui.dev/r/kinetik-haptics.json"
  ],
  "files": [
    {
      "path": "src/components/kinetik/seat-picker.tsx",
      "type": "registry:file",
      "target": "~/components/kinetik/seat-picker.tsx",
      "content": "import { Canvas, Group, Path, Skia } from '@shopify/react-native-skia';\nimport { useEffect, useState } from 'react';\nimport {\n  Pressable,\n  StyleSheet,\n  Text,\n  View,\n  type AccessibilityActionEvent,\n  type StyleProp,\n  type ViewStyle,\n} from 'react-native';\nimport Animated, {\n  FadeInDown,\n  FadeInUp,\n  FadeOutDown,\n  FadeOutUp,\n  interpolateColor,\n  useAnimatedStyle,\n  useDerivedValue,\n  useSharedValue,\n  withSequence,\n  withSpring,\n  withTiming,\n} from 'react-native-reanimated';\n\nimport { useHaptic } from '../../lib/kinetik/hooks/use-haptic';\nimport { useReduceMotion } from '../../lib/kinetik/hooks/use-reduce-motion';\nimport { durations, easings, spring, timing } from '../../lib/kinetik/motion/motion';\nimport { useKinetikTheme } from '../../lib/kinetik/tokens/theme';\nimport { minTouchTarget, withAlpha } from '../../lib/kinetik/tokens/tokens';\n\nexport type SeatPickerProps = {\n  value: number;\n  onChange: (value: number) => void;\n  /** Seats that can be taken. Each one is drawn. Defaults to 5. */\n  max?: number;\n  /** Defaults to 1. */\n  min?: number;\n  /** Defaults to \"Seats\". */\n  title?: string;\n  /** A line above the action, e.g. \"Add seats now and upgrade later if you need more.\" */\n  caption?: string;\n  /** A full-width button at the bottom, e.g. Upgrade. */\n  action?: { label: string; onPress: () => void };\n  /** Shows an info button next to the title. */\n  onInfo?: () => void;\n  /** Ticks on each change and a buzz at the limits. Defaults to true. */\n  haptics?: boolean;\n  style?: StyleProp<ViewStyle>;\n};\n\n/** Armchair from Tabler Icons (MIT, https://tabler.io/icons), on a 24 pt grid. */\nconst CHAIR = Skia.Path.MakeFromSVGString(\n  'M5 11a2 2 0 0 1 2 2v2h10v-2a2 2 0 1 1 4 0v4a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-4a2 2 0 0 1 2 -2z M5 11v-5a3 3 0 0 1 3 -3h8a3 3 0 0 1 3 3v5 M6 19v2 M18 19v2',\n)!;\n\nconst SEAT = 34;\nconst GAP = 10;\n\n/**\n * A seat counter: a row of armchairs that fill in as you add seats, a\n * stepper whose number rolls up or down, and a badge counting what is left.\n * New seats pop in, removed ones settle back, and pushing past a limit gives\n * the stepper a shake.\n */\nexport function SeatPicker({\n  value,\n  onChange,\n  max = 5,\n  min = 1,\n  title = 'Seats',\n  caption,\n  action,\n  onInfo,\n  haptics = true,\n  style,\n}: SeatPickerProps) {\n  const { colors, radius, space, font, shadow } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const haptic = useHaptic(haptics);\n  const shake = useSharedValue(0);\n  const bump = useSharedValue(0);\n  // Which way the number rolls: up when it grows, down when it shrinks.\n  const [last, setLast] = useState(value);\n  const [rising, setRising] = useState(true);\n  if (value !== last) {\n    setRising(value > last);\n    setLast(value);\n  }\n  const left = Math.max(0, max - value);\n\n  useEffect(() => {\n    if (!reduced) {\n      bump.set(withSequence(withTiming(1, timing('quick')), withSpring(0, spring('bouncy'))));\n    }\n  }, [value, reduced, bump]);\n\n  const change = (delta: number) => {\n    const next = value + delta;\n    if (next < min || next > max) {\n      haptic('warning');\n      if (!reduced) {\n        shake.set(\n          withSequence(\n            withTiming(-6, { duration: 50 }),\n            withTiming(6, { duration: 70 }),\n            withTiming(-3, { duration: 60 }),\n            withSpring(0, spring('snappy')),\n          ),\n        );\n      }\n      return;\n    }\n    haptic('tick');\n    onChange(next);\n  };\n\n  const onAccessibilityAction = (e: AccessibilityActionEvent) =>\n    change(e.nativeEvent.actionName === 'increment' ? 1 : -1);\n\n  const row = useAnimatedStyle(() => ({ transform: [{ translateX: shake.get() }] }));\n  const badge = useAnimatedStyle(() => ({ transform: [{ scale: 1 + bump.get() * 0.08 }] }));\n  const full = left === 0;\n  const tone = full ? colors.danger : colors.warning;\n\n  return (\n    <View style={style}>\n      {/* The shadow is its own layer, so seats and numbers animating never redraw it. */}\n      <View\n        pointerEvents=\"none\"\n        style={[\n          StyleSheet.absoluteFill,\n          { borderRadius: radius.xl, backgroundColor: colors.surfaceRaised, boxShadow: shadow.lg },\n        ]}\n      />\n      <View\n        style={[\n          styles.card,\n          {\n            backgroundColor: colors.surfaceRaised,\n            borderColor: colors.border,\n            borderRadius: radius.xl,\n            padding: space[5],\n            gap: space[5],\n          },\n        ]}\n      >\n        <View style={[styles.row, { gap: space[2] }]}>\n          <Text\n            accessibilityRole=\"header\"\n            style={{ color: colors.text, fontSize: font.size.lg, fontWeight: font.weight.medium }}\n          >\n            {title}\n          </Text>\n          <Animated.View\n            accessible\n            accessibilityLabel={\n              full ? 'No seats left' : `${left} ${left === 1 ? 'seat' : 'seats'} left`\n            }\n            accessibilityLiveRegion=\"polite\"\n            style={[\n              styles.badge,\n              { backgroundColor: withAlpha(tone, 0.18), borderRadius: radius.sm, gap: 4 },\n              badge,\n            ]}\n          >\n            <Chair size={14} color={tone} />\n            <Text style={{ color: tone, fontSize: font.size.xs, fontWeight: font.weight.bold }}>\n              {full ? 'Full' : `${left} left`}\n            </Text>\n          </Animated.View>\n          <View style={styles.grow} />\n          {onInfo ? (\n            <Pressable\n              accessibilityRole=\"button\"\n              accessibilityLabel=\"About seats\"\n              onPress={onInfo}\n              hitSlop={10}\n              style={styles.info}\n            >\n              <View style={[styles.infoRing, { borderColor: colors.textMuted }]}>\n                <View style={[styles.infoDot, { backgroundColor: colors.textMuted }]} />\n                <View style={[styles.infoStem, { backgroundColor: colors.textMuted }]} />\n              </View>\n            </Pressable>\n          ) : null}\n        </View>\n\n        <Seats count={max} taken={value} />\n\n        <Animated.View style={[styles.row, { gap: space[2] }, row]}>\n          <StepButton kind=\"minus\" disabled={value <= min} onPress={() => change(-1)} />\n          <View\n            accessible\n            accessibilityRole=\"adjustable\"\n            accessibilityLabel={title}\n            accessibilityValue={{\n              min,\n              max,\n              now: value,\n              text: `${value} ${value === 1 ? 'seat' : 'seats'}`,\n            }}\n            accessibilityActions={[{ name: 'increment' }, { name: 'decrement' }]}\n            onAccessibilityAction={onAccessibilityAction}\n            style={styles.count}\n          >\n            <Animated.Text\n              key={value}\n              entering={\n                reduced\n                  ? undefined\n                  : (rising ? FadeInDown : FadeInUp)\n                      .duration(durations.base)\n                      .easing(easings.standard)\n              }\n              exiting={\n                reduced\n                  ? undefined\n                  : (rising ? FadeOutUp : FadeOutDown)\n                      .duration(durations.quick)\n                      .easing(easings.exit)\n              }\n              style={[\n                styles.number,\n                {\n                  color: colors.text,\n                  fontSize: font.size['3xl'],\n                  fontWeight: font.weight.semibold,\n                  fontVariant: ['tabular-nums'],\n                },\n              ]}\n            >\n              {value}\n            </Animated.Text>\n          </View>\n          <StepButton kind=\"plus\" disabled={value >= max} onPress={() => change(1)} />\n        </Animated.View>\n\n        {caption || action ? (\n          <View style={{ gap: space[3] }}>\n            {caption ? (\n              <Text\n                style={{ color: colors.textMuted, fontSize: font.size.sm, textAlign: 'center' }}\n              >\n                {caption}\n              </Text>\n            ) : null}\n            {action ? (\n              <Pressable\n                accessibilityRole=\"button\"\n                onPress={action.onPress}\n                style={({ pressed }) => [\n                  styles.action,\n                  {\n                    borderColor: colors.borderStrong,\n                    borderRadius: radius.pill,\n                    backgroundColor: pressed ? colors.surfaceSunken : colors.surfaceRaised,\n                    transform: [{ scale: pressed ? 0.98 : 1 }],\n                  },\n                ]}\n              >\n                <Text\n                  style={{\n                    color: colors.text,\n                    fontSize: font.size.md,\n                    fontWeight: font.weight.semibold,\n                  }}\n                >\n                  {action.label}\n                </Text>\n              </Pressable>\n            ) : null}\n          </View>\n        ) : null}\n      </View>\n    </View>\n  );\n}\n\n/** The row of armchairs, one canvas for all of them. */\nfunction Seats({ count, taken }: { count: number; taken: number }) {\n  const width = count * SEAT + (count - 1) * GAP;\n  return (\n    <View aria-hidden style={styles.seats}>\n      <Canvas style={{ width, height: SEAT + 8 }}>\n        {Array.from({ length: count }, (_, i) => (\n          <Seat key={i} index={i} on={i < taken} />\n        ))}\n      </Canvas>\n    </View>\n  );\n}\n\n/** One armchair: fills and pops when taken, empties and sinks back when freed. */\nfunction Seat({ index, on }: { index: number; on: boolean }) {\n  const { colors } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const fill = useSharedValue(on ? 1 : 0);\n  const scale = useSharedValue(1);\n\n  useEffect(() => {\n    if (reduced) {\n      fill.set(on ? 1 : 0);\n      return;\n    }\n    fill.set(withTiming(on ? 1 : 0, timing('base')));\n    scale.set(\n      on\n        ? withSequence(withTiming(0.7, { duration: 90 }), withSpring(1, spring('bouncy')))\n        : withSequence(withTiming(0.86, { duration: 110 }), withSpring(1, spring('smooth'))),\n    );\n  }, [on, reduced, fill, scale]);\n\n  const empty = withAlpha(colors.text, 0.1);\n  const color = useDerivedValue(() => interpolateColor(fill.get(), [0, 1], [empty, colors.text]));\n  const transform = useDerivedValue(() => {\n    const s = scale.get();\n    const c = SEAT / 2;\n    const x = index * (SEAT + GAP);\n    return [\n      { translateX: x + c },\n      { translateY: 4 + c },\n      { scale: s * (SEAT / 24) },\n      { translateX: -12 },\n      { translateY: -12 },\n    ];\n  });\n\n  return (\n    <Group transform={transform}>\n      <Path path={CHAIR} color={color} />\n      <Path\n        path={CHAIR}\n        color={color}\n        style=\"stroke\"\n        strokeWidth={2}\n        strokeCap=\"round\"\n        strokeJoin=\"round\"\n      />\n    </Group>\n  );\n}\n\n/** A small armchair for the badge. */\nfunction Chair({ size, color }: { size: number; color: string }) {\n  return (\n    <View aria-hidden>\n      <Canvas style={{ width: size, height: size }}>\n        <Group transform={[{ scale: size / 24 }]}>\n          <Path\n            path={CHAIR}\n            color={color}\n            style=\"stroke\"\n            strokeWidth={2.2}\n            strokeCap=\"round\"\n            strokeJoin=\"round\"\n          />\n        </Group>\n      </Canvas>\n    </View>\n  );\n}\n\nfunction StepButton({\n  kind,\n  disabled,\n  onPress,\n}: {\n  kind: 'minus' | 'plus';\n  disabled: boolean;\n  onPress: () => void;\n}) {\n  const { colors, radius, shadow } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const press = useSharedValue(0);\n  const style = useAnimatedStyle(() => ({ transform: [{ scale: 1 - press.get() * 0.05 }] }));\n  const ink = disabled ? colors.textSubtle : colors.text;\n  return (\n    <Pressable\n      accessibilityRole=\"button\"\n      accessibilityLabel={kind === 'plus' ? 'Add a seat' : 'Remove a seat'}\n      accessibilityState={{ disabled }}\n      onPress={onPress}\n      onPressIn={() => press.set(withSpring(1, spring('snappy', reduced)))}\n      onPressOut={() => press.set(withSpring(0, spring('bouncy', reduced)))}\n      style={styles.grow}\n    >\n      <Animated.View\n        style={[\n          styles.step,\n          {\n            backgroundColor: colors.surface,\n            borderColor: colors.border,\n            borderRadius: radius.pill,\n            boxShadow: shadow.sm,\n          },\n          style,\n        ]}\n      >\n        <View style={[styles.glyph, { borderColor: ink }]}>\n          <View style={[styles.bar, { backgroundColor: ink }]} />\n          {kind === 'plus' ? (\n            <View style={[styles.bar, styles.upright, { backgroundColor: ink }]} />\n          ) : null}\n        </View>\n      </Animated.View>\n    </Pressable>\n  );\n}\n\nconst styles = StyleSheet.create({\n  card: { borderWidth: StyleSheet.hairlineWidth },\n  row: { flexDirection: 'row', alignItems: 'center' },\n  grow: { flex: 1 },\n  badge: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 8, paddingVertical: 4 },\n  info: {\n    width: minTouchTarget,\n    height: minTouchTarget,\n    alignItems: 'center',\n    justifyContent: 'center',\n    marginRight: -10,\n  },\n  infoRing: {\n    width: 22,\n    height: 22,\n    borderRadius: 11,\n    borderWidth: 2,\n    alignItems: 'center',\n    paddingTop: 4,\n    gap: 2,\n  },\n  infoDot: { width: 2.5, height: 2.5, borderRadius: 1.25 },\n  infoStem: { width: 2, height: 6, borderRadius: 1 },\n  seats: { alignSelf: 'center' },\n  count: {\n    width: 56,\n    height: 52,\n    alignItems: 'center',\n    justifyContent: 'center',\n    overflow: 'hidden',\n  },\n  number: { position: 'absolute' },\n  step: {\n    height: 52,\n    alignItems: 'center',\n    justifyContent: 'center',\n    borderWidth: StyleSheet.hairlineWidth,\n  },\n  glyph: {\n    width: 22,\n    height: 22,\n    borderRadius: 11,\n    borderWidth: 2,\n    alignItems: 'center',\n    justifyContent: 'center',\n  },\n  bar: { position: 'absolute', width: 10, height: 2, borderRadius: 1 },\n  upright: { transform: [{ rotate: '90deg' }] },\n  action: {\n    minHeight: 52,\n    alignItems: 'center',\n    justifyContent: 'center',\n    borderWidth: 1,\n  },\n});\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "kind": "component",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "category": "input",
    "web": "live",
    "perf": {
      "budget": "Seat pops and the number roll run once per change on the UI thread; at rest nothing animates. All seats share one Skia canvas.",
      "measurements": [
        {
          "device": "Pixel 9 emulator, API 35",
          "kind": "emulator",
          "date": "2026-10-14",
          "build": "release",
          "frameMs": 27,
          "p90Ms": 30,
          "baselineMs": 17,
          "jankyPercent": 0.22,
          "atRest": "idle",
          "memoryMb": 162,
          "notes": "Frame times are mostly the emulator GPU swap: framestats show about 6 ms of app work per frame (input, animation and drawing) and ~17 ms waiting for the swap."
        }
      ]
    },
    "a11y": {
      "reducedMotion": "Seats fill and empty without popping, the number changes in place and the stepper does not shake.",
      "screenReader": "The count is an adjustable control (\"2 seats\"); the buttons are named Add a seat and Remove a seat; the badge reads \"3 seats left\" and is announced as it changes.",
      "touchTarget": "Stepper buttons and the action are 52 pt tall; the info button is 44 pt."
    },
    "requires": "React Native New Architecture (Reanimated 4)",
    "guide": "## Usage\n\n```tsx\nimport { SeatPicker } from '@/components/kinetik/seat-picker';\n\nconst [seats, setSeats] = useState(1);\n\n<SeatPicker\n  value={seats}\n  onChange={setSeats}\n  max={plan.seatLimit}\n  caption=\"Add seats now and upgrade later if you need more.\"\n  action={{ label: 'Upgrade', onPress: () => router.push('/upgrade') }}\n  onInfo={() => openSheet('seats')}\n/>;\n```\n\n## When to use\n\n- Choosing a small number of seats, licences, tickets or guests, up to about eight.\n- When seeing what is left matters, such as a plan limit or a nearly full table.\n\n## When not to use\n\n- Large counts: eight chairs is the most that reads at a glance. Use a stepper or a number field.\n- Picking specific seats on a map: this counts seats, it does not place them.\n\n## Notes\n\n- Adding past `max` or removing below `min` shakes the stepper and plays a warning haptic instead of changing the value.\n- The badge counts `max - value` and turns red with \"Full\" when none are left.\n- The armchair is the Tabler Icons armchair (MIT licence, via iconstack.io).\n"
  },
  "docs": "Prefer `npx kinetik-ui add seat-picker`: it installs dependencies with expo install, so versions match your Expo SDK."
}
