@effect-app/vue-components 0.5.0 → 0.6.2

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 (42) hide show
  1. package/dist/types/components/OmegaForm/OmegaAutoGen.vue.d.ts +30 -0
  2. package/dist/types/components/OmegaForm/index.d.ts +3 -7
  3. package/dist/vue-components.es.js +24 -27
  4. package/dist/vue-components.es10.js +6 -23
  5. package/dist/vue-components.es11.js +3 -3
  6. package/dist/vue-components.es15.js +1 -1
  7. package/dist/vue-components.es17.js +2 -5
  8. package/dist/vue-components.es18.js +5 -32
  9. package/dist/vue-components.es19.js +32 -2
  10. package/dist/vue-components.es2.js +16 -19
  11. package/dist/vue-components.es20.js +2 -2
  12. package/dist/vue-components.es21.js +2 -98
  13. package/dist/vue-components.es22.js +98 -11
  14. package/dist/vue-components.es23.js +11 -2
  15. package/dist/vue-components.es24.js +2 -115
  16. package/dist/vue-components.es25.js +117 -0
  17. package/dist/{vue-components.es26.js → vue-components.es27.js} +1 -1
  18. package/dist/vue-components.es3.js +3 -3
  19. package/dist/vue-components.es4.js +2 -2
  20. package/dist/vue-components.es5.js +78 -36
  21. package/dist/vue-components.es6.js +34 -131
  22. package/dist/vue-components.es7.js +128 -211
  23. package/dist/vue-components.es8.js +216 -6
  24. package/dist/vue-components.es9.js +4 -4
  25. package/package.json +9 -3
  26. package/src/components/OmegaForm/OmegaAutoGen.vue +110 -0
  27. package/src/components/OmegaForm/OmegaWrapper.vue +1 -1
  28. package/src/components/OmegaForm/index.ts +3 -21
  29. package/src/env.d.ts +0 -8
  30. package/src/stories/OmegaForm/Clearable.vue +0 -20
  31. package/src/stories/OmegaForm/ComplexForm.vue +0 -87
  32. package/src/stories/OmegaForm/EmailForm.vue +0 -48
  33. package/src/stories/OmegaForm/Meta.vue +0 -47
  34. package/src/stories/OmegaForm/OneHundredWaysToWriteAForm.vue +0 -188
  35. package/src/stories/OmegaForm/PersistencyForm.vue +0 -58
  36. package/src/stories/OmegaForm/SimpleForm.vue +0 -30
  37. package/src/stories/OmegaForm/SimpleFormVuetifyDefault.vue +0 -15
  38. package/src/stories/OmegaForm/SumExample.vue +0 -37
  39. package/src/stories/OmegaForm/form.Input.vue +0 -98
  40. package/src/stories/OmegaForm.stories.ts +0 -114
  41. package/src/stories/README.md +0 -29
  42. package/src/stories/tsconfig.json +0 -4
@@ -1,117 +1,4 @@
1
- import { defineComponent as P, resolveComponent as i, createElementBlock as g, openBlock as o, createBlock as n, createCommentVNode as l, mergeProps as s } from "vue";
2
- const b = /* @__PURE__ */ P({
3
- inheritAttrs: !1,
4
- __name: "OmegaInputVuetify",
5
- props: {
6
- inputProps: {},
7
- vuetifyValue: {}
8
- },
9
- emits: ["focus", "blur"],
10
- setup(y) {
11
- return (e, r) => {
12
- const a = i("v-checkbox"), u = i("v-text-field"), t = i("v-textarea"), m = i("v-select"), d = i("v-autocomplete");
13
- return o(), g("div", {
14
- class: "omega-input",
15
- onFocusout: r[4] || (r[4] = (p) => e.$emit("blur", p)),
16
- onFocusin: r[5] || (r[5] = (p) => e.$emit("focus", p))
17
- }, [
18
- e.inputProps.type === "boolean" ? (o(), n(a, s({
19
- key: 0,
20
- id: e.inputProps.id,
21
- name: e.inputProps.name,
22
- label: e.inputProps.label,
23
- "error-messages": e.inputProps.errorMessages,
24
- error: e.inputProps.error,
25
- ripple: ""
26
- }, e.$attrs, {
27
- "model-value": e.vuetifyValue,
28
- onChange: r[0] || (r[0] = (p) => e.inputProps.field.handleChange(p.target.checked))
29
- }), null, 16, ["id", "name", "label", "error-messages", "error", "model-value"])) : l("", !0),
30
- e.inputProps.type === "email" || e.inputProps.type === "string" ? (o(), n(u, s({
31
- key: 1,
32
- id: e.inputProps.id,
33
- required: e.inputProps.required,
34
- "min-length": e.inputProps.minLength,
35
- "max-length": e.inputProps.maxLength,
36
- type: e.inputProps.type,
37
- name: e.inputProps.name,
38
- label: e.inputProps.label,
39
- "error-messages": e.inputProps.errorMessages,
40
- error: e.inputProps.error
41
- }, e.$attrs, {
42
- "model-value": e.vuetifyValue,
43
- "onUpdate:modelValue": e.inputProps.field.handleChange
44
- }), null, 16, ["id", "required", "min-length", "max-length", "type", "name", "label", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
45
- e.inputProps.type === "text" ? (o(), n(t, s({
46
- key: 2,
47
- id: e.inputProps.id,
48
- required: e.inputProps.required,
49
- "min-length": e.inputProps.minLength,
50
- "max-length": e.inputProps.maxLength,
51
- type: e.inputProps.type,
52
- name: e.inputProps.name,
53
- label: e.inputProps.label,
54
- "error-messages": e.inputProps.errorMessages,
55
- error: e.inputProps.error
56
- }, e.$attrs, {
57
- "model-value": e.vuetifyValue,
58
- "onUpdate:modelValue": e.inputProps.field.handleChange
59
- }), null, 16, ["id", "required", "min-length", "max-length", "type", "name", "label", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
60
- e.inputProps.type === "number" ? (o(), n(u, s({
61
- key: 3,
62
- id: e.inputProps.id,
63
- required: e.inputProps.required,
64
- min: e.inputProps.min,
65
- max: e.inputProps.max,
66
- type: e.inputProps.type,
67
- name: e.inputProps.name,
68
- label: e.inputProps.label,
69
- "error-messages": e.inputProps.errorMessages,
70
- error: e.inputProps.error
71
- }, e.$attrs, {
72
- "model-value": e.vuetifyValue,
73
- "onUpdate:modelValue": r[1] || (r[1] = (p) => {
74
- e.inputProps.field.handleChange(Number(p));
75
- })
76
- }), null, 16, ["id", "required", "min", "max", "type", "name", "label", "error-messages", "error", "model-value"])) : l("", !0),
77
- e.inputProps.type === "select" || e.inputProps.type === "multiple" ? (o(), n(m, s({
78
- key: 4,
79
- id: e.inputProps.id,
80
- clearable: e.inputProps.type === "select",
81
- required: e.inputProps.required,
82
- multiple: e.inputProps.type === "multiple",
83
- chips: e.inputProps.type === "multiple",
84
- name: e.inputProps.name,
85
- label: e.inputProps.label,
86
- items: e.inputProps.options,
87
- "error-messages": e.inputProps.errorMessages,
88
- error: e.inputProps.error
89
- }, e.$attrs, {
90
- "model-value": e.vuetifyValue,
91
- onClear: r[2] || (r[2] = (p) => e.inputProps.field.handleChange(void 0)),
92
- "onUpdate:modelValue": e.inputProps.field.handleChange
93
- }), null, 16, ["id", "clearable", "required", "multiple", "chips", "name", "label", "items", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
94
- e.inputProps.type === "autocomplete" || e.inputProps.type === "autocompletemultiple" ? (o(), n(d, s({
95
- key: 5,
96
- id: e.inputProps.id,
97
- clearable: e.inputProps.type === "autocomplete",
98
- multiple: e.inputProps.type === "autocompletemultiple",
99
- required: e.inputProps.required,
100
- name: e.inputProps.name,
101
- label: e.inputProps.label,
102
- items: e.inputProps.options,
103
- "error-messages": e.inputProps.errorMessages,
104
- error: e.inputProps.error,
105
- chips: e.inputProps.type === "autocompletemultiple"
106
- }, e.$attrs, {
107
- "model-value": e.vuetifyValue,
108
- onClear: r[3] || (r[3] = (p) => e.inputProps.field.handleChange(void 0)),
109
- "onUpdate:modelValue": e.inputProps.field.handleChange
110
- }), null, 16, ["id", "clearable", "multiple", "required", "name", "label", "items", "error-messages", "error", "chips", "model-value", "onUpdate:modelValue"])) : l("", !0)
111
- ], 32);
112
- };
113
- }
114
- });
1
+ import f from "./vue-components.es22.js";
115
2
  export {
116
- b as default
3
+ f as default
117
4
  };
@@ -0,0 +1,117 @@
1
+ import { defineComponent as P, resolveComponent as i, createElementBlock as g, openBlock as o, createBlock as n, createCommentVNode as l, mergeProps as s } from "vue";
2
+ const b = /* @__PURE__ */ P({
3
+ inheritAttrs: !1,
4
+ __name: "OmegaInputVuetify",
5
+ props: {
6
+ inputProps: {},
7
+ vuetifyValue: {}
8
+ },
9
+ emits: ["focus", "blur"],
10
+ setup(y) {
11
+ return (e, r) => {
12
+ const a = i("v-checkbox"), u = i("v-text-field"), t = i("v-textarea"), m = i("v-select"), d = i("v-autocomplete");
13
+ return o(), g("div", {
14
+ class: "omega-input",
15
+ onFocusout: r[4] || (r[4] = (p) => e.$emit("blur", p)),
16
+ onFocusin: r[5] || (r[5] = (p) => e.$emit("focus", p))
17
+ }, [
18
+ e.inputProps.type === "boolean" ? (o(), n(a, s({
19
+ key: 0,
20
+ id: e.inputProps.id,
21
+ name: e.inputProps.name,
22
+ label: e.inputProps.label,
23
+ "error-messages": e.inputProps.errorMessages,
24
+ error: e.inputProps.error,
25
+ ripple: ""
26
+ }, e.$attrs, {
27
+ "model-value": e.vuetifyValue,
28
+ onChange: r[0] || (r[0] = (p) => e.inputProps.field.handleChange(p.target.checked))
29
+ }), null, 16, ["id", "name", "label", "error-messages", "error", "model-value"])) : l("", !0),
30
+ e.inputProps.type === "email" || e.inputProps.type === "string" ? (o(), n(u, s({
31
+ key: 1,
32
+ id: e.inputProps.id,
33
+ required: e.inputProps.required,
34
+ "min-length": e.inputProps.minLength,
35
+ "max-length": e.inputProps.maxLength,
36
+ type: e.inputProps.type,
37
+ name: e.inputProps.name,
38
+ label: e.inputProps.label,
39
+ "error-messages": e.inputProps.errorMessages,
40
+ error: e.inputProps.error
41
+ }, e.$attrs, {
42
+ "model-value": e.vuetifyValue,
43
+ "onUpdate:modelValue": e.inputProps.field.handleChange
44
+ }), null, 16, ["id", "required", "min-length", "max-length", "type", "name", "label", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
45
+ e.inputProps.type === "text" ? (o(), n(t, s({
46
+ key: 2,
47
+ id: e.inputProps.id,
48
+ required: e.inputProps.required,
49
+ "min-length": e.inputProps.minLength,
50
+ "max-length": e.inputProps.maxLength,
51
+ type: e.inputProps.type,
52
+ name: e.inputProps.name,
53
+ label: e.inputProps.label,
54
+ "error-messages": e.inputProps.errorMessages,
55
+ error: e.inputProps.error
56
+ }, e.$attrs, {
57
+ "model-value": e.vuetifyValue,
58
+ "onUpdate:modelValue": e.inputProps.field.handleChange
59
+ }), null, 16, ["id", "required", "min-length", "max-length", "type", "name", "label", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
60
+ e.inputProps.type === "number" ? (o(), n(u, s({
61
+ key: 3,
62
+ id: e.inputProps.id,
63
+ required: e.inputProps.required,
64
+ min: e.inputProps.min,
65
+ max: e.inputProps.max,
66
+ type: e.inputProps.type,
67
+ name: e.inputProps.name,
68
+ label: e.inputProps.label,
69
+ "error-messages": e.inputProps.errorMessages,
70
+ error: e.inputProps.error
71
+ }, e.$attrs, {
72
+ "model-value": e.vuetifyValue,
73
+ "onUpdate:modelValue": r[1] || (r[1] = (p) => {
74
+ e.inputProps.field.handleChange(Number(p));
75
+ })
76
+ }), null, 16, ["id", "required", "min", "max", "type", "name", "label", "error-messages", "error", "model-value"])) : l("", !0),
77
+ e.inputProps.type === "select" || e.inputProps.type === "multiple" ? (o(), n(m, s({
78
+ key: 4,
79
+ id: e.inputProps.id,
80
+ clearable: e.inputProps.type === "select",
81
+ required: e.inputProps.required,
82
+ multiple: e.inputProps.type === "multiple",
83
+ chips: e.inputProps.type === "multiple",
84
+ name: e.inputProps.name,
85
+ label: e.inputProps.label,
86
+ items: e.inputProps.options,
87
+ "error-messages": e.inputProps.errorMessages,
88
+ error: e.inputProps.error
89
+ }, e.$attrs, {
90
+ "model-value": e.vuetifyValue,
91
+ onClear: r[2] || (r[2] = (p) => e.inputProps.field.handleChange(void 0)),
92
+ "onUpdate:modelValue": e.inputProps.field.handleChange
93
+ }), null, 16, ["id", "clearable", "required", "multiple", "chips", "name", "label", "items", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : l("", !0),
94
+ e.inputProps.type === "autocomplete" || e.inputProps.type === "autocompletemultiple" ? (o(), n(d, s({
95
+ key: 5,
96
+ id: e.inputProps.id,
97
+ clearable: e.inputProps.type === "autocomplete",
98
+ multiple: e.inputProps.type === "autocompletemultiple",
99
+ required: e.inputProps.required,
100
+ name: e.inputProps.name,
101
+ label: e.inputProps.label,
102
+ items: e.inputProps.options,
103
+ "error-messages": e.inputProps.errorMessages,
104
+ error: e.inputProps.error,
105
+ chips: e.inputProps.type === "autocompletemultiple"
106
+ }, e.$attrs, {
107
+ "model-value": e.vuetifyValue,
108
+ onClear: r[3] || (r[3] = (p) => e.inputProps.field.handleChange(void 0)),
109
+ "onUpdate:modelValue": e.inputProps.field.handleChange
110
+ }), null, 16, ["id", "clearable", "multiple", "required", "name", "label", "items", "error-messages", "error", "chips", "model-value", "onUpdate:modelValue"])) : l("", !0)
111
+ ], 32);
112
+ };
113
+ }
114
+ });
115
+ export {
116
+ b as default
117
+ };
@@ -1,5 +1,5 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");if(n.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;-webkit-appearance:none;-moz-appearance:none;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),document.head.appendChild(n),window.customElements){const e=window.customElements.define;window.customElements.define=function(o,t){const a=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(a&&a.call(this),this.shadowRoot){const i=document.createElement("style");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;-webkit-appearance:none;-moz-appearance:none;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),this.shadowRoot.appendChild(i)}},e.call(window.customElements,o,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
- import o from "./vue-components.es24.js";
2
+ import o from "./vue-components.es25.js";
3
3
 
4
4
  export {
5
5
  o as default
@@ -1,10 +1,10 @@
1
- import { inject as o, provide as r } from "vue";
1
+ import { provide as o, inject as r } from "vue";
2
2
  const n = Symbol(), i = () => {
3
- const t = o(n);
3
+ const t = r(n);
4
4
  if (!t)
5
5
  throw new Error("useIntl must be used within a IntlProvider");
6
6
  return t;
7
- }, s = (t) => r(n, t);
7
+ }, s = (t) => o(n, t);
8
8
  export {
9
9
  s as provideIntl,
10
10
  i as useIntl
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as i, computed as t, createBlock as p, openBlock as d, resolveDynamicComponent as u, withCtx as r, createVNode as f, mergeProps as c, renderSlot as v, normalizeProps as h, guardReactiveProps as g } from "vue";
2
- import { generateInputStandardSchemaFromFieldMeta as y } from "./vue-components.es7.js";
3
- import b from "./vue-components.es21.js";
2
+ import { generateInputStandardSchemaFromFieldMeta as y } from "./vue-components.es8.js";
3
+ import b from "./vue-components.es22.js";
4
4
  const S = /* @__PURE__ */ i({
5
5
  inheritAttrs: !1,
6
6
  __name: "OmegaInput",
@@ -1,38 +1,80 @@
1
- import { ref as l, computed as p, readonly as v, provide as E, inject as f } from "vue";
2
- const u = Symbol();
3
- function h(e, a, t = "onSubmit") {
4
- const r = l([]), n = (o) => {
5
- r.value = r.value.filter((d) => d.inputId !== o);
6
- }, c = (o) => {
7
- n(o.inputId), r.value.push(o);
8
- }, i = () => {
9
- r.value = [];
10
- }, m = p(() => {
11
- switch (t) {
12
- case "onChange":
13
- return !0;
14
- default:
15
- return e.value > 0;
16
- }
17
- }), s = {
18
- errors: v(r),
19
- addError: c,
20
- removeError: n,
21
- clearErrors: i,
22
- showErrors: m,
23
- generalErrors: a,
24
- showErrorsOn: t ?? "onSubmit"
25
- };
26
- return E(u, s), s;
27
- }
28
- function w() {
29
- const e = f(u);
30
- if (!e)
31
- throw new Error("useOmegaErrors must be used within an OmegaForm provider");
32
- return e;
33
- }
1
+ import { defineComponent as _, computed as O, createElementBlock as j, openBlock as M, Fragment as E, renderList as A, renderSlot as F, createVNode as g, mergeProps as h } from "vue";
2
+ import { Order as s, pipe as k, Array as l } from "effect-app";
3
+ import v from "./vue-components.es4.js";
4
+ const R = /* @__PURE__ */ _({
5
+ __name: "OmegaAutoGen",
6
+ props: {
7
+ form: {},
8
+ pick: {},
9
+ omit: {},
10
+ labelMap: { type: Function },
11
+ filterMap: { type: Function },
12
+ order: {},
13
+ sort: {}
14
+ },
15
+ setup(m) {
16
+ const u = (e) => (t) => Object.fromEntries(
17
+ Object.entries(t).map(([r, o]) => [r, e(o, r)])
18
+ ), a = (e) => (t) => Object.fromEntries(
19
+ Object.entries(t).filter(([r, o]) => e(o, r))
20
+ ), f = (e) => (t) => Object.entries(t).reduce(
21
+ (r, [o, c]) => {
22
+ const i = e(c, o);
23
+ return i !== !1 && (r[o] = i), r;
24
+ },
25
+ {}
26
+ ), n = m, p = (e, t) => {
27
+ const r = (t == null ? void 0 : t.indexOf(e)) ?? -1;
28
+ return r === -1 ? Number.MAX_SAFE_INTEGER : r;
29
+ }, d = s.mapInput(
30
+ s.number,
31
+ (e) => p(e.name, n.order || [])
32
+ ), b = O(
33
+ () => k(
34
+ n.form.meta,
35
+ // include / exclude
36
+ a(
37
+ (e, t) => {
38
+ var r, o;
39
+ return n.pick ? n.pick.includes(t) && !((r = n.omit) != null && r.includes(t)) : !((o = n.omit) != null && o.includes(t));
40
+ }
41
+ ),
42
+ (e) => e,
43
+ // labelMap and adding name
44
+ u((e, t) => {
45
+ var r;
46
+ return {
47
+ name: t,
48
+ label: ((r = n.labelMap) == null ? void 0 : r.call(n, t)) || t,
49
+ ...e
50
+ };
51
+ }),
52
+ // filterMap
53
+ n.filterMap ? f((e) => {
54
+ var r;
55
+ const t = (r = n.filterMap) == null ? void 0 : r.call(n, e.name, e);
56
+ return t === void 0 || t === !0 ? e : t;
57
+ }) : (e) => e,
58
+ // transform to array
59
+ (e) => Object.values(e),
60
+ // order
61
+ l.sort(d),
62
+ // sort
63
+ n.sort ? l.sort(n.sort) : (e) => e
64
+ )
65
+ );
66
+ return (e, t) => (M(!0), j(E, null, A(b.value, ({ name: r, label: o, ...c }) => F(e.$slots, "default", {
67
+ child: { name: r, label: o, ...c }
68
+ }, () => [
69
+ g(v, h({
70
+ form: n.form,
71
+ name: r,
72
+ label: o,
73
+ ref_for: !0
74
+ }, c), null, 16, ["form", "name", "label"])
75
+ ])), 256));
76
+ }
77
+ });
34
78
  export {
35
- u as OmegaErrorsKey,
36
- h as provideOmegaErrors,
37
- w as useOmegaErrors
79
+ R as default
38
80
  };
@@ -1,135 +1,38 @@
1
- import { useForm as I } from "@tanstack/vue-form";
2
- import { S as N } from "effect-app";
3
- import { generateMetaFromSchema as R } from "./vue-components.es7.js";
4
- import { computed as b, onUnmounted as A, onMounted as D, onBeforeUnmount as J, provide as K } from "vue";
5
- import { isObject as q } from "./vue-components.es17.js";
6
- import M from "./vue-components.es18.js";
7
- const x = Symbol("OmegaForm"), H = (w, s, i) => {
8
- if (!w) throw new Error("Schema is required");
9
- const V = N.standardSchemaV1(w), { filterItems: L, meta: t } = R(w), d = b(() => {
10
- var l;
11
- if ((l = i == null ? void 0 : i.persistency) != null && l.id)
12
- return i.persistency.id;
13
- const e = window.location.pathname, r = Object.keys(t);
14
- return `${e}-${r.join("-")}`;
15
- }), U = () => {
16
- const e = new URLSearchParams(window.location.search);
17
- e.delete(d.value);
18
- const r = new URL(window.location.href);
19
- r.search = e.toString(), window.history.replaceState({}, "", r.toString());
20
- };
21
- function v(e, r) {
22
- for (const l in r)
23
- r[l] && q(r[l]) ? (e[l] || (e[l] = {}), v(e[l], r[l])) : e[l] = r[l];
24
- return e;
25
- }
26
- const j = b(() => {
27
- var l;
28
- if (s != null && s.defaultValues && !((l = i == null ? void 0 : i.persistency) != null && l.overrideDefaultValues))
29
- return s == null ? void 0 : s.defaultValues;
30
- let e;
31
- const r = i == null ? void 0 : i.persistency;
32
- if (!(r != null && r.policies) || r.policies.length === 0) return {};
33
- if (r.policies.includes("querystring"))
34
- try {
35
- const c = new URLSearchParams(window.location.search).get(d.value);
36
- U(), c && (e = JSON.parse(c));
37
- } catch (u) {
38
- console.error(u);
39
- }
40
- if (
41
- // query string has higher priority than local/session storage
42
- !e && (r.policies.includes("local") || r.policies.includes("session"))
43
- ) {
44
- const u = r.policies.includes("local") ? localStorage : sessionStorage;
45
- if (u)
46
- try {
47
- const c = JSON.parse(
48
- u.getItem(d.value) || "{}"
49
- );
50
- u.removeItem(d.value), e = c;
51
- } catch (c) {
52
- console.error(c);
53
- }
54
- }
55
- if (e ?? (e = {}), (s == null ? void 0 : s.defaultValues) == null)
56
- return e;
57
- {
58
- const u = s == null ? void 0 : s.defaultValues;
59
- return v(u, e);
60
- }
61
- }), n = I({
62
- ...s,
63
- validators: {
64
- onSubmit: V,
65
- ...(s == null ? void 0 : s.validators) || {}
66
- },
67
- onSubmit: s != null && s.onSubmit ? ({ formApi: e, meta: r, value: l }) => {
68
- var u;
69
- return (u = s.onSubmit) == null ? void 0 : u.call(s, {
70
- formApi: e,
71
- meta: r,
72
- value: l
73
- });
74
- } : void 0,
75
- defaultValues: j.value
76
- }), E = () => {
77
- Object.keys(t).forEach((e) => {
78
- n.setFieldValue(e, void 0);
79
- });
80
- }, S = (e) => e.reduce(
81
- (r, l) => {
82
- const u = l.split(".");
83
- return u.reduce((c, o, P) => (P === u.length - 1 ? c[o] = n.getFieldValue(l) : c[o] = c[o] ?? {}, c[o]), r), r;
84
- },
85
- {}
86
- ), f = (e) => {
87
- if (e) {
88
- if (Array.isArray(e.keys))
89
- return S(e.keys);
90
- if (Array.isArray(e.banKeys)) {
91
- const r = Object.keys(t).filter(
92
- (l) => {
93
- var u;
94
- return (u = e.banKeys) == null ? void 0 : u.includes(l);
95
- }
96
- );
97
- return S(r);
98
- }
99
- return n.store.state.values;
100
- }
101
- }, h = () => {
102
- const e = i == null ? void 0 : i.persistency;
103
- if (!(!(e != null && e.policies) || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
104
- const r = e.policies.includes("local") ? localStorage : sessionStorage;
105
- if (!r) return;
106
- const l = f(e);
107
- return r.setItem(d.value, JSON.stringify(l));
108
- }
109
- }, a = () => {
110
- const e = i == null ? void 0 : i.persistency;
111
- if (!(!(e != null && e.policies) || e.policies.length === 0) && e.policies.includes("querystring")) {
112
- const r = f(e), l = new URLSearchParams(window.location.search);
113
- l.set(d.value, JSON.stringify(r));
114
- const u = new URL(window.location.href);
115
- u.search = l.toString(), window.history.replaceState({}, "", u.toString());
1
+ import { ref as l, computed as p, readonly as v, provide as E, inject as f } from "vue";
2
+ const u = Symbol();
3
+ function h(e, a, t = "onSubmit") {
4
+ const r = l([]), n = (o) => {
5
+ r.value = r.value.filter((d) => d.inputId !== o);
6
+ }, c = (o) => {
7
+ n(o.inputId), r.value.push(o);
8
+ }, i = () => {
9
+ r.value = [];
10
+ }, m = p(() => {
11
+ switch (t) {
12
+ case "onChange":
13
+ return !0;
14
+ default:
15
+ return e.value > 0;
116
16
  }
17
+ }), s = {
18
+ errors: v(r),
19
+ addError: c,
20
+ removeError: n,
21
+ clearErrors: i,
22
+ showErrors: m,
23
+ generalErrors: a,
24
+ showErrorsOn: t ?? "onSubmit"
117
25
  };
118
- A(h), D(() => {
119
- window.addEventListener("beforeunload", h), window.addEventListener("blur", a);
120
- }), J(() => {
121
- window.removeEventListener("beforeunload", h), window.removeEventListener("blur", a);
122
- });
123
- const y = Object.assign(n, {
124
- meta: t,
125
- filterItems: L,
126
- clear: E
127
- });
128
- return K(x, y), Object.assign(y, {
129
- Input: M
130
- });
131
- };
26
+ return E(u, s), s;
27
+ }
28
+ function w() {
29
+ const e = f(u);
30
+ if (!e)
31
+ throw new Error("useOmegaErrors must be used within an OmegaForm provider");
32
+ return e;
33
+ }
132
34
  export {
133
- x as OmegaFormKey,
134
- H as useOmegaForm
35
+ u as OmegaErrorsKey,
36
+ h as provideOmegaErrors,
37
+ w as useOmegaErrors
135
38
  };