@@ -8,9 +8,13 @@ import FormKitIcon from './FormKitIcon.vue'
88import FormKitPrefix from ' ./FormKitPrefix.vue'
99import FormKitSuffix from ' ./FormKitSuffix.vue'
1010
11+ export interface PrimeOutputListProps {
12+ convertValue? : (array : []) => []
13+ }
14+
1115const props = defineProps ({
1216 context: {
13- type: Object as PropType <FormKitFrameworkContext > & FormKitIconProps ,
17+ type: Object as PropType <FormKitFrameworkContext > & FormKitIconProps & PrimeOutputListProps ,
1418 required: true ,
1519 },
1620})
@@ -20,34 +24,42 @@ const listStyle = computed(() => {
2024})
2125
2226const { hasPrefix, hasPrefixIcon, hasSuffix, hasSuffixIcon } = useFormKitSection (props .context )
27+
28+ const getListValues = computed (() => {
29+ const values = Array .isArray (props .context ?._value ) ? props .context ._value : []
30+ if (typeof props .context ?.convertValue === ' function' ) {
31+ return [props .context .convertValue ([... values ])]
32+ }
33+ return values
34+ })
2335 </script >
2436
2537<template >
2638 <div class =" p-formkit p-output-list" >
2739 <FormKitIcon v-if =" hasPrefixIcon" :icon-class =" context?.iconPrefix as string" :on-click =" context?.onIconPrefixClicked as (() => void)" position =" prefix" />
2840 <FormKitPrefix v-if =" hasPrefix && listStyle === 'span'" :prefix =" context?.prefix as string" />
2941 <span v-if =" listStyle === 'span'" :id =" context?.id" :style =" context?.attrs?.style" class =" p-output-list-items" :class =" context?.attrs?.class" >
30- <template v-for =" (value , index ) of context ?. _value " :key =" index " >
42+ <template v-for =" (value , index ) of getListValues " :key =" index " >
3143 <span v-if =" index !== 0" class =" p-output-list-divider" :class =" context?.dividerClass" >{{ context?.divider ?? ', ' }}</span >
3244 <span class =" p-output-list-item" :class =" context?.itemClass" >{{ value }}</span >
3345 </template >
3446 </span >
3547 <div v-if =" listStyle === 'div'" :id =" context?.id" :style =" context?.attrs?.style" class =" p-output-list-items" :class =" context?.attrs?.class" >
36- <template v-for =" (value , index ) of context ?. _value " :key =" index " >
48+ <template v-for =" (value , index ) of getListValues " :key =" index " >
3749 <div class =" p-output-list-item" :class =" context?.itemClass" >
3850 {{ value }}
3951 </div >
4052 </template >
4153 </div >
4254 <ul v-if =" listStyle === 'ul'" :id =" context?.id" :style =" context?.attrs?.style" class =" p-output-list-items" :class =" context?.attrs?.class" >
43- <li v-for =" (value, index) of context?._value " :key =" index" >
55+ <li v-for =" (value, index) of getListValues " :key =" index" >
4456 <span class =" p-output-list-item" :class =" context?.itemClass" >
4557 {{ value }}
4658 </span >
4759 </li >
4860 </ul >
4961 <ol v-if =" listStyle === 'ol'" :id =" context?.id" :style =" context?.attrs?.style" class =" p-output-list-items" :class =" context?.attrs?.class" >
50- <li v-for =" (value, index) of context?._value " :key =" index" >
62+ <li v-for =" (value, index) of getListValues " :key =" index" >
5163 <span class =" p-output-list-item" :class =" context?.itemClass" >
5264 {{ value }}
5365 </span >
0 commit comments