Skip to content

Commit 470a922

Browse files
committed
v0.11.0-alpha
1 parent 49f756c commit 470a922

File tree

9 files changed

+43
-8
lines changed

9 files changed

+43
-8
lines changed

dist/vue-the-mask.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/client.30a1c666.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/client.b9b51cb7.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ <h1>Currency</h1>
128128
<img src="https://img.shields.io/github/stars/plentz/jquery-maskmoney.svg?style=social&label=Star">
129129
<a href="https://github.com/plentz/jquery-maskmoney">https://github.com/plentz/jquery-maskmoney</a>
130130
</li>
131+
<li>
132+
<img src="https://img.shields.io/github/stars/autoNumeric/autoNumeric.svg?style=social&label=Star">
133+
<a href="https://github.com/autoNumeric/autoNumeric">https://github.com/autoNumeric/autoNumeric</a>
134+
</li>
131135
<li>
132136
<img src="https://img.shields.io/github/stars/flaviosilveira/Jquery-Price-Format.svg?style=social&label=Star">
133137
<a href="https://github.com/flaviosilveira/Jquery-Price-Format">https://github.com/flaviosilveira/Jquery-Price-Format</a>
@@ -143,5 +147,5 @@ <h1>Currency</h1>
143147
</p>
144148
</section>
145149

146-
<script type="text/javascript" src="client.b9b51cb7.js"></script></body>
150+
<script type="text/javascript" src="client.30a1c666.js"></script></body>
147151
</html>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-the-mask",
3-
"version": "0.10.1",
3+
"version": "0.11.0-alpha",
44
"description": "Tiny (2KB) and dependency free mask input for Vue.js",
55
"main": "dist/vue-the-mask.js",
66
"scripts": {

src/directive.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import masker from './masker'
2+
import tokens from './tokens'
23

34
// https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events#The_old-fashioned_way
45
function event (name) {
@@ -9,10 +10,25 @@ function event (name) {
910

1011
export default function (el, binding) {
1112
var config = binding.value
13+
if (typeof config === 'string') {
14+
config = {
15+
mask: config,
16+
tokens: tokens
17+
}
18+
}
19+
20+
if (el.tagName.toLocaleUpperCase() !== 'INPUT') {
21+
var els = el.getElementsByTagName('input')
22+
if (els.length !== 1) {
23+
throw new Error("v-mask directive requires 1 input, found " + els.length)
24+
} else {
25+
el = els[0]
26+
}
27+
}
1228

1329
el.oninput = function (evt) {
1430
if (!evt.isTrusted) return // avoid infinite loop
15-
/*
31+
/* other properties to try to diferentiate InputEvent of Event (custom)
1632
InputEvent (native)
1733
cancelable: false
1834
isTrusted: true
@@ -30,7 +46,7 @@ export default function (el, binding) {
3046
// save the character just inserted
3147
var digit = el.value[position-1]
3248
el.value = masker(el.value, config.mask, true, config.tokens)
33-
// if the digit changed, increment position until find the digit again
49+
// if the digit was changed, increment position until find the digit again
3450
while (position < el.value.length && el.value.charAt(position-1) !== digit) {
3551
position++
3652
}

src/docs/docs.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,22 @@
160160
<the-mask :mask="mask" :value="value" :type="type" :masked="masked" :placeholder="placeholder"></the-mask>
161161
</div>
162162
<pre>{{code}}</pre>
163+
164+
<h2>Directive Usage</h2>
165+
166+
<div class="field" v-mask="'##/##/####'">
167+
<input type="tel" placeholder="dd/mm/yyyy" />
168+
</div>
169+
<pre>{{directive}}</pre>
170+
163171
</div>
164172
</div>
165173
</template>
166174

167175
<script>
168176
import Field from './field'
169177
import TheMask from '../component'
178+
import mask from '../directive'
170179
171180
export default {
172181
components: {Field, TheMask},
@@ -185,13 +194,15 @@ export default {
185194
placeholder: 'test your mask here',
186195
mask: '#XSAa',
187196
value: '12TgB',
197+
directive: `<input type="tel" v-mask="'##/##/####'" />`
188198
}
189199
},
190200
computed: {
191201
code () {
192202
return `<the-mask mask="${this.mask}" value="${this.value}" type="${this.type}" masked="${this.masked}" placeholder="${this.placeholder}"></the-mask>`
193203
}
194-
}
204+
},
205+
directives: {mask}
195206
}
196207
</script>
197208

src/docs/layout.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ <h1>Currency</h1>
128128
<img src="https://img.shields.io/github/stars/plentz/jquery-maskmoney.svg?style=social&label=Star">
129129
<a href="https://github.com/plentz/jquery-maskmoney">https://github.com/plentz/jquery-maskmoney</a>
130130
</li>
131+
<li>
132+
<img src="https://img.shields.io/github/stars/autoNumeric/autoNumeric.svg?style=social&label=Star">
133+
<a href="https://github.com/autoNumeric/autoNumeric">https://github.com/autoNumeric/autoNumeric</a>
134+
</li>
131135
<li>
132136
<img src="https://img.shields.io/github/stars/flaviosilveira/Jquery-Price-Format.svg?style=social&label=Star">
133137
<a href="https://github.com/flaviosilveira/Jquery-Price-Format">https://github.com/flaviosilveira/Jquery-Price-Format</a>

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const tokens = require('./tokens')
2+
const Mask = require('./directive')
23
const TheMask = require('./component.vue')
3-
const Mask = require('./directive.vue')
44

55
TheMask.tokens = tokens
66
TheMask.mask = mask

0 commit comments

Comments
 (0)