@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,43 +1,23 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/consistent-type-imports */
|
|
1
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type FormAsyncValidateOrFn,
|
|
6
|
-
type StandardSchemaV1,
|
|
7
|
-
DeepKeys,
|
|
8
|
-
} from "@tanstack/vue-form"
|
|
9
|
-
import { type Record, S } from "effect-app"
|
|
10
|
-
import {
|
|
11
|
-
generateMetaFromSchema,
|
|
12
|
-
type NestedKeyOf,
|
|
13
|
-
type FilterItems,
|
|
14
|
-
type FormProps,
|
|
15
|
-
type MetaRecord,
|
|
16
|
-
type OmegaFormApi,
|
|
17
|
-
TypeOverride,
|
|
18
|
-
FieldValidators,
|
|
19
|
-
} from "./OmegaFormStuff"
|
|
20
|
-
import {
|
|
21
|
-
computed,
|
|
22
|
-
onBeforeUnmount,
|
|
23
|
-
onMounted,
|
|
24
|
-
onUnmounted,
|
|
25
|
-
provide,
|
|
26
|
-
type InjectionKey,
|
|
27
|
-
} from "vue"
|
|
3
|
+
|
|
4
|
+
import { type DeepKeys, type FormAsyncValidateOrFn, type FormValidateOrFn, type StandardSchemaV1, useForm } from "@tanstack/vue-form"
|
|
5
|
+
import { S } from "effect-app"
|
|
28
6
|
import { isObject } from "effect/Predicate"
|
|
7
|
+
import { computed, type InjectionKey, onBeforeUnmount, onMounted, onUnmounted, provide } from "vue"
|
|
8
|
+
import { type InputProps } from "./InputProps"
|
|
29
9
|
import OmegaFormInput from "./OmegaFormInput.vue"
|
|
30
|
-
import {
|
|
10
|
+
import { type FieldValidators, type FilterItems, type FormProps, generateMetaFromSchema, type MetaRecord, type NestedKeyOf, type OmegaFormApi, type TypeOverride } from "./OmegaFormStuff"
|
|
31
11
|
|
|
32
12
|
type keysRule<T> =
|
|
33
13
|
| {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
14
|
+
keys?: NestedKeyOf<T>[]
|
|
15
|
+
banKeys?: "You should only use one of banKeys or keys, not both, moron"
|
|
16
|
+
}
|
|
37
17
|
| {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
18
|
+
keys?: "You should only use one of banKeys or keys, not both, moron"
|
|
19
|
+
banKeys?: NestedKeyOf<T>[]
|
|
20
|
+
}
|
|
41
21
|
|
|
42
22
|
export type OmegaConfig<T> = {
|
|
43
23
|
persistency?: {
|
|
@@ -59,39 +39,59 @@ interface OF<From, To> extends OmegaFormApi<From, To> {
|
|
|
59
39
|
|
|
60
40
|
export const OmegaFormKey = Symbol("OmegaForm") as InjectionKey<OF<any, any>>
|
|
61
41
|
|
|
62
|
-
type __VLS_PrettifyLocal<T> =
|
|
63
|
-
|
|
64
|
-
|
|
42
|
+
type __VLS_PrettifyLocal<T> =
|
|
43
|
+
& {
|
|
44
|
+
[K in keyof T]: T[K]
|
|
45
|
+
}
|
|
46
|
+
& {}
|
|
65
47
|
|
|
66
|
-
export interface OmegaFormReturn<From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>>
|
|
48
|
+
export interface OmegaFormReturn<From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>>
|
|
49
|
+
extends OF<From, To>
|
|
50
|
+
{
|
|
67
51
|
// this crazy thing here is copied from the OmegaFormInput.vue.d.ts, with `From` removed as Generic, instead closed over from the From generic above..
|
|
68
|
-
Input: <Name extends DeepKeys<From>>(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
52
|
+
Input: <Name extends DeepKeys<From>>(
|
|
53
|
+
__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"],
|
|
54
|
+
__VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>,
|
|
55
|
+
__VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"],
|
|
56
|
+
__VLS_setup?: Promise<{
|
|
57
|
+
props:
|
|
58
|
+
& __VLS_PrettifyLocal<
|
|
59
|
+
Pick<
|
|
60
|
+
& Partial<{}>
|
|
61
|
+
& Omit<
|
|
62
|
+
{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps,
|
|
63
|
+
never
|
|
64
|
+
>,
|
|
65
|
+
never
|
|
66
|
+
> & {
|
|
67
|
+
name: Name
|
|
68
|
+
label: string
|
|
69
|
+
validators?: FieldValidators<From>
|
|
70
|
+
options?: {
|
|
71
|
+
title: string
|
|
72
|
+
value: string
|
|
73
|
+
}[]
|
|
74
|
+
type?: TypeOverride
|
|
75
|
+
} & Partial<{}>
|
|
76
|
+
>
|
|
77
|
+
& import("vue").PublicProps
|
|
78
|
+
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void
|
|
79
|
+
attrs: any
|
|
80
|
+
slots: {
|
|
81
|
+
default(props: InputProps<From, Name>): void
|
|
82
|
+
}
|
|
83
|
+
emit: {}
|
|
84
|
+
}>
|
|
85
|
+
) => import("vue").VNode & {
|
|
86
|
+
__ctx?: Awaited<typeof __VLS_setup>
|
|
87
|
+
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
export const useOmegaForm = <
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
92
|
From extends Record<PropertyKey, any>,
|
|
93
93
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
-
To extends Record<PropertyKey, any
|
|
94
|
+
To extends Record<PropertyKey, any>
|
|
95
95
|
>(
|
|
96
96
|
schema: S.Schema<To, From, never>,
|
|
97
97
|
tanstackFormOptions?: NoInfer<FormProps<From, To>>,
|
|
@@ -135,8 +135,8 @@ export const useOmegaForm = <
|
|
|
135
135
|
|
|
136
136
|
const defaultValues = computed(() => {
|
|
137
137
|
if (
|
|
138
|
-
tanstackFormOptions?.defaultValues
|
|
139
|
-
!omegaConfig?.persistency?.overrideDefaultValues
|
|
138
|
+
tanstackFormOptions?.defaultValues
|
|
139
|
+
&& !omegaConfig?.persistency?.overrideDefaultValues
|
|
140
140
|
) {
|
|
141
141
|
// defaultValues from tanstack are not partial,
|
|
142
142
|
// so if ovverrideDefaultValues is false we simply return them
|
|
@@ -166,9 +166,9 @@ export const useOmegaForm = <
|
|
|
166
166
|
|
|
167
167
|
if (
|
|
168
168
|
// query string has higher priority than local/session storage
|
|
169
|
-
!defValuesPatch
|
|
170
|
-
(persistency.policies.includes("local")
|
|
171
|
-
persistency.policies.includes("session"))
|
|
169
|
+
!defValuesPatch
|
|
170
|
+
&& (persistency.policies.includes("local")
|
|
171
|
+
|| persistency.policies.includes("session"))
|
|
172
172
|
) {
|
|
173
173
|
const storage = persistency.policies.includes("local")
|
|
174
174
|
? localStorage
|
|
@@ -213,17 +213,17 @@ export const useOmegaForm = <
|
|
|
213
213
|
...tanstackFormOptions,
|
|
214
214
|
validators: {
|
|
215
215
|
onSubmit: standardSchema,
|
|
216
|
-
...(tanstackFormOptions?.validators || {})
|
|
216
|
+
...(tanstackFormOptions?.validators || {})
|
|
217
217
|
},
|
|
218
218
|
onSubmit: tanstackFormOptions?.onSubmit
|
|
219
219
|
? ({ formApi, meta, value }) =>
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
220
|
+
tanstackFormOptions.onSubmit?.({
|
|
221
|
+
formApi: formApi as OmegaFormApi<From, To>,
|
|
222
|
+
meta,
|
|
223
|
+
value: value as unknown as To
|
|
224
|
+
})
|
|
225
225
|
: undefined,
|
|
226
|
-
defaultValues: defaultValues.value as any
|
|
226
|
+
defaultValues: defaultValues.value as any
|
|
227
227
|
}) satisfies OmegaFormApi<To, From>
|
|
228
228
|
|
|
229
229
|
const clear = () => {
|
|
@@ -252,9 +252,7 @@ export const useOmegaForm = <
|
|
|
252
252
|
return createNestedObjectFromPaths(persistency.keys)
|
|
253
253
|
}
|
|
254
254
|
if (Array.isArray(persistency.banKeys)) {
|
|
255
|
-
const subs = Object.keys(meta).filter(metakey =>
|
|
256
|
-
persistency.banKeys?.includes(metakey as any)
|
|
257
|
-
)
|
|
255
|
+
const subs = Object.keys(meta).filter((metakey) => persistency.banKeys?.includes(metakey as any))
|
|
258
256
|
return createNestedObjectFromPaths(subs)
|
|
259
257
|
}
|
|
260
258
|
return form.store.state.values
|
|
@@ -266,8 +264,8 @@ export const useOmegaForm = <
|
|
|
266
264
|
return
|
|
267
265
|
}
|
|
268
266
|
if (
|
|
269
|
-
persistency.policies.includes("local")
|
|
270
|
-
persistency.policies.includes("session")
|
|
267
|
+
persistency.policies.includes("local")
|
|
268
|
+
|| persistency.policies.includes("session")
|
|
271
269
|
) {
|
|
272
270
|
const storage = persistency.policies.includes("local")
|
|
273
271
|
? localStorage
|
|
@@ -307,7 +305,7 @@ export const useOmegaForm = <
|
|
|
307
305
|
const formWithExtras: OF<From, To> = Object.assign(form, {
|
|
308
306
|
meta,
|
|
309
307
|
filterItems,
|
|
310
|
-
clear
|
|
308
|
+
clear
|
|
311
309
|
})
|
|
312
310
|
|
|
313
311
|
provide(OmegaFormKey, formWithExtras)
|
package/src/utils/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { inject, type InjectionKey, provide } from "vue"
|
|
2
1
|
import { type makeIntl } from "@effect-app/vue"
|
|
2
|
+
import { inject, type InjectionKey, provide } from "vue"
|
|
3
3
|
|
|
4
4
|
const intlKey = Symbol() as InjectionKey<
|
|
5
5
|
ReturnType<ReturnType<typeof makeIntl>["useIntl"]>
|
|
@@ -12,5 +12,5 @@ export const useIntl = () => {
|
|
|
12
12
|
return intl
|
|
13
13
|
}
|
|
14
14
|
export const provideIntl = (
|
|
15
|
-
intl: ReturnType<ReturnType<typeof makeIntl>["useIntl"]
|
|
15
|
+
intl: ReturnType<ReturnType<typeof makeIntl>["useIntl"]>
|
|
16
16
|
) => provide(intlKey, intl)
|
|
File without changes
|