@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.
@@ -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[]>, formSubmissionAttempts: import("vue").Ref<number, number>;
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
- formSubmissionAttempts: typeof formSubmissionAttempts;
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 { OmegaError } from "./OmegaFormStuff";
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
- formSubmissionAttempts: Ref<number>;
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
- formSubmissionAttempts: Ref<number, number>;
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
- formSubmissionAttempts: Ref<number>;
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;
@@ -36,7 +36,6 @@ declare const _default: <From, To>(__VLS_props: NonNullable<Awaited<typeof __VLS
36
36
  title: string;
37
37
  value: string;
38
38
  }[];
39
- onFocusout: () => void;
40
39
  }) => any) | undefined;
41
40
  };
42
41
  emit: {};
@@ -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;
@@ -34,7 +34,6 @@ declare const _default: <To>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup
34
34
  title: string;
35
35
  value: string;
36
36
  }[];
37
- onFocusout: () => void;
38
37
  }) => any) | undefined;
39
38
  };
40
39
  emit: {};
@@ -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 a, createElementVNode as h, renderSlot as M } from "vue";
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 y } from "./vue-components.es16.js";
4
- import { provideOmegaErrors as O } from "./vue-components.es4.js";
5
- import { useOmegaForm as F } from "./vue-components.es5.js";
6
- const I = ["disabled"], A = /* @__PURE__ */ d({
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 r = u, t = r.form ?? F(r.schema, r), f = i(t.store, (e) => e.isSubmitting);
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 = y(
26
+ const c = M(
26
27
  t,
27
- r.subscribe
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
- (s) => !!s
38
+ (r) => !!r
38
39
  ).flatMap(
39
- (s) => Object.values(s).flat().map((n) => n.message)
40
- ).some((s) => s === e.message) && e.items.forEach((s) => {
41
- const n = t.getFieldMeta(s);
42
- t.setFieldMeta(s, {
43
- ...n,
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: [s], message: e.message }]
46
+ onSubmit: [{ path: [r], message: e.message }]
46
47
  }
47
48
  });
48
49
  }), {}) : {} : {};
49
50
  }
50
- ), O(p, o), (e, m) => (g(), S("form", {
51
- onSubmit: m[0] || (m[0] = v((s) => a(t).handleSubmit(), ["prevent", "stop"]))
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: a(f) }, [
54
- M(e.$slots, "default", {
55
- form: a(t),
56
- subscribedValues: a(c)
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, I)
59
+ ], 8, w)
59
60
  ], 32));
60
61
  }
61
62
  });
@@ -1,27 +1,27 @@
1
- import { defineComponent as E, getCurrentInstance as b, computed as x, createBlock as o, openBlock as t, Transition as B, withCtx as l, createElementBlock as m, createCommentVNode as w, unref as e, renderSlot as I, normalizeProps as V, guardReactiveProps as N, resolveDynamicComponent as a, normalizeClass as O, createElementVNode as u, toDisplayString as d, Fragment as g, renderList as k, createTextVNode as y } from "vue";
2
- import { useOmegaErrors as S } from "./vue-components.es4.js";
3
- import { mdiLink as z } from "@mdi/js";
4
- import { useIntl as A } from "./vue-components.es3.js";
5
- const D = {
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
- }, G = { class: "text-h6 mb-3" }, L = { class: "font-weight-medium" }, M = { class: "error-message" }, P = ["href"], T = { key: 1 }, H = /* @__PURE__ */ E({
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 c = b(), f = c == null ? void 0 : c.appContext.components.VAlert, { errors: n, formSubmissionAttempts: C, generalErrors: _ } = S(), { trans: v } = A(), p = x(() => _.value ? _.value.filter(
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((s) => !!s).flatMap(
15
- (s) => s.filter(
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, s) => (t(), o(B, null, {
20
+ return (i, a) => (t(), o(b, null, {
21
21
  default: l(() => [
22
- e(C) > 0 && (e(n).length || p.value.length) ? (t(), m("div", D, [
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(a(e(f) ? "v-alert" : "div"), {
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
- u("div", G, d(e(v)("form.includes_error")) + ":", 1),
33
- e(n).length ? (t(), o(a(e(n).length > 1 ? "ul" : "div"), {
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), m(g, null, k(e(n), (r) => (t(), o(a(e(n).length > 1 ? "li" : "div"), {
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
- u("div", L, d(r.label), 1),
44
- u("div", M, [
45
- (t(), o(a(r.errors.length > 1 ? "ul" : "div"), { class: "error-list" }, {
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), m(g, null, k(r.errors, (h) => (t(), o(a(r.errors.length > 1 ? "li" : "span"), { key: h }, {
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(d(h), 1)
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
- u("a", {
57
+ d("a", {
58
58
  href: `#${r.inputId}`,
59
59
  class: "error-link"
60
60
  }, [
61
- (t(), o(a(e(f) ? "v-icon" : "i"), {
62
- icon: e(z),
61
+ (t(), o(s(e(f) ? "v-icon" : "i"), {
62
+ icon: e(D),
63
63
  "aria-hidden": "true"
64
64
  }, {
65
- default: l(() => s[0] || (s[0] = [
66
- u("i", null, "🔗", -1)
65
+ default: l(() => a[0] || (a[0] = [
66
+ d("i", null, "🔗", -1)
67
67
  ])),
68
68
  _: 1
69
69
  }, 8, ["icon"])),
70
- y(" " + d(e(v)("form.fix_input")), 1)
71
- ], 8, P)
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(), m("span", T, d(p.value[0]), 1))
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 C, getCurrentInstance as L, useId as O, computed as n, watch as q, onMounted as S, ref as A, watchEffect as D, renderSlot as F, mergeProps as E, createBlock as M, createCommentVNode as P, unref as T, openBlock as U } from "vue";
3
- import { useStore as N } from "@tanstack/vue-form";
4
- import { useOmegaErrors as R } from "./vue-components.es4.js";
5
- import j from "./vue-components.es18.js";
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 Q = /* @__PURE__ */ C({
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(I) {
19
- const e = I, l = L(), $ = l == null ? void 0 : l.appContext.components.VTextField, o = O(), u = e.field, a = N(u.store, (t) => t), i = n(() => {
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
- }), m = n(() => a.value.value), p = n(
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
- q(
29
- () => [!!m.value],
28
+ x(
29
+ () => [!!s.value],
30
30
  () => {
31
31
  var t, r;
32
- p.value.length && !m.value && !((t = e.meta) != null && t.required) && u.setValue(
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
- ), S(() => {
36
+ ), P(() => {
37
37
  var t, r;
38
- !m.value && !((t = e.meta) != null && t.required) && ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "null" && u.setValue(null);
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 s = A(!1), f = () => {
41
- s.value = !0;
42
- }, { addError: k, formSubmissionAttempts: w, removeError: B } = R();
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 d = n(() => !s.value && i.value !== "select" ? [] : p.value);
47
- q(
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 ? k({
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
- }) : B(o);
54
+ }) : I(o);
55
55
  }
56
56
  );
57
- const c = n(() => {
58
- var t, r, v, g, y, h, b, x, V, _;
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" && ((v = e.meta) == null ? void 0 : v.minLength),
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: ((x = e.meta) == null ? void 0 : x.type) === "number" && ((V = e.meta) == null ? void 0 : V.minimum),
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: d.value,
69
- error: !!d.value.length,
68
+ errorMessages: v.value,
69
+ error: !!v.value.length,
70
70
  field: e.field,
71
71
  setRealDirty: f,
72
- type: i.value,
73
- label: `${e.label}${(_ = e.meta) != null && _.required ? " *" : ""}`,
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) => F(t.$slots, "default", E(c.value, { onFocusout: f }), () => [
78
- T($) ? (U(), M(j, E({
79
- key: 0,
80
- "input-props": c.value
81
- }, t.$attrs), null, 16, ["input-props"])) : P("", !0)
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
- Q as default
90
+ Z as default
87
91
  };
@@ -1,14 +1,15 @@
1
- import { defineComponent as P, resolveComponent as i, createElementBlock as g, openBlock as o, createBlock as n, createCommentVNode as l, mergeProps as s } from "vue";
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(v) {
10
+ setup(y) {
10
11
  return (e, r) => {
11
- const a = i("v-checkbox"), u = i("v-text-field"), t = i("v-textarea"), m = i("v-select"), d = i("v-autocomplete");
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.inputProps.field.state.value,
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(u, s({
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.inputProps.field.state.value,
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.inputProps.field.state.value,
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(u, s({
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.inputProps.field.state.value,
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.inputProps.field.state.value,
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.inputProps.field.state.value,
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 m, readonly as d, provide as l, inject as p } from "vue";
2
- const s = Symbol();
3
- function E(e, u) {
4
- const r = m([]), t = (o) => {
5
- r.value = r.value.filter((i) => i.inputId !== o);
6
- }, a = (o) => {
7
- t(o.inputId), r.value.push(o);
8
- }, c = () => {
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
- }, n = {
11
- errors: d(r),
12
- addError: a,
13
- removeError: t,
14
- clearErrors: c,
15
- formSubmissionAttempts: e,
16
- generalErrors: u
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 l(s, n), n;
26
+ return E(u, s), s;
19
27
  }
20
- function f() {
21
- const e = p(s);
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
- s as OmegaErrorsKey,
28
- E as provideOmegaErrors,
29
- f as useOmegaErrors
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-0de09910]{display:contents}")),document.head.appendChild(n),window.customElements){const e=window.customElements.define;window.customElements.define=function(i,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-0de09910]{display:contents}")),this.shadowRoot.appendChild(o)}},e.call(window.customElements,i,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
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-0de09910"]]);
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-fde7a2c8],.v-leave-to[data-v-fde7a2c8]{max-height:0px;grid-template-rows:0fr;opacity:0}.v-enter-active[data-v-fde7a2c8],.v-leave-active[data-v-fde7a2c8]{display:grid;transition:all .15s}.v-enter-to[data-v-fde7a2c8],.v-leave-from[data-v-fde7a2c8]{grid-template-rows:1fr;max-height:50vh;opacity:1}.error-alert[data-v-fde7a2c8]{transition-behavior:allow-discrete;display:grid;overflow:hidden;min-height:0}.error-alert>*[data-v-fde7a2c8]{min-height:0}.error-list[data-v-fde7a2c8]{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-fde7a2c8]{grid-template-columns:auto 1fr}.error-link[data-v-fde7a2c8]{grid-column:1 / -1;justify-self:end}}@container (max-width: 18.75rem){.error-list[data-v-fde7a2c8]{grid-template-columns:1fr}.error-message[data-v-fde7a2c8]{grid-column:1 / -1}}.error-item[data-v-fde7a2c8]{display:contents}a[data-v-fde7a2c8]{min-width:min-content}.error-link[data-v-fde7a2c8]{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(d,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-fde7a2c8],.v-leave-to[data-v-fde7a2c8]{max-height:0px;grid-template-rows:0fr;opacity:0}.v-enter-active[data-v-fde7a2c8],.v-leave-active[data-v-fde7a2c8]{display:grid;transition:all .15s}.v-enter-to[data-v-fde7a2c8],.v-leave-from[data-v-fde7a2c8]{grid-template-rows:1fr;max-height:50vh;opacity:1}.error-alert[data-v-fde7a2c8]{transition-behavior:allow-discrete;display:grid;overflow:hidden;min-height:0}.error-alert>*[data-v-fde7a2c8]{min-height:0}.error-list[data-v-fde7a2c8]{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-fde7a2c8]{grid-template-columns:auto 1fr}.error-link[data-v-fde7a2c8]{grid-column:1 / -1;justify-self:end}}@container (max-width: 18.75rem){.error-list[data-v-fde7a2c8]{grid-template-columns:1fr}.error-message[data-v-fde7a2c8]{grid-column:1 / -1}}.error-item[data-v-fde7a2c8]{display:contents}a[data-v-fde7a2c8]{min-width:min-content}.error-link[data-v-fde7a2c8]{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,d,a)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
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-fde7a2c8"]]);
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "@tanstack/vue-form": "^1.2.4",
@@ -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, formSubmissionAttempts, generalErrors } = useOmegaErrors()
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 { OmegaError } from "./OmegaFormStuff"
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
- formSubmissionAttempts: Ref<number>
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
- formSubmissionAttempts,
61
+ showErrors,
50
62
  generalErrors,
63
+ showErrorsOn: showErrorsOn ?? "onSubmit",
51
64
  }
52
65
 
53
66
  provide(OmegaErrorsKey, context)
@@ -16,6 +16,8 @@ import {
16
16
  import type { Component } from "vue"
17
17
  import { useIntl } from "../../utils"
18
18
 
19
+ export type ShowErrorsOn = "onChange" | "onBlur" | "onSubmit"
20
+
19
21
  export type TypeOverride =
20
22
  | "string"
21
23
  | "text"
@@ -13,7 +13,7 @@
13
13
  :error="inputProps.error"
14
14
  ripple
15
15
  v-bind="$attrs"
16
- :model-value="inputProps.field.state.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="inputProps.field.state.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="inputProps.field.state.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="inputProps.field.state.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="inputProps.field.state.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="inputProps.field.state.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" @focusout="setRealDirty">
3
- <OmegaInputVuetify
4
- v-if="vuetified"
5
- :input-props="inputProps"
6
- v-bind="$attrs"
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 (formSubmissionAttempts.value > 0) {
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>