Skip to content

Commit 805908b

Browse files
author
刘欢
committed
feat: change ts name
1 parent 9a2c1f6 commit 805908b

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

src/Select.tsx

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ type ArrayElementType<T> = T extends (infer E)[] ? E : T;
110110

111111
export type SemanticName = BaseSelectSemanticName;
112112
export type PopupSemantic = 'listItem' | 'list';
113-
interface ShowSearch<OptionType> {
113+
interface SearchConfig<OptionType> {
114114
searchValue?: string;
115115
autoClearSearchValue?: boolean;
116116
onSearch?: (value: string) => void;
117-
tokenSeparators?: string | string[];
117+
tokenSeparators?: string[];
118118
filterOption?: boolean | FilterFunc<OptionType>;
119119
filterSort?: (optionA: OptionType, optionB: OptionType, info: { searchValue: string }) => number;
120120
optionFilterProp?: string;
@@ -129,25 +129,33 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
129129

130130
// >>> Field Names
131131
fieldNames?: FieldNames;
132-
showSearch?: boolean | ShowSearch<OptionType>;
133-
searchValue?: string;
134-
onSearch?: (value: string) => void;
132+
showSearch?: boolean | SearchConfig<OptionType>;
133+
/** @deprecated pleace use SearchConfig.searchValue */
134+
searchValue?: SearchConfig<OptionType>['searchValue'];
135+
/** @deprecated pleace use SearchConfig.autoClearSearchValue */
135136
autoClearSearchValue?: boolean;
136-
137-
// >>> Select
138-
onSelect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
139-
onDeselect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
140-
137+
/** @deprecated pleace use SearchConfig.onSearch */
138+
onSearch?: SearchConfig<OptionType>['onSearch'];
139+
/** @deprecated pleace use SearchConfig.tokenSeparators */
140+
tokenSeparators?: string[];
141141
// >>> Options
142142
/**
143143
* In Select, `false` means do nothing.
144144
* In TreeSelect, `false` will highlight match item.
145145
* It's by design.
146146
*/
147-
filterOption?: boolean | FilterFunc<OptionType>;
148-
filterSort?: (optionA: OptionType, optionB: OptionType, info: { searchValue: string }) => number;
147+
/** @deprecated pleace use SearchConfig.filterOption */
148+
filterOption?: SearchConfig<OptionType>['filterOption'];
149+
/** @deprecated pleace use SearchConfig.filterSort */
150+
filterSort?: SearchConfig<OptionType>['filterSort'];
151+
/** @deprecated pleace use SearchConfig.optionFilterProp */
149152
optionFilterProp?: string;
153+
/** @deprecated pleace use SearchConfig.optionLabelProp */
150154
optionLabelProp?: string;
155+
// >>> Select
156+
onSelect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
157+
onDeselect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
158+
151159
children?: React.ReactNode;
152160
options?: OptionType[];
153161
optionRender?: (
@@ -224,7 +232,7 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
224232
'autoClearSearchValue',
225233
'tokenSeparators',
226234
];
227-
const legacyShowSearch: ShowSearch<DefaultOptionType> = {};
235+
const legacyShowSearch: SearchConfig<DefaultOptionType> = {};
228236
legacySearchProps.forEach((propsName) => {
229237
legacyShowSearch[propsName] = restProps?.[propsName];
230238
});
@@ -237,6 +245,7 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
237245
filterSort,
238246
onSearch,
239247
autoClearSearchValue,
248+
tokenSeparators,
240249
} = mergedShowSearch;
241250

242251
const mergedId = useId(id);
@@ -715,6 +724,7 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
715724
onSearch={onInternalSearch}
716725
autoClearSearchValue={autoClearSearchValue}
717726
onSearchSplit={onInternalSearchSplit}
727+
tokenSeparators={tokenSeparators}
718728
popupMatchSelectWidth={popupMatchSelectWidth}
719729
// >>> OptionList
720730
OptionList={OptionList}

0 commit comments

Comments
 (0)