@effect-app/vue-components 0.3.1 → 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>[];
@@ -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.es16.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,95 +1,7 @@
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.es18.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
+ 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);
93
3
  export {
94
- Z as default
4
+ s as isFunction,
5
+ i as isObject,
6
+ t as isRecordOrArray
95
7
  };
@@ -1,13 +1,4 @@
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
+ const o = (n) => typeof n == "function";
11
2
  export {
12
- c as getOmegaStore
3
+ o as isFunction
13
4
  };
@@ -1,4 +1,95 @@
1
- import f from "./vue-components.es15.js";
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
+ });
2
93
  export {
3
- f as default
94
+ Z as default
4
95
  };
@@ -1,117 +1,13 @@
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 { 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
+ }
115
11
  export {
116
- b as default
12
+ c as getOmegaStore
117
13
  };
@@ -0,0 +1,4 @@
1
+ import f from "./vue-components.es17.js";
2
+ export {
3
+ f as default
4
+ };
@@ -1,6 +1,117 @@
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.es18.js";
3
-
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
+ });
4
115
  export {
5
- o as default
116
+ b as default
6
117
  };
@@ -0,0 +1,6 @@
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.es20.js";
3
+
4
+ export {
5
+ o as default
6
+ };
@@ -1,110 +1,125 @@
1
- import { useForm as p } from "@tanstack/vue-form";
2
- import { S as E } from "effect-app";
3
- import { generateMetaFromSchema as P } from "./vue-components.es6.js";
4
- import { computed as y, onUnmounted as I, onMounted as N, onBeforeUnmount as R } from "vue";
5
- const K = (a, t, u) => {
6
- if (!a) throw new Error("Schema is required");
7
- const b = E.standardSchemaV1(a), { filterItems: f, meta: c } = P(a), i = y(() => {
8
- var r;
9
- if ((r = u == null ? void 0 : u.persistency) != null && r.id)
10
- return u.persistency.id;
11
- const e = window.location.pathname, l = Object.keys(c);
12
- return `${e}-${l.join("-")}`;
1
+ import { useForm as E } from "@tanstack/vue-form";
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("-")}`;
13
14
  }), L = () => {
14
15
  const e = new URLSearchParams(window.location.search);
15
- e.delete(i.value);
16
- const l = new URL(window.location.href);
17
- l.search = e.toString(), window.history.replaceState({}, "", l.toString());
18
- }, U = y(() => {
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(() => {
19
26
  var l;
20
- if (t != null && t.defaultValues && !((l = u == null ? void 0 : u.persistency) != null && l.overrideDefaultValues))
21
- return t == null ? void 0 : t.defaultValues;
22
- const e = u == null ? void 0 : u.persistency;
23
- if (!(e != null && e.policies) || e.policies.length === 0) return {};
24
- if (e.policies.includes("querystring"))
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"))
25
33
  try {
26
- const s = new URLSearchParams(window.location.search).get(i.value);
27
- if (L(), s)
28
- return JSON.parse(s);
29
- } catch (r) {
30
- console.error(r);
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);
31
38
  }
32
- if (e.policies.includes("local") || e.policies.includes("session")) {
33
- const r = e.policies.includes("local") ? localStorage : sessionStorage;
34
- if (r)
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)
35
45
  try {
36
- const s = JSON.parse(
37
- r.getItem(i.value) || "{}"
46
+ const d = JSON.parse(
47
+ s.getItem(c.value) || "{}"
38
48
  );
39
- return r.removeItem(i.value), s;
40
- } catch (s) {
41
- console.error(s);
49
+ s.removeItem(c.value), e = d;
50
+ } catch (d) {
51
+ console.error(d);
42
52
  }
43
53
  }
44
- return {};
45
- }), n = p({
46
- ...t,
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,
47
62
  validators: {
48
63
  onSubmit: b,
49
- ...(t == null ? void 0 : t.validators) || {}
64
+ ...(u == null ? void 0 : u.validators) || {}
50
65
  },
51
- onSubmit: t != null && t.onSubmit ? ({ formApi: e, meta: l, value: r }) => {
66
+ onSubmit: u != null && u.onSubmit ? ({ formApi: e, meta: r, value: l }) => {
52
67
  var s;
53
- return (s = t.onSubmit) == null ? void 0 : s.call(t, {
68
+ return (s = u.onSubmit) == null ? void 0 : s.call(u, {
54
69
  formApi: e,
55
- meta: l,
56
- value: r
70
+ meta: r,
71
+ value: l
57
72
  });
58
73
  } : void 0,
59
74
  defaultValues: U.value
60
- }), V = () => {
61
- Object.keys(c).forEach((e) => {
75
+ }), j = () => {
76
+ Object.keys(t).forEach((e) => {
62
77
  n.setFieldValue(e, void 0);
63
78
  });
64
- }, S = (e) => e.reduce(
65
- (l, r) => {
66
- const s = r.split(".");
67
- return s.reduce((d, o, j) => (j === s.length - 1 ? d[o] = n.getFieldValue(r) : d[o] = d[o] || {}, d[o]), l);
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;
68
83
  },
69
84
  {}
70
- ), h = (e) => {
85
+ ), v = (e) => {
71
86
  if (e) {
72
87
  if (Array.isArray(e.keys))
73
- return S(e.keys);
88
+ return o(e.keys);
74
89
  if (Array.isArray(e.banKeys)) {
75
- const l = Object.keys(c).filter(
76
- (r) => {
90
+ const r = Object.keys(t).filter(
91
+ (l) => {
77
92
  var s;
78
- return (s = e.banKeys) == null ? void 0 : s.includes(r);
93
+ return (s = e.banKeys) == null ? void 0 : s.includes(l);
79
94
  }
80
95
  );
81
- return S(l);
96
+ return o(r);
82
97
  }
83
98
  return n.store.state.values;
84
99
  }
85
- }, w = () => {
86
- const e = u == null ? void 0 : u.persistency;
100
+ }, S = () => {
101
+ const e = i == null ? void 0 : i.persistency;
87
102
  if (!(!(e != null && e.policies) || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
88
- const l = e.policies.includes("local") ? localStorage : sessionStorage;
89
- if (!l) return;
90
- const r = h(e);
91
- return l.setItem(i.value, JSON.stringify(r));
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));
92
107
  }
93
- }, v = () => {
94
- const e = u == null ? void 0 : u.persistency;
108
+ }, y = () => {
109
+ const e = i == null ? void 0 : i.persistency;
95
110
  if (!(!(e != null && e.policies) || e.policies.length === 0) && e.policies.includes("querystring")) {
96
- const l = h(e), r = new URLSearchParams(window.location.search);
97
- r.set(i.value, JSON.stringify(l));
111
+ const r = v(e), l = new URLSearchParams(window.location.search);
112
+ l.set(c.value, JSON.stringify(r));
98
113
  const s = new URL(window.location.href);
99
- s.search = r.toString(), window.history.replaceState({}, "", s.toString());
114
+ s.search = l.toString(), window.history.replaceState({}, "", s.toString());
100
115
  }
101
116
  };
102
- return I(w), N(() => {
103
- window.addEventListener("beforeunload", w), window.addEventListener("blur", v);
104
- }), R(() => {
105
- window.removeEventListener("beforeunload", w), window.removeEventListener("blur", v);
106
- }), Object.assign(n, { meta: c, filterItems: f, clear: 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 });
107
122
  };
108
123
  export {
109
- K as useOmegaForm
124
+ z as useOmegaForm
110
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.es15.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.1",
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 { S } from "effect-app"
8
+ import { type Record, S } from "effect-app"
9
9
  import {
10
10
  generateMetaFromSchema,
11
11
  type NestedKeyOf,
@@ -15,6 +15,7 @@ import {
15
15
  type OmegaFormApi,
16
16
  } from "./OmegaFormStuff"
17
17
  import { computed, onBeforeUnmount, onMounted, onUnmounted } from "vue"
18
+ import { isObject } from "effect/Predicate"
18
19
 
19
20
  type keysRule<T> =
20
21
  | {
@@ -76,13 +77,36 @@ export const useOmegaForm = <
76
77
  window.history.replaceState({}, "", url.toString())
77
78
  }
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
+
79
94
  const defaultValues = computed(() => {
80
95
  if (
81
96
  tanstackFormOptions?.defaultValues &&
82
97
  !omegaConfig?.persistency?.overrideDefaultValues
83
98
  ) {
99
+ // defaultValues from tanstack are not partial,
100
+ // so if ovverrideDefaultValues is false we simply return them
84
101
  return tanstackFormOptions?.defaultValues
85
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
+
86
110
  const persistency = omegaConfig?.persistency
87
111
  if (!persistency?.policies || persistency.policies.length === 0) return {}
88
112
  if (persistency.policies.includes("querystring")) {
@@ -91,7 +115,7 @@ export const useOmegaForm = <
91
115
  const value = params.get(persistencyKey.value)
92
116
  clearUrlParams()
93
117
  if (value) {
94
- return JSON.parse(value)
118
+ defValuesPatch = JSON.parse(value)
95
119
  }
96
120
  } catch (error) {
97
121
  console.error(error)
@@ -99,8 +123,10 @@ export const useOmegaForm = <
99
123
  }
100
124
 
101
125
  if (
102
- persistency.policies.includes("local") ||
103
- persistency.policies.includes("session")
126
+ // query string has higher priority than local/session storage
127
+ !defValuesPatch &&
128
+ (persistency.policies.includes("local") ||
129
+ persistency.policies.includes("session"))
104
130
  ) {
105
131
  const storage = persistency.policies.includes("local")
106
132
  ? localStorage
@@ -111,13 +137,23 @@ export const useOmegaForm = <
111
137
  storage.getItem(persistencyKey.value) || "{}",
112
138
  )
113
139
  storage.removeItem(persistencyKey.value)
114
- return value
140
+ defValuesPatch = value
115
141
  } catch (error) {
116
142
  console.error(error)
117
143
  }
118
144
  }
119
145
  }
120
- return {}
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
+ }
121
157
  })
122
158
 
123
159
  const form = useForm<
@@ -158,14 +194,15 @@ export const useOmegaForm = <
158
194
  paths.reduce(
159
195
  (result, path) => {
160
196
  const parts = path.split(".")
161
- return parts.reduce((acc, part, i) => {
197
+ parts.reduce((acc, part, i) => {
162
198
  if (i === parts.length - 1) {
163
199
  acc[part] = form.getFieldValue(path as any)
164
200
  } else {
165
- acc[part] = acc[part] || {}
201
+ acc[part] = acc[part] ?? {}
166
202
  }
167
203
  return acc[part]
168
204
  }, result)
205
+ return result
169
206
  },
170
207
  {} as Record<string, any>,
171
208
  )