@effect-app/vue-components 0.14.5 → 0.14.6

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
1
  import { S as n, Option as f, pipe as O } from "effect-app";
2
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 = {}) => {
3
+ const M = n.NonEmptyArray(n.String), L = (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: o }, l = {}) => {
4
4
  if (t && t._tag === "Transformation")
5
5
  return m({
6
6
  parent: i,
@@ -14,85 +14,86 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
14
14
  });
15
15
  if (o) {
16
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;
17
+ const u = i ? `${i}.${r.name.toString()}` : r.name.toString(), a = g(r.type), p = !a, b = 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 y = 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 (y.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(
25
+ if (!a) {
26
+ const s = m({
27
+ parent: u,
28
+ property: r.type,
29
+ meta: { required: p, nullableOrUndefined: a }
30
+ });
31
+ l[u] = s;
32
+ }
33
+ for (const s of y)
34
+ "propertySignatures" in s && Object.assign(
33
35
  l,
34
36
  m({
35
37
  parent: u,
36
- propertySignatures: g.propertySignatures,
37
- meta: { required: p, nullableOrUndefined: s }
38
+ propertySignatures: s.propertySignatures,
39
+ meta: { required: p, nullableOrUndefined: a }
38
40
  })
39
41
  );
40
42
  } else {
41
- const a = m({
43
+ const s = m({
42
44
  parent: u,
43
45
  property: r.type,
44
- meta: { required: p, nullableOrUndefined: s }
46
+ meta: { required: p, nullableOrUndefined: a }
45
47
  });
46
- l[u] = a;
48
+ l[u] = s;
47
49
  }
48
- }
49
- if ("propertySignatures" in b)
50
+ } else if ("propertySignatures" in b)
50
51
  Object.assign(
51
52
  l,
52
53
  m({
53
54
  parent: u,
54
55
  propertySignatures: b.propertySignatures,
55
- meta: { required: p, nullableOrUndefined: s }
56
+ meta: { required: p, nullableOrUndefined: a }
56
57
  })
57
58
  );
58
59
  else if (n.AST.isTupleType(r.type))
59
60
  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({
61
+ const c = r.type.rest[0].type;
62
+ if (c._tag === "TypeLiteral" && "propertySignatures" in c)
63
+ for (const s of c.propertySignatures) {
64
+ const S = `${u}.${s.name.toString()}`;
65
+ if (n.AST.isTupleType(s.type) && s.type.rest.length > 0) {
66
+ const d = s.type.rest[0].type;
67
+ if (d._tag === "TypeLiteral" && "propertySignatures" in d)
68
+ for (const T of d.propertySignatures) {
69
+ const h = `${S}.${T.name.toString()}`, x = m({
69
70
  parent: h,
70
71
  property: T.type,
71
72
  meta: {
72
- required: !y(T.type),
73
- nullableOrUndefined: y(T.type)
73
+ required: !g(T.type),
74
+ nullableOrUndefined: g(T.type)
74
75
  }
75
76
  });
76
77
  l[h] = x;
77
78
  }
78
79
  else
79
- l[g] = {
80
+ l[S] = {
80
81
  type: "multiple",
81
- members: a.type.elements,
82
- rest: a.type.rest,
83
- required: !y(a.type),
84
- nullableOrUndefined: y(a.type)
82
+ members: s.type.elements,
83
+ rest: s.type.rest,
84
+ required: !g(s.type),
85
+ nullableOrUndefined: g(s.type)
85
86
  };
86
87
  } else {
87
- const c = m({
88
- parent: g,
89
- property: a.type,
88
+ const d = m({
89
+ parent: S,
90
+ property: s.type,
90
91
  meta: {
91
- required: !y(a.type),
92
- nullableOrUndefined: y(a.type)
92
+ required: !g(s.type),
93
+ nullableOrUndefined: g(s.type)
93
94
  }
94
95
  });
95
- l[g] = c;
96
+ l[S] = d;
96
97
  }
97
98
  }
98
99
  } else
@@ -101,15 +102,15 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
101
102
  members: r.type.elements,
102
103
  rest: r.type.rest,
103
104
  required: p,
104
- nullableOrUndefined: s
105
+ nullableOrUndefined: a
105
106
  };
106
107
  else {
107
- const d = m({
108
+ const y = m({
108
109
  parent: u,
109
110
  property: r.type,
110
- meta: { required: p, nullableOrUndefined: s }
111
+ meta: { required: p, nullableOrUndefined: a }
111
112
  });
112
- l[u] = d;
113
+ l[u] = y;
113
114
  }
114
115
  }
115
116
  return l;
@@ -117,11 +118,11 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
117
118
  if (t) {
118
119
  const r = L(t);
119
120
  if (Object.hasOwnProperty.call(e, "required") || (e.required = !r), n.AST.isUnion(t)) {
120
- const s = t.types.find(
121
+ const a = t.types.find(
121
122
  (p) => p._tag !== "UndefinedKeyword" && p !== n.Null.ast
122
123
  );
123
- return "propertySignatures" in s ? m({
124
- propertySignatures: s.propertySignatures,
124
+ return "propertySignatures" in a ? m({
125
+ propertySignatures: a.propertySignatures,
125
126
  parent: i,
126
127
  meta: e
127
128
  }) : t.types.every(n.AST.isLiteral) ? {
@@ -133,7 +134,7 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
133
134
  ...m({
134
135
  parent: i,
135
136
  meta: e,
136
- property: s
137
+ property: a
137
138
  })
138
139
  };
139
140
  }
@@ -171,9 +172,9 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
171
172
  if (Object.values(o).every((r) => r && "type" in r))
172
173
  return o;
173
174
  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);
175
+ for (const a in r) {
176
+ const p = u ? `${u}.${a}` : a;
177
+ r[a] && typeof r[a] == "object" && "type" in r[a] ? t[p] = r[a] : r[a] && typeof r[a] == "object" && l(r[a], p);
177
178
  }
178
179
  };
179
180
  l(o);
@@ -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.14.6",
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) {
@@ -298,8 +300,7 @@ export const createMeta = <T = any>(
298
300
  })
299
301
  acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
300
302
  }
301
- }
302
- if ("propertySignatures" in typeToProcess) {
303
+ } else if ("propertySignatures" in typeToProcess) {
303
304
  Object.assign(
304
305
  acc,
305
306
  createMeta<T>({
@@ -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)