@effect-app/vue-components 4.0.0-beta.150 → 4.0.0-beta.152
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/types/components/OmegaForm/OmegaFormStuff.d.ts +2 -1
- package/dist/vue-components12.es.js +70 -44
- package/dist/vue-components51.es.js +12 -5
- package/dist/vue-components61.es.js +59 -59
- package/package.json +3 -3
- package/src/components/OmegaForm/OmegaFormStuff.ts +102 -14
- package/src/components/OmegaForm/OmegaInput.vue +35 -1
- package/src/components/OmegaForm/useOmegaForm.ts +10 -4
|
@@ -91,6 +91,7 @@ export type FieldValidators<T> = {
|
|
|
91
91
|
export type BaseFieldMeta = {
|
|
92
92
|
required: boolean;
|
|
93
93
|
nullableOrUndefined?: false | "undefined" | "null";
|
|
94
|
+
originalSchema?: StandardSchemaV1<any, any>;
|
|
94
95
|
/**
|
|
95
96
|
* True when the schema property is `S.optionalKey` (AST
|
|
96
97
|
* `context.isOptional`) — i.e. the key should be ABSENT from the submitted
|
|
@@ -154,7 +155,7 @@ export type CreateMeta = {
|
|
|
154
155
|
property: S.AST.AST;
|
|
155
156
|
});
|
|
156
157
|
export declare const isNullableOrUndefined: (property: false | S.AST.AST | undefined) => false | "undefined" | "null";
|
|
157
|
-
export declare const createMeta: <T = any>({ meta, parent, property, propertySignatures }: CreateMeta, acc?: Partial<MetaRecord<T
|
|
158
|
+
export declare const createMeta: <T = any>({ meta, parent, property, propertySignatures }: CreateMeta, acc?: Partial<MetaRecord<T>>, fieldAstByPath?: Record<string, S.AST.AST>) => MetaRecord<T> | FieldMeta;
|
|
158
159
|
export declare const toFormSchema: <From, To>(schema: S.Codec<To, From, never>) => S.Codec<To, From, never>;
|
|
159
160
|
export declare const duplicateSchema: <From, To>(schema: S.Codec<To, From, never>) => S.Codec<To, From, never, never>;
|
|
160
161
|
export declare const generateMetaFromSchema: <From, To>(schema: S.Codec<To, From, never>) => {
|
|
@@ -72,29 +72,29 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
|
|
|
72
72
|
}
|
|
73
73
|
} else a.AST.isBoolean(e) ? t.type = "boolean" : a.AST.isDeclaration(e) && e.annotations?.typeConstructor?._tag === "Date" ? t.type = "date" : t.type = "unknown";
|
|
74
74
|
return t;
|
|
75
|
-
}, b = ({ meta: e = {}, parent: t = "", property: n, propertySignatures: r }, i = {}) => {
|
|
75
|
+
}, b = ({ meta: e = {}, parent: t = "", property: n, propertySignatures: r }, i = {}, o) => {
|
|
76
76
|
if (n &&= c(n), n && a.AST.isObjects(n)) return b({
|
|
77
77
|
meta: e,
|
|
78
78
|
propertySignatures: n.propertySignatures
|
|
79
79
|
});
|
|
80
80
|
if (r) {
|
|
81
81
|
for (let n of r) {
|
|
82
|
-
let r = t ? `${t}.${n.name.toString()}` : n.name.toString(),
|
|
83
|
-
|
|
84
|
-
let
|
|
82
|
+
let r = t ? `${t}.${n.name.toString()}` : n.name.toString(), s = f(n.type), l = n.type.context?.isOptional === !0, u;
|
|
83
|
+
u = e._isNullableDiscriminatedUnion && n.name.toString() === "_tag" || e.required === !1 || l ? !1 : !s;
|
|
84
|
+
let d = c(n.type);
|
|
85
85
|
if (a.AST.isUnion(n.type)) {
|
|
86
86
|
let e = m(n.type.types);
|
|
87
87
|
if (e.some(a.AST.isObjects)) {
|
|
88
|
-
|
|
88
|
+
s || (i[r] = b({
|
|
89
89
|
parent: r,
|
|
90
90
|
property: n.type,
|
|
91
91
|
meta: {
|
|
92
|
-
required:
|
|
93
|
-
nullableOrUndefined:
|
|
92
|
+
required: u,
|
|
93
|
+
nullableOrUndefined: s
|
|
94
94
|
}
|
|
95
95
|
}));
|
|
96
96
|
for (let t of e) if (a.AST.isObjects(t)) {
|
|
97
|
-
let n =
|
|
97
|
+
let n = s && e.length > 1, a = b({
|
|
98
98
|
parent: r,
|
|
99
99
|
propertySignatures: t.propertySignatures,
|
|
100
100
|
meta: n ? { _isNullableDiscriminatedUnion: !0 } : {}
|
|
@@ -112,9 +112,9 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
|
|
|
112
112
|
type: "multiple",
|
|
113
113
|
members: e.elements,
|
|
114
114
|
rest: e.rest,
|
|
115
|
-
required:
|
|
116
|
-
nullableOrUndefined:
|
|
117
|
-
}, e.rest && e.rest.length > 0) {
|
|
115
|
+
required: u,
|
|
116
|
+
nullableOrUndefined: s
|
|
117
|
+
}, o && (o[r] = n.type), e.rest && e.rest.length > 0) {
|
|
118
118
|
let t = c(e.rest[0]);
|
|
119
119
|
if (a.AST.isObjects(t)) for (let e of t.propertySignatures) {
|
|
120
120
|
let t = `${r}.${e.name.toString()}`, n = b({
|
|
@@ -125,7 +125,7 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
|
|
|
125
125
|
nullableOrUndefined: f(e.type)
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
|
-
if (n && typeof n == "object" && "type" in n && (i[t] = n, n.type === "multiple" && a.AST.isArrays(e.type) && e.type.rest && e.type.rest.length > 0)) {
|
|
128
|
+
if (n && typeof n == "object" && "type" in n && (i[t] = n, o && (o[t] = e.type), n.type === "multiple" && a.AST.isArrays(e.type) && e.type.rest && e.type.rest.length > 0)) {
|
|
129
129
|
let n = c(e.type.rest[0]);
|
|
130
130
|
if (a.AST.isObjects(n)) for (let e of n.propertySignatures) {
|
|
131
131
|
let n = `${t}.${e.name.toString()}`, r = b({
|
|
@@ -136,7 +136,7 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
|
|
|
136
136
|
nullableOrUndefined: f(e.type)
|
|
137
137
|
}
|
|
138
138
|
});
|
|
139
|
-
r && typeof r == "object" && "type" in r && (i[n] = r);
|
|
139
|
+
r && typeof r == "object" && "type" in r && (i[n] = r, o && (o[n] = e.type));
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -145,19 +145,19 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
|
|
|
145
145
|
parent: r,
|
|
146
146
|
property: n.type,
|
|
147
147
|
meta: {
|
|
148
|
-
required:
|
|
149
|
-
nullableOrUndefined:
|
|
148
|
+
required: u,
|
|
149
|
+
nullableOrUndefined: s
|
|
150
150
|
}
|
|
151
|
-
});
|
|
151
|
+
}), o && (o[r] = n.type);
|
|
152
152
|
}
|
|
153
|
-
} else if (a.AST.isObjects(
|
|
153
|
+
} else if (a.AST.isObjects(d)) Object.assign(i, b({
|
|
154
154
|
parent: r,
|
|
155
|
-
propertySignatures:
|
|
155
|
+
propertySignatures: d.propertySignatures,
|
|
156
156
|
meta: {
|
|
157
|
-
required:
|
|
158
|
-
nullableOrUndefined:
|
|
157
|
+
required: u,
|
|
158
|
+
nullableOrUndefined: s
|
|
159
159
|
}
|
|
160
|
-
}));
|
|
160
|
+
}, {}, o));
|
|
161
161
|
else if (a.AST.isArrays(n.type)) if (n.type.rest.length > 0 && a.AST.isObjects(c(n.type.rest[0]))) {
|
|
162
162
|
let e = c(n.type.rest[0]);
|
|
163
163
|
if (a.AST.isObjects(e)) for (let t of e.propertySignatures) {
|
|
@@ -173,7 +173,7 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
|
|
|
173
173
|
required: !f(t.type),
|
|
174
174
|
nullableOrUndefined: f(t.type)
|
|
175
175
|
}
|
|
176
|
-
});
|
|
176
|
+
}), o && (o[n] = t.type);
|
|
177
177
|
}
|
|
178
178
|
else i[e] = {
|
|
179
179
|
type: "multiple",
|
|
@@ -181,7 +181,7 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
|
|
|
181
181
|
rest: t.type.rest,
|
|
182
182
|
required: !f(t.type),
|
|
183
183
|
nullableOrUndefined: f(t.type)
|
|
184
|
-
};
|
|
184
|
+
}, o && (o[e] = t.type);
|
|
185
185
|
} else i[e] = b({
|
|
186
186
|
parent: e,
|
|
187
187
|
property: t.type,
|
|
@@ -189,24 +189,24 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
|
|
|
189
189
|
required: !f(t.type),
|
|
190
190
|
nullableOrUndefined: f(t.type)
|
|
191
191
|
}
|
|
192
|
-
});
|
|
192
|
+
}), o && (o[e] = t.type);
|
|
193
193
|
}
|
|
194
194
|
} else i[r] = {
|
|
195
195
|
type: "multiple",
|
|
196
196
|
members: n.type.elements,
|
|
197
197
|
rest: n.type.rest,
|
|
198
|
-
required:
|
|
199
|
-
nullableOrUndefined:
|
|
200
|
-
};
|
|
198
|
+
required: u,
|
|
199
|
+
nullableOrUndefined: s
|
|
200
|
+
}, o && (o[r] = n.type);
|
|
201
201
|
else i[r] = b({
|
|
202
202
|
parent: r,
|
|
203
203
|
property: n.type,
|
|
204
204
|
meta: {
|
|
205
|
-
required:
|
|
206
|
-
nullableOrUndefined:
|
|
207
|
-
...
|
|
205
|
+
required: u && (!a.AST.isString(d) || !!y(d).minLength),
|
|
206
|
+
nullableOrUndefined: s,
|
|
207
|
+
...l ? { isOptionalKey: !0 } : {}
|
|
208
208
|
}
|
|
209
|
-
});
|
|
209
|
+
}), o && (o[r] = n.type);
|
|
210
210
|
}
|
|
211
211
|
return i;
|
|
212
212
|
}
|
|
@@ -263,22 +263,45 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
|
|
|
263
263
|
}
|
|
264
264
|
return n;
|
|
265
265
|
}, S = (e) => {
|
|
266
|
-
let t = c(e.ast), n = {}, r = {}, i = {}
|
|
266
|
+
let t = c(e.ast), n = {}, r = {}, i = {}, l = {}, d = (e, t) => {
|
|
267
|
+
let n = a.make(e), r = t ? n : a.NullishOr(n);
|
|
268
|
+
return a.toStandardSchemaV1(r);
|
|
269
|
+
}, f = (e) => {
|
|
270
|
+
for (let [t, n] of Object.entries(l)) {
|
|
271
|
+
let r = e[t];
|
|
272
|
+
if (r) try {
|
|
273
|
+
let e = r.required ?? !0;
|
|
274
|
+
Object.defineProperty(r, "originalSchema", {
|
|
275
|
+
value: d(n, e),
|
|
276
|
+
enumerable: !1,
|
|
277
|
+
configurable: !0,
|
|
278
|
+
writable: !0
|
|
279
|
+
});
|
|
280
|
+
} catch {
|
|
281
|
+
Object.defineProperty(r, "originalSchema", {
|
|
282
|
+
value: a.toStandardSchemaV1(a.Unknown),
|
|
283
|
+
enumerable: !1,
|
|
284
|
+
configurable: !0,
|
|
285
|
+
writable: !0
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
};
|
|
267
290
|
if (a.AST.isUnion(t)) {
|
|
268
291
|
let e = m(t.types);
|
|
269
292
|
if (e.every(a.AST.isObjects) && e.length > 0) {
|
|
270
293
|
let t = [];
|
|
271
294
|
for (let r of e) if (a.AST.isObjects(r)) {
|
|
272
|
-
let e = r.propertySignatures.find((e) => e.name.toString() === "_tag"), c = null,
|
|
273
|
-
|
|
274
|
-
let
|
|
275
|
-
c && (i[c] = x(
|
|
295
|
+
let e = r.propertySignatures.find((e) => e.name.toString() === "_tag"), c = null, d = e ? u(e.type) : null;
|
|
296
|
+
d && a.AST.isLiteral(d) && (c = d.literal, t.push(c), e && a.AST.isUnion(e.type) && s() && c != null && !o.has(c) && (o.add(c), console.warn(`[OmegaForm] Union member with _tag "${c}" uses S.Struct({ _tag: S.Literal("${c}"), ... }). Please migrate to S.TaggedStruct("${c}", { ... }) for cleaner AST handling.`)));
|
|
297
|
+
let f = b({ propertySignatures: r.propertySignatures }, {}, l);
|
|
298
|
+
c && (i[c] = x(f)), Object.assign(n, f);
|
|
276
299
|
}
|
|
277
300
|
return t.length > 0 && (n._tag = {
|
|
278
301
|
type: "select",
|
|
279
302
|
members: t,
|
|
280
303
|
required: !0
|
|
281
|
-
}), {
|
|
304
|
+
}), f(n), {
|
|
282
305
|
meta: n,
|
|
283
306
|
defaultValues: r,
|
|
284
307
|
unionMeta: i
|
|
@@ -286,12 +309,15 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
|
|
|
286
309
|
}
|
|
287
310
|
}
|
|
288
311
|
if (a.AST.isObjects(t)) {
|
|
289
|
-
let e = b({ propertySignatures: t.propertySignatures });
|
|
290
|
-
if (Object.values(e).every((e) => e && "type" in e))
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
312
|
+
let e = b({ propertySignatures: t.propertySignatures }, {}, l);
|
|
313
|
+
if (Object.values(e).every((e) => e && "type" in e)) {
|
|
314
|
+
let t = e;
|
|
315
|
+
return f(t), {
|
|
316
|
+
meta: t,
|
|
317
|
+
defaultValues: r,
|
|
318
|
+
unionMeta: i
|
|
319
|
+
};
|
|
320
|
+
}
|
|
295
321
|
let a = (e, t = "") => {
|
|
296
322
|
for (let r in e) {
|
|
297
323
|
let i = t ? `${t}.${r}` : r;
|
|
@@ -300,7 +326,7 @@ var o = /* @__PURE__ */ new Set(), s = () => globalThis.process?.env?.NODE_ENV !
|
|
|
300
326
|
};
|
|
301
327
|
a(e);
|
|
302
328
|
}
|
|
303
|
-
return {
|
|
329
|
+
return f(n), {
|
|
304
330
|
meta: n,
|
|
305
331
|
defaultValues: r,
|
|
306
332
|
unionMeta: i
|
|
@@ -22,15 +22,22 @@ var y = /* @__PURE__ */ c({
|
|
|
22
22
|
if (!e) return b.value;
|
|
23
23
|
let t = e;
|
|
24
24
|
return `${b.value}-${t.type}-${t.minLength ?? ""}-${t.maxLength ?? ""}-${t.minimum ?? ""}-${t.maximum ?? ""}`;
|
|
25
|
-
}), { trans: E } = e(), D =
|
|
25
|
+
}), { trans: E } = e(), D = (e) => Array.isArray(e?.issues) && e.issues.length > 0, O = (e, t) => ({ "~standard": {
|
|
26
|
+
...e["~standard"],
|
|
27
|
+
validate: (n) => {
|
|
28
|
+
let r = e["~standard"].validate(n);
|
|
29
|
+
return r && typeof r.then == "function" ? r.then((e) => D(e) ? e : t["~standard"].validate(n)) : D(r) ? r : t["~standard"].validate(n);
|
|
30
|
+
}
|
|
31
|
+
} }), k = i(() => {
|
|
26
32
|
if (!w.value) throw console.log(y.name, Object.keys(y.form.meta), y.form.meta), Error("Meta is undefined");
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
let e = t(w.value, E), n = w.value.originalSchema;
|
|
34
|
+
return n ? O(e, n) : e;
|
|
35
|
+
}), A = r(y.form);
|
|
29
36
|
return (e, t) => (p(), a(h(c.form.Field), {
|
|
30
37
|
key: T.value,
|
|
31
38
|
name: c.name,
|
|
32
39
|
validators: {
|
|
33
|
-
onBlur:
|
|
40
|
+
onBlur: k.value,
|
|
34
41
|
...c.validators
|
|
35
42
|
}
|
|
36
43
|
}, {
|
|
@@ -42,7 +49,7 @@ var y = /* @__PURE__ */ c({
|
|
|
42
49
|
field: t,
|
|
43
50
|
state: r,
|
|
44
51
|
register: c.form.registerField,
|
|
45
|
-
label: c.label ?? g(
|
|
52
|
+
label: c.label ?? g(A)(b.value),
|
|
46
53
|
meta: w.value
|
|
47
54
|
}), s({
|
|
48
55
|
default: v((t) => [m(e.$slots, "default", f(l(t)))]),
|
|
@@ -9,12 +9,12 @@ import u from "./vue-components45.es.js";
|
|
|
9
9
|
import d from "./vue-components52.es.js";
|
|
10
10
|
import f from "./vue-components56.es.js";
|
|
11
11
|
import p from "./vue-components60.es.js";
|
|
12
|
-
import { computed as m, h, onBeforeUnmount as
|
|
13
|
-
import { Array as
|
|
14
|
-
import { useForm as
|
|
15
|
-
import { makeRunPromise as
|
|
12
|
+
import { computed as m, h, onBeforeUnmount as ee, onMounted as te, onUnmounted as g, ref as _, watch as v } from "vue";
|
|
13
|
+
import { Array as y, Context as b, Data as x, Effect as S, Fiber as C, Option as w, S as T } from "effect-app";
|
|
14
|
+
import { useForm as E } from "@tanstack/vue-form";
|
|
15
|
+
import { makeRunPromise as D } from "@effect-app/vue/runtime";
|
|
16
16
|
//#region src/components/OmegaForm/useOmegaForm.ts
|
|
17
|
-
var
|
|
17
|
+
var O = class extends x.TaggedError("FormErrors") {}, k = (e) => function(t) {
|
|
18
18
|
return { render() {
|
|
19
19
|
return h(t, {
|
|
20
20
|
form: e,
|
|
@@ -48,9 +48,9 @@ var te = class extends S.TaggedError("FormErrors") {}, k = (e) => function(t) {
|
|
|
48
48
|
}), e;
|
|
49
49
|
}, []), n = [];
|
|
50
50
|
if (a.value.onSubmit) {
|
|
51
|
-
for (let [e, r] of Object.entries(a.value.onSubmit)) if (
|
|
51
|
+
for (let [e, r] of Object.entries(a.value.onSubmit)) if (y.isArray(r) && r.length) for (let e of r) {
|
|
52
52
|
let r = e;
|
|
53
|
-
if (r?.path &&
|
|
53
|
+
if (r?.path && y.isArray(r.path) && r.path.length) {
|
|
54
54
|
let e = r.path.join(".");
|
|
55
55
|
if (!t.value.has(e)) {
|
|
56
56
|
n.push({
|
|
@@ -75,15 +75,15 @@ var te = class extends S.TaggedError("FormErrors") {}, k = (e) => function(t) {
|
|
|
75
75
|
}, this.$slots);
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
|
-
}, M = (e, t) => e.includes(t), N =
|
|
78
|
+
}, M = (e, t) => e.includes(t), N = D(b.empty()), P = (e, h, b) => {
|
|
79
79
|
if (!e) throw Error("Schema is required");
|
|
80
|
-
let
|
|
80
|
+
let x = i(e), D = T.toStandardSchemaV1(x), A = T.decodeUnknownEffect(x), { meta: P, unionMeta: ne } = r(x), F = m(() => b?.persistency?.id ? b.persistency.id : `${window.location.pathname}-${Object.keys(P).join("-")}`), re = () => {
|
|
81
81
|
let e = new URLSearchParams(window.location.search);
|
|
82
82
|
e.delete(F.value);
|
|
83
83
|
let t = new URL(window.location.href);
|
|
84
84
|
t.search = e.toString(), window.history.replaceState({}, "", t.toString());
|
|
85
|
-
},
|
|
86
|
-
let r, i =
|
|
85
|
+
}, I = m(() => {
|
|
86
|
+
let r, i = b?.persistency;
|
|
87
87
|
if (i?.policies && !r && (M(i.policies, "local") || M(i.policies, "session"))) {
|
|
88
88
|
let e = M(i.policies, "local") ? localStorage : sessionStorage;
|
|
89
89
|
if (e) try {
|
|
@@ -95,7 +95,7 @@ var te = class extends S.TaggedError("FormErrors") {}, k = (e) => function(t) {
|
|
|
95
95
|
}
|
|
96
96
|
if (i?.policies && M(i.policies, "querystring")) try {
|
|
97
97
|
let e = new URLSearchParams(window.location.search).get(F.value);
|
|
98
|
-
|
|
98
|
+
re(), e && (r = t(r || {}, JSON.parse(e)));
|
|
99
99
|
} catch (e) {
|
|
100
100
|
console.error(e);
|
|
101
101
|
}
|
|
@@ -105,106 +105,106 @@ var te = class extends S.TaggedError("FormErrors") {}, k = (e) => function(t) {
|
|
|
105
105
|
persistency: r,
|
|
106
106
|
schema: n(e)
|
|
107
107
|
};
|
|
108
|
-
return (
|
|
108
|
+
return (b?.defaultValuesPriority || [
|
|
109
109
|
"tanstack",
|
|
110
110
|
"persistency",
|
|
111
111
|
"schema"
|
|
112
112
|
]).reverse().reduce((e, n) => Object.keys(e).length ? t(e, a[n]) : a[n], {});
|
|
113
|
-
}),
|
|
113
|
+
}), L = (e, t) => e ? a.with(o.setSpan(a.active(), e), t) : t(), R = E({
|
|
114
114
|
...h,
|
|
115
115
|
validators: {
|
|
116
|
-
onSubmit:
|
|
116
|
+
onSubmit: D,
|
|
117
117
|
...h?.validators || {}
|
|
118
118
|
},
|
|
119
|
-
onSubmit: h?.onSubmit ? ({ formApi: e, meta: t, value: n }) =>
|
|
119
|
+
onSubmit: h?.onSubmit ? ({ formApi: e, meta: t, value: n }) => L(t?.currentSpan, async () => {
|
|
120
120
|
let r = await N(A(n)), i = h.onSubmit({
|
|
121
121
|
formApi: e,
|
|
122
122
|
meta: t,
|
|
123
123
|
value: r
|
|
124
124
|
});
|
|
125
|
-
if (
|
|
126
|
-
if (
|
|
125
|
+
if (C.isFiber(i)) return await s(i);
|
|
126
|
+
if (S.isEffect(i)) {
|
|
127
127
|
let e = await N(i);
|
|
128
|
-
return
|
|
128
|
+
return C.isFiber(e) ? await s(e) : e;
|
|
129
129
|
}
|
|
130
130
|
return i;
|
|
131
131
|
}) : void 0,
|
|
132
|
-
defaultValues:
|
|
133
|
-
}),
|
|
132
|
+
defaultValues: I.value
|
|
133
|
+
}), z = () => {
|
|
134
134
|
Object.keys(P).forEach((e) => {
|
|
135
|
-
|
|
135
|
+
R.setFieldValue(e, void 0);
|
|
136
136
|
});
|
|
137
|
-
},
|
|
137
|
+
}, B = (e) => e.reduce((e, t) => {
|
|
138
138
|
let n = t.split(".");
|
|
139
|
-
return n.reduce((e, r, i) => (i === n.length - 1 ? e[r] =
|
|
140
|
-
}, {}),
|
|
139
|
+
return n.reduce((e, r, i) => (i === n.length - 1 ? e[r] = R.getFieldValue(t) : e[r] = e[r] ?? {}, e[r]), e), e;
|
|
140
|
+
}, {}), V = (e) => {
|
|
141
141
|
if (!e) return;
|
|
142
142
|
let { banKeys: t, keys: n } = e;
|
|
143
|
-
return
|
|
144
|
-
},
|
|
145
|
-
let e =
|
|
143
|
+
return y.isArray(n) ? B(n) : y.isArray(t) ? B(Object.keys(P).filter((e) => t.includes(e))) : R.store.state.values;
|
|
144
|
+
}, H = () => {
|
|
145
|
+
let e = b?.persistency;
|
|
146
146
|
if (!(!e?.policies || e.policies.length === 0) && (M(e.policies, "local") || M(e.policies, "session"))) {
|
|
147
147
|
let t = M(e.policies, "local") ? localStorage : sessionStorage;
|
|
148
148
|
if (!t) return;
|
|
149
|
-
let n =
|
|
149
|
+
let n = V(e);
|
|
150
150
|
return t.setItem(F.value, JSON.stringify(n));
|
|
151
151
|
}
|
|
152
|
-
},
|
|
153
|
-
let e =
|
|
152
|
+
}, U = () => {
|
|
153
|
+
let e = b?.persistency;
|
|
154
154
|
if (!(!e?.policies || e.policies.length === 0) && M(e.policies, "querystring")) {
|
|
155
|
-
let t =
|
|
155
|
+
let t = V(e), n = new URLSearchParams(window.location.search);
|
|
156
156
|
n.set(F.value, JSON.stringify(t));
|
|
157
157
|
let r = new URL(window.location.href);
|
|
158
158
|
r.search = n.toString(), window.history.replaceState({}, "", r.toString());
|
|
159
159
|
}
|
|
160
|
-
},
|
|
161
|
-
|
|
160
|
+
}, W = (e) => {
|
|
161
|
+
R.store.state.isDirty && e.preventDefault();
|
|
162
162
|
};
|
|
163
|
-
if (
|
|
164
|
-
window.addEventListener("beforeunload",
|
|
165
|
-
}),
|
|
166
|
-
window.removeEventListener("beforeunload",
|
|
167
|
-
}),
|
|
168
|
-
let e =
|
|
169
|
-
|
|
170
|
-
i && !e && t > 0 && n.value &&
|
|
163
|
+
if (g(H), te(() => {
|
|
164
|
+
window.addEventListener("beforeunload", H), window.addEventListener("blur", U), b?.preventWindowExit && b.preventWindowExit !== "nope" && window.addEventListener("beforeunload", W);
|
|
165
|
+
}), ee(() => {
|
|
166
|
+
window.removeEventListener("beforeunload", H), window.removeEventListener("blur", U), b?.preventWindowExit && b.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", W);
|
|
167
|
+
}), b?.preventWindowExit === "prevent-and-reset") {
|
|
168
|
+
let e = R.useStore((e) => e.isSubmitting), t = R.useStore((e) => e.submissionAttempts), n = R.useStore((e) => e.canSubmit), r = R.useStore((e) => e.values);
|
|
169
|
+
v([e, t], ([e, t], [i]) => {
|
|
170
|
+
i && !e && t > 0 && n.value && R.reset(r.value);
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
|
-
let K = (e) =>
|
|
173
|
+
let G = R.handleSubmit, K = async (e) => (await R.validateAllFields("blur"), await G(e)), q = (e) => S.currentSpan.pipe(S.option, S.flatMap((t) => S.promise(() => K(w.isSome(t) ? {
|
|
174
174
|
currentSpan: t.value,
|
|
175
175
|
...e
|
|
176
|
-
} : e)))),
|
|
177
|
-
let e =
|
|
178
|
-
if (Object.keys(e.fields).length || e.form.errors.length) return yield*
|
|
176
|
+
} : e)))), J = (e) => e?.checkErrors ? q(e?.meta).pipe(S.flatMap(S.fnUntraced(function* () {
|
|
177
|
+
let e = R.getAllErrors();
|
|
178
|
+
if (Object.keys(e.fields).length || e.form.errors.length) return yield* S.fail(new O({
|
|
179
179
|
form: e.form,
|
|
180
180
|
fields: e.fields
|
|
181
181
|
}));
|
|
182
|
-
}))) :
|
|
183
|
-
i18nNamespace:
|
|
184
|
-
ignorePreventCloseEvents:
|
|
182
|
+
}))) : q(e?.meta), Y = _(/* @__PURE__ */ new Map()), X = Object.assign(R, {
|
|
183
|
+
i18nNamespace: b?.i18nNamespace,
|
|
184
|
+
ignorePreventCloseEvents: b?.ignorePreventCloseEvents,
|
|
185
185
|
meta: P,
|
|
186
186
|
unionMeta: ne,
|
|
187
|
-
clear:
|
|
188
|
-
handleSubmit: (e) =>
|
|
187
|
+
clear: z,
|
|
188
|
+
handleSubmit: (e) => K({
|
|
189
189
|
currentSpan: o.getSpan(a.active()),
|
|
190
190
|
...e
|
|
191
191
|
}),
|
|
192
|
-
handleSubmitEffect:
|
|
192
|
+
handleSubmitEffect: J,
|
|
193
193
|
registerField: (e) => {
|
|
194
|
-
|
|
194
|
+
v(e, (e) => {
|
|
195
195
|
Y.value.set(e.name, {
|
|
196
196
|
label: e.label,
|
|
197
197
|
id: e.id
|
|
198
198
|
});
|
|
199
|
-
}, { immediate: !0 }),
|
|
199
|
+
}, { immediate: !0 }), g(() => {
|
|
200
200
|
Y.value.get(e.value.name)?.id === e.value.id && Y.value.delete(e.value.name);
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
|
-
}), Z =
|
|
204
|
-
|
|
203
|
+
}), Z = _(0), Q = R.useStore((e) => e.submissionAttempts);
|
|
204
|
+
v(R.useStore((e) => e.values), () => {
|
|
205
205
|
if (Z.value !== Q.value) {
|
|
206
206
|
Z.value = Q.value;
|
|
207
|
-
for (let e of Object.values(
|
|
207
|
+
for (let e of Object.values(R.fieldInfo)) e?.instance?.state.meta.errorMap?.onSubmit && e.instance.setMeta((e) => ({
|
|
208
208
|
...e,
|
|
209
209
|
errorMap: {
|
|
210
210
|
...e.errorMap,
|
|
@@ -223,9 +223,9 @@ var te = class extends S.TaggedError("FormErrors") {}, k = (e) => function(t) {
|
|
|
223
223
|
_schema: e,
|
|
224
224
|
errorContext: $,
|
|
225
225
|
Form: k(X)(p),
|
|
226
|
-
Input: k(X)(
|
|
226
|
+
Input: k(X)(b?.input ?? d),
|
|
227
227
|
TaggedUnion: k(X)(f),
|
|
228
|
-
Field:
|
|
228
|
+
Field: R.Field,
|
|
229
229
|
Errors: j($)(u),
|
|
230
230
|
Array: k(X)(c),
|
|
231
231
|
AutoGen: k(X)(l)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.152",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@mdi/js": "^7.4.47",
|
|
6
6
|
"effect": "^4.0.0-beta.56",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"highlight.js": "^11.11.1",
|
|
59
59
|
"mitt": "^3.0.1",
|
|
60
60
|
"vue3-highlightjs": "^1.0.5",
|
|
61
|
-
"effect-app": "4.0.0-beta.
|
|
62
|
-
"@effect-app/vue": "4.0.0-beta.
|
|
61
|
+
"effect-app": "4.0.0-beta.152",
|
|
62
|
+
"@effect-app/vue": "4.0.0-beta.152"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"check": "vue-tsc",
|
|
@@ -256,6 +256,7 @@ export type FieldValidators<T> = {
|
|
|
256
256
|
export type BaseFieldMeta = {
|
|
257
257
|
required: boolean
|
|
258
258
|
nullableOrUndefined?: false | "undefined" | "null"
|
|
259
|
+
originalSchema?: StandardSchemaV1<any, any>
|
|
259
260
|
/**
|
|
260
261
|
* True when the schema property is `S.optionalKey` (AST
|
|
261
262
|
* `context.isOptional`) — i.e. the key should be ABSENT from the submitted
|
|
@@ -509,7 +510,8 @@ const getFieldMetadataFromAst = (property: S.AST.AST) => {
|
|
|
509
510
|
|
|
510
511
|
export const createMeta = <T = any>(
|
|
511
512
|
{ meta = {}, parent = "", property, propertySignatures }: CreateMeta,
|
|
512
|
-
acc: Partial<MetaRecord<T>> = {}
|
|
513
|
+
acc: Partial<MetaRecord<T>> = {},
|
|
514
|
+
fieldAstByPath?: Record<string, S.AST.AST>
|
|
513
515
|
): MetaRecord<T> | FieldMeta => {
|
|
514
516
|
if (property) {
|
|
515
517
|
property = unwrapDeclaration(property)
|
|
@@ -608,6 +610,9 @@ export const createMeta = <T = any>(
|
|
|
608
610
|
required: isRequired,
|
|
609
611
|
nullableOrUndefined
|
|
610
612
|
} as FieldMeta
|
|
613
|
+
if (fieldAstByPath) {
|
|
614
|
+
fieldAstByPath[key] = p.type
|
|
615
|
+
}
|
|
611
616
|
|
|
612
617
|
// If the array has struct elements, also create metadata for their properties
|
|
613
618
|
if (arrayType.rest && arrayType.rest.length > 0) {
|
|
@@ -628,6 +633,9 @@ export const createMeta = <T = any>(
|
|
|
628
633
|
// add to accumulator if valid
|
|
629
634
|
if (propMeta && typeof propMeta === "object" && "type" in propMeta) {
|
|
630
635
|
acc[propKey as NestedKeyOf<T>] = propMeta as FieldMeta
|
|
636
|
+
if (fieldAstByPath) {
|
|
637
|
+
fieldAstByPath[propKey] = prop.type
|
|
638
|
+
}
|
|
631
639
|
|
|
632
640
|
if (
|
|
633
641
|
propMeta.type === "multiple" && S.AST.isArrays(prop.type) && prop
|
|
@@ -651,6 +659,9 @@ export const createMeta = <T = any>(
|
|
|
651
659
|
// add to accumulator if valid
|
|
652
660
|
if (nestedPropMeta && typeof nestedPropMeta === "object" && "type" in nestedPropMeta) {
|
|
653
661
|
acc[nestedPropKey as NestedKeyOf<T>] = nestedPropMeta as FieldMeta
|
|
662
|
+
if (fieldAstByPath) {
|
|
663
|
+
fieldAstByPath[nestedPropKey] = nestedProp.type
|
|
664
|
+
}
|
|
654
665
|
}
|
|
655
666
|
}
|
|
656
667
|
}
|
|
@@ -667,17 +678,24 @@ export const createMeta = <T = any>(
|
|
|
667
678
|
meta: { required: isRequired, nullableOrUndefined }
|
|
668
679
|
})
|
|
669
680
|
acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
|
|
681
|
+
if (fieldAstByPath) {
|
|
682
|
+
fieldAstByPath[key] = p.type
|
|
683
|
+
}
|
|
670
684
|
}
|
|
671
685
|
}
|
|
672
686
|
} else {
|
|
673
687
|
if (S.AST.isObjects(typeToProcess)) {
|
|
674
688
|
Object.assign(
|
|
675
689
|
acc,
|
|
676
|
-
createMeta<T>(
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
690
|
+
createMeta<T>(
|
|
691
|
+
{
|
|
692
|
+
parent: key,
|
|
693
|
+
propertySignatures: typeToProcess.propertySignatures,
|
|
694
|
+
meta: { required: isRequired, nullableOrUndefined }
|
|
695
|
+
},
|
|
696
|
+
{},
|
|
697
|
+
fieldAstByPath
|
|
698
|
+
)
|
|
681
699
|
)
|
|
682
700
|
} else if (S.AST.isArrays(p.type)) {
|
|
683
701
|
// Check if it has struct elements
|
|
@@ -708,6 +726,9 @@ export const createMeta = <T = any>(
|
|
|
708
726
|
}
|
|
709
727
|
})
|
|
710
728
|
acc[nestedKey as NestedKeyOf<T>] = nestedMeta as FieldMeta
|
|
729
|
+
if (fieldAstByPath) {
|
|
730
|
+
fieldAstByPath[nestedKey] = nestedProp.type
|
|
731
|
+
}
|
|
711
732
|
}
|
|
712
733
|
} else {
|
|
713
734
|
// Array with primitive elements - create meta for the array itself
|
|
@@ -718,6 +739,9 @@ export const createMeta = <T = any>(
|
|
|
718
739
|
required: !isNullableOrUndefined(prop.type),
|
|
719
740
|
nullableOrUndefined: isNullableOrUndefined(prop.type)
|
|
720
741
|
} as FieldMeta
|
|
742
|
+
if (fieldAstByPath) {
|
|
743
|
+
fieldAstByPath[propKey] = prop.type
|
|
744
|
+
}
|
|
721
745
|
}
|
|
722
746
|
} else {
|
|
723
747
|
const fieldMeta = createMeta<T>({
|
|
@@ -729,6 +753,9 @@ export const createMeta = <T = any>(
|
|
|
729
753
|
}
|
|
730
754
|
})
|
|
731
755
|
acc[propKey as NestedKeyOf<T>] = fieldMeta as FieldMeta
|
|
756
|
+
if (fieldAstByPath) {
|
|
757
|
+
fieldAstByPath[propKey] = prop.type
|
|
758
|
+
}
|
|
732
759
|
}
|
|
733
760
|
}
|
|
734
761
|
}
|
|
@@ -741,6 +768,9 @@ export const createMeta = <T = any>(
|
|
|
741
768
|
required: isRequired,
|
|
742
769
|
nullableOrUndefined
|
|
743
770
|
} as FieldMeta
|
|
771
|
+
if (fieldAstByPath) {
|
|
772
|
+
fieldAstByPath[key] = p.type
|
|
773
|
+
}
|
|
744
774
|
}
|
|
745
775
|
} else {
|
|
746
776
|
const newMeta = createMeta<T>({
|
|
@@ -757,6 +787,9 @@ export const createMeta = <T = any>(
|
|
|
757
787
|
})
|
|
758
788
|
|
|
759
789
|
acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
|
|
790
|
+
if (fieldAstByPath) {
|
|
791
|
+
fieldAstByPath[key] = p.type
|
|
792
|
+
}
|
|
760
793
|
}
|
|
761
794
|
}
|
|
762
795
|
}
|
|
@@ -861,11 +894,50 @@ const flattenMeta = <T>(meta: MetaRecord<T> | FieldMeta, parentKey: string = "")
|
|
|
861
894
|
|
|
862
895
|
const metadataFromAst = <From, To>(
|
|
863
896
|
schema: S.Codec<To, From, never>
|
|
864
|
-
): {
|
|
897
|
+
): {
|
|
898
|
+
meta: MetaRecord<To>
|
|
899
|
+
defaultValues: Record<string, any>
|
|
900
|
+
unionMeta: Record<string, MetaRecord<To>>
|
|
901
|
+
} => {
|
|
865
902
|
const ast = unwrapDeclaration(schema.ast)
|
|
866
903
|
const newMeta: MetaRecord<To> = {}
|
|
867
904
|
const defaultValues: Record<string, any> = {}
|
|
868
905
|
const unionMeta: Record<string, MetaRecord<To>> = {}
|
|
906
|
+
const fieldAstByPath: Record<string, S.AST.AST> = {}
|
|
907
|
+
|
|
908
|
+
const toFieldStandardSchema = (
|
|
909
|
+
propertyAst: S.AST.AST,
|
|
910
|
+
required: boolean
|
|
911
|
+
): StandardSchemaV1<any, any> => {
|
|
912
|
+
const base = S.make(propertyAst)
|
|
913
|
+
const fieldSchema = required ? base : S.NullishOr(base)
|
|
914
|
+
return S.toStandardSchemaV1(fieldSchema as any)
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
const attachOriginalSchemas = (metaRecord: MetaRecord<To>) => {
|
|
918
|
+
for (const [key, fieldAst] of Object.entries(fieldAstByPath)) {
|
|
919
|
+
const fieldMeta = metaRecord[key as NestedKeyOf<To>]
|
|
920
|
+
if (!fieldMeta) {
|
|
921
|
+
continue
|
|
922
|
+
}
|
|
923
|
+
try {
|
|
924
|
+
const required = fieldMeta.required ?? true
|
|
925
|
+
Object.defineProperty(fieldMeta, "originalSchema", {
|
|
926
|
+
value: toFieldStandardSchema(fieldAst, required),
|
|
927
|
+
enumerable: false,
|
|
928
|
+
configurable: true,
|
|
929
|
+
writable: true
|
|
930
|
+
})
|
|
931
|
+
} catch {
|
|
932
|
+
Object.defineProperty(fieldMeta, "originalSchema", {
|
|
933
|
+
value: S.toStandardSchemaV1(S.Unknown),
|
|
934
|
+
enumerable: false,
|
|
935
|
+
configurable: true,
|
|
936
|
+
writable: true
|
|
937
|
+
})
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}
|
|
869
941
|
|
|
870
942
|
// Handle root-level Union types (discriminated unions)
|
|
871
943
|
if (S.AST.isUnion(ast)) {
|
|
@@ -910,9 +982,13 @@ const metadataFromAst = <From, To>(
|
|
|
910
982
|
}
|
|
911
983
|
|
|
912
984
|
// Create metadata for this member's properties
|
|
913
|
-
const memberMeta = createMeta<To>(
|
|
914
|
-
|
|
915
|
-
|
|
985
|
+
const memberMeta = createMeta<To>(
|
|
986
|
+
{
|
|
987
|
+
propertySignatures: memberType.propertySignatures
|
|
988
|
+
},
|
|
989
|
+
{},
|
|
990
|
+
fieldAstByPath
|
|
991
|
+
)
|
|
916
992
|
|
|
917
993
|
// Store per-tag metadata for reactive lookup
|
|
918
994
|
if (tagValue) {
|
|
@@ -933,17 +1009,28 @@ const metadataFromAst = <From, To>(
|
|
|
933
1009
|
} as FieldMeta
|
|
934
1010
|
}
|
|
935
1011
|
|
|
1012
|
+
attachOriginalSchemas(newMeta)
|
|
936
1013
|
return { meta: newMeta, defaultValues, unionMeta }
|
|
937
1014
|
}
|
|
938
1015
|
}
|
|
939
1016
|
|
|
940
1017
|
if (S.AST.isObjects(ast)) {
|
|
941
|
-
const meta = createMeta<To>(
|
|
942
|
-
|
|
943
|
-
|
|
1018
|
+
const meta = createMeta<To>(
|
|
1019
|
+
{
|
|
1020
|
+
propertySignatures: ast.propertySignatures
|
|
1021
|
+
},
|
|
1022
|
+
{},
|
|
1023
|
+
fieldAstByPath
|
|
1024
|
+
)
|
|
944
1025
|
|
|
945
1026
|
if (Object.values(meta).every((value) => value && "type" in value)) {
|
|
946
|
-
|
|
1027
|
+
const typedMeta = meta as MetaRecord<To>
|
|
1028
|
+
attachOriginalSchemas(typedMeta)
|
|
1029
|
+
return {
|
|
1030
|
+
meta: typedMeta,
|
|
1031
|
+
defaultValues,
|
|
1032
|
+
unionMeta
|
|
1033
|
+
}
|
|
947
1034
|
}
|
|
948
1035
|
|
|
949
1036
|
const flattenObject = (
|
|
@@ -963,6 +1050,7 @@ const metadataFromAst = <From, To>(
|
|
|
963
1050
|
flattenObject(meta)
|
|
964
1051
|
}
|
|
965
1052
|
|
|
1053
|
+
attachOriginalSchemas(newMeta)
|
|
966
1054
|
return { meta: newMeta, defaultValues, unionMeta }
|
|
967
1055
|
}
|
|
968
1056
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
:key="fieldKey"
|
|
5
5
|
:name="name"
|
|
6
6
|
:validators="{
|
|
7
|
+
// onChange: schema,
|
|
7
8
|
onBlur: schema,
|
|
8
9
|
...validators
|
|
9
10
|
}"
|
|
@@ -97,12 +98,45 @@ const fieldKey = computed(() => {
|
|
|
97
98
|
// Call useIntl during setup to avoid issues when computed re-evaluates
|
|
98
99
|
const { trans } = useIntl()
|
|
99
100
|
|
|
101
|
+
const hasIssues = (result: any): boolean => Array.isArray(result?.issues) && result.issues.length > 0
|
|
102
|
+
|
|
103
|
+
const composeStandardSchemas = (
|
|
104
|
+
omegaSchema: any,
|
|
105
|
+
originalSchema: any
|
|
106
|
+
) => ({
|
|
107
|
+
"~standard": {
|
|
108
|
+
...omegaSchema["~standard"],
|
|
109
|
+
validate: (value: unknown) => {
|
|
110
|
+
const omegaResult = omegaSchema["~standard"].validate(value)
|
|
111
|
+
if (omegaResult && typeof omegaResult.then === "function") {
|
|
112
|
+
return omegaResult.then((resolved: any) => {
|
|
113
|
+
if (hasIssues(resolved)) {
|
|
114
|
+
return resolved
|
|
115
|
+
}
|
|
116
|
+
return originalSchema["~standard"].validate(value)
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (hasIssues(omegaResult)) {
|
|
121
|
+
return omegaResult
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return originalSchema["~standard"].validate(value)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
|
|
100
129
|
const schema = computed(() => {
|
|
101
130
|
if (!meta.value) {
|
|
102
131
|
console.log(props.name, Object.keys(props.form.meta), props.form.meta)
|
|
103
132
|
throw new Error("Meta is undefined")
|
|
104
133
|
}
|
|
105
|
-
|
|
134
|
+
const omegaSchema = generateInputStandardSchemaFromFieldMeta(meta.value, trans)
|
|
135
|
+
const fieldSchema = meta.value.originalSchema
|
|
136
|
+
if (fieldSchema) {
|
|
137
|
+
return composeStandardSchemas(omegaSchema, fieldSchema)
|
|
138
|
+
}
|
|
139
|
+
return omegaSchema
|
|
106
140
|
})
|
|
107
141
|
|
|
108
142
|
const errori18n = useErrorLabel(props.form)
|
|
@@ -688,7 +688,7 @@ export const useOmegaForm = <
|
|
|
688
688
|
const standardSchema = S.toStandardSchemaV1(formCompatibleSchema)
|
|
689
689
|
const decode = S.decodeUnknownEffect(formCompatibleSchema)
|
|
690
690
|
|
|
691
|
-
const { meta, unionMeta } = generateMetaFromSchema(
|
|
691
|
+
const { meta, unionMeta } = generateMetaFromSchema(formCompatibleSchema)
|
|
692
692
|
|
|
693
693
|
const persistencyKey = computed(() => {
|
|
694
694
|
if (omegaConfig?.persistency?.id) {
|
|
@@ -923,12 +923,20 @@ export const useOmegaForm = <
|
|
|
923
923
|
})
|
|
924
924
|
}
|
|
925
925
|
|
|
926
|
+
const hs = form.handleSubmit
|
|
927
|
+
|
|
928
|
+
const handleSubmit: typeof form.handleSubmit = async (meta?: Record<string, any>) => {
|
|
929
|
+
// workaround for not revealing all form errors on submit
|
|
930
|
+
await form.validateAllFields("blur")
|
|
931
|
+
return await hs(meta)
|
|
932
|
+
}
|
|
933
|
+
|
|
926
934
|
const handleSubmitEffect_ = (meta?: Record<string, any>) =>
|
|
927
935
|
Effect.currentSpan.pipe(
|
|
928
936
|
Effect.option,
|
|
929
937
|
Effect
|
|
930
938
|
.flatMap((span) =>
|
|
931
|
-
Effect.promise(() =>
|
|
939
|
+
Effect.promise(() => handleSubmit(Option.isSome(span) ? { currentSpan: span.value, ...meta } : meta))
|
|
932
940
|
)
|
|
933
941
|
)
|
|
934
942
|
|
|
@@ -947,8 +955,6 @@ export const useOmegaForm = <
|
|
|
947
955
|
})))
|
|
948
956
|
: handleSubmitEffect_(options?.meta)
|
|
949
957
|
|
|
950
|
-
const handleSubmit = form.handleSubmit
|
|
951
|
-
|
|
952
958
|
const fieldMap = ref(new Map<string, { label: string; id: string }>())
|
|
953
959
|
|
|
954
960
|
const formWithExtras: OF<From, To> = Object.assign(form, {
|