# vue-country-region-select

> A Country select component and Region select component for Vue.js. Work together and standalone.

Latest version **2.0.16** (published 2021-05-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-country-region-select
pnpm add vue-country-region-select
yarn add vue-country-region-select
bun add vue-country-region-select
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.16 |
| Published | 2021-05-17 |
| First published | 2018-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 189.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 86 |
| Author | Justin Gehr |
| Maintainers | gehrj |
| Keywords | vue-country-region-select, vue-country-state-select, vue country select, vue region select, vue, select, country, region, vue component, component, country select, region select, lightweight, state select, state, vue state select, country dropdown, dropdown, region dropdown, state dropdown, vue-country-region-dropdown, vue-country-state-dropdown, vue dropdown component, country and state select |

## Links

- npm: https://www.npmjs.com/package/vue-country-region-select
- Repository: https://github.com/gehrj/vue-country-region-select
- Homepage: https://github.com/gehrj/vue-country-region-select#readme
- Issues: https://github.com/gehrj/vue-country-region-select/issues
- npm.io page: https://npm.io/package/vue-country-region-select

## Dependencies (1)

- [vue](https://npm.io/package/vue.md) ^2.5.17

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 2.0.16 (latest) — 2021-05-17
- 2.0.15 — 2021-05-13
- 2.0.14 — 2020-06-08
- 2.0.13 — 2020-02-18
- 2.0.12 — 2020-02-05
- 2.0.11 — 2019-09-30
- 2.0.10 — 2019-06-03
- 2.0.9 — 2019-06-03
- 2.0.8 — 2019-06-03
- 2.0.7 — 2019-06-03
- 2.0.6 — 2019-05-03
- 2.0.5 — 2019-05-03
- 2.0.4 — 2019-04-17
- 2.0.3 — 2019-03-19
- 2.0.2 — 2019-03-19
- … 17 more at https://npm.io/package/vue-country-region-select/versions

## README

# Vue-Country-Region-Select ![CI status](https://img.shields.io/badge/build-passing-brightgreen.svg)

Vue-Country-Region-Select 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.

## Installation
`npm install vue-country-region-select --save`

## Dependencies 
Being that these are Vue components you will need to use them inside of Vue.

The Data for the countries and regions are originally taken from: https://www.npmjs.com/package/country-region-data
However the data set is now located in this project and is available to be edited to suit more countries and regions as you need.

## 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.
```javascript
// too be added before mounting app
import Vue from 'vue'
import vueCountryRegionSelect from 'vue-country-region-select'
Vue.use(vueCountryRegionSelect)

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

// then inside your vue components
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 />```

Parameter | Required? | Default | Type | Description
--------- | --------- | ------- | -------- | ----------
v-model | yes | ''| string | The data binding for your component
country | yes | '' | string | Make this tied to the same piece of data as v-model
topCountry | no | '' | string | By 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'.
countryName | no | false | boolean | By 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.
whiteList | no | [] | array | Fill this array with capitalized short codes of the countries you want to appear in the dropdown list. ex: ['US', 'CA', 'MX']
blackList | no | [] | array | Fill this array with capitalized short codes of the countries you want to remove from dropdown list. ex: ['US'] 
className | no | '' | string | Class name ex: `form-control`
placeholder | no | 'Select Country' | string | The placeholder text for country select
autocomplete | no | false | boolean | Set to true to enable browser to automatically fill out the country.
shortCodeDropdown | no | false | boolean | Use this to have dropdown text display as short codes
usei18n | no | true | boolean | Set to false if using i18n and want to disable for this component
disablePlaceholder | no | false | boolean | Set to true to make placeholder non-selectable
removePlaceholder | no | false | boolean | Set to true to remove placeholder all together, this will autoselect first in list automatically

```<region-select /> ```

Parameter | Required? | Default | Type | Description
--------- | --------- | ------- | -------- | ----------
v-model | yes | ''| string | The data binding for your component
region | yes | '' | string | Make this tied to the same piece of data as v-model
country | no | '' | string | This 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.
defaultRegion | no | 'US' | string | This 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.
countryName | no | false | boolean | Set 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.
regionName | no | false | boolean | Set this to true if you want the v-model to output full region names instead of the default abbreviations.
whiteList | no | [] | array | Fill this array with capitalized short codes of the regions you want to appear in the dropdown list. ex: ['AL', 'AK', 'WA']
blackList | no | [] | array | Fill this array with capitalized short codes of the regions you want to remove from dropdown list. ex: ['AZ'] 
className | no | '' | string | Class name ex: `form-control`
placeholder | no | 'Select Region' | string | The placeholder text for region select
autocomplete | no | false | boolean | Set to true to enable browser to automatically fill out the region.
shortCodeDropdown | no | false | boolean | Use this to have dropdown text display as short codes
usei18n | no | true | boolean | Set to false if using i18n and want to disable for this component
disablePlaceholder | no | false | boolean | Set to true to make placeholder non-selectable, this will cause regions to set to first available when switching countries
removePlaceholder | no | false | boolean | Set to true to remove placeholder all together, this will autoselect first in list automatically


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

## License
[MIT](https://choosealicense.com/licenses/mit/)

---
_Source: https://npm.io/package/vue-country-region-select · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
