diff --git a/docs/examples/common.less b/docs/examples/common.less deleted file mode 100644 index d78a563b..00000000 --- a/docs/examples/common.less +++ /dev/null @@ -1,10 +0,0 @@ -// input { -// // height: 24px; -// // line-height: 24px; -// border: 1px solid #333; -// border-radius: 4px; -// } - -// button { -// border: 1px solid #333; -// } diff --git a/docs/examples/custom-icon.tsx b/docs/examples/custom-icon.tsx index b82aff55..4d3112d7 100644 --- a/docs/examples/custom-icon.tsx +++ b/docs/examples/custom-icon.tsx @@ -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" @@ -110,7 +110,6 @@ class CustomIconComponent extends React.Component { } return getSvg(arrowPath); }} - clearIcon={getSvg(clearPath)} removeIcon={getSvg(clearPath)} menuItemSelectedIcon={singleItemIcon} > @@ -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} @@ -196,7 +195,6 @@ class Test extends React.Component { tokenSeparators={[' ', ',']} prefix="Foobar" suffixIcon={getSvg(arrowPath)} - clearIcon={getSvg(clearPath)} removeIcon={getSvg(clearPath)} menuItemSelectedIcon={menuItemSelectedIcon} > diff --git a/src/Select.tsx b/src/Select.tsx index 9ead1bf4..3233b5a2 100644 --- a/src/Select.tsx +++ b/src/Select.tsx @@ -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 = @@ -119,9 +117,6 @@ export interface SelectProps>> Field Names fieldNames?: FieldNames; - // >>> Search - /** @deprecated Use `searchValue` instead */ - inputValue?: string; searchValue?: string; onSearch?: (value: string) => void; autoClearSearchValue?: boolean; @@ -178,7 +173,6 @@ const Select = React.forwardRef search || '', }); @@ -263,7 +257,6 @@ const Select = React.forwardRef { let rawValue: RawValueType; let rawLabel: React.ReactNode; - let rawKey: React.Key; let rawDisabled: boolean | undefined; let rawTitle: string; @@ -271,9 +264,8 @@ const Select = React.forwardRef mergedValues[index]?.value !== newVal?.value)) ) { - const returnValues = labelInValue ? labeledValues : labeledValues.map((v) => v.value); + const returnValues = labelInValue + ? labeledValues.map(({ label: l, value: v }) => ({ label: l, value: v })) + : labeledValues.map((v) => v.value); + const returnOptions = labeledValues.map((v) => injectPropsWithOption(getMixedOption(v.value)), ); @@ -513,7 +507,6 @@ const Select = React.forwardRef { }); it('show static prefix', () => { - render(); + render( + , + ); expect(screen.findByText('Foobar')).toBeTruthy(); }); @@ -459,7 +461,7 @@ describe('Select.Multiple', () => { toggleOpen(container); selectItem(container, 0); expect(onChange).toHaveBeenCalledWith( - [{ label: 'Light', value: 'light', key: 'light' }], + [{ label: 'Light', value: 'light' }], [{ label: 'Light', value: 'light', option: 2333 }], ); onChange.mockReset(); @@ -470,8 +472,8 @@ describe('Select.Multiple', () => { selectItem(container, 0); expect(onChange).toHaveBeenCalledWith( [ - { label: 'Light', value: 'light', key: 'light' }, - { label: 'Bamboo', value: 'bamboo', key: 'bamboo' }, + { label: 'Light', value: 'light' }, + { label: 'Bamboo', value: 'bamboo' }, ], [ { label: 'Light', value: 'light', option: 2333 }, diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx index a37330dd..47d430e1 100644 --- a/tests/Select.test.tsx +++ b/tests/Select.test.tsx @@ -289,7 +289,7 @@ describe('Select.Basic', () => { resetWarned(); const { container: container5 } = render( - x }} value="1"> , @@ -298,7 +298,7 @@ describe('Select.Basic', () => { expect(container5.querySelector('.custom-clear-icon').textContent).toBe('x'); const { container: container6 } = render( - x }}> , @@ -487,7 +487,7 @@ describe('Select.Basic', () => { toggleOpen(container); selectItem(container); expect(handleChange).toHaveBeenCalledWith( - { key: '1', value: '1', label: 'One' }, + { value: '1', label: 'One' }, { children: 'One', key: null, testprop: 'test', value: '1' }, ); }); @@ -508,7 +508,7 @@ describe('Select.Basic', () => { toggleOpen(container); selectItem(container); expect(handleChange).toHaveBeenCalledWith( - { key: '1', label: 'One', value: '1' }, + { label: 'One', value: '1' }, { children: 'One', key: null, testprop: 'test', value: '1' }, ); }); @@ -1240,7 +1240,7 @@ describe('Select.Basic', () => { it('does not filter when filterOption value is false', () => { const { container } = testingRender( - , @@ -2330,7 +2330,7 @@ describe('Select.Basic', () => { const renderDemo = (props?: any) => (