UNPKG

@mskcc/carbon-react

Version:

Carbon react components for the MSKCC DSM

44 lines (43 loc) 1.51 kB
/** * MSKCC DSM 2021, 2024 */ import React from 'react'; import PropTypes from 'prop-types'; export interface AutocompleteContextValue<Item> { isOpen: boolean; getMenuProps: any; getInputProps: any; highlightedIndex: number | null; getItemProps: any; items: Item[]; clearInput: () => void; } export interface AutocompleteProps<Item> { children: React.ReactNode; handleInput: (inputValue: string) => Item[] | Promise<Item[]>; /** * The minimum number of characters that must be typed before the handleInput function is called. */ min?: number; } export declare function useAutocomplete<Item>(): AutocompleteContextValue<Item>; export declare const Autocomplete: { <Item extends unknown>({ children, handleInput, min, ...downshiftProps }: AutocompleteProps<Item>): JSX.Element; displayName: string; propTypes: { /** * The children of the Autocomplete component. */ children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>; /** * The function that will be called when the user types in the input. * It should return an array of items or a promise that resolves to an array of items. */ handleInput: PropTypes.Validator<(...args: any[]) => any>; /** * The minimum number of characters that must be typed before the handleInput function is called. */ min: PropTypes.Requireable<number>; }; }; export default Autocomplete;