power-focusable 4.1.5 → 4.1.7

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/dist/index.cjs CHANGED
@@ -44,14 +44,17 @@ function getFocusables(container = document.body, options = {}) {
44
44
  console.warn("Invalid container element. Fallback: <body> element.");
45
45
  container = document.body;
46
46
  }
47
- const { composed = false } = options;
48
- let { filter, include } = options;
49
- if (filter && typeof filter !== "function") {
50
- console.warn("Invalid filter function");
47
+ let { composed = false, filter, include } = options;
48
+ if (typeof composed !== "boolean") {
49
+ console.warn("Invalid composed. Fallback: false.");
50
+ composed = false;
51
+ }
52
+ if (typeof filter !== "undefined" && typeof filter !== "function") {
53
+ console.warn("Invalid filter. Fallback: no filter function (undefined).");
51
54
  filter = void 0;
52
55
  }
53
- if (include && typeof include !== "function") {
54
- console.warn("Invalid include function");
56
+ if (typeof include !== "undefined" && typeof include !== "function") {
57
+ console.warn("Invalid include. Fallback: no include function (undefined).");
55
58
  include = void 0;
56
59
  }
57
60
  const elements = [];
@@ -88,24 +91,12 @@ function getFocusables(container = document.body, options = {}) {
88
91
  return filter ? unfiltered.filter(filter) : unfiltered;
89
92
  }
90
93
  function getNextFocusable(container = document.body, options = {}) {
91
- if (!(container instanceof Element)) {
92
- console.warn("Invalid container element. Fallback: <body> element.");
93
- container = document.body;
94
- }
95
94
  return getRelativeFocusable(container, 1, options);
96
95
  }
97
96
  function getPreviousFocusable(container = document.body, options = {}) {
98
- if (!(container instanceof Element)) {
99
- console.warn("Invalid container element. Fallback: <body> element.");
100
- container = document.body;
101
- }
102
97
  return getRelativeFocusable(container, -1, options);
103
98
  }
104
99
  function hasFocusable(container = document.body, options = {}) {
105
- if (!(container instanceof Element)) {
106
- console.warn("Invalid container element. Fallback: <body> element.");
107
- container = document.body;
108
- }
109
100
  return !!getFocusables(container, options).length;
110
101
  }
111
102
  function inertOutside(element) {
@@ -164,8 +155,17 @@ function isFocusable(element) {
164
155
  return true;
165
156
  }
166
157
  function getRelativeFocusable(container, offset, options) {
167
- let anchor = options.anchor ?? getActiveElement();
168
- const { composed = false, filter, include, wrap = false } = options;
158
+ if (!(container instanceof Element)) {
159
+ console.warn("Invalid container element. Fallback: <body> element.");
160
+ container = document.body;
161
+ }
162
+ let {
163
+ anchor = getActiveElement(),
164
+ composed = false,
165
+ filter,
166
+ include,
167
+ wrap = false
168
+ } = options;
169
169
  if (!(anchor instanceof Element)) {
170
170
  const active = getActiveElement();
171
171
  if (active instanceof Element) {
@@ -180,6 +180,22 @@ function getRelativeFocusable(container, offset, options) {
180
180
  console.warn("Anchor (active) element not within container");
181
181
  return null;
182
182
  }
183
+ if (typeof composed !== "boolean") {
184
+ console.warn("Invalid composed. Fallback: false.");
185
+ composed = false;
186
+ }
187
+ if (typeof filter !== "undefined" && typeof filter !== "function") {
188
+ console.warn("Invalid filter. Fallback: no filter function (undefined).");
189
+ filter = void 0;
190
+ }
191
+ if (typeof include !== "undefined" && typeof include !== "function") {
192
+ console.warn("Invalid include. Fallback: no include function (undefined).");
193
+ include = void 0;
194
+ }
195
+ if (typeof wrap !== "boolean") {
196
+ console.warn("Invalid wrap. Fallback: false.");
197
+ wrap = false;
198
+ }
183
199
  const focusables = getFocusables(container, { composed, filter, include });
184
200
  const { length } = focusables;
185
201
  if (!length) {
@@ -411,7 +427,7 @@ function isUngroupedRadio(element) {
411
427
  * High-precision focus management utility with full composed tree support.
412
428
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
413
429
  *
414
- * @version 4.1.5
430
+ * @version 4.1.7
415
431
  * @author Yusuke Kamiyamane
416
432
  * @license MIT
417
433
  * @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.1.5
6
+ * @version 4.1.7
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.1.5
6
+ * @version 4.1.7
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -42,14 +42,17 @@ function getFocusables(container = document.body, options = {}) {
42
42
  console.warn("Invalid container element. Fallback: <body> element.");
43
43
  container = document.body;
44
44
  }
45
- const { composed = false } = options;
46
- let { filter, include } = options;
47
- if (filter && typeof filter !== "function") {
48
- console.warn("Invalid filter function");
45
+ let { composed = false, filter, include } = options;
46
+ if (typeof composed !== "boolean") {
47
+ console.warn("Invalid composed. Fallback: false.");
48
+ composed = false;
49
+ }
50
+ if (typeof filter !== "undefined" && typeof filter !== "function") {
51
+ console.warn("Invalid filter. Fallback: no filter function (undefined).");
49
52
  filter = void 0;
50
53
  }
51
- if (include && typeof include !== "function") {
52
- console.warn("Invalid include function");
54
+ if (typeof include !== "undefined" && typeof include !== "function") {
55
+ console.warn("Invalid include. Fallback: no include function (undefined).");
53
56
  include = void 0;
54
57
  }
55
58
  const elements = [];
@@ -86,24 +89,12 @@ function getFocusables(container = document.body, options = {}) {
86
89
  return filter ? unfiltered.filter(filter) : unfiltered;
87
90
  }
88
91
  function getNextFocusable(container = document.body, options = {}) {
89
- if (!(container instanceof Element)) {
90
- console.warn("Invalid container element. Fallback: <body> element.");
91
- container = document.body;
92
- }
93
92
  return getRelativeFocusable(container, 1, options);
94
93
  }
95
94
  function getPreviousFocusable(container = document.body, options = {}) {
96
- if (!(container instanceof Element)) {
97
- console.warn("Invalid container element. Fallback: <body> element.");
98
- container = document.body;
99
- }
100
95
  return getRelativeFocusable(container, -1, options);
101
96
  }
102
97
  function hasFocusable(container = document.body, options = {}) {
103
- if (!(container instanceof Element)) {
104
- console.warn("Invalid container element. Fallback: <body> element.");
105
- container = document.body;
106
- }
107
98
  return !!getFocusables(container, options).length;
108
99
  }
109
100
  function inertOutside(element) {
@@ -162,8 +153,17 @@ function isFocusable(element) {
162
153
  return true;
163
154
  }
164
155
  function getRelativeFocusable(container, offset, options) {
165
- let anchor = options.anchor ?? getActiveElement();
166
- const { composed = false, filter, include, wrap = false } = options;
156
+ if (!(container instanceof Element)) {
157
+ console.warn("Invalid container element. Fallback: <body> element.");
158
+ container = document.body;
159
+ }
160
+ let {
161
+ anchor = getActiveElement(),
162
+ composed = false,
163
+ filter,
164
+ include,
165
+ wrap = false
166
+ } = options;
167
167
  if (!(anchor instanceof Element)) {
168
168
  const active = getActiveElement();
169
169
  if (active instanceof Element) {
@@ -178,6 +178,22 @@ function getRelativeFocusable(container, offset, options) {
178
178
  console.warn("Anchor (active) element not within container");
179
179
  return null;
180
180
  }
181
+ if (typeof composed !== "boolean") {
182
+ console.warn("Invalid composed. Fallback: false.");
183
+ composed = false;
184
+ }
185
+ if (typeof filter !== "undefined" && typeof filter !== "function") {
186
+ console.warn("Invalid filter. Fallback: no filter function (undefined).");
187
+ filter = void 0;
188
+ }
189
+ if (typeof include !== "undefined" && typeof include !== "function") {
190
+ console.warn("Invalid include. Fallback: no include function (undefined).");
191
+ include = void 0;
192
+ }
193
+ if (typeof wrap !== "boolean") {
194
+ console.warn("Invalid wrap. Fallback: false.");
195
+ wrap = false;
196
+ }
181
197
  const focusables = getFocusables(container, { composed, filter, include });
182
198
  const { length } = focusables;
183
199
  if (!length) {
@@ -409,7 +425,7 @@ function isUngroupedRadio(element) {
409
425
  * High-precision focus management utility with full composed tree support.
410
426
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
411
427
  *
412
- * @version 4.1.5
428
+ * @version 4.1.7
413
429
  * @author Yusuke Kamiyamane
414
430
  * @license MIT
415
431
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "power-focusable",
3
- "version": "4.1.5",
3
+ "version": "4.1.7",
4
4
  "description": "High-precision focus management utility with full composed tree support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",