2
2
import { type PropType , computed } from ' vue'
3
3
import type { FormKitFrameworkContext } from ' @formkit/core'
4
4
import type { InputTextProps } from ' primevue/inputtext'
5
+ import type { IconFieldProps } from ' primevue/iconfield'
5
6
6
7
export interface FormKitPrimeInputTextProps {
7
8
pt? : InputTextProps [' pt' ]
8
9
ptOptions? : InputTextProps [' ptOptions' ]
9
10
unstyled? : InputTextProps [' unstyled' ]
10
11
placeholder? : InputTextProps [' placeholder' ]
11
12
icon? : string
13
+ iconPosition? : IconFieldProps [' iconPosition' ]
12
14
}
13
15
14
16
const props = defineProps ({
@@ -24,7 +26,15 @@ const hasIcon = computed(() => {
24
26
}
25
27
26
28
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
+ })
28
38
29
39
function handleBlur(e : Event ) {
30
40
props .context ?.handlers .blur (e )
@@ -39,8 +49,8 @@ const styleClass = computed(() => (props.context?.state.validationVisible && !pr
39
49
40
50
<template >
41
51
<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" />
44
54
<InputText
45
55
:id =" context.id"
46
56
v-model =" context._value"
0 commit comments