@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/tagInput/index.js
CHANGED
|
@@ -4,9 +4,10 @@ import _isNull from "lodash/isNull";
|
|
|
4
4
|
import _isArray from "lodash/isArray";
|
|
5
5
|
import _isString from "lodash/isString";
|
|
6
6
|
import _noop from "lodash/noop";
|
|
7
|
-
import
|
|
7
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
8
8
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
9
|
-
import
|
|
9
|
+
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
10
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
10
11
|
import React from 'react';
|
|
11
12
|
import cls from 'classnames';
|
|
12
13
|
import PropTypes from 'prop-types';
|
|
@@ -19,7 +20,27 @@ import Tag from '../tag';
|
|
|
19
20
|
import Input from '../input';
|
|
20
21
|
import Popover from '../popover';
|
|
21
22
|
import Paragraph from '../typography/paragraph';
|
|
22
|
-
import { IconClear } from '@douyinfe/semi-icons';
|
|
23
|
+
import { IconClear, IconHandle } from '@douyinfe/semi-icons';
|
|
24
|
+
import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
|
|
25
|
+
const SortableItem = SortableElement(props => props.item);
|
|
26
|
+
const SortableList = SortableContainer(_ref => {
|
|
27
|
+
let {
|
|
28
|
+
items
|
|
29
|
+
} = _ref;
|
|
30
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
style: {
|
|
32
|
+
display: 'flex',
|
|
33
|
+
flexFlow: 'row wrap'
|
|
34
|
+
}
|
|
35
|
+
}, _mapInstanceProperty(items).call(items, (item, index) =>
|
|
36
|
+
/*#__PURE__*/
|
|
37
|
+
// @ts-ignore skip SortableItem type check
|
|
38
|
+
React.createElement(SortableItem, {
|
|
39
|
+
key: item.key,
|
|
40
|
+
index: index,
|
|
41
|
+
item: item.item
|
|
42
|
+
})));
|
|
43
|
+
});
|
|
23
44
|
const prefixCls = cssClasses.PREFIX;
|
|
24
45
|
|
|
25
46
|
class TagInput extends BaseComponent {
|
|
@@ -60,6 +81,10 @@ class TagInput extends BaseComponent {
|
|
|
60
81
|
this.foundation.handleInputMouseLeave();
|
|
61
82
|
};
|
|
62
83
|
|
|
84
|
+
this.handleClick = e => {
|
|
85
|
+
this.foundation.handleClick(e);
|
|
86
|
+
};
|
|
87
|
+
|
|
63
88
|
this.handleInputMouseEnter = e => {
|
|
64
89
|
this.foundation.handleInputMouseEnter();
|
|
65
90
|
};
|
|
@@ -72,14 +97,86 @@ class TagInput extends BaseComponent {
|
|
|
72
97
|
this.foundation.handlePreventMouseDown(e);
|
|
73
98
|
};
|
|
74
99
|
|
|
100
|
+
this.getAllTags = () => {
|
|
101
|
+
var _context;
|
|
102
|
+
|
|
103
|
+
const {
|
|
104
|
+
size,
|
|
105
|
+
disabled,
|
|
106
|
+
renderTagItem,
|
|
107
|
+
showContentTooltip,
|
|
108
|
+
draggable
|
|
109
|
+
} = this.props;
|
|
110
|
+
const {
|
|
111
|
+
tagsArray,
|
|
112
|
+
active
|
|
113
|
+
} = this.state;
|
|
114
|
+
const showIconHandler = active && draggable;
|
|
115
|
+
const tagCls = cls("".concat(prefixCls, "-wrapper-tag"), {
|
|
116
|
+
[_concatInstanceProperty(_context = "".concat(prefixCls, "-wrapper-tag-size-")).call(_context, size)]: size,
|
|
117
|
+
["".concat(prefixCls, "-wrapper-tag-icon")]: showIconHandler
|
|
118
|
+
});
|
|
119
|
+
const typoCls = cls("".concat(prefixCls, "-wrapper-typo"), {
|
|
120
|
+
["".concat(prefixCls, "-wrapper-typo-disabled")]: disabled
|
|
121
|
+
});
|
|
122
|
+
const itemWrapperCls = cls({
|
|
123
|
+
["".concat(prefixCls, "-drag-item")]: showIconHandler,
|
|
124
|
+
["".concat(prefixCls, "-wrapper-tag-icon")]: showIconHandler
|
|
125
|
+
});
|
|
126
|
+
const DragHandle = SortableHandle(() => /*#__PURE__*/React.createElement(IconHandle, {
|
|
127
|
+
className: "".concat(prefixCls, "-drag-handler")
|
|
128
|
+
}));
|
|
129
|
+
return _mapInstanceProperty(tagsArray).call(tagsArray, (value, index) => {
|
|
130
|
+
var _context2;
|
|
131
|
+
|
|
132
|
+
const elementKey = showIconHandler ? value : _concatInstanceProperty(_context2 = "".concat(index)).call(_context2, value);
|
|
133
|
+
|
|
134
|
+
if (_isFunction(renderTagItem)) {
|
|
135
|
+
return showIconHandler ? /*#__PURE__*/React.createElement("div", {
|
|
136
|
+
className: itemWrapperCls,
|
|
137
|
+
key: elementKey
|
|
138
|
+
}, /*#__PURE__*/React.createElement(DragHandle, null), renderTagItem(value, index)) : renderTagItem(value, index);
|
|
139
|
+
} else {
|
|
140
|
+
var _context3;
|
|
141
|
+
|
|
142
|
+
return /*#__PURE__*/React.createElement(Tag, {
|
|
143
|
+
className: tagCls,
|
|
144
|
+
color: "white",
|
|
145
|
+
size: size === 'small' ? 'small' : 'large',
|
|
146
|
+
type: "light",
|
|
147
|
+
onClose: () => {
|
|
148
|
+
!disabled && this.handleTagClose(index);
|
|
149
|
+
},
|
|
150
|
+
closable: !disabled,
|
|
151
|
+
key: elementKey,
|
|
152
|
+
visible: true,
|
|
153
|
+
"aria-label": _concatInstanceProperty(_context3 = "".concat(!disabled ? 'Closable ' : '', "Tag: ")).call(_context3, value)
|
|
154
|
+
}, showIconHandler && /*#__PURE__*/React.createElement(DragHandle, null), /*#__PURE__*/React.createElement(Paragraph, {
|
|
155
|
+
className: typoCls,
|
|
156
|
+
ellipsis: {
|
|
157
|
+
showTooltip: showContentTooltip,
|
|
158
|
+
rows: 1
|
|
159
|
+
}
|
|
160
|
+
}, value));
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
this.onSortEnd = callbackProps => {
|
|
166
|
+
this.foundation.handleSortEnd(callbackProps);
|
|
167
|
+
};
|
|
168
|
+
|
|
75
169
|
this.foundation = new TagInputFoundation(this.adapter);
|
|
76
170
|
this.state = {
|
|
77
171
|
tagsArray: props.defaultValue || [],
|
|
78
172
|
inputValue: '',
|
|
79
173
|
focusing: false,
|
|
80
|
-
hovering: false
|
|
174
|
+
hovering: false,
|
|
175
|
+
active: false
|
|
81
176
|
};
|
|
82
177
|
this.inputRef = /*#__PURE__*/React.createRef();
|
|
178
|
+
this.tagInputRef = /*#__PURE__*/React.createRef();
|
|
179
|
+
this.clickOutsideHandler = null;
|
|
83
180
|
}
|
|
84
181
|
|
|
85
182
|
static getDerivedStateFromProps(nextProps, prevState) {
|
|
@@ -146,6 +243,14 @@ class TagInput extends BaseComponent {
|
|
|
146
243
|
hovering
|
|
147
244
|
});
|
|
148
245
|
},
|
|
246
|
+
setActive: active => {
|
|
247
|
+
this.setState({
|
|
248
|
+
active
|
|
249
|
+
});
|
|
250
|
+
},
|
|
251
|
+
getClickOutsideHandler: () => {
|
|
252
|
+
return this.clickOutsideHandler;
|
|
253
|
+
},
|
|
149
254
|
notifyBlur: e => {
|
|
150
255
|
this.props.onBlur(e);
|
|
151
256
|
},
|
|
@@ -166,6 +271,23 @@ class TagInput extends BaseComponent {
|
|
|
166
271
|
},
|
|
167
272
|
notifyKeyDown: e => {
|
|
168
273
|
this.props.onKeyDown(e);
|
|
274
|
+
},
|
|
275
|
+
registerClickOutsideHandler: cb => {
|
|
276
|
+
const clickOutsideHandler = e => {
|
|
277
|
+
const tagInputDom = this.tagInputRef && this.tagInputRef.current;
|
|
278
|
+
const target = e.target;
|
|
279
|
+
|
|
280
|
+
if (tagInputDom && !tagInputDom.contains(target)) {
|
|
281
|
+
cb(e);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
this.clickOutsideHandler = clickOutsideHandler;
|
|
286
|
+
document.addEventListener('click', clickOutsideHandler, false);
|
|
287
|
+
},
|
|
288
|
+
unregisterClickOutsideHandler: () => {
|
|
289
|
+
document.removeEventListener('click', this.clickOutsideHandler, false);
|
|
290
|
+
this.clickOutsideHandler = null;
|
|
169
291
|
}
|
|
170
292
|
});
|
|
171
293
|
}
|
|
@@ -181,7 +303,10 @@ class TagInput extends BaseComponent {
|
|
|
181
303
|
this.inputRef.current.focus({
|
|
182
304
|
preventScroll
|
|
183
305
|
});
|
|
306
|
+
this.foundation.handleClick();
|
|
184
307
|
}
|
|
308
|
+
|
|
309
|
+
this.foundation.init();
|
|
185
310
|
}
|
|
186
311
|
|
|
187
312
|
renderClearBtn() {
|
|
@@ -270,71 +395,49 @@ class TagInput extends BaseComponent {
|
|
|
270
395
|
}
|
|
271
396
|
|
|
272
397
|
renderTags() {
|
|
273
|
-
var _context;
|
|
274
|
-
|
|
275
398
|
const {
|
|
276
|
-
size,
|
|
277
399
|
disabled,
|
|
278
|
-
renderTagItem,
|
|
279
400
|
maxTagCount,
|
|
280
|
-
showContentTooltip,
|
|
281
401
|
showRestTagsPopover,
|
|
282
|
-
restTagsPopoverProps = {}
|
|
402
|
+
restTagsPopoverProps = {},
|
|
403
|
+
draggable,
|
|
404
|
+
expandRestTagsOnClick
|
|
283
405
|
} = this.props;
|
|
284
406
|
const {
|
|
285
|
-
tagsArray
|
|
407
|
+
tagsArray,
|
|
408
|
+
active
|
|
286
409
|
} = this.state;
|
|
287
|
-
const tagCls = cls("".concat(prefixCls, "-wrapper-tag"), {
|
|
288
|
-
[_concatInstanceProperty(_context = "".concat(prefixCls, "-wrapper-tag-size-")).call(_context, size)]: size
|
|
289
|
-
});
|
|
290
|
-
const typoCls = cls("".concat(prefixCls, "-wrapper-typo"), {
|
|
291
|
-
["".concat(prefixCls, "-wrapper-typo-disabled")]: disabled
|
|
292
|
-
});
|
|
293
410
|
const restTagsCls = cls("".concat(prefixCls, "-wrapper-n"), {
|
|
294
411
|
["".concat(prefixCls, "-wrapper-n-disabled")]: disabled
|
|
295
412
|
});
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
_forEachInstanceProperty(tagsArray).call(tagsArray, (value, index) => {
|
|
300
|
-
let item = null;
|
|
301
|
-
|
|
302
|
-
if (_isFunction(renderTagItem)) {
|
|
303
|
-
item = renderTagItem(value, index);
|
|
304
|
-
} else {
|
|
305
|
-
var _context2, _context3;
|
|
306
|
-
|
|
307
|
-
item = /*#__PURE__*/React.createElement(Tag, {
|
|
308
|
-
className: tagCls,
|
|
309
|
-
color: "white",
|
|
310
|
-
size: size === 'small' ? 'small' : 'large',
|
|
311
|
-
type: "light",
|
|
312
|
-
onClose: () => {
|
|
313
|
-
!disabled && this.handleTagClose(index);
|
|
314
|
-
},
|
|
315
|
-
closable: !disabled,
|
|
316
|
-
key: _concatInstanceProperty(_context2 = "".concat(index)).call(_context2, value),
|
|
317
|
-
visible: true,
|
|
318
|
-
"aria-label": _concatInstanceProperty(_context3 = "".concat(!disabled ? 'Closable ' : '', "Tag: ")).call(_context3, value)
|
|
319
|
-
}, /*#__PURE__*/React.createElement(Paragraph, {
|
|
320
|
-
className: typoCls,
|
|
321
|
-
ellipsis: {
|
|
322
|
-
showTooltip: showContentTooltip,
|
|
323
|
-
rows: 1
|
|
324
|
-
}
|
|
325
|
-
}, value));
|
|
326
|
-
}
|
|
413
|
+
const allTags = this.getAllTags();
|
|
414
|
+
let restTags = [];
|
|
415
|
+
let tags = [...allTags];
|
|
327
416
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
});
|
|
417
|
+
if ((!active || !expandRestTagsOnClick) && maxTagCount && maxTagCount < allTags.length) {
|
|
418
|
+
tags = _sliceInstanceProperty(allTags).call(allTags, 0, maxTagCount);
|
|
419
|
+
restTags = _sliceInstanceProperty(allTags).call(allTags, maxTagCount);
|
|
420
|
+
}
|
|
334
421
|
|
|
335
422
|
const restTagsContent = /*#__PURE__*/React.createElement("span", {
|
|
336
423
|
className: restTagsCls
|
|
337
424
|
}, "+", tagsArray.length - maxTagCount);
|
|
425
|
+
|
|
426
|
+
const sortableListItems = _mapInstanceProperty(allTags).call(allTags, (item, index) => ({
|
|
427
|
+
item: item,
|
|
428
|
+
key: tagsArray[index]
|
|
429
|
+
}));
|
|
430
|
+
|
|
431
|
+
if (active && draggable && sortableListItems.length > 0) {
|
|
432
|
+
// @ts-ignore skip SortableItem type check
|
|
433
|
+
return /*#__PURE__*/React.createElement(SortableList, {
|
|
434
|
+
useDragHandle: true,
|
|
435
|
+
items: sortableListItems,
|
|
436
|
+
onSortEnd: this.onSortEnd,
|
|
437
|
+
axis: "xy"
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
338
441
|
return /*#__PURE__*/React.createElement(React.Fragment, null, tags, restTags.length > 0 && (showRestTagsPopover ? /*#__PURE__*/React.createElement(Popover, _Object$assign({
|
|
339
442
|
content: restTags,
|
|
340
443
|
showArrow: true,
|
|
@@ -345,16 +448,24 @@ class TagInput extends BaseComponent {
|
|
|
345
448
|
}
|
|
346
449
|
|
|
347
450
|
blur() {
|
|
348
|
-
this.inputRef.current.blur();
|
|
451
|
+
this.inputRef.current.blur(); // unregister clickOutside event
|
|
452
|
+
|
|
453
|
+
this.foundation.clickOutsideCallBack();
|
|
349
454
|
}
|
|
350
455
|
|
|
351
456
|
focus() {
|
|
352
457
|
const {
|
|
353
|
-
preventScroll
|
|
458
|
+
preventScroll,
|
|
459
|
+
disabled
|
|
354
460
|
} = this.props;
|
|
355
461
|
this.inputRef.current.focus({
|
|
356
462
|
preventScroll
|
|
357
463
|
});
|
|
464
|
+
|
|
465
|
+
if (!disabled) {
|
|
466
|
+
// register clickOutside event
|
|
467
|
+
this.foundation.handleClick();
|
|
468
|
+
}
|
|
358
469
|
}
|
|
359
470
|
|
|
360
471
|
render() {
|
|
@@ -370,10 +481,11 @@ class TagInput extends BaseComponent {
|
|
|
370
481
|
focusing,
|
|
371
482
|
hovering,
|
|
372
483
|
tagsArray,
|
|
373
|
-
inputValue
|
|
484
|
+
inputValue,
|
|
485
|
+
active
|
|
374
486
|
} = this.state;
|
|
375
487
|
const tagInputCls = cls(prefixCls, className, {
|
|
376
|
-
["".concat(prefixCls, "-focus")]: focusing,
|
|
488
|
+
["".concat(prefixCls, "-focus")]: focusing || active,
|
|
377
489
|
["".concat(prefixCls, "-disabled")]: disabled,
|
|
378
490
|
["".concat(prefixCls, "-hover")]: hovering && !disabled,
|
|
379
491
|
["".concat(prefixCls, "-error")]: validateStatus === 'error',
|
|
@@ -381,41 +493,49 @@ class TagInput extends BaseComponent {
|
|
|
381
493
|
});
|
|
382
494
|
const inputCls = cls("".concat(prefixCls, "-wrapper-input"));
|
|
383
495
|
const wrapperCls = cls("".concat(prefixCls, "-wrapper"));
|
|
384
|
-
return
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
"
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
this.
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
496
|
+
return (
|
|
497
|
+
/*#__PURE__*/
|
|
498
|
+
// eslint-disable-next-line
|
|
499
|
+
React.createElement("div", {
|
|
500
|
+
ref: this.tagInputRef,
|
|
501
|
+
style: style,
|
|
502
|
+
className: tagInputCls,
|
|
503
|
+
"aria-disabled": disabled,
|
|
504
|
+
"aria-label": this.props['aria-label'],
|
|
505
|
+
"aria-invalid": validateStatus === 'error',
|
|
506
|
+
onMouseEnter: e => {
|
|
507
|
+
this.handleInputMouseEnter(e);
|
|
508
|
+
},
|
|
509
|
+
onMouseLeave: e => {
|
|
510
|
+
this.handleInputMouseLeave(e);
|
|
511
|
+
},
|
|
512
|
+
onClick: e => {
|
|
513
|
+
this.handleClick(e);
|
|
514
|
+
}
|
|
515
|
+
}, this.renderPrefix(), /*#__PURE__*/React.createElement("div", {
|
|
516
|
+
className: wrapperCls
|
|
517
|
+
}, this.renderTags(), /*#__PURE__*/React.createElement(Input, {
|
|
518
|
+
"aria-label": 'input value',
|
|
519
|
+
ref: this.inputRef,
|
|
520
|
+
className: inputCls,
|
|
521
|
+
disabled: disabled,
|
|
522
|
+
value: inputValue,
|
|
523
|
+
size: size,
|
|
524
|
+
placeholder: tagsArray.length === 0 ? placeholder : '',
|
|
525
|
+
onKeyDown: e => {
|
|
526
|
+
this.handleKeyDown(e);
|
|
527
|
+
},
|
|
528
|
+
onChange: (v, e) => {
|
|
529
|
+
this.handleInputChange(e);
|
|
530
|
+
},
|
|
531
|
+
onBlur: e => {
|
|
532
|
+
this.handleInputBlur(e);
|
|
533
|
+
},
|
|
534
|
+
onFocus: e => {
|
|
535
|
+
this.handleInputFocus(e);
|
|
536
|
+
}
|
|
537
|
+
})), this.renderClearBtn(), this.renderSuffix())
|
|
538
|
+
);
|
|
419
539
|
}
|
|
420
540
|
|
|
421
541
|
}
|
|
@@ -439,6 +559,8 @@ TagInput.propTypes = {
|
|
|
439
559
|
separator: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
440
560
|
showClear: PropTypes.bool,
|
|
441
561
|
addOnBlur: PropTypes.bool,
|
|
562
|
+
draggable: PropTypes.bool,
|
|
563
|
+
expandRestTagsOnClick: PropTypes.bool,
|
|
442
564
|
autoFocus: PropTypes.bool,
|
|
443
565
|
renderTagItem: PropTypes.func,
|
|
444
566
|
onBlur: PropTypes.func,
|
|
@@ -463,6 +585,8 @@ TagInput.defaultProps = {
|
|
|
463
585
|
allowDuplicates: true,
|
|
464
586
|
showRestTagsPopover: true,
|
|
465
587
|
autoFocus: false,
|
|
588
|
+
draggable: false,
|
|
589
|
+
expandRestTagsOnClick: true,
|
|
466
590
|
showContentTooltip: true,
|
|
467
591
|
separator: ',',
|
|
468
592
|
size: 'default',
|
|
@@ -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>;
|
package/lib/es/tooltip/index.js
CHANGED
|
@@ -683,8 +683,8 @@ export default class Tooltip extends BaseComponent {
|
|
|
683
683
|
ref.current = node;
|
|
684
684
|
}
|
|
685
685
|
},
|
|
686
|
-
tabIndex: 0,
|
|
687
|
-
|
|
686
|
+
tabIndex: children.props.tabIndex || 0 // a11y keyboard, in some condition select's tabindex need to -1 or 0
|
|
687
|
+
|
|
688
688
|
})); // 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
|
|
689
689
|
// So if the user adds ref to the content, you need to use callback ref: https://github.com/facebook/react/issues/8873
|
|
690
690
|
|
|
@@ -749,5 +749,7 @@ Tooltip.defaultProps = {
|
|
|
749
749
|
closeOnEsc: false,
|
|
750
750
|
guardFocus: false,
|
|
751
751
|
returnFocusOnClose: false,
|
|
752
|
-
onEscKeyDown: _noop
|
|
752
|
+
onEscKeyDown: _noop,
|
|
753
|
+
disableFocusListener: false,
|
|
754
|
+
disableArrowKeyDown: false
|
|
753
755
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
17
17
|
"@douyinfe/semi-animation": "2.12.0",
|
|
18
|
-
"@douyinfe/semi-animation-react": "2.
|
|
19
|
-
"@douyinfe/semi-foundation": "2.
|
|
20
|
-
"@douyinfe/semi-icons": "2.
|
|
18
|
+
"@douyinfe/semi-animation-react": "2.17.0-beta.0",
|
|
19
|
+
"@douyinfe/semi-foundation": "2.17.0-beta.0",
|
|
20
|
+
"@douyinfe/semi-icons": "2.17.0-beta.0",
|
|
21
21
|
"@douyinfe/semi-illustrations": "2.15.0",
|
|
22
|
-
"@douyinfe/semi-theme-default": "2.
|
|
22
|
+
"@douyinfe/semi-theme-default": "2.17.0-beta.0",
|
|
23
23
|
"async-validator": "^3.5.0",
|
|
24
24
|
"classnames": "^2.2.6",
|
|
25
25
|
"copy-text-to-clipboard": "^2.1.1",
|
|
@@ -66,13 +66,13 @@
|
|
|
66
66
|
],
|
|
67
67
|
"author": "",
|
|
68
68
|
"license": "MIT",
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "471474bb6fe0a743bc3daba532279969cc9374a5",
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
72
72
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
73
73
|
"@babel/preset-env": "^7.15.8",
|
|
74
74
|
"@babel/preset-react": "^7.14.5",
|
|
75
|
-
"@douyinfe/semi-scss-compile": "2.
|
|
75
|
+
"@douyinfe/semi-scss-compile": "2.17.0-beta.0",
|
|
76
76
|
"@storybook/addon-knobs": "^6.3.1",
|
|
77
77
|
"@types/lodash": "^4.14.176",
|
|
78
78
|
"@types/react": ">=16.0.0",
|
package/popover/index.tsx
CHANGED
|
@@ -44,7 +44,8 @@ export interface PopoverProps extends BaseProps {
|
|
|
44
44
|
guardFocus?: TooltipProps['guardFocus'];
|
|
45
45
|
returnFocusOnClose?: TooltipProps['returnFocusOnClose'];
|
|
46
46
|
onEscKeyDown?: TooltipProps['onEscKeyDown'];
|
|
47
|
-
clickToHide?:TooltipProps['clickToHide']
|
|
47
|
+
clickToHide?:TooltipProps['clickToHide'];
|
|
48
|
+
disableFocusListener?: boolean
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
export interface PopoverState {
|
|
@@ -82,6 +83,7 @@ class Popover extends React.PureComponent<PopoverProps, PopoverState> {
|
|
|
82
83
|
arrowBounding: PropTypes.object,
|
|
83
84
|
prefixCls: PropTypes.string,
|
|
84
85
|
guardFocus: PropTypes.bool,
|
|
86
|
+
disableArrowKeyDown: PropTypes.bool,
|
|
85
87
|
};
|
|
86
88
|
|
|
87
89
|
static defaultProps = {
|
|
@@ -100,6 +102,7 @@ class Popover extends React.PureComponent<PopoverProps, PopoverState> {
|
|
|
100
102
|
closeOnEsc: true,
|
|
101
103
|
returnFocusOnClose: true,
|
|
102
104
|
guardFocus: true,
|
|
105
|
+
disableFocusListener: true
|
|
103
106
|
};
|
|
104
107
|
|
|
105
108
|
context: ContextValue;
|
|
@@ -876,9 +876,9 @@ describe('Select', () => {
|
|
|
876
876
|
// Since there is no mechanism such as event bubbling in enzyme + jsdom, the blur event can only be triggered manually on the blur element,
|
|
877
877
|
// and the blur of the `a element` cannot be achieved through the focus `b element`.
|
|
878
878
|
|
|
879
|
-
//
|
|
879
|
+
// Adapt to A11y requirements, close the panel will not call the onBlur func
|
|
880
880
|
select.instance().close();
|
|
881
|
-
expect(spyOnBlur.callCount).toEqual(
|
|
881
|
+
expect(spyOnBlur.callCount).toEqual(0);
|
|
882
882
|
select.unmount();
|
|
883
883
|
});
|
|
884
884
|
|
|
@@ -1076,10 +1076,12 @@ describe('Select', () => {
|
|
|
1076
1076
|
};
|
|
1077
1077
|
let select = getSelect(props);
|
|
1078
1078
|
// press ⬇️
|
|
1079
|
+
// since the defaultActiveFirstOption default to be true, after ⬇️, the second option focused
|
|
1079
1080
|
select.find(`.${BASE_CLASS_PREFIX}-select`).simulate('keydown', { keyCode: keyCode.DOWN });
|
|
1080
|
-
expect(select.find(`.${BASE_CLASS_PREFIX}-select-option`).at(
|
|
1081
|
+
expect(select.find(`.${BASE_CLASS_PREFIX}-select-option`).at(1).hasClass(`${BASE_CLASS_PREFIX}-select-option-focused`)).toBe(true);
|
|
1081
1082
|
// press ⬆️
|
|
1082
1083
|
select.find(`.${BASE_CLASS_PREFIX}-select`).simulate('keydown', { keyCode: keyCode.UP });
|
|
1084
|
+
select.find(`.${BASE_CLASS_PREFIX}-select`).simulate('keydown', { keyCode: keyCode.UP });
|
|
1083
1085
|
expect(select.find(`.${BASE_CLASS_PREFIX}-select-option`).at(defaultList.length-1).hasClass(`${BASE_CLASS_PREFIX}-select-option-focused`)).toBe(true);
|
|
1084
1086
|
// press ESC
|
|
1085
1087
|
select.find(`.${BASE_CLASS_PREFIX}-select`).simulate('keydown', { keyCode: keyCode.ESC });
|