Skip to content

Commit bafb22c

Browse files
author
Daniel Requejo
committed
🦄 Adding logo, contribution guidelines and enhancing readme
1 parent 429ecf4 commit bafb22c

File tree

3 files changed

+96
-9
lines changed

3 files changed

+96
-9
lines changed

CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://kcd.im/pull-request)

README.md

+95-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,102 @@
1-
# Vue 3 + TypeScript + Vite
21

3-
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
2+
<div align="center">
3+
<h1>vue-form-handler</h1>
44

5-
## Recommended IDE Setup
5+
The easy way of handling your vue forms
6+
</div>
67

7-
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
8+
[![Build Status](https://github.com/mattphillips/deep-object-diff/actions/workflows/ci.yaml/badge.svg)](https://github.com/dbssman/vue-form-handler/actions/workflows/node.js.yml)
9+
[![version](https://img.shields.io/npm/v/deep-object-diff.svg?style=flat-square)](https://www.npmjs.com/package/deep-object-diff)
10+
[![downloads](https://img.shields.io/npm/dm/deep-object-diff.svg?style=flat-square)](http://npm-stat.com/charts.html?package=deep-object-diff&from=2016-11-23)
11+
[![MIT License](https://img.shields.io/npm/l/deep-object-diff.svg?style=flat-square)](https://github.com/dbssman/vue-form-handler/blob/master/License.md)
12+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
813

9-
## Type Support For `.vue` Imports in TS
14+
## 📦 Installation
15+
---
16+
``` yarn add vue-form-handler ```
1017

11-
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:
18+
``` npm i --save vue-form-handler ```
1219

13-
1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
14-
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.
20+
## 🚀 Features
21+
---
22+
- 💪 **Type strong**: Written in TypeScript
23+
- 🔩 **Flexible**: you can wrap the form handler over native inputs or any other like the ones from material libraries or custom inputs.
24+
- 🪶 **Super light**: Small package size
25+
- 💻 **DX**: Great development experience
1526

16-
You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
27+
## 🦄 Usage
28+
---
29+
### Basic usage
30+
31+
```vue
32+
<template>
33+
<form @submit.prevent="handleSubmit(successFn)">
34+
<input v-bind="register('firstName')" />
35+
<input v-bind="register('lastName')" />
36+
<input v-bind="register('age')" type="number"/>
37+
<input type="submit"/>
38+
</form>
39+
</template>
40+
<script setup>
41+
import { useFormHandler } from 'vue-form-handler';
42+
const { register, handleSubmit } = useFormHandler();
43+
const successFn = (form) => {console.log({form})}
44+
</script>
45+
```
46+
47+
### Validations
48+
49+
```vue
50+
<template>
51+
<form @submit.prevent="handleSubmit(successFn)">
52+
<input v-bind="register('firstName',{
53+
required:'This field is required'
54+
})" />
55+
<p>{{formState.errors.firstName}}</p>
56+
<input v-bind="register('lastName')" />
57+
<input v-bind="register('age', {
58+
min:{
59+
value: 18,
60+
message: 'Your age is below the accepted range'
61+
}
62+
})" type="number" />
63+
<p>{{formState.errors.age}}</p>
64+
<input type="submit"/>
65+
</form>
66+
</template>
67+
<script setup>
68+
import { useFormHandler } from 'vue-form-handler';
69+
const { formState, register, handleSubmit } = useFormHandler();
70+
const successFn = (form) => {console.log({form})}
71+
</script>
72+
```
73+
74+
### Integration with Material frameworks
75+
76+
```vue
77+
<template>
78+
<form @submit.prevent="handleSubmit(successFn)">
79+
<q-input v-bind="register('name')" />
80+
<q-checkbox v-bind="register('married')"/>
81+
<q-select v-bind="register('pet')" :options="['dog','cat','mouse']"/>
82+
<input type="submit"/>
83+
</form>
84+
</template>
85+
<script setup>
86+
import { useFormHandler } from 'vue-form-handler';
87+
const { formState, register, handleSubmit } = useFormHandler();
88+
const successFn = (form) => {console.log({form})}
89+
</script>
90+
```
91+
92+
### For a more advanced usage visit the [Docs](https://vue-form-handler.com)
93+
94+
## 💜 Thanks
95+
---
96+
This project is heavily inspired by other awesome projects like:
97+
- [jaredpalmer/formik](https://github.com/jaredpalmer/formik)
98+
- [react-hook-form/react-hook-form](https://github.com/react-hook-form/react-hook-form)
99+
100+
## 📄 License
101+
---
102+
[MIT License](https://github.com/dbssman/vue-form-handler/blob/master/License.md) © 2022-PRESENT [Dennis Bosmans](https://github.com/dbssman)

docs/logo.png

4.84 KB
Loading

0 commit comments

Comments
 (0)