1
1
![ Library Banner] ( https://res.cloudinary.com/alvarosaburido/image/upload/v1589993773/portfolio/web/vue-dynamic-forms/open-graph-preview_kv4glm.png )
2
2
3
- # Vue Dynamic Forms
3
+ # Vue ` 3.x.x ` Dynamic Forms
4
4
5
5
<p align =" center " >
6
6
<a href =" https://www.npmjs.com/package/@asigloo/vue-dynamic-forms " >
7
- <img src="https://badgen.net/npm/v/@asigloo/vue-dynamic-forms" alt="Current npm version">
7
+ <img src="https://badgen.net/npm/v/@asigloo/vue-dynamic-forms/next " alt="Current npm version">
8
8
</a >
9
9
<a href =" https://bundlephobia.com/result?p=@asigloo/vue-dynamic-forms@latest " >
10
10
<img src="https://flat.badgen.net/bundlephobia/min/@asigloo/vue-dynamic-forms" alt="Minified size">
11
11
</a >
12
12
<a href =" https://vuejs.org " >
13
- <img src="https://flat.badgen.net/badge/vue.js/2.6 .x/4fc08d?icon=github" alt="Vue.js version">
13
+ <img src="https://flat.badgen.net/badge/vue.js/3.x .x/4fc08d?icon=github" alt="Vue.js version">
14
14
</a >
15
15
</p >
16
16
@@ -23,18 +23,19 @@ Especially if you need to create a very large form, in which the inputs are simi
23
23
24
24
So, wouldn't it be more economical to create the forms dynamically? Based on metadata that describes the business object model?
25
25
26
- That's Vue Dynamic Forms.
26
+ That's ** Vue Dynamic Forms** .
27
27
28
- ## Vue support
28
+ ## Status: Stable
29
29
30
- This is the Vue ` 2 .x.x` compatible version. For the Vue ` 3.x.x ` and Typescript support, please use the version available in the branch [ next ] ( https://github.com/alvarosaburido/vue-dynamic-forms/tree/next ) .
30
+ This is the Vue ` 3 .x.x` compatible version. Out of the box ` Typescript ` support, three shakeable, improved accesiility and be lighter in size. For Vue ` 2.x.x ` please use the library tags [ 2.x ] ( https://github.com/alvarosaburido/vue-dynamic-forms/tree/2.x ) .
31
31
32
32
## Documentation
33
33
34
34
Complete documentation and examples available at
35
35
36
36
- ** [ Documentation] ( https://vue-dynamic-forms.netlify.app ) **
37
- - ** [ Sandbox Demo] ( https://codesandbox.io/s/vue-dynamic-forms-ftzes ) **
37
+ - ** [ Demos] ( #demos ) **
38
+ - ** Migration Guide** (soon)
38
39
39
40
## Installation
40
41
@@ -50,34 +51,105 @@ $ yarn add @asigloo/vue-dynamic-forms
50
51
51
52
## Usage
52
53
53
- ### Global
54
+ The installation and usage has change to align with new Vue 3 plugin process.
54
55
55
- Register the component globally in your ` main.js ` :
56
+ To create a new ` Dynamic Form ` instance, use the ` createDynamicForms ` function;
56
57
57
58
``` js
58
- import Vue from ' vue' ;
59
- import VueDynamicForms from ' @asigloo/vue-dynamic-forms' ;
59
+ import { createApp } from ' vue' ;
60
+ import { createDynamicForms } from ' @asigloo/vue-dynamic-forms' ;
61
+
62
+ const VueDynamicForms = createDynamicForms ();
63
+
64
+ export const app = createApp (App);
65
+
66
+ app .use (VueDynamicForms);
67
+ ```
68
+
69
+ In your component:
70
+
71
+ ``` vue
72
+ <template>
73
+ <dynamic-form :form="form" @change="valueChanged" />
74
+ </template>
75
+
76
+ <script lang="ts">
77
+ import { computed, defineComponent, reactive } from 'vue';
78
+
79
+ import {
80
+ CheckboxField,
81
+ TextField,
82
+ SelectField,
83
+ } from '@asigloo/vue-dynamic-forms';
84
+
85
+ export default defineComponent({
86
+ name: 'BasicDemo',
87
+ setup() {
88
+ const form = computed(() => ({
89
+ id: 'basic-demo',
90
+ fields: {
91
+ username: TextField({
92
+ label: 'Username',
93
+ }),
94
+ games: SelectField({
95
+ label: 'Games',
96
+ options: [
97
+ {
98
+ value: 'the-last-of-us',
99
+ label: 'The Last of Us II',
100
+ },
101
+ {
102
+ value: 'death-stranding',
103
+ label: 'Death Stranding',
104
+ },
105
+ {
106
+ value: 'nier-automata',
107
+ label: 'Nier Automata',
108
+ },
109
+ ],
110
+ }),
111
+ checkIfAwesome: CheckboxField({
112
+ label: 'Remember Me',
113
+ }),
114
+ },
115
+ }));
116
+
117
+ function valueChanged(values) {
118
+ console.log('Values', values);
119
+ }
120
+
121
+ return {
122
+ form,
123
+ valueChanged,
124
+ };
125
+ },
126
+ });
127
+ </script>
128
+ ```
129
+
130
+ ## Demos
131
+
132
+ ![ Vue Dynamic Forms Demo] ( https://res.cloudinary.com/alvarosaburido/image/upload/v1610265908/vue-dynamic-forms-demo.png )
133
+
134
+ We've prepared some demos to show different use cases of the library and how to use each type of input field.
135
+
136
+ To check them just run the command bellow which run the app at ` http://localhost:6044/ `
60
137
61
- Vue .use (VueDynamicForms);
62
138
```
63
-
64
- ### Local
65
-
66
- You can include the dynamic form directly to your component.
67
-
68
- ``` js
69
- import Vue from ' vue' ;
70
- import { DynamicForm } from ' @asigloo/vue-dynamic-forms' ;
71
-
72
- const components = { DynamicForm };
73
-
74
- export {
75
- ...
76
- components ,
77
- ...
78
- }
139
+ yarn run serve
79
140
```
80
141
142
+ - [x] General Form
143
+ - [x] Text Fields
144
+ - [x] Number Fields
145
+ - [x] Select Fields
146
+ - [x] Textarea Fields
147
+ - [x] Radio Fields
148
+ - [x] Login
149
+ - [x] Custom Fields
150
+ - [ ] Axios form (Retrieve form structure from an API)
151
+ - [ ] TailwindCSS styling
152
+
81
153
## Development
82
154
83
155
### Project setup
@@ -98,10 +170,10 @@ yarn run serve
98
170
yarn run build
99
171
```
100
172
101
- ### Run your tests
173
+ ### Generate types
102
174
103
175
```
104
- yarn run test
176
+ yarn run build:dts
105
177
```
106
178
107
179
### Lints and fixes files
@@ -113,7 +185,13 @@ yarn run lint
113
185
### Run your unit tests
114
186
115
187
```
116
- yarn run test:unit
188
+ yarn run test
189
+ ```
190
+
191
+ ### Run your e2e tests
192
+
193
+ ```
194
+ yarn run test
117
195
```
118
196
119
197
## Contributing
@@ -122,13 +200,7 @@ If you find this library useful and you want to help improve it, maintain it or
122
200
123
201
## Todolist
124
202
125
- This are the features I have planned for next versions of this library
126
-
127
- - [x] Material theme
128
- - [ ] Form Mixins for fields manipulation (for example, change values of a field depending of other)
129
- - [ ] More complex input types.
130
- - [x] Nuxt plugin istall
131
- - [x] Better docs & online examples
203
+ - [ ] Update docs
132
204
133
205
## License
134
206
0 commit comments