1.1.2 • Published 2 years ago

@alisson-amaral/material-ui-phone-number-text-field v1.1.2

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

material-ui-phone-number-text-field

Highly customizable phone input component with auto formatting. Based on the wonderful react-phone-input-2 package.

It looks like this, but in Material Design:

alt tag

Uses @mui/material/TextField for rendering the phone input

Installation

npm install @alisson-amaral/material-ui-phone-number-text-field --save

Usage

import MaterialUiPhoneNumberTextField from '@alisson-amaral/material-ui-phone-number-text-field';

React.render(
  <MaterialUiPhoneNumberTextField defaultCountry={'us'} onChange={handleOnChange}/>,
  document.getElementById('root')
);

Your handler for the onChange event should expect a string as parameter, where the value is that of the entered phone number. For example:

function handleOnChange(value) {
   this.setState({
      phone: value
   });
}

Options

Localization

  <MaterialUiPhoneNumberTextField
    onlyCountries={['de', 'es']}
    localization={{'Germany': 'Deutschland', 'Spain': 'España'}}
  />

You can check the current supported countries over here

If the country that you want does not have on the default country list, you can also use your own custom list

Example

    <MaterialUiPhoneNumberTextField
      defaultCountry="ar"
      label="Phone number"
      countryList={customList}
    />

Country List example

export default [
  {
    iso2: 'al',
    dialCode: '355',
    format: '+... .........',
    name: 'Albania'
  },
  {
    iso2: "ar",
    dialCode: "54",
    format: "+.. (..) ........",
    name: "Argentina"
  },
  {
    iso2: "au",
    dialCode: "61",
    format: "+.. ... ... ...",
    name: "Australia",
  }
]

Supported events

Country data object not returns from onKeyDown event

License

Based on material-ui-phone-number

Based on react-phone-input-2

Based on react-phone-input using MIT

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago