Skip to content

Commit bf12df9

Browse files
committed
📝 update doc
1 parent 0381cf2 commit bf12df9

File tree

1 file changed

+22
-80
lines changed

1 file changed

+22
-80
lines changed

README.md

Lines changed: 22 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,52 @@
1-
<h1 align="center">
2-
vue-use-form(WIP)
1+
<h1 align="center">
2+
vue-use-form
33
</h1>
4-
5-
Inspired by [react-hook-form](https://react-hook-form.com/), if you love react-hook-form usage, come on and try it!
6-
7-
## Document
8-
9-
The usage is almost the same as that of the react-hook-form. you can go [react-hook-form](https://react-hook-form.com/) to check.
4+
<p align="center">
5+
Inspired by <a href="https://react-hook-form.com/">react-hook-form</a>, if you love react-hook-form usage, come on and try it!
6+
</p>
7+
<p align="center">
8+
<a href="https://vue-use-form.netlify.app/">📝Document</a>
9+
|
10+
<a href="https://vue-use-form-play.netlify.app/">
11+
🤽‍♀️Playground
12+
</a>
13+
</p>
1014

1115
## Install
1216

1317
```bash
14-
# npm
1518
npm i vue-use-form
16-
17-
# pnpm
18-
pnpm i vue-use-form
19-
20-
# yarn
21-
yarn add vue-use-form
2219
```
2320

2421
## 🚀Features
2522
- 🦾 Type Strong: Written in TypeScript
2623
- 🏆 No Component: No need to import any components to use, you can use it in all UI framework
27-
- 😍 Easy to use: Just 3 main hooks: useForm, useFormState, useFieldArray
28-
29-
## TODO
30-
31-
- [ ] 🐵Main features
32-
- [ ] 🍉`useForm`
33-
- [ ] 🍎 register -> disabled -> setValueAsDate
34-
- [ ] register -> support custom modelValue like `v-model:checked`
35-
- [ ] 🍊`useFormState`
36-
- [ ] 🍋`useFieldArray`
37-
- [ ] 🍎schema
38-
- [x] 🍵 class-validator
39-
- [x] 🍶 Yup
40-
- [ ] Test
41-
- [ ] 🐯Unit test
42-
- [ ] 🐼 Community(WIP...)
43-
- [ ] 🎋中文文档
44-
- [ ] 📖Documentation .
45-
24+
- 😍 Easy to use: Just 2 main hooks: useForm, useFieldArray
4625

47-
## 🎁Try it online
48-
🎮[play with element-plus](https://stackblitz.com/edit/vitejs-vite-typsyz?file=src%2Fmain.ts,src%2FApp.vue,package.json&terminal=dev) by default way.
4926

50-
🎮[play with class-validator](https://stackblitz.com/edit/vitejs-vite-foumka?file=src%2FApp.vue,vite.config.ts,src%2Fmain.ts,package.json,src%2Fenv.d.ts&terminal=dev) by using `class-validator` resolver
51-
52-
## 🚣playground
53-
you can fork/download this repo, and then just 3 steps can make playground run
54-
```bash
55-
# 1. open this repo folder in your local
56-
# 2. init dependencies
57-
pnpm i
58-
# 3. open the playground folder and run `dev` script or
59-
pnpm run dev
60-
```
6127

6228
## Quick Start
63-
64-
```vue
29+
```html
6530
<script setup lang="ts">
6631
import { useForm } from 'vue-use-form'
6732
6833
interface Inputs {
69-
age: number
34+
username: string
7035
}
7136
72-
const {
73-
formState,
74-
register,
75-
createSubmitHandler,
76-
createErrorHandler,
77-
} = useForm<Inputs>({
78-
mode: 'onChange',
79-
shouldFocusError: true,
80-
})
81-
82-
const onSubmit = createSubmitHandler((data) => {
83-
console.log('validate success', data)
84-
})
85-
86-
const onError = createErrorHandler((errors) => {
87-
console.log('validate error', errors)
88-
})
37+
const { regsiter } = useForm<Inputs>()
8938
</script>
9039

9140
<template>
92-
<form @submit.prevent="handleSubmit(onSubmit, onError)()">
93-
<input
94-
:="register('age', {
95-
required: 'Age is required!',
96-
min: { value: 18, message: 'Age must be at least 18' },
97-
max: { value: 10000, message: '?' },
98-
valueAsNumber: true,
99-
})"
100-
type="number"
101-
name="age"
102-
>
103-
<button type="submit" v-text="'Submit'" />
104-
</form>
41+
<input
42+
:="register('username', {
43+
required: 'username field cannot be empty!'
44+
})"
45+
>
10546
</template>
10647
```
10748

49+
10850
## use with schema
10951
- [@vue-use-form/class-validator](https://github.com/vue-use-form/vue-use-form/tree/master/packages/resolver-class-validator)
11052
- [@vue-use-form/yup](https://github.com/vue-use-form/vue-use-form/tree/master/packages/resolver-yup)

0 commit comments

Comments
 (0)