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

vue-e164

v2.0.0

Published

Vue.js filter for phone formatting with E.164 support

Downloads

78

Readme

vue-e164

npm version js-standard-style Awesome Conventional Commits

Vue.js filter for phone formatting with E.164 support

Includes:

  • Filter
  • Global method
  • Directive

Setup

NPM

npm install --save vue-e164

CDN

<script src="//unpkg.com/vue-e164/dist/vue-e164.js"></script>
import e164 from 'vue-164'

const options = {
  plus: true,
  brackets: false,
  space: false,
  dash: false,
  areaCode: true
}

Vue.use(e164, options)

Options

plus {Boolean} - add plus symbol before area code

brackets {Boolean} - add brackets

space {Boolean} - split number by space

dash {Boolean} - split number by dash

areaCode {Boolean} - set to false to exclude area code and plus

If you want to use E.164 standart, you need this options:

{
  plus: true,
  brackets: false,
  space: false,
  dash: false,
  areaCode: true
}

Examples

| plus | brackets | space | dash | areaCode | Result | |:-----:|:--------:|:-----:|:-----:|:--------:|:----------------------:| | true | true | true | false | true | +1 (495) 000 99 88 | | false | false | false | false | true | 14950009988 | | true | false | false | false | true | +14950009988 (E.164) | | true | true | false | false | true | +1(495)0009988 | | false | true | true | false | true | 1 (495) 000 99 88 | | false | false | true | false | true | 1 495 000 99 88 | | false | true | false | false | true | 1(495)0009988 | | true | false | true | false | true | +1 495 000 99 88 | | true | true | true | true | true |+1 (495) 000 - 99 - 88| | true | true | false | true | true | +1(495)000-99-88 | | true | false | true | true | true | +1 495 000 - 99 - 88 | | false | true | true | true | true |1 (495) 000 - 99 - 88 | | true | false | true | true | true | +1 495 000 - 99 - 88 | | true | true | true | true | false | (495) 000 - 99 - 88 | | true | true | false | true | false | (495)000-99-88 | | true | false | true | true | false | 495 000 - 99 - 88 | | false | true | true | true | false | (495) 000 - 99 - 88 | | true | false | true | true | false | 495 000 - 99 - 88 |

Usage

vue-e164 adds phone filter, and can be used as any other vue.js filter.

<template>
  <p>{{ string | phone }}</p>
</template>

If you need to use different options for each element, from v0.0.2 you can use directive v-phone:

<template>
  <p v-phone="{ plus: true, brackets: false, space: false, dash: false, areaCode: true }">{{ string }}</p>
</template>

From v1.2.0 you can use global function $filterPhone:

...
methods: {
    applyFilter (phoneInput) {
        return this.$filterPhone(phoneInput, {
              plus: true,
              brackets: false,
              space: false,
              dash: false,
              areaCode: true
        })
    } 
}
...
/* Or as computed property */
...
data () {
    return {
      phone: '70005555555'
    }
},
computed: {
    filteredPhone () {
        return this.$filterPhone(this.phone, {
          plus: true,
          brackets: false,
          space: false,
          dash: false,
          areaCode: true
        })
    }
}
...

Test

npm run build
npm run test

License

MIT

Copyright (c) 2018-2020 Stanislav Mihaylov