@effect-app/vue-components 1.4.2 → 1.5.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/blockDialog.d.ts +12 -0
- package/dist/types/components/OmegaForm/index.d.ts +1 -0
- package/dist/types/components/OmegaForm/onMountedWithCleanup.d.ts +6 -0
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +1 -0
- package/dist/vue-components.es.js +21 -18
- package/dist/vue-components.es10.js +30 -10
- package/dist/vue-components.es11.js +10 -5
- package/dist/vue-components.es12.js +5 -54
- package/dist/vue-components.es13.js +49 -63
- package/dist/vue-components.es14.js +68 -6
- package/dist/vue-components.es15.js +5 -5
- package/dist/vue-components.es16.js +6 -3
- package/dist/vue-components.es17.js +3 -3
- package/dist/vue-components.es18.js +3 -2
- package/dist/vue-components.es19.js +1 -1
- package/dist/vue-components.es2.js +12 -9
- package/dist/vue-components.es20.js +2 -135
- package/dist/vue-components.es21.js +19 -0
- package/dist/vue-components.es22.js +11 -42
- package/dist/vue-components.es23.js +135 -2
- package/dist/vue-components.es25.js +41 -89
- package/dist/vue-components.es27.js +2 -7
- package/dist/vue-components.es28.js +86 -27
- package/dist/vue-components.es30.js +7 -4
- package/dist/vue-components.es31.js +31 -23
- package/dist/vue-components.es33.js +4 -21
- package/dist/vue-components.es34.js +20 -27
- package/dist/vue-components.es35.js +5 -22
- package/dist/vue-components.es36.js +15 -6
- package/dist/vue-components.es37.js +30 -5
- package/dist/vue-components.es38.js +22 -19
- package/dist/vue-components.es39.js +12 -9
- package/dist/vue-components.es4.js +1 -1
- package/dist/vue-components.es40.js +5 -31
- package/dist/vue-components.es41.js +19 -48
- package/dist/vue-components.es42.js +9 -26
- package/dist/vue-components.es43.js +31 -11
- package/dist/vue-components.es44.js +37 -54
- package/dist/vue-components.es45.js +21 -51
- package/dist/vue-components.es46.js +10 -16
- package/dist/vue-components.es47.js +64 -32
- package/dist/vue-components.es48.js +55 -28
- package/dist/vue-components.es49.js +16 -41
- package/dist/vue-components.es5.js +44 -44
- package/dist/vue-components.es50.js +33 -2
- package/dist/vue-components.es51.js +28 -43
- package/dist/vue-components.es52.js +42 -2
- package/dist/vue-components.es53.js +4 -0
- package/dist/vue-components.es54.js +46 -0
- package/dist/vue-components.es55.js +4 -0
- package/dist/vue-components.es7.js +45 -44
- package/dist/vue-components.es8.js +29 -355
- package/dist/vue-components.es9.js +352 -26
- package/package.json +5 -4
- package/src/components/OmegaForm/OmegaInternalInput.vue +6 -4
- package/src/components/OmegaForm/blockDialog.ts +56 -0
- package/src/components/OmegaForm/index.ts +2 -0
- package/src/components/OmegaForm/onMountedWithCleanup.ts +22 -0
- package/src/components/OmegaForm/useOmegaForm.ts +7 -0
- package/dist/vue-components.es32.js +0 -7
- /package/dist/{vue-components.es24.js → vue-components.es26.js} +0 -0
|
@@ -1,32 +1,358 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import { S as n, Option as c, pipe as q } from "effect-app";
|
|
2
|
+
import { getMetadataFromSchema as U } from "@effect-app/vue/form";
|
|
3
|
+
import { useIntl as _, getTransformationFrom as N } from "./vue-components.es3.js";
|
|
4
|
+
const w = 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 = {}) => {
|
|
5
|
+
if (t && t._tag === "Transformation")
|
|
6
|
+
return m({
|
|
7
|
+
parent: i,
|
|
8
|
+
meta: e,
|
|
9
|
+
property: t.from
|
|
10
|
+
});
|
|
11
|
+
if (t?._tag === "TypeLiteral" && "propertySignatures" in t)
|
|
12
|
+
return m({
|
|
13
|
+
meta: e,
|
|
14
|
+
propertySignatures: t.propertySignatures
|
|
15
|
+
});
|
|
16
|
+
if (p) {
|
|
17
|
+
for (const r of p) {
|
|
18
|
+
const l = i ? `${i}.${r.name.toString()}` : r.name.toString(), a = g(r.type), u = !a, A = r.type;
|
|
19
|
+
if (n.AST.isUnion(r.type)) {
|
|
20
|
+
const T = r.type.types.filter(
|
|
21
|
+
(s) => s._tag !== "UndefinedKeyword" && s !== n.Null.ast
|
|
22
|
+
).map(N);
|
|
23
|
+
if (T.some(
|
|
24
|
+
(s) => "propertySignatures" in s
|
|
25
|
+
)) {
|
|
26
|
+
if (!a) {
|
|
27
|
+
const s = m({
|
|
28
|
+
parent: l,
|
|
29
|
+
property: r.type,
|
|
30
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
31
|
+
});
|
|
32
|
+
o[l] = s;
|
|
33
|
+
}
|
|
34
|
+
for (const s of T)
|
|
35
|
+
"propertySignatures" in s && Object.assign(
|
|
36
|
+
o,
|
|
37
|
+
m({
|
|
38
|
+
parent: l,
|
|
39
|
+
propertySignatures: s.propertySignatures,
|
|
40
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
} else {
|
|
44
|
+
const s = T.filter(n.AST.isTupleType);
|
|
45
|
+
if (s.length > 0) {
|
|
46
|
+
const f = s[0];
|
|
47
|
+
if (o[l] = {
|
|
48
|
+
type: "multiple",
|
|
49
|
+
members: f.elements,
|
|
50
|
+
rest: f.rest,
|
|
51
|
+
required: u,
|
|
52
|
+
nullableOrUndefined: a
|
|
53
|
+
}, f.rest && f.rest.length > 0) {
|
|
54
|
+
const d = f.rest[0];
|
|
55
|
+
if (d.type._tag === "TypeLiteral" && "propertySignatures" in d.type)
|
|
56
|
+
for (const y of d.type.propertySignatures) {
|
|
57
|
+
const b = `${l}.${y.name.toString()}`, S = m({
|
|
58
|
+
parent: b,
|
|
59
|
+
property: y.type,
|
|
60
|
+
meta: {
|
|
61
|
+
required: !g(y.type),
|
|
62
|
+
nullableOrUndefined: g(y.type)
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
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)) {
|
|
66
|
+
const O = y.type.rest[0];
|
|
67
|
+
if (O.type._tag === "TypeLiteral" && "propertySignatures" in O.type)
|
|
68
|
+
for (const x of O.type.propertySignatures) {
|
|
69
|
+
const M = `${b}.${x.name.toString()}`, v = m({
|
|
70
|
+
parent: M,
|
|
71
|
+
property: x.type,
|
|
72
|
+
meta: {
|
|
73
|
+
required: !g(x.type),
|
|
74
|
+
nullableOrUndefined: g(x.type)
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
v && typeof v == "object" && "type" in v && (o[M] = v);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
const f = m({
|
|
84
|
+
parent: l,
|
|
85
|
+
property: r.type,
|
|
86
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
87
|
+
});
|
|
88
|
+
o[l] = f;
|
|
89
|
+
}
|
|
25
90
|
}
|
|
91
|
+
} else if ("propertySignatures" in A)
|
|
92
|
+
Object.assign(
|
|
93
|
+
o,
|
|
94
|
+
m({
|
|
95
|
+
parent: l,
|
|
96
|
+
propertySignatures: A.propertySignatures,
|
|
97
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
else if (n.AST.isTupleType(r.type))
|
|
101
|
+
if (r.type.rest.length > 0 && r.type.rest[0].type._tag === "TypeLiteral" && "propertySignatures" in r.type.rest[0].type) {
|
|
102
|
+
const h = r.type.rest[0].type;
|
|
103
|
+
if (h._tag === "TypeLiteral" && "propertySignatures" in h)
|
|
104
|
+
for (const s of h.propertySignatures) {
|
|
105
|
+
const f = `${l}.${s.name.toString()}`;
|
|
106
|
+
if (n.AST.isTupleType(s.type) && s.type.rest.length > 0) {
|
|
107
|
+
const d = s.type.rest[0].type;
|
|
108
|
+
if (d._tag === "TypeLiteral" && "propertySignatures" in d)
|
|
109
|
+
for (const y of d.propertySignatures) {
|
|
110
|
+
const b = `${f}.${y.name.toString()}`, S = m({
|
|
111
|
+
parent: b,
|
|
112
|
+
property: y.type,
|
|
113
|
+
meta: {
|
|
114
|
+
required: !g(y.type),
|
|
115
|
+
nullableOrUndefined: g(y.type)
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
o[b] = S;
|
|
119
|
+
}
|
|
120
|
+
else
|
|
121
|
+
o[f] = {
|
|
122
|
+
type: "multiple",
|
|
123
|
+
members: s.type.elements,
|
|
124
|
+
rest: s.type.rest,
|
|
125
|
+
required: !g(s.type),
|
|
126
|
+
nullableOrUndefined: g(s.type)
|
|
127
|
+
};
|
|
128
|
+
} else {
|
|
129
|
+
const d = m({
|
|
130
|
+
parent: f,
|
|
131
|
+
property: s.type,
|
|
132
|
+
meta: {
|
|
133
|
+
required: !g(s.type),
|
|
134
|
+
nullableOrUndefined: g(s.type)
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
o[f] = d;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
} else
|
|
141
|
+
o[l] = {
|
|
142
|
+
type: "multiple",
|
|
143
|
+
members: r.type.elements,
|
|
144
|
+
rest: r.type.rest,
|
|
145
|
+
required: u,
|
|
146
|
+
nullableOrUndefined: a
|
|
147
|
+
};
|
|
148
|
+
else {
|
|
149
|
+
const T = m({
|
|
150
|
+
parent: l,
|
|
151
|
+
property: r.type,
|
|
152
|
+
meta: {
|
|
153
|
+
// an empty string is valid for a S.String field, so we should not mark it as required
|
|
154
|
+
// TODO: handle this better via the createMeta minLength parsing
|
|
155
|
+
required: u && (r.type._tag !== "StringKeyword" || U(r.type).minLength),
|
|
156
|
+
nullableOrUndefined: a
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
o[l] = T;
|
|
26
160
|
}
|
|
27
161
|
}
|
|
162
|
+
return o;
|
|
163
|
+
}
|
|
164
|
+
if (t) {
|
|
165
|
+
const r = E(t);
|
|
166
|
+
if (Object.hasOwnProperty.call(e, "required") || (e.required = !r), n.AST.isUnion(t)) {
|
|
167
|
+
const a = t.types.find(
|
|
168
|
+
(u) => u._tag !== "UndefinedKeyword" && u !== n.Null.ast
|
|
169
|
+
);
|
|
170
|
+
return "propertySignatures" in a ? m({
|
|
171
|
+
propertySignatures: a.propertySignatures,
|
|
172
|
+
parent: i,
|
|
173
|
+
meta: e
|
|
174
|
+
}) : t.types.every(n.AST.isLiteral) ? {
|
|
175
|
+
...e,
|
|
176
|
+
type: "select",
|
|
177
|
+
members: t.types.map((u) => u.literal)
|
|
178
|
+
} : {
|
|
179
|
+
...e,
|
|
180
|
+
...m({
|
|
181
|
+
parent: i,
|
|
182
|
+
meta: e,
|
|
183
|
+
property: a
|
|
184
|
+
})
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
if (n.AST.isTupleType(t))
|
|
188
|
+
return {
|
|
189
|
+
...e,
|
|
190
|
+
type: "multiple",
|
|
191
|
+
members: t.elements,
|
|
192
|
+
rest: t.rest
|
|
193
|
+
};
|
|
194
|
+
const l = n.AST.getAnnotation(
|
|
195
|
+
t,
|
|
196
|
+
n.AST.JSONSchemaAnnotationId
|
|
197
|
+
).pipe(c.getOrElse(() => ({})));
|
|
198
|
+
return e = { ...e, ...l }, "from" in t ? m({
|
|
199
|
+
parent: i,
|
|
200
|
+
meta: e,
|
|
201
|
+
property: t.from
|
|
202
|
+
}) : (e.type = n.AST.getAnnotation(
|
|
203
|
+
t,
|
|
204
|
+
n.AST.TitleAnnotationId
|
|
205
|
+
).pipe(
|
|
206
|
+
c.getOrElse(() => "unknown")
|
|
207
|
+
), e);
|
|
208
|
+
}
|
|
209
|
+
return o;
|
|
210
|
+
}, L = (e) => {
|
|
211
|
+
const i = e.ast, t = {};
|
|
212
|
+
if (i._tag === "Transformation" || i._tag === "Refinement")
|
|
213
|
+
return L(n.make(i.from));
|
|
214
|
+
if ("propertySignatures" in i) {
|
|
215
|
+
const p = m({
|
|
216
|
+
propertySignatures: i.propertySignatures
|
|
217
|
+
});
|
|
218
|
+
if (Object.values(p).every((r) => r && "type" in r))
|
|
219
|
+
return p;
|
|
220
|
+
const o = (r, l = "") => {
|
|
221
|
+
for (const a in r) {
|
|
222
|
+
const u = l ? `${l}.${a}` : a;
|
|
223
|
+
r[a] && typeof r[a] == "object" && "type" in r[a] ? t[u] = r[a] : r[a] && typeof r[a] == "object" && o(r[a], u);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
o(p);
|
|
227
|
+
}
|
|
228
|
+
return t;
|
|
229
|
+
}, P = (e) => n.extend(e, n.Struct({})), F = (e) => {
|
|
230
|
+
const i = L(e), t = q(
|
|
231
|
+
e.ast,
|
|
232
|
+
c.liftPredicate((p) => p._tag === "Refinement" && "filter" in p),
|
|
233
|
+
c.flatMap((p) => n.AST.getJSONSchemaAnnotation(p)),
|
|
234
|
+
c.filter((p) => "items" in p),
|
|
235
|
+
c.filterMap(({ items: p }) => n.decodeUnknownOption(w)(p)),
|
|
236
|
+
c.zipWith(
|
|
237
|
+
n.AST.getMessageAnnotation(e.ast),
|
|
238
|
+
(p, o) => ({
|
|
239
|
+
items: p,
|
|
240
|
+
message: o("")
|
|
241
|
+
})
|
|
242
|
+
),
|
|
243
|
+
c.getOrUndefined
|
|
28
244
|
);
|
|
29
|
-
};
|
|
245
|
+
return { schema: e, meta: i, filterItems: t };
|
|
246
|
+
}, j = (e) => {
|
|
247
|
+
const { trans: i } = _();
|
|
248
|
+
let t;
|
|
249
|
+
switch (e.type) {
|
|
250
|
+
case "string":
|
|
251
|
+
t = n.String.annotations({
|
|
252
|
+
message: () => i("validation.empty")
|
|
253
|
+
}), e.format === "email" && (t = n.compose(
|
|
254
|
+
t,
|
|
255
|
+
n.Email.annotations({
|
|
256
|
+
message: () => i("validation.email.invalid")
|
|
257
|
+
})
|
|
258
|
+
)), e.required && t.annotations({
|
|
259
|
+
message: () => i("validation.empty")
|
|
260
|
+
}), e.maxLength && (t = t.pipe(n.maxLength(e.maxLength)).annotations({
|
|
261
|
+
message: () => i("validation.string.maxLength", {
|
|
262
|
+
maxLength: e.maxLength
|
|
263
|
+
})
|
|
264
|
+
})), e.minLength && (t = t.pipe(n.minLength(e.minLength)).annotations({
|
|
265
|
+
message: () => i("validation.string.minLength", {
|
|
266
|
+
minLength: e.minLength
|
|
267
|
+
})
|
|
268
|
+
}));
|
|
269
|
+
break;
|
|
270
|
+
case "number":
|
|
271
|
+
t = n.Number.annotations({
|
|
272
|
+
message: () => i("validation.empty")
|
|
273
|
+
}), e.required && t.annotations({
|
|
274
|
+
message: () => i("validation.empty")
|
|
275
|
+
}), e.minimum && (t = t.pipe(n.greaterThanOrEqualTo(e.minimum)).annotations({
|
|
276
|
+
message: () => i("validation.number.min", {
|
|
277
|
+
minimum: e.minimum,
|
|
278
|
+
isExclusive: !0
|
|
279
|
+
})
|
|
280
|
+
})), e.maximum && (t = t.pipe(n.lessThanOrEqualTo(e.maximum)).annotations({
|
|
281
|
+
message: () => i("validation.number.max", {
|
|
282
|
+
maximum: e.maximum,
|
|
283
|
+
isExclusive: !0
|
|
284
|
+
})
|
|
285
|
+
})), e.exclusiveMinimum && (t = t.pipe(n.greaterThan(e.exclusiveMinimum)).annotations({
|
|
286
|
+
message: () => i("validation.number.min", {
|
|
287
|
+
minimum: e.exclusiveMinimum,
|
|
288
|
+
isExclusive: !1
|
|
289
|
+
})
|
|
290
|
+
})), e.exclusiveMaximum && (t = t.pipe(n.lessThan(e.exclusiveMaximum)).annotations({
|
|
291
|
+
message: () => i("validation.number.max", {
|
|
292
|
+
maximum: e.exclusiveMaximum,
|
|
293
|
+
isExclusive: !1
|
|
294
|
+
})
|
|
295
|
+
}));
|
|
296
|
+
break;
|
|
297
|
+
case "select":
|
|
298
|
+
t = n.Literal(...e.members).annotations({
|
|
299
|
+
message: () => ({
|
|
300
|
+
message: i("validation.not_a_valid", {
|
|
301
|
+
type: "select",
|
|
302
|
+
message: e.members.join(", ")
|
|
303
|
+
}),
|
|
304
|
+
override: !0
|
|
305
|
+
})
|
|
306
|
+
});
|
|
307
|
+
break;
|
|
308
|
+
case "multiple":
|
|
309
|
+
t = n.Array(n.String).annotations({
|
|
310
|
+
message: () => i("validation.not_a_valid", {
|
|
311
|
+
type: "multiple",
|
|
312
|
+
message: e.members.join(", ")
|
|
313
|
+
})
|
|
314
|
+
});
|
|
315
|
+
break;
|
|
316
|
+
case "boolean":
|
|
317
|
+
t = n.Boolean;
|
|
318
|
+
break;
|
|
319
|
+
// todo: switch must be exhaustive or have default case, otherwise falls through with schema undefined.
|
|
320
|
+
case "unknown":
|
|
321
|
+
t = n.Unknown;
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
return e.required ? t.pipe(
|
|
325
|
+
n.annotations({
|
|
326
|
+
message: () => i("validation.empty")
|
|
327
|
+
})
|
|
328
|
+
) : t = n.NullishOr(t), n.standardSchemaV1(t);
|
|
329
|
+
}, R = (e, i) => n.NullOr(e).pipe(
|
|
330
|
+
n.transform(n.typeSchema(e), {
|
|
331
|
+
decode: (t) => t ?? i(),
|
|
332
|
+
encode: (t) => t
|
|
333
|
+
})
|
|
334
|
+
), k = [
|
|
335
|
+
"button",
|
|
336
|
+
"checkbox",
|
|
337
|
+
"color",
|
|
338
|
+
"date",
|
|
339
|
+
"email",
|
|
340
|
+
"number",
|
|
341
|
+
"password",
|
|
342
|
+
"radio",
|
|
343
|
+
"range",
|
|
344
|
+
"search",
|
|
345
|
+
"submit",
|
|
346
|
+
"tel",
|
|
347
|
+
"text",
|
|
348
|
+
"time",
|
|
349
|
+
"url"
|
|
350
|
+
], J = (e) => k.includes(e) ? e : "text";
|
|
30
351
|
export {
|
|
31
|
-
|
|
352
|
+
m as createMeta,
|
|
353
|
+
P as duplicateSchema,
|
|
354
|
+
j as generateInputStandardSchemaFromFieldMeta,
|
|
355
|
+
F as generateMetaFromSchema,
|
|
356
|
+
J as getInputType,
|
|
357
|
+
R as nullableInput
|
|
32
358
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@mdi/js": "^7.4.47",
|
|
6
6
|
"effect": "^3.18.0",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"@storybook/vue3-vite": "^9.1.9",
|
|
18
18
|
"@types/node": "^24.6.0",
|
|
19
19
|
"@vitejs/plugin-vue": "^6.0.1",
|
|
20
|
-
"@vueuse/core": "^13.9.0",
|
|
21
20
|
"@vue/test-utils": "^2.4.6",
|
|
21
|
+
"@vueuse/core": "^13.9.0",
|
|
22
22
|
"dprint": "^0.50.2",
|
|
23
23
|
"jsdom": "^27.0.0",
|
|
24
24
|
"rimraf": "^6.0.1",
|
|
@@ -49,9 +49,10 @@
|
|
|
49
49
|
"@opentelemetry/api": "^1.9.0",
|
|
50
50
|
"@tanstack/vue-form": "^1.23.5",
|
|
51
51
|
"highlight.js": "^11.11.1",
|
|
52
|
+
"mitt": "^3.0.1",
|
|
52
53
|
"vue3-highlightjs": "^1.0.5",
|
|
53
|
-
"
|
|
54
|
-
"effect-app": "
|
|
54
|
+
"effect-app": "3.9.0",
|
|
55
|
+
"@effect-app/vue": "2.82.0"
|
|
55
56
|
},
|
|
56
57
|
"scripts": {
|
|
57
58
|
"build": "pnpm build:run",
|
|
@@ -57,9 +57,11 @@ const fieldType = computed(() => {
|
|
|
57
57
|
})
|
|
58
58
|
|
|
59
59
|
const fieldValue = computed(() => fieldState.value.value)
|
|
60
|
+
// workaround strange tanstack form issue where the errors key becomes undefined ???
|
|
61
|
+
const _errors = computed(() => fieldState.value.meta.errors ?? [])
|
|
60
62
|
const errors = computed(() =>
|
|
61
63
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
-
|
|
64
|
+
_errors.value.map((e: any) => e?.message).filter(Boolean)
|
|
63
65
|
)
|
|
64
66
|
|
|
65
67
|
const isFalsyButNotZero = (value: unknown): boolean => {
|
|
@@ -123,9 +125,9 @@ const showedErrors = computed(() => {
|
|
|
123
125
|
})
|
|
124
126
|
|
|
125
127
|
watch(
|
|
126
|
-
|
|
127
|
-
() => {
|
|
128
|
-
if (
|
|
128
|
+
_errors,
|
|
129
|
+
(errors) => {
|
|
130
|
+
if (errors.length) {
|
|
129
131
|
mapError({
|
|
130
132
|
inputId: id,
|
|
131
133
|
errors: fieldState
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import mitt from "mitt"
|
|
2
|
+
import { inject, type InjectionKey, provide, type Ref } from "vue"
|
|
3
|
+
import { onMountedWithCleanup } from "./onMountedWithCleanup"
|
|
4
|
+
|
|
5
|
+
export type DialogClosing = { prevent?: boolean | Promise<boolean> }
|
|
6
|
+
const makeBus = () => mitt<{ "dialog-closing": DialogClosing }>()
|
|
7
|
+
|
|
8
|
+
const Bus = Symbol("dialog") as InjectionKey<ReturnType<typeof makeBus>>
|
|
9
|
+
|
|
10
|
+
export const injectBus = () => inject(Bus)
|
|
11
|
+
export const provideBus = () => {
|
|
12
|
+
const bus = makeBus()
|
|
13
|
+
provide(Bus, bus)
|
|
14
|
+
return bus
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const usePreventClose = (mkIsDirty: () => Ref<boolean>) => {
|
|
18
|
+
const bus = injectBus()
|
|
19
|
+
if (!bus) {
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
const isDirty = mkIsDirty()
|
|
23
|
+
onMountedWithCleanup(() => {
|
|
24
|
+
const onDialogClosing = (evt: DialogClosing) => {
|
|
25
|
+
if (isDirty.value) {
|
|
26
|
+
if (!confirm("Es sind ungespeicherte Änderungen vorhanden. Wirklich schließen?")) {
|
|
27
|
+
evt.prevent = true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
bus.on("dialog-closing", onDialogClosing)
|
|
32
|
+
|
|
33
|
+
return () => bus.off("dialog-closing", onDialogClosing)
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const useOnClose = (close: () => void) => {
|
|
38
|
+
const bus = provideBus()
|
|
39
|
+
const onClose = () => {
|
|
40
|
+
const evt: DialogClosing = {}
|
|
41
|
+
bus.emit("dialog-closing", evt)
|
|
42
|
+
if (evt.prevent) {
|
|
43
|
+
if (typeof evt.prevent === "object" && "then" in evt.prevent) {
|
|
44
|
+
evt.prevent.then((r) => {
|
|
45
|
+
if (r !== false) {
|
|
46
|
+
close()
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
close()
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return onClose
|
|
56
|
+
}
|
|
@@ -5,6 +5,8 @@ export { type OmegaFormReturn, useOmegaForm } from "./useOmegaForm"
|
|
|
5
5
|
export { default as OmegaInput } from "./OmegaInput.vue"
|
|
6
6
|
export { default as OmegaVuetifyInput } from "./OmegaInternalInput.vue"
|
|
7
7
|
|
|
8
|
+
export { useOnClose, usePreventClose } from "./blockDialog"
|
|
9
|
+
|
|
8
10
|
export { getInputType } from "./OmegaFormStuff"
|
|
9
11
|
|
|
10
12
|
export { createUseFormWithCustomInput } from "./createUseFormWithCustomInput"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
|
|
2
|
+
|
|
3
|
+
import { onMounted, onUnmounted } from "vue"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A convenience wrapper for onMounted and onUnmounted, the returned Function of the callback,
|
|
7
|
+
* will be ran on unmount.
|
|
8
|
+
* @param cb Function to run on unmount
|
|
9
|
+
*/
|
|
10
|
+
export function onMountedWithCleanup(cb: () => Function | void) {
|
|
11
|
+
let cleanup: Function | undefined = undefined
|
|
12
|
+
onMounted(() => {
|
|
13
|
+
const cleanup_ = cb()
|
|
14
|
+
if (cleanup_) {
|
|
15
|
+
cleanup = cleanup_
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
onUnmounted(() => {
|
|
20
|
+
if (cleanup) cleanup()
|
|
21
|
+
})
|
|
22
|
+
}
|
|
@@ -7,6 +7,7 @@ import { Data, Effect, Fiber, Option, Order, S } from "effect-app"
|
|
|
7
7
|
import { runtimeFiberAsPromise } from "effect-app/utils"
|
|
8
8
|
import { isObject } from "effect/Predicate"
|
|
9
9
|
import { Component, computed, ConcreteComponent, h, type InjectionKey, onBeforeUnmount, onMounted, onUnmounted, watch } from "vue"
|
|
10
|
+
import { usePreventClose } from "./blockDialog"
|
|
10
11
|
import { type InputProps } from "./InputProps"
|
|
11
12
|
import OmegaArray from "./OmegaArray.vue"
|
|
12
13
|
import OmegaAutoGen from "./OmegaAutoGen.vue"
|
|
@@ -100,6 +101,8 @@ export type OmegaConfig<T> = {
|
|
|
100
101
|
id?: string
|
|
101
102
|
} & keysRule<T>
|
|
102
103
|
|
|
104
|
+
ignorePreventCloseEvents?: boolean
|
|
105
|
+
|
|
103
106
|
input?: any
|
|
104
107
|
}
|
|
105
108
|
|
|
@@ -909,6 +912,10 @@ export const useOmegaForm = <
|
|
|
909
912
|
// provide(OmegaFormKey, formWithExtras)
|
|
910
913
|
const errorContext = buildOmegaErrors(formSubmissionAttempts, errors, omegaConfig?.showErrorsOn)
|
|
911
914
|
|
|
915
|
+
if (!omegaConfig?.ignorePreventCloseEvents) {
|
|
916
|
+
usePreventClose(() => formWithExtras.useStore((state) => state.isDirty))
|
|
917
|
+
}
|
|
918
|
+
|
|
912
919
|
return Object.assign(formWithExtras, {
|
|
913
920
|
errorContext,
|
|
914
921
|
Form: fHoc(formWithExtras)(OmegaForm as any) as any,
|
|
File without changes
|