File tree Expand file tree Collapse file tree 3 files changed +48
-1
lines changed
docs/src/pages/components
src/components/mdInputContainer Expand file tree Collapse file tree 3 files changed +48
-1
lines changed Original file line number Diff line number Diff line change 28
28
<md-table-cell ><code >Boolean</code ></md-table-cell >
29
29
<md-table-cell >Show a button to toggle the password visibility. Default <code >false</code ></md-table-cell >
30
30
</md-table-row >
31
+
32
+ <md-table-row >
33
+ <md-table-cell >md-clearable</md-table-cell >
34
+ <md-table-cell ><code >Boolean</code ></md-table-cell >
35
+ <md-table-cell >Show a button to clear the input. Default <code >false</code ></md-table-cell >
36
+ </md-table-row >
31
37
</md-table-body >
32
38
</md-table >
33
39
176
182
<label >Disabled</label >
177
183
<md-input disabled ></md-input >
178
184
</md-input-container >
185
+
186
+ <md-input-container md-clearable >
187
+ <label >Clearable</label >
188
+ <md-input v-model =" initialValue" ></md-input >
189
+ </md-input-container >
179
190
</form >
180
191
</div >
181
192
211
222
< ; label> ; Disabled< ; /label> ;
212
223
< ; md-input disabled> ;< ; /md-input> ;
213
224
< ; /md-input-container> ;
225
+
226
+ < ; md-input-container md-clearable> ;
227
+ < ; label> ; Clearable< ; /label> ;
228
+ < ; md-input v-model=" ; initialValue" ;> ;< ; /md-input> ;
229
+ < ; /md-input-container> ;
214
230
< ; /form> ;
215
231
</code-block >
216
232
Original file line number Diff line number Diff line change @@ -215,6 +215,24 @@ $input-size: 32px;
215
215
}
216
216
}
217
217
218
+ & .md-clearable {
219
+ & .md-input-focused .md-clear-input {
220
+ color : rgba (#000 , .54 );
221
+ }
222
+
223
+ .md-clear-input {
224
+ margin : 0 ;
225
+ position : absolute ;
226
+ right : 0 ;
227
+ bottom : -2px ;
228
+ color : rgba (#000 , .38 );
229
+
230
+ .md-ink-ripple {
231
+ color : rgba (#000 , .87 );
232
+ }
233
+ }
234
+ }
235
+
218
236
& .md-input-invalid {
219
237
.md-error {
220
238
opacity : 1 ;
Original file line number Diff line number Diff line change 7
7
<md-button class =" md-icon-button md-toggle-password" @click.native =" togglePasswordType" v-if =" mdHasPassword" >
8
8
<md-icon >{{ showPassword ? 'visibility_off' : 'visibility' }}</md-icon >
9
9
</md-button >
10
+
11
+ <md-button class =" md-icon-button md-clear-input" @click.native =" clearInput" v-if =" mdClearable && hasValue" >
12
+ <md-icon >clear</md-icon >
13
+ </md-button >
10
14
</div >
11
15
</template >
12
16
20
24
name: ' md-input-container' ,
21
25
props: {
22
26
mdInline: Boolean ,
23
- mdHasPassword: Boolean
27
+ mdHasPassword: Boolean ,
28
+ mdClearable: Boolean
24
29
},
25
30
mixins: [theme],
26
31
data () {
51
56
return {
52
57
' md-input-inline' : this .mdInline ,
53
58
' md-has-password' : this .mdHasPassword ,
59
+ ' md-clearable' : this .mdClearable ,
54
60
' md-has-select' : this .hasSelect ,
55
61
' md-has-file' : this .hasFile ,
56
62
' md-has-value' : this .hasValue ,
78
84
this .input .focus ();
79
85
}
80
86
},
87
+ clearInput () {
88
+ if (this .isInput ()) {
89
+ this .input .value = ' ' ;
90
+ this .setValue (this .input .value );
91
+ this .$emit (' input' , this .input .value );
92
+ }
93
+ },
81
94
setValue (value ) {
82
95
this .value = value;
83
96
}
You can’t perform that action at this time.
0 commit comments