'use client'; import { Combobox as ComboboxPrimitive, Select as SelectPrimitive } from '@base-ui/react'; import { cx } from 'class-variance-authority'; import { ReactNode, useLayoutEffect } from 'react'; import { Checkbox } from '../checkbox'; import { getMatch } from '../menu/utils'; import { Text } from '../text'; import styles from './select.module.css'; import { useSelectContext } from './select-root'; export interface SelectItemProps extends SelectPrimitive.Item.Props { leadingIcon?: ReactNode; trailingIcon?: ReactNode; } export function SelectItem({ className, children, value: providedValue, leadingIcon, trailingIcon, disabled, ...props }: SelectItemProps) { const value = String(providedValue); const { registerItem, unregisterItem, autocomplete, inputValue, value: selectValue, shouldFilter, hasItems, multiple } = useSelectContext(); const isSelected = multiple ? selectValue?.includes(value) : value === selectValue; const isMatched = getMatch(value, children, inputValue); const isHidden = shouldFilter && !hasItems && isSelected && !isMatched; const element = typeof children === 'string' ? ( <> {leadingIcon && (