Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-telephone-input

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-telephone-input - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

.publish/bundle.js

2

package.json
{
"name": "react-telephone-input",
"version": "1.2.3",
"version": "1.2.4",
"description": "React component for entering and validating international telephone numbers. Inspired from the awesome jquery plugin for the same - https://github.com/Bluefieldscom/intl-tel-input.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -27,3 +27,9 @@ Reactjs Component for International Telephone Input

- You will need to copy flags.png from example/src folder to see the flag icons for each country.
- Set the flagImagePath using the prop flagImagePath
```
<ReactTelephoneInput defaultCountry='in' flagImagePath='/path/to/images/flags.png'>
```
The default value for flagImagePath is 'flags.png'
## Features

@@ -30,0 +36,0 @@ * Automatically format the number as the user types

@@ -96,2 +96,3 @@ 'use strict';

isValid: isNumberValid,
flagsImagePath: 'flags.png',
onEnterKeyPress: function () {}

@@ -106,2 +107,7 @@ };

},
setFlagPathForFlagCssClass() {
var node = document.createElement('style');
node.innerHTML = `.flag{background:url(${this.props.flagsImagePath})`;
document.body.appendChild(node);
},
componentDidMount() {

@@ -111,3 +117,3 @@ document.addEventListener('keydown', this.handleKeydown);

this._cursorToEnd();
this.setFlagPathForFlagCssClass();
if(typeof this.props.onChange === 'function') {

@@ -243,3 +249,2 @@ this.props.onChange(this.state.formattedNumber);

handleInput(event) {
var formattedNumber = '+', newSelectedCountry = this.state.selectedCountry, freezeSelection = this.state.freezeSelection;

@@ -304,16 +309,21 @@

var nextSelectedCountry = findWhere(this.props.onlyCountries, country);
var newNumber = this.state.formattedNumber.replace(currentSelectedCountry.dialCode, nextSelectedCountry.dialCode);
var formattedNumber = this.formatNumber(newNumber.replace(/\D/g, ''), nextSelectedCountry.format);
this.setState({
showDropDown: false,
selectedCountry: nextSelectedCountry,
freezeSelection: true,
formattedNumber: formattedNumber
}, function() {
this._cursorToEnd();
if(this.props.onChange) {
this.props.onChange(formattedNumber);
}
});
// tiny optimization
if(currentSelectedCountry.iso2 !== nextSelectedCountry.iso2) {
// TODO - the below replacement is a bug. It will replace stuff from middle too
var newNumber = this.state.formattedNumber.replace(currentSelectedCountry.dialCode, nextSelectedCountry.dialCode);
var formattedNumber = this.formatNumber(newNumber.replace(/\D/g, ''), nextSelectedCountry.format);
this.setState({
showDropDown: false,
selectedCountry: nextSelectedCountry,
freezeSelection: true,
formattedNumber: formattedNumber
}, function() {
this._cursorToEnd();
if(this.props.onChange) {
this.props.onChange(formattedNumber);
}
});
}
},

@@ -326,14 +336,2 @@ handleInputFocus() {

},
_findIndexOfCountry(allTheCountries, countryToFind, startIndex) {
if(!startIndex) {
startIndex = 0;
}
for(var i = startIndex; i < allTheCountries.length; i++) {
if(allTheCountries[i].iso2 === countryToFind.iso2) {
return i;
}
}
return -1;
},
_getHighlightCountryIndex(direction) {

@@ -362,4 +360,4 @@ // had to write own function because underscore does not have findIndex. lodash has it

searchCountry() {
var probableCandidate = this._searchCountry(this.state.queryString) || this.props.onlyCountries[0];
var probableCandidateIndex = findIndex(this.props.onlyCountries, probableCandidate) + this.state.preferredCountries.length;
const probableCandidate = this._searchCountry(this.state.queryString) || this.props.onlyCountries[0];
const probableCandidateIndex = findIndex(this.props.onlyCountries, probableCandidate) + this.state.preferredCountries.length;

@@ -418,20 +416,13 @@ this.scrollTo(this.getElement(probableCandidateIndex), true);

},
handleBlur() {
this.setState({
showDropDown: false
});
},
handleClickOutside() {
if(this.state.showDropDown) {
this.handleBlur();
this.setState({
showDropDown: false
});
}
},
getCountryDropDownList() {
var dropDownClasses = classNames({
'country-list': true,
'hide': !this.state.showDropDown
});
var countryDropDownList = map(this.state.preferredCountries.concat(this.props.onlyCountries), function(country, index) {
var itemClasses = classNames({
var countryDropDownList = map([this.state.preferredCountries, ...this.props.onlyCountries], function(country, index) {
let itemClasses = classNames({
country: true,

@@ -459,6 +450,10 @@ preferred: country.iso2 === 'us' || country.iso2 === 'gb',

var dashedLi = (<li key={"dashes"} className="divider" />);
const dashedLi = (<li key={"dashes"} className="divider" />);
// let's insert a dashed line in between preffered countries and the rest
countryDropDownList.splice(this.state.preferredCountries.length, 0, dashedLi);
const dropDownClasses = classNames({
'country-list': true,
'hide': !this.state.showDropDown
});
return (

@@ -465,0 +460,0 @@ <ul ref="flagDropdownList" className={dropDownClasses}>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc