-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce defineField and deprecate bind API (#4497)
- Loading branch information
Showing
55 changed files
with
630 additions
and
698 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'vee-validate': patch | ||
--- | ||
|
||
feat: add label support to defineField closes #4530 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 3 additions & 18 deletions
21
docs/src/components/examples/CompositionComponentBindsBasic05.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,24 @@ | ||
<script setup> | ||
import { useForm } from 'vee-validate'; | ||
import * as yup from 'yup'; | ||
import CustomInput from './CustomInput.vue'; | ||
const { values, errors, defineInputBinds, defineComponentBinds } = useForm({ | ||
const { values, errors, defineField } = useForm({ | ||
validationSchema: yup.object({ | ||
email: yup.string().email().required(), | ||
emailComponent: yup.string().email().required(), | ||
}), | ||
}); | ||
const email = defineInputBinds('email', state => { | ||
return { | ||
// validate aggressively as long as there are errors on the input | ||
validateOnInput: state.errors.length > 0, | ||
}; | ||
}); | ||
const emailComponent = defineComponentBinds('emailComponent', state => { | ||
const [email, emailAttrs] = defineField('email', state => { | ||
return { | ||
// validate aggressively as long as there are errors on the input | ||
validateOnModelUpdate: state.errors.length > 0, | ||
validateOnBlur: true, | ||
props: { | ||
error: state.errors[0], | ||
}, | ||
}; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<input v-bind="email" /> | ||
<input v-model="email" v-bind="emailAttrs" /> | ||
<div>{{ errors.email }}</div> | ||
|
||
<CustomInput v-bind="emailComponent" /> | ||
|
||
<pre>values: {{ values }}</pre> | ||
</template> |
22 changes: 0 additions & 22 deletions
22
docs/src/components/examples/CompositionComponentBindsBasic06.vue
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
docs/src/components/examples/CompositionHandlingForms01.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<template> | ||
<input v-bind="name" /> | ||
|
||
<button :disabled="!meta.touched">Submit</button> | ||
</template> | ||
|
||
<script setup> | ||
import { useForm } from 'vee-validate'; | ||
const { meta, defineInputBinds } = useForm(); | ||
const { meta, defineField } = useForm(); | ||
const name = defineInputBinds('name'); | ||
const [name, nameAttrs] = defineField('name'); | ||
</script> | ||
|
||
<template> | ||
<input v-model="name" v-bind="nameAttrs" /> | ||
|
||
<button :disabled="!meta.touched">Submit</button> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.