@effect-app/vue-components 0.7.6 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +1 -1
- package/dist/vue-components.es24.js +40 -40
- package/dist/vue-components.es27.js +10 -10
- package/package.json +1 -1
- package/src/components/OmegaForm/OmegaFormStuff.ts +1 -0
- package/src/components/OmegaForm/OmegaInputVuetify.vue +3 -2
- package/src/components/OmegaForm/OmegaInternalInput.vue +5 -1
|
@@ -15,7 +15,7 @@ export type OmegaInputProps<From, To> = {
|
|
|
15
15
|
}[];
|
|
16
16
|
type?: TypeOverride;
|
|
17
17
|
};
|
|
18
|
-
export type TypeOverride = "string" | "text" | "number" | "select" | "multiple" | "boolean" | "autocomplete" | "autocompletemultiple" | "switch";
|
|
18
|
+
export type TypeOverride = "string" | "text" | "number" | "select" | "multiple" | "boolean" | "autocomplete" | "autocompletemultiple" | "switch" | "range";
|
|
19
19
|
export interface OmegaError {
|
|
20
20
|
label: string;
|
|
21
21
|
inputId: string;
|
|
@@ -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
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const b = /* @__PURE__ */
|
|
1
|
+
import { defineComponent as P, resolveComponent as s, createElementBlock as g, openBlock as o, createBlock as n, createCommentVNode as l, resolveDynamicComponent as u, mergeProps as i } from "vue";
|
|
2
|
+
const b = /* @__PURE__ */ P({
|
|
3
3
|
inheritAttrs: !1,
|
|
4
4
|
__name: "OmegaInputVuetify",
|
|
5
5
|
props: {
|
|
@@ -9,13 +9,13 @@ const b = /* @__PURE__ */ d({
|
|
|
9
9
|
emits: ["focus", "blur"],
|
|
10
10
|
setup(y) {
|
|
11
11
|
return (e, r) => {
|
|
12
|
-
const
|
|
13
|
-
return o(),
|
|
12
|
+
const a = s("v-text-field"), t = s("v-textarea"), m = s("v-select"), d = s("v-autocomplete");
|
|
13
|
+
return o(), g("div", {
|
|
14
14
|
class: "omega-input",
|
|
15
15
|
onFocusout: r[4] || (r[4] = (p) => e.$emit("blur", p)),
|
|
16
16
|
onFocusin: r[5] || (r[5] = (p) => e.$emit("focus", p))
|
|
17
17
|
}, [
|
|
18
|
-
e.inputProps.type === "boolean" || e.inputProps.type === "switch" ? (o(), n(
|
|
18
|
+
e.inputProps.type === "boolean" || e.inputProps.type === "switch" ? (o(), n(u(e.inputProps.type === "boolean" ? "v-checkbox" : "v-switch"), i({
|
|
19
19
|
key: 0,
|
|
20
20
|
id: e.inputProps.id,
|
|
21
21
|
name: e.inputProps.name,
|
|
@@ -27,7 +27,7 @@ const b = /* @__PURE__ */ d({
|
|
|
27
27
|
"model-value": e.vuetifyValue,
|
|
28
28
|
onChange: r[0] || (r[0] = (p) => e.inputProps.field.handleChange(p.target.checked))
|
|
29
29
|
}), null, 16, ["id", "name", "label", "error-messages", "error", "model-value"])) : l("", !0),
|
|
30
|
-
e.inputProps.type === "email" || e.inputProps.type === "string" ? (o(), n(
|
|
30
|
+
e.inputProps.type === "email" || e.inputProps.type === "string" ? (o(), n(a, i({
|
|
31
31
|
key: 1,
|
|
32
32
|
id: e.inputProps.id,
|
|
33
33
|
required: e.inputProps.required,
|
|
@@ -42,7 +42,7 @@ const b = /* @__PURE__ */ d({
|
|
|
42
42
|
"model-value": e.vuetifyValue,
|
|
43
43
|
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
44
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(
|
|
45
|
+
e.inputProps.type === "text" ? (o(), n(t, i({
|
|
46
46
|
key: 2,
|
|
47
47
|
id: e.inputProps.id,
|
|
48
48
|
required: e.inputProps.required,
|
|
@@ -57,7 +57,7 @@ const b = /* @__PURE__ */ d({
|
|
|
57
57
|
"model-value": e.vuetifyValue,
|
|
58
58
|
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
59
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, i({
|
|
60
|
+
e.inputProps.type === "number" || e.inputProps.type === "range" ? (o(), n(u(e.inputProps.type === "range" ? "v-slider" : "v-text-field"), i({
|
|
61
61
|
key: 3,
|
|
62
62
|
id: e.inputProps.id,
|
|
63
63
|
required: e.inputProps.required,
|
|
@@ -74,7 +74,7 @@ const b = /* @__PURE__ */ d({
|
|
|
74
74
|
e.inputProps.field.handleChange(Number(p));
|
|
75
75
|
})
|
|
76
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(
|
|
77
|
+
e.inputProps.type === "select" || e.inputProps.type === "multiple" ? (o(), n(m, i({
|
|
78
78
|
key: 4,
|
|
79
79
|
id: e.inputProps.id,
|
|
80
80
|
clearable: e.inputProps.type === "select",
|
|
@@ -91,7 +91,7 @@ const b = /* @__PURE__ */ d({
|
|
|
91
91
|
onClear: r[2] || (r[2] = (p) => e.inputProps.field.handleChange(void 0)),
|
|
92
92
|
"onUpdate:modelValue": e.inputProps.field.handleChange
|
|
93
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(
|
|
94
|
+
e.inputProps.type === "autocomplete" || e.inputProps.type === "autocompletemultiple" ? (o(), n(d, i({
|
|
95
95
|
key: 5,
|
|
96
96
|
id: e.inputProps.id,
|
|
97
97
|
clearable: e.inputProps.type === "autocomplete",
|
package/package.json
CHANGED
|
@@ -47,8 +47,9 @@
|
|
|
47
47
|
:model-value="vuetifyValue"
|
|
48
48
|
@update:model-value="inputProps.field.handleChange"
|
|
49
49
|
/>
|
|
50
|
-
<
|
|
51
|
-
|
|
50
|
+
<component
|
|
51
|
+
:is="inputProps.type === 'range' ? 'v-slider' : 'v-text-field'"
|
|
52
|
+
v-if="inputProps.type === 'number' || inputProps.type === 'range'"
|
|
52
53
|
:id="inputProps.id"
|
|
53
54
|
:required="inputProps.required"
|
|
54
55
|
:min="inputProps.min"
|
|
@@ -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,
|