UNPKG

4.8 kBTypeScriptView Raw
1import type { AlignType, BuildInPlacements } from '@rc-component/trigger/lib/interface';
2import type { ScrollConfig, ScrollTo } from 'rc-virtual-list/lib/List';
3import * as React from 'react';
4import type { DisplayInfoType, DisplayValueType, Mode, Placement, RawValueType, RenderDOMFunc, RenderNode } from '../interface';
5export type { DisplayInfoType, DisplayValueType, Mode, Placement, RenderDOMFunc, RenderNode, RawValueType, };
6export interface RefOptionListProps {
7 onKeyDown: React.KeyboardEventHandler;
8 onKeyUp: React.KeyboardEventHandler;
9 scrollTo?: (args: number | ScrollConfig) => void;
10}
11export type CustomTagProps = {
12 label: React.ReactNode;
13 value: any;
14 disabled: boolean;
15 onClose: (event?: React.MouseEvent<HTMLElement, MouseEvent>) => void;
16 closable: boolean;
17 isMaxTag: boolean;
18};
19export interface BaseSelectRef {
20 focus: (options?: FocusOptions) => void;
21 blur: () => void;
22 scrollTo: ScrollTo;
23 nativeElement: HTMLElement;
24}
25export interface BaseSelectPrivateProps {
26 id: string;
27 prefixCls: string;
28 omitDomProps?: string[];
29 displayValues: DisplayValueType[];
30 onDisplayValuesChange: (values: DisplayValueType[], info: {
31 type: DisplayInfoType;
32 values: DisplayValueType[];
33 }) => void;
34 /** Current dropdown list active item string value */
35 activeValue?: string;
36 /** Link search input with target element */
37 activeDescendantId?: string;
38 onActiveValueChange?: (value: string | null) => void;
39 searchValue: string;
40 autoClearSearchValue?: boolean;
41 /** Trigger onSearch, return false to prevent trigger open event */
42 onSearch: (searchValue: string, info: {
43 source: 'typing' | 'effect' | 'submit' | 'blur';
44 }) => void;
45 /** Trigger when search text match the `tokenSeparators`. Will provide split content */
46 onSearchSplit?: (words: string[]) => void;
47 OptionList: React.ForwardRefExoticComponent<React.PropsWithoutRef<any> & React.RefAttributes<RefOptionListProps>>;
48 /** Tell if provided `options` is empty */
49 emptyOptions: boolean;
50}
51export type BaseSelectPropsWithoutPrivate = Omit<BaseSelectProps, keyof BaseSelectPrivateProps>;
52export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttributes {
53 className?: string;
54 style?: React.CSSProperties;
55 title?: string;
56 showSearch?: boolean;
57 tagRender?: (props: CustomTagProps) => React.ReactElement;
58 direction?: 'ltr' | 'rtl';
59 maxLength?: number;
60 tabIndex?: number;
61 autoFocus?: boolean;
62 notFoundContent?: React.ReactNode;
63 placeholder?: React.ReactNode;
64 onClear?: () => void;
65 choiceTransitionName?: string;
66 mode?: Mode;
67 disabled?: boolean;
68 loading?: boolean;
69 open?: boolean;
70 defaultOpen?: boolean;
71 onDropdownVisibleChange?: (open: boolean) => void;
72 /** @private Internal usage. Do not use in your production. */
73 getInputElement?: () => JSX.Element;
74 /** @private Internal usage. Do not use in your production. */
75 getRawInputElement?: () => JSX.Element;
76 maxTagTextLength?: number;
77 maxTagCount?: number | 'responsive';
78 maxTagPlaceholder?: React.ReactNode | ((omittedValues: DisplayValueType[]) => React.ReactNode);
79 tokenSeparators?: string[];
80 allowClear?: boolean | {
81 clearIcon?: RenderNode;
82 };
83 prefix?: React.ReactNode;
84 suffixIcon?: RenderNode;
85 /**
86 * Clear all icon
87 * @deprecated Please use `allowClear` instead
88 **/
89 clearIcon?: RenderNode;
90 /** Selector remove icon */
91 removeIcon?: RenderNode;
92 animation?: string;
93 transitionName?: string;
94 dropdownStyle?: React.CSSProperties;
95 dropdownClassName?: string;
96 dropdownMatchSelectWidth?: boolean | number;
97 dropdownRender?: (menu: React.ReactElement) => React.ReactElement;
98 dropdownAlign?: AlignType;
99 placement?: Placement;
100 builtinPlacements?: BuildInPlacements;
101 getPopupContainer?: RenderDOMFunc;
102 showAction?: ('focus' | 'click')[];
103 onBlur?: React.FocusEventHandler<HTMLElement>;
104 onFocus?: React.FocusEventHandler<HTMLElement>;
105 onKeyUp?: React.KeyboardEventHandler<HTMLDivElement>;
106 onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
107 onMouseDown?: React.MouseEventHandler<HTMLDivElement>;
108 onPopupScroll?: React.UIEventHandler<HTMLDivElement>;
109 onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
110 onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
111 onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
112 onClick?: React.MouseEventHandler<HTMLDivElement>;
113}
114export declare const isMultiple: (mode: Mode) => boolean;
115declare const BaseSelect: React.ForwardRefExoticComponent<BaseSelectProps & React.RefAttributes<BaseSelectRef>>;
116export default BaseSelect;