@effect-app/vue-components 0.14.2 → 0.14.5

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.
@@ -1,4 +1,4 @@
1
- import { S, type Record, type Effect } from "effect-app";
1
+ import { S, type Effect } from "effect-app";
2
2
  import { type FormAsyncValidateOrFn, type FormValidateOrFn, type StandardSchemaV1, type FormApi, type VueFormApi, type FormOptions, type DeepKeys, type FieldValidateOrFn, type FieldAsyncValidateOrFn, type FormState } from "@tanstack/vue-form";
3
3
  import { OmegaFormReturn } from "./useOmegaForm";
4
4
  import { OmegaFieldInternalApi } from "./InputProps";
@@ -1,5 +1,5 @@
1
1
  import { DeepKeys } from "@tanstack/vue-form";
2
- import { type Record, S } from "effect-app";
2
+ import { S } from "effect-app";
3
3
  import { type NestedKeyOf, type FilterItems, type FormProps, type MetaRecord, type OmegaFormApi, TypeOverride, FieldValidators } from "./OmegaFormStuff";
4
4
  import { type InjectionKey } from "vue";
5
5
  import { InputProps } from "./InputProps";
@@ -1,200 +1,248 @@
1
- import { S as t, Option as g, pipe as S } from "effect-app";
2
- import { useIntl as v } from "./vue-components.es3.js";
3
- const x = t.NonEmptyArray(t.String), T = (e) => t.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKeyword" || i === t.Null.ast), h = (e) => !e || !t.AST.isUnion(e) ? !1 : e.types.find((i) => i._tag === "UndefinedKeyword") ? "undefined" : e.types.find((i) => i === t.Null.ast) ? "null" : !1, m = ({ meta: e = {}, parent: i = "", property: n, propertySignatures: a }, u = {}) => {
4
- if (n && n._tag === "Transformation")
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 = {}) => {
4
+ if (t && t._tag === "Transformation")
5
5
  return m({
6
6
  parent: i,
7
7
  meta: e,
8
- property: n.from
8
+ property: t.from
9
9
  });
10
- if (n?._tag === "TypeLiteral" && "propertySignatures" in n)
10
+ if (t?._tag === "TypeLiteral" && "propertySignatures" in t)
11
11
  return m({
12
12
  meta: e,
13
- propertySignatures: n.propertySignatures
13
+ propertySignatures: t.propertySignatures
14
14
  });
15
- if (a) {
16
- for (const s of a) {
17
- const o = i ? `${i}.${s.name.toString()}` : s.name.toString(), r = h(s.type), l = !r, d = s.type;
18
- if (t.AST.isUnion(s.type)) {
19
- const p = s.type.types.filter(
20
- (f) => f._tag !== "UndefinedKeyword" && f !== t.Null.ast
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;
18
+ if (n.AST.isUnion(r.type)) {
19
+ const d = r.type.types.filter(
20
+ (a) => a._tag !== "UndefinedKeyword" && a !== n.Null.ast
21
21
  );
22
- if (p.some(
23
- (f) => "propertySignatures" in f
22
+ if (d.some(
23
+ (a) => "propertySignatures" in a
24
24
  )) {
25
- const f = m({
26
- parent: o,
27
- property: s.type,
28
- meta: { required: l, nullableOrUndefined: r }
25
+ const a = m({
26
+ parent: u,
27
+ property: r.type,
28
+ meta: { required: p, nullableOrUndefined: s }
29
29
  });
30
- u[o] = f;
31
- for (const c of p)
32
- "propertySignatures" in c && Object.assign(
33
- u,
30
+ l[u] = a;
31
+ for (const g of d)
32
+ "propertySignatures" in g && Object.assign(
33
+ l,
34
34
  m({
35
- parent: o,
36
- propertySignatures: c.propertySignatures,
37
- meta: { required: l, nullableOrUndefined: r }
35
+ parent: u,
36
+ propertySignatures: g.propertySignatures,
37
+ meta: { required: p, nullableOrUndefined: s }
38
38
  })
39
39
  );
40
40
  } else {
41
- const f = m({
42
- parent: o,
43
- property: s.type,
44
- meta: { required: l, nullableOrUndefined: r }
41
+ const a = m({
42
+ parent: u,
43
+ property: r.type,
44
+ meta: { required: p, nullableOrUndefined: s }
45
45
  });
46
- u[o] = f;
46
+ l[u] = a;
47
47
  }
48
48
  }
49
- if ("propertySignatures" in d)
49
+ if ("propertySignatures" in b)
50
50
  Object.assign(
51
- u,
51
+ l,
52
52
  m({
53
- parent: o,
54
- propertySignatures: d.propertySignatures,
55
- meta: { required: l, nullableOrUndefined: r }
53
+ parent: u,
54
+ propertySignatures: b.propertySignatures,
55
+ meta: { required: p, nullableOrUndefined: s }
56
56
  })
57
57
  );
58
+ else if (n.AST.isTupleType(r.type))
59
+ 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,
71
+ meta: {
72
+ required: !y(T.type),
73
+ nullableOrUndefined: y(T.type)
74
+ }
75
+ });
76
+ l[h] = x;
77
+ }
78
+ else
79
+ l[g] = {
80
+ type: "multiple",
81
+ members: a.type.elements,
82
+ rest: a.type.rest,
83
+ required: !y(a.type),
84
+ nullableOrUndefined: y(a.type)
85
+ };
86
+ } else {
87
+ const c = m({
88
+ parent: g,
89
+ property: a.type,
90
+ meta: {
91
+ required: !y(a.type),
92
+ nullableOrUndefined: y(a.type)
93
+ }
94
+ });
95
+ l[g] = c;
96
+ }
97
+ }
98
+ } else
99
+ l[u] = {
100
+ type: "multiple",
101
+ members: r.type.elements,
102
+ rest: r.type.rest,
103
+ required: p,
104
+ nullableOrUndefined: s
105
+ };
58
106
  else {
59
- const p = m({
60
- parent: o,
61
- property: s.type,
62
- meta: { required: l, nullableOrUndefined: r }
107
+ const d = m({
108
+ parent: u,
109
+ property: r.type,
110
+ meta: { required: p, nullableOrUndefined: s }
63
111
  });
64
- u[o] = p;
112
+ l[u] = d;
65
113
  }
66
114
  }
67
- return u;
115
+ return l;
68
116
  }
69
- if (n) {
70
- const s = T(n);
71
- if (Object.hasOwnProperty.call(e, "required") || (e.required = !s), t.AST.isUnion(n)) {
72
- const r = n.types.find(
73
- (l) => l._tag !== "UndefinedKeyword" && l !== t.Null.ast
117
+ if (t) {
118
+ const r = L(t);
119
+ 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
74
122
  );
75
- return "propertySignatures" in r ? m({
76
- propertySignatures: r.propertySignatures,
123
+ return "propertySignatures" in s ? m({
124
+ propertySignatures: s.propertySignatures,
77
125
  parent: i,
78
126
  meta: e
79
- }) : n.types.every(t.AST.isLiteral) ? {
127
+ }) : t.types.every(n.AST.isLiteral) ? {
80
128
  ...e,
81
129
  type: "select",
82
- members: n.types.map((l) => l.literal)
130
+ members: t.types.map((p) => p.literal)
83
131
  } : {
84
132
  ...e,
85
133
  ...m({
86
134
  parent: i,
87
135
  meta: e,
88
- property: r
136
+ property: s
89
137
  })
90
138
  };
91
139
  }
92
- if (t.AST.isTupleType(n))
140
+ if (n.AST.isTupleType(t))
93
141
  return {
94
142
  ...e,
95
143
  type: "multiple",
96
- members: n.elements,
97
- rest: n.rest
144
+ members: t.elements,
145
+ rest: t.rest
98
146
  };
99
- const o = t.AST.getAnnotation(
100
- n,
101
- t.AST.JSONSchemaAnnotationId
102
- ).pipe(g.getOrElse(() => ({})));
103
- return e = { ...e, ...o }, "from" in n ? m({
147
+ const u = n.AST.getAnnotation(
148
+ t,
149
+ n.AST.JSONSchemaAnnotationId
150
+ ).pipe(f.getOrElse(() => ({})));
151
+ return e = { ...e, ...u }, "from" in t ? m({
104
152
  parent: i,
105
153
  meta: e,
106
- property: n.from
107
- }) : (e.type = t.AST.getAnnotation(
108
- n,
109
- t.AST.TitleAnnotationId
154
+ property: t.from
155
+ }) : (e.type = n.AST.getAnnotation(
156
+ t,
157
+ n.AST.TitleAnnotationId
110
158
  ).pipe(
111
- g.getOrElse(() => "unknown")
159
+ f.getOrElse(() => "unknown")
112
160
  ), e);
113
161
  }
114
- return u;
115
- }, y = (e) => {
116
- const i = e.ast, n = {};
162
+ return l;
163
+ }, v = (e) => {
164
+ const i = e.ast, t = {};
117
165
  if (i._tag === "Transformation" || i._tag === "Refinement")
118
- return y(t.make(i.from));
166
+ return v(n.make(i.from));
119
167
  if ("propertySignatures" in i) {
120
- const a = m({
168
+ const o = m({
121
169
  propertySignatures: i.propertySignatures
122
170
  });
123
- if (Object.values(a).every((s) => s && "type" in s))
124
- return a;
125
- const u = (s, o = "") => {
126
- for (const r in s) {
127
- const l = o ? `${o}.${r}` : r;
128
- s[r] && typeof s[r] == "object" && "type" in s[r] ? n[l] = s[r] : s[r] && typeof s[r] == "object" && u(s[r], l);
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);
129
177
  }
130
178
  };
131
- u(a);
179
+ l(o);
132
180
  }
133
- return n;
134
- }, M = (e) => t.extend(e, t.Struct({})), N = (e) => {
135
- const i = y(e), n = S(
181
+ return t;
182
+ }, N = (e) => n.extend(e, n.Struct({})), _ = (e) => {
183
+ const i = v(e), t = O(
136
184
  e.ast,
137
- g.liftPredicate((a) => a._tag === "Refinement" && "filter" in a),
138
- g.flatMap((a) => t.AST.getJSONSchemaAnnotation(a)),
139
- g.filter((a) => "items" in a),
140
- g.filterMap(
141
- ({ items: a }) => t.decodeUnknownOption(x)(a)
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)
142
190
  ),
143
- g.zipWith(
144
- t.AST.getMessageAnnotation(e.ast),
145
- (a, u) => ({
146
- items: a,
147
- message: u("")
191
+ f.zipWith(
192
+ n.AST.getMessageAnnotation(e.ast),
193
+ (o, l) => ({
194
+ items: o,
195
+ message: l("")
148
196
  })
149
197
  ),
150
- g.getOrUndefined
198
+ f.getOrUndefined
151
199
  );
152
- return { schema: e, meta: i, filterItems: n };
153
- }, L = (e) => {
154
- const { trans: i } = v();
155
- let n;
200
+ return { schema: e, meta: i, filterItems: t };
201
+ }, k = (e) => {
202
+ const { trans: i } = A();
203
+ let t;
156
204
  switch (e.type) {
157
205
  case "string":
158
- n = t.String.annotations({
206
+ t = n.String.annotations({
159
207
  message: () => i("validation.empty")
160
- }), e.format === "email" && (n = t.compose(
161
- n,
162
- t.Email.annotations({
208
+ }), e.format === "email" && (t = n.compose(
209
+ t,
210
+ n.Email.annotations({
163
211
  message: () => i("validation.email.invalid")
164
212
  })
165
- )), e.required && n.annotations({
213
+ )), e.required && t.annotations({
166
214
  message: () => i("validation.empty")
167
- }), e.maxLength && (n = n.pipe(t.maxLength(e.maxLength)).annotations({
215
+ }), e.maxLength && (t = t.pipe(n.maxLength(e.maxLength)).annotations({
168
216
  message: () => i("validation.string.maxLength", {
169
217
  maxLength: e.maxLength
170
218
  })
171
- })), e.minLength && (n = n.pipe(t.minLength(e.minLength)).annotations({
219
+ })), e.minLength && (t = t.pipe(n.minLength(e.minLength)).annotations({
172
220
  message: () => i("validation.string.minLength", {
173
221
  minLength: e.minLength
174
222
  })
175
223
  }));
176
224
  break;
177
225
  case "number":
178
- n = t.Number.annotations({
226
+ t = n.Number.annotations({
179
227
  message: () => i("validation.empty")
180
- }), e.required && n.annotations({
228
+ }), e.required && t.annotations({
181
229
  message: () => i("validation.empty")
182
- }), e.minimum && (n = n.pipe(t.greaterThanOrEqualTo(e.minimum)).annotations({
230
+ }), e.minimum && (t = t.pipe(n.greaterThanOrEqualTo(e.minimum)).annotations({
183
231
  message: () => i("validation.number.min", {
184
232
  minimum: e.minimum,
185
233
  isExclusive: !0
186
234
  })
187
- })), e.maximum && (n = n.pipe(t.lessThanOrEqualTo(e.maximum)).annotations({
235
+ })), e.maximum && (t = t.pipe(n.lessThanOrEqualTo(e.maximum)).annotations({
188
236
  message: () => i("validation.number.max", {
189
237
  maximum: e.maximum,
190
238
  isExclusive: !0
191
239
  })
192
- })), e.exclusiveMinimum && (n = n.pipe(t.greaterThan(e.exclusiveMinimum)).annotations({
240
+ })), e.exclusiveMinimum && (t = t.pipe(n.greaterThan(e.exclusiveMinimum)).annotations({
193
241
  message: () => i("validation.number.min", {
194
242
  minimum: e.exclusiveMinimum,
195
243
  isExclusive: !1
196
244
  })
197
- })), e.exclusiveMaximum && (n = n.pipe(t.lessThan(e.exclusiveMaximum)).annotations({
245
+ })), e.exclusiveMaximum && (t = t.pipe(n.lessThan(e.exclusiveMaximum)).annotations({
198
246
  message: () => i("validation.number.max", {
199
247
  maximum: e.exclusiveMaximum,
200
248
  isExclusive: !1
@@ -202,7 +250,7 @@ const x = t.NonEmptyArray(t.String), T = (e) => t.AST.isUnion(e) && e.types.find
202
250
  }));
203
251
  break;
204
252
  case "select":
205
- n = t.Literal(...e.members).annotations({
253
+ t = n.Literal(...e.members).annotations({
206
254
  message: () => ({
207
255
  message: i("validation.not_a_valid", {
208
256
  type: "select",
@@ -213,7 +261,7 @@ const x = t.NonEmptyArray(t.String), T = (e) => t.AST.isUnion(e) && e.types.find
213
261
  });
214
262
  break;
215
263
  case "multiple":
216
- n = t.Array(t.String).annotations({
264
+ t = n.Array(n.String).annotations({
217
265
  message: () => i("validation.not_a_valid", {
218
266
  type: "multiple",
219
267
  message: e.members.join(", ")
@@ -221,28 +269,28 @@ const x = t.NonEmptyArray(t.String), T = (e) => t.AST.isUnion(e) && e.types.find
221
269
  });
222
270
  break;
223
271
  case "boolean":
224
- n = t.Boolean;
272
+ t = n.Boolean;
225
273
  break;
226
274
  // todo: switch must be exhaustive or have default case, otherwise falls through with schema undefined.
227
275
  case "unknown":
228
- n = t.Unknown;
276
+ t = n.Unknown;
229
277
  break;
230
278
  }
231
- return e.required ? n.pipe(
232
- t.annotations({
279
+ return e.required ? t.pipe(
280
+ n.annotations({
233
281
  message: () => i("validation.empty")
234
282
  })
235
- ) : n = t.NullishOr(n), t.standardSchemaV1(n);
236
- }, U = (e, i) => t.NullOr(e).pipe(
237
- t.transform(t.typeSchema(e), {
238
- decode: (n) => n ?? i(),
239
- encode: (n) => n
283
+ ) : t = n.NullishOr(t), n.standardSchemaV1(t);
284
+ }, w = (e, i) => n.NullOr(e).pipe(
285
+ n.transform(n.typeSchema(e), {
286
+ decode: (t) => t ?? i(),
287
+ encode: (t) => t
240
288
  })
241
289
  );
242
290
  export {
243
291
  m as createMeta,
244
- M as duplicateSchema,
245
- L as generateInputStandardSchemaFromFieldMeta,
246
- N as generateMetaFromSchema,
247
- U as nullableInput
292
+ N as duplicateSchema,
293
+ k as generateInputStandardSchemaFromFieldMeta,
294
+ _ as generateMetaFromSchema,
295
+ w as nullableInput
248
296
  };
@@ -1,6 +1,5 @@
1
- import { defineComponent as y, computed as u, onMounted as c, provide as g, createElementBlock as M, openBlock as p, Fragment as v, renderList as _, createBlock as h, resolveDynamicComponent as k, withCtx as F, renderSlot as S, mergeProps as $ } from "vue";
2
- import { createMeta as A } from "./vue-components.es10.js";
3
- const C = /* @__PURE__ */ y({
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({
4
3
  inheritAttrs: !1,
5
4
  __name: "OmegaArray",
6
5
  props: {
@@ -10,41 +9,23 @@ const C = /* @__PURE__ */ y({
10
9
  items: {}
11
10
  },
12
11
  setup(l) {
13
- const t = l, i = t.form.useStore((e) => e.values), m = u(() => t.name.split(".").reduce((e, a) => e[a], i.value));
14
- c(async () => {
15
- t.defaultItems && !m.value && t.form.setFieldValue(t.name, t.defaultItems);
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);
16
15
  });
17
- const f = u(() => {
18
- const e = t.form.meta[t.name];
19
- if (e && e.type === "multiple") {
20
- const a = e.rest.reduce((r, n) => n.type._tag === "TypeLiteral" ? {
21
- ...r,
22
- propertySignatures: [
23
- ...r.propertySignatures || [],
24
- ...n.type.propertySignatures
25
- ]
26
- } : {
27
- ...r,
28
- property: n.type
29
- }, {}), s = A({ ...a, meta: e });
30
- return (r) => {
31
- if (r.endsWith("]")) return s;
32
- const n = r.split("]."), d = n[n.length - 1];
33
- return s[d];
34
- };
35
- }
36
- return (a) => {
37
- };
16
+ const d = m(() => (r) => {
17
+ const a = r.replace(/\[\d+\]/g, "");
18
+ return t.form.meta[a];
38
19
  });
39
- return g("getMetaFromArray", f), (e, a) => (p(!0), M(v, null, _(m.value, (s, o) => (p(), h(k(e.form.Field), {
40
- key: `${e.name}[${Number(o)}]`,
41
- name: `${e.name}[${Number(o)}]`
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)}]`
42
23
  }, {
43
- default: F(({ field: r, state: n }) => [
44
- S(e.$slots, "default", $({ ref_for: !0 }, {
45
- subField: r,
46
- subState: n,
47
- index: Number(o)
24
+ default: _(({ field: c, state: f }) => [
25
+ $(e.$slots, "default", k({ ref_for: !0 }, {
26
+ subField: c,
27
+ subState: f,
28
+ index: Number(n)
48
29
  }))
49
30
  ]),
50
31
  _: 2
@@ -52,5 +33,5 @@ const C = /* @__PURE__ */ y({
52
33
  }
53
34
  });
54
35
  export {
55
- C as default
36
+ P as default
56
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "0.14.2",
3
+ "version": "0.14.5",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "@tanstack/vue-form": "^1.2.4",
@@ -50,8 +50,8 @@
50
50
  "dependencies": {
51
51
  "highlight.js": "^11.11.1",
52
52
  "vue3-highlightjs": "^1.0.5",
53
- "@effect-app/vue": "2.51.11",
54
- "effect-app": "3.0.10"
53
+ "@effect-app/vue": "2.51.13",
54
+ "effect-app": "3.1.0"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "pnpm build:run",
@@ -29,9 +29,7 @@
29
29
  >
30
30
  import { computed, onMounted, provide } from "vue"
31
31
  import {
32
- type CreateMeta,
33
32
  type OmegaInputProps,
34
- createMeta,
35
33
  } from "./OmegaFormStuff"
36
34
  import { type DeepValue, type DeepKeys } from "@tanstack/vue-form"
37
35
 
@@ -52,10 +50,8 @@ defineOptions({
52
50
 
53
51
  const store = props.form.useStore(state => state.values)
54
52
  const items = computed(() => {
55
- return props.name.split(".").reduce((acc, curr) => {
56
- if (curr === "items") {
57
- return acc[curr]
58
- }
53
+ const normalizedPath = props.name.replace(/\[/g, ".").replace(/\]/g, "")
54
+ return normalizedPath.split(".").reduce((acc, curr) => {
59
55
  return acc[curr] as typeof store.value
60
56
  }, store.value)
61
57
  })
@@ -67,34 +63,14 @@ onMounted(async () => {
67
63
  })
68
64
 
69
65
  const getMetaFromArray = computed(() => {
70
- const inputMeta = props.form.meta[props.name]
71
- if (inputMeta && inputMeta.type === "multiple") {
72
- const result = inputMeta.rest.reduce<CreateMeta>((acc, curr) => {
73
- if (curr.type._tag === "TypeLiteral") {
74
- return {
75
- ...acc,
76
- propertySignatures: [
77
- ...(acc.propertySignatures || []),
78
- ...curr.type.propertySignatures,
79
- ],
80
- } as CreateMeta
81
- }
82
- return {
83
- ...acc,
84
- property: curr.type,
85
- } as CreateMeta
86
- }, {} as CreateMeta)
66
+ const getMeta = (path: string) => {
67
+ // Transform path like 'a[0].b[11].c' into 'a.b.c'
68
+ const simplifiedPath = path.replace(/\[\d+\]/g, '')
87
69
 
88
- const arrayMeta = createMeta({ ...result, meta: inputMeta })
89
- const getMeta = (index: string) => {
90
- if (index.endsWith("]")) return arrayMeta
91
- const parts = index.split("].")
92
- const key = parts[parts.length - 1]
93
- return arrayMeta[key as keyof typeof arrayMeta]
94
- }
95
- return getMeta
70
+ return props.form.meta[simplifiedPath as keyof typeof props.form.meta]
96
71
  }
97
- return (_: string) => undefined
72
+
73
+ return getMeta
98
74
  })
99
75
 
100
76
  provide("getMetaFromArray", getMetaFromArray)
@@ -255,6 +255,7 @@ export const createMeta = <T = any>(
255
255
  const key = parent ? `${parent}.${p.name.toString()}` : p.name.toString()
256
256
  const nullableOrUndefined = isNullableOrUndefined(p.type)
257
257
  const isRequired = !nullableOrUndefined
258
+
258
259
 
259
260
  const typeToProcess = p.type
260
261
  if (S.AST.isUnion(p.type)) {
@@ -308,12 +309,79 @@ export const createMeta = <T = any>(
308
309
  })
309
310
  )
310
311
  } else {
311
- const newMeta = createMeta<T>({
312
- parent: key,
313
- property: p.type,
314
- meta: { required: isRequired, nullableOrUndefined },
315
- })
316
- acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
312
+ // Check if this is an array type
313
+ if (S.AST.isTupleType(p.type)) {
314
+ // Check if it has struct elements
315
+ const hasStructElements = p.type.rest.length > 0 &&
316
+ p.type.rest[0].type._tag === "TypeLiteral" &&
317
+ "propertySignatures" in p.type.rest[0].type
318
+
319
+ if (hasStructElements) {
320
+ // For arrays with struct elements, only create meta for nested fields, not the array itself
321
+ const elementType = p.type.rest[0].type
322
+ if (elementType._tag === "TypeLiteral" && "propertySignatures" in elementType) {
323
+ // Process each property in the array element
324
+ for (const prop of elementType.propertySignatures) {
325
+ const propKey = `${key}.${prop.name.toString()}`
326
+
327
+ // Check if the property is another array
328
+ if (S.AST.isTupleType(prop.type) && prop.type.rest.length > 0) {
329
+ const nestedElementType = prop.type.rest[0].type
330
+ if (nestedElementType._tag === "TypeLiteral" && "propertySignatures" in nestedElementType) {
331
+ // Array with struct elements - process nested fields
332
+ for (const nestedProp of nestedElementType.propertySignatures) {
333
+ const nestedKey = `${propKey}.${nestedProp.name.toString()}`
334
+ const nestedMeta = createMeta<T>({
335
+ parent: nestedKey,
336
+ property: nestedProp.type,
337
+ meta: {
338
+ required: !isNullableOrUndefined(nestedProp.type),
339
+ nullableOrUndefined: isNullableOrUndefined(nestedProp.type)
340
+ }
341
+ })
342
+ acc[nestedKey as NestedKeyOf<T>] = nestedMeta as FieldMeta
343
+ }
344
+ } else {
345
+ // Array with primitive elements - create meta for the array itself
346
+ acc[propKey as NestedKeyOf<T>] = {
347
+ type: "multiple",
348
+ members: prop.type.elements,
349
+ rest: prop.type.rest,
350
+ required: !isNullableOrUndefined(prop.type),
351
+ nullableOrUndefined: isNullableOrUndefined(prop.type)
352
+ } as FieldMeta
353
+ }
354
+ } else {
355
+ const fieldMeta = createMeta<T>({
356
+ parent: propKey,
357
+ property: prop.type,
358
+ meta: {
359
+ required: !isNullableOrUndefined(prop.type),
360
+ nullableOrUndefined: isNullableOrUndefined(prop.type)
361
+ }
362
+ })
363
+ acc[propKey as NestedKeyOf<T>] = fieldMeta as FieldMeta
364
+ }
365
+ }
366
+ }
367
+ } else {
368
+ // For arrays with primitive elements, create the array meta
369
+ acc[key as NestedKeyOf<T>] = {
370
+ type: "multiple",
371
+ members: p.type.elements,
372
+ rest: p.type.rest,
373
+ required: isRequired,
374
+ nullableOrUndefined
375
+ } as FieldMeta
376
+ }
377
+ } else {
378
+ const newMeta = createMeta<T>({
379
+ parent: key,
380
+ property: p.type,
381
+ meta: { required: isRequired, nullableOrUndefined },
382
+ })
383
+ acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
384
+ }
317
385
  }
318
386
  }
319
387
  return acc