@effect-app/vue-components 2.0.0 → 2.1.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.
Files changed (75) hide show
  1. package/dist/types/components/OmegaForm/InputProps.d.ts +24 -0
  2. package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +1 -1
  3. package/dist/types/components/OmegaForm/OmegaInternalInput.vue.d.ts +2 -2
  4. package/dist/types/components/OmegaForm/OmegaTaggedUnion.vue.d.ts +34 -0
  5. package/dist/types/components/OmegaForm/OmegaTaggedUnionInternal.vue.d.ts +32 -0
  6. package/dist/types/components/OmegaForm/index.d.ts +3 -1
  7. package/dist/types/components/OmegaForm/useOmegaForm.d.ts +26 -0
  8. package/dist/vue-components.es.js +30 -26
  9. package/dist/vue-components.es10.js +223 -341
  10. package/dist/vue-components.es11.js +29 -33
  11. package/dist/vue-components.es12.js +357 -2
  12. package/dist/vue-components.es13.js +34 -2
  13. package/dist/vue-components.es14.js +2 -10
  14. package/dist/vue-components.es15.js +2 -5
  15. package/dist/vue-components.es16.js +10 -54
  16. package/dist/vue-components.es17.js +5 -68
  17. package/dist/vue-components.es18.js +54 -6
  18. package/dist/vue-components.es19.js +68 -6
  19. package/dist/vue-components.es2.js +20 -16
  20. package/dist/vue-components.es20.js +6 -3
  21. package/dist/vue-components.es21.js +6 -3
  22. package/dist/vue-components.es22.js +3 -2
  23. package/dist/vue-components.es23.js +3 -2
  24. package/dist/vue-components.es24.js +2 -17
  25. package/dist/vue-components.es25.js +2 -11
  26. package/dist/vue-components.es26.js +2 -136
  27. package/dist/vue-components.es27.js +4 -0
  28. package/dist/vue-components.es28.js +17 -42
  29. package/dist/vue-components.es29.js +11 -2
  30. package/dist/vue-components.es30.js +136 -2
  31. package/dist/vue-components.es32.js +44 -0
  32. package/dist/vue-components.es33.js +2 -7
  33. package/dist/vue-components.es34.js +2 -32
  34. package/dist/vue-components.es37.js +7 -23
  35. package/dist/vue-components.es38.js +32 -5
  36. package/dist/vue-components.es40.js +4 -30
  37. package/dist/vue-components.es41.js +20 -19
  38. package/dist/vue-components.es42.js +5 -12
  39. package/dist/vue-components.es43.js +21 -5
  40. package/dist/vue-components.es44.js +29 -18
  41. package/dist/vue-components.es45.js +22 -9
  42. package/dist/vue-components.es46.js +7 -26
  43. package/dist/vue-components.es47.js +5 -48
  44. package/dist/vue-components.es48.js +19 -26
  45. package/dist/vue-components.es49.js +9 -11
  46. package/dist/vue-components.es5.js +2 -2
  47. package/dist/vue-components.es50.js +26 -60
  48. package/dist/vue-components.es51.js +37 -45
  49. package/dist/vue-components.es52.js +26 -17
  50. package/dist/vue-components.es53.js +10 -32
  51. package/dist/vue-components.es54.js +65 -29
  52. package/dist/vue-components.es55.js +45 -31
  53. package/dist/vue-components.es56.js +17 -2
  54. package/dist/vue-components.es57.js +29 -40
  55. package/dist/vue-components.es58.js +29 -2
  56. package/dist/vue-components.es59.js +44 -0
  57. package/dist/vue-components.es6.js +9 -9
  58. package/dist/vue-components.es60.js +4 -0
  59. package/dist/vue-components.es61.js +46 -0
  60. package/dist/vue-components.es62.js +4 -0
  61. package/dist/vue-components.es7.js +26 -25
  62. package/dist/vue-components.es8.js +51 -198
  63. package/dist/vue-components.es9.js +17 -30
  64. package/package.json +1 -1
  65. package/src/components/OmegaForm/InputProps.ts +32 -0
  66. package/src/components/OmegaForm/OmegaFormStuff.ts +22 -3
  67. package/src/components/OmegaForm/OmegaInput.vue +4 -1
  68. package/src/components/OmegaForm/OmegaInternalInput.vue +35 -13
  69. package/src/components/OmegaForm/OmegaTaggedUnion.vue +73 -0
  70. package/src/components/OmegaForm/OmegaTaggedUnionInternal.vue +38 -0
  71. package/src/components/OmegaForm/index.ts +3 -1
  72. package/src/components/OmegaForm/useOmegaForm.ts +178 -11
  73. package/dist/vue-components.es36.js +0 -6
  74. package/dist/vue-components.es39.js +0 -23
  75. /package/dist/{vue-components.es31.js → vue-components.es35.js} +0 -0
@@ -1,353 +1,235 @@
1
- import { S as n, Option as M } from "effect-app";
2
- import { getMetadataFromSchema as w } from "@effect-app/vue/form";
3
- import { useIntl as _, getTransformationFrom as N } from "./vue-components.es3.js";
4
- const E = (e) => n.AST.isUnion(e) && e.types.find((r) => r._tag === "UndefinedKeyword" || r === n.Null.ast), f = (e) => !e || !n.AST.isUnion(e) ? !1 : e.types.find((r) => r._tag === "UndefinedKeyword") ? "undefined" : e.types.find((r) => r === n.Null.ast) ? "null" : !1, L = (e) => {
5
- const r = [];
6
- for (const t of e)
7
- if (n.AST.isUnion(t)) {
8
- const g = L(t.types);
9
- r.push(...g);
10
- } else
11
- r.push(t);
12
- return r;
13
- }, l = ({ meta: e = {}, parent: r = "", property: t, propertySignatures: g }, a = {}) => {
14
- if (t && t._tag === "Transformation")
15
- return l({
16
- parent: r,
17
- meta: e,
18
- property: t.from
19
- });
20
- if (t?._tag === "TypeLiteral" && "propertySignatures" in t)
21
- return l({
22
- meta: e,
23
- propertySignatures: t.propertySignatures
24
- });
25
- if (g) {
26
- for (const i of g) {
27
- const o = r ? `${r}.${i.name.toString()}` : i.name.toString(), s = f(i.type), u = !s, S = i.type;
28
- if (n.AST.isUnion(i.type)) {
29
- const T = L(i.type.types).filter(
30
- (p) => p._tag !== "UndefinedKeyword" && p !== n.Null.ast
31
- ).map(N);
32
- if (T.some(
33
- (p) => "propertySignatures" in p
34
- )) {
35
- if (!s) {
36
- const p = l({
37
- parent: o,
38
- property: i.type,
39
- meta: { required: u, nullableOrUndefined: s }
40
- });
41
- a[o] = p;
42
- }
43
- for (const p of T)
44
- "propertySignatures" in p && Object.assign(
45
- a,
46
- l({
47
- parent: o,
48
- propertySignatures: p.propertySignatures,
49
- meta: { required: u, nullableOrUndefined: s }
50
- })
51
- );
52
- } else {
53
- const p = T.filter(n.AST.isTupleType);
54
- if (p.length > 0) {
55
- const m = p[0];
56
- if (a[o] = {
57
- type: "multiple",
58
- members: m.elements,
59
- rest: m.rest,
60
- required: u,
61
- nullableOrUndefined: s
62
- }, m.rest && m.rest.length > 0) {
63
- const c = m.rest[0];
64
- if (c.type._tag === "TypeLiteral" && "propertySignatures" in c.type)
65
- for (const d of c.type.propertySignatures) {
66
- const b = `${o}.${d.name.toString()}`, h = l({
67
- parent: b,
68
- property: d.type,
69
- meta: {
70
- required: !f(d.type),
71
- nullableOrUndefined: f(d.type)
72
- }
73
- });
74
- if (h && typeof h == "object" && "type" in h && (a[b] = h, h.type === "multiple" && n.AST.isTupleType(d.type) && d.type.rest && d.type.rest.length > 0)) {
75
- const A = d.type.rest[0];
76
- if (A.type._tag === "TypeLiteral" && "propertySignatures" in A.type)
77
- for (const x of A.type.propertySignatures) {
78
- const q = `${b}.${x.name.toString()}`, v = l({
79
- parent: q,
80
- property: x.type,
81
- meta: {
82
- required: !f(x.type),
83
- nullableOrUndefined: f(x.type)
84
- }
85
- });
86
- v && typeof v == "object" && "type" in v && (a[q] = v);
87
- }
88
- }
89
- }
90
- }
91
- } else {
92
- const m = l({
93
- parent: o,
94
- property: i.type,
95
- meta: { required: u, nullableOrUndefined: s }
96
- });
97
- a[o] = m;
1
+ import { useForm as q } from "@tanstack/vue-form";
2
+ import { Data as B, S as D, Effect as c, Fiber as x, Option as P, Array as g } from "effect-app";
3
+ import { runtimeFiberAsPromise as K } from "./vue-components.es16.js";
4
+ import { isObject as T } from "./vue-components.es17.js";
5
+ import { computed as O, onUnmounted as N, onMounted as G, onBeforeUnmount as z, watch as W, ref as Q, h as H } from "vue";
6
+ import X from "./vue-components.es18.js";
7
+ import Y from "./vue-components.es19.js";
8
+ import Z from "./vue-components.es20.js";
9
+ import { generateMetaFromSchema as C } from "./vue-components.es12.js";
10
+ import ee from "./vue-components.es6.js";
11
+ import re from "./vue-components.es8.js";
12
+ import te from "./vue-components.es21.js";
13
+ import { trace as R } from "./vue-components.es22.js";
14
+ import { context as L } from "./vue-components.es23.js";
15
+ class ne extends B.TaggedError("FormErrors") {
16
+ }
17
+ const E = (u) => function(s) {
18
+ return {
19
+ render() {
20
+ return H(s, {
21
+ form: u,
22
+ ...this.$attrs
23
+ }, this.$slots);
24
+ }
25
+ };
26
+ }, se = (u) => function(s) {
27
+ return {
28
+ setup() {
29
+ const { fieldMap: b, form: p } = u, y = p.useStore((d) => d.errors), f = p.useStore((d) => d.fieldMeta), M = p.useStore((d) => d.errorMap), j = O(() => {
30
+ const d = g.filterMap(
31
+ Object.entries(f.value),
32
+ ([i, v]) => {
33
+ const h = v.errors ?? [];
34
+ if (!h.length) return P.none();
35
+ const a = b.value.get(i);
36
+ return a ? P.some({
37
+ label: a.label,
38
+ inputId: a.id,
39
+ // Only show the first error
40
+ errors: [h[0]?.message].filter(Boolean)
41
+ }) : P.none();
98
42
  }
99
- }
100
- } else if ("propertySignatures" in S)
101
- Object.assign(
102
- a,
103
- l({
104
- parent: o,
105
- propertySignatures: S.propertySignatures,
106
- meta: { required: u, nullableOrUndefined: s }
107
- })
108
- );
109
- else if (n.AST.isTupleType(i.type))
110
- if (i.type.rest.length > 0 && i.type.rest[0].type._tag === "TypeLiteral" && "propertySignatures" in i.type.rest[0].type) {
111
- const T = i.type.rest[0].type;
112
- if (T._tag === "TypeLiteral" && "propertySignatures" in T)
113
- for (const y of T.propertySignatures) {
114
- const p = `${o}.${y.name.toString()}`;
115
- if (n.AST.isTupleType(y.type) && y.type.rest.length > 0) {
116
- const m = y.type.rest[0].type;
117
- if (m._tag === "TypeLiteral" && "propertySignatures" in m)
118
- for (const c of m.propertySignatures) {
119
- const d = `${p}.${c.name.toString()}`, b = l({
120
- parent: d,
121
- property: c.type,
122
- meta: {
123
- required: !f(c.type),
124
- nullableOrUndefined: f(c.type)
125
- }
43
+ ), F = [];
44
+ if (M.value.onSubmit) {
45
+ for (const [i, v] of Object.entries(M.value.onSubmit))
46
+ if (g.isArray(v) && v.length)
47
+ for (const h of v) {
48
+ const a = h;
49
+ if (a?.path && g.isArray(a.path) && a.path.length) {
50
+ const S = a.path.join(".");
51
+ if (!b.value.has(S)) {
52
+ F.push({
53
+ label: S,
54
+ inputId: S,
55
+ errors: [a.message].filter(Boolean)
126
56
  });
127
- a[d] = b;
128
- }
129
- else
130
- a[p] = {
131
- type: "multiple",
132
- members: y.type.elements,
133
- rest: y.type.rest,
134
- required: !f(y.type),
135
- nullableOrUndefined: f(y.type)
136
- };
137
- } else {
138
- const m = l({
139
- parent: p,
140
- property: y.type,
141
- meta: {
142
- required: !f(y.type),
143
- nullableOrUndefined: f(y.type)
57
+ break;
144
58
  }
145
- });
146
- a[p] = m;
59
+ }
147
60
  }
148
- }
149
- } else
150
- a[o] = {
151
- type: "multiple",
152
- members: i.type.elements,
153
- rest: i.type.rest,
154
- required: u,
155
- nullableOrUndefined: s
156
- };
157
- else {
158
- const O = l({
159
- parent: o,
160
- property: i.type,
161
- meta: {
162
- // an empty string is valid for a S.String field, so we should not mark it as required
163
- // TODO: handle this better via the createMeta minLength parsing
164
- required: u && (i.type._tag !== "StringKeyword" || w(i.type).minLength),
165
- nullableOrUndefined: s
166
- }
167
- });
168
- a[o] = O;
169
- }
170
- }
171
- return a;
172
- }
173
- if (t) {
174
- const i = E(t);
175
- if (Object.hasOwnProperty.call(e, "required") || (e.required = !i), n.AST.isUnion(t)) {
176
- const s = L(t.types), u = s.find(
177
- (S) => S._tag !== "UndefinedKeyword" && S !== n.Null.ast
178
- );
179
- return "propertySignatures" in u ? l({
180
- propertySignatures: u.propertySignatures,
181
- parent: r,
182
- meta: e
183
- }) : s.every(n.AST.isLiteral) ? {
184
- ...e,
185
- type: "select",
186
- members: s.map((S) => S.literal)
187
- } : {
188
- ...e,
189
- ...l({
190
- parent: r,
191
- meta: e,
192
- property: u
193
- })
194
- };
195
- }
196
- if (n.AST.isTupleType(t))
61
+ }
62
+ return [...d, ...F];
63
+ });
197
64
  return {
198
- ...e,
199
- type: "multiple",
200
- members: t.elements,
201
- rest: t.rest
65
+ generalErrors: y,
66
+ errors: j
202
67
  };
203
- const o = n.AST.getAnnotation(
204
- t,
205
- n.AST.JSONSchemaAnnotationId
206
- ).pipe(M.getOrElse(() => ({})));
207
- return e = { ...e, ...o }, "from" in t ? l({
208
- parent: r,
209
- meta: e,
210
- property: t.from
211
- }) : (e.type = n.AST.getAnnotation(
212
- t,
213
- n.AST.TitleAnnotationId
214
- ).pipe(
215
- M.getOrElse(() => "unknown")
216
- ), e);
68
+ },
69
+ render({ errors: b, generalErrors: p }) {
70
+ return H(s, {
71
+ errors: b,
72
+ generalErrors: p,
73
+ ...this.$attrs
74
+ }, this.$slots);
75
+ }
76
+ };
77
+ }, be = (u, l, s) => {
78
+ if (!u) throw new Error("Schema is required");
79
+ const b = D.standardSchemaV1(u), p = D.decode(u), { meta: y } = C(u), f = O(() => {
80
+ if (s?.persistency?.id)
81
+ return s.persistency.id;
82
+ const e = window.location.pathname, r = Object.keys(y);
83
+ return `${e}-${r.join("-")}`;
84
+ }), M = () => {
85
+ const e = new URLSearchParams(window.location.search);
86
+ e.delete(f.value);
87
+ const r = new URL(window.location.href);
88
+ r.search = e.toString(), window.history.replaceState({}, "", r.toString());
89
+ };
90
+ function j(e, r) {
91
+ for (const t in r)
92
+ r[t] && T(r[t]) ? (e[t] || (e[t] = {}), j(e[t], r[t])) : e[t] = r[t];
93
+ return e;
217
94
  }
218
- return a;
219
- }, U = (e) => {
220
- const r = e.ast, t = {};
221
- if (r._tag === "Transformation" || r._tag === "Refinement")
222
- return U(n.make(r.from));
223
- if ("propertySignatures" in r) {
224
- const g = l({
225
- propertySignatures: r.propertySignatures
226
- });
227
- if (Object.values(g).every((i) => i && "type" in i))
228
- return g;
229
- const a = (i, o = "") => {
230
- for (const s in i) {
231
- const u = o ? `${o}.${s}` : s;
232
- i[s] && typeof i[s] == "object" && "type" in i[s] ? t[u] = i[s] : i[s] && typeof i[s] == "object" && a(i[s], u);
95
+ const d = O(() => {
96
+ if (l?.defaultValues && !s?.persistency?.overrideDefaultValues)
97
+ return l?.defaultValues;
98
+ let e;
99
+ const r = s?.persistency;
100
+ if (!r?.policies || r.policies.length === 0) return {};
101
+ if (r.policies.includes("querystring"))
102
+ try {
103
+ const o = new URLSearchParams(window.location.search).get(f.value);
104
+ M(), o && (e = JSON.parse(o));
105
+ } catch (t) {
106
+ console.error(t);
233
107
  }
234
- };
235
- a(g);
236
- }
237
- return t;
238
- }, P = (e) => n.extend(e, n.Struct({})), F = (e) => {
239
- const r = U(e);
240
- return { schema: e, meta: r };
241
- }, j = (e) => {
242
- const { trans: r } = _();
243
- let t;
244
- switch (e.type) {
245
- case "string":
246
- t = n.String.annotations({
247
- message: () => r("validation.empty")
248
- }), e.format === "email" && (t = n.compose(
249
- t,
250
- n.Email.annotations({
251
- message: () => r("validation.email.invalid")
252
- })
253
- )), e.required && t.annotations({
254
- message: () => r("validation.empty")
255
- }), e.maxLength && (t = t.pipe(n.maxLength(e.maxLength)).annotations({
256
- message: () => r("validation.string.maxLength", {
257
- maxLength: e.maxLength
258
- })
259
- })), e.minLength && (t = t.pipe(n.minLength(e.minLength)).annotations({
260
- message: () => r("validation.string.minLength", {
261
- minLength: e.minLength
262
- })
263
- }));
264
- break;
265
- case "number":
266
- t = n.Number.annotations({
267
- message: () => r("validation.empty")
268
- }), e.required && t.annotations({
269
- message: () => r("validation.empty")
270
- }), e.minimum && (t = t.pipe(n.greaterThanOrEqualTo(e.minimum)).annotations({
271
- message: () => r("validation.number.min", {
272
- minimum: e.minimum,
273
- isExclusive: !0
274
- })
275
- })), e.maximum && (t = t.pipe(n.lessThanOrEqualTo(e.maximum)).annotations({
276
- message: () => r("validation.number.max", {
277
- maximum: e.maximum,
278
- isExclusive: !0
279
- })
280
- })), e.exclusiveMinimum && (t = t.pipe(n.greaterThan(e.exclusiveMinimum)).annotations({
281
- message: () => r("validation.number.min", {
282
- minimum: e.exclusiveMinimum,
283
- isExclusive: !1
284
- })
285
- })), e.exclusiveMaximum && (t = t.pipe(n.lessThan(e.exclusiveMaximum)).annotations({
286
- message: () => r("validation.number.max", {
287
- maximum: e.exclusiveMaximum,
288
- isExclusive: !1
289
- })
290
- }));
291
- break;
292
- case "select":
293
- t = n.Literal(...e.members).annotations({
294
- message: () => ({
295
- message: r("validation.not_a_valid", {
296
- type: "select",
297
- message: e.members.join(", ")
298
- }),
299
- override: !0
300
- })
301
- });
302
- break;
303
- case "multiple":
304
- t = n.Array(n.String).annotations({
305
- message: () => r("validation.not_a_valid", {
306
- type: "multiple",
307
- message: e.members.join(", ")
308
- })
108
+ if (
109
+ // query string has higher priority than local/session storage
110
+ !e && (r.policies.includes("local") || r.policies.includes("session"))
111
+ ) {
112
+ const t = r.policies.includes("local") ? localStorage : sessionStorage;
113
+ if (t)
114
+ try {
115
+ const o = JSON.parse(
116
+ t.getItem(f.value) || "{}"
117
+ );
118
+ t.removeItem(f.value), e = o;
119
+ } catch (o) {
120
+ console.error(o);
121
+ }
122
+ }
123
+ if (e ??= {}, l?.defaultValues == null)
124
+ return e;
125
+ {
126
+ const t = l?.defaultValues;
127
+ return j(t, e);
128
+ }
129
+ }), F = (e, r) => e ? L.with(R.setSpan(L.active(), e), r) : r(), i = q({
130
+ ...l,
131
+ validators: {
132
+ onSubmit: b,
133
+ ...l?.validators || {}
134
+ },
135
+ onSubmit: l?.onSubmit ? ({ formApi: e, meta: r, value: t }) => F(r?.currentSpan, async () => {
136
+ const o = await c.runPromise(p(t)), n = l.onSubmit({
137
+ formApi: e,
138
+ meta: r,
139
+ value: o
309
140
  });
310
- break;
311
- case "boolean":
312
- t = n.Boolean;
313
- break;
314
- // todo: switch must be exhaustive or have default case, otherwise falls through with schema undefined.
315
- case "unknown":
316
- t = n.Unknown;
317
- break;
141
+ return x.isFiber(n) && x.isRuntimeFiber(n) ? await K(n) : c.isEffect(n) ? await c.runPromise(
142
+ n.pipe(
143
+ // meta?.currentSpan
144
+ // ? Effect.withParentSpan(meta.currentSpan)
145
+ // : (_) => _,
146
+ c.flatMap((m) => x.join(m))
147
+ )
148
+ ) : n;
149
+ }) : void 0,
150
+ defaultValues: d.value
151
+ }), v = () => {
152
+ Object.keys(y).forEach((e) => {
153
+ i.setFieldValue(e, void 0);
154
+ });
155
+ }, h = (e) => e.reduce((r, t) => {
156
+ const o = t.split(".");
157
+ return o.reduce((n, m, A) => (A === o.length - 1 ? n[m] = i.getFieldValue(t) : n[m] = n[m] ?? {}, n[m]), r), r;
158
+ }, {}), a = (e) => {
159
+ if (e) {
160
+ if (g.isArray(e.keys))
161
+ return h(e.keys);
162
+ if (g.isArray(e.banKeys)) {
163
+ const r = Object.keys(y).filter((t) => e.banKeys?.includes(t));
164
+ return h(r);
165
+ }
166
+ return i.store.state.values;
167
+ }
168
+ }, S = () => {
169
+ const e = s?.persistency;
170
+ if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
171
+ const r = e.policies.includes("local") ? localStorage : sessionStorage;
172
+ if (!r) return;
173
+ const t = a(e);
174
+ return r.setItem(f.value, JSON.stringify(t));
175
+ }
176
+ }, U = () => {
177
+ const e = s?.persistency;
178
+ if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
179
+ const r = a(e), t = new URLSearchParams(window.location.search);
180
+ t.set(f.value, JSON.stringify(r));
181
+ const o = new URL(window.location.href);
182
+ o.search = t.toString(), window.history.replaceState({}, "", o.toString());
183
+ }
184
+ }, _ = (e) => {
185
+ i.store.state.isDirty && e.preventDefault();
186
+ };
187
+ if (N(S), G(() => {
188
+ window.addEventListener("beforeunload", S), window.addEventListener("blur", U), s?.preventWindowExit && s.preventWindowExit !== "nope" && window.addEventListener("beforeunload", _);
189
+ }), z(() => {
190
+ window.removeEventListener("beforeunload", S), window.removeEventListener("blur", U), s?.preventWindowExit && s.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", _);
191
+ }), s?.preventWindowExit === "prevent-and-reset") {
192
+ const e = i.useStore((n) => n.isSubmitting), r = i.useStore((n) => n.submissionAttempts), t = i.useStore((n) => n.canSubmit), o = i.useStore((n) => n.values);
193
+ W([e, r], ([n, m], [A]) => {
194
+ A && !n && m > 0 && t.value && i.reset(o.value);
195
+ });
318
196
  }
319
- return e.required ? t.pipe(
320
- n.annotations({
321
- message: () => r("validation.empty")
322
- })
323
- ) : t = n.NullishOr(t), n.standardSchemaV1(t);
324
- }, R = (e, r) => n.NullOr(e).pipe(
325
- n.transform(n.typeSchema(e), {
326
- decode: (t) => t ?? r(),
327
- encode: (t) => t
328
- })
329
- ), k = [
330
- "button",
331
- "checkbox",
332
- "color",
333
- "date",
334
- "email",
335
- "number",
336
- "password",
337
- "radio",
338
- "range",
339
- "search",
340
- "submit",
341
- "tel",
342
- "text",
343
- "time",
344
- "url"
345
- ], J = (e) => k.includes(e) ? e : "text";
197
+ const I = (e) => c.currentSpan.pipe(
198
+ c.option,
199
+ c.flatMap(
200
+ (r) => c.promise(() => i.handleSubmit(P.isSome(r) ? { currentSpan: r.value, ...e } : e))
201
+ )
202
+ ), J = (e) => e?.checkErrors ? I(e?.meta).pipe(c.flatMap(c.fnUntraced(function* () {
203
+ const r = i.getAllErrors();
204
+ if (Object.keys(r.fields).length || r.form.errors.length)
205
+ return yield* new ne({ form: r.form, fields: r.fields });
206
+ }))) : I(e?.meta), k = i.handleSubmit, V = Q(/* @__PURE__ */ new Map()), w = Object.assign(i, {
207
+ i18nNamespace: s?.i18nNamespace,
208
+ ignorePreventCloseEvents: s?.ignorePreventCloseEvents,
209
+ meta: y,
210
+ clear: v,
211
+ handleSubmit: (e) => {
212
+ const r = R.getSpan(L.active());
213
+ return k({ currentSpan: r, ...e });
214
+ },
215
+ // /** @experimental */
216
+ handleSubmitEffect: J,
217
+ registerField: (e) => {
218
+ W(e, (r) => V.value.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), N(() => V.value.delete(e.value.name));
219
+ }
220
+ }), $ = { form: w, fieldMap: V };
221
+ return Object.assign(w, {
222
+ errorContext: $,
223
+ Form: E(w)(te),
224
+ Input: E(w)(s?.input ?? ee),
225
+ TaggedUnion: E(w)(re),
226
+ Field: i.Field,
227
+ Errors: se($)(Z),
228
+ Array: E(w)(X),
229
+ AutoGen: E(w)(Y)
230
+ });
231
+ };
346
232
  export {
347
- l as createMeta,
348
- P as duplicateSchema,
349
- j as generateInputStandardSchemaFromFieldMeta,
350
- F as generateMetaFromSchema,
351
- J as getInputType,
352
- R as nullableInput
233
+ ne as FormErrors,
234
+ be as useOmegaForm
353
235
  };
@@ -1,36 +1,32 @@
1
- import { h as o } from "vue";
2
- import l from "./vue-components.es6.js";
3
- import { useOmegaForm as O } from "./vue-components.es8.js";
4
- const g = (n) => (...m) => {
5
- const [p, s, a] = m;
6
- return O(
7
- p,
8
- s,
9
- {
10
- ...a,
11
- input: {
12
- name: "WrappedInput",
13
- inheritAttrs: !1,
14
- setup(c, { attrs: t }) {
15
- return () => o(l, {
16
- ...c,
17
- ...t
18
- }, {
19
- // Override the default slot that OmegaInternalInput provides
20
- default: ({ field: f, state: i, ...r }) => {
21
- const u = Object.fromEntries(
22
- Object.entries(t).filter(
23
- ([e]) => !Object.prototype.hasOwnProperty.call(r, e) && e !== "form"
24
- )
25
- );
26
- return o(n, { ...u, field: f, state: i, inputProps: r });
27
- }
28
- });
29
- }
30
- }
31
- }
32
- );
1
+ import l from "./vue-components.es28.js";
2
+ import { inject as c, provide as u } from "vue";
3
+ import { onMountedWithCleanup as f } from "./vue-components.es29.js";
4
+ const p = () => l(), i = Symbol("DialogBus"), r = () => c(i, null), g = () => {
5
+ const n = p();
6
+ return u(i, n), n;
7
+ }, d = (n) => {
8
+ const o = r();
9
+ if (!o)
10
+ return;
11
+ const s = n();
12
+ f(() => {
13
+ const e = (t) => {
14
+ s.value && (confirm("Es sind ungespeicherte Änderungen vorhanden. Wirklich schließen?") || (t.prevent = !0));
15
+ };
16
+ return o.on("dialog-closing", e), () => o.off("dialog-closing", e);
17
+ });
18
+ }, h = (n) => {
19
+ let o = r();
20
+ return o || (o = g()), () => {
21
+ const e = {};
22
+ o.emit("dialog-closing", e), e.prevent ? typeof e.prevent == "object" && "then" in e.prevent && e.prevent.then((t) => {
23
+ t !== !1 && n();
24
+ }) : n();
25
+ };
33
26
  };
34
27
  export {
35
- g as createUseFormWithCustomInput
28
+ r as injectBus,
29
+ g as provideBus,
30
+ h as useOnClose,
31
+ d as usePreventClose
36
32
  };