1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | import * as React from 'react';
|
32 | import type { BaseSelectPropsWithoutPrivate, BaseSelectRef, DisplayValueType, RenderNode } from './BaseSelect';
|
33 | import OptGroup from './OptGroup';
|
34 | import Option from './Option';
|
35 | import type { FlattenOptionData } from './interface';
|
36 | export type OnActiveValue = (active: RawValueType, index: number, info?: {
|
37 | source?: 'keyboard' | 'mouse';
|
38 | }) => void;
|
39 | export type OnInternalSelect = (value: RawValueType, info: {
|
40 | selected: boolean;
|
41 | }) => void;
|
42 | export type RawValueType = string | number;
|
43 | export interface LabelInValueType {
|
44 | label: React.ReactNode;
|
45 | value: RawValueType;
|
46 |
|
47 | key?: React.Key;
|
48 | }
|
49 | export type DraftValueType = RawValueType | LabelInValueType | DisplayValueType | (RawValueType | LabelInValueType | DisplayValueType)[];
|
50 | export type FilterFunc<OptionType> = (inputValue: string, option?: OptionType) => boolean;
|
51 | export interface FieldNames {
|
52 | value?: string;
|
53 | label?: string;
|
54 | groupLabel?: string;
|
55 | options?: string;
|
56 | }
|
57 | export interface BaseOptionType {
|
58 | disabled?: boolean;
|
59 | className?: string;
|
60 | title?: string;
|
61 | [name: string]: any;
|
62 | }
|
63 | export interface DefaultOptionType extends BaseOptionType {
|
64 | label?: React.ReactNode;
|
65 | value?: string | number | null;
|
66 | children?: Omit<DefaultOptionType, 'children'>[];
|
67 | }
|
68 | export type SelectHandler<ValueType, OptionType extends BaseOptionType = DefaultOptionType> = (value: ValueType, option: OptionType) => void;
|
69 | type ArrayElementType<T> = T extends (infer E)[] ? E : T;
|
70 | export interface SelectProps<ValueType = any, OptionType extends BaseOptionType = DefaultOptionType> extends BaseSelectPropsWithoutPrivate {
|
71 | prefixCls?: string;
|
72 | id?: string;
|
73 | backfill?: boolean;
|
74 | fieldNames?: FieldNames;
|
75 |
|
76 | inputValue?: string;
|
77 | searchValue?: string;
|
78 | onSearch?: (value: string) => void;
|
79 | autoClearSearchValue?: boolean;
|
80 | onSelect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
|
81 | onDeselect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
|
82 | |
83 |
|
84 |
|
85 |
|
86 |
|
87 | filterOption?: boolean | FilterFunc<OptionType>;
|
88 | filterSort?: (optionA: OptionType, optionB: OptionType, info: {
|
89 | searchValue: string;
|
90 | }) => number;
|
91 | optionFilterProp?: string;
|
92 | optionLabelProp?: string;
|
93 | children?: React.ReactNode;
|
94 | options?: OptionType[];
|
95 | optionRender?: (oriOption: FlattenOptionData<OptionType>, info: {
|
96 | index: number;
|
97 | }) => React.ReactNode;
|
98 | defaultActiveFirstOption?: boolean;
|
99 | virtual?: boolean;
|
100 | direction?: 'ltr' | 'rtl';
|
101 | listHeight?: number;
|
102 | listItemHeight?: number;
|
103 | labelRender?: (props: LabelInValueType) => React.ReactNode;
|
104 | menuItemSelectedIcon?: RenderNode;
|
105 | mode?: 'combobox' | 'multiple' | 'tags';
|
106 | labelInValue?: boolean;
|
107 | value?: ValueType | null;
|
108 | defaultValue?: ValueType | null;
|
109 | maxCount?: number;
|
110 | onChange?: (value: ValueType, option: OptionType | OptionType[]) => void;
|
111 | }
|
112 | declare const TypedSelect: (<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: SelectProps<ValueType, OptionType> & {
|
113 | children?: React.ReactNode;
|
114 | } & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
|
115 | Option: typeof Option;
|
116 | OptGroup: typeof OptGroup;
|
117 | };
|
118 | export default TypedSelect;
|