@douyinfe/semi-ui 2.16.1 → 2.17.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/collapse/__test__/collapse.test.js +22 -2
- package/collapse/_story/accordion.stories.js +2 -2
- package/collapse/item.tsx +20 -6
- package/datePicker/__test__/datePicker.test.js +5 -5
- package/datePicker/_story/datePicker.stories.js +138 -22
- package/datePicker/datePicker.tsx +42 -7
- package/datePicker/monthsGrid.tsx +22 -10
- package/datePicker/quickControl.tsx +62 -16
- package/datePicker/yearAndMonth.tsx +31 -5
- package/dist/css/semi.css +289 -32
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +45706 -45192
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/collapse/item.d.ts +8 -0
- package/lib/cjs/collapse/item.js +19 -8
- package/lib/cjs/datePicker/datePicker.d.ts +3 -0
- package/lib/cjs/datePicker/datePicker.js +56 -9
- package/lib/cjs/datePicker/monthsGrid.d.ts +3 -0
- package/lib/cjs/datePicker/monthsGrid.js +14 -3
- package/lib/cjs/datePicker/quickControl.d.ts +6 -0
- package/lib/cjs/datePicker/quickControl.js +61 -14
- package/lib/cjs/datePicker/yearAndMonth.d.ts +3 -0
- package/lib/cjs/datePicker/yearAndMonth.js +15 -3
- package/lib/cjs/popover/index.d.ts +3 -0
- package/lib/cjs/popover/index.js +4 -2
- package/lib/cjs/select/index.d.ts +6 -1
- package/lib/cjs/select/index.js +130 -72
- package/lib/cjs/select/option.js +4 -2
- package/lib/cjs/tag/index.js +6 -4
- package/lib/cjs/tag/interface.d.ts +1 -0
- package/lib/cjs/tagInput/index.d.ts +13 -1
- package/lib/cjs/tagInput/index.js +217 -91
- package/lib/cjs/tooltip/index.d.ts +4 -0
- package/lib/cjs/tooltip/index.js +5 -3
- package/lib/es/collapse/item.d.ts +8 -0
- package/lib/es/collapse/item.js +19 -8
- package/lib/es/datePicker/datePicker.d.ts +3 -0
- package/lib/es/datePicker/datePicker.js +56 -9
- package/lib/es/datePicker/monthsGrid.d.ts +3 -0
- package/lib/es/datePicker/monthsGrid.js +14 -3
- package/lib/es/datePicker/quickControl.d.ts +6 -0
- package/lib/es/datePicker/quickControl.js +61 -15
- package/lib/es/datePicker/yearAndMonth.d.ts +3 -0
- package/lib/es/datePicker/yearAndMonth.js +14 -3
- package/lib/es/popover/index.d.ts +3 -0
- package/lib/es/popover/index.js +4 -2
- package/lib/es/select/index.d.ts +6 -1
- package/lib/es/select/index.js +129 -71
- package/lib/es/select/option.js +4 -2
- package/lib/es/tag/index.js +6 -4
- package/lib/es/tag/interface.d.ts +1 -0
- package/lib/es/tagInput/index.d.ts +13 -1
- package/lib/es/tagInput/index.js +217 -93
- package/lib/es/tooltip/index.d.ts +4 -0
- package/lib/es/tooltip/index.js +5 -3
- package/package.json +7 -7
- package/popover/index.tsx +4 -1
- package/select/__test__/select.test.js +5 -3
- package/select/index.tsx +65 -30
- package/select/option.tsx +2 -0
- package/tag/index.tsx +3 -2
- package/tag/interface.ts +1 -0
- package/tagInput/_story/tagInput.stories.js +18 -0
- package/tagInput/index.tsx +126 -26
- package/tooltip/index.tsx +5 -2
package/lib/cjs/select/index.js
CHANGED
|
@@ -56,7 +56,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
56
56
|
|
|
57
57
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
58
58
|
|
|
59
|
-
var
|
|
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
|
|
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
|
|
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
|
|
393
|
+
var _context7;
|
|
371
394
|
|
|
372
|
-
optionClassName = (0, _concat.default)(
|
|
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)(
|
|
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
|
|
428
|
+
var _context10, _context11;
|
|
405
429
|
|
|
406
|
-
const prevChildrenKeys = (0, _map2.default)(
|
|
407
|
-
const nowChildrenKeys = (0, _map2.default)(
|
|
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
|
-
//
|
|
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
|
|
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
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
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
|
|
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
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
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 =
|
|
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:
|
|
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,
|
|
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
|
package/lib/cjs/select/option.js
CHANGED
|
@@ -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
|
package/lib/cjs/tag/index.js
CHANGED
|
@@ -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;
|