@effect-app/vue-components 0.27.16 → 1.0.0-next.1
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 +2 -3
- 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/OmegaInput.vue.d.ts +1 -2
- package/dist/types/components/OmegaForm/OmegaWrapper.vue.d.ts +7 -37
- package/dist/types/components/OmegaForm/index.d.ts +1 -7
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +65 -1
- 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 +89 -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 -11
- package/dist/vue-components.es27.js +23 -90
- package/dist/vue-components.es28.js +5 -42
- package/dist/vue-components.es29.js +21 -2
- package/dist/vue-components.es3.js +12 -8
- package/dist/vue-components.es30.js +27 -20
- package/dist/vue-components.es31.js +22 -5
- package/dist/vue-components.es32.js +6 -15
- package/dist/vue-components.es33.js +5 -30
- package/dist/vue-components.es34.js +19 -22
- package/dist/vue-components.es35.js +9 -12
- package/dist/vue-components.es36.js +31 -5
- package/dist/vue-components.es37.js +48 -19
- package/dist/vue-components.es38.js +26 -9
- package/dist/vue-components.es39.js +11 -31
- package/dist/vue-components.es4.js +47 -47
- package/dist/vue-components.es40.js +114 -47
- package/dist/vue-components.es42.js +1 -1
- package/dist/vue-components.es44.js +1 -1
- package/dist/vue-components.es45.js +3 -3
- package/dist/vue-components.es46.js +3 -3
- package/dist/vue-components.es47.js +1 -1
- package/dist/vue-components.es48.js +4 -115
- package/dist/vue-components.es49.js +4 -0
- package/dist/vue-components.es5.js +29 -70
- package/dist/vue-components.es50.js +44 -2
- package/dist/vue-components.es51.js +2 -44
- package/dist/vue-components.es6.js +209 -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/OmegaArray.vue +4 -2
- package/src/components/OmegaForm/OmegaAutoGen.vue +5 -5
- package/src/components/OmegaForm/OmegaErrorsContext.ts +10 -8
- package/src/components/OmegaForm/{OmegaErrors.vue → OmegaErrorsInternal.vue} +11 -5
- package/src/components/OmegaForm/OmegaFormInput.vue +4 -2
- package/src/components/OmegaForm/OmegaFormStuff.ts +5 -6
- package/src/components/OmegaForm/OmegaInput.vue +6 -5
- package/src/components/OmegaForm/OmegaInternalInput.vue +1 -2
- package/src/components/OmegaForm/OmegaWrapper.vue +23 -247
- package/src/components/OmegaForm/index.ts +1 -7
- package/src/components/OmegaForm/useOmegaForm.ts +239 -7
- 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 -4
- package/dist/vue-components.es53.js +0 -6
|
@@ -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
|
};
|
|
@@ -1,150 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { trace as P } from "./vue-components.es24.js";
|
|
9
|
-
import { context as S } from "./vue-components.es25.js";
|
|
10
|
-
const B = Symbol("OmegaForm"), Z = (u, o, n) => {
|
|
11
|
-
if (!u) throw new Error("Schema is required");
|
|
12
|
-
const j = V.standardSchemaV1(u), E = V.decode(u), { filterItems: L, meta: d } = $(u), a = g(() => {
|
|
13
|
-
if (n?.persistency?.id)
|
|
14
|
-
return n.persistency.id;
|
|
15
|
-
const e = window.location.pathname, r = Object.keys(d);
|
|
16
|
-
return `${e}-${r.join("-")}`;
|
|
17
|
-
}), U = () => {
|
|
18
|
-
const e = new URLSearchParams(window.location.search);
|
|
19
|
-
e.delete(a.value);
|
|
20
|
-
const r = new URL(window.location.href);
|
|
21
|
-
r.search = e.toString(), window.history.replaceState({}, "", r.toString());
|
|
22
|
-
};
|
|
23
|
-
function h(e, r) {
|
|
24
|
-
for (const t in r)
|
|
25
|
-
r[t] && J(r[t]) ? (e[t] || (e[t] = {}), h(e[t], r[t])) : e[t] = r[t];
|
|
26
|
-
return e;
|
|
27
|
-
}
|
|
28
|
-
const F = g(() => {
|
|
29
|
-
if (o?.defaultValues && !n?.persistency?.overrideDefaultValues)
|
|
30
|
-
return o?.defaultValues;
|
|
31
|
-
let e;
|
|
32
|
-
const r = n?.persistency;
|
|
33
|
-
if (!r?.policies || r.policies.length === 0) return {};
|
|
34
|
-
if (r.policies.includes("querystring"))
|
|
35
|
-
try {
|
|
36
|
-
const s = new URLSearchParams(window.location.search).get(a.value);
|
|
37
|
-
U(), s && (e = JSON.parse(s));
|
|
38
|
-
} catch (t) {
|
|
39
|
-
console.error(t);
|
|
40
|
-
}
|
|
41
|
-
if (
|
|
42
|
-
// query string has higher priority than local/session storage
|
|
43
|
-
!e && (r.policies.includes("local") || r.policies.includes("session"))
|
|
44
|
-
) {
|
|
45
|
-
const t = r.policies.includes("local") ? localStorage : sessionStorage;
|
|
46
|
-
if (t)
|
|
47
|
-
try {
|
|
48
|
-
const s = JSON.parse(
|
|
49
|
-
t.getItem(a.value) || "{}"
|
|
50
|
-
);
|
|
51
|
-
t.removeItem(a.value), e = s;
|
|
52
|
-
} catch (s) {
|
|
53
|
-
console.error(s);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (e ??= {}, o?.defaultValues == null)
|
|
57
|
-
return e;
|
|
58
|
-
{
|
|
59
|
-
const t = o?.defaultValues;
|
|
60
|
-
return h(t, e);
|
|
61
|
-
}
|
|
62
|
-
}), N = (e, r) => e ? S.with(P.setSpan(S.active(), e), r) : r(), c = A({
|
|
63
|
-
...o,
|
|
64
|
-
validators: {
|
|
65
|
-
onSubmit: j,
|
|
66
|
-
...o?.validators || {}
|
|
67
|
-
},
|
|
68
|
-
onSubmit: o?.onSubmit ? ({ formApi: e, meta: r, value: t }) => N(r?.currentSpan, async () => {
|
|
69
|
-
const s = await f.runPromise(E(t)), i = o.onSubmit({
|
|
70
|
-
formApi: e,
|
|
71
|
-
meta: r,
|
|
72
|
-
value: s
|
|
73
|
-
});
|
|
74
|
-
return w.isFiber(i) && w.isRuntimeFiber(i) ? await D(i) : f.isEffect(i) ? await f.runPromise(
|
|
75
|
-
i.pipe(
|
|
76
|
-
// meta?.currentSpan
|
|
77
|
-
// ? Effect.withParentSpan(meta.currentSpan)
|
|
78
|
-
// : (_) => _,
|
|
79
|
-
f.flatMap((l) => w.join(l))
|
|
80
|
-
)
|
|
81
|
-
) : i;
|
|
82
|
-
}) : void 0,
|
|
83
|
-
defaultValues: F.value
|
|
84
|
-
}), O = () => {
|
|
85
|
-
Object.keys(d).forEach((e) => {
|
|
86
|
-
c.setFieldValue(e, void 0);
|
|
87
|
-
});
|
|
88
|
-
}, y = (e) => e.reduce((r, t) => {
|
|
89
|
-
const s = t.split(".");
|
|
90
|
-
return s.reduce((i, l, R) => (R === s.length - 1 ? i[l] = c.getFieldValue(t) : i[l] = i[l] ?? {}, i[l]), r), r;
|
|
91
|
-
}, {}), v = (e) => {
|
|
92
|
-
if (e) {
|
|
93
|
-
if (Array.isArray(e.keys))
|
|
94
|
-
return y(e.keys);
|
|
95
|
-
if (Array.isArray(e.banKeys)) {
|
|
96
|
-
const r = Object.keys(d).filter((t) => e.banKeys?.includes(t));
|
|
97
|
-
return y(r);
|
|
98
|
-
}
|
|
99
|
-
return c.store.state.values;
|
|
100
|
-
}
|
|
101
|
-
}, m = () => {
|
|
102
|
-
const e = n?.persistency;
|
|
103
|
-
if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
|
|
104
|
-
const r = e.policies.includes("local") ? localStorage : sessionStorage;
|
|
105
|
-
if (!r) return;
|
|
106
|
-
const t = v(e);
|
|
107
|
-
return r.setItem(a.value, JSON.stringify(t));
|
|
108
|
-
}
|
|
109
|
-
}, b = () => {
|
|
110
|
-
const e = n?.persistency;
|
|
111
|
-
if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
|
|
112
|
-
const r = v(e), t = new URLSearchParams(window.location.search);
|
|
113
|
-
t.set(a.value, JSON.stringify(r));
|
|
114
|
-
const s = new URL(window.location.href);
|
|
115
|
-
s.search = t.toString(), window.history.replaceState({}, "", s.toString());
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
K(m), M(() => {
|
|
119
|
-
window.addEventListener("beforeunload", m), window.addEventListener("blur", b);
|
|
120
|
-
}), q(() => {
|
|
121
|
-
window.removeEventListener("beforeunload", m), window.removeEventListener("blur", b);
|
|
122
|
-
});
|
|
123
|
-
const I = c.handleSubmit, p = Object.assign(c, {
|
|
124
|
-
i18nNamespace: n?.i18nNamespace,
|
|
125
|
-
meta: d,
|
|
126
|
-
filterItems: L,
|
|
127
|
-
clear: O,
|
|
128
|
-
handleSubmit: (e) => {
|
|
129
|
-
const r = P.getSpan(S.active());
|
|
130
|
-
return I({ currentSpan: r, ...e });
|
|
131
|
-
}
|
|
132
|
-
// /** @experimental */
|
|
133
|
-
// handleSubmitEffect: (meta?: Record<string, any>) =>
|
|
134
|
-
// Effect.currentSpan.pipe(
|
|
135
|
-
// Effect.option,
|
|
136
|
-
// Effect
|
|
137
|
-
// .flatMap((span) =>
|
|
138
|
-
// Effect.promise(() => form.handleSubmit(Option.isSome(span) ? { currentSpan: span.value, ...meta } : meta))
|
|
139
|
-
// )
|
|
140
|
-
// )
|
|
141
|
-
});
|
|
142
|
-
return x(B, p), Object.assign(p, {
|
|
143
|
-
Input: n?.input ? n.input(p) : _,
|
|
144
|
-
Field: c.Field
|
|
145
|
-
});
|
|
146
|
-
};
|
|
1
|
+
import { Exit as c, Runtime as s } from "effect";
|
|
2
|
+
import { dual as n, isFunction as m } from "./vue-components.es18.js";
|
|
3
|
+
const i = Symbol.for("clone-trait"), u = n(2, (e, t) => i in e ? e[i](t) : Object.setPrototypeOf(t, Object.getPrototypeOf(e)));
|
|
4
|
+
n(2, (e, t) => u(e, { ...e, ...m(t) ? t(e) : t }));
|
|
5
|
+
const b = (e) => new Promise((t, r) => e.addObserver((o) => {
|
|
6
|
+
c.isSuccess(o) ? t(o.value) : r(s.makeFiberFailure(o.cause));
|
|
7
|
+
}));
|
|
147
8
|
export {
|
|
148
|
-
|
|
149
|
-
|
|
9
|
+
u as clone,
|
|
10
|
+
i as cloneTrait,
|
|
11
|
+
b as runtimeFiberAsPromise
|
|
150
12
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-next.1",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@mdi/js": "^7.4.47",
|
|
6
6
|
"effect": "^3.17.13",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@opentelemetry/api": "^1.9.0",
|
|
49
|
-
"@tanstack/vue-form": "^1.
|
|
49
|
+
"@tanstack/vue-form": "^1.23.0",
|
|
50
50
|
"highlight.js": "^11.11.1",
|
|
51
51
|
"vue3-highlightjs": "^1.0.5",
|
|
52
52
|
"@effect-app/vue": "2.80.2",
|
|
@@ -42,9 +42,11 @@
|
|
|
42
42
|
<script
|
|
43
43
|
setup
|
|
44
44
|
lang="ts"
|
|
45
|
-
generic="
|
|
45
|
+
generic="
|
|
46
|
+
// dprint ignore - somehow with 120 chars, this becomes a mess. should report it.
|
|
46
47
|
From extends Record<PropertyKey, any>,
|
|
47
|
-
To extends Record<PropertyKey, any>
|
|
48
|
+
To extends Record<PropertyKey, any>
|
|
49
|
+
"
|
|
48
50
|
>
|
|
49
51
|
import { type DeepKeys, type DeepValue } from "@tanstack/vue-form"
|
|
50
52
|
import { computed, onMounted, provide } from "vue"
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
v-for="({ name, label, ...attrs }) in children"
|
|
4
4
|
:child="{ name, label, ...attrs }"
|
|
5
5
|
>
|
|
6
|
-
<
|
|
7
|
-
:form="props.form"
|
|
6
|
+
<form.Input
|
|
8
7
|
:name="name"
|
|
9
8
|
:label="label"
|
|
10
9
|
v-bind="attrs"
|
|
@@ -15,14 +14,15 @@
|
|
|
15
14
|
<script
|
|
16
15
|
setup
|
|
17
16
|
lang="ts"
|
|
18
|
-
generic="
|
|
19
|
-
|
|
17
|
+
generic="
|
|
18
|
+
From extends Record<PropertyKey, string>,
|
|
19
|
+
To extends Record<PropertyKey, string>
|
|
20
|
+
"
|
|
20
21
|
>
|
|
21
22
|
import { type DeepKeys } from "@tanstack/vue-form"
|
|
22
23
|
import { Array as A, Order, pipe } from "effect-app"
|
|
23
24
|
import { computed } from "vue"
|
|
24
25
|
import { type FieldMeta, type OmegaInputProps } from "./OmegaFormStuff"
|
|
25
|
-
import OmegaInput from "./OmegaInput.vue"
|
|
26
26
|
|
|
27
27
|
export type OmegaAutoGenMeta<
|
|
28
28
|
From extends Record<PropertyKey, string>,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StandardSchemaV1Issue } from "@tanstack/vue-form"
|
|
2
|
-
import { computed, inject, type InjectionKey,
|
|
2
|
+
import { computed, inject, type InjectionKey, readonly, type Ref, ref } from "vue"
|
|
3
3
|
import { type OmegaError, type ShowErrorsOn } from "./OmegaFormStuff"
|
|
4
4
|
|
|
5
5
|
export const OmegaErrorsKey = Symbol() as InjectionKey<{
|
|
@@ -9,15 +9,19 @@ export const OmegaErrorsKey = Symbol() as InjectionKey<{
|
|
|
9
9
|
clearErrors: () => void
|
|
10
10
|
showErrors: Ref<boolean>
|
|
11
11
|
showErrorsOn: ShowErrorsOn
|
|
12
|
-
generalErrors:
|
|
13
|
-
|
|
12
|
+
generalErrors: Readonly<
|
|
13
|
+
Ref<
|
|
14
|
+
(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined
|
|
15
|
+
>
|
|
14
16
|
>
|
|
15
17
|
}>
|
|
16
18
|
|
|
17
|
-
export function
|
|
19
|
+
export function buildOmegaErrors(
|
|
18
20
|
formSubmissionAttempts: Ref<number>,
|
|
19
|
-
generalErrors:
|
|
20
|
-
|
|
21
|
+
generalErrors: Readonly<
|
|
22
|
+
Ref<
|
|
23
|
+
(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined
|
|
24
|
+
>
|
|
21
25
|
>,
|
|
22
26
|
showErrorsOn: ShowErrorsOn = "onSubmit"
|
|
23
27
|
) {
|
|
@@ -51,8 +55,6 @@ export function provideOmegaErrors(
|
|
|
51
55
|
showErrorsOn: showErrorsOn ?? "onSubmit"
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
provide(OmegaErrorsKey, context)
|
|
55
|
-
|
|
56
58
|
return context
|
|
57
59
|
}
|
|
58
60
|
|