1
1
<template >
2
- <!-- ===================================================================================== -->
3
- <!-- Mew Input -->
4
- <!-- ===================================================================================== -->
2
+ <!--
3
+ =====================================================================================
4
+ Mew Input
5
+ =====================================================================================
6
+ -->
5
7
<v-text-field
6
- v-model =" inputValue"
7
8
class =" mew-input rounded-lg"
8
- :class =" hideValue ? 'hide-value' : ''"
9
9
:disabled =" disabled"
10
10
:label =" label"
11
11
:placeholder =" placeholder"
14
14
:solo =" hasNoBorder"
15
15
color =" primary"
16
16
:autofocus =" autofocus"
17
+ v-model =" inputValue"
17
18
:hint =" resolvedAddr ? resolvedAddr : hint"
18
19
:persistent-hint =" persistentHint || resolvedAddr.length > 0"
19
20
:suffix =" rightLabel"
22
23
:type =" inputType"
23
24
:append-icon =" showPasswordIcon"
24
25
:readonly =" isReadOnly"
26
+ @click:append =" onPasswordIconClick"
27
+ @keydown.native =" preventCharE($event)"
25
28
validate-on-blur
26
29
height =" 62"
27
- @click:append =" onPasswordIconClick"
28
30
>
29
- <!-- ===================================================================================== -->
30
- <!-- Mew Input: Error Messages -->
31
- <!-- ===================================================================================== -->
32
- <template #message =" item " >
31
+ <!--
32
+ =====================================================================================
33
+ Mew Input: Error Messages
34
+ =====================================================================================
35
+ -->
36
+ <template v-slot :message =" item " >
33
37
<span
34
38
class =" mew-label"
35
39
>{{ item.message }}
40
44
@click =" emitBuyMore"
41
45
>{{ buyMoreStr }}</a ></span >
42
46
</template >
43
- <template #prepend-inner >
44
- <!-- ===================================================================================== -->
45
- <!-- Mew Input: Blockie (displays at the beginning of the input) -->
46
- <!-- ===================================================================================== -->
47
+ <template v-slot :prepend-inner >
48
+ <!--
49
+ =====================================================================================
50
+ Mew Input: Blockie (displays at the beginning of the input)
51
+ =====================================================================================
52
+ -->
47
53
<div
48
54
v-if =" showBlockie && !value"
49
55
class =" blockie-placeholder mr-1 selectHover"
55
61
height =" 25px"
56
62
/>
57
63
<div class =" d-flex align-center justify-center" >
58
- <!-- ===================================================================================== -->
59
- <!-- slot: prependInnerIcon -->
60
- <!-- prepends content to the beginning of the input. -->
61
- <!-- ===================================================================================== -->
64
+ <!--
65
+ =====================================================================================
66
+ slot: prependInnerIcon
67
+ prepends content to the beginning of the input.
68
+ =====================================================================================
69
+ -->
62
70
<slot name =" prependInnerIcon" />
63
-
64
- <!-- ===================================================================================== -->
65
- <!-- Mew Input: Token Image (displays at the beginning of the input) -->
66
- <!-- ===================================================================================== -->
71
+ <!--
72
+ =====================================================================================
73
+ Mew Input: Token Image (displays at the beginning of the input)
74
+ =====================================================================================
75
+ -->
67
76
<mew-token-container
68
77
v-if =" image"
69
78
class =" mx-1 mt-1"
73
82
/>
74
83
</div >
75
84
</template >
76
-
77
- <!-- ===================================================================================== -->
78
- <!-- Max Button (displays at the end of the input) -->
79
- <!-- ===================================================================================== -->
80
- <template #append >
85
+ <!--
86
+ =====================================================================================
87
+ Max Button (displays at the end of the input)
88
+ =====================================================================================
89
+ -->
90
+ <template v-slot :append >
81
91
<v-btn
82
92
v-if =" maxBtnObj.method"
93
+ @click =" maxBtnObj.method"
83
94
:class =" [
84
95
maxBtnObj.disabled
85
96
? 'disabled--text no-pointer-events'
86
97
: 'greyPrimary--text',
87
- 'rounded-lg mt-n2 mew-caption font-weight-medium'
98
+ 'rounded-lg mt-n2 mew-caption font-weight-medium',
88
99
]"
89
100
min-width =" 40"
90
101
min-height =" 40"
91
102
height =" 40"
92
103
width =" 40"
93
104
depressed
94
105
color =" greyLight"
95
- @click =" maxBtnObj.method"
96
106
>
97
107
{{ maxBtnObj.title }}
98
108
</v-btn >
@@ -110,85 +120,85 @@ export default {
110
120
name: ' MewInput' ,
111
121
components: {
112
122
MewBlockie,
113
- MewTokenContainer
123
+ MewTokenContainer,
114
124
},
115
125
props: {
116
126
/**
117
127
* Error messages to display at the bottom of the input.
118
128
*/
119
129
errorMessages: {
120
130
type: [String , Array ],
121
- default: ' '
131
+ default: ' ' ,
122
132
},
123
133
/**
124
134
* Input becomes read only.
125
135
*/
126
136
isReadOnly: {
127
137
type: Boolean ,
128
- default: false
138
+ default: false ,
129
139
},
130
140
/**
131
141
* Prepends the blockie to the beginning of the input.
132
142
*/
133
143
showBlockie: {
134
144
type: Boolean ,
135
- default: false
145
+ default: false ,
136
146
},
137
147
/**
138
148
* Removes the input border and adds a box shadow.
139
149
*/
140
150
hasNoBorder: {
141
151
type: Boolean ,
142
- default: false
152
+ default: false ,
143
153
},
144
154
/**
145
155
* Disables the input.
146
156
*/
147
157
disabled: {
148
158
type: Boolean ,
149
- default: false
159
+ default: false ,
150
160
},
151
161
/**
152
162
* The input label.
153
163
*/
154
164
label: {
155
165
type: String ,
156
- default: ' '
166
+ default: ' ' ,
157
167
},
158
168
/**
159
169
* The input placeholder.
160
170
*/
161
171
placeholder: {
162
172
type: String ,
163
- default: ' '
173
+ default: ' ' ,
164
174
},
165
175
/**
166
176
* The input value.
167
177
*/
168
178
value: {
169
179
type: String ,
170
- default: ' '
180
+ default: ' ' ,
171
181
},
172
182
/**
173
183
* The input id.
174
184
*/
175
185
id: {
176
186
type: Number ,
177
- default: null
187
+ default: null ,
178
188
},
179
189
/**
180
190
* Displays text on the right inner side of the input.
181
191
*/
182
192
rightLabel: {
183
193
type: String ,
184
- default: ' '
194
+ default: ' ' ,
185
195
},
186
196
/**
187
197
* Hides input clear functionality. Clear symbol will be displayed on the right side.
188
198
*/
189
199
hideClearBtn: {
190
200
type: Boolean ,
191
- default: false
201
+ default: false ,
192
202
},
193
203
/**
194
204
* For validating your input - accepts an array of functions that take an input value as an argument and returns either true / false
@@ -198,49 +208,49 @@ export default {
198
208
type: Array ,
199
209
default : () => {
200
210
return [];
201
- }
211
+ },
202
212
},
203
213
/**
204
214
* The resolved address.
205
215
*/
206
216
resolvedAddr: {
207
217
type: String ,
208
- default: ' '
218
+ default: ' ' ,
209
219
},
210
220
/**
211
221
* Enables persistent hint.
212
222
*/
213
223
persistentHint: {
214
224
type: Boolean ,
215
- default: false
225
+ default: false ,
216
226
},
217
227
/**
218
228
* Hint text (will be displayed at the bottom of the input).
219
229
*/
220
230
hint: {
221
231
type: String ,
222
- default: ' '
232
+ default: ' ' ,
223
233
},
224
234
/**
225
235
* Sets input type.
226
236
*/
227
237
type: {
228
238
type: String ,
229
- default: ' text'
239
+ default: ' text' ,
230
240
},
231
241
/**
232
242
* Prepends an image to the beginning of the input.
233
243
*/
234
244
image: {
235
245
type: String ,
236
- default: ' '
246
+ default: ' ' ,
237
247
},
238
248
/**
239
249
* Adds a "Buy more" string to the end of the first index of the errorMessages prop.
240
250
*/
241
251
buyMoreStr: {
242
252
type: String ,
243
- default: ' '
253
+ default: ' ' ,
244
254
},
245
255
/**
246
256
* Displays a button to the right inner side of the input.
@@ -251,37 +261,42 @@ export default {
251
261
type: Object ,
252
262
default : () => {
253
263
return {};
254
- }
264
+ },
255
265
},
256
266
/**
257
267
* Autofocuses the input.
258
268
*/
259
269
autofocus: {
260
270
type: Boolean ,
261
- default: false
271
+ default: false ,
262
272
},
263
273
/**
264
274
* Hides the toggle show password icon on the right
265
275
* when input type is password.
266
276
*/
267
277
hidePasswordIcon: {
268
278
type: Boolean ,
269
- default: false
279
+ default: false ,
270
280
},
271
- /**
272
- * Hide password and key value
273
- */
274
- hideValue: {
275
- type: Boolean ,
276
- default: false
277
- }
278
281
},
279
282
data () {
280
283
return {
281
284
inputValue: ' ' ,
282
- showPassword: false
285
+ showPassword: false ,
283
286
};
284
287
},
288
+ watch: {
289
+ inputValue (newVal , oldVal ) {
290
+ if (newVal !== oldVal) {
291
+ this .$emit (' input' , newVal, this .id );
292
+ }
293
+ },
294
+ value (newVal , oldVal ) {
295
+ if (newVal !== oldVal) {
296
+ this .inputValue = newVal;
297
+ }
298
+ },
299
+ },
285
300
computed: {
286
301
isPasswordType () {
287
302
return this .type === types[0 ];
@@ -297,19 +312,7 @@ export default {
297
312
return types[1 ];
298
313
}
299
314
return this .type ;
300
- }
301
- },
302
- watch: {
303
- inputValue (newVal , oldVal ) {
304
- if (newVal !== oldVal) {
305
- this .$emit (' input' , newVal, this .id );
306
- }
307
315
},
308
- value (newVal , oldVal ) {
309
- if (newVal !== oldVal) {
310
- this .inputValue = newVal;
311
- }
312
- }
313
316
},
314
317
mounted () {
315
318
this .inputValue = this .value ;
@@ -325,21 +328,18 @@ export default {
325
328
},
326
329
clear (val ) {
327
330
this .inputValue = val ? val : ' ' ;
328
- }
329
- }
331
+ },
332
+ preventCharE (e ) {
333
+ if (this .type === ' number' && e .key === ' e' ) e .preventDefault ();
334
+ },
335
+ },
330
336
};
331
337
</script >
332
-
333
338
<style lang="scss">
334
339
/* *
335
340
* Mew Input styles
336
341
*/
337
342
.mew-input {
338
- & .hide-value {
339
- input {
340
- -webkit-text-security : disc ;
341
- }
342
- }
343
343
.mdi-close {
344
344
font-size : 20px !important ;
345
345
}
0 commit comments