@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
@@ -1,3 +1,4 @@
1
+ import _isEqual from "lodash/isEqual";
1
2
  import _isFunction from "lodash/isFunction";
2
3
  import _get from "lodash/get";
3
4
  import _isDate from "lodash/isDate";
@@ -12,6 +13,10 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
12
13
  /* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/interactive-supports-focus */
13
14
 
14
15
  /* eslint-disable max-len */
16
+
17
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
18
+
19
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
15
20
  import React from 'react';
16
21
  import classnames from 'classnames';
17
22
  import PropTypes from 'prop-types';
@@ -65,6 +70,8 @@ export default class DatePicker extends BaseComponent {
65
70
  return _this.foundation.handleInputChange(...arguments);
66
71
  };
67
72
 
73
+ this.handleInsetInputChange = options => this.foundation.handleInsetInputChange(options);
74
+
68
75
  this.handleInputComplete = v => this.foundation.handleInputComplete(v);
69
76
 
70
77
  this.handleInputBlur = e => this.foundation.handleInputBlur(_get(e, 'nativeEvent.target.value'), e);
@@ -93,6 +100,30 @@ export default class DatePicker extends BaseComponent {
93
100
  }
94
101
  };
95
102
 
103
+ this.handleInsetDateFocus = (e, rangeType) => {
104
+ const monthGridFoundation = _get(this, 'monthGrid.current.foundation');
105
+
106
+ if (monthGridFoundation) {
107
+ monthGridFoundation.showDatePanel(strings.PANEL_TYPE_LEFT);
108
+ monthGridFoundation.showDatePanel(strings.PANEL_TYPE_RIGHT);
109
+ }
110
+
111
+ this.handleInputFocus(e, rangeType);
112
+ };
113
+
114
+ this.handleInsetTimeFocus = () => {
115
+ const monthGridFoundation = _get(this, 'monthGrid.current.foundation');
116
+
117
+ if (monthGridFoundation) {
118
+ monthGridFoundation.showTimePicker(strings.PANEL_TYPE_LEFT);
119
+ monthGridFoundation.showTimePicker(strings.PANEL_TYPE_RIGHT);
120
+ }
121
+ };
122
+
123
+ this.handlePanelVisibleChange = visible => {
124
+ this.foundation.handlePanelVisibleChange(visible);
125
+ };
126
+
96
127
  this.handleConfirm = e => this.foundation.handleConfirm();
97
128
 
98
129
  this.handleCancel = e => this.foundation.handleCancel();
@@ -116,19 +147,43 @@ export default class DatePicker extends BaseComponent {
116
147
  dropdownStyle,
117
148
  density,
118
149
  topSlot,
119
- bottomSlot
150
+ bottomSlot,
151
+ insetInput,
152
+ type,
153
+ format,
154
+ rangeSeparator
120
155
  } = this.props;
156
+ const {
157
+ insetInputValue,
158
+ value
159
+ } = this.state;
121
160
  const wrapCls = classnames(cssClasses.PREFIX, {
122
161
  [cssClasses.PANEL_YAM]: this.adapter.typeIsYearOrMonth(),
123
162
  ["".concat(cssClasses.PREFIX, "-compact")]: density === 'compact'
124
163
  }, dropdownClassName);
164
+ const insetInputProps = {
165
+ dateFnsLocale,
166
+ format,
167
+ insetInputValue,
168
+ rangeSeparator,
169
+ type,
170
+ value: value,
171
+ handleInsetDateFocus: this.handleInsetDateFocus,
172
+ handleInsetTimeFocus: this.handleInsetTimeFocus,
173
+ onInsetInputChange: this.handleInsetInputChange,
174
+ rangeInputStartRef: this.rangeInputStartRef,
175
+ rangeInputEndRef: this.rangeInputEndRef,
176
+ density
177
+ };
125
178
  return /*#__PURE__*/React.createElement("div", {
126
179
  ref: this.panelRef,
127
180
  className: wrapCls,
128
181
  style: dropdownStyle
129
182
  }, topSlot && /*#__PURE__*/React.createElement("div", {
130
183
  className: "".concat(cssClasses.PREFIX, "-topSlot")
131
- }, topSlot), this.adapter.typeIsYearOrMonth() ? this.renderYearMonthPanel(locale, localeCode) : this.renderMonthGrid(locale, localeCode, dateFnsLocale), this.renderQuickControls(), bottomSlot && /*#__PURE__*/React.createElement("div", {
184
+ }, topSlot), insetInput && /*#__PURE__*/React.createElement(DateInput, _Object$assign({}, insetInputProps, {
185
+ insetInput: true
186
+ })), this.adapter.typeIsYearOrMonth() ? this.renderYearMonthPanel(locale, localeCode) : this.renderMonthGrid(locale, localeCode, dateFnsLocale), this.renderQuickControls(), bottomSlot && /*#__PURE__*/React.createElement("div", {
132
187
  className: "".concat(cssClasses.PREFIX, "-bottomSlot")
133
188
  }, bottomSlot), this.renderFooter(locale, localeCode));
134
189
  };
@@ -192,7 +247,8 @@ export default class DatePicker extends BaseComponent {
192
247
  position: position,
193
248
  visible: panelShow,
194
249
  stopPropagation: stopPropagation,
195
- spacing: spacing
250
+ spacing: spacing,
251
+ onVisibleChange: this.handlePanelVisibleChange
196
252
  }, children);
197
253
  };
198
254
 
@@ -205,7 +261,9 @@ export default class DatePicker extends BaseComponent {
205
261
  prevTimeZone: null,
206
262
  motionEnd: false,
207
263
  rangeInputFocus: undefined,
208
- autofocus: props.autoFocus || this.isRangeType(props.type, props.triggerRender) && (props.open || props.defaultOpen)
264
+ autofocus: props.autoFocus || this.isRangeType(props.type, props.triggerRender) && (props.open || props.defaultOpen),
265
+ insetInputValue: null,
266
+ triggerDisabled: undefined
209
267
  };
210
268
  this.adapter.setCache('cachedSelectedValue', null);
211
269
  this.triggerElRef = /*#__PURE__*/React.createRef();
@@ -308,6 +366,17 @@ export default class DatePicker extends BaseComponent {
308
366
  inputValue
309
367
  });
310
368
  },
369
+ updateInsetInputValue: insetInputValue => {
370
+ const {
371
+ insetInput
372
+ } = this.props;
373
+
374
+ if (insetInput && !_isEqual(insetInputValue, this.state.insetInputValue)) {
375
+ this.setState({
376
+ insetInputValue
377
+ });
378
+ }
379
+ },
311
380
  needConfirm: () => {
312
381
  var _context;
313
382
 
@@ -382,7 +451,38 @@ export default class DatePicker extends BaseComponent {
382
451
  }
383
452
  },
384
453
  couldPanelClosed: () => this.focusRecordsRef.current.rangeStart && this.focusRecordsRef.current.rangeEnd,
385
- isEventTarget: e => e && e.target === e.currentTarget
454
+ isEventTarget: e => e && e.target === e.currentTarget,
455
+ setInsetInputFocus: () => {
456
+ const {
457
+ rangeInputFocus
458
+ } = this.state;
459
+
460
+ switch (rangeInputFocus) {
461
+ case 'rangeEnd':
462
+ if (document.activeElement !== this.rangeInputEndRef.current) {
463
+ const inputEndNode = _get(this, 'rangeInputEndRef.current');
464
+
465
+ inputEndNode && inputEndNode.focus();
466
+ }
467
+
468
+ break;
469
+
470
+ case 'rangeStart':
471
+ default:
472
+ if (document.activeElement !== this.rangeInputStartRef.current) {
473
+ const inputStartNode = _get(this, 'rangeInputStartRef.current');
474
+
475
+ inputStartNode && inputStartNode.focus();
476
+ }
477
+
478
+ break;
479
+ }
480
+ },
481
+ setTriggerDisabled: disabled => {
482
+ this.setState({
483
+ triggerDisabled: disabled
484
+ });
485
+ }
386
486
  });
387
487
  }
388
488
 
@@ -440,7 +540,8 @@ export default class DatePicker extends BaseComponent {
440
540
  syncSwitchMonth,
441
541
  onPanelChange,
442
542
  timeZone,
443
- triggerRender
543
+ triggerRender,
544
+ insetInput
444
545
  } = this.props;
445
546
  const {
446
547
  value,
@@ -488,7 +589,8 @@ export default class DatePicker extends BaseComponent {
488
589
  onPanelChange: onPanelChange,
489
590
  timeZone: timeZone,
490
591
  focusRecordsRef: this.focusRecordsRef,
491
- triggerRender: triggerRender
592
+ triggerRender: triggerRender,
593
+ insetInput: insetInput
492
594
  });
493
595
  }
494
596
 
@@ -524,20 +626,23 @@ export default class DatePicker extends BaseComponent {
524
626
  triggerRender,
525
627
  size,
526
628
  inputReadOnly,
527
- rangeSeparator
629
+ rangeSeparator,
630
+ insetInput
528
631
  } = this.props;
529
632
  const {
530
633
  value,
531
634
  inputValue,
532
- rangeInputFocus
635
+ rangeInputFocus,
636
+ triggerDisabled
533
637
  } = this.state; // This class is not needed when triggerRender is function
534
638
 
535
639
  const isRangeType = this.isRangeType(type, triggerRender);
640
+ const inputDisabled = disabled || insetInput && triggerDisabled;
536
641
  const inputCls = classnames("".concat(cssClasses.PREFIX, "-input"), {
537
642
  ["".concat(cssClasses.PREFIX, "-range-input")]: isRangeType,
538
643
  [_concatInstanceProperty(_context3 = "".concat(cssClasses.PREFIX, "-range-input-")).call(_context3, size)]: isRangeType && size,
539
- ["".concat(cssClasses.PREFIX, "-range-input-active")]: isRangeType && rangeInputFocus && !disabled,
540
- ["".concat(cssClasses.PREFIX, "-range-input-disabled")]: isRangeType && disabled,
644
+ ["".concat(cssClasses.PREFIX, "-range-input-active")]: isRangeType && rangeInputFocus && !inputDisabled,
645
+ ["".concat(cssClasses.PREFIX, "-range-input-disabled")]: isRangeType && inputDisabled,
541
646
  [_concatInstanceProperty(_context4 = "".concat(cssClasses.PREFIX, "-range-input-")).call(_context4, validateStatus)]: isRangeType && validateStatus
542
647
  });
543
648
  const phText = placeholder || locale.placeholder[type]; // i18n
@@ -545,9 +650,9 @@ export default class DatePicker extends BaseComponent {
545
650
 
546
651
  const props = _Object$assign(_Object$assign({}, extraProps), {
547
652
  placeholder: phText,
548
- disabled,
653
+ disabled: inputDisabled,
549
654
  inputValue,
550
- value,
655
+ value: value,
551
656
  onChange: this.handleInputChange,
552
657
  onEnterPress: this.handleInputComplete,
553
658
  // TODO: remove in next major version
@@ -560,7 +665,7 @@ export default class DatePicker extends BaseComponent {
560
665
  format,
561
666
  multiple,
562
667
  validateStatus,
563
- inputReadOnly,
668
+ inputReadOnly: inputReadOnly || insetInput,
564
669
  // onClick: this.handleOpenPanel,
565
670
  onBlur: this.handleInputBlur,
566
671
  onFocus: this.handleInputFocus,
@@ -569,13 +674,13 @@ export default class DatePicker extends BaseComponent {
569
674
  size,
570
675
  autofocus: this.state.autofocus,
571
676
  dateFnsLocale,
572
- rangeInputStartRef: this.rangeInputStartRef,
573
- rangeInputEndRef: this.rangeInputEndRef,
574
677
  rangeInputFocus,
575
678
  rangeSeparator,
576
679
  onRangeBlur: this.handleRangeInputBlur,
577
680
  onRangeClear: this.handleRangeInputClear,
578
- onRangeEndTabPress: this.handleRangeEndTabPress
681
+ onRangeEndTabPress: this.handleRangeEndTabPress,
682
+ rangeInputStartRef: insetInput ? null : this.rangeInputStartRef,
683
+ rangeInputEndRef: insetInput ? null : this.rangeInputEndRef
579
684
  });
580
685
 
581
686
  return /*#__PURE__*/React.createElement("div", {
@@ -723,5 +828,6 @@ DatePicker.defaultProps = {
723
828
  spacing: numbers.SPACING,
724
829
  autoSwitchDate: true,
725
830
  syncSwitchMonth: false,
726
- rangeSeparator: strings.DEFAULT_SEPARATOR_RANGE
831
+ rangeSeparator: strings.DEFAULT_SEPARATOR_RANGE,
832
+ insetInput: false
727
833
  };
@@ -1,7 +1,9 @@
1
1
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
2
2
  import _trimInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/trim";
3
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
3
4
  import React from 'react';
4
5
  import { forwardStatics } from '@douyinfe/semi-foundation/lib/es/utils/object';
6
+ import { numbers, strings } from '@douyinfe/semi-foundation/lib/es/datePicker/constants';
5
7
  import DatePicker from './datePicker';
6
8
  import ConfigContext from '../configProvider/context';
7
9
  import LocaleConsumer from '../locale/localeConsumer';
@@ -29,6 +31,24 @@ export default forwardStatics( /*#__PURE__*/React.forwardRef((props, ref) => {
29
31
  propsObj.rangeSeparator = " ".concat(_trimInstanceProperty(rangeSeparator).call(rangeSeparator), " ");
30
32
  }
31
33
 
34
+ if (propsObj.insetInput) {
35
+ var _context;
36
+
37
+ if (!propsObj.position) {
38
+ propsObj.position = strings.POSITION_INLINE_INPUT;
39
+ }
40
+ /**
41
+ * When insetInput is `true` and `position` includes `over`, use 1px `spacing` to solve the problem of border-radius leakage in the upper left corner
42
+ *
43
+ * @see https://user-images.githubusercontent.com/26477537/158817185-126a5f33-41f7-414a-8e36-8d1be2dda5cd.png
44
+ */
45
+
46
+
47
+ if (_includesInstanceProperty(_context = propsObj.position).call(_context, 'Over') && !propsObj.spacing) {
48
+ propsObj.spacing = numbers.SPACING_INSET_INPUT;
49
+ }
50
+ }
51
+
32
52
  return /*#__PURE__*/React.createElement(ConfigContext.Consumer, null, _ref => {
33
53
  let {
34
54
  timeZone
@@ -0,0 +1,21 @@
1
+ import { InsetInputValue, Type, InsetInputChangeFoundationProps } from '@douyinfe/semi-foundation/lib/es/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,65 @@
1
+ import _get from "lodash/get";
2
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
3
+ import React from 'react';
4
+ import Input from '../input';
5
+ export function InsetDateInput(props) {
6
+ const {
7
+ insetInputValue,
8
+ valuePath,
9
+ onFocus,
10
+ onChange,
11
+ placeholder,
12
+ forwardRef
13
+ } = props;
14
+
15
+ const value = _get(insetInputValue, valuePath);
16
+
17
+ return /*#__PURE__*/React.createElement(Input, {
18
+ value: value,
19
+ onChange: (value, event) => {
20
+ onChange({
21
+ value,
22
+ event,
23
+ insetInputValue,
24
+ valuePath
25
+ });
26
+ },
27
+ onFocus: onFocus,
28
+ placeholder: placeholder,
29
+ ref: forwardRef
30
+ });
31
+ }
32
+ export function InsetTimeInput(props) {
33
+ const {
34
+ insetInputValue,
35
+ valuePath,
36
+ type,
37
+ onFocus,
38
+ onChange,
39
+ placeholder,
40
+ disabled
41
+ } = props;
42
+
43
+ const _isTimeType = _includesInstanceProperty(type).call(type, 'Time');
44
+
45
+ if (!_isTimeType) {
46
+ return null;
47
+ }
48
+
49
+ const value = _get(insetInputValue, valuePath);
50
+
51
+ return /*#__PURE__*/React.createElement(Input, {
52
+ value: value,
53
+ onChange: (value, event) => {
54
+ onChange({
55
+ value,
56
+ event,
57
+ insetInputValue,
58
+ valuePath
59
+ });
60
+ },
61
+ onFocus: onFocus,
62
+ placeholder: placeholder,
63
+ disabled: disabled
64
+ });
65
+ }
@@ -9,6 +9,8 @@ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/ins
9
9
 
10
10
  /* eslint-disable jsx-a11y/interactive-supports-focus,jsx-a11y/click-events-have-key-events */
11
11
 
12
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
13
+
12
14
  /* eslint-disable react/no-did-update-set-state */
13
15
 
14
16
  /* eslint-disable max-len */
@@ -284,6 +286,9 @@ export default class MonthsGrid extends BaseComponent {
284
286
  monthRight,
285
287
  currentPanelHeight
286
288
  } = this.state;
289
+ const {
290
+ insetInput
291
+ } = this.props;
287
292
  const panelDetail = panelType === strings.PANEL_TYPE_RIGHT ? monthRight : monthLeft;
288
293
  const {
289
294
  isTimePickerOpen,
@@ -306,7 +311,7 @@ export default class MonthsGrid extends BaseComponent {
306
311
  style.minWidth = wrap.getBoundingClientRect().width;
307
312
  }
308
313
 
309
- if (this.leftIsYearOrTime() && this.rightIsYearOrTime()) {
314
+ if (this.leftIsYearOrTime() && this.rightIsYearOrTime() && !insetInput) {
310
315
  /**
311
316
  * left和right同时为tpk时,panel会有一个minHeight
312
317
  * 如果缓存的currentPanelHeight为0,则需要计算滚动列表的高度
@@ -316,7 +321,7 @@ export default class MonthsGrid extends BaseComponent {
316
321
  * When left and right are tpk at the same time, the panel will have a minHeight
317
322
  * If the cached currentPanelHeight is 0, you need to calculate the height of the scrolling list
318
323
  * 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)
319
- * See packages/semi-foundation/scrollList/itemF oundation.js initWheelList function
324
+ * See packages/semi-foundation/scrollList/itemFoundation.js initWheelList function
320
325
  */
321
326
  style.minHeight = currentPanelHeight ? currentPanelHeight : this.calcScrollListHeight();
322
327
  }
@@ -324,10 +329,14 @@ export default class MonthsGrid extends BaseComponent {
324
329
  monthCls = classnames(monthCls, "".concat(prefixCls, "-yam-showing"));
325
330
  }
326
331
 
332
+ const _isDatePanelOpen = !(isYearPickerOpen || isTimePickerOpen);
333
+
334
+ const xOpenType = _isDatePanelOpen ? 'date' : isYearPickerOpen ? 'year' : 'time';
327
335
  return /*#__PURE__*/React.createElement("div", {
328
336
  className: monthCls,
329
337
  key: panelType,
330
- style: style
338
+ style: style,
339
+ "x-open-type": xOpenType
331
340
  }, yearAndMonthLayer, timePickerLayer, this.foundation.isRangeType() ? panelContent : isYearPickerOpen || isTimePickerOpen ? null : panelContent, this.renderSwitch(panelType));
332
341
  }
333
342
 
@@ -538,10 +547,11 @@ export default class MonthsGrid extends BaseComponent {
538
547
  locale,
539
548
  disabledTimePicker,
540
549
  density,
541
- dateFnsLocale
542
- } = this.props; // Type: date, dateRange, year, month, no rendering required
550
+ dateFnsLocale,
551
+ insetInput
552
+ } = this.props; // Type: date, dateRange, year, month, inset input no rendering required
543
553
 
544
- if (!_includesInstanceProperty(type).call(type, 'Time')) {
554
+ if (!_includesInstanceProperty(type).call(type, 'Time') || insetInput) {
545
555
  return null;
546
556
  } // switch year/month & time
547
557
 
@@ -614,7 +624,8 @@ export default class MonthsGrid extends BaseComponent {
614
624
  monthRight
615
625
  } = this.state;
616
626
  const {
617
- type
627
+ type,
628
+ insetInput
618
629
  } = this.props;
619
630
  const monthGridCls = classnames({
620
631
  ["".concat(prefixCls, "-month-grid")]: true
@@ -636,6 +647,7 @@ export default class MonthsGrid extends BaseComponent {
636
647
  className: monthGridCls,
637
648
  "x-type": type,
638
649
  "x-panel-yearandmonth-open-type": yearOpenType,
650
+ "x-insetInput": insetInput ? "true" : "false",
639
651
  ref: current => this.cacheRefCurrent('monthGrid', current)
640
652
  }, content);
641
653
  }
@@ -1 +1,2 @@
1
- export default function useFormApi(): import("@douyinfe/semi-foundation/lib/es/form/interface").BaseFormApi<any>;
1
+ import { BaseFormApi } from '@douyinfe/semi-foundation/lib/es/form/interface';
2
+ export default function useFormApi<T extends Record<string, any> = any>(): BaseFormApi<T>;
@@ -39,6 +39,8 @@ const HookModal = (_a, ref) => {
39
39
  const {
40
40
  motion
41
41
  } = props;
42
+ /* istanbul ignore next */
43
+
42
44
  const mergedMotion = typeof motion === 'undefined' || motion ? _Object$assign(_Object$assign({}, motion), {
43
45
  didLeave: function () {
44
46
  const didLeave = _get(props.motion, 'didLeave');
@@ -32,6 +32,12 @@ class RadioGroup extends BaseComponent {
32
32
  }
33
33
 
34
34
  componentDidUpdate(prevProps) {
35
+ if (typeof prevProps.value === 'number' && isNaN(prevProps.value) && typeof this.props.value === 'number' && isNaN(this.props.value)) {
36
+ // `NaN === NaN` returns false, and this will fail the next if check
37
+ // therefore triggering an infinite loop
38
+ return;
39
+ }
40
+
35
41
  if (prevProps.value !== this.props.value) {
36
42
  this.foundation.handlePropValueChange(this.props.value);
37
43
  }
@@ -688,7 +688,9 @@ class Select extends BaseComponent {
688
688
  });
689
689
  }
690
690
 
691
- const tags = _mapInstanceProperty(selectedItems).call(selectedItems, (item, i) => {
691
+ const mapItems = maxTagCount ? _sliceInstanceProperty(selectedItems).call(selectedItems, 0, maxTagCount) : selectedItems; // no need to render rest tag when maxTagCount is setting
692
+
693
+ const tags = _mapInstanceProperty(mapItems).call(mapItems, (item, i) => {
692
694
  const label = item[0];
693
695
  const {
694
696
  value
@@ -747,12 +749,13 @@ class Select extends BaseComponent {
747
749
  const placeholderText = placeholder && !inputValue ? /*#__PURE__*/React.createElement("span", {
748
750
  className: spanCls
749
751
  }, placeholder) : null;
750
- const n = tags.length > maxTagCount ? maxTagCount : undefined;
752
+ const n = selectedItems.length > maxTagCount ? maxTagCount : undefined;
751
753
  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
752
754
 
753
755
  const tagContent = NotOneLine ? tags : /*#__PURE__*/React.createElement(TagGroup, {
754
756
  tagList: tags,
755
757
  maxTagCount: n,
758
+ restCount: maxTagCount ? selectedItems.length - maxTagCount : undefined,
756
759
  size: "large",
757
760
  mode: "custom"
758
761
  });
@@ -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>;
@@ -46,9 +46,10 @@ export default class TagGroup extends PureComponent {
46
46
  renderMergeTags(tags) {
47
47
  const {
48
48
  maxTagCount,
49
- tagList
49
+ tagList,
50
+ restCount
50
51
  } = this.props;
51
- const n = tagList.length - maxTagCount;
52
+ const n = restCount ? restCount : tagList.length - maxTagCount;
52
53
  let renderTags = tags;
53
54
 
54
55
  const normalTags = _sliceInstanceProperty(tags).call(tags, 0, maxTagCount);
@@ -128,6 +129,7 @@ TagGroup.propTypes = {
128
129
  style: PropTypes.object,
129
130
  className: PropTypes.string,
130
131
  maxTagCount: PropTypes.number,
132
+ restCount: PropTypes.number,
131
133
  tagList: PropTypes.array,
132
134
  size: PropTypes.oneOf(tagSize),
133
135
  mode: PropTypes.string,
@@ -422,7 +422,7 @@ export default class Tooltip extends BaseComponent {
422
422
  willUpdateStates.visible = visible;
423
423
  }
424
424
 
425
- this.setState(willUpdateStates, () => {
425
+ this.mounted && this.setState(willUpdateStates, () => {
426
426
  cb();
427
427
  });
428
428
  },
@@ -216,7 +216,8 @@ class Tree extends BaseComponent {
216
216
  const isSeaching = Boolean(props.filterTreeNode && prevState.inputValue && prevState.inputValue.length);
217
217
  const newState = {
218
218
  prevProps: props
219
- }; // Accept a props field as a parameter to determine whether to update the field
219
+ };
220
+ const isExpandControlled = ('expandedKeys' in props); // Accept a props field as a parameter to determine whether to update the field
220
221
 
221
222
  const needUpdate = name => {
222
223
  const firstInProps = !prevProps && name in props;
@@ -260,7 +261,8 @@ class Tree extends BaseComponent {
260
261
  }
261
262
  }
262
263
 
263
- const expandAllWhenDataChange = (needUpdate('treeDataSimpleJson') || needUpdate('treeData')) && props.expandAll;
264
+ const dataUpdated = needUpdate('treeDataSimpleJson') || needUpdate('treeData');
265
+ const expandAllWhenDataChange = dataUpdated && props.expandAll;
264
266
 
265
267
  if (!isSeaching) {
266
268
  // Update expandedKeys
@@ -286,7 +288,7 @@ class Tree extends BaseComponent {
286
288
  newState.expandedKeys = calcExpandedKeys(props.defaultExpandedKeys, keyEntities);
287
289
  } else if (!prevProps && props.defaultValue) {
288
290
  newState.expandedKeys = calcExpandedKeysForValues(props.defaultValue, keyEntities, props.multiple, valueEntities);
289
- } else if (!prevProps && props.value) {
291
+ } else if ((!prevProps || !isExpandControlled && dataUpdated) && props.value) {
290
292
  newState.expandedKeys = calcExpandedKeysForValues(props.value, keyEntities, props.multiple, valueEntities);
291
293
  }
292
294
 
@@ -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>>;
@@ -22,6 +22,7 @@ export default class NodeList extends PureComponent {
22
22
  super(props);
23
23
 
24
24
  this.onMotionEnd = () => {
25
+ typeof this.props.onMotionEnd === 'function' && this.props.onMotionEnd();
25
26
  this.setState({
26
27
  transitionNodes: []
27
28
  });
@@ -83,12 +84,13 @@ export default class NodeList extends PureComponent {
83
84
  const {
84
85
  flattenNodes,
85
86
  motionType,
87
+ searchTargetIsDeep,
86
88
  renderTreeNode
87
89
  } = this.props;
88
90
  const {
89
91
  transitionNodes
90
92
  } = this.state;
91
- const mapData = transitionNodes.length ? transitionNodes : flattenNodes;
93
+ const mapData = transitionNodes.length && !searchTargetIsDeep ? transitionNodes : flattenNodes;
92
94
 
93
95
  const options = _mapInstanceProperty(mapData).call(mapData, treeNode => {
94
96
  const isMotionNode = _Array$isArray(treeNode);