@effect-app/vue-components 2.11.3 → 2.11.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,9 +1,9 @@
1
- import { defineComponent as F, computed as o, useAttrs as M, inject as A, createBlock as u, openBlock as i, resolveDynamicComponent as S, withCtx as m, createCommentVNode as w, mergeProps as I, unref as L, createSlots as P, renderSlot as f, normalizeProps as c, guardReactiveProps as d } from "vue";
1
+ import { defineComponent as M, computed as o, useAttrs as $, inject as k, createBlock as m, openBlock as i, resolveDynamicComponent as A, withCtx as s, createCommentVNode as S, mergeProps as w, unref as I, createSlots as P, renderSlot as u, normalizeProps as f, guardReactiveProps as c } from "vue";
2
2
  import { useIntl as j } from "./vue-components.es3.js";
3
3
  import { generateInputStandardSchemaFromFieldMeta as B } from "./vue-components.es12.js";
4
4
  import E from "./vue-components.es7.js";
5
5
  import { useErrorLabel as N } from "./vue-components.es10.js";
6
- const V = /* @__PURE__ */ F({
6
+ const V = /* @__PURE__ */ M({
7
7
  inheritAttrs: !1,
8
8
  __name: "OmegaInput",
9
9
  props: {
@@ -13,55 +13,49 @@ const V = /* @__PURE__ */ F({
13
13
  name: {},
14
14
  inputClass: {}
15
15
  },
16
- setup(a) {
17
- const t = a, l = o(() => t.name), v = M(), p = o(() => {
18
- if (t.inputClass !== null)
19
- return t.inputClass !== void 0 ? t.inputClass : v.class;
20
- }), g = A(
16
+ setup(r) {
17
+ const e = r, l = o(() => e.name), d = $(), p = o(() => {
18
+ if (e.inputClass !== null)
19
+ return e.inputClass !== void 0 ? e.inputClass : d.class;
20
+ }), v = k(
21
21
  "getMetaFromArray",
22
22
  null
23
- ), n = o(() => {
24
- const e = g?.value?.(t.name);
25
- return e || t.form.meta[l.value];
26
- }), $ = o(() => {
27
- const e = n.value;
28
- if (!e) return l.value;
29
- const r = e;
30
- return `${l.value}-${r.type}-${r.minLength ?? ""}-${r.maxLength ?? ""}-${r.minimum ?? ""}-${r.maximum ?? ""}`;
31
- }), { trans: C } = j(), y = o(() => {
32
- if (!n.value)
33
- throw console.log(t.name, Object.keys(t.form.meta), t.form.meta), new Error("Meta is undefined");
34
- return B(n.value, C);
35
- }), b = N(t.form);
36
- return (e, r) => (i(), u(S(a.form.Field), {
37
- key: $.value,
38
- name: a.name,
23
+ ), a = o(() => {
24
+ const t = v?.value?.(e.name);
25
+ return t || e.form.meta[l.value];
26
+ }), { trans: g } = j(), C = o(() => {
27
+ if (!a.value)
28
+ throw console.log(e.name, Object.keys(e.form.meta), e.form.meta), new Error("Meta is undefined");
29
+ return B(a.value, g);
30
+ }), b = N(e.form);
31
+ return (t, h) => (i(), m(A(r.form.Field), {
32
+ name: r.name,
39
33
  validators: {
40
- onChange: y.value,
41
- ...a.validators
34
+ onChange: C.value,
35
+ ...r.validators
42
36
  }
43
37
  }, {
44
- default: m(({ field: h, state: k }) => [
45
- n.value ? (i(), u(E, I({ key: 0 }, { ...e.$attrs, ...e.$props, inputClass: p.value }, {
46
- field: h,
47
- state: k,
48
- register: a.form.registerField,
49
- label: a.label ?? L(b)(l.value),
50
- meta: n.value
38
+ default: s(({ field: y, state: F }) => [
39
+ a.value ? (i(), m(E, w({ key: 0 }, { ...t.$attrs, ...t.$props, inputClass: p.value }, {
40
+ field: y,
41
+ state: F,
42
+ register: r.form.registerField,
43
+ label: r.label ?? I(b)(l.value),
44
+ meta: a.value
51
45
  }), P({
52
- default: m((s) => [
53
- f(e.$slots, "default", c(d(s)))
46
+ default: s((n) => [
47
+ u(t.$slots, "default", f(c(n)))
54
48
  ]),
55
49
  _: 2
56
50
  }, [
57
- e.$slots.label ? {
51
+ t.$slots.label ? {
58
52
  name: "label",
59
- fn: m((s) => [
60
- f(e.$slots, "label", c(d(s)))
53
+ fn: s((n) => [
54
+ u(t.$slots, "label", f(c(n)))
61
55
  ]),
62
56
  key: "0"
63
57
  } : void 0
64
- ]), 1040, ["field", "state", "register", "label", "meta"])) : w("", !0)
58
+ ]), 1040, ["field", "state", "register", "label", "meta"])) : S("", !0)
65
59
  ]),
66
60
  _: 3
67
61
  }, 8, ["name", "validators"]));
@@ -1,5 +1,5 @@
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({
1
+ import { defineComponent as r, watch as m, nextTick as o, renderSlot as u, createCommentVNode as i, normalizeProps as f, mergeProps as c } from "vue";
2
+ const $ = /* @__PURE__ */ r({
3
3
  __name: "OmegaTaggedUnionInternal",
4
4
  props: {
5
5
  state: {},
@@ -10,18 +10,19 @@ const g = /* @__PURE__ */ s({
10
10
  setup(e) {
11
11
  const a = e;
12
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] ?? {},
13
+ t === null && a.field.setValue(null), t !== n && t && o(() => {
14
+ const s = a.form.unionDefaultValues?.[t] ?? {}, l = {
15
+ ...a.form.state.values,
16
+ ...s,
16
17
  _tag: t
17
18
  };
18
19
  a.form.reset(l), setTimeout(() => {
19
20
  a.field.validate("change");
20
21
  }, 0);
21
22
  });
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
+ }, { immediate: !0 }), (t, n) => e.state ? u(t.$slots, `${e.name ? `${e.name}.` : ""}${e.state}`, f(c({ key: 0 }, { field: e.field, state: e.state }))) : i("", !0);
23
24
  }
24
25
  });
25
26
  export {
26
- g as default
27
+ $ as default
27
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "2.11.3",
3
+ "version": "2.11.5",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "effect": "^3.19.3",
@@ -1,7 +1,6 @@
1
1
  <template>
2
2
  <component
3
3
  :is="form.Field"
4
- :key="fieldKey"
5
4
  :name="name"
6
5
  :validators="{
7
6
  onChange: schema,
@@ -84,18 +83,6 @@ const meta = computed(() => {
84
83
  return formMeta
85
84
  })
86
85
 
87
- // Key to force Field re-mount when meta type changes (for TaggedUnion support)
88
- const fieldKey = computed(() => {
89
- const m = meta.value
90
- if (!m) return propsName.value
91
- // Include type and key constraints in the key so Field re-mounts when validation rules change
92
- // Cast to any since not all FieldMeta variants have these properties
93
- const fm = m as any
94
- return `${propsName.value}-${fm.type}-${fm.minLength ?? ""}-${fm.maxLength ?? ""}-${fm.minimum ?? ""}-${
95
- fm.maximum ?? ""
96
- }`
97
- })
98
-
99
86
  // Call useIntl during setup to avoid issues when computed re-evaluates
100
87
  const { trans } = useIntl()
101
88
 
@@ -34,8 +34,11 @@ watch(() => props.state, (newTag, oldTag) => {
34
34
  nextTick(() => {
35
35
  // Get default values for the new tag to ensure correct types
36
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
37
+ // Get current form values to preserve user's selections (e.g., carrier)
38
+ const currentValues = props.form.state.values
39
+ // Merge: keep current values, override with tag defaults for type correctness, set new _tag
38
40
  const resetValues = {
41
+ ...currentValues,
39
42
  ...tagDefaults,
40
43
  _tag: newTag
41
44
  }