@douyinfe/semi-ui 2.17.0-alpha.1 → 2.17.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.
Files changed (100) hide show
  1. package/_base/_story/a11y.jsx +2 -2
  2. package/avatar/__test__/avatar.test.js +3 -3
  3. package/avatar/interface.ts +1 -1
  4. package/cascader/_story/cascader.stories.js +91 -1
  5. package/cascader/index.tsx +35 -26
  6. package/checkbox/checkbox.tsx +4 -1
  7. package/collapse/__test__/collapse.test.js +22 -2
  8. package/collapse/_story/accordion.stories.js +2 -2
  9. package/collapse/item.tsx +20 -6
  10. package/collapsible/_story/collapsible.stories.js +6 -6
  11. package/configProvider/_story/RTLDirection/RTLForm.jsx +1 -1
  12. package/datePicker/__test__/datePicker.test.js +5 -5
  13. package/datePicker/_story/datePicker.stories.js +138 -22
  14. package/datePicker/datePicker.tsx +42 -7
  15. package/datePicker/monthsGrid.tsx +22 -10
  16. package/datePicker/quickControl.tsx +62 -16
  17. package/datePicker/yearAndMonth.tsx +31 -5
  18. package/dist/css/semi.css +328 -47
  19. package/dist/css/semi.min.css +1 -1
  20. package/dist/umd/semi-ui.js +36811 -36304
  21. package/dist/umd/semi-ui.js.map +1 -1
  22. package/dist/umd/semi-ui.min.js +1 -1
  23. package/dist/umd/semi-ui.min.js.map +1 -1
  24. package/empty/index.tsx +3 -3
  25. package/lib/cjs/avatar/interface.d.ts +1 -1
  26. package/lib/cjs/cascader/index.js +36 -25
  27. package/lib/cjs/checkbox/checkbox.js +4 -1
  28. package/lib/cjs/collapse/item.d.ts +8 -0
  29. package/lib/cjs/collapse/item.js +19 -8
  30. package/lib/cjs/datePicker/datePicker.d.ts +3 -0
  31. package/lib/cjs/datePicker/datePicker.js +56 -9
  32. package/lib/cjs/datePicker/monthsGrid.d.ts +3 -0
  33. package/lib/cjs/datePicker/monthsGrid.js +14 -3
  34. package/lib/cjs/datePicker/quickControl.d.ts +6 -0
  35. package/lib/cjs/datePicker/quickControl.js +61 -14
  36. package/lib/cjs/datePicker/yearAndMonth.d.ts +3 -0
  37. package/lib/cjs/datePicker/yearAndMonth.js +15 -3
  38. package/lib/cjs/empty/index.js +1 -1
  39. package/lib/cjs/popover/index.d.ts +3 -0
  40. package/lib/cjs/popover/index.js +4 -2
  41. package/lib/cjs/select/index.d.ts +6 -1
  42. package/lib/cjs/select/index.js +130 -72
  43. package/lib/cjs/select/option.js +4 -2
  44. package/lib/cjs/tag/index.js +6 -4
  45. package/lib/cjs/tag/interface.d.ts +1 -0
  46. package/lib/cjs/tagInput/index.d.ts +13 -1
  47. package/lib/cjs/tagInput/index.js +217 -91
  48. package/lib/cjs/timePicker/TimePicker.js +1 -1
  49. package/lib/cjs/tooltip/index.d.ts +4 -0
  50. package/lib/cjs/tooltip/index.js +5 -3
  51. package/lib/cjs/typography/base.js +3 -15
  52. package/lib/cjs/typography/text.js +1 -11
  53. package/lib/es/avatar/interface.d.ts +1 -1
  54. package/lib/es/cascader/index.js +40 -29
  55. package/lib/es/checkbox/checkbox.js +4 -1
  56. package/lib/es/collapse/item.d.ts +8 -0
  57. package/lib/es/collapse/item.js +19 -8
  58. package/lib/es/datePicker/datePicker.d.ts +3 -0
  59. package/lib/es/datePicker/datePicker.js +56 -9
  60. package/lib/es/datePicker/monthsGrid.d.ts +3 -0
  61. package/lib/es/datePicker/monthsGrid.js +14 -3
  62. package/lib/es/datePicker/quickControl.d.ts +6 -0
  63. package/lib/es/datePicker/quickControl.js +61 -15
  64. package/lib/es/datePicker/yearAndMonth.d.ts +3 -0
  65. package/lib/es/datePicker/yearAndMonth.js +14 -3
  66. package/lib/es/empty/index.js +1 -1
  67. package/lib/es/popover/index.d.ts +3 -0
  68. package/lib/es/popover/index.js +4 -2
  69. package/lib/es/select/index.d.ts +6 -1
  70. package/lib/es/select/index.js +129 -71
  71. package/lib/es/select/option.js +4 -2
  72. package/lib/es/tag/index.js +6 -4
  73. package/lib/es/tag/interface.d.ts +1 -0
  74. package/lib/es/tagInput/index.d.ts +13 -1
  75. package/lib/es/tagInput/index.js +217 -93
  76. package/lib/es/timePicker/TimePicker.js +1 -1
  77. package/lib/es/tooltip/index.d.ts +4 -0
  78. package/lib/es/tooltip/index.js +5 -3
  79. package/lib/es/typography/base.js +3 -15
  80. package/lib/es/typography/text.js +1 -10
  81. package/package.json +7 -7
  82. package/popover/index.tsx +4 -1
  83. package/select/__test__/select.test.js +5 -3
  84. package/select/_story/select.stories.js +1 -1
  85. package/select/_story/select.stories.tsx +2 -2
  86. package/select/index.tsx +65 -30
  87. package/select/option.tsx +2 -0
  88. package/table/_story/Perf/Render/complex.jsx +1 -1
  89. package/table/_story/Perf/Render/resizableSelection.jsx +1 -1
  90. package/tag/index.tsx +3 -2
  91. package/tag/interface.ts +1 -0
  92. package/tagInput/_story/tagInput.stories.js +20 -2
  93. package/tagInput/index.tsx +126 -26
  94. package/timePicker/TimePicker.tsx +1 -1
  95. package/tooltip/index.tsx +5 -2
  96. package/typography/_story/typography.stories.js +3 -15
  97. package/typography/base.tsx +4 -9
  98. package/typography/text.tsx +1 -9
  99. package/upload/__test__/upload.test.js +9 -9
  100. package/upload/_story/upload.stories.js +5 -5
@@ -10,11 +10,13 @@ _Object$defineProperty(exports, "__esModule", {
10
10
 
11
11
  exports.default = void 0;
12
12
 
13
- var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
13
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
14
14
 
15
15
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
16
16
 
17
- var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
17
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
18
+
19
+ var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
18
20
 
19
21
  var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
20
22
 
@@ -54,6 +56,27 @@ var _paragraph = _interopRequireDefault(require("../typography/paragraph"));
54
56
 
55
57
  var _semiIcons = require("@douyinfe/semi-icons");
56
58
 
59
+ var _reactSortableHoc = require("react-sortable-hoc");
60
+
61
+ const SortableItem = (0, _reactSortableHoc.SortableElement)(props => props.item);
62
+ const SortableList = (0, _reactSortableHoc.SortableContainer)(_ref => {
63
+ let {
64
+ items
65
+ } = _ref;
66
+ return /*#__PURE__*/_react.default.createElement("div", {
67
+ style: {
68
+ display: 'flex',
69
+ flexFlow: 'row wrap'
70
+ }
71
+ }, (0, _map.default)(items).call(items, (item, index) =>
72
+ /*#__PURE__*/
73
+ // @ts-ignore skip SortableItem type check
74
+ _react.default.createElement(SortableItem, {
75
+ key: item.key,
76
+ index: index,
77
+ item: item.item
78
+ })));
79
+ });
57
80
  const prefixCls = _constants.cssClasses.PREFIX;
58
81
 
59
82
  class TagInput extends _baseComponent.default {
@@ -94,6 +117,10 @@ class TagInput extends _baseComponent.default {
94
117
  this.foundation.handleInputMouseLeave();
95
118
  };
96
119
 
120
+ this.handleClick = e => {
121
+ this.foundation.handleClick(e);
122
+ };
123
+
97
124
  this.handleInputMouseEnter = e => {
98
125
  this.foundation.handleInputMouseEnter();
99
126
  };
@@ -106,14 +133,86 @@ class TagInput extends _baseComponent.default {
106
133
  this.foundation.handlePreventMouseDown(e);
107
134
  };
108
135
 
136
+ this.getAllTags = () => {
137
+ var _context;
138
+
139
+ const {
140
+ size,
141
+ disabled,
142
+ renderTagItem,
143
+ showContentTooltip,
144
+ draggable
145
+ } = this.props;
146
+ const {
147
+ tagsArray,
148
+ active
149
+ } = this.state;
150
+ const showIconHandler = active && draggable;
151
+ const tagCls = (0, _classnames.default)("".concat(prefixCls, "-wrapper-tag"), {
152
+ [(0, _concat.default)(_context = "".concat(prefixCls, "-wrapper-tag-size-")).call(_context, size)]: size,
153
+ ["".concat(prefixCls, "-wrapper-tag-icon")]: showIconHandler
154
+ });
155
+ const typoCls = (0, _classnames.default)("".concat(prefixCls, "-wrapper-typo"), {
156
+ ["".concat(prefixCls, "-wrapper-typo-disabled")]: disabled
157
+ });
158
+ const itemWrapperCls = (0, _classnames.default)({
159
+ ["".concat(prefixCls, "-drag-item")]: showIconHandler,
160
+ ["".concat(prefixCls, "-wrapper-tag-icon")]: showIconHandler
161
+ });
162
+ const DragHandle = (0, _reactSortableHoc.SortableHandle)(() => /*#__PURE__*/_react.default.createElement(_semiIcons.IconHandle, {
163
+ className: "".concat(prefixCls, "-drag-handler")
164
+ }));
165
+ return (0, _map.default)(tagsArray).call(tagsArray, (value, index) => {
166
+ var _context2;
167
+
168
+ const elementKey = showIconHandler ? value : (0, _concat.default)(_context2 = "".concat(index)).call(_context2, value);
169
+
170
+ if ((0, _isFunction2.default)(renderTagItem)) {
171
+ return showIconHandler ? /*#__PURE__*/_react.default.createElement("div", {
172
+ className: itemWrapperCls,
173
+ key: elementKey
174
+ }, /*#__PURE__*/_react.default.createElement(DragHandle, null), renderTagItem(value, index)) : renderTagItem(value, index);
175
+ } else {
176
+ var _context3;
177
+
178
+ return /*#__PURE__*/_react.default.createElement(_tag.default, {
179
+ className: tagCls,
180
+ color: "white",
181
+ size: size === 'small' ? 'small' : 'large',
182
+ type: "light",
183
+ onClose: () => {
184
+ !disabled && this.handleTagClose(index);
185
+ },
186
+ closable: !disabled,
187
+ key: elementKey,
188
+ visible: true,
189
+ "aria-label": (0, _concat.default)(_context3 = "".concat(!disabled ? 'Closable ' : '', "Tag: ")).call(_context3, value)
190
+ }, showIconHandler && /*#__PURE__*/_react.default.createElement(DragHandle, null), /*#__PURE__*/_react.default.createElement(_paragraph.default, {
191
+ className: typoCls,
192
+ ellipsis: {
193
+ showTooltip: showContentTooltip,
194
+ rows: 1
195
+ }
196
+ }, value));
197
+ }
198
+ });
199
+ };
200
+
201
+ this.onSortEnd = callbackProps => {
202
+ this.foundation.handleSortEnd(callbackProps);
203
+ };
204
+
109
205
  this.foundation = new _foundation.default(this.adapter);
110
206
  this.state = {
111
207
  tagsArray: props.defaultValue || [],
112
208
  inputValue: '',
113
209
  focusing: false,
114
- hovering: false
210
+ hovering: false,
211
+ active: false
115
212
  };
116
213
  this.inputRef = /*#__PURE__*/_react.default.createRef();
214
+ this.tagInputRef = /*#__PURE__*/_react.default.createRef();
215
+ this.clickOutsideHandler = null;
117
216
  }
118
217
 
119
218
  static getDerivedStateFromProps(nextProps, prevState) {
@@ -180,6 +279,14 @@ class TagInput extends _baseComponent.default {
180
279
  hovering
181
280
  });
182
281
  },
282
+ setActive: active => {
283
+ this.setState({
284
+ active
285
+ });
286
+ },
287
+ getClickOutsideHandler: () => {
288
+ return this.clickOutsideHandler;
289
+ },
183
290
  notifyBlur: e => {
184
291
  this.props.onBlur(e);
185
292
  },
@@ -200,6 +307,23 @@ class TagInput extends _baseComponent.default {
200
307
  },
201
308
  notifyKeyDown: e => {
202
309
  this.props.onKeyDown(e);
310
+ },
311
+ registerClickOutsideHandler: cb => {
312
+ const clickOutsideHandler = e => {
313
+ const tagInputDom = this.tagInputRef && this.tagInputRef.current;
314
+ const target = e.target;
315
+
316
+ if (tagInputDom && !tagInputDom.contains(target)) {
317
+ cb(e);
318
+ }
319
+ };
320
+
321
+ this.clickOutsideHandler = clickOutsideHandler;
322
+ document.addEventListener('click', clickOutsideHandler, false);
323
+ },
324
+ unregisterClickOutsideHandler: () => {
325
+ document.removeEventListener('click', this.clickOutsideHandler, false);
326
+ this.clickOutsideHandler = null;
203
327
  }
204
328
  });
205
329
  }
@@ -215,7 +339,10 @@ class TagInput extends _baseComponent.default {
215
339
  this.inputRef.current.focus({
216
340
  preventScroll
217
341
  });
342
+ this.foundation.handleClick();
218
343
  }
344
+
345
+ this.foundation.init();
219
346
  }
220
347
 
221
348
  renderClearBtn() {
@@ -304,71 +431,49 @@ class TagInput extends _baseComponent.default {
304
431
  }
305
432
 
306
433
  renderTags() {
307
- var _context;
308
-
309
434
  const {
310
- size,
311
435
  disabled,
312
- renderTagItem,
313
436
  maxTagCount,
314
- showContentTooltip,
315
437
  showRestTagsPopover,
316
- restTagsPopoverProps = {}
438
+ restTagsPopoverProps = {},
439
+ draggable,
440
+ expandRestTagsOnClick
317
441
  } = this.props;
318
442
  const {
319
- tagsArray
443
+ tagsArray,
444
+ active
320
445
  } = this.state;
321
- const tagCls = (0, _classnames.default)("".concat(prefixCls, "-wrapper-tag"), {
322
- [(0, _concat.default)(_context = "".concat(prefixCls, "-wrapper-tag-size-")).call(_context, size)]: size
323
- });
324
- const typoCls = (0, _classnames.default)("".concat(prefixCls, "-wrapper-typo"), {
325
- ["".concat(prefixCls, "-wrapper-typo-disabled")]: disabled
326
- });
327
446
  const restTagsCls = (0, _classnames.default)("".concat(prefixCls, "-wrapper-n"), {
328
447
  ["".concat(prefixCls, "-wrapper-n-disabled")]: disabled
329
448
  });
330
- const restTags = [];
331
- const tags = [];
332
- (0, _forEach.default)(tagsArray).call(tagsArray, (value, index) => {
333
- let item = null;
334
-
335
- if ((0, _isFunction2.default)(renderTagItem)) {
336
- item = renderTagItem(value, index);
337
- } else {
338
- var _context2, _context3;
339
-
340
- item = /*#__PURE__*/_react.default.createElement(_tag.default, {
341
- className: tagCls,
342
- color: "white",
343
- size: size === 'small' ? 'small' : 'large',
344
- type: "light",
345
- onClose: () => {
346
- !disabled && this.handleTagClose(index);
347
- },
348
- closable: !disabled,
349
- key: (0, _concat.default)(_context2 = "".concat(index)).call(_context2, value),
350
- visible: true,
351
- "aria-label": (0, _concat.default)(_context3 = "".concat(!disabled ? 'Closable ' : '', "Tag: ")).call(_context3, value)
352
- }, /*#__PURE__*/_react.default.createElement(_paragraph.default, {
353
- className: typoCls,
354
- ellipsis: {
355
- showTooltip: showContentTooltip,
356
- rows: 1
357
- }
358
- }, value));
359
- }
449
+ const allTags = this.getAllTags();
450
+ let restTags = [];
451
+ let tags = [...allTags];
360
452
 
361
- if (maxTagCount && index >= maxTagCount) {
362
- restTags.push(item);
363
- } else {
364
- tags.push(item);
365
- }
366
- });
453
+ if ((!active || !expandRestTagsOnClick) && maxTagCount && maxTagCount < allTags.length) {
454
+ tags = (0, _slice.default)(allTags).call(allTags, 0, maxTagCount);
455
+ restTags = (0, _slice.default)(allTags).call(allTags, maxTagCount);
456
+ }
367
457
 
368
458
  const restTagsContent = /*#__PURE__*/_react.default.createElement("span", {
369
459
  className: restTagsCls
370
460
  }, "+", tagsArray.length - maxTagCount);
371
461
 
462
+ const sortableListItems = (0, _map.default)(allTags).call(allTags, (item, index) => ({
463
+ item: item,
464
+ key: tagsArray[index]
465
+ }));
466
+
467
+ if (active && draggable && sortableListItems.length > 0) {
468
+ // @ts-ignore skip SortableItem type check
469
+ return /*#__PURE__*/_react.default.createElement(SortableList, {
470
+ useDragHandle: true,
471
+ items: sortableListItems,
472
+ onSortEnd: this.onSortEnd,
473
+ axis: "xy"
474
+ });
475
+ }
476
+
372
477
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tags, restTags.length > 0 && (showRestTagsPopover ? /*#__PURE__*/_react.default.createElement(_popover.default, (0, _assign.default)({
373
478
  content: restTags,
374
479
  showArrow: true,
@@ -379,16 +484,24 @@ class TagInput extends _baseComponent.default {
379
484
  }
380
485
 
381
486
  blur() {
382
- this.inputRef.current.blur();
487
+ this.inputRef.current.blur(); // unregister clickOutside event
488
+
489
+ this.foundation.clickOutsideCallBack();
383
490
  }
384
491
 
385
492
  focus() {
386
493
  const {
387
- preventScroll
494
+ preventScroll,
495
+ disabled
388
496
  } = this.props;
389
497
  this.inputRef.current.focus({
390
498
  preventScroll
391
499
  });
500
+
501
+ if (!disabled) {
502
+ // register clickOutside event
503
+ this.foundation.handleClick();
504
+ }
392
505
  }
393
506
 
394
507
  render() {
@@ -404,10 +517,11 @@ class TagInput extends _baseComponent.default {
404
517
  focusing,
405
518
  hovering,
406
519
  tagsArray,
407
- inputValue
520
+ inputValue,
521
+ active
408
522
  } = this.state;
409
523
  const tagInputCls = (0, _classnames.default)(prefixCls, className, {
410
- ["".concat(prefixCls, "-focus")]: focusing,
524
+ ["".concat(prefixCls, "-focus")]: focusing || active,
411
525
  ["".concat(prefixCls, "-disabled")]: disabled,
412
526
  ["".concat(prefixCls, "-hover")]: hovering && !disabled,
413
527
  ["".concat(prefixCls, "-error")]: validateStatus === 'error',
@@ -415,41 +529,49 @@ class TagInput extends _baseComponent.default {
415
529
  });
416
530
  const inputCls = (0, _classnames.default)("".concat(prefixCls, "-wrapper-input"));
417
531
  const wrapperCls = (0, _classnames.default)("".concat(prefixCls, "-wrapper"));
418
- return /*#__PURE__*/_react.default.createElement("div", {
419
- style: style,
420
- className: tagInputCls,
421
- "aria-disabled": disabled,
422
- "aria-label": this.props['aria-label'],
423
- "aria-invalid": validateStatus === 'error',
424
- onMouseEnter: e => {
425
- this.handleInputMouseEnter(e);
426
- },
427
- onMouseLeave: e => {
428
- this.handleInputMouseLeave(e);
429
- }
430
- }, this.renderPrefix(), /*#__PURE__*/_react.default.createElement("div", {
431
- className: wrapperCls
432
- }, this.renderTags(), /*#__PURE__*/_react.default.createElement(_input.default, {
433
- "aria-label": 'input value',
434
- ref: this.inputRef,
435
- className: inputCls,
436
- disabled: disabled,
437
- value: inputValue,
438
- size: size,
439
- placeholder: tagsArray.length === 0 ? placeholder : '',
440
- onKeyDown: e => {
441
- this.handleKeyDown(e);
442
- },
443
- onChange: (v, e) => {
444
- this.handleInputChange(e);
445
- },
446
- onBlur: e => {
447
- this.handleInputBlur(e);
448
- },
449
- onFocus: e => {
450
- this.handleInputFocus(e);
451
- }
452
- })), this.renderClearBtn(), this.renderSuffix());
532
+ return (
533
+ /*#__PURE__*/
534
+ // eslint-disable-next-line
535
+ _react.default.createElement("div", {
536
+ ref: this.tagInputRef,
537
+ style: style,
538
+ className: tagInputCls,
539
+ "aria-disabled": disabled,
540
+ "aria-label": this.props['aria-label'],
541
+ "aria-invalid": validateStatus === 'error',
542
+ onMouseEnter: e => {
543
+ this.handleInputMouseEnter(e);
544
+ },
545
+ onMouseLeave: e => {
546
+ this.handleInputMouseLeave(e);
547
+ },
548
+ onClick: e => {
549
+ this.handleClick(e);
550
+ }
551
+ }, this.renderPrefix(), /*#__PURE__*/_react.default.createElement("div", {
552
+ className: wrapperCls
553
+ }, this.renderTags(), /*#__PURE__*/_react.default.createElement(_input.default, {
554
+ "aria-label": 'input value',
555
+ ref: this.inputRef,
556
+ className: inputCls,
557
+ disabled: disabled,
558
+ value: inputValue,
559
+ size: size,
560
+ placeholder: tagsArray.length === 0 ? placeholder : '',
561
+ onKeyDown: e => {
562
+ this.handleKeyDown(e);
563
+ },
564
+ onChange: (v, e) => {
565
+ this.handleInputChange(e);
566
+ },
567
+ onBlur: e => {
568
+ this.handleInputBlur(e);
569
+ },
570
+ onFocus: e => {
571
+ this.handleInputFocus(e);
572
+ }
573
+ })), this.renderClearBtn(), this.renderSuffix())
574
+ );
453
575
  }
454
576
 
455
577
  }
@@ -473,6 +595,8 @@ TagInput.propTypes = {
473
595
  separator: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.array]),
474
596
  showClear: _propTypes.default.bool,
475
597
  addOnBlur: _propTypes.default.bool,
598
+ draggable: _propTypes.default.bool,
599
+ expandRestTagsOnClick: _propTypes.default.bool,
476
600
  autoFocus: _propTypes.default.bool,
477
601
  renderTagItem: _propTypes.default.func,
478
602
  onBlur: _propTypes.default.func,
@@ -497,6 +621,8 @@ TagInput.defaultProps = {
497
621
  allowDuplicates: true,
498
622
  showRestTagsPopover: true,
499
623
  autoFocus: false,
624
+ draggable: false,
625
+ expandRestTagsOnClick: true,
500
626
  showContentTooltip: true,
501
627
  separator: ',',
502
628
  size: 'default',
@@ -167,7 +167,7 @@ class TimePicker extends _baseComponent.default {
167
167
 
168
168
  if (!isInTimepicker && !isInPanel) {
169
169
  const clickedOutside = true;
170
- this.foundation.hanldePanelClose(clickedOutside, e);
170
+ this.foundation.handlePanelClose(clickedOutside, e);
171
171
  }
172
172
  };
173
173
 
@@ -53,8 +53,10 @@ export interface TooltipProps extends BaseProps {
53
53
  guardFocus?: boolean;
54
54
  returnFocusOnClose?: boolean;
55
55
  onEscKeyDown?: (e: React.KeyboardEvent) => void;
56
+ disableArrowKeyDown?: boolean;
56
57
  wrapperId?: string;
57
58
  preventScroll?: boolean;
59
+ disableFocusListener?: boolean;
58
60
  }
59
61
  interface TooltipState {
60
62
  visible: boolean;
@@ -139,6 +141,8 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
139
141
  guardFocus: boolean;
140
142
  returnFocusOnClose: boolean;
141
143
  onEscKeyDown: (...args: any[]) => void;
144
+ disableFocusListener: boolean;
145
+ disableArrowKeyDown: boolean;
142
146
  };
143
147
  eventManager: Event;
144
148
  triggerEl: React.RefObject<unknown>;
@@ -721,8 +721,8 @@ class Tooltip extends _baseComponent.default {
721
721
  ref.current = node;
722
722
  }
723
723
  },
724
- tabIndex: 0,
725
- 'data-popupid': id
724
+ tabIndex: children.props.tabIndex || 0 // a11y keyboard, in some condition select's tabindex need to -1 or 0
725
+
726
726
  })); // If you do not add a layer of div, in order to bind the events and className in the tooltip, you need to cloneElement children, but this time it may overwrite the children's original ref reference
727
727
  // So if the user adds ref to the content, you need to use callback ref: https://github.com/facebook/react/issues/8873
728
728
 
@@ -790,5 +790,7 @@ Tooltip.defaultProps = {
790
790
  closeOnEsc: false,
791
791
  guardFocus: false,
792
792
  returnFocusOnClose: false,
793
- onEscKeyDown: _noop2.default
793
+ onEscKeyDown: _noop2.default,
794
+ disableFocusListener: false,
795
+ disableArrowKeyDown: false
794
796
  };
@@ -89,18 +89,12 @@ const wrapperDecorations = (props, content) => {
89
89
  underline,
90
90
  strong,
91
91
  link,
92
- disabled,
93
- icon
92
+ disabled
94
93
  } = props;
95
94
  let wrapped = content;
96
95
 
97
96
  const wrap = (isNeeded, tag) => {
98
- let wrapProps = icon ? {
99
- style: {
100
- display: 'inline-flex',
101
- alignItems: 'center'
102
- }
103
- } : {};
97
+ let wrapProps = {};
104
98
 
105
99
  if (!isNeeded) {
106
100
  return;
@@ -118,13 +112,7 @@ const wrapperDecorations = (props, content) => {
118
112
  wrap(underline && !link, 'u');
119
113
  wrap(strong, 'strong');
120
114
  wrap(props.delete, 'del');
121
- wrap(link, disabled ? 'span' : 'a'); // When the content is not wrapped, and there is more than one element in the content (one of which is an icon),
122
- // use span to wrap the content, so that the content in the span is vertically aligned
123
-
124
- if (wrapped === content && icon) {
125
- wrap(true, 'span');
126
- }
127
-
115
+ wrap(link, disabled ? 'span' : 'a');
128
116
  return wrapped;
129
117
  };
130
118
 
@@ -24,25 +24,15 @@ var _constants = require("@douyinfe/semi-foundation/lib/cjs/typography/constants
24
24
 
25
25
  var _base = _interopRequireDefault(require("./base"));
26
26
 
27
- var _classnames = _interopRequireDefault(require("classnames"));
28
-
29
27
  function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
30
28
 
31
29
  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; }
32
30
 
33
- const prefixCls = _constants.cssClasses.PREFIX;
34
-
35
31
  class Text extends _react.PureComponent {
36
32
  render() {
37
- const className = (0, _classnames.default)(this.props.className, {
38
- ["".concat(prefixCls, "-text")]: true,
39
- ["".concat(prefixCls, "-text-icon")]: this.props.icon
40
- });
41
33
  return /*#__PURE__*/_react.default.createElement(_base.default, (0, _assign.default)({
42
34
  component: 'span'
43
- }, this.props, {
44
- className: className
45
- }));
35
+ }, this.props));
46
36
  }
47
37
 
48
38
  }
@@ -19,7 +19,7 @@ export interface AvatarProps extends BaseProps {
19
19
  imgAttr?: React.ImgHTMLAttributes<HTMLImageElement>;
20
20
  }
21
21
  export declare type AvatarGroupShape = 'circle' | 'square';
22
- export declare type AvatarGroupSize = 'extra-extra-small' | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large';
22
+ export declare type AvatarGroupSize = 'extra-extra-small' | 'extra-small' | 'small' | 'default' | 'medium' | 'large' | 'extra-large';
23
23
  export declare type AvatarGroupOverlapFrom = 'start' | 'end';
24
24
  export interface AvatarGroupProps {
25
25
  children?: React.ReactNode;
@@ -742,6 +742,37 @@ class Cascader extends BaseComponent {
742
742
  return firstInProps || treeDataHasChange;
743
743
  };
744
744
 
745
+ const getRealKeys = (realValue, keyEntities) => {
746
+ // normallizedValue is used to save the value in two-dimensional array format
747
+ let normallizedValue = [];
748
+
749
+ if (_Array$isArray(realValue)) {
750
+ normallizedValue = _Array$isArray(realValue[0]) ? realValue : [realValue];
751
+ } else {
752
+ if (realValue !== undefined) {
753
+ normallizedValue = [[realValue]];
754
+ }
755
+ } // formatValuePath is used to save value of valuePath
756
+
757
+
758
+ const formatValuePath = [];
759
+
760
+ _forEachInstanceProperty(normallizedValue).call(normallizedValue, valueItem => {
761
+ const formatItem = onChangeWithObject ? _mapInstanceProperty(valueItem).call(valueItem, i => i === null || i === void 0 ? void 0 : i.value) : valueItem;
762
+ formatValuePath.push(formatItem);
763
+ }); // formatKeys is used to save key of value
764
+
765
+
766
+ const formatKeys = [];
767
+
768
+ _forEachInstanceProperty(formatValuePath).call(formatValuePath, v => {
769
+ const formatKeyItem = findKeysForValues(v, keyEntities);
770
+ !_isEmpty(formatKeyItem) && formatKeys.push(formatKeyItem);
771
+ });
772
+
773
+ return formatKeys;
774
+ };
775
+
745
776
  const needUpdateTreeData = needUpdate('treeData') || needUpdateData();
746
777
  const needUpdateValue = needUpdate('value') || _isEmpty(prevProps) && defaultValue;
747
778
 
@@ -758,35 +789,15 @@ class Cascader extends BaseComponent {
758
789
  let realKeys = prevState.checkedKeys; // when data was updated
759
790
 
760
791
  if (needUpdateValue) {
761
- // normallizedValue is used to save the value in two-dimensional array format
762
- let normallizedValue = [];
763
- const realValue = needUpdate('value') ? value : defaultValue; // eslint-disable-next-line max-depth
764
-
765
- if (_Array$isArray(realValue)) {
766
- normallizedValue = _Array$isArray(realValue[0]) ? realValue : [realValue];
767
- } else {
768
- if (realValue !== undefined) {
769
- normallizedValue = [[realValue]];
770
- }
771
- } // formatValuePath is used to save value of valuePath
772
-
773
-
774
- const formatValuePath = [];
775
-
776
- _forEachInstanceProperty(normallizedValue).call(normallizedValue, valueItem => {
777
- const formatItem = onChangeWithObject ? _mapInstanceProperty(valueItem).call(valueItem, i => i === null || i === void 0 ? void 0 : i.value) : valueItem;
778
- formatValuePath.push(formatItem);
779
- }); // formatKeys is used to save key of value
780
-
781
-
782
- const formatKeys = [];
783
-
784
- _forEachInstanceProperty(formatValuePath).call(formatValuePath, v => {
785
- const formatKeyItem = findKeysForValues(v, keyEntities);
786
- !_isEmpty(formatKeyItem) && formatKeys.push(formatKeyItem);
787
- });
788
-
789
- realKeys = formatKeys;
792
+ const realValue = needUpdate('value') ? value : defaultValue;
793
+ realKeys = getRealKeys(realValue, keyEntities);
794
+ } else {
795
+ // needUpdateValue is false
796
+ // if treeData is updated & Cascader is controlled, realKeys should be recalculated
797
+ if (needUpdateTreeData && 'value' in props) {
798
+ const realValue = value;
799
+ realKeys = getRealKeys(realValue, keyEntities);
800
+ }
790
801
  }
791
802
 
792
803
  if (_isSet(realKeys)) {
@@ -98,7 +98,10 @@ class Checkbox extends BaseComponent {
98
98
  }
99
99
 
100
100
  isInGroup() {
101
- return Boolean(this.context && this.context.checkboxGroup);
101
+ // Why do we need to determine whether there is a value in props?
102
+ // If there is no value in the props of the checkbox in the context of the checkboxGroup,
103
+ // it will be considered not to belong to the checkboxGroup。
104
+ return Boolean(this.context && this.context.checkboxGroup && 'value' in this.props);
102
105
  }
103
106
 
104
107
  focus() {
@@ -9,6 +9,8 @@ export interface CollapsePanelProps {
9
9
  children?: React.ReactNode;
10
10
  reCalcKey?: number | string;
11
11
  style?: CSSProperties;
12
+ showArrow?: boolean;
13
+ disabled?: boolean;
12
14
  }
13
15
  export default class CollapsePanel extends PureComponent<CollapsePanelProps> {
14
16
  static contextType: React.Context<CollapseContextType>;
@@ -18,6 +20,12 @@ export default class CollapsePanel extends PureComponent<CollapsePanelProps> {
18
20
  header: PropTypes.Requireable<PropTypes.ReactNodeLike>;
19
21
  className: PropTypes.Requireable<string>;
20
22
  reCalcKey: PropTypes.Requireable<string | number>;
23
+ showArrow: PropTypes.Requireable<boolean>;
24
+ disabled: PropTypes.Requireable<boolean>;
25
+ };
26
+ static defaultProps: {
27
+ showArrow: boolean;
28
+ disabled: boolean;
21
29
  };
22
30
  private ariaID;
23
31
  context: CollapseContextType;