jaredpalmer / Country Fns
Licence: mit
🌏 Useful country data for forms and stuff.
Stars: ✭ 35
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to Country Fns
vue-use-form
✅ A Vue.js composition API function to validate forms
Stars: ✭ 97 (+177.14%)
Mutual labels: forms, form
ContactEtc
Laraval package to instantly add a customisable contact form to your site.
Stars: ✭ 21 (-40%)
Mutual labels: forms, form
react-final-form-listeners
A collection of components to listen to 🏁 React Final Form fields
Stars: ✭ 91 (+160%)
Mutual labels: forms, form
Forms
Tracking our progress moving all city paper and pdf forms online.
Stars: ✭ 14 (-60%)
Mutual labels: forms, form
form-data-json
A zero dependency, cross browser library to easily get or set/manipulate form input values as/from a json object.
Stars: ✭ 37 (+5.71%)
Mutual labels: forms, form
react-search
This package will help you create a pretty good and beautiful search. And other related features
Stars: ✭ 17 (-51.43%)
Mutual labels: forms, form
React Hook Form
📋 React Hooks for form state management and validation (Web + React Native)
Stars: ✭ 24,831 (+70845.71%)
Mutual labels: form, forms
Formik Persist
💾 Persist and rehydrate a Formik form to localStorage
Stars: ✭ 345 (+885.71%)
Mutual labels: form, forms
Verticalstepperform
Vertical Stepper Form Library for Android. It follows Google Material Design guidelines.
Stars: ✭ 868 (+2380%)
Mutual labels: form, forms
Formik
Build forms in React, without the tears 😭
Stars: ✭ 29,047 (+82891.43%)
Mutual labels: form, forms
contact-officials
Form definitions powering Resistbot's electronic deliveries to elected officials in the United States.
Stars: ✭ 29 (-17.14%)
Mutual labels: forms, form
react-cool-form
😎 📋 React hooks for forms state and validation, less code more performant.
Stars: ✭ 246 (+602.86%)
Mutual labels: forms, form
SuluFormBundle
Form Bundle for handling Dynamic and Symfony Forms in https://sulu.io
Stars: ✭ 51 (+45.71%)
Mutual labels: forms, form
react-hubspot
A collection of React hooks for interacting with Hubspot APIs
Stars: ✭ 20 (-42.86%)
Mutual labels: forms, form
p01contact
Create contact forms by writing simple tags. Also a plugin for GetSimple and Pico CMS.
Stars: ✭ 15 (-57.14%)
Mutual labels: forms, form
formurai
Lightweight and powerfull library for declarative form validation
Stars: ✭ 49 (+40%)
Mutual labels: forms, form
country-fns
Useful country data for forms and stuff.
Install
npm install country-fns --save
Overview
Each country in country-fns is represented by an object with the following keys:
-
name
: Common name and native name in parentheses if available. -
iso2
: 2 character ISO2 code. Lowercase. -
dial
: International calling code. -
format
: Telephone format.
Quick Example
Imagine you need to make a "Select Country" input.
import React from 'react'
import { getCountries } from 'country-fns'
const SelectCountry = (props) =>
<select {...props}>
{getCountries().map((c) =>
<option value={c.iso2}>{c.name}</option>
)}
</select>
export default SelectCountry
Other use cases
- Intelligent telephone placeholder and input masks
- Telephone number validation
- Localized
tel:
andsms:
<a>
elements - Other annoying stuff I never want to lookup again.
API
getCountry(code: string): Country
getCountries(): Country[]
countries = { [code: string]: Country }
iso2Codes = string[]
getCountry(code: string): Country
Returns a single country by its ISO2 code.
const { getCountry } = require('country-fns')
const hockeyLand = getCountry('ca')
console.log(hockeyLand.name) // => Canada
console.log(hockeyLand.format) // => Canada
getCountries(): Country[]
Returns an array of all countries
const { getCountries } = require('country-fns')
const allCountries = getCountries()
console.log(allCountries)
/*
[
{
name: 'Afghanistan (افغانستان)',
iso2: 'af',
dial: '93',
format: '+..-..-...-....',
},
{
name: 'Albania (Shqipëri)',
iso2: 'al',
dial: '355',
format: '+...(...)...-...',
},
{
name: 'Algeria (الجزائر)',
iso2: 'dz',
dial: '213',
format: '+...-..-...-....',
},
...
]
*/
countries = { [code: string]: Country }
An object containing all countries, keyed by lowercase ISO2 code.
const { countries } = require('country-fns')
console.log(countries)
/*
{
af: {
name: 'Afghanistan (افغانستان)',
iso2: 'af',
dial: '93',
format: '+..-..-...-....',
},
al: {
name: 'Albania (Shqipëri)',
iso2: 'al',
dial: '355',
format: '+...(...)...-...',
},
dz: {
name: 'Algeria (الجزائر)',
iso2: 'dz',
dial: '213',
format: '+...-..-...-....',
},
...
}
*/
iso2Codes = string[]
An array of all ISO2 Codes (lowercase).
const { iso2Codes } = require('country-fns')
console.log(iso2Codes)
/*
['af', 'al', 'dz', 'as', 'ad', 'ao', ... ]
*/
Author
- Jared Palmer (@jaredpalmer)
MIT LICENSE.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].