0.2.0 • Published 3 years ago

@kingscode/vuetify-phone-input v0.2.0

Weekly downloads
19
License
MIT
Repository
github
Last release
3 years ago

Vuetify Phone Input

Example

Vuetify Phone Input

Please refer to the TextField if you want to see which inherited props will be available.

Props

NameTypeDefault
valuestring''
countries[]countries
typestringtel
placeholderstring#
countryCodestring-number''
prependCountryCodebooleantrue

Events:

NameReturn valueWhat
@countrystringThe new selected country code
@phonestringEquivalent to @change event, but with additional features. Gets called on blur

Installation

install the dependency

npm i @kingscode/vuetify-phone-input

Then just import the component in the file you need it

import VuetifyPhoneInput from '@kingscode/vuetify-phone-input';

And add it to the components in your vue file

  components: {
    VuetifyPhoneInput,
    ...

Usage

<template>
    <div>
        <VuetifyPhoneInput :countries="countries"
                           @country="onCountry"
                           @phone="onPhone"/>
    </div>
</template>

<script lang="js">
import VuetifyPhoneInput from '@kingscode/vuetify-phone-input';

export default {
    name: 'Home',
    components: {
        VuetifyPhoneInput
    },
    computed: {
        countries: () => [ // we can now provide our own list of countries + codes. Defaults to all possible countries.
            {
                code: 31,
                name: 'NL',
            },
            {
                code: 32,
                name: 'BE',
            },
        ],
    },
    methods: {
        onCountry(country) { // callback when the consumer changed the country code.
            console.log(country); // 32
        },
        onPhone(phone) { // callback when the consumer changed the phone number
            console.log(phone); // +31612345678
        },
    },
};
</script>

If the consumer enters the following: +32612345678 when the current selected country does not match, the country will be adjusted accordingly.

Remember that this Phone Input is derived from the VTextField from Vuetify, meaning that you can still use the error-messages, or placeholder attributes for example.

0.2.0

3 years ago

0.1.2

4 years ago

0.1.1

5 years ago

0.1.0

5 years ago