@effect-app/vue-components 0.7.6 → 0.7.7
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,10 +1,10 @@
|
|
|
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 { defineComponent as
|
|
2
|
+
import { defineComponent as q, getCurrentInstance as L, useId as P, computed as l, watch as w, nextTick as F, onMounted as x, ref as S, watchEffect as T, renderSlot as z, normalizeProps as A, guardReactiveProps as D, createElementVNode as M, normalizeClass as R, createBlock as U, createCommentVNode as Z, unref as j, openBlock as G, mergeProps as H } from "vue";
|
|
3
3
|
import { useStore as J } from "@tanstack/vue-form";
|
|
4
4
|
import { useOmegaErrors as K } from "./vue-components.es7.js";
|
|
5
5
|
import Q from "./vue-components.es27.js";
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const re = /* @__PURE__ */ q({
|
|
8
8
|
inheritAttrs: !1,
|
|
9
9
|
__name: "OmegaInternalInput",
|
|
10
10
|
props: {
|
|
@@ -16,33 +16,33 @@ const te = /* @__PURE__ */ B({
|
|
|
16
16
|
validators: {}
|
|
17
17
|
},
|
|
18
18
|
setup(C) {
|
|
19
|
-
const
|
|
20
|
-
var
|
|
21
|
-
return
|
|
22
|
-
}), i =
|
|
19
|
+
const t = C, o = L(), N = o == null ? void 0 : o.appContext.components.VTextField, s = P(), u = t.field, a = J(u.store, (e) => e), d = l(() => {
|
|
20
|
+
var e, r;
|
|
21
|
+
return t.type ? t.type : ((e = t.meta) == null ? void 0 : e.type) === "string" ? t.meta.format === "email" ? "email" : "string" : ((r = t.meta) == null ? void 0 : r.type) || "unknown";
|
|
22
|
+
}), i = l(() => a.value.value), $ = l(
|
|
23
23
|
() => (
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
-
a.value.meta.errors.map((
|
|
25
|
+
a.value.meta.errors.map((e) => e == null ? void 0 : e.message).filter(Boolean)
|
|
26
26
|
)
|
|
27
|
-
);
|
|
27
|
+
), k = (e) => e == null || e === !1 || e === "" || Number.isNaN(e);
|
|
28
28
|
w(
|
|
29
29
|
() => !!i.value,
|
|
30
|
-
(
|
|
30
|
+
(e) => {
|
|
31
31
|
var r;
|
|
32
|
-
|
|
33
|
-
var
|
|
32
|
+
k(e) && ((r = t.meta) == null ? void 0 : r.type) !== "boolean" && F(() => {
|
|
33
|
+
var n;
|
|
34
34
|
u.setValue(
|
|
35
|
-
((
|
|
35
|
+
((n = t.meta) == null ? void 0 : n.nullableOrUndefined) === "undefined" ? void 0 : null
|
|
36
36
|
);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
), x(() => {
|
|
40
|
-
var
|
|
41
|
-
!i.value && !((
|
|
40
|
+
var e, r;
|
|
41
|
+
!i.value && !((e = t.meta) != null && e.required) && ((r = t.meta) == null ? void 0 : r.nullableOrUndefined) === "null" && u.setValue(null);
|
|
42
42
|
});
|
|
43
|
-
const { addError:
|
|
44
|
-
|
|
45
|
-
(
|
|
43
|
+
const { addError: B, removeError: I, showErrors: O, showErrorsOn: _ } = K(), m = S(!1);
|
|
44
|
+
T(() => {
|
|
45
|
+
(O.value || _ === "onChange") && (m.value = !0);
|
|
46
46
|
});
|
|
47
47
|
const p = () => {
|
|
48
48
|
m.value = !0;
|
|
@@ -50,52 +50,52 @@ const te = /* @__PURE__ */ B({
|
|
|
50
50
|
x(() => {
|
|
51
51
|
i.value && p();
|
|
52
52
|
});
|
|
53
|
-
const c =
|
|
53
|
+
const c = l(() => !m.value && d.value !== "select" ? [] : $.value);
|
|
54
54
|
w(
|
|
55
55
|
() => a.value.meta.errors,
|
|
56
56
|
() => {
|
|
57
|
-
a.value.meta.errors.length ?
|
|
57
|
+
a.value.meta.errors.length ? B({
|
|
58
58
|
inputId: s,
|
|
59
|
-
errors: a.value.meta.errors.map((
|
|
60
|
-
label:
|
|
61
|
-
}) :
|
|
59
|
+
errors: a.value.meta.errors.map((e) => e.message).filter(Boolean),
|
|
60
|
+
label: t.label
|
|
61
|
+
}) : I(s);
|
|
62
62
|
}
|
|
63
63
|
);
|
|
64
|
-
const f =
|
|
65
|
-
var
|
|
64
|
+
const f = l(() => {
|
|
65
|
+
var e, r, n, v, g, y, h, b, E, V;
|
|
66
66
|
return {
|
|
67
67
|
id: s,
|
|
68
|
-
required: (
|
|
69
|
-
minLength: ((r =
|
|
70
|
-
maxLength: ((v =
|
|
71
|
-
max: ((y =
|
|
72
|
-
min: ((b =
|
|
73
|
-
name:
|
|
74
|
-
modelValue:
|
|
68
|
+
required: (e = t.meta) == null ? void 0 : e.required,
|
|
69
|
+
minLength: ((r = t.meta) == null ? void 0 : r.type) === "string" && ((n = t.meta) == null ? void 0 : n.minLength),
|
|
70
|
+
maxLength: ((v = t.meta) == null ? void 0 : v.type) === "string" && ((g = t.meta) == null ? void 0 : g.maxLength),
|
|
71
|
+
max: ((y = t.meta) == null ? void 0 : y.type) === "number" && ((h = t.meta) == null ? void 0 : h.maximum),
|
|
72
|
+
min: ((b = t.meta) == null ? void 0 : b.type) === "number" && ((E = t.meta) == null ? void 0 : E.minimum),
|
|
73
|
+
name: t.field.name,
|
|
74
|
+
modelValue: t.field.state.value,
|
|
75
75
|
errorMessages: c.value,
|
|
76
76
|
error: !!c.value.length,
|
|
77
|
-
field:
|
|
77
|
+
field: t.field,
|
|
78
78
|
setRealDirty: p,
|
|
79
79
|
type: d.value,
|
|
80
|
-
label: `${
|
|
81
|
-
options:
|
|
80
|
+
label: `${t.label}${(V = t.meta) != null && V.required ? " *" : ""}`,
|
|
81
|
+
options: t.options
|
|
82
82
|
};
|
|
83
83
|
});
|
|
84
|
-
return (
|
|
84
|
+
return (e, r) => z(e.$slots, "default", A(D(f.value)), () => [
|
|
85
85
|
M("div", {
|
|
86
|
-
class:
|
|
86
|
+
class: R(e.$attrs.class),
|
|
87
87
|
onFocusout: p
|
|
88
88
|
}, [
|
|
89
|
-
j(
|
|
89
|
+
j(N) ? (G(), U(Q, H({
|
|
90
90
|
key: 0,
|
|
91
91
|
"input-props": f.value
|
|
92
|
-
},
|
|
92
|
+
}, e.$attrs, {
|
|
93
93
|
"vuetify-value": f.value.field.state.value
|
|
94
|
-
}), null, 16, ["input-props", "vuetify-value"])) :
|
|
94
|
+
}), null, 16, ["input-props", "vuetify-value"])) : Z("", !0)
|
|
95
95
|
], 34)
|
|
96
96
|
]);
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
export {
|
|
100
|
-
|
|
100
|
+
re as default
|
|
101
101
|
};
|
package/package.json
CHANGED
|
@@ -71,12 +71,16 @@ const errors = computed(() =>
|
|
|
71
71
|
fieldState.value.meta.errors.map((e: any) => e?.message).filter(Boolean),
|
|
72
72
|
)
|
|
73
73
|
|
|
74
|
+
const isFalsyButNotZero = (value: unknown): boolean => {
|
|
75
|
+
return value == null || value === false || value === "" || Number.isNaN(value)
|
|
76
|
+
}
|
|
77
|
+
|
|
74
78
|
// we remove value and errors when the field is empty and not required
|
|
75
79
|
//watchEffect will trigger infinite times with both free fieldValue and errors, so bet to watch a stupid boolean
|
|
76
80
|
watch(
|
|
77
81
|
() => !!fieldValue.value,
|
|
78
82
|
value => {
|
|
79
|
-
if (
|
|
83
|
+
if (isFalsyButNotZero(value) && props.meta?.type !== "boolean") {
|
|
80
84
|
nextTick(() => {
|
|
81
85
|
fieldApi.setValue(
|
|
82
86
|
props.meta?.nullableOrUndefined === "undefined" ? undefined : null,
|