@effect-app/vue-components 1.0.0-next.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +5 -2
  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 +135 -2
  15. package/dist/vue-components.es2.js +10 -8
  16. package/dist/vue-components.es21.js +41 -89
  17. package/dist/vue-components.es23.js +2 -7
  18. package/dist/vue-components.es24.js +86 -27
  19. package/dist/vue-components.es26.js +7 -2
  20. package/dist/vue-components.es27.js +31 -23
  21. package/dist/vue-components.es29.js +4 -21
  22. package/dist/vue-components.es30.js +20 -27
  23. package/dist/vue-components.es31.js +5 -22
  24. package/dist/vue-components.es32.js +15 -6
  25. package/dist/vue-components.es33.js +30 -5
  26. package/dist/vue-components.es34.js +22 -19
  27. package/dist/vue-components.es35.js +12 -9
  28. package/dist/vue-components.es36.js +5 -31
  29. package/dist/vue-components.es37.js +19 -48
  30. package/dist/vue-components.es38.js +9 -26
  31. package/dist/vue-components.es39.js +31 -11
  32. package/dist/vue-components.es4.js +80 -42
  33. package/dist/vue-components.es40.js +47 -114
  34. package/dist/vue-components.es41.js +28 -0
  35. package/dist/vue-components.es42.js +11 -65
  36. package/dist/vue-components.es43.js +54 -45
  37. package/dist/vue-components.es44.js +54 -15
  38. package/dist/vue-components.es45.js +15 -31
  39. package/dist/vue-components.es46.js +30 -26
  40. package/dist/vue-components.es47.js +29 -42
  41. package/dist/vue-components.es48.js +42 -4
  42. package/dist/vue-components.es5.js +51 -29
  43. package/dist/vue-components.es6.js +27 -207
  44. package/dist/vue-components.es7.js +202 -343
  45. package/dist/vue-components.es8.js +350 -2
  46. package/dist/vue-components.es9.js +2 -10
  47. package/package.json +3 -3
  48. package/src/components/OmegaForm/OmegaFormStuff.ts +5 -2
  49. package/src/components/OmegaForm/OmegaInputVuetify.vue +19 -0
  50. package/src/components/OmegaForm/index.ts +2 -0
  51. package/src/components/OmegaForm/useOmegaForm.ts +287 -29
  52. package/dist/vue-components.es28.js +0 -7
  53. /package/dist/{vue-components.es20.js → vue-components.es22.js} +0 -0
@@ -1,6 +1,44 @@
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 o from "./vue-components.es40.js";
3
-
1
+ import { ROOT_CONTEXT as l } from "./vue-components.es30.js";
2
+ var c = function(t, o) {
3
+ var n = typeof Symbol == "function" && t[Symbol.iterator];
4
+ if (!n) return t;
5
+ var e = n.call(t), a, r = [], u;
6
+ try {
7
+ for (; (o === void 0 || o-- > 0) && !(a = e.next()).done; ) r.push(a.value);
8
+ } catch (i) {
9
+ u = { error: i };
10
+ } finally {
11
+ try {
12
+ a && !a.done && (n = e.return) && n.call(e);
13
+ } finally {
14
+ if (u) throw u.error;
15
+ }
16
+ }
17
+ return r;
18
+ }, p = function(t, o, n) {
19
+ if (n || arguments.length === 2) for (var e = 0, a = o.length, r; e < a; e++)
20
+ (r || !(e in o)) && (r || (r = Array.prototype.slice.call(o, 0, e)), r[e] = o[e]);
21
+ return t.concat(r || Array.prototype.slice.call(o));
22
+ }, y = (
23
+ /** @class */
24
+ (function() {
25
+ function t() {
26
+ }
27
+ return t.prototype.active = function() {
28
+ return l;
29
+ }, t.prototype.with = function(o, n, e) {
30
+ for (var a = [], r = 3; r < arguments.length; r++)
31
+ a[r - 3] = arguments[r];
32
+ return n.call.apply(n, p([e], c(a), !1));
33
+ }, t.prototype.bind = function(o, n) {
34
+ return n;
35
+ }, t.prototype.enable = function() {
36
+ return this;
37
+ }, t.prototype.disable = function() {
38
+ return this;
39
+ }, t;
40
+ })()
41
+ );
4
42
  export {
5
- o as default
43
+ y as NoopContextManager
6
44
  };
@@ -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
  };