@y14e/portal 1.4.5 → 1.4.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.bundle.cjs +19 -21
- package/dist/index.bundle.js +19 -21
- package/dist/index.cjs +3 -0
- package/dist/index.js +3 -0
- package/package.json +2 -2
package/dist/index.bundle.cjs
CHANGED
|
@@ -39,23 +39,23 @@ function containsComposed(container, element) {
|
|
|
39
39
|
}
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
|
-
function getComposedChildren(
|
|
43
|
-
if (
|
|
44
|
-
return [...
|
|
42
|
+
function getComposedChildren(element) {
|
|
43
|
+
if (element instanceof ShadowRoot) {
|
|
44
|
+
return [...element.children];
|
|
45
45
|
}
|
|
46
|
-
if (!(
|
|
46
|
+
if (!(element instanceof Element)) {
|
|
47
47
|
return [];
|
|
48
48
|
}
|
|
49
|
-
if (
|
|
50
|
-
const assigned =
|
|
49
|
+
if (element instanceof HTMLSlotElement) {
|
|
50
|
+
const assigned = element.assignedElements({ flatten: true });
|
|
51
51
|
if (assigned.length) {
|
|
52
52
|
return assigned;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
if (
|
|
56
|
-
return [...
|
|
55
|
+
if (element instanceof HTMLElement && element.shadowRoot?.mode === "open") {
|
|
56
|
+
return [...element.shadowRoot.children];
|
|
57
57
|
}
|
|
58
|
-
return [...
|
|
58
|
+
return [...element.children];
|
|
59
59
|
}
|
|
60
60
|
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"])';
|
|
61
61
|
var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX = FOCUSABLE_SELECTOR.replace(
|
|
@@ -201,10 +201,8 @@ function isDisabledDeep(element) {
|
|
|
201
201
|
if (isInert(current)) {
|
|
202
202
|
return true;
|
|
203
203
|
}
|
|
204
|
-
if (isFormControl(element) && current.tagName === "FIELDSET" && isDisabled(current)) {
|
|
205
|
-
|
|
206
|
-
return true;
|
|
207
|
-
}
|
|
204
|
+
if (isFormControl(element) && current.tagName === "FIELDSET" && isDisabled(current) && !current.querySelector(":scope > legend:first-of-type")?.contains(element)) {
|
|
205
|
+
return true;
|
|
208
206
|
}
|
|
209
207
|
current = current.parentNode;
|
|
210
208
|
}
|
|
@@ -213,10 +211,7 @@ function isDisabledDeep(element) {
|
|
|
213
211
|
function normalizeRadioGroup(elements) {
|
|
214
212
|
let map = null;
|
|
215
213
|
for (const element of elements) {
|
|
216
|
-
if (!(element instanceof HTMLInputElement)) {
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
if (!isUngroupedRadio(element)) {
|
|
214
|
+
if (!(element instanceof HTMLInputElement) || !isUngroupedRadio(element)) {
|
|
220
215
|
continue;
|
|
221
216
|
}
|
|
222
217
|
if (!map) {
|
|
@@ -275,11 +270,11 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
275
270
|
match && isFocusable(match, { skipNegativeTabIndexCheck, skipVisibilityCheck }) && candidates.push(match);
|
|
276
271
|
}
|
|
277
272
|
} else {
|
|
278
|
-
let traverse2 = function(
|
|
279
|
-
if (isFocusable(
|
|
280
|
-
candidates.push(
|
|
273
|
+
let traverse2 = function(element) {
|
|
274
|
+
if (isFocusable(element, { skipNegativeTabIndexCheck, skipVisibilityCheck }) || include?.(element)) {
|
|
275
|
+
candidates.push(element);
|
|
281
276
|
}
|
|
282
|
-
(!composed ? [...
|
|
277
|
+
(!composed ? [...element.children] : getComposedChildren(element)).map(traverse2);
|
|
283
278
|
};
|
|
284
279
|
(!composed ? [...container.children] : getComposedChildren(container)).map(traverse2);
|
|
285
280
|
}
|
|
@@ -426,6 +421,9 @@ var Portal = class {
|
|
|
426
421
|
last ? focusElement(last) : this.#moveFocus("previous");
|
|
427
422
|
};
|
|
428
423
|
#onKeyDown = (event) => {
|
|
424
|
+
if (!(event instanceof KeyboardEvent)) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
429
427
|
const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
|
|
430
428
|
if (key !== "Tab" || altKey || ctrlKey || metaKey) {
|
|
431
429
|
return;
|
package/dist/index.bundle.js
CHANGED
|
@@ -37,23 +37,23 @@ function containsComposed(container, element) {
|
|
|
37
37
|
}
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
40
|
-
function getComposedChildren(
|
|
41
|
-
if (
|
|
42
|
-
return [...
|
|
40
|
+
function getComposedChildren(element) {
|
|
41
|
+
if (element instanceof ShadowRoot) {
|
|
42
|
+
return [...element.children];
|
|
43
43
|
}
|
|
44
|
-
if (!(
|
|
44
|
+
if (!(element instanceof Element)) {
|
|
45
45
|
return [];
|
|
46
46
|
}
|
|
47
|
-
if (
|
|
48
|
-
const assigned =
|
|
47
|
+
if (element instanceof HTMLSlotElement) {
|
|
48
|
+
const assigned = element.assignedElements({ flatten: true });
|
|
49
49
|
if (assigned.length) {
|
|
50
50
|
return assigned;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
if (
|
|
54
|
-
return [...
|
|
53
|
+
if (element instanceof HTMLElement && element.shadowRoot?.mode === "open") {
|
|
54
|
+
return [...element.shadowRoot.children];
|
|
55
55
|
}
|
|
56
|
-
return [...
|
|
56
|
+
return [...element.children];
|
|
57
57
|
}
|
|
58
58
|
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"])';
|
|
59
59
|
var FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX = FOCUSABLE_SELECTOR.replace(
|
|
@@ -199,10 +199,8 @@ function isDisabledDeep(element) {
|
|
|
199
199
|
if (isInert(current)) {
|
|
200
200
|
return true;
|
|
201
201
|
}
|
|
202
|
-
if (isFormControl(element) && current.tagName === "FIELDSET" && isDisabled(current)) {
|
|
203
|
-
|
|
204
|
-
return true;
|
|
205
|
-
}
|
|
202
|
+
if (isFormControl(element) && current.tagName === "FIELDSET" && isDisabled(current) && !current.querySelector(":scope > legend:first-of-type")?.contains(element)) {
|
|
203
|
+
return true;
|
|
206
204
|
}
|
|
207
205
|
current = current.parentNode;
|
|
208
206
|
}
|
|
@@ -211,10 +209,7 @@ function isDisabledDeep(element) {
|
|
|
211
209
|
function normalizeRadioGroup(elements) {
|
|
212
210
|
let map = null;
|
|
213
211
|
for (const element of elements) {
|
|
214
|
-
if (!(element instanceof HTMLInputElement)) {
|
|
215
|
-
continue;
|
|
216
|
-
}
|
|
217
|
-
if (!isUngroupedRadio(element)) {
|
|
212
|
+
if (!(element instanceof HTMLInputElement) || !isUngroupedRadio(element)) {
|
|
218
213
|
continue;
|
|
219
214
|
}
|
|
220
215
|
if (!map) {
|
|
@@ -273,11 +268,11 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
273
268
|
match && isFocusable(match, { skipNegativeTabIndexCheck, skipVisibilityCheck }) && candidates.push(match);
|
|
274
269
|
}
|
|
275
270
|
} else {
|
|
276
|
-
let traverse2 = function(
|
|
277
|
-
if (isFocusable(
|
|
278
|
-
candidates.push(
|
|
271
|
+
let traverse2 = function(element) {
|
|
272
|
+
if (isFocusable(element, { skipNegativeTabIndexCheck, skipVisibilityCheck }) || include?.(element)) {
|
|
273
|
+
candidates.push(element);
|
|
279
274
|
}
|
|
280
|
-
(!composed ? [...
|
|
275
|
+
(!composed ? [...element.children] : getComposedChildren(element)).map(traverse2);
|
|
281
276
|
};
|
|
282
277
|
(!composed ? [...container.children] : getComposedChildren(container)).map(traverse2);
|
|
283
278
|
}
|
|
@@ -424,6 +419,9 @@ var Portal = class {
|
|
|
424
419
|
last ? focusElement(last) : this.#moveFocus("previous");
|
|
425
420
|
};
|
|
426
421
|
#onKeyDown = (event) => {
|
|
422
|
+
if (!(event instanceof KeyboardEvent)) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
427
425
|
const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
|
|
428
426
|
if (key !== "Tab" || altKey || ctrlKey || metaKey) {
|
|
429
427
|
return;
|
package/dist/index.cjs
CHANGED
|
@@ -110,6 +110,9 @@ var Portal = class {
|
|
|
110
110
|
last ? powerFocusable.focusElement(last) : this.#moveFocus("previous");
|
|
111
111
|
};
|
|
112
112
|
#onKeyDown = (event) => {
|
|
113
|
+
if (!(event instanceof KeyboardEvent)) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
113
116
|
const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
|
|
114
117
|
if (key !== "Tab" || altKey || ctrlKey || metaKey) {
|
|
115
118
|
return;
|
package/dist/index.js
CHANGED
|
@@ -108,6 +108,9 @@ var Portal = class {
|
|
|
108
108
|
last ? focusElement(last) : this.#moveFocus("previous");
|
|
109
109
|
};
|
|
110
110
|
#onKeyDown = (event) => {
|
|
111
|
+
if (!(event instanceof KeyboardEvent)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
111
114
|
const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
|
|
112
115
|
if (key !== "Tab" || altKey || ctrlKey || metaKey) {
|
|
113
116
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y14e/portal",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"description": "Lightweight DOM portal (teleport) utility with fully focus management",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"a11y",
|
|
@@ -59,6 +59,6 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@y14e/attribute-utils": "^2.0.18",
|
|
62
|
-
"power-focusable": "^4.5.
|
|
62
|
+
"power-focusable": "^4.5.9"
|
|
63
63
|
}
|
|
64
64
|
}
|