@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
|
|
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__ */
|
|
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(
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
20
|
-
}),
|
|
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
|
-
),
|
|
24
|
-
const
|
|
25
|
-
return
|
|
26
|
-
}),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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:
|
|
41
|
-
...
|
|
34
|
+
onChange: C.value,
|
|
35
|
+
...r.validators
|
|
42
36
|
}
|
|
43
37
|
}, {
|
|
44
|
-
default:
|
|
45
|
-
|
|
46
|
-
field:
|
|
47
|
-
state:
|
|
48
|
-
register:
|
|
49
|
-
label:
|
|
50
|
-
meta:
|
|
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:
|
|
53
|
-
|
|
46
|
+
default: s((n) => [
|
|
47
|
+
u(t.$slots, "default", f(c(n)))
|
|
54
48
|
]),
|
|
55
49
|
_: 2
|
|
56
50
|
}, [
|
|
57
|
-
|
|
51
|
+
t.$slots.label ? {
|
|
58
52
|
name: "label",
|
|
59
|
-
fn:
|
|
60
|
-
|
|
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"])) :
|
|
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
|
|
2
|
-
const
|
|
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 &&
|
|
14
|
-
const l = {
|
|
15
|
-
...a.form.
|
|
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 ?
|
|
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
|
-
|
|
27
|
+
$ as default
|
|
27
28
|
};
|
package/package.json
CHANGED
|
@@ -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
|
-
//
|
|
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
|
}
|