3.0.0 • Published 5 years ago

@koterion/country_list v3.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

React Country List

country_list is a React Component for entering mobile numbers with code of choosing country.

Live demo

All examples on the demo page

Installing

npm install --save @koterion/country_list

Examples

Flags image

.cntr-flag {
  background-image: url('@koterion/country_list/dist/img/flags.png')
}

Basic usage

import CountryList from '@koterion/country_list';
import '@koterion/country_list/dist/styles.css';

const phone = (<CountryList />);

options

optiontypedefaultdesc
countryAllarray[]Array of countries iso
removebooleanfalseIf true remove countries using countryAll
listbooleanfalseIf true create list of country using countryAll
flagInInputbooleanfalseIf true add flags to current selector
flagInSelectbooleanfalseIf true add flags to dropdown
geoobjectUse for checked country by ip
closestFormstringformClosest form or selector
hasPhonebooleanfalseUsing your custom phone input from inputPhoneName
inputCountryNamestringcountryName for input with country name (auto create type=hidden)
inputPhoneNamestringphoneName for input with phone number
searchbooleanfalseIf true create input with name from inputCountryName, live search in country list
selectbooleanfalseIf true create list like select
requiredbooleanfalseIf true add required for input
countriesjsonCountries in json format

countryAll

Use with delete or list

Example:

<CountryList delete countryAll={['ua', 'us']} />
<CountryList list countryAll={['ua', 'us']} />

geo

For define country by ip we use service Sypexgeo

You can rewrite method, it option geo by default it's object with this parameters:

{
  url: 'https://api.sypexgeo.net/',
  getIso: response => response.country.iso
}

url - api for service, getIso - return country iso

Also you can use current with current country in ISO format. Example:

<CountryList current='ua' />

countries

Format for custom countries

{
  "name": "Afghanistan",
  "iso": "af",
  "code": "93"
},
{
  "name": "Albania",
  "iso": "al",
  "code": "355"
},