@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
|
@@ -117,6 +117,7 @@ function withField(Component, opts) {
|
|
|
117
117
|
const [touched, setTouched] = (0, _react.useState)();
|
|
118
118
|
const [cursor, setCursor, getCursor] = (0, _index.useStateWithGetter)(0);
|
|
119
119
|
const [status, setStatus] = (0, _react.useState)(validateStatus); // use props.validateStatus to init
|
|
120
|
+
const isUnmounted = (0, _react.useRef)(false);
|
|
120
121
|
const rulesRef = (0, _react.useRef)(rules);
|
|
121
122
|
const validateRef = (0, _react.useRef)(validate);
|
|
122
123
|
const validatePromise = (0, _react.useRef)(null);
|
|
@@ -127,6 +128,9 @@ function withField(Component, opts) {
|
|
|
127
128
|
updater.updateStateTouched(field, isTouched, callOpts);
|
|
128
129
|
};
|
|
129
130
|
const updateError = (errors, callOpts) => {
|
|
131
|
+
if (isUnmounted.current) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
130
134
|
if (errors === getError()) {
|
|
131
135
|
// When the inspection result is unchanged, no need to update, saving a forceUpdate overhead
|
|
132
136
|
// When errors is an array, deepEqual is not used, and it is always treated as a need to update
|
|
@@ -171,7 +175,7 @@ function withField(Component, opts) {
|
|
|
171
175
|
validator.validate(model, {
|
|
172
176
|
first: mergeStopValidateWithError
|
|
173
177
|
}, (errors, fields) => {}).then(res => {
|
|
174
|
-
if (validatePromise.current !== rootPromise) {
|
|
178
|
+
if (isUnmounted.current || validatePromise.current !== rootPromise) {
|
|
175
179
|
return;
|
|
176
180
|
}
|
|
177
181
|
// validation passed
|
|
@@ -179,7 +183,7 @@ function withField(Component, opts) {
|
|
|
179
183
|
updateError(undefined, callOpts);
|
|
180
184
|
resolve({});
|
|
181
185
|
}).catch(err => {
|
|
182
|
-
if (validatePromise.current !== rootPromise) {
|
|
186
|
+
if (isUnmounted.current || validatePromise.current !== rootPromise) {
|
|
183
187
|
return;
|
|
184
188
|
}
|
|
185
189
|
let {
|
|
@@ -225,7 +229,7 @@ function withField(Component, opts) {
|
|
|
225
229
|
} else if ((0, _isPromise.default)(maybePromisedErrors)) {
|
|
226
230
|
maybePromisedErrors.then(result => {
|
|
227
231
|
// If the async validate is outdated (a newer validate occurs), the result should be discarded
|
|
228
|
-
if (validatePromise.current !== rootPromise) {
|
|
232
|
+
if (isUnmounted.current || validatePromise.current !== rootPromise) {
|
|
229
233
|
return;
|
|
230
234
|
}
|
|
231
235
|
if ((0, _utils.isValid)(result)) {
|
|
@@ -353,11 +357,14 @@ function withField(Component, opts) {
|
|
|
353
357
|
rulesRef.current = rules;
|
|
354
358
|
validateRef.current = validate;
|
|
355
359
|
}, [rules, validate]);
|
|
356
|
-
// exec validate once when trigger inlcude 'mount'
|
|
357
360
|
useIsomorphicEffect(() => {
|
|
361
|
+
// exec validate once when trigger include 'mount'
|
|
358
362
|
if (validateOnMount) {
|
|
359
363
|
fieldValidate(value);
|
|
360
364
|
}
|
|
365
|
+
return () => {
|
|
366
|
+
isUnmounted.current = true;
|
|
367
|
+
};
|
|
361
368
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
362
369
|
}, []);
|
|
363
370
|
// register when mounted,unregister when unmounted
|
package/lib/cjs/image/image.js
CHANGED
|
@@ -169,9 +169,11 @@ class Image extends _baseComponent.default {
|
|
|
169
169
|
fallback,
|
|
170
170
|
placeholder,
|
|
171
171
|
imageID,
|
|
172
|
-
setDownloadName
|
|
172
|
+
setDownloadName,
|
|
173
|
+
imgCls,
|
|
174
|
+
imgStyle
|
|
173
175
|
} = _b,
|
|
174
|
-
restProps = __rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName"]);
|
|
176
|
+
restProps = __rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName", "imgCls", "imgStyle"]);
|
|
175
177
|
const outerStyle = Object.assign({
|
|
176
178
|
width,
|
|
177
179
|
height
|
|
@@ -194,9 +196,11 @@ class Image extends _baseComponent.default {
|
|
|
194
196
|
src: this.isInGroup() && this.isLazyLoad() ? undefined : src,
|
|
195
197
|
"data-src": src,
|
|
196
198
|
alt: alt,
|
|
199
|
+
style: imgStyle,
|
|
197
200
|
className: (0, _classnames.default)(`${prefixCls}-img`, {
|
|
198
201
|
[`${prefixCls}-img-preview`]: showPreviewCursor,
|
|
199
|
-
[`${prefixCls}-img-error`]: loadStatus === "error"
|
|
202
|
+
[`${prefixCls}-img-error`]: loadStatus === "error",
|
|
203
|
+
[imgCls]: Boolean(imgCls)
|
|
200
204
|
}),
|
|
201
205
|
width: width,
|
|
202
206
|
height: height,
|
|
@@ -23,6 +23,8 @@ export interface ImageProps extends BaseProps {
|
|
|
23
23
|
children?: ReactNode;
|
|
24
24
|
imageID?: number;
|
|
25
25
|
setDownloadName?: (src: string) => string;
|
|
26
|
+
imgStyle?: React.CSSProperties;
|
|
27
|
+
imgCls?: string;
|
|
26
28
|
}
|
|
27
29
|
export interface PreviewProps extends BaseProps {
|
|
28
30
|
visible?: boolean;
|
package/lib/cjs/input/index.js
CHANGED
|
@@ -70,9 +70,10 @@ class Input extends _baseComponent.default {
|
|
|
70
70
|
this.handlePreventMouseDown = e => {
|
|
71
71
|
this.foundation.handlePreventMouseDown(e);
|
|
72
72
|
};
|
|
73
|
+
const initValue = 'value' in props ? props.value : props.defaultValue;
|
|
73
74
|
this.state = {
|
|
74
|
-
value:
|
|
75
|
-
cachedValue:
|
|
75
|
+
value: initValue,
|
|
76
|
+
cachedValue: props.value,
|
|
76
77
|
disabled: false,
|
|
77
78
|
props: {},
|
|
78
79
|
isFocus: false,
|
|
@@ -145,7 +146,6 @@ class Input extends _baseComponent.default {
|
|
|
145
146
|
componentDidMount() {
|
|
146
147
|
// autofocus is changed from the original support of input to the support of manually calling the focus method,
|
|
147
148
|
// so that preventScroll can still take effect under the setting of autofocus
|
|
148
|
-
this.foundation.init();
|
|
149
149
|
const {
|
|
150
150
|
disabled,
|
|
151
151
|
autoFocus,
|
|
@@ -46,12 +46,14 @@ class TextArea extends _baseComponent.default {
|
|
|
46
46
|
forwardRef.current = node;
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
const initValue = 'value' in props ? props.value : props.defaultValue;
|
|
49
50
|
this.state = {
|
|
50
|
-
value:
|
|
51
|
+
value: initValue,
|
|
51
52
|
isFocus: false,
|
|
52
53
|
isHover: false,
|
|
53
54
|
height: 0,
|
|
54
|
-
minLength: props.minLength
|
|
55
|
+
minLength: props.minLength,
|
|
56
|
+
cachedValue: props.value
|
|
55
57
|
};
|
|
56
58
|
this.focusing = false;
|
|
57
59
|
this.foundation = new _textareaFoundation.default(this.adapter);
|
package/lib/cjs/tooltip/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
|
13
13
|
var _noop2 = _interopRequireDefault(require("lodash/noop"));
|
|
14
14
|
var _throttle2 = _interopRequireDefault(require("lodash/throttle"));
|
|
15
15
|
var _react = _interopRequireWildcard(require("react"));
|
|
16
|
-
var _reactDom =
|
|
16
|
+
var _reactDom = _interopRequireWildcard(require("react-dom"));
|
|
17
17
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
18
18
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
19
|
var _constants = require("@douyinfe/semi-foundation/lib/cjs/base/constants");
|
|
@@ -545,6 +545,15 @@ class Tooltip extends _baseComponent.default {
|
|
|
545
545
|
this.mounted = true;
|
|
546
546
|
this.getPopupContainer = this.props.getPopupContainer || this.context.getPopupContainer || defaultGetContainer;
|
|
547
547
|
this.foundation.init();
|
|
548
|
+
(0, _utils.runAfterTicks)(() => {
|
|
549
|
+
let triggerEle = this.triggerEl.current;
|
|
550
|
+
if (triggerEle) {
|
|
551
|
+
if (!(triggerEle instanceof HTMLElement)) {
|
|
552
|
+
triggerEle = (0, _reactDom.findDOMNode)(triggerEle);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
this.foundation.updateStateIfCursorOnTrigger(triggerEle);
|
|
556
|
+
}, 1);
|
|
548
557
|
}
|
|
549
558
|
componentWillUnmount() {
|
|
550
559
|
this.mounted = false;
|
|
@@ -367,15 +367,17 @@ class TreeSelect extends _baseComponent.default {
|
|
|
367
367
|
leafOnly,
|
|
368
368
|
searchPosition,
|
|
369
369
|
triggerRender,
|
|
370
|
-
borderless
|
|
370
|
+
borderless,
|
|
371
|
+
checkRelation
|
|
371
372
|
} = _a,
|
|
372
|
-
rest = __rest(_a, ["disabled", "multiple", "filterTreeNode", "validateStatus", "prefix", "suffix", "style", "size", "insetLabel", "className", "placeholder", "showClear", "leafOnly", "searchPosition", "triggerRender", "borderless"]);
|
|
373
|
+
rest = __rest(_a, ["disabled", "multiple", "filterTreeNode", "validateStatus", "prefix", "suffix", "style", "size", "insetLabel", "className", "placeholder", "showClear", "leafOnly", "searchPosition", "triggerRender", "borderless", "checkRelation"]);
|
|
373
374
|
const {
|
|
374
375
|
inputValue,
|
|
375
376
|
selectedKeys,
|
|
376
377
|
checkedKeys,
|
|
377
378
|
keyEntities,
|
|
378
|
-
isFocus
|
|
379
|
+
isFocus,
|
|
380
|
+
realCheckedKeys
|
|
379
381
|
} = this.state;
|
|
380
382
|
const filterable = Boolean(filterTreeNode);
|
|
381
383
|
const useCustomTrigger = typeof triggerRender === 'function';
|
|
@@ -403,31 +405,45 @@ class TreeSelect extends _baseComponent.default {
|
|
|
403
405
|
[`${prefixcls}-with-suffix`]: suffix,
|
|
404
406
|
[`${prefixcls}-with-suffix`]: suffix
|
|
405
407
|
}, className);
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
408
|
+
let inner;
|
|
409
|
+
if (useCustomTrigger) {
|
|
410
|
+
let triggerRenderKeys = [];
|
|
411
|
+
if (multiple) {
|
|
412
|
+
if (checkRelation === 'related') {
|
|
413
|
+
triggerRenderKeys = (0, _treeUtil.normalizeKeyList)([...checkedKeys], keyEntities, leafOnly, true);
|
|
414
|
+
} else if (checkRelation === 'unRelated') {
|
|
415
|
+
triggerRenderKeys = [...realCheckedKeys];
|
|
416
|
+
}
|
|
417
|
+
} else {
|
|
418
|
+
triggerRenderKeys = selectedKeys;
|
|
419
|
+
}
|
|
420
|
+
inner = /*#__PURE__*/_react.default.createElement(_trigger.default, {
|
|
421
|
+
inputValue: inputValue,
|
|
422
|
+
value: triggerRenderKeys.map(key => (0, _get2.default)(keyEntities, [key, 'data'])),
|
|
423
|
+
disabled: disabled,
|
|
424
|
+
placeholder: placeholder,
|
|
425
|
+
onClear: this.handleClear,
|
|
426
|
+
componentName: 'TreeSelect',
|
|
427
|
+
triggerRender: triggerRender,
|
|
428
|
+
componentProps: Object.assign({}, this.props),
|
|
429
|
+
onSearch: this.search,
|
|
430
|
+
onRemove: this.removeTag
|
|
431
|
+
});
|
|
432
|
+
} else {
|
|
433
|
+
inner = [/*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
434
|
+
key: 'prefix'
|
|
435
|
+
}, prefix || insetLabel ? this.renderPrefix() : null), /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
436
|
+
key: 'selection'
|
|
437
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
438
|
+
className: `${prefixcls}-selection`
|
|
439
|
+
}, this.renderSelectContent())), /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
440
|
+
key: 'suffix'
|
|
441
|
+
}, suffix ? this.renderSuffix() : null), /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
442
|
+
key: 'clearBtn'
|
|
443
|
+
}, showClear || isTriggerPositionSearch && inputValue ? this.renderClearBtn() : null), /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
444
|
+
key: 'arrow'
|
|
445
|
+
}, this.renderArrow())];
|
|
446
|
+
}
|
|
431
447
|
const tabIndex = disabled ? null : 0;
|
|
432
448
|
/**
|
|
433
449
|
* Reasons for disabling the a11y eslint rule:
|
|
@@ -891,7 +907,6 @@ class TreeSelect extends _baseComponent.default {
|
|
|
891
907
|
};
|
|
892
908
|
}
|
|
893
909
|
static getDerivedStateFromProps(props, prevState) {
|
|
894
|
-
var _a;
|
|
895
910
|
const {
|
|
896
911
|
prevProps,
|
|
897
912
|
rePosKey
|
|
@@ -954,16 +969,6 @@ class TreeSelect extends _baseComponent.default {
|
|
|
954
969
|
newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)((0, _treeUtil.normalizeValue)(props.defaultValue, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
|
|
955
970
|
} else if (!prevProps && props.value) {
|
|
956
971
|
newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)((0, _treeUtil.normalizeValue)(props.value, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
|
|
957
|
-
} else if (!isExpandControlled && needUpdateTreeData && props.value) {
|
|
958
|
-
// 当 treeData 已经设置具体的值,并且设置了 props.loadData ,则认为 treeData 的更新是因为 loadData 导致的
|
|
959
|
-
// 如果是因为 loadData 导致 treeData改变, 此时在这里重新计算 key 会导致为未选中的展开项目被收起
|
|
960
|
-
// 所以此时不需要重新计算 expandedKeys,因为在点击展开按钮时候已经把被展开的项添加到 expandedKeys 中
|
|
961
|
-
// When treeData has a specific value and props.loadData is set, it is considered that the update of treeData is caused by loadData
|
|
962
|
-
// If the treeData is changed because of loadData, recalculating the key here will cause the unselected expanded items to be collapsed
|
|
963
|
-
// 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
|
|
964
|
-
if (!(prevState.treeData && ((_a = prevState.treeData) === null || _a === void 0 ? void 0 : _a.length) > 0 && props.loadData)) {
|
|
965
|
-
newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)(props.value, keyEntities, props.multiple, valueEntities);
|
|
966
|
-
}
|
|
967
972
|
}
|
|
968
973
|
if (!newState.expandedKeys) {
|
|
969
974
|
delete newState.expandedKeys;
|
|
@@ -107,6 +107,7 @@ function withField(Component, opts) {
|
|
|
107
107
|
const [touched, setTouched] = useState();
|
|
108
108
|
const [cursor, setCursor, getCursor] = useStateWithGetter(0);
|
|
109
109
|
const [status, setStatus] = useState(validateStatus); // use props.validateStatus to init
|
|
110
|
+
const isUnmounted = useRef(false);
|
|
110
111
|
const rulesRef = useRef(rules);
|
|
111
112
|
const validateRef = useRef(validate);
|
|
112
113
|
const validatePromise = useRef(null);
|
|
@@ -117,6 +118,9 @@ function withField(Component, opts) {
|
|
|
117
118
|
updater.updateStateTouched(field, isTouched, callOpts);
|
|
118
119
|
};
|
|
119
120
|
const updateError = (errors, callOpts) => {
|
|
121
|
+
if (isUnmounted.current) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
120
124
|
if (errors === getError()) {
|
|
121
125
|
// When the inspection result is unchanged, no need to update, saving a forceUpdate overhead
|
|
122
126
|
// When errors is an array, deepEqual is not used, and it is always treated as a need to update
|
|
@@ -161,7 +165,7 @@ function withField(Component, opts) {
|
|
|
161
165
|
validator.validate(model, {
|
|
162
166
|
first: mergeStopValidateWithError
|
|
163
167
|
}, (errors, fields) => {}).then(res => {
|
|
164
|
-
if (validatePromise.current !== rootPromise) {
|
|
168
|
+
if (isUnmounted.current || validatePromise.current !== rootPromise) {
|
|
165
169
|
return;
|
|
166
170
|
}
|
|
167
171
|
// validation passed
|
|
@@ -169,7 +173,7 @@ function withField(Component, opts) {
|
|
|
169
173
|
updateError(undefined, callOpts);
|
|
170
174
|
resolve({});
|
|
171
175
|
}).catch(err => {
|
|
172
|
-
if (validatePromise.current !== rootPromise) {
|
|
176
|
+
if (isUnmounted.current || validatePromise.current !== rootPromise) {
|
|
173
177
|
return;
|
|
174
178
|
}
|
|
175
179
|
let {
|
|
@@ -215,7 +219,7 @@ function withField(Component, opts) {
|
|
|
215
219
|
} else if (isPromise(maybePromisedErrors)) {
|
|
216
220
|
maybePromisedErrors.then(result => {
|
|
217
221
|
// If the async validate is outdated (a newer validate occurs), the result should be discarded
|
|
218
|
-
if (validatePromise.current !== rootPromise) {
|
|
222
|
+
if (isUnmounted.current || validatePromise.current !== rootPromise) {
|
|
219
223
|
return;
|
|
220
224
|
}
|
|
221
225
|
if (isValid(result)) {
|
|
@@ -343,11 +347,14 @@ function withField(Component, opts) {
|
|
|
343
347
|
rulesRef.current = rules;
|
|
344
348
|
validateRef.current = validate;
|
|
345
349
|
}, [rules, validate]);
|
|
346
|
-
// exec validate once when trigger inlcude 'mount'
|
|
347
350
|
useIsomorphicEffect(() => {
|
|
351
|
+
// exec validate once when trigger include 'mount'
|
|
348
352
|
if (validateOnMount) {
|
|
349
353
|
fieldValidate(value);
|
|
350
354
|
}
|
|
355
|
+
return () => {
|
|
356
|
+
isUnmounted.current = true;
|
|
357
|
+
};
|
|
351
358
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
352
359
|
}, []);
|
|
353
360
|
// register when mounted,unregister when unmounted
|
package/lib/es/image/image.js
CHANGED
|
@@ -162,9 +162,11 @@ export default class Image extends BaseComponent {
|
|
|
162
162
|
fallback,
|
|
163
163
|
placeholder,
|
|
164
164
|
imageID,
|
|
165
|
-
setDownloadName
|
|
165
|
+
setDownloadName,
|
|
166
|
+
imgCls,
|
|
167
|
+
imgStyle
|
|
166
168
|
} = _b,
|
|
167
|
-
restProps = __rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName"]);
|
|
169
|
+
restProps = __rest(_b, ["src", "width", "height", "alt", "style", "className", "crossOrigin", "preview", "fallback", "placeholder", "imageID", "setDownloadName", "imgCls", "imgStyle"]);
|
|
168
170
|
const outerStyle = Object.assign({
|
|
169
171
|
width,
|
|
170
172
|
height
|
|
@@ -187,9 +189,11 @@ export default class Image extends BaseComponent {
|
|
|
187
189
|
src: this.isInGroup() && this.isLazyLoad() ? undefined : src,
|
|
188
190
|
"data-src": src,
|
|
189
191
|
alt: alt,
|
|
192
|
+
style: imgStyle,
|
|
190
193
|
className: cls(`${prefixCls}-img`, {
|
|
191
194
|
[`${prefixCls}-img-preview`]: showPreviewCursor,
|
|
192
|
-
[`${prefixCls}-img-error`]: loadStatus === "error"
|
|
195
|
+
[`${prefixCls}-img-error`]: loadStatus === "error",
|
|
196
|
+
[imgCls]: Boolean(imgCls)
|
|
193
197
|
}),
|
|
194
198
|
width: width,
|
|
195
199
|
height: height,
|
|
@@ -23,6 +23,8 @@ export interface ImageProps extends BaseProps {
|
|
|
23
23
|
children?: ReactNode;
|
|
24
24
|
imageID?: number;
|
|
25
25
|
setDownloadName?: (src: string) => string;
|
|
26
|
+
imgStyle?: React.CSSProperties;
|
|
27
|
+
imgCls?: string;
|
|
26
28
|
}
|
|
27
29
|
export interface PreviewProps extends BaseProps {
|
|
28
30
|
visible?: boolean;
|
package/lib/es/input/index.js
CHANGED
|
@@ -63,9 +63,10 @@ class Input extends BaseComponent {
|
|
|
63
63
|
this.handlePreventMouseDown = e => {
|
|
64
64
|
this.foundation.handlePreventMouseDown(e);
|
|
65
65
|
};
|
|
66
|
+
const initValue = 'value' in props ? props.value : props.defaultValue;
|
|
66
67
|
this.state = {
|
|
67
|
-
value:
|
|
68
|
-
cachedValue:
|
|
68
|
+
value: initValue,
|
|
69
|
+
cachedValue: props.value,
|
|
69
70
|
disabled: false,
|
|
70
71
|
props: {},
|
|
71
72
|
isFocus: false,
|
|
@@ -138,7 +139,6 @@ class Input extends BaseComponent {
|
|
|
138
139
|
componentDidMount() {
|
|
139
140
|
// autofocus is changed from the original support of input to the support of manually calling the focus method,
|
|
140
141
|
// so that preventScroll can still take effect under the setting of autofocus
|
|
141
|
-
this.foundation.init();
|
|
142
142
|
const {
|
|
143
143
|
disabled,
|
|
144
144
|
autoFocus,
|
package/lib/es/input/textarea.js
CHANGED
|
@@ -39,12 +39,14 @@ class TextArea extends BaseComponent {
|
|
|
39
39
|
forwardRef.current = node;
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
const initValue = 'value' in props ? props.value : props.defaultValue;
|
|
42
43
|
this.state = {
|
|
43
|
-
value:
|
|
44
|
+
value: initValue,
|
|
44
45
|
isFocus: false,
|
|
45
46
|
isHover: false,
|
|
46
47
|
height: 0,
|
|
47
|
-
minLength: props.minLength
|
|
48
|
+
minLength: props.minLength,
|
|
49
|
+
cachedValue: props.value
|
|
48
50
|
};
|
|
49
51
|
this.focusing = false;
|
|
50
52
|
this.foundation = new TextAreaFoundation(this.adapter);
|
package/lib/es/tooltip/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
15
15
|
return t;
|
|
16
16
|
};
|
|
17
17
|
import React, { isValidElement, cloneElement } from 'react';
|
|
18
|
-
import ReactDOM from 'react-dom';
|
|
18
|
+
import ReactDOM, { findDOMNode } from 'react-dom';
|
|
19
19
|
import classNames from 'classnames';
|
|
20
20
|
import PropTypes from 'prop-types';
|
|
21
21
|
import { BASE_CLASS_PREFIX } from '@douyinfe/semi-foundation/lib/es/base/constants';
|
|
@@ -28,7 +28,7 @@ import { getUuidShort } from '@douyinfe/semi-foundation/lib/es/utils/uuid';
|
|
|
28
28
|
import '@douyinfe/semi-foundation/lib/es/tooltip/tooltip.css';
|
|
29
29
|
import BaseComponent from '../_base/baseComponent';
|
|
30
30
|
import { isHTMLElement } from '../_base/reactUtils';
|
|
31
|
-
import { getActiveElement, getDefaultPropsFromGlobalConfig, getFocusableElements, stopPropagation } from '../_utils';
|
|
31
|
+
import { getActiveElement, getDefaultPropsFromGlobalConfig, getFocusableElements, runAfterTicks, stopPropagation } from '../_utils';
|
|
32
32
|
import Portal from '../_portal/index';
|
|
33
33
|
import ConfigContext from '../configProvider/context';
|
|
34
34
|
import TriangleArrow from './TriangleArrow';
|
|
@@ -536,6 +536,15 @@ export default class Tooltip extends BaseComponent {
|
|
|
536
536
|
this.mounted = true;
|
|
537
537
|
this.getPopupContainer = this.props.getPopupContainer || this.context.getPopupContainer || defaultGetContainer;
|
|
538
538
|
this.foundation.init();
|
|
539
|
+
runAfterTicks(() => {
|
|
540
|
+
let triggerEle = this.triggerEl.current;
|
|
541
|
+
if (triggerEle) {
|
|
542
|
+
if (!(triggerEle instanceof HTMLElement)) {
|
|
543
|
+
triggerEle = findDOMNode(triggerEle);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
this.foundation.updateStateIfCursorOnTrigger(triggerEle);
|
|
547
|
+
}, 1);
|
|
539
548
|
}
|
|
540
549
|
componentWillUnmount() {
|
|
541
550
|
this.mounted = false;
|
|
@@ -358,15 +358,17 @@ class TreeSelect extends BaseComponent {
|
|
|
358
358
|
leafOnly,
|
|
359
359
|
searchPosition,
|
|
360
360
|
triggerRender,
|
|
361
|
-
borderless
|
|
361
|
+
borderless,
|
|
362
|
+
checkRelation
|
|
362
363
|
} = _a,
|
|
363
|
-
rest = __rest(_a, ["disabled", "multiple", "filterTreeNode", "validateStatus", "prefix", "suffix", "style", "size", "insetLabel", "className", "placeholder", "showClear", "leafOnly", "searchPosition", "triggerRender", "borderless"]);
|
|
364
|
+
rest = __rest(_a, ["disabled", "multiple", "filterTreeNode", "validateStatus", "prefix", "suffix", "style", "size", "insetLabel", "className", "placeholder", "showClear", "leafOnly", "searchPosition", "triggerRender", "borderless", "checkRelation"]);
|
|
364
365
|
const {
|
|
365
366
|
inputValue,
|
|
366
367
|
selectedKeys,
|
|
367
368
|
checkedKeys,
|
|
368
369
|
keyEntities,
|
|
369
|
-
isFocus
|
|
370
|
+
isFocus,
|
|
371
|
+
realCheckedKeys
|
|
370
372
|
} = this.state;
|
|
371
373
|
const filterable = Boolean(filterTreeNode);
|
|
372
374
|
const useCustomTrigger = typeof triggerRender === 'function';
|
|
@@ -394,31 +396,45 @@ class TreeSelect extends BaseComponent {
|
|
|
394
396
|
[`${prefixcls}-with-suffix`]: suffix,
|
|
395
397
|
[`${prefixcls}-with-suffix`]: suffix
|
|
396
398
|
}, className);
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}
|
|
399
|
+
let inner;
|
|
400
|
+
if (useCustomTrigger) {
|
|
401
|
+
let triggerRenderKeys = [];
|
|
402
|
+
if (multiple) {
|
|
403
|
+
if (checkRelation === 'related') {
|
|
404
|
+
triggerRenderKeys = normalizeKeyList([...checkedKeys], keyEntities, leafOnly, true);
|
|
405
|
+
} else if (checkRelation === 'unRelated') {
|
|
406
|
+
triggerRenderKeys = [...realCheckedKeys];
|
|
407
|
+
}
|
|
408
|
+
} else {
|
|
409
|
+
triggerRenderKeys = selectedKeys;
|
|
410
|
+
}
|
|
411
|
+
inner = /*#__PURE__*/React.createElement(Trigger, {
|
|
412
|
+
inputValue: inputValue,
|
|
413
|
+
value: triggerRenderKeys.map(key => _get(keyEntities, [key, 'data'])),
|
|
414
|
+
disabled: disabled,
|
|
415
|
+
placeholder: placeholder,
|
|
416
|
+
onClear: this.handleClear,
|
|
417
|
+
componentName: 'TreeSelect',
|
|
418
|
+
triggerRender: triggerRender,
|
|
419
|
+
componentProps: Object.assign({}, this.props),
|
|
420
|
+
onSearch: this.search,
|
|
421
|
+
onRemove: this.removeTag
|
|
422
|
+
});
|
|
423
|
+
} else {
|
|
424
|
+
inner = [/*#__PURE__*/React.createElement(Fragment, {
|
|
425
|
+
key: 'prefix'
|
|
426
|
+
}, prefix || insetLabel ? this.renderPrefix() : null), /*#__PURE__*/React.createElement(Fragment, {
|
|
427
|
+
key: 'selection'
|
|
428
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
429
|
+
className: `${prefixcls}-selection`
|
|
430
|
+
}, this.renderSelectContent())), /*#__PURE__*/React.createElement(Fragment, {
|
|
431
|
+
key: 'suffix'
|
|
432
|
+
}, suffix ? this.renderSuffix() : null), /*#__PURE__*/React.createElement(Fragment, {
|
|
433
|
+
key: 'clearBtn'
|
|
434
|
+
}, showClear || isTriggerPositionSearch && inputValue ? this.renderClearBtn() : null), /*#__PURE__*/React.createElement(Fragment, {
|
|
435
|
+
key: 'arrow'
|
|
436
|
+
}, this.renderArrow())];
|
|
437
|
+
}
|
|
422
438
|
const tabIndex = disabled ? null : 0;
|
|
423
439
|
/**
|
|
424
440
|
* Reasons for disabling the a11y eslint rule:
|
|
@@ -882,7 +898,6 @@ class TreeSelect extends BaseComponent {
|
|
|
882
898
|
};
|
|
883
899
|
}
|
|
884
900
|
static getDerivedStateFromProps(props, prevState) {
|
|
885
|
-
var _a;
|
|
886
901
|
const {
|
|
887
902
|
prevProps,
|
|
888
903
|
rePosKey
|
|
@@ -945,16 +960,6 @@ class TreeSelect extends BaseComponent {
|
|
|
945
960
|
newState.expandedKeys = calcExpandedKeysForValues(normalizeValue(props.defaultValue, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
|
|
946
961
|
} else if (!prevProps && props.value) {
|
|
947
962
|
newState.expandedKeys = calcExpandedKeysForValues(normalizeValue(props.value, withObject, keyMaps), keyEntities, props.multiple, valueEntities);
|
|
948
|
-
} else if (!isExpandControlled && needUpdateTreeData && props.value) {
|
|
949
|
-
// 当 treeData 已经设置具体的值,并且设置了 props.loadData ,则认为 treeData 的更新是因为 loadData 导致的
|
|
950
|
-
// 如果是因为 loadData 导致 treeData改变, 此时在这里重新计算 key 会导致为未选中的展开项目被收起
|
|
951
|
-
// 所以此时不需要重新计算 expandedKeys,因为在点击展开按钮时候已经把被展开的项添加到 expandedKeys 中
|
|
952
|
-
// When treeData has a specific value and props.loadData is set, it is considered that the update of treeData is caused by loadData
|
|
953
|
-
// If the treeData is changed because of loadData, recalculating the key here will cause the unselected expanded items to be collapsed
|
|
954
|
-
// 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
|
|
955
|
-
if (!(prevState.treeData && ((_a = prevState.treeData) === null || _a === void 0 ? void 0 : _a.length) > 0 && props.loadData)) {
|
|
956
|
-
newState.expandedKeys = calcExpandedKeysForValues(props.value, keyEntities, props.multiple, valueEntities);
|
|
957
|
-
}
|
|
958
963
|
}
|
|
959
964
|
if (!newState.expandedKeys) {
|
|
960
965
|
delete newState.expandedKeys;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.57.0
|
|
3
|
+
"version": "2.57.0",
|
|
4
4
|
"description": "A modern, comprehensive, flexible design system and UI library. Connect DesignOps & DevOps. Quickly build beautiful React apps. Maintained by Douyin-fe team.",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"@dnd-kit/core": "^6.0.8",
|
|
21
21
|
"@dnd-kit/sortable": "^7.0.2",
|
|
22
22
|
"@dnd-kit/utilities": "^3.2.1",
|
|
23
|
-
"@douyinfe/semi-animation": "2.57.0
|
|
24
|
-
"@douyinfe/semi-animation-react": "2.57.0
|
|
25
|
-
"@douyinfe/semi-foundation": "2.57.0
|
|
26
|
-
"@douyinfe/semi-icons": "2.57.0
|
|
27
|
-
"@douyinfe/semi-illustrations": "2.57.0
|
|
28
|
-
"@douyinfe/semi-theme-default": "2.57.0
|
|
23
|
+
"@douyinfe/semi-animation": "2.57.0",
|
|
24
|
+
"@douyinfe/semi-animation-react": "2.57.0",
|
|
25
|
+
"@douyinfe/semi-foundation": "2.57.0",
|
|
26
|
+
"@douyinfe/semi-icons": "2.57.0",
|
|
27
|
+
"@douyinfe/semi-illustrations": "2.57.0",
|
|
28
|
+
"@douyinfe/semi-theme-default": "2.57.0",
|
|
29
29
|
"async-validator": "^3.5.0",
|
|
30
30
|
"classnames": "^2.2.6",
|
|
31
31
|
"copy-text-to-clipboard": "^2.1.1",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
],
|
|
76
76
|
"author": "",
|
|
77
77
|
"license": "MIT",
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "57571d206421c8044245b6eaf70b49cce034f939",
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
81
81
|
"@babel/plugin-transform-runtime": "^7.15.8",
|