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

Commit f4ed7b9

Browse files
authored
Merge pull request #218 from asigloo/final-stable-next-on-master
Final stable next on master
2 parents 4ffd8c0 + ba85f29 commit f4ed7b9

File tree

157 files changed

+19521
-25230
lines changed

Some content is hidden

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

157 files changed

+19521
-25230
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
dist/
2+
*.config.js

.eslintrc.js

+42-29
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,48 @@
11
module.exports = {
2-
root: true,
3-
env: {
4-
browser: true,
5-
node: true,
6-
},
7-
extends: [
8-
'plugin:vue/essential',
9-
'plugin:prettier/recommended',
10-
'prettier',
11-
'prettier/vue',
2+
root: true,
3+
env: {
4+
node: true,
5+
},
6+
extends: [
7+
/* 'plugin:vue/vue3-essential', */
8+
'eslint:recommended',
9+
'@vue/typescript/recommended',
10+
'@vue/prettier',
11+
'@vue/prettier/@typescript-eslint',
12+
],
13+
parserOptions: {
14+
ecmaVersion: 2020,
15+
},
16+
rules: {
17+
'vue/valid-v-slot': 'off',
18+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
19+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
20+
'@typescript-eslint/no-this-alias': [
21+
'error',
22+
{
23+
allowDestructuring: true, // Allow `const { props, state } = this`; false by default
24+
allowedNames: ['self', 'vdf'], // Allow `const self = this`; `[]` by default
25+
},
1226
],
13-
plugins: ['prettier'],
14-
rules: {
15-
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
16-
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
17-
'prettier/prettier': [
18-
'error',
19-
{
20-
htmlWhitespaceSensitivity: 'ignore',
21-
singleQuote: true,
22-
semi: true,
23-
trailingComma: 'all',
24-
},
27+
},
28+
overrides: [
29+
{
30+
files: [
31+
'**/__tests__/*.{j,t}s?(x)',
32+
'**/tests/unit/**/*.spec.{j,t}s?(x)',
2533
],
34+
env: {
35+
jest: true,
36+
},
2637
},
27-
parserOptions: {
28-
parser: 'babel-eslint',
29-
},
30-
settings: {
31-
'import/resolver': {
32-
alias: [['@', './src']],
38+
{
39+
files: [
40+
'**/__tests__/*.{j,t}s?(x)',
41+
'**/tests/unit/**/*.spec.{j,t}s?(x)',
42+
],
43+
env: {
44+
jest: true,
3345
},
3446
},
35-
}
47+
],
48+
};

.github/workflows/ci.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
name: ci
2-
1+
name: CI
32
on:
43
pull_request:
54
branches:
65
- master
76
- next
8-
97
jobs:
10-
test-and-release:
11-
name: Run tests
8+
check:
9+
name: Check stuff
1210
runs-on: ubuntu-18.04
1311
steps:
1412
- name: Checkout
@@ -19,5 +17,7 @@ jobs:
1917
node-version: 12
2018
- name: Install dependencies
2119
run: npm ci
22-
- name: Run tests
23-
run: npm run test
20+
- name: Run unit tests
21+
run: npm run test --verbose
22+
- name: Build Library
23+
run: npm run build

.github/workflows/release.yml

+4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ jobs:
1717
node-version: 12
1818
- name: Install dependencies
1919
run: npm ci
20+
- name: Run unit tests
21+
run: npm run test --verbose
2022
- name: Build Library
2123
run: npm run build
24+
- name: Build Types Declarations
25+
run: npm run build:dts
2226
- name: Release
2327
env:
2428
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ node_modules
66
/coverage
77
/tests/e2e/videos/
88
/tests/e2e/screenshots/
9-
9+
/temp
1010
# local env files
1111
.env.local
1212
.env.*.local

.husky/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname $0)/_/husky.sh"
3+
4+
npm run lint

.husky/pre-push

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname $0)/_/husky.sh"
3+
4+
npm test

.npmignore

+9
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22
.vuegenerator
33
.eslintrc.js
44
.eslintignore
5+
.nyc_output
6+
.husky
57
netlify.toml
68
jest.config.js
79
babel.config.js
810
vue.config.js
911
postcss.config.js
12+
api-extractor.json
13+
renovate.json
14+
rollup.config.js
15+
tailwind.config.js
1016
.prettierrc
1117
.git
18+
.prettierignore
1219
**/.git/
1320
**/node_modules/
1421
yarn.lock
@@ -18,3 +25,5 @@ yarn.lock
1825
/coverage
1926
/.vscode
2027
/tests
28+
/temp
29+
/templates

.nyc_output/out.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

README.md

+110-38
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
![Library Banner](https://res.cloudinary.com/alvarosaburido/image/upload/v1589993773/portfolio/web/vue-dynamic-forms/open-graph-preview_kv4glm.png)
22

3-
# Vue Dynamic Forms
3+
# Vue `3.x.x` Dynamic Forms
44

55
<p align="center">
66
<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">
88
</a>
99
<a href="https://bundlephobia.com/result?p=@asigloo/vue-dynamic-forms@latest">
1010
<img src="https://flat.badgen.net/bundlephobia/min/@asigloo/vue-dynamic-forms" alt="Minified size">
1111
</a>
1212
<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">
1414
</a>
1515
</p>
1616

@@ -23,18 +23,19 @@ Especially if you need to create a very large form, in which the inputs are simi
2323

2424
So, wouldn't it be more economical to create the forms dynamically? Based on metadata that describes the business object model?
2525

26-
That's Vue Dynamic Forms.
26+
That's **Vue Dynamic Forms**.
2727

28-
## Vue support
28+
## Status: Stable
2929

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).
3131

3232
## Documentation
3333

3434
Complete documentation and examples available at
3535

3636
- **[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)
3839

3940
## Installation
4041

@@ -50,34 +51,105 @@ $ yarn add @asigloo/vue-dynamic-forms
5051

5152
## Usage
5253

53-
### Global
54+
The installation and usage has change to align with new Vue 3 plugin process.
5455

55-
Register the component globally in your `main.js`:
56+
To create a new `Dynamic Form` instance, use the `createDynamicForms` function;
5657

5758
```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/ `
60137

61-
Vue.use(VueDynamicForms);
62138
```
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
79140
```
80141

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+
81153
## Development
82154

83155
### Project setup
@@ -98,10 +170,10 @@ yarn run serve
98170
yarn run build
99171
```
100172

101-
### Run your tests
173+
### Generate types
102174

103175
```
104-
yarn run test
176+
yarn run build:dts
105177
```
106178

107179
### Lints and fixes files
@@ -113,7 +185,13 @@ yarn run lint
113185
### Run your unit tests
114186

115187
```
116-
yarn run test:unit
188+
yarn run test
189+
```
190+
191+
### Run your e2e tests
192+
193+
```
194+
yarn run test
117195
```
118196

119197
## Contributing
@@ -122,13 +200,7 @@ If you find this library useful and you want to help improve it, maintain it or
122200

123201
## Todolist
124202

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
132204

133205
## License
134206

0 commit comments

Comments
 (0)