import React, { ReactNode } from 'react'; import { type ChipProps } from '@leafygreen-ui/chip'; import { Either } from '@leafygreen-ui/lib'; import { PopoverProps, RenderMode } from '@leafygreen-ui/popover'; import { ComboboxSize, DropdownWidthBasis, onChangeType, Overflow, SearchState, SelectValueType, State, } from '../types'; export { RenderMode }; /** * Combobox Props */ export interface ComboboxMultiselectProps { /** * Defines whether a user can select multiple options, or only a single option. * When using TypeScript, `multiselect` affects the valid values of `initialValue`, `value`, and `onChange` */ multiselect?: M; /** * The initial selection. * Must be a string (or array of strings) that matches the `value` prop of a `ComboboxOption`. * Changing the `initialValue` after initial render will not change the selection. */ initialValue?: SelectValueType; /** * A callback called when the selection changes. * Callback receives a single argument that is the new selection, either string, or string array */ onChange?: onChangeType; /** * The controlled value of the Combobox. * Must be a string (or array of strings) that matches the `value` prop of a `ComboboxOption`. * Changing `value` after initial render _will_ affect the selection. * `value` will always take precedence over `initialValue` if both are provided. */ value?: SelectValueType; /** * Defines the overflow behavior of a multiselect combobox. * * `expand-y`: Combobox has fixed width, and additional selections will cause the element to grow in the block direction. * * `expand-x`: Combobox has fixed height, and additional selections will cause the element to grow in the inline direction. * * `scroll-x`: Combobox has fixed height and width, and additional selections will cause the element to be scrollable in the x (horizontal) direction. */ overflow?: M extends true ? Overflow : undefined; } type PartialChipProps = Pick< ChipProps, 'chipTruncationLocation' | 'chipCharacterLimit' >; export type BaseComboboxProps = Omit, 'onChange'> & Pick< PopoverProps, | 'popoverZIndex' | 'portalClassName' | 'portalContainer' | 'portalRef' | 'renderMode' | 'scrollContainer' > & PartialChipProps & { /** * Defines the Combobox Options by passing children. Must be `ComboboxOption` or `ComboboxGroup` */ children?: ReactNode; /** * An accessible label for the input, rendered in a