@effect-app/vue-components 1.5.1 → 1.6.1
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/InputProps.d.ts +18 -18
- package/dist/types/components/OmegaForm/OmegaFormInput.vue.d.ts +2 -2
- package/dist/types/components/OmegaForm/OmegaInput.vue.d.ts +1 -4
- package/dist/types/components/OmegaForm/OmegaInputVuetify.vue.d.ts +1 -4
- package/dist/types/components/OmegaForm/OmegaInternalInput.vue.d.ts +1 -4
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +2 -2
- package/dist/vue-components.es10.js +12 -13
- package/dist/vue-components.es23.js +50 -50
- package/dist/vue-components.es5.js +53 -52
- package/package.json +1 -1
- package/src/components/OmegaForm/InputProps.ts +18 -15
- package/src/components/OmegaForm/OmegaFormInput.vue +2 -2
- package/src/components/OmegaForm/OmegaInputVuetify.vue +25 -28
- package/src/components/OmegaForm/OmegaInternalInput.vue +32 -21
- package/src/components/OmegaForm/createUseFormWithCustomInput.ts +1 -2
- package/src/components/OmegaForm/useOmegaForm.ts +2 -2
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import type { DeepKeys, DeepValue, FieldApi, FieldAsyncValidateOrFn, FieldValidateAsyncFn, FieldValidateFn, FieldValidateOrFn, FormAsyncValidateOrFn, FormValidateOrFn, StandardSchemaV1 } from "@tanstack/vue-form";
|
|
2
2
|
export type OmegaFieldInternalApi<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> = FieldApi<From, TName, DeepValue<From, TName>, FieldValidateOrFn<From, TName, DeepValue<From, TName>> | undefined, StandardSchemaV1<DeepValue<From, TName>, unknown> | FieldValidateFn<From, TName>, StandardSchemaV1<DeepValue<From, TName>, unknown> | FieldValidateAsyncFn<From, TName>, FieldValidateOrFn<From, TName, DeepValue<From, TName>>, FieldAsyncValidateOrFn<From, TName, DeepValue<From, TName>>, FieldValidateOrFn<From, TName, DeepValue<From, TName>> | undefined, FieldAsyncValidateOrFn<From, TName, DeepValue<From, TName>> | undefined, FieldValidateOrFn<From, TName, DeepValue<From, TName>> | undefined, FieldAsyncValidateOrFn<From, TName, DeepValue<From, TName>> | undefined, FormValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, any, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From> | undefined, Record<string, any> | undefined>;
|
|
3
3
|
export type InputProps<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
inputProps: {
|
|
5
|
+
id: string;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
minLength?: number | false;
|
|
8
|
+
maxLength?: number | false;
|
|
9
|
+
max?: number | false;
|
|
10
|
+
min?: number | false;
|
|
11
|
+
errorMessages: string[];
|
|
12
|
+
error: boolean;
|
|
13
|
+
setRealDirty: () => void;
|
|
14
|
+
type: string;
|
|
15
|
+
label: string;
|
|
16
|
+
options?: {
|
|
17
|
+
title: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
15
21
|
field: OmegaFieldInternalApi<From, TName>;
|
|
16
|
-
setRealDirty: () => void;
|
|
17
|
-
type: string;
|
|
18
|
-
label: string;
|
|
19
|
-
options?: {
|
|
20
|
-
title: string;
|
|
21
|
-
value: string;
|
|
22
|
-
}[];
|
|
23
22
|
};
|
|
23
|
+
export type MergedInputProps<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> = InputProps<From, TName>["inputProps"] & Pick<InputProps<From, TName>, "field">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DeepKeys } from "@tanstack/vue-form";
|
|
2
|
-
import type {
|
|
2
|
+
import type { MergedInputProps } from "./InputProps";
|
|
3
3
|
import type { DefaultInputProps } from "./OmegaFormStuff";
|
|
4
4
|
declare const __VLS_export: <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Name extends DeepKeys<From>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
5
5
|
props: __VLS_PrettifyLocal<{
|
|
@@ -8,7 +8,7 @@ declare const __VLS_export: <From extends Record<PropertyKey, any>, To extends R
|
|
|
8
8
|
expose: (exposed: {}) => void;
|
|
9
9
|
attrs: any;
|
|
10
10
|
slots: {
|
|
11
|
-
default(props:
|
|
11
|
+
default(props: MergedInputProps<From, Name>): void;
|
|
12
12
|
};
|
|
13
13
|
emit: {};
|
|
14
14
|
}>) => import("vue").VNode & {
|
|
@@ -5,18 +5,15 @@ declare const __VLS_export: <From extends Record<PropertyKey, any>, To extends R
|
|
|
5
5
|
attrs: any;
|
|
6
6
|
slots: {
|
|
7
7
|
default?: (props: {
|
|
8
|
+
field: import("./InputProps").OmegaFieldInternalApi<From, any>;
|
|
8
9
|
id: string;
|
|
9
10
|
required?: boolean;
|
|
10
11
|
minLength?: number | false;
|
|
11
12
|
maxLength?: number | false;
|
|
12
13
|
max?: number | false;
|
|
13
14
|
min?: number | false;
|
|
14
|
-
name: string;
|
|
15
|
-
modelValue: import("@tanstack/vue-form").DeepValue<From, any>;
|
|
16
|
-
handleChange: (value: import("@tanstack/vue-form").DeepValue<From, any>) => void;
|
|
17
15
|
errorMessages: string[];
|
|
18
16
|
error: boolean;
|
|
19
|
-
field: import("./InputProps").OmegaFieldInternalApi<From, any>;
|
|
20
17
|
setRealDirty: () => void;
|
|
21
18
|
type: string;
|
|
22
19
|
label: string;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { type DeepKeys } from "@tanstack/vue-form";
|
|
2
2
|
import type { InputProps } from "./InputProps";
|
|
3
3
|
declare const __VLS_export: <From extends Record<PropertyKey, any>, Name extends DeepKeys<From>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
-
props: __VLS_PrettifyLocal<{
|
|
5
|
-
inputProps: InputProps<From, Name>;
|
|
6
|
-
vuetifyValue: unknown;
|
|
7
|
-
} & {
|
|
4
|
+
props: __VLS_PrettifyLocal<InputProps<From, Name> & {
|
|
8
5
|
onBlur?: ((event: Event) => any) | undefined;
|
|
9
6
|
onFocus?: ((event: Event) => any) | undefined;
|
|
10
7
|
}> & import("vue").PublicProps;
|
|
@@ -17,18 +17,15 @@ declare const __VLS_export: <From extends Record<PropertyKey, any>, Name extends
|
|
|
17
17
|
attrs: any;
|
|
18
18
|
slots: {
|
|
19
19
|
default?: (props: {
|
|
20
|
+
field: OmegaFieldInternalApi<From, Name>;
|
|
20
21
|
id: string;
|
|
21
22
|
required?: boolean;
|
|
22
23
|
minLength?: number | false;
|
|
23
24
|
maxLength?: number | false;
|
|
24
25
|
max?: number | false;
|
|
25
26
|
min?: number | false;
|
|
26
|
-
name: string;
|
|
27
|
-
modelValue: import("@tanstack/vue-form").DeepValue<From, Name>;
|
|
28
|
-
handleChange: (value: import("@tanstack/vue-form").DeepValue<From, Name>) => void;
|
|
29
27
|
errorMessages: string[];
|
|
30
28
|
error: boolean;
|
|
31
|
-
field: OmegaFieldInternalApi<From, Name>;
|
|
32
29
|
setRealDirty: () => void;
|
|
33
30
|
type: string;
|
|
34
31
|
label: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DeepKeys, DeepValue, StandardSchemaV1Issue, ValidationError, ValidationErrorMap } from "@tanstack/vue-form";
|
|
2
2
|
import { Effect, Order, S } from "effect-app";
|
|
3
3
|
import { type InjectionKey } from "vue";
|
|
4
|
-
import {
|
|
4
|
+
import { MergedInputProps } from "./InputProps";
|
|
5
5
|
import { DefaultInputProps, type FilterItems, type FormProps, type MetaRecord, type NestedKeyOf, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState, OmegaInputProps, ShowErrorsOn } from "./OmegaFormStuff";
|
|
6
6
|
type keysRule<T> = {
|
|
7
7
|
keys?: NestedKeyOf<T>[];
|
|
@@ -71,7 +71,7 @@ export interface OmegaFormReturn<From extends Record<PropertyKey, any>, To exten
|
|
|
71
71
|
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
|
|
72
72
|
attrs: any;
|
|
73
73
|
slots: {
|
|
74
|
-
default(props:
|
|
74
|
+
default(props: MergedInputProps<From, Name>): void;
|
|
75
75
|
};
|
|
76
76
|
emit: {};
|
|
77
77
|
}>) => import("vue").VNode & {
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import { h as
|
|
1
|
+
import { h as r } from "vue";
|
|
2
2
|
import s from "./vue-components.es4.js";
|
|
3
|
-
import { useOmegaForm as
|
|
4
|
-
const W = (
|
|
5
|
-
const [m,
|
|
6
|
-
return
|
|
3
|
+
import { useOmegaForm as i } from "./vue-components.es7.js";
|
|
4
|
+
const W = (e) => (...n) => {
|
|
5
|
+
const [m, o, a] = n;
|
|
6
|
+
return i(
|
|
7
7
|
m,
|
|
8
|
-
|
|
8
|
+
o,
|
|
9
9
|
{
|
|
10
|
-
...
|
|
10
|
+
...a,
|
|
11
11
|
input: {
|
|
12
12
|
name: "WrappedInput",
|
|
13
13
|
inheritAttrs: !1,
|
|
14
|
-
setup(f, { attrs: u, slots:
|
|
15
|
-
return () =>
|
|
14
|
+
setup(f, { attrs: u, slots: p }) {
|
|
15
|
+
return () => r(s, {
|
|
16
16
|
...f,
|
|
17
17
|
...u
|
|
18
18
|
}, {
|
|
19
19
|
// Override the default slot that OmegaInternalInput provides
|
|
20
|
-
default: (t) => t && "field" in t ? e
|
|
21
|
-
inputProps: t
|
|
22
|
-
|
|
23
|
-
}) : i.default?.(t)
|
|
20
|
+
default: (t) => t && "field" in t ? r(e, {
|
|
21
|
+
inputProps: t
|
|
22
|
+
}) : p.default?.(t)
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
25
|
}
|
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { getInputType as
|
|
3
|
-
const U = /* @__PURE__ */
|
|
1
|
+
import { defineComponent as y, resolveComponent as o, createElementBlock as m, openBlock as n, createBlock as a, createCommentVNode as i, resolveDynamicComponent as d, mergeProps as u, unref as b, withCtx as h, Fragment as c, renderList as C } from "vue";
|
|
2
|
+
import { getInputType as q } from "./vue-components.es9.js";
|
|
3
|
+
const U = /* @__PURE__ */ y({
|
|
4
4
|
inheritAttrs: !1,
|
|
5
5
|
__name: "OmegaInputVuetify",
|
|
6
6
|
props: {
|
|
7
7
|
inputProps: {},
|
|
8
|
-
|
|
8
|
+
field: {}
|
|
9
9
|
},
|
|
10
10
|
emits: ["focus", "blur"],
|
|
11
11
|
setup(e) {
|
|
12
|
-
return (
|
|
13
|
-
const
|
|
14
|
-
return
|
|
12
|
+
return (r, l) => {
|
|
13
|
+
const s = o("v-text-field"), P = o("v-textarea"), g = o("v-radio"), v = o("v-radio-group"), p = o("v-select"), f = o("v-autocomplete");
|
|
14
|
+
return n(), m("div", {
|
|
15
15
|
class: "omega-input",
|
|
16
|
-
onFocusout:
|
|
17
|
-
onFocusin:
|
|
16
|
+
onFocusout: l[4] || (l[4] = (t) => r.$emit("blur", t)),
|
|
17
|
+
onFocusin: l[5] || (l[5] = (t) => r.$emit("focus", t))
|
|
18
18
|
}, [
|
|
19
|
-
e.inputProps.type === "boolean" || e.inputProps.type === "switch" ? (
|
|
19
|
+
e.inputProps.type === "boolean" || e.inputProps.type === "switch" ? (n(), a(d(e.inputProps.type === "boolean" ? "v-checkbox" : "v-switch"), u({
|
|
20
20
|
key: 0,
|
|
21
21
|
id: e.inputProps.id,
|
|
22
|
-
name: e.
|
|
22
|
+
name: e.field.name,
|
|
23
23
|
label: e.inputProps.label,
|
|
24
24
|
"error-messages": e.inputProps.errorMessages,
|
|
25
25
|
error: e.inputProps.error,
|
|
26
26
|
ripple: ""
|
|
27
|
-
},
|
|
28
|
-
"model-value": e.
|
|
29
|
-
onChange:
|
|
27
|
+
}, r.$attrs, {
|
|
28
|
+
"model-value": e.field.state.value,
|
|
29
|
+
onChange: l[0] || (l[0] = (t) => e.field.handleChange(t.target.checked))
|
|
30
30
|
}), null, 16, ["id", "name", "label", "error-messages", "error", "model-value"])) : i("", !0),
|
|
31
|
-
e.inputProps.type === "email" || e.inputProps.type === "string" || e.inputProps.type === "password" ? (
|
|
31
|
+
e.inputProps.type === "email" || e.inputProps.type === "string" || e.inputProps.type === "password" ? (n(), a(s, u({
|
|
32
32
|
key: 1,
|
|
33
33
|
id: e.inputProps.id,
|
|
34
34
|
required: e.inputProps.required,
|
|
35
35
|
"min-length": e.inputProps.minLength,
|
|
36
36
|
"max-length": e.inputProps.maxLength,
|
|
37
|
-
type:
|
|
38
|
-
name: e.
|
|
37
|
+
type: b(q)(e.inputProps.type),
|
|
38
|
+
name: e.field.name,
|
|
39
39
|
label: e.inputProps.label,
|
|
40
40
|
"error-messages": e.inputProps.errorMessages,
|
|
41
41
|
error: e.inputProps.error
|
|
42
|
-
},
|
|
43
|
-
"model-value": e.
|
|
44
|
-
"onUpdate:modelValue": e.
|
|
42
|
+
}, r.$attrs, {
|
|
43
|
+
"model-value": e.field.state.value,
|
|
44
|
+
"onUpdate:modelValue": e.field.handleChange
|
|
45
45
|
}), null, 16, ["id", "required", "min-length", "max-length", "type", "name", "label", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : i("", !0),
|
|
46
|
-
e.inputProps.type === "text" ? (
|
|
46
|
+
e.inputProps.type === "text" ? (n(), a(P, u({
|
|
47
47
|
key: 2,
|
|
48
48
|
id: e.inputProps.id,
|
|
49
49
|
required: e.inputProps.required,
|
|
50
50
|
"min-length": e.inputProps.minLength,
|
|
51
51
|
"max-length": e.inputProps.maxLength,
|
|
52
|
-
name: e.
|
|
52
|
+
name: e.field.name,
|
|
53
53
|
label: e.inputProps.label,
|
|
54
54
|
"error-messages": e.inputProps.errorMessages,
|
|
55
55
|
error: e.inputProps.error
|
|
56
|
-
},
|
|
57
|
-
"model-value": e.
|
|
58
|
-
"onUpdate:modelValue": e.
|
|
56
|
+
}, r.$attrs, {
|
|
57
|
+
"model-value": e.field.state.value,
|
|
58
|
+
"onUpdate:modelValue": e.field.handleChange
|
|
59
59
|
}), null, 16, ["id", "required", "min-length", "max-length", "name", "label", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : i("", !0),
|
|
60
|
-
e.inputProps.type === "number" || e.inputProps.type === "range" ? (
|
|
60
|
+
e.inputProps.type === "number" || e.inputProps.type === "range" ? (n(), a(d(e.inputProps.type === "range" ? "v-slider" : "v-text-field"), u({
|
|
61
61
|
key: 3,
|
|
62
62
|
id: e.inputProps.id,
|
|
63
63
|
required: e.inputProps.required,
|
|
64
64
|
min: e.inputProps.min,
|
|
65
65
|
max: e.inputProps.max,
|
|
66
66
|
type: e.inputProps.type,
|
|
67
|
-
name: e.
|
|
67
|
+
name: e.field.name,
|
|
68
68
|
label: e.inputProps.label,
|
|
69
69
|
"error-messages": e.inputProps.errorMessages,
|
|
70
70
|
error: e.inputProps.error
|
|
71
|
-
},
|
|
72
|
-
"model-value": e.
|
|
73
|
-
"onUpdate:modelValue":
|
|
74
|
-
t || t === 0 ? e.
|
|
71
|
+
}, r.$attrs, {
|
|
72
|
+
"model-value": e.field.state.value,
|
|
73
|
+
"onUpdate:modelValue": l[1] || (l[1] = (t) => {
|
|
74
|
+
t || t === 0 ? e.field.handleChange(Number(t)) : e.field.handleChange(void 0);
|
|
75
75
|
})
|
|
76
76
|
}), null, 16, ["id", "required", "min", "max", "type", "name", "label", "error-messages", "error", "model-value"])) : i("", !0),
|
|
77
|
-
e.inputProps.type === "radio" ? (
|
|
77
|
+
e.inputProps.type === "radio" ? (n(), a(v, u({
|
|
78
78
|
key: 4,
|
|
79
79
|
id: e.inputProps.id,
|
|
80
|
-
name: e.
|
|
80
|
+
name: e.field.name,
|
|
81
81
|
label: e.inputProps.label,
|
|
82
82
|
"error-messages": e.inputProps.errorMessages,
|
|
83
83
|
error: e.inputProps.error
|
|
84
|
-
},
|
|
85
|
-
"model-value": e.
|
|
86
|
-
"onUpdate:modelValue": e.
|
|
84
|
+
}, r.$attrs, {
|
|
85
|
+
"model-value": e.field.state.value,
|
|
86
|
+
"onUpdate:modelValue": e.field.handleChange
|
|
87
87
|
}), {
|
|
88
|
-
default:
|
|
89
|
-
(
|
|
88
|
+
default: h(() => [
|
|
89
|
+
(n(!0), m(c, null, C(e.inputProps.options, (t) => (n(), a(g, {
|
|
90
90
|
key: t.value,
|
|
91
91
|
label: t.title,
|
|
92
92
|
value: t.value
|
|
@@ -94,39 +94,39 @@ const U = /* @__PURE__ */ b({
|
|
|
94
94
|
]),
|
|
95
95
|
_: 1
|
|
96
96
|
}, 16, ["id", "name", "label", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : i("", !0),
|
|
97
|
-
e.inputProps.type === "select" || e.inputProps.type === "multiple" ? (
|
|
97
|
+
e.inputProps.type === "select" || e.inputProps.type === "multiple" ? (n(), a(p, u({
|
|
98
98
|
key: 5,
|
|
99
99
|
id: e.inputProps.id,
|
|
100
100
|
clearable: e.inputProps.type === "select",
|
|
101
101
|
required: e.inputProps.required,
|
|
102
102
|
multiple: e.inputProps.type === "multiple",
|
|
103
103
|
chips: e.inputProps.type === "multiple",
|
|
104
|
-
name: e.
|
|
104
|
+
name: e.field.name,
|
|
105
105
|
label: e.inputProps.label,
|
|
106
106
|
items: e.inputProps.options,
|
|
107
107
|
"error-messages": e.inputProps.errorMessages,
|
|
108
108
|
error: e.inputProps.error
|
|
109
|
-
},
|
|
110
|
-
"model-value": e.
|
|
111
|
-
onClear:
|
|
112
|
-
"onUpdate:modelValue": e.
|
|
109
|
+
}, r.$attrs, {
|
|
110
|
+
"model-value": e.field.state.value,
|
|
111
|
+
onClear: l[2] || (l[2] = (t) => e.field.handleChange(void 0)),
|
|
112
|
+
"onUpdate:modelValue": e.field.handleChange
|
|
113
113
|
}), null, 16, ["id", "clearable", "required", "multiple", "chips", "name", "label", "items", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : i("", !0),
|
|
114
|
-
e.inputProps.type === "autocomplete" || e.inputProps.type === "autocompletemultiple" ? (
|
|
114
|
+
e.inputProps.type === "autocomplete" || e.inputProps.type === "autocompletemultiple" ? (n(), a(f, u({
|
|
115
115
|
key: 6,
|
|
116
116
|
id: e.inputProps.id,
|
|
117
117
|
clearable: e.inputProps.type === "autocomplete",
|
|
118
118
|
multiple: e.inputProps.type === "autocompletemultiple",
|
|
119
119
|
required: e.inputProps.required,
|
|
120
|
-
name: e.
|
|
120
|
+
name: e.field.name,
|
|
121
121
|
label: e.inputProps.label,
|
|
122
122
|
items: e.inputProps.options,
|
|
123
123
|
"error-messages": e.inputProps.errorMessages,
|
|
124
124
|
error: e.inputProps.error,
|
|
125
125
|
chips: e.inputProps.type === "autocompletemultiple"
|
|
126
|
-
},
|
|
127
|
-
"model-value": e.
|
|
128
|
-
onClear:
|
|
129
|
-
"onUpdate:modelValue": e.
|
|
126
|
+
}, r.$attrs, {
|
|
127
|
+
"model-value": e.field.state.value,
|
|
128
|
+
onClear: l[3] || (l[3] = (t) => e.field.handleChange(void 0)),
|
|
129
|
+
"onUpdate:modelValue": e.field.handleChange
|
|
130
130
|
}), null, 16, ["id", "clearable", "multiple", "required", "name", "label", "items", "error-messages", "error", "chips", "model-value", "onUpdate:modelValue"])) : i("", !0)
|
|
131
131
|
], 32);
|
|
132
132
|
};
|
|
@@ -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 $, 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.es23.js";
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const Y = /* @__PURE__ */ $({
|
|
7
7
|
inheritAttrs: !1,
|
|
8
8
|
__name: "OmegaInternalInput",
|
|
9
9
|
props: {
|
|
@@ -14,79 +14,80 @@ const J = /* @__PURE__ */ N({
|
|
|
14
14
|
type: {},
|
|
15
15
|
validators: {}
|
|
16
16
|
},
|
|
17
|
-
setup(
|
|
18
|
-
const e =
|
|
17
|
+
setup(v) {
|
|
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(
|
|
19
19
|
() => (
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
-
|
|
21
|
+
d.value.map((t) => t?.message).filter(Boolean)
|
|
22
22
|
)
|
|
23
|
-
),
|
|
24
|
-
|
|
23
|
+
), C = (t) => t == null || t === !1 || t === "" || Number.isNaN(t), x = (t) => {
|
|
24
|
+
C(t) && e.meta?.type !== "boolean" ? e.field.handleChange(
|
|
25
25
|
e.meta?.nullableOrUndefined === "undefined" ? void 0 : null
|
|
26
26
|
) : e.field.handleChange(t);
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
if (!
|
|
30
|
-
const t =
|
|
31
|
-
|
|
28
|
+
g(() => {
|
|
29
|
+
if (!p.value && !e.meta?.required && e.meta?.nullableOrUndefined === "null") {
|
|
30
|
+
const t = o.value.meta.isDirty;
|
|
31
|
+
l.setValue(null), l.setMeta((r) => ({ ...r, isDirty: t }));
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
const { mapError:
|
|
35
|
-
|
|
36
|
-
(
|
|
34
|
+
const { mapError: w, removeError: f, showErrors: _, showErrorsOn: E } = e.field.form.errorContext, s = V(!1);
|
|
35
|
+
k(() => {
|
|
36
|
+
(_.value || E === "onChange") && (s.value = !0);
|
|
37
37
|
});
|
|
38
38
|
const i = () => {
|
|
39
39
|
s.value = !0;
|
|
40
40
|
};
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
g(() => {
|
|
42
|
+
p.value && i();
|
|
43
43
|
});
|
|
44
|
-
const c =
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const c = n(() => !s.value && m.value !== "select" ? [] : b.value);
|
|
45
|
+
q(
|
|
46
|
+
d,
|
|
47
47
|
(t) => {
|
|
48
|
-
t.length ?
|
|
48
|
+
t.length ? w({
|
|
49
49
|
inputId: a,
|
|
50
|
-
errors:
|
|
50
|
+
errors: o.value.meta.errors.map((r) => r.message).filter(Boolean),
|
|
51
51
|
label: e.label
|
|
52
|
-
}) :
|
|
52
|
+
}) : f(a);
|
|
53
53
|
}
|
|
54
|
-
),
|
|
55
|
-
|
|
54
|
+
), D(() => {
|
|
55
|
+
f(a);
|
|
56
56
|
});
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
57
|
+
const P = (t) => {
|
|
58
|
+
const r = {
|
|
59
|
+
get(H, N, J) {
|
|
60
|
+
return N === "handleChange" ? x : Reflect.get(...arguments);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return new Proxy(t, r);
|
|
64
|
+
}, u = n(() => ({
|
|
65
|
+
inputProps: {
|
|
66
|
+
id: a,
|
|
67
|
+
required: e.meta?.required,
|
|
68
|
+
minLength: e.meta?.type === "string" && e.meta?.minLength,
|
|
69
|
+
maxLength: e.meta?.type === "string" && e.meta?.maxLength,
|
|
70
|
+
max: e.meta?.type === "number" && e.meta?.maximum,
|
|
71
|
+
min: e.meta?.type === "number" && e.meta?.minimum,
|
|
72
|
+
errorMessages: c.value,
|
|
73
|
+
error: !!c.value.length,
|
|
74
|
+
setRealDirty: i,
|
|
75
|
+
type: m.value,
|
|
76
|
+
label: `${e.label}${e.meta?.required ? " *" : ""}`,
|
|
77
|
+
options: e.options
|
|
78
|
+
},
|
|
79
|
+
field: P(e.field)
|
|
74
80
|
}));
|
|
75
|
-
return (t,
|
|
81
|
+
return (t, r) => F(t.$slots, "default", h(L({ ...u.value.inputProps, field: u.value.field })), () => [
|
|
76
82
|
O("div", {
|
|
77
|
-
class:
|
|
83
|
+
class: M(t.$attrs.class),
|
|
78
84
|
onFocusout: i
|
|
79
85
|
}, [
|
|
80
|
-
|
|
81
|
-
key: 0,
|
|
82
|
-
"input-props": u.value
|
|
83
|
-
}, t.$attrs, {
|
|
84
|
-
"vuetify-value": u.value.field.state.value
|
|
85
|
-
}), null, 16, ["input-props", "vuetify-value"])) : M("", !0)
|
|
86
|
+
U(y) ? (z(), R(Z, h(A({ key: 0 }, { ...u.value, ...t.$attrs })), 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
|
@@ -28,20 +28,23 @@ export type OmegaFieldInternalApi<From extends Record<PropertyKey, any>, TName e
|
|
|
28
28
|
>
|
|
29
29
|
|
|
30
30
|
export type InputProps<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
inputProps: {
|
|
32
|
+
id: string
|
|
33
|
+
required?: boolean
|
|
34
|
+
minLength?: number | false
|
|
35
|
+
maxLength?: number | false
|
|
36
|
+
max?: number | false
|
|
37
|
+
min?: number | false
|
|
38
|
+
errorMessages: string[]
|
|
39
|
+
error: boolean
|
|
40
|
+
setRealDirty: () => void
|
|
41
|
+
type: string
|
|
42
|
+
label: string
|
|
43
|
+
options?: { title: string; value: string }[]
|
|
44
|
+
}
|
|
42
45
|
field: OmegaFieldInternalApi<From, TName>
|
|
43
|
-
setRealDirty: () => void
|
|
44
|
-
type: string
|
|
45
|
-
label: string
|
|
46
|
-
options?: { title: string; value: string }[]
|
|
47
46
|
}
|
|
47
|
+
|
|
48
|
+
export type MergedInputProps<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> =
|
|
49
|
+
& InputProps<From, TName>["inputProps"]
|
|
50
|
+
& Pick<InputProps<From, TName>, "field">
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
>
|
|
26
26
|
import { type DeepKeys } from "@tanstack/vue-form"
|
|
27
27
|
import { inject } from "vue"
|
|
28
|
-
import type {
|
|
28
|
+
import type { MergedInputProps } from "./InputProps"
|
|
29
29
|
import type { DefaultInputProps, OmegaInputProps } from "./OmegaFormStuff"
|
|
30
30
|
import OmegaInput from "./OmegaInput.vue"
|
|
31
31
|
import { OmegaFormKey } from "./useOmegaForm"
|
|
@@ -46,6 +46,6 @@ defineProps<
|
|
|
46
46
|
>()
|
|
47
47
|
|
|
48
48
|
defineSlots<{
|
|
49
|
-
default(props:
|
|
49
|
+
default(props: MergedInputProps<From, Name>): void
|
|
50
50
|
}>()
|
|
51
51
|
</script>
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
:is="inputProps.type === 'boolean' ? 'v-checkbox' : 'v-switch'"
|
|
9
9
|
v-if="inputProps.type === 'boolean' || inputProps.type === 'switch'"
|
|
10
10
|
:id="inputProps.id"
|
|
11
|
-
:name="
|
|
11
|
+
:name="field.name"
|
|
12
12
|
:label="inputProps.label"
|
|
13
13
|
:error-messages="inputProps.errorMessages"
|
|
14
14
|
:error="inputProps.error"
|
|
15
15
|
ripple
|
|
16
16
|
v-bind="$attrs"
|
|
17
|
-
:model-value="
|
|
18
|
-
@change="(e: any) =>
|
|
17
|
+
:model-value="field.state.value"
|
|
18
|
+
@change="(e: any) => field.handleChange(e.target.checked)"
|
|
19
19
|
/>
|
|
20
20
|
<v-text-field
|
|
21
21
|
v-if="inputProps.type === 'email' || inputProps.type === 'string' || inputProps.type === 'password'"
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
:min-length="inputProps.minLength"
|
|
25
25
|
:max-length="inputProps.maxLength"
|
|
26
26
|
:type="getInputType(inputProps.type)"
|
|
27
|
-
:name="
|
|
27
|
+
:name="field.name"
|
|
28
28
|
:label="inputProps.label"
|
|
29
29
|
:error-messages="inputProps.errorMessages"
|
|
30
30
|
:error="inputProps.error"
|
|
31
31
|
v-bind="$attrs"
|
|
32
|
-
:model-value="
|
|
33
|
-
@update:model-value="
|
|
32
|
+
:model-value="field.state.value"
|
|
33
|
+
@update:model-value="field.handleChange"
|
|
34
34
|
/>
|
|
35
35
|
<v-textarea
|
|
36
36
|
v-if="inputProps.type === 'text'"
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
:required="inputProps.required"
|
|
39
39
|
:min-length="inputProps.minLength"
|
|
40
40
|
:max-length="inputProps.maxLength"
|
|
41
|
-
:name="
|
|
41
|
+
:name="field.name"
|
|
42
42
|
:label="inputProps.label"
|
|
43
43
|
:error-messages="inputProps.errorMessages"
|
|
44
44
|
:error="inputProps.error"
|
|
45
45
|
v-bind="$attrs"
|
|
46
|
-
:model-value="
|
|
47
|
-
@update:model-value="
|
|
46
|
+
:model-value="field.state.value"
|
|
47
|
+
@update:model-value="field.handleChange"
|
|
48
48
|
/>
|
|
49
49
|
<component
|
|
50
50
|
:is="inputProps.type === 'range' ? 'v-slider' : 'v-text-field'"
|
|
@@ -54,30 +54,30 @@
|
|
|
54
54
|
:min="inputProps.min"
|
|
55
55
|
:max="inputProps.max"
|
|
56
56
|
:type="inputProps.type"
|
|
57
|
-
:name="
|
|
57
|
+
:name="field.name"
|
|
58
58
|
:label="inputProps.label"
|
|
59
59
|
:error-messages="inputProps.errorMessages"
|
|
60
60
|
:error="inputProps.error"
|
|
61
61
|
v-bind="$attrs"
|
|
62
|
-
:model-value="
|
|
62
|
+
:model-value="field.state.value"
|
|
63
63
|
@update:model-value="(e: any) => {
|
|
64
64
|
if (e || e === 0) {
|
|
65
|
-
|
|
65
|
+
field.handleChange(Number(e) as any)
|
|
66
66
|
} else {
|
|
67
|
-
|
|
67
|
+
field.handleChange(undefined as any)
|
|
68
68
|
}
|
|
69
69
|
}"
|
|
70
70
|
/>
|
|
71
71
|
<template v-if="inputProps.type === 'radio'">
|
|
72
72
|
<v-radio-group
|
|
73
73
|
:id="inputProps.id"
|
|
74
|
-
:name="
|
|
74
|
+
:name="field.name"
|
|
75
75
|
:label="inputProps.label"
|
|
76
76
|
:error-messages="inputProps.errorMessages"
|
|
77
77
|
:error="inputProps.error"
|
|
78
78
|
v-bind="$attrs"
|
|
79
|
-
:model-value="
|
|
80
|
-
@update:model-value="
|
|
79
|
+
:model-value="field.state.value"
|
|
80
|
+
@update:model-value="field.handleChange"
|
|
81
81
|
>
|
|
82
82
|
<v-radio
|
|
83
83
|
v-for="option in inputProps.options"
|
|
@@ -94,15 +94,15 @@
|
|
|
94
94
|
:required="inputProps.required"
|
|
95
95
|
:multiple="inputProps.type === 'multiple'"
|
|
96
96
|
:chips="inputProps.type === 'multiple'"
|
|
97
|
-
:name="
|
|
97
|
+
:name="field.name"
|
|
98
98
|
:label="inputProps.label"
|
|
99
99
|
:items="inputProps.options"
|
|
100
100
|
:error-messages="inputProps.errorMessages"
|
|
101
101
|
:error="inputProps.error"
|
|
102
102
|
v-bind="$attrs"
|
|
103
|
-
:model-value="
|
|
104
|
-
@clear="
|
|
105
|
-
@update:model-value="
|
|
103
|
+
:model-value="field.state.value"
|
|
104
|
+
@clear="field.handleChange(undefined as any)"
|
|
105
|
+
@update:model-value="field.handleChange"
|
|
106
106
|
/>
|
|
107
107
|
|
|
108
108
|
<v-autocomplete
|
|
@@ -112,16 +112,16 @@
|
|
|
112
112
|
:clearable="inputProps.type === 'autocomplete'"
|
|
113
113
|
:multiple="inputProps.type === 'autocompletemultiple'"
|
|
114
114
|
:required="inputProps.required"
|
|
115
|
-
:name="
|
|
115
|
+
:name="field.name"
|
|
116
116
|
:label="inputProps.label"
|
|
117
117
|
:items="inputProps.options"
|
|
118
118
|
:error-messages="inputProps.errorMessages"
|
|
119
119
|
:error="inputProps.error"
|
|
120
120
|
:chips="inputProps.type === 'autocompletemultiple'"
|
|
121
121
|
v-bind="$attrs"
|
|
122
|
-
:model-value="
|
|
123
|
-
@clear="
|
|
124
|
-
@update:model-value="
|
|
122
|
+
:model-value="field.state.value"
|
|
123
|
+
@clear="field.handleChange(undefined as any)"
|
|
124
|
+
@update:model-value="field.handleChange"
|
|
125
125
|
/>
|
|
126
126
|
</div>
|
|
127
127
|
</template>
|
|
@@ -135,10 +135,7 @@ import { type DeepKeys } from "@tanstack/vue-form"
|
|
|
135
135
|
import { getInputType } from "../OmegaForm/OmegaFormStuff"
|
|
136
136
|
import type { InputProps } from "./InputProps"
|
|
137
137
|
|
|
138
|
-
defineProps<
|
|
139
|
-
inputProps: InputProps<From, Name>
|
|
140
|
-
vuetifyValue: unknown
|
|
141
|
-
}>()
|
|
138
|
+
defineProps<InputProps<From, Name>>()
|
|
142
139
|
|
|
143
140
|
defineEmits<{
|
|
144
141
|
(e: "focus", event: Event): void
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<slot v-bind="inputProps">
|
|
2
|
+
<slot v-bind="{ ...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
|
-
|
|
10
|
-
v-bind="$attrs"
|
|
11
|
-
:vuetify-value="inputProps.field.state.value"
|
|
9
|
+
v-bind="{ ...inputProps, ...$attrs }"
|
|
12
10
|
/>
|
|
13
11
|
</div>
|
|
14
12
|
</slot>
|
|
@@ -69,7 +67,6 @@ const isFalsyButNotZero = (value: unknown): boolean => {
|
|
|
69
67
|
}
|
|
70
68
|
|
|
71
69
|
// we remove value and errors when the field is empty and not required
|
|
72
|
-
|
|
73
70
|
// convert nullish value to null or undefined based on schema
|
|
74
71
|
const handleChange: OmegaFieldInternalApi<From, Name>["handleChange"] = (value) => {
|
|
75
72
|
if (isFalsyButNotZero(value) && props.meta?.type !== "boolean") {
|
|
@@ -149,22 +146,36 @@ onUnmounted(() => {
|
|
|
149
146
|
removeError(id)
|
|
150
147
|
})
|
|
151
148
|
|
|
149
|
+
const wrapField = (field: OmegaFieldInternalApi<From, Name>) => {
|
|
150
|
+
const handler3 = {
|
|
151
|
+
get(_target: any, prop: PropertyKey, _receiver: any) {
|
|
152
|
+
if (prop === "handleChange") {
|
|
153
|
+
return handleChange
|
|
154
|
+
}
|
|
155
|
+
return Reflect.get(...arguments as unknown as [any, any, any])
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const proxy3 = new Proxy(field, handler3)
|
|
160
|
+
return proxy3 as typeof field
|
|
161
|
+
}
|
|
162
|
+
|
|
152
163
|
const inputProps: ComputedRef<InputProps<From, Name>> = computed(() => ({
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
inputProps: {
|
|
165
|
+
id,
|
|
166
|
+
required: props.meta?.required,
|
|
167
|
+
minLength: props.meta?.type === "string" && props.meta?.minLength,
|
|
168
|
+
maxLength: props.meta?.type === "string" && props.meta?.maxLength,
|
|
169
|
+
max: props.meta?.type === "number" && props.meta?.maximum,
|
|
170
|
+
min: props.meta?.type === "number" && props.meta?.minimum,
|
|
171
|
+
errorMessages: showedErrors.value,
|
|
172
|
+
error: !!showedErrors.value.length,
|
|
173
|
+
setRealDirty,
|
|
174
|
+
type: fieldType.value,
|
|
175
|
+
label: `${props.label}${props.meta?.required ? " *" : ""}`,
|
|
176
|
+
options: props.options
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
field: wrapField(props.field)
|
|
169
180
|
}))
|
|
170
181
|
</script>
|
|
@@ -28,8 +28,7 @@ export const createUseFormWithCustomInput = (CustomInputComponent: Component) =>
|
|
|
28
28
|
// If we receive inputProps from OmegaInternalInput, use our custom component
|
|
29
29
|
if (inputProps && "field" in inputProps) {
|
|
30
30
|
return h(CustomInputComponent, {
|
|
31
|
-
inputProps
|
|
32
|
-
vuetifyValue: inputProps.field.state.value
|
|
31
|
+
inputProps
|
|
33
32
|
})
|
|
34
33
|
}
|
|
35
34
|
// Otherwise, pass through the slot content
|
|
@@ -8,7 +8,7 @@ import { runtimeFiberAsPromise } from "effect-app/utils"
|
|
|
8
8
|
import { isObject } from "effect/Predicate"
|
|
9
9
|
import { Component, computed, ConcreteComponent, h, type InjectionKey, onBeforeUnmount, onMounted, onUnmounted, watch } from "vue"
|
|
10
10
|
import { usePreventClose } from "./blockDialog"
|
|
11
|
-
import {
|
|
11
|
+
import { MergedInputProps } from "./InputProps"
|
|
12
12
|
import OmegaArray from "./OmegaArray.vue"
|
|
13
13
|
import OmegaAutoGen from "./OmegaAutoGen.vue"
|
|
14
14
|
import { buildOmegaErrors } from "./OmegaErrorsContext"
|
|
@@ -161,7 +161,7 @@ export interface OmegaFormReturn<
|
|
|
161
161
|
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void
|
|
162
162
|
attrs: any
|
|
163
163
|
slots: {
|
|
164
|
-
default(props:
|
|
164
|
+
default(props: MergedInputProps<From, Name>): void
|
|
165
165
|
}
|
|
166
166
|
emit: {}
|
|
167
167
|
}>
|