0.3.0 â€ĸ Published 2 years ago

react-native-intl-phone-field v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

🕹ī¸ Demo

It's a javascript-only (no native code) component that can run in iOS, Android, Expo & React Native Web. Below you can gifs of the demo app that showcases the component in action.

Click on the image to see it in a larger size.

👋 Introduction

A simple <TextInput> that validates and formats international phone numbers using Google's library libphonenumber and phonenumber-js. Works with pre-propulated data and displays an emoji flag if country code is derived from the number. Additionally, adds a + sign infront of the number, so it's considered international.

⚙ī¸ Installation

yarn add react-native-intl-phone-field

✂ī¸ Usage

import IntlPhoneField from 'react-native-intl-phone-field';

<IntlPhoneField
  onEndEditing={(result) => console.log(result)}
  onValidation={(isValid) => console.log(isValid)}
  defaultCountry="BG"
  defaultPrefix="+359"
  defaultFlag="🇧đŸ‡Ŧ"
/>

For more detailed example, take a look at the demo app inside example/.

âšĒ Props

PropertyTypeDefaultDescription
flagUndeterminedstring?❓Displayed when country code cannot be derived from current phone number.
onEndEditingfunctionundefinedCallback that is called when text input ends text input ends. It receives result.
onValidationfunctionundefinedCallback that is called each time the validation status changes.
onValueUpdatefunctionundefinedCallback that is called each time the underlying value changes.
defaultCountrystringundefinedTwo letter code for default country, eg. BG
defaultPrefixstringundefinedDefault number prefix, eg. +359
defaultValuestringundefinedDefault value for the TextInput, if you want to pre-populate it.
defaultFlagstringundefinedEmoji for the default flag, eg. 🇧đŸ‡Ŧ
containerStyleobjectundefinedStyles for the component's wrapper <View />
flagContainerStyleobjectundefinedStyles for the flag emoji wrapper <View />
flagTextStyleobjectundefinedStyles for the flag emoji <Text />
textInputStyleobjectundefinedStyles for the underlying <TextInput />
textInputPropsobjectundefinedAdditional props for the underlying <TextInput />

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT