docs: add more info about v-model.lazy in input.md and form.md

This commit is contained in:
sadeghbarati 2023-11-27 23:29:02 -08:00
parent eb0cd65626
commit e80124e894
5 changed files with 64 additions and 4 deletions

View File

@ -401,6 +401,13 @@ export const Index = {
component: () => import('../src/lib/registry/default/example/InputWithLabel.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/InputWithLabel.vue'],
},
InputLazyDemo: {
name: 'InputLazyDemo',
type: 'components:example',
registryDependencies: ['input', 'button'],
component: () => import('../src/lib/registry/default/example/InputLazyDemo.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/InputLazyDemo.vue'],
},
LabelDemo: {
name: 'LabelDemo',
type: 'components:example',

View File

@ -336,3 +336,16 @@ See the following links for more examples on how to use the `vee-validate` featu
This example shows how to add motion to your forms with [Formkit AutoAnimate](https://auto-animate.formkit.com/)
<ComponentPreview name="InputFormAutoAnimate" />
This example show how to use `v-model.lazy`-like in VeeValidate with `validateOnChange`
<Callout class="mt-4">
`v-model` modifiers don't work on custom Vue components
</Callout>
<ComponentPreview name="InputLazyForm" />

View File

@ -63,10 +63,18 @@ import { Input } from '@/components/ui/input'
<ComponentPreview name="InputWithButton" class="max-w-xs" />
### Lazy (v-model.lazy)
<Callout class="mt-4">
`v-model` modifiers don't work on custom Vue components,
instead you can use `@change` event on custom Vue component
</Callout>
<ComponentPreview name="InputLazyDemo" class="max-w-xs" />
### Form
<ComponentPreview name="InputForm" />
#### v-model.lazy binding
<ComponentPreview name="InputLazyForm" />

View File

@ -0,0 +1,16 @@
<script setup lang="ts">
import { ref } from 'vue'
import { Input } from '@/lib/registry/default/ui/input'
const emailRef = ref('')
</script>
<template>
<div class="w-full">
<Input type="email" placeholder="Email" @change="event => emailRef = event.target.value" />
<div>
{{ emailRef }}
</div>
</div>
</template>

View File

@ -0,0 +1,16 @@
<script setup lang="ts">
import { ref } from 'vue'
import { Input } from '@/lib/registry/new-york/ui/input'
const emailRef = ref('')
</script>
<template>
<div class="w-full">
<Input type="email" placeholder="Email" @change="event => emailRef = event.target.value" />
<div>
{{ emailRef }}
</div>
</div>
</template>