@y14e/portal 1.1.0 → 1.2.0
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 +18 -9
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -381,7 +381,7 @@ var Portal = class {
|
|
|
381
381
|
return;
|
|
382
382
|
}
|
|
383
383
|
this.#update();
|
|
384
|
-
const focusables =
|
|
384
|
+
const focusables = this.#getFocusables();
|
|
385
385
|
if (!focusables.length) {
|
|
386
386
|
event.preventDefault();
|
|
387
387
|
(event.shiftKey ? this.#entranceSentinel : this.#exitSentinel).focus();
|
|
@@ -400,9 +400,10 @@ var Portal = class {
|
|
|
400
400
|
}
|
|
401
401
|
};
|
|
402
402
|
#update() {
|
|
403
|
-
const current = new Set(
|
|
404
|
-
getFocusables(this.#host, { composed: true })
|
|
405
|
-
|
|
403
|
+
const current = /* @__PURE__ */ new Set([
|
|
404
|
+
...getFocusables(this.#host, { composed: true }),
|
|
405
|
+
...this.#getFocusables()
|
|
406
|
+
]);
|
|
406
407
|
this.#focusables.forEach((focusable) => {
|
|
407
408
|
if (current.has(focusable)) {
|
|
408
409
|
return;
|
|
@@ -418,13 +419,13 @@ var Portal = class {
|
|
|
418
419
|
this.#focusables.delete(focusable);
|
|
419
420
|
this.#tabIndexes.delete(focusable);
|
|
420
421
|
});
|
|
421
|
-
const active = getActiveElement2();
|
|
422
422
|
current.forEach((c) => {
|
|
423
|
-
if (
|
|
424
|
-
|
|
423
|
+
if (this.#focusables.has(c)) {
|
|
424
|
+
return;
|
|
425
425
|
}
|
|
426
|
-
c.setAttribute("tabindex", c === active ? "0" : "-1");
|
|
427
426
|
this.#focusables.add(c);
|
|
427
|
+
this.#tabIndexes.set(c, c.getAttribute("tabindex"));
|
|
428
|
+
c.setAttribute("tabindex", "-1");
|
|
428
429
|
});
|
|
429
430
|
}
|
|
430
431
|
#createSentinel() {
|
|
@@ -435,6 +436,14 @@ var Portal = class {
|
|
|
435
436
|
sentinel.style.cssText += VISUALLY_HIDDEN_CSS;
|
|
436
437
|
return sentinel;
|
|
437
438
|
}
|
|
439
|
+
#getFocusables() {
|
|
440
|
+
return getFocusables(this.#host, {
|
|
441
|
+
composed: true,
|
|
442
|
+
include: (element) => {
|
|
443
|
+
return this.#focusables.has(element);
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
}
|
|
438
447
|
#moveFocus(direction) {
|
|
439
448
|
const options = {
|
|
440
449
|
anchor: direction === "previous" ? this.#entranceSentinel : this.#exitSentinel,
|
|
@@ -469,7 +478,7 @@ function getActiveElement2() {
|
|
|
469
478
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
470
479
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
471
480
|
*
|
|
472
|
-
* @version 1.
|
|
481
|
+
* @version 1.2.0
|
|
473
482
|
* @author Yusuke Kamiyamane
|
|
474
483
|
* @license MIT
|
|
475
484
|
* @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.
|
|
6
|
+
* @version 1.2.0
|
|
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.
|
|
6
|
+
* @version 1.2.0
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -379,7 +379,7 @@ var Portal = class {
|
|
|
379
379
|
return;
|
|
380
380
|
}
|
|
381
381
|
this.#update();
|
|
382
|
-
const focusables =
|
|
382
|
+
const focusables = this.#getFocusables();
|
|
383
383
|
if (!focusables.length) {
|
|
384
384
|
event.preventDefault();
|
|
385
385
|
(event.shiftKey ? this.#entranceSentinel : this.#exitSentinel).focus();
|
|
@@ -398,9 +398,10 @@ var Portal = class {
|
|
|
398
398
|
}
|
|
399
399
|
};
|
|
400
400
|
#update() {
|
|
401
|
-
const current = new Set(
|
|
402
|
-
getFocusables(this.#host, { composed: true })
|
|
403
|
-
|
|
401
|
+
const current = /* @__PURE__ */ new Set([
|
|
402
|
+
...getFocusables(this.#host, { composed: true }),
|
|
403
|
+
...this.#getFocusables()
|
|
404
|
+
]);
|
|
404
405
|
this.#focusables.forEach((focusable) => {
|
|
405
406
|
if (current.has(focusable)) {
|
|
406
407
|
return;
|
|
@@ -416,13 +417,13 @@ var Portal = class {
|
|
|
416
417
|
this.#focusables.delete(focusable);
|
|
417
418
|
this.#tabIndexes.delete(focusable);
|
|
418
419
|
});
|
|
419
|
-
const active = getActiveElement2();
|
|
420
420
|
current.forEach((c) => {
|
|
421
|
-
if (
|
|
422
|
-
|
|
421
|
+
if (this.#focusables.has(c)) {
|
|
422
|
+
return;
|
|
423
423
|
}
|
|
424
|
-
c.setAttribute("tabindex", c === active ? "0" : "-1");
|
|
425
424
|
this.#focusables.add(c);
|
|
425
|
+
this.#tabIndexes.set(c, c.getAttribute("tabindex"));
|
|
426
|
+
c.setAttribute("tabindex", "-1");
|
|
426
427
|
});
|
|
427
428
|
}
|
|
428
429
|
#createSentinel() {
|
|
@@ -433,6 +434,14 @@ var Portal = class {
|
|
|
433
434
|
sentinel.style.cssText += VISUALLY_HIDDEN_CSS;
|
|
434
435
|
return sentinel;
|
|
435
436
|
}
|
|
437
|
+
#getFocusables() {
|
|
438
|
+
return getFocusables(this.#host, {
|
|
439
|
+
composed: true,
|
|
440
|
+
include: (element) => {
|
|
441
|
+
return this.#focusables.has(element);
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
}
|
|
436
445
|
#moveFocus(direction) {
|
|
437
446
|
const options = {
|
|
438
447
|
anchor: direction === "previous" ? this.#entranceSentinel : this.#exitSentinel,
|
|
@@ -467,7 +476,7 @@ function getActiveElement2() {
|
|
|
467
476
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
468
477
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
469
478
|
*
|
|
470
|
-
* @version 1.
|
|
479
|
+
* @version 1.2.0
|
|
471
480
|
* @author Yusuke Kamiyamane
|
|
472
481
|
* @license MIT
|
|
473
482
|
* @copyright Copyright (c) Yusuke Kamiyamane
|