Skip to content

Commit 4867beb

Browse files
committed
feat(primeOutputList): add listStyles: span, div, ul, ol
1 parent 5ba9ac1 commit 4867beb

File tree

6 files changed

+80
-11
lines changed

6 files changed

+80
-11
lines changed

dev/App.scss

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

1111
html {
1212
height: 100%;
13-
font-size: 14px;
13+
font-size: 16px;
1414
}
1515

1616
a {

dev/pages/outputs/OutputList.vue

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
<script setup lang='ts'>
2+
import { useFormKitSchema } from 'my-library'
3+
24
const primeAttributes = ''
35
const customAttributes = 'iconPrefix, prefix, suffix, iconSuffix'
6+
const { addElement } = useFormKitSchema()
47
58
const schema
69
= [
10+
addElement('h3', ['Default (listStyle: span)']),
11+
712
{
813
$formkit: 'primeOutputList',
914
name: 'list1',
@@ -29,14 +34,39 @@ const schema
2934
itemClass: 'p-chip-item',
3035
divider: ' ',
3136
},
37+
addElement('h3', ['List Styles']),
38+
{
39+
$formkit: 'primeOutputList',
40+
name: 'list1',
41+
label: 'Use listStyle: span',
42+
listStyle: 'span',
43+
},
44+
{
45+
$formkit: 'primeOutputList',
46+
name: 'list2',
47+
label: 'Use listStyle: div',
48+
listStyle: 'div',
49+
},
50+
{
51+
$formkit: 'primeOutputList',
52+
name: 'list2',
53+
label: 'Use listStyle: ul',
54+
listStyle: 'ul',
55+
},
56+
{
57+
$formkit: 'primeOutputList',
58+
name: 'list2',
59+
label: 'Use listStyle: ol',
60+
listStyle: 'ol',
61+
},
3262
3363
]
3464
3565
const data = { list1: ['Hello', 'World'], list2: ['FormKit', 'meets', 'PrimeVue'] }
3666
</script>
3767

3868
<template>
39-
<div class="">
69+
<div class="list">
4070
<PrimeOutput
4171
header="PrimeOutputList" :schema="schema" :data="data"
4272
:prime-attributes="primeAttributes" :custom-attributes="customAttributes"
@@ -45,5 +75,7 @@ const data = { list1: ['Hello', 'World'], list2: ['FormKit', 'meets', 'PrimeVue'
4575
</template>
4676

4777
<style lang='scss' scoped>
48-
78+
.list .p-formkit-data-view .formkit-form .formkit-outer {
79+
padding-bottom: 1rem;
80+
}
4981
</style>

dev/uno.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
defineConfig,
33
presetIcons,
4-
presetWind3,
4+
presetWind4,
55
transformerDirectives,
66
transformerVariantGroup,
77
} from 'unocss'
@@ -12,7 +12,7 @@ function convert(color: string) {
1212

1313
export default defineConfig({
1414
presets: [
15-
presetWind3(),
15+
presetWind4(),
1616
presetIcons({
1717
scale: 1.2,
1818
unit: 'em',

src/components/PrimeOutputList.vue

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,61 @@
11
<script setup lang='ts'>
22
import type { FormKitFrameworkContext } from '@formkit/core'
33
import type { PropType } from 'vue'
4+
import { computed } from 'vue'
45
import { useFormKitSection } from '../composables'
56
7+
export interface FormKitOutputListProps {
8+
listStyle?: 'div' | 'ul' | 'ol' | 'span'
9+
}
10+
611
const props = defineProps({
712
context: {
8-
type: Object as PropType<FormKitFrameworkContext>,
13+
type: Object as PropType<FormKitFrameworkContext & FormKitOutputListProps>,
914
required: true,
1015
},
1116
})
1217
18+
const listStyle = computed(() => {
19+
return props.context?.listStyle || 'span'
20+
})
21+
1322
const { hasPrefix, hasPrefixIcon, hasSuffix, hasSuffixIcon } = useFormKitSection(props.context)
1423
</script>
1524

1625
<template>
1726
<div class="p-formkit p-output-list">
1827
<i v-if="hasPrefixIcon" class="formkit-prefix-icon" :class="context?.iconPrefix" />
19-
<span v-if="hasPrefix" class="formkit-prefix">
28+
<span v-if="hasPrefix && listStyle === 'span'" class="formkit-prefix">
2029
{{ context?.prefix }}
2130
</span>
22-
<span :id="context?.id" :style="context?.attrs?.style" class="p-output-list-items" :class="context?.attrs?.class">
31+
<span v-if="listStyle === 'span'" :id="context?.id" :style="context?.attrs?.style" class="p-output-list-items" :class="context?.attrs?.class">
2332
<template v-for="(value, index) of context?._value" :key="index">
2433
<span v-if="index !== 0" class="p-output-list-divider" :class="context?.dividerClass">{{ context?.divider ?? ', ' }}</span>
2534
<span class="p-output-list-item" :class="context?.itemClass">{{ value }}</span>
2635
</template>
2736
</span>
28-
<span v-if="hasSuffix" class="formkit-suffix">
37+
<div v-if="listStyle === 'div'" :id="context?.id" :style="context?.attrs?.style" class="p-output-list-items" :class="context?.attrs?.class">
38+
<template v-for="(value, index) of context?._value" :key="index">
39+
<div class="p-output-list-item" :class="context?.itemClass">
40+
{{ value }}
41+
</div>
42+
</template>
43+
</div>
44+
<ul v-if="listStyle === 'ul'" :id="context?.id" :style="context?.attrs?.style" class="p-output-list-items" :class="context?.attrs?.class">
45+
<li v-for="(value, index) of context?._value" :key="index">
46+
<span class="p-output-list-item" :class="context?.itemClass">
47+
{{ value }}
48+
</span>
49+
</li>
50+
</ul>
51+
<ol v-if="listStyle === 'ol'" :id="context?.id" :style="context?.attrs?.style" class="p-output-list-items" :class="context?.attrs?.class">
52+
<li v-for="(value, index) of context?._value" :key="index">
53+
<span class="p-output-list-item" :class="context?.itemClass">
54+
{{ value }}
55+
</span>
56+
</li>
57+
</ol>
58+
<span v-if="hasSuffix && listStyle === 'span'" class="formkit-suffix">
2959
{{ context?.suffix }}
3060
</span>
3161
<i v-if="hasSuffixIcon" class="formkit-suffix-icon" :class="context?.iconSuffix" />

src/definitions/output.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ export const primeOutputDurationDefinition: FormKitTypeDefinition = createInput(
3838
})
3939

4040
export const primeOutputListDefinition: FormKitTypeDefinition = createInput(PrimeOutputList, {
41-
props: ['prefix', 'suffix', 'iconPrefix', 'iconSuffix', 'divider', 'itemClass', 'dividerClass'],
41+
props: ['prefix', 'suffix', 'iconPrefix', 'iconSuffix', 'divider', 'itemClass', 'dividerClass', 'listStyle'],
4242
})

src/sass/formkit-primevue.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,23 @@ $grid-breakpoints: (
179179
.p-formkit-data-view {
180180
.formkit-form {
181181
.formkit-outer {
182-
padding-bottom: 0.25rem;
182+
padding-bottom: 0.5rem;
183183
}
184184

185185
&.form-horizontal {
186186
padding-bottom: 0.8rem;
187187
}
188188

189189
.formkit-help {
190+
padding-top: 0.25rem;
190191
margin: 0;
191192
}
193+
194+
ul, ol {
195+
padding-inline-start: 1rem;
196+
margin-block-start: 0;
197+
margin-block-end: 0;
198+
}
192199
}
193200
}
194201

0 commit comments

Comments
 (0)