@y14e/portal 1.2.10 → 1.2.11
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 +4 -4
- package/dist/index.cjs +20 -3
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -3
- package/package.json +1 -1
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.
|
|
13
|
+
import { createPortal } from '@y14e/portal@1.2.11';
|
|
14
14
|
|
|
15
15
|
// CDNs
|
|
16
|
-
import { createPortal } from 'https://esm.sh/@y14e/portal@1.2.
|
|
16
|
+
import { createPortal } from 'https://esm.sh/@y14e/portal@1.2.11';
|
|
17
17
|
// or
|
|
18
|
-
import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.2.
|
|
18
|
+
import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.2.11/+esm';
|
|
19
19
|
// or
|
|
20
|
-
import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.2.
|
|
20
|
+
import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.2.11';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 📦 APIs
|
package/dist/index.cjs
CHANGED
|
@@ -452,7 +452,15 @@ var Portal = class {
|
|
|
452
452
|
}
|
|
453
453
|
this.#update();
|
|
454
454
|
const first = [...this.#focusables][0];
|
|
455
|
-
|
|
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
|
+
}
|
|
456
464
|
return;
|
|
457
465
|
}
|
|
458
466
|
if (current === this.#exitSentinel) {
|
|
@@ -462,7 +470,16 @@ var Portal = class {
|
|
|
462
470
|
}
|
|
463
471
|
this.#update();
|
|
464
472
|
const last = [...this.#focusables].at(-1);
|
|
465
|
-
|
|
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
|
+
}
|
|
482
|
+
return;
|
|
466
483
|
}
|
|
467
484
|
};
|
|
468
485
|
#onKeyDown = (event) => {
|
|
@@ -566,7 +583,7 @@ function getActiveElement2() {
|
|
|
566
583
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
567
584
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
568
585
|
*
|
|
569
|
-
* @version 1.2.
|
|
586
|
+
* @version 1.2.11
|
|
570
587
|
* @author Yusuke Kamiyamane
|
|
571
588
|
* @license MIT
|
|
572
589
|
* @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.11
|
|
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.11
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -450,7 +450,15 @@ var Portal = class {
|
|
|
450
450
|
}
|
|
451
451
|
this.#update();
|
|
452
452
|
const first = [...this.#focusables][0];
|
|
453
|
-
|
|
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
|
+
}
|
|
454
462
|
return;
|
|
455
463
|
}
|
|
456
464
|
if (current === this.#exitSentinel) {
|
|
@@ -460,7 +468,16 @@ var Portal = class {
|
|
|
460
468
|
}
|
|
461
469
|
this.#update();
|
|
462
470
|
const last = [...this.#focusables].at(-1);
|
|
463
|
-
|
|
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
|
+
}
|
|
480
|
+
return;
|
|
464
481
|
}
|
|
465
482
|
};
|
|
466
483
|
#onKeyDown = (event) => {
|
|
@@ -564,7 +581,7 @@ function getActiveElement2() {
|
|
|
564
581
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
565
582
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
566
583
|
*
|
|
567
|
-
* @version 1.2.
|
|
584
|
+
* @version 1.2.11
|
|
568
585
|
* @author Yusuke Kamiyamane
|
|
569
586
|
* @license MIT
|
|
570
587
|
* @copyright Copyright (c) Yusuke Kamiyamane
|