@effect-app/vue-components 0.15.29 → 0.16.0

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/README.md CHANGED
@@ -182,3 +182,24 @@ In [tsconfig.json](tsconfig.js), set the following to address [Issue #32](https:
182
182
  ]
183
183
  }
184
184
  ```
185
+
186
+ ### On Submit event
187
+ The :on-submit event could be tricky in `<OmegaForm />` component.
188
+ This is a prop that is basically a map of Tanstack Form `onSubmit` option and accept a function that return a Promise. If you want to use it as an event, you have to manage the state of loading yourself with `@submit` with a function returning `void`
189
+
190
+ E.g.
191
+
192
+ to use it as a Promise based Tanstack way:
193
+ ```html
194
+ <OmegaForm :schema="schema" :on-submit="onSubmit" :subscribe="['values']">
195
+ ```
196
+
197
+ to use it as an event:
198
+ ```html
199
+ <OmegaForm :schema="schema" @submit="onSubmit" :is-loading="false" :subscribe="['values']">
200
+ ```
201
+
202
+ this will give you a type error instead, because `:is-loading` is only accepted in event mode
203
+ ```html
204
+ <OmegaForm :schema="schema" :on-submit="onSubmit" :is-loading="false" :subscribe="['values']">
205
+ ```
@@ -1,23 +1,23 @@
1
1
  import { type S } from "effect-app";
2
- import { type OmegaFormState, type ShowErrorsOn } from "./OmegaFormStuff";
2
+ import { type FormProps, type OmegaFormState, type ShowErrorsOn } from "./OmegaFormStuff";
3
3
  import { type OmegaConfig, type OmegaFormReturn } from "./useOmegaForm";
4
4
  declare const _default: <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, K extends keyof OmegaFormState<From, To> = keyof OmegaFormState<From, To>>(__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<{
5
5
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & ({
6
6
  omegaConfig?: OmegaConfig<From>;
7
7
  subscribe?: K[];
8
8
  showErrorsOn?: ShowErrorsOn;
9
- } & Omit<import("@tanstack/vue-form").FormOptions<From, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").StandardSchemaV1<From, To>, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined>, "onSubmit"> & ({
10
- onSubmit?: ((props: {
11
- formApi: import("./OmegaFormStuff").OmegaFormParams<From, To>;
12
- meta: any;
13
- value: To;
14
- }) => Promise<any> | any) | undefined;
15
- } & ({
9
+ } & Omit<FormProps<From, To>, "onSubmit"> & (({
16
10
  form: OmegaFormReturn<From, To>;
17
11
  schema?: undefined;
18
12
  } | {
19
13
  form?: undefined;
20
14
  schema: S.Schema<To, From, never>;
15
+ }) & ({
16
+ isLoading?: undefined;
17
+ onSubmit?: FormProps<From, To>["onSubmit"];
18
+ } | {
19
+ isLoading: boolean;
20
+ onSubmit: (data: To) => void;
21
21
  }))) & {}> & import("vue").PublicProps;
22
22
  expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
23
23
  attrs: any;
@@ -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-fd69dadb]{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-fd69dadb]{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-57a15ff7]{display:contents}fieldset[disabled][data-v-57a15ff7]>*{pointer-events:none}")),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-57a15ff7]{display:contents}fieldset[disabled][data-v-57a15ff7]>*{pointer-events:none}")),this.shadowRoot.appendChild(o)}},e.call(window.customElements,i,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 m = /* @__PURE__ */ r(o, [["__scopeId", "data-v-fd69dadb"]]);
5
+ const f = /* @__PURE__ */ r(o, [["__scopeId", "data-v-57a15ff7"]]);
6
6
  export {
7
- m as default
7
+ f as default
8
8
  };
@@ -1,9 +1,9 @@
1
- import { defineComponent as w, computed as f, onBeforeMount as E, watch as j, createElementBlock as v, openBlock as b, withModifiers as F, createElementVNode as M, unref as c, renderSlot as p, createCommentVNode as k, Fragment as V } from "vue";
2
- import { useStore as g } from "@tanstack/vue-form";
3
- import { getOmegaStore as B } from "./vue-components.es24.js";
4
- import { provideOmegaErrors as C } from "./vue-components.es8.js";
5
- import { useOmegaForm as I } from "./vue-components.es9.js";
6
- const $ = ["disabled"], N = /* @__PURE__ */ w({
1
+ import { defineComponent as M, getCurrentInstance as F, computed as p, onBeforeMount as B, watch as b, createElementBlock as v, openBlock as g, withModifiers as C, createElementVNode as I, unref as m, renderSlot as c, createCommentVNode as L, Fragment as V } from "vue";
2
+ import { useStore as O } from "@tanstack/vue-form";
3
+ import { getOmegaStore as k } from "./vue-components.es25.js";
4
+ import { provideOmegaErrors as $ } from "./vue-components.es8.js";
5
+ import { useOmegaForm as A } from "./vue-components.es9.js";
6
+ const K = ["disabled"], W = /* @__PURE__ */ M({
7
7
  __name: "OmegaWrapper",
8
8
  props: {
9
9
  omegaConfig: {},
@@ -15,99 +15,111 @@ const $ = ["disabled"], N = /* @__PURE__ */ w({
15
15
  asyncDebounceMs: {},
16
16
  validators: {},
17
17
  onSubmitMeta: {},
18
- onSubmitInvalid: { type: Function },
18
+ onSubmitInvalid: {},
19
19
  transform: {},
20
- onSubmit: { type: Function },
21
20
  form: {},
22
- schema: {}
21
+ schema: {},
22
+ isLoading: { type: Boolean, default: void 0 },
23
+ onSubmit: {}
23
24
  },
24
- setup(O) {
25
- const o = O, m = f(() => {
26
- if (!(o.form || !o.schema))
27
- return I(o.schema, o, o.omegaConfig);
28
- }), t = f(() => o.form ?? m.value);
29
- E(() => {
25
+ setup(S) {
26
+ const o = S, h = F(), y = ({ value: e }) => {
27
+ new Promise((r) => {
28
+ h.emit("submit", e);
29
+ const n = b(() => o.isLoading, (t) => {
30
+ t || (r(), n.stop());
31
+ });
32
+ });
33
+ }, u = o.form || !o.schema ? void 0 : A(
34
+ o.schema,
35
+ {
36
+ ...o,
37
+ onSubmit: typeof o.isLoading < "u" ? y : o.onSubmit
38
+ },
39
+ o.omegaConfig
40
+ ), s = p(() => o.form ?? u);
41
+ B(() => {
30
42
  if (!o.form) return;
31
- const e = Object.keys(o.form.options || {}), s = /* @__PURE__ */ new Set([
43
+ const e = Object.keys(o.form.options || {}), r = /* @__PURE__ */ new Set([
32
44
  "omegaConfig",
33
45
  "subscribe",
34
46
  "showErrorsOn",
35
47
  "asyncAlways",
36
48
  "form",
37
49
  "schema"
38
- ]), i = Object.fromEntries(
50
+ ]), n = Object.fromEntries(
39
51
  Object.entries(o).filter(
40
- ([a, u]) => !s.has(a) && u !== void 0
52
+ ([a, f]) => a === "isLoading" ? !1 : !r.has(a) && f !== void 0
41
53
  )
42
- ), r = Object.keys(i), n = e.filter(
43
- (a) => r.includes(a) && i[a] !== void 0
54
+ ), t = Object.keys(n), i = e.filter(
55
+ (a) => t.includes(a) && n[a] !== void 0
44
56
  );
45
- n.length > 0 && console.warn(
57
+ i.length > 0 && console.warn(
46
58
  `[OmegaWrapper] Overlapping keys found between form options and filtered props:
47
- ${n.join(
59
+ ${i.join(
48
60
  `,
49
61
  `
50
62
  )}.
51
63
  Props will overwrite existing form options. This might indicate a configuration issue.`
52
64
  );
53
- const S = {
54
- ...t.value.options,
55
- ...i
65
+ const j = {
66
+ ...s.value.options,
67
+ ...n
56
68
  };
57
- t.value.options = Object.fromEntries(
69
+ s.value.options = Object.fromEntries(
58
70
  // TODO
59
- Object.entries(S).filter(
60
- ([a, u]) => u !== void 0
71
+ Object.entries(j).filter(
72
+ ([a, f]) => f !== void 0
61
73
  )
62
74
  );
63
75
  });
64
- const h = g(
65
- t.value.store,
76
+ const w = O(
77
+ s.value.store,
66
78
  (e) => e.isSubmitting
67
- ), d = B(
68
- t.value,
79
+ ), d = k(
80
+ s.value,
69
81
  o.subscribe
70
- ), y = g(
71
- t.value.store,
82
+ ), E = O(
83
+ s.value.store,
72
84
  (e) => e.submissionAttempts
73
- ), l = f(() => t.value.useStore((e) => e.errors));
74
- return j(
75
- () => [t.value.filterItems, l.value.value],
85
+ ), l = p(() => s.value.useStore((e) => e.errors));
86
+ return b(
87
+ () => [s.value.filterItems, l.value.value],
76
88
  () => {
77
- const e = t.value.filterItems, s = l.value.value;
78
- return e ? s ? (Object.values(s).filter(
79
- (r) => !!r
89
+ const e = s.value.filterItems, r = l.value.value;
90
+ return e ? r ? (Object.values(r).filter(
91
+ (t) => !!t
80
92
  ).flatMap(
81
- (r) => Object.values(r).flat().map((n) => n.message)
82
- ).some((r) => r === e.message) && e.items.forEach((r) => {
83
- const n = t.value.getFieldMeta(r);
84
- n && t.value.setFieldMeta(r, {
85
- ...n,
93
+ (t) => Object.values(t).flat().map((i) => i.message)
94
+ ).some((t) => t === e.message) && e.items.forEach((t) => {
95
+ const i = s.value.getFieldMeta(t);
96
+ i && s.value.setFieldMeta(t, {
97
+ ...i,
86
98
  errorMap: {
87
99
  onSubmit: [
88
- { path: [r], message: e.message }
100
+ { path: [t], message: e.message }
89
101
  ]
90
102
  }
91
103
  });
92
104
  }), {}) : {} : {};
93
105
  }
94
- ), C(y, l.value, o.showErrorsOn), (e, s) => (b(), v("form", {
106
+ ), $(E, l.value, o.showErrorsOn), (e, r) => (g(), v("form", {
95
107
  novalidate: "",
96
- onSubmit: s[0] || (s[0] = F((i) => t.value.handleSubmit(), ["prevent", "stop"]))
108
+ onSubmit: r[0] || (r[0] = C((n) => s.value.handleSubmit(), ["prevent", "stop"]))
97
109
  }, [
98
- M("fieldset", { disabled: c(h) }, [
99
- o.form ? (b(), v(V, { key: 0 }, [
100
- p(e.$slots, "externalForm", { subscribedValues: c(d) }, void 0, !0),
101
- p(e.$slots, "default", {}, void 0, !0)
102
- ], 64)) : m.value ? p(e.$slots, "internalForm", {
110
+ I("fieldset", { disabled: m(w) }, [
111
+ o.form ? (g(), v(V, { key: 0 }, [
112
+ c(e.$slots, "externalForm", { subscribedValues: m(d) }, void 0, !0),
113
+ c(e.$slots, "default", {}, void 0, !0)
114
+ ], 64)) : m(u) ? c(e.$slots, "internalForm", {
103
115
  key: 1,
104
- form: m.value,
105
- subscribedValues: c(d)
106
- }, void 0, !0) : k("", !0)
107
- ], 8, $)
116
+ form: m(u),
117
+ subscribedValues: m(d)
118
+ }, void 0, !0) : L("", !0)
119
+ ], 8, K)
108
120
  ], 32));
109
121
  }
110
122
  });
111
123
  export {
112
- N as default
124
+ W as default
113
125
  };
@@ -1,4 +1,4 @@
1
- import { isFunction as c } from "./vue-components.es25.js";
1
+ import { isFunction as c } from "./vue-components.es23.js";
2
2
  const s = c, t = (o) => typeof o == "object" && o !== null, i = (o) => t(o) || s(o);
3
3
  export {
4
4
  s as isFunction,
@@ -1,92 +1,4 @@
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.es27.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
- });
1
+ const o = (n) => typeof n == "function";
90
2
  export {
91
- J as default
3
+ o as isFunction
92
4
  };
@@ -1,13 +1,92 @@
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
- }
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.es27.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
- c as getOmegaStore
91
+ J as default
13
92
  };
@@ -1,4 +1,13 @@
1
- const o = (n) => typeof n == "function";
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
+ }
2
11
  export {
3
- o as isFunction
12
+ c as getOmegaStore
4
13
  };
@@ -1,4 +1,4 @@
1
- import f from "./vue-components.es23.js";
1
+ import f from "./vue-components.es24.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as d, inject as f, computed as r, createBlock as n, openBlock as m, resolveDynamicComponent as c, withCtx as l, createCommentVNode as v, mergeProps as y, renderSlot as g, normalizeProps as h, guardReactiveProps as b } from "vue";
2
2
  import { generateInputStandardSchemaFromFieldMeta as C } from "./vue-components.es10.js";
3
- import F from "./vue-components.es23.js";
3
+ import F from "./vue-components.es24.js";
4
4
  const P = /* @__PURE__ */ d({
5
5
  inheritAttrs: !1,
6
6
  __name: "OmegaInput",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "0.15.29",
3
+ "version": "0.16.0",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "@tanstack/vue-form": "1.2.4",
@@ -66,20 +66,20 @@
66
66
  */
67
67
  /* eslint-disable @typescript-eslint/no-explicit-any */
68
68
  import { type StandardSchemaV1Issue, useStore } from "@tanstack/vue-form"
69
- import { type S } from "effect-app"
70
- import { computed, onBeforeMount, watch } from "vue"
69
+ import { type Record, type S } from "effect-app"
70
+ import { computed, getCurrentInstance, onBeforeMount, watch } from "vue"
71
71
  import { getOmegaStore } from "./getOmegaStore"
72
72
  import { provideOmegaErrors } from "./OmegaErrorsContext"
73
73
  import { type FilterItems, type FormProps, type OmegaFormApi, type OmegaFormState, type ShowErrorsOn } from "./OmegaFormStuff"
74
74
  import { type OmegaConfig, type OmegaFormReturn, useOmegaForm } from "./useOmegaForm"
75
75
 
76
- const props = defineProps<
76
+ type OmegaWrapperProps =
77
77
  & {
78
78
  omegaConfig?: OmegaConfig<From>
79
79
  subscribe?: K[]
80
80
  showErrorsOn?: ShowErrorsOn
81
81
  }
82
- & FormProps<From, To>
82
+ & Omit<FormProps<From, To>, "onSubmit">
83
83
  & (
84
84
  | {
85
85
  form: OmegaFormReturn<From, To>
@@ -90,16 +90,53 @@ const props = defineProps<
90
90
  schema: S.Schema<To, From, never>
91
91
  }
92
92
  )
93
- >()
93
+ & (
94
+ | {
95
+ isLoading?: undefined
96
+ onSubmit?: FormProps<From, To>["onSubmit"]
97
+ }
98
+ | {
99
+ isLoading: boolean
100
+ onSubmit: (data: To) => void
101
+ }
102
+ )
94
103
 
95
- const localForm = computed(() => {
96
- if (props.form || !props.schema) {
97
- return undefined
98
- }
99
- return useOmegaForm<From, To>(props.schema, props, props.omegaConfig)
104
+ const props = withDefaults(defineProps<OmegaWrapperProps>(), {
105
+ isLoading: undefined
100
106
  })
101
107
 
102
- const formToUse = computed(() => props.form ?? localForm.value!)
108
+ const instance = getCurrentInstance()
109
+
110
+ // we prefer to use the standard abstraction in Vue which separates props (going down) and event emits (going back up)
111
+ // so if isLoading + @submit are provided, we wrap them into a Promise, so that TanStack Form can properly track the submitting state.
112
+ // 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.
113
+ const eventOnSubmit: FormProps<From, To>["onSubmit"] = ({ value }) => {
114
+ new Promise<void>((resolve) => {
115
+ instance!.emit("submit", value)
116
+ // even if the emit would be immediately handled, prop changes are not published/received immediately.
117
+ // so we have to wait for the prop to change to true, and back to false again.
118
+ const handle = watch(() => props.isLoading, (v) => {
119
+ if (v) return
120
+ resolve()
121
+ handle.stop()
122
+ })
123
+ })
124
+ }
125
+
126
+ const localForm = props.form || !props.schema
127
+ ? undefined
128
+ : useOmegaForm<From, To>(
129
+ props.schema,
130
+ {
131
+ ...props,
132
+ onSubmit: typeof props.isLoading !== "undefined"
133
+ ? eventOnSubmit
134
+ : props.onSubmit
135
+ },
136
+ props.omegaConfig
137
+ )
138
+
139
+ const formToUse = computed(() => props.form ?? localForm!)
103
140
 
104
141
  onBeforeMount(() => {
105
142
  if (!props.form) return
@@ -116,17 +153,22 @@ onBeforeMount(() => {
116
153
 
117
154
  const filteredProps = Object.fromEntries(
118
155
  Object.entries(props).filter(
119
- ([key, value]) =>
120
- !excludedKeys.has(key as keyof typeof props) && value !== undefined
156
+ ([key, value]) => {
157
+ if (key === "isLoading") {
158
+ return false
159
+ }
160
+ return !excludedKeys.has(key as keyof typeof props)
161
+ && value !== undefined
162
+ }
121
163
  )
122
- ) as Partial<typeof props>
164
+ ) as Record<string, unknown>
123
165
 
124
166
  const propsKeys = Object.keys(filteredProps)
125
167
 
126
168
  const overlappingKeys = formOptionsKeys.filter(
127
169
  (key) =>
128
170
  propsKeys.includes(key)
129
- && filteredProps[key as keyof typeof props] !== undefined
171
+ && filteredProps[key] !== undefined
130
172
  )
131
173
 
132
174
  if (overlappingKeys.length > 0) {
@@ -227,5 +269,9 @@ defineSlots<{
227
269
  <style scoped>
228
270
  fieldset {
229
271
  display: contents;
272
+
273
+ &[disabled] > * {
274
+ pointer-events: none;
275
+ }
230
276
  }
231
277
  </style>