@douyinfe/semi-ui 2.47.0 → 2.48.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/dist/css/semi.css +3 -1
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +152 -47
- 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/lib/cjs/dropdown/dropdownItem.js +2 -1
- package/lib/cjs/form/baseForm.js +2 -2
- package/lib/cjs/select/utils.d.ts +1 -1
- package/lib/cjs/select/utils.js +16 -4
- package/lib/cjs/table/HeadTable.js +2 -4
- package/lib/cjs/treeSelect/index.d.ts +1 -1
- package/lib/cjs/treeSelect/index.js +117 -29
- package/lib/es/dropdown/dropdownItem.js +2 -1
- package/lib/es/form/baseForm.js +2 -2
- package/lib/es/select/utils.d.ts +1 -1
- package/lib/es/select/utils.js +16 -4
- package/lib/es/table/HeadTable.js +2 -4
- package/lib/es/treeSelect/index.d.ts +1 -1
- package/lib/es/treeSelect/index.js +118 -30
- package/package.json +8 -8
|
@@ -46,8 +46,9 @@ class DropdownItem extends _baseComponent.default {
|
|
|
46
46
|
['onClick', 'onMouseEnter', 'onMouseLeave', 'onContextMenu'].forEach(eventName => {
|
|
47
47
|
if (eventName === "onClick") {
|
|
48
48
|
events["onMouseDown"] = e => {
|
|
49
|
+
var _a, _b;
|
|
49
50
|
if (e.button === 0) {
|
|
50
|
-
this.props[eventName](e);
|
|
51
|
+
(_b = (_a = this.props)[eventName]) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
51
52
|
}
|
|
52
53
|
};
|
|
53
54
|
} else {
|
package/lib/cjs/form/baseForm.js
CHANGED
|
@@ -181,7 +181,7 @@ class Form extends _baseComponent.default {
|
|
|
181
181
|
[prefix + '-vertical']: layout === 'vertical',
|
|
182
182
|
[prefix + '-horizontal']: layout === 'horizontal'
|
|
183
183
|
});
|
|
184
|
-
const
|
|
184
|
+
const shouldAppendRow = wrapperCol && labelCol;
|
|
185
185
|
const formContent = /*#__PURE__*/_react.default.createElement("form", Object.assign({
|
|
186
186
|
style: style
|
|
187
187
|
}, rest, {
|
|
@@ -197,7 +197,7 @@ class Form extends _baseComponent.default {
|
|
|
197
197
|
value: this.formApi
|
|
198
198
|
}, /*#__PURE__*/_react.default.createElement(_context.FormStateContext.Provider, {
|
|
199
199
|
value: formState
|
|
200
|
-
},
|
|
200
|
+
}, shouldAppendRow ? withRowForm : formContent)));
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
Form.propTypes = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { OptionProps } from './option';
|
|
3
3
|
import { OptionGroupProps } from './optionGroup';
|
|
4
|
-
declare const generateOption: (child: React.ReactElement, parent: any, index: number) => OptionProps;
|
|
4
|
+
declare const generateOption: (child: React.ReactElement, parent: any, index: number, newKey?: string | number) => OptionProps;
|
|
5
5
|
declare const getOptionsFromGroup: (selectChildren: React.ReactNode) => {
|
|
6
6
|
optionGroups: OptionGroupProps[];
|
|
7
7
|
options: OptionProps[];
|
package/lib/cjs/select/utils.js
CHANGED
|
@@ -15,7 +15,7 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
|
15
15
|
}
|
|
16
16
|
return t;
|
|
17
17
|
};
|
|
18
|
-
const generateOption = (child, parent, index) => {
|
|
18
|
+
const generateOption = (child, parent, index, newKey) => {
|
|
19
19
|
const childProps = child.props;
|
|
20
20
|
if (!child || !childProps) {
|
|
21
21
|
return null;
|
|
@@ -33,7 +33,7 @@ const generateOption = (child, parent, index) => {
|
|
|
33
33
|
// Props are collected from ReactNode, after React.Children.toArray
|
|
34
34
|
// no need to determine whether the key exists in child
|
|
35
35
|
// Even if the user does not explicitly declare it, React will always generate a key.
|
|
36
|
-
option._keyInJsx = child.key;
|
|
36
|
+
option._keyInJsx = newKey || child.key;
|
|
37
37
|
return option;
|
|
38
38
|
};
|
|
39
39
|
exports.generateOption = generateOption;
|
|
@@ -65,10 +65,22 @@ const getOptionsFromGroup = selectChildren => {
|
|
|
65
65
|
children
|
|
66
66
|
} = _a,
|
|
67
67
|
restGroupProps = __rest(_a, ["children"]);
|
|
68
|
+
let originKeys = [];
|
|
69
|
+
if (Array.isArray(children)) {
|
|
70
|
+
// if group has children > 1
|
|
71
|
+
originKeys = children.map(item => item.key);
|
|
72
|
+
} else {
|
|
73
|
+
originKeys.push(children.key);
|
|
74
|
+
}
|
|
68
75
|
children = _react.default.Children.toArray(children);
|
|
69
|
-
const childrenOption = children.map(option => {
|
|
76
|
+
const childrenOption = children.map((option, index) => {
|
|
77
|
+
let newKey = option.key;
|
|
78
|
+
if (originKeys[index] === null) {
|
|
79
|
+
newKey = child.key + '' + option.key; // if option in group and didn't set key, concat parent key to avoid conflict (default generate key just like .0, .1)
|
|
80
|
+
}
|
|
81
|
+
|
|
70
82
|
optionIndex++;
|
|
71
|
-
return generateOption(option, restGroupProps, optionIndex);
|
|
83
|
+
return generateOption(option, restGroupProps, optionIndex, newKey);
|
|
72
84
|
});
|
|
73
85
|
const group = Object.assign(Object.assign({}, child.props), {
|
|
74
86
|
children: childrenOption,
|
|
@@ -37,9 +37,6 @@ class HeadTable extends _react.default.PureComponent {
|
|
|
37
37
|
bodyHasScrollBar,
|
|
38
38
|
sticky
|
|
39
39
|
} = this.props;
|
|
40
|
-
if (!showHeader) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
40
|
const Table = (0, _get2.default)(components, 'header.outer', 'table');
|
|
44
41
|
const x = (0, _get2.default)(scroll, 'x');
|
|
45
42
|
const headStyle = {};
|
|
@@ -60,7 +57,8 @@ class HeadTable extends _react.default.PureComponent {
|
|
|
60
57
|
onDidUpdate: onDidUpdate
|
|
61
58
|
}));
|
|
62
59
|
const headTableCls = (0, _classnames.default)(`${prefixCls}-header`, {
|
|
63
|
-
[`${prefixCls}-header-sticky`]: sticky
|
|
60
|
+
[`${prefixCls}-header-sticky`]: sticky,
|
|
61
|
+
[`${prefixCls}-header-hidden`]: !showHeader
|
|
64
62
|
});
|
|
65
63
|
const stickyTop = (0, _get2.default)(sticky, 'top', 0);
|
|
66
64
|
if (typeof stickyTop === 'number') {
|
|
@@ -190,7 +190,6 @@ declare class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState>
|
|
|
190
190
|
triggerRef: React.RefObject<HTMLDivElement>;
|
|
191
191
|
optionsRef: React.RefObject<any>;
|
|
192
192
|
clickOutsideHandler: any;
|
|
193
|
-
_flattenNodes: TreeState['flattenNodes'];
|
|
194
193
|
onNodeClick: any;
|
|
195
194
|
onNodeDoubleClick: any;
|
|
196
195
|
onMotionEnd: any;
|
|
@@ -247,6 +246,7 @@ declare class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState>
|
|
|
247
246
|
};
|
|
248
247
|
getTreeNodeKey: (treeNode: TreeNodeData) => string;
|
|
249
248
|
handlePopoverClose: (isVisible: any) => void;
|
|
249
|
+
afterClose: () => void;
|
|
250
250
|
renderTreeNode: (treeNode: FlattenNode, ind: number, style: React.CSSProperties) => JSX.Element;
|
|
251
251
|
itemKey: (index: number, data: Record<string, any>) => any;
|
|
252
252
|
renderNodeList: () => JSX.Element;
|
|
@@ -689,13 +689,27 @@ class TreeSelect extends _baseComponent.default {
|
|
|
689
689
|
searchAutoFocus,
|
|
690
690
|
searchPosition
|
|
691
691
|
} = this.props;
|
|
692
|
-
|
|
693
|
-
|
|
692
|
+
// 将 inputValue 清空,如果有选中值的话,选中项能够快速回显
|
|
693
|
+
// Clear the inputValue. If there is a selected value, the selected item can be quickly echoed.
|
|
694
|
+
if (isVisible === false && filterTreeNode) {
|
|
695
|
+
this.foundation.clearInputValue();
|
|
694
696
|
}
|
|
695
697
|
if (filterTreeNode && searchPosition === _constants.strings.SEARCH_POSITION_DROPDOWN && isVisible && searchAutoFocus) {
|
|
696
698
|
this.foundation.focusInput(true);
|
|
697
699
|
}
|
|
698
700
|
};
|
|
701
|
+
this.afterClose = () => {
|
|
702
|
+
// flattenNode 的变化将导致弹出层面板中的选项数目变化
|
|
703
|
+
// 在弹层完全收起之后,再通过 clearInput 重新计算 state 中的 expandedKey, flattenNode
|
|
704
|
+
// 防止在弹出层未收起时弹层面板中选项数目变化导致视觉上出现弹层闪动问题
|
|
705
|
+
// Changes to flattenNode will cause the number of options in the popup panel to change
|
|
706
|
+
// After the pop-up layer is completely closed, recalculate the expandedKey and flattenNode in the state through clearInput.
|
|
707
|
+
// Prevent the pop-up layer from flickering visually due to changes in the number of options in the pop-up panel when the pop-up layer is not collapsed.
|
|
708
|
+
const {
|
|
709
|
+
filterTreeNode
|
|
710
|
+
} = this.props;
|
|
711
|
+
filterTreeNode && this.foundation.clearInput();
|
|
712
|
+
};
|
|
699
713
|
this.renderTreeNode = (treeNode, ind, style) => {
|
|
700
714
|
const {
|
|
701
715
|
data,
|
|
@@ -728,6 +742,7 @@ class TreeSelect extends _baseComponent.default {
|
|
|
728
742
|
this.renderNodeList = () => {
|
|
729
743
|
const {
|
|
730
744
|
flattenNodes,
|
|
745
|
+
cachedFlattenNodes,
|
|
731
746
|
motionKeys,
|
|
732
747
|
motionType,
|
|
733
748
|
filteredKeys
|
|
@@ -743,7 +758,7 @@ class TreeSelect extends _baseComponent.default {
|
|
|
743
758
|
if (!virtualize || (0, _isEmpty2.default)(virtualize)) {
|
|
744
759
|
return /*#__PURE__*/_react.default.createElement(_nodeList.default, {
|
|
745
760
|
flattenNodes: flattenNodes,
|
|
746
|
-
flattenList:
|
|
761
|
+
flattenList: cachedFlattenNodes,
|
|
747
762
|
motionKeys: motionExpand ? motionKeys : new Set([]),
|
|
748
763
|
motionType: motionType,
|
|
749
764
|
// When motionKeys is empty, but filteredKeys is not empty (that is, the search hits), this situation should be distinguished from ordinary motionKeys
|
|
@@ -862,6 +877,7 @@ class TreeSelect extends _baseComponent.default {
|
|
|
862
877
|
keyEntities: {},
|
|
863
878
|
treeData: [],
|
|
864
879
|
flattenNodes: [],
|
|
880
|
+
cachedFlattenNodes: undefined,
|
|
865
881
|
selectedKeys: [],
|
|
866
882
|
checkedKeys: new Set(),
|
|
867
883
|
halfCheckedKeys: new Set(),
|
|
@@ -891,6 +907,7 @@ class TreeSelect extends _baseComponent.default {
|
|
|
891
907
|
};
|
|
892
908
|
}
|
|
893
909
|
static getDerivedStateFromProps(props, prevState) {
|
|
910
|
+
var _a;
|
|
894
911
|
const {
|
|
895
912
|
prevProps,
|
|
896
913
|
rePosKey
|
|
@@ -908,6 +925,8 @@ class TreeSelect extends _baseComponent.default {
|
|
|
908
925
|
};
|
|
909
926
|
const needUpdateTreeData = needUpdate('treeData');
|
|
910
927
|
const needUpdateExpandedKeys = needUpdate('expandedKeys');
|
|
928
|
+
const isExpandControlled = ('expandedKeys' in props);
|
|
929
|
+
const isSearching = Boolean(props.filterTreeNode && prevState.inputValue && prevState.inputValue.length);
|
|
911
930
|
// TreeNode
|
|
912
931
|
if (needUpdateTreeData) {
|
|
913
932
|
treeData = props.treeData;
|
|
@@ -926,31 +945,97 @@ class TreeSelect extends _baseComponent.default {
|
|
|
926
945
|
}
|
|
927
946
|
}
|
|
928
947
|
const expandAllWhenDataChange = needUpdateTreeData && props.expandAll;
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
948
|
+
if (!isSearching) {
|
|
949
|
+
// expandedKeys
|
|
950
|
+
if (needUpdateExpandedKeys || prevProps && needUpdate('autoExpandParent')) {
|
|
951
|
+
newState.expandedKeys = (0, _treeUtil.calcExpandedKeys)(props.expandedKeys, keyEntities, props.autoExpandParent || !prevProps);
|
|
952
|
+
// only show animation when treeData does not change
|
|
953
|
+
if (prevProps && props.motion && !treeData) {
|
|
954
|
+
const {
|
|
955
|
+
motionKeys,
|
|
956
|
+
motionType
|
|
957
|
+
} = (0, _treeUtil.calcMotionKeys)(prevState.expandedKeys, newState.expandedKeys, keyEntities);
|
|
958
|
+
newState.motionKeys = new Set(motionKeys);
|
|
959
|
+
newState.motionType = motionType;
|
|
960
|
+
if (motionType === 'hide') {
|
|
961
|
+
// cache flatten nodes: expandedKeys changed may not be triggered by interaction
|
|
962
|
+
newState.cachedFlattenNodes = (0, _treeUtil2.cloneDeep)(prevState.flattenNodes);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
} else if (!prevProps && (props.defaultExpandAll || props.expandAll) || expandAllWhenDataChange) {
|
|
966
|
+
newState.expandedKeys = new Set(Object.keys(keyEntities));
|
|
967
|
+
} else if (!prevProps && props.defaultExpandedKeys) {
|
|
968
|
+
newState.expandedKeys = (0, _treeUtil.calcExpandedKeys)(props.defaultExpandedKeys, keyEntities);
|
|
969
|
+
} else if (!prevProps && props.defaultValue) {
|
|
970
|
+
newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)((0, _treeUtil.normalizeValue)(props.defaultValue, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
|
|
971
|
+
} else if (!prevProps && props.value) {
|
|
972
|
+
newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)((0, _treeUtil.normalizeValue)(props.value, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
|
|
973
|
+
} else if (!isExpandControlled && needUpdateTreeData && props.value) {
|
|
974
|
+
// 当 treeData 已经设置具体的值,并且设置了 props.loadData ,则认为 treeData 的更新是因为 loadData 导致的
|
|
975
|
+
// 如果是因为 loadData 导致 treeData改变, 此时在这里重新计算 key 会导致为未选中的展开项目被收起
|
|
976
|
+
// 所以此时不需要重新计算 expandedKeys,因为在点击展开按钮时候已经把被展开的项添加到 expandedKeys 中
|
|
977
|
+
// When treeData has a specific value and props.loadData is set, it is considered that the update of treeData is caused by loadData
|
|
978
|
+
// If the treeData is changed because of loadData, recalculating the key here will cause the unselected expanded items to be collapsed
|
|
979
|
+
// So there is no need to recalculate expandedKeys at this time, because the expanded item has been added to expandedKeys when the expand button is clicked
|
|
980
|
+
if (!(prevState.treeData && ((_a = prevState.treeData) === null || _a === void 0 ? void 0 : _a.length) > 0 && props.loadData)) {
|
|
981
|
+
newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)(props.value, keyEntities, props.multiple, valueEntities);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
if (!newState.expandedKeys) {
|
|
985
|
+
delete newState.expandedKeys;
|
|
986
|
+
}
|
|
987
|
+
if (treeData || newState.expandedKeys) {
|
|
988
|
+
const flattenNodes = (0, _treeUtil.flattenTreeData)(treeData || prevState.treeData, newState.expandedKeys || prevState.expandedKeys, keyMaps);
|
|
989
|
+
newState.flattenNodes = flattenNodes;
|
|
990
|
+
}
|
|
991
|
+
} else {
|
|
992
|
+
let filteredState;
|
|
993
|
+
// treeData changed while searching
|
|
994
|
+
if (treeData) {
|
|
995
|
+
// Get filter data
|
|
996
|
+
filteredState = (0, _treeUtil.filterTreeData)({
|
|
997
|
+
treeData,
|
|
998
|
+
inputValue: prevState.inputValue,
|
|
999
|
+
filterTreeNode: props.filterTreeNode,
|
|
1000
|
+
filterProps: props.treeNodeFilterProp,
|
|
1001
|
+
showFilteredOnly: props.showFilteredOnly,
|
|
1002
|
+
keyEntities: newState.keyEntities,
|
|
1003
|
+
prevExpandedKeys: [...prevState.filteredExpandedKeys],
|
|
1004
|
+
keyMaps: keyMaps
|
|
1005
|
+
});
|
|
1006
|
+
newState.flattenNodes = filteredState.flattenNodes;
|
|
1007
|
+
newState.motionKeys = new Set([]);
|
|
1008
|
+
newState.filteredKeys = filteredState.filteredKeys;
|
|
1009
|
+
newState.filteredShownKeys = filteredState.filteredShownKeys;
|
|
1010
|
+
newState.filteredExpandedKeys = filteredState.filteredExpandedKeys;
|
|
1011
|
+
}
|
|
1012
|
+
// expandedKeys changed while searching
|
|
1013
|
+
if (props.expandedKeys) {
|
|
1014
|
+
newState.filteredExpandedKeys = (0, _treeUtil.calcExpandedKeys)(props.expandedKeys, keyEntities, props.autoExpandParent || !prevProps);
|
|
1015
|
+
if (prevProps && props.motion) {
|
|
1016
|
+
const prevKeys = prevState ? prevState.filteredExpandedKeys : new Set([]);
|
|
1017
|
+
// only show animation when treeData does not change
|
|
1018
|
+
if (!treeData) {
|
|
1019
|
+
const motionResult = (0, _treeUtil.calcMotionKeys)(prevKeys, newState.filteredExpandedKeys, keyEntities);
|
|
1020
|
+
let {
|
|
1021
|
+
motionKeys
|
|
1022
|
+
} = motionResult;
|
|
1023
|
+
const {
|
|
1024
|
+
motionType
|
|
1025
|
+
} = motionResult;
|
|
1026
|
+
if (props.showFilteredOnly) {
|
|
1027
|
+
motionKeys = motionKeys.filter(key => prevState.filteredShownKeys.has(key));
|
|
1028
|
+
}
|
|
1029
|
+
if (motionType === 'hide') {
|
|
1030
|
+
// cache flatten nodes: expandedKeys changed may not be triggered by interaction
|
|
1031
|
+
newState.cachedFlattenNodes = (0, _treeUtil2.cloneDeep)(prevState.flattenNodes);
|
|
1032
|
+
}
|
|
1033
|
+
newState.motionKeys = new Set(motionKeys);
|
|
1034
|
+
newState.motionType = motionType;
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
newState.flattenNodes = (0, _treeUtil.flattenTreeData)(treeData || prevState.treeData, newState.filteredExpandedKeys || prevState.filteredExpandedKeys, keyMaps, props.showFilteredOnly && prevState.filteredShownKeys);
|
|
940
1038
|
}
|
|
941
|
-
} else if (!prevProps && (props.defaultExpandAll || props.expandAll) || expandAllWhenDataChange) {
|
|
942
|
-
newState.expandedKeys = new Set(Object.keys(keyEntities));
|
|
943
|
-
} else if (!prevProps && props.defaultExpandedKeys) {
|
|
944
|
-
newState.expandedKeys = (0, _treeUtil.calcExpandedKeys)(props.defaultExpandedKeys, keyEntities);
|
|
945
|
-
} else if (!prevProps && props.defaultValue) {
|
|
946
|
-
newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)((0, _treeUtil.normalizeValue)(props.defaultValue, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
|
|
947
|
-
} else if (!prevProps && props.value) {
|
|
948
|
-
newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)((0, _treeUtil.normalizeValue)(props.value, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
|
|
949
|
-
}
|
|
950
|
-
// flattenNodes
|
|
951
|
-
if (treeData || needUpdateExpandedKeys) {
|
|
952
|
-
const flattenNodes = (0, _treeUtil.flattenTreeData)(treeData || prevState.treeData, newState.expandedKeys || prevState.expandedKeys, keyMaps);
|
|
953
|
-
newState.flattenNodes = flattenNodes;
|
|
954
1039
|
}
|
|
955
1040
|
// selectedKeys: single mode controlled
|
|
956
1041
|
const isMultiple = props.multiple;
|
|
@@ -1057,7 +1142,9 @@ class TreeSelect extends _baseComponent.default {
|
|
|
1057
1142
|
this.props.onSearch && this.props.onSearch(input, filteredExpandedKeys);
|
|
1058
1143
|
},
|
|
1059
1144
|
cacheFlattenNodes: bool => {
|
|
1060
|
-
this.
|
|
1145
|
+
this.setState({
|
|
1146
|
+
cachedFlattenNodes: bool ? (0, _treeUtil2.cloneDeep)(this.state.flattenNodes) : undefined
|
|
1147
|
+
});
|
|
1061
1148
|
},
|
|
1062
1149
|
notifyLoad: (newLoadedKeys, data) => {
|
|
1063
1150
|
const {
|
|
@@ -1202,7 +1289,8 @@ class TreeSelect extends _baseComponent.default {
|
|
|
1202
1289
|
autoAdjustOverflow: autoAdjustOverflow,
|
|
1203
1290
|
mouseLeaveDelay: mouseLeaveDelay,
|
|
1204
1291
|
mouseEnterDelay: mouseEnterDelay,
|
|
1205
|
-
onVisibleChange: this.handlePopoverClose
|
|
1292
|
+
onVisibleChange: this.handlePopoverClose,
|
|
1293
|
+
afterClose: this.afterClose
|
|
1206
1294
|
}, selection);
|
|
1207
1295
|
}
|
|
1208
1296
|
}
|
|
@@ -39,8 +39,9 @@ class DropdownItem extends BaseComponent {
|
|
|
39
39
|
['onClick', 'onMouseEnter', 'onMouseLeave', 'onContextMenu'].forEach(eventName => {
|
|
40
40
|
if (eventName === "onClick") {
|
|
41
41
|
events["onMouseDown"] = e => {
|
|
42
|
+
var _a, _b;
|
|
42
43
|
if (e.button === 0) {
|
|
43
|
-
this.props[eventName](e);
|
|
44
|
+
(_b = (_a = this.props)[eventName]) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
44
45
|
}
|
|
45
46
|
};
|
|
46
47
|
} else {
|
package/lib/es/form/baseForm.js
CHANGED
|
@@ -174,7 +174,7 @@ class Form extends BaseComponent {
|
|
|
174
174
|
[prefix + '-vertical']: layout === 'vertical',
|
|
175
175
|
[prefix + '-horizontal']: layout === 'horizontal'
|
|
176
176
|
});
|
|
177
|
-
const
|
|
177
|
+
const shouldAppendRow = wrapperCol && labelCol;
|
|
178
178
|
const formContent = /*#__PURE__*/React.createElement("form", Object.assign({
|
|
179
179
|
style: style
|
|
180
180
|
}, rest, {
|
|
@@ -190,7 +190,7 @@ class Form extends BaseComponent {
|
|
|
190
190
|
value: this.formApi
|
|
191
191
|
}, /*#__PURE__*/React.createElement(FormStateContext.Provider, {
|
|
192
192
|
value: formState
|
|
193
|
-
},
|
|
193
|
+
}, shouldAppendRow ? withRowForm : formContent)));
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
Form.propTypes = {
|
package/lib/es/select/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { OptionProps } from './option';
|
|
3
3
|
import { OptionGroupProps } from './optionGroup';
|
|
4
|
-
declare const generateOption: (child: React.ReactElement, parent: any, index: number) => OptionProps;
|
|
4
|
+
declare const generateOption: (child: React.ReactElement, parent: any, index: number, newKey?: string | number) => OptionProps;
|
|
5
5
|
declare const getOptionsFromGroup: (selectChildren: React.ReactNode) => {
|
|
6
6
|
optionGroups: OptionGroupProps[];
|
|
7
7
|
options: OptionProps[];
|
package/lib/es/select/utils.js
CHANGED
|
@@ -8,7 +8,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
8
8
|
};
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import warning from '@douyinfe/semi-foundation/lib/es/utils/warning';
|
|
11
|
-
const generateOption = (child, parent, index) => {
|
|
11
|
+
const generateOption = (child, parent, index, newKey) => {
|
|
12
12
|
const childProps = child.props;
|
|
13
13
|
if (!child || !childProps) {
|
|
14
14
|
return null;
|
|
@@ -26,7 +26,7 @@ const generateOption = (child, parent, index) => {
|
|
|
26
26
|
// Props are collected from ReactNode, after React.Children.toArray
|
|
27
27
|
// no need to determine whether the key exists in child
|
|
28
28
|
// Even if the user does not explicitly declare it, React will always generate a key.
|
|
29
|
-
option._keyInJsx = child.key;
|
|
29
|
+
option._keyInJsx = newKey || child.key;
|
|
30
30
|
return option;
|
|
31
31
|
};
|
|
32
32
|
const getOptionsFromGroup = selectChildren => {
|
|
@@ -57,10 +57,22 @@ const getOptionsFromGroup = selectChildren => {
|
|
|
57
57
|
children
|
|
58
58
|
} = _a,
|
|
59
59
|
restGroupProps = __rest(_a, ["children"]);
|
|
60
|
+
let originKeys = [];
|
|
61
|
+
if (Array.isArray(children)) {
|
|
62
|
+
// if group has children > 1
|
|
63
|
+
originKeys = children.map(item => item.key);
|
|
64
|
+
} else {
|
|
65
|
+
originKeys.push(children.key);
|
|
66
|
+
}
|
|
60
67
|
children = React.Children.toArray(children);
|
|
61
|
-
const childrenOption = children.map(option => {
|
|
68
|
+
const childrenOption = children.map((option, index) => {
|
|
69
|
+
let newKey = option.key;
|
|
70
|
+
if (originKeys[index] === null) {
|
|
71
|
+
newKey = child.key + '' + option.key; // if option in group and didn't set key, concat parent key to avoid conflict (default generate key just like .0, .1)
|
|
72
|
+
}
|
|
73
|
+
|
|
62
74
|
optionIndex++;
|
|
63
|
-
return generateOption(option, restGroupProps, optionIndex);
|
|
75
|
+
return generateOption(option, restGroupProps, optionIndex, newKey);
|
|
64
76
|
});
|
|
65
77
|
const group = Object.assign(Object.assign({}, child.props), {
|
|
66
78
|
children: childrenOption,
|
|
@@ -30,9 +30,6 @@ class HeadTable extends React.PureComponent {
|
|
|
30
30
|
bodyHasScrollBar,
|
|
31
31
|
sticky
|
|
32
32
|
} = this.props;
|
|
33
|
-
if (!showHeader) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
33
|
const Table = _get(components, 'header.outer', 'table');
|
|
37
34
|
const x = _get(scroll, 'x');
|
|
38
35
|
const headStyle = {};
|
|
@@ -53,7 +50,8 @@ class HeadTable extends React.PureComponent {
|
|
|
53
50
|
onDidUpdate: onDidUpdate
|
|
54
51
|
}));
|
|
55
52
|
const headTableCls = classnames(`${prefixCls}-header`, {
|
|
56
|
-
[`${prefixCls}-header-sticky`]: sticky
|
|
53
|
+
[`${prefixCls}-header-sticky`]: sticky,
|
|
54
|
+
[`${prefixCls}-header-hidden`]: !showHeader
|
|
57
55
|
});
|
|
58
56
|
const stickyTop = _get(sticky, 'top', 0);
|
|
59
57
|
if (typeof stickyTop === 'number') {
|
|
@@ -190,7 +190,6 @@ declare class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState>
|
|
|
190
190
|
triggerRef: React.RefObject<HTMLDivElement>;
|
|
191
191
|
optionsRef: React.RefObject<any>;
|
|
192
192
|
clickOutsideHandler: any;
|
|
193
|
-
_flattenNodes: TreeState['flattenNodes'];
|
|
194
193
|
onNodeClick: any;
|
|
195
194
|
onNodeDoubleClick: any;
|
|
196
195
|
onMotionEnd: any;
|
|
@@ -247,6 +246,7 @@ declare class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState>
|
|
|
247
246
|
};
|
|
248
247
|
getTreeNodeKey: (treeNode: TreeNodeData) => string;
|
|
249
248
|
handlePopoverClose: (isVisible: any) => void;
|
|
249
|
+
afterClose: () => void;
|
|
250
250
|
renderTreeNode: (treeNode: FlattenNode, ind: number, style: React.CSSProperties) => JSX.Element;
|
|
251
251
|
itemKey: (index: number, data: Record<string, any>) => any;
|
|
252
252
|
renderNodeList: () => JSX.Element;
|