@y14e/portal 1.2.6 → 1.2.8

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/dist/index.cjs CHANGED
@@ -9,11 +9,7 @@ function restoreAttributes(elements) {
9
9
  continue;
10
10
  }
11
11
  for (const [attribute, value] of snapshot.entries()) {
12
- if (value === null) {
13
- element.removeAttribute(attribute);
14
- } else {
15
- element.setAttribute(attribute, value);
16
- }
12
+ value === null ? element.removeAttribute(attribute) : element.setAttribute(attribute, value);
17
13
  }
18
14
  snapshots.delete(element);
19
15
  }
@@ -40,15 +36,19 @@ function getFocusables(container = document.body, options = {}) {
40
36
  }
41
37
  let { composed = false, filter, include } = options;
42
38
  if (typeof composed !== "boolean") {
43
- console.warn("Invalid composed. Fallback: false.");
39
+ console.warn("Invalid composed option. Fallback: false.");
44
40
  composed = false;
45
41
  }
46
42
  if (typeof filter !== "undefined" && typeof filter !== "function") {
47
- console.warn("Invalid filter. Fallback: no filter function (undefined).");
43
+ console.warn(
44
+ "Invalid filter function. Fallback: no filter function (undefined)."
45
+ );
48
46
  filter = void 0;
49
47
  }
50
48
  if (typeof include !== "undefined" && typeof include !== "function") {
51
- console.warn("Invalid include. Fallback: no include function (undefined).");
49
+ console.warn(
50
+ "Invalid include function. Fallback: no include function (undefined)."
51
+ );
52
52
  include = void 0;
53
53
  }
54
54
  const elements = [];
@@ -143,19 +143,23 @@ function getRelativeFocusable(container, offset, options) {
143
143
  return null;
144
144
  }
145
145
  if (typeof composed !== "boolean") {
146
- console.warn("Invalid composed. Fallback: false.");
146
+ console.warn("Invalid composed option. Fallback: false.");
147
147
  composed = false;
148
148
  }
149
149
  if (typeof filter !== "undefined" && typeof filter !== "function") {
150
- console.warn("Invalid filter. Fallback: no filter function (undefined).");
150
+ console.warn(
151
+ "Invalid filter function. Fallback: no filter function (undefined)."
152
+ );
151
153
  filter = void 0;
152
154
  }
153
155
  if (typeof include !== "undefined" && typeof include !== "function") {
154
- console.warn("Invalid include. Fallback: no include function (undefined).");
156
+ console.warn(
157
+ "Invalid include function. Fallback: no include function (undefined)."
158
+ );
155
159
  include = void 0;
156
160
  }
157
161
  if (typeof wrap !== "boolean") {
158
- console.warn("Invalid wrap. Fallback: false.");
162
+ console.warn("Invalid wrap option. Fallback: false.");
159
163
  wrap = false;
160
164
  }
161
165
  const focusables = getFocusables(container, { composed, filter, include });
@@ -447,18 +451,16 @@ var Portal = class {
447
451
  if (current.has(focusable)) {
448
452
  continue;
449
453
  }
450
- if (focusable.isConnected) {
451
- restoreAttributes([focusable]);
452
- }
454
+ focusable.isConnected && restoreAttributes([focusable]);
453
455
  this.#focusables.delete(focusable);
454
456
  }
455
- for (const c of current) {
456
- if (this.#focusables.has(c)) {
457
+ for (const focusable of current) {
458
+ if (this.#focusables.has(focusable)) {
457
459
  continue;
458
460
  }
459
- this.#focusables.add(c);
460
- saveAttributes([c], ["tabindex"]);
461
- c.setAttribute("tabindex", "-1");
461
+ this.#focusables.add(focusable);
462
+ saveAttributes([focusable], ["tabindex"]);
463
+ focusable.setAttribute("tabindex", "-1");
462
464
  }
463
465
  }
464
466
  #createSentinel() {
@@ -514,7 +516,7 @@ function getActiveElement2() {
514
516
  * Lightweight DOM portal (teleport) utility with fully focus management.
515
517
  * Designed for accessible dialogs, menus, overlays, popovers.
516
518
  *
517
- * @version 1.2.6
519
+ * @version 1.2.8
518
520
  * @author Yusuke Kamiyamane
519
521
  * @license MIT
520
522
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -526,7 +528,7 @@ function getActiveElement2() {
526
528
  (**
527
529
  * Attributes Utils
528
530
  *
529
- * @version 1.0.2
531
+ * @version 1.0.5
530
532
  * @author Yusuke Kamiyamane
531
533
  * @license MIT
532
534
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -539,7 +541,7 @@ power-focusable/dist/index.js:
539
541
  * High-precision focus management utility with full composed tree support.
540
542
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
541
543
  *
542
- * @version 4.1.7
544
+ * @version 4.1.8
543
545
  * @author Yusuke Kamiyamane
544
546
  * @license MIT
545
547
  * @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
6
+ * @version 1.2.8
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
6
+ * @version 1.2.8
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -7,11 +7,7 @@ function restoreAttributes(elements) {
7
7
  continue;
8
8
  }
9
9
  for (const [attribute, value] of snapshot.entries()) {
10
- if (value === null) {
11
- element.removeAttribute(attribute);
12
- } else {
13
- element.setAttribute(attribute, value);
14
- }
10
+ value === null ? element.removeAttribute(attribute) : element.setAttribute(attribute, value);
15
11
  }
16
12
  snapshots.delete(element);
17
13
  }
@@ -38,15 +34,19 @@ function getFocusables(container = document.body, options = {}) {
38
34
  }
39
35
  let { composed = false, filter, include } = options;
40
36
  if (typeof composed !== "boolean") {
41
- console.warn("Invalid composed. Fallback: false.");
37
+ console.warn("Invalid composed option. Fallback: false.");
42
38
  composed = false;
43
39
  }
44
40
  if (typeof filter !== "undefined" && typeof filter !== "function") {
45
- console.warn("Invalid filter. Fallback: no filter function (undefined).");
41
+ console.warn(
42
+ "Invalid filter function. Fallback: no filter function (undefined)."
43
+ );
46
44
  filter = void 0;
47
45
  }
48
46
  if (typeof include !== "undefined" && typeof include !== "function") {
49
- console.warn("Invalid include. Fallback: no include function (undefined).");
47
+ console.warn(
48
+ "Invalid include function. Fallback: no include function (undefined)."
49
+ );
50
50
  include = void 0;
51
51
  }
52
52
  const elements = [];
@@ -141,19 +141,23 @@ function getRelativeFocusable(container, offset, options) {
141
141
  return null;
142
142
  }
143
143
  if (typeof composed !== "boolean") {
144
- console.warn("Invalid composed. Fallback: false.");
144
+ console.warn("Invalid composed option. Fallback: false.");
145
145
  composed = false;
146
146
  }
147
147
  if (typeof filter !== "undefined" && typeof filter !== "function") {
148
- console.warn("Invalid filter. Fallback: no filter function (undefined).");
148
+ console.warn(
149
+ "Invalid filter function. Fallback: no filter function (undefined)."
150
+ );
149
151
  filter = void 0;
150
152
  }
151
153
  if (typeof include !== "undefined" && typeof include !== "function") {
152
- console.warn("Invalid include. Fallback: no include function (undefined).");
154
+ console.warn(
155
+ "Invalid include function. Fallback: no include function (undefined)."
156
+ );
153
157
  include = void 0;
154
158
  }
155
159
  if (typeof wrap !== "boolean") {
156
- console.warn("Invalid wrap. Fallback: false.");
160
+ console.warn("Invalid wrap option. Fallback: false.");
157
161
  wrap = false;
158
162
  }
159
163
  const focusables = getFocusables(container, { composed, filter, include });
@@ -445,18 +449,16 @@ var Portal = class {
445
449
  if (current.has(focusable)) {
446
450
  continue;
447
451
  }
448
- if (focusable.isConnected) {
449
- restoreAttributes([focusable]);
450
- }
452
+ focusable.isConnected && restoreAttributes([focusable]);
451
453
  this.#focusables.delete(focusable);
452
454
  }
453
- for (const c of current) {
454
- if (this.#focusables.has(c)) {
455
+ for (const focusable of current) {
456
+ if (this.#focusables.has(focusable)) {
455
457
  continue;
456
458
  }
457
- this.#focusables.add(c);
458
- saveAttributes([c], ["tabindex"]);
459
- c.setAttribute("tabindex", "-1");
459
+ this.#focusables.add(focusable);
460
+ saveAttributes([focusable], ["tabindex"]);
461
+ focusable.setAttribute("tabindex", "-1");
460
462
  }
461
463
  }
462
464
  #createSentinel() {
@@ -512,7 +514,7 @@ function getActiveElement2() {
512
514
  * Lightweight DOM portal (teleport) utility with fully focus management.
513
515
  * Designed for accessible dialogs, menus, overlays, popovers.
514
516
  *
515
- * @version 1.2.6
517
+ * @version 1.2.8
516
518
  * @author Yusuke Kamiyamane
517
519
  * @license MIT
518
520
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -524,7 +526,7 @@ function getActiveElement2() {
524
526
  (**
525
527
  * Attributes Utils
526
528
  *
527
- * @version 1.0.2
529
+ * @version 1.0.5
528
530
  * @author Yusuke Kamiyamane
529
531
  * @license MIT
530
532
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -537,7 +539,7 @@ power-focusable/dist/index.js:
537
539
  * High-precision focus management utility with full composed tree support.
538
540
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
539
541
  *
540
- * @version 4.1.7
542
+ * @version 4.1.8
541
543
  * @author Yusuke Kamiyamane
542
544
  * @license MIT
543
545
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/portal",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "description": "Lightweight DOM portal (teleport) utility with fully focus management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -47,9 +47,9 @@
47
47
  },
48
48
  "homepage": "https://github.com/y14e/portal#readme",
49
49
  "devDependencies": {
50
- "@y14e/attributes-utils": "^1.0.2",
50
+ "@y14e/attributes-utils": "^1.0.5",
51
51
  "bun-types": "latest",
52
- "power-focusable": "^4.1.7",
52
+ "power-focusable": "^4.1.8",
53
53
  "tsup": "^8.0.0",
54
54
  "typescript": "^5.6.0"
55
55
  },