@lumx/core 4.12.1-next.1 → 4.12.1-next.2
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.
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
/** CSS selector listing all tabbable elements. */
|
|
2
2
|
export declare const TABBABLE_ELEMENTS_SELECTOR = "a[href], button, textarea, input:not([type=\"hidden\"]):not([hidden]), [tabindex]";
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* CSS selector matching elements that should be excluded from focus traversal.
|
|
5
|
+
*
|
|
6
|
+
* Note: `aria-disabled` is intentionally NOT in this list — per ARIA semantics, an `aria-disabled` element
|
|
7
|
+
* remains focusable (and discoverable by assistive tech). To remove an element from the tab order, use
|
|
8
|
+
* `tabindex="-1"` instead.
|
|
9
|
+
*/
|
|
10
|
+
export declare const DISABLED_SELECTOR = "[hidden], [tabindex=\"-1\"], [disabled]:not([disabled=\"false\"])";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { getFirstAndLastFocusable } from './getFirstAndLastFocusable';
|
|
2
2
|
export { getFocusableElements } from './getFocusableElements';
|
|
3
|
+
export { setupFocusTrap, type SetupFocusTrapOptions } from './setupFocusTrap';
|
|
3
4
|
export { TABBABLE_ELEMENTS_SELECTOR, DISABLED_SELECTOR } from './constants';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface SetupFocusTrapOptions {
|
|
2
|
+
/** The element in which to trap the focus. */
|
|
3
|
+
focusZoneElement: HTMLElement;
|
|
4
|
+
/**
|
|
5
|
+
* The element to focus when the trap is activated.
|
|
6
|
+
* Falls back to the first focusable element inside the zone, then to the zone element itself.
|
|
7
|
+
*/
|
|
8
|
+
focusElement?: HTMLElement | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Trap 'Tab' focus switch inside the `focusZoneElement`.
|
|
12
|
+
*
|
|
13
|
+
* Setup behavior:
|
|
14
|
+
* 1. Focus `focusElement` if provided and contained in the zone.
|
|
15
|
+
* 2. Otherwise focus the first focusable descendant.
|
|
16
|
+
* 3. Otherwise focus the zone element itself (falling back to setting `tabindex="-1"` if needed) so that
|
|
17
|
+
* keyboard users (especially screen reader users) land inside the trapped region (e.g. an empty dialog).
|
|
18
|
+
*
|
|
19
|
+
* Tab key behavior:
|
|
20
|
+
* - With at least one focusable descendant: focus cycles between the first and last focusable in the zone.
|
|
21
|
+
* - With no focusable descendant: Tab is swallowed and focus is restored to the zone element itself.
|
|
22
|
+
*
|
|
23
|
+
* Multiple traps stack — only the latest one is active; previous traps re-enable when the latest is torn down.
|
|
24
|
+
*
|
|
25
|
+
* @param options Trap configuration.
|
|
26
|
+
* @param signal AbortSignal used to tear down the trap.
|
|
27
|
+
*/
|
|
28
|
+
export declare function setupFocusTrap(options: SetupFocusTrapOptions, signal: AbortSignal): void;
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@floating-ui/dom": "^1.7.5",
|
|
10
|
-
"@lumx/icons": "^4.12.1-next.
|
|
10
|
+
"@lumx/icons": "^4.12.1-next.2",
|
|
11
11
|
"classnames": "^2.3.2",
|
|
12
12
|
"focus-visible": "^5.0.2",
|
|
13
13
|
"lodash": "4.18.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
|
|
70
70
|
},
|
|
71
71
|
"sideEffects": false,
|
|
72
|
-
"version": "4.12.1-next.
|
|
72
|
+
"version": "4.12.1-next.2",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
75
75
|
"@testing-library/dom": "^10.4.1",
|