@dynamicforms/vue-forms 0.2.5 → 0.2.6
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.
|
@@ -37,7 +37,7 @@ var u = (s, i, t) => new Promise((e, n) => {
|
|
|
37
37
|
l((t = t.apply(s, i)).next());
|
|
38
38
|
});
|
|
39
39
|
import { isEqual as B, isBoolean as nt, isString as C, isEmpty as J, truncate as xt, isArray as lt, isObject as ct } from "lodash-es";
|
|
40
|
-
import { unref as
|
|
40
|
+
import { unref as g, computed as ot, reactive as D } from "vue";
|
|
41
41
|
var T = /* @__PURE__ */ ((s) => (s[s.SUPPRESS = 1] = "SUPPRESS", s[s.HIDDEN = 5] = "HIDDEN", s[s.INVISIBLE = 8] = "INVISIBLE", s[s.FULL = 10] = "FULL", s))(T || {});
|
|
42
42
|
const rt = 10;
|
|
43
43
|
((s) => {
|
|
@@ -88,7 +88,7 @@ class p {
|
|
|
88
88
|
class K extends Error {
|
|
89
89
|
}
|
|
90
90
|
const ut = Symbol("ValueChangedAction");
|
|
91
|
-
class
|
|
91
|
+
class d extends p {
|
|
92
92
|
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
93
93
|
constructor(i) {
|
|
94
94
|
super(i);
|
|
@@ -99,14 +99,14 @@ class g extends p {
|
|
|
99
99
|
}
|
|
100
100
|
execute(i, t, e, n) {
|
|
101
101
|
return u(this, null, function* () {
|
|
102
|
-
return v(
|
|
102
|
+
return v(d.prototype, this, "execute").call(this, i, t, e, n);
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
class L extends String {
|
|
107
107
|
}
|
|
108
108
|
function Y(s) {
|
|
109
|
-
const i =
|
|
109
|
+
const i = g(s);
|
|
110
110
|
return typeof i == "object" && "componentName" in i;
|
|
111
111
|
}
|
|
112
112
|
class Z {
|
|
@@ -145,44 +145,44 @@ class y extends Z {
|
|
|
145
145
|
this.text = t, this.textType = ot(() => this.getTextType);
|
|
146
146
|
}
|
|
147
147
|
get getTextType() {
|
|
148
|
-
const t =
|
|
148
|
+
const t = g(this.text);
|
|
149
149
|
return t ? t instanceof L ? "md" : Y(t) ? "component" : "string" : "string";
|
|
150
150
|
}
|
|
151
151
|
get componentName() {
|
|
152
|
-
switch (
|
|
152
|
+
switch (g(this.textType)) {
|
|
153
153
|
case "string":
|
|
154
154
|
return "template";
|
|
155
155
|
case "md":
|
|
156
156
|
return "vue-markdown";
|
|
157
157
|
case "component":
|
|
158
|
-
return
|
|
158
|
+
return g(this.text).componentName;
|
|
159
159
|
default:
|
|
160
160
|
return "template";
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
get componentBindings() {
|
|
164
|
-
switch (
|
|
164
|
+
switch (g(this.textType)) {
|
|
165
165
|
case "string":
|
|
166
166
|
return {};
|
|
167
167
|
case "md":
|
|
168
168
|
return { source: this.text.toString() };
|
|
169
169
|
case "component":
|
|
170
|
-
return
|
|
170
|
+
return g(this.text).componentProps;
|
|
171
171
|
default:
|
|
172
172
|
return {};
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
get componentBody() {
|
|
176
|
-
switch (
|
|
176
|
+
switch (g(this.textType)) {
|
|
177
177
|
case "string":
|
|
178
|
-
return
|
|
178
|
+
return g(this.text);
|
|
179
179
|
default:
|
|
180
180
|
return "";
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
const It = Symbol("Validator");
|
|
185
|
-
class b extends
|
|
185
|
+
class b extends d {
|
|
186
186
|
/**
|
|
187
187
|
* Creates a new validator
|
|
188
188
|
* @param validationFn Function that validates the field value and returns errors or null
|
|
@@ -270,7 +270,7 @@ class k extends Map {
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
const _t = Symbol("ConditionalStatementAction");
|
|
273
|
-
class q extends
|
|
273
|
+
class q extends d {
|
|
274
274
|
constructor(t, e) {
|
|
275
275
|
const n = (r, a, l, c) => u(this, null, function* () {
|
|
276
276
|
const o = t.evaluate();
|
|
@@ -286,7 +286,7 @@ class q extends g {
|
|
|
286
286
|
// boundField tracks the fields this action is bound to. so that it may perform the executorFn on them and not on the
|
|
287
287
|
// ValueChangedAction fields that will call the actionExecutor
|
|
288
288
|
h(this, "boundFields", /* @__PURE__ */ new Set());
|
|
289
|
-
t.collectFields().forEach((r) => r.registerAction(new
|
|
289
|
+
t.collectFields().forEach((r) => r.registerAction(new d(n)));
|
|
290
290
|
}
|
|
291
291
|
// eslint-disable-next-line class-methods-use-this
|
|
292
292
|
static get classIdentifier() {
|
|
@@ -516,10 +516,10 @@ class j {
|
|
|
516
516
|
this.operand1 = i, this.operator = t, this.operand2 = e;
|
|
517
517
|
}
|
|
518
518
|
get operand1Value() {
|
|
519
|
-
return this.operand1 instanceof j ? this.operand1.evaluate() : this.operand1 instanceof x ?
|
|
519
|
+
return this.operand1 instanceof j ? this.operand1.evaluate() : this.operand1 instanceof x ? g(this.operand1.value) : this.operand1;
|
|
520
520
|
}
|
|
521
521
|
get operand2Value() {
|
|
522
|
-
return this.operand2 instanceof j ? this.operand2.evaluate() : this.operand2 instanceof x ?
|
|
522
|
+
return this.operand2 instanceof j ? this.operand2.evaluate() : this.operand2 instanceof x ? g(this.operand2.value) : this.operand2;
|
|
523
523
|
}
|
|
524
524
|
evaluate() {
|
|
525
525
|
var e, n, r, a;
|
|
@@ -646,13 +646,13 @@ class $ extends x {
|
|
|
646
646
|
set value(t) {
|
|
647
647
|
if (!this.enabled) return;
|
|
648
648
|
const e = this._value;
|
|
649
|
-
this._value.icon = t == null ? void 0 : t.icon, this._value.label = t == null ? void 0 : t.label, this.actions.trigger(
|
|
649
|
+
this._value.icon = t == null ? void 0 : t.icon, this._value.label = t == null ? void 0 : t.label, this.actions.trigger(d, this, t, e), this.parent && this.parent.notifyValueChanged(), this.validate();
|
|
650
650
|
}
|
|
651
651
|
setValue(t) {
|
|
652
652
|
return u(this, null, function* () {
|
|
653
653
|
if (!this.enabled) return;
|
|
654
654
|
const e = this._value;
|
|
655
|
-
this._value.icon = t == null ? void 0 : t.icon, this._value.label = t == null ? void 0 : t.label, yield this.actions.trigger(
|
|
655
|
+
this._value.icon = t == null ? void 0 : t.icon, this._value.label = t == null ? void 0 : t.label, yield this.actions.trigger(d, this, t, e), this.parent && (yield this.parent.notifyValueChanged()), this.validate();
|
|
656
656
|
});
|
|
657
657
|
}
|
|
658
658
|
get icon() {
|
|
@@ -700,16 +700,16 @@ class V extends x {
|
|
|
700
700
|
return D(new V(t));
|
|
701
701
|
}
|
|
702
702
|
get value() {
|
|
703
|
-
return this._value;
|
|
703
|
+
return g(this._value);
|
|
704
704
|
}
|
|
705
705
|
set value(t) {
|
|
706
706
|
const e = this._value;
|
|
707
|
-
!this.enabled || e === t || (this._value = t, this.actions.trigger(
|
|
707
|
+
!this.enabled || e === t || (this._value = t, this.actions.trigger(d, this, t, e), this.parent && this.parent.notifyValueChanged(), this.validate());
|
|
708
708
|
}
|
|
709
709
|
setValue(t) {
|
|
710
710
|
return u(this, null, function* () {
|
|
711
711
|
const e = this._value;
|
|
712
|
-
!this.enabled || e === t || (this._value = t, yield this.actions.trigger(
|
|
712
|
+
!this.enabled || e === t || (this._value = t, yield this.actions.trigger(d, this, t, e), this.parent && (yield this.parent.notifyValueChanged()), this.validate());
|
|
713
713
|
});
|
|
714
714
|
}
|
|
715
715
|
clone(t) {
|
|
@@ -723,7 +723,7 @@ class V extends x {
|
|
|
723
723
|
}));
|
|
724
724
|
}
|
|
725
725
|
}
|
|
726
|
-
const Ut = V.create({ value: "EmptyField" }).registerAction(new
|
|
726
|
+
const Ut = V.create({ value: "EmptyField" }).registerAction(new d(
|
|
727
727
|
() => u(void 0, null, function* () {
|
|
728
728
|
console.warn("Working with EmptyField! This should not happen");
|
|
729
729
|
})
|
|
@@ -821,7 +821,7 @@ class _ extends x {
|
|
|
821
821
|
const t = this.value;
|
|
822
822
|
if (!B(t, this._value)) {
|
|
823
823
|
const e = this._value;
|
|
824
|
-
this._value = t, yield this.actions.trigger(
|
|
824
|
+
this._value = t, yield this.actions.trigger(d, this, t, e), this.parent && (yield this.parent.notifyValueChanged());
|
|
825
825
|
}
|
|
826
826
|
});
|
|
827
827
|
}
|
|
@@ -865,12 +865,12 @@ class tt extends x {
|
|
|
865
865
|
}
|
|
866
866
|
set value(t) {
|
|
867
867
|
const e = this.value;
|
|
868
|
-
this.setValueInternal(t), this.actions.trigger(
|
|
868
|
+
this.setValueInternal(t), this.actions.trigger(d, this, this.value, e), this.parent && this.parent.notifyValueChanged();
|
|
869
869
|
}
|
|
870
870
|
setValue(t) {
|
|
871
871
|
return u(this, null, function* () {
|
|
872
872
|
const e = this.value;
|
|
873
|
-
this.setValueInternal(t), yield this.actions.trigger(
|
|
873
|
+
this.setValueInternal(t), yield this.actions.trigger(d, this, this.value, e), this.parent && (yield this.parent.notifyValueChanged());
|
|
874
874
|
});
|
|
875
875
|
}
|
|
876
876
|
clone(t) {
|
|
@@ -887,7 +887,7 @@ class tt extends x {
|
|
|
887
887
|
const t = this.value;
|
|
888
888
|
if (!B(t, this._previousValue)) {
|
|
889
889
|
const e = this._previousValue;
|
|
890
|
-
this._previousValue = t, this.actions.trigger(
|
|
890
|
+
this._previousValue = t, this.actions.trigger(d, this, t, e), this.parent && this.parent.notifyValueChanged();
|
|
891
891
|
}
|
|
892
892
|
}
|
|
893
893
|
get(t) {
|
|
@@ -938,11 +938,11 @@ function E(s) {
|
|
|
938
938
|
class $t extends b {
|
|
939
939
|
constructor(t, e, n) {
|
|
940
940
|
let r = !1, a, l;
|
|
941
|
-
super((o, m, S) => (a = o, l = m, r || (r = !0, this.otherField.registerAction(new
|
|
941
|
+
super((o, m, S) => (a = o, l = m, r || (r = !0, this.otherField.registerAction(new d((G, ft, gt, dt) => u(this, null, function* () {
|
|
942
942
|
yield ft(G, gt, dt), this.unregistered || (yield this.execute(S, () => u(this, null, function* () {
|
|
943
943
|
return null;
|
|
944
944
|
}), a, l));
|
|
945
|
-
})))), this.isValidComparison(
|
|
945
|
+
})))), this.isValidComparison(g(o), g(this.otherField.value)) ? null : [
|
|
946
946
|
new y(
|
|
947
947
|
this.replacePlaceholders(n, { newValue: o, oldValue: m, field: S, otherField: this.otherField })
|
|
948
948
|
)
|
|
@@ -963,7 +963,7 @@ class Bt extends b {
|
|
|
963
963
|
separator: ", ",
|
|
964
964
|
omission: `... (${i.length} items total)`
|
|
965
965
|
}));
|
|
966
|
-
const r = (a, l, c) => i.includes(
|
|
966
|
+
const r = (a, l, c) => i.includes(g(a)) ? null : [
|
|
967
967
|
new y(
|
|
968
968
|
this.replacePlaceholders(e, { newValue: a, oldValue: l, field: c, allowedValues: i, allowedAsText: n })
|
|
969
969
|
)
|
|
@@ -976,7 +976,7 @@ function kt(s) {
|
|
|
976
976
|
}
|
|
977
977
|
class qt extends b {
|
|
978
978
|
constructor(i) {
|
|
979
|
-
const t = i || E("Please enter a value"), e = (n, r, a) => kt(
|
|
979
|
+
const t = i || E("Please enter a value"), e = (n, r, a) => kt(g(n)) === 0 ? [new y(
|
|
980
980
|
this.replacePlaceholders(t, { newValue: n, oldValue: r, field: a })
|
|
981
981
|
)] : null;
|
|
982
982
|
super(e);
|
|
@@ -1042,7 +1042,7 @@ class Gt extends b {
|
|
|
1042
1042
|
}
|
|
1043
1043
|
class Wt extends b {
|
|
1044
1044
|
constructor(i, t) {
|
|
1045
|
-
const e = t || E('Value must match pattern "**{pattern}**"'), n = (r, a, l) => i.test(String(
|
|
1045
|
+
const e = t || E('Value must match pattern "**{pattern}**"'), n = (r, a, l) => i.test(String(g(r))) ? null : [
|
|
1046
1046
|
new y(this.replacePlaceholders(e, { newValue: r, oldValue: a, field: l, pattern: i }))
|
|
1047
1047
|
];
|
|
1048
1048
|
super(n);
|
|
@@ -1090,7 +1090,7 @@ const Jt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
1090
1090
|
ValidationErrorText: Et,
|
|
1091
1091
|
Validator: b,
|
|
1092
1092
|
Validators: Jt,
|
|
1093
|
-
ValueChangedAction:
|
|
1093
|
+
ValueChangedAction: d,
|
|
1094
1094
|
VisibilityChangedAction: O,
|
|
1095
1095
|
VisibilityChangingAction: z,
|
|
1096
1096
|
buildErrorMessage: E,
|
|
@@ -1125,7 +1125,7 @@ export {
|
|
|
1125
1125
|
Et as ValidationErrorText,
|
|
1126
1126
|
b as Validator,
|
|
1127
1127
|
Jt as Validators,
|
|
1128
|
-
|
|
1128
|
+
d as ValueChangedAction,
|
|
1129
1129
|
O as VisibilityChangedAction,
|
|
1130
1130
|
z as VisibilityChangingAction,
|
|
1131
1131
|
E as buildErrorMessage,
|