@y14e/portal 1.2.20 → 1.2.22

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
@@ -10,14 +10,14 @@ npm i @y14e/portal
10
10
 
11
11
  ```ts
12
12
  // npm
13
- import { createPortal } from '@y14e/portal@1.2.20';
13
+ import { createPortal } from '@y14e/portal@1.2.22';
14
14
 
15
15
  // CDNs
16
- import { createPortal } from 'https://esm.sh/@y14e/portal@1.2.20';
16
+ import { createPortal } from 'https://esm.sh/@y14e/portal@1.2.22';
17
17
  // or
18
- import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.2.20/+esm';
18
+ import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.2.22/+esm';
19
19
  // or
20
- import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.2.20';
20
+ import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.2.22';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
@@ -388,7 +388,6 @@ var Portal = class {
388
388
  #exitSentinel;
389
389
  #focusables = /* @__PURE__ */ new Set();
390
390
  #controller = null;
391
- #timer;
392
391
  #isDestroyed = false;
393
392
  constructor(host, container) {
394
393
  this.#host = host;
@@ -408,10 +407,6 @@ var Portal = class {
408
407
  this.#isDestroyed = true;
409
408
  this.#controller?.abort();
410
409
  this.#controller = null;
411
- if (this.#timer !== void 0) {
412
- cancelAnimationFrame(this.#timer);
413
- this.#timer = void 0;
414
- }
415
410
  restoreAttributes([...this.#focusables]);
416
411
  this.#focusables.clear();
417
412
  this.#exitSentinel.after(this.#host);
@@ -438,12 +433,12 @@ var Portal = class {
438
433
  }
439
434
  #onFocusIn = (event) => {
440
435
  const current = event.target;
441
- const before = event.relatedTarget;
442
- if (!(before instanceof Element)) {
436
+ const previous = event.relatedTarget;
437
+ if (!(previous instanceof Element)) {
443
438
  return;
444
439
  }
445
440
  if (current === this.#entranceSentinel) {
446
- if (this.#host.contains(before)) {
441
+ if (this.#host.contains(previous)) {
447
442
  this.#moveFocus("previous");
448
443
  return;
449
444
  }
@@ -459,7 +454,7 @@ var Portal = class {
459
454
  next && focusElement(next);
460
455
  }
461
456
  } else if (current === this.#exitSentinel) {
462
- if (this.#host.contains(before)) {
457
+ if (this.#host.contains(previous)) {
463
458
  this.#moveFocus("next");
464
459
  return;
465
460
  }
@@ -468,11 +463,11 @@ var Portal = class {
468
463
  if (last) {
469
464
  focusElement(last);
470
465
  } else {
471
- const previous = getPreviousFocusable(document.body, {
466
+ const previous2 = getPreviousFocusable(document.body, {
472
467
  anchor: this.#entranceSentinel,
473
468
  composed: true
474
469
  });
475
- previous && focusElement(previous);
470
+ previous2 && focusElement(previous2);
476
471
  }
477
472
  }
478
473
  };
@@ -530,10 +525,7 @@ var Portal = class {
530
525
  return sentinel;
531
526
  }
532
527
  #focusSentinel(isPrevious) {
533
- this.#timer && cancelAnimationFrame(this.#timer);
534
- this.#timer = requestAnimationFrame(
535
- () => (isPrevious ? this.#entranceSentinel : this.#exitSentinel).focus()
536
- );
528
+ (isPrevious ? this.#entranceSentinel : this.#exitSentinel).focus();
537
529
  }
538
530
  #getFocusables() {
539
531
  return getFocusables(this.#host, {
@@ -565,7 +557,7 @@ function containsComposed2(container, element) {
565
557
  * Lightweight DOM portal (teleport) utility with fully focus management.
566
558
  * Designed for accessible dialogs, menus, overlays, popovers.
567
559
  *
568
- * @version 1.2.20
560
+ * @version 1.2.22
569
561
  * @author Yusuke Kamiyamane
570
562
  * @license MIT
571
563
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -386,7 +386,6 @@ var Portal = class {
386
386
  #exitSentinel;
387
387
  #focusables = /* @__PURE__ */ new Set();
388
388
  #controller = null;
389
- #timer;
390
389
  #isDestroyed = false;
391
390
  constructor(host, container) {
392
391
  this.#host = host;
@@ -406,10 +405,6 @@ var Portal = class {
406
405
  this.#isDestroyed = true;
407
406
  this.#controller?.abort();
408
407
  this.#controller = null;
409
- if (this.#timer !== void 0) {
410
- cancelAnimationFrame(this.#timer);
411
- this.#timer = void 0;
412
- }
413
408
  restoreAttributes([...this.#focusables]);
414
409
  this.#focusables.clear();
415
410
  this.#exitSentinel.after(this.#host);
@@ -436,12 +431,12 @@ var Portal = class {
436
431
  }
437
432
  #onFocusIn = (event) => {
438
433
  const current = event.target;
439
- const before = event.relatedTarget;
440
- if (!(before instanceof Element)) {
434
+ const previous = event.relatedTarget;
435
+ if (!(previous instanceof Element)) {
441
436
  return;
442
437
  }
443
438
  if (current === this.#entranceSentinel) {
444
- if (this.#host.contains(before)) {
439
+ if (this.#host.contains(previous)) {
445
440
  this.#moveFocus("previous");
446
441
  return;
447
442
  }
@@ -457,7 +452,7 @@ var Portal = class {
457
452
  next && focusElement(next);
458
453
  }
459
454
  } else if (current === this.#exitSentinel) {
460
- if (this.#host.contains(before)) {
455
+ if (this.#host.contains(previous)) {
461
456
  this.#moveFocus("next");
462
457
  return;
463
458
  }
@@ -466,11 +461,11 @@ var Portal = class {
466
461
  if (last) {
467
462
  focusElement(last);
468
463
  } else {
469
- const previous = getPreviousFocusable(document.body, {
464
+ const previous2 = getPreviousFocusable(document.body, {
470
465
  anchor: this.#entranceSentinel,
471
466
  composed: true
472
467
  });
473
- previous && focusElement(previous);
468
+ previous2 && focusElement(previous2);
474
469
  }
475
470
  }
476
471
  };
@@ -528,10 +523,7 @@ var Portal = class {
528
523
  return sentinel;
529
524
  }
530
525
  #focusSentinel(isPrevious) {
531
- this.#timer && cancelAnimationFrame(this.#timer);
532
- this.#timer = requestAnimationFrame(
533
- () => (isPrevious ? this.#entranceSentinel : this.#exitSentinel).focus()
534
- );
526
+ (isPrevious ? this.#entranceSentinel : this.#exitSentinel).focus();
535
527
  }
536
528
  #getFocusables() {
537
529
  return getFocusables(this.#host, {
@@ -563,7 +555,7 @@ function containsComposed2(container, element) {
563
555
  * Lightweight DOM portal (teleport) utility with fully focus management.
564
556
  * Designed for accessible dialogs, menus, overlays, popovers.
565
557
  *
566
- * @version 1.2.20
558
+ * @version 1.2.22
567
559
  * @author Yusuke Kamiyamane
568
560
  * @license MIT
569
561
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -31,7 +31,6 @@ var Portal = class {
31
31
  #exitSentinel;
32
32
  #focusables = /* @__PURE__ */ new Set();
33
33
  #controller = null;
34
- #timer;
35
34
  #isDestroyed = false;
36
35
  constructor(host, container) {
37
36
  this.#host = host;
@@ -51,10 +50,6 @@ var Portal = class {
51
50
  this.#isDestroyed = true;
52
51
  this.#controller?.abort();
53
52
  this.#controller = null;
54
- if (this.#timer !== void 0) {
55
- cancelAnimationFrame(this.#timer);
56
- this.#timer = void 0;
57
- }
58
53
  attributesUtils.restoreAttributes([...this.#focusables]);
59
54
  this.#focusables.clear();
60
55
  this.#exitSentinel.after(this.#host);
@@ -81,12 +76,12 @@ var Portal = class {
81
76
  }
82
77
  #onFocusIn = (event) => {
83
78
  const current = event.target;
84
- const before = event.relatedTarget;
85
- if (!(before instanceof Element)) {
79
+ const previous = event.relatedTarget;
80
+ if (!(previous instanceof Element)) {
86
81
  return;
87
82
  }
88
83
  if (current === this.#entranceSentinel) {
89
- if (this.#host.contains(before)) {
84
+ if (this.#host.contains(previous)) {
90
85
  this.#moveFocus("previous");
91
86
  return;
92
87
  }
@@ -102,7 +97,7 @@ var Portal = class {
102
97
  next && powerFocusable.focusElement(next);
103
98
  }
104
99
  } else if (current === this.#exitSentinel) {
105
- if (this.#host.contains(before)) {
100
+ if (this.#host.contains(previous)) {
106
101
  this.#moveFocus("next");
107
102
  return;
108
103
  }
@@ -111,11 +106,11 @@ var Portal = class {
111
106
  if (last) {
112
107
  powerFocusable.focusElement(last);
113
108
  } else {
114
- const previous = powerFocusable.getPreviousFocusable(document.body, {
109
+ const previous2 = powerFocusable.getPreviousFocusable(document.body, {
115
110
  anchor: this.#entranceSentinel,
116
111
  composed: true
117
112
  });
118
- previous && powerFocusable.focusElement(previous);
113
+ previous2 && powerFocusable.focusElement(previous2);
119
114
  }
120
115
  }
121
116
  };
@@ -173,10 +168,7 @@ var Portal = class {
173
168
  return sentinel;
174
169
  }
175
170
  #focusSentinel(isPrevious) {
176
- this.#timer && cancelAnimationFrame(this.#timer);
177
- this.#timer = requestAnimationFrame(
178
- () => (isPrevious ? this.#entranceSentinel : this.#exitSentinel).focus()
179
- );
171
+ (isPrevious ? this.#entranceSentinel : this.#exitSentinel).focus();
180
172
  }
181
173
  #getFocusables() {
182
174
  return powerFocusable.getFocusables(this.#host, {
@@ -208,7 +200,7 @@ function containsComposed(container, element) {
208
200
  * Lightweight DOM portal (teleport) utility with fully focus management.
209
201
  * Designed for accessible dialogs, menus, overlays, popovers.
210
202
  *
211
- * @version 1.2.20
203
+ * @version 1.2.22
212
204
  * @author Yusuke Kamiyamane
213
205
  * @license MIT
214
206
  * @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.2.20
6
+ * @version 1.2.22
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.2.20
6
+ * @version 1.2.22
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -29,7 +29,6 @@ var Portal = class {
29
29
  #exitSentinel;
30
30
  #focusables = /* @__PURE__ */ new Set();
31
31
  #controller = null;
32
- #timer;
33
32
  #isDestroyed = false;
34
33
  constructor(host, container) {
35
34
  this.#host = host;
@@ -49,10 +48,6 @@ var Portal = class {
49
48
  this.#isDestroyed = true;
50
49
  this.#controller?.abort();
51
50
  this.#controller = null;
52
- if (this.#timer !== void 0) {
53
- cancelAnimationFrame(this.#timer);
54
- this.#timer = void 0;
55
- }
56
51
  restoreAttributes([...this.#focusables]);
57
52
  this.#focusables.clear();
58
53
  this.#exitSentinel.after(this.#host);
@@ -79,12 +74,12 @@ var Portal = class {
79
74
  }
80
75
  #onFocusIn = (event) => {
81
76
  const current = event.target;
82
- const before = event.relatedTarget;
83
- if (!(before instanceof Element)) {
77
+ const previous = event.relatedTarget;
78
+ if (!(previous instanceof Element)) {
84
79
  return;
85
80
  }
86
81
  if (current === this.#entranceSentinel) {
87
- if (this.#host.contains(before)) {
82
+ if (this.#host.contains(previous)) {
88
83
  this.#moveFocus("previous");
89
84
  return;
90
85
  }
@@ -100,7 +95,7 @@ var Portal = class {
100
95
  next && focusElement(next);
101
96
  }
102
97
  } else if (current === this.#exitSentinel) {
103
- if (this.#host.contains(before)) {
98
+ if (this.#host.contains(previous)) {
104
99
  this.#moveFocus("next");
105
100
  return;
106
101
  }
@@ -109,11 +104,11 @@ var Portal = class {
109
104
  if (last) {
110
105
  focusElement(last);
111
106
  } else {
112
- const previous = getPreviousFocusable(document.body, {
107
+ const previous2 = getPreviousFocusable(document.body, {
113
108
  anchor: this.#entranceSentinel,
114
109
  composed: true
115
110
  });
116
- previous && focusElement(previous);
111
+ previous2 && focusElement(previous2);
117
112
  }
118
113
  }
119
114
  };
@@ -171,10 +166,7 @@ var Portal = class {
171
166
  return sentinel;
172
167
  }
173
168
  #focusSentinel(isPrevious) {
174
- this.#timer && cancelAnimationFrame(this.#timer);
175
- this.#timer = requestAnimationFrame(
176
- () => (isPrevious ? this.#entranceSentinel : this.#exitSentinel).focus()
177
- );
169
+ (isPrevious ? this.#entranceSentinel : this.#exitSentinel).focus();
178
170
  }
179
171
  #getFocusables() {
180
172
  return getFocusables(this.#host, {
@@ -206,7 +198,7 @@ function containsComposed(container, element) {
206
198
  * Lightweight DOM portal (teleport) utility with fully focus management.
207
199
  * Designed for accessible dialogs, menus, overlays, popovers.
208
200
  *
209
- * @version 1.2.20
201
+ * @version 1.2.22
210
202
  * @author Yusuke Kamiyamane
211
203
  * @license MIT
212
204
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/portal",
3
- "version": "1.2.20",
3
+ "version": "1.2.22",
4
4
  "description": "Lightweight DOM portal (teleport) utility with fully focus management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",