@y14e/portal 1.3.3 → 1.3.5
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 +3 -3
- package/dist/index.bundle.cjs +86 -95
- package/dist/index.bundle.js +86 -95
- package/dist/index.cjs +10 -7
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -7
- package/package.json +31 -31
package/README.md
CHANGED
|
@@ -13,11 +13,11 @@ npm i @y14e/portal
|
|
|
13
13
|
import { createPortal } from '@y14e/portal';
|
|
14
14
|
|
|
15
15
|
// CDNs
|
|
16
|
-
import { createPortal } from 'https://esm.sh/@y14e/portal@1.3.
|
|
16
|
+
import { createPortal } from 'https://esm.sh/@y14e/portal@1.3.5';
|
|
17
17
|
// or
|
|
18
|
-
import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.3.
|
|
18
|
+
import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.3.5/+esm';
|
|
19
19
|
// or
|
|
20
|
-
import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.3.
|
|
20
|
+
import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.3.5';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 📦 APIs
|
package/dist/index.bundle.cjs
CHANGED
|
@@ -39,37 +39,13 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
39
39
|
console.warn("Invalid container element. Fallback: <body> element.");
|
|
40
40
|
container = document.body;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
composed
|
|
42
|
+
const {
|
|
43
|
+
composed,
|
|
44
44
|
filter,
|
|
45
45
|
include,
|
|
46
|
-
skipNegativeTabIndexCheck
|
|
47
|
-
skipVisibilityCheck
|
|
48
|
-
} = options;
|
|
49
|
-
if (typeof composed !== "boolean") {
|
|
50
|
-
console.warn("Invalid composed option. Fallback: false.");
|
|
51
|
-
composed = false;
|
|
52
|
-
}
|
|
53
|
-
if (typeof filter !== "undefined" && typeof filter !== "function") {
|
|
54
|
-
console.warn(
|
|
55
|
-
"Invalid filter function. Fallback: no filter function (undefined)."
|
|
56
|
-
);
|
|
57
|
-
filter = void 0;
|
|
58
|
-
}
|
|
59
|
-
if (typeof include !== "undefined" && typeof include !== "function") {
|
|
60
|
-
console.warn(
|
|
61
|
-
"Invalid include function. Fallback: no include function (undefined)."
|
|
62
|
-
);
|
|
63
|
-
include = void 0;
|
|
64
|
-
}
|
|
65
|
-
if (typeof skipNegativeTabIndexCheck !== "boolean") {
|
|
66
|
-
console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
|
|
67
|
-
skipNegativeTabIndexCheck = false;
|
|
68
|
-
}
|
|
69
|
-
if (typeof skipVisibilityCheck !== "boolean") {
|
|
70
|
-
console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
|
|
71
|
-
skipVisibilityCheck = false;
|
|
72
|
-
}
|
|
46
|
+
skipNegativeTabIndexCheck,
|
|
47
|
+
skipVisibilityCheck
|
|
48
|
+
} = resolveOptions(options);
|
|
73
49
|
const candidates = [];
|
|
74
50
|
if (composed || include) {
|
|
75
51
|
let traverse2 = function(node) {
|
|
@@ -119,15 +95,7 @@ function isFocusable(element, options = {}) {
|
|
|
119
95
|
console.warn("Invalid element");
|
|
120
96
|
return false;
|
|
121
97
|
}
|
|
122
|
-
|
|
123
|
-
if (typeof skipNegativeTabIndexCheck !== "boolean") {
|
|
124
|
-
console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
|
|
125
|
-
skipNegativeTabIndexCheck = false;
|
|
126
|
-
}
|
|
127
|
-
if (typeof skipVisibilityCheck !== "boolean") {
|
|
128
|
-
console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
|
|
129
|
-
skipVisibilityCheck = false;
|
|
130
|
-
}
|
|
98
|
+
const { skipNegativeTabIndexCheck, skipVisibilityCheck } = resolveOptions(options);
|
|
131
99
|
if (element.hasAttribute("hidden") || isInert(element)) {
|
|
132
100
|
return false;
|
|
133
101
|
}
|
|
@@ -156,65 +124,30 @@ function getRelativeFocusable(container, offset, options) {
|
|
|
156
124
|
console.warn("Invalid container element. Fallback: <body> element.");
|
|
157
125
|
container = document.body;
|
|
158
126
|
}
|
|
159
|
-
|
|
160
|
-
anchor
|
|
161
|
-
composed
|
|
127
|
+
const {
|
|
128
|
+
anchor,
|
|
129
|
+
composed,
|
|
162
130
|
filter,
|
|
163
131
|
include,
|
|
164
|
-
skipNegativeTabIndexCheck
|
|
165
|
-
skipVisibilityCheck
|
|
166
|
-
wrap
|
|
167
|
-
} = options;
|
|
132
|
+
skipNegativeTabIndexCheck,
|
|
133
|
+
skipVisibilityCheck,
|
|
134
|
+
wrap
|
|
135
|
+
} = resolveOptions(options);
|
|
168
136
|
if (!(anchor instanceof Element)) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
console.warn("Invalid anchor element. Fallback: active element.");
|
|
172
|
-
anchor = active;
|
|
173
|
-
} else {
|
|
174
|
-
console.warn("Invalid anchor element");
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
137
|
+
console.warn("Invalid anchor element");
|
|
138
|
+
return null;
|
|
177
139
|
}
|
|
178
140
|
if (!containsComposed(container, anchor)) {
|
|
179
141
|
console.warn("Anchor (active) element not within container");
|
|
180
142
|
return null;
|
|
181
143
|
}
|
|
182
|
-
|
|
183
|
-
console.warn("Invalid composed option. Fallback: false.");
|
|
184
|
-
composed = false;
|
|
185
|
-
}
|
|
186
|
-
if (typeof filter !== "undefined" && typeof filter !== "function") {
|
|
187
|
-
console.warn(
|
|
188
|
-
"Invalid filter function. Fallback: no filter function (undefined)."
|
|
189
|
-
);
|
|
190
|
-
filter = void 0;
|
|
191
|
-
}
|
|
192
|
-
if (typeof include !== "undefined" && typeof include !== "function") {
|
|
193
|
-
console.warn(
|
|
194
|
-
"Invalid include function. Fallback: no include function (undefined)."
|
|
195
|
-
);
|
|
196
|
-
include = void 0;
|
|
197
|
-
}
|
|
198
|
-
if (typeof skipNegativeTabIndexCheck !== "boolean") {
|
|
199
|
-
console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
|
|
200
|
-
skipNegativeTabIndexCheck = false;
|
|
201
|
-
}
|
|
202
|
-
if (typeof skipVisibilityCheck !== "boolean") {
|
|
203
|
-
console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
|
|
204
|
-
skipVisibilityCheck = false;
|
|
205
|
-
}
|
|
206
|
-
if (typeof wrap !== "boolean") {
|
|
207
|
-
console.warn("Invalid wrap option. Fallback: false.");
|
|
208
|
-
wrap = false;
|
|
209
|
-
}
|
|
210
|
-
const settings = {
|
|
144
|
+
const focusables = getFocusables(container, {
|
|
211
145
|
composed,
|
|
146
|
+
filter,
|
|
147
|
+
include,
|
|
212
148
|
skipNegativeTabIndexCheck,
|
|
213
149
|
skipVisibilityCheck
|
|
214
|
-
};
|
|
215
|
-
filter && Object.assign(settings, { filter });
|
|
216
|
-
include && Object.assign(settings, { include });
|
|
217
|
-
const focusables = getFocusables(container, settings);
|
|
150
|
+
});
|
|
218
151
|
const { length } = focusables;
|
|
219
152
|
if (!length) {
|
|
220
153
|
return null;
|
|
@@ -391,6 +324,61 @@ function isInert(element) {
|
|
|
391
324
|
function isUngroupedRadio(element) {
|
|
392
325
|
return element.type === "radio" && !!element.name;
|
|
393
326
|
}
|
|
327
|
+
function resolveOptions(options) {
|
|
328
|
+
let {
|
|
329
|
+
anchor = getActiveElement(),
|
|
330
|
+
composed = false,
|
|
331
|
+
filter,
|
|
332
|
+
include,
|
|
333
|
+
skipNegativeTabIndexCheck = false,
|
|
334
|
+
skipVisibilityCheck = false,
|
|
335
|
+
wrap = false
|
|
336
|
+
} = options;
|
|
337
|
+
if (!(anchor instanceof Element)) {
|
|
338
|
+
const active = getActiveElement();
|
|
339
|
+
if (active instanceof Element) {
|
|
340
|
+
console.warn("Invalid anchor element. Fallback: active element.");
|
|
341
|
+
anchor = active;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (typeof composed !== "boolean") {
|
|
345
|
+
console.warn("Invalid composed option. Fallback: false.");
|
|
346
|
+
composed = false;
|
|
347
|
+
}
|
|
348
|
+
if (filter !== void 0 && typeof filter !== "function") {
|
|
349
|
+
console.warn(
|
|
350
|
+
"Invalid filter function. Fallback: no filter function (undefined)."
|
|
351
|
+
);
|
|
352
|
+
filter = void 0;
|
|
353
|
+
}
|
|
354
|
+
if (include !== void 0 && typeof include !== "function") {
|
|
355
|
+
console.warn(
|
|
356
|
+
"Invalid include function. Fallback: no include function (undefined)."
|
|
357
|
+
);
|
|
358
|
+
include = void 0;
|
|
359
|
+
}
|
|
360
|
+
if (typeof skipNegativeTabIndexCheck !== "boolean") {
|
|
361
|
+
console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
|
|
362
|
+
skipNegativeTabIndexCheck = false;
|
|
363
|
+
}
|
|
364
|
+
if (typeof skipVisibilityCheck !== "boolean") {
|
|
365
|
+
console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
|
|
366
|
+
skipVisibilityCheck = false;
|
|
367
|
+
}
|
|
368
|
+
if (typeof wrap !== "boolean") {
|
|
369
|
+
console.warn("Invalid wrap option. Fallback: false.");
|
|
370
|
+
wrap = false;
|
|
371
|
+
}
|
|
372
|
+
return {
|
|
373
|
+
anchor,
|
|
374
|
+
composed,
|
|
375
|
+
filter,
|
|
376
|
+
include,
|
|
377
|
+
skipNegativeTabIndexCheck,
|
|
378
|
+
skipVisibilityCheck,
|
|
379
|
+
wrap
|
|
380
|
+
};
|
|
381
|
+
}
|
|
394
382
|
|
|
395
383
|
// src/index.ts
|
|
396
384
|
var VISUALLY_HIDDEN_CSS = `border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;`;
|
|
@@ -429,12 +417,7 @@ var Portal = class {
|
|
|
429
417
|
container = document.body;
|
|
430
418
|
}
|
|
431
419
|
this.#container = container;
|
|
432
|
-
|
|
433
|
-
if (typeof noInlineStyle !== "boolean") {
|
|
434
|
-
console.warn("Invalid noInlineStyle option. Fallback: false.");
|
|
435
|
-
noInlineStyle = false;
|
|
436
|
-
}
|
|
437
|
-
this.#settings = { noInlineStyle };
|
|
420
|
+
this.#settings = resolveOptions2(options);
|
|
438
421
|
this.#entranceSentinel = this.#createSentinel();
|
|
439
422
|
this.#exitSentinel = this.#createSentinel();
|
|
440
423
|
this.#initialize();
|
|
@@ -572,12 +555,20 @@ function containsComposed2(container, element) {
|
|
|
572
555
|
}
|
|
573
556
|
return false;
|
|
574
557
|
}
|
|
558
|
+
function resolveOptions2(options) {
|
|
559
|
+
let { noInlineStyle = false } = options;
|
|
560
|
+
if (typeof noInlineStyle !== "boolean") {
|
|
561
|
+
console.warn("Invalid noInlineStyle option. Fallback: false.");
|
|
562
|
+
noInlineStyle = false;
|
|
563
|
+
}
|
|
564
|
+
return { noInlineStyle };
|
|
565
|
+
}
|
|
575
566
|
/**
|
|
576
567
|
* Portal
|
|
577
568
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
578
569
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
579
570
|
*
|
|
580
|
-
* @version 1.3.
|
|
571
|
+
* @version 1.3.5
|
|
581
572
|
* @author Yusuke Kamiyamane
|
|
582
573
|
* @license MIT
|
|
583
574
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -589,7 +580,7 @@ function containsComposed2(container, element) {
|
|
|
589
580
|
(**
|
|
590
581
|
* Attribute Utils
|
|
591
582
|
*
|
|
592
|
-
* @version 2.0.
|
|
583
|
+
* @version 2.0.8
|
|
593
584
|
* @author Yusuke Kamiyamane
|
|
594
585
|
* @license MIT
|
|
595
586
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -602,7 +593,7 @@ power-focusable/dist/index.js:
|
|
|
602
593
|
* High-precision focus management utility with full composed tree support.
|
|
603
594
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
604
595
|
*
|
|
605
|
-
* @version 4.3.
|
|
596
|
+
* @version 4.3.29
|
|
606
597
|
* @author Yusuke Kamiyamane
|
|
607
598
|
* @license MIT
|
|
608
599
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.bundle.js
CHANGED
|
@@ -37,37 +37,13 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
37
37
|
console.warn("Invalid container element. Fallback: <body> element.");
|
|
38
38
|
container = document.body;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
composed
|
|
40
|
+
const {
|
|
41
|
+
composed,
|
|
42
42
|
filter,
|
|
43
43
|
include,
|
|
44
|
-
skipNegativeTabIndexCheck
|
|
45
|
-
skipVisibilityCheck
|
|
46
|
-
} = options;
|
|
47
|
-
if (typeof composed !== "boolean") {
|
|
48
|
-
console.warn("Invalid composed option. Fallback: false.");
|
|
49
|
-
composed = false;
|
|
50
|
-
}
|
|
51
|
-
if (typeof filter !== "undefined" && typeof filter !== "function") {
|
|
52
|
-
console.warn(
|
|
53
|
-
"Invalid filter function. Fallback: no filter function (undefined)."
|
|
54
|
-
);
|
|
55
|
-
filter = void 0;
|
|
56
|
-
}
|
|
57
|
-
if (typeof include !== "undefined" && typeof include !== "function") {
|
|
58
|
-
console.warn(
|
|
59
|
-
"Invalid include function. Fallback: no include function (undefined)."
|
|
60
|
-
);
|
|
61
|
-
include = void 0;
|
|
62
|
-
}
|
|
63
|
-
if (typeof skipNegativeTabIndexCheck !== "boolean") {
|
|
64
|
-
console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
|
|
65
|
-
skipNegativeTabIndexCheck = false;
|
|
66
|
-
}
|
|
67
|
-
if (typeof skipVisibilityCheck !== "boolean") {
|
|
68
|
-
console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
|
|
69
|
-
skipVisibilityCheck = false;
|
|
70
|
-
}
|
|
44
|
+
skipNegativeTabIndexCheck,
|
|
45
|
+
skipVisibilityCheck
|
|
46
|
+
} = resolveOptions(options);
|
|
71
47
|
const candidates = [];
|
|
72
48
|
if (composed || include) {
|
|
73
49
|
let traverse2 = function(node) {
|
|
@@ -117,15 +93,7 @@ function isFocusable(element, options = {}) {
|
|
|
117
93
|
console.warn("Invalid element");
|
|
118
94
|
return false;
|
|
119
95
|
}
|
|
120
|
-
|
|
121
|
-
if (typeof skipNegativeTabIndexCheck !== "boolean") {
|
|
122
|
-
console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
|
|
123
|
-
skipNegativeTabIndexCheck = false;
|
|
124
|
-
}
|
|
125
|
-
if (typeof skipVisibilityCheck !== "boolean") {
|
|
126
|
-
console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
|
|
127
|
-
skipVisibilityCheck = false;
|
|
128
|
-
}
|
|
96
|
+
const { skipNegativeTabIndexCheck, skipVisibilityCheck } = resolveOptions(options);
|
|
129
97
|
if (element.hasAttribute("hidden") || isInert(element)) {
|
|
130
98
|
return false;
|
|
131
99
|
}
|
|
@@ -154,65 +122,30 @@ function getRelativeFocusable(container, offset, options) {
|
|
|
154
122
|
console.warn("Invalid container element. Fallback: <body> element.");
|
|
155
123
|
container = document.body;
|
|
156
124
|
}
|
|
157
|
-
|
|
158
|
-
anchor
|
|
159
|
-
composed
|
|
125
|
+
const {
|
|
126
|
+
anchor,
|
|
127
|
+
composed,
|
|
160
128
|
filter,
|
|
161
129
|
include,
|
|
162
|
-
skipNegativeTabIndexCheck
|
|
163
|
-
skipVisibilityCheck
|
|
164
|
-
wrap
|
|
165
|
-
} = options;
|
|
130
|
+
skipNegativeTabIndexCheck,
|
|
131
|
+
skipVisibilityCheck,
|
|
132
|
+
wrap
|
|
133
|
+
} = resolveOptions(options);
|
|
166
134
|
if (!(anchor instanceof Element)) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
console.warn("Invalid anchor element. Fallback: active element.");
|
|
170
|
-
anchor = active;
|
|
171
|
-
} else {
|
|
172
|
-
console.warn("Invalid anchor element");
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
135
|
+
console.warn("Invalid anchor element");
|
|
136
|
+
return null;
|
|
175
137
|
}
|
|
176
138
|
if (!containsComposed(container, anchor)) {
|
|
177
139
|
console.warn("Anchor (active) element not within container");
|
|
178
140
|
return null;
|
|
179
141
|
}
|
|
180
|
-
|
|
181
|
-
console.warn("Invalid composed option. Fallback: false.");
|
|
182
|
-
composed = false;
|
|
183
|
-
}
|
|
184
|
-
if (typeof filter !== "undefined" && typeof filter !== "function") {
|
|
185
|
-
console.warn(
|
|
186
|
-
"Invalid filter function. Fallback: no filter function (undefined)."
|
|
187
|
-
);
|
|
188
|
-
filter = void 0;
|
|
189
|
-
}
|
|
190
|
-
if (typeof include !== "undefined" && typeof include !== "function") {
|
|
191
|
-
console.warn(
|
|
192
|
-
"Invalid include function. Fallback: no include function (undefined)."
|
|
193
|
-
);
|
|
194
|
-
include = void 0;
|
|
195
|
-
}
|
|
196
|
-
if (typeof skipNegativeTabIndexCheck !== "boolean") {
|
|
197
|
-
console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
|
|
198
|
-
skipNegativeTabIndexCheck = false;
|
|
199
|
-
}
|
|
200
|
-
if (typeof skipVisibilityCheck !== "boolean") {
|
|
201
|
-
console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
|
|
202
|
-
skipVisibilityCheck = false;
|
|
203
|
-
}
|
|
204
|
-
if (typeof wrap !== "boolean") {
|
|
205
|
-
console.warn("Invalid wrap option. Fallback: false.");
|
|
206
|
-
wrap = false;
|
|
207
|
-
}
|
|
208
|
-
const settings = {
|
|
142
|
+
const focusables = getFocusables(container, {
|
|
209
143
|
composed,
|
|
144
|
+
filter,
|
|
145
|
+
include,
|
|
210
146
|
skipNegativeTabIndexCheck,
|
|
211
147
|
skipVisibilityCheck
|
|
212
|
-
};
|
|
213
|
-
filter && Object.assign(settings, { filter });
|
|
214
|
-
include && Object.assign(settings, { include });
|
|
215
|
-
const focusables = getFocusables(container, settings);
|
|
148
|
+
});
|
|
216
149
|
const { length } = focusables;
|
|
217
150
|
if (!length) {
|
|
218
151
|
return null;
|
|
@@ -389,6 +322,61 @@ function isInert(element) {
|
|
|
389
322
|
function isUngroupedRadio(element) {
|
|
390
323
|
return element.type === "radio" && !!element.name;
|
|
391
324
|
}
|
|
325
|
+
function resolveOptions(options) {
|
|
326
|
+
let {
|
|
327
|
+
anchor = getActiveElement(),
|
|
328
|
+
composed = false,
|
|
329
|
+
filter,
|
|
330
|
+
include,
|
|
331
|
+
skipNegativeTabIndexCheck = false,
|
|
332
|
+
skipVisibilityCheck = false,
|
|
333
|
+
wrap = false
|
|
334
|
+
} = options;
|
|
335
|
+
if (!(anchor instanceof Element)) {
|
|
336
|
+
const active = getActiveElement();
|
|
337
|
+
if (active instanceof Element) {
|
|
338
|
+
console.warn("Invalid anchor element. Fallback: active element.");
|
|
339
|
+
anchor = active;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (typeof composed !== "boolean") {
|
|
343
|
+
console.warn("Invalid composed option. Fallback: false.");
|
|
344
|
+
composed = false;
|
|
345
|
+
}
|
|
346
|
+
if (filter !== void 0 && typeof filter !== "function") {
|
|
347
|
+
console.warn(
|
|
348
|
+
"Invalid filter function. Fallback: no filter function (undefined)."
|
|
349
|
+
);
|
|
350
|
+
filter = void 0;
|
|
351
|
+
}
|
|
352
|
+
if (include !== void 0 && typeof include !== "function") {
|
|
353
|
+
console.warn(
|
|
354
|
+
"Invalid include function. Fallback: no include function (undefined)."
|
|
355
|
+
);
|
|
356
|
+
include = void 0;
|
|
357
|
+
}
|
|
358
|
+
if (typeof skipNegativeTabIndexCheck !== "boolean") {
|
|
359
|
+
console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
|
|
360
|
+
skipNegativeTabIndexCheck = false;
|
|
361
|
+
}
|
|
362
|
+
if (typeof skipVisibilityCheck !== "boolean") {
|
|
363
|
+
console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
|
|
364
|
+
skipVisibilityCheck = false;
|
|
365
|
+
}
|
|
366
|
+
if (typeof wrap !== "boolean") {
|
|
367
|
+
console.warn("Invalid wrap option. Fallback: false.");
|
|
368
|
+
wrap = false;
|
|
369
|
+
}
|
|
370
|
+
return {
|
|
371
|
+
anchor,
|
|
372
|
+
composed,
|
|
373
|
+
filter,
|
|
374
|
+
include,
|
|
375
|
+
skipNegativeTabIndexCheck,
|
|
376
|
+
skipVisibilityCheck,
|
|
377
|
+
wrap
|
|
378
|
+
};
|
|
379
|
+
}
|
|
392
380
|
|
|
393
381
|
// src/index.ts
|
|
394
382
|
var VISUALLY_HIDDEN_CSS = `border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;`;
|
|
@@ -427,12 +415,7 @@ var Portal = class {
|
|
|
427
415
|
container = document.body;
|
|
428
416
|
}
|
|
429
417
|
this.#container = container;
|
|
430
|
-
|
|
431
|
-
if (typeof noInlineStyle !== "boolean") {
|
|
432
|
-
console.warn("Invalid noInlineStyle option. Fallback: false.");
|
|
433
|
-
noInlineStyle = false;
|
|
434
|
-
}
|
|
435
|
-
this.#settings = { noInlineStyle };
|
|
418
|
+
this.#settings = resolveOptions2(options);
|
|
436
419
|
this.#entranceSentinel = this.#createSentinel();
|
|
437
420
|
this.#exitSentinel = this.#createSentinel();
|
|
438
421
|
this.#initialize();
|
|
@@ -570,12 +553,20 @@ function containsComposed2(container, element) {
|
|
|
570
553
|
}
|
|
571
554
|
return false;
|
|
572
555
|
}
|
|
556
|
+
function resolveOptions2(options) {
|
|
557
|
+
let { noInlineStyle = false } = options;
|
|
558
|
+
if (typeof noInlineStyle !== "boolean") {
|
|
559
|
+
console.warn("Invalid noInlineStyle option. Fallback: false.");
|
|
560
|
+
noInlineStyle = false;
|
|
561
|
+
}
|
|
562
|
+
return { noInlineStyle };
|
|
563
|
+
}
|
|
573
564
|
/**
|
|
574
565
|
* Portal
|
|
575
566
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
576
567
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
577
568
|
*
|
|
578
|
-
* @version 1.3.
|
|
569
|
+
* @version 1.3.5
|
|
579
570
|
* @author Yusuke Kamiyamane
|
|
580
571
|
* @license MIT
|
|
581
572
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -587,7 +578,7 @@ function containsComposed2(container, element) {
|
|
|
587
578
|
(**
|
|
588
579
|
* Attribute Utils
|
|
589
580
|
*
|
|
590
|
-
* @version 2.0.
|
|
581
|
+
* @version 2.0.8
|
|
591
582
|
* @author Yusuke Kamiyamane
|
|
592
583
|
* @license MIT
|
|
593
584
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -600,7 +591,7 @@ power-focusable/dist/index.js:
|
|
|
600
591
|
* High-precision focus management utility with full composed tree support.
|
|
601
592
|
* Handles complex focus rules including tabindex ordering, radio groups, inert.
|
|
602
593
|
*
|
|
603
|
-
* @version 4.3.
|
|
594
|
+
* @version 4.3.29
|
|
604
595
|
* @author Yusuke Kamiyamane
|
|
605
596
|
* @license MIT
|
|
606
597
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.cjs
CHANGED
|
@@ -61,12 +61,7 @@ var Portal = class {
|
|
|
61
61
|
container = document.body;
|
|
62
62
|
}
|
|
63
63
|
this.#container = container;
|
|
64
|
-
|
|
65
|
-
if (typeof noInlineStyle !== "boolean") {
|
|
66
|
-
console.warn("Invalid noInlineStyle option. Fallback: false.");
|
|
67
|
-
noInlineStyle = false;
|
|
68
|
-
}
|
|
69
|
-
this.#settings = { noInlineStyle };
|
|
64
|
+
this.#settings = resolveOptions(options);
|
|
70
65
|
this.#entranceSentinel = this.#createSentinel();
|
|
71
66
|
this.#exitSentinel = this.#createSentinel();
|
|
72
67
|
this.#initialize();
|
|
@@ -204,12 +199,20 @@ function containsComposed(container, element) {
|
|
|
204
199
|
}
|
|
205
200
|
return false;
|
|
206
201
|
}
|
|
202
|
+
function resolveOptions(options) {
|
|
203
|
+
let { noInlineStyle = false } = options;
|
|
204
|
+
if (typeof noInlineStyle !== "boolean") {
|
|
205
|
+
console.warn("Invalid noInlineStyle option. Fallback: false.");
|
|
206
|
+
noInlineStyle = false;
|
|
207
|
+
}
|
|
208
|
+
return { noInlineStyle };
|
|
209
|
+
}
|
|
207
210
|
/**
|
|
208
211
|
* Portal
|
|
209
212
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
210
213
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
211
214
|
*
|
|
212
|
-
* @version 1.3.
|
|
215
|
+
* @version 1.3.5
|
|
213
216
|
* @author Yusuke Kamiyamane
|
|
214
217
|
* @license MIT
|
|
215
218
|
* @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.3.
|
|
6
|
+
* @version 1.3.5
|
|
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.3.
|
|
6
|
+
* @version 1.3.5
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -38,12 +38,7 @@ var Portal = class {
|
|
|
38
38
|
container = document.body;
|
|
39
39
|
}
|
|
40
40
|
this.#container = container;
|
|
41
|
-
|
|
42
|
-
if (typeof noInlineStyle !== "boolean") {
|
|
43
|
-
console.warn("Invalid noInlineStyle option. Fallback: false.");
|
|
44
|
-
noInlineStyle = false;
|
|
45
|
-
}
|
|
46
|
-
this.#settings = { noInlineStyle };
|
|
41
|
+
this.#settings = resolveOptions(options);
|
|
47
42
|
this.#entranceSentinel = this.#createSentinel();
|
|
48
43
|
this.#exitSentinel = this.#createSentinel();
|
|
49
44
|
this.#initialize();
|
|
@@ -181,12 +176,20 @@ function containsComposed(container, element) {
|
|
|
181
176
|
}
|
|
182
177
|
return false;
|
|
183
178
|
}
|
|
179
|
+
function resolveOptions(options) {
|
|
180
|
+
let { noInlineStyle = false } = options;
|
|
181
|
+
if (typeof noInlineStyle !== "boolean") {
|
|
182
|
+
console.warn("Invalid noInlineStyle option. Fallback: false.");
|
|
183
|
+
noInlineStyle = false;
|
|
184
|
+
}
|
|
185
|
+
return { noInlineStyle };
|
|
186
|
+
}
|
|
184
187
|
/**
|
|
185
188
|
* Portal
|
|
186
189
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
187
190
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
188
191
|
*
|
|
189
|
-
* @version 1.3.
|
|
192
|
+
* @version 1.3.5
|
|
190
193
|
* @author Yusuke Kamiyamane
|
|
191
194
|
* @license MIT
|
|
192
195
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/package.json
CHANGED
|
@@ -1,28 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y14e/portal",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "Lightweight DOM portal (teleport) utility with fully focus management",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.cjs",
|
|
7
|
-
"module": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.js",
|
|
13
|
-
"require": "./dist/index.cjs"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"dist",
|
|
18
|
-
"LICENSE",
|
|
19
|
-
"README.md"
|
|
20
|
-
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "tsup",
|
|
23
|
-
"prepublishOnly": "npm run build",
|
|
24
|
-
"lint": "tsc --noEmit"
|
|
25
|
-
},
|
|
26
5
|
"keywords": [
|
|
27
6
|
"a11y",
|
|
28
7
|
"accessibility",
|
|
@@ -36,16 +15,41 @@
|
|
|
36
15
|
"typescript",
|
|
37
16
|
"utility"
|
|
38
17
|
],
|
|
39
|
-
"
|
|
40
|
-
"
|
|
18
|
+
"homepage": "https://github.com/y14e/portal#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/y14e/portal/issues"
|
|
21
|
+
},
|
|
41
22
|
"repository": {
|
|
42
23
|
"type": "git",
|
|
43
24
|
"url": "git+https://github.com/y14e/portal.git"
|
|
44
25
|
},
|
|
45
|
-
"
|
|
46
|
-
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"author": "Yusuke Kamiyamane",
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"require": "./dist/index.cjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"main": "./dist/index.cjs",
|
|
37
|
+
"module": "./dist/index.js",
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"LICENSE",
|
|
42
|
+
"README.md"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsup",
|
|
46
|
+
"lint": "tsc --noEmit",
|
|
47
|
+
"prepublishOnly": "npm run build"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@y14e/attribute-utils": "^2.0.8",
|
|
51
|
+
"power-focusable": "^4.3.29"
|
|
47
52
|
},
|
|
48
|
-
"homepage": "https://github.com/y14e/portal#readme",
|
|
49
53
|
"devDependencies": {
|
|
50
54
|
"bun-types": "latest",
|
|
51
55
|
"tsup": "^8.0.0",
|
|
@@ -56,9 +60,5 @@
|
|
|
56
60
|
},
|
|
57
61
|
"allowScripts": {
|
|
58
62
|
"esbuild": true
|
|
59
|
-
},
|
|
60
|
-
"dependencies": {
|
|
61
|
-
"@y14e/attribute-utils": "^2.0.5",
|
|
62
|
-
"power-focusable": "^4.3.26"
|
|
63
63
|
}
|
|
64
64
|
}
|