Skip to content

Commit b656541

Browse files
committed
feat(data): Add formClass to DataEdit and DataView - add demo for formkit class styling
1 parent e4804ab commit b656541

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

dev/components/demo/PrimeInput.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const props = defineProps<{
1111
data: object
1212
primeAttributes?: string
1313
customAttributes?: string
14+
formClass?: string
1415
}>()
1516
1617
const toast = useToast()
@@ -38,7 +39,7 @@ async function submitHandler() {
3839
<slot />
3940
<div class="flex flex-wrap gap-8">
4041
<div class="min-w-30rem basis-1/3 md:basis-1/4">
41-
<FormKitDataEdit :schema="formSchema" :data="formData" :debug-schema="false" :debug-data="true" @data-saved="submitHandler" />
42+
<FormKitDataEdit :form-class="formClass" :schema="formSchema" :data="formData" :debug-schema="false" :debug-data="true" form-class="data-edit" @data-saved="submitHandler" />
4243
</div>
4344
<div class="">
4445
<Tabs>

dev/pages/styling/Class.vue

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<script setup lang='ts'>
2+
const schema
3+
= [
4+
{
5+
$formkit: 'primeInputText',
6+
name: 'name',
7+
label: 'Styling by class',
8+
help: 'Required.',
9+
validation: 'required',
10+
outerClass: 'stylingOuterClass',
11+
},
12+
{
13+
$formkit: 'primeInputText',
14+
name: 'name2',
15+
label: 'Styling by class',
16+
help: 'Required.',
17+
validation: 'required',
18+
innerClass: 'stylingSampleClass',
19+
20+
},
21+
22+
]
23+
24+
const data = { name: 'Some Label in Green', name2: 'Some Text in Green' }
25+
</script>
26+
27+
<template>
28+
<div class="">
29+
<PrimeInput
30+
header="Styling" :schema="schema" form-class="grid grid-cols-2 gap-4" :data="data"
31+
>
32+
<div class="pb-8" />
33+
</PrimeInput>
34+
</div>
35+
</template>
36+
37+
<style lang='scss'>
38+
.stylingOuterClass {
39+
color: yellowgreen;
40+
}
41+
.stylingSampleClass {
42+
input {
43+
color: green;
44+
}
45+
}
46+
</style>

src/components/FormKitDataEdit.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ const props = defineProps({
2323
type: String,
2424
default: 'Save',
2525
},
26+
formClass: {
27+
type: String,
28+
default: '',
29+
},
2630
})
2731
2832
const emit = defineEmits(['dataSaved'])
@@ -40,11 +44,13 @@ function handleSave() {
4044
<FormKit
4145
id="form"
4246
v-model="formData"
47+
:form-class="formClass"
4348
type="form"
4449
:submit-label="submitLabel"
4550
:submit-attrs="{
4651
inputClass: 'p-button p-component p-formkit-button',
4752
}"
53+
4854
@submit="handleSave"
4955
>
5056
<FormKitSchema :schema="formSchema" :data="formData" />

src/components/FormKitDataView.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const props = defineProps({
1111
type: Object,
1212
default: null,
1313
},
14+
formClass: {
15+
type: String,
16+
default: '',
17+
},
1418
debugData: {
1519
type: Boolean,
1620
default: false,
@@ -30,6 +34,7 @@ const formData = ref(props.data)
3034
<FormKit
3135
v-model="formData"
3236
type="form"
37+
:form-class="formClass"
3338
:submit-attrs="{
3439
style: 'display: none;',
3540
}"

0 commit comments

Comments
 (0)