@y14e/portal 1.3.5 → 1.3.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/README.md CHANGED
@@ -13,11 +13,11 @@ npm i @y14e/portal
13
13
  import { createPortal } from '@y14e/portal';
14
14
 
15
15
  // CDNs
16
- import { createPortal } from 'https://esm.sh/@y14e/portal@1.3.5';
16
+ import { createPortal } from 'https://esm.sh/@y14e/portal@1.3.7';
17
17
  // or
18
- import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.3.5/+esm';
18
+ import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.3.7/+esm';
19
19
  // or
20
- import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.3.5';
20
+ import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.3.7';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
@@ -3,33 +3,33 @@
3
3
  // node_modules/@y14e/attribute-utils/dist/index.js
4
4
  var snapshots = /* @__PURE__ */ new WeakMap();
5
5
  function restoreAttributes(element_or_elements) {
6
- for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
7
- const snapshot = snapshots.get(element);
6
+ for (const e of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
7
+ const snapshot = snapshots.get(e);
8
8
  if (!snapshot) {
9
9
  continue;
10
10
  }
11
- for (const [name, value] of snapshot.entries()) {
12
- value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
11
+ for (const [n, v] of snapshot.entries()) {
12
+ v === null ? e.removeAttribute(n) : e.setAttribute(n, v);
13
13
  }
14
- snapshots.delete(element);
14
+ snapshots.delete(e);
15
15
  }
16
16
  }
17
17
  function saveAttributes(element_or_elements, name_or_names) {
18
18
  const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
19
- (Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
20
- let snapshot = snapshots.get(element);
19
+ for (const e of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
20
+ let snapshot = snapshots.get(e);
21
21
  if (!snapshot) {
22
22
  snapshot = /* @__PURE__ */ new Map();
23
- snapshots.set(element, snapshot);
23
+ snapshots.set(e, snapshot);
24
24
  }
25
- names.forEach((name) => {
26
- snapshot.set(name, element.getAttribute(name));
27
- });
28
- });
25
+ for (const n of names) {
26
+ snapshot.set(n, e.getAttribute(n));
27
+ }
28
+ }
29
29
  }
30
30
 
31
31
  // node_modules/power-focusable/dist/index.js
32
- 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"])`;
32
+ 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"])';
33
33
  var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX = FOCUSABLE_SELECTOR.replace(
34
34
  /(,\s*)?\[tabindex="-1"\]/g,
35
35
  ""
@@ -53,31 +53,21 @@ function getFocusables(container = document.body, options = {}) {
53
53
  skipNegativeTabIndexCheck,
54
54
  skipVisibilityCheck
55
55
  }) || include?.(node)) {
56
- candidates[candidates.length] = node;
57
- }
58
- const children2 = composed ? getComposedChildren(node) : getChildren(node);
59
- for (let i = 0, l = children2.length; i < l; i++) {
60
- const child = children2[i];
61
- child && traverse2(child);
56
+ candidates.push(node);
62
57
  }
58
+ (composed ? getComposedChildren(node) : [...node.children]).map(traverse2);
63
59
  };
64
- const children = composed ? getComposedChildren(container) : getChildren(container);
65
- for (let i = 0, l = children.length; i < l; i++) {
66
- const child = children[i];
67
- child && traverse2(child);
68
- }
60
+ (composed ? getComposedChildren(container) : [...container.children]).map(
61
+ traverse2
62
+ );
69
63
  } else {
70
- const matches = container.querySelectorAll(
64
+ for (const m of container.querySelectorAll(
71
65
  skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
72
- );
73
- for (let i = 0, l = matches.length; i < l; i++) {
74
- const matched = matches[i];
75
- if (matched && isFocusable(matched, {
66
+ )) {
67
+ m && isFocusable(m, {
76
68
  skipNegativeTabIndexCheck,
77
69
  skipVisibilityCheck
78
- })) {
79
- candidates[candidates.length] = matched;
80
- }
70
+ }) && candidates.push(m);
81
71
  }
82
72
  }
83
73
  return normalizeRadioGroup(
@@ -193,74 +183,60 @@ function isDisabledDeep(element) {
193
183
  }
194
184
  function normalizeRadioGroup(elements) {
195
185
  let map = null;
196
- for (let i = 0, l = elements.length; i < l; i++) {
197
- const element = elements[i];
198
- if (!(element instanceof HTMLInputElement)) {
186
+ for (const e of elements) {
187
+ if (!(e instanceof HTMLInputElement)) {
199
188
  continue;
200
189
  }
201
- if (!isUngroupedRadio(element)) {
190
+ if (!isUngroupedRadio(e)) {
202
191
  continue;
203
192
  }
204
193
  if (!map) {
205
194
  map = /* @__PURE__ */ new Map();
206
195
  }
207
- const root = element.getRootNode();
208
- let value = map.get(root);
209
- if (!value) {
210
- value = /* @__PURE__ */ new Map();
211
- map.set(root, value);
196
+ const root = e.getRootNode();
197
+ let groups = map.get(root);
198
+ if (!groups) {
199
+ groups = /* @__PURE__ */ new Map();
200
+ map.set(root, groups);
212
201
  }
213
- let v = value.get(element.form);
214
- if (!v) {
215
- v = /* @__PURE__ */ new Map();
216
- value.set(element.form, v);
202
+ let group = groups.get(e.form);
203
+ if (!group) {
204
+ group = /* @__PURE__ */ new Map();
205
+ groups.set(e.form, group);
217
206
  }
218
- let vv = v.get(element.name);
219
- if (!vv) {
220
- vv = [];
221
- v.set(element.name, vv);
207
+ let radios = group.get(e.name);
208
+ if (!radios) {
209
+ radios = [];
210
+ group.set(e.name, radios);
222
211
  }
223
- vv[vv.length] = element;
212
+ radios.push(e);
224
213
  }
225
214
  if (!map) {
226
215
  return elements;
227
216
  }
228
217
  const placeholder = /* @__PURE__ */ new Set();
229
- for (const value of map.values()) {
230
- for (const v of value.values()) {
231
- for (const vv of v.values()) {
232
- const radio = vv.find((element) => element.checked) ?? vv[0];
218
+ for (const v of map.values()) {
219
+ for (const w of v.values()) {
220
+ for (const x of w.values()) {
221
+ const radio = x.find((r) => r.checked) ?? x[0];
233
222
  radio && placeholder.add(radio);
234
223
  }
235
224
  }
236
225
  }
237
- return elements.filter((element) => {
238
- if (!(element instanceof HTMLInputElement)) {
226
+ return elements.filter((e) => {
227
+ if (!(e instanceof HTMLInputElement)) {
239
228
  return true;
240
229
  }
241
- return !isUngroupedRadio(element) || placeholder.has(element);
230
+ return !isUngroupedRadio(e) || placeholder.has(e);
242
231
  });
243
232
  }
244
233
  function sortByTabIndex(elements) {
245
234
  const ordered = [];
246
235
  const natural = [];
247
- for (let i = 0, l = elements.length; i < l; i++) {
248
- const element = elements[i];
249
- if (element) {
250
- const target = getTabIndex(element) > 0 ? ordered : natural;
251
- target[target.length] = element;
252
- }
253
- }
254
- ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b));
255
- let count = 0;
256
- const sorted = new Array(ordered.length + natural.length);
257
- for (let i = 0, l = ordered.length; i < l; i++) {
258
- sorted[count++] = ordered[i];
259
- }
260
- for (let i = 0, l = natural.length; i < l; i++) {
261
- sorted[count++] = natural[i];
236
+ for (const e of elements) {
237
+ (getTabIndex(e) > 0 ? ordered : natural).push(e);
262
238
  }
263
- return sorted;
239
+ return ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b)).concat(natural);
264
240
  }
265
241
  function containsComposed(container, element) {
266
242
  let current = element;
@@ -275,7 +251,7 @@ function containsComposed(container, element) {
275
251
  }
276
252
  function getComposedChildren(node) {
277
253
  if (node instanceof ShadowRoot) {
278
- return getChildren(node);
254
+ return [...node.children];
279
255
  }
280
256
  if (!(node instanceof Element)) {
281
257
  return [];
@@ -287,9 +263,9 @@ function getComposedChildren(node) {
287
263
  }
288
264
  }
289
265
  if (node instanceof HTMLElement && node.shadowRoot?.mode === "open") {
290
- return getChildren(node.shadowRoot);
266
+ return [...node.shadowRoot.children];
291
267
  }
292
- return getChildren(node);
268
+ return [...node.children];
293
269
  }
294
270
  function focusElement(element) {
295
271
  "focus" in element && typeof element.focus === "function" && element.focus();
@@ -301,13 +277,6 @@ function getActiveElement() {
301
277
  }
302
278
  return current;
303
279
  }
304
- function getChildren(node) {
305
- const elements = [];
306
- for (let child = node.firstElementChild; child; child = child.nextElementSibling) {
307
- elements[elements.length] = child;
308
- }
309
- return elements;
310
- }
311
280
  function getTabIndex(element) {
312
281
  return "tabIndex" in element ? Number(element.tabIndex) : 0;
313
282
  }
@@ -381,7 +350,7 @@ function resolveOptions(options) {
381
350
  }
382
351
 
383
352
  // src/index.ts
384
- var VISUALLY_HIDDEN_CSS = `border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;`;
353
+ var VISUALLY_HIDDEN_CSS = "border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;";
385
354
  function createPortal(host, container = document.body, options = {}) {
386
355
  if (!(host instanceof Element)) {
387
356
  console.warn("Invalid host element");
@@ -443,9 +412,9 @@ var Portal = class {
443
412
  this.#update();
444
413
  this.#controller = new AbortController();
445
414
  const { signal } = this.#controller;
446
- [this.#entranceSentinel, this.#exitSentinel].forEach((sentinel) => {
447
- sentinel.addEventListener("focus", this.#onFocus, { signal });
448
- });
415
+ for (const s of [this.#entranceSentinel, this.#exitSentinel]) {
416
+ s.addEventListener("focus", this.#onFocus, { signal });
417
+ }
449
418
  this.#host.addEventListener("keydown", this.#onKeyDown, { signal });
450
419
  this.#host.setAttribute("data-portaled", "");
451
420
  }
@@ -503,17 +472,17 @@ var Portal = class {
503
472
  ...this.#getFocusables(),
504
473
  ...getFocusables(this.#host, { composed: true })
505
474
  ]);
506
- for (const focusable of this.#focusables) {
507
- if (!current.has(focusable)) {
508
- restoreAttributes(focusable);
509
- this.#focusables.delete(focusable);
475
+ for (const f of this.#focusables) {
476
+ if (!current.has(f)) {
477
+ restoreAttributes(f);
478
+ this.#focusables.delete(f);
510
479
  }
511
480
  }
512
- for (const focusable of current) {
513
- if (!this.#focusables.has(focusable)) {
514
- this.#focusables.add(focusable);
515
- saveAttributes(focusable, "tabindex");
516
- focusable.setAttribute("tabindex", "-1");
481
+ for (const f of current) {
482
+ if (!this.#focusables.has(f)) {
483
+ this.#focusables.add(f);
484
+ saveAttributes(f, "tabindex");
485
+ f.setAttribute("tabindex", "-1");
517
486
  }
518
487
  }
519
488
  }
@@ -568,7 +537,7 @@ function resolveOptions2(options) {
568
537
  * Lightweight DOM portal (teleport) utility with fully focus management.
569
538
  * Designed for accessible dialogs, menus, overlays, popovers.
570
539
  *
571
- * @version 1.3.5
540
+ * @version 1.3.7
572
541
  * @author Yusuke Kamiyamane
573
542
  * @license MIT
574
543
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -580,7 +549,7 @@ function resolveOptions2(options) {
580
549
  (**
581
550
  * Attribute Utils
582
551
  *
583
- * @version 2.0.8
552
+ * @version 2.0.11
584
553
  * @author Yusuke Kamiyamane
585
554
  * @license MIT
586
555
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -593,7 +562,7 @@ power-focusable/dist/index.js:
593
562
  * High-precision focus management utility with full composed tree support.
594
563
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
595
564
  *
596
- * @version 4.3.29
565
+ * @version 4.3.31
597
566
  * @author Yusuke Kamiyamane
598
567
  * @license MIT
599
568
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -1,33 +1,33 @@
1
1
  // node_modules/@y14e/attribute-utils/dist/index.js
2
2
  var snapshots = /* @__PURE__ */ new WeakMap();
3
3
  function restoreAttributes(element_or_elements) {
4
- for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
5
- const snapshot = snapshots.get(element);
4
+ for (const e of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
5
+ const snapshot = snapshots.get(e);
6
6
  if (!snapshot) {
7
7
  continue;
8
8
  }
9
- for (const [name, value] of snapshot.entries()) {
10
- value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
9
+ for (const [n, v] of snapshot.entries()) {
10
+ v === null ? e.removeAttribute(n) : e.setAttribute(n, v);
11
11
  }
12
- snapshots.delete(element);
12
+ snapshots.delete(e);
13
13
  }
14
14
  }
15
15
  function saveAttributes(element_or_elements, name_or_names) {
16
16
  const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
17
- (Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]).forEach((element) => {
18
- let snapshot = snapshots.get(element);
17
+ for (const e of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
18
+ let snapshot = snapshots.get(e);
19
19
  if (!snapshot) {
20
20
  snapshot = /* @__PURE__ */ new Map();
21
- snapshots.set(element, snapshot);
21
+ snapshots.set(e, snapshot);
22
22
  }
23
- names.forEach((name) => {
24
- snapshot.set(name, element.getAttribute(name));
25
- });
26
- });
23
+ for (const n of names) {
24
+ snapshot.set(n, e.getAttribute(n));
25
+ }
26
+ }
27
27
  }
28
28
 
29
29
  // node_modules/power-focusable/dist/index.js
30
- 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"])`;
30
+ 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"])';
31
31
  var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX = FOCUSABLE_SELECTOR.replace(
32
32
  /(,\s*)?\[tabindex="-1"\]/g,
33
33
  ""
@@ -51,31 +51,21 @@ function getFocusables(container = document.body, options = {}) {
51
51
  skipNegativeTabIndexCheck,
52
52
  skipVisibilityCheck
53
53
  }) || include?.(node)) {
54
- candidates[candidates.length] = node;
55
- }
56
- const children2 = composed ? getComposedChildren(node) : getChildren(node);
57
- for (let i = 0, l = children2.length; i < l; i++) {
58
- const child = children2[i];
59
- child && traverse2(child);
54
+ candidates.push(node);
60
55
  }
56
+ (composed ? getComposedChildren(node) : [...node.children]).map(traverse2);
61
57
  };
62
- const children = composed ? getComposedChildren(container) : getChildren(container);
63
- for (let i = 0, l = children.length; i < l; i++) {
64
- const child = children[i];
65
- child && traverse2(child);
66
- }
58
+ (composed ? getComposedChildren(container) : [...container.children]).map(
59
+ traverse2
60
+ );
67
61
  } else {
68
- const matches = container.querySelectorAll(
62
+ for (const m of container.querySelectorAll(
69
63
  skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
70
- );
71
- for (let i = 0, l = matches.length; i < l; i++) {
72
- const matched = matches[i];
73
- if (matched && isFocusable(matched, {
64
+ )) {
65
+ m && isFocusable(m, {
74
66
  skipNegativeTabIndexCheck,
75
67
  skipVisibilityCheck
76
- })) {
77
- candidates[candidates.length] = matched;
78
- }
68
+ }) && candidates.push(m);
79
69
  }
80
70
  }
81
71
  return normalizeRadioGroup(
@@ -191,74 +181,60 @@ function isDisabledDeep(element) {
191
181
  }
192
182
  function normalizeRadioGroup(elements) {
193
183
  let map = null;
194
- for (let i = 0, l = elements.length; i < l; i++) {
195
- const element = elements[i];
196
- if (!(element instanceof HTMLInputElement)) {
184
+ for (const e of elements) {
185
+ if (!(e instanceof HTMLInputElement)) {
197
186
  continue;
198
187
  }
199
- if (!isUngroupedRadio(element)) {
188
+ if (!isUngroupedRadio(e)) {
200
189
  continue;
201
190
  }
202
191
  if (!map) {
203
192
  map = /* @__PURE__ */ new Map();
204
193
  }
205
- const root = element.getRootNode();
206
- let value = map.get(root);
207
- if (!value) {
208
- value = /* @__PURE__ */ new Map();
209
- map.set(root, value);
194
+ const root = e.getRootNode();
195
+ let groups = map.get(root);
196
+ if (!groups) {
197
+ groups = /* @__PURE__ */ new Map();
198
+ map.set(root, groups);
210
199
  }
211
- let v = value.get(element.form);
212
- if (!v) {
213
- v = /* @__PURE__ */ new Map();
214
- value.set(element.form, v);
200
+ let group = groups.get(e.form);
201
+ if (!group) {
202
+ group = /* @__PURE__ */ new Map();
203
+ groups.set(e.form, group);
215
204
  }
216
- let vv = v.get(element.name);
217
- if (!vv) {
218
- vv = [];
219
- v.set(element.name, vv);
205
+ let radios = group.get(e.name);
206
+ if (!radios) {
207
+ radios = [];
208
+ group.set(e.name, radios);
220
209
  }
221
- vv[vv.length] = element;
210
+ radios.push(e);
222
211
  }
223
212
  if (!map) {
224
213
  return elements;
225
214
  }
226
215
  const placeholder = /* @__PURE__ */ new Set();
227
- for (const value of map.values()) {
228
- for (const v of value.values()) {
229
- for (const vv of v.values()) {
230
- const radio = vv.find((element) => element.checked) ?? vv[0];
216
+ for (const v of map.values()) {
217
+ for (const w of v.values()) {
218
+ for (const x of w.values()) {
219
+ const radio = x.find((r) => r.checked) ?? x[0];
231
220
  radio && placeholder.add(radio);
232
221
  }
233
222
  }
234
223
  }
235
- return elements.filter((element) => {
236
- if (!(element instanceof HTMLInputElement)) {
224
+ return elements.filter((e) => {
225
+ if (!(e instanceof HTMLInputElement)) {
237
226
  return true;
238
227
  }
239
- return !isUngroupedRadio(element) || placeholder.has(element);
228
+ return !isUngroupedRadio(e) || placeholder.has(e);
240
229
  });
241
230
  }
242
231
  function sortByTabIndex(elements) {
243
232
  const ordered = [];
244
233
  const natural = [];
245
- for (let i = 0, l = elements.length; i < l; i++) {
246
- const element = elements[i];
247
- if (element) {
248
- const target = getTabIndex(element) > 0 ? ordered : natural;
249
- target[target.length] = element;
250
- }
251
- }
252
- ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b));
253
- let count = 0;
254
- const sorted = new Array(ordered.length + natural.length);
255
- for (let i = 0, l = ordered.length; i < l; i++) {
256
- sorted[count++] = ordered[i];
257
- }
258
- for (let i = 0, l = natural.length; i < l; i++) {
259
- sorted[count++] = natural[i];
234
+ for (const e of elements) {
235
+ (getTabIndex(e) > 0 ? ordered : natural).push(e);
260
236
  }
261
- return sorted;
237
+ return ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b)).concat(natural);
262
238
  }
263
239
  function containsComposed(container, element) {
264
240
  let current = element;
@@ -273,7 +249,7 @@ function containsComposed(container, element) {
273
249
  }
274
250
  function getComposedChildren(node) {
275
251
  if (node instanceof ShadowRoot) {
276
- return getChildren(node);
252
+ return [...node.children];
277
253
  }
278
254
  if (!(node instanceof Element)) {
279
255
  return [];
@@ -285,9 +261,9 @@ function getComposedChildren(node) {
285
261
  }
286
262
  }
287
263
  if (node instanceof HTMLElement && node.shadowRoot?.mode === "open") {
288
- return getChildren(node.shadowRoot);
264
+ return [...node.shadowRoot.children];
289
265
  }
290
- return getChildren(node);
266
+ return [...node.children];
291
267
  }
292
268
  function focusElement(element) {
293
269
  "focus" in element && typeof element.focus === "function" && element.focus();
@@ -299,13 +275,6 @@ function getActiveElement() {
299
275
  }
300
276
  return current;
301
277
  }
302
- function getChildren(node) {
303
- const elements = [];
304
- for (let child = node.firstElementChild; child; child = child.nextElementSibling) {
305
- elements[elements.length] = child;
306
- }
307
- return elements;
308
- }
309
278
  function getTabIndex(element) {
310
279
  return "tabIndex" in element ? Number(element.tabIndex) : 0;
311
280
  }
@@ -379,7 +348,7 @@ function resolveOptions(options) {
379
348
  }
380
349
 
381
350
  // src/index.ts
382
- var VISUALLY_HIDDEN_CSS = `border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;`;
351
+ var VISUALLY_HIDDEN_CSS = "border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;";
383
352
  function createPortal(host, container = document.body, options = {}) {
384
353
  if (!(host instanceof Element)) {
385
354
  console.warn("Invalid host element");
@@ -441,9 +410,9 @@ var Portal = class {
441
410
  this.#update();
442
411
  this.#controller = new AbortController();
443
412
  const { signal } = this.#controller;
444
- [this.#entranceSentinel, this.#exitSentinel].forEach((sentinel) => {
445
- sentinel.addEventListener("focus", this.#onFocus, { signal });
446
- });
413
+ for (const s of [this.#entranceSentinel, this.#exitSentinel]) {
414
+ s.addEventListener("focus", this.#onFocus, { signal });
415
+ }
447
416
  this.#host.addEventListener("keydown", this.#onKeyDown, { signal });
448
417
  this.#host.setAttribute("data-portaled", "");
449
418
  }
@@ -501,17 +470,17 @@ var Portal = class {
501
470
  ...this.#getFocusables(),
502
471
  ...getFocusables(this.#host, { composed: true })
503
472
  ]);
504
- for (const focusable of this.#focusables) {
505
- if (!current.has(focusable)) {
506
- restoreAttributes(focusable);
507
- this.#focusables.delete(focusable);
473
+ for (const f of this.#focusables) {
474
+ if (!current.has(f)) {
475
+ restoreAttributes(f);
476
+ this.#focusables.delete(f);
508
477
  }
509
478
  }
510
- for (const focusable of current) {
511
- if (!this.#focusables.has(focusable)) {
512
- this.#focusables.add(focusable);
513
- saveAttributes(focusable, "tabindex");
514
- focusable.setAttribute("tabindex", "-1");
479
+ for (const f of current) {
480
+ if (!this.#focusables.has(f)) {
481
+ this.#focusables.add(f);
482
+ saveAttributes(f, "tabindex");
483
+ f.setAttribute("tabindex", "-1");
515
484
  }
516
485
  }
517
486
  }
@@ -566,7 +535,7 @@ function resolveOptions2(options) {
566
535
  * Lightweight DOM portal (teleport) utility with fully focus management.
567
536
  * Designed for accessible dialogs, menus, overlays, popovers.
568
537
  *
569
- * @version 1.3.5
538
+ * @version 1.3.7
570
539
  * @author Yusuke Kamiyamane
571
540
  * @license MIT
572
541
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -578,7 +547,7 @@ function resolveOptions2(options) {
578
547
  (**
579
548
  * Attribute Utils
580
549
  *
581
- * @version 2.0.8
550
+ * @version 2.0.11
582
551
  * @author Yusuke Kamiyamane
583
552
  * @license MIT
584
553
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -591,7 +560,7 @@ power-focusable/dist/index.js:
591
560
  * High-precision focus management utility with full composed tree support.
592
561
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
593
562
  *
594
- * @version 4.3.29
563
+ * @version 4.3.31
595
564
  * @author Yusuke Kamiyamane
596
565
  * @license MIT
597
566
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -25,7 +25,7 @@ var utils__namespace = /*#__PURE__*/_interopNamespace(utils);
25
25
  var pf__namespace = /*#__PURE__*/_interopNamespace(pf);
26
26
 
27
27
  // src/index.ts
28
- var VISUALLY_HIDDEN_CSS = `border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;`;
28
+ var VISUALLY_HIDDEN_CSS = "border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;";
29
29
  function createPortal(host, container = document.body, options = {}) {
30
30
  if (!(host instanceof Element)) {
31
31
  console.warn("Invalid host element");
@@ -87,9 +87,9 @@ var Portal = class {
87
87
  this.#update();
88
88
  this.#controller = new AbortController();
89
89
  const { signal } = this.#controller;
90
- [this.#entranceSentinel, this.#exitSentinel].forEach((sentinel) => {
91
- sentinel.addEventListener("focus", this.#onFocus, { signal });
92
- });
90
+ for (const s of [this.#entranceSentinel, this.#exitSentinel]) {
91
+ s.addEventListener("focus", this.#onFocus, { signal });
92
+ }
93
93
  this.#host.addEventListener("keydown", this.#onKeyDown, { signal });
94
94
  this.#host.setAttribute("data-portaled", "");
95
95
  }
@@ -147,17 +147,17 @@ var Portal = class {
147
147
  ...this.#getFocusables(),
148
148
  ...pf__namespace.getFocusables(this.#host, { composed: true })
149
149
  ]);
150
- for (const focusable of this.#focusables) {
151
- if (!current.has(focusable)) {
152
- utils__namespace.restoreAttributes(focusable);
153
- this.#focusables.delete(focusable);
150
+ for (const f of this.#focusables) {
151
+ if (!current.has(f)) {
152
+ utils__namespace.restoreAttributes(f);
153
+ this.#focusables.delete(f);
154
154
  }
155
155
  }
156
- for (const focusable of current) {
157
- if (!this.#focusables.has(focusable)) {
158
- this.#focusables.add(focusable);
159
- utils__namespace.saveAttributes(focusable, "tabindex");
160
- focusable.setAttribute("tabindex", "-1");
156
+ for (const f of current) {
157
+ if (!this.#focusables.has(f)) {
158
+ this.#focusables.add(f);
159
+ utils__namespace.saveAttributes(f, "tabindex");
160
+ f.setAttribute("tabindex", "-1");
161
161
  }
162
162
  }
163
163
  }
@@ -212,7 +212,7 @@ function resolveOptions(options) {
212
212
  * Lightweight DOM portal (teleport) utility with fully focus management.
213
213
  * Designed for accessible dialogs, menus, overlays, popovers.
214
214
  *
215
- * @version 1.3.5
215
+ * @version 1.3.7
216
216
  * @author Yusuke Kamiyamane
217
217
  * @license MIT
218
218
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Lightweight DOM portal (teleport) utility with fully focus management.
4
4
  * Designed for accessible dialogs, menus, overlays, popovers.
5
5
  *
6
- * @version 1.3.5
6
+ * @version 1.3.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
  * Lightweight DOM portal (teleport) utility with fully focus management.
4
4
  * Designed for accessible dialogs, menus, overlays, popovers.
5
5
  *
6
- * @version 1.3.5
6
+ * @version 1.3.7
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import * as utils from '@y14e/attribute-utils';
2
2
  import * as pf from 'power-focusable';
3
3
 
4
4
  // src/index.ts
5
- var VISUALLY_HIDDEN_CSS = `border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;`;
5
+ var VISUALLY_HIDDEN_CSS = "border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;";
6
6
  function createPortal(host, container = document.body, options = {}) {
7
7
  if (!(host instanceof Element)) {
8
8
  console.warn("Invalid host element");
@@ -64,9 +64,9 @@ var Portal = class {
64
64
  this.#update();
65
65
  this.#controller = new AbortController();
66
66
  const { signal } = this.#controller;
67
- [this.#entranceSentinel, this.#exitSentinel].forEach((sentinel) => {
68
- sentinel.addEventListener("focus", this.#onFocus, { signal });
69
- });
67
+ for (const s of [this.#entranceSentinel, this.#exitSentinel]) {
68
+ s.addEventListener("focus", this.#onFocus, { signal });
69
+ }
70
70
  this.#host.addEventListener("keydown", this.#onKeyDown, { signal });
71
71
  this.#host.setAttribute("data-portaled", "");
72
72
  }
@@ -124,17 +124,17 @@ var Portal = class {
124
124
  ...this.#getFocusables(),
125
125
  ...pf.getFocusables(this.#host, { composed: true })
126
126
  ]);
127
- for (const focusable of this.#focusables) {
128
- if (!current.has(focusable)) {
129
- utils.restoreAttributes(focusable);
130
- this.#focusables.delete(focusable);
127
+ for (const f of this.#focusables) {
128
+ if (!current.has(f)) {
129
+ utils.restoreAttributes(f);
130
+ this.#focusables.delete(f);
131
131
  }
132
132
  }
133
- for (const focusable of current) {
134
- if (!this.#focusables.has(focusable)) {
135
- this.#focusables.add(focusable);
136
- utils.saveAttributes(focusable, "tabindex");
137
- focusable.setAttribute("tabindex", "-1");
133
+ for (const f of current) {
134
+ if (!this.#focusables.has(f)) {
135
+ this.#focusables.add(f);
136
+ utils.saveAttributes(f, "tabindex");
137
+ f.setAttribute("tabindex", "-1");
138
138
  }
139
139
  }
140
140
  }
@@ -189,7 +189,7 @@ function resolveOptions(options) {
189
189
  * Lightweight DOM portal (teleport) utility with fully focus management.
190
190
  * Designed for accessible dialogs, menus, overlays, popovers.
191
191
  *
192
- * @version 1.3.5
192
+ * @version 1.3.7
193
193
  * @author Yusuke Kamiyamane
194
194
  * @license MIT
195
195
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/portal",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "Lightweight DOM portal (teleport) utility with fully focus management",
5
5
  "keywords": [
6
6
  "a11y",
@@ -46,10 +46,6 @@
46
46
  "lint": "tsc --noEmit",
47
47
  "prepublishOnly": "npm run build"
48
48
  },
49
- "dependencies": {
50
- "@y14e/attribute-utils": "^2.0.8",
51
- "power-focusable": "^4.3.29"
52
- },
53
49
  "devDependencies": {
54
50
  "bun-types": "latest",
55
51
  "tsup": "^8.0.0",
@@ -60,5 +56,9 @@
60
56
  },
61
57
  "allowScripts": {
62
58
  "esbuild": true
59
+ },
60
+ "dependencies": {
61
+ "@y14e/attribute-utils": "^2.0.11",
62
+ "power-focusable": "^4.3.31"
63
63
  }
64
64
  }