Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 2463ec7

Browse files
committed
Merge branch 'master' into feature/material-theme
2 parents bf6cbbb + f77f287 commit 2463ec7

File tree

137 files changed

+6011
-356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+6011
-356
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.vuegenerator
33
.eslintrc.js
44
.eslintignore
5+
netlify.toml
56
jest.config.js
67
babel.config.js
78
vue.config.js

CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,49 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## 0.3.1 - 2020-06-17
9+
10+
## Fixed
11+
12+
- Undefined variables in theme ([#40](https://github.com/alvarosaburido/vue-dynamic-forms/issues/40))
13+
14+
## 0.3.0 - 2020-06-17
15+
16+
## Added
17+
18+
- Customizable Default Theme ([#37](https://github.com/alvarosaburido/vue-dynamic-forms/issues/37))
19+
- Added missing models to docs ([#36](https://github.com/alvarosaburido/vue-dynamic-forms/issues/36))
20+
- Helper text/hint ([#26](https://github.com/alvarosaburido/vue-dynamic-forms/issues/26))
21+
- Url regex validation ([#28](https://github.com/alvarosaburido/vue-dynamic-forms/issues/28))
22+
- Configurable input `id` ([#31](https://github.com/alvarosaburido/vue-dynamic-forms/issues/31))
23+
24+
## 0.2.2 - 2020-05-27
25+
26+
### Fixed
27+
28+
- Added build command to publish command
29+
30+
## 0.2.1 - 2020-05-27
31+
32+
### Fixed
33+
34+
- Text Area methods ([#29](https://github.com/alvarosaburido/vue-dynamic-forms/issues/29))
35+
36+
## 0.2.0 - 2020-05-26
37+
38+
### Added
39+
40+
- VuePress for Better documentation ([#15](https://github.com/alvarosaburido/vue-dynamic-forms/issues/15))
41+
- Allow Input validation on change and blur ([#21](https://github.com/alvarosaburido/vue-dynamic-forms/issues/21))
42+
- Custom fields via scoped slots ([#12](https://github.com/alvarosaburido/vue-dynamic-forms/issues/12))
43+
- Spread Form options and netlify forms support ([#19](https://github.com/alvarosaburido/vue-dynamic-forms/issues/19))
44+
45+
### Fixed
46+
47+
- Fixed missing github link in npm ([#6](https://github.com/alvarosaburido/vue-dynamic-forms/issues/6))
48+
- Custom classes ([#16](https://github.com/alvarosaburido/vue-dynamic-forms/issues/16))
49+
- Textarea validation and events not triggering ([#23](https://github.com/alvarosaburido/vue-dynamic-forms/issues/23))
50+
851
## 0.1.2 - 2020-05-05
952

1053
### Fixed

README.md

Lines changed: 7 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
![repository-banner.png](https://res.cloudinary.com/alvarosaburido/image/upload/v1564929632/as-readme-banner_tqdgrx.png)
1+
![Library Banner](https://res.cloudinary.com/alvarosaburido/image/upload/v1589993773/portfolio/web/vue-dynamic-forms/open-graph-preview_kv4glm.png)
22

33
# Vue Dynamic Forms
44

55
<p align="center">
66
<a href="https://www.npmjs.com/package/@asigloo/vue-dynamic-forms">
77
<img src="https://badgen.net/npm/v/@asigloo/vue-dynamic-forms" alt="Current npm version">
88
</a>
9-
<a href="https://bundlephobia.com/result?p=@asigloo/vue-dynamic-forms@0.1.2">
9+
<a href="https://bundlephobia.com/result?p=@asigloo/vue-dynamic-forms@0.2.0">
1010
<img src="https://flat.badgen.net/bundlephobia/min/@asigloo/vue-dynamic-forms" alt="Minified size">
1111
</a>
1212
<a href="https://vuejs.org">
@@ -15,20 +15,21 @@
1515
</p>
1616

1717
Implementing handcrafted forms can be:
18+
1819
1. Costly
1920
2. Time-consuming
2021

21-
Specially if you need to create a very large form, in which the inputs are similar to each other, and they change frequently to meet rapidly changing business and regulatory requirements.
22+
Especially if you need to create a very large form, in which the inputs are similar to each other, and they change frequently to meet rapidly changing business and regulatory requirements.
2223

23-
So, will not be more economical to create the forms dynamically? Based on metadata that describes the business object model?
24+
So, wouldn't it be more economical to create the forms dynamically? Based on metadata that describes the business object model?
2425

2526
That's Vue Dynamic Forms.
2627

2728
## Documentation
2829

2930
Complete documentation and examples available at
3031

31-
- **[API Documentation]()** (soon)
32+
- **[Documentation](https://vue-dynamic-forms.netlify.app)**
3233
- **[Sandbox Demo](https://codesandbox.io/s/vue-dynamic-forms-ftzes)**
3334

3435
## Installation
@@ -73,207 +74,6 @@ export {
7374
}
7475
```
7576

76-
### Form Composition
77-
78-
The dynamic form component is really easy to use, you will only need to add it to your template like this:
79-
80-
```html
81-
<template>
82-
<dynamic-form :id="testForm.id" :fields="testForm.fields" />
83-
<button type="submit" :form="testForm.id">Submit</button>
84-
</template>
85-
```
86-
87-
And then create the fields on your component's data structure, to create the fields you can import the factory function `FormField` from the library core:
88-
89-
```js
90-
import { FormField } from '@asigloo/vue-dynamic-forms';
91-
92-
const yourAwesomeComponent = {
93-
name: 'your-awesome',
94-
data() {
95-
return {
96-
testForm: {
97-
id: 'test-form',
98-
fields: [
99-
new FormField({
100-
type: 'text',
101-
label: 'Name',
102-
name: 'name',
103-
}),
104-
new FormField({
105-
type: 'email',
106-
label: 'Email',
107-
name: 'email',
108-
}),
109-
],
110-
},
111-
};
112-
},
113-
};
114-
115-
export default yourAwesomeComponent;
116-
```
117-
118-
Each `FormField` has a set of properties to customize your input field:
119-
120-
| Property | Type | Default | Description |
121-
| :---------- | :--------------- | :------ | :----------------------------------------------------------------------------------------------------- |
122-
| type | String | text | Define the nature of the field, can be `text|email|url|password|number|radio|checkbox|textarea|select` |
123-
| label | String | null | Defines the text in the input label |
124-
| placeholder | String | null | Defines short hint that describes the expected value of an input field |
125-
| name | String | null | Name property for the field inside of the form data |
126-
| value | any | null | Initial value of the input field |
127-
| disabled | Boolean | false | Whenever the input field is disabled or not |
128-
| customClass | String | null | Allows the user to set custom classes to the input for styling purpouses |
129-
| options | Array of Objects | [] | Options for input type `select` |
130-
| inline | Boolean | false | Specifies if options for `radio|checkbox` should be inline |
131-
| validations | Array of Objects | [] | Array of `FormValidation` objects, specify validations and messages for the input |
132-
133-
### Events and Submit
134-
135-
| Event | Type | Emitter | Description |
136-
| :----------- | :--- | :------------ | :----------------------------------------------------------------------------------------------------------------------------- |
137-
| `submit` | | `DynamicForm` | Emits whenever the submit button has been clicked and the form is valid (no errors), returns all the form values in an Object |
138-
| `form-error` | | `DynamicForm` | Emits whenever the submit button has been clicked and the form is invalid (with errors), returns all errors |
139-
| `change` | | `DynamicForm` | Emits every time there is a value changed on the form, returns all the form values in an Object without the need ob submitting |
140-
141-
A small example of a form without submit button
142-
143-
```html
144-
<template>
145-
<dynamic-form
146-
:id="testForm.id"
147-
:fields="testForm.fields"
148-
@change="valuesChanged"
149-
/>
150-
</template>
151-
```
152-
153-
```js
154-
...
155-
const yourAwesomeComponent = {
156-
name: 'your-awesome',
157-
methods: {
158-
valuesChanged(values) {
159-
this.formData = {
160-
...this.formData,
161-
...values,
162-
};
163-
},
164-
}
165-
}
166-
...
167-
```
168-
169-
### Select input
170-
171-
```js
172-
...
173-
new FormField({
174-
type: 'select',
175-
label: 'Category',
176-
name: 'category',
177-
options: [
178-
{ value: null, text: 'Please select an option' },
179-
{ value: 'arduino', text: 'Arduino' },
180-
{ value: 'transistors', text: 'Transistors' },
181-
],
182-
}),
183-
...
184-
```
185-
186-
### Radio and Checkboxes
187-
188-
```js
189-
...
190-
new FormField({
191-
type: 'checkbox',
192-
label: 'Read the conditions',
193-
name: 'conditions',
194-
inline: false,
195-
}),
196-
new FormField({
197-
type: 'radio',
198-
label: 'Prefered Animal',
199-
name: 'animal',
200-
inline: true,
201-
options: [
202-
{ text: 'Dogs', value: 'dogs' },
203-
{ text: 'Cats', value: 'cats' },
204-
{ text: 'Others', value: 'others' },
205-
],
206-
}),
207-
...
208-
```
209-
210-
### Validation
211-
212-
This library offers a simple validation system using the property `validations` as an array of `FormValidation`objects containing the validation function and the text in case of error.
213-
214-
To use it you need the following code:
215-
216-
```js
217-
import {
218-
FormField,
219-
FormValidation,
220-
required,
221-
email,
222-
pattern,
223-
} from '@asigloo/vue-dynamic-forms';
224-
225-
const yourAwesomeComponent = {
226-
name: 'your-awesome',
227-
data() {
228-
return {
229-
testForm: {
230-
id: 'test-form',
231-
fields: [
232-
new FormField({
233-
type: 'text',
234-
label: 'Name',
235-
name: 'name',
236-
}),
237-
new FormField({
238-
type: 'email',
239-
label: 'Email',
240-
name: 'email',
241-
validations: [
242-
new FormValidation(required, 'This field is required'),
243-
new FormValidation(email, 'Format of email is incorrect'),
244-
],
245-
}),
246-
new FormField({
247-
type: 'password',
248-
label: 'Password',
249-
name: 'password',
250-
validations: [
251-
new FormValidation(required, 'This field is required'),
252-
new FormValidation(
253-
pattern(
254-
'^(?=.*[a-z])(?=.*[A-Z])(?=.*d)(?=.*[#$^+=!*()@%&]).{8,10}$',
255-
),
256-
'Password must contain at least 1 Uppercase, 1 Lowercase, 1 number, 1 special character and min 8 characters max 10',
257-
),
258-
],
259-
}),
260-
],
261-
},
262-
};
263-
},
264-
};
265-
266-
export default yourAwesomeComponent;
267-
```
268-
269-
### Styling themes
270-
271-
The components are unstyled by default, so you can customize them with your own styles. If you want a more "ready to go" solution you can import on of the themes we have included in `src/styles/themes/`
272-
273-
```scss
274-
@import '~@asigloo/vue-dynamic-forms/src/styles/themes/default.scss';
275-
```
276-
27777
## Development
27878

27979
### Project setup
@@ -324,7 +124,7 @@ This are the features I have planned for next versions of this library
324124
- [ ] Form Mixins for fields manipulation (for example, change values of a field depending of other)
325125
- [ ] More complex input types.
326126
- [ ] Nuxt plugin istall
327-
- [ ] Better docs & online examples
127+
- [x] Better docs & online examples
328128
- [ ] Storybook
329129

330130
## License

0 commit comments

Comments
 (0)