Skip to content

Commit

Permalink
feat(countries): Added missing countries from ISO 3166 #3894 (#3899)
Browse files Browse the repository at this point in the history
The reasoning for adding these countries is that they are required for
compliance reasons for application in some of DNBs solutions.

The country list in Eufemia serves two purposes in letting users select
countries and letting users select the dialing code for a country.
The country codes missing from ISO 3166 are mostly for external
territories of other states.
The dialing code for some of them are certain, and are contained in the
wikipedia page the country list was based on earlier.
For others the dialing code is not certain, and most likely they do not
have a dialing code. These countries are mostly research bases, or
otherwise not permanently inhabited.

The likelyhood of any of these countries actually being used is probably
very small.

In the event that someone should want to use a number from one of the
uncertain dialing codes, they will most likely identify that the dialing
code is wrong. As far as I can tell each of these countries belong to a
group of islands or a territory that they share a dialing code with, and
we can probably assume that the users of these dialing codes knows which
other country to look for in the list.

Added the following countries:
- AX	Åland Islands - Shared dialing code with Finland
- BV Bouvet Island - Most likely no dialing code, uses the dialing code
of Norway
- TF French Southern Territories - Most likely no dialing code, uses the
dialing code of Mayoette and Reunion
- HM Heard Island and McDonald Islands - Same dialing code as Australian
External Territories
- MQ	Martinique
- NF Norfolk Island - Same dialing code as Australian External
Territories
- GS South Georgia and the South Sandwich Islands - Same dialing code as
Falkland Islands
- UM United States Minor Outlying Islands - Most likely no dialing code,
uses the dialing code of USA
- BQ	Bonaire, Sint Eustatius and Saba
  • Loading branch information
andlbrei authored Sep 5, 2024
2 parents e5e54c3 + 2992084 commit ada0e92
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ describe('Field.PhoneNumber', () => {
keyCode: 13,
})

expect(europe).toHaveLength(51)
expect(europe).toHaveLength(52)
})

it('should return correct value onChange event', async () => {
Expand Down
87 changes: 86 additions & 1 deletion packages/dnb-eufemia/src/extensions/forms/constants/countries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/**
* Source: Wikipedia's official list of phone number country codes
* Sources:
* - https://en.wikipedia.org/wiki/List_of_country_calling_codes
* - https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
* - https://www.itu.int/rec/T-REC-E.164/en#:~:text=The%20international%20public%20telecommunication%20numbering%20plan
*
* cdc: Country Dialing Code
*/
Expand All @@ -19,6 +22,7 @@ export type CountryType = {
| 'Antarctica'
| 'North America'
| 'South America'
| 'None'
regions?: Array<'Scandinavia' | 'Nordic'>
}

Expand Down Expand Up @@ -284,6 +288,15 @@ const countries: Array<CountryType> = [
iso: 'BW',
continent: 'Africa',
},
{
i18n: {
en: 'Bouvet Island',
nb: 'Bouvetøya',
},
cdc: '47', // Uncertain, low to no population on these islands
iso: 'BV',
continent: 'Antarctica',
},
{
i18n: {
en: 'Brazil',
Expand Down Expand Up @@ -383,6 +396,15 @@ const countries: Array<CountryType> = [
iso: 'CV',
continent: 'Africa',
},
{
i18n: {
en: 'Bonaire, Saint Eustatius and Saba',
nb: 'Bonaire, Saint Eustatius og Saba',
},
cdc: '599',
iso: 'BQ',
continent: 'South America',
},
{
i18n: {
en: 'Cayman Islands',
Expand Down Expand Up @@ -719,6 +741,15 @@ const countries: Array<CountryType> = [
iso: 'PF',
continent: 'Oceania',
},
{
i18n: {
en: 'French Southern and Antarctic Lands',
nb: 'De franske sørterritorier',
},
cdc: '262', // Uncertain, low to no population on these islands
iso: 'TF',
continent: 'Africa',
},
{
i18n: {
en: 'Gabon',
Expand Down Expand Up @@ -873,6 +904,15 @@ const countries: Array<CountryType> = [
iso: 'HT',
continent: 'North America',
},
{
i18n: {
en: 'Heard Island and McDonald Islands',
nb: 'Heard- og McDonaldøyene',
},
cdc: '672',
iso: 'HM',
continent: 'Antarctica',
},
{
i18n: {
en: 'Honduras',
Expand Down Expand Up @@ -1243,6 +1283,15 @@ const countries: Array<CountryType> = [
iso: 'MH',
continent: 'Oceania',
},
{
i18n: {
en: 'Martinique',
nb: 'Martinique',
},
cdc: '596',
iso: 'MH',
continent: 'South America',
},
{
i18n: {
en: 'Mauritania',
Expand Down Expand Up @@ -1459,6 +1508,15 @@ const countries: Array<CountryType> = [
iso: 'NU',
continent: 'Oceania',
},
{
i18n: {
en: 'Norfolk Island',
nb: 'Norfolkøya',
},
cdc: '672',
iso: 'NF',
continent: 'Oceania',
},
{
i18n: {
en: 'North Korea',
Expand Down Expand Up @@ -1856,6 +1914,15 @@ const countries: Array<CountryType> = [
iso: 'ZA',
continent: 'Africa',
},
{
i18n: {
en: 'South Georgia and the South Sandwich Islands',
nb: 'Sør-Georgia og Sør-Sandwichøyene',
},
cdc: '500',
iso: 'GS',
continent: 'None',
},
{
i18n: {
en: 'South Korea',
Expand Down Expand Up @@ -2127,6 +2194,15 @@ const countries: Array<CountryType> = [
iso: 'US',
continent: 'North America',
},
{
i18n: {
en: 'United States Minor Outlying Islands',
nb: 'USAs ytre småøyer',
},
cdc: '1', // Uncertain, low to no population on these islands
iso: 'UM',
continent: 'None',
},
{
i18n: {
en: 'Uruguay',
Expand Down Expand Up @@ -2226,6 +2302,15 @@ const countries: Array<CountryType> = [
iso: 'ZW',
continent: 'Africa',
},
{
i18n: {
en: 'Åland Islands',
nb: 'Åland',
},
cdc: '358',
iso: 'AX',
continent: 'Europe',
},
]

export default countries

0 comments on commit ada0e92

Please sign in to comment.