@effect-app/vue-components 1.0.0-next.9 → 1.0.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 (43) hide show
  1. package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +1 -1
  2. package/dist/types/components/OmegaForm/index.d.ts +1 -0
  3. package/dist/types/components/OmegaForm/useOmegaForm.d.ts +26 -13
  4. package/dist/vue-components.es.js +21 -19
  5. package/dist/vue-components.es10.js +10 -5
  6. package/dist/vue-components.es11.js +5 -54
  7. package/dist/vue-components.es12.js +49 -66
  8. package/dist/vue-components.es13.js +71 -6
  9. package/dist/vue-components.es14.js +5 -5
  10. package/dist/vue-components.es15.js +6 -3
  11. package/dist/vue-components.es16.js +3 -3
  12. package/dist/vue-components.es17.js +3 -89
  13. package/dist/vue-components.es18.js +2 -42
  14. package/dist/vue-components.es19.js +42 -2
  15. package/dist/vue-components.es2.js +10 -8
  16. package/dist/vue-components.es21.js +2 -90
  17. package/dist/vue-components.es22.js +92 -0
  18. package/dist/vue-components.es24.js +7 -31
  19. package/dist/vue-components.es25.js +33 -0
  20. package/dist/vue-components.es30.js +1 -1
  21. package/dist/vue-components.es37.js +3 -3
  22. package/dist/vue-components.es38.js +3 -3
  23. package/dist/vue-components.es39.js +43 -23
  24. package/dist/vue-components.es4.js +80 -42
  25. package/dist/vue-components.es42.js +4 -65
  26. package/dist/vue-components.es43.js +54 -45
  27. package/dist/vue-components.es44.js +54 -15
  28. package/dist/vue-components.es45.js +15 -31
  29. package/dist/vue-components.es46.js +30 -26
  30. package/dist/vue-components.es47.js +29 -42
  31. package/dist/vue-components.es48.js +42 -4
  32. package/dist/vue-components.es5.js +51 -29
  33. package/dist/vue-components.es6.js +27 -207
  34. package/dist/vue-components.es7.js +202 -343
  35. package/dist/vue-components.es8.js +350 -2
  36. package/dist/vue-components.es9.js +2 -10
  37. package/package.json +4 -4
  38. package/src/components/OmegaForm/OmegaFormStuff.ts +1 -0
  39. package/src/components/OmegaForm/OmegaInputVuetify.vue +19 -0
  40. package/src/components/OmegaForm/index.ts +2 -0
  41. package/src/components/OmegaForm/useOmegaForm.ts +287 -29
  42. package/dist/vue-components.es23.js +0 -9
  43. package/dist/vue-components.es26.js +0 -4
@@ -1,31 +1,53 @@
1
- import { ref as a, computed as l, readonly as d, inject as E } from "vue";
2
- const f = Symbol();
3
- function b(o, u, t = "onSubmit") {
4
- const r = a([]), n = (e) => {
5
- r.value = r.value.filter((m) => m.inputId !== e);
6
- }, s = (e) => {
7
- n(e.inputId), r.value.push(e);
8
- }, c = () => {
9
- r.value = [];
10
- }, i = l(() => t === "onSubmit" ? o.value > 0 : !0);
11
- return {
12
- errors: d(r),
13
- addError: s,
14
- removeError: n,
15
- clearErrors: c,
16
- showErrors: i,
17
- generalErrors: u,
18
- showErrorsOn: t ?? "onSubmit"
19
- };
20
- }
21
- function g() {
22
- const o = E(f);
23
- if (!o)
24
- throw new Error("useOmegaErrors must be used within an OmegaForm provider");
25
- return o;
26
- }
1
+ import { defineComponent as y, inject as h, computed as l, createBlock as s, openBlock as i, resolveDynamicComponent as M, withCtx as p, createCommentVNode as $, mergeProps as b, renderSlot as C, normalizeProps as k, guardReactiveProps as F } from "vue";
2
+ import { useIntl as A } from "./vue-components.es3.js";
3
+ import { generateInputStandardSchemaFromFieldMeta as w } from "./vue-components.es8.js";
4
+ import I from "./vue-components.es4.js";
5
+ const z = /* @__PURE__ */ y({
6
+ inheritAttrs: !1,
7
+ __name: "OmegaInput",
8
+ props: {
9
+ form: {},
10
+ name: {},
11
+ label: {},
12
+ validators: {},
13
+ options: {},
14
+ type: {}
15
+ },
16
+ setup(u) {
17
+ const e = u, r = h(
18
+ "getMetaFromArray",
19
+ null
20
+ ), t = l(() => r?.value && r.value(e.name) ? r.value(e.name) : e.form.meta[e.name]), f = l(() => {
21
+ if (!t.value)
22
+ throw console.log(e.name, Object.keys(e.form.meta), e.form.meta), new Error("Meta is undefined");
23
+ return w(t.value);
24
+ }), { formatMessage: o } = A(), d = (a) => a.replace(/([A-Z])/g, " $1").replace(/^./, (m) => m.toUpperCase()).trim(), n = () => o({ id: `general.fields.${e.name}`, defaultMessage: d(e.name) }), c = () => e.form.i18nNamespace ? o({ id: `${e.form.i18nNamespace}.fields.${e.name}`, defaultMessage: n() }) : n();
25
+ return (a, m) => (i(), s(M(a.form.Field), {
26
+ name: a.name,
27
+ validators: {
28
+ onChange: f.value,
29
+ ...a.validators
30
+ }
31
+ }, {
32
+ default: p(({ field: v }) => [
33
+ t.value ? (i(), s(I, b({
34
+ key: 0,
35
+ field: v,
36
+ label: a.label ?? c(),
37
+ options: a.options,
38
+ meta: t.value,
39
+ type: a.type
40
+ }, a.$attrs), {
41
+ default: p((g) => [
42
+ C(a.$slots, "default", k(F(g)))
43
+ ]),
44
+ _: 3
45
+ }, 16, ["field", "label", "options", "meta", "type"])) : $("", !0)
46
+ ]),
47
+ _: 3
48
+ }, 8, ["name", "validators"]));
49
+ }
50
+ });
27
51
  export {
28
- f as OmegaErrorsKey,
29
- b as buildOmegaErrors,
30
- g as useOmegaErrors
52
+ z as default
31
53
  };
@@ -1,211 +1,31 @@
1
- import { useForm as D, useStore as H } from "@tanstack/vue-form";
2
- import { S as O, Effect as d, Fiber as y } from "effect-app";
3
- import { runtimeFiberAsPromise as J } from "./vue-components.es9.js";
4
- import { isObject as q } from "./vue-components.es10.js";
5
- import { computed as I, onUnmounted as K, onMounted as B, onBeforeUnmount as G, watch as W, h as $ } from "vue";
6
- import k from "./vue-components.es11.js";
7
- import z from "./vue-components.es12.js";
8
- import { buildOmegaErrors as Q } from "./vue-components.es5.js";
9
- import T from "./vue-components.es13.js";
10
- import { generateMetaFromSchema as X } from "./vue-components.es7.js";
11
- import Y from "./vue-components.es4.js";
12
- import Z from "./vue-components.es14.js";
13
- import { trace as P } from "./vue-components.es15.js";
14
- import { context as g } from "./vue-components.es16.js";
15
- const p = (c) => function(o) {
1
+ import { ref as a, computed as l, readonly as d, inject as E } from "vue";
2
+ const f = Symbol();
3
+ function b(o, u, t = "onSubmit") {
4
+ const r = a([]), n = (e) => {
5
+ r.value = r.value.filter((m) => m.inputId !== e);
6
+ }, s = (e) => {
7
+ n(e.inputId), r.value.push(e);
8
+ }, c = () => {
9
+ r.value = [];
10
+ }, i = l(() => t === "onSubmit" ? o.value > 0 : !0);
16
11
  return {
17
- render() {
18
- return $(o, {
19
- form: c,
20
- on: this.$listeners,
21
- attrs: this.$attrs
22
- }, this.$slots);
23
- }
12
+ errors: d(r),
13
+ addError: s,
14
+ removeError: n,
15
+ clearErrors: c,
16
+ showErrors: i,
17
+ generalErrors: u,
18
+ showErrorsOn: t ?? "onSubmit"
24
19
  };
25
- }, C = (c) => function(o) {
26
- return {
27
- setup() {
28
- return {
29
- ...c
30
- };
31
- },
32
- render({ errors: h, generalErrors: w, showErrors: S }) {
33
- return $(o, {
34
- errors: h,
35
- generalErrors: w,
36
- showErrors: S,
37
- on: this.$listeners,
38
- attrs: this.$attrs
39
- }, this.$slots);
40
- }
41
- };
42
- }, pe = (c, a, o) => {
43
- if (!c) throw new Error("Schema is required");
44
- const h = O.standardSchemaV1(c), w = O.decode(c), { filterItems: S, meta: f } = X(c), l = I(() => {
45
- if (o?.persistency?.id)
46
- return o.persistency.id;
47
- const e = window.location.pathname, r = Object.keys(f);
48
- return `${e}-${r.join("-")}`;
49
- }), A = () => {
50
- const e = new URLSearchParams(window.location.search);
51
- e.delete(l.value);
52
- const r = new URL(window.location.href);
53
- r.search = e.toString(), window.history.replaceState({}, "", r.toString());
54
- };
55
- function E(e, r) {
56
- for (const t in r)
57
- r[t] && q(r[t]) ? (e[t] || (e[t] = {}), E(e[t], r[t])) : e[t] = r[t];
58
- return e;
59
- }
60
- const U = I(() => {
61
- if (a?.defaultValues && !o?.persistency?.overrideDefaultValues)
62
- return a?.defaultValues;
63
- let e;
64
- const r = o?.persistency;
65
- if (!r?.policies || r.policies.length === 0) return {};
66
- if (r.policies.includes("querystring"))
67
- try {
68
- const s = new URLSearchParams(window.location.search).get(l.value);
69
- A(), s && (e = JSON.parse(s));
70
- } catch (t) {
71
- console.error(t);
72
- }
73
- if (
74
- // query string has higher priority than local/session storage
75
- !e && (r.policies.includes("local") || r.policies.includes("session"))
76
- ) {
77
- const t = r.policies.includes("local") ? localStorage : sessionStorage;
78
- if (t)
79
- try {
80
- const s = JSON.parse(
81
- t.getItem(l.value) || "{}"
82
- );
83
- t.removeItem(l.value), e = s;
84
- } catch (s) {
85
- console.error(s);
86
- }
87
- }
88
- if (e ??= {}, a?.defaultValues == null)
89
- return e;
90
- {
91
- const t = a?.defaultValues;
92
- return E(t, e);
93
- }
94
- }), M = (e, r) => e ? g.with(P.setSpan(g.active(), e), r) : r(), u = D({
95
- ...a,
96
- validators: {
97
- onSubmit: h,
98
- ...a?.validators || {}
99
- },
100
- onSubmit: a?.onSubmit ? ({ formApi: e, meta: r, value: t }) => M(r?.currentSpan, async () => {
101
- const s = await d.runPromise(w(t)), n = a.onSubmit({
102
- formApi: e,
103
- meta: r,
104
- value: s
105
- });
106
- return y.isFiber(n) && y.isRuntimeFiber(n) ? await J(n) : d.isEffect(n) ? await d.runPromise(
107
- n.pipe(
108
- // meta?.currentSpan
109
- // ? Effect.withParentSpan(meta.currentSpan)
110
- // : (_) => _,
111
- d.flatMap((m) => y.join(m))
112
- )
113
- ) : n;
114
- }) : void 0,
115
- defaultValues: U.value
116
- }), N = () => {
117
- Object.keys(f).forEach((e) => {
118
- u.setFieldValue(e, void 0);
119
- });
120
- }, V = (e) => e.reduce((r, t) => {
121
- const s = t.split(".");
122
- return s.reduce((n, m, x) => (x === s.length - 1 ? n[m] = u.getFieldValue(t) : n[m] = n[m] ?? {}, n[m]), r), r;
123
- }, {}), F = (e) => {
124
- if (e) {
125
- if (Array.isArray(e.keys))
126
- return V(e.keys);
127
- if (Array.isArray(e.banKeys)) {
128
- const r = Object.keys(f).filter((t) => e.banKeys?.includes(t));
129
- return V(r);
130
- }
131
- return u.store.state.values;
132
- }
133
- }, v = () => {
134
- const e = o?.persistency;
135
- if (!(!e?.policies || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
136
- const r = e.policies.includes("local") ? localStorage : sessionStorage;
137
- if (!r) return;
138
- const t = F(e);
139
- return r.setItem(l.value, JSON.stringify(t));
140
- }
141
- }, j = () => {
142
- const e = o?.persistency;
143
- if (!(!e?.policies || e.policies.length === 0) && e.policies.includes("querystring")) {
144
- const r = F(e), t = new URLSearchParams(window.location.search);
145
- t.set(l.value, JSON.stringify(r));
146
- const s = new URL(window.location.href);
147
- s.search = t.toString(), window.history.replaceState({}, "", s.toString());
148
- }
149
- };
150
- K(v), B(() => {
151
- window.addEventListener("beforeunload", v), window.addEventListener("blur", j);
152
- }), G(() => {
153
- window.removeEventListener("beforeunload", v), window.removeEventListener("blur", j);
154
- });
155
- const R = u.handleSubmit, i = Object.assign(u, {
156
- i18nNamespace: o?.i18nNamespace,
157
- meta: f,
158
- filterItems: S,
159
- clear: N,
160
- handleSubmit: (e) => {
161
- const r = P.getSpan(g.active());
162
- return R({ currentSpan: r, ...e });
163
- }
164
- // /** @experimental */
165
- // handleSubmitEffect: (meta?: Record<string, any>) =>
166
- // Effect.currentSpan.pipe(
167
- // Effect.option,
168
- // Effect
169
- // .flatMap((span) =>
170
- // Effect.promise(() => form.handleSubmit(Option.isSome(span) ? { currentSpan: span.value, ...meta } : meta))
171
- // )
172
- // )
173
- }), _ = H(
174
- i.store,
175
- (e) => e.submissionAttempts
176
- ), b = i.useStore((e) => e.errors);
177
- W(
178
- () => [i.filterItems, b.value],
179
- () => {
180
- const e = i.filterItems, r = b.value;
181
- return e ? r ? (Object.values(r).filter(
182
- (s) => !!s
183
- ).flatMap(
184
- (s) => Object.values(s).flat().map((n) => n.message)
185
- ).some((s) => s === e.message) && e.items.forEach((s) => {
186
- const n = i.getFieldMeta(s);
187
- n && i.setFieldMeta(s, {
188
- ...n,
189
- errorMap: {
190
- onSubmit: [
191
- { path: [s], message: e.message }
192
- ]
193
- }
194
- });
195
- }), {}) : {} : {};
196
- }
197
- );
198
- const L = Q(_, b, o?.showErrorsOn);
199
- return Object.assign(i, {
200
- errorContext: L,
201
- Form: p(i)(Z),
202
- Input: p(i)(o?.input ?? Y),
203
- Field: u.Field,
204
- Errors: C(L)(T),
205
- Array: p(i)(k),
206
- AutoGen: p(i)(z)
207
- });
208
- };
20
+ }
21
+ function g() {
22
+ const o = E(f);
23
+ if (!o)
24
+ throw new Error("useOmegaErrors must be used within an OmegaForm provider");
25
+ return o;
26
+ }
209
27
  export {
210
- pe as useOmegaForm
28
+ f as OmegaErrorsKey,
29
+ b as buildOmegaErrors,
30
+ g as useOmegaErrors
211
31
  };