@effect-app/vue-components 4.0.0-beta.3 → 4.0.0-beta.30

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 (102) hide show
  1. package/README.md +24 -0
  2. package/dist/reset.css +51 -0
  3. package/dist/types/components/OmegaForm/OmegaAutoGen.vue.d.ts +1 -1
  4. package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +14 -12
  5. package/dist/types/components/OmegaForm/useOmegaForm.d.ts +2 -4
  6. package/dist/types/utils/index.d.ts +3 -4
  7. package/dist/vue-components.es10.js +131 -129
  8. package/dist/vue-components.es11.js +2 -2
  9. package/dist/vue-components.es12.js +407 -343
  10. package/dist/vue-components.es16.js +4 -723
  11. package/dist/vue-components.es17.js +10 -140
  12. package/dist/vue-components.es18.js +55 -4
  13. package/dist/vue-components.es19.js +54 -11
  14. package/dist/vue-components.es20.js +6 -3
  15. package/dist/vue-components.es21.js +6 -24
  16. package/dist/vue-components.es22.js +3 -4
  17. package/dist/vue-components.es23.js +3 -8
  18. package/dist/vue-components.es24.js +2 -55
  19. package/dist/vue-components.es25.js +2 -69
  20. package/dist/vue-components.es26.js +2 -6
  21. package/dist/vue-components.es27.js +2 -6
  22. package/dist/vue-components.es28.js +17 -3
  23. package/dist/vue-components.es29.js +11 -3
  24. package/dist/vue-components.es3.js +11 -10
  25. package/dist/vue-components.es30.js +192 -2
  26. package/dist/vue-components.es32.js +29 -2
  27. package/dist/vue-components.es33.js +4 -2
  28. package/dist/vue-components.es34.js +2 -17
  29. package/dist/vue-components.es35.js +2 -11
  30. package/dist/vue-components.es36.js +109 -36
  31. package/dist/vue-components.es38.js +7 -83
  32. package/dist/vue-components.es39.js +31 -51
  33. package/dist/vue-components.es41.js +4 -41
  34. package/dist/vue-components.es42.js +22 -26
  35. package/dist/vue-components.es43.js +5 -5
  36. package/dist/vue-components.es44.js +21 -40
  37. package/dist/vue-components.es45.js +27 -311
  38. package/dist/vue-components.es46.js +22 -31
  39. package/dist/vue-components.es47.js +12 -4
  40. package/dist/vue-components.es48.js +5 -24
  41. package/dist/vue-components.es49.js +17 -73
  42. package/dist/vue-components.es5.js +1 -1
  43. package/dist/vue-components.es50.js +9 -99
  44. package/dist/vue-components.es51.js +31 -2
  45. package/dist/vue-components.es52.js +45 -315
  46. package/dist/vue-components.es53.js +26 -64
  47. package/dist/vue-components.es54.js +11 -2
  48. package/dist/vue-components.es55.js +65 -2
  49. package/dist/vue-components.es56.js +55 -110
  50. package/dist/{vue-components.es94.js → vue-components.es57.js} +1 -1
  51. package/dist/vue-components.es58.js +33 -7
  52. package/dist/vue-components.es59.js +29 -32
  53. package/dist/{vue-components.es97.js → vue-components.es60.js} +1 -1
  54. package/dist/vue-components.es61.js +2 -192
  55. package/dist/{vue-components.es99.js → vue-components.es62.js} +1 -1
  56. package/dist/vue-components.es63.js +2 -4
  57. package/dist/vue-components.es7.js +37 -37
  58. package/package.json +16 -12
  59. package/src/components/OmegaForm/OmegaAutoGen.vue +25 -30
  60. package/src/components/OmegaForm/OmegaErrorsInternal.vue +2 -3
  61. package/src/components/OmegaForm/OmegaFormStuff.ts +425 -323
  62. package/src/components/OmegaForm/OmegaInternalInput.vue +9 -5
  63. package/src/components/OmegaForm/useOmegaForm.ts +30 -32
  64. package/src/reset.css +51 -0
  65. package/src/utils/index.ts +4 -8
  66. package/dist/vue-components.es100.js +0 -4
  67. package/dist/vue-components.es31.js +0 -4
  68. package/dist/vue-components.es37.js +0 -6
  69. package/dist/vue-components.es40.js +0 -563
  70. package/dist/vue-components.es64.js +0 -103
  71. package/dist/vue-components.es65.js +0 -84
  72. package/dist/vue-components.es66.js +0 -17
  73. package/dist/vue-components.es67.js +0 -34
  74. package/dist/vue-components.es68.js +0 -4
  75. package/dist/vue-components.es69.js +0 -23
  76. package/dist/vue-components.es70.js +0 -14
  77. package/dist/vue-components.es71.js +0 -115
  78. package/dist/vue-components.es72.js +0 -5
  79. package/dist/vue-components.es73.js +0 -4
  80. package/dist/vue-components.es74.js +0 -4
  81. package/dist/vue-components.es75.js +0 -17
  82. package/dist/vue-components.es76.js +0 -72
  83. package/dist/vue-components.es77.js +0 -25
  84. package/dist/vue-components.es78.js +0 -7
  85. package/dist/vue-components.es79.js +0 -23
  86. package/dist/vue-components.es80.js +0 -32
  87. package/dist/vue-components.es81.js +0 -24
  88. package/dist/vue-components.es82.js +0 -14
  89. package/dist/vue-components.es83.js +0 -7
  90. package/dist/vue-components.es84.js +0 -21
  91. package/dist/vue-components.es85.js +0 -11
  92. package/dist/vue-components.es86.js +0 -33
  93. package/dist/vue-components.es87.js +0 -50
  94. package/dist/vue-components.es88.js +0 -28
  95. package/dist/vue-components.es89.js +0 -18
  96. package/dist/vue-components.es90.js +0 -10
  97. package/dist/vue-components.es91.js +0 -13
  98. package/dist/vue-components.es92.js +0 -67
  99. package/dist/vue-components.es93.js +0 -58
  100. package/dist/vue-components.es95.js +0 -35
  101. package/dist/vue-components.es96.js +0 -31
  102. package/dist/vue-components.es98.js +0 -4
@@ -1,358 +1,418 @@
1
- import { isUnion as k, isUndefined as q, isDeclaration as C, isObjects as c, isNull as V, isArrays as $, isLiteral as B, isString as J, isNumber as G, isBoolean as R } from "./vue-components.es16.js";
2
- import { Array as H, String as N, Literal as K, Union as _, makeFilter as x, toStandardSchemaV1 as Q, Null as I, make as W, Unknown as j, Boolean as X, Int as Y, Number as Z, Undefined as ee } from "./vue-components.es17.js";
3
- import { useIntl as te, getTransformationFrom as E } from "./vue-components.es3.js";
4
- import { isObject as ne } from "./vue-components.es18.js";
5
- const ie = (e) => k(e) ? e.types.find((n) => q(n) || n === I.ast) : !1, g = (e) => !e || !k(e) ? !1 : e.types.find((n) => q(n)) ? "undefined" : e.types.find((n) => n === I.ast) ? "null" : !1, F = (e) => {
6
- const n = [];
7
- for (const t of e)
8
- if (k(t)) {
9
- const i = F(t.types);
10
- n.push(...i);
1
+ import { S as i, Effect as P, Option as w } from "effect-app";
2
+ import { useIntl as I, getTransformationFrom as q } from "./vue-components.es3.js";
3
+ import { isObject as G } from "./vue-components.es16.js";
4
+ const E = /* @__PURE__ */ new Set(), K = () => globalThis.process?.env?.NODE_ENV !== "production", S = (e) => {
5
+ let t = q(e);
6
+ for (; i.AST.isDeclaration(t) && t.typeParameters.length > 0; )
7
+ t = q(t.typeParameters[0]);
8
+ return t;
9
+ }, j = (e) => i.AST.isUndefined(e) || i.AST.isNull(e), _ = (e) => i.AST.isUnion(e) && e.types.length === 1 && i.AST.isLiteral(e.types[0]) ? e.types[0] : e, B = (e) => i.AST.isUnion(e) ? e.types.find((t) => j(t)) : !1, g = (e) => !e || !i.AST.isUnion(e) ? !1 : e.types.find((t) => i.AST.isUndefined(t)) ? "undefined" : e.types.find((t) => i.AST.isNull(t)) ? "null" : !1, U = (e) => {
10
+ const t = [];
11
+ for (const n of e)
12
+ if (i.AST.isUnion(n)) {
13
+ const r = U(n.types);
14
+ t.push(...r);
11
15
  } else
12
- n.push(t);
13
- return n;
14
- }, m = ({ meta: e = {}, parent: n = "", property: t, propertySignatures: i }, r = {}) => {
15
- if (t && C(t)) {
16
- const s = t.annotations?.title ?? "";
17
- if (s !== "Int" && s !== "int")
18
- return m({
19
- parent: n,
20
- meta: e,
21
- property: t
22
- });
23
- }
24
- if (t && c(t))
25
- return m({
16
+ t.push(n);
17
+ return t;
18
+ }, F = (e) => U(e).map(S).filter((t) => !j(t)), C = (e) => {
19
+ const t = i.AST.resolve(e)?.jsonSchema;
20
+ return t && typeof t == "object" ? t : {};
21
+ }, D = (e) => {
22
+ if (e?.transformation?.decode?.run)
23
+ try {
24
+ const t = P.runSync(e.transformation.decode.run(w.none()));
25
+ return w.isSome(t) ? t.value : void 0;
26
+ } catch {
27
+ return;
28
+ }
29
+ }, A = (e) => {
30
+ const t = e.context?.defaultValue?.[0], n = D(t);
31
+ if (n !== void 0) return n;
32
+ const r = e.encoding?.[0];
33
+ if (r && e.context?.isOptional)
34
+ return D(r);
35
+ }, R = (e) => (e.checks ?? []).flatMap((n) => {
36
+ if (n._tag === "FilterGroup")
37
+ return n.checks.flatMap((a) => {
38
+ const s = a.annotations?.meta;
39
+ return s && typeof s == "object" ? [s] : [];
40
+ });
41
+ const r = n.annotations?.meta;
42
+ return r && typeof r == "object" ? [r] : [];
43
+ }), $ = (e) => {
44
+ const t = {
45
+ description: i.AST.resolveDescription(e)
46
+ }, n = R(e);
47
+ if (i.AST.isString(e)) {
48
+ t.type = "string";
49
+ for (const r of n)
50
+ switch (r._tag) {
51
+ case "isMinLength":
52
+ t.minLength = r.minLength;
53
+ break;
54
+ case "isMaxLength":
55
+ t.maxLength = r.maxLength;
56
+ break;
57
+ }
58
+ i.AST.resolveTitle(e) === "Email" && (t.format = "email");
59
+ } else if (i.AST.isNumber(e)) {
60
+ t.type = "number";
61
+ for (const r of n)
62
+ switch (r._tag) {
63
+ case "isInt":
64
+ t.refinement = "int";
65
+ break;
66
+ case "isGreaterThanOrEqualTo":
67
+ t.minimum = r.minimum;
68
+ break;
69
+ case "isLessThanOrEqualTo":
70
+ t.maximum = r.maximum;
71
+ break;
72
+ case "isBetween":
73
+ t.minimum = r.minimum, t.maximum = r.maximum;
74
+ break;
75
+ case "isGreaterThan":
76
+ t.exclusiveMinimum = r.exclusiveMinimum;
77
+ break;
78
+ case "isLessThan":
79
+ t.exclusiveMaximum = r.exclusiveMaximum;
80
+ break;
81
+ }
82
+ } else i.AST.isBoolean(e) ? t.type = "boolean" : i.AST.isDeclaration(e) && e.annotations?.typeConstructor?._tag === "Date" ? t.type = "date" : t.type = "unknown";
83
+ return t;
84
+ }, y = ({ meta: e = {}, parent: t = "", property: n, propertySignatures: r }, a = {}) => {
85
+ if (n && (n = S(n)), n && i.AST.isObjects(n))
86
+ return y({
26
87
  meta: e,
27
- propertySignatures: t.propertySignatures
88
+ propertySignatures: n.propertySignatures
28
89
  });
29
- if (i) {
30
- for (const s of i) {
31
- const o = n ? `${n}.${s.name.toString()}` : s.name.toString(), l = g(s.type), f = s.type.annotations?.title ?? "", a = f === "Int" || f === "int";
32
- let p;
33
- e._isNullableDiscriminatedUnion && s.name.toString() === "_tag" || e.required === !1 ? p = !1 : p = !l;
34
- const v = s.type;
35
- if (k(s.type)) {
36
- const b = F(s.type.types).filter(
37
- (u) => !q(u) && !V(u)
38
- ).map(E);
39
- if (b.some(
40
- (u) => c(u)
41
- )) {
42
- if (!l) {
43
- const u = m({
44
- parent: o,
90
+ if (r) {
91
+ for (const s of r) {
92
+ const l = t ? `${t}.${s.name.toString()}` : s.name.toString(), o = g(s.type);
93
+ let m;
94
+ e._isNullableDiscriminatedUnion && s.name.toString() === "_tag" || e.required === !1 ? m = !1 : m = !o;
95
+ const c = S(s.type);
96
+ if (i.AST.isUnion(s.type)) {
97
+ const u = F(s.type.types);
98
+ if (u.some(i.AST.isObjects)) {
99
+ if (!o) {
100
+ const f = y({
101
+ parent: l,
45
102
  property: s.type,
46
- meta: { required: p, nullableOrUndefined: l }
103
+ meta: { required: m, nullableOrUndefined: o }
47
104
  });
48
- r[o] = u;
105
+ a[l] = f;
49
106
  }
50
- for (const u of b)
51
- if (c(u)) {
52
- const y = l && b.length > 1;
53
- Object.assign(
54
- r,
55
- m({
56
- parent: o,
57
- propertySignatures: u.propertySignatures,
58
- meta: y ? { _isNullableDiscriminatedUnion: !0 } : {}
59
- })
60
- );
107
+ for (const f of u)
108
+ if (i.AST.isObjects(f)) {
109
+ const p = o && u.length > 1, h = y({
110
+ parent: l,
111
+ propertySignatures: f.propertySignatures,
112
+ meta: p ? { _isNullableDiscriminatedUnion: !0 } : {}
113
+ });
114
+ for (const [d, T] of Object.entries(h)) {
115
+ const b = a[d];
116
+ b && b.type === "select" && T?.type === "select" ? b.members = [
117
+ ...b.members,
118
+ ...T.members.filter(
119
+ (x) => !b.members.includes(x)
120
+ )
121
+ ] : a[d] = T;
122
+ }
61
123
  }
62
124
  } else {
63
- const u = b.filter($);
64
- if (u.length > 0) {
65
- const y = u[0];
66
- if (r[o] = {
125
+ const f = u.filter(i.AST.isArrays);
126
+ if (f.length > 0) {
127
+ const p = f[0];
128
+ if (a[l] = {
67
129
  type: "multiple",
68
- members: y.elements,
69
- rest: y.rest,
70
- required: p,
71
- nullableOrUndefined: l
72
- }, y.rest && y.rest.length > 0) {
73
- const S = y.rest[0];
74
- if (c(S))
75
- for (const d of S.propertySignatures) {
76
- const O = `${o}.${d.name.toString()}`, h = m({
77
- parent: O,
130
+ members: p.elements,
131
+ rest: p.rest,
132
+ required: m,
133
+ nullableOrUndefined: o
134
+ }, p.rest && p.rest.length > 0) {
135
+ const h = S(p.rest[0]);
136
+ if (i.AST.isObjects(h))
137
+ for (const d of h.propertySignatures) {
138
+ const T = `${l}.${d.name.toString()}`, b = y({
139
+ parent: T,
78
140
  property: d.type,
79
141
  meta: {
80
142
  required: !g(d.type),
81
143
  nullableOrUndefined: g(d.type)
82
144
  }
83
145
  });
84
- if (h && typeof h == "object" && "type" in h && (r[O] = h, h.type === "multiple" && $(d.type) && d.type.rest && d.type.rest.length > 0)) {
85
- const P = d.type.rest[0];
86
- if (c(P))
87
- for (const T of P.propertySignatures) {
88
- const D = `${O}.${T.name.toString()}`, w = m({
89
- parent: D,
90
- property: T.type,
146
+ if (b && typeof b == "object" && "type" in b && (a[T] = b, b.type === "multiple" && i.AST.isArrays(d.type) && d.type.rest && d.type.rest.length > 0)) {
147
+ const x = S(d.type.rest[0]);
148
+ if (i.AST.isObjects(x))
149
+ for (const O of x.propertySignatures) {
150
+ const N = `${T}.${O.name.toString()}`, k = y({
151
+ parent: N,
152
+ property: O.type,
91
153
  meta: {
92
- required: !g(T.type),
93
- nullableOrUndefined: g(T.type)
154
+ required: !g(O.type),
155
+ nullableOrUndefined: g(O.type)
94
156
  }
95
157
  });
96
- w && typeof w == "object" && "type" in w && (r[D] = w);
158
+ k && typeof k == "object" && "type" in k && (a[N] = k);
97
159
  }
98
160
  }
99
161
  }
100
162
  }
101
163
  } else {
102
- const y = m({
103
- parent: o,
164
+ const p = y({
165
+ parent: l,
104
166
  property: s.type,
105
- meta: { required: p, nullableOrUndefined: l }
167
+ meta: { required: m, nullableOrUndefined: o }
106
168
  });
107
- r[o] = y;
169
+ a[l] = p;
108
170
  }
109
171
  }
110
- } else {
111
- const M = E(v);
112
- if (c(M))
113
- Object.assign(
114
- r,
115
- m({
116
- parent: o,
117
- propertySignatures: M.propertySignatures,
118
- meta: { required: p, nullableOrUndefined: l }
119
- })
120
- );
121
- else if ($(s.type))
122
- if (s.type.rest.length > 0 && c(s.type.rest[0])) {
123
- const L = s.type.rest[0];
124
- if (c(L))
125
- for (const u of L.propertySignatures) {
126
- const y = `${o}.${u.name.toString()}`;
127
- if ($(u.type) && u.type.rest.length > 0) {
128
- const S = u.type.rest[0];
129
- if (c(S))
130
- for (const d of S.propertySignatures) {
131
- const O = `${y}.${d.name.toString()}`, h = m({
132
- parent: O,
133
- property: d.type,
134
- meta: {
135
- required: !g(d.type),
136
- nullableOrUndefined: g(d.type)
137
- }
138
- });
139
- r[O] = h;
140
- }
141
- else
142
- r[y] = {
143
- type: "multiple",
144
- members: u.type.elements,
145
- rest: u.type.rest,
146
- required: !g(u.type),
147
- nullableOrUndefined: g(u.type)
148
- };
149
- } else {
150
- const S = m({
151
- parent: y,
152
- property: u.type,
153
- meta: {
154
- required: !g(u.type),
155
- nullableOrUndefined: g(u.type)
156
- }
157
- });
158
- r[y] = S;
159
- }
172
+ } else if (i.AST.isObjects(c))
173
+ Object.assign(
174
+ a,
175
+ y({
176
+ parent: l,
177
+ propertySignatures: c.propertySignatures,
178
+ meta: { required: m, nullableOrUndefined: o }
179
+ })
180
+ );
181
+ else if (i.AST.isArrays(s.type))
182
+ if (s.type.rest.length > 0 && i.AST.isObjects(S(s.type.rest[0]))) {
183
+ const v = S(s.type.rest[0]);
184
+ if (i.AST.isObjects(v))
185
+ for (const f of v.propertySignatures) {
186
+ const p = `${l}.${f.name.toString()}`;
187
+ if (i.AST.isArrays(f.type) && f.type.rest.length > 0) {
188
+ const h = S(f.type.rest[0]);
189
+ if (i.AST.isObjects(h))
190
+ for (const d of h.propertySignatures) {
191
+ const T = `${p}.${d.name.toString()}`, b = y({
192
+ parent: T,
193
+ property: d.type,
194
+ meta: {
195
+ required: !g(d.type),
196
+ nullableOrUndefined: g(d.type)
197
+ }
198
+ });
199
+ a[T] = b;
200
+ }
201
+ else
202
+ a[p] = {
203
+ type: "multiple",
204
+ members: f.type.elements,
205
+ rest: f.type.rest,
206
+ required: !g(f.type),
207
+ nullableOrUndefined: g(f.type)
208
+ };
209
+ } else {
210
+ const h = y({
211
+ parent: p,
212
+ property: f.type,
213
+ meta: {
214
+ required: !g(f.type),
215
+ nullableOrUndefined: g(f.type)
216
+ }
217
+ });
218
+ a[p] = h;
160
219
  }
161
- } else
162
- r[o] = {
163
- type: "multiple",
164
- members: s.type.elements,
165
- rest: s.type.rest,
166
- required: p,
167
- nullableOrUndefined: l
168
- };
169
- else {
170
- const b = m({
171
- parent: o,
172
- property: s.type,
173
- meta: {
174
- required: p,
175
- nullableOrUndefined: l,
176
- ...a && { refinement: "int" }
177
220
  }
178
- });
179
- r[o] = b;
180
- }
221
+ } else
222
+ a[l] = {
223
+ type: "multiple",
224
+ members: s.type.elements,
225
+ rest: s.type.rest,
226
+ required: m,
227
+ nullableOrUndefined: o
228
+ };
229
+ else {
230
+ const u = y({
231
+ parent: l,
232
+ property: s.type,
233
+ meta: {
234
+ // an empty string is valid for a S.String field, so we should not mark it as required
235
+ // TODO: handle this better via the createMeta minLength parsing
236
+ required: m && (!i.AST.isString(c) || !!$(s.type).minLength),
237
+ nullableOrUndefined: o
238
+ }
239
+ });
240
+ a[l] = u;
181
241
  }
182
242
  }
183
- return r;
243
+ return a;
184
244
  }
185
- if (t) {
186
- const s = ie(t);
187
- if (Object.hasOwnProperty.call(e, "required") || (e.required = !s), k(t)) {
188
- const f = F(t.types), a = f.find(
189
- (p) => !q(p) && !V(p)
190
- );
191
- return c(a) ? m({
192
- propertySignatures: a.propertySignatures,
193
- parent: n,
194
- meta: e
195
- }) : f.every(B) ? {
245
+ if (n) {
246
+ const s = B(n);
247
+ if (n = S(n), Object.hasOwnProperty.call(e, "required") || (e.required = !s), i.AST.isUnion(n)) {
248
+ const l = U(n.types).map(S), o = l.filter((u) => !j(u));
249
+ if (o.length === 1 && i.AST.isLiteral(o[0]) && typeof o[0].literal == "boolean")
250
+ return y({ parent: t, meta: e, property: o[0] });
251
+ const m = o[0];
252
+ if (i.AST.isObjects(m))
253
+ return y({
254
+ propertySignatures: m.propertySignatures,
255
+ parent: t,
256
+ meta: e
257
+ });
258
+ const c = l.map(_);
259
+ return c.every((u) => j(u) || i.AST.isLiteral(u)) ? {
196
260
  ...e,
197
261
  type: "select",
198
- members: f.map((p) => p.literal)
262
+ members: c.filter(i.AST.isLiteral).map((u) => u.literal)
199
263
  } : {
200
264
  ...e,
201
- ...m({
202
- parent: n,
265
+ ...y({
266
+ parent: t,
203
267
  meta: e,
204
- property: a
268
+ property: m
205
269
  })
206
270
  };
207
271
  }
208
- if ($(t))
209
- return {
210
- ...e,
211
- type: "multiple",
212
- members: t.elements,
213
- rest: t.rest
214
- };
215
- e = { ...t.annotations?.jsonSchema ?? {}, ...e };
216
- let l = t.annotations?.title ?? "unknown";
217
- return l === "unknown" && (J(t) ? l = "string" : G(t) ? l = "number" : R(t) && (l = "boolean")), l === "Int" || l === "int" ? (e.type = "number", e.refinement = "int") : e.type = l, Object.hasOwnProperty.call(e, "required") || (e.required = !s), e;
272
+ return i.AST.isArrays(n) ? {
273
+ ...e,
274
+ type: "multiple",
275
+ members: n.elements,
276
+ rest: n.rest
277
+ } : (e = { ...C(n), ...$(n), ...e }, e);
218
278
  }
219
- return r;
220
- }, z = (e, n = "") => {
221
- const t = {};
222
- for (const i in e) {
223
- const r = e[i], s = n ? `${n}.${i}` : i;
224
- r && typeof r == "object" && "type" in r ? t[s] = r : r && typeof r == "object" && Object.assign(t, z(r, s));
279
+ return a;
280
+ }, V = (e, t = "") => {
281
+ const n = {};
282
+ for (const r in e) {
283
+ const a = e[r], s = t ? `${t}.${r}` : r;
284
+ a && typeof a == "object" && "type" in a ? n[s] = a : a && typeof a == "object" && Object.assign(n, V(a, s));
225
285
  }
226
- return t;
227
- }, re = (e) => {
228
- const n = e.ast, t = {}, i = {}, r = {};
229
- if (k(n)) {
230
- const o = n.types.filter((f) => !q(f) && !V(f)).map(E);
231
- if (o.every((f) => c(f)) && o.length > 0) {
232
- const f = [];
233
- for (const a of o)
234
- if (c(a)) {
235
- const p = a.propertySignatures.find(
236
- (b) => b.name.toString() === "_tag"
286
+ return n;
287
+ }, J = (e) => {
288
+ const t = S(e.ast), n = {}, r = {}, a = {};
289
+ if (i.AST.isUnion(t)) {
290
+ const s = F(t.types);
291
+ if (s.every(i.AST.isObjects) && s.length > 0) {
292
+ const o = [];
293
+ for (const m of s)
294
+ if (i.AST.isObjects(m)) {
295
+ const c = m.propertySignatures.find(
296
+ (p) => p.name.toString() === "_tag"
237
297
  );
238
- let v = null;
239
- p && B(p.type) && (v = p.type.literal, f.push(v));
240
- const M = m({
241
- propertySignatures: a.propertySignatures
298
+ let u = null;
299
+ const v = c ? _(c.type) : null;
300
+ v && i.AST.isLiteral(v) && (u = v.literal, o.push(u), c && i.AST.isUnion(c.type) && K() && u != null && !E.has(u) && (E.add(u), console.warn(
301
+ `[OmegaForm] Union member with _tag "${u}" uses S.Struct({ _tag: S.Literal("${u}"), ... }). Please migrate to S.TaggedStruct("${u}", { ... }) for cleaner AST handling.`
302
+ )));
303
+ const f = y({
304
+ propertySignatures: m.propertySignatures
242
305
  });
243
- v && (r[v] = z(M)), Object.assign(t, M);
306
+ u && (a[u] = V(f)), Object.assign(n, f);
244
307
  }
245
- return f.length > 0 && (t._tag = {
308
+ return o.length > 0 && (n._tag = {
246
309
  type: "select",
247
- members: f,
310
+ members: o,
248
311
  required: !0
249
- }), { meta: t, defaultValues: i, unionMeta: r };
312
+ }), { meta: n, defaultValues: r, unionMeta: a };
250
313
  }
251
314
  }
252
- if (c(n)) {
253
- const s = m({
254
- propertySignatures: n.propertySignatures
315
+ if (i.AST.isObjects(t)) {
316
+ const s = y({
317
+ propertySignatures: t.propertySignatures
255
318
  });
256
- if (Object.values(s).every((l) => l && "type" in l))
257
- return { meta: s, defaultValues: i, unionMeta: r };
258
- const o = (l, f = "") => {
259
- for (const a in l) {
260
- const p = f ? `${f}.${a}` : a;
261
- l[a] && typeof l[a] == "object" && "type" in l[a] ? t[p] = l[a] : l[a] && typeof l[a] == "object" && o(l[a], p);
319
+ if (Object.values(s).every((o) => o && "type" in o))
320
+ return { meta: s, defaultValues: r, unionMeta: a };
321
+ const l = (o, m = "") => {
322
+ for (const c in o) {
323
+ const u = m ? `${m}.${c}` : c;
324
+ o[c] && typeof o[c] == "object" && "type" in o[c] ? n[u] = o[c] : o[c] && typeof o[c] == "object" && l(o[c], u);
262
325
  }
263
326
  };
264
- o(s);
327
+ l(s);
265
328
  }
266
- return { meta: t, defaultValues: i, unionMeta: r };
267
- }, me = (e) => e, ye = (e) => {
268
- const { meta: n, unionMeta: t } = re(e);
269
- return { schema: e, meta: n, unionMeta: t };
270
- }, ce = (e, n) => {
271
- n || (n = te().trans);
272
- let t;
329
+ return { meta: n, defaultValues: r, unionMeta: a };
330
+ }, Z = (e) => e, ee = (e) => {
331
+ const { meta: t, unionMeta: n } = J(e);
332
+ return { schema: e, meta: t, unionMeta: n };
333
+ }, te = (e, t) => {
334
+ t || (t = I().trans);
335
+ let n;
273
336
  switch (e.type) {
274
- case "string": {
275
- if (t = N, e.format === "email" && (t = N.check(
276
- x(
277
- (i) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i) || n("validation.email.invalid"),
278
- { title: "email format" }
279
- )
280
- )), e.required || typeof e.minLength == "number") {
281
- const i = e.required ? Math.max(1, e.minLength || 0) : e.minLength || 0;
282
- i > 0 && (t = t.check(
283
- x(
284
- (r) => r.length >= i || n("validation.string.minLength", { minLength: i }),
285
- { title: `minLength(${i})` }
286
- )
287
- ));
288
- }
289
- typeof e.maxLength == "number" && (t = t.check(
290
- x(
291
- (i) => i.length <= e.maxLength || n("validation.string.maxLength", { maxLength: e.maxLength }),
292
- { title: `maxLength(${e.maxLength})` }
293
- )
294
- ));
337
+ case "string":
338
+ n = e.format === "email" ? i.Email.annotate({
339
+ message: t("validation.email.invalid")
340
+ }) : i.String.annotate({
341
+ message: t("validation.empty")
342
+ }), e.required && (n = n.check(i.isMinLength(1, {
343
+ message: t("validation.empty")
344
+ }))), typeof e.maxLength == "number" && (n = n.check(i.isMaxLength(e.maxLength, {
345
+ message: t("validation.string.maxLength", {
346
+ maxLength: e.maxLength
347
+ })
348
+ }))), typeof e.minLength == "number" && (n = n.check(i.isMinLength(e.minLength, {
349
+ message: t("validation.string.minLength", {
350
+ minLength: e.minLength
351
+ })
352
+ })));
295
353
  break;
296
- }
297
- case "number": {
298
- e.refinement === "int" ? t = Y : t = Z, typeof e.minimum == "number" && (t = t.check(
299
- x(
300
- (i) => i >= e.minimum || n(
301
- e.minimum === 0 ? "validation.number.positive" : "validation.number.min",
302
- { minimum: e.minimum, isExclusive: !1 }
303
- ),
304
- { title: `>=${e.minimum}` }
305
- )
306
- )), typeof e.maximum == "number" && (t = t.check(
307
- x(
308
- (i) => i <= e.maximum || n("validation.number.max", {
309
- maximum: e.maximum,
310
- isExclusive: !1
311
- }),
312
- { title: `<=${e.maximum}` }
313
- )
314
- )), typeof e.exclusiveMinimum == "number" && (t = t.check(
315
- x(
316
- (i) => i > e.exclusiveMinimum || n(
317
- e.exclusiveMinimum === 0 ? "validation.number.positive" : "validation.number.min",
318
- { minimum: e.exclusiveMinimum, isExclusive: !0 }
319
- ),
320
- { title: `>${e.exclusiveMinimum}` }
321
- )
322
- )), typeof e.exclusiveMaximum == "number" && (t = t.check(
323
- x(
324
- (i) => i < e.exclusiveMaximum || n("validation.number.max", {
325
- maximum: e.exclusiveMaximum,
326
- isExclusive: !0
327
- }),
328
- { title: `<${e.exclusiveMaximum}` }
329
- )
330
- ));
354
+ case "number":
355
+ e.refinement === "int" ? n = i.Number.annotate({
356
+ message: t("validation.empty")
357
+ }).check(i.isInt({
358
+ message: t("validation.integer.expected", { actualValue: "NaN" })
359
+ })) : (n = i.Number.annotate({
360
+ message: t("validation.number.expected", { actualValue: "NaN" })
361
+ }), e.required && (n = n.annotate({
362
+ message: t("validation.empty")
363
+ }))), typeof e.minimum == "number" && (n = n.check(i.isGreaterThanOrEqualTo(e.minimum, {
364
+ message: t(e.minimum === 0 ? "validation.number.positive" : "validation.number.min", {
365
+ minimum: e.minimum,
366
+ isExclusive: !0
367
+ })
368
+ }))), typeof e.maximum == "number" && (n = n.check(i.isLessThanOrEqualTo(e.maximum, {
369
+ message: t("validation.number.max", {
370
+ maximum: e.maximum,
371
+ isExclusive: !0
372
+ })
373
+ }))), typeof e.exclusiveMinimum == "number" && (n = n.check(i.isGreaterThan(e.exclusiveMinimum, {
374
+ message: t(e.exclusiveMinimum === 0 ? "validation.number.positive" : "validation.number.min", {
375
+ minimum: e.exclusiveMinimum,
376
+ isExclusive: !1
377
+ })
378
+ }))), typeof e.exclusiveMaximum == "number" && (n = n.check(i.isLessThan(e.exclusiveMaximum, {
379
+ message: t("validation.number.max", {
380
+ maximum: e.exclusiveMaximum,
381
+ isExclusive: !1
382
+ })
383
+ })));
331
384
  break;
332
- }
333
- case "select": {
334
- e.members.length === 0 ? t = j : e.members.length === 1 ? t = K(e.members[0]) : t = _(e.members.map((i) => K(i)));
385
+ case "select":
386
+ n = i.Literals(e.members).annotate({
387
+ message: t("validation.not_a_valid", {
388
+ type: "select",
389
+ message: e.members.join(", ")
390
+ })
391
+ });
335
392
  break;
336
- }
337
- case "multiple": {
338
- t = H(N);
393
+ case "multiple":
394
+ n = i.Array(i.String).annotate({
395
+ message: t("validation.not_a_valid", {
396
+ type: "multiple",
397
+ message: e.members.join(", ")
398
+ })
399
+ });
339
400
  break;
340
- }
341
- case "boolean": {
342
- t = X;
401
+ case "boolean":
402
+ n = i.Boolean;
343
403
  break;
344
- }
345
- case "unknown": {
346
- t = j;
404
+ case "date":
405
+ n = i.Date;
347
406
  break;
348
- }
349
- default: {
350
- console.warn(`Unhandled field type: ${e.type}`), t = j;
407
+ case "unknown":
408
+ n = i.Unknown;
409
+ break;
410
+ default:
411
+ console.warn(`Unhandled field type: ${e}`), n = i.Unknown;
351
412
  break;
352
- }
353
413
  }
354
- return e.required || (t = _([t, I, ee])), Q(t);
355
- }, se = [
414
+ return e.required || (n = i.NullishOr(n)), i.toStandardSchemaV1(n);
415
+ }, W = [
356
416
  "button",
357
417
  "checkbox",
358
418
  "color",
@@ -368,72 +428,76 @@ const ie = (e) => k(e) ? e.types.find((n) => q(n) || n === I.ast) : !1, g = (e)
368
428
  "text",
369
429
  "time",
370
430
  "url"
371
- ], de = (e) => se.includes(e) ? e : "text";
372
- function le(e, n) {
373
- const t = { ...e };
374
- for (const i in n)
375
- Array.isArray(n[i]) ? t[i] = n[i] : n[i] && ne(n[i]) ? t[i] = le(t[i], n[i]) : t[i] = n[i];
376
- return t;
431
+ ], ne = (e) => W.includes(e) ? e : "text";
432
+ function z(e, t) {
433
+ const n = { ...e };
434
+ for (const r in t)
435
+ Array.isArray(t[r]) ? n[r] = t[r] : t[r] && G(t[r]) ? n[r] = z(n[r], t[r]) : n[r] = t[r];
436
+ return n;
377
437
  }
378
- function A(e) {
438
+ function L(e) {
379
439
  return e && "fields" in e && typeof e.fields == "object";
380
440
  }
381
- function oe(e) {
441
+ function H(e) {
382
442
  return e && "members" in e && Array.isArray(e.members);
383
443
  }
384
- const U = (e, n = {}) => {
385
- const t = e.ast;
444
+ const M = (e, t = {}) => {
445
+ const n = e.ast, r = A(n);
446
+ if (r !== void 0)
447
+ return r;
386
448
  if (g(e.ast) === "null")
387
449
  return null;
388
450
  if (g(e.ast) !== "undefined") {
389
- if (c(t)) {
390
- const i = { ...n };
391
- for (const r of t.propertySignatures) {
392
- const s = r.name.toString(), o = r.type;
393
- let l;
394
- e.fields && e.fields[s] ? l = e.fields[s] : l = W(o);
395
- const f = U(l, n[s] || {});
396
- f !== void 0 && (i[s] = f);
451
+ if (L(e)) {
452
+ const a = {};
453
+ for (const [s, l] of Object.entries(e.fields)) {
454
+ const o = A(l?.ast);
455
+ if (o !== void 0) {
456
+ a[s] = o;
457
+ continue;
458
+ }
459
+ const m = M(l, t[s] || {});
460
+ m !== void 0 ? a[s] = m : g(l.ast) === "undefined" && (a[s] = void 0);
397
461
  }
398
- return i;
462
+ return { ...a, ...t };
399
463
  }
400
- if (A(e)) {
401
- const i = {};
402
- for (const [r, s] of Object.entries(e.fields)) {
403
- const o = s?.ast;
404
- if (o?.defaultValue)
405
- try {
406
- i[r] = o.defaultValue();
464
+ if (e?.from && L(e.from))
465
+ return M(e.from, t);
466
+ if (H(e)) {
467
+ const a = e.members.reduce((s, l) => (L(l) && Object.entries(l.fields).forEach(([o, m]) => {
468
+ const c = A(m.ast), u = s[o] ? A(s[o].ast) : void 0;
469
+ (!s[o] || c !== void 0 && u === void 0) && (s[o] = m);
470
+ }), s), {});
471
+ return Object.keys(a).length === 0 ? Object.keys(t).length > 0 ? t : void 0 : Object.entries(a).reduce((s, [l, o]) => (s[l] = M(o, t[l] || {}), s), t);
472
+ }
473
+ if (Object.keys(t).length === 0) {
474
+ if (i.AST.isObjects(n)) {
475
+ const a = { ...t };
476
+ for (const s of n.propertySignatures) {
477
+ const l = s.name.toString(), o = s.type, m = A(o);
478
+ if (m !== void 0) {
479
+ a[l] = m;
407
480
  continue;
408
- } catch {
409
481
  }
410
- const l = U(s, n[r] || {});
411
- l !== void 0 && (i[r] = l);
482
+ const c = i.make(o), u = M(c, t[l] || {});
483
+ u !== void 0 ? a[l] = u : g(o) === "undefined" && (a[l] = void 0);
484
+ }
485
+ return a;
412
486
  }
413
- return { ...i, ...n };
414
- }
415
- if (e?.from && A(e.from))
416
- return U(e.from, n);
417
- if (oe(e)) {
418
- const i = e.members.reduce((r, s) => (A(s) && Object.entries(s.fields).forEach(([o, l]) => {
419
- const f = l.ast, a = r[o]?.ast;
420
- (!r[o] || f?.defaultValue && !a?.defaultValue) && (r[o] = l);
421
- }), r), {});
422
- return Object.entries(i).reduce((r, [s, o]) => (r[s] = U(o, n[s] || {}), r), n);
487
+ if (i.AST.isString(n))
488
+ return "";
489
+ if (i.AST.isBoolean(n))
490
+ return !1;
423
491
  }
424
- if (Object.keys(n).length === 0 && t.context?.defaultValue, J(t))
425
- return "";
426
- if (R(t))
427
- return !1;
428
492
  }
429
493
  };
430
494
  export {
431
- m as createMeta,
432
- le as deepMerge,
433
- U as defaultsValueFromSchema,
434
- me as duplicateSchema,
435
- ce as generateInputStandardSchemaFromFieldMeta,
436
- ye as generateMetaFromSchema,
437
- de as getInputType,
495
+ y as createMeta,
496
+ z as deepMerge,
497
+ M as defaultsValueFromSchema,
498
+ Z as duplicateSchema,
499
+ te as generateInputStandardSchemaFromFieldMeta,
500
+ ee as generateMetaFromSchema,
501
+ ne as getInputType,
438
502
  g as isNullableOrUndefined
439
503
  };