@daracl/dialog 0.0.8 → 0.0.9
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 +1 -1
- package/dist/daracl.dialog.css +4 -1
- package/dist/daracl.dialog.js +100 -68
- package/dist/daracl.dialog.js.map +1 -1
- package/dist/daracl.dialog.min.css +1 -1
- package/dist/daracl.dialog.min.js +3 -3
- package/dist/daracl.dialog.min.umd.js +3 -3
- package/dist/daracl.dialog.umd.js +100 -68
- package/dist/daracl.dialog.umd.js.map +1 -1
- package/dist/dialog.d.ts +24 -1
- package/dist/index.cjs +100 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +4 -1
- package/dist/index.js +100 -68
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +2 -2
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +147 -124
- package/dist/index.min.js.map +1 -1
- package/package.json +3 -3
- package/style/daracl.dialog.scss +6 -1
package/dist/index.min.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { sanitizeHtml as
|
|
1
|
+
import { sanitizeHtml as T, isSafeUrl as H } from "@daracl/core/utils";
|
|
2
2
|
/*!
|
|
3
|
-
* @daracl/dialog v0.0.
|
|
3
|
+
* @daracl/dialog v0.0.9
|
|
4
4
|
* Copyright 2024-2026 darainfo and other contributors;
|
|
5
5
|
* Licensed MIT
|
|
6
6
|
*/
|
|
7
|
-
let
|
|
8
|
-
const
|
|
7
|
+
let W = 0, S = 0;
|
|
8
|
+
const O = "daraclDialogHidden", L = "data-daracl-theme", w = {
|
|
9
9
|
primary: "primary",
|
|
10
10
|
secondary: "secondary",
|
|
11
11
|
info: "info",
|
|
12
12
|
success: "success",
|
|
13
13
|
warning: "warning",
|
|
14
14
|
danger: "danger"
|
|
15
|
-
},
|
|
15
|
+
}, D = [
|
|
16
16
|
"a[href]",
|
|
17
17
|
"area[href]",
|
|
18
18
|
"button:not([disabled])",
|
|
@@ -23,7 +23,7 @@ const S = "daraclDialogHidden", A = "data-daracl-theme", z = {
|
|
|
23
23
|
"[contenteditable=true]",
|
|
24
24
|
"[tabindex]:not([tabindex='-1'])"
|
|
25
25
|
].join(",");
|
|
26
|
-
let
|
|
26
|
+
let N = {
|
|
27
27
|
width: 400,
|
|
28
28
|
height: 300,
|
|
29
29
|
styleClass: "",
|
|
@@ -60,42 +60,42 @@ let M = {
|
|
|
60
60
|
afterOpen: !1
|
|
61
61
|
// open 후 호출 메소드
|
|
62
62
|
};
|
|
63
|
-
function
|
|
64
|
-
let
|
|
65
|
-
return
|
|
63
|
+
function M() {
|
|
64
|
+
let r = document.getElementById(O);
|
|
65
|
+
return r == null && (r = document.createElement("div"), r.id = O, r.className = "daracl-dialog-hidden", document.body.appendChild(r)), r;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
return
|
|
67
|
+
function C(r) {
|
|
68
|
+
return r == null || r === "" ? "" : typeof r == "number" || /^\d+(\.\d+)?$/.test(String(r)) ? r + "px" : String(r);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
typeof e == "string" && e.split(/\s+/).filter((t) => t !== "").forEach((t) =>
|
|
70
|
+
function z(r, e) {
|
|
71
|
+
typeof e == "string" && e.split(/\s+/).filter((t) => t !== "").forEach((t) => r.classList.add(t));
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
73
|
+
function B(r) {
|
|
74
|
+
return r.key === "Enter" || r.key === " " || r.key === "Spacebar";
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
const e =
|
|
76
|
+
function A(r) {
|
|
77
|
+
const e = r.touches && r.touches[0] ? r.touches[0] : r.changedTouches && r.changedTouches[0] ? r.changedTouches[0] : r;
|
|
78
78
|
return { clientX: e.clientX, clientY: e.clientY, pageX: e.pageX, pageY: e.pageY };
|
|
79
79
|
}
|
|
80
|
-
class
|
|
81
|
-
static VERSION = "0.0.
|
|
80
|
+
class F {
|
|
81
|
+
static VERSION = "0.0.9";
|
|
82
82
|
/**
|
|
83
83
|
* @param {DialogOptions | string} options 옵션. 문자열이면 template 으로 쓴다.
|
|
84
84
|
*/
|
|
85
85
|
constructor(e) {
|
|
86
86
|
typeof e == "string" && (e = /** @type {DialogOptions} */
|
|
87
|
-
{ template: e, items: e }), this.options = Object.assign({},
|
|
87
|
+
{ template: e, items: e }), this.options = Object.assign({}, N, e), this.idx = W += 1, this.eventList = [], this.timerSet = /* @__PURE__ */ new Set(), this.frameSet = /* @__PURE__ */ new Set();
|
|
88
88
|
const t = document.createElement("div");
|
|
89
|
-
t.className = `daracl-dialog-wrapper hide dd-${
|
|
89
|
+
t.className = `daracl-dialog-wrapper hide dd-${W}`, t.setAttribute("role", "dialog"), t.setAttribute("tabindex", "-1"), this.options.isModal === !0 && t.setAttribute("aria-modal", "true");
|
|
90
90
|
const i = t.style;
|
|
91
|
-
i.zIndex = String(this.options.zIndex +
|
|
91
|
+
i.zIndex = String(this.options.zIndex + W), i.width = C(this.options.width), i.height = C(this.options.height), i.minHeight = C(this.options.minHeight), i.minWidth = C(this.options.minWidth), M().appendChild(t), this.dialogWrapperElement = t, this.setTheme(this.options.theme), this.dialogTemplate(), this.addEvent(t, "keydown", this.onKeydown), this.options.draggable !== !1 && (t.classList.add("draggable"), this.initDrag()), this.options.resizable === !0 && (t.classList.add("resizable"), this.initResize()), this.options.autoOpen !== !1 && this.show();
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* @param {DialogOptions | string} options
|
|
95
95
|
* @returns {Dialog}
|
|
96
96
|
*/
|
|
97
97
|
static create(e) {
|
|
98
|
-
return new
|
|
98
|
+
return new F(e);
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* default options 셋팅
|
|
@@ -104,7 +104,7 @@ class B {
|
|
|
104
104
|
* @param {DialogOptions} options
|
|
105
105
|
*/
|
|
106
106
|
static setOptions(e) {
|
|
107
|
-
|
|
107
|
+
N = Object.assign({}, N, e);
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
110
|
* 문자열 HTML 을 sanitize 옵션에 따라 target 에 추가한다.
|
|
@@ -129,14 +129,14 @@ class B {
|
|
|
129
129
|
e.insertAdjacentHTML("beforeend", s);
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
|
-
e.appendChild(
|
|
132
|
+
e.appendChild(T(s));
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
135
|
* 포커스 가능한 요소 목록
|
|
136
136
|
* @returns {HTMLElement[]}
|
|
137
137
|
*/
|
|
138
138
|
getFocusableElements() {
|
|
139
|
-
return this.dialogWrapperElement ? Array.prototype.slice.call(this.dialogWrapperElement.querySelectorAll(
|
|
139
|
+
return this.dialogWrapperElement ? Array.prototype.slice.call(this.dialogWrapperElement.querySelectorAll(D)).filter((e) => !e.closest(".resizer")) : [];
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
142
|
* ESC 닫기, 모달일 때 Tab focus trap
|
|
@@ -175,39 +175,67 @@ class B {
|
|
|
175
175
|
clearTimer(e) {
|
|
176
176
|
e !== void 0 && (clearTimeout(e), this.timerSet.delete(e));
|
|
177
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* 마우스 / 터치 이동을 화면 갱신 주기(requestAnimationFrame)마다 한 번만 반영한다.
|
|
180
|
+
* 한 프레임 안의 여러 move 이벤트는 마지막 좌표만 쓰고, flush 는 남은 좌표를 바로 반영한다 (놓을 때 마지막 이동 유지).
|
|
181
|
+
* requestAnimationFrame 이 없는 환경에서는 moveDelay(ms) 타이머로 대신한다.
|
|
182
|
+
* @param {(point: {clientX: number, clientY: number, pageX: number, pageY: number}) => void} apply
|
|
183
|
+
*/
|
|
184
|
+
createFrameUpdater(e) {
|
|
185
|
+
let t = null, i = 0, s;
|
|
186
|
+
const n = () => {
|
|
187
|
+
i && (cancelAnimationFrame(i), this.frameSet.delete(i), i = 0), this.clearTimer(s), s = void 0;
|
|
188
|
+
}, o = () => {
|
|
189
|
+
n();
|
|
190
|
+
const a = t;
|
|
191
|
+
t = null, a && this.dialogWrapperElement && e(a);
|
|
192
|
+
};
|
|
193
|
+
return {
|
|
194
|
+
/** @param {{clientX: number, clientY: number, pageX: number, pageY: number}} point */
|
|
195
|
+
request: (a) => {
|
|
196
|
+
if (t = a, !(i || s !== void 0))
|
|
197
|
+
if (typeof requestAnimationFrame == "function") {
|
|
198
|
+
const p = requestAnimationFrame(() => {
|
|
199
|
+
this.frameSet.delete(p), i = 0, o();
|
|
200
|
+
});
|
|
201
|
+
i = p, this.frameSet.add(p);
|
|
202
|
+
} else
|
|
203
|
+
s = this.setTimer(() => {
|
|
204
|
+
s = void 0, o();
|
|
205
|
+
}, Math.max(this.options.moveDelay || 0, 0));
|
|
206
|
+
},
|
|
207
|
+
flush: o
|
|
208
|
+
};
|
|
209
|
+
}
|
|
178
210
|
/** 사이즈 조절 초기화 */
|
|
179
211
|
initResize() {
|
|
180
212
|
const e = this.dialogWrapperElement, t = this.dialogWrapperElement.querySelectorAll(".resizer");
|
|
181
|
-
let i, s, n, o,
|
|
182
|
-
this.addEvent(t, "mousedown touchstart", (
|
|
213
|
+
let i, s, n, o, a = "", p = -1, f = -1, g, d;
|
|
214
|
+
this.addEvent(t, "mousedown touchstart", (m) => {
|
|
183
215
|
if (this.isMaximise())
|
|
184
216
|
return !1;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
if (n =
|
|
189
|
-
const
|
|
190
|
-
this.setPosition(
|
|
217
|
+
a = /** @type {HTMLElement} */
|
|
218
|
+
m.currentTarget.getAttribute("data-mode") || "", g = a.indexOf("t") > -1, d = a.indexOf("l") > -1, p = d ? e.getBoundingClientRect().left : -1, f = g ? e.getBoundingClientRect().top : -1, m.preventDefault();
|
|
219
|
+
const u = A(m);
|
|
220
|
+
if (n = u.pageX, o = u.pageY, i = e.clientWidth, s = e.clientHeight, !e.classList.contains("transform-disable")) {
|
|
221
|
+
const E = e.getBoundingClientRect();
|
|
222
|
+
this.setPosition(u, u.clientX - E.left, u.clientY - E.top, i, s), e.classList.add("transform-disable");
|
|
191
223
|
}
|
|
192
|
-
this.addEvent(document, "mousemove touchmove",
|
|
224
|
+
this.addEvent(document, "mousemove touchmove", c), this.addEvent(document, "mouseup touchend touchcancel", h);
|
|
193
225
|
});
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
l && (T = u - v, T <= 0 && (T = 0, W = i + u), e.style.left = T + "px"), r != "b" && r != "t" && (e.style.width = W + "px"), r != "r" && r != "l" && (e.style.height = x + "px");
|
|
208
|
-
}, d);
|
|
209
|
-
}, y = () => {
|
|
210
|
-
this.clearTimer(h), c = -1, this.removeEvent(document, "mousemove touchmove", p), this.removeEvent(document, "mouseup touchend touchcancel", y);
|
|
226
|
+
const l = this.createFrameUpdater((m) => {
|
|
227
|
+
let u = m.pageX - n, E = m.pageY - o;
|
|
228
|
+
E = g ? E * -1 : E, u = d ? u * -1 : u;
|
|
229
|
+
let v = s + E, b = i + u;
|
|
230
|
+
this.options.minHeight >= v && (v = this.options.minHeight, E = (s - v) * -1), this.options.minWidth >= b && (b = this.options.minWidth, u = (i - b) * -1);
|
|
231
|
+
let y = -1;
|
|
232
|
+
g && (y = f - E, y <= 0 && (y = 0, v = s + f), e.style.top = y + "px");
|
|
233
|
+
let x = -1;
|
|
234
|
+
d && (x = p - u, x <= 0 && (x = 0, b = i + p), e.style.left = x + "px"), a != "b" && a != "t" && (e.style.width = b + "px"), a != "r" && a != "l" && (e.style.height = v + "px");
|
|
235
|
+
}), c = (m) => {
|
|
236
|
+
l.request(A(m));
|
|
237
|
+
}, h = () => {
|
|
238
|
+
l.flush(), this.removeEvent(document, "mousemove touchmove", c), this.removeEvent(document, "mouseup touchend touchcancel", h);
|
|
211
239
|
};
|
|
212
240
|
}
|
|
213
241
|
/**
|
|
@@ -216,31 +244,26 @@ class B {
|
|
|
216
244
|
initDrag() {
|
|
217
245
|
const e = this.dialogWrapperElement, t = this.dialogWrapperElement.querySelector(".dialog-header");
|
|
218
246
|
if (!t) return;
|
|
219
|
-
let i = !1, s, n, o,
|
|
220
|
-
this.addEvent(t, "mousedown touchstart", (
|
|
221
|
-
const
|
|
247
|
+
let i = !1, s, n, o, a, p = !1;
|
|
248
|
+
this.addEvent(t, "mousedown touchstart", (l) => {
|
|
249
|
+
const c = (
|
|
222
250
|
/** @type {HTMLElement} */
|
|
223
|
-
|
|
251
|
+
l.target
|
|
224
252
|
);
|
|
225
|
-
if ((
|
|
253
|
+
if ((c.tagName || "").search(/(input|textarea|select|button)/gi) > -1 || c.closest && c.closest(".btn-area"))
|
|
226
254
|
return !0;
|
|
227
255
|
if (this.isMaximise())
|
|
228
256
|
return !1;
|
|
229
|
-
|
|
230
|
-
const
|
|
231
|
-
o = e.clientWidth,
|
|
257
|
+
l.preventDefault();
|
|
258
|
+
const m = A(l), u = e.getBoundingClientRect();
|
|
259
|
+
o = e.clientWidth, a = e.clientHeight, i = !0, s = m.clientX - u.left, n = m.clientY - u.top, p || (this.setPosition(m, s, n, o, a), p = !0, e.classList.add("transform-disable")), e.classList.add("move-on"), this.addEvent(document, "mousemove touchmove", g), this.addEvent(document, "mouseup touchend touchcancel", d);
|
|
232
260
|
});
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
m = -1, this.dialogWrapperElement && this.setPosition(p, s, n, o, r);
|
|
240
|
-
}, l);
|
|
241
|
-
}
|
|
242
|
-
}, h = () => {
|
|
243
|
-
i = !1, m = -1, this.clearTimer(f), e.classList.remove("move-on"), this.removeEvent(document, "mousemove touchmove", c), this.removeEvent(document, "mouseup touchend touchcancel", h);
|
|
261
|
+
const f = this.createFrameUpdater((l) => {
|
|
262
|
+
this.setPosition(l, s, n, o, a);
|
|
263
|
+
}), g = (l) => {
|
|
264
|
+
i && f.request(A(l));
|
|
265
|
+
}, d = () => {
|
|
266
|
+
f.flush(), i = !1, e.classList.remove("move-on"), this.removeEvent(document, "mousemove touchmove", g), this.removeEvent(document, "mouseup touchend touchcancel", d);
|
|
244
267
|
};
|
|
245
268
|
}
|
|
246
269
|
/**
|
|
@@ -253,8 +276,8 @@ class B {
|
|
|
253
276
|
* @param {Number} dialogHeight dialog height
|
|
254
277
|
*/
|
|
255
278
|
setPosition(e, t, i, s, n) {
|
|
256
|
-
let o,
|
|
257
|
-
this.options.dragOverflow === !1 ? (o = Math.min(Math.max(e.clientX - t, 0), window.innerWidth - s),
|
|
279
|
+
let o, a;
|
|
280
|
+
this.options.dragOverflow === !1 ? (o = Math.min(Math.max(e.clientX - t, 0), window.innerWidth - s), a = Math.min(Math.max(e.clientY - i, 0), window.innerHeight - n)) : (o = Math.min(Math.max(e.clientX - t, (s - 80) * -1), window.innerWidth - 80), a = Math.min(Math.max(e.clientY - i, 0), window.innerHeight - 30)), this.dialogWrapperElement.style.left = o + "px", this.dialogWrapperElement.style.top = a + "px";
|
|
258
281
|
}
|
|
259
282
|
/**
|
|
260
283
|
* span 버튼에 role / tabindex / 키보드 동작을 붙인다.
|
|
@@ -264,7 +287,7 @@ class B {
|
|
|
264
287
|
*/
|
|
265
288
|
bindButton(e, t, i) {
|
|
266
289
|
e.setAttribute("role", "button"), e.setAttribute("tabindex", "0"), this.addEvent(e, t, i), this.addEvent(e, "keydown", (s) => {
|
|
267
|
-
|
|
290
|
+
B(
|
|
268
291
|
/** @type {KeyboardEvent} */
|
|
269
292
|
s
|
|
270
293
|
) && (s.preventDefault(), i(s));
|
|
@@ -272,52 +295,52 @@ class B {
|
|
|
272
295
|
}
|
|
273
296
|
dialogTemplate() {
|
|
274
297
|
const e = this.options, t = e.enableHeader !== !1, i = e.enableFooter !== !1, s = document.createElement("div");
|
|
275
|
-
if (s.className = "daracl-dialog",
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
if (
|
|
282
|
-
const
|
|
283
|
-
|
|
298
|
+
if (s.className = "daracl-dialog", z(s, e.styleClass ?? ""), t) {
|
|
299
|
+
const d = document.createElement("div");
|
|
300
|
+
d.className = "dialog-header", this.appendHtml(d, e.title ?? "", !1);
|
|
301
|
+
const l = (d.textContent || "").trim();
|
|
302
|
+
l !== "" && this.dialogWrapperElement.setAttribute("aria-label", l);
|
|
303
|
+
const c = document.createElement("div");
|
|
304
|
+
if (c.className = "btn-area", e.enableMaxButton) {
|
|
305
|
+
const h = document.createElement("span");
|
|
306
|
+
h.className = "dialog-maximise", h.setAttribute("aria-label", "Maximize"), h.setAttribute("title", "Maximize"), c.appendChild(h);
|
|
284
307
|
}
|
|
285
308
|
if (e.enableCloseButton) {
|
|
286
|
-
const
|
|
287
|
-
|
|
309
|
+
const h = document.createElement("span");
|
|
310
|
+
h.className = "dialog-close", h.setAttribute("aria-label", "Close"), h.setAttribute("title", "Close"), c.appendChild(h);
|
|
288
311
|
}
|
|
289
|
-
|
|
312
|
+
d.appendChild(c), s.appendChild(d);
|
|
290
313
|
}
|
|
291
314
|
const n = document.createElement("div");
|
|
292
|
-
n.className = "dialog-body", Object.prototype.hasOwnProperty.call(
|
|
315
|
+
n.className = "dialog-body", Object.prototype.hasOwnProperty.call(w, e.icon) && n.classList.add(w[e.icon]), n.style.height = `calc(100%${t ? " - 40px" : ""}${i ? " - 45px" : ""})`;
|
|
293
316
|
const o = document.createElement("div");
|
|
294
317
|
o.className = "dialog-move-overay", n.appendChild(o);
|
|
295
|
-
const
|
|
296
|
-
if (
|
|
297
|
-
const
|
|
298
|
-
if (
|
|
299
|
-
const
|
|
300
|
-
|
|
318
|
+
const a = document.createElement("div");
|
|
319
|
+
if (a.className = "dialog-content", n.appendChild(a), e.url) {
|
|
320
|
+
const d = String(e.url);
|
|
321
|
+
if (H(d)) {
|
|
322
|
+
const l = document.createElement("iframe");
|
|
323
|
+
l.className = "dialog-frame", l.src = d, typeof e.title == "string" && (l.title = (this.dialogWrapperElement.getAttribute("aria-label") || "").slice(0, 200)), a.appendChild(l);
|
|
301
324
|
} else
|
|
302
|
-
console.warn("[daracl.dialog] unsafe url blocked : " +
|
|
303
|
-
} else typeof e.template == "function" ? this.appendHtml(
|
|
325
|
+
console.warn("[daracl.dialog] unsafe url blocked : " + d.slice(0, 100));
|
|
326
|
+
} else typeof e.template == "function" ? this.appendHtml(a, e.template(), !0) : this.appendHtml(a, e.template, !0);
|
|
304
327
|
s.appendChild(n);
|
|
305
|
-
const
|
|
328
|
+
const p = e.buttons ?? [];
|
|
306
329
|
if (i) {
|
|
330
|
+
const d = document.createElement("div");
|
|
331
|
+
d.className = "dialog-footer";
|
|
307
332
|
const l = document.createElement("div");
|
|
308
|
-
l.className = "
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
for (let h = 0; h < u.length; h++) {
|
|
312
|
-
const d = (
|
|
333
|
+
l.className = "btn-area";
|
|
334
|
+
for (let c = 0; c < p.length; c++) {
|
|
335
|
+
const h = (
|
|
313
336
|
/** @type {DialogButton} */
|
|
314
|
-
|
|
315
|
-
),
|
|
316
|
-
|
|
317
|
-
typeof
|
|
318
|
-
}),
|
|
337
|
+
p[c] ?? {}
|
|
338
|
+
), m = document.createElement("span");
|
|
339
|
+
m.className = `dialog-btn dialog-btn-${c}`, z(m, h.styleClass ?? "success"), this.appendHtml(m, h.label ?? "", !1), this.bindButton(m, "mousedown", (u) => {
|
|
340
|
+
typeof h.callback == "function" && h.callback(u);
|
|
341
|
+
}), l.appendChild(m);
|
|
319
342
|
}
|
|
320
|
-
|
|
343
|
+
d.appendChild(l), s.appendChild(d);
|
|
321
344
|
}
|
|
322
345
|
e.resizable === !0 && [
|
|
323
346
|
["top", "t"],
|
|
@@ -328,22 +351,22 @@ class B {
|
|
|
328
351
|
["top-right", "tr"],
|
|
329
352
|
["bottom-left", "bl"],
|
|
330
353
|
["bottom-right", "br"]
|
|
331
|
-
].forEach(([
|
|
332
|
-
const
|
|
333
|
-
|
|
354
|
+
].forEach(([d, l]) => {
|
|
355
|
+
const c = document.createElement("div");
|
|
356
|
+
c.className = `resizer ${d}`, c.setAttribute("data-mode", l), s.appendChild(c);
|
|
334
357
|
}), this.dialogWrapperElement.appendChild(s);
|
|
335
|
-
const
|
|
358
|
+
const f = (
|
|
336
359
|
/** @type {HTMLElement | null} */
|
|
337
360
|
s.querySelector(".dialog-header .dialog-maximise")
|
|
338
361
|
);
|
|
339
|
-
|
|
362
|
+
f && this.bindButton(f, "click", () => {
|
|
340
363
|
this.maximise();
|
|
341
364
|
});
|
|
342
|
-
const
|
|
365
|
+
const g = (
|
|
343
366
|
/** @type {HTMLElement | null} */
|
|
344
367
|
s.querySelector(".dialog-header .dialog-close")
|
|
345
368
|
);
|
|
346
|
-
|
|
369
|
+
g && this.bindButton(g, "click", () => {
|
|
347
370
|
this.hide();
|
|
348
371
|
});
|
|
349
372
|
}
|
|
@@ -355,7 +378,7 @@ class B {
|
|
|
355
378
|
*/
|
|
356
379
|
setTheme(e) {
|
|
357
380
|
return this.dialogWrapperElement ? (this.themeName = e ? String(e) : "", [this.dialogWrapperElement, this.dialogOverrayElement].forEach((t) => {
|
|
358
|
-
t && (this.themeName ? t.setAttribute(
|
|
381
|
+
t && (this.themeName ? t.setAttribute(L, this.themeName) : t.removeAttribute(L));
|
|
359
382
|
}), this) : this;
|
|
360
383
|
}
|
|
361
384
|
/**
|
|
@@ -372,16 +395,16 @@ class B {
|
|
|
372
395
|
show = () => {
|
|
373
396
|
if (!this.dialogWrapperElement || !this.dialogWrapperElement.classList.contains("hide"))
|
|
374
397
|
return this;
|
|
375
|
-
|
|
376
|
-
const e = this.options.zIndex +
|
|
398
|
+
S = Math.max(S, W) + 2;
|
|
399
|
+
const e = this.options.zIndex + S;
|
|
377
400
|
if (this.returnFocusElement = typeof document < "u" ? (
|
|
378
401
|
/** @type {HTMLElement | null} */
|
|
379
402
|
document.activeElement
|
|
380
403
|
) : null, this.dialogWrapperElement.style.zIndex = String(e), this.dialogWrapperElement.classList.remove("hide"), this.options.isModal === !0) {
|
|
381
404
|
this.removeDialogOverrayElement();
|
|
382
405
|
const t = document.createElement("div");
|
|
383
|
-
t.className = "daracl-dialog-overlay", t.style.zIndex = String(e - 1), this.themeName && t.setAttribute(
|
|
384
|
-
const i =
|
|
406
|
+
t.className = "daracl-dialog-overlay", t.style.zIndex = String(e - 1), this.themeName && t.setAttribute(L, this.themeName);
|
|
407
|
+
const i = M(), s = i.firstChild;
|
|
385
408
|
s ? i.insertBefore(t, s) : i.appendChild(t), this.dialogOverrayElement = t;
|
|
386
409
|
}
|
|
387
410
|
if (this.options.autoFocus !== !1) {
|
|
@@ -437,7 +460,7 @@ class B {
|
|
|
437
460
|
const s = e instanceof NodeList || Array.isArray(e) ? Array.prototype.slice.call(e) : [e];
|
|
438
461
|
t.split(" ").forEach((n) => {
|
|
439
462
|
n !== "" && s.forEach((o) => {
|
|
440
|
-
o && (this.eventList.some(([
|
|
463
|
+
o && (this.eventList.some(([a, p, f]) => a === o && p === n && f === i) || (o.addEventListener(n, i, !1), this.eventList.push([o, n, i])));
|
|
441
464
|
});
|
|
442
465
|
});
|
|
443
466
|
}
|
|
@@ -450,7 +473,7 @@ class B {
|
|
|
450
473
|
const s = e instanceof NodeList || Array.isArray(e) ? Array.prototype.slice.call(e) : [e];
|
|
451
474
|
t.split(" ").forEach((n) => {
|
|
452
475
|
s.forEach((o) => {
|
|
453
|
-
o && (o.removeEventListener(n, i, !1), this.eventList = this.eventList.filter(([
|
|
476
|
+
o && (o.removeEventListener(n, i, !1), this.eventList = this.eventList.filter(([a, p, f]) => !(a === o && p === n && f === i)));
|
|
454
477
|
});
|
|
455
478
|
});
|
|
456
479
|
}
|
|
@@ -460,13 +483,13 @@ class B {
|
|
|
460
483
|
destroy = () => {
|
|
461
484
|
if (!this.dialogWrapperElement) return;
|
|
462
485
|
const e = this.isOpen(), t = this.dialogWrapperElement.contains(document.activeElement);
|
|
463
|
-
this.eventList.forEach(([s, n, o]) => s.removeEventListener(n, o, !1)), this.eventList = [], this.timerSet.forEach((s) => clearTimeout(s)), this.timerSet.clear(), this.removeDialogOverrayElement(), e && this.restoreFocus(t);
|
|
486
|
+
this.eventList.forEach(([s, n, o]) => s.removeEventListener(n, o, !1)), this.eventList = [], this.timerSet.forEach((s) => clearTimeout(s)), this.timerSet.clear(), typeof cancelAnimationFrame == "function" && this.frameSet.forEach((s) => cancelAnimationFrame(s)), this.frameSet.clear(), this.removeDialogOverrayElement(), e && this.restoreFocus(t);
|
|
464
487
|
const i = this.dialogWrapperElement;
|
|
465
488
|
i.parentNode && i.parentNode.removeChild(i), this.dialogWrapperElement = null, this.options = null, this.idx = -1;
|
|
466
489
|
};
|
|
467
490
|
}
|
|
468
491
|
export {
|
|
469
|
-
|
|
470
|
-
|
|
492
|
+
F as Dialog,
|
|
493
|
+
F as default
|
|
471
494
|
};
|
|
472
495
|
//# sourceMappingURL=index.min.js.map
|