@volverjs/form-vue 0.0.10-beta.5 → 0.0.10-beta.7
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/README.md +232 -153
- package/dist/VvForm.d.ts +150 -36
- package/dist/VvFormField.d.ts +9 -21
- package/dist/VvFormTemplate.d.ts +20 -0
- package/dist/VvFormWrapper.d.ts +10 -22
- package/dist/enums.d.ts +4 -0
- package/dist/index.d.ts +344 -83
- package/dist/index.es.js +404 -296
- package/dist/index.umd.js +1 -1
- package/dist/types.d.ts +98 -20
- package/dist/utils.d.ts +2 -13
- package/package.json +12 -11
- package/src/VvForm.ts +153 -120
- package/src/VvFormField.ts +16 -19
- package/src/VvFormTemplate.ts +179 -0
- package/src/VvFormWrapper.ts +21 -23
- package/src/enums.ts +5 -0
- package/src/index.ts +22 -19
- package/src/types.d.ts +98 -20
- package/src/utils.ts +2 -6
package/README.md
CHANGED
|
@@ -45,8 +45,8 @@ import { createForm } from '@volverjs/form-vue'
|
|
|
45
45
|
import { z } from 'zod'
|
|
46
46
|
|
|
47
47
|
const schema = z.object({
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
firstName: z.string(),
|
|
49
|
+
lastName: z.string()
|
|
50
50
|
})
|
|
51
51
|
|
|
52
52
|
const app = createApp(App)
|
|
@@ -72,16 +72,16 @@ A `valid` or `invalid` event is emitted when the form status changes.
|
|
|
72
72
|
```vue
|
|
73
73
|
<script lang="ts" setup>
|
|
74
74
|
const onSubmit = (formData) => {
|
|
75
|
-
//
|
|
75
|
+
// ...
|
|
76
76
|
}
|
|
77
77
|
const onInvalid = (errors) => {
|
|
78
|
-
//
|
|
78
|
+
// ...
|
|
79
79
|
}
|
|
80
80
|
</script>
|
|
81
81
|
|
|
82
82
|
<template>
|
|
83
83
|
<VvForm @submit="onSubmit" @invalid="onInvalid">
|
|
84
|
-
<!--
|
|
84
|
+
<!-- ... -->
|
|
85
85
|
<button type="submit">Submit</button>
|
|
86
86
|
</VvForm>
|
|
87
87
|
</template>
|
|
@@ -96,7 +96,7 @@ The submit can be triggered programmatically with the `submit()` method.
|
|
|
96
96
|
|
|
97
97
|
const formEl = ref<InstanceType<FormComponent>>(null)
|
|
98
98
|
const onSubmit = (formData) => {
|
|
99
|
-
//
|
|
99
|
+
// ...
|
|
100
100
|
}
|
|
101
101
|
const submitForm = () => {
|
|
102
102
|
formEl.value.submit()
|
|
@@ -105,54 +105,63 @@ The submit can be triggered programmatically with the `submit()` method.
|
|
|
105
105
|
|
|
106
106
|
<template>
|
|
107
107
|
<VvForm @submit="onSubmit" ref="formEl">
|
|
108
|
-
<!--
|
|
108
|
+
<!-- ... -->
|
|
109
109
|
</VvForm>
|
|
110
110
|
<button type="button" @click.stop="submitForm">Submit</button>
|
|
111
111
|
</template>
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
Use the `v-model` directive (or only `:model-value` to set the initial value of form data)
|
|
115
|
-
|
|
116
|
-
The throttle can be changed with the `updateThrottle` option.
|
|
114
|
+
Use the `v-model` directive (or only `:model-value` to set the initial value of form data) or bind the form data.
|
|
115
|
+
|
|
116
|
+
The form data two way binding is **throttled** by default (500ms) to avoid performance issues. The throttle can be changed with the `updateThrottle` option or prop.
|
|
117
|
+
|
|
118
|
+
By default form validation **stops** when a **valid state** is reached.
|
|
119
|
+
To activate **continuos validation** use the `continuosValidation` option or prop.
|
|
117
120
|
|
|
118
121
|
```vue
|
|
119
122
|
<script lang="ts" setup>
|
|
120
123
|
import { ref } from 'vue'
|
|
121
124
|
|
|
122
125
|
const formData = ref({
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
firstName: '',
|
|
127
|
+
lastName: ''
|
|
125
128
|
})
|
|
126
129
|
</script>
|
|
127
130
|
|
|
128
131
|
<template>
|
|
129
|
-
<VvForm v-model="formData">
|
|
130
|
-
<!--
|
|
132
|
+
<VvForm v-model="formData" :update-throttle="1000" continuos-validation>
|
|
133
|
+
<!-- ... -->
|
|
131
134
|
</VvForm>
|
|
132
135
|
</template>
|
|
133
136
|
```
|
|
134
137
|
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
## Composable
|
|
139
|
+
|
|
140
|
+
`useForm` can be used to create a form programmatically inside a Vue 3 Component.
|
|
141
|
+
The **default settings** are **inherited** from the plugin (if it was defined).
|
|
137
142
|
|
|
138
143
|
```vue
|
|
139
144
|
<script lang="ts" setup>
|
|
140
|
-
import {
|
|
145
|
+
import { useForm } from '@volverjs/form-vue'
|
|
146
|
+
import { z } from 'zod'
|
|
141
147
|
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
148
|
+
const schema = z.object({
|
|
149
|
+
firstName: z.string(),
|
|
150
|
+
lastName: z.string()
|
|
145
151
|
})
|
|
146
152
|
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
153
|
+
const { VvForm, VvFormWrapper, VvFormField } = useForm(schema, {
|
|
154
|
+
// lazyLoad: boolean - default false
|
|
155
|
+
// updateThrottle: number - default 500
|
|
156
|
+
// continuosValidation: boolean - default false
|
|
157
|
+
// sideEffects?: (formData: any) => void
|
|
150
158
|
})
|
|
151
159
|
</script>
|
|
152
160
|
|
|
153
161
|
<template>
|
|
154
|
-
<VvForm
|
|
155
|
-
|
|
162
|
+
<VvForm>
|
|
163
|
+
<VvFormField type="text" name="firstName" label="First Name" />
|
|
164
|
+
<VvFormField type="text" name="lastName" label="Last Name" />
|
|
156
165
|
</VvForm>
|
|
157
166
|
</template>
|
|
158
167
|
```
|
|
@@ -181,7 +190,7 @@ The wrapper status is invalid if at least one of the fields inside it is invalid
|
|
|
181
190
|
</template>
|
|
182
191
|
```
|
|
183
192
|
|
|
184
|
-
`VvFormWrapper` can be used recursively to create a validation tree. The wrapper status is invalid if at least one of the fields inside it or one of its children is invalid
|
|
193
|
+
`VvFormWrapper` can be used recursively to create a validation tree. The wrapper status is invalid if **at least one of the fields** inside it or one of its children **is invalid**.
|
|
185
194
|
|
|
186
195
|
```vue
|
|
187
196
|
<template>
|
|
@@ -204,57 +213,28 @@ The wrapper status is invalid if at least one of the fields inside it is invalid
|
|
|
204
213
|
|
|
205
214
|
### VvFormField
|
|
206
215
|
|
|
207
|
-
`VvFormField` allow you to render a [`@volverjs/ui-vue`](https://github.com/volverjs/ui-vue) input component inside a form.
|
|
216
|
+
`VvFormField` allow you to render a form field or a [`@volverjs/ui-vue`](https://github.com/volverjs/ui-vue) input component inside a form.
|
|
208
217
|
|
|
209
|
-
|
|
210
|
-
<template>
|
|
211
|
-
<VvForm>
|
|
212
|
-
<VvFormField type="text" name="name" label="Name" />
|
|
213
|
-
<VvFormField type="text" name="surname" label="Surname" />
|
|
214
|
-
</VvForm>
|
|
215
|
-
</template>
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
For nested objects, use the `name` attribute with dot notation.
|
|
219
|
-
|
|
220
|
-
```vue
|
|
221
|
-
<template>
|
|
222
|
-
<VvForm>
|
|
223
|
-
<VvFormField type="text" name="shipping.address" label="Shipping address" />
|
|
224
|
-
</VvForm>
|
|
225
|
-
</template>
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
The type of input component is defined by the `type` attribute.
|
|
229
|
-
All the available input types are listed in the [VvFormField documentation](/docs/VvFormField.md).
|
|
230
|
-
|
|
231
|
-
You can also use the `VvFormField` component to render a default slot without a `type` (default `type` is `custom`).
|
|
218
|
+
It automatically bind the form data through the `name` attribute. For nested objects, use the `name` attribute with **dot notation**.
|
|
232
219
|
|
|
233
220
|
```vue
|
|
234
221
|
<template>
|
|
235
222
|
<VvForm>
|
|
236
223
|
<VvFormField
|
|
237
|
-
v-slot="{
|
|
238
|
-
|
|
239
|
-
invalid,
|
|
240
|
-
invalidLabel,
|
|
241
|
-
formData,
|
|
242
|
-
formErrors,
|
|
243
|
-
errors,
|
|
244
|
-
onUpdate
|
|
245
|
-
}"
|
|
246
|
-
name="surname"
|
|
224
|
+
v-slot="{ modelValue, invalid, invalidLabel, onUpdate }"
|
|
225
|
+
name="lastName"
|
|
247
226
|
>
|
|
248
|
-
<label for="
|
|
227
|
+
<label for="lastName">Last Name</label>
|
|
249
228
|
<input
|
|
250
|
-
id="
|
|
229
|
+
id="lastName"
|
|
251
230
|
type="text"
|
|
231
|
+
name="lastName"
|
|
252
232
|
:value="modelValue"
|
|
253
233
|
:aria-invalid="invalid"
|
|
254
|
-
:aria-errormessage="invalid ? '
|
|
234
|
+
:aria-errormessage="invalid ? 'last-name-alert' : undefined"
|
|
255
235
|
@input="onUpdate"
|
|
256
236
|
/>
|
|
257
|
-
<small v-if="invalid" role="alert" id="
|
|
237
|
+
<small v-if="invalid" role="alert" id="last-name-alert">
|
|
258
238
|
{{ invalidLabel }}
|
|
259
239
|
</small>
|
|
260
240
|
</VvFormField>
|
|
@@ -262,104 +242,105 @@ You can also use the `VvFormField` component to render a default slot without a
|
|
|
262
242
|
</template>
|
|
263
243
|
```
|
|
264
244
|
|
|
265
|
-
|
|
245
|
+
To render a [`@volverjs/ui-vue`](https://github.com/volverjs/ui-vue) input component, use the `type` attribute.
|
|
266
246
|
|
|
267
247
|
```vue
|
|
268
|
-
<script lang="ts" setup>
|
|
269
|
-
import MyInput from './MyInput.vue'
|
|
270
|
-
</script>
|
|
271
|
-
|
|
272
248
|
<template>
|
|
273
249
|
<VvForm>
|
|
274
|
-
<VvFormField name="
|
|
250
|
+
<VvFormField type="text" name="username" label="Username" />
|
|
251
|
+
<VvFormField type="password" name="password" label="Password" />
|
|
275
252
|
</VvForm>
|
|
276
253
|
</template>
|
|
277
254
|
```
|
|
278
255
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
In some use cases can be usefull nest `VvFormField`.
|
|
282
|
-
For example let's assume:
|
|
283
|
-
|
|
284
|
-
- a shopping list that is a field of our model (ex: ToDo list)
|
|
285
|
-
- the sum of all products of the shopping list cannot be 0
|
|
286
|
-
- we don't know all the products a priori
|
|
256
|
+
Check the [`VvFormField`](./docs/VvFormField.md) documentation to learn more about form fields.
|
|
287
257
|
|
|
288
|
-
|
|
258
|
+
## Form Template
|
|
289
259
|
|
|
290
|
-
|
|
291
|
-
const toDo = {
|
|
292
|
-
shoppingList: {
|
|
293
|
-
bread: 0,
|
|
294
|
-
milk: 0,
|
|
295
|
-
tomato: 0,
|
|
296
|
-
potato: 0,
|
|
297
|
-
...
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
```
|
|
260
|
+
Forms can also be created using a template. A template is an **array of objects** that describes the form fields. All properties that are **not listed** below are passed to the component **as props**.
|
|
301
261
|
|
|
302
|
-
|
|
262
|
+
```vue
|
|
263
|
+
<script lang="ts" setup>
|
|
264
|
+
import { useForm } from '@volverjs/form-vue'
|
|
265
|
+
import { z } from 'zod'
|
|
303
266
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
.object({
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
Object.keys(value).length &&
|
|
313
|
-
!Object.keys(value).find((key) => shoppingList[key] > 0)
|
|
314
|
-
) {
|
|
315
|
-
ctx.addIssue({
|
|
316
|
-
code: z.ZodIssueCode.custom,
|
|
317
|
-
message: i18n.global.t('atLeastOneProduct')
|
|
318
|
-
})
|
|
319
|
-
}
|
|
267
|
+
const schema = z.object({
|
|
268
|
+
firstName: z.string(),
|
|
269
|
+
lastName: z.string(),
|
|
270
|
+
address: z.object({
|
|
271
|
+
street: z.string(),
|
|
272
|
+
number: z.string(),
|
|
273
|
+
city: z.string(),
|
|
274
|
+
zip: z.string()
|
|
320
275
|
})
|
|
321
|
-
})
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
And the Vue component:
|
|
325
|
-
|
|
326
|
-
```vue
|
|
327
|
-
<script setup lang="ts">
|
|
328
|
-
const { VvForm, VvFormField } = useForm(toDoSchema, {
|
|
329
|
-
lazyLoad: true,
|
|
330
|
-
continuosValidation: true
|
|
331
276
|
})
|
|
332
277
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
278
|
+
const templateSchema = [
|
|
279
|
+
{
|
|
280
|
+
vvName: 'firstName',
|
|
281
|
+
vvType: 'text',
|
|
282
|
+
label: 'First Name'
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
vvName: 'lastName',
|
|
286
|
+
vvType: 'text',
|
|
287
|
+
label: 'Last Name'
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
vvIs: 'div',
|
|
291
|
+
class: 'grid grid-col-3 gap-4',
|
|
292
|
+
vvChildren: [
|
|
293
|
+
{
|
|
294
|
+
vvName: 'address.street',
|
|
295
|
+
vvType: 'text',
|
|
296
|
+
label: 'Street',
|
|
297
|
+
class: 'col-span-2'
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
vvName: 'address.number',
|
|
301
|
+
vvType: 'text',
|
|
302
|
+
label: 'Number'
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
vvName: 'address.city',
|
|
306
|
+
vvType: 'text',
|
|
307
|
+
label: 'City'
|
|
308
|
+
class: 'col-span-2',
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
vvName: 'address.zip',
|
|
312
|
+
vvType: 'number',
|
|
313
|
+
label: 'Zip'
|
|
314
|
+
}
|
|
315
|
+
]
|
|
316
|
+
}
|
|
317
|
+
]
|
|
318
|
+
|
|
319
|
+
const { VvForm, VvFormTemplate } = useForm(schema)
|
|
340
320
|
</script>
|
|
341
321
|
|
|
342
322
|
<template>
|
|
343
323
|
<VvForm>
|
|
344
|
-
<
|
|
345
|
-
<VvFormField
|
|
346
|
-
v-for="key in Object.keys(shoppingList)"
|
|
347
|
-
:key="key"
|
|
348
|
-
:name="`shoppingList.${key}`"
|
|
349
|
-
:label="$t(key)"
|
|
350
|
-
/>
|
|
351
|
-
<small v-if="invalid" class="input-counter__hint">{{
|
|
352
|
-
invalidLabel[0]
|
|
353
|
-
}}</small>
|
|
354
|
-
</VvFormField>
|
|
324
|
+
<VvFormTemplate :schema="templateSchema" />
|
|
355
325
|
</VvForm>
|
|
356
326
|
</template>
|
|
357
327
|
```
|
|
358
328
|
|
|
359
|
-
|
|
329
|
+
Template items, by default, are rendered as a `VvFormField` component but this can be changed using the `vvIs` property. The `vvIs` property can be a string or a component.
|
|
360
330
|
|
|
361
|
-
`
|
|
362
|
-
|
|
331
|
+
`vvName` refers to the name of the field in the schema and can be a nested property using **dot notation**.
|
|
332
|
+
|
|
333
|
+
`vvType` refers to the type of the field and can be any of the supported types.
|
|
334
|
+
|
|
335
|
+
`vvDefaultValue` can be used to set default values for the form item.
|
|
336
|
+
|
|
337
|
+
`vvShowValid` can be used to show the valid state of the form item.
|
|
338
|
+
|
|
339
|
+
`vvSlots` can be used to pass a slots to the template item.
|
|
340
|
+
|
|
341
|
+
`vvChildren` is an array of template items which will be wrapped in the parent item.
|
|
342
|
+
|
|
343
|
+
Conditional rendering can be achieved using the `vvIf` and `vvElseIf` properties.
|
|
363
344
|
|
|
364
345
|
```vue
|
|
365
346
|
<script lang="ts" setup>
|
|
@@ -367,26 +348,108 @@ The default settings are inherited from the plugin (if it was defined).
|
|
|
367
348
|
import { z } from 'zod'
|
|
368
349
|
|
|
369
350
|
const schema = z.object({
|
|
370
|
-
|
|
371
|
-
|
|
351
|
+
firstName: z.string(),
|
|
352
|
+
lastName: z.string(),
|
|
353
|
+
hasUsername: z.boolean(),
|
|
354
|
+
username: z.string().optional()
|
|
355
|
+
email: z.string().email().optional()
|
|
356
|
+
}).superRefine((value, ctx) => {
|
|
357
|
+
if (value.hasUsername && !value.username) {
|
|
358
|
+
ctx.addIssue({
|
|
359
|
+
code: z.ZodIssueCode.custom,
|
|
360
|
+
message: 'Username is required'
|
|
361
|
+
})
|
|
362
|
+
}
|
|
363
|
+
if (!value.hasUsername && !value.email) {
|
|
364
|
+
ctx.addIssue({
|
|
365
|
+
code: z.ZodIssueCode.custom,
|
|
366
|
+
message: 'Email is required'
|
|
367
|
+
})
|
|
368
|
+
}
|
|
372
369
|
})
|
|
373
370
|
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
371
|
+
const templateSchema = [
|
|
372
|
+
{
|
|
373
|
+
vvName: 'firstName',
|
|
374
|
+
vvType: 'text',
|
|
375
|
+
label: 'First Name'
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
vvName: 'lastName',
|
|
379
|
+
vvType: 'text',
|
|
380
|
+
label: 'Last Name'
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
vvName: 'hasUsername',
|
|
384
|
+
vvType: 'checkbox',
|
|
385
|
+
label: 'Has Username'
|
|
386
|
+
value: true,
|
|
387
|
+
uncheckedValue: false
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
vvIf: 'hasUsername',
|
|
391
|
+
vvName: 'username',
|
|
392
|
+
vvType: 'text',
|
|
393
|
+
label: 'Username'
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
vvElseIf: true,
|
|
397
|
+
vvName: 'email',
|
|
398
|
+
vvType: 'email',
|
|
399
|
+
label: 'Email'
|
|
400
|
+
}
|
|
401
|
+
]
|
|
402
|
+
|
|
403
|
+
const { VvForm, VvFormTemplate } = useForm(schema)
|
|
380
404
|
</script>
|
|
381
405
|
|
|
382
406
|
<template>
|
|
383
407
|
<VvForm>
|
|
384
|
-
<
|
|
385
|
-
<VvFormField type="text" name="surname" label="Surname" />
|
|
408
|
+
<VvFormTemplate :schema="templateSchema" />
|
|
386
409
|
</VvForm>
|
|
387
410
|
</template>
|
|
388
411
|
```
|
|
389
412
|
|
|
413
|
+
`vvElseIf` can be used multiple times. `vvElseIf: true` is like an `else` statement and will be rendered if all previous `vvIf` and `vvElseIf` conditions are false.
|
|
414
|
+
|
|
415
|
+
`vvIf` and `vvElseIf` can be a string or a function. If it is a string it will be evaluated as a **property** of the form data. If it is a function it will be called with the **form context** as the **first argument**.
|
|
416
|
+
|
|
417
|
+
```ts
|
|
418
|
+
{
|
|
419
|
+
vvIf: (ctx) => ctx.formData.value.hasUsername,
|
|
420
|
+
vvName: 'username',
|
|
421
|
+
vvType: 'text',
|
|
422
|
+
label: 'Username'
|
|
423
|
+
}
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
The template schema and all template items can be a function. The function will be called with the form context as the first argument.
|
|
427
|
+
|
|
428
|
+
```ts
|
|
429
|
+
const templateSchema = (ctx) => [
|
|
430
|
+
{
|
|
431
|
+
vvName: 'firstName',
|
|
432
|
+
vvType: 'text',
|
|
433
|
+
label: `Hi ${ctx.formData.value.firstName}!`
|
|
434
|
+
}
|
|
435
|
+
]
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
```ts
|
|
439
|
+
const templateSchema = [
|
|
440
|
+
(ctx) => ({
|
|
441
|
+
vvName: 'firstName',
|
|
442
|
+
vvType: 'text',
|
|
443
|
+
label: `Hi ${ctx.formData.value.firstName}!`
|
|
444
|
+
}),
|
|
445
|
+
{
|
|
446
|
+
vvName: 'username',
|
|
447
|
+
type: 'text',
|
|
448
|
+
label: 'username'
|
|
449
|
+
}
|
|
450
|
+
]
|
|
451
|
+
```
|
|
452
|
+
|
|
390
453
|
## Outside a Vue 3 Component
|
|
391
454
|
|
|
392
455
|
`formFactory` can be used to create a form outside a Vue 3 Component.
|
|
@@ -401,20 +464,36 @@ const schema = z.object({
|
|
|
401
464
|
surname: z.string()
|
|
402
465
|
})
|
|
403
466
|
|
|
404
|
-
const {
|
|
467
|
+
const {
|
|
468
|
+
VvForm,
|
|
469
|
+
VvFormWrapper,
|
|
470
|
+
VvFormField,
|
|
471
|
+
VvFormTemplate,
|
|
472
|
+
formData,
|
|
473
|
+
status,
|
|
474
|
+
errors
|
|
475
|
+
} = formFactory(schema, {
|
|
405
476
|
// lazyLoad: boolean - default false
|
|
406
477
|
// updateThrottle: number - default 500
|
|
407
|
-
// continuosValidation:
|
|
478
|
+
// continuosValidation: boolean - default false
|
|
408
479
|
// sideEffects?: (data: any) => void
|
|
409
480
|
})
|
|
410
481
|
|
|
411
|
-
export default {
|
|
482
|
+
export default {
|
|
483
|
+
VvForm,
|
|
484
|
+
VvFormWrapper,
|
|
485
|
+
VvFormField,
|
|
486
|
+
VvFormTemplate,
|
|
487
|
+
formData,
|
|
488
|
+
status,
|
|
489
|
+
errors
|
|
490
|
+
}
|
|
412
491
|
```
|
|
413
492
|
|
|
414
493
|
## Default Object by Zod Object Schema
|
|
415
494
|
|
|
416
|
-
`defaultObjectBySchema` creates an object by a Zod Object Schema.
|
|
417
|
-
It can be useful to create a default object for a form
|
|
495
|
+
`defaultObjectBySchema` creates an object by a [Zod Object Schema](https://zod.dev/?id=objects).
|
|
496
|
+
It can be useful to create a **default object** for a **form**. The default object is created by the default values of the schema and can be merged with an other object passed as parameter.
|
|
418
497
|
|
|
419
498
|
```ts
|
|
420
499
|
import { z } from 'zod'
|