@effect-app/vue-components 1.8.26 → 1.9.1

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.
Files changed (62) hide show
  1. package/dist/types/components/CommandButton.vue.d.ts +38 -0
  2. package/dist/types/components/OmegaForm/OmegaArray.vue.d.ts +1 -1
  3. package/dist/types/components/index.d.ts +1 -0
  4. package/dist/vue-components.es.js +22 -20
  5. package/dist/vue-components.es10.js +338 -30
  6. package/dist/vue-components.es11.js +34 -2
  7. package/dist/vue-components.es12.js +2 -10
  8. package/dist/vue-components.es13.js +2 -5
  9. package/dist/vue-components.es14.js +10 -54
  10. package/dist/vue-components.es15.js +5 -68
  11. package/dist/vue-components.es16.js +54 -6
  12. package/dist/vue-components.es17.js +68 -6
  13. package/dist/vue-components.es18.js +6 -3
  14. package/dist/vue-components.es19.js +6 -3
  15. package/dist/vue-components.es2.js +20 -18
  16. package/dist/vue-components.es20.js +3 -2
  17. package/dist/vue-components.es21.js +3 -2
  18. package/dist/vue-components.es22.js +2 -17
  19. package/dist/vue-components.es23.js +2 -11
  20. package/dist/vue-components.es24.js +17 -42
  21. package/dist/vue-components.es25.js +11 -2
  22. package/dist/vue-components.es26.js +42 -2
  23. package/dist/vue-components.es27.js +2 -89
  24. package/dist/vue-components.es28.js +4 -0
  25. package/dist/vue-components.es29.js +89 -7
  26. package/dist/vue-components.es31.js +9 -0
  27. package/dist/vue-components.es32.js +25 -130
  28. package/dist/vue-components.es34.js +136 -23
  29. package/dist/vue-components.es36.js +11 -21
  30. package/dist/vue-components.es37.js +4 -30
  31. package/dist/vue-components.es38.js +20 -19
  32. package/dist/vue-components.es39.js +5 -12
  33. package/dist/vue-components.es4.js +43 -43
  34. package/dist/vue-components.es40.js +21 -5
  35. package/dist/vue-components.es41.js +29 -18
  36. package/dist/vue-components.es42.js +22 -9
  37. package/dist/vue-components.es43.js +7 -26
  38. package/dist/vue-components.es44.js +5 -48
  39. package/dist/vue-components.es45.js +19 -26
  40. package/dist/vue-components.es46.js +9 -11
  41. package/dist/vue-components.es47.js +31 -4
  42. package/dist/vue-components.es48.js +37 -54
  43. package/dist/vue-components.es49.js +21 -51
  44. package/dist/vue-components.es5.js +45 -46
  45. package/dist/vue-components.es50.js +64 -16
  46. package/dist/vue-components.es51.js +54 -31
  47. package/dist/vue-components.es52.js +16 -28
  48. package/dist/vue-components.es53.js +32 -41
  49. package/dist/vue-components.es54.js +29 -2
  50. package/dist/vue-components.es55.js +41 -43
  51. package/dist/vue-components.es56.js +2 -2
  52. package/dist/vue-components.es57.js +46 -0
  53. package/dist/vue-components.es58.js +4 -0
  54. package/dist/vue-components.es6.js +40 -63
  55. package/dist/vue-components.es7.js +69 -197
  56. package/dist/vue-components.es8.js +197 -28
  57. package/dist/vue-components.es9.js +29 -341
  58. package/package.json +5 -3
  59. package/src/components/CommandButton.vue +72 -0
  60. package/src/components/index.ts +1 -0
  61. package/dist/vue-components.es30.js +0 -33
  62. package/dist/vue-components.es35.js +0 -7
@@ -1,73 +1,50 @@
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 b, getCurrentInstance as C, useId as x, computed as n, onMounted as _, renderSlot as P, normalizeProps as m, guardReactiveProps as M, createElementVNode as N, normalizeClass as $, createBlock as V, createCommentVNode as k, unref as q, openBlock as B, mergeProps as F } from "vue";
3
- import { useStore as I } from "@tanstack/vue-form";
4
- import L from "./vue-components.es32.js";
5
-
6
- const U = /* @__PURE__ */ b({
1
+ import { defineComponent as $, inject as M, computed as s, createBlock as i, openBlock as f, resolveDynamicComponent as b, withCtx as u, createCommentVNode as C, mergeProps as F, renderSlot as k, normalizeProps as y, guardReactiveProps as A } from "vue";
2
+ import { useIntl as w } from "./vue-components.es3.js";
3
+ import { generateInputStandardSchemaFromFieldMeta as I } from "./vue-components.es10.js";
4
+ import N from "./vue-components.es7.js";
5
+ const B = /* @__PURE__ */ $({
7
6
  inheritAttrs: !1,
8
- __name: "OmegaInternalInput",
7
+ __name: "OmegaInput",
9
8
  props: {
10
- field: {},
11
- state: {},
12
- meta: {},
9
+ form: {},
13
10
  label: {},
14
- type: {},
15
11
  validators: {},
16
- register: { type: Function },
17
- options: {}
12
+ name: {}
18
13
  },
19
- setup(u) {
20
- const e = u, p = C()?.appContext.components.VTextField, s = x(), l = e.field, o = I(l.store, (t) => t), d = n(() => e.type ? e.type : e.meta?.type === "string" ? e.meta.format === "email" ? "email" : "string" : e.meta?.type || "unknown");
21
- e.register(n(() => ({ name: e.field.name, label: e.label, id: s })));
22
- const f = n(() => o.value.value), c = n(() => o.value.meta.errors ?? []), i = n(
23
- () => (
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
- c.value.map((t) => t?.message).filter(Boolean)
26
- )
27
- ), g = (t) => t == null || t === !1 || t === "" || Number.isNaN(t), y = (t) => {
28
- g(t) && e.meta?.type !== "boolean" ? e.field.handleChange(
29
- e.meta?.nullableOrUndefined === "undefined" ? void 0 : null
30
- ) : e.field.handleChange(t), e.field.setMeta((r) => ({ ...r, errorMap: { ...r.errorMap, onSubmit: void 0 } }));
31
- };
32
- _(() => {
33
- if (!f.value && !e.meta?.required && e.meta?.nullableOrUndefined === "null") {
34
- const t = o.value.meta.isDirty;
35
- l.setValue(null), l.setMeta((r) => ({ ...r, isDirty: t }));
14
+ setup(a) {
15
+ const e = a, n = M(
16
+ "getMetaFromArray",
17
+ null
18
+ ), r = s(() => n?.value && n.value(e.name) ? n.value(e.name) : e.form.meta[e.name]), c = s(() => {
19
+ if (!r.value)
20
+ throw console.log(e.name, Object.keys(e.form.meta), e.form.meta), new Error("Meta is undefined");
21
+ return I(r.value);
22
+ }), { formatMessage: o } = w(), d = (t) => t.replace(/([A-Z])/g, " $1").replace(/^./, (l) => l.toUpperCase()).trim(), m = () => o({ id: `general.fields.${e.name}`, defaultMessage: d(e.name) }), p = () => e.form.i18nNamespace ? o({ id: `${e.form.i18nNamespace}.fields.${e.name}`, defaultMessage: m() }) : m();
23
+ return (t, l) => (f(), i(b(a.form.Field), {
24
+ name: a.name,
25
+ validators: {
26
+ onChange: c.value,
27
+ ...a.validators
36
28
  }
37
- });
38
- const h = (t) => {
39
- const r = {
40
- get(O, v, z) {
41
- return v === "handleChange" ? y : Reflect.get(...arguments);
42
- }
43
- };
44
- return new Proxy(t, r);
45
- }, a = n(() => ({
46
- inputProps: {
47
- id: s,
48
- required: e.meta?.required,
49
- minLength: e.meta?.type === "string" && e.meta?.minLength,
50
- maxLength: e.meta?.type === "string" && e.meta?.maxLength,
51
- max: e.meta?.type === "number" && e.meta?.maximum,
52
- min: e.meta?.type === "number" && e.meta?.minimum,
53
- errorMessages: i.value,
54
- error: !!i.value.length,
55
- type: d.value,
56
- label: `${e.label}${e.meta?.required ? " *" : ""}`,
57
- options: e.options
58
- },
59
- state: e.state,
60
- field: h(e.field)
61
- }));
62
- return (t, r) => P(t.$slots, "default", m(M({ ...a.value.inputProps, field: a.value.field, state: a.value.state })), () => [
63
- N("div", {
64
- class: $(t.$attrs.class)
65
- }, [
66
- q(p) ? (B(), V(L, m(F({ key: 0 }, { ...t.$attrs, ...a.value })), null, 16)) : k("", !0)
67
- ], 2)
68
- ]);
29
+ }, {
30
+ default: u(({ field: g, state: v }) => [
31
+ r.value ? (f(), i(N, F({ key: 0 }, { ...t.$attrs, ...t.$props }, {
32
+ field: g,
33
+ state: v,
34
+ register: a.form.registerField,
35
+ label: a.label ?? p(),
36
+ meta: r.value
37
+ }), {
38
+ default: u((h) => [
39
+ k(t.$slots, "default", y(A(h)))
40
+ ]),
41
+ _: 3
42
+ }, 16, ["field", "state", "register", "label", "meta"])) : C("", !0)
43
+ ]),
44
+ _: 3
45
+ }, 8, ["name", "validators"]));
69
46
  }
70
47
  });
71
48
  export {
72
- U as default
49
+ B as default
73
50
  };
@@ -1,201 +1,73 @@
1
- import { useForm as q } from "@tanstack/vue-form";
2
- import { Data as K, S as I, Effect as l, Fiber as F, Option as M, Array as P } from "effect-app";
3
- import { runtimeFiberAsPromise as B } from "./vue-components.es12.js";
4
- import { isObject as G } from "./vue-components.es13.js";
5
- import { computed as j, onUnmounted as N, onMounted as T, onBeforeUnmount as W, ref as k, watch as z, h as D } from "vue";
6
- import { usePreventClose as Q } from "./vue-components.es8.js";
7
- import X from "./vue-components.es14.js";
8
- import Y from "./vue-components.es15.js";
9
- import Z from "./vue-components.es16.js";
10
- import { generateMetaFromSchema as C } from "./vue-components.es9.js";
11
- import ee from "./vue-components.es5.js";
12
- import re from "./vue-components.es17.js";
13
- import { trace as _ } from "./vue-components.es18.js";
14
- import { context as V } from "./vue-components.es19.js";
15
- class te extends K.TaggedError("FormErrors") {
16
- }
17
- const w = (c) => function(n) {
18
- return {
19
- render() {
20
- return D(n, {
21
- form: c,
22
- ...this.$attrs
23
- }, this.$slots);
24
- }
25
- };
26
- }, se = (c) => function(n) {
27
- return {
28
- setup() {
29
- const { fieldMap: f, form: p } = c, h = p.useStore((a) => a.errors), u = p.useStore((a) => a.fieldMeta), b = j(
30
- () => P.filterMap(
31
- Object.entries(u.value),
32
- ([a, v]) => (v.errors ?? []).length && f.value.get(a)?.id ? M.some({
33
- label: f.value.get(a).label,
34
- inputId: f.value.get(a).id,
35
- errors: (v.errors ?? []).map((y) => y.message).filter(Boolean)
36
- }) : M.none()
37
- )
38
- );
39
- return {
40
- generalErrors: h,
41
- errors: b
42
- };
43
- },
44
- render({ errors: f, generalErrors: p }) {
45
- return D(n, {
46
- errors: f,
47
- generalErrors: p,
48
- ...this.$attrs
49
- }, this.$slots);
50
- }
51
- };
52
- }, we = (c, i, n) => {
53
- if (!c) throw new Error("Schema is required");
54
- const f = I.standardSchemaV1(c), p = I.decode(c), { meta: h } = C(c), u = j(() => {
55
- if (n?.persistency?.id)
56
- return n.persistency.id;
57
- const e = window.location.pathname, r = Object.keys(h);
58
- return `${e}-${r.join("-")}`;
59
- }), b = () => {
60
- const e = new URLSearchParams(window.location.search);
61
- e.delete(u.value);
62
- const r = new URL(window.location.href);
63
- r.search = e.toString(), window.history.replaceState({}, "", r.toString());
64
- };
65
- function a(e, r) {
66
- for (const t in r)
67
- r[t] && G(r[t]) ? (e[t] || (e[t] = {}), a(e[t], r[t])) : e[t] = r[t];
68
- return e;
69
- }
70
- const v = j(() => {
71
- if (i?.defaultValues && !n?.persistency?.overrideDefaultValues)
72
- return i?.defaultValues;
73
- let e;
74
- const r = n?.persistency;
75
- if (!r?.policies || r.policies.length === 0) return {};
76
- if (r.policies.includes("querystring"))
77
- try {
78
- const s = new URLSearchParams(window.location.search).get(u.value);
79
- b(), s && (e = JSON.parse(s));
80
- } catch (t) {
81
- console.error(t);
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 b, getCurrentInstance as C, useId as x, computed as n, onMounted as _, renderSlot as P, normalizeProps as m, guardReactiveProps as M, createElementVNode as N, normalizeClass as $, createBlock as V, createCommentVNode as k, unref as q, openBlock as B, mergeProps as F } from "vue";
3
+ import { useStore as I } from "@tanstack/vue-form";
4
+ import L from "./vue-components.es34.js";
5
+
6
+ const U = /* @__PURE__ */ b({
7
+ inheritAttrs: !1,
8
+ __name: "OmegaInternalInput",
9
+ props: {
10
+ field: {},
11
+ state: {},
12
+ meta: {},
13
+ label: {},
14
+ type: {},
15
+ validators: {},
16
+ register: { type: Function },
17
+ options: {}
18
+ },
19
+ setup(u) {
20
+ const e = u, p = C()?.appContext.components.VTextField, s = x(), l = e.field, o = I(l.store, (t) => t), d = n(() => e.type ? e.type : e.meta?.type === "string" ? e.meta.format === "email" ? "email" : "string" : e.meta?.type || "unknown");
21
+ e.register(n(() => ({ name: e.field.name, label: e.label, id: s })));
22
+ const f = n(() => o.value.value), c = n(() => o.value.meta.errors ?? []), i = n(
23
+ () => (
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
+ c.value.map((t) => t?.message).filter(Boolean)
26
+ )
27
+ ), g = (t) => t == null || t === !1 || t === "" || Number.isNaN(t), y = (t) => {
28
+ g(t) && e.meta?.type !== "boolean" ? e.field.handleChange(
29
+ e.meta?.nullableOrUndefined === "undefined" ? void 0 : null
30
+ ) : e.field.handleChange(t), e.field.setMeta((r) => ({ ...r, errorMap: { ...r.errorMap, onSubmit: void 0 } }));
31
+ };
32
+ _(() => {
33
+ if (!f.value && !e.meta?.required && e.meta?.nullableOrUndefined === "null") {
34
+ const t = o.value.meta.isDirty;
35
+ l.setValue(null), l.setMeta((r) => ({ ...r, isDirty: t }));
82
36
  }
83
- if (
84
- // query string has higher priority than local/session storage
85
- !e && (r.policies.includes("local") || r.policies.includes("session"))
86
- ) {
87
- const t = r.policies.includes("local") ? localStorage : sessionStorage;
88
- if (t)
89
- try {
90
- const s = JSON.parse(
91
- t.getItem(u.value) || "{}"
92
- );
93
- t.removeItem(u.value), e = s;
94
- } catch (s) {
95
- console.error(s);
96
- }
97
- }
98
- if (e ??= {}, i?.defaultValues == null)
99
- return e;
100
- {
101
- const t = i?.defaultValues;
102
- return a(t, e);
103
- }
104
- }), y = (e, r) => e ? V.with(_.setSpan(V.active(), e), r) : r(), d = q({
105
- ...i,
106
- validators: {
107
- onSubmit: f,
108
- ...i?.validators || {}
109
- },
110
- onSubmit: i?.onSubmit ? ({ formApi: e, meta: r, value: t }) => y(r?.currentSpan, async () => {
111
- const s = await l.runPromise(p(t)), o = i.onSubmit({
112
- formApi: e,
113
- meta: r,
114
- value: s
115
- });
116
- return F.isFiber(o) && F.isRuntimeFiber(o) ? await B(o) : l.isEffect(o) ? await l.runPromise(
117
- o.pipe(
118
- // meta?.currentSpan
119
- // ? Effect.withParentSpan(meta.currentSpan)
120
- // : (_) => _,
121
- l.flatMap((S) => F.join(S))
122
- )
123
- ) : o;
124
- }) : void 0,
125
- defaultValues: v.value
126
- }), R = () => {
127
- Object.keys(h).forEach((e) => {
128
- d.setFieldValue(e, void 0);
129
37
  });
130
- }, O = (e) => e.reduce((r, t) => {
131
- const s = t.split(".");
132
- return s.reduce((o, S, J) => (J === s.length - 1 ? o[S] = d.getFieldValue(t) : o[S] = o[S] ?? {}, o[S]), r), r;
133
- }, {}), U = (e) => {
134
- if (e) {
135
- if (P.isArray(e.keys))
136
- return O(e.keys);
137
- if (P.isArray(e.banKeys)) {
138
- const r = Object.keys(h).filter((t) => e.banKeys?.includes(t));
139
- return O(r);
140
- }
141
- return d.store.state.values;
142
- }
143
- }, g = () => {
144
- const e = n?.persistency;
145
- if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
146
- const r = e.policies.includes("local") ? localStorage : sessionStorage;
147
- if (!r) return;
148
- const t = U(e);
149
- return r.setItem(u.value, JSON.stringify(t));
150
- }
151
- }, L = () => {
152
- const e = n?.persistency;
153
- if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
154
- const r = U(e), t = new URLSearchParams(window.location.search);
155
- t.set(u.value, JSON.stringify(r));
156
- const s = new URL(window.location.href);
157
- s.search = t.toString(), window.history.replaceState({}, "", s.toString());
158
- }
159
- };
160
- N(g), T(() => {
161
- window.addEventListener("beforeunload", g), window.addEventListener("blur", L);
162
- }), W(() => {
163
- window.removeEventListener("beforeunload", g), window.removeEventListener("blur", L);
164
- });
165
- const $ = (e) => l.currentSpan.pipe(
166
- l.option,
167
- l.flatMap(
168
- (r) => l.promise(() => d.handleSubmit(M.isSome(r) ? { currentSpan: r.value, ...e } : e))
169
- )
170
- ), x = (e) => e?.checkErrors ? $(e?.meta).pipe(l.flatMap(l.fnUntraced(function* () {
171
- const r = d.getAllErrors();
172
- if (Object.keys(r.fields).length || r.form.errors.length)
173
- return yield* new te({ form: r.form, fields: r.fields });
174
- }))) : $(e?.meta), H = d.handleSubmit, E = k(/* @__PURE__ */ new Map()), m = Object.assign(d, {
175
- i18nNamespace: n?.i18nNamespace,
176
- meta: h,
177
- clear: R,
178
- handleSubmit: (e) => {
179
- const r = _.getSpan(V.active());
180
- return H({ currentSpan: r, ...e });
181
- },
182
- // /** @experimental */
183
- handleSubmitEffect: x,
184
- registerField: (e) => {
185
- z(e, (r) => E.value.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), N(() => E.value.delete(e.value.name));
186
- }
187
- }), A = { form: m, fieldMap: E };
188
- return n?.ignorePreventCloseEvents || Q(() => m.useStore((e) => e.isDirty)), Object.assign(m, {
189
- errorContext: A,
190
- Form: w(m)(re),
191
- Input: w(m)(n?.input ?? ee),
192
- Field: d.Field,
193
- Errors: se(A)(Z),
194
- Array: w(m)(X),
195
- AutoGen: w(m)(Y)
196
- });
197
- };
38
+ const h = (t) => {
39
+ const r = {
40
+ get(O, v, z) {
41
+ return v === "handleChange" ? y : Reflect.get(...arguments);
42
+ }
43
+ };
44
+ return new Proxy(t, r);
45
+ }, a = n(() => ({
46
+ inputProps: {
47
+ id: s,
48
+ required: e.meta?.required,
49
+ minLength: e.meta?.type === "string" && e.meta?.minLength,
50
+ maxLength: e.meta?.type === "string" && e.meta?.maxLength,
51
+ max: e.meta?.type === "number" && e.meta?.maximum,
52
+ min: e.meta?.type === "number" && e.meta?.minimum,
53
+ errorMessages: i.value,
54
+ error: !!i.value.length,
55
+ type: d.value,
56
+ label: `${e.label}${e.meta?.required ? " *" : ""}`,
57
+ options: e.options
58
+ },
59
+ state: e.state,
60
+ field: h(e.field)
61
+ }));
62
+ return (t, r) => P(t.$slots, "default", m(M({ ...a.value.inputProps, field: a.value.field, state: a.value.state })), () => [
63
+ N("div", {
64
+ class: $(t.$attrs.class)
65
+ }, [
66
+ q(p) ? (B(), V(L, m(F({ key: 0 }, { ...t.$attrs, ...a.value })), null, 16)) : k("", !0)
67
+ ], 2)
68
+ ]);
69
+ }
70
+ });
198
71
  export {
199
- te as FormErrors,
200
- we as useOmegaForm
72
+ U as default
201
73
  };
@@ -1,32 +1,201 @@
1
- import r from "./vue-components.es22.js";
2
- import { inject as c, provide as l } from "vue";
3
- import { onMountedWithCleanup as u } from "./vue-components.es23.js";
4
- const f = () => r(), i = Symbol("DialogBus"), p = () => c(i, null), g = () => {
5
- const e = f();
6
- return l(i, e), e;
7
- }, d = (e) => {
8
- const o = p();
9
- if (!o)
10
- return;
11
- const s = e();
12
- u(() => {
13
- const n = (t) => {
14
- s.value && (confirm("Es sind ungespeicherte Änderungen vorhanden. Wirklich schließen?") || (t.prevent = !0));
15
- };
16
- return o.on("dialog-closing", n), () => o.off("dialog-closing", n);
17
- });
18
- }, h = (e) => {
19
- const o = g();
20
- return () => {
21
- const n = {};
22
- o.emit("dialog-closing", n), n.prevent ? typeof n.prevent == "object" && "then" in n.prevent && n.prevent.then((t) => {
23
- t !== !1 && e();
24
- }) : e();
1
+ import { useForm as q } from "@tanstack/vue-form";
2
+ import { Data as K, S as I, Effect as l, Fiber as F, Option as M, Array as P } from "effect-app";
3
+ import { runtimeFiberAsPromise as B } from "./vue-components.es14.js";
4
+ import { isObject as G } from "./vue-components.es15.js";
5
+ import { computed as j, onUnmounted as N, onMounted as T, onBeforeUnmount as W, ref as k, watch as z, h as D } from "vue";
6
+ import { usePreventClose as Q } from "./vue-components.es9.js";
7
+ import X from "./vue-components.es16.js";
8
+ import Y from "./vue-components.es17.js";
9
+ import Z from "./vue-components.es18.js";
10
+ import { generateMetaFromSchema as C } from "./vue-components.es10.js";
11
+ import ee from "./vue-components.es6.js";
12
+ import re from "./vue-components.es19.js";
13
+ import { trace as _ } from "./vue-components.es20.js";
14
+ import { context as V } from "./vue-components.es21.js";
15
+ class te extends K.TaggedError("FormErrors") {
16
+ }
17
+ const w = (c) => function(n) {
18
+ return {
19
+ render() {
20
+ return D(n, {
21
+ form: c,
22
+ ...this.$attrs
23
+ }, this.$slots);
24
+ }
25
+ };
26
+ }, se = (c) => function(n) {
27
+ return {
28
+ setup() {
29
+ const { fieldMap: f, form: p } = c, h = p.useStore((a) => a.errors), u = p.useStore((a) => a.fieldMeta), b = j(
30
+ () => P.filterMap(
31
+ Object.entries(u.value),
32
+ ([a, v]) => (v.errors ?? []).length && f.value.get(a)?.id ? M.some({
33
+ label: f.value.get(a).label,
34
+ inputId: f.value.get(a).id,
35
+ errors: (v.errors ?? []).map((y) => y.message).filter(Boolean)
36
+ }) : M.none()
37
+ )
38
+ );
39
+ return {
40
+ generalErrors: h,
41
+ errors: b
42
+ };
43
+ },
44
+ render({ errors: f, generalErrors: p }) {
45
+ return D(n, {
46
+ errors: f,
47
+ generalErrors: p,
48
+ ...this.$attrs
49
+ }, this.$slots);
50
+ }
51
+ };
52
+ }, we = (c, i, n) => {
53
+ if (!c) throw new Error("Schema is required");
54
+ const f = I.standardSchemaV1(c), p = I.decode(c), { meta: h } = C(c), u = j(() => {
55
+ if (n?.persistency?.id)
56
+ return n.persistency.id;
57
+ const e = window.location.pathname, r = Object.keys(h);
58
+ return `${e}-${r.join("-")}`;
59
+ }), b = () => {
60
+ const e = new URLSearchParams(window.location.search);
61
+ e.delete(u.value);
62
+ const r = new URL(window.location.href);
63
+ r.search = e.toString(), window.history.replaceState({}, "", r.toString());
25
64
  };
65
+ function a(e, r) {
66
+ for (const t in r)
67
+ r[t] && G(r[t]) ? (e[t] || (e[t] = {}), a(e[t], r[t])) : e[t] = r[t];
68
+ return e;
69
+ }
70
+ const v = j(() => {
71
+ if (i?.defaultValues && !n?.persistency?.overrideDefaultValues)
72
+ return i?.defaultValues;
73
+ let e;
74
+ const r = n?.persistency;
75
+ if (!r?.policies || r.policies.length === 0) return {};
76
+ if (r.policies.includes("querystring"))
77
+ try {
78
+ const s = new URLSearchParams(window.location.search).get(u.value);
79
+ b(), s && (e = JSON.parse(s));
80
+ } catch (t) {
81
+ console.error(t);
82
+ }
83
+ if (
84
+ // query string has higher priority than local/session storage
85
+ !e && (r.policies.includes("local") || r.policies.includes("session"))
86
+ ) {
87
+ const t = r.policies.includes("local") ? localStorage : sessionStorage;
88
+ if (t)
89
+ try {
90
+ const s = JSON.parse(
91
+ t.getItem(u.value) || "{}"
92
+ );
93
+ t.removeItem(u.value), e = s;
94
+ } catch (s) {
95
+ console.error(s);
96
+ }
97
+ }
98
+ if (e ??= {}, i?.defaultValues == null)
99
+ return e;
100
+ {
101
+ const t = i?.defaultValues;
102
+ return a(t, e);
103
+ }
104
+ }), y = (e, r) => e ? V.with(_.setSpan(V.active(), e), r) : r(), d = q({
105
+ ...i,
106
+ validators: {
107
+ onSubmit: f,
108
+ ...i?.validators || {}
109
+ },
110
+ onSubmit: i?.onSubmit ? ({ formApi: e, meta: r, value: t }) => y(r?.currentSpan, async () => {
111
+ const s = await l.runPromise(p(t)), o = i.onSubmit({
112
+ formApi: e,
113
+ meta: r,
114
+ value: s
115
+ });
116
+ return F.isFiber(o) && F.isRuntimeFiber(o) ? await B(o) : l.isEffect(o) ? await l.runPromise(
117
+ o.pipe(
118
+ // meta?.currentSpan
119
+ // ? Effect.withParentSpan(meta.currentSpan)
120
+ // : (_) => _,
121
+ l.flatMap((S) => F.join(S))
122
+ )
123
+ ) : o;
124
+ }) : void 0,
125
+ defaultValues: v.value
126
+ }), R = () => {
127
+ Object.keys(h).forEach((e) => {
128
+ d.setFieldValue(e, void 0);
129
+ });
130
+ }, O = (e) => e.reduce((r, t) => {
131
+ const s = t.split(".");
132
+ return s.reduce((o, S, J) => (J === s.length - 1 ? o[S] = d.getFieldValue(t) : o[S] = o[S] ?? {}, o[S]), r), r;
133
+ }, {}), U = (e) => {
134
+ if (e) {
135
+ if (P.isArray(e.keys))
136
+ return O(e.keys);
137
+ if (P.isArray(e.banKeys)) {
138
+ const r = Object.keys(h).filter((t) => e.banKeys?.includes(t));
139
+ return O(r);
140
+ }
141
+ return d.store.state.values;
142
+ }
143
+ }, g = () => {
144
+ const e = n?.persistency;
145
+ if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
146
+ const r = e.policies.includes("local") ? localStorage : sessionStorage;
147
+ if (!r) return;
148
+ const t = U(e);
149
+ return r.setItem(u.value, JSON.stringify(t));
150
+ }
151
+ }, L = () => {
152
+ const e = n?.persistency;
153
+ if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
154
+ const r = U(e), t = new URLSearchParams(window.location.search);
155
+ t.set(u.value, JSON.stringify(r));
156
+ const s = new URL(window.location.href);
157
+ s.search = t.toString(), window.history.replaceState({}, "", s.toString());
158
+ }
159
+ };
160
+ N(g), T(() => {
161
+ window.addEventListener("beforeunload", g), window.addEventListener("blur", L);
162
+ }), W(() => {
163
+ window.removeEventListener("beforeunload", g), window.removeEventListener("blur", L);
164
+ });
165
+ const $ = (e) => l.currentSpan.pipe(
166
+ l.option,
167
+ l.flatMap(
168
+ (r) => l.promise(() => d.handleSubmit(M.isSome(r) ? { currentSpan: r.value, ...e } : e))
169
+ )
170
+ ), x = (e) => e?.checkErrors ? $(e?.meta).pipe(l.flatMap(l.fnUntraced(function* () {
171
+ const r = d.getAllErrors();
172
+ if (Object.keys(r.fields).length || r.form.errors.length)
173
+ return yield* new te({ form: r.form, fields: r.fields });
174
+ }))) : $(e?.meta), H = d.handleSubmit, E = k(/* @__PURE__ */ new Map()), m = Object.assign(d, {
175
+ i18nNamespace: n?.i18nNamespace,
176
+ meta: h,
177
+ clear: R,
178
+ handleSubmit: (e) => {
179
+ const r = _.getSpan(V.active());
180
+ return H({ currentSpan: r, ...e });
181
+ },
182
+ // /** @experimental */
183
+ handleSubmitEffect: x,
184
+ registerField: (e) => {
185
+ z(e, (r) => E.value.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), N(() => E.value.delete(e.value.name));
186
+ }
187
+ }), A = { form: m, fieldMap: E };
188
+ return n?.ignorePreventCloseEvents || Q(() => m.useStore((e) => e.isDirty)), Object.assign(m, {
189
+ errorContext: A,
190
+ Form: w(m)(re),
191
+ Input: w(m)(n?.input ?? ee),
192
+ Field: d.Field,
193
+ Errors: se(A)(Z),
194
+ Array: w(m)(X),
195
+ AutoGen: w(m)(Y)
196
+ });
26
197
  };
27
198
  export {
28
- p as injectBus,
29
- g as provideBus,
30
- h as useOnClose,
31
- d as usePreventClose
199
+ te as FormErrors,
200
+ we as useOmegaForm
32
201
  };