@douyinfe/semi-foundation 2.14.0-beta.2 → 2.15.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/cascader/cascader.scss +20 -0
- package/cascader/foundation.ts +21 -0
- package/cascader/variables.scss +2 -0
- package/checkbox/checkbox.scss +9 -9
- package/checkbox/checkboxFoundation.ts +1 -0
- package/datePicker/foundation.ts +32 -8
- package/datePicker/monthsGridFoundation.ts +1 -2
- package/dropdown/dropdown.scss +4 -0
- package/dropdown/foundation.ts +38 -1
- package/dropdown/menuFoundation.ts +77 -0
- package/lib/cjs/cascader/cascader.css +15 -0
- package/lib/cjs/cascader/cascader.scss +20 -0
- package/lib/cjs/cascader/foundation.d.ts +6 -0
- package/lib/cjs/cascader/foundation.js +23 -0
- package/lib/cjs/cascader/variables.scss +2 -0
- package/lib/cjs/checkbox/checkbox.css +5 -5
- package/lib/cjs/checkbox/checkbox.scss +9 -9
- package/lib/cjs/checkbox/checkboxFoundation.d.ts +1 -0
- package/lib/cjs/datePicker/foundation.d.ts +7 -0
- package/lib/cjs/datePicker/foundation.js +38 -7
- package/lib/cjs/datePicker/monthsGridFoundation.js +1 -4
- package/lib/cjs/dropdown/dropdown.css +4 -0
- package/lib/cjs/dropdown/dropdown.scss +4 -0
- package/lib/cjs/dropdown/foundation.d.ts +4 -0
- package/lib/cjs/dropdown/foundation.js +48 -0
- package/lib/cjs/dropdown/menuFoundation.d.ts +9 -0
- package/lib/cjs/dropdown/menuFoundation.js +119 -0
- package/lib/cjs/list/list.css +1 -1
- package/lib/cjs/list/list.scss +1 -1
- package/lib/cjs/list/variables.scss +2 -1
- package/lib/cjs/modal/modalFoundation.d.ts +1 -0
- package/lib/cjs/rating/foundation.d.ts +13 -0
- package/lib/cjs/rating/foundation.js +123 -35
- package/lib/cjs/rating/rating.css +14 -5
- package/lib/cjs/rating/rating.scss +21 -8
- package/lib/cjs/rating/variables.scss +4 -0
- package/lib/cjs/tabs/foundation.js +28 -6
- package/lib/cjs/tooltip/foundation.js +39 -9
- package/lib/cjs/tree/foundation.d.ts +1 -0
- package/lib/cjs/treeSelect/foundation.js +9 -1
- package/lib/cjs/utils/FocusHandle.d.ts +1 -0
- package/lib/cjs/utils/FocusHandle.js +6 -1
- package/lib/cjs/utils/a11y.d.ts +9 -0
- package/lib/cjs/utils/a11y.js +123 -0
- package/lib/es/cascader/cascader.css +15 -0
- package/lib/es/cascader/cascader.scss +20 -0
- package/lib/es/cascader/foundation.d.ts +6 -0
- package/lib/es/cascader/foundation.js +23 -0
- package/lib/es/cascader/variables.scss +2 -0
- package/lib/es/checkbox/checkbox.css +5 -5
- package/lib/es/checkbox/checkbox.scss +9 -9
- package/lib/es/checkbox/checkboxFoundation.d.ts +1 -0
- package/lib/es/datePicker/foundation.d.ts +7 -0
- package/lib/es/datePicker/foundation.js +37 -7
- package/lib/es/datePicker/monthsGridFoundation.js +1 -3
- package/lib/es/dropdown/dropdown.css +4 -0
- package/lib/es/dropdown/dropdown.scss +4 -0
- package/lib/es/dropdown/foundation.d.ts +4 -0
- package/lib/es/dropdown/foundation.js +45 -0
- package/lib/es/dropdown/menuFoundation.d.ts +9 -0
- package/lib/es/dropdown/menuFoundation.js +99 -0
- package/lib/es/list/list.css +1 -1
- package/lib/es/list/list.scss +1 -1
- package/lib/es/list/variables.scss +2 -1
- package/lib/es/modal/modalFoundation.d.ts +1 -0
- package/lib/es/rating/foundation.d.ts +13 -0
- package/lib/es/rating/foundation.js +116 -32
- package/lib/es/rating/rating.css +14 -5
- package/lib/es/rating/rating.scss +21 -8
- package/lib/es/rating/variables.scss +4 -0
- package/lib/es/tabs/foundation.js +30 -6
- package/lib/es/tooltip/foundation.js +38 -9
- package/lib/es/tree/foundation.d.ts +1 -0
- package/lib/es/treeSelect/foundation.js +9 -1
- package/lib/es/utils/FocusHandle.d.ts +1 -0
- package/lib/es/utils/FocusHandle.js +6 -1
- package/lib/es/utils/a11y.d.ts +9 -0
- package/lib/es/utils/a11y.js +101 -0
- package/list/list.scss +1 -1
- package/list/variables.scss +2 -1
- package/modal/modalFoundation.ts +1 -0
- package/package.json +2 -2
- package/rating/foundation.ts +90 -31
- package/rating/rating.scss +21 -8
- package/rating/variables.scss +4 -0
- package/tabs/foundation.ts +9 -6
- package/tooltip/foundation.ts +16 -8
- package/tree/foundation.ts +1 -0
- package/treeSelect/foundation.ts +5 -1
- package/utils/FocusHandle.ts +3 -1
- package/utils/a11y.ts +105 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
$color-rating-icon-default: rgba(var(--semi-yellow-5), 1); // 评分图标按钮颜色 - 已填
|
|
2
2
|
$color-rating-bg-default: var(--semi-color-fill-0); // 评分图标按钮颜色 - 未填
|
|
3
3
|
|
|
4
|
+
$color-rating-outline-focus: var(--semi-color-primary-light-active); // 聚焦轮廓颜色
|
|
5
|
+
|
|
4
6
|
$font-rating-fontSize: 20px; // 评分文本字体大小
|
|
5
7
|
|
|
6
8
|
$spacing-rating-margin: 0px; // 整体外边距
|
|
@@ -12,3 +14,5 @@ $font-rating_item_small-fontSize: $width-rating_item_small; // 小尺寸评分
|
|
|
12
14
|
|
|
13
15
|
$width-rating_item_default: 24px; // 评分项宽度
|
|
14
16
|
$font-rating_item_default-fontSize: $width-rating_item_default; // 评分项文本字体大小
|
|
17
|
+
|
|
18
|
+
$width-rating-outline-focus: 2px; // 聚焦轮廓宽度
|
|
@@ -37,6 +37,9 @@ class TabsFoundation extends _foundation.default {
|
|
|
37
37
|
this.handleKeyDown = (event, itemKey, closable) => {
|
|
38
38
|
var _context;
|
|
39
39
|
|
|
40
|
+
const {
|
|
41
|
+
preventScroll
|
|
42
|
+
} = this.getProps();
|
|
40
43
|
const tabs = (0, _filter.default)(_context = [...event.target.parentNode.childNodes]).call(_context, item => {
|
|
41
44
|
var _context2;
|
|
42
45
|
|
|
@@ -63,13 +66,17 @@ class TabsFoundation extends _foundation.default {
|
|
|
63
66
|
break;
|
|
64
67
|
|
|
65
68
|
case "Home":
|
|
66
|
-
tabs[0].focus(
|
|
69
|
+
tabs[0].focus({
|
|
70
|
+
preventScroll
|
|
71
|
+
}); // focus first tab
|
|
67
72
|
|
|
68
73
|
this.handlePrevent(event);
|
|
69
74
|
break;
|
|
70
75
|
|
|
71
76
|
case "End":
|
|
72
|
-
tabs[tabs.length - 1].focus(
|
|
77
|
+
tabs[tabs.length - 1].focus({
|
|
78
|
+
preventScroll
|
|
79
|
+
}); // focus last tab
|
|
73
80
|
|
|
74
81
|
this.handlePrevent(event);
|
|
75
82
|
break;
|
|
@@ -164,18 +171,27 @@ class TabsFoundation extends _foundation.default {
|
|
|
164
171
|
}
|
|
165
172
|
|
|
166
173
|
handleDeleteKeyDown(event, tabs, itemKey, closable) {
|
|
174
|
+
const {
|
|
175
|
+
preventScroll
|
|
176
|
+
} = this.getProps();
|
|
177
|
+
|
|
167
178
|
if (closable) {
|
|
168
179
|
this.handleTabDelete(itemKey);
|
|
169
180
|
const index = (0, _indexOf.default)(tabs).call(tabs, event.target); // Move focus to next element after deletion
|
|
170
181
|
// If the element is the last removable tab, focus to its previous tab
|
|
171
182
|
|
|
172
183
|
if (tabs.length !== 1) {
|
|
173
|
-
tabs[index + 1 >= tabs.length ? index - 1 : index + 1].focus(
|
|
184
|
+
tabs[index + 1 >= tabs.length ? index - 1 : index + 1].focus({
|
|
185
|
+
preventScroll
|
|
186
|
+
});
|
|
174
187
|
}
|
|
175
188
|
}
|
|
176
189
|
}
|
|
177
190
|
|
|
178
191
|
switchTabOnArrowPress(event, tabs) {
|
|
192
|
+
const {
|
|
193
|
+
preventScroll
|
|
194
|
+
} = this.getProps();
|
|
179
195
|
const index = (0, _indexOf.default)(tabs).call(tabs, event.target);
|
|
180
196
|
const direction = {
|
|
181
197
|
"ArrowLeft": -1,
|
|
@@ -187,11 +203,17 @@ class TabsFoundation extends _foundation.default {
|
|
|
187
203
|
if (direction[event.key]) {
|
|
188
204
|
if (index !== undefined) {
|
|
189
205
|
if (tabs[index + direction[event.key]]) {
|
|
190
|
-
tabs[index + direction[event.key]].focus(
|
|
206
|
+
tabs[index + direction[event.key]].focus({
|
|
207
|
+
preventScroll
|
|
208
|
+
});
|
|
191
209
|
} else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
|
|
192
|
-
tabs[tabs.length - 1].focus(
|
|
210
|
+
tabs[tabs.length - 1].focus({
|
|
211
|
+
preventScroll
|
|
212
|
+
}); // focus last tab
|
|
193
213
|
} else if (event.key === "ArrowRight" || event.key == "ArrowDown") {
|
|
194
|
-
tabs[0].focus(
|
|
214
|
+
tabs[0].focus({
|
|
215
|
+
preventScroll
|
|
216
|
+
}); // focus first tab
|
|
195
217
|
}
|
|
196
218
|
}
|
|
197
219
|
}
|
|
@@ -28,6 +28,8 @@ var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
|
28
28
|
|
|
29
29
|
var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
30
30
|
|
|
31
|
+
var _a11y = require("../utils/a11y");
|
|
32
|
+
|
|
31
33
|
const REGS = {
|
|
32
34
|
TOP: /top/i,
|
|
33
35
|
RIGHT: /right/i,
|
|
@@ -952,6 +954,7 @@ class Tooltip extends _foundation.default {
|
|
|
952
954
|
|
|
953
955
|
switch (event && event.key) {
|
|
954
956
|
case "Escape":
|
|
957
|
+
(0, _a11y.handlePrevent)(event);
|
|
955
958
|
closeOnEsc && this._handleEscKeyDown(event);
|
|
956
959
|
break;
|
|
957
960
|
|
|
@@ -981,14 +984,17 @@ class Tooltip extends _foundation.default {
|
|
|
981
984
|
_focusTrigger() {
|
|
982
985
|
const {
|
|
983
986
|
trigger,
|
|
984
|
-
returnFocusOnClose
|
|
987
|
+
returnFocusOnClose,
|
|
988
|
+
preventScroll
|
|
985
989
|
} = this.getProps();
|
|
986
990
|
|
|
987
|
-
if (returnFocusOnClose && trigger
|
|
991
|
+
if (returnFocusOnClose && trigger !== 'custom') {
|
|
988
992
|
const triggerNode = this._adapter.getTriggerNode();
|
|
989
993
|
|
|
990
994
|
if (triggerNode && 'focus' in triggerNode) {
|
|
991
|
-
triggerNode.focus(
|
|
995
|
+
triggerNode.focus({
|
|
996
|
+
preventScroll
|
|
997
|
+
});
|
|
992
998
|
}
|
|
993
999
|
}
|
|
994
1000
|
}
|
|
@@ -999,43 +1005,67 @@ class Tooltip extends _foundation.default {
|
|
|
999
1005
|
} = this.getProps();
|
|
1000
1006
|
|
|
1001
1007
|
if (trigger !== 'custom') {
|
|
1002
|
-
|
|
1003
|
-
|
|
1008
|
+
// Move the focus into the trigger first and then close the pop-up layer
|
|
1009
|
+
// to avoid the problem of opening the pop-up layer again when the focus returns to the trigger in the case of hover and focus
|
|
1004
1010
|
this._focusTrigger();
|
|
1011
|
+
|
|
1012
|
+
this.hide();
|
|
1005
1013
|
}
|
|
1006
1014
|
|
|
1007
1015
|
this._adapter.notifyEscKeydown(event);
|
|
1008
1016
|
}
|
|
1009
1017
|
|
|
1010
1018
|
_handleContainerTabKeyDown(focusableElements, event) {
|
|
1019
|
+
const {
|
|
1020
|
+
preventScroll
|
|
1021
|
+
} = this.getProps();
|
|
1022
|
+
|
|
1011
1023
|
const activeElement = this._adapter.getActiveElement();
|
|
1012
1024
|
|
|
1013
1025
|
const isLastCurrentFocus = focusableElements[focusableElements.length - 1] === activeElement;
|
|
1014
1026
|
|
|
1015
1027
|
if (isLastCurrentFocus) {
|
|
1016
|
-
focusableElements[0].focus(
|
|
1028
|
+
focusableElements[0].focus({
|
|
1029
|
+
preventScroll
|
|
1030
|
+
});
|
|
1017
1031
|
event.preventDefault(); // prevent browser default tab move behavior
|
|
1018
1032
|
}
|
|
1019
1033
|
}
|
|
1020
1034
|
|
|
1021
1035
|
_handleContainerShiftTabKeyDown(focusableElements, event) {
|
|
1036
|
+
const {
|
|
1037
|
+
preventScroll
|
|
1038
|
+
} = this.getProps();
|
|
1039
|
+
|
|
1022
1040
|
const activeElement = this._adapter.getActiveElement();
|
|
1023
1041
|
|
|
1024
1042
|
const isFirstCurrentFocus = focusableElements[0] === activeElement;
|
|
1025
1043
|
|
|
1026
1044
|
if (isFirstCurrentFocus) {
|
|
1027
|
-
focusableElements[focusableElements.length - 1].focus(
|
|
1045
|
+
focusableElements[focusableElements.length - 1].focus({
|
|
1046
|
+
preventScroll
|
|
1047
|
+
});
|
|
1028
1048
|
event.preventDefault(); // prevent browser default tab move behavior
|
|
1029
1049
|
}
|
|
1030
1050
|
}
|
|
1031
1051
|
|
|
1032
1052
|
_handleTriggerArrowDownKeydown(focusableElements, event) {
|
|
1033
|
-
|
|
1053
|
+
const {
|
|
1054
|
+
preventScroll
|
|
1055
|
+
} = this.getProps();
|
|
1056
|
+
focusableElements[0].focus({
|
|
1057
|
+
preventScroll
|
|
1058
|
+
});
|
|
1034
1059
|
event.preventDefault(); // prevent browser default scroll behavior
|
|
1035
1060
|
}
|
|
1036
1061
|
|
|
1037
1062
|
_handleTriggerArrowUpKeydown(focusableElements, event) {
|
|
1038
|
-
|
|
1063
|
+
const {
|
|
1064
|
+
preventScroll
|
|
1065
|
+
} = this.getProps();
|
|
1066
|
+
focusableElements[focusableElements.length - 1].focus({
|
|
1067
|
+
preventScroll
|
|
1068
|
+
});
|
|
1039
1069
|
event.preventDefault(); // prevent browser default scroll behavior
|
|
1040
1070
|
}
|
|
1041
1071
|
|
|
@@ -168,6 +168,7 @@ export interface BasicTreeProps {
|
|
|
168
168
|
onContextMenu?: (e: any, node: BasicTreeNodeData) => void;
|
|
169
169
|
onSearch?: (sunInput: string) => void;
|
|
170
170
|
onSelect?: (selectedKeys: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
171
|
+
preventScroll?: boolean;
|
|
171
172
|
renderDraggingNode?: (nodeInstance: HTMLElement, node: BasicTreeNodeData) => HTMLElement;
|
|
172
173
|
renderFullLabel?: (renderFullLabelProps: BasicRenderFullLabelProps) => any;
|
|
173
174
|
renderLabel?: (label?: any, treeNode?: BasicTreeNodeData) => any;
|
|
@@ -353,8 +353,12 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
353
353
|
const isDisabled = this._isDisabled();
|
|
354
354
|
|
|
355
355
|
const {
|
|
356
|
-
isOpen
|
|
356
|
+
isOpen,
|
|
357
|
+
inputValue
|
|
357
358
|
} = this.getStates();
|
|
359
|
+
const {
|
|
360
|
+
searchPosition
|
|
361
|
+
} = this.getProps();
|
|
358
362
|
|
|
359
363
|
if (isDisabled) {
|
|
360
364
|
return;
|
|
@@ -363,6 +367,10 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
363
367
|
|
|
364
368
|
this._notifyFocus(e);
|
|
365
369
|
} else if (isOpen) {
|
|
370
|
+
if (searchPosition === 'trigger' && inputValue) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
|
|
366
374
|
this.close(e);
|
|
367
375
|
}
|
|
368
376
|
}
|
|
@@ -2,6 +2,7 @@ declare type FocusRedirectListener = (element: HTMLElement) => boolean;
|
|
|
2
2
|
interface HandleOptions {
|
|
3
3
|
enable?: boolean;
|
|
4
4
|
onFocusRedirectListener?: FocusRedirectListener | FocusRedirectListener[];
|
|
5
|
+
preventScroll?: boolean;
|
|
5
6
|
}
|
|
6
7
|
declare class FocusTrapHandle {
|
|
7
8
|
container: HTMLElement;
|
|
@@ -74,7 +74,12 @@ class FocusTrapHandle {
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
this.focusElement = (element, event) => {
|
|
77
|
-
|
|
77
|
+
const {
|
|
78
|
+
preventScroll
|
|
79
|
+
} = this.options;
|
|
80
|
+
element === null || element === void 0 ? void 0 : element.focus({
|
|
81
|
+
preventScroll
|
|
82
|
+
});
|
|
78
83
|
event.preventDefault(); // prevent browser default tab move behavior
|
|
79
84
|
};
|
|
80
85
|
|
package/lib/cjs/utils/a11y.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
1
|
export declare function handlePrevent(event: any): void;
|
|
2
|
+
export declare function isPrintableCharacter(string: string): RegExpMatchArray;
|
|
3
|
+
export declare function setFocusToItem(itemNodes: HTMLElement[], targetItem: HTMLElement): void;
|
|
4
|
+
export declare function setFocusToFirstItem(itemNodes: HTMLElement[]): void;
|
|
5
|
+
export declare function setFocusToLastItem(itemNodes: HTMLElement[]): void;
|
|
6
|
+
export declare function setFocusToPreviousMenuItem(itemNodes: HTMLElement[], currentItem: HTMLElement): void;
|
|
7
|
+
export declare function setFocusToNextMenuitem(itemNodes: HTMLElement[], currentItem: HTMLElement): void;
|
|
8
|
+
export declare function findIndexByCharacter(itemList: HTMLElement[], curItem: HTMLElement, firstCharList: string[], char: string): number;
|
|
9
|
+
export declare function getAncestorNodeByRole(curElement: Element, role: string): Element;
|
|
10
|
+
export declare function getMenuButton(focusableEle: NodeListOf<HTMLElement>, Id: string): HTMLElement;
|
package/lib/cjs/utils/a11y.js
CHANGED
|
@@ -2,13 +2,136 @@
|
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
4
|
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
+
|
|
5
7
|
_Object$defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
|
|
11
|
+
exports.findIndexByCharacter = findIndexByCharacter;
|
|
12
|
+
exports.getAncestorNodeByRole = getAncestorNodeByRole;
|
|
13
|
+
exports.getMenuButton = getMenuButton;
|
|
9
14
|
exports.handlePrevent = handlePrevent;
|
|
15
|
+
exports.isPrintableCharacter = isPrintableCharacter;
|
|
16
|
+
exports.setFocusToFirstItem = setFocusToFirstItem;
|
|
17
|
+
exports.setFocusToItem = setFocusToItem;
|
|
18
|
+
exports.setFocusToLastItem = setFocusToLastItem;
|
|
19
|
+
exports.setFocusToNextMenuitem = setFocusToNextMenuitem;
|
|
20
|
+
exports.setFocusToPreviousMenuItem = setFocusToPreviousMenuItem;
|
|
21
|
+
|
|
22
|
+
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
23
|
+
|
|
24
|
+
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
10
25
|
|
|
11
26
|
function handlePrevent(event) {
|
|
12
27
|
event.stopPropagation();
|
|
13
28
|
event.preventDefault();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function isPrintableCharacter(string) {
|
|
32
|
+
return string.length === 1 && string.match(/\S/);
|
|
33
|
+
} // set focus to the target item in item list
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
function setFocusToItem(itemNodes, targetItem) {
|
|
37
|
+
for (let i = 0; i < itemNodes.length; i++) {
|
|
38
|
+
if (itemNodes[i] === targetItem) {
|
|
39
|
+
itemNodes[i].tabIndex = 0;
|
|
40
|
+
itemNodes[i].focus();
|
|
41
|
+
} else {
|
|
42
|
+
itemNodes[i].tabIndex = -1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} // set focus to the first item in item list
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
function setFocusToFirstItem(itemNodes) {
|
|
49
|
+
itemNodes.length > 0 && setFocusToItem(itemNodes, itemNodes[0]);
|
|
50
|
+
} // set focus to the last item in item list
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
function setFocusToLastItem(itemNodes) {
|
|
54
|
+
itemNodes.length > 0 && setFocusToItem(itemNodes, itemNodes[itemNodes.length - 1]);
|
|
55
|
+
} // set focus to the previous item in item list
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
function setFocusToPreviousMenuItem(itemNodes, currentItem) {
|
|
59
|
+
let newMenuItem, index;
|
|
60
|
+
|
|
61
|
+
if (itemNodes.length > 0) {
|
|
62
|
+
if (currentItem === itemNodes[0]) {
|
|
63
|
+
newMenuItem = itemNodes[itemNodes.length - 1];
|
|
64
|
+
} else {
|
|
65
|
+
index = (0, _indexOf.default)(itemNodes).call(itemNodes, currentItem);
|
|
66
|
+
newMenuItem = itemNodes[index - 1];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
setFocusToItem(itemNodes, newMenuItem);
|
|
70
|
+
}
|
|
71
|
+
} // set focus to the next item in item list
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
function setFocusToNextMenuitem(itemNodes, currentItem) {
|
|
75
|
+
let newMenuItem, index;
|
|
76
|
+
|
|
77
|
+
if (itemNodes.length > 0) {
|
|
78
|
+
if (currentItem === itemNodes[itemNodes.length - 1]) {
|
|
79
|
+
newMenuItem = itemNodes[0];
|
|
80
|
+
} else {
|
|
81
|
+
index = (0, _indexOf.default)(itemNodes).call(itemNodes, currentItem);
|
|
82
|
+
newMenuItem = itemNodes[index + 1];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
setFocusToItem(itemNodes, newMenuItem);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function findIndexByCharacter(itemList, curItem, firstCharList, char) {
|
|
90
|
+
let start, index;
|
|
91
|
+
|
|
92
|
+
if (!itemList || !firstCharList || !char || char.length > 1) {
|
|
93
|
+
return -1;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
char = char.toLowerCase(); // Get start index for search based on position of currentItem
|
|
97
|
+
|
|
98
|
+
start = (0, _indexOf.default)(itemList).call(itemList, curItem) + 1;
|
|
99
|
+
|
|
100
|
+
if (start >= itemList.length) {
|
|
101
|
+
start = 0;
|
|
102
|
+
} // Check remaining menu items in the menu
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
index = (0, _indexOf.default)(firstCharList).call(firstCharList, char, start); // If not found in remaining menu items, check from beginning
|
|
106
|
+
|
|
107
|
+
if (index === -1) {
|
|
108
|
+
index = (0, _indexOf.default)(firstCharList).call(firstCharList, char, 0);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return index >= 0 ? index : -1;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function getAncestorNodeByRole(curElement, role) {
|
|
115
|
+
if (!curElement) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
while (curElement.parentElement && (0, _get2.default)(curElement.parentElement, 'attributes.role.value', '') !== role) {
|
|
120
|
+
curElement = curElement.parentElement;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return curElement.parentElement;
|
|
124
|
+
} // According to the Id, find the corresponding data-popupId element
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
function getMenuButton(focusableEle, Id) {
|
|
128
|
+
for (let i = 0; i < focusableEle.length; i++) {
|
|
129
|
+
const curAriDescribedby = focusableEle[i].attributes['data-popupId'];
|
|
130
|
+
|
|
131
|
+
if (curAriDescribedby && curAriDescribedby.value === Id) {
|
|
132
|
+
return focusableEle[i];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return null;
|
|
14
137
|
}
|
|
@@ -149,6 +149,12 @@
|
|
|
149
149
|
.semi-cascader-selection .semi-tagInput .semi-input-wrapper-large {
|
|
150
150
|
height: 38px;
|
|
151
151
|
}
|
|
152
|
+
.semi-cascader-selection-text-inactive {
|
|
153
|
+
color: var(--semi-color-text-2);
|
|
154
|
+
}
|
|
155
|
+
.semi-cascader-selection-text-hide {
|
|
156
|
+
display: none;
|
|
157
|
+
}
|
|
152
158
|
.semi-cascader-arrow, .semi-cascader-clearbtn {
|
|
153
159
|
display: inline-flex;
|
|
154
160
|
align-items: center;
|
|
@@ -242,8 +248,17 @@
|
|
|
242
248
|
}
|
|
243
249
|
.semi-cascader-single.semi-cascader-filterable .semi-cascader-selection .semi-cascader-search-wrapper {
|
|
244
250
|
width: 100%;
|
|
251
|
+
height: 30px;
|
|
252
|
+
display: flex;
|
|
253
|
+
align-items: center;
|
|
254
|
+
position: relative;
|
|
245
255
|
}
|
|
246
256
|
.semi-cascader-single.semi-cascader-filterable .semi-cascader-selection .semi-cascader-search-wrapper .semi-input-wrapper {
|
|
257
|
+
position: absolute;
|
|
258
|
+
top: 0;
|
|
259
|
+
left: 0;
|
|
260
|
+
border: none;
|
|
261
|
+
background-color: transparent;
|
|
247
262
|
height: 100%;
|
|
248
263
|
width: 100%;
|
|
249
264
|
border: none;
|
|
@@ -175,6 +175,17 @@ $module: #{$prefix}-cascader;
|
|
|
175
175
|
height: $height-cascader_selection_tagInput_input_large;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
+
|
|
179
|
+
&-text {
|
|
180
|
+
|
|
181
|
+
&-inactive {
|
|
182
|
+
color: $color-cascader_selection_text_inactive;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&-hide {
|
|
186
|
+
display: none;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
178
189
|
}
|
|
179
190
|
|
|
180
191
|
&-arrow,
|
|
@@ -294,8 +305,17 @@ $module: #{$prefix}-cascader;
|
|
|
294
305
|
.#{$module}-selection {
|
|
295
306
|
.#{$module}-search-wrapper {
|
|
296
307
|
width: 100%;
|
|
308
|
+
height: $height-cascader_selection_wrapper;
|
|
309
|
+
display: flex;
|
|
310
|
+
align-items: center;
|
|
311
|
+
position: relative;
|
|
297
312
|
|
|
298
313
|
.#{$prefix}-input-wrapper {
|
|
314
|
+
position: absolute;
|
|
315
|
+
top: 0;
|
|
316
|
+
left: 0;
|
|
317
|
+
border: none;
|
|
318
|
+
background-color: transparent;
|
|
299
319
|
height: 100%;
|
|
300
320
|
width: 100%;
|
|
301
321
|
border: $color-cascader_input-border-default;
|
|
@@ -99,6 +99,7 @@ export interface BasicCascaderProps {
|
|
|
99
99
|
disableStrictly?: boolean;
|
|
100
100
|
leafOnly?: boolean;
|
|
101
101
|
enableLeafClick?: boolean;
|
|
102
|
+
preventScroll?: boolean;
|
|
102
103
|
onClear?: () => void;
|
|
103
104
|
triggerRender?: (props: BasicTriggerRenderProps) => any;
|
|
104
105
|
onListScroll?: (e: any, panel: BasicScrollPanelProps) => void;
|
|
@@ -136,6 +137,7 @@ export interface BasicCascaderInnerData {
|
|
|
136
137
|
isFocus?: boolean;
|
|
137
138
|
isInput?: boolean;
|
|
138
139
|
disabledKeys?: Set<string>;
|
|
140
|
+
showInput?: boolean;
|
|
139
141
|
}
|
|
140
142
|
export interface CascaderAdapter extends DefaultAdapter<BasicCascaderProps, BasicCascaderInnerData> {
|
|
141
143
|
notifyClear?: () => void;
|
|
@@ -160,6 +162,8 @@ export interface CascaderAdapter extends DefaultAdapter<BasicCascaderProps, Basi
|
|
|
160
162
|
notifyOnLoad: (newLoadedKeys: Set<string>, data: BasicCascaderData) => void;
|
|
161
163
|
notifyListScroll: (e: any, panel: BasicScrollPanelProps) => void;
|
|
162
164
|
notifyOnExceed: (data: BasicEntity[]) => void;
|
|
165
|
+
toggleInputShow: (show: boolean, cb: () => void) => void;
|
|
166
|
+
updateFocusState: (focus: boolean) => void;
|
|
163
167
|
}
|
|
164
168
|
export default class CascaderFoundation extends BaseFoundation<CascaderAdapter, BasicCascaderProps, BasicCascaderInnerData> {
|
|
165
169
|
constructor(adapter: CascaderAdapter);
|
|
@@ -187,6 +191,8 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
|
|
|
187
191
|
open(): void;
|
|
188
192
|
reCalcActiveKeys(): void;
|
|
189
193
|
close(e: any, key?: string): void;
|
|
194
|
+
toggle2SearchInput(isShow: boolean): void;
|
|
195
|
+
focusInput(): void;
|
|
190
196
|
getMergedMotion: () => any;
|
|
191
197
|
handleItemClick(e: any, item: BasicEntity | BasicData): void;
|
|
192
198
|
handleItemHover(e: any, item: BasicEntity): void;
|
|
@@ -388,10 +388,16 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
388
388
|
open() {
|
|
389
389
|
const filterable = this._isFilterable();
|
|
390
390
|
|
|
391
|
+
const {
|
|
392
|
+
multiple
|
|
393
|
+
} = this.getProps();
|
|
394
|
+
|
|
391
395
|
this._adapter.openMenu();
|
|
392
396
|
|
|
393
397
|
if (filterable) {
|
|
394
398
|
this._clearInput();
|
|
399
|
+
|
|
400
|
+
!multiple && this.toggle2SearchInput(true);
|
|
395
401
|
}
|
|
396
402
|
|
|
397
403
|
if (this._isControlledComponent()) {
|
|
@@ -451,11 +457,28 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
451
457
|
this._adapter.updateStates({
|
|
452
458
|
inputValue
|
|
453
459
|
});
|
|
460
|
+
|
|
461
|
+
!multiple && this.toggle2SearchInput(false);
|
|
462
|
+
!multiple && this._adapter.updateFocusState(false);
|
|
454
463
|
}
|
|
455
464
|
|
|
456
465
|
this._notifyBlur(e);
|
|
457
466
|
}
|
|
458
467
|
|
|
468
|
+
toggle2SearchInput(isShow) {
|
|
469
|
+
if (isShow) {
|
|
470
|
+
this._adapter.toggleInputShow(isShow, () => this.focusInput());
|
|
471
|
+
} else {
|
|
472
|
+
this._adapter.toggleInputShow(isShow, () => undefined);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
focusInput() {
|
|
477
|
+
this._adapter.focusInput();
|
|
478
|
+
|
|
479
|
+
this._adapter.updateFocusState(true);
|
|
480
|
+
}
|
|
481
|
+
|
|
459
482
|
handleItemClick(e, item) {
|
|
460
483
|
const isDisabled = this._isDisabled();
|
|
461
484
|
|
|
@@ -54,6 +54,7 @@ $spacing-cascader_clearBtn-marginRight: 12px; // 级联选择触发器清空按
|
|
|
54
54
|
|
|
55
55
|
$color-cascader_selection_n-text-default: var(--semi-color-text-0); // 超出 maxTagCount 后,+n 的文字默认颜色
|
|
56
56
|
$color-cascader_selection_n-text-disabled: var(--semi-color-disabled-text); // 超出 maxTagCount 后,+n 的文字disabled颜色
|
|
57
|
+
$color-cascader_selection_text_inactive: var(--semi-color-text-2); // 级联选择单选inpu输入框和text并存时,text颜色
|
|
57
58
|
$color-cascader_selection-text-default: var(--semi-color-text-0); // 级联选择选中项文字颜色
|
|
58
59
|
$color-cascader_placeholder-text-default: var(--semi-color-text-2); // 级联选择未选中项文字颜色
|
|
59
60
|
$color-cascader-icon-default: var(--semi-color-text-2); // 级联选择图标颜色 - 默认
|
|
@@ -94,6 +95,7 @@ $height-cascader_option_list: 180px; // 级联选择菜单高度
|
|
|
94
95
|
$height-cascader_selection_tagInput_input_small: 22px;
|
|
95
96
|
$height-cascader_selection_tagInput_input_default: 30px;
|
|
96
97
|
$height-cascader_selection_tagInput_input_large: 38px;
|
|
98
|
+
$height-cascader_selection_wrapper: 30px;
|
|
97
99
|
|
|
98
100
|
$spacing-cascader_text-marginX: $spacing-base-tight; // 级联选择 prefix/suffix 文字水平内间距
|
|
99
101
|
$spacing-cascader_icon-marginX: $spacing-tight; // 级联选择 prefix/suffix 图标水平内间距
|
|
@@ -75,11 +75,6 @@
|
|
|
75
75
|
.semi-checkbox-inner-display .semi-icon {
|
|
76
76
|
font-size: 16px;
|
|
77
77
|
}
|
|
78
|
-
.semi-checkbox-inner-pureCardType {
|
|
79
|
-
opacity: 0;
|
|
80
|
-
width: 0;
|
|
81
|
-
margin-right: 0 !important;
|
|
82
|
-
}
|
|
83
78
|
.semi-checkbox-inner-checked .semi-checkbox-inner-display {
|
|
84
79
|
background: var(--semi-color-primary);
|
|
85
80
|
color: var(--semi-color-white);
|
|
@@ -138,6 +133,11 @@
|
|
|
138
133
|
.semi-checkbox-cardType .semi-checkbox-inner-display {
|
|
139
134
|
background: var(--semi-color-white);
|
|
140
135
|
}
|
|
136
|
+
.semi-checkbox-cardType .semi-checkbox-inner-pureCardType {
|
|
137
|
+
opacity: 0;
|
|
138
|
+
width: 0;
|
|
139
|
+
margin-right: 0;
|
|
140
|
+
}
|
|
141
141
|
.semi-checkbox-cardType .semi-checkbox-addon {
|
|
142
142
|
font-weight: 600;
|
|
143
143
|
font-size: 14px;
|
|
@@ -101,15 +101,6 @@ $module: #{$prefix}-checkbox;
|
|
|
101
101
|
font-size: 16px;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
&-pureCardType {
|
|
106
|
-
// Reasons to use opacity:0 & width: 0 instead of display: none
|
|
107
|
-
// The a11y keyboard focus event of the checkbox depends on the implementation of the input focus/blur event
|
|
108
|
-
// input focus/blur cannot take effect when display: none
|
|
109
|
-
opacity: 0;
|
|
110
|
-
width: 0;
|
|
111
|
-
margin-right: 0 !important;
|
|
112
|
-
}
|
|
113
104
|
}
|
|
114
105
|
|
|
115
106
|
&-inner-checked {
|
|
@@ -196,6 +187,15 @@ $module: #{$prefix}-checkbox;
|
|
|
196
187
|
flex-shrink: 0;
|
|
197
188
|
}
|
|
198
189
|
|
|
190
|
+
.#{$module}-inner-pureCardType {
|
|
191
|
+
// Reasons to use opacity:0 & width: 0 instead of display: none
|
|
192
|
+
// The a11y keyboard focus event of the checkbox depends on the implementation of the input focus/blur event
|
|
193
|
+
// input focus/blur cannot take effect when display: none
|
|
194
|
+
opacity: 0;
|
|
195
|
+
width: 0;
|
|
196
|
+
margin-right: 0;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
199
|
.#{$module}-addon {
|
|
200
200
|
font-weight: $font-checkbox_cardType_addon-fontWeight;
|
|
201
201
|
font-size: $font-checkbox_cardType_addon-size;
|
|
@@ -131,6 +131,7 @@ export interface DatePickerFoundationProps extends ElementProps, RenderProps, Ev
|
|
|
131
131
|
localeCode?: string;
|
|
132
132
|
rangeSeparator?: string;
|
|
133
133
|
insetInput?: boolean;
|
|
134
|
+
preventScroll?: boolean;
|
|
134
135
|
}
|
|
135
136
|
export interface DatePickerFoundationState {
|
|
136
137
|
panelShow: boolean;
|
|
@@ -184,6 +185,12 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
184
185
|
initFromProps({ value, timeZone, prevTimeZone }: Pick<DatePickerFoundationProps, 'value' | 'timeZone'> & {
|
|
185
186
|
prevTimeZone?: string | number;
|
|
186
187
|
}): void;
|
|
188
|
+
/**
|
|
189
|
+
* 如果用户传了一个空的 value,需要把 range input focus 设置为 rangeStart,这样用户可以清除完之后继续从开始选择
|
|
190
|
+
*
|
|
191
|
+
* If the user passes an empty value, you need to set the range input focus to rangeStart, so that the user can continue to select from the beginning after clearing
|
|
192
|
+
*/
|
|
193
|
+
initRangeInputFocus(result: Date[]): void;
|
|
187
194
|
parseWithTimezone(value: ValueType, timeZone: string | number, prevTimeZone: string | number): Date[];
|
|
188
195
|
_isMultiple(): boolean;
|
|
189
196
|
/**
|