Skip to content

feat: retire deprecated api #1099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions docs/examples/common.less

This file was deleted.

6 changes: 2 additions & 4 deletions docs/examples/custom-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class CustomIconComponent extends React.Component {
onSelect={this.onSelect}
onInputKeyDown={this.onKeyDown}
notFoundContent=""
allowClear
allowClear={{ clearIcon: getSvg(clearPath) }}
placeholder="please select"
value={value}
mode="combobox"
Expand All @@ -110,7 +110,6 @@ class CustomIconComponent extends React.Component {
}
return getSvg(arrowPath);
}}
clearIcon={getSvg(clearPath)}
removeIcon={getSvg(clearPath)}
menuItemSelectedIcon={singleItemIcon}
>
Expand Down Expand Up @@ -185,7 +184,7 @@ class Test extends React.Component {
choiceTransitionName="rc-select-selection__choice-zoom"
style={{ width: 500 }}
mode="multiple"
allowClear
allowClear={{ clearIcon: getSvg(clearPath) }}
optionFilterProp="children"
optionLabelProp="children"
onSelect={this.onSelect}
Expand All @@ -196,7 +195,6 @@ class Test extends React.Component {
tokenSeparators={[' ', ',']}
prefix="Foobar"
suffixIcon={getSvg(arrowPath)}
clearIcon={getSvg(clearPath)}
removeIcon={getSvg(clearPath)}
menuItemSelectedIcon={menuItemSelectedIcon}
>
Expand Down
7 changes: 0 additions & 7 deletions src/BaseSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,6 @@ export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttri
allowClear?: boolean | { clearIcon?: RenderNode };
prefix?: React.ReactNode;
suffixIcon?: RenderNode;
/**
* Clear all icon
* @deprecated Please use `allowClear` instead
**/
clearIcon?: RenderNode;
/** Selector remove icon */
removeIcon?: RenderNode;

Expand Down Expand Up @@ -262,7 +257,6 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
allowClear,
prefix,
suffixIcon,
clearIcon,

// Dropdown
OptionList,
Expand Down Expand Up @@ -733,7 +727,6 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
onClearMouseDown,
displayValues,
allowClear,
clearIcon,
disabled,
mergedSearchValue,
mode,
Expand Down
11 changes: 1 addition & 10 deletions src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ export type RawValueType = string | number;
export interface LabelInValueType {
label: React.ReactNode;
value: RawValueType;
/** @deprecated `key` is useless since it should always same as `value` */
key?: React.Key;
}

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

// >>> Search
/** @deprecated Use `searchValue` instead */
inputValue?: string;
searchValue?: string;
onSearch?: (value: string) => void;
autoClearSearchValue?: boolean;
Expand Down Expand Up @@ -178,7 +173,6 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
fieldNames,

// Search
inputValue,
searchValue,
onSearch,
autoClearSearchValue = true,
Expand Down Expand Up @@ -239,7 +233,7 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp

// =========================== Search ===========================
const [mergedSearchValue, setSearchValue] = useMergedState('', {
value: searchValue !== undefined ? searchValue : inputValue,
value: searchValue,
postState: (search) => search || '',
});

Expand Down Expand Up @@ -271,7 +265,6 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
if (isRawValue(val)) {
rawValue = val;
} else {
rawKey = val.key;
rawLabel = val.label;
rawValue = val.value ?? (rawKey as RawValueType);
}
Expand Down Expand Up @@ -513,7 +506,6 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
? {
label: option?.[mergedFieldNames.label],
value: val,
key: option?.key ?? val,
}
: val,
injectPropsWithOption(option),
Expand Down Expand Up @@ -547,7 +539,6 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp

// Clean search value if single or configured
if (mode === 'combobox') {
// setSearchValue(String(val));
setActiveValue('');
} else if (!isMultiple || autoClearSearchValue) {
setSearchValue('');
Expand Down
10 changes: 3 additions & 7 deletions src/hooks/useAllowClear.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ export const useAllowClear = (
onClearMouseDown: React.MouseEventHandler<HTMLSpanElement>,
displayValues: DisplayValueType[],
allowClear?: boolean | { clearIcon?: RenderNode },
clearIcon?: RenderNode,
disabled: boolean = false,
mergedSearchValue?: string,
mode?: Mode,
) => {
const mergedClearIcon = React.useMemo(() => {
const clearIcon = React.useMemo(() => {
if (typeof allowClear === 'object') {
return allowClear.clearIcon;
}
if (clearIcon) {
return clearIcon;
}
}, [allowClear, clearIcon]);
}, [allowClear]);

const mergedAllowClear = React.useMemo<boolean>(() => {
if (
Expand All @@ -39,7 +35,7 @@ export const useAllowClear = (
<TransBtn
className={`${prefixCls}-clear`}
onMouseDown={onClearMouseDown}
customizeIcon={mergedClearIcon}
customizeIcon={clearIcon}
>
×
</TransBtn>
Expand Down
6 changes: 0 additions & 6 deletions src/utils/warningPropsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function warningProps(props: SelectProps) {
autoFocus,
labelInValue,
value,
inputValue,
optionLabelProp,
} = props;

Expand Down Expand Up @@ -149,11 +148,6 @@ function warningProps(props: SelectProps) {
}\`.`,
);
}

warning(
inputValue === undefined,
'`inputValue` is deprecated, please use `searchValue` instead.',
);
}
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ describe('Select.Basic', () => {

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

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

it('does not filter when filterOption value is false', () => {
const { container } = testingRender(
<Select inputValue="1" filterOption={false} open>
<Select searchValue="1" filterOption={false} open>
<Option value="1">1</Option>
<Option value="2">2</Option>
</Select>,
Expand Down Expand Up @@ -2330,7 +2330,7 @@ describe('Select.Basic', () => {
const renderDemo = (props?: any) => (
<Select
labelInValue
value={{ key: 1, label: 'One' }}
value={{ value: 1, label: 'One' }}
labelRender={labelRender}
options={[
{
Expand Down
Loading