import { default as React } from 'react'; import { UseMultipleSelectionReturnValue } from 'downshift'; import { MultiSelectItemProps } from './MultiSelectItem'; type MultiSelectItemElement = React.ReactElement; export interface MultiSelectSummaryFormatterArgs { /** Currently selected item React elements */ selectedItems: MultiSelectItemElement[]; /** downshift helper for token props */ getSelectedItemProps: UseMultipleSelectionReturnValue["getSelectedItemProps"]; /** Removes a token */ removeSelectedItem: (item: MultiSelectItemElement) => void; /** Flag indicating if the component is disabled */ disabled: boolean; /** Placeholder text when no items are selected */ label: string; } export interface MultiSelectProps { /** * unique name attribute for the input (used for `id` and `name`). * The trigger id falls back to a value derived from `label`. */ name?: string; /** Label for the select control */ label: string; /** MultiSelect.Item children */ children?: React.ReactNode; /** * When passed, the MultiSelect becomes fully controlled. * Use `onSelectedItemsChange` to manage this value. */ selectedItems?: Value[]; /** * Change callback for user actions that select or deselect items. * Called with an array of selected item values. */ onSelectedItemsChange?: (values: Value[]) => void; /** * Disables the input and all user interaction. * You may still pass in `selectedItems` if items need to be selected * when the input is disabled. */ disabled?: boolean; /** * Value for the input with the given `name` prop. * This should be the value of the field in the submitted form. */ fieldValue?: string; /** * Error message. * When passed, this will cause the trigger to render in error state. */ errorText?: string; /** Optional value for `data-testid` attribute */ testId?: string; /** Optional label override for the clear all button */ clearLabel?: string; /** If true, renders a "Clear all" button on the right side of the trigger */ isClearable?: boolean; /** * Optional function to format the summary content shown in the trigger. * Must return a React node. */ summaryFormatter?: (args: MultiSelectSummaryFormatterArgs) => React.ReactNode; /** * Function with signature `(userInputValue, selectItemNode) => {}`, * used to customize typeahead filtering behavior. * See "Changing Typeahead Behavior" story for example. */ getTypeaheadString?: (userInput: string, selectItem: MultiSelectItemElement) => string; } /** * Accessible multiple select control for giving users the ability to select * multiple options from a list of options. * * Typeahead is enabled based on the `value` prop of `MultiSelect.Item` * elements passed in. You may also set a custom `searchValue` * on each `MultiSelect.Item` for control over typeahead behavior. * * - isClearable: if true, a "Clear all" button is rendered on the right side of the input. * - clearLabel: overridable text for the clear all button. * - summaryFormatter: an optional function that receives the number of selected items and an array of labels, * and returns a string summary. */ declare function MultiSelect(props: MultiSelectProps): React.JSX.Element; declare namespace MultiSelect { var Item: { ({ children }: MultiSelectItemProps): React.JSX.Element; displayName: string; propTypes: { value: import("prop-types").Validator; searchValue: import("prop-types").Requireable; tokenLabel: import("prop-types").Requireable; children: import("prop-types").Requireable>; }; }; } export default MultiSelect; //# sourceMappingURL=index.d.ts.map