diff --git a/src/components/PrimeInputText.vue b/src/components/PrimeInputText.vue index be67293a..241010e0 100644 --- a/src/components/PrimeInputText.vue +++ b/src/components/PrimeInputText.vue @@ -2,6 +2,7 @@ import { type PropType, computed } from 'vue' import type { FormKitFrameworkContext } from '@formkit/core' import type { InputTextProps } from 'primevue/inputtext' +import type { IconFieldProps } from 'primevue/iconfield' export interface FormKitPrimeInputTextProps { pt?: InputTextProps['pt'] @@ -9,6 +10,7 @@ export interface FormKitPrimeInputTextProps { unstyled?: InputTextProps['unstyled'] placeholder?: InputTextProps['placeholder'] icon?: string + iconPosition?: IconFieldProps['iconPosition'] } const props = defineProps({ @@ -18,9 +20,21 @@ const props = defineProps({ }, }) -function hasIcon() { +const hasIcon = computed(() => { + if (props.context?.icon && props.context?.icon.length > 0) { + return true + } + return props.context?.attrs?.icon && props.context?.attrs?.icon.length > 0 -} +}) + +const icon = computed(() => { + return props.context?.icon ?? props.context?.attrs?.icon +}) + +const iconPosition = computed(() => { + return props.context?.attrs?.iconPosition ?? undefined; +}) function handleBlur(e: Event) { props.context?.handlers.blur(e) @@ -35,9 +49,8 @@ const styleClass = computed(() => (props.context?.state.validationVisible && !pr