@effect-app/vue-components 2.11.2 → 2.11.3

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,5 +1,5 @@
1
- import { defineComponent as l, watch as r, renderSlot as o, createCommentVNode as m, normalizeProps as u, mergeProps as f } from "vue";
2
- const c = /* @__PURE__ */ l({
1
+ import { defineComponent as s, watch as m, nextTick as i, renderSlot as o, createCommentVNode as r, normalizeProps as f, mergeProps as u } from "vue";
2
+ const g = /* @__PURE__ */ s({
3
3
  __name: "OmegaTaggedUnionInternal",
4
4
  props: {
5
5
  state: {},
@@ -7,21 +7,21 @@ const c = /* @__PURE__ */ l({
7
7
  name: {},
8
8
  form: {}
9
9
  },
10
- setup(t) {
11
- const a = t;
12
- return a.form.useStore(({ values: e }) => e), r(() => a.state, (e, n) => {
13
- if (e === null && a.field.setValue(null), e !== n && e) {
14
- const s = {
15
- ...a.form.unionDefaultValues?.[e] ?? {},
16
- _tag: e
10
+ setup(e) {
11
+ const a = e;
12
+ return m(() => a.state, (t, n) => {
13
+ t === null && a.field.setValue(null), t !== n && t && i(() => {
14
+ const l = {
15
+ ...a.form.unionDefaultValues?.[t] ?? {},
16
+ _tag: t
17
17
  };
18
- a.form.reset(s), setTimeout(() => {
18
+ a.form.reset(l), setTimeout(() => {
19
19
  a.field.validate("change");
20
20
  }, 0);
21
- }
22
- }, { immediate: !0 }), (e, n) => t.state ? o(e.$slots, `${t.name ? `${t.name}.` : ""}${t.state}`, u(f({ key: 0 }, { field: t.field, state: t.state }))) : m("", !0);
21
+ });
22
+ }, { immediate: !0 }), (t, n) => e.state ? o(t.$slots, `${e.name ? `${e.name}.` : ""}${e.state}`, f(u({ key: 0 }, { field: e.field, state: e.state }))) : r("", !0);
23
23
  }
24
24
  });
25
25
  export {
26
- c as default
26
+ g as default
27
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "2.11.2",
3
+ "version": "2.11.3",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "effect": "^3.19.3",
@@ -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": "3.15.1",
57
- "@effect-app/vue": "2.93.6"
56
+ "@effect-app/vue": "2.93.6",
57
+ "effect-app": "3.15.1"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "pnpm build:run",
@@ -12,7 +12,7 @@
12
12
  generic="From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Name extends DeepKeys<From>"
13
13
  >
14
14
  import { type DeepKeys, type DeepValue } from "@tanstack/vue-form"
15
- import { watch } from "vue"
15
+ import { nextTick, watch } from "vue"
16
16
  import { type OmegaFieldInternalApi } from "./InputProps"
17
17
  import { type useOmegaForm } from "./useOmegaForm"
18
18
 
@@ -23,8 +23,6 @@ const props = defineProps<{
23
23
  form: ReturnType<typeof useOmegaForm<From, To>>
24
24
  }>()
25
25
 
26
- const values = props.form.useStore(({ values }) => values)
27
-
28
26
  // Watch for _tag changes
29
27
  watch(() => props.state, (newTag, oldTag) => {
30
28
  if (newTag === null) {
@@ -32,18 +30,20 @@ watch(() => props.state, (newTag, oldTag) => {
32
30
  }
33
31
 
34
32
  if (newTag !== oldTag && newTag) {
35
- // Get default values for the new tag to ensure correct types
36
- const tagDefaults = (props.form as any).unionDefaultValues?.[newTag as string] ?? {}
37
- // Merge: keep _tag from current values, but use tag defaults for other fields
38
- const resetValues = {
39
- ...tagDefaults,
40
- _tag: newTag
41
- }
42
- props.form.reset(resetValues as any)
43
- setTimeout(() => {
44
- props.field.validate("change")
45
- }, 0)
33
+ // Use nextTick to avoid cleanup conflicts during reactive updates
34
+ nextTick(() => {
35
+ // Get default values for the new tag to ensure correct types
36
+ const tagDefaults = (props.form as any).unionDefaultValues?.[newTag as string] ?? {}
37
+ // Merge: keep _tag from current values, but use tag defaults for other fields
38
+ const resetValues = {
39
+ ...tagDefaults,
40
+ _tag: newTag
41
+ }
42
+ props.form.reset(resetValues as any)
43
+ setTimeout(() => {
44
+ props.field.validate("change")
45
+ }, 0)
46
+ })
46
47
  }
47
- return undefined
48
48
  }, { immediate: true })
49
49
  </script>