@companix/formkit 0.0.24 → 0.0.25
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/bundle.es.js +15 -15
- package/package.json +1 -1
package/dist/bundle.es.js
CHANGED
|
@@ -39,7 +39,7 @@ const D = M({}), q = (o) => {
|
|
|
39
39
|
$(() => () => {
|
|
40
40
|
t();
|
|
41
41
|
}, []);
|
|
42
|
-
const { value: g, error:
|
|
42
|
+
const { value: g, error: m } = s.getForm(r);
|
|
43
43
|
return /* @__PURE__ */ h(
|
|
44
44
|
o,
|
|
45
45
|
{
|
|
@@ -53,7 +53,7 @@ const D = M({}), q = (o) => {
|
|
|
53
53
|
ref: l
|
|
54
54
|
},
|
|
55
55
|
isDirty: !1,
|
|
56
|
-
error:
|
|
56
|
+
error: m,
|
|
57
57
|
disabled: s.disabled
|
|
58
58
|
}
|
|
59
59
|
);
|
|
@@ -68,7 +68,7 @@ const D = M({}), q = (o) => {
|
|
|
68
68
|
return s.forEach(({ name: b }) => {
|
|
69
69
|
t.getForm([...r, b].join(".")).value !== void 0 && f.push(b);
|
|
70
70
|
}), f;
|
|
71
|
-
}, []),
|
|
71
|
+
}, []), m = C(() => g(), []), [y, v] = w(m);
|
|
72
72
|
$(() => {
|
|
73
73
|
const { unregistry: f } = t.registryExtraForm(
|
|
74
74
|
s.map(({ name: b }) => [...r, b].join(".")),
|
|
@@ -123,7 +123,7 @@ const D = M({}), q = (o) => {
|
|
|
123
123
|
E(t.childs, [...r, t.context], e[t.context] ?? {}, s);
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
|
-
if (t.type === "layout" || t.type === "condition") {
|
|
126
|
+
if (t.type === "layout" || t.type === "condition" || t.type === "visability") {
|
|
127
127
|
E(t.childs, r, e, s);
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
@@ -167,7 +167,7 @@ const D = M({}), q = (o) => {
|
|
|
167
167
|
const e = {};
|
|
168
168
|
return p({ scheme: o, path: [], values: e, forms: r }), e;
|
|
169
169
|
}, G = (o, r) => {
|
|
170
|
-
const { onSubmit: e, onEqual: s, disabled: t, onDirty: l, onFormDirty: g, onChangeEvent:
|
|
170
|
+
const { onSubmit: e, onEqual: s, disabled: t, onDirty: l, onFormDirty: g, onChangeEvent: m, defaultValues: y } = r, v = { onSubmit: e }, d = {
|
|
171
171
|
isActive: !1,
|
|
172
172
|
isSubmitted: !1,
|
|
173
173
|
dirtyCount: 0
|
|
@@ -242,11 +242,11 @@ const D = M({}), q = (o) => {
|
|
|
242
242
|
const i = T(o, a);
|
|
243
243
|
await v.onSubmit(i, {
|
|
244
244
|
setError: (c, F) => {
|
|
245
|
-
const
|
|
246
|
-
|
|
245
|
+
const x = this.getForm(c);
|
|
246
|
+
x.error = {
|
|
247
247
|
error: !0,
|
|
248
248
|
messages: [F.message]
|
|
249
|
-
},
|
|
249
|
+
}, x.rerender();
|
|
250
250
|
}
|
|
251
251
|
}).catch((c) => {
|
|
252
252
|
console.log("[formkit] submit exception:", c);
|
|
@@ -261,8 +261,8 @@ const D = M({}), q = (o) => {
|
|
|
261
261
|
a[c].value = void 0;
|
|
262
262
|
return;
|
|
263
263
|
}
|
|
264
|
-
const
|
|
265
|
-
u || (a[c].startValue =
|
|
264
|
+
const x = F ?? i.defaultValue;
|
|
265
|
+
u || (a[c].startValue = x, a[c].isDirty = !1), a[c].value !== x && this.onChange(c, x);
|
|
266
266
|
}), u || (d.dirtyCount = 0, d.isSubmitted = !1), f.subscribers.forEach(({ visualizeEvalueatedForms: i }) => {
|
|
267
267
|
i();
|
|
268
268
|
});
|
|
@@ -305,10 +305,10 @@ const D = M({}), q = (o) => {
|
|
|
305
305
|
},
|
|
306
306
|
onChange(n, u) {
|
|
307
307
|
const i = this.getForm(n), c = !L(u, i.startValue);
|
|
308
|
-
i.isDirty !== c && b(n, c), i.isDirty = c,
|
|
308
|
+
i.isDirty !== c && b(n, c), i.isDirty = c, m?.({ name: n, value: u }), (i.error || d.isSubmitted) && (i.error = i.validate(u) || null);
|
|
309
309
|
const F = i.value;
|
|
310
|
-
i.value = u, i.rerender(), i.subscribers.forEach(({ callback:
|
|
311
|
-
|
|
310
|
+
i.value = u, i.rerender(), i.subscribers.forEach(({ callback: x }) => {
|
|
311
|
+
x(u, F);
|
|
312
312
|
});
|
|
313
313
|
}
|
|
314
314
|
};
|
|
@@ -363,14 +363,14 @@ const D = M({}), q = (o) => {
|
|
|
363
363
|
};
|
|
364
364
|
}
|
|
365
365
|
}, X = (o) => (r, e) => {
|
|
366
|
-
const s = o.getRequireCheck(e), { $rules: t = {}, ...l } = e, { validate: g, required:
|
|
366
|
+
const s = o.getRequireCheck(e), { $rules: t = {}, ...l } = e, { validate: g, required: m } = t;
|
|
367
367
|
return {
|
|
368
368
|
type: "form",
|
|
369
369
|
name: r,
|
|
370
370
|
defaultValue: o.defaultValue,
|
|
371
371
|
Form: o.getForm(l),
|
|
372
372
|
validate: (y) => {
|
|
373
|
-
if (
|
|
373
|
+
if (m) {
|
|
374
374
|
const v = S(() => s(y));
|
|
375
375
|
if (v)
|
|
376
376
|
return v;
|