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

Commit fedf1ad

Browse files
committed
feat: vitepress almost working
1 parent aa98f25 commit fedf1ad

19 files changed

+37074
-6961
lines changed

.prettierrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

.prettierrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
...require('@asigloo/prettier-config')
3+
}

demos/vue-3/src/main.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { createApp } from 'vue';
2-
import App from './App.vue';
3-
import './styles/main.css';
4-
import router from './router';
1+
import { createApp } from 'vue'
2+
import App from './App.vue'
3+
import './styles/main.css'
4+
import router from './router'
55

6-
/* import { createDynamicForms } from '/@'; */
6+
import { createDynamicForms } from '/@'
77

8-
import { createDynamicForms } from '../../../dist/as-dynamic-forms.es';
8+
/* import { createDynamicForms } from '../../../dist/as-dynamic-forms.es'; */
99

1010
const VueDynamicForms = createDynamicForms({
1111
autoValidate: true,
@@ -15,12 +15,12 @@ const VueDynamicForms = createDynamicForms({
1515
netlify: false,
1616
netlifyHoneypot: null,
1717
},
18-
});
18+
})
1919

20-
export const app = createApp(App);
20+
export const app = createApp(App)
2121

22-
console.log({ app });
22+
console.log({ app })
2323

24-
app.use(VueDynamicForms);
24+
app.use(VueDynamicForms)
2525

26-
app.use(router).mount('#app');
26+
app.use(router).mount('#app')
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<template>
2+
<dynamic-form :form="form" />
3+
</template>
4+
5+
<script lang="ts">
6+
import { TextField, EmailField } from '../../../src'
7+
8+
export default {
9+
name: 'FormCompositionOptionsApi',
10+
data() {
11+
return {
12+
form: {
13+
id: 'my-awesome-form',
14+
fields: {
15+
name: TextField({
16+
label: 'Name',
17+
}),
18+
email: EmailField({
19+
label: 'Email',
20+
}),
21+
},
22+
},
23+
}
24+
},
25+
}
26+
</script>

docs/.vitepress/config.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { description } = require('../../package')
2+
3+
module.exports = {
4+
title: 'Vue Dynamic Forms',
5+
description,
6+
themeConfig: {
7+
repo: 'asigloo/vue-dynamic-forms',
8+
logo: '/logo.svg',
9+
nav: [
10+
{
11+
text: 'Migration Guide',
12+
link: '/v3/guide/migration-guide',
13+
},
14+
],
15+
sidebar: {
16+
'/': [
17+
{
18+
text: 'Guide',
19+
children: [
20+
{
21+
text: 'Introduction',
22+
link: '/guide/',
23+
},
24+
{
25+
text: 'Getting Started',
26+
link: '/guide/getting-started',
27+
},
28+
{
29+
text: 'Usage',
30+
link: '/guide/usage',
31+
},
32+
],
33+
},
34+
],
35+
},
36+
},
37+
}

docs/.vitepress/theme/index.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import DefaultTheme, { Config } from 'vitepress/theme'
2+
import { createDynamicForms } from '../../../src'
3+
4+
const modules = import.meta.globEager('../components/**/*.vue')
5+
const components = []
6+
7+
for (const path in modules) {
8+
components.push(modules[path].default)
9+
}
10+
11+
const VueDynamicForms = createDynamicForms({
12+
autoValidate: true,
13+
form: {
14+
customClass: 'plugin-options-class-added',
15+
method: 'POST',
16+
netlify: false,
17+
netlifyHoneypot: null,
18+
},
19+
})
20+
21+
const theme: Config = {
22+
...DefaultTheme,
23+
enhanceApp({ app }) {
24+
app.use(VueDynamicForms)
25+
components.forEach(component => {
26+
app.component(component.name, component)
27+
})
28+
},
29+
}
30+
31+
export default theme

docs/guide/getting-started.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Installation
2+
3+
Install with yarn:
4+
5+
```bash
6+
yarn add @asigloo/vue-dynamic-forms
7+
8+
# or, using NPM
9+
npm install @asigloo/vue-dynamic-forms --S
10+
```
11+
12+
## Setup
13+
14+
To create a new `Dynamic Form` instance, use the `createDynamicForms` function;
15+
16+
```javascript
17+
import { createApp } from 'vue';
18+
import { createDynamicForms } from '@asigloo/vue-dynamic-forms';
19+
20+
const VueDynamicForms = createDynamicForms({
21+
// Global Options go here
22+
});
23+
24+
export const app = createApp(App);
25+
26+
app.use(VueDynamicForms);
27+
```

docs/guide/index.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Introduction
2+
3+
Vue Dynamic Forms (a.k.a vdf) is a lighweight [Vue 3x](https://v3.vuejs.org/) plugin to easily create dynamic forms.
4+
5+
## Why VDF?
6+
7+
Implementing handcrafted forms can be:
8+
9+
- Costly 💰 🔥
10+
- Time-consuming 😅 ⏱
11+
12+
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.
13+
14+
So, wouldn't it be more economical to create the forms dynamically? Based on metadata that describes the business object model?
15+
16+
That's **Vue Dynamic Forms**.
17+
18+
## Features
19+
20+
- ✓ UI Framework agnostic (Bootstrap, material, tailwindcss?) You choose.
21+
- ✓ Dx (Developer Experience) oriented, forget about those infintie form templates, only one component to use. [./components/dynamic-form]
22+
- ✓ Full [Typescript](https://www.typescriptlang.org/) Support
23+
- ✓ Supports both [Options API](https://v3.vuejs.org/api/options-api.html) and [Composition API](https://v3.vuejs.org/guide/composition-api-introduction.html)
24+
- ✓ Ridicously lightweight ([~26.3 kB minified - 6.7 kb Gzipped](https://bundlephobia.com/package/@asigloo/vue-dynamic-forms@latest))
25+
- ✓ Tree-Shakeable
26+
- ✓ Completly accessible [AA](https://www.w3.org/WAI/WCAG2AA-Conformance)
27+
28+
## Vue 2.x
29+
30+
::: warning
31+
This version doesn't support Vue [2.x.x](https://github.com/alvarosaburido/vue-dynamic-forms/tree/2.x) anymore since there aren't new feature request or issues opened. I decided to drop the support and focus on the development and mantainance of the main current [v3.x](https://github.com/alvarosaburido/vue-dynamic-forms).
32+
:::
33+
34+
If you still want to use this plugin on Vue `2.x` please use the library tags [2.x](https://github.com/alvarosaburido/vue-dynamic-forms/tree/2.x).
35+
36+
## Why Not ...?
37+
38+
Are there more Vue Forms alternatives? Of course they are, hovewer, I was motivated to create this library because none of those allowed to easily create forms without caring about creating the different input components and handling the events etc. Most of them offer a mixed solution with schemas and your own input components, but you still need to do everything pretty much manually.
39+
40+
If you want a ready to go solution based on a javascript/JSON metadata object containing your form fields. [Vue Dynamic Forms](https://github.com/asigloo/vue-dynamic-forms) is the solution you're looking for.
41+
42+
### Vue Formulate
43+
44+
Vue Formulate is a very good library that brings a lot of different funcionalities and features, however, Vue Formulate don't support Vue3 at the moment [Check here](https://github.com/wearebraid/vue-formulate/issues/198) and current version weights 3x more than VDF. [Check here](https://bundlephobia.com/package/@braid/[email protected])
45+
46+
### FormVueLate
47+
48+
FormVueLate is an amazing library that allows you to generate schema-driven forms with extreme ease. This is similar of what VDF offers.
49+
50+
They do support Vue3, a downside would be that FormVueLate is that hey don't have a built-in solution for validations, you will need to add a vee-validate plugin to support them.
51+
52+
Apart from that the main difference between FormVueLate and VDF is pretty much highlighted in their docs:
53+
54+
> FormVueLate is a bring-your-own-components library! We do not provide any base components for your to build your forms. There are numerous component libraries out there that do a great job of providing carefully constructed components for you to use, and FormVueLate does a great job at allowing you to bring those external components to your forms, or even crafting your own.
55+
56+
### Vuetify
57+
58+
Vuetify is full UI framework which includes forms as one of their features but is not a specific library dedicated to it-

0 commit comments

Comments
 (0)