@effect-app/vue-components 0.15.23 → 0.15.25
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 +3 -3
- package/dist/types/components/OmegaForm/OmegaArray.vue.d.ts +4 -4
- package/dist/types/components/OmegaForm/OmegaAutoGen.vue.d.ts +4 -4
- package/dist/types/components/OmegaForm/OmegaErrors.vue.d.ts +2 -2
- package/dist/types/components/OmegaForm/OmegaErrorsContext.d.ts +1 -1
- package/dist/types/components/OmegaForm/OmegaFormInput.vue.d.ts +4 -4
- package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +4 -4
- package/dist/types/components/OmegaForm/OmegaInput.vue.d.ts +2 -2
- package/dist/types/components/OmegaForm/OmegaInputVuetify.vue.d.ts +3 -3
- package/dist/types/components/OmegaForm/OmegaInternalInput.vue.d.ts +4 -4
- package/dist/types/components/OmegaForm/OmegaWrapper.vue.d.ts +2 -2
- package/dist/types/components/OmegaForm/getOmegaStore.d.ts +1 -1
- package/dist/types/components/OmegaForm/index.d.ts +7 -7
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +3 -3
- package/dist/vue-components.es.js +6 -6
- package/dist/vue-components.es10.js +1 -3
- package/dist/vue-components.es11.js +5 -5
- package/dist/vue-components.es12.js +5 -5
- package/dist/vue-components.es13.js +2 -111
- package/dist/vue-components.es14.js +4 -0
- package/dist/vue-components.es15.js +88 -7
- package/dist/vue-components.es17.js +7 -2
- package/dist/vue-components.es18.js +2 -89
- package/dist/vue-components.es2.js +12 -12
- package/dist/vue-components.es20.js +111 -2
- package/dist/vue-components.es22.js +1 -1
- package/dist/vue-components.es23.js +2 -90
- package/dist/vue-components.es24.js +90 -11
- package/dist/vue-components.es25.js +11 -2
- package/dist/vue-components.es26.js +1 -1
- package/dist/vue-components.es4.js +39 -38
- package/dist/vue-components.es5.js +66 -28
- package/dist/vue-components.es6.js +28 -66
- package/dist/vue-components.es7.js +39 -40
- package/dist/vue-components.es9.js +7 -9
- package/package.json +20 -17
- package/src/components/OmegaForm/InputProps.ts +23 -35
- package/src/components/OmegaForm/OmegaArray.vue +24 -14
- package/src/components/OmegaForm/OmegaAutoGen.vue +38 -30
- package/src/components/OmegaForm/OmegaErrors.vue +25 -14
- package/src/components/OmegaForm/OmegaErrorsContext.ts +5 -13
- package/src/components/OmegaForm/OmegaFormInput.vue +17 -10
- package/src/components/OmegaForm/OmegaFormStuff.ts +141 -136
- package/src/components/OmegaForm/OmegaInput.vue +13 -10
- package/src/components/OmegaForm/OmegaInputVuetify.vue +18 -15
- package/src/components/OmegaForm/OmegaInternalInput.vue +34 -34
- package/src/components/OmegaForm/OmegaWrapper.vue +60 -58
- package/src/components/OmegaForm/getOmegaStore.ts +6 -7
- package/src/components/OmegaForm/index.ts +7 -7
- package/src/components/OmegaForm/useOmegaForm.ts +74 -76
- package/src/utils/index.ts +2 -2
- package/dist/vue-components.es16.js +0 -4
- /package/dist/{vue-components.es21.js → vue-components.es19.js} +0 -0
|
@@ -1,41 +1,49 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<slot
|
|
3
|
-
v-for="{ name, label, ...attrs } in children"
|
|
3
|
+
v-for="({ name, label, ...attrs }) in children"
|
|
4
4
|
:child="{ name, label, ...attrs }"
|
|
5
5
|
>
|
|
6
|
-
<OmegaInput
|
|
6
|
+
<OmegaInput
|
|
7
|
+
:form="props.form"
|
|
8
|
+
:name="name"
|
|
9
|
+
:label="label"
|
|
10
|
+
v-bind="attrs"
|
|
11
|
+
/>
|
|
7
12
|
</slot>
|
|
8
13
|
</template>
|
|
9
14
|
|
|
10
|
-
<script
|
|
15
|
+
<script
|
|
16
|
+
setup
|
|
17
|
+
lang="ts"
|
|
18
|
+
generic="
|
|
19
|
+
From extends Record<PropertyKey, string>,
|
|
20
|
+
To extends Record<PropertyKey, string>
|
|
21
|
+
"
|
|
22
|
+
>
|
|
23
|
+
import { type DeepKeys } from "@tanstack/vue-form"
|
|
24
|
+
import { Array as A, Order, pipe } from "effect-app"
|
|
11
25
|
import { computed } from "vue"
|
|
12
|
-
import {
|
|
13
|
-
type NestedKeyOf,
|
|
14
|
-
type MetaRecord,
|
|
15
|
-
type FormType,
|
|
16
|
-
type FieldMeta,
|
|
17
|
-
type OmegaInputProps,
|
|
18
|
-
} from "./OmegaFormStuff"
|
|
19
|
-
import { pipe, Order, Array as A } from "effect-app"
|
|
26
|
+
import { type FieldMeta, type OmegaInputProps } from "./OmegaFormStuff"
|
|
20
27
|
import OmegaInput from "./OmegaInput.vue"
|
|
21
|
-
import { DeepKeys } from "@tanstack/vue-form"
|
|
22
|
-
import { OmegaFormReturn } from "./useOmegaForm"
|
|
23
28
|
|
|
24
|
-
export type OmegaAutoGenMeta<
|
|
29
|
+
export type OmegaAutoGenMeta<
|
|
30
|
+
From extends Record<PropertyKey, string>,
|
|
31
|
+
To extends Record<PropertyKey, string>
|
|
32
|
+
> = Omit<OmegaInputProps<From, To>, "form">
|
|
25
33
|
type NewMeta = OmegaAutoGenMeta<From, To>
|
|
26
34
|
|
|
27
35
|
const mapObject =
|
|
28
36
|
<K extends string, A, B>(fn: (value: A, key: K) => B) =>
|
|
29
37
|
(obj: Record<K, A>): Record<K, B> =>
|
|
30
38
|
Object.fromEntries(
|
|
31
|
-
(Object.entries(obj) as [K, A][]).map(([k, v]) => [k, fn(v, k)])
|
|
39
|
+
(Object.entries(obj) as [K, A][]).map(([k, v]) => [k, fn(v, k)])
|
|
32
40
|
) as Record<K, B> // Cast needed for Object.fromEntries
|
|
33
41
|
|
|
34
42
|
const filterRecord =
|
|
35
43
|
<K extends string, V>(predicate: (value: V, key: K) => boolean) =>
|
|
36
44
|
(obj: Record<K, V>): Record<K, V> =>
|
|
37
45
|
Object.fromEntries(
|
|
38
|
-
(Object.entries(obj) as [K, V][]).filter(([k, v]) => predicate(v, k))
|
|
46
|
+
(Object.entries(obj) as [K, V][]).filter(([k, v]) => predicate(v, k))
|
|
39
47
|
) as Record<K, V>
|
|
40
48
|
|
|
41
49
|
const filterMapRecord =
|
|
@@ -49,11 +57,11 @@ const filterMapRecord =
|
|
|
49
57
|
}
|
|
50
58
|
return acc
|
|
51
59
|
},
|
|
52
|
-
{} as Record<K, B
|
|
60
|
+
{} as Record<K, B>
|
|
53
61
|
)
|
|
54
62
|
|
|
55
63
|
const props = defineProps<{
|
|
56
|
-
form: OmegaInputProps<From, To>[
|
|
64
|
+
form: OmegaInputProps<From, To>["form"]
|
|
57
65
|
pick?: DeepKeys<From>[]
|
|
58
66
|
omit?: DeepKeys<From>[]
|
|
59
67
|
labelMap?: (key: DeepKeys<From>) => string | undefined
|
|
@@ -69,7 +77,7 @@ const namePosition = (name: DeepKeys<From>, order: DeepKeys<From>[]) => {
|
|
|
69
77
|
|
|
70
78
|
const orderBy: Order.Order<NewMeta> = Order.mapInput(
|
|
71
79
|
Order.number,
|
|
72
|
-
(x: NewMeta) => namePosition(x.name, props.order || [])
|
|
80
|
+
(x: NewMeta) => namePosition(x.name, props.order || [])
|
|
73
81
|
)
|
|
74
82
|
|
|
75
83
|
const children = computed<NewMeta[]>(() =>
|
|
@@ -79,29 +87,29 @@ const children = computed<NewMeta[]>(() =>
|
|
|
79
87
|
filterRecord((_, metaKey) =>
|
|
80
88
|
props.pick
|
|
81
89
|
? props.pick.includes(metaKey) && !props.omit?.includes(metaKey)
|
|
82
|
-
: !props.omit?.includes(metaKey)
|
|
90
|
+
: !props.omit?.includes(metaKey)
|
|
83
91
|
),
|
|
84
|
-
x => x,
|
|
92
|
+
(x) => x,
|
|
85
93
|
// labelMap and adding name
|
|
86
94
|
mapObject((metaValue, metaKey) => ({
|
|
87
95
|
name: metaKey,
|
|
88
96
|
label: props.labelMap?.(metaKey) || metaKey,
|
|
89
|
-
...metaValue
|
|
97
|
+
...metaValue
|
|
90
98
|
})),
|
|
91
99
|
// filterMap
|
|
92
100
|
props.filterMap
|
|
93
|
-
? filterMapRecord(m => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
: x => x,
|
|
101
|
+
? filterMapRecord((m) => {
|
|
102
|
+
const result = props.filterMap?.(m.name!, m as NewMeta)
|
|
103
|
+
return result === undefined || result === true ? m : result
|
|
104
|
+
})
|
|
105
|
+
: (x) => x,
|
|
98
106
|
// transform to array
|
|
99
|
-
obj => Object.values(obj) as NewMeta[],
|
|
107
|
+
(obj) => Object.values(obj) as NewMeta[],
|
|
100
108
|
// order
|
|
101
109
|
A.sort(orderBy),
|
|
102
110
|
// sort
|
|
103
|
-
props.sort ? A.sort(props.sort) : x => x
|
|
104
|
-
)
|
|
111
|
+
props.sort ? A.sort(props.sort) : (x) => x
|
|
112
|
+
)
|
|
105
113
|
)
|
|
106
114
|
|
|
107
115
|
defineSlots<{
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
aria-live="polite"
|
|
15
15
|
class="mb-4"
|
|
16
16
|
>
|
|
17
|
-
<div class="text-h6 mb-3">
|
|
17
|
+
<div class="text-h6 mb-3">
|
|
18
|
+
{{ trans("form.includes_error") }}:
|
|
19
|
+
</div>
|
|
18
20
|
<component
|
|
19
21
|
:is="errors.length > 1 ? 'ul' : 'div'"
|
|
20
22
|
v-if="errors.length"
|
|
@@ -26,14 +28,18 @@
|
|
|
26
28
|
:key="error.inputId"
|
|
27
29
|
class="error-item"
|
|
28
30
|
>
|
|
29
|
-
<div class="font-weight-medium">
|
|
31
|
+
<div class="font-weight-medium">
|
|
32
|
+
{{ error.label }}
|
|
33
|
+
</div>
|
|
30
34
|
<div class="error-message">
|
|
31
35
|
<component
|
|
32
36
|
:is="error.errors.length > 1 ? 'ul' : 'div'"
|
|
33
37
|
class="error-list"
|
|
34
38
|
>
|
|
35
39
|
<component
|
|
36
|
-
:is="error.errors.length > 1
|
|
40
|
+
:is="error.errors.length > 1
|
|
41
|
+
? 'li'
|
|
42
|
+
: 'span'"
|
|
37
43
|
v-for="e in error.errors"
|
|
38
44
|
:key="e"
|
|
39
45
|
>
|
|
@@ -41,7 +47,10 @@
|
|
|
41
47
|
</component>
|
|
42
48
|
</component>
|
|
43
49
|
</div>
|
|
44
|
-
<a
|
|
50
|
+
<a
|
|
51
|
+
:href="`#${error.inputId}`"
|
|
52
|
+
class="error-link"
|
|
53
|
+
>
|
|
45
54
|
<component
|
|
46
55
|
:is="vuetified ? 'v-icon' : 'i'"
|
|
47
56
|
:icon="mdiLink"
|
|
@@ -63,11 +72,11 @@
|
|
|
63
72
|
</template>
|
|
64
73
|
|
|
65
74
|
<script setup lang="ts">
|
|
66
|
-
import { useOmegaErrors } from "./OmegaErrorsContext"
|
|
67
75
|
import { mdiLink } from "@mdi/js"
|
|
68
|
-
import { useIntl } from "../../utils"
|
|
69
76
|
import type { StandardSchemaV1Issue } from "@tanstack/vue-form"
|
|
70
77
|
import { computed, getCurrentInstance } from "vue"
|
|
78
|
+
import { useIntl } from "../../utils"
|
|
79
|
+
import { useOmegaErrors } from "./OmegaErrorsContext"
|
|
71
80
|
|
|
72
81
|
const instance = getCurrentInstance()
|
|
73
82
|
const vuetified = instance?.appContext.components["VAlert"]
|
|
@@ -79,21 +88,23 @@ const { trans } = useIntl()
|
|
|
79
88
|
const showedGeneralErrors = computed(() => {
|
|
80
89
|
if (!generalErrors.value) return []
|
|
81
90
|
|
|
82
|
-
return generalErrors
|
|
91
|
+
return generalErrors
|
|
92
|
+
.value
|
|
83
93
|
.filter((record): record is Record<string, StandardSchemaV1Issue[]> =>
|
|
84
|
-
Boolean(record)
|
|
94
|
+
Boolean(record)
|
|
85
95
|
)
|
|
86
|
-
.flatMap(errorRecord =>
|
|
87
|
-
Object
|
|
96
|
+
.flatMap((errorRecord) =>
|
|
97
|
+
Object
|
|
98
|
+
.values(errorRecord)
|
|
88
99
|
.filter((issues): issues is StandardSchemaV1Issue[] => Boolean(issues))
|
|
89
|
-
.flatMap(issues =>
|
|
100
|
+
.flatMap((issues) =>
|
|
90
101
|
issues
|
|
91
102
|
.filter(
|
|
92
103
|
(issue): issue is StandardSchemaV1Issue & { message: string } =>
|
|
93
|
-
Boolean(issue?.message)
|
|
104
|
+
Boolean(issue?.message)
|
|
94
105
|
)
|
|
95
|
-
.map(issue => issue.message)
|
|
96
|
-
)
|
|
106
|
+
.map((issue) => issue.message)
|
|
107
|
+
)
|
|
97
108
|
)
|
|
98
109
|
})
|
|
99
110
|
</script>
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type InjectionKey,
|
|
3
|
-
provide,
|
|
4
|
-
inject,
|
|
5
|
-
ref,
|
|
6
|
-
readonly,
|
|
7
|
-
type Ref,
|
|
8
|
-
computed,
|
|
9
|
-
} from "vue"
|
|
10
|
-
import { type OmegaError, type ShowErrorsOn } from "./OmegaFormStuff"
|
|
11
1
|
import type { StandardSchemaV1Issue } from "@tanstack/vue-form"
|
|
2
|
+
import { computed, inject, type InjectionKey, provide, readonly, type Ref, ref } from "vue"
|
|
3
|
+
import { type OmegaError, type ShowErrorsOn } from "./OmegaFormStuff"
|
|
12
4
|
|
|
13
5
|
export const OmegaErrorsKey = Symbol() as InjectionKey<{
|
|
14
6
|
errors: Ref<readonly OmegaError[]>
|
|
@@ -27,12 +19,12 @@ export function provideOmegaErrors(
|
|
|
27
19
|
generalErrors: Ref<
|
|
28
20
|
(Record<string, StandardSchemaV1Issue[]> | undefined)[] | undefined
|
|
29
21
|
>,
|
|
30
|
-
showErrorsOn: ShowErrorsOn = "onSubmit"
|
|
22
|
+
showErrorsOn: ShowErrorsOn = "onSubmit"
|
|
31
23
|
) {
|
|
32
24
|
const errors = ref<OmegaError[]>([])
|
|
33
25
|
|
|
34
26
|
const removeError = (inputId: string) => {
|
|
35
|
-
errors.value = errors.value.filter(error => error.inputId !== inputId)
|
|
27
|
+
errors.value = errors.value.filter((error) => error.inputId !== inputId)
|
|
36
28
|
}
|
|
37
29
|
|
|
38
30
|
const addError = (error: OmegaError) => {
|
|
@@ -56,7 +48,7 @@ export function provideOmegaErrors(
|
|
|
56
48
|
clearErrors,
|
|
57
49
|
showErrors,
|
|
58
50
|
generalErrors,
|
|
59
|
-
showErrorsOn: showErrorsOn ?? "onSubmit"
|
|
51
|
+
showErrorsOn: showErrorsOn ?? "onSubmit"
|
|
60
52
|
}
|
|
61
53
|
|
|
62
54
|
provide(OmegaErrorsKey, context)
|
|
@@ -9,25 +9,32 @@
|
|
|
9
9
|
:type="type"
|
|
10
10
|
>
|
|
11
11
|
<template #default="slotProps">
|
|
12
|
-
<slot v-bind="slotProps"
|
|
12
|
+
<slot v-bind="slotProps" />
|
|
13
13
|
</template>
|
|
14
14
|
</OmegaInput>
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
|
-
<script
|
|
17
|
+
<script
|
|
18
|
+
setup
|
|
19
|
+
lang="ts"
|
|
20
|
+
generic="
|
|
21
|
+
From extends Record<PropertyKey, any>,
|
|
22
|
+
To extends Record<PropertyKey, any>,
|
|
23
|
+
Name extends DeepKeys<From>
|
|
24
|
+
"
|
|
25
|
+
>
|
|
26
|
+
import { type DeepKeys } from "@tanstack/vue-form"
|
|
18
27
|
import { inject } from "vue"
|
|
19
|
-
import type {
|
|
20
|
-
FieldValidators,
|
|
21
|
-
TypeOverride,
|
|
22
|
-
OmegaInputProps,
|
|
23
|
-
} from "./OmegaFormStuff"
|
|
24
28
|
import type { InputProps } from "./InputProps"
|
|
29
|
+
import type { FieldValidators, OmegaInputProps, TypeOverride } from "./OmegaFormStuff"
|
|
25
30
|
import OmegaInput from "./OmegaInput.vue"
|
|
26
31
|
import { OmegaFormKey } from "./useOmegaForm"
|
|
27
|
-
import { DeepKeys } from "@tanstack/vue-form"
|
|
28
32
|
|
|
29
|
-
const form = inject(OmegaFormKey) as unknown as OmegaInputProps<
|
|
30
|
-
|
|
33
|
+
const form = inject(OmegaFormKey) as unknown as OmegaInputProps<
|
|
34
|
+
From,
|
|
35
|
+
To
|
|
36
|
+
>["form"]
|
|
37
|
+
|
|
31
38
|
if (!form) {
|
|
32
39
|
throw new Error("OmegaFormInput must be used within an OmegaForm context")
|
|
33
40
|
}
|