@y14e/portal 1.2.0 → 1.2.1
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 +4 -0
- package/dist/index.cjs +8 -3
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -3
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -384,7 +384,7 @@ var Portal = class {
|
|
|
384
384
|
const focusables = this.#getFocusables();
|
|
385
385
|
if (!focusables.length) {
|
|
386
386
|
event.preventDefault();
|
|
387
|
-
(event.shiftKey
|
|
387
|
+
this.#focusSentinel(event.shiftKey);
|
|
388
388
|
return;
|
|
389
389
|
}
|
|
390
390
|
const index = focusables.indexOf(active);
|
|
@@ -396,7 +396,7 @@ var Portal = class {
|
|
|
396
396
|
if (focusable) {
|
|
397
397
|
focusElement(focusable);
|
|
398
398
|
} else {
|
|
399
|
-
(event.shiftKey
|
|
399
|
+
this.#focusSentinel(event.shiftKey);
|
|
400
400
|
}
|
|
401
401
|
};
|
|
402
402
|
#update() {
|
|
@@ -436,6 +436,11 @@ var Portal = class {
|
|
|
436
436
|
sentinel.style.cssText += VISUALLY_HIDDEN_CSS;
|
|
437
437
|
return sentinel;
|
|
438
438
|
}
|
|
439
|
+
#focusSentinel(isPrevious) {
|
|
440
|
+
requestAnimationFrame(
|
|
441
|
+
() => (isPrevious ? this.#entranceSentinel : this.#exitSentinel).focus()
|
|
442
|
+
);
|
|
443
|
+
}
|
|
439
444
|
#getFocusables() {
|
|
440
445
|
return getFocusables(this.#host, {
|
|
441
446
|
composed: true,
|
|
@@ -478,7 +483,7 @@ function getActiveElement2() {
|
|
|
478
483
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
479
484
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
480
485
|
*
|
|
481
|
-
* @version 1.2.
|
|
486
|
+
* @version 1.2.1
|
|
482
487
|
* @author Yusuke Kamiyamane
|
|
483
488
|
* @license MIT
|
|
484
489
|
* @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.1
|
|
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.1
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -382,7 +382,7 @@ var Portal = class {
|
|
|
382
382
|
const focusables = this.#getFocusables();
|
|
383
383
|
if (!focusables.length) {
|
|
384
384
|
event.preventDefault();
|
|
385
|
-
(event.shiftKey
|
|
385
|
+
this.#focusSentinel(event.shiftKey);
|
|
386
386
|
return;
|
|
387
387
|
}
|
|
388
388
|
const index = focusables.indexOf(active);
|
|
@@ -394,7 +394,7 @@ var Portal = class {
|
|
|
394
394
|
if (focusable) {
|
|
395
395
|
focusElement(focusable);
|
|
396
396
|
} else {
|
|
397
|
-
(event.shiftKey
|
|
397
|
+
this.#focusSentinel(event.shiftKey);
|
|
398
398
|
}
|
|
399
399
|
};
|
|
400
400
|
#update() {
|
|
@@ -434,6 +434,11 @@ var Portal = class {
|
|
|
434
434
|
sentinel.style.cssText += VISUALLY_HIDDEN_CSS;
|
|
435
435
|
return sentinel;
|
|
436
436
|
}
|
|
437
|
+
#focusSentinel(isPrevious) {
|
|
438
|
+
requestAnimationFrame(
|
|
439
|
+
() => (isPrevious ? this.#entranceSentinel : this.#exitSentinel).focus()
|
|
440
|
+
);
|
|
441
|
+
}
|
|
437
442
|
#getFocusables() {
|
|
438
443
|
return getFocusables(this.#host, {
|
|
439
444
|
composed: true,
|
|
@@ -476,7 +481,7 @@ function getActiveElement2() {
|
|
|
476
481
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
477
482
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
478
483
|
*
|
|
479
|
-
* @version 1.2.
|
|
484
|
+
* @version 1.2.1
|
|
480
485
|
* @author Yusuke Kamiyamane
|
|
481
486
|
* @license MIT
|
|
482
487
|
* @copyright Copyright (c) Yusuke Kamiyamane
|