@@ -8,8 +8,7 @@ export interface FormKitPrimeInputTextProps {
88 ptOptions? : InputTextProps [' ptOptions' ]
99 unstyled? : InputTextProps [' unstyled' ]
1010 placeholder? : InputTextProps [' placeholder' ]
11- iconLeft? : string
12- iconRight? : string
11+ icon? : string
1312}
1413
1514const props = defineProps ({
@@ -19,21 +18,8 @@ const props = defineProps({
1918 },
2019})
2120
22- function hasLeftIcon() {
23- return props .context ?.iconLeft && props .context ?.iconLeft .length > 0
24- }
25-
26- function hasRightIcon() {
27- return props .context ?.iconRight && props .context ?.iconRight .length > 0
28- }
29-
30- function spanClass() {
31- let result = ' '
32- if (hasLeftIcon ())
33- result = ` p-formkit-icon ${result }p-input-icon-left `
34- if (hasRightIcon ())
35- result = ` p-formkit-icon ${result }p-input-icon-right `
36- return result
21+ function hasIcon() {
22+ return props .context ?.attrs ?.icon && props .context ?.attrs ?.icon .length > 0
3723}
3824
3925function handleBlur(e : Event ) {
@@ -49,13 +35,13 @@ const styleClass = computed(() => (props.context?.state.validationVisible && !pr
4935
5036<template >
5137 <div class =" p-formkit" >
52- < span :class = " spanClass() " >
53- < i v-if =" hasLeftIcon ()" :class =" context?.iconLeft " / >
54-
38+ {{ context.attrs.icon }}
39+ < IconField v-if =" hasIcon ()" :icon-position =" context?.attrs.iconPosition " >
40+ < InputIcon :class = " context.attrs.icon " />
5541 <InputText
5642 :id =" context.id"
5743 v-model =" context._value"
58- v-bind =" context.attrs"
44+ v-bind =" context? .attrs"
5945 :disabled =" !!context?.disabled"
6046 :readonly =" context?.attrs._readonly ?? false"
6147 :style =" context?.attrs.style"
@@ -70,7 +56,25 @@ const styleClass = computed(() => (props.context?.state.validationVisible && !pr
7056 @input =" handleInput"
7157 @blur =" handleBlur"
7258 />
73- <i v-if =" hasRightIcon()" :class =" context?.iconRight" />
74- </span >
59+ </IconField >
60+ <InputText
61+ v-else
62+ :id =" context.id"
63+ v-model =" context._value"
64+ v-bind =" context?.attrs"
65+ :disabled =" !!context?.disabled"
66+ :readonly =" context?.attrs._readonly ?? false"
67+ :style =" context?.attrs.style"
68+ :class =" styleClass"
69+ :tabindex =" context?.attrs.tabindex"
70+ :aria-label =" context?.attrs.ariaLabel"
71+ :aria-labelledby =" context?.attrs.ariaLabelledby"
72+ :placeholder =" context.placeholder"
73+ :pt =" context.pt"
74+ :pt-options =" context.ptOptions"
75+ :unstyled =" context.unstyled ?? false"
76+ @input =" handleInput"
77+ @blur =" handleBlur"
78+ />
7579 </div >
7680</template >
0 commit comments