@y14e/portal 1.2.3 → 1.2.4
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 +46 -19
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +46 -19
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// node_modules/@y14e/attributes-utils/dist/index.js
|
|
4
|
+
var snapshots = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
function restoreAttributes(elements) {
|
|
6
|
+
elements.forEach((element) => {
|
|
7
|
+
const snapshot = snapshots.get(element);
|
|
8
|
+
if (!snapshot) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
for (const [attribute, value] of snapshot.entries()) {
|
|
12
|
+
if (value === null) {
|
|
13
|
+
element.removeAttribute(attribute);
|
|
14
|
+
} else {
|
|
15
|
+
element.setAttribute(attribute, value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
snapshots.delete(element);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function saveAttributes(elements, attributes) {
|
|
22
|
+
elements.forEach((element) => {
|
|
23
|
+
let snapshot = snapshots.get(element);
|
|
24
|
+
if (!snapshot) {
|
|
25
|
+
snapshot = /* @__PURE__ */ new Map();
|
|
26
|
+
snapshots.set(element, snapshot);
|
|
27
|
+
}
|
|
28
|
+
attributes.forEach((attribute) => {
|
|
29
|
+
snapshot.set(attribute, element.getAttribute(attribute));
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
3
34
|
// node_modules/power-focusable/dist/index.js
|
|
4
35
|
var FOCUSABLE_SELECTOR = `:is(a[href], area[href], button, embed, iframe, input:not([type="hidden" i]), object, select, details > summary:first-of-type, textarea, [contenteditable]:not([contenteditable="false" i]), [controls], [tabindex]):not(:disabled, [hidden], [inert], [tabindex="-1"])`;
|
|
5
36
|
function getFocusables(container = document.body, options = {}) {
|
|
@@ -296,7 +327,6 @@ var Portal = class {
|
|
|
296
327
|
#entranceSentinel;
|
|
297
328
|
#exitSentinel;
|
|
298
329
|
#focusables = /* @__PURE__ */ new Set();
|
|
299
|
-
#tabIndexes = /* @__PURE__ */ new Map();
|
|
300
330
|
#controller = null;
|
|
301
331
|
#isDestroyed = false;
|
|
302
332
|
constructor(host, container) {
|
|
@@ -313,16 +343,8 @@ var Portal = class {
|
|
|
313
343
|
this.#isDestroyed = true;
|
|
314
344
|
this.#controller?.abort();
|
|
315
345
|
this.#controller = null;
|
|
316
|
-
this.#focusables
|
|
317
|
-
const index = this.#tabIndexes.get(focusable);
|
|
318
|
-
if (index == null) {
|
|
319
|
-
focusable.removeAttribute("tabindex");
|
|
320
|
-
} else {
|
|
321
|
-
focusable.setAttribute("tabindex", index);
|
|
322
|
-
}
|
|
323
|
-
});
|
|
346
|
+
restoreAttributes([...this.#focusables]);
|
|
324
347
|
this.#focusables.clear();
|
|
325
|
-
this.#tabIndexes.clear();
|
|
326
348
|
this.#exitSentinel.after(this.#host);
|
|
327
349
|
this.#entranceSentinel.remove();
|
|
328
350
|
this.#exitSentinel.remove();
|
|
@@ -410,22 +432,16 @@ var Portal = class {
|
|
|
410
432
|
return;
|
|
411
433
|
}
|
|
412
434
|
if (focusable.isConnected) {
|
|
413
|
-
|
|
414
|
-
if (index == null) {
|
|
415
|
-
focusable.removeAttribute("tabindex");
|
|
416
|
-
} else {
|
|
417
|
-
focusable.setAttribute("tabindex", index);
|
|
418
|
-
}
|
|
435
|
+
restoreAttributes([focusable]);
|
|
419
436
|
}
|
|
420
437
|
this.#focusables.delete(focusable);
|
|
421
|
-
this.#tabIndexes.delete(focusable);
|
|
422
438
|
});
|
|
423
439
|
current.forEach((c) => {
|
|
424
440
|
if (this.#focusables.has(c)) {
|
|
425
441
|
return;
|
|
426
442
|
}
|
|
427
443
|
this.#focusables.add(c);
|
|
428
|
-
|
|
444
|
+
saveAttributes([c], ["tabindex"]);
|
|
429
445
|
c.setAttribute("tabindex", "-1");
|
|
430
446
|
});
|
|
431
447
|
}
|
|
@@ -482,7 +498,7 @@ function getActiveElement2() {
|
|
|
482
498
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
483
499
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
484
500
|
*
|
|
485
|
-
* @version 1.2.
|
|
501
|
+
* @version 1.2.4
|
|
486
502
|
* @author Yusuke Kamiyamane
|
|
487
503
|
* @license MIT
|
|
488
504
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -490,6 +506,17 @@ function getActiveElement2() {
|
|
|
490
506
|
*/
|
|
491
507
|
/*! Bundled license information:
|
|
492
508
|
|
|
509
|
+
@y14e/attributes-utils/dist/index.js:
|
|
510
|
+
(**
|
|
511
|
+
* Attributes Utils
|
|
512
|
+
*
|
|
513
|
+
* @version 1.0.0
|
|
514
|
+
* @author Yusuke Kamiyamane
|
|
515
|
+
* @license MIT
|
|
516
|
+
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
517
|
+
* @see {@link https://github.com/y14e/attributes-utils}
|
|
518
|
+
*)
|
|
519
|
+
|
|
493
520
|
power-focusable/dist/index.js:
|
|
494
521
|
(**
|
|
495
522
|
* Power Focusable
|
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.4
|
|
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.4
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
// node_modules/@y14e/attributes-utils/dist/index.js
|
|
2
|
+
var snapshots = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
function restoreAttributes(elements) {
|
|
4
|
+
elements.forEach((element) => {
|
|
5
|
+
const snapshot = snapshots.get(element);
|
|
6
|
+
if (!snapshot) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
for (const [attribute, value] of snapshot.entries()) {
|
|
10
|
+
if (value === null) {
|
|
11
|
+
element.removeAttribute(attribute);
|
|
12
|
+
} else {
|
|
13
|
+
element.setAttribute(attribute, value);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
snapshots.delete(element);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function saveAttributes(elements, attributes) {
|
|
20
|
+
elements.forEach((element) => {
|
|
21
|
+
let snapshot = snapshots.get(element);
|
|
22
|
+
if (!snapshot) {
|
|
23
|
+
snapshot = /* @__PURE__ */ new Map();
|
|
24
|
+
snapshots.set(element, snapshot);
|
|
25
|
+
}
|
|
26
|
+
attributes.forEach((attribute) => {
|
|
27
|
+
snapshot.set(attribute, element.getAttribute(attribute));
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
1
32
|
// node_modules/power-focusable/dist/index.js
|
|
2
33
|
var FOCUSABLE_SELECTOR = `:is(a[href], area[href], button, embed, iframe, input:not([type="hidden" i]), object, select, details > summary:first-of-type, textarea, [contenteditable]:not([contenteditable="false" i]), [controls], [tabindex]):not(:disabled, [hidden], [inert], [tabindex="-1"])`;
|
|
3
34
|
function getFocusables(container = document.body, options = {}) {
|
|
@@ -294,7 +325,6 @@ var Portal = class {
|
|
|
294
325
|
#entranceSentinel;
|
|
295
326
|
#exitSentinel;
|
|
296
327
|
#focusables = /* @__PURE__ */ new Set();
|
|
297
|
-
#tabIndexes = /* @__PURE__ */ new Map();
|
|
298
328
|
#controller = null;
|
|
299
329
|
#isDestroyed = false;
|
|
300
330
|
constructor(host, container) {
|
|
@@ -311,16 +341,8 @@ var Portal = class {
|
|
|
311
341
|
this.#isDestroyed = true;
|
|
312
342
|
this.#controller?.abort();
|
|
313
343
|
this.#controller = null;
|
|
314
|
-
this.#focusables
|
|
315
|
-
const index = this.#tabIndexes.get(focusable);
|
|
316
|
-
if (index == null) {
|
|
317
|
-
focusable.removeAttribute("tabindex");
|
|
318
|
-
} else {
|
|
319
|
-
focusable.setAttribute("tabindex", index);
|
|
320
|
-
}
|
|
321
|
-
});
|
|
344
|
+
restoreAttributes([...this.#focusables]);
|
|
322
345
|
this.#focusables.clear();
|
|
323
|
-
this.#tabIndexes.clear();
|
|
324
346
|
this.#exitSentinel.after(this.#host);
|
|
325
347
|
this.#entranceSentinel.remove();
|
|
326
348
|
this.#exitSentinel.remove();
|
|
@@ -408,22 +430,16 @@ var Portal = class {
|
|
|
408
430
|
return;
|
|
409
431
|
}
|
|
410
432
|
if (focusable.isConnected) {
|
|
411
|
-
|
|
412
|
-
if (index == null) {
|
|
413
|
-
focusable.removeAttribute("tabindex");
|
|
414
|
-
} else {
|
|
415
|
-
focusable.setAttribute("tabindex", index);
|
|
416
|
-
}
|
|
433
|
+
restoreAttributes([focusable]);
|
|
417
434
|
}
|
|
418
435
|
this.#focusables.delete(focusable);
|
|
419
|
-
this.#tabIndexes.delete(focusable);
|
|
420
436
|
});
|
|
421
437
|
current.forEach((c) => {
|
|
422
438
|
if (this.#focusables.has(c)) {
|
|
423
439
|
return;
|
|
424
440
|
}
|
|
425
441
|
this.#focusables.add(c);
|
|
426
|
-
|
|
442
|
+
saveAttributes([c], ["tabindex"]);
|
|
427
443
|
c.setAttribute("tabindex", "-1");
|
|
428
444
|
});
|
|
429
445
|
}
|
|
@@ -480,7 +496,7 @@ function getActiveElement2() {
|
|
|
480
496
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
481
497
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
482
498
|
*
|
|
483
|
-
* @version 1.2.
|
|
499
|
+
* @version 1.2.4
|
|
484
500
|
* @author Yusuke Kamiyamane
|
|
485
501
|
* @license MIT
|
|
486
502
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -488,6 +504,17 @@ function getActiveElement2() {
|
|
|
488
504
|
*/
|
|
489
505
|
/*! Bundled license information:
|
|
490
506
|
|
|
507
|
+
@y14e/attributes-utils/dist/index.js:
|
|
508
|
+
(**
|
|
509
|
+
* Attributes Utils
|
|
510
|
+
*
|
|
511
|
+
* @version 1.0.0
|
|
512
|
+
* @author Yusuke Kamiyamane
|
|
513
|
+
* @license MIT
|
|
514
|
+
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
515
|
+
* @see {@link https://github.com/y14e/attributes-utils}
|
|
516
|
+
*)
|
|
517
|
+
|
|
491
518
|
power-focusable/dist/index.js:
|
|
492
519
|
(**
|
|
493
520
|
* Power Focusable
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y14e/portal",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "Lightweight DOM portal (teleport) utility with fully focus management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/y14e/portal#readme",
|
|
49
49
|
"devDependencies": {
|
|
50
|
+
"@y14e/attributes-utils": "^1.0.0",
|
|
50
51
|
"bun-types": "latest",
|
|
51
52
|
"power-focusable": "^4.1.5",
|
|
52
53
|
"tsup": "^8.0.0",
|