@douyinfe/semi-ui 2.48.0-alpha.0 → 2.48.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 +99 -140
- 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/avatar/index.d.ts +4 -0
- package/lib/cjs/avatar/index.js +27 -5
- package/lib/cjs/avatar/interface.d.ts +1 -0
- package/lib/cjs/slider/index.js +15 -2
- package/lib/cjs/treeSelect/index.d.ts +1 -1
- package/lib/cjs/treeSelect/index.js +29 -117
- package/lib/es/avatar/index.d.ts +4 -0
- package/lib/es/avatar/index.js +27 -5
- package/lib/es/avatar/interface.d.ts +1 -0
- package/lib/es/slider/index.js +15 -2
- package/lib/es/treeSelect/index.d.ts +1 -1
- package/lib/es/treeSelect/index.js +30 -118
- package/package.json +8 -8
package/dist/umd/semi-ui.js
CHANGED
|
@@ -27299,8 +27299,27 @@ class AvatarFoundation extends foundation {
|
|
|
27299
27299
|
this.handleBlur = () => {
|
|
27300
27300
|
this._adapter.setFocusVisible(false);
|
|
27301
27301
|
};
|
|
27302
|
+
this.changeScale = () => {
|
|
27303
|
+
const {
|
|
27304
|
+
gap
|
|
27305
|
+
} = this.getProps();
|
|
27306
|
+
const node = this._adapter.getAvatarNode();
|
|
27307
|
+
const stringNode = node === null || node === void 0 ? void 0 : node.firstChild;
|
|
27308
|
+
const [nodeWidth, stringNodeWidth] = [(node === null || node === void 0 ? void 0 : node.offsetWidth) || 0, (stringNode === null || stringNode === void 0 ? void 0 : stringNode.offsetWidth) || 0];
|
|
27309
|
+
if (nodeWidth !== 0 && stringNodeWidth !== 0 && gap * 2 < nodeWidth) {
|
|
27310
|
+
const scale = nodeWidth - gap * 2 > stringNodeWidth ? 1 : (nodeWidth - gap * 2) / stringNodeWidth;
|
|
27311
|
+
this._adapter.setScale(scale);
|
|
27312
|
+
}
|
|
27313
|
+
};
|
|
27314
|
+
}
|
|
27315
|
+
init() {
|
|
27316
|
+
const {
|
|
27317
|
+
children
|
|
27318
|
+
} = this.getProps();
|
|
27319
|
+
if (typeof children === "string") {
|
|
27320
|
+
this.changeScale();
|
|
27321
|
+
}
|
|
27302
27322
|
}
|
|
27303
|
-
init() {}
|
|
27304
27323
|
destroy() {}
|
|
27305
27324
|
handleImgLoadError() {
|
|
27306
27325
|
const {
|
|
@@ -27399,8 +27418,12 @@ class Avatar extends BaseComponent {
|
|
|
27399
27418
|
})
|
|
27400
27419
|
};
|
|
27401
27420
|
const finalProps = clickable ? Object.assign(Object.assign({}, props), a11yFocusProps) : props;
|
|
27421
|
+
const stringStyle = {
|
|
27422
|
+
transform: `scale(${this.state.scale})`
|
|
27423
|
+
};
|
|
27402
27424
|
content = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
27403
|
-
className: `${avatar_prefixCls}-content
|
|
27425
|
+
className: `${avatar_prefixCls}-content`,
|
|
27426
|
+
style: stringStyle
|
|
27404
27427
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", Object.assign({}, finalProps, {
|
|
27405
27428
|
"x-semi-prop": "children"
|
|
27406
27429
|
}), children));
|
|
@@ -27410,13 +27433,15 @@ class Avatar extends BaseComponent {
|
|
|
27410
27433
|
this.state = {
|
|
27411
27434
|
isImgExist: true,
|
|
27412
27435
|
hoverContent: '',
|
|
27413
|
-
focusVisible: false
|
|
27436
|
+
focusVisible: false,
|
|
27437
|
+
scale: 1
|
|
27414
27438
|
};
|
|
27415
27439
|
this.onEnter = this.onEnter.bind(this);
|
|
27416
27440
|
this.onLeave = this.onLeave.bind(this);
|
|
27417
27441
|
this.handleError = this.handleError.bind(this);
|
|
27418
27442
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
27419
27443
|
this.getContent = this.getContent.bind(this);
|
|
27444
|
+
this.avatarRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
|
|
27420
27445
|
}
|
|
27421
27446
|
get adapter() {
|
|
27422
27447
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
@@ -27453,6 +27478,15 @@ class Avatar extends BaseComponent {
|
|
|
27453
27478
|
this.setState({
|
|
27454
27479
|
focusVisible
|
|
27455
27480
|
});
|
|
27481
|
+
},
|
|
27482
|
+
setScale: scale => {
|
|
27483
|
+
this.setState({
|
|
27484
|
+
scale
|
|
27485
|
+
});
|
|
27486
|
+
},
|
|
27487
|
+
getAvatarNode: () => {
|
|
27488
|
+
var _a;
|
|
27489
|
+
return (_a = this.avatarRef) === null || _a === void 0 ? void 0 : _a.current;
|
|
27456
27490
|
}
|
|
27457
27491
|
});
|
|
27458
27492
|
}
|
|
@@ -27480,6 +27514,9 @@ class Avatar extends BaseComponent {
|
|
|
27480
27514
|
});
|
|
27481
27515
|
};
|
|
27482
27516
|
}
|
|
27517
|
+
if (typeof this.props.children === "string" && this.props.children !== prevProps.children) {
|
|
27518
|
+
this.foundation.changeScale();
|
|
27519
|
+
}
|
|
27483
27520
|
}
|
|
27484
27521
|
componentWillUnmount() {
|
|
27485
27522
|
this.foundation.destroy();
|
|
@@ -27523,9 +27560,10 @@ class Avatar extends BaseComponent {
|
|
|
27523
27560
|
src,
|
|
27524
27561
|
srcSet,
|
|
27525
27562
|
style,
|
|
27526
|
-
alt
|
|
27563
|
+
alt,
|
|
27564
|
+
gap
|
|
27527
27565
|
} = _a,
|
|
27528
|
-
others = avatar_rest(_a, ["shape", "children", "size", "color", "className", "hoverMask", "onClick", "imgAttr", "src", "srcSet", "style", "alt"]);
|
|
27566
|
+
others = avatar_rest(_a, ["shape", "children", "size", "color", "className", "hoverMask", "onClick", "imgAttr", "src", "srcSet", "style", "alt", "gap"]);
|
|
27529
27567
|
const {
|
|
27530
27568
|
isImgExist,
|
|
27531
27569
|
hoverContent,
|
|
@@ -27549,7 +27587,8 @@ class Avatar extends BaseComponent {
|
|
|
27549
27587
|
onClick: onClick,
|
|
27550
27588
|
onMouseEnter: this.onEnter,
|
|
27551
27589
|
onMouseLeave: this.onLeave,
|
|
27552
|
-
role: 'listitem'
|
|
27590
|
+
role: 'listitem',
|
|
27591
|
+
ref: this.avatarRef
|
|
27553
27592
|
}), this.getContent(), hoverRender);
|
|
27554
27593
|
}
|
|
27555
27594
|
}
|
|
@@ -27557,6 +27596,7 @@ Avatar.defaultProps = {
|
|
|
27557
27596
|
size: 'medium',
|
|
27558
27597
|
color: 'grey',
|
|
27559
27598
|
shape: 'circle',
|
|
27599
|
+
gap: 3,
|
|
27560
27600
|
onClick: function_noop,
|
|
27561
27601
|
onMouseEnter: function_noop,
|
|
27562
27602
|
onMouseLeave: function_noop
|
|
@@ -27569,6 +27609,7 @@ Avatar.propTypes = {
|
|
|
27569
27609
|
hoverMask: (prop_types_default()).node,
|
|
27570
27610
|
className: (prop_types_default()).string,
|
|
27571
27611
|
style: (prop_types_default()).object,
|
|
27612
|
+
gap: (prop_types_default()).number,
|
|
27572
27613
|
imgAttr: (prop_types_default()).object,
|
|
27573
27614
|
src: (prop_types_default()).string,
|
|
27574
27615
|
srcSet: (prop_types_default()).string,
|
|
@@ -76267,6 +76308,7 @@ class Slider extends BaseComponent {
|
|
|
76267
76308
|
});
|
|
76268
76309
|
const handleContents = !range ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(Tooltip, {
|
|
76269
76310
|
content: tipChildren.min,
|
|
76311
|
+
showArrow: this.props.showArrow,
|
|
76270
76312
|
position: "top",
|
|
76271
76313
|
trigger: "custom",
|
|
76272
76314
|
rePosKey: minPercent,
|
|
@@ -76465,7 +76507,7 @@ class Slider extends BaseComponent {
|
|
|
76465
76507
|
[`${slider_prefixCls}-dot-active`]: this.foundation.isMarkActive(Number(mark)) === 'active'
|
|
76466
76508
|
});
|
|
76467
76509
|
const markPercent = (Number(mark) - min) / (max - min);
|
|
76468
|
-
|
|
76510
|
+
const dotDOM =
|
|
76469
76511
|
/*#__PURE__*/
|
|
76470
76512
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
76471
76513
|
external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
@@ -76475,11 +76517,17 @@ class Slider extends BaseComponent {
|
|
|
76475
76517
|
style: {
|
|
76476
76518
|
[stylePos]: `calc(${markPercent * 100}% - 2px)`
|
|
76477
76519
|
}
|
|
76478
|
-
})
|
|
76520
|
+
});
|
|
76521
|
+
return activeResult ? this.props.tooltipOnMark ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(Tooltip, {
|
|
76522
|
+
content: marks[mark]
|
|
76523
|
+
}, dotDOM) : dotDOM : null;
|
|
76479
76524
|
})) : null;
|
|
76480
76525
|
return labelContent;
|
|
76481
76526
|
};
|
|
76482
76527
|
this.renderLabel = () => {
|
|
76528
|
+
if (!this.props.showMarkLabel) {
|
|
76529
|
+
return null;
|
|
76530
|
+
}
|
|
76483
76531
|
const {
|
|
76484
76532
|
min,
|
|
76485
76533
|
max,
|
|
@@ -76808,6 +76856,7 @@ Slider.propTypes = {
|
|
|
76808
76856
|
// allowClear: PropTypes.bool,
|
|
76809
76857
|
defaultValue: prop_types_default().oneOfType([(prop_types_default()).number, (prop_types_default()).array]),
|
|
76810
76858
|
disabled: (prop_types_default()).bool,
|
|
76859
|
+
showMarkLabel: (prop_types_default()).bool,
|
|
76811
76860
|
included: (prop_types_default()).bool,
|
|
76812
76861
|
marks: (prop_types_default()).object,
|
|
76813
76862
|
max: (prop_types_default()).number,
|
|
@@ -76820,7 +76869,9 @@ Slider.propTypes = {
|
|
|
76820
76869
|
onAfterChange: (prop_types_default()).func,
|
|
76821
76870
|
onChange: (prop_types_default()).func,
|
|
76822
76871
|
onMouseUp: (prop_types_default()).func,
|
|
76872
|
+
tooltipOnMark: (prop_types_default()).bool,
|
|
76823
76873
|
tooltipVisible: (prop_types_default()).bool,
|
|
76874
|
+
showArrow: (prop_types_default()).bool,
|
|
76824
76875
|
style: (prop_types_default()).object,
|
|
76825
76876
|
className: (prop_types_default()).string,
|
|
76826
76877
|
showBoundary: (prop_types_default()).bool,
|
|
@@ -76831,10 +76882,13 @@ Slider.propTypes = {
|
|
|
76831
76882
|
Slider.defaultProps = {
|
|
76832
76883
|
// allowClear: false,
|
|
76833
76884
|
disabled: false,
|
|
76885
|
+
showMarkLabel: true,
|
|
76886
|
+
tooltipOnMark: false,
|
|
76834
76887
|
included: true,
|
|
76835
76888
|
max: 100,
|
|
76836
76889
|
min: 0,
|
|
76837
76890
|
range: false,
|
|
76891
|
+
showArrow: true,
|
|
76838
76892
|
step: 1,
|
|
76839
76893
|
tipFormatter: value => value,
|
|
76840
76894
|
vertical: false,
|
|
@@ -85470,7 +85524,7 @@ const parseToDate = function (input) {
|
|
|
85470
85524
|
let dateFnsLocale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : zh_CN;
|
|
85471
85525
|
if (input instanceof Date) {
|
|
85472
85526
|
return input;
|
|
85473
|
-
} else if (typeof input === 'number'
|
|
85527
|
+
} else if (typeof input === 'number') {
|
|
85474
85528
|
return new Date(toNumber_default()(input));
|
|
85475
85529
|
} else if (typeof input === 'string') {
|
|
85476
85530
|
let curDate = new Date();
|
|
@@ -87372,7 +87426,6 @@ class ToastFactory {
|
|
|
87372
87426
|
*/
|
|
87373
87427
|
|
|
87374
87428
|
|
|
87375
|
-
|
|
87376
87429
|
class TreeFoundation extends foundation {
|
|
87377
87430
|
constructor(adapter) {
|
|
87378
87431
|
super(Object.assign({}, adapter));
|
|
@@ -89549,12 +89602,6 @@ class TreeSelectFoundation extends foundation {
|
|
|
89549
89602
|
this.close(e);
|
|
89550
89603
|
});
|
|
89551
89604
|
};
|
|
89552
|
-
this.clearInputValue = () => {
|
|
89553
|
-
const {
|
|
89554
|
-
inputValue
|
|
89555
|
-
} = this.getStates();
|
|
89556
|
-
inputValue && this._adapter.updateInputValue('');
|
|
89557
|
-
};
|
|
89558
89605
|
}
|
|
89559
89606
|
init() {
|
|
89560
89607
|
const {
|
|
@@ -89706,7 +89753,7 @@ class TreeSelectFoundation extends foundation {
|
|
|
89706
89753
|
const isSearching = Boolean(inputValue);
|
|
89707
89754
|
const treeNodeProps = {
|
|
89708
89755
|
eventKey: key,
|
|
89709
|
-
expanded: isSearching ? filteredExpandedKeys.has(key) : expandedKeys.has(key),
|
|
89756
|
+
expanded: isSearching && !this._isExpandControlled() ? filteredExpandedKeys.has(key) : expandedKeys.has(key),
|
|
89710
89757
|
selected: selectedKeys.includes(key),
|
|
89711
89758
|
checked: realChecked,
|
|
89712
89759
|
halfChecked: realHalfChecked,
|
|
@@ -89979,8 +90026,8 @@ class TreeSelectFoundation extends foundation {
|
|
|
89979
90026
|
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
89980
90027
|
const newFlattenNodes = flattenTreeData(treeData, newExpandedKeys, keyMaps);
|
|
89981
90028
|
this._adapter.updateState({
|
|
89982
|
-
expandedKeys: newExpandedKeys,
|
|
89983
|
-
flattenNodes: newFlattenNodes,
|
|
90029
|
+
expandedKeys: isExpandControlled ? expandedKeys : newExpandedKeys,
|
|
90030
|
+
flattenNodes: isExpandControlled ? flattenNodes : newFlattenNodes,
|
|
89984
90031
|
inputValue: '',
|
|
89985
90032
|
motionKeys: new Set([]),
|
|
89986
90033
|
filteredKeys: new Set([]),
|
|
@@ -90029,8 +90076,8 @@ class TreeSelectFoundation extends foundation {
|
|
|
90029
90076
|
const newFilteredExpandedKeys = new Set(expandedOptsKeys);
|
|
90030
90077
|
this._adapter.notifySearch(sugInput, Array.from(newFilteredExpandedKeys));
|
|
90031
90078
|
this._adapter.updateState({
|
|
90032
|
-
expandedKeys: newExpandedKeys,
|
|
90033
|
-
flattenNodes: newFlattenNodes,
|
|
90079
|
+
expandedKeys: this._isExpandControlled() ? expandedKeys : newExpandedKeys,
|
|
90080
|
+
flattenNodes: this._isExpandControlled() ? flattenNodes : newFlattenNodes,
|
|
90034
90081
|
motionKeys: new Set([]),
|
|
90035
90082
|
filteredKeys: new Set(filteredOptsKeys),
|
|
90036
90083
|
filteredExpandedKeys: newFilteredExpandedKeys,
|
|
@@ -90238,7 +90285,7 @@ class TreeSelectFoundation extends foundation {
|
|
|
90238
90285
|
return;
|
|
90239
90286
|
}
|
|
90240
90287
|
const isExpandControlled = this._isExpandControlled();
|
|
90241
|
-
if (isSearching) {
|
|
90288
|
+
if (isSearching && !isExpandControlled) {
|
|
90242
90289
|
this.handleNodeExpandInSearch(e, treeNode);
|
|
90243
90290
|
return;
|
|
90244
90291
|
}
|
|
@@ -91008,27 +91055,13 @@ class TreeSelect extends BaseComponent {
|
|
|
91008
91055
|
searchAutoFocus,
|
|
91009
91056
|
searchPosition
|
|
91010
91057
|
} = this.props;
|
|
91011
|
-
|
|
91012
|
-
|
|
91013
|
-
if (isVisible === false && filterTreeNode) {
|
|
91014
|
-
this.foundation.clearInputValue();
|
|
91058
|
+
if (isVisible === false && Boolean(filterTreeNode)) {
|
|
91059
|
+
this.foundation.clearInput();
|
|
91015
91060
|
}
|
|
91016
91061
|
if (filterTreeNode && searchPosition === treeSelect_constants_strings.SEARCH_POSITION_DROPDOWN && isVisible && searchAutoFocus) {
|
|
91017
91062
|
this.foundation.focusInput(true);
|
|
91018
91063
|
}
|
|
91019
91064
|
};
|
|
91020
|
-
this.afterClose = () => {
|
|
91021
|
-
// flattenNode 的变化将导致弹出层面板中的选项数目变化
|
|
91022
|
-
// 在弹层完全收起之后,再通过 clearInput 重新计算 state 中的 expandedKey, flattenNode
|
|
91023
|
-
// 防止在弹出层未收起时弹层面板中选项数目变化导致视觉上出现弹层闪动问题
|
|
91024
|
-
// Changes to flattenNode will cause the number of options in the popup panel to change
|
|
91025
|
-
// After the pop-up layer is completely closed, recalculate the expandedKey and flattenNode in the state through clearInput.
|
|
91026
|
-
// 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.
|
|
91027
|
-
const {
|
|
91028
|
-
filterTreeNode
|
|
91029
|
-
} = this.props;
|
|
91030
|
-
filterTreeNode && this.foundation.clearInput();
|
|
91031
|
-
};
|
|
91032
91065
|
this.renderTreeNode = (treeNode, ind, style) => {
|
|
91033
91066
|
const {
|
|
91034
91067
|
data,
|
|
@@ -91061,7 +91094,6 @@ class TreeSelect extends BaseComponent {
|
|
|
91061
91094
|
this.renderNodeList = () => {
|
|
91062
91095
|
const {
|
|
91063
91096
|
flattenNodes,
|
|
91064
|
-
cachedFlattenNodes,
|
|
91065
91097
|
motionKeys,
|
|
91066
91098
|
motionType,
|
|
91067
91099
|
filteredKeys
|
|
@@ -91077,7 +91109,7 @@ class TreeSelect extends BaseComponent {
|
|
|
91077
91109
|
if (!virtualize || isEmpty_default()(virtualize)) {
|
|
91078
91110
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(NodeList, {
|
|
91079
91111
|
flattenNodes: flattenNodes,
|
|
91080
|
-
flattenList:
|
|
91112
|
+
flattenList: this._flattenNodes,
|
|
91081
91113
|
motionKeys: motionExpand ? motionKeys : new Set([]),
|
|
91082
91114
|
motionType: motionType,
|
|
91083
91115
|
// When motionKeys is empty, but filteredKeys is not empty (that is, the search hits), this situation should be distinguished from ordinary motionKeys
|
|
@@ -91196,7 +91228,6 @@ class TreeSelect extends BaseComponent {
|
|
|
91196
91228
|
keyEntities: {},
|
|
91197
91229
|
treeData: [],
|
|
91198
91230
|
flattenNodes: [],
|
|
91199
|
-
cachedFlattenNodes: undefined,
|
|
91200
91231
|
selectedKeys: [],
|
|
91201
91232
|
checkedKeys: new Set(),
|
|
91202
91233
|
halfCheckedKeys: new Set(),
|
|
@@ -91226,7 +91257,6 @@ class TreeSelect extends BaseComponent {
|
|
|
91226
91257
|
};
|
|
91227
91258
|
}
|
|
91228
91259
|
static getDerivedStateFromProps(props, prevState) {
|
|
91229
|
-
var _a;
|
|
91230
91260
|
const {
|
|
91231
91261
|
prevProps,
|
|
91232
91262
|
rePosKey
|
|
@@ -91244,8 +91274,6 @@ class TreeSelect extends BaseComponent {
|
|
|
91244
91274
|
};
|
|
91245
91275
|
const needUpdateTreeData = needUpdate('treeData');
|
|
91246
91276
|
const needUpdateExpandedKeys = needUpdate('expandedKeys');
|
|
91247
|
-
const isExpandControlled = ('expandedKeys' in props);
|
|
91248
|
-
const isSearching = Boolean(props.filterTreeNode && prevState.inputValue && prevState.inputValue.length);
|
|
91249
91277
|
// TreeNode
|
|
91250
91278
|
if (needUpdateTreeData) {
|
|
91251
91279
|
treeData = props.treeData;
|
|
@@ -91264,97 +91292,31 @@ class TreeSelect extends BaseComponent {
|
|
|
91264
91292
|
}
|
|
91265
91293
|
}
|
|
91266
91294
|
const expandAllWhenDataChange = needUpdateTreeData && props.expandAll;
|
|
91267
|
-
|
|
91268
|
-
|
|
91269
|
-
|
|
91270
|
-
|
|
91271
|
-
|
|
91272
|
-
|
|
91273
|
-
|
|
91274
|
-
|
|
91275
|
-
|
|
91276
|
-
|
|
91277
|
-
|
|
91278
|
-
|
|
91279
|
-
|
|
91280
|
-
|
|
91281
|
-
|
|
91282
|
-
|
|
91283
|
-
|
|
91284
|
-
|
|
91285
|
-
|
|
91286
|
-
|
|
91287
|
-
|
|
91288
|
-
|
|
91289
|
-
|
|
91290
|
-
|
|
91291
|
-
|
|
91292
|
-
} else if (!isExpandControlled && needUpdateTreeData && props.value) {
|
|
91293
|
-
// 当 treeData 已经设置具体的值,并且设置了 props.loadData ,则认为 treeData 的更新是因为 loadData 导致的
|
|
91294
|
-
// 如果是因为 loadData 导致 treeData改变, 此时在这里重新计算 key 会导致为未选中的展开项目被收起
|
|
91295
|
-
// 所以此时不需要重新计算 expandedKeys,因为在点击展开按钮时候已经把被展开的项添加到 expandedKeys 中
|
|
91296
|
-
// When treeData has a specific value and props.loadData is set, it is considered that the update of treeData is caused by loadData
|
|
91297
|
-
// If the treeData is changed because of loadData, recalculating the key here will cause the unselected expanded items to be collapsed
|
|
91298
|
-
// 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
|
|
91299
|
-
if (!(prevState.treeData && ((_a = prevState.treeData) === null || _a === void 0 ? void 0 : _a.length) > 0 && props.loadData)) {
|
|
91300
|
-
newState.expandedKeys = calcExpandedKeysForValues(props.value, keyEntities, props.multiple, valueEntities);
|
|
91301
|
-
}
|
|
91302
|
-
}
|
|
91303
|
-
if (!newState.expandedKeys) {
|
|
91304
|
-
delete newState.expandedKeys;
|
|
91305
|
-
}
|
|
91306
|
-
if (treeData || newState.expandedKeys) {
|
|
91307
|
-
const flattenNodes = flattenTreeData(treeData || prevState.treeData, newState.expandedKeys || prevState.expandedKeys, keyMaps);
|
|
91308
|
-
newState.flattenNodes = flattenNodes;
|
|
91309
|
-
}
|
|
91310
|
-
} else {
|
|
91311
|
-
let filteredState;
|
|
91312
|
-
// treeData changed while searching
|
|
91313
|
-
if (treeData) {
|
|
91314
|
-
// Get filter data
|
|
91315
|
-
filteredState = filterTreeData({
|
|
91316
|
-
treeData,
|
|
91317
|
-
inputValue: prevState.inputValue,
|
|
91318
|
-
filterTreeNode: props.filterTreeNode,
|
|
91319
|
-
filterProps: props.treeNodeFilterProp,
|
|
91320
|
-
showFilteredOnly: props.showFilteredOnly,
|
|
91321
|
-
keyEntities: newState.keyEntities,
|
|
91322
|
-
prevExpandedKeys: [...prevState.filteredExpandedKeys],
|
|
91323
|
-
keyMaps: keyMaps
|
|
91324
|
-
});
|
|
91325
|
-
newState.flattenNodes = filteredState.flattenNodes;
|
|
91326
|
-
newState.motionKeys = new Set([]);
|
|
91327
|
-
newState.filteredKeys = filteredState.filteredKeys;
|
|
91328
|
-
newState.filteredShownKeys = filteredState.filteredShownKeys;
|
|
91329
|
-
newState.filteredExpandedKeys = filteredState.filteredExpandedKeys;
|
|
91330
|
-
}
|
|
91331
|
-
// expandedKeys changed while searching
|
|
91332
|
-
if (props.expandedKeys) {
|
|
91333
|
-
newState.filteredExpandedKeys = calcExpandedKeys(props.expandedKeys, keyEntities, props.autoExpandParent || !prevProps);
|
|
91334
|
-
if (prevProps && props.motion) {
|
|
91335
|
-
const prevKeys = prevState ? prevState.filteredExpandedKeys : new Set([]);
|
|
91336
|
-
// only show animation when treeData does not change
|
|
91337
|
-
if (!treeData) {
|
|
91338
|
-
const motionResult = calcMotionKeys(prevKeys, newState.filteredExpandedKeys, keyEntities);
|
|
91339
|
-
let {
|
|
91340
|
-
motionKeys
|
|
91341
|
-
} = motionResult;
|
|
91342
|
-
const {
|
|
91343
|
-
motionType
|
|
91344
|
-
} = motionResult;
|
|
91345
|
-
if (props.showFilteredOnly) {
|
|
91346
|
-
motionKeys = motionKeys.filter(key => prevState.filteredShownKeys.has(key));
|
|
91347
|
-
}
|
|
91348
|
-
if (motionType === 'hide') {
|
|
91349
|
-
// cache flatten nodes: expandedKeys changed may not be triggered by interaction
|
|
91350
|
-
newState.cachedFlattenNodes = treeUtil_cloneDeep(prevState.flattenNodes);
|
|
91351
|
-
}
|
|
91352
|
-
newState.motionKeys = new Set(motionKeys);
|
|
91353
|
-
newState.motionType = motionType;
|
|
91354
|
-
}
|
|
91355
|
-
}
|
|
91356
|
-
newState.flattenNodes = flattenTreeData(treeData || prevState.treeData, newState.filteredExpandedKeys || prevState.filteredExpandedKeys, keyMaps, props.showFilteredOnly && prevState.filteredShownKeys);
|
|
91357
|
-
}
|
|
91295
|
+
// expandedKeys
|
|
91296
|
+
if (needUpdateExpandedKeys || prevProps && needUpdate('autoExpandParent')) {
|
|
91297
|
+
newState.expandedKeys = calcExpandedKeys(props.expandedKeys, keyEntities, props.autoExpandParent || !prevProps);
|
|
91298
|
+
// only show animation when treeData does not change
|
|
91299
|
+
if (prevProps && props.motion && !treeData) {
|
|
91300
|
+
const {
|
|
91301
|
+
motionKeys,
|
|
91302
|
+
motionType
|
|
91303
|
+
} = calcMotionKeys(prevState.expandedKeys, newState.expandedKeys, keyEntities);
|
|
91304
|
+
newState.motionKeys = new Set(motionKeys);
|
|
91305
|
+
newState.motionType = motionType;
|
|
91306
|
+
}
|
|
91307
|
+
} else if (!prevProps && (props.defaultExpandAll || props.expandAll) || expandAllWhenDataChange) {
|
|
91308
|
+
newState.expandedKeys = new Set(Object.keys(keyEntities));
|
|
91309
|
+
} else if (!prevProps && props.defaultExpandedKeys) {
|
|
91310
|
+
newState.expandedKeys = calcExpandedKeys(props.defaultExpandedKeys, keyEntities);
|
|
91311
|
+
} else if (!prevProps && props.defaultValue) {
|
|
91312
|
+
newState.expandedKeys = calcExpandedKeysForValues(normalizeValue(props.defaultValue, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
|
|
91313
|
+
} else if (!prevProps && props.value) {
|
|
91314
|
+
newState.expandedKeys = calcExpandedKeysForValues(normalizeValue(props.value, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
|
|
91315
|
+
}
|
|
91316
|
+
// flattenNodes
|
|
91317
|
+
if (treeData || needUpdateExpandedKeys) {
|
|
91318
|
+
const flattenNodes = flattenTreeData(treeData || prevState.treeData, newState.expandedKeys || prevState.expandedKeys, keyMaps);
|
|
91319
|
+
newState.flattenNodes = flattenNodes;
|
|
91358
91320
|
}
|
|
91359
91321
|
// selectedKeys: single mode controlled
|
|
91360
91322
|
const isMultiple = props.multiple;
|
|
@@ -91461,9 +91423,7 @@ class TreeSelect extends BaseComponent {
|
|
|
91461
91423
|
this.props.onSearch && this.props.onSearch(input, filteredExpandedKeys);
|
|
91462
91424
|
},
|
|
91463
91425
|
cacheFlattenNodes: bool => {
|
|
91464
|
-
this.
|
|
91465
|
-
cachedFlattenNodes: bool ? treeUtil_cloneDeep(this.state.flattenNodes) : undefined
|
|
91466
|
-
});
|
|
91426
|
+
this._flattenNodes = bool ? treeUtil_cloneDeep(this.state.flattenNodes) : null;
|
|
91467
91427
|
},
|
|
91468
91428
|
notifyLoad: (newLoadedKeys, data) => {
|
|
91469
91429
|
const {
|
|
@@ -91608,8 +91568,7 @@ class TreeSelect extends BaseComponent {
|
|
|
91608
91568
|
autoAdjustOverflow: autoAdjustOverflow,
|
|
91609
91569
|
mouseLeaveDelay: mouseLeaveDelay,
|
|
91610
91570
|
mouseEnterDelay: mouseEnterDelay,
|
|
91611
|
-
onVisibleChange: this.handlePopoverClose
|
|
91612
|
-
afterClose: this.afterClose
|
|
91571
|
+
onVisibleChange: this.handlePopoverClose
|
|
91613
91572
|
}, selection);
|
|
91614
91573
|
}
|
|
91615
91574
|
}
|