@effect-app/vue-components 1.8.2 → 1.8.3
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.
|
@@ -8,6 +8,10 @@ declare const __VLS_export: <From extends Record<PropertyKey, any>, Name extends
|
|
|
8
8
|
label: string;
|
|
9
9
|
type?: TypeOverride;
|
|
10
10
|
validators?: FieldValidators<From>;
|
|
11
|
+
options?: {
|
|
12
|
+
title: string;
|
|
13
|
+
value: string;
|
|
14
|
+
}[];
|
|
11
15
|
}> & import("vue").PublicProps;
|
|
12
16
|
expose: (exposed: {}) => void;
|
|
13
17
|
attrs: any;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var i=document.createElement("style");if(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;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),document.head.appendChild(i),window.customElements){const e=window.customElements.define;window.customElements.define=function(s,t){const n=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(n&&n.call(this),this.shadowRoot){const a=document.createElement("style");a.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;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),this.shadowRoot.appendChild(a)}},e.call(window.customElements,s,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { useStore as
|
|
4
|
-
import
|
|
2
|
+
import { defineComponent as N, getCurrentInstance as B, useId as I, computed as n, onMounted as g, ref as V, watchEffect as k, watch as q, onUnmounted as D, renderSlot as F, normalizeProps as h, guardReactiveProps as L, createElementVNode as O, normalizeClass as M, createBlock as R, createCommentVNode as S, unref as U, openBlock as z, mergeProps as A } from "vue";
|
|
3
|
+
import { useStore as T } from "@tanstack/vue-form";
|
|
4
|
+
import Z from "./vue-components.es25.js";
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const Y = /* @__PURE__ */ N({
|
|
7
7
|
inheritAttrs: !1,
|
|
8
8
|
__name: "OmegaInternalInput",
|
|
9
9
|
props: {
|
|
@@ -11,82 +11,83 @@ const te = /* @__PURE__ */ I({
|
|
|
11
11
|
meta: {},
|
|
12
12
|
label: {},
|
|
13
13
|
type: {},
|
|
14
|
-
validators: {}
|
|
14
|
+
validators: {},
|
|
15
|
+
options: {}
|
|
15
16
|
},
|
|
16
17
|
setup(v) {
|
|
17
|
-
const e = v, y =
|
|
18
|
+
const e = v, y = B()?.appContext.components.VTextField, a = I(), l = e.field, o = T(l.store, (t) => t), m = n(() => e.type ? e.type : e.meta?.type === "string" ? e.meta.format === "email" ? "email" : "string" : e.meta?.type || "unknown"), p = n(() => o.value.value), d = n(() => o.value.meta.errors ?? []), b = n(
|
|
18
19
|
() => (
|
|
19
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
|
|
21
|
+
d.value.map((t) => t?.message).filter(Boolean)
|
|
21
22
|
)
|
|
22
|
-
), C = (t) => t == null || t === !1 || t === "" || Number.isNaN(t),
|
|
23
|
+
), C = (t) => t == null || t === !1 || t === "" || Number.isNaN(t), w = (t) => {
|
|
23
24
|
C(t) && e.meta?.type !== "boolean" ? e.field.handleChange(
|
|
24
25
|
e.meta?.nullableOrUndefined === "undefined" ? void 0 : null
|
|
25
26
|
) : e.field.handleChange(t);
|
|
26
27
|
};
|
|
27
28
|
g(() => {
|
|
28
|
-
if (!
|
|
29
|
+
if (!p.value && !e.meta?.required && e.meta?.nullableOrUndefined === "null") {
|
|
29
30
|
const t = o.value.meta.isDirty;
|
|
30
31
|
l.setValue(null), l.setMeta((r) => ({ ...r, isDirty: t }));
|
|
31
32
|
}
|
|
32
33
|
});
|
|
33
|
-
const { mapError:
|
|
34
|
-
|
|
35
|
-
(
|
|
34
|
+
const { mapError: x, removeError: f, showErrors: E, showErrorsOn: P } = e.field.form.errorContext, s = V(!1);
|
|
35
|
+
k(() => {
|
|
36
|
+
(E.value || P === "onChange") && (s.value = !0);
|
|
36
37
|
});
|
|
37
38
|
const i = () => {
|
|
38
39
|
s.value = !0;
|
|
39
40
|
};
|
|
40
41
|
g(() => {
|
|
41
|
-
|
|
42
|
+
p.value && i();
|
|
42
43
|
});
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const c = n(() => !s.value && m.value !== "select" ? [] : b.value);
|
|
45
|
+
q(
|
|
46
|
+
d,
|
|
46
47
|
(t) => {
|
|
47
|
-
t.length ?
|
|
48
|
+
t.length ? x({
|
|
48
49
|
inputId: a,
|
|
49
50
|
errors: o.value.meta.errors.map((r) => r.message).filter(Boolean),
|
|
50
51
|
label: e.label
|
|
51
|
-
}) :
|
|
52
|
+
}) : f(a);
|
|
52
53
|
}
|
|
53
|
-
),
|
|
54
|
-
|
|
54
|
+
), D(() => {
|
|
55
|
+
f(a);
|
|
55
56
|
});
|
|
56
|
-
const
|
|
57
|
+
const _ = (t) => {
|
|
57
58
|
const r = {
|
|
58
|
-
get(
|
|
59
|
-
return
|
|
59
|
+
get(H, $, J) {
|
|
60
|
+
return $ === "handleChange" ? w : Reflect.get(...arguments);
|
|
60
61
|
}
|
|
61
62
|
};
|
|
62
63
|
return new Proxy(t, r);
|
|
63
|
-
},
|
|
64
|
+
}, u = n(() => ({
|
|
64
65
|
inputProps: {
|
|
65
|
-
...N,
|
|
66
66
|
id: a,
|
|
67
67
|
required: e.meta?.required,
|
|
68
68
|
minLength: e.meta?.type === "string" && e.meta?.minLength,
|
|
69
69
|
maxLength: e.meta?.type === "string" && e.meta?.maxLength,
|
|
70
70
|
max: e.meta?.type === "number" && e.meta?.maximum,
|
|
71
71
|
min: e.meta?.type === "number" && e.meta?.minimum,
|
|
72
|
-
errorMessages:
|
|
73
|
-
error: !!
|
|
72
|
+
errorMessages: c.value,
|
|
73
|
+
error: !!c.value.length,
|
|
74
74
|
setRealDirty: i,
|
|
75
75
|
type: m.value,
|
|
76
|
-
label: `${e.label}${e.meta?.required ? " *" : ""}
|
|
76
|
+
label: `${e.label}${e.meta?.required ? " *" : ""}`,
|
|
77
|
+
options: e.options
|
|
77
78
|
},
|
|
78
|
-
field:
|
|
79
|
+
field: _(e.field)
|
|
79
80
|
}));
|
|
80
|
-
return (t, r) =>
|
|
81
|
-
|
|
82
|
-
class:
|
|
81
|
+
return (t, r) => F(t.$slots, "default", h(L({ ...t.$attrs, ...u.value.inputProps, field: u.value.field })), () => [
|
|
82
|
+
O("div", {
|
|
83
|
+
class: M(t.$attrs.class),
|
|
83
84
|
onFocusout: i
|
|
84
85
|
}, [
|
|
85
|
-
|
|
86
|
+
U(y) ? (z(), R(Z, h(A({ key: 0 }, { ...t.$attrs, ...u.value })), null, 16)) : S("", !0)
|
|
86
87
|
], 34)
|
|
87
88
|
]);
|
|
88
89
|
}
|
|
89
90
|
});
|
|
90
91
|
export {
|
|
91
|
-
|
|
92
|
+
Y as default
|
|
92
93
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<slot v-bind="{ ...inputProps.inputProps, field: inputProps.field }">
|
|
2
|
+
<slot v-bind="{ ...$attrs, ...inputProps.inputProps, field: inputProps.field }">
|
|
3
3
|
<div
|
|
4
4
|
:class="$attrs.class"
|
|
5
5
|
@focusout="setRealDirty"
|
|
6
6
|
>
|
|
7
7
|
<OmegaInputVuetify
|
|
8
8
|
v-if="vuetified"
|
|
9
|
-
v-bind="inputProps"
|
|
9
|
+
v-bind="{ ...$attrs, ...inputProps }"
|
|
10
10
|
/>
|
|
11
11
|
</div>
|
|
12
12
|
</slot>
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
generic="From extends Record<PropertyKey, any>, Name extends DeepKeys<From>"
|
|
19
19
|
>
|
|
20
20
|
import { type DeepKeys, useStore } from "@tanstack/vue-form"
|
|
21
|
-
import { computed, type ComputedRef, getCurrentInstance, onMounted, onUnmounted, ref,
|
|
21
|
+
import { computed, type ComputedRef, getCurrentInstance, onMounted, onUnmounted, ref, useId, watch, watchEffect } from "vue"
|
|
22
22
|
import type { InputProps, OmegaFieldInternalApi } from "./InputProps"
|
|
23
23
|
import type { FieldValidators, MetaRecord, NestedKeyOf, TypeOverride } from "./OmegaFormStuff"
|
|
24
24
|
import OmegaInputVuetify from "./OmegaInputVuetify.vue"
|
|
@@ -33,6 +33,9 @@ const props = defineProps<{
|
|
|
33
33
|
label: string
|
|
34
34
|
type?: TypeOverride
|
|
35
35
|
validators?: FieldValidators<From>
|
|
36
|
+
|
|
37
|
+
// TODO: these should really be optional, depending on the input type (and the custom input type for custom inputs :s)
|
|
38
|
+
options?: { title: string; value: string }[]
|
|
36
39
|
}>()
|
|
37
40
|
|
|
38
41
|
const instance = getCurrentInstance()
|
|
@@ -159,11 +162,8 @@ const wrapField = (field: OmegaFieldInternalApi<From, Name>) => {
|
|
|
159
162
|
return proxy3 as typeof field
|
|
160
163
|
}
|
|
161
164
|
|
|
162
|
-
const attrs = useAttrs()
|
|
163
|
-
|
|
164
165
|
const inputProps: ComputedRef<InputProps<From, Name>> = computed(() => ({
|
|
165
166
|
inputProps: {
|
|
166
|
-
...attrs,
|
|
167
167
|
id,
|
|
168
168
|
required: props.meta?.required,
|
|
169
169
|
minLength: props.meta?.type === "string" && props.meta?.minLength,
|
|
@@ -174,7 +174,8 @@ const inputProps: ComputedRef<InputProps<From, Name>> = computed(() => ({
|
|
|
174
174
|
error: !!showedErrors.value.length,
|
|
175
175
|
setRealDirty,
|
|
176
176
|
type: fieldType.value,
|
|
177
|
-
label: `${props.label}${props.meta?.required ? " *" : ""}
|
|
177
|
+
label: `${props.label}${props.meta?.required ? " *" : ""}`,
|
|
178
|
+
options: props.options
|
|
178
179
|
},
|
|
179
180
|
|
|
180
181
|
field: wrapField(props.field)
|