0.4.0 • Published 2 years ago

@saiful676/vuetify-country-region-input v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

vuetify-country-region-input

This package provides a pair of Vuetify components for countries/region select inputs. Components may be used together or standalone. Vue-i18n is also supported.


Installation

npm i --save @timbouc/vuetify-country-region-input
# or yarn add @timbouc/vuetify-country-region-input

Usage

import Vue from 'vue'
import VCountryRegionSelect from '@timbouc/vuetify-country-region-input'
Vue.use(VCountryRegionSelect)

new Vue({}).$mount('#app')

// then inside your vue components
export default Vue.extend({
  data: () => ({
    country: 'AU',
    region: 'South Australia'
  })
})

<template>
    <v-country-select v-model="country" />
    <v-region-select v-model="region" :country="country" />
</template>

Use standalone

<script>
import { VCountrySelect } from '@timbouc/vuetify-country-region-input'

export default {
  name: 'App',
  components: { VCountrySelect },
  data: () => ({
    country: 'AU',
  })
};
</script>

<template>
    <v-country-select v-model="country" />
</template>

Options

In addition to Vuetify VSelect props, here are the available attributes that can be used with the provided components.

VCountrySelect

ParameterRequired?DefaultTypeDescription
v-modelyes''stringThe data binding for your component
topCountryno''stringBy providing this value you will tell component what country to put at the top of the dropdown list for easy selection. Make sure to use country short code. So for United states you would provide 'US'. However, if you set countryName to true make sure to also write out full country name when setting a topCountry. In this scenerio United States would be 'United States'.
countryNamenofalsebooleanBy setting this value to true, country names will be output in full instead of using the abbreviated short codes. Make sure to set this true for both country and region if you are using.
whiteListno[]arrayFill this array with capitalized short codes of the countries you want to appear in the dropdown list. ex: 'US', 'CA', 'MX'
blackListno[]arrayFill this array with capitalized short codes of the countries you want to remove from dropdown list. ex: 'US'
displayShortCodenofalsebooleanUse this to have dropdown text display as short codes
usei18nnotruebooleanSet to false if using i18n and want to disable for this component

VRegionSelect

ParameterRequired?DefaultTypeDescription
v-modelyes''stringThe data binding for your component
countryno''stringThis tells the component what country to grab the list of displayed regions from. To have it work in tandem with country component provide it the variable that is tied to the v-model of the country-select component.
defaultRegionno'AU'stringThis allows you to set a default region when choosing not to use the country attribute. It will be set to regions of the United States if not provided.
countryNamenofalsebooleanSet this to true if you are setting it to true while using Country Select. This is just to help keep the data values in sync.
regionNamenofalsebooleanSet this to true if you want the v-model to output full region names instead of the default abbreviations.
whiteListno[]arrayFill this array with capitalized short codes of the regions you want to appear in the dropdown list. ex: 'AL', 'AK', 'WA'
blackListno[]arrayFill this array with capitalized short codes of the regions you want to remove from dropdown list. ex: 'AZ'
displayShortCodenofalsebooleanUse this to have dropdown text display as short codes
usei18nnotruebooleanSet to false if using i18n and want to disable for this component

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Credits

License

MIT