import { default as React } from 'react'; import { VALID_ICON_NAMES } from '../icons/iconNames'; import { ComboboxItemProps } from './ComboboxItem'; import { ComboboxHeadingProps } from './ComboboxHeading'; import { ComboboxCategoryProps } from './ComboboxCategory'; import { ComboboxActionProps } from './ComboboxAction'; import { IconName } from '../types/Icon.types'; export { VALID_ICON_NAMES }; type ComboboxItemElement = React.ReactElement; type ComboboxActionElement = React.ReactElement; type ComboboxHeadingElement = React.ReactElement; type ComboboxChild = ComboboxItemElement | ComboboxActionElement | ComboboxHeadingElement; /** * @param item Combobox.{Action|Item|Heading} component * @returns true if the item is a Combobox.Action */ export declare const isAction: (item: React.ReactNode) => item is ComboboxActionElement; /** * @param component a Combobox.Item or Combobox.Heading component * @returns true if the item is a selectable Combobox.Item or Action */ export declare const isSelectable: (component: ComboboxChild | null | undefined) => boolean; /** * @param inputValue current value of the combobox input * @param highlightedIndex index of highlighted item from downshift * @param displayedItems list of all items currently displayed * @param categoryChildren list of items in category * @param selectedItem the currently selected item * @returns if the category should be forced open */ export declare const shouldOpenCategory: (inputValue: string | undefined, highlightedIndex: number, displayedItems: ComboboxChild[], categoryChildren: ComboboxChild[], selectedItem: ComboboxChild | null | undefined) => boolean; /** * @param displayedItems currently displayed combobox items * @param categoryChildren items in category * @returns [] containing which category items should be visible */ export declare const getVisibleChildrenByCategory: (displayedItems: ComboboxChild[], categoryChildren: ComboboxChild[]) => ComboboxChild[]; /** * @param items all selectable Combobox.Item children * @param inputValue lowercase value of input * @returns Combobox.Item children, filtered by the input value */ export declare const defaultFilterItemsByInput: (items: ComboboxItemElement[], inputValue: string) => ComboboxItemElement[]; /** * * @param isOpen whether the combobox is open * @returns chevron icon that toggles based on the open state of the combobox */ export declare const defaultRenderEndContent: (isOpen: boolean) => React.JSX.Element; export interface ComboboxProps { /** Combobox.Item, Combobox.Action, Combobox.Heading, or Combobox.Category children */ children: React.ReactNode; /** Label for the input */ label: string; /** Change callback. * Called when an item is selected, with the `value` of the selected item. * Called with empty string when the user clears the input. */ onChange?: (value: Value) => void; /** * Sets value of the input in a controlled manner. * When using the `inputValue` prop, you **must** update it via the * `onInputChange` handler. */ inputValue?: string; /** Input change callback. Called whenever the user updates the value of the input. */ onInputChange?: (inputValue: string) => void; /** * Set to `true` to disable the default behavior of filtering the list * as the user types. */ disableFiltering?: boolean; /** * When `true`, selecting an action will clear any existing selection. */ clearSelectionOnAction?: boolean; /** * Optionally pass a function to customize filtering behavior * * Signature: `(items, inputValue) => [...filteredItems]` */ filterItemsByInput?: (items: ComboboxItemElement[], inputValue: string) => ComboboxItemElement[]; /** * Error message. * When passed, this will cause the input to render in error state. */ errorText?: string; /** Name of icon to place at the start of the input */ icon?: IconName; /** Optional value for `data-testid` attribute */ testId?: string; /** Function to render content at the end of the input. * Defaults to a function that renders a chevron icon that toggles based on the open state of the combobox. * * Signature: `(isOpen) => React.ReactNode` */ renderEndContent?: (isOpen: boolean) => React.ReactNode; } /** * Autocomplete input component following the accessible * [ARIA combobox pattern](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/combobox_role). * * Autocomplete options are defined by passing the `Combobox.Item` subcomponent * as children. To add heading dividers, use the `Combobox.Heading` subcomponent. * * By default options will be filtered down as the user types in the input. This * behavior can be disabled via the `disableFiltering` prop. */ declare function Combobox(props: ComboboxProps): React.JSX.Element; declare namespace Combobox { var Item: { ({ children, value }: ComboboxItemProps): React.JSX.Element; displayName: string; propTypes: { value: import("prop-types").Validator; searchValue: import("prop-types").Requireable; children: import("prop-types").Requireable>; }; }; var Heading: { ({ text, kind }: ComboboxHeadingProps): React.JSX.Element; displayName: string; propTypes: { text: import("prop-types").Validator; kind: import("prop-types").Requireable; }; }; var Category: { ({ children }: ComboboxCategoryProps): React.JSX.Element; displayName: string; propTypes: { label: import("prop-types").Validator; children: import("prop-types").Requireable>; }; }; var Action: { ({ onSelect }: ComboboxActionProps): React.JSX.Element; displayName: string; propTypes: { onSelect: import("prop-types").Validator<(...args: any[]) => any>; label: import("prop-types").Validator; }; }; } export default Combobox; //# sourceMappingURL=index.d.ts.map