@effect-app/vue-components 1.8.6 → 1.8.7

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,11 +1,13 @@
1
- import type { StandardSchemaV1Issue } from "@tanstack/vue-form";
2
- import { type OmegaError } from "./OmegaFormStuff";
1
+ import { type OmegaError, type OmegaFormApi } from "./OmegaFormStuff";
3
2
  type __VLS_Props = {
4
- errors: readonly OmegaError[];
5
- generalErrors: (Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined;
3
+ form: OmegaFormApi<any, any>;
4
+ fieldMap: Map<string, {
5
+ id: string;
6
+ label: string;
7
+ }>;
6
8
  };
7
9
  declare var __VLS_6: {
8
- errors: readonly OmegaError[];
10
+ errors: OmegaError[];
9
11
  showedGeneralErrors: string[];
10
12
  };
11
13
  type __VLS_Slots = {} & {
@@ -1,8 +1,8 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");if(a.appendChild(document.createTextNode(".v-enter-from[data-v-4f889c81],.v-leave-to[data-v-4f889c81]{max-height:0px;grid-template-rows:0fr;opacity:0}.v-enter-active[data-v-4f889c81],.v-leave-active[data-v-4f889c81]{display:grid;transition:all .15s}.v-enter-to[data-v-4f889c81],.v-leave-from[data-v-4f889c81]{grid-template-rows:1fr;max-height:50vh;opacity:1}.error-alert[data-v-4f889c81]{transition-behavior:allow-discrete;display:grid;overflow:hidden;min-height:0}.error-alert>*[data-v-4f889c81]{min-height:0}.error-list[data-v-4f889c81]{list-style-position:inside}div.error-list[data-v-4f889c81]{container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;gap:1.5em;align-items:start}@container (max-width: 27.125rem){div.error-list[data-v-4f889c81]{grid-template-columns:auto 1fr}.error-link[data-v-4f889c81]{grid-column:1 / -1;justify-self:end}}@container (max-width: 17.75rem){div.error-list[data-v-4f889c81]{grid-template-columns:1fr}.error-message[data-v-4f889c81]{grid-column:1 / -1}}.error-item[data-v-4f889c81]{display:contents}a[data-v-4f889c81]{min-width:min-content}.error-link[data-v-4f889c81]{align-items:center;color:inherit;display:inline-flex;flex-wrap:wrap;gap:.25em;padding-bottom:1em;text-decoration:none}")),document.head.appendChild(a),window.customElements){const e=window.customElements.define;window.customElements.define=function(n,t){const i=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(i&&i.call(this),this.shadowRoot){const r=document.createElement("style");r.appendChild(document.createTextNode(".v-enter-from[data-v-4f889c81],.v-leave-to[data-v-4f889c81]{max-height:0px;grid-template-rows:0fr;opacity:0}.v-enter-active[data-v-4f889c81],.v-leave-active[data-v-4f889c81]{display:grid;transition:all .15s}.v-enter-to[data-v-4f889c81],.v-leave-from[data-v-4f889c81]{grid-template-rows:1fr;max-height:50vh;opacity:1}.error-alert[data-v-4f889c81]{transition-behavior:allow-discrete;display:grid;overflow:hidden;min-height:0}.error-alert>*[data-v-4f889c81]{min-height:0}.error-list[data-v-4f889c81]{list-style-position:inside}div.error-list[data-v-4f889c81]{container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;gap:1.5em;align-items:start}@container (max-width: 27.125rem){div.error-list[data-v-4f889c81]{grid-template-columns:auto 1fr}.error-link[data-v-4f889c81]{grid-column:1 / -1;justify-self:end}}@container (max-width: 17.75rem){div.error-list[data-v-4f889c81]{grid-template-columns:1fr}.error-message[data-v-4f889c81]{grid-column:1 / -1}}.error-item[data-v-4f889c81]{display:contents}a[data-v-4f889c81]{min-width:min-content}.error-link[data-v-4f889c81]{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,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
1
+ (function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");if(a.appendChild(document.createTextNode(".v-enter-from[data-v-6dbb0b00],.v-leave-to[data-v-6dbb0b00]{max-height:0px;grid-template-rows:0fr;opacity:0}.v-enter-active[data-v-6dbb0b00],.v-leave-active[data-v-6dbb0b00]{display:grid;transition:all .15s}.v-enter-to[data-v-6dbb0b00],.v-leave-from[data-v-6dbb0b00]{grid-template-rows:1fr;max-height:50vh;opacity:1}.error-alert[data-v-6dbb0b00]{transition-behavior:allow-discrete;display:grid;overflow:hidden;min-height:0}.error-alert>*[data-v-6dbb0b00]{min-height:0}.error-list[data-v-6dbb0b00]{list-style-position:inside}div.error-list[data-v-6dbb0b00]{container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;gap:1.5em;align-items:start}@container (max-width: 27.125rem){div.error-list[data-v-6dbb0b00]{grid-template-columns:auto 1fr}.error-link[data-v-6dbb0b00]{grid-column:1 / -1;justify-self:end}}@container (max-width: 17.75rem){div.error-list[data-v-6dbb0b00]{grid-template-columns:1fr}.error-message[data-v-6dbb0b00]{grid-column:1 / -1}}.error-item[data-v-6dbb0b00]{display:contents}a[data-v-6dbb0b00]{min-width:min-content}.error-link[data-v-6dbb0b00]{align-items:center;color:inherit;display:inline-flex;flex-wrap:wrap;gap:.25em;padding-bottom:1em;text-decoration:none}")),document.head.appendChild(a),window.customElements){const e=window.customElements.define;window.customElements.define=function(r,t){const i=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(i&&i.call(this),this.shadowRoot){const d=document.createElement("style");d.appendChild(document.createTextNode(".v-enter-from[data-v-6dbb0b00],.v-leave-to[data-v-6dbb0b00]{max-height:0px;grid-template-rows:0fr;opacity:0}.v-enter-active[data-v-6dbb0b00],.v-leave-active[data-v-6dbb0b00]{display:grid;transition:all .15s}.v-enter-to[data-v-6dbb0b00],.v-leave-from[data-v-6dbb0b00]{grid-template-rows:1fr;max-height:50vh;opacity:1}.error-alert[data-v-6dbb0b00]{transition-behavior:allow-discrete;display:grid;overflow:hidden;min-height:0}.error-alert>*[data-v-6dbb0b00]{min-height:0}.error-list[data-v-6dbb0b00]{list-style-position:inside}div.error-list[data-v-6dbb0b00]{container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;gap:1.5em;align-items:start}@container (max-width: 27.125rem){div.error-list[data-v-6dbb0b00]{grid-template-columns:auto 1fr}.error-link[data-v-6dbb0b00]{grid-column:1 / -1;justify-self:end}}@container (max-width: 17.75rem){div.error-list[data-v-6dbb0b00]{grid-template-columns:1fr}.error-message[data-v-6dbb0b00]{grid-column:1 / -1}}.error-item[data-v-6dbb0b00]{display:contents}a[data-v-6dbb0b00]{min-width:min-content}.error-link[data-v-6dbb0b00]{align-items:center;color:inherit;display:inline-flex;flex-wrap:wrap;gap:.25em;padding-bottom:1em;text-decoration:none}")),this.shadowRoot.appendChild(d)}},e.call(window.customElements,r,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
2
  import r from "./vue-components.es29.js";
3
3
 
4
4
  import o from "./vue-components.es31.js";
5
- const e = /* @__PURE__ */ o(r, [["__scopeId", "data-v-4f889c81"]]);
5
+ const e = /* @__PURE__ */ o(r, [["__scopeId", "data-v-6dbb0b00"]]);
6
6
  export {
7
7
  e as default
8
8
  };
@@ -1,53 +1,63 @@
1
- import { defineComponent as y, getCurrentInstance as E, computed as C, createBlock as n, openBlock as e, Transition as x, withCtx as o, createElementBlock as d, createCommentVNode as B, renderSlot as b, normalizeProps as I, guardReactiveProps as w, resolveDynamicComponent as s, unref as a, normalizeClass as V, createElementVNode as c, toDisplayString as u, Fragment as p, renderList as _, createTextVNode as k } from "vue";
2
- import { mdiLink as N } from "@mdi/js";
3
- import { useIntl as z } from "./vue-components.es3.js";
1
+ import { defineComponent as x, getCurrentInstance as E, computed as h, createBlock as o, openBlock as t, Transition as I, withCtx as a, createElementBlock as m, createCommentVNode as w, renderSlot as O, normalizeProps as S, guardReactiveProps as V, resolveDynamicComponent as s, unref as i, normalizeClass as N, createElementVNode as d, toDisplayString as c, Fragment as M, renderList as b, createTextVNode as k } from "vue";
2
+ import { mdiLink as j } from "@mdi/js";
3
+ import { Array as z, Option as y } from "effect-app";
4
+ import { useIntl as A } from "./vue-components.es3.js";
4
5
  const D = {
5
6
  key: 0,
6
7
  class: "error-alert"
7
- }, G = { class: "text-h6 mb-3" }, L = { class: "font-weight-medium" }, M = { class: "error-message" }, O = ["href"], P = { key: 1 }, A = /* @__PURE__ */ y({
8
+ }, G = { class: "text-h6 mb-3" }, L = { class: "font-weight-medium" }, P = { class: "error-message" }, T = ["href"], $ = { key: 1 }, K = /* @__PURE__ */ x({
8
9
  __name: "OmegaErrorsInternal",
9
10
  props: {
10
- errors: {},
11
- generalErrors: {}
11
+ form: {},
12
+ fieldMap: {}
12
13
  },
13
- setup(t) {
14
- const m = E()?.appContext.components.VAlert, h = t, { trans: g } = z(), f = C(() => h.generalErrors ? h.generalErrors.filter((i) => !!i).flatMap(
15
- (i) => Object.values(i).filter((l) => !!l).flatMap(
14
+ setup(B) {
15
+ const f = E()?.appContext.components.VAlert, u = B, v = u.form.useStore((e) => e.errors), C = u.form.useStore((e) => e.fieldMeta), n = h(
16
+ () => z.filterMap(
17
+ Object.entries(C.value),
18
+ ([e, l]) => (l.errors ?? []).length && u.fieldMap.get(e)?.id ? y.some({
19
+ label: u.fieldMap.get(e).label,
20
+ inputId: u.fieldMap.get(e).id,
21
+ errors: (l.errors ?? []).map((r) => r.message).filter(Boolean)
22
+ }) : y.none()
23
+ )
24
+ ), { trans: _ } = A(), p = h(() => v.value ? v.value.filter((e) => !!e).flatMap(
25
+ (e) => Object.values(e).filter((l) => !!l).flatMap(
16
26
  (l) => l.filter(
17
27
  (r) => !!r?.message
18
28
  ).map((r) => r.message)
19
29
  )
20
30
  ) : []);
21
- return (i, l) => (e(), n(x, null, {
22
- default: o(() => [
23
- t.errors.length || f.value.length ? (e(), d("div", D, [
24
- b(i.$slots, "default", I(w({ errors: t.errors, showedGeneralErrors: f.value })), () => [
25
- (e(), n(s(a(m) ? "v-alert" : "div"), {
26
- class: V([a(m) ? "mb-4" : "error-alert-content", "mb-4"]),
31
+ return (e, l) => (t(), o(I, null, {
32
+ default: a(() => [
33
+ n.value.length || p.value.length ? (t(), m("div", D, [
34
+ O(e.$slots, "default", S(V({ errors: n.value, showedGeneralErrors: p.value })), () => [
35
+ (t(), o(s(i(f) ? "v-alert" : "div"), {
36
+ class: N([i(f) ? "mb-4" : "error-alert-content", "mb-4"]),
27
37
  type: "error",
28
38
  variant: "tonal",
29
39
  role: "alert",
30
40
  "aria-live": "polite"
31
41
  }, {
32
- default: o(() => [
33
- c("div", G, u(a(g)("form.includes_error")) + ": ", 1),
34
- t.errors.length ? (e(), n(s(t.errors.length > 1 ? "ul" : "div"), {
42
+ default: a(() => [
43
+ d("div", G, c(i(_)("form.includes_error")) + ": ", 1),
44
+ n.value.length ? (t(), o(s(n.value.length > 1 ? "ul" : "div"), {
35
45
  key: 0,
36
46
  class: "error-list"
37
47
  }, {
38
- default: o(() => [
39
- (e(!0), d(p, null, _(t.errors, (r) => (e(), n(s(t.errors.length > 1 ? "li" : "div"), {
48
+ default: a(() => [
49
+ (t(!0), m(M, null, b(n.value, (r) => (t(), o(s(n.value.length > 1 ? "li" : "div"), {
40
50
  key: r.inputId,
41
51
  class: "error-item"
42
52
  }, {
43
- default: o(() => [
44
- c("div", L, u(r.label), 1),
45
- c("div", M, [
46
- (e(), n(s(r.errors.length > 1 ? "ul" : "div"), { class: "error-list" }, {
47
- default: o(() => [
48
- (e(!0), d(p, null, _(r.errors, (v) => (e(), n(s(r.errors.length > 1 ? "li" : "span"), { key: v }, {
49
- default: o(() => [
50
- k(u(v), 1)
53
+ default: a(() => [
54
+ d("div", L, c(r.label), 1),
55
+ d("div", P, [
56
+ (t(), o(s(r.errors.length > 1 ? "ul" : "div"), { class: "error-list" }, {
57
+ default: a(() => [
58
+ (t(!0), m(M, null, b(r.errors, (g) => (t(), o(s(r.errors.length > 1 ? "li" : "span"), { key: g }, {
59
+ default: a(() => [
60
+ k(c(g), 1)
51
61
  ]),
52
62
  _: 2
53
63
  }, 1024))), 128))
@@ -55,37 +65,37 @@ const D = {
55
65
  _: 2
56
66
  }, 1024))
57
67
  ]),
58
- c("a", {
68
+ d("a", {
59
69
  href: `#${r.inputId}`,
60
70
  class: "error-link"
61
71
  }, [
62
- (e(), n(s(a(m) ? "v-icon" : "i"), {
63
- icon: a(N),
72
+ (t(), o(s(i(f) ? "v-icon" : "i"), {
73
+ icon: i(j),
64
74
  "aria-hidden": "true"
65
75
  }, {
66
- default: o(() => [...l[0] || (l[0] = [
67
- c("i", null, "🔗", -1)
76
+ default: a(() => [...l[0] || (l[0] = [
77
+ d("i", null, "🔗", -1)
68
78
  ])]),
69
79
  _: 1
70
80
  }, 8, ["icon"])),
71
- k(" " + u(a(g)("form.fix_input")), 1)
72
- ], 8, O)
81
+ k(" " + c(i(_)("form.fix_input")), 1)
82
+ ], 8, T)
73
83
  ]),
74
84
  _: 2
75
85
  }, 1024))), 128))
76
86
  ]),
77
87
  _: 1
78
- })) : (e(), d("span", P, u(f.value[0]), 1))
88
+ })) : (t(), m("span", $, c(p.value[0]), 1))
79
89
  ]),
80
90
  _: 1
81
91
  }, 8, ["class"]))
82
92
  ], !0)
83
- ])) : B("", !0)
93
+ ])) : w("", !0)
84
94
  ]),
85
95
  _: 3
86
96
  }));
87
97
  }
88
98
  });
89
99
  export {
90
- A as default
100
+ K as default
91
101
  };
@@ -1,8 +1,8 @@
1
- import { useForm as T } from "@tanstack/vue-form";
2
- import { Data as W, S as U, Effect as l, Array as g, Option as E, Fiber as F } from "effect-app";
3
- import { runtimeFiberAsPromise as k } from "./vue-components.es12.js";
4
- import { isObject as z } from "./vue-components.es13.js";
5
- import { computed as $, onUnmounted as A, onMounted as Q, onBeforeUnmount as X, watch as N, h as D } from "vue";
1
+ import { useForm as k } from "@tanstack/vue-form";
2
+ import { Data as B, S as L, Effect as l, Fiber as b, Option as G, Array as O } from "effect-app";
3
+ import { runtimeFiberAsPromise as T } from "./vue-components.es12.js";
4
+ import { isObject as W } from "./vue-components.es13.js";
5
+ import { computed as I, onUnmounted as U, onMounted as z, onBeforeUnmount as Q, ref as X, watch as $, h as N } from "vue";
6
6
  import { usePreventClose as Y } from "./vue-components.es8.js";
7
7
  import Z from "./vue-components.es14.js";
8
8
  import C from "./vue-components.es15.js";
@@ -10,63 +10,62 @@ import ee from "./vue-components.es16.js";
10
10
  import { generateMetaFromSchema as re } from "./vue-components.es9.js";
11
11
  import te from "./vue-components.es5.js";
12
12
  import se from "./vue-components.es17.js";
13
- import { trace as _ } from "./vue-components.es18.js";
14
- import { context as M } from "./vue-components.es19.js";
15
- class ne extends W.TaggedError("FormErrors") {
13
+ import { trace as A } from "./vue-components.es18.js";
14
+ import { context as y } from "./vue-components.es19.js";
15
+ class ne extends B.TaggedError("FormErrors") {
16
16
  }
17
- const h = (c) => function(o) {
17
+ const p = (c) => function(i) {
18
18
  return {
19
19
  render() {
20
- return D(o, {
20
+ return N(i, {
21
21
  form: c,
22
22
  ...this.$attrs
23
23
  }, this.$slots);
24
24
  }
25
25
  };
26
- }, oe = (c) => function(o) {
26
+ }, ie = (c) => function(i) {
27
27
  return {
28
28
  setup() {
29
29
  return {
30
30
  ...c
31
31
  };
32
32
  },
33
- render({ errors: S, generalErrors: w, showErrors: v }) {
34
- return D(o, {
35
- errors: S,
36
- generalErrors: w,
37
- showErrors: v,
33
+ render({ fieldMap: h, form: S }) {
34
+ return N(i, {
35
+ form: S,
36
+ fieldMap: h,
38
37
  ...this.$attrs
39
38
  }, this.$slots);
40
39
  }
41
40
  };
42
- }, ye = (c, a, o) => {
41
+ }, ye = (c, a, i) => {
43
42
  if (!c) throw new Error("Schema is required");
44
- const S = U.standardSchemaV1(c), w = U.decode(c), { filterItems: v, meta: p } = re(c), m = $(() => {
45
- if (o?.persistency?.id)
46
- return o.persistency.id;
47
- const e = window.location.pathname, r = Object.keys(p);
43
+ const h = L.standardSchemaV1(c), S = L.decode(c), { filterItems: _, meta: d } = re(c), m = I(() => {
44
+ if (i?.persistency?.id)
45
+ return i.persistency.id;
46
+ const e = window.location.pathname, r = Object.keys(d);
48
47
  return `${e}-${r.join("-")}`;
49
- }), R = () => {
48
+ }), D = () => {
50
49
  const e = new URLSearchParams(window.location.search);
51
50
  e.delete(m.value);
52
51
  const r = new URL(window.location.href);
53
52
  r.search = e.toString(), window.history.replaceState({}, "", r.toString());
54
53
  };
55
- function j(e, r) {
54
+ function g(e, r) {
56
55
  for (const t in r)
57
- r[t] && z(r[t]) ? (e[t] || (e[t] = {}), j(e[t], r[t])) : e[t] = r[t];
56
+ r[t] && W(r[t]) ? (e[t] || (e[t] = {}), g(e[t], r[t])) : e[t] = r[t];
58
57
  return e;
59
58
  }
60
- const x = $(() => {
61
- if (a?.defaultValues && !o?.persistency?.overrideDefaultValues)
59
+ const R = I(() => {
60
+ if (a?.defaultValues && !i?.persistency?.overrideDefaultValues)
62
61
  return a?.defaultValues;
63
62
  let e;
64
- const r = o?.persistency;
63
+ const r = i?.persistency;
65
64
  if (!r?.policies || r.policies.length === 0) return {};
66
65
  if (r.policies.includes("querystring"))
67
66
  try {
68
67
  const s = new URLSearchParams(window.location.search).get(m.value);
69
- R(), s && (e = JSON.parse(s));
68
+ D(), s && (e = JSON.parse(s));
70
69
  } catch (t) {
71
70
  console.error(t);
72
71
  }
@@ -89,113 +88,104 @@ const h = (c) => function(o) {
89
88
  return e;
90
89
  {
91
90
  const t = a?.defaultValues;
92
- return j(t, e);
91
+ return g(t, e);
93
92
  }
94
- }), H = (e, r) => e ? M.with(_.setSpan(M.active(), e), r) : r(), u = T({
93
+ }), x = (e, r) => e ? y.with(A.setSpan(y.active(), e), r) : r(), u = k({
95
94
  ...a,
96
95
  validators: {
97
- onSubmit: S,
96
+ onSubmit: h,
98
97
  ...a?.validators || {}
99
98
  },
100
- onSubmit: a?.onSubmit ? ({ formApi: e, meta: r, value: t }) => H(r?.currentSpan, async () => {
101
- const s = await l.runPromise(w(t)), n = a.onSubmit({
99
+ onSubmit: a?.onSubmit ? ({ formApi: e, meta: r, value: t }) => x(r?.currentSpan, async () => {
100
+ const s = await l.runPromise(S(t)), n = a.onSubmit({
102
101
  formApi: e,
103
102
  meta: r,
104
103
  value: s
105
104
  });
106
- return F.isFiber(n) && F.isRuntimeFiber(n) ? await k(n) : l.isEffect(n) ? await l.runPromise(
105
+ return b.isFiber(n) && b.isRuntimeFiber(n) ? await T(n) : l.isEffect(n) ? await l.runPromise(
107
106
  n.pipe(
108
107
  // meta?.currentSpan
109
108
  // ? Effect.withParentSpan(meta.currentSpan)
110
109
  // : (_) => _,
111
- l.flatMap((d) => F.join(d))
110
+ l.flatMap((f) => b.join(f))
112
111
  )
113
112
  ) : n;
114
113
  }) : void 0,
115
- defaultValues: x.value
116
- }), J = () => {
117
- Object.keys(p).forEach((e) => {
114
+ defaultValues: R.value
115
+ }), H = () => {
116
+ Object.keys(d).forEach((e) => {
118
117
  u.setFieldValue(e, void 0);
119
118
  });
120
- }, V = (e) => e.reduce((r, t) => {
119
+ }, E = (e) => e.reduce((r, t) => {
121
120
  const s = t.split(".");
122
- return s.reduce((n, d, G) => (G === s.length - 1 ? n[d] = u.getFieldValue(t) : n[d] = n[d] ?? {}, n[d]), r), r;
123
- }, {}), O = (e) => {
121
+ return s.reduce((n, f, K) => (K === s.length - 1 ? n[f] = u.getFieldValue(t) : n[f] = n[f] ?? {}, n[f]), r), r;
122
+ }, {}), F = (e) => {
124
123
  if (e) {
125
- if (g.isArray(e.keys))
126
- return V(e.keys);
127
- if (g.isArray(e.banKeys)) {
128
- const r = Object.keys(p).filter((t) => e.banKeys?.includes(t));
129
- return V(r);
124
+ if (O.isArray(e.keys))
125
+ return E(e.keys);
126
+ if (O.isArray(e.banKeys)) {
127
+ const r = Object.keys(d).filter((t) => e.banKeys?.includes(t));
128
+ return E(r);
130
129
  }
131
130
  return u.store.state.values;
132
131
  }
133
- }, b = () => {
134
- const e = o?.persistency;
132
+ }, v = () => {
133
+ const e = i?.persistency;
135
134
  if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
136
135
  const r = e.policies.includes("local") ? localStorage : sessionStorage;
137
136
  if (!r) return;
138
- const t = O(e);
137
+ const t = F(e);
139
138
  return r.setItem(m.value, JSON.stringify(t));
140
139
  }
141
- }, P = () => {
142
- const e = o?.persistency;
140
+ }, V = () => {
141
+ const e = i?.persistency;
143
142
  if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
144
- const r = O(e), t = new URLSearchParams(window.location.search);
143
+ const r = F(e), t = new URLSearchParams(window.location.search);
145
144
  t.set(m.value, JSON.stringify(r));
146
145
  const s = new URL(window.location.href);
147
146
  s.search = t.toString(), window.history.replaceState({}, "", s.toString());
148
147
  }
149
148
  };
150
- A(b), Q(() => {
151
- window.addEventListener("beforeunload", b), window.addEventListener("blur", P);
152
- }), X(() => {
153
- window.removeEventListener("beforeunload", b), window.removeEventListener("blur", P);
149
+ U(v), z(() => {
150
+ window.addEventListener("beforeunload", v), window.addEventListener("blur", V);
151
+ }), Q(() => {
152
+ window.removeEventListener("beforeunload", v), window.removeEventListener("blur", V);
154
153
  });
155
- const I = (e) => l.currentSpan.pipe(
154
+ const j = (e) => l.currentSpan.pipe(
156
155
  l.option,
157
156
  l.flatMap(
158
- (r) => l.promise(() => u.handleSubmit(E.isSome(r) ? { currentSpan: r.value, ...e } : e))
157
+ (r) => l.promise(() => u.handleSubmit(G.isSome(r) ? { currentSpan: r.value, ...e } : e))
159
158
  )
160
- ), q = (e) => e?.checkErrors ? I(e?.meta).pipe(l.flatMap(l.fnUntraced(function* () {
159
+ ), J = (e) => e?.checkErrors ? j(e?.meta).pipe(l.flatMap(l.fnUntraced(function* () {
161
160
  const r = u.getAllErrors();
162
161
  if (Object.keys(r.fields).length || r.form.errors.length)
163
162
  return yield* new ne({ form: r.form, fields: r.fields });
164
- }))) : I(e?.meta), B = u.handleSubmit, f = /* @__PURE__ */ new Map(), i = Object.assign(u, {
165
- i18nNamespace: o?.i18nNamespace,
166
- meta: p,
167
- filterItems: v,
168
- clear: J,
163
+ }))) : j(e?.meta), q = u.handleSubmit, w = X(/* @__PURE__ */ new Map()), o = Object.assign(u, {
164
+ i18nNamespace: i?.i18nNamespace,
165
+ meta: d,
166
+ filterItems: _,
167
+ clear: H,
169
168
  handleSubmit: (e) => {
170
- const r = _.getSpan(M.active());
171
- return B({ currentSpan: r, ...e });
169
+ const r = A.getSpan(y.active());
170
+ return q({ currentSpan: r, ...e });
172
171
  },
173
172
  // /** @experimental */
174
- handleSubmitEffect: q,
173
+ handleSubmitEffect: J,
175
174
  registerField: (e) => {
176
- N(e, (r) => f.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), A(() => f.delete(e.value.name));
175
+ $(e, (r) => w.value.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), U(() => w.value.delete(e.value.name));
177
176
  }
178
- }), y = i.useStore((e) => e.errors), K = i.useStore(
179
- (e) => g.filterMap(
180
- Object.entries(e.fieldMeta),
181
- ([r, t]) => (t.errors ?? []).length && f.get(r)?.id ? E.some({
182
- label: f.get(r).label,
183
- inputId: f.get(r).id,
184
- errors: (t.errors ?? []).map((s) => s.message).filter(Boolean)
185
- }) : E.none()
186
- )
187
- );
188
- N(
189
- () => [i.filterItems, y.value],
177
+ }), M = o.useStore((e) => e.errors);
178
+ $(
179
+ () => [o.filterItems, M.value],
190
180
  () => {
191
- const e = i.filterItems, r = y.value;
181
+ const e = o.filterItems, r = M.value;
192
182
  return e ? r ? (Object.values(r).filter(
193
183
  (s) => !!s
194
184
  ).flatMap(
195
185
  (s) => Object.values(s).flat().map((n) => n.message)
196
186
  ).some((s) => s === e.message) && e.items.forEach((s) => {
197
- const n = i.getFieldMeta(s);
198
- n && i.setFieldMeta(s, {
187
+ const n = o.getFieldMeta(s);
188
+ n && o.setFieldMeta(s, {
199
189
  ...n,
200
190
  errorMap: {
201
191
  onSubmit: [
@@ -206,15 +196,15 @@ const h = (c) => function(o) {
206
196
  }), {}) : {} : {};
207
197
  }
208
198
  );
209
- const L = { generalErrors: y, errors: K };
210
- return o?.ignorePreventCloseEvents || Y(() => i.useStore((e) => e.isDirty)), Object.assign(i, {
211
- errorContext: L,
212
- Form: h(i)(se),
213
- Input: h(i)(o?.input ?? te),
199
+ const P = { form: o, fieldMap: w };
200
+ return i?.ignorePreventCloseEvents || Y(() => o.useStore((e) => e.isDirty)), Object.assign(o, {
201
+ errorContext: P,
202
+ Form: p(o)(se),
203
+ Input: p(o)(i?.input ?? te),
214
204
  Field: u.Field,
215
- Errors: oe(L)(ee),
216
- Array: h(i)(Z),
217
- AutoGen: h(i)(C)
205
+ Errors: ie(P)(ee),
206
+ Array: p(o)(Z),
207
+ AutoGen: p(o)(C)
218
208
  });
219
209
  };
220
210
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "1.8.6",
3
+ "version": "1.8.7",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "effect": "^3.18.0",
@@ -74,27 +74,45 @@
74
74
  <script setup lang="ts">
75
75
  import { mdiLink } from "@mdi/js"
76
76
  import type { StandardSchemaV1Issue } from "@tanstack/vue-form"
77
+ import { Array as Array$, Option } from "effect-app"
77
78
  import { computed, getCurrentInstance } from "vue"
78
79
  import { useIntl } from "../../utils"
79
- import { type OmegaError } from "./OmegaFormStuff"
80
+ import { type OmegaError, type OmegaFormApi } from "./OmegaFormStuff"
80
81
 
81
82
  const instance = getCurrentInstance()
82
83
  const vuetified = instance?.appContext.components["VAlert"]
83
84
 
84
85
  const props = defineProps<
85
86
  {
86
- errors: readonly OmegaError[]
87
- generalErrors: (Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined
87
+ form: OmegaFormApi<any, any>
88
+ fieldMap: Map<string, { id: string; label: string }>
88
89
  }
89
90
  >()
90
91
 
92
+ const generalErrors = props.form.useStore((state) => state.errors)
93
+ const fieldMeta = props.form.useStore((state) => state.fieldMeta)
94
+ const errors = computed(() =>
95
+ Array$.filterMap(
96
+ Object
97
+ .entries(fieldMeta.value),
98
+ ([key, m]): Option.Option<OmegaError> =>
99
+ ((m as any).errors ?? []).length && props.fieldMap.get(key)?.id
100
+ ? Option.some({
101
+ label: props.fieldMap.get(key)!.label,
102
+ inputId: props.fieldMap.get(key)!.id,
103
+ errors: ((m as any).errors ?? []).map((e: any) => e.message).filter(Boolean)
104
+ })
105
+ : Option.none()
106
+ )
107
+ )
108
+
91
109
  const { trans } = useIntl()
92
110
 
93
111
  const showedGeneralErrors = computed(() => {
94
- if (!props.generalErrors) return []
112
+ if (!generalErrors.value) return []
95
113
 
96
- return props
97
- .generalErrors
114
+ return generalErrors
115
+ .value
98
116
  .filter((record): record is Record<string, StandardSchemaV1Issue[]> => Boolean(record))
99
117
  .flatMap((errorRecord) =>
100
118
  Object
@@ -6,7 +6,7 @@ import { type DeepKeys, DeepValue, type FormAsyncValidateOrFn, type FormValidate
6
6
  import { Array, Data, Effect, Fiber, Option, Order, S } from "effect-app"
7
7
  import { runtimeFiberAsPromise } from "effect-app/utils"
8
8
  import { isObject } from "effect/Predicate"
9
- import { Component, computed, ComputedRef, ConcreteComponent, h, type InjectionKey, onBeforeUnmount, onMounted, onUnmounted, Ref, watch } from "vue"
9
+ import { Component, computed, ComputedRef, ConcreteComponent, h, type InjectionKey, onBeforeUnmount, onMounted, onUnmounted, Ref, ref, watch } from "vue"
10
10
  import { usePreventClose } from "./blockDialog"
11
11
  import { MergedInputProps } from "./InputProps"
12
12
  import OmegaArray from "./OmegaArray.vue"
@@ -65,13 +65,8 @@ const fHoc = (form: OF<any, any>) => {
65
65
  }
66
66
 
67
67
  const eHoc = (errorProps: {
68
- generalErrors: Readonly<
69
- Ref<
70
- (Record<string, StandardSchemaV1Issue[]> | undefined)[],
71
- (Record<string, StandardSchemaV1Issue[]> | undefined)[]
72
- >
73
- >
74
- errors: Readonly<Ref<(OmegaError | undefined)[], (OmegaError | undefined)[]>>
68
+ form: OF<any, any>
69
+ fieldMap: Ref<Map<string, { id: string; label: string }>>
75
70
  }) => {
76
71
  return function FormHoc<P>(
77
72
  WrappedComponent: Component<P>
@@ -82,11 +77,10 @@ const eHoc = (errorProps: {
82
77
  ...errorProps
83
78
  }
84
79
  },
85
- render({ errors, generalErrors, showErrors }: any) {
80
+ render({ fieldMap, form }: any) {
86
81
  return h(WrappedComponent, {
87
- errors,
88
- generalErrors,
89
- showErrors,
82
+ form,
83
+ fieldMap,
90
84
  ...this.$attrs
91
85
  } as any, this.$slots)
92
86
  }
@@ -863,7 +857,7 @@ export const useOmegaForm = <
863
857
 
864
858
  const handleSubmit = form.handleSubmit
865
859
 
866
- const fieldMap = new Map<string, { label: string; id: string }>()
860
+ const fieldMap = ref(new Map<string, { label: string; id: string }>())
867
861
 
868
862
  const formWithExtras: OF<From, To> = Object.assign(form, {
869
863
  i18nNamespace: omegaConfig?.i18nNamespace,
@@ -877,26 +871,12 @@ export const useOmegaForm = <
877
871
  // /** @experimental */
878
872
  handleSubmitEffect,
879
873
  registerField: (field: ComputedRef<{ name: string; label: string; id: string }>) => {
880
- watch(field, (f) => fieldMap.set(f.name, { label: f.label, id: f.id }), { immediate: true })
881
- onUnmounted(() => fieldMap.delete(field.value.name)) // todo; perhap only when owned (id match)
874
+ watch(field, (f) => fieldMap.value.set(f.name, { label: f.label, id: f.id }), { immediate: true })
875
+ onUnmounted(() => fieldMap.value.delete(field.value.name)) // todo; perhap only when owned (id match)
882
876
  }
883
877
  })
884
878
 
885
879
  const errors = formWithExtras.useStore((state) => state.errors)
886
- const fieldErrors = formWithExtras.useStore((state) =>
887
- Array.filterMap(
888
- Object
889
- .entries(state.fieldMeta),
890
- ([key, m]): Option.Option<OmegaError> =>
891
- ((m as any).errors ?? []).length && fieldMap.get(key)?.id
892
- ? Option.some({
893
- label: fieldMap.get(key)!.label,
894
- inputId: fieldMap.get(key)!.id,
895
- errors: ((m as any).errors ?? []).map((e: any) => e.message).filter(Boolean)
896
- })
897
- : Option.none()
898
- )
899
- )
900
880
 
901
881
  watch(
902
882
  () => [formWithExtras.filterItems, errors.value],
@@ -937,7 +917,7 @@ export const useOmegaForm = <
937
917
  }
938
918
  )
939
919
 
940
- const errorContext = { generalErrors: errors, errors: fieldErrors }
920
+ const errorContext = { form: formWithExtras, fieldMap }
941
921
 
942
922
  if (!omegaConfig?.ignorePreventCloseEvents) {
943
923
  usePreventClose(() => formWithExtras.useStore((state) => state.isDirty))