Skip to content

Commit 51c936e

Browse files
committed
feat: retire deprecated api
1 parent fd1f076 commit 51c936e

File tree

7 files changed

+10
-47
lines changed

7 files changed

+10
-47
lines changed

docs/examples/common.less

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs/examples/custom-icon.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class CustomIconComponent extends React.Component {
9898
onSelect={this.onSelect}
9999
onInputKeyDown={this.onKeyDown}
100100
notFoundContent=""
101-
allowClear
101+
allowClear={{ clearIcon: getSvg(clearPath) }}
102102
placeholder="please select"
103103
value={value}
104104
mode="combobox"
@@ -110,7 +110,6 @@ class CustomIconComponent extends React.Component {
110110
}
111111
return getSvg(arrowPath);
112112
}}
113-
clearIcon={getSvg(clearPath)}
114113
removeIcon={getSvg(clearPath)}
115114
menuItemSelectedIcon={singleItemIcon}
116115
>
@@ -185,7 +184,7 @@ class Test extends React.Component {
185184
choiceTransitionName="rc-select-selection__choice-zoom"
186185
style={{ width: 500 }}
187186
mode="multiple"
188-
allowClear
187+
allowClear={{ clearIcon: getSvg(clearPath) }}
189188
optionFilterProp="children"
190189
optionLabelProp="children"
191190
onSelect={this.onSelect}
@@ -196,7 +195,6 @@ class Test extends React.Component {
196195
tokenSeparators={[' ', ',']}
197196
prefix="Foobar"
198197
suffixIcon={getSvg(arrowPath)}
199-
clearIcon={getSvg(clearPath)}
200198
removeIcon={getSvg(clearPath)}
201199
menuItemSelectedIcon={menuItemSelectedIcon}
202200
>

src/BaseSelect/index.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttri
175175
allowClear?: boolean | { clearIcon?: RenderNode };
176176
prefix?: React.ReactNode;
177177
suffixIcon?: RenderNode;
178-
/**
179-
* Clear all icon
180-
* @deprecated Please use `allowClear` instead
181-
**/
182-
clearIcon?: RenderNode;
183178
/** Selector remove icon */
184179
removeIcon?: RenderNode;
185180

@@ -262,7 +257,6 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
262257
allowClear,
263258
prefix,
264259
suffixIcon,
265-
clearIcon,
266260

267261
// Dropdown
268262
OptionList,
@@ -733,7 +727,6 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
733727
onClearMouseDown,
734728
displayValues,
735729
allowClear,
736-
clearIcon,
737730
disabled,
738731
mergedSearchValue,
739732
mode,

src/Select.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ export type RawValueType = string | number;
7070
export interface LabelInValueType {
7171
label: React.ReactNode;
7272
value: RawValueType;
73-
/** @deprecated `key` is useless since it should always same as `value` */
74-
key?: React.Key;
7573
}
7674

7775
export type DraftValueType =
@@ -119,9 +117,6 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
119117
// >>> Field Names
120118
fieldNames?: FieldNames;
121119

122-
// >>> Search
123-
/** @deprecated Use `searchValue` instead */
124-
inputValue?: string;
125120
searchValue?: string;
126121
onSearch?: (value: string) => void;
127122
autoClearSearchValue?: boolean;
@@ -178,7 +173,6 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
178173
fieldNames,
179174

180175
// Search
181-
inputValue,
182176
searchValue,
183177
onSearch,
184178
autoClearSearchValue = true,
@@ -239,7 +233,7 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
239233

240234
// =========================== Search ===========================
241235
const [mergedSearchValue, setSearchValue] = useMergedState('', {
242-
value: searchValue !== undefined ? searchValue : inputValue,
236+
value: searchValue,
243237
postState: (search) => search || '',
244238
});
245239

@@ -271,7 +265,6 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
271265
if (isRawValue(val)) {
272266
rawValue = val;
273267
} else {
274-
rawKey = val.key;
275268
rawLabel = val.label;
276269
rawValue = val.value ?? (rawKey as RawValueType);
277270
}
@@ -513,7 +506,6 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
513506
? {
514507
label: option?.[mergedFieldNames.label],
515508
value: val,
516-
key: option?.key ?? val,
517509
}
518510
: val,
519511
injectPropsWithOption(option),

src/hooks/useAllowClear.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,15 @@ export const useAllowClear = (
77
onClearMouseDown: React.MouseEventHandler<HTMLSpanElement>,
88
displayValues: DisplayValueType[],
99
allowClear?: boolean | { clearIcon?: RenderNode },
10-
clearIcon?: RenderNode,
1110
disabled: boolean = false,
1211
mergedSearchValue?: string,
1312
mode?: Mode,
1413
) => {
15-
const mergedClearIcon = React.useMemo(() => {
14+
const clearIcon = React.useMemo(() => {
1615
if (typeof allowClear === 'object') {
1716
return allowClear.clearIcon;
1817
}
19-
if (clearIcon) {
20-
return clearIcon;
21-
}
22-
}, [allowClear, clearIcon]);
18+
}, [allowClear]);
2319

2420
const mergedAllowClear = React.useMemo<boolean>(() => {
2521
if (
@@ -39,7 +35,7 @@ export const useAllowClear = (
3935
<TransBtn
4036
className={`${prefixCls}-clear`}
4137
onMouseDown={onClearMouseDown}
42-
customizeIcon={mergedClearIcon}
38+
customizeIcon={clearIcon}
4339
>
4440
×
4541
</TransBtn>

src/utils/warningPropsUtil.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ function warningProps(props: SelectProps) {
2828
autoFocus,
2929
labelInValue,
3030
value,
31-
inputValue,
3231
optionLabelProp,
3332
} = props;
3433

@@ -149,11 +148,6 @@ function warningProps(props: SelectProps) {
149148
}\`.`,
150149
);
151150
}
152-
153-
warning(
154-
inputValue === undefined,
155-
'`inputValue` is deprecated, please use `searchValue` instead.',
156-
);
157151
}
158152
}
159153

tests/Select.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ describe('Select.Basic', () => {
289289

290290
resetWarned();
291291
const { container: container5 } = render(
292-
<Select allowClear clearIcon={<div className="custom-clear-icon">x</div>} value="1">
292+
<Select allowClear={{ clearIcon: <div className="custom-clear-icon">x</div> }} value="1">
293293
<Option value="1">1</Option>
294294
<Option value="2">2</Option>
295295
</Select>,
@@ -298,7 +298,7 @@ describe('Select.Basic', () => {
298298
expect(container5.querySelector('.custom-clear-icon').textContent).toBe('x');
299299

300300
const { container: container6 } = render(
301-
<Select allowClear clearIcon={<div className="custom-clear-icon">x</div>}>
301+
<Select allowClear={{ clearIcon: <div className="custom-clear-icon">x</div> }}>
302302
<Option value="1">1</Option>
303303
<Option value="2">2</Option>
304304
</Select>,
@@ -1240,7 +1240,7 @@ describe('Select.Basic', () => {
12401240

12411241
it('does not filter when filterOption value is false', () => {
12421242
const { container } = testingRender(
1243-
<Select inputValue="1" filterOption={false} open>
1243+
<Select searchValue="1" filterOption={false} open>
12441244
<Option value="1">1</Option>
12451245
<Option value="2">2</Option>
12461246
</Select>,
@@ -2330,7 +2330,7 @@ describe('Select.Basic', () => {
23302330
const renderDemo = (props?: any) => (
23312331
<Select
23322332
labelInValue
2333-
value={{ key: 1, label: 'One' }}
2333+
value={{ value: 1, label: 'One' }}
23342334
labelRender={labelRender}
23352335
options={[
23362336
{

0 commit comments

Comments
 (0)