@douyinfe/semi-ui 2.7.0-beta.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/semi-ui.js +20 -4
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/form/hooks/useFormApi.tsx +3 -2
- package/lib/cjs/form/hooks/useFormApi.d.ts +2 -1
- package/lib/cjs/radio/radioGroup.js +6 -0
- package/lib/cjs/select/index.js +5 -2
- package/lib/cjs/tag/group.d.ts +2 -0
- package/lib/cjs/tag/group.js +4 -2
- package/lib/cjs/tree/nodeList.js +1 -0
- package/lib/cjs/treeSelect/index.js +4 -0
- package/lib/es/form/hooks/useFormApi.d.ts +2 -1
- package/lib/es/radio/radioGroup.js +6 -0
- package/lib/es/select/index.js +5 -2
- package/lib/es/tag/group.d.ts +2 -0
- package/lib/es/tag/group.js +4 -2
- package/lib/es/tree/nodeList.js +1 -0
- package/lib/es/treeSelect/index.js +4 -0
- package/package.json +9 -9
- package/radio/__test__/radioGroup.test.jsx +9 -1
- package/radio/_story/radio.stories.js +22 -1
- package/radio/radioGroup.tsx +9 -0
- package/select/_story/select.stories.js +73 -2
- package/select/index.tsx +5 -3
- package/tag/group.tsx +5 -3
- package/tree/nodeList.tsx +1 -0
- package/treeSelect/index.tsx +3 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { BaseFormApi } from '@douyinfe/semi-foundation/form/interface';
|
|
1
2
|
import React, { useContext } from 'react';
|
|
2
3
|
import { FormApiContext } from '../context';
|
|
3
4
|
|
|
4
|
-
export default function useFormApi() {
|
|
5
|
-
return useContext(FormApiContext);
|
|
5
|
+
export default function useFormApi<T extends Record<string, any> = any>() {
|
|
6
|
+
return useContext<BaseFormApi<T>>(FormApiContext);
|
|
6
7
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { BaseFormApi } from '@douyinfe/semi-foundation/lib/cjs/form/interface';
|
|
2
|
+
export default function useFormApi<T extends Record<string, any> = any>(): BaseFormApi<T>;
|
|
@@ -55,6 +55,12 @@ class RadioGroup extends _baseComponent.default {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
componentDidUpdate(prevProps) {
|
|
58
|
+
if (typeof prevProps.value === 'number' && isNaN(prevProps.value) && typeof this.props.value === 'number' && isNaN(this.props.value)) {
|
|
59
|
+
// `NaN === NaN` returns false, and this will fail the next if check
|
|
60
|
+
// therefore triggering an infinite loop
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
if (prevProps.value !== this.props.value) {
|
|
59
65
|
this.foundation.handlePropValueChange(this.props.value);
|
|
60
66
|
}
|
package/lib/cjs/select/index.js
CHANGED
|
@@ -742,7 +742,9 @@ class Select extends _baseComponent.default {
|
|
|
742
742
|
});
|
|
743
743
|
}
|
|
744
744
|
|
|
745
|
-
const
|
|
745
|
+
const mapItems = maxTagCount ? (0, _slice.default)(selectedItems).call(selectedItems, 0, maxTagCount) : selectedItems; // no need to render rest tag when maxTagCount is setting
|
|
746
|
+
|
|
747
|
+
const tags = (0, _map2.default)(mapItems).call(mapItems, (item, i) => {
|
|
746
748
|
const label = item[0];
|
|
747
749
|
const {
|
|
748
750
|
value
|
|
@@ -800,12 +802,13 @@ class Select extends _baseComponent.default {
|
|
|
800
802
|
const placeholderText = placeholder && !inputValue ? /*#__PURE__*/_react.default.createElement("span", {
|
|
801
803
|
className: spanCls
|
|
802
804
|
}, placeholder) : null;
|
|
803
|
-
const n =
|
|
805
|
+
const n = selectedItems.length > maxTagCount ? maxTagCount : undefined;
|
|
804
806
|
const NotOneLine = !maxTagCount; // Multiple lines (that is, do not set maxTagCount), do not use TagGroup, directly traverse with Tag, otherwise Input cannot follow the correct position
|
|
805
807
|
|
|
806
808
|
const tagContent = NotOneLine ? tags : /*#__PURE__*/_react.default.createElement(_group.default, {
|
|
807
809
|
tagList: tags,
|
|
808
810
|
maxTagCount: n,
|
|
811
|
+
restCount: maxTagCount ? selectedItems.length - maxTagCount : undefined,
|
|
809
812
|
size: "large",
|
|
810
813
|
mode: "custom"
|
|
811
814
|
});
|
package/lib/cjs/tag/group.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface TagGroupProps {
|
|
|
7
7
|
style?: React.CSSProperties;
|
|
8
8
|
className?: string;
|
|
9
9
|
maxTagCount?: number;
|
|
10
|
+
restCount?: number;
|
|
10
11
|
tagList?: (TagProps | React.ReactNode)[];
|
|
11
12
|
size?: 'small' | 'large';
|
|
12
13
|
showPopover?: boolean;
|
|
@@ -26,6 +27,7 @@ export default class TagGroup extends PureComponent<TagGroupProps> {
|
|
|
26
27
|
style: PropTypes.Requireable<object>;
|
|
27
28
|
className: PropTypes.Requireable<string>;
|
|
28
29
|
maxTagCount: PropTypes.Requireable<number>;
|
|
30
|
+
restCount: PropTypes.Requireable<number>;
|
|
29
31
|
tagList: PropTypes.Requireable<any[]>;
|
|
30
32
|
size: PropTypes.Requireable<string>;
|
|
31
33
|
mode: PropTypes.Requireable<string>;
|
package/lib/cjs/tag/group.js
CHANGED
|
@@ -77,9 +77,10 @@ class TagGroup extends _react.PureComponent {
|
|
|
77
77
|
renderMergeTags(tags) {
|
|
78
78
|
const {
|
|
79
79
|
maxTagCount,
|
|
80
|
-
tagList
|
|
80
|
+
tagList,
|
|
81
|
+
restCount
|
|
81
82
|
} = this.props;
|
|
82
|
-
const n = tagList.length - maxTagCount;
|
|
83
|
+
const n = restCount ? restCount : tagList.length - maxTagCount;
|
|
83
84
|
let renderTags = tags;
|
|
84
85
|
const normalTags = (0, _slice.default)(tags).call(tags, 0, maxTagCount);
|
|
85
86
|
const restTags = (0, _slice.default)(tags).call(tags, maxTagCount);
|
|
@@ -156,6 +157,7 @@ TagGroup.propTypes = {
|
|
|
156
157
|
style: _propTypes.default.object,
|
|
157
158
|
className: _propTypes.default.string,
|
|
158
159
|
maxTagCount: _propTypes.default.number,
|
|
160
|
+
restCount: _propTypes.default.number,
|
|
159
161
|
tagList: _propTypes.default.array,
|
|
160
162
|
size: _propTypes.default.oneOf(tagSize),
|
|
161
163
|
mode: _propTypes.default.string,
|
package/lib/cjs/tree/nodeList.js
CHANGED
|
@@ -955,6 +955,10 @@ class TreeSelect extends _baseComponent.default {
|
|
|
955
955
|
this.clickOutsideHandler = null;
|
|
956
956
|
this.foundation = new _foundation.default(this.adapter);
|
|
957
957
|
this.treeSelectID = (0, _slice.default)(_context2 = Math.random().toString(36)).call(_context2, 2);
|
|
958
|
+
|
|
959
|
+
this.onMotionEnd = () => {
|
|
960
|
+
this.adapter.rePositionDropdown();
|
|
961
|
+
};
|
|
958
962
|
} // eslint-disable-next-line max-lines-per-function
|
|
959
963
|
|
|
960
964
|
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { BaseFormApi } from '@douyinfe/semi-foundation/lib/es/form/interface';
|
|
2
|
+
export default function useFormApi<T extends Record<string, any> = any>(): BaseFormApi<T>;
|
|
@@ -32,6 +32,12 @@ class RadioGroup extends BaseComponent {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
componentDidUpdate(prevProps) {
|
|
35
|
+
if (typeof prevProps.value === 'number' && isNaN(prevProps.value) && typeof this.props.value === 'number' && isNaN(this.props.value)) {
|
|
36
|
+
// `NaN === NaN` returns false, and this will fail the next if check
|
|
37
|
+
// therefore triggering an infinite loop
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
if (prevProps.value !== this.props.value) {
|
|
36
42
|
this.foundation.handlePropValueChange(this.props.value);
|
|
37
43
|
}
|
package/lib/es/select/index.js
CHANGED
|
@@ -688,7 +688,9 @@ class Select extends BaseComponent {
|
|
|
688
688
|
});
|
|
689
689
|
}
|
|
690
690
|
|
|
691
|
-
const
|
|
691
|
+
const mapItems = maxTagCount ? _sliceInstanceProperty(selectedItems).call(selectedItems, 0, maxTagCount) : selectedItems; // no need to render rest tag when maxTagCount is setting
|
|
692
|
+
|
|
693
|
+
const tags = _mapInstanceProperty(mapItems).call(mapItems, (item, i) => {
|
|
692
694
|
const label = item[0];
|
|
693
695
|
const {
|
|
694
696
|
value
|
|
@@ -747,12 +749,13 @@ class Select extends BaseComponent {
|
|
|
747
749
|
const placeholderText = placeholder && !inputValue ? /*#__PURE__*/React.createElement("span", {
|
|
748
750
|
className: spanCls
|
|
749
751
|
}, placeholder) : null;
|
|
750
|
-
const n =
|
|
752
|
+
const n = selectedItems.length > maxTagCount ? maxTagCount : undefined;
|
|
751
753
|
const NotOneLine = !maxTagCount; // Multiple lines (that is, do not set maxTagCount), do not use TagGroup, directly traverse with Tag, otherwise Input cannot follow the correct position
|
|
752
754
|
|
|
753
755
|
const tagContent = NotOneLine ? tags : /*#__PURE__*/React.createElement(TagGroup, {
|
|
754
756
|
tagList: tags,
|
|
755
757
|
maxTagCount: n,
|
|
758
|
+
restCount: maxTagCount ? selectedItems.length - maxTagCount : undefined,
|
|
756
759
|
size: "large",
|
|
757
760
|
mode: "custom"
|
|
758
761
|
});
|
package/lib/es/tag/group.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface TagGroupProps {
|
|
|
7
7
|
style?: React.CSSProperties;
|
|
8
8
|
className?: string;
|
|
9
9
|
maxTagCount?: number;
|
|
10
|
+
restCount?: number;
|
|
10
11
|
tagList?: (TagProps | React.ReactNode)[];
|
|
11
12
|
size?: 'small' | 'large';
|
|
12
13
|
showPopover?: boolean;
|
|
@@ -26,6 +27,7 @@ export default class TagGroup extends PureComponent<TagGroupProps> {
|
|
|
26
27
|
style: PropTypes.Requireable<object>;
|
|
27
28
|
className: PropTypes.Requireable<string>;
|
|
28
29
|
maxTagCount: PropTypes.Requireable<number>;
|
|
30
|
+
restCount: PropTypes.Requireable<number>;
|
|
29
31
|
tagList: PropTypes.Requireable<any[]>;
|
|
30
32
|
size: PropTypes.Requireable<string>;
|
|
31
33
|
mode: PropTypes.Requireable<string>;
|
package/lib/es/tag/group.js
CHANGED
|
@@ -46,9 +46,10 @@ export default class TagGroup extends PureComponent {
|
|
|
46
46
|
renderMergeTags(tags) {
|
|
47
47
|
const {
|
|
48
48
|
maxTagCount,
|
|
49
|
-
tagList
|
|
49
|
+
tagList,
|
|
50
|
+
restCount
|
|
50
51
|
} = this.props;
|
|
51
|
-
const n = tagList.length - maxTagCount;
|
|
52
|
+
const n = restCount ? restCount : tagList.length - maxTagCount;
|
|
52
53
|
let renderTags = tags;
|
|
53
54
|
|
|
54
55
|
const normalTags = _sliceInstanceProperty(tags).call(tags, 0, maxTagCount);
|
|
@@ -128,6 +129,7 @@ TagGroup.propTypes = {
|
|
|
128
129
|
style: PropTypes.object,
|
|
129
130
|
className: PropTypes.string,
|
|
130
131
|
maxTagCount: PropTypes.number,
|
|
132
|
+
restCount: PropTypes.number,
|
|
131
133
|
tagList: PropTypes.array,
|
|
132
134
|
size: PropTypes.oneOf(tagSize),
|
|
133
135
|
mode: PropTypes.string,
|
package/lib/es/tree/nodeList.js
CHANGED
|
@@ -901,6 +901,10 @@ class TreeSelect extends BaseComponent {
|
|
|
901
901
|
this.clickOutsideHandler = null;
|
|
902
902
|
this.foundation = new TreeSelectFoundation(this.adapter);
|
|
903
903
|
this.treeSelectID = _sliceInstanceProperty(_context2 = Math.random().toString(36)).call(_context2, 2);
|
|
904
|
+
|
|
905
|
+
this.onMotionEnd = () => {
|
|
906
|
+
this.adapter.rePositionDropdown();
|
|
907
|
+
};
|
|
904
908
|
} // eslint-disable-next-line max-lines-per-function
|
|
905
909
|
|
|
906
910
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.7.0
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
17
|
-
"@douyinfe/semi-animation": "2.7.0
|
|
18
|
-
"@douyinfe/semi-animation-react": "2.7.0
|
|
19
|
-
"@douyinfe/semi-foundation": "2.7.0
|
|
20
|
-
"@douyinfe/semi-icons": "2.7.0
|
|
21
|
-
"@douyinfe/semi-illustrations": "2.7.0
|
|
22
|
-
"@douyinfe/semi-theme-default": "2.7.0
|
|
17
|
+
"@douyinfe/semi-animation": "2.7.0",
|
|
18
|
+
"@douyinfe/semi-animation-react": "2.7.0",
|
|
19
|
+
"@douyinfe/semi-foundation": "2.7.0",
|
|
20
|
+
"@douyinfe/semi-icons": "2.7.0",
|
|
21
|
+
"@douyinfe/semi-illustrations": "2.7.0",
|
|
22
|
+
"@douyinfe/semi-theme-default": "2.7.0",
|
|
23
23
|
"@types/react-window": "^1.8.2",
|
|
24
24
|
"async-validator": "^3.5.0",
|
|
25
25
|
"classnames": "^2.2.6",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
],
|
|
70
70
|
"author": "",
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "b6e4e0a1e22d4dabe68cbf7e3d2cfd0202da0424",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
76
76
|
"@babel/preset-env": "^7.15.8",
|
|
77
77
|
"@babel/preset-react": "^7.14.5",
|
|
78
|
-
"@douyinfe/semi-scss-compile": "2.7.0
|
|
78
|
+
"@douyinfe/semi-scss-compile": "2.7.0",
|
|
79
79
|
"@storybook/addon-knobs": "^6.3.1",
|
|
80
80
|
"@types/lodash": "^4.14.176",
|
|
81
81
|
"babel-loader": "^8.2.2",
|
|
@@ -196,4 +196,12 @@ describe('RadioGroup', () => {
|
|
|
196
196
|
expect(middleRadio.exists(`.${BASE_CLASS_PREFIX}-radio-addon-buttonRadio-middle`)).toEqual(true);
|
|
197
197
|
expect(largeRadio.exists(`.${BASE_CLASS_PREFIX}-radio-addon-buttonRadio-large`)).toEqual(true);
|
|
198
198
|
});
|
|
199
|
-
|
|
199
|
+
|
|
200
|
+
it('does not trigger Maximum update exceeded when setting radio-group\'s value to NaN', () => {
|
|
201
|
+
const radioGroup = mount(
|
|
202
|
+
createRadioGroup({ value: NaN }),
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
expect(radioGroup.exists(`${BASE_CLASS_PREFIX}-radio-checked`)).toEqual(false);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
@@ -865,4 +865,25 @@ export const FixWithFieldLossRef = () => {
|
|
|
865
865
|
</Form>
|
|
866
866
|
);
|
|
867
867
|
}
|
|
868
|
-
FixWithFieldLossRef.storyName = '修复 Form Field 丢失 ref 问题 #384';
|
|
868
|
+
FixWithFieldLossRef.storyName = '修复 Form Field 丢失 ref 问题 #384';
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
export const SwitchValueToNaN = () => {
|
|
872
|
+
const [val, setVal] = useState(1);
|
|
873
|
+
|
|
874
|
+
return (
|
|
875
|
+
<>
|
|
876
|
+
<RadioGroup direction="vertical" aria-label="单选组合示例" value={val}>
|
|
877
|
+
<Radio value={1}>A</Radio>
|
|
878
|
+
<Radio value={2}>B</Radio>
|
|
879
|
+
<Radio value={3}>C</Radio>
|
|
880
|
+
<Radio value={4}>D</Radio>
|
|
881
|
+
</RadioGroup>
|
|
882
|
+
<Space>
|
|
883
|
+
<Button onClick={() => setVal(NaN)}>NaN</Button>
|
|
884
|
+
<Button onClick={() => setVal(2)}>2</Button>
|
|
885
|
+
</Space>
|
|
886
|
+
</>
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
SwitchValueToNaN.storyName = 'SwitchValueToNaN';
|
package/radio/radioGroup.tsx
CHANGED
|
@@ -97,6 +97,15 @@ class RadioGroup extends BaseComponent<RadioGroupProps, RadioGroupState> {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
componentDidUpdate(prevProps: RadioGroupProps) {
|
|
100
|
+
if (typeof prevProps.value === 'number'
|
|
101
|
+
&& isNaN(prevProps.value)
|
|
102
|
+
&& typeof this.props.value === 'number'
|
|
103
|
+
&& isNaN(this.props.value)
|
|
104
|
+
) {
|
|
105
|
+
// `NaN === NaN` returns false, and this will fail the next if check
|
|
106
|
+
// therefore triggering an infinite loop
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
100
109
|
if (prevProps.value !== this.props.value) {
|
|
101
110
|
this.foundation.handlePropValueChange(this.props.value);
|
|
102
111
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState, useRef, useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
import './select.scss';
|
|
4
|
-
import { Input, Select, Button, Icon, Avatar, Checkbox, Form, withField, Space } from '../../index';
|
|
4
|
+
import { Input, Select, Button, Icon, Avatar, Checkbox, Form, withField, Space, Tag } from '../../index';
|
|
5
5
|
import CustomTrigger from './CustomTrigger';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import { getHighLightTextHTML } from '../../_utils/index';
|
|
@@ -2903,4 +2903,75 @@ export const AutoClearSearchValue = () => {
|
|
|
2903
2903
|
|
|
2904
2904
|
SelectInputPropsDemo.story = {
|
|
2905
2905
|
name: 'AutoClearSearchValue',
|
|
2906
|
-
};
|
|
2906
|
+
};
|
|
2907
|
+
|
|
2908
|
+
|
|
2909
|
+
export const RenderSelectedItemCallCount = () => {
|
|
2910
|
+
const list = [
|
|
2911
|
+
{ "name": "夏可漫", "email": "xiakeman@example.com", "avatar": "https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/avatarDemo.jpeg" },
|
|
2912
|
+
{ "name": "申悦", "email": "shenyue@example.com", "avatar": "https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bf8647bffab13c38772c9ff94bf91a9d.jpg" },
|
|
2913
|
+
{ "name": "曲晨一", "email": "quchenyi@example.com", "avatar": "https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/8bd8224511db085ed74fea37205aede5.jpg" },
|
|
2914
|
+
{ "name": "文嘉茂", "email": "wenjiamao@example.com", "avatar": "https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/6fbafc2d-e3e6-4cff-a1e2-17709c680624.png" },
|
|
2915
|
+
{ "name": "文嘉茂2", "email": "wenjiamao@example.com", "avatar": "https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/6fbafc2d-e3e6-4cff-a1e2-17709c680624.png" },
|
|
2916
|
+
{ "name": "文嘉茂3", "email": "wenjiamao@example.com", "avatar": "https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/6fbafc2d-e3e6-4cff-a1e2-17709c680624.png" },
|
|
2917
|
+
]
|
|
2918
|
+
|
|
2919
|
+
const renderMultipleWithCustomTag = (optionNode, { onClose }) => {
|
|
2920
|
+
console.count('rerender')
|
|
2921
|
+
const content = (
|
|
2922
|
+
<Tag
|
|
2923
|
+
avatarSrc={optionNode.avatar}
|
|
2924
|
+
avatarShape='circle'
|
|
2925
|
+
closable={true}
|
|
2926
|
+
onClose={onClose}
|
|
2927
|
+
size='large'
|
|
2928
|
+
>
|
|
2929
|
+
{optionNode.name}
|
|
2930
|
+
</Tag>
|
|
2931
|
+
);
|
|
2932
|
+
return {
|
|
2933
|
+
isRenderInTag: false,
|
|
2934
|
+
content
|
|
2935
|
+
};
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
const renderCustomOption = (item, index) => {
|
|
2939
|
+
const optionStyle = {
|
|
2940
|
+
display: 'flex',
|
|
2941
|
+
paddingLeft: 24,
|
|
2942
|
+
paddingTop: 10,
|
|
2943
|
+
paddingBottom: 10
|
|
2944
|
+
}
|
|
2945
|
+
return (
|
|
2946
|
+
<Select.Option key={index} value={item.name} style={optionStyle} showTick={true} {...item} key={item.email}>
|
|
2947
|
+
<Avatar size="small" src={item.avatar} />
|
|
2948
|
+
<div style={{ marginLeft: 8 }}>
|
|
2949
|
+
<div style={{ fontSize: 14 }}>{item.name}</div>
|
|
2950
|
+
<div style={{ color: 'var(--color-text-2)', fontSize: 12, lineHeight: '16px', fontWeight: 'normal' }}>{item.email}</div>
|
|
2951
|
+
</div>
|
|
2952
|
+
</Select.Option>
|
|
2953
|
+
)
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
return (
|
|
2957
|
+
<>
|
|
2958
|
+
<Select
|
|
2959
|
+
placeholder='请选择'
|
|
2960
|
+
showClear
|
|
2961
|
+
multiple
|
|
2962
|
+
maxTagCount={2}
|
|
2963
|
+
style={{ width: 280, height: 40 }}
|
|
2964
|
+
onChange={v => console.log(v)}
|
|
2965
|
+
defaultValue={'夏可漫'}
|
|
2966
|
+
renderSelectedItem={renderMultipleWithCustomTag}
|
|
2967
|
+
>
|
|
2968
|
+
{list.map((item, index) => renderCustomOption(item, index))}
|
|
2969
|
+
</Select>
|
|
2970
|
+
</>
|
|
2971
|
+
);
|
|
2972
|
+
}
|
|
2973
|
+
|
|
2974
|
+
|
|
2975
|
+
RenderSelectedItemCallCount.story = {
|
|
2976
|
+
name: 'RenderSelectedItemCallCount',
|
|
2977
|
+
};
|
package/select/index.tsx
CHANGED
|
@@ -898,8 +898,10 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
898
898
|
content: optionNode.label,
|
|
899
899
|
});
|
|
900
900
|
}
|
|
901
|
+
|
|
902
|
+
const mapItems = maxTagCount ? selectedItems.slice(0, maxTagCount) : selectedItems; // no need to render rest tag when maxTagCount is setting
|
|
901
903
|
|
|
902
|
-
const tags =
|
|
904
|
+
const tags = mapItems.map((item, i) => {
|
|
903
905
|
const label = item[0];
|
|
904
906
|
const { value } = item[1];
|
|
905
907
|
const disabled = item[1].disabled || selectDisabled;
|
|
@@ -939,11 +941,11 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
939
941
|
// [prefixcls + '-selection-text-inactive']: !inputValue && !tags.length,
|
|
940
942
|
});
|
|
941
943
|
const placeholderText = placeholder && !inputValue ? <span className={spanCls}>{placeholder}</span> : null;
|
|
942
|
-
const n =
|
|
944
|
+
const n = selectedItems.length > maxTagCount ? maxTagCount : undefined;
|
|
943
945
|
|
|
944
946
|
const NotOneLine = !maxTagCount; // Multiple lines (that is, do not set maxTagCount), do not use TagGroup, directly traverse with Tag, otherwise Input cannot follow the correct position
|
|
945
947
|
|
|
946
|
-
const tagContent = NotOneLine ? tags : <TagGroup tagList={tags} maxTagCount={n} size="large" mode="custom" />;
|
|
948
|
+
const tagContent = NotOneLine ? tags : <TagGroup tagList={tags} maxTagCount={n} restCount={maxTagCount ? selectedItems.length - maxTagCount : undefined} size="large" mode="custom" />;
|
|
947
949
|
|
|
948
950
|
return (
|
|
949
951
|
<>
|
package/tag/group.tsx
CHANGED
|
@@ -14,12 +14,13 @@ export interface TagGroupProps {
|
|
|
14
14
|
style?: React.CSSProperties;
|
|
15
15
|
className?: string;
|
|
16
16
|
maxTagCount?: number;
|
|
17
|
+
restCount?: number;
|
|
17
18
|
tagList?: (TagProps | React.ReactNode)[];
|
|
18
19
|
size?: 'small' | 'large';
|
|
19
20
|
showPopover?: boolean;
|
|
20
21
|
popoverProps?: PopoverProps;
|
|
21
22
|
avatarShape?: AvatarShape;
|
|
22
|
-
mode?: string;
|
|
23
|
+
mode?: string;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export default class TagGroup extends PureComponent<TagGroupProps> {
|
|
@@ -35,6 +36,7 @@ export default class TagGroup extends PureComponent<TagGroupProps> {
|
|
|
35
36
|
style: PropTypes.object,
|
|
36
37
|
className: PropTypes.string,
|
|
37
38
|
maxTagCount: PropTypes.number,
|
|
39
|
+
restCount: PropTypes.number,
|
|
38
40
|
tagList: PropTypes.array,
|
|
39
41
|
size: PropTypes.oneOf(tagSize),
|
|
40
42
|
mode: PropTypes.string,
|
|
@@ -77,8 +79,8 @@ export default class TagGroup extends PureComponent<TagGroupProps> {
|
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
renderMergeTags(tags: (Tag | React.ReactNode)[]) {
|
|
80
|
-
const { maxTagCount, tagList } = this.props;
|
|
81
|
-
const n = tagList.length - maxTagCount;
|
|
82
|
+
const { maxTagCount, tagList, restCount } = this.props;
|
|
83
|
+
const n = restCount ? restCount : tagList.length - maxTagCount;
|
|
82
84
|
let renderTags: (Tag | React.ReactNode)[] = tags;
|
|
83
85
|
|
|
84
86
|
const normalTags: (Tag | React.ReactNode)[] = tags.slice(0, maxTagCount);
|
package/tree/nodeList.tsx
CHANGED
package/treeSelect/index.tsx
CHANGED
|
@@ -331,6 +331,9 @@ class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState> {
|
|
|
331
331
|
this.clickOutsideHandler = null;
|
|
332
332
|
this.foundation = new TreeSelectFoundation(this.adapter);
|
|
333
333
|
this.treeSelectID = Math.random().toString(36).slice(2);
|
|
334
|
+
this.onMotionEnd = () => {
|
|
335
|
+
this.adapter.rePositionDropdown();
|
|
336
|
+
};
|
|
334
337
|
}
|
|
335
338
|
|
|
336
339
|
// eslint-disable-next-line max-lines-per-function
|