npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-mask

v3.1.1

Published

Angular mask without dependencies (NO JQUERY). Pure javascript and only ~6kb! It gives you power to create your mask with optional fields in accordance with your business.

Downloads

13,760

Readme

ngMask

Best Angular JS mask alternative!

Angular mask without dependencies (NO JQUERY). Pure javascript and only ~6kb! It gives you power to create your mask with optional fields in accordance with your business.

=======

GitHub version Bower version Build Status Code Climate Test Coverage NPM Dependencies

Chrome Firefox IE8+ Opera Safari

TL;DR

Check live examples here.

Install

With Bower

  • Install the dependency:

    bower install angular-mask --save
  • Add ngMask.min.js to your code:

    <script src='bower_components/ngMask/dist/ngMask.min.js'></script>
  • Include module dependency:

    angular.module('yourApp', ['ngMask']);

Without Bower:

  • Download the ngMask.min.js file from dist folder:

    wget https://raw.githubusercontent.com/candreoliveira/ngMask/master/dist/ngMask.min.js
  • Add ngMask.min.js to your code:

    <script src='ngMask.min.js'></script>
  • Include module dependency:

    angular.module('yourApp', ['ngMask']);

======

How To Use

  1. Add ngMask plugin after your AngularJS.

    <script src="angular.min.js"></script>
    <script src='ngMask.min.js'></script>
  2. Add ngMask module dependency to your app.

    angular.module('yourApp', ['ngMask']);
  3. Use the avaiable patterns to create your mask. Set the mask attribute.

    <input type='text' ng-model='maskModel' mask='39/19/9999' />
  4. Adjust your mask options.

    <input type='text' ng-model='maskModel' ng-value='0/3/9' mask='3/9?' mask-repeat='2' mask-restrict='accept' mask-clean='true' mask-validate='false' mask-limit='false' />

======

Available Patterns

You can make your mask using some patterns available. If you use a pattern not specified below to construct your mask, It'll be considered a divisor. A dividor is a character used to group semantic elements, for example: "/" in dates to separate days, months and years, "-" in SSN to separate area, group and serial numbers or "." in IPv4 to create 4 groups of 8 bits.

Common Patterns

    • =====> /./
    • Any single character
  • w =====> /\w/
    • Any word character (letter, number, underscore)
  • W =====> /\W/
    • Any non-word character
  • d =====> /\d/
    • Any digit
  • D =====> /\D/
    • Any non-digit
  • s =====> /\s/
    • Any whitespace character
  • S =====> /\S/
    • Any non-whitespace character
  • b =====> /\b/
    • Any word boundary

Number Patterns

  • 9 =====> /[0-9]/
    • Valid numbers: 0,1,2,3,4,5,6,7,8,9
  • 8 =====> /[0-8]/
    • Valid numbers: 0,1,2,3,4,5,6,7,8
  • 7 =====> /[0-7]/
    • Valid numbers: 0,1,2,3,4,5,6,7
  • 6 =====> /[0-6]/
    • Valid numbers: 0,1,2,3,4,5,6
  • 5 =====> /[0-5]/
    • Valid numbers: 0,1,2,3,4,5
  • 4 =====> /[0-4]/
    • Valid numbers: 0,1,2,3,4
  • 3 =====> /[0-3]/
    • Valid numbers: 0,1,2,3
  • 2 =====> /[0-2]/
    • Valid numbers: 0,1,2
  • 1 =====> /[0-1]/
    • Valid numbers: 0,1
  • 0 =====> /[0]/
    • Valid numbers: 0

Especial Patterns

  • ? =====> /?/
    • Optional character. It makes the previous pattern optional.
  • A =====> /[A-Z]/
    • Any uppercase alphabet letter without accents
  • a =====> /[a-z]/
    • Any lowercase alphabet letter without accents
  • Z =====> /[A-ZÇÀÁÂÃÈÉÊẼÌÍÎĨÒÓÔÕÙÚÛŨ]/
    • Any uppercase alphabet letter with accents
  • z =====> /[a-zçáàãâéèêẽíìĩîóòôõúùũüû]/
    • Any lowercase alphabet letter with accents
  • @ =====> /[a-zA-Z]/
    • Any alphabet letter without accents
  • # =====> /[a-zA-ZçáàãâéèêẽíìĩîóòôõúùũüûÇÀÁÂÃÈÉÊẼÌÍÎĨÒÓÔÕÙÚÛŨ]/
    • Any alphabet letter with accents
  • % =====> /[0-9a-zA-zçáàãâéèêẽíìĩîóòôõúùũüûÇÀÁÂÃÈÉÊẼÌÍÎĨÒÓÔÕÙÚÛŨ]/
    • Any digit and alphabet letter with accents

======

Options

  • NgModel (required): model object
    • Attribute 'ng-model'
    • The model of input.
  • Mask (required): mask definition
    • Attribute 'mask'
    • The mask for input.
  • NgValue: initial mask value (default: undefined)
    • Attribute 'ng-value'
    • The initial value of input.
  • Restrict: 'select', 'reject' or 'accept' (default: select)
    • Attribute 'mask-restrict' or 'restrict'
    • The way how ngMask will interact with user input.
      • Select restriction: The input will show the char inputted even on error cases. If it has errors, the wrong char will be selected.
      • Reject restriction: The input will show the char inputted on successful cases. If it has errors, the wrong char will be rejected.
      • Accept restriction: The input will always show the char inputted. No matter it's right or wrong.
  • Repeat: number - repeat mask n times (default: undefined)
    • Attribute 'mask-repeat' or 'repeat'
    • Repeats the mask attribute the defined times.
  • Clean: 'true' or 'false' (default: false)
    • Attribute 'mask-clean' or 'clean'
    • Cleans model value. Removes divisors from model value.
  • Validate: 'true' or 'false' (default: true)
    • Attribute 'mask-validate' or 'validate'
    • Applies validation. Uses form controller setValidity method.
  • Limit: 'true' or 'false' (default: true)
    • Attribute 'mask-limit' or 'limit'
    • Limits the max length inputted according with mask.

======

Examples

How to ngMask

======

License

Open Source

The MIT License (MIT)

Copyright (c) 2014 @candreoliveira

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.