@myparcel-dev/vue-form-builder 1.0.0-beta.44 → 1.0.0-beta.44-pdk-compatible
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +99 -97
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type { AnyElementConfiguration, AnyElementInstance, ComponentOrHtmlElement, ComponentProps, CreatedElement, CreatedField, CreatedForm, ElementName, FormConfiguration, FormInstance, InteractiveElementConfiguration, InteractiveElementInstance, ModularCreatedElement, ModularCreatedField, PlainElementConfiguration, PlainElementInstance, ResolvedElementConfiguration, Validator, } from '@myparcel-vfb/core';
|
|
2
2
|
export type { SelectOption } from '@myparcel-vfb/utils';
|
|
3
3
|
export { FormHook, MagicForm, createField, createForm, defineField, defineForm, useElement, useForm, useFormBuilder, } from '@myparcel-vfb/core';
|
|
4
|
+
import { MagicForm as __MagicForm } from '@myparcel-vfb/core';
|
|
5
|
+
export default __MagicForm;
|
|
4
6
|
export { MyParcelFormBuilderPlugin, createMyParcelFormBuilderPlugin } from '@myparcel-vfb/plugin';
|
package/dist/index.js
CHANGED
|
@@ -2,18 +2,18 @@ var le = Object.defineProperty;
|
|
|
2
2
|
var ue = (s, t, e) => t in s ? le(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
3
|
var n = (s, t, e) => (ue(s, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
4
|
import * as he from "vue";
|
|
5
|
-
import { inject as
|
|
6
|
-
import { isOfType as p, asyncEvery as
|
|
7
|
-
import { useMemoize as
|
|
8
|
-
const
|
|
5
|
+
import { inject as j, defineComponent as E, toRefs as K, computed as b, unref as v, openBlock as m, createBlock as w, resolveDynamicComponent as T, mergeProps as q, createSlots as fe, renderList as _, withCtx as g, renderSlot as F, normalizeProps as de, guardReactiveProps as ce, provide as J, h as k, Teleport as me, reactive as $, markRaw as D, ref as f, onMounted as Y, onUnmounted as pe, defineAsyncComponent as be, toValue as o, createElementBlock as A, Fragment as S, Suspense as Q, createCommentVNode as W, withModifiers as U, createVNode as ve, watchEffect as we, watch as H } from "vue";
|
|
6
|
+
import { isOfType as p, asyncEvery as Ee } from "@myparcel/ts-utils";
|
|
7
|
+
import { useMemoize as ge, isDefined as ye } from "@vueuse/core";
|
|
8
|
+
const ke = (s) => p(s, "then") ? s : Promise.resolve(s), L = (s) => s.charAt(0).toUpperCase() + s.slice(1), Ve = (s, t) => {
|
|
9
9
|
const e = [t];
|
|
10
10
|
if (t.startsWith("before")) {
|
|
11
11
|
const r = t.replace(/^before/, "").toLowerCase();
|
|
12
|
-
e.push(r), e.push(`after${
|
|
12
|
+
e.push(r), e.push(`after${L(r)}`);
|
|
13
13
|
}
|
|
14
14
|
if (t.startsWith("after")) {
|
|
15
15
|
const r = t.replace(/^after/, "").toLowerCase();
|
|
16
|
-
e.push(r), e.push(`before${
|
|
16
|
+
e.push(r), e.push(`before${L(r)}`);
|
|
17
17
|
}
|
|
18
18
|
return e.some((r) => s.includes(r));
|
|
19
19
|
};
|
|
@@ -55,7 +55,7 @@ class X {
|
|
|
55
55
|
return t.callback.toString() === e.toString();
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
const Z = (s) => new X(s),
|
|
58
|
+
const Z = (s) => new X(s), Fe = () => ({
|
|
59
59
|
field: {
|
|
60
60
|
elementProp: !0
|
|
61
61
|
},
|
|
@@ -80,7 +80,7 @@ const ee = Object.freeze(Object.values(c)), x = [
|
|
|
80
80
|
"onMounted",
|
|
81
81
|
"onUnmounted",
|
|
82
82
|
"onUpdated"
|
|
83
|
-
], te = ["blur", "click", "focus", ...x],
|
|
83
|
+
], te = ["blur", "click", "focus", ...x], De = [
|
|
84
84
|
"blur",
|
|
85
85
|
"focus",
|
|
86
86
|
"sanitize",
|
|
@@ -98,26 +98,26 @@ const ee = Object.freeze(Object.values(c)), x = [
|
|
|
98
98
|
});
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
}),
|
|
101
|
+
}), Oe = (s) => {
|
|
102
102
|
se().register(s.hooks, s);
|
|
103
103
|
}, re = Symbol("form"), ie = Symbol("element"), Je = () => {
|
|
104
|
-
const s =
|
|
104
|
+
const s = j(ie);
|
|
105
105
|
if (!s)
|
|
106
106
|
throw new Error("No element found.");
|
|
107
107
|
return s;
|
|
108
|
-
},
|
|
109
|
-
const s =
|
|
108
|
+
}, C = () => {
|
|
109
|
+
const s = j(re);
|
|
110
110
|
if (!s)
|
|
111
111
|
throw new Error("No form found.");
|
|
112
112
|
return s;
|
|
113
|
-
},
|
|
113
|
+
}, Be = /* @__PURE__ */ E({
|
|
114
114
|
__name: "FormElement",
|
|
115
115
|
props: {
|
|
116
116
|
element: {}
|
|
117
117
|
},
|
|
118
118
|
setup(s) {
|
|
119
|
-
const t = s, e =
|
|
120
|
-
|
|
119
|
+
const t = s, e = K(t);
|
|
120
|
+
Oe(e.element.value);
|
|
121
121
|
const r = b(() => {
|
|
122
122
|
var h, l;
|
|
123
123
|
const a = (l = (h = t.element.form) == null ? void 0 : h.config.field) == null ? void 0 : l.elementProp, u = {
|
|
@@ -132,25 +132,25 @@ const ee = Object.freeze(Object.values(c)), x = [
|
|
|
132
132
|
t.element.ref = a;
|
|
133
133
|
}
|
|
134
134
|
});
|
|
135
|
-
return (a, u) => (m(), w(T(a.element.component),
|
|
135
|
+
return (a, u) => (m(), w(T(a.element.component), q({
|
|
136
136
|
modelValue: i.value,
|
|
137
137
|
"onUpdate:modelValue": u[0] || (u[0] = (h) => i.value = h)
|
|
138
138
|
}, r.value), fe({ _: 2 }, [
|
|
139
|
-
|
|
139
|
+
_(Object.keys(a.$slots), (h) => ({
|
|
140
140
|
name: h,
|
|
141
|
-
fn:
|
|
142
|
-
|
|
141
|
+
fn: g((l) => [
|
|
142
|
+
F(a.$slots, h, de(ce(l || {})))
|
|
143
143
|
])
|
|
144
144
|
}))
|
|
145
145
|
]), 1040, ["modelValue"]));
|
|
146
146
|
}
|
|
147
|
-
}),
|
|
147
|
+
}), Re = (s) => {
|
|
148
148
|
const t = [];
|
|
149
149
|
let e = {};
|
|
150
150
|
return p(s, "children") && (Array.isArray(s.children) ? s.children.forEach((r) => {
|
|
151
151
|
t.push(typeof r == "function" ? r : () => r);
|
|
152
152
|
}) : p(s, "children") ? e = s.children : t.push(s.children)), { ...t, ...e };
|
|
153
|
-
}, N =
|
|
153
|
+
}, N = E({
|
|
154
154
|
name: "FormElementWrapper",
|
|
155
155
|
props: {
|
|
156
156
|
form: {
|
|
@@ -167,12 +167,12 @@ const ee = Object.freeze(Object.values(c)), x = [
|
|
|
167
167
|
},
|
|
168
168
|
render() {
|
|
169
169
|
var i, a, u;
|
|
170
|
-
const s =
|
|
171
|
-
let t =
|
|
172
|
-
|
|
170
|
+
const s = Re(this.element.component);
|
|
171
|
+
let t = k(
|
|
172
|
+
Be,
|
|
173
173
|
{
|
|
174
174
|
...this.$attrs,
|
|
175
|
-
...
|
|
175
|
+
...Le(this.element),
|
|
176
176
|
element: this.element
|
|
177
177
|
},
|
|
178
178
|
{
|
|
@@ -184,7 +184,7 @@ const ee = Object.freeze(Object.values(c)), x = [
|
|
|
184
184
|
const e = typeof this.element.wrapper != "boolean";
|
|
185
185
|
if (this.element.wrapper === !0 && ((i = this.form.config.field) == null ? void 0 : i.wrapper) || e) {
|
|
186
186
|
const h = t;
|
|
187
|
-
t =
|
|
187
|
+
t = k(
|
|
188
188
|
e ? this.element.wrapper : (a = this.form.config.field) == null ? void 0 : a.wrapper,
|
|
189
189
|
{
|
|
190
190
|
...this.$attrs,
|
|
@@ -194,11 +194,11 @@ const ee = Object.freeze(Object.values(c)), x = [
|
|
|
194
194
|
{ ...this.element.slots, default: () => h }
|
|
195
195
|
);
|
|
196
196
|
}
|
|
197
|
-
return this.element.teleportSelector ?
|
|
197
|
+
return this.element.teleportSelector ? k(me, { to: this.element.teleportSelector }, [t]) : t;
|
|
198
198
|
}
|
|
199
|
-
}),
|
|
199
|
+
}), $e = (s) => E({
|
|
200
200
|
setup() {
|
|
201
|
-
const t =
|
|
201
|
+
const t = C(), e = f();
|
|
202
202
|
return Y(async () => {
|
|
203
203
|
e.value = await t.addElement(s);
|
|
204
204
|
}), pe(() => {
|
|
@@ -209,47 +209,47 @@ const ee = Object.freeze(Object.values(c)), x = [
|
|
|
209
209
|
};
|
|
210
210
|
},
|
|
211
211
|
render() {
|
|
212
|
-
return this.element &&
|
|
212
|
+
return this.element && k(N, { ...this.$attrs, form: this.form, element: this.element }, this.$slots);
|
|
213
213
|
}
|
|
214
|
-
}),
|
|
214
|
+
}), Ce = (s) => E({
|
|
215
215
|
setup() {
|
|
216
|
-
const t =
|
|
216
|
+
const t = C();
|
|
217
217
|
return { element: b(() => s.name && t.getField(s.name)) };
|
|
218
218
|
},
|
|
219
219
|
render() {
|
|
220
|
-
return this.element &&
|
|
220
|
+
return this.element && k("label", { for: this.element.attributes.id ?? this.element.name }, [this.element.label]);
|
|
221
221
|
}
|
|
222
|
-
}),
|
|
222
|
+
}), Me = (s) => E({
|
|
223
223
|
setup() {
|
|
224
|
-
const t =
|
|
224
|
+
const t = C();
|
|
225
225
|
return { element: b(() => s.name ? t.getField(s.name) : void 0) };
|
|
226
226
|
},
|
|
227
227
|
render() {
|
|
228
228
|
var t, e, r;
|
|
229
229
|
return o((t = this.element) == null ? void 0 : t.errors) && ((r = (e = this.$slots).default) == null ? void 0 : r.call(e, { errors: o(this.element.errors) }));
|
|
230
230
|
}
|
|
231
|
-
}),
|
|
231
|
+
}), z = (s) => D(be(() => Promise.resolve(s()))), Ye = (s) => $({
|
|
232
232
|
field: s,
|
|
233
|
-
Component:
|
|
233
|
+
Component: D($e(s)),
|
|
234
234
|
...p(s, "ref") && {
|
|
235
235
|
ref: s.ref ?? f(),
|
|
236
|
-
Label:
|
|
237
|
-
Errors:
|
|
236
|
+
Label: z(() => Ce(s)),
|
|
237
|
+
Errors: z(() => Me(s))
|
|
238
238
|
}
|
|
239
|
-
}), Ae = /* @__PURE__ */
|
|
239
|
+
}), Ae = /* @__PURE__ */ E({
|
|
240
240
|
__name: "RenderedFormContent",
|
|
241
241
|
setup(s) {
|
|
242
|
-
const t = f(!1), e =
|
|
242
|
+
const t = f(!1), e = C();
|
|
243
243
|
if (!e)
|
|
244
244
|
throw new Error("Form not found");
|
|
245
245
|
const r = b(() => o(e.fields).filter((a) => !a.teleportSelector)), i = b(() => o(e.fields).filter((a) => !!a.teleportSelector));
|
|
246
|
-
return (a, u) => (m(), A(
|
|
246
|
+
return (a, u) => (m(), A(S, null, [
|
|
247
247
|
v(e) ? (m(), w(Q, {
|
|
248
248
|
key: 0,
|
|
249
249
|
onResolve: u[0] || (u[0] = (h) => t.value = !0)
|
|
250
250
|
}, {
|
|
251
|
-
default:
|
|
252
|
-
(m(!0), A(
|
|
251
|
+
default: g(() => [
|
|
252
|
+
(m(!0), A(S, null, _(r.value, (h, l) => (m(), w(v(N), {
|
|
253
253
|
key: `element--${h.name ?? "unnamed"}--${l}`,
|
|
254
254
|
element: h,
|
|
255
255
|
form: v(e)
|
|
@@ -257,14 +257,14 @@ const ee = Object.freeze(Object.values(c)), x = [
|
|
|
257
257
|
]),
|
|
258
258
|
_: 1
|
|
259
259
|
})) : W("", !0),
|
|
260
|
-
v(e) && t.value ? (m(!0), A(
|
|
260
|
+
v(e) && t.value ? (m(!0), A(S, { key: 1 }, _(i.value, (h, l) => (m(), w(v(N), {
|
|
261
261
|
key: `element--${h.name ?? "unnamed"}--${l}`,
|
|
262
262
|
element: h,
|
|
263
263
|
form: v(e)
|
|
264
264
|
}, null, 8, ["element", "form"]))), 128)) : W("", !0)
|
|
265
265
|
], 64));
|
|
266
266
|
}
|
|
267
|
-
}),
|
|
267
|
+
}), Se = E({
|
|
268
268
|
name: "Fragment",
|
|
269
269
|
props: {
|
|
270
270
|
component: {
|
|
@@ -278,21 +278,21 @@ const ee = Object.freeze(Object.values(c)), x = [
|
|
|
278
278
|
e[r] = i;
|
|
279
279
|
return e;
|
|
280
280
|
};
|
|
281
|
-
function
|
|
281
|
+
function _e(s, t, e, r, i, a) {
|
|
282
282
|
return s.component ? (m(), w(T(s.component), { key: 0 }, {
|
|
283
|
-
default:
|
|
284
|
-
|
|
283
|
+
default: g(() => [
|
|
284
|
+
F(s.$slots, "default")
|
|
285
285
|
]),
|
|
286
286
|
_: 3
|
|
287
|
-
})) :
|
|
287
|
+
})) : F(s.$slots, "default", { key: 1 });
|
|
288
288
|
}
|
|
289
|
-
const He = /* @__PURE__ */ Pe(
|
|
289
|
+
const He = /* @__PURE__ */ Pe(Se, [["render", _e]]), xe = /* @__PURE__ */ E({
|
|
290
290
|
__name: "MagicForm",
|
|
291
291
|
props: {
|
|
292
292
|
form: {}
|
|
293
293
|
},
|
|
294
294
|
setup(s, { emit: t }) {
|
|
295
|
-
const e = f(null), r = s, i = t, u =
|
|
295
|
+
const e = f(null), r = s, i = t, u = K(r).form.value;
|
|
296
296
|
return Y(() => {
|
|
297
297
|
const l = o(e);
|
|
298
298
|
l && (r.form.element = l);
|
|
@@ -300,25 +300,25 @@ const He = /* @__PURE__ */ Pe(_e, [["render", Be]]), xe = /* @__PURE__ */ y({
|
|
|
300
300
|
r.form.on(l, (d) => {
|
|
301
301
|
i(l, d);
|
|
302
302
|
});
|
|
303
|
-
}), se().register(u.hooks, u), (l, d) => (m(), w(T(l.form.config.form.tag),
|
|
303
|
+
}), se().register(u.hooks, u), (l, d) => (m(), w(T(l.form.config.form.tag), q({
|
|
304
304
|
id: l.form.name,
|
|
305
305
|
ref_key: "formElement",
|
|
306
306
|
ref: e
|
|
307
307
|
}, l.form.config.form.attributes, {
|
|
308
|
-
onSubmit: d[0] || (d[0] =
|
|
309
|
-
onReset: d[1] || (d[1] =
|
|
308
|
+
onSubmit: d[0] || (d[0] = U(() => l.form.submit(), ["prevent"])),
|
|
309
|
+
onReset: d[1] || (d[1] = U(() => l.form.reset(), ["prevent"]))
|
|
310
310
|
}), {
|
|
311
|
-
default:
|
|
311
|
+
default: g(() => [
|
|
312
312
|
ve(He, {
|
|
313
313
|
component: l.form.config.form.wrapper
|
|
314
314
|
}, {
|
|
315
|
-
default:
|
|
315
|
+
default: g(() => [
|
|
316
316
|
l.$slots.default ? (m(), w(Q, { key: 0 }, {
|
|
317
|
-
default:
|
|
318
|
-
|
|
317
|
+
default: g(() => [
|
|
318
|
+
F(l.$slots, "default")
|
|
319
319
|
]),
|
|
320
|
-
fallback:
|
|
321
|
-
|
|
320
|
+
fallback: g(() => [
|
|
321
|
+
F(l.$slots, "loader")
|
|
322
322
|
]),
|
|
323
323
|
_: 3
|
|
324
324
|
})) : (m(), w(Ae, { key: 1 }))
|
|
@@ -332,17 +332,17 @@ const He = /* @__PURE__ */ Pe(_e, [["render", Be]]), xe = /* @__PURE__ */ y({
|
|
|
332
332
|
}), Ne = (s, t) => ne().register(s, t), Qe = (s, t) => {
|
|
333
333
|
const e = Ne(s, t);
|
|
334
334
|
return {
|
|
335
|
-
Component:
|
|
335
|
+
Component: D((r, i) => k(xe, { ...i.attrs, form: e }, i.slots)),
|
|
336
336
|
instance: e
|
|
337
337
|
};
|
|
338
|
-
}, Xe = (s) => s,
|
|
338
|
+
}, Xe = (s) => s, y = (s) => {
|
|
339
339
|
if (typeof s == "string" || typeof s == "boolean")
|
|
340
340
|
return s;
|
|
341
341
|
if (s)
|
|
342
|
-
return
|
|
343
|
-
},
|
|
342
|
+
return D(s);
|
|
343
|
+
}, R = (s, t) => {
|
|
344
344
|
s && we(() => {
|
|
345
|
-
|
|
345
|
+
ke(s()).then((e) => {
|
|
346
346
|
t.value = e;
|
|
347
347
|
});
|
|
348
348
|
});
|
|
@@ -366,11 +366,11 @@ class oe {
|
|
|
366
366
|
const r = this.hooks.getAvailableHooks();
|
|
367
367
|
if (Object.keys(e).filter((i) => !r.includes(i)).forEach((i) => {
|
|
368
368
|
this[i] = e[i];
|
|
369
|
-
}), this.props =
|
|
369
|
+
}), this.props = $(e.props ?? {}), this.attributes = $(e.attributes ?? {}), this.config = e, this.form = t, this.name = e.name, this.wrapper = e.wrapper ?? !0, this.setVisible(e.visible ?? !0), this.formattedErrors = b(() => o(this.errors).map((i) => typeof i == "function" ? i() : i)), "visibleWhen" in e && R(() => this.config.visibleWhen(this), this.isVisible), typeof e.component == "string") {
|
|
370
370
|
this.component = e.component;
|
|
371
371
|
return;
|
|
372
372
|
}
|
|
373
|
-
this.component =
|
|
373
|
+
this.component = D(e.component);
|
|
374
374
|
}
|
|
375
375
|
setVisible(t) {
|
|
376
376
|
this.isVisible.value = t;
|
|
@@ -387,7 +387,7 @@ class Ie extends oe {
|
|
|
387
387
|
// eslint-disable-next-line max-lines-per-function
|
|
388
388
|
constructor(e, r) {
|
|
389
389
|
var i, a, u;
|
|
390
|
-
super(e, { ...r, hookNames:
|
|
390
|
+
super(e, { ...r, hookNames: De });
|
|
391
391
|
n(this, "errorsTarget");
|
|
392
392
|
n(this, "isDirty", f(!1));
|
|
393
393
|
n(this, "isDisabled", f(!1));
|
|
@@ -419,22 +419,22 @@ class Ie extends oe {
|
|
|
419
419
|
const d = await l.validate(this, o(this.ref));
|
|
420
420
|
if (!d && l.errorMessage)
|
|
421
421
|
if (this.errorsTarget) {
|
|
422
|
-
const
|
|
422
|
+
const M = o(this.form.fields).find(
|
|
423
423
|
(ae) => ae.name === this.errorsTarget
|
|
424
424
|
);
|
|
425
|
-
(I = o(
|
|
425
|
+
(I = o(M == null ? void 0 : M.errors)) == null || I.push(l.errorMessage);
|
|
426
426
|
} else
|
|
427
427
|
o(this.errors).push(l.errorMessage);
|
|
428
428
|
return d;
|
|
429
429
|
}, r = o(this.validators).filter((l) => !l.precedence), i = o(this.validators).filter((l) => p(l, "precedence")).sort((l, d) => (l.precedence ?? 0) - (d.precedence ?? 0));
|
|
430
430
|
o(this.isOptional) || r.push(Te(((h = this.form.config.validationMessages) == null ? void 0 : h.required) ?? ""));
|
|
431
|
-
const a = (await Promise.all(r.map(e))).every(Boolean), u = await
|
|
431
|
+
const a = (await Promise.all(r.map(e))).every(Boolean), u = await Ee(i, e);
|
|
432
432
|
return this.isValid.value = a && u, await this.hooks.execute("afterValidate", this, o(this.ref), o(this.isValid)), o(this.isValid);
|
|
433
433
|
});
|
|
434
434
|
this.ref = r.ref, (i = e.config.initialValues) != null && i.hasOwnProperty(r.name) && (this.ref.value = e.config.initialValues[r.name]), this.initialValue = o(this.ref), this.lazy = r.lazy ?? !1, this.errorsTarget = r.errorsTarget, this.label = r.label ? ((u = (a = e.config).renderLabel) == null ? void 0 : u.call(a, r.label)) ?? r.label : void 0, this.isDisabled.value = r.disabled ?? !1, this.isOptional.value = r.optional ?? !1, this.isReadOnly.value = r.readOnly ?? !1, this.createValidators(r), H(this.ref, async (h, l) => {
|
|
435
435
|
await this.hooks.execute("beforeUpdate", this, h, l), this.isDirty.value = !0, await this.hooks.execute("afterUpdate", this, h, l);
|
|
436
436
|
}), H(e.stable, (h) => {
|
|
437
|
-
h && (r.disabledWhen &&
|
|
437
|
+
h && (r.disabledWhen && R(() => r.disabledWhen(this), this.isDisabled), r.optionalWhen && R(() => r.optionalWhen(this), this.isOptional), r.readOnlyWhen && R(() => r.readOnlyWhen(this), this.isReadOnly));
|
|
438
438
|
});
|
|
439
439
|
}
|
|
440
440
|
setDisabled(e) {
|
|
@@ -470,12 +470,13 @@ class We {
|
|
|
470
470
|
n(this, "on");
|
|
471
471
|
n(this, "stable", f(!1));
|
|
472
472
|
n(this, "values");
|
|
473
|
-
n(this, "getFieldMemoized",
|
|
473
|
+
n(this, "getFieldMemoized", ge((t) => o(this.fields).find((r) => r.name === t) ?? null));
|
|
474
474
|
const { fields: r, ...i } = e;
|
|
475
|
-
e.hookNames = [...ee, ...e.hookNames ?? []], this.hooks = Z(e), this.on = this.hooks.register.bind(this.hooks), this.off = this.hooks.unregister.bind(this.hooks), this.name = t, this.config = i, this.values =
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
475
|
+
e.hookNames = [...ee, ...e.hookNames ?? []], this.hooks = Z(e), this.on = this.hooks.register.bind(this.hooks), this.off = this.hooks.unregister.bind(this.hooks), this.name = t, this.config = i, this.values = $({}), y(this.config.field.wrapper), y(this.config.fieldDefaults.wrapper), r.forEach((a, u) => {
|
|
476
|
+
;
|
|
477
|
+
const h = this.createFieldInstance(a, this);
|
|
478
|
+
o(this.fields).push(h), .length, "items");
|
|
479
|
+
}), ), this.interactiveFields = b(() => o(this.fields).filter((a) => p(a, "ref"))), this.isDirty = b(() => o(this.interactiveFields).some((a) => o(a.isDirty))), this.stable.value = !0;
|
|
479
480
|
}
|
|
480
481
|
async addElement(t, e, r = "after") {
|
|
481
482
|
await this.hooks.execute(c.BeforeAddElement, this, t);
|
|
@@ -537,7 +538,7 @@ class We {
|
|
|
537
538
|
...t.attributes
|
|
538
539
|
}
|
|
539
540
|
};
|
|
540
|
-
if (
|
|
541
|
+
if (y(r.component), y(r.wrapper), !p(r, "ref")) {
|
|
541
542
|
const u = new oe(e, r);
|
|
542
543
|
return this.registerElement(r.name, u);
|
|
543
544
|
}
|
|
@@ -547,31 +548,31 @@ class We {
|
|
|
547
548
|
}), o(i.isDisabled) || (this.values[r.name] = v(i.ref)), this.registerElement(r.name, i);
|
|
548
549
|
}
|
|
549
550
|
registerElement(t, e) {
|
|
550
|
-
return
|
|
551
|
+
return ye(t) && (this.model[t] = e, this.getFieldMemoized.delete(t)), e;
|
|
551
552
|
}
|
|
552
553
|
}
|
|
553
|
-
let
|
|
554
|
-
const
|
|
555
|
-
hookNames: [
|
|
554
|
+
let O, V, B;
|
|
555
|
+
const Ue = "register", ne = () => (O ?? (O = f({})), V ?? (V = f(Fe())), B ?? (B = new X({
|
|
556
|
+
hookNames: [Ue]
|
|
556
557
|
})), {
|
|
557
|
-
forms:
|
|
558
|
+
forms: O,
|
|
558
559
|
defaults: V,
|
|
559
560
|
on(s, t) {
|
|
560
|
-
|
|
561
|
+
B.register(s, t);
|
|
561
562
|
},
|
|
562
563
|
getForm(s) {
|
|
563
|
-
return o(
|
|
564
|
+
return o(O)[s];
|
|
564
565
|
},
|
|
565
566
|
// @ts-expect-error todo
|
|
566
567
|
register(s, t) {
|
|
567
|
-
|
|
568
|
-
const e = new We(s,
|
|
569
|
-
return o(
|
|
568
|
+
B.execute("beforeRegister");
|
|
569
|
+
const e = new We(s, G(o(V), t));
|
|
570
|
+
return o(O)[s] = e, B.execute("afterRegister", e), e;
|
|
570
571
|
},
|
|
571
572
|
setDefaults(s) {
|
|
572
|
-
V.value =
|
|
573
|
+
V.value = G(o(V), s);
|
|
573
574
|
}
|
|
574
|
-
}),
|
|
575
|
+
}), G = (s, t) => {
|
|
575
576
|
var e, r, i, a, u, h;
|
|
576
577
|
return {
|
|
577
578
|
...s,
|
|
@@ -580,7 +581,7 @@ const Le = "register", ne = () => (D ?? (D = f({})), V ?? (V = f(Oe())), R ?? (R
|
|
|
580
581
|
form: {
|
|
581
582
|
...s.form,
|
|
582
583
|
...t.form,
|
|
583
|
-
wrapper:
|
|
584
|
+
wrapper: y(((e = t.form) == null ? void 0 : e.wrapper) ?? ((r = s.form) == null ? void 0 : r.wrapper)),
|
|
584
585
|
attributes: {
|
|
585
586
|
...s.form.attributes,
|
|
586
587
|
...(i = t.form) == null ? void 0 : i.attributes
|
|
@@ -589,31 +590,32 @@ const Le = "register", ne = () => (D ?? (D = f({})), V ?? (V = f(Oe())), R ?? (R
|
|
|
589
590
|
fieldDefaults: {
|
|
590
591
|
...s.fieldDefaults,
|
|
591
592
|
...t.fieldDefaults,
|
|
592
|
-
wrapper:
|
|
593
|
+
wrapper: y(((a = t.fieldDefaults) == null ? void 0 : a.wrapper) ?? ((u = s.fieldDefaults) == null ? void 0 : u.wrapper)),
|
|
593
594
|
attributes: {
|
|
594
595
|
...s.fieldDefaults.attributes,
|
|
595
596
|
...(h = t.fieldDefaults) == null ? void 0 : h.attributes
|
|
596
597
|
}
|
|
597
598
|
}
|
|
598
599
|
};
|
|
599
|
-
},
|
|
600
|
+
}, Le = (s) => ({}), ze = {
|
|
600
601
|
install(s, t) {
|
|
601
602
|
const e = ne();
|
|
602
603
|
s._context.config.globalProperties.$formBuilder = e, t && e.setDefaults(t);
|
|
603
604
|
}
|
|
604
605
|
}, Ze = (s) => ({
|
|
605
|
-
install: (t) =>
|
|
606
|
+
install: (t) => ze.install(t, s)
|
|
606
607
|
});
|
|
607
608
|
export {
|
|
608
609
|
c as FormHook,
|
|
609
610
|
xe as MagicForm,
|
|
610
|
-
|
|
611
|
+
ze as MyParcelFormBuilderPlugin,
|
|
611
612
|
Ye as createField,
|
|
612
613
|
Qe as createForm,
|
|
613
614
|
Ze as createMyParcelFormBuilderPlugin,
|
|
615
|
+
xe as default,
|
|
614
616
|
Xe as defineField,
|
|
615
617
|
Ne as defineForm,
|
|
616
618
|
Je as useElement,
|
|
617
|
-
|
|
619
|
+
C as useForm,
|
|
618
620
|
ne as useFormBuilder
|
|
619
621
|
};
|
package/package.json
CHANGED