@effect-app/vue-components 0.12.19 → 0.12.21
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 +5 -47
- package/dist/types/components/OmegaForm/OmegaArray.vue.d.ts +5 -5
- package/dist/types/components/OmegaForm/OmegaAutoGen.vue.d.ts +8 -9
- package/dist/types/components/OmegaForm/OmegaFormInput.vue.d.ts +4 -3
- package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +14 -13
- package/dist/types/components/OmegaForm/OmegaInput.vue.d.ts +2 -3
- package/dist/types/components/OmegaForm/OmegaInputVuetify.vue.d.ts +2 -2
- package/dist/types/components/OmegaForm/OmegaInternalInput.vue.d.ts +6 -6
- package/dist/types/components/OmegaForm/OmegaWrapper.vue.d.ts +3 -3
- package/dist/types/components/OmegaForm/index.d.ts +2 -1
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +2 -2
- package/dist/vue-components.es.js +15 -13
- package/dist/vue-components.es10.js +246 -6
- package/dist/vue-components.es11.js +5 -5
- package/dist/vue-components.es12.js +6 -111
- package/dist/vue-components.es13.js +113 -0
- package/dist/vue-components.es15.js +7 -2
- package/dist/vue-components.es16.js +2 -89
- package/dist/vue-components.es17.js +4 -0
- package/dist/vue-components.es18.js +89 -2
- package/dist/vue-components.es2.js +17 -15
- package/dist/vue-components.es20.js +2 -5
- package/dist/vue-components.es21.js +2 -32
- package/dist/vue-components.es22.js +5 -2
- package/dist/vue-components.es23.js +2 -2
- package/dist/vue-components.es24.js +90 -11
- package/dist/vue-components.es25.js +11 -90
- package/dist/vue-components.es26.js +1 -1
- package/dist/vue-components.es4.js +2 -2
- package/dist/vue-components.es5.js +28 -66
- package/dist/vue-components.es6.js +65 -55
- package/dist/vue-components.es7.js +60 -29
- package/dist/vue-components.es8.js +28 -124
- package/dist/vue-components.es9.js +118 -241
- package/package.json +5 -9
- package/src/components/OmegaForm/InputProps.ts +37 -64
- package/src/components/OmegaForm/OmegaArray.vue +5 -3
- package/src/components/OmegaForm/OmegaAutoGen.vue +10 -10
- package/src/components/OmegaForm/OmegaFormInput.vue +6 -8
- package/src/components/OmegaForm/OmegaFormStuff.ts +76 -77
- package/src/components/OmegaForm/OmegaInput.vue +1 -2
- package/src/components/OmegaForm/OmegaInputVuetify.vue +3 -3
- package/src/components/OmegaForm/OmegaInternalInput.vue +5 -5
- package/src/components/OmegaForm/OmegaWrapper.vue +2 -2
- package/src/components/OmegaForm/index.ts +2 -1
- package/src/components/OmegaForm/useOmegaForm.ts +20 -22
- package/dist/vue-components.es14.js +0 -9
- package/dist/vue-components.es19.js +0 -4
|
@@ -1,68 +1,41 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type {
|
|
3
|
+
DeepValue,
|
|
4
|
+
DeepKeys,
|
|
5
|
+
FieldApi,
|
|
6
|
+
ValidationError,
|
|
7
|
+
FormAsyncValidateOrFn,
|
|
8
|
+
FormValidateOrFn,
|
|
9
|
+
StandardSchemaV1,
|
|
10
|
+
FieldValidateOrFn,
|
|
11
|
+
FieldValidateFn,
|
|
12
|
+
FieldValidateAsyncFn,
|
|
13
|
+
FieldAsyncValidateOrFn,
|
|
14
|
+
} from "@tanstack/vue-form"
|
|
4
15
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
export type OmegaFieldInternalApi<From, To> = FieldApi<
|
|
17
|
+
From,
|
|
18
|
+
DeepKeys<From>,
|
|
19
|
+
DeepValue<From, any>,
|
|
20
|
+
FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, any>> | undefined,
|
|
21
|
+
StandardSchemaV1<unknown, To> | FieldValidateFn<From, any, To>,
|
|
22
|
+
StandardSchemaV1<unknown, To> | FieldValidateAsyncFn<From, any, To>,
|
|
23
|
+
FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, any>>,
|
|
24
|
+
FieldAsyncValidateOrFn<From, DeepKeys<From>, DeepValue<From, any>>,
|
|
25
|
+
FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, any>> | undefined,
|
|
26
|
+
FieldAsyncValidateOrFn<From, DeepKeys<From>, DeepValue<From, any>> | undefined,
|
|
27
|
+
FormValidateOrFn<From> | undefined,
|
|
28
|
+
FormValidateOrFn<From> | undefined,
|
|
29
|
+
any,
|
|
30
|
+
FormValidateOrFn<From> | undefined,
|
|
31
|
+
FormAsyncValidateOrFn<From> | undefined,
|
|
32
|
+
FormValidateOrFn<From> | undefined,
|
|
33
|
+
FormAsyncValidateOrFn<From> | undefined,
|
|
34
|
+
FormAsyncValidateOrFn<From> | undefined,
|
|
35
|
+
FormAsyncValidateOrFn<From> | undefined
|
|
36
|
+
>
|
|
26
37
|
|
|
27
|
-
|
|
28
|
-
type FlexibleUpdater<T> = ((prev: T) => T) | T
|
|
29
|
-
|
|
30
|
-
export type OmegaFieldInternalApi<To> = Omit<
|
|
31
|
-
FieldApi<
|
|
32
|
-
To, // TParentData
|
|
33
|
-
NestedKeyOf<To>, // TName
|
|
34
|
-
DeepValue<To, NestedKeyOf<To>>, // TData
|
|
35
|
-
// Field Validators (approximated typqes)
|
|
36
|
-
ValidatorFnSync, // TOnMount
|
|
37
|
-
ValidatorFnSync, // TOnChange
|
|
38
|
-
ValidatorFnAsync, // TOnChangeAsync
|
|
39
|
-
ValidatorFnSync, // TOnBlur
|
|
40
|
-
ValidatorFnAsync, // TOnBlurAsync
|
|
41
|
-
ValidatorFnSync, // TOnSubmit
|
|
42
|
-
ValidatorFnAsync, // TOnSubmitAsync
|
|
43
|
-
// Form Validators (approximated types)
|
|
44
|
-
FormValidatorFnSync, // TFormOnMount
|
|
45
|
-
FormValidatorFnSync, // TFormOnChange
|
|
46
|
-
FormValidatorFnAsync, // TFormOnChangeAsync
|
|
47
|
-
FormValidatorFnSync, // TFormOnBlur
|
|
48
|
-
FormValidatorFnAsync, // TFormOnBlurAsync
|
|
49
|
-
FormValidatorFnSync, // TFormOnSubmit
|
|
50
|
-
FormValidatorFnAsync, // TFormOnSubmitAsync
|
|
51
|
-
// Other Form types (placeholders)
|
|
52
|
-
FormServerError, // TFormOnServer
|
|
53
|
-
SubmitMeta // TParentSubmitMeta
|
|
54
|
-
>,
|
|
55
|
-
"handleChange" | "setValue"
|
|
56
|
-
> & {
|
|
57
|
-
handleChange: (
|
|
58
|
-
updater: FlexibleUpdater<DeepValue<To, NestedKeyOf<To>>> | any,
|
|
59
|
-
) => void
|
|
60
|
-
setValue: (
|
|
61
|
-
updater: FlexibleUpdater<DeepValue<To, NestedKeyOf<To>>> | any,
|
|
62
|
-
) => void
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export type InputProps<T> = {
|
|
38
|
+
export type InputProps<T, S = unknown> = {
|
|
66
39
|
id: string
|
|
67
40
|
required?: boolean
|
|
68
41
|
minLength?: number | false
|
|
@@ -70,10 +43,10 @@ export type InputProps<T> = {
|
|
|
70
43
|
max?: number | false
|
|
71
44
|
min?: number | false
|
|
72
45
|
name: string
|
|
73
|
-
modelValue:
|
|
46
|
+
modelValue: S
|
|
74
47
|
errorMessages: string[]
|
|
75
48
|
error: boolean
|
|
76
|
-
field: OmegaFieldInternalApi<T>
|
|
49
|
+
field: OmegaFieldInternalApi<T, S>
|
|
77
50
|
setRealDirty: () => void
|
|
78
51
|
type: string
|
|
79
52
|
label: string
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
<component
|
|
5
5
|
:is="form.Field"
|
|
6
6
|
v-for="(_, i) of field.state.value"
|
|
7
|
-
:key="i"
|
|
8
|
-
:name="
|
|
7
|
+
:key="`${name}[${Number(i)}]`"
|
|
8
|
+
:name="
|
|
9
|
+
`${name}[${Number(i)}]` as DeepKeys<From>
|
|
10
|
+
"
|
|
9
11
|
>
|
|
10
12
|
<template #default="{ field: subField, state: subState }">
|
|
11
13
|
<slot
|
|
@@ -13,7 +15,7 @@
|
|
|
13
15
|
field,
|
|
14
16
|
subField,
|
|
15
17
|
subState,
|
|
16
|
-
index: i,
|
|
18
|
+
index: Number(i),
|
|
17
19
|
}"
|
|
18
20
|
/>
|
|
19
21
|
</template>
|
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
} from "./OmegaFormStuff"
|
|
19
19
|
import { pipe, Order, Array as A } from "effect-app"
|
|
20
20
|
import OmegaInput from "./OmegaInput.vue"
|
|
21
|
+
import { DeepKeys } from "@tanstack/vue-form"
|
|
22
|
+
import { OmegaFormReturn } from "./useOmegaForm"
|
|
21
23
|
|
|
22
24
|
export type OmegaAutoGenMeta<From, To> = Omit<OmegaInputProps<From, To>, "form">
|
|
23
25
|
type NewMeta = OmegaAutoGenMeta<From, To>
|
|
@@ -51,18 +53,16 @@ const filterMapRecord =
|
|
|
51
53
|
)
|
|
52
54
|
|
|
53
55
|
const props = defineProps<{
|
|
54
|
-
form:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
filterMap?: <M extends NewMeta>(key: NestedKeyOf<To>, meta: M) => boolean | M
|
|
61
|
-
order?: NestedKeyOf<To>[]
|
|
56
|
+
form: OmegaInputProps<From, To>['form']
|
|
57
|
+
pick?: DeepKeys<From>[]
|
|
58
|
+
omit?: DeepKeys<From>[]
|
|
59
|
+
labelMap?: (key: DeepKeys<From>) => string | undefined
|
|
60
|
+
filterMap?: <M extends NewMeta>(key: DeepKeys<From>, meta: M) => boolean | M
|
|
61
|
+
order?: DeepKeys<From>[]
|
|
62
62
|
sort?: Order.Order<NewMeta>
|
|
63
63
|
}>()
|
|
64
64
|
|
|
65
|
-
const namePosition = (name:
|
|
65
|
+
const namePosition = (name: DeepKeys<From>, order: DeepKeys<From>[]) => {
|
|
66
66
|
const index = order?.indexOf(name) ?? -1
|
|
67
67
|
return index === -1 ? Number.MAX_SAFE_INTEGER : index
|
|
68
68
|
}
|
|
@@ -74,7 +74,7 @@ const orderBy: Order.Order<NewMeta> = Order.mapInput(
|
|
|
74
74
|
|
|
75
75
|
const children = computed<NewMeta[]>(() =>
|
|
76
76
|
pipe(
|
|
77
|
-
props.form.meta as Record<
|
|
77
|
+
props.form.meta as Record<DeepKeys<From>, FieldMeta | undefined>,
|
|
78
78
|
// include / exclude
|
|
79
79
|
filterRecord((_, metaKey) =>
|
|
80
80
|
props.pick
|
|
@@ -18,24 +18,22 @@
|
|
|
18
18
|
import { inject } from "vue"
|
|
19
19
|
import type {
|
|
20
20
|
FieldValidators,
|
|
21
|
-
NestedKeyOf,
|
|
22
21
|
TypeOverride,
|
|
23
|
-
|
|
24
|
-
MetaRecord,
|
|
22
|
+
OmegaInputProps,
|
|
25
23
|
} from "./OmegaFormStuff"
|
|
26
24
|
import type { InputProps } from "./InputProps"
|
|
27
25
|
import OmegaInput from "./OmegaInput.vue"
|
|
28
26
|
import { OmegaFormKey } from "./useOmegaForm"
|
|
27
|
+
import { DeepKeys } from "@tanstack/vue-form"
|
|
29
28
|
|
|
30
|
-
const form = inject(OmegaFormKey) as
|
|
31
|
-
|
|
32
|
-
}
|
|
29
|
+
const form = inject(OmegaFormKey) as unknown as OmegaInputProps<From, To>['form']
|
|
30
|
+
|
|
33
31
|
if (!form) {
|
|
34
32
|
throw new Error("OmegaFormInput must be used within an OmegaForm context")
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
defineProps<{
|
|
38
|
-
name:
|
|
36
|
+
name: DeepKeys<From>
|
|
39
37
|
label: string
|
|
40
38
|
validators?: FieldValidators<From>
|
|
41
39
|
options?: { title: string; value: string }[]
|
|
@@ -44,6 +42,6 @@ defineProps<{
|
|
|
44
42
|
|
|
45
43
|
defineSlots<{
|
|
46
44
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
-
default:
|
|
45
|
+
default: InputProps<From, To>
|
|
48
46
|
}>()
|
|
49
47
|
</script>
|
|
@@ -6,23 +6,23 @@ import {
|
|
|
6
6
|
type StandardSchemaV1,
|
|
7
7
|
type FormApi,
|
|
8
8
|
type VueFormApi,
|
|
9
|
-
type FieldComponent,
|
|
10
9
|
type FormOptions,
|
|
11
10
|
type DeepKeys,
|
|
12
11
|
type FieldValidateOrFn,
|
|
13
12
|
type FieldAsyncValidateOrFn,
|
|
14
13
|
type FormState,
|
|
15
14
|
} from "@tanstack/vue-form"
|
|
16
|
-
import type { Component } from "vue"
|
|
17
15
|
import { useIntl } from "../../utils"
|
|
16
|
+
import { OmegaFormReturn } from "./useOmegaForm"
|
|
17
|
+
import { OmegaFieldInternalApi } from "./InputProps"
|
|
18
18
|
|
|
19
19
|
export type ShowErrorsOn = "onChange" | "onBlur" | "onSubmit"
|
|
20
20
|
|
|
21
21
|
export type OmegaInputProps<From, To> = {
|
|
22
|
-
form:
|
|
23
|
-
meta: MetaRecord<
|
|
22
|
+
form: OmegaFormReturn<From, To> & {
|
|
23
|
+
meta: MetaRecord<From>
|
|
24
24
|
}
|
|
25
|
-
name: NestedKeyOf<
|
|
25
|
+
name: NestedKeyOf<From>
|
|
26
26
|
validators?: FieldValidators<From>
|
|
27
27
|
label: string
|
|
28
28
|
options?: { title: string; value: string }[]
|
|
@@ -49,68 +49,68 @@ export interface OmegaError {
|
|
|
49
49
|
|
|
50
50
|
const isArrayOfString = S.NonEmptyArray(S.String)
|
|
51
51
|
|
|
52
|
-
export type FormProps<
|
|
52
|
+
export type FormProps<From, To> = Omit<
|
|
53
53
|
FormOptions<
|
|
54
|
-
|
|
55
|
-
FormValidateOrFn<
|
|
56
|
-
FormValidateOrFn<
|
|
57
|
-
StandardSchemaV1<
|
|
58
|
-
FormValidateOrFn<
|
|
59
|
-
FormAsyncValidateOrFn<
|
|
60
|
-
FormValidateOrFn<
|
|
61
|
-
FormAsyncValidateOrFn<
|
|
62
|
-
FormAsyncValidateOrFn<
|
|
63
|
-
FormAsyncValidateOrFn<
|
|
54
|
+
From,
|
|
55
|
+
FormValidateOrFn<From> | undefined,
|
|
56
|
+
FormValidateOrFn<From> | undefined,
|
|
57
|
+
StandardSchemaV1<From, To>,
|
|
58
|
+
FormValidateOrFn<From> | undefined,
|
|
59
|
+
FormAsyncValidateOrFn<From> | undefined,
|
|
60
|
+
FormValidateOrFn<From> | undefined,
|
|
61
|
+
FormAsyncValidateOrFn<From> | undefined,
|
|
62
|
+
FormAsyncValidateOrFn<From> | undefined,
|
|
63
|
+
FormAsyncValidateOrFn<From> | undefined
|
|
64
64
|
>,
|
|
65
65
|
"onSubmit"
|
|
66
66
|
> & {
|
|
67
67
|
onSubmit?: (props: {
|
|
68
|
-
formApi: OmegaFormParams<
|
|
68
|
+
formApi: OmegaFormParams<From, To>
|
|
69
69
|
meta: any
|
|
70
|
-
value:
|
|
70
|
+
value: To
|
|
71
71
|
}) => Promise<any> | any
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
export type OmegaFormParams<
|
|
75
|
-
|
|
76
|
-
FormValidateOrFn<
|
|
77
|
-
FormValidateOrFn<
|
|
78
|
-
StandardSchemaV1<
|
|
79
|
-
FormValidateOrFn<
|
|
80
|
-
FormAsyncValidateOrFn<
|
|
81
|
-
FormValidateOrFn<
|
|
82
|
-
FormAsyncValidateOrFn<
|
|
83
|
-
FormAsyncValidateOrFn<
|
|
84
|
-
FormAsyncValidateOrFn<
|
|
74
|
+
export type OmegaFormParams<From, To> = FormApi<
|
|
75
|
+
From,
|
|
76
|
+
FormValidateOrFn<From> | undefined,
|
|
77
|
+
FormValidateOrFn<From> | undefined,
|
|
78
|
+
StandardSchemaV1<From, To>,
|
|
79
|
+
FormValidateOrFn<From> | undefined,
|
|
80
|
+
FormAsyncValidateOrFn<From> | undefined,
|
|
81
|
+
FormValidateOrFn<From> | undefined,
|
|
82
|
+
FormAsyncValidateOrFn<From> | undefined,
|
|
83
|
+
FormAsyncValidateOrFn<From> | undefined,
|
|
84
|
+
FormAsyncValidateOrFn<From> | undefined
|
|
85
85
|
>
|
|
86
86
|
|
|
87
|
-
export type OmegaFormState<
|
|
88
|
-
|
|
89
|
-
FormValidateOrFn<
|
|
90
|
-
FormValidateOrFn<
|
|
91
|
-
StandardSchemaV1<
|
|
92
|
-
FormValidateOrFn<
|
|
93
|
-
FormAsyncValidateOrFn<
|
|
94
|
-
FormValidateOrFn<
|
|
95
|
-
FormAsyncValidateOrFn<
|
|
96
|
-
FormAsyncValidateOrFn<
|
|
87
|
+
export type OmegaFormState<From, To> = FormState<
|
|
88
|
+
From,
|
|
89
|
+
FormValidateOrFn<From> | undefined,
|
|
90
|
+
FormValidateOrFn<From> | undefined,
|
|
91
|
+
StandardSchemaV1<From, To>,
|
|
92
|
+
FormValidateOrFn<From> | undefined,
|
|
93
|
+
FormAsyncValidateOrFn<From> | undefined,
|
|
94
|
+
FormValidateOrFn<From> | undefined,
|
|
95
|
+
FormAsyncValidateOrFn<From> | undefined,
|
|
96
|
+
FormAsyncValidateOrFn<From> | undefined
|
|
97
97
|
>
|
|
98
98
|
|
|
99
|
-
export type OmegaFormApi<
|
|
99
|
+
export type OmegaFormApi<From, To> = OmegaFormParams<From, To> &
|
|
100
100
|
VueFormApi<
|
|
101
|
-
|
|
102
|
-
FormValidateOrFn<
|
|
103
|
-
FormValidateOrFn<
|
|
104
|
-
StandardSchemaV1<
|
|
105
|
-
FormValidateOrFn<
|
|
106
|
-
FormAsyncValidateOrFn<
|
|
107
|
-
FormValidateOrFn<
|
|
108
|
-
FormAsyncValidateOrFn<
|
|
109
|
-
FormAsyncValidateOrFn<
|
|
110
|
-
FormAsyncValidateOrFn<
|
|
101
|
+
From,
|
|
102
|
+
FormValidateOrFn<From> | undefined,
|
|
103
|
+
FormValidateOrFn<From> | undefined,
|
|
104
|
+
StandardSchemaV1<From, To>,
|
|
105
|
+
FormValidateOrFn<From> | undefined,
|
|
106
|
+
FormAsyncValidateOrFn<From> | undefined,
|
|
107
|
+
FormValidateOrFn<From> | undefined,
|
|
108
|
+
FormAsyncValidateOrFn<From> | undefined,
|
|
109
|
+
FormAsyncValidateOrFn<From> | undefined,
|
|
110
|
+
FormAsyncValidateOrFn<From> | undefined
|
|
111
111
|
>
|
|
112
112
|
|
|
113
|
-
export type FormComponent<T, S> =
|
|
113
|
+
export type FormComponent<T, S> = VueFormApi<
|
|
114
114
|
T,
|
|
115
115
|
FormValidateOrFn<T> | undefined,
|
|
116
116
|
FormValidateOrFn<T> | undefined,
|
|
@@ -121,16 +121,15 @@ export type FormComponent<T, S> = FieldComponent<
|
|
|
121
121
|
FormAsyncValidateOrFn<T> | undefined,
|
|
122
122
|
FormAsyncValidateOrFn<T> | undefined,
|
|
123
123
|
FormAsyncValidateOrFn<T> | undefined
|
|
124
|
-
>
|
|
125
|
-
Component
|
|
124
|
+
>
|
|
126
125
|
|
|
127
126
|
export type FormType<T, S = unknown> = OmegaFormApi<T, S> & {
|
|
128
|
-
Field:
|
|
127
|
+
Field: OmegaFieldInternalApi<T, S>
|
|
129
128
|
}
|
|
130
129
|
|
|
131
130
|
export type PrefixFromDepth<
|
|
132
131
|
K extends string | number,
|
|
133
|
-
_TDepth extends any[]
|
|
132
|
+
_TDepth extends any[]
|
|
134
133
|
> = K
|
|
135
134
|
|
|
136
135
|
export type NestedKeyOf<T> = DeepKeys<T>
|
|
@@ -234,7 +233,7 @@ const isNullableOrUndefined = (property: false | S.AST.AST | undefined) => {
|
|
|
234
233
|
|
|
235
234
|
export const createMeta = <T = any>(
|
|
236
235
|
{ meta = {}, parent = "", property, propertySignatures }: CreateMeta,
|
|
237
|
-
acc: Partial<MetaRecord<T>> = {}
|
|
236
|
+
acc: Partial<MetaRecord<T>> = {}
|
|
238
237
|
): MetaRecord<T> | FieldMeta => {
|
|
239
238
|
if (property && property._tag === "Transformation") {
|
|
240
239
|
return createMeta<T>({
|
|
@@ -260,11 +259,11 @@ export const createMeta = <T = any>(
|
|
|
260
259
|
const typeToProcess = p.type
|
|
261
260
|
if (S.AST.isUnion(p.type)) {
|
|
262
261
|
const nonNullTypes = p.type.types.filter(
|
|
263
|
-
t => t._tag !== "UndefinedKeyword" && t !== S.Null.ast
|
|
262
|
+
t => t._tag !== "UndefinedKeyword" && t !== S.Null.ast
|
|
264
263
|
)
|
|
265
264
|
|
|
266
265
|
const hasStructMembers = nonNullTypes.some(
|
|
267
|
-
t => "propertySignatures" in t
|
|
266
|
+
t => "propertySignatures" in t
|
|
268
267
|
)
|
|
269
268
|
|
|
270
269
|
if (hasStructMembers) {
|
|
@@ -285,7 +284,7 @@ export const createMeta = <T = any>(
|
|
|
285
284
|
parent: key,
|
|
286
285
|
propertySignatures: nonNullType.propertySignatures,
|
|
287
286
|
meta: { required: isRequired, nullableOrUndefined },
|
|
288
|
-
})
|
|
287
|
+
})
|
|
289
288
|
)
|
|
290
289
|
}
|
|
291
290
|
}
|
|
@@ -306,7 +305,7 @@ export const createMeta = <T = any>(
|
|
|
306
305
|
parent: key,
|
|
307
306
|
propertySignatures: typeToProcess.propertySignatures,
|
|
308
307
|
meta: { required: isRequired, nullableOrUndefined },
|
|
309
|
-
})
|
|
308
|
+
})
|
|
310
309
|
)
|
|
311
310
|
} else {
|
|
312
311
|
const newMeta = createMeta<T>({
|
|
@@ -329,7 +328,7 @@ export const createMeta = <T = any>(
|
|
|
329
328
|
|
|
330
329
|
if (S.AST.isUnion(property)) {
|
|
331
330
|
const nonNullType = property.types.find(
|
|
332
|
-
t => t._tag !== "UndefinedKeyword" && t !== S.Null.ast
|
|
331
|
+
t => t._tag !== "UndefinedKeyword" && t !== S.Null.ast
|
|
333
332
|
)!
|
|
334
333
|
|
|
335
334
|
if ("propertySignatures" in nonNullType) {
|
|
@@ -369,7 +368,7 @@ export const createMeta = <T = any>(
|
|
|
369
368
|
|
|
370
369
|
const JSONAnnotation = S.AST.getAnnotation(
|
|
371
370
|
property,
|
|
372
|
-
S.AST.JSONSchemaAnnotationId
|
|
371
|
+
S.AST.JSONSchemaAnnotationId
|
|
373
372
|
).pipe(Option.getOrElse(() => ({}))) as Record<string, unknown>
|
|
374
373
|
|
|
375
374
|
meta = { ...meta, ...JSONAnnotation }
|
|
@@ -383,11 +382,11 @@ export const createMeta = <T = any>(
|
|
|
383
382
|
} else {
|
|
384
383
|
meta["type"] = S.AST.getAnnotation(
|
|
385
384
|
property,
|
|
386
|
-
S.AST.TitleAnnotationId
|
|
385
|
+
S.AST.TitleAnnotationId
|
|
387
386
|
).pipe(
|
|
388
387
|
Option.getOrElse(() => {
|
|
389
388
|
return "unknown"
|
|
390
|
-
})
|
|
389
|
+
})
|
|
391
390
|
)
|
|
392
391
|
}
|
|
393
392
|
|
|
@@ -398,7 +397,7 @@ export const createMeta = <T = any>(
|
|
|
398
397
|
}
|
|
399
398
|
|
|
400
399
|
const flattenMeta = <From, To>(
|
|
401
|
-
schema: S.Schema<From, To, never
|
|
400
|
+
schema: S.Schema<From, To, never>
|
|
402
401
|
): MetaRecord<To> => {
|
|
403
402
|
const ast = schema.ast
|
|
404
403
|
const result: MetaRecord<To> = {}
|
|
@@ -418,12 +417,12 @@ const flattenMeta = <From, To>(
|
|
|
418
417
|
|
|
419
418
|
const flattenObject = (
|
|
420
419
|
obj: Record<string, any>,
|
|
421
|
-
parentKey: string = ""
|
|
420
|
+
parentKey: string = ""
|
|
422
421
|
) => {
|
|
423
422
|
for (const key in obj) {
|
|
424
423
|
const newKey = parentKey ? `${parentKey}.${key}` : key
|
|
425
424
|
if (obj[key] && typeof obj[key] === "object" && "type" in obj[key]) {
|
|
426
|
-
result[newKey as
|
|
425
|
+
result[newKey as DeepKeys<To>] = obj[key] as FieldMeta
|
|
427
426
|
} else if (obj[key] && typeof obj[key] === "object") {
|
|
428
427
|
flattenObject(obj[key], newKey)
|
|
429
428
|
}
|
|
@@ -437,13 +436,13 @@ const flattenMeta = <From, To>(
|
|
|
437
436
|
}
|
|
438
437
|
|
|
439
438
|
export const duplicateSchema = <From, To>(
|
|
440
|
-
schema: S.Schema<From, To, never
|
|
439
|
+
schema: S.Schema<From, To, never>
|
|
441
440
|
) => {
|
|
442
441
|
return S.extend(schema, S.Struct({}))
|
|
443
442
|
}
|
|
444
443
|
|
|
445
444
|
export const generateMetaFromSchema = <From, To>(
|
|
446
|
-
schema: S.Schema<From, To, never
|
|
445
|
+
schema: S.Schema<From, To, never>
|
|
447
446
|
): {
|
|
448
447
|
schema: S.Schema<From, To, never>
|
|
449
448
|
meta: MetaRecord<To>
|
|
@@ -457,23 +456,23 @@ export const generateMetaFromSchema = <From, To>(
|
|
|
457
456
|
Option.flatMap(s => S.AST.getJSONSchemaAnnotation(s)),
|
|
458
457
|
Option.filter(s => "items" in s),
|
|
459
458
|
Option.filterMap(({ items }) =>
|
|
460
|
-
S.decodeUnknownOption(isArrayOfString)(items)
|
|
459
|
+
S.decodeUnknownOption(isArrayOfString)(items)
|
|
461
460
|
),
|
|
462
461
|
Option.zipWith(
|
|
463
462
|
S.AST.getMessageAnnotation(schema.ast),
|
|
464
463
|
(items, message) => ({
|
|
465
464
|
items,
|
|
466
465
|
message: message("" as unknown as S.ParseResult.ParseIssue),
|
|
467
|
-
})
|
|
466
|
+
})
|
|
468
467
|
),
|
|
469
|
-
Option.getOrUndefined
|
|
468
|
+
Option.getOrUndefined
|
|
470
469
|
)
|
|
471
470
|
|
|
472
471
|
return { schema, meta, filterItems }
|
|
473
472
|
}
|
|
474
473
|
|
|
475
474
|
export const generateInputStandardSchemaFromFieldMeta = (
|
|
476
|
-
meta: FieldMeta
|
|
475
|
+
meta: FieldMeta
|
|
477
476
|
): StandardSchemaV1<any, any> => {
|
|
478
477
|
const { trans } = useIntl()
|
|
479
478
|
let schema: S.Schema<any, any, never>
|
|
@@ -488,7 +487,7 @@ export const generateInputStandardSchemaFromFieldMeta = (
|
|
|
488
487
|
schema,
|
|
489
488
|
S.Email.annotations({
|
|
490
489
|
message: () => trans("validation.email.invalid"),
|
|
491
|
-
})
|
|
490
|
+
})
|
|
492
491
|
)
|
|
493
492
|
}
|
|
494
493
|
|
|
@@ -601,7 +600,7 @@ export const generateInputStandardSchemaFromFieldMeta = (
|
|
|
601
600
|
schema.pipe(
|
|
602
601
|
S.annotations({
|
|
603
602
|
message: () => trans("validation.empty"),
|
|
604
|
-
})
|
|
603
|
+
})
|
|
605
604
|
)
|
|
606
605
|
}
|
|
607
606
|
const result = S.standardSchemaV1(schema)
|
|
@@ -610,11 +609,11 @@ export const generateInputStandardSchemaFromFieldMeta = (
|
|
|
610
609
|
|
|
611
610
|
export const nullableInput = <A, I, R>(
|
|
612
611
|
schema: S.Schema<A, I, R>,
|
|
613
|
-
defaultValue: () => A
|
|
612
|
+
defaultValue: () => A
|
|
614
613
|
) =>
|
|
615
614
|
S.NullOr(schema).pipe(
|
|
616
615
|
S.transform(S.typeSchema(schema), {
|
|
617
616
|
decode: input => input ?? defaultValue(),
|
|
618
617
|
encode: input => input,
|
|
619
|
-
})
|
|
618
|
+
})
|
|
620
619
|
)
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
...validators,
|
|
8
8
|
}"
|
|
9
9
|
>
|
|
10
|
-
|
|
10
|
+
<template #default="{ field }">
|
|
11
11
|
<OmegaInternalInput
|
|
12
12
|
v-if="meta"
|
|
13
13
|
:field="field"
|
|
@@ -33,7 +33,6 @@ import {
|
|
|
33
33
|
type OmegaInputProps,
|
|
34
34
|
} from "./OmegaFormStuff"
|
|
35
35
|
import OmegaInternalInput from "./OmegaInternalInput.vue"
|
|
36
|
-
import type { OmegaFieldInternalApi } from "./InputProps"
|
|
37
36
|
|
|
38
37
|
const props = defineProps<OmegaInputProps<From, To>>()
|
|
39
38
|
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
@update:model-value="
|
|
65
65
|
(e: any) => {
|
|
66
66
|
if (e || e === 0) {
|
|
67
|
-
|
|
67
|
+
inputProps.field.handleChange(Number(e))
|
|
68
68
|
} else {
|
|
69
69
|
inputProps.field.handleChange(undefined)
|
|
70
70
|
}
|
|
@@ -112,11 +112,11 @@
|
|
|
112
112
|
</div>
|
|
113
113
|
</template>
|
|
114
114
|
|
|
115
|
-
<script setup lang="ts" generic="T">
|
|
115
|
+
<script setup lang="ts" generic="T, S">
|
|
116
116
|
import type { InputProps } from "./InputProps"
|
|
117
117
|
|
|
118
118
|
defineProps<{
|
|
119
|
-
inputProps: InputProps<T>
|
|
119
|
+
inputProps: InputProps<T, S>
|
|
120
120
|
vuetifyValue: unknown
|
|
121
121
|
}>()
|
|
122
122
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
</slot>
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
|
-
<script setup lang="ts" generic="To">
|
|
14
|
+
<script setup lang="ts" generic="From, To">
|
|
15
15
|
import { useStore } from "@tanstack/vue-form"
|
|
16
16
|
import {
|
|
17
17
|
useId,
|
|
@@ -39,12 +39,12 @@ defineOptions({
|
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
const props = defineProps<{
|
|
42
|
-
field: OmegaFieldInternalApi<To>
|
|
43
|
-
meta: MetaRecord<
|
|
42
|
+
field: OmegaFieldInternalApi<From, To>
|
|
43
|
+
meta: MetaRecord<From>[NestedKeyOf<From>]
|
|
44
44
|
label: string
|
|
45
45
|
options?: { title: string; value: string }[]
|
|
46
46
|
type?: TypeOverride
|
|
47
|
-
validators?: FieldValidators<
|
|
47
|
+
validators?: FieldValidators<From>
|
|
48
48
|
}>()
|
|
49
49
|
|
|
50
50
|
const instance = getCurrentInstance()
|
|
@@ -143,7 +143,7 @@ watch(
|
|
|
143
143
|
},
|
|
144
144
|
)
|
|
145
145
|
|
|
146
|
-
const inputProps: ComputedRef<InputProps<To>> = computed(() => ({
|
|
146
|
+
const inputProps: ComputedRef<InputProps<From, To>> = computed(() => ({
|
|
147
147
|
id,
|
|
148
148
|
required: props.meta?.required,
|
|
149
149
|
minLength: props.meta?.type === "string" && props.meta?.minLength,
|
|
@@ -84,7 +84,7 @@ const props = defineProps<
|
|
|
84
84
|
} & FormProps<To, From> &
|
|
85
85
|
(
|
|
86
86
|
| {
|
|
87
|
-
form: OmegaFormReturn<
|
|
87
|
+
form: OmegaFormReturn<From, To>
|
|
88
88
|
schema?: undefined
|
|
89
89
|
}
|
|
90
90
|
| {
|
|
@@ -158,7 +158,7 @@ const formIsSubmitting = useStore(
|
|
|
158
158
|
)
|
|
159
159
|
|
|
160
160
|
const subscribedValues = getOmegaStore(
|
|
161
|
-
formToUse.value as OmegaFormApi<
|
|
161
|
+
formToUse.value as unknown as OmegaFormApi<From, To>,
|
|
162
162
|
props.subscribe,
|
|
163
163
|
)
|
|
164
164
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as OmegaForm } from "./OmegaWrapper.vue"
|
|
2
2
|
import { default as OmegaInput } from "./OmegaInput.vue"
|
|
3
|
+
import { default as OmegaFormInput } from "./OmegaFormInput.vue"
|
|
3
4
|
import { default as OmegaErrors } from "./OmegaErrors.vue"
|
|
4
5
|
import { default as OmegaAutoGen } from "./OmegaAutoGen.vue"
|
|
5
6
|
import { default as OmegaArray } from "./OmegaArray.vue"
|
|
@@ -9,4 +10,4 @@ export * from "./OmegaFormStuff"
|
|
|
9
10
|
export { useOmegaForm, type OmegaFormReturn } from "./useOmegaForm"
|
|
10
11
|
export { default } from "./OmegaWrapper.vue"
|
|
11
12
|
|
|
12
|
-
export { OmegaForm, OmegaInput, OmegaErrors, OmegaAutoGen, OmegaArray }
|
|
13
|
+
export { OmegaForm, OmegaInput, OmegaFormInput, OmegaErrors, OmegaAutoGen, OmegaArray }
|