@t007/dialog 0.0.36 → 0.0.38
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.global.js +12 -12
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
return Math.min(Math.max(val, min), max);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
// ../../../sia-reactor/dist/chunk-
|
|
8
|
+
// ../../../sia-reactor/dist/chunk-PJTPFVEG.js
|
|
9
9
|
function onAllMethods(owner, callback, skipOwn = true, nested = false) {
|
|
10
10
|
let proto = owner;
|
|
11
11
|
while (proto && proto !== Object.prototype) {
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
}
|
|
45
45
|
return el;
|
|
46
46
|
}
|
|
47
|
-
function getActiveEl(root) {
|
|
47
|
+
function getActiveEl(root, noBody = true) {
|
|
48
48
|
const activeEl = (root ?? document).activeElement;
|
|
49
|
-
return !activeEl ? null : activeEl.shadowRoot ? getActiveEl(activeEl.shadowRoot) : activeEl;
|
|
49
|
+
return !activeEl || noBody && activeEl === document.body ? null : activeEl.shadowRoot ? getActiveEl(activeEl.shadowRoot) : activeEl;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
// ../../../sia-reactor/dist/chunk-
|
|
52
|
+
// ../../../sia-reactor/dist/chunk-LZJYX2LE.js
|
|
53
53
|
var RTR_BATCH = "undefined" !== typeof window ? ("undefined" !== typeof queueMicrotask ? queueMicrotask : setTimeout).bind(window) : "undefined" !== typeof process && process.nextTick ? process.nextTick : setTimeout;
|
|
54
54
|
var RTR_LOG = console.log.bind(console, "[S.I.A Reactor]");
|
|
55
55
|
var NIL = Object.freeze({});
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
};
|
|
84
84
|
var CTX = globalThis[/* @__PURE__ */ Symbol.for("S.I.A_CTX")] ??= CTX_BUILD;
|
|
85
85
|
|
|
86
|
-
// ../utils/dist/chunk-
|
|
86
|
+
// ../utils/dist/chunk-ZFW6HNGO.js
|
|
87
87
|
var INTERACTIVE_SELECTOR = ":is(button,[href],input:not([type='hidden']),select,textarea,details>summary,[contenteditable],iframe,audio[controls],video[controls],[tabindex]):not([disabled],[tabindex='-1'],[data-focus-guard],[inert],[inert] *)";
|
|
88
88
|
var isInteractive = (target) => target instanceof HTMLElement && target.matches(INTERACTIVE_SELECTOR);
|
|
89
89
|
var VIRTUAL_RESOURCE = /* @__PURE__ */ Symbol.for("T007_VIRTUAL_RESOURCE");
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
window.T007_DIALOG_CSS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/dialog@latest/dist/index.min.css`;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
// ../utils/dist/chunk-
|
|
158
|
+
// ../utils/dist/chunk-GCJ5LPEB.js
|
|
159
159
|
function initOutsideClick(el, { enabled = false, onOutside = NOOP, outOnClick = true, outOnEscape = true, outOnFocusOut = false, allowBounds = false, allowInputs = false, root = window, scoped = true, capture = true } = NIL) {
|
|
160
160
|
const stack = t007._outsiders_stack ??= [], existing = (t007._outsiders ??= /* @__PURE__ */ new WeakMap()).get(el);
|
|
161
161
|
if (!enabled || existing) return existing ? existing : void 0;
|
|
@@ -176,20 +176,20 @@
|
|
|
176
176
|
return !stack.includes(el) && stack.push(el), t007._outsiders.set(el, destroy), destroy;
|
|
177
177
|
}
|
|
178
178
|
var removeOutsideClick = (el) => t007._outsiders?.get(el)?.();
|
|
179
|
-
function initFocusTrap(el, { enabled = false, initialSelector = "[data-autofocus]", ringClassName = "focus-outline", root = window, scoped = true, capture = true } = NIL) {
|
|
179
|
+
function initFocusTrap(el, { enabled = false, initialSelector = "[data-autofocus]", ringClassName = "focus-outline", root = window, scoped = true, capture = true, focusOptions } = NIL) {
|
|
180
180
|
const stack = t007._ftrappers_stack ??= [], existing = (t007._ftrappers ??= /* @__PURE__ */ new WeakMap()).get(el);
|
|
181
181
|
if (!enabled || existing) return existing ? existing : void 0;
|
|
182
182
|
scoped = scoped && root instanceof HTMLElement, root = scoped ? root : root === document ? document : window;
|
|
183
183
|
let recovering = false;
|
|
184
|
-
const focused = document.querySelector(":focus"), initial = el.querySelector(initialSelector), first = createEl("span", { tabIndex: 0 }, { focusGuard: "start" }, { position: "absolute", width: "0", height: "0", pointerEvents: "none" }), last = createEl("span", { tabIndex: 0 }, { focusGuard: "end" }, { position: "absolute", width: "0", height: "0", pointerEvents: "none" }), getFocusable = (c = el) => [...c.querySelectorAll(INTERACTIVE_SELECTOR)], resetFocus = (i = 0, els = getFocusable()) => !recovering && (recovering = true, els?.length ? els.at(i).focus() : (!el.hasAttribute("tabindex") && (el.tabIndex = -1), el.focus()), recovering = false), edgeFocus = (pre = false, rt = root) => {
|
|
184
|
+
const focused = document.querySelector(":focus"), initial = el.querySelector(initialSelector), first = createEl("span", { tabIndex: 0 }, { focusGuard: "start" }, { position: "absolute", width: "0", height: "0", pointerEvents: "none" }), last = createEl("span", { tabIndex: 0 }, { focusGuard: "end" }, { position: "absolute", width: "0", height: "0", pointerEvents: "none" }), getFocusable = (c = el) => [...c.querySelectorAll(INTERACTIVE_SELECTOR)], resetFocus = (i = 0, els = getFocusable()) => !recovering && (recovering = true, els?.length ? els.at(i).focus(focusOptions) : (!el.hasAttribute("tabindex") && (el.tabIndex = -1), el.focus(focusOptions)), recovering = false), edgeFocus = (pre = false, rt = root) => {
|
|
185
185
|
if (!scoped) return resetFocus(pre ? -1 : 0);
|
|
186
|
-
if (rt.hasAttribute("tabindex")) return rt.focus();
|
|
186
|
+
if (rt.hasAttribute("tabindex")) return rt.focus(focusOptions);
|
|
187
187
|
const items = getFocusable();
|
|
188
188
|
if (!items.length) return resetFocus(0, null);
|
|
189
189
|
const ceil = document.fullscreenElement || document.querySelector("dialog:modal") || document.body;
|
|
190
190
|
let p = rt.parentElement || ceil, all = getFocusable(p);
|
|
191
191
|
while (p !== ceil && (!all.length || (pre ? rt.contains(all[0]) : rt.contains(all.at(-1))))) all = getFocusable(p = p.parentElement || ceil);
|
|
192
|
-
for (let target, len = all.length, i = all.indexOf(items[pre ? 0 : items.length - 1]) + (pre ? -1 : 1); pre ? i >= 0 : i < len; pre ? i-- : i++) if (!rt.contains(target = all[i])) return target.focus();
|
|
192
|
+
for (let target, len = all.length, i = all.indexOf(items[pre ? 0 : items.length - 1]) + (pre ? -1 : 1); pre ? i >= 0 : i < len; pre ? i-- : i++) if (!rt.contains(target = all[i])) return target.focus(focusOptions);
|
|
193
193
|
(pre ? first : last).blur();
|
|
194
194
|
}, handleFocusIn = (e) => {
|
|
195
195
|
if (document.querySelector("dialog:modal") && !el.matches("dialog:modal")) return;
|
|
@@ -198,9 +198,9 @@
|
|
|
198
198
|
first.addEventListener("focus", (e) => el.contains(e.relatedTarget) ? edgeFocus(true) : resetFocus(), capture), el.prepend(first);
|
|
199
199
|
last.addEventListener("focus", (e) => el.contains(e.relatedTarget) ? edgeFocus() : resetFocus(-1), capture), el.append(last);
|
|
200
200
|
root.addEventListener("focusin", handleFocusIn, capture);
|
|
201
|
-
if (initial || !el.contains(focused)) !initial ? setTimeout(resetFocus) : setTimeout(() => (initial.classList.add(ringClassName), initial.focus(), initial.addEventListener("blur", handleInitialBlur, capture)));
|
|
201
|
+
if (initial || !el.contains(focused)) !initial ? setTimeout(resetFocus) : setTimeout(() => (initial.classList.add(ringClassName), initial.focus(focusOptions), initial.addEventListener("blur", handleInitialBlur, capture)));
|
|
202
202
|
const destroy = () => {
|
|
203
|
-
focused?.isConnected && focused.focus(), first.remove(), last.remove();
|
|
203
|
+
focused?.isConnected && focused.focus(focusOptions), first.remove(), last.remove();
|
|
204
204
|
root.removeEventListener("focusin", handleFocusIn, capture);
|
|
205
205
|
initial?.removeEventListener("blur", handleInitialBlur, capture);
|
|
206
206
|
t007._ftrappers.delete(el), stack.splice(stack.indexOf(el), 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t007/dialog",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.38",
|
|
4
4
|
"description": "A lightweight, pure JS dialog system.",
|
|
5
5
|
"author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"accessible"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@t007/utils": "^0.0.
|
|
60
|
+
"@t007/utils": "^0.0.39"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"esbuild-sass-plugin": "^3.7.0"
|