UNPKG

3.31 kBTypeScriptView Raw
1/**
2 * Cursor rule:
3 * 1. Only `showSearch` enabled
4 * 2. Only `open` is `true`
5 * 3. When typing, set `open` to `true` which hit rule of 2
6 *
7 * Accessibility:
8 * - https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html
9 */
10import type { ScrollTo } from 'rc-virtual-list/lib/List';
11import * as React from 'react';
12import type { CustomTagProps, DisplayValueType, Mode, RenderNode } from '../BaseSelect';
13export interface InnerSelectorProps {
14 prefixCls: string;
15 id: string;
16 mode: Mode;
17 title?: string;
18 inputRef: React.Ref<HTMLInputElement | HTMLTextAreaElement>;
19 placeholder?: React.ReactNode;
20 disabled?: boolean;
21 autoFocus?: boolean;
22 autoComplete?: string;
23 values: DisplayValueType[];
24 showSearch?: boolean;
25 searchValue: string;
26 autoClearSearchValue?: boolean;
27 activeDescendantId?: string;
28 open: boolean;
29 tabIndex?: number;
30 maxLength?: number;
31 onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
32 onInputMouseDown: React.MouseEventHandler<HTMLInputElement | HTMLTextAreaElement>;
33 onInputChange: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement>;
34 onInputPaste: React.ClipboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
35 onInputCompositionStart: React.CompositionEventHandler<HTMLInputElement | HTMLTextAreaElement>;
36 onInputCompositionEnd: React.CompositionEventHandler<HTMLInputElement | HTMLTextAreaElement>;
37}
38export interface RefSelectorProps {
39 focus: (options?: FocusOptions) => void;
40 blur: () => void;
41 scrollTo?: ScrollTo;
42}
43export interface SelectorProps {
44 id: string;
45 prefixCls: string;
46 showSearch?: boolean;
47 open: boolean;
48 /** Display in the Selector value, it's not same as `value` prop */
49 values: DisplayValueType[];
50 mode: Mode;
51 searchValue: string;
52 activeValue: string;
53 autoClearSearchValue: boolean;
54 inputElement: JSX.Element;
55 maxLength?: number;
56 autoFocus?: boolean;
57 activeDescendantId?: string;
58 tabIndex?: number;
59 disabled?: boolean;
60 placeholder?: React.ReactNode;
61 removeIcon?: RenderNode;
62 prefix?: React.ReactNode;
63 maxTagCount?: number | 'responsive';
64 maxTagTextLength?: number;
65 maxTagPlaceholder?: React.ReactNode | ((omittedValues: DisplayValueType[]) => React.ReactNode);
66 tagRender?: (props: CustomTagProps) => React.ReactElement;
67 /** Check if `tokenSeparators` contains `\n` or `\r\n` */
68 tokenWithEnter?: boolean;
69 choiceTransitionName?: string;
70 onToggleOpen: (open?: boolean) => void;
71 /** `onSearch` returns go next step boolean to check if need do toggle open */
72 onSearch: (searchText: string, fromTyping: boolean, isCompositing: boolean) => boolean;
73 onSearchSubmit?: (searchText: string) => void;
74 onRemove: (value: DisplayValueType) => void;
75 onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
76 /**
77 * @private get real dom for trigger align.
78 * This may be removed after React provides replacement of `findDOMNode`
79 */
80 domRef: React.Ref<HTMLDivElement>;
81}
82declare const ForwardSelector: React.ForwardRefExoticComponent<SelectorProps & React.RefAttributes<RefSelectorProps>>;
83export default ForwardSelector;