{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "question-deck",
  "type": "registry:item",
  "title": "Question Deck",
  "description": "A questionnaire card on a loose stack: answers spring in, questions slide and the cards behind shuffle.",
  "categories": [
    "card"
  ],
  "dependencies": [
    "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/question-deck.tsx",
      "type": "registry:file",
      "target": "~/components/kinetik/question-deck.tsx",
      "content": "import { useEffect, useState } from 'react';\nimport {\n  Platform,\n  Pressable,\n  StyleSheet,\n  Text,\n  View,\n  type StyleProp,\n  type ViewStyle,\n} from 'react-native';\nimport Animated, {\n  FadeIn,\n  SlideInLeft,\n  SlideInRight,\n  useAnimatedStyle,\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 } from '../../lib/kinetik/tokens/tokens';\n\nexport type DeckQuestion = {\n  id: string;\n  title: string;\n  options: readonly string[];\n  /** Small caps line above the options. Defaults to \"Select only one\". */\n  hint?: string;\n};\n\nexport type QuestionDeckProps = {\n  questions: readonly DeckQuestion[];\n  /** Called from the last question with every answer, by question id. */\n  onComplete: (answers: Record<string, string>) => void;\n  /** Shows a close button. */\n  onClose?: () => void;\n  /** Colour of the Next button. Defaults to the theme success green. */\n  accent?: string;\n  nextLabel?: string;\n  finishLabel?: string;\n  backLabel?: string;\n  /** A tick on each choice and step. Defaults to true. */\n  haptics?: boolean;\n  style?: StyleProp<ViewStyle>;\n};\n\nconst MONO = Platform.select({\n  ios: 'Menlo',\n  android: 'monospace',\n  default: 'ui-monospace, monospace',\n});\n\n/**\n * A short questionnaire on a card resting on a loose stack of cards. Each\n * answer fills its radio with a spring; Next slides the next question in\n * while the cards behind shuffle, and the progress dashes fill as you go.\n */\nexport function QuestionDeck({\n  questions,\n  onComplete,\n  onClose,\n  accent,\n  nextLabel = 'Next',\n  finishLabel = 'Finish',\n  backLabel = 'Back',\n  haptics = true,\n  style,\n}: QuestionDeckProps) {\n  const { colors, radius, space, font, shadow } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const haptic = useHaptic(haptics);\n  const [index, setIndex] = useState(0);\n  const [back, setBack] = useState(false);\n  const [answers, setAnswers] = useState<Record<string, string>>({});\n  const shuffle = useSharedValue(0);\n  const q = questions[index];\n  const last = index === questions.length - 1;\n  const fill = accent ?? colors.success;\n\n  useEffect(() => {\n    if (reduced) return;\n    shuffle.set(withSequence(withTiming(1, timing('base')), withSpring(0, spring('bouncy'))));\n  }, [index, reduced, shuffle]);\n\n  const behind = useAnimatedStyle(() => ({\n    transform: [\n      { rotate: `${-7 - shuffle.get() * 4}deg` },\n      { translateX: -8 - shuffle.get() * 10 },\n    ],\n  }));\n  const middle = useAnimatedStyle(() => ({\n    transform: [{ rotate: `${5 + shuffle.get() * 3}deg` }, { translateX: 10 + shuffle.get() * 8 }],\n  }));\n\n  if (!q) return null;\n  const picked = answers[q.id];\n\n  const go = (to: number) => {\n    haptic('tick');\n    setBack(to < index);\n    setIndex(to);\n  };\n\n  const enter = reduced\n    ? FadeIn.duration(durations.quick)\n    : (back ? SlideInLeft : SlideInRight).duration(durations.slow).easing(easings.standard);\n\n  const sheet = {\n    // A step off the page colour on either theme, so the loose cards read.\n    backgroundColor: colors.skeleton,\n    borderColor: colors.borderStrong,\n    borderRadius: radius.xl + 4,\n  };\n\n  return (\n    <View style={[styles.stage, style]}>\n      <Animated.View\n        pointerEvents=\"none\"\n        style={[StyleSheet.absoluteFill, styles.back, sheet, behind]}\n      />\n      <Animated.View\n        pointerEvents=\"none\"\n        style={[StyleSheet.absoluteFill, styles.back, sheet, middle]}\n      />\n      <View\n        style={[\n          styles.card,\n          {\n            backgroundColor: colors.surfaceRaised,\n            borderRadius: radius.xl + 4,\n            padding: space[6],\n            boxShadow: shadow.md,\n          },\n        ]}\n      >\n        <View style={[styles.top, { gap: space[2] }]}>\n          <View\n            accessible\n            accessibilityRole=\"progressbar\"\n            accessibilityLabel=\"Questions\"\n            accessibilityValue={{\n              min: 1,\n              max: questions.length,\n              now: index + 1,\n              text: `Question ${index + 1} of ${questions.length}`,\n            }}\n            style={[styles.dashes, { gap: 6 }]}\n          >\n            {questions.map((item, i) => (\n              <Dash key={item.id} state={i < index ? 'done' : i === index ? 'now' : 'next'} />\n            ))}\n          </View>\n          {onClose ? (\n            <Pressable\n              accessibilityRole=\"button\"\n              accessibilityLabel=\"Close\"\n              onPress={onClose}\n              style={styles.close}\n            >\n              <View style={[styles.closeDot, { backgroundColor: colors.textSubtle }]}>\n                <View style={[styles.cross, { backgroundColor: colors.surfaceRaised }]} />\n                <View\n                  style={[\n                    styles.cross,\n                    styles.crossBack,\n                    { backgroundColor: colors.surfaceRaised },\n                  ]}\n                />\n              </View>\n            </Pressable>\n          ) : null}\n        </View>\n\n        <Animated.View key={q.id} entering={enter} style={{ gap: space[5], marginTop: space[6] }}>\n          <View style={{ gap: space[3] }}>\n            <Text\n              style={{\n                color: colors.text,\n                fontFamily: MONO,\n                fontSize: font.size.xs,\n                letterSpacing: 1,\n              }}\n            >\n              QUESTION {String(index + 1).padStart(2, '0')}\n            </Text>\n            <Text\n              accessibilityRole=\"header\"\n              style={{\n                color: colors.text,\n                fontSize: font.size.xl + 4,\n                lineHeight: 32,\n                fontWeight: font.weight.medium,\n                letterSpacing: font.tracking.tight,\n              }}\n            >\n              {q.title}\n            </Text>\n          </View>\n          <View accessibilityRole=\"radiogroup\" style={{ gap: space[1] }}>\n            <Text\n              style={{\n                color: colors.textSubtle,\n                fontFamily: MONO,\n                fontSize: font.size.xs,\n                letterSpacing: 1,\n                marginBottom: space[1],\n              }}\n            >\n              {(q.hint ?? 'Select only one').toUpperCase()}\n            </Text>\n            {q.options.map((option) => (\n              <Option\n                key={option}\n                label={option}\n                on={picked === option}\n                onPress={() => {\n                  haptic('tick');\n                  setAnswers((a) => ({ ...a, [q.id]: option }));\n                }}\n              />\n            ))}\n          </View>\n        </Animated.View>\n\n        <View style={[styles.actions, { gap: space[2], marginTop: space[8] }]}>\n          {index > 0 ? (\n            <Pressable\n              accessibilityRole=\"button\"\n              onPress={() => go(index - 1)}\n              style={[styles.button, { paddingHorizontal: space[5] }]}\n            >\n              <Text\n                style={{\n                  color: colors.text,\n                  fontSize: font.size.md,\n                  fontWeight: font.weight.medium,\n                }}\n              >\n                {backLabel}\n              </Text>\n            </Pressable>\n          ) : null}\n          <Pressable\n            accessibilityRole=\"button\"\n            accessibilityState={{ disabled: !picked }}\n            disabled={!picked}\n            onPress={() => {\n              if (last) {\n                haptic('success');\n                onComplete(answers);\n              } else go(index + 1);\n            }}\n            style={({ pressed }) => [\n              styles.button,\n              {\n                paddingHorizontal: space[8],\n                backgroundColor: fill,\n                borderRadius: radius.md,\n                opacity: picked ? 1 : 0.4,\n                transform: [{ scale: pressed ? 0.97 : 1 }],\n              },\n            ]}\n          >\n            <Text\n              style={{\n                color: colors.onEmber,\n                fontSize: font.size.md,\n                fontWeight: font.weight.semibold,\n              }}\n            >\n              {last ? finishLabel : nextLabel}\n            </Text>\n          </Pressable>\n        </View>\n      </View>\n    </View>\n  );\n}\n\n/** A progress dash that widens and darkens for the current question. */\nfunction Dash({ state }: { state: 'done' | 'now' | 'next' }) {\n  const { colors } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const now = useSharedValue(state === 'now' ? 1 : 0);\n  useEffect(() => {\n    const v = state === 'now' ? 1 : 0;\n    now.set(reduced ? v : withSpring(v, spring('smooth')));\n  }, [state, reduced, now]);\n  const style = useAnimatedStyle(() => ({ width: 22 + now.get() * 14 }));\n  return (\n    <Animated.View\n      style={[\n        styles.dash,\n        {\n          backgroundColor: state === 'next' ? colors.track : colors.text,\n          opacity: state === 'done' ? 0.45 : 1,\n        },\n        style,\n      ]}\n    />\n  );\n}\n\nfunction Option({ label, on, onPress }: { label: string; on: boolean; onPress: () => void }) {\n  const { colors, font, space } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const dot = useSharedValue(on ? 1 : 0);\n  useEffect(() => {\n    dot.set(reduced ? (on ? 1 : 0) : withSpring(on ? 1 : 0, spring('bouncy')));\n  }, [on, reduced, dot]);\n  const inner = useAnimatedStyle(() => ({ transform: [{ scale: dot.get() }] }));\n  return (\n    <Pressable\n      accessibilityRole=\"radio\"\n      accessibilityLabel={label}\n      accessibilityState={{ checked: on }}\n      onPress={onPress}\n      style={[styles.option, { gap: space[3] }]}\n    >\n      <View style={[styles.radio, { borderColor: colors.text }]}>\n        <Animated.View style={[styles.radioDot, { backgroundColor: colors.text }, inner]} />\n      </View>\n      <Text style={{ color: colors.text, fontSize: font.size.md + 1 }}>{label}</Text>\n    </Pressable>\n  );\n}\n\nconst styles = StyleSheet.create({\n  stage: { padding: 14 },\n  back: { margin: 14, borderWidth: StyleSheet.hairlineWidth },\n  card: {},\n  top: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },\n  dashes: { flexDirection: 'row', flexShrink: 1 },\n  dash: { height: 4, borderRadius: 2 },\n  close: {\n    width: minTouchTarget,\n    height: minTouchTarget,\n    alignItems: 'center',\n    justifyContent: 'center',\n    marginRight: -12,\n    marginVertical: -12,\n  },\n  closeDot: {\n    width: 22,\n    height: 22,\n    borderRadius: 11,\n    alignItems: 'center',\n    justifyContent: 'center',\n  },\n  cross: {\n    position: 'absolute',\n    width: 10,\n    height: 2,\n    borderRadius: 1,\n    transform: [{ rotate: '45deg' }],\n  },\n  crossBack: { transform: [{ rotate: '-45deg' }] },\n  option: { flexDirection: 'row', alignItems: 'center', minHeight: minTouchTarget },\n  radio: {\n    width: 18,\n    height: 18,\n    borderRadius: 9,\n    borderWidth: 1.5,\n    alignItems: 'center',\n    justifyContent: 'center',\n  },\n  radioDot: { width: 9, height: 9, borderRadius: 4.5 },\n  actions: { flexDirection: 'row', justifyContent: 'flex-end', alignItems: 'center' },\n  button: { minHeight: 52, alignItems: 'center', justifyContent: 'center' },\n});\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "kind": "component",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "category": "card",
    "web": "live",
    "perf": {
      "budget": "Each step runs one layout animation and a shuffle spring on the UI thread; at rest nothing animates.",
      "measurements": [
        {
          "device": "Pixel 9 emulator, API 35",
          "kind": "emulator",
          "date": "2026-10-14",
          "build": "release",
          "frameMs": 17,
          "p90Ms": 25,
          "baselineMs": 17,
          "jankyPercent": 3.79,
          "atRest": "idle",
          "memoryMb": 208,
          "notes": "Most janky frames are the step slide; at rest nothing animates."
        }
      ]
    },
    "a11y": {
      "reducedMotion": "Questions cross-fade and the stack does not shuffle.",
      "screenReader": "Progress reads \"Question 2 of 6\"; the question is a header; options are radios; Next is disabled until something is picked.",
      "touchTarget": "Options, Back, Next and Close are at least 44 pt."
    },
    "requires": "React Native New Architecture (Reanimated 4)",
    "guide": "## Usage\n\n```tsx\nimport { QuestionDeck } from '@/components/kinetik/question-deck';\n\n<QuestionDeck\n  questions={[\n    {\n      id: 'how',\n      title: 'How would you like to make change happen?',\n      options: ['D.I.Y.', 'Contractor', 'Property Manager'],\n    },\n    { id: 'when', title: 'When would you like to start?', options: ['This month', 'Later'] },\n  ]}\n  onComplete={(answers) => saveProfile(answers)}\n  onClose={() => router.back()}\n/>;\n```\n\n## When to use\n\n- Short onboarding or intake questionnaires: two to eight single-choice questions.\n\n## When not to use\n\n- Long forms or questions that need typing: use a form.\n- Multiple choice: each question takes exactly one answer.\n\n## Notes\n\n- Next stays disabled until an option is picked; Back keeps earlier answers.\n- `onComplete` receives every answer keyed by question id.\n- The Next button uses `accent` (the theme success green by default).\n"
  },
  "docs": "Prefer `npx kinetik-ui add question-deck`: it installs dependencies with expo install, so versions match your Expo SDK."
}
