Giter Site home page Giter Site logo

ahmedalsharkawy / vue-phone-number-input Goto Github PK

View Code? Open in Web Editor NEW

This project forked from louismazel/vue-phone-number-input

0.0 1.0 0.0 4.79 MB

A phone number input made with Vue JS (format & valid phone number)

Home Page: https://louismazel.github.io/vue-phone-number-input

JavaScript 30.22% HTML 1.92% Vue 60.87% CSS 7.00%

vue-phone-number-input's Introduction

vue-phone-number-input

A beautiful text field to format phone numbers made with VueJS

vue-phone-number-input

Demo

Enjoy

Installation

Using yarn

yarn add vue-phone-number-input

Using npm

npm i --save vue-phone-number-input

Usage

ES6 Modules / CommonJS

import VuePhoneNumberInput from 'vue-phone-number-input';
import 'vue-phone-number-input/dist/vue-phone-number-input.css';

Vue.component('vue-phone-number-input', VuePhoneNumberInput);
<VuePhoneNumberInput v-model="yourValue" />

UMD

<VuePhoneNumberInput v-model="yourValue" />

<script src="https://unpkg.com/vue" charset="utf-8"></script>
<script src="./dist/vue-phone-number-input.umd.min.js" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="./dist/vue-phone-number-input.css">

<script type="text/javascript">
  Vue.component('vue-phone-number-input', window.VuePhoneNumberInput.default);
</script>

Features List

  • You can set preferred-countries, ignored-countries or have only-countries
  • Validator State : input becomes green (you can modify this color with valid-color option) when the phone number is valid (can be disabled by no-validator-state attr)
  • Use browser locale to set the country calling code (can be disabled & you can use default-country-code option)
  • Phone number formatting while typing
  • You can search your country in list (open countries list & type your country name)
  • Keyboard accessibility (Arrow down, Arrow up : Countries list navigation - Escape : Close countries list)
  • Phone number example for each country in placeholder/label
  • Auto focus phone number input after selecting country
  • You can disable the flags - no-flags props
  • Set your translations

All options of VueInputUi are availables

  • Differents size of input (sm or lg) size="sm|lg"
  • Disabled option (disabled prop)
  • Dark UI option (dark prop)
  • Active a clear button by the prop clearable (cf: VueInputUi options)
  • Active a loader progress bar by the prop loader (cf: VueInputUi options)
  • And others `

Props API

Props Type Required Default
v-model String/Int true -
id String false VuePhoneNumberInput
color String HEX no dogderblue
valid-color String HEX no yellowgreen
size String `sm lg` no
default-country-code (1) String no null
preferred-countries (2) Array<string> no null
ignored-countries Array<string> no null
only-countries Array<string> no null
no-validator-state Boolean no false
no-use-browser-locale Boolean no false
no-flags Boolean no false
disabled Boolean no false
dark Boolean no false
required Boolean no false
error Boolean no false
clearable Boolean no false
loader (3) Boolean no false
translations (4) Object no null

(1) Ex : default-country-code="FR"

(2) Ex : preferred-countries="['FR', 'BE', 'DE']" This countries will be at the top of the list

(3) Loader progress bar has the input color (color props)

(4) translations comes to replace default texts - Ex :

translations="{
  countrySelectorLabel: 'Code pays',
  countrySelectorError: 'Choisir un pays',
  phoneNumberLabel: 'Numéro de téléphone',
  example: 'Exemple :'
}"

Events API

Event Return
phone-number-focused - (emit when phone number input is focused)
phone-number-blur - (emit when phone number input is blur)
input AsYouType value (emit when new value is enter on phone number input && when a country is choosed)
update All values (cf values in table on demo) (emit when new value is enter on phone number input && when a country is choosed)

Keyboard accessibility

Props Action
ArrowDown Navigation down in countries list
ArrowUp Navigation up in countries list
Escape Close countries list
All letters characters Searching country name in countries list (should be open)

Contribution

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

Lints and fixes files

npm run lint

License

This project is licensed under MIT License

vue-phone-number-input's People

Contributors

louismazel avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.