Giter VIP home page Giter VIP logo

react-native-intl-phone-input's Introduction

React-Native-INTL-Phone-Input

It's an international phone input with phone mask.

USAGE

install npm library

npm install react-native-intl-phone-input

İmport library

import IntlPhoneInput from 'react-native-intl-phone-input';

use component

  onChangeText = ({dialCode, unmaskedPhoneNumber, phoneNumber, isVerified}) => {
    console.log(dialCode, unmaskedPhoneNumber, phoneNumber, isVerified);
  };
  render() {
    return (
      <SafeAreaView>
        <IntlPhoneInput onChangeText={this.onChangeText} defaultCountry="TR" renderAction={() => <Text>XX</Text>} />
      </SafeAreaView>
    );
  }

Custom Modal Example

 renderCustomModal=(modalVisible, countries, onCountryChange) => (
    <Modal visible={modalVisible}>
      <SafeAreaView style={{ flex: 1 }}>
        <View>
          <View>
            <TextInput placeholder="Search" />
            <Text>🔍</Text>
          </View>
          <FlatList
            style={{ flex: 1 }}
            data={countries}
            keyExtractor={(item, index) => index.toString()}
            renderItem={({ item }) => (
              <TouchableWithoutFeedback onPress={() => onCountryChange(item.code)}>
                <Text>{item['your language code here for example tr']}</Text>
              </TouchableWithoutFeedback>
            )}
          />
        </View>
        <TouchableOpacity onPress={() => this.phoneInput.hideModal()}>
          <Text>CLOSE</Text>
        </TouchableOpacity>
      </SafeAreaView>
    </Modal>
  )

  render(){
    return <IntlPhoneInput
        ref={(ref) => this.phoneInput = ref}
        customModal={this.renderCustomModal}
        defaultCountry="TR"
        lang="TR"
      />;
  }

Supported Languages
TR Turkish
LT Lithuanian
EN English
RU Russian
prop names type default value comment
lang String Translate country name on modal
placeholder String This prop change the phone input placeholder
defaultCountry String TR You can change your default country code
mask String You can set custom mask
onChangeText Function This function works when input text is changed
customModal Function Generate your custom modal
phoneInputStyle Style This prop is about the text field's ReactNative.TextInput style
containerStyle Style This prop is about the text field's container style
dialCodeTextStyle Style
flagStyle Style
modalContainer Style This prop is about the modal field's SafeAreaView style.
filterInputStyle Style This prop is about the top of model filter text style
closeButtonStyle Style This prop is about text style of bottom modal
modalCountryItemCountryNameStyle Style
filterText String Filter This is the text of placeholder input of top modal
closeText String CLOSE This prop is about the text of bottom modal
disableCountryChange Bool false This prop is about disable open select country modal
renderAction Function This prop attaching a component right of phone input
placeholderTextColor String black This prop allows you to assign a color to the placeholderText

react-native-intl-phone-input's People

Contributors

abdulgafur24 avatar anasalaqeel avatar anmayorquin avatar kamalpandey avatar muhammedalmaz avatar roka20012 avatar satya5614 avatar sergeypostovoy avatar thingsidoforlove avatar vsavitskiy avatar zl-0627 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-intl-phone-input's Issues

How to change default country

I know that i can change dfault text with using a ref and using onChangeText to set a default value but how can I do the same for setting a default country? I've tried the same approach by calling phoneInputRef.current!.defaultCountry(country) but it isn't getting set.

Please help. Thanks

Error when type country

In filterCountries method need add const { lang } = this.props;
otherwise there will be a mistake

Typescript support

Great work, Is there a declaration.ts file somewhere I can use for this library?

set default value

Hey, is there a prop to set the default value of the input field?

How can i use other <TextInput> props?

I want to use some normal TextInput props functions like onBlur, onFocus, etc. How can i do this, please? I thought the component should inherit all props of the normal TextInput. Please let me know how i can do this. Thanks

country code filter clear

  1. input a country code
  2. select a country in the list
  3. open country code list again
  4. the filter country code will be cleared, and the list will display the last list

MX Mask is wrong

Hello great component, thanks for your work.

MX mask should be '99 9999 9999'

Thanks!

Crashing on Filter List (Fixed)

In filterCountries function please use obj.en.indexOf(value) instead of obj.name.indexOf(value)

filterCountries = (value) => {
const countryData = data.filter((obj) =>
(obj.en.indexOf(value) > -1 || obj.dialCode.indexOf(value) > -1));
this.setState({ countryData });
}

Web compatibility

When using expo and run it in browser, list of country(modal) is shown it should be hidden

Multiple number formats for Indonesia (+62)

It seems there are 2 number formats in Indonesia (+62)

+62 XXX XXXX XXX
+62 XXX XXXX XXXX

But on Countries.js the mask is fixed as
mask: '9999-999-999' so only the first one works.

Is it possible to add multiple masks ?

Add Custom Mask

Because some mask's formats are incorrect, Can you add a prop that provide the developer add custom mask?

Thank you @MuhammedAlmaz

Feature request: `focus` imperative handle

It would be handy to have a focus method on <IntlPhoneInput />

const inputRef = React.useRef();

// focus on mount
React.useEffect(() => {
  inputRef.current.focus();
}, []);

return (
  <IntlPhoneInput
    ref={inputRef}
    ...
  />
);

Phone Input Max Length

Please provide option to add custom phone input max length, since several country has different max length of phone number

How to set default phoneNumber with country from outside.


componentDidMount() {
   this.phoneInput.onChangeText("9841******");
   this.phoneInput.onCountryChange("NP")
}

Here * is actually the number 

<IntlPhoneInput
      ref={ref => { this.phoneInput = ref; }}
      onChangeText={this.onChangeText}
      renderAction={() => null}
/>

ReferenceError: Can't find variable: lang

After installing the package, i attempted to use the component

<IntlPhoneInput
defaultCountry="VC"
lang="EN"
onChangeText={({ dialCode, unmaskedPhoneNumber }) =>
setPhoneNumber(dialCode + unmaskedPhoneNumber)
}
/>

To reproduce the issue:

Install the package
Attempt to change the country's flag by searching for country's name

Error:

ReferenceError: Can't find variable: lang

Start number with 0 and autotrim issue

Hi team, I am using this plugin in my react native application and my requirement is i want to add number with start with 0 like if my Indian number like 99999 99999 then i am try to write 09999 99999 so at final character when i reach 0 should be remove and in textfield allow me to write number 99999 99999. as per current plugin behavior it allows me type like 09999 99999.

User should be allow enter 99999 99999 and 0 should be remove form first place so is there any possibility on this ? how i can achieve this

country name in search is case sensitive

country name in search is case sensitive, which means the user will not found the country if he not using the first letter in uppercase.
it should be not case sensitive.

Passing value from props

How can i pass arbitrary value from outside of the component as for example :

        <IntlPhoneInput
               ref={(ref) => this.phoneInput = ref}
               onChangeText={(props) => model.phone = props.phoneNumber}
               value={model.phone}
               defaultCountry="TR"
               lang="TR"
           />

how long until it relfects to yarn and npm

Hello, sorry if that is a silly question, i would like to know if i submit a PR and you accept it, how long does it take to reflect on yarn or npm? i see a PR accepted that is not reflecting when i run yarn add...

Reference problem

Having multiple different phone numbers like home phone and mobile phone on one page and taking a different reference for each, always results in the second one having undefined value

Make search icon replacable

It should be possible to overwrite the search icon.
Right now it's hardcoded.
<Text style={[styles.searchIconStyle, searchIconStyle]}>🔍</Text>

Path: react-native-intl-phone-input\src\IntlPhoneInput.js

Change placeholderTextColor

According to the docs:
Captura de tela de 2020-08-06 16-09-30

but when i'm trying to set the placeholder text color:

phoneInputStyle={{ fontSize: 16, placeholderTextColor:'rgba(255, 255, 255, 0.8)', color: "#FFF" }}

this happens:
Captura de tela de 2020-08-06 16-08-12

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.