@effect-app/vue-components 1.8.3 → 1.8.4
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 +0 -1
- package/dist/types/components/OmegaForm/OmegaErrorsInternal.vue.d.ts +0 -1
- package/dist/types/components/OmegaForm/OmegaInput.vue.d.ts +0 -1
- package/dist/types/components/OmegaForm/OmegaInternalInput.vue.d.ts +6 -1
- package/dist/types/components/OmegaForm/index.d.ts +0 -1
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +6 -1
- package/dist/types/components/OmegaForm/useRegisterField.d.ts +7 -0
- package/dist/vue-components.es.js +24 -26
- package/dist/vue-components.es10.js +23 -352
- package/dist/vue-components.es11.js +2 -27
- package/dist/vue-components.es12.js +10 -2
- package/dist/vue-components.es13.js +5 -10
- package/dist/vue-components.es14.js +54 -5
- package/dist/vue-components.es15.js +63 -49
- package/dist/vue-components.es16.js +6 -68
- package/dist/vue-components.es17.js +5 -5
- package/dist/vue-components.es18.js +3 -6
- package/dist/vue-components.es19.js +3 -3
- package/dist/vue-components.es2.js +19 -21
- package/dist/vue-components.es20.js +2 -3
- package/dist/vue-components.es21.js +1 -1
- package/dist/vue-components.es22.js +17 -2
- package/dist/vue-components.es23.js +10 -16
- package/dist/vue-components.es24.js +135 -11
- package/dist/vue-components.es26.js +44 -0
- package/dist/vue-components.es27.js +2 -42
- package/dist/vue-components.es29.js +89 -2
- package/dist/vue-components.es31.js +9 -0
- package/dist/vue-components.es32.js +31 -7
- package/dist/vue-components.es34.js +6 -0
- package/dist/vue-components.es35.js +23 -4
- package/dist/vue-components.es36.js +5 -23
- package/dist/vue-components.es37.js +21 -5
- package/dist/vue-components.es38.js +25 -16
- package/dist/vue-components.es39.js +15 -23
- package/dist/vue-components.es4.js +2 -2
- package/dist/vue-components.es40.js +7 -17
- package/dist/vue-components.es41.js +5 -12
- package/dist/vue-components.es42.js +19 -5
- package/dist/vue-components.es43.js +9 -19
- package/dist/vue-components.es44.js +31 -9
- package/dist/vue-components.es45.js +42 -25
- package/dist/vue-components.es46.js +16 -38
- package/dist/vue-components.es47.js +11 -26
- package/dist/vue-components.es48.js +65 -11
- package/dist/vue-components.es49.js +45 -54
- package/dist/vue-components.es5.js +10 -9
- package/dist/vue-components.es50.js +15 -54
- package/dist/vue-components.es51.js +31 -15
- package/dist/vue-components.es52.js +26 -30
- package/dist/vue-components.es53.js +42 -29
- package/dist/vue-components.es54.js +2 -42
- package/dist/vue-components.es55.js +44 -2
- package/dist/vue-components.es56.js +2 -44
- package/dist/vue-components.es6.js +33 -55
- package/dist/vue-components.es7.js +219 -27
- package/dist/vue-components.es8.js +28 -211
- package/dist/vue-components.es9.js +355 -29
- package/package.json +1 -1
- package/src/components/OmegaForm/InputProps.ts +0 -1
- package/src/components/OmegaForm/OmegaErrorsInternal.vue +1 -2
- package/src/components/OmegaForm/OmegaInput.vue +1 -0
- package/src/components/OmegaForm/OmegaInternalInput.vue +13 -52
- package/src/components/OmegaForm/index.ts +0 -1
- package/src/components/OmegaForm/useOmegaForm.ts +42 -13
- package/src/components/OmegaForm/useRegisterField.ts +15 -0
- package/dist/types/components/OmegaForm/OmegaErrorsContext.d.ts +0 -38
- package/dist/vue-components.es25.js +0 -137
- package/dist/vue-components.es30.js +0 -92
- package/dist/vue-components.es33.js +0 -33
- package/dist/vue-components.es57.js +0 -4
- package/src/components/OmegaForm/OmegaErrorsContext.ts +0 -67
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<slot v-bind="{ ...$attrs, ...inputProps.inputProps, field: inputProps.field }">
|
|
3
|
-
<div
|
|
4
|
-
:class="$attrs.class"
|
|
5
|
-
@focusout="setRealDirty"
|
|
6
|
-
>
|
|
3
|
+
<div :class="$attrs.class">
|
|
7
4
|
<OmegaInputVuetify
|
|
8
5
|
v-if="vuetified"
|
|
9
6
|
v-bind="{ ...$attrs, ...inputProps }"
|
|
@@ -18,7 +15,7 @@
|
|
|
18
15
|
generic="From extends Record<PropertyKey, any>, Name extends DeepKeys<From>"
|
|
19
16
|
>
|
|
20
17
|
import { type DeepKeys, useStore } from "@tanstack/vue-form"
|
|
21
|
-
import { computed, type ComputedRef, getCurrentInstance, onMounted,
|
|
18
|
+
import { computed, type ComputedRef, getCurrentInstance, onMounted, useId } from "vue"
|
|
22
19
|
import type { InputProps, OmegaFieldInternalApi } from "./InputProps"
|
|
23
20
|
import type { FieldValidators, MetaRecord, NestedKeyOf, TypeOverride } from "./OmegaFormStuff"
|
|
24
21
|
import OmegaInputVuetify from "./OmegaInputVuetify.vue"
|
|
@@ -34,6 +31,14 @@ const props = defineProps<{
|
|
|
34
31
|
type?: TypeOverride
|
|
35
32
|
validators?: FieldValidators<From>
|
|
36
33
|
|
|
34
|
+
register: (
|
|
35
|
+
field: ComputedRef<{
|
|
36
|
+
name: string
|
|
37
|
+
label: string
|
|
38
|
+
id: string
|
|
39
|
+
}>
|
|
40
|
+
) => void
|
|
41
|
+
|
|
37
42
|
// TODO: these should really be optional, depending on the input type (and the custom input type for custom inputs :s)
|
|
38
43
|
options?: { title: string; value: string }[]
|
|
39
44
|
}>()
|
|
@@ -56,6 +61,8 @@ const fieldType = computed(() => {
|
|
|
56
61
|
return props.meta?.type || "unknown"
|
|
57
62
|
})
|
|
58
63
|
|
|
64
|
+
props.register(computed(() => ({ name: props.field.name, label: props.label, id })))
|
|
65
|
+
|
|
59
66
|
const fieldValue = computed(() => fieldState.value.value)
|
|
60
67
|
// workaround strange tanstack form issue where the errors key becomes undefined ???
|
|
61
68
|
const _errors = computed(() => fieldState.value.meta.errors ?? [])
|
|
@@ -97,57 +104,12 @@ onMounted(() => {
|
|
|
97
104
|
}
|
|
98
105
|
})
|
|
99
106
|
|
|
100
|
-
const { mapError, removeError, showErrors, showErrorsOn } = (props.field.form as any).errorContext // todo; update types to include extended Omega Form props
|
|
101
|
-
|
|
102
|
-
const realDirty = ref(false)
|
|
103
|
-
|
|
104
|
-
watchEffect(() => {
|
|
105
|
-
if (showErrors.value || showErrorsOn === "onChange") {
|
|
106
|
-
realDirty.value = true
|
|
107
|
-
}
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
const setRealDirty = () => {
|
|
111
|
-
realDirty.value = true
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
onMounted(() => {
|
|
115
|
-
if (fieldValue.value) {
|
|
116
|
-
setRealDirty()
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
|
|
120
107
|
const showedErrors = computed(() => {
|
|
121
108
|
// single select field can be validated on change
|
|
122
|
-
if (!
|
|
109
|
+
if (!fieldState.value.meta.isDirty && fieldType.value !== "select") return []
|
|
123
110
|
return errors.value
|
|
124
111
|
})
|
|
125
112
|
|
|
126
|
-
watch(
|
|
127
|
-
_errors,
|
|
128
|
-
(errors) => {
|
|
129
|
-
if (errors.length) {
|
|
130
|
-
mapError({
|
|
131
|
-
inputId: id,
|
|
132
|
-
errors: fieldState
|
|
133
|
-
.value
|
|
134
|
-
.meta
|
|
135
|
-
.errors
|
|
136
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
|
-
.map((e: any) => e.message)
|
|
138
|
-
.filter(Boolean),
|
|
139
|
-
label: props.label
|
|
140
|
-
})
|
|
141
|
-
} else {
|
|
142
|
-
removeError(id)
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
onUnmounted(() => {
|
|
148
|
-
removeError(id)
|
|
149
|
-
})
|
|
150
|
-
|
|
151
113
|
const wrapField = (field: OmegaFieldInternalApi<From, Name>) => {
|
|
152
114
|
const handler3 = {
|
|
153
115
|
get(_target: any, prop: PropertyKey, _receiver: any) {
|
|
@@ -172,7 +134,6 @@ const inputProps: ComputedRef<InputProps<From, Name>> = computed(() => ({
|
|
|
172
134
|
min: props.meta?.type === "number" && props.meta?.minimum,
|
|
173
135
|
errorMessages: showedErrors.value,
|
|
174
136
|
error: !!showedErrors.value.length,
|
|
175
|
-
setRealDirty,
|
|
176
137
|
type: fieldType.value,
|
|
177
138
|
label: `${props.label}${props.meta?.required ? " *" : ""}`,
|
|
178
139
|
options: props.options
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
3
|
|
|
4
4
|
import * as api from "@opentelemetry/api"
|
|
5
|
-
import { type DeepKeys, DeepValue, type FormAsyncValidateOrFn, type FormValidateOrFn, type StandardSchemaV1, StandardSchemaV1Issue, useForm,
|
|
6
|
-
import { Data, Effect, Fiber, Option, Order, S } from "effect-app"
|
|
5
|
+
import { type DeepKeys, DeepValue, type FormAsyncValidateOrFn, type FormValidateOrFn, type StandardSchemaV1, StandardSchemaV1Issue, useForm, ValidationError, ValidationErrorMap } from "@tanstack/vue-form"
|
|
6
|
+
import { Array, Data, Effect, Fiber, Option, Order, S } from "effect-app"
|
|
7
7
|
import { runtimeFiberAsPromise } from "effect-app/utils"
|
|
8
8
|
import { isObject } from "effect/Predicate"
|
|
9
|
-
import { Component, computed, ConcreteComponent, h, type InjectionKey, onBeforeUnmount, onMounted, onUnmounted, watch } from "vue"
|
|
9
|
+
import { Component, computed, ComputedRef, ConcreteComponent, h, type InjectionKey, onBeforeUnmount, onMounted, onUnmounted, Ref, watch } from "vue"
|
|
10
10
|
import { usePreventClose } from "./blockDialog"
|
|
11
11
|
import { MergedInputProps } from "./InputProps"
|
|
12
12
|
import OmegaArray from "./OmegaArray.vue"
|
|
13
13
|
import OmegaAutoGen from "./OmegaAutoGen.vue"
|
|
14
|
-
import { buildOmegaErrors } from "./OmegaErrorsContext"
|
|
15
14
|
import OmegaErrorsInternal from "./OmegaErrorsInternal.vue"
|
|
16
15
|
import { BaseProps, DefaultTypeProps, type FilterItems, type FormProps, generateMetaFromSchema, type MetaRecord, type NestedKeyOf, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState, OmegaInputProps, ShowErrorsOn } from "./OmegaFormStuff"
|
|
17
16
|
import OmegaInput from "./OmegaInput.vue"
|
|
@@ -65,7 +64,15 @@ const fHoc = (form: OF<any, any>) => {
|
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
const eHoc = (errorProps:
|
|
67
|
+
const eHoc = (errorProps: {
|
|
68
|
+
generalErrors: Readonly<
|
|
69
|
+
Ref<
|
|
70
|
+
(Record<string, StandardSchemaV1Issue[]> | undefined)[],
|
|
71
|
+
(Record<string, StandardSchemaV1Issue[]> | undefined)[]
|
|
72
|
+
>
|
|
73
|
+
>
|
|
74
|
+
errors: Readonly<Ref<(OmegaError | undefined)[], (OmegaError | undefined)[]>>
|
|
75
|
+
}) => {
|
|
69
76
|
return function FormHoc<P>(
|
|
70
77
|
WrappedComponent: Component<P>
|
|
71
78
|
): ConcreteComponent<P> {
|
|
@@ -111,6 +118,13 @@ export interface OF<From, To> extends OmegaFormApi<From, To> {
|
|
|
111
118
|
filterItems?: FilterItems
|
|
112
119
|
clear: () => void
|
|
113
120
|
i18nNamespace?: string
|
|
121
|
+
registerField: (
|
|
122
|
+
field: ComputedRef<{
|
|
123
|
+
name: string
|
|
124
|
+
label: string
|
|
125
|
+
id: string
|
|
126
|
+
}>
|
|
127
|
+
) => void
|
|
114
128
|
/** @experimental */
|
|
115
129
|
handleSubmitEffect: {
|
|
116
130
|
/**
|
|
@@ -848,6 +862,9 @@ export const useOmegaForm = <
|
|
|
848
862
|
: handleSubmitEffect_(options?.meta)
|
|
849
863
|
|
|
850
864
|
const handleSubmit = form.handleSubmit
|
|
865
|
+
|
|
866
|
+
const fieldMap = new Map<string, { label: string; id: string }>()
|
|
867
|
+
|
|
851
868
|
const formWithExtras: OF<From, To> = Object.assign(form, {
|
|
852
869
|
i18nNamespace: omegaConfig?.i18nNamespace,
|
|
853
870
|
meta,
|
|
@@ -858,15 +875,28 @@ export const useOmegaForm = <
|
|
|
858
875
|
return handleSubmit({ currentSpan: span, ...meta })
|
|
859
876
|
},
|
|
860
877
|
// /** @experimental */
|
|
861
|
-
handleSubmitEffect
|
|
878
|
+
handleSubmitEffect,
|
|
879
|
+
registerField: (field: ComputedRef<{ name: string; label: string; id: string }>) => {
|
|
880
|
+
watch(field, (f) => fieldMap.set(f.name, { label: f.label, id: f.id }), { immediate: true })
|
|
881
|
+
onUnmounted(() => fieldMap.delete(field.value.name)) // todo; perhap only when owned (id match)
|
|
882
|
+
}
|
|
862
883
|
})
|
|
863
884
|
|
|
864
|
-
const formSubmissionAttempts = useStore(
|
|
865
|
-
formWithExtras.store,
|
|
866
|
-
(state) => state.submissionAttempts
|
|
867
|
-
)
|
|
868
|
-
|
|
869
885
|
const errors = formWithExtras.useStore((state) => state.errors)
|
|
886
|
+
const fieldErrors = formWithExtras.useStore((state) =>
|
|
887
|
+
Array.filterMap(
|
|
888
|
+
Object
|
|
889
|
+
.entries(state.fieldMeta),
|
|
890
|
+
([key, m]): Option.Option<OmegaError> =>
|
|
891
|
+
((m as any).errors ?? []).length && fieldMap.get(key)?.id
|
|
892
|
+
? Option.some({
|
|
893
|
+
label: fieldMap.get(key)!.label,
|
|
894
|
+
inputId: fieldMap.get(key)!.id,
|
|
895
|
+
errors: ((m as any).errors ?? []).map((e: any) => e.message).filter(Boolean)
|
|
896
|
+
})
|
|
897
|
+
: Option.none()
|
|
898
|
+
)
|
|
899
|
+
)
|
|
870
900
|
|
|
871
901
|
watch(
|
|
872
902
|
() => [formWithExtras.filterItems, errors.value],
|
|
@@ -907,8 +937,7 @@ export const useOmegaForm = <
|
|
|
907
937
|
}
|
|
908
938
|
)
|
|
909
939
|
|
|
910
|
-
|
|
911
|
-
const errorContext = buildOmegaErrors(formSubmissionAttempts, errors, omegaConfig?.showErrorsOn)
|
|
940
|
+
const errorContext = { generalErrors: errors, errors: fieldErrors }
|
|
912
941
|
|
|
913
942
|
if (!omegaConfig?.ignorePreventCloseEvents) {
|
|
914
943
|
usePreventClose(() => formWithExtras.useStore((state) => state.isDirty))
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { injectCertain } from "@effect-app/vue"
|
|
2
|
+
import { type ComputedRef, type InjectionKey, onUnmounted, provide, watch } from "vue"
|
|
3
|
+
|
|
4
|
+
const Key = Symbol("injected") as InjectionKey<Map<string, { label: string; id: string }>>
|
|
5
|
+
|
|
6
|
+
export const useRegisterField = (field: ComputedRef<{ name: string; label: string; id: string }>) => {
|
|
7
|
+
const map = injectCertain(Key)
|
|
8
|
+
watch(field, (f) => map.set(f.name, { label: f.label, id: f.id }), { immediate: true })
|
|
9
|
+
onUnmounted(() => map.delete(field.value.name)) // todo; perhap only when owned
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const provideRegisterField = () => {
|
|
13
|
+
const map = new Map<string, { label: string; id: string }>()
|
|
14
|
+
provide(Key, map)
|
|
15
|
+
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { StandardSchemaV1Issue } from "@tanstack/vue-form";
|
|
2
|
-
import { type InjectionKey, type Ref } from "vue";
|
|
3
|
-
import { type OmegaError, type ShowErrorsOn } from "./OmegaFormStuff";
|
|
4
|
-
export declare const OmegaErrorsKey: InjectionKey<{
|
|
5
|
-
errors: Ref<readonly OmegaError[]>;
|
|
6
|
-
mapError: (error: OmegaError) => void;
|
|
7
|
-
removeError: (inputId: string) => void;
|
|
8
|
-
clearErrors: () => void;
|
|
9
|
-
showErrors: Ref<boolean>;
|
|
10
|
-
showErrorsOn: ShowErrorsOn;
|
|
11
|
-
generalErrors: Readonly<Ref<(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined>>;
|
|
12
|
-
}>;
|
|
13
|
-
export declare function buildOmegaErrors(formSubmissionAttempts: Ref<number>, generalErrors: Readonly<Ref<(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined>>, showErrorsOn?: ShowErrorsOn): {
|
|
14
|
-
errors: Readonly<Ref<readonly {
|
|
15
|
-
readonly label: string;
|
|
16
|
-
readonly inputId: string;
|
|
17
|
-
readonly errors: readonly string[];
|
|
18
|
-
}[], readonly {
|
|
19
|
-
readonly label: string;
|
|
20
|
-
readonly inputId: string;
|
|
21
|
-
readonly errors: readonly string[];
|
|
22
|
-
}[]>>;
|
|
23
|
-
mapError: (error: OmegaError) => void;
|
|
24
|
-
removeError: (inputId: string) => void;
|
|
25
|
-
clearErrors: () => void;
|
|
26
|
-
showErrors: import("vue").ComputedRef<boolean>;
|
|
27
|
-
generalErrors: Readonly<Ref<(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined, (Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined>>;
|
|
28
|
-
showErrorsOn: ShowErrorsOn;
|
|
29
|
-
};
|
|
30
|
-
export declare function useOmegaErrors(): {
|
|
31
|
-
errors: Ref<readonly OmegaError[]>;
|
|
32
|
-
mapError: (error: OmegaError) => void;
|
|
33
|
-
removeError: (inputId: string) => void;
|
|
34
|
-
clearErrors: () => void;
|
|
35
|
-
showErrors: Ref<boolean>;
|
|
36
|
-
showErrorsOn: ShowErrorsOn;
|
|
37
|
-
generalErrors: Readonly<Ref<(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined>>;
|
|
38
|
-
};
|
|
@@ -1,137 +0,0 @@
|
|
|
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.es10.js";
|
|
3
|
-
const U = /* @__PURE__ */ y({
|
|
4
|
-
inheritAttrs: !1,
|
|
5
|
-
__name: "OmegaInputVuetify",
|
|
6
|
-
props: {
|
|
7
|
-
inputProps: {},
|
|
8
|
-
field: {}
|
|
9
|
-
},
|
|
10
|
-
emits: ["focus", "blur"],
|
|
11
|
-
setup(e) {
|
|
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
|
-
class: "omega-input",
|
|
16
|
-
onFocusout: l[4] || (l[4] = (t) => r.$emit("blur", t)),
|
|
17
|
-
onFocusin: l[5] || (l[5] = (t) => r.$emit("focus", t))
|
|
18
|
-
}, [
|
|
19
|
-
e.inputProps.type === "boolean" || e.inputProps.type === "switch" ? (n(), a(d(e.inputProps.type === "boolean" ? "v-checkbox" : "v-switch"), u({
|
|
20
|
-
key: 0,
|
|
21
|
-
id: e.inputProps.id,
|
|
22
|
-
name: e.field.name,
|
|
23
|
-
label: e.inputProps.label,
|
|
24
|
-
"error-messages": e.inputProps.errorMessages,
|
|
25
|
-
error: e.inputProps.error,
|
|
26
|
-
ripple: ""
|
|
27
|
-
}, r.$attrs, {
|
|
28
|
-
"model-value": e.field.state.value,
|
|
29
|
-
onChange: l[0] || (l[0] = (t) => e.field.handleChange(t.target.checked))
|
|
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" ? (n(), a(s, u({
|
|
32
|
-
key: 1,
|
|
33
|
-
id: e.inputProps.id,
|
|
34
|
-
required: e.inputProps.required,
|
|
35
|
-
"min-length": e.inputProps.minLength,
|
|
36
|
-
"max-length": e.inputProps.maxLength,
|
|
37
|
-
type: b(q)(e.inputProps.type),
|
|
38
|
-
name: e.field.name,
|
|
39
|
-
label: e.inputProps.label,
|
|
40
|
-
"error-messages": e.inputProps.errorMessages,
|
|
41
|
-
error: e.inputProps.error
|
|
42
|
-
}, r.$attrs, {
|
|
43
|
-
"model-value": e.field.state.value,
|
|
44
|
-
"onUpdate:modelValue": e.field.handleChange
|
|
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" ? (n(), a(P, u({
|
|
47
|
-
key: 2,
|
|
48
|
-
id: e.inputProps.id,
|
|
49
|
-
required: e.inputProps.required,
|
|
50
|
-
"min-length": e.inputProps.minLength,
|
|
51
|
-
"max-length": e.inputProps.maxLength,
|
|
52
|
-
name: e.field.name,
|
|
53
|
-
label: e.inputProps.label,
|
|
54
|
-
"error-messages": e.inputProps.errorMessages,
|
|
55
|
-
error: e.inputProps.error
|
|
56
|
-
}, r.$attrs, {
|
|
57
|
-
"model-value": e.field.state.value,
|
|
58
|
-
"onUpdate:modelValue": e.field.handleChange
|
|
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" ? (n(), a(d(e.inputProps.type === "range" ? "v-slider" : "v-text-field"), u({
|
|
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.field.name,
|
|
68
|
-
label: e.inputProps.label,
|
|
69
|
-
"error-messages": e.inputProps.errorMessages,
|
|
70
|
-
error: e.inputProps.error
|
|
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
|
-
})
|
|
76
|
-
}), null, 16, ["id", "required", "min", "max", "type", "name", "label", "error-messages", "error", "model-value"])) : i("", !0),
|
|
77
|
-
e.inputProps.type === "radio" ? (n(), a(v, u({
|
|
78
|
-
key: 4,
|
|
79
|
-
id: e.inputProps.id,
|
|
80
|
-
name: e.field.name,
|
|
81
|
-
label: e.inputProps.label,
|
|
82
|
-
"error-messages": e.inputProps.errorMessages,
|
|
83
|
-
error: e.inputProps.error
|
|
84
|
-
}, r.$attrs, {
|
|
85
|
-
"model-value": e.field.state.value,
|
|
86
|
-
"onUpdate:modelValue": e.field.handleChange
|
|
87
|
-
}), {
|
|
88
|
-
default: h(() => [
|
|
89
|
-
(n(!0), m(c, null, C(e.inputProps.options, (t) => (n(), a(g, {
|
|
90
|
-
key: t.value,
|
|
91
|
-
label: t.title,
|
|
92
|
-
value: t.value
|
|
93
|
-
}, null, 8, ["label", "value"]))), 128))
|
|
94
|
-
]),
|
|
95
|
-
_: 1
|
|
96
|
-
}, 16, ["id", "name", "label", "error-messages", "error", "model-value", "onUpdate:modelValue"])) : i("", !0),
|
|
97
|
-
e.inputProps.type === "select" || e.inputProps.type === "multiple" ? (n(), a(p, u({
|
|
98
|
-
key: 5,
|
|
99
|
-
id: e.inputProps.id,
|
|
100
|
-
clearable: e.inputProps.type === "select",
|
|
101
|
-
required: e.inputProps.required,
|
|
102
|
-
multiple: e.inputProps.type === "multiple",
|
|
103
|
-
chips: e.inputProps.type === "multiple",
|
|
104
|
-
name: e.field.name,
|
|
105
|
-
label: e.inputProps.label,
|
|
106
|
-
items: e.inputProps.options,
|
|
107
|
-
"error-messages": e.inputProps.errorMessages,
|
|
108
|
-
error: e.inputProps.error
|
|
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
|
-
}), 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" ? (n(), a(f, u({
|
|
115
|
-
key: 6,
|
|
116
|
-
id: e.inputProps.id,
|
|
117
|
-
clearable: e.inputProps.type === "autocomplete",
|
|
118
|
-
multiple: e.inputProps.type === "autocompletemultiple",
|
|
119
|
-
required: e.inputProps.required,
|
|
120
|
-
name: e.field.name,
|
|
121
|
-
label: e.inputProps.label,
|
|
122
|
-
items: e.inputProps.options,
|
|
123
|
-
"error-messages": e.inputProps.errorMessages,
|
|
124
|
-
error: e.inputProps.error,
|
|
125
|
-
chips: e.inputProps.type === "autocompletemultiple"
|
|
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
|
-
}), null, 16, ["id", "clearable", "multiple", "required", "name", "label", "items", "error-messages", "error", "chips", "model-value", "onUpdate:modelValue"])) : i("", !0)
|
|
131
|
-
], 32);
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
export {
|
|
136
|
-
U as default
|
|
137
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { defineComponent as _, getCurrentInstance as y, computed as B, createBlock as n, openBlock as e, Transition as C, withCtx as o, createElementBlock as d, createCommentVNode as w, renderSlot as x, normalizeProps as b, guardReactiveProps as I, resolveDynamicComponent as l, unref as a, normalizeClass as V, createElementVNode as c, toDisplayString as u, Fragment as p, renderList as k, createTextVNode as E } from "vue";
|
|
2
|
-
import { mdiLink as N } from "@mdi/js";
|
|
3
|
-
import { useIntl as z } from "./vue-components.es3.js";
|
|
4
|
-
const D = {
|
|
5
|
-
key: 0,
|
|
6
|
-
class: "error-alert"
|
|
7
|
-
}, G = { class: "text-h6 mb-3" }, L = { class: "font-weight-medium" }, M = { class: "error-message" }, O = ["href"], P = { key: 1 }, A = /* @__PURE__ */ _({
|
|
8
|
-
__name: "OmegaErrorsInternal",
|
|
9
|
-
props: {
|
|
10
|
-
errors: {},
|
|
11
|
-
generalErrors: {},
|
|
12
|
-
showErrors: { type: Boolean }
|
|
13
|
-
},
|
|
14
|
-
setup(t) {
|
|
15
|
-
const m = y()?.appContext.components.VAlert, h = t, { trans: g } = z(), f = B(() => h.generalErrors ? h.generalErrors.filter((i) => !!i).flatMap(
|
|
16
|
-
(i) => Object.values(i).filter((s) => !!s).flatMap(
|
|
17
|
-
(s) => s.filter(
|
|
18
|
-
(r) => !!r?.message
|
|
19
|
-
).map((r) => r.message)
|
|
20
|
-
)
|
|
21
|
-
) : []);
|
|
22
|
-
return (i, s) => (e(), n(C, null, {
|
|
23
|
-
default: o(() => [
|
|
24
|
-
t.showErrors && (t.errors.length || f.value.length) ? (e(), d("div", D, [
|
|
25
|
-
x(i.$slots, "default", b(I({ errors: t.errors, showedGeneralErrors: f.value })), () => [
|
|
26
|
-
(e(), n(l(a(m) ? "v-alert" : "div"), {
|
|
27
|
-
class: V([a(m) ? "mb-4" : "error-alert-content", "mb-4"]),
|
|
28
|
-
type: "error",
|
|
29
|
-
variant: "tonal",
|
|
30
|
-
role: "alert",
|
|
31
|
-
"aria-live": "polite"
|
|
32
|
-
}, {
|
|
33
|
-
default: o(() => [
|
|
34
|
-
c("div", G, u(a(g)("form.includes_error")) + ": ", 1),
|
|
35
|
-
t.errors.length ? (e(), n(l(t.errors.length > 1 ? "ul" : "div"), {
|
|
36
|
-
key: 0,
|
|
37
|
-
class: "error-list"
|
|
38
|
-
}, {
|
|
39
|
-
default: o(() => [
|
|
40
|
-
(e(!0), d(p, null, k(t.errors, (r) => (e(), n(l(t.errors.length > 1 ? "li" : "div"), {
|
|
41
|
-
key: r.inputId,
|
|
42
|
-
class: "error-item"
|
|
43
|
-
}, {
|
|
44
|
-
default: o(() => [
|
|
45
|
-
c("div", L, u(r.label), 1),
|
|
46
|
-
c("div", M, [
|
|
47
|
-
(e(), n(l(r.errors.length > 1 ? "ul" : "div"), { class: "error-list" }, {
|
|
48
|
-
default: o(() => [
|
|
49
|
-
(e(!0), d(p, null, k(r.errors, (v) => (e(), n(l(r.errors.length > 1 ? "li" : "span"), { key: v }, {
|
|
50
|
-
default: o(() => [
|
|
51
|
-
E(u(v), 1)
|
|
52
|
-
]),
|
|
53
|
-
_: 2
|
|
54
|
-
}, 1024))), 128))
|
|
55
|
-
]),
|
|
56
|
-
_: 2
|
|
57
|
-
}, 1024))
|
|
58
|
-
]),
|
|
59
|
-
c("a", {
|
|
60
|
-
href: `#${r.inputId}`,
|
|
61
|
-
class: "error-link"
|
|
62
|
-
}, [
|
|
63
|
-
(e(), n(l(a(m) ? "v-icon" : "i"), {
|
|
64
|
-
icon: a(N),
|
|
65
|
-
"aria-hidden": "true"
|
|
66
|
-
}, {
|
|
67
|
-
default: o(() => [...s[0] || (s[0] = [
|
|
68
|
-
c("i", null, "🔗", -1)
|
|
69
|
-
])]),
|
|
70
|
-
_: 1
|
|
71
|
-
}, 8, ["icon"])),
|
|
72
|
-
E(" " + u(a(g)("form.fix_input")), 1)
|
|
73
|
-
], 8, O)
|
|
74
|
-
]),
|
|
75
|
-
_: 2
|
|
76
|
-
}, 1024))), 128))
|
|
77
|
-
]),
|
|
78
|
-
_: 1
|
|
79
|
-
})) : (e(), d("span", P, u(f.value[0]), 1))
|
|
80
|
-
]),
|
|
81
|
-
_: 1
|
|
82
|
-
}, 8, ["class"]))
|
|
83
|
-
], !0)
|
|
84
|
-
])) : w("", !0)
|
|
85
|
-
]),
|
|
86
|
-
_: 3
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
export {
|
|
91
|
-
A as default
|
|
92
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { defineComponent as m, createElementBlock as d, openBlock as a, withModifiers as l, createElementVNode as u, unref as s, renderSlot as b } from "vue";
|
|
2
|
-
import { useStore as f } from "@tanstack/vue-form";
|
|
3
|
-
import { getOmegaStore as c } from "./vue-components.es48.js";
|
|
4
|
-
const p = ["disabled"], V = /* @__PURE__ */ m({
|
|
5
|
-
__name: "OmegaWrapper",
|
|
6
|
-
props: {
|
|
7
|
-
form: {},
|
|
8
|
-
disabled: { type: Boolean },
|
|
9
|
-
subscribe: {}
|
|
10
|
-
},
|
|
11
|
-
setup(e) {
|
|
12
|
-
const t = e, i = f(
|
|
13
|
-
t.form.store,
|
|
14
|
-
(o) => o.isSubmitting
|
|
15
|
-
), n = c(
|
|
16
|
-
t.form,
|
|
17
|
-
t.subscribe
|
|
18
|
-
);
|
|
19
|
-
return (o, r) => (a(), d("form", {
|
|
20
|
-
novalidate: "",
|
|
21
|
-
onSubmit: r[0] || (r[0] = l((S) => e.form.handleSubmit(), ["prevent", "stop"]))
|
|
22
|
-
}, [
|
|
23
|
-
u("fieldset", {
|
|
24
|
-
disabled: s(i) || e.disabled
|
|
25
|
-
}, [
|
|
26
|
-
b(o.$slots, "default", { subscribedValues: s(n) }, void 0, !0)
|
|
27
|
-
], 8, p)
|
|
28
|
-
], 32));
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
export {
|
|
32
|
-
V as default
|
|
33
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { StandardSchemaV1Issue } from "@tanstack/vue-form"
|
|
2
|
-
import { computed, inject, type InjectionKey, readonly, type Ref, ref } from "vue"
|
|
3
|
-
import { type OmegaError, type ShowErrorsOn } from "./OmegaFormStuff"
|
|
4
|
-
|
|
5
|
-
export const OmegaErrorsKey = Symbol() as InjectionKey<{
|
|
6
|
-
errors: Ref<readonly OmegaError[]>
|
|
7
|
-
mapError: (error: OmegaError) => void
|
|
8
|
-
removeError: (inputId: string) => void
|
|
9
|
-
clearErrors: () => void
|
|
10
|
-
showErrors: Ref<boolean>
|
|
11
|
-
showErrorsOn: ShowErrorsOn
|
|
12
|
-
generalErrors: Readonly<
|
|
13
|
-
Ref<
|
|
14
|
-
(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined
|
|
15
|
-
>
|
|
16
|
-
>
|
|
17
|
-
}>
|
|
18
|
-
|
|
19
|
-
export function buildOmegaErrors(
|
|
20
|
-
formSubmissionAttempts: Ref<number>,
|
|
21
|
-
generalErrors: Readonly<
|
|
22
|
-
Ref<
|
|
23
|
-
(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined
|
|
24
|
-
>
|
|
25
|
-
>,
|
|
26
|
-
showErrorsOn: ShowErrorsOn = "onSubmit"
|
|
27
|
-
) {
|
|
28
|
-
const errors = ref<OmegaError[]>([])
|
|
29
|
-
|
|
30
|
-
const removeError = (inputId: string) => {
|
|
31
|
-
errors.value = errors.value.filter((error) => error.inputId !== inputId)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const mapError = (error: OmegaError) => {
|
|
35
|
-
removeError(error.inputId)
|
|
36
|
-
errors.value.push(error)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const clearErrors = () => {
|
|
40
|
-
errors.value = []
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const showErrors = computed(() => {
|
|
44
|
-
if (showErrorsOn === "onSubmit") return formSubmissionAttempts.value > 0
|
|
45
|
-
return true
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
const context = {
|
|
49
|
-
errors: readonly(errors),
|
|
50
|
-
mapError,
|
|
51
|
-
removeError,
|
|
52
|
-
clearErrors,
|
|
53
|
-
showErrors,
|
|
54
|
-
generalErrors,
|
|
55
|
-
showErrorsOn: showErrorsOn ?? "onSubmit"
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return context
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function useOmegaErrors() {
|
|
62
|
-
const context = inject(OmegaErrorsKey)
|
|
63
|
-
if (!context) {
|
|
64
|
-
throw new Error("useOmegaErrors must be used within an OmegaForm provider")
|
|
65
|
-
}
|
|
66
|
-
return context
|
|
67
|
-
}
|