@cerberus-design/react
Version:
The Cerberus Design React component library.
29 lines (28 loc) • 1.11 kB
text/typescript
import { ComboboxInputValueChangeDetails } from '@ark-ui/react/combobox';
import { SelectCollectionItem } from '../select/select';
import { createSelectCollection } from '../select/primitives';
/**
* This module contains a custom hook that provides a stateful collection for
* the Combobox component.
*/
export interface StatefulCollectionReturn {
/**
* The collection of items.
*/
collection: ReturnType<typeof createSelectCollection>;
/**
* The filter value split into an array of characters.
*/
filterChars: string[];
/**
* The function to handle input changes.
*/
handleInputChange: (details: ComboboxInputValueChangeDetails) => void;
}
/**
* This hook provides a stateful collection for the Combobox component.
* It returns a collection of items and a function to handle input changes.
* @param initialItems - The initial collection of items.
* @return An object containing the collection and a function to handle input changes.
*/
export declare function useStatefulCollection(initialItems?: SelectCollectionItem[]): StatefulCollectionReturn;