@douyinfe/semi-ui 2.57.0-beta.0 → 2.58.0-beta.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 +21 -3
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +99 -92
- 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/navigation/Item.js +1 -1
- package/lib/cjs/table/Body/BaseRow.d.ts +0 -2
- package/lib/cjs/table/Body/BaseRow.js +5 -10
- package/lib/cjs/table/ColGroup.d.ts +2 -2
- package/lib/cjs/table/interface.d.ts +17 -16
- package/lib/cjs/tagInput/index.js +8 -3
- 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/navigation/Item.js +1 -1
- package/lib/es/table/Body/BaseRow.d.ts +0 -2
- package/lib/es/table/Body/BaseRow.js +5 -8
- package/lib/es/table/ColGroup.d.ts +2 -2
- package/lib/es/table/interface.d.ts +17 -16
- package/lib/es/tagInput/index.js +8 -3
- 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);
|
|
@@ -217,7 +217,7 @@ class NavItem extends _baseComponent.default {
|
|
|
217
217
|
onMouseEnter: onMouseEnter,
|
|
218
218
|
onMouseLeave: onMouseLeave,
|
|
219
219
|
onKeyPress: this.handleKeyPress
|
|
220
|
-
}), itemChildren);
|
|
220
|
+
}, this.getDataAttr(this.props)), itemChildren);
|
|
221
221
|
}
|
|
222
222
|
// Display Tooltip when disabled and SubNav
|
|
223
223
|
if (isCollapsed && !isInSubNav && !isSubNav || isCollapsed && isSubNav && disabled) {
|
|
@@ -158,11 +158,9 @@ export default class TableRow extends BaseComponent<BaseRowProps, Record<string,
|
|
|
158
158
|
disabled: boolean;
|
|
159
159
|
};
|
|
160
160
|
get adapter(): TableRowAdapter<BaseRowProps>;
|
|
161
|
-
ref: React.MutableRefObject<any>;
|
|
162
161
|
constructor(props: BaseRowProps);
|
|
163
162
|
componentDidMount(): void;
|
|
164
163
|
shouldComponentUpdate(nextProps: BaseRowProps): boolean;
|
|
165
|
-
_cacheNode: (node: any) => void;
|
|
166
164
|
renderExpandIcon: (record: Record<string, any>) => React.ReactNode;
|
|
167
165
|
renderCells(): React.ReactNode[];
|
|
168
166
|
handleMouseEnter: (e: React.MouseEvent) => void;
|
|
@@ -11,7 +11,7 @@ var _stubTrue2 = _interopRequireDefault(require("lodash/stubTrue"));
|
|
|
11
11
|
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
12
12
|
var _noop2 = _interopRequireDefault(require("lodash/noop"));
|
|
13
13
|
var _each2 = _interopRequireDefault(require("lodash/each"));
|
|
14
|
-
var _react =
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
15
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
16
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
17
|
var _constants = require("@douyinfe/semi-foundation/lib/cjs/table/constants");
|
|
@@ -20,8 +20,6 @@ var _tableRowFoundation = _interopRequireDefault(require("@douyinfe/semi-foundat
|
|
|
20
20
|
var _utils = require("@douyinfe/semi-foundation/lib/cjs/table/utils");
|
|
21
21
|
var _baseComponent = _interopRequireDefault(require("../../_base/baseComponent"));
|
|
22
22
|
var _TableCell = _interopRequireDefault(require("../TableCell"));
|
|
23
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
24
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
27
25
|
var t = {};
|
|
@@ -98,9 +96,6 @@ class TableRow extends _baseComponent.default {
|
|
|
98
96
|
}
|
|
99
97
|
constructor(props) {
|
|
100
98
|
super(props);
|
|
101
|
-
this._cacheNode = node => {
|
|
102
|
-
this.ref.current = node;
|
|
103
|
-
};
|
|
104
99
|
// Pass true to render the tree-shaped expand button
|
|
105
100
|
this.renderExpandIcon = record => {
|
|
106
101
|
const {
|
|
@@ -129,7 +124,6 @@ class TableRow extends _baseComponent.default {
|
|
|
129
124
|
customRowProps.onClick(e);
|
|
130
125
|
}
|
|
131
126
|
};
|
|
132
|
-
this.ref = /*#__PURE__*/(0, _react.createRef)();
|
|
133
127
|
this.foundation = new _tableRowFoundation.default(this.adapter);
|
|
134
128
|
}
|
|
135
129
|
componentDidMount() {
|
|
@@ -270,7 +264,8 @@ class TableRow extends _baseComponent.default {
|
|
|
270
264
|
expandableRow,
|
|
271
265
|
level,
|
|
272
266
|
expandedRow,
|
|
273
|
-
isSection
|
|
267
|
+
isSection,
|
|
268
|
+
rowKey
|
|
274
269
|
} = this.props;
|
|
275
270
|
const BodyRow = components.body.row;
|
|
276
271
|
const _a = onRow(record, index) || {},
|
|
@@ -281,7 +276,7 @@ class TableRow extends _baseComponent.default {
|
|
|
281
276
|
rowProps = __rest(_a, ["className", "style"]);
|
|
282
277
|
this.adapter.setCache('customRowProps', Object.assign({}, rowProps));
|
|
283
278
|
const baseRowStyle = Object.assign(Object.assign({}, style), customStyle);
|
|
284
|
-
const rowCls = typeof replaceClassName === 'string' && replaceClassName.length ? replaceClassName : (0, _classnames.default)(className, `${prefixCls}-row`, {
|
|
279
|
+
const rowCls = typeof replaceClassName === 'string' && replaceClassName.length ? (0, _classnames.default)(replaceClassName, customClassName) : (0, _classnames.default)(className, `${prefixCls}-row`, {
|
|
285
280
|
[`${prefixCls}-row-selected`]: selected,
|
|
286
281
|
[`${prefixCls}-row-expanded`]: expanded,
|
|
287
282
|
[`${prefixCls}-row-hovered`]: hovered,
|
|
@@ -309,7 +304,7 @@ class TableRow extends _baseComponent.default {
|
|
|
309
304
|
}, ariaProps, rowProps, {
|
|
310
305
|
style: baseRowStyle,
|
|
311
306
|
className: rowCls,
|
|
312
|
-
|
|
307
|
+
"data-row-key": rowKey,
|
|
313
308
|
onMouseEnter: this.handleMouseEnter,
|
|
314
309
|
onMouseLeave: this.handleMouseLeave,
|
|
315
310
|
onClick: this.handleClick
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { ColumnProps } from './interface';
|
|
3
|
+
import { ColumnProps, TableComponents } from './interface';
|
|
4
4
|
export interface ColGroupProps {
|
|
5
5
|
columns?: ColumnProps[];
|
|
6
6
|
prefixCls?: string;
|
|
7
7
|
className?: string;
|
|
8
8
|
style?: React.CSSProperties;
|
|
9
|
-
components?:
|
|
9
|
+
components?: TableComponents['body'];
|
|
10
10
|
}
|
|
11
11
|
export default class ColGroup extends React.PureComponent<ColGroupProps> {
|
|
12
12
|
static propTypes: {
|
|
@@ -173,7 +173,7 @@ export interface OnRowReturnObject extends Omit<React.DetailedHTMLProps<React.HT
|
|
|
173
173
|
style?: React.CSSProperties;
|
|
174
174
|
onClick?: (e: React.MouseEvent) => void;
|
|
175
175
|
}
|
|
176
|
-
export interface OnGroupedRowReturnObject extends
|
|
176
|
+
export interface OnGroupedRowReturnObject extends React.HTMLAttributes<HTMLTableRowElement> {
|
|
177
177
|
[x: string]: any;
|
|
178
178
|
style?: React.CSSProperties;
|
|
179
179
|
onClick?: (e: React.MouseEvent) => void;
|
|
@@ -188,29 +188,30 @@ export interface Data {
|
|
|
188
188
|
[x: string]: any;
|
|
189
189
|
key?: string | number;
|
|
190
190
|
}
|
|
191
|
+
export type TableComponent<P> = React.ComponentType<P> | React.ForwardRefExoticComponent<P> | keyof React.ReactHTML;
|
|
191
192
|
export interface TableComponents {
|
|
192
|
-
table?:
|
|
193
|
+
table?: TableComponent<any>;
|
|
193
194
|
header?: {
|
|
194
|
-
outer?:
|
|
195
|
-
wrapper?:
|
|
196
|
-
row?:
|
|
197
|
-
cell?:
|
|
195
|
+
outer?: TableComponent<any>;
|
|
196
|
+
wrapper?: TableComponent<any>;
|
|
197
|
+
row?: TableComponent<any>;
|
|
198
|
+
cell?: TableComponent<any>;
|
|
198
199
|
};
|
|
199
200
|
body?: {
|
|
200
|
-
outer?:
|
|
201
|
-
wrapper?:
|
|
202
|
-
row?:
|
|
203
|
-
cell?:
|
|
201
|
+
outer?: TableComponent<any>;
|
|
202
|
+
wrapper?: TableComponent<any>;
|
|
203
|
+
row?: TableComponent<any>;
|
|
204
|
+
cell?: TableComponent<any>;
|
|
204
205
|
colgroup?: {
|
|
205
|
-
wrapper?:
|
|
206
|
-
col?:
|
|
206
|
+
wrapper?: TableComponent<any>;
|
|
207
|
+
col?: TableComponent<any>;
|
|
207
208
|
};
|
|
208
209
|
};
|
|
209
210
|
footer?: {
|
|
210
|
-
wrapper?:
|
|
211
|
-
row?:
|
|
212
|
-
cell?:
|
|
213
|
-
outer?:
|
|
211
|
+
wrapper?: TableComponent<any>;
|
|
212
|
+
row?: TableComponent<any>;
|
|
213
|
+
cell?: TableComponent<any>;
|
|
214
|
+
outer?: TableComponent<any>;
|
|
214
215
|
};
|
|
215
216
|
}
|
|
216
217
|
export interface RowSelectionProps<RecordType> {
|
|
@@ -448,9 +448,12 @@ class TagInput extends _baseComponent.default {
|
|
|
448
448
|
className,
|
|
449
449
|
disabled,
|
|
450
450
|
placeholder,
|
|
451
|
-
validateStatus
|
|
451
|
+
validateStatus,
|
|
452
|
+
prefix,
|
|
453
|
+
insetLabel,
|
|
454
|
+
suffix
|
|
452
455
|
} = _a,
|
|
453
|
-
rest = __rest(_a, ["size", "style", "className", "disabled", "placeholder", "validateStatus"]);
|
|
456
|
+
rest = __rest(_a, ["size", "style", "className", "disabled", "placeholder", "validateStatus", "prefix", "insetLabel", "suffix"]);
|
|
454
457
|
const {
|
|
455
458
|
focusing,
|
|
456
459
|
hovering,
|
|
@@ -465,7 +468,9 @@ class TagInput extends _baseComponent.default {
|
|
|
465
468
|
[`${prefixCls}-error`]: validateStatus === 'error',
|
|
466
469
|
[`${prefixCls}-warning`]: validateStatus === 'warning',
|
|
467
470
|
[`${prefixCls}-small`]: size === 'small',
|
|
468
|
-
[`${prefixCls}-large`]: size === 'large'
|
|
471
|
+
[`${prefixCls}-large`]: size === 'large',
|
|
472
|
+
[`${prefixCls}-with-prefix`]: !!prefix || !!insetLabel,
|
|
473
|
+
[`${prefixCls}-with-suffix`]: !!suffix
|
|
469
474
|
});
|
|
470
475
|
const inputCls = (0, _classnames.default)(`${prefixCls}-wrapper-input`, `${prefixCls}-wrapper-input-${size}`);
|
|
471
476
|
const wrapperCls = (0, _classnames.default)(`${prefixCls}-wrapper`);
|
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);
|
|
@@ -210,7 +210,7 @@ export default class NavItem extends BaseComponent {
|
|
|
210
210
|
onMouseEnter: onMouseEnter,
|
|
211
211
|
onMouseLeave: onMouseLeave,
|
|
212
212
|
onKeyPress: this.handleKeyPress
|
|
213
|
-
}), itemChildren);
|
|
213
|
+
}, this.getDataAttr(this.props)), itemChildren);
|
|
214
214
|
}
|
|
215
215
|
// Display Tooltip when disabled and SubNav
|
|
216
216
|
if (isCollapsed && !isInSubNav && !isSubNav || isCollapsed && isSubNav && disabled) {
|
|
@@ -158,11 +158,9 @@ export default class TableRow extends BaseComponent<BaseRowProps, Record<string,
|
|
|
158
158
|
disabled: boolean;
|
|
159
159
|
};
|
|
160
160
|
get adapter(): TableRowAdapter<BaseRowProps>;
|
|
161
|
-
ref: React.MutableRefObject<any>;
|
|
162
161
|
constructor(props: BaseRowProps);
|
|
163
162
|
componentDidMount(): void;
|
|
164
163
|
shouldComponentUpdate(nextProps: BaseRowProps): boolean;
|
|
165
|
-
_cacheNode: (node: any) => void;
|
|
166
164
|
renderExpandIcon: (record: Record<string, any>) => React.ReactNode;
|
|
167
165
|
renderCells(): React.ReactNode[];
|
|
168
166
|
handleMouseEnter: (e: React.MouseEvent) => void;
|