@stonecrop/aform 0.3.7 → 0.3.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/dist/aform.js CHANGED
@@ -132,16 +132,16 @@ import './assets/index.css';const Ve = { class: "aform_form-element" }, Ie = ["f
132
132
  setup(e, { emit: t }) {
133
133
  const n = t, o = v(e.items), l = F(e, "modelValue"), s = v(!1), a = v(0), r = v(!1);
134
134
  N(() => {
135
- document.addEventListener("click", f), c();
135
+ document.addEventListener("click", f), u();
136
136
  }), we(() => {
137
137
  document.removeEventListener("click", f);
138
138
  });
139
- const u = (y) => {
139
+ const c = (y) => {
140
140
  l.value = y, m();
141
- }, c = () => {
141
+ }, u = () => {
142
142
  l.value ? o.value = e.items.filter((y) => y.toLowerCase().indexOf(l.value.toLowerCase()) > -1) : o.value = e.items;
143
143
  }, d = () => {
144
- r.value = !0, e.isAsync ? (s.value = !0, n("filterChanged", l.value)) : c();
144
+ r.value = !0, e.isAsync ? (s.value = !0, n("filterChanged", l.value)) : u();
145
145
  }, f = () => {
146
146
  m(), a.value = 0;
147
147
  }, m = () => {
@@ -174,7 +174,7 @@ import './assets/index.css';const Ve = { class: "aform_form-element" }, Ie = ["f
174
174
  w(i("ul", Ke, [
175
175
  s.value ? (p(), g("li", ze, "Loading results...")) : (p(!0), g(q, { key: 1 }, O(o.value, (x, h) => (p(), g("li", {
176
176
  key: h,
177
- onClick: (_) => u(x),
177
+ onClick: (_) => c(x),
178
178
  class: z(["autocomplete-result", { "is-active": h === a.value }])
179
179
  }, k(x), 11, Ne))), 128))
180
180
  ], 512), [
@@ -207,7 +207,7 @@ function U(...e) {
207
207
  Array.isArray(n) || (n = [n]), Array.isArray(o) || (o = [o]);
208
208
  const s = [], a = () => {
209
209
  s.forEach((d) => d()), s.length = 0;
210
- }, r = (d, f, m, b) => (d.addEventListener(f, m, b), () => d.removeEventListener(f, m, b)), u = W(
210
+ }, r = (d, f, m, b) => (d.addEventListener(f, m, b), () => d.removeEventListener(f, m, b)), c = W(
211
211
  () => [R(t), Q(l)],
212
212
  ([d, f]) => {
213
213
  if (a(), !d)
@@ -218,10 +218,10 @@ function U(...e) {
218
218
  );
219
219
  },
220
220
  { immediate: !0, flush: "post" }
221
- ), c = () => {
222
- u(), a();
221
+ ), u = () => {
222
+ c(), a();
223
223
  };
224
- return ve(c), c;
224
+ return ve(u), u;
225
225
  }
226
226
  function nt() {
227
227
  const e = v(!1), t = Ae();
@@ -238,17 +238,17 @@ function lt(e, t, n = {}) {
238
238
  let s;
239
239
  const a = ot(() => o && "MutationObserver" in o), r = () => {
240
240
  s && (s.disconnect(), s = void 0);
241
- }, u = V(() => {
241
+ }, c = V(() => {
242
242
  const m = Q(e), b = (Array.isArray(m) ? m : [m]).map(R).filter(Xe);
243
243
  return new Set(b);
244
- }), c = W(
245
- () => u.value,
244
+ }), u = W(
245
+ () => c.value,
246
246
  (m) => {
247
247
  r(), a.value && m.size && (s = new MutationObserver(t), m.forEach((b) => s.observe(b, l)));
248
248
  },
249
249
  { immediate: !0, flush: "post" }
250
250
  ), d = () => s == null ? void 0 : s.takeRecords(), f = () => {
251
- c(), r();
251
+ u(), r();
252
252
  };
253
253
  return ve(f), {
254
254
  isSupported: a,
@@ -263,25 +263,25 @@ function at(e = {}) {
263
263
  deep: o = !0,
264
264
  triggerOnRemoval: l = !1
265
265
  } = e, s = (t = e.document) != null ? t : n == null ? void 0 : n.document, a = () => {
266
- var c;
266
+ var u;
267
267
  let d = s == null ? void 0 : s.activeElement;
268
268
  if (o)
269
269
  for (; d != null && d.shadowRoot; )
270
- d = (c = d == null ? void 0 : d.shadowRoot) == null ? void 0 : c.activeElement;
270
+ d = (u = d == null ? void 0 : d.shadowRoot) == null ? void 0 : u.activeElement;
271
271
  return d;
272
- }, r = v(), u = () => {
272
+ }, r = v(), c = () => {
273
273
  r.value = a();
274
274
  };
275
- return n && (U(n, "blur", (c) => {
276
- c.relatedTarget === null && u();
277
- }, !0), U(n, "focus", u, !0)), l && lt(s, (c) => {
278
- c.filter((d) => d.removedNodes.length).map((d) => Array.from(d.removedNodes)).flat().forEach((d) => {
279
- d === r.value && u();
275
+ return n && (U(n, "blur", (u) => {
276
+ u.relatedTarget === null && c();
277
+ }, !0), U(n, "focus", c, !0)), l && lt(s, (u) => {
278
+ u.filter((d) => d.removedNodes.length).map((d) => Array.from(d.removedNodes)).flat().forEach((d) => {
279
+ d === r.value && c();
280
280
  });
281
281
  }, {
282
282
  childList: !0,
283
283
  subtree: !0
284
- }), u(), r;
284
+ }), c(), r;
285
285
  }
286
286
  const st = "focusin", rt = "focusout";
287
287
  function it(e, t = {}) {
@@ -335,8 +335,8 @@ const S = (e) => {
335
335
  if (n instanceof HTMLTableCellElement) {
336
336
  const l = (t = n.parentElement) == null ? void 0 : t.parentElement;
337
337
  if (l) {
338
- const s = l.firstElementChild.children[n.cellIndex];
339
- s && (o = s);
338
+ const s = l.firstElementChild, a = s == null ? void 0 : s.children[n.cellIndex];
339
+ a && (o = a);
340
340
  }
341
341
  } else if (n instanceof HTMLTableRowElement) {
342
342
  const l = n.parentElement;
@@ -370,8 +370,8 @@ const S = (e) => {
370
370
  if (n instanceof HTMLTableCellElement) {
371
371
  const l = (t = n.parentElement) == null ? void 0 : t.parentElement;
372
372
  if (l) {
373
- const s = l.lastElementChild.children[n.cellIndex];
374
- s && (o = s);
373
+ const s = l.lastElementChild, a = s == null ? void 0 : s.children[n.cellIndex];
374
+ a && (o = a);
375
375
  }
376
376
  } else if (n instanceof HTMLTableRowElement) {
377
377
  const l = n.parentElement;
@@ -408,11 +408,11 @@ const S = (e) => {
408
408
  }
409
409
  return n && (!$(n) || !S(n)) ? te(n) : n;
410
410
  }, se = (e) => {
411
- const t = e.target.parentElement.firstElementChild;
412
- return t && (!$(t) || !S(t)) ? te(t) : t;
411
+ const t = e.target.parentElement, n = t == null ? void 0 : t.firstElementChild;
412
+ return n && (!$(n) || !S(n)) ? te(n) : n;
413
413
  }, re = (e) => {
414
- const t = e.target.parentElement.lastElementChild;
415
- return t && (!$(t) || !S(t)) ? ee(t) : t;
414
+ const t = e.target.parentElement, n = t == null ? void 0 : t.lastElementChild;
415
+ return n && (!$(n) || !S(n)) ? ee(n) : n;
416
416
  }, G = ["alt", "control", "shift", "meta"], ft = {
417
417
  ArrowUp: "up",
418
418
  ArrowDown: "down",
@@ -487,33 +487,35 @@ function mt(e) {
487
487
  let r = null;
488
488
  return a.parent && (typeof a.parent == "string" ? r = document.querySelector(a.parent) : a.parent instanceof HTMLElement ? r = a.parent : r = a.parent.value), r;
489
489
  }, n = (a) => {
490
- const r = t(a);
490
+ var r;
491
+ const c = t(a);
491
492
  let u = [];
492
493
  if (typeof a.selectors == "string")
493
- u = r ? Array.from(r.querySelectorAll(a.selectors)) : Array.from(document.querySelectorAll(a.selectors));
494
+ u = c ? Array.from(c.querySelectorAll(a.selectors)) : Array.from(document.querySelectorAll(a.selectors));
494
495
  else if (Array.isArray(a.selectors))
495
- for (const c of a.selectors)
496
- c instanceof HTMLElement ? u.push(c) : u.push(c.$el);
496
+ for (const d of a.selectors)
497
+ d instanceof HTMLElement ? u.push(d) : u.push(d.$el);
497
498
  else if (a.selectors instanceof HTMLElement)
498
499
  u.push(a.selectors);
499
- else if (Array.isArray(a.selectors.value))
500
- for (const c of a.selectors.value)
501
- c instanceof HTMLElement ? u.push(c) : u.push(c.$el);
502
- else
503
- u.push(a.selectors.value);
500
+ else if ((r = a.selectors) != null && r.value)
501
+ if (Array.isArray(a.selectors.value))
502
+ for (const d of a.selectors.value)
503
+ d instanceof HTMLElement ? u.push(d) : u.push(d.$el);
504
+ else
505
+ u.push(a.selectors.value);
504
506
  return u;
505
507
  }, o = (a) => {
506
508
  const r = t(a);
507
- let u = [];
508
- return a.selectors ? u = n(a) : r && (u = Array.from(r.children).filter((c) => $(c) && S(c))), u;
509
+ let c = [];
510
+ return a.selectors ? c = n(a) : r && (c = Array.from(r.children).filter((u) => $(u) && S(u))), c;
509
511
  }, l = (a) => (r) => {
510
- const u = ft[r.key] || r.key.toLowerCase();
511
- if (G.includes(u)) return;
512
- const c = a.handlers || ge;
513
- for (const d of Object.keys(c)) {
512
+ const c = ft[r.key] || r.key.toLowerCase();
513
+ if (G.includes(c)) return;
514
+ const u = a.handlers || ge;
515
+ for (const d of Object.keys(u)) {
514
516
  const [f, ...m] = d.split(".");
515
- if (f === "keydown" && m.includes(u)) {
516
- const b = c[d], A = m.filter((y) => G.includes(y)), M = G.some((y) => {
517
+ if (f === "keydown" && m.includes(c)) {
518
+ const b = u[d], A = m.filter((y) => G.includes(y)), M = G.some((y) => {
517
519
  const E = y.charAt(0).toUpperCase() + y.slice(1);
518
520
  return r.getModifierState(E);
519
521
  });
@@ -532,10 +534,10 @@ function mt(e) {
532
534
  }, s = [];
533
535
  N(() => {
534
536
  for (const a of e) {
535
- const r = t(a), u = o(a), c = l(a), d = r ? [r] : u;
537
+ const r = t(a), c = o(a), u = l(a), d = r ? [r] : c;
536
538
  for (const f of d) {
537
539
  const { focused: m } = it(v(f)), b = W(m, (A) => {
538
- A ? f.addEventListener("keydown", c) : f.removeEventListener("keydown", c);
540
+ A ? f.addEventListener("keydown", u) : f.removeEventListener("keydown", u);
539
541
  });
540
542
  s.push(b);
541
543
  }
@@ -562,7 +564,7 @@ const pt = {
562
564
  setup(e, { expose: t }) {
563
565
  const n = F(e, "modelValue"), o = v(new Date(n.value)), l = v(o.value.getMonth()), s = v(o.value.getFullYear()), a = v([]), r = de("datepicker");
564
566
  N(async () => {
565
- u(), await Me();
567
+ c(), await Me();
566
568
  const h = document.getElementsByClassName("selectedDate");
567
569
  if (h.length > 0)
568
570
  h[0].focus();
@@ -571,15 +573,15 @@ const pt = {
571
573
  _.length > 0 && _[0].focus();
572
574
  }
573
575
  });
574
- const u = () => {
576
+ const c = () => {
575
577
  a.value = [];
576
578
  const h = new Date(s.value, l.value, 1), _ = h.getDay(), C = h.setDate(h.getDate() - _);
577
579
  for (const L of Array(43).keys())
578
580
  a.value.push(C + L * 864e5);
579
581
  };
580
- W([l, s], u);
581
- const c = () => s.value -= 1, d = () => s.value += 1, f = () => {
582
- l.value == 0 ? (l.value = 11, c()) : l.value -= 1;
582
+ W([l, s], c);
583
+ const u = () => s.value -= 1, d = () => s.value += 1, f = () => {
584
+ l.value == 0 ? (l.value = 11, u()) : l.value -= 1;
583
585
  }, m = () => {
584
586
  l.value == 11 ? (l.value = 0, d()) : l.value += 1;
585
587
  }, b = (h) => {
@@ -599,7 +601,7 @@ const pt = {
599
601
  handlers: {
600
602
  ...ge,
601
603
  "keydown.pageup": f,
602
- "keydown.shift.pageup": c,
604
+ "keydown.shift.pageup": u,
603
605
  "keydown.pagedown": m,
604
606
  "keydown.shift.pagedown": d,
605
607
  // TODO: this is a hack to override the stonecrop enter handler;
@@ -675,31 +677,31 @@ const pt = {
675
677
  setup(e, { emit: t }) {
676
678
  const n = t, o = v(e.data || {}), l = (a) => {
677
679
  let r = {};
678
- for (const [u, c] of Object.entries(a))
679
- ["component", "fieldtype"].includes(u) || (r[u] = c), u === "rows" && c && c.length === 0 && (r.rows = o.value[a.fieldname]);
680
+ for (const [c, u] of Object.entries(a))
681
+ ["component", "fieldtype"].includes(c) || (r[c] = u), c === "rows" && u && u.length === 0 && (r.rows = o.value[a.fieldname]);
680
682
  return r;
681
683
  }, s = V({
682
684
  get: () => e.modelValue.map((a, r) => V({
683
685
  get() {
684
686
  return a.value;
685
687
  },
686
- set: (u) => {
687
- e.modelValue[r].value = u, n("update:modelValue", e.modelValue);
688
+ set: (c) => {
689
+ e.modelValue[r].value = c, n("update:modelValue", e.modelValue);
688
690
  }
689
691
  })),
690
692
  set: () => {
691
693
  }
692
694
  });
693
695
  return (a, r) => (p(), g("form", wt, [
694
- (p(!0), g(q, null, O(a.modelValue, (u, c) => (p(), j(Ce(u.component), Te({
695
- key: c,
696
- schema: u,
697
- modelValue: s.value[c].value,
698
- "onUpdate:modelValue": (d) => s.value[c].value = d,
699
- data: o.value[u.fieldname],
696
+ (p(!0), g(q, null, O(a.modelValue, (c, u) => (p(), j(Ce(c.component), Te({
697
+ key: u,
698
+ schema: c,
699
+ modelValue: s.value[u].value,
700
+ "onUpdate:modelValue": (d) => s.value[u].value = d,
701
+ data: o.value[c.fieldname],
700
702
  readonly: a.readonly,
701
703
  ref_for: !0
702
- }, l(u)), null, 16, ["schema", "modelValue", "onUpdate:modelValue", "data", "readonly"]))), 128))
704
+ }, l(c)), null, 16, ["schema", "modelValue", "onUpdate:modelValue", "data", "readonly"]))), 128))
703
705
  ]));
704
706
  }
705
707
  }), he = /* @__PURE__ */ T(Dt, [["__scopeId", "data-v-68845234"]]), At = /* @__PURE__ */ D({
@@ -728,7 +730,7 @@ const pt = {
728
730
  Se(a.$slots, "default", { collapsed: n.value }, () => [
729
731
  w($e(he, {
730
732
  modelValue: l.value,
731
- "onUpdate:modelValue": r[0] || (r[0] = (u) => l.value = u),
733
+ "onUpdate:modelValue": r[0] || (r[0] = (c) => l.value = c),
732
734
  data: o.value
733
735
  }, null, 8, ["modelValue", "data"]), [
734
736
  [B, !n.value]
@@ -775,9 +777,9 @@ function Lt(e = {}) {
775
777
  }, r.oncancel = () => {
776
778
  a();
777
779
  });
778
- const u = () => {
780
+ const c = () => {
779
781
  n.value = null, r && r.value && (r.value = "", l(null));
780
- }, c = (d) => {
782
+ }, u = (d) => {
781
783
  if (!r)
782
784
  return;
783
785
  const f = {
@@ -785,12 +787,12 @@ function Lt(e = {}) {
785
787
  ...e,
786
788
  ...d
787
789
  };
788
- r.multiple = f.multiple, r.accept = f.accept, r.webkitdirectory = f.directory, Tt(f, "capture") && (r.capture = f.capture), f.reset && u(), r.click();
790
+ r.multiple = f.multiple, r.accept = f.accept, r.webkitdirectory = f.directory, Tt(f, "capture") && (r.capture = f.capture), f.reset && c(), r.click();
789
791
  };
790
792
  return {
791
793
  files: Le(n),
792
- open: c,
793
- reset: u,
794
+ open: u,
795
+ reset: c,
794
796
  onCancel: s,
795
797
  onChange: o
796
798
  };
@@ -811,19 +813,19 @@ const Vt = { class: "aform_form-element aform_file-attach aform__grid--full" },
811
813
  r[2] || (r[2] = pe(" You have selected: ")),
812
814
  i("b", null, k(s.value), 1)
813
815
  ]),
814
- (p(!0), g(q, null, O(I(t), (u) => (p(), g("li", {
815
- key: u.name
816
- }, k(u.name), 1))), 128))
816
+ (p(!0), g(q, null, O(I(t), (c) => (p(), g("li", {
817
+ key: c.name
818
+ }, k(c.name), 1))), 128))
817
819
  ])) : J("", !0),
818
820
  i("button", {
819
821
  type: "button",
820
- onClick: r[0] || (r[0] = (u) => I(n)()),
822
+ onClick: r[0] || (r[0] = (c) => I(n)()),
821
823
  class: "aform_form-btn"
822
824
  }, k(a.label), 1),
823
825
  i("button", {
824
826
  type: "button",
825
827
  disabled: !I(t),
826
- onClick: r[1] || (r[1] = (u) => I(o)()),
828
+ onClick: r[1] || (r[1] = (c) => I(o)()),
827
829
  class: "aform_form-btn"
828
830
  }, "Reset", 8, xt)
829
831
  ]));
@@ -883,17 +885,17 @@ function Ut(e) {
883
885
  }
884
886
  }
885
887
  function Wt(e) {
886
- var n;
888
+ var n, o, l;
887
889
  let t = e.value;
888
890
  if (t) {
889
- const o = Ut(t);
890
- if (o) {
891
- const l = e.instance.locale;
892
- t = o(l);
891
+ const s = Ut(t);
892
+ if (s) {
893
+ const a = (n = e.instance) == null ? void 0 : n.locale;
894
+ t = s(a);
893
895
  }
894
896
  } else {
895
- const o = e.instance.schema, l = (n = o == null ? void 0 : o.fieldtype) == null ? void 0 : n.toLowerCase();
896
- l && ce[l] && (t = ce[l]);
897
+ const s = (o = e.instance) == null ? void 0 : o.schema, a = (l = s == null ? void 0 : s.fieldtype) == null ? void 0 : l.toLowerCase();
898
+ a && ce[a] && (t = ce[a]);
897
899
  }
898
900
  return t;
899
901
  }
@@ -916,12 +918,13 @@ function Gt(e, t, n) {
916
918
  return o.slice(0, t.length);
917
919
  }
918
920
  function Kt(e, t) {
921
+ var a;
919
922
  const n = Wt(t);
920
923
  if (!n) return;
921
924
  const o = "#", l = e.value, s = Yt(l, o);
922
925
  if (s) {
923
- const a = Gt(s, n, o);
924
- t.instance.maskFilled && (t.instance.maskFilled = !a.includes(o)), e.value = a;
926
+ const r = Gt(s, n, o);
927
+ (a = t.instance) != null && a.maskFilled && (t.instance.maskFilled = !r.includes(o)), e.value = r;
925
928
  } else
926
929
  e.value = n;
927
930
  }
@@ -978,24 +981,24 @@ const zt = { class: "aform_form-element" }, Nt = ["id", "disabled", "maxlength",
978
981
  emits: ["loginFailed", "loginSuccess"],
979
982
  setup(e, { emit: t }) {
980
983
  const n = t, o = v(""), l = v(""), s = v(!1), a = v(!1);
981
- function r(u) {
982
- if (u.preventDefault(), s.value = !0, a.value) {
984
+ function r(c) {
985
+ if (c.preventDefault(), s.value = !0, a.value) {
983
986
  s.value = !1, n("loginFailed");
984
987
  return;
985
988
  }
986
989
  s.value = !1, n("loginSuccess");
987
990
  }
988
- return (u, c) => (p(), g("div", Xt, [
991
+ return (c, u) => (p(), g("div", Xt, [
989
992
  i("div", null, [
990
993
  i("div", Zt, [
991
994
  i("div", en, [
992
- i("h1", tn, k(u.headerTitle), 1),
993
- i("p", nn, k(u.headerSubtitle), 1)
995
+ i("h1", tn, k(c.headerTitle), 1),
996
+ i("p", nn, k(c.headerSubtitle), 1)
994
997
  ]),
995
998
  i("form", { onSubmit: r }, [
996
999
  i("div", on, [
997
1000
  i("div", ln, [
998
- c[2] || (c[2] = i("label", {
1001
+ u[2] || (u[2] = i("label", {
999
1002
  id: "login-email",
1000
1003
  for: "email",
1001
1004
  class: "aform_field-label"
@@ -1006,7 +1009,7 @@ const zt = { class: "aform_form-element" }, Nt = ["id", "disabled", "maxlength",
1006
1009
  name: "email",
1007
1010
  placeholder: "name@example.com",
1008
1011
  type: "email",
1009
- "onUpdate:modelValue": c[0] || (c[0] = (d) => o.value = d),
1012
+ "onUpdate:modelValue": u[0] || (u[0] = (d) => o.value = d),
1010
1013
  "auto-capitalize": "none",
1011
1014
  "auto-complete": "email",
1012
1015
  "auto-correct": "off",
@@ -1016,7 +1019,7 @@ const zt = { class: "aform_form-element" }, Nt = ["id", "disabled", "maxlength",
1016
1019
  ])
1017
1020
  ]),
1018
1021
  i("div", sn, [
1019
- c[3] || (c[3] = i("label", {
1022
+ u[3] || (u[3] = i("label", {
1020
1023
  id: "login-password",
1021
1024
  for: "password",
1022
1025
  class: "aform_field-label"
@@ -1026,7 +1029,7 @@ const zt = { class: "aform_form-element" }, Nt = ["id", "disabled", "maxlength",
1026
1029
  class: "aform_input-field",
1027
1030
  name: "password",
1028
1031
  type: "password",
1029
- "onUpdate:modelValue": c[1] || (c[1] = (d) => l.value = d),
1032
+ "onUpdate:modelValue": u[1] || (u[1] = (d) => l.value = d),
1030
1033
  disabled: s.value
1031
1034
  }, null, 8, rn), [
1032
1035
  [P, l.value]
@@ -1038,11 +1041,11 @@ const zt = { class: "aform_form-element" }, Nt = ["id", "disabled", "maxlength",
1038
1041
  disabled: s.value || !o.value || !l.value
1039
1042
  }, [
1040
1043
  s.value ? (p(), g("span", cn, "progress_activity")) : J("", !0),
1041
- c[4] || (c[4] = i("span", { id: "login-form-button" }, "Login", -1))
1044
+ u[4] || (u[4] = i("span", { id: "login-form-button" }, "Login", -1))
1042
1045
  ], 8, un)
1043
1046
  ])
1044
1047
  ], 32),
1045
- c[5] || (c[5] = i("button", { class: "btn" }, [
1048
+ u[5] || (u[5] = i("button", { class: "btn" }, [
1046
1049
  i("span", { id: "forgot-password-button" }, "Forgot password?")
1047
1050
  ], -1))
1048
1051
  ])