Skip to content

Commit 6fb35b1

Browse files
committed
docs(vitepress): add composables documentation
1 parent adc032c commit 6fb35b1

File tree

5 files changed

+65
-10
lines changed

5 files changed

+65
-10
lines changed

dev/components/app/AppFooter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const version = ref(import.meta.env.VITE_APP_VERSION)
44

55
<template>
66
<div class="mt-8 layout-footer text-center text-gray-700">
7-
<span class="font-medium ml-2">Formkit (1.5) - PrimeVue (3.49) - FormKit-PrimeVue-Version {{ version }} - sfxcode 2024</span>
7+
<span class="font-medium ml-2">Formkit (1.6) - PrimeVue (3.49) - FormKit-PrimeVue-Version {{ version }} - sfxcode 2024</span>
88
</div>
99
</template>
1010

dev/pages/index.vue

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<script setup lang='ts'>
22
import { ref } from 'vue'
3+
import { useFormKitSchema } from 'my-library'
4+
5+
const { addElement } = useFormKitSchema()
36
47
const options = [
58
{ label: 'Every page load', value: 'refresh' },
@@ -9,14 +12,8 @@ const options = [
912
1013
const schema = reactive(
1114
[
12-
{
13-
$el: 'h2',
14-
children: ['Register ', '$email'],
15-
},
16-
{
17-
$el: 'h3',
18-
children: 'Header Text H3',
19-
},
15+
addElement('h2', ['Register ', '$email']),
16+
addElement('h3', 'Header Text H3'),
2017
{
2118
$formkit: 'primeInputText',
2219
name: 'email',

docs/.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ function sidebarGuide() {
9090
{ text: 'Usage', link: '/guide/usage' },
9191
{ text: 'PrimeVue Inputs', link: '/guide/inputs' },
9292
{ text: 'Options', link: '/guide/options' },
93+
{ text: 'Composables', link: '/guide/composables' },
9394
{ text: 'Styling', link: '/guide/styling' },
9495
{ text: 'Sample Apps', link: '/guide/examples' },
9596
],

docs/guide/composables.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Composables
2+
3+
Composables are used make your development with this library a little easier.
4+
5+
## useFormkitSchema
6+
7+
This composable provides helper functions to simplify building a schema.
8+
9+
Sometimes it provides a little more concise syntax or provide the needed helper functions.
10+
11+
### addComponent
12+
13+
```ts
14+
const { addComponent } = useFormKitSchema()
15+
16+
const addButtonComponent = (onClick: string = '', label: string = '', icon: string = '', severity: string = '', render: string = 'true', styleClass: string = 'p-button-sm ml-2'): object => {
17+
return addComponent('Button', { onClick, label, icon, class: styleClass, severity }, render)
18+
}
19+
```
20+
21+
### addElement
22+
23+
Following json in the schema
24+
25+
```json
26+
[
27+
{
28+
$el: 'h2',
29+
children: ['Register ', '$email'],
30+
},
31+
{
32+
$el: 'h3',
33+
children: 'Header Text H3',
34+
}
35+
]
36+
```
37+
38+
can be replaced by:
39+
40+
```ts
41+
const { addElement } = useFormKitSchema()
42+
43+
[
44+
addElement('h2', ['Register ', '$email']),
45+
addElement('h3', 'Header Text H3')
46+
]
47+
```
48+
49+
### Repeater
50+
51+
To simplify the build of a repeater you can use:
52+
53+
- addList
54+
- addListGroup
55+
- addListGroupFunctions
56+
57+
A working example can be found in the [repeater demo](https://github.com/sfxcode/formkit-primevue/blob/main/dev/pages/samples/Repeater.vue).

docs/guide/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**formkit-primevue** combines the [PrimeVue](https://www.primefaces.org/primevue) component framework with the validation power of [Formkit](https://formkit.com/) in your Vue/Nuxt application.
44

5-
The main motivation for this project is to use Formkit Validation by Schema with form elements provided by PrimeVue..
5+
The main motivation for this project is to use Formkit Validation by Schema with form elements provided by PrimeVue.
66

77
## Formkit Schema
88

0 commit comments

Comments
 (0)