UNPKG

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