Skip to content

Commit 730f20e

Browse files
committed
refactor(Outputs): Add some more properties and add new PrimeOutputReference component
1 parent 774572f commit 730f20e

File tree

15 files changed

+153
-21
lines changed

15 files changed

+153
-21
lines changed

dev/components/app/AppTopbar.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const items = ref([
9494
{ label: 'Output List', icon: 'pi pi-fw pi-user-edit', route: '/outputs/outputList' },
9595
{ label: 'Output Boolean', icon: 'pi pi-fw pi-user-edit', route: '/outputs/outputBoolean' },
9696
{ label: 'Output Duration', icon: 'pi pi-fw pi-user-edit', route: '/outputs/outputDuration' },
97+
{ label: 'Output Reference', icon: 'pi pi-fw pi-user-edit', route: '/outputs/outputReference' },
9798
],
9899
},
99100
],

dev/pages/outputs/OutputLink.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ const schema
77
{
88
$formkit: 'primeOutputLink',
99
name: 'link1',
10-
label: 'Link',
10+
label: 'External Link',
1111
},
1212
{
1313
$formkit: 'primeOutputLink',
1414
name: 'link2',
15-
label: 'No prefix',
15+
label: 'Ensure protocol with custom title',
16+
title: 'Click me',
1617
},
1718
1819
]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<script setup lang='ts'>
2+
const primeAttributes = ''
3+
const customAttributes = 'iconPrefix, prefix, suffix, iconSuffix'
4+
5+
const schema
6+
= [
7+
{
8+
$formkit: 'primeOutputReference',
9+
name: 'externalId',
10+
label: 'External Link',
11+
reference: 'https://github.com/sfxcode/{{value}}',
12+
},
13+
{
14+
$formkit: 'primeOutputReference',
15+
name: 'externalValue',
16+
label: 'Another External Link',
17+
reference: 'https://github.com/sfxcode/{{valueNameNotImportant}}',
18+
},
19+
{
20+
$formkit: 'primeOutputReference',
21+
name: 'internalLink',
22+
label: 'Internal Link',
23+
internal: true,
24+
reference: '/outputs/{{value}}',
25+
},
26+
27+
]
28+
29+
const data = { externalId: 42, externalValue: 'formkit', internalLink: 'outputLink' }
30+
</script>
31+
32+
<template>
33+
<div class="">
34+
<PrimeOutput
35+
header="PrimeOutputReference" :schema="schema" :data="data"
36+
:prime-attributes="primeAttributes" :custom-attributes="customAttributes"
37+
/>
38+
</div>
39+
</template>
40+
41+
<style lang='scss' scoped>
42+
43+
</style>

dev/pages/outputs/OutputText.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ const schema
99
name: 'name',
1010
label: 'Basic',
1111
},
12+
{
13+
$formkit: 'primeOutputText',
14+
name: 'html',
15+
label: 'HTML as Text (Default)',
16+
},
17+
{
18+
$formkit: 'primeOutputText',
19+
name: 'html',
20+
html: true,
21+
label: 'HTML Output (v-html)',
22+
help: 'Only use on trusted content or sanitize after input !',
23+
},
1224
{
1325
$formkit: 'primeOutputText',
1426
id: 'icon',
@@ -27,7 +39,7 @@ const schema
2739
2840
]
2941
30-
const data = { name: 'Harry Potter', iconLeft: 'Some Text ...', iconRight: 'Another Text ...' }
42+
const data = { name: 'Harry Potter', iconLeft: 'Some Text ...', iconRight: 'Another Text ...', html: '<b style="color: gold">Bold Hello World</b>' }
3143
</script>
3244

3345
<template>

docs/.vitepress/theme/components/DisplayOutputComponents.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang='ts'>
22
import { ref } from 'vue'
33
4-
const primeOutputNames = ['OutputBoolean', 'OutputDate', 'OutputDuration', 'OutputLink', 'OutputList', 'OutputNumber', 'OutputText']
4+
const primeOutputNames = ['OutputBoolean', 'OutputDate', 'OutputDuration', 'OutputLink', 'OutputList', 'OutputNumber', 'OutputReference', 'OutputText']
55
66
const names = ref(primeOutputNames.sort((a, b) => a.localeCompare(b)))
77
</script>

src/components/PrimeOutputDate.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ const converted = computed(() => {
3636
<div class="p-formkit p-output-date">
3737
<i v-if="hasPrefixIcon" class="formkit-prefix-icon" :class="context?.iconPrefix" />
3838
<span v-if="hasPrefix" class="formkit-prefix">
39-
{{ context?.attrs?.prefix }}
39+
{{ context?.prefix }}
4040
</span>
4141
<span :id="context?.id" :style="context?.attrs?.style" :class="context?.attrs?.class">
4242
{{ converted }}
4343
</span>
4444
<span v-if="hasSuffix" class="formkit-suffix">
45-
{{ context?.attrs?.suffix }}
45+
{{ context?.suffix }}
4646
</span>
4747
<i v-if="hasSuffixIcon" class="formkit-suffix-icon" :class="context?.iconSuffix" />
4848
</div>

src/components/PrimeOutputDuration.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ const { formattedDuration } = useOutputDuration()
1818
<div class="p-formkit p-output-duration">
1919
<i v-if="hasPrefixIcon" class="formkit-prefix-icon" :class="context?.iconPrefix" />
2020
<span v-if="hasPrefix" class="formkit-prefix">
21-
{{ context?.attrs?.prefix }}
21+
{{ context?.prefix }}
2222
</span>
2323
<span :id="context?.id" :style="context?.attrs?.style" :class="context?.attrs?.class">
2424
{{ formattedDuration(context?._value) }}
2525
</span>
2626
<span v-if="hasSuffix" class="formkit-suffix">
27-
{{ context?.attrs?.suffix }}
27+
{{ context?.suffix }}
2828
</span>
2929
<i v-if="hasSuffixIcon" class="formkit-suffix-icon" :class="context?.iconSuffix" />
3030
</div>

src/components/PrimeOutputLink.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ const props = defineProps({
1313
const { hasPrefix, hasPrefixIcon, hasSuffix, hasSuffixIcon } = useFormKitSection(props.context)
1414
1515
const url = computed(() => props.context?._value.indexOf('http') > -1 ? props.context?._value : `https://${props.context?._value}`)
16+
17+
const title = computed(() => {
18+
const value = props.context?._value ?? ''
19+
return props.context?.title ?? value
20+
})
1621
</script>
1722

1823
<template>
1924
<div class="p-formkit p-output-link">
2025
<i v-if="hasPrefixIcon" class="formkit-prefix-icon" :class="context?.iconPrefix" />
2126
<span v-if="hasPrefix" class="formkit-prefix">
22-
{{ context?.attrs?.prefix }}
27+
{{ context?.prefix }}
2328
</span>
2429
<a
2530
:id="context?.id"
@@ -28,10 +33,10 @@ const url = computed(() => props.context?._value.indexOf('http') > -1 ? props.co
2833
:href="url"
2934
:target="context?.attrs?.target ?? '_new'"
3035
>
31-
{{ context?._value }}
36+
<span>{{ title }}</span>
3237
</a>
3338
<span v-if="hasSuffix" class="formkit-suffix">
34-
{{ context?.attrs?.suffix }}
39+
{{ context?.suffix }}
3540
</span>
3641
<i v-if="hasSuffixIcon" class="formkit-suffix-icon" :class="context?.iconSuffix" />
3742
</div>

src/components/PrimeOutputList.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const { hasPrefix, hasPrefixIcon, hasSuffix, hasSuffixIcon } = useFormKitSection
1717
<div class="p-formkit p-output-list">
1818
<i v-if="hasPrefixIcon" class="formkit-prefix-icon" :class="context?.iconPrefix" />
1919
<span v-if="hasPrefix" class="formkit-prefix">
20-
{{ context?.attrs?.prefix }}
20+
{{ context?.prefix }}
2121
</span>
2222
<span :id="context?.id" :style="context?.attrs?.style" class="p-output-list-items" :class="context?.attrs?.class">
2323
<template v-for="(value, index) of context?._value" :key="index">
@@ -26,7 +26,7 @@ const { hasPrefix, hasPrefixIcon, hasSuffix, hasSuffixIcon } = useFormKitSection
2626
</template>
2727
</span>
2828
<span v-if="hasSuffix" class="formkit-suffix">
29-
{{ context?.attrs?.suffix }}
29+
{{ context?.suffix }}
3030
</span>
3131
<i v-if="hasSuffixIcon" class="formkit-suffix-icon" :class="context?.iconSuffix" />
3232
</div>

src/components/PrimeOutputNumber.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ const converted = computed(() => {
4444
<div class="p-formkit p-output-number">
4545
<i v-if="hasPrefixIcon" class="formkit-prefix-icon" :class="context?.iconPrefix" />
4646
<span v-if="hasPrefix" class="formkit-prefix">
47-
{{ context?.attrs?.prefix }}
47+
{{ context?.prefix }}
4848
</span>
4949
<span :id="context?.id" :style="context?.attrs?.style" :class="context?.attrs?.class">
5050
{{ converted }}
5151
</span>
5252
<span v-if="hasSuffix" class="formkit-suffix">
53-
{{ context?.attrs?.suffix }}
53+
{{ context?.suffix }}
5454
</span>
5555
<i v-if="hasSuffixIcon" class="formkit-suffix-icon" :class="context?.iconSuffix" />
5656
</div>

0 commit comments

Comments
 (0)