{"version":3,"file":"combobox-item.cjs","sources":["../../../components/combobox/combobox-item.tsx"],"sourcesContent":["'use client';\n\nimport { Combobox as ComboboxPrimitive } from '@base-ui/react';\nimport { cx } from 'class-variance-authority';\nimport { ReactNode } from 'react';\nimport { Checkbox } from '../checkbox';\nimport { getMatch } from '../menu/utils';\nimport { Text } from '../text';\nimport styles from './combobox.module.css';\nimport { useComboboxContext } from './combobox-root';\n\nexport interface ComboboxItemProps extends ComboboxPrimitive.Item.Props {\n  leadingIcon?: ReactNode;\n}\n\nexport const ComboboxItem = ({\n  className,\n  children,\n  value: providedValue,\n  leadingIcon,\n  disabled,\n  render,\n  ...props\n}: ComboboxItemProps) => {\n  const value = providedValue\n    ? providedValue\n    : typeof children === 'string'\n      ? children\n      : undefined;\n\n  const { multiple, inputValue, hasItems } = useComboboxContext();\n\n  // When items prop is not provided on Root, use custom filtering\n  if (!hasItems && inputValue?.length) {\n    const isMatched = getMatch(value, children, inputValue);\n    if (!isMatched) return null;\n  }\n\n  const element =\n    typeof children === 'string' ? (\n      <>\n        {leadingIcon && (\n          <div className={styles.itemIcon} data-slot='combobox-item-icon'>\n            {leadingIcon}\n          </div>\n        )}\n        <Text data-slot='combobox-item-text'>{children}</Text>\n      </>\n    ) : (\n      children\n    );\n\n  return (\n    <ComboboxPrimitive.Item\n      value={value}\n      className={cx(styles.menuitem, className)}\n      disabled={disabled}\n      data-slot='combobox-item'\n      {...props}\n      render={\n        render\n          ? render\n          : (renderProps, state) => (\n              <div {...renderProps}>\n                {multiple && <Checkbox checked={state.selected} />}\n                {element}\n              </div>\n            )\n      }\n    />\n  );\n};\nComboboxItem.displayName = 'Combobox.Item';\n"],"names":[],"mappings":";;;;;;;;;;;;AAea;;AAUT;AACA;AACE;;;;AAMJ;;AAEE;AAAgB;;AAGlB;AAcA;AASQ;AACA;AASV;AACA;;"}