@y14e/portal 1.0.4 → 1.0.6
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 +10 -10
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -10
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -10,11 +10,11 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
10
10
|
const { composed = false } = options;
|
|
11
11
|
let { filter, include } = options;
|
|
12
12
|
if (filter && typeof filter !== "function") {
|
|
13
|
-
console.warn("Invalid filter function
|
|
13
|
+
console.warn("Invalid filter function");
|
|
14
14
|
filter = void 0;
|
|
15
15
|
}
|
|
16
16
|
if (include && typeof include !== "function") {
|
|
17
|
-
console.warn("Invalid include function
|
|
17
|
+
console.warn("Invalid include function");
|
|
18
18
|
include = void 0;
|
|
19
19
|
}
|
|
20
20
|
const elements = [];
|
|
@@ -104,7 +104,7 @@ function getRelativeFocusable(container, offset, options) {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
if (!containsComposed(container, anchor)) {
|
|
107
|
-
console.warn("
|
|
107
|
+
console.warn("Anchor (active) element not within container");
|
|
108
108
|
return null;
|
|
109
109
|
}
|
|
110
110
|
const focusables = getFocusables(container, { composed, filter, include });
|
|
@@ -359,14 +359,14 @@ var Portal = class {
|
|
|
359
359
|
this.#moveFocus("previous");
|
|
360
360
|
} else {
|
|
361
361
|
const first = this.#getFocusables()[0];
|
|
362
|
-
first &&
|
|
362
|
+
first && focusElement(first);
|
|
363
363
|
}
|
|
364
364
|
} else if (current === this.#exitSentinel) {
|
|
365
365
|
if (this.#host.contains(before)) {
|
|
366
366
|
this.#moveFocus("next");
|
|
367
367
|
} else {
|
|
368
368
|
const last = this.#getFocusables().at(-1);
|
|
369
|
-
last &&
|
|
369
|
+
last && focusElement(last);
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
};
|
|
@@ -392,7 +392,7 @@ var Portal = class {
|
|
|
392
392
|
event.preventDefault();
|
|
393
393
|
const focusable = this.#getFocusables()[index + (event.shiftKey ? -1 : 1)];
|
|
394
394
|
if (focusable) {
|
|
395
|
-
|
|
395
|
+
focusElement(focusable);
|
|
396
396
|
} else {
|
|
397
397
|
(event.shiftKey ? this.#entranceSentinel : this.#exitSentinel).focus();
|
|
398
398
|
}
|
|
@@ -417,7 +417,7 @@ var Portal = class {
|
|
|
417
417
|
composed: true
|
|
418
418
|
};
|
|
419
419
|
const focusable = direction === "previous" ? getPreviousFocusable(document.body, options) : getNextFocusable(document.body, options);
|
|
420
|
-
focusable &&
|
|
420
|
+
focusable && focusElement(focusable);
|
|
421
421
|
}
|
|
422
422
|
};
|
|
423
423
|
function containsComposed2(container, element) {
|
|
@@ -430,7 +430,7 @@ function containsComposed2(container, element) {
|
|
|
430
430
|
}
|
|
431
431
|
return false;
|
|
432
432
|
}
|
|
433
|
-
function
|
|
433
|
+
function focusElement(element) {
|
|
434
434
|
"focus" in element && typeof element.focus === "function" && element.focus();
|
|
435
435
|
}
|
|
436
436
|
function getActiveElement2() {
|
|
@@ -445,7 +445,7 @@ function getActiveElement2() {
|
|
|
445
445
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
446
446
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
447
447
|
*
|
|
448
|
-
* @version 1.0.
|
|
448
|
+
* @version 1.0.6
|
|
449
449
|
* @author Yusuke Kamiyamane
|
|
450
450
|
* @license MIT
|
|
451
451
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -459,7 +459,7 @@ power-focusable/dist/index.js:
|
|
|
459
459
|
* High-precision focus management utility with full composed tree support.
|
|
460
460
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
461
461
|
*
|
|
462
|
-
* @version 4.1.
|
|
462
|
+
* @version 4.1.5
|
|
463
463
|
* @author Yusuke Kamiyamane
|
|
464
464
|
* @license MIT
|
|
465
465
|
* @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.0.
|
|
6
|
+
* @version 1.0.6
|
|
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.0.
|
|
6
|
+
* @version 1.0.6
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -8,11 +8,11 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
8
8
|
const { composed = false } = options;
|
|
9
9
|
let { filter, include } = options;
|
|
10
10
|
if (filter && typeof filter !== "function") {
|
|
11
|
-
console.warn("Invalid filter function
|
|
11
|
+
console.warn("Invalid filter function");
|
|
12
12
|
filter = void 0;
|
|
13
13
|
}
|
|
14
14
|
if (include && typeof include !== "function") {
|
|
15
|
-
console.warn("Invalid include function
|
|
15
|
+
console.warn("Invalid include function");
|
|
16
16
|
include = void 0;
|
|
17
17
|
}
|
|
18
18
|
const elements = [];
|
|
@@ -102,7 +102,7 @@ function getRelativeFocusable(container, offset, options) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
if (!containsComposed(container, anchor)) {
|
|
105
|
-
console.warn("
|
|
105
|
+
console.warn("Anchor (active) element not within container");
|
|
106
106
|
return null;
|
|
107
107
|
}
|
|
108
108
|
const focusables = getFocusables(container, { composed, filter, include });
|
|
@@ -357,14 +357,14 @@ var Portal = class {
|
|
|
357
357
|
this.#moveFocus("previous");
|
|
358
358
|
} else {
|
|
359
359
|
const first = this.#getFocusables()[0];
|
|
360
|
-
first &&
|
|
360
|
+
first && focusElement(first);
|
|
361
361
|
}
|
|
362
362
|
} else if (current === this.#exitSentinel) {
|
|
363
363
|
if (this.#host.contains(before)) {
|
|
364
364
|
this.#moveFocus("next");
|
|
365
365
|
} else {
|
|
366
366
|
const last = this.#getFocusables().at(-1);
|
|
367
|
-
last &&
|
|
367
|
+
last && focusElement(last);
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
};
|
|
@@ -390,7 +390,7 @@ var Portal = class {
|
|
|
390
390
|
event.preventDefault();
|
|
391
391
|
const focusable = this.#getFocusables()[index + (event.shiftKey ? -1 : 1)];
|
|
392
392
|
if (focusable) {
|
|
393
|
-
|
|
393
|
+
focusElement(focusable);
|
|
394
394
|
} else {
|
|
395
395
|
(event.shiftKey ? this.#entranceSentinel : this.#exitSentinel).focus();
|
|
396
396
|
}
|
|
@@ -415,7 +415,7 @@ var Portal = class {
|
|
|
415
415
|
composed: true
|
|
416
416
|
};
|
|
417
417
|
const focusable = direction === "previous" ? getPreviousFocusable(document.body, options) : getNextFocusable(document.body, options);
|
|
418
|
-
focusable &&
|
|
418
|
+
focusable && focusElement(focusable);
|
|
419
419
|
}
|
|
420
420
|
};
|
|
421
421
|
function containsComposed2(container, element) {
|
|
@@ -428,7 +428,7 @@ function containsComposed2(container, element) {
|
|
|
428
428
|
}
|
|
429
429
|
return false;
|
|
430
430
|
}
|
|
431
|
-
function
|
|
431
|
+
function focusElement(element) {
|
|
432
432
|
"focus" in element && typeof element.focus === "function" && element.focus();
|
|
433
433
|
}
|
|
434
434
|
function getActiveElement2() {
|
|
@@ -443,7 +443,7 @@ function getActiveElement2() {
|
|
|
443
443
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
444
444
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
445
445
|
*
|
|
446
|
-
* @version 1.0.
|
|
446
|
+
* @version 1.0.6
|
|
447
447
|
* @author Yusuke Kamiyamane
|
|
448
448
|
* @license MIT
|
|
449
449
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -457,7 +457,7 @@ power-focusable/dist/index.js:
|
|
|
457
457
|
* High-precision focus management utility with full composed tree support.
|
|
458
458
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
459
459
|
*
|
|
460
|
-
* @version 4.1.
|
|
460
|
+
* @version 4.1.5
|
|
461
461
|
* @author Yusuke Kamiyamane
|
|
462
462
|
* @license MIT
|
|
463
463
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y14e/portal",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Lightweight DOM portal (teleport) utility with fully focus management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"homepage": "https://github.com/y14e/portal#readme",
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"bun-types": "latest",
|
|
51
|
-
"power-focusable": "^4.1.
|
|
51
|
+
"power-focusable": "^4.1.5",
|
|
52
52
|
"tsup": "^8.0.0",
|
|
53
53
|
"typescript": "^5.6.0"
|
|
54
54
|
},
|