@volverjs/form-vue 1.0.0-beta.9 → 1.0.0

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/src/index.ts CHANGED
@@ -1,134 +1,158 @@
1
1
  import {
2
- getCurrentInstance,
3
- type App,
4
- inject,
5
- type InjectionKey,
6
- type Plugin,
2
+ getCurrentInstance,
3
+
4
+ inject,
5
+
7
6
  } from 'vue'
8
- import { defineFormField } from './VvFormField'
7
+ import type { App, InjectionKey, Plugin } from 'vue'
8
+ import type { AnyZodObject } from 'zod'
9
9
  import { defineForm } from './VvForm'
10
+ import { defineFormField } from './VvFormField'
11
+ import { defineFormFieldsGroup } from './VvFormFieldsGroup'
10
12
  import { defineFormWrapper } from './VvFormWrapper'
11
13
  import { defineFormTemplate } from './VvFormTemplate'
12
14
  import type {
13
- InjectedFormData,
14
- InjectedFormWrapperData,
15
- InjectedFormFieldData,
16
- FormComposableOptions,
17
- FormPluginOptions,
18
- FormTemplateItem,
19
- Path,
20
- PathValue,
21
- FormSchema,
22
- FormTemplate,
15
+ InjectedFormData,
16
+ InjectedFormWrapperData,
17
+ InjectedFormFieldData,
18
+ InjectedFormFieldsGroupData,
19
+ FormComposableOptions,
20
+ FormPluginOptions,
21
+ FormTemplateItem,
22
+ Path,
23
+ PathValue,
24
+ FormSchema,
25
+ FormTemplate,
23
26
  } from './types'
24
- import type { AnyZodObject } from 'zod'
25
27
 
26
- const _formFactory = <Schema extends FormSchema>(
27
- schema: Schema,
28
- options: FormComposableOptions<Schema> = {},
29
- ) => {
30
- // create injection keys
31
- const formInjectionKey = Symbol() as InjectionKey<InjectedFormData<Schema>>
32
- const formWrapperInjectionKey = Symbol() as InjectionKey<
33
- InjectedFormWrapperData<Schema>
34
- >
35
- const formFieldInjectionKey = Symbol() as InjectionKey<
36
- InjectedFormFieldData<Schema>
37
- >
28
+ function _formType<Schema extends FormSchema, Type>(schema: Schema, options: FormComposableOptions<Schema, Type> = {}) {
29
+ // create injection keys
30
+ const formInjectionKey = Symbol('formInjectionKey') as InjectionKey<InjectedFormData<Schema, Type>>
31
+ const formWrapperInjectionKey = Symbol('formWrapperInjectionKey') as InjectionKey<
32
+ InjectedFormWrapperData<Schema>
33
+ >
34
+ const formFieldInjectionKey = Symbol('formFieldInjectionKey') as InjectionKey<
35
+ InjectedFormFieldData<Schema>
36
+ >
37
+ const formFieldsGroupInjectionKey = Symbol('formFieldsGroupInjectionKey') as InjectionKey<
38
+ InjectedFormFieldsGroupData<Schema>
39
+ >
38
40
 
39
- // create components
40
- const VvFormWrapper = defineFormWrapper(
41
- formInjectionKey,
42
- formWrapperInjectionKey,
43
- )
44
- const VvFormField = defineFormField(
45
- formInjectionKey,
46
- formWrapperInjectionKey,
47
- formFieldInjectionKey,
48
- options,
49
- )
50
- const VvFormTemplate = defineFormTemplate(formInjectionKey, VvFormField)
51
- const {
52
- VvForm,
53
- errors,
54
- status,
55
- invalid,
56
- readonly,
57
- formData,
58
- validate,
59
- submit,
60
- ignoreUpdates,
61
- stopUpdatesWatch,
62
- } = defineForm(schema, formInjectionKey, options, VvFormTemplate)
41
+ // create components
42
+ const VvFormWrapper = defineFormWrapper<Schema, Type>(
43
+ formInjectionKey,
44
+ formWrapperInjectionKey,
45
+ )
46
+ const VvFormField = defineFormField<Schema, Type>(
47
+ formInjectionKey,
48
+ formWrapperInjectionKey,
49
+ formFieldInjectionKey,
50
+ options,
51
+ )
52
+ const VvFormFieldsGroup = defineFormFieldsGroup<Schema, Type>(
53
+ formInjectionKey,
54
+ formWrapperInjectionKey,
55
+ formFieldsGroupInjectionKey,
56
+ )
57
+ const VvFormTemplate = defineFormTemplate<Schema, Type>(formInjectionKey, VvFormField)
58
+ const wrappers = new Map<string, InjectedFormWrapperData<Schema>>()
59
+ const {
60
+ clear,
61
+ errors,
62
+ formData,
63
+ ignoreUpdates,
64
+ invalid,
65
+ readonly,
66
+ reset,
67
+ status,
68
+ stopUpdatesWatch,
69
+ submit,
70
+ validate,
71
+ VvForm,
72
+ } = defineForm(schema, formInjectionKey, options, VvFormTemplate, wrappers)
63
73
 
64
- return {
65
- VvForm,
66
- VvFormWrapper,
67
- VvFormField,
68
- VvFormTemplate,
69
- formInjectionKey,
70
- formWrapperInjectionKey,
71
- formFieldInjectionKey,
72
- errors,
73
- status,
74
- invalid,
75
- readonly,
76
- formData,
77
- validate,
78
- submit,
79
- ignoreUpdates,
80
- stopUpdatesWatch,
81
- }
74
+ return {
75
+ clear,
76
+ errors,
77
+ formData,
78
+ formFieldInjectionKey,
79
+ formInjectionKey,
80
+ formWrapperInjectionKey,
81
+ ignoreUpdates,
82
+ invalid,
83
+ readonly,
84
+ reset,
85
+ status,
86
+ stopUpdatesWatch,
87
+ submit,
88
+ validate,
89
+ wrappers,
90
+ VvForm,
91
+ VvFormField,
92
+ VvFormFieldsGroup,
93
+ VvFormTemplate,
94
+ VvFormWrapper,
95
+ }
82
96
  }
83
97
 
84
- export const pluginInjectionKey = Symbol() as InjectionKey<FormPluginOptions>
98
+ export const pluginInjectionKey = Symbol('pluginInjectionKey') as InjectionKey<FormPluginOptions>
85
99
 
86
- export const createForm = (
87
- options: FormPluginOptions,
88
- ): Plugin & Partial<ReturnType<typeof useForm>> => {
89
- let toReturn: Partial<ReturnType<typeof useForm>> = {}
90
- if (options.schema) {
91
- toReturn = _formFactory(options.schema as AnyZodObject, options)
92
- }
93
- return {
94
- ...toReturn,
95
- install(app: App, { global = false } = {}) {
96
- app.provide(pluginInjectionKey, options)
100
+ export function createForm(options: FormPluginOptions): Plugin & Partial<ReturnType<typeof useForm>> {
101
+ let toReturn: Partial<ReturnType<typeof useForm>> = {}
102
+ if (options.schema) {
103
+ toReturn = _formType(options.schema as AnyZodObject, options)
104
+ }
105
+ return {
106
+ ...toReturn,
107
+ install(app: App, { global = false } = {}) {
108
+ app.provide(pluginInjectionKey, options)
97
109
 
98
- if (global) {
99
- app.config.globalProperties.$vvForm = options
110
+ if (global) {
111
+ app.config.globalProperties.$vvForm = options
100
112
 
101
- if (toReturn?.VvForm) {
102
- app.component('VvForm', toReturn.VvForm)
103
- }
104
- if (toReturn?.VvFormWrapper) {
105
- app.component('VvFormWrapper', toReturn.VvFormWrapper)
106
- }
107
- if (toReturn?.VvFormField) {
108
- app.component('VvFormField', toReturn.VvFormField)
109
- }
110
- if (toReturn?.VvFormTemplate) {
111
- app.component('VvFormTemplate', toReturn.VvFormTemplate)
112
- }
113
- }
114
- },
115
- }
113
+ if (toReturn?.VvForm) {
114
+ app.component('VvForm', toReturn.VvForm)
115
+ }
116
+ if (toReturn?.VvFormWrapper) {
117
+ app.component('VvFormWrapper', toReturn.VvFormWrapper)
118
+ }
119
+ if (toReturn?.VvFormField) {
120
+ app.component('VvFormField', toReturn.VvFormField)
121
+ }
122
+ if (toReturn?.VvFormFieldsGroup) {
123
+ app.component('VvFormFieldsGroup', toReturn.VvFormFieldsGroup)
124
+ }
125
+ if (toReturn?.VvFormTemplate) {
126
+ app.component('VvFormTemplate', toReturn.VvFormTemplate)
127
+ }
128
+ }
129
+ },
130
+ }
116
131
  }
117
132
 
118
- export const useForm = <Schema extends FormSchema>(
119
- schema: Schema,
120
- options: FormComposableOptions<Schema> = {},
121
- ) => {
122
- if (!getCurrentInstance()) {
123
- return _formFactory(schema, options)
124
- }
125
- return _formFactory(
126
- schema as AnyZodObject,
127
- {
128
- ...inject(pluginInjectionKey, {}),
129
- ...options,
130
- } as FormComposableOptions<AnyZodObject>,
131
- )
133
+ const formInstances: Map<string, ReturnType<typeof _formType>> = new Map()
134
+ export function useForm<Schema extends FormSchema, Type>(schema: Schema, options: FormComposableOptions<Schema, Type> = {}): ReturnType <typeof _formType<Schema, Type>> {
135
+ if (options.scope && formInstances.has(options.scope)) {
136
+ return formInstances.get(options.scope)
137
+ }
138
+ if (!getCurrentInstance()) {
139
+ const toReturn = _formType(schema, options)
140
+ if (options.scope) {
141
+ formInstances.set(options.scope, toReturn)
142
+ }
143
+ return toReturn
144
+ }
145
+ const toReturn = _formType(
146
+ schema,
147
+ {
148
+ ...inject(pluginInjectionKey, {}),
149
+ ...options,
150
+ } as FormComposableOptions<Schema, Type>,
151
+ )
152
+ if (options.scope) {
153
+ formInstances.set(options.scope, toReturn)
154
+ }
155
+ return toReturn
132
156
  }
133
157
 
134
158
  export { FormFieldType } from './enums'
@@ -137,31 +161,30 @@ export { defaultObjectBySchema } from './utils'
137
161
  type FormComponent = ReturnType<typeof defineForm>
138
162
  type FormWrapperComponent = ReturnType<typeof defineFormWrapper>
139
163
  type FormFieldComponent = ReturnType<typeof defineFormField>
140
- type FormTemplateComponent = ReturnType<typeof defineFormTemplate>
164
+ type FormFieldsGroupComponent = ReturnType<typeof defineFormFieldsGroup>
165
+ type FormTemplateComponent = ReturnType<typeof defineFormFieldsGroup>
141
166
 
142
167
  export type {
143
- InjectedFormData,
144
- InjectedFormWrapperData,
145
- InjectedFormFieldData,
146
- FormComposableOptions,
147
- FormSchema,
148
- FormPluginOptions,
149
- FormComponent,
150
- FormWrapperComponent,
151
- FormFieldComponent,
152
- FormTemplate,
153
- FormTemplateComponent,
154
- FormTemplateItem,
155
- Path,
156
- PathValue,
168
+ FormComponent,
169
+ FormComposableOptions,
170
+ FormFieldComponent,
171
+ FormFieldsGroupComponent,
172
+ FormPluginOptions,
173
+ FormSchema,
174
+ FormTemplate,
175
+ FormTemplateComponent,
176
+ FormTemplateItem,
177
+ FormWrapperComponent,
178
+ InjectedFormData,
179
+ InjectedFormFieldData,
180
+ InjectedFormWrapperData,
181
+ Path,
182
+ PathValue,
157
183
  }
158
184
 
159
185
  /**
160
186
  * @deprecated Use `useForm()` instead
161
187
  */
162
- export const formFactory = <Schema extends FormSchema>(
163
- schema: Schema,
164
- options: FormComposableOptions<Schema> = {},
165
- ) => {
166
- return _formFactory(schema, options)
188
+ export function formType<Schema extends FormSchema, Type>(schema: Schema, options: FormComposableOptions<Schema, Type> = {}) {
189
+ return _formType(schema, options)
167
190
  }
package/src/types.ts CHANGED
@@ -1,158 +1,195 @@
1
- import type { Component, DeepReadonly, Ref, WatchStopHandle } from 'vue'
2
- import type { z, AnyZodObject, ZodEffects, inferFormattedError } from 'zod'
1
+ import type { Component, DeepReadonly, Ref, RendererElement, RendererNode, VNode, WatchStopHandle } from 'vue'
2
+ import type { z, AnyZodObject, ZodEffects, ZodOptional, ZodTypeAny, RefinementCtx } from 'zod'
3
3
  import type { IgnoredUpdater } from '@vueuse/core'
4
4
  import type { FormFieldType, FormStatus } from './enums'
5
5
 
6
- export type FormSchema =
7
- | AnyZodObject
8
- | ZodEffects<AnyZodObject>
9
- | ZodEffects<ZodEffects<AnyZodObject>>
6
+ type Depth = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] // Adjust the depth limit as needed
7
+
8
+ type DecrementDepth<D extends Depth[number]> = Depth[D]
9
+
10
+ export type EffectType<T extends ZodTypeAny, D extends Depth[number] = 10>
11
+ = D extends 0
12
+ ? T
13
+ : T | ZodOptional<T> | ZodEffects<EffectType<T, DecrementDepth<D>>>
14
+
15
+ export type FormSchema = EffectType<AnyZodObject>
10
16
 
11
17
  export type FormFieldComponentOptions = {
12
- lazyLoad?: boolean
13
- sideEffects?: (type: `${FormFieldType}`) => Promise<void> | void
18
+ lazyLoad?: boolean
19
+ sideEffects?: (type: `${FormFieldType}`) => Promise<void> | void
14
20
  }
15
21
 
16
- export type FormComponentOptions<Schema> = {
17
- updateThrottle?: number
18
- continuosValidation?: boolean
19
- readonly?: boolean
20
- template?: Schema extends FormSchema ? FormTemplate<Schema> : never
21
- onUpdate?: Schema extends FormSchema
22
- ? (data: Partial<z.infer<Schema> | undefined>) => void
23
- : never
24
- onSubmit?: Schema extends FormSchema
25
- ? (data: z.infer<Schema>) => void
26
- : never
27
- onInvalid?: Schema extends FormSchema
28
- ? (error: inferFormattedError<Schema, string>) => void
29
- : never
30
- onValid?: Schema extends FormSchema
31
- ? (data: z.infer<Schema>) => void
32
- : never
22
+ export type FormComponentOptions<Schema, Type> = {
23
+ updateThrottle?: number
24
+ continuousValidation?: boolean
25
+ readonly?: boolean
26
+ template?: Schema extends FormSchema ? FormTemplate<Schema, Type> : never
27
+ class?: Schema extends FormSchema ? new (data?: Partial<z.infer<Schema>>) => Type : never
28
+ onUpdate?: Schema extends FormSchema
29
+ ? (data?: undefined extends Type ? Partial<z.infer<Schema>> : Type) => void
30
+ : never
31
+ onSubmit?: Schema extends FormSchema
32
+ ? (data?: undefined extends Type ? Partial<z.infer<Schema>> : Type) => void
33
+ : never
34
+ onReset?: Schema extends FormSchema ? (data?: undefined extends Type ? Partial<z.infer<Schema>> : Type) => void : never
35
+ onInvalid?: Schema extends FormSchema
36
+ ? (error?: z.inferFormattedError<Schema>) => void
37
+ : never
38
+ onValid?: Schema extends FormSchema
39
+ ? (data?: undefined extends Type ? Partial<z.infer<Schema>> : Type) => void
40
+ : never
33
41
  }
34
42
 
35
- export type FormComposableOptions<Schema> = FormFieldComponentOptions &
36
- FormComponentOptions<Schema>
43
+ export type FormComposableOptions<Schema, Type> = FormFieldComponentOptions
44
+ & FormComponentOptions<Schema, Type> & {
45
+ scope?: string
46
+ }
37
47
 
38
- type FormPluginOptionsSchema = {
39
- schema?: FormSchema
48
+ type FormPluginOptionsSchema<T = Partial<z.infer<FormSchema>>> = {
49
+ schema?: FormSchema
50
+ factory?: (data?: Partial<z.infer<FormSchema>>) => T
40
51
  }
41
52
 
42
- export type FormPluginOptions = FormPluginOptionsSchema &
43
- FormComposableOptions<FormPluginOptionsSchema['schema']>
44
-
45
- export type InjectedFormData<Schema extends FormSchema> = {
46
- formData: Ref<Partial<z.infer<Schema>> | undefined>
47
- errors: Readonly<
48
- Ref<DeepReadonly<z.inferFormattedError<Schema>> | undefined>
49
- >
50
- submit: () => Promise<boolean>
51
- validate: () => Promise<boolean>
52
- ignoreUpdates: IgnoredUpdater
53
- stopUpdatesWatch: WatchStopHandle
54
- status: Readonly<Ref<FormStatus | undefined>>
55
- invalid: Readonly<Ref<boolean>>
56
- readonly: Ref<boolean>
53
+ export type FormPluginOptions = FormPluginOptionsSchema
54
+ & FormComposableOptions<FormPluginOptionsSchema['schema'], FormPluginOptionsSchema['factory']>
55
+
56
+ export type InjectedFormData<Schema extends FormSchema, Type> = {
57
+ formData: Ref<(undefined extends Type ? Partial<z.infer<Schema>> : Type) | undefined>
58
+ errors: Readonly<
59
+ Ref<DeepReadonly<z.inferFormattedError<Schema>> | undefined>
60
+ >
61
+ submit: () => Promise<boolean>
62
+ validate: (formData?: undefined extends Type ? Partial<z.infer<Schema>> : Type, options?: { fields?: Set<Path<z.infer<Schema>>>, superRefine?: (arg: z.infer<Schema>, ctx: RefinementCtx) => void | Promise<void> }) => Promise<boolean>
63
+ clear: () => void
64
+ reset: () => void
65
+ ignoreUpdates: IgnoredUpdater
66
+ stopUpdatesWatch: WatchStopHandle
67
+ status: Readonly<Ref<FormStatus | undefined>>
68
+ invalid: Readonly<Ref<boolean>>
69
+ readonly: Ref<boolean>
70
+ wrappers: Map<string, InjectedFormWrapperData<Schema>>
57
71
  }
58
72
 
59
73
  export type InjectedFormWrapperData<Schema extends FormSchema> = {
60
- name: Ref<string>
61
- fields: Ref<Set<string>>
62
- errors: Ref<Map<string, z.inferFormattedError<Schema, string>>>
74
+ name: Readonly<Ref<string>>
75
+ errors: Ref<Map<string, z.inferFormattedError<Schema>>>
76
+ invalid: Readonly<Ref<boolean>>
77
+ readonly: Readonly<Ref<boolean>>
78
+ fields: Ref<Map<string, string>>
63
79
  }
64
80
 
65
81
  export type InjectedFormFieldData<Schema extends FormSchema> = {
66
- name: Ref<string>
67
- errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema>>>>
82
+ name: Readonly<Ref<Path<z.infer<Schema>>>>
83
+ errors: Readonly<Ref<DeepReadonly<z.inferFormattedError<Schema>>>>
68
84
  }
69
85
 
70
- export type Primitive =
71
- | null
72
- | undefined
73
- | string
74
- | number
75
- | boolean
76
- | symbol
77
- | bigint
86
+ export type InjectedFormFieldsGroupData<Schema extends FormSchema> = {
87
+ names: DeepReadonly<Ref<Path<z.infer<Schema>>[]>>
88
+ errors: Readonly<Ref<DeepReadonly<Record<string, z.inferFormattedError<Schema>> | undefined>>>
89
+ }
90
+
91
+ export type Primitive
92
+ = | null
93
+ | undefined
94
+ | string
95
+ | number
96
+ | boolean
97
+ | symbol
98
+ | bigint
78
99
 
79
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
100
  type IsTuple<T extends readonly any[]> = number extends T['length']
81
- ? false
82
- : true
101
+ ? false
102
+ : true
83
103
 
84
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
104
  type TupleKeys<T extends readonly any[]> = Exclude<keyof T, keyof any[]>
86
105
 
87
106
  export type PathConcat<
88
- TKey extends string | number,
89
- TValue,
107
+ TKey extends string | number,
108
+ TValue,
90
109
  > = TValue extends Primitive ? `${TKey}` : `${TKey}` | `${TKey}.${Path<TValue>}`
91
110
 
92
111
  export type Path<T> = T extends readonly (infer V)[]
93
- ? IsTuple<T> extends true
94
- ? {
95
- [K in TupleKeys<T>]-?: PathConcat<K & string, T[K]>
96
- }[TupleKeys<T>]
97
- : PathConcat<number, V>
98
- : {
99
- [K in keyof T]-?: PathConcat<K & string, T[K]>
100
- }[keyof T]
101
-
102
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
+ ? IsTuple<T> extends true
113
+ ? {
114
+ [K in TupleKeys<T>]-?: PathConcat<K & string, T[K]>
115
+ }[TupleKeys<T>]
116
+ : PathConcat<number, V>
117
+ : {
118
+ [K in keyof T]-?: PathConcat<K & string, T[K]>
119
+ }[keyof T]
120
+
103
121
  export type PathValue<T, TPath extends Path<T> | Path<T>[]> = T extends any
104
- ? TPath extends `${infer K}.${infer R}`
105
- ? K extends keyof T
106
- ? R extends Path<T[K]>
107
- ? undefined extends T[K]
108
- ? PathValue<T[K], R> | undefined
109
- : PathValue<T[K], R>
110
- : never
111
- : K extends `${number}`
112
- ? T extends readonly (infer V)[]
113
- ? PathValue<V, R & Path<V>>
114
- : never
115
- : never
116
- : TPath extends keyof T
117
- ? T[TPath]
118
- : TPath extends `${number}`
119
- ? T extends readonly (infer V)[]
120
- ? V
121
- : never
122
- : never
123
- : never
124
-
125
- export type AnyBoolean<Schema extends FormSchema> =
126
- | boolean
127
- | Ref<boolean>
128
- | ((data?: InjectedFormData<Schema>) => boolean | Ref<boolean>)
129
-
130
- export type SimpleFormTemplateItem<Schema extends FormSchema> = Record<
131
- string,
132
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
133
- any
122
+ ? TPath extends `${infer K}.${infer R}`
123
+ ? K extends keyof T
124
+ ? R extends Path<T[K]>
125
+ ? undefined extends T[K]
126
+ ? PathValue<T[K], R> | undefined
127
+ : PathValue<T[K], R>
128
+ : never
129
+ : K extends `${number}`
130
+ ? T extends readonly (infer V)[]
131
+ ? PathValue<V, R & Path<V>>
132
+ : never
133
+ : never
134
+ : TPath extends keyof T
135
+ ? T[TPath]
136
+ : TPath extends `${number}`
137
+ ? T extends readonly (infer V)[]
138
+ ? V
139
+ : never
140
+ : never
141
+ : never
142
+
143
+ export type AnyBoolean<Schema extends FormSchema, Type>
144
+ = | boolean
145
+ | Ref<boolean>
146
+ | ((data?: InjectedFormData<Schema, Type>) => boolean | Ref<boolean>)
147
+
148
+ export type SimpleFormTemplateItem<Schema extends FormSchema, Type> = Record<
149
+ string,
150
+ any
134
151
  > & {
135
- vvIs?: string | Component
136
- vvName?: Path<z.infer<Schema>>
137
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
138
- vvSlots?: Record<string, any>
139
- vvChildren?: Array<
140
- | SimpleFormTemplateItem<Schema>
141
- | ((data?: InjectedFormData<Schema>) => SimpleFormTemplateItem<Schema>)
142
- >
143
- vvIf?: AnyBoolean<Schema> | Path<z.infer<Schema>>
144
- vvElseIf?: AnyBoolean<Schema> | Path<z.infer<Schema>>
145
- vvType?: `${FormFieldType}`
146
- vvShowValid?: boolean
147
- vvContent?: string
148
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
149
- vvDefaultValue?: any
152
+ vvIs?: string | Component
153
+ vvName?: Path<z.infer<Schema>>
154
+ vvSlots?: Record<string, any>
155
+ vvChildren?:
156
+ | Array<
157
+ | SimpleFormTemplateItem<Schema, Type>
158
+ | ((
159
+ data?: InjectedFormData<Schema, Type>,
160
+ scope?: Record<string, unknown>,
161
+ ) => SimpleFormTemplateItem<Schema, Type>)
162
+ >
163
+ | ((
164
+ data?: InjectedFormData<Schema, Type>,
165
+ scope?: Record<string, unknown>,
166
+ ) => Array<
167
+ | SimpleFormTemplateItem<Schema, Type>
168
+ | ((
169
+ data?: InjectedFormData<Schema, Type>,
170
+ scope?: Record<string, unknown>,
171
+ ) => SimpleFormTemplateItem<Schema, Type>)
172
+ >)
173
+ vvIf?: AnyBoolean<Schema, Type> | Path<z.infer<Schema>>
174
+ vvElseIf?: AnyBoolean<Schema, Type> | Path<z.infer<Schema>>
175
+ vvType?: `${FormFieldType}`
176
+ vvShowValid?: boolean
177
+ vvContent?: string
178
+ vvDefaultValue?: any
150
179
  }
151
180
 
152
- export type FormTemplateItem<Schema extends FormSchema> =
153
- | SimpleFormTemplateItem<Schema>
154
- | ((data?: InjectedFormData<Schema>) => SimpleFormTemplateItem<Schema>)
155
-
156
- export type FormTemplate<Schema extends FormSchema> =
157
- | FormTemplateItem<Schema>[]
158
- | ((data?: InjectedFormData<Schema>) => FormTemplateItem<Schema>[])
181
+ export type FormTemplateItem<Schema extends FormSchema, Type = undefined>
182
+ = | SimpleFormTemplateItem<Schema, Type>
183
+ | ((
184
+ data?: InjectedFormData<Schema, Type>,
185
+ scope?: Record<string, unknown>,
186
+ ) => SimpleFormTemplateItem<Schema, Type>)
187
+
188
+ export type FormTemplate<Schema extends FormSchema, Type = undefined>
189
+ = | FormTemplateItem<Schema, Type>[]
190
+ | ((
191
+ data?: InjectedFormData<Schema, Type>,
192
+ scope?: Record<string, unknown>,
193
+ ) => FormTemplateItem<Schema, Type>[])
194
+
195
+ export type RenderFunctionOutput = VNode<RendererNode, RendererElement, { [key: string]: any }>