1.0.4 • Published 10 months ago

@almuz/vue-tel-input v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@almuz/vue-tel-input

Improved International Telephone Input with Vue.

Useful Links

Table of Contents

Installation

  • yarn:
      yarn add @almuz/vue-tel-input
  • npm:
      npm i --save @almuz/vue-tel-input

Usage

  • Import default CSS to your project:

    import '@almuz/vue-tel-input/dist/vue-tel-input.css'
  • In your component:

    <template>
      ...
      <vue-tel-input v-model="phone"></vue-tel-input>
      ...
      <template>
        <script>
          import VueTelInput from 'vue-tel-input'
    
          export default {
            components: {
              VueTelInput
            },
            data() {
              return {
                phone: ''
              }
            }
          }
        </script>
      </template>
    </template>

Props

PropertyTypeDefault valueDescription
defaultCountryString''Default country
disabledBooleanfalseDisable input field
disabledFormattingBooleanfalseDisable formatting the phone number in the input, the formatted result still be accessible by formattedNumber returned from onInput event
placeholderStringEnter a phone numberPlaceholder for the input
requiredBooleanfalseRequired property for HTML5 required attribute
enabledCountryCodeBooleanfalseEnable country code in the input
enabledFlagsBooleantrueEnable flags in the input
preferredCountriesArray[]Preferred countries list, will be on top of the dropdown. ie ['AU', 'BR']
onlyCountriesArray[]List of countries will be shown on the dropdown. ie ['AU', 'BR']
ignoredCountriesArray[]List of countries will NOT be shown on the dropdown. ie ['AU', 'BR']
autocompleteString'on'Native input 'autocomplete' attribute
nameString'telephone'Native input 'name' attribute
maxLenNumber25Native input 'maxlength' attribute
wrapperClassesString | Array | Object''Custom classes for the wrapper
inputClassesString | Array | Object''Custom classes for the input
inputIdString''Custom 'id' for the input
dropdownOptionsObject{ disabledDialCode: false, tabindex: 0 }Options for dropdown, supporting disabledDialCode and tabindex
inputOptionsObject{ showDialCode: false, tabindex: 0 }Options for input, supporting showDialCode (always show dial code in the input) and tabindex
validCharactersOnlyBooleanfalseOnly allow valid characters in a phone number (will also verify in mounted, so phone number with invalid characters will be shown as an empty string)

Events

EventArgumentsDescriptionNotes
inputString, ObjectFires when the input changes with the argument is the object includes { number, isValid, country }onInput deprecated
validateObjectFires when the correctness of the phone number changes (from true to false or vice-versa) and when the component is mounted { number, isValid, country }onValidate deprecated
blurFires on blur eventonBlur deprecated
spaceFires on keyup.space eventonSpace deprecated
enterFires on keyup.enter eventonEnter deprecated
openFires when the flags dropdown opens
closeFires when the flags dropdown closes
country-changedObjectFires when country changed (even for the first time)Available from v2.4.2

Slots

SlotDescriptionNotes
arrow-iconReplace the arrow next to the flag with a component of your choice

Demo Usage

# install dependencies
$ yarn/npm install

# compile demo for development
$ yarn/npm dev

# open Browser and start serving in demo
$ yarn/npm demo:open

# compile dist demo
$ yarn/npm dist:demo

# compile dist
$ yarn/npm dist

Typescript Support

If you working with typescript will need declaration requirements.

npm install --save-dev @types/vue-tel-input
1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago