@t007/dialog 0.0.35 → 0.0.37
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.css +0 -1
- package/dist/index.global.js +34 -12
- package/package.json +2 -2
package/dist/index.css
CHANGED
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({});
|
|
@@ -60,8 +60,30 @@
|
|
|
60
60
|
isDevEnv = process.env.NODE_ENV !== "production";
|
|
61
61
|
} catch (e) {
|
|
62
62
|
}
|
|
63
|
+
var CTX_BUILD = {
|
|
64
|
+
/** Flag indicating whether the application is running in development mode. */
|
|
65
|
+
isDevEnv,
|
|
66
|
+
/** Flag indicating whether an operation is bypassing checks so reactors can allow all writes. */
|
|
67
|
+
usingForce: false,
|
|
68
|
+
/** Active `Autotracker` instance, override for automatic dependency collection on `Reactor` traps. */
|
|
69
|
+
autotracker: null,
|
|
70
|
+
/** Extensible meta context for payloads and cross-cutting concerns. */
|
|
71
|
+
meta: null,
|
|
72
|
+
/** Default configuration for new `Reactor` instances and also fallback for utils that need and are called without these options. */
|
|
73
|
+
defaults: {
|
|
74
|
+
crossRealms: false,
|
|
75
|
+
smartCloning: false,
|
|
76
|
+
eventBubbling: true,
|
|
77
|
+
eventCapturing: "auto",
|
|
78
|
+
lineageTracing: false,
|
|
79
|
+
preserveContext: false,
|
|
80
|
+
equalityFunction: Object.is,
|
|
81
|
+
batchingFunction: RTR_BATCH
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var CTX = globalThis[/* @__PURE__ */ Symbol.for("S.I.A_CTX")] ??= CTX_BUILD;
|
|
63
85
|
|
|
64
|
-
// ../utils/dist/chunk-
|
|
86
|
+
// ../utils/dist/chunk-ZFW6HNGO.js
|
|
65
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] *)";
|
|
66
88
|
var isInteractive = (target) => target instanceof HTMLElement && target.matches(INTERACTIVE_SELECTOR);
|
|
67
89
|
var VIRTUAL_RESOURCE = /* @__PURE__ */ Symbol.for("T007_VIRTUAL_RESOURCE");
|
|
@@ -133,7 +155,7 @@
|
|
|
133
155
|
window.T007_DIALOG_CSS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/dialog@latest/dist/index.min.css`;
|
|
134
156
|
}
|
|
135
157
|
|
|
136
|
-
// ../utils/dist/chunk-
|
|
158
|
+
// ../utils/dist/chunk-GCJ5LPEB.js
|
|
137
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) {
|
|
138
160
|
const stack = t007._outsiders_stack ??= [], existing = (t007._outsiders ??= /* @__PURE__ */ new WeakMap()).get(el);
|
|
139
161
|
if (!enabled || existing) return existing ? existing : void 0;
|
|
@@ -154,20 +176,20 @@
|
|
|
154
176
|
return !stack.includes(el) && stack.push(el), t007._outsiders.set(el, destroy), destroy;
|
|
155
177
|
}
|
|
156
178
|
var removeOutsideClick = (el) => t007._outsiders?.get(el)?.();
|
|
157
|
-
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) {
|
|
158
180
|
const stack = t007._ftrappers_stack ??= [], existing = (t007._ftrappers ??= /* @__PURE__ */ new WeakMap()).get(el);
|
|
159
181
|
if (!enabled || existing) return existing ? existing : void 0;
|
|
160
182
|
scoped = scoped && root instanceof HTMLElement, root = scoped ? root : root === document ? document : window;
|
|
161
183
|
let recovering = false;
|
|
162
|
-
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) => {
|
|
163
185
|
if (!scoped) return resetFocus(pre ? -1 : 0);
|
|
164
|
-
if (rt.hasAttribute("tabindex")) return rt.focus();
|
|
186
|
+
if (rt.hasAttribute("tabindex")) return rt.focus(focusOptions);
|
|
165
187
|
const items = getFocusable();
|
|
166
188
|
if (!items.length) return resetFocus(0, null);
|
|
167
189
|
const ceil = document.fullscreenElement || document.querySelector("dialog:modal") || document.body;
|
|
168
190
|
let p = rt.parentElement || ceil, all = getFocusable(p);
|
|
169
191
|
while (p !== ceil && (!all.length || (pre ? rt.contains(all[0]) : rt.contains(all.at(-1))))) all = getFocusable(p = p.parentElement || ceil);
|
|
170
|
-
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);
|
|
171
193
|
(pre ? first : last).blur();
|
|
172
194
|
}, handleFocusIn = (e) => {
|
|
173
195
|
if (document.querySelector("dialog:modal") && !el.matches("dialog:modal")) return;
|
|
@@ -176,9 +198,9 @@
|
|
|
176
198
|
first.addEventListener("focus", (e) => el.contains(e.relatedTarget) ? edgeFocus(true) : resetFocus(), capture), el.prepend(first);
|
|
177
199
|
last.addEventListener("focus", (e) => el.contains(e.relatedTarget) ? edgeFocus() : resetFocus(-1), capture), el.append(last);
|
|
178
200
|
root.addEventListener("focusin", handleFocusIn, capture);
|
|
179
|
-
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)));
|
|
180
202
|
const destroy = () => {
|
|
181
|
-
focused?.isConnected && focused.focus(), first.remove(), last.remove();
|
|
203
|
+
focused?.isConnected && focused.focus(focusOptions), first.remove(), last.remove();
|
|
182
204
|
root.removeEventListener("focusin", handleFocusIn, capture);
|
|
183
205
|
initial?.removeEventListener("blur", handleInitialBlur, capture);
|
|
184
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.37",
|
|
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.38"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"esbuild-sass-plugin": "^3.7.0"
|