@effect-app/vue-components 2.7.5 → 2.7.7
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 +1 -0
- package/dist/vue-components.es.js +12 -11
- package/dist/vue-components.es10.js +147 -128
- package/dist/vue-components.es12.js +1 -0
- package/dist/vue-components.es2.js +14 -13
- package/package.json +3 -3
- package/src/components/OmegaForm/OmegaFormStuff.ts +1 -1
- package/src/components/OmegaForm/useOmegaForm.ts +31 -5
|
@@ -136,6 +136,7 @@ export type CreateMeta = {
|
|
|
136
136
|
propertySignatures?: never;
|
|
137
137
|
property: S.AST.AST;
|
|
138
138
|
});
|
|
139
|
+
export declare const isNullableOrUndefined: (property: false | S.AST.AST | undefined) => false | "undefined" | "null";
|
|
139
140
|
export declare const createMeta: <T = any>({ meta, parent, property, propertySignatures }: CreateMeta, acc?: Partial<MetaRecord<T>>) => MetaRecord<T> | FieldMeta;
|
|
140
141
|
export declare const duplicateSchema: <From, To>(schema: S.Schema<To, From, never>) => S.extend<S.Schema<To, From, never>, S.Struct<{}>>;
|
|
141
142
|
export declare const generateMetaFromSchema: <From, To>(schema: S.Schema<To, From, never>) => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as o from "./vue-components.es2.js";
|
|
2
|
-
import { getTransformationFrom as f, provideIntl as
|
|
2
|
+
import { getTransformationFrom as f, provideIntl as l, useIntl as u, useIntlKey as s } from "./vue-components.es3.js";
|
|
3
3
|
import { default as i } from "./vue-components.es4.js";
|
|
4
4
|
import { default as g } from "./vue-components.es5.js";
|
|
5
5
|
import { default as I } from "./vue-components.es6.js";
|
|
6
6
|
import { default as y } from "./vue-components.es7.js";
|
|
7
7
|
import { default as h } from "./vue-components.es8.js";
|
|
8
|
-
import { default as
|
|
9
|
-
import { useOmegaForm as
|
|
10
|
-
import { useOnClose as
|
|
11
|
-
import { createMeta as P, duplicateSchema as k, generateInputStandardSchemaFromFieldMeta as w, generateMetaFromSchema as B, getInputType as D,
|
|
8
|
+
import { default as C } from "./vue-components.es9.js";
|
|
9
|
+
import { useOmegaForm as T } from "./vue-components.es10.js";
|
|
10
|
+
import { useOnClose as M, usePreventClose as j } from "./vue-components.es11.js";
|
|
11
|
+
import { createMeta as P, duplicateSchema as k, generateInputStandardSchemaFromFieldMeta as w, generateMetaFromSchema as B, getInputType as D, isNullableOrUndefined as K, nullableInput as N } from "./vue-components.es12.js";
|
|
12
12
|
import { createUseFormWithCustomInput as W } from "./vue-components.es13.js";
|
|
13
13
|
function r(a) {
|
|
14
14
|
for (const e in o)
|
|
@@ -23,7 +23,7 @@ export {
|
|
|
23
23
|
g as Dialog,
|
|
24
24
|
I as OmegaInput,
|
|
25
25
|
h as OmegaTaggedUnion,
|
|
26
|
-
|
|
26
|
+
C as OmegaTaggedUnionInternal,
|
|
27
27
|
y as OmegaVuetifyInput,
|
|
28
28
|
P as createMeta,
|
|
29
29
|
W as createUseFormWithCustomInput,
|
|
@@ -33,11 +33,12 @@ export {
|
|
|
33
33
|
B as generateMetaFromSchema,
|
|
34
34
|
D as getInputType,
|
|
35
35
|
f as getTransformationFrom,
|
|
36
|
-
K as
|
|
37
|
-
|
|
38
|
-
l as
|
|
36
|
+
K as isNullableOrUndefined,
|
|
37
|
+
N as nullableInput,
|
|
38
|
+
l as provideIntl,
|
|
39
|
+
u as useIntl,
|
|
39
40
|
s as useIntlKey,
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
T as useOmegaForm,
|
|
42
|
+
M as useOnClose,
|
|
42
43
|
j as usePreventClose
|
|
43
44
|
};
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import { useForm as
|
|
2
|
-
import { Data as
|
|
3
|
-
import { runtimeFiberAsPromise as
|
|
4
|
-
import { isObject as
|
|
5
|
-
import { computed as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { generateMetaFromSchema as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { trace as
|
|
1
|
+
import { useForm as z } from "@tanstack/vue-form";
|
|
2
|
+
import { Data as Q, S as v, Effect as b, Array as g, Fiber as O, Option as D } from "effect-app";
|
|
3
|
+
import { runtimeFiberAsPromise as X } from "./vue-components.es16.js";
|
|
4
|
+
import { isObject as Y } from "./vue-components.es17.js";
|
|
5
|
+
import { computed as T, onUnmounted as W, onMounted as Z, onBeforeUnmount as C, watch as H, ref as ee, h as B } from "vue";
|
|
6
|
+
import te from "./vue-components.es18.js";
|
|
7
|
+
import re from "./vue-components.es19.js";
|
|
8
|
+
import ne from "./vue-components.es20.js";
|
|
9
|
+
import { generateMetaFromSchema as se, isNullableOrUndefined as J } from "./vue-components.es12.js";
|
|
10
|
+
import oe from "./vue-components.es6.js";
|
|
11
|
+
import ie from "./vue-components.es8.js";
|
|
12
|
+
import ae from "./vue-components.es21.js";
|
|
13
|
+
import { trace as q } from "./vue-components.es22.js";
|
|
14
14
|
import { context as V } from "./vue-components.es23.js";
|
|
15
|
-
const _ = (
|
|
16
|
-
const i =
|
|
15
|
+
const _ = (l) => {
|
|
16
|
+
const i = l.ast;
|
|
17
17
|
if (i._tag === "Union") {
|
|
18
|
-
const o = i.types.map((
|
|
19
|
-
const
|
|
20
|
-
return _(
|
|
21
|
-
}),
|
|
18
|
+
const o = i.types.map((f) => {
|
|
19
|
+
const c = v.make(f);
|
|
20
|
+
return _(c).ast;
|
|
21
|
+
}), p = {
|
|
22
22
|
...i,
|
|
23
23
|
types: o
|
|
24
24
|
};
|
|
25
|
-
return
|
|
25
|
+
return v.make(p);
|
|
26
26
|
}
|
|
27
27
|
if (i._tag === "Transformation") {
|
|
28
|
-
const o =
|
|
28
|
+
const o = v.make(i.from), p = v.make(i.to), f = _(o), c = _(p), d = {
|
|
29
29
|
...i,
|
|
30
|
-
from:
|
|
31
|
-
to:
|
|
30
|
+
from: f.ast,
|
|
31
|
+
to: c.ast
|
|
32
32
|
};
|
|
33
|
-
return
|
|
33
|
+
return v.make(d);
|
|
34
34
|
}
|
|
35
35
|
if (i._tag === "TypeLiteral") {
|
|
36
|
-
const o = i.propertySignatures.map((
|
|
37
|
-
const
|
|
38
|
-
let
|
|
39
|
-
if (
|
|
40
|
-
const k =
|
|
41
|
-
|
|
36
|
+
const o = i.propertySignatures.map((f) => {
|
|
37
|
+
const c = f.type;
|
|
38
|
+
let d = c;
|
|
39
|
+
if (c._tag === "TypeLiteral" || c._tag === "Union" || c._tag === "Transformation") {
|
|
40
|
+
const k = v.make(c);
|
|
41
|
+
d = _(k).ast;
|
|
42
42
|
}
|
|
43
43
|
return {
|
|
44
|
-
...
|
|
45
|
-
type:
|
|
44
|
+
...f,
|
|
45
|
+
type: d,
|
|
46
46
|
isOptional: !0
|
|
47
47
|
};
|
|
48
|
-
}),
|
|
48
|
+
}), p = {
|
|
49
49
|
...i,
|
|
50
50
|
propertySignatures: o
|
|
51
51
|
};
|
|
52
|
-
return
|
|
52
|
+
return v.make(p);
|
|
53
53
|
}
|
|
54
|
-
return
|
|
54
|
+
return l;
|
|
55
55
|
};
|
|
56
|
-
class
|
|
56
|
+
class le extends Q.TaggedError("FormErrors") {
|
|
57
57
|
}
|
|
58
|
-
const
|
|
58
|
+
const U = (l) => function(o) {
|
|
59
59
|
return {
|
|
60
60
|
render() {
|
|
61
|
-
return
|
|
62
|
-
form:
|
|
61
|
+
return B(o, {
|
|
62
|
+
form: l,
|
|
63
63
|
...this.$attrs
|
|
64
64
|
}, this.$slots);
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
}, ce = (
|
|
67
|
+
}, ce = (l) => function(o) {
|
|
68
68
|
return {
|
|
69
69
|
setup() {
|
|
70
|
-
const { fieldMap:
|
|
70
|
+
const { fieldMap: p, form: f } = l, c = f.useStore((S) => S.errors), d = f.useStore((S) => S.fieldMeta), k = f.useStore((S) => S.errorMap), w = T(() => {
|
|
71
71
|
const S = g.filterMap(
|
|
72
|
-
Object.entries(
|
|
73
|
-
([x,
|
|
74
|
-
const a =
|
|
72
|
+
Object.entries(d.value),
|
|
73
|
+
([x, h]) => {
|
|
74
|
+
const a = h.errors ?? [];
|
|
75
75
|
if (!a.length) return D.none();
|
|
76
|
-
const
|
|
77
|
-
return
|
|
78
|
-
label:
|
|
79
|
-
inputId:
|
|
76
|
+
const y = p.value.get(x);
|
|
77
|
+
return y ? D.some({
|
|
78
|
+
label: y.label,
|
|
79
|
+
inputId: y.id,
|
|
80
80
|
// Only show the first error
|
|
81
81
|
errors: [a[0]?.message].filter(Boolean)
|
|
82
82
|
}) : D.none();
|
|
83
83
|
}
|
|
84
84
|
), F = [];
|
|
85
85
|
if (k.value.onSubmit) {
|
|
86
|
-
for (const [x,
|
|
87
|
-
if (g.isArray(
|
|
88
|
-
for (const a of
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
91
|
-
const A =
|
|
92
|
-
if (!
|
|
86
|
+
for (const [x, h] of Object.entries(k.value.onSubmit))
|
|
87
|
+
if (g.isArray(h) && h.length)
|
|
88
|
+
for (const a of h) {
|
|
89
|
+
const y = a;
|
|
90
|
+
if (y?.path && g.isArray(y.path) && y.path.length) {
|
|
91
|
+
const A = y.path.join(".");
|
|
92
|
+
if (!p.value.has(A)) {
|
|
93
93
|
F.push({
|
|
94
94
|
label: A,
|
|
95
95
|
inputId: A,
|
|
96
|
-
errors: [
|
|
96
|
+
errors: [y.message].filter(Boolean)
|
|
97
97
|
});
|
|
98
98
|
break;
|
|
99
99
|
}
|
|
@@ -103,49 +103,57 @@ const M = (c) => function(o) {
|
|
|
103
103
|
return [...S, ...F];
|
|
104
104
|
});
|
|
105
105
|
return {
|
|
106
|
-
generalErrors:
|
|
106
|
+
generalErrors: c,
|
|
107
107
|
errors: w
|
|
108
108
|
};
|
|
109
109
|
},
|
|
110
|
-
render({ errors:
|
|
111
|
-
return
|
|
112
|
-
errors:
|
|
113
|
-
generalErrors:
|
|
110
|
+
render({ errors: p, generalErrors: f }) {
|
|
111
|
+
return B(o, {
|
|
112
|
+
errors: p,
|
|
113
|
+
generalErrors: f,
|
|
114
114
|
...this.$attrs
|
|
115
115
|
}, this.$slots);
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
|
-
},
|
|
119
|
-
if (!
|
|
120
|
-
const
|
|
118
|
+
}, Ae = (l, i, o) => {
|
|
119
|
+
if (!l) throw new Error("Schema is required");
|
|
120
|
+
const p = v.standardSchemaV1(l), f = v.decode(l), { meta: c } = se(l), d = T(() => {
|
|
121
121
|
if (o?.persistency?.id)
|
|
122
122
|
return o.persistency.id;
|
|
123
|
-
const e = window.location.pathname, t = Object.keys(
|
|
123
|
+
const e = window.location.pathname, t = Object.keys(c);
|
|
124
124
|
return `${e}-${t.join("-")}`;
|
|
125
125
|
}), k = () => {
|
|
126
126
|
const e = new URLSearchParams(window.location.search);
|
|
127
|
-
e.delete(
|
|
127
|
+
e.delete(d.value);
|
|
128
128
|
const t = new URL(window.location.href);
|
|
129
129
|
t.search = e.toString(), window.history.replaceState({}, "", t.toString());
|
|
130
130
|
};
|
|
131
131
|
function w(e, t) {
|
|
132
132
|
for (const r in t)
|
|
133
|
-
g.isArray(t[r]) ? e[r] = t[r] : t[r] &&
|
|
133
|
+
g.isArray(t[r]) ? e[r] = t[r] : t[r] && Y(t[r]) ? (e[r] || (e[r] = {}), w(e[r], t[r])) : e[r] = t[r];
|
|
134
134
|
return e;
|
|
135
135
|
}
|
|
136
136
|
const S = (e) => {
|
|
137
137
|
const t = {};
|
|
138
138
|
if (typeof e?.make == "function")
|
|
139
139
|
try {
|
|
140
|
-
|
|
140
|
+
const n = e.make({});
|
|
141
|
+
if (e?.fields && typeof e.fields == "object") {
|
|
142
|
+
for (const [s, u] of Object.entries(e.fields))
|
|
143
|
+
if (n[s] === void 0) {
|
|
144
|
+
const m = u.ast, M = J(m);
|
|
145
|
+
M === "null" ? n[s] = null : M === "undefined" && (n[s] = void 0);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return n;
|
|
141
149
|
} catch {
|
|
142
150
|
}
|
|
143
|
-
const r = e?.members || (e?.ast?._tag === "Union" && e.ast.types ? e.ast.types.map((n) =>
|
|
151
|
+
const r = e?.members || (e?.ast?._tag === "Union" && e.ast.types ? e.ast.types.map((n) => v.make(n)) : null);
|
|
144
152
|
if (r && g.isArray(r)) {
|
|
145
153
|
for (const n of r) {
|
|
146
154
|
const s = S(n);
|
|
147
155
|
if (Object.keys(s).length > 0 && n?.fields && Object.entries(n.fields).some(
|
|
148
|
-
([
|
|
156
|
+
([m, M]) => m === "_tag" || m === "type" || m === "kind" ? M?.ast?.defaultValue !== void 0 : !1
|
|
149
157
|
))
|
|
150
158
|
return s;
|
|
151
159
|
}
|
|
@@ -155,30 +163,41 @@ const M = (c) => function(o) {
|
|
|
155
163
|
for (const [n, s] of Object.entries(e.fields)) {
|
|
156
164
|
if (s?.ast?.defaultValue)
|
|
157
165
|
try {
|
|
158
|
-
const
|
|
159
|
-
|
|
166
|
+
const m = s.ast.defaultValue();
|
|
167
|
+
t[n] = m;
|
|
160
168
|
} catch {
|
|
161
169
|
}
|
|
162
|
-
|
|
163
|
-
|
|
170
|
+
else {
|
|
171
|
+
const m = s.ast;
|
|
172
|
+
switch (J(m)) {
|
|
173
|
+
case "null":
|
|
174
|
+
t[n] = null;
|
|
175
|
+
break;
|
|
176
|
+
case "undefined":
|
|
177
|
+
t[n] = void 0;
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const u = S(s);
|
|
182
|
+
Object.keys(u).length > 0 && (t[n] && typeof t[n] == "object" ? Object.assign(t[n], u) : t[n] || (t[n] = u));
|
|
164
183
|
}
|
|
165
184
|
return t;
|
|
166
185
|
}, F = (e = {}) => {
|
|
167
186
|
let t = {};
|
|
168
187
|
try {
|
|
169
|
-
const r =
|
|
170
|
-
t =
|
|
188
|
+
const r = l.make(e);
|
|
189
|
+
t = v.encodeSync(_(S(l)))(r);
|
|
171
190
|
} catch (r) {
|
|
172
191
|
window.location.hostname === "localhost" && console.warn("schema.make() failed, extracting defaults from AST:", r);
|
|
173
192
|
try {
|
|
174
|
-
const n = S(
|
|
175
|
-
t =
|
|
193
|
+
const n = S(l);
|
|
194
|
+
t = v.encodeSync(_(l))(n);
|
|
176
195
|
} catch (n) {
|
|
177
196
|
window.location.hostname === "localhost" && console.warn("Could not extract defaults from AST:", n);
|
|
178
197
|
}
|
|
179
198
|
}
|
|
180
199
|
return w(t, e);
|
|
181
|
-
}, x =
|
|
200
|
+
}, x = T(() => {
|
|
182
201
|
let e;
|
|
183
202
|
const t = o?.persistency;
|
|
184
203
|
if (
|
|
@@ -189,16 +208,16 @@ const M = (c) => function(o) {
|
|
|
189
208
|
if (r)
|
|
190
209
|
try {
|
|
191
210
|
const n = JSON.parse(
|
|
192
|
-
r.getItem(
|
|
211
|
+
r.getItem(d.value) || "{}"
|
|
193
212
|
);
|
|
194
|
-
r.removeItem(
|
|
213
|
+
r.removeItem(d.value), e = n;
|
|
195
214
|
} catch (n) {
|
|
196
215
|
console.error(n);
|
|
197
216
|
}
|
|
198
217
|
}
|
|
199
218
|
if (t?.policies && t.policies.includes("querystring"))
|
|
200
219
|
try {
|
|
201
|
-
const n = new URLSearchParams(window.location.search).get(
|
|
220
|
+
const n = new URLSearchParams(window.location.search).get(d.value);
|
|
202
221
|
k(), n && (e = w(e || {}, JSON.parse(n)));
|
|
203
222
|
} catch (r) {
|
|
204
223
|
console.error(r);
|
|
@@ -206,41 +225,41 @@ const M = (c) => function(o) {
|
|
|
206
225
|
return e ??= {}, F(
|
|
207
226
|
o?.persistency?.overrideDefaultValues ? w(i?.defaultValues || {}, e) : w(e, i?.defaultValues || {})
|
|
208
227
|
);
|
|
209
|
-
}),
|
|
228
|
+
}), h = (e, t) => e ? V.with(q.setSpan(V.active(), e), t) : t(), a = z({
|
|
210
229
|
...i,
|
|
211
230
|
validators: {
|
|
212
|
-
onSubmit:
|
|
231
|
+
onSubmit: p,
|
|
213
232
|
...i?.validators || {}
|
|
214
233
|
},
|
|
215
|
-
onSubmit: i?.onSubmit ? ({ formApi: e, meta: t, value: r }) =>
|
|
216
|
-
const n = await
|
|
234
|
+
onSubmit: i?.onSubmit ? ({ formApi: e, meta: t, value: r }) => h(t?.currentSpan, async () => {
|
|
235
|
+
const n = await b.runPromise(f(r)), s = i.onSubmit({
|
|
217
236
|
formApi: e,
|
|
218
237
|
meta: t,
|
|
219
238
|
value: n
|
|
220
239
|
});
|
|
221
|
-
return
|
|
240
|
+
return O.isFiber(s) && O.isRuntimeFiber(s) ? await X(s) : b.isEffect(s) ? await b.runPromise(
|
|
222
241
|
s.pipe(
|
|
223
242
|
// meta?.currentSpan
|
|
224
243
|
// ? Effect.withParentSpan(meta.currentSpan)
|
|
225
244
|
// : (_) => _,
|
|
226
|
-
|
|
245
|
+
b.flatMap((u) => O.join(u))
|
|
227
246
|
)
|
|
228
247
|
) : s;
|
|
229
248
|
}) : void 0,
|
|
230
249
|
defaultValues: x.value
|
|
231
|
-
}),
|
|
232
|
-
Object.keys(
|
|
250
|
+
}), y = () => {
|
|
251
|
+
Object.keys(c).forEach((e) => {
|
|
233
252
|
a.setFieldValue(e, void 0);
|
|
234
253
|
});
|
|
235
254
|
}, A = (e) => e.reduce((t, r) => {
|
|
236
255
|
const n = r.split(".");
|
|
237
|
-
return n.reduce((s,
|
|
238
|
-
}, {}),
|
|
256
|
+
return n.reduce((s, u, m) => (m === n.length - 1 ? s[u] = a.getFieldValue(r) : s[u] = s[u] ?? {}, s[u]), t), t;
|
|
257
|
+
}, {}), j = (e) => {
|
|
239
258
|
if (e) {
|
|
240
259
|
if (g.isArray(e.keys))
|
|
241
260
|
return A(e.keys);
|
|
242
261
|
if (g.isArray(e.banKeys)) {
|
|
243
|
-
const t = Object.keys(
|
|
262
|
+
const t = Object.keys(c).filter((r) => e.banKeys?.includes(r));
|
|
244
263
|
return A(t);
|
|
245
264
|
}
|
|
246
265
|
return a.store.state.values;
|
|
@@ -250,69 +269,69 @@ const M = (c) => function(o) {
|
|
|
250
269
|
if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
|
|
251
270
|
const t = e.policies.includes("local") ? localStorage : sessionStorage;
|
|
252
271
|
if (!t) return;
|
|
253
|
-
const r =
|
|
254
|
-
return t.setItem(
|
|
272
|
+
const r = j(e);
|
|
273
|
+
return t.setItem(d.value, JSON.stringify(r));
|
|
255
274
|
}
|
|
256
|
-
},
|
|
275
|
+
}, I = () => {
|
|
257
276
|
const e = o?.persistency;
|
|
258
277
|
if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
|
|
259
|
-
const t =
|
|
260
|
-
r.set(
|
|
278
|
+
const t = j(e), r = new URLSearchParams(window.location.search);
|
|
279
|
+
r.set(d.value, JSON.stringify(t));
|
|
261
280
|
const n = new URL(window.location.href);
|
|
262
281
|
n.search = r.toString(), window.history.replaceState({}, "", n.toString());
|
|
263
282
|
}
|
|
264
|
-
},
|
|
283
|
+
}, $ = (e) => {
|
|
265
284
|
a.store.state.isDirty && e.preventDefault();
|
|
266
285
|
};
|
|
267
|
-
if (
|
|
268
|
-
window.addEventListener("beforeunload", P), window.addEventListener("blur",
|
|
269
|
-
}),
|
|
270
|
-
window.removeEventListener("beforeunload", P), window.removeEventListener("blur",
|
|
286
|
+
if (W(P), Z(() => {
|
|
287
|
+
window.addEventListener("beforeunload", P), window.addEventListener("blur", I), o?.preventWindowExit && o.preventWindowExit !== "nope" && window.addEventListener("beforeunload", $);
|
|
288
|
+
}), C(() => {
|
|
289
|
+
window.removeEventListener("beforeunload", P), window.removeEventListener("blur", I), o?.preventWindowExit && o.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", $);
|
|
271
290
|
}), o?.preventWindowExit === "prevent-and-reset") {
|
|
272
291
|
const e = a.useStore((s) => s.isSubmitting), t = a.useStore((s) => s.submissionAttempts), r = a.useStore((s) => s.canSubmit), n = a.useStore((s) => s.values);
|
|
273
|
-
|
|
274
|
-
|
|
292
|
+
H([e, t], ([s, u], [m]) => {
|
|
293
|
+
m && !s && u > 0 && r.value && a.reset(n.value);
|
|
275
294
|
});
|
|
276
295
|
}
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
(t) =>
|
|
296
|
+
const N = (e) => b.currentSpan.pipe(
|
|
297
|
+
b.option,
|
|
298
|
+
b.flatMap(
|
|
299
|
+
(t) => b.promise(() => a.handleSubmit(D.isSome(t) ? { currentSpan: t.value, ...e } : e))
|
|
281
300
|
)
|
|
282
|
-
),
|
|
301
|
+
), K = (e) => e?.checkErrors ? N(e?.meta).pipe(b.flatMap(b.fnUntraced(function* () {
|
|
283
302
|
const t = a.getAllErrors();
|
|
284
303
|
if (Object.keys(t.fields).length || t.form.errors.length)
|
|
285
|
-
return yield* new
|
|
286
|
-
}))) :
|
|
304
|
+
return yield* new le({ form: t.form, fields: t.fields });
|
|
305
|
+
}))) : N(e?.meta), G = a.handleSubmit, L = ee(/* @__PURE__ */ new Map()), E = Object.assign(a, {
|
|
287
306
|
i18nNamespace: o?.i18nNamespace,
|
|
288
307
|
ignorePreventCloseEvents: o?.ignorePreventCloseEvents,
|
|
289
|
-
meta:
|
|
290
|
-
clear:
|
|
308
|
+
meta: c,
|
|
309
|
+
clear: y,
|
|
291
310
|
handleSubmit: (e) => {
|
|
292
|
-
const t =
|
|
293
|
-
return
|
|
311
|
+
const t = q.getSpan(V.active());
|
|
312
|
+
return G({ currentSpan: t, ...e });
|
|
294
313
|
},
|
|
295
314
|
// /** @experimental */
|
|
296
|
-
handleSubmitEffect:
|
|
315
|
+
handleSubmitEffect: K,
|
|
297
316
|
registerField: (e) => {
|
|
298
|
-
|
|
317
|
+
H(e, (t) => L.value.set(t.name, { label: t.label, id: t.id }), { immediate: !0 }), W(() => L.value.delete(e.value.name));
|
|
299
318
|
}
|
|
300
|
-
}),
|
|
319
|
+
}), R = { form: E, fieldMap: L };
|
|
301
320
|
return Object.assign(E, {
|
|
302
321
|
// Type-level properties for performance optimization (not used at runtime)
|
|
303
322
|
_paths: void 0,
|
|
304
323
|
_keys: void 0,
|
|
305
|
-
errorContext:
|
|
306
|
-
Form:
|
|
307
|
-
Input:
|
|
308
|
-
TaggedUnion:
|
|
324
|
+
errorContext: R,
|
|
325
|
+
Form: U(E)(ae),
|
|
326
|
+
Input: U(E)(o?.input ?? oe),
|
|
327
|
+
TaggedUnion: U(E)(ie),
|
|
309
328
|
Field: a.Field,
|
|
310
|
-
Errors: ce(
|
|
311
|
-
Array:
|
|
312
|
-
AutoGen:
|
|
329
|
+
Errors: ce(R)(ne),
|
|
330
|
+
Array: U(E)(te),
|
|
331
|
+
AutoGen: U(E)(re)
|
|
313
332
|
});
|
|
314
333
|
};
|
|
315
334
|
export {
|
|
316
|
-
|
|
317
|
-
|
|
335
|
+
le as FormErrors,
|
|
336
|
+
Ae as useOmegaForm
|
|
318
337
|
};
|
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import { default as a } from "./vue-components.es4.js";
|
|
2
2
|
import { default as r } from "./vue-components.es5.js";
|
|
3
|
-
import { createMeta as n, duplicateSchema as u, generateInputStandardSchemaFromFieldMeta as
|
|
4
|
-
import { useOmegaForm as
|
|
5
|
-
import { default as
|
|
3
|
+
import { createMeta as n, duplicateSchema as u, generateInputStandardSchemaFromFieldMeta as f, generateMetaFromSchema as l, getInputType as p, isNullableOrUndefined as d, nullableInput as s } from "./vue-components.es12.js";
|
|
4
|
+
import { useOmegaForm as x } from "./vue-components.es10.js";
|
|
5
|
+
import { default as I } from "./vue-components.es6.js";
|
|
6
6
|
import { default as c } from "./vue-components.es7.js";
|
|
7
|
-
import { default as
|
|
8
|
-
import { default as
|
|
7
|
+
import { default as h } from "./vue-components.es8.js";
|
|
8
|
+
import { default as S } from "./vue-components.es9.js";
|
|
9
9
|
import { useOnClose as M, usePreventClose as T } from "./vue-components.es11.js";
|
|
10
10
|
import { createUseFormWithCustomInput as y } from "./vue-components.es13.js";
|
|
11
11
|
export {
|
|
12
12
|
a as CommandButton,
|
|
13
13
|
r as Dialog,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
I as OmegaInput,
|
|
15
|
+
h as OmegaTaggedUnion,
|
|
16
|
+
S as OmegaTaggedUnionInternal,
|
|
17
17
|
c as OmegaVuetifyInput,
|
|
18
18
|
n as createMeta,
|
|
19
19
|
y as createUseFormWithCustomInput,
|
|
20
20
|
u as duplicateSchema,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
d as
|
|
25
|
-
s as
|
|
21
|
+
f as generateInputStandardSchemaFromFieldMeta,
|
|
22
|
+
l as generateMetaFromSchema,
|
|
23
|
+
p as getInputType,
|
|
24
|
+
d as isNullableOrUndefined,
|
|
25
|
+
s as nullableInput,
|
|
26
|
+
x as useOmegaForm,
|
|
26
27
|
M as useOnClose,
|
|
27
28
|
T as usePreventClose
|
|
28
29
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.7",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@mdi/js": "^7.4.47",
|
|
6
6
|
"effect": "^3.18.0",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"highlight.js": "^11.11.1",
|
|
54
54
|
"mitt": "^3.0.1",
|
|
55
55
|
"vue3-highlightjs": "^1.0.5",
|
|
56
|
-
"effect-app": "
|
|
57
|
-
"
|
|
56
|
+
"@effect-app/vue": "2.92.2",
|
|
57
|
+
"effect-app": "3.12.0"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "pnpm build:run",
|
|
@@ -321,7 +321,7 @@ const getNullableOrUndefined = (property: S.AST.AST) => {
|
|
|
321
321
|
)
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
const isNullableOrUndefined = (property: false | S.AST.AST | undefined) => {
|
|
324
|
+
export const isNullableOrUndefined = (property: false | S.AST.AST | undefined) => {
|
|
325
325
|
if (!property || !S.AST.isUnion(property)) return false
|
|
326
326
|
if (property.types.find((_) => _._tag === "UndefinedKeyword")) {
|
|
327
327
|
return "undefined"
|
|
@@ -11,7 +11,7 @@ import { MergedInputProps } from "./InputProps"
|
|
|
11
11
|
import OmegaArray from "./OmegaArray.vue"
|
|
12
12
|
import OmegaAutoGen from "./OmegaAutoGen.vue"
|
|
13
13
|
import OmegaErrorsInternal from "./OmegaErrorsInternal.vue"
|
|
14
|
-
import { BaseProps, DefaultTypeProps, FieldPath, type FormProps, generateMetaFromSchema, type MetaRecord, type NestedKeyOf, OmegaArrayProps, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState } from "./OmegaFormStuff"
|
|
14
|
+
import { BaseProps, DefaultTypeProps, FieldPath, type FormProps, generateMetaFromSchema, isNullableOrUndefined, type MetaRecord, type NestedKeyOf, OmegaArrayProps, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState } from "./OmegaFormStuff"
|
|
15
15
|
import OmegaInput from "./OmegaInput.vue"
|
|
16
16
|
import OmegaTaggedUnion from "./OmegaTaggedUnion.vue"
|
|
17
17
|
import OmegaForm from "./OmegaWrapper.vue"
|
|
@@ -768,6 +768,22 @@ export const useOmegaForm = <
|
|
|
768
768
|
try {
|
|
769
769
|
const instance = schemaObj.make({})
|
|
770
770
|
// For ExtendedClass, the instance is already in the correct encoded format
|
|
771
|
+
// But we need to check for nullable fields that may have been set to undefined
|
|
772
|
+
// instead of null, and fix them
|
|
773
|
+
if (schemaObj?.fields && typeof schemaObj.fields === "object") {
|
|
774
|
+
for (const [key, fieldSchema] of Object.entries(schemaObj.fields)) {
|
|
775
|
+
// Only fix fields that are undefined in the instance
|
|
776
|
+
if (instance[key] === undefined) {
|
|
777
|
+
const ast = (fieldSchema as any).ast
|
|
778
|
+
const nullableOrUndefined = isNullableOrUndefined(ast)
|
|
779
|
+
if (nullableOrUndefined === "null") {
|
|
780
|
+
instance[key] = null
|
|
781
|
+
} else if (nullableOrUndefined === "undefined") {
|
|
782
|
+
instance[key] = undefined
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
771
787
|
return instance
|
|
772
788
|
} catch {
|
|
773
789
|
// If make() fails, fall through to manual extraction
|
|
@@ -813,12 +829,22 @@ export const useOmegaForm = <
|
|
|
813
829
|
if ((fieldSchema as any)?.ast?.defaultValue) {
|
|
814
830
|
try {
|
|
815
831
|
const defaultValue = (fieldSchema as any).ast.defaultValue()
|
|
816
|
-
|
|
817
|
-
result[key] = defaultValue
|
|
818
|
-
}
|
|
832
|
+
result[key] = defaultValue
|
|
819
833
|
} catch {
|
|
820
834
|
// Silently ignore if defaultValue() throws
|
|
821
835
|
}
|
|
836
|
+
} else {
|
|
837
|
+
// TODO Should we put to null/undefined only leaves?
|
|
838
|
+
const ast = (fieldSchema as any).ast
|
|
839
|
+
const nullableOrUndefined = isNullableOrUndefined(ast)
|
|
840
|
+
switch (nullableOrUndefined) {
|
|
841
|
+
case "null":
|
|
842
|
+
result[key] = null
|
|
843
|
+
break
|
|
844
|
+
case "undefined":
|
|
845
|
+
result[key] = undefined
|
|
846
|
+
break
|
|
847
|
+
}
|
|
822
848
|
}
|
|
823
849
|
|
|
824
850
|
// Recursively check nested fields for structs and unions
|
|
@@ -847,7 +873,7 @@ export const useOmegaForm = <
|
|
|
847
873
|
// First try to use schema.make() if available
|
|
848
874
|
// Note: Partial schemas don't have .make() method yet (https://github.com/Effect-TS/effect/issues/4222)
|
|
849
875
|
const decoded = (schema as any).make(defaultValues)
|
|
850
|
-
result = S.encodeSync(partialRecursive(schema))(decoded)
|
|
876
|
+
result = S.encodeSync(partialRecursive(extractDefaultsFromAST(schema)))(decoded)
|
|
851
877
|
} catch (error) {
|
|
852
878
|
// If make() fails, try to extract defaults from AST
|
|
853
879
|
if (window.location.hostname === "localhost") {
|