{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "combobox",
  "title": "Combobox",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-native/components/combobox/Combobox.tsx",
      "content": "import * as React from 'react'\nimport { Platform, Pressable, View, type PressableProps, type ViewProps } from 'react-native'\nimport { Check, ChevronDown } from 'lucide-react-native'\nimport { Button, type ButtonProps } from '@/components/ui/button'\nimport { SearchBar, type SearchBarProps } from '@/components/ui/search-bar'\nimport { Sheet, SheetContent, type SheetContentProps } from '@/components/ui/sheet'\nimport { Text } from '@/components/ui/text'\nimport { useOverlay, useOverlayTriggerRef, type OverlayProps } from '@/lib/overlay'\nimport { useThemeColors } from '@/lib/theme'\nimport { cn } from '@/lib/utils'\nimport { renderTextChildren } from '@/lib/label-children'\n\nexport interface ComboboxOption {\n  value: string\n  label: string\n}\ninterface CommonProps extends OverlayProps {\n  disabled?: boolean\n}\nexport type ComboboxProps = CommonProps &\n  (\n    | {\n        multiple?: false\n        value?: ComboboxOption | null\n        defaultValue?: ComboboxOption | null\n        onValueChange?: (value: ComboboxOption | null) => void\n      }\n    | {\n        multiple: true\n        value?: ComboboxOption[]\n        defaultValue?: ComboboxOption[]\n        onValueChange?: (value: ComboboxOption[]) => void\n      }\n  )\ninterface ChoiceContext {\n  selected: ComboboxOption[]\n  multiple: boolean\n  disabled: boolean\n  query: string\n  setQuery: (query: string) => void\n  choose: (option: ComboboxOption) => void\n  clear: () => void\n  matches: (text: string) => boolean\n  register: (id: string, text: string) => () => void\n  hasMatches: boolean\n}\nconst Context = React.createContext<ChoiceContext | null>(null)\nfunction useChoice() {\n  const context = React.useContext(Context)\n  if (!context) throw new Error('Combobox parts must be inside Combobox')\n  return context\n}\nfunction array(value: ComboboxOption | ComboboxOption[] | null | undefined) {\n  return Array.isArray(value) ? value : value ? [value] : []\n}\nfunction matches(text: string, query: string) {\n  return text.toLocaleLowerCase().includes(query.trim().toLocaleLowerCase())\n}\n\nexport function Combobox(props: ComboboxProps) {\n  const {\n    children,\n    disabled = false,\n    value,\n    defaultValue,\n    onValueChange: _onValueChange,\n    multiple = false,\n    ...overlay\n  } = props\n  const [internal, setInternal] = React.useState(() => array(defaultValue))\n  const [query, setQuery] = React.useState('')\n  const [entries, setEntries] = React.useState<Map<string, string>>(() => new Map())\n  const selected = value === undefined ? internal : array(value)\n  const register = React.useCallback((id: string, text: string) => {\n    setEntries((previous) => new Map(previous).set(id, text))\n    return () =>\n      setEntries((previous) => {\n        if (!previous.has(id)) return previous\n        const next = new Map(previous)\n        next.delete(id)\n        return next\n      })\n  }, [])\n  function publish(next: ComboboxOption[]) {\n    if (disabled) return\n    if (value === undefined) setInternal(next)\n    if (props.multiple) props.onValueChange?.(next)\n    else props.onValueChange?.(next[0] ?? null)\n  }\n  return (\n    <Context.Provider\n      value={{\n        selected,\n        multiple,\n        disabled,\n        query,\n        setQuery,\n        register,\n        hasMatches: [...entries.values()].some((text) => matches(text, query)),\n        matches: (text) => matches(text, query),\n        choose: (option) => {\n          if (disabled) return\n          const checked = selected.some((item) => item.value === option.value)\n          if (multiple)\n            publish(checked ? selected.filter((item) => item.value !== option.value) : [...selected, option])\n          else if (!checked) publish([option])\n        },\n        clear: () => {\n          if (selected.length) publish([])\n        },\n      }}\n    >\n      <Sheet {...overlay}>{children}</Sheet>\n    </Context.Provider>\n  )\n}\n\nexport interface ComboboxTriggerProps extends Omit<ButtonProps, 'variant' | 'textClassName' | 'size'> {\n  size?: Exclude<ButtonProps['size'], 'icon'>\n  placeholder?: string\n  invalid?: boolean\n}\nexport const ComboboxTrigger = React.forwardRef<React.ComponentRef<typeof Pressable>, ComboboxTriggerProps>(\n  (\n    {\n      placeholder = 'Choose an option',\n      invalid,\n      disabled,\n      onPress,\n      children,\n      className,\n      accessibilityState,\n      accessibilityValue,\n      ...props\n    },\n    ref,\n  ) => {\n    const choice = useChoice()\n    const overlay = useOverlay()\n    const trigger = useOverlayTriggerRef(ref)\n    const colors = useThemeColors()\n    const isDisabled = choice.disabled || !!disabled\n    const label = choice.selected.map((item) => item.label).join(', ')\n    return (\n      <Button\n        {...props}\n        ref={trigger.ref}\n        variant=\"outline\"\n        accessibilityRole={Platform.OS === 'ios' ? 'button' : 'combobox'}\n        accessibilityState={{ ...accessibilityState, disabled: isDisabled, expanded: overlay.open }}\n        accessibilityValue={{ ...accessibilityValue, text: label || placeholder }}\n        disabled={isDisabled}\n        className={cn('justify-between', invalid && 'border-destructive', className)}\n        onPress={(event) => {\n          if (isDisabled) return\n          onPress?.(event)\n          if (event.isDefaultPrevented()) return\n          trigger.capture()\n          overlay.setOpen(true)\n        }}\n      >\n        <Text className={cn('min-w-0 flex-1', !label && 'text-muted-foreground')}>\n          {children ?? (label || placeholder)}\n        </Text>\n        <ChevronDown size={20} color={colors.foreground} aria-hidden />\n      </Button>\n    )\n  },\n)\nComboboxTrigger.displayName = 'ComboboxTrigger'\n\nexport const ComboboxContent = React.forwardRef<React.ComponentRef<typeof View>, SheetContentProps>((props, ref) => (\n  <SheetContent ref={ref} {...props} />\n))\nComboboxContent.displayName = 'ComboboxContent'\nexport type ComboboxContentProps = SheetContentProps\n\nexport type ComboboxSearchProps = Omit<SearchBarProps, 'value' | 'defaultValue' | 'onChangeText'>\nexport const ComboboxSearch = React.forwardRef<React.ComponentRef<typeof SearchBar>, ComboboxSearchProps>(\n  ({ editable, accessibilityLabel = 'Search options', ...props }, ref) => {\n    const choice = useChoice()\n    return (\n      <SearchBar\n        ref={ref}\n        {...props}\n        accessibilityLabel={accessibilityLabel}\n        value={choice.query}\n        onChangeText={choice.setQuery}\n        editable={!choice.disabled && editable !== false}\n      />\n    )\n  },\n)\nComboboxSearch.displayName = 'ComboboxSearch'\n\nexport interface ComboboxItemProps extends Omit<PressableProps, 'children'> {\n  children?: React.ReactNode\n  value: string\n  label: string\n  searchText?: string\n  className?: string\n}\nexport const ComboboxItem = React.forwardRef<React.ComponentRef<typeof Pressable>, ComboboxItemProps>(\n  ({ value, label, searchText = label, children, disabled, onPress, className, accessibilityState, ...props }, ref) => {\n    const choice = useChoice()\n    const { setOpen } = useOverlay()\n    const colors = useThemeColors()\n    const id = React.useId()\n    const { register } = choice\n    React.useLayoutEffect(() => register(id, searchText), [register, id, searchText])\n    if (!choice.matches(searchText)) return null\n    const checked = choice.selected.some((option) => option.value === value)\n    const isDisabled = choice.disabled || !!disabled\n    return (\n      <Pressable\n        {...props}\n        ref={ref}\n        disabled={isDisabled}\n        accessibilityRole={choice.multiple ? 'checkbox' : 'radio'}\n        accessibilityLabel={props.accessibilityLabel ?? label}\n        accessibilityState={{ ...accessibilityState, disabled: isDisabled, checked }}\n        className={cn(\n          'min-h-[48px] flex-row items-center gap-[12px] rounded-md px-[12px] py-[12px] active:bg-muted',\n          checked && 'bg-secondary',\n          isDisabled && 'opacity-50',\n          className,\n        )}\n        onPress={(event) => {\n          if (isDisabled) return\n          onPress?.(event)\n          if (event.isDefaultPrevented()) return\n          choice.choose({ value, label })\n          if (!choice.multiple) setOpen(false)\n        }}\n      >\n        <View pointerEvents=\"none\" aria-hidden className=\"min-w-0 flex-1 gap-[4px]\">\n          <Text className=\"font-medium\">{label}</Text>\n          {renderTextChildren(children, 'text-muted-foreground')}\n        </View>\n        <View pointerEvents=\"none\" aria-hidden className=\"size-[20px] items-center justify-center\">\n          {checked ? <Check size={20} color={colors.foreground} aria-hidden /> : null}\n        </View>\n      </Pressable>\n    )\n  },\n)\nComboboxItem.displayName = 'ComboboxItem'\n\nexport const ComboboxEmpty = React.forwardRef<React.ComponentRef<typeof View>, ViewProps & { className?: string }>(\n  ({ children = <Text variant=\"muted\">No matching options.</Text>, className, ...props }, ref) => {\n    const choice = useChoice()\n    if (choice.hasMatches) return null\n    return (\n      <View {...props} ref={ref} className={cn('p-[16px]', className)}>\n        {children}\n      </View>\n    )\n  },\n)\nComboboxEmpty.displayName = 'ComboboxEmpty'\n\nexport const ComboboxClear = React.forwardRef<React.ComponentRef<typeof Pressable>, ButtonProps>(\n  ({ children = 'Clear selection', disabled, onPress, ...props }, ref) => {\n    const choice = useChoice()\n    const isDisabled = choice.disabled || !!disabled || !choice.selected.length\n    return (\n      <Button\n        {...props}\n        ref={ref}\n        disabled={isDisabled}\n        onPress={(event) => {\n          if (isDisabled) return\n          onPress?.(event)\n          if (!event.isDefaultPrevented()) choice.clear()\n        }}\n      >\n        {children}\n      </Button>\n    )\n  },\n)\nComboboxClear.displayName = 'ComboboxClear'\nexport { SheetClose as ComboboxClose } from '@/components/ui/sheet'\n",
      "type": "registry:ui",
      "target": "~/components/ui/combobox/Combobox.tsx"
    },
    {
      "path": "packages/registry-native/components/combobox/index.ts",
      "content": "export * from './Combobox'\n",
      "type": "registry:ui",
      "target": "~/components/ui/combobox/index.ts"
    }
  ],
  "dependencies": [
    "lucide-react-native",
    "react-native-svg"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/search-bar.json",
    "https://native.uipkge.dev/r/native/sheet.json",
    "https://native.uipkge.dev/r/native/text.json",
    "https://native.uipkge.dev/r/native/theme.json",
    "https://native.uipkge.dev/r/native/utils.json",
    "https://native.uipkge.dev/r/native/overlay.json",
    "https://native.uipkge.dev/r/native/label-children.json"
  ],
  "description": "Searchable single or multiple selection with composed options and native sheet dismissal."
}