@effect-app/vue-components 0.2.6 → 0.2.8
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/OmegaErrors.vue.d.ts +2 -2
- package/dist/types/components/OmegaForm/OmegaErrorsContext.d.ts +8 -5
- package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +1 -0
- package/dist/types/components/OmegaForm/OmegaInput.vue.d.ts +0 -1
- package/dist/types/components/OmegaForm/OmegaInputVuetify.vue.d.ts +1 -0
- package/dist/types/components/OmegaForm/OmegaInternalInput.vue.d.ts +0 -1
- package/dist/types/components/OmegaForm/OmegaWrapper.vue.d.ts +2 -1
- package/dist/types/components/OmegaForm/index.d.ts +2 -0
- package/dist/vue-components.es11.js +23 -22
- package/dist/vue-components.es14.js +29 -29
- package/dist/vue-components.es15.js +40 -36
- package/dist/vue-components.es18.js +13 -12
- package/dist/vue-components.es4.js +29 -21
- package/dist/vue-components.es7.js +2 -2
- package/dist/vue-components.es9.js +2 -2
- package/package.json +1 -1
- package/src/components/OmegaForm/OmegaErrors.vue +2 -5
- package/src/components/OmegaForm/OmegaErrorsContext.ts +16 -3
- package/src/components/OmegaForm/OmegaFormStuff.ts +2 -0
- package/src/components/OmegaForm/OmegaInputVuetify.vue +7 -6
- package/src/components/OmegaForm/OmegaInternalInput.vue +15 -12
- package/src/components/OmegaForm/OmegaWrapper.vue +3 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mdiLink } from "@mdi/js";
|
|
2
2
|
declare const vuetified: import("vue").Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions, {}, any> | undefined;
|
|
3
|
-
declare const errors: import("vue").Ref<readonly import("./OmegaFormStuff").OmegaError[], readonly import("./OmegaFormStuff").OmegaError[]>,
|
|
3
|
+
declare const errors: import("vue").Ref<readonly import("./OmegaFormStuff").OmegaError[], readonly import("./OmegaFormStuff").OmegaError[]>, showErrors: import("vue").Ref<boolean, boolean>;
|
|
4
4
|
declare const trans: (id: string, values?: Record<string, import("intl-messageformat").PrimitiveType | import("intl-messageformat").FormatXMLElementFn<string, string>>) => string;
|
|
5
5
|
declare const showedGeneralErrors: import("vue").ComputedRef<string[]>;
|
|
6
6
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
@@ -15,7 +15,7 @@ declare const __VLS_self: import("vue").DefineComponent<{}, {
|
|
|
15
15
|
mdiLink: typeof mdiLink;
|
|
16
16
|
vuetified: typeof vuetified;
|
|
17
17
|
errors: typeof errors;
|
|
18
|
-
|
|
18
|
+
showErrors: typeof showErrors;
|
|
19
19
|
trans: typeof trans;
|
|
20
20
|
showedGeneralErrors: typeof showedGeneralErrors;
|
|
21
21
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { type InjectionKey, type Ref } from "vue";
|
|
2
|
-
import type
|
|
2
|
+
import { type OmegaError, type ShowErrorsOn } from "./OmegaFormStuff";
|
|
3
3
|
import type { StandardSchemaV1Issue } from "@tanstack/vue-form";
|
|
4
4
|
export declare const OmegaErrorsKey: InjectionKey<{
|
|
5
5
|
errors: Ref<readonly OmegaError[]>;
|
|
6
6
|
addError: (error: OmegaError) => void;
|
|
7
7
|
removeError: (inputId: string) => void;
|
|
8
8
|
clearErrors: () => void;
|
|
9
|
-
|
|
9
|
+
showErrors: Ref<boolean>;
|
|
10
|
+
showErrorsOn: ShowErrorsOn;
|
|
10
11
|
generalErrors: Ref<(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined>;
|
|
11
12
|
}>;
|
|
12
|
-
export declare function provideOmegaErrors(formSubmissionAttempts: Ref<number>, generalErrors: Ref<(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined
|
|
13
|
+
export declare function provideOmegaErrors(formSubmissionAttempts: Ref<number>, generalErrors: Ref<(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined>, showErrorsOn?: ShowErrorsOn): {
|
|
13
14
|
errors: Readonly<Ref<readonly {
|
|
14
15
|
readonly label: string;
|
|
15
16
|
readonly inputId: string;
|
|
@@ -22,14 +23,16 @@ export declare function provideOmegaErrors(formSubmissionAttempts: Ref<number>,
|
|
|
22
23
|
addError: (error: OmegaError) => void;
|
|
23
24
|
removeError: (inputId: string) => void;
|
|
24
25
|
clearErrors: () => void;
|
|
25
|
-
|
|
26
|
+
showErrors: import("vue").ComputedRef<boolean>;
|
|
26
27
|
generalErrors: Ref<(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined, (Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined>;
|
|
28
|
+
showErrorsOn: ShowErrorsOn;
|
|
27
29
|
};
|
|
28
30
|
export declare function useOmegaErrors(): {
|
|
29
31
|
errors: Ref<readonly OmegaError[]>;
|
|
30
32
|
addError: (error: OmegaError) => void;
|
|
31
33
|
removeError: (inputId: string) => void;
|
|
32
34
|
clearErrors: () => void;
|
|
33
|
-
|
|
35
|
+
showErrors: Ref<boolean>;
|
|
36
|
+
showErrorsOn: ShowErrorsOn;
|
|
34
37
|
generalErrors: Ref<(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined>;
|
|
35
38
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { S, type Effect } from "effect-app";
|
|
2
2
|
import { type FormAsyncValidateOrFn, type FormValidateOrFn, type StandardSchemaV1, type FormApi, type VueFormApi, type FieldComponent, type FormOptions, type DeepKeys, type FieldValidateOrFn, type FieldAsyncValidateOrFn, type FormState } from "@tanstack/vue-form";
|
|
3
3
|
import type { Component } from "vue";
|
|
4
|
+
export type ShowErrorsOn = "onChange" | "onBlur" | "onSubmit";
|
|
4
5
|
export type TypeOverride = "string" | "text" | "number" | "select" | "multiple" | "boolean" | "autocomplete" | "autocompletemultiple";
|
|
5
6
|
export interface OmegaError {
|
|
6
7
|
label: string;
|
|
@@ -5,6 +5,7 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
|
|
|
5
5
|
readonly onFocus?: ((event: Event) => any) | undefined;
|
|
6
6
|
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onBlur" | "onFocus"> & {
|
|
7
7
|
inputProps: InputProps<T>;
|
|
8
|
+
vuetifyValue: unknown;
|
|
8
9
|
} & Partial<{}>> & import("vue").PublicProps;
|
|
9
10
|
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
|
|
10
11
|
attrs: any;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type S } from "effect-app";
|
|
2
|
-
import { type FilterItems, type MetaRecord, type OmegaFormApi, type OmegaFormState } from "./OmegaFormStuff";
|
|
2
|
+
import { type FilterItems, type MetaRecord, type OmegaFormApi, type OmegaFormState, type ShowErrorsOn } from "./OmegaFormStuff";
|
|
3
3
|
declare const _default: <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, K extends keyof OmegaFormState<To, From> = keyof OmegaFormState<To, From>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
4
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & ({
|
|
5
5
|
subscribe?: K[];
|
|
6
|
+
showErrorsOn?: ShowErrorsOn;
|
|
6
7
|
} & ({
|
|
7
8
|
form: OmegaFormApi<To, From> & {
|
|
8
9
|
meta: MetaRecord<To>;
|
|
@@ -8,6 +8,7 @@ export { default } from "./OmegaWrapper.vue";
|
|
|
8
8
|
export { OmegaForm, OmegaInput, OmegaErrors };
|
|
9
9
|
declare const OmegaFormCE: new <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, K extends keyof import("./OmegaFormStuff").OmegaFormState<To, From> = keyof import("./OmegaFormStuff").OmegaFormState<To, From>>(initialProps?: Record<string, any>) => import("vue").VueElement & ((({
|
|
10
10
|
subscribe?: K[] | undefined;
|
|
11
|
+
showErrorsOn?: import("./OmegaFormStuff").ShowErrorsOn | undefined;
|
|
11
12
|
form: import("./OmegaFormStuff").OmegaFormApi<To, From> & {
|
|
12
13
|
meta: import("./OmegaFormStuff").MetaRecord<To>;
|
|
13
14
|
filterItems?: import("./OmegaFormStuff").FilterItems;
|
|
@@ -15,6 +16,7 @@ declare const OmegaFormCE: new <From extends Record<PropertyKey, any>, To extend
|
|
|
15
16
|
schema?: undefined | undefined;
|
|
16
17
|
} | {
|
|
17
18
|
subscribe?: K[] | undefined;
|
|
19
|
+
showErrorsOn?: import("./OmegaFormStuff").ShowErrorsOn | undefined;
|
|
18
20
|
defaultValues?: To | undefined;
|
|
19
21
|
defaultState?: Partial<import("@tanstack/vue-form").FormState<To, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").StandardSchemaV1<To, From>, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined>> | undefined;
|
|
20
22
|
asyncAlways?: boolean | undefined;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { defineComponent as d, watch as b, createElementBlock as S, openBlock as g, withModifiers as v, unref as
|
|
1
|
+
import { defineComponent as d, watch as b, createElementBlock as S, openBlock as g, withModifiers as v, unref as n, createElementVNode as h, renderSlot as O } from "vue";
|
|
2
2
|
import { useStore as i } from "@tanstack/vue-form";
|
|
3
|
-
import { getOmegaStore as
|
|
4
|
-
import { provideOmegaErrors as
|
|
5
|
-
import { useOmegaForm as
|
|
6
|
-
const
|
|
3
|
+
import { getOmegaStore as M } from "./vue-components.es16.js";
|
|
4
|
+
import { provideOmegaErrors as y } from "./vue-components.es4.js";
|
|
5
|
+
import { useOmegaForm as E } from "./vue-components.es5.js";
|
|
6
|
+
const w = ["disabled"], A = /* @__PURE__ */ d({
|
|
7
7
|
__name: "OmegaWrapper",
|
|
8
8
|
props: {
|
|
9
9
|
subscribe: {},
|
|
10
|
+
showErrorsOn: {},
|
|
10
11
|
form: {},
|
|
11
12
|
schema: {},
|
|
12
13
|
defaultValues: {},
|
|
@@ -20,11 +21,11 @@ const I = ["disabled"], A = /* @__PURE__ */ d({
|
|
|
20
21
|
onSubmit: { type: Function }
|
|
21
22
|
},
|
|
22
23
|
setup(u, { expose: l }) {
|
|
23
|
-
const
|
|
24
|
+
const s = u, t = s.form ?? E(s.schema, s), f = i(t.store, (e) => e.isSubmitting);
|
|
24
25
|
l(t);
|
|
25
|
-
const c =
|
|
26
|
+
const c = M(
|
|
26
27
|
t,
|
|
27
|
-
|
|
28
|
+
s.subscribe
|
|
28
29
|
), p = i(
|
|
29
30
|
t.store,
|
|
30
31
|
(e) => e.submissionAttempts
|
|
@@ -34,28 +35,28 @@ const I = ["disabled"], A = /* @__PURE__ */ d({
|
|
|
34
35
|
() => {
|
|
35
36
|
const e = t.filterItems;
|
|
36
37
|
return e ? o.value ? (Object.values(o.value).filter(
|
|
37
|
-
(
|
|
38
|
+
(r) => !!r
|
|
38
39
|
).flatMap(
|
|
39
|
-
(
|
|
40
|
-
).some((
|
|
41
|
-
const
|
|
42
|
-
t.setFieldMeta(
|
|
43
|
-
...
|
|
40
|
+
(r) => Object.values(r).flat().map((m) => m.message)
|
|
41
|
+
).some((r) => r === e.message) && e.items.forEach((r) => {
|
|
42
|
+
const m = t.getFieldMeta(r);
|
|
43
|
+
t.setFieldMeta(r, {
|
|
44
|
+
...m,
|
|
44
45
|
errorMap: {
|
|
45
|
-
onSubmit: [{ path: [
|
|
46
|
+
onSubmit: [{ path: [r], message: e.message }]
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
49
|
}), {}) : {} : {};
|
|
49
50
|
}
|
|
50
|
-
),
|
|
51
|
-
onSubmit:
|
|
51
|
+
), y(p, o, s.showErrorsOn), (e, a) => (g(), S("form", {
|
|
52
|
+
onSubmit: a[0] || (a[0] = v((r) => n(t).handleSubmit(), ["prevent", "stop"]))
|
|
52
53
|
}, [
|
|
53
|
-
h("fieldset", { disabled:
|
|
54
|
-
|
|
55
|
-
form:
|
|
56
|
-
subscribedValues:
|
|
54
|
+
h("fieldset", { disabled: n(f) }, [
|
|
55
|
+
O(e.$slots, "default", {
|
|
56
|
+
form: n(t),
|
|
57
|
+
subscribedValues: n(c)
|
|
57
58
|
}, void 0, !0)
|
|
58
|
-
], 8,
|
|
59
|
+
], 8, w)
|
|
59
60
|
], 32));
|
|
60
61
|
}
|
|
61
62
|
});
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useOmegaErrors as
|
|
3
|
-
import { mdiLink as
|
|
4
|
-
import { useIntl as
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as C, getCurrentInstance as x, computed as B, createBlock as o, openBlock as t, Transition as b, withCtx as l, createElementBlock as c, createCommentVNode as w, unref as e, renderSlot as I, normalizeProps as V, guardReactiveProps as N, resolveDynamicComponent as s, normalizeClass as O, createElementVNode as d, toDisplayString as u, Fragment as g, renderList as k, createTextVNode as y } from "vue";
|
|
2
|
+
import { useOmegaErrors as z } from "./vue-components.es4.js";
|
|
3
|
+
import { mdiLink as D } from "@mdi/js";
|
|
4
|
+
import { useIntl as G } from "./vue-components.es3.js";
|
|
5
|
+
const L = {
|
|
6
6
|
key: 0,
|
|
7
7
|
class: "error-alert"
|
|
8
|
-
},
|
|
8
|
+
}, M = { class: "text-h6 mb-3" }, P = { class: "font-weight-medium" }, S = { class: "error-message" }, T = ["href"], $ = { key: 1 }, H = /* @__PURE__ */ C({
|
|
9
9
|
__name: "OmegaErrors",
|
|
10
|
-
setup(
|
|
11
|
-
const
|
|
10
|
+
setup(j) {
|
|
11
|
+
const m = x(), f = m == null ? void 0 : m.appContext.components.VAlert, { errors: n, generalErrors: _, showErrors: E } = z(), { trans: h } = G(), p = B(() => _.value ? _.value.filter(
|
|
12
12
|
(i) => !!i
|
|
13
13
|
).flatMap(
|
|
14
|
-
(i) => Object.values(i).filter((
|
|
15
|
-
(
|
|
14
|
+
(i) => Object.values(i).filter((a) => !!a).flatMap(
|
|
15
|
+
(a) => a.filter(
|
|
16
16
|
(r) => !!(r != null && r.message)
|
|
17
17
|
).map((r) => r.message)
|
|
18
18
|
)
|
|
19
19
|
) : []);
|
|
20
|
-
return (i,
|
|
20
|
+
return (i, a) => (t(), o(b, null, {
|
|
21
21
|
default: l(() => [
|
|
22
|
-
e(
|
|
22
|
+
e(E) && (e(n).length || p.value.length) ? (t(), c("div", L, [
|
|
23
23
|
I(i.$slots, "default", V(N({ errors: e(n), showedGeneralErrors: p.value })), () => [
|
|
24
|
-
(t(), o(
|
|
24
|
+
(t(), o(s(e(f) ? "v-alert" : "div"), {
|
|
25
25
|
class: O([e(f) ? "mb-4" : "error-alert-content", "mb-4"]),
|
|
26
26
|
type: "error",
|
|
27
27
|
variant: "tonal",
|
|
@@ -29,24 +29,24 @@ const D = {
|
|
|
29
29
|
"aria-live": "polite"
|
|
30
30
|
}, {
|
|
31
31
|
default: l(() => [
|
|
32
|
-
|
|
33
|
-
e(n).length ? (t(), o(
|
|
32
|
+
d("div", M, u(e(h)("form.includes_error")) + ":", 1),
|
|
33
|
+
e(n).length ? (t(), o(s(e(n).length > 1 ? "ul" : "div"), {
|
|
34
34
|
key: 0,
|
|
35
35
|
class: "error-list"
|
|
36
36
|
}, {
|
|
37
37
|
default: l(() => [
|
|
38
|
-
(t(!0),
|
|
38
|
+
(t(!0), c(g, null, k(e(n), (r) => (t(), o(s(e(n).length > 1 ? "li" : "div"), {
|
|
39
39
|
key: r.inputId,
|
|
40
40
|
class: "error-item"
|
|
41
41
|
}, {
|
|
42
42
|
default: l(() => [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
(t(), o(
|
|
43
|
+
d("div", P, u(r.label), 1),
|
|
44
|
+
d("div", S, [
|
|
45
|
+
(t(), o(s(r.errors.length > 1 ? "ul" : "div"), { class: "error-list" }, {
|
|
46
46
|
default: l(() => [
|
|
47
|
-
(t(!0),
|
|
47
|
+
(t(!0), c(g, null, k(r.errors, (v) => (t(), o(s(r.errors.length > 1 ? "li" : "span"), { key: v }, {
|
|
48
48
|
default: l(() => [
|
|
49
|
-
y(
|
|
49
|
+
y(u(v), 1)
|
|
50
50
|
]),
|
|
51
51
|
_: 2
|
|
52
52
|
}, 1024))), 128))
|
|
@@ -54,27 +54,27 @@ const D = {
|
|
|
54
54
|
_: 2
|
|
55
55
|
}, 1024))
|
|
56
56
|
]),
|
|
57
|
-
|
|
57
|
+
d("a", {
|
|
58
58
|
href: `#${r.inputId}`,
|
|
59
59
|
class: "error-link"
|
|
60
60
|
}, [
|
|
61
|
-
(t(), o(
|
|
62
|
-
icon: e(
|
|
61
|
+
(t(), o(s(e(f) ? "v-icon" : "i"), {
|
|
62
|
+
icon: e(D),
|
|
63
63
|
"aria-hidden": "true"
|
|
64
64
|
}, {
|
|
65
|
-
default: l(() =>
|
|
66
|
-
|
|
65
|
+
default: l(() => a[0] || (a[0] = [
|
|
66
|
+
d("i", null, "🔗", -1)
|
|
67
67
|
])),
|
|
68
68
|
_: 1
|
|
69
69
|
}, 8, ["icon"])),
|
|
70
|
-
y(" " +
|
|
71
|
-
], 8,
|
|
70
|
+
y(" " + u(e(h)("form.fix_input")), 1)
|
|
71
|
+
], 8, T)
|
|
72
72
|
]),
|
|
73
73
|
_: 2
|
|
74
74
|
}, 1024))), 128))
|
|
75
75
|
]),
|
|
76
76
|
_: 1
|
|
77
|
-
})) : (t(),
|
|
77
|
+
})) : (t(), c("span", $, u(p.value[0]), 1))
|
|
78
78
|
]),
|
|
79
79
|
_: 1
|
|
80
80
|
}, 8, ["class"]))
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");if(n.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;-webkit-appearance:none;-moz-appearance:none;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),document.head.appendChild(n),window.customElements){const e=window.customElements.define;window.customElements.define=function(o,t){const a=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(a&&a.call(this),this.shadowRoot){const i=document.createElement("style");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;-webkit-appearance:none;-moz-appearance:none;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),this.shadowRoot.appendChild(i)}},e.call(window.customElements,o,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { useStore as
|
|
4
|
-
import { useOmegaErrors as
|
|
5
|
-
import
|
|
2
|
+
import { defineComponent as k, getCurrentInstance as B, useId as L, computed as n, watch as x, onMounted as P, ref as S, watchEffect as A, renderSlot as D, normalizeProps as F, guardReactiveProps as M, createElementVNode as N, createBlock as R, createCommentVNode as T, unref as U, openBlock as z, mergeProps as j } from "vue";
|
|
3
|
+
import { useStore as G } from "@tanstack/vue-form";
|
|
4
|
+
import { useOmegaErrors as H } from "./vue-components.es4.js";
|
|
5
|
+
import J from "./vue-components.es18.js";
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const Z = /* @__PURE__ */ k({
|
|
8
8
|
inheritAttrs: !1,
|
|
9
9
|
__name: "OmegaInternalInput",
|
|
10
10
|
props: {
|
|
@@ -15,73 +15,77 @@ const Q = /* @__PURE__ */ C({
|
|
|
15
15
|
type: {},
|
|
16
16
|
validators: {}
|
|
17
17
|
},
|
|
18
|
-
setup(
|
|
19
|
-
const e =
|
|
18
|
+
setup(_) {
|
|
19
|
+
const e = _, l = B(), q = l == null ? void 0 : l.appContext.components.VTextField, o = L(), u = e.field, a = G(u.store, (t) => t), p = n(() => {
|
|
20
20
|
var t, r;
|
|
21
21
|
return e.type ? e.type : ((t = e.meta) == null ? void 0 : t.type) === "string" ? e.meta.format === "email" ? "email" : "string" : ((r = e.meta) == null ? void 0 : r.type) || "unknown";
|
|
22
|
-
}),
|
|
22
|
+
}), s = n(() => a.value.value), d = n(
|
|
23
23
|
() => (
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
25
|
a.value.meta.errors.map((t) => t == null ? void 0 : t.message).filter(Boolean)
|
|
26
26
|
)
|
|
27
27
|
);
|
|
28
|
-
|
|
29
|
-
() => [!!
|
|
28
|
+
x(
|
|
29
|
+
() => [!!s.value],
|
|
30
30
|
() => {
|
|
31
31
|
var t, r;
|
|
32
|
-
|
|
32
|
+
d.value.length && !s.value && !((t = e.meta) != null && t.required) && u.setValue(
|
|
33
33
|
((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "undefined" ? void 0 : null
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
|
-
),
|
|
36
|
+
), P(() => {
|
|
37
37
|
var t, r;
|
|
38
|
-
!
|
|
38
|
+
!s.value && !((t = e.meta) != null && t.required) && ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "null" && u.setValue(null);
|
|
39
39
|
});
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
D(() => {
|
|
44
|
-
w.value > 0 && (s.value = !0);
|
|
40
|
+
const { addError: C, removeError: I, showErrors: O, showErrorsOn: $ } = H(), i = S(!1);
|
|
41
|
+
A(() => {
|
|
42
|
+
(O.value || $ === "onChange") && (i.value = !0);
|
|
45
43
|
});
|
|
46
|
-
const
|
|
47
|
-
|
|
44
|
+
const f = () => {
|
|
45
|
+
i.value = !0;
|
|
46
|
+
}, v = n(() => !i.value && p.value !== "select" ? [] : d.value);
|
|
47
|
+
x(
|
|
48
48
|
() => a.value.meta.errors,
|
|
49
49
|
() => {
|
|
50
|
-
a.value.meta.errors.length ?
|
|
50
|
+
a.value.meta.errors.length ? C({
|
|
51
51
|
inputId: o,
|
|
52
52
|
errors: a.value.meta.errors.map((t) => t.message).filter(Boolean),
|
|
53
53
|
label: e.label
|
|
54
|
-
}) :
|
|
54
|
+
}) : I(o);
|
|
55
55
|
}
|
|
56
56
|
);
|
|
57
|
-
const
|
|
58
|
-
var t, r,
|
|
57
|
+
const m = n(() => {
|
|
58
|
+
var t, r, c, g, y, h, b, E, V, w;
|
|
59
59
|
return {
|
|
60
60
|
id: o,
|
|
61
61
|
required: (t = e.meta) == null ? void 0 : t.required,
|
|
62
|
-
minLength: ((r = e.meta) == null ? void 0 : r.type) === "string" && ((
|
|
62
|
+
minLength: ((r = e.meta) == null ? void 0 : r.type) === "string" && ((c = e.meta) == null ? void 0 : c.minLength),
|
|
63
63
|
maxLength: ((g = e.meta) == null ? void 0 : g.type) === "string" && ((y = e.meta) == null ? void 0 : y.maxLength),
|
|
64
64
|
max: ((h = e.meta) == null ? void 0 : h.type) === "number" && ((b = e.meta) == null ? void 0 : b.maximum),
|
|
65
|
-
min: ((
|
|
65
|
+
min: ((E = e.meta) == null ? void 0 : E.type) === "number" && ((V = e.meta) == null ? void 0 : V.minimum),
|
|
66
66
|
name: e.field.name,
|
|
67
67
|
modelValue: e.field.state.value,
|
|
68
|
-
errorMessages:
|
|
69
|
-
error: !!
|
|
68
|
+
errorMessages: v.value,
|
|
69
|
+
error: !!v.value.length,
|
|
70
70
|
field: e.field,
|
|
71
71
|
setRealDirty: f,
|
|
72
|
-
type:
|
|
73
|
-
label: `${e.label}${(
|
|
72
|
+
type: p.value,
|
|
73
|
+
label: `${e.label}${(w = e.meta) != null && w.required ? " *" : ""}`,
|
|
74
74
|
options: e.options
|
|
75
75
|
};
|
|
76
76
|
});
|
|
77
|
-
return (t, r) =>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
return (t, r) => D(t.$slots, "default", F(M(m.value)), () => [
|
|
78
|
+
N("div", { onFocusout: f }, [
|
|
79
|
+
U(q) ? (z(), R(J, j({
|
|
80
|
+
key: 0,
|
|
81
|
+
"input-props": m.value
|
|
82
|
+
}, t.$attrs, {
|
|
83
|
+
"vuetify-value": m.value.field.state.value
|
|
84
|
+
}), null, 16, ["input-props", "vuetify-value"])) : T("", !0)
|
|
85
|
+
], 32)
|
|
82
86
|
]);
|
|
83
87
|
}
|
|
84
88
|
});
|
|
85
89
|
export {
|
|
86
|
-
|
|
90
|
+
Z as default
|
|
87
91
|
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { defineComponent as P, resolveComponent as
|
|
1
|
+
import { defineComponent as P, resolveComponent as u, createElementBlock as g, openBlock as o, createBlock as n, createCommentVNode as l, mergeProps as s } from "vue";
|
|
2
2
|
const b = /* @__PURE__ */ P({
|
|
3
3
|
inheritAttrs: !1,
|
|
4
4
|
__name: "OmegaInputVuetify",
|
|
5
5
|
props: {
|
|
6
|
-
inputProps: {}
|
|
6
|
+
inputProps: {},
|
|
7
|
+
vuetifyValue: {}
|
|
7
8
|
},
|
|
8
9
|
emits: ["focus", "blur"],
|
|
9
|
-
setup(
|
|
10
|
+
setup(y) {
|
|
10
11
|
return (e, r) => {
|
|
11
|
-
const a =
|
|
12
|
+
const a = u("v-checkbox"), i = u("v-text-field"), t = u("v-textarea"), m = u("v-select"), d = u("v-autocomplete");
|
|
12
13
|
return o(), g("div", {
|
|
13
14
|
class: "omega-input",
|
|
14
15
|
onFocusout: r[4] || (r[4] = (p) => e.$emit("blur", p)),
|
|
@@ -23,10 +24,10 @@ const b = /* @__PURE__ */ P({
|
|
|
23
24
|
error: e.inputProps.error,
|
|
24
25
|
ripple: ""
|
|
25
26
|
}, e.$attrs, {
|
|
26
|
-
"model-value": e.
|
|
27
|
+
"model-value": e.vuetifyValue,
|
|
27
28
|
onChange: r[0] || (r[0] = (p) => e.inputProps.field.handleChange(p.target.checked))
|
|
28
29
|
}), null, 16, ["id", "name", "label", "error-messages", "error", "model-value"])) : l("", !0),
|
|
29
|
-
e.inputProps.type === "email" || e.inputProps.type === "string" ? (o(), n(
|
|
30
|
+
e.inputProps.type === "email" || e.inputProps.type === "string" ? (o(), n(i, s({
|
|
30
31
|
key: 1,
|
|
31
32
|
id: e.inputProps.id,
|
|
32
33
|
required: e.inputProps.required,
|
|
@@ -38,7 +39,7 @@ const b = /* @__PURE__ */ P({
|
|
|
38
39
|
"error-messages": e.inputProps.errorMessages,
|
|
39
40
|
error: e.inputProps.error
|
|
40
41
|
}, e.$attrs, {
|
|
41
|
-
"model-value": e.
|
|
42
|
+
"model-value": e.vuetifyValue,
|
|
42
43
|
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
43
44
|
}), null, 16, ["id", "required", "min-length", "max-length", "type", "name", "label", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
|
|
44
45
|
e.inputProps.type === "text" ? (o(), n(t, s({
|
|
@@ -53,10 +54,10 @@ const b = /* @__PURE__ */ P({
|
|
|
53
54
|
"error-messages": e.inputProps.errorMessages,
|
|
54
55
|
error: e.inputProps.error
|
|
55
56
|
}, e.$attrs, {
|
|
56
|
-
"model-value": e.
|
|
57
|
+
"model-value": e.vuetifyValue,
|
|
57
58
|
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
58
59
|
}), null, 16, ["id", "required", "min-length", "max-length", "type", "name", "label", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
|
|
59
|
-
e.inputProps.type === "number" ? (o(), n(
|
|
60
|
+
e.inputProps.type === "number" ? (o(), n(i, s({
|
|
60
61
|
key: 3,
|
|
61
62
|
id: e.inputProps.id,
|
|
62
63
|
required: e.inputProps.required,
|
|
@@ -68,7 +69,7 @@ const b = /* @__PURE__ */ P({
|
|
|
68
69
|
"error-messages": e.inputProps.errorMessages,
|
|
69
70
|
error: e.inputProps.error
|
|
70
71
|
}, e.$attrs, {
|
|
71
|
-
"model-value": e.
|
|
72
|
+
"model-value": e.vuetifyValue,
|
|
72
73
|
"onUpdate:modelValue": r[1] || (r[1] = (p) => {
|
|
73
74
|
e.inputProps.field.handleChange(Number(p));
|
|
74
75
|
})
|
|
@@ -86,7 +87,7 @@ const b = /* @__PURE__ */ P({
|
|
|
86
87
|
"error-messages": e.inputProps.errorMessages,
|
|
87
88
|
error: e.inputProps.error
|
|
88
89
|
}, e.$attrs, {
|
|
89
|
-
"model-value": e.
|
|
90
|
+
"model-value": e.vuetifyValue,
|
|
90
91
|
onClear: r[2] || (r[2] = (p) => e.inputProps.field.handleChange(void 0)),
|
|
91
92
|
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
92
93
|
}), null, 16, ["id", "clearable", "required", "multiple", "chips", "name", "label", "items", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
|
|
@@ -103,7 +104,7 @@ const b = /* @__PURE__ */ P({
|
|
|
103
104
|
error: e.inputProps.error,
|
|
104
105
|
chips: e.inputProps.type === "autocompletemultiple"
|
|
105
106
|
}, e.$attrs, {
|
|
106
|
-
"model-value": e.
|
|
107
|
+
"model-value": e.vuetifyValue,
|
|
107
108
|
onClear: r[3] || (r[3] = (p) => e.inputProps.field.handleChange(void 0)),
|
|
108
109
|
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
109
110
|
}), null, 16, ["id", "clearable", "multiple", "required", "name", "label", "items", "error-messages", "error", "chips", "model-value", "onUpdate:modelValue"])) : l("", !0)
|
|
@@ -1,30 +1,38 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const r =
|
|
5
|
-
r.value = r.value.filter((
|
|
6
|
-
},
|
|
7
|
-
|
|
8
|
-
},
|
|
1
|
+
import { ref as l, computed as p, readonly as v, provide as E, inject as f } from "vue";
|
|
2
|
+
const u = Symbol();
|
|
3
|
+
function h(e, a, t = "onSubmit") {
|
|
4
|
+
const r = l([]), n = (o) => {
|
|
5
|
+
r.value = r.value.filter((d) => d.inputId !== o);
|
|
6
|
+
}, c = (o) => {
|
|
7
|
+
n(o.inputId), r.value.push(o);
|
|
8
|
+
}, i = () => {
|
|
9
9
|
r.value = [];
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
}, m = p(() => {
|
|
11
|
+
switch (t) {
|
|
12
|
+
case "onChange":
|
|
13
|
+
return !0;
|
|
14
|
+
default:
|
|
15
|
+
return e.value > 0;
|
|
16
|
+
}
|
|
17
|
+
}), s = {
|
|
18
|
+
errors: v(r),
|
|
19
|
+
addError: c,
|
|
20
|
+
removeError: n,
|
|
21
|
+
clearErrors: i,
|
|
22
|
+
showErrors: m,
|
|
23
|
+
generalErrors: a,
|
|
24
|
+
showErrorsOn: t ?? "onSubmit"
|
|
17
25
|
};
|
|
18
|
-
return
|
|
26
|
+
return E(u, s), s;
|
|
19
27
|
}
|
|
20
|
-
function
|
|
21
|
-
const e =
|
|
28
|
+
function w() {
|
|
29
|
+
const e = f(u);
|
|
22
30
|
if (!e)
|
|
23
31
|
throw new Error("useOmegaErrors must be used within an OmegaForm provider");
|
|
24
32
|
return e;
|
|
25
33
|
}
|
|
26
34
|
export {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
u as OmegaErrorsKey,
|
|
36
|
+
h as provideOmegaErrors,
|
|
37
|
+
w as useOmegaErrors
|
|
30
38
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
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-59131cd0]{display:contents}")),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-59131cd0]{display:contents}")),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.es11.js";
|
|
3
3
|
import m from "./vue-components.es12.js";
|
|
4
|
-
const a = /* @__PURE__ */ m(o, [["__scopeId", "data-v-
|
|
4
|
+
const a = /* @__PURE__ */ m(o, [["__scopeId", "data-v-59131cd0"]]);
|
|
5
5
|
export {
|
|
6
6
|
a as default
|
|
7
7
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");if(t.appendChild(document.createTextNode(".v-enter-from[data-v-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");if(t.appendChild(document.createTextNode(".v-enter-from[data-v-502ecb3a],.v-leave-to[data-v-502ecb3a]{max-height:0px;grid-template-rows:0fr;opacity:0}.v-enter-active[data-v-502ecb3a],.v-leave-active[data-v-502ecb3a]{display:grid;transition:all .15s}.v-enter-to[data-v-502ecb3a],.v-leave-from[data-v-502ecb3a]{grid-template-rows:1fr;max-height:50vh;opacity:1}.error-alert[data-v-502ecb3a]{transition-behavior:allow-discrete;display:grid;overflow:hidden;min-height:0}.error-alert>*[data-v-502ecb3a]{min-height:0}.error-list[data-v-502ecb3a]{container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;gap:.5em;align-items:start}@container (max-width: 28.125rem){.error-list[data-v-502ecb3a]{grid-template-columns:auto 1fr}.error-link[data-v-502ecb3a]{grid-column:1 / -1;justify-self:end}}@container (max-width: 18.75rem){.error-list[data-v-502ecb3a]{grid-template-columns:1fr}.error-message[data-v-502ecb3a]{grid-column:1 / -1}}.error-item[data-v-502ecb3a]{display:contents}a[data-v-502ecb3a]{min-width:min-content}.error-link[data-v-502ecb3a]{align-items:center;color:inherit;display:inline-flex;flex-wrap:wrap;gap:.25em;padding-bottom:1em;text-decoration:none}")),document.head.appendChild(t),window.customElements){const e=window.customElements.define;window.customElements.define=function(n,a){const i=a.prototype.connectedCallback;return a.prototype.connectedCallback=function(){if(i&&i.call(this),this.shadowRoot){const r=document.createElement("style");r.appendChild(document.createTextNode(".v-enter-from[data-v-502ecb3a],.v-leave-to[data-v-502ecb3a]{max-height:0px;grid-template-rows:0fr;opacity:0}.v-enter-active[data-v-502ecb3a],.v-leave-active[data-v-502ecb3a]{display:grid;transition:all .15s}.v-enter-to[data-v-502ecb3a],.v-leave-from[data-v-502ecb3a]{grid-template-rows:1fr;max-height:50vh;opacity:1}.error-alert[data-v-502ecb3a]{transition-behavior:allow-discrete;display:grid;overflow:hidden;min-height:0}.error-alert>*[data-v-502ecb3a]{min-height:0}.error-list[data-v-502ecb3a]{container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;gap:.5em;align-items:start}@container (max-width: 28.125rem){.error-list[data-v-502ecb3a]{grid-template-columns:auto 1fr}.error-link[data-v-502ecb3a]{grid-column:1 / -1;justify-self:end}}@container (max-width: 18.75rem){.error-list[data-v-502ecb3a]{grid-template-columns:1fr}.error-message[data-v-502ecb3a]{grid-column:1 / -1}}.error-item[data-v-502ecb3a]{display:contents}a[data-v-502ecb3a]{min-width:min-content}.error-link[data-v-502ecb3a]{align-items:center;color:inherit;display:inline-flex;flex-wrap:wrap;gap:.25em;padding-bottom:1em;text-decoration:none}")),this.shadowRoot.appendChild(r)}},e.call(window.customElements,n,a)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
2
|
import o from "./vue-components.es14.js";
|
|
3
3
|
import r from "./vue-components.es12.js";
|
|
4
|
-
const e = /* @__PURE__ */ r(o, [["__scopeId", "data-v-
|
|
4
|
+
const e = /* @__PURE__ */ r(o, [["__scopeId", "data-v-502ecb3a"]]);
|
|
5
5
|
export {
|
|
6
6
|
e as default
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Transition>
|
|
3
3
|
<div
|
|
4
|
-
v-if="
|
|
5
|
-
formSubmissionAttempts > 0 &&
|
|
6
|
-
(errors.length || showedGeneralErrors.length)
|
|
7
|
-
"
|
|
4
|
+
v-if="showErrors && (errors.length || showedGeneralErrors.length)"
|
|
8
5
|
class="error-alert"
|
|
9
6
|
>
|
|
10
7
|
<slot v-bind="{ errors, showedGeneralErrors }">
|
|
@@ -75,7 +72,7 @@ import { computed, getCurrentInstance } from "vue"
|
|
|
75
72
|
const instance = getCurrentInstance()
|
|
76
73
|
const vuetified = instance?.appContext.components["VAlert"]
|
|
77
74
|
|
|
78
|
-
const { errors,
|
|
75
|
+
const { errors, generalErrors, showErrors } = useOmegaErrors()
|
|
79
76
|
|
|
80
77
|
const { trans } = useIntl()
|
|
81
78
|
|
|
@@ -5,8 +5,9 @@ import {
|
|
|
5
5
|
ref,
|
|
6
6
|
readonly,
|
|
7
7
|
type Ref,
|
|
8
|
+
computed,
|
|
8
9
|
} from "vue"
|
|
9
|
-
import type
|
|
10
|
+
import { type OmegaError, type ShowErrorsOn } from "./OmegaFormStuff"
|
|
10
11
|
import type { StandardSchemaV1Issue } from "@tanstack/vue-form"
|
|
11
12
|
|
|
12
13
|
export const OmegaErrorsKey = Symbol() as InjectionKey<{
|
|
@@ -14,7 +15,8 @@ export const OmegaErrorsKey = Symbol() as InjectionKey<{
|
|
|
14
15
|
addError: (error: OmegaError) => void
|
|
15
16
|
removeError: (inputId: string) => void
|
|
16
17
|
clearErrors: () => void
|
|
17
|
-
|
|
18
|
+
showErrors: Ref<boolean>
|
|
19
|
+
showErrorsOn: ShowErrorsOn
|
|
18
20
|
generalErrors: Ref<
|
|
19
21
|
(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined
|
|
20
22
|
>
|
|
@@ -25,6 +27,7 @@ export function provideOmegaErrors(
|
|
|
25
27
|
generalErrors: Ref<
|
|
26
28
|
(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined
|
|
27
29
|
>,
|
|
30
|
+
showErrorsOn: ShowErrorsOn = "onSubmit",
|
|
28
31
|
) {
|
|
29
32
|
const errors = ref<OmegaError[]>([])
|
|
30
33
|
|
|
@@ -41,13 +44,23 @@ export function provideOmegaErrors(
|
|
|
41
44
|
errors.value = []
|
|
42
45
|
}
|
|
43
46
|
|
|
47
|
+
const showErrors = computed(() => {
|
|
48
|
+
switch (showErrorsOn) {
|
|
49
|
+
case "onChange":
|
|
50
|
+
return true
|
|
51
|
+
default:
|
|
52
|
+
return formSubmissionAttempts.value > 0
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
|
|
44
56
|
const context = {
|
|
45
57
|
errors: readonly(errors),
|
|
46
58
|
addError,
|
|
47
59
|
removeError,
|
|
48
60
|
clearErrors,
|
|
49
|
-
|
|
61
|
+
showErrors,
|
|
50
62
|
generalErrors,
|
|
63
|
+
showErrorsOn: showErrorsOn ?? "onSubmit",
|
|
51
64
|
}
|
|
52
65
|
|
|
53
66
|
provide(OmegaErrorsKey, context)
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
:error="inputProps.error"
|
|
14
14
|
ripple
|
|
15
15
|
v-bind="$attrs"
|
|
16
|
-
:model-value="
|
|
16
|
+
:model-value="vuetifyValue"
|
|
17
17
|
@change="(e: any) => inputProps.field.handleChange(e.target.checked)"
|
|
18
18
|
/>
|
|
19
19
|
<v-text-field
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
:error-messages="inputProps.errorMessages"
|
|
29
29
|
:error="inputProps.error"
|
|
30
30
|
v-bind="$attrs"
|
|
31
|
-
:model-value="
|
|
31
|
+
:model-value="vuetifyValue"
|
|
32
32
|
@update:model-value="inputProps.field.handleChange"
|
|
33
33
|
/>
|
|
34
34
|
<v-textarea
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
:error-messages="inputProps.errorMessages"
|
|
44
44
|
:error="inputProps.error"
|
|
45
45
|
v-bind="$attrs"
|
|
46
|
-
:model-value="
|
|
46
|
+
:model-value="vuetifyValue"
|
|
47
47
|
@update:model-value="inputProps.field.handleChange"
|
|
48
48
|
/>
|
|
49
49
|
<v-text-field
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
:error-messages="inputProps.errorMessages"
|
|
59
59
|
:error="inputProps.error"
|
|
60
60
|
v-bind="$attrs"
|
|
61
|
-
:model-value="
|
|
61
|
+
:model-value="vuetifyValue"
|
|
62
62
|
@update:model-value="
|
|
63
63
|
(e: any) => {
|
|
64
64
|
inputProps.field.handleChange(Number(e))
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
:error-messages="inputProps.errorMessages"
|
|
79
79
|
:error="inputProps.error"
|
|
80
80
|
v-bind="$attrs"
|
|
81
|
-
:model-value="
|
|
81
|
+
:model-value="vuetifyValue"
|
|
82
82
|
@clear="inputProps.field.handleChange(undefined)"
|
|
83
83
|
@update:model-value="inputProps.field.handleChange"
|
|
84
84
|
/>
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
:error="inputProps.error"
|
|
100
100
|
:chips="inputProps.type === 'autocompletemultiple'"
|
|
101
101
|
v-bind="$attrs"
|
|
102
|
-
:model-value="
|
|
102
|
+
:model-value="vuetifyValue"
|
|
103
103
|
@clear="inputProps.field.handleChange(undefined)"
|
|
104
104
|
@update:model-value="inputProps.field.handleChange"
|
|
105
105
|
/>
|
|
@@ -111,6 +111,7 @@ import type { InputProps } from "./InputProps"
|
|
|
111
111
|
|
|
112
112
|
defineProps<{
|
|
113
113
|
inputProps: InputProps<T>
|
|
114
|
+
vuetifyValue: unknown
|
|
114
115
|
}>()
|
|
115
116
|
|
|
116
117
|
defineEmits<{
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<slot v-bind="inputProps"
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
<slot v-bind="inputProps">
|
|
3
|
+
<div @focusout="setRealDirty">
|
|
4
|
+
<OmegaInputVuetify
|
|
5
|
+
v-if="vuetified"
|
|
6
|
+
:input-props="inputProps"
|
|
7
|
+
v-bind="$attrs"
|
|
8
|
+
:vuetify-value="inputProps.field.state.value"
|
|
9
|
+
/>
|
|
10
|
+
</div>
|
|
8
11
|
</slot>
|
|
9
12
|
</template>
|
|
10
13
|
|
|
@@ -89,20 +92,20 @@ onMounted(() => {
|
|
|
89
92
|
fieldApi.setValue(null)
|
|
90
93
|
}
|
|
91
94
|
})
|
|
95
|
+
const { addError, removeError, showErrors, showErrorsOn } = useOmegaErrors()
|
|
92
96
|
|
|
93
97
|
const realDirty = ref(false)
|
|
94
|
-
const setRealDirty = () => {
|
|
95
|
-
realDirty.value = true
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const { addError, formSubmissionAttempts, removeError } = useOmegaErrors()
|
|
99
98
|
|
|
100
99
|
watchEffect(() => {
|
|
101
|
-
if (
|
|
100
|
+
if (showErrors.value || showErrorsOn === "onChange") {
|
|
102
101
|
realDirty.value = true
|
|
103
102
|
}
|
|
104
103
|
})
|
|
105
104
|
|
|
105
|
+
const setRealDirty = () => {
|
|
106
|
+
realDirty.value = true
|
|
107
|
+
}
|
|
108
|
+
|
|
106
109
|
const showedErrors = computed(() => {
|
|
107
110
|
// single select field can be validated on change
|
|
108
111
|
if (!realDirty.value && fieldType.value !== "select") return []
|
|
@@ -54,6 +54,7 @@ import {
|
|
|
54
54
|
type MetaRecord,
|
|
55
55
|
type OmegaFormApi,
|
|
56
56
|
type OmegaFormState,
|
|
57
|
+
type ShowErrorsOn,
|
|
57
58
|
} from "./OmegaFormStuff"
|
|
58
59
|
import { getOmegaStore } from "./getOmegaStore"
|
|
59
60
|
import { provideOmegaErrors } from "./OmegaErrorsContext"
|
|
@@ -63,6 +64,7 @@ import { watch } from "vue"
|
|
|
63
64
|
const props = defineProps<
|
|
64
65
|
{
|
|
65
66
|
subscribe?: K[]
|
|
67
|
+
showErrorsOn?: ShowErrorsOn
|
|
66
68
|
} & (
|
|
67
69
|
| {
|
|
68
70
|
form: OmegaFormApi<To, From> & {
|
|
@@ -127,7 +129,7 @@ watch(
|
|
|
127
129
|
},
|
|
128
130
|
)
|
|
129
131
|
|
|
130
|
-
provideOmegaErrors(formSubmissionAttempts, errors)
|
|
132
|
+
provideOmegaErrors(formSubmissionAttempts, errors, props.showErrorsOn)
|
|
131
133
|
</script>
|
|
132
134
|
|
|
133
135
|
<style scoped>
|