Skip to content

Commit c7d61b4

Browse files
committed
fix: use icon and iconPosition prop defined in formkit component, to allow kebab-cased props in non-schema definitions
1 parent d9b4ca6 commit c7d61b4

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/components/PrimeInputText.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
import { type PropType, computed } from 'vue'
33
import type { FormKitFrameworkContext } from '@formkit/core'
44
import type { InputTextProps } from 'primevue/inputtext'
5+
import type { IconFieldProps } from 'primevue/iconfield'
56
67
export interface FormKitPrimeInputTextProps {
78
pt?: InputTextProps['pt']
89
ptOptions?: InputTextProps['ptOptions']
910
unstyled?: InputTextProps['unstyled']
1011
placeholder?: InputTextProps['placeholder']
1112
icon?: string
13+
iconPosition?: IconFieldProps['iconPosition']
1214
}
1315
1416
const props = defineProps({
@@ -24,7 +26,15 @@ const hasIcon = computed(() => {
2426
}
2527
2628
return props.context?.attrs?.icon && props.context?.attrs?.icon.length > 0
27-
}
29+
})
30+
31+
const icon = computed(() => {
32+
return props.context?.icon ?? props.context?.attrs?.icon
33+
})
34+
35+
const iconPosition = computed(() => {
36+
return props.context?.attrs?.iconPosition ?? undefined;
37+
})
2838
2939
function handleBlur(e: Event) {
3040
props.context?.handlers.blur(e)
@@ -39,8 +49,8 @@ const styleClass = computed(() => (props.context?.state.validationVisible && !pr
3949

4050
<template>
4151
<div class="p-formkit">
42-
<IconField v-if="hasIcon" :icon-position="context?.attrs.iconPosition">
43-
<InputIcon :class="context.attrs.icon" />
52+
<IconField v-if="hasIcon" :icon-position="iconPosition">
53+
<InputIcon :class="icon" />
4454
<InputText
4555
:id="context.id"
4656
v-model="context._value"

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ export const primeAutoCompleteDefinition: FormKitTypeDefinition = createInput(Pr
4646
})
4747
export const primeInputTextDefinition: FormKitTypeDefinition = createInput(PrimeInputText, {
4848
props: [
49-
'iconRight',
50-
'iconLeft',
5149
'pt',
5250
'ptOptions',
5351
'unstyled',
5452
'placeholder',
53+
'icon',
5554
],
5655
})
5756

0 commit comments

Comments
 (0)