# vue-country-code-select

> Country Code Select with Vue

Latest version **1.6.7** (published 2021-01-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-country-code-select
pnpm add vue-country-code-select
yarn add vue-country-code-select
bun add vue-country-code-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 | 1.6.7 |
| Published | 2021-01-19 |
| First published | 2020-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 428.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Trong Binh Han |
| Maintainers | denfedweb |
| Keywords | vue, telephone, phone, country, vue-country-code, phone code, country code |

## Links

- npm: https://www.npmjs.com/package/vue-country-code-select
- Repository: https://github.com/denfedweb/vue-country-code
- Homepage: https://hantrongbinh.github.io/vue-country-code/
- Issues: https://github.com/hantrongbinh/vue-country-code/issues
- npm.io page: https://npm.io/package/vue-country-code-select

## Recent versions

- 1.6.7 (latest) — 2021-01-19
- 1.5.7 — 2020-10-21
- 1.5.6 — 2020-10-21
- 1.5.5 — 2020-10-21
- 1.5.1 — 2020-10-21
- 1.1.8 — 2020-10-21
- 1.1.7 — 2020-10-21
- 1.1.5 — 2020-10-21

## README

# vue-country-code-select

Country Code Select with Vue.

Checkout Demo at [Github pages](https://hantrongbinh.github.io/vue-country-code/).

## Installation

- **yarn**:
  ```bash
    yarn add vue-country-code-select
  ```
- **npm**:
  ```bash
    npm i --save vue-country-code-select
  ```

## Usage

- Install as a global component:

  ```javascript
  import Vue from "vue";
  import VueCountryCode from "vue-country-code-select";

  Vue.use(VueCountryCode);
  ```

- In your component:

  ```js
  <template>
  ...
     <vue-country-code
                    @onSelect="onSelect"
                    <!-- optional -->
                    :preferredCountries="['vn', 'us', 'gb']">
     </vue-country-code>
  ...
  <template>
  <script>
  export default {
    data() {
      return {
      };
    },
    methods: {
       onSelect({name, iso2, dialCode}) {
         console.log(name, iso2, dialCode);
       },
    },
  }
  </script>
  ```

- Register the new field as a global component

### Props

| Property value            | Type      | Default value                 | Description                                                                 |
| ------------------------- | --------- | ----------------------------- | --------------------------------------------------------------------------- |
| `defaultCountry`          | `string`  | `''`                          | Default country, will override the country fetched from IP address of user  |
| `searchPlaceholderText`          | `string`  | `''`                          | Default text - "Search country"                                      |
| `enableSearchField`          | `Boolean`  | `''`                          | Default "false"                                                         |
| `disabledFetchingCountry` | `Boolean` | false                         | Disable fetching current country based on IP address of user                |
| `enabledCountryCode`      | `Boolean` | `false`                       | Enable country code in the input                                            |
| `enabledFlags`            | `Boolean` | `true`                        | Enable flags in the input                                                   |
| `preferredCountries`      | `Array`   | `[]`                          | Preferred countries list, will be on top of the dropdown. ie `['AU', 'BR']` |
| `onlyCountries`           | `Array`   | `[]`                          | List of countries will be shown on the dropdown. ie `['AU', 'BR']`          |
| `ignoredCountries`        | `Array`   | `[]`                          | List of countries will NOT be shown on the dropdown. ie `['AU', 'BR']`      |
| `dropdownOptions`         | `Object`  | `{ disabledDialCode: false }` | Options for dropdown, supporting `disabledDialCode`                         |

### Events

| Property value | Arguments | Description                                                                                      |
| -------------- | --------- | ------------------------------------------------------------------------------------------------ |
| `onSelect`     | `Object`  | Fires when the input changes with the argument is the object includes `{ name, iso2, dialCode }` |

## Highlights & Credits

- Forked from [hantrongbinh/vue-country-code](https://github.com/hantrongbinh/vue-country-code).
- Vue app created by [vue-cli](https://github.com/vuejs/vue-cli).
- Telephone Number parsing, validation by [libphonenumber-js](https://catamphetamine.github.io/libphonenumber-js/).
- Country Codes data from [intl-tel-input](https://github.com/jackocnr/intl-tel-input/blob/master/src/js/data.js).
- Country Flags by [behdad/region-flags](https://github.com/behdad/region-flags).
- User's Location by [get-json](https://www.npmjs.com/package/get-json) and [ipifo.io](https://ipinfo.io/json)

## Demo Usage

```bash

# install dependencies
$ yarn/npm install

# compile demo and start serve for development
$ yarn/npm dev

# build
$ yarn/npm build

```

Made by [Mon](https://github.com/hantrongbinh).

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