@xwadex/fesd 0.0.42 → 0.0.44
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/fesd-bundle.css +1 -1
- package/dist/fesd-bundle.js +338 -334
- package/dist/fesd-bundle.js.map +1 -1
- package/dist/image-preview-bundle.js +632 -598
- package/dist/image-preview-bundle.js.map +1 -1
- package/dist/tools-bundle.js +143 -142
- package/dist/tools-bundle.js.map +1 -1
- package/package.json +1 -1
package/dist/tools-bundle.js
CHANGED
|
@@ -9,10 +9,10 @@ var D = (r, e, t) => {
|
|
|
9
9
|
};
|
|
10
10
|
var V = (r, e, t) => (U(r, e, "access private method"), t);
|
|
11
11
|
import { n as z, o as C } from "./image-preview-bundle.js";
|
|
12
|
-
import { x as ue, B as de, z as fe, G as pe, F as me, J as ye, K as he, E as ve, L as ge, O as be, P as ke, Q as xe, X as Se, Y as Ae, w as
|
|
12
|
+
import { x as ue, B as de, z as fe, G as pe, F as me, J as ye, K as he, E as ve, L as ge, O as be, P as ke, Q as xe, X as Se, Y as Ae, w as we, U as Ee, W as qe, u as Ce, t as Le, V as Oe, q as Te, r as Fe, p as Ge, S as $e, y as Ie, H as Ne, N as De } from "./image-preview-bundle.js";
|
|
13
13
|
import { o as H, z as Q } from "./vendor-bundle.js";
|
|
14
14
|
import h from "jquery";
|
|
15
|
-
import
|
|
15
|
+
import w from "validator";
|
|
16
16
|
import _ from "flatpickr";
|
|
17
17
|
function se() {
|
|
18
18
|
if (!document.body.classList.contains("error") || document.querySelector(".back-home") == null)
|
|
@@ -25,50 +25,50 @@ function se() {
|
|
|
25
25
|
}
|
|
26
26
|
function W(r, e = r) {
|
|
27
27
|
if (r.complete) {
|
|
28
|
-
const o = new H().getColor(r),
|
|
29
|
-
G(
|
|
28
|
+
const o = new H().getColor(r), i = o[0] * 0.299 + o[1] * 0.587 + o[2] * 0.114;
|
|
29
|
+
G(i, e), e.classList.add("detected");
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
function G(r, e) {
|
|
33
33
|
const t = e.getAttribute("addClassEl");
|
|
34
34
|
r >= 192 ? t && t !== "" ? t.split(",").forEach((o) => {
|
|
35
|
-
var
|
|
36
|
-
e.closest(o) || console.error(`closest "${o}" not found`), (
|
|
35
|
+
var i;
|
|
36
|
+
e.closest(o) || console.error(`closest "${o}" not found`), (i = e.closest(o)) == null || i.classList.add("is-light");
|
|
37
37
|
}) : e.classList.add("is-light") : t && t !== "" ? t.split(",").forEach((o) => {
|
|
38
|
-
var
|
|
39
|
-
e.closest(o) || console.error(`closest "${o}" not found`), (
|
|
38
|
+
var i;
|
|
39
|
+
e.closest(o) || console.error(`closest "${o}" not found`), (i = e.closest(o)) == null || i.classList.add("is-dark");
|
|
40
40
|
}) : e.classList.add("is-dark");
|
|
41
41
|
}
|
|
42
42
|
function R(r, e, t) {
|
|
43
|
-
const o = document.createElement("canvas"),
|
|
43
|
+
const o = document.createElement("canvas"), i = o.getContext("2d");
|
|
44
44
|
if (o.width = 50, o.height = 50, r !== "" && e === "")
|
|
45
|
-
|
|
45
|
+
i.fillStyle = r;
|
|
46
46
|
else if (r !== "" && e !== "") {
|
|
47
|
-
const
|
|
48
|
-
|
|
47
|
+
const y = i.createLinearGradient(0, 0, o.width, o.height);
|
|
48
|
+
y.addColorStop(0, r), y.addColorStop(1, e), i.fillStyle = y;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
return
|
|
50
|
+
i.fillRect(0, 0, o.width, o.height);
|
|
51
|
+
const f = new Image();
|
|
52
|
+
return f.src = o.toDataURL(), f.crossOrigin = "Anonymous", f.addEventListener("load", function() {
|
|
53
53
|
W(this, t);
|
|
54
|
-
}),
|
|
54
|
+
}), f;
|
|
55
55
|
}
|
|
56
56
|
function ie() {
|
|
57
57
|
[...document.querySelectorAll(".detect-shade:not(.detected)")].forEach((e) => {
|
|
58
58
|
if (e.tagName === "IMG")
|
|
59
59
|
return;
|
|
60
|
-
const t = ["#FFF", "#FFFFFF", "#fff", "#ffffff"], o = ["#000", "#000000"],
|
|
61
|
-
if (
|
|
60
|
+
const t = ["#FFF", "#FFFFFF", "#fff", "#ffffff"], o = ["#000", "#000000"], i = getComputedStyle(e).getPropertyValue("--start-color"), f = getComputedStyle(e).getPropertyValue("--end-color");
|
|
61
|
+
if (i === "" && f === "") {
|
|
62
62
|
console.error(e, "=> No color set!");
|
|
63
63
|
return;
|
|
64
|
-
} else if (t.indexOf(
|
|
64
|
+
} else if (t.indexOf(i) > 0) {
|
|
65
65
|
console.warn(e, "=> TypeError!! ( #FFF ) "), G(255, e);
|
|
66
66
|
return;
|
|
67
|
-
} else if (o.indexOf(
|
|
67
|
+
} else if (o.indexOf(i) > 0) {
|
|
68
68
|
console.warn(e, "=> TypeError!! ( #000 ) "), G(0, e);
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
R(
|
|
71
|
+
R(i, f, e);
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
const O = {
|
|
@@ -147,31 +147,31 @@ const O = {
|
|
|
147
147
|
}
|
|
148
148
|
}, j = (r, e) => {
|
|
149
149
|
r.preventDefault();
|
|
150
|
-
const t = h(r.currentTarget), o = t.attr("target"),
|
|
151
|
-
let
|
|
150
|
+
const t = h(r.currentTarget), o = t.attr("target"), i = t.attr("href");
|
|
151
|
+
let f;
|
|
152
152
|
if (e) {
|
|
153
153
|
if (t.is("[data-nolink]")) {
|
|
154
154
|
r.stopPropagation(), r.preventDefault();
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
|
-
t.hasClass("href-link") ?
|
|
157
|
+
t.hasClass("href-link") ? f = t.closest("[data-href]").attr("data-href") : f = i;
|
|
158
158
|
} else {
|
|
159
159
|
if (t.is("[data-nolink]")) {
|
|
160
160
|
r.stopPropagation(), r.preventDefault();
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
|
-
t.hasClass("click-block") ?
|
|
163
|
+
t.hasClass("click-block") ? f = t.closest("[data-href]").attr("data-href") : f = i;
|
|
164
164
|
}
|
|
165
|
-
let
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
let l =
|
|
165
|
+
let d = window.location.pathname.replace("http://", "").split("/");
|
|
166
|
+
d = s(d);
|
|
167
|
+
const c = f.replace("http://", "");
|
|
168
|
+
let l = c.split("/");
|
|
169
169
|
l = s(l);
|
|
170
|
-
function s(
|
|
171
|
-
const
|
|
172
|
-
return
|
|
170
|
+
function s(n) {
|
|
171
|
+
const a = n.pop();
|
|
172
|
+
return a.indexOf("#") > -1 || a.indexOf("html") > 0 ? n.push(a) : (a == "" || n.push(a), n.push("index.html")), n;
|
|
173
173
|
}
|
|
174
|
-
o == "_blank" || r.ctrlKey || r.metaKey ? window.open(
|
|
174
|
+
o == "_blank" || r.ctrlKey || r.metaKey ? window.open(f) : c.indexOf("jpg") > -1 || c.indexOf("javascript") > -1 || K(f);
|
|
175
175
|
}, X = (r) => {
|
|
176
176
|
const t = h(r.currentTarget).closest("[data-href]");
|
|
177
177
|
t.hasClass("isHover") || t.addClass("isHover");
|
|
@@ -181,18 +181,18 @@ const O = {
|
|
|
181
181
|
}, ae = (r = !0) => {
|
|
182
182
|
h.easing.jswing = h.easing.swing, h.extend(h.easing, {
|
|
183
183
|
def: "easeOutQuad",
|
|
184
|
-
easeOutQuad: function(e, t, o,
|
|
185
|
-
return -
|
|
184
|
+
easeOutQuad: function(e, t, o, i, f) {
|
|
185
|
+
return -i * (t /= f) * (t - 2) + o;
|
|
186
186
|
},
|
|
187
|
-
easeInOutCirc: function(e, t, o,
|
|
188
|
-
return (t /=
|
|
187
|
+
easeInOutCirc: function(e, t, o, i, f) {
|
|
188
|
+
return (t /= f / 2) < 1 ? -i / 2 * (Math.sqrt(1 - t * t) - 1) + o : i / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + o;
|
|
189
189
|
}
|
|
190
190
|
}), r ? (h("body").on("click", "a:not(.nocg), .href-link, [data-nolink]", (e) => j(e, r)), h("body").on("click", "a:not(.nocg)", function(e) {
|
|
191
191
|
e.stopPropagation();
|
|
192
192
|
})) : (h("body").on("click", "a:not(.nocg), .click-block, [data-nolink]", (e) => j(e, r)), h("body").on("click", "a:not(.nocg)", function(e) {
|
|
193
193
|
e.stopPropagation();
|
|
194
194
|
})), h("body").on("mouseenter", "[data-href] a", (e) => X(e)), h("body").on("mouseleave", "[data-href] a", (e) => Y(e));
|
|
195
|
-
},
|
|
195
|
+
}, E = {
|
|
196
196
|
"zh-TW": {
|
|
197
197
|
format: "格式錯誤",
|
|
198
198
|
input: "尚未填寫",
|
|
@@ -231,7 +231,7 @@ class le {
|
|
|
231
231
|
* 綁事件
|
|
232
232
|
*/
|
|
233
233
|
D(this, T);
|
|
234
|
-
this.element = document.querySelector(e), this.allField = this.element.querySelectorAll(`${e} [form-field]`), this.allInput = this.element.querySelectorAll(`${e} input`), this.allTextarea = this.element.querySelectorAll(`${e} textarea`), this.allCheckbox = this.element.querySelectorAll(`${e} input[type="checkbox"]`), this.allRadio = this.element.querySelectorAll(`${e} input[type="radio"]`), this.allFileUpload = this.element.querySelectorAll(`${e} fake-file-upload`), this.allDropdown = this.element.querySelectorAll(`${e} dropdown-el`), this.submitEvent = new Event("submit");
|
|
234
|
+
this.element = document.querySelector(e), this.allField = this.element.querySelectorAll(`${e} [form-field]`), this.allInput = this.element.querySelectorAll(`${e} input`), this.allTextarea = this.element.querySelectorAll(`${e} textarea`), this.allCheckbox = this.element.querySelectorAll(`${e} input[type="checkbox"]`), this.allRadio = this.element.querySelectorAll(`${e} input[type="radio"]`), this.allFileUpload = this.element.querySelectorAll(`${e} .fake-file-upload`), this.allDropdown = this.element.querySelectorAll(`${e} dropdown-el`), this.submitEvent = new Event("submit");
|
|
235
235
|
const o = {
|
|
236
236
|
locale: "zh-TW",
|
|
237
237
|
datepicker: [
|
|
@@ -260,13 +260,13 @@ class le {
|
|
|
260
260
|
underField: !1,
|
|
261
261
|
detailOutput: !1
|
|
262
262
|
}
|
|
263
|
-
},
|
|
264
|
-
const
|
|
265
|
-
for (let
|
|
266
|
-
typeof
|
|
267
|
-
return
|
|
263
|
+
}, i = (f, y) => {
|
|
264
|
+
const d = { ...f };
|
|
265
|
+
for (let c of Object.keys(y))
|
|
266
|
+
typeof y[c] == "object" && c in f ? d[c] = Array.isArray(d[c]) ? [...y[c]] : i(f[c], y[c]) : d[c] = y[c];
|
|
267
|
+
return d;
|
|
268
268
|
};
|
|
269
|
-
this.options = t ?
|
|
269
|
+
this.options = t ? i(o, t) : o, this.init();
|
|
270
270
|
}
|
|
271
271
|
init() {
|
|
272
272
|
var t;
|
|
@@ -281,50 +281,51 @@ class le {
|
|
|
281
281
|
const e = this;
|
|
282
282
|
let t = {};
|
|
283
283
|
return [...e.allField].forEach((o) => {
|
|
284
|
-
|
|
284
|
+
var y;
|
|
285
|
+
const i = o.getAttribute("form-field");
|
|
285
286
|
switch (o.getAttribute("field-type")) {
|
|
286
287
|
case "isRadio":
|
|
287
|
-
const
|
|
288
|
-
if (!
|
|
288
|
+
const d = o.querySelector("input:checked");
|
|
289
|
+
if (!d)
|
|
289
290
|
return;
|
|
290
|
-
const
|
|
291
|
-
t[
|
|
292
|
-
id: parseInt(
|
|
293
|
-
value:
|
|
291
|
+
const c = d.querySelector('input[type="text"]');
|
|
292
|
+
t[i] = {
|
|
293
|
+
id: parseInt(d.closest(".option-item").querySelector(".text").getAttribute("data-id")),
|
|
294
|
+
value: c ? c.value : d.closest(".option-item").querySelector(".text").textContent
|
|
294
295
|
};
|
|
295
296
|
break;
|
|
296
297
|
case "isCheckBox":
|
|
297
|
-
const
|
|
298
|
-
t[
|
|
299
|
-
const
|
|
298
|
+
const l = o.querySelectorAll("input:checked");
|
|
299
|
+
t[i] = [...l].map((a) => {
|
|
300
|
+
const u = a.querySelector('input[type="text"]');
|
|
300
301
|
return {
|
|
301
|
-
id: parseInt(
|
|
302
|
-
value:
|
|
302
|
+
id: parseInt(a.closest(".option-item").querySelector(".text").getAttribute("data-id")),
|
|
303
|
+
value: u ? u.value : a.closest(".option-item").querySelector(".text").textContent
|
|
303
304
|
};
|
|
304
305
|
});
|
|
305
306
|
break;
|
|
306
307
|
case "isSelect":
|
|
307
308
|
switch (o.hasAttribute("multiple") ? "multiple" : "single") {
|
|
308
309
|
case "single":
|
|
309
|
-
t[
|
|
310
|
+
t[i] = {
|
|
310
311
|
value: o.s.value.id ? o.s.value.id : "",
|
|
311
312
|
display: o.s.value.el ? o.s.value.el.textContent : ""
|
|
312
313
|
};
|
|
313
314
|
break;
|
|
314
315
|
case "multiple":
|
|
315
|
-
t[
|
|
316
|
-
value: o.s.value.map((
|
|
317
|
-
display: o.s.value.map((
|
|
316
|
+
t[i] = {
|
|
317
|
+
value: o.s.value.map((a) => a.id),
|
|
318
|
+
display: o.s.value.map((a) => a.el.textContent)
|
|
318
319
|
};
|
|
319
320
|
break;
|
|
320
321
|
}
|
|
321
322
|
break;
|
|
322
323
|
case "isFile":
|
|
323
|
-
const
|
|
324
|
-
t[
|
|
324
|
+
const n = (y = o.closest(".file-wrap")) == null ? void 0 : y.querySelector('input[type="file"]');
|
|
325
|
+
t[i] = (n == null ? void 0 : n.files) ?? void 0;
|
|
325
326
|
break;
|
|
326
327
|
default:
|
|
327
|
-
t[
|
|
328
|
+
t[i] = o.value;
|
|
328
329
|
break;
|
|
329
330
|
}
|
|
330
331
|
}), t;
|
|
@@ -335,25 +336,25 @@ class le {
|
|
|
335
336
|
* @returns
|
|
336
337
|
*/
|
|
337
338
|
verify(e) {
|
|
338
|
-
var
|
|
339
|
-
const t = this, { options: o } = t,
|
|
340
|
-
function
|
|
341
|
-
var s,
|
|
339
|
+
var d;
|
|
340
|
+
const t = this, { options: o } = t, i = t.element.value, f = e || i;
|
|
341
|
+
function y(c) {
|
|
342
|
+
var s, n, a, u;
|
|
342
343
|
const l = '<div class="validation-icon"></div>';
|
|
343
|
-
for (const q in
|
|
344
|
-
const k = t.element.querySelector(`[form-field="${q}"]`), L = k.getAttribute("data-verify"),
|
|
344
|
+
for (const q in c) {
|
|
345
|
+
const k = t.element.querySelector(`[form-field="${q}"]`), L = k.getAttribute("data-verify"), p = k.closest(".form-group");
|
|
345
346
|
switch (L) {
|
|
346
347
|
case "select":
|
|
347
|
-
const A = k.querySelector(".select-wrapper"),
|
|
348
|
-
(s = A.querySelector(".validation-icon")) == null || s.remove(), A.insertBefore(C(l),
|
|
348
|
+
const A = k.querySelector(".select-wrapper"), m = A.querySelector(".dropdown-icon");
|
|
349
|
+
(s = A.querySelector(".validation-icon")) == null || s.remove(), A.insertBefore(C(l), m);
|
|
349
350
|
break;
|
|
350
351
|
case "radio":
|
|
351
352
|
case "checkbox":
|
|
352
|
-
(
|
|
353
|
+
(n = p.querySelector(".validation-icon")) == null || n.remove(), p.append(C(l));
|
|
353
354
|
break;
|
|
354
355
|
case "file":
|
|
355
356
|
const v = k.closest(".file-wrap").querySelector(".fake-file-upload"), b = k.closest(".file-wrap").querySelector(".upload-icon");
|
|
356
|
-
(
|
|
357
|
+
(a = v.querySelector(".validation-icon")) == null || a.remove(), b ? v.insertBefore(C(l), b) : v.append(C(l));
|
|
357
358
|
break;
|
|
358
359
|
case "date":
|
|
359
360
|
case "textarea":
|
|
@@ -363,14 +364,14 @@ class le {
|
|
|
363
364
|
}
|
|
364
365
|
}
|
|
365
366
|
}
|
|
366
|
-
if (
|
|
367
|
-
const
|
|
368
|
-
t.element.querySelectorAll(`.error-text[name="${
|
|
367
|
+
if (y(f), e) {
|
|
368
|
+
const c = Object.keys(f)[0];
|
|
369
|
+
t.element.querySelectorAll(`.error-text[name="${c}"]`).forEach((l) => l.remove());
|
|
369
370
|
} else
|
|
370
|
-
t.element.querySelectorAll(".error-text").forEach((
|
|
371
|
-
for (const
|
|
372
|
-
let
|
|
373
|
-
const g = t.element.querySelector(`[form-field="${
|
|
371
|
+
t.element.querySelectorAll(".error-text").forEach((c) => c.remove());
|
|
372
|
+
for (const c in f) {
|
|
373
|
+
let p = function(v, b, x) {
|
|
374
|
+
const g = t.element.querySelector(`[form-field="${c}"]`), $ = [...t.element.querySelectorAll("[form-field]")].indexOf(g), S = (F) => `<p class="error-text" name="${c}" index="${$}">${n} - ${E[o.locale][F]}</p>`;
|
|
374
375
|
switch (b) {
|
|
375
376
|
case "underField":
|
|
376
377
|
if (!o.errorText.underField)
|
|
@@ -392,22 +393,22 @@ class le {
|
|
|
392
393
|
return (g = t.detailOutputEl) == null ? void 0 : g.appendChild(x);
|
|
393
394
|
});
|
|
394
395
|
};
|
|
395
|
-
const l = t.element.querySelector(`[form-field="${
|
|
396
|
-
let
|
|
396
|
+
const l = t.element.querySelector(`[form-field="${c}"]`), s = l.closest(".form-group"), n = (d = s.querySelector(".subject")) == null ? void 0 : d.textContent, a = l.getAttribute("data-verify"), u = () => typeof i[c] == "object" && !Array.isArray(i[c]) ? a === "file" ? i[c] : i[c].value : i[c], q = () => a === "file" ? u() === void 0 ? !0 : u() && u().length === 0 : Array.isArray(u()) && u().length === 0 || !Array.isArray(u()) && w.isEmpty(u()), k = () => a === "file" ? u() === void 0 ? !1 : u() && u().length > 0 : Array.isArray(u()) && u().length > 0 || !Array.isArray(u()) && !w.isEmpty(u()), L = s.classList.contains("required");
|
|
397
|
+
let m;
|
|
397
398
|
if (L && q())
|
|
398
|
-
switch (l.classList.remove("success"), l.classList.add("error"), s.classList.add("error"),
|
|
399
|
+
switch (l.classList.remove("success"), l.classList.add("error"), s.classList.add("error"), a) {
|
|
399
400
|
case "select":
|
|
400
|
-
|
|
401
|
+
m = l.querySelector(".validation-icon"), m.setAttribute("error-text", E[o.locale].select), p("select", "underField", s.parentNode), p("select", "detail", t.detailOutputEl);
|
|
401
402
|
break;
|
|
402
403
|
case "radio":
|
|
403
404
|
case "checkbox":
|
|
404
|
-
|
|
405
|
+
m = s.querySelector(".validation-icon"), m.setAttribute("error-text", E[o.locale].select), p("select", "underField", s.parentNode), p("select", "detail", t.detailOutputEl);
|
|
405
406
|
break;
|
|
406
407
|
case "file":
|
|
407
|
-
|
|
408
|
+
m = l.closest(".file-wrap").querySelector(".validation-icon"), m.setAttribute("error-text", E[o.locale].file), p("file", "underField", s.parentNode), p("file", "detail", t.detailOutputEl);
|
|
408
409
|
break;
|
|
409
410
|
default:
|
|
410
|
-
|
|
411
|
+
m = l.closest(".input-wrap").querySelector(".validation-icon"), m.setAttribute("error-text", E[o.locale].input), p("input", "underField", s.parentNode), p("input", "detail", t.detailOutputEl);
|
|
411
412
|
break;
|
|
412
413
|
}
|
|
413
414
|
if (k()) {
|
|
@@ -417,25 +418,25 @@ class le {
|
|
|
417
418
|
const S = b.getAttribute("data-verify") === "phone" ? g.querySelector("*:not(input)[form-field]") : g.querySelector("*:not(dropdown-el)[form-field]"), F = !!S, I = b.classList.contains("success"), B = b.classList.contains("error"), M = S == null ? void 0 : S.classList.contains("success"), N = S == null ? void 0 : S.classList.contains("error");
|
|
418
419
|
F ? M && !N && I ? (g.classList.remove("error"), g.classList.add("success")) : (N || B) && (g.classList.remove("success"), g.classList.add("error")) : I ? (g.classList.remove("error"), g.classList.add("success")) : (g.classList.add("error"), g.classList.remove("success"));
|
|
419
420
|
};
|
|
420
|
-
switch (
|
|
421
|
+
switch (a) {
|
|
421
422
|
case "phone":
|
|
422
423
|
const b = s.querySelector("dropdown-el");
|
|
423
|
-
|
|
424
|
+
w.isMobilePhone(u()) ? (v(l, !0), b && b.classList.contains("success") && (s.classList.remove("error"), s.classList.add("success"))) : (v(l, !1), m = l.closest(".input-wrap").querySelector(".validation-icon"), m.setAttribute("error-text", E[o.locale].format), p("format", "underField", s.parentNode), p("format", "detail", t.detailOutputEl));
|
|
424
425
|
break;
|
|
425
426
|
case "password":
|
|
426
|
-
|
|
427
|
+
w.isStrongPassword(u(), {
|
|
427
428
|
minLength: 8,
|
|
428
429
|
minLowercase: 1,
|
|
429
430
|
minUppercase: 0,
|
|
430
431
|
minNumbers: 1,
|
|
431
432
|
minSymbols: 0
|
|
432
|
-
}) ? v(l, !0) : (v(l, !1),
|
|
433
|
+
}) ? v(l, !0) : (v(l, !1), m = l.closest(".input-wrap").querySelector(".validation-icon"), m.setAttribute("error-text", E[o.locale].format), p("format", "underField", s.parentNode), p("format", "detail", t.detailOutputEl));
|
|
433
434
|
break;
|
|
434
435
|
case "email":
|
|
435
|
-
|
|
436
|
+
w.isEmail(u()) ? v(l, !0) : (v(l, !1), m = l.closest(".input-wrap").querySelector(".validation-icon"), m.setAttribute("error-text", E[o.locale].format), p("format", "underField", s.parentNode), p("format", "detail", t.detailOutputEl));
|
|
436
437
|
break;
|
|
437
438
|
case "verifyCode":
|
|
438
|
-
|
|
439
|
+
w.isNumeric(u(), { no_symbols: !0 }) && w.isLength(u(), { min: 4, max: 4 }) ? v(l, !0) : (v(l, !1), m = l.closest(".input-wrap").querySelector(".validation-icon"), m.setAttribute("error-text", E[o.locale].format), p("format", "underField", s.parentNode), p("format", "detail", t.detailOutputEl));
|
|
439
440
|
break;
|
|
440
441
|
case "select":
|
|
441
442
|
default:
|
|
@@ -457,91 +458,91 @@ class le {
|
|
|
457
458
|
* 清除表單所有欄位
|
|
458
459
|
*/
|
|
459
460
|
clear() {
|
|
460
|
-
const e = this, { allInput: t, allTextarea: o, allCheckbox:
|
|
461
|
-
[...e.allField].forEach((
|
|
461
|
+
const e = this, { allInput: t, allTextarea: o, allCheckbox: i, allFileUpload: f, allDropdown: y } = e;
|
|
462
|
+
[...e.allField].forEach((d) => {
|
|
462
463
|
var l;
|
|
463
|
-
const
|
|
464
|
-
|
|
465
|
-
}), [...t].forEach((
|
|
466
|
-
|
|
467
|
-
}), [...o].forEach((
|
|
468
|
-
|
|
469
|
-
}), [...
|
|
470
|
-
|
|
471
|
-
}), [...
|
|
472
|
-
let
|
|
473
|
-
const l =
|
|
474
|
-
l.classList.remove("is-upload"), l.textContent =
|
|
475
|
-
}), [...
|
|
476
|
-
|
|
464
|
+
const c = d.closest(".form-group");
|
|
465
|
+
c.classList.remove("success"), c.classList.remove("error"), d.classList.remove("success"), d.classList.remove("error"), (l = d.closest(".form-grid").querySelector(".error-text")) == null || l.remove(), e.detailOutputEl && (e.detailOutputEl.textContent = "");
|
|
466
|
+
}), [...t].forEach((d) => {
|
|
467
|
+
d.value = "";
|
|
468
|
+
}), [...o].forEach((d) => {
|
|
469
|
+
d.value = "";
|
|
470
|
+
}), [...i].forEach((d) => {
|
|
471
|
+
d.checked = !1;
|
|
472
|
+
}), [...f].forEach((d) => {
|
|
473
|
+
let c = d.getAttribute("data-default");
|
|
474
|
+
const l = d.querySelector(".file-name"), s = d.closest(".file-wrap").querySelector('input[type="file"]');
|
|
475
|
+
l.classList.remove("is-upload"), l.textContent = c, s && (s.value = "");
|
|
476
|
+
}), [...y].forEach((d) => {
|
|
477
|
+
d.setAttribute("d4-value", ""), d.hasAttribute("control-elements") && [...d.getAttribute("control-elements").split(",")].forEach((l) => {
|
|
477
478
|
document.querySelector(l).classList.remove("disabled");
|
|
478
479
|
});
|
|
479
480
|
}), e.element.value = e.getValue();
|
|
480
481
|
}
|
|
481
482
|
}
|
|
482
483
|
T = new WeakSet(), P = function() {
|
|
483
|
-
const e = this, { datepicker: t, timepicker: o, clearEl:
|
|
484
|
-
function
|
|
484
|
+
const e = this, { datepicker: t, timepicker: o, clearEl: i, submitEl: f } = e.options;
|
|
485
|
+
function y() {
|
|
485
486
|
t.forEach((s) => {
|
|
486
487
|
_(s.el, s.options);
|
|
487
488
|
}), o.forEach((s) => {
|
|
488
489
|
_(s.el, s.options);
|
|
489
490
|
});
|
|
490
491
|
}
|
|
491
|
-
function
|
|
492
|
-
const s = document.querySelector(
|
|
492
|
+
function d() {
|
|
493
|
+
const s = document.querySelector(i), n = document.querySelector(f);
|
|
493
494
|
s == null || s.addEventListener("click", function() {
|
|
494
495
|
e.clear();
|
|
495
|
-
}),
|
|
496
|
+
}), n == null || n.addEventListener("click", function() {
|
|
496
497
|
e.submit();
|
|
497
498
|
});
|
|
498
499
|
}
|
|
499
|
-
function
|
|
500
|
-
var
|
|
501
|
-
const
|
|
500
|
+
function c(s) {
|
|
501
|
+
var m;
|
|
502
|
+
const n = s.closest(".form-group");
|
|
502
503
|
if (s.files.length <= 0)
|
|
503
504
|
return;
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
const u =
|
|
507
|
-
L > q ? (
|
|
505
|
+
const a = s.closest(".file-wrap").querySelector(".fake-file-upload");
|
|
506
|
+
a.getAttribute("data-default");
|
|
507
|
+
const u = a.querySelector(".file-name"), q = Number(s.getAttribute("data-limit")), k = s.files[0], L = k.size / 1024 / 1024, p = k.name, A = s.cloneNode(!0);
|
|
508
|
+
L > q ? (n.classList.add("error"), n.classList.remove("success"), A.value = "") : (n.classList.remove("error"), n.classList.add("success")), u.textContent = p, A.removeAttribute("form-field field-type data-limit"), (m = a.querySelector('input[type="file"]')) == null || m.remove(), a.append(A);
|
|
508
509
|
}
|
|
509
510
|
function l() {
|
|
510
511
|
e.element.addEventListener(
|
|
511
512
|
"input",
|
|
512
513
|
z(function(s) {
|
|
513
|
-
const { target:
|
|
514
|
-
if (
|
|
515
|
-
if (e.element.value = e.getValue(), !
|
|
516
|
-
|
|
514
|
+
const { target: n } = s;
|
|
515
|
+
if (n.matches('[type="text"],[type="number"],[type="email"],[type="password"], textarea')) {
|
|
516
|
+
if (e.element.value = e.getValue(), !n.closest(".form-group").classList.contains("required") && n.hasAttribute("data-verify")) {
|
|
517
|
+
w.isEmpty(n.value) && (n.classList.remove("error"), n.classList.remove("success"), n.closest(".form-group").classList.remove("error"));
|
|
517
518
|
return;
|
|
518
519
|
}
|
|
519
|
-
const
|
|
520
|
-
[
|
|
520
|
+
const a = n.getAttribute("form-field"), u = {
|
|
521
|
+
[a]: e.element.value[a]
|
|
521
522
|
};
|
|
522
523
|
e.options.verify && e.verify(u);
|
|
523
524
|
}
|
|
524
525
|
})
|
|
525
526
|
), e.element.addEventListener("change", (s) => {
|
|
526
|
-
const { target:
|
|
527
|
-
let
|
|
528
|
-
|
|
529
|
-
[
|
|
530
|
-
}, e.verify(u)),
|
|
531
|
-
[
|
|
527
|
+
const { target: n } = s;
|
|
528
|
+
let a, u;
|
|
529
|
+
n.matches('[type="radio"], [type="checkbox"]') && (e.element.value = e.getValue(), a = n.closest(".form-check").getAttribute("form-field"), u = {
|
|
530
|
+
[a]: e.element.value[a]
|
|
531
|
+
}, e.verify(u)), n.matches('[type="file"]') && (c(n), e.element.value = e.getValue(), a = n.getAttribute("form-field"), u = {
|
|
532
|
+
[a]: e.element.value[a]
|
|
532
533
|
}, e.verify(u));
|
|
533
534
|
}), e.allDropdown.forEach((s) => {
|
|
534
535
|
s.on("change", function() {
|
|
535
|
-
const
|
|
536
|
+
const n = this.getAttribute("form-field");
|
|
536
537
|
e.element.value = e.getValue();
|
|
537
|
-
const
|
|
538
|
-
[
|
|
538
|
+
const a = e.element.value[n], u = typeof a == "object" && !Array.isArray(a) ? a.value : a, q = {
|
|
539
|
+
[n]: a
|
|
539
540
|
};
|
|
540
|
-
(Array.isArray(u) && u.length > 0 || !Array.isArray(u) && !
|
|
541
|
+
(Array.isArray(u) && u.length > 0 || !Array.isArray(u) && !w.isEmpty(u)) && e.options.verify && e.verify(q);
|
|
541
542
|
});
|
|
542
543
|
});
|
|
543
544
|
}
|
|
544
|
-
|
|
545
|
+
y(), d(), l();
|
|
545
546
|
};
|
|
546
547
|
export {
|
|
547
548
|
le as CustomForm,
|
|
@@ -559,7 +560,7 @@ export {
|
|
|
559
560
|
ve as detectMacOSVersion,
|
|
560
561
|
W as detectShade,
|
|
561
562
|
se as errorPage,
|
|
562
|
-
|
|
563
|
+
E as errorText,
|
|
563
564
|
ge as fixMobile100vh,
|
|
564
565
|
be as formatFloat,
|
|
565
566
|
ke as getSlideDataIndex,
|
|
@@ -567,9 +568,9 @@ export {
|
|
|
567
568
|
Se as getTransformX,
|
|
568
569
|
Ae as getTransformY,
|
|
569
570
|
C as htmlStringToDOM,
|
|
570
|
-
|
|
571
|
+
we as imagePreview,
|
|
571
572
|
ie as init,
|
|
572
|
-
|
|
573
|
+
Ee as isVideo,
|
|
573
574
|
qe as letterGrow,
|
|
574
575
|
Ce as loaded,
|
|
575
576
|
Le as loading,
|