@y14e/portal 1.2.17 → 1.2.18

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.17';
13
+ import { createPortal } from '@y14e/portal@1.2.18';
14
14
 
15
15
  // CDNs
16
- import { createPortal } from 'https://esm.sh/@y14e/portal@1.2.17';
16
+ import { createPortal } from 'https://esm.sh/@y14e/portal@1.2.18';
17
17
  // or
18
- import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.2.17/+esm';
18
+ import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.2.18/+esm';
19
19
  // or
20
- import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.2.17';
20
+ import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.2.18';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
package/dist/index.cjs CHANGED
@@ -326,6 +326,9 @@ function getComposedChildren(node) {
326
326
  }
327
327
  return getChildren(node);
328
328
  }
329
+ function focusElement(element) {
330
+ "focus" in element && typeof element.focus === "function" && element.focus();
331
+ }
329
332
  function getActiveElement() {
330
333
  let current = document.activeElement;
331
334
  while (current?.shadowRoot?.activeElement) {
@@ -478,7 +481,7 @@ var Portal = class {
478
481
  if (key !== "Tab" || altKey || ctrlKey || metaKey) {
479
482
  return;
480
483
  }
481
- const active = getActiveElement2();
484
+ const active = getActiveElement();
482
485
  if (!(active instanceof Element)) {
483
486
  return;
484
487
  }
@@ -557,22 +560,12 @@ function containsComposed2(container, element) {
557
560
  }
558
561
  return false;
559
562
  }
560
- function focusElement(element) {
561
- "focus" in element && typeof element.focus === "function" && element.focus();
562
- }
563
- function getActiveElement2() {
564
- let current = document.activeElement;
565
- while (current?.shadowRoot?.activeElement) {
566
- current = current.shadowRoot.activeElement;
567
- }
568
- return current;
569
- }
570
563
  /**
571
564
  * Portal
572
565
  * Lightweight DOM portal (teleport) utility with fully focus management.
573
566
  * Designed for accessible dialogs, menus, overlays, popovers.
574
567
  *
575
- * @version 1.2.17
568
+ * @version 1.2.18
576
569
  * @author Yusuke Kamiyamane
577
570
  * @license MIT
578
571
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -606,3 +599,8 @@ power-focusable/dist/index.js:
606
599
  */
607
600
 
608
601
  exports.createPortal = createPortal;
602
+ exports.getFocusables = getFocusables;
603
+ exports.getNextFocusable = getNextFocusable;
604
+ exports.getPreviousFocusable = getPreviousFocusable;
605
+ exports.restoreAttributes = restoreAttributes;
606
+ exports.saveAttributes = saveAttributes;
package/dist/index.d.cts CHANGED
@@ -1,14 +1,18 @@
1
+ export { restoreAttributes, saveAttributes } from '@y14e/attributes-utils';
2
+ export { getFocusables, getNextFocusable, getPreviousFocusable } from 'power-focusable';
3
+
1
4
  /**
2
5
  * Portal
3
6
  * Lightweight DOM portal (teleport) utility with fully focus management.
4
7
  * Designed for accessible dialogs, menus, overlays, popovers.
5
8
  *
6
- * @version 1.2.17
9
+ * @version 1.2.18
7
10
  * @author Yusuke Kamiyamane
8
11
  * @license MIT
9
12
  * @copyright Copyright (c) Yusuke Kamiyamane
10
13
  * @see {@link https://github.com/y14e/portal}
11
14
  */
15
+
12
16
  declare function createPortal(host: Element, container?: HTMLElement): () => void;
13
17
 
14
18
  export { createPortal };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,18 @@
1
+ export { restoreAttributes, saveAttributes } from '@y14e/attributes-utils';
2
+ export { getFocusables, getNextFocusable, getPreviousFocusable } from 'power-focusable';
3
+
1
4
  /**
2
5
  * Portal
3
6
  * Lightweight DOM portal (teleport) utility with fully focus management.
4
7
  * Designed for accessible dialogs, menus, overlays, popovers.
5
8
  *
6
- * @version 1.2.17
9
+ * @version 1.2.18
7
10
  * @author Yusuke Kamiyamane
8
11
  * @license MIT
9
12
  * @copyright Copyright (c) Yusuke Kamiyamane
10
13
  * @see {@link https://github.com/y14e/portal}
11
14
  */
15
+
12
16
  declare function createPortal(host: Element, container?: HTMLElement): () => void;
13
17
 
14
18
  export { createPortal };
package/dist/index.js CHANGED
@@ -324,6 +324,9 @@ function getComposedChildren(node) {
324
324
  }
325
325
  return getChildren(node);
326
326
  }
327
+ function focusElement(element) {
328
+ "focus" in element && typeof element.focus === "function" && element.focus();
329
+ }
327
330
  function getActiveElement() {
328
331
  let current = document.activeElement;
329
332
  while (current?.shadowRoot?.activeElement) {
@@ -476,7 +479,7 @@ var Portal = class {
476
479
  if (key !== "Tab" || altKey || ctrlKey || metaKey) {
477
480
  return;
478
481
  }
479
- const active = getActiveElement2();
482
+ const active = getActiveElement();
480
483
  if (!(active instanceof Element)) {
481
484
  return;
482
485
  }
@@ -555,22 +558,12 @@ function containsComposed2(container, element) {
555
558
  }
556
559
  return false;
557
560
  }
558
- function focusElement(element) {
559
- "focus" in element && typeof element.focus === "function" && element.focus();
560
- }
561
- function getActiveElement2() {
562
- let current = document.activeElement;
563
- while (current?.shadowRoot?.activeElement) {
564
- current = current.shadowRoot.activeElement;
565
- }
566
- return current;
567
- }
568
561
  /**
569
562
  * Portal
570
563
  * Lightweight DOM portal (teleport) utility with fully focus management.
571
564
  * Designed for accessible dialogs, menus, overlays, popovers.
572
565
  *
573
- * @version 1.2.17
566
+ * @version 1.2.18
574
567
  * @author Yusuke Kamiyamane
575
568
  * @license MIT
576
569
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -603,4 +596,4 @@ power-focusable/dist/index.js:
603
596
  *)
604
597
  */
605
598
 
606
- export { createPortal };
599
+ export { createPortal, getFocusables, getNextFocusable, getPreviousFocusable, restoreAttributes, saveAttributes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/portal",
3
- "version": "1.2.17",
3
+ "version": "1.2.18",
4
4
  "description": "Lightweight DOM portal (teleport) utility with fully focus management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -49,7 +49,7 @@
49
49
  "devDependencies": {
50
50
  "@y14e/attributes-utils": "^1.1.2",
51
51
  "bun-types": "latest",
52
- "power-focusable": "^4.3.3",
52
+ "power-focusable": "^4.3.4",
53
53
  "tsup": "^8.0.0",
54
54
  "typescript": "^5.6.0"
55
55
  },