@effect-app/vue-components 0.23.0 → 0.23.1
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/types/components/OmegaForm/OmegaWrapper.vue.d.ts +10 -2
- package/dist/vue-components.es12.js +3 -3
- package/dist/vue-components.es20.js +24 -24
- package/dist/vue-components.es26.js +11 -90
- package/dist/vue-components.es27.js +90 -11
- package/dist/vue-components.es41.js +1 -1
- package/dist/vue-components.es7.js +1 -1
- package/package.json +3 -3
- package/src/components/OmegaForm/OmegaWrapper.vue +5 -5
|
@@ -14,10 +14,18 @@ declare const _default: <From extends Record<PropertyKey, any>, To extends Recor
|
|
|
14
14
|
schema: S.Schema<To, From, never>;
|
|
15
15
|
}) & ({
|
|
16
16
|
isLoading: boolean;
|
|
17
|
-
onSubmit: (value: To,
|
|
17
|
+
onSubmit: (value: To, extra: Pick<{
|
|
18
|
+
formApi: import("./OmegaFormStuff").OmegaFormParams<From, To>;
|
|
19
|
+
meta: any;
|
|
20
|
+
value: To;
|
|
21
|
+
}, "formApi" | "meta">) => void;
|
|
18
22
|
} | {
|
|
19
23
|
isLoading?: undefined;
|
|
20
|
-
onSubmit?: (value: To,
|
|
24
|
+
onSubmit?: (value: To, extra: Pick<{
|
|
25
|
+
formApi: import("./OmegaFormStuff").OmegaFormParams<From, To>;
|
|
26
|
+
meta: any;
|
|
27
|
+
value: To;
|
|
28
|
+
}, "formApi" | "meta">) => ReturnType<(props: {
|
|
21
29
|
formApi: import("./OmegaFormStuff").OmegaFormParams<From, To>;
|
|
22
30
|
meta: any;
|
|
23
31
|
value: To;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");if(n.appendChild(document.createTextNode("fieldset[data-v-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");if(n.appendChild(document.createTextNode("fieldset[data-v-d1710c8c]{display:contents}fieldset[disabled][data-v-d1710c8c]>*{pointer-events:none}")),document.head.appendChild(n),window.customElements){const e=window.customElements.define;window.customElements.define=function(c,t){const d=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(d&&d.call(this),this.shadowRoot){const o=document.createElement("style");o.appendChild(document.createTextNode("fieldset[data-v-d1710c8c]{display:contents}fieldset[disabled][data-v-d1710c8c]>*{pointer-events:none}")),this.shadowRoot.appendChild(o)}},e.call(window.customElements,c,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
2
|
import o from "./vue-components.es20.js";
|
|
3
3
|
|
|
4
4
|
import r from "./vue-components.es17.js";
|
|
5
|
-
const
|
|
5
|
+
const m = /* @__PURE__ */ r(o, [["__scopeId", "data-v-d1710c8c"]]);
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
m as default
|
|
8
8
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as B, getCurrentInstance as F, computed as
|
|
1
|
+
import { defineComponent as B, getCurrentInstance as F, computed as u, onBeforeMount as L, watch as S, createElementBlock as O, openBlock as h, withModifiers as C, createElementVNode as V, unref as m, renderSlot as p, createCommentVNode as k, Fragment as _ } from "vue";
|
|
2
2
|
import { useStore as y } from "@tanstack/vue-form";
|
|
3
|
-
import { getOmegaStore as $ } from "./vue-components.
|
|
3
|
+
import { getOmegaStore as $ } from "./vue-components.es26.js";
|
|
4
4
|
import { provideOmegaErrors as A } from "./vue-components.es8.js";
|
|
5
5
|
import { useOmegaForm as K } from "./vue-components.es9.js";
|
|
6
6
|
const P = ["disabled"], H = /* @__PURE__ */ B({
|
|
@@ -27,19 +27,19 @@ const P = ["disabled"], H = /* @__PURE__ */ B({
|
|
|
27
27
|
onSubmit: {}
|
|
28
28
|
},
|
|
29
29
|
setup(w) {
|
|
30
|
-
const o = w, E = F(), j = (e, r
|
|
31
|
-
E.emit("submit", e, r
|
|
32
|
-
const
|
|
33
|
-
|
|
30
|
+
const o = w, E = F(), j = (e, r) => new Promise((n) => {
|
|
31
|
+
E.emit("submit", e, r);
|
|
32
|
+
const t = S(() => o.isLoading, (i) => {
|
|
33
|
+
i || (n(), t.stop());
|
|
34
34
|
});
|
|
35
|
-
}),
|
|
35
|
+
}), b = typeof o.isLoading < "u" ? u(() => j) : typeof o.onSubmit < "u" ? u(() => o.onSubmit) : void 0, l = b?.value ? ({ formApi: e, meta: r, value: n }) => b.value(n, { meta: r, formApi: e }) : void 0, f = o.form || !o.schema ? void 0 : K(
|
|
36
36
|
o.schema,
|
|
37
37
|
{
|
|
38
38
|
...o,
|
|
39
|
-
onSubmit:
|
|
39
|
+
onSubmit: l
|
|
40
40
|
},
|
|
41
41
|
o.omegaConfig
|
|
42
|
-
), s =
|
|
42
|
+
), s = u(() => o.form ?? f);
|
|
43
43
|
L(() => {
|
|
44
44
|
if (!o.form) return;
|
|
45
45
|
const e = Object.keys(o.form.options || {}), r = /* @__PURE__ */ new Set([
|
|
@@ -51,7 +51,7 @@ const P = ["disabled"], H = /* @__PURE__ */ B({
|
|
|
51
51
|
"schema"
|
|
52
52
|
]), n = Object.fromEntries(
|
|
53
53
|
Object.entries(o).filter(
|
|
54
|
-
([a,
|
|
54
|
+
([a, d]) => a === "isLoading" ? !1 : !r.has(a) && d !== void 0
|
|
55
55
|
)
|
|
56
56
|
), t = Object.keys(n), i = e.filter(
|
|
57
57
|
(a) => t.includes(a) && n[a] !== void 0
|
|
@@ -64,31 +64,31 @@ ${i.join(
|
|
|
64
64
|
)}.
|
|
65
65
|
Props will overwrite existing form options. This might indicate a configuration issue.`
|
|
66
66
|
);
|
|
67
|
-
const
|
|
67
|
+
const g = {
|
|
68
68
|
...s.value.options,
|
|
69
69
|
...n
|
|
70
70
|
};
|
|
71
|
-
|
|
71
|
+
l && (g.onSubmit = l), s.value.options = Object.fromEntries(
|
|
72
72
|
// TODO
|
|
73
|
-
Object.entries(
|
|
74
|
-
([a,
|
|
73
|
+
Object.entries(g).filter(
|
|
74
|
+
([a, d]) => d !== void 0
|
|
75
75
|
)
|
|
76
76
|
);
|
|
77
77
|
});
|
|
78
78
|
const I = y(
|
|
79
79
|
s.value.store,
|
|
80
80
|
(e) => e.isSubmitting
|
|
81
|
-
),
|
|
81
|
+
), v = $(
|
|
82
82
|
s.value,
|
|
83
83
|
o.subscribe
|
|
84
84
|
), M = y(
|
|
85
85
|
s.value.store,
|
|
86
86
|
(e) => e.submissionAttempts
|
|
87
|
-
),
|
|
87
|
+
), c = u(() => s.value.useStore((e) => e.errors));
|
|
88
88
|
return S(
|
|
89
|
-
() => [s.value.filterItems,
|
|
89
|
+
() => [s.value.filterItems, c.value.value],
|
|
90
90
|
() => {
|
|
91
|
-
const e = s.value.filterItems, r =
|
|
91
|
+
const e = s.value.filterItems, r = c.value.value;
|
|
92
92
|
return e ? r ? (Object.values(r).filter(
|
|
93
93
|
(t) => !!t
|
|
94
94
|
).flatMap(
|
|
@@ -105,18 +105,18 @@ Props will overwrite existing form options. This might indicate a configuration
|
|
|
105
105
|
});
|
|
106
106
|
}), {}) : {} : {};
|
|
107
107
|
}
|
|
108
|
-
), A(M,
|
|
108
|
+
), A(M, c.value, o.showErrorsOn), (e, r) => (h(), O("form", {
|
|
109
109
|
novalidate: "",
|
|
110
110
|
onSubmit: r[0] || (r[0] = C((n) => s.value.handleSubmit(), ["prevent", "stop"]))
|
|
111
111
|
}, [
|
|
112
112
|
V("fieldset", { disabled: m(I) }, [
|
|
113
113
|
o.form ? (h(), O(_, { key: 0 }, [
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
], 64)) : m(
|
|
114
|
+
p(e.$slots, "externalForm", { subscribedValues: m(v) }, void 0, !0),
|
|
115
|
+
p(e.$slots, "default", {}, void 0, !0)
|
|
116
|
+
], 64)) : m(f) ? p(e.$slots, "internalForm", {
|
|
117
117
|
key: 1,
|
|
118
|
-
form: m(
|
|
119
|
-
subscribedValues: m(
|
|
118
|
+
form: m(f),
|
|
119
|
+
subscribedValues: m(v)
|
|
120
120
|
}, void 0, !0) : k("", !0)
|
|
121
121
|
], 8, P)
|
|
122
122
|
], 32));
|
|
@@ -1,92 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
field: {},
|
|
12
|
-
meta: {},
|
|
13
|
-
label: {},
|
|
14
|
-
options: {},
|
|
15
|
-
type: {},
|
|
16
|
-
validators: {}
|
|
17
|
-
},
|
|
18
|
-
setup(c) {
|
|
19
|
-
const e = c, v = x()?.appContext.components.VTextField, l = C(), o = e.field, r = z(o.store, (t) => t), m = a(() => e.type ? e.type : e.meta?.type === "string" ? e.meta.format === "email" ? "email" : "string" : e.meta?.type || "unknown"), n = a(() => r.value.value), g = a(
|
|
20
|
-
() => (
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
-
r.value.meta.errors.map((t) => t?.message).filter(Boolean)
|
|
23
|
-
)
|
|
24
|
-
), y = (t) => t == null || t === !1 || t === "" || Number.isNaN(t);
|
|
25
|
-
f(
|
|
26
|
-
() => !!n.value,
|
|
27
|
-
() => {
|
|
28
|
-
y(n.value) && e.meta?.type !== "boolean" && N(() => {
|
|
29
|
-
o.setValue(
|
|
30
|
-
e.meta?.nullableOrUndefined === "undefined" ? void 0 : null
|
|
31
|
-
);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
), d(() => {
|
|
35
|
-
!n.value && !e.meta?.required && e.meta?.nullableOrUndefined === "null" && o.setValue(null);
|
|
36
|
-
});
|
|
37
|
-
const { addError: h, removeError: b, showErrors: E, showErrorsOn: V } = A(), s = $(!1);
|
|
38
|
-
k(() => {
|
|
39
|
-
(E.value || V === "onChange") && (s.value = !0);
|
|
40
|
-
});
|
|
41
|
-
const u = () => {
|
|
42
|
-
s.value = !0;
|
|
43
|
-
};
|
|
44
|
-
d(() => {
|
|
45
|
-
n.value && u();
|
|
46
|
-
});
|
|
47
|
-
const p = a(() => !s.value && m.value !== "select" ? [] : g.value);
|
|
48
|
-
f(
|
|
49
|
-
() => r.value.meta.errors,
|
|
50
|
-
() => {
|
|
51
|
-
r.value.meta.errors.length ? h({
|
|
52
|
-
inputId: l,
|
|
53
|
-
errors: r.value.meta.errors.map((t) => t.message).filter(Boolean),
|
|
54
|
-
label: e.label
|
|
55
|
-
}) : b(l);
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
const i = a(() => ({
|
|
59
|
-
id: l,
|
|
60
|
-
required: e.meta?.required,
|
|
61
|
-
minLength: e.meta?.type === "string" && e.meta?.minLength,
|
|
62
|
-
maxLength: e.meta?.type === "string" && e.meta?.maxLength,
|
|
63
|
-
max: e.meta?.type === "number" && e.meta?.maximum,
|
|
64
|
-
min: e.meta?.type === "number" && e.meta?.minimum,
|
|
65
|
-
name: e.field.name,
|
|
66
|
-
modelValue: e.field.state.value,
|
|
67
|
-
errorMessages: p.value,
|
|
68
|
-
error: !!p.value.length,
|
|
69
|
-
field: e.field,
|
|
70
|
-
setRealDirty: u,
|
|
71
|
-
type: m.value,
|
|
72
|
-
label: `${e.label}${e.meta?.required ? " *" : ""}`,
|
|
73
|
-
options: e.options
|
|
74
|
-
}));
|
|
75
|
-
return (t, R) => B(t.$slots, "default", I(O(i.value)), () => [
|
|
76
|
-
_("div", {
|
|
77
|
-
class: q(t.$attrs.class),
|
|
78
|
-
onFocusout: u
|
|
79
|
-
}, [
|
|
80
|
-
F(v) ? (S(), L(D, T({
|
|
81
|
-
key: 0,
|
|
82
|
-
"input-props": i.value
|
|
83
|
-
}, t.$attrs, {
|
|
84
|
-
"vuetify-value": i.value.field.state.value
|
|
85
|
-
}), null, 16, ["input-props", "vuetify-value"])) : P("", !0)
|
|
86
|
-
], 34)
|
|
87
|
-
]);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
1
|
+
import { useStore as u } from "@tanstack/vue-form";
|
|
2
|
+
import { computed as f } from "vue";
|
|
3
|
+
function c(o, t) {
|
|
4
|
+
return f(() => t ? u(o.store, (n) => {
|
|
5
|
+
const r = {};
|
|
6
|
+
for (const e of t)
|
|
7
|
+
r[e] = n[e];
|
|
8
|
+
return r;
|
|
9
|
+
}).value : {});
|
|
10
|
+
}
|
|
90
11
|
export {
|
|
91
|
-
|
|
12
|
+
c as getOmegaStore
|
|
92
13
|
};
|
|
@@ -1,13 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
import { computed as f } from "vue";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 w, getCurrentInstance as x, useId as C, computed as a, watch as f, nextTick as N, onMounted as d, ref as $, watchEffect as k, renderSlot as B, normalizeProps as I, guardReactiveProps as O, createElementVNode as _, normalizeClass as q, createBlock as L, createCommentVNode as P, unref as F, openBlock as S, mergeProps as T } from "vue";
|
|
3
|
+
import { useStore as z } from "@tanstack/vue-form";
|
|
4
|
+
import { useOmegaErrors as A } from "./vue-components.es8.js";
|
|
5
|
+
import D from "./vue-components.es48.js";
|
|
6
|
+
|
|
7
|
+
const J = /* @__PURE__ */ w({
|
|
8
|
+
inheritAttrs: !1,
|
|
9
|
+
__name: "OmegaInternalInput",
|
|
10
|
+
props: {
|
|
11
|
+
field: {},
|
|
12
|
+
meta: {},
|
|
13
|
+
label: {},
|
|
14
|
+
options: {},
|
|
15
|
+
type: {},
|
|
16
|
+
validators: {}
|
|
17
|
+
},
|
|
18
|
+
setup(c) {
|
|
19
|
+
const e = c, v = x()?.appContext.components.VTextField, l = C(), o = e.field, r = z(o.store, (t) => t), m = a(() => e.type ? e.type : e.meta?.type === "string" ? e.meta.format === "email" ? "email" : "string" : e.meta?.type || "unknown"), n = a(() => r.value.value), g = a(
|
|
20
|
+
() => (
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
r.value.meta.errors.map((t) => t?.message).filter(Boolean)
|
|
23
|
+
)
|
|
24
|
+
), y = (t) => t == null || t === !1 || t === "" || Number.isNaN(t);
|
|
25
|
+
f(
|
|
26
|
+
() => !!n.value,
|
|
27
|
+
() => {
|
|
28
|
+
y(n.value) && e.meta?.type !== "boolean" && N(() => {
|
|
29
|
+
o.setValue(
|
|
30
|
+
e.meta?.nullableOrUndefined === "undefined" ? void 0 : null
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
), d(() => {
|
|
35
|
+
!n.value && !e.meta?.required && e.meta?.nullableOrUndefined === "null" && o.setValue(null);
|
|
36
|
+
});
|
|
37
|
+
const { addError: h, removeError: b, showErrors: E, showErrorsOn: V } = A(), s = $(!1);
|
|
38
|
+
k(() => {
|
|
39
|
+
(E.value || V === "onChange") && (s.value = !0);
|
|
40
|
+
});
|
|
41
|
+
const u = () => {
|
|
42
|
+
s.value = !0;
|
|
43
|
+
};
|
|
44
|
+
d(() => {
|
|
45
|
+
n.value && u();
|
|
46
|
+
});
|
|
47
|
+
const p = a(() => !s.value && m.value !== "select" ? [] : g.value);
|
|
48
|
+
f(
|
|
49
|
+
() => r.value.meta.errors,
|
|
50
|
+
() => {
|
|
51
|
+
r.value.meta.errors.length ? h({
|
|
52
|
+
inputId: l,
|
|
53
|
+
errors: r.value.meta.errors.map((t) => t.message).filter(Boolean),
|
|
54
|
+
label: e.label
|
|
55
|
+
}) : b(l);
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
const i = a(() => ({
|
|
59
|
+
id: l,
|
|
60
|
+
required: e.meta?.required,
|
|
61
|
+
minLength: e.meta?.type === "string" && e.meta?.minLength,
|
|
62
|
+
maxLength: e.meta?.type === "string" && e.meta?.maxLength,
|
|
63
|
+
max: e.meta?.type === "number" && e.meta?.maximum,
|
|
64
|
+
min: e.meta?.type === "number" && e.meta?.minimum,
|
|
65
|
+
name: e.field.name,
|
|
66
|
+
modelValue: e.field.state.value,
|
|
67
|
+
errorMessages: p.value,
|
|
68
|
+
error: !!p.value.length,
|
|
69
|
+
field: e.field,
|
|
70
|
+
setRealDirty: u,
|
|
71
|
+
type: m.value,
|
|
72
|
+
label: `${e.label}${e.meta?.required ? " *" : ""}`,
|
|
73
|
+
options: e.options
|
|
74
|
+
}));
|
|
75
|
+
return (t, R) => B(t.$slots, "default", I(O(i.value)), () => [
|
|
76
|
+
_("div", {
|
|
77
|
+
class: q(t.$attrs.class),
|
|
78
|
+
onFocusout: u
|
|
79
|
+
}, [
|
|
80
|
+
F(v) ? (S(), L(D, T({
|
|
81
|
+
key: 0,
|
|
82
|
+
"input-props": i.value
|
|
83
|
+
}, t.$attrs, {
|
|
84
|
+
"vuetify-value": i.value.field.state.value
|
|
85
|
+
}), null, 16, ["input-props", "vuetify-value"])) : P("", !0)
|
|
86
|
+
], 34)
|
|
87
|
+
]);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
11
90
|
export {
|
|
12
|
-
|
|
91
|
+
J as default
|
|
13
92
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as y, inject as h, computed as l, createBlock as s, openBlock as i, resolveDynamicComponent as M, withCtx as p, createCommentVNode as $, mergeProps as b, renderSlot as C, normalizeProps as k, guardReactiveProps as F } from "vue";
|
|
2
2
|
import { generateInputStandardSchemaFromFieldMeta as A } from "./vue-components.es10.js";
|
|
3
|
-
import w from "./vue-components.
|
|
3
|
+
import w from "./vue-components.es27.js";
|
|
4
4
|
import { useIntl as I } from "./vue-components.es3.js";
|
|
5
5
|
const z = /* @__PURE__ */ y({
|
|
6
6
|
inheritAttrs: !1,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@mdi/js": "^7.4.47",
|
|
6
6
|
"effect": "^3.17.13",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@tanstack/vue-form": "^1.19.5",
|
|
49
49
|
"highlight.js": "^11.11.1",
|
|
50
50
|
"vue3-highlightjs": "^1.0.5",
|
|
51
|
-
"
|
|
52
|
-
"effect-app": "
|
|
51
|
+
"effect-app": "3.3.7",
|
|
52
|
+
"@effect-app/vue": "2.65.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "pnpm build:run",
|
|
@@ -73,8 +73,8 @@ import { type OmegaConfig, type OmegaFormReturn, useOmegaForm } from "./useOmega
|
|
|
73
73
|
|
|
74
74
|
type OnSubmit = NonNullable<FormProps<From, To>["onSubmit"]>
|
|
75
75
|
type OnSubmitArg = Parameters<OnSubmit>[0]
|
|
76
|
-
type OnSubmitEmit = (value: To,
|
|
77
|
-
type OnSubmitAwaitable = (value: To,
|
|
76
|
+
type OnSubmitEmit = (value: To, extra: Pick<OnSubmitArg, "formApi" | "meta">) => void
|
|
77
|
+
type OnSubmitAwaitable = (value: To, extra: Pick<OnSubmitArg, "formApi" | "meta">) => ReturnType<OnSubmit>
|
|
78
78
|
|
|
79
79
|
type OmegaWrapperProps =
|
|
80
80
|
& {
|
|
@@ -113,9 +113,9 @@ const instance = getCurrentInstance()
|
|
|
113
113
|
// we prefer to use the standard abstraction in Vue which separates props (going down) and event emits (going back up)
|
|
114
114
|
// so if isLoading + @submit are provided, we wrap them into a Promise, so that TanStack Form can properly track the submitting state.
|
|
115
115
|
// we use this approach because it means we can keep relying on the built-in beaviour of TanStack Form, and we dont have to re-implement/keep in sync/break any internals.
|
|
116
|
-
const eventOnSubmit: OnSubmitAwaitable = (value,
|
|
116
|
+
const eventOnSubmit: OnSubmitAwaitable = (value, extra) =>
|
|
117
117
|
new Promise<void>((resolve) => {
|
|
118
|
-
instance!.emit("submit", value,
|
|
118
|
+
instance!.emit("submit", value, extra)
|
|
119
119
|
// even if the emit would be immediately handled, prop changes are not published/received immediately.
|
|
120
120
|
// so we have to wait for the prop to change to true, and back to false again.
|
|
121
121
|
const handle = watch(() => props.isLoading, (v) => {
|
|
@@ -133,7 +133,7 @@ const onSubmit_ = typeof props.isLoading !== "undefined"
|
|
|
133
133
|
? computed(() => props.onSubmit)
|
|
134
134
|
: undefined
|
|
135
135
|
|
|
136
|
-
const onSubmitHandler = onSubmit_?.value ? ({formApi, meta, value }: OnSubmitArg) => onSubmit_!.value!(value, meta, formApi) : undefined
|
|
136
|
+
const onSubmitHandler = onSubmit_?.value ? ({formApi, meta, value }: OnSubmitArg) => onSubmit_!.value!(value, { meta, formApi }) : undefined
|
|
137
137
|
|
|
138
138
|
const localForm = props.form || !props.schema
|
|
139
139
|
? undefined
|