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 | export type OnActiveValue = (active: RawValueType, index: number, info?: {
|
36 | source?: 'keyboard' | 'mouse';
|
37 | }) => void;
|
38 | export type OnInternalSelect = (value: RawValueType, info: {
|
39 | selected: boolean;
|
40 | }) => void;
|
41 | export type RawValueType = string | number;
|
42 | export interface LabelInValueType {
|
43 | label: React.ReactNode;
|
44 | value: RawValueType;
|
45 |
|
46 | key?: React.Key;
|
47 | }
|
48 | export type DraftValueType = RawValueType | LabelInValueType | DisplayValueType | (RawValueType | LabelInValueType | DisplayValueType)[];
|
49 | export type FilterFunc<OptionType> = (inputValue: string, option?: OptionType) => boolean;
|
50 | export interface FieldNames {
|
51 | value?: string;
|
52 | label?: string;
|
53 | groupLabel?: string;
|
54 | options?: string;
|
55 | }
|
56 | export interface BaseOptionType {
|
57 | disabled?: boolean;
|
58 | [name: string]: any;
|
59 | }
|
60 | export interface DefaultOptionType extends BaseOptionType {
|
61 | label: React.ReactNode;
|
62 | value?: string | number | null;
|
63 | children?: Omit<DefaultOptionType, 'children'>[];
|
64 | }
|
65 | export type SelectHandler<ValueType, OptionType extends BaseOptionType = DefaultOptionType> = (value: ValueType, option: OptionType) => void;
|
66 | type ArrayElementType<T> = T extends (infer E)[] ? E : T;
|
67 | export interface SelectProps<ValueType = any, OptionType extends BaseOptionType = DefaultOptionType> extends BaseSelectPropsWithoutPrivate {
|
68 | prefixCls?: string;
|
69 | id?: string;
|
70 | backfill?: boolean;
|
71 | fieldNames?: FieldNames;
|
72 |
|
73 | inputValue?: string;
|
74 | searchValue?: string;
|
75 | onSearch?: (value: string) => void;
|
76 | autoClearSearchValue?: boolean;
|
77 | onSelect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
|
78 | onDeselect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
|
79 | |
80 |
|
81 |
|
82 |
|
83 |
|
84 | filterOption?: boolean | FilterFunc<OptionType>;
|
85 | filterSort?: (optionA: OptionType, optionB: OptionType) => number;
|
86 | optionFilterProp?: string;
|
87 | optionLabelProp?: string;
|
88 | children?: React.ReactNode;
|
89 | options?: OptionType[];
|
90 | defaultActiveFirstOption?: boolean;
|
91 | virtual?: boolean;
|
92 | direction?: 'ltr' | 'rtl';
|
93 | listHeight?: number;
|
94 | listItemHeight?: number;
|
95 | menuItemSelectedIcon?: RenderNode;
|
96 | mode?: 'combobox' | 'multiple' | 'tags';
|
97 | labelInValue?: boolean;
|
98 | value?: ValueType | null;
|
99 | defaultValue?: ValueType | null;
|
100 | onChange?: (value: ValueType, option: OptionType | OptionType[]) => void;
|
101 | }
|
102 | declare const TypedSelect: (<ValueType = any, OptionType extends DefaultOptionType | BaseOptionType = DefaultOptionType>(props: SelectProps<ValueType, OptionType> & {
|
103 | children?: React.ReactNode;
|
104 | } & {
|
105 | ref?: React.Ref<BaseSelectRef>;
|
106 | }) => React.ReactElement) & {
|
107 | Option: typeof Option;
|
108 | OptGroup: typeof OptGroup;
|
109 | };
|
110 | export default TypedSelect;
|