@xwadex/fesd 0.0.67 → 0.0.69

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.
@@ -1,78 +1,65 @@
1
- var U = (r, e, t) => {
2
- if (!e.has(r))
3
- throw TypeError("Cannot " + t);
4
- };
5
- var D = (r, e, t) => {
6
- if (e.has(r))
7
- throw TypeError("Cannot add the same private member more than once");
8
- e instanceof WeakSet ? e.add(r) : e.set(r, t);
9
- };
10
- var V = (r, e, t) => (U(r, e, "access private method"), t);
11
- import { n as z, o as C } from "./image-preview-bundle.js";
12
- import { w as ue, z as de, y as fe, F as pe, E as me, J as ye, K as he, B as ve, L as ge, O as be, P as ke, Q as xe, X as Se, Y as Ae, u as we, U as Ee, W as qe, t as Ce, r as Le, V as Oe, p as Te, q as Fe, G as Ge, S as $e, x as Ie, H as Ne, N as De } from "./image-preview-bundle.js";
13
- import { o as H, z as Q } from "./vendor-bundle.js";
1
+ import { n as V, x as C } from "./image-preview-bundle.js";
2
+ import { e as re, f as se, h as ie, i as ae, j as le, l as ne, o as ce, p as ue, q as de, r as fe, t as pe, u as me, v as he, w as ye, y as ve, G as ge, H as be, J as ke, K as xe, L as Se, N as Ae, O as we, Q as Ce, S as Ee, U as qe, V as Le, Y as Oe } from "./image-preview-bundle.js";
3
+ import { o as _, z as j } from "./vendor-bundle.js";
14
4
  import h from "jquery";
15
- import w from "validator";
16
- import _ from "flatpickr";
17
- function se() {
18
- if (!document.body.classList.contains("error") || document.querySelector(".back-home") == null)
19
- return;
20
- let r, e = 5;
5
+ import x from "validator";
6
+ import $ from "flatpickr";
7
+ function J() {
8
+ if (!document.body.classList.contains("error") || document.querySelector(".back-home") == null) return;
9
+ let l, e = 5;
21
10
  const t = document.querySelector(".back-home").getAttribute("href"), o = document.querySelector(".back-home .countdown");
22
- r = setInterval(() => {
23
- e--, o.textContent = e, e === 0 && (clearInterval(r), window.location.href = t);
11
+ l = setInterval(() => {
12
+ e--, o.textContent = e, e === 0 && (clearInterval(l), window.location.href = t);
24
13
  }, 1e3);
25
14
  }
26
- function W(r, e = r) {
27
- if (r.complete) {
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");
15
+ function B(l, e = l) {
16
+ if (l.complete) {
17
+ const o = new _().getColor(l), n = o[0] * 0.299 + o[1] * 0.587 + o[2] * 0.114;
18
+ O(n, e), e.classList.add("detected");
30
19
  }
31
20
  }
32
- function G(r, e) {
21
+ function O(l, e) {
33
22
  const t = e.getAttribute("addClassEl");
34
- r >= 192 ? t && t !== "" ? t.split(",").forEach((o) => {
35
- var i;
36
- e.closest(o) || console.error(`closest "${o}" not found`), (i = e.closest(o)) == null || i.classList.add("is-light");
23
+ l >= 192 ? t && t !== "" ? t.split(",").forEach((o) => {
24
+ e.closest(o) || console.error(`closest "${o}" not found`), e.closest(o)?.classList.add("is-light");
37
25
  }) : e.classList.add("is-light") : t && t !== "" ? t.split(",").forEach((o) => {
38
- var i;
39
- e.closest(o) || console.error(`closest "${o}" not found`), (i = e.closest(o)) == null || i.classList.add("is-dark");
26
+ e.closest(o) || console.error(`closest "${o}" not found`), e.closest(o)?.classList.add("is-dark");
40
27
  }) : e.classList.add("is-dark");
41
28
  }
42
- function R(r, e, t) {
43
- const o = document.createElement("canvas"), i = o.getContext("2d");
44
- if (o.width = 50, o.height = 50, r !== "" && e === "")
45
- i.fillStyle = r;
46
- else if (r !== "" && e !== "") {
47
- const y = i.createLinearGradient(0, 0, o.width, o.height);
48
- y.addColorStop(0, r), y.addColorStop(1, e), i.fillStyle = y;
29
+ function P(l, e, t) {
30
+ const o = document.createElement("canvas"), n = o.getContext("2d");
31
+ if (o.width = 50, o.height = 50, l !== "" && e === "")
32
+ n.fillStyle = l;
33
+ else if (l !== "" && e !== "") {
34
+ const f = n.createLinearGradient(0, 0, o.width, o.height);
35
+ f.addColorStop(0, l), f.addColorStop(1, e), n.fillStyle = f;
49
36
  }
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
- W(this, t);
54
- }), f;
37
+ n.fillRect(0, 0, o.width, o.height);
38
+ const u = new Image();
39
+ return u.src = o.toDataURL(), u.crossOrigin = "Anonymous", u.addEventListener("load", function() {
40
+ B(this, t);
41
+ }), u;
55
42
  }
56
- function ie() {
43
+ function X() {
57
44
  [...document.querySelectorAll(".detect-shade:not(.detected)")].forEach((e) => {
58
45
  if (e.tagName === "IMG")
59
46
  return;
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 === "") {
47
+ const t = ["#FFF", "#FFFFFF", "#fff", "#ffffff"], o = ["#000", "#000000"], n = getComputedStyle(e).getPropertyValue("--start-color"), u = getComputedStyle(e).getPropertyValue("--end-color");
48
+ if (n === "" && u === "") {
62
49
  console.error(e, "=> No color set!");
63
50
  return;
64
- } else if (t.indexOf(i) > 0) {
65
- console.warn(e, "=> TypeError!! ( #FFF ) "), G(255, e);
51
+ } else if (t.indexOf(n) > 0) {
52
+ console.warn(e, "=> TypeError!! ( #FFF ) "), O(255, e);
66
53
  return;
67
- } else if (o.indexOf(i) > 0) {
68
- console.warn(e, "=> TypeError!! ( #000 ) "), G(0, e);
54
+ } else if (o.indexOf(n) > 0) {
55
+ console.warn(e, "=> TypeError!! ( #000 ) "), O(0, e);
69
56
  return;
70
57
  }
71
- R(i, f, e);
58
+ P(n, u, e);
72
59
  });
73
60
  }
74
- const O = {
75
- CG_A: function(r) {
61
+ const M = {
62
+ CG_A: function(l) {
76
63
  h("html,body").delay(100).animate(
77
64
  { opacity: "0" },
78
65
  {
@@ -80,12 +67,12 @@ const O = {
80
67
  duration: 800,
81
68
  easing: "easeOutQuad",
82
69
  complete: function() {
83
- window.location.assign(r);
70
+ window.location.assign(l);
84
71
  }
85
72
  }
86
73
  );
87
74
  },
88
- CG_B: function(r) {
75
+ CG_B: function(l) {
89
76
  h("main").append("<div id='CG_Abg'><div class='CG_Abg1'></div><div class='CG_Abg2'></div></div>"), h("body").delay(1200).animate(
90
77
  { opacity: "0" },
91
78
  {
@@ -94,13 +81,13 @@ const O = {
94
81
  easing: "easeOutQuad",
95
82
  complete: function() {
96
83
  setTimeout(function() {
97
- window.location.assign(r);
84
+ window.location.assign(l);
98
85
  }, 100);
99
86
  }
100
87
  }
101
88
  );
102
89
  },
103
- CG_C: function(r) {
90
+ CG_C: function(l) {
104
91
  h("main").append("<div id='CG_Bbg'></div>"), h("body").delay(1200).animate(
105
92
  { opacity: "0" },
106
93
  {
@@ -109,13 +96,13 @@ const O = {
109
96
  easing: "easeOutQuad",
110
97
  complete: function() {
111
98
  setTimeout(function() {
112
- window.location.assign(r);
99
+ window.location.assign(l);
113
100
  }, 100);
114
101
  }
115
102
  }
116
103
  );
117
104
  },
118
- CG_D: function(r) {
105
+ CG_D: function(l) {
119
106
  h("main").append("<div id='CG_Cbg'><div class='CG_Cbg1'></div><div class='CG_Cbg2'></div></div>"), h("body").delay(1200).animate(
120
107
  { opacity: "0" },
121
108
  {
@@ -124,75 +111,62 @@ const O = {
124
111
  easing: "easeOutQuad",
125
112
  complete: function() {
126
113
  setTimeout(function() {
127
- window.location.assign(r);
114
+ window.location.assign(l);
128
115
  }, 100);
129
116
  }
130
117
  }
131
118
  );
132
119
  }
133
- }, K = (r) => {
134
- switch (1) {
135
- case 1:
136
- O.CG_A(r);
137
- break;
138
- case 2:
139
- O.CG_B(r);
140
- break;
141
- case 3:
142
- O.CG_C(r);
143
- break;
144
- case 4:
145
- O.CG_D(r);
146
- break;
147
- }
148
- }, j = (r, e) => {
149
- r.preventDefault();
150
- const t = h(r.currentTarget), o = t.attr("target"), i = t.attr("href");
151
- let f;
120
+ }, U = (l) => {
121
+ M.CG_A(l);
122
+ }, I = (l, e) => {
123
+ l.preventDefault();
124
+ const t = h(l.currentTarget), o = t.attr("target"), n = t.attr("href");
125
+ let u;
152
126
  if (e) {
153
127
  if (t.is("[data-nolink]")) {
154
- r.stopPropagation(), r.preventDefault();
128
+ l.stopPropagation(), l.preventDefault();
155
129
  return;
156
130
  }
157
- t.hasClass("href-link") ? f = t.closest("[data-href]").attr("data-href") : f = i;
131
+ t.hasClass("href-link") ? u = t.closest("[data-href]").attr("data-href") : u = n;
158
132
  } else {
159
133
  if (t.is("[data-nolink]")) {
160
- r.stopPropagation(), r.preventDefault();
134
+ l.stopPropagation(), l.preventDefault();
161
135
  return;
162
136
  }
163
- t.hasClass("click-block") ? f = t.closest("[data-href]").attr("data-href") : f = i;
137
+ t.hasClass("click-block") ? u = t.closest("[data-href]").attr("data-href") : u = n;
164
138
  }
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
- l = s(l);
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;
139
+ let a = window.location.pathname.replace("http://", "").split("/");
140
+ a = c(a);
141
+ const s = u.replace("http://", "");
142
+ let d = s.split("/");
143
+ d = c(d);
144
+ function c(i) {
145
+ const r = i.pop();
146
+ return r.indexOf("#") > -1 || r.indexOf("html") > 0 ? i.push(r) : (r == "" || i.push(r), i.push("index.html")), i;
173
147
  }
174
- o == "_blank" || r.ctrlKey || r.metaKey ? window.open(f) : c.indexOf("jpg") > -1 || c.indexOf("javascript") > -1 || K(f);
175
- }, X = (r) => {
176
- const t = h(r.currentTarget).closest("[data-href]");
148
+ o == "_blank" || l.ctrlKey || l.metaKey ? window.open(u) : s.indexOf("jpg") > -1 || s.indexOf("javascript") > -1 || U(u);
149
+ }, z = (l) => {
150
+ const t = h(l.currentTarget).closest("[data-href]");
177
151
  t.hasClass("isHover") || t.addClass("isHover");
178
- }, Y = (r) => {
179
- const t = h(r.currentTarget).closest("[data-href]");
152
+ }, H = (l) => {
153
+ const t = h(l.currentTarget).closest("[data-href]");
180
154
  t.hasClass("isHover") && t.removeClass("isHover");
181
- }, ae = (r = !0) => {
155
+ }, Z = (l = !0) => {
182
156
  h.easing.jswing = h.easing.swing, h.extend(h.easing, {
183
157
  def: "easeOutQuad",
184
- easeOutQuad: function(e, t, o, i, f) {
185
- return -i * (t /= f) * (t - 2) + o;
158
+ easeOutQuad: function(e, t, o, n, u) {
159
+ return -n * (t /= u) * (t - 2) + o;
186
160
  },
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;
161
+ easeInOutCirc: function(e, t, o, n, u) {
162
+ return (t /= u / 2) < 1 ? -n / 2 * (Math.sqrt(1 - t * t) - 1) + o : n / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + o;
189
163
  }
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) {
164
+ }), l ? (h("body").on("click", "a:not(.nocg), .href-link, [data-nolink]", (e) => I(e, l)), h("body").on("click", "a:not(.nocg)", function(e) {
191
165
  e.stopPropagation();
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) {
166
+ })) : (h("body").on("click", "a:not(.nocg), .click-block, [data-nolink]", (e) => I(e, l)), h("body").on("click", "a:not(.nocg)", function(e) {
193
167
  e.stopPropagation();
194
- })), h("body").on("mouseenter", "[data-href] a", (e) => X(e)), h("body").on("mouseleave", "[data-href] a", (e) => Y(e));
195
- }, E = {
168
+ })), h("body").on("mouseenter", "[data-href] a", (e) => z(e)), h("body").on("mouseleave", "[data-href] a", (e) => H(e));
169
+ }, S = {
196
170
  "zh-TW": {
197
171
  format: "格式錯誤",
198
172
  input: "尚未填寫",
@@ -224,13 +198,8 @@ const O = {
224
198
  select: ""
225
199
  }
226
200
  };
227
- var T, P;
228
- class le {
201
+ class ee {
229
202
  constructor(e, t) {
230
- /**
231
- * 綁事件
232
- */
233
- D(this, T);
234
203
  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
204
  const o = {
236
205
  locale: "zh-TW",
@@ -238,7 +207,7 @@ class le {
238
207
  {
239
208
  el: ".datepicker-input",
240
209
  options: {
241
- locale: Q.Mandarin
210
+ locale: j.Mandarin
242
211
  }
243
212
  }
244
213
  ],
@@ -260,18 +229,82 @@ class le {
260
229
  underField: !1,
261
230
  detailOutput: !1
262
231
  }
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;
232
+ }, n = (u, f) => {
233
+ const a = { ...u };
234
+ for (let s of Object.keys(f))
235
+ typeof f[s] == "object" && s in u ? a[s] = Array.isArray(a[s]) ? [...f[s]] : n(u[s], f[s]) : a[s] = f[s];
236
+ return a;
268
237
  };
269
- this.options = t ? i(o, t) : o, this.init();
238
+ this.options = t ? n(o, t) : o, this.init();
270
239
  }
271
240
  init() {
272
- var t;
273
241
  const e = this;
274
- e.element.value = e.getValue(), e.detailOutputEl = e.options.errorText.detailOutput ? document.querySelector(e.options.errorText.detailOutput) : null, V(t = e, T, P).call(t);
242
+ e.element.value = e.getValue(), e.detailOutputEl = e.options.errorText.detailOutput ? document.querySelector(e.options.errorText.detailOutput) : null, e.#e();
243
+ }
244
+ /**
245
+ * 綁事件
246
+ */
247
+ #e() {
248
+ const e = this, { datepicker: t, timepicker: o, clearEl: n, submitEl: u } = e.options;
249
+ function f() {
250
+ t.forEach((c) => {
251
+ $(c.el, c.options);
252
+ }), o.forEach((c) => {
253
+ $(c.el, c.options);
254
+ });
255
+ }
256
+ function a() {
257
+ const c = document.querySelector(n), i = document.querySelector(u);
258
+ c?.addEventListener("click", function() {
259
+ e.clear();
260
+ }), i?.addEventListener("click", function() {
261
+ e.submit();
262
+ });
263
+ }
264
+ function s(c) {
265
+ const i = c.closest(".form-group");
266
+ if (c.files.length <= 0) return;
267
+ const r = c.closest(".file-wrap").querySelector(".fake-file-upload");
268
+ r.getAttribute("data-default");
269
+ const y = r.querySelector(".file-name"), w = Number(c.getAttribute("data-limit")), A = c.files[0], p = A.size / 1024 / 1024, q = A.name, m = c.cloneNode(!0);
270
+ p > w ? (i.classList.add("error"), i.classList.remove("success"), m.value = "") : (i.classList.remove("error"), i.classList.add("success")), y.textContent = q, m.removeAttribute("form-field field-type data-limit"), r.querySelector('input[type="file"]')?.remove(), r.append(m);
271
+ }
272
+ function d() {
273
+ e.element.addEventListener(
274
+ "input",
275
+ V(function(c) {
276
+ const { target: i } = c;
277
+ if (i.matches('[type="text"],[type="number"],[type="email"],[type="password"], textarea')) {
278
+ if (e.element.value = e.getValue(), !i.closest(".form-group").classList.contains("required") && i.hasAttribute("data-verify")) {
279
+ x.isEmpty(i.value) && (i.classList.remove("error"), i.classList.remove("success"), i.closest(".form-group").classList.remove("error"));
280
+ return;
281
+ }
282
+ const r = i.getAttribute("form-field"), y = {
283
+ [r]: e.element.value[r]
284
+ };
285
+ e.options.verify && e.verify(y);
286
+ }
287
+ })
288
+ ), e.element.addEventListener("change", (c) => {
289
+ const { target: i } = c;
290
+ let r, y;
291
+ i.matches('[type="radio"], [type="checkbox"]') && (e.element.value = e.getValue(), r = i.closest(".form-check").getAttribute("form-field"), y = {
292
+ [r]: e.element.value[r]
293
+ }, e.verify(y)), i.matches('[type="file"]') && (s(i), e.element.value = e.getValue(), r = i.getAttribute("form-field"), y = {
294
+ [r]: e.element.value[r]
295
+ }, e.verify(y));
296
+ }), e.allDropdown.forEach((c) => {
297
+ c.on("change", function() {
298
+ const i = this.getAttribute("form-field");
299
+ e.element.value = e.getValue();
300
+ const r = e.element.value[i], y = typeof r == "object" && !Array.isArray(r) ? r.value : r, w = {
301
+ [i]: r
302
+ };
303
+ (Array.isArray(y) && y.length > 0 || !Array.isArray(y) && !x.isEmpty(y)) && e.options.verify && e.verify(w);
304
+ });
305
+ });
306
+ }
307
+ f(), a(), d();
275
308
  }
276
309
  /**
277
310
  * 取得表單所有的值
@@ -281,51 +314,54 @@ class le {
281
314
  const e = this;
282
315
  let t = {};
283
316
  return [...e.allField].forEach((o) => {
284
- var y;
285
- const i = o.getAttribute("form-field");
317
+ const n = o.getAttribute("form-field");
286
318
  switch (o.getAttribute("field-type")) {
319
+ // 單選Radio
287
320
  case "isRadio":
288
- const d = o.querySelector("input:checked");
289
- if (!d)
290
- return;
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
321
+ const f = o.querySelector("input:checked");
322
+ if (!f) return;
323
+ const a = f.querySelector('input[type="text"]');
324
+ t[n] = {
325
+ id: parseInt(f.closest(".option-item").querySelector(".text").getAttribute("data-id")),
326
+ value: a ? a.value : f.closest(".option-item").querySelector(".text").textContent
295
327
  };
296
328
  break;
329
+ // 複選Checkbox
297
330
  case "isCheckBox":
298
- const l = o.querySelectorAll("input:checked");
299
- t[i] = [...l].map((a) => {
300
- const u = a.querySelector('input[type="text"]');
331
+ const s = o.querySelectorAll("input:checked");
332
+ t[n] = [...s].map((i) => {
333
+ const r = i.querySelector('input[type="text"]');
301
334
  return {
302
- id: parseInt(a.closest(".option-item").querySelector(".text").getAttribute("data-id")),
303
- value: u ? u.value : a.closest(".option-item").querySelector(".text").textContent
335
+ id: parseInt(i.closest(".option-item").querySelector(".text").getAttribute("data-id")),
336
+ value: r ? r.value : i.closest(".option-item").querySelector(".text").textContent
304
337
  };
305
338
  });
306
339
  break;
340
+ // 下拉選單
307
341
  case "isSelect":
308
342
  switch (o.hasAttribute("multiple") ? "multiple" : "single") {
309
343
  case "single":
310
- t[i] = {
344
+ t[n] = {
311
345
  value: o.s.value.id ? o.s.value.id : "",
312
346
  display: o.s.value.el ? o.s.value.el.textContent : ""
313
347
  };
314
348
  break;
315
349
  case "multiple":
316
- t[i] = {
317
- value: o.s.value.map((a) => a.id),
318
- display: o.s.value.map((a) => a.el.textContent)
350
+ t[n] = {
351
+ value: o.s.value.map((i) => i.id),
352
+ display: o.s.value.map((i) => i.el.textContent)
319
353
  };
320
354
  break;
321
355
  }
322
356
  break;
357
+ // 檔案上傳
323
358
  case "isFile":
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;
359
+ const c = o.closest(".file-wrap")?.querySelector('input[type="file"]');
360
+ t[n] = c?.files ?? void 0;
326
361
  break;
362
+ // 其他
327
363
  default:
328
- t[i] = o.value;
364
+ t[n] = o.value;
329
365
  break;
330
366
  }
331
367
  }), t;
@@ -336,115 +372,105 @@ class le {
336
372
  * @returns
337
373
  */
338
374
  verify(e) {
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;
343
- const l = '<div class="validation-icon"></div>';
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");
346
- switch (L) {
375
+ const t = this, { options: o } = t, n = t.element.value, u = e || n;
376
+ function f(a) {
377
+ const s = '<div class="validation-icon"></div>';
378
+ for (const d in a) {
379
+ const c = t.element.querySelector(`[form-field="${d}"]`), i = c.getAttribute("data-verify"), r = c.closest(".form-group");
380
+ switch (i) {
347
381
  case "select":
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);
382
+ const y = c.querySelector(".select-wrapper"), w = y.querySelector(".dropdown-icon");
383
+ y.querySelector(".validation-icon")?.remove(), y.insertBefore(C(s), w);
350
384
  break;
351
385
  case "radio":
352
386
  case "checkbox":
353
- (n = p.querySelector(".validation-icon")) == null || n.remove(), p.append(C(l));
387
+ r.querySelector(".validation-icon")?.remove(), r.append(C(s));
354
388
  break;
355
389
  case "file":
356
- const v = k.closest(".file-wrap").querySelector(".fake-file-upload"), b = k.closest(".file-wrap").querySelector(".upload-icon");
357
- (a = v.querySelector(".validation-icon")) == null || a.remove(), b ? v.insertBefore(C(l), b) : v.append(C(l));
390
+ const A = c.closest(".file-wrap").querySelector(".fake-file-upload"), p = c.closest(".file-wrap").querySelector(".upload-icon");
391
+ A.querySelector(".validation-icon")?.remove(), p ? A.insertBefore(C(s), p) : A.append(C(s));
358
392
  break;
359
- case "date":
360
- case "textarea":
361
393
  default:
362
- (u = k.closest(".input-wrap").querySelector(".validation-icon")) == null || u.remove(), k.closest(".input-wrap").append(C(l));
394
+ c.closest(".input-wrap").querySelector(".validation-icon")?.remove(), c.closest(".input-wrap").append(C(s));
363
395
  break;
364
396
  }
365
397
  }
366
398
  }
367
- if (y(f), e) {
368
- const c = Object.keys(f)[0];
369
- t.element.querySelectorAll(`.error-text[name="${c}"]`).forEach((l) => l.remove());
399
+ if (f(u), e) {
400
+ const a = Object.keys(u)[0];
401
+ t.element.querySelectorAll(`.error-text[name="${a}"]`).forEach((s) => s.remove());
370
402
  } else
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>`;
403
+ t.element.querySelectorAll(".error-text").forEach((a) => a.remove());
404
+ for (const a in u) {
405
+ let p = function(v, b, k) {
406
+ const g = t.element.querySelector(`[form-field="${a}"]`), F = [...t.element.querySelectorAll("[form-field]")].indexOf(g), E = (L) => `<p class="error-text" name="${a}" index="${F}">${c} - ${S[o.locale][L]}</p>`;
375
407
  switch (b) {
376
408
  case "underField":
377
- if (!o.errorText.underField)
378
- return;
379
- x.append(C(S(v)));
409
+ if (!o.errorText.underField) return;
410
+ k.append(C(E(v)));
380
411
  break;
381
412
  case "detail":
382
- if (!x)
383
- return;
384
- x.append(C(S(v)));
413
+ if (!k) return;
414
+ k.append(C(E(v)));
385
415
  break;
386
416
  }
387
- }, A = function() {
417
+ }, q = function() {
388
418
  const v = t.detailOutputEl.querySelectorAll(".error-text");
389
419
  [...v].length > 0 ? t.element.classList.add("something-wrong") : t.element.classList.remove("something-wrong");
390
- const b = [...v].sort((x, g) => x.getAttribute("index") - g.getAttribute("index"));
391
- t.detailOutputEl && (t.detailOutputEl.textContent = ""), b.forEach((x) => {
392
- var g;
393
- return (g = t.detailOutputEl) == null ? void 0 : g.appendChild(x);
394
- });
420
+ const b = [...v].sort((k, g) => k.getAttribute("index") - g.getAttribute("index"));
421
+ t.detailOutputEl && (t.detailOutputEl.textContent = ""), b.forEach((k) => t.detailOutputEl?.appendChild(k));
395
422
  };
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");
423
+ const s = t.element.querySelector(`[form-field="${a}"]`), d = s.closest(".form-group"), c = d.querySelector(".subject")?.textContent, i = s.getAttribute("data-verify"), r = () => typeof n[a] == "object" && !Array.isArray(n[a]) ? i === "file" ? n[a] : n[a].value : n[a], y = () => i === "file" ? r() === void 0 ? !0 : r() && r().length === 0 : Array.isArray(r()) && r().length === 0 || !Array.isArray(r()) && x.isEmpty(r()), w = () => i === "file" ? r() === void 0 ? !1 : r() && r().length > 0 : Array.isArray(r()) && r().length > 0 || !Array.isArray(r()) && !x.isEmpty(r()), A = d.classList.contains("required");
397
424
  let m;
398
- if (L && q())
399
- switch (l.classList.remove("success"), l.classList.add("error"), s.classList.add("error"), a) {
425
+ if (A && y())
426
+ switch (s.classList.remove("success"), s.classList.add("error"), d.classList.add("error"), i) {
400
427
  case "select":
401
- m = l.querySelector(".validation-icon"), m.setAttribute("error-text", E[o.locale].select), p("select", "underField", s.parentNode), p("select", "detail", t.detailOutputEl);
428
+ m = s.querySelector(".validation-icon"), m.setAttribute("error-text", S[o.locale].select), p("select", "underField", d.parentNode), p("select", "detail", t.detailOutputEl);
402
429
  break;
403
430
  case "radio":
404
431
  case "checkbox":
405
- m = s.querySelector(".validation-icon"), m.setAttribute("error-text", E[o.locale].select), p("select", "underField", s.parentNode), p("select", "detail", t.detailOutputEl);
432
+ m = d.querySelector(".validation-icon"), m.setAttribute("error-text", S[o.locale].select), p("select", "underField", d.parentNode), p("select", "detail", t.detailOutputEl);
406
433
  break;
407
434
  case "file":
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);
435
+ m = s.closest(".file-wrap").querySelector(".validation-icon"), m.setAttribute("error-text", S[o.locale].file), p("file", "underField", d.parentNode), p("file", "detail", t.detailOutputEl);
409
436
  break;
410
437
  default:
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);
438
+ m = s.closest(".input-wrap").querySelector(".validation-icon"), m.setAttribute("error-text", S[o.locale].input), p("input", "underField", d.parentNode), p("input", "detail", t.detailOutputEl);
412
439
  break;
413
440
  }
414
- if (k()) {
415
- let v = function(b, x) {
441
+ if (w()) {
442
+ let v = function(b, k) {
416
443
  const g = b.closest(".form-group");
417
- b.classList.toggle("error", !x), b.classList.toggle("success", x);
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");
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"));
444
+ b.classList.toggle("error", !k), b.classList.toggle("success", k);
445
+ const E = b.getAttribute("data-verify") === "phone" ? g.querySelector("*:not(input)[form-field]") : g.querySelector("*:not(dropdown-el)[form-field]"), L = !!E, T = b.classList.contains("success"), N = b.classList.contains("error"), D = E?.classList.contains("success"), G = E?.classList.contains("error");
446
+ L ? D && !G && T ? (g.classList.remove("error"), g.classList.add("success")) : (G || N) && (g.classList.remove("success"), g.classList.add("error")) : T ? (g.classList.remove("error"), g.classList.add("success")) : (g.classList.add("error"), g.classList.remove("success"));
420
447
  };
421
- switch (a) {
448
+ switch (i) {
422
449
  case "phone":
423
- const b = s.querySelector("dropdown-el");
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));
450
+ const b = d.querySelector("dropdown-el");
451
+ x.isMobilePhone(r()) ? (v(s, !0), b && b.classList.contains("success") && (d.classList.remove("error"), d.classList.add("success"))) : (v(s, !1), m = s.closest(".input-wrap").querySelector(".validation-icon"), m.setAttribute("error-text", S[o.locale].format), p("format", "underField", d.parentNode), p("format", "detail", t.detailOutputEl));
425
452
  break;
426
453
  case "password":
427
- w.isStrongPassword(u(), {
454
+ x.isStrongPassword(r(), {
428
455
  minLength: 8,
429
456
  minLowercase: 1,
430
457
  minUppercase: 0,
431
458
  minNumbers: 1,
432
459
  minSymbols: 0
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));
460
+ }) ? v(s, !0) : (v(s, !1), m = s.closest(".input-wrap").querySelector(".validation-icon"), m.setAttribute("error-text", S[o.locale].format), p("format", "underField", d.parentNode), p("format", "detail", t.detailOutputEl));
434
461
  break;
435
462
  case "email":
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));
463
+ x.isEmail(r()) ? v(s, !0) : (v(s, !1), m = s.closest(".input-wrap").querySelector(".validation-icon"), m.setAttribute("error-text", S[o.locale].format), p("format", "underField", d.parentNode), p("format", "detail", t.detailOutputEl));
437
464
  break;
438
465
  case "verifyCode":
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));
466
+ x.isNumeric(r(), { no_symbols: !0 }) && x.isLength(r(), { min: 4, max: 4 }) ? v(s, !0) : (v(s, !1), m = s.closest(".input-wrap").querySelector(".validation-icon"), m.setAttribute("error-text", S[o.locale].format), p("format", "underField", d.parentNode), p("format", "detail", t.detailOutputEl));
440
467
  break;
441
- case "select":
442
468
  default:
443
- v(l, !0);
469
+ v(s, !0);
444
470
  break;
445
471
  }
446
472
  }
447
- t.detailOutputEl && A();
473
+ t.detailOutputEl && q();
448
474
  }
449
475
  }
450
476
  /**
@@ -458,129 +484,64 @@ class le {
458
484
  * 清除表單所有欄位
459
485
  */
460
486
  clear() {
461
- const e = this, { allInput: t, allTextarea: o, allCheckbox: i, allFileUpload: f, allDropdown: y } = e;
462
- [...e.allField].forEach((d) => {
463
- var l;
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) => {
478
- document.querySelector(l).classList.remove("disabled");
487
+ const e = this, { allInput: t, allTextarea: o, allCheckbox: n, allFileUpload: u, allDropdown: f } = e;
488
+ [...e.allField].forEach((a) => {
489
+ const s = a.closest(".form-group");
490
+ s.classList.remove("success"), s.classList.remove("error"), a.classList.remove("success"), a.classList.remove("error"), a.closest(".form-grid").querySelector(".error-text")?.remove(), e.detailOutputEl && (e.detailOutputEl.textContent = "");
491
+ }), [...t].forEach((a) => {
492
+ a.value = "";
493
+ }), [...o].forEach((a) => {
494
+ a.value = "";
495
+ }), [...n].forEach((a) => {
496
+ a.checked = !1;
497
+ }), [...u].forEach((a) => {
498
+ let s = a.getAttribute("data-default");
499
+ const d = a.querySelector(".file-name"), c = a.closest(".file-wrap").querySelector('input[type="file"]');
500
+ d.classList.remove("is-upload"), d.textContent = s, c && (c.value = "");
501
+ }), [...f].forEach((a) => {
502
+ a.setAttribute("d4-value", ""), a.hasAttribute("control-elements") && [...a.getAttribute("control-elements").split(",")].forEach((d) => {
503
+ document.querySelector(d).classList.remove("disabled");
479
504
  });
480
505
  }), e.element.value = e.getValue();
481
506
  }
482
507
  }
483
- T = new WeakSet(), P = function() {
484
- const e = this, { datepicker: t, timepicker: o, clearEl: i, submitEl: f } = e.options;
485
- function y() {
486
- t.forEach((s) => {
487
- _(s.el, s.options);
488
- }), o.forEach((s) => {
489
- _(s.el, s.options);
490
- });
491
- }
492
- function d() {
493
- const s = document.querySelector(i), n = document.querySelector(f);
494
- s == null || s.addEventListener("click", function() {
495
- e.clear();
496
- }), n == null || n.addEventListener("click", function() {
497
- e.submit();
498
- });
499
- }
500
- function c(s) {
501
- var m;
502
- const n = s.closest(".form-group");
503
- if (s.files.length <= 0)
504
- return;
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);
509
- }
510
- function l() {
511
- e.element.addEventListener(
512
- "input",
513
- z(function(s) {
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"));
518
- return;
519
- }
520
- const a = n.getAttribute("form-field"), u = {
521
- [a]: e.element.value[a]
522
- };
523
- e.options.verify && e.verify(u);
524
- }
525
- })
526
- ), e.element.addEventListener("change", (s) => {
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]
533
- }, e.verify(u));
534
- }), e.allDropdown.forEach((s) => {
535
- s.on("change", function() {
536
- const n = this.getAttribute("form-field");
537
- e.element.value = e.getValue();
538
- const a = e.element.value[n], u = typeof a == "object" && !Array.isArray(a) ? a.value : a, q = {
539
- [n]: a
540
- };
541
- (Array.isArray(u) && u.length > 0 || !Array.isArray(u) && !w.isEmpty(u)) && e.options.verify && e.verify(q);
542
- });
543
- });
544
- }
545
- y(), d(), l();
546
- };
547
508
  export {
548
- le as CustomForm,
549
- ue as ajaxUpdate,
550
- de as appleDebug,
551
- fe as bodyScrollbarInit,
552
- ae as cgpagechange,
553
- pe as clickSwitchClass,
554
- me as clickToggleClass,
555
- G as colorPick,
556
- ye as countDown,
557
- R as createColorCube,
558
- z as debounce,
559
- he as delay,
560
- ve as detectMacOSVersion,
561
- W as detectShade,
562
- se as errorPage,
563
- E as errorText,
564
- ge as fixMobile100vh,
565
- be as formatFloat,
566
- ke as getSlideDataIndex,
567
- xe as getSlidesCount,
568
- Se as getTransformX,
569
- Ae as getTransformY,
509
+ ee as CustomForm,
510
+ re as ajaxUpdate,
511
+ se as appleDebug,
512
+ ie as bodyScrollbarInit,
513
+ Z as cgpagechange,
514
+ ae as clickSwitchClass,
515
+ le as clickToggleClass,
516
+ O as colorPick,
517
+ ne as countDown,
518
+ P as createColorCube,
519
+ V as debounce,
520
+ ce as delay,
521
+ ue as detectMacOSVersion,
522
+ B as detectShade,
523
+ J as errorPage,
524
+ S as errorText,
525
+ de as fixMobile100vh,
526
+ fe as formatFloat,
527
+ pe as getSlideDataIndex,
528
+ me as getSlidesCount,
529
+ he as getTransformX,
530
+ ye as getTransformY,
570
531
  C as htmlStringToDOM,
571
- we as imagePreview,
572
- ie as init,
573
- Ee as isVideo,
574
- qe as letterGrow,
575
- Ce as loaded,
576
- Le as loading,
577
- Oe as numberGrow,
578
- Te as scrollLock,
579
- Fe as scrollUnlock,
580
- Ge as sleep,
581
- $e as slideImgDetect,
582
- Ie as tabChange,
583
- Ne as throttle,
584
- De as wordAnimation
532
+ ve as imagePreview,
533
+ X as init,
534
+ ge as isVideo,
535
+ be as letterGrow,
536
+ ke as loaded,
537
+ xe as loading,
538
+ Se as numberGrow,
539
+ Ae as scrollLock,
540
+ we as scrollUnlock,
541
+ Ce as sleep,
542
+ Ee as slideImgDetect,
543
+ qe as tabChange,
544
+ Le as throttle,
545
+ Oe as wordAnimation
585
546
  };
586
547
  //# sourceMappingURL=tools-bundle.js.map