import * as React from 'react'; import { GetOptionSelected, OnRequestClose, Value } from '../Menu'; import type { MenuItemProps } from '../Menu/MenuItem'; import SelectboxItem from '../Menu/MenuItem'; import { SelectboxButtonProps } from './SelectboxButton'; import { SelectboxChevronIconProps } from './SelectboxChevronIcon'; import { AnchorPos, PositionStrategy } from '../Popper'; import { TextFieldLabelProps } from '../TextField/TextFieldLabel'; import { TextFieldLabelAsteriskProps } from '../TextField/TextFieldLabelAsterisk'; import { TextFieldErrorTextProps } from '../TextField/TextFieldErrorText'; import { SelectboxButtonWrapperProps } from './SelectboxButtonWrapper'; import { SelectboxContainerProps } from './SelectboxContainer'; export { SelectboxItem }; export interface SelectboxProps extends Omit, 'value' | 'onChange' | 'children'> { /** * Array of values */ readonly items: readonly T[]; readonly value: Value; /** * Array of items. If will be array of objects or array of strings */ readonly multiple?: Multiple; /** * Menu open state\ * If `true` then menu is open, otherwise - closed */ readonly isOpen?: boolean; /** * Loading indicator visiblility\ * If `true` then visible, otherwise - hidden */ /** * Anchor position\ * \ * Default: `bottom` */ readonly anchorPos?: AnchorPos; readonly positionStrategy?: PositionStrategy; readonly autoFlip?: boolean; /** * Text field loading state\ * If `true` then text field has been contained the loading indicator, otherwise - nop */ readonly isLoading?: boolean; /** * If true then Selectbox will be filled in full width on horizontal */ readonly fullWidth?: boolean; /** * If true then `errorText` value will be displayed under the TextField element */ readonly error?: boolean; /** * If is true then the asterisk will be displayed in label\ * If is ReactNode then ReactNode will be displayed in label */ readonly requiredAsterisk?: boolean | React.ReactNode; /** * Text or ReactNode to show in error element\ * Will be displaed only if `error` property is tru */ readonly errorText?: React.ReactNode; /** * Field label text or element */ readonly label?: React.ReactNode; /** * End icon component */ readonly endIcon?: React.ReactElement; /** * Start icon component */ readonly startIcon?: React.ReactElement; /** * items render function */ readonly children: Children; /** * The function that will be called when an item is selected from the list */ readonly onChange?: OnChange; /** * A function that transforms the selected item into a string * Example: * ```tsx * item.name} // item is {id: 1, name: 'Oleg'} * ... * > * ... * * ``` */ readonly selectedItemToString: ItemToString; /** * A function that determines which of the elements is currently selected\ * Example: * ```tsx * item.id === value.id} * > * ... * * ``` */ readonly getOptionSelected?: GetOptionSelected; /** * The function that will be called at the moment when you want to close the selectbox */ readonly onRequestClose?: OnRequestClose; /** * The function that will be called at the moment when you want to open the selectbox */ readonly onRequestOpen?: (event: React.KeyboardEvent | React.MouseEvent | React.FocusEvent | React.ChangeEvent) => void; /** * Еhe label that will be shown if there are no selected items */ readonly notSetLabel?: string; /** * Overridable components map */ readonly overrides?: SelectboxOverrides; } export interface SelectboxOverrides { /** * Container element */ readonly Container?: React.ComponentType>; /** * Base element */ readonly Button?: React.ComponentType>; /** * Icon */ readonly Icon?: React.ComponentType>; /** * Component for display error text */ readonly ErrorText?: React.ComponentType>; /** * label component */ readonly Label?: React.ComponentType>; /** * label asterisk component */ readonly Asterisk?: React.ComponentType>; /** * button wrapper component */ readonly ButtonWrapper?: React.ComponentType>; } export type Children = (data: { item: T; index: number; }, itemProps: MenuItemProps) => React.ReactNode; export type ItemToString = (item: Multiple extends undefined ? T : readonly T[]) => string; export type OnChange = (item: Value) => void; declare const _default: (props: SelectboxProps & { ref?: React.ForwardedRef | undefined; }) => JSX.Element; export default _default;