@douyinfe/semi-ui 2.17.0 → 2.19.0-alpha.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/anchor/index.tsx +1 -1
- package/anchor/link.tsx +3 -4
- package/autoComplete/__test__/autoComplete.test.js +6 -6
- package/autoComplete/index.tsx +3 -1
- package/autoComplete/option.tsx +164 -0
- package/calendar/__test__/calendar.test.js +21 -2
- package/calendar/_story/calendar.stories.js +31 -0
- package/calendar/index.tsx +3 -1
- package/calendar/interface.ts +2 -1
- package/carousel/index.tsx +5 -5
- package/checkbox/checkbox.tsx +10 -2
- package/dist/css/semi.css +174 -29
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +4190 -5430
- 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/_story/FieldProps/labelOptional.jsx +30 -0
- package/form/_story/form.stories.js +7 -0
- package/form/hoc/withField.tsx +1 -0
- package/form/label.tsx +21 -7
- package/gulpfile.js +3 -1
- package/lib/cjs/_base/base.css +35 -0
- package/lib/cjs/anchor/index.js +2 -1
- package/lib/cjs/anchor/link.d.ts +1 -1
- package/lib/cjs/anchor/link.js +9 -5
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/autoComplete/index.js +6 -3
- package/lib/cjs/autoComplete/option.d.ts +50 -0
- package/lib/cjs/autoComplete/option.js +218 -0
- package/lib/cjs/calendar/index.d.ts +2 -0
- package/lib/cjs/calendar/index.js +3 -1
- package/lib/cjs/calendar/interface.d.ts +2 -1
- package/lib/cjs/carousel/index.js +2 -2
- package/lib/cjs/checkbox/checkbox.d.ts +4 -0
- package/lib/cjs/checkbox/checkbox.js +9 -3
- package/lib/cjs/form/hoc/withField.js +2 -1
- package/lib/cjs/form/label.d.ts +8 -5
- package/lib/cjs/form/label.js +15 -4
- package/lib/cjs/locale/interface.d.ts +3 -0
- package/lib/cjs/locale/source/ar.js +3 -0
- package/lib/cjs/locale/source/de.js +3 -0
- package/lib/cjs/locale/source/en_GB.js +3 -0
- package/lib/cjs/locale/source/en_US.js +3 -0
- package/lib/cjs/locale/source/es.js +3 -0
- package/lib/cjs/locale/source/fr.js +3 -0
- package/lib/cjs/locale/source/id_ID.js +3 -0
- package/lib/cjs/locale/source/it.js +3 -0
- package/lib/cjs/locale/source/ja_JP.js +3 -0
- package/lib/cjs/locale/source/ko_KR.js +3 -0
- package/lib/cjs/locale/source/ms_MY.js +3 -0
- package/lib/cjs/locale/source/pt_BR.js +3 -0
- package/lib/cjs/locale/source/ru_RU.js +3 -0
- package/lib/cjs/locale/source/th_TH.js +3 -0
- package/lib/cjs/locale/source/tr_TR.js +3 -0
- package/lib/cjs/locale/source/vi_VN.js +3 -0
- package/lib/cjs/locale/source/zh_CN.js +3 -0
- package/lib/cjs/locale/source/zh_TW.js +3 -0
- package/lib/cjs/modal/Modal.js +0 -8
- package/lib/cjs/modal/ModalContent.js +4 -1
- package/lib/cjs/radio/radio.d.ts +2 -0
- package/lib/cjs/radio/radio.js +33 -8
- package/lib/cjs/table/ColumnFilter.js +4 -2
- package/lib/cjs/table/ColumnSorter.d.ts +1 -0
- package/lib/cjs/table/ColumnSorter.js +9 -6
- package/lib/cjs/table/Table.js +11 -4
- package/lib/cjs/tag/group.d.ts +3 -0
- package/lib/cjs/tag/group.js +24 -6
- package/lib/cjs/tag/index.d.ts +2 -1
- package/lib/cjs/tag/index.js +7 -5
- package/lib/cjs/tag/interface.d.ts +2 -1
- package/lib/cjs/tree/index.d.ts +3 -1
- package/lib/cjs/tree/index.js +23 -0
- package/lib/cjs/tree/interface.d.ts +4 -0
- package/lib/cjs/tree/treeNode.d.ts +4 -1
- package/lib/cjs/tree/treeNode.js +13 -4
- package/lib/es/_base/base.css +35 -0
- package/lib/es/anchor/index.js +2 -1
- package/lib/es/anchor/link.d.ts +1 -1
- package/lib/es/anchor/link.js +9 -5
- package/lib/es/autoComplete/index.d.ts +1 -1
- package/lib/es/autoComplete/index.js +6 -3
- package/lib/es/autoComplete/option.d.ts +50 -0
- package/lib/es/autoComplete/option.js +188 -0
- package/lib/es/calendar/index.d.ts +2 -0
- package/lib/es/calendar/index.js +3 -1
- package/lib/es/calendar/interface.d.ts +2 -1
- package/lib/es/carousel/index.js +2 -2
- package/lib/es/checkbox/checkbox.d.ts +4 -0
- package/lib/es/checkbox/checkbox.js +10 -4
- package/lib/es/form/hoc/withField.js +2 -1
- package/lib/es/form/label.d.ts +8 -5
- package/lib/es/form/label.js +13 -4
- package/lib/es/locale/interface.d.ts +3 -0
- package/lib/es/locale/source/ar.js +3 -0
- package/lib/es/locale/source/de.js +3 -0
- package/lib/es/locale/source/en_GB.js +3 -0
- package/lib/es/locale/source/en_US.js +3 -0
- package/lib/es/locale/source/es.js +3 -0
- package/lib/es/locale/source/fr.js +3 -0
- package/lib/es/locale/source/id_ID.js +3 -0
- package/lib/es/locale/source/it.js +3 -0
- package/lib/es/locale/source/ja_JP.js +3 -0
- package/lib/es/locale/source/ko_KR.js +3 -0
- package/lib/es/locale/source/ms_MY.js +3 -0
- package/lib/es/locale/source/pt_BR.js +3 -0
- package/lib/es/locale/source/ru_RU.js +3 -0
- package/lib/es/locale/source/th_TH.js +3 -0
- package/lib/es/locale/source/tr_TR.js +3 -0
- package/lib/es/locale/source/vi_VN.js +3 -0
- package/lib/es/locale/source/zh_CN.js +3 -0
- package/lib/es/locale/source/zh_TW.js +3 -0
- package/lib/es/modal/Modal.js +0 -8
- package/lib/es/modal/ModalContent.js +4 -1
- package/lib/es/radio/radio.d.ts +2 -0
- package/lib/es/radio/radio.js +31 -8
- package/lib/es/table/ColumnFilter.js +4 -2
- package/lib/es/table/ColumnSorter.d.ts +1 -0
- package/lib/es/table/ColumnSorter.js +9 -6
- package/lib/es/table/Table.js +10 -4
- package/lib/es/tag/group.d.ts +3 -0
- package/lib/es/tag/group.js +24 -6
- package/lib/es/tag/index.d.ts +2 -1
- package/lib/es/tag/index.js +7 -5
- package/lib/es/tag/interface.d.ts +2 -1
- package/lib/es/tree/index.d.ts +3 -1
- package/lib/es/tree/index.js +22 -0
- package/lib/es/tree/interface.d.ts +4 -0
- package/lib/es/tree/treeNode.d.ts +4 -1
- package/lib/es/tree/treeNode.js +13 -4
- package/locale/interface.ts +3 -0
- package/locale/source/ar.ts +3 -0
- package/locale/source/de.ts +3 -0
- package/locale/source/en_GB.ts +3 -0
- package/locale/source/en_US.ts +3 -0
- package/locale/source/es.ts +3 -0
- package/locale/source/fr.ts +3 -0
- package/locale/source/id_ID.ts +3 -0
- package/locale/source/it.ts +3 -0
- package/locale/source/ja_JP.ts +3 -0
- package/locale/source/ko_KR.ts +3 -0
- package/locale/source/ms_MY.ts +3 -0
- package/locale/source/pt_BR.ts +3 -0
- package/locale/source/ru_RU.ts +3 -0
- package/locale/source/th_TH.ts +3 -0
- package/locale/source/tr_TR.ts +4 -1
- package/locale/source/vi_VN.ts +3 -0
- package/locale/source/zh_CN.ts +3 -0
- package/locale/source/zh_TW.ts +3 -0
- package/modal/Modal.tsx +0 -6
- package/modal/ModalContent.tsx +4 -1
- package/modal/__test__/modal.test.js +1 -1
- package/modal/_story/__snapshots__/modal.stories.tsx.snap +203 -0
- package/package.json +7 -7
- package/radio/_story/radio.stories.js +2 -2
- package/radio/radio.tsx +27 -5
- package/rating/__test__/rating.test.js +1 -1
- package/select/__test__/select.test.js +11 -17
- package/select/_story/select.stories.js +6 -6
- package/steps/_story/steps.stories.js +3 -3
- package/switch/_story/switch.stories.js +4 -4
- package/switch/_story/switch.stories.tsx +4 -4
- package/table/ColumnFilter.tsx +2 -1
- package/table/ColumnSorter.tsx +16 -10
- package/table/Table.tsx +7 -4
- package/table/_story/v2/FixedFilter/index.tsx +106 -0
- package/table/_story/v2/FixedSorter/index.tsx +102 -0
- package/table/_story/v2/index.js +4 -2
- package/tag/_story/tag.stories.js +57 -1
- package/tag/group.tsx +20 -3
- package/tag/index.tsx +6 -5
- package/tag/interface.ts +2 -1
- package/transfer/_story/transfer.stories.js +2 -2
- package/tree/_story/tree.stories.js +152 -3
- package/tree/index.tsx +16 -1
- package/tree/interface.ts +6 -0
- package/tree/treeNode.tsx +11 -5
- package/upload/_story/upload.stories.js +2 -2
- package/webpack.config.js +13 -3
|
@@ -12,9 +12,10 @@ export default class ColumnSorter extends PureComponent {
|
|
|
12
12
|
prefixCls,
|
|
13
13
|
onClick,
|
|
14
14
|
sortOrder,
|
|
15
|
-
style
|
|
15
|
+
style,
|
|
16
|
+
title
|
|
16
17
|
} = this.props;
|
|
17
|
-
const iconBtnSize = '
|
|
18
|
+
const iconBtnSize = 'default';
|
|
18
19
|
const upCls = cls("".concat(prefixCls, "-column-sorter-up"), {
|
|
19
20
|
on: sortOrder === strings.SORT_DIRECTIONS[0]
|
|
20
21
|
});
|
|
@@ -33,11 +34,13 @@ export default class ColumnSorter extends PureComponent {
|
|
|
33
34
|
role: 'button'
|
|
34
35
|
}, ariaProps, {
|
|
35
36
|
tabIndex: -1,
|
|
36
|
-
|
|
37
|
-
className: "".concat(prefixCls, "-column-sorter"),
|
|
37
|
+
className: "".concat(prefixCls, "-column-sorter-wrapper"),
|
|
38
38
|
onClick: onClick,
|
|
39
39
|
onKeyPress: e => isEnterPress(e) && onClick(e)
|
|
40
|
-
}), /*#__PURE__*/React.createElement("
|
|
40
|
+
}), title, /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
style: style,
|
|
42
|
+
className: "".concat(prefixCls, "-column-sorter")
|
|
43
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
41
44
|
className: "".concat(upCls)
|
|
42
45
|
}, /*#__PURE__*/React.createElement(IconCaretup, {
|
|
43
46
|
size: iconBtnSize
|
|
@@ -45,7 +48,7 @@ export default class ColumnSorter extends PureComponent {
|
|
|
45
48
|
className: "".concat(downCls)
|
|
46
49
|
}, /*#__PURE__*/React.createElement(IconCaretdown, {
|
|
47
50
|
size: iconBtnSize
|
|
48
|
-
})));
|
|
51
|
+
}))));
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
}
|
package/lib/es/table/Table.js
CHANGED
|
@@ -494,15 +494,23 @@ class Table extends BaseComponent {
|
|
|
494
494
|
const defaultSortOrder = _get(curQuery, 'defaultSortOrder', false);
|
|
495
495
|
|
|
496
496
|
const sortOrder = _this.foundation.isSortOrderValid(stateSortOrder) ? stateSortOrder : defaultSortOrder;
|
|
497
|
+
const TitleNode = typeof rawTitle !== 'function' && /*#__PURE__*/React.createElement(React.Fragment, {
|
|
498
|
+
key: strings.DEFAULT_KEY_COLUMN_TITLE
|
|
499
|
+
}, rawTitle);
|
|
497
500
|
|
|
498
501
|
if (typeof column.sorter === 'function' || column.sorter === true) {
|
|
502
|
+
// In order to increase the click hot area of sorting, when sorting is required & useFullRender is false,
|
|
503
|
+
// both the title and sorting areas are used as the click hot area for sorting。
|
|
499
504
|
const sorter = /*#__PURE__*/React.createElement(ColumnSorter, {
|
|
500
505
|
key: strings.DEFAULT_KEY_COLUMN_SORTER,
|
|
501
506
|
sortOrder: sortOrder,
|
|
502
|
-
onClick: e => _this.foundation.handleSort(column, e)
|
|
507
|
+
onClick: e => _this.foundation.handleSort(column, e),
|
|
508
|
+
title: TitleNode
|
|
503
509
|
});
|
|
504
510
|
useFullRender && (titleMap.sorter = sorter);
|
|
505
511
|
titleArr.push(sorter);
|
|
512
|
+
} else {
|
|
513
|
+
titleArr.push(TitleNode);
|
|
506
514
|
}
|
|
507
515
|
|
|
508
516
|
const stateFilteredValue = _get(curQuery, 'filteredValue');
|
|
@@ -523,9 +531,7 @@ class Table extends BaseComponent {
|
|
|
523
531
|
titleArr.push(filter);
|
|
524
532
|
}
|
|
525
533
|
|
|
526
|
-
const newTitle = typeof rawTitle === 'function' ? () => rawTitle(titleMap) : titleArr
|
|
527
|
-
key: strings.DEFAULT_KEY_COLUMN_TITLE
|
|
528
|
-
}, rawTitle)) && titleArr;
|
|
534
|
+
const newTitle = typeof rawTitle === 'function' ? () => rawTitle(titleMap) : titleArr;
|
|
529
535
|
column = _Object$assign(_Object$assign({}, column), {
|
|
530
536
|
title: newTitle
|
|
531
537
|
});
|
package/lib/es/tag/group.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface TagGroupProps<T> {
|
|
|
14
14
|
popoverProps?: PopoverProps;
|
|
15
15
|
avatarShape?: AvatarShape;
|
|
16
16
|
mode?: string;
|
|
17
|
+
onTagClose: (tagChildren: React.ReactNode, event: React.MouseEvent<HTMLElement>, tagKey: string | number) => void;
|
|
17
18
|
}
|
|
18
19
|
export default class TagGroup<T> extends PureComponent<TagGroupProps<T>> {
|
|
19
20
|
static defaultProps: {
|
|
@@ -21,6 +22,7 @@ export default class TagGroup<T> extends PureComponent<TagGroupProps<T>> {
|
|
|
21
22
|
className: string;
|
|
22
23
|
size: string;
|
|
23
24
|
avatarShape: string;
|
|
25
|
+
onTagClose: () => any;
|
|
24
26
|
};
|
|
25
27
|
static propTypes: {
|
|
26
28
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
@@ -31,6 +33,7 @@ export default class TagGroup<T> extends PureComponent<TagGroupProps<T>> {
|
|
|
31
33
|
tagList: PropTypes.Requireable<any[]>;
|
|
32
34
|
size: PropTypes.Requireable<string>;
|
|
33
35
|
mode: PropTypes.Requireable<string>;
|
|
36
|
+
onTagClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
34
37
|
showPopover: PropTypes.Requireable<boolean>;
|
|
35
38
|
popoverProps: PropTypes.Requireable<object>;
|
|
36
39
|
avatarShape: PropTypes.Requireable<string>;
|
package/lib/es/tag/group.js
CHANGED
|
@@ -72,10 +72,11 @@ export default class TagGroup extends PureComponent {
|
|
|
72
72
|
tagList,
|
|
73
73
|
size,
|
|
74
74
|
mode,
|
|
75
|
-
avatarShape
|
|
75
|
+
avatarShape,
|
|
76
|
+
onTagClose
|
|
76
77
|
} = this.props;
|
|
77
78
|
|
|
78
|
-
const renderTags = _mapInstanceProperty(tagList).call(tagList,
|
|
79
|
+
const renderTags = _mapInstanceProperty(tagList).call(tagList, tag => {
|
|
79
80
|
if (mode === 'custom') {
|
|
80
81
|
return tag;
|
|
81
82
|
}
|
|
@@ -88,9 +89,24 @@ export default class TagGroup extends PureComponent {
|
|
|
88
89
|
tag.avatarShape = avatarShape;
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
if (!tag.tagKey) {
|
|
93
|
+
if (typeof tag.children === 'string' || typeof tag.children === 'number') {
|
|
94
|
+
tag.tagKey = tag.children;
|
|
95
|
+
} else {
|
|
96
|
+
tag.tagKey = Math.random();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return /*#__PURE__*/React.createElement(Tag, _Object$assign({}, tag, {
|
|
101
|
+
key: tag.tagKey,
|
|
102
|
+
onClose: (tagChildren, e, tagKey) => {
|
|
103
|
+
if (tag.onClose) {
|
|
104
|
+
tag.onClose(tagChildren, e, tagKey);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
onTagClose && onTagClose(tagChildren, e, tagKey);
|
|
108
|
+
}
|
|
109
|
+
}));
|
|
94
110
|
});
|
|
95
111
|
|
|
96
112
|
return renderTags;
|
|
@@ -122,7 +138,8 @@ TagGroup.defaultProps = {
|
|
|
122
138
|
style: {},
|
|
123
139
|
className: '',
|
|
124
140
|
size: tagSize[0],
|
|
125
|
-
avatarShape: 'square'
|
|
141
|
+
avatarShape: 'square',
|
|
142
|
+
onTagClose: () => undefined
|
|
126
143
|
};
|
|
127
144
|
TagGroup.propTypes = {
|
|
128
145
|
children: PropTypes.node,
|
|
@@ -133,6 +150,7 @@ TagGroup.propTypes = {
|
|
|
133
150
|
tagList: PropTypes.array,
|
|
134
151
|
size: PropTypes.oneOf(tagSize),
|
|
135
152
|
mode: PropTypes.string,
|
|
153
|
+
onTagClose: PropTypes.func,
|
|
136
154
|
showPopover: PropTypes.bool,
|
|
137
155
|
popoverProps: PropTypes.object,
|
|
138
156
|
avatarShape: PropTypes.oneOf(avatarShapeSet)
|
package/lib/es/tag/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export default class Tag extends Component<TagProps, TagState> {
|
|
|
10
10
|
static defaultProps: TagProps;
|
|
11
11
|
static propTypes: {
|
|
12
12
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
13
|
+
tagKey: PropTypes.Requireable<PropTypes.Requireable<string> | PropTypes.Requireable<number>>;
|
|
13
14
|
size: PropTypes.Requireable<string>;
|
|
14
15
|
color: PropTypes.Requireable<string>;
|
|
15
16
|
type: PropTypes.Requireable<string>;
|
|
@@ -28,7 +29,7 @@ export default class Tag extends Component<TagProps, TagState> {
|
|
|
28
29
|
visible: boolean;
|
|
29
30
|
};
|
|
30
31
|
setVisible(visible: boolean): void;
|
|
31
|
-
close(e: React.MouseEvent<HTMLElement>, value: React.ReactNode): void;
|
|
32
|
+
close(e: React.MouseEvent<HTMLElement>, value: React.ReactNode, tagKey: string | number): void;
|
|
32
33
|
handleKeyDown(event: any): void;
|
|
33
34
|
renderAvatar(): JSX.Element;
|
|
34
35
|
render(): JSX.Element;
|
package/lib/es/tag/index.js
CHANGED
|
@@ -63,13 +63,13 @@ export default class Tag extends Component {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
close(e, value) {
|
|
66
|
+
close(e, value, tagKey) {
|
|
67
67
|
const {
|
|
68
68
|
onClose
|
|
69
69
|
} = this.props;
|
|
70
70
|
e.stopPropagation();
|
|
71
71
|
e.nativeEvent.stopImmediatePropagation();
|
|
72
|
-
onClose && onClose(value, e); // when user call e.preventDefault() in onClick callback, tag will not hidden
|
|
72
|
+
onClose && onClose(value, e, tagKey); // when user call e.preventDefault() in onClick callback, tag will not hidden
|
|
73
73
|
|
|
74
74
|
if (e.defaultPrevented) {
|
|
75
75
|
return;
|
|
@@ -88,7 +88,7 @@ export default class Tag extends Component {
|
|
|
88
88
|
switch (event.key) {
|
|
89
89
|
case "Backspace":
|
|
90
90
|
case "Delete":
|
|
91
|
-
closable && this.close(event, this.props.children);
|
|
91
|
+
closable && this.close(event, this.props.children, this.props.tagKey);
|
|
92
92
|
handlePrevent(event);
|
|
93
93
|
break;
|
|
94
94
|
|
|
@@ -125,6 +125,7 @@ export default class Tag extends Component {
|
|
|
125
125
|
|
|
126
126
|
const _a = this.props,
|
|
127
127
|
{
|
|
128
|
+
tagKey,
|
|
128
129
|
children,
|
|
129
130
|
size,
|
|
130
131
|
color,
|
|
@@ -138,7 +139,7 @@ export default class Tag extends Component {
|
|
|
138
139
|
avatarShape,
|
|
139
140
|
tabIndex
|
|
140
141
|
} = _a,
|
|
141
|
-
attr = __rest(_a, ["children", "size", "color", "closable", "visible", "onClose", "onClick", "className", "type", "avatarSrc", "avatarShape", "tabIndex"]);
|
|
142
|
+
attr = __rest(_a, ["tagKey", "children", "size", "color", "closable", "visible", "onClose", "onClick", "className", "type", "avatarSrc", "avatarShape", "tabIndex"]);
|
|
142
143
|
|
|
143
144
|
const {
|
|
144
145
|
visible: isVisible
|
|
@@ -171,7 +172,7 @@ export default class Tag extends Component {
|
|
|
171
172
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
172
173
|
React.createElement("div", {
|
|
173
174
|
className: "".concat(prefixCls, "-close"),
|
|
174
|
-
onClick: e => this.close(e, children)
|
|
175
|
+
onClick: e => this.close(e, children, tagKey)
|
|
175
176
|
}, /*#__PURE__*/React.createElement(IconClose, {
|
|
176
177
|
size: "small"
|
|
177
178
|
})) : null;
|
|
@@ -197,6 +198,7 @@ Tag.defaultProps = {
|
|
|
197
198
|
};
|
|
198
199
|
Tag.propTypes = {
|
|
199
200
|
children: PropTypes.node,
|
|
201
|
+
tagKey: PropTypes.oneOf([PropTypes.string, PropTypes.number]),
|
|
200
202
|
size: PropTypes.oneOf(tagSize),
|
|
201
203
|
color: PropTypes.oneOf(tagColors),
|
|
202
204
|
type: PropTypes.oneOf(tagType),
|
|
@@ -5,12 +5,13 @@ export declare type TagSize = 'default' | 'small' | 'large';
|
|
|
5
5
|
export declare type AvatarShape = 'circle' | 'square';
|
|
6
6
|
export interface TagProps {
|
|
7
7
|
children?: React.ReactNode;
|
|
8
|
+
tagKey?: string | number;
|
|
8
9
|
size?: TagSize;
|
|
9
10
|
color?: TagColor;
|
|
10
11
|
type?: TagType;
|
|
11
12
|
closable?: boolean;
|
|
12
13
|
visible?: boolean;
|
|
13
|
-
onClose?: (tagChildren: React.ReactNode, event: React.MouseEvent<HTMLElement
|
|
14
|
+
onClose?: (tagChildren: React.ReactNode, event: React.MouseEvent<HTMLElement>, tagKey: string | number) => void;
|
|
14
15
|
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
15
16
|
style?: React.CSSProperties;
|
|
16
17
|
className?: string;
|
package/lib/es/tree/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import BaseComponent from '../_base/baseComponent';
|
|
|
6
6
|
import Input from '../input/index';
|
|
7
7
|
import TreeNode from './treeNode';
|
|
8
8
|
import '@douyinfe/semi-foundation/lib/es/tree/tree.css';
|
|
9
|
-
import { TreeProps, TreeState, TreeNodeProps, TreeNodeData, FlattenNode, KeyEntity } from './interface';
|
|
9
|
+
import { TreeProps, TreeState, TreeNodeProps, TreeNodeData, FlattenNode, KeyEntity, ScrollData } from './interface';
|
|
10
10
|
export * from './interface';
|
|
11
11
|
export { AutoSizerProps } from './autoSizer';
|
|
12
12
|
declare class Tree extends BaseComponent<TreeProps, TreeState> {
|
|
@@ -102,6 +102,7 @@ declare class Tree extends BaseComponent<TreeProps, TreeState> {
|
|
|
102
102
|
onNodeClick: any;
|
|
103
103
|
onMotionEnd: any;
|
|
104
104
|
context: ContextValue;
|
|
105
|
+
virtualizedListRef: React.RefObject<any>;
|
|
105
106
|
constructor(props: TreeProps);
|
|
106
107
|
/**
|
|
107
108
|
* Process of getDerivedStateFromProps was inspired by rc-tree
|
|
@@ -110,6 +111,7 @@ declare class Tree extends BaseComponent<TreeProps, TreeState> {
|
|
|
110
111
|
static getDerivedStateFromProps(props: TreeProps, prevState: TreeState): Partial<TreeState>;
|
|
111
112
|
get adapter(): TreeAdapter;
|
|
112
113
|
search: (value: string) => void;
|
|
114
|
+
scrollTo: (scrollData: ScrollData) => void;
|
|
113
115
|
renderInput(): JSX.Element;
|
|
114
116
|
renderEmpty: () => JSX.Element;
|
|
115
117
|
onNodeSelect: (e: MouseEvent | KeyboardEvent, treeNode: TreeNodeProps) => void;
|
package/lib/es/tree/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import _isFunction from "lodash/isFunction";
|
|
|
2
2
|
import _get from "lodash/get";
|
|
3
3
|
import _isEqual from "lodash/isEqual";
|
|
4
4
|
import _isEmpty from "lodash/isEmpty";
|
|
5
|
+
import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
|
|
5
6
|
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
6
7
|
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
7
8
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
@@ -40,6 +41,25 @@ class Tree extends BaseComponent {
|
|
|
40
41
|
this.foundation.handleInputChange(value);
|
|
41
42
|
};
|
|
42
43
|
|
|
44
|
+
this.scrollTo = scrollData => {
|
|
45
|
+
var _a;
|
|
46
|
+
|
|
47
|
+
const {
|
|
48
|
+
key,
|
|
49
|
+
align = 'center'
|
|
50
|
+
} = scrollData;
|
|
51
|
+
const {
|
|
52
|
+
flattenNodes
|
|
53
|
+
} = this.state;
|
|
54
|
+
|
|
55
|
+
if (key) {
|
|
56
|
+
const index = flattenNodes === null || flattenNodes === void 0 ? void 0 : _findIndexInstanceProperty(flattenNodes).call(flattenNodes, node => {
|
|
57
|
+
return node.key === key;
|
|
58
|
+
});
|
|
59
|
+
index >= 0 && ((_a = this.virtualizedListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToItem(index, align));
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
43
63
|
this.renderEmpty = () => {
|
|
44
64
|
const {
|
|
45
65
|
emptyContent
|
|
@@ -201,6 +221,7 @@ class Tree extends BaseComponent {
|
|
|
201
221
|
this.optionsRef = /*#__PURE__*/React.createRef();
|
|
202
222
|
this.foundation = new TreeFoundation(this.adapter);
|
|
203
223
|
this.dragNode = null;
|
|
224
|
+
this.virtualizedListRef = /*#__PURE__*/React.createRef();
|
|
204
225
|
}
|
|
205
226
|
/**
|
|
206
227
|
* Process of getDerivedStateFromProps was inspired by rc-tree
|
|
@@ -573,6 +594,7 @@ class Tree extends BaseComponent {
|
|
|
573
594
|
width
|
|
574
595
|
} = _ref4;
|
|
575
596
|
return /*#__PURE__*/React.createElement(VirtualList, {
|
|
597
|
+
ref: this.virtualizedListRef,
|
|
576
598
|
itemCount: flattenNodes.length,
|
|
577
599
|
itemSize: virtualize.itemSize,
|
|
578
600
|
height: height,
|
|
@@ -55,7 +55,10 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
|
|
|
55
55
|
isLeaf: () => boolean;
|
|
56
56
|
isDisabled: () => boolean;
|
|
57
57
|
renderArrow(): JSX.Element;
|
|
58
|
-
renderCheckbox(
|
|
58
|
+
renderCheckbox(options: {
|
|
59
|
+
label: React.ReactNode;
|
|
60
|
+
icon: React.ReactNode;
|
|
61
|
+
}): JSX.Element;
|
|
59
62
|
renderIcon(): any;
|
|
60
63
|
renderEmptyNode(): JSX.Element;
|
|
61
64
|
renderRealLabel: () => any;
|
package/lib/es/tree/treeNode.js
CHANGED
|
@@ -300,7 +300,11 @@ export default class TreeNode extends PureComponent {
|
|
|
300
300
|
});
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
renderCheckbox() {
|
|
303
|
+
renderCheckbox(options) {
|
|
304
|
+
const {
|
|
305
|
+
label,
|
|
306
|
+
icon
|
|
307
|
+
} = options;
|
|
304
308
|
const {
|
|
305
309
|
checked,
|
|
306
310
|
halfChecked,
|
|
@@ -317,7 +321,7 @@ export default class TreeNode extends PureComponent {
|
|
|
317
321
|
indeterminate: halfChecked,
|
|
318
322
|
checked: checked,
|
|
319
323
|
disabled: Boolean(disabled)
|
|
320
|
-
}));
|
|
324
|
+
}, icon, label));
|
|
321
325
|
}
|
|
322
326
|
|
|
323
327
|
renderIcon() {
|
|
@@ -487,6 +491,8 @@ export default class TreeNode extends PureComponent {
|
|
|
487
491
|
const setsize = _get(rest, ['data', 'children', 'length']);
|
|
488
492
|
|
|
489
493
|
const posinset = _isString(rest.pos) ? Number(rest.pos.split('-')[level + 1]) + 1 : 1;
|
|
494
|
+
const label = this.renderRealLabel();
|
|
495
|
+
const icon = this.renderIcon();
|
|
490
496
|
return /*#__PURE__*/React.createElement("li", _Object$assign({
|
|
491
497
|
className: nodeCls,
|
|
492
498
|
role: "treeitem",
|
|
@@ -506,9 +512,12 @@ export default class TreeNode extends PureComponent {
|
|
|
506
512
|
style: style
|
|
507
513
|
}, dragProps), this.renderArrow(), /*#__PURE__*/React.createElement("span", {
|
|
508
514
|
className: labelCls
|
|
509
|
-
}, multiple ? this.renderCheckbox(
|
|
515
|
+
}, multiple ? this.renderCheckbox({
|
|
516
|
+
label,
|
|
517
|
+
icon
|
|
518
|
+
}) : null, !multiple && icon, !multiple && /*#__PURE__*/React.createElement("span", {
|
|
510
519
|
className: "".concat(prefixcls, "-label-text")
|
|
511
|
-
},
|
|
520
|
+
}, label)));
|
|
512
521
|
}
|
|
513
522
|
|
|
514
523
|
}
|
package/locale/interface.ts
CHANGED
package/locale/source/ar.ts
CHANGED
package/locale/source/de.ts
CHANGED
package/locale/source/en_GB.ts
CHANGED
package/locale/source/en_US.ts
CHANGED
package/locale/source/es.ts
CHANGED
package/locale/source/fr.ts
CHANGED
package/locale/source/id_ID.ts
CHANGED
package/locale/source/it.ts
CHANGED
package/locale/source/ja_JP.ts
CHANGED
package/locale/source/ko_KR.ts
CHANGED
package/locale/source/ms_MY.ts
CHANGED
package/locale/source/pt_BR.ts
CHANGED
package/locale/source/ru_RU.ts
CHANGED
package/locale/source/th_TH.ts
CHANGED
package/locale/source/tr_TR.ts
CHANGED
package/locale/source/vi_VN.ts
CHANGED
package/locale/source/zh_CN.ts
CHANGED
package/locale/source/zh_TW.ts
CHANGED
package/modal/Modal.tsx
CHANGED
|
@@ -347,12 +347,6 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
|
|
|
347
347
|
let style = styleFromProps;
|
|
348
348
|
const maskStyle = maskStyleFromProps;
|
|
349
349
|
const renderFooter = 'footer' in this.props ? footer : this.renderFooter();
|
|
350
|
-
if (this.props.centered) {
|
|
351
|
-
style = {
|
|
352
|
-
transform: 'translateY(-50%)',
|
|
353
|
-
top: '50%', ...style,
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
350
|
let wrapperStyle: {
|
|
357
351
|
zIndex?: CSSProperties['zIndex'];
|
|
358
352
|
position?: CSSProperties['position'];
|
package/modal/ModalContent.tsx
CHANGED
|
@@ -318,7 +318,10 @@ export default class ModalContent extends BaseComponent<ModalContentReactProps,
|
|
|
318
318
|
<div
|
|
319
319
|
role="none"
|
|
320
320
|
tabIndex={-1}
|
|
321
|
-
className={
|
|
321
|
+
className={cls({
|
|
322
|
+
[`${cssClasses.DIALOG}-wrap`]:true,
|
|
323
|
+
[`${cssClasses.DIALOG}-wrap-center`]:this.props.centered
|
|
324
|
+
})}
|
|
322
325
|
onClick={maskClosable ? this.onMaskClick : null}
|
|
323
326
|
onMouseUp={maskClosable ? this.onMaskMouseUp : null}
|
|
324
327
|
>
|
|
@@ -287,7 +287,7 @@ describe('modal', () => {
|
|
|
287
287
|
it('centered without motion', () => {
|
|
288
288
|
let com = getModal({ centered: true, visible: true, motion: false });
|
|
289
289
|
let modal = mount(com, { attachTo: document.getElementById('container') });
|
|
290
|
-
expect(modal.find(`div.${BASE_CLASS_PREFIX}-modal`)).
|
|
290
|
+
expect(modal.find(`div.${BASE_CLASS_PREFIX}-modal-wrap`)).toHaveClassName(`${BASE_CLASS_PREFIX}-modal-wrap-center`)
|
|
291
291
|
});
|
|
292
292
|
|
|
293
293
|
it('keepDOM', () => {
|