Skip to content

Commit 9a85b3d

Browse files
Add some examples with an initialization with the empty value
Signed-off-by: Alexandre Bonneau <alexandre.bonneau@linuxfr.eu>
1 parent e9568ef commit 9a85b3d

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

examples-src/App.vue

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,22 @@
241241
<div class="rawValue">{{ anValue }}</div>
242242
</div>
243243
</div>
244+
245+
<div :class="boxClasses" :style="boxStyle">
246+
<div :class="labelClasses">Initialization with an empty value</div>
247+
248+
<div class="inputAndRawValue">
249+
<vue-autonumeric
250+
id="inputToEmpty"
251+
options="euro"
252+
v-model="emptyValue"
253+
:placeholder="'Enter your value here'"
254+
/>
255+
<div class="rawValue">{{ emptyValue }}</div>
256+
<button class="controls" @click="clearValue">Clear the value with `clear()`</button>
257+
<button class="controls" @click="setToEmptyString">Set to the empty string</button>
258+
</div>
259+
</div>
244260
</div>
245261
</div>
246262
</div>
@@ -263,6 +279,7 @@
263279
autoNumericModel2: 12468.642,
264280
autoNumericModel3: 221226.44,
265281
anModel : 42.01,
282+
emptyValue : '',
266283
optionsToggle : true,
267284
options2Toggle : true,
268285
options3 : 'euro',
@@ -356,6 +373,14 @@
356373
this.obj.val = 123456.78;
357374
this.obj.options = AutoNumeric.getDefaultConfig();
358375
},
376+
377+
clearValue() {
378+
AutoNumeric.getAutoNumericElement('#inputToEmpty').clear(true);
379+
},
380+
381+
setToEmptyString() {
382+
AutoNumeric.getAutoNumericElement('#inputToEmpty').set('');
383+
},
359384
},
360385
};
361386
</script>
@@ -401,6 +426,7 @@
401426
line-height : 1;
402427
}
403428
429+
$boxShadow : 0 1px 5px rgba(0, 0, 0, .2), 0 2px 2px rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .12);
404430
input {
405431
background-color : white;
406432
border : 1px solid #B1B1B1;
@@ -409,7 +435,6 @@
409435
border-radius : 4px;
410436
transition : all $transitionShortDuration ease;
411437
412-
$boxShadow : 0 1px 5px rgba(0, 0, 0, .2), 0 2px 2px rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .12);
413438
&:hover {
414439
box-shadow : $boxShadow;
415440
}
@@ -454,4 +479,26 @@
454479
border-radius : 3px;
455480
font-size : 0.9rem;
456481
}
482+
483+
.controls {
484+
background-color : $linkColor;
485+
border : 1px solid $linkColorHover;
486+
color : white;
487+
padding : 0.5rem;
488+
border-radius : 4px;
489+
transition : all $transitionShortDuration ease;
490+
margin-left : 2rem;
491+
cursor : pointer;
492+
493+
&:hover {
494+
box-shadow : $boxShadow;
495+
background-color : dodgerblue;
496+
border-color : darkblue;
497+
}
498+
499+
&:focus {
500+
border-color : #6B819F;
501+
box-shadow : $boxShadow;
502+
}
503+
}
457504
</style>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"components"
4040
],
4141
"dependencies": {
42-
"autonumeric": "^4.2.9"
42+
"autonumeric": "^4.2.12"
4343
},
4444
"devDependencies": {
4545
"autoprefixer": "^6.7.7",

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,9 @@ atob@^2.0.0:
331331
version "2.0.3"
332332
resolved "https://registry.yarnpkg.com/atob/-/atob-2.0.3.tgz#19c7a760473774468f20b2d2d03372ad7d4cbf5d"
333333

334-
autonumeric@^4.2.9:
335-
version "4.2.9"
336-
resolved "https://registry.yarnpkg.com/autonumeric/-/autonumeric-4.2.9.tgz#5aadad61fe950c199e99b6663b687d4f1c0f8bb1"
334+
autonumeric@^4.2.12:
335+
version "4.2.12"
336+
resolved "https://registry.yarnpkg.com/autonumeric/-/autonumeric-4.2.12.tgz#0d5cefc9ec36f0e625231462c64bed245b149f79"
337337

338338
autoprefixer@^6.3.1, autoprefixer@^6.7.7:
339339
version "6.7.7"

0 commit comments

Comments
 (0)