@douyinfe/semi-ui 2.57.0-beta.0 → 2.57.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/README.md +1 -1
- package/dist/css/semi.css +0 -1
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +86 -81
- 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/form/hoc/withField.js +11 -4
- package/lib/cjs/image/image.js +7 -3
- package/lib/cjs/image/interface.d.ts +2 -0
- package/lib/cjs/input/index.js +3 -3
- package/lib/cjs/input/textarea.js +4 -2
- package/lib/cjs/tooltip/index.js +10 -1
- package/lib/cjs/treeSelect/index.js +44 -39
- package/lib/es/form/hoc/withField.js +11 -4
- package/lib/es/image/image.js +7 -3
- package/lib/es/image/interface.d.ts +2 -0
- package/lib/es/input/index.js +3 -3
- package/lib/es/input/textarea.js +4 -2
- package/lib/es/tooltip/index.js +11 -2
- package/lib/es/treeSelect/index.js +44 -39
- package/package.json +8 -8
package/dist/umd/semi-ui.js
CHANGED
|
@@ -18204,6 +18204,14 @@ class foundation_Tooltip extends foundation {
|
|
|
18204
18204
|
this.setDisplayNone = (displayNone, cb) => {
|
|
18205
18205
|
this._adapter.setDisplayNone(displayNone, cb);
|
|
18206
18206
|
};
|
|
18207
|
+
this.updateStateIfCursorOnTrigger = trigger => {
|
|
18208
|
+
var _a, _b;
|
|
18209
|
+
if ((_a = trigger === null || trigger === void 0 ? void 0 : trigger.matches) === null || _a === void 0 ? void 0 : _a.call(trigger, ":hover")) {
|
|
18210
|
+
const eventNames = this._adapter.getEventName();
|
|
18211
|
+
const triggerEventSet = this.getState("triggerEventSet");
|
|
18212
|
+
(_b = triggerEventSet[eventNames.mouseEnter]) === null || _b === void 0 ? void 0 : _b.call(triggerEventSet);
|
|
18213
|
+
}
|
|
18214
|
+
};
|
|
18207
18215
|
this.onResize = () => {
|
|
18208
18216
|
// this.log('resize');
|
|
18209
18217
|
// rePosition when window resize
|
|
@@ -20631,6 +20639,15 @@ class Tooltip extends BaseComponent {
|
|
|
20631
20639
|
this.mounted = true;
|
|
20632
20640
|
this.getPopupContainer = this.props.getPopupContainer || this.context.getPopupContainer || tooltip_defaultGetContainer;
|
|
20633
20641
|
this.foundation.init();
|
|
20642
|
+
runAfterTicks(() => {
|
|
20643
|
+
let triggerEle = this.triggerEl.current;
|
|
20644
|
+
if (triggerEle) {
|
|
20645
|
+
if (!(triggerEle instanceof HTMLElement)) {
|
|
20646
|
+
triggerEle = (0,external_root_ReactDOM_commonjs2_react_dom_commonjs_react_dom_amd_react_dom_.findDOMNode)(triggerEle);
|
|
20647
|
+
}
|
|
20648
|
+
}
|
|
20649
|
+
this.foundation.updateStateIfCursorOnTrigger(triggerEle);
|
|
20650
|
+
}, 1);
|
|
20634
20651
|
}
|
|
20635
20652
|
componentWillUnmount() {
|
|
20636
20653
|
this.mounted = false;
|
|
@@ -25073,9 +25090,6 @@ class InputFoundation extends foundation {
|
|
|
25073
25090
|
constructor(adapter) {
|
|
25074
25091
|
super(Object.assign(Object.assign({}, InputFoundation.inputDefaultAdapter), adapter));
|
|
25075
25092
|
}
|
|
25076
|
-
init() {
|
|
25077
|
-
this._setInitValue();
|
|
25078
|
-
}
|
|
25079
25093
|
destroy() {
|
|
25080
25094
|
if (this._timer) {
|
|
25081
25095
|
clearTimeout(this._timer);
|
|
@@ -25083,19 +25097,6 @@ class InputFoundation extends foundation {
|
|
|
25083
25097
|
}
|
|
25084
25098
|
}
|
|
25085
25099
|
setDisable() {}
|
|
25086
|
-
_setInitValue() {
|
|
25087
|
-
const {
|
|
25088
|
-
defaultValue,
|
|
25089
|
-
value
|
|
25090
|
-
} = this.getProps();
|
|
25091
|
-
let v = defaultValue;
|
|
25092
|
-
if (this._isControlledComponent()) {
|
|
25093
|
-
v = value;
|
|
25094
|
-
}
|
|
25095
|
-
this._adapter.setValue(v);
|
|
25096
|
-
// this.checkAllowClear(v);
|
|
25097
|
-
}
|
|
25098
|
-
|
|
25099
25100
|
setValue(value) {
|
|
25100
25101
|
this._adapter.setValue(value);
|
|
25101
25102
|
}
|
|
@@ -25480,9 +25481,10 @@ class Input extends BaseComponent {
|
|
|
25480
25481
|
this.handlePreventMouseDown = e => {
|
|
25481
25482
|
this.foundation.handlePreventMouseDown(e);
|
|
25482
25483
|
};
|
|
25484
|
+
const initValue = 'value' in props ? props.value : props.defaultValue;
|
|
25483
25485
|
this.state = {
|
|
25484
|
-
value:
|
|
25485
|
-
cachedValue:
|
|
25486
|
+
value: initValue,
|
|
25487
|
+
cachedValue: props.value,
|
|
25486
25488
|
disabled: false,
|
|
25487
25489
|
props: {},
|
|
25488
25490
|
isFocus: false,
|
|
@@ -25555,7 +25557,6 @@ class Input extends BaseComponent {
|
|
|
25555
25557
|
componentDidMount() {
|
|
25556
25558
|
// autofocus is changed from the original support of input to the support of manually calling the focus method,
|
|
25557
25559
|
// so that preventScroll can still take effect under the setting of autofocus
|
|
25558
|
-
this.foundation.init();
|
|
25559
25560
|
const {
|
|
25560
25561
|
disabled,
|
|
25561
25562
|
autoFocus,
|
|
@@ -64302,21 +64303,7 @@ class TextAreaFoundation extends foundation {
|
|
|
64302
64303
|
}
|
|
64303
64304
|
};
|
|
64304
64305
|
}
|
|
64305
|
-
init() {
|
|
64306
|
-
this.setInitValue();
|
|
64307
|
-
}
|
|
64308
64306
|
destroy() {}
|
|
64309
|
-
setInitValue() {
|
|
64310
|
-
const {
|
|
64311
|
-
defaultValue,
|
|
64312
|
-
value
|
|
64313
|
-
} = this.getProps();
|
|
64314
|
-
let v = defaultValue;
|
|
64315
|
-
if (this._isControlledComponent()) {
|
|
64316
|
-
v = value;
|
|
64317
|
-
}
|
|
64318
|
-
this._adapter.setValue(v);
|
|
64319
|
-
}
|
|
64320
64307
|
handleValueChange(v) {
|
|
64321
64308
|
this._adapter.setValue(v);
|
|
64322
64309
|
}
|
|
@@ -64544,12 +64531,14 @@ class TextArea extends BaseComponent {
|
|
|
64544
64531
|
forwardRef.current = node;
|
|
64545
64532
|
}
|
|
64546
64533
|
};
|
|
64534
|
+
const initValue = 'value' in props ? props.value : props.defaultValue;
|
|
64547
64535
|
this.state = {
|
|
64548
|
-
value:
|
|
64536
|
+
value: initValue,
|
|
64549
64537
|
isFocus: false,
|
|
64550
64538
|
isHover: false,
|
|
64551
64539
|
height: 0,
|
|
64552
|
-
minLength: props.minLength
|
|
64540
|
+
minLength: props.minLength,
|
|
64541
|
+
cachedValue: props.value
|
|
64553
64542
|
};
|
|
64554
64543
|
this.focusing = false;
|
|
64555
64544
|
this.foundation = new TextAreaFoundation(this.adapter);
|
|
@@ -91164,15 +91153,17 @@ class TreeSelect extends BaseComponent {
|
|
|
91164
91153
|
leafOnly,
|
|
91165
91154
|
searchPosition,
|
|
91166
91155
|
triggerRender,
|
|
91167
|
-
borderless
|
|
91156
|
+
borderless,
|
|
91157
|
+
checkRelation
|
|
91168
91158
|
} = _a,
|
|
91169
|
-
rest = treeSelect_rest(_a, ["disabled", "multiple", "filterTreeNode", "validateStatus", "prefix", "suffix", "style", "size", "insetLabel", "className", "placeholder", "showClear", "leafOnly", "searchPosition", "triggerRender", "borderless"]);
|
|
91159
|
+
rest = treeSelect_rest(_a, ["disabled", "multiple", "filterTreeNode", "validateStatus", "prefix", "suffix", "style", "size", "insetLabel", "className", "placeholder", "showClear", "leafOnly", "searchPosition", "triggerRender", "borderless", "checkRelation"]);
|
|
91170
91160
|
const {
|
|
91171
91161
|
inputValue,
|
|
91172
91162
|
selectedKeys,
|
|
91173
91163
|
checkedKeys,
|
|
91174
91164
|
keyEntities,
|
|
91175
|
-
isFocus
|
|
91165
|
+
isFocus,
|
|
91166
|
+
realCheckedKeys
|
|
91176
91167
|
} = this.state;
|
|
91177
91168
|
const filterable = Boolean(filterTreeNode);
|
|
91178
91169
|
const useCustomTrigger = typeof triggerRender === 'function';
|
|
@@ -91200,31 +91191,45 @@ class TreeSelect extends BaseComponent {
|
|
|
91200
91191
|
[`${treeSelect_prefixcls}-with-suffix`]: suffix,
|
|
91201
91192
|
[`${treeSelect_prefixcls}-with-suffix`]: suffix
|
|
91202
91193
|
}, className);
|
|
91203
|
-
|
|
91204
|
-
|
|
91205
|
-
|
|
91206
|
-
|
|
91207
|
-
|
|
91208
|
-
|
|
91209
|
-
|
|
91210
|
-
|
|
91211
|
-
|
|
91212
|
-
|
|
91213
|
-
|
|
91214
|
-
|
|
91215
|
-
|
|
91216
|
-
|
|
91217
|
-
|
|
91218
|
-
|
|
91219
|
-
|
|
91220
|
-
|
|
91221
|
-
|
|
91222
|
-
|
|
91223
|
-
|
|
91224
|
-
|
|
91225
|
-
|
|
91226
|
-
|
|
91227
|
-
}
|
|
91194
|
+
let inner;
|
|
91195
|
+
if (useCustomTrigger) {
|
|
91196
|
+
let triggerRenderKeys = [];
|
|
91197
|
+
if (multiple) {
|
|
91198
|
+
if (checkRelation === 'related') {
|
|
91199
|
+
triggerRenderKeys = normalizeKeyList([...checkedKeys], keyEntities, leafOnly, true);
|
|
91200
|
+
} else if (checkRelation === 'unRelated') {
|
|
91201
|
+
triggerRenderKeys = [...realCheckedKeys];
|
|
91202
|
+
}
|
|
91203
|
+
} else {
|
|
91204
|
+
triggerRenderKeys = selectedKeys;
|
|
91205
|
+
}
|
|
91206
|
+
inner = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(trigger, {
|
|
91207
|
+
inputValue: inputValue,
|
|
91208
|
+
value: triggerRenderKeys.map(key => get_default()(keyEntities, [key, 'data'])),
|
|
91209
|
+
disabled: disabled,
|
|
91210
|
+
placeholder: placeholder,
|
|
91211
|
+
onClear: this.handleClear,
|
|
91212
|
+
componentName: 'TreeSelect',
|
|
91213
|
+
triggerRender: triggerRender,
|
|
91214
|
+
componentProps: Object.assign({}, this.props),
|
|
91215
|
+
onSearch: this.search,
|
|
91216
|
+
onRemove: this.removeTag
|
|
91217
|
+
});
|
|
91218
|
+
} else {
|
|
91219
|
+
inner = [/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
|
|
91220
|
+
key: 'prefix'
|
|
91221
|
+
}, prefix || insetLabel ? this.renderPrefix() : null), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
|
|
91222
|
+
key: 'selection'
|
|
91223
|
+
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
91224
|
+
className: `${treeSelect_prefixcls}-selection`
|
|
91225
|
+
}, this.renderSelectContent())), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
|
|
91226
|
+
key: 'suffix'
|
|
91227
|
+
}, suffix ? this.renderSuffix() : null), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
|
|
91228
|
+
key: 'clearBtn'
|
|
91229
|
+
}, showClear || isTriggerPositionSearch && inputValue ? this.renderClearBtn() : null), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {
|
|
91230
|
+
key: 'arrow'
|
|
91231
|
+
}, this.renderArrow())];
|
|
91232
|
+
}
|
|
91228
91233
|
const tabIndex = disabled ? null : 0;
|
|
91229
91234
|
/**
|
|
91230
91235
|
* Reasons for disabling the a11y eslint rule:
|
|
@@ -91688,7 +91693,6 @@ class TreeSelect extends BaseComponent {
|
|
|
91688
91693
|
};
|
|
91689
91694
|
}
|
|
91690
91695
|
static getDerivedStateFromProps(props, prevState) {
|
|
91691
|
-
var _a;
|
|
91692
91696
|
const {
|
|
91693
91697
|
prevProps,
|
|
91694
91698
|
rePosKey
|
|
@@ -91751,16 +91755,6 @@ class TreeSelect extends BaseComponent {
|
|
|
91751
91755
|
newState.expandedKeys = calcExpandedKeysForValues(normalizeValue(props.defaultValue, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
|
|
91752
91756
|
} else if (!prevProps && props.value) {
|
|
91753
91757
|
newState.expandedKeys = calcExpandedKeysForValues(normalizeValue(props.value, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
|
|
91754
|
-
} else if (!isExpandControlled && needUpdateTreeData && props.value) {
|
|
91755
|
-
// 当 treeData 已经设置具体的值,并且设置了 props.loadData ,则认为 treeData 的更新是因为 loadData 导致的
|
|
91756
|
-
// 如果是因为 loadData 导致 treeData改变, 此时在这里重新计算 key 会导致为未选中的展开项目被收起
|
|
91757
|
-
// 所以此时不需要重新计算 expandedKeys,因为在点击展开按钮时候已经把被展开的项添加到 expandedKeys 中
|
|
91758
|
-
// When treeData has a specific value and props.loadData is set, it is considered that the update of treeData is caused by loadData
|
|
91759
|
-
// If the treeData is changed because of loadData, recalculating the key here will cause the unselected expanded items to be collapsed
|
|
91760
|
-
// 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
|
|
91761
|
-
if (!(prevState.treeData && ((_a = prevState.treeData) === null || _a === void 0 ? void 0 : _a.length) > 0 && props.loadData)) {
|
|
91762
|
-
newState.expandedKeys = calcExpandedKeysForValues(props.value, keyEntities, props.multiple, valueEntities);
|
|
91763
|
-
}
|
|
91764
91758
|
}
|
|
91765
91759
|
if (!newState.expandedKeys) {
|
|
91766
91760
|
delete newState.expandedKeys;
|
|
@@ -98371,6 +98365,7 @@ function withField(Component, opts) {
|
|
|
98371
98365
|
const [touched, setTouched] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)();
|
|
98372
98366
|
const [cursor, setCursor, getCursor] = useStateWithGetter(0);
|
|
98373
98367
|
const [status, setStatus] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(validateStatus); // use props.validateStatus to init
|
|
98368
|
+
const isUnmounted = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);
|
|
98374
98369
|
const rulesRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(rules);
|
|
98375
98370
|
const validateRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(validate);
|
|
98376
98371
|
const validatePromise = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
|
|
@@ -98381,6 +98376,9 @@ function withField(Component, opts) {
|
|
|
98381
98376
|
updater.updateStateTouched(field, isTouched, callOpts);
|
|
98382
98377
|
};
|
|
98383
98378
|
const updateError = (errors, callOpts) => {
|
|
98379
|
+
if (isUnmounted.current) {
|
|
98380
|
+
return;
|
|
98381
|
+
}
|
|
98384
98382
|
if (errors === getError()) {
|
|
98385
98383
|
// When the inspection result is unchanged, no need to update, saving a forceUpdate overhead
|
|
98386
98384
|
// When errors is an array, deepEqual is not used, and it is always treated as a need to update
|
|
@@ -98425,7 +98423,7 @@ function withField(Component, opts) {
|
|
|
98425
98423
|
validator.validate(model, {
|
|
98426
98424
|
first: mergeStopValidateWithError
|
|
98427
98425
|
}, (errors, fields) => {}).then(res => {
|
|
98428
|
-
if (validatePromise.current !== rootPromise) {
|
|
98426
|
+
if (isUnmounted.current || validatePromise.current !== rootPromise) {
|
|
98429
98427
|
return;
|
|
98430
98428
|
}
|
|
98431
98429
|
// validation passed
|
|
@@ -98433,7 +98431,7 @@ function withField(Component, opts) {
|
|
|
98433
98431
|
updateError(undefined, callOpts);
|
|
98434
98432
|
resolve({});
|
|
98435
98433
|
}).catch(err => {
|
|
98436
|
-
if (validatePromise.current !== rootPromise) {
|
|
98434
|
+
if (isUnmounted.current || validatePromise.current !== rootPromise) {
|
|
98437
98435
|
return;
|
|
98438
98436
|
}
|
|
98439
98437
|
let {
|
|
@@ -98479,7 +98477,7 @@ function withField(Component, opts) {
|
|
|
98479
98477
|
} else if (isPromise(maybePromisedErrors)) {
|
|
98480
98478
|
maybePromisedErrors.then(result => {
|
|
98481
98479
|
// If the async validate is outdated (a newer validate occurs), the result should be discarded
|
|
98482
|
-
if (validatePromise.current !== rootPromise) {
|
|
98480
|
+
if (isUnmounted.current || validatePromise.current !== rootPromise) {
|
|
98483
98481
|
return;
|
|
98484
98482
|
}
|
|
98485
98483
|
if (utils_isValid(result)) {
|
|
@@ -98607,11 +98605,14 @@ function withField(Component, opts) {
|
|
|
98607
98605
|
rulesRef.current = rules;
|
|
98608
98606
|
validateRef.current = validate;
|
|
98609
98607
|
}, [rules, validate]);
|
|
98610
|
-
// exec validate once when trigger inlcude 'mount'
|
|
98611
98608
|
useIsomorphicEffect(() => {
|
|
98609
|
+
// exec validate once when trigger include 'mount'
|
|
98612
98610
|
if (validateOnMount) {
|
|
98613
98611
|
fieldValidate(value);
|
|
98614
98612
|
}
|
|
98613
|
+
return () => {
|
|
98614
|
+
isUnmounted.current = true;
|
|
98615
|
+
};
|
|
98615
98616
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98616
98617
|
}, []);
|
|
98617
98618
|
// register when mounted,unregister when unmounted
|
|
@@ -101541,9 +101542,11 @@ class image_Image extends BaseComponent {
|
|
|
101541
101542
|
fallback,
|
|
101542
101543
|
placeholder,
|
|
101543
101544
|
imageID,
|
|
101544
|
-
setDownloadName
|
|
101545
|
+
setDownloadName,
|
|
101546
|
+
imgCls,
|
|
101547
|
+
imgStyle
|
|
101545
101548
|
} = _b,
|
|
101546
|
-
restProps = image_rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName"]);
|
|
101549
|
+
restProps = image_rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName", "imgCls", "imgStyle"]);
|
|
101547
101550
|
const outerStyle = Object.assign({
|
|
101548
101551
|
width,
|
|
101549
101552
|
height
|
|
@@ -101566,9 +101569,11 @@ class image_Image extends BaseComponent {
|
|
|
101566
101569
|
src: this.isInGroup() && this.isLazyLoad() ? undefined : src,
|
|
101567
101570
|
"data-src": src,
|
|
101568
101571
|
alt: alt,
|
|
101572
|
+
style: imgStyle,
|
|
101569
101573
|
className: classnames_default()(`${image_prefixCls}-img`, {
|
|
101570
101574
|
[`${image_prefixCls}-img-preview`]: showPreviewCursor,
|
|
101571
|
-
[`${image_prefixCls}-img-error`]: loadStatus === "error"
|
|
101575
|
+
[`${image_prefixCls}-img-error`]: loadStatus === "error",
|
|
101576
|
+
[imgCls]: Boolean(imgCls)
|
|
101572
101577
|
}),
|
|
101573
101578
|
width: width,
|
|
101574
101579
|
height: height,
|