Skip to content

Commit be00f9b

Browse files
committed
refactor(InputText): Icons
Use Icon Field instead of custom spans use Attributes icon (and iconPosition) if needed (left: default) BREAKING CHANGE: IconField and InputIcon from latest PrimeVue 3.39.x is required for showing Icons - displaying icons on both sides is not longer supported
1 parent e7689dc commit be00f9b

File tree

1 file changed

+18
-27
lines changed

1 file changed

+18
-27
lines changed

src/formkit/PrimeInputText.vue

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,8 @@ const props = defineProps({
66
const context = props.context
77
const attrs = computed(() => context?.attrs)
88
9-
function hasLeftIcon() {
10-
return context?.iconLeft && context?.iconLeft.length > 0
11-
}
12-
13-
function hasRightIcon() {
14-
return context?.iconRight && context?.iconRight.length > 0
15-
}
16-
17-
function spanClass() {
18-
let result = ''
19-
if (hasLeftIcon())
20-
result = `p-formkit-icon ${result}p-input-icon-left `
21-
if (hasRightIcon())
22-
result = `p-formkit-icon ${result}p-input-icon-right `
23-
return result
9+
function hasIcon() {
10+
return context?.icon && context?.icon.length > 0
2411
}
2512
2613
function handleBlur(e: any) {
@@ -36,27 +23,31 @@ const styleClass = computed(() => (context?.state.validationVisible && !context?
3623

3724
<template>
3825
<div class="p-formkit">
39-
<span :class="spanClass()">
40-
<i v-if="hasLeftIcon()" :class="context?.iconLeft" />
41-
26+
<IconField v-if="hasIcon()" :icon-position="attrs.iconPosition">
27+
<InputIcon :class="context.icon" />
4228
<InputText
4329
:id="context.id"
4430
v-model="context._value"
31+
v-bind="attrs"
4532
:disabled="attrs._disabled ?? !!context?.disabled"
4633
:readonly="attrs._readonly ?? false"
4734
:style="attrs.style"
4835
:class="styleClass"
49-
:tabindex="attrs.tabindex"
50-
:aria-label="attrs.ariaLabel"
51-
:aria-labelledby="attrs.ariaLabelledby"
52-
:placeholder="attrs.placeholder"
53-
:pt="attrs.pt"
54-
:pt-options="attrs.ptOptions"
55-
:unstyled="attrs.unstyled ?? false"
5636
@input="handleInput"
5737
@blur="handleBlur"
5838
/>
59-
<i v-if="hasRightIcon()" :class="context?.iconRight" />
60-
</span>
39+
</IconField>
40+
<InputText
41+
v-else
42+
:id="context.id"
43+
v-model="context._value"
44+
v-bind="attrs"
45+
:disabled="attrs._disabled ?? !!context?.disabled"
46+
:readonly="attrs._readonly ?? false"
47+
:style="attrs.style"
48+
:class="styleClass"
49+
@input="handleInput"
50+
@blur="handleBlur"
51+
/>
6152
</div>
6253
</template>

0 commit comments

Comments
 (0)