catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
https://catamphetamine.gitlab.io/libphonenumber-js/
MIT License
2.76k stars 218 forks source link

Get countryCode, countryName, countryFlag object #441

Closed ankit-gl closed 1 year ago

ankit-gl commented 1 year ago

I want to develop custom country picker for input field and wanted to list the countries with their name, flag and country code. Could not find a way to get these data.

getCountries on returns countryCode, but wanted the name and flag too.

catamphetamine commented 1 year ago

There're no names or flags in this repo.

Flags could be looked up in country-flag-icons.

Names could be read from react-phone-number-input.

bryanltobing commented 6 months ago

i'm using react-native so using react-phone-number-input that is based on html and css is not an option. is it possible to export only the utils to get the value.

i'm thinking creating something like getCountryCallingCode(countryCode)

maybe

is this make sense to be implemented in this library? wdyt

edit:

import { getCountries} from 'libphonenumber-js'; import getUnicodeFlagIcon from 'country-flag-icons/unicode';

getCountries.map((countryCode) => { return getUnicodeFlagIcon(countryCode) // 🇺🇸 if US })

catamphetamine commented 6 months ago

You haven’t read any pf the readmes. How’re you even in the profession. I’ll block you. Also, there is a React Native component in reach-phone-number-input.

On Wed, 7 Feb 2024 at 10:33, Bryan Lumbantobing @.***> wrote:

i'm using react-native so using react-phone-number-input that is based on html and css is not an option. is it possible to export only the utils to get the value.

i'm thinking creating something like getCountryCallingCode(countryCode)

maybe

  • getCountryName(countryCode)
  • getCountryFlag(countryCode)

— Reply to this email directly, view it on GitHub https://github.com/catamphetamine/libphonenumber-js/issues/441#issuecomment-1931442552, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADUP36LQGKLBNX4IV3FMPLYSMU3VAVCNFSM6AAAAAAXCZDJ5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZRGQ2DENJVGI . You are receiving this because you modified the open/close state.Message ID: @.***>

bryanltobing commented 6 months ago

Thanks