@@ -8,9 +8,13 @@ import FormKitIcon from './FormKitIcon.vue'
8
8
import FormKitPrefix from ' ./FormKitPrefix.vue'
9
9
import FormKitSuffix from ' ./FormKitSuffix.vue'
10
10
11
+ export interface PrimeOutputListProps {
12
+ convertValue? : (array : []) => []
13
+ }
14
+
11
15
const props = defineProps ({
12
16
context: {
13
- type: Object as PropType <FormKitFrameworkContext > & FormKitIconProps ,
17
+ type: Object as PropType <FormKitFrameworkContext > & FormKitIconProps & PrimeOutputListProps ,
14
18
required: true ,
15
19
},
16
20
})
@@ -20,34 +24,42 @@ const listStyle = computed(() => {
20
24
})
21
25
22
26
const { 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
+ })
23
35
</script >
24
36
25
37
<template >
26
38
<div class =" p-formkit p-output-list" >
27
39
<FormKitIcon v-if =" hasPrefixIcon" :icon-class =" context?.iconPrefix as string" :on-click =" context?.onIconPrefixClicked as (() => void)" position =" prefix" />
28
40
<FormKitPrefix v-if =" hasPrefix && listStyle === 'span'" :prefix =" context?.prefix as string" />
29
41
<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 " >
31
43
<span v-if =" index !== 0" class =" p-output-list-divider" :class =" context?.dividerClass" >{{ context?.divider ?? ', ' }}</span >
32
44
<span class =" p-output-list-item" :class =" context?.itemClass" >{{ value }}</span >
33
45
</template >
34
46
</span >
35
47
<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 " >
37
49
<div class =" p-output-list-item" :class =" context?.itemClass" >
38
50
{{ value }}
39
51
</div >
40
52
</template >
41
53
</div >
42
54
<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" >
44
56
<span class =" p-output-list-item" :class =" context?.itemClass" >
45
57
{{ value }}
46
58
</span >
47
59
</li >
48
60
</ul >
49
61
<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" >
51
63
<span class =" p-output-list-item" :class =" context?.itemClass" >
52
64
{{ value }}
53
65
</span >
0 commit comments