@effect-app/vue-components 3.0.0 → 3.0.2
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.
- package/dist/vue-components.es10.js +26 -22
- package/dist/vue-components.es11.js +2 -2
- package/dist/vue-components.es12.js +1 -1
- package/dist/vue-components.es16.js +11 -4
- package/dist/vue-components.es17.js +4 -10
- package/dist/vue-components.es18.js +10 -55
- package/dist/vue-components.es19.js +50 -63
- package/dist/vue-components.es20.js +68 -6
- package/dist/vue-components.es21.js +5 -5
- package/dist/vue-components.es22.js +6 -3
- package/dist/vue-components.es23.js +3 -3
- package/dist/vue-components.es24.js +3 -2
- package/dist/vue-components.es25.js +1 -1
- package/dist/vue-components.es26.js +1 -1
- package/dist/vue-components.es27.js +1 -1
- package/dist/vue-components.es28.js +2 -17
- package/dist/vue-components.es29.js +16 -10
- package/dist/vue-components.es31.js +1 -1
- package/dist/vue-components.es32.js +1 -1
- package/dist/vue-components.es5.js +1 -1
- package/dist/vue-components.es6.js +31 -37
- package/dist/vue-components.es7.js +27 -25
- package/package.json +3 -3
- package/src/components/OmegaForm/OmegaInput.vue +0 -13
- package/src/components/OmegaForm/OmegaInternalInput.vue +10 -2
- package/src/components/OmegaForm/useOmegaForm.ts +12 -2
- package/src/components/OmegaForm/useRegisterField.ts +3 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { useForm as K } from "@tanstack/vue-form";
|
|
2
|
-
import { Data as T, S as W, Effect as d, Fiber as $, Option as
|
|
3
|
-
import { runtimeFiberAsPromise as z } from "./vue-components.
|
|
2
|
+
import { Data as T, S as W, Effect as d, Fiber as $, Option as j, Array as F } from "effect-app";
|
|
3
|
+
import { runtimeFiberAsPromise as z } from "./vue-components.es18.js";
|
|
4
4
|
import { computed as x, onUnmounted as D, onMounted as G, onBeforeUnmount as Z, watch as R, ref as Q, h as J } from "vue";
|
|
5
5
|
import { useIntl as X } from "./vue-components.es3.js";
|
|
6
|
-
import Y from "./vue-components.
|
|
7
|
-
import C from "./vue-components.
|
|
8
|
-
import ee from "./vue-components.
|
|
6
|
+
import Y from "./vue-components.es19.js";
|
|
7
|
+
import C from "./vue-components.es20.js";
|
|
8
|
+
import ee from "./vue-components.es21.js";
|
|
9
9
|
import { generateMetaFromSchema as re, deepMerge as N, defaultsValueFromSchema as te } from "./vue-components.es12.js";
|
|
10
10
|
import se from "./vue-components.es6.js";
|
|
11
11
|
import ne from "./vue-components.es8.js";
|
|
12
|
-
import oe from "./vue-components.
|
|
13
|
-
import { trace as H } from "./vue-components.
|
|
14
|
-
import { context as U } from "./vue-components.
|
|
12
|
+
import oe from "./vue-components.es22.js";
|
|
13
|
+
import { trace as H } from "./vue-components.es23.js";
|
|
14
|
+
import { context as U } from "./vue-components.es24.js";
|
|
15
15
|
class ie extends T.TaggedError("FormErrors") {
|
|
16
16
|
}
|
|
17
17
|
const M = (i) => function(s) {
|
|
@@ -29,19 +29,19 @@ const M = (i) => function(s) {
|
|
|
29
29
|
}, ce = (i) => function(s) {
|
|
30
30
|
return {
|
|
31
31
|
setup() {
|
|
32
|
-
const { fieldMap: f, form: m } = i, a = m.useStore((v) => v.errors), g = m.useStore((v) => v.fieldMeta), p = m.useStore((v) => v.errorMap),
|
|
32
|
+
const { fieldMap: f, form: m } = i, a = m.useStore((v) => v.errors), g = m.useStore((v) => v.fieldMeta), p = m.useStore((v) => v.errorMap), A = ae(m), L = x(() => {
|
|
33
33
|
const v = F.filterMap(
|
|
34
34
|
Object.entries(g.value),
|
|
35
35
|
([O, h]) => {
|
|
36
36
|
const w = h.errors ?? [];
|
|
37
|
-
if (!w.length) return
|
|
37
|
+
if (!w.length) return j.none();
|
|
38
38
|
const u = f.value.get(O);
|
|
39
|
-
return u ?
|
|
39
|
+
return u ? j.some({
|
|
40
40
|
label: u.label,
|
|
41
41
|
inputId: u.id,
|
|
42
42
|
// Only show the first error
|
|
43
43
|
errors: [w[0]?.message].filter(Boolean)
|
|
44
|
-
}) :
|
|
44
|
+
}) : j.none();
|
|
45
45
|
}
|
|
46
46
|
), o = [];
|
|
47
47
|
if (p.value.onSubmit) {
|
|
@@ -53,7 +53,7 @@ const M = (i) => function(s) {
|
|
|
53
53
|
const E = u.path.join(".");
|
|
54
54
|
if (!f.value.has(E)) {
|
|
55
55
|
o.push({
|
|
56
|
-
label:
|
|
56
|
+
label: A(E),
|
|
57
57
|
inputId: E,
|
|
58
58
|
errors: [u.message].filter(Boolean)
|
|
59
59
|
});
|
|
@@ -66,7 +66,7 @@ const M = (i) => function(s) {
|
|
|
66
66
|
});
|
|
67
67
|
return {
|
|
68
68
|
generalErrors: a,
|
|
69
|
-
errors:
|
|
69
|
+
errors: L
|
|
70
70
|
};
|
|
71
71
|
},
|
|
72
72
|
render({ errors: f, generalErrors: m }) {
|
|
@@ -84,12 +84,12 @@ const M = (i) => function(s) {
|
|
|
84
84
|
return s.persistency.id;
|
|
85
85
|
const e = window.location.pathname, r = Object.keys(a);
|
|
86
86
|
return `${e}-${r.join("-")}`;
|
|
87
|
-
}),
|
|
87
|
+
}), A = () => {
|
|
88
88
|
const e = new URLSearchParams(window.location.search);
|
|
89
89
|
e.delete(p.value);
|
|
90
90
|
const r = new URL(window.location.href);
|
|
91
91
|
r.search = e.toString(), window.history.replaceState({}, "", r.toString());
|
|
92
|
-
},
|
|
92
|
+
}, L = x(() => {
|
|
93
93
|
let e;
|
|
94
94
|
const r = s?.persistency;
|
|
95
95
|
if (
|
|
@@ -110,7 +110,7 @@ const M = (i) => function(s) {
|
|
|
110
110
|
if (r?.policies && b(r.policies, "querystring"))
|
|
111
111
|
try {
|
|
112
112
|
const t = new URLSearchParams(window.location.search).get(p.value);
|
|
113
|
-
|
|
113
|
+
A(), t && (e = N(e || {}, JSON.parse(t)));
|
|
114
114
|
} catch (n) {
|
|
115
115
|
console.error(n);
|
|
116
116
|
}
|
|
@@ -145,7 +145,7 @@ const M = (i) => function(s) {
|
|
|
145
145
|
)
|
|
146
146
|
) : t;
|
|
147
147
|
}) : void 0,
|
|
148
|
-
defaultValues:
|
|
148
|
+
defaultValues: L.value
|
|
149
149
|
}), O = () => {
|
|
150
150
|
Object.keys(a).forEach((e) => {
|
|
151
151
|
o.setFieldValue(e, void 0);
|
|
@@ -195,13 +195,13 @@ const M = (i) => function(s) {
|
|
|
195
195
|
const I = (e) => d.currentSpan.pipe(
|
|
196
196
|
d.option,
|
|
197
197
|
d.flatMap(
|
|
198
|
-
(r) => d.promise(() => o.handleSubmit(
|
|
198
|
+
(r) => d.promise(() => o.handleSubmit(j.isSome(r) ? { currentSpan: r.value, ...e } : e))
|
|
199
199
|
)
|
|
200
200
|
), q = (e) => e?.checkErrors ? I(e?.meta).pipe(d.flatMap(d.fnUntraced(function* () {
|
|
201
201
|
const r = o.getAllErrors();
|
|
202
202
|
if (Object.keys(r.fields).length || r.form.errors.length)
|
|
203
203
|
return yield* new ie({ form: r.form, fields: r.fields });
|
|
204
|
-
}))) : I(e?.meta), B = o.handleSubmit,
|
|
204
|
+
}))) : I(e?.meta), B = o.handleSubmit, P = Q(/* @__PURE__ */ new Map()), y = Object.assign(o, {
|
|
205
205
|
i18nNamespace: s?.i18nNamespace,
|
|
206
206
|
ignorePreventCloseEvents: s?.ignorePreventCloseEvents,
|
|
207
207
|
meta: a,
|
|
@@ -214,9 +214,13 @@ const M = (i) => function(s) {
|
|
|
214
214
|
// /** @experimental */
|
|
215
215
|
handleSubmitEffect: q,
|
|
216
216
|
registerField: (e) => {
|
|
217
|
-
R(e, (r) =>
|
|
217
|
+
R(e, (r) => {
|
|
218
|
+
P.value.set(r.name, { label: r.label, id: r.id });
|
|
219
|
+
}, { immediate: !0 }), D(() => {
|
|
220
|
+
P.value.get(e.value.name)?.id === e.value.id && P.value.delete(e.value.name);
|
|
221
|
+
});
|
|
218
222
|
}
|
|
219
|
-
}), V = { form: y, fieldMap:
|
|
223
|
+
}), V = { form: y, fieldMap: P };
|
|
220
224
|
return Object.assign(y, {
|
|
221
225
|
// Type-level properties for performance optimization (not used at runtime)
|
|
222
226
|
_paths: void 0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import l from "./vue-components.
|
|
1
|
+
import l from "./vue-components.es29.js";
|
|
2
2
|
import { inject as c, provide as u } from "vue";
|
|
3
|
-
import { onMountedWithCleanup as f } from "./vue-components.
|
|
3
|
+
import { onMountedWithCleanup as f } from "./vue-components.es16.js";
|
|
4
4
|
const p = () => l(), i = Symbol("DialogBus"), r = () => c(i, null), g = () => {
|
|
5
5
|
const n = p();
|
|
6
6
|
return u(i, n), n;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { S as i, Option as q } from "effect-app";
|
|
2
2
|
import { getMetadataFromSchema as V } from "@effect-app/vue/form";
|
|
3
3
|
import { useIntl as E, getTransformationFrom as U } from "./vue-components.es3.js";
|
|
4
|
-
import { isObject as $ } from "./vue-components.
|
|
4
|
+
import { isObject as $ } from "./vue-components.es17.js";
|
|
5
5
|
const j = (e) => i.AST.isUnion(e) && e.types.find((n) => n._tag === "UndefinedKeyword" || n === i.Null.ast), g = (e) => !e || !i.AST.isUnion(e) ? !1 : e.types.find((n) => n._tag === "UndefinedKeyword") ? "undefined" : e.types.find((n) => n === i.Null.ast) ? "null" : !1, _ = (e) => {
|
|
6
6
|
const n = [];
|
|
7
7
|
for (const t of e)
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import "vue";
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { onMounted as e, onUnmounted as u } from "vue";
|
|
2
|
+
function p(t) {
|
|
3
|
+
let n;
|
|
4
|
+
e(() => {
|
|
5
|
+
const o = t();
|
|
6
|
+
o && (n = o);
|
|
7
|
+
}), u(() => {
|
|
8
|
+
n && n();
|
|
9
|
+
});
|
|
10
|
+
}
|
|
4
11
|
export {
|
|
5
|
-
|
|
12
|
+
p as onMountedWithCleanup
|
|
6
13
|
};
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
n(2, (e, t) => a(e, { ...e, ...m(t) ? t(e) : t }));
|
|
5
|
-
const p = (e, t) => new Promise((o, s) => e.addObserver((r) => {
|
|
6
|
-
c.isSuccess(r) ? o(r.value) : s(u.makeFiberFailure(r.cause));
|
|
7
|
-
}));
|
|
1
|
+
import "vue";
|
|
2
|
+
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
3
|
+
const t = Object.prototype.toString, c = (o) => t.call(o) === "[object Object]";
|
|
8
4
|
export {
|
|
9
|
-
|
|
10
|
-
i as cloneTrait,
|
|
11
|
-
p as runtimeFiberAsPromise
|
|
5
|
+
c as isObject
|
|
12
6
|
};
|
|
@@ -1,57 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
name: {},
|
|
9
|
-
defaultItems: {},
|
|
10
|
-
items: {}
|
|
11
|
-
},
|
|
12
|
-
setup(n) {
|
|
13
|
-
const a = n, y = a.form.useStore((e) => e.values), i = f(() => {
|
|
14
|
-
const e = a.name.replace(/\[/g, ".").replace(/\]/g, "");
|
|
15
|
-
try {
|
|
16
|
-
return e.split(".").reduce((r, t) => r && r[t], y.value);
|
|
17
|
-
} catch (r) {
|
|
18
|
-
return console.error(r), [];
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
M(async () => {
|
|
22
|
-
a.defaultItems && !i.value && a.form.setFieldValue(a.name, a.defaultItems);
|
|
23
|
-
});
|
|
24
|
-
const $ = f(() => (r) => {
|
|
25
|
-
const t = r.replace(/\[\d+\]/g, "");
|
|
26
|
-
return a.form.meta[t];
|
|
27
|
-
});
|
|
28
|
-
return P("getMetaFromArray", $), (e, r) => (s(), c(p(n.form.Field), { name: n.name }, {
|
|
29
|
-
default: g(({ field: t, state: d }) => [
|
|
30
|
-
o(e.$slots, "pre-array", l(u({ field: t, state: d }))),
|
|
31
|
-
(s(!0), k(A, null, C(i.value, (B, m) => (s(), c(p(n.form.Field), {
|
|
32
|
-
key: `${n.name}[${Number(m)}]`,
|
|
33
|
-
name: (
|
|
34
|
-
// eslint-disable-next-line
|
|
35
|
-
`${n.name}[${Number(m)}]`
|
|
36
|
-
)
|
|
37
|
-
}, {
|
|
38
|
-
default: g(({ field: v, state: h }) => [
|
|
39
|
-
o(e.$slots, "default", b({ ref_for: !0 }, {
|
|
40
|
-
subField: v,
|
|
41
|
-
subState: h,
|
|
42
|
-
index: Number(m),
|
|
43
|
-
field: t
|
|
44
|
-
}))
|
|
45
|
-
]),
|
|
46
|
-
_: 2
|
|
47
|
-
}, 1032, ["name"]))), 128)),
|
|
48
|
-
o(e.$slots, "post-array", l(u({ field: t, state: d }))),
|
|
49
|
-
o(e.$slots, "field", l(u({ field: t })))
|
|
50
|
-
]),
|
|
51
|
-
_: 3
|
|
52
|
-
}, 8, ["name"]));
|
|
53
|
-
}
|
|
54
|
-
});
|
|
1
|
+
import { Exit as c, Runtime as u } from "effect";
|
|
2
|
+
import { dual as n, isFunction as m } from "./vue-components.es30.js";
|
|
3
|
+
const i = Symbol.for("clone-trait"), a = n(2, (e, t) => i in e ? e[i](t) : Object.setPrototypeOf(t, Object.getPrototypeOf(e)));
|
|
4
|
+
n(2, (e, t) => a(e, { ...e, ...m(t) ? t(e) : t }));
|
|
5
|
+
const p = (e, t) => new Promise((o, s) => e.addObserver((r) => {
|
|
6
|
+
c.isSuccess(r) ? o(r.value) : s(u.makeFiberFailure(r.cause));
|
|
7
|
+
}));
|
|
55
8
|
export {
|
|
56
|
-
|
|
9
|
+
a as clone,
|
|
10
|
+
i as cloneTrait,
|
|
11
|
+
p as runtimeFiberAsPromise
|
|
57
12
|
};
|
|
@@ -1,70 +1,57 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
__name: "
|
|
1
|
+
import { defineComponent as F, computed as f, onMounted as M, provide as P, createBlock as c, openBlock as s, resolveDynamicComponent as p, withCtx as g, renderSlot as o, createElementBlock as k, normalizeProps as l, guardReactiveProps as u, Fragment as A, renderList as C, mergeProps as b } from "vue";
|
|
2
|
+
const N = /* @__PURE__ */ F({
|
|
3
|
+
inheritAttrs: !1,
|
|
4
|
+
__name: "OmegaArray",
|
|
5
5
|
props: {
|
|
6
6
|
form: {},
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
order: {},
|
|
12
|
-
sort: {}
|
|
7
|
+
inputClass: {},
|
|
8
|
+
name: {},
|
|
9
|
+
defaultItems: {},
|
|
10
|
+
items: {}
|
|
13
11
|
},
|
|
14
|
-
setup(
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
n.form.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
(e
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
n.sort ? u.sort(n.sort) : (e) => e
|
|
56
|
-
)
|
|
57
|
-
);
|
|
58
|
-
return (e, r) => (_(!0), M(E, null, A(b.value, ({ name: t, label: o, ...c }) => F(e.$slots, "default", {
|
|
59
|
-
child: { name: t, label: o, ...c }
|
|
60
|
-
}, () => [
|
|
61
|
-
g(h(i.form).Input, k({
|
|
62
|
-
name: t,
|
|
63
|
-
label: o
|
|
64
|
-
}, { ref_for: !0 }, c), null, 16, ["name", "label"])
|
|
65
|
-
])), 256));
|
|
12
|
+
setup(n) {
|
|
13
|
+
const a = n, y = a.form.useStore((e) => e.values), i = f(() => {
|
|
14
|
+
const e = a.name.replace(/\[/g, ".").replace(/\]/g, "");
|
|
15
|
+
try {
|
|
16
|
+
return e.split(".").reduce((r, t) => r && r[t], y.value);
|
|
17
|
+
} catch (r) {
|
|
18
|
+
return console.error(r), [];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
M(async () => {
|
|
22
|
+
a.defaultItems && !i.value && a.form.setFieldValue(a.name, a.defaultItems);
|
|
23
|
+
});
|
|
24
|
+
const $ = f(() => (r) => {
|
|
25
|
+
const t = r.replace(/\[\d+\]/g, "");
|
|
26
|
+
return a.form.meta[t];
|
|
27
|
+
});
|
|
28
|
+
return P("getMetaFromArray", $), (e, r) => (s(), c(p(n.form.Field), { name: n.name }, {
|
|
29
|
+
default: g(({ field: t, state: d }) => [
|
|
30
|
+
o(e.$slots, "pre-array", l(u({ field: t, state: d }))),
|
|
31
|
+
(s(!0), k(A, null, C(i.value, (B, m) => (s(), c(p(n.form.Field), {
|
|
32
|
+
key: `${n.name}[${Number(m)}]`,
|
|
33
|
+
name: (
|
|
34
|
+
// eslint-disable-next-line
|
|
35
|
+
`${n.name}[${Number(m)}]`
|
|
36
|
+
)
|
|
37
|
+
}, {
|
|
38
|
+
default: g(({ field: v, state: h }) => [
|
|
39
|
+
o(e.$slots, "default", b({ ref_for: !0 }, {
|
|
40
|
+
subField: v,
|
|
41
|
+
subState: h,
|
|
42
|
+
index: Number(m),
|
|
43
|
+
field: t
|
|
44
|
+
}))
|
|
45
|
+
]),
|
|
46
|
+
_: 2
|
|
47
|
+
}, 1032, ["name"]))), 128)),
|
|
48
|
+
o(e.$slots, "post-array", l(u({ field: t, state: d }))),
|
|
49
|
+
o(e.$slots, "field", l(u({ field: t })))
|
|
50
|
+
]),
|
|
51
|
+
_: 3
|
|
52
|
+
}, 8, ["name"]));
|
|
66
53
|
}
|
|
67
54
|
});
|
|
68
55
|
export {
|
|
69
|
-
|
|
56
|
+
N as default
|
|
70
57
|
};
|
|
@@ -1,8 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { defineComponent as O, computed as j, createElementBlock as M, openBlock as _, Fragment as E, renderList as A, renderSlot as F, createVNode as g, unref as h, mergeProps as k } from "vue";
|
|
2
|
+
import { Order as l, pipe as v, Array as u } from "effect-app";
|
|
3
|
+
const I = /* @__PURE__ */ O({
|
|
4
|
+
__name: "OmegaAutoGen",
|
|
5
|
+
props: {
|
|
6
|
+
form: {},
|
|
7
|
+
pick: {},
|
|
8
|
+
omit: {},
|
|
9
|
+
labelMap: { type: Function },
|
|
10
|
+
filterMap: { type: Function },
|
|
11
|
+
order: {},
|
|
12
|
+
sort: {}
|
|
13
|
+
},
|
|
14
|
+
setup(i) {
|
|
15
|
+
const p = (e) => (r) => Object.fromEntries(
|
|
16
|
+
Object.entries(r).map(([t, o]) => [t, e(o, t)])
|
|
17
|
+
), a = (e) => (r) => Object.fromEntries(
|
|
18
|
+
Object.entries(r).filter(([t, o]) => e(o, t))
|
|
19
|
+
), m = (e) => (r) => Object.entries(r).reduce(
|
|
20
|
+
(t, [o, c]) => {
|
|
21
|
+
const s = e(c, o);
|
|
22
|
+
return s !== !1 && (t[o] = s), t;
|
|
23
|
+
},
|
|
24
|
+
{}
|
|
25
|
+
), n = i, f = (e, r) => {
|
|
26
|
+
const t = r?.indexOf(e) ?? -1;
|
|
27
|
+
return t === -1 ? Number.MAX_SAFE_INTEGER : t;
|
|
28
|
+
}, d = l.mapInput(
|
|
29
|
+
l.number,
|
|
30
|
+
(e) => f(e.name, n.order || [])
|
|
31
|
+
), b = j(
|
|
32
|
+
() => v(
|
|
33
|
+
n.form.meta,
|
|
34
|
+
// include / exclude
|
|
35
|
+
a(
|
|
36
|
+
(e, r) => n.pick ? n.pick.includes(r) && !n.omit?.includes(r) : !n.omit?.includes(r)
|
|
37
|
+
),
|
|
38
|
+
(e) => e,
|
|
39
|
+
// labelMap and adding name
|
|
40
|
+
p((e, r) => ({
|
|
41
|
+
name: r,
|
|
42
|
+
label: n.labelMap?.(r) || r,
|
|
43
|
+
...e
|
|
44
|
+
})),
|
|
45
|
+
// filterMap
|
|
46
|
+
n.filterMap ? m((e) => {
|
|
47
|
+
const r = n.filterMap?.(e.name, e);
|
|
48
|
+
return r === void 0 || r === !0 ? e : r;
|
|
49
|
+
}) : (e) => e,
|
|
50
|
+
// transform to array
|
|
51
|
+
(e) => Object.values(e),
|
|
52
|
+
// order
|
|
53
|
+
u.sort(d),
|
|
54
|
+
// sort
|
|
55
|
+
n.sort ? u.sort(n.sort) : (e) => e
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
return (e, r) => (_(!0), M(E, null, A(b.value, ({ name: t, label: o, ...c }) => F(e.$slots, "default", {
|
|
59
|
+
child: { name: t, label: o, ...c }
|
|
60
|
+
}, () => [
|
|
61
|
+
g(h(i.form).Input, k({
|
|
62
|
+
name: t,
|
|
63
|
+
label: o
|
|
64
|
+
}, { ref_for: !0 }, c), null, 16, ["name", "label"])
|
|
65
|
+
])), 256));
|
|
66
|
+
}
|
|
67
|
+
});
|
|
6
68
|
export {
|
|
7
|
-
|
|
69
|
+
I as default
|
|
8
70
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var
|
|
2
|
-
import
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");if(a.appendChild(document.createTextNode('.v-enter-from[data-v-6b2bf87e],.v-leave-to[data-v-6b2bf87e]{max-height:0px;grid-template-rows:0fr;opacity:0}.v-enter-active[data-v-6b2bf87e],.v-leave-active[data-v-6b2bf87e]{display:grid;transition:all .15s}.v-enter-to[data-v-6b2bf87e],.v-leave-from[data-v-6b2bf87e]{grid-template-rows:1fr;max-height:50vh;opacity:1}.error-alert[data-v-6b2bf87e]{transition-behavior:allow-discrete;display:grid;overflow:hidden;min-height:0}.error-alert>*[data-v-6b2bf87e]{min-height:0}.error-list[data-v-6b2bf87e]{list-style-position:inside}.error-list [data-v-6b2bf87e]::marker{margin:0;padding:0}.error-alert-content[data-v-6b2bf87e]{background-color:var(--error-background, #fff5f5);color:var(--error-color, #c92a2a);padding:1em}.error-link[data-v-6b2bf87e]{font-weight:700;position:relative;color:var(--error-color, #c92a2a);cursor:pointer}.error-link[data-v-6b2bf87e]:after{content:"";position:absolute;left:0;right:0;bottom:0;height:1px;background:rgba(from var(--error-color, #c92a2a) r g b / .5)}.text-h6[data-v-6b2bf87e]{font-weight:700;font-size:1.25em}.error-message[data-v-6b2bf87e]{font-style:italic}.error-item[data-v-6b2bf87e]{margin-bottom:.5em;overflow:hidden}.error-item>div[data-v-6b2bf87e]{float:right;width:100%;max-width:calc(100% - 1.5em)}.container[data-v-6b2bf87e]{display:flex;gap:1.5em}.container svg[data-v-6b2bf87e]{width:3em}.container .single-error[data-v-6b2bf87e]{display:inline-block}')),document.head.appendChild(a),window.customElements){const e=window.customElements.define;window.customElements.define=function(i,t){const r=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(r&&r.call(this),this.shadowRoot){const o=document.createElement("style");o.appendChild(document.createTextNode('.v-enter-from[data-v-6b2bf87e],.v-leave-to[data-v-6b2bf87e]{max-height:0px;grid-template-rows:0fr;opacity:0}.v-enter-active[data-v-6b2bf87e],.v-leave-active[data-v-6b2bf87e]{display:grid;transition:all .15s}.v-enter-to[data-v-6b2bf87e],.v-leave-from[data-v-6b2bf87e]{grid-template-rows:1fr;max-height:50vh;opacity:1}.error-alert[data-v-6b2bf87e]{transition-behavior:allow-discrete;display:grid;overflow:hidden;min-height:0}.error-alert>*[data-v-6b2bf87e]{min-height:0}.error-list[data-v-6b2bf87e]{list-style-position:inside}.error-list [data-v-6b2bf87e]::marker{margin:0;padding:0}.error-alert-content[data-v-6b2bf87e]{background-color:var(--error-background, #fff5f5);color:var(--error-color, #c92a2a);padding:1em}.error-link[data-v-6b2bf87e]{font-weight:700;position:relative;color:var(--error-color, #c92a2a);cursor:pointer}.error-link[data-v-6b2bf87e]:after{content:"";position:absolute;left:0;right:0;bottom:0;height:1px;background:rgba(from var(--error-color, #c92a2a) r g b / .5)}.text-h6[data-v-6b2bf87e]{font-weight:700;font-size:1.25em}.error-message[data-v-6b2bf87e]{font-style:italic}.error-item[data-v-6b2bf87e]{margin-bottom:.5em;overflow:hidden}.error-item>div[data-v-6b2bf87e]{float:right;width:100%;max-width:calc(100% - 1.5em)}.container[data-v-6b2bf87e]{display:flex;gap:1.5em}.container svg[data-v-6b2bf87e]{width:3em}.container .single-error[data-v-6b2bf87e]{display:inline-block}')),this.shadowRoot.appendChild(o)}},e.call(window.customElements,i,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
import r from "./vue-components.es33.js";
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
const
|
|
4
|
+
import o from "./vue-components.es35.js";
|
|
5
|
+
const m = /* @__PURE__ */ o(r, [["__scopeId", "data-v-6b2bf87e"]]);
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
m as default
|
|
8
8
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");if(n.appendChild(document.createTextNode("fieldset[data-v-8c9cb27c]{display:contents}fieldset[disabled][data-v-8c9cb27c]>*{pointer-events:none}")),document.head.appendChild(n),window.customElements){const e=window.customElements.define;window.customElements.define=function(o,t){const d=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(d&&d.call(this),this.shadowRoot){const c=document.createElement("style");c.appendChild(document.createTextNode("fieldset[data-v-8c9cb27c]{display:contents}fieldset[disabled][data-v-8c9cb27c]>*{pointer-events:none}")),this.shadowRoot.appendChild(c)}},e.call(window.customElements,o,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
import o from "./vue-components.es36.js";
|
|
3
|
+
|
|
4
|
+
import m from "./vue-components.es35.js";
|
|
5
|
+
const a = /* @__PURE__ */ m(o, [["__scopeId", "data-v-8c9cb27c"]]);
|
|
3
6
|
export {
|
|
4
|
-
|
|
7
|
+
a as default
|
|
5
8
|
};
|
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
return { all: t = t || /* @__PURE__ */ new Map(), on: function(e, f) {
|
|
3
|
-
var i = t.get(e);
|
|
4
|
-
i ? i.push(f) : t.set(e, [f]);
|
|
5
|
-
}, off: function(e, f) {
|
|
6
|
-
var i = t.get(e);
|
|
7
|
-
i && (f ? i.splice(i.indexOf(f) >>> 0, 1) : t.set(e, []));
|
|
8
|
-
}, emit: function(e, f) {
|
|
9
|
-
var i = t.get(e);
|
|
10
|
-
i && i.slice().map(function(a) {
|
|
11
|
-
a(f);
|
|
12
|
-
}), (i = t.get("*")) && i.slice().map(function(a) {
|
|
13
|
-
a(e, f);
|
|
14
|
-
});
|
|
15
|
-
} };
|
|
16
|
-
}
|
|
1
|
+
import f from "./vue-components.es9.js";
|
|
17
2
|
export {
|
|
18
|
-
|
|
3
|
+
f as default
|
|
19
4
|
};
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
function c(t) {
|
|
2
|
+
return { all: t = t || /* @__PURE__ */ new Map(), on: function(e, f) {
|
|
3
|
+
var i = t.get(e);
|
|
4
|
+
i ? i.push(f) : t.set(e, [f]);
|
|
5
|
+
}, off: function(e, f) {
|
|
6
|
+
var i = t.get(e);
|
|
7
|
+
i && (f ? i.splice(i.indexOf(f) >>> 0, 1) : t.set(e, []));
|
|
8
|
+
}, emit: function(e, f) {
|
|
9
|
+
var i = t.get(e);
|
|
10
|
+
i && i.slice().map(function(a) {
|
|
11
|
+
a(f);
|
|
12
|
+
}), (i = t.get("*")) && i.slice().map(function(a) {
|
|
13
|
+
a(e, f);
|
|
14
|
+
});
|
|
15
|
+
} };
|
|
10
16
|
}
|
|
11
17
|
export {
|
|
12
|
-
|
|
18
|
+
c as default
|
|
13
19
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as v, mergeModels as C, useModel as k, useSlots as V, computed as _, resolveComponent as g, createBlock as y, openBlock as B, unref as a, createSlots as E, withCtx as u, renderSlot as d, renderList as M, normalizeProps as S, guardReactiveProps as w } from "vue";
|
|
2
2
|
import { useOnClose as L } from "./vue-components.es11.js";
|
|
3
|
-
import { onMountedWithCleanup as h } from "./vue-components.
|
|
3
|
+
import { onMountedWithCleanup as h } from "./vue-components.es16.js";
|
|
4
4
|
const z = /* @__PURE__ */ v({
|
|
5
5
|
__name: "Dialog",
|
|
6
6
|
props: /* @__PURE__ */ C({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as F, computed as
|
|
2
|
-
import { useIntl as
|
|
3
|
-
import { generateInputStandardSchemaFromFieldMeta as
|
|
4
|
-
import
|
|
5
|
-
import { useErrorLabel as
|
|
1
|
+
import { defineComponent as F, computed as o, useAttrs as $, inject as k, createBlock as u, openBlock as i, resolveDynamicComponent as A, withCtx as m, createCommentVNode as M, mergeProps as S, unref as w, createSlots as I, renderSlot as f, normalizeProps as c, guardReactiveProps as d } from "vue";
|
|
2
|
+
import { useIntl as P } from "./vue-components.es3.js";
|
|
3
|
+
import { generateInputStandardSchemaFromFieldMeta as j } from "./vue-components.es12.js";
|
|
4
|
+
import B from "./vue-components.es7.js";
|
|
5
|
+
import { useErrorLabel as E } from "./vue-components.es10.js";
|
|
6
6
|
const V = /* @__PURE__ */ F({
|
|
7
7
|
inheritAttrs: !1,
|
|
8
8
|
__name: "OmegaInput",
|
|
@@ -13,52 +13,46 @@ const V = /* @__PURE__ */ F({
|
|
|
13
13
|
name: {},
|
|
14
14
|
inputClass: {}
|
|
15
15
|
},
|
|
16
|
-
setup(
|
|
17
|
-
const e =
|
|
16
|
+
setup(t) {
|
|
17
|
+
const e = t, l = o(() => e.name), v = $(), p = o(() => {
|
|
18
18
|
if (e.inputClass !== null)
|
|
19
|
-
return e.inputClass !== void 0 ? e.inputClass :
|
|
20
|
-
}),
|
|
19
|
+
return e.inputClass !== void 0 ? e.inputClass : v.class;
|
|
20
|
+
}), n = k(
|
|
21
21
|
"getMetaFromArray",
|
|
22
22
|
null
|
|
23
|
-
),
|
|
24
|
-
|
|
25
|
-
if (!t) return n.value;
|
|
26
|
-
const r = t;
|
|
27
|
-
return `${n.value}-${r.type}-${r.minLength ?? ""}-${r.maxLength ?? ""}-${r.minimum ?? ""}-${r.maximum ?? ""}`;
|
|
28
|
-
}), { trans: C } = j(), b = l(() => {
|
|
29
|
-
if (!o.value)
|
|
23
|
+
), r = o(() => n?.value && n.value(e.name) ? n.value(l.value) : e.form.meta[l.value]), { trans: g } = P(), C = o(() => {
|
|
24
|
+
if (!r.value)
|
|
30
25
|
throw console.log(e.name, Object.keys(e.form.meta), e.form.meta), new Error("Meta is undefined");
|
|
31
|
-
return
|
|
32
|
-
}),
|
|
33
|
-
return (
|
|
34
|
-
|
|
35
|
-
name: a.name,
|
|
26
|
+
return j(r.value, g);
|
|
27
|
+
}), b = E(e.form);
|
|
28
|
+
return (a, N) => (i(), u(A(t.form.Field), {
|
|
29
|
+
name: t.name,
|
|
36
30
|
validators: {
|
|
37
|
-
onChange:
|
|
38
|
-
...
|
|
31
|
+
onChange: C.value,
|
|
32
|
+
...t.validators
|
|
39
33
|
}
|
|
40
34
|
}, {
|
|
41
|
-
default:
|
|
42
|
-
|
|
43
|
-
field:
|
|
44
|
-
state:
|
|
45
|
-
register:
|
|
46
|
-
label:
|
|
47
|
-
meta:
|
|
48
|
-
}),
|
|
49
|
-
default:
|
|
50
|
-
|
|
35
|
+
default: m(({ field: h, state: y }) => [
|
|
36
|
+
r.value ? (i(), u(B, S({ key: 0 }, { ...a.$attrs, ...a.$props, inputClass: p.value }, {
|
|
37
|
+
field: h,
|
|
38
|
+
state: y,
|
|
39
|
+
register: t.form.registerField,
|
|
40
|
+
label: t.label ?? w(b)(l.value),
|
|
41
|
+
meta: r.value
|
|
42
|
+
}), I({
|
|
43
|
+
default: m((s) => [
|
|
44
|
+
f(a.$slots, "default", c(d(s)))
|
|
51
45
|
]),
|
|
52
46
|
_: 2
|
|
53
47
|
}, [
|
|
54
|
-
|
|
48
|
+
a.$slots.label ? {
|
|
55
49
|
name: "label",
|
|
56
|
-
fn:
|
|
57
|
-
|
|
50
|
+
fn: m((s) => [
|
|
51
|
+
f(a.$slots, "label", c(d(s)))
|
|
58
52
|
]),
|
|
59
53
|
key: "0"
|
|
60
54
|
} : void 0
|
|
61
|
-
]), 1040, ["field", "state", "register", "label", "meta"])) :
|
|
55
|
+
]), 1040, ["field", "state", "register", "label", "meta"])) : M("", !0)
|
|
62
56
|
]),
|
|
63
57
|
_: 3
|
|
64
58
|
}, 8, ["name", "validators"]));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var i=document.createElement("style");if(i.appendChild(document.createTextNode(".omega-input .v-input__details:has(.v-messages:empty){grid-template-rows:0fr;transition:all .2s}.omega-input .v-messages:empty{min-height:0}.omega-input .v-input__details:has(.v-messages){transition:all .2s;overflow:hidden;min-height:0;display:grid;grid-template-rows:1fr}.omega-input .v-messages{transition:all .2s}.omega-input .v-messages>*{transition-duration:0s!important}.omega-input [role=alert]:has(.v-messages:empty){padding:0}.omega-input .v-btn{cursor:pointer;width:auto;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),document.head.appendChild(i),window.customElements){const e=window.customElements.define;window.customElements.define=function(s,t){const n=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(n&&n.call(this),this.shadowRoot){const a=document.createElement("style");a.appendChild(document.createTextNode(".omega-input .v-input__details:has(.v-messages:empty){grid-template-rows:0fr;transition:all .2s}.omega-input .v-messages:empty{min-height:0}.omega-input .v-input__details:has(.v-messages){transition:all .2s;overflow:hidden;min-height:0;display:grid;grid-template-rows:1fr}.omega-input .v-messages{transition:all .2s}.omega-input .v-messages>*{transition-duration:0s!important}.omega-input [role=alert]:has(.v-messages:empty){padding:0}.omega-input .v-btn{cursor:pointer;width:auto;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),this.shadowRoot.appendChild(a)}},e.call(window.customElements,s,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { useStore as
|
|
2
|
+
import { defineComponent as N, computed as n, getCurrentInstance as k, useAttrs as q, useSlots as B, useId as S, renderSlot as d, normalizeProps as s, guardReactiveProps as p, createElementVNode as w, normalizeClass as F, createBlock as I, createCommentVNode as L, unref as A, openBlock as O, mergeProps as R, createSlots as V, withCtx as z } from "vue";
|
|
3
|
+
import { useStore as f } from "@tanstack/vue-form";
|
|
4
4
|
import T from "./vue-components.es38.js";
|
|
5
5
|
|
|
6
|
-
const H = /* @__PURE__ */
|
|
6
|
+
const H = /* @__PURE__ */ N({
|
|
7
7
|
inheritAttrs: !1,
|
|
8
8
|
__name: "OmegaInternalInput",
|
|
9
9
|
props: {
|
|
@@ -18,25 +18,27 @@ const H = /* @__PURE__ */ $({
|
|
|
18
18
|
register: {},
|
|
19
19
|
options: { default: void 0 }
|
|
20
20
|
},
|
|
21
|
-
setup(
|
|
22
|
-
const e =
|
|
23
|
-
const { class: t, ...a } =
|
|
21
|
+
setup(c) {
|
|
22
|
+
const e = c, l = n(() => e.required ?? e?.meta?.required), g = k()?.appContext.components.VTextField, v = q(), y = B(), h = n(() => {
|
|
23
|
+
const { class: t, ...a } = v;
|
|
24
24
|
return a;
|
|
25
|
-
}), i =
|
|
25
|
+
}), i = S(), o = e.field;
|
|
26
|
+
f(o.store, (t) => t);
|
|
27
|
+
const b = f(o.form.store, (t) => t.fieldMeta), C = n(() => e.type ? e.type : e.meta?.type === "string" ? e.meta.format === "email" ? "email" : "string" : e.meta?.type || "unknown");
|
|
26
28
|
e.register(n(() => ({ name: e.field.name, label: e.label, id: i })));
|
|
27
|
-
const
|
|
29
|
+
const x = n(() => b.value[e.field.name]?.errors ?? []), m = n(
|
|
28
30
|
() => (
|
|
29
31
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
-
|
|
32
|
+
x.value.map((t) => t?.message).filter(Boolean)
|
|
31
33
|
)
|
|
32
|
-
),
|
|
33
|
-
|
|
34
|
+
), M = (t) => t == null || t === !1 || t === "" || Number.isNaN(t), _ = (t) => {
|
|
35
|
+
M(t) && e.meta?.type !== "boolean" && e.meta?.nullableOrUndefined ? e.field.handleChange(
|
|
34
36
|
e.meta.nullableOrUndefined === "undefined" ? void 0 : null
|
|
35
37
|
) : e.field.handleChange(t), e.field.setMeta((a) => ({ ...a, errorMap: { ...a.errorMap, onSubmit: void 0 } }));
|
|
36
|
-
},
|
|
38
|
+
}, P = (t) => {
|
|
37
39
|
const a = {
|
|
38
|
-
get(E,
|
|
39
|
-
return
|
|
40
|
+
get(E, $, W) {
|
|
41
|
+
return $ === "handleChange" ? _ : Reflect.get(...arguments);
|
|
40
42
|
}
|
|
41
43
|
};
|
|
42
44
|
return new Proxy(t, a);
|
|
@@ -48,26 +50,26 @@ const H = /* @__PURE__ */ $({
|
|
|
48
50
|
maxLength: e.meta?.type === "string" && e.meta?.maxLength,
|
|
49
51
|
max: e.meta?.type === "number" && (e.meta?.maximum ?? (typeof e.meta?.exclusiveMaximum == "number" && e.meta.exclusiveMaximum - 1)),
|
|
50
52
|
min: e.meta?.type === "number" && (e.meta?.minimum ?? (typeof e.meta?.exclusiveMinimum == "number" && e.meta.exclusiveMinimum + 1)),
|
|
51
|
-
errorMessages:
|
|
52
|
-
error: !!
|
|
53
|
-
type:
|
|
53
|
+
errorMessages: m.value,
|
|
54
|
+
error: !!m.value.length,
|
|
55
|
+
type: C.value,
|
|
54
56
|
// Only add asterisk if label slot is not provided (slot has full control)
|
|
55
|
-
label:
|
|
57
|
+
label: y.label ? e.label : `${e.label}${l.value ? " *" : ""}`,
|
|
56
58
|
options: e.options,
|
|
57
59
|
inputClass: e.inputClass
|
|
58
60
|
},
|
|
59
61
|
state: e.state,
|
|
60
|
-
field:
|
|
62
|
+
field: P(e.field)
|
|
61
63
|
}));
|
|
62
|
-
return (t, a) =>
|
|
63
|
-
|
|
64
|
-
class:
|
|
64
|
+
return (t, a) => d(t.$slots, "default", s(p({ ...r.value.inputProps, field: r.value.field, state: r.value.state })), () => [
|
|
65
|
+
w("div", {
|
|
66
|
+
class: F(t.$attrs.class)
|
|
65
67
|
}, [
|
|
66
|
-
A(
|
|
68
|
+
A(g) ? (O(), I(T, s(R({ key: 0 }, { ...h.value, ...r.value, class: e.inputClass })), V({ _: 2 }, [
|
|
67
69
|
t.$slots.label ? {
|
|
68
70
|
name: "label",
|
|
69
|
-
fn:
|
|
70
|
-
|
|
71
|
+
fn: z((u) => [
|
|
72
|
+
d(t.$slots, "label", s(p(u)))
|
|
71
73
|
]),
|
|
72
74
|
key: "0"
|
|
73
75
|
} : void 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
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": "
|
|
57
|
-
"
|
|
56
|
+
"@effect-app/vue": "2.93.6",
|
|
57
|
+
"effect-app": "3.15.1"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "pnpm build:run",
|
|
@@ -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,
|
|
@@ -82,18 +81,6 @@ const meta = computed(() => {
|
|
|
82
81
|
return props.form.meta[propsName.value]
|
|
83
82
|
})
|
|
84
83
|
|
|
85
|
-
// Key to force Field re-mount when meta type changes (for TaggedUnion support)
|
|
86
|
-
const fieldKey = computed(() => {
|
|
87
|
-
const m = meta.value
|
|
88
|
-
if (!m) return propsName.value
|
|
89
|
-
// Include type and key constraints in the key so Field re-mounts when validation rules change
|
|
90
|
-
// Cast to any since not all FieldMeta variants have these properties
|
|
91
|
-
const fm = m as any
|
|
92
|
-
return `${propsName.value}-${fm.type}-${fm.minLength ?? ""}-${fm.maxLength ?? ""}-${fm.minimum ?? ""}-${
|
|
93
|
-
fm.maximum ?? ""
|
|
94
|
-
}`
|
|
95
|
-
})
|
|
96
|
-
|
|
97
84
|
// Call useIntl during setup to avoid issues when computed re-evaluates
|
|
98
85
|
const { trans } = useIntl()
|
|
99
86
|
|
|
@@ -84,6 +84,9 @@ const fieldApi = props.field
|
|
|
84
84
|
|
|
85
85
|
const fieldState = useStore(fieldApi.store, (state) => state)
|
|
86
86
|
|
|
87
|
+
// Get errors from form-level fieldMeta (persists across Field re-mounts)
|
|
88
|
+
const formFieldMeta = useStore(fieldApi.form.store, (state) => state.fieldMeta)
|
|
89
|
+
|
|
87
90
|
const fieldType = computed(() => {
|
|
88
91
|
if (props.type) return props.type
|
|
89
92
|
if (props.meta?.type === "string") {
|
|
@@ -95,8 +98,13 @@ const fieldType = computed(() => {
|
|
|
95
98
|
|
|
96
99
|
props.register(computed(() => ({ name: props.field.name, label: props.label, id })))
|
|
97
100
|
|
|
98
|
-
//
|
|
99
|
-
|
|
101
|
+
// Get errors from form-level fieldMeta instead of field-level state
|
|
102
|
+
// This ensures errors persist when Field components re-mount due to :key changes
|
|
103
|
+
const _errors = computed(() => {
|
|
104
|
+
const fieldMeta = formFieldMeta.value[props.field.name] as any
|
|
105
|
+
// Treat errors as an array (like useOmegaForm does)
|
|
106
|
+
return fieldMeta?.errors ?? []
|
|
107
|
+
})
|
|
100
108
|
const errors = computed(() =>
|
|
101
109
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
110
|
_errors.value.map((e: any) => e?.message).filter(Boolean)
|
|
@@ -962,8 +962,18 @@ export const useOmegaForm = <
|
|
|
962
962
|
// /** @experimental */
|
|
963
963
|
handleSubmitEffect,
|
|
964
964
|
registerField: (field: ComputedRef<{ name: string; label: string; id: string }>) => {
|
|
965
|
-
watch(field, (f) =>
|
|
966
|
-
|
|
965
|
+
watch(field, (f) => {
|
|
966
|
+
fieldMap.value.set(f.name, { label: f.label, id: f.id })
|
|
967
|
+
}, { immediate: true })
|
|
968
|
+
onUnmounted(() => {
|
|
969
|
+
// Only delete if we still own this entry (id matches)
|
|
970
|
+
// This prevents old components from deleting entries registered by new components
|
|
971
|
+
// during re-mount transitions (e.g., when :key changes)
|
|
972
|
+
const currentEntry = fieldMap.value.get(field.value.name)
|
|
973
|
+
if (currentEntry?.id === field.value.id) {
|
|
974
|
+
fieldMap.value.delete(field.value.name)
|
|
975
|
+
}
|
|
976
|
+
})
|
|
967
977
|
}
|
|
968
978
|
})
|
|
969
979
|
|
|
@@ -5,7 +5,9 @@ const Key = Symbol("injected") as InjectionKey<Map<string, { label: string; id:
|
|
|
5
5
|
|
|
6
6
|
export const useRegisterField = (field: ComputedRef<{ name: string; label: string; id: string }>) => {
|
|
7
7
|
const map = injectCertain(Key)
|
|
8
|
-
watch(field, (f) =>
|
|
8
|
+
watch(field, (f) => {
|
|
9
|
+
map.set(f.name, { label: f.label, id: f.id })
|
|
10
|
+
}, { immediate: true })
|
|
9
11
|
onUnmounted(() => map.delete(field.value.name)) // todo; perhap only when owned
|
|
10
12
|
}
|
|
11
13
|
|