From a30c78b7638db759db12a0feb347f88ab5d0a7d8 Mon Sep 17 00:00:00 2001 From: MuxinFeng <434980373@qq.com> Date: Mon, 3 Jul 2023 19:01:44 +0800 Subject: [PATCH] fix: rename inputIcon --- README.md | 9 +++-- docs/examples/custom-icon.tsx | 4 +-- docs/examples/multiple.tsx | 66 +++++++++++++++++++---------------- docs/examples/suggest.tsx | 2 +- src/BaseSelect.tsx | 8 ++--- tests/Multiple.test.tsx | 49 ++++++++++---------------- 6 files changed, 68 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 54d66851..11aced2b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,12 @@ React Select -[![NPM version][npm-image]][npm-url] [![npm download][download-image]][download-url] [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![bundle size][bundlephobia-image]][bundlephobia-url] [![dumi][dumi-image]][dumi-url] +[![NPM version][npm-image]][npm-url] +[![npm download][download-image]][download-url] +[![build status][github-actions-image]][github-actions-url] +[![Codecov][codecov-image]][codecov-url] +[![bundle size][bundlephobia-image]][bundlephobia-url] +[![dumi][dumi-image]][dumi-url] [npm-image]: http://img.shields.io/npm/v/rc-select.svg?style=flat-square [npm-url]: http://npmjs.org/package/rc-select @@ -113,7 +118,7 @@ export default () => ( | showAction | actions trigger the dropdown to show | String[]? | - | | autoFocus | focus select after mount | Bool | - | | autoClearSearchValue | auto clear search input value when multiple select is selected/deselected | boolean | true | -| inputIcon | specify the select arrow icon | ReactNode | - | +| suffixIcon | specify the select arrow icon | ReactNode | - | | clearIcon | specify the clear icon | ReactNode | - | | removeIcon | specify the remove icon | ReactNode | - | | menuItemSelectedIcon | specify the item selected icon | ReactNode \| (props: MenuItemProps) => ReactNode | - | diff --git a/docs/examples/custom-icon.tsx b/docs/examples/custom-icon.tsx index 938ad418..59daa7b8 100644 --- a/docs/examples/custom-icon.tsx +++ b/docs/examples/custom-icon.tsx @@ -102,7 +102,7 @@ class CustomIconComponent extends React.Component { value={value} mode="combobox" backfill - inputIcon={({ searchValue }) => { + suffixIcon={({ searchValue }) => { if (searchValue) { return '😺'; } @@ -192,7 +192,7 @@ class Test extends React.Component { onChange={this.onChange} onFocus={() => console.log('focus')} tokenSeparators={[' ', ',']} - inputIcon={getSvg(arrowPath)} + suffixIcon={getSvg(arrowPath)} clearIcon={getSvg(clearPath)} removeIcon={getSvg(clearPath)} menuItemSelectedIcon={menuItemSelectedIcon} diff --git a/docs/examples/multiple.tsx b/docs/examples/multiple.tsx index 80fba7af..5edae7f7 100644 --- a/docs/examples/multiple.tsx +++ b/docs/examples/multiple.tsx @@ -1,6 +1,6 @@ /* eslint-disable no-console */ -import React from 'react'; import Select, { Option } from 'rc-select'; +import React from 'react'; import '../../assets/index.less'; const children = []; @@ -15,10 +15,10 @@ for (let i = 10; i < 36; i += 1) { class Test extends React.Component { state = { useAnim: false, - inputIcon: null, + suffixIcon: null, loading: false, value: ['a10'], - searchValue: "", + searchValue: '', }; onChange = (value, options) => { @@ -36,32 +36,32 @@ class Test extends React.Component { console.log(args); }; - useAnim = e => { + useAnim = (e) => { this.setState({ useAnim: e.target.checked, }); }; - showArrow = e => { + showArrow = (e) => { this.setState({ - inputIcon: e.target.checked ?
arrow
: null, + suffixIcon: e.target.checked ?
arrow
: null, }); }; - loading = e => { + loading = (e) => { this.setState({ loading: e.target.checked, }); }; - setSearchValue = val => { + setSearchValue = (val) => { this.setState({ searchValue: val, - }) - } + }); + }; render() { - const { useAnim, loading, value, inputIcon } = this.state; + const { useAnim, loading, value, suffixIcon } = this.state; return (

multiple select(scroll the menu)

@@ -74,7 +74,12 @@ class Test extends React.Component {

@@ -93,7 +98,7 @@ class Test extends React.Component { style={{ width: 500 }} mode="multiple" loading={loading} - inputIcon={inputIcon} + suffixIcon={suffixIcon} allowClear optionFilterProp="children" optionLabelProp="children" @@ -102,33 +107,32 @@ class Test extends React.Component { placeholder="please select" onChange={this.onChange} onFocus={() => console.log('focus')} - onBlur={v => console.log('blur', v)} + onBlur={(v) => console.log('blur', v)} tokenSeparators={[' ', ',']} > {children}

-

multiple select with autoClearSearchValue = false

diff --git a/docs/examples/suggest.tsx b/docs/examples/suggest.tsx index e6326093..7e28e75b 100644 --- a/docs/examples/suggest.tsx +++ b/docs/examples/suggest.tsx @@ -59,7 +59,7 @@ class Test extends React.Component { placeholder="placeholder" defaultActiveFirstOption={false} getInputElement={() => } - inputIcon={null} + suffixIcon={null} notFoundContent="" onChange={this.fetchData} onSelect={this.onSelect} diff --git a/src/BaseSelect.tsx b/src/BaseSelect.tsx index 5086d7b3..7865eb7c 100644 --- a/src/BaseSelect.tsx +++ b/src/BaseSelect.tsx @@ -169,7 +169,7 @@ export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttri // >>> Icons allowClear?: boolean; - inputIcon?: RenderNode; + suffixIcon?: RenderNode; /** Clear all icon */ clearIcon?: RenderNode; /** Selector remove icon */ @@ -254,7 +254,7 @@ const BaseSelect = React.forwardRef((props: BaseSelectProps, ref: React.Ref { injectRunAllTimers(jest); @@ -379,7 +378,7 @@ describe('Select.Multiple', () => { expect(wrapper.find('.rc-select-arrow').length).toBeFalsy(); wrapper.setProps({ - inputIcon:
arrow
, + suffixIcon:
arrow
, }); expect(wrapper.find('.rc-select-arrow').length).toBeTruthy(); }); @@ -622,15 +621,10 @@ describe('Select.Multiple', () => { }); }); - describe("autoClearSearchValue", () => { + describe('autoClearSearchValue', () => { it('search value should not show when autoClearSearchValue is undefined', () => { const wrapper = mount( - , ); expect(wrapper.find('input').props().value).toBe(''); }); @@ -648,12 +642,12 @@ describe('Select.Multiple', () => { }); it('search value should no clear when autoClearSearchValue is false', () => { const wrapper = mount( - , ); toggleOpen(wrapper); @@ -662,12 +656,7 @@ describe('Select.Multiple', () => { }); it('search value should clear when autoClearSearchValue is true', () => { const wrapper = mount( - , ); toggleOpen(wrapper); toggleOpen(wrapper);