@y14e/portal 1.2.26 → 1.2.27
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 +3 -3
- package/dist/index.bundle.cjs +12 -10
- package/dist/index.bundle.js +12 -10
- package/dist/index.cjs +12 -10
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -10
- package/package.json +1 -1
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.2.
|
|
16
|
+
import { createPortal } from 'https://esm.sh/@y14e/portal@1.2.27';
|
|
17
17
|
// or
|
|
18
|
-
import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.2.
|
|
18
|
+
import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.2.27/+esm';
|
|
19
19
|
// or
|
|
20
|
-
import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.2.
|
|
20
|
+
import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.2.27';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 📦 APIs
|
package/dist/index.bundle.cjs
CHANGED
|
@@ -426,17 +426,22 @@ var Portal = class {
|
|
|
426
426
|
this.#update();
|
|
427
427
|
this.#controller = new AbortController();
|
|
428
428
|
const { signal } = this.#controller;
|
|
429
|
-
|
|
430
|
-
|
|
429
|
+
[this.#entranceSentinel, this.#exitSentinel].forEach((sentinel) => {
|
|
430
|
+
sentinel.addEventListener("focus", this.#onFocus, { signal });
|
|
431
|
+
});
|
|
432
|
+
if (!(this.#host instanceof HTMLElement)) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
this.#host.addEventListener("keydown", this.#onKeyDown, { signal });
|
|
431
436
|
this.#host.setAttribute("data-portaled", "");
|
|
432
437
|
}
|
|
433
|
-
#
|
|
434
|
-
const
|
|
438
|
+
#onFocus = (event) => {
|
|
439
|
+
const sentinel = event.target;
|
|
435
440
|
const previous = event.relatedTarget;
|
|
436
441
|
if (!(previous instanceof Element)) {
|
|
437
442
|
return;
|
|
438
443
|
}
|
|
439
|
-
if (
|
|
444
|
+
if (sentinel === this.#entranceSentinel) {
|
|
440
445
|
if (this.#host.contains(previous)) {
|
|
441
446
|
this.#moveFocus("previous");
|
|
442
447
|
return;
|
|
@@ -452,7 +457,7 @@ var Portal = class {
|
|
|
452
457
|
});
|
|
453
458
|
next && focusElement(next);
|
|
454
459
|
}
|
|
455
|
-
} else
|
|
460
|
+
} else {
|
|
456
461
|
if (this.#host.contains(previous)) {
|
|
457
462
|
this.#moveFocus("next");
|
|
458
463
|
return;
|
|
@@ -479,9 +484,6 @@ var Portal = class {
|
|
|
479
484
|
if (!(active instanceof Element)) {
|
|
480
485
|
return;
|
|
481
486
|
}
|
|
482
|
-
if (!this.#host.contains(active)) {
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
487
|
this.#update();
|
|
486
488
|
const focusables = this.#getFocusables();
|
|
487
489
|
if (focusables.length) {
|
|
@@ -562,7 +564,7 @@ function containsComposed2(container, element) {
|
|
|
562
564
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
563
565
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
564
566
|
*
|
|
565
|
-
* @version 1.2.
|
|
567
|
+
* @version 1.2.27
|
|
566
568
|
* @author Yusuke Kamiyamane
|
|
567
569
|
* @license MIT
|
|
568
570
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.bundle.js
CHANGED
|
@@ -424,17 +424,22 @@ var Portal = class {
|
|
|
424
424
|
this.#update();
|
|
425
425
|
this.#controller = new AbortController();
|
|
426
426
|
const { signal } = this.#controller;
|
|
427
|
-
|
|
428
|
-
|
|
427
|
+
[this.#entranceSentinel, this.#exitSentinel].forEach((sentinel) => {
|
|
428
|
+
sentinel.addEventListener("focus", this.#onFocus, { signal });
|
|
429
|
+
});
|
|
430
|
+
if (!(this.#host instanceof HTMLElement)) {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
this.#host.addEventListener("keydown", this.#onKeyDown, { signal });
|
|
429
434
|
this.#host.setAttribute("data-portaled", "");
|
|
430
435
|
}
|
|
431
|
-
#
|
|
432
|
-
const
|
|
436
|
+
#onFocus = (event) => {
|
|
437
|
+
const sentinel = event.target;
|
|
433
438
|
const previous = event.relatedTarget;
|
|
434
439
|
if (!(previous instanceof Element)) {
|
|
435
440
|
return;
|
|
436
441
|
}
|
|
437
|
-
if (
|
|
442
|
+
if (sentinel === this.#entranceSentinel) {
|
|
438
443
|
if (this.#host.contains(previous)) {
|
|
439
444
|
this.#moveFocus("previous");
|
|
440
445
|
return;
|
|
@@ -450,7 +455,7 @@ var Portal = class {
|
|
|
450
455
|
});
|
|
451
456
|
next && focusElement(next);
|
|
452
457
|
}
|
|
453
|
-
} else
|
|
458
|
+
} else {
|
|
454
459
|
if (this.#host.contains(previous)) {
|
|
455
460
|
this.#moveFocus("next");
|
|
456
461
|
return;
|
|
@@ -477,9 +482,6 @@ var Portal = class {
|
|
|
477
482
|
if (!(active instanceof Element)) {
|
|
478
483
|
return;
|
|
479
484
|
}
|
|
480
|
-
if (!this.#host.contains(active)) {
|
|
481
|
-
return;
|
|
482
|
-
}
|
|
483
485
|
this.#update();
|
|
484
486
|
const focusables = this.#getFocusables();
|
|
485
487
|
if (focusables.length) {
|
|
@@ -560,7 +562,7 @@ function containsComposed2(container, element) {
|
|
|
560
562
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
561
563
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
562
564
|
*
|
|
563
|
-
* @version 1.2.
|
|
565
|
+
* @version 1.2.27
|
|
564
566
|
* @author Yusuke Kamiyamane
|
|
565
567
|
* @license MIT
|
|
566
568
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.cjs
CHANGED
|
@@ -69,17 +69,22 @@ var Portal = class {
|
|
|
69
69
|
this.#update();
|
|
70
70
|
this.#controller = new AbortController();
|
|
71
71
|
const { signal } = this.#controller;
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
[this.#entranceSentinel, this.#exitSentinel].forEach((sentinel) => {
|
|
73
|
+
sentinel.addEventListener("focus", this.#onFocus, { signal });
|
|
74
|
+
});
|
|
75
|
+
if (!(this.#host instanceof HTMLElement)) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.#host.addEventListener("keydown", this.#onKeyDown, { signal });
|
|
74
79
|
this.#host.setAttribute("data-portaled", "");
|
|
75
80
|
}
|
|
76
|
-
#
|
|
77
|
-
const
|
|
81
|
+
#onFocus = (event) => {
|
|
82
|
+
const sentinel = event.target;
|
|
78
83
|
const previous = event.relatedTarget;
|
|
79
84
|
if (!(previous instanceof Element)) {
|
|
80
85
|
return;
|
|
81
86
|
}
|
|
82
|
-
if (
|
|
87
|
+
if (sentinel === this.#entranceSentinel) {
|
|
83
88
|
if (this.#host.contains(previous)) {
|
|
84
89
|
this.#moveFocus("previous");
|
|
85
90
|
return;
|
|
@@ -95,7 +100,7 @@ var Portal = class {
|
|
|
95
100
|
});
|
|
96
101
|
next && powerFocusable.focusElement(next);
|
|
97
102
|
}
|
|
98
|
-
} else
|
|
103
|
+
} else {
|
|
99
104
|
if (this.#host.contains(previous)) {
|
|
100
105
|
this.#moveFocus("next");
|
|
101
106
|
return;
|
|
@@ -122,9 +127,6 @@ var Portal = class {
|
|
|
122
127
|
if (!(active instanceof Element)) {
|
|
123
128
|
return;
|
|
124
129
|
}
|
|
125
|
-
if (!this.#host.contains(active)) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
130
|
this.#update();
|
|
129
131
|
const focusables = this.#getFocusables();
|
|
130
132
|
if (focusables.length) {
|
|
@@ -205,7 +207,7 @@ function containsComposed(container, element) {
|
|
|
205
207
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
206
208
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
207
209
|
*
|
|
208
|
-
* @version 1.2.
|
|
210
|
+
* @version 1.2.27
|
|
209
211
|
* @author Yusuke Kamiyamane
|
|
210
212
|
* @license MIT
|
|
211
213
|
* @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.
|
|
6
|
+
* @version 1.2.27
|
|
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.
|
|
6
|
+
* @version 1.2.27
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -67,17 +67,22 @@ var Portal = class {
|
|
|
67
67
|
this.#update();
|
|
68
68
|
this.#controller = new AbortController();
|
|
69
69
|
const { signal } = this.#controller;
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
[this.#entranceSentinel, this.#exitSentinel].forEach((sentinel) => {
|
|
71
|
+
sentinel.addEventListener("focus", this.#onFocus, { signal });
|
|
72
|
+
});
|
|
73
|
+
if (!(this.#host instanceof HTMLElement)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this.#host.addEventListener("keydown", this.#onKeyDown, { signal });
|
|
72
77
|
this.#host.setAttribute("data-portaled", "");
|
|
73
78
|
}
|
|
74
|
-
#
|
|
75
|
-
const
|
|
79
|
+
#onFocus = (event) => {
|
|
80
|
+
const sentinel = event.target;
|
|
76
81
|
const previous = event.relatedTarget;
|
|
77
82
|
if (!(previous instanceof Element)) {
|
|
78
83
|
return;
|
|
79
84
|
}
|
|
80
|
-
if (
|
|
85
|
+
if (sentinel === this.#entranceSentinel) {
|
|
81
86
|
if (this.#host.contains(previous)) {
|
|
82
87
|
this.#moveFocus("previous");
|
|
83
88
|
return;
|
|
@@ -93,7 +98,7 @@ var Portal = class {
|
|
|
93
98
|
});
|
|
94
99
|
next && focusElement(next);
|
|
95
100
|
}
|
|
96
|
-
} else
|
|
101
|
+
} else {
|
|
97
102
|
if (this.#host.contains(previous)) {
|
|
98
103
|
this.#moveFocus("next");
|
|
99
104
|
return;
|
|
@@ -120,9 +125,6 @@ var Portal = class {
|
|
|
120
125
|
if (!(active instanceof Element)) {
|
|
121
126
|
return;
|
|
122
127
|
}
|
|
123
|
-
if (!this.#host.contains(active)) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
128
|
this.#update();
|
|
127
129
|
const focusables = this.#getFocusables();
|
|
128
130
|
if (focusables.length) {
|
|
@@ -203,7 +205,7 @@ function containsComposed(container, element) {
|
|
|
203
205
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
204
206
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
205
207
|
*
|
|
206
|
-
* @version 1.2.
|
|
208
|
+
* @version 1.2.27
|
|
207
209
|
* @author Yusuke Kamiyamane
|
|
208
210
|
* @license MIT
|
|
209
211
|
* @copyright Copyright (c) Yusuke Kamiyamane
|