@effect-app/vue-components 2.9.2 → 2.10.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/types/components/OmegaForm/OmegaFormStuff.d.ts +2 -0
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +13 -2
- package/dist/vue-components.es.js +17 -15
- package/dist/vue-components.es10.js +120 -115
- package/dist/vue-components.es12.js +282 -204
- package/dist/vue-components.es16.js +4 -10
- package/dist/vue-components.es17.js +10 -97
- package/dist/vue-components.es2.js +29 -27
- package/dist/vue-components.es20.js +2 -2
- package/dist/vue-components.es21.js +2 -2
- package/dist/vue-components.es22.js +1 -1
- package/dist/vue-components.es23.js +1 -1
- package/dist/vue-components.es31.js +2 -4
- package/dist/vue-components.es32.js +1 -1
- package/dist/vue-components.es33.js +111 -2
- package/dist/vue-components.es35.js +9 -0
- package/dist/vue-components.es36.js +32 -7
- package/dist/vue-components.es40.js +6 -0
- package/dist/vue-components.es41.js +23 -4
- package/dist/vue-components.es42.js +5 -23
- package/dist/vue-components.es43.js +21 -5
- package/dist/vue-components.es44.js +25 -16
- package/dist/vue-components.es45.js +15 -23
- package/dist/vue-components.es46.js +7 -17
- package/dist/vue-components.es47.js +5 -12
- package/dist/vue-components.es48.js +19 -5
- package/dist/vue-components.es49.js +9 -19
- package/dist/vue-components.es50.js +31 -9
- package/dist/vue-components.es51.js +42 -25
- package/dist/vue-components.es52.js +16 -38
- package/dist/vue-components.es53.js +11 -26
- package/dist/vue-components.es54.js +65 -11
- package/dist/vue-components.es55.js +45 -54
- package/dist/vue-components.es56.js +15 -54
- package/dist/vue-components.es57.js +31 -15
- package/dist/vue-components.es58.js +26 -30
- package/dist/vue-components.es59.js +42 -29
- package/dist/vue-components.es60.js +2 -42
- package/dist/vue-components.es61.js +44 -2
- package/dist/vue-components.es62.js +2 -44
- package/dist/vue-components.es7.js +1 -1
- package/dist/vue-components.es9.js +10 -33
- package/package.json +3 -3
- package/src/components/OmegaForm/OmegaFormStuff.ts +174 -11
- package/src/components/OmegaForm/OmegaTaggedUnionInternal.vue +0 -48
- package/src/components/OmegaForm/useOmegaForm.ts +49 -25
- package/dist/types/components/OmegaForm/defaultAST.d.ts +0 -4
- package/dist/vue-components.es34.js +0 -113
- package/dist/vue-components.es37.js +0 -34
- package/dist/vue-components.es63.js +0 -4
- package/src/components/OmegaForm/defaultAST.ts +0 -191
- /package/dist/{vue-components.es39.js → vue-components.es38.js} +0 -0
|
@@ -1,328 +1,329 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
import { getMetadataFromSchema as
|
|
3
|
-
import { useIntl as
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { S as i, Option as M } from "effect-app";
|
|
2
|
+
import { getMetadataFromSchema as k } from "@effect-app/vue/form";
|
|
3
|
+
import { useIntl as V, getTransformationFrom as q } from "./vue-components.es3.js";
|
|
4
|
+
import { isObject as E } from "./vue-components.es16.js";
|
|
5
|
+
const $ = (e) => i.AST.isUnion(e) && e.types.find((n) => n._tag === "UndefinedKeyword" || n === i.Null.ast), g = (e) => !e || !i.AST.isUnion(e) ? !1 : e.types.find((n) => n._tag === "UndefinedKeyword") ? "undefined" : e.types.find((n) => n === i.Null.ast) ? "null" : !1, w = (e) => {
|
|
6
|
+
const n = [];
|
|
6
7
|
for (const t of e)
|
|
7
|
-
if (
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
if (i.AST.isUnion(t)) {
|
|
9
|
+
const l = w(t.types);
|
|
10
|
+
n.push(...l);
|
|
10
11
|
} else
|
|
11
|
-
|
|
12
|
-
return
|
|
13
|
-
},
|
|
12
|
+
n.push(t);
|
|
13
|
+
return n;
|
|
14
|
+
}, m = ({ meta: e = {}, parent: n = "", property: t, propertySignatures: l }, o = {}) => {
|
|
14
15
|
if (t && t._tag === "Transformation")
|
|
15
|
-
return
|
|
16
|
-
parent:
|
|
16
|
+
return m({
|
|
17
|
+
parent: n,
|
|
17
18
|
meta: e,
|
|
18
19
|
property: t.from
|
|
19
20
|
});
|
|
20
21
|
if (t?._tag === "TypeLiteral" && "propertySignatures" in t)
|
|
21
|
-
return
|
|
22
|
+
return m({
|
|
22
23
|
meta: e,
|
|
23
24
|
propertySignatures: t.propertySignatures
|
|
24
25
|
});
|
|
25
|
-
if (
|
|
26
|
-
for (const
|
|
27
|
-
const
|
|
26
|
+
if (l) {
|
|
27
|
+
for (const s of l) {
|
|
28
|
+
const r = n ? `${n}.${s.name.toString()}` : s.name.toString(), p = g(s.type);
|
|
28
29
|
let a;
|
|
29
|
-
e._isNullableDiscriminatedUnion &&
|
|
30
|
-
const f =
|
|
31
|
-
if (
|
|
32
|
-
const S =
|
|
33
|
-
(
|
|
34
|
-
).map(
|
|
30
|
+
e._isNullableDiscriminatedUnion && s.name.toString() === "_tag" || e.required === !1 ? a = !1 : a = !p;
|
|
31
|
+
const f = s.type;
|
|
32
|
+
if (i.AST.isUnion(s.type)) {
|
|
33
|
+
const S = w(s.type.types).filter(
|
|
34
|
+
(u) => u._tag !== "UndefinedKeyword" && u !== i.Null.ast
|
|
35
|
+
).map(q);
|
|
35
36
|
if (S.some(
|
|
36
|
-
(
|
|
37
|
+
(u) => "propertySignatures" in u
|
|
37
38
|
)) {
|
|
38
|
-
if (!
|
|
39
|
-
const
|
|
40
|
-
parent:
|
|
41
|
-
property:
|
|
42
|
-
meta: { required: a, nullableOrUndefined:
|
|
39
|
+
if (!p) {
|
|
40
|
+
const u = m({
|
|
41
|
+
parent: r,
|
|
42
|
+
property: s.type,
|
|
43
|
+
meta: { required: a, nullableOrUndefined: p }
|
|
43
44
|
});
|
|
44
|
-
o[
|
|
45
|
+
o[r] = u;
|
|
45
46
|
}
|
|
46
|
-
for (const
|
|
47
|
-
if ("propertySignatures" in
|
|
48
|
-
const
|
|
47
|
+
for (const u of S)
|
|
48
|
+
if ("propertySignatures" in u) {
|
|
49
|
+
const y = p && S.length > 1;
|
|
49
50
|
Object.assign(
|
|
50
51
|
o,
|
|
51
|
-
|
|
52
|
-
parent:
|
|
53
|
-
propertySignatures:
|
|
54
|
-
meta:
|
|
52
|
+
m({
|
|
53
|
+
parent: r,
|
|
54
|
+
propertySignatures: u.propertySignatures,
|
|
55
|
+
meta: y ? { _isNullableDiscriminatedUnion: !0 } : {}
|
|
55
56
|
})
|
|
56
57
|
);
|
|
57
58
|
}
|
|
58
59
|
} else {
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
const
|
|
62
|
-
if (o[
|
|
60
|
+
const u = S.filter(i.AST.isTupleType);
|
|
61
|
+
if (u.length > 0) {
|
|
62
|
+
const y = u[0];
|
|
63
|
+
if (o[r] = {
|
|
63
64
|
type: "multiple",
|
|
64
|
-
members:
|
|
65
|
-
rest:
|
|
65
|
+
members: y.elements,
|
|
66
|
+
rest: y.rest,
|
|
66
67
|
required: a,
|
|
67
|
-
nullableOrUndefined:
|
|
68
|
-
},
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
for (const
|
|
72
|
-
const h = `${
|
|
68
|
+
nullableOrUndefined: p
|
|
69
|
+
}, y.rest && y.rest.length > 0) {
|
|
70
|
+
const b = y.rest[0];
|
|
71
|
+
if (b.type._tag === "TypeLiteral" && "propertySignatures" in b.type)
|
|
72
|
+
for (const c of b.type.propertySignatures) {
|
|
73
|
+
const h = `${r}.${c.name.toString()}`, x = m({
|
|
73
74
|
parent: h,
|
|
74
|
-
property:
|
|
75
|
+
property: c.type,
|
|
75
76
|
meta: {
|
|
76
|
-
required: !g(
|
|
77
|
-
nullableOrUndefined: g(
|
|
77
|
+
required: !g(c.type),
|
|
78
|
+
nullableOrUndefined: g(c.type)
|
|
78
79
|
}
|
|
79
80
|
});
|
|
80
|
-
if (
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
for (const
|
|
84
|
-
const
|
|
85
|
-
parent:
|
|
86
|
-
property:
|
|
81
|
+
if (x && typeof x == "object" && "type" in x && (o[h] = x, x.type === "multiple" && i.AST.isTupleType(c.type) && c.type.rest && c.type.rest.length > 0)) {
|
|
82
|
+
const U = c.type.rest[0];
|
|
83
|
+
if (U.type._tag === "TypeLiteral" && "propertySignatures" in U.type)
|
|
84
|
+
for (const A of U.type.propertySignatures) {
|
|
85
|
+
const L = `${h}.${A.name.toString()}`, O = m({
|
|
86
|
+
parent: L,
|
|
87
|
+
property: A.type,
|
|
87
88
|
meta: {
|
|
88
|
-
required: !g(
|
|
89
|
-
nullableOrUndefined: g(
|
|
89
|
+
required: !g(A.type),
|
|
90
|
+
nullableOrUndefined: g(A.type)
|
|
90
91
|
}
|
|
91
92
|
});
|
|
92
|
-
|
|
93
|
+
O && typeof O == "object" && "type" in O && (o[L] = O);
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
} else {
|
|
98
|
-
const
|
|
99
|
-
parent:
|
|
100
|
-
property:
|
|
101
|
-
meta: { required: a, nullableOrUndefined:
|
|
99
|
+
const y = m({
|
|
100
|
+
parent: r,
|
|
101
|
+
property: s.type,
|
|
102
|
+
meta: { required: a, nullableOrUndefined: p }
|
|
102
103
|
});
|
|
103
|
-
o[
|
|
104
|
+
o[r] = y;
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
} else if ("propertySignatures" in f)
|
|
107
108
|
Object.assign(
|
|
108
109
|
o,
|
|
109
|
-
|
|
110
|
-
parent:
|
|
110
|
+
m({
|
|
111
|
+
parent: r,
|
|
111
112
|
propertySignatures: f.propertySignatures,
|
|
112
|
-
meta: { required: a, nullableOrUndefined:
|
|
113
|
+
meta: { required: a, nullableOrUndefined: p }
|
|
113
114
|
})
|
|
114
115
|
);
|
|
115
|
-
else if (
|
|
116
|
-
if (
|
|
117
|
-
const S =
|
|
116
|
+
else if (i.AST.isTupleType(s.type))
|
|
117
|
+
if (s.type.rest.length > 0 && s.type.rest[0].type._tag === "TypeLiteral" && "propertySignatures" in s.type.rest[0].type) {
|
|
118
|
+
const S = s.type.rest[0].type;
|
|
118
119
|
if (S._tag === "TypeLiteral" && "propertySignatures" in S)
|
|
119
|
-
for (const
|
|
120
|
-
const
|
|
121
|
-
if (
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
124
|
-
for (const
|
|
125
|
-
const
|
|
126
|
-
parent:
|
|
127
|
-
property:
|
|
120
|
+
for (const d of S.propertySignatures) {
|
|
121
|
+
const u = `${r}.${d.name.toString()}`;
|
|
122
|
+
if (i.AST.isTupleType(d.type) && d.type.rest.length > 0) {
|
|
123
|
+
const y = d.type.rest[0].type;
|
|
124
|
+
if (y._tag === "TypeLiteral" && "propertySignatures" in y)
|
|
125
|
+
for (const b of y.propertySignatures) {
|
|
126
|
+
const c = `${u}.${b.name.toString()}`, h = m({
|
|
127
|
+
parent: c,
|
|
128
|
+
property: b.type,
|
|
128
129
|
meta: {
|
|
129
|
-
required: !g(
|
|
130
|
-
nullableOrUndefined: g(
|
|
130
|
+
required: !g(b.type),
|
|
131
|
+
nullableOrUndefined: g(b.type)
|
|
131
132
|
}
|
|
132
133
|
});
|
|
133
|
-
o[
|
|
134
|
+
o[c] = h;
|
|
134
135
|
}
|
|
135
136
|
else
|
|
136
|
-
o[
|
|
137
|
+
o[u] = {
|
|
137
138
|
type: "multiple",
|
|
138
|
-
members:
|
|
139
|
-
rest:
|
|
140
|
-
required: !g(
|
|
141
|
-
nullableOrUndefined: g(
|
|
139
|
+
members: d.type.elements,
|
|
140
|
+
rest: d.type.rest,
|
|
141
|
+
required: !g(d.type),
|
|
142
|
+
nullableOrUndefined: g(d.type)
|
|
142
143
|
};
|
|
143
144
|
} else {
|
|
144
|
-
const
|
|
145
|
-
parent:
|
|
146
|
-
property:
|
|
145
|
+
const y = m({
|
|
146
|
+
parent: u,
|
|
147
|
+
property: d.type,
|
|
147
148
|
meta: {
|
|
148
|
-
required: !g(
|
|
149
|
-
nullableOrUndefined: g(
|
|
149
|
+
required: !g(d.type),
|
|
150
|
+
nullableOrUndefined: g(d.type)
|
|
150
151
|
}
|
|
151
152
|
});
|
|
152
|
-
o[
|
|
153
|
+
o[u] = y;
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
} else
|
|
156
|
-
o[
|
|
157
|
+
o[r] = {
|
|
157
158
|
type: "multiple",
|
|
158
|
-
members:
|
|
159
|
-
rest:
|
|
159
|
+
members: s.type.elements,
|
|
160
|
+
rest: s.type.rest,
|
|
160
161
|
required: a,
|
|
161
|
-
nullableOrUndefined:
|
|
162
|
+
nullableOrUndefined: p
|
|
162
163
|
};
|
|
163
164
|
else {
|
|
164
|
-
const
|
|
165
|
-
parent:
|
|
166
|
-
property:
|
|
165
|
+
const T = m({
|
|
166
|
+
parent: r,
|
|
167
|
+
property: s.type,
|
|
167
168
|
meta: {
|
|
168
169
|
// an empty string is valid for a S.String field, so we should not mark it as required
|
|
169
170
|
// TODO: handle this better via the createMeta minLength parsing
|
|
170
|
-
required: a && (
|
|
171
|
-
nullableOrUndefined:
|
|
171
|
+
required: a && (s.type._tag !== "StringKeyword" || k(s.type).minLength),
|
|
172
|
+
nullableOrUndefined: p
|
|
172
173
|
}
|
|
173
174
|
});
|
|
174
|
-
o[
|
|
175
|
+
o[r] = T;
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
return o;
|
|
178
179
|
}
|
|
179
180
|
if (t) {
|
|
180
|
-
const
|
|
181
|
-
if (Object.hasOwnProperty.call(e, "required") || (e.required = !
|
|
182
|
-
const
|
|
183
|
-
(f) => f._tag !== "UndefinedKeyword" && f !==
|
|
181
|
+
const s = $(t);
|
|
182
|
+
if (Object.hasOwnProperty.call(e, "required") || (e.required = !s), i.AST.isUnion(t)) {
|
|
183
|
+
const p = w(t.types), a = p.find(
|
|
184
|
+
(f) => f._tag !== "UndefinedKeyword" && f !== i.Null.ast
|
|
184
185
|
);
|
|
185
|
-
return "propertySignatures" in a ?
|
|
186
|
+
return "propertySignatures" in a ? m({
|
|
186
187
|
propertySignatures: a.propertySignatures,
|
|
187
|
-
parent:
|
|
188
|
+
parent: n,
|
|
188
189
|
meta: e
|
|
189
|
-
}) :
|
|
190
|
+
}) : p.every(i.AST.isLiteral) ? {
|
|
190
191
|
...e,
|
|
191
192
|
type: "select",
|
|
192
|
-
members:
|
|
193
|
+
members: p.map((f) => f.literal)
|
|
193
194
|
} : {
|
|
194
195
|
...e,
|
|
195
|
-
...
|
|
196
|
-
parent:
|
|
196
|
+
...m({
|
|
197
|
+
parent: n,
|
|
197
198
|
meta: e,
|
|
198
199
|
property: a
|
|
199
200
|
})
|
|
200
201
|
};
|
|
201
202
|
}
|
|
202
|
-
if (
|
|
203
|
+
if (i.AST.isTupleType(t))
|
|
203
204
|
return {
|
|
204
205
|
...e,
|
|
205
206
|
type: "multiple",
|
|
206
207
|
members: t.elements,
|
|
207
208
|
rest: t.rest
|
|
208
209
|
};
|
|
209
|
-
const
|
|
210
|
+
const r = i.AST.getAnnotation(
|
|
210
211
|
t,
|
|
211
|
-
|
|
212
|
-
).pipe(
|
|
213
|
-
return e = { ...e, ...
|
|
214
|
-
parent:
|
|
212
|
+
i.AST.JSONSchemaAnnotationId
|
|
213
|
+
).pipe(M.getOrElse(() => ({})));
|
|
214
|
+
return e = { ...e, ...r }, "from" in t ? m({
|
|
215
|
+
parent: n,
|
|
215
216
|
meta: e,
|
|
216
217
|
property: t.from
|
|
217
|
-
}) : (e.type =
|
|
218
|
+
}) : (e.type = i.AST.getAnnotation(
|
|
218
219
|
t,
|
|
219
|
-
|
|
220
|
+
i.AST.TitleAnnotationId
|
|
220
221
|
).pipe(
|
|
221
|
-
|
|
222
|
+
M.getOrElse(() => "unknown")
|
|
222
223
|
), e);
|
|
223
224
|
}
|
|
224
225
|
return o;
|
|
225
|
-
},
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
228
|
-
return
|
|
229
|
-
if (
|
|
230
|
-
const r = (
|
|
231
|
-
if (r.every((
|
|
232
|
-
const
|
|
233
|
-
for (const
|
|
234
|
-
if ("propertySignatures" in
|
|
235
|
-
const
|
|
236
|
-
(
|
|
226
|
+
}, N = (e) => {
|
|
227
|
+
const n = e.ast, t = {}, l = {};
|
|
228
|
+
if (n._tag === "Transformation" || n._tag === "Refinement")
|
|
229
|
+
return N(i.make(n.from));
|
|
230
|
+
if (n._tag === "Union") {
|
|
231
|
+
const r = (n.types || []).filter((a) => a._tag !== "UndefinedKeyword" && a !== i.Null.ast).map(q);
|
|
232
|
+
if (r.every((a) => a._tag === "TypeLiteral" && "propertySignatures" in a) && r.length > 0) {
|
|
233
|
+
const a = [];
|
|
234
|
+
for (const f of r)
|
|
235
|
+
if ("propertySignatures" in f) {
|
|
236
|
+
const T = f.propertySignatures.find(
|
|
237
|
+
(d) => d.name.toString() === "_tag"
|
|
237
238
|
);
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
propertySignatures:
|
|
239
|
+
T && i.AST.isLiteral(T.type) && a.push(T.type.literal);
|
|
240
|
+
const S = m({
|
|
241
|
+
propertySignatures: f.propertySignatures
|
|
241
242
|
});
|
|
242
|
-
Object.assign(t,
|
|
243
|
+
Object.assign(t, S);
|
|
243
244
|
}
|
|
244
|
-
return
|
|
245
|
+
return a.length > 0 && (t._tag = {
|
|
245
246
|
type: "select",
|
|
246
|
-
members:
|
|
247
|
+
members: a,
|
|
247
248
|
required: !0
|
|
248
|
-
}), t;
|
|
249
|
+
}), { meta: t, defaultValues: l };
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
|
-
if ("propertySignatures" in
|
|
252
|
-
const
|
|
253
|
-
propertySignatures:
|
|
252
|
+
if ("propertySignatures" in n) {
|
|
253
|
+
const o = m({
|
|
254
|
+
propertySignatures: n.propertySignatures
|
|
254
255
|
});
|
|
255
|
-
if (Object.values(
|
|
256
|
-
return
|
|
257
|
-
const
|
|
258
|
-
for (const
|
|
259
|
-
const
|
|
260
|
-
r[
|
|
256
|
+
if (Object.values(o).every((r) => r && "type" in r))
|
|
257
|
+
return { meta: o, defaultValues: l };
|
|
258
|
+
const s = (r, p = "") => {
|
|
259
|
+
for (const a in r) {
|
|
260
|
+
const f = p ? `${p}.${a}` : a;
|
|
261
|
+
r[a] && typeof r[a] == "object" && "type" in r[a] ? t[f] = r[a] : r[a] && typeof r[a] == "object" && s(r[a], f);
|
|
261
262
|
}
|
|
262
263
|
};
|
|
263
|
-
o
|
|
264
|
+
s(o);
|
|
264
265
|
}
|
|
265
|
-
return t;
|
|
266
|
-
},
|
|
267
|
-
const
|
|
268
|
-
return { schema: e, meta:
|
|
269
|
-
},
|
|
270
|
-
const { trans:
|
|
266
|
+
return { meta: t, defaultValues: l };
|
|
267
|
+
}, B = (e) => i.extend(e, i.Struct({})), J = (e) => {
|
|
268
|
+
const { meta: n } = N(e);
|
|
269
|
+
return { schema: e, meta: n };
|
|
270
|
+
}, z = (e) => {
|
|
271
|
+
const { trans: n } = V();
|
|
271
272
|
let t;
|
|
272
273
|
switch (e.type) {
|
|
273
274
|
case "string":
|
|
274
|
-
t =
|
|
275
|
-
message: () =>
|
|
276
|
-
}), e.format === "email" && (t =
|
|
275
|
+
t = i.String.annotations({
|
|
276
|
+
message: () => n("validation.empty")
|
|
277
|
+
}), e.format === "email" && (t = i.compose(
|
|
277
278
|
t,
|
|
278
|
-
|
|
279
|
-
message: () =>
|
|
279
|
+
i.Email.annotations({
|
|
280
|
+
message: () => n("validation.email.invalid")
|
|
280
281
|
})
|
|
281
282
|
)), e.required && (t = t.annotations({
|
|
282
|
-
message: () =>
|
|
283
|
-
}).pipe(
|
|
284
|
-
message: () =>
|
|
285
|
-
})), typeof e.maxLength == "number" && (t = t.pipe(
|
|
286
|
-
message: () =>
|
|
283
|
+
message: () => n("validation.empty")
|
|
284
|
+
}).pipe(i.minLength(1)).annotations({
|
|
285
|
+
message: () => n("validation.empty")
|
|
286
|
+
})), typeof e.maxLength == "number" && (t = t.pipe(i.maxLength(e.maxLength)).annotations({
|
|
287
|
+
message: () => n("validation.string.maxLength", {
|
|
287
288
|
maxLength: e.maxLength
|
|
288
289
|
})
|
|
289
|
-
})), typeof e.minLength == "number" && (t = t.pipe(
|
|
290
|
-
message: () =>
|
|
290
|
+
})), typeof e.minLength == "number" && (t = t.pipe(i.minLength(e.minLength)).annotations({
|
|
291
|
+
message: () => n("validation.string.minLength", {
|
|
291
292
|
minLength: e.minLength
|
|
292
293
|
})
|
|
293
294
|
}));
|
|
294
295
|
break;
|
|
295
296
|
case "number":
|
|
296
|
-
t =
|
|
297
|
-
message: () =>
|
|
297
|
+
t = i.Number.annotations({
|
|
298
|
+
message: () => n("validation.empty")
|
|
298
299
|
}), e.required && t.annotations({
|
|
299
|
-
message: () =>
|
|
300
|
-
}), typeof e.minimum == "number" && (t = t.pipe(
|
|
301
|
-
message: () =>
|
|
300
|
+
message: () => n("validation.empty")
|
|
301
|
+
}), typeof e.minimum == "number" && (t = t.pipe(i.greaterThanOrEqualTo(e.minimum)).annotations({
|
|
302
|
+
message: () => n(e.minimum === 0 ? "validation.number.positive" : "validation.number.min", {
|
|
302
303
|
minimum: e.minimum,
|
|
303
304
|
isExclusive: !0
|
|
304
305
|
})
|
|
305
|
-
})), typeof e.maximum == "number" && (t = t.pipe(
|
|
306
|
-
message: () =>
|
|
306
|
+
})), typeof e.maximum == "number" && (t = t.pipe(i.lessThanOrEqualTo(e.maximum)).annotations({
|
|
307
|
+
message: () => n("validation.number.max", {
|
|
307
308
|
maximum: e.maximum,
|
|
308
309
|
isExclusive: !0
|
|
309
310
|
})
|
|
310
|
-
})), typeof e.exclusiveMinimum == "number" && (t = t.pipe(
|
|
311
|
-
message: () =>
|
|
311
|
+
})), typeof e.exclusiveMinimum == "number" && (t = t.pipe(i.greaterThan(e.exclusiveMinimum)).annotations({
|
|
312
|
+
message: () => n(e.exclusiveMinimum === 0 ? "validation.number.positive" : "validation.number.min", {
|
|
312
313
|
minimum: e.exclusiveMinimum,
|
|
313
314
|
isExclusive: !1
|
|
314
315
|
})
|
|
315
|
-
})), typeof e.exclusiveMaximum == "number" && (t = t.pipe(
|
|
316
|
-
message: () =>
|
|
316
|
+
})), typeof e.exclusiveMaximum == "number" && (t = t.pipe(i.lessThan(e.exclusiveMaximum)).annotations({
|
|
317
|
+
message: () => n("validation.number.max", {
|
|
317
318
|
maximum: e.exclusiveMaximum,
|
|
318
319
|
isExclusive: !1
|
|
319
320
|
})
|
|
320
321
|
}));
|
|
321
322
|
break;
|
|
322
323
|
case "select":
|
|
323
|
-
t =
|
|
324
|
+
t = i.Literal(...e.members).annotations({
|
|
324
325
|
message: () => ({
|
|
325
|
-
message:
|
|
326
|
+
message: n("validation.not_a_valid", {
|
|
326
327
|
type: "select",
|
|
327
328
|
message: e.members.join(", ")
|
|
328
329
|
}),
|
|
@@ -331,34 +332,34 @@ const k = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKe
|
|
|
331
332
|
});
|
|
332
333
|
break;
|
|
333
334
|
case "multiple":
|
|
334
|
-
t =
|
|
335
|
-
message: () =>
|
|
335
|
+
t = i.Array(i.String).annotations({
|
|
336
|
+
message: () => n("validation.not_a_valid", {
|
|
336
337
|
type: "multiple",
|
|
337
338
|
message: e.members.join(", ")
|
|
338
339
|
})
|
|
339
340
|
});
|
|
340
341
|
break;
|
|
341
342
|
case "boolean":
|
|
342
|
-
t =
|
|
343
|
+
t = i.Boolean;
|
|
343
344
|
break;
|
|
344
345
|
case "unknown":
|
|
345
|
-
t =
|
|
346
|
+
t = i.Unknown;
|
|
346
347
|
break;
|
|
347
348
|
default:
|
|
348
|
-
console.warn(`Unhandled field type: ${e}`), t =
|
|
349
|
+
console.warn(`Unhandled field type: ${e}`), t = i.Unknown;
|
|
349
350
|
break;
|
|
350
351
|
}
|
|
351
352
|
return e.required ? t.pipe(
|
|
352
|
-
|
|
353
|
-
message: () =>
|
|
353
|
+
i.annotations({
|
|
354
|
+
message: () => n("validation.empty")
|
|
354
355
|
})
|
|
355
|
-
) : t =
|
|
356
|
-
},
|
|
357
|
-
|
|
358
|
-
decode: (t) => t ??
|
|
356
|
+
) : t = i.NullishOr(t), i.standardSchemaV1(t);
|
|
357
|
+
}, C = (e, n) => i.NullOr(e).pipe(
|
|
358
|
+
i.transform(i.typeSchema(e), {
|
|
359
|
+
decode: (t) => t ?? n(),
|
|
359
360
|
encode: (t) => t
|
|
360
361
|
})
|
|
361
|
-
),
|
|
362
|
+
), K = [
|
|
362
363
|
"button",
|
|
363
364
|
"checkbox",
|
|
364
365
|
"color",
|
|
@@ -374,13 +375,90 @@ const k = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKe
|
|
|
374
375
|
"text",
|
|
375
376
|
"time",
|
|
376
377
|
"url"
|
|
377
|
-
],
|
|
378
|
+
], G = (e) => K.includes(e) ? e : "text";
|
|
379
|
+
function j(e, n) {
|
|
380
|
+
const t = { ...e };
|
|
381
|
+
for (const l in n)
|
|
382
|
+
Array.isArray(n[l]) ? t[l] = n[l] : n[l] && E(n[l]) ? t[l] = j(t[l], n[l]) : t[l] = n[l];
|
|
383
|
+
return t;
|
|
384
|
+
}
|
|
385
|
+
function _(e) {
|
|
386
|
+
return e && "fields" in e && typeof e.fields == "object";
|
|
387
|
+
}
|
|
388
|
+
function F(e) {
|
|
389
|
+
return e && "members" in e && Array.isArray(e.members);
|
|
390
|
+
}
|
|
391
|
+
const v = (e, n = {}) => {
|
|
392
|
+
const t = e.ast;
|
|
393
|
+
if (t?.defaultValue)
|
|
394
|
+
return t.defaultValue();
|
|
395
|
+
if (g(e.ast) === "null")
|
|
396
|
+
return null;
|
|
397
|
+
if (g(e.ast) !== "undefined") {
|
|
398
|
+
if (_(e)) {
|
|
399
|
+
const l = {};
|
|
400
|
+
for (const [o, s] of Object.entries(e.fields)) {
|
|
401
|
+
const r = s?.ast;
|
|
402
|
+
if (r?.defaultValue)
|
|
403
|
+
try {
|
|
404
|
+
l[o] = r.defaultValue();
|
|
405
|
+
continue;
|
|
406
|
+
} catch {
|
|
407
|
+
}
|
|
408
|
+
const p = v(s, n[o] || {});
|
|
409
|
+
p !== void 0 && (l[o] = p);
|
|
410
|
+
}
|
|
411
|
+
return { ...l, ...n };
|
|
412
|
+
}
|
|
413
|
+
if (e?.from && _(e.from))
|
|
414
|
+
return v(e.from, n);
|
|
415
|
+
if (F(e)) {
|
|
416
|
+
const l = e.members.reduce((o, s) => (_(s) && Object.entries(s.fields).forEach(([r, p]) => {
|
|
417
|
+
const a = p.ast, f = o[r]?.ast;
|
|
418
|
+
(!o[r] || a?.defaultValue && !f?.defaultValue) && (o[r] = p);
|
|
419
|
+
}), o), {});
|
|
420
|
+
return Object.entries(l).reduce((o, [s, r]) => (o[s] = v(r, n[s] || {}), o), n);
|
|
421
|
+
}
|
|
422
|
+
if (Object.keys(n).length === 0)
|
|
423
|
+
switch (e.ast._tag) {
|
|
424
|
+
case "Refinement":
|
|
425
|
+
return v(i.make(e.ast.from), n);
|
|
426
|
+
case "Transformation": {
|
|
427
|
+
const l = i.make(e.ast.from);
|
|
428
|
+
return v(l, n);
|
|
429
|
+
}
|
|
430
|
+
case "TypeLiteral": {
|
|
431
|
+
const l = { ...n };
|
|
432
|
+
for (const o of t.propertySignatures) {
|
|
433
|
+
const s = o.name.toString(), r = o.type;
|
|
434
|
+
if (r._tag === "Transformation" && r.defaultValue) {
|
|
435
|
+
l[s] = r.defaultValue();
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
if (r.defaultValue) {
|
|
439
|
+
l[s] = r.defaultValue();
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
const p = i.make(r), a = v(p, n[s] || {});
|
|
443
|
+
a !== void 0 && (l[s] = a);
|
|
444
|
+
}
|
|
445
|
+
return l;
|
|
446
|
+
}
|
|
447
|
+
case "StringKeyword":
|
|
448
|
+
return "";
|
|
449
|
+
case "BooleanKeyword":
|
|
450
|
+
return !1;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
};
|
|
378
454
|
export {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
455
|
+
m as createMeta,
|
|
456
|
+
j as deepMerge,
|
|
457
|
+
v as defaultsValueFromSchema,
|
|
458
|
+
B as duplicateSchema,
|
|
459
|
+
z as generateInputStandardSchemaFromFieldMeta,
|
|
460
|
+
J as generateMetaFromSchema,
|
|
461
|
+
G as getInputType,
|
|
384
462
|
g as isNullableOrUndefined,
|
|
385
|
-
|
|
463
|
+
C as nullableInput
|
|
386
464
|
};
|