File tree 1 file changed +3
-1
lines changed
1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ let mdcTextField = {}
20
20
21
21
$: mdcTextField .value = value
22
22
$: width = ` ${ element .offsetWidth } px`
23
+ $: hasReachedMaxLength = maxlength && value .length >= maxlength
23
24
24
25
onMount (() => {
25
26
mdcTextField = new MDCTextField (element)
@@ -58,6 +59,7 @@ const focus = (node) => autofocus && node.focus()
58
59
class ="mdc-text-field mdc-text-field--outlined {$$props .class } textfield-radius"
59
60
class:mdc-text-field--no-label ={! label }
60
61
class:mdc-text-field--disabled ={disabled }
62
+ class:mdc-text-field--invalid ={hasReachedMaxLength }
61
63
bind:this ={element }
62
64
>
63
65
<i class ="material-icons" aria-hidden ="true" >{icon }</i >
@@ -94,7 +96,7 @@ const focus = (node) => autofocus && node.focus()
94
96
{/if }
95
97
{#if maxlength }
96
98
<div class =" mdc-text-field-helper-line" >
97
- <div class ="mdc-text-field-character-counter" >0 / {maxlength }</div >
99
+ <div class ="mdc-text-field-character-counter" >{ value . length } / {maxlength }</div >
98
100
</div >
99
101
{/if }
100
102
</div >
You can’t perform that action at this time.
0 commit comments