@os-design/core 1.0.262 → 1.0.264
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/Input/utils/getFocusableElements.d.ts.map +1 -1
- package/dist/Input/utils/getFocusableElements.js +10 -1
- package/dist/Menu/utils/useFocusWithArrows.js +1 -1
- package/package.json +13 -13
- package/src/Input/utils/getFocusableElements.ts +12 -6
- package/src/Menu/utils/useFocusWithArrows.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFocusableElements.d.ts","sourceRoot":"","sources":["../../../src/Input/utils/getFocusableElements.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,oBAAoB,YAAa,UAAU,KAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"getFocusableElements.d.ts","sourceRoot":"","sources":["../../../src/Input/utils/getFocusableElements.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,oBAAoB,YAAa,UAAU,KAAG,WAAW,EAW9D,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
const getFocusableElements = element =>
|
|
1
|
+
const getFocusableElements = element => {
|
|
2
|
+
const nodes = element.querySelectorAll('a, button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])');
|
|
3
|
+
const res = [];
|
|
4
|
+
nodes.forEach(node => {
|
|
5
|
+
if (!node.hasAttribute('disabled')) {
|
|
6
|
+
res.push(node);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
return res;
|
|
10
|
+
};
|
|
2
11
|
export default getFocusableElements;
|
|
@@ -7,7 +7,7 @@ const useFocusWithArrows = ref => {
|
|
|
7
7
|
const {
|
|
8
8
|
activeElement
|
|
9
9
|
} = document;
|
|
10
|
-
const curFocusedIndex = activeElement ?
|
|
10
|
+
const curFocusedIndex = activeElement ? Array.from(focusableListItems).indexOf(activeElement) : -1;
|
|
11
11
|
let nextFocusedIndex;
|
|
12
12
|
if (curFocusedIndex === -1 && e.key === 'ArrowUp') {
|
|
13
13
|
nextFocusedIndex = focusableListItems.length - 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@os-design/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.264",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": "git@gitlab.com:os-team/libs/os-design.git",
|
|
6
6
|
"type": "module",
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@os-design/date-picker-utils": "^1.0.
|
|
33
|
-
"@os-design/icons": "^1.0.
|
|
34
|
-
"@os-design/input-number-utils": "^1.0.
|
|
35
|
-
"@os-design/input-password-utils": "^1.0.
|
|
36
|
-
"@os-design/media": "^1.0.
|
|
37
|
-
"@os-design/menu-utils": "^1.0.
|
|
38
|
-
"@os-design/portal": "^1.0.
|
|
39
|
-
"@os-design/styles": "^1.0.
|
|
40
|
-
"@os-design/theming": "^1.0.
|
|
41
|
-
"@os-design/time-picker-utils": "^1.0.
|
|
42
|
-
"@os-design/utils": "^1.0.
|
|
32
|
+
"@os-design/date-picker-utils": "^1.0.31",
|
|
33
|
+
"@os-design/icons": "^1.0.67",
|
|
34
|
+
"@os-design/input-number-utils": "^1.0.37",
|
|
35
|
+
"@os-design/input-password-utils": "^1.0.3",
|
|
36
|
+
"@os-design/media": "^1.0.31",
|
|
37
|
+
"@os-design/menu-utils": "^1.0.27",
|
|
38
|
+
"@os-design/portal": "^1.0.23",
|
|
39
|
+
"@os-design/styles": "^1.0.64",
|
|
40
|
+
"@os-design/theming": "^1.0.60",
|
|
41
|
+
"@os-design/time-picker-utils": "^1.0.22",
|
|
42
|
+
"@os-design/utils": "^1.0.84",
|
|
43
43
|
"facepaint": "^1.2.1",
|
|
44
44
|
"react-focus-lock": "^2.13.2",
|
|
45
45
|
"react-window": "^1.8.10"
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"react": ">=18",
|
|
59
59
|
"react-dom": ">=18"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "ed7b645f040dc652da07a9bd23a5983b0416f126"
|
|
62
62
|
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
const getFocusableElements = (element: ParentNode): HTMLElement[] =>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const getFocusableElements = (element: ParentNode): HTMLElement[] => {
|
|
2
|
+
const nodes = element.querySelectorAll<HTMLElement>(
|
|
3
|
+
'a, button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])'
|
|
4
|
+
);
|
|
5
|
+
const res: HTMLElement[] = [];
|
|
6
|
+
nodes.forEach((node) => {
|
|
7
|
+
if (!node.hasAttribute('disabled')) {
|
|
8
|
+
res.push(node);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return res;
|
|
12
|
+
};
|
|
7
13
|
|
|
8
14
|
export default getFocusableElements;
|
|
@@ -10,10 +10,10 @@ const useFocusWithArrows = (ref: RefObject<Element>): void => {
|
|
|
10
10
|
);
|
|
11
11
|
const { activeElement } = document;
|
|
12
12
|
const curFocusedIndex = activeElement
|
|
13
|
-
? (
|
|
13
|
+
? (Array.from(focusableListItems) as Element[]).indexOf(activeElement)
|
|
14
14
|
: -1;
|
|
15
15
|
|
|
16
|
-
let nextFocusedIndex;
|
|
16
|
+
let nextFocusedIndex: number | undefined;
|
|
17
17
|
if (curFocusedIndex === -1 && e.key === 'ArrowUp') {
|
|
18
18
|
nextFocusedIndex = focusableListItems.length - 1;
|
|
19
19
|
} else if (curFocusedIndex === -1 && e.key === 'ArrowDown') {
|