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