Commit af38d151 authored by niksmr's avatar niksmr Committed by GitHub

Merge pull request #15 from dmitrichev/feature/mask-as-object

Added the ability to specify an object as a mask
parents 61211263 9fe4fa3c
...@@ -39,9 +39,8 @@ export default { ...@@ -39,9 +39,8 @@ export default {
type: String, type: String,
}, },
mask: { mask: {
type: String,
required: true, required: true,
validator: value => !!(value && value.length >= 1), validator: value => !! ((value && value.length >= 1) || value instanceof Object)
}, },
placeholderChar: { placeholderChar: {
type: String, type: String,
...@@ -70,6 +69,9 @@ export default { ...@@ -70,6 +69,9 @@ export default {
methods: { methods: {
initMask() { initMask() {
try { try {
if (this.mask instanceof Object) {
this.maskСore = new InputMask(this.mask)
} else {
this.maskCore = new InputMask({ this.maskCore = new InputMask({
pattern: this.mask, pattern: this.mask,
value: '', value: '',
...@@ -96,6 +98,7 @@ export default { ...@@ -96,6 +98,7 @@ export default {
}, },
/* eslint-enable */ /* eslint-enable */
}); });
}
[...this.$refs.input.value].reduce((memo, item) => this.maskCore.input(item), null); [...this.$refs.input.value].reduce((memo, item) => this.maskCore.input(item), null);
this.maskCore.setSelection({ this.maskCore.setSelection({
start: 0, start: 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment