@effect-app/vue-components 0.18.13 → 0.18.15

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.
@@ -28,7 +28,7 @@ export type FormProps<From, To> = Omit<FormOptions<From, FormValidateOrFn<From>
28
28
  formApi: OmegaFormParams<From, To>;
29
29
  meta: any;
30
30
  value: To;
31
- }) => Promise<any> | RuntimeFiber<any, any>;
31
+ }) => Promise<any> | RuntimeFiber<any, any> | Effect.Effect<RuntimeFiber<any, any>, any, never>;
32
32
  };
33
33
  export type OmegaFormParams<From, To> = FormApi<From, FormValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, StandardSchemaV1<From, To>, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, Record<string, any> | undefined>;
34
34
  export type OmegaFormState<From, To> = FormState<From, FormValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, StandardSchemaV1<From, To>, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined>;
@@ -1,5 +1,5 @@
1
1
  import { type DeepKeys } from "@tanstack/vue-form";
2
- import { S } from "effect-app";
2
+ import { Effect, S } from "effect-app";
3
3
  import { type InjectionKey } from "vue";
4
4
  import { type InputProps } from "./InputProps";
5
5
  import { type FieldValidators, type FilterItems, type FormProps, type MetaRecord, type NestedKeyOf, type OmegaFormApi, type TypeOverride } from "./OmegaFormStuff";
@@ -24,7 +24,8 @@ export type OmegaConfig<T> = {
24
24
  interface OF<From, To> extends OmegaFormApi<From, To> {
25
25
  meta: MetaRecord<From>;
26
26
  filterItems?: FilterItems;
27
- clear: () => void;
27
+ /** @experimental */
28
+ handleSubmitEffect: (meta?: Record<string, any>) => Effect.Effect<void, never, never>;
28
29
  }
29
30
  export declare const OmegaFormKey: InjectionKey<OF<any, any>>;
30
31
  type __VLS_PrettifyLocal<T> = {
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as F, getCurrentInstance as B, computed as v, onBeforeMount as C, watch as g, createElementBlock as O, openBlock as S, withModifiers as I, createElementVNode as L, unref as m, renderSlot as d, createCommentVNode as V, Fragment as k } from "vue";
2
2
  import { useStore as h } from "@tanstack/vue-form";
3
- import { getOmegaStore as $ } from "./vue-components.es26.js";
3
+ import { getOmegaStore as $ } from "./vue-components.es25.js";
4
4
  import { provideOmegaErrors as A } from "./vue-components.es8.js";
5
5
  import { useOmegaForm as K } from "./vue-components.es9.js";
6
6
  const _ = ["disabled"], D = /* @__PURE__ */ F({
@@ -1,5 +1,5 @@
1
1
  import { Exit as c, Runtime as s } from "effect";
2
- import { dual as n, isFunction as m } from "./vue-components.es24.js";
2
+ import { dual as n, isFunction as m } from "./vue-components.es26.js";
3
3
  const i = Symbol.for("clone-trait"), u = n(2, (e, t) => i in e ? e[i](t) : Object.setPrototypeOf(t, Object.getPrototypeOf(e)));
4
4
  n(2, (e, t) => u(e, { ...e, ...m(t) ? t(e) : t }));
5
5
  const b = (e) => new Promise((t, r) => e.addObserver((o) => {
@@ -1,4 +1,4 @@
1
- import { isFunction as c } from "./vue-components.es24.js";
1
+ import { isFunction as c } from "./vue-components.es26.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,44 +1,92 @@
1
- const f = (c) => typeof c == "function", a = function(c, r) {
2
- switch (c) {
3
- case 0:
4
- case 1:
5
- throw new RangeError(`Invalid arity ${c}`);
6
- case 2:
7
- return function(n, t) {
8
- return arguments.length >= 2 ? r(n, t) : function(e) {
9
- return r(e, n);
10
- };
11
- };
12
- case 3:
13
- return function(n, t, e) {
14
- return arguments.length >= 3 ? r(n, t, e) : function(u) {
15
- return r(u, n, t);
16
- };
17
- };
18
- case 4:
19
- return function(n, t, e, u) {
20
- return arguments.length >= 4 ? r(n, t, e, u) : function(i) {
21
- return r(i, n, t, e);
22
- };
23
- };
24
- case 5:
25
- return function(n, t, e, u, i) {
26
- return arguments.length >= 5 ? r(n, t, e, u, i) : function(s) {
27
- return r(s, n, t, e, u);
28
- };
29
- };
30
- default:
31
- return function() {
32
- if (arguments.length >= c)
33
- return r.apply(this, arguments);
34
- const n = arguments;
35
- return function(t) {
36
- return r(t, ...n);
37
- };
38
- };
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.es28.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
+ ]);
39
88
  }
40
- };
89
+ });
41
90
  export {
42
- a as dual,
43
- f as isFunction
91
+ J as default
44
92
  };
@@ -1,92 +1,13 @@
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.es28.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
+ import { useStore as u } from "@tanstack/vue-form";
2
+ import { computed as f } from "vue";
3
+ function c(o, t) {
4
+ return f(() => t ? u(o.store, (n) => {
5
+ const r = {};
6
+ for (const e of t)
7
+ r[e] = n[e];
8
+ return r;
9
+ }).value : {});
10
+ }
90
11
  export {
91
- J as default
12
+ c as getOmegaStore
92
13
  };
@@ -1,13 +1,44 @@
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
+ const f = (c) => typeof c == "function", a = function(c, r) {
2
+ switch (c) {
3
+ case 0:
4
+ case 1:
5
+ throw new RangeError(`Invalid arity ${c}`);
6
+ case 2:
7
+ return function(n, t) {
8
+ return arguments.length >= 2 ? r(n, t) : function(e) {
9
+ return r(e, n);
10
+ };
11
+ };
12
+ case 3:
13
+ return function(n, t, e) {
14
+ return arguments.length >= 3 ? r(n, t, e) : function(u) {
15
+ return r(u, n, t);
16
+ };
17
+ };
18
+ case 4:
19
+ return function(n, t, e, u) {
20
+ return arguments.length >= 4 ? r(n, t, e, u) : function(i) {
21
+ return r(i, n, t, e);
22
+ };
23
+ };
24
+ case 5:
25
+ return function(n, t, e, u, i) {
26
+ return arguments.length >= 5 ? r(n, t, e, u, i) : function(s) {
27
+ return r(s, n, t, e, u);
28
+ };
29
+ };
30
+ default:
31
+ return function() {
32
+ if (arguments.length >= c)
33
+ return r.apply(this, arguments);
34
+ const n = arguments;
35
+ return function(t) {
36
+ return r(t, ...n);
37
+ };
38
+ };
39
+ }
40
+ };
11
41
  export {
12
- c as getOmegaStore
42
+ a as dual,
43
+ f as isFunction
13
44
  };
@@ -1,4 +1,4 @@
1
- import f from "./vue-components.es25.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.es25.js";
3
+ import F from "./vue-components.es24.js";
4
4
  const P = /* @__PURE__ */ d({
5
5
  inheritAttrs: !1,
6
6
  __name: "OmegaInput",
@@ -1,127 +1,142 @@
1
- import { useForm as F } from "@tanstack/vue-form";
2
- import { S as P, Fiber as v } from "effect-app";
3
- import { runtimeFiberAsPromise as E } from "./vue-components.es22.js";
4
- import { isObject as O } from "./vue-components.es23.js";
5
- import { computed as S, onUnmounted as I, onMounted as R, onBeforeUnmount as A, provide as N } from "vue";
6
- import D from "./vue-components.es6.js";
1
+ import { useForm as U } from "@tanstack/vue-form";
2
+ import { S as F, Fiber as p, Effect as o } from "effect-app";
3
+ import { runtimeFiberAsPromise as O } from "./vue-components.es22.js";
4
+ import { isObject as I } from "./vue-components.es23.js";
5
+ import { computed as b, onUnmounted as R, onMounted as A, onBeforeUnmount as D, provide as M } from "vue";
6
+ import N from "./vue-components.es6.js";
7
7
  import { generateMetaFromSchema as J } from "./vue-components.es10.js";
8
- const K = Symbol("OmegaForm"), k = (d, i, n) => {
9
- if (!d) throw new Error("Schema is required");
10
- const b = P.standardSchemaV1(d), { filterItems: g, meta: a } = J(d), o = S(() => {
11
- if (n?.persistency?.id)
12
- return n.persistency.id;
13
- const e = window.location.pathname, r = Object.keys(a);
8
+ const K = Symbol("OmegaForm"), z = (f, i, a) => {
9
+ if (!f) throw new Error("Schema is required");
10
+ const g = F.standardSchemaV1(f), { filterItems: V, meta: u } = J(f), l = b(() => {
11
+ if (a?.persistency?.id)
12
+ return a.persistency.id;
13
+ const e = window.location.pathname, r = Object.keys(u);
14
14
  return `${e}-${r.join("-")}`;
15
- }), V = () => {
15
+ }), E = () => {
16
16
  const e = new URLSearchParams(window.location.search);
17
- e.delete(o.value);
17
+ e.delete(l.value);
18
18
  const r = new URL(window.location.href);
19
19
  r.search = e.toString(), window.history.replaceState({}, "", r.toString());
20
20
  };
21
- function m(e, r) {
22
- for (const s in r)
23
- r[s] && O(r[s]) ? (e[s] || (e[s] = {}), m(e[s], r[s])) : e[s] = r[s];
21
+ function S(e, r) {
22
+ for (const t in r)
23
+ r[t] && I(r[t]) ? (e[t] || (e[t] = {}), S(e[t], r[t])) : e[t] = r[t];
24
24
  return e;
25
25
  }
26
- const L = S(() => {
27
- if (i?.defaultValues && !n?.persistency?.overrideDefaultValues)
26
+ const P = b(() => {
27
+ if (i?.defaultValues && !a?.persistency?.overrideDefaultValues)
28
28
  return i?.defaultValues;
29
29
  let e;
30
- const r = n?.persistency;
30
+ const r = a?.persistency;
31
31
  if (!r?.policies || r.policies.length === 0) return {};
32
32
  if (r.policies.includes("querystring"))
33
33
  try {
34
- const t = new URLSearchParams(window.location.search).get(o.value);
35
- V(), t && (e = JSON.parse(t));
36
- } catch (s) {
37
- console.error(s);
34
+ const s = new URLSearchParams(window.location.search).get(l.value);
35
+ E(), s && (e = JSON.parse(s));
36
+ } catch (t) {
37
+ console.error(t);
38
38
  }
39
39
  if (
40
40
  // query string has higher priority than local/session storage
41
41
  !e && (r.policies.includes("local") || r.policies.includes("session"))
42
42
  ) {
43
- const s = r.policies.includes("local") ? localStorage : sessionStorage;
44
- if (s)
43
+ const t = r.policies.includes("local") ? localStorage : sessionStorage;
44
+ if (t)
45
45
  try {
46
- const t = JSON.parse(
47
- s.getItem(o.value) || "{}"
46
+ const s = JSON.parse(
47
+ t.getItem(l.value) || "{}"
48
48
  );
49
- s.removeItem(o.value), e = t;
50
- } catch (t) {
51
- console.error(t);
49
+ t.removeItem(l.value), e = s;
50
+ } catch (s) {
51
+ console.error(s);
52
52
  }
53
53
  }
54
54
  if (e ??= {}, i?.defaultValues == null)
55
55
  return e;
56
56
  {
57
- const s = i?.defaultValues;
58
- return m(s, e);
57
+ const t = i?.defaultValues;
58
+ return S(t, e);
59
59
  }
60
- }), l = F({
60
+ }), c = U({
61
61
  ...i,
62
62
  validators: {
63
- onSubmit: b,
63
+ onSubmit: g,
64
64
  ...i?.validators || {}
65
65
  },
66
- onSubmit: i?.onSubmit ? ({ formApi: e, meta: r, value: s }) => {
67
- const t = i.onSubmit({
66
+ onSubmit: i?.onSubmit ? ({ formApi: e, meta: r, value: t }) => {
67
+ const s = i.onSubmit({
68
68
  formApi: e,
69
69
  meta: r,
70
- value: s
70
+ value: t
71
71
  });
72
- return v.isFiber(t) && v.isRuntimeFiber(t) ? E(t) : t;
72
+ return p.isFiber(s) && p.isRuntimeFiber(s) ? O(s) : o.isEffect(s) ? o.runPromise(
73
+ s.pipe(
74
+ r?.currentSpan ? o.withParentSpan(r.currentSpan) : (n) => n,
75
+ o.flatMap((n) => p.join(n))
76
+ )
77
+ ) : s;
73
78
  } : void 0,
74
- defaultValues: L.value
75
- }), U = () => {
76
- Object.keys(a).forEach((e) => {
77
- l.setFieldValue(e, void 0);
79
+ defaultValues: P.value
80
+ }), j = () => {
81
+ Object.keys(u).forEach((e) => {
82
+ c.setFieldValue(e, void 0);
78
83
  });
79
- }, p = (e) => e.reduce((r, s) => {
80
- const t = s.split(".");
81
- return t.reduce((c, u, j) => (j === t.length - 1 ? c[u] = l.getFieldValue(s) : c[u] = c[u] ?? {}, c[u]), r), r;
82
- }, {}), w = (e) => {
84
+ }, w = (e) => e.reduce((r, t) => {
85
+ const s = t.split(".");
86
+ return s.reduce((n, d, L) => (L === s.length - 1 ? n[d] = c.getFieldValue(t) : n[d] = n[d] ?? {}, n[d]), r), r;
87
+ }, {}), h = (e) => {
83
88
  if (e) {
84
89
  if (Array.isArray(e.keys))
85
- return p(e.keys);
90
+ return w(e.keys);
86
91
  if (Array.isArray(e.banKeys)) {
87
- const r = Object.keys(a).filter((s) => e.banKeys?.includes(s));
88
- return p(r);
92
+ const r = Object.keys(u).filter((t) => e.banKeys?.includes(t));
93
+ return w(r);
89
94
  }
90
- return l.store.state.values;
95
+ return c.store.state.values;
91
96
  }
92
- }, f = () => {
93
- const e = n?.persistency;
97
+ }, m = () => {
98
+ const e = a?.persistency;
94
99
  if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
95
100
  const r = e.policies.includes("local") ? localStorage : sessionStorage;
96
101
  if (!r) return;
97
- const s = w(e);
98
- return r.setItem(o.value, JSON.stringify(s));
102
+ const t = h(e);
103
+ return r.setItem(l.value, JSON.stringify(t));
99
104
  }
100
105
  }, y = () => {
101
- const e = n?.persistency;
106
+ const e = a?.persistency;
102
107
  if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
103
- const r = w(e), s = new URLSearchParams(window.location.search);
104
- s.set(o.value, JSON.stringify(r));
105
- const t = new URL(window.location.href);
106
- t.search = s.toString(), window.history.replaceState({}, "", t.toString());
108
+ const r = h(e), t = new URLSearchParams(window.location.search);
109
+ t.set(l.value, JSON.stringify(r));
110
+ const s = new URL(window.location.href);
111
+ s.search = t.toString(), window.history.replaceState({}, "", s.toString());
107
112
  }
108
113
  };
109
- I(f), R(() => {
110
- window.addEventListener("beforeunload", f), window.addEventListener("blur", y);
111
- }), A(() => {
112
- window.removeEventListener("beforeunload", f), window.removeEventListener("blur", y);
114
+ R(m), A(() => {
115
+ window.addEventListener("beforeunload", m), window.addEventListener("blur", y);
116
+ }), D(() => {
117
+ window.removeEventListener("beforeunload", m), window.removeEventListener("blur", y);
113
118
  });
114
- const h = Object.assign(l, {
115
- meta: a,
116
- filterItems: g,
117
- clear: U
119
+ const v = Object.assign(c, {
120
+ meta: u,
121
+ filterItems: V,
122
+ clear: j,
123
+ /** @experimental */
124
+ handleSubmitEffect: (e) => o.currentSpan.pipe(
125
+ o.orDie,
126
+ o.flatMap(
127
+ (r) => (
128
+ // TODO: fix type of handleSubmit, TSubmitMeta is somehow async validator :D
129
+ o.promise(() => c.handleSubmit({ currentSpan: r, ...e }))
130
+ )
131
+ )
132
+ )
118
133
  });
119
- return N(K, h), Object.assign(h, {
120
- Input: D,
121
- Field: l.Field
134
+ return M(K, v), Object.assign(v, {
135
+ Input: N,
136
+ Field: c.Field
122
137
  });
123
138
  };
124
139
  export {
125
140
  K as OmegaFormKey,
126
- k as useOmegaForm
141
+ z as useOmegaForm
127
142
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "0.18.13",
3
+ "version": "0.18.15",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "@tanstack/vue-form": "1.2.4",
@@ -53,7 +53,7 @@
53
53
  "dependencies": {
54
54
  "highlight.js": "^11.11.1",
55
55
  "vue3-highlightjs": "^1.0.5",
56
- "@effect-app/vue": "2.55.6",
56
+ "@effect-app/vue": "2.55.7",
57
57
  "effect-app": "3.3.4"
58
58
  },
59
59
  "scripts": {
@@ -60,7 +60,7 @@ export type FormProps<From, To> =
60
60
  formApi: OmegaFormParams<From, To>
61
61
  meta: any
62
62
  value: To
63
- }) => Promise<any> | RuntimeFiber<any, any>
63
+ }) => Promise<any> | RuntimeFiber<any, any> | Effect.Effect<RuntimeFiber<any, any>, any, never>
64
64
  }
65
65
 
66
66
  export type OmegaFormParams<From, To> = FormApi<
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
 
4
4
  import { type DeepKeys, type FormAsyncValidateOrFn, type FormValidateOrFn, type StandardSchemaV1, useForm } from "@tanstack/vue-form"
5
- import { Fiber, S } from "effect-app"
5
+ import { Effect, Fiber, S } from "effect-app"
6
6
  import { runtimeFiberAsPromise } from "effect-app/utils"
7
7
  import { isObject } from "effect/Predicate"
8
8
  import { computed, type InjectionKey, onBeforeUnmount, onMounted, onUnmounted, provide } from "vue"
@@ -35,7 +35,8 @@ export type OmegaConfig<T> = {
35
35
  interface OF<From, To> extends OmegaFormApi<From, To> {
36
36
  meta: MetaRecord<From>
37
37
  filterItems?: FilterItems
38
- clear: () => void
38
+ /** @experimental */
39
+ handleSubmitEffect: (meta?: Record<string, any>) => Effect.Effect<void, never, never>
39
40
  }
40
41
 
41
42
  export const OmegaFormKey = Symbol("OmegaForm") as InjectionKey<OF<any, any>>
@@ -226,6 +227,16 @@ export const useOmegaForm = <
226
227
  if (Fiber.isFiber(r) && Fiber.isRuntimeFiber(r)) {
227
228
  return runtimeFiberAsPromise(r)
228
229
  }
230
+ if (Effect.isEffect(r)) {
231
+ return Effect.runPromise(
232
+ r.pipe(
233
+ meta?.currentSpan
234
+ ? Effect.withParentSpan(meta.currentSpan)
235
+ : (_) => _,
236
+ Effect.flatMap((_) => Fiber.join(_))
237
+ )
238
+ )
239
+ }
229
240
  return r
230
241
  }
231
242
  : undefined,
@@ -311,7 +322,17 @@ export const useOmegaForm = <
311
322
  const formWithExtras: OF<From, To> = Object.assign(form, {
312
323
  meta,
313
324
  filterItems,
314
- clear
325
+ clear,
326
+ /** @experimental */
327
+ handleSubmitEffect: (meta?: Record<string, any>) =>
328
+ Effect.currentSpan.pipe(
329
+ Effect.orDie,
330
+ Effect
331
+ .flatMap((span) =>
332
+ // TODO: fix type of handleSubmit, TSubmitMeta is somehow async validator :D
333
+ Effect.promise(() => form.handleSubmit({ currentSpan: span, ...meta }))
334
+ )
335
+ )
315
336
  })
316
337
 
317
338
  provide(OmegaFormKey, formWithExtras)