@@ -13,6 +13,8 @@ export type FormKitPrimeInputMaskProps = {
13
13
unstyled? : InputMaskProps [' unstyled' ];
14
14
invalid? : InputMaskProps [' invalid' ];
15
15
variant? : InputMaskProps [' variant' ];
16
+ iconLeft? : string ;
17
+ iconRight? : string ;
16
18
}
17
19
18
20
const props = defineProps ({
@@ -26,30 +28,54 @@ function handleInput(e: Event) {
26
28
props .context ?.node .input (props .context ?._value )
27
29
props .context ?.handlers .blur (e )
28
30
}
31
+
32
+ function hasLeftIcon() {
33
+ return props .context ?.iconLeft && props .context ?.iconLeft .length > 0
34
+ }
35
+
36
+ function hasRightIcon() {
37
+ return props .context ?.iconRight && props .context ?.iconRight .length > 0
38
+ }
39
+
40
+ function spanClass() {
41
+ let result = ' '
42
+ if (hasLeftIcon ())
43
+ result = ` ${result }p-input-icon-left `
44
+ if (hasRightIcon ())
45
+ result = ` ${result }p-input-icon-right `
46
+ return result
47
+ }
48
+
29
49
const styleClass = computed (() => (props .context ?.state .validationVisible && ! props .context ?.state .valid ) ? ` ${props .context ?.attrs ?.class } p-invalid ` : props .context ?.attrs ?.class )
30
50
</script >
31
51
32
52
<template >
33
53
<div class =" p-formkit" >
34
- <InputMask
35
- :id =" context.id"
36
- v-model =" context._value"
37
- :disabled =" !!context?.disabled"
38
- :readonly =" context?.attrs._readonly ?? false"
39
- :class =" styleClass"
40
- :tabindex =" context?.attrs.tabindex"
41
- :aria-label =" context?.attrs.ariaLabel"
42
- :aria-labelledby =" context?.attrs.ariaLabelledby"
43
- :mask =" context.mask ?? undefined"
44
- :slot-char =" context.slotChar ?? '_'"
45
- :auto-clear =" context.autoClear ?? true"
46
- :unmask =" context.unmask ?? false"
47
- :pt =" context.pt"
48
- :invalid =" context.invalid"
49
- :variant =" context.variant"
50
- :pt-options =" context.ptOptions"
51
- :unstyled =" context.unstyled ?? false"
52
- @blur =" handleInput"
53
- />
54
+ <span :class =" spanClass()" >
55
+ <i v-if =" hasLeftIcon()" :class =" context.iconLeft" />
56
+
57
+ <InputMask
58
+ :id =" context.id"
59
+ v-model =" context._value"
60
+ :disabled =" !!context?.disabled"
61
+ :readonly =" context?.attrs._readonly ?? false"
62
+ :class =" styleClass"
63
+ :tabindex =" context?.attrs.tabindex"
64
+ :aria-label =" context?.attrs.ariaLabel"
65
+ :aria-labelledby =" context?.attrs.ariaLabelledby"
66
+ :mask =" context.mask ?? undefined"
67
+ :slot-char =" context.slotChar ?? '_'"
68
+ :auto-clear =" context.autoClear ?? true"
69
+ :unmask =" context.unmask ?? false"
70
+ :pt =" context.pt"
71
+ :invalid =" context.invalid"
72
+ :variant =" context.variant"
73
+ :pt-options =" context.ptOptions"
74
+ :unstyled =" context.unstyled ?? false"
75
+ @blur =" handleInput"
76
+ />
77
+
78
+ <i v-if =" hasRightIcon" :class =" context.iconRight" />
79
+ </span >
54
80
</div >
55
81
</template >
0 commit comments