{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "combo-box",
  "type": "registry:ui",
  "title": "ComboBox",
  "description": "Select combined with a text input: filter the option list and either pick an option or type a custom value.",
  "dependencies": [
    "@remixicon/react@^4.9.0",
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "https://wideset.co/r/icon-button.json",
    "https://wideset.co/r/list-item.json",
    "https://wideset.co/r/motion.json",
    "https://wideset.co/r/popup.json",
    "https://wideset.co/r/select.json",
    "https://wideset.co/r/styles.json",
    "https://wideset.co/r/text-input.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/components/combo-box/ComboBox.context.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/combo-box/ComboBox.context.ts",
      "content": "'use client';\n\nimport {\n  createContext,\n  type FocusEventHandler,\n  type KeyboardEventHandler,\n  type MouseEvent,\n  useCallback,\n  useContext,\n  useEffect,\n  useId,\n  useMemo,\n  useRef,\n  useState,\n} from 'react';\n\nimport type { SelectOptionType } from '../select/Select.types';\nimport type { ComboBoxContextValue, ComboBoxRootProps } from './ComboBox.types';\n\nexport const ComboBoxContext = createContext<ComboBoxContextValue | undefined>(undefined);\n\nexport function useCreateComboBoxContextValue({\n  options = [],\n  value,\n  defaultValue,\n  clearable,\n  disallowCustomValue,\n  disabled,\n  open,\n  defaultOpen,\n  onOpenChange,\n  onChange,\n  onClear,\n}: ComboBoxRootProps): ComboBoxContextValue {\n  const [internalValue, setInternalValue] = useState(defaultValue ?? '');\n  const isControlled = value !== undefined;\n  const currentValue = isControlled ? value : internalValue;\n  const [search, setSearch] = useState('');\n  const contentId = useId();\n\n  const [internalOpen, setInternalOpen] = useState(defaultOpen ?? false);\n  const isOpenControlled = open !== undefined;\n  const isOpen = isOpenControlled ? open : internalOpen;\n\n  const [highlightedIndex, setHighlightedIndex] = useState(0);\n\n  const inputRef = useRef<HTMLInputElement>(null);\n\n  const selectedOption = useMemo(\n    () => options.find((option) => option.value === currentValue),\n    [currentValue, options],\n  );\n\n  const filteredOptions = useMemo(\n    () =>\n      search\n        ? options.filter((option) => option.label.toLowerCase().includes(search.toLowerCase()))\n        : options,\n    [options, search],\n  );\n\n  const getFirstEnabledIndex = useCallback(\n    () => filteredOptions.findIndex((option) => !option.disabled),\n    [filteredOptions],\n  );\n\n  const getLastEnabledIndex = useCallback(() => {\n    for (let index = filteredOptions.length - 1; index >= 0; index -= 1) {\n      if (!filteredOptions[index]?.disabled) return index;\n    }\n\n    return -1;\n  }, [filteredOptions]);\n\n  const getSelectedEnabledIndex = useCallback(\n    () => filteredOptions.findIndex((option) => option.value === currentValue && !option.disabled),\n    [currentValue, filteredOptions],\n  );\n\n  const setOpenState = useCallback(\n    (nextOpen: boolean) => {\n      if (!isOpenControlled) setInternalOpen(nextOpen);\n      onOpenChange?.(nextOpen);\n    },\n    [isOpenControlled, onOpenChange],\n  );\n\n  const setValue = useCallback(\n    (nextValue: string) => {\n      if (!isControlled) setInternalValue(nextValue);\n      onChange?.(nextValue);\n    },\n    [isControlled, onChange],\n  );\n\n  useEffect(() => {\n    if (!search) return;\n\n    setHighlightedIndex(getFirstEnabledIndex());\n  }, [getFirstEnabledIndex, search]);\n\n  useEffect(() => {\n    if (!filteredOptions.length) {\n      setHighlightedIndex(-1);\n      return;\n    }\n\n    setHighlightedIndex((previousIndex) => {\n      if (filteredOptions[previousIndex] && !filteredOptions[previousIndex].disabled) {\n        return previousIndex;\n      }\n\n      return getFirstEnabledIndex();\n    });\n  }, [filteredOptions, getFirstEnabledIndex]);\n\n  useEffect(() => {\n    if (!isOpen) return;\n\n    const selectedEnabledIndex = getSelectedEnabledIndex();\n    setHighlightedIndex(selectedEnabledIndex >= 0 ? selectedEnabledIndex : getFirstEnabledIndex());\n  }, [isOpen, getFirstEnabledIndex, getSelectedEnabledIndex]);\n\n  useEffect(() => {\n    if (!isOpen) return;\n\n    requestAnimationFrame(() => {\n      inputRef.current?.focus();\n      if (disallowCustomValue && !search && selectedOption?.label) {\n        inputRef.current?.select();\n      }\n    });\n  }, [isOpen, disallowCustomValue, search, selectedOption?.label]);\n\n  const handleSelect = useCallback(\n    (option: SelectOptionType) => {\n      if (disabled || option.disabled) return;\n\n      setValue(option.value);\n      setSearch('');\n      setOpenState(false);\n    },\n    [disabled, setValue, setOpenState],\n  );\n\n  const handleClear = useCallback(\n    (event: MouseEvent<HTMLButtonElement>) => {\n      event.preventDefault();\n      event.stopPropagation();\n\n      setValue('');\n      setSearch('');\n      onClear?.();\n      setOpenState(false);\n    },\n    [setValue, onClear, setOpenState],\n  );\n\n  const handleInputChange = useCallback(\n    (nextValue: string) => {\n      if (disabled) return;\n\n      if (!disallowCustomValue) {\n        setValue(nextValue);\n      } else if (nextValue === '') {\n        setValue('');\n      }\n\n      setSearch(nextValue);\n    },\n    [disabled, disallowCustomValue, setValue],\n  );\n\n  const handleOpenChange = useCallback(\n    (nextOpen: boolean) => {\n      if (disabled) return;\n\n      if (!nextOpen && disallowCustomValue) setSearch('');\n\n      setOpenState(nextOpen);\n    },\n    [disabled, disallowCustomValue, setOpenState],\n  );\n\n  const getNextEnabledIndex = useCallback(\n    (currentIndex: number, direction: 1 | -1): number => {\n      if (!filteredOptions.length) return -1;\n\n      if (currentIndex < 0) {\n        return direction === 1 ? getFirstEnabledIndex() : getLastEnabledIndex();\n      }\n\n      for (let step = 1; step <= filteredOptions.length; step += 1) {\n        const nextIndex =\n          (currentIndex + step * direction + filteredOptions.length) % filteredOptions.length;\n        if (!filteredOptions[nextIndex]?.disabled) return nextIndex;\n      }\n\n      return currentIndex;\n    },\n    [filteredOptions, getFirstEnabledIndex, getLastEnabledIndex],\n  );\n\n  const handleInputKeyDown = useCallback<KeyboardEventHandler<HTMLInputElement>>(\n    (event) => {\n      switch (event.key) {\n        case 'ArrowDown': {\n          event.preventDefault();\n          if (!isOpen) {\n            setOpenState(true);\n          } else {\n            setHighlightedIndex((previousIndex) => getNextEnabledIndex(previousIndex, 1));\n          }\n          break;\n        }\n        case 'ArrowUp': {\n          event.preventDefault();\n          if (isOpen) {\n            setHighlightedIndex((previousIndex) => getNextEnabledIndex(previousIndex, -1));\n          }\n          break;\n        }\n        case 'Enter': {\n          event.preventDefault();\n          if (\n            isOpen &&\n            filteredOptions[highlightedIndex] &&\n            !filteredOptions[highlightedIndex].disabled\n          ) {\n            handleSelect(filteredOptions[highlightedIndex]);\n          } else if (!disallowCustomValue) {\n            setOpenState(false);\n          }\n          break;\n        }\n        case 'Escape': {\n          event.preventDefault();\n          setSearch('');\n          setOpenState(false);\n          break;\n        }\n        case 'Tab': {\n          if (isOpen) {\n            if (disallowCustomValue) setSearch('');\n            setOpenState(false);\n          }\n          break;\n        }\n      }\n    },\n    [\n      isOpen,\n      disallowCustomValue,\n      filteredOptions,\n      getNextEnabledIndex,\n      handleSelect,\n      highlightedIndex,\n      setOpenState,\n    ],\n  );\n\n  const handleInputBlur = useCallback<FocusEventHandler<HTMLInputElement>>(() => {\n    if (disallowCustomValue) setSearch('');\n\n    setOpenState(false);\n  }, [disallowCustomValue, setOpenState]);\n\n  const getOptionId = useCallback((index: number) => `${contentId}-option-${index}`, [contentId]);\n\n  const handleItemMouseEnter = useCallback((index: number) => {\n    if (index < 0) return;\n\n    setHighlightedIndex(index);\n  }, []);\n\n  return {\n    contentId,\n    open: isOpen,\n    onOpenChange: handleOpenChange,\n    options,\n    inputRef,\n    currentValue,\n    search,\n    disallowCustomValue,\n    displayedLabel: selectedOption?.label ?? (disallowCustomValue ? '' : currentValue),\n    inputValue: disallowCustomValue\n      ? search || selectedOption?.label || ''\n      : (selectedOption?.label ?? currentValue),\n    hasClearButton: Boolean(clearable && !disabled && (currentValue !== '' || search !== '')),\n    filteredOptions,\n    highlightedIndex,\n    getOptionId,\n    activeDescendantId:\n      isOpen && filteredOptions[highlightedIndex] ? getOptionId(highlightedIndex) : undefined,\n    onInputChange: handleInputChange,\n    onInputKeyDown: handleInputKeyDown,\n    onInputBlur: handleInputBlur,\n    onSelect: handleSelect,\n    onItemMouseEnter: handleItemMouseEnter,\n    onClear: handleClear,\n  };\n}\n\nexport const useComboBoxContext = () => {\n  const context = useContext(ComboBoxContext);\n\n  if (context === undefined) {\n    throw new Error('useComboBoxContext must be used within a ComboBox');\n  }\n\n  return context;\n};\n"
    },
    {
      "path": "src/components/combo-box/ComboBox.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/combo-box/ComboBox.tsx",
      "content": "'use client';\n\nimport React from 'react';\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useComboBoxContext } from './ComboBox.context';\nimport type {\n  ComboBoxIconProps,\n  ComboBoxPrefixProps,\n  ComboBoxProps,\n  ComboBoxWithSubComponents,\n} from './ComboBox.types';\nimport { ComboBoxContent } from './ComboBoxContent';\nimport { ComboBoxItem } from './ComboBoxItem';\nimport { ComboBoxRoot } from './ComboBoxRoot';\nimport { ComboBoxTrigger } from './ComboBoxTrigger';\n\nconst ComboBoxBody = ({\n  className,\n  children,\n  placeholder,\n  size,\n  preset,\n  disabled,\n  variant,\n  ...props\n}: Omit<\n  ComboBoxProps,\n  | 'options'\n  | 'clearable'\n  | 'disallowCustomValue'\n  | 'value'\n  | 'defaultValue'\n  | 'onChange'\n  | 'onClear'\n>) => {\n  const { options, currentValue, filteredOptions } = useComboBoxContext();\n\n  const selectedOption = options?.find((option) => option.value === currentValue);\n\n  const triggerChildren =\n    children ??\n    (selectedOption?.prefix ? <TextInput.Prefix>{selectedOption.prefix}</TextInput.Prefix> : null);\n\n  const hasPrefix = React.Children.toArray(triggerChildren).some(\n    (child) =>\n      React.isValidElement(child) &&\n      (child.type === TextInput.Prefix || child.type === ComboBoxPrefix),\n  );\n\n  return (\n    <>\n      <ComboBoxTrigger\n        className={cn('relative w-[16rem]', className)}\n        size={size}\n        variant={variant}\n        preset={preset}\n        disabled={disabled}\n        hasPrefix={hasPrefix}\n        placeholder={placeholder}\n        {...props}\n      >\n        {triggerChildren}\n      </ComboBoxTrigger>\n      {filteredOptions.length > 0 && (\n        <ComboBoxContent>\n          {filteredOptions.map((option) => (\n            <ComboBoxItem key={option.value} value={option.value} />\n          ))}\n        </ComboBoxContent>\n      )}\n    </>\n  );\n};\n\nconst ComboBox = (({\n  options,\n  placeholder,\n  className,\n  children,\n  clearable,\n  disallowCustomValue,\n  value,\n  defaultValue,\n  onChange,\n  onClear,\n  size,\n  preset,\n  disabled,\n  variant = 'primary',\n  defaultMotion,\n  ...props\n}: ComboBoxProps) => {\n  const isComposable = React.Children.toArray(children).some(\n    (child) =>\n      React.isValidElement(child) &&\n      (child.type === ComboBoxTrigger || child.type === ComboBoxContent),\n  );\n\n  return (\n    <ComboBoxRoot\n      options={options}\n      clearable={clearable}\n      disallowCustomValue={disallowCustomValue}\n      value={value}\n      defaultValue={defaultValue}\n      onChange={onChange}\n      onClear={onClear}\n      disabled={disabled}\n      defaultMotion={defaultMotion}\n    >\n      {isComposable ? (\n        children\n      ) : (\n        <ComboBoxBody\n          className={className}\n          placeholder={placeholder}\n          size={size}\n          preset={preset}\n          disabled={disabled}\n          variant={variant}\n          {...props}\n        >\n          {children}\n        </ComboBoxBody>\n      )}\n    </ComboBoxRoot>\n  );\n}) as ComboBoxWithSubComponents;\n\nComboBox.displayName = 'ComboBox';\nComboBox.Trigger = ComboBoxTrigger;\nComboBox.Content = ComboBoxContent;\nComboBox.Item = ComboBoxItem;\nexport const ComboBoxPrefix = (props: ComboBoxPrefixProps) => (\n  <TextInput.Prefix data-slot=\"combo-box-prefix\" {...props} />\n);\nComboBoxPrefix.displayName = 'ComboBox.Prefix';\nComboBox.Prefix = ComboBoxPrefix;\nexport const ComboBoxIcon = (props: ComboBoxIconProps) => (\n  <TextInput.Icon data-slot=\"combo-box-icon\" {...props} />\n);\nComboBoxIcon.displayName = 'ComboBox.Icon';\nComboBox.Icon = ComboBoxIcon;\n\nexport { ComboBox };\n"
    },
    {
      "path": "src/components/combo-box/ComboBox.types.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/combo-box/ComboBox.types.ts",
      "content": "import type React from 'react';\n\nimport type { MotionProps } from '@/lib/wideset/motion/Motion.types';\nimport type { ListItem } from '../list-item/ListItem';\nimport type { Popup } from '../popup/Popup';\nimport type { SelectOptionType, SelectProps } from '../select/Select.types';\nimport type { TextInput } from '../text-input/TextInput';\nimport type { TextInputIconProps, TextInputProps } from '../text-input/TextInput.types';\nimport type { TextInputPrefixProps } from '../text-input/TextInputPrefix';\nimport type { ComboBoxContent } from './ComboBoxContent';\nimport type { ComboBoxItem } from './ComboBoxItem';\nimport type { ComboBoxTrigger } from './ComboBoxTrigger';\n\n/** A searchable selection control that can accept custom values. Name it with `aria-label` or `aria-labelledby`; a `<label htmlFor>` does not reach it. */\nexport type ComboBoxProps = Omit<\n  React.ComponentPropsWithoutRef<'div'>,\n  'children' | 'className' | 'onChange' | 'defaultValue'\n> &\n  MotionProps & {\n    /** Sub-components for composable usage (`ComboBox.Trigger`, `ComboBox.Content`, `ComboBox.Item`). Use instead of the default rendering when you need custom layouts or full rendering control. */\n    children?: React.ReactNode;\n    /** Array of options to display in the dropdown. Each item requires `value` and `label`. */\n    options?: SelectProps['options'];\n    /** Placeholder text shown in the trigger when no option is selected and no custom value is typed. */\n    placeholder?: string;\n    /** Additional CSS classes applied to the trigger element. Width utilities (e.g. `w-[20rem]`) override the default width. */\n    className?: string;\n    /** Controls the height, padding, and typography size of the trigger and its filter input. */\n    size?: SelectProps['size'];\n    /** Visual style preset. `border` adds a visible border and background; `ghost` uses a transparent background. */\n    preset?: SelectProps['preset'];\n    /** Color variant. `danger` applies error styling for form validation feedback. */\n    variant?: SelectProps['variant'];\n    /** Whether to show a clear button in the trigger when a value is selected or text is typed. */\n    clearable?: boolean;\n    /** Called when the clear button is clicked. Use for custom reset logic beyond clearing the value. */\n    onClear?: () => void;\n    /** Disables the combobox: it cannot be opened, typed into, or cleared, and is removed from the tab order. */\n    disabled?: boolean;\n    /** Restricts the value to existing options. When enabled, typed text only filters the list instead of becoming a custom value; clearing the input deselects. */\n    disallowCustomValue?: boolean;\n    /** Controlled selected value. Matches an option `value`, or any custom string when custom values are allowed. */\n    value?: string;\n    /** Initial value for uncontrolled usage. Seeds the selection on first render only; ignored afterwards. */\n    defaultValue?: string;\n    /** Called when the selected option or typed custom value changes. Receives the next string value and fires in both controlled and uncontrolled modes. */\n    onChange?: (value: string) => void;\n    /** Accessible label for the clear-selection button rendered in the trigger. Defaults to `'Clear selection'`. */\n    clearSelectionAriaLabel?: string;\n  };\n\nexport type ComboBoxWithSubComponents = React.FC<ComboBoxProps> & {\n  Trigger: typeof ComboBoxTrigger;\n  Content: typeof ComboBoxContent;\n  Item: typeof ComboBoxItem;\n  Prefix: typeof TextInput.Prefix;\n  Icon: typeof TextInput.Icon;\n};\n\nexport type ComboBoxOption = SelectOptionType;\n\n/** The content surface rendered within `ComboBox`. */\nexport type ComboBoxContentProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> &\n  MotionProps & {\n    /** Composed content, or a render function called for each filtered option. */\n    children?: React.ReactNode | ((option: ComboBoxOption) => React.ReactNode);\n  };\n\n/** An option label with matching search text highlighted. */\nexport type ComboBoxHighlightedLabelProps = {\n  /** Option label whose matching text is highlighted. */\n  label: string;\n  /** Search text to highlight within the label. */\n  search: string;\n};\n\n/** Props for the combo box root, which holds the options and value state and wraps a `Popup`. */\nexport type ComboBoxRootProps = React.ComponentProps<typeof Popup> &\n  MotionProps & {\n    /** Options available for selection. */\n    options?: ComboBoxOption[];\n    /** Controlled value. Pair with the change callback to update it. */\n    value?: string;\n    /** Initial value for uncontrolled usage; subsequent changes are ignored. */\n    defaultValue?: string;\n    /** Shows a clear button when a value is selected. */\n    clearable?: boolean;\n    /** Restricts selection to the supplied options; typed text filters the list. */\n    disallowCustomValue?: boolean;\n    /** Disables interaction with the control. */\n    disabled?: boolean;\n    /** Called with the next value in both controlled and uncontrolled usage. */\n    onChange?: (value: string) => void;\n    /** Called when the clear button resets the selection. */\n    onClear?: () => void;\n  };\n\n/** An individual item within `ComboBox`. */\nexport type ComboBoxItemProps = React.ComponentPropsWithoutRef<'li'> &\n  MotionProps & {\n    /** Option value this item represents. Must match the `value` of an option passed to the parent `ComboBox` to inherit its label, prefix, and disabled state. */\n    value: string;\n    /** Overrides the selected state. By default derived from the parent `ComboBox` value. */\n    isSelected?: boolean;\n    /** Overrides the keyboard-highlight state. By default derived from the parent `ComboBox` arrow-key navigation. */\n    isHighlighted?: boolean;\n    /** Disables the item: it cannot be selected and is skipped during keyboard navigation. Defaults to the matching option's `disabled` flag. */\n    disabled?: boolean;\n    /** Visual variant of the row. `danger` renders the item in error colors (e.g. destructive actions). Defaults to the matching option's `variant`. */\n    variant?: React.ComponentProps<typeof ListItem>['variant'];\n  };\n\n/** The control that opens or toggles the associated content. */\nexport type ComboBoxTriggerProps = React.ComponentPropsWithoutRef<'div'> &\n  MotionProps & {\n    /** Controls the height, padding, and typography size of the trigger. */\n    size?: TextInputProps['size'];\n    /** Color variant. `danger` applies error styling for form validation feedback. */\n    variant?: ComboBoxProps['variant'];\n    /** Visual style preset. `border` adds a visible border and background; `ghost` uses a transparent background. */\n    preset?: TextInputProps['preset'];\n    /** Disables the trigger: it cannot be opened, typed into, or cleared, and is removed from the tab order. */\n    disabled?: boolean;\n    /** Whether the trigger renders a `ComboBox.Prefix` — removes the left padding so the prefix sits flush. Detected automatically in the simple (non-composed) mode. */\n    hasPrefix?: boolean;\n    /** Overrides the open state. By default derived from the parent `ComboBox`. */\n    open?: boolean;\n    /** Ref to the filter input rendered while open. By default provided by the parent `ComboBox`. */\n    inputRef?: React.RefObject<HTMLInputElement | null>;\n    /** Overrides the filter input value. By default derived from the parent `ComboBox` search/selection state. */\n    inputValue?: string;\n    /** Overrides the label shown in the closed trigger. By default the selected option's label (or the custom value). */\n    displayedLabel?: string;\n    /** Placeholder text shown when no option is selected. */\n    placeholder?: string;\n    /** Overrides whether the clear button is shown. By default derived from the parent `ComboBox` `clearable` prop and current value. */\n    hasClearButton?: boolean;\n    /** Accessible label for the clear-selection button. Defaults to `'Clear selection'`. */\n    clearSelectionAriaLabel?: string;\n    /** Called with the new text whenever the filter input changes. Fires in addition to the parent `ComboBox` filtering. */\n    onInputChange?: (value: string) => void;\n    /** Keydown handler for the filter input. Fires in addition to the built-in keyboard navigation. */\n    onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n    /** Blur handler for the filter input. Fires in addition to the built-in close-on-blur behavior. */\n    onInputBlur?: React.FocusEventHandler<HTMLInputElement>;\n  };\n\nexport type ComboBoxContextValue = Pick<ComboBoxRootProps, 'options' | 'disallowCustomValue'> &\n  Pick<\n    ComboBoxTriggerProps,\n    | 'open'\n    | 'inputRef'\n    | 'displayedLabel'\n    | 'inputValue'\n    | 'hasClearButton'\n    | 'onInputChange'\n    | 'onInputKeyDown'\n    | 'onInputBlur'\n  > & {\n    contentId: string;\n    onOpenChange: (open: boolean) => void;\n    currentValue: string;\n    search: string;\n    filteredOptions: ComboBoxOption[];\n    highlightedIndex: number;\n    getOptionId?: (index: number) => string;\n    activeDescendantId?: string;\n    onSelect: (option: ComboBoxOption) => void;\n    onItemMouseEnter: (index: number) => void;\n    onClear: (event: React.MouseEvent<HTMLButtonElement>) => void;\n    motion?: boolean;\n  };\n\n/** `ComboBox.Icon` is `TextInput.Icon`; same props. */\nexport type ComboBoxIconProps = TextInputIconProps;\n\n/** `ComboBox.Prefix` is `TextInput.Prefix`; same props. */\nexport type ComboBoxPrefixProps = TextInputPrefixProps;\n"
    },
    {
      "path": "src/components/combo-box/ComboBox.variants.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/combo-box/ComboBox.variants.ts",
      "content": "import { cva } from 'class-variance-authority';\n\nimport { fieldFocusMotion } from '@/lib/wideset/motion/recipes';\n\nexport const comboBoxTriggerMotionVariants = cva('', {\n  variants: {\n    enabled: { true: fieldFocusMotion, false: '' },\n  },\n  defaultVariants: { enabled: true },\n});\n\nexport const comboBoxContentMotionVariants = cva('', {\n  variants: {\n    enabled: { true: 'origin-(--radix-popover-content-transform-origin)', false: '' },\n  },\n  defaultVariants: { enabled: true },\n});\n"
    },
    {
      "path": "src/components/combo-box/ComboBoxContent.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/combo-box/ComboBoxContent.tsx",
      "content": "'use client';\n\nimport React from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useDefaultMotion } from '@/lib/wideset/motion/MotionProvider';\nimport { Popup } from '../popup/Popup';\nimport { selectContentVariants } from '../select/Select.variants';\nimport { useComboBoxContext } from './ComboBox.context';\nimport type { ComboBoxContentProps } from './ComboBox.types';\nimport { comboBoxContentMotionVariants } from './ComboBox.variants';\n\nconst ComboBoxContent = React.forwardRef<HTMLDivElement, ComboBoxContentProps>(\n  ({ children, className, defaultMotion, ...props }, ref) => {\n    const { contentId, filteredOptions, motion: comboBoxMotion } = useComboBoxContext();\n    const motion = useDefaultMotion(defaultMotion ?? comboBoxMotion);\n\n    return filteredOptions.length > 0 ? (\n      <Popup.Container\n        ref={ref}\n        data-slot=\"combo-box-content\"\n        defaultMotion={motion}\n        // `document?.body` still throws on the server: `document` is not declared there at all.\n        className={cn(\n          selectContentVariants({ position: 'popper' }),\n          comboBoxContentMotionVariants({ enabled: motion }),\n          'max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] min-w-[var(--radix-popover-trigger-width)]',\n          className,\n        )}\n        onOpenAutoFocus={(e) => e.preventDefault()}\n        onCloseAutoFocus={(e) => e.preventDefault()}\n        {...props}\n      >\n        <ul id={contentId} role=\"listbox\" className=\"p-ws-3 max-h-[18rem] overflow-y-auto\">\n          {typeof children === 'function'\n            ? filteredOptions.map((option) => (\n                <React.Fragment key={option.value}>{children(option)}</React.Fragment>\n              ))\n            : children}\n        </ul>\n      </Popup.Container>\n    ) : null;\n  },\n);\n\nComboBoxContent.displayName = 'ComboBox.Content';\n\nexport { ComboBoxContent };\n"
    },
    {
      "path": "src/components/combo-box/ComboBoxHighlightedLabel.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/combo-box/ComboBoxHighlightedLabel.tsx",
      "content": "'use client';\n\nimport type { ComboBoxHighlightedLabelProps } from './ComboBox.types';\n\nconst ComboBoxHighlightedLabel = ({ label, search }: ComboBoxHighlightedLabelProps) => {\n  if (!search) return label;\n\n  const index = label.toLowerCase().indexOf(search.toLowerCase());\n\n  if (index === -1) return label;\n\n  return (\n    <>\n      {label.slice(0, index)}\n      <span className=\"text-ws-dynamic-primary-default\">\n        {label.slice(index, index + search.length)}\n      </span>\n      {label.slice(index + search.length)}\n    </>\n  );\n};\n\nComboBoxHighlightedLabel.displayName = 'ComboBoxHighlightedLabel';\n\nexport { ComboBoxHighlightedLabel };\n"
    },
    {
      "path": "src/components/combo-box/ComboBoxItem.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/combo-box/ComboBoxItem.tsx",
      "content": "'use client';\n\nimport React, { useCallback } from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useDefaultMotion } from '@/lib/wideset/motion/MotionProvider';\nimport { ListItem } from '../list-item/ListItem';\nimport { useComboBoxContext } from './ComboBox.context';\nimport type { ComboBoxItemProps } from './ComboBox.types';\nimport { ComboBoxHighlightedLabel } from './ComboBoxHighlightedLabel';\n\nconst ComboBoxItem = React.forwardRef<HTMLLIElement, ComboBoxItemProps>(\n  (\n    {\n      children,\n      value,\n      isHighlighted,\n      className,\n      onClick,\n      onMouseEnter,\n      defaultMotion,\n      id,\n      ...props\n    },\n    ref,\n  ) => {\n    const context = useComboBoxContext();\n    const motion = useDefaultMotion(defaultMotion ?? context.motion);\n    const contextOption = context.filteredOptions.find((option) => option.value === value);\n    const optionIndex = context.filteredOptions.findIndex((option) => option.value === value);\n\n    const disabled = props.disabled ?? contextOption?.disabled;\n    const isSelected = props.isSelected ?? context.currentValue === value;\n    const itemVariant = props.variant ?? contextOption?.variant;\n    const isItemHighlighted = isHighlighted ?? context.highlightedIndex === optionIndex;\n    const itemChildren =\n      children ??\n      (contextOption ? (\n        <>\n          {contextOption.prefix && <ListItem.Prefix>{contextOption.prefix}</ListItem.Prefix>}\n          <ListItem.Content>\n            <ListItem.Label>\n              <ComboBoxHighlightedLabel label={contextOption.label} search={context.search} />\n            </ListItem.Label>\n          </ListItem.Content>\n        </>\n      ) : null);\n\n    const handleClick = useCallback(\n      (event: React.MouseEvent<HTMLLIElement>) => {\n        if (disabled) return;\n\n        if (contextOption) {\n          context.onSelect(contextOption);\n        } else {\n          context.onOpenChange(false);\n        }\n        onClick?.(event);\n      },\n      [context, contextOption, onClick, disabled],\n    );\n\n    const handleKeyDown = useCallback(\n      (event: React.KeyboardEvent<HTMLLIElement>) => {\n        if (disabled) return;\n\n        if (event.key === 'Enter' || event.key === ' ') {\n          event.preventDefault();\n          event.currentTarget.click();\n        }\n      },\n      [disabled],\n    );\n\n    const handleMouseEnter = useCallback(\n      (event: React.MouseEvent<HTMLLIElement>) => {\n        if (disabled || optionIndex < 0) return;\n\n        context.onItemMouseEnter(optionIndex);\n        onMouseEnter?.(event);\n      },\n      [context, disabled, onMouseEnter, optionIndex],\n    );\n\n    const handleMouseDown = useCallback((event: React.MouseEvent<HTMLLIElement>) => {\n      event.preventDefault();\n    }, []);\n\n    return (\n      <li\n        ref={ref}\n        id={(optionIndex >= 0 && context.getOptionId?.(optionIndex)) || id}\n        data-slot=\"combo-box-item\"\n        role=\"option\"\n        aria-selected={isSelected}\n        aria-disabled={disabled}\n        data-highlighted={isItemHighlighted}\n        data-disabled={disabled || undefined}\n        tabIndex={disabled ? -1 : 0}\n        onMouseDown={handleMouseDown}\n        onClick={handleClick}\n        onKeyDown={handleKeyDown}\n        onMouseEnter={handleMouseEnter}\n        className={cn('list-none', className)}\n        {...props}\n      >\n        <ListItem\n          variant={itemVariant}\n          disabled={disabled}\n          data-state={isSelected ? 'checked' : undefined}\n          data-highlighted={isItemHighlighted || undefined}\n          defaultMotion={motion}\n          className={cn(\n            // Figma pins the menu row's min-height to `Size/14` (32px); ListItem's\n            // padding (Gap/3 + 20px content + Gap/3) only reaches 28px on its own.\n            'min-h-ws-14',\n            !isSelected &&\n              isItemHighlighted &&\n              !disabled &&\n              (itemVariant === 'danger'\n                ? 'bg-ws-dynamic-danger-alpha-default text-ws-dynamic-danger-default'\n                : 'bg-ws-dynamic-secondary-alpha-hover text-ws-dynamic-secondary-default'),\n          )}\n        >\n          <div className=\"gap-ws-5 flex min-w-0 flex-1 flex-row items-center overflow-hidden\">\n            {itemChildren}\n          </div>\n        </ListItem>\n      </li>\n    );\n  },\n);\n\nComboBoxItem.displayName = 'ComboBox.Item';\n\nexport { ComboBoxItem };\n"
    },
    {
      "path": "src/components/combo-box/ComboBoxRoot.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/combo-box/ComboBoxRoot.tsx",
      "content": "'use client';\n\nimport { useDefaultMotion } from '@/lib/wideset/motion/MotionProvider';\nimport { Popup } from '../popup/Popup';\nimport { ComboBoxContext, useCreateComboBoxContextValue } from './ComboBox.context';\nimport type { ComboBoxRootProps } from './ComboBox.types';\n\nconst ComboBoxRoot = ({\n  children,\n  options,\n  value,\n  defaultValue,\n  clearable,\n  disallowCustomValue,\n  disabled,\n  onChange,\n  onClear,\n  defaultMotion,\n  ...popupProps\n}: ComboBoxRootProps) => {\n  const motion = useDefaultMotion(defaultMotion);\n  const contextValue = useCreateComboBoxContextValue({\n    ...popupProps,\n    options,\n    value,\n    defaultValue,\n    clearable,\n    disallowCustomValue,\n    disabled,\n    onChange,\n    onClear,\n  });\n\n  return (\n    <ComboBoxContext.Provider value={{ ...contextValue, motion }}>\n      <Popup {...popupProps} open={contextValue.open} onOpenChange={contextValue.onOpenChange}>\n        {children}\n      </Popup>\n    </ComboBoxContext.Provider>\n  );\n};\n\nComboBoxRoot.displayName = 'ComboBoxRoot';\n\nexport { ComboBoxRoot };\n"
    },
    {
      "path": "src/components/combo-box/ComboBoxTrigger.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/combo-box/ComboBoxTrigger.tsx",
      "content": "'use client';\n\nimport { RiArrowDownSLine, RiCloseLine } from '@remixicon/react';\nimport React, { useRef } from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useDefaultMotion } from '@/lib/wideset/motion/MotionProvider';\nimport { IconButton } from '../button/IconButton';\nimport { Popup } from '../popup/Popup';\nimport {\n  selectClearButtonIconVariants,\n  selectClearButtonVariants,\n  selectTriggerSuffixIconVariants,\n  selectTriggerSuffixVariants,\n  selectTriggerVariants,\n  selectValueLeftPaddingVariants,\n  selectValueRightPaddingVariants,\n} from '../select/Select.variants';\nimport { TextInput } from '../text-input/TextInput';\nimport { TextInputContext } from '../text-input/TextInput.context';\nimport { useComboBoxContext } from './ComboBox.context';\nimport type { ComboBoxTriggerProps } from './ComboBox.types';\nimport { comboBoxTriggerMotionVariants } from './ComboBox.variants';\nimport { clearButtonOffsetVariants } from './ComboBoxTrigger.variants';\n\nconst ComboBoxTrigger = React.forwardRef<HTMLDivElement, ComboBoxTriggerProps>(\n  (\n    {\n      children,\n      className,\n      size,\n      variant,\n      preset,\n      disabled,\n      hasPrefix,\n      open,\n      inputRef,\n      inputValue,\n      displayedLabel,\n      placeholder,\n      hasClearButton,\n      clearSelectionAriaLabel = 'Clear selection',\n      onInputChange,\n      onInputKeyDown,\n      onInputBlur,\n      onClick,\n      onKeyDown,\n      defaultMotion,\n      id,\n      'aria-label': ariaLabel,\n      'aria-labelledby': ariaLabelledBy,\n      'aria-describedby': ariaDescribedBy,\n      'aria-invalid': ariaInvalid,\n      ...props\n    },\n    ref,\n  ) => {\n    const context = useComboBoxContext();\n    const motion = useDefaultMotion(defaultMotion ?? context.motion);\n    const internalInputRef = useRef<HTMLInputElement>(null);\n    const isOpen = open ?? context.open;\n\n    const resolvedInputRef = inputRef ?? context.inputRef ?? internalInputRef;\n    const resolvedInputValue = inputValue ?? context.inputValue;\n    const resolvedDisplayedLabel = displayedLabel ?? context.displayedLabel;\n    const resolvedHasClearButton = hasClearButton ?? context.hasClearButton;\n\n    const comboboxProps = {\n      'aria-controls': context.contentId,\n      'aria-expanded': isOpen,\n      'aria-haspopup': 'listbox',\n      'aria-label': ariaLabel,\n      'aria-labelledby': ariaLabelledBy,\n      'aria-describedby': ariaDescribedBy,\n      // Only when given: an `undefined` here would override the danger variant's own value.\n      ...(ariaInvalid !== undefined && { 'aria-invalid': ariaInvalid }),\n    } as const;\n\n    const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n      context.onInputChange?.(event.target.value);\n      onInputChange?.(event.target.value);\n    };\n\n    const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n      context.onInputKeyDown?.(event);\n      onInputKeyDown?.(event);\n    };\n\n    const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n      context.onInputBlur?.(event);\n      onInputBlur?.(event);\n    };\n\n    const handleTriggerOpen = (\n      event: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>,\n    ) => {\n      if (onClick) {\n        onClick(event as React.MouseEvent<HTMLDivElement>);\n        if (event.defaultPrevented) return;\n      }\n\n      context.onOpenChange(true);\n    };\n\n    const handleTriggerKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n      if (disabled || event.target !== event.currentTarget) return;\n\n      onKeyDown?.(event);\n      if (event.defaultPrevented) return;\n\n      if (event.key === 'Enter') {\n        handleTriggerOpen(event);\n        return;\n      }\n\n      if (event.key === ' ' || event.key === 'ArrowDown') {\n        event.preventDefault();\n        handleTriggerOpen(event);\n      }\n    };\n\n    return (\n      <TextInputContext.Provider\n        value={{\n          size,\n          variant,\n          disabled,\n          inputRef: resolvedInputRef,\n          currentValue: String(resolvedInputValue ?? ''),\n          handleChange: handleInputChange,\n          motion,\n        }}\n      >\n        <Popup.Trigger asChild>\n          <div\n            ref={ref}\n            id={id}\n            data-slot=\"combo-box-trigger\"\n            role={isOpen ? undefined : 'combobox'}\n            {...(isOpen\n              ? {\n                  'aria-controls': undefined,\n                  'aria-expanded': undefined,\n                  'aria-haspopup': undefined,\n                }\n              : comboboxProps)}\n            data-disabled={disabled}\n            tabIndex={disabled ? -1 : 0}\n            onKeyDown={handleTriggerKeyDown}\n            className={cn(\n              selectTriggerVariants({ size, preset, variant }),\n              comboBoxTriggerMotionVariants({ enabled: motion }),\n              !disabled && 'cursor-text',\n              hasPrefix && 'pl-0',\n              className,\n            )}\n            {...props}\n          >\n            {children}\n            {isOpen ? (\n              <TextInput.Input\n                onKeyDown={handleInputKeyDown}\n                onBlur={handleInputBlur}\n                placeholder={resolvedDisplayedLabel || placeholder}\n                className={cn(\n                  'h-auto min-w-0 flex-1 px-0',\n                  hasPrefix && selectValueLeftPaddingVariants({ size }),\n                  resolvedHasClearButton && selectValueRightPaddingVariants({ size }),\n                )}\n                role=\"combobox\"\n                {...comboboxProps}\n                aria-activedescendant={context.activeDescendantId}\n                aria-autocomplete=\"list\"\n              />\n            ) : (\n              <span\n                className={cn(\n                  'min-w-0 flex-1 truncate',\n                  !resolvedDisplayedLabel && 'text-ws-static-subtle',\n                  hasPrefix && selectValueLeftPaddingVariants({ size }),\n                  resolvedHasClearButton && selectValueRightPaddingVariants({ size }),\n                )}\n              >\n                {resolvedDisplayedLabel || placeholder}\n              </span>\n            )}\n            {resolvedHasClearButton && (\n              <IconButton\n                onClick={context.onClear}\n                aria-label={clearSelectionAriaLabel}\n                defaultMotion={motion}\n                icon={RiCloseLine}\n                preset=\"ghost\"\n                variant=\"secondary\"\n                className={cn(\n                  selectClearButtonVariants({ size, hideArrow: false }),\n                  clearButtonOffsetVariants({ size }),\n                )}\n                iconClassName={selectClearButtonIconVariants({ size })}\n              />\n            )}\n            <div\n              className={cn(\n                selectTriggerSuffixVariants({ size, preset }),\n                !disabled && 'cursor-pointer',\n              )}\n            >\n              <RiArrowDownSLine\n                aria-hidden=\"true\"\n                focusable=\"false\"\n                className={selectTriggerSuffixIconVariants({ size })}\n                data-disabled={disabled}\n              />\n            </div>\n          </div>\n        </Popup.Trigger>\n      </TextInputContext.Provider>\n    );\n  },\n);\n\nComboBoxTrigger.displayName = 'ComboBox.Trigger';\n\nexport { ComboBoxTrigger };\n"
    },
    {
      "path": "src/components/combo-box/ComboBoxTrigger.variants.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/combo-box/ComboBoxTrigger.variants.ts",
      "content": "import { cva } from 'class-variance-authority';\n\nexport const clearButtonOffsetVariants = cva('', {\n  variants: {\n    size: {\n      sm: 'right-ws-14',\n      md: 'right-ws-16',\n      lg: 'right-ws-18',\n    },\n  },\n  defaultVariants: {\n    size: 'md',\n  },\n});\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "commit": "8bb3627"
  }
}
