Skip to content

Commit ab95443

Browse files
committed
refactor(data): Data Edit / View
1 parent c64b0f4 commit ab95443

File tree

6 files changed

+73
-22
lines changed

6 files changed

+73
-22
lines changed

dev/components/app/AppTopbar.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const items = ref([
8181
items: [
8282
[
8383
{
84-
label: 'Outputs',
84+
label: 'Output Components',
8585
items: [
8686
{ label: 'Output Text', icon: 'pi pi-fw pi-user-edit', route: '/outputs/outputText' },
8787
{ label: 'Output Number', icon: 'pi pi-fw pi-user-edit', route: '/outputs/outputNumber' },
@@ -99,6 +99,8 @@ const items = ref([
9999
items: [
100100
{ label: 'Basic', icon: 'pi pi-fw pi-user-edit', route: '/styling/base' },
101101
{ label: 'Pass Through', icon: 'pi pi-fw pi-user-edit', route: '/styling/passThrough' },
102+
{ label: 'FormKit Class', icon: 'pi pi-fw pi-user-edit', route: '/styling/class' },
103+
{ label: 'Grid based Form', icon: 'pi pi-fw pi-user-edit', route: '/styling/grid' },
102104
],
103105
},
104106
],

dev/pages/styling/Class.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ const schema
44
{
55
$formkit: 'primeInputText',
66
name: 'name',
7-
label: 'Styling by class',
7+
label: 'Styling outer class',
88
help: 'Required.',
9-
validation: 'required',
109
outerClass: 'stylingOuterClass',
1110
},
1211
{
1312
$formkit: 'primeInputText',
1413
name: 'name2',
15-
label: 'Styling by class',
14+
label: 'Styling inner class',
1615
help: 'Required.',
17-
validation: 'required',
1816
innerClass: 'stylingSampleClass',
1917
2018
},
@@ -27,7 +25,7 @@ const data = { name: 'Some Label in Green', name2: 'Some Text in Green' }
2725
<template>
2826
<div class="">
2927
<PrimeInput
30-
header="Styling" :schema="schema" form-class="grid grid-cols-2 gap-4" :data="data"
28+
header="Styling by FormKit Classes" :schema="schema" form-class="grid grid-cols-2 gap-4" :data="data"
3129
>
3230
<div class="pb-8" />
3331
</PrimeInput>

dev/pages/styling/Grid.vue

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<script setup lang='ts'>
2+
import { FormKitDataEdit, FormKitDataView } from 'my-library-components'
3+
4+
const schema
5+
= [
6+
{
7+
$formkit: 'primeInputText',
8+
name: 'name',
9+
label: 'Styling by class',
10+
help: 'Required.',
11+
validation: 'required',
12+
outerClass: 'col-span-full md:col-span-8',
13+
},
14+
{
15+
$formkit: 'primeInputText',
16+
name: 'name2',
17+
label: 'Styling by class',
18+
help: 'Required.',
19+
validation: 'required',
20+
outerClass: 'col-span-full md:col-span-4',
21+
22+
},
23+
{
24+
$formkit: 'primeInputText',
25+
name: 'name3',
26+
label: 'Styling by class',
27+
help: 'Required.',
28+
validation: 'required',
29+
outerClass: 'col-span-full md:col-span-4',
30+
31+
},
32+
33+
]
34+
35+
const data = { name: 'Some Label in Green', name2: 'Some Text in Green' }
36+
</script>
37+
38+
<template>
39+
<h2 class="text-color-[var(--primary-color)]">
40+
Grid in Data Edit
41+
</h2>
42+
<div class="p-10">
43+
<FormKitDataEdit form-class="grid grid-cols-12 gap-4" actions-class="col-span-full" :schema="schema" :data="data" :debug-schema="false" :debug-data="false" />
44+
</div>
45+
<h2 class="text-color-[var(--primary-color)]">
46+
Grid in Data View
47+
</h2>
48+
<div class="p-10">
49+
<FormKitDataView form-class="grid grid-cols-12 gap-4" :schema="schema" :data="data" :debug-schema="false" :debug-data="false" />
50+
</div>
51+
</template>
52+
53+
<style lang='scss'>
54+
55+
</style>

src/components/FormKitDataEdit.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ const props = defineProps({
1919
type: Boolean,
2020
default: false,
2121
},
22+
inputClass: {
23+
type: String,
24+
default: 'p-button p-component p-formkit-button',
25+
},
2226
submitLabel: {
2327
type: String,
2428
default: 'Save',
2529
},
30+
actionsClass: {
31+
type: String,
32+
default: '',
33+
},
2634
formClass: {
2735
type: String,
2836
default: '',
@@ -45,12 +53,12 @@ function handleSave() {
4553
id="form"
4654
v-model="formData"
4755
:form-class="formClass"
56+
:actions-class="actionsClass"
4857
type="form"
4958
:submit-label="submitLabel"
5059
:submit-attrs="{
51-
inputClass: 'p-button p-component p-formkit-button',
60+
inputClass,
5261
}"
53-
5462
@submit="handleSave"
5563
>
5664
<FormKitSchema :schema="formSchema" :data="formData" />

src/components/FormKitDataView.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ const formData = ref(props.data)
3535
v-model="formData"
3636
type="form"
3737
:form-class="formClass"
38-
:submit-attrs="{
39-
style: 'display: none;',
40-
}"
38+
:actions="false"
4139
>
4240
<FormKitSchema :schema="formSchema" :data="formData" />
4341
</FormKit>

src/sass/formkit-primevue.scss

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,6 @@
108108
margin-left: 1rem;
109109
}
110110

111-
.p-formkit-icon-left {
112-
padding-right: 0.5rem;
113-
}
114-
115-
.p-formkit-icon-right {
116-
padding-left: 0.5rem;
117-
}
118-
119111
.formkit-prefix-icon {
120112
padding-right: 0.5rem;
121113
}
@@ -141,9 +133,7 @@
141133
}
142134

143135
.p-formkit-data-view {
144-
.formkit-actions {
145-
display: none;
146-
}
136+
147137
}
148138

149139
.p-formkit-data-edit {

0 commit comments

Comments
 (0)