power-focusable 4.3.15 → 4.3.17

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
@@ -24,11 +24,11 @@ import {
24
24
  } from 'power-focusable';
25
25
 
26
26
  // CDNs
27
- import { ... } 'https://esm.sh/power-focusable@4.3.15';
27
+ import { ... } 'https://esm.sh/power-focusable@4.3.17';
28
28
  // or
29
- import { ... } 'https://cdn.jsdelivr.net/npm/power-focusable@4.3.15/+esm';
29
+ import { ... } 'https://cdn.jsdelivr.net/npm/power-focusable@4.3.17/+esm';
30
30
  // or
31
- import { ... } 'https://esm.unpkg.com/power-focusable@4.3.15';
31
+ import { ... } 'https://esm.unpkg.com/power-focusable@4.3.17';
32
32
  ```
33
33
 
34
34
  ## 🪄 Options
@@ -121,9 +121,6 @@ getFocusables(container, { composed: true });
121
121
 
122
122
  // Uses custom filter function
123
123
  getFocusables(container, { filter: (element) => !element.matches('[data-skip-focus]') });
124
-
125
- // Uses custom include function
126
- getFocusables(container, { filter: (element) => element.matches('[data-force-focusable]') });
127
124
  ```
128
125
 
129
126
  ### `getNextFocusable`
@@ -145,9 +142,6 @@ getNextFocusable(container, { composed: true });
145
142
  // Uses custom filter function
146
143
  getNextFocusable(container, { filter: (element) => !element.matches('[data-skip-focus]') });
147
144
 
148
- // Uses custom include function
149
- getNextFocusable(container, { filter: (element) => element.matches('[data-force-focusable]') });
150
-
151
145
  // Wraps around to the first element when reaching the end
152
146
  getNextFocusable(container, { wrap: true });
153
147
  ```
@@ -171,9 +165,6 @@ getPreviousFocusable(container, { composed: true });
171
165
  // Uses custom filter function
172
166
  getPreviousFocusable(container, { filter: (element) => !element.matches('[data-skip-focus]') });
173
167
 
174
- // Uses custom include function
175
- getPreviousFocusable(container, { filter: (element) => element.matches('[data-force-focusable]') });
176
-
177
168
  // Wraps around to the last element when reaching the end
178
169
  getPreviousFocusable(container, { wrap: true });
179
170
 
@@ -194,9 +185,6 @@ hasFocusable(container, { composed: true });
194
185
 
195
186
  // Uses custom filter function
196
187
  hasFocusable(container, { filter: (element) => !element.matches('[data-skip-focus]') });
197
-
198
- // Uses custom include function
199
- hasFocusable(container, { filter: (element) => element.matches('[data-force-focusable]') });
200
188
  ```
201
189
 
202
190
  ### `inertOutside`
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/index.ts
4
4
  var FOCUSABLE_SELECTOR = `:is(a[href], area[href], button, embed, iframe, input:not([type="hidden" i]), object, select, details > summary:first-of-type, textarea, [contenteditable]:not([contenteditable="false" i]), [controls], [tabindex]):not(:disabled, [hidden], [inert], [tabindex="-1"])`;
5
- var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TAB_INDEX = FOCUSABLE_SELECTOR.replace(
5
+ var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX = FOCUSABLE_SELECTOR.replace(
6
6
  /(,\s*)?\[tabindex="-1"\]/g,
7
7
  ""
8
8
  );
@@ -118,7 +118,7 @@ function getFocusables(container = document.body, options = {}) {
118
118
  }
119
119
  } else {
120
120
  const candidates = container.querySelectorAll(
121
- skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TAB_INDEX : FOCUSABLE_SELECTOR
121
+ skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
122
122
  );
123
123
  for (let i = 0, l = candidates.length; i < l; i++) {
124
124
  const candidate = candidates[i];
@@ -186,7 +186,7 @@ function isFocusable(element, options = {}) {
186
186
  return false;
187
187
  }
188
188
  if (!element.matches(
189
- skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TAB_INDEX : FOCUSABLE_SELECTOR
189
+ skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
190
190
  )) {
191
191
  return false;
192
192
  }
@@ -265,20 +265,20 @@ function getRelativeFocusable(container, offset, options) {
265
265
  skipNegativeTabIndexCheck,
266
266
  skipVisibilityCheck
267
267
  };
268
- const focusables = getFocusables(container, settings);
269
- const { length } = focusables;
268
+ const candidates = getFocusables(container, settings);
269
+ const { length } = candidates;
270
270
  if (!length) {
271
271
  return null;
272
272
  }
273
- const currentIndex = focusables.indexOf(anchor);
274
- if (currentIndex === -1) {
273
+ const foundIndex = candidates.indexOf(anchor);
274
+ if (foundIndex === -1) {
275
275
  return null;
276
276
  }
277
- const offsetIndex = currentIndex + offset;
277
+ const offsetIndex = foundIndex + offset;
278
278
  if ((offsetIndex < 0 || offsetIndex >= length) && !wrap) {
279
279
  return null;
280
280
  }
281
- return focusables[(offsetIndex + length) % length] ?? null;
281
+ return candidates[(offsetIndex + length) % length] ?? null;
282
282
  }
283
283
  function isDisabledDeep(element) {
284
284
  let current = element;
@@ -493,7 +493,7 @@ function isUngroupedRadio(element) {
493
493
  * High-precision focus management utility with full composed tree support.
494
494
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
495
495
  *
496
- * @version 4.3.15
496
+ * @version 4.3.17
497
497
  * @author Yusuke Kamiyamane
498
498
  * @license MIT
499
499
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@
3
3
  * High-precision focus management utility with full composed tree support.
4
4
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
5
5
  *
6
- * @version 4.3.15
6
+ * @version 4.3.17
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * High-precision focus management utility with full composed tree support.
4
4
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
5
5
  *
6
- * @version 4.3.15
6
+ * @version 4.3.17
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
2
  var FOCUSABLE_SELECTOR = `:is(a[href], area[href], button, embed, iframe, input:not([type="hidden" i]), object, select, details > summary:first-of-type, textarea, [contenteditable]:not([contenteditable="false" i]), [controls], [tabindex]):not(:disabled, [hidden], [inert], [tabindex="-1"])`;
3
- var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TAB_INDEX = FOCUSABLE_SELECTOR.replace(
3
+ var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX = FOCUSABLE_SELECTOR.replace(
4
4
  /(,\s*)?\[tabindex="-1"\]/g,
5
5
  ""
6
6
  );
@@ -116,7 +116,7 @@ function getFocusables(container = document.body, options = {}) {
116
116
  }
117
117
  } else {
118
118
  const candidates = container.querySelectorAll(
119
- skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TAB_INDEX : FOCUSABLE_SELECTOR
119
+ skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
120
120
  );
121
121
  for (let i = 0, l = candidates.length; i < l; i++) {
122
122
  const candidate = candidates[i];
@@ -184,7 +184,7 @@ function isFocusable(element, options = {}) {
184
184
  return false;
185
185
  }
186
186
  if (!element.matches(
187
- skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TAB_INDEX : FOCUSABLE_SELECTOR
187
+ skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
188
188
  )) {
189
189
  return false;
190
190
  }
@@ -263,20 +263,20 @@ function getRelativeFocusable(container, offset, options) {
263
263
  skipNegativeTabIndexCheck,
264
264
  skipVisibilityCheck
265
265
  };
266
- const focusables = getFocusables(container, settings);
267
- const { length } = focusables;
266
+ const candidates = getFocusables(container, settings);
267
+ const { length } = candidates;
268
268
  if (!length) {
269
269
  return null;
270
270
  }
271
- const currentIndex = focusables.indexOf(anchor);
272
- if (currentIndex === -1) {
271
+ const foundIndex = candidates.indexOf(anchor);
272
+ if (foundIndex === -1) {
273
273
  return null;
274
274
  }
275
- const offsetIndex = currentIndex + offset;
275
+ const offsetIndex = foundIndex + offset;
276
276
  if ((offsetIndex < 0 || offsetIndex >= length) && !wrap) {
277
277
  return null;
278
278
  }
279
- return focusables[(offsetIndex + length) % length] ?? null;
279
+ return candidates[(offsetIndex + length) % length] ?? null;
280
280
  }
281
281
  function isDisabledDeep(element) {
282
282
  let current = element;
@@ -491,7 +491,7 @@ function isUngroupedRadio(element) {
491
491
  * High-precision focus management utility with full composed tree support.
492
492
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
493
493
  *
494
- * @version 4.3.15
494
+ * @version 4.3.17
495
495
  * @author Yusuke Kamiyamane
496
496
  * @license MIT
497
497
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "power-focusable",
3
- "version": "4.3.15",
3
+ "version": "4.3.17",
4
4
  "description": "High-precision focus management utility with full composed tree support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",