@dynamicforms/vue-forms 0.1.0
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/LICENSE +21 -0
- package/dist/dynamicforms-vue-forms.js +574 -0
- package/dist/dynamicforms-vue-forms.js.map +1 -0
- package/dist/dynamicforms-vue-forms.umd.cjs +2 -0
- package/dist/dynamicforms-vue-forms.umd.cjs.map +1 -0
- package/dist/index.d.ts +220 -0
- package/package.json +74 -0
- package/readme.md +133 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Jure Erznožnik
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
var q = Object.defineProperty, W = Object.defineProperties;
|
|
2
|
+
var $ = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var x = Object.getOwnPropertySymbols, J = Object.getPrototypeOf, T = Object.prototype.hasOwnProperty, B = Object.prototype.propertyIsEnumerable, K = Reflect.get;
|
|
4
|
+
var j = (n, i, t) => i in n ? q(n, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[i] = t, m = (n, i) => {
|
|
5
|
+
for (var t in i || (i = {}))
|
|
6
|
+
T.call(i, t) && j(n, t, i[t]);
|
|
7
|
+
if (x)
|
|
8
|
+
for (var t of x(i))
|
|
9
|
+
B.call(i, t) && j(n, t, i[t]);
|
|
10
|
+
return n;
|
|
11
|
+
}, _ = (n, i) => W(n, $(i));
|
|
12
|
+
var v = (n, i) => {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var e in n)
|
|
15
|
+
T.call(n, e) && i.indexOf(e) < 0 && (t[e] = n[e]);
|
|
16
|
+
if (n != null && x)
|
|
17
|
+
for (var e of x(n))
|
|
18
|
+
i.indexOf(e) < 0 && B.call(n, e) && (t[e] = n[e]);
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
var u = (n, i, t) => j(n, typeof i != "symbol" ? i + "" : i, t);
|
|
22
|
+
var o = (n, i, t) => K(J(n), t, i);
|
|
23
|
+
var c = (n, i, t) => new Promise((e, s) => {
|
|
24
|
+
var l = (h) => {
|
|
25
|
+
try {
|
|
26
|
+
r(t.next(h));
|
|
27
|
+
} catch (p) {
|
|
28
|
+
s(p);
|
|
29
|
+
}
|
|
30
|
+
}, a = (h) => {
|
|
31
|
+
try {
|
|
32
|
+
r(t.throw(h));
|
|
33
|
+
} catch (p) {
|
|
34
|
+
s(p);
|
|
35
|
+
}
|
|
36
|
+
}, r = (h) => h.done ? e(h.value) : Promise.resolve(h.value).then(l, a);
|
|
37
|
+
r((t = t.apply(n, i)).next());
|
|
38
|
+
});
|
|
39
|
+
import { reactive as A, computed as Q } from "vue";
|
|
40
|
+
import { isBoolean as H, isEqual as O, isEmpty as F } from "lodash";
|
|
41
|
+
class f {
|
|
42
|
+
constructor(i) {
|
|
43
|
+
u(this, "executorFn");
|
|
44
|
+
this.executorFn = i;
|
|
45
|
+
}
|
|
46
|
+
execute(i, t, ...e) {
|
|
47
|
+
return c(this, null, function* () {
|
|
48
|
+
return this.executorFn(i, t, ...e);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
class X extends Error {
|
|
53
|
+
}
|
|
54
|
+
class Y extends Map {
|
|
55
|
+
register(i) {
|
|
56
|
+
if (!(i instanceof f))
|
|
57
|
+
throw new Error("Invalid action type");
|
|
58
|
+
const t = i.classIdentifier, e = this.get(t) || (() => null);
|
|
59
|
+
function s(l, ...a) {
|
|
60
|
+
return i.execute(l, e, ...a);
|
|
61
|
+
}
|
|
62
|
+
this.set(t, s);
|
|
63
|
+
}
|
|
64
|
+
trigger(i, t, ...e) {
|
|
65
|
+
const s = new i(() => {
|
|
66
|
+
}).classIdentifier, l = this.get(s);
|
|
67
|
+
try {
|
|
68
|
+
if (l) return l(t, ...e);
|
|
69
|
+
} catch (a) {
|
|
70
|
+
if (!(a instanceof X)) throw a;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const Z = Symbol("EnabledChangingAction");
|
|
76
|
+
class P extends f {
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
78
|
+
constructor(i) {
|
|
79
|
+
super(i);
|
|
80
|
+
}
|
|
81
|
+
// eslint-disable-next-line class-methods-use-this
|
|
82
|
+
get classIdentifier() {
|
|
83
|
+
return Z;
|
|
84
|
+
}
|
|
85
|
+
execute(i, t, e, s) {
|
|
86
|
+
return c(this, null, function* () {
|
|
87
|
+
return o(P.prototype, this, "execute").call(this, i, t, e, s);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const G = Symbol("EnabledChangedAction");
|
|
92
|
+
class I extends f {
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
94
|
+
constructor(i) {
|
|
95
|
+
super(i);
|
|
96
|
+
}
|
|
97
|
+
// eslint-disable-next-line class-methods-use-this
|
|
98
|
+
get classIdentifier() {
|
|
99
|
+
return G;
|
|
100
|
+
}
|
|
101
|
+
execute(i, t, e, s) {
|
|
102
|
+
return c(this, null, function* () {
|
|
103
|
+
return o(I.prototype, this, "execute").call(this, i, t, e, s);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const M = Symbol("ExecuteAction");
|
|
108
|
+
class w extends f {
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
110
|
+
constructor(i) {
|
|
111
|
+
super(i);
|
|
112
|
+
}
|
|
113
|
+
// eslint-disable-next-line class-methods-use-this
|
|
114
|
+
get classIdentifier() {
|
|
115
|
+
return M;
|
|
116
|
+
}
|
|
117
|
+
execute(i, t, e) {
|
|
118
|
+
return c(this, null, function* () {
|
|
119
|
+
return o(w.prototype, this, "execute").call(this, i, t, e);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const tt = Symbol("VisibilityChangingAction");
|
|
124
|
+
class L extends f {
|
|
125
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
126
|
+
constructor(i) {
|
|
127
|
+
super(i);
|
|
128
|
+
}
|
|
129
|
+
// eslint-disable-next-line class-methods-use-this
|
|
130
|
+
get classIdentifier() {
|
|
131
|
+
return tt;
|
|
132
|
+
}
|
|
133
|
+
execute(i, t, e, s) {
|
|
134
|
+
return c(this, null, function* () {
|
|
135
|
+
return o(L.prototype, this, "execute").call(this, i, t, e, s);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const et = Symbol("VisibilityChangedAction");
|
|
140
|
+
class E extends f {
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
142
|
+
constructor(i) {
|
|
143
|
+
super(i);
|
|
144
|
+
}
|
|
145
|
+
// eslint-disable-next-line class-methods-use-this
|
|
146
|
+
get classIdentifier() {
|
|
147
|
+
return et;
|
|
148
|
+
}
|
|
149
|
+
execute(i, t, e, s) {
|
|
150
|
+
return c(this, null, function* () {
|
|
151
|
+
return o(E.prototype, this, "execute").call(this, i, t, e, s);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const it = Symbol("ValidChangedAction");
|
|
156
|
+
class N extends f {
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
158
|
+
constructor(i) {
|
|
159
|
+
super(i);
|
|
160
|
+
}
|
|
161
|
+
// eslint-disable-next-line class-methods-use-this
|
|
162
|
+
get classIdentifier() {
|
|
163
|
+
return it;
|
|
164
|
+
}
|
|
165
|
+
execute(i, t, e, s) {
|
|
166
|
+
return c(this, null, function* () {
|
|
167
|
+
return o(N.prototype, this, "execute").call(this, i, t, e, s);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const st = Symbol("ValueChangedAction");
|
|
172
|
+
class g extends f {
|
|
173
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
174
|
+
constructor(i) {
|
|
175
|
+
super(i);
|
|
176
|
+
}
|
|
177
|
+
// eslint-disable-next-line class-methods-use-this
|
|
178
|
+
get classIdentifier() {
|
|
179
|
+
return st;
|
|
180
|
+
}
|
|
181
|
+
execute(i, t, e, s) {
|
|
182
|
+
return c(this, null, function* () {
|
|
183
|
+
return o(g.prototype, this, "execute").call(this, i, t, e, s);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const nt = Symbol("ListItemAddedAction");
|
|
188
|
+
class C extends f {
|
|
189
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
190
|
+
constructor(i) {
|
|
191
|
+
super(i);
|
|
192
|
+
}
|
|
193
|
+
// eslint-disable-next-line class-methods-use-this
|
|
194
|
+
get classIdentifier() {
|
|
195
|
+
return nt;
|
|
196
|
+
}
|
|
197
|
+
execute(i, t, e, s) {
|
|
198
|
+
return c(this, null, function* () {
|
|
199
|
+
return o(C.prototype, this, "execute").call(this, i, t, e, s);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const lt = Symbol("ListItemRemovedAction");
|
|
204
|
+
class U extends f {
|
|
205
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
206
|
+
constructor(i) {
|
|
207
|
+
super(i);
|
|
208
|
+
}
|
|
209
|
+
// eslint-disable-next-line class-methods-use-this
|
|
210
|
+
get classIdentifier() {
|
|
211
|
+
return lt;
|
|
212
|
+
}
|
|
213
|
+
execute(i, t, e, s) {
|
|
214
|
+
return c(this, null, function* () {
|
|
215
|
+
return o(U.prototype, this, "execute").call(this, i, t, e, s);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
var d = /* @__PURE__ */ ((n) => (n[n.SUPPRESS = 1] = "SUPPRESS", n[n.HIDDEN = 5] = "HIDDEN", n[n.INVISIBLE = 8] = "INVISIBLE", n[n.FULL = 10] = "FULL", n))(d || {});
|
|
220
|
+
const R = 10;
|
|
221
|
+
((n) => {
|
|
222
|
+
function i(s) {
|
|
223
|
+
return s.toUpperCase() === "SUPPRESS" ? 1 : s.toUpperCase() === "HIDDEN" ? 5 : s.toUpperCase() === "INVISIBLE" ? 8 : R;
|
|
224
|
+
}
|
|
225
|
+
n.fromString = i;
|
|
226
|
+
function t(s) {
|
|
227
|
+
const l = typeof s == "number" ? s : n.fromString(s);
|
|
228
|
+
return Object.values(n).includes(l) ? l : R;
|
|
229
|
+
}
|
|
230
|
+
n.fromAny = t;
|
|
231
|
+
function e(s) {
|
|
232
|
+
const l = typeof s == "number" ? s : n.fromString(s);
|
|
233
|
+
return Object.values(n).includes(l);
|
|
234
|
+
}
|
|
235
|
+
n.isDefined = e;
|
|
236
|
+
})(d || (d = {}));
|
|
237
|
+
Object.freeze(d);
|
|
238
|
+
const V = d;
|
|
239
|
+
class y {
|
|
240
|
+
constructor() {
|
|
241
|
+
// contains original field value as was provided at creation
|
|
242
|
+
u(this, "valid", !0);
|
|
243
|
+
// is current value valid as per FE and BE validators?
|
|
244
|
+
u(this, "errors", []);
|
|
245
|
+
// when member of a Group, fieldName specifies the name of this field
|
|
246
|
+
u(this, "actions", new Y());
|
|
247
|
+
// default property handlers
|
|
248
|
+
u(this, "_visibility", V.FULL);
|
|
249
|
+
u(this, "_enabled", !0);
|
|
250
|
+
}
|
|
251
|
+
get visibility() {
|
|
252
|
+
return this._visibility;
|
|
253
|
+
}
|
|
254
|
+
set visibility(i) {
|
|
255
|
+
const t = this._visibility;
|
|
256
|
+
if (!V.isDefined(i)) throw new Error("visibility must be a DisplayMode constant");
|
|
257
|
+
this._visibility = V.fromAny(i), this.actions.trigger(E, this, this._visibility, t);
|
|
258
|
+
}
|
|
259
|
+
setVisibility(i) {
|
|
260
|
+
return c(this, null, function* () {
|
|
261
|
+
const t = this._visibility, e = yield this.actions.trigger(L, this, i, t);
|
|
262
|
+
if (!V.isDefined(e != null ? e : i)) throw new Error("visibility must be a DisplayMode constant");
|
|
263
|
+
this._visibility = V.fromAny(e != null ? e : i), this.actions.trigger(E, this, this._visibility, t);
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
get enabled() {
|
|
267
|
+
return this._enabled;
|
|
268
|
+
}
|
|
269
|
+
set enabled(i) {
|
|
270
|
+
const t = this._enabled;
|
|
271
|
+
if (!H(i)) throw new Error("Enabled value must be boolean");
|
|
272
|
+
this._enabled = i, this.actions.trigger(I, this, this._enabled, t);
|
|
273
|
+
}
|
|
274
|
+
setEnabled(i) {
|
|
275
|
+
return c(this, null, function* () {
|
|
276
|
+
const t = this._enabled, e = yield this.actions.trigger(P, this, i, t);
|
|
277
|
+
if (!H(e != null ? e : i)) throw new Error("Enabled value must be boolean");
|
|
278
|
+
this._enabled = e != null ? e : i, this.actions.trigger(I, this, this._enabled, t);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
validate() {
|
|
282
|
+
const i = this.valid;
|
|
283
|
+
this.valid = this.errors.length === 0, this.valid !== i && this.actions.trigger(N, this, this.valid, i);
|
|
284
|
+
}
|
|
285
|
+
get fullValue() {
|
|
286
|
+
return this.value;
|
|
287
|
+
}
|
|
288
|
+
get isChanged() {
|
|
289
|
+
return !O(this.value, this.originalValue);
|
|
290
|
+
}
|
|
291
|
+
get reactive() {
|
|
292
|
+
return A(this);
|
|
293
|
+
}
|
|
294
|
+
registerAction(i) {
|
|
295
|
+
return this.actions.register(i), this;
|
|
296
|
+
}
|
|
297
|
+
triggerAction(i, ...t) {
|
|
298
|
+
return this.actions.trigger(i, this, ...t);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function D(n, i) {
|
|
302
|
+
return (n == null ? void 0 : n.label) == null && (n == null ? void 0 : n.icon) == null ? i : n;
|
|
303
|
+
}
|
|
304
|
+
class k extends y {
|
|
305
|
+
constructor(t) {
|
|
306
|
+
super();
|
|
307
|
+
u(this, "_value");
|
|
308
|
+
if (t) {
|
|
309
|
+
const e = t, { value: s, originalValue: l } = e, a = v(e, ["value", "originalValue"]);
|
|
310
|
+
Object.assign(this, a);
|
|
311
|
+
const r = { label: s == null ? void 0 : s.label, icon: s == null ? void 0 : s.icon }, h = Object.freeze({ label: l == null ? void 0 : l.label, icon: l == null ? void 0 : l.icon });
|
|
312
|
+
this._value = A(D(r, h)), this.originalValue = D(h, r);
|
|
313
|
+
} else
|
|
314
|
+
this._value = A({ label: void 0, icon: void 0 });
|
|
315
|
+
}
|
|
316
|
+
get value() {
|
|
317
|
+
return this._value;
|
|
318
|
+
}
|
|
319
|
+
set value(t) {
|
|
320
|
+
if (!this.enabled) return;
|
|
321
|
+
const e = this._value;
|
|
322
|
+
this._value.icon = t == null ? void 0 : t.icon, this._value.label = t == null ? void 0 : t.label, this.actions.trigger(g, this, t, e), this.parent && this.parent.notifyValueChanged(), this.validate();
|
|
323
|
+
}
|
|
324
|
+
get icon() {
|
|
325
|
+
return this.value.icon;
|
|
326
|
+
}
|
|
327
|
+
set icon(t) {
|
|
328
|
+
this.value = { label: this.label, icon: t };
|
|
329
|
+
}
|
|
330
|
+
get label() {
|
|
331
|
+
return this.value.label;
|
|
332
|
+
}
|
|
333
|
+
set label(t) {
|
|
334
|
+
this.value = { label: t, icon: this.value.icon };
|
|
335
|
+
}
|
|
336
|
+
clone(t) {
|
|
337
|
+
var e, s, l, a;
|
|
338
|
+
return new k(_(m({
|
|
339
|
+
value: (e = t == null ? void 0 : t.value) != null ? e : this.value
|
|
340
|
+
}, t && "originalValue" in t ? { originalValue: t.originalValue } : {}), {
|
|
341
|
+
errors: [...(s = t == null ? void 0 : t.errors) != null ? s : this.errors],
|
|
342
|
+
enabled: (l = t == null ? void 0 : t.enabled) != null ? l : this.enabled,
|
|
343
|
+
visibility: (a = t == null ? void 0 : t.visibility) != null ? a : this.visibility
|
|
344
|
+
}));
|
|
345
|
+
}
|
|
346
|
+
execute(t) {
|
|
347
|
+
this.actions.trigger(w, this, t);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
class S extends y {
|
|
351
|
+
constructor(t) {
|
|
352
|
+
super();
|
|
353
|
+
u(this, "_value");
|
|
354
|
+
if (t) {
|
|
355
|
+
const e = t, { value: s } = e, l = v(e, ["value"]);
|
|
356
|
+
Object.assign(this, l), this._value = s != null ? s : this.originalValue, this.originalValue === void 0 && (this.originalValue = this._value);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
get value() {
|
|
360
|
+
return this._value;
|
|
361
|
+
}
|
|
362
|
+
set value(t) {
|
|
363
|
+
if (!this.enabled) return;
|
|
364
|
+
const e = this._value;
|
|
365
|
+
this._value = t, this.actions.trigger(g, this, t, e), this.parent && this.parent.notifyValueChanged(), this.validate();
|
|
366
|
+
}
|
|
367
|
+
clone(t) {
|
|
368
|
+
var e, s, l, a;
|
|
369
|
+
return new S(_(m({
|
|
370
|
+
value: (e = t == null ? void 0 : t.value) != null ? e : this.value
|
|
371
|
+
}, t && "originalValue" in t ? { originalValue: t.originalValue } : {}), {
|
|
372
|
+
errors: [...(s = t == null ? void 0 : t.errors) != null ? s : this.errors],
|
|
373
|
+
enabled: (l = t == null ? void 0 : t.enabled) != null ? l : this.enabled,
|
|
374
|
+
visibility: (a = t == null ? void 0 : t.visibility) != null ? a : this.visibility
|
|
375
|
+
}));
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const ct = new S({ value: "EmptyField" }).registerAction(new g(
|
|
379
|
+
() => c(void 0, null, function* () {
|
|
380
|
+
console.warn("Working with EmptyField! This should not happen");
|
|
381
|
+
})
|
|
382
|
+
));
|
|
383
|
+
class b extends y {
|
|
384
|
+
constructor(t, e) {
|
|
385
|
+
super();
|
|
386
|
+
u(this, "_fields");
|
|
387
|
+
u(this, "_value", null);
|
|
388
|
+
u(this, "reactiveValue");
|
|
389
|
+
u(this, "suppressNotifyValueChanged", !1);
|
|
390
|
+
if (!b.isValidFields(t)) throw new Error("Invalid fields object provided");
|
|
391
|
+
if (this._fields = {}, Object.entries(t).forEach(([l, a]) => {
|
|
392
|
+
Object.defineProperty(a, "parent", { get: () => this, configurable: !1, enumerable: !1 }), Object.defineProperty(a, "fieldName", { get: () => l, configurable: !1, enumerable: !1 });
|
|
393
|
+
const r = a.reactive;
|
|
394
|
+
Object.defineProperty(
|
|
395
|
+
this._fields,
|
|
396
|
+
l,
|
|
397
|
+
{ get() {
|
|
398
|
+
return r;
|
|
399
|
+
}, configurable: !1, enumerable: !0 }
|
|
400
|
+
);
|
|
401
|
+
}), e) {
|
|
402
|
+
const s = e, { value: l } = s, a = v(s, ["value"]);
|
|
403
|
+
Object.assign(this, a), this.value = l != null ? l : this.originalValue;
|
|
404
|
+
}
|
|
405
|
+
this.originalValue === void 0 && (this.originalValue = this.value), this.reactiveValue = Q(() => this.value);
|
|
406
|
+
}
|
|
407
|
+
get reactive() {
|
|
408
|
+
return this;
|
|
409
|
+
}
|
|
410
|
+
static isValidFields(t) {
|
|
411
|
+
function e(s) {
|
|
412
|
+
return s instanceof y;
|
|
413
|
+
}
|
|
414
|
+
return typeof t == "object" && t !== null && Object.entries(t).every(([, s]) => e(s));
|
|
415
|
+
}
|
|
416
|
+
static createFromFormData(t) {
|
|
417
|
+
if (t instanceof y)
|
|
418
|
+
throw new Error("data is already a Form structure, should be a simple object");
|
|
419
|
+
return new b(
|
|
420
|
+
t == null ? {} : Object.fromEntries(
|
|
421
|
+
Object.entries(t).map(([e, s]) => [e, new S({ value: s })])
|
|
422
|
+
)
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
field(t) {
|
|
426
|
+
var e;
|
|
427
|
+
return (e = this._fields[t]) != null ? e : null;
|
|
428
|
+
}
|
|
429
|
+
get fields() {
|
|
430
|
+
return this._fields;
|
|
431
|
+
}
|
|
432
|
+
get value() {
|
|
433
|
+
const t = {};
|
|
434
|
+
return Object.entries(this._fields).forEach(([e, s]) => {
|
|
435
|
+
const l = s.value;
|
|
436
|
+
(s.enabled || s instanceof b && !F(l)) && (t[e] = l);
|
|
437
|
+
}), F(t) ? null : t;
|
|
438
|
+
}
|
|
439
|
+
set value(t) {
|
|
440
|
+
this.suppressNotifyValueChanged = !0;
|
|
441
|
+
try {
|
|
442
|
+
Object.entries(this._fields).forEach(([e, s]) => {
|
|
443
|
+
(t == null || e in t) && (s.value = t == null ? null : t[e]);
|
|
444
|
+
});
|
|
445
|
+
} finally {
|
|
446
|
+
this.suppressNotifyValueChanged = !1;
|
|
447
|
+
}
|
|
448
|
+
this.notifyValueChanged();
|
|
449
|
+
}
|
|
450
|
+
get fullValue() {
|
|
451
|
+
const t = {};
|
|
452
|
+
return Object.entries(this._fields).forEach(([e, s]) => {
|
|
453
|
+
t[e] = s.fullValue;
|
|
454
|
+
}), t;
|
|
455
|
+
}
|
|
456
|
+
notifyValueChanged() {
|
|
457
|
+
if (this.suppressNotifyValueChanged) return;
|
|
458
|
+
const t = this.value;
|
|
459
|
+
if (!O(t, this._value)) {
|
|
460
|
+
const e = this._value;
|
|
461
|
+
this._value = t, this.actions.trigger(g, this, t, e), this.parent && this.parent.notifyValueChanged();
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
clone(t) {
|
|
465
|
+
var s, l, a, r;
|
|
466
|
+
const e = {};
|
|
467
|
+
return Object.entries(this._fields).forEach(([h, p]) => {
|
|
468
|
+
e[h] = p.clone();
|
|
469
|
+
}), new b(e, _(m({
|
|
470
|
+
value: (s = t == null ? void 0 : t.value) != null ? s : this.value
|
|
471
|
+
}, t && "originalValue" in t ? { originalValue: t.originalValue } : {}), {
|
|
472
|
+
errors: [...(l = t == null ? void 0 : t.errors) != null ? l : []],
|
|
473
|
+
enabled: (a = t == null ? void 0 : t.enabled) != null ? a : this.enabled,
|
|
474
|
+
visibility: (r = t == null ? void 0 : t.visibility) != null ? r : this.visibility
|
|
475
|
+
}));
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
class z extends y {
|
|
479
|
+
constructor(t, e) {
|
|
480
|
+
super();
|
|
481
|
+
u(this, "_value", null);
|
|
482
|
+
u(this, "_itemTemplate");
|
|
483
|
+
u(this, "_previousValue");
|
|
484
|
+
if (this._itemTemplate = t, e) {
|
|
485
|
+
const s = e, { value: l } = s, a = v(s, ["value"]);
|
|
486
|
+
Object.assign(this, a), l && this.setValue(l);
|
|
487
|
+
}
|
|
488
|
+
this.originalValue === void 0 && (this.originalValue = this.value), this._previousValue = this.value;
|
|
489
|
+
}
|
|
490
|
+
get reactive() {
|
|
491
|
+
return this;
|
|
492
|
+
}
|
|
493
|
+
processSetValueItem(t) {
|
|
494
|
+
let e;
|
|
495
|
+
return t instanceof b ? e = t : this._itemTemplate ? e = this._itemTemplate.clone({ value: t }) : e = b.createFromFormData(t), Object.defineProperty(e, "parent", { get: () => this, configurable: !1, enumerable: !1 }), e;
|
|
496
|
+
}
|
|
497
|
+
setValue(t) {
|
|
498
|
+
Array.isArray(t) && (this._value = t.map((e) => this.processSetValueItem(e)));
|
|
499
|
+
}
|
|
500
|
+
get value() {
|
|
501
|
+
var e;
|
|
502
|
+
const t = (e = this._value) == null ? void 0 : e.map((s) => s.value);
|
|
503
|
+
return F(t) ? null : t;
|
|
504
|
+
}
|
|
505
|
+
set value(t) {
|
|
506
|
+
const e = this.value;
|
|
507
|
+
this.setValue(t), this.actions.trigger(g, this, this.value, e), this.parent && this.parent.notifyValueChanged();
|
|
508
|
+
}
|
|
509
|
+
clone(t) {
|
|
510
|
+
var e, s, l, a, r;
|
|
511
|
+
return new z((e = this._itemTemplate) == null ? void 0 : e.clone(), _(m({
|
|
512
|
+
value: [...(s = t == null ? void 0 : t.value) != null ? s : this.value]
|
|
513
|
+
}, t && "originalValue" in t ? { originalValue: t.originalValue } : {}), {
|
|
514
|
+
errors: [...(l = t == null ? void 0 : t.errors) != null ? l : []],
|
|
515
|
+
enabled: (a = t == null ? void 0 : t.enabled) != null ? a : this.enabled,
|
|
516
|
+
visibility: (r = t == null ? void 0 : t.visibility) != null ? r : this.visibility
|
|
517
|
+
}));
|
|
518
|
+
}
|
|
519
|
+
notifyValueChanged() {
|
|
520
|
+
const t = this.value;
|
|
521
|
+
if (!O(t, this._previousValue)) {
|
|
522
|
+
const e = this._previousValue;
|
|
523
|
+
this._previousValue = t, this.actions.trigger(g, this, t, e), this.parent && this.parent.notifyValueChanged();
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
get(t) {
|
|
527
|
+
return this._value != null ? this._value[t] : void 0;
|
|
528
|
+
}
|
|
529
|
+
push(t) {
|
|
530
|
+
var e, s;
|
|
531
|
+
return this.insert(t, (s = (e = this._value) == null ? void 0 : e.length) != null ? s : 0) + 1;
|
|
532
|
+
}
|
|
533
|
+
pop() {
|
|
534
|
+
var t, e;
|
|
535
|
+
return this.remove(((e = (t = this._value) == null ? void 0 : t.length) != null ? e : 0) - 1);
|
|
536
|
+
}
|
|
537
|
+
remove(t) {
|
|
538
|
+
var s;
|
|
539
|
+
if (this._value == null || t < 0 || this._value.length <= t) return;
|
|
540
|
+
let e = (s = this._value.splice(t, 1)) == null ? void 0 : s[0];
|
|
541
|
+
return e && (e = e.clone(), this.actions.trigger(U, this, e, t), this.notifyValueChanged()), e;
|
|
542
|
+
}
|
|
543
|
+
insert(t, e) {
|
|
544
|
+
for (this._value == null && (this._value = []); this._value.length < e; ) {
|
|
545
|
+
const l = this.processSetValueItem(null), a = this._value.push(l);
|
|
546
|
+
this.actions.trigger(C, this, l, a);
|
|
547
|
+
}
|
|
548
|
+
const s = this.processSetValueItem(t);
|
|
549
|
+
return this._value.splice(e, 0, s), this.actions.trigger(C, this, s, e), this.notifyValueChanged(), e;
|
|
550
|
+
}
|
|
551
|
+
clear() {
|
|
552
|
+
this._value = null, this.notifyValueChanged();
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
export {
|
|
556
|
+
X as AbortEventHandlingException,
|
|
557
|
+
k as Action,
|
|
558
|
+
Y as ActionsMap,
|
|
559
|
+
ct as EmptyField,
|
|
560
|
+
I as EnabledChangedAction,
|
|
561
|
+
P as EnabledChangingAction,
|
|
562
|
+
w as ExecuteAction,
|
|
563
|
+
S as Field,
|
|
564
|
+
f as FieldActionBase,
|
|
565
|
+
b as Group,
|
|
566
|
+
z as List,
|
|
567
|
+
C as ListItemAddedAction,
|
|
568
|
+
U as ListItemRemovedAction,
|
|
569
|
+
N as ValidChangedAction,
|
|
570
|
+
g as ValueChangedAction,
|
|
571
|
+
E as VisibilityChangedAction,
|
|
572
|
+
L as VisibilityChangingAction
|
|
573
|
+
};
|
|
574
|
+
//# sourceMappingURL=dynamicforms-vue-forms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamicforms-vue-forms.js","sources":["../src/actions/field-action-base.ts","../src/field.interface.ts","../src/actions/actions-map.ts","../src/actions/enabled-actions.ts","../src/actions/execute-action.ts","../src/actions/visibility-actions.ts","../src/actions/valid-changed-action.ts","../src/actions/value-changed-action.ts","../src/actions/list-item-added-action.ts","../src/actions/list-item-removed-action.ts","../src/display-mode.ts","../src/field-base.ts","../src/action.ts","../src/field.ts","../src/group.ts","../src/list.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport {\n FieldActionExecute,\n type IField,\n type IFieldAction,\n} from '@/field.interface';\n\ntype ActionExecutor = (field: IField, supr: FieldActionExecute, ...params: any[]) => Promise<any>;\n\nexport default abstract class FieldActionBase implements IFieldAction {\n public abstract get classIdentifier(): symbol;\n private readonly executorFn: ActionExecutor;\n\n constructor(executorFn: ActionExecutor) {\n this.executorFn = executorFn;\n }\n\n async execute(field: IField, supr: IFieldAction['execute'], ...params: any[]): Promise<any> {\n return this.executorFn(field, supr, ...params);\n }\n}\n","import type DisplayMode from './display-mode';\nimport { type ValidationError } from './validation-error';\n\nexport interface IField<T = any> {\n value: T;\n fullValue: T;\n originalValue: T;\n valid: boolean;\n errors: ValidationError[];\n enabled: boolean;\n visibility: DisplayMode;\n\n parent?: any; // Group when member of a Group, parent will specify that group\n fieldName?: string; // when member of a Group, fieldName specifies the name of this field\n\n clone(overrides?: Partial<IField<T>>): IField<T>;\n // events\n registerAction(action: IFieldAction<T>): this;\n triggerAction<T2 extends IFieldAction<T>>(actionClass: abstract new (...args: any[]) => T2, ...params: any[]): any;\n\n // API\n validate(): void;\n isChanged: boolean;\n}\n\nexport class AbortEventHandlingException extends Error {}\n\nexport type FieldActionExecute<T = any> = (field: IField<T>, ...params: any[]) => Promise<any>;\nexport interface IFieldAction<T = any> {\n execute(field: IField<T>, supr: FieldActionExecute<T>, ...params: any[]): any;\n}\n","import { type FieldActionExecute, type IField, AbortEventHandlingException } from '../field.interface';\n\nimport FieldActionBase from './field-action-base';\n\nexport default class ActionsMap extends Map<symbol, FieldActionExecute> {\n register(action: FieldActionBase) {\n if (!(action instanceof FieldActionBase)) {\n throw new Error('Invalid action type');\n }\n\n const actionType = action.classIdentifier;\n const existingExecute = this.get(actionType) || (() => null);\n\n function ex(field: IField, ...params: any[]) {\n return action.execute(field, existingExecute, ...params);\n }\n this.set(actionType, ex);\n }\n\n trigger<T extends FieldActionBase>(\n ActionClass: new (...args: any[]) => T,\n field: IField,\n ...params: any[]\n ): any {\n const identifier = new ActionClass(() => {}).classIdentifier;\n const execute = this.get(identifier);\n try {\n if (execute) return execute(field, ...params);\n } catch (error) {\n if (!(error instanceof AbortEventHandlingException)) throw error;\n }\n return null;\n }\n}\n","// eslint-disable-next-line max-classes-per-file\nimport FieldActionBase from './field-action-base';\n\nimport { FieldActionExecute, type IField } from '@/field.interface';\n\nconst EnabledChangingActionClassIdentifier = Symbol('EnabledChangingAction');\n\nexport class EnabledChangingAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (\n field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean\n ) => Promise<boolean>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return EnabledChangingActionClassIdentifier; }\n\n async execute(field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean)\n : Promise<boolean> {\n return super.execute(field, supr, newValue, oldValue);\n }\n}\n\nconst EnabledChangedActionClassIdentifier = Symbol('EnabledChangedAction');\n\nexport class EnabledChangedAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (\n field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean\n ) => Promise<void>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return EnabledChangedActionClassIdentifier; }\n\n async execute(\n field: IField,\n supr: FieldActionExecute,\n newValue: boolean,\n oldValue: boolean,\n ): Promise<void> {\n return super.execute(field, supr, newValue, oldValue);\n }\n}\n","import FieldActionBase from './field-action-base';\n\nimport { FieldActionExecute, type IField } from '@/field.interface';\n\nconst ExecuteActionClassIdentifier = Symbol('ExecuteAction');\n\n// eslint-disable-next-line import/prefer-default-export\nexport class ExecuteAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (field: IField, supr: FieldActionExecute, params: any) => Promise<any>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return ExecuteActionClassIdentifier; }\n\n async execute(field: IField, supr: FieldActionExecute, params: any): Promise<any> {\n return super.execute(field, supr, params);\n }\n}\n","// eslint-disable-next-line max-classes-per-file\nimport FieldActionBase from './field-action-base';\n\nimport DisplayMode from '@/display-mode';\nimport { FieldActionExecute, type IField } from '@/field.interface';\n\nconst VisibilityChangingActionClassIdentifier = Symbol('VisibilityChangingAction');\n\nexport class VisibilityChangingAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (\n field: IField, supr: FieldActionExecute, newValue: DisplayMode, oldValue: DisplayMode\n ) => Promise<DisplayMode>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return VisibilityChangingActionClassIdentifier; }\n\n async execute(\n field: IField,\n supr: FieldActionExecute,\n newValue: DisplayMode,\n oldValue: DisplayMode,\n ): Promise<DisplayMode> {\n return super.execute(field, supr, newValue, oldValue);\n }\n}\n\nconst VisibilityChangedActionClassIdentifier = Symbol('VisibilityChangedAction');\n\nexport class VisibilityChangedAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (\n field: IField, supr: FieldActionExecute, newValue: DisplayMode, oldValue: DisplayMode,\n ) => Promise<void>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return VisibilityChangedActionClassIdentifier; }\n\n async execute(\n field: IField,\n supr: FieldActionExecute,\n newValue: DisplayMode,\n oldValue: DisplayMode,\n ): Promise<void> {\n return super.execute(field, supr, newValue, oldValue);\n }\n}\n","import FieldActionBase from './field-action-base';\n\nimport { FieldActionExecute, type IField } from '@/field.interface';\n\nconst ValidChangedActionClassIdentifier = Symbol('ValidChangedAction');\n\n// eslint-disable-next-line import/prefer-default-export\nexport class ValidChangedAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (\n field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean,\n ) => Promise<void>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return ValidChangedActionClassIdentifier; }\n\n async execute(\n field: IField,\n supr: FieldActionExecute,\n newValue: boolean,\n oldValue: boolean,\n ): Promise<void> {\n return super.execute(field, supr, newValue, oldValue);\n }\n}\n","import FieldActionBase from './field-action-base';\n\nimport { FieldActionExecute, type IField } from '@/field.interface';\n\nconst ValueChangedActionClassIdentifier = Symbol('ValueChangedAction');\n\n// eslint-disable-next-line import/prefer-default-export\nexport class ValueChangedAction<T = any> extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (\n field: IField<T>, supr: FieldActionExecute<T>, newValue: T, oldValue: T,\n ) => Promise<void>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return ValueChangedActionClassIdentifier; }\n\n async execute(\n field: IField<T>,\n supr: FieldActionExecute<T>,\n newValue: T,\n oldValue: T,\n ): Promise<void> {\n return super.execute(field, supr, newValue, oldValue);\n }\n}\n","import FieldActionBase from './field-action-base';\n\nimport { FieldActionExecute, type IField } from '@/field.interface';\n\nconst ListItemAddedActionClassIdentifier = Symbol('ListItemAddedAction');\n\n// eslint-disable-next-line import/prefer-default-export\nexport class ListItemAddedAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (field: IField, supr: FieldActionExecute, item: any, index: number) => Promise<void>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return ListItemAddedActionClassIdentifier; }\n\n async execute(field: IField, supr: FieldActionExecute, item: any, index: number): Promise<void> {\n return super.execute(field, supr, item, index);\n }\n}\n","import FieldActionBase from './field-action-base';\n\nimport { FieldActionExecute, type IField } from '@/field.interface';\n\nconst ListItemRemovedActionClassIdentifier = Symbol('ListItemRemovedAction');\n\n// eslint-disable-next-line import/prefer-default-export\nexport class ListItemRemovedAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (field: IField, supr: FieldActionExecute, item: any, index: number) => Promise<void>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return ListItemRemovedActionClassIdentifier; }\n\n async execute(field: IField, supr: FieldActionExecute, item: any, index: number): Promise<void> {\n return super.execute(field, supr, item, index);\n }\n}\n","/**\n * DisplayMode enum provides an enumeration for supported ways of rendering a particular object in the DOM\n */\nenum DisplayMode {\n // This enum is actually declared in dynamicforms.mixins.field_render.py\n SUPPRESS = 1, // Field will be entirely suppressed. it will not render (not even to JSON) and will not parse for PUT\n HIDDEN = 5, // Field will render as <input type=\"hidden\"> or <tr data-field_name>\n INVISIBLE = 8, // Field will render completely, but with display: none. Equal to setting its style = {display: none}\n FULL = 10, // Field will render completely\n}\n\nexport const defaultDisplayMode = DisplayMode.FULL;\n\nnamespace DisplayMode {\n export function fromString(mode: string): DisplayMode {\n if (mode.toUpperCase() === 'SUPPRESS') return DisplayMode.SUPPRESS;\n if (mode.toUpperCase() === 'HIDDEN') return DisplayMode.HIDDEN;\n if (mode.toUpperCase() === 'INVISIBLE') return DisplayMode.INVISIBLE;\n return defaultDisplayMode;\n }\n\n export function fromAny(mode: any): DisplayMode {\n const input = (typeof mode === 'number') ? mode : DisplayMode.fromString(mode as string);\n if (Object.values(DisplayMode).includes(input)) return input;\n return defaultDisplayMode;\n }\n\n export function isDefined(mode: number | string): boolean {\n const check = (typeof mode === 'number') ? mode : DisplayMode.fromString(mode as string);\n return Object.values(DisplayMode).includes(check);\n }\n}\n\nObject.freeze(DisplayMode);\n\nexport default DisplayMode;\n","import { isBoolean, isEqual } from 'lodash';\nimport { reactive } from 'vue';\n\nimport {\n ActionsMap,\n EnabledChangedAction,\n EnabledChangingAction,\n ValidChangedAction,\n VisibilityChangedAction,\n VisibilityChangingAction,\n} from './actions';\nimport FieldActionBase from './actions/field-action-base';\nimport DisplayMode from './display-mode';\nimport { IField, IFieldAction } from './field.interface';\nimport { type Group } from './group';\nimport { ValidationError } from './validation-error';\n\n// eslint-disable-next-line import/prefer-default-export\nexport abstract class FieldBase<T = any> implements IField<T> {\n abstract get value(): T;\n abstract set value(newValue: T);\n\n abstract clone(overrides?: Partial<IField<T>>): IField<T>;\n\n declare originalValue: T; // contains original field value as was provided at creation\n\n valid: boolean = true; // is current value valid as per FE and BE validators?\n\n errors: ValidationError[] = []; // list of errors\n\n declare parent?: Group; // when member of a Group, parent will specify that group\n\n declare fieldName?: string; // when member of a Group, fieldName specifies the name of this field\n\n protected actions: ActionsMap = new ActionsMap();\n\n // default property handlers\n private _visibility: DisplayMode = DisplayMode.FULL;\n\n get visibility(): DisplayMode { return this._visibility; }\n\n set visibility(newValue: DisplayMode) {\n const oldValue = this._visibility;\n if (!DisplayMode.isDefined(newValue)) throw new Error('visibility must be a DisplayMode constant');\n this._visibility = DisplayMode.fromAny(newValue);\n this.actions.trigger(VisibilityChangedAction, this, this._visibility, oldValue);\n }\n\n async setVisibility(newValue: DisplayMode) {\n const oldValue = this._visibility;\n const alteredValue = await this.actions.trigger(VisibilityChangingAction, this, newValue, oldValue);\n if (!DisplayMode.isDefined(alteredValue ?? newValue)) throw new Error('visibility must be a DisplayMode constant');\n this._visibility = DisplayMode.fromAny(alteredValue ?? newValue);\n this.actions.trigger(VisibilityChangedAction, this, this._visibility, oldValue);\n }\n\n private _enabled: boolean = true;\n\n get enabled(): boolean { return this._enabled; }\n\n set enabled(newValue: boolean) {\n const oldValue = this._enabled;\n if (!isBoolean(newValue)) throw new Error('Enabled value must be boolean');\n this._enabled = newValue;\n this.actions.trigger(EnabledChangedAction, this, this._enabled, oldValue);\n }\n\n async setEnabled(newValue: boolean) {\n const oldValue = this._enabled;\n const alteredValue = await this.actions.trigger(EnabledChangingAction, this, newValue, oldValue);\n if (!isBoolean(alteredValue ?? newValue)) throw new Error('Enabled value must be boolean');\n this._enabled = alteredValue ?? newValue;\n this.actions.trigger(EnabledChangedAction, this, this._enabled, oldValue);\n }\n\n validate() {\n const oldValid = this.valid;\n this.valid = this.errors.length === 0;\n if (this.valid !== oldValid) this.actions.trigger(ValidChangedAction, this, this.valid, oldValid);\n }\n\n get fullValue(): any {\n return this.value;\n }\n\n get isChanged() : boolean {\n return !isEqual(this.value, this.originalValue);\n }\n\n get reactive(): IField {\n return reactive(this);\n }\n\n registerAction(action: IFieldAction<T>): this {\n this.actions.register(action as FieldActionBase);\n return this;\n }\n\n triggerAction<T2 extends IFieldAction<T>>(\n actionClass: new (...args: any[]) => T2,\n ...params: any[]\n ): any {\n return this.actions.trigger(actionClass as any, this, ...params);\n }\n}\n","import { reactive } from 'vue';\n\nimport { ExecuteAction, ValueChangedAction } from './actions';\nimport { FieldBase } from './field-base';\nimport { IField } from './field.interface';\n\nexport interface ActionValue {\n label?: string;\n icon?: string;\n}\n\nfunction isValEmpty(val: ActionValue, defaultIfTrue: ActionValue): ActionValue {\n if (val?.label == null && val?.icon == null) return defaultIfTrue;\n return val;\n}\n\nexport class Action extends FieldBase {\n private readonly _value: ActionValue;\n\n constructor(params?: Partial<IField>) {\n super();\n if (params) {\n const { value: paramValue, originalValue, ...otherParams } = params;\n Object.assign(this, otherParams);\n const val = { label: paramValue?.label, icon: paramValue?.icon } as ActionValue;\n const orgVal = Object.freeze({ label: originalValue?.label, icon: originalValue?.icon } as ActionValue);\n this._value = reactive(isValEmpty(val, orgVal));\n this.originalValue = isValEmpty(orgVal, val);\n } else {\n this._value = reactive({ label: undefined, icon: undefined });\n }\n }\n\n get value(): ActionValue { return this._value; }\n\n set value(newValue: ActionValue) {\n if (!this.enabled) return; // a disabled field does not allow changing value\n const oldValue = this._value;\n this._value.icon = newValue?.icon;\n this._value.label = newValue?.label;\n this.actions.trigger(ValueChangedAction, this, newValue, oldValue);\n if (this.parent) this.parent.notifyValueChanged();\n this.validate();\n }\n\n get icon(): string | undefined {\n return this.value.icon;\n }\n\n set icon(newValue: string | undefined) {\n this.value = { label: this.label, icon: newValue };\n }\n\n get label(): string | undefined {\n return this.value.label;\n }\n\n set label(newValue: string | undefined) {\n this.value = { label: newValue, icon: this.value.icon };\n }\n\n clone(overrides?: Partial<IField>): Action {\n return new Action({\n value: overrides?.value ?? this.value,\n ...(overrides && 'originalValue' in overrides ? { originalValue: overrides.originalValue } : { }),\n errors: [...(overrides?.errors ?? this.errors)],\n enabled: overrides?.enabled ?? this.enabled,\n visibility: overrides?.visibility ?? this.visibility,\n });\n }\n\n execute(params: any) {\n this.actions.trigger(ExecuteAction, this, params);\n }\n}\n\nexport type NullableAction = Action | null;\n","import { ValueChangedAction } from './actions';\nimport { FieldBase } from './field-base';\nimport { IField } from './field.interface';\n\n// eslint-disable-next-line import/prefer-default-export\nexport class Field<T = any> extends FieldBase {\n private _value: T = undefined!;\n\n constructor(params?: Partial<IField<T>>) {\n super();\n if (params) {\n const { value: paramValue, ...otherParams } = params;\n Object.assign(this, otherParams);\n this._value = paramValue ?? this.originalValue;\n if (this.originalValue === undefined) this.originalValue = this._value;\n }\n }\n\n get value() { return this._value; }\n\n set value(newValue: T) {\n if (!this.enabled) return; // a disabled field does not allow changing value\n const oldValue = this._value;\n this._value = newValue;\n this.actions.trigger(ValueChangedAction, this, newValue, oldValue);\n if (this.parent) this.parent.notifyValueChanged();\n this.validate();\n }\n\n clone(overrides?: Partial<IField<T>>): Field<T> {\n return new Field<T>({\n value: overrides?.value ?? this.value,\n ...(overrides && 'originalValue' in overrides ? { originalValue: overrides.originalValue } : { }),\n errors: [...(overrides?.errors ?? this.errors)],\n enabled: overrides?.enabled ?? this.enabled,\n visibility: overrides?.visibility ?? this.visibility,\n });\n }\n}\n\nexport type NullableField<T = any> = Field<T> | null;\n\nexport const EmptyField = new Field({ value: 'EmptyField' })\n .registerAction(new ValueChangedAction(\n async () => {\n console.warn('Working with EmptyField! This should not happen');\n },\n ));\n","import { isEmpty, isEqual } from 'lodash';\nimport { ComputedRef, computed } from 'vue';\n\nimport { ValueChangedAction } from './actions';\nimport { Field } from './field';\nimport { FieldBase } from './field-base';\nimport { IField } from './field.interface';\n\nexport type GenericFieldsInterface = Record<string, IField>;\n\nexport class Group<T extends GenericFieldsInterface = GenericFieldsInterface> extends FieldBase {\n private readonly _fields: T;\n\n private _value: Record<string, any> | null = null;\n\n public readonly reactiveValue: ComputedRef<Record<string, any> | null>;\n\n private suppressNotifyValueChanged: boolean = false;\n\n constructor(fields: T, params?: Partial<IField>) {\n super();\n\n if (!Group.isValidFields(fields)) throw new Error('Invalid fields object provided');\n this._fields = {} as T;\n Object.entries(fields).forEach(([name, field]) => {\n Object.defineProperty(field, 'parent', { get: () => this, configurable: false, enumerable: false });\n Object.defineProperty(field, 'fieldName', { get: () => name, configurable: false, enumerable: false });\n const reactiveField = field.reactive;\n Object.defineProperty(\n this._fields,\n name,\n { get() { return reactiveField; }, configurable: false, enumerable: true },\n );\n });\n\n if (params) {\n const { value: paramValue, ...otherParams } = params;\n Object.assign(this, otherParams);\n this.value = paramValue ?? this.originalValue;\n }\n\n if (this.originalValue === undefined) this.originalValue = this.value;\n\n this.reactiveValue = computed(() => this.value);\n // if (Object.keys(this._fields).length) console.log('group created', this, Error().stack);\n }\n\n get reactive() {\n return this;\n }\n\n private static isValidFields(flds: unknown): flds is Record<string, FieldBase> {\n function isFieldAll(field: unknown): field is FieldBase {\n return field instanceof FieldBase;\n }\n\n return typeof flds === 'object' &&\n flds !== null &&\n Object.entries(flds).every(([, field]) => isFieldAll(field));\n }\n\n static createFromFormData(data: Record<string, any> | null): Group {\n if (data instanceof FieldBase) {\n throw new Error('data is already a Form structure, should be a simple object');\n }\n return new Group(\n data == null ?\n { } :\n Object.fromEntries(\n Object.entries(data).map(([key, value]) => [key, new Field({ value })]),\n ),\n );\n }\n\n field(fieldName: string): IField | null {\n return this._fields[fieldName] ?? null;\n }\n\n get fields(): T {\n return this._fields;\n }\n\n get value(): Record<string, any> | null {\n const value: Record<string, any> = {};\n Object.entries(this._fields).forEach(([name, field]) => {\n const fieldValue = field.value;\n if (field.enabled) {\n // readOnly fields do not serialize\n value[name] = fieldValue;\n } else if (field instanceof Group && !isEmpty(fieldValue)) {\n // readOnly group only serializes if it is non-empty (some of its fields are not readOnly)\n value[name] = fieldValue;\n }\n });\n return isEmpty(value) ? null : value;\n }\n\n set value(newValue: Record<string, any> | null) {\n this.suppressNotifyValueChanged = true;\n try {\n Object.entries(this._fields).forEach(([name, field]) => {\n if (newValue == null || name in newValue) {\n field.value = newValue == null ? null : newValue[name];\n }\n });\n } finally {\n this.suppressNotifyValueChanged = false;\n }\n this.notifyValueChanged();\n }\n\n get fullValue(): Record<string, any> {\n const value: Record<string, any> = {};\n Object.entries(this._fields).forEach(([name, field]) => { value[name] = field.fullValue; });\n return value;\n }\n\n notifyValueChanged() {\n if (this.suppressNotifyValueChanged) return;\n const newValue = this.value;\n if (!isEqual(newValue, this._value)) {\n const oldValue = this._value;\n this._value = newValue;\n this.actions.trigger(ValueChangedAction, this, newValue, oldValue);\n if (this.parent) this.parent.notifyValueChanged();\n }\n }\n\n clone(overrides?: Partial<IField>): Group<T> {\n const newFields = {} as T;\n Object.entries(this._fields).forEach(([name, field]) => {\n newFields[name as keyof T] = field.clone() as any;\n });\n\n return new Group(newFields, {\n value: overrides?.value ?? this.value,\n ...(overrides && 'originalValue' in overrides ? { originalValue: overrides.originalValue } : { }),\n errors: [...(overrides?.errors ?? [])],\n enabled: overrides?.enabled ?? this.enabled,\n visibility: overrides?.visibility ?? this.visibility,\n });\n }\n}\n\nexport type NullableGroup = Group | null;\n","import { isEmpty, isEqual } from 'lodash';\n\nimport { ListItemAddedAction, ListItemRemovedAction, ValueChangedAction } from './actions';\nimport { FieldBase } from './field-base';\nimport { IField } from './field.interface';\nimport { GenericFieldsInterface, Group } from './group';\n\nexport class List<T extends GenericFieldsInterface = GenericFieldsInterface> extends FieldBase {\n private _value: Group<T>[] | null = null;\n\n private _itemTemplate?: Group<T>;\n\n private _previousValue: Record<string, any>[] | null;\n\n constructor(itemTemplate?: Group<T>, params?: Partial<IField>) {\n super();\n\n this._itemTemplate = itemTemplate;\n\n if (params) {\n const { value: paramValue, ...otherParams } = params;\n Object.assign(this, otherParams);\n\n if (paramValue) this.setValue(paramValue);\n }\n\n if (this.originalValue === undefined) this.originalValue = this.value;\n this._previousValue = this.value;\n // if (Object.keys(this._fields).length) console.log('formGroup created', this, Error().stack);\n }\n\n get reactive() {\n return this;\n }\n\n private processSetValueItem(item: any) : Group<T> {\n let res: Group<T>;\n // If item is already a Group, use it\n if (item instanceof Group) res = item;\n // Otherwise create a Group from item\n else if (this._itemTemplate) res = this._itemTemplate.clone({ value: item });\n else res = Group.createFromFormData(item) as Group<T>;\n\n Object.defineProperty(res, 'parent', { get: () => this, configurable: false, enumerable: false });\n\n return res;\n }\n\n private setValue(newValue: any[]) {\n if (Array.isArray(newValue)) {\n this._value = newValue.map((item: any) => this.processSetValueItem(item));\n }\n }\n\n get value(): Record<string, any>[] | null {\n const value = this._value?.map((item) => item.value);\n return isEmpty(value) ? null : <Record<string, any>[]> value;\n }\n\n set value(newValue: Record<string, any>[]) {\n const oldValue = this.value;\n this.setValue(newValue);\n this.actions.trigger(ValueChangedAction, this, this.value, oldValue);\n if (this.parent) this.parent.notifyValueChanged();\n }\n\n clone(overrides?: Partial<IField>): List<T> {\n return new List(this._itemTemplate?.clone(), {\n value: [...(overrides?.value ?? this.value)],\n ...(overrides && 'originalValue' in overrides ? { originalValue: overrides.originalValue } : { }),\n errors: [...(overrides?.errors ?? [])],\n enabled: overrides?.enabled ?? this.enabled,\n visibility: overrides?.visibility ?? this.visibility,\n });\n }\n\n notifyValueChanged() {\n const newValue = this.value;\n if (!isEqual(newValue, this._previousValue)) {\n const oldValue = this._previousValue;\n this._previousValue = newValue;\n this.actions.trigger(ValueChangedAction, this, newValue, oldValue);\n if (this.parent) this.parent.notifyValueChanged();\n }\n }\n\n get(index: number): Group<T> | undefined {\n return this._value != null ? this._value[index] : undefined;\n }\n\n push(item: any): number {\n return this.insert(item, this._value?.length ?? 0) + 1;\n }\n\n pop(): Group<T> | undefined {\n return this.remove((this._value?.length ?? 0) - 1);\n }\n\n remove(index: number): Group<T> | undefined {\n if (this._value == null || index < 0 || this._value.length <= index) return undefined;\n\n let removedItem = this._value.splice(index, 1)?.[0];\n\n if (removedItem) {\n // Remove parent reference\n removedItem = removedItem.clone();\n\n // Trigger events\n this.actions.trigger(ListItemRemovedAction, this, removedItem, index);\n this.notifyValueChanged();\n }\n\n return removedItem;\n }\n\n insert(item: any, index: number): number {\n if (this._value == null) this._value = [];\n while (this._value.length < index) {\n // if the index is too large for current array size, we add as many as necessary\n const itm = this.processSetValueItem(null);\n const idx = this._value.push(itm);\n this.actions.trigger(ListItemAddedAction, this, itm, idx);\n }\n const itm = this.processSetValueItem(item);\n this._value.splice(index, 0, itm);\n\n this.actions.trigger(ListItemAddedAction, this, itm, index);\n this.notifyValueChanged();\n\n return index;\n }\n\n clear() {\n this._value = null;\n this.notifyValueChanged();\n }\n}\n\nexport type NullableList = List | null;\n"],"names":["FieldActionBase","executorFn","__publicField","field","supr","params","__async","AbortEventHandlingException","ActionsMap","action","actionType","existingExecute","ex","ActionClass","identifier","execute","error","EnabledChangingActionClassIdentifier","EnabledChangingAction","newValue","oldValue","__superGet","EnabledChangedActionClassIdentifier","EnabledChangedAction","ExecuteActionClassIdentifier","ExecuteAction","VisibilityChangingActionClassIdentifier","VisibilityChangingAction","VisibilityChangedActionClassIdentifier","VisibilityChangedAction","ValidChangedActionClassIdentifier","ValidChangedAction","ValueChangedActionClassIdentifier","ValueChangedAction","ListItemAddedActionClassIdentifier","ListItemAddedAction","item","index","ListItemRemovedActionClassIdentifier","ListItemRemovedAction","DisplayMode","defaultDisplayMode","fromString","mode","fromAny","input","isDefined","check","DisplayMode$1","FieldBase","alteredValue","isBoolean","oldValid","isEqual","reactive","actionClass","isValEmpty","val","defaultIfTrue","Action","_a","paramValue","originalValue","otherParams","__objRest","orgVal","overrides","__spreadProps","__spreadValues","_b","_c","_d","Field","EmptyField","Group","fields","name","reactiveField","computed","flds","isFieldAll","data","key","value","fieldName","fieldValue","isEmpty","newFields","List","itemTemplate","res","_e","removedItem","itm","idx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAA8BA,EAAwC;AAAA,EAIpE,YAAYC,GAA4B;AAFvB,IAAAC,EAAA;AAGf,SAAK,aAAaD;AAAA,EAAA;AAAA,EAGd,QAAQE,GAAeC,MAAkCC,GAA6B;AAAA,WAAAC,EAAA;AAC1F,aAAO,KAAK,WAAWH,GAAOC,GAAM,GAAGC,CAAM;AAAA,IAAA;AAAA;AAEjD;ACKO,MAAME,UAAoC,MAAM;AAAC;ACrBxD,MAAqBC,UAAmB,IAAgC;AAAA,EACtE,SAASC,GAAyB;AAC5B,QAAA,EAAEA,aAAkBT;AAChB,YAAA,IAAI,MAAM,qBAAqB;AAGvC,UAAMU,IAAaD,EAAO,iBACpBE,IAAkB,KAAK,IAAID,CAAU,MAAM,MAAM;AAE9C,aAAAE,EAAGT,MAAkBE,GAAe;AAC3C,aAAOI,EAAO,QAAQN,GAAOQ,GAAiB,GAAGN,CAAM;AAAA,IAAA;AAEpD,SAAA,IAAIK,GAAYE,CAAE;AAAA,EAAA;AAAA,EAGzB,QACEC,GACAV,MACGE,GACE;AACC,UAAAS,IAAa,IAAID,EAAY,MAAM;AAAA,IAAE,CAAA,EAAE,iBACvCE,IAAU,KAAK,IAAID,CAAU;AAC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,MAAM,GAGhC,KAAK,QAAQ,QAAQrD,GAAuB,MAAMqD,GAAavD,CAAK,GACpE,KAAK,mBAAmB,IAGnBuD;AAAA,EAAA;AAAA,EAGT,OAAOxD,GAAWC,GAAuB;AAEhC,SADH,KAAK,UAAU,SAAM,KAAK,SAAS,CAAC,IACjC,KAAK,OAAO,SAASA,KAAO;AAE3BwD,YAAAA,IAAM,KAAK,oBAAoB,IAAI,GACnCC,IAAM,KAAK,OAAO,KAAKD,CAAG;AAChC,WAAK,QAAQ,QAAQ1D,GAAqB,MAAM0D,GAAKC,CAAG;AAAA,IAAA;AAEpD,UAAAD,IAAM,KAAK,oBAAoBzD,CAAI;AACzC,gBAAK,OAAO,OAAOC,GAAO,GAAGwD,CAAG,GAEhC,KAAK,QAAQ,QAAQ1D,GAAqB,MAAM0D,GAAKxD,CAAK,GAC1D,KAAK,mBAAmB,GAEjBA;AAAA,EAAA;AAAA,EAGT,QAAQ;AACN,SAAK,SAAS,MACd,KAAK,mBAAmB;AAAA,EAAA;AAE5B;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(s,a){typeof exports=="object"&&typeof module!="undefined"?a(exports,require("vue"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","vue","lodash"],a):(s=typeof globalThis!="undefined"?globalThis:s||self,a((s["dynamicforms-vue-forms"]=s["dynamicforms-vue-forms"]||{},s["dynamicforms-vue-forms"]["[name]"]={}),s.vue,s.lodash))})(this,function(s,a,u){"use strict";var tt=Object.defineProperty,et=Object.defineProperties;var it=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols,nt=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,st=Reflect.get;var R=(s,a,u)=>a in s?tt(s,a,{enumerable:!0,configurable:!0,writable:!0,value:u}):s[a]=u,x=(s,a)=>{for(var u in a||(a={}))z.call(a,u)&&R(s,u,a[u]);if(U)for(var u of U(a))W.call(a,u)&&R(s,u,a[u]);return s},j=(s,a)=>et(s,it(a));var F=(s,a)=>{var u={};for(var h in s)z.call(s,h)&&a.indexOf(h)<0&&(u[h]=s[h]);if(s!=null&&U)for(var h of U(s))a.indexOf(h)<0&&W.call(s,h)&&(u[h]=s[h]);return u};var o=(s,a,u)=>R(s,typeof a!="symbol"?a+"":a,u);var b=(s,a,u)=>st(nt(s),u,a);var f=(s,a,u)=>new Promise((h,V)=>{var O=y=>{try{d(u.next(y))}catch(p){V(p)}},B=y=>{try{d(u.throw(y))}catch(p){V(p)}},d=y=>y.done?h(y.value):Promise.resolve(y.value).then(O,B);d((u=u.apply(s,a)).next())});class h{constructor(n){o(this,"executorFn");this.executorFn=n}execute(n,t,...e){return f(this,null,function*(){return this.executorFn(n,t,...e)})}}class V extends Error{}class O extends Map{register(n){if(!(n instanceof h))throw new Error("Invalid action type");const t=n.classIdentifier,e=this.get(t)||(()=>null);function i(l,...r){return n.execute(l,e,...r)}this.set(t,i)}trigger(n,t,...e){const i=new n(()=>{}).classIdentifier,l=this.get(i);try{if(l)return l(t,...e)}catch(r){if(!(r instanceof V))throw r}return null}}const B=Symbol("EnabledChangingAction");class d extends h{constructor(n){super(n)}get classIdentifier(){return B}execute(n,t,e,i){return f(this,null,function*(){return b(d.prototype,this,"execute").call(this,n,t,e,i)})}}const y=Symbol("EnabledChangedAction");class p extends h{constructor(n){super(n)}get classIdentifier(){return y}execute(n,t,e,i){return f(this,null,function*(){return b(p.prototype,this,"execute").call(this,n,t,e,i)})}}const $=Symbol("ExecuteAction");class P extends h{constructor(n){super(n)}get classIdentifier(){return $}execute(n,t,e){return f(this,null,function*(){return b(P.prototype,this,"execute").call(this,n,t,e)})}}const J=Symbol("VisibilityChangingAction");class L extends h{constructor(n){super(n)}get classIdentifier(){return J}execute(n,t,e,i){return f(this,null,function*(){return b(L.prototype,this,"execute").call(this,n,t,e,i)})}}const K=Symbol("VisibilityChangedAction");class E extends h{constructor(n){super(n)}get classIdentifier(){return K}execute(n,t,e,i){return f(this,null,function*(){return b(E.prototype,this,"execute").call(this,n,t,e,i)})}}const Q=Symbol("ValidChangedAction");class w extends h{constructor(n){super(n)}get classIdentifier(){return Q}execute(n,t,e,i){return f(this,null,function*(){return b(w.prototype,this,"execute").call(this,n,t,e,i)})}}const X=Symbol("ValueChangedAction");class m extends h{constructor(n){super(n)}get classIdentifier(){return X}execute(n,t,e,i){return f(this,null,function*(){return b(m.prototype,this,"execute").call(this,n,t,e,i)})}}const Y=Symbol("ListItemAddedAction");class I extends h{constructor(n){super(n)}get classIdentifier(){return Y}execute(n,t,e,i){return f(this,null,function*(){return b(I.prototype,this,"execute").call(this,n,t,e,i)})}}const Z=Symbol("ListItemRemovedAction");class N extends h{constructor(n){super(n)}get classIdentifier(){return Z}execute(n,t,e,i){return f(this,null,function*(){return b(N.prototype,this,"execute").call(this,n,t,e,i)})}}var C=(c=>(c[c.SUPPRESS=1]="SUPPRESS",c[c.HIDDEN=5]="HIDDEN",c[c.INVISIBLE=8]="INVISIBLE",c[c.FULL=10]="FULL",c))(C||{});const D=10;(c=>{function n(i){return i.toUpperCase()==="SUPPRESS"?1:i.toUpperCase()==="HIDDEN"?5:i.toUpperCase()==="INVISIBLE"?8:D}c.fromString=n;function t(i){const l=typeof i=="number"?i:c.fromString(i);return Object.values(c).includes(l)?l:D}c.fromAny=t;function e(i){const l=typeof i=="number"?i:c.fromString(i);return Object.values(c).includes(l)}c.isDefined=e})(C||(C={})),Object.freeze(C);const A=C;class _{constructor(){o(this,"valid",!0);o(this,"errors",[]);o(this,"actions",new O);o(this,"_visibility",A.FULL);o(this,"_enabled",!0)}get visibility(){return this._visibility}set visibility(n){const t=this._visibility;if(!A.isDefined(n))throw new Error("visibility must be a DisplayMode constant");this._visibility=A.fromAny(n),this.actions.trigger(E,this,this._visibility,t)}setVisibility(n){return f(this,null,function*(){const t=this._visibility,e=yield this.actions.trigger(L,this,n,t);if(!A.isDefined(e!=null?e:n))throw new Error("visibility must be a DisplayMode constant");this._visibility=A.fromAny(e!=null?e:n),this.actions.trigger(E,this,this._visibility,t)})}get enabled(){return this._enabled}set enabled(n){const t=this._enabled;if(!u.isBoolean(n))throw new Error("Enabled value must be boolean");this._enabled=n,this.actions.trigger(p,this,this._enabled,t)}setEnabled(n){return f(this,null,function*(){const t=this._enabled,e=yield this.actions.trigger(d,this,n,t);if(!u.isBoolean(e!=null?e:n))throw new Error("Enabled value must be boolean");this._enabled=e!=null?e:n,this.actions.trigger(p,this,this._enabled,t)})}validate(){const n=this.valid;this.valid=this.errors.length===0,this.valid!==n&&this.actions.trigger(w,this,this.valid,n)}get fullValue(){return this.value}get isChanged(){return!u.isEqual(this.value,this.originalValue)}get reactive(){return a.reactive(this)}registerAction(n){return this.actions.register(n),this}triggerAction(n,...t){return this.actions.trigger(n,this,...t)}}function k(c,n){return(c==null?void 0:c.label)==null&&(c==null?void 0:c.icon)==null?n:c}class q extends _{constructor(t){super();o(this,"_value");if(t){const e=t,{value:i,originalValue:l}=e,r=F(e,["value","originalValue"]);Object.assign(this,r);const g={label:i==null?void 0:i.label,icon:i==null?void 0:i.icon},T=Object.freeze({label:l==null?void 0:l.label,icon:l==null?void 0:l.icon});this._value=a.reactive(k(g,T)),this.originalValue=k(T,g)}else this._value=a.reactive({label:void 0,icon:void 0})}get value(){return this._value}set value(t){if(!this.enabled)return;const e=this._value;this._value.icon=t==null?void 0:t.icon,this._value.label=t==null?void 0:t.label,this.actions.trigger(m,this,t,e),this.parent&&this.parent.notifyValueChanged(),this.validate()}get icon(){return this.value.icon}set icon(t){this.value={label:this.label,icon:t}}get label(){return this.value.label}set label(t){this.value={label:t,icon:this.value.icon}}clone(t){var e,i,l,r;return new q(j(x({value:(e=t==null?void 0:t.value)!=null?e:this.value},t&&"originalValue"in t?{originalValue:t.originalValue}:{}),{errors:[...(i=t==null?void 0:t.errors)!=null?i:this.errors],enabled:(l=t==null?void 0:t.enabled)!=null?l:this.enabled,visibility:(r=t==null?void 0:t.visibility)!=null?r:this.visibility}))}execute(t){this.actions.trigger(P,this,t)}}class S extends _{constructor(t){super();o(this,"_value");if(t){const e=t,{value:i}=e,l=F(e,["value"]);Object.assign(this,l),this._value=i!=null?i:this.originalValue,this.originalValue===void 0&&(this.originalValue=this._value)}}get value(){return this._value}set value(t){if(!this.enabled)return;const e=this._value;this._value=t,this.actions.trigger(m,this,t,e),this.parent&&this.parent.notifyValueChanged(),this.validate()}clone(t){var e,i,l,r;return new S(j(x({value:(e=t==null?void 0:t.value)!=null?e:this.value},t&&"originalValue"in t?{originalValue:t.originalValue}:{}),{errors:[...(i=t==null?void 0:t.errors)!=null?i:this.errors],enabled:(l=t==null?void 0:t.enabled)!=null?l:this.enabled,visibility:(r=t==null?void 0:t.visibility)!=null?r:this.visibility}))}}const G=new S({value:"EmptyField"}).registerAction(new m(()=>f(this,null,function*(){console.warn("Working with EmptyField! This should not happen")})));class v extends _{constructor(t,e){super();o(this,"_fields");o(this,"_value",null);o(this,"reactiveValue");o(this,"suppressNotifyValueChanged",!1);if(!v.isValidFields(t))throw new Error("Invalid fields object provided");if(this._fields={},Object.entries(t).forEach(([l,r])=>{Object.defineProperty(r,"parent",{get:()=>this,configurable:!1,enumerable:!1}),Object.defineProperty(r,"fieldName",{get:()=>l,configurable:!1,enumerable:!1});const g=r.reactive;Object.defineProperty(this._fields,l,{get(){return g},configurable:!1,enumerable:!0})}),e){const i=e,{value:l}=i,r=F(i,["value"]);Object.assign(this,r),this.value=l!=null?l:this.originalValue}this.originalValue===void 0&&(this.originalValue=this.value),this.reactiveValue=a.computed(()=>this.value)}get reactive(){return this}static isValidFields(t){function e(i){return i instanceof _}return typeof t=="object"&&t!==null&&Object.entries(t).every(([,i])=>e(i))}static createFromFormData(t){if(t instanceof _)throw new Error("data is already a Form structure, should be a simple object");return new v(t==null?{}:Object.fromEntries(Object.entries(t).map(([e,i])=>[e,new S({value:i})])))}field(t){var e;return(e=this._fields[t])!=null?e:null}get fields(){return this._fields}get value(){const t={};return Object.entries(this._fields).forEach(([e,i])=>{const l=i.value;(i.enabled||i instanceof v&&!u.isEmpty(l))&&(t[e]=l)}),u.isEmpty(t)?null:t}set value(t){this.suppressNotifyValueChanged=!0;try{Object.entries(this._fields).forEach(([e,i])=>{(t==null||e in t)&&(i.value=t==null?null:t[e])})}finally{this.suppressNotifyValueChanged=!1}this.notifyValueChanged()}get fullValue(){const t={};return Object.entries(this._fields).forEach(([e,i])=>{t[e]=i.fullValue}),t}notifyValueChanged(){if(this.suppressNotifyValueChanged)return;const t=this.value;if(!u.isEqual(t,this._value)){const e=this._value;this._value=t,this.actions.trigger(m,this,t,e),this.parent&&this.parent.notifyValueChanged()}}clone(t){var i,l,r,g;const e={};return Object.entries(this._fields).forEach(([T,M])=>{e[T]=M.clone()}),new v(e,j(x({value:(i=t==null?void 0:t.value)!=null?i:this.value},t&&"originalValue"in t?{originalValue:t.originalValue}:{}),{errors:[...(l=t==null?void 0:t.errors)!=null?l:[]],enabled:(r=t==null?void 0:t.enabled)!=null?r:this.enabled,visibility:(g=t==null?void 0:t.visibility)!=null?g:this.visibility}))}}class H extends _{constructor(t,e){super();o(this,"_value",null);o(this,"_itemTemplate");o(this,"_previousValue");if(this._itemTemplate=t,e){const i=e,{value:l}=i,r=F(i,["value"]);Object.assign(this,r),l&&this.setValue(l)}this.originalValue===void 0&&(this.originalValue=this.value),this._previousValue=this.value}get reactive(){return this}processSetValueItem(t){let e;return t instanceof v?e=t:this._itemTemplate?e=this._itemTemplate.clone({value:t}):e=v.createFromFormData(t),Object.defineProperty(e,"parent",{get:()=>this,configurable:!1,enumerable:!1}),e}setValue(t){Array.isArray(t)&&(this._value=t.map(e=>this.processSetValueItem(e)))}get value(){var e;const t=(e=this._value)==null?void 0:e.map(i=>i.value);return u.isEmpty(t)?null:t}set value(t){const e=this.value;this.setValue(t),this.actions.trigger(m,this,this.value,e),this.parent&&this.parent.notifyValueChanged()}clone(t){var e,i,l,r,g;return new H((e=this._itemTemplate)==null?void 0:e.clone(),j(x({value:[...(i=t==null?void 0:t.value)!=null?i:this.value]},t&&"originalValue"in t?{originalValue:t.originalValue}:{}),{errors:[...(l=t==null?void 0:t.errors)!=null?l:[]],enabled:(r=t==null?void 0:t.enabled)!=null?r:this.enabled,visibility:(g=t==null?void 0:t.visibility)!=null?g:this.visibility}))}notifyValueChanged(){const t=this.value;if(!u.isEqual(t,this._previousValue)){const e=this._previousValue;this._previousValue=t,this.actions.trigger(m,this,t,e),this.parent&&this.parent.notifyValueChanged()}}get(t){return this._value!=null?this._value[t]:void 0}push(t){var e,i;return this.insert(t,(i=(e=this._value)==null?void 0:e.length)!=null?i:0)+1}pop(){var t,e;return this.remove(((e=(t=this._value)==null?void 0:t.length)!=null?e:0)-1)}remove(t){var i;if(this._value==null||t<0||this._value.length<=t)return;let e=(i=this._value.splice(t,1))==null?void 0:i[0];return e&&(e=e.clone(),this.actions.trigger(N,this,e,t),this.notifyValueChanged()),e}insert(t,e){for(this._value==null&&(this._value=[]);this._value.length<e;){const l=this.processSetValueItem(null),r=this._value.push(l);this.actions.trigger(I,this,l,r)}const i=this.processSetValueItem(t);return this._value.splice(e,0,i),this.actions.trigger(I,this,i,e),this.notifyValueChanged(),e}clear(){this._value=null,this.notifyValueChanged()}}s.AbortEventHandlingException=V,s.Action=q,s.ActionsMap=O,s.EmptyField=G,s.EnabledChangedAction=p,s.EnabledChangingAction=d,s.ExecuteAction=P,s.Field=S,s.FieldActionBase=h,s.Group=v,s.List=H,s.ListItemAddedAction=I,s.ListItemRemovedAction=N,s.ValidChangedAction=w,s.ValueChangedAction=m,s.VisibilityChangedAction=E,s.VisibilityChangingAction=L,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
|
2
|
+
//# sourceMappingURL=dynamicforms-vue-forms.umd.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamicforms-vue-forms.umd.cjs","sources":["../src/actions/field-action-base.ts","../src/field.interface.ts","../src/actions/actions-map.ts","../src/actions/enabled-actions.ts","../src/actions/execute-action.ts","../src/actions/visibility-actions.ts","../src/actions/valid-changed-action.ts","../src/actions/value-changed-action.ts","../src/actions/list-item-added-action.ts","../src/actions/list-item-removed-action.ts","../src/display-mode.ts","../src/field-base.ts","../src/action.ts","../src/field.ts","../src/group.ts","../src/list.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport {\n FieldActionExecute,\n type IField,\n type IFieldAction,\n} from '@/field.interface';\n\ntype ActionExecutor = (field: IField, supr: FieldActionExecute, ...params: any[]) => Promise<any>;\n\nexport default abstract class FieldActionBase implements IFieldAction {\n public abstract get classIdentifier(): symbol;\n private readonly executorFn: ActionExecutor;\n\n constructor(executorFn: ActionExecutor) {\n this.executorFn = executorFn;\n }\n\n async execute(field: IField, supr: IFieldAction['execute'], ...params: any[]): Promise<any> {\n return this.executorFn(field, supr, ...params);\n }\n}\n","import type DisplayMode from './display-mode';\nimport { type ValidationError } from './validation-error';\n\nexport interface IField<T = any> {\n value: T;\n fullValue: T;\n originalValue: T;\n valid: boolean;\n errors: ValidationError[];\n enabled: boolean;\n visibility: DisplayMode;\n\n parent?: any; // Group when member of a Group, parent will specify that group\n fieldName?: string; // when member of a Group, fieldName specifies the name of this field\n\n clone(overrides?: Partial<IField<T>>): IField<T>;\n // events\n registerAction(action: IFieldAction<T>): this;\n triggerAction<T2 extends IFieldAction<T>>(actionClass: abstract new (...args: any[]) => T2, ...params: any[]): any;\n\n // API\n validate(): void;\n isChanged: boolean;\n}\n\nexport class AbortEventHandlingException extends Error {}\n\nexport type FieldActionExecute<T = any> = (field: IField<T>, ...params: any[]) => Promise<any>;\nexport interface IFieldAction<T = any> {\n execute(field: IField<T>, supr: FieldActionExecute<T>, ...params: any[]): any;\n}\n","import { type FieldActionExecute, type IField, AbortEventHandlingException } from '../field.interface';\n\nimport FieldActionBase from './field-action-base';\n\nexport default class ActionsMap extends Map<symbol, FieldActionExecute> {\n register(action: FieldActionBase) {\n if (!(action instanceof FieldActionBase)) {\n throw new Error('Invalid action type');\n }\n\n const actionType = action.classIdentifier;\n const existingExecute = this.get(actionType) || (() => null);\n\n function ex(field: IField, ...params: any[]) {\n return action.execute(field, existingExecute, ...params);\n }\n this.set(actionType, ex);\n }\n\n trigger<T extends FieldActionBase>(\n ActionClass: new (...args: any[]) => T,\n field: IField,\n ...params: any[]\n ): any {\n const identifier = new ActionClass(() => {}).classIdentifier;\n const execute = this.get(identifier);\n try {\n if (execute) return execute(field, ...params);\n } catch (error) {\n if (!(error instanceof AbortEventHandlingException)) throw error;\n }\n return null;\n }\n}\n","// eslint-disable-next-line max-classes-per-file\nimport FieldActionBase from './field-action-base';\n\nimport { FieldActionExecute, type IField } from '@/field.interface';\n\nconst EnabledChangingActionClassIdentifier = Symbol('EnabledChangingAction');\n\nexport class EnabledChangingAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (\n field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean\n ) => Promise<boolean>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return EnabledChangingActionClassIdentifier; }\n\n async execute(field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean)\n : Promise<boolean> {\n return super.execute(field, supr, newValue, oldValue);\n }\n}\n\nconst EnabledChangedActionClassIdentifier = Symbol('EnabledChangedAction');\n\nexport class EnabledChangedAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (\n field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean\n ) => Promise<void>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return EnabledChangedActionClassIdentifier; }\n\n async execute(\n field: IField,\n supr: FieldActionExecute,\n newValue: boolean,\n oldValue: boolean,\n ): Promise<void> {\n return super.execute(field, supr, newValue, oldValue);\n }\n}\n","import FieldActionBase from './field-action-base';\n\nimport { FieldActionExecute, type IField } from '@/field.interface';\n\nconst ExecuteActionClassIdentifier = Symbol('ExecuteAction');\n\n// eslint-disable-next-line import/prefer-default-export\nexport class ExecuteAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (field: IField, supr: FieldActionExecute, params: any) => Promise<any>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return ExecuteActionClassIdentifier; }\n\n async execute(field: IField, supr: FieldActionExecute, params: any): Promise<any> {\n return super.execute(field, supr, params);\n }\n}\n","// eslint-disable-next-line max-classes-per-file\nimport FieldActionBase from './field-action-base';\n\nimport DisplayMode from '@/display-mode';\nimport { FieldActionExecute, type IField } from '@/field.interface';\n\nconst VisibilityChangingActionClassIdentifier = Symbol('VisibilityChangingAction');\n\nexport class VisibilityChangingAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (\n field: IField, supr: FieldActionExecute, newValue: DisplayMode, oldValue: DisplayMode\n ) => Promise<DisplayMode>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return VisibilityChangingActionClassIdentifier; }\n\n async execute(\n field: IField,\n supr: FieldActionExecute,\n newValue: DisplayMode,\n oldValue: DisplayMode,\n ): Promise<DisplayMode> {\n return super.execute(field, supr, newValue, oldValue);\n }\n}\n\nconst VisibilityChangedActionClassIdentifier = Symbol('VisibilityChangedAction');\n\nexport class VisibilityChangedAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (\n field: IField, supr: FieldActionExecute, newValue: DisplayMode, oldValue: DisplayMode,\n ) => Promise<void>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return VisibilityChangedActionClassIdentifier; }\n\n async execute(\n field: IField,\n supr: FieldActionExecute,\n newValue: DisplayMode,\n oldValue: DisplayMode,\n ): Promise<void> {\n return super.execute(field, supr, newValue, oldValue);\n }\n}\n","import FieldActionBase from './field-action-base';\n\nimport { FieldActionExecute, type IField } from '@/field.interface';\n\nconst ValidChangedActionClassIdentifier = Symbol('ValidChangedAction');\n\n// eslint-disable-next-line import/prefer-default-export\nexport class ValidChangedAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (\n field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean,\n ) => Promise<void>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return ValidChangedActionClassIdentifier; }\n\n async execute(\n field: IField,\n supr: FieldActionExecute,\n newValue: boolean,\n oldValue: boolean,\n ): Promise<void> {\n return super.execute(field, supr, newValue, oldValue);\n }\n}\n","import FieldActionBase from './field-action-base';\n\nimport { FieldActionExecute, type IField } from '@/field.interface';\n\nconst ValueChangedActionClassIdentifier = Symbol('ValueChangedAction');\n\n// eslint-disable-next-line import/prefer-default-export\nexport class ValueChangedAction<T = any> extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (\n field: IField<T>, supr: FieldActionExecute<T>, newValue: T, oldValue: T,\n ) => Promise<void>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return ValueChangedActionClassIdentifier; }\n\n async execute(\n field: IField<T>,\n supr: FieldActionExecute<T>,\n newValue: T,\n oldValue: T,\n ): Promise<void> {\n return super.execute(field, supr, newValue, oldValue);\n }\n}\n","import FieldActionBase from './field-action-base';\n\nimport { FieldActionExecute, type IField } from '@/field.interface';\n\nconst ListItemAddedActionClassIdentifier = Symbol('ListItemAddedAction');\n\n// eslint-disable-next-line import/prefer-default-export\nexport class ListItemAddedAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (field: IField, supr: FieldActionExecute, item: any, index: number) => Promise<void>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return ListItemAddedActionClassIdentifier; }\n\n async execute(field: IField, supr: FieldActionExecute, item: any, index: number): Promise<void> {\n return super.execute(field, supr, item, index);\n }\n}\n","import FieldActionBase from './field-action-base';\n\nimport { FieldActionExecute, type IField } from '@/field.interface';\n\nconst ListItemRemovedActionClassIdentifier = Symbol('ListItemRemovedAction');\n\n// eslint-disable-next-line import/prefer-default-export\nexport class ListItemRemovedAction extends FieldActionBase {\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(\n executorFn: (field: IField, supr: FieldActionExecute, item: any, index: number) => Promise<void>,\n ) {\n super(executorFn);\n }\n\n // eslint-disable-next-line class-methods-use-this\n get classIdentifier() { return ListItemRemovedActionClassIdentifier; }\n\n async execute(field: IField, supr: FieldActionExecute, item: any, index: number): Promise<void> {\n return super.execute(field, supr, item, index);\n }\n}\n","/**\n * DisplayMode enum provides an enumeration for supported ways of rendering a particular object in the DOM\n */\nenum DisplayMode {\n // This enum is actually declared in dynamicforms.mixins.field_render.py\n SUPPRESS = 1, // Field will be entirely suppressed. it will not render (not even to JSON) and will not parse for PUT\n HIDDEN = 5, // Field will render as <input type=\"hidden\"> or <tr data-field_name>\n INVISIBLE = 8, // Field will render completely, but with display: none. Equal to setting its style = {display: none}\n FULL = 10, // Field will render completely\n}\n\nexport const defaultDisplayMode = DisplayMode.FULL;\n\nnamespace DisplayMode {\n export function fromString(mode: string): DisplayMode {\n if (mode.toUpperCase() === 'SUPPRESS') return DisplayMode.SUPPRESS;\n if (mode.toUpperCase() === 'HIDDEN') return DisplayMode.HIDDEN;\n if (mode.toUpperCase() === 'INVISIBLE') return DisplayMode.INVISIBLE;\n return defaultDisplayMode;\n }\n\n export function fromAny(mode: any): DisplayMode {\n const input = (typeof mode === 'number') ? mode : DisplayMode.fromString(mode as string);\n if (Object.values(DisplayMode).includes(input)) return input;\n return defaultDisplayMode;\n }\n\n export function isDefined(mode: number | string): boolean {\n const check = (typeof mode === 'number') ? mode : DisplayMode.fromString(mode as string);\n return Object.values(DisplayMode).includes(check);\n }\n}\n\nObject.freeze(DisplayMode);\n\nexport default DisplayMode;\n","import { isBoolean, isEqual } from 'lodash';\nimport { reactive } from 'vue';\n\nimport {\n ActionsMap,\n EnabledChangedAction,\n EnabledChangingAction,\n ValidChangedAction,\n VisibilityChangedAction,\n VisibilityChangingAction,\n} from './actions';\nimport FieldActionBase from './actions/field-action-base';\nimport DisplayMode from './display-mode';\nimport { IField, IFieldAction } from './field.interface';\nimport { type Group } from './group';\nimport { ValidationError } from './validation-error';\n\n// eslint-disable-next-line import/prefer-default-export\nexport abstract class FieldBase<T = any> implements IField<T> {\n abstract get value(): T;\n abstract set value(newValue: T);\n\n abstract clone(overrides?: Partial<IField<T>>): IField<T>;\n\n declare originalValue: T; // contains original field value as was provided at creation\n\n valid: boolean = true; // is current value valid as per FE and BE validators?\n\n errors: ValidationError[] = []; // list of errors\n\n declare parent?: Group; // when member of a Group, parent will specify that group\n\n declare fieldName?: string; // when member of a Group, fieldName specifies the name of this field\n\n protected actions: ActionsMap = new ActionsMap();\n\n // default property handlers\n private _visibility: DisplayMode = DisplayMode.FULL;\n\n get visibility(): DisplayMode { return this._visibility; }\n\n set visibility(newValue: DisplayMode) {\n const oldValue = this._visibility;\n if (!DisplayMode.isDefined(newValue)) throw new Error('visibility must be a DisplayMode constant');\n this._visibility = DisplayMode.fromAny(newValue);\n this.actions.trigger(VisibilityChangedAction, this, this._visibility, oldValue);\n }\n\n async setVisibility(newValue: DisplayMode) {\n const oldValue = this._visibility;\n const alteredValue = await this.actions.trigger(VisibilityChangingAction, this, newValue, oldValue);\n if (!DisplayMode.isDefined(alteredValue ?? newValue)) throw new Error('visibility must be a DisplayMode constant');\n this._visibility = DisplayMode.fromAny(alteredValue ?? newValue);\n this.actions.trigger(VisibilityChangedAction, this, this._visibility, oldValue);\n }\n\n private _enabled: boolean = true;\n\n get enabled(): boolean { return this._enabled; }\n\n set enabled(newValue: boolean) {\n const oldValue = this._enabled;\n if (!isBoolean(newValue)) throw new Error('Enabled value must be boolean');\n this._enabled = newValue;\n this.actions.trigger(EnabledChangedAction, this, this._enabled, oldValue);\n }\n\n async setEnabled(newValue: boolean) {\n const oldValue = this._enabled;\n const alteredValue = await this.actions.trigger(EnabledChangingAction, this, newValue, oldValue);\n if (!isBoolean(alteredValue ?? newValue)) throw new Error('Enabled value must be boolean');\n this._enabled = alteredValue ?? newValue;\n this.actions.trigger(EnabledChangedAction, this, this._enabled, oldValue);\n }\n\n validate() {\n const oldValid = this.valid;\n this.valid = this.errors.length === 0;\n if (this.valid !== oldValid) this.actions.trigger(ValidChangedAction, this, this.valid, oldValid);\n }\n\n get fullValue(): any {\n return this.value;\n }\n\n get isChanged() : boolean {\n return !isEqual(this.value, this.originalValue);\n }\n\n get reactive(): IField {\n return reactive(this);\n }\n\n registerAction(action: IFieldAction<T>): this {\n this.actions.register(action as FieldActionBase);\n return this;\n }\n\n triggerAction<T2 extends IFieldAction<T>>(\n actionClass: new (...args: any[]) => T2,\n ...params: any[]\n ): any {\n return this.actions.trigger(actionClass as any, this, ...params);\n }\n}\n","import { reactive } from 'vue';\n\nimport { ExecuteAction, ValueChangedAction } from './actions';\nimport { FieldBase } from './field-base';\nimport { IField } from './field.interface';\n\nexport interface ActionValue {\n label?: string;\n icon?: string;\n}\n\nfunction isValEmpty(val: ActionValue, defaultIfTrue: ActionValue): ActionValue {\n if (val?.label == null && val?.icon == null) return defaultIfTrue;\n return val;\n}\n\nexport class Action extends FieldBase {\n private readonly _value: ActionValue;\n\n constructor(params?: Partial<IField>) {\n super();\n if (params) {\n const { value: paramValue, originalValue, ...otherParams } = params;\n Object.assign(this, otherParams);\n const val = { label: paramValue?.label, icon: paramValue?.icon } as ActionValue;\n const orgVal = Object.freeze({ label: originalValue?.label, icon: originalValue?.icon } as ActionValue);\n this._value = reactive(isValEmpty(val, orgVal));\n this.originalValue = isValEmpty(orgVal, val);\n } else {\n this._value = reactive({ label: undefined, icon: undefined });\n }\n }\n\n get value(): ActionValue { return this._value; }\n\n set value(newValue: ActionValue) {\n if (!this.enabled) return; // a disabled field does not allow changing value\n const oldValue = this._value;\n this._value.icon = newValue?.icon;\n this._value.label = newValue?.label;\n this.actions.trigger(ValueChangedAction, this, newValue, oldValue);\n if (this.parent) this.parent.notifyValueChanged();\n this.validate();\n }\n\n get icon(): string | undefined {\n return this.value.icon;\n }\n\n set icon(newValue: string | undefined) {\n this.value = { label: this.label, icon: newValue };\n }\n\n get label(): string | undefined {\n return this.value.label;\n }\n\n set label(newValue: string | undefined) {\n this.value = { label: newValue, icon: this.value.icon };\n }\n\n clone(overrides?: Partial<IField>): Action {\n return new Action({\n value: overrides?.value ?? this.value,\n ...(overrides && 'originalValue' in overrides ? { originalValue: overrides.originalValue } : { }),\n errors: [...(overrides?.errors ?? this.errors)],\n enabled: overrides?.enabled ?? this.enabled,\n visibility: overrides?.visibility ?? this.visibility,\n });\n }\n\n execute(params: any) {\n this.actions.trigger(ExecuteAction, this, params);\n }\n}\n\nexport type NullableAction = Action | null;\n","import { ValueChangedAction } from './actions';\nimport { FieldBase } from './field-base';\nimport { IField } from './field.interface';\n\n// eslint-disable-next-line import/prefer-default-export\nexport class Field<T = any> extends FieldBase {\n private _value: T = undefined!;\n\n constructor(params?: Partial<IField<T>>) {\n super();\n if (params) {\n const { value: paramValue, ...otherParams } = params;\n Object.assign(this, otherParams);\n this._value = paramValue ?? this.originalValue;\n if (this.originalValue === undefined) this.originalValue = this._value;\n }\n }\n\n get value() { return this._value; }\n\n set value(newValue: T) {\n if (!this.enabled) return; // a disabled field does not allow changing value\n const oldValue = this._value;\n this._value = newValue;\n this.actions.trigger(ValueChangedAction, this, newValue, oldValue);\n if (this.parent) this.parent.notifyValueChanged();\n this.validate();\n }\n\n clone(overrides?: Partial<IField<T>>): Field<T> {\n return new Field<T>({\n value: overrides?.value ?? this.value,\n ...(overrides && 'originalValue' in overrides ? { originalValue: overrides.originalValue } : { }),\n errors: [...(overrides?.errors ?? this.errors)],\n enabled: overrides?.enabled ?? this.enabled,\n visibility: overrides?.visibility ?? this.visibility,\n });\n }\n}\n\nexport type NullableField<T = any> = Field<T> | null;\n\nexport const EmptyField = new Field({ value: 'EmptyField' })\n .registerAction(new ValueChangedAction(\n async () => {\n console.warn('Working with EmptyField! This should not happen');\n },\n ));\n","import { isEmpty, isEqual } from 'lodash';\nimport { ComputedRef, computed } from 'vue';\n\nimport { ValueChangedAction } from './actions';\nimport { Field } from './field';\nimport { FieldBase } from './field-base';\nimport { IField } from './field.interface';\n\nexport type GenericFieldsInterface = Record<string, IField>;\n\nexport class Group<T extends GenericFieldsInterface = GenericFieldsInterface> extends FieldBase {\n private readonly _fields: T;\n\n private _value: Record<string, any> | null = null;\n\n public readonly reactiveValue: ComputedRef<Record<string, any> | null>;\n\n private suppressNotifyValueChanged: boolean = false;\n\n constructor(fields: T, params?: Partial<IField>) {\n super();\n\n if (!Group.isValidFields(fields)) throw new Error('Invalid fields object provided');\n this._fields = {} as T;\n Object.entries(fields).forEach(([name, field]) => {\n Object.defineProperty(field, 'parent', { get: () => this, configurable: false, enumerable: false });\n Object.defineProperty(field, 'fieldName', { get: () => name, configurable: false, enumerable: false });\n const reactiveField = field.reactive;\n Object.defineProperty(\n this._fields,\n name,\n { get() { return reactiveField; }, configurable: false, enumerable: true },\n );\n });\n\n if (params) {\n const { value: paramValue, ...otherParams } = params;\n Object.assign(this, otherParams);\n this.value = paramValue ?? this.originalValue;\n }\n\n if (this.originalValue === undefined) this.originalValue = this.value;\n\n this.reactiveValue = computed(() => this.value);\n // if (Object.keys(this._fields).length) console.log('group created', this, Error().stack);\n }\n\n get reactive() {\n return this;\n }\n\n private static isValidFields(flds: unknown): flds is Record<string, FieldBase> {\n function isFieldAll(field: unknown): field is FieldBase {\n return field instanceof FieldBase;\n }\n\n return typeof flds === 'object' &&\n flds !== null &&\n Object.entries(flds).every(([, field]) => isFieldAll(field));\n }\n\n static createFromFormData(data: Record<string, any> | null): Group {\n if (data instanceof FieldBase) {\n throw new Error('data is already a Form structure, should be a simple object');\n }\n return new Group(\n data == null ?\n { } :\n Object.fromEntries(\n Object.entries(data).map(([key, value]) => [key, new Field({ value })]),\n ),\n );\n }\n\n field(fieldName: string): IField | null {\n return this._fields[fieldName] ?? null;\n }\n\n get fields(): T {\n return this._fields;\n }\n\n get value(): Record<string, any> | null {\n const value: Record<string, any> = {};\n Object.entries(this._fields).forEach(([name, field]) => {\n const fieldValue = field.value;\n if (field.enabled) {\n // readOnly fields do not serialize\n value[name] = fieldValue;\n } else if (field instanceof Group && !isEmpty(fieldValue)) {\n // readOnly group only serializes if it is non-empty (some of its fields are not readOnly)\n value[name] = fieldValue;\n }\n });\n return isEmpty(value) ? null : value;\n }\n\n set value(newValue: Record<string, any> | null) {\n this.suppressNotifyValueChanged = true;\n try {\n Object.entries(this._fields).forEach(([name, field]) => {\n if (newValue == null || name in newValue) {\n field.value = newValue == null ? null : newValue[name];\n }\n });\n } finally {\n this.suppressNotifyValueChanged = false;\n }\n this.notifyValueChanged();\n }\n\n get fullValue(): Record<string, any> {\n const value: Record<string, any> = {};\n Object.entries(this._fields).forEach(([name, field]) => { value[name] = field.fullValue; });\n return value;\n }\n\n notifyValueChanged() {\n if (this.suppressNotifyValueChanged) return;\n const newValue = this.value;\n if (!isEqual(newValue, this._value)) {\n const oldValue = this._value;\n this._value = newValue;\n this.actions.trigger(ValueChangedAction, this, newValue, oldValue);\n if (this.parent) this.parent.notifyValueChanged();\n }\n }\n\n clone(overrides?: Partial<IField>): Group<T> {\n const newFields = {} as T;\n Object.entries(this._fields).forEach(([name, field]) => {\n newFields[name as keyof T] = field.clone() as any;\n });\n\n return new Group(newFields, {\n value: overrides?.value ?? this.value,\n ...(overrides && 'originalValue' in overrides ? { originalValue: overrides.originalValue } : { }),\n errors: [...(overrides?.errors ?? [])],\n enabled: overrides?.enabled ?? this.enabled,\n visibility: overrides?.visibility ?? this.visibility,\n });\n }\n}\n\nexport type NullableGroup = Group | null;\n","import { isEmpty, isEqual } from 'lodash';\n\nimport { ListItemAddedAction, ListItemRemovedAction, ValueChangedAction } from './actions';\nimport { FieldBase } from './field-base';\nimport { IField } from './field.interface';\nimport { GenericFieldsInterface, Group } from './group';\n\nexport class List<T extends GenericFieldsInterface = GenericFieldsInterface> extends FieldBase {\n private _value: Group<T>[] | null = null;\n\n private _itemTemplate?: Group<T>;\n\n private _previousValue: Record<string, any>[] | null;\n\n constructor(itemTemplate?: Group<T>, params?: Partial<IField>) {\n super();\n\n this._itemTemplate = itemTemplate;\n\n if (params) {\n const { value: paramValue, ...otherParams } = params;\n Object.assign(this, otherParams);\n\n if (paramValue) this.setValue(paramValue);\n }\n\n if (this.originalValue === undefined) this.originalValue = this.value;\n this._previousValue = this.value;\n // if (Object.keys(this._fields).length) console.log('formGroup created', this, Error().stack);\n }\n\n get reactive() {\n return this;\n }\n\n private processSetValueItem(item: any) : Group<T> {\n let res: Group<T>;\n // If item is already a Group, use it\n if (item instanceof Group) res = item;\n // Otherwise create a Group from item\n else if (this._itemTemplate) res = this._itemTemplate.clone({ value: item });\n else res = Group.createFromFormData(item) as Group<T>;\n\n Object.defineProperty(res, 'parent', { get: () => this, configurable: false, enumerable: false });\n\n return res;\n }\n\n private setValue(newValue: any[]) {\n if (Array.isArray(newValue)) {\n this._value = newValue.map((item: any) => this.processSetValueItem(item));\n }\n }\n\n get value(): Record<string, any>[] | null {\n const value = this._value?.map((item) => item.value);\n return isEmpty(value) ? null : <Record<string, any>[]> value;\n }\n\n set value(newValue: Record<string, any>[]) {\n const oldValue = this.value;\n this.setValue(newValue);\n this.actions.trigger(ValueChangedAction, this, this.value, oldValue);\n if (this.parent) this.parent.notifyValueChanged();\n }\n\n clone(overrides?: Partial<IField>): List<T> {\n return new List(this._itemTemplate?.clone(), {\n value: [...(overrides?.value ?? this.value)],\n ...(overrides && 'originalValue' in overrides ? { originalValue: overrides.originalValue } : { }),\n errors: [...(overrides?.errors ?? [])],\n enabled: overrides?.enabled ?? this.enabled,\n visibility: overrides?.visibility ?? this.visibility,\n });\n }\n\n notifyValueChanged() {\n const newValue = this.value;\n if (!isEqual(newValue, this._previousValue)) {\n const oldValue = this._previousValue;\n this._previousValue = newValue;\n this.actions.trigger(ValueChangedAction, this, newValue, oldValue);\n if (this.parent) this.parent.notifyValueChanged();\n }\n }\n\n get(index: number): Group<T> | undefined {\n return this._value != null ? this._value[index] : undefined;\n }\n\n push(item: any): number {\n return this.insert(item, this._value?.length ?? 0) + 1;\n }\n\n pop(): Group<T> | undefined {\n return this.remove((this._value?.length ?? 0) - 1);\n }\n\n remove(index: number): Group<T> | undefined {\n if (this._value == null || index < 0 || this._value.length <= index) return undefined;\n\n let removedItem = this._value.splice(index, 1)?.[0];\n\n if (removedItem) {\n // Remove parent reference\n removedItem = removedItem.clone();\n\n // Trigger events\n this.actions.trigger(ListItemRemovedAction, this, removedItem, index);\n this.notifyValueChanged();\n }\n\n return removedItem;\n }\n\n insert(item: any, index: number): number {\n if (this._value == null) this._value = [];\n while (this._value.length < index) {\n // if the index is too large for current array size, we add as many as necessary\n const itm = this.processSetValueItem(null);\n const idx = this._value.push(itm);\n this.actions.trigger(ListItemAddedAction, this, itm, idx);\n }\n const itm = this.processSetValueItem(item);\n this._value.splice(index, 0, itm);\n\n this.actions.trigger(ListItemAddedAction, this, itm, index);\n this.notifyValueChanged();\n\n return index;\n }\n\n clear() {\n this._value = null;\n this.notifyValueChanged();\n }\n}\n\nexport type NullableList = List | null;\n"],"names":["FieldActionBase","executorFn","__publicField","field","supr","params","__async","AbortEventHandlingException","ActionsMap","action","actionType","existingExecute","ex","ActionClass","identifier","execute","error","EnabledChangingActionClassIdentifier","EnabledChangingAction","newValue","oldValue","__superGet","EnabledChangedActionClassIdentifier","EnabledChangedAction","ExecuteActionClassIdentifier","ExecuteAction","VisibilityChangingActionClassIdentifier","VisibilityChangingAction","VisibilityChangedActionClassIdentifier","VisibilityChangedAction","ValidChangedActionClassIdentifier","ValidChangedAction","ValueChangedActionClassIdentifier","ValueChangedAction","ListItemAddedActionClassIdentifier","ListItemAddedAction","item","index","ListItemRemovedActionClassIdentifier","ListItemRemovedAction","DisplayMode","defaultDisplayMode","fromString","mode","fromAny","input","isDefined","check","DisplayMode$1","FieldBase","alteredValue","isBoolean","oldValid","isEqual","reactive","actionClass","isValEmpty","val","defaultIfTrue","Action","_a","paramValue","originalValue","otherParams","__objRest","orgVal","overrides","__spreadProps","__spreadValues","_b","_c","_d","Field","EmptyField","Group","fields","name","reactiveField","computed","flds","isFieldAll","data","key","value","fieldName","fieldValue","isEmpty","newFields","List","itemTemplate","res","_e","removedItem","itm","idx"],"mappings":"iyCASA,MAA8BA,CAAwC,CAIpE,YAAYC,EAA4B,CAFvBC,EAAA,mBAGf,KAAK,WAAaD,CAAA,CAGd,QAAQE,EAAeC,KAAkCC,EAA6B,QAAAC,EAAA,sBAC1F,OAAO,KAAK,WAAWH,EAAOC,EAAM,GAAGC,CAAM,CAAA,GAEjD,CCKO,MAAME,UAAoC,KAAM,CAAC,CCrBxD,MAAqBC,UAAmB,GAAgC,CACtE,SAASC,EAAyB,CAC5B,GAAA,EAAEA,aAAkBT,GAChB,MAAA,IAAI,MAAM,qBAAqB,EAGvC,MAAMU,EAAaD,EAAO,gBACpBE,EAAkB,KAAK,IAAID,CAAU,IAAM,IAAM,MAE9C,SAAAE,EAAGT,KAAkBE,EAAe,CAC3C,OAAOI,EAAO,QAAQN,EAAOQ,EAAiB,GAAGN,CAAM,CAAA,CAEpD,KAAA,IAAIK,EAAYE,CAAE,CAAA,CAGzB,QACEC,EACAV,KACGE,EACE,CACC,MAAAS,EAAa,IAAID,EAAY,IAAM,CAAE,CAAA,EAAE,gBACvCE,EAAU,KAAK,IAAID,CAAU,EAC/B,GAAA,CACF,GAAIC,EAAS,OAAOA,EAAQZ,EAAO,GAAGE,CAAM,QACrCW,EAAO,CACV,GAAA,EAAEA,aAAiBT,GAAoC,MAAAS,CAAA,CAEtD,OAAA,IAAA,CAEX,CC5BA,MAAMC,EAAuC,OAAO,uBAAuB,EAEp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220 @@
|
|
|
1
|
+
import { ComputedRef } from 'vue';
|
|
2
|
+
|
|
3
|
+
export declare class AbortEventHandlingException extends Error {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export declare class Action extends FieldBase {
|
|
7
|
+
private readonly _value;
|
|
8
|
+
constructor(params?: Partial<IField>);
|
|
9
|
+
get value(): ActionValue;
|
|
10
|
+
set value(newValue: ActionValue);
|
|
11
|
+
get icon(): string | undefined;
|
|
12
|
+
set icon(newValue: string | undefined);
|
|
13
|
+
get label(): string | undefined;
|
|
14
|
+
set label(newValue: string | undefined);
|
|
15
|
+
clone(overrides?: Partial<IField>): Action;
|
|
16
|
+
execute(params: any): void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare type ActionExecutor = (field: IField, supr: FieldActionExecute, ...params: any[]) => Promise<any>;
|
|
20
|
+
|
|
21
|
+
export declare class ActionsMap extends Map<symbol, FieldActionExecute> {
|
|
22
|
+
register(action: FieldActionBase): void;
|
|
23
|
+
trigger<T extends FieldActionBase>(ActionClass: new (...args: any[]) => T, field: IField, ...params: any[]): any;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export declare interface ActionValue {
|
|
27
|
+
label?: string;
|
|
28
|
+
icon?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* DisplayMode enum provides an enumeration for supported ways of rendering a particular object in the DOM
|
|
33
|
+
*/
|
|
34
|
+
declare enum DisplayMode {
|
|
35
|
+
SUPPRESS = 1,// Field will be entirely suppressed. it will not render (not even to JSON) and will not parse for PUT
|
|
36
|
+
HIDDEN = 5,// Field will render as <input type="hidden"> or <tr data-field_name>
|
|
37
|
+
INVISIBLE = 8,// Field will render completely, but with display: none. Equal to setting its style = {display: none}
|
|
38
|
+
FULL = 10
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare namespace DisplayMode {
|
|
42
|
+
function fromString(mode: string): DisplayMode;
|
|
43
|
+
function fromAny(mode: any): DisplayMode;
|
|
44
|
+
function isDefined(mode: number | string): boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export declare const EmptyField: Field<string>;
|
|
48
|
+
|
|
49
|
+
export declare class EnabledChangedAction extends FieldActionBase {
|
|
50
|
+
constructor(executorFn: (field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean) => Promise<void>);
|
|
51
|
+
get classIdentifier(): symbol;
|
|
52
|
+
execute(field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export declare class EnabledChangingAction extends FieldActionBase {
|
|
56
|
+
constructor(executorFn: (field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean) => Promise<boolean>);
|
|
57
|
+
get classIdentifier(): symbol;
|
|
58
|
+
execute(field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean): Promise<boolean>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export declare class ExecuteAction extends FieldActionBase {
|
|
62
|
+
constructor(executorFn: (field: IField, supr: FieldActionExecute, params: any) => Promise<any>);
|
|
63
|
+
get classIdentifier(): symbol;
|
|
64
|
+
execute(field: IField, supr: FieldActionExecute, params: any): Promise<any>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export declare class Field<T = any> extends FieldBase {
|
|
68
|
+
private _value;
|
|
69
|
+
constructor(params?: Partial<IField<T>>);
|
|
70
|
+
get value(): T;
|
|
71
|
+
set value(newValue: T);
|
|
72
|
+
clone(overrides?: Partial<IField<T>>): Field<T>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export declare abstract class FieldActionBase implements IFieldAction {
|
|
76
|
+
abstract get classIdentifier(): symbol;
|
|
77
|
+
private readonly executorFn;
|
|
78
|
+
constructor(executorFn: ActionExecutor);
|
|
79
|
+
execute(field: IField, supr: IFieldAction['execute'], ...params: any[]): Promise<any>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export declare type FieldActionExecute<T = any> = (field: IField<T>, ...params: any[]) => Promise<any>;
|
|
83
|
+
|
|
84
|
+
declare abstract class FieldBase<T = any> implements IField<T> {
|
|
85
|
+
abstract get value(): T;
|
|
86
|
+
abstract set value(newValue: T);
|
|
87
|
+
abstract clone(overrides?: Partial<IField<T>>): IField<T>;
|
|
88
|
+
originalValue: T;
|
|
89
|
+
valid: boolean;
|
|
90
|
+
errors: ValidationError[];
|
|
91
|
+
parent?: Group;
|
|
92
|
+
fieldName?: string;
|
|
93
|
+
protected actions: ActionsMap;
|
|
94
|
+
private _visibility;
|
|
95
|
+
get visibility(): DisplayMode;
|
|
96
|
+
set visibility(newValue: DisplayMode);
|
|
97
|
+
setVisibility(newValue: DisplayMode): Promise<void>;
|
|
98
|
+
private _enabled;
|
|
99
|
+
get enabled(): boolean;
|
|
100
|
+
set enabled(newValue: boolean);
|
|
101
|
+
setEnabled(newValue: boolean): Promise<void>;
|
|
102
|
+
validate(): void;
|
|
103
|
+
get fullValue(): any;
|
|
104
|
+
get isChanged(): boolean;
|
|
105
|
+
get reactive(): IField;
|
|
106
|
+
registerAction(action: IFieldAction<T>): this;
|
|
107
|
+
triggerAction<T2 extends IFieldAction<T>>(actionClass: new (...args: any[]) => T2, ...params: any[]): any;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export declare type GenericFieldsInterface = Record<string, IField>;
|
|
111
|
+
|
|
112
|
+
export declare class Group<T extends GenericFieldsInterface = GenericFieldsInterface> extends FieldBase {
|
|
113
|
+
private readonly _fields;
|
|
114
|
+
private _value;
|
|
115
|
+
readonly reactiveValue: ComputedRef<Record<string, any> | null>;
|
|
116
|
+
private suppressNotifyValueChanged;
|
|
117
|
+
constructor(fields: T, params?: Partial<IField>);
|
|
118
|
+
get reactive(): this;
|
|
119
|
+
private static isValidFields;
|
|
120
|
+
static createFromFormData(data: Record<string, any> | null): Group;
|
|
121
|
+
field(fieldName: string): IField | null;
|
|
122
|
+
get fields(): T;
|
|
123
|
+
get value(): Record<string, any> | null;
|
|
124
|
+
set value(newValue: Record<string, any> | null);
|
|
125
|
+
get fullValue(): Record<string, any>;
|
|
126
|
+
notifyValueChanged(): void;
|
|
127
|
+
clone(overrides?: Partial<IField>): Group<T>;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export declare interface IField<T = any> {
|
|
131
|
+
value: T;
|
|
132
|
+
fullValue: T;
|
|
133
|
+
originalValue: T;
|
|
134
|
+
valid: boolean;
|
|
135
|
+
errors: ValidationError[];
|
|
136
|
+
enabled: boolean;
|
|
137
|
+
visibility: DisplayMode;
|
|
138
|
+
parent?: any;
|
|
139
|
+
fieldName?: string;
|
|
140
|
+
clone(overrides?: Partial<IField<T>>): IField<T>;
|
|
141
|
+
registerAction(action: IFieldAction<T>): this;
|
|
142
|
+
triggerAction<T2 extends IFieldAction<T>>(actionClass: abstract new (...args: any[]) => T2, ...params: any[]): any;
|
|
143
|
+
validate(): void;
|
|
144
|
+
isChanged: boolean;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export declare interface IFieldAction<T = any> {
|
|
148
|
+
execute(field: IField<T>, supr: FieldActionExecute<T>, ...params: any[]): any;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export declare class List<T extends GenericFieldsInterface = GenericFieldsInterface> extends FieldBase {
|
|
152
|
+
private _value;
|
|
153
|
+
private _itemTemplate?;
|
|
154
|
+
private _previousValue;
|
|
155
|
+
constructor(itemTemplate?: Group<T>, params?: Partial<IField>);
|
|
156
|
+
get reactive(): this;
|
|
157
|
+
private processSetValueItem;
|
|
158
|
+
private setValue;
|
|
159
|
+
get value(): Record<string, any>[] | null;
|
|
160
|
+
set value(newValue: Record<string, any>[]);
|
|
161
|
+
clone(overrides?: Partial<IField>): List<T>;
|
|
162
|
+
notifyValueChanged(): void;
|
|
163
|
+
get(index: number): Group<T> | undefined;
|
|
164
|
+
push(item: any): number;
|
|
165
|
+
pop(): Group<T> | undefined;
|
|
166
|
+
remove(index: number): Group<T> | undefined;
|
|
167
|
+
insert(item: any, index: number): number;
|
|
168
|
+
clear(): void;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export declare class ListItemAddedAction extends FieldActionBase {
|
|
172
|
+
constructor(executorFn: (field: IField, supr: FieldActionExecute, item: any, index: number) => Promise<void>);
|
|
173
|
+
get classIdentifier(): symbol;
|
|
174
|
+
execute(field: IField, supr: FieldActionExecute, item: any, index: number): Promise<void>;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export declare class ListItemRemovedAction extends FieldActionBase {
|
|
178
|
+
constructor(executorFn: (field: IField, supr: FieldActionExecute, item: any, index: number) => Promise<void>);
|
|
179
|
+
get classIdentifier(): symbol;
|
|
180
|
+
execute(field: IField, supr: FieldActionExecute, item: any, index: number): Promise<void>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export declare type NullableAction = Action | null;
|
|
184
|
+
|
|
185
|
+
export declare type NullableField<T = any> = Field<T> | null;
|
|
186
|
+
|
|
187
|
+
export declare type NullableGroup = Group | null;
|
|
188
|
+
|
|
189
|
+
export declare type NullableList = List | null;
|
|
190
|
+
|
|
191
|
+
declare class ValidationError {
|
|
192
|
+
get componentName(): string;
|
|
193
|
+
get componentBindings(): {};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export declare class ValidChangedAction extends FieldActionBase {
|
|
197
|
+
constructor(executorFn: (field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean) => Promise<void>);
|
|
198
|
+
get classIdentifier(): symbol;
|
|
199
|
+
execute(field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean): Promise<void>;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export declare class ValueChangedAction<T = any> extends FieldActionBase {
|
|
203
|
+
constructor(executorFn: (field: IField<T>, supr: FieldActionExecute<T>, newValue: T, oldValue: T) => Promise<void>);
|
|
204
|
+
get classIdentifier(): symbol;
|
|
205
|
+
execute(field: IField<T>, supr: FieldActionExecute<T>, newValue: T, oldValue: T): Promise<void>;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export declare class VisibilityChangedAction extends FieldActionBase {
|
|
209
|
+
constructor(executorFn: (field: IField, supr: FieldActionExecute, newValue: DisplayMode, oldValue: DisplayMode) => Promise<void>);
|
|
210
|
+
get classIdentifier(): symbol;
|
|
211
|
+
execute(field: IField, supr: FieldActionExecute, newValue: DisplayMode, oldValue: DisplayMode): Promise<void>;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export declare class VisibilityChangingAction extends FieldActionBase {
|
|
215
|
+
constructor(executorFn: (field: IField, supr: FieldActionExecute, newValue: DisplayMode, oldValue: DisplayMode) => Promise<DisplayMode>);
|
|
216
|
+
get classIdentifier(): symbol;
|
|
217
|
+
execute(field: IField, supr: FieldActionExecute, newValue: DisplayMode, oldValue: DisplayMode): Promise<DisplayMode>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export { }
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dynamicforms/vue-forms",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Data entry forms for vue - logic (no controls here)",
|
|
7
|
+
"author": "Jure Erznožnik",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/*"
|
|
10
|
+
],
|
|
11
|
+
"main": "dist/dynamicforms-vue-forms.umd.cjs",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"require": "./dist/dynamicforms-vue-forms.umd.cjs",
|
|
16
|
+
"import": "./dist/dynamicforms-vue-forms.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"workspaces": [
|
|
20
|
+
"docs"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "vite build",
|
|
24
|
+
"test": "vitest run --coverage",
|
|
25
|
+
"lint": "eslint src && vue-tsc --noEmit",
|
|
26
|
+
"docs:dev": "npm run docs:dev -w docs",
|
|
27
|
+
"docs:build": "npm run docs:build -w docs",
|
|
28
|
+
"docs:preview": "npm run docs:preview -w docs"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"vue",
|
|
32
|
+
"dynamicforms",
|
|
33
|
+
"velis",
|
|
34
|
+
"forms",
|
|
35
|
+
"data entry"
|
|
36
|
+
],
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git@github.com:velis74/dynamicforms-vue-forms.git"
|
|
41
|
+
},
|
|
42
|
+
"issues": "https://github.com/velis74/dynamicforms-vue-forms/issues",
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"lodash": "^4.17.16",
|
|
45
|
+
"vue": "^3.4"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/lodash": "^4.17.16",
|
|
49
|
+
"@vitejs/plugin-vue": "^5",
|
|
50
|
+
"@vitest/coverage-v8": "^3",
|
|
51
|
+
"@vue/test-utils": "^2.2.4",
|
|
52
|
+
"@vue/tsconfig": "^0.7.0",
|
|
53
|
+
"eslint-config-velis": "^1.1.16",
|
|
54
|
+
"jsdom": "^26.0.0",
|
|
55
|
+
"typescript": "^5",
|
|
56
|
+
"vite": "^5",
|
|
57
|
+
"vite-plugin-dts": "^4",
|
|
58
|
+
"vite-plugin-eslint": "^1.8.1",
|
|
59
|
+
"vitest": "^3",
|
|
60
|
+
"vue-tsc": "^2"
|
|
61
|
+
},
|
|
62
|
+
"eslintConfig": {
|
|
63
|
+
"extends": [
|
|
64
|
+
"velis"
|
|
65
|
+
],
|
|
66
|
+
"ignorePatterns": [
|
|
67
|
+
"dist/*",
|
|
68
|
+
"coverage/*",
|
|
69
|
+
"node_modules/*",
|
|
70
|
+
"docs/*",
|
|
71
|
+
"vite.config.ts"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# @dynamicforms/vue-forms
|
|
2
|
+
|
|
3
|
+
A lightweight, reactive data entry forms library for Vue.js that handles form state management without dictating your
|
|
4
|
+
UI components.
|
|
5
|
+
|
|
6
|
+
## Introduction
|
|
7
|
+
|
|
8
|
+
`@dynamicforms/vue-forms` provides a powerful yet simple way to manage form data, validation, and state in Vue
|
|
9
|
+
applications. The library focuses on the logic layer of forms, giving you complete freedom to use any UI components
|
|
10
|
+
you prefer.
|
|
11
|
+
|
|
12
|
+
Unlike other form libraries that couple data management with specific UI components, `@dynamicforms/vue-forms`
|
|
13
|
+
separates these concerns, allowing you to build forms that match your design system perfectly.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **UI-agnostic**: Works with any Vue UI components or your custom ones
|
|
18
|
+
- **Reactive**: Built on Vue's reactivity system for seamless integration
|
|
19
|
+
- **Nested structures**: Support for complex data with nested fields and groups
|
|
20
|
+
- **Event system**: Rich event handling for field changes, validation, and more
|
|
21
|
+
- **TypeScript support**: Full type definitions for excellent developer experience
|
|
22
|
+
- **Lightweight**: No dependencies besides Vue and lodash
|
|
23
|
+
- **Field types**: Core field types (Field, Action, Group, List) to represent any data structure
|
|
24
|
+
- **Validation**: Simple validation system with extensible error handling
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @dynamicforms/vue-forms
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Basic Usage Example
|
|
33
|
+
|
|
34
|
+
Here's a simple example of how to create and use a form with fields and groups:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { reactive } from 'vue';
|
|
38
|
+
import { Field, Group, ValueChangedAction } from '@dynamicforms/vue-forms';
|
|
39
|
+
|
|
40
|
+
// Create a form with fields
|
|
41
|
+
const personForm = new Group({
|
|
42
|
+
firstName: new Field({ value: 'John' }),
|
|
43
|
+
lastName: new Field({ value: 'Doe' }),
|
|
44
|
+
age: new Field({ value: 30 }),
|
|
45
|
+
active: new Field({ value: true })
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Access values
|
|
49
|
+
console.log(personForm.value); // { firstName: 'John', lastName: 'Doe', age: 30, active: true }
|
|
50
|
+
|
|
51
|
+
// Update a field
|
|
52
|
+
personForm.fields.firstName.value = 'Jane';
|
|
53
|
+
|
|
54
|
+
// Disable a field
|
|
55
|
+
personForm.fields.age.enabled = false;
|
|
56
|
+
|
|
57
|
+
// Form serializes only enabled fields
|
|
58
|
+
console.log(personForm.value); // { firstName: 'Jane', lastName: 'Doe', active: true }
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Events Example
|
|
62
|
+
|
|
63
|
+
The library provides a powerful event system for field changes and other actions:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { Field, Group, ValueChangedAction, ValidationErrorText } from '@dynamicforms/vue-forms';
|
|
67
|
+
|
|
68
|
+
const emailField = new Field({ value: '' })
|
|
69
|
+
.registerAction(new ValueChangedAction(async (field, supr, newValue, oldValue) => {
|
|
70
|
+
// Custom validation on value change
|
|
71
|
+
if (!newValue.includes('@')) {
|
|
72
|
+
field.errors = [new ValidationErrorText('Invalid email format')];
|
|
73
|
+
} else {
|
|
74
|
+
field.errors = [];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Always call supr to continue the action chain
|
|
78
|
+
return supr(field, newValue, oldValue);
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
// Or register events on a form
|
|
82
|
+
const form = new Group({
|
|
83
|
+
email: emailField,
|
|
84
|
+
username: new Field()
|
|
85
|
+
}).registerAction(new ValueChangedAction(async (field, supr, newValue, oldValue) => {
|
|
86
|
+
console.log('Form data changed:', newValue);
|
|
87
|
+
return supr(field, newValue, oldValue);
|
|
88
|
+
}));
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## TypeScript Support
|
|
92
|
+
|
|
93
|
+
The library is written in TypeScript and provides full type definitions:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { Field, Group, IField } from '@dynamicforms/vue-forms';
|
|
97
|
+
|
|
98
|
+
// Define your form structure with types
|
|
99
|
+
interface UserFormData {
|
|
100
|
+
username: Field;
|
|
101
|
+
email: Field;
|
|
102
|
+
preferences: Group<{
|
|
103
|
+
darkMode: Field;
|
|
104
|
+
notifications: Field;
|
|
105
|
+
}>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Create the form with type checking
|
|
109
|
+
const userForm = new Group<UserFormData>({
|
|
110
|
+
username: new Field({ value: '' }),
|
|
111
|
+
email: new Field({ value: '' }),
|
|
112
|
+
preferences: new Group({
|
|
113
|
+
darkMode: new Field({ value: true }),
|
|
114
|
+
notifications: new Field({ value: true })
|
|
115
|
+
})
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// TypeScript knows the structure
|
|
119
|
+
const darkMode: boolean = userForm.fields.preferences.fields.darkMode.value;
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Conclusion
|
|
123
|
+
|
|
124
|
+
`@dynamicforms/vue-forms` provides a clean, flexible approach to form management in Vue applications. By focusing on
|
|
125
|
+
data structures and state management rather than UI components, it offers unparalleled flexibility while maintaining
|
|
126
|
+
a simple, intuitive API.
|
|
127
|
+
|
|
128
|
+
For more detailed documentation and examples, check out the [source code](https://github.com/velis74/dynamicforms-vue-forms) or reach out to the author
|
|
129
|
+
for assistance.
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
MIT
|