@effect-app/vue-components 0.14.5 → 0.15.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.
@@ -13,6 +13,10 @@ declare const _default: <From extends Record<PropertyKey, any>, To extends Recor
13
13
  subState: import("@tanstack/vue-form").FieldState<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").StandardSchemaV1<From, To>, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined>;
14
14
  index: number;
15
15
  }) => any;
16
+ } & {
17
+ field?: (props: {
18
+ field: import("@tanstack/vue-form").FieldApi<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").StandardSchemaV1<From, To>, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined>;
19
+ }) => any;
16
20
  };
17
21
  emit: {};
18
22
  }>) => import("vue").VNode & {
@@ -1,6 +1,6 @@
1
- import { S as n, Option as f, pipe as O } from "effect-app";
2
- import { useIntl as A } from "./vue-components.es3.js";
3
- const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKeyword" || i === n.Null.ast), y = (e) => !e || !n.AST.isUnion(e) ? !1 : e.types.find((i) => i._tag === "UndefinedKeyword") ? "undefined" : e.types.find((i) => i === n.Null.ast) ? "null" : !1, m = ({ meta: e = {}, parent: i = "", property: t, propertySignatures: o }, l = {}) => {
1
+ import { S as n, Option as c, pipe as L } from "effect-app";
2
+ import { useIntl as U } from "./vue-components.es3.js";
3
+ const _ = n.NonEmptyArray(n.String), N = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKeyword" || i === n.Null.ast), g = (e) => !e || !n.AST.isUnion(e) ? !1 : e.types.find((i) => i._tag === "UndefinedKeyword") ? "undefined" : e.types.find((i) => i === n.Null.ast) ? "null" : !1, m = ({ meta: e = {}, parent: i = "", property: t, propertySignatures: p }, o = {}) => {
4
4
  if (t && t._tag === "Transformation")
5
5
  return m({
6
6
  parent: i,
@@ -12,128 +12,169 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
12
12
  meta: e,
13
13
  propertySignatures: t.propertySignatures
14
14
  });
15
- if (o) {
16
- for (const r of o) {
17
- const u = i ? `${i}.${r.name.toString()}` : r.name.toString(), s = y(r.type), p = !s, b = r.type;
15
+ if (p) {
16
+ for (const r of p) {
17
+ const l = i ? `${i}.${r.name.toString()}` : r.name.toString(), a = g(r.type), u = !a, A = r.type;
18
18
  if (n.AST.isUnion(r.type)) {
19
- const d = r.type.types.filter(
20
- (a) => a._tag !== "UndefinedKeyword" && a !== n.Null.ast
19
+ const T = r.type.types.filter(
20
+ (s) => s._tag !== "UndefinedKeyword" && s !== n.Null.ast
21
21
  );
22
- if (d.some(
23
- (a) => "propertySignatures" in a
22
+ if (T.some(
23
+ (s) => "propertySignatures" in s
24
24
  )) {
25
- const a = m({
26
- parent: u,
27
- property: r.type,
28
- meta: { required: p, nullableOrUndefined: s }
29
- });
30
- l[u] = a;
31
- for (const g of d)
32
- "propertySignatures" in g && Object.assign(
33
- l,
25
+ if (!a) {
26
+ const s = m({
27
+ parent: l,
28
+ property: r.type,
29
+ meta: { required: u, nullableOrUndefined: a }
30
+ });
31
+ o[l] = s;
32
+ }
33
+ for (const s of T)
34
+ "propertySignatures" in s && Object.assign(
35
+ o,
34
36
  m({
35
- parent: u,
36
- propertySignatures: g.propertySignatures,
37
- meta: { required: p, nullableOrUndefined: s }
37
+ parent: l,
38
+ propertySignatures: s.propertySignatures,
39
+ meta: { required: u, nullableOrUndefined: a }
38
40
  })
39
41
  );
40
42
  } else {
41
- const a = m({
42
- parent: u,
43
- property: r.type,
44
- meta: { required: p, nullableOrUndefined: s }
45
- });
46
- l[u] = a;
43
+ const s = T.filter(n.AST.isTupleType);
44
+ if (s.length > 0) {
45
+ const f = s[0];
46
+ if (o[l] = {
47
+ type: "multiple",
48
+ members: f.elements,
49
+ rest: f.rest,
50
+ required: u,
51
+ nullableOrUndefined: a
52
+ }, f.rest && f.rest.length > 0) {
53
+ const d = f.rest[0];
54
+ if (d.type._tag === "TypeLiteral" && "propertySignatures" in d.type)
55
+ for (const y of d.type.propertySignatures) {
56
+ const b = `${l}.${y.name.toString()}`, S = m({
57
+ parent: b,
58
+ property: y.type,
59
+ meta: {
60
+ required: !g(y.type),
61
+ nullableOrUndefined: g(y.type)
62
+ }
63
+ });
64
+ if (S && typeof S == "object" && "type" in S && (o[b] = S, S.type === "multiple" && n.AST.isTupleType(y.type) && y.type.rest && y.type.rest.length > 0)) {
65
+ const O = y.type.rest[0];
66
+ if (O.type._tag === "TypeLiteral" && "propertySignatures" in O.type)
67
+ for (const v of O.type.propertySignatures) {
68
+ const M = `${b}.${v.name.toString()}`, x = m({
69
+ parent: M,
70
+ property: v.type,
71
+ meta: {
72
+ required: !g(v.type),
73
+ nullableOrUndefined: g(v.type)
74
+ }
75
+ });
76
+ x && typeof x == "object" && "type" in x && (o[M] = x);
77
+ }
78
+ }
79
+ }
80
+ }
81
+ } else {
82
+ const f = m({
83
+ parent: l,
84
+ property: r.type,
85
+ meta: { required: u, nullableOrUndefined: a }
86
+ });
87
+ o[l] = f;
88
+ }
47
89
  }
48
- }
49
- if ("propertySignatures" in b)
90
+ } else if ("propertySignatures" in A)
50
91
  Object.assign(
51
- l,
92
+ o,
52
93
  m({
53
- parent: u,
54
- propertySignatures: b.propertySignatures,
55
- meta: { required: p, nullableOrUndefined: s }
94
+ parent: l,
95
+ propertySignatures: A.propertySignatures,
96
+ meta: { required: u, nullableOrUndefined: a }
56
97
  })
57
98
  );
58
99
  else if (n.AST.isTupleType(r.type))
59
100
  if (r.type.rest.length > 0 && r.type.rest[0].type._tag === "TypeLiteral" && "propertySignatures" in r.type.rest[0].type) {
60
- const S = r.type.rest[0].type;
61
- if (S._tag === "TypeLiteral" && "propertySignatures" in S)
62
- for (const a of S.propertySignatures) {
63
- const g = `${u}.${a.name.toString()}`;
64
- if (n.AST.isTupleType(a.type) && a.type.rest.length > 0) {
65
- const c = a.type.rest[0].type;
66
- if (c._tag === "TypeLiteral" && "propertySignatures" in c)
67
- for (const T of c.propertySignatures) {
68
- const h = `${g}.${T.name.toString()}`, x = m({
69
- parent: h,
70
- property: T.type,
101
+ const h = r.type.rest[0].type;
102
+ if (h._tag === "TypeLiteral" && "propertySignatures" in h)
103
+ for (const s of h.propertySignatures) {
104
+ const f = `${l}.${s.name.toString()}`;
105
+ if (n.AST.isTupleType(s.type) && s.type.rest.length > 0) {
106
+ const d = s.type.rest[0].type;
107
+ if (d._tag === "TypeLiteral" && "propertySignatures" in d)
108
+ for (const y of d.propertySignatures) {
109
+ const b = `${f}.${y.name.toString()}`, S = m({
110
+ parent: b,
111
+ property: y.type,
71
112
  meta: {
72
- required: !y(T.type),
73
- nullableOrUndefined: y(T.type)
113
+ required: !g(y.type),
114
+ nullableOrUndefined: g(y.type)
74
115
  }
75
116
  });
76
- l[h] = x;
117
+ o[b] = S;
77
118
  }
78
119
  else
79
- l[g] = {
120
+ o[f] = {
80
121
  type: "multiple",
81
- members: a.type.elements,
82
- rest: a.type.rest,
83
- required: !y(a.type),
84
- nullableOrUndefined: y(a.type)
122
+ members: s.type.elements,
123
+ rest: s.type.rest,
124
+ required: !g(s.type),
125
+ nullableOrUndefined: g(s.type)
85
126
  };
86
127
  } else {
87
- const c = m({
88
- parent: g,
89
- property: a.type,
128
+ const d = m({
129
+ parent: f,
130
+ property: s.type,
90
131
  meta: {
91
- required: !y(a.type),
92
- nullableOrUndefined: y(a.type)
132
+ required: !g(s.type),
133
+ nullableOrUndefined: g(s.type)
93
134
  }
94
135
  });
95
- l[g] = c;
136
+ o[f] = d;
96
137
  }
97
138
  }
98
139
  } else
99
- l[u] = {
140
+ o[l] = {
100
141
  type: "multiple",
101
142
  members: r.type.elements,
102
143
  rest: r.type.rest,
103
- required: p,
104
- nullableOrUndefined: s
144
+ required: u,
145
+ nullableOrUndefined: a
105
146
  };
106
147
  else {
107
- const d = m({
108
- parent: u,
148
+ const T = m({
149
+ parent: l,
109
150
  property: r.type,
110
- meta: { required: p, nullableOrUndefined: s }
151
+ meta: { required: u, nullableOrUndefined: a }
111
152
  });
112
- l[u] = d;
153
+ o[l] = T;
113
154
  }
114
155
  }
115
- return l;
156
+ return o;
116
157
  }
117
158
  if (t) {
118
- const r = L(t);
159
+ const r = N(t);
119
160
  if (Object.hasOwnProperty.call(e, "required") || (e.required = !r), n.AST.isUnion(t)) {
120
- const s = t.types.find(
121
- (p) => p._tag !== "UndefinedKeyword" && p !== n.Null.ast
161
+ const a = t.types.find(
162
+ (u) => u._tag !== "UndefinedKeyword" && u !== n.Null.ast
122
163
  );
123
- return "propertySignatures" in s ? m({
124
- propertySignatures: s.propertySignatures,
164
+ return "propertySignatures" in a ? m({
165
+ propertySignatures: a.propertySignatures,
125
166
  parent: i,
126
167
  meta: e
127
168
  }) : t.types.every(n.AST.isLiteral) ? {
128
169
  ...e,
129
170
  type: "select",
130
- members: t.types.map((p) => p.literal)
171
+ members: t.types.map((u) => u.literal)
131
172
  } : {
132
173
  ...e,
133
174
  ...m({
134
175
  parent: i,
135
176
  meta: e,
136
- property: s
177
+ property: a
137
178
  })
138
179
  };
139
180
  }
@@ -144,11 +185,11 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
144
185
  members: t.elements,
145
186
  rest: t.rest
146
187
  };
147
- const u = n.AST.getAnnotation(
188
+ const l = n.AST.getAnnotation(
148
189
  t,
149
190
  n.AST.JSONSchemaAnnotationId
150
- ).pipe(f.getOrElse(() => ({})));
151
- return e = { ...e, ...u }, "from" in t ? m({
191
+ ).pipe(c.getOrElse(() => ({})));
192
+ return e = { ...e, ...l }, "from" in t ? m({
152
193
  parent: i,
153
194
  meta: e,
154
195
  property: t.from
@@ -156,50 +197,50 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
156
197
  t,
157
198
  n.AST.TitleAnnotationId
158
199
  ).pipe(
159
- f.getOrElse(() => "unknown")
200
+ c.getOrElse(() => "unknown")
160
201
  ), e);
161
202
  }
162
- return l;
163
- }, v = (e) => {
203
+ return o;
204
+ }, q = (e) => {
164
205
  const i = e.ast, t = {};
165
206
  if (i._tag === "Transformation" || i._tag === "Refinement")
166
- return v(n.make(i.from));
207
+ return q(n.make(i.from));
167
208
  if ("propertySignatures" in i) {
168
- const o = m({
209
+ const p = m({
169
210
  propertySignatures: i.propertySignatures
170
211
  });
171
- if (Object.values(o).every((r) => r && "type" in r))
172
- return o;
173
- const l = (r, u = "") => {
174
- for (const s in r) {
175
- const p = u ? `${u}.${s}` : s;
176
- r[s] && typeof r[s] == "object" && "type" in r[s] ? t[p] = r[s] : r[s] && typeof r[s] == "object" && l(r[s], p);
212
+ if (Object.values(p).every((r) => r && "type" in r))
213
+ return p;
214
+ const o = (r, l = "") => {
215
+ for (const a in r) {
216
+ const u = l ? `${l}.${a}` : a;
217
+ r[a] && typeof r[a] == "object" && "type" in r[a] ? t[u] = r[a] : r[a] && typeof r[a] == "object" && o(r[a], u);
177
218
  }
178
219
  };
179
- l(o);
220
+ o(p);
180
221
  }
181
222
  return t;
182
- }, N = (e) => n.extend(e, n.Struct({})), _ = (e) => {
183
- const i = v(e), t = O(
223
+ }, w = (e) => n.extend(e, n.Struct({})), $ = (e) => {
224
+ const i = q(e), t = L(
184
225
  e.ast,
185
- f.liftPredicate((o) => o._tag === "Refinement" && "filter" in o),
186
- f.flatMap((o) => n.AST.getJSONSchemaAnnotation(o)),
187
- f.filter((o) => "items" in o),
188
- f.filterMap(
189
- ({ items: o }) => n.decodeUnknownOption(M)(o)
226
+ c.liftPredicate((p) => p._tag === "Refinement" && "filter" in p),
227
+ c.flatMap((p) => n.AST.getJSONSchemaAnnotation(p)),
228
+ c.filter((p) => "items" in p),
229
+ c.filterMap(
230
+ ({ items: p }) => n.decodeUnknownOption(_)(p)
190
231
  ),
191
- f.zipWith(
232
+ c.zipWith(
192
233
  n.AST.getMessageAnnotation(e.ast),
193
- (o, l) => ({
194
- items: o,
195
- message: l("")
234
+ (p, o) => ({
235
+ items: p,
236
+ message: o("")
196
237
  })
197
238
  ),
198
- f.getOrUndefined
239
+ c.getOrUndefined
199
240
  );
200
241
  return { schema: e, meta: i, filterItems: t };
201
- }, k = (e) => {
202
- const { trans: i } = A();
242
+ }, K = (e) => {
243
+ const { trans: i } = U();
203
244
  let t;
204
245
  switch (e.type) {
205
246
  case "string":
@@ -281,7 +322,7 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
281
322
  message: () => i("validation.empty")
282
323
  })
283
324
  ) : t = n.NullishOr(t), n.standardSchemaV1(t);
284
- }, w = (e, i) => n.NullOr(e).pipe(
325
+ }, P = (e, i) => n.NullOr(e).pipe(
285
326
  n.transform(n.typeSchema(e), {
286
327
  decode: (t) => t ?? i(),
287
328
  encode: (t) => t
@@ -289,8 +330,8 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
289
330
  );
290
331
  export {
291
332
  m as createMeta,
292
- N as duplicateSchema,
293
- k as generateInputStandardSchemaFromFieldMeta,
294
- _ as generateMetaFromSchema,
295
- w as nullableInput
333
+ w as duplicateSchema,
334
+ K as generateInputStandardSchemaFromFieldMeta,
335
+ $ as generateMetaFromSchema,
336
+ P as nullableInput
296
337
  };
@@ -1,6 +1,6 @@
1
- import { defineComponent as d, inject as f, computed as o, createBlock as n, openBlock as m, resolveDynamicComponent as v, withCtx as l, createCommentVNode as c, mergeProps as y, renderSlot as g, normalizeProps as h, guardReactiveProps as C } from "vue";
2
- import { generateInputStandardSchemaFromFieldMeta as F } from "./vue-components.es10.js";
3
- import b from "./vue-components.es24.js";
1
+ import { defineComponent as d, inject as f, computed as r, createBlock as n, openBlock as m, resolveDynamicComponent as c, withCtx as l, createCommentVNode as v, mergeProps as y, renderSlot as g, normalizeProps as h, guardReactiveProps as b } from "vue";
2
+ import { generateInputStandardSchemaFromFieldMeta as C } from "./vue-components.es10.js";
3
+ import F from "./vue-components.es24.js";
4
4
  const P = /* @__PURE__ */ d({
5
5
  inheritAttrs: !1,
6
6
  __name: "OmegaInput",
@@ -13,15 +13,15 @@ const P = /* @__PURE__ */ d({
13
13
  type: {}
14
14
  },
15
15
  setup(s) {
16
- const a = s, r = f(
16
+ const a = s, o = f(
17
17
  "getMetaFromArray",
18
18
  null
19
- ), t = o(() => r?.value && r.value(a.name) ? r.value(a.name) : a.form.meta[a.name]), i = o(() => {
19
+ ), t = r(() => o?.value && o.value(a.name) ? o.value(a.name) : a.form.meta[a.name]), i = r(() => {
20
20
  if (!t.value)
21
- throw new Error("Meta is undefined");
22
- return F(t.value);
21
+ throw console.log(a.name, Object.keys(a.form.meta), a.form.meta), new Error("Meta is undefined");
22
+ return C(t.value);
23
23
  });
24
- return (e, M) => (m(), n(v(e.form.Field), {
24
+ return (e, k) => (m(), n(c(e.form.Field), {
25
25
  name: e.name,
26
26
  validators: {
27
27
  onChange: i.value,
@@ -29,7 +29,7 @@ const P = /* @__PURE__ */ d({
29
29
  }
30
30
  }, {
31
31
  default: l(({ field: p }) => [
32
- t.value ? (m(), n(b, y({
32
+ t.value ? (m(), n(F, y({
33
33
  key: 0,
34
34
  field: p,
35
35
  label: e.label,
@@ -38,10 +38,10 @@ const P = /* @__PURE__ */ d({
38
38
  type: e.type
39
39
  }, e.$attrs), {
40
40
  default: l((u) => [
41
- g(e.$slots, "default", h(C(u)))
41
+ g(e.$slots, "default", h(b(u)))
42
42
  ]),
43
43
  _: 2
44
- }, 1040, ["field", "label", "options", "meta", "type"])) : c("", !0)
44
+ }, 1040, ["field", "label", "options", "meta", "type"])) : v("", !0)
45
45
  ]),
46
46
  _: 3
47
47
  }, 8, ["name", "validators"]));
@@ -1,5 +1,5 @@
1
- import { defineComponent as i, computed as m, onMounted as p, provide as g, createElementBlock as h, openBlock as s, Fragment as v, renderList as y, createBlock as F, resolveDynamicComponent as M, withCtx as _, renderSlot as $, mergeProps as k } from "vue";
2
- const P = /* @__PURE__ */ i({
1
+ import { defineComponent as F, computed as l, onMounted as P, provide as $, createElementBlock as s, openBlock as n, Fragment as u, createBlock as d, renderList as M, resolveDynamicComponent as i, withCtx as f, renderSlot as p, mergeProps as k, normalizeProps as A, guardReactiveProps as b } from "vue";
2
+ const B = /* @__PURE__ */ F({
3
3
  inheritAttrs: !1,
4
4
  __name: "OmegaArray",
5
5
  props: {
@@ -8,30 +8,38 @@ const P = /* @__PURE__ */ i({
8
8
  defaultItems: {},
9
9
  items: {}
10
10
  },
11
- setup(l) {
12
- const t = l, u = t.form.useStore((e) => e.values), o = m(() => t.name.replace(/\[/g, ".").replace(/\]/g, "").split(".").reduce((r, a) => r[a], u.value));
13
- p(async () => {
14
- t.defaultItems && !o.value && t.form.setFieldValue(t.name, t.defaultItems);
11
+ setup(c) {
12
+ const r = c, g = r.form.useStore((e) => e.values), m = l(() => r.name.replace(/\[/g, ".").replace(/\]/g, "").split(".").reduce((a, t) => a[t], g.value));
13
+ P(async () => {
14
+ r.defaultItems && !m.value && r.form.setFieldValue(r.name, r.defaultItems);
15
15
  });
16
- const d = m(() => (r) => {
17
- const a = r.replace(/\[\d+\]/g, "");
18
- return t.form.meta[a];
16
+ const v = l(() => (a) => {
17
+ const t = a.replace(/\[\d+\]/g, "");
18
+ return r.form.meta[t];
19
19
  });
20
- return g("getMetaFromArray", d), (e, r) => (s(!0), h(v, null, y(o.value, (a, n) => (s(), F(M(e.form.Field), {
21
- key: `${e.name}[${Number(n)}]`,
22
- name: `${e.name}[${Number(n)}]`
23
- }, {
24
- default: _(({ field: c, state: f }) => [
25
- $(e.$slots, "default", k({ ref_for: !0 }, {
26
- subField: c,
27
- subState: f,
28
- index: Number(n)
29
- }))
30
- ]),
31
- _: 2
32
- }, 1032, ["name"]))), 128));
20
+ return $("getMetaFromArray", v), (e, a) => (n(), s(u, null, [
21
+ (n(!0), s(u, null, M(m.value, (t, o) => (n(), d(i(e.form.Field), {
22
+ key: `${e.name}[${Number(o)}]`,
23
+ name: `${e.name}[${Number(o)}]`
24
+ }, {
25
+ default: f(({ field: h, state: y }) => [
26
+ p(e.$slots, "default", k({ ref_for: !0 }, {
27
+ subField: h,
28
+ subState: y,
29
+ index: Number(o)
30
+ }))
31
+ ]),
32
+ _: 2
33
+ }, 1032, ["name"]))), 128)),
34
+ (n(), d(i(e.form.Field), { name: e.name }, {
35
+ default: f(({ field: t }) => [
36
+ p(e.$slots, "field", A(b({ field: t })))
37
+ ]),
38
+ _: 3
39
+ }, 8, ["name"]))
40
+ ], 64));
33
41
  }
34
42
  });
35
43
  export {
36
- P as default
44
+ B as default
37
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "0.14.5",
3
+ "version": "0.15.0",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "@tanstack/vue-form": "^1.2.4",
@@ -17,8 +17,12 @@
17
17
  />
18
18
  </template>
19
19
  </component>
20
+ <component :is="form.Field" :name="name">
21
+ <template #default="{ field }">
22
+ <slot name="field" v-bind="{ field }" />
23
+ </template>
24
+ </component>
20
25
  </template>
21
-
22
26
  <script
23
27
  setup
24
28
  lang="ts"
@@ -268,14 +268,16 @@ export const createMeta = <T = any>(
268
268
  )
269
269
 
270
270
  if (hasStructMembers) {
271
- // Create metadata for the parent level (the union itself)
272
- const parentMeta = createMeta<T>({
273
- parent: key,
274
- property: p.type,
275
- meta: { required: isRequired, nullableOrUndefined },
276
- })
277
- acc[key as NestedKeyOf<T>] = parentMeta as FieldMeta
278
-
271
+ // Only create parent meta for non-NullOr unions to avoid duplicates
272
+ if (!nullableOrUndefined) {
273
+ const parentMeta = createMeta<T>({
274
+ parent: key,
275
+ property: p.type,
276
+ meta: { required: isRequired, nullableOrUndefined },
277
+ })
278
+ acc[key as NestedKeyOf<T>] = parentMeta as FieldMeta
279
+ }
280
+
279
281
  // Process each non-null type and merge their metadata
280
282
  for (const nonNullType of nonNullTypes) {
281
283
  if ("propertySignatures" in nonNullType) {
@@ -290,16 +292,78 @@ export const createMeta = <T = any>(
290
292
  }
291
293
  }
292
294
  } else {
293
- // If no struct members, process as regular union
294
- const newMeta = createMeta<T>({
295
- parent: key,
296
- property: p.type,
297
- meta: { required: isRequired, nullableOrUndefined },
298
- })
299
- acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
295
+ // Check if any of the union types are arrays (TupleType)
296
+ const arrayTypes = nonNullTypes.filter(S.AST.isTupleType)
297
+ if (arrayTypes.length > 0) {
298
+ const arrayType = arrayTypes[0] // Take the first array type
299
+
300
+ acc[key as NestedKeyOf<T>] = {
301
+ type: "multiple",
302
+ members: arrayType.elements,
303
+ rest: arrayType.rest,
304
+ required: isRequired,
305
+ nullableOrUndefined
306
+ } as FieldMeta
307
+
308
+ // If the array has struct elements, also create metadata for their properties
309
+ if (arrayType.rest && arrayType.rest.length > 0) {
310
+ const restElement = arrayType.rest[0]
311
+ if (restElement.type._tag === "TypeLiteral" && "propertySignatures" in restElement.type) {
312
+
313
+ for (const prop of restElement.type.propertySignatures) {
314
+ const propKey = `${key}.${prop.name.toString()}`
315
+
316
+ const propMeta = createMeta<T>({
317
+ parent: propKey,
318
+ property: prop.type,
319
+ meta: {
320
+ required: !isNullableOrUndefined(prop.type),
321
+ nullableOrUndefined: isNullableOrUndefined(prop.type)
322
+ }
323
+ })
324
+
325
+ // add to accumulator if valid
326
+ if (propMeta && typeof propMeta === 'object' && 'type' in propMeta) {
327
+ acc[propKey as NestedKeyOf<T>] = propMeta as FieldMeta
328
+
329
+ if (propMeta.type === "multiple" && S.AST.isTupleType(prop.type) && prop.type.rest && prop.type.rest.length > 0) {
330
+ const nestedRestElement = prop.type.rest[0]
331
+ if (nestedRestElement.type._tag === "TypeLiteral" && "propertySignatures" in nestedRestElement.type) {
332
+
333
+ for (const nestedProp of nestedRestElement.type.propertySignatures) {
334
+ const nestedPropKey = `${propKey}.${nestedProp.name.toString()}`
335
+
336
+ const nestedPropMeta = createMeta<T>({
337
+ parent: nestedPropKey,
338
+ property: nestedProp.type,
339
+ meta: {
340
+ required: !isNullableOrUndefined(nestedProp.type),
341
+ nullableOrUndefined: isNullableOrUndefined(nestedProp.type)
342
+ }
343
+ })
344
+
345
+ // add to accumulator if valid
346
+ if (nestedPropMeta && typeof nestedPropMeta === 'object' && 'type' in nestedPropMeta) {
347
+ acc[nestedPropKey as NestedKeyOf<T>] = nestedPropMeta as FieldMeta
348
+ }
349
+ }
350
+ }
351
+ }
352
+ }
353
+ }
354
+ }
355
+ }
356
+ } else {
357
+ // If no struct members and no arrays, process as regular union
358
+ const newMeta = createMeta<T>({
359
+ parent: key,
360
+ property: p.type,
361
+ meta: { required: isRequired, nullableOrUndefined },
362
+ })
363
+ acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
364
+ }
300
365
  }
301
- }
302
- if ("propertySignatures" in typeToProcess) {
366
+ } else if ("propertySignatures" in typeToProcess) {
303
367
  Object.assign(
304
368
  acc,
305
369
  createMeta<T>({
@@ -380,6 +444,8 @@ export const createMeta = <T = any>(
380
444
  property: p.type,
381
445
  meta: { required: isRequired, nullableOrUndefined },
382
446
  })
447
+
448
+
383
449
  acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
384
450
  }
385
451
  }
@@ -54,6 +54,7 @@ const meta = computed(() => {
54
54
 
55
55
  const schema = computed(() => {
56
56
  if (!meta.value) {
57
+ console.log(props.name, Object.keys(props.form.meta), props.form.meta)
57
58
  throw new Error("Meta is undefined")
58
59
  }
59
60
  return generateInputStandardSchemaFromFieldMeta(meta.value)