Skip to content

Commit 9737aaf

Browse files
committed
docs: update docs with plugin options
1 parent 0064071 commit 9737aaf

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

apps/docs/.vitepress/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export default defineConfig({
4848
text: 'Form Generator',
4949
items: [
5050
{ text: 'Props', link: '/guide/form-generator/props' },
51-
{ text: 'Events', link: '/guide/form-generator/events' }
51+
{ text: 'Events', link: '/guide/form-generator/events' },
52+
{ text: 'Plugin options', link: '/guide/form-generator/plugin-options' }
5253
]
5354
},
5455
{
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
These are options you can pass to the plugin when installing it into your app.
2+
3+
## Usage
4+
5+
```ts
6+
import VueFormGenerator from '@kevinkosterr/vue3-form-generator'
7+
8+
app.use(
9+
VueFormGenerator,
10+
{} // Your options go here.
11+
)
12+
```
13+
14+
## `aliases`
15+
> An object where the component names are the keys and their aliases are its values.
16+
```ts
17+
{
18+
aliases: {
19+
'FieldText': 'FieldTextInput'
20+
}
21+
}
22+
```
23+
When defining something like this, the `type` inside a schema changes to everything
24+
after `"Field"`, so in this example a new schema would look like this:
25+
```ts
26+
{
27+
type: 'textinput',
28+
// Other code...
29+
}
30+
```
31+
32+
## `components`
33+
> An array of objects with two properties, `name` and `component` where name is the name of the component (must start with `"Field"`)
34+
> and component is the component instance.
35+
```ts
36+
import FieldTest from '@/components/FieldTest.vue'
37+
38+
{
39+
components: [
40+
{
41+
name: 'FieldTest',
42+
component: FieldTest
43+
}
44+
]
45+
}
46+
```
47+
48+
## `excludedComponents`
49+
> An array of field component names to exclude from the global components, this makes it
50+
> so the components can't be used inside your forms.
51+
```ts
52+
{
53+
excludedComponents: [ 'FieldObject', 'FieldNumber' ]
54+
}
55+
```
56+
57+
## `messages`
58+
> An object where the keys are the validator function names and the values its error messages.
59+
> This is for showing specific messages for your custom or existing components.
60+
```ts
61+
{
62+
messages: {
63+
'yourcustomvalidator': 'This is not valid, man!'
64+
}
65+
}
66+
```

0 commit comments

Comments
 (0)