power-focusable 3.1.1 → 4.0.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/README.md CHANGED
@@ -35,14 +35,14 @@ import { ... } 'https://unpkg.com/power-focusable/dist/index.js';
35
35
 
36
36
  ```ts
37
37
  interface PowerFocusableOptions {
38
- active?: Element | null; // default: document.activeElement
38
+ anchor?: Element | null; // default: document.activeElement
39
39
  composed?: boolean; // default: false
40
40
  filter?: (element: Element) => boolean; // default: () => true
41
41
  wrap?: boolean; // default: false
42
42
  }
43
43
  ```
44
44
 
45
- ### `active`
45
+ ### `anchor`
46
46
 
47
47
  Specifies the starting element.
48
48
 
@@ -109,7 +109,7 @@ getNextFocusable(container);
109
109
  // container (optional): Element (default: <body>)
110
110
 
111
111
  // Specifies the starting element
112
- getNextFocusable(container, { active: document.querySelector('.button') });
112
+ getNextFocusable(container, { anchor: document.querySelector('.button') });
113
113
 
114
114
  // Traverses the composed tree (including shadow DOM; slower)
115
115
  getNextFocusable(container, { composed: true });
@@ -132,7 +132,7 @@ getPreviousFocusable(container);
132
132
  // container (optional): Element (default: <body>)
133
133
 
134
134
  // Specifies the starting element
135
- getPreviousFocusable(container, { active: document.querySelector('.button') });
135
+ getPreviousFocusable(container, { anchor: document.querySelector('.button') });
136
136
 
137
137
  // Traverses the composed tree (including shadow DOM; slower)
138
138
  getPreviousFocusable(container, { composed: true });
package/dist/index.cjs CHANGED
@@ -155,7 +155,7 @@ function isFocusable(element) {
155
155
  }
156
156
  function getRelativeFocusable(container, offset, options) {
157
157
  const {
158
- active = getActiveElement(),
158
+ anchor = getActiveElement(),
159
159
  composed = false,
160
160
  filter = () => true,
161
161
  wrap = false
@@ -165,13 +165,13 @@ function getRelativeFocusable(container, offset, options) {
165
165
  if (!length) {
166
166
  return null;
167
167
  }
168
- if (!active || !containsComposed(container, active)) {
168
+ if (!anchor || !containsComposed(container, anchor)) {
169
169
  return null;
170
170
  }
171
- if (!(active instanceof Element)) {
171
+ if (!(anchor instanceof Element)) {
172
172
  return null;
173
173
  }
174
- const currentIndex = focusables.indexOf(active);
174
+ const currentIndex = focusables.indexOf(anchor);
175
175
  if (currentIndex === -1) {
176
176
  return null;
177
177
  }
@@ -398,7 +398,7 @@ function isUngroupedRadio(element) {
398
398
  * Handles complex focus rules including tabindex ordering, radio groups, inert,
399
399
  * and shadow DOM.
400
400
  *
401
- * @version 3.1.1
401
+ * @version 4.0.0
402
402
  * @author Yusuke Kamiyamane
403
403
  * @license MIT
404
404
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -4,23 +4,23 @@
4
4
  * Handles complex focus rules including tabindex ordering, radio groups, inert,
5
5
  * and shadow DOM.
6
6
  *
7
- * @version 3.1.1
7
+ * @version 4.0.0
8
8
  * @author Yusuke Kamiyamane
9
9
  * @license MIT
10
10
  * @copyright Copyright (c) Yusuke Kamiyamane
11
11
  * @see {@link https://github.com/y14e/power-focusable}
12
12
  */
13
13
  interface PowerFocusableOptions {
14
- readonly active?: Element | null;
14
+ readonly anchor?: Element | null;
15
15
  readonly composed?: boolean;
16
16
  readonly filter?: (element: Element) => boolean;
17
17
  readonly wrap?: boolean;
18
18
  }
19
19
  declare function createFocusTrap(container: Element): () => void;
20
- declare function getFocusables(container?: Element, options?: Omit<PowerFocusableOptions, 'active' | 'wrap'>): Element[];
20
+ declare function getFocusables(container?: Element, options?: Omit<PowerFocusableOptions, 'anchor' | 'wrap'>): Element[];
21
21
  declare function getNextFocusable(container?: Element, options?: PowerFocusableOptions): Element | null;
22
22
  declare function getPreviousFocusable(container?: Element, options?: PowerFocusableOptions): Element | null;
23
- declare function hasFocusable(container?: Element, options?: Omit<PowerFocusableOptions, 'active' | 'wrap'>): boolean;
23
+ declare function hasFocusable(container?: Element, options?: Omit<PowerFocusableOptions, 'anchor' | 'wrap'>): boolean;
24
24
  declare function inertOutside(element: Element): () => void;
25
25
  declare function isFocusable(element: Element): boolean;
26
26
 
package/dist/index.d.ts CHANGED
@@ -4,23 +4,23 @@
4
4
  * Handles complex focus rules including tabindex ordering, radio groups, inert,
5
5
  * and shadow DOM.
6
6
  *
7
- * @version 3.1.1
7
+ * @version 4.0.0
8
8
  * @author Yusuke Kamiyamane
9
9
  * @license MIT
10
10
  * @copyright Copyright (c) Yusuke Kamiyamane
11
11
  * @see {@link https://github.com/y14e/power-focusable}
12
12
  */
13
13
  interface PowerFocusableOptions {
14
- readonly active?: Element | null;
14
+ readonly anchor?: Element | null;
15
15
  readonly composed?: boolean;
16
16
  readonly filter?: (element: Element) => boolean;
17
17
  readonly wrap?: boolean;
18
18
  }
19
19
  declare function createFocusTrap(container: Element): () => void;
20
- declare function getFocusables(container?: Element, options?: Omit<PowerFocusableOptions, 'active' | 'wrap'>): Element[];
20
+ declare function getFocusables(container?: Element, options?: Omit<PowerFocusableOptions, 'anchor' | 'wrap'>): Element[];
21
21
  declare function getNextFocusable(container?: Element, options?: PowerFocusableOptions): Element | null;
22
22
  declare function getPreviousFocusable(container?: Element, options?: PowerFocusableOptions): Element | null;
23
- declare function hasFocusable(container?: Element, options?: Omit<PowerFocusableOptions, 'active' | 'wrap'>): boolean;
23
+ declare function hasFocusable(container?: Element, options?: Omit<PowerFocusableOptions, 'anchor' | 'wrap'>): boolean;
24
24
  declare function inertOutside(element: Element): () => void;
25
25
  declare function isFocusable(element: Element): boolean;
26
26
 
package/dist/index.js CHANGED
@@ -153,7 +153,7 @@ function isFocusable(element) {
153
153
  }
154
154
  function getRelativeFocusable(container, offset, options) {
155
155
  const {
156
- active = getActiveElement(),
156
+ anchor = getActiveElement(),
157
157
  composed = false,
158
158
  filter = () => true,
159
159
  wrap = false
@@ -163,13 +163,13 @@ function getRelativeFocusable(container, offset, options) {
163
163
  if (!length) {
164
164
  return null;
165
165
  }
166
- if (!active || !containsComposed(container, active)) {
166
+ if (!anchor || !containsComposed(container, anchor)) {
167
167
  return null;
168
168
  }
169
- if (!(active instanceof Element)) {
169
+ if (!(anchor instanceof Element)) {
170
170
  return null;
171
171
  }
172
- const currentIndex = focusables.indexOf(active);
172
+ const currentIndex = focusables.indexOf(anchor);
173
173
  if (currentIndex === -1) {
174
174
  return null;
175
175
  }
@@ -396,7 +396,7 @@ function isUngroupedRadio(element) {
396
396
  * Handles complex focus rules including tabindex ordering, radio groups, inert,
397
397
  * and shadow DOM.
398
398
  *
399
- * @version 3.1.1
399
+ * @version 4.0.0
400
400
  * @author Yusuke Kamiyamane
401
401
  * @license MIT
402
402
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "power-focusable",
3
- "version": "3.1.1",
3
+ "version": "4.0.0",
4
4
  "description": "High-precision focus management utility with full composed tree support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",