@effect-app/vue-components 0.3.0 → 0.3.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.
@@ -1,4 +1,4 @@
1
- import { S } from "effect-app";
1
+ import { type Record, S } from "effect-app";
2
2
  import { type NestedKeyOf, type FilterItems, type FormProps, type MetaRecord, type OmegaFormApi } from "./OmegaFormStuff";
3
3
  type keysRule<T> = {
4
4
  keys?: NestedKeyOf<T>[];
@@ -9,7 +9,11 @@ type keysRule<T> = {
9
9
  };
10
10
  export type OmegaConfig<T> = {
11
11
  persistency?: {
12
- method?: "session" | "local" | "none";
12
+ /** Order of importance:
13
+ * - "querystring": Highest priority when persisting
14
+ * - "local" and then "session": Lower priority storage options
15
+ */
16
+ policies?: ("local" | "session" | "querystring")[];
13
17
  overrideDefaultValues?: boolean;
14
18
  id?: string;
15
19
  } & keysRule<T>;
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as d, watch as b, createElementBlock as g, openBlock as S, withModifiers as v, unref as n, createElementVNode as h, renderSlot as O } from "vue";
2
2
  import { useStore as i } from "@tanstack/vue-form";
3
- import { getOmegaStore as M } from "./vue-components.es17.js";
3
+ import { getOmegaStore as M } from "./vue-components.es18.js";
4
4
  import { provideOmegaErrors as y } from "./vue-components.es4.js";
5
5
  import { useOmegaForm as E } from "./vue-components.es5.js";
6
6
  const w = ["disabled"], A = /* @__PURE__ */ d({
@@ -1,6 +1,7 @@
1
- const o = (n) => () => n, t = /* @__PURE__ */ o(void 0), c = t;
1
+ import { isFunction as c } from "./vue-components.es16.js";
2
+ const s = c, t = (o) => typeof o == "object" && o !== null, i = (o) => t(o) || s(o);
2
3
  export {
3
- t as constUndefined,
4
- c as constVoid,
5
- o as constant
4
+ s as isFunction,
5
+ i as isObject,
6
+ t as isRecordOrArray
6
7
  };
@@ -1,95 +1,4 @@
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 { defineComponent as B, getCurrentInstance as L, useId as P, computed as n, watch as x, onMounted as _, ref as S, watchEffect as A, renderSlot as D, normalizeProps as F, guardReactiveProps as M, createElementVNode as N, createBlock as R, createCommentVNode as T, unref as U, openBlock as z, mergeProps as j } from "vue";
3
- import { useStore as G } from "@tanstack/vue-form";
4
- import { useOmegaErrors as H } from "./vue-components.es4.js";
5
- import J from "./vue-components.es19.js";
6
-
7
- const Z = /* @__PURE__ */ B({
8
- inheritAttrs: !1,
9
- __name: "OmegaInternalInput",
10
- props: {
11
- field: {},
12
- meta: {},
13
- label: {},
14
- options: {},
15
- type: {},
16
- validators: {}
17
- },
18
- setup(q) {
19
- const e = q, o = L(), C = o == null ? void 0 : o.appContext.components.VTextField, u = P(), s = e.field, a = G(s.store, (t) => t), f = n(() => {
20
- var t, r;
21
- return e.type ? e.type : ((t = e.meta) == null ? void 0 : t.type) === "string" ? e.meta.format === "email" ? "email" : "string" : ((r = e.meta) == null ? void 0 : r.type) || "unknown";
22
- }), l = n(() => a.value.value), d = n(
23
- () => (
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
- a.value.meta.errors.map((t) => t == null ? void 0 : t.message).filter(Boolean)
26
- )
27
- );
28
- x(
29
- () => [!!l.value],
30
- () => {
31
- var t, r;
32
- d.value.length && !l.value && !((t = e.meta) != null && t.required) && s.setValue(
33
- ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "undefined" ? void 0 : null
34
- );
35
- }
36
- ), _(() => {
37
- var t, r;
38
- !l.value && !((t = e.meta) != null && t.required) && ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "null" && s.setValue(null);
39
- });
40
- const { addError: I, removeError: O, showErrors: $, showErrorsOn: k } = H(), i = S(!1);
41
- A(() => {
42
- ($.value || k === "onChange") && (i.value = !0);
43
- });
44
- const m = () => {
45
- i.value = !0;
46
- };
47
- _(() => {
48
- l.value && m();
49
- });
50
- const v = n(() => !i.value && f.value !== "select" ? [] : d.value);
51
- x(
52
- () => a.value.meta.errors,
53
- () => {
54
- a.value.meta.errors.length ? I({
55
- inputId: u,
56
- errors: a.value.meta.errors.map((t) => t.message).filter(Boolean),
57
- label: e.label
58
- }) : O(u);
59
- }
60
- );
61
- const p = n(() => {
62
- var t, r, c, g, y, h, b, E, V, w;
63
- return {
64
- id: u,
65
- required: (t = e.meta) == null ? void 0 : t.required,
66
- minLength: ((r = e.meta) == null ? void 0 : r.type) === "string" && ((c = e.meta) == null ? void 0 : c.minLength),
67
- maxLength: ((g = e.meta) == null ? void 0 : g.type) === "string" && ((y = e.meta) == null ? void 0 : y.maxLength),
68
- max: ((h = e.meta) == null ? void 0 : h.type) === "number" && ((b = e.meta) == null ? void 0 : b.maximum),
69
- min: ((E = e.meta) == null ? void 0 : E.type) === "number" && ((V = e.meta) == null ? void 0 : V.minimum),
70
- name: e.field.name,
71
- modelValue: e.field.state.value,
72
- errorMessages: v.value,
73
- error: !!v.value.length,
74
- field: e.field,
75
- setRealDirty: m,
76
- type: f.value,
77
- label: `${e.label}${(w = e.meta) != null && w.required ? " *" : ""}`,
78
- options: e.options
79
- };
80
- });
81
- return (t, r) => D(t.$slots, "default", F(M(p.value)), () => [
82
- N("div", { onFocusout: m }, [
83
- U(C) ? (z(), R(J, j({
84
- key: 0,
85
- "input-props": p.value
86
- }, t.$attrs, {
87
- "vuetify-value": p.value.field.state.value
88
- }), null, 16, ["input-props", "vuetify-value"])) : T("", !0)
89
- ], 32)
90
- ]);
91
- }
92
- });
1
+ const o = (n) => typeof n == "function";
93
2
  export {
94
- Z as default
3
+ o as isFunction
95
4
  };
@@ -1,13 +1,95 @@
1
- import { useStore as u } from "@tanstack/vue-form";
2
- import { computed as f } from "vue";
3
- function c(o, t) {
4
- return f(() => t ? u(o.store, (n) => {
5
- const r = {};
6
- for (const e of t)
7
- r[e] = n[e];
8
- return r;
9
- }).value : {});
10
- }
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 { defineComponent as B, getCurrentInstance as L, useId as P, computed as n, watch as x, onMounted as _, ref as S, watchEffect as A, renderSlot as D, normalizeProps as F, guardReactiveProps as M, createElementVNode as N, createBlock as R, createCommentVNode as T, unref as U, openBlock as z, mergeProps as j } from "vue";
3
+ import { useStore as G } from "@tanstack/vue-form";
4
+ import { useOmegaErrors as H } from "./vue-components.es4.js";
5
+ import J from "./vue-components.es20.js";
6
+
7
+ const Z = /* @__PURE__ */ B({
8
+ inheritAttrs: !1,
9
+ __name: "OmegaInternalInput",
10
+ props: {
11
+ field: {},
12
+ meta: {},
13
+ label: {},
14
+ options: {},
15
+ type: {},
16
+ validators: {}
17
+ },
18
+ setup(q) {
19
+ const e = q, o = L(), C = o == null ? void 0 : o.appContext.components.VTextField, u = P(), s = e.field, a = G(s.store, (t) => t), f = n(() => {
20
+ var t, r;
21
+ return e.type ? e.type : ((t = e.meta) == null ? void 0 : t.type) === "string" ? e.meta.format === "email" ? "email" : "string" : ((r = e.meta) == null ? void 0 : r.type) || "unknown";
22
+ }), l = n(() => a.value.value), d = n(
23
+ () => (
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
+ a.value.meta.errors.map((t) => t == null ? void 0 : t.message).filter(Boolean)
26
+ )
27
+ );
28
+ x(
29
+ () => [!!l.value],
30
+ () => {
31
+ var t, r;
32
+ d.value.length && !l.value && !((t = e.meta) != null && t.required) && s.setValue(
33
+ ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "undefined" ? void 0 : null
34
+ );
35
+ }
36
+ ), _(() => {
37
+ var t, r;
38
+ !l.value && !((t = e.meta) != null && t.required) && ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "null" && s.setValue(null);
39
+ });
40
+ const { addError: I, removeError: O, showErrors: $, showErrorsOn: k } = H(), i = S(!1);
41
+ A(() => {
42
+ ($.value || k === "onChange") && (i.value = !0);
43
+ });
44
+ const m = () => {
45
+ i.value = !0;
46
+ };
47
+ _(() => {
48
+ l.value && m();
49
+ });
50
+ const v = n(() => !i.value && f.value !== "select" ? [] : d.value);
51
+ x(
52
+ () => a.value.meta.errors,
53
+ () => {
54
+ a.value.meta.errors.length ? I({
55
+ inputId: u,
56
+ errors: a.value.meta.errors.map((t) => t.message).filter(Boolean),
57
+ label: e.label
58
+ }) : O(u);
59
+ }
60
+ );
61
+ const p = n(() => {
62
+ var t, r, c, g, y, h, b, E, V, w;
63
+ return {
64
+ id: u,
65
+ required: (t = e.meta) == null ? void 0 : t.required,
66
+ minLength: ((r = e.meta) == null ? void 0 : r.type) === "string" && ((c = e.meta) == null ? void 0 : c.minLength),
67
+ maxLength: ((g = e.meta) == null ? void 0 : g.type) === "string" && ((y = e.meta) == null ? void 0 : y.maxLength),
68
+ max: ((h = e.meta) == null ? void 0 : h.type) === "number" && ((b = e.meta) == null ? void 0 : b.maximum),
69
+ min: ((E = e.meta) == null ? void 0 : E.type) === "number" && ((V = e.meta) == null ? void 0 : V.minimum),
70
+ name: e.field.name,
71
+ modelValue: e.field.state.value,
72
+ errorMessages: v.value,
73
+ error: !!v.value.length,
74
+ field: e.field,
75
+ setRealDirty: m,
76
+ type: f.value,
77
+ label: `${e.label}${(w = e.meta) != null && w.required ? " *" : ""}`,
78
+ options: e.options
79
+ };
80
+ });
81
+ return (t, r) => D(t.$slots, "default", F(M(p.value)), () => [
82
+ N("div", { onFocusout: m }, [
83
+ U(C) ? (z(), R(J, j({
84
+ key: 0,
85
+ "input-props": p.value
86
+ }, t.$attrs, {
87
+ "vuetify-value": p.value.field.state.value
88
+ }), null, 16, ["input-props", "vuetify-value"])) : T("", !0)
89
+ ], 32)
90
+ ]);
91
+ }
92
+ });
11
93
  export {
12
- c as getOmegaStore
94
+ Z as default
13
95
  };
@@ -1,4 +1,13 @@
1
- import f from "./vue-components.es16.js";
1
+ import { useStore as u } from "@tanstack/vue-form";
2
+ import { computed as f } from "vue";
3
+ function c(o, t) {
4
+ return f(() => t ? u(o.store, (n) => {
5
+ const r = {};
6
+ for (const e of t)
7
+ r[e] = n[e];
8
+ return r;
9
+ }).value : {});
10
+ }
2
11
  export {
3
- f as default
12
+ c as getOmegaStore
4
13
  };
@@ -1,117 +1,4 @@
1
- import { defineComponent as P, resolveComponent as u, 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 = u("v-checkbox"), i = u("v-text-field"), t = u("v-textarea"), m = u("v-select"), d = u("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(i, 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(i, 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.es17.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 u, 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 = u("v-checkbox"), i = u("v-text-field"), t = u("v-textarea"), m = u("v-select"), d = u("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(i, 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(i, 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.es19.js";
2
+ import o from "./vue-components.es20.js";
3
3
 
4
4
  export {
5
5
  o as default
@@ -1,91 +1,125 @@
1
1
  import { useForm as E } from "@tanstack/vue-form";
2
- import { S as j, Match as n } from "effect-app";
3
- import { generateMetaFromSchema as A } from "./vue-components.es6.js";
4
- import { computed as b, onUnmounted as I, onMounted as K, onBeforeUnmount as M } from "vue";
5
- import { constVoid as x } from "./vue-components.es15.js";
6
- const m = (i, e, u) => {
7
- if (!i) throw new Error("Schema is required");
8
- const a = j.standardSchemaV1(i), { filterItems: f, meta: y } = A(i), o = b(() => {
9
- var d;
10
- if ((d = u == null ? void 0 : u.persistency) != null && d.id)
11
- return u.persistency.id;
12
- const l = window.location.pathname, r = Object.keys(y);
13
- return `${l}-${r.join("-")}`;
14
- }), w = b(() => {
15
- var r;
16
- if (e != null && e.defaultValues && !((r = u == null ? void 0 : u.persistency) != null && r.overrideDefaultValues))
17
- return e.defaultValues;
18
- const l = u == null ? void 0 : u.persistency;
19
- return n.value(l).pipe(
20
- n.when(
21
- { method: (d) => ["local", "session"].includes(d) },
22
- (d) => {
23
- const c = d.method === "local" ? localStorage : sessionStorage;
24
- if (c)
25
- try {
26
- const s = JSON.parse(
27
- c.getItem(o.value) || "{}"
28
- );
29
- return c.removeItem(o.value), s;
30
- } catch (s) {
31
- return console.error(s), {};
32
- }
33
- return {};
2
+ import { S as I } from "effect-app";
3
+ import { generateMetaFromSchema as N } from "./vue-components.es6.js";
4
+ import { computed as a, onUnmounted as R, onMounted as A, onBeforeUnmount as D } from "vue";
5
+ import { isObject as J } from "./vue-components.es15.js";
6
+ const z = (h, u, i) => {
7
+ if (!h) throw new Error("Schema is required");
8
+ const b = I.standardSchemaV1(h), { filterItems: V, meta: t } = N(h), c = a(() => {
9
+ var l;
10
+ if ((l = i == null ? void 0 : i.persistency) != null && l.id)
11
+ return i.persistency.id;
12
+ const e = window.location.pathname, r = Object.keys(t);
13
+ return `${e}-${r.join("-")}`;
14
+ }), L = () => {
15
+ const e = new URLSearchParams(window.location.search);
16
+ e.delete(c.value);
17
+ const r = new URL(window.location.href);
18
+ r.search = e.toString(), window.history.replaceState({}, "", r.toString());
19
+ };
20
+ function f(e, r) {
21
+ for (const l in r)
22
+ r[l] && J(r[l]) ? (e[l] || (e[l] = {}), f(e[l], r[l])) : e[l] = r[l];
23
+ return e;
24
+ }
25
+ const U = a(() => {
26
+ var l;
27
+ if (u != null && u.defaultValues && !((l = i == null ? void 0 : i.persistency) != null && l.overrideDefaultValues))
28
+ return u == null ? void 0 : u.defaultValues;
29
+ let e;
30
+ const r = i == null ? void 0 : i.persistency;
31
+ if (!(r != null && r.policies) || r.policies.length === 0) return {};
32
+ if (r.policies.includes("querystring"))
33
+ try {
34
+ const d = new URLSearchParams(window.location.search).get(c.value);
35
+ L(), d && (e = JSON.parse(d));
36
+ } catch (s) {
37
+ console.error(s);
38
+ }
39
+ if (
40
+ // query string has higher priority than local/session storage
41
+ !e && (r.policies.includes("local") || r.policies.includes("session"))
42
+ ) {
43
+ const s = r.policies.includes("local") ? localStorage : sessionStorage;
44
+ if (s)
45
+ try {
46
+ const d = JSON.parse(
47
+ s.getItem(c.value) || "{}"
48
+ );
49
+ s.removeItem(c.value), e = d;
50
+ } catch (d) {
51
+ console.error(d);
34
52
  }
35
- ),
36
- n.orElse(() => ({}))
37
- );
38
- }), h = E({
39
- ...e,
53
+ }
54
+ if (e ?? (e = {}), (u == null ? void 0 : u.defaultValues) == null)
55
+ return e;
56
+ {
57
+ const s = u == null ? void 0 : u.defaultValues;
58
+ return f(s, e);
59
+ }
60
+ }), n = E({
61
+ ...u,
40
62
  validators: {
41
- onSubmit: a,
42
- ...(e == null ? void 0 : e.validators) || {}
63
+ onSubmit: b,
64
+ ...(u == null ? void 0 : u.validators) || {}
43
65
  },
44
- onSubmit: e != null && e.onSubmit ? ({ formApi: l, meta: r, value: d }) => {
45
- var t;
46
- return (t = e.onSubmit) == null ? void 0 : t.call(e, {
47
- formApi: l,
66
+ onSubmit: u != null && u.onSubmit ? ({ formApi: e, meta: r, value: l }) => {
67
+ var s;
68
+ return (s = u.onSubmit) == null ? void 0 : s.call(u, {
69
+ formApi: e,
48
70
  meta: r,
49
- value: d
71
+ value: l
50
72
  });
51
73
  } : void 0,
52
- defaultValues: w.value
53
- }), V = Object.assign(h, { meta: y, filterItems: f, clear: () => {
54
- Object.keys(y).forEach((l) => {
55
- h.setFieldValue(l, void 0);
74
+ defaultValues: U.value
75
+ }), j = () => {
76
+ Object.keys(t).forEach((e) => {
77
+ n.setFieldValue(e, void 0);
56
78
  });
57
- } }), v = () => {
58
- const l = u == null ? void 0 : u.persistency;
59
- n.value(l).pipe(
60
- n.when(
61
- { method: (r) => ["local", "session"].includes(r) },
62
- (r) => {
63
- const t = r.method === "local" ? localStorage : sessionStorage;
64
- if (t)
65
- return Array.isArray(r.keys) && Object.keys(y).filter(
66
- (s) => {
67
- var S;
68
- return !((S = r.keys) != null && S.includes(s));
69
- }
70
- ).forEach((s) => {
71
- h.setFieldValue(s, void 0);
72
- }), Array.isArray(r.banKeys) && r.banKeys.forEach((c) => {
73
- h.setFieldValue(c, void 0);
74
- }), t.setItem(
75
- o.value,
76
- JSON.stringify(h.store.state.values)
77
- );
78
- }
79
- ),
80
- n.orElse(x)
81
- );
79
+ }, o = (e) => e.reduce(
80
+ (r, l) => {
81
+ const s = l.split(".");
82
+ return s.reduce((d, w, P) => (P === s.length - 1 ? d[w] = n.getFieldValue(l) : d[w] = d[w] ?? {}, d[w]), r), r;
83
+ },
84
+ {}
85
+ ), v = (e) => {
86
+ if (e) {
87
+ if (Array.isArray(e.keys))
88
+ return o(e.keys);
89
+ if (Array.isArray(e.banKeys)) {
90
+ const r = Object.keys(t).filter(
91
+ (l) => {
92
+ var s;
93
+ return (s = e.banKeys) == null ? void 0 : s.includes(l);
94
+ }
95
+ );
96
+ return o(r);
97
+ }
98
+ return n.store.state.values;
99
+ }
100
+ }, S = () => {
101
+ const e = i == null ? void 0 : i.persistency;
102
+ if (!(!(e != null && e.policies) || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
103
+ const r = e.policies.includes("local") ? localStorage : sessionStorage;
104
+ if (!r) return;
105
+ const l = v(e);
106
+ return r.setItem(c.value, JSON.stringify(l));
107
+ }
108
+ }, y = () => {
109
+ const e = i == null ? void 0 : i.persistency;
110
+ if (!(!(e != null && e.policies) || e.policies.length === 0) && e.policies.includes("querystring")) {
111
+ const r = v(e), l = new URLSearchParams(window.location.search);
112
+ l.set(c.value, JSON.stringify(r));
113
+ const s = new URL(window.location.href);
114
+ s.search = l.toString(), window.history.replaceState({}, "", s.toString());
115
+ }
82
116
  };
83
- return I(v), K(() => {
84
- window.addEventListener("beforeunload", v);
85
- }), M(() => {
86
- window.removeEventListener("beforeunload", v);
87
- }), V;
117
+ return R(S), A(() => {
118
+ window.addEventListener("beforeunload", S), window.addEventListener("blur", y);
119
+ }), D(() => {
120
+ window.removeEventListener("beforeunload", S), window.removeEventListener("blur", y);
121
+ }), Object.assign(n, { meta: t, filterItems: V, clear: j });
88
122
  };
89
123
  export {
90
- m as useOmegaForm
124
+ z as useOmegaForm
91
125
  };
@@ -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
2
  import { generateInputStandardSchemaFromFieldMeta as y } from "./vue-components.es6.js";
3
- import b from "./vue-components.es16.js";
3
+ import b from "./vue-components.es17.js";
4
4
  const S = /* @__PURE__ */ i({
5
5
  inheritAttrs: !1,
6
6
  __name: "OmegaInput",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "@tanstack/vue-form": "^1.2.4",
@@ -5,7 +5,7 @@ import {
5
5
  type FormAsyncValidateOrFn,
6
6
  type StandardSchemaV1,
7
7
  } from "@tanstack/vue-form"
8
- import { Match, S } from "effect-app"
8
+ import { type Record, S } from "effect-app"
9
9
  import {
10
10
  generateMetaFromSchema,
11
11
  type NestedKeyOf,
@@ -15,7 +15,7 @@ import {
15
15
  type OmegaFormApi,
16
16
  } from "./OmegaFormStuff"
17
17
  import { computed, onBeforeUnmount, onMounted, onUnmounted } from "vue"
18
- import { constVoid } from "effect/Function"
18
+ import { isObject } from "effect/Predicate"
19
19
 
20
20
  type keysRule<T> =
21
21
  | {
@@ -29,7 +29,11 @@ type keysRule<T> =
29
29
 
30
30
  export type OmegaConfig<T> = {
31
31
  persistency?: {
32
- method?: "session" | "local" | "none"
32
+ /** Order of importance:
33
+ * - "querystring": Highest priority when persisting
34
+ * - "local" and then "session": Lower priority storage options
35
+ */
36
+ policies?: ("local" | "session" | "querystring")[]
33
37
  overrideDefaultValues?: boolean
34
38
  id?: string
35
39
  } & keysRule<T>
@@ -65,36 +69,91 @@ export const useOmegaForm = <
65
69
  return `${path}-${keys.join("-")}`
66
70
  })
67
71
 
72
+ const clearUrlParams = () => {
73
+ const params = new URLSearchParams(window.location.search)
74
+ params.delete(persistencyKey.value)
75
+ const url = new URL(window.location.href)
76
+ url.search = params.toString()
77
+ window.history.replaceState({}, "", url.toString())
78
+ }
79
+
80
+ function deepMerge(target: any, source: any) {
81
+ for (const key in source) {
82
+ if (source[key] && isObject(source[key])) {
83
+ if (!target[key]) {
84
+ target[key] = {}
85
+ }
86
+ deepMerge(target[key], source[key])
87
+ } else {
88
+ target[key] = source[key]
89
+ }
90
+ }
91
+ return target
92
+ }
93
+
68
94
  const defaultValues = computed(() => {
69
95
  if (
70
96
  tanstackFormOptions?.defaultValues &&
71
97
  !omegaConfig?.persistency?.overrideDefaultValues
72
- )
73
- return tanstackFormOptions.defaultValues
98
+ ) {
99
+ // defaultValues from tanstack are not partial,
100
+ // so if ovverrideDefaultValues is false we simply return them
101
+ return tanstackFormOptions?.defaultValues
102
+ }
103
+
104
+ // we are here because there are no default values from tankstack
105
+ // or because omegaConfig?.persistency?.overrideDefaultValues is true
106
+
107
+ // will contain what we get from querystring or local/session storage
108
+ let defValuesPatch
109
+
74
110
  const persistency = omegaConfig?.persistency
75
- return Match.value(persistency).pipe(
76
- Match.when(
77
- { method: method => ["local", "session"].includes(method) },
78
- persistency => {
79
- const method = persistency.method
80
- const storage = method === "local" ? localStorage : sessionStorage
81
- if (storage) {
82
- try {
83
- const value = JSON.parse(
84
- storage.getItem(persistencyKey.value) || "{}",
85
- )
86
- storage.removeItem(persistencyKey.value)
87
- return value
88
- } catch (error) {
89
- console.error(error)
90
- return {}
91
- }
92
- }
93
- return {}
94
- },
95
- ),
96
- Match.orElse(() => ({})),
97
- )
111
+ if (!persistency?.policies || persistency.policies.length === 0) return {}
112
+ if (persistency.policies.includes("querystring")) {
113
+ try {
114
+ const params = new URLSearchParams(window.location.search)
115
+ const value = params.get(persistencyKey.value)
116
+ clearUrlParams()
117
+ if (value) {
118
+ defValuesPatch = JSON.parse(value)
119
+ }
120
+ } catch (error) {
121
+ console.error(error)
122
+ }
123
+ }
124
+
125
+ if (
126
+ // query string has higher priority than local/session storage
127
+ !defValuesPatch &&
128
+ (persistency.policies.includes("local") ||
129
+ persistency.policies.includes("session"))
130
+ ) {
131
+ const storage = persistency.policies.includes("local")
132
+ ? localStorage
133
+ : sessionStorage
134
+ if (storage) {
135
+ try {
136
+ const value = JSON.parse(
137
+ storage.getItem(persistencyKey.value) || "{}",
138
+ )
139
+ storage.removeItem(persistencyKey.value)
140
+ defValuesPatch = value
141
+ } catch (error) {
142
+ console.error(error)
143
+ }
144
+ }
145
+ }
146
+
147
+ // to be sure we have a valid object at the end of the gathering process
148
+ defValuesPatch ??= {}
149
+
150
+ if (tanstackFormOptions?.defaultValues == undefined) {
151
+ // we just return what we gathered from the query/storage
152
+ return defValuesPatch
153
+ } else {
154
+ const startingDefValues = tanstackFormOptions?.defaultValues
155
+ return deepMerge(startingDefValues, defValuesPatch)
156
+ }
98
157
  })
99
158
 
100
159
  const form = useForm<
@@ -131,55 +190,82 @@ export const useOmegaForm = <
131
190
  })
132
191
  }
133
192
 
134
- const exposed = Object.assign(form, { meta, filterItems, clear })
193
+ const createNestedObjectFromPaths = (paths: string[]) =>
194
+ paths.reduce(
195
+ (result, path) => {
196
+ const parts = path.split(".")
197
+ parts.reduce((acc, part, i) => {
198
+ if (i === parts.length - 1) {
199
+ acc[part] = form.getFieldValue(path as any)
200
+ } else {
201
+ acc[part] = acc[part] ?? {}
202
+ }
203
+ return acc[part]
204
+ }, result)
205
+ return result
206
+ },
207
+ {} as Record<string, any>,
208
+ )
209
+
210
+ const persistFilter = (persistency: OmegaConfig<From>["persistency"]) => {
211
+ if (!persistency) return
212
+ if (Array.isArray(persistency.keys)) {
213
+ return createNestedObjectFromPaths(persistency.keys)
214
+ }
215
+ if (Array.isArray(persistency.banKeys)) {
216
+ const subs = Object.keys(meta).filter(metakey =>
217
+ persistency.banKeys?.includes(metakey as any),
218
+ )
219
+ return createNestedObjectFromPaths(subs)
220
+ }
221
+ return form.store.state.values
222
+ }
135
223
 
136
- // This is fragile as fuck. It's an experiment, it's only used because
137
- // it's not a core feature of our products, so even if the this is not consistent
138
- // it's not a big deal. So not take this code as a good example of how to do things.
139
- // This is done only because this function is called before the component is destroyed,
140
- // so the state would be lost anyway. So in this case we can play with the state, without
141
- // worrying about the side effects.
142
224
  const persistData = () => {
143
225
  const persistency = omegaConfig?.persistency
144
- Match.value(persistency).pipe(
145
- Match.when(
146
- { method: method => ["local", "session"].includes(method) },
147
- persistency => {
148
- const method = persistency.method
149
- const storage = method === "local" ? localStorage : sessionStorage
150
- if (storage) {
151
- if (Array.isArray(persistency.keys)) {
152
- const subs = Object.keys(meta).filter(
153
- metakey => !persistency.keys?.includes(metakey as any),
154
- )
155
- subs.forEach(key => {
156
- form.setFieldValue(key as any, undefined)
157
- })
158
- }
159
- if (Array.isArray(persistency.banKeys)) {
160
- persistency.banKeys.forEach(key => {
161
- form.setFieldValue(key as any, undefined)
162
- })
163
- }
164
- return storage.setItem(
165
- persistencyKey.value,
166
- JSON.stringify(form.store.state.values),
167
- )
168
- }
169
- },
170
- ),
171
- Match.orElse(constVoid),
172
- )
226
+ if (!persistency?.policies || persistency.policies.length === 0) {
227
+ return
228
+ }
229
+ if (
230
+ persistency.policies.includes("local") ||
231
+ persistency.policies.includes("session")
232
+ ) {
233
+ const storage = persistency.policies.includes("local")
234
+ ? localStorage
235
+ : sessionStorage
236
+ if (!storage) return
237
+ const values = persistFilter(persistency)
238
+ return storage.setItem(persistencyKey.value, JSON.stringify(values))
239
+ }
240
+ }
241
+
242
+ const saveDataInUrl = () => {
243
+ const persistency = omegaConfig?.persistency
244
+ if (!persistency?.policies || persistency.policies.length === 0) {
245
+ return
246
+ }
247
+ if (persistency.policies.includes("querystring")) {
248
+ const values = persistFilter(persistency)
249
+ const searchParams = new URLSearchParams(window.location.search)
250
+ searchParams.set(persistencyKey.value, JSON.stringify(values))
251
+ const url = new URL(window.location.href)
252
+ url.search = searchParams.toString()
253
+ window.history.replaceState({}, "", url.toString())
254
+ }
173
255
  }
174
256
 
175
257
  onUnmounted(persistData)
176
258
 
177
259
  onMounted(() => {
178
260
  window.addEventListener("beforeunload", persistData)
261
+ window.addEventListener("blur", saveDataInUrl)
179
262
  })
180
263
  onBeforeUnmount(() => {
181
264
  window.removeEventListener("beforeunload", persistData)
265
+ window.removeEventListener("blur", saveDataInUrl)
182
266
  })
183
267
 
268
+ const exposed = Object.assign(form, { meta, filterItems, clear })
269
+
184
270
  return exposed
185
271
  }
@@ -73,7 +73,7 @@ const form = useOmegaForm(
73
73
  },
74
74
  {
75
75
  persistency: {
76
- method: "local",
76
+ policies: ["local"],
77
77
  overrideDefaultValues: true,
78
78
  },
79
79
  },
@@ -44,7 +44,7 @@ const addForm = useOmegaForm(
44
44
  {},
45
45
  {
46
46
  persistency: {
47
- method: "session",
47
+ policies: ["session", "querystring"],
48
48
  keys: ["first", "third.fourth"],
49
49
  },
50
50
  },
@@ -55,11 +55,4 @@ const values = addForm.useStore(({ values }) => values)
55
55
  watch(values, ({ first, second }) => {
56
56
  sum.value = first + second
57
57
  })
58
-
59
- // TODO: Implement this when we have a way to persist the form values
60
- // {
61
- // persist: "session",
62
- // persistKeys: ["riskCategoryPeriod"],
63
- // persistBanKeys: ["riskCategory"],
64
- // }
65
58
  </script>