@brightspace-ui/core 3.29.0 → 3.30.0
Sign up to get free protection for your applications and to get access to all the features.
- package/helpers/README.md +3 -0
- package/helpers/focus.js +19 -0
- package/package.json +1 -1
package/helpers/README.md
CHANGED
@@ -126,6 +126,9 @@ getComposedActiveElement()
|
|
126
126
|
// gets the first focusable descendant given a node, including those within the shadow DOM
|
127
127
|
getFirstFocusableDescendant(node, includeHidden, predicate, includeTabbablesOnly)
|
128
128
|
|
129
|
+
// gets the focusable elements within the specified element
|
130
|
+
getFocusableDescendants(node, { deep: false, disabled: false, hidden: false, predicate: elem => false, tabbablesOnly: true })
|
131
|
+
|
129
132
|
// gets the focus pseudo-class to used in selectors (focus-visible if supported, or focus)
|
130
133
|
// Usage:
|
131
134
|
// css`
|
package/helpers/focus.js
CHANGED
@@ -40,6 +40,25 @@ export function getFirstFocusableDescendant(node, includeHidden, predicate, incl
|
|
40
40
|
return null;
|
41
41
|
}
|
42
42
|
|
43
|
+
export function getFocusableDescendants(node, options) {
|
44
|
+
let focusables = [];
|
45
|
+
|
46
|
+
const composedChildren = getComposedChildren(node);
|
47
|
+
composedChildren.forEach(child => {
|
48
|
+
if (child.tagName === 'svg') return;
|
49
|
+
if (options?.predicate) {
|
50
|
+
if (!options.predicate(child)) return;
|
51
|
+
}
|
52
|
+
|
53
|
+
if (isFocusable(child, options?.hidden, options?.tabbablesOnly, options?.disabled)) focusables.push(child);
|
54
|
+
if (options?.deep) {
|
55
|
+
focusables = [...focusables, ...getFocusableDescendants(child, options)];
|
56
|
+
}
|
57
|
+
});
|
58
|
+
|
59
|
+
return focusables;
|
60
|
+
}
|
61
|
+
|
43
62
|
export function getFocusPseudoClass() {
|
44
63
|
return isFocusVisibleSupported() ? 'focus-visible' : 'focus';
|
45
64
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.30.0",
|
4
4
|
"description": "A collection of accessible, free, open-source web components for building Brightspace applications",
|
5
5
|
"type": "module",
|
6
6
|
"repository": "https://github.com/BrightspaceUI/core.git",
|