@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
@@ -39,6 +39,7 @@ export interface PopoverProps extends BaseProps {
39
39
  returnFocusOnClose?: TooltipProps['returnFocusOnClose'];
40
40
  onEscKeyDown?: TooltipProps['onEscKeyDown'];
41
41
  clickToHide?: TooltipProps['clickToHide'];
42
+ disableFocusListener?: boolean;
42
43
  }
43
44
  export interface PopoverState {
44
45
  popConfirmVisible: boolean;
@@ -71,6 +72,7 @@ declare class Popover extends React.PureComponent<PopoverProps, PopoverState> {
71
72
  arrowBounding: PropTypes.Requireable<object>;
72
73
  prefixCls: PropTypes.Requireable<string>;
73
74
  guardFocus: PropTypes.Requireable<boolean>;
75
+ disableArrowKeyDown: PropTypes.Requireable<boolean>;
74
76
  };
75
77
  static defaultProps: {
76
78
  arrowBounding: {
@@ -93,6 +95,7 @@ declare class Popover extends React.PureComponent<PopoverProps, PopoverState> {
93
95
  closeOnEsc: boolean;
94
96
  returnFocusOnClose: boolean;
95
97
  guardFocus: boolean;
98
+ disableFocusListener: boolean;
96
99
  };
97
100
  context: ContextValue;
98
101
  renderPopCard: ({ initialFocusRef }: {
@@ -166,7 +166,8 @@ Popover.propTypes = {
166
166
  arrowPointAtCenter: _propTypes.default.bool,
167
167
  arrowBounding: _propTypes.default.object,
168
168
  prefixCls: _propTypes.default.string,
169
- guardFocus: _propTypes.default.bool
169
+ guardFocus: _propTypes.default.bool,
170
+ disableArrowKeyDown: _propTypes.default.bool
170
171
  };
171
172
  Popover.defaultProps = {
172
173
  arrowBounding: _constants.numbers.ARROW_BOUNDING,
@@ -183,7 +184,8 @@ Popover.defaultProps = {
183
184
  onEscKeyDown: _noop2.default,
184
185
  closeOnEsc: true,
185
186
  returnFocusOnClose: true,
186
- guardFocus: true
187
+ guardFocus: true,
188
+ disableFocusListener: true
187
189
  };
188
190
  var _default = Popover;
189
191
  exports.default = _default;
@@ -137,6 +137,7 @@ export interface SelectState {
137
137
  keyboardEventSet: any;
138
138
  optionGroups: Array<any>;
139
139
  isHovering: boolean;
140
+ isFocusInContainer: boolean;
140
141
  }
141
142
  declare class Select extends BaseComponent<SelectProps, SelectState> {
142
143
  static contextType: React.Context<ContextValue>;
@@ -220,13 +221,18 @@ declare class Select extends BaseComponent<SelectProps, SelectState> {
220
221
  static defaultProps: Partial<SelectProps>;
221
222
  inputRef: React.RefObject<HTMLInputElement>;
222
223
  triggerRef: React.RefObject<HTMLDivElement>;
224
+ optionContainerEl: React.RefObject<HTMLDivElement>;
223
225
  optionsRef: React.RefObject<any>;
224
226
  virtualizeListRef: React.RefObject<any>;
225
227
  selectOptionListID: string;
228
+ selectID: string;
226
229
  clickOutsideHandler: (e: MouseEvent) => void;
227
230
  foundation: SelectFoundation;
228
231
  context: ContextValue;
229
232
  constructor(props: SelectProps);
233
+ setOptionContainerEl: (node: HTMLDivElement) => {
234
+ current: HTMLDivElement;
235
+ };
230
236
  get adapter(): SelectAdapter<SelectProps, SelectState>;
231
237
  componentDidMount(): void;
232
238
  componentWillUnmount(): void;
@@ -241,7 +247,6 @@ declare class Select extends BaseComponent<SelectProps, SelectState> {
241
247
  focus(): void;
242
248
  onSelect(option: OptionProps, optionIndex: number, e: any): void;
243
249
  onClear(e: React.MouseEvent): void;
244
- onClearBtnEnterPress(e: React.KeyboardEvent): void;
245
250
  renderEmpty(): JSX.Element;
246
251
  renderLoading(): JSX.Element;
247
252
  renderOption(option: OptionProps, optionIndex: number, style?: React.CSSProperties): any;
@@ -56,7 +56,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
56
56
 
57
57
  var _propTypes = _interopRequireDefault(require("prop-types"));
58
58
 
59
- var _context15 = _interopRequireDefault(require("../configProvider/context"));
59
+ var _context17 = _interopRequireDefault(require("../configProvider/context"));
60
60
 
61
61
  var _foundation = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/select/foundation"));
62
62
 
@@ -112,10 +112,14 @@ const key = 0; // Notes: Use the label of the option as the identifier, that is,
112
112
 
113
113
  class Select extends _baseComponent.default {
114
114
  constructor(props) {
115
- var _context, _context2, _context3, _context4, _context5, _context6, _context7;
115
+ var _context, _context2, _context3, _context4, _context5, _context6;
116
116
 
117
117
  super(props);
118
118
 
119
+ this.setOptionContainerEl = node => this.optionContainerEl = {
120
+ current: node
121
+ };
122
+
119
123
  this.handleInputChange = value => this.foundation.handleInputChange(value);
120
124
 
121
125
  this.state = {
@@ -130,15 +134,18 @@ class Select extends _baseComponent.default {
130
134
  focusIndex: props.defaultActiveFirstOption ? 0 : -1,
131
135
  keyboardEventSet: {},
132
136
  optionGroups: [],
133
- isHovering: false
137
+ isHovering: false,
138
+ isFocusInContainer: false
134
139
  };
135
140
  /* Generate random string */
136
141
 
137
142
  this.selectOptionListID = '';
143
+ this.selectID = '';
138
144
  this.virtualizeListRef = /*#__PURE__*/_react.default.createRef();
139
145
  this.inputRef = /*#__PURE__*/_react.default.createRef();
140
146
  this.triggerRef = /*#__PURE__*/_react.default.createRef();
141
147
  this.optionsRef = /*#__PURE__*/_react.default.createRef();
148
+ this.optionContainerEl = /*#__PURE__*/_react.default.createRef();
142
149
  this.clickOutsideHandler = null;
143
150
  this.onSelect = (0, _bind.default)(_context = this.onSelect).call(_context, this);
144
151
  this.onClear = (0, _bind.default)(_context2 = this.onClear).call(_context2, this);
@@ -146,7 +153,6 @@ class Select extends _baseComponent.default {
146
153
  this.onMouseLeave = (0, _bind.default)(_context4 = this.onMouseLeave).call(_context4, this);
147
154
  this.renderOption = (0, _bind.default)(_context5 = this.renderOption).call(_context5, this);
148
155
  this.onKeyPress = (0, _bind.default)(_context6 = this.onKeyPress).call(_context6, this);
149
- this.onClearBtnEnterPress = (0, _bind.default)(_context7 = this.onClearBtnEnterPress).call(_context7, this);
150
156
  this.foundation = new _foundation.default(this.adapter);
151
157
  (0, _warning.default)('optionLabelProp' in this.props, '[Semi Select] \'optionLabelProp\' has already been deprecated, please use \'renderSelectedItem\' instead.');
152
158
  (0, _warning.default)('labelInValue' in this.props, '[Semi Select] \'labelInValue\' has already been deprecated, please use \'onChangeWithObject\' instead.');
@@ -360,19 +366,36 @@ class Select extends _baseComponent.default {
360
366
  });
361
367
  } catch (error) {}
362
368
  },
369
+ getContainer: () => {
370
+ return this.optionContainerEl && this.optionContainerEl.current;
371
+ },
372
+ getFocusableElements: node => {
373
+ return (0, _utils2.getFocusableElements)(node);
374
+ },
375
+ getActiveElement: () => {
376
+ return (0, _utils2.getActiveElement)();
377
+ },
378
+ setIsFocusInContainer: isFocusInContainer => {
379
+ this.setState({
380
+ isFocusInContainer
381
+ });
382
+ },
383
+ getIsFocusInContainer: () => {
384
+ return this.state.isFocusInContainer;
385
+ },
363
386
  updateScrollTop: index => {
364
- var _context9, _context10;
387
+ var _context8, _context9;
365
388
 
366
389
  // eslint-disable-next-line max-len
367
390
  let optionClassName = ".".concat(prefixcls, "-option-selected");
368
391
 
369
392
  if (index !== undefined) {
370
- var _context8;
393
+ var _context7;
371
394
 
372
- optionClassName = (0, _concat.default)(_context8 = ".".concat(prefixcls, "-option:nth-child(")).call(_context8, index, ")");
395
+ optionClassName = (0, _concat.default)(_context7 = ".".concat(prefixcls, "-option:nth-child(")).call(_context7, index, ")");
373
396
  }
374
397
 
375
- let destNode = document.querySelector((0, _concat.default)(_context9 = (0, _concat.default)(_context10 = "#".concat(prefixcls, "-")).call(_context10, this.selectOptionListID, " ")).call(_context9, optionClassName));
398
+ let destNode = document.querySelector((0, _concat.default)(_context8 = (0, _concat.default)(_context9 = "#".concat(prefixcls, "-")).call(_context9, this.selectOptionListID, " ")).call(_context8, optionClassName));
376
399
 
377
400
  if ((0, _isArray.default)(destNode)) {
378
401
  // eslint-disable-next-line prefer-destructuring
@@ -394,6 +417,7 @@ class Select extends _baseComponent.default {
394
417
  componentDidMount() {
395
418
  this.foundation.init();
396
419
  this.selectOptionListID = (0, _uuid.getUuidShort)();
420
+ this.selectID = this.props.id || (0, _uuid.getUuidShort)();
397
421
  }
398
422
 
399
423
  componentWillUnmount() {
@@ -401,10 +425,10 @@ class Select extends _baseComponent.default {
401
425
  }
402
426
 
403
427
  componentDidUpdate(prevProps, prevState) {
404
- var _context11, _context12;
428
+ var _context10, _context11;
405
429
 
406
- const prevChildrenKeys = (0, _map2.default)(_context11 = _react.default.Children.toArray(prevProps.children)).call(_context11, child => child.key);
407
- const nowChildrenKeys = (0, _map2.default)(_context12 = _react.default.Children.toArray(this.props.children)).call(_context12, child => child.key);
430
+ const prevChildrenKeys = (0, _map2.default)(_context10 = _react.default.Children.toArray(prevProps.children)).call(_context10, child => child.key);
431
+ const nowChildrenKeys = (0, _map2.default)(_context11 = _react.default.Children.toArray(this.props.children)).call(_context11, child => child.key);
408
432
  let isOptionsChanged = false;
409
433
 
410
434
  if (!(0, _isEqual2.default)(prevChildrenKeys, nowChildrenKeys) || !(0, _isEqual2.default)(prevProps.optionList, this.props.optionList)) {
@@ -423,11 +447,14 @@ class Select extends _baseComponent.default {
423
447
  }
424
448
 
425
449
  renderInput() {
450
+ var _context12;
451
+
426
452
  const {
427
453
  size,
428
454
  multiple,
429
455
  disabled,
430
- inputProps
456
+ inputProps,
457
+ filter
431
458
  } = this.props;
432
459
  const inputPropsCls = (0, _get2.default)(inputProps, 'className');
433
460
  const inputcls = (0, _classnames.default)("".concat(prefixcls, "-input"), {
@@ -435,7 +462,8 @@ class Select extends _baseComponent.default {
435
462
  ["".concat(prefixcls, "-input-multiple")]: multiple
436
463
  }, inputPropsCls);
437
464
  const {
438
- inputValue
465
+ inputValue,
466
+ focusIndex
439
467
  } = this.state;
440
468
  const selectInputProps = (0, _assign.default)({
441
469
  value: inputValue,
@@ -455,10 +483,20 @@ class Select extends _baseComponent.default {
455
483
  return /*#__PURE__*/_react.default.createElement(_index3.default, (0, _assign.default)({
456
484
  ref: this.inputRef,
457
485
  size: size,
486
+ "aria-activedescendant": focusIndex !== -1 ? (0, _concat.default)(_context12 = "".concat(this.selectID, "-option-")).call(_context12, focusIndex) : '',
458
487
  onFocus: e => {
459
- // prevent event bubbling which will fire trigger onFocus event
488
+ // if multiple and filter, when use tab key to let select get focus
489
+ // need to manual update state isFocus to let the focus style take effect
490
+ if (multiple && Boolean(filter)) {
491
+ this.setState({
492
+ isFocus: true
493
+ });
494
+ } // prevent event bubbling which will fire trigger onFocus event
495
+
496
+
460
497
  e.stopPropagation(); // e.nativeEvent.stopImmediatePropagation();
461
- }
498
+ },
499
+ onBlur: e => this.foundation.handleInputBlur(e)
462
500
  }, selectInputProps));
463
501
  }
464
502
 
@@ -494,12 +532,6 @@ class Select extends _baseComponent.default {
494
532
  e.nativeEvent.stopImmediatePropagation();
495
533
  this.foundation.handleClearClick(e);
496
534
  }
497
- /* istanbul ignore next */
498
-
499
-
500
- onClearBtnEnterPress(e) {
501
- this.foundation.handleClearBtnEnterPress(e);
502
- }
503
535
 
504
536
  renderEmpty() {
505
537
  return /*#__PURE__*/_react.default.createElement(_option.default, {
@@ -534,6 +566,8 @@ class Select extends _baseComponent.default {
534
566
  if (option._inputCreateOnly) {
535
567
  optionContent = this.renderCreateOption(option, isFocused, optionIndex, style);
536
568
  } else {
569
+ var _context13;
570
+
537
571
  // use another name to make sure that 'key' in optionList still exist when we call onChange
538
572
  if ('key' in option) {
539
573
  option._keyInOptionList = option.key;
@@ -549,7 +583,8 @@ class Select extends _baseComponent.default {
549
583
  style: optionStyle,
550
584
  key: option.key || option.label + option.value + optionIndex,
551
585
  renderOptionItem: renderOptionItem,
552
- inputValue: inputValue
586
+ inputValue: inputValue,
587
+ id: (0, _concat.default)(_context13 = "".concat(this.selectID, "-option-")).call(_context13, optionIndex)
553
588
  }), option.label);
554
589
  }
555
590
 
@@ -647,7 +682,7 @@ class Select extends _baseComponent.default {
647
682
  }
648
683
 
649
684
  renderOptions(children) {
650
- var _context13;
685
+ var _context14;
651
686
 
652
687
  const {
653
688
  dropdownMinWidth,
@@ -682,19 +717,25 @@ class Select extends _baseComponent.default {
682
717
  ["".concat(prefixcls, "-option-list-chosen")]: selections.size
683
718
  });
684
719
  const isEmpty = !options.length || !(0, _some.default)(options).call(options, item => item._show);
685
- return /*#__PURE__*/_react.default.createElement("div", {
686
- id: (0, _concat.default)(_context13 = "".concat(prefixcls, "-")).call(_context13, this.selectOptionListID),
687
- className: dropdownClassName,
688
- style: style
689
- }, outerTopSlot, /*#__PURE__*/_react.default.createElement("div", {
690
- style: {
691
- maxHeight: "".concat(maxHeight, "px")
692
- },
693
- className: optionListCls,
694
- role: "listbox",
695
- "aria-multiselectable": multiple,
696
- onScroll: e => this.foundation.handleListScroll(e)
697
- }, innerTopSlot, loading ? this.renderLoading() : isEmpty ? this.renderEmpty() : listContent, innerBottomSlot), outerBottomSlot);
720
+ return (
721
+ /*#__PURE__*/
722
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
723
+ _react.default.createElement("div", {
724
+ id: (0, _concat.default)(_context14 = "".concat(prefixcls, "-")).call(_context14, this.selectOptionListID),
725
+ className: dropdownClassName,
726
+ style: style,
727
+ ref: this.setOptionContainerEl,
728
+ onKeyDown: e => this.foundation.handleContainerKeyDown(e)
729
+ }, outerTopSlot, /*#__PURE__*/_react.default.createElement("div", {
730
+ style: {
731
+ maxHeight: "".concat(maxHeight, "px")
732
+ },
733
+ className: optionListCls,
734
+ role: "listbox",
735
+ "aria-multiselectable": multiple,
736
+ onScroll: e => this.foundation.handleListScroll(e)
737
+ }, innerTopSlot, loading ? this.renderLoading() : isEmpty ? this.renderEmpty() : listContent, innerBottomSlot), outerBottomSlot)
738
+ );
698
739
  }
699
740
 
700
741
  renderSingleSelection(selections, filterable) {
@@ -797,7 +838,8 @@ class Select extends _baseComponent.default {
797
838
  return /*#__PURE__*/_react.default.createElement(_index.default, (0, _assign.default)({}, basic, {
798
839
  color: "white",
799
840
  size: size || 'large',
800
- key: value
841
+ key: value,
842
+ tabIndex: -1
801
843
  }), content);
802
844
  } else {
803
845
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
@@ -917,7 +959,7 @@ class Select extends _baseComponent.default {
917
959
  }
918
960
 
919
961
  renderSelection() {
920
- var _context14;
962
+ var _context15, _context16;
921
963
 
922
964
  const {
923
965
  disabled,
@@ -942,7 +984,9 @@ class Select extends _baseComponent.default {
942
984
  keyboardEventSet,
943
985
  inputValue,
944
986
  isHovering,
945
- isFocus
987
+ isFocus,
988
+ showInput,
989
+ focusIndex
946
990
  } = this.state;
947
991
  const useCustomTrigger = typeof triggerRender === 'function';
948
992
  const filterable = Boolean(filter); // filter(boolean || function)
@@ -988,40 +1032,51 @@ class Select extends _baseComponent.default {
988
1032
  }, multiple ? this.renderMultipleSelection(selections, filterable) : this.renderSingleSelection(selections, filterable))), /*#__PURE__*/_react.default.createElement(_react.Fragment, {
989
1033
  key: "clearicon"
990
1034
  }, showClear ? /*#__PURE__*/_react.default.createElement("div", {
991
- role: "button",
992
- "aria-label": "Clear selected value",
993
- tabIndex: 0,
994
1035
  className: (0, _classnames.default)("".concat(prefixcls, "-clear")),
995
- onClick: this.onClear,
996
- onKeyPress: this.onClearBtnEnterPress
1036
+ onClick: this.onClear
997
1037
  }, /*#__PURE__*/_react.default.createElement(_semiIcons.IconClear, null)) : arrowContent), /*#__PURE__*/_react.default.createElement(_react.Fragment, {
998
1038
  key: "suffix"
999
1039
  }, suffix ? this.renderSuffix() : null)];
1000
- const tabIndex = disabled ? null : 0;
1001
- return /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({
1002
- role: "combobox",
1003
- "aria-disabled": disabled,
1004
- "aria-expanded": isOpen,
1005
- "aria-controls": (0, _concat.default)(_context14 = "".concat(prefixcls, "-")).call(_context14, this.selectOptionListID),
1006
- "aria-haspopup": "listbox",
1007
- "aria-label": "select value",
1008
- "aria-invalid": this.props['aria-invalid'],
1009
- "aria-errormessage": this.props['aria-errormessage'],
1010
- "aria-labelledby": this.props['aria-labelledby'],
1011
- "aria-describedby": this.props['aria-describedby'],
1012
- "aria-required": this.props['aria-required'],
1013
- className: selectionCls,
1014
- ref: ref => this.triggerRef.current = ref,
1015
- onClick: e => this.foundation.handleClick(e),
1016
- style: style,
1017
- id: id,
1018
- tabIndex: tabIndex,
1019
- onMouseEnter: this.onMouseEnter,
1020
- onMouseLeave: this.onMouseLeave,
1021
- // onFocus={e => this.foundation.handleTriggerFocus(e)}
1022
- onBlur: e => this.foundation.handleTriggerBlur(e),
1023
- onKeyPress: this.onKeyPress
1024
- }, keyboardEventSet), inner);
1040
+ /**
1041
+ *
1042
+ * In disabled, searchable single-selection and display input, and searchable multi-selection
1043
+ * make combobox not focusable by tab key
1044
+ *
1045
+ * 在disabled,可搜索单选且显示input框,以及可搜索多选情况下
1046
+ * 让combobox无法通过tab聚焦
1047
+ */
1048
+
1049
+ const tabIndex = disabled || filterable && showInput || filterable && multiple ? -1 : 0;
1050
+ return (
1051
+ /*#__PURE__*/
1052
+
1053
+ /* eslint-disable-next-line jsx-a11y/aria-activedescendant-has-tabindex */
1054
+ _react.default.createElement("div", (0, _assign.default)({
1055
+ role: "combobox",
1056
+ "aria-disabled": disabled,
1057
+ "aria-expanded": isOpen,
1058
+ "aria-controls": (0, _concat.default)(_context15 = "".concat(prefixcls, "-")).call(_context15, this.selectOptionListID),
1059
+ "aria-haspopup": "listbox",
1060
+ "aria-label": selections.size ? 'selected' : '',
1061
+ "aria-invalid": this.props['aria-invalid'],
1062
+ "aria-errormessage": this.props['aria-errormessage'],
1063
+ "aria-labelledby": this.props['aria-labelledby'],
1064
+ "aria-describedby": this.props['aria-describedby'],
1065
+ "aria-required": this.props['aria-required'],
1066
+ className: selectionCls,
1067
+ ref: ref => this.triggerRef.current = ref,
1068
+ onClick: e => this.foundation.handleClick(e),
1069
+ style: style,
1070
+ id: this.selectID,
1071
+ tabIndex: tabIndex,
1072
+ "aria-activedescendant": focusIndex !== -1 ? (0, _concat.default)(_context16 = "".concat(this.selectID, "-option-")).call(_context16, focusIndex) : '',
1073
+ onMouseEnter: this.onMouseEnter,
1074
+ onMouseLeave: this.onMouseLeave,
1075
+ onFocus: e => this.foundation.handleTriggerFocus(e),
1076
+ onBlur: e => this.foundation.handleTriggerBlur(e),
1077
+ onKeyPress: this.onKeyPress
1078
+ }, keyboardEventSet), inner)
1079
+ );
1025
1080
  }
1026
1081
 
1027
1082
  render() {
@@ -1063,13 +1118,14 @@ class Select extends _baseComponent.default {
1063
1118
  position: position,
1064
1119
  spacing: spacing,
1065
1120
  stopPropagation: stopPropagation,
1121
+ disableArrowKeyDown: true,
1066
1122
  onVisibleChange: status => this.handlePopoverVisibleChange(status)
1067
1123
  }, selection);
1068
1124
  }
1069
1125
 
1070
1126
  }
1071
1127
 
1072
- Select.contextType = _context15.default;
1128
+ Select.contextType = _context17.default;
1073
1129
  Select.Option = _option.default;
1074
1130
  Select.OptGroup = _optionGroup.default;
1075
1131
  Select.propTypes = {
@@ -1181,13 +1237,15 @@ Select.defaultProps = {
1181
1237
  onListScroll: _noop2.default,
1182
1238
  maxHeight: 300,
1183
1239
  dropdownMatchSelectWidth: true,
1184
- defaultActiveFirstOption: false,
1240
+ defaultActiveFirstOption: true,
1185
1241
  showArrow: true,
1186
1242
  showClear: false,
1187
1243
  remote: false,
1188
1244
  autoAdjustOverflow: true,
1189
1245
  autoClearSearchValue: true,
1190
- arrowIcon: /*#__PURE__*/_react.default.createElement(_semiIcons.IconChevronDown, null) // Radio selection is different from the default renderSelectedItem for multiple selection, so it is not declared here
1246
+ arrowIcon: /*#__PURE__*/_react.default.createElement(_semiIcons.IconChevronDown, {
1247
+ "aria-label": ''
1248
+ }) // Radio selection is different from the default renderSelectedItem for multiple selection, so it is not declared here
1191
1249
  // renderSelectedItem: (optionNode) => optionNode.label,
1192
1250
  // The default creator rendering is related to i18, so it is not declared here
1193
1251
  // renderCreateItem: (input) => input
@@ -108,9 +108,10 @@ class Option extends _react.PureComponent {
108
108
  onMouseEnter,
109
109
  prefixCls,
110
110
  renderOptionItem,
111
- inputValue
111
+ inputValue,
112
+ id
112
113
  } = _a,
113
- rest = __rest(_a, ["children", "disabled", "value", "selected", "label", "empty", "emptyContent", "onSelect", "focused", "showTick", "className", "style", "onMouseEnter", "prefixCls", "renderOptionItem", "inputValue"]);
114
+ rest = __rest(_a, ["children", "disabled", "value", "selected", "label", "empty", "emptyContent", "onSelect", "focused", "showTick", "className", "style", "onMouseEnter", "prefixCls", "renderOptionItem", "inputValue", "id"]);
114
115
 
115
116
  const optionClassName = (0, _classnames.default)(prefixCls, {
116
117
  ["".concat(prefixCls, "-disabled")]: disabled,
@@ -174,6 +175,7 @@ class Option extends _react.PureComponent {
174
175
  },
175
176
  onMouseEnter: e => onMouseEnter && onMouseEnter(e),
176
177
  role: "option",
178
+ id: id,
177
179
  "aria-selected": selected ? "true" : "false",
178
180
  "aria-disabled": disabled ? "true" : "false",
179
181
  style: style
@@ -192,17 +192,19 @@ class Tag extends _react.Component {
192
192
  className,
193
193
  type,
194
194
  avatarSrc,
195
- avatarShape
195
+ avatarShape,
196
+ tabIndex
196
197
  } = _a,
197
- attr = __rest(_a, ["children", "size", "color", "closable", "visible", "onClose", "onClick", "className", "type", "avatarSrc", "avatarShape"]);
198
+ attr = __rest(_a, ["children", "size", "color", "closable", "visible", "onClose", "onClick", "className", "type", "avatarSrc", "avatarShape", "tabIndex"]);
198
199
 
199
200
  const {
200
201
  visible: isVisible
201
202
  } = this.state;
202
- const clickable = onClick !== Tag.defaultProps.onClick || closable;
203
+ const clickable = onClick !== Tag.defaultProps.onClick || closable; // only when the Tag is clickable or closable, the value of tabIndex is allowed to be passed in.
204
+
203
205
  const a11yProps = {
204
206
  role: 'button',
205
- tabIndex: 0,
207
+ tabIndex: tabIndex | 0,
206
208
  onKeyDown: this.handleKeyDown
207
209
  };
208
210
  const baseProps = (0, _assign.default)((0, _assign.default)({}, attr), {
@@ -18,6 +18,7 @@ export interface TagProps {
18
18
  avatarShape?: AvatarShape;
19
19
  onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
20
20
  'aria-label'?: React.AriaAttributes['aria-label'];
21
+ tabIndex?: number;
21
22
  }
22
23
  export interface TagGroupProps {
23
24
  style?: React.CSSProperties;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { strings } from '@douyinfe/semi-foundation/lib/cjs/tagInput/constants';
4
4
  import '@douyinfe/semi-foundation/lib/cjs/tagInput/tagInput.css';
5
- import TagInputFoundation, { TagInputAdapter } from '@douyinfe/semi-foundation/lib/cjs/tagInput/foundation';
5
+ import TagInputFoundation, { TagInputAdapter, OnSortEndProps } from '@douyinfe/semi-foundation/lib/cjs/tagInput/foundation';
6
6
  import { ArrayElement } from '../_base/base';
7
7
  import BaseComponent from '../_base/baseComponent';
8
8
  import { PopoverProps } from '../popover';
@@ -22,6 +22,8 @@ export interface TagInputProps {
22
22
  showContentTooltip?: boolean;
23
23
  allowDuplicates?: boolean;
24
24
  addOnBlur?: boolean;
25
+ draggable?: boolean;
26
+ expandRestTagsOnClick?: boolean;
25
27
  onAdd?: (addedValue: string[]) => void;
26
28
  onBlur?: (e: React.MouseEvent<HTMLInputElement>) => void;
27
29
  onChange?: (value: string[]) => void;
@@ -52,6 +54,7 @@ export interface TagInputState {
52
54
  inputValue?: string;
53
55
  focusing?: boolean;
54
56
  hovering?: boolean;
57
+ active?: boolean;
55
58
  }
56
59
  declare class TagInput extends BaseComponent<TagInputProps, TagInputState> {
57
60
  static propTypes: {
@@ -73,6 +76,8 @@ declare class TagInput extends BaseComponent<TagInputProps, TagInputState> {
73
76
  separator: PropTypes.Requireable<string | any[]>;
74
77
  showClear: PropTypes.Requireable<boolean>;
75
78
  addOnBlur: PropTypes.Requireable<boolean>;
79
+ draggable: PropTypes.Requireable<boolean>;
80
+ expandRestTagsOnClick: PropTypes.Requireable<boolean>;
76
81
  autoFocus: PropTypes.Requireable<boolean>;
77
82
  renderTagItem: PropTypes.Requireable<(...args: any[]) => any>;
78
83
  onBlur: PropTypes.Requireable<(...args: any[]) => any>;
@@ -97,6 +102,8 @@ declare class TagInput extends BaseComponent<TagInputProps, TagInputState> {
97
102
  allowDuplicates: boolean;
98
103
  showRestTagsPopover: boolean;
99
104
  autoFocus: boolean;
105
+ draggable: boolean;
106
+ expandRestTagsOnClick: boolean;
100
107
  showContentTooltip: boolean;
101
108
  separator: string;
102
109
  size: "default";
@@ -112,7 +119,9 @@ declare class TagInput extends BaseComponent<TagInputProps, TagInputState> {
112
119
  onKeyDown: (...args: any[]) => void;
113
120
  };
114
121
  inputRef: React.RefObject<HTMLInputElement>;
122
+ tagInputRef: React.RefObject<HTMLDivElement>;
115
123
  foundation: TagInputFoundation;
124
+ clickOutsideHandler: any;
116
125
  constructor(props: TagInputProps);
117
126
  static getDerivedStateFromProps(nextProps: TagInputProps, prevState: TagInputState): {
118
127
  tagsArray: string[];
@@ -128,12 +137,15 @@ declare class TagInput extends BaseComponent<TagInputProps, TagInputState> {
128
137
  handleClearEnterPress: (e: React.KeyboardEvent<HTMLDivElement>) => void;
129
138
  handleTagClose: (idx: number) => void;
130
139
  handleInputMouseLeave: (e: React.MouseEvent<HTMLDivElement>) => void;
140
+ handleClick: (e: React.MouseEvent<HTMLDivElement>) => void;
131
141
  handleInputMouseEnter: (e: React.MouseEvent<HTMLDivElement>) => void;
132
142
  handleClickPrefixOrSuffix: (e: React.MouseEvent<HTMLInputElement>) => void;
133
143
  handlePreventMouseDown: (e: React.MouseEvent<HTMLInputElement>) => void;
134
144
  renderClearBtn(): JSX.Element;
135
145
  renderPrefix(): JSX.Element;
136
146
  renderSuffix(): JSX.Element;
147
+ getAllTags: () => (string | number | boolean | React.ReactFragment | JSX.Element)[];
148
+ onSortEnd: (callbackProps: OnSortEndProps) => void;
137
149
  renderTags(): JSX.Element;
138
150
  blur(): void;
139
151
  focus(): void;