@dynamicforms/vue-forms 0.4.2 → 0.4.4

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,8 +1,8 @@
1
- var dt = Object.defineProperty, ft = Object.defineProperties;
1
+ var gt = Object.defineProperty, ft = Object.defineProperties;
2
2
  var pt = Object.getOwnPropertyDescriptors;
3
3
  var R = Object.getOwnPropertySymbols;
4
4
  var J = Object.prototype.hasOwnProperty, K = Object.prototype.propertyIsEnumerable;
5
- var $ = (n, s, t) => s in n ? dt(n, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[s] = t, A = (n, s) => {
5
+ var $ = (n, s, t) => s in n ? gt(n, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[s] = t, A = (n, s) => {
6
6
  for (var t in s || (s = {}))
7
7
  J.call(s, t) && $(n, t, s[t]);
8
8
  if (R)
@@ -21,7 +21,7 @@ var S = (n, s) => {
21
21
  };
22
22
  var o = (n, s, t) => $(n, typeof s != "symbol" ? s + "" : s, t);
23
23
  import { isEqual as U, isBoolean as bt, isString as C, isEmpty as M, truncate as mt, isArray as st, isObject as nt } from "lodash-es";
24
- import { unref as d, computed as z, reactive as vt, defineComponent as yt, resolveComponent as Z, createBlock as xt, openBlock as Et, h as w } from "vue";
24
+ import { unref as g, computed as z, reactive as vt, defineComponent as yt, resolveComponent as Z, createBlock as xt, openBlock as Et, h as w } from "vue";
25
25
  var N = /* @__PURE__ */ ((n) => (n[n.SUPPRESS = 1] = "SUPPRESS", n[n.HIDDEN = 5] = "HIDDEN", n[n.INVISIBLE = 8] = "INVISIBLE", n[n.FULL = 10] = "FULL", n))(N || {});
26
26
  const tt = 10;
27
27
  ((n) => {
@@ -41,7 +41,7 @@ const tt = 10;
41
41
  n.isDefined = e;
42
42
  })(N || (N = {}));
43
43
  Object.freeze(N);
44
- const V = N;
44
+ const _ = N;
45
45
  class b {
46
46
  constructor(s) {
47
47
  o(this, "executorFn");
@@ -86,7 +86,7 @@ class m extends b {
86
86
  class L extends String {
87
87
  }
88
88
  function G(n) {
89
- const s = d(n);
89
+ const s = g(n);
90
90
  return typeof s == "object" && "componentName" in s;
91
91
  }
92
92
  class W {
@@ -125,39 +125,39 @@ class p extends W {
125
125
  this.classes = e, this.text = t, this.textType = z(() => this.getTextType);
126
126
  }
127
127
  get getTextType() {
128
- const t = d(this.text);
128
+ const t = g(this.text);
129
129
  return t ? t instanceof L ? "md" : G(t) ? "component" : "string" : "string";
130
130
  }
131
131
  get componentName() {
132
- switch (d(this.textType)) {
132
+ switch (g(this.textType)) {
133
133
  case "string":
134
134
  return "template";
135
135
  case "md":
136
136
  return "vue-markdown";
137
137
  case "component":
138
- return d(this.text).componentName;
138
+ return g(this.text).componentName;
139
139
  default:
140
140
  return "template";
141
141
  }
142
142
  }
143
143
  get componentBindings() {
144
- switch (d(this.textType)) {
144
+ switch (g(this.textType)) {
145
145
  case "string":
146
146
  return {};
147
147
  case "md":
148
148
  return { source: this.text.toString() };
149
149
  case "component":
150
- return d(this.text).componentProps || {};
150
+ return g(this.text).componentProps || {};
151
151
  default:
152
152
  return {};
153
153
  }
154
154
  }
155
155
  get componentBody() {
156
- switch (d(this.textType)) {
156
+ switch (g(this.textType)) {
157
157
  case "string":
158
- return d(this.text);
158
+ return g(this.text);
159
159
  case "component":
160
- return d(this.text).componentVHtml || "";
160
+ return g(this.text).componentVHtml || "";
161
161
  default:
162
162
  return "";
163
163
  }
@@ -166,9 +166,9 @@ class p extends W {
166
166
  return this.classes;
167
167
  }
168
168
  }
169
- class Vt extends p {
169
+ class _t extends p {
170
170
  }
171
- const _t = Symbol("Validator");
171
+ const Vt = Symbol("Validator");
172
172
  class f extends m {
173
173
  /**
174
174
  * Creates a new validator
@@ -177,14 +177,14 @@ class f extends m {
177
177
  constructor(t) {
178
178
  super((i, r, a, l) => {
179
179
  const c = t(a, l, i) || [], u = (h) => {
180
- var _;
180
+ var V;
181
181
  h == null || h.forEach(
182
182
  (x) => Object.defineProperty(x, "source", { value: this.source, enumerable: !1, configurable: !1 })
183
183
  );
184
184
  for (let x = i.errors.length - 1; x >= 0; x--) {
185
185
  const P = i.errors[x];
186
186
  if (P.source === this.source) {
187
- const O = (_ = h == null ? void 0 : h.findIndex((B) => U(B, P))) != null ? _ : -1;
187
+ const O = (V = h == null ? void 0 : h.findIndex((B) => U(B, P))) != null ? V : -1;
188
188
  O >= 0 ? h == null || h.splice(O, 1) : i.errors.splice(x, 1);
189
189
  }
190
190
  }
@@ -199,7 +199,7 @@ class f extends m {
199
199
  }
200
200
  // eslint-disable-next-line class-methods-use-this
201
201
  static get classIdentifier() {
202
- return _t;
202
+ return Vt;
203
203
  }
204
204
  // eslint-disable-next-line class-methods-use-this
205
205
  get eager() {
@@ -295,7 +295,7 @@ class k extends m {
295
295
  class It extends k {
296
296
  constructor(s) {
297
297
  super(s, (t, e) => {
298
- t.visibility = e ? V.FULL : V.SUPPRESS;
298
+ t.visibility = e ? _.FULL : _.SUPPRESS;
299
299
  });
300
300
  }
301
301
  }
@@ -353,7 +353,7 @@ var j = /* @__PURE__ */ ((n) => (n[n.NOT = 0] = "NOT", n[n.OR = 1] = "OR", n[n.A
353
353
  n.isLogicOperator = i;
354
354
  })(j || (j = {}));
355
355
  Object.freeze(j);
356
- const g = j, Ft = Symbol("EnabledChangingAction");
356
+ const d = j, Ft = Symbol("EnabledChangingAction");
357
357
  class rt extends b {
358
358
  // eslint-disable-next-line @typescript-eslint/no-useless-constructor
359
359
  constructor(s) {
@@ -435,7 +435,7 @@ class y {
435
435
  // when member of a Group, fieldName specifies the name of this field
436
436
  o(this, "actions", new T());
437
437
  // default property handlers
438
- o(this, "_visibility", V.FULL);
438
+ o(this, "_visibility", _.FULL);
439
439
  o(this, "_enabled", !0);
440
440
  }
441
441
  get visibility() {
@@ -443,8 +443,8 @@ class y {
443
443
  }
444
444
  set visibility(s) {
445
445
  const t = this._visibility, e = this.actions.trigger(ot, this, s, t);
446
- if (!V.isDefined(e != null ? e : s)) throw new Error("visibility must be a DisplayMode constant");
447
- this._visibility = V.fromAny(e != null ? e : s), this.actions.trigger(ct, this, this._visibility, t);
446
+ if (!_.isDefined(e != null ? e : s)) throw new Error("visibility must be a DisplayMode constant");
447
+ this._visibility = _.fromAny(e != null ? e : s), this.actions.trigger(ct, this, this._visibility, t);
448
448
  }
449
449
  get enabled() {
450
450
  return this._enabled;
@@ -454,9 +454,10 @@ class y {
454
454
  if (!bt(e != null ? e : s)) throw new Error("Enabled value must be boolean");
455
455
  this._enabled = e != null ? e : s, this.actions.trigger(at, this, this._enabled, t);
456
456
  }
457
- validate() {
458
- const s = this._valid;
459
- this._valid = this.valid, this._valid !== s && this.actions.trigger(lt, this, this.valid, s);
457
+ validate(s = !1) {
458
+ s && this.actions.triggerEager(this, this.value, this.value);
459
+ const t = this._valid;
460
+ this._valid = this.valid, this._valid !== t && this.actions.trigger(lt, this, this.valid, t);
460
461
  }
461
462
  get valid() {
462
463
  return this.errors.length === 0;
@@ -489,46 +490,46 @@ class F {
489
490
  this.operand1 = s, this.operator = t, this.operand2 = e;
490
491
  }
491
492
  get operand1Value() {
492
- return this.operand1 instanceof F ? this.operand1.evaluate() : this.operand1 instanceof y ? d(this.operand1.value) : this.operand1;
493
+ return this.operand1 instanceof F ? this.operand1.evaluate() : this.operand1 instanceof y ? g(this.operand1.value) : this.operand1;
493
494
  }
494
495
  get operand2Value() {
495
- return this.operand2 instanceof F ? this.operand2.evaluate() : this.operand2 instanceof y ? d(this.operand2.value) : this.operand2;
496
+ return this.operand2 instanceof F ? this.operand2.evaluate() : this.operand2 instanceof y ? g(this.operand2.value) : this.operand2;
496
497
  }
497
498
  evaluate() {
498
499
  var e, i, r, a;
499
500
  const s = this.operand1Value, t = this.operand2Value;
500
501
  switch (this.operator) {
501
- case g.AND:
502
+ case d.AND:
502
503
  return s && t;
503
- case g.OR:
504
+ case d.OR:
504
505
  return s || t;
505
- case g.NAND:
506
+ case d.NAND:
506
507
  return !(s && t);
507
- case g.NOR:
508
+ case d.NOR:
508
509
  return !(s || t);
509
- case g.XOR:
510
+ case d.XOR:
510
511
  return Pt(s, t);
511
- case g.NOT:
512
+ case d.NOT:
512
513
  return !s;
513
- case g.EQUALS:
514
+ case d.EQUALS:
514
515
  return s == t;
515
- case g.NOT_EQUALS:
516
+ case d.NOT_EQUALS:
516
517
  return s != t;
517
- case g.LT:
518
+ case d.LT:
518
519
  return s < t;
519
- case g.LE:
520
+ case d.LE:
520
521
  return s <= t;
521
- case g.GE:
522
+ case d.GE:
522
523
  return s >= t;
523
- case g.GT:
524
+ case d.GT:
524
525
  return s > t;
525
- case g.IN:
526
+ case d.IN:
526
527
  return (i = (e = t == null ? void 0 : t.includes) == null ? void 0 : e.call(t, s)) != null ? i : !1;
527
- case g.NOT_IN:
528
+ case d.NOT_IN:
528
529
  return !((a = (r = t == null ? void 0 : t.includes) == null ? void 0 : r.call(t, s)) == null || a);
529
- case g.INCLUDES:
530
+ case d.INCLUDES:
530
531
  return C(s) && C(t) && s.indexOf(t) >= 0;
531
- case g.NOT_INCLUDES:
532
+ case d.NOT_INCLUDES:
532
533
  return !(C(s) && C(t) && s.indexOf(t) >= 0);
533
534
  default:
534
535
  throw new Error(`Operator not implemented ${this.operator}`);
@@ -679,37 +680,96 @@ const Bt = /* @__PURE__ */ yt({
679
680
  classes: { default: "text-error" }
680
681
  },
681
682
  setup(n) {
682
- const s = n, t = Z("vue-markdown"), e = () => {
683
+ const s = n, t = Z("vue-markdown"), e = /* @__PURE__ */ new Set([
684
+ "div",
685
+ "span",
686
+ "p",
687
+ "h1",
688
+ "h2",
689
+ "h3",
690
+ "h4",
691
+ "h5",
692
+ "h6",
693
+ "section",
694
+ "article",
695
+ "aside",
696
+ "nav",
697
+ "header",
698
+ "footer",
699
+ "main",
700
+ "figure",
701
+ "figcaption",
702
+ "blockquote",
703
+ "pre",
704
+ "code",
705
+ "em",
706
+ "strong",
707
+ "small",
708
+ "mark",
709
+ "del",
710
+ "ins",
711
+ "sub",
712
+ "sup",
713
+ "i",
714
+ "b",
715
+ "u",
716
+ "s",
717
+ "a",
718
+ "img",
719
+ "button",
720
+ "input",
721
+ "textarea",
722
+ "select",
723
+ "option",
724
+ "label",
725
+ "form",
726
+ "table",
727
+ "tr",
728
+ "td",
729
+ "th",
730
+ "thead",
731
+ "tbody",
732
+ "tfoot",
733
+ "ul",
734
+ "ol",
735
+ "li",
736
+ "dl",
737
+ "dt",
738
+ "dd"
739
+ ]), i = () => {
683
740
  if (typeof s.message == "string") return w("span", { class: s.classes }, s.message);
684
- const i = [];
685
- return s.message.forEach((r) => {
686
- switch (r.componentName) {
741
+ const r = [];
742
+ return s.message.forEach((a) => {
743
+ switch (a.componentName) {
687
744
  case "template":
688
- i.push(w("div", { class: [s.classes, r.extraClasses] }, r.componentBody));
745
+ r.push(w("div", { class: [s.classes, a.extraClasses] }, a.componentBody));
689
746
  break;
690
747
  case "vue-markdown":
691
748
  typeof t == "string" ? (console.warn(
692
749
  "You are using markdown for messages-widget, but you haven't registered a vue-markdown component"
693
- ), i.push(w("div", { class: [s.classes, r.extraClasses] }, r.componentBindings.source))) : i.push(w(
750
+ ), r.push(w("div", { class: [s.classes, a.extraClasses] }, a.componentBindings.source))) : r.push(w(
694
751
  t,
695
752
  {
696
- class: [s.classes, r.extraClasses, "df-messages-widget-markdown"],
697
- source: r.componentBindings.source
753
+ class: [s.classes, a.extraClasses, "df-messages-widget-markdown"],
754
+ source: a.componentBindings.source
698
755
  }
699
756
  ));
700
757
  break;
701
758
  default:
702
- i.push(
759
+ r.push(
703
760
  w(
704
- Z(r.componentName),
705
- I(A({ class: [s.classes, r.extraClasses] }, r.componentBindings), { innerHTML: r.componentBody })
761
+ e.has(a.componentName.toLowerCase()) ? (
762
+ // only resolve if it's not a common html element
763
+ a.componentName
764
+ ) : Z(a.componentName),
765
+ I(A({ class: [s.classes, a.extraClasses] }, a.componentBindings), { innerHTML: a.componentBody })
706
766
  )
707
767
  );
708
768
  break;
709
769
  }
710
- }), i;
770
+ }), r;
711
771
  };
712
- return (i, r) => (Et(), xt(e));
772
+ return (r, a) => (Et(), xt(i));
713
773
  }
714
774
  });
715
775
  class E extends y {
@@ -794,6 +854,9 @@ class E extends y {
794
854
  get valid() {
795
855
  return super.valid && Object.values(this._fields).every((t) => t.valid);
796
856
  }
857
+ validate(t = !1) {
858
+ t && Object.values(this._fields).forEach((e) => e.validate(!0)), super.validate(t);
859
+ }
797
860
  clone(t) {
798
861
  var r, a, l;
799
862
  const e = {};
@@ -858,6 +921,10 @@ class X extends y {
858
921
  var t, e;
859
922
  return super.valid && ((e = (t = this._value) == null ? void 0 : t.every((i) => i.valid)) != null ? e : !0);
860
923
  }
924
+ validate(t = !1) {
925
+ var e;
926
+ t && ((e = this._value) == null || e.forEach((i) => i.validate(!0))), super.validate(t);
927
+ }
861
928
  get(t) {
862
929
  return this._value != null ? this._value[t] : void 0;
863
930
  }
@@ -887,12 +954,12 @@ class X extends y {
887
954
  this._value = null, this.notifyValueChanged();
888
955
  }
889
956
  }
890
- const gt = { useMarkdownInValidators: !0 };
957
+ const dt = { useMarkdownInValidators: !0 };
891
958
  function $t() {
892
- return gt;
959
+ return dt;
893
960
  }
894
961
  function qt(n) {
895
- Object.assign(gt, n);
962
+ Object.assign(dt, n);
896
963
  }
897
964
  const ie = {
898
965
  install(n, s) {
@@ -906,11 +973,11 @@ function v(n) {
906
973
  class Mt extends f {
907
974
  constructor(t, e, i) {
908
975
  let r = !1, a, l;
909
- super((u, h, _) => (a = u, l = h, r || (r = !0, this.otherField.registerAction(new m((x, P, O, B) => {
910
- P(x, O, B), this.unregistered || this.execute(_, () => null, a, l);
911
- }))), this.isValidComparison(d(u), d(this.otherField.value)) ? null : [
976
+ super((u, h, V) => (a = u, l = h, r || (r = !0, this.otherField.registerAction(new m((x, P, O, B) => {
977
+ P(x, O, B), this.unregistered || this.execute(V, () => null, a, l);
978
+ }))), this.isValidComparison(g(u), g(this.otherField.value)) ? null : [
912
979
  new p(
913
- this.replacePlaceholders(i, { newValue: u, oldValue: h, field: _, otherField: this.otherField })
980
+ this.replacePlaceholders(i, { newValue: u, oldValue: h, field: V, otherField: this.otherField })
914
981
  )
915
982
  ]));
916
983
  o(this, "unregistered", !1);
@@ -929,7 +996,7 @@ class Ht extends f {
929
996
  separator: ", ",
930
997
  omission: `... (${s.length} items total)`
931
998
  }));
932
- const r = (a, l, c) => s.includes(d(a)) ? null : [
999
+ const r = (a, l, c) => s.includes(g(a)) ? null : [
933
1000
  new p(
934
1001
  this.replacePlaceholders(e, { newValue: a, oldValue: l, field: c, allowedValues: s, allowedAsText: i })
935
1002
  )
@@ -942,7 +1009,7 @@ function Qt(n) {
942
1009
  }
943
1010
  class zt extends f {
944
1011
  constructor(s) {
945
- const t = s || v("Please enter a value"), e = (i, r, a) => Qt(d(i)) === 0 ? [new p(
1012
+ const t = s || v("Please enter a value"), e = (i, r, a) => Qt(g(i)) === 0 ? [new p(
946
1013
  this.replacePlaceholders(t, { newValue: i, oldValue: r, field: a })
947
1014
  )] : null;
948
1015
  super(e);
@@ -1008,7 +1075,7 @@ class Kt extends f {
1008
1075
  }
1009
1076
  class Zt extends f {
1010
1077
  constructor(s, t) {
1011
- const e = t || v('Value must match pattern "**{pattern}**"'), i = (r, a, l) => s.test(String(d(r))) ? null : [
1078
+ const e = t || v('Value must match pattern "**{pattern}**"'), i = (r, a, l) => s.test(String(g(r))) ? null : [
1012
1079
  new p(this.replacePlaceholders(e, { newValue: r, oldValue: a, field: l, pattern: s }))
1013
1080
  ];
1014
1081
  super(i);
@@ -1036,7 +1103,7 @@ const te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1036
1103
  ConditionalStatementAction: k,
1037
1104
  ConditionalValueAction: wt,
1038
1105
  ConditionalVisibilityAction: It,
1039
- DisplayMode: V,
1106
+ DisplayMode: _,
1040
1107
  EmptyField: kt,
1041
1108
  EnabledChangedAction: at,
1042
1109
  EnabledChangingAction: rt,
@@ -1050,8 +1117,8 @@ const te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1050
1117
  ListItemRemovedAction: ht,
1051
1118
  MdString: L,
1052
1119
  MessagesWidget: Bt,
1053
- Operator: g,
1054
- RenderableValue: Vt,
1120
+ Operator: d,
1121
+ RenderableValue: _t,
1055
1122
  Statement: F,
1056
1123
  ValidChangedAction: lt,
1057
1124
  ValidationError: W,
@@ -1073,7 +1140,7 @@ export {
1073
1140
  k as ConditionalStatementAction,
1074
1141
  wt as ConditionalValueAction,
1075
1142
  It as ConditionalVisibilityAction,
1076
- V as DisplayMode,
1143
+ _ as DisplayMode,
1077
1144
  kt as EmptyField,
1078
1145
  at as EnabledChangedAction,
1079
1146
  rt as EnabledChangingAction,
@@ -1087,8 +1154,8 @@ export {
1087
1154
  ht as ListItemRemovedAction,
1088
1155
  L as MdString,
1089
1156
  Bt as MessagesWidget,
1090
- g as Operator,
1091
- Vt as RenderableValue,
1157
+ d as Operator,
1158
+ _t as RenderableValue,
1092
1159
  F as Statement,
1093
1160
  lt as ValidChangedAction,
1094
1161
  W as ValidationError,