@effect-app/vue-components 2.7.2 → 2.7.4

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,17 +13,17 @@ declare const __VLS_export: <From extends Record<PropertyKey, any>, To extends R
13
13
  attrs: any;
14
14
  slots: {
15
15
  [x: string]: ((props: {
16
- field: import("./InputProps").OmegaFieldInternalApi<From, any>;
17
- state: NonNullable<import("@tanstack/vue-form").DeepValue<From, any>>;
16
+ field: import("./InputProps").OmegaFieldInternalApi<From, `${NonNullable<Name>}._tag` | "_tag">;
17
+ state: NonNullable<import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">>;
18
18
  }) => any) | undefined;
19
19
  [x: number]: ((props: {
20
- field: import("./InputProps").OmegaFieldInternalApi<From, any>;
21
- state: NonNullable<import("@tanstack/vue-form").DeepValue<From, any>>;
20
+ field: import("./InputProps").OmegaFieldInternalApi<From, `${NonNullable<Name>}._tag` | "_tag">;
21
+ state: NonNullable<import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">>;
22
22
  }) => any) | undefined;
23
23
  } & {
24
24
  OmegaCustomInput?: (props: {
25
- field: import("@tanstack/vue-form").FieldApi<From, any, import("@tanstack/vue-form").DeepValue<From, any>, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | 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").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, Record<string, any> | undefined>;
26
- state: import("@tanstack/vue-form").FieldState<From, any, import("@tanstack/vue-form").DeepValue<From, any>, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, any, import("@tanstack/vue-form").DeepValue<From, any>> | 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").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined>;
25
+ field: import("@tanstack/vue-form").FieldApi<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">, import("@tanstack/vue-form").FieldValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | 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").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, Record<string, any> | undefined>;
26
+ state: import("@tanstack/vue-form").FieldState<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">, import("@tanstack/vue-form").FieldValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, `${NonNullable<Name>}._tag` | "_tag", import("@tanstack/vue-form").DeepValue<From, `${NonNullable<Name>}._tag` | "_tag">> | 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").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined>;
27
27
  }) => any;
28
28
  } & {
29
29
  default?: (props: {}) => any;
@@ -1,10 +1,12 @@
1
1
  import { type DeepKeys, type DeepValue } from "@tanstack/vue-form";
2
2
  import { type OmegaFieldInternalApi } from "./InputProps";
3
+ import { type useOmegaForm } from "./useOmegaForm";
3
4
  declare const __VLS_export: <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Name extends DeepKeys<From>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
5
  props: __VLS_PrettifyLocal<{
5
6
  state: DeepValue<From, Name>;
6
7
  field: OmegaFieldInternalApi<From, Name>;
7
8
  name?: DeepKeys<From>;
9
+ form: ReturnType<typeof useOmegaForm<From, To>>;
8
10
  }> & import("vue").PublicProps;
9
11
  expose: (exposed: {}) => void;
10
12
  attrs: any;
@@ -1,5 +1,5 @@
1
1
  import { useForm as Y } from "@tanstack/vue-form";
2
- import { Data as C, S as v, Effect as S, Fiber as j, Option as V, Array as A } from "effect-app";
2
+ import { Data as C, S as v, Effect as S, Array as g, Fiber as j, Option as V } from "effect-app";
3
3
  import { runtimeFiberAsPromise as ee } from "./vue-components.es16.js";
4
4
  import { isObject as te } from "./vue-components.es17.js";
5
5
  import { computed as I, onUnmounted as J, onMounted as re, onBeforeUnmount as ne, watch as K, ref as se, h as Z } from "vue";
@@ -37,8 +37,8 @@ const k = (f) => {
37
37
  const u = d.type;
38
38
  let m = u;
39
39
  if (u._tag === "TypeLiteral" || u._tag === "Union" || u._tag === "Transformation") {
40
- const E = v.make(u);
41
- m = k(E).ast;
40
+ const A = v.make(u);
41
+ m = k(A).ast;
42
42
  }
43
43
  return {
44
44
  ...d,
@@ -67,8 +67,8 @@ const D = (f) => function(o) {
67
67
  }, me = (f) => function(o) {
68
68
  return {
69
69
  setup() {
70
- const { fieldMap: p, form: d } = f, u = d.useStore((y) => y.errors), m = d.useStore((y) => y.fieldMeta), E = d.useStore((y) => y.errorMap), b = I(() => {
71
- const y = A.filterMap(
70
+ const { fieldMap: p, form: d } = f, u = d.useStore((y) => y.errors), m = d.useStore((y) => y.fieldMeta), A = d.useStore((y) => y.errorMap), b = I(() => {
71
+ const y = g.filterMap(
72
72
  Object.entries(m.value),
73
73
  ([U, h]) => {
74
74
  const _ = h.errors ?? [];
@@ -82,12 +82,12 @@ const D = (f) => function(o) {
82
82
  }) : V.none();
83
83
  }
84
84
  ), F = [];
85
- if (E.value.onSubmit) {
86
- for (const [U, h] of Object.entries(E.value.onSubmit))
87
- if (A.isArray(h) && h.length)
85
+ if (A.value.onSubmit) {
86
+ for (const [U, h] of Object.entries(A.value.onSubmit))
87
+ if (g.isArray(h) && h.length)
88
88
  for (const _ of h) {
89
89
  const i = _;
90
- if (i?.path && A.isArray(i.path) && i.path.length) {
90
+ if (i?.path && g.isArray(i.path) && i.path.length) {
91
91
  const M = i.path.join(".");
92
92
  if (!p.value.has(M)) {
93
93
  F.push({
@@ -122,7 +122,7 @@ const D = (f) => function(o) {
122
122
  return o.persistency.id;
123
123
  const e = window.location.pathname, t = Object.keys(u);
124
124
  return `${e}-${t.join("-")}`;
125
- }), E = () => {
125
+ }), A = () => {
126
126
  const e = new URLSearchParams(window.location.search);
127
127
  e.delete(m.value);
128
128
  const t = new URL(window.location.href);
@@ -130,13 +130,13 @@ const D = (f) => function(o) {
130
130
  };
131
131
  function b(e, t) {
132
132
  for (const r in t)
133
- t[r] && te(t[r]) ? (e[r] || (e[r] = {}), b(e[r], t[r])) : e[r] = t[r];
133
+ g.isArray(t[r]) ? e[r] = t[r] : t[r] && te(t[r]) ? (e[r] || (e[r] = {}), b(e[r], t[r])) : e[r] = t[r];
134
134
  return e;
135
135
  }
136
136
  const y = (e) => {
137
137
  if (!e) return;
138
- const t = { ...e }, r = (s, a) => a.split(".").reduce((l, g) => l?.[g], s), n = (s, a, l) => {
139
- const g = a.split("."), N = g.pop(), X = g.reduce((L, O) => (L[O] || (L[O] = {}), L[O]), s);
138
+ const t = { ...e }, r = (s, a) => a.split(".").reduce((l, E) => l?.[E], s), n = (s, a, l) => {
139
+ const E = a.split("."), N = E.pop(), X = E.reduce((L, O) => (L[O] || (L[O] = {}), L[O]), s);
140
140
  X[N] = l;
141
141
  };
142
142
  for (const s in u) {
@@ -152,11 +152,11 @@ const D = (f) => function(o) {
152
152
  } catch {
153
153
  }
154
154
  const r = e?.members || (e?.ast?._tag === "Union" && e.ast.types ? e.ast.types.map((n) => v.make(n)) : null);
155
- if (r && A.isArray(r)) {
155
+ if (r && g.isArray(r)) {
156
156
  for (const n of r) {
157
157
  const s = F(n);
158
158
  if (Object.keys(s).length > 0 && n?.fields && Object.entries(n.fields).some(
159
- ([l, g]) => l === "_tag" || l === "type" || l === "kind" ? g?.ast?.defaultValue !== void 0 : !1
159
+ ([l, E]) => l === "_tag" || l === "type" || l === "kind" ? E?.ast?.defaultValue !== void 0 : !1
160
160
  ))
161
161
  return s;
162
162
  }
@@ -210,7 +210,7 @@ const D = (f) => function(o) {
210
210
  if (t?.policies && t.policies.includes("querystring"))
211
211
  try {
212
212
  const n = new URLSearchParams(window.location.search).get(m.value);
213
- E(), n && (e = b(e || {}, JSON.parse(n)));
213
+ A(), n && (e = b(e || {}, JSON.parse(n)));
214
214
  } catch (r) {
215
215
  console.error(r);
216
216
  }
@@ -250,9 +250,9 @@ const D = (f) => function(o) {
250
250
  return n.reduce((s, a, l) => (l === n.length - 1 ? s[a] = i.getFieldValue(r) : s[a] = s[a] ?? {}, s[a]), t), t;
251
251
  }, {}), R = (e) => {
252
252
  if (e) {
253
- if (A.isArray(e.keys))
253
+ if (g.isArray(e.keys))
254
254
  return $(e.keys);
255
- if (A.isArray(e.banKeys)) {
255
+ if (g.isArray(e.banKeys)) {
256
256
  const t = Object.keys(u).filter((r) => e.banKeys?.includes(r));
257
257
  return $(t);
258
258
  }
@@ -1,4 +1,4 @@
1
- import { defineComponent as d, createBlock as u, openBlock as g, unref as l, withCtx as o, renderSlot as n, createVNode as r, createCommentVNode as c, normalizeProps as s, guardReactiveProps as f, createSlots as $, renderList as y } from "vue";
1
+ import { defineComponent as d, createBlock as u, openBlock as g, unref as l, withCtx as o, renderSlot as n, createVNode as f, createCommentVNode as c, normalizeProps as r, guardReactiveProps as s, createSlots as $, renderList as y } from "vue";
2
2
  import C from "./vue-components.es9.js";
3
3
  const h = /* @__PURE__ */ d({
4
4
  __name: "OmegaTaggedUnion",
@@ -14,8 +14,8 @@ const h = /* @__PURE__ */ d({
14
14
  name: e.name ? `${e.name}._tag` : "_tag"
15
15
  }, {
16
16
  default: o((t) => [
17
- n(a.$slots, "OmegaCustomInput", s(f(t)), () => [
18
- r(l(e.form).Input, {
17
+ n(a.$slots, "OmegaCustomInput", r(s(t)), () => [
18
+ f(l(e.form).Input, {
19
19
  name: e.name ? `${e.name}._tag` : "_tag",
20
20
  label: e.label,
21
21
  type: e.type ?? "select",
@@ -23,18 +23,19 @@ const h = /* @__PURE__ */ d({
23
23
  }, null, 8, ["name", "label", "type", "options"])
24
24
  ]),
25
25
  n(a.$slots, "default"),
26
- r(C, {
26
+ f(C, {
27
27
  field: t.field,
28
28
  state: t.state.value,
29
- name: e.name
29
+ name: e.name,
30
+ form: e.form
30
31
  }, $({ _: 2 }, [
31
32
  y(a.$slots, (k, m) => ({
32
33
  name: m,
33
34
  fn: o((i) => [
34
- n(a.$slots, m, s(f(i)))
35
+ n(a.$slots, m, r(s(i)))
35
36
  ])
36
37
  }))
37
- ]), 1032, ["field", "state", "name"]),
38
+ ]), 1032, ["field", "state", "name", "form"]),
38
39
  t.state.value ? n(a.$slots, "OmegaCommon", { key: 0 }) : c("", !0)
39
40
  ]),
40
41
  _: 3
@@ -1,20 +1,21 @@
1
- import { defineComponent as l, watch as i, renderSlot as m, createCommentVNode as s, normalizeProps as o, mergeProps as r } from "vue";
2
- const f = /* @__PURE__ */ l({
1
+ import { defineComponent as s, watch as m, renderSlot as o, createCommentVNode as r, normalizeProps as f, mergeProps as i } from "vue";
2
+ const d = /* @__PURE__ */ s({
3
3
  __name: "OmegaTaggedUnionInternal",
4
4
  props: {
5
5
  state: {},
6
6
  field: {},
7
- name: {}
7
+ name: {},
8
+ form: {}
8
9
  },
9
10
  setup(e) {
10
- const a = e;
11
- return i(() => a.state, (t, n) => {
12
- t === null && a.field.setValue(null), t !== n && setTimeout(() => {
11
+ const a = e, l = a.form.useStore(({ values: t }) => t);
12
+ return m(() => a.state, (t, n) => {
13
+ t === null && a.field.setValue(null), t !== n && (a.form.reset(l.value), setTimeout(() => {
13
14
  a.field.validate("change");
14
- }, 0);
15
- }), (t, n) => e.state ? m(t.$slots, `${e.name ? `${e.name}.` : ""}${e.state}`, o(r({ key: 0 }, { field: e.field, state: e.state }))) : s("", !0);
15
+ }, 0));
16
+ }), (t, n) => e.state ? o(t.$slots, `${e.name ? `${e.name}.` : ""}${e.state}`, f(i({ key: 0 }, { field: e.field, state: e.state }))) : r("", !0);
16
17
  }
17
18
  });
18
19
  export {
19
- f as default
20
+ d as default
20
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "2.7.2",
3
+ "version": "2.7.4",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "effect": "^3.18.0",
@@ -53,8 +53,8 @@
53
53
  "highlight.js": "^11.11.1",
54
54
  "mitt": "^3.0.1",
55
55
  "vue3-highlightjs": "^1.0.5",
56
- "@effect-app/vue": "2.92.2",
57
- "effect-app": "3.12.0"
56
+ "effect-app": "3.12.0",
57
+ "@effect-app/vue": "2.92.2"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "pnpm build:run",
@@ -23,7 +23,7 @@ defineProps<{
23
23
  </script>
24
24
 
25
25
  <template>
26
- <form.Field :name="(name ? `${name}._tag` : '_tag') as any">
26
+ <form.Field :name="name ? `${name}._tag` : '_tag'">
27
27
  <template #default="inputProps">
28
28
  <slot
29
29
  name="OmegaCustomInput"
@@ -41,6 +41,7 @@ defineProps<{
41
41
  :field="inputProps.field as any"
42
42
  :state="inputProps.state.value"
43
43
  :name="name"
44
+ :form="form"
44
45
  >
45
46
  <template
46
47
  v-for="(_, slotname) in $slots"
@@ -18,19 +18,24 @@
18
18
  import { type DeepKeys, type DeepValue } from "@tanstack/vue-form"
19
19
  import { watch } from "vue"
20
20
  import { type OmegaFieldInternalApi } from "./InputProps"
21
+ import { type useOmegaForm } from "./useOmegaForm"
21
22
 
22
23
  const props = defineProps<{
23
24
  state: DeepValue<From, Name>
24
25
  field: OmegaFieldInternalApi<From, Name>
25
26
  name?: DeepKeys<From>
27
+ form: ReturnType<typeof useOmegaForm<From, To>>
26
28
  }>()
27
29
 
30
+ const values = props.form.useStore(({ values }) => values)
31
+
28
32
  // Watch for _tag changes
29
33
  watch(() => props.state, (newTag, oldTag) => {
30
34
  if (newTag === null) {
31
35
  props.field.setValue(null as DeepValue<From, Name>)
32
36
  }
33
37
  if (newTag !== oldTag) {
38
+ props.form.reset(values.value)
34
39
  setTimeout(() => {
35
40
  props.field.validate("change")
36
41
  }, 0)
@@ -743,7 +743,10 @@ export const useOmegaForm = <
743
743
 
744
744
  function deepMerge(target: any, source: any) {
745
745
  for (const key in source) {
746
- if (source[key] && isObject(source[key])) {
746
+ if (Array.isArray(source[key])) {
747
+ // Arrays should be copied directly, not deep merged
748
+ target[key] = source[key]
749
+ } else if (source[key] && isObject(source[key])) {
747
750
  if (!target[key]) {
748
751
  target[key] = {}
749
752
  }