@y14e/portal 1.2.11 → 1.2.12

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.11';
13
+ import { createPortal } from '@y14e/portal@1.2.12';
14
14
 
15
15
  // CDNs
16
- import { createPortal } from 'https://esm.sh/@y14e/portal@1.2.11';
16
+ import { createPortal } from 'https://esm.sh/@y14e/portal@1.2.12';
17
17
  // or
18
- import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.2.11/+esm';
18
+ import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.2.12/+esm';
19
19
  // or
20
- import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.2.11';
20
+ import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.2.12';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
package/dist/index.cjs CHANGED
@@ -452,15 +452,7 @@ var Portal = class {
452
452
  }
453
453
  this.#update();
454
454
  const first = [...this.#focusables][0];
455
- if (first) {
456
- focusElement(first);
457
- } else {
458
- const next = getNextFocusable(document.body, {
459
- anchor: this.#exitSentinel,
460
- composed: true
461
- });
462
- next && focusElement(next);
463
- }
455
+ first && focusElement(first);
464
456
  return;
465
457
  }
466
458
  if (current === this.#exitSentinel) {
@@ -470,15 +462,7 @@ var Portal = class {
470
462
  }
471
463
  this.#update();
472
464
  const last = [...this.#focusables].at(-1);
473
- if (last) {
474
- focusElement(last);
475
- } else {
476
- const previous = getPreviousFocusable(document.body, {
477
- anchor: this.#entranceSentinel,
478
- composed: true
479
- });
480
- previous && focusElement(previous);
481
- }
465
+ last && focusElement(last);
482
466
  return;
483
467
  }
484
468
  };
@@ -498,7 +482,7 @@ var Portal = class {
498
482
  const focusables = this.#getFocusables();
499
483
  if (!focusables.length) {
500
484
  event.preventDefault();
501
- this.#focusSentinel(shiftKey);
485
+ this.#moveFocus(shiftKey ? "previous" : "next");
502
486
  return;
503
487
  }
504
488
  const index = focusables.indexOf(active);
@@ -583,7 +567,7 @@ function getActiveElement2() {
583
567
  * Lightweight DOM portal (teleport) utility with fully focus management.
584
568
  * Designed for accessible dialogs, menus, overlays, popovers.
585
569
  *
586
- * @version 1.2.11
570
+ * @version 1.2.12
587
571
  * @author Yusuke Kamiyamane
588
572
  * @license MIT
589
573
  * @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.11
6
+ * @version 1.2.12
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.11
6
+ * @version 1.2.12
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -450,15 +450,7 @@ var Portal = class {
450
450
  }
451
451
  this.#update();
452
452
  const first = [...this.#focusables][0];
453
- if (first) {
454
- focusElement(first);
455
- } else {
456
- const next = getNextFocusable(document.body, {
457
- anchor: this.#exitSentinel,
458
- composed: true
459
- });
460
- next && focusElement(next);
461
- }
453
+ first && focusElement(first);
462
454
  return;
463
455
  }
464
456
  if (current === this.#exitSentinel) {
@@ -468,15 +460,7 @@ var Portal = class {
468
460
  }
469
461
  this.#update();
470
462
  const last = [...this.#focusables].at(-1);
471
- if (last) {
472
- focusElement(last);
473
- } else {
474
- const previous = getPreviousFocusable(document.body, {
475
- anchor: this.#entranceSentinel,
476
- composed: true
477
- });
478
- previous && focusElement(previous);
479
- }
463
+ last && focusElement(last);
480
464
  return;
481
465
  }
482
466
  };
@@ -496,7 +480,7 @@ var Portal = class {
496
480
  const focusables = this.#getFocusables();
497
481
  if (!focusables.length) {
498
482
  event.preventDefault();
499
- this.#focusSentinel(shiftKey);
483
+ this.#moveFocus(shiftKey ? "previous" : "next");
500
484
  return;
501
485
  }
502
486
  const index = focusables.indexOf(active);
@@ -581,7 +565,7 @@ function getActiveElement2() {
581
565
  * Lightweight DOM portal (teleport) utility with fully focus management.
582
566
  * Designed for accessible dialogs, menus, overlays, popovers.
583
567
  *
584
- * @version 1.2.11
568
+ * @version 1.2.12
585
569
  * @author Yusuke Kamiyamane
586
570
  * @license MIT
587
571
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/portal",
3
- "version": "1.2.11",
3
+ "version": "1.2.12",
4
4
  "description": "Lightweight DOM portal (teleport) utility with fully focus management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",