@effect-app/vue-components 0.8.1 → 0.8.2
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.es27.js +1 -1
- package/dist/vue-components.es7.js +19 -26
- package/dist/vue-components.es9.js +88 -60
- package/package.json +1 -1
- package/src/components/OmegaForm/OmegaErrorsContext.ts +2 -6
- package/src/components/OmegaForm/OmegaFormStuff.ts +39 -4
- package/src/components/OmegaForm/OmegaInputVuetify.vue +5 -1
|
@@ -71,7 +71,7 @@ const b = /* @__PURE__ */ P({
|
|
|
71
71
|
}, e.$attrs, {
|
|
72
72
|
"model-value": e.vuetifyValue,
|
|
73
73
|
"onUpdate:modelValue": r[1] || (r[1] = (p) => {
|
|
74
|
-
e.inputProps.field.handleChange(Number(p));
|
|
74
|
+
p || p === 0 ? e.inputProps.field.handleChange(Number(p)) : e.inputProps.field.handleChange(void 0);
|
|
75
75
|
})
|
|
76
76
|
}), null, 16, ["id", "required", "min", "max", "type", "name", "label", "error-messages", "error", "model-value"])) : l("", !0),
|
|
77
77
|
e.inputProps.type === "select" || e.inputProps.type === "multiple" ? (o(), n(m, i({
|
|
@@ -1,38 +1,31 @@
|
|
|
1
1
|
import { ref as l, computed as p, readonly as v, provide as E, inject as f } from "vue";
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const r = l([]), n = (
|
|
5
|
-
r.value = r.value.filter((d) => d.inputId !==
|
|
6
|
-
}, c = (
|
|
7
|
-
n(
|
|
8
|
-
},
|
|
2
|
+
const s = Symbol();
|
|
3
|
+
function g(o, i, t = "onSubmit") {
|
|
4
|
+
const r = l([]), n = (e) => {
|
|
5
|
+
r.value = r.value.filter((d) => d.inputId !== e);
|
|
6
|
+
}, c = (e) => {
|
|
7
|
+
n(e.inputId), r.value.push(e);
|
|
8
|
+
}, m = () => {
|
|
9
9
|
r.value = [];
|
|
10
|
-
},
|
|
11
|
-
switch (t) {
|
|
12
|
-
case "onChange":
|
|
13
|
-
return !0;
|
|
14
|
-
default:
|
|
15
|
-
return e.value > 0;
|
|
16
|
-
}
|
|
17
|
-
}), s = {
|
|
10
|
+
}, a = p(() => t === "onSubmit" ? o.value > 0 : !0), u = {
|
|
18
11
|
errors: v(r),
|
|
19
12
|
addError: c,
|
|
20
13
|
removeError: n,
|
|
21
|
-
clearErrors:
|
|
22
|
-
showErrors:
|
|
23
|
-
generalErrors:
|
|
14
|
+
clearErrors: m,
|
|
15
|
+
showErrors: a,
|
|
16
|
+
generalErrors: i,
|
|
24
17
|
showErrorsOn: t ?? "onSubmit"
|
|
25
18
|
};
|
|
26
|
-
return E(
|
|
19
|
+
return E(s, u), u;
|
|
27
20
|
}
|
|
28
|
-
function
|
|
29
|
-
const
|
|
30
|
-
if (!
|
|
21
|
+
function O() {
|
|
22
|
+
const o = f(s);
|
|
23
|
+
if (!o)
|
|
31
24
|
throw new Error("useOmegaErrors must be used within an OmegaForm provider");
|
|
32
|
-
return
|
|
25
|
+
return o;
|
|
33
26
|
}
|
|
34
27
|
export {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
s as OmegaErrorsKey,
|
|
29
|
+
g as provideOmegaErrors,
|
|
30
|
+
O as useOmegaErrors
|
|
38
31
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as i, Option as
|
|
2
|
-
import { useIntl as
|
|
3
|
-
const
|
|
1
|
+
import { S as i, Option as g, pipe as y } from "effect-app";
|
|
2
|
+
import { useIntl as v } from "./vue-components.es3.js";
|
|
3
|
+
const x = i.NonEmptyArray(i.String), T = (e) => i.AST.isUnion(e) && e.types.find((t) => t._tag === "UndefinedKeyword" || t === i.Null.ast), h = (e) => !e || !i.AST.isUnion(e) ? !1 : e.types.find((t) => t._tag === "UndefinedKeyword") ? "undefined" : e.types.find((t) => t === i.Null.ast) ? "null" : !1, m = ({ meta: e = {}, parent: t = "", property: n, propertySignatures: r }, u = {}) => {
|
|
4
4
|
if (n && n._tag === "Transformation")
|
|
5
5
|
return m({
|
|
6
6
|
parent: t,
|
|
@@ -12,52 +12,80 @@ const y = i.NonEmptyArray(i.String), v = (e) => i.AST.isUnion(e) && e.types.find
|
|
|
12
12
|
meta: e,
|
|
13
13
|
propertySignatures: n.propertySignatures
|
|
14
14
|
});
|
|
15
|
-
if (
|
|
16
|
-
for (const s of
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
if (r) {
|
|
16
|
+
for (const s of r) {
|
|
17
|
+
const o = t ? `${t}.${s.name.toString()}` : s.name.toString(), a = h(s.type), l = !a, p = s.type;
|
|
18
|
+
if (i.AST.isUnion(s.type)) {
|
|
19
|
+
const d = s.type.types.filter(
|
|
20
|
+
(f) => f._tag !== "UndefinedKeyword" && f !== i.Null.ast
|
|
21
|
+
);
|
|
22
|
+
if (d.some(
|
|
23
|
+
(f) => "propertySignatures" in f
|
|
24
|
+
)) {
|
|
25
|
+
const f = m({
|
|
26
|
+
parent: o,
|
|
27
|
+
property: s.type,
|
|
28
|
+
meta: { required: l, nullableOrUndefined: a }
|
|
29
|
+
});
|
|
30
|
+
u[o] = f;
|
|
31
|
+
for (const c of d)
|
|
32
|
+
"propertySignatures" in c && Object.assign(
|
|
33
|
+
u,
|
|
34
|
+
m({
|
|
35
|
+
parent: o,
|
|
36
|
+
propertySignatures: c.propertySignatures,
|
|
37
|
+
meta: { required: l, nullableOrUndefined: a }
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
} else {
|
|
41
|
+
const f = m({
|
|
42
|
+
parent: o,
|
|
43
|
+
property: s.type,
|
|
44
|
+
meta: { required: l, nullableOrUndefined: a }
|
|
45
|
+
});
|
|
46
|
+
u[o] = f;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if ("propertySignatures" in p)
|
|
22
50
|
Object.assign(
|
|
23
|
-
|
|
51
|
+
u,
|
|
24
52
|
m({
|
|
25
|
-
parent:
|
|
26
|
-
propertySignatures:
|
|
27
|
-
meta: { required:
|
|
53
|
+
parent: o,
|
|
54
|
+
propertySignatures: p.propertySignatures,
|
|
55
|
+
meta: { required: l, nullableOrUndefined: a }
|
|
28
56
|
})
|
|
29
57
|
);
|
|
30
58
|
else {
|
|
31
|
-
const
|
|
32
|
-
parent:
|
|
59
|
+
const d = m({
|
|
60
|
+
parent: o,
|
|
33
61
|
property: s.type,
|
|
34
|
-
meta: { required:
|
|
62
|
+
meta: { required: l, nullableOrUndefined: a }
|
|
35
63
|
});
|
|
36
|
-
|
|
64
|
+
u[o] = d;
|
|
37
65
|
}
|
|
38
66
|
}
|
|
39
|
-
return
|
|
67
|
+
return u;
|
|
40
68
|
}
|
|
41
69
|
if (n) {
|
|
42
|
-
const s =
|
|
70
|
+
const s = T(n);
|
|
43
71
|
if (Object.hasOwnProperty.call(e, "required") || (e.required = !s), i.AST.isUnion(n)) {
|
|
44
|
-
const
|
|
45
|
-
(
|
|
72
|
+
const a = n.types.find(
|
|
73
|
+
(l) => l._tag !== "UndefinedKeyword" && l !== i.Null.ast
|
|
46
74
|
);
|
|
47
|
-
return "propertySignatures" in
|
|
48
|
-
propertySignatures:
|
|
75
|
+
return "propertySignatures" in a ? m({
|
|
76
|
+
propertySignatures: a.propertySignatures,
|
|
49
77
|
parent: t,
|
|
50
78
|
meta: e
|
|
51
79
|
}) : n.types.every(i.AST.isLiteral) ? {
|
|
52
80
|
...e,
|
|
53
81
|
type: "select",
|
|
54
|
-
members: n.types.map((
|
|
82
|
+
members: n.types.map((l) => l.literal)
|
|
55
83
|
} : {
|
|
56
84
|
...e,
|
|
57
85
|
...m({
|
|
58
86
|
parent: t,
|
|
59
87
|
meta: e,
|
|
60
|
-
property:
|
|
88
|
+
property: a
|
|
61
89
|
})
|
|
62
90
|
};
|
|
63
91
|
}
|
|
@@ -68,11 +96,11 @@ const y = i.NonEmptyArray(i.String), v = (e) => i.AST.isUnion(e) && e.types.find
|
|
|
68
96
|
members: n.elements,
|
|
69
97
|
rest: n.rest
|
|
70
98
|
};
|
|
71
|
-
const
|
|
99
|
+
const o = i.AST.getAnnotation(
|
|
72
100
|
n,
|
|
73
101
|
i.AST.JSONSchemaAnnotationId
|
|
74
|
-
).pipe(
|
|
75
|
-
return e = { ...e, ...
|
|
102
|
+
).pipe(g.getOrElse(() => ({})));
|
|
103
|
+
return e = { ...e, ...o }, "from" in n ? m({
|
|
76
104
|
parent: t,
|
|
77
105
|
meta: e,
|
|
78
106
|
property: n.from
|
|
@@ -80,50 +108,50 @@ const y = i.NonEmptyArray(i.String), v = (e) => i.AST.isUnion(e) && e.types.find
|
|
|
80
108
|
n,
|
|
81
109
|
i.AST.TitleAnnotationId
|
|
82
110
|
).pipe(
|
|
83
|
-
|
|
111
|
+
g.getOrElse(() => "unknown")
|
|
84
112
|
), e);
|
|
85
113
|
}
|
|
86
|
-
return
|
|
87
|
-
},
|
|
114
|
+
return u;
|
|
115
|
+
}, S = (e) => {
|
|
88
116
|
const t = e.ast, n = {};
|
|
89
117
|
if (t._tag === "Transformation" || t._tag === "Refinement")
|
|
90
|
-
return
|
|
118
|
+
return S(i.make(t.from));
|
|
91
119
|
if ("propertySignatures" in t) {
|
|
92
|
-
const
|
|
120
|
+
const r = m({
|
|
93
121
|
propertySignatures: t.propertySignatures
|
|
94
122
|
});
|
|
95
|
-
if (Object.values(
|
|
96
|
-
return
|
|
97
|
-
const
|
|
98
|
-
for (const
|
|
99
|
-
const
|
|
100
|
-
s[
|
|
123
|
+
if (Object.values(r).every((s) => s && "type" in s))
|
|
124
|
+
return r;
|
|
125
|
+
const u = (s, o = "") => {
|
|
126
|
+
for (const a in s) {
|
|
127
|
+
const l = o ? `${o}.${a}` : a;
|
|
128
|
+
s[a] && typeof s[a] == "object" && "type" in s[a] ? n[l] = s[a] : s[a] && typeof s[a] == "object" && u(s[a], l);
|
|
101
129
|
}
|
|
102
130
|
};
|
|
103
|
-
|
|
131
|
+
u(r);
|
|
104
132
|
}
|
|
105
133
|
return n;
|
|
106
|
-
},
|
|
107
|
-
const t =
|
|
134
|
+
}, M = (e) => i.extend(e, i.Struct({})), N = (e) => {
|
|
135
|
+
const t = S(e), n = y(
|
|
108
136
|
e.ast,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
({ items:
|
|
137
|
+
g.liftPredicate((r) => r._tag === "Refinement" && "filter" in r),
|
|
138
|
+
g.flatMap((r) => i.AST.getJSONSchemaAnnotation(r)),
|
|
139
|
+
g.filter((r) => "items" in r),
|
|
140
|
+
g.filterMap(
|
|
141
|
+
({ items: r }) => i.decodeUnknownOption(x)(r)
|
|
114
142
|
),
|
|
115
|
-
|
|
143
|
+
g.zipWith(
|
|
116
144
|
i.AST.getMessageAnnotation(e.ast),
|
|
117
|
-
(
|
|
118
|
-
items:
|
|
119
|
-
message:
|
|
145
|
+
(r, u) => ({
|
|
146
|
+
items: r,
|
|
147
|
+
message: u("")
|
|
120
148
|
})
|
|
121
149
|
),
|
|
122
|
-
|
|
150
|
+
g.getOrUndefined
|
|
123
151
|
);
|
|
124
152
|
return { schema: e, meta: t, filterItems: n };
|
|
125
|
-
},
|
|
126
|
-
const { trans: t } =
|
|
153
|
+
}, L = (e) => {
|
|
154
|
+
const { trans: t } = v();
|
|
127
155
|
let n;
|
|
128
156
|
switch (e.type) {
|
|
129
157
|
case "string":
|
|
@@ -205,7 +233,7 @@ const y = i.NonEmptyArray(i.String), v = (e) => i.AST.isUnion(e) && e.types.find
|
|
|
205
233
|
message: () => t("validation.empty")
|
|
206
234
|
})
|
|
207
235
|
) : n = i.NullishOr(n), i.standardSchemaV1(n);
|
|
208
|
-
},
|
|
236
|
+
}, U = (e, t) => i.NullOr(e).pipe(
|
|
209
237
|
i.transform(i.typeSchema(e), {
|
|
210
238
|
decode: (n) => n ?? t(),
|
|
211
239
|
encode: (n) => n
|
|
@@ -213,8 +241,8 @@ const y = i.NonEmptyArray(i.String), v = (e) => i.AST.isUnion(e) && e.types.find
|
|
|
213
241
|
);
|
|
214
242
|
export {
|
|
215
243
|
m as createMeta,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
244
|
+
M as duplicateSchema,
|
|
245
|
+
L as generateInputStandardSchemaFromFieldMeta,
|
|
246
|
+
N as generateMetaFromSchema,
|
|
247
|
+
U as nullableInput
|
|
220
248
|
};
|
package/package.json
CHANGED
|
@@ -45,12 +45,8 @@ export function provideOmegaErrors(
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const showErrors = computed(() => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return true
|
|
51
|
-
default:
|
|
52
|
-
return formSubmissionAttempts.value > 0
|
|
53
|
-
}
|
|
48
|
+
if (showErrorsOn === "onSubmit") return formSubmissionAttempts.value > 0
|
|
49
|
+
return true
|
|
54
50
|
})
|
|
55
51
|
|
|
56
52
|
const context = {
|
|
@@ -257,13 +257,48 @@ export const createMeta = <T = any>(
|
|
|
257
257
|
const nullableOrUndefined = isNullableOrUndefined(p.type)
|
|
258
258
|
const isRequired = !nullableOrUndefined
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
const typeToProcess = p.type
|
|
261
261
|
if (S.AST.isUnion(p.type)) {
|
|
262
|
-
|
|
262
|
+
const nonNullTypes = p.type.types.filter(
|
|
263
263
|
t => t._tag !== "UndefinedKeyword" && t !== S.Null.ast,
|
|
264
|
-
)
|
|
265
|
-
}
|
|
264
|
+
)
|
|
266
265
|
|
|
266
|
+
const hasStructMembers = nonNullTypes.some(
|
|
267
|
+
t => "propertySignatures" in t,
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
if (hasStructMembers) {
|
|
271
|
+
// Create metadata for the parent level (the union itself)
|
|
272
|
+
const parentMeta = createMeta<T>({
|
|
273
|
+
parent: key,
|
|
274
|
+
property: p.type,
|
|
275
|
+
meta: { required: isRequired, nullableOrUndefined },
|
|
276
|
+
})
|
|
277
|
+
acc[key as NestedKeyOf<T>] = parentMeta as FieldMeta
|
|
278
|
+
|
|
279
|
+
// Process each non-null type and merge their metadata
|
|
280
|
+
for (const nonNullType of nonNullTypes) {
|
|
281
|
+
if ("propertySignatures" in nonNullType) {
|
|
282
|
+
Object.assign(
|
|
283
|
+
acc,
|
|
284
|
+
createMeta<T>({
|
|
285
|
+
parent: key,
|
|
286
|
+
propertySignatures: nonNullType.propertySignatures,
|
|
287
|
+
meta: { required: isRequired, nullableOrUndefined },
|
|
288
|
+
}),
|
|
289
|
+
)
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
} else {
|
|
293
|
+
// If no struct members, process as regular union
|
|
294
|
+
const newMeta = createMeta<T>({
|
|
295
|
+
parent: key,
|
|
296
|
+
property: p.type,
|
|
297
|
+
meta: { required: isRequired, nullableOrUndefined },
|
|
298
|
+
})
|
|
299
|
+
acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
|
|
300
|
+
}
|
|
301
|
+
}
|
|
267
302
|
if ("propertySignatures" in typeToProcess) {
|
|
268
303
|
Object.assign(
|
|
269
304
|
acc,
|
|
@@ -63,7 +63,11 @@
|
|
|
63
63
|
:model-value="vuetifyValue"
|
|
64
64
|
@update:model-value="
|
|
65
65
|
(e: any) => {
|
|
66
|
-
|
|
66
|
+
if (e || e === 0) {
|
|
67
|
+
inputProps.field.handleChange(Number(e))
|
|
68
|
+
} else {
|
|
69
|
+
inputProps.field.handleChange(undefined)
|
|
70
|
+
}
|
|
67
71
|
}
|
|
68
72
|
"
|
|
69
73
|
/>
|