@effect-app/vue-components 4.0.0-beta.2 → 4.0.0-beta.20

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