@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/es/select/index.js
CHANGED
|
@@ -41,7 +41,7 @@ import OptionGroup from './optionGroup';
|
|
|
41
41
|
import Spin from '../spin';
|
|
42
42
|
import Trigger from '../trigger';
|
|
43
43
|
import { IconChevronDown, IconClear } from '@douyinfe/semi-icons';
|
|
44
|
-
import { isSemiIcon } from '../_utils';
|
|
44
|
+
import { isSemiIcon, getFocusableElements, getActiveElement } from '../_utils';
|
|
45
45
|
import warning from '@douyinfe/semi-foundation/lib/es/utils/warning';
|
|
46
46
|
import { getUuidShort } from '@douyinfe/semi-foundation/lib/es/utils/uuid';
|
|
47
47
|
import '@douyinfe/semi-foundation/lib/es/select/select.css';
|
|
@@ -50,10 +50,14 @@ const key = 0; // Notes: Use the label of the option as the identifier, that is,
|
|
|
50
50
|
|
|
51
51
|
class Select extends BaseComponent {
|
|
52
52
|
constructor(props) {
|
|
53
|
-
var _context, _context2, _context3, _context4, _context5, _context6
|
|
53
|
+
var _context, _context2, _context3, _context4, _context5, _context6;
|
|
54
54
|
|
|
55
55
|
super(props);
|
|
56
56
|
|
|
57
|
+
this.setOptionContainerEl = node => this.optionContainerEl = {
|
|
58
|
+
current: node
|
|
59
|
+
};
|
|
60
|
+
|
|
57
61
|
this.handleInputChange = value => this.foundation.handleInputChange(value);
|
|
58
62
|
|
|
59
63
|
this.state = {
|
|
@@ -68,15 +72,18 @@ class Select extends BaseComponent {
|
|
|
68
72
|
focusIndex: props.defaultActiveFirstOption ? 0 : -1,
|
|
69
73
|
keyboardEventSet: {},
|
|
70
74
|
optionGroups: [],
|
|
71
|
-
isHovering: false
|
|
75
|
+
isHovering: false,
|
|
76
|
+
isFocusInContainer: false
|
|
72
77
|
};
|
|
73
78
|
/* Generate random string */
|
|
74
79
|
|
|
75
80
|
this.selectOptionListID = '';
|
|
81
|
+
this.selectID = '';
|
|
76
82
|
this.virtualizeListRef = /*#__PURE__*/React.createRef();
|
|
77
83
|
this.inputRef = /*#__PURE__*/React.createRef();
|
|
78
84
|
this.triggerRef = /*#__PURE__*/React.createRef();
|
|
79
85
|
this.optionsRef = /*#__PURE__*/React.createRef();
|
|
86
|
+
this.optionContainerEl = /*#__PURE__*/React.createRef();
|
|
80
87
|
this.clickOutsideHandler = null;
|
|
81
88
|
this.onSelect = _bindInstanceProperty(_context = this.onSelect).call(_context, this);
|
|
82
89
|
this.onClear = _bindInstanceProperty(_context2 = this.onClear).call(_context2, this);
|
|
@@ -84,7 +91,6 @@ class Select extends BaseComponent {
|
|
|
84
91
|
this.onMouseLeave = _bindInstanceProperty(_context4 = this.onMouseLeave).call(_context4, this);
|
|
85
92
|
this.renderOption = _bindInstanceProperty(_context5 = this.renderOption).call(_context5, this);
|
|
86
93
|
this.onKeyPress = _bindInstanceProperty(_context6 = this.onKeyPress).call(_context6, this);
|
|
87
|
-
this.onClearBtnEnterPress = _bindInstanceProperty(_context7 = this.onClearBtnEnterPress).call(_context7, this);
|
|
88
94
|
this.foundation = new SelectFoundation(this.adapter);
|
|
89
95
|
warning('optionLabelProp' in this.props, '[Semi Select] \'optionLabelProp\' has already been deprecated, please use \'renderSelectedItem\' instead.');
|
|
90
96
|
warning('labelInValue' in this.props, '[Semi Select] \'labelInValue\' has already been deprecated, please use \'onChangeWithObject\' instead.');
|
|
@@ -297,19 +303,36 @@ class Select extends BaseComponent {
|
|
|
297
303
|
});
|
|
298
304
|
} catch (error) {}
|
|
299
305
|
},
|
|
306
|
+
getContainer: () => {
|
|
307
|
+
return this.optionContainerEl && this.optionContainerEl.current;
|
|
308
|
+
},
|
|
309
|
+
getFocusableElements: node => {
|
|
310
|
+
return getFocusableElements(node);
|
|
311
|
+
},
|
|
312
|
+
getActiveElement: () => {
|
|
313
|
+
return getActiveElement();
|
|
314
|
+
},
|
|
315
|
+
setIsFocusInContainer: isFocusInContainer => {
|
|
316
|
+
this.setState({
|
|
317
|
+
isFocusInContainer
|
|
318
|
+
});
|
|
319
|
+
},
|
|
320
|
+
getIsFocusInContainer: () => {
|
|
321
|
+
return this.state.isFocusInContainer;
|
|
322
|
+
},
|
|
300
323
|
updateScrollTop: index => {
|
|
301
|
-
var
|
|
324
|
+
var _context8, _context9;
|
|
302
325
|
|
|
303
326
|
// eslint-disable-next-line max-len
|
|
304
327
|
let optionClassName = ".".concat(prefixcls, "-option-selected");
|
|
305
328
|
|
|
306
329
|
if (index !== undefined) {
|
|
307
|
-
var
|
|
330
|
+
var _context7;
|
|
308
331
|
|
|
309
|
-
optionClassName = _concatInstanceProperty(
|
|
332
|
+
optionClassName = _concatInstanceProperty(_context7 = ".".concat(prefixcls, "-option:nth-child(")).call(_context7, index, ")");
|
|
310
333
|
}
|
|
311
334
|
|
|
312
|
-
let destNode = document.querySelector(_concatInstanceProperty(
|
|
335
|
+
let destNode = document.querySelector(_concatInstanceProperty(_context8 = _concatInstanceProperty(_context9 = "#".concat(prefixcls, "-")).call(_context9, this.selectOptionListID, " ")).call(_context8, optionClassName));
|
|
313
336
|
|
|
314
337
|
if (_Array$isArray(destNode)) {
|
|
315
338
|
// eslint-disable-next-line prefer-destructuring
|
|
@@ -331,6 +354,7 @@ class Select extends BaseComponent {
|
|
|
331
354
|
componentDidMount() {
|
|
332
355
|
this.foundation.init();
|
|
333
356
|
this.selectOptionListID = getUuidShort();
|
|
357
|
+
this.selectID = this.props.id || getUuidShort();
|
|
334
358
|
}
|
|
335
359
|
|
|
336
360
|
componentWillUnmount() {
|
|
@@ -338,11 +362,11 @@ class Select extends BaseComponent {
|
|
|
338
362
|
}
|
|
339
363
|
|
|
340
364
|
componentDidUpdate(prevProps, prevState) {
|
|
341
|
-
var
|
|
365
|
+
var _context10, _context11;
|
|
342
366
|
|
|
343
|
-
const prevChildrenKeys = _mapInstanceProperty(
|
|
367
|
+
const prevChildrenKeys = _mapInstanceProperty(_context10 = React.Children.toArray(prevProps.children)).call(_context10, child => child.key);
|
|
344
368
|
|
|
345
|
-
const nowChildrenKeys = _mapInstanceProperty(
|
|
369
|
+
const nowChildrenKeys = _mapInstanceProperty(_context11 = React.Children.toArray(this.props.children)).call(_context11, child => child.key);
|
|
346
370
|
|
|
347
371
|
let isOptionsChanged = false;
|
|
348
372
|
|
|
@@ -362,11 +386,14 @@ class Select extends BaseComponent {
|
|
|
362
386
|
}
|
|
363
387
|
|
|
364
388
|
renderInput() {
|
|
389
|
+
var _context12;
|
|
390
|
+
|
|
365
391
|
const {
|
|
366
392
|
size,
|
|
367
393
|
multiple,
|
|
368
394
|
disabled,
|
|
369
|
-
inputProps
|
|
395
|
+
inputProps,
|
|
396
|
+
filter
|
|
370
397
|
} = this.props;
|
|
371
398
|
|
|
372
399
|
const inputPropsCls = _get(inputProps, 'className');
|
|
@@ -376,7 +403,8 @@ class Select extends BaseComponent {
|
|
|
376
403
|
["".concat(prefixcls, "-input-multiple")]: multiple
|
|
377
404
|
}, inputPropsCls);
|
|
378
405
|
const {
|
|
379
|
-
inputValue
|
|
406
|
+
inputValue,
|
|
407
|
+
focusIndex
|
|
380
408
|
} = this.state;
|
|
381
409
|
|
|
382
410
|
const selectInputProps = _Object$assign({
|
|
@@ -398,10 +426,20 @@ class Select extends BaseComponent {
|
|
|
398
426
|
return /*#__PURE__*/React.createElement(Input, _Object$assign({
|
|
399
427
|
ref: this.inputRef,
|
|
400
428
|
size: size,
|
|
429
|
+
"aria-activedescendant": focusIndex !== -1 ? _concatInstanceProperty(_context12 = "".concat(this.selectID, "-option-")).call(_context12, focusIndex) : '',
|
|
401
430
|
onFocus: e => {
|
|
402
|
-
//
|
|
431
|
+
// if multiple and filter, when use tab key to let select get focus
|
|
432
|
+
// need to manual update state isFocus to let the focus style take effect
|
|
433
|
+
if (multiple && Boolean(filter)) {
|
|
434
|
+
this.setState({
|
|
435
|
+
isFocus: true
|
|
436
|
+
});
|
|
437
|
+
} // prevent event bubbling which will fire trigger onFocus event
|
|
438
|
+
|
|
439
|
+
|
|
403
440
|
e.stopPropagation(); // e.nativeEvent.stopImmediatePropagation();
|
|
404
|
-
}
|
|
441
|
+
},
|
|
442
|
+
onBlur: e => this.foundation.handleInputBlur(e)
|
|
405
443
|
}, selectInputProps));
|
|
406
444
|
}
|
|
407
445
|
|
|
@@ -437,12 +475,6 @@ class Select extends BaseComponent {
|
|
|
437
475
|
e.nativeEvent.stopImmediatePropagation();
|
|
438
476
|
this.foundation.handleClearClick(e);
|
|
439
477
|
}
|
|
440
|
-
/* istanbul ignore next */
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
onClearBtnEnterPress(e) {
|
|
444
|
-
this.foundation.handleClearBtnEnterPress(e);
|
|
445
|
-
}
|
|
446
478
|
|
|
447
479
|
renderEmpty() {
|
|
448
480
|
return /*#__PURE__*/React.createElement(Option, {
|
|
@@ -477,6 +509,8 @@ class Select extends BaseComponent {
|
|
|
477
509
|
if (option._inputCreateOnly) {
|
|
478
510
|
optionContent = this.renderCreateOption(option, isFocused, optionIndex, style);
|
|
479
511
|
} else {
|
|
512
|
+
var _context13;
|
|
513
|
+
|
|
480
514
|
// use another name to make sure that 'key' in optionList still exist when we call onChange
|
|
481
515
|
if ('key' in option) {
|
|
482
516
|
option._keyInOptionList = option.key;
|
|
@@ -492,7 +526,8 @@ class Select extends BaseComponent {
|
|
|
492
526
|
style: optionStyle,
|
|
493
527
|
key: option.key || option.label + option.value + optionIndex,
|
|
494
528
|
renderOptionItem: renderOptionItem,
|
|
495
|
-
inputValue: inputValue
|
|
529
|
+
inputValue: inputValue,
|
|
530
|
+
id: _concatInstanceProperty(_context13 = "".concat(this.selectID, "-option-")).call(_context13, optionIndex)
|
|
496
531
|
}), option.label);
|
|
497
532
|
}
|
|
498
533
|
|
|
@@ -590,7 +625,7 @@ class Select extends BaseComponent {
|
|
|
590
625
|
}
|
|
591
626
|
|
|
592
627
|
renderOptions(children) {
|
|
593
|
-
var
|
|
628
|
+
var _context14;
|
|
594
629
|
|
|
595
630
|
const {
|
|
596
631
|
dropdownMinWidth,
|
|
@@ -627,19 +662,25 @@ class Select extends BaseComponent {
|
|
|
627
662
|
["".concat(prefixcls, "-option-list-chosen")]: selections.size
|
|
628
663
|
});
|
|
629
664
|
const isEmpty = !options.length || !_someInstanceProperty(options).call(options, item => item._show);
|
|
630
|
-
return
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
665
|
+
return (
|
|
666
|
+
/*#__PURE__*/
|
|
667
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
668
|
+
React.createElement("div", {
|
|
669
|
+
id: _concatInstanceProperty(_context14 = "".concat(prefixcls, "-")).call(_context14, this.selectOptionListID),
|
|
670
|
+
className: dropdownClassName,
|
|
671
|
+
style: style,
|
|
672
|
+
ref: this.setOptionContainerEl,
|
|
673
|
+
onKeyDown: e => this.foundation.handleContainerKeyDown(e)
|
|
674
|
+
}, outerTopSlot, /*#__PURE__*/React.createElement("div", {
|
|
675
|
+
style: {
|
|
676
|
+
maxHeight: "".concat(maxHeight, "px")
|
|
677
|
+
},
|
|
678
|
+
className: optionListCls,
|
|
679
|
+
role: "listbox",
|
|
680
|
+
"aria-multiselectable": multiple,
|
|
681
|
+
onScroll: e => this.foundation.handleListScroll(e)
|
|
682
|
+
}, innerTopSlot, loading ? this.renderLoading() : isEmpty ? this.renderEmpty() : listContent, innerBottomSlot), outerBottomSlot)
|
|
683
|
+
);
|
|
643
684
|
}
|
|
644
685
|
|
|
645
686
|
renderSingleSelection(selections, filterable) {
|
|
@@ -742,7 +783,8 @@ class Select extends BaseComponent {
|
|
|
742
783
|
return /*#__PURE__*/React.createElement(Tag, _Object$assign({}, basic, {
|
|
743
784
|
color: "white",
|
|
744
785
|
size: size || 'large',
|
|
745
|
-
key: value
|
|
786
|
+
key: value,
|
|
787
|
+
tabIndex: -1
|
|
746
788
|
}), content);
|
|
747
789
|
} else {
|
|
748
790
|
return /*#__PURE__*/React.createElement(Fragment, {
|
|
@@ -865,7 +907,7 @@ class Select extends BaseComponent {
|
|
|
865
907
|
}
|
|
866
908
|
|
|
867
909
|
renderSelection() {
|
|
868
|
-
var
|
|
910
|
+
var _context15, _context16;
|
|
869
911
|
|
|
870
912
|
const {
|
|
871
913
|
disabled,
|
|
@@ -890,7 +932,9 @@ class Select extends BaseComponent {
|
|
|
890
932
|
keyboardEventSet,
|
|
891
933
|
inputValue,
|
|
892
934
|
isHovering,
|
|
893
|
-
isFocus
|
|
935
|
+
isFocus,
|
|
936
|
+
showInput,
|
|
937
|
+
focusIndex
|
|
894
938
|
} = this.state;
|
|
895
939
|
const useCustomTrigger = typeof triggerRender === 'function';
|
|
896
940
|
const filterable = Boolean(filter); // filter(boolean || function)
|
|
@@ -936,40 +980,51 @@ class Select extends BaseComponent {
|
|
|
936
980
|
}, multiple ? this.renderMultipleSelection(selections, filterable) : this.renderSingleSelection(selections, filterable))), /*#__PURE__*/React.createElement(Fragment, {
|
|
937
981
|
key: "clearicon"
|
|
938
982
|
}, showClear ? /*#__PURE__*/React.createElement("div", {
|
|
939
|
-
role: "button",
|
|
940
|
-
"aria-label": "Clear selected value",
|
|
941
|
-
tabIndex: 0,
|
|
942
983
|
className: cls("".concat(prefixcls, "-clear")),
|
|
943
|
-
onClick: this.onClear
|
|
944
|
-
onKeyPress: this.onClearBtnEnterPress
|
|
984
|
+
onClick: this.onClear
|
|
945
985
|
}, /*#__PURE__*/React.createElement(IconClear, null)) : arrowContent), /*#__PURE__*/React.createElement(Fragment, {
|
|
946
986
|
key: "suffix"
|
|
947
987
|
}, suffix ? this.renderSuffix() : null)];
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
988
|
+
/**
|
|
989
|
+
*
|
|
990
|
+
* In disabled, searchable single-selection and display input, and searchable multi-selection
|
|
991
|
+
* make combobox not focusable by tab key
|
|
992
|
+
*
|
|
993
|
+
* 在disabled,可搜索单选且显示input框,以及可搜索多选情况下
|
|
994
|
+
* 让combobox无法通过tab聚焦
|
|
995
|
+
*/
|
|
996
|
+
|
|
997
|
+
const tabIndex = disabled || filterable && showInput || filterable && multiple ? -1 : 0;
|
|
998
|
+
return (
|
|
999
|
+
/*#__PURE__*/
|
|
1000
|
+
|
|
1001
|
+
/* eslint-disable-next-line jsx-a11y/aria-activedescendant-has-tabindex */
|
|
1002
|
+
React.createElement("div", _Object$assign({
|
|
1003
|
+
role: "combobox",
|
|
1004
|
+
"aria-disabled": disabled,
|
|
1005
|
+
"aria-expanded": isOpen,
|
|
1006
|
+
"aria-controls": _concatInstanceProperty(_context15 = "".concat(prefixcls, "-")).call(_context15, this.selectOptionListID),
|
|
1007
|
+
"aria-haspopup": "listbox",
|
|
1008
|
+
"aria-label": selections.size ? 'selected' : '',
|
|
1009
|
+
"aria-invalid": this.props['aria-invalid'],
|
|
1010
|
+
"aria-errormessage": this.props['aria-errormessage'],
|
|
1011
|
+
"aria-labelledby": this.props['aria-labelledby'],
|
|
1012
|
+
"aria-describedby": this.props['aria-describedby'],
|
|
1013
|
+
"aria-required": this.props['aria-required'],
|
|
1014
|
+
className: selectionCls,
|
|
1015
|
+
ref: ref => this.triggerRef.current = ref,
|
|
1016
|
+
onClick: e => this.foundation.handleClick(e),
|
|
1017
|
+
style: style,
|
|
1018
|
+
id: this.selectID,
|
|
1019
|
+
tabIndex: tabIndex,
|
|
1020
|
+
"aria-activedescendant": focusIndex !== -1 ? _concatInstanceProperty(_context16 = "".concat(this.selectID, "-option-")).call(_context16, focusIndex) : '',
|
|
1021
|
+
onMouseEnter: this.onMouseEnter,
|
|
1022
|
+
onMouseLeave: this.onMouseLeave,
|
|
1023
|
+
onFocus: e => this.foundation.handleTriggerFocus(e),
|
|
1024
|
+
onBlur: e => this.foundation.handleTriggerBlur(e),
|
|
1025
|
+
onKeyPress: this.onKeyPress
|
|
1026
|
+
}, keyboardEventSet), inner)
|
|
1027
|
+
);
|
|
973
1028
|
}
|
|
974
1029
|
|
|
975
1030
|
render() {
|
|
@@ -1011,6 +1066,7 @@ class Select extends BaseComponent {
|
|
|
1011
1066
|
position: position,
|
|
1012
1067
|
spacing: spacing,
|
|
1013
1068
|
stopPropagation: stopPropagation,
|
|
1069
|
+
disableArrowKeyDown: true,
|
|
1014
1070
|
onVisibleChange: status => this.handlePopoverVisibleChange(status)
|
|
1015
1071
|
}, selection);
|
|
1016
1072
|
}
|
|
@@ -1129,13 +1185,15 @@ Select.defaultProps = {
|
|
|
1129
1185
|
onListScroll: _noop,
|
|
1130
1186
|
maxHeight: 300,
|
|
1131
1187
|
dropdownMatchSelectWidth: true,
|
|
1132
|
-
defaultActiveFirstOption:
|
|
1188
|
+
defaultActiveFirstOption: true,
|
|
1133
1189
|
showArrow: true,
|
|
1134
1190
|
showClear: false,
|
|
1135
1191
|
remote: false,
|
|
1136
1192
|
autoAdjustOverflow: true,
|
|
1137
1193
|
autoClearSearchValue: true,
|
|
1138
|
-
arrowIcon: /*#__PURE__*/React.createElement(IconChevronDown,
|
|
1194
|
+
arrowIcon: /*#__PURE__*/React.createElement(IconChevronDown, {
|
|
1195
|
+
"aria-label": ''
|
|
1196
|
+
}) // Radio selection is different from the default renderSelectedItem for multiple selection, so it is not declared here
|
|
1139
1197
|
// renderSelectedItem: (optionNode) => optionNode.label,
|
|
1140
1198
|
// The default creator rendering is related to i18, so it is not declared here
|
|
1141
1199
|
// renderCreateItem: (input) => input
|
package/lib/es/select/option.js
CHANGED
|
@@ -79,9 +79,10 @@ class Option extends PureComponent {
|
|
|
79
79
|
onMouseEnter,
|
|
80
80
|
prefixCls,
|
|
81
81
|
renderOptionItem,
|
|
82
|
-
inputValue
|
|
82
|
+
inputValue,
|
|
83
|
+
id
|
|
83
84
|
} = _a,
|
|
84
|
-
rest = __rest(_a, ["children", "disabled", "value", "selected", "label", "empty", "emptyContent", "onSelect", "focused", "showTick", "className", "style", "onMouseEnter", "prefixCls", "renderOptionItem", "inputValue"]);
|
|
85
|
+
rest = __rest(_a, ["children", "disabled", "value", "selected", "label", "empty", "emptyContent", "onSelect", "focused", "showTick", "className", "style", "onMouseEnter", "prefixCls", "renderOptionItem", "inputValue", "id"]);
|
|
85
86
|
|
|
86
87
|
const optionClassName = classNames(prefixCls, {
|
|
87
88
|
["".concat(prefixCls, "-disabled")]: disabled,
|
|
@@ -145,6 +146,7 @@ class Option extends PureComponent {
|
|
|
145
146
|
},
|
|
146
147
|
onMouseEnter: e => onMouseEnter && onMouseEnter(e),
|
|
147
148
|
role: "option",
|
|
149
|
+
id: id,
|
|
148
150
|
"aria-selected": selected ? "true" : "false",
|
|
149
151
|
"aria-disabled": disabled ? "true" : "false",
|
|
150
152
|
style: style
|
package/lib/es/tag/index.js
CHANGED
|
@@ -135,17 +135,19 @@ export default class Tag extends Component {
|
|
|
135
135
|
className,
|
|
136
136
|
type,
|
|
137
137
|
avatarSrc,
|
|
138
|
-
avatarShape
|
|
138
|
+
avatarShape,
|
|
139
|
+
tabIndex
|
|
139
140
|
} = _a,
|
|
140
|
-
attr = __rest(_a, ["children", "size", "color", "closable", "visible", "onClose", "onClick", "className", "type", "avatarSrc", "avatarShape"]);
|
|
141
|
+
attr = __rest(_a, ["children", "size", "color", "closable", "visible", "onClose", "onClick", "className", "type", "avatarSrc", "avatarShape", "tabIndex"]);
|
|
141
142
|
|
|
142
143
|
const {
|
|
143
144
|
visible: isVisible
|
|
144
145
|
} = this.state;
|
|
145
|
-
const clickable = onClick !== Tag.defaultProps.onClick || closable;
|
|
146
|
+
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.
|
|
147
|
+
|
|
146
148
|
const a11yProps = {
|
|
147
149
|
role: 'button',
|
|
148
|
-
tabIndex: 0,
|
|
150
|
+
tabIndex: tabIndex | 0,
|
|
149
151
|
onKeyDown: this.handleKeyDown
|
|
150
152
|
};
|
|
151
153
|
|
|
@@ -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/es/tagInput/constants';
|
|
4
4
|
import '@douyinfe/semi-foundation/lib/es/tagInput/tagInput.css';
|
|
5
|
-
import TagInputFoundation, { TagInputAdapter } from '@douyinfe/semi-foundation/lib/es/tagInput/foundation';
|
|
5
|
+
import TagInputFoundation, { TagInputAdapter, OnSortEndProps } from '@douyinfe/semi-foundation/lib/es/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;
|