Skip to content

Tiny and dependency free mask input for VueJS

Notifications You must be signed in to change notification settings

caneco/vee-mask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vee Mask

npm npm Maintenance

vee-mask is a tiny and dependency free mask input for Vue.js that allows you to easily mask your input fields based on tokens.

NOTICE

I've created this package from a fork of vue-the-mask due to lack of maintenance; the need of some extra features; and code fixes well discussed in the original repository. But still, props to the original algorithms from @neves 🙌

Install

yarn add vee-mask
or
npm i -S vee-mask

Usage

Globally

import VeeMask from 'vee-mask'
Vue.use(VeeMask)

…or, Locally (as directive)

import { mask } from 'vee-mask'
export default {
  directives: { mask },
}

Tokens

'*': { pattern: /./ },
'#': { pattern: /\d/ },
'X': { pattern: /[0-9a-zA-Z]/ },
'S': { pattern: /[a-zA-Z]/ },
'A': { pattern: /[a-zA-Z]/, transform: v => v.toLocaleUpperCase() },
'a': { pattern: /[a-zA-Z]/, transform: v => v.toLocaleLowerCase() },
'N': { pattern: /[a-zA-Z0-9]/, transform: v => v.toLocaleUpperCase() },
'n': { pattern: /[a-zA-Z0-9]/, transform: v => v.toLocaleLowerCase() },
'!': { escape: true }

Properties

Property Required Type Default Description
value false String Input value or v-model
mask true String, Array Mask pattern
masked false Boolean false emit value with mask chars, default is raw
tokens false Object tokens Custom tokens for mask

License

This project is licensed under MIT License

About

Tiny and dependency free mask input for VueJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published