@douyinfe/semi-ui 2.24.0-beta.0 → 2.24.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/dist/css/semi.css +6 -2
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +91 -28
- 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/_base/base.css +4 -0
- package/lib/cjs/image/preview.js +1 -1
- package/lib/cjs/input/index.d.ts +2 -0
- package/lib/cjs/input/index.js +32 -12
- package/lib/cjs/tabs/TabBar.js +1 -2
- package/lib/cjs/treeSelect/index.js +40 -6
- package/lib/es/_base/base.css +4 -0
- package/lib/es/image/preview.js +1 -1
- package/lib/es/input/index.d.ts +2 -0
- package/lib/es/input/index.js +31 -12
- package/lib/es/tabs/TabBar.js +1 -2
- package/lib/es/treeSelect/index.js +40 -6
- package/package.json +8 -8
package/lib/cjs/_base/base.css
CHANGED
|
@@ -456,6 +456,8 @@ body, body[theme-mode=dark] .semi-always-light {
|
|
|
456
456
|
--semi-border-radius-large: 12px;
|
|
457
457
|
--semi-border-radius-circle: 50%;
|
|
458
458
|
--semi-border-radius-full: 9999px;
|
|
459
|
+
--semi-color-highlight-bg: rgba(var(--semi-yellow-4), 1);
|
|
460
|
+
--semi-color-highlight: rgba(var(--semi-black), 1);
|
|
459
461
|
}
|
|
460
462
|
|
|
461
463
|
body[theme-mode=dark], body .semi-always-dark {
|
|
@@ -544,6 +546,8 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
544
546
|
--semi-border-radius-large: 12px;
|
|
545
547
|
--semi-border-radius-circle: 50%;
|
|
546
548
|
--semi-border-radius-full: 9999px;
|
|
549
|
+
--semi-color-highlight-bg: rgba(var(--semi-yellow-2), 1);
|
|
550
|
+
--semi-color-highlight: rgba(var(--semi-white), 1);
|
|
547
551
|
}
|
|
548
552
|
|
|
549
553
|
.semi-light-scrollbar::-webkit-scrollbar, .semi-light-scrollbar *::-webkit-scrollbar {
|
package/lib/cjs/image/preview.js
CHANGED
|
@@ -178,7 +178,7 @@ class Preview extends _baseComponent.default {
|
|
|
178
178
|
const finalSrcList = [...srcArr, ...srcListInChildren];
|
|
179
179
|
return /*#__PURE__*/_react.default.createElement(_previewContext.PreviewContext.Provider, {
|
|
180
180
|
value: {
|
|
181
|
-
isGroup:
|
|
181
|
+
isGroup: true,
|
|
182
182
|
previewSrc: finalSrcList,
|
|
183
183
|
titles: titles,
|
|
184
184
|
currentIndex,
|
package/lib/cjs/input/index.d.ts
CHANGED
|
@@ -132,6 +132,7 @@ declare class Input extends BaseComponent<InputProps, InputState> {
|
|
|
132
132
|
setValue: (value: string) => void;
|
|
133
133
|
setEyeClosed: (value: boolean) => void;
|
|
134
134
|
toggleFocusing: (isFocus: boolean) => void;
|
|
135
|
+
focusInput: () => void;
|
|
135
136
|
toggleHovering: (isHovering: boolean) => void;
|
|
136
137
|
getIfFocusing: () => boolean;
|
|
137
138
|
notifyChange: (cbValue: string, e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
@@ -178,6 +179,7 @@ declare class Input extends BaseComponent<InputProps, InputState> {
|
|
|
178
179
|
renderPrefix(): JSX.Element;
|
|
179
180
|
showClearBtn(): boolean;
|
|
180
181
|
renderSuffix(suffixAllowClear: boolean): JSX.Element;
|
|
182
|
+
getInputRef(): React.RefObject<HTMLInputElement> | React.MutableRefObject<any> | ((node: HTMLInputElement) => void);
|
|
181
183
|
render(): JSX.Element;
|
|
182
184
|
}
|
|
183
185
|
declare const ForwardInput: React.ForwardRefExoticComponent<Omit<InputProps, "forwardRef"> & React.RefAttributes<HTMLInputElement>>;
|
package/lib/cjs/input/index.js
CHANGED
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.Input = void 0;
|
|
7
7
|
|
|
8
|
+
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
|
|
9
|
+
|
|
8
10
|
var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
|
|
9
11
|
|
|
10
12
|
var _noop2 = _interopRequireDefault(require("lodash/noop"));
|
|
@@ -126,21 +128,17 @@ class Input extends _baseComponent.default {
|
|
|
126
128
|
eyeClosed: value
|
|
127
129
|
}),
|
|
128
130
|
toggleFocusing: isFocus => {
|
|
131
|
+
this.setState({
|
|
132
|
+
isFocus
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
focusInput: () => {
|
|
129
136
|
const {
|
|
130
137
|
preventScroll
|
|
131
138
|
} = this.props;
|
|
132
139
|
const input = this.inputRef && this.inputRef.current;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
input && input.focus({
|
|
136
|
-
preventScroll
|
|
137
|
-
});
|
|
138
|
-
} else {
|
|
139
|
-
input && input.blur();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
this.setState({
|
|
143
|
-
isFocus
|
|
140
|
+
input && input.focus({
|
|
141
|
+
preventScroll
|
|
144
142
|
});
|
|
145
143
|
},
|
|
146
144
|
toggleHovering: isHovering => this.setState({
|
|
@@ -344,6 +342,28 @@ class Input extends _baseComponent.default {
|
|
|
344
342
|
);
|
|
345
343
|
}
|
|
346
344
|
|
|
345
|
+
getInputRef() {
|
|
346
|
+
const {
|
|
347
|
+
forwardRef
|
|
348
|
+
} = this.props;
|
|
349
|
+
|
|
350
|
+
if (!(0, _isUndefined2.default)(forwardRef)) {
|
|
351
|
+
if (typeof forwardRef === 'function') {
|
|
352
|
+
return node => {
|
|
353
|
+
forwardRef(node);
|
|
354
|
+
this.inputRef = {
|
|
355
|
+
current: node
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
} else if (Object.prototype.toString.call(forwardRef) === '[object Object]') {
|
|
359
|
+
this.inputRef = forwardRef;
|
|
360
|
+
return forwardRef;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return this.inputRef;
|
|
365
|
+
}
|
|
366
|
+
|
|
347
367
|
render() {
|
|
348
368
|
const _a = this.props,
|
|
349
369
|
{
|
|
@@ -383,7 +403,7 @@ class Input extends _baseComponent.default {
|
|
|
383
403
|
} = this.state;
|
|
384
404
|
const suffixAllowClear = this.showClearBtn();
|
|
385
405
|
const suffixIsIcon = (0, _utils.isSemiIcon)(suffix);
|
|
386
|
-
const ref =
|
|
406
|
+
const ref = this.getInputRef();
|
|
387
407
|
const wrapperPrefix = "".concat(prefixCls, "-wrapper");
|
|
388
408
|
const wrapperCls = (0, _classnames.default)(wrapperPrefix, className, {
|
|
389
409
|
["".concat(prefixCls, "-wrapper__with-prefix")]: prefix || insetLabel,
|
package/lib/cjs/tabs/TabBar.js
CHANGED
|
@@ -112,7 +112,6 @@ class TabBar extends _react.default.Component {
|
|
|
112
112
|
this.renderTabComponents = list => list.map(panel => this.renderTabItem(panel));
|
|
113
113
|
|
|
114
114
|
this.handleArrowClick = (items, pos) => {
|
|
115
|
-
const inline = pos === 'start' ? 'end' : 'start';
|
|
116
115
|
const lastItem = pos === 'start' ? items.pop() : items.shift();
|
|
117
116
|
|
|
118
117
|
if (!lastItem) {
|
|
@@ -126,7 +125,7 @@ class TabBar extends _react.default.Component {
|
|
|
126
125
|
tabItem.scrollIntoView({
|
|
127
126
|
behavior: 'smooth',
|
|
128
127
|
block: 'nearest',
|
|
129
|
-
inline
|
|
128
|
+
inline: 'nearest'
|
|
130
129
|
});
|
|
131
130
|
};
|
|
132
131
|
|
|
@@ -586,7 +586,9 @@ class TreeSelect extends _baseComponent.default {
|
|
|
586
586
|
maxTagCount,
|
|
587
587
|
checkRelation,
|
|
588
588
|
showRestTagsPopover,
|
|
589
|
-
restTagsPopoverProps
|
|
589
|
+
restTagsPopoverProps,
|
|
590
|
+
searchPosition,
|
|
591
|
+
filterTreeNode
|
|
590
592
|
} = this.props;
|
|
591
593
|
const {
|
|
592
594
|
keyEntities,
|
|
@@ -600,8 +602,16 @@ class TreeSelect extends _baseComponent.default {
|
|
|
600
602
|
keyList = (0, _treeUtil.normalizeKeyList)(checkedKeys, keyEntities, leafOnly);
|
|
601
603
|
} else if (checkRelation === 'unRelated') {
|
|
602
604
|
keyList = [...realCheckedKeys];
|
|
603
|
-
}
|
|
605
|
+
} // auto focus search input divide into two parts
|
|
606
|
+
// 1. filterTreeNode && searchPosition === strings.SEARCH_POSITION_TRIGGER
|
|
607
|
+
// Implemented by passing autofocus to the underlying input's autofocus
|
|
608
|
+
// 2. filterTreeNode && searchPosition === strings.SEARCH_POSITION_DROPDOWN
|
|
609
|
+
// Due to the off-screen rendering in the tooltip implementation mechanism, if it is implemented through the
|
|
610
|
+
// autofocus of the input, when the option panel is opened, the page will scroll to top, so it is necessary
|
|
611
|
+
// to call the focus method through ref in the onVisibleChange callback of the Popover to achieve focus
|
|
612
|
+
|
|
604
613
|
|
|
614
|
+
const autoFocus = filterTreeNode && searchPosition === _constants.strings.SEARCH_POSITION_TRIGGER ? searchAutoFocus : undefined;
|
|
605
615
|
return /*#__PURE__*/_react.default.createElement(_tagInput.default, {
|
|
606
616
|
maxTagCount: maxTagCount,
|
|
607
617
|
disabled: disabled,
|
|
@@ -614,7 +624,7 @@ class TreeSelect extends _baseComponent.default {
|
|
|
614
624
|
showRestTagsPopover: showRestTagsPopover,
|
|
615
625
|
restTagsPopoverProps: restTagsPopoverProps,
|
|
616
626
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
617
|
-
autoFocus:
|
|
627
|
+
autoFocus: autoFocus,
|
|
618
628
|
renderTagItem: (itemKey, index) => this.renderTagItem(itemKey, index),
|
|
619
629
|
onRemove: itemKey => this.removeTag(itemKey),
|
|
620
630
|
expandRestTagsOnClick: false
|
|
@@ -650,6 +660,7 @@ class TreeSelect extends _baseComponent.default {
|
|
|
650
660
|
prefix: /*#__PURE__*/_react.default.createElement(_semiIcons.IconSearch, null)
|
|
651
661
|
};
|
|
652
662
|
const inputTriggerProps = {
|
|
663
|
+
autofocus: searchAutoFocus,
|
|
653
664
|
onFocus: e => this.foundation.handleInputTriggerFocus(),
|
|
654
665
|
onBlur: e => this.foundation.handleInputTriggerBlur(),
|
|
655
666
|
disabled
|
|
@@ -681,7 +692,6 @@ class TreeSelect extends _baseComponent.default {
|
|
|
681
692
|
return /*#__PURE__*/_react.default.createElement(_index2.default, Object.assign({
|
|
682
693
|
"aria-label": 'Filter TreeSelect item',
|
|
683
694
|
ref: this.inputRef,
|
|
684
|
-
autofocus: searchAutoFocus,
|
|
685
695
|
placeholder: placeholder
|
|
686
696
|
}, baseInputProps, realInputProps));
|
|
687
697
|
}));
|
|
@@ -755,12 +765,18 @@ class TreeSelect extends _baseComponent.default {
|
|
|
755
765
|
|
|
756
766
|
this.handlePopoverClose = isVisible => {
|
|
757
767
|
const {
|
|
758
|
-
filterTreeNode
|
|
768
|
+
filterTreeNode,
|
|
769
|
+
searchAutoFocus,
|
|
770
|
+
searchPosition
|
|
759
771
|
} = this.props;
|
|
760
772
|
|
|
761
773
|
if (isVisible === false && Boolean(filterTreeNode)) {
|
|
762
774
|
this.foundation.clearInput();
|
|
763
775
|
}
|
|
776
|
+
|
|
777
|
+
if (filterTreeNode && searchPosition === _constants.strings.SEARCH_POSITION_DROPDOWN && isVisible && searchAutoFocus) {
|
|
778
|
+
this.foundation.focusInput(true);
|
|
779
|
+
}
|
|
764
780
|
};
|
|
765
781
|
|
|
766
782
|
this.renderTreeNode = (treeNode, ind, style) => {
|
|
@@ -1225,7 +1241,25 @@ class TreeSelect extends _baseComponent.default {
|
|
|
1225
1241
|
isHovering: bool
|
|
1226
1242
|
});
|
|
1227
1243
|
},
|
|
1228
|
-
updateInputFocus: bool => {
|
|
1244
|
+
updateInputFocus: bool => {
|
|
1245
|
+
if (bool) {
|
|
1246
|
+
if (this.inputRef && this.inputRef.current) {
|
|
1247
|
+
this.inputRef.current.focus();
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
if (this.tagInputRef && this.tagInputRef.current) {
|
|
1251
|
+
this.tagInputRef.current.focus();
|
|
1252
|
+
}
|
|
1253
|
+
} else {
|
|
1254
|
+
if (this.inputRef && this.inputRef.current) {
|
|
1255
|
+
this.inputRef.current.blur();
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
if (this.tagInputRef && this.tagInputRef.current) {
|
|
1259
|
+
this.tagInputRef.current.blur();
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
} // eslint-disable-line
|
|
1229
1263
|
|
|
1230
1264
|
});
|
|
1231
1265
|
}
|
package/lib/es/_base/base.css
CHANGED
|
@@ -456,6 +456,8 @@ body, body[theme-mode=dark] .semi-always-light {
|
|
|
456
456
|
--semi-border-radius-large: 12px;
|
|
457
457
|
--semi-border-radius-circle: 50%;
|
|
458
458
|
--semi-border-radius-full: 9999px;
|
|
459
|
+
--semi-color-highlight-bg: rgba(var(--semi-yellow-4), 1);
|
|
460
|
+
--semi-color-highlight: rgba(var(--semi-black), 1);
|
|
459
461
|
}
|
|
460
462
|
|
|
461
463
|
body[theme-mode=dark], body .semi-always-dark {
|
|
@@ -544,6 +546,8 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
544
546
|
--semi-border-radius-large: 12px;
|
|
545
547
|
--semi-border-radius-circle: 50%;
|
|
546
548
|
--semi-border-radius-full: 9999px;
|
|
549
|
+
--semi-color-highlight-bg: rgba(var(--semi-yellow-2), 1);
|
|
550
|
+
--semi-color-highlight: rgba(var(--semi-white), 1);
|
|
547
551
|
}
|
|
548
552
|
|
|
549
553
|
.semi-light-scrollbar::-webkit-scrollbar, .semi-light-scrollbar *::-webkit-scrollbar {
|
package/lib/es/image/preview.js
CHANGED
|
@@ -159,7 +159,7 @@ export default class Preview extends BaseComponent {
|
|
|
159
159
|
const finalSrcList = [...srcArr, ...srcListInChildren];
|
|
160
160
|
return /*#__PURE__*/React.createElement(PreviewContext.Provider, {
|
|
161
161
|
value: {
|
|
162
|
-
isGroup:
|
|
162
|
+
isGroup: true,
|
|
163
163
|
previewSrc: finalSrcList,
|
|
164
164
|
titles: titles,
|
|
165
165
|
currentIndex,
|
package/lib/es/input/index.d.ts
CHANGED
|
@@ -132,6 +132,7 @@ declare class Input extends BaseComponent<InputProps, InputState> {
|
|
|
132
132
|
setValue: (value: string) => void;
|
|
133
133
|
setEyeClosed: (value: boolean) => void;
|
|
134
134
|
toggleFocusing: (isFocus: boolean) => void;
|
|
135
|
+
focusInput: () => void;
|
|
135
136
|
toggleHovering: (isHovering: boolean) => void;
|
|
136
137
|
getIfFocusing: () => boolean;
|
|
137
138
|
notifyChange: (cbValue: string, e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
@@ -178,6 +179,7 @@ declare class Input extends BaseComponent<InputProps, InputState> {
|
|
|
178
179
|
renderPrefix(): JSX.Element;
|
|
179
180
|
showClearBtn(): boolean;
|
|
180
181
|
renderSuffix(suffixAllowClear: boolean): JSX.Element;
|
|
182
|
+
getInputRef(): React.RefObject<HTMLInputElement> | React.MutableRefObject<any> | ((node: HTMLInputElement) => void);
|
|
181
183
|
render(): JSX.Element;
|
|
182
184
|
}
|
|
183
185
|
declare const ForwardInput: React.ForwardRefExoticComponent<Omit<InputProps, "forwardRef"> & React.RefAttributes<HTMLInputElement>>;
|
package/lib/es/input/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _isUndefined from "lodash/isUndefined";
|
|
1
2
|
import _isFunction from "lodash/isFunction";
|
|
2
3
|
import _noop from "lodash/noop";
|
|
3
4
|
import _isString from "lodash/isString";
|
|
@@ -106,21 +107,17 @@ class Input extends BaseComponent {
|
|
|
106
107
|
eyeClosed: value
|
|
107
108
|
}),
|
|
108
109
|
toggleFocusing: isFocus => {
|
|
110
|
+
this.setState({
|
|
111
|
+
isFocus
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
focusInput: () => {
|
|
109
115
|
const {
|
|
110
116
|
preventScroll
|
|
111
117
|
} = this.props;
|
|
112
118
|
const input = this.inputRef && this.inputRef.current;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
input && input.focus({
|
|
116
|
-
preventScroll
|
|
117
|
-
});
|
|
118
|
-
} else {
|
|
119
|
-
input && input.blur();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
this.setState({
|
|
123
|
-
isFocus
|
|
119
|
+
input && input.focus({
|
|
120
|
+
preventScroll
|
|
124
121
|
});
|
|
125
122
|
},
|
|
126
123
|
toggleHovering: isHovering => this.setState({
|
|
@@ -324,6 +321,28 @@ class Input extends BaseComponent {
|
|
|
324
321
|
);
|
|
325
322
|
}
|
|
326
323
|
|
|
324
|
+
getInputRef() {
|
|
325
|
+
const {
|
|
326
|
+
forwardRef
|
|
327
|
+
} = this.props;
|
|
328
|
+
|
|
329
|
+
if (!_isUndefined(forwardRef)) {
|
|
330
|
+
if (typeof forwardRef === 'function') {
|
|
331
|
+
return node => {
|
|
332
|
+
forwardRef(node);
|
|
333
|
+
this.inputRef = {
|
|
334
|
+
current: node
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
} else if (Object.prototype.toString.call(forwardRef) === '[object Object]') {
|
|
338
|
+
this.inputRef = forwardRef;
|
|
339
|
+
return forwardRef;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return this.inputRef;
|
|
344
|
+
}
|
|
345
|
+
|
|
327
346
|
render() {
|
|
328
347
|
const _a = this.props,
|
|
329
348
|
{
|
|
@@ -363,7 +382,7 @@ class Input extends BaseComponent {
|
|
|
363
382
|
} = this.state;
|
|
364
383
|
const suffixAllowClear = this.showClearBtn();
|
|
365
384
|
const suffixIsIcon = isSemiIcon(suffix);
|
|
366
|
-
const ref =
|
|
385
|
+
const ref = this.getInputRef();
|
|
367
386
|
const wrapperPrefix = "".concat(prefixCls, "-wrapper");
|
|
368
387
|
const wrapperCls = cls(wrapperPrefix, className, {
|
|
369
388
|
["".concat(prefixCls, "-wrapper__with-prefix")]: prefix || insetLabel,
|
package/lib/es/tabs/TabBar.js
CHANGED
|
@@ -94,7 +94,6 @@ class TabBar extends React.Component {
|
|
|
94
94
|
this.renderTabComponents = list => list.map(panel => this.renderTabItem(panel));
|
|
95
95
|
|
|
96
96
|
this.handleArrowClick = (items, pos) => {
|
|
97
|
-
const inline = pos === 'start' ? 'end' : 'start';
|
|
98
97
|
const lastItem = pos === 'start' ? items.pop() : items.shift();
|
|
99
98
|
|
|
100
99
|
if (!lastItem) {
|
|
@@ -108,7 +107,7 @@ class TabBar extends React.Component {
|
|
|
108
107
|
tabItem.scrollIntoView({
|
|
109
108
|
behavior: 'smooth',
|
|
110
109
|
block: 'nearest',
|
|
111
|
-
inline
|
|
110
|
+
inline: 'nearest'
|
|
112
111
|
});
|
|
113
112
|
};
|
|
114
113
|
|
|
@@ -541,7 +541,9 @@ class TreeSelect extends BaseComponent {
|
|
|
541
541
|
maxTagCount,
|
|
542
542
|
checkRelation,
|
|
543
543
|
showRestTagsPopover,
|
|
544
|
-
restTagsPopoverProps
|
|
544
|
+
restTagsPopoverProps,
|
|
545
|
+
searchPosition,
|
|
546
|
+
filterTreeNode
|
|
545
547
|
} = this.props;
|
|
546
548
|
const {
|
|
547
549
|
keyEntities,
|
|
@@ -555,8 +557,16 @@ class TreeSelect extends BaseComponent {
|
|
|
555
557
|
keyList = normalizeKeyList(checkedKeys, keyEntities, leafOnly);
|
|
556
558
|
} else if (checkRelation === 'unRelated') {
|
|
557
559
|
keyList = [...realCheckedKeys];
|
|
558
|
-
}
|
|
560
|
+
} // auto focus search input divide into two parts
|
|
561
|
+
// 1. filterTreeNode && searchPosition === strings.SEARCH_POSITION_TRIGGER
|
|
562
|
+
// Implemented by passing autofocus to the underlying input's autofocus
|
|
563
|
+
// 2. filterTreeNode && searchPosition === strings.SEARCH_POSITION_DROPDOWN
|
|
564
|
+
// Due to the off-screen rendering in the tooltip implementation mechanism, if it is implemented through the
|
|
565
|
+
// autofocus of the input, when the option panel is opened, the page will scroll to top, so it is necessary
|
|
566
|
+
// to call the focus method through ref in the onVisibleChange callback of the Popover to achieve focus
|
|
567
|
+
|
|
559
568
|
|
|
569
|
+
const autoFocus = filterTreeNode && searchPosition === strings.SEARCH_POSITION_TRIGGER ? searchAutoFocus : undefined;
|
|
560
570
|
return /*#__PURE__*/React.createElement(TagInput, {
|
|
561
571
|
maxTagCount: maxTagCount,
|
|
562
572
|
disabled: disabled,
|
|
@@ -569,7 +579,7 @@ class TreeSelect extends BaseComponent {
|
|
|
569
579
|
showRestTagsPopover: showRestTagsPopover,
|
|
570
580
|
restTagsPopoverProps: restTagsPopoverProps,
|
|
571
581
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
572
|
-
autoFocus:
|
|
582
|
+
autoFocus: autoFocus,
|
|
573
583
|
renderTagItem: (itemKey, index) => this.renderTagItem(itemKey, index),
|
|
574
584
|
onRemove: itemKey => this.removeTag(itemKey),
|
|
575
585
|
expandRestTagsOnClick: false
|
|
@@ -605,6 +615,7 @@ class TreeSelect extends BaseComponent {
|
|
|
605
615
|
prefix: /*#__PURE__*/React.createElement(IconSearch, null)
|
|
606
616
|
};
|
|
607
617
|
const inputTriggerProps = {
|
|
618
|
+
autofocus: searchAutoFocus,
|
|
608
619
|
onFocus: e => this.foundation.handleInputTriggerFocus(),
|
|
609
620
|
onBlur: e => this.foundation.handleInputTriggerBlur(),
|
|
610
621
|
disabled
|
|
@@ -636,7 +647,6 @@ class TreeSelect extends BaseComponent {
|
|
|
636
647
|
return /*#__PURE__*/React.createElement(Input, Object.assign({
|
|
637
648
|
"aria-label": 'Filter TreeSelect item',
|
|
638
649
|
ref: this.inputRef,
|
|
639
|
-
autofocus: searchAutoFocus,
|
|
640
650
|
placeholder: placeholder
|
|
641
651
|
}, baseInputProps, realInputProps));
|
|
642
652
|
}));
|
|
@@ -710,12 +720,18 @@ class TreeSelect extends BaseComponent {
|
|
|
710
720
|
|
|
711
721
|
this.handlePopoverClose = isVisible => {
|
|
712
722
|
const {
|
|
713
|
-
filterTreeNode
|
|
723
|
+
filterTreeNode,
|
|
724
|
+
searchAutoFocus,
|
|
725
|
+
searchPosition
|
|
714
726
|
} = this.props;
|
|
715
727
|
|
|
716
728
|
if (isVisible === false && Boolean(filterTreeNode)) {
|
|
717
729
|
this.foundation.clearInput();
|
|
718
730
|
}
|
|
731
|
+
|
|
732
|
+
if (filterTreeNode && searchPosition === strings.SEARCH_POSITION_DROPDOWN && isVisible && searchAutoFocus) {
|
|
733
|
+
this.foundation.focusInput(true);
|
|
734
|
+
}
|
|
719
735
|
};
|
|
720
736
|
|
|
721
737
|
this.renderTreeNode = (treeNode, ind, style) => {
|
|
@@ -1179,7 +1195,25 @@ class TreeSelect extends BaseComponent {
|
|
|
1179
1195
|
isHovering: bool
|
|
1180
1196
|
});
|
|
1181
1197
|
},
|
|
1182
|
-
updateInputFocus: bool => {
|
|
1198
|
+
updateInputFocus: bool => {
|
|
1199
|
+
if (bool) {
|
|
1200
|
+
if (this.inputRef && this.inputRef.current) {
|
|
1201
|
+
this.inputRef.current.focus();
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
if (this.tagInputRef && this.tagInputRef.current) {
|
|
1205
|
+
this.tagInputRef.current.focus();
|
|
1206
|
+
}
|
|
1207
|
+
} else {
|
|
1208
|
+
if (this.inputRef && this.inputRef.current) {
|
|
1209
|
+
this.inputRef.current.blur();
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
if (this.tagInputRef && this.tagInputRef.current) {
|
|
1213
|
+
this.tagInputRef.current.blur();
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
} // eslint-disable-line
|
|
1183
1217
|
|
|
1184
1218
|
});
|
|
1185
1219
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.24.0
|
|
3
|
+
"version": "2.24.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"lib/*"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@douyinfe/semi-animation": "2.24.0
|
|
21
|
-
"@douyinfe/semi-animation-react": "2.24.0
|
|
22
|
-
"@douyinfe/semi-foundation": "2.24.0
|
|
23
|
-
"@douyinfe/semi-icons": "2.24.0
|
|
24
|
-
"@douyinfe/semi-illustrations": "2.24.0
|
|
25
|
-
"@douyinfe/semi-theme-default": "2.24.0
|
|
20
|
+
"@douyinfe/semi-animation": "2.24.0",
|
|
21
|
+
"@douyinfe/semi-animation-react": "2.24.0",
|
|
22
|
+
"@douyinfe/semi-foundation": "2.24.0",
|
|
23
|
+
"@douyinfe/semi-icons": "2.24.0",
|
|
24
|
+
"@douyinfe/semi-illustrations": "2.24.0",
|
|
25
|
+
"@douyinfe/semi-theme-default": "2.24.0",
|
|
26
26
|
"async-validator": "^3.5.0",
|
|
27
27
|
"classnames": "^2.2.6",
|
|
28
28
|
"copy-text-to-clipboard": "^2.1.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
],
|
|
70
70
|
"author": "",
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "3cf6c8a6fa76511fd3797c7168f9ecd4bc0ef662",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|