power-focusable 2.1.0 → 2.1.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.
package/README.md CHANGED
@@ -49,7 +49,7 @@ Used by `getNextFocusable` and `getPreviousFocusable`.
49
49
 
50
50
  If `true`, traverses the composed tree (including shadow DOM; slower)
51
51
 
52
- Used by `getFocusables`, `getNextFocusable`, and `getPreviousFocusable`.
52
+ Used by `getFocusables`, `getNextFocusable`, `getPreviousFocusable`, and `hasFocusable`.
53
53
 
54
54
  ### `wrap`
55
55
 
@@ -123,6 +123,9 @@ hasFocusable(container);
123
123
  // => boolean
124
124
  //
125
125
  // container (optional): HTMLElement (default: <body>)
126
+
127
+ // Traverses the composed tree (including shadow DOM; slower)
128
+ hasFocusable(container, { composed: true });
126
129
  ```
127
130
 
128
131
  ### `isFocusable`
package/dist/index.cjs CHANGED
@@ -59,12 +59,12 @@ function getPreviousFocusable(container = document.body, options = {}) {
59
59
  }
60
60
  return getRelativeFocusable(container, -1, options);
61
61
  }
62
- function hasFocusable(container = document.body) {
62
+ function hasFocusable(container = document.body, options = {}) {
63
63
  if (!(container instanceof HTMLElement)) {
64
64
  console.warn("Invalid container element. Fallback: <body> element.");
65
65
  container = document.body;
66
66
  }
67
- return getFocusables(container).length > 0;
67
+ return getFocusables(container, options).length > 0;
68
68
  }
69
69
  function isFocusable(element) {
70
70
  if (!(element instanceof HTMLElement)) {
@@ -241,7 +241,7 @@ function sortByTabIndex(elements) {
241
241
  * High-precision focus management utility with shadow DOM support.
242
242
  * Handles complex focus rules including tabindex ordering, radio groups, etc.
243
243
  *
244
- * @version 2.1.0
244
+ * @version 2.1.2
245
245
  * @author Yusuke Kamiyamane
246
246
  * @license MIT
247
247
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@
3
3
  * High-precision focus management utility with shadow DOM support.
4
4
  * Handles complex focus rules including tabindex ordering, radio groups, etc.
5
5
  *
6
- * @version 2.1.0
6
+ * @version 2.1.2
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -17,7 +17,7 @@ interface PowerFocusableOptions {
17
17
  declare function getFocusables(container?: HTMLElement, options?: Omit<PowerFocusableOptions, 'active' | 'wrap'>): HTMLElement[];
18
18
  declare function getNextFocusable(container?: HTMLElement, options?: PowerFocusableOptions): HTMLElement | null;
19
19
  declare function getPreviousFocusable(container?: HTMLElement, options?: PowerFocusableOptions): HTMLElement | null;
20
- declare function hasFocusable(container?: HTMLElement): boolean;
20
+ declare function hasFocusable(container?: HTMLElement, options?: Omit<PowerFocusableOptions, 'active' | 'wrap'>): boolean;
21
21
  declare function isFocusable(element: HTMLElement): boolean;
22
22
 
23
23
  export { type PowerFocusableOptions, getFocusables, getNextFocusable, getPreviousFocusable, hasFocusable, isFocusable };
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * High-precision focus management utility with shadow DOM support.
4
4
  * Handles complex focus rules including tabindex ordering, radio groups, etc.
5
5
  *
6
- * @version 2.1.0
6
+ * @version 2.1.2
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -17,7 +17,7 @@ interface PowerFocusableOptions {
17
17
  declare function getFocusables(container?: HTMLElement, options?: Omit<PowerFocusableOptions, 'active' | 'wrap'>): HTMLElement[];
18
18
  declare function getNextFocusable(container?: HTMLElement, options?: PowerFocusableOptions): HTMLElement | null;
19
19
  declare function getPreviousFocusable(container?: HTMLElement, options?: PowerFocusableOptions): HTMLElement | null;
20
- declare function hasFocusable(container?: HTMLElement): boolean;
20
+ declare function hasFocusable(container?: HTMLElement, options?: Omit<PowerFocusableOptions, 'active' | 'wrap'>): boolean;
21
21
  declare function isFocusable(element: HTMLElement): boolean;
22
22
 
23
23
  export { type PowerFocusableOptions, getFocusables, getNextFocusable, getPreviousFocusable, hasFocusable, isFocusable };
package/dist/index.js CHANGED
@@ -57,12 +57,12 @@ function getPreviousFocusable(container = document.body, options = {}) {
57
57
  }
58
58
  return getRelativeFocusable(container, -1, options);
59
59
  }
60
- function hasFocusable(container = document.body) {
60
+ function hasFocusable(container = document.body, options = {}) {
61
61
  if (!(container instanceof HTMLElement)) {
62
62
  console.warn("Invalid container element. Fallback: <body> element.");
63
63
  container = document.body;
64
64
  }
65
- return getFocusables(container).length > 0;
65
+ return getFocusables(container, options).length > 0;
66
66
  }
67
67
  function isFocusable(element) {
68
68
  if (!(element instanceof HTMLElement)) {
@@ -239,7 +239,7 @@ function sortByTabIndex(elements) {
239
239
  * High-precision focus management utility with shadow DOM support.
240
240
  * Handles complex focus rules including tabindex ordering, radio groups, etc.
241
241
  *
242
- * @version 2.1.0
242
+ * @version 2.1.2
243
243
  * @author Yusuke Kamiyamane
244
244
  * @license MIT
245
245
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "power-focusable",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "High-precision focus management utility with shadow DOM support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",