@y14e/portal 1.0.0 → 1.0.1
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 +16 -6
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -6
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -7,9 +7,18 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
7
7
|
console.warn("Invalid container element. Fallback: <body> element.");
|
|
8
8
|
container = document.body;
|
|
9
9
|
}
|
|
10
|
-
const { composed = false
|
|
10
|
+
const { composed = false } = options;
|
|
11
|
+
let { filter, include } = options;
|
|
12
|
+
if (filter && typeof filter !== "function") {
|
|
13
|
+
console.warn("Invalid filter function. Fallback: undefined.");
|
|
14
|
+
filter = void 0;
|
|
15
|
+
}
|
|
16
|
+
if (include && typeof include !== "function") {
|
|
17
|
+
console.warn("Invalid include function. Fallback: undefined.");
|
|
18
|
+
include = void 0;
|
|
19
|
+
}
|
|
11
20
|
const elements = [];
|
|
12
|
-
if (composed ||
|
|
21
|
+
if (composed || include) {
|
|
13
22
|
let traverse2 = function(node) {
|
|
14
23
|
if (node instanceof Element) {
|
|
15
24
|
if (isFocusable(node) || include?.(node)) {
|
|
@@ -38,7 +47,8 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
38
47
|
}
|
|
39
48
|
}
|
|
40
49
|
}
|
|
41
|
-
|
|
50
|
+
const unfiltered = normalizeRadioGroup(sortByTabIndex(elements));
|
|
51
|
+
return filter ? unfiltered.filter(filter) : unfiltered;
|
|
42
52
|
}
|
|
43
53
|
function getNextFocusable(container = document.body, options = {}) {
|
|
44
54
|
if (!(container instanceof Element)) {
|
|
@@ -84,7 +94,7 @@ function getRelativeFocusable(container, offset, options) {
|
|
|
84
94
|
const {
|
|
85
95
|
anchor = getActiveElement(),
|
|
86
96
|
composed = false,
|
|
87
|
-
filter
|
|
97
|
+
filter,
|
|
88
98
|
include,
|
|
89
99
|
wrap = false
|
|
90
100
|
} = options;
|
|
@@ -409,7 +419,7 @@ function getActiveElement2() {
|
|
|
409
419
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
410
420
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
411
421
|
*
|
|
412
|
-
* @version 1.0.
|
|
422
|
+
* @version 1.0.1
|
|
413
423
|
* @author Yusuke Kamiyamane
|
|
414
424
|
* @license MIT
|
|
415
425
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -423,7 +433,7 @@ power-focusable/dist/index.js:
|
|
|
423
433
|
* High-precision focus management utility with full composed tree support.
|
|
424
434
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
425
435
|
*
|
|
426
|
-
* @version 4.1.
|
|
436
|
+
* @version 4.1.2
|
|
427
437
|
* @author Yusuke Kamiyamane
|
|
428
438
|
* @license MIT
|
|
429
439
|
* @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.1
|
|
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.1
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -5,9 +5,18 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
5
5
|
console.warn("Invalid container element. Fallback: <body> element.");
|
|
6
6
|
container = document.body;
|
|
7
7
|
}
|
|
8
|
-
const { composed = false
|
|
8
|
+
const { composed = false } = options;
|
|
9
|
+
let { filter, include } = options;
|
|
10
|
+
if (filter && typeof filter !== "function") {
|
|
11
|
+
console.warn("Invalid filter function. Fallback: undefined.");
|
|
12
|
+
filter = void 0;
|
|
13
|
+
}
|
|
14
|
+
if (include && typeof include !== "function") {
|
|
15
|
+
console.warn("Invalid include function. Fallback: undefined.");
|
|
16
|
+
include = void 0;
|
|
17
|
+
}
|
|
9
18
|
const elements = [];
|
|
10
|
-
if (composed ||
|
|
19
|
+
if (composed || include) {
|
|
11
20
|
let traverse2 = function(node) {
|
|
12
21
|
if (node instanceof Element) {
|
|
13
22
|
if (isFocusable(node) || include?.(node)) {
|
|
@@ -36,7 +45,8 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
36
45
|
}
|
|
37
46
|
}
|
|
38
47
|
}
|
|
39
|
-
|
|
48
|
+
const unfiltered = normalizeRadioGroup(sortByTabIndex(elements));
|
|
49
|
+
return filter ? unfiltered.filter(filter) : unfiltered;
|
|
40
50
|
}
|
|
41
51
|
function getNextFocusable(container = document.body, options = {}) {
|
|
42
52
|
if (!(container instanceof Element)) {
|
|
@@ -82,7 +92,7 @@ function getRelativeFocusable(container, offset, options) {
|
|
|
82
92
|
const {
|
|
83
93
|
anchor = getActiveElement(),
|
|
84
94
|
composed = false,
|
|
85
|
-
filter
|
|
95
|
+
filter,
|
|
86
96
|
include,
|
|
87
97
|
wrap = false
|
|
88
98
|
} = options;
|
|
@@ -407,7 +417,7 @@ function getActiveElement2() {
|
|
|
407
417
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
408
418
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
409
419
|
*
|
|
410
|
-
* @version 1.0.
|
|
420
|
+
* @version 1.0.1
|
|
411
421
|
* @author Yusuke Kamiyamane
|
|
412
422
|
* @license MIT
|
|
413
423
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -421,7 +431,7 @@ power-focusable/dist/index.js:
|
|
|
421
431
|
* High-precision focus management utility with full composed tree support.
|
|
422
432
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
423
433
|
*
|
|
424
|
-
* @version 4.1.
|
|
434
|
+
* @version 4.1.2
|
|
425
435
|
* @author Yusuke Kamiyamane
|
|
426
436
|
* @license MIT
|
|
427
437
|
* @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.1",
|
|
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.2",
|
|
52
52
|
"tsup": "^8.0.0",
|
|
53
53
|
"typescript": "^5.6.0"
|
|
54
54
|
},
|