├── .github └── workflows │ ├── continuous-integration.yml │ ├── dependency-review.yml │ └── deploy-storybook.yml ├── .gitignore ├── .npmignore ├── .prettierrc.json ├── .storybook ├── main.ts ├── preview.scss └── preview.ts ├── .stylelintignore ├── .stylelintrc.cjs ├── .yarn └── releases │ └── yarn-4.5.3.cjs ├── .yarnrc.yml ├── LICENSE ├── README.md ├── eslint.config.js ├── package.json ├── rollup.config.mjs ├── setupTests.ts ├── src ├── PhoneInput │ ├── PhoneInput.stories.tsx │ ├── PhoneInput.test.tsx │ ├── PhoneInput.tsx │ ├── index.ts │ └── styles.scss ├── hooks │ ├── usePhonenumber.test.ts │ └── usePhonenumber.ts ├── index.ts ├── types.ts └── utils │ ├── allCountries.ts │ ├── countries-fn.test.ts │ ├── countries-fn.ts │ ├── detectMobile.ts │ └── index.ts ├── tsconfig.json ├── vite.config.ts ├── vitest.config.ts └── yarn.lock /.github/workflows/continuous-integration.yml: -------------------------------------------------------------------------------- 1 | name: react-rollup-boilerplate 2 | 3 | on: 4 | pull_request: 5 | branches: [ main ] 6 | 7 | concurrency: 8 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 9 | cancel-in-progress: true 10 | 11 | jobs: 12 | continuous-integration: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | - uses: actions/setup-node@v3 17 | with: 18 | node-version: 18.x 19 | 20 | - name: Install dependencies 21 | run: | 22 | yarn install --immutable 23 | 24 | - name: Run Continuous Integration 25 | run: | 26 | yarn ci 27 | -------------------------------------------------------------------------------- /.github/workflows/dependency-review.yml: -------------------------------------------------------------------------------- 1 | # Dependency Review Action 2 | # 3 | # This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging. 4 | # 5 | # Source repository: https://github.com/actions/dependency-review-action 6 | # Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement 7 | name: 'Dependency Review' 8 | on: 9 | pull_request: 10 | branches: [ main ] 11 | 12 | concurrency: 13 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 14 | cancel-in-progress: true 15 | 16 | permissions: 17 | contents: read 18 | 19 | jobs: 20 | dependency-review: 21 | runs-on: ubuntu-latest 22 | steps: 23 | - name: 'Checkout Repository' 24 | uses: actions/checkout@v3 25 | - name: 'Dependency Review' 26 | uses: actions/dependency-review-action@v2 27 | -------------------------------------------------------------------------------- /.github/workflows/deploy-storybook.yml: -------------------------------------------------------------------------------- 1 | name: deploy-storybook 2 | 3 | on: 4 | push: 5 | branches: 6 | - "main" # change to the branch you wish to deploy from 7 | 8 | permissions: 9 | contents: read 10 | pages: write 11 | id-token: write 12 | 13 | jobs: 14 | deploy: 15 | environment: 16 | name: github-pages 17 | url: ${{ steps.build-publish.outputs.page_url }} 18 | runs-on: ubuntu-latest 19 | steps: 20 | - id: build-publish 21 | uses: bitovi/github-actions-storybook-to-github-pages@v1.0.3 22 | with: 23 | path: storybook-static 24 | install_command: yarn install --immutable 25 | build_command: yarn run storybook:build 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # See https://help.github.com/ignore-files/ for more about ignoring files. 3 | 4 | # dependencies 5 | node_modules 6 | .yarn/cache 7 | .yarn/install-state.gz 8 | 9 | # builds 10 | build 11 | coverage 12 | dist 13 | .rpt2_cache 14 | 15 | # misc 16 | .DS_Store 17 | .env 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | coverage 27 | storybook-static 28 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | ._* 3 | .DS_Store 4 | .git 5 | .gitlab-ci* 6 | .github 7 | .hg 8 | .npmrc 9 | .lock-wscript 10 | .svn 11 | .wafpickle-* 12 | .travis.yml 13 | .editorconfig 14 | .eslint* 15 | eslint.config.js 16 | .yarnrc 17 | .babel* 18 | .stylelint* 19 | .storybook 20 | .yarn* 21 | .prettier* 22 | jest* 23 | postcss* 24 | prettier* 25 | rollup* 26 | vit* 27 | setupTests.* 28 | 29 | config.gypi 30 | CVS 31 | npm-debug.log 32 | 33 | yarn-debug.log* 34 | yarn-error.log* 35 | default.config 36 | rollup.config.js 37 | tsconfig.json 38 | 39 | docker* 40 | Docker* 41 | 42 | coverage 43 | config 44 | demo 45 | public 46 | src 47 | scripts 48 | storybook-static 49 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "bracketSpacing": true, 4 | "arrowParens": "always", 5 | "printWidth": 140, 6 | "quoteProps": "preserve", 7 | "trailingComma": "all", 8 | "overrides": [ 9 | { 10 | "files": "*.jsx", 11 | "options": { 12 | "printWidth": 120 13 | } 14 | }, 15 | { 16 | "files": "*.tsx", 17 | "options": { 18 | "printWidth": 120 19 | } 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /.storybook/main.ts: -------------------------------------------------------------------------------- 1 | import { mergeConfig } from 'vite'; 2 | import svgr from 'vite-plugin-svgr'; 3 | import type { StorybookConfig } from '@storybook/react-vite'; 4 | 5 | const config: StorybookConfig = { 6 | 'stories': ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'], 7 | 8 | 'addons': [ 9 | '@storybook/addon-links', 10 | '@storybook/addon-essentials', 11 | '@chromatic-com/storybook', 12 | '@storybook/addon-interactions' 13 | ], 14 | 15 | 'framework': { 16 | 'name': '@storybook/react-vite', 17 | 'options': {}, 18 | }, 19 | 'docs': {}, 20 | 'typescript': { 21 | 'reactDocgen': 'react-docgen-typescript' 22 | }, 23 | 'core': { 24 | 'disableTelemetry': true 25 | }, 26 | }; 27 | 28 | export default config; 29 | -------------------------------------------------------------------------------- /.storybook/preview.scss: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0 !important; 4 | -webkit-font-smoothing: antialiased; 5 | -moz-osx-font-smoothing: grayscale; 6 | height: 100vh; 7 | overflow: auto; 8 | } 9 | 10 | #storybook-root { 11 | height: 100%; 12 | padding: 1rem; 13 | } 14 | -------------------------------------------------------------------------------- /.storybook/preview.ts: -------------------------------------------------------------------------------- 1 | import type { Preview } from "@storybook/react"; 2 | 3 | const preview: Preview = { 4 | parameters: { 5 | controls: { 6 | matchers: { 7 | color: /(background|color)$/i, 8 | date: /Date$/i, 9 | }, 10 | }, 11 | }, 12 | 13 | tags: ['autodocs'] 14 | }; 15 | 16 | export default preview; 17 | -------------------------------------------------------------------------------- /.stylelintignore: -------------------------------------------------------------------------------- 1 | .git 2 | .npmrc 3 | .yarnrc 4 | build 5 | dist 6 | node_modules 7 | coverage 8 | storybook-static 9 | 10 | -------------------------------------------------------------------------------- /.stylelintrc.cjs: -------------------------------------------------------------------------------- 1 | const bemClass = /^([a-z0-9\\-]{2,})(__[a-z0-9\\-]{2,})?(--[a-z0-9\\-]{2,})?$/; 2 | 3 | module.exports = { 4 | plugins: ['stylelint-scss', 'stylelint-prettier'], 5 | customSyntax: 'postcss-scss', 6 | rules: { 7 | 'prettier/prettier': true, 8 | 9 | // General / Sheet 10 | 'no-duplicate-at-import-rules': true, 11 | 'no-duplicate-selectors': true, 12 | 'selector-max-universal': 2, 13 | 'max-nesting-depth': 6, 14 | 'scss/load-no-partial-leading-underscore': true, 15 | 16 | // Declaration block 17 | 'declaration-block-no-shorthand-property-overrides': true, 18 | 19 | // Selector 20 | 'selector-class-pattern': [bemClass, { resolveNestedSelectors: true }], 21 | 'selector-pseudo-class-no-unknown': [ 22 | true, 23 | { 24 | ignorePseudoClasses: 'global', 25 | }, 26 | ], 27 | 'selector-pseudo-element-no-unknown': true, 28 | 'selector-type-no-unknown': true, 29 | 'selector-no-vendor-prefix': true, 30 | 'selector-pseudo-element-colon-notation': 'single', 31 | 'scss/selector-no-redundant-nesting-selector': true, 32 | 33 | // Media 34 | 'media-feature-name-no-unknown': true, 35 | 'media-feature-name-no-vendor-prefix': true, 36 | 37 | // At-rule 38 | 'scss/at-rule-no-unknown': true, 39 | 'at-rule-no-vendor-prefix': true, 40 | 41 | // Properties 42 | 'property-no-unknown': true, 43 | 'shorthand-property-no-redundant-values': true, 44 | 45 | // Values 46 | 'number-max-precision': 4, 47 | 'value-no-vendor-prefix': true, 48 | 'unit-no-unknown': true, 49 | 'length-zero-no-unit': true, 50 | 51 | // Colors 52 | 'color-no-invalid-hex': true, 53 | 54 | // Fonts 55 | 'font-family-no-duplicate-names': true, 56 | 'font-family-no-missing-generic-family-keyword': true, 57 | 'font-family-name-quotes': 'always-unless-keyword', 58 | 59 | // Function 60 | 'function-linear-gradient-no-nonstandard-direction': true, 61 | // 'function-calc-no-invalid': true, 62 | // Comment 63 | 'comment-no-empty': true, 64 | 65 | // Operators 66 | 'scss/operator-no-unspaced': true, 67 | }, 68 | }; 69 | -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | compressionLevel: mixed 2 | 3 | enableGlobalCache: false 4 | 5 | nodeLinker: node-modules 6 | 7 | yarnPath: .yarn/releases/yarn-4.5.3.cjs 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Kai Hotz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

React-PhoneNr-Input

2 | 3 |
4 | 5 | [![NPM](https://img.shields.io/npm/v/react-phonenr-input.svg)](https://www.npmjs.com/package/react-phonenr-input) 6 | [![license](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/KaiHotz/react-formik-ui/blob/master/LICENSE) 7 | ![npm](https://img.shields.io/npm/dw/react-phonenr-input) 8 | 9 |
10 | 11 | ## Overview 12 | React-PhoneNr-Input is a simple to use phonenumber input field with country selection, that by default, intuitively guesses the country for- and formats the entered phonenumber 13 | 14 | For International phonenumbers a dropdown menu is available to select ya country from. 15 | 16 | By passing the prop `format='NATIONAL'` and a default country e.g. `defaultCountry='DE'` a simple input field is shown that formats the entered phonenumber with the national format declared by the `defaultCountry` prop. 17 | 18 | All written with less than 300 lines of code 19 | 20 | 21 | ### Demo and Examples [here](https://kaihotz.github.io/React-PhoneNr-Input/) 22 | 23 | 24 | ## Installation 25 | npm: 26 | ```sh 27 | npm i -S react-phonenr-input 28 | ``` 29 | 30 | yarn: 31 | ```sh 32 | yarn add react-phonenr-input 33 | ``` 34 | 35 | #### Props: 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 |
NameTypeDefaultDescription
onChange(data: PhoneNumber) => voidrequiredThe function/method that returns the entered phonenumber or phonenumber object
withCountryMetabooleanfalse 54 | changes the retuned value into an Object that contains the phonenumber and the country information. 55 | eg.: 56 |
 57 |         {
 58 |           phoneNumber: "+49 176 12345678",
 59 |           country: {
 60 |             name: "Germany (Deutschland)"
 61 |             iso2: "DE"
 62 |           }
 63 |         }
 64 |       
65 |
classNamestringundefinedAdds a custom class to the Phonenumber Input Field
defaultCountryIsoCodeundefinedSets the default country (use iso alpha-2 country code e.g 'US', 'GB', 'DE')
disabledbooleanfalseDisables the Phonenumber Input Field
formatNumberFormat'INTERNATIONAL'One of: 'INTERNATIONAL', 'NATIONAL'. Sets the format of the entered phonenumber, in case of 'NATIONAL' the defaultCountry must be set
initialValuestringundefinedSets the initial Value of the Phonenumber Input. This is usefull in case you need to set a phonenumber stored for example in a database
placeholderstringundefinedSets the Placeholder text
preferredCountriesIsoCode[]undefinedLets you restrict the country dropdown to a specific list of countries (use iso alpha-2 country code e.g 'US', 'GB', 'DE')
regions"asia" | "europe" | "africa" | "north-africa" | "oceania" | "america" | "carribean" | "south-america" | "ex-ussr" | "european-union" | "middle-east" | "central-america" | "north-america" | Region[]undefinedLets you restrict the country dropdown to a list of countries in the specified regions
116 | 117 | ###### In addition to the here listed Props you can pass all other properties that can be used on a normal Html input field 118 | 119 | #### Code example: 120 | ```tsx 121 | import React, { useState } from 'react' 122 | import { PhoneInput, PhoneNumber } from 'react-phonenr-input'; 123 | 124 | const Example = () => { 125 | const [value, setValue] = useState('') 126 | 127 | const handleChange = (phoneNumber: PhoneNumber) => { 128 | // Do something with the phoneNumber 129 | setValue(phoneNumber) 130 | } 131 | 132 | return ( 133 |
134 | 135 |
136 | ) 137 | } 138 | ``` 139 | 140 | #### Optimized for Mobile usage 141 | 142 | mobile 143 | 144 | 145 | ## Support 146 | If you like the project and want to support my work, you can buy me a coffee :) 147 | 148 | [![paypal](https://img.shields.io/badge/donate-paypal-blue.svg)](https://paypal.me/kaihotz) 149 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js'; 2 | import globals from 'globals'; 3 | import reactHooks from 'eslint-plugin-react-hooks'; 4 | import reactRefresh from 'eslint-plugin-react-refresh'; 5 | import jsxA11y from 'eslint-plugin-jsx-a11y'; 6 | import configPrettier from 'eslint-config-prettier'; 7 | import eslintPluginPrettier from 'eslint-plugin-prettier'; 8 | import pluginReact from 'eslint-plugin-react'; 9 | import tseslint from 'typescript-eslint'; 10 | import pluginImport from 'eslint-plugin-import'; 11 | export default tseslint.config( 12 | { 13 | ignores: ['dist', '.git', '.npmrc', '.yarnrc', 'coverage', 'storybook-static', '.storybook', '.yarn', 'node_modules'], 14 | }, 15 | { 16 | extends: [js.configs.recommended, ...tseslint.configs.recommended, configPrettier], 17 | files: ['**/*.{ts,tsx}', '**/*.{js,jsx}'], 18 | languageOptions: { 19 | ecmaVersion: 'latest', 20 | globals: globals.browser, 21 | parser: tseslint.parser, 22 | parserOptions: { 23 | project: ['./tsconfig.json'], 24 | }, 25 | }, 26 | plugins: { 27 | 'react': pluginReact, 28 | 'react-hooks': reactHooks, 29 | 'react-refresh': reactRefresh, 30 | 'import': pluginImport, 31 | 'jsx-a11y': jsxA11y, 32 | 'prettier': eslintPluginPrettier, 33 | }, 34 | rules: { 35 | ...reactHooks.configs.recommended.rules, 36 | 'prettier/prettier': 'error', 37 | 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], 38 | 'newline-before-return': 'warn', 39 | 'no-console': [ 40 | 'warn', 41 | { 42 | allow: [ 43 | 'info', 44 | 'warn', 45 | 'dir', 46 | 'timeLog', 47 | 'assert', 48 | 'clear', 49 | 'count', 50 | 'countReset', 51 | 'group', 52 | 'groupEnd', 53 | 'table', 54 | 'dirxml', 55 | 'error', 56 | 'groupCollapsed', 57 | 'Console', 58 | 'profile', 59 | 'profileEnd', 60 | 'timeStamp', 61 | 'context', 62 | ], 63 | }, 64 | ], 65 | 'no-debugger': 'warn', 66 | 'no-warning-comments': 'warn', 67 | 'object-shorthand': 'error', 68 | 'no-param-reassign': 'off', 69 | 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], 70 | 'react/display-name': 'off', 71 | 'react/prop-types': 'off', 72 | 'react/self-closing-comp': [ 73 | 'error', 74 | { 75 | component: true, 76 | html: true, 77 | }, 78 | ], 79 | 'react/jsx-uses-react': 'error', 80 | 'react/jsx-uses-vars': 'error', 81 | 'react/jsx-props-no-spreading': 'off', 82 | 'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }], 83 | 'jsx-a11y/click-events-have-key-events': 'off', 84 | 'jsx-a11y/no-noninteractive-element-to-interactive-role': 'off', 85 | 'jsx-a11y/anchor-is-valid': [ 86 | 'error', 87 | { 88 | components: ['Link', 'RouterLink'], 89 | aspects: ['invalidHref'], 90 | }, 91 | ], 92 | 'sort-imports': ['error', { 'ignoreCase': true, 'ignoreDeclarationSort': true }], 93 | 'import/no-duplicates': 'error', 94 | 'import/no-self-import': 'error', 95 | 'import/order': [ 96 | 'error', 97 | { 98 | 'newlines-between': 'always', 99 | pathGroups: [ 100 | { 101 | pattern: '$/**', 102 | group: 'internal', 103 | }, 104 | ], 105 | pathGroupsExcludedImportTypes: ['builtin'], 106 | groups: [['builtin', 'external'], ['internal'], ['parent', 'sibling', 'index'], 'unknown'], 107 | }, 108 | ], 109 | 'import/no-cycle': [ 110 | 'error', 111 | { 112 | maxDepth: '∞', 113 | ignoreExternal: true, 114 | }, 115 | ], 116 | '@typescript-eslint/no-deprecated': 'warn', 117 | '@typescript-eslint/no-unused-vars': 'warn', 118 | '@typescript-eslint/no-misused-promises': 'off', 119 | '@typescript-eslint/unbound-method': 'off', 120 | '@typescript-eslint/no-unsafe-return': 'off', 121 | '@typescript-eslint/no-unsafe-call': 'off', 122 | '@typescript-eslint/no-unsafe-argument': 'off', 123 | '@typescript-eslint/no-unsafe-assignment': 'off', 124 | '@typescript-eslint/no-unsafe-member-access': 'off', 125 | '@typescript-eslint/no-use-before-define': ['error', { functions: false }], 126 | '@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }], 127 | }, 128 | }, 129 | ); 130 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-phonenr-input", 3 | "version": "3.2.6", 4 | "description": "An automated and intuitive international and national phone input field", 5 | "author": "Kai Hotz", 6 | "license": "MIT", 7 | "repository": { 8 | "type": "git", 9 | "url": "git@github.com:KaiHotz/React-PhoneNr-Input.git" 10 | }, 11 | "homepage": "https://github.com/KaiHotz/React-PhoneNr-Input", 12 | "publishConfig": { 13 | "registry": "https://npm.pkg.github.com/KaiHotz" 14 | }, 15 | "main": "dist/index.js", 16 | "module": "dist/index.js", 17 | "types": "dist/index.d.ts", 18 | "type": "module", 19 | "engines": { 20 | "node": ">=18" 21 | }, 22 | "scripts": { 23 | "start": "NODE_ENV=development BABEL_ENV=development yarn storybook", 24 | "build": "rimraf dist && NODE_ENV=production BABEL_ENV=production rollup -c", 25 | "lint": "yarn check-types && yarn eslint && yarn stylelint", 26 | "lint:fix": "yarn eslint:fix && yarn stylelint:fix", 27 | "eslint": "eslint . --report-unused-disable-directives --max-warnings 0", 28 | "eslint:fix": "eslint . --fix", 29 | "stylelint": "stylelint \"**/*.{css,scss,sass}\"", 30 | "stylelint:fix": "stylelint \"**/*.{css,scss,sass}\" --fix", 31 | "check-types": "tsc --noEmit true", 32 | "ci": "yarn lint && yarn test --watch=false", 33 | "test": "vitest --config ./vitest.config.ts", 34 | "release": "yarn ci && yarn build && npm publish", 35 | "storybook": "storybook dev -p 6006", 36 | "storybook:build": "storybook build" 37 | }, 38 | "peerDependencies": { 39 | "react": "18.x || 19.x", 40 | "react-dom": "18.x || 19.x" 41 | }, 42 | "dependencies": { 43 | "immer": "^10.1.1", 44 | "libphonenumber-js": "^1.11.16", 45 | "lodash.omit": "^4.5.0", 46 | "react-country-flag": "^3.1.0" 47 | }, 48 | "devDependencies": { 49 | "@chromatic-com/storybook": "^3.2.2", 50 | "@eslint/js": "^9.16.0", 51 | "@rollup/plugin-commonjs": "^28.0.1", 52 | "@rollup/plugin-node-resolve": "^15.3.0", 53 | "@rollup/plugin-terser": "^0.4.4", 54 | "@rollup/plugin-typescript": "^12.1.1", 55 | "@rollup/plugin-url": "^8.0.2", 56 | "@storybook/addon-docs": "^8.4.7", 57 | "@storybook/addon-essentials": "^8.4.7", 58 | "@storybook/addon-interactions": "^8.4.7", 59 | "@storybook/addon-links": "^8.4.7", 60 | "@storybook/addon-onboarding": "^8.4.7", 61 | "@storybook/blocks": "^8.4.7", 62 | "@storybook/react": "^8.4.7", 63 | "@storybook/react-vite": "^8.4.7", 64 | "@storybook/test": "^8.4.7", 65 | "@svgr/rollup": "^8.1.0", 66 | "@testing-library/dom": "^10.4.0", 67 | "@testing-library/jest-dom": "^6.6.3", 68 | "@testing-library/react": "^16.1.0", 69 | "@testing-library/user-event": "^14.5.2", 70 | "@types/lodash.omit": "^4.5.9", 71 | "@types/node": "^22.10.1", 72 | "@types/react": "^19.0.1", 73 | "@types/react-dom": "^19.0.1", 74 | "@vitejs/plugin-react": "^4.3.4", 75 | "clsx": "^2.1.1", 76 | "eslint": "^9.16.0", 77 | "eslint-config-prettier": "^9.1.0", 78 | "eslint-plugin-import": "^2.31.0", 79 | "eslint-plugin-jsx-a11y": "^6.10.2", 80 | "eslint-plugin-prettier": "^5.2.1", 81 | "eslint-plugin-react": "^7.37.2", 82 | "eslint-plugin-react-hooks": "^5.1.0", 83 | "eslint-plugin-react-refresh": "^0.4.16", 84 | "eslint-plugin-storybook": "^0.11.1", 85 | "globals": "^15.13.0", 86 | "jsdom": "^25.0.1", 87 | "postcss": "^8.4.49", 88 | "postcss-scss": "^4.0.9", 89 | "prettier": "3.4.2", 90 | "react": "^19.0.0", 91 | "react-dom": "^19.0.0", 92 | "regenerator-runtime": "^0.14.1", 93 | "rimraf": "^6.0.1", 94 | "rollup": "^4.28.1", 95 | "rollup-plugin-dts": "^6.1.1", 96 | "rollup-plugin-peer-deps-external": "^2.2.4", 97 | "rollup-plugin-postcss": "^4.0.2", 98 | "sass": "^1.82.0", 99 | "storybook": "^8.4.7", 100 | "stylelint": "^16.11.0", 101 | "stylelint-prettier": "^5.0.2", 102 | "stylelint-scss": "^6.10.0", 103 | "tslib": "^2.8.1", 104 | "typescript": "5.7.2", 105 | "typescript-eslint": "^8.17.0", 106 | "vite": "^6.0.3", 107 | "vite-plugin-svgr": "^4.3.0", 108 | "vitest": "^2.1.8" 109 | }, 110 | "resolutions": { 111 | "react": "^19.0.0", 112 | "react-dom": "^19.0.0", 113 | "@types/react": "^19.0.1", 114 | "@types/react-dom": "^19.0.1" 115 | }, 116 | "packageManager": "yarn@4.5.3" 117 | } 118 | -------------------------------------------------------------------------------- /rollup.config.mjs: -------------------------------------------------------------------------------- 1 | import { readFileSync } from 'fs'; 2 | import { defineConfig } from 'rollup'; 3 | import resolve from '@rollup/plugin-node-resolve'; 4 | import commonjs from '@rollup/plugin-commonjs'; 5 | import typescript from '@rollup/plugin-typescript'; 6 | import url from '@rollup/plugin-url'; 7 | import terser from '@rollup/plugin-terser'; 8 | import svgr from '@svgr/rollup'; 9 | import external from 'rollup-plugin-peer-deps-external'; 10 | import postcss from 'rollup-plugin-postcss'; 11 | import dts from 'rollup-plugin-dts'; 12 | import typescriptEngine from 'typescript'; 13 | 14 | const packageJson = JSON.parse(readFileSync('./package.json')); 15 | 16 | export default defineConfig( 17 | { 18 | input: './src/index.ts', 19 | output: [ 20 | { 21 | file: packageJson.module, 22 | format: 'es', 23 | exports: 'named', 24 | sourcemap: false, 25 | }, 26 | ], 27 | plugins: [ 28 | external({ includeDependencies: true }), 29 | resolve(), 30 | commonjs(), 31 | svgr(), 32 | url(), 33 | postcss({ 34 | plugins: [], 35 | minimize: true, 36 | }), 37 | typescript({ 38 | tsconfig: './tsconfig.json', 39 | typescript: typescriptEngine, 40 | sourceMap: false, 41 | exclude: [ 42 | 'coverage', 43 | '.storybook', 44 | 'storybook-static', 45 | 'config', 46 | 'dist', 47 | 'node_modules/**', 48 | '*.cjs', 49 | '*.mjs', 50 | '**/__snapshots__/*', 51 | '**/.storybook/*', 52 | '**/__tests__', 53 | '**/*.test.js+(|x)', 54 | '**/*.test.ts+(|x)', 55 | '**/*.mdx', 56 | '**/*.story.ts+(|x)', 57 | '**/*.story.js+(|x)', 58 | '**/*.stories.ts+(|x)', 59 | '**/*.stories.js+(|x)', 60 | 'setupTests.ts', 61 | 'vite.config.ts', 62 | 'vitest.config.ts', 63 | ], 64 | }), 65 | terser(), 66 | ], 67 | }, 68 | { 69 | input: 'dist/src/index.d.ts', 70 | output: [{ file: 'dist/index.d.ts', format: 'esm' }], 71 | external: [/\.(sc|sa|c)ss$/], 72 | plugins: [dts()], 73 | }, 74 | ); 75 | -------------------------------------------------------------------------------- /setupTests.ts: -------------------------------------------------------------------------------- 1 | import '@testing-library/jest-dom'; 2 | import 'regenerator-runtime/runtime'; 3 | -------------------------------------------------------------------------------- /src/PhoneInput/PhoneInput.stories.tsx: -------------------------------------------------------------------------------- 1 | import { FC, useState } from 'react'; 2 | 3 | import { PhoneInput } from './PhoneInput'; 4 | import { PhoneNumber } from '../types'; 5 | 6 | export default { 7 | title: 'PhoneInput', 8 | component: PhoneInput, 9 | }; 10 | 11 | export const Default: FC = () => { 12 | const [value, setValue] = useState(''); 13 | 14 | const handleChange = (phoneNumber: PhoneNumber) => { 15 | /* Do something with the phoneNumber eg.: setting state */ 16 | setValue(phoneNumber); 17 | }; 18 | 19 | return ( 20 | <> 21 |

Enter a Phone number to see the retuned value

22 | 23 | 24 | 25 |
26 | Preview of the returned Value: 27 |
{value && JSON.stringify(value, null, 2)}
28 |
29 | 30 | ); 31 | }; 32 | 33 | export const WithIntialPhoneNumber: FC = () => { 34 | const [value, setValue] = useState(''); 35 | 36 | const handleChange = (phoneNumber: PhoneNumber) => { 37 | /* Do something with the phoneNumber eg.: setting state */ 38 | setValue(phoneNumber); 39 | }; 40 | 41 | return ( 42 | <> 43 |

Enter a Phone number to see the retuned value

44 | 45 | 46 | 47 |
48 | Preview of the returned Value: 49 |
{value && JSON.stringify(value, null, 2)}
50 |
51 | 52 | ); 53 | }; 54 | 55 | export const WithPhoneNumberAndCountryMeta: FC = () => { 56 | const [value, setValue] = useState(''); 57 | 58 | const handleChange = (phoneNumber: PhoneNumber) => { 59 | /* Do something with the phoneNumber eg.: setting state */ 60 | setValue(phoneNumber); 61 | }; 62 | 63 | return ( 64 | <> 65 |

66 | Enter a Phone number to see the retuned value 67 |

68 | 69 | 70 | 71 |
72 | Preview of the returned Value: 73 |
{value && JSON.stringify(value, null, 2)}
74 |
75 | 76 | ); 77 | }; 78 | 79 | export const WithDefaultCountry: FC = () => { 80 | const [value, setValue] = useState(''); 81 | 82 | const handleChange = (phoneNumber: PhoneNumber) => { 83 | /* Do something with the phoneNumber eg.: setting state */ 84 | setValue(phoneNumber); 85 | }; 86 | 87 | return ( 88 | <> 89 |

90 | Enter a Phone number to see the retuned value 91 |

92 | 93 | 94 | 95 |
96 | Preview of the returned Value: 97 |
{value && JSON.stringify(value, null, 2)}
98 |
99 | 100 | ); 101 | }; 102 | 103 | export const WithPreferredCountries: FC = () => { 104 | const [value, setValue] = useState(''); 105 | 106 | const handleChange = (phoneNumber: PhoneNumber) => { 107 | /* Do something with the phoneNumber eg.: setting state */ 108 | setValue(phoneNumber); 109 | }; 110 | 111 | return ( 112 | <> 113 |

114 | Enter a Phone number to see the retuned value 115 |

116 | 117 | 118 | 119 |
120 | Preview of the returned Value: 121 |
{value && JSON.stringify(value, null, 2)}
122 |
123 | 124 | ); 125 | }; 126 | 127 | export const WithPreferredRegions: FC = () => { 128 | const [value, setValue] = useState(''); 129 | 130 | const handleChange = (phoneNumber: PhoneNumber) => { 131 | /* Do something with the phoneNumber eg.: setting state */ 132 | setValue(phoneNumber); 133 | }; 134 | 135 | return ( 136 | <> 137 |

138 | Enter a Phone number to see the retuned value 139 |

140 | 141 | 142 | 143 |
144 | Preview of the returned Value: 145 |
{value && JSON.stringify(value, null, 2)}
146 |
147 | 148 | ); 149 | }; 150 | 151 | export const NationalPhoneNumberFormat: FC = () => { 152 | const [value, setValue] = useState(''); 153 | 154 | const handleChange = (phoneNumber: PhoneNumber) => { 155 | /* Do something with the phoneNumber eg.: setting state */ 156 | setValue(phoneNumber); 157 | }; 158 | 159 | return ( 160 | <> 161 |

162 | Enter a Phone number to see the retuned value 163 |

164 | 165 | 166 | 167 |
168 | Preview of the returned Value: 169 |
{value && JSON.stringify(value, null, 2)}
170 |
171 | 172 | ); 173 | }; 174 | 175 | export const NationalPhoneNumberFormatWithMeta: FC = () => { 176 | const [value, setValue] = useState(''); 177 | 178 | const handleChange = (phoneNumber: PhoneNumber) => { 179 | /* Do something with the phoneNumber eg.: setting state */ 180 | setValue(phoneNumber); 181 | }; 182 | 183 | return ( 184 | <> 185 |

186 | Enter a Phone number to see the retuned value 187 |

188 | 189 | 196 | 197 |
198 | Preview of the returned Value: 199 |
{value && JSON.stringify(value, null, 2)}
200 |
201 | 202 | ); 203 | }; 204 | -------------------------------------------------------------------------------- /src/PhoneInput/PhoneInput.test.tsx: -------------------------------------------------------------------------------- 1 | import { describe, expect, it, vi } from 'vitest'; 2 | import { render, screen } from '@testing-library/react'; 3 | import user from '@testing-library/user-event'; 4 | import { CountryCode } from 'libphonenumber-js'; 5 | 6 | import { PhoneInput } from './PhoneInput'; 7 | 8 | const baseProps = { 9 | name: 'phoneInput', 10 | onChange: vi.fn(), 11 | }; 12 | 13 | describe('', () => { 14 | it('should render', () => { 15 | render(); 16 | const input = screen.getByRole('textbox'); 17 | 18 | expect(input).toBeInTheDocument(); 19 | }); 20 | 21 | it('should have the initial dialCode', () => { 22 | render(); 23 | const input = screen.getByRole('textbox'); 24 | 25 | expect(input).toHaveValue(''); 26 | }); 27 | 28 | it('should have default Country DE', () => { 29 | const props = { 30 | ...baseProps, 31 | defaultCountry: 'DE' as CountryCode, 32 | }; 33 | render(); 34 | const input = screen.getByRole('textbox'); 35 | 36 | expect(input).toHaveValue('+49'); 37 | }); 38 | 39 | it('should call onChange', async () => { 40 | render(); 41 | const input = screen.getByRole('textbox'); 42 | 43 | await user.click(input); 44 | 45 | expect(baseProps.onChange).toHaveBeenCalled(); 46 | }); 47 | 48 | it('should be disabled', () => { 49 | render(); 50 | const input = screen.getByRole('textbox'); 51 | 52 | expect(input).toHaveProperty('disabled'); 53 | }); 54 | 55 | it('should allow custom className', () => { 56 | const props = { 57 | ...baseProps, 58 | className: 'Custom', 59 | }; 60 | render(); 61 | const input = screen.getByRole('textbox'); 62 | 63 | expect(input).toHaveProperty('className'); 64 | }); 65 | }); 66 | -------------------------------------------------------------------------------- /src/PhoneInput/PhoneInput.tsx: -------------------------------------------------------------------------------- 1 | import { ChangeEvent, FC, useEffect, useRef } from 'react'; 2 | import cx from 'clsx'; 3 | import omit from 'lodash.omit'; 4 | import FlagIcon from 'react-country-flag'; 5 | import { CountryCode } from 'libphonenumber-js'; 6 | 7 | import { detectMobile, getCountryList, getInitialCountry, usePhonenumber } from '../utils'; 8 | import { IPhoneInputProps, PhoneNumber } from '../types'; 9 | import './styles.scss'; 10 | 11 | export const PhoneInput: FC = ({ 12 | className, 13 | maxLength = 21, 14 | defaultCountry, 15 | preferredCountries, 16 | regions, 17 | format = 'INTERNATIONAL', 18 | initialValue, 19 | withCountryMeta = false, 20 | onChange, 21 | disabled, 22 | placeholder, 23 | onFocus, 24 | onBlur, 25 | ...rest 26 | }) => { 27 | const initialCountry = getInitialCountry(defaultCountry, preferredCountries, regions); 28 | const countriesList = getCountryList(preferredCountries, regions); 29 | const isInternational = format === 'INTERNATIONAL'; 30 | const isMobile = detectMobile.any(); 31 | 32 | const phoneInputWrapper = useRef(null); 33 | const phoneInput = useRef(null); 34 | const countryList = useRef(null); 35 | const activeCountry = useRef(null); 36 | 37 | const { country, phoneNumber, showCountries, setShowCountries, onSelect, onInputChange, resetState } = usePhonenumber( 38 | { 39 | initialValue, 40 | initialCountry, 41 | format, 42 | }, 43 | ); 44 | 45 | useEffect(() => { 46 | const clickOutside = (e: Event): void => { 47 | if (phoneInputWrapper.current && !phoneInputWrapper.current.contains(e.target as Node)) { 48 | setShowCountries(false); 49 | } 50 | }; 51 | document.addEventListener('mousedown', clickOutside); 52 | 53 | return (): void => { 54 | document.removeEventListener('mousedown', clickOutside); 55 | }; 56 | // eslint-disable-next-line react-hooks/exhaustive-deps 57 | }, []); 58 | 59 | useEffect(() => { 60 | if (showCountries && country && countryList.current && activeCountry.current) { 61 | countryList.current.scrollTop = activeCountry.current.offsetTop - 50; 62 | } 63 | 64 | const data: PhoneNumber = withCountryMeta 65 | ? { phoneNumber, country: country ? omit(country, ['hasAreaCodes', 'isAreaCode', 'dialCode', 'regions']) : null } 66 | : phoneNumber; 67 | 68 | onChange(data); 69 | // eslint-disable-next-line react-hooks/exhaustive-deps 70 | }, [country, phoneNumber, showCountries]); 71 | 72 | const handleToggleList = (): void => { 73 | if (!disabled) { 74 | setShowCountries(!showCountries); 75 | } 76 | }; 77 | 78 | const handleMobileSelect = (e: ChangeEvent): void => { 79 | const { value } = e.target; 80 | onSelect(value as CountryCode); 81 | 82 | phoneInput.current?.focus(); 83 | }; 84 | 85 | const handleSelect = (countryCode: CountryCode) => (): void => { 86 | onSelect(countryCode); 87 | 88 | phoneInput.current?.focus(); 89 | }; 90 | 91 | const handleChange = (e: ChangeEvent): void => { 92 | const { value } = e.target; 93 | 94 | if (!value.length) { 95 | resetState(); 96 | } 97 | 98 | if (!/^[\d ()+-]+$/.test(value)) return; 99 | 100 | onInputChange(value); 101 | }; 102 | 103 | return ( 104 |
105 | {isInternational && ( 106 |
107 | {country ? ( 108 | 115 | ) : ( 116 | 123 | 124 | 125 | )} 126 | {isMobile && ( 127 | 140 | )} 141 |
142 | )} 143 | 156 | {showCountries && isInternational && !isMobile && ( 157 |
    158 | {countriesList.map((c) => { 159 | if (c?.isAreaCode) { 160 | return null; 161 | } 162 | 163 | return ( 164 |
  • 171 | 178 | {` (${c?.dialCode}) ${c?.name}`} 179 |
  • 180 | ); 181 | })} 182 |
183 | )} 184 |
185 | ); 186 | }; 187 | -------------------------------------------------------------------------------- /src/PhoneInput/index.ts: -------------------------------------------------------------------------------- 1 | export * from './PhoneInput'; 2 | -------------------------------------------------------------------------------- /src/PhoneInput/styles.scss: -------------------------------------------------------------------------------- 1 | .react-phonenr-input { 2 | display: flex; 3 | max-width: 320; 4 | position: relative; 5 | 6 | button, 7 | input { 8 | appearance: none; 9 | box-sizing: border-box; 10 | border: 1px solid #ccc; 11 | outline: none; 12 | border-radius: 0; 13 | height: calc(0.3rem * 6); 14 | } 15 | 16 | .flag-wrapper { 17 | position: relative; 18 | display: flex; 19 | align-content: center; 20 | justify-content: center; 21 | align-items: center; 22 | padding-right: 12px; 23 | padding-left: 5px; 24 | width: 20px; 25 | border: 1px solid #ccc; 26 | border-right: none; 27 | background-color: #ddd; 28 | 29 | select { 30 | position: absolute; 31 | appearance: none; 32 | width: 100%; 33 | height: 100%; 34 | padding: 0; 35 | margin: 0; 36 | border: none; 37 | border-radius: 0; 38 | opacity: 0%; 39 | z-index: 10; 40 | } 41 | 42 | &:after { 43 | content: ''; 44 | width: 0; 45 | height: 0; 46 | border: 4px solid transparent; 47 | border-color: #000 transparent transparent; 48 | position: absolute; 49 | right: 2px; 50 | top: 55%; 51 | transform: translateY(-50%); 52 | pointer-events: none; 53 | } 54 | } 55 | 56 | input { 57 | width: 280; 58 | font-size: inherit; 59 | padding: 0 5px; 60 | } 61 | 62 | ul { 63 | box-sizing: border-box; 64 | width: 100%; 65 | max-height: 290px; 66 | position: absolute; 67 | top: 35px; 68 | border: 1px solid #ccc; 69 | list-style: none; 70 | margin: 0; 71 | overflow-y: auto; 72 | padding: 0; 73 | background-color: #fff; 74 | z-index: 999; 75 | 76 | li { 77 | position: relative; 78 | display: flex; 79 | align-items: center; 80 | align-content: space-between; 81 | font-size: 1rem; 82 | padding: 3px 0.5rem 3px 5px; 83 | 84 | &:hover, 85 | &.active-country { 86 | background-color: #ddd; 87 | color: currentColor; 88 | cursor: pointer; 89 | } 90 | 91 | img { 92 | margin-right: 10px; 93 | } 94 | } 95 | 96 | /* width */ 97 | &::-webkit-scrollbar { 98 | width: 3px; 99 | } 100 | 101 | /* Track */ 102 | &::-webkit-scrollbar-track { 103 | background: #f1f1f1; 104 | box-shadow: inset 0 0 5px #ccc; 105 | } 106 | 107 | /* Handle */ 108 | &::-webkit-scrollbar-thumb { 109 | background: #888; 110 | } 111 | 112 | /* Handle on hover */ 113 | &::-webkit-scrollbar-thumb:hover { 114 | background: #555; 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/hooks/usePhonenumber.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, expect, it } from 'vitest'; 2 | import { act, renderHook } from '@testing-library/react'; 3 | 4 | import { usePhonenumber } from './usePhonenumber'; 5 | import { allCountries } from '../utils'; 6 | 7 | describe('usePhonenumber', () => { 8 | describe('INTERNATIONAL', () => { 9 | describe('default', () => { 10 | it('should have initial country undefined', () => { 11 | const { result } = renderHook(() => usePhonenumber({ format: 'INTERNATIONAL' })); 12 | 13 | expect(result.current.country).toBe(undefined); 14 | }); 15 | 16 | it('should have no initial value', () => { 17 | const { result } = renderHook(() => usePhonenumber({ format: 'INTERNATIONAL' })); 18 | 19 | expect(result.current.phoneNumber).toBe(''); 20 | }); 21 | 22 | it('should set correct county and dial code onSelect', () => { 23 | const { result } = renderHook(() => usePhonenumber({ format: 'INTERNATIONAL' })); 24 | 25 | act(() => result.current.onSelect('DE')); 26 | expect(result.current.country?.iso2).toBe('DE'); 27 | expect(result.current.phoneNumber).toBe('+49'); 28 | }); 29 | }); 30 | describe('With intial Country', () => { 31 | it('should have initial country', () => { 32 | const expected = allCountries[121]; 33 | const { result } = renderHook(() => usePhonenumber({ format: 'INTERNATIONAL', initialCountry: expected })); 34 | 35 | expect(result.current.country).toBe(expected); 36 | }); 37 | }); 38 | 39 | describe('With intial value', () => { 40 | it('should have initial country', () => { 41 | const expected = '+49 176 1234112'; 42 | const { result } = renderHook(() => usePhonenumber({ format: 'INTERNATIONAL', initialValue: expected })); 43 | 44 | expect(result.current.phoneNumber).toBe(expected); 45 | }); 46 | }); 47 | }); 48 | }); 49 | -------------------------------------------------------------------------------- /src/hooks/usePhonenumber.ts: -------------------------------------------------------------------------------- 1 | import { useEffect, useReducer } from 'react'; 2 | import { produce } from 'immer'; 3 | import { CountryCode, findPhoneNumbersInText } from 'libphonenumber-js'; 4 | 5 | import { IPhoneNumberState, IUsePhoneInputProps } from '../types'; 6 | import { findCountryByCode, formatNumber, getCountryByDialCode } from '../utils/countries-fn'; 7 | 8 | export const initialState: IPhoneNumberState = { 9 | country: undefined, 10 | phoneNumber: '', 11 | showCountries: false, 12 | }; 13 | 14 | interface IOnChange { 15 | type: 'onChange'; 16 | payload: Partial; 17 | } 18 | 19 | interface ISetShowCountries { 20 | type: 'setShowCountries'; 21 | payload: boolean; 22 | } 23 | 24 | const phoneInputReducer = (state: IPhoneNumberState, action: IOnChange | ISetShowCountries) => { 25 | switch (action.type) { 26 | case 'onChange': 27 | state = { ...state, ...action.payload }; 28 | 29 | return state; 30 | 31 | case 'setShowCountries': 32 | state.showCountries = action.payload; 33 | 34 | return state; 35 | 36 | default: 37 | return state; 38 | } 39 | }; 40 | 41 | export const usePhonenumber = ({ initialValue, initialCountry, format }: IUsePhoneInputProps) => { 42 | const reducer = produce(phoneInputReducer); 43 | const [state, dispatch] = useReducer(reducer, initialState); 44 | const isInternational = format === 'INTERNATIONAL'; 45 | 46 | useEffect(() => { 47 | let payload = { 48 | country: initialCountry, 49 | phoneNumber: isInternational && initialCountry ? initialCountry.dialCode : '', 50 | }; 51 | 52 | if (initialValue && typeof initialValue === 'string') { 53 | const metaData = findPhoneNumbersInText(initialValue); 54 | const selectedCountry = findCountryByCode(metaData[0].number.country); 55 | const formated = selectedCountry ? formatNumber(initialValue, format, selectedCountry.iso2) : initialValue; 56 | 57 | payload = { 58 | country: selectedCountry, 59 | phoneNumber: formated.length > 0 ? formated : initialValue, 60 | }; 61 | } 62 | 63 | dispatch({ 64 | type: 'onChange', 65 | payload, 66 | }); 67 | // eslint-disable-next-line react-hooks/exhaustive-deps 68 | }, []); 69 | 70 | const onSelect = (countryCode: CountryCode) => { 71 | const selectedCountry = findCountryByCode(countryCode); 72 | 73 | dispatch({ 74 | type: 'onChange', 75 | payload: { 76 | country: selectedCountry, 77 | phoneNumber: selectedCountry?.dialCode || '', 78 | showCountries: false, 79 | }, 80 | }); 81 | }; 82 | 83 | const onInputChange = (value: string) => { 84 | const formated = state.country ? formatNumber(value, format, state.country.iso2) : ''; 85 | const selectedCountry = getCountryByDialCode(formated.length > 0 ? formated : value); 86 | 87 | dispatch({ 88 | type: 'onChange', 89 | payload: { 90 | country: isInternational && selectedCountry ? selectedCountry : state.country, 91 | phoneNumber: formated.length > 0 ? formated : value, 92 | }, 93 | }); 94 | }; 95 | 96 | const resetState = () => { 97 | dispatch({ 98 | type: 'onChange', 99 | payload: isInternational ? initialState : { phoneNumber: '' }, 100 | }); 101 | }; 102 | 103 | const setShowCountries = (show: boolean) => { 104 | dispatch({ 105 | type: 'setShowCountries', 106 | payload: show, 107 | }); 108 | }; 109 | 110 | return { 111 | country: state.country, 112 | phoneNumber: state.phoneNumber, 113 | showCountries: state.showCountries, 114 | onSelect, 115 | onInputChange, 116 | setShowCountries, 117 | resetState, 118 | }; 119 | }; 120 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './PhoneInput'; 2 | export * from './types'; 3 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | import { InputHTMLAttributes } from 'react'; 2 | import { CountryCode } from 'libphonenumber-js'; 3 | 4 | export type Region = 5 | | 'asia' 6 | | 'europe' 7 | | 'africa' 8 | | 'north-africa' 9 | | 'oceania' 10 | | 'america' 11 | | 'carribean' 12 | | 'south-america' 13 | | 'ex-ussr' 14 | | 'european-union' 15 | | 'middle-east' 16 | | 'central-america' 17 | | 'north-america'; 18 | 19 | export type NumberFormat = 'INTERNATIONAL' | 'NATIONAL'; 20 | export type DetectMobile = boolean | null | RegExpMatchArray; 21 | 22 | export interface ICountry { 23 | name: string; 24 | regions: Region[]; 25 | iso2: CountryCode; 26 | dialCode: string; 27 | hasAreaCodes?: boolean; 28 | isAreaCode?: boolean; 29 | } 30 | 31 | export interface IPhoneNumberObj { 32 | phoneNumber: string; 33 | country: Omit | null; 34 | } 35 | 36 | export type PhoneNumber = string | IPhoneNumberObj; 37 | 38 | export interface IPhoneInputProps extends Omit, 'onChange'> { 39 | /** The function that returns the phonenumber or phonenumber object */ 40 | onChange: (data: PhoneNumber) => void; 41 | /** Sets the format of the entered phonenumber, in case of 'NATIONAL' the defaultCountry must be set */ 42 | format?: NumberFormat; 43 | /** 44 | * changes the retuned value into an Object that contains the phonenumber and country meta information 45 | * eg.: 46 | { 47 | phoneNumber: "+49 176 12345678", 48 | country: { 49 | name: "Germany (Deutschland)" 50 | iso2: "DE" 51 | } 52 | } 53 | */ 54 | withCountryMeta?: boolean; 55 | /** Sets the initial Value of the Phonenumber Input. This is usefull in case you need to set a phonenumber stored for example in a database */ 56 | initialValue?: PhoneNumber; 57 | /** Sets the default country (use iso alpha-2 country code e.g 'US', 'GB', 'DE') */ 58 | defaultCountry?: CountryCode; 59 | /** Lets you restrict the country dropdown to a specific list of countries (use iso alpha-2 country code e.g 'US', 'GB', 'DE') */ 60 | preferredCountries?: CountryCode[]; 61 | /** Lets you restrict the country dropdown to a list of countries in the specified regions */ 62 | regions?: Region | Region[]; 63 | } 64 | 65 | export interface IPhoneNumberState { 66 | country?: ICountry; 67 | phoneNumber: string; 68 | showCountries: boolean; 69 | } 70 | 71 | export interface IUsePhoneInputProps { 72 | format: NumberFormat; 73 | initialCountry?: ICountry; 74 | initialValue?: PhoneNumber; 75 | } 76 | -------------------------------------------------------------------------------- /src/utils/allCountries.ts: -------------------------------------------------------------------------------- 1 | import { ICountry } from '../types'; 2 | 3 | export const allCountries: ICountry[] = [ 4 | { 5 | name: 'Afghanistan', 6 | regions: ['asia'], 7 | iso2: 'AF', 8 | dialCode: '+93', 9 | hasAreaCodes: false, 10 | isAreaCode: false, 11 | }, 12 | { 13 | name: 'Albania (Shqipëri)', 14 | regions: ['europe'], 15 | iso2: 'AL', 16 | dialCode: '+355', 17 | hasAreaCodes: false, 18 | isAreaCode: false, 19 | }, 20 | { 21 | name: 'Algeria', 22 | regions: ['africa', 'north-africa'], 23 | iso2: 'DZ', 24 | dialCode: '+213', 25 | hasAreaCodes: false, 26 | isAreaCode: false, 27 | }, 28 | { 29 | name: 'American Samoa', 30 | regions: ['oceania'], 31 | iso2: 'AS', 32 | dialCode: '+1684', 33 | hasAreaCodes: false, 34 | isAreaCode: false, 35 | }, 36 | { 37 | name: 'Andorra', 38 | regions: ['europe'], 39 | iso2: 'AD', 40 | dialCode: '+376', 41 | hasAreaCodes: false, 42 | isAreaCode: false, 43 | }, 44 | { 45 | name: 'Angola', 46 | regions: ['africa'], 47 | iso2: 'AO', 48 | dialCode: '+244', 49 | hasAreaCodes: false, 50 | isAreaCode: false, 51 | }, 52 | { 53 | name: 'Anguilla', 54 | regions: ['america', 'carribean'], 55 | iso2: 'AI', 56 | dialCode: '+1264', 57 | hasAreaCodes: false, 58 | isAreaCode: false, 59 | }, 60 | { 61 | name: 'Antigua and Barbuda', 62 | regions: ['america', 'carribean'], 63 | iso2: 'AG', 64 | dialCode: '+1268', 65 | hasAreaCodes: false, 66 | isAreaCode: false, 67 | }, 68 | { 69 | name: 'Argentina', 70 | regions: ['america', 'south-america'], 71 | iso2: 'AR', 72 | dialCode: '+54', 73 | hasAreaCodes: false, 74 | isAreaCode: false, 75 | }, 76 | { 77 | name: 'Armenia', 78 | regions: ['asia', 'ex-ussr'], 79 | iso2: 'AM', 80 | dialCode: '+374', 81 | hasAreaCodes: false, 82 | isAreaCode: false, 83 | }, 84 | { 85 | name: 'Aruba', 86 | regions: ['america', 'carribean'], 87 | iso2: 'AW', 88 | dialCode: '+297', 89 | hasAreaCodes: false, 90 | isAreaCode: false, 91 | }, 92 | { 93 | name: 'Australia', 94 | regions: ['oceania'], 95 | iso2: 'AU', 96 | dialCode: '+61', 97 | hasAreaCodes: false, 98 | isAreaCode: false, 99 | }, 100 | { 101 | name: 'Austria (Österreich)', 102 | regions: ['europe', 'european-union'], 103 | iso2: 'AT', 104 | dialCode: '+43', 105 | hasAreaCodes: false, 106 | isAreaCode: false, 107 | }, 108 | { 109 | name: 'Azerbaijan (Azərbaycan)', 110 | regions: ['asia', 'ex-ussr'], 111 | iso2: 'AZ', 112 | dialCode: '+994', 113 | hasAreaCodes: false, 114 | isAreaCode: false, 115 | }, 116 | { 117 | name: 'Bahamas', 118 | regions: ['america', 'carribean'], 119 | iso2: 'BS', 120 | dialCode: '+1242', 121 | hasAreaCodes: false, 122 | isAreaCode: false, 123 | }, 124 | { 125 | name: 'Bahrain', 126 | regions: ['middle-east'], 127 | iso2: 'BH', 128 | dialCode: '+973', 129 | hasAreaCodes: false, 130 | isAreaCode: false, 131 | }, 132 | { 133 | name: 'Bangladesh (বাংলাদেশ)', 134 | regions: ['asia'], 135 | iso2: 'BD', 136 | dialCode: '+880', 137 | hasAreaCodes: false, 138 | isAreaCode: false, 139 | }, 140 | { 141 | name: 'Barbados', 142 | regions: ['america', 'carribean'], 143 | iso2: 'BB', 144 | dialCode: '+1246', 145 | hasAreaCodes: false, 146 | isAreaCode: false, 147 | }, 148 | { 149 | name: 'Belarus', 150 | regions: ['europe', 'ex-ussr'], 151 | iso2: 'BY', 152 | dialCode: '+375', 153 | hasAreaCodes: false, 154 | isAreaCode: false, 155 | }, 156 | { 157 | name: 'Belgium (België)', 158 | regions: ['europe', 'european-union'], 159 | iso2: 'BE', 160 | dialCode: '+32', 161 | hasAreaCodes: false, 162 | isAreaCode: false, 163 | }, 164 | { 165 | name: 'Belize', 166 | regions: ['america', 'central-america'], 167 | iso2: 'BZ', 168 | dialCode: '+501', 169 | hasAreaCodes: false, 170 | isAreaCode: false, 171 | }, 172 | { 173 | name: 'Benin (Bénin)', 174 | regions: ['africa'], 175 | iso2: 'BJ', 176 | dialCode: '+229', 177 | hasAreaCodes: false, 178 | isAreaCode: false, 179 | }, 180 | { 181 | name: 'Bermuda', 182 | regions: ['america', 'north-america'], 183 | iso2: 'BM', 184 | dialCode: '+1441', 185 | hasAreaCodes: false, 186 | isAreaCode: false, 187 | }, 188 | { 189 | name: 'Bhutan (འབྲུག)', 190 | regions: ['asia'], 191 | iso2: 'BT', 192 | dialCode: '+975', 193 | hasAreaCodes: false, 194 | isAreaCode: false, 195 | }, 196 | { 197 | name: 'Bolivia', 198 | regions: ['america', 'south-america'], 199 | iso2: 'BO', 200 | dialCode: '+591', 201 | hasAreaCodes: false, 202 | isAreaCode: false, 203 | }, 204 | { 205 | name: 'Bosnia and Herzegovina', 206 | regions: ['europe'], 207 | iso2: 'BA', 208 | dialCode: '+387', 209 | hasAreaCodes: false, 210 | isAreaCode: false, 211 | }, 212 | { 213 | name: 'Botswana', 214 | regions: ['africa'], 215 | iso2: 'BW', 216 | dialCode: '+267', 217 | hasAreaCodes: false, 218 | isAreaCode: false, 219 | }, 220 | { 221 | name: 'Brazil (Brasil)', 222 | regions: ['america', 'south-america'], 223 | iso2: 'BR', 224 | dialCode: '+55', 225 | hasAreaCodes: false, 226 | isAreaCode: false, 227 | }, 228 | { 229 | name: 'British Indian Ocean Territory', 230 | regions: ['asia'], 231 | iso2: 'IO', 232 | dialCode: '+246', 233 | hasAreaCodes: false, 234 | isAreaCode: false, 235 | }, 236 | { 237 | name: 'British Virgin Islands', 238 | regions: ['america', 'carribean'], 239 | iso2: 'VG', 240 | dialCode: '+1284', 241 | hasAreaCodes: false, 242 | isAreaCode: false, 243 | }, 244 | { 245 | name: 'Brunei', 246 | regions: ['asia'], 247 | iso2: 'BN', 248 | dialCode: '+673', 249 | hasAreaCodes: false, 250 | isAreaCode: false, 251 | }, 252 | { 253 | name: 'Bulgaria', 254 | regions: ['europe', 'european-union'], 255 | iso2: 'BG', 256 | dialCode: '+359', 257 | hasAreaCodes: false, 258 | isAreaCode: false, 259 | }, 260 | { 261 | name: 'Burkina Faso', 262 | regions: ['africa'], 263 | iso2: 'BF', 264 | dialCode: '+226', 265 | hasAreaCodes: false, 266 | isAreaCode: false, 267 | }, 268 | { 269 | name: 'Burundi (Uburundi)', 270 | regions: ['africa'], 271 | iso2: 'BI', 272 | dialCode: '+257', 273 | hasAreaCodes: false, 274 | isAreaCode: false, 275 | }, 276 | { 277 | name: 'Cambodia (កម្ពុជា)', 278 | regions: ['asia'], 279 | iso2: 'KH', 280 | dialCode: '+855', 281 | hasAreaCodes: false, 282 | isAreaCode: false, 283 | }, 284 | { 285 | name: 'Cameroon (Cameroun)', 286 | regions: ['africa'], 287 | iso2: 'CM', 288 | dialCode: '+237', 289 | hasAreaCodes: false, 290 | isAreaCode: false, 291 | }, 292 | { 293 | name: 'Canada', 294 | regions: ['america', 'north-america'], 295 | iso2: 'CA', 296 | dialCode: '+1', 297 | hasAreaCodes: true, 298 | isAreaCode: false, 299 | }, 300 | { 301 | name: 'Canada', 302 | regions: ['america', 'north-america'], 303 | iso2: 'CA', 304 | dialCode: '+1204', 305 | hasAreaCodes: true, 306 | isAreaCode: true, 307 | }, 308 | { 309 | name: 'Canada', 310 | regions: ['america', 'north-america'], 311 | iso2: 'CA', 312 | dialCode: '+1236', 313 | hasAreaCodes: true, 314 | isAreaCode: true, 315 | }, 316 | { 317 | name: 'Canada', 318 | regions: ['america', 'north-america'], 319 | iso2: 'CA', 320 | dialCode: '+1249', 321 | hasAreaCodes: true, 322 | isAreaCode: true, 323 | }, 324 | { 325 | name: 'Canada', 326 | regions: ['america', 'north-america'], 327 | iso2: 'CA', 328 | dialCode: '+1250', 329 | hasAreaCodes: true, 330 | isAreaCode: true, 331 | }, 332 | { 333 | name: 'Canada', 334 | regions: ['america', 'north-america'], 335 | iso2: 'CA', 336 | dialCode: '+1289', 337 | hasAreaCodes: true, 338 | isAreaCode: true, 339 | }, 340 | { 341 | name: 'Canada', 342 | regions: ['america', 'north-america'], 343 | iso2: 'CA', 344 | dialCode: '+1306', 345 | hasAreaCodes: true, 346 | isAreaCode: true, 347 | }, 348 | { 349 | name: 'Canada', 350 | regions: ['america', 'north-america'], 351 | iso2: 'CA', 352 | dialCode: '+1343', 353 | hasAreaCodes: true, 354 | isAreaCode: true, 355 | }, 356 | { 357 | name: 'Canada', 358 | regions: ['america', 'north-america'], 359 | iso2: 'CA', 360 | dialCode: '+1365', 361 | hasAreaCodes: true, 362 | isAreaCode: true, 363 | }, 364 | { 365 | name: 'Canada', 366 | regions: ['america', 'north-america'], 367 | iso2: 'CA', 368 | dialCode: '+1387', 369 | hasAreaCodes: true, 370 | isAreaCode: true, 371 | }, 372 | { 373 | name: 'Canada', 374 | regions: ['america', 'north-america'], 375 | iso2: 'CA', 376 | dialCode: '+1403', 377 | hasAreaCodes: true, 378 | isAreaCode: true, 379 | }, 380 | { 381 | name: 'Canada', 382 | regions: ['america', 'north-america'], 383 | iso2: 'CA', 384 | dialCode: '+1416', 385 | hasAreaCodes: true, 386 | isAreaCode: true, 387 | }, 388 | { 389 | name: 'Canada', 390 | regions: ['america', 'north-america'], 391 | iso2: 'CA', 392 | dialCode: '+1418', 393 | hasAreaCodes: true, 394 | isAreaCode: true, 395 | }, 396 | { 397 | name: 'Canada', 398 | regions: ['america', 'north-america'], 399 | iso2: 'CA', 400 | dialCode: '+1431', 401 | hasAreaCodes: true, 402 | isAreaCode: true, 403 | }, 404 | { 405 | name: 'Canada', 406 | regions: ['america', 'north-america'], 407 | iso2: 'CA', 408 | dialCode: '+1437', 409 | hasAreaCodes: true, 410 | isAreaCode: true, 411 | }, 412 | { 413 | name: 'Canada', 414 | regions: ['america', 'north-america'], 415 | iso2: 'CA', 416 | dialCode: '+1438', 417 | hasAreaCodes: true, 418 | isAreaCode: true, 419 | }, 420 | { 421 | name: 'Canada', 422 | regions: ['america', 'north-america'], 423 | iso2: 'CA', 424 | dialCode: '+1450', 425 | hasAreaCodes: true, 426 | isAreaCode: true, 427 | }, 428 | { 429 | name: 'Canada', 430 | regions: ['america', 'north-america'], 431 | iso2: 'CA', 432 | dialCode: '+1506', 433 | hasAreaCodes: true, 434 | isAreaCode: true, 435 | }, 436 | { 437 | name: 'Canada', 438 | regions: ['america', 'north-america'], 439 | iso2: 'CA', 440 | dialCode: '+1514', 441 | hasAreaCodes: true, 442 | isAreaCode: true, 443 | }, 444 | { 445 | name: 'Canada', 446 | regions: ['america', 'north-america'], 447 | iso2: 'CA', 448 | dialCode: '+1519', 449 | hasAreaCodes: true, 450 | isAreaCode: true, 451 | }, 452 | { 453 | name: 'Canada', 454 | regions: ['america', 'north-america'], 455 | iso2: 'CA', 456 | dialCode: '+1548', 457 | hasAreaCodes: true, 458 | isAreaCode: true, 459 | }, 460 | { 461 | name: 'Canada', 462 | regions: ['america', 'north-america'], 463 | iso2: 'CA', 464 | dialCode: '+1579', 465 | hasAreaCodes: true, 466 | isAreaCode: true, 467 | }, 468 | { 469 | name: 'Canada', 470 | regions: ['america', 'north-america'], 471 | iso2: 'CA', 472 | dialCode: '+1581', 473 | hasAreaCodes: true, 474 | isAreaCode: true, 475 | }, 476 | { 477 | name: 'Canada', 478 | regions: ['america', 'north-america'], 479 | iso2: 'CA', 480 | dialCode: '+1587', 481 | hasAreaCodes: true, 482 | isAreaCode: true, 483 | }, 484 | { 485 | name: 'Canada', 486 | regions: ['america', 'north-america'], 487 | iso2: 'CA', 488 | dialCode: '+1604', 489 | hasAreaCodes: true, 490 | isAreaCode: true, 491 | }, 492 | { 493 | name: 'Canada', 494 | regions: ['america', 'north-america'], 495 | iso2: 'CA', 496 | dialCode: '+1613', 497 | hasAreaCodes: true, 498 | isAreaCode: true, 499 | }, 500 | { 501 | name: 'Canada', 502 | regions: ['america', 'north-america'], 503 | iso2: 'CA', 504 | dialCode: '+1639', 505 | hasAreaCodes: true, 506 | isAreaCode: true, 507 | }, 508 | { 509 | name: 'Canada', 510 | regions: ['america', 'north-america'], 511 | iso2: 'CA', 512 | dialCode: '+1647', 513 | hasAreaCodes: true, 514 | isAreaCode: true, 515 | }, 516 | { 517 | name: 'Canada', 518 | regions: ['america', 'north-america'], 519 | iso2: 'CA', 520 | dialCode: '+1672', 521 | hasAreaCodes: true, 522 | isAreaCode: true, 523 | }, 524 | { 525 | name: 'Canada', 526 | regions: ['america', 'north-america'], 527 | iso2: 'CA', 528 | dialCode: '+1705', 529 | hasAreaCodes: true, 530 | isAreaCode: true, 531 | }, 532 | { 533 | name: 'Canada', 534 | regions: ['america', 'north-america'], 535 | iso2: 'CA', 536 | dialCode: '+1709', 537 | hasAreaCodes: true, 538 | isAreaCode: true, 539 | }, 540 | { 541 | name: 'Canada', 542 | regions: ['america', 'north-america'], 543 | iso2: 'CA', 544 | dialCode: '+1742', 545 | hasAreaCodes: true, 546 | isAreaCode: true, 547 | }, 548 | { 549 | name: 'Canada', 550 | regions: ['america', 'north-america'], 551 | iso2: 'CA', 552 | dialCode: '+1778', 553 | hasAreaCodes: true, 554 | isAreaCode: true, 555 | }, 556 | { 557 | name: 'Canada', 558 | regions: ['america', 'north-america'], 559 | iso2: 'CA', 560 | dialCode: '+1780', 561 | hasAreaCodes: true, 562 | isAreaCode: true, 563 | }, 564 | { 565 | name: 'Canada', 566 | regions: ['america', 'north-america'], 567 | iso2: 'CA', 568 | dialCode: '+1782', 569 | hasAreaCodes: true, 570 | isAreaCode: true, 571 | }, 572 | { 573 | name: 'Canada', 574 | regions: ['america', 'north-america'], 575 | iso2: 'CA', 576 | dialCode: '+1807', 577 | hasAreaCodes: true, 578 | isAreaCode: true, 579 | }, 580 | { 581 | name: 'Canada', 582 | regions: ['america', 'north-america'], 583 | iso2: 'CA', 584 | dialCode: '+1819', 585 | hasAreaCodes: true, 586 | isAreaCode: true, 587 | }, 588 | { 589 | name: 'Canada', 590 | regions: ['america', 'north-america'], 591 | iso2: 'CA', 592 | dialCode: '+1825', 593 | hasAreaCodes: true, 594 | isAreaCode: true, 595 | }, 596 | { 597 | name: 'Canada', 598 | regions: ['america', 'north-america'], 599 | iso2: 'CA', 600 | dialCode: '+1867', 601 | hasAreaCodes: true, 602 | isAreaCode: true, 603 | }, 604 | { 605 | name: 'Canada', 606 | regions: ['america', 'north-america'], 607 | iso2: 'CA', 608 | dialCode: '+1873', 609 | hasAreaCodes: true, 610 | isAreaCode: true, 611 | }, 612 | { 613 | name: 'Canada', 614 | regions: ['america', 'north-america'], 615 | iso2: 'CA', 616 | dialCode: '+1902', 617 | hasAreaCodes: true, 618 | isAreaCode: true, 619 | }, 620 | { 621 | name: 'Canada', 622 | regions: ['america', 'north-america'], 623 | iso2: 'CA', 624 | dialCode: '+1905', 625 | hasAreaCodes: true, 626 | isAreaCode: true, 627 | }, 628 | { 629 | name: 'Cape Verde (Kabu Verdi)', 630 | regions: ['africa'], 631 | iso2: 'CV', 632 | dialCode: '+238', 633 | hasAreaCodes: false, 634 | isAreaCode: false, 635 | }, 636 | { 637 | name: 'Caribbean Netherlands', 638 | regions: ['america', 'carribean'], 639 | iso2: 'BQ', 640 | dialCode: '+599', 641 | hasAreaCodes: false, 642 | isAreaCode: false, 643 | }, 644 | { 645 | name: 'Cayman Islands', 646 | regions: ['america', 'carribean'], 647 | iso2: 'KY', 648 | dialCode: '+1345', 649 | hasAreaCodes: false, 650 | isAreaCode: false, 651 | }, 652 | { 653 | name: 'Central African Republic (République centrafricaine)', 654 | regions: ['africa'], 655 | iso2: 'CF', 656 | dialCode: '+236', 657 | hasAreaCodes: false, 658 | isAreaCode: false, 659 | }, 660 | { 661 | name: 'Chad (Tchad)', 662 | regions: ['africa'], 663 | iso2: 'TD', 664 | dialCode: '+235', 665 | hasAreaCodes: false, 666 | isAreaCode: false, 667 | }, 668 | { 669 | name: 'Chile', 670 | regions: ['america', 'south-america'], 671 | iso2: 'CL', 672 | dialCode: '+56', 673 | hasAreaCodes: false, 674 | isAreaCode: false, 675 | }, 676 | { 677 | name: 'China (中国)', 678 | regions: ['asia'], 679 | iso2: 'CN', 680 | dialCode: '+86', 681 | hasAreaCodes: false, 682 | isAreaCode: false, 683 | }, 684 | { 685 | name: 'Colombia', 686 | regions: ['america', 'south-america'], 687 | iso2: 'CO', 688 | dialCode: '+57', 689 | hasAreaCodes: false, 690 | isAreaCode: false, 691 | }, 692 | { 693 | name: 'Comoros', 694 | regions: ['africa'], 695 | iso2: 'KM', 696 | dialCode: '+269', 697 | hasAreaCodes: false, 698 | isAreaCode: false, 699 | }, 700 | { 701 | name: 'Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)', 702 | regions: ['africa'], 703 | iso2: 'CD', 704 | dialCode: '+243', 705 | hasAreaCodes: false, 706 | isAreaCode: false, 707 | }, 708 | { 709 | name: 'Congo (Republic) (Congo-Brazzaville)', 710 | regions: ['africa'], 711 | iso2: 'CG', 712 | dialCode: '+242', 713 | hasAreaCodes: false, 714 | isAreaCode: false, 715 | }, 716 | { 717 | name: 'Cook Islands', 718 | regions: ['oceania'], 719 | iso2: 'CK', 720 | dialCode: '+682', 721 | hasAreaCodes: false, 722 | isAreaCode: false, 723 | }, 724 | { 725 | name: 'Costa Rica', 726 | regions: ['america', 'central-america'], 727 | iso2: 'CR', 728 | dialCode: '+506', 729 | hasAreaCodes: false, 730 | isAreaCode: false, 731 | }, 732 | { 733 | name: 'Côte d Ivoire', 734 | regions: ['africa'], 735 | iso2: 'CI', 736 | dialCode: '+225', 737 | hasAreaCodes: false, 738 | isAreaCode: false, 739 | }, 740 | { 741 | name: 'Croatia (Hrvatska)', 742 | regions: ['europe', 'european-union'], 743 | iso2: 'HR', 744 | dialCode: '+385', 745 | hasAreaCodes: false, 746 | isAreaCode: false, 747 | }, 748 | { 749 | name: 'Cuba', 750 | regions: ['america', 'carribean'], 751 | iso2: 'CU', 752 | dialCode: '+53', 753 | hasAreaCodes: false, 754 | isAreaCode: false, 755 | }, 756 | { 757 | name: 'Curaçao', 758 | regions: ['america', 'carribean'], 759 | iso2: 'CW', 760 | dialCode: '+599', 761 | hasAreaCodes: false, 762 | isAreaCode: false, 763 | }, 764 | { 765 | name: 'Cyprus', 766 | regions: ['europe', 'european-union'], 767 | iso2: 'CY', 768 | dialCode: '+357', 769 | hasAreaCodes: false, 770 | isAreaCode: false, 771 | }, 772 | { 773 | name: 'Czech Republic (Česká republika)', 774 | regions: ['europe', 'european-union'], 775 | iso2: 'CZ', 776 | dialCode: '+420', 777 | hasAreaCodes: false, 778 | isAreaCode: false, 779 | }, 780 | { 781 | name: 'Denmark (Danmark)', 782 | regions: ['europe', 'european-union'], 783 | iso2: 'DK', 784 | dialCode: '+45', 785 | hasAreaCodes: false, 786 | isAreaCode: false, 787 | }, 788 | { 789 | name: 'Djibouti', 790 | regions: ['africa'], 791 | iso2: 'DJ', 792 | dialCode: '+253', 793 | hasAreaCodes: false, 794 | isAreaCode: false, 795 | }, 796 | { 797 | name: 'Dominica', 798 | regions: ['america', 'carribean'], 799 | iso2: 'DM', 800 | dialCode: '+1767', 801 | hasAreaCodes: false, 802 | isAreaCode: false, 803 | }, 804 | { 805 | name: 'Dominican Republic (República Dominicana)', 806 | regions: ['america', 'carribean'], 807 | iso2: 'DO', 808 | dialCode: '+1', 809 | hasAreaCodes: true, 810 | isAreaCode: false, 811 | }, 812 | { 813 | name: 'Dominican Republic (República Dominicana)', 814 | regions: ['america', 'carribean'], 815 | iso2: 'DO', 816 | dialCode: '+1809', 817 | hasAreaCodes: true, 818 | isAreaCode: true, 819 | }, 820 | { 821 | name: 'Dominican Republic (República Dominicana)', 822 | regions: ['america', 'carribean'], 823 | iso2: 'SO', 824 | dialCode: '+1829', 825 | hasAreaCodes: true, 826 | isAreaCode: true, 827 | }, 828 | { 829 | name: 'Dominican Republic (República Dominicana)', 830 | regions: ['america', 'carribean'], 831 | iso2: 'DO', 832 | dialCode: '+1849', 833 | hasAreaCodes: true, 834 | isAreaCode: true, 835 | }, 836 | { 837 | name: 'Ecuador', 838 | regions: ['america', 'south-america'], 839 | iso2: 'EC', 840 | dialCode: '+593', 841 | hasAreaCodes: false, 842 | isAreaCode: false, 843 | }, 844 | { 845 | name: 'Egypt', 846 | regions: ['africa', 'north-africa'], 847 | iso2: 'EG', 848 | dialCode: '+20', 849 | hasAreaCodes: false, 850 | isAreaCode: false, 851 | }, 852 | { 853 | name: 'El Salvador', 854 | regions: ['america', 'central-america'], 855 | iso2: 'SV', 856 | dialCode: '+503', 857 | hasAreaCodes: false, 858 | isAreaCode: false, 859 | }, 860 | { 861 | name: 'Equatorial Guinea (Guinea Ecuatorial)', 862 | regions: ['africa'], 863 | iso2: 'GQ', 864 | dialCode: '+240', 865 | hasAreaCodes: false, 866 | isAreaCode: false, 867 | }, 868 | { 869 | name: 'Eritrea', 870 | regions: ['africa'], 871 | iso2: 'ER', 872 | dialCode: '+291', 873 | hasAreaCodes: false, 874 | isAreaCode: false, 875 | }, 876 | { 877 | name: 'Estonia (Eesti)', 878 | regions: ['europe', 'european-union', 'ex-ussr'], 879 | iso2: 'EE', 880 | dialCode: '+372', 881 | hasAreaCodes: false, 882 | isAreaCode: false, 883 | }, 884 | { 885 | name: 'Ethiopia', 886 | regions: ['africa'], 887 | iso2: 'ET', 888 | dialCode: '+251', 889 | hasAreaCodes: false, 890 | isAreaCode: false, 891 | }, 892 | { 893 | name: 'Falkland Islands (Islas Malvinas)', 894 | regions: ['america', 'south-america'], 895 | iso2: 'FK', 896 | dialCode: '+500', 897 | hasAreaCodes: false, 898 | isAreaCode: false, 899 | }, 900 | { 901 | name: 'Faroe Islands (Føroyar)', 902 | regions: ['europe'], 903 | iso2: 'FO', 904 | dialCode: '+298', 905 | hasAreaCodes: false, 906 | isAreaCode: false, 907 | }, 908 | { 909 | name: 'Fiji', 910 | regions: ['oceania'], 911 | iso2: 'FJ', 912 | dialCode: '+679', 913 | hasAreaCodes: false, 914 | isAreaCode: false, 915 | }, 916 | { 917 | name: 'Finland (Suomi)', 918 | regions: ['europe', 'european-union'], 919 | iso2: 'FI', 920 | dialCode: '+358', 921 | hasAreaCodes: false, 922 | isAreaCode: false, 923 | }, 924 | { 925 | name: 'France', 926 | regions: ['europe', 'european-union'], 927 | iso2: 'FR', 928 | dialCode: '+33', 929 | hasAreaCodes: false, 930 | isAreaCode: false, 931 | }, 932 | { 933 | name: 'French Guiana (Guyane française)', 934 | regions: ['america', 'south-america'], 935 | iso2: 'GF', 936 | dialCode: '+594', 937 | hasAreaCodes: false, 938 | isAreaCode: false, 939 | }, 940 | { 941 | name: 'French Polynesia (Polynésie française)', 942 | regions: ['oceania'], 943 | iso2: 'PF', 944 | dialCode: '+689', 945 | hasAreaCodes: false, 946 | isAreaCode: false, 947 | }, 948 | { 949 | name: 'Gabon', 950 | regions: ['africa'], 951 | iso2: 'GA', 952 | dialCode: '+241', 953 | hasAreaCodes: false, 954 | isAreaCode: false, 955 | }, 956 | { 957 | name: 'Gambia', 958 | regions: ['africa'], 959 | iso2: 'GM', 960 | dialCode: '+220', 961 | hasAreaCodes: false, 962 | isAreaCode: false, 963 | }, 964 | { 965 | name: 'Georgia (საქართველო)', 966 | regions: ['asia', 'ex-ussr'], 967 | iso2: 'GE', 968 | dialCode: '+995', 969 | hasAreaCodes: false, 970 | isAreaCode: false, 971 | }, 972 | { 973 | name: 'Germany (Deutschland)', 974 | regions: ['europe', 'european-union'], 975 | iso2: 'DE', 976 | dialCode: '+49', 977 | hasAreaCodes: false, 978 | isAreaCode: false, 979 | }, 980 | { 981 | name: 'Ghana (Gaana)', 982 | regions: ['africa'], 983 | iso2: 'GH', 984 | dialCode: '+233', 985 | hasAreaCodes: false, 986 | isAreaCode: false, 987 | }, 988 | { 989 | name: 'Gibraltar', 990 | regions: ['europe'], 991 | iso2: 'GI', 992 | dialCode: '+350', 993 | hasAreaCodes: false, 994 | isAreaCode: false, 995 | }, 996 | { 997 | name: 'Greece', 998 | regions: ['europe', 'european-union'], 999 | iso2: 'GR', 1000 | dialCode: '+30', 1001 | hasAreaCodes: false, 1002 | isAreaCode: false, 1003 | }, 1004 | { 1005 | name: 'Greenland (Kalaallit Nunaat)', 1006 | regions: ['america'], 1007 | iso2: 'GL', 1008 | dialCode: '+299', 1009 | hasAreaCodes: false, 1010 | isAreaCode: false, 1011 | }, 1012 | { 1013 | name: 'Grenada', 1014 | regions: ['america', 'carribean'], 1015 | iso2: 'GD', 1016 | dialCode: '+1473', 1017 | hasAreaCodes: false, 1018 | isAreaCode: false, 1019 | }, 1020 | { 1021 | name: 'Guadeloupe', 1022 | regions: ['america', 'carribean'], 1023 | iso2: 'GP', 1024 | dialCode: '+590', 1025 | hasAreaCodes: false, 1026 | isAreaCode: false, 1027 | }, 1028 | { 1029 | name: 'Guam', 1030 | regions: ['oceania'], 1031 | iso2: 'GU', 1032 | dialCode: '+1671', 1033 | hasAreaCodes: false, 1034 | isAreaCode: false, 1035 | }, 1036 | { 1037 | name: 'Guatemala', 1038 | regions: ['america', 'central-america'], 1039 | iso2: 'GT', 1040 | dialCode: '+502', 1041 | hasAreaCodes: false, 1042 | isAreaCode: false, 1043 | }, 1044 | { 1045 | name: 'Guinea (Guinée)', 1046 | regions: ['africa'], 1047 | iso2: 'GN', 1048 | dialCode: '+224', 1049 | hasAreaCodes: false, 1050 | isAreaCode: false, 1051 | }, 1052 | { 1053 | name: 'Guinea-Bissau (Guiné Bissau)', 1054 | regions: ['africa'], 1055 | iso2: 'GW', 1056 | dialCode: '+245', 1057 | hasAreaCodes: false, 1058 | isAreaCode: false, 1059 | }, 1060 | { 1061 | name: 'Guyana', 1062 | regions: ['america', 'south-america'], 1063 | iso2: 'GY', 1064 | dialCode: '+592', 1065 | hasAreaCodes: false, 1066 | isAreaCode: false, 1067 | }, 1068 | { 1069 | name: 'Haiti', 1070 | regions: ['america', 'carribean'], 1071 | iso2: 'HT', 1072 | dialCode: '+509', 1073 | hasAreaCodes: false, 1074 | isAreaCode: false, 1075 | }, 1076 | { 1077 | name: 'Honduras', 1078 | regions: ['america', 'central-america'], 1079 | iso2: 'HN', 1080 | dialCode: '+504', 1081 | hasAreaCodes: false, 1082 | isAreaCode: false, 1083 | }, 1084 | { 1085 | name: 'Hong Kong (香港)', 1086 | regions: ['asia'], 1087 | iso2: 'HK', 1088 | dialCode: '+852', 1089 | hasAreaCodes: false, 1090 | isAreaCode: false, 1091 | }, 1092 | { 1093 | name: 'Hungary (Magyarország)', 1094 | regions: ['europe', 'european-union'], 1095 | iso2: 'HU', 1096 | dialCode: '+36', 1097 | hasAreaCodes: false, 1098 | isAreaCode: false, 1099 | }, 1100 | { 1101 | name: 'Iceland (Ísland)', 1102 | regions: ['europe'], 1103 | iso2: 'IS', 1104 | dialCode: '+354', 1105 | hasAreaCodes: false, 1106 | isAreaCode: false, 1107 | }, 1108 | { 1109 | name: 'India (भारत)', 1110 | regions: ['asia'], 1111 | iso2: 'IN', 1112 | dialCode: '+91', 1113 | hasAreaCodes: false, 1114 | isAreaCode: false, 1115 | }, 1116 | { 1117 | name: 'Indonesia', 1118 | regions: ['asia'], 1119 | iso2: 'ID', 1120 | dialCode: '+62', 1121 | hasAreaCodes: false, 1122 | isAreaCode: false, 1123 | }, 1124 | { 1125 | name: 'Iran', 1126 | regions: ['middle-east'], 1127 | iso2: 'IR', 1128 | dialCode: '+98', 1129 | hasAreaCodes: false, 1130 | isAreaCode: false, 1131 | }, 1132 | { 1133 | name: 'Iraq', 1134 | regions: ['middle-east'], 1135 | iso2: 'IQ', 1136 | dialCode: '+964', 1137 | hasAreaCodes: false, 1138 | isAreaCode: false, 1139 | }, 1140 | { 1141 | name: 'Ireland', 1142 | regions: ['europe', 'european-union'], 1143 | iso2: 'IE', 1144 | dialCode: '+353', 1145 | hasAreaCodes: false, 1146 | isAreaCode: false, 1147 | }, 1148 | { 1149 | name: 'Israel', 1150 | regions: ['middle-east'], 1151 | iso2: 'IL', 1152 | dialCode: '+972', 1153 | hasAreaCodes: false, 1154 | isAreaCode: false, 1155 | }, 1156 | { 1157 | name: 'Italy (Italia)', 1158 | regions: ['europe', 'european-union'], 1159 | iso2: 'IT', 1160 | dialCode: '+39', 1161 | hasAreaCodes: false, 1162 | isAreaCode: false, 1163 | }, 1164 | { 1165 | name: 'Jamaica', 1166 | regions: ['america', 'carribean'], 1167 | iso2: 'JM', 1168 | dialCode: '+1876', 1169 | hasAreaCodes: false, 1170 | isAreaCode: false, 1171 | }, 1172 | { 1173 | name: 'Japan (日本)', 1174 | regions: ['asia'], 1175 | iso2: 'JP', 1176 | dialCode: '+81', 1177 | hasAreaCodes: false, 1178 | isAreaCode: false, 1179 | }, 1180 | { 1181 | name: 'Jordan', 1182 | regions: ['middle-east'], 1183 | iso2: 'JO', 1184 | dialCode: '+962', 1185 | hasAreaCodes: false, 1186 | isAreaCode: false, 1187 | }, 1188 | { 1189 | name: 'Russia', 1190 | regions: ['europe', 'asia', 'ex-ussr'], 1191 | iso2: 'RU', 1192 | dialCode: '+7', 1193 | hasAreaCodes: false, 1194 | isAreaCode: false, 1195 | }, 1196 | { 1197 | name: 'Kazakhstan', 1198 | regions: ['asia', 'ex-ussr'], 1199 | iso2: 'KZ', 1200 | dialCode: '+7', 1201 | hasAreaCodes: true, 1202 | isAreaCode: false, 1203 | }, 1204 | { 1205 | name: 'Kazakhstan', 1206 | regions: ['asia', 'ex-ussr'], 1207 | iso2: 'KZ', 1208 | dialCode: '+7313', 1209 | hasAreaCodes: true, 1210 | isAreaCode: true, 1211 | }, 1212 | { 1213 | name: 'Kazakhstan', 1214 | regions: ['asia', 'ex-ussr'], 1215 | iso2: 'KZ', 1216 | dialCode: '+7327', 1217 | hasAreaCodes: true, 1218 | isAreaCode: true, 1219 | }, 1220 | { 1221 | name: 'Kazakhstan', 1222 | regions: ['asia', 'ex-ussr'], 1223 | iso2: 'KZ', 1224 | dialCode: '+77172', 1225 | hasAreaCodes: true, 1226 | isAreaCode: true, 1227 | }, 1228 | { 1229 | name: 'Kazakhstan', 1230 | regions: ['asia', 'ex-ussr'], 1231 | iso2: 'KZ', 1232 | dialCode: '+7312', 1233 | hasAreaCodes: true, 1234 | isAreaCode: true, 1235 | }, 1236 | { 1237 | name: 'Kazakhstan', 1238 | regions: ['asia', 'ex-ussr'], 1239 | iso2: 'KZ', 1240 | dialCode: '+773622', 1241 | hasAreaCodes: true, 1242 | isAreaCode: true, 1243 | }, 1244 | { 1245 | name: 'Kazakhstan', 1246 | regions: ['asia', 'ex-ussr'], 1247 | iso2: 'KZ', 1248 | dialCode: '+7321', 1249 | hasAreaCodes: true, 1250 | isAreaCode: true, 1251 | }, 1252 | { 1253 | name: 'Kazakhstan', 1254 | regions: ['asia', 'ex-ussr'], 1255 | iso2: 'KZ', 1256 | dialCode: '+7324', 1257 | hasAreaCodes: true, 1258 | isAreaCode: true, 1259 | }, 1260 | { 1261 | name: 'Kazakhstan', 1262 | regions: ['asia', 'ex-ussr'], 1263 | iso2: 'KZ', 1264 | dialCode: '+7336', 1265 | hasAreaCodes: true, 1266 | isAreaCode: true, 1267 | }, 1268 | { 1269 | name: 'Kazakhstan', 1270 | regions: ['asia', 'ex-ussr'], 1271 | iso2: 'KZ', 1272 | dialCode: '+7318', 1273 | hasAreaCodes: true, 1274 | isAreaCode: true, 1275 | }, 1276 | { 1277 | name: 'Kazakhstan', 1278 | regions: ['asia', 'ex-ussr'], 1279 | iso2: 'KZ', 1280 | dialCode: '+7315', 1281 | hasAreaCodes: true, 1282 | isAreaCode: true, 1283 | }, 1284 | { 1285 | name: 'Kazakhstan', 1286 | regions: ['asia', 'ex-ussr'], 1287 | iso2: 'KZ', 1288 | dialCode: '+7325', 1289 | hasAreaCodes: true, 1290 | isAreaCode: true, 1291 | }, 1292 | { 1293 | name: 'Kazakhstan', 1294 | regions: ['asia', 'ex-ussr'], 1295 | iso2: 'KZ', 1296 | dialCode: '+7311', 1297 | hasAreaCodes: true, 1298 | isAreaCode: true, 1299 | }, 1300 | { 1301 | name: 'Kazakhstan', 1302 | regions: ['asia', 'ex-ussr'], 1303 | iso2: 'KZ', 1304 | dialCode: '+7326', 1305 | hasAreaCodes: true, 1306 | isAreaCode: true, 1307 | }, 1308 | { 1309 | name: 'Kazakhstan', 1310 | regions: ['asia', 'ex-ussr'], 1311 | iso2: 'KZ', 1312 | dialCode: '+7310', 1313 | hasAreaCodes: true, 1314 | isAreaCode: true, 1315 | }, 1316 | { 1317 | name: 'Kenya', 1318 | regions: ['africa'], 1319 | iso2: 'KE', 1320 | dialCode: '+254', 1321 | hasAreaCodes: false, 1322 | isAreaCode: false, 1323 | }, 1324 | { 1325 | name: 'Kiribati', 1326 | regions: ['oceania'], 1327 | iso2: 'KI', 1328 | dialCode: '+686', 1329 | hasAreaCodes: false, 1330 | isAreaCode: false, 1331 | }, 1332 | { 1333 | name: 'Kuwait', 1334 | regions: ['middle-east'], 1335 | iso2: 'KW', 1336 | dialCode: '+965', 1337 | hasAreaCodes: false, 1338 | isAreaCode: false, 1339 | }, 1340 | { 1341 | name: 'Kyrgyzstan (Кыргызстан)', 1342 | regions: ['asia', 'ex-ussr'], 1343 | iso2: 'KG', 1344 | dialCode: '+996', 1345 | hasAreaCodes: false, 1346 | isAreaCode: false, 1347 | }, 1348 | { 1349 | name: 'Laos (ລາວ)', 1350 | regions: ['asia'], 1351 | iso2: 'LA', 1352 | dialCode: '+856', 1353 | hasAreaCodes: false, 1354 | isAreaCode: false, 1355 | }, 1356 | { 1357 | name: 'Latvia (Latvija)', 1358 | regions: ['europe', 'european-union', 'ex-ussr'], 1359 | iso2: 'LV', 1360 | dialCode: '+371', 1361 | hasAreaCodes: false, 1362 | isAreaCode: false, 1363 | }, 1364 | { 1365 | name: 'Lebanon', 1366 | regions: ['middle-east'], 1367 | iso2: 'LB', 1368 | dialCode: '+961', 1369 | hasAreaCodes: false, 1370 | isAreaCode: false, 1371 | }, 1372 | { 1373 | name: 'Lesotho', 1374 | regions: ['africa'], 1375 | iso2: 'LS', 1376 | dialCode: '+266', 1377 | hasAreaCodes: false, 1378 | isAreaCode: false, 1379 | }, 1380 | { 1381 | name: 'Liberia', 1382 | regions: ['africa'], 1383 | iso2: 'LR', 1384 | dialCode: '+231', 1385 | hasAreaCodes: false, 1386 | isAreaCode: false, 1387 | }, 1388 | { 1389 | name: 'Libya', 1390 | regions: ['africa', 'north-africa'], 1391 | iso2: 'LY', 1392 | dialCode: '+218', 1393 | hasAreaCodes: false, 1394 | isAreaCode: false, 1395 | }, 1396 | { 1397 | name: 'Liechtenstein', 1398 | regions: ['europe'], 1399 | iso2: 'LI', 1400 | dialCode: '+423', 1401 | hasAreaCodes: false, 1402 | isAreaCode: false, 1403 | }, 1404 | { 1405 | name: 'Lithuania (Lietuva)', 1406 | regions: ['europe', 'european-union', 'ex-ussr'], 1407 | iso2: 'LT', 1408 | dialCode: '+370', 1409 | hasAreaCodes: false, 1410 | isAreaCode: false, 1411 | }, 1412 | { 1413 | name: 'Luxembourg', 1414 | regions: ['europe', 'european-union'], 1415 | iso2: 'LU', 1416 | dialCode: '+352', 1417 | hasAreaCodes: false, 1418 | isAreaCode: false, 1419 | }, 1420 | { 1421 | name: 'Macau (澳門)', 1422 | regions: ['asia'], 1423 | iso2: 'MO', 1424 | dialCode: '+853', 1425 | hasAreaCodes: false, 1426 | isAreaCode: false, 1427 | }, 1428 | { 1429 | name: 'Macedonia (FYROM)', 1430 | regions: ['europe'], 1431 | iso2: 'MK', 1432 | dialCode: '+389', 1433 | hasAreaCodes: false, 1434 | isAreaCode: false, 1435 | }, 1436 | { 1437 | name: 'Madagascar (Madagasikara)', 1438 | regions: ['africa'], 1439 | iso2: 'MG', 1440 | dialCode: '+261', 1441 | hasAreaCodes: false, 1442 | isAreaCode: false, 1443 | }, 1444 | { 1445 | name: 'Malawi', 1446 | regions: ['africa'], 1447 | iso2: 'MW', 1448 | dialCode: '+265', 1449 | hasAreaCodes: false, 1450 | isAreaCode: false, 1451 | }, 1452 | { 1453 | name: 'Malaysia', 1454 | regions: ['asia'], 1455 | iso2: 'MY', 1456 | dialCode: '+60', 1457 | hasAreaCodes: false, 1458 | isAreaCode: false, 1459 | }, 1460 | { 1461 | name: 'Maldives', 1462 | regions: ['asia'], 1463 | iso2: 'MV', 1464 | dialCode: '+960', 1465 | hasAreaCodes: false, 1466 | isAreaCode: false, 1467 | }, 1468 | { 1469 | name: 'Mali', 1470 | regions: ['africa'], 1471 | iso2: 'ML', 1472 | dialCode: '+223', 1473 | hasAreaCodes: false, 1474 | isAreaCode: false, 1475 | }, 1476 | { 1477 | name: 'Malta', 1478 | regions: ['europe', 'european-union'], 1479 | iso2: 'MT', 1480 | dialCode: '+356', 1481 | hasAreaCodes: false, 1482 | isAreaCode: false, 1483 | }, 1484 | { 1485 | name: 'Marshall Islands', 1486 | regions: ['oceania'], 1487 | iso2: 'MH', 1488 | dialCode: '+692', 1489 | hasAreaCodes: false, 1490 | isAreaCode: false, 1491 | }, 1492 | { 1493 | name: 'Martinique', 1494 | regions: ['america', 'carribean'], 1495 | iso2: 'MQ', 1496 | dialCode: '+596', 1497 | hasAreaCodes: false, 1498 | isAreaCode: false, 1499 | }, 1500 | { 1501 | name: 'Mauritania', 1502 | regions: ['africa'], 1503 | iso2: 'MR', 1504 | dialCode: '+222', 1505 | hasAreaCodes: false, 1506 | isAreaCode: false, 1507 | }, 1508 | { 1509 | name: 'Mauritius (Moris)', 1510 | regions: ['africa'], 1511 | iso2: 'MU', 1512 | dialCode: '+230', 1513 | hasAreaCodes: false, 1514 | isAreaCode: false, 1515 | }, 1516 | { 1517 | name: 'Mexico (México)', 1518 | regions: ['america', 'central-america'], 1519 | iso2: 'MX', 1520 | dialCode: '+52', 1521 | hasAreaCodes: false, 1522 | isAreaCode: false, 1523 | }, 1524 | { 1525 | name: 'Micronesia', 1526 | regions: ['oceania'], 1527 | iso2: 'FM', 1528 | dialCode: '+691', 1529 | hasAreaCodes: false, 1530 | isAreaCode: false, 1531 | }, 1532 | { 1533 | name: 'Moldova (Republica Moldova)', 1534 | regions: ['europe'], 1535 | iso2: 'MD', 1536 | dialCode: '+373', 1537 | hasAreaCodes: false, 1538 | isAreaCode: false, 1539 | }, 1540 | { 1541 | name: 'Monaco', 1542 | regions: ['europe'], 1543 | iso2: 'MC', 1544 | dialCode: '+377', 1545 | hasAreaCodes: false, 1546 | isAreaCode: false, 1547 | }, 1548 | { 1549 | name: 'Mongolia (Монгол)', 1550 | regions: ['asia'], 1551 | iso2: 'MN', 1552 | dialCode: '+976', 1553 | hasAreaCodes: false, 1554 | isAreaCode: false, 1555 | }, 1556 | { 1557 | name: 'Montenegro (Crna Gora)', 1558 | regions: ['europe'], 1559 | iso2: 'ME', 1560 | dialCode: '+382', 1561 | hasAreaCodes: false, 1562 | isAreaCode: false, 1563 | }, 1564 | { 1565 | name: 'Montserrat', 1566 | regions: ['america', 'carribean'], 1567 | iso2: 'MS', 1568 | dialCode: '+1664', 1569 | hasAreaCodes: false, 1570 | isAreaCode: false, 1571 | }, 1572 | { 1573 | name: 'Morocco', 1574 | regions: ['africa', 'north-africa'], 1575 | iso2: 'MA', 1576 | dialCode: '+212', 1577 | hasAreaCodes: false, 1578 | isAreaCode: false, 1579 | }, 1580 | { 1581 | name: 'Mozambique (Moçambique)', 1582 | regions: ['africa'], 1583 | iso2: 'MZ', 1584 | dialCode: '+258', 1585 | hasAreaCodes: false, 1586 | isAreaCode: false, 1587 | }, 1588 | { 1589 | name: 'Myanmar (Burma) (မြန်မာ)', 1590 | regions: ['asia'], 1591 | iso2: 'MM', 1592 | dialCode: '+95', 1593 | hasAreaCodes: false, 1594 | isAreaCode: false, 1595 | }, 1596 | { 1597 | name: 'Namibia (Namibië)', 1598 | regions: ['africa'], 1599 | iso2: 'NA', 1600 | dialCode: '+264', 1601 | hasAreaCodes: false, 1602 | isAreaCode: false, 1603 | }, 1604 | { 1605 | name: 'Nauru', 1606 | regions: ['africa'], 1607 | iso2: 'NR', 1608 | dialCode: '+674', 1609 | hasAreaCodes: false, 1610 | isAreaCode: false, 1611 | }, 1612 | { 1613 | name: 'Nepal (नेपाल)', 1614 | regions: ['asia'], 1615 | iso2: 'NP', 1616 | dialCode: '+977', 1617 | hasAreaCodes: false, 1618 | isAreaCode: false, 1619 | }, 1620 | { 1621 | name: 'Netherlands (Nederland)', 1622 | regions: ['europe', 'european-union'], 1623 | iso2: 'NL', 1624 | dialCode: '+31', 1625 | hasAreaCodes: false, 1626 | isAreaCode: false, 1627 | }, 1628 | { 1629 | name: 'New Caledonia (Nouvelle-Calédonie)', 1630 | regions: ['oceania'], 1631 | iso2: 'NC', 1632 | dialCode: '+687', 1633 | hasAreaCodes: false, 1634 | isAreaCode: false, 1635 | }, 1636 | { 1637 | name: 'New Zealand', 1638 | regions: ['oceania'], 1639 | iso2: 'NZ', 1640 | dialCode: '+64', 1641 | hasAreaCodes: false, 1642 | isAreaCode: false, 1643 | }, 1644 | { 1645 | name: 'Nicaragua', 1646 | regions: ['america', 'central-america'], 1647 | iso2: 'NI', 1648 | dialCode: '+505', 1649 | hasAreaCodes: false, 1650 | isAreaCode: false, 1651 | }, 1652 | { 1653 | name: 'Niger (Nijar)', 1654 | regions: ['africa'], 1655 | iso2: 'NE', 1656 | dialCode: '+227', 1657 | hasAreaCodes: false, 1658 | isAreaCode: false, 1659 | }, 1660 | { 1661 | name: 'Nigeria', 1662 | regions: ['africa'], 1663 | iso2: 'NG', 1664 | dialCode: '+234', 1665 | hasAreaCodes: false, 1666 | isAreaCode: false, 1667 | }, 1668 | { 1669 | name: 'Niue', 1670 | regions: ['asia'], 1671 | iso2: 'NU', 1672 | dialCode: '+683', 1673 | hasAreaCodes: false, 1674 | isAreaCode: false, 1675 | }, 1676 | { 1677 | name: 'Norfolk Island', 1678 | regions: ['oceania'], 1679 | iso2: 'NF', 1680 | dialCode: '+672', 1681 | hasAreaCodes: false, 1682 | isAreaCode: false, 1683 | }, 1684 | { 1685 | name: 'North Korea (조선 민주주의 인민 공화국)', 1686 | regions: ['asia'], 1687 | iso2: 'KP', 1688 | dialCode: '+850', 1689 | hasAreaCodes: false, 1690 | isAreaCode: false, 1691 | }, 1692 | { 1693 | name: 'Northern Mariana Islands', 1694 | regions: ['oceania'], 1695 | iso2: 'MP', 1696 | dialCode: '+1670', 1697 | hasAreaCodes: false, 1698 | isAreaCode: false, 1699 | }, 1700 | { 1701 | name: 'Norway (Norge)', 1702 | regions: ['europe'], 1703 | iso2: 'NO', 1704 | dialCode: '+47', 1705 | hasAreaCodes: false, 1706 | isAreaCode: false, 1707 | }, 1708 | { 1709 | name: 'Oman', 1710 | regions: ['middle-east'], 1711 | iso2: 'OM', 1712 | dialCode: '+968', 1713 | hasAreaCodes: false, 1714 | isAreaCode: false, 1715 | }, 1716 | { 1717 | name: 'Pakistan', 1718 | regions: ['asia'], 1719 | iso2: 'PK', 1720 | dialCode: '+92', 1721 | hasAreaCodes: false, 1722 | isAreaCode: false, 1723 | }, 1724 | { 1725 | name: 'Palau', 1726 | regions: ['oceania'], 1727 | iso2: 'PW', 1728 | dialCode: '+680', 1729 | hasAreaCodes: false, 1730 | isAreaCode: false, 1731 | }, 1732 | { 1733 | name: 'Palestine', 1734 | regions: ['middle-east'], 1735 | iso2: 'PS', 1736 | dialCode: '+970', 1737 | hasAreaCodes: false, 1738 | isAreaCode: false, 1739 | }, 1740 | { 1741 | name: 'Panama (Panamá)', 1742 | regions: ['america', 'central-america'], 1743 | iso2: 'PA', 1744 | dialCode: '+507', 1745 | hasAreaCodes: false, 1746 | isAreaCode: false, 1747 | }, 1748 | { 1749 | name: 'Papua New Guinea', 1750 | regions: ['oceania'], 1751 | iso2: 'PG', 1752 | dialCode: '+675', 1753 | hasAreaCodes: false, 1754 | isAreaCode: false, 1755 | }, 1756 | { 1757 | name: 'Paraguay', 1758 | regions: ['america', 'south-america'], 1759 | iso2: 'PY', 1760 | dialCode: '+595', 1761 | hasAreaCodes: false, 1762 | isAreaCode: false, 1763 | }, 1764 | { 1765 | name: 'Peru (Perú)', 1766 | regions: ['america', 'south-america'], 1767 | iso2: 'PE', 1768 | dialCode: '+51', 1769 | hasAreaCodes: false, 1770 | isAreaCode: false, 1771 | }, 1772 | { 1773 | name: 'Philippines', 1774 | regions: ['asia'], 1775 | iso2: 'PH', 1776 | dialCode: '+63', 1777 | hasAreaCodes: false, 1778 | isAreaCode: false, 1779 | }, 1780 | { 1781 | name: 'Poland (Polska)', 1782 | regions: ['europe', 'european-union'], 1783 | iso2: 'PL', 1784 | dialCode: '+48', 1785 | hasAreaCodes: false, 1786 | isAreaCode: false, 1787 | }, 1788 | { 1789 | name: 'Portugal', 1790 | regions: ['europe', 'european-union'], 1791 | iso2: 'PT', 1792 | dialCode: '+351', 1793 | hasAreaCodes: false, 1794 | isAreaCode: false, 1795 | }, 1796 | { 1797 | name: 'Puerto Rico', 1798 | regions: ['america', 'carribean'], 1799 | iso2: 'PR', 1800 | dialCode: '+1', 1801 | hasAreaCodes: true, 1802 | isAreaCode: false, 1803 | }, 1804 | { 1805 | name: 'Puerto Rico', 1806 | regions: ['america', 'carribean'], 1807 | iso2: 'PR', 1808 | dialCode: '+1787', 1809 | hasAreaCodes: true, 1810 | isAreaCode: true, 1811 | }, 1812 | { 1813 | name: 'Puerto Rico', 1814 | regions: ['america', 'carribean'], 1815 | iso2: 'PR', 1816 | dialCode: '+1939', 1817 | hasAreaCodes: true, 1818 | isAreaCode: true, 1819 | }, 1820 | { 1821 | name: 'Qatar', 1822 | regions: ['middle-east'], 1823 | iso2: 'QA', 1824 | dialCode: '+974', 1825 | hasAreaCodes: false, 1826 | isAreaCode: false, 1827 | }, 1828 | { 1829 | name: 'Réunion (La Réunion)', 1830 | regions: ['africa'], 1831 | iso2: 'RE', 1832 | dialCode: '+262', 1833 | hasAreaCodes: false, 1834 | isAreaCode: false, 1835 | }, 1836 | { 1837 | name: 'Romania (România)', 1838 | regions: ['europe', 'european-union'], 1839 | iso2: 'RO', 1840 | dialCode: '+40', 1841 | hasAreaCodes: false, 1842 | isAreaCode: false, 1843 | }, 1844 | { 1845 | name: 'Rwanda', 1846 | regions: ['africa'], 1847 | iso2: 'RW', 1848 | dialCode: '+250', 1849 | hasAreaCodes: false, 1850 | isAreaCode: false, 1851 | }, 1852 | { 1853 | name: 'Saint Barthélemy (Saint-Barthélemy)', 1854 | regions: ['america', 'carribean'], 1855 | iso2: 'BL', 1856 | dialCode: '+590', 1857 | hasAreaCodes: false, 1858 | isAreaCode: false, 1859 | }, 1860 | { 1861 | name: 'Saint Helena', 1862 | regions: ['africa'], 1863 | iso2: 'SH', 1864 | dialCode: '+290', 1865 | hasAreaCodes: false, 1866 | isAreaCode: false, 1867 | }, 1868 | { 1869 | name: 'Saint Kitts and Nevis', 1870 | regions: ['america', 'carribean'], 1871 | iso2: 'KN', 1872 | dialCode: '+1869', 1873 | hasAreaCodes: false, 1874 | isAreaCode: false, 1875 | }, 1876 | { 1877 | name: 'Saint Lucia', 1878 | regions: ['america', 'carribean'], 1879 | iso2: 'LC', 1880 | dialCode: '+1758', 1881 | hasAreaCodes: false, 1882 | isAreaCode: false, 1883 | }, 1884 | { 1885 | name: 'Saint Martin (Saint-Martin (partie française))', 1886 | regions: ['america', 'carribean'], 1887 | iso2: 'MF', 1888 | dialCode: '+590', 1889 | hasAreaCodes: false, 1890 | isAreaCode: false, 1891 | }, 1892 | { 1893 | name: 'Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)', 1894 | regions: ['america', 'north-america'], 1895 | iso2: 'PM', 1896 | dialCode: '+508', 1897 | hasAreaCodes: false, 1898 | isAreaCode: false, 1899 | }, 1900 | { 1901 | name: 'Saint Vincent and the Grenadines', 1902 | regions: ['america', 'carribean'], 1903 | iso2: 'VC', 1904 | dialCode: '+1784', 1905 | hasAreaCodes: false, 1906 | isAreaCode: false, 1907 | }, 1908 | { 1909 | name: 'Samoa', 1910 | regions: ['oceania'], 1911 | iso2: 'WS', 1912 | dialCode: '+685', 1913 | hasAreaCodes: false, 1914 | isAreaCode: false, 1915 | }, 1916 | { 1917 | name: 'San Marino', 1918 | regions: ['europe'], 1919 | iso2: 'SM', 1920 | dialCode: '+378', 1921 | hasAreaCodes: false, 1922 | isAreaCode: false, 1923 | }, 1924 | { 1925 | name: 'São Tomé and Príncipe (São Tomé e Príncipe)', 1926 | regions: ['africa'], 1927 | iso2: 'ST', 1928 | dialCode: '+239', 1929 | hasAreaCodes: false, 1930 | isAreaCode: false, 1931 | }, 1932 | { 1933 | name: 'Saudi Arabia', 1934 | regions: ['middle-east'], 1935 | iso2: 'SA', 1936 | dialCode: '+966', 1937 | hasAreaCodes: false, 1938 | isAreaCode: false, 1939 | }, 1940 | { 1941 | name: 'Senegal (Sénégal)', 1942 | regions: ['africa'], 1943 | iso2: 'SN', 1944 | dialCode: '+221', 1945 | hasAreaCodes: false, 1946 | isAreaCode: false, 1947 | }, 1948 | { 1949 | name: 'Serbia', 1950 | regions: ['europe'], 1951 | iso2: 'RS', 1952 | dialCode: '+381', 1953 | hasAreaCodes: false, 1954 | isAreaCode: false, 1955 | }, 1956 | { 1957 | name: 'Seychelles', 1958 | regions: ['africa'], 1959 | iso2: 'SC', 1960 | dialCode: '+248', 1961 | hasAreaCodes: false, 1962 | isAreaCode: false, 1963 | }, 1964 | { 1965 | name: 'Sierra Leone', 1966 | regions: ['africa'], 1967 | iso2: 'SL', 1968 | dialCode: '+232', 1969 | hasAreaCodes: false, 1970 | isAreaCode: false, 1971 | }, 1972 | { 1973 | name: 'Singapore', 1974 | regions: ['asia'], 1975 | iso2: 'SG', 1976 | dialCode: '+65', 1977 | hasAreaCodes: false, 1978 | isAreaCode: false, 1979 | }, 1980 | { 1981 | name: 'Sint Maarten', 1982 | regions: ['america', 'carribean'], 1983 | iso2: 'SX', 1984 | dialCode: '+1721', 1985 | hasAreaCodes: false, 1986 | isAreaCode: false, 1987 | }, 1988 | { 1989 | name: 'Slovakia (Slovensko)', 1990 | regions: ['europe', 'european-union'], 1991 | iso2: 'SK', 1992 | dialCode: '+421', 1993 | hasAreaCodes: false, 1994 | isAreaCode: false, 1995 | }, 1996 | { 1997 | name: 'Slovenia (Slovenija)', 1998 | regions: ['europe', 'european-union'], 1999 | iso2: 'SI', 2000 | dialCode: '+386', 2001 | hasAreaCodes: false, 2002 | isAreaCode: false, 2003 | }, 2004 | { 2005 | name: 'Solomon Islands', 2006 | regions: ['oceania'], 2007 | iso2: 'SB', 2008 | dialCode: '+677', 2009 | hasAreaCodes: false, 2010 | isAreaCode: false, 2011 | }, 2012 | { 2013 | name: 'Somalia (Soomaaliya)', 2014 | regions: ['africa'], 2015 | iso2: 'SO', 2016 | dialCode: '+252', 2017 | hasAreaCodes: false, 2018 | isAreaCode: false, 2019 | }, 2020 | { 2021 | name: 'South Africa', 2022 | regions: ['africa'], 2023 | iso2: 'ZA', 2024 | dialCode: '+27', 2025 | hasAreaCodes: false, 2026 | isAreaCode: false, 2027 | }, 2028 | { 2029 | name: 'South Korea (대한민국)', 2030 | regions: ['asia'], 2031 | iso2: 'KR', 2032 | dialCode: '+82', 2033 | hasAreaCodes: false, 2034 | isAreaCode: false, 2035 | }, 2036 | { 2037 | name: 'South Sudan', 2038 | regions: ['africa', 'north-africa'], 2039 | iso2: 'SS', 2040 | dialCode: '+211', 2041 | hasAreaCodes: false, 2042 | isAreaCode: false, 2043 | }, 2044 | { 2045 | name: 'Spain (España)', 2046 | regions: ['europe', 'european-union'], 2047 | iso2: 'ES', 2048 | dialCode: '+34', 2049 | hasAreaCodes: false, 2050 | isAreaCode: false, 2051 | }, 2052 | { 2053 | name: 'Sri Lanka (ශ්‍රී ලංකාව)', 2054 | regions: ['asia'], 2055 | iso2: 'LK', 2056 | dialCode: '+94', 2057 | hasAreaCodes: false, 2058 | isAreaCode: false, 2059 | }, 2060 | { 2061 | name: 'Sudan', 2062 | regions: ['africa'], 2063 | iso2: 'SD', 2064 | dialCode: '+249', 2065 | hasAreaCodes: false, 2066 | isAreaCode: false, 2067 | }, 2068 | { 2069 | name: 'Suriname', 2070 | regions: ['america', 'south-america'], 2071 | iso2: 'SR', 2072 | dialCode: '+597', 2073 | hasAreaCodes: false, 2074 | isAreaCode: false, 2075 | }, 2076 | { 2077 | name: 'Swaziland', 2078 | regions: ['africa'], 2079 | iso2: 'SZ', 2080 | dialCode: '+268', 2081 | hasAreaCodes: false, 2082 | isAreaCode: false, 2083 | }, 2084 | { 2085 | name: 'Sweden (Sverige)', 2086 | regions: ['europe', 'european-union'], 2087 | iso2: 'SE', 2088 | dialCode: '+46', 2089 | hasAreaCodes: false, 2090 | isAreaCode: false, 2091 | }, 2092 | { 2093 | name: 'Switzerland (Schweiz)', 2094 | regions: ['europe'], 2095 | iso2: 'CH', 2096 | dialCode: '+41', 2097 | hasAreaCodes: false, 2098 | isAreaCode: false, 2099 | }, 2100 | { 2101 | name: 'Syria', 2102 | regions: ['middle-east'], 2103 | iso2: 'SY', 2104 | dialCode: '+963', 2105 | hasAreaCodes: false, 2106 | isAreaCode: false, 2107 | }, 2108 | { 2109 | name: 'Taiwan (台灣)', 2110 | regions: ['asia'], 2111 | iso2: 'TW', 2112 | dialCode: '+886', 2113 | hasAreaCodes: false, 2114 | isAreaCode: false, 2115 | }, 2116 | { 2117 | name: 'Tajikistan', 2118 | regions: ['asia', 'ex-ussr'], 2119 | iso2: 'TJ', 2120 | dialCode: '+992', 2121 | hasAreaCodes: false, 2122 | isAreaCode: false, 2123 | }, 2124 | { 2125 | name: 'Tanzania', 2126 | regions: ['africa'], 2127 | iso2: 'TZ', 2128 | dialCode: '+255', 2129 | hasAreaCodes: false, 2130 | isAreaCode: false, 2131 | }, 2132 | { 2133 | name: 'Thailand (ไทย)', 2134 | regions: ['asia'], 2135 | iso2: 'TH', 2136 | dialCode: '+66', 2137 | hasAreaCodes: false, 2138 | isAreaCode: false, 2139 | }, 2140 | { 2141 | name: 'Timor-Leste', 2142 | regions: ['asia'], 2143 | iso2: 'TL', 2144 | dialCode: '+670', 2145 | hasAreaCodes: false, 2146 | isAreaCode: false, 2147 | }, 2148 | { 2149 | name: 'Togo', 2150 | regions: ['africa'], 2151 | iso2: 'TG', 2152 | dialCode: '+228', 2153 | hasAreaCodes: false, 2154 | isAreaCode: false, 2155 | }, 2156 | { 2157 | name: 'Tokelau', 2158 | regions: ['oceania'], 2159 | iso2: 'TK', 2160 | dialCode: '+690', 2161 | hasAreaCodes: false, 2162 | isAreaCode: false, 2163 | }, 2164 | { 2165 | name: 'Tonga', 2166 | regions: ['oceania'], 2167 | iso2: 'TO', 2168 | dialCode: '+676', 2169 | hasAreaCodes: false, 2170 | isAreaCode: false, 2171 | }, 2172 | { 2173 | name: 'Trinidad and Tobago', 2174 | regions: ['america', 'carribean'], 2175 | iso2: 'TT', 2176 | dialCode: '+1868', 2177 | hasAreaCodes: false, 2178 | isAreaCode: false, 2179 | }, 2180 | { 2181 | name: 'Tunisia', 2182 | regions: ['africa', 'north-africa'], 2183 | iso2: 'TN', 2184 | dialCode: '+216', 2185 | hasAreaCodes: false, 2186 | isAreaCode: false, 2187 | }, 2188 | { 2189 | name: 'Turkey (Türkiye)', 2190 | regions: ['europe'], 2191 | iso2: 'TR', 2192 | dialCode: '+90', 2193 | hasAreaCodes: false, 2194 | isAreaCode: false, 2195 | }, 2196 | { 2197 | name: 'Turkmenistan', 2198 | regions: ['asia', 'ex-ussr'], 2199 | iso2: 'TM', 2200 | dialCode: '+993', 2201 | hasAreaCodes: false, 2202 | isAreaCode: false, 2203 | }, 2204 | { 2205 | name: 'Turks and Caicos Islands', 2206 | regions: ['america', 'carribean'], 2207 | iso2: 'TC', 2208 | dialCode: '+1649', 2209 | hasAreaCodes: false, 2210 | isAreaCode: false, 2211 | }, 2212 | { 2213 | name: 'Tuvalu', 2214 | regions: ['asia'], 2215 | iso2: 'TV', 2216 | dialCode: '+688', 2217 | hasAreaCodes: false, 2218 | isAreaCode: false, 2219 | }, 2220 | { 2221 | name: 'U.S. Virgin Islands', 2222 | regions: ['america', 'carribean'], 2223 | iso2: 'VI', 2224 | dialCode: '+1340', 2225 | hasAreaCodes: false, 2226 | isAreaCode: false, 2227 | }, 2228 | { 2229 | name: 'Uganda', 2230 | regions: ['africa'], 2231 | iso2: 'UG', 2232 | dialCode: '+256', 2233 | hasAreaCodes: false, 2234 | isAreaCode: false, 2235 | }, 2236 | { 2237 | name: 'Ukraine', 2238 | regions: ['europe', 'ex-ussr'], 2239 | iso2: 'UA', 2240 | dialCode: '+380', 2241 | hasAreaCodes: false, 2242 | isAreaCode: false, 2243 | }, 2244 | { 2245 | name: 'United Arab Emirates', 2246 | regions: ['middle-east'], 2247 | iso2: 'AE', 2248 | dialCode: '+971', 2249 | hasAreaCodes: false, 2250 | isAreaCode: false, 2251 | }, 2252 | { 2253 | name: 'United Kingdom', 2254 | regions: ['europe', 'european-union'], 2255 | iso2: 'GB', 2256 | dialCode: '+44', 2257 | hasAreaCodes: false, 2258 | isAreaCode: false, 2259 | }, 2260 | { 2261 | name: 'United States', 2262 | regions: ['america', 'north-america'], 2263 | iso2: 'US', 2264 | dialCode: '+1', 2265 | hasAreaCodes: true, 2266 | isAreaCode: false, 2267 | }, 2268 | { 2269 | name: 'United States', 2270 | regions: ['america', 'north-america'], 2271 | iso2: 'US', 2272 | dialCode: '+1907', 2273 | hasAreaCodes: true, 2274 | isAreaCode: true, 2275 | }, 2276 | { 2277 | name: 'United States', 2278 | regions: ['america', 'north-america'], 2279 | iso2: 'US', 2280 | dialCode: '+1205', 2281 | hasAreaCodes: true, 2282 | isAreaCode: true, 2283 | }, 2284 | { 2285 | name: 'United States', 2286 | regions: ['america', 'north-america'], 2287 | iso2: 'US', 2288 | dialCode: '+1251', 2289 | hasAreaCodes: true, 2290 | isAreaCode: true, 2291 | }, 2292 | { 2293 | name: 'United States', 2294 | regions: ['america', 'north-america'], 2295 | iso2: 'US', 2296 | dialCode: '+1256', 2297 | hasAreaCodes: true, 2298 | isAreaCode: true, 2299 | }, 2300 | { 2301 | name: 'United States', 2302 | regions: ['america', 'north-america'], 2303 | iso2: 'US', 2304 | dialCode: '+1334', 2305 | hasAreaCodes: true, 2306 | isAreaCode: true, 2307 | }, 2308 | { 2309 | name: 'United States', 2310 | regions: ['america', 'north-america'], 2311 | iso2: 'US', 2312 | dialCode: '+1479', 2313 | hasAreaCodes: true, 2314 | isAreaCode: true, 2315 | }, 2316 | { 2317 | name: 'United States', 2318 | regions: ['america', 'north-america'], 2319 | iso2: 'US', 2320 | dialCode: '+1501', 2321 | hasAreaCodes: true, 2322 | isAreaCode: true, 2323 | }, 2324 | { 2325 | name: 'United States', 2326 | regions: ['america', 'north-america'], 2327 | iso2: 'US', 2328 | dialCode: '+1870', 2329 | hasAreaCodes: true, 2330 | isAreaCode: true, 2331 | }, 2332 | { 2333 | name: 'United States', 2334 | regions: ['america', 'north-america'], 2335 | iso2: 'US', 2336 | dialCode: '+1480', 2337 | hasAreaCodes: true, 2338 | isAreaCode: true, 2339 | }, 2340 | { 2341 | name: 'United States', 2342 | regions: ['america', 'north-america'], 2343 | iso2: 'US', 2344 | dialCode: '+1520', 2345 | hasAreaCodes: true, 2346 | isAreaCode: true, 2347 | }, 2348 | { 2349 | name: 'United States', 2350 | regions: ['america', 'north-america'], 2351 | iso2: 'US', 2352 | dialCode: '+1602', 2353 | hasAreaCodes: true, 2354 | isAreaCode: true, 2355 | }, 2356 | { 2357 | name: 'United States', 2358 | regions: ['america', 'north-america'], 2359 | iso2: 'US', 2360 | dialCode: '+1623', 2361 | hasAreaCodes: true, 2362 | isAreaCode: true, 2363 | }, 2364 | { 2365 | name: 'United States', 2366 | regions: ['america', 'north-america'], 2367 | iso2: 'US', 2368 | dialCode: '+1928', 2369 | hasAreaCodes: true, 2370 | isAreaCode: true, 2371 | }, 2372 | { 2373 | name: 'United States', 2374 | regions: ['america', 'north-america'], 2375 | iso2: 'US', 2376 | dialCode: '+1209', 2377 | hasAreaCodes: true, 2378 | isAreaCode: true, 2379 | }, 2380 | { 2381 | name: 'United States', 2382 | regions: ['america', 'north-america'], 2383 | iso2: 'US', 2384 | dialCode: '+1213', 2385 | hasAreaCodes: true, 2386 | isAreaCode: true, 2387 | }, 2388 | { 2389 | name: 'United States', 2390 | regions: ['america', 'north-america'], 2391 | iso2: 'US', 2392 | dialCode: '+1310', 2393 | hasAreaCodes: true, 2394 | isAreaCode: true, 2395 | }, 2396 | { 2397 | name: 'United States', 2398 | regions: ['america', 'north-america'], 2399 | iso2: 'US', 2400 | dialCode: '+1323', 2401 | hasAreaCodes: true, 2402 | isAreaCode: true, 2403 | }, 2404 | { 2405 | name: 'United States', 2406 | regions: ['america', 'north-america'], 2407 | iso2: 'US', 2408 | dialCode: '+1408', 2409 | hasAreaCodes: true, 2410 | isAreaCode: true, 2411 | }, 2412 | { 2413 | name: 'United States', 2414 | regions: ['america', 'north-america'], 2415 | iso2: 'US', 2416 | dialCode: '+1415', 2417 | hasAreaCodes: true, 2418 | isAreaCode: true, 2419 | }, 2420 | { 2421 | name: 'United States', 2422 | regions: ['america', 'north-america'], 2423 | iso2: 'US', 2424 | dialCode: '+1510', 2425 | hasAreaCodes: true, 2426 | isAreaCode: true, 2427 | }, 2428 | { 2429 | name: 'United States', 2430 | regions: ['america', 'north-america'], 2431 | iso2: 'US', 2432 | dialCode: '+1530', 2433 | hasAreaCodes: true, 2434 | isAreaCode: true, 2435 | }, 2436 | { 2437 | name: 'United States', 2438 | regions: ['america', 'north-america'], 2439 | iso2: 'US', 2440 | dialCode: '+1559', 2441 | hasAreaCodes: true, 2442 | isAreaCode: true, 2443 | }, 2444 | { 2445 | name: 'United States', 2446 | regions: ['america', 'north-america'], 2447 | iso2: 'US', 2448 | dialCode: '+1562', 2449 | hasAreaCodes: true, 2450 | isAreaCode: true, 2451 | }, 2452 | { 2453 | name: 'United States', 2454 | regions: ['america', 'north-america'], 2455 | iso2: 'US', 2456 | dialCode: '+1619', 2457 | hasAreaCodes: true, 2458 | isAreaCode: true, 2459 | }, 2460 | { 2461 | name: 'United States', 2462 | regions: ['america', 'north-america'], 2463 | iso2: 'US', 2464 | dialCode: '+1626', 2465 | hasAreaCodes: true, 2466 | isAreaCode: true, 2467 | }, 2468 | { 2469 | name: 'United States', 2470 | regions: ['america', 'north-america'], 2471 | iso2: 'US', 2472 | dialCode: '+1650', 2473 | hasAreaCodes: true, 2474 | isAreaCode: true, 2475 | }, 2476 | { 2477 | name: 'United States', 2478 | regions: ['america', 'north-america'], 2479 | iso2: 'US', 2480 | dialCode: '+1661', 2481 | hasAreaCodes: true, 2482 | isAreaCode: true, 2483 | }, 2484 | { 2485 | name: 'United States', 2486 | regions: ['america', 'north-america'], 2487 | iso2: 'US', 2488 | dialCode: '+1707', 2489 | hasAreaCodes: true, 2490 | isAreaCode: true, 2491 | }, 2492 | { 2493 | name: 'United States', 2494 | regions: ['america', 'north-america'], 2495 | iso2: 'US', 2496 | dialCode: '+1714', 2497 | hasAreaCodes: true, 2498 | isAreaCode: true, 2499 | }, 2500 | { 2501 | name: 'United States', 2502 | regions: ['america', 'north-america'], 2503 | iso2: 'US', 2504 | dialCode: '+1760', 2505 | hasAreaCodes: true, 2506 | isAreaCode: true, 2507 | }, 2508 | { 2509 | name: 'United States', 2510 | regions: ['america', 'north-america'], 2511 | iso2: 'US', 2512 | dialCode: '+1805', 2513 | hasAreaCodes: true, 2514 | isAreaCode: true, 2515 | }, 2516 | { 2517 | name: 'United States', 2518 | regions: ['america', 'north-america'], 2519 | iso2: 'US', 2520 | dialCode: '+1818', 2521 | hasAreaCodes: true, 2522 | isAreaCode: true, 2523 | }, 2524 | { 2525 | name: 'United States', 2526 | regions: ['america', 'north-america'], 2527 | iso2: 'US', 2528 | dialCode: '+1831', 2529 | hasAreaCodes: true, 2530 | isAreaCode: true, 2531 | }, 2532 | { 2533 | name: 'United States', 2534 | regions: ['america', 'north-america'], 2535 | iso2: 'US', 2536 | dialCode: '+1858', 2537 | hasAreaCodes: true, 2538 | isAreaCode: true, 2539 | }, 2540 | { 2541 | name: 'United States', 2542 | regions: ['america', 'north-america'], 2543 | iso2: 'US', 2544 | dialCode: '+1909', 2545 | hasAreaCodes: true, 2546 | isAreaCode: true, 2547 | }, 2548 | { 2549 | name: 'United States', 2550 | regions: ['america', 'north-america'], 2551 | iso2: 'US', 2552 | dialCode: '+1916', 2553 | hasAreaCodes: true, 2554 | isAreaCode: true, 2555 | }, 2556 | { 2557 | name: 'United States', 2558 | regions: ['america', 'north-america'], 2559 | iso2: 'US', 2560 | dialCode: '+1925', 2561 | hasAreaCodes: true, 2562 | isAreaCode: true, 2563 | }, 2564 | { 2565 | name: 'United States', 2566 | regions: ['america', 'north-america'], 2567 | iso2: 'US', 2568 | dialCode: '+1949', 2569 | hasAreaCodes: true, 2570 | isAreaCode: true, 2571 | }, 2572 | { 2573 | name: 'United States', 2574 | regions: ['america', 'north-america'], 2575 | iso2: 'US', 2576 | dialCode: '+1951', 2577 | hasAreaCodes: true, 2578 | isAreaCode: true, 2579 | }, 2580 | { 2581 | name: 'United States', 2582 | regions: ['america', 'north-america'], 2583 | iso2: 'US', 2584 | dialCode: '+1303', 2585 | hasAreaCodes: true, 2586 | isAreaCode: true, 2587 | }, 2588 | { 2589 | name: 'United States', 2590 | regions: ['america', 'north-america'], 2591 | iso2: 'US', 2592 | dialCode: '+1719', 2593 | hasAreaCodes: true, 2594 | isAreaCode: true, 2595 | }, 2596 | { 2597 | name: 'United States', 2598 | regions: ['america', 'north-america'], 2599 | iso2: 'US', 2600 | dialCode: '+1970', 2601 | hasAreaCodes: true, 2602 | isAreaCode: true, 2603 | }, 2604 | { 2605 | name: 'United States', 2606 | regions: ['america', 'north-america'], 2607 | iso2: 'US', 2608 | dialCode: '+1203', 2609 | hasAreaCodes: true, 2610 | isAreaCode: true, 2611 | }, 2612 | { 2613 | name: 'United States', 2614 | regions: ['america', 'north-america'], 2615 | iso2: 'US', 2616 | dialCode: '+1860', 2617 | hasAreaCodes: true, 2618 | isAreaCode: true, 2619 | }, 2620 | { 2621 | name: 'United States', 2622 | regions: ['america', 'north-america'], 2623 | iso2: 'US', 2624 | dialCode: '+1202', 2625 | hasAreaCodes: true, 2626 | isAreaCode: true, 2627 | }, 2628 | { 2629 | name: 'United States', 2630 | regions: ['america', 'north-america'], 2631 | iso2: 'US', 2632 | dialCode: '+1302', 2633 | hasAreaCodes: true, 2634 | isAreaCode: true, 2635 | }, 2636 | { 2637 | name: 'United States', 2638 | regions: ['america', 'north-america'], 2639 | iso2: 'US', 2640 | dialCode: '+1239', 2641 | hasAreaCodes: true, 2642 | isAreaCode: true, 2643 | }, 2644 | { 2645 | name: 'United States', 2646 | regions: ['america', 'north-america'], 2647 | iso2: 'US', 2648 | dialCode: '+1305', 2649 | hasAreaCodes: true, 2650 | isAreaCode: true, 2651 | }, 2652 | { 2653 | name: 'United States', 2654 | regions: ['america', 'north-america'], 2655 | iso2: 'US', 2656 | dialCode: '+1321', 2657 | hasAreaCodes: true, 2658 | isAreaCode: true, 2659 | }, 2660 | { 2661 | name: 'United States', 2662 | regions: ['america', 'north-america'], 2663 | iso2: 'US', 2664 | dialCode: '+1352', 2665 | hasAreaCodes: true, 2666 | isAreaCode: true, 2667 | }, 2668 | { 2669 | name: 'United States', 2670 | regions: ['america', 'north-america'], 2671 | iso2: 'US', 2672 | dialCode: '+1386', 2673 | hasAreaCodes: true, 2674 | isAreaCode: true, 2675 | }, 2676 | { 2677 | name: 'United States', 2678 | regions: ['america', 'north-america'], 2679 | iso2: 'US', 2680 | dialCode: '+1407', 2681 | hasAreaCodes: true, 2682 | isAreaCode: true, 2683 | }, 2684 | { 2685 | name: 'United States', 2686 | regions: ['america', 'north-america'], 2687 | iso2: 'US', 2688 | dialCode: '+1561', 2689 | hasAreaCodes: true, 2690 | isAreaCode: true, 2691 | }, 2692 | { 2693 | name: 'United States', 2694 | regions: ['america', 'north-america'], 2695 | iso2: 'US', 2696 | dialCode: '+1727', 2697 | hasAreaCodes: true, 2698 | isAreaCode: true, 2699 | }, 2700 | { 2701 | name: 'United States', 2702 | regions: ['america', 'north-america'], 2703 | iso2: 'US', 2704 | dialCode: '+1772', 2705 | hasAreaCodes: true, 2706 | isAreaCode: true, 2707 | }, 2708 | { 2709 | name: 'United States', 2710 | regions: ['america', 'north-america'], 2711 | iso2: 'US', 2712 | dialCode: '+1813', 2713 | hasAreaCodes: true, 2714 | isAreaCode: true, 2715 | }, 2716 | { 2717 | name: 'United States', 2718 | regions: ['america', 'north-america'], 2719 | iso2: 'US', 2720 | dialCode: '+1850', 2721 | hasAreaCodes: true, 2722 | isAreaCode: true, 2723 | }, 2724 | { 2725 | name: 'United States', 2726 | regions: ['america', 'north-america'], 2727 | iso2: 'US', 2728 | dialCode: '+1863', 2729 | hasAreaCodes: true, 2730 | isAreaCode: true, 2731 | }, 2732 | { 2733 | name: 'United States', 2734 | regions: ['america', 'north-america'], 2735 | iso2: 'US', 2736 | dialCode: '+1904', 2737 | hasAreaCodes: true, 2738 | isAreaCode: true, 2739 | }, 2740 | { 2741 | name: 'United States', 2742 | regions: ['america', 'north-america'], 2743 | iso2: 'US', 2744 | dialCode: '+1941', 2745 | hasAreaCodes: true, 2746 | isAreaCode: true, 2747 | }, 2748 | { 2749 | name: 'United States', 2750 | regions: ['america', 'north-america'], 2751 | iso2: 'US', 2752 | dialCode: '+1954', 2753 | hasAreaCodes: true, 2754 | isAreaCode: true, 2755 | }, 2756 | { 2757 | name: 'United States', 2758 | regions: ['america', 'north-america'], 2759 | iso2: 'US', 2760 | dialCode: '+1229', 2761 | hasAreaCodes: true, 2762 | isAreaCode: true, 2763 | }, 2764 | { 2765 | name: 'United States', 2766 | regions: ['america', 'north-america'], 2767 | iso2: 'US', 2768 | dialCode: '+1404', 2769 | hasAreaCodes: true, 2770 | isAreaCode: true, 2771 | }, 2772 | { 2773 | name: 'United States', 2774 | regions: ['america', 'north-america'], 2775 | iso2: 'US', 2776 | dialCode: '+1478', 2777 | hasAreaCodes: true, 2778 | isAreaCode: true, 2779 | }, 2780 | { 2781 | name: 'United States', 2782 | regions: ['america', 'north-america'], 2783 | iso2: 'US', 2784 | dialCode: '+1706', 2785 | hasAreaCodes: true, 2786 | isAreaCode: true, 2787 | }, 2788 | { 2789 | name: 'United States', 2790 | regions: ['america', 'north-america'], 2791 | iso2: 'US', 2792 | dialCode: '+1770', 2793 | hasAreaCodes: true, 2794 | isAreaCode: true, 2795 | }, 2796 | { 2797 | name: 'United States', 2798 | regions: ['america', 'north-america'], 2799 | iso2: 'US', 2800 | dialCode: '+1912', 2801 | hasAreaCodes: true, 2802 | isAreaCode: true, 2803 | }, 2804 | { 2805 | name: 'United States', 2806 | regions: ['america', 'north-america'], 2807 | iso2: 'US', 2808 | dialCode: '+1808', 2809 | hasAreaCodes: true, 2810 | isAreaCode: true, 2811 | }, 2812 | { 2813 | name: 'United States', 2814 | regions: ['america', 'north-america'], 2815 | iso2: 'US', 2816 | dialCode: '+1319', 2817 | hasAreaCodes: true, 2818 | isAreaCode: true, 2819 | }, 2820 | { 2821 | name: 'United States', 2822 | regions: ['america', 'north-america'], 2823 | iso2: 'US', 2824 | dialCode: '+1515', 2825 | hasAreaCodes: true, 2826 | isAreaCode: true, 2827 | }, 2828 | { 2829 | name: 'United States', 2830 | regions: ['america', 'north-america'], 2831 | iso2: 'US', 2832 | dialCode: '+1563', 2833 | hasAreaCodes: true, 2834 | isAreaCode: true, 2835 | }, 2836 | { 2837 | name: 'United States', 2838 | regions: ['america', 'north-america'], 2839 | iso2: 'US', 2840 | dialCode: '+1641', 2841 | hasAreaCodes: true, 2842 | isAreaCode: true, 2843 | }, 2844 | { 2845 | name: 'United States', 2846 | regions: ['america', 'north-america'], 2847 | iso2: 'US', 2848 | dialCode: '+1712', 2849 | hasAreaCodes: true, 2850 | isAreaCode: true, 2851 | }, 2852 | { 2853 | name: 'United States', 2854 | regions: ['america', 'north-america'], 2855 | iso2: 'US', 2856 | dialCode: '+1208', 2857 | hasAreaCodes: true, 2858 | isAreaCode: true, 2859 | }, 2860 | { 2861 | name: 'United States', 2862 | regions: ['america', 'north-america'], 2863 | iso2: 'US', 2864 | dialCode: '+1217', 2865 | hasAreaCodes: true, 2866 | isAreaCode: true, 2867 | }, 2868 | { 2869 | name: 'United States', 2870 | regions: ['america', 'north-america'], 2871 | iso2: 'US', 2872 | dialCode: '+1309', 2873 | hasAreaCodes: true, 2874 | isAreaCode: true, 2875 | }, 2876 | { 2877 | name: 'United States', 2878 | regions: ['america', 'north-america'], 2879 | iso2: 'US', 2880 | dialCode: '+1312', 2881 | hasAreaCodes: true, 2882 | isAreaCode: true, 2883 | }, 2884 | { 2885 | name: 'United States', 2886 | regions: ['america', 'north-america'], 2887 | iso2: 'US', 2888 | dialCode: '+1618', 2889 | hasAreaCodes: true, 2890 | isAreaCode: true, 2891 | }, 2892 | { 2893 | name: 'United States', 2894 | regions: ['america', 'north-america'], 2895 | iso2: 'US', 2896 | dialCode: '+1630', 2897 | hasAreaCodes: true, 2898 | isAreaCode: true, 2899 | }, 2900 | { 2901 | name: 'United States', 2902 | regions: ['america', 'north-america'], 2903 | iso2: 'US', 2904 | dialCode: '+1708', 2905 | hasAreaCodes: true, 2906 | isAreaCode: true, 2907 | }, 2908 | { 2909 | name: 'United States', 2910 | regions: ['america', 'north-america'], 2911 | iso2: 'US', 2912 | dialCode: '+1773', 2913 | hasAreaCodes: true, 2914 | isAreaCode: true, 2915 | }, 2916 | { 2917 | name: 'United States', 2918 | regions: ['america', 'north-america'], 2919 | iso2: 'US', 2920 | dialCode: '+1815', 2921 | hasAreaCodes: true, 2922 | isAreaCode: true, 2923 | }, 2924 | { 2925 | name: 'United States', 2926 | regions: ['america', 'north-america'], 2927 | iso2: 'US', 2928 | dialCode: '+1847', 2929 | hasAreaCodes: true, 2930 | isAreaCode: true, 2931 | }, 2932 | { 2933 | name: 'United States', 2934 | regions: ['america', 'north-america'], 2935 | iso2: 'US', 2936 | dialCode: '+1219', 2937 | hasAreaCodes: true, 2938 | isAreaCode: true, 2939 | }, 2940 | { 2941 | name: 'United States', 2942 | regions: ['america', 'north-america'], 2943 | iso2: 'US', 2944 | dialCode: '+1260', 2945 | hasAreaCodes: true, 2946 | isAreaCode: true, 2947 | }, 2948 | { 2949 | name: 'United States', 2950 | regions: ['america', 'north-america'], 2951 | iso2: 'US', 2952 | dialCode: '+1317', 2953 | hasAreaCodes: true, 2954 | isAreaCode: true, 2955 | }, 2956 | { 2957 | name: 'United States', 2958 | regions: ['america', 'north-america'], 2959 | iso2: 'US', 2960 | dialCode: '+1574', 2961 | hasAreaCodes: true, 2962 | isAreaCode: true, 2963 | }, 2964 | { 2965 | name: 'United States', 2966 | regions: ['america', 'north-america'], 2967 | iso2: 'US', 2968 | dialCode: '+1765', 2969 | hasAreaCodes: true, 2970 | isAreaCode: true, 2971 | }, 2972 | { 2973 | name: 'United States', 2974 | regions: ['america', 'north-america'], 2975 | iso2: 'US', 2976 | dialCode: '+1812', 2977 | hasAreaCodes: true, 2978 | isAreaCode: true, 2979 | }, 2980 | { 2981 | name: 'United States', 2982 | regions: ['america', 'north-america'], 2983 | iso2: 'US', 2984 | dialCode: '+1316', 2985 | hasAreaCodes: true, 2986 | isAreaCode: true, 2987 | }, 2988 | { 2989 | name: 'United States', 2990 | regions: ['america', 'north-america'], 2991 | iso2: 'US', 2992 | dialCode: '+1620', 2993 | hasAreaCodes: true, 2994 | isAreaCode: true, 2995 | }, 2996 | { 2997 | name: 'United States', 2998 | regions: ['america', 'north-america'], 2999 | iso2: 'US', 3000 | dialCode: '+1785', 3001 | hasAreaCodes: true, 3002 | isAreaCode: true, 3003 | }, 3004 | { 3005 | name: 'United States', 3006 | regions: ['america', 'north-america'], 3007 | iso2: 'US', 3008 | dialCode: '+1913', 3009 | 3010 | hasAreaCodes: true, 3011 | isAreaCode: true, 3012 | }, 3013 | { 3014 | name: 'United States', 3015 | regions: ['america', 'north-america'], 3016 | iso2: 'US', 3017 | dialCode: '+1270', 3018 | hasAreaCodes: true, 3019 | isAreaCode: true, 3020 | }, 3021 | { 3022 | name: 'United States', 3023 | regions: ['america', 'north-america'], 3024 | iso2: 'US', 3025 | dialCode: '+1502', 3026 | hasAreaCodes: true, 3027 | isAreaCode: true, 3028 | }, 3029 | { 3030 | name: 'United States', 3031 | regions: ['america', 'north-america'], 3032 | iso2: 'US', 3033 | dialCode: '+1606', 3034 | hasAreaCodes: true, 3035 | isAreaCode: true, 3036 | }, 3037 | { 3038 | name: 'United States', 3039 | regions: ['america', 'north-america'], 3040 | iso2: 'US', 3041 | dialCode: '+1859', 3042 | hasAreaCodes: true, 3043 | isAreaCode: true, 3044 | }, 3045 | { 3046 | name: 'United States', 3047 | regions: ['america', 'north-america'], 3048 | iso2: 'US', 3049 | dialCode: '+1225', 3050 | hasAreaCodes: true, 3051 | isAreaCode: true, 3052 | }, 3053 | { 3054 | name: 'United States', 3055 | regions: ['america', 'north-america'], 3056 | iso2: 'US', 3057 | dialCode: '+1318', 3058 | hasAreaCodes: true, 3059 | isAreaCode: true, 3060 | }, 3061 | { 3062 | name: 'United States', 3063 | regions: ['america', 'north-america'], 3064 | iso2: 'US', 3065 | dialCode: '+1337', 3066 | hasAreaCodes: true, 3067 | isAreaCode: true, 3068 | }, 3069 | { 3070 | name: 'United States', 3071 | regions: ['america', 'north-america'], 3072 | iso2: 'US', 3073 | dialCode: '+1504', 3074 | hasAreaCodes: true, 3075 | isAreaCode: true, 3076 | }, 3077 | { 3078 | name: 'United States', 3079 | regions: ['america', 'north-america'], 3080 | iso2: 'US', 3081 | dialCode: '+1985', 3082 | hasAreaCodes: true, 3083 | isAreaCode: true, 3084 | }, 3085 | { 3086 | name: 'United States', 3087 | regions: ['america', 'north-america'], 3088 | iso2: 'US', 3089 | dialCode: '+1413', 3090 | hasAreaCodes: true, 3091 | isAreaCode: true, 3092 | }, 3093 | { 3094 | name: 'United States', 3095 | regions: ['america', 'north-america'], 3096 | iso2: 'US', 3097 | dialCode: '+1508', 3098 | hasAreaCodes: true, 3099 | isAreaCode: true, 3100 | }, 3101 | { 3102 | name: 'United States', 3103 | regions: ['america', 'north-america'], 3104 | iso2: 'US', 3105 | dialCode: '+1617', 3106 | hasAreaCodes: true, 3107 | isAreaCode: true, 3108 | }, 3109 | { 3110 | name: 'United States', 3111 | regions: ['america', 'north-america'], 3112 | iso2: 'US', 3113 | dialCode: '+1781', 3114 | hasAreaCodes: true, 3115 | isAreaCode: true, 3116 | }, 3117 | { 3118 | name: 'United States', 3119 | regions: ['america', 'north-america'], 3120 | iso2: 'US', 3121 | dialCode: '+1978', 3122 | hasAreaCodes: true, 3123 | isAreaCode: true, 3124 | }, 3125 | { 3126 | name: 'United States', 3127 | regions: ['america', 'north-america'], 3128 | iso2: 'US', 3129 | dialCode: '+1301', 3130 | hasAreaCodes: true, 3131 | isAreaCode: true, 3132 | }, 3133 | { 3134 | name: 'United States', 3135 | regions: ['america', 'north-america'], 3136 | iso2: 'US', 3137 | dialCode: '+1410', 3138 | hasAreaCodes: true, 3139 | isAreaCode: true, 3140 | }, 3141 | { 3142 | name: 'United States', 3143 | regions: ['america', 'north-america'], 3144 | iso2: 'US', 3145 | dialCode: '+1207', 3146 | hasAreaCodes: true, 3147 | isAreaCode: true, 3148 | }, 3149 | { 3150 | name: 'United States', 3151 | regions: ['america', 'north-america'], 3152 | iso2: 'US', 3153 | dialCode: '+1231', 3154 | hasAreaCodes: true, 3155 | isAreaCode: true, 3156 | }, 3157 | { 3158 | name: 'United States', 3159 | regions: ['america', 'north-america'], 3160 | iso2: 'US', 3161 | dialCode: '+1248', 3162 | hasAreaCodes: true, 3163 | isAreaCode: true, 3164 | }, 3165 | { 3166 | name: 'United States', 3167 | regions: ['america', 'north-america'], 3168 | iso2: 'US', 3169 | dialCode: '+1269', 3170 | hasAreaCodes: true, 3171 | isAreaCode: true, 3172 | }, 3173 | { 3174 | name: 'United States', 3175 | regions: ['america', 'north-america'], 3176 | iso2: 'US', 3177 | dialCode: '+1313', 3178 | hasAreaCodes: true, 3179 | isAreaCode: true, 3180 | }, 3181 | { 3182 | name: 'United States', 3183 | regions: ['america', 'north-america'], 3184 | iso2: 'US', 3185 | dialCode: '+1517', 3186 | hasAreaCodes: true, 3187 | isAreaCode: true, 3188 | }, 3189 | { 3190 | name: 'United States', 3191 | regions: ['america', 'north-america'], 3192 | iso2: 'US', 3193 | dialCode: '+1586', 3194 | hasAreaCodes: true, 3195 | isAreaCode: true, 3196 | }, 3197 | { 3198 | name: 'United States', 3199 | regions: ['america', 'north-america'], 3200 | iso2: 'US', 3201 | dialCode: '+1616', 3202 | hasAreaCodes: true, 3203 | isAreaCode: true, 3204 | }, 3205 | { 3206 | name: 'United States', 3207 | regions: ['america', 'north-america'], 3208 | iso2: 'US', 3209 | dialCode: '+1734', 3210 | hasAreaCodes: true, 3211 | isAreaCode: true, 3212 | }, 3213 | { 3214 | name: 'United States', 3215 | regions: ['america', 'north-america'], 3216 | iso2: 'US', 3217 | dialCode: '+1810', 3218 | hasAreaCodes: true, 3219 | isAreaCode: true, 3220 | }, 3221 | { 3222 | name: 'United States', 3223 | regions: ['america', 'north-america'], 3224 | iso2: 'US', 3225 | dialCode: '+1906', 3226 | hasAreaCodes: true, 3227 | isAreaCode: true, 3228 | }, 3229 | { 3230 | name: 'United States', 3231 | regions: ['america', 'north-america'], 3232 | iso2: 'US', 3233 | dialCode: '+1989', 3234 | hasAreaCodes: true, 3235 | isAreaCode: true, 3236 | }, 3237 | { 3238 | name: 'United States', 3239 | regions: ['america', 'north-america'], 3240 | iso2: 'US', 3241 | dialCode: '+1218', 3242 | hasAreaCodes: true, 3243 | isAreaCode: true, 3244 | }, 3245 | { 3246 | name: 'United States', 3247 | regions: ['america', 'north-america'], 3248 | iso2: 'US', 3249 | dialCode: '+1320', 3250 | hasAreaCodes: true, 3251 | isAreaCode: true, 3252 | }, 3253 | { 3254 | name: 'United States', 3255 | regions: ['america', 'north-america'], 3256 | iso2: 'US', 3257 | dialCode: '+1507', 3258 | hasAreaCodes: true, 3259 | isAreaCode: true, 3260 | }, 3261 | { 3262 | name: 'United States', 3263 | regions: ['america', 'north-america'], 3264 | iso2: 'US', 3265 | dialCode: '+1612', 3266 | hasAreaCodes: true, 3267 | isAreaCode: true, 3268 | }, 3269 | { 3270 | name: 'United States', 3271 | regions: ['america', 'north-america'], 3272 | iso2: 'US', 3273 | dialCode: '+1651', 3274 | hasAreaCodes: true, 3275 | isAreaCode: true, 3276 | }, 3277 | { 3278 | name: 'United States', 3279 | regions: ['america', 'north-america'], 3280 | iso2: 'US', 3281 | dialCode: '+1763', 3282 | hasAreaCodes: true, 3283 | isAreaCode: true, 3284 | }, 3285 | { 3286 | name: 'United States', 3287 | regions: ['america', 'north-america'], 3288 | iso2: 'US', 3289 | dialCode: '+1952', 3290 | hasAreaCodes: true, 3291 | isAreaCode: true, 3292 | }, 3293 | { 3294 | name: 'United States', 3295 | regions: ['america', 'north-america'], 3296 | iso2: 'US', 3297 | dialCode: '+1314', 3298 | hasAreaCodes: true, 3299 | isAreaCode: true, 3300 | }, 3301 | { 3302 | name: 'United States', 3303 | regions: ['america', 'north-america'], 3304 | iso2: 'US', 3305 | dialCode: '+1417', 3306 | hasAreaCodes: true, 3307 | isAreaCode: true, 3308 | }, 3309 | { 3310 | name: 'United States', 3311 | regions: ['america', 'north-america'], 3312 | iso2: 'US', 3313 | dialCode: '+1573', 3314 | hasAreaCodes: true, 3315 | isAreaCode: true, 3316 | }, 3317 | { 3318 | name: 'United States', 3319 | regions: ['america', 'north-america'], 3320 | iso2: 'US', 3321 | dialCode: '+1636', 3322 | hasAreaCodes: true, 3323 | isAreaCode: true, 3324 | }, 3325 | { 3326 | name: 'United States', 3327 | regions: ['america', 'north-america'], 3328 | iso2: 'US', 3329 | dialCode: '+1660', 3330 | hasAreaCodes: true, 3331 | isAreaCode: true, 3332 | }, 3333 | { 3334 | name: 'United States', 3335 | regions: ['america', 'north-america'], 3336 | iso2: 'US', 3337 | dialCode: '+1816', 3338 | hasAreaCodes: true, 3339 | isAreaCode: true, 3340 | }, 3341 | { 3342 | name: 'United States', 3343 | regions: ['america', 'north-america'], 3344 | iso2: 'US', 3345 | dialCode: '+1228', 3346 | hasAreaCodes: true, 3347 | isAreaCode: true, 3348 | }, 3349 | { 3350 | name: 'United States', 3351 | regions: ['america', 'north-america'], 3352 | iso2: 'US', 3353 | dialCode: '+1601', 3354 | hasAreaCodes: true, 3355 | isAreaCode: true, 3356 | }, 3357 | { 3358 | name: 'United States', 3359 | regions: ['america', 'north-america'], 3360 | iso2: 'US', 3361 | dialCode: '+1662', 3362 | hasAreaCodes: true, 3363 | isAreaCode: true, 3364 | }, 3365 | { 3366 | name: 'United States', 3367 | regions: ['america', 'north-america'], 3368 | iso2: 'US', 3369 | dialCode: '+1406', 3370 | hasAreaCodes: true, 3371 | isAreaCode: true, 3372 | }, 3373 | { 3374 | name: 'United States', 3375 | regions: ['america', 'north-america'], 3376 | iso2: 'US', 3377 | dialCode: '+1252', 3378 | hasAreaCodes: true, 3379 | isAreaCode: true, 3380 | }, 3381 | { 3382 | name: 'United States', 3383 | regions: ['america', 'north-america'], 3384 | iso2: 'US', 3385 | dialCode: '+1336', 3386 | hasAreaCodes: true, 3387 | isAreaCode: true, 3388 | }, 3389 | { 3390 | name: 'United States', 3391 | regions: ['america', 'north-america'], 3392 | iso2: 'US', 3393 | dialCode: '+1704', 3394 | hasAreaCodes: true, 3395 | isAreaCode: true, 3396 | }, 3397 | { 3398 | name: 'United States', 3399 | regions: ['america', 'north-america'], 3400 | iso2: 'US', 3401 | dialCode: '+1828', 3402 | hasAreaCodes: true, 3403 | isAreaCode: true, 3404 | }, 3405 | { 3406 | name: 'United States', 3407 | regions: ['america', 'north-america'], 3408 | iso2: 'US', 3409 | dialCode: '+1910', 3410 | hasAreaCodes: true, 3411 | isAreaCode: true, 3412 | }, 3413 | { 3414 | name: 'United States', 3415 | regions: ['america', 'north-america'], 3416 | iso2: 'US', 3417 | dialCode: '+1919', 3418 | hasAreaCodes: true, 3419 | isAreaCode: true, 3420 | }, 3421 | { 3422 | name: 'United States', 3423 | regions: ['america', 'north-america'], 3424 | iso2: 'US', 3425 | dialCode: '+1701', 3426 | hasAreaCodes: true, 3427 | isAreaCode: true, 3428 | }, 3429 | { 3430 | name: 'United States', 3431 | regions: ['america', 'north-america'], 3432 | iso2: 'US', 3433 | dialCode: '+1308', 3434 | hasAreaCodes: true, 3435 | isAreaCode: true, 3436 | }, 3437 | { 3438 | name: 'United States', 3439 | regions: ['america', 'north-america'], 3440 | iso2: 'US', 3441 | dialCode: '+1402', 3442 | hasAreaCodes: true, 3443 | isAreaCode: true, 3444 | }, 3445 | { 3446 | name: 'United States', 3447 | regions: ['america', 'north-america'], 3448 | iso2: 'US', 3449 | dialCode: '+1603', 3450 | hasAreaCodes: true, 3451 | isAreaCode: true, 3452 | }, 3453 | { 3454 | name: 'United States', 3455 | regions: ['america', 'north-america'], 3456 | iso2: 'US', 3457 | dialCode: '+1201', 3458 | hasAreaCodes: true, 3459 | isAreaCode: true, 3460 | }, 3461 | { 3462 | name: 'United States', 3463 | regions: ['america', 'north-america'], 3464 | iso2: 'US', 3465 | dialCode: '+1609', 3466 | hasAreaCodes: true, 3467 | isAreaCode: true, 3468 | }, 3469 | { 3470 | name: 'United States', 3471 | regions: ['america', 'north-america'], 3472 | iso2: 'US', 3473 | dialCode: '+1732', 3474 | hasAreaCodes: true, 3475 | isAreaCode: true, 3476 | }, 3477 | { 3478 | name: 'United States', 3479 | regions: ['america', 'north-america'], 3480 | iso2: 'US', 3481 | dialCode: '+1856', 3482 | hasAreaCodes: true, 3483 | isAreaCode: true, 3484 | }, 3485 | { 3486 | name: 'United States', 3487 | regions: ['america', 'north-america'], 3488 | iso2: 'US', 3489 | dialCode: '+1908', 3490 | hasAreaCodes: true, 3491 | isAreaCode: true, 3492 | }, 3493 | { 3494 | name: 'United States', 3495 | regions: ['america', 'north-america'], 3496 | iso2: 'US', 3497 | dialCode: '+1973', 3498 | hasAreaCodes: true, 3499 | isAreaCode: true, 3500 | }, 3501 | { 3502 | name: 'United States', 3503 | regions: ['america', 'north-america'], 3504 | iso2: 'US', 3505 | dialCode: '+1505', 3506 | hasAreaCodes: true, 3507 | isAreaCode: true, 3508 | }, 3509 | { 3510 | name: 'United States', 3511 | regions: ['america', 'north-america'], 3512 | iso2: 'US', 3513 | dialCode: '+1575', 3514 | hasAreaCodes: true, 3515 | isAreaCode: true, 3516 | }, 3517 | { 3518 | name: 'United States', 3519 | regions: ['america', 'north-america'], 3520 | iso2: 'US', 3521 | dialCode: '+1702', 3522 | hasAreaCodes: true, 3523 | isAreaCode: true, 3524 | }, 3525 | { 3526 | name: 'United States', 3527 | regions: ['america', 'north-america'], 3528 | iso2: 'US', 3529 | dialCode: '+1775', 3530 | hasAreaCodes: true, 3531 | isAreaCode: true, 3532 | }, 3533 | { 3534 | name: 'United States', 3535 | regions: ['america', 'north-america'], 3536 | iso2: 'US', 3537 | dialCode: '+1212', 3538 | hasAreaCodes: true, 3539 | isAreaCode: true, 3540 | }, 3541 | { 3542 | name: 'United States', 3543 | regions: ['america', 'north-america'], 3544 | iso2: 'US', 3545 | dialCode: '+1315', 3546 | hasAreaCodes: true, 3547 | isAreaCode: true, 3548 | }, 3549 | { 3550 | name: 'United States', 3551 | regions: ['america', 'north-america'], 3552 | iso2: 'US', 3553 | dialCode: '+1516', 3554 | hasAreaCodes: true, 3555 | isAreaCode: true, 3556 | }, 3557 | { 3558 | name: 'United States', 3559 | regions: ['america', 'north-america'], 3560 | iso2: 'US', 3561 | dialCode: '+1518', 3562 | hasAreaCodes: true, 3563 | isAreaCode: true, 3564 | }, 3565 | { 3566 | name: 'United States', 3567 | regions: ['america', 'north-america'], 3568 | iso2: 'US', 3569 | dialCode: '+1585', 3570 | hasAreaCodes: true, 3571 | isAreaCode: true, 3572 | }, 3573 | { 3574 | name: 'United States', 3575 | regions: ['america', 'north-america'], 3576 | iso2: 'US', 3577 | dialCode: '+1607', 3578 | hasAreaCodes: true, 3579 | isAreaCode: true, 3580 | }, 3581 | { 3582 | name: 'United States', 3583 | regions: ['america', 'north-america'], 3584 | iso2: 'US', 3585 | dialCode: '+1631', 3586 | hasAreaCodes: true, 3587 | isAreaCode: true, 3588 | }, 3589 | { 3590 | name: 'United States', 3591 | regions: ['america', 'north-america'], 3592 | iso2: 'US', 3593 | dialCode: '+1716', 3594 | hasAreaCodes: true, 3595 | isAreaCode: true, 3596 | }, 3597 | { 3598 | name: 'United States', 3599 | regions: ['america', 'north-america'], 3600 | iso2: 'US', 3601 | dialCode: '+1718', 3602 | hasAreaCodes: true, 3603 | isAreaCode: true, 3604 | }, 3605 | { 3606 | name: 'United States', 3607 | regions: ['america', 'north-america'], 3608 | iso2: 'US', 3609 | dialCode: '+1845', 3610 | hasAreaCodes: true, 3611 | isAreaCode: true, 3612 | }, 3613 | { 3614 | name: 'United States', 3615 | regions: ['america', 'north-america'], 3616 | iso2: 'US', 3617 | dialCode: '+1914', 3618 | hasAreaCodes: true, 3619 | isAreaCode: true, 3620 | }, 3621 | { 3622 | name: 'United States', 3623 | regions: ['america', 'north-america'], 3624 | iso2: 'US', 3625 | dialCode: '+1216', 3626 | hasAreaCodes: true, 3627 | isAreaCode: true, 3628 | }, 3629 | { 3630 | name: 'United States', 3631 | regions: ['america', 'north-america'], 3632 | iso2: 'US', 3633 | dialCode: '+1330', 3634 | hasAreaCodes: true, 3635 | isAreaCode: true, 3636 | }, 3637 | { 3638 | name: 'United States', 3639 | regions: ['america', 'north-america'], 3640 | iso2: 'US', 3641 | dialCode: '+1419', 3642 | hasAreaCodes: true, 3643 | isAreaCode: true, 3644 | }, 3645 | { 3646 | name: 'United States', 3647 | regions: ['america', 'north-america'], 3648 | iso2: 'US', 3649 | dialCode: '+1440', 3650 | hasAreaCodes: true, 3651 | isAreaCode: true, 3652 | }, 3653 | { 3654 | name: 'United States', 3655 | regions: ['america', 'north-america'], 3656 | iso2: 'US', 3657 | dialCode: '+1513', 3658 | hasAreaCodes: true, 3659 | isAreaCode: true, 3660 | }, 3661 | { 3662 | name: 'United States', 3663 | regions: ['america', 'north-america'], 3664 | iso2: 'US', 3665 | dialCode: '+1614', 3666 | hasAreaCodes: true, 3667 | isAreaCode: true, 3668 | }, 3669 | { 3670 | name: 'United States', 3671 | regions: ['america', 'north-america'], 3672 | iso2: 'US', 3673 | dialCode: '+1740', 3674 | hasAreaCodes: true, 3675 | isAreaCode: true, 3676 | }, 3677 | { 3678 | name: 'United States', 3679 | regions: ['america', 'north-america'], 3680 | iso2: 'US', 3681 | dialCode: '+1937', 3682 | hasAreaCodes: true, 3683 | isAreaCode: true, 3684 | }, 3685 | { 3686 | name: 'United States', 3687 | regions: ['america', 'north-america'], 3688 | iso2: 'US', 3689 | dialCode: '+1405', 3690 | hasAreaCodes: true, 3691 | isAreaCode: true, 3692 | }, 3693 | { 3694 | name: 'United States', 3695 | regions: ['america', 'north-america'], 3696 | iso2: 'US', 3697 | dialCode: '+1580', 3698 | hasAreaCodes: true, 3699 | isAreaCode: true, 3700 | }, 3701 | { 3702 | name: 'United States', 3703 | regions: ['america', 'north-america'], 3704 | iso2: 'US', 3705 | dialCode: '+1918', 3706 | hasAreaCodes: true, 3707 | isAreaCode: true, 3708 | }, 3709 | { 3710 | name: 'United States', 3711 | regions: ['america', 'north-america'], 3712 | iso2: 'US', 3713 | dialCode: '+1503', 3714 | hasAreaCodes: true, 3715 | isAreaCode: true, 3716 | }, 3717 | { 3718 | name: 'United States', 3719 | regions: ['america', 'north-america'], 3720 | iso2: 'US', 3721 | dialCode: '+1541', 3722 | hasAreaCodes: true, 3723 | isAreaCode: true, 3724 | }, 3725 | { 3726 | name: 'United States', 3727 | regions: ['america', 'north-america'], 3728 | iso2: 'US', 3729 | dialCode: '+1215', 3730 | hasAreaCodes: true, 3731 | isAreaCode: true, 3732 | }, 3733 | { 3734 | name: 'United States', 3735 | regions: ['america', 'north-america'], 3736 | iso2: 'US', 3737 | dialCode: '+1412', 3738 | hasAreaCodes: true, 3739 | isAreaCode: true, 3740 | }, 3741 | { 3742 | name: 'United States', 3743 | regions: ['america', 'north-america'], 3744 | iso2: 'US', 3745 | dialCode: '+1570', 3746 | hasAreaCodes: true, 3747 | isAreaCode: true, 3748 | }, 3749 | { 3750 | name: 'United States', 3751 | regions: ['america', 'north-america'], 3752 | iso2: 'US', 3753 | dialCode: '+1610', 3754 | hasAreaCodes: true, 3755 | isAreaCode: true, 3756 | }, 3757 | { 3758 | name: 'United States', 3759 | regions: ['america', 'north-america'], 3760 | iso2: 'US', 3761 | dialCode: '+1717', 3762 | hasAreaCodes: true, 3763 | isAreaCode: true, 3764 | }, 3765 | { 3766 | name: 'United States', 3767 | regions: ['america', 'north-america'], 3768 | iso2: 'US', 3769 | dialCode: '+1724', 3770 | hasAreaCodes: true, 3771 | isAreaCode: true, 3772 | }, 3773 | { 3774 | name: 'United States', 3775 | regions: ['america', 'north-america'], 3776 | iso2: 'US', 3777 | dialCode: '+1814', 3778 | hasAreaCodes: true, 3779 | isAreaCode: true, 3780 | }, 3781 | { 3782 | name: 'United States', 3783 | regions: ['america', 'north-america'], 3784 | iso2: 'US', 3785 | dialCode: '+1401', 3786 | hasAreaCodes: true, 3787 | isAreaCode: true, 3788 | }, 3789 | { 3790 | name: 'United States', 3791 | regions: ['america', 'north-america'], 3792 | iso2: 'US', 3793 | dialCode: '+1803', 3794 | hasAreaCodes: true, 3795 | isAreaCode: true, 3796 | }, 3797 | { 3798 | name: 'United States', 3799 | regions: ['america', 'north-america'], 3800 | iso2: 'US', 3801 | dialCode: '+1843', 3802 | hasAreaCodes: true, 3803 | isAreaCode: true, 3804 | }, 3805 | { 3806 | name: 'United States', 3807 | regions: ['america', 'north-america'], 3808 | iso2: 'US', 3809 | dialCode: '+1864', 3810 | hasAreaCodes: true, 3811 | isAreaCode: true, 3812 | }, 3813 | { 3814 | name: 'United States', 3815 | regions: ['america', 'north-america'], 3816 | iso2: 'US', 3817 | dialCode: '+1605', 3818 | hasAreaCodes: true, 3819 | isAreaCode: true, 3820 | }, 3821 | { 3822 | name: 'United States', 3823 | regions: ['america', 'north-america'], 3824 | iso2: 'US', 3825 | dialCode: '+1423', 3826 | hasAreaCodes: true, 3827 | isAreaCode: true, 3828 | }, 3829 | { 3830 | name: 'United States', 3831 | regions: ['america', 'north-america'], 3832 | iso2: 'US', 3833 | dialCode: '+1615', 3834 | hasAreaCodes: true, 3835 | isAreaCode: true, 3836 | }, 3837 | { 3838 | name: 'United States', 3839 | regions: ['america', 'north-america'], 3840 | iso2: 'US', 3841 | dialCode: '+1731', 3842 | hasAreaCodes: true, 3843 | isAreaCode: true, 3844 | }, 3845 | { 3846 | name: 'United States', 3847 | regions: ['america', 'north-america'], 3848 | iso2: 'US', 3849 | dialCode: '+1865', 3850 | hasAreaCodes: true, 3851 | isAreaCode: true, 3852 | }, 3853 | { 3854 | name: 'United States', 3855 | regions: ['america', 'north-america'], 3856 | iso2: 'US', 3857 | dialCode: '+1901', 3858 | hasAreaCodes: true, 3859 | isAreaCode: true, 3860 | }, 3861 | { 3862 | name: 'United States', 3863 | regions: ['america', 'north-america'], 3864 | iso2: 'US', 3865 | dialCode: '+1931', 3866 | hasAreaCodes: true, 3867 | isAreaCode: true, 3868 | }, 3869 | { 3870 | name: 'United States', 3871 | regions: ['america', 'north-america'], 3872 | iso2: 'US', 3873 | dialCode: '+1210', 3874 | hasAreaCodes: true, 3875 | isAreaCode: true, 3876 | }, 3877 | { 3878 | name: 'United States', 3879 | regions: ['america', 'north-america'], 3880 | iso2: 'US', 3881 | dialCode: '+1214', 3882 | hasAreaCodes: true, 3883 | isAreaCode: true, 3884 | }, 3885 | { 3886 | name: 'United States', 3887 | regions: ['america', 'north-america'], 3888 | iso2: 'US', 3889 | dialCode: '+1254', 3890 | hasAreaCodes: true, 3891 | isAreaCode: true, 3892 | }, 3893 | { 3894 | name: 'United States', 3895 | regions: ['america', 'north-america'], 3896 | iso2: 'US', 3897 | dialCode: '+1281', 3898 | hasAreaCodes: true, 3899 | isAreaCode: true, 3900 | }, 3901 | { 3902 | name: 'United States', 3903 | regions: ['america', 'north-america'], 3904 | iso2: 'US', 3905 | dialCode: '+1325', 3906 | hasAreaCodes: true, 3907 | isAreaCode: true, 3908 | }, 3909 | { 3910 | name: 'United States', 3911 | regions: ['america', 'north-america'], 3912 | iso2: 'US', 3913 | dialCode: '+1361', 3914 | hasAreaCodes: true, 3915 | isAreaCode: true, 3916 | }, 3917 | { 3918 | name: 'United States', 3919 | regions: ['america', 'north-america'], 3920 | iso2: 'US', 3921 | dialCode: '+1409', 3922 | hasAreaCodes: true, 3923 | isAreaCode: true, 3924 | }, 3925 | { 3926 | name: 'United States', 3927 | regions: ['america', 'north-america'], 3928 | iso2: 'US', 3929 | dialCode: '+1432', 3930 | hasAreaCodes: true, 3931 | isAreaCode: true, 3932 | }, 3933 | { 3934 | name: 'United States', 3935 | regions: ['america', 'north-america'], 3936 | iso2: 'US', 3937 | dialCode: '+1512', 3938 | hasAreaCodes: true, 3939 | isAreaCode: true, 3940 | }, 3941 | { 3942 | name: 'United States', 3943 | regions: ['america', 'north-america'], 3944 | iso2: 'US', 3945 | dialCode: '+1713', 3946 | hasAreaCodes: true, 3947 | isAreaCode: true, 3948 | }, 3949 | { 3950 | name: 'United States', 3951 | regions: ['america', 'north-america'], 3952 | iso2: 'US', 3953 | dialCode: '+1806', 3954 | hasAreaCodes: true, 3955 | isAreaCode: true, 3956 | }, 3957 | { 3958 | name: 'United States', 3959 | regions: ['america', 'north-america'], 3960 | iso2: 'US', 3961 | dialCode: '+1817', 3962 | hasAreaCodes: true, 3963 | isAreaCode: true, 3964 | }, 3965 | { 3966 | name: 'United States', 3967 | regions: ['america', 'north-america'], 3968 | iso2: 'US', 3969 | dialCode: '+1830', 3970 | hasAreaCodes: true, 3971 | isAreaCode: true, 3972 | }, 3973 | { 3974 | name: 'United States', 3975 | regions: ['america', 'north-america'], 3976 | iso2: 'US', 3977 | dialCode: '+1903', 3978 | hasAreaCodes: true, 3979 | isAreaCode: true, 3980 | }, 3981 | { 3982 | name: 'United States', 3983 | regions: ['america', 'north-america'], 3984 | iso2: 'US', 3985 | dialCode: '+1915', 3986 | hasAreaCodes: true, 3987 | isAreaCode: true, 3988 | }, 3989 | { 3990 | name: 'United States', 3991 | regions: ['america', 'north-america'], 3992 | iso2: 'US', 3993 | dialCode: '+1936', 3994 | hasAreaCodes: true, 3995 | isAreaCode: true, 3996 | }, 3997 | { 3998 | name: 'United States', 3999 | regions: ['america', 'north-america'], 4000 | iso2: 'US', 4001 | dialCode: '+1940', 4002 | hasAreaCodes: true, 4003 | isAreaCode: true, 4004 | }, 4005 | { 4006 | name: 'United States', 4007 | regions: ['america', 'north-america'], 4008 | iso2: 'US', 4009 | dialCode: '+1956', 4010 | hasAreaCodes: true, 4011 | isAreaCode: true, 4012 | }, 4013 | { 4014 | name: 'United States', 4015 | regions: ['america', 'north-america'], 4016 | iso2: 'US', 4017 | dialCode: '+1972', 4018 | hasAreaCodes: true, 4019 | isAreaCode: true, 4020 | }, 4021 | { 4022 | name: 'United States', 4023 | regions: ['america', 'north-america'], 4024 | iso2: 'US', 4025 | dialCode: '+1979', 4026 | hasAreaCodes: true, 4027 | isAreaCode: true, 4028 | }, 4029 | { 4030 | name: 'United States', 4031 | regions: ['america', 'north-america'], 4032 | iso2: 'US', 4033 | dialCode: '+1435', 4034 | hasAreaCodes: true, 4035 | isAreaCode: true, 4036 | }, 4037 | { 4038 | name: 'United States', 4039 | regions: ['america', 'north-america'], 4040 | iso2: 'US', 4041 | dialCode: '+1801', 4042 | hasAreaCodes: true, 4043 | isAreaCode: true, 4044 | }, 4045 | { 4046 | name: 'United States', 4047 | regions: ['america', 'north-america'], 4048 | iso2: 'US', 4049 | dialCode: '+1276', 4050 | hasAreaCodes: true, 4051 | isAreaCode: true, 4052 | }, 4053 | { 4054 | name: 'United States', 4055 | regions: ['america', 'north-america'], 4056 | iso2: 'US', 4057 | dialCode: '+1434', 4058 | hasAreaCodes: true, 4059 | isAreaCode: true, 4060 | }, 4061 | { 4062 | name: 'United States', 4063 | regions: ['america', 'north-america'], 4064 | iso2: 'US', 4065 | dialCode: '+1540', 4066 | hasAreaCodes: true, 4067 | isAreaCode: true, 4068 | }, 4069 | { 4070 | name: 'United States', 4071 | regions: ['america', 'north-america'], 4072 | iso2: 'US', 4073 | dialCode: '+1703', 4074 | hasAreaCodes: true, 4075 | isAreaCode: true, 4076 | }, 4077 | { 4078 | name: 'United States', 4079 | regions: ['america', 'north-america'], 4080 | iso2: 'US', 4081 | dialCode: '+1757', 4082 | hasAreaCodes: true, 4083 | isAreaCode: true, 4084 | }, 4085 | { 4086 | name: 'United States', 4087 | regions: ['america', 'north-america'], 4088 | iso2: 'US', 4089 | dialCode: '+1804', 4090 | hasAreaCodes: true, 4091 | isAreaCode: true, 4092 | }, 4093 | { 4094 | name: 'United States', 4095 | regions: ['america', 'north-america'], 4096 | iso2: 'US', 4097 | dialCode: '+1802', 4098 | hasAreaCodes: true, 4099 | isAreaCode: true, 4100 | }, 4101 | { 4102 | name: 'United States', 4103 | regions: ['america', 'north-america'], 4104 | iso2: 'US', 4105 | dialCode: '+1206', 4106 | hasAreaCodes: true, 4107 | isAreaCode: true, 4108 | }, 4109 | { 4110 | name: 'United States', 4111 | regions: ['america', 'north-america'], 4112 | iso2: 'US', 4113 | dialCode: '+1253', 4114 | hasAreaCodes: true, 4115 | isAreaCode: true, 4116 | }, 4117 | { 4118 | name: 'United States', 4119 | regions: ['america', 'north-america'], 4120 | iso2: 'US', 4121 | dialCode: '+1360', 4122 | hasAreaCodes: true, 4123 | isAreaCode: true, 4124 | }, 4125 | { 4126 | name: 'United States', 4127 | regions: ['america', 'north-america'], 4128 | iso2: 'US', 4129 | dialCode: '+1425', 4130 | hasAreaCodes: true, 4131 | isAreaCode: true, 4132 | }, 4133 | { 4134 | name: 'United States', 4135 | regions: ['america', 'north-america'], 4136 | iso2: 'US', 4137 | dialCode: '+1509', 4138 | hasAreaCodes: true, 4139 | isAreaCode: true, 4140 | }, 4141 | { 4142 | name: 'United States', 4143 | regions: ['america', 'north-america'], 4144 | iso2: 'US', 4145 | dialCode: '+1262', 4146 | hasAreaCodes: true, 4147 | isAreaCode: true, 4148 | }, 4149 | { 4150 | name: 'United States', 4151 | regions: ['america', 'north-america'], 4152 | iso2: 'US', 4153 | dialCode: '+1414', 4154 | hasAreaCodes: true, 4155 | isAreaCode: true, 4156 | }, 4157 | { 4158 | name: 'United States', 4159 | regions: ['america', 'north-america'], 4160 | iso2: 'US', 4161 | dialCode: '+1608', 4162 | hasAreaCodes: true, 4163 | isAreaCode: true, 4164 | }, 4165 | { 4166 | name: 'United States', 4167 | regions: ['america', 'north-america'], 4168 | iso2: 'US', 4169 | dialCode: '+1715', 4170 | hasAreaCodes: true, 4171 | isAreaCode: true, 4172 | }, 4173 | { 4174 | name: 'United States', 4175 | regions: ['america', 'north-america'], 4176 | iso2: 'US', 4177 | dialCode: '+1920', 4178 | hasAreaCodes: true, 4179 | isAreaCode: true, 4180 | }, 4181 | { 4182 | name: 'United States', 4183 | regions: ['america', 'north-america'], 4184 | iso2: 'US', 4185 | dialCode: '+1304', 4186 | hasAreaCodes: true, 4187 | isAreaCode: true, 4188 | }, 4189 | { 4190 | name: 'United States', 4191 | regions: ['america', 'north-america'], 4192 | iso2: 'US', 4193 | dialCode: '+1307', 4194 | hasAreaCodes: true, 4195 | isAreaCode: true, 4196 | }, 4197 | { 4198 | name: 'Uruguay', 4199 | regions: ['america', 'south-america'], 4200 | iso2: 'UY', 4201 | dialCode: '+598', 4202 | hasAreaCodes: false, 4203 | isAreaCode: false, 4204 | }, 4205 | { 4206 | name: 'Uzbekistan (Oʻzbekiston)', 4207 | regions: ['asia', 'ex-ussr'], 4208 | iso2: 'UZ', 4209 | dialCode: '+998', 4210 | hasAreaCodes: false, 4211 | isAreaCode: false, 4212 | }, 4213 | { 4214 | name: 'Vanuatu', 4215 | regions: ['oceania'], 4216 | iso2: 'VU', 4217 | dialCode: '+678', 4218 | hasAreaCodes: false, 4219 | isAreaCode: false, 4220 | }, 4221 | { 4222 | name: 'Vatican City (Città del Vaticano)', 4223 | regions: ['europe'], 4224 | iso2: 'VA', 4225 | dialCode: '+39', 4226 | hasAreaCodes: false, 4227 | isAreaCode: false, 4228 | }, 4229 | { 4230 | name: 'Venezuela', 4231 | regions: ['america', 'south-america'], 4232 | iso2: 'VE', 4233 | dialCode: '+58', 4234 | hasAreaCodes: false, 4235 | isAreaCode: false, 4236 | }, 4237 | { 4238 | name: 'Vietnam (Việt Nam)', 4239 | regions: ['asia'], 4240 | iso2: 'VN', 4241 | dialCode: '+84', 4242 | hasAreaCodes: false, 4243 | isAreaCode: false, 4244 | }, 4245 | { 4246 | name: 'Wallis and Futuna', 4247 | regions: ['oceania'], 4248 | iso2: 'WF', 4249 | dialCode: '+681', 4250 | hasAreaCodes: false, 4251 | isAreaCode: false, 4252 | }, 4253 | { 4254 | name: 'Yemen', 4255 | regions: ['middle-east'], 4256 | iso2: 'YE', 4257 | dialCode: '+967', 4258 | hasAreaCodes: false, 4259 | isAreaCode: false, 4260 | }, 4261 | { 4262 | name: 'Zambia', 4263 | regions: ['africa'], 4264 | iso2: 'ZM', 4265 | dialCode: '+260', 4266 | hasAreaCodes: false, 4267 | isAreaCode: false, 4268 | }, 4269 | { 4270 | name: 'Zimbabwe', 4271 | regions: ['africa'], 4272 | iso2: 'ZW', 4273 | dialCode: '+263', 4274 | hasAreaCodes: false, 4275 | isAreaCode: false, 4276 | }, 4277 | ]; 4278 | -------------------------------------------------------------------------------- /src/utils/countries-fn.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, expect, it } from 'vitest'; 2 | import { CountryCode } from 'libphonenumber-js'; 3 | 4 | import { findCountryByCode, getCountryByDialCode, getInitialCountry } from './countries-fn'; 5 | import { allCountries } from './allCountries'; 6 | 7 | describe('findCountryByCode', () => { 8 | describe('when passed iso2 as identifier', () => { 9 | it('should return corresponding country', () => { 10 | expect(findCountryByCode('DE')).toEqual(allCountries[121]); 11 | }); 12 | }); 13 | 14 | describe('when no code is provided', () => { 15 | it('should return undefined', () => { 16 | expect(findCountryByCode()).toBe(undefined); 17 | }); 18 | }); 19 | 20 | describe('when no match is found', () => { 21 | it('should return undefined', () => { 22 | expect(findCountryByCode('notFound' as CountryCode)).toBe(undefined); 23 | }); 24 | }); 25 | }); 26 | 27 | describe('getCountry', () => { 28 | describe('when passed phonenumber starting with +00', () => { 29 | it('should return corresponding country', () => { 30 | expect(getCountryByDialCode('+0049')).toEqual(allCountries[121]); 31 | }); 32 | }); 33 | 34 | describe('when passed phonenumber starting with +', () => { 35 | it('should return corresponding country', () => { 36 | expect(getCountryByDialCode('+49')).toEqual(allCountries[121]); 37 | }); 38 | }); 39 | 40 | describe('when passed phonenumber starting with 00', () => { 41 | it('should return corresponding country', () => { 42 | expect(getCountryByDialCode('0049')).toEqual(allCountries[121]); 43 | }); 44 | }); 45 | 46 | describe('when passed phonenumber starting with 49', () => { 47 | it('should return corresponding country', () => { 48 | expect(getCountryByDialCode('49')).toEqual(allCountries[121]); 49 | }); 50 | }); 51 | }); 52 | 53 | describe('getInitialCountry', () => { 54 | describe('when no data is provided', () => { 55 | it('should return undefined', () => { 56 | expect(getInitialCountry()).toBe(undefined); 57 | }); 58 | }); 59 | 60 | describe('when default country is provided', () => { 61 | it('should return undefined', () => { 62 | expect(getInitialCountry('DE')).toEqual(allCountries[121]); 63 | }); 64 | }); 65 | 66 | describe('when preferred country list is provided', () => { 67 | it('should return undefined', () => { 68 | expect(getInitialCountry(undefined, ['DE', 'CL', 'AR'])).toEqual(allCountries[121]); 69 | }); 70 | }); 71 | }); 72 | -------------------------------------------------------------------------------- /src/utils/countries-fn.ts: -------------------------------------------------------------------------------- 1 | import { CountryCode, parsePhoneNumberFromString } from 'libphonenumber-js'; 2 | 3 | import { ICountry, NumberFormat, Region } from '../types'; 4 | import { allCountries } from './allCountries'; 5 | 6 | export const findCountryByCode = (code?: CountryCode) => allCountries.find((country) => country.iso2 === code); 7 | 8 | export const getCountryByDialCode = (phoneNumber: string) => { 9 | let tel = phoneNumber; 10 | 11 | if (phoneNumber.startsWith('+00')) { 12 | tel = phoneNumber.substring(5, 3); 13 | } else if (phoneNumber.startsWith('+')) { 14 | tel = phoneNumber.substring(6, 1); 15 | } else if (phoneNumber.startsWith('00')) { 16 | tel = phoneNumber.substring(5, 2); 17 | } else { 18 | tel = phoneNumber.substring(5, 0); 19 | } 20 | 21 | return allCountries.find((country) => country.dialCode.startsWith(`+${tel.replace(' ', '')}`)); 22 | }; 23 | 24 | export const getCountriesByRegions = (regions: Region[] | Region): ICountry[] => { 25 | if (typeof regions === 'string') { 26 | return allCountries.filter((country) => country.regions.includes(regions)); 27 | } 28 | 29 | return allCountries.filter((country) => regions.map((region) => country.regions.includes(region)).some((el) => el)); 30 | }; 31 | 32 | export const getInitialCountry = (defaultCountry?: CountryCode, preferredCountries?: CountryCode[], regions?: Region | Region[]) => { 33 | if (defaultCountry) { 34 | return findCountryByCode(defaultCountry); 35 | } 36 | 37 | if (preferredCountries) { 38 | return findCountryByCode(preferredCountries[0]); 39 | } 40 | 41 | if (regions) { 42 | return getCountriesByRegions(regions)[0]; 43 | } 44 | 45 | return undefined; 46 | }; 47 | 48 | export const getCountryList = (preferredCountries?: CountryCode[], regions?: Region | Region[]) => { 49 | if (preferredCountries) { 50 | return preferredCountries.map((prefCountry) => findCountryByCode(prefCountry)); 51 | } 52 | 53 | if (regions) { 54 | return getCountriesByRegions(regions); 55 | } 56 | 57 | return allCountries; 58 | }; 59 | 60 | export const formatNumber = (pohneNumber: string, format: NumberFormat, iso2: CountryCode) => { 61 | let fromatedPhoneNumber = pohneNumber; 62 | 63 | if (format === 'INTERNATIONAL' && pohneNumber.length > 0) { 64 | if (!fromatedPhoneNumber.startsWith('+')) { 65 | fromatedPhoneNumber = `+${fromatedPhoneNumber}`; 66 | } 67 | if (fromatedPhoneNumber.startsWith('+00')) { 68 | fromatedPhoneNumber = fromatedPhoneNumber.replace('00', ''); 69 | } 70 | if (fromatedPhoneNumber.startsWith('00')) { 71 | fromatedPhoneNumber = fromatedPhoneNumber.replace('00', '+'); 72 | } 73 | } 74 | 75 | const parsedPhoneNumber = parsePhoneNumberFromString(fromatedPhoneNumber, iso2); 76 | 77 | try { 78 | fromatedPhoneNumber = parsedPhoneNumber?.format(format) || ''; 79 | } catch (error) { 80 | console.error(error); 81 | fromatedPhoneNumber = fromatedPhoneNumber.replace(/^\s+|(? hasWindowObj && window.navigator.userAgent.match(/Android/i), 7 | BlackBerry: (): DetectMobile => hasWindowObj && window.navigator.userAgent.match(/BlackBerry/i), 8 | iOS: (): DetectMobile => hasWindowObj && window.navigator.userAgent.match(/iPhone|iPad|iPod/i), 9 | Opera: (): DetectMobile => hasWindowObj && window.navigator.userAgent.match(/Opera Mini/i), 10 | Windows: (): DetectMobile => hasWindowObj && window.navigator.userAgent.match(/IEMobile/i), 11 | any: (): DetectMobile => 12 | detectMobile.Android() || detectMobile.BlackBerry() || detectMobile.iOS() || detectMobile.Opera() || detectMobile.Windows(), 13 | }; 14 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './allCountries'; 2 | export * from './countries-fn'; 3 | export * from './detectMobile'; 4 | export * from '../hooks/usePhonenumber'; 5 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "./src", 4 | "paths": { 5 | "*": [ 6 | "*", 7 | ] 8 | }, 9 | "allowJs": true, 10 | "target": "ES2023", 11 | "module": "ESNext", 12 | "useDefineForClassFields": true, 13 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 14 | "types": ["@testing-library/jest-dom"], 15 | "skipLibCheck": true, 16 | "sourceMap": true, 17 | "outDir": "dist", 18 | "declaration": true, 19 | "esModuleInterop": true, 20 | "forceConsistentCasingInFileNames": true, 21 | "resolveJsonModule": true, 22 | "downlevelIteration": true, 23 | 24 | /* Bundler mode */ 25 | "moduleResolution": "bundler", 26 | "isolatedModules": true, 27 | "allowSyntheticDefaultImports": true, 28 | "moduleDetection": "force", 29 | "noEmit": false, 30 | "jsx": "react-jsx", 31 | 32 | /* Linting */ 33 | "strict": true, 34 | "strictNullChecks": true, 35 | "noImplicitAny": true, 36 | "noUnusedLocals": true, 37 | "noUnusedParameters": true, 38 | "noFallthroughCasesInSwitch": true, 39 | "noImplicitReturns": true, 40 | }, 41 | "include": ["src", "*.tsx", "*.ts", "eslint.config.js"], 42 | "exclude": [ 43 | "coverage", 44 | "config", 45 | "dist", 46 | "node_modules/**" 47 | ] 48 | } 49 | -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import svgr from 'vite-plugin-svgr'; 3 | import react from '@vitejs/plugin-react'; 4 | 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [react(), svgr({ include: '**/*.svg' })], 8 | }); 9 | -------------------------------------------------------------------------------- /vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config'; 2 | 3 | export default defineConfig({ 4 | test: { 5 | globals: true, 6 | environment: 'jsdom', 7 | setupFiles: ['./setupTests.ts'], 8 | }, 9 | }); 10 | --------------------------------------------------------------------------------