@t007/dialog 0.0.27 → 0.0.29
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 +3 -2
- package/dist/index.global.js +24 -20
- package/dist/index.js +5 -5
- package/package.json +2 -2
package/dist/index.css
CHANGED
|
@@ -83,10 +83,11 @@
|
|
|
83
83
|
cursor: pointer;
|
|
84
84
|
filter: brightness(1.15);
|
|
85
85
|
}
|
|
86
|
-
:
|
|
86
|
+
html:has(> body > .t007-dialog),
|
|
87
|
+
body:has(> .t007-dialog) {
|
|
87
88
|
overflow: hidden;
|
|
88
89
|
}
|
|
89
|
-
body:has(.t007-dialog) {
|
|
90
|
+
body:has(> .t007-dialog) {
|
|
90
91
|
overflow-y: visible;
|
|
91
92
|
}
|
|
92
93
|
*:where(:has(> .t007-dialog.t007-dialog-scoped)) {
|
package/dist/index.global.js
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// ../../../sia-reactor/dist/chunk-
|
|
47
|
+
// ../../../sia-reactor/dist/chunk-4PLMBUCP.js
|
|
48
48
|
var CTX = {
|
|
49
49
|
/** Flag indicating whether the application is running in development mode. */
|
|
50
50
|
isDevEnv: "undefined" !== typeof process ? process.env.NODE_ENV !== "production" : true,
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
var NOOP = () => {
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
// ../utils/dist/chunk-
|
|
62
|
+
// ../utils/dist/chunk-4O76EZJ4.js
|
|
63
63
|
var INTERACTIVE_SELECTOR = ":is(button,[href],input:not([type='hidden']),select,textarea,details>summary,[contenteditable='true'],iframe,audio[controls],video[controls],[tabindex]):not([disabled],[tabindex='-1'],[data-focus-guard],[inert],[inert] *)";
|
|
64
64
|
var isInteractive = (target) => target instanceof HTMLElement && target.matches(INTERACTIVE_SELECTOR);
|
|
65
65
|
var VIRTUAL_RESOURCE = /* @__PURE__ */ Symbol.for("T007_VIRTUAL_RESOURCE");
|
|
@@ -105,15 +105,18 @@
|
|
|
105
105
|
function parseCSSTime(time) {
|
|
106
106
|
return time?.endsWith?.("ms") ? parseFloat(time) : parseFloat(time) * 1e3;
|
|
107
107
|
}
|
|
108
|
-
function
|
|
109
|
-
if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
|
|
108
|
+
function cleanURL(url) {
|
|
110
109
|
try {
|
|
111
|
-
const
|
|
112
|
-
return decodeURIComponent(
|
|
110
|
+
const u = new URL(url, window.location.href);
|
|
111
|
+
return decodeURIComponent(u.origin + u.pathname);
|
|
113
112
|
} catch {
|
|
114
|
-
return
|
|
113
|
+
return url.replace(/\\/g, "/").split("?")[0].trim();
|
|
115
114
|
}
|
|
116
115
|
}
|
|
116
|
+
function isSameURL(url1, url2) {
|
|
117
|
+
if (!isStr(url1) || !isStr(url2) || !url1 || !url2) return false;
|
|
118
|
+
return cleanURL(url1) === cleanURL(url2);
|
|
119
|
+
}
|
|
117
120
|
if ("undefined" !== typeof window) {
|
|
118
121
|
(window.t007 ??= {}).VIRTUAL_RESOURCE = VIRTUAL_RESOURCE;
|
|
119
122
|
window.T007_TOAST_JS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/toast@latest`;
|
|
@@ -124,17 +127,18 @@
|
|
|
124
127
|
window.T007_DIALOG_CSS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/dialog@latest/dist/index.min.css`;
|
|
125
128
|
}
|
|
126
129
|
|
|
127
|
-
// ../utils/dist/chunk-
|
|
128
|
-
function initOutsideClick(el, { enabled = false,
|
|
130
|
+
// ../utils/dist/chunk-QJ72EQCJ.js
|
|
131
|
+
function initOutsideClick(el, { enabled = false, onOutside = NOOP, outOnClick = true, outOnEscape = true, outOnFocusOut = false, allowBounds = false, allowInputs = false, root = window, scoped = true, capture = true } = NIL) {
|
|
129
132
|
const stacks = t007._outsiders_stacks ??= /* @__PURE__ */ new WeakMap(), existing = (t007._outsiders ??= /* @__PURE__ */ new WeakMap()).get(el);
|
|
130
133
|
if (!enabled || existing) return existing ? existing : void 0;
|
|
131
134
|
scoped = scoped && root instanceof HTMLElement, root = scoped ? root : root === document ? document : window;
|
|
132
|
-
const stack = stacks.get(root) ?? [], onScopedOut = (e, t, p = e.touches?.[0] || e, rect = el.getBoundingClientRect()) => {
|
|
133
|
-
if (stack.at(-1) !== el || p.clientX >= rect.left && p.clientX <= rect.right && p.clientY >= rect.top && p.clientY <= rect.bottom) return false;
|
|
134
|
-
return (!scoped ? true : root.contains(t)) &&
|
|
135
|
-
}, handleClick = ((e) => outOnClick && !(allowInputs && isInteractive(e.target)) && onScopedOut(e, e.target)), handleEscape = ((e) => outOnEscape && e.key === "Escape" && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey && stack.at(-1) === el &&
|
|
135
|
+
const stack = stacks.get(root) ?? [], onScopedOut = (e, t, p = e.touches?.[0] || e, rect = allowBounds ? el.getBoundingClientRect() : null) => {
|
|
136
|
+
if (stack.at(-1) !== el || (allowBounds ? p.clientX >= rect.left && p.clientX <= rect.right && p.clientY >= rect.top && p.clientY <= rect.bottom : el.contains(t))) return false;
|
|
137
|
+
return (!scoped ? true : root.contains(t)) && onOutside(e);
|
|
138
|
+
}, handleClick = ((e) => outOnClick && !(allowInputs && isInteractive(e.target)) && onScopedOut(e, e.target)), handleEscape = ((e) => outOnEscape && e.key === "Escape" && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey && stack.at(-1) === el && onOutside(e)), handleFocusOut = (e) => outOnFocusOut && !el.contains(e.relatedTarget) && onScopedOut(e, e.relatedTarget);
|
|
136
139
|
root.addEventListener("mousedown", handleClick, capture), root.addEventListener("touchstart", handleClick, { passive: true, capture });
|
|
137
|
-
root.addEventListener("keydown", handleEscape, capture)
|
|
140
|
+
root.addEventListener("keydown", handleEscape, capture);
|
|
141
|
+
el.addEventListener("focusout", handleFocusOut, capture);
|
|
138
142
|
if (!stack.includes(el)) stack.push(el), stacks.set(root, stack);
|
|
139
143
|
const destroy = () => {
|
|
140
144
|
root.removeEventListener("mousedown", handleClick, capture), root.removeEventListener("touchstart", handleClick, capture);
|
|
@@ -166,7 +170,7 @@
|
|
|
166
170
|
first.addEventListener("focus", (e) => el.contains(e.relatedTarget) ? edgeFocus(true) : resetFocus(), capture), el.prepend(first);
|
|
167
171
|
last.addEventListener("focus", (e) => el.contains(e.relatedTarget) ? edgeFocus() : resetFocus(-1), capture), el.append(last);
|
|
168
172
|
root.addEventListener("focusin", handleFocusIn, capture);
|
|
169
|
-
if (!el.
|
|
173
|
+
if (initial || !el.contains(focused)) !initial ? setTimeout(resetFocus) : setTimeout(() => (initial.classList.add(ringClassName), initial.focus(), initial.addEventListener("blur", handleInitialBlur, capture)));
|
|
170
174
|
if (!stack.includes(el)) stack.push(el), stacks.set(root, stack);
|
|
171
175
|
const destroy = () => {
|
|
172
176
|
focused?.isConnected && focused.focus(), first.remove(), last.remove();
|
|
@@ -363,10 +367,10 @@
|
|
|
363
367
|
this.resolve = resolve;
|
|
364
368
|
t007.dialogs.set(this.id = id ?? uid("t007_dialog_"), this);
|
|
365
369
|
this.rootElement = root?.isConnected ? root : document.body, this.rootScoped = this.rootElement !== document.body, this.scoped = this.rootScoped && scoped;
|
|
366
|
-
this.rootElement.append(this.dialog = createEl("dialog", { closedBy: by || (this.rootScoped ? "none" : "any"), className: `t007-dialog${this.rootScoped ? " t007-dialog-scoped" : ""}`, id: this.id }), this.rootScoped ? this.backdrop = createEl("div", { className: "t007-dialog-backdrop", id: `${this.id}_backdrop` }) :
|
|
370
|
+
this.rootElement.append(this.dialog = createEl("dialog", { closedBy: by || (this.rootScoped ? "none" : "any"), className: `t007-dialog${this.rootScoped ? " t007-dialog-scoped" : ""}`, id: this.id }), this.rootScoped ? this.backdrop = createEl("div", { className: "t007-dialog-backdrop", id: `${this.id}_backdrop` }) : "");
|
|
367
371
|
this.dialog.addEventListener("cancel", this.cancel);
|
|
368
372
|
initArrowNavigation(this.dialog, { enabled: true, rovingTab: false });
|
|
369
|
-
this.rootScoped && !by && initOutsideClick(this.dialog, { enabled: true,
|
|
373
|
+
this.rootScoped && !by && initOutsideClick(this.dialog, { enabled: true, onOutside: this.cancel, root: this.rootElement, scoped: this.scoped });
|
|
370
374
|
}
|
|
371
375
|
show() {
|
|
372
376
|
this.dialog[this.rootScoped ? "show" : "showModal"]();
|
|
@@ -394,7 +398,7 @@
|
|
|
394
398
|
<div class="t007-dialog-question">${message}</div>
|
|
395
399
|
</div>
|
|
396
400
|
<div class="t007-dialog-bottom-section">
|
|
397
|
-
<button type="button"
|
|
401
|
+
<button type="button" autofocus data-arrow-item class="t007-dialog-confirm-button">${options.confirmText || "OK"}</button>
|
|
398
402
|
</div>
|
|
399
403
|
`;
|
|
400
404
|
this.dialog.querySelector(".t007-dialog-confirm-button").addEventListener("click", this.confirm);
|
|
@@ -411,7 +415,7 @@
|
|
|
411
415
|
<div class="t007-dialog-question">${question}</div>
|
|
412
416
|
</div>
|
|
413
417
|
<div class="t007-dialog-bottom-section">
|
|
414
|
-
<button type="button"
|
|
418
|
+
<button type="button" autofocus data-arrow-item class="t007-dialog-confirm-button">${options.confirmText || "OK"}</button>
|
|
415
419
|
<button type="button" data-arrow-item class="t007-dialog-cancel-button">${options.cancelText || "Cancel"}</button>
|
|
416
420
|
</div>
|
|
417
421
|
`;
|
|
@@ -425,7 +429,7 @@
|
|
|
425
429
|
super(resolve, options), this.render(question, defaultValue, options);
|
|
426
430
|
}
|
|
427
431
|
async render(question, defaultValue, options) {
|
|
428
|
-
options = { ...options, value: defaultValue };
|
|
432
|
+
options = { autofocus: true, ...options, value: defaultValue };
|
|
429
433
|
await loadResource(window.T007_INPUT_JS_SRC, "script");
|
|
430
434
|
this.dialog.innerHTML = `
|
|
431
435
|
<form class="t007-input-form" ${t007.field ? "novalidate" : ""}>
|
package/dist/index.js
CHANGED
|
@@ -7,10 +7,10 @@ var T007_Dialog = class {
|
|
|
7
7
|
this.resolve = resolve;
|
|
8
8
|
t007.dialogs.set(this.id = id ?? uid("t007_dialog_"), this);
|
|
9
9
|
this.rootElement = root?.isConnected ? root : document.body, this.rootScoped = this.rootElement !== document.body, this.scoped = this.rootScoped && scoped;
|
|
10
|
-
this.rootElement.append(this.dialog = createEl("dialog", { closedBy: by || (this.rootScoped ? "none" : "any"), className: `t007-dialog${this.rootScoped ? " t007-dialog-scoped" : ""}`, id: this.id }), this.rootScoped ? this.backdrop = createEl("div", { className: "t007-dialog-backdrop", id: `${this.id}_backdrop` }) :
|
|
10
|
+
this.rootElement.append(this.dialog = createEl("dialog", { closedBy: by || (this.rootScoped ? "none" : "any"), className: `t007-dialog${this.rootScoped ? " t007-dialog-scoped" : ""}`, id: this.id }), this.rootScoped ? this.backdrop = createEl("div", { className: "t007-dialog-backdrop", id: `${this.id}_backdrop` }) : "");
|
|
11
11
|
this.dialog.addEventListener("cancel", this.cancel);
|
|
12
12
|
initArrowNavigation(this.dialog, { enabled: true, rovingTab: false });
|
|
13
|
-
this.rootScoped && !by && initOutsideClick(this.dialog, { enabled: true,
|
|
13
|
+
this.rootScoped && !by && initOutsideClick(this.dialog, { enabled: true, onOutside: this.cancel, root: this.rootElement, scoped: this.scoped });
|
|
14
14
|
}
|
|
15
15
|
show() {
|
|
16
16
|
this.dialog[this.rootScoped ? "show" : "showModal"]();
|
|
@@ -38,7 +38,7 @@ var T007_Alert_Dialog = class extends T007_Dialog {
|
|
|
38
38
|
<div class="t007-dialog-question">${message}</div>
|
|
39
39
|
</div>
|
|
40
40
|
<div class="t007-dialog-bottom-section">
|
|
41
|
-
<button type="button"
|
|
41
|
+
<button type="button" autofocus data-arrow-item class="t007-dialog-confirm-button">${options.confirmText || "OK"}</button>
|
|
42
42
|
</div>
|
|
43
43
|
`;
|
|
44
44
|
this.dialog.querySelector(".t007-dialog-confirm-button").addEventListener("click", this.confirm);
|
|
@@ -55,7 +55,7 @@ var T007_Confirm_Dialog = class extends T007_Dialog {
|
|
|
55
55
|
<div class="t007-dialog-question">${question}</div>
|
|
56
56
|
</div>
|
|
57
57
|
<div class="t007-dialog-bottom-section">
|
|
58
|
-
<button type="button"
|
|
58
|
+
<button type="button" autofocus data-arrow-item class="t007-dialog-confirm-button">${options.confirmText || "OK"}</button>
|
|
59
59
|
<button type="button" data-arrow-item class="t007-dialog-cancel-button">${options.cancelText || "Cancel"}</button>
|
|
60
60
|
</div>
|
|
61
61
|
`;
|
|
@@ -69,7 +69,7 @@ var T007_Prompt_Dialog = class extends T007_Dialog {
|
|
|
69
69
|
super(resolve, options), this.render(question, defaultValue, options);
|
|
70
70
|
}
|
|
71
71
|
async render(question, defaultValue, options) {
|
|
72
|
-
options = { ...options, value: defaultValue };
|
|
72
|
+
options = { autofocus: true, ...options, value: defaultValue };
|
|
73
73
|
await loadResource(window.T007_INPUT_JS_SRC, "script");
|
|
74
74
|
this.dialog.innerHTML = `
|
|
75
75
|
<form class="t007-input-form" ${t007.field ? "novalidate" : ""}>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t007/dialog",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"description": "A lightweight, pure JS dialog system.",
|
|
5
5
|
"author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"accessible"
|
|
57
57
|
],
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@t007/utils": "^0.0.
|
|
59
|
+
"@t007/utils": "^0.0.32"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"esbuild-sass-plugin": "^3.7.0"
|