@douyinfe/semi-ui 2.10.0-beta.0 → 2.10.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/button/buttonGroup.tsx +2 -2
- package/carousel/CarouselArrow.tsx +4 -4
- package/carousel/CarouselIndicator.tsx +0 -1
- package/carousel/index.tsx +1 -3
- package/carousel/interface.ts +1 -2
- package/checkbox/checkbox.tsx +1 -3
- package/checkbox/checkboxInner.tsx +19 -14
- package/datePicker/monthsGrid.tsx +8 -8
- package/dist/css/semi.css +5 -4
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +711 -547
- 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/form/baseForm.tsx +10 -2
- package/form/hoc/withField.tsx +17 -5
- package/inputNumber/__test__/inputNumber.test.js +40 -3
- package/inputNumber/_story/inputNumber.stories.js +56 -1
- package/inputNumber/index.tsx +22 -14
- package/lib/cjs/button/buttonGroup.d.ts +1 -1
- package/lib/cjs/carousel/CarouselArrow.js +3 -6
- package/lib/cjs/carousel/index.js +1 -3
- package/lib/cjs/carousel/interface.d.ts +1 -2
- package/lib/cjs/checkbox/checkbox.js +1 -2
- package/lib/cjs/checkbox/checkboxInner.js +21 -17
- package/lib/cjs/datePicker/monthsGrid.js +6 -6
- package/lib/cjs/form/baseForm.d.ts +1 -0
- package/lib/cjs/form/baseForm.js +10 -2
- package/lib/cjs/form/hoc/withField.js +8 -1
- package/lib/cjs/inputNumber/index.d.ts +2 -6
- package/lib/cjs/inputNumber/index.js +27 -11
- package/lib/cjs/tooltip/index.d.ts +1 -0
- package/lib/cjs/tooltip/index.js +9 -6
- package/lib/cjs/transfer/index.js +5 -5
- package/lib/cjs/treeSelect/index.js +1 -1
- package/lib/es/button/buttonGroup.d.ts +1 -1
- package/lib/es/carousel/CarouselArrow.js +3 -5
- package/lib/es/carousel/index.js +1 -3
- package/lib/es/carousel/interface.d.ts +1 -2
- package/lib/es/checkbox/checkbox.js +1 -2
- package/lib/es/checkbox/checkboxInner.js +20 -17
- package/lib/es/datePicker/monthsGrid.js +7 -7
- package/lib/es/form/baseForm.d.ts +1 -0
- package/lib/es/form/baseForm.js +10 -2
- package/lib/es/form/hoc/withField.js +8 -1
- package/lib/es/inputNumber/index.d.ts +2 -6
- package/lib/es/inputNumber/index.js +26 -11
- package/lib/es/tooltip/index.d.ts +1 -0
- package/lib/es/tooltip/index.js +9 -6
- package/lib/es/transfer/index.js +1 -1
- package/lib/es/treeSelect/index.js +1 -1
- package/package.json +9 -9
- package/popover/_story/popover.stories.js +38 -2
- package/tooltip/index.tsx +9 -2
- package/transfer/index.tsx +1 -1
- package/treeSelect/index.tsx +1 -1
|
@@ -24,6 +24,8 @@ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
|
24
24
|
|
|
25
25
|
var _noop2 = _interopRequireDefault(require("lodash/noop"));
|
|
26
26
|
|
|
27
|
+
var _isString2 = _interopRequireDefault(require("lodash/isString"));
|
|
28
|
+
|
|
27
29
|
var _isNaN2 = _interopRequireDefault(require("lodash/isNaN"));
|
|
28
30
|
|
|
29
31
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -300,6 +302,9 @@ class InputNumber extends _baseComponent.default {
|
|
|
300
302
|
},
|
|
301
303
|
setClickUpOrDown: value => {
|
|
302
304
|
this.clickUpOrDown = value;
|
|
305
|
+
},
|
|
306
|
+
updateStates: (states, callback) => {
|
|
307
|
+
this.setState(states, callback);
|
|
303
308
|
}
|
|
304
309
|
});
|
|
305
310
|
}
|
|
@@ -311,6 +316,7 @@ class InputNumber extends _baseComponent.default {
|
|
|
311
316
|
const {
|
|
312
317
|
focusing
|
|
313
318
|
} = this.state;
|
|
319
|
+
let newValue;
|
|
314
320
|
/**
|
|
315
321
|
* To determine whether the front and back are equal
|
|
316
322
|
* NaN need to check whether both are NaN
|
|
@@ -318,8 +324,9 @@ class InputNumber extends _baseComponent.default {
|
|
|
318
324
|
|
|
319
325
|
if (value !== prevProps.value && !(0, _isBothNaN.default)(value, prevProps.value)) {
|
|
320
326
|
if ((0, _isNullOrUndefined.default)(value) || value === '') {
|
|
321
|
-
|
|
322
|
-
|
|
327
|
+
newValue = '';
|
|
328
|
+
this.foundation.updateStates({
|
|
329
|
+
value: newValue,
|
|
323
330
|
number: null
|
|
324
331
|
});
|
|
325
332
|
} else {
|
|
@@ -375,33 +382,42 @@ class InputNumber extends _baseComponent.default {
|
|
|
375
382
|
|
|
376
383
|
if (this.clickUpOrDown) {
|
|
377
384
|
obj.value = this.foundation.doFormat(valueStr, true);
|
|
385
|
+
newValue = obj.value;
|
|
378
386
|
}
|
|
379
387
|
|
|
380
|
-
this.
|
|
388
|
+
this.foundation.updateStates(obj, () => this.adapter.restoreCursor());
|
|
381
389
|
} else if (!(0, _isNaN2.default)(toNum)) {
|
|
382
390
|
// Update input content when controlled input is illegal and not NaN
|
|
383
|
-
this.
|
|
384
|
-
|
|
391
|
+
newValue = this.foundation.doFormat(toNum, false);
|
|
392
|
+
this.foundation.updateStates({
|
|
393
|
+
value: newValue
|
|
385
394
|
});
|
|
386
395
|
} else {
|
|
387
396
|
// Update input content when controlled input NaN
|
|
388
|
-
this.
|
|
389
|
-
|
|
397
|
+
newValue = this.foundation.doFormat(valueStr, false);
|
|
398
|
+
this.foundation.updateStates({
|
|
399
|
+
value: newValue
|
|
390
400
|
});
|
|
391
401
|
}
|
|
392
402
|
} else if (this.foundation.isValidNumber(parsedNum)) {
|
|
393
|
-
this.
|
|
403
|
+
newValue = this.foundation.doFormat(parsedNum);
|
|
404
|
+
this.foundation.updateStates({
|
|
394
405
|
number: parsedNum,
|
|
395
|
-
value:
|
|
406
|
+
value: newValue
|
|
396
407
|
});
|
|
397
408
|
} else {
|
|
398
409
|
// Invalid digital analog blurring effect instead of controlled failure
|
|
399
|
-
|
|
410
|
+
newValue = '';
|
|
411
|
+
this.foundation.updateStates({
|
|
400
412
|
number: null,
|
|
401
|
-
value:
|
|
413
|
+
value: newValue
|
|
402
414
|
});
|
|
403
415
|
}
|
|
404
416
|
}
|
|
417
|
+
|
|
418
|
+
if ((0, _isString2.default)(newValue) && newValue !== String(this.props.value)) {
|
|
419
|
+
this.foundation.notifyChange(newValue, null);
|
|
420
|
+
}
|
|
405
421
|
}
|
|
406
422
|
|
|
407
423
|
if (!this.clickUpOrDown) {
|
|
@@ -164,6 +164,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
164
164
|
componentDidUpdate(prevProps: TooltipProps, prevState: TooltipState): void;
|
|
165
165
|
renderIcon: () => any;
|
|
166
166
|
handlePortalInnerClick: (e: React.MouseEvent) => void;
|
|
167
|
+
handlePortalMouseDown: (e: React.MouseEvent) => void;
|
|
167
168
|
handlePortalInnerKeyDown: (e: React.KeyboardEvent) => void;
|
|
168
169
|
renderContentNode: (content: TooltipProps['content']) => React.ReactNode;
|
|
169
170
|
renderPortal: () => JSX.Element;
|
package/lib/cjs/tooltip/index.js
CHANGED
|
@@ -187,6 +187,12 @@ class Tooltip extends _baseComponent.default {
|
|
|
187
187
|
}
|
|
188
188
|
};
|
|
189
189
|
|
|
190
|
+
this.handlePortalMouseDown = e => {
|
|
191
|
+
if (this.props.stopPropagation) {
|
|
192
|
+
(0, _utils.stopPropagation)(e);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
190
196
|
this.handlePortalInnerKeyDown = e => {
|
|
191
197
|
this.foundation.handleContainerKeydown(e);
|
|
192
198
|
};
|
|
@@ -271,6 +277,7 @@ class Tooltip extends _baseComponent.default {
|
|
|
271
277
|
style: portalInnerStyle,
|
|
272
278
|
ref: this.setContainerEl,
|
|
273
279
|
onClick: this.handlePortalInnerClick,
|
|
280
|
+
onMouseDown: this.handlePortalMouseDown,
|
|
274
281
|
onKeyDown: this.handlePortalInnerKeyDown
|
|
275
282
|
}, inner));
|
|
276
283
|
};
|
|
@@ -498,15 +505,11 @@ class Tooltip extends _baseComponent.default {
|
|
|
498
505
|
}
|
|
499
506
|
};
|
|
500
507
|
|
|
501
|
-
|
|
502
|
-
capture: true
|
|
503
|
-
});
|
|
508
|
+
window.addEventListener('mousedown', this.clickOutsideHandler);
|
|
504
509
|
},
|
|
505
510
|
unregisterClickOutsideHandler: () => {
|
|
506
511
|
if (this.clickOutsideHandler) {
|
|
507
|
-
|
|
508
|
-
capture: true
|
|
509
|
-
});
|
|
512
|
+
window.removeEventListener('mousedown', this.clickOutsideHandler);
|
|
510
513
|
this.clickOutsideHandler = null;
|
|
511
514
|
}
|
|
512
515
|
},
|
|
@@ -52,7 +52,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
52
52
|
|
|
53
53
|
var _foundation = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/transfer/foundation"));
|
|
54
54
|
|
|
55
|
-
var
|
|
55
|
+
var _transferUtils = require("@douyinfe/semi-foundation/lib/cjs/transfer/transferUtils");
|
|
56
56
|
|
|
57
57
|
var _constants = require("@douyinfe/semi-foundation/lib/cjs/transfer/constants");
|
|
58
58
|
|
|
@@ -98,13 +98,13 @@ class Transfer extends _baseComponent.default {
|
|
|
98
98
|
if (Boolean(dataSource) && (0, _isArray3.default)(dataSource)) {
|
|
99
99
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
100
100
|
// @ts-ignore Avoid reporting errors this.state.xxx is read-only
|
|
101
|
-
this.state.data = (0,
|
|
101
|
+
this.state.data = (0, _transferUtils._generateDataByType)(dataSource, type);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
if (Boolean(defaultValue) && (0, _isArray3.default)(defaultValue)) {
|
|
105
105
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
106
106
|
// @ts-ignore Avoid reporting errors this.state.xxx is read-only
|
|
107
|
-
this.state.selectedItems = (0,
|
|
107
|
+
this.state.selectedItems = (0, _transferUtils._generateSelectedItems)(defaultValue, this.state.data);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
this.onSelectOrRemove = (0, _bind.default)(_context = this.onSelectOrRemove).call(_context, this);
|
|
@@ -124,12 +124,12 @@ class Transfer extends _baseComponent.default {
|
|
|
124
124
|
let newSelectedItems = state.selectedItems;
|
|
125
125
|
|
|
126
126
|
if (Boolean(dataSource) && (0, _isArray2.default)(dataSource)) {
|
|
127
|
-
newData = (0,
|
|
127
|
+
newData = (0, _transferUtils._generateDataByType)(dataSource, type);
|
|
128
128
|
mergedState.data = newData;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
if (Boolean(value) && (0, _isArray2.default)(value)) {
|
|
132
|
-
newSelectedItems = (0,
|
|
132
|
+
newSelectedItems = (0, _transferUtils._generateSelectedItems)(value, newData);
|
|
133
133
|
mergedState.selectedItems = newSelectedItems;
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -101,7 +101,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "functi
|
|
|
101
101
|
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; }
|
|
102
102
|
|
|
103
103
|
const prefixcls = _constants.cssClasses.PREFIX;
|
|
104
|
-
const prefixTree = _constants.cssClasses.
|
|
104
|
+
const prefixTree = _constants.cssClasses.PREFIX_TREE;
|
|
105
105
|
const key = 0;
|
|
106
106
|
|
|
107
107
|
class TreeSelect extends _baseComponent.default {
|
|
@@ -10,7 +10,7 @@ export interface ButtonGroupProps extends BaseProps {
|
|
|
10
10
|
size?: Size;
|
|
11
11
|
theme?: Theme;
|
|
12
12
|
className?: string;
|
|
13
|
-
children?: React.
|
|
13
|
+
children?: React.ReactNode;
|
|
14
14
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
15
15
|
}
|
|
16
16
|
export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _throttle from "lodash/throttle";
|
|
2
1
|
import _get from "lodash/get";
|
|
3
2
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
4
3
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
@@ -37,8 +36,7 @@ class CarouselArrow extends React.PureComponent {
|
|
|
37
36
|
type,
|
|
38
37
|
theme,
|
|
39
38
|
prev,
|
|
40
|
-
next
|
|
41
|
-
timing
|
|
39
|
+
next
|
|
42
40
|
} = this.props;
|
|
43
41
|
const classNames = cls({
|
|
44
42
|
[cssClasses.CAROUSEL_ARROW]: true,
|
|
@@ -58,12 +56,12 @@ class CarouselArrow extends React.PureComponent {
|
|
|
58
56
|
}, /*#__PURE__*/React.createElement("div", _Object$assign({
|
|
59
57
|
// role='button'
|
|
60
58
|
className: leftClassNames,
|
|
61
|
-
onClick:
|
|
59
|
+
onClick: prev
|
|
62
60
|
}, _get(this.props, 'arrowProps.leftArrow.props')), this.renderLeftIcon()), /*#__PURE__*/React.createElement("div", _Object$assign({
|
|
63
61
|
// role='button'
|
|
64
62
|
// tabIndex={0}
|
|
65
63
|
className: rightClassNames,
|
|
66
|
-
onClick:
|
|
64
|
+
onClick: next
|
|
67
65
|
}, _get(this.props, 'arrowProps.rightArrow.props')), this.renderRightIcon()));
|
|
68
66
|
}
|
|
69
67
|
|
package/lib/es/carousel/index.js
CHANGED
|
@@ -67,7 +67,7 @@ class Carousel extends BaseComponent {
|
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
this.onIndicatorChange = activeIndex => {
|
|
70
|
-
return this.foundation.
|
|
70
|
+
return this.foundation.onIndicatorChange(activeIndex);
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
this.getChildren = () => {
|
|
@@ -166,7 +166,6 @@ class Carousel extends BaseComponent {
|
|
|
166
166
|
theme,
|
|
167
167
|
arrowProps
|
|
168
168
|
} = this.props;
|
|
169
|
-
const timing = this.foundation.getSwitchingTime();
|
|
170
169
|
|
|
171
170
|
if (showArrow && children.length > 1) {
|
|
172
171
|
return /*#__PURE__*/React.createElement(CarouselArrow, {
|
|
@@ -174,7 +173,6 @@ class Carousel extends BaseComponent {
|
|
|
174
173
|
theme: theme,
|
|
175
174
|
prev: this.prev,
|
|
176
175
|
next: this.next,
|
|
177
|
-
timing: timing,
|
|
178
176
|
arrowProps: arrowProps
|
|
179
177
|
});
|
|
180
178
|
}
|
|
@@ -3,7 +3,7 @@ import { strings } from '@douyinfe/semi-foundation/lib/es/carousel/constants';
|
|
|
3
3
|
export interface CarouselMethod {
|
|
4
4
|
next?: () => void;
|
|
5
5
|
prev?: () => void;
|
|
6
|
-
goTo?: () => void;
|
|
6
|
+
goTo?: (tagetIndex: number) => void;
|
|
7
7
|
play?: () => void;
|
|
8
8
|
stop?: () => void;
|
|
9
9
|
}
|
|
@@ -50,7 +50,6 @@ export interface CarouselArrowProps {
|
|
|
50
50
|
prev?: () => void;
|
|
51
51
|
next?: () => void;
|
|
52
52
|
arrowProps?: ArrowProps;
|
|
53
|
-
timing: number;
|
|
54
53
|
}
|
|
55
54
|
export interface ArrowButton {
|
|
56
55
|
props?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
@@ -126,6 +126,7 @@ class Checkbox extends BaseComponent {
|
|
|
126
126
|
} = this.context.checkboxGroup;
|
|
127
127
|
props.isCardType = isCardType;
|
|
128
128
|
props.isPureCardType = isPureCardType;
|
|
129
|
+
props['name'] = this.context.checkboxGroup.name;
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
const prefix = prefixCls || css.PREFIX;
|
|
@@ -144,7 +145,6 @@ class Checkbox extends BaseComponent {
|
|
|
144
145
|
const extraCls = classnames("".concat(prefix, "-extra"), {
|
|
145
146
|
["".concat(prefix, "-cardType_extra_noChildren")]: props.isCardType && !children
|
|
146
147
|
});
|
|
147
|
-
const name = inGroup && this.context.checkboxGroup.name;
|
|
148
148
|
|
|
149
149
|
const renderContent = () => /*#__PURE__*/React.createElement(React.Fragment, null, children ? /*#__PURE__*/React.createElement("span", {
|
|
150
150
|
id: this.addonId,
|
|
@@ -172,7 +172,6 @@ class Checkbox extends BaseComponent {
|
|
|
172
172
|
}, /*#__PURE__*/React.createElement(CheckboxInner, _Object$assign({}, this.props, props, {
|
|
173
173
|
addonId: children && this.addonId,
|
|
174
174
|
extraId: extra && this.extraId,
|
|
175
|
-
name: name,
|
|
176
175
|
isPureCardType: props.isPureCardType,
|
|
177
176
|
ref: ref => {
|
|
178
177
|
this.checkboxEntity = ref;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _noop from "lodash/noop";
|
|
2
|
+
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
2
3
|
|
|
3
4
|
/* eslint-disable no-nested-ternary */
|
|
4
5
|
import React, { PureComponent } from 'react';
|
|
@@ -38,27 +39,29 @@ class CheckboxInner extends PureComponent {
|
|
|
38
39
|
["".concat(prefix, "-inner-display")]: true
|
|
39
40
|
});
|
|
40
41
|
const icon = checked ? /*#__PURE__*/React.createElement(IconCheckboxTick, null) : indeterminate ? /*#__PURE__*/React.createElement(IconCheckboxIndeterminate, null) : null;
|
|
41
|
-
|
|
42
|
-
className: wrapper
|
|
43
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
42
|
+
const inputProps = {
|
|
44
43
|
type: "checkbox",
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
ref: ref => {
|
|
54
|
-
this.inputEntity = ref;
|
|
55
|
-
},
|
|
44
|
+
'aria-label': this.props['aria-label'],
|
|
45
|
+
'aria-disabled': disabled,
|
|
46
|
+
'aria-checked': checked,
|
|
47
|
+
'aria-labelledby': addonId,
|
|
48
|
+
'aria-describedby': extraId || this.props['aria-describedby'],
|
|
49
|
+
'aria-invalid': this.props['aria-invalid'],
|
|
50
|
+
'aria-errormessage': this.props['aria-errormessage'],
|
|
51
|
+
'aria-required': this.props['aria-required'],
|
|
56
52
|
className: css.INPUT,
|
|
57
53
|
onChange: _noop,
|
|
58
54
|
checked: checked,
|
|
59
|
-
disabled: disabled
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
disabled: disabled
|
|
56
|
+
};
|
|
57
|
+
name && (inputProps['name'] = name);
|
|
58
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
59
|
+
className: wrapper
|
|
60
|
+
}, /*#__PURE__*/React.createElement("input", _Object$assign({}, inputProps, {
|
|
61
|
+
ref: ref => {
|
|
62
|
+
this.inputEntity = ref;
|
|
63
|
+
}
|
|
64
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
62
65
|
className: inner
|
|
63
66
|
}, icon));
|
|
64
67
|
}
|
|
@@ -21,7 +21,7 @@ import PropTypes from 'prop-types';
|
|
|
21
21
|
import { format as formatFn, isSameDay } from 'date-fns';
|
|
22
22
|
import MonthsGridFoundation from '@douyinfe/semi-foundation/lib/es/datePicker/monthsGridFoundation';
|
|
23
23
|
import { strings, numbers, cssClasses } from '@douyinfe/semi-foundation/lib/es/datePicker/constants';
|
|
24
|
-
import {
|
|
24
|
+
import { compatibleParse } from '@douyinfe/semi-foundation/lib/es/datePicker/_utils/parser';
|
|
25
25
|
import BaseComponent from '../_base/baseComponent';
|
|
26
26
|
import Navigation from './navigation';
|
|
27
27
|
import Month from './month';
|
|
@@ -474,7 +474,7 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
474
474
|
const dateFormat = this.foundation.getValidDateFormat();
|
|
475
475
|
let startDate, endDate;
|
|
476
476
|
|
|
477
|
-
if (type === 'dateTimeRange' && rangeStart && rangeEnd && isSameDay(startDate =
|
|
477
|
+
if (type === 'dateTimeRange' && rangeStart && rangeEnd && isSameDay(startDate = compatibleParse(rangeStart, dateFormat, undefined, dateFnsLocale), endDate = compatibleParse(rangeEnd, dateFormat, undefined, dateFnsLocale))) {
|
|
478
478
|
if (panelType === strings.PANEL_TYPE_RIGHT) {
|
|
479
479
|
rangeStart && (restProps.startDate = startDate);
|
|
480
480
|
} else {
|
|
@@ -560,10 +560,10 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
560
560
|
|
|
561
561
|
if (panelType === strings.PANEL_TYPE_LEFT) {
|
|
562
562
|
panelDetail = monthLeft;
|
|
563
|
-
dateText = rangeStart ? formatFn(
|
|
563
|
+
dateText = rangeStart ? formatFn(compatibleParse(rangeStart, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
|
|
564
564
|
} else {
|
|
565
565
|
panelDetail = monthRight;
|
|
566
|
-
dateText = rangeEnd ? formatFn(
|
|
566
|
+
dateText = rangeEnd ? formatFn(compatibleParse(rangeEnd, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
|
|
567
567
|
}
|
|
568
568
|
|
|
569
569
|
const {
|
|
@@ -573,7 +573,7 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
573
573
|
const monthText = showDate ? formatFn(showDate, FORMAT_SWITCH_DATE) : '';
|
|
574
574
|
const timeText = showDate ? formatFn(showDate, formatTimePicker) : '';
|
|
575
575
|
|
|
576
|
-
const
|
|
576
|
+
const showSwitchIcon = _includesInstanceProperty(_context3 = ['default']).call(_context3, density);
|
|
577
577
|
|
|
578
578
|
const switchCls = classnames("".concat(prefixCls, "-switch"));
|
|
579
579
|
const dateCls = classnames({
|
|
@@ -594,7 +594,7 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
594
594
|
"aria-label": "Switch to date panel",
|
|
595
595
|
className: dateCls,
|
|
596
596
|
onClick: e => this.foundation.showDatePanel(panelType)
|
|
597
|
-
},
|
|
597
|
+
}, showSwitchIcon && /*#__PURE__*/React.createElement(IconCalendar, {
|
|
598
598
|
"aria-hidden": true
|
|
599
599
|
}), /*#__PURE__*/React.createElement("span", {
|
|
600
600
|
className: textCls
|
|
@@ -603,7 +603,7 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
603
603
|
"aria-label": "Switch to time panel",
|
|
604
604
|
className: timeCls,
|
|
605
605
|
onClick: e => this.foundation.showTimePicker(panelType, true)
|
|
606
|
-
},
|
|
606
|
+
}, showSwitchIcon && /*#__PURE__*/React.createElement(IconClock, {
|
|
607
607
|
"aria-hidden": true
|
|
608
608
|
}), /*#__PURE__*/React.createElement("span", {
|
|
609
609
|
className: textCls
|
|
@@ -147,6 +147,7 @@ declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
|
|
|
147
147
|
static Section: typeof Section;
|
|
148
148
|
formApi: FormApi;
|
|
149
149
|
constructor(props: BaseFormProps);
|
|
150
|
+
componentDidMount(): void;
|
|
150
151
|
componentWillUnmount(): void;
|
|
151
152
|
get adapter(): BaseFormAdapter<BaseFormProps, BaseFormState>;
|
|
152
153
|
get content(): React.ReactNode;
|
package/lib/es/form/baseForm.js
CHANGED
|
@@ -47,7 +47,7 @@ class Form extends BaseComponent {
|
|
|
47
47
|
|
|
48
48
|
super(props);
|
|
49
49
|
this.state = {
|
|
50
|
-
formId:
|
|
50
|
+
formId: ''
|
|
51
51
|
};
|
|
52
52
|
warning(Boolean(props.component && props.render), '[Semi Form] You should not use <Form component> and <Form render> in ths same time; <Form render> will be ignored');
|
|
53
53
|
warning(props.component && props.children && !isEmptyChildren(props.children), '[Semi Form] You should not use <Form component> and <Form>{children}</Form> in ths same time; <Form>{children}</Form> will be ignored');
|
|
@@ -62,9 +62,12 @@ class Form extends BaseComponent {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
componentDidMount() {
|
|
66
|
+
this.foundation.init();
|
|
67
|
+
}
|
|
68
|
+
|
|
65
69
|
componentWillUnmount() {
|
|
66
70
|
this.foundation.destroy();
|
|
67
|
-
this.foundation = null;
|
|
68
71
|
this.formApi = null;
|
|
69
72
|
}
|
|
70
73
|
|
|
@@ -89,6 +92,11 @@ class Form extends BaseComponent {
|
|
|
89
92
|
notifyReset: () => {
|
|
90
93
|
this.props.onReset();
|
|
91
94
|
},
|
|
95
|
+
initFormId: () => {
|
|
96
|
+
this.setState({
|
|
97
|
+
formId: getUuidv4()
|
|
98
|
+
});
|
|
99
|
+
},
|
|
92
100
|
getInitValues: () => this.props.initValues,
|
|
93
101
|
getFormProps: keys => {
|
|
94
102
|
if (typeof keys === 'undefined') {
|
|
@@ -380,9 +380,16 @@ function withField(Component, opts) {
|
|
|
380
380
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
381
381
|
return () => {};
|
|
382
382
|
} // log('register: ' + field);
|
|
383
|
+
// field value may change after field component mounted, we use ref value here to get changed value
|
|
383
384
|
|
|
384
385
|
|
|
385
|
-
|
|
386
|
+
const refValue = getVal();
|
|
387
|
+
updater.register(field, {
|
|
388
|
+
value: refValue,
|
|
389
|
+
error,
|
|
390
|
+
touched,
|
|
391
|
+
status
|
|
392
|
+
}, {
|
|
386
393
|
field,
|
|
387
394
|
fieldApi,
|
|
388
395
|
keepState,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { InputProps } from '../input';
|
|
4
|
-
import InputNumberFoundation, { InputNumberAdapter } from '@douyinfe/semi-foundation/lib/es/inputNumber/foundation';
|
|
4
|
+
import InputNumberFoundation, { BaseInputNumberState, InputNumberAdapter } from '@douyinfe/semi-foundation/lib/es/inputNumber/foundation';
|
|
5
5
|
import BaseComponent from '../_base/baseComponent';
|
|
6
6
|
import { strings } from '@douyinfe/semi-foundation/lib/es/inputNumber/constants';
|
|
7
7
|
import '@douyinfe/semi-foundation/lib/es/inputNumber/inputNumber.css';
|
|
@@ -40,11 +40,7 @@ export interface InputNumberProps extends InputProps {
|
|
|
40
40
|
onNumberChange?: (value: number, e?: React.ChangeEvent) => void;
|
|
41
41
|
onUpClick?: (value: string, e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
42
42
|
}
|
|
43
|
-
export interface InputNumberState {
|
|
44
|
-
value?: number | string;
|
|
45
|
-
number?: number | null;
|
|
46
|
-
focusing?: boolean;
|
|
47
|
-
hovering?: boolean;
|
|
43
|
+
export interface InputNumberState extends BaseInputNumberState {
|
|
48
44
|
}
|
|
49
45
|
declare class InputNumber extends BaseComponent<InputNumberProps, InputNumberState> {
|
|
50
46
|
static propTypes: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _noop from "lodash/noop";
|
|
2
|
+
import _isString from "lodash/isString";
|
|
2
3
|
import _isNaN from "lodash/isNaN";
|
|
3
4
|
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
|
|
4
5
|
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
@@ -271,6 +272,9 @@ class InputNumber extends BaseComponent {
|
|
|
271
272
|
},
|
|
272
273
|
setClickUpOrDown: value => {
|
|
273
274
|
this.clickUpOrDown = value;
|
|
275
|
+
},
|
|
276
|
+
updateStates: (states, callback) => {
|
|
277
|
+
this.setState(states, callback);
|
|
274
278
|
}
|
|
275
279
|
});
|
|
276
280
|
}
|
|
@@ -282,6 +286,7 @@ class InputNumber extends BaseComponent {
|
|
|
282
286
|
const {
|
|
283
287
|
focusing
|
|
284
288
|
} = this.state;
|
|
289
|
+
let newValue;
|
|
285
290
|
/**
|
|
286
291
|
* To determine whether the front and back are equal
|
|
287
292
|
* NaN need to check whether both are NaN
|
|
@@ -289,8 +294,9 @@ class InputNumber extends BaseComponent {
|
|
|
289
294
|
|
|
290
295
|
if (value !== prevProps.value && !isBothNaN(value, prevProps.value)) {
|
|
291
296
|
if (isNullOrUndefined(value) || value === '') {
|
|
292
|
-
|
|
293
|
-
|
|
297
|
+
newValue = '';
|
|
298
|
+
this.foundation.updateStates({
|
|
299
|
+
value: newValue,
|
|
294
300
|
number: null
|
|
295
301
|
});
|
|
296
302
|
} else {
|
|
@@ -346,33 +352,42 @@ class InputNumber extends BaseComponent {
|
|
|
346
352
|
|
|
347
353
|
if (this.clickUpOrDown) {
|
|
348
354
|
obj.value = this.foundation.doFormat(valueStr, true);
|
|
355
|
+
newValue = obj.value;
|
|
349
356
|
}
|
|
350
357
|
|
|
351
|
-
this.
|
|
358
|
+
this.foundation.updateStates(obj, () => this.adapter.restoreCursor());
|
|
352
359
|
} else if (!_isNaN(toNum)) {
|
|
353
360
|
// Update input content when controlled input is illegal and not NaN
|
|
354
|
-
this.
|
|
355
|
-
|
|
361
|
+
newValue = this.foundation.doFormat(toNum, false);
|
|
362
|
+
this.foundation.updateStates({
|
|
363
|
+
value: newValue
|
|
356
364
|
});
|
|
357
365
|
} else {
|
|
358
366
|
// Update input content when controlled input NaN
|
|
359
|
-
this.
|
|
360
|
-
|
|
367
|
+
newValue = this.foundation.doFormat(valueStr, false);
|
|
368
|
+
this.foundation.updateStates({
|
|
369
|
+
value: newValue
|
|
361
370
|
});
|
|
362
371
|
}
|
|
363
372
|
} else if (this.foundation.isValidNumber(parsedNum)) {
|
|
364
|
-
this.
|
|
373
|
+
newValue = this.foundation.doFormat(parsedNum);
|
|
374
|
+
this.foundation.updateStates({
|
|
365
375
|
number: parsedNum,
|
|
366
|
-
value:
|
|
376
|
+
value: newValue
|
|
367
377
|
});
|
|
368
378
|
} else {
|
|
369
379
|
// Invalid digital analog blurring effect instead of controlled failure
|
|
370
|
-
|
|
380
|
+
newValue = '';
|
|
381
|
+
this.foundation.updateStates({
|
|
371
382
|
number: null,
|
|
372
|
-
value:
|
|
383
|
+
value: newValue
|
|
373
384
|
});
|
|
374
385
|
}
|
|
375
386
|
}
|
|
387
|
+
|
|
388
|
+
if (_isString(newValue) && newValue !== String(this.props.value)) {
|
|
389
|
+
this.foundation.notifyChange(newValue, null);
|
|
390
|
+
}
|
|
376
391
|
}
|
|
377
392
|
|
|
378
393
|
if (!this.clickUpOrDown) {
|
|
@@ -164,6 +164,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
164
164
|
componentDidUpdate(prevProps: TooltipProps, prevState: TooltipState): void;
|
|
165
165
|
renderIcon: () => any;
|
|
166
166
|
handlePortalInnerClick: (e: React.MouseEvent) => void;
|
|
167
|
+
handlePortalMouseDown: (e: React.MouseEvent) => void;
|
|
167
168
|
handlePortalInnerKeyDown: (e: React.KeyboardEvent) => void;
|
|
168
169
|
renderContentNode: (content: TooltipProps['content']) => React.ReactNode;
|
|
169
170
|
renderPortal: () => JSX.Element;
|
package/lib/es/tooltip/index.js
CHANGED
|
@@ -138,6 +138,12 @@ export default class Tooltip extends BaseComponent {
|
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
+
this.handlePortalMouseDown = e => {
|
|
142
|
+
if (this.props.stopPropagation) {
|
|
143
|
+
stopPropagation(e);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
141
147
|
this.handlePortalInnerKeyDown = e => {
|
|
142
148
|
this.foundation.handleContainerKeydown(e);
|
|
143
149
|
};
|
|
@@ -225,6 +231,7 @@ export default class Tooltip extends BaseComponent {
|
|
|
225
231
|
style: portalInnerStyle,
|
|
226
232
|
ref: this.setContainerEl,
|
|
227
233
|
onClick: this.handlePortalInnerClick,
|
|
234
|
+
onMouseDown: this.handlePortalMouseDown,
|
|
228
235
|
onKeyDown: this.handlePortalInnerKeyDown
|
|
229
236
|
}, inner));
|
|
230
237
|
};
|
|
@@ -457,15 +464,11 @@ export default class Tooltip extends BaseComponent {
|
|
|
457
464
|
}
|
|
458
465
|
};
|
|
459
466
|
|
|
460
|
-
|
|
461
|
-
capture: true
|
|
462
|
-
});
|
|
467
|
+
window.addEventListener('mousedown', this.clickOutsideHandler);
|
|
463
468
|
},
|
|
464
469
|
unregisterClickOutsideHandler: () => {
|
|
465
470
|
if (this.clickOutsideHandler) {
|
|
466
|
-
|
|
467
|
-
capture: true
|
|
468
|
-
});
|
|
471
|
+
window.removeEventListener('mousedown', this.clickOutsideHandler);
|
|
469
472
|
this.clickOutsideHandler = null;
|
|
470
473
|
}
|
|
471
474
|
},
|
package/lib/es/transfer/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import cls from 'classnames';
|
|
|
19
19
|
import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
|
|
20
20
|
import PropTypes from 'prop-types';
|
|
21
21
|
import TransferFoundation from '@douyinfe/semi-foundation/lib/es/transfer/foundation';
|
|
22
|
-
import { _generateDataByType, _generateSelectedItems } from '@douyinfe/semi-foundation/lib/es/transfer/
|
|
22
|
+
import { _generateDataByType, _generateSelectedItems } from '@douyinfe/semi-foundation/lib/es/transfer/transferUtils';
|
|
23
23
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/transfer/constants';
|
|
24
24
|
import '@douyinfe/semi-foundation/lib/es/transfer/transfer.css';
|
|
25
25
|
import BaseComponent from '../_base/baseComponent';
|
|
@@ -40,7 +40,7 @@ import TagInput from '../tagInput';
|
|
|
40
40
|
import { isSemiIcon } from '../_utils';
|
|
41
41
|
import { IconChevronDown, IconClear, IconSearch } from '@douyinfe/semi-icons';
|
|
42
42
|
const prefixcls = cssClasses.PREFIX;
|
|
43
|
-
const prefixTree = cssClasses.
|
|
43
|
+
const prefixTree = cssClasses.PREFIX_TREE;
|
|
44
44
|
const key = 0;
|
|
45
45
|
|
|
46
46
|
class TreeSelect extends BaseComponent {
|