@douyinfe/semi-ui 2.6.0 → 2.7.1

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.
Files changed (94) hide show
  1. package/_base/_story/index.stories.js +2 -6
  2. package/_portal/_story/portal.stories.js +1 -5
  3. package/_utils/hooks/usePrevFocus.ts +1 -0
  4. package/button/__test__/button.test.js +7 -0
  5. package/button/buttonGroup.tsx +5 -2
  6. package/cascader/__test__/cascader.test.js +159 -81
  7. package/cascader/_story/cascader.stories.js +36 -23
  8. package/cascader/index.tsx +26 -5
  9. package/datePicker/_story/v2/InsetInput.jsx +104 -0
  10. package/datePicker/_story/v2/InsetInputE2E.jsx +69 -0
  11. package/datePicker/_story/v2/index.js +2 -0
  12. package/datePicker/dateInput.tsx +95 -9
  13. package/datePicker/datePicker.tsx +89 -15
  14. package/datePicker/index.tsx +15 -0
  15. package/datePicker/insetInput.tsx +76 -0
  16. package/datePicker/monthsGrid.tsx +14 -7
  17. package/dist/css/semi.css +109 -7
  18. package/dist/css/semi.min.css +1 -1
  19. package/dist/umd/semi-ui.js +925 -152
  20. package/dist/umd/semi-ui.js.map +1 -1
  21. package/dist/umd/semi-ui.min.js +1 -1
  22. package/dist/umd/semi-ui.min.js.map +1 -1
  23. package/form/hooks/useFormApi.tsx +3 -2
  24. package/input/_story/input.stories.js +23 -1
  25. package/lib/cjs/_utils/hooks/usePrevFocus.js +1 -0
  26. package/lib/cjs/button/buttonGroup.d.ts +1 -0
  27. package/lib/cjs/button/buttonGroup.js +6 -2
  28. package/lib/cjs/cascader/index.d.ts +1 -0
  29. package/lib/cjs/cascader/index.js +38 -9
  30. package/lib/cjs/datePicker/dateInput.d.ts +9 -2
  31. package/lib/cjs/datePicker/dateInput.js +92 -9
  32. package/lib/cjs/datePicker/datePicker.d.ts +7 -2
  33. package/lib/cjs/datePicker/datePicker.js +123 -18
  34. package/lib/cjs/datePicker/index.js +24 -2
  35. package/lib/cjs/datePicker/insetInput.d.ts +21 -0
  36. package/lib/cjs/datePicker/insetInput.js +80 -0
  37. package/lib/cjs/datePicker/monthsGrid.js +19 -7
  38. package/lib/cjs/form/hooks/useFormApi.d.ts +2 -1
  39. package/lib/cjs/modal/useModal/HookModal.js +2 -0
  40. package/lib/cjs/radio/radioGroup.js +6 -0
  41. package/lib/cjs/select/index.js +5 -2
  42. package/lib/cjs/tag/group.d.ts +2 -0
  43. package/lib/cjs/tag/group.js +4 -2
  44. package/lib/cjs/tooltip/index.js +1 -1
  45. package/lib/cjs/tree/index.js +5 -3
  46. package/lib/cjs/tree/interface.d.ts +1 -0
  47. package/lib/cjs/tree/nodeList.js +3 -1
  48. package/lib/cjs/treeSelect/index.js +11 -3
  49. package/lib/es/_utils/hooks/usePrevFocus.js +2 -0
  50. package/lib/es/button/buttonGroup.d.ts +1 -0
  51. package/lib/es/button/buttonGroup.js +5 -2
  52. package/lib/es/cascader/index.d.ts +1 -0
  53. package/lib/es/cascader/index.js +35 -6
  54. package/lib/es/datePicker/dateInput.d.ts +9 -2
  55. package/lib/es/datePicker/dateInput.js +91 -9
  56. package/lib/es/datePicker/datePicker.d.ts +7 -2
  57. package/lib/es/datePicker/datePicker.js +124 -18
  58. package/lib/es/datePicker/index.js +20 -0
  59. package/lib/es/datePicker/insetInput.d.ts +21 -0
  60. package/lib/es/datePicker/insetInput.js +65 -0
  61. package/lib/es/datePicker/monthsGrid.js +19 -7
  62. package/lib/es/form/hooks/useFormApi.d.ts +2 -1
  63. package/lib/es/modal/useModal/HookModal.js +2 -0
  64. package/lib/es/radio/radioGroup.js +6 -0
  65. package/lib/es/select/index.js +5 -2
  66. package/lib/es/tag/group.d.ts +2 -0
  67. package/lib/es/tag/group.js +4 -2
  68. package/lib/es/tooltip/index.js +1 -1
  69. package/lib/es/tree/index.js +5 -3
  70. package/lib/es/tree/interface.d.ts +1 -0
  71. package/lib/es/tree/nodeList.js +3 -1
  72. package/lib/es/treeSelect/index.js +11 -3
  73. package/modal/_story/modal.stories.js +93 -1
  74. package/modal/useModal/HookModal.tsx +1 -0
  75. package/notification/_story/useNotification/index.jsx +21 -7
  76. package/package.json +9 -9
  77. package/radio/__test__/radioGroup.test.jsx +9 -1
  78. package/radio/_story/radio.stories.js +22 -1
  79. package/radio/radioGroup.tsx +9 -0
  80. package/select/_story/select.stories.js +73 -2
  81. package/select/index.tsx +5 -3
  82. package/table/_story/v2/FixedMemoryLeak/index.jsx +33 -0
  83. package/table/_story/v2/index.js +2 -1
  84. package/tag/group.tsx +5 -3
  85. package/toast/_story/toast.stories.js +41 -0
  86. package/tooltip/index.tsx +1 -1
  87. package/tree/__test__/tree.test.js +87 -2
  88. package/tree/_story/tree.stories.js +65 -5
  89. package/tree/index.tsx +4 -2
  90. package/tree/interface.ts +1 -0
  91. package/tree/nodeList.tsx +3 -2
  92. package/treeSelect/__test__/treeSelect.test.js +28 -0
  93. package/treeSelect/_story/treeSelect.stories.js +55 -2
  94. package/treeSelect/index.tsx +14 -3
@@ -20,6 +20,8 @@ var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-j
20
20
 
21
21
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
22
22
 
23
+ var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
24
+
23
25
  var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
24
26
 
25
27
  var _get2 = _interopRequireDefault(require("lodash/get"));
@@ -65,6 +67,10 @@ require("@douyinfe/semi-foundation/lib/cjs/datePicker/datePicker.css");
65
67
  /* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/interactive-supports-focus */
66
68
 
67
69
  /* eslint-disable max-len */
70
+
71
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
72
+
73
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
68
74
  class DatePicker extends _baseComponent.default {
69
75
  constructor(props) {
70
76
  var _this;
@@ -102,6 +108,8 @@ class DatePicker extends _baseComponent.default {
102
108
  return _this.foundation.handleInputChange(...arguments);
103
109
  };
104
110
 
111
+ this.handleInsetInputChange = options => this.foundation.handleInsetInputChange(options);
112
+
105
113
  this.handleInputComplete = v => this.foundation.handleInputComplete(v);
106
114
 
107
115
  this.handleInputBlur = e => this.foundation.handleInputBlur((0, _get2.default)(e, 'nativeEvent.target.value'), e);
@@ -130,6 +138,30 @@ class DatePicker extends _baseComponent.default {
130
138
  }
131
139
  };
132
140
 
141
+ this.handleInsetDateFocus = (e, rangeType) => {
142
+ const monthGridFoundation = (0, _get2.default)(this, 'monthGrid.current.foundation');
143
+
144
+ if (monthGridFoundation) {
145
+ monthGridFoundation.showDatePanel(_constants.strings.PANEL_TYPE_LEFT);
146
+ monthGridFoundation.showDatePanel(_constants.strings.PANEL_TYPE_RIGHT);
147
+ }
148
+
149
+ this.handleInputFocus(e, rangeType);
150
+ };
151
+
152
+ this.handleInsetTimeFocus = () => {
153
+ const monthGridFoundation = (0, _get2.default)(this, 'monthGrid.current.foundation');
154
+
155
+ if (monthGridFoundation) {
156
+ monthGridFoundation.showTimePicker(_constants.strings.PANEL_TYPE_LEFT);
157
+ monthGridFoundation.showTimePicker(_constants.strings.PANEL_TYPE_RIGHT);
158
+ }
159
+ };
160
+
161
+ this.handlePanelVisibleChange = visible => {
162
+ this.foundation.handlePanelVisibleChange(visible);
163
+ };
164
+
133
165
  this.handleConfirm = e => this.foundation.handleConfirm();
134
166
 
135
167
  this.handleCancel = e => this.foundation.handleCancel();
@@ -153,19 +185,43 @@ class DatePicker extends _baseComponent.default {
153
185
  dropdownStyle,
154
186
  density,
155
187
  topSlot,
156
- bottomSlot
188
+ bottomSlot,
189
+ insetInput,
190
+ type,
191
+ format,
192
+ rangeSeparator
157
193
  } = this.props;
194
+ const {
195
+ insetInputValue,
196
+ value
197
+ } = this.state;
158
198
  const wrapCls = (0, _classnames.default)(_constants.cssClasses.PREFIX, {
159
199
  [_constants.cssClasses.PANEL_YAM]: this.adapter.typeIsYearOrMonth(),
160
200
  ["".concat(_constants.cssClasses.PREFIX, "-compact")]: density === 'compact'
161
201
  }, dropdownClassName);
202
+ const insetInputProps = {
203
+ dateFnsLocale,
204
+ format,
205
+ insetInputValue,
206
+ rangeSeparator,
207
+ type,
208
+ value: value,
209
+ handleInsetDateFocus: this.handleInsetDateFocus,
210
+ handleInsetTimeFocus: this.handleInsetTimeFocus,
211
+ onInsetInputChange: this.handleInsetInputChange,
212
+ rangeInputStartRef: this.rangeInputStartRef,
213
+ rangeInputEndRef: this.rangeInputEndRef,
214
+ density
215
+ };
162
216
  return /*#__PURE__*/_react.default.createElement("div", {
163
217
  ref: this.panelRef,
164
218
  className: wrapCls,
165
219
  style: dropdownStyle
166
220
  }, topSlot && /*#__PURE__*/_react.default.createElement("div", {
167
221
  className: "".concat(_constants.cssClasses.PREFIX, "-topSlot")
168
- }, topSlot), this.adapter.typeIsYearOrMonth() ? this.renderYearMonthPanel(locale, localeCode) : this.renderMonthGrid(locale, localeCode, dateFnsLocale), this.renderQuickControls(), bottomSlot && /*#__PURE__*/_react.default.createElement("div", {
222
+ }, topSlot), insetInput && /*#__PURE__*/_react.default.createElement(_dateInput.default, (0, _assign.default)({}, insetInputProps, {
223
+ insetInput: true
224
+ })), this.adapter.typeIsYearOrMonth() ? this.renderYearMonthPanel(locale, localeCode) : this.renderMonthGrid(locale, localeCode, dateFnsLocale), this.renderQuickControls(), bottomSlot && /*#__PURE__*/_react.default.createElement("div", {
169
225
  className: "".concat(_constants.cssClasses.PREFIX, "-bottomSlot")
170
226
  }, bottomSlot), this.renderFooter(locale, localeCode));
171
227
  };
@@ -229,7 +285,8 @@ class DatePicker extends _baseComponent.default {
229
285
  position: position,
230
286
  visible: panelShow,
231
287
  stopPropagation: stopPropagation,
232
- spacing: spacing
288
+ spacing: spacing,
289
+ onVisibleChange: this.handlePanelVisibleChange
233
290
  }, children);
234
291
  };
235
292
 
@@ -242,7 +299,9 @@ class DatePicker extends _baseComponent.default {
242
299
  prevTimeZone: null,
243
300
  motionEnd: false,
244
301
  rangeInputFocus: undefined,
245
- autofocus: props.autoFocus || this.isRangeType(props.type, props.triggerRender) && (props.open || props.defaultOpen)
302
+ autofocus: props.autoFocus || this.isRangeType(props.type, props.triggerRender) && (props.open || props.defaultOpen),
303
+ insetInputValue: null,
304
+ triggerDisabled: undefined
246
305
  };
247
306
  this.adapter.setCache('cachedSelectedValue', null);
248
307
  this.triggerElRef = /*#__PURE__*/_react.default.createRef();
@@ -345,6 +404,17 @@ class DatePicker extends _baseComponent.default {
345
404
  inputValue
346
405
  });
347
406
  },
407
+ updateInsetInputValue: insetInputValue => {
408
+ const {
409
+ insetInput
410
+ } = this.props;
411
+
412
+ if (insetInput && !(0, _isEqual2.default)(insetInputValue, this.state.insetInputValue)) {
413
+ this.setState({
414
+ insetInputValue
415
+ });
416
+ }
417
+ },
348
418
  needConfirm: () => {
349
419
  var _context;
350
420
 
@@ -415,7 +485,36 @@ class DatePicker extends _baseComponent.default {
415
485
  }
416
486
  },
417
487
  couldPanelClosed: () => this.focusRecordsRef.current.rangeStart && this.focusRecordsRef.current.rangeEnd,
418
- isEventTarget: e => e && e.target === e.currentTarget
488
+ isEventTarget: e => e && e.target === e.currentTarget,
489
+ setInsetInputFocus: () => {
490
+ const {
491
+ rangeInputFocus
492
+ } = this.state;
493
+
494
+ switch (rangeInputFocus) {
495
+ case 'rangeEnd':
496
+ if (document.activeElement !== this.rangeInputEndRef.current) {
497
+ const inputEndNode = (0, _get2.default)(this, 'rangeInputEndRef.current');
498
+ inputEndNode && inputEndNode.focus();
499
+ }
500
+
501
+ break;
502
+
503
+ case 'rangeStart':
504
+ default:
505
+ if (document.activeElement !== this.rangeInputStartRef.current) {
506
+ const inputStartNode = (0, _get2.default)(this, 'rangeInputStartRef.current');
507
+ inputStartNode && inputStartNode.focus();
508
+ }
509
+
510
+ break;
511
+ }
512
+ },
513
+ setTriggerDisabled: disabled => {
514
+ this.setState({
515
+ triggerDisabled: disabled
516
+ });
517
+ }
419
518
  });
420
519
  }
421
520
 
@@ -473,7 +572,8 @@ class DatePicker extends _baseComponent.default {
473
572
  syncSwitchMonth,
474
573
  onPanelChange,
475
574
  timeZone,
476
- triggerRender
575
+ triggerRender,
576
+ insetInput
477
577
  } = this.props;
478
578
  const {
479
579
  value,
@@ -521,7 +621,8 @@ class DatePicker extends _baseComponent.default {
521
621
  onPanelChange: onPanelChange,
522
622
  timeZone: timeZone,
523
623
  focusRecordsRef: this.focusRecordsRef,
524
- triggerRender: triggerRender
624
+ triggerRender: triggerRender,
625
+ insetInput: insetInput
525
626
  });
526
627
  }
527
628
 
@@ -557,20 +658,23 @@ class DatePicker extends _baseComponent.default {
557
658
  triggerRender,
558
659
  size,
559
660
  inputReadOnly,
560
- rangeSeparator
661
+ rangeSeparator,
662
+ insetInput
561
663
  } = this.props;
562
664
  const {
563
665
  value,
564
666
  inputValue,
565
- rangeInputFocus
667
+ rangeInputFocus,
668
+ triggerDisabled
566
669
  } = this.state; // This class is not needed when triggerRender is function
567
670
 
568
671
  const isRangeType = this.isRangeType(type, triggerRender);
672
+ const inputDisabled = disabled || insetInput && triggerDisabled;
569
673
  const inputCls = (0, _classnames.default)("".concat(_constants.cssClasses.PREFIX, "-input"), {
570
674
  ["".concat(_constants.cssClasses.PREFIX, "-range-input")]: isRangeType,
571
675
  [(0, _concat.default)(_context3 = "".concat(_constants.cssClasses.PREFIX, "-range-input-")).call(_context3, size)]: isRangeType && size,
572
- ["".concat(_constants.cssClasses.PREFIX, "-range-input-active")]: isRangeType && rangeInputFocus && !disabled,
573
- ["".concat(_constants.cssClasses.PREFIX, "-range-input-disabled")]: isRangeType && disabled,
676
+ ["".concat(_constants.cssClasses.PREFIX, "-range-input-active")]: isRangeType && rangeInputFocus && !inputDisabled,
677
+ ["".concat(_constants.cssClasses.PREFIX, "-range-input-disabled")]: isRangeType && inputDisabled,
574
678
  [(0, _concat.default)(_context4 = "".concat(_constants.cssClasses.PREFIX, "-range-input-")).call(_context4, validateStatus)]: isRangeType && validateStatus
575
679
  });
576
680
  const phText = placeholder || locale.placeholder[type]; // i18n
@@ -578,9 +682,9 @@ class DatePicker extends _baseComponent.default {
578
682
 
579
683
  const props = (0, _assign.default)((0, _assign.default)({}, extraProps), {
580
684
  placeholder: phText,
581
- disabled,
685
+ disabled: inputDisabled,
582
686
  inputValue,
583
- value,
687
+ value: value,
584
688
  onChange: this.handleInputChange,
585
689
  onEnterPress: this.handleInputComplete,
586
690
  // TODO: remove in next major version
@@ -593,7 +697,7 @@ class DatePicker extends _baseComponent.default {
593
697
  format,
594
698
  multiple,
595
699
  validateStatus,
596
- inputReadOnly,
700
+ inputReadOnly: inputReadOnly || insetInput,
597
701
  // onClick: this.handleOpenPanel,
598
702
  onBlur: this.handleInputBlur,
599
703
  onFocus: this.handleInputFocus,
@@ -602,13 +706,13 @@ class DatePicker extends _baseComponent.default {
602
706
  size,
603
707
  autofocus: this.state.autofocus,
604
708
  dateFnsLocale,
605
- rangeInputStartRef: this.rangeInputStartRef,
606
- rangeInputEndRef: this.rangeInputEndRef,
607
709
  rangeInputFocus,
608
710
  rangeSeparator,
609
711
  onRangeBlur: this.handleRangeInputBlur,
610
712
  onRangeClear: this.handleRangeInputClear,
611
- onRangeEndTabPress: this.handleRangeEndTabPress
713
+ onRangeEndTabPress: this.handleRangeEndTabPress,
714
+ rangeInputStartRef: insetInput ? null : this.rangeInputStartRef,
715
+ rangeInputEndRef: insetInput ? null : this.rangeInputEndRef
612
716
  });
613
717
  return /*#__PURE__*/_react.default.createElement("div", {
614
718
  // tooltip will mount a11y props to children
@@ -757,5 +861,6 @@ DatePicker.defaultProps = {
757
861
  spacing: _constants.numbers.SPACING,
758
862
  autoSwitchDate: true,
759
863
  syncSwitchMonth: false,
760
- rangeSeparator: _constants.strings.DEFAULT_SEPARATOR_RANGE
864
+ rangeSeparator: _constants.strings.DEFAULT_SEPARATOR_RANGE,
865
+ insetInput: false
761
866
  };
@@ -14,13 +14,17 @@ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
14
14
 
15
15
  var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
16
16
 
17
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
18
+
17
19
  var _react = _interopRequireDefault(require("react"));
18
20
 
19
21
  var _object = require("@douyinfe/semi-foundation/lib/cjs/utils/object");
20
22
 
23
+ var _constants = require("@douyinfe/semi-foundation/lib/cjs/datePicker/constants");
24
+
21
25
  var _datePicker = _interopRequireDefault(require("./datePicker"));
22
26
 
23
- var _context = _interopRequireDefault(require("../configProvider/context"));
27
+ var _context2 = _interopRequireDefault(require("../configProvider/context"));
24
28
 
25
29
  var _localeConsumer = _interopRequireDefault(require("../locale/localeConsumer"));
26
30
 
@@ -47,7 +51,25 @@ var _default = (0, _object.forwardStatics)( /*#__PURE__*/_react.default.forwardR
47
51
  propsObj.rangeSeparator = " ".concat((0, _trim.default)(rangeSeparator).call(rangeSeparator), " ");
48
52
  }
49
53
 
50
- return /*#__PURE__*/_react.default.createElement(_context.default.Consumer, null, _ref => {
54
+ if (propsObj.insetInput) {
55
+ var _context;
56
+
57
+ if (!propsObj.position) {
58
+ propsObj.position = _constants.strings.POSITION_INLINE_INPUT;
59
+ }
60
+ /**
61
+ * When insetInput is `true` and `position` includes `over`, use 1px `spacing` to solve the problem of border-radius leakage in the upper left corner
62
+ *
63
+ * @see https://user-images.githubusercontent.com/26477537/158817185-126a5f33-41f7-414a-8e36-8d1be2dda5cd.png
64
+ */
65
+
66
+
67
+ if ((0, _includes.default)(_context = propsObj.position).call(_context, 'Over') && !propsObj.spacing) {
68
+ propsObj.spacing = _constants.numbers.SPACING_INSET_INPUT;
69
+ }
70
+ }
71
+
72
+ return /*#__PURE__*/_react.default.createElement(_context2.default.Consumer, null, _ref => {
51
73
  let {
52
74
  timeZone
53
75
  } = _ref;
@@ -0,0 +1,21 @@
1
+ import { InsetInputValue, Type, InsetInputChangeFoundationProps } from '@douyinfe/semi-foundation/lib/cjs/datePicker/inputFoundation';
2
+ import { InputProps } from '../input';
3
+ export interface InsetDateInputProps {
4
+ forwardRef: InputProps['forwardRef'];
5
+ insetInputValue: InsetInputValue;
6
+ placeholder: string;
7
+ valuePath: string;
8
+ onChange: (options: InsetInputChangeFoundationProps) => void;
9
+ onFocus: InputProps['onFocus'];
10
+ }
11
+ export interface InsetTimeInputProps {
12
+ disabled: boolean;
13
+ insetInputValue: InsetInputValue;
14
+ placeholder: string;
15
+ valuePath: string;
16
+ type: Type;
17
+ onChange: (options: InsetInputChangeFoundationProps) => void;
18
+ onFocus: InputProps['onFocus'];
19
+ }
20
+ export declare function InsetDateInput(props: InsetDateInputProps): JSX.Element;
21
+ export declare function InsetTimeInput(props: InsetTimeInputProps): JSX.Element;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ exports.InsetDateInput = InsetDateInput;
12
+ exports.InsetTimeInput = InsetTimeInput;
13
+
14
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
15
+
16
+ var _get2 = _interopRequireDefault(require("lodash/get"));
17
+
18
+ var _react = _interopRequireDefault(require("react"));
19
+
20
+ var _input = _interopRequireDefault(require("../input"));
21
+
22
+ function InsetDateInput(props) {
23
+ const {
24
+ insetInputValue,
25
+ valuePath,
26
+ onFocus,
27
+ onChange,
28
+ placeholder,
29
+ forwardRef
30
+ } = props;
31
+ const value = (0, _get2.default)(insetInputValue, valuePath);
32
+ return /*#__PURE__*/_react.default.createElement(_input.default, {
33
+ value: value,
34
+ onChange: (value, event) => {
35
+ onChange({
36
+ value,
37
+ event,
38
+ insetInputValue,
39
+ valuePath
40
+ });
41
+ },
42
+ onFocus: onFocus,
43
+ placeholder: placeholder,
44
+ ref: forwardRef
45
+ });
46
+ }
47
+
48
+ function InsetTimeInput(props) {
49
+ const {
50
+ insetInputValue,
51
+ valuePath,
52
+ type,
53
+ onFocus,
54
+ onChange,
55
+ placeholder,
56
+ disabled
57
+ } = props;
58
+
59
+ const _isTimeType = (0, _includes.default)(type).call(type, 'Time');
60
+
61
+ if (!_isTimeType) {
62
+ return null;
63
+ }
64
+
65
+ const value = (0, _get2.default)(insetInputValue, valuePath);
66
+ return /*#__PURE__*/_react.default.createElement(_input.default, {
67
+ value: value,
68
+ onChange: (value, event) => {
69
+ onChange({
70
+ value,
71
+ event,
72
+ insetInputValue,
73
+ valuePath
74
+ });
75
+ },
76
+ onFocus: onFocus,
77
+ placeholder: placeholder,
78
+ disabled: disabled
79
+ });
80
+ }
@@ -56,6 +56,8 @@ var _getDefaultFormatToken = require("@douyinfe/semi-foundation/lib/cjs/datePick
56
56
 
57
57
  /* eslint-disable jsx-a11y/interactive-supports-focus,jsx-a11y/click-events-have-key-events */
58
58
 
59
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
60
+
59
61
  /* eslint-disable react/no-did-update-set-state */
60
62
 
61
63
  /* eslint-disable max-len */
@@ -317,6 +319,9 @@ class MonthsGrid extends _baseComponent.default {
317
319
  monthRight,
318
320
  currentPanelHeight
319
321
  } = this.state;
322
+ const {
323
+ insetInput
324
+ } = this.props;
320
325
  const panelDetail = panelType === _constants.strings.PANEL_TYPE_RIGHT ? monthRight : monthLeft;
321
326
  const {
322
327
  isTimePickerOpen,
@@ -339,7 +344,7 @@ class MonthsGrid extends _baseComponent.default {
339
344
  style.minWidth = wrap.getBoundingClientRect().width;
340
345
  }
341
346
 
342
- if (this.leftIsYearOrTime() && this.rightIsYearOrTime()) {
347
+ if (this.leftIsYearOrTime() && this.rightIsYearOrTime() && !insetInput) {
343
348
  /**
344
349
  * left和right同时为tpk时,panel会有一个minHeight
345
350
  * 如果缓存的currentPanelHeight为0,则需要计算滚动列表的高度
@@ -349,7 +354,7 @@ class MonthsGrid extends _baseComponent.default {
349
354
  * When left and right are tpk at the same time, the panel will have a minHeight
350
355
  * If the cached currentPanelHeight is 0, you need to calculate the height of the scrolling list
351
356
  * If there is a cached value, use currentPanelHeight (if this height is less than the actual value, it will affect the number of cycles in the ScrollList to render the list)
352
- * See packages/semi-foundation/scrollList/itemF oundation.js initWheelList function
357
+ * See packages/semi-foundation/scrollList/itemFoundation.js initWheelList function
353
358
  */
354
359
  style.minHeight = currentPanelHeight ? currentPanelHeight : this.calcScrollListHeight();
355
360
  }
@@ -357,10 +362,14 @@ class MonthsGrid extends _baseComponent.default {
357
362
  monthCls = (0, _classnames.default)(monthCls, "".concat(prefixCls, "-yam-showing"));
358
363
  }
359
364
 
365
+ const _isDatePanelOpen = !(isYearPickerOpen || isTimePickerOpen);
366
+
367
+ const xOpenType = _isDatePanelOpen ? 'date' : isYearPickerOpen ? 'year' : 'time';
360
368
  return /*#__PURE__*/_react.default.createElement("div", {
361
369
  className: monthCls,
362
370
  key: panelType,
363
- style: style
371
+ style: style,
372
+ "x-open-type": xOpenType
364
373
  }, yearAndMonthLayer, timePickerLayer, this.foundation.isRangeType() ? panelContent : isYearPickerOpen || isTimePickerOpen ? null : panelContent, this.renderSwitch(panelType));
365
374
  }
366
375
 
@@ -569,10 +578,11 @@ class MonthsGrid extends _baseComponent.default {
569
578
  locale,
570
579
  disabledTimePicker,
571
580
  density,
572
- dateFnsLocale
573
- } = this.props; // Type: date, dateRange, year, month, no rendering required
581
+ dateFnsLocale,
582
+ insetInput
583
+ } = this.props; // Type: date, dateRange, year, month, inset input no rendering required
574
584
 
575
- if (!(0, _includes.default)(type).call(type, 'Time')) {
585
+ if (!(0, _includes.default)(type).call(type, 'Time') || insetInput) {
576
586
  return null;
577
587
  } // switch year/month & time
578
588
 
@@ -643,7 +653,8 @@ class MonthsGrid extends _baseComponent.default {
643
653
  monthRight
644
654
  } = this.state;
645
655
  const {
646
- type
656
+ type,
657
+ insetInput
647
658
  } = this.props;
648
659
  const monthGridCls = (0, _classnames.default)({
649
660
  ["".concat(prefixCls, "-month-grid")]: true
@@ -665,6 +676,7 @@ class MonthsGrid extends _baseComponent.default {
665
676
  className: monthGridCls,
666
677
  "x-type": type,
667
678
  "x-panel-yearandmonth-open-type": yearOpenType,
679
+ "x-insetInput": insetInput ? "true" : "false",
668
680
  ref: current => this.cacheRefCurrent('monthGrid', current)
669
681
  }, content);
670
682
  }
@@ -1 +1,2 @@
1
- export default function useFormApi(): import("@douyinfe/semi-foundation/lib/cjs/form/interface").BaseFormApi<any>;
1
+ import { BaseFormApi } from '@douyinfe/semi-foundation/lib/cjs/form/interface';
2
+ export default function useFormApi<T extends Record<string, any> = any>(): BaseFormApi<T>;
@@ -57,6 +57,8 @@ const HookModal = (_a, ref) => {
57
57
  const {
58
58
  motion
59
59
  } = props;
60
+ /* istanbul ignore next */
61
+
60
62
  const mergedMotion = typeof motion === 'undefined' || motion ? (0, _assign.default)((0, _assign.default)({}, motion), {
61
63
  didLeave: function () {
62
64
  const didLeave = (0, _get2.default)(props.motion, 'didLeave');
@@ -55,6 +55,12 @@ class RadioGroup extends _baseComponent.default {
55
55
  }
56
56
 
57
57
  componentDidUpdate(prevProps) {
58
+ if (typeof prevProps.value === 'number' && isNaN(prevProps.value) && typeof this.props.value === 'number' && isNaN(this.props.value)) {
59
+ // `NaN === NaN` returns false, and this will fail the next if check
60
+ // therefore triggering an infinite loop
61
+ return;
62
+ }
63
+
58
64
  if (prevProps.value !== this.props.value) {
59
65
  this.foundation.handlePropValueChange(this.props.value);
60
66
  }
@@ -742,7 +742,9 @@ class Select extends _baseComponent.default {
742
742
  });
743
743
  }
744
744
 
745
- const tags = (0, _map2.default)(selectedItems).call(selectedItems, (item, i) => {
745
+ const mapItems = maxTagCount ? (0, _slice.default)(selectedItems).call(selectedItems, 0, maxTagCount) : selectedItems; // no need to render rest tag when maxTagCount is setting
746
+
747
+ const tags = (0, _map2.default)(mapItems).call(mapItems, (item, i) => {
746
748
  const label = item[0];
747
749
  const {
748
750
  value
@@ -800,12 +802,13 @@ class Select extends _baseComponent.default {
800
802
  const placeholderText = placeholder && !inputValue ? /*#__PURE__*/_react.default.createElement("span", {
801
803
  className: spanCls
802
804
  }, placeholder) : null;
803
- const n = tags.length > maxTagCount ? maxTagCount : undefined;
805
+ const n = selectedItems.length > maxTagCount ? maxTagCount : undefined;
804
806
  const NotOneLine = !maxTagCount; // Multiple lines (that is, do not set maxTagCount), do not use TagGroup, directly traverse with Tag, otherwise Input cannot follow the correct position
805
807
 
806
808
  const tagContent = NotOneLine ? tags : /*#__PURE__*/_react.default.createElement(_group.default, {
807
809
  tagList: tags,
808
810
  maxTagCount: n,
811
+ restCount: maxTagCount ? selectedItems.length - maxTagCount : undefined,
809
812
  size: "large",
810
813
  mode: "custom"
811
814
  });
@@ -7,6 +7,7 @@ export interface TagGroupProps {
7
7
  style?: React.CSSProperties;
8
8
  className?: string;
9
9
  maxTagCount?: number;
10
+ restCount?: number;
10
11
  tagList?: (TagProps | React.ReactNode)[];
11
12
  size?: 'small' | 'large';
12
13
  showPopover?: boolean;
@@ -26,6 +27,7 @@ export default class TagGroup extends PureComponent<TagGroupProps> {
26
27
  style: PropTypes.Requireable<object>;
27
28
  className: PropTypes.Requireable<string>;
28
29
  maxTagCount: PropTypes.Requireable<number>;
30
+ restCount: PropTypes.Requireable<number>;
29
31
  tagList: PropTypes.Requireable<any[]>;
30
32
  size: PropTypes.Requireable<string>;
31
33
  mode: PropTypes.Requireable<string>;
@@ -77,9 +77,10 @@ class TagGroup extends _react.PureComponent {
77
77
  renderMergeTags(tags) {
78
78
  const {
79
79
  maxTagCount,
80
- tagList
80
+ tagList,
81
+ restCount
81
82
  } = this.props;
82
- const n = tagList.length - maxTagCount;
83
+ const n = restCount ? restCount : tagList.length - maxTagCount;
83
84
  let renderTags = tags;
84
85
  const normalTags = (0, _slice.default)(tags).call(tags, 0, maxTagCount);
85
86
  const restTags = (0, _slice.default)(tags).call(tags, maxTagCount);
@@ -156,6 +157,7 @@ TagGroup.propTypes = {
156
157
  style: _propTypes.default.object,
157
158
  className: _propTypes.default.string,
158
159
  maxTagCount: _propTypes.default.number,
160
+ restCount: _propTypes.default.number,
159
161
  tagList: _propTypes.default.array,
160
162
  size: _propTypes.default.oneOf(tagSize),
161
163
  mode: _propTypes.default.string,
@@ -463,7 +463,7 @@ class Tooltip extends _baseComponent.default {
463
463
  willUpdateStates.visible = visible;
464
464
  }
465
465
 
466
- this.setState(willUpdateStates, () => {
466
+ this.mounted && this.setState(willUpdateStates, () => {
467
467
  cb();
468
468
  });
469
469
  },
@@ -275,7 +275,8 @@ class Tree extends _baseComponent.default {
275
275
  const isSeaching = Boolean(props.filterTreeNode && prevState.inputValue && prevState.inputValue.length);
276
276
  const newState = {
277
277
  prevProps: props
278
- }; // Accept a props field as a parameter to determine whether to update the field
278
+ };
279
+ const isExpandControlled = ('expandedKeys' in props); // Accept a props field as a parameter to determine whether to update the field
279
280
 
280
281
  const needUpdate = name => {
281
282
  const firstInProps = !prevProps && name in props;
@@ -319,7 +320,8 @@ class Tree extends _baseComponent.default {
319
320
  }
320
321
  }
321
322
 
322
- const expandAllWhenDataChange = (needUpdate('treeDataSimpleJson') || needUpdate('treeData')) && props.expandAll;
323
+ const dataUpdated = needUpdate('treeDataSimpleJson') || needUpdate('treeData');
324
+ const expandAllWhenDataChange = dataUpdated && props.expandAll;
323
325
 
324
326
  if (!isSeaching) {
325
327
  // Update expandedKeys
@@ -345,7 +347,7 @@ class Tree extends _baseComponent.default {
345
347
  newState.expandedKeys = (0, _treeUtil.calcExpandedKeys)(props.defaultExpandedKeys, keyEntities);
346
348
  } else if (!prevProps && props.defaultValue) {
347
349
  newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)(props.defaultValue, keyEntities, props.multiple, valueEntities);
348
- } else if (!prevProps && props.value) {
350
+ } else if ((!prevProps || !isExpandControlled && dataUpdated) && props.value) {
349
351
  newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)(props.value, keyEntities, props.multiple, valueEntities);
350
352
  }
351
353
 
@@ -109,6 +109,7 @@ export interface NodeListProps {
109
109
  motionKeys: Set<string>;
110
110
  motionType: string;
111
111
  flattenList: FlattenNode[] | undefined;
112
+ searchTargetIsDeep?: boolean;
112
113
  renderTreeNode: (treeNode: FlattenNode, ind?: number, style?: React.CSSProperties) => ReactNode;
113
114
  }
114
115
  export declare type TransitionNodes<T> = Array<T | Array<T>>;
@@ -49,6 +49,7 @@ class NodeList extends _react.PureComponent {
49
49
  super(props);
50
50
 
51
51
  this.onMotionEnd = () => {
52
+ typeof this.props.onMotionEnd === 'function' && this.props.onMotionEnd();
52
53
  this.setState({
53
54
  transitionNodes: []
54
55
  });
@@ -107,12 +108,13 @@ class NodeList extends _react.PureComponent {
107
108
  const {
108
109
  flattenNodes,
109
110
  motionType,
111
+ searchTargetIsDeep,
110
112
  renderTreeNode
111
113
  } = this.props;
112
114
  const {
113
115
  transitionNodes
114
116
  } = this.state;
115
- const mapData = transitionNodes.length ? transitionNodes : flattenNodes;
117
+ const mapData = transitionNodes.length && !searchTargetIsDeep ? transitionNodes : flattenNodes;
116
118
  const options = (0, _map.default)(mapData).call(mapData, treeNode => {
117
119
  const isMotionNode = (0, _isArray.default)(treeNode);
118
120