import { ReactNode } from "react"; import { SelectItem, NvSelectItemDefaultProps, SelectTypes, ValueType } from "./types"; interface OnChangeHandler { (result: ValueType[] | ValueType | SelectItem[] | SelectItem | null): void; } /** * Defines the props for the NvSelectMain component. * * @param {string} [label] - The label text over the select. * @param {string} [placeholder] - The short hint displayed in the select before the user selects a value. * @param {SelectTypes} [type] - Type of the select. * @param {string} [description] - The text between the label and the select. * @param {string} [error] - The error text under the checkbox, if true the label is red. * @param {boolean} [returnObject] - If true, not only the values will be returned on select instead of just, but whole passed item object. * @param {boolean} [disabled] - If true, the component is disabled. * @param {ValueType[] | ValueType} [value] - The value of the select. * @param {OnChangeHandler} [onChange] - Callback fired when the value is changed. * @param {(searchStr: string) => void} [onChangeSearch] - Callback fired when the search string is changed. * @param {boolean} clearable - Indicates if the clear button is displayed. * @param {() => void} onClear - Callback fired when the clear button is clicked. */ export interface NvSelectMainProps { /** The label text over the select. */ label?: string; name?: string; /** The short hint displayed in the select before the user selects a value. */ placeholder?: string; /** Type of the select. */ type?: SelectTypes; /** The text between the label and the select. */ description?: string; /** The error text under the checkbox, if true the label is red. */ error?: string; /** If true, not only the values will be returned on select instead of just, but whole passed item object. */ returnObject?: boolean; /** If true, the component is disabled. */ disabled?: boolean; /** The value of the select. */ value?: ValueType[] | ValueType; /** Callback fired when the value is changed. */ onChange?: OnChangeHandler; /** Callback fired when the search string is changed. */ onChangeSearch?: (searchStr: string) => void; /** If true, displays the clear button over the wrapped node. */ clearable?: boolean; /** Custom callback fired when the clear button is clicked. */ onClear?: () => void; /** The additional CSS class for the wrapper element. */ className?: string; } /** * Renders a customizable select component with various types like primary, checkbox, and multi-select. * * @template Item - The type of the select item. * @template TextKey - The type of the text property in the item object. * @template ValueKey - The type of the value property in the item object. * @template ItemsKey - The type of the items property in the item object. * * @param {Item[]} items - The option items to populate the select with. * @param {TextKey} [itemText] - Field name for the text property of the item object. * @param {ValueKey} [itemValue] - Field name for the value property of the item object. * @param {ItemsKey} [itemItems] - Field name for the items property of the item object. * @param {string} [label] - The label for the select component. * @param {string} [description] - The description for the select component. * @param {string} [error] - The error message to display for the select component. * @param {SelectTypes} type - The type of select component (primary, checkbox, multi). * @param {string} className - The additional CSS class for the wrapper element. * @returns {ReactNode} The rendered select component. */ declare function NvSelect(props: { /** The option items to populate the select with. */ items: Item[]; } & NvSelectMainProps): ReactNode; declare function NvSelect, TextKey extends PropertyKey = typeof NvSelectItemDefaultProps.TEXT>(props: { /** Field name for text property of item object. */ itemText: TextKey; /** The option items to populate the select with. */ items: Item[]; } & NvSelectMainProps): ReactNode; declare function NvSelect, ValueKey extends PropertyKey>(props: { /** Field name for value property of item object. */ itemValue: ValueKey; /** The option items to populate the select with. */ items: Item[]; } & NvSelectMainProps): ReactNode; declare function NvSelect, ValueKey extends PropertyKey, TextKey extends PropertyKey>(props: { /** Field name for text property of item object. */ itemText: TextKey; /** Field name for value property of item object. */ itemValue: ValueKey; /** The option items to populate the select with. */ items: Item[]; } & NvSelectMainProps): ReactNode; declare function NvSelect, ItemsKey extends PropertyKey = "items", ValueKey extends PropertyKey = "value", TextKey extends PropertyKey = "text">(props: { /** Field name for items property of item object. */ itemItems?: ItemsKey; /** Field name for text property of item object. */ itemText?: TextKey; /** Field name for value property of item object. */ itemValue?: ValueKey; /** The option items to populate the select with. */ items: Item[]; } & NvSelectMainProps): ReactNode; export default NvSelect; export { NvSelect };