@effect-app/vue-components 2.7.6 → 2.7.8
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/vue-components.es10.js +137 -127
- package/dist/vue-components.es12.js +39 -37
- package/dist/vue-components.es22.js +1 -1
- package/dist/vue-components.es23.js +1 -1
- package/dist/vue-components.es36.js +1 -1
- package/dist/vue-components.es40.js +4 -23
- package/dist/vue-components.es41.js +23 -5
- package/dist/vue-components.es42.js +5 -21
- package/dist/vue-components.es43.js +16 -25
- package/dist/vue-components.es44.js +23 -15
- package/dist/vue-components.es45.js +17 -7
- package/dist/vue-components.es46.js +12 -5
- package/dist/vue-components.es47.js +5 -19
- package/dist/vue-components.es48.js +19 -9
- package/dist/vue-components.es49.js +9 -31
- package/dist/vue-components.es50.js +25 -42
- package/dist/vue-components.es51.js +38 -16
- package/dist/vue-components.es52.js +26 -11
- package/dist/vue-components.es53.js +11 -4
- package/dist/vue-components.es54.js +1 -1
- package/dist/vue-components.es56.js +1 -1
- package/dist/vue-components.es58.js +3 -3
- package/dist/vue-components.es59.js +1 -1
- package/package.json +3 -3
- package/src/components/OmegaForm/OmegaFormStuff.ts +6 -1
- package/src/components/OmegaForm/useOmegaForm.ts +25 -4
|
@@ -1,151 +1,159 @@
|
|
|
1
|
-
import { useForm as
|
|
2
|
-
import { Data as
|
|
3
|
-
import { runtimeFiberAsPromise as
|
|
4
|
-
import { isObject as
|
|
5
|
-
import { computed as V, onUnmounted as W, onMounted as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { generateMetaFromSchema as
|
|
1
|
+
import { useForm as z } from "@tanstack/vue-form";
|
|
2
|
+
import { Data as Q, S, 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 V, 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
10
|
import oe from "./vue-components.es6.js";
|
|
11
11
|
import ie from "./vue-components.es8.js";
|
|
12
12
|
import ae from "./vue-components.es21.js";
|
|
13
|
-
import { trace as
|
|
14
|
-
import { context as
|
|
15
|
-
const
|
|
16
|
-
const i =
|
|
13
|
+
import { trace as q } from "./vue-components.es22.js";
|
|
14
|
+
import { context as T } from "./vue-components.es23.js";
|
|
15
|
+
const A = (c) => {
|
|
16
|
+
const i = c.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 l = S.make(f);
|
|
20
|
+
return A(l).ast;
|
|
21
|
+
}), p = {
|
|
22
22
|
...i,
|
|
23
23
|
types: o
|
|
24
24
|
};
|
|
25
|
-
return
|
|
25
|
+
return S.make(p);
|
|
26
26
|
}
|
|
27
27
|
if (i._tag === "Transformation") {
|
|
28
|
-
const o =
|
|
28
|
+
const o = S.make(i.from), p = S.make(i.to), f = A(o), l = A(p), d = {
|
|
29
29
|
...i,
|
|
30
|
-
from:
|
|
31
|
-
to:
|
|
30
|
+
from: f.ast,
|
|
31
|
+
to: l.ast
|
|
32
32
|
};
|
|
33
|
-
return
|
|
33
|
+
return S.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 l = f.type;
|
|
38
|
+
let d = l;
|
|
39
|
+
if (l._tag === "TypeLiteral" || l._tag === "Union" || l._tag === "Transformation") {
|
|
40
|
+
const k = S.make(l);
|
|
41
|
+
d = A(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 S.make(p);
|
|
53
53
|
}
|
|
54
|
-
return
|
|
54
|
+
return c;
|
|
55
55
|
};
|
|
56
|
-
class le extends
|
|
56
|
+
class le extends Q.TaggedError("FormErrors") {
|
|
57
57
|
}
|
|
58
|
-
const M = (
|
|
58
|
+
const M = (c) => function(o) {
|
|
59
59
|
return {
|
|
60
60
|
render() {
|
|
61
|
-
return
|
|
62
|
-
form:
|
|
61
|
+
return B(o, {
|
|
62
|
+
form: c,
|
|
63
63
|
...this.$attrs
|
|
64
64
|
}, this.$slots);
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
}, ce = (
|
|
67
|
+
}, ce = (c) => function(o) {
|
|
68
68
|
return {
|
|
69
69
|
setup() {
|
|
70
|
-
const { fieldMap:
|
|
71
|
-
const
|
|
72
|
-
Object.entries(
|
|
73
|
-
([
|
|
70
|
+
const { fieldMap: p, form: f } = c, l = f.useStore((v) => v.errors), d = f.useStore((v) => v.fieldMeta), k = f.useStore((v) => v.errorMap), h = V(() => {
|
|
71
|
+
const v = g.filterMap(
|
|
72
|
+
Object.entries(d.value),
|
|
73
|
+
([x, w]) => {
|
|
74
74
|
const a = w.errors ?? [];
|
|
75
|
-
if (!a.length) return
|
|
76
|
-
const
|
|
77
|
-
return
|
|
78
|
-
label:
|
|
79
|
-
inputId:
|
|
75
|
+
if (!a.length) return D.none();
|
|
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 [
|
|
86
|
+
for (const [x, w] of Object.entries(k.value.onSubmit))
|
|
87
87
|
if (g.isArray(w) && w.length)
|
|
88
88
|
for (const a of w) {
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
91
|
-
const
|
|
92
|
-
if (!
|
|
89
|
+
const y = a;
|
|
90
|
+
if (y?.path && g.isArray(y.path) && y.path.length) {
|
|
91
|
+
const _ = y.path.join(".");
|
|
92
|
+
if (!p.value.has(_)) {
|
|
93
93
|
F.push({
|
|
94
|
-
label:
|
|
95
|
-
inputId:
|
|
96
|
-
errors: [
|
|
94
|
+
label: _,
|
|
95
|
+
inputId: _,
|
|
96
|
+
errors: [y.message].filter(Boolean)
|
|
97
97
|
});
|
|
98
98
|
break;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
return [...
|
|
103
|
+
return [...v, ...F];
|
|
104
104
|
});
|
|
105
105
|
return {
|
|
106
|
-
generalErrors:
|
|
106
|
+
generalErrors: l,
|
|
107
107
|
errors: h
|
|
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
|
+
}, _e = (c, i, o) => {
|
|
119
|
+
if (!c) throw new Error("Schema is required");
|
|
120
|
+
const p = S.standardSchemaV1(c), f = S.decode(c), { meta: l } = se(c), d = V(() => {
|
|
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(l);
|
|
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 h(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] = {}), h(e[r], t[r])) : e[r] = t[r];
|
|
134
134
|
return e;
|
|
135
135
|
}
|
|
136
|
-
const
|
|
136
|
+
const v = (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, U = J(m);
|
|
145
|
+
U === "null" ? n[s] = null : U === "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) => S.make(n)) : null);
|
|
144
152
|
if (r && g.isArray(r)) {
|
|
145
153
|
for (const n of r) {
|
|
146
|
-
const s =
|
|
154
|
+
const s = v(n);
|
|
147
155
|
if (Object.keys(s).length > 0 && n?.fields && Object.entries(n.fields).some(
|
|
148
|
-
([
|
|
156
|
+
([m, U]) => m === "_tag" || m === "type" || m === "kind" ? U?.ast?.defaultValue !== void 0 : !1
|
|
149
157
|
))
|
|
150
158
|
return s;
|
|
151
159
|
}
|
|
@@ -155,13 +163,13 @@ const M = (l) => 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
|
-
t[n] =
|
|
166
|
+
const m = s.ast.defaultValue();
|
|
167
|
+
t[n] = m;
|
|
160
168
|
} catch {
|
|
161
169
|
}
|
|
162
170
|
else {
|
|
163
|
-
const
|
|
164
|
-
switch (
|
|
171
|
+
const m = s?.ast;
|
|
172
|
+
switch (J(m)) {
|
|
165
173
|
case "null":
|
|
166
174
|
t[n] = null;
|
|
167
175
|
break;
|
|
@@ -170,26 +178,28 @@ const M = (l) => function(o) {
|
|
|
170
178
|
break;
|
|
171
179
|
}
|
|
172
180
|
}
|
|
173
|
-
const
|
|
174
|
-
Object.keys(
|
|
181
|
+
const u = v(s);
|
|
182
|
+
Object.keys(u).length > 0 && (t[n] && typeof t[n] == "object" ? Object.assign(t[n], u) : t[n] || (t[n] = u));
|
|
175
183
|
}
|
|
176
184
|
return t;
|
|
177
185
|
}, F = (e = {}) => {
|
|
178
186
|
let t = {};
|
|
179
187
|
try {
|
|
180
|
-
|
|
181
|
-
|
|
188
|
+
let r = c;
|
|
189
|
+
r?.ast?._tag === "Refinement" && r?.from && (r = r.from);
|
|
190
|
+
const n = r.make(e);
|
|
191
|
+
t = S.encodeSync(A(r))(n);
|
|
182
192
|
} catch (r) {
|
|
183
193
|
window.location.hostname === "localhost" && console.warn("schema.make() failed, extracting defaults from AST:", r);
|
|
184
194
|
try {
|
|
185
|
-
const n =
|
|
186
|
-
t =
|
|
195
|
+
const n = v(c);
|
|
196
|
+
t = S.encodeSync(A(c))(n);
|
|
187
197
|
} catch (n) {
|
|
188
198
|
window.location.hostname === "localhost" && console.warn("Could not extract defaults from AST:", n);
|
|
189
199
|
}
|
|
190
200
|
}
|
|
191
201
|
return h(t, e);
|
|
192
|
-
},
|
|
202
|
+
}, x = V(() => {
|
|
193
203
|
let e;
|
|
194
204
|
const t = o?.persistency;
|
|
195
205
|
if (
|
|
@@ -200,16 +210,16 @@ const M = (l) => function(o) {
|
|
|
200
210
|
if (r)
|
|
201
211
|
try {
|
|
202
212
|
const n = JSON.parse(
|
|
203
|
-
r.getItem(
|
|
213
|
+
r.getItem(d.value) || "{}"
|
|
204
214
|
);
|
|
205
|
-
r.removeItem(
|
|
215
|
+
r.removeItem(d.value), e = n;
|
|
206
216
|
} catch (n) {
|
|
207
217
|
console.error(n);
|
|
208
218
|
}
|
|
209
219
|
}
|
|
210
220
|
if (t?.policies && t.policies.includes("querystring"))
|
|
211
221
|
try {
|
|
212
|
-
const n = new URLSearchParams(window.location.search).get(
|
|
222
|
+
const n = new URLSearchParams(window.location.search).get(d.value);
|
|
213
223
|
k(), n && (e = h(e || {}, JSON.parse(n)));
|
|
214
224
|
} catch (r) {
|
|
215
225
|
console.error(r);
|
|
@@ -217,113 +227,113 @@ const M = (l) => function(o) {
|
|
|
217
227
|
return e ??= {}, F(
|
|
218
228
|
o?.persistency?.overrideDefaultValues ? h(i?.defaultValues || {}, e) : h(e, i?.defaultValues || {})
|
|
219
229
|
);
|
|
220
|
-
}), w = (e, t) => e ?
|
|
230
|
+
}), w = (e, t) => e ? T.with(q.setSpan(T.active(), e), t) : t(), a = z({
|
|
221
231
|
...i,
|
|
222
232
|
validators: {
|
|
223
|
-
onSubmit:
|
|
233
|
+
onSubmit: p,
|
|
224
234
|
...i?.validators || {}
|
|
225
235
|
},
|
|
226
236
|
onSubmit: i?.onSubmit ? ({ formApi: e, meta: t, value: r }) => w(t?.currentSpan, async () => {
|
|
227
|
-
const n = await b.runPromise(
|
|
237
|
+
const n = await b.runPromise(f(r)), s = i.onSubmit({
|
|
228
238
|
formApi: e,
|
|
229
239
|
meta: t,
|
|
230
240
|
value: n
|
|
231
241
|
});
|
|
232
|
-
return O.isFiber(s) && O.isRuntimeFiber(s) ? await
|
|
242
|
+
return O.isFiber(s) && O.isRuntimeFiber(s) ? await X(s) : b.isEffect(s) ? await b.runPromise(
|
|
233
243
|
s.pipe(
|
|
234
244
|
// meta?.currentSpan
|
|
235
245
|
// ? Effect.withParentSpan(meta.currentSpan)
|
|
236
246
|
// : (_) => _,
|
|
237
|
-
b.flatMap((
|
|
247
|
+
b.flatMap((u) => O.join(u))
|
|
238
248
|
)
|
|
239
249
|
) : s;
|
|
240
250
|
}) : void 0,
|
|
241
|
-
defaultValues:
|
|
242
|
-
}),
|
|
243
|
-
Object.keys(
|
|
251
|
+
defaultValues: x.value
|
|
252
|
+
}), y = () => {
|
|
253
|
+
Object.keys(l).forEach((e) => {
|
|
244
254
|
a.setFieldValue(e, void 0);
|
|
245
255
|
});
|
|
246
|
-
},
|
|
256
|
+
}, _ = (e) => e.reduce((t, r) => {
|
|
247
257
|
const n = r.split(".");
|
|
248
|
-
return n.reduce((s,
|
|
258
|
+
return n.reduce((s, u, m) => (m === n.length - 1 ? s[u] = a.getFieldValue(r) : s[u] = s[u] ?? {}, s[u]), t), t;
|
|
249
259
|
}, {}), j = (e) => {
|
|
250
260
|
if (e) {
|
|
251
261
|
if (g.isArray(e.keys))
|
|
252
|
-
return
|
|
262
|
+
return _(e.keys);
|
|
253
263
|
if (g.isArray(e.banKeys)) {
|
|
254
|
-
const t = Object.keys(
|
|
255
|
-
return
|
|
264
|
+
const t = Object.keys(l).filter((r) => e.banKeys?.includes(r));
|
|
265
|
+
return _(t);
|
|
256
266
|
}
|
|
257
267
|
return a.store.state.values;
|
|
258
268
|
}
|
|
259
|
-
},
|
|
269
|
+
}, P = () => {
|
|
260
270
|
const e = o?.persistency;
|
|
261
271
|
if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
|
|
262
272
|
const t = e.policies.includes("local") ? localStorage : sessionStorage;
|
|
263
273
|
if (!t) return;
|
|
264
274
|
const r = j(e);
|
|
265
|
-
return t.setItem(
|
|
275
|
+
return t.setItem(d.value, JSON.stringify(r));
|
|
266
276
|
}
|
|
267
|
-
},
|
|
277
|
+
}, I = () => {
|
|
268
278
|
const e = o?.persistency;
|
|
269
279
|
if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
|
|
270
280
|
const t = j(e), r = new URLSearchParams(window.location.search);
|
|
271
|
-
r.set(
|
|
281
|
+
r.set(d.value, JSON.stringify(t));
|
|
272
282
|
const n = new URL(window.location.href);
|
|
273
283
|
n.search = r.toString(), window.history.replaceState({}, "", n.toString());
|
|
274
284
|
}
|
|
275
|
-
},
|
|
285
|
+
}, $ = (e) => {
|
|
276
286
|
a.store.state.isDirty && e.preventDefault();
|
|
277
287
|
};
|
|
278
|
-
if (W(
|
|
279
|
-
window.addEventListener("beforeunload",
|
|
280
|
-
}),
|
|
281
|
-
window.removeEventListener("beforeunload",
|
|
288
|
+
if (W(P), Z(() => {
|
|
289
|
+
window.addEventListener("beforeunload", P), window.addEventListener("blur", I), o?.preventWindowExit && o.preventWindowExit !== "nope" && window.addEventListener("beforeunload", $);
|
|
290
|
+
}), C(() => {
|
|
291
|
+
window.removeEventListener("beforeunload", P), window.removeEventListener("blur", I), o?.preventWindowExit && o.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", $);
|
|
282
292
|
}), o?.preventWindowExit === "prevent-and-reset") {
|
|
283
293
|
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);
|
|
284
|
-
H([e, t], ([s,
|
|
285
|
-
|
|
294
|
+
H([e, t], ([s, u], [m]) => {
|
|
295
|
+
m && !s && u > 0 && r.value && a.reset(n.value);
|
|
286
296
|
});
|
|
287
297
|
}
|
|
288
|
-
const
|
|
298
|
+
const N = (e) => b.currentSpan.pipe(
|
|
289
299
|
b.option,
|
|
290
300
|
b.flatMap(
|
|
291
|
-
(t) => b.promise(() => a.handleSubmit(
|
|
301
|
+
(t) => b.promise(() => a.handleSubmit(D.isSome(t) ? { currentSpan: t.value, ...e } : e))
|
|
292
302
|
)
|
|
293
|
-
),
|
|
303
|
+
), K = (e) => e?.checkErrors ? N(e?.meta).pipe(b.flatMap(b.fnUntraced(function* () {
|
|
294
304
|
const t = a.getAllErrors();
|
|
295
305
|
if (Object.keys(t.fields).length || t.form.errors.length)
|
|
296
306
|
return yield* new le({ form: t.form, fields: t.fields });
|
|
297
|
-
}))) :
|
|
307
|
+
}))) : N(e?.meta), G = a.handleSubmit, L = ee(/* @__PURE__ */ new Map()), E = Object.assign(a, {
|
|
298
308
|
i18nNamespace: o?.i18nNamespace,
|
|
299
309
|
ignorePreventCloseEvents: o?.ignorePreventCloseEvents,
|
|
300
|
-
meta:
|
|
301
|
-
clear:
|
|
310
|
+
meta: l,
|
|
311
|
+
clear: y,
|
|
302
312
|
handleSubmit: (e) => {
|
|
303
|
-
const t =
|
|
304
|
-
return
|
|
313
|
+
const t = q.getSpan(T.active());
|
|
314
|
+
return G({ currentSpan: t, ...e });
|
|
305
315
|
},
|
|
306
316
|
// /** @experimental */
|
|
307
|
-
handleSubmitEffect:
|
|
317
|
+
handleSubmitEffect: K,
|
|
308
318
|
registerField: (e) => {
|
|
309
|
-
H(e, (t) =>
|
|
319
|
+
H(e, (t) => L.value.set(t.name, { label: t.label, id: t.id }), { immediate: !0 }), W(() => L.value.delete(e.value.name));
|
|
310
320
|
}
|
|
311
|
-
}),
|
|
321
|
+
}), R = { form: E, fieldMap: L };
|
|
312
322
|
return Object.assign(E, {
|
|
313
323
|
// Type-level properties for performance optimization (not used at runtime)
|
|
314
324
|
_paths: void 0,
|
|
315
325
|
_keys: void 0,
|
|
316
|
-
errorContext:
|
|
326
|
+
errorContext: R,
|
|
317
327
|
Form: M(E)(ae),
|
|
318
328
|
Input: M(E)(o?.input ?? oe),
|
|
319
329
|
TaggedUnion: M(E)(ie),
|
|
320
330
|
Field: a.Field,
|
|
321
|
-
Errors: ce(
|
|
322
|
-
Array: M(E)(
|
|
323
|
-
AutoGen: M(E)(
|
|
331
|
+
Errors: ce(R)(ne),
|
|
332
|
+
Array: M(E)(te),
|
|
333
|
+
AutoGen: M(E)(re)
|
|
324
334
|
});
|
|
325
335
|
};
|
|
326
336
|
export {
|
|
327
337
|
le as FormErrors,
|
|
328
|
-
|
|
338
|
+
_e as useOmegaForm
|
|
329
339
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { S as n, Option as L } from "effect-app";
|
|
2
|
-
import { getMetadataFromSchema as
|
|
3
|
-
import { useIntl as N, getTransformationFrom as
|
|
4
|
-
const
|
|
2
|
+
import { getMetadataFromSchema as q } from "@effect-app/vue/form";
|
|
3
|
+
import { useIntl as N, getTransformationFrom as w } from "./vue-components.es3.js";
|
|
4
|
+
const k = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKeyword" || i === n.Null.ast), g = (e) => !e || !n.AST.isUnion(e) ? !1 : e.types.find((i) => i._tag === "UndefinedKeyword") ? "undefined" : e.types.find((i) => i === n.Null.ast) ? "null" : !1, _ = (e) => {
|
|
5
5
|
const i = [];
|
|
6
6
|
for (const t of e)
|
|
7
7
|
if (n.AST.isUnion(t)) {
|
|
@@ -24,14 +24,14 @@ const E = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKe
|
|
|
24
24
|
});
|
|
25
25
|
if (c) {
|
|
26
26
|
for (const r of c) {
|
|
27
|
-
const p = i ? `${i}.${r.name.toString()}` : r.name.toString(), s =
|
|
27
|
+
const p = i ? `${i}.${r.name.toString()}` : r.name.toString(), s = g(r.type);
|
|
28
28
|
let a;
|
|
29
29
|
e._isNullableDiscriminatedUnion && r.name.toString() === "_tag" || e.required === !1 ? a = !1 : a = !s;
|
|
30
30
|
const f = r.type;
|
|
31
31
|
if (n.AST.isUnion(r.type)) {
|
|
32
32
|
const S = _(r.type.types).filter(
|
|
33
33
|
(l) => l._tag !== "UndefinedKeyword" && l !== n.Null.ast
|
|
34
|
-
).map(
|
|
34
|
+
).map(w);
|
|
35
35
|
if (S.some(
|
|
36
36
|
(l) => "propertySignatures" in l
|
|
37
37
|
)) {
|
|
@@ -68,28 +68,28 @@ const E = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKe
|
|
|
68
68
|
}, m.rest && m.rest.length > 0) {
|
|
69
69
|
const T = m.rest[0];
|
|
70
70
|
if (T.type._tag === "TypeLiteral" && "propertySignatures" in T.type)
|
|
71
|
-
for (const
|
|
72
|
-
const h = `${p}.${
|
|
71
|
+
for (const d of T.type.propertySignatures) {
|
|
72
|
+
const h = `${p}.${d.name.toString()}`, v = u({
|
|
73
73
|
parent: h,
|
|
74
|
-
property:
|
|
74
|
+
property: d.type,
|
|
75
75
|
meta: {
|
|
76
|
-
required: !d
|
|
77
|
-
nullableOrUndefined: d
|
|
76
|
+
required: !g(d.type),
|
|
77
|
+
nullableOrUndefined: g(d.type)
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
|
-
if (v && typeof v == "object" && "type" in v && (o[h] = v, v.type === "multiple" && n.AST.isTupleType(
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
for (const x of
|
|
84
|
-
const A = `${h}.${x.name.toString()}`,
|
|
80
|
+
if (v && typeof v == "object" && "type" in v && (o[h] = v, v.type === "multiple" && n.AST.isTupleType(d.type) && d.type.rest && d.type.rest.length > 0)) {
|
|
81
|
+
const O = d.type.rest[0];
|
|
82
|
+
if (O.type._tag === "TypeLiteral" && "propertySignatures" in O.type)
|
|
83
|
+
for (const x of O.type.propertySignatures) {
|
|
84
|
+
const A = `${h}.${x.name.toString()}`, U = u({
|
|
85
85
|
parent: A,
|
|
86
86
|
property: x.type,
|
|
87
87
|
meta: {
|
|
88
|
-
required: !
|
|
89
|
-
nullableOrUndefined:
|
|
88
|
+
required: !g(x.type),
|
|
89
|
+
nullableOrUndefined: g(x.type)
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
|
-
|
|
92
|
+
U && typeof U == "object" && "type" in U && (o[A] = U);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -122,31 +122,31 @@ const E = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKe
|
|
|
122
122
|
const m = y.type.rest[0].type;
|
|
123
123
|
if (m._tag === "TypeLiteral" && "propertySignatures" in m)
|
|
124
124
|
for (const T of m.propertySignatures) {
|
|
125
|
-
const
|
|
126
|
-
parent:
|
|
125
|
+
const d = `${l}.${T.name.toString()}`, h = u({
|
|
126
|
+
parent: d,
|
|
127
127
|
property: T.type,
|
|
128
128
|
meta: {
|
|
129
|
-
required: !
|
|
130
|
-
nullableOrUndefined:
|
|
129
|
+
required: !g(T.type),
|
|
130
|
+
nullableOrUndefined: g(T.type)
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
|
-
o[
|
|
133
|
+
o[d] = h;
|
|
134
134
|
}
|
|
135
135
|
else
|
|
136
136
|
o[l] = {
|
|
137
137
|
type: "multiple",
|
|
138
138
|
members: y.type.elements,
|
|
139
139
|
rest: y.type.rest,
|
|
140
|
-
required: !
|
|
141
|
-
nullableOrUndefined:
|
|
140
|
+
required: !g(y.type),
|
|
141
|
+
nullableOrUndefined: g(y.type)
|
|
142
142
|
};
|
|
143
143
|
} else {
|
|
144
144
|
const m = u({
|
|
145
145
|
parent: l,
|
|
146
146
|
property: y.type,
|
|
147
147
|
meta: {
|
|
148
|
-
required: !
|
|
149
|
-
nullableOrUndefined:
|
|
148
|
+
required: !g(y.type),
|
|
149
|
+
nullableOrUndefined: g(y.type)
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
152
|
o[l] = m;
|
|
@@ -167,7 +167,7 @@ const E = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKe
|
|
|
167
167
|
meta: {
|
|
168
168
|
// an empty string is valid for a S.String field, so we should not mark it as required
|
|
169
169
|
// TODO: handle this better via the createMeta minLength parsing
|
|
170
|
-
required: a && (r.type._tag !== "StringKeyword" ||
|
|
170
|
+
required: a && (r.type._tag !== "StringKeyword" || q(r.type).minLength),
|
|
171
171
|
nullableOrUndefined: s
|
|
172
172
|
}
|
|
173
173
|
});
|
|
@@ -177,7 +177,7 @@ const E = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKe
|
|
|
177
177
|
return o;
|
|
178
178
|
}
|
|
179
179
|
if (t) {
|
|
180
|
-
const r =
|
|
180
|
+
const r = k(t);
|
|
181
181
|
if (Object.hasOwnProperty.call(e, "required") || (e.required = !r), n.AST.isUnion(t)) {
|
|
182
182
|
const s = _(t.types), a = s.find(
|
|
183
183
|
(f) => f._tag !== "UndefinedKeyword" && f !== n.Null.ast
|
|
@@ -222,12 +222,12 @@ const E = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKe
|
|
|
222
222
|
), e);
|
|
223
223
|
}
|
|
224
224
|
return o;
|
|
225
|
-
},
|
|
225
|
+
}, M = (e) => {
|
|
226
226
|
const i = e.ast, t = {};
|
|
227
227
|
if (i._tag === "Transformation" || i._tag === "Refinement")
|
|
228
|
-
return
|
|
228
|
+
return M(n.make(i.from));
|
|
229
229
|
if (i._tag === "Union") {
|
|
230
|
-
const r = (i.types || []).filter((s) => s._tag !== "UndefinedKeyword" && s !== n.Null.ast).map(
|
|
230
|
+
const r = (i.types || []).filter((s) => s._tag !== "UndefinedKeyword" && s !== n.Null.ast).map(w);
|
|
231
231
|
if (r.every((s) => s._tag === "TypeLiteral" && "propertySignatures" in s) && r.length > 0) {
|
|
232
232
|
const s = [];
|
|
233
233
|
for (const a of r)
|
|
@@ -264,7 +264,7 @@ const E = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKe
|
|
|
264
264
|
}
|
|
265
265
|
return t;
|
|
266
266
|
}, P = (e) => n.extend(e, n.Struct({})), j = (e) => {
|
|
267
|
-
const i =
|
|
267
|
+
const i = M(e);
|
|
268
268
|
return { schema: e, meta: i };
|
|
269
269
|
}, F = (e) => {
|
|
270
270
|
const { trans: i } = N();
|
|
@@ -341,10 +341,12 @@ const E = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKe
|
|
|
341
341
|
case "boolean":
|
|
342
342
|
t = n.Boolean;
|
|
343
343
|
break;
|
|
344
|
-
// todo: switch must be exhaustive or have default case, otherwise falls through with schema undefined.
|
|
345
344
|
case "unknown":
|
|
346
345
|
t = n.Unknown;
|
|
347
346
|
break;
|
|
347
|
+
default:
|
|
348
|
+
console.warn(`Unhandled field type: ${e}`), t = n.Unknown;
|
|
349
|
+
break;
|
|
348
350
|
}
|
|
349
351
|
return e.required ? t.pipe(
|
|
350
352
|
n.annotations({
|
|
@@ -356,7 +358,7 @@ const E = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKe
|
|
|
356
358
|
decode: (t) => t ?? i(),
|
|
357
359
|
encode: (t) => t
|
|
358
360
|
})
|
|
359
|
-
),
|
|
361
|
+
), E = [
|
|
360
362
|
"button",
|
|
361
363
|
"checkbox",
|
|
362
364
|
"color",
|
|
@@ -372,13 +374,13 @@ const E = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKe
|
|
|
372
374
|
"text",
|
|
373
375
|
"time",
|
|
374
376
|
"url"
|
|
375
|
-
], R = (e) =>
|
|
377
|
+
], R = (e) => E.includes(e) ? e : "text";
|
|
376
378
|
export {
|
|
377
379
|
u as createMeta,
|
|
378
380
|
P as duplicateSchema,
|
|
379
381
|
F as generateInputStandardSchemaFromFieldMeta,
|
|
380
382
|
j as generateMetaFromSchema,
|
|
381
383
|
R as getInputType,
|
|
382
|
-
|
|
384
|
+
g as isNullableOrUndefined,
|
|
383
385
|
D as nullableInput
|
|
384
386
|
};
|