reablocks
Version:
Component library for React
182 lines (180 loc) • 4.66 kB
TypeScript
import { SelectOptionProps } from './SelectOption';
import { SelectMenu, SelectMenuProps } from './SelectMenu';
import { SelectInput, SelectInputProps } from './SelectInput';
import { Placement } from '../../utils';
import { default as Fuse } from 'fuse.js';
import { default as React, FC, ReactElement } from 'react';
export interface SelectProps {
/**
* The id of the select.
*/
id?: string;
/**
* The form name of the select.
*/
name?: string;
/**
* Additional CSS style attributes to apply to the select.
*/
style?: React.CSSProperties;
/**
* Additional class names to apply to the select.
*/
className?: string;
/**
* Additional class names to apply to the select container.
*/
containerClassName?: string;
/**
* Additional class names to apply to the select when the
* menu is open
*/
activeClassName?: string;
/**
* Set the select to disabled state.
*/
disabled?: boolean;
/**
* Auto focus the select on render.
*/
autoFocus?: boolean;
/**
* Close the select after you select an option.
*/
closeOnSelect?: boolean;
/**
* The value of the select.
*/
value?: string | string[];
/**
* The deafult value of the input filter.
*/
defaultFilterValue?: string;
/**
* Whether the select is required or not.
*/
required?: boolean;
/**
* Whether the select is multi or single select.
*/
multiple?: boolean;
/**
* Default placeholder text.
*/
placeholder?: string;
/**
* Whether you can filter the select options.
*/
filterable?: boolean | 'async';
/**
* Whether you can clear the select after selection.
*/
clearable?: boolean;
/**
* Whether you can use the Tab key to select the current active option.
*/
tabToSelect?: boolean;
/**
* Whether the select is in loading state or not.
*/
loading?: boolean;
/**
* Whether you can refresh the async values or not.
*/
refreshable?: boolean;
/**
* Whether you can create new options or not.
*/
createable?: boolean;
/**
* Select options when paste text inside input.
*/
selectOnPaste?: boolean;
/**
* The list of KeyCodes for creating select values.
* The default is ['Enter']
* Typical options would be: ['Enter', 'Tab', 'Space', 'Comma']
*/
selectOnKeys?: string[];
/**
* The options of the select.
*/
children?: any;
/**
* Whether the select has an error state or not.
*/
error?: boolean;
/**
* The placement options for the menu.
*/
menuPlacement?: Placement;
/**
* Whether the menu is disabled or not.
*/
menuDisabled?: boolean;
/**
* The size of the select.
*/
size?: 'small' | 'medium' | 'large' | string;
/**
* Whether to clear the input on blur.
*/
clearOnBlur?: boolean;
/**
* When the input receives a key down event.
*/
onInputKeydown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
/**
* When the input receives a key up event.
*/
onInputKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
/**
* When the select was focused.
*/
onFocus?: (event: React.FocusEvent<HTMLInputElement> | React.MouseEvent<HTMLDivElement>) => void;
/**
* When the select was blurred.
*/
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
/**
* When the select input value changed.
*/
onInputChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
/**
* When the user manually refreshed the options.
*/
onRefresh?: () => void;
/**
* When the user clears the select input.
*/
onClear?: () => void;
/**
* When the value changes.
*/
onChange?: (value: any) => void;
/**
* When a new option is added or removed.
*/
onOptionsChange?: (options: SelectOptionProps[]) => void;
/**
* Input override component.
*/
input?: ReactElement<SelectInputProps, typeof SelectInput>;
/**
* Menu component override.
*/
menu?: ReactElement<SelectMenuProps, typeof SelectMenu>;
/**
* The options for the Fuse.js search algorithm.
*/
searchOptions?: Fuse.IFuseOptions<SelectOptionProps>;
/**
* When menu is opened
*/
onOpenMenu?: () => void;
/**
* When menu is closed
*/
onCloseMenu?: () => void;
}
export declare const Select: FC<SelectProps>;