Skip to content

Commit d5f6eca

Browse files
committed
feat(PrimeOutputList): Introduce Divider and more styling options - Add Chips Demo
1 parent 185aad1 commit d5f6eca

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

dev/pages/outputs/OutputList.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,27 @@ const schema
77
{
88
$formkit: 'primeOutputList',
99
name: 'list1',
10-
label: 'list1',
10+
label: 'Default Divider',
11+
},
12+
{
13+
$formkit: 'primeOutputList',
14+
name: 'list1',
15+
label: 'Custom Divider',
16+
divider: ' ',
1117
},
1218
{
1319
$formkit: 'primeOutputList',
1420
name: 'list2',
21+
label: 'Custom Divider with Prefix Icon',
22+
iconPrefix: 'pi pi-list',
1523
divider: ' - ',
16-
label: 'list2',
24+
},
25+
{
26+
$formkit: 'primeOutputList',
27+
name: 'list2',
28+
label: 'Use Chips from PrimeVue',
29+
itemClass: 'p-chip',
30+
divider: ' ',
1731
},
1832
1933
]
@@ -24,7 +38,7 @@ const data = { list1: ['Hello', 'World'], list2: ['FormKit', 'meets', 'PrimeVue'
2438
<template>
2539
<div class="">
2640
<PrimeOutput
27-
header="PrimeOutputBoolean" :schema="schema" :data="data"
41+
header="PrimeOutputList" :schema="schema" :data="data"
2842
:prime-attributes="primeAttributes" :custom-attributes="customAttributes"
2943
/>
3044
</div>

src/components/PrimeOutputList.vue

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ const props = defineProps({
1111
})
1212
1313
const { hasPrefix, hasPrefixIcon, hasSuffix, hasSuffixIcon } = useFormKitSection(props.context)
14-
15-
function listValue(index: number, value: string): string {
16-
const divider = props.context?.attrs?.divider || ', '
17-
if (index === 0)
18-
return value
19-
else
20-
return `${divider}${value}`
21-
}
2214
</script>
2315

2416
<template>
@@ -27,9 +19,10 @@ function listValue(index: number, value: string): string {
2719
<span v-if="hasPrefix" class="formkit-prefix">
2820
{{ context?.attrs?.prefix }}
2921
</span>
30-
<span :id="context?.id" :style="context?.attrs?.style" :class="context?.attrs?.class">
22+
<span :id="context?.id" :style="context?.attrs?.style" class="p-output-list-items" :class="context?.attrs?.class">
3123
<template v-for="(value, index) of context?._value" :key="index">
32-
<span class="p-output-list-item">{{ listValue(index, value) }}</span>
24+
<span v-if="index !== 0" class="p-output-list-divider" :class="context?.dividerClass">{{ context?.divider ?? ', ' }}</span>
25+
<span class="p-output-list-item" :class="context?.itemClass">{{ value }}</span>
3326
</template>
3427
</span>
3528
<span v-if="hasSuffix" class="formkit-suffix">

0 commit comments

Comments
 (0)