{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "snackbar",
  "title": "Snackbar",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-native/components/snackbar/Snackbar.tsx",
      "content": "import * as React from 'react'\nimport {\n  AccessibilityInfo,\n  AppState,\n  KeyboardAvoidingView,\n  Platform,\n  Pressable,\n  ScrollView,\n  StyleSheet,\n  View,\n  type ViewProps,\n} from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { X } from 'lucide-react-native'\nimport { Button, type ButtonProps } from '@/components/ui/button'\nimport { Text } from '@/components/ui/text'\nimport { useAnnouncement } from '@/lib/accessibility'\nimport { cn } from '@/lib/utils'\nimport { useThemeColors } from '@/lib/theme'\n\nexport interface SnackbarProps extends ViewProps {\n  open?: boolean\n  defaultOpen?: boolean\n  onOpenChange?: (open: boolean) => void\n  message: string\n  /** Milliseconds. Zero disables automatic dismissal. Screen readers also keep the message open. */\n  duration?: number\n  /** Extra space above app-owned bottom navigation. Safe areas are added automatically. */\n  bottomOffset?: number\n  closeLabel?: string\n  className?: string\n}\n\nconst SnackbarContext = React.createContext<(() => void) | null>(null)\n\nexport const Snackbar = React.forwardRef<React.ComponentRef<typeof View>, SnackbarProps>(\n  (\n    {\n      open,\n      defaultOpen = false,\n      onOpenChange,\n      message,\n      duration = 5000,\n      bottomOffset = 0,\n      closeLabel = 'Dismiss message',\n      className,\n      children,\n      ...props\n    },\n    ref,\n  ) => {\n    const [internal, setInternal] = React.useState(defaultOpen)\n    const visible = open ?? internal\n    const [screenReader, setScreenReader] = React.useState(true)\n    const [appState, setAppState] = React.useState(AppState.currentState)\n    const [interacting, setInteracting] = React.useState(false)\n    const insets = useSafeAreaInsets()\n    const colors = useThemeColors()\n    const requested = React.useRef(visible)\n    requested.current = visible\n    const controlled = open !== undefined\n    const change = React.useRef(onOpenChange)\n    change.current = onOpenChange\n    const dismiss = React.useCallback(() => {\n      if (!requested.current) return\n      if (!controlled) {\n        requested.current = false\n        setInternal(false)\n      }\n      change.current?.(false)\n    }, [controlled])\n    useAnnouncement(visible ? message : undefined)\n\n    React.useEffect(() => {\n      setInteracting(false)\n      if (!visible) return\n      let mounted = true\n      void AccessibilityInfo.isScreenReaderEnabled().then((enabled) => {\n        if (mounted) setScreenReader(enabled)\n      })\n      setAppState(AppState.currentState)\n      const reader = AccessibilityInfo.addEventListener('screenReaderChanged', setScreenReader)\n      const app = AppState.addEventListener('change', setAppState)\n      return () => {\n        mounted = false\n        reader.remove()\n        app.remove()\n      }\n    }, [visible])\n\n    React.useEffect(() => {\n      if (\n        !visible ||\n        screenReader ||\n        interacting ||\n        appState !== 'active' ||\n        duration <= 0 ||\n        !Number.isFinite(duration)\n      )\n        return\n      const timeout = setTimeout(dismiss, duration)\n      return () => clearTimeout(timeout)\n    }, [visible, message, duration, screenReader, appState, interacting, dismiss])\n\n    if (!visible) return null\n    return (\n      <SnackbarContext.Provider value={dismiss}>\n        <KeyboardAvoidingView\n          pointerEvents=\"box-none\"\n          behavior={Platform.OS === 'ios' ? 'padding' : undefined}\n          style={StyleSheet.absoluteFill}\n        >\n          <View\n            pointerEvents=\"box-none\"\n            style={{\n              flex: 1,\n              justifyContent: 'flex-end',\n              paddingLeft: insets.left + 16,\n              paddingRight: insets.right + 16,\n              paddingBottom: insets.bottom + 16 + Math.max(0, bottomOffset),\n            }}\n          >\n            <View\n              ref={ref}\n              {...props}\n              onTouchStart={(event) => {\n                setInteracting(true)\n                props.onTouchStart?.(event)\n              }}\n              onTouchEnd={(event) => {\n                setInteracting(false)\n                props.onTouchEnd?.(event)\n              }}\n              onTouchCancel={(event) => {\n                setInteracting(false)\n                props.onTouchCancel?.(event)\n              }}\n              style={[\n                { width: '100%', maxWidth: 600, maxHeight: '100%', flexShrink: 1, alignSelf: 'center' },\n                props.style,\n              ]}\n              className={cn('bg-card border-border gap-3 rounded-xl border p-4 shadow-sm', className)}\n            >\n              <ScrollView\n                style={{ flexGrow: 0, flexShrink: 1 }}\n                contentContainerStyle={{ gap: 12 }}\n                keyboardShouldPersistTaps=\"handled\"\n              >\n                <Text>{message}</Text>\n                <View className=\"flex-row flex-wrap items-center justify-end gap-[8px]\">\n                  {children}\n                  <Button variant=\"ghost\" size=\"icon\" accessibilityLabel={closeLabel} onPress={dismiss}>\n                    <X size={20} color={colors.foreground} aria-hidden />\n                  </Button>\n                </View>\n              </ScrollView>\n            </View>\n          </View>\n        </KeyboardAvoidingView>\n      </SnackbarContext.Provider>\n    )\n  },\n)\nSnackbar.displayName = 'Snackbar'\n\nexport const SnackbarAction = React.forwardRef<React.ComponentRef<typeof Pressable>, ButtonProps>(\n  ({ onPress, disabled, loading, ...props }, ref) => {\n    const dismiss = React.useContext(SnackbarContext)\n    if (!dismiss) throw new Error('SnackbarAction must be inside Snackbar')\n    return (\n      <Button\n        ref={ref}\n        variant=\"secondary\"\n        {...props}\n        disabled={disabled}\n        loading={loading}\n        onPress={(event) => {\n          if (disabled || loading) return\n          onPress?.(event)\n          if (!event.isDefaultPrevented()) dismiss()\n        }}\n      />\n    )\n  },\n)\nSnackbarAction.displayName = 'SnackbarAction'\n",
      "type": "registry:ui",
      "target": "~/components/ui/snackbar/Snackbar.tsx"
    },
    {
      "path": "packages/registry-native/components/snackbar/index.ts",
      "content": "export { Snackbar, SnackbarAction, type SnackbarProps } from './Snackbar'\n",
      "type": "registry:ui",
      "target": "~/components/ui/snackbar/index.ts"
    }
  ],
  "dependencies": [
    "react-native-safe-area-context",
    "lucide-react-native",
    "react-native-svg"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/text.json",
    "https://native.uipkge.dev/r/native/accessibility.json",
    "https://native.uipkge.dev/r/native/theme.json"
  ],
  "description": "Non-modal feedback with optional actions, safe-area and keyboard placement, polite announcements, and automatic dismissal paused for screen readers, touch, and backgrounding.",
  "categories": [
    "feedback"
  ]
}