{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "action-sheet",
  "type": "registry:item",
  "title": "Action Sheet",
  "description": "Actions from the bottom edge with Cancel apart: it springs up, follows a downward drag and drops away.",
  "categories": [
    "overlay"
  ],
  "dependencies": [
    "react-native-gesture-handler",
    "react-native-reanimated",
    "react-native-safe-area-context",
    "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/action-sheet.tsx",
      "type": "registry:file",
      "target": "~/components/kinetik/action-sheet.tsx",
      "content": "import { useContext, useEffect, useState } from 'react';\nimport {\n  Modal,\n  Pressable,\n  StyleSheet,\n  Text,\n  View,\n  type StyleProp,\n  type ViewStyle,\n} from 'react-native';\nimport { Gesture, GestureDetector, GestureHandlerRootView } from 'react-native-gesture-handler';\nimport Animated, {\n  interpolate,\n  useAnimatedStyle,\n  useSharedValue,\n  withSpring,\n  withTiming,\n} from 'react-native-reanimated';\nimport { SafeAreaInsetsContext } from 'react-native-safe-area-context';\nimport { scheduleOnRN } from 'react-native-worklets';\n\nimport { useHaptic } from '../../lib/kinetik/hooks/use-haptic';\nimport { useReduceMotion } from '../../lib/kinetik/hooks/use-reduce-motion';\nimport { durations, easings, spring } from '../../lib/kinetik/motion/motion';\nimport { useKinetikTheme } from '../../lib/kinetik/tokens/theme';\n\nexport type SheetAction = {\n  label: string;\n  onPress: () => void;\n  /** \"danger\" is drawn in red, for actions that destroy something. */\n  tone?: 'default' | 'danger';\n  disabled?: boolean;\n};\n\nexport type ActionSheetProps = {\n  visible: boolean;\n  /** Called whenever the sheet closes: Cancel, a tap outside, a swipe down, Back. */\n  onClose: () => void;\n  actions: readonly SheetAction[];\n  /** A short line above the actions, e.g. what they apply to. */\n  title?: string;\n  message?: string;\n  /** Defaults to \"Cancel\". */\n  cancelLabel?: string;\n  /** A tick when an action is chosen. Defaults to true. */\n  haptics?: boolean;\n  testID?: string;\n  style?: StyleProp<ViewStyle>;\n};\n\nconst ROW = 56;\nconst MARGIN = 10;\nconst TRAVEL = 480;\n\n/**\n * A sheet of actions from the bottom edge, with Cancel in its own card. It\n * springs up over a dimmed screen, follows the finger when dragged down and\n * drops away past a threshold; a chosen action runs once the sheet is gone.\n */\nexport function ActionSheet({\n  visible,\n  onClose,\n  actions,\n  title,\n  message,\n  cancelLabel = 'Cancel',\n  haptics = true,\n  testID,\n  style,\n}: ActionSheetProps) {\n  const { colors, font, radius, shadow } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const haptic = useHaptic(haptics);\n  const insets = useContext(SafeAreaInsetsContext);\n  const [mounted, setMounted] = useState(visible);\n  if (visible && !mounted) setMounted(true);\n  const t = useSharedValue(0);\n  const drag = useSharedValue(0);\n  const height = useSharedValue(TRAVEL);\n\n  useEffect(() => {\n    if (visible) {\n      drag.set(0);\n      t.set(reduced ? 1 : withSpring(1, spring('smooth')));\n      return;\n    }\n    if (reduced) {\n      t.set(0);\n      setTimeout(() => setMounted(false), 0);\n      return;\n    }\n    t.set(\n      withTiming(0, { duration: durations.base, easing: easings.exit }, (done) => {\n        if (done) scheduleOnRN(setMounted, false);\n      }),\n    );\n  }, [visible, reduced, t, drag]);\n\n  // A chosen action runs after the sheet has gone, so it never fights the exit.\n  const choose = (action: SheetAction) => {\n    haptic('tick');\n    onClose();\n    setTimeout(action.onPress, reduced ? 0 : durations.base);\n  };\n\n  const pan = Gesture.Pan()\n    .withTestId('action-sheet')\n    .activeOffsetY(6)\n    .failOffsetX([-20, 20])\n    .onUpdate((e) => {\n      // Upwards it gives a little and resists; downwards it follows the finger.\n      drag.set(e.translationY > 0 ? e.translationY : -Math.sqrt(-e.translationY) * 2);\n    })\n    .onEnd((e) => {\n      if (e.translationY > height.get() * 0.28 || e.velocityY > 900) {\n        scheduleOnRN(onClose);\n      } else {\n        drag.set(withSpring(0, spring('bouncy', reduced)));\n      }\n    });\n\n  const scrim = useAnimatedStyle(() => ({\n    opacity: t.get() * (1 - Math.min(1, Math.max(0, drag.get()) / Math.max(1, height.get()))),\n  }));\n  const sheet = useAnimatedStyle(() => ({\n    transform: [{ translateY: interpolate(t.get(), [0, 1], [height.get() + 40, 0]) + drag.get() }],\n  }));\n\n  return (\n    <Modal\n      visible={mounted}\n      transparent\n      animationType=\"none\"\n      onRequestClose={onClose}\n      statusBarTranslucent\n      navigationBarTranslucent\n    >\n      {/* A modal is its own window on Android, so gestures need their own root. */}\n      <GestureHandlerRootView style={styles.fill}>\n        <View style={styles.root} onAccessibilityEscape={onClose}>\n          <Animated.View\n            style={[StyleSheet.absoluteFill, { backgroundColor: colors.scrim }, scrim]}\n          >\n            <Pressable\n              style={StyleSheet.absoluteFill}\n              onPress={onClose}\n              accessibilityRole=\"button\"\n              accessibilityLabel=\"Close\"\n            />\n          </Animated.View>\n          <GestureDetector gesture={pan}>\n            <Animated.View\n              collapsable={false}\n              testID={testID}\n              onLayout={(e) => height.set(e.nativeEvent.layout.height)}\n              style={[\n                styles.sheet,\n                { paddingBottom: MARGIN + (insets?.bottom ?? 0), gap: 8 },\n                style,\n                sheet,\n              ]}\n            >\n              <View\n                style={[\n                  styles.card,\n                  {\n                    backgroundColor: colors.surfaceRaised,\n                    borderRadius: radius.xl,\n                    boxShadow: shadow.lg,\n                  },\n                ]}\n              >\n                <View style={[styles.grabber, { backgroundColor: colors.borderStrong }]} />\n                {title || message ? (\n                  <View style={[styles.head, { borderBottomColor: colors.border }]}>\n                    {title ? (\n                      <Text\n                        accessibilityRole=\"header\"\n                        style={[\n                          styles.center,\n                          {\n                            color: colors.textMuted,\n                            fontSize: font.size.sm,\n                            fontWeight: font.weight.semibold,\n                          },\n                        ]}\n                      >\n                        {title}\n                      </Text>\n                    ) : null}\n                    {message ? (\n                      <Text\n                        style={[\n                          styles.center,\n                          { color: colors.textSubtle, fontSize: font.size.xs },\n                        ]}\n                      >\n                        {message}\n                      </Text>\n                    ) : null}\n                  </View>\n                ) : null}\n                {actions.map((a, i) => (\n                  <Pressable\n                    key={a.label}\n                    onPress={() => choose(a)}\n                    disabled={a.disabled}\n                    accessibilityRole=\"button\"\n                    accessibilityLabel={a.label}\n                    accessibilityState={{ disabled: a.disabled }}\n                    style={({ pressed }) => [\n                      styles.row,\n                      i > 0 && {\n                        borderTopColor: colors.border,\n                        borderTopWidth: StyleSheet.hairlineWidth,\n                      },\n                      {\n                        backgroundColor: pressed ? colors.surfaceSunken : undefined,\n                        opacity: a.disabled ? 0.4 : 1,\n                      },\n                    ]}\n                  >\n                    <Text\n                      style={{\n                        color: a.tone === 'danger' ? colors.danger : colors.text,\n                        fontSize: font.size.lg,\n                      }}\n                    >\n                      {a.label}\n                    </Text>\n                  </Pressable>\n                ))}\n              </View>\n              <Pressable\n                onPress={onClose}\n                accessibilityRole=\"button\"\n                accessibilityLabel={cancelLabel}\n                style={({ pressed }) => [\n                  styles.row,\n                  styles.card,\n                  {\n                    backgroundColor: pressed ? colors.surfaceSunken : colors.surfaceRaised,\n                    borderRadius: radius.xl,\n                  },\n                ]}\n              >\n                <Text\n                  style={{\n                    color: colors.text,\n                    fontSize: font.size.lg,\n                    fontWeight: font.weight.semibold,\n                  }}\n                >\n                  {cancelLabel}\n                </Text>\n              </Pressable>\n            </Animated.View>\n          </GestureDetector>\n        </View>\n      </GestureHandlerRootView>\n    </Modal>\n  );\n}\n\nconst styles = StyleSheet.create({\n  fill: { flex: 1 },\n  root: { flex: 1, justifyContent: 'flex-end' },\n  sheet: { paddingHorizontal: MARGIN },\n  card: { overflow: 'hidden' },\n  grabber: {\n    alignSelf: 'center',\n    width: 36,\n    height: 4,\n    borderRadius: 2,\n    marginTop: 8,\n    marginBottom: 2,\n  },\n  head: {\n    paddingHorizontal: 20,\n    paddingTop: 8,\n    paddingBottom: 14,\n    gap: 4,\n    borderBottomWidth: StyleSheet.hairlineWidth,\n  },\n  center: { textAlign: 'center' },\n  row: { height: ROW, alignItems: 'center', justifyContent: 'center', paddingHorizontal: 20 },\n});\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "kind": "component",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "category": "overlay",
    "web": "live",
    "perf": {
      "budget": "A transparent modal of plain views; the sheet and scrim read two shared values. Nothing runs at rest.",
      "measurements": [
        {
          "device": "Pixel 9 emulator, API 35",
          "kind": "emulator",
          "date": "2026-10-13",
          "build": "release",
          "frameMs": 19,
          "p90Ms": 23,
          "baselineMs": 18,
          "jankyPercent": 6.72,
          "atRest": "idle",
          "memoryMb": 141,
          "notes": "p99 spikes are the first frame of the modal window opening."
        }
      ]
    },
    "a11y": {
      "reducedMotion": "The sheet appears and disappears without sliding.",
      "screenReader": "A heading and a button per action, plus Cancel; Back and the escape gesture close it.",
      "touchTarget": "Every action and Cancel are full-width rows 56 pt tall."
    },
    "requires": "React Native New Architecture (Reanimated 4)",
    "guide": "## Usage\n\n```tsx\nimport { ActionSheet } from '@/components/kinetik/action-sheet';\n\n<ActionSheet\n  visible={open}\n  onClose={() => setOpen(false)}\n  title=\"Sunset at the pier.jpg\"\n  actions={[\n    { label: 'Share', onPress: share },\n    { label: 'Delete photo', tone: 'danger', onPress: remove },\n  ]}\n/>;\n```\n\n## When to use\n\n- A short list of things to do with one object: a photo, a message, a file.\n- Phone layouts, where the actions are easiest to reach at the bottom edge.\n\n## When not to use\n\n- A single confirmation. Use Pop Dialog.\n- Menus attached to a button on wide screens. Use Pop Menu.\n\n## Notes\n\n- A chosen action runs after the sheet has closed, so navigation or a dialog it opens never overlaps the exit.\n- Drag the sheet down past about a quarter of its height, or flick it, to close it; a shorter drag springs back.\n- The bottom padding follows the safe area when the app has a `SafeAreaProvider` (Expo Router adds one).\n- With reduced motion it appears and disappears without sliding.\n"
  },
  "docs": "Prefer `npx kinetik-ui add action-sheet`: it installs dependencies with expo install, so versions match your Expo SDK."
}
