@y14e/portal 1.2.5 → 1.2.7
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 +9 -17
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -17
- package/package.json +2 -2
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
|
-
|
|
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
|
}
|
|
@@ -436,11 +432,7 @@ var Portal = class {
|
|
|
436
432
|
}
|
|
437
433
|
event.preventDefault();
|
|
438
434
|
const focusable = focusables[index + (shiftKey ? -1 : 1)];
|
|
439
|
-
|
|
440
|
-
focusElement(focusable);
|
|
441
|
-
} else {
|
|
442
|
-
this.#focusSentinel(shiftKey);
|
|
443
|
-
}
|
|
435
|
+
focusable ? focusElement(focusable) : this.#focusSentinel(shiftKey);
|
|
444
436
|
};
|
|
445
437
|
#update() {
|
|
446
438
|
const current = /* @__PURE__ */ new Set([
|
|
@@ -456,13 +448,13 @@ var Portal = class {
|
|
|
456
448
|
}
|
|
457
449
|
this.#focusables.delete(focusable);
|
|
458
450
|
}
|
|
459
|
-
for (const
|
|
460
|
-
if (this.#focusables.has(
|
|
451
|
+
for (const focusable of current) {
|
|
452
|
+
if (this.#focusables.has(focusable)) {
|
|
461
453
|
continue;
|
|
462
454
|
}
|
|
463
|
-
this.#focusables.add(
|
|
464
|
-
saveAttributes([
|
|
465
|
-
|
|
455
|
+
this.#focusables.add(focusable);
|
|
456
|
+
saveAttributes([focusable], ["tabindex"]);
|
|
457
|
+
focusable.setAttribute("tabindex", "-1");
|
|
466
458
|
}
|
|
467
459
|
}
|
|
468
460
|
#createSentinel() {
|
|
@@ -518,7 +510,7 @@ function getActiveElement2() {
|
|
|
518
510
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
519
511
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
520
512
|
*
|
|
521
|
-
* @version 1.2.
|
|
513
|
+
* @version 1.2.7
|
|
522
514
|
* @author Yusuke Kamiyamane
|
|
523
515
|
* @license MIT
|
|
524
516
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -530,7 +522,7 @@ function getActiveElement2() {
|
|
|
530
522
|
(**
|
|
531
523
|
* Attributes Utils
|
|
532
524
|
*
|
|
533
|
-
* @version 1.0.
|
|
525
|
+
* @version 1.0.5
|
|
534
526
|
* @author Yusuke Kamiyamane
|
|
535
527
|
* @license MIT
|
|
536
528
|
* @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.7
|
|
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.7
|
|
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
|
-
|
|
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
|
}
|
|
@@ -434,11 +430,7 @@ var Portal = class {
|
|
|
434
430
|
}
|
|
435
431
|
event.preventDefault();
|
|
436
432
|
const focusable = focusables[index + (shiftKey ? -1 : 1)];
|
|
437
|
-
|
|
438
|
-
focusElement(focusable);
|
|
439
|
-
} else {
|
|
440
|
-
this.#focusSentinel(shiftKey);
|
|
441
|
-
}
|
|
433
|
+
focusable ? focusElement(focusable) : this.#focusSentinel(shiftKey);
|
|
442
434
|
};
|
|
443
435
|
#update() {
|
|
444
436
|
const current = /* @__PURE__ */ new Set([
|
|
@@ -454,13 +446,13 @@ var Portal = class {
|
|
|
454
446
|
}
|
|
455
447
|
this.#focusables.delete(focusable);
|
|
456
448
|
}
|
|
457
|
-
for (const
|
|
458
|
-
if (this.#focusables.has(
|
|
449
|
+
for (const focusable of current) {
|
|
450
|
+
if (this.#focusables.has(focusable)) {
|
|
459
451
|
continue;
|
|
460
452
|
}
|
|
461
|
-
this.#focusables.add(
|
|
462
|
-
saveAttributes([
|
|
463
|
-
|
|
453
|
+
this.#focusables.add(focusable);
|
|
454
|
+
saveAttributes([focusable], ["tabindex"]);
|
|
455
|
+
focusable.setAttribute("tabindex", "-1");
|
|
464
456
|
}
|
|
465
457
|
}
|
|
466
458
|
#createSentinel() {
|
|
@@ -516,7 +508,7 @@ function getActiveElement2() {
|
|
|
516
508
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
517
509
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
518
510
|
*
|
|
519
|
-
* @version 1.2.
|
|
511
|
+
* @version 1.2.7
|
|
520
512
|
* @author Yusuke Kamiyamane
|
|
521
513
|
* @license MIT
|
|
522
514
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -528,7 +520,7 @@ function getActiveElement2() {
|
|
|
528
520
|
(**
|
|
529
521
|
* Attributes Utils
|
|
530
522
|
*
|
|
531
|
-
* @version 1.0.
|
|
523
|
+
* @version 1.0.5
|
|
532
524
|
* @author Yusuke Kamiyamane
|
|
533
525
|
* @license MIT
|
|
534
526
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y14e/portal",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "Lightweight DOM portal (teleport) utility with fully focus management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/y14e/portal#readme",
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@y14e/attributes-utils": "^1.0.
|
|
50
|
+
"@y14e/attributes-utils": "^1.0.5",
|
|
51
51
|
"bun-types": "latest",
|
|
52
52
|
"power-focusable": "^4.1.7",
|
|
53
53
|
"tsup": "^8.0.0",
|