@effect-app/vue-components 0.27.15 → 1.0.0-next.0
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/OmegaArray.vue.d.ts +1 -1
- package/dist/types/components/OmegaForm/OmegaErrorsContext.d.ts +4 -4
- package/dist/types/components/OmegaForm/OmegaErrorsInternal.vue.d.ts +22 -0
- package/dist/types/components/OmegaForm/OmegaWrapper.vue.d.ts +8 -38
- package/dist/types/components/OmegaForm/index.d.ts +1 -7
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +68 -4
- package/dist/types/utils/index.d.ts +9 -0
- package/dist/vue-components.es.js +16 -25
- package/dist/vue-components.es10.js +5 -333
- package/dist/vue-components.es11.js +54 -6
- package/dist/vue-components.es12.js +71 -6
- package/dist/vue-components.es13.js +6 -2
- package/dist/vue-components.es14.js +6 -2
- package/dist/vue-components.es15.js +3 -86
- package/dist/vue-components.es16.js +5 -0
- package/dist/vue-components.es17.js +90 -7
- package/dist/vue-components.es18.js +42 -2
- package/dist/vue-components.es19.js +1 -1
- package/dist/vue-components.es2.js +10 -20
- package/dist/vue-components.es20.js +2 -126
- package/dist/vue-components.es21.js +92 -0
- package/dist/vue-components.es23.js +7 -5
- package/dist/vue-components.es24.js +31 -3
- package/dist/vue-components.es26.js +2 -90
- package/dist/vue-components.es28.js +22 -41
- package/dist/vue-components.es29.js +5 -2
- package/dist/vue-components.es3.js +12 -8
- package/dist/vue-components.es30.js +18 -20
- package/dist/vue-components.es31.js +30 -5
- package/dist/vue-components.es32.js +17 -16
- package/dist/vue-components.es33.js +7 -25
- package/dist/vue-components.es34.js +5 -22
- package/dist/vue-components.es35.js +19 -12
- package/dist/vue-components.es36.js +9 -5
- package/dist/vue-components.es37.js +31 -19
- package/dist/vue-components.es38.js +48 -9
- package/dist/vue-components.es39.js +20 -25
- package/dist/vue-components.es4.js +40 -43
- package/dist/vue-components.es40.js +114 -47
- package/dist/vue-components.es42.js +4 -65
- package/dist/vue-components.es43.js +54 -45
- package/dist/vue-components.es44.js +54 -15
- package/dist/vue-components.es45.js +15 -31
- package/dist/vue-components.es46.js +30 -26
- package/dist/vue-components.es47.js +29 -42
- package/dist/vue-components.es48.js +41 -114
- package/dist/vue-components.es49.js +4 -0
- package/dist/vue-components.es5.js +29 -70
- package/dist/vue-components.es50.js +44 -4
- package/dist/vue-components.es51.js +2 -2
- package/dist/vue-components.es6.js +211 -31
- package/dist/vue-components.es7.js +331 -49
- package/dist/vue-components.es8.js +2 -29
- package/dist/vue-components.es9.js +10 -148
- package/package.json +2 -2
- package/src/components/OmegaForm/OmegaAutoGen.vue +1 -3
- package/src/components/OmegaForm/OmegaErrorsContext.ts +10 -8
- package/src/components/OmegaForm/{OmegaErrors.vue → OmegaErrorsInternal.vue} +11 -5
- package/src/components/OmegaForm/OmegaFormStuff.ts +5 -6
- package/src/components/OmegaForm/OmegaWrapper.vue +21 -246
- package/src/components/OmegaForm/index.ts +1 -7
- package/src/components/OmegaForm/useOmegaForm.ts +230 -10
- package/src/utils/index.ts +16 -0
- package/dist/types/components/OmegaForm/OmegaErrors.vue.d.ts +0 -15
- package/dist/vue-components.es22.js +0 -12
- package/dist/vue-components.es25.js +0 -5
- package/dist/vue-components.es41.js +0 -28
- package/dist/vue-components.es52.js +0 -46
- package/dist/vue-components.es53.js +0 -4
|
@@ -1,34 +1,214 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
import { useForm as D, useStore as H } from "@tanstack/vue-form";
|
|
2
|
+
import { S as L, Effect as f, Fiber as y } from "effect-app";
|
|
3
|
+
import { runtimeFiberAsPromise as J } from "./vue-components.es9.js";
|
|
4
|
+
import { isObject as q } from "./vue-components.es10.js";
|
|
5
|
+
import { computed as O, onUnmounted as K, onMounted as B, onBeforeUnmount as G, watch as W, h as I } from "vue";
|
|
6
|
+
import k from "./vue-components.es11.js";
|
|
7
|
+
import z from "./vue-components.es12.js";
|
|
8
|
+
import { buildOmegaErrors as Q } from "./vue-components.es5.js";
|
|
9
|
+
import T from "./vue-components.es13.js";
|
|
10
|
+
import { generateMetaFromSchema as X } from "./vue-components.es7.js";
|
|
11
|
+
import Y from "./vue-components.es4.js";
|
|
12
|
+
import Z from "./vue-components.es14.js";
|
|
13
|
+
import { trace as $ } from "./vue-components.es15.js";
|
|
14
|
+
import { context as E } from "./vue-components.es16.js";
|
|
15
|
+
const p = (c) => function(n) {
|
|
16
|
+
return {
|
|
17
|
+
setup() {
|
|
18
|
+
},
|
|
19
|
+
render() {
|
|
20
|
+
return I(n, {
|
|
21
|
+
form: c,
|
|
22
|
+
on: this.$listeners,
|
|
23
|
+
attrs: this.$attrs,
|
|
24
|
+
scopedSlots: this.$scopedSlots
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}, C = (c) => function(n) {
|
|
29
|
+
return {
|
|
30
|
+
setup() {
|
|
31
|
+
return {
|
|
32
|
+
...c
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
render({ errors: h, generalErrors: S, showErrors: w }) {
|
|
36
|
+
return I(n, {
|
|
37
|
+
errors: h,
|
|
38
|
+
generalErrors: S,
|
|
39
|
+
showErrors: w,
|
|
40
|
+
on: this.$listeners,
|
|
41
|
+
attrs: this.$attrs,
|
|
42
|
+
scopedSlots: this.$scopedSlots
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}, pe = (c, a, n) => {
|
|
47
|
+
if (!c) throw new Error("Schema is required");
|
|
48
|
+
const h = L.standardSchemaV1(c), S = L.decode(c), { filterItems: w, meta: d } = X(c), l = O(() => {
|
|
49
|
+
if (n?.persistency?.id)
|
|
50
|
+
return n.persistency.id;
|
|
51
|
+
const e = window.location.pathname, r = Object.keys(d);
|
|
52
|
+
return `${e}-${r.join("-")}`;
|
|
53
|
+
}), P = () => {
|
|
54
|
+
const e = new URLSearchParams(window.location.search);
|
|
55
|
+
e.delete(l.value);
|
|
56
|
+
const r = new URL(window.location.href);
|
|
57
|
+
r.search = e.toString(), window.history.replaceState({}, "", r.toString());
|
|
58
|
+
};
|
|
59
|
+
function g(e, r) {
|
|
60
|
+
for (const t in r)
|
|
61
|
+
r[t] && q(r[t]) ? (e[t] || (e[t] = {}), g(e[t], r[t])) : e[t] = r[t];
|
|
62
|
+
return e;
|
|
30
63
|
}
|
|
31
|
-
|
|
64
|
+
const A = O(() => {
|
|
65
|
+
if (a?.defaultValues && !n?.persistency?.overrideDefaultValues)
|
|
66
|
+
return a?.defaultValues;
|
|
67
|
+
let e;
|
|
68
|
+
const r = n?.persistency;
|
|
69
|
+
if (!r?.policies || r.policies.length === 0) return {};
|
|
70
|
+
if (r.policies.includes("querystring"))
|
|
71
|
+
try {
|
|
72
|
+
const s = new URLSearchParams(window.location.search).get(l.value);
|
|
73
|
+
P(), s && (e = JSON.parse(s));
|
|
74
|
+
} catch (t) {
|
|
75
|
+
console.error(t);
|
|
76
|
+
}
|
|
77
|
+
if (
|
|
78
|
+
// query string has higher priority than local/session storage
|
|
79
|
+
!e && (r.policies.includes("local") || r.policies.includes("session"))
|
|
80
|
+
) {
|
|
81
|
+
const t = r.policies.includes("local") ? localStorage : sessionStorage;
|
|
82
|
+
if (t)
|
|
83
|
+
try {
|
|
84
|
+
const s = JSON.parse(
|
|
85
|
+
t.getItem(l.value) || "{}"
|
|
86
|
+
);
|
|
87
|
+
t.removeItem(l.value), e = s;
|
|
88
|
+
} catch (s) {
|
|
89
|
+
console.error(s);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (e ??= {}, a?.defaultValues == null)
|
|
93
|
+
return e;
|
|
94
|
+
{
|
|
95
|
+
const t = a?.defaultValues;
|
|
96
|
+
return g(t, e);
|
|
97
|
+
}
|
|
98
|
+
}), U = (e, r) => e ? E.with($.setSpan(E.active(), e), r) : r(), u = D({
|
|
99
|
+
...a,
|
|
100
|
+
validators: {
|
|
101
|
+
onSubmit: h,
|
|
102
|
+
...a?.validators || {}
|
|
103
|
+
},
|
|
104
|
+
onSubmit: a?.onSubmit ? ({ formApi: e, meta: r, value: t }) => U(r?.currentSpan, async () => {
|
|
105
|
+
const s = await f.runPromise(S(t)), o = a.onSubmit({
|
|
106
|
+
formApi: e,
|
|
107
|
+
meta: r,
|
|
108
|
+
value: s
|
|
109
|
+
});
|
|
110
|
+
return y.isFiber(o) && y.isRuntimeFiber(o) ? await J(o) : f.isEffect(o) ? await f.runPromise(
|
|
111
|
+
o.pipe(
|
|
112
|
+
// meta?.currentSpan
|
|
113
|
+
// ? Effect.withParentSpan(meta.currentSpan)
|
|
114
|
+
// : (_) => _,
|
|
115
|
+
f.flatMap((m) => y.join(m))
|
|
116
|
+
)
|
|
117
|
+
) : o;
|
|
118
|
+
}) : void 0,
|
|
119
|
+
defaultValues: A.value
|
|
120
|
+
}), M = () => {
|
|
121
|
+
Object.keys(d).forEach((e) => {
|
|
122
|
+
u.setFieldValue(e, void 0);
|
|
123
|
+
});
|
|
124
|
+
}, V = (e) => e.reduce((r, t) => {
|
|
125
|
+
const s = t.split(".");
|
|
126
|
+
return s.reduce((o, m, x) => (x === s.length - 1 ? o[m] = u.getFieldValue(t) : o[m] = o[m] ?? {}, o[m]), r), r;
|
|
127
|
+
}, {}), F = (e) => {
|
|
128
|
+
if (e) {
|
|
129
|
+
if (Array.isArray(e.keys))
|
|
130
|
+
return V(e.keys);
|
|
131
|
+
if (Array.isArray(e.banKeys)) {
|
|
132
|
+
const r = Object.keys(d).filter((t) => e.banKeys?.includes(t));
|
|
133
|
+
return V(r);
|
|
134
|
+
}
|
|
135
|
+
return u.store.state.values;
|
|
136
|
+
}
|
|
137
|
+
}, v = () => {
|
|
138
|
+
const e = n?.persistency;
|
|
139
|
+
if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
|
|
140
|
+
const r = e.policies.includes("local") ? localStorage : sessionStorage;
|
|
141
|
+
if (!r) return;
|
|
142
|
+
const t = F(e);
|
|
143
|
+
return r.setItem(l.value, JSON.stringify(t));
|
|
144
|
+
}
|
|
145
|
+
}, j = () => {
|
|
146
|
+
const e = n?.persistency;
|
|
147
|
+
if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
|
|
148
|
+
const r = F(e), t = new URLSearchParams(window.location.search);
|
|
149
|
+
t.set(l.value, JSON.stringify(r));
|
|
150
|
+
const s = new URL(window.location.href);
|
|
151
|
+
s.search = t.toString(), window.history.replaceState({}, "", s.toString());
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
K(v), B(() => {
|
|
155
|
+
window.addEventListener("beforeunload", v), window.addEventListener("blur", j);
|
|
156
|
+
}), G(() => {
|
|
157
|
+
window.removeEventListener("beforeunload", v), window.removeEventListener("blur", j);
|
|
158
|
+
});
|
|
159
|
+
const N = u.handleSubmit, i = Object.assign(u, {
|
|
160
|
+
i18nNamespace: n?.i18nNamespace,
|
|
161
|
+
meta: d,
|
|
162
|
+
filterItems: w,
|
|
163
|
+
clear: M,
|
|
164
|
+
handleSubmit: (e) => {
|
|
165
|
+
const r = $.getSpan(E.active());
|
|
166
|
+
return N({ currentSpan: r, ...e });
|
|
167
|
+
}
|
|
168
|
+
// /** @experimental */
|
|
169
|
+
// handleSubmitEffect: (meta?: Record<string, any>) =>
|
|
170
|
+
// Effect.currentSpan.pipe(
|
|
171
|
+
// Effect.option,
|
|
172
|
+
// Effect
|
|
173
|
+
// .flatMap((span) =>
|
|
174
|
+
// Effect.promise(() => form.handleSubmit(Option.isSome(span) ? { currentSpan: span.value, ...meta } : meta))
|
|
175
|
+
// )
|
|
176
|
+
// )
|
|
177
|
+
}), R = H(
|
|
178
|
+
i.store,
|
|
179
|
+
(e) => e.submissionAttempts
|
|
180
|
+
), b = i.useStore((e) => e.errors);
|
|
181
|
+
W(
|
|
182
|
+
() => [i.filterItems, b.value],
|
|
183
|
+
() => {
|
|
184
|
+
const e = i.filterItems, r = b.value;
|
|
185
|
+
return e ? r ? (Object.values(r).filter(
|
|
186
|
+
(s) => !!s
|
|
187
|
+
).flatMap(
|
|
188
|
+
(s) => Object.values(s).flat().map((o) => o.message)
|
|
189
|
+
).some((s) => s === e.message) && e.items.forEach((s) => {
|
|
190
|
+
const o = i.getFieldMeta(s);
|
|
191
|
+
o && i.setFieldMeta(s, {
|
|
192
|
+
...o,
|
|
193
|
+
errorMap: {
|
|
194
|
+
onSubmit: [
|
|
195
|
+
{ path: [s], message: e.message }
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}), {}) : {} : {};
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
const _ = Q(R, b, n?.showErrorsOn);
|
|
203
|
+
return Object.assign(i, {
|
|
204
|
+
Form: p(i)(Z),
|
|
205
|
+
Input: n?.input ? n.input(i) : p(i)(Y),
|
|
206
|
+
Field: u.Field,
|
|
207
|
+
Errors: C(_)(T),
|
|
208
|
+
Array: p(i)(k),
|
|
209
|
+
AutoGen: p(i)(z)
|
|
210
|
+
});
|
|
211
|
+
};
|
|
32
212
|
export {
|
|
33
|
-
|
|
213
|
+
pe as useOmegaForm
|
|
34
214
|
};
|
|
@@ -1,53 +1,335 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useIntl as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
import { S as n, Option as c, pipe as L } from "effect-app";
|
|
2
|
+
import { getTransformationFrom as U, useIntl as _ } from "./vue-components.es3.js";
|
|
3
|
+
const N = n.NonEmptyArray(n.String), E = (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, m = ({ meta: e = {}, parent: i = "", property: t, propertySignatures: p }, o = {}) => {
|
|
4
|
+
if (t && t._tag === "Transformation")
|
|
5
|
+
return m({
|
|
6
|
+
parent: i,
|
|
7
|
+
meta: e,
|
|
8
|
+
property: t.from
|
|
9
|
+
});
|
|
10
|
+
if (t?._tag === "TypeLiteral" && "propertySignatures" in t)
|
|
11
|
+
return m({
|
|
12
|
+
meta: e,
|
|
13
|
+
propertySignatures: t.propertySignatures
|
|
14
|
+
});
|
|
15
|
+
if (p) {
|
|
16
|
+
for (const r of p) {
|
|
17
|
+
const l = i ? `${i}.${r.name.toString()}` : r.name.toString(), a = g(r.type), u = !a, A = r.type;
|
|
18
|
+
if (n.AST.isUnion(r.type)) {
|
|
19
|
+
const T = r.type.types.filter(
|
|
20
|
+
(s) => s._tag !== "UndefinedKeyword" && s !== n.Null.ast
|
|
21
|
+
).map(U);
|
|
22
|
+
if (T.some(
|
|
23
|
+
(s) => "propertySignatures" in s
|
|
24
|
+
)) {
|
|
25
|
+
if (!a) {
|
|
26
|
+
const s = m({
|
|
27
|
+
parent: l,
|
|
28
|
+
property: r.type,
|
|
29
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
30
|
+
});
|
|
31
|
+
o[l] = s;
|
|
32
|
+
}
|
|
33
|
+
for (const s of T)
|
|
34
|
+
"propertySignatures" in s && Object.assign(
|
|
35
|
+
o,
|
|
36
|
+
m({
|
|
37
|
+
parent: l,
|
|
38
|
+
propertySignatures: s.propertySignatures,
|
|
39
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
} else {
|
|
43
|
+
const s = T.filter(n.AST.isTupleType);
|
|
44
|
+
if (s.length > 0) {
|
|
45
|
+
const f = s[0];
|
|
46
|
+
if (o[l] = {
|
|
47
|
+
type: "multiple",
|
|
48
|
+
members: f.elements,
|
|
49
|
+
rest: f.rest,
|
|
50
|
+
required: u,
|
|
51
|
+
nullableOrUndefined: a
|
|
52
|
+
}, f.rest && f.rest.length > 0) {
|
|
53
|
+
const d = f.rest[0];
|
|
54
|
+
if (d.type._tag === "TypeLiteral" && "propertySignatures" in d.type)
|
|
55
|
+
for (const y of d.type.propertySignatures) {
|
|
56
|
+
const b = `${l}.${y.name.toString()}`, S = m({
|
|
57
|
+
parent: b,
|
|
58
|
+
property: y.type,
|
|
59
|
+
meta: {
|
|
60
|
+
required: !g(y.type),
|
|
61
|
+
nullableOrUndefined: g(y.type)
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
if (S && typeof S == "object" && "type" in S && (o[b] = S, S.type === "multiple" && n.AST.isTupleType(y.type) && y.type.rest && y.type.rest.length > 0)) {
|
|
65
|
+
const O = y.type.rest[0];
|
|
66
|
+
if (O.type._tag === "TypeLiteral" && "propertySignatures" in O.type)
|
|
67
|
+
for (const v of O.type.propertySignatures) {
|
|
68
|
+
const M = `${b}.${v.name.toString()}`, x = m({
|
|
69
|
+
parent: M,
|
|
70
|
+
property: v.type,
|
|
71
|
+
meta: {
|
|
72
|
+
required: !g(v.type),
|
|
73
|
+
nullableOrUndefined: g(v.type)
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
x && typeof x == "object" && "type" in x && (o[M] = x);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
const f = m({
|
|
83
|
+
parent: l,
|
|
84
|
+
property: r.type,
|
|
85
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
86
|
+
});
|
|
87
|
+
o[l] = f;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} else if ("propertySignatures" in A)
|
|
91
|
+
Object.assign(
|
|
92
|
+
o,
|
|
93
|
+
m({
|
|
94
|
+
parent: l,
|
|
95
|
+
propertySignatures: A.propertySignatures,
|
|
96
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
97
|
+
})
|
|
98
|
+
);
|
|
99
|
+
else if (n.AST.isTupleType(r.type))
|
|
100
|
+
if (r.type.rest.length > 0 && r.type.rest[0].type._tag === "TypeLiteral" && "propertySignatures" in r.type.rest[0].type) {
|
|
101
|
+
const h = r.type.rest[0].type;
|
|
102
|
+
if (h._tag === "TypeLiteral" && "propertySignatures" in h)
|
|
103
|
+
for (const s of h.propertySignatures) {
|
|
104
|
+
const f = `${l}.${s.name.toString()}`;
|
|
105
|
+
if (n.AST.isTupleType(s.type) && s.type.rest.length > 0) {
|
|
106
|
+
const d = s.type.rest[0].type;
|
|
107
|
+
if (d._tag === "TypeLiteral" && "propertySignatures" in d)
|
|
108
|
+
for (const y of d.propertySignatures) {
|
|
109
|
+
const b = `${f}.${y.name.toString()}`, S = m({
|
|
110
|
+
parent: b,
|
|
111
|
+
property: y.type,
|
|
112
|
+
meta: {
|
|
113
|
+
required: !g(y.type),
|
|
114
|
+
nullableOrUndefined: g(y.type)
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
o[b] = S;
|
|
118
|
+
}
|
|
119
|
+
else
|
|
120
|
+
o[f] = {
|
|
121
|
+
type: "multiple",
|
|
122
|
+
members: s.type.elements,
|
|
123
|
+
rest: s.type.rest,
|
|
124
|
+
required: !g(s.type),
|
|
125
|
+
nullableOrUndefined: g(s.type)
|
|
126
|
+
};
|
|
127
|
+
} else {
|
|
128
|
+
const d = m({
|
|
129
|
+
parent: f,
|
|
130
|
+
property: s.type,
|
|
131
|
+
meta: {
|
|
132
|
+
required: !g(s.type),
|
|
133
|
+
nullableOrUndefined: g(s.type)
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
o[f] = d;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} else
|
|
140
|
+
o[l] = {
|
|
141
|
+
type: "multiple",
|
|
142
|
+
members: r.type.elements,
|
|
143
|
+
rest: r.type.rest,
|
|
144
|
+
required: u,
|
|
145
|
+
nullableOrUndefined: a
|
|
146
|
+
};
|
|
147
|
+
else {
|
|
148
|
+
const T = m({
|
|
149
|
+
parent: l,
|
|
150
|
+
property: r.type,
|
|
151
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
152
|
+
});
|
|
153
|
+
o[l] = T;
|
|
30
154
|
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
t.value ? (i(), s(I, b({
|
|
34
|
-
key: 0,
|
|
35
|
-
field: v,
|
|
36
|
-
label: a.label ?? c(),
|
|
37
|
-
options: a.options,
|
|
38
|
-
meta: t.value,
|
|
39
|
-
type: a.type
|
|
40
|
-
}, a.$attrs), {
|
|
41
|
-
default: p((g) => [
|
|
42
|
-
C(a.$slots, "default", k(F(g)))
|
|
43
|
-
]),
|
|
44
|
-
_: 3
|
|
45
|
-
}, 16, ["field", "label", "options", "meta", "type"])) : $("", !0)
|
|
46
|
-
]),
|
|
47
|
-
_: 3
|
|
48
|
-
}, 8, ["name", "validators"]));
|
|
155
|
+
}
|
|
156
|
+
return o;
|
|
49
157
|
}
|
|
50
|
-
|
|
158
|
+
if (t) {
|
|
159
|
+
const r = E(t);
|
|
160
|
+
if (Object.hasOwnProperty.call(e, "required") || (e.required = !r), n.AST.isUnion(t)) {
|
|
161
|
+
const a = t.types.find(
|
|
162
|
+
(u) => u._tag !== "UndefinedKeyword" && u !== n.Null.ast
|
|
163
|
+
);
|
|
164
|
+
return "propertySignatures" in a ? m({
|
|
165
|
+
propertySignatures: a.propertySignatures,
|
|
166
|
+
parent: i,
|
|
167
|
+
meta: e
|
|
168
|
+
}) : t.types.every(n.AST.isLiteral) ? {
|
|
169
|
+
...e,
|
|
170
|
+
type: "select",
|
|
171
|
+
members: t.types.map((u) => u.literal)
|
|
172
|
+
} : {
|
|
173
|
+
...e,
|
|
174
|
+
...m({
|
|
175
|
+
parent: i,
|
|
176
|
+
meta: e,
|
|
177
|
+
property: a
|
|
178
|
+
})
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
if (n.AST.isTupleType(t))
|
|
182
|
+
return {
|
|
183
|
+
...e,
|
|
184
|
+
type: "multiple",
|
|
185
|
+
members: t.elements,
|
|
186
|
+
rest: t.rest
|
|
187
|
+
};
|
|
188
|
+
const l = n.AST.getAnnotation(
|
|
189
|
+
t,
|
|
190
|
+
n.AST.JSONSchemaAnnotationId
|
|
191
|
+
).pipe(c.getOrElse(() => ({})));
|
|
192
|
+
return e = { ...e, ...l }, "from" in t ? m({
|
|
193
|
+
parent: i,
|
|
194
|
+
meta: e,
|
|
195
|
+
property: t.from
|
|
196
|
+
}) : (e.type = n.AST.getAnnotation(
|
|
197
|
+
t,
|
|
198
|
+
n.AST.TitleAnnotationId
|
|
199
|
+
).pipe(
|
|
200
|
+
c.getOrElse(() => "unknown")
|
|
201
|
+
), e);
|
|
202
|
+
}
|
|
203
|
+
return o;
|
|
204
|
+
}, q = (e) => {
|
|
205
|
+
const i = e.ast, t = {};
|
|
206
|
+
if (i._tag === "Transformation" || i._tag === "Refinement")
|
|
207
|
+
return q(n.make(i.from));
|
|
208
|
+
if ("propertySignatures" in i) {
|
|
209
|
+
const p = m({
|
|
210
|
+
propertySignatures: i.propertySignatures
|
|
211
|
+
});
|
|
212
|
+
if (Object.values(p).every((r) => r && "type" in r))
|
|
213
|
+
return p;
|
|
214
|
+
const o = (r, l = "") => {
|
|
215
|
+
for (const a in r) {
|
|
216
|
+
const u = l ? `${l}.${a}` : a;
|
|
217
|
+
r[a] && typeof r[a] == "object" && "type" in r[a] ? t[u] = r[a] : r[a] && typeof r[a] == "object" && o(r[a], u);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
o(p);
|
|
221
|
+
}
|
|
222
|
+
return t;
|
|
223
|
+
}, $ = (e) => n.extend(e, n.Struct({})), K = (e) => {
|
|
224
|
+
const i = q(e), t = L(
|
|
225
|
+
e.ast,
|
|
226
|
+
c.liftPredicate((p) => p._tag === "Refinement" && "filter" in p),
|
|
227
|
+
c.flatMap((p) => n.AST.getJSONSchemaAnnotation(p)),
|
|
228
|
+
c.filter((p) => "items" in p),
|
|
229
|
+
c.filterMap(({ items: p }) => n.decodeUnknownOption(N)(p)),
|
|
230
|
+
c.zipWith(
|
|
231
|
+
n.AST.getMessageAnnotation(e.ast),
|
|
232
|
+
(p, o) => ({
|
|
233
|
+
items: p,
|
|
234
|
+
message: o("")
|
|
235
|
+
})
|
|
236
|
+
),
|
|
237
|
+
c.getOrUndefined
|
|
238
|
+
);
|
|
239
|
+
return { schema: e, meta: i, filterItems: t };
|
|
240
|
+
}, P = (e) => {
|
|
241
|
+
const { trans: i } = _();
|
|
242
|
+
let t;
|
|
243
|
+
switch (e.type) {
|
|
244
|
+
case "string":
|
|
245
|
+
t = n.String.annotations({
|
|
246
|
+
message: () => i("validation.empty")
|
|
247
|
+
}), e.format === "email" && (t = n.compose(
|
|
248
|
+
t,
|
|
249
|
+
n.Email.annotations({
|
|
250
|
+
message: () => i("validation.email.invalid")
|
|
251
|
+
})
|
|
252
|
+
)), e.required && t.annotations({
|
|
253
|
+
message: () => i("validation.empty")
|
|
254
|
+
}), e.maxLength && (t = t.pipe(n.maxLength(e.maxLength)).annotations({
|
|
255
|
+
message: () => i("validation.string.maxLength", {
|
|
256
|
+
maxLength: e.maxLength
|
|
257
|
+
})
|
|
258
|
+
})), e.minLength && (t = t.pipe(n.minLength(e.minLength)).annotations({
|
|
259
|
+
message: () => i("validation.string.minLength", {
|
|
260
|
+
minLength: e.minLength
|
|
261
|
+
})
|
|
262
|
+
}));
|
|
263
|
+
break;
|
|
264
|
+
case "number":
|
|
265
|
+
t = n.Number.annotations({
|
|
266
|
+
message: () => i("validation.empty")
|
|
267
|
+
}), e.required && t.annotations({
|
|
268
|
+
message: () => i("validation.empty")
|
|
269
|
+
}), e.minimum && (t = t.pipe(n.greaterThanOrEqualTo(e.minimum)).annotations({
|
|
270
|
+
message: () => i("validation.number.min", {
|
|
271
|
+
minimum: e.minimum,
|
|
272
|
+
isExclusive: !0
|
|
273
|
+
})
|
|
274
|
+
})), e.maximum && (t = t.pipe(n.lessThanOrEqualTo(e.maximum)).annotations({
|
|
275
|
+
message: () => i("validation.number.max", {
|
|
276
|
+
maximum: e.maximum,
|
|
277
|
+
isExclusive: !0
|
|
278
|
+
})
|
|
279
|
+
})), e.exclusiveMinimum && (t = t.pipe(n.greaterThan(e.exclusiveMinimum)).annotations({
|
|
280
|
+
message: () => i("validation.number.min", {
|
|
281
|
+
minimum: e.exclusiveMinimum,
|
|
282
|
+
isExclusive: !1
|
|
283
|
+
})
|
|
284
|
+
})), e.exclusiveMaximum && (t = t.pipe(n.lessThan(e.exclusiveMaximum)).annotations({
|
|
285
|
+
message: () => i("validation.number.max", {
|
|
286
|
+
maximum: e.exclusiveMaximum,
|
|
287
|
+
isExclusive: !1
|
|
288
|
+
})
|
|
289
|
+
}));
|
|
290
|
+
break;
|
|
291
|
+
case "select":
|
|
292
|
+
t = n.Literal(...e.members).annotations({
|
|
293
|
+
message: () => ({
|
|
294
|
+
message: i("validation.not_a_valid", {
|
|
295
|
+
type: "select",
|
|
296
|
+
message: e.members.join(", ")
|
|
297
|
+
}),
|
|
298
|
+
override: !0
|
|
299
|
+
})
|
|
300
|
+
});
|
|
301
|
+
break;
|
|
302
|
+
case "multiple":
|
|
303
|
+
t = n.Array(n.String).annotations({
|
|
304
|
+
message: () => i("validation.not_a_valid", {
|
|
305
|
+
type: "multiple",
|
|
306
|
+
message: e.members.join(", ")
|
|
307
|
+
})
|
|
308
|
+
});
|
|
309
|
+
break;
|
|
310
|
+
case "boolean":
|
|
311
|
+
t = n.Boolean;
|
|
312
|
+
break;
|
|
313
|
+
// todo: switch must be exhaustive or have default case, otherwise falls through with schema undefined.
|
|
314
|
+
case "unknown":
|
|
315
|
+
t = n.Unknown;
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
return e.required ? t.pipe(
|
|
319
|
+
n.annotations({
|
|
320
|
+
message: () => i("validation.empty")
|
|
321
|
+
})
|
|
322
|
+
) : t = n.NullishOr(t), n.standardSchemaV1(t);
|
|
323
|
+
}, I = (e, i) => n.NullOr(e).pipe(
|
|
324
|
+
n.transform(n.typeSchema(e), {
|
|
325
|
+
decode: (t) => t ?? i(),
|
|
326
|
+
encode: (t) => t
|
|
327
|
+
})
|
|
328
|
+
);
|
|
51
329
|
export {
|
|
52
|
-
|
|
330
|
+
m as createMeta,
|
|
331
|
+
$ as duplicateSchema,
|
|
332
|
+
P as generateInputStandardSchemaFromFieldMeta,
|
|
333
|
+
K as generateMetaFromSchema,
|
|
334
|
+
I as nullableInput
|
|
53
335
|
};
|
|
@@ -1,31 +1,4 @@
|
|
|
1
|
-
import
|
|
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
|
-
r.value = [];
|
|
10
|
-
}, a = p(() => t === "onSubmit" ? o.value > 0 : !0), u = {
|
|
11
|
-
errors: v(r),
|
|
12
|
-
addError: c,
|
|
13
|
-
removeError: n,
|
|
14
|
-
clearErrors: m,
|
|
15
|
-
showErrors: a,
|
|
16
|
-
generalErrors: i,
|
|
17
|
-
showErrorsOn: t ?? "onSubmit"
|
|
18
|
-
};
|
|
19
|
-
return E(s, u), u;
|
|
20
|
-
}
|
|
21
|
-
function O() {
|
|
22
|
-
const o = f(s);
|
|
23
|
-
if (!o)
|
|
24
|
-
throw new Error("useOmegaErrors must be used within an OmegaForm provider");
|
|
25
|
-
return o;
|
|
26
|
-
}
|
|
1
|
+
import f from "./vue-components.es4.js";
|
|
27
2
|
export {
|
|
28
|
-
|
|
29
|
-
g as provideOmegaErrors,
|
|
30
|
-
O as useOmegaErrors
|
|
3
|
+
f as default
|
|
31
4
|
};
|