0.1.2 • Published 5 years ago

vue-country-region-select-lite v0.1.2

Weekly downloads
15
License
-
Repository
-
Last release
5 years ago

Vue-Country-Region-Select-Lite CI status

Vue-Country-Region-Select-Lite provides a pair of Vue components that will allow you to easily put a country and region dropdown in your project that will work together or standalone. Supports vue-i18n. This is the adapted version that includes a select amount of countries. The full version can be found here https://github.com/gehrj/vue-country-region-select

Installation

npm install vue-country-region-select-lite --save

Currently supported Countries

  • United States
  • Canada
  • China
  • Germany
  • Ireland
  • Japan
  • Mexico
  • United States minor outlying islands

(I am open to adding a few more based on use case, the full version linked above includes a very thorough list of countries, this is meant to be a very slim version )

Usage

Here is a sample use case of how you would use vue-country-region-select in your vue project. You can alternatively store the data in a store somewhere. Country and Region values will be returned in their short code values by default.

Ex. country: 'US' and region: 'IL'

There is a prop that will allow for country to be returned in full instead of in short code version.

The library registers the components globally so only need to import the library once in order to make the components be available throughout your project.

import Vue from 'vue'
import vueCountryRegionSelect from 'vue-country-region-select'
Vue.use(vueCountryRegionSelect)

export default Vue.extend({
  data: () => ({
    country: '',
    region: ''
  })
})

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

Options

Here are the available attributes that can be used with the provided components.

<country-select />

ParameterRequired?DefaultTypeDescription
v-modelyes''stringThe data binding for your component
countryyes''stringMake this tied to the same piece of data as v-model
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'
classNameno''stringClass name ex: form-control
placeholderno'Select Country'stringThe placeholder text for country select
shortCodeDropdownnofalsebooleanUse this to have dropdown text display as short codes
usei18nnotruebooleanSet to false if using i18n and want to disable for this component

<region-select />

ParameterRequired?DefaultTypeDescription
v-modelyes''stringThe data binding for your component
regionyes''stringMake this tied to the same piece of data as v-model
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'US'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.
classNameno''stringClass name ex: form-control
placeholderno'Select Region'stringThe placeholder text for region select
shortCodeDropdownnofalsebooleanUse 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.

License

MIT

vue-country-region-select-lite

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago