react-intl-phone-input
Advanced tools
Comparing version 4.6.0 to 4.6.1
{ | ||
"name": "react-intl-phone-input", | ||
"version": "4.6.0", | ||
"version": "4.6.1", | ||
"description": "Telephone input component. Rewrite intl-tel-input in React.js.", | ||
@@ -5,0 +5,0 @@ "author": "patw", |
@@ -143,7 +143,3 @@ import React, { Component } from 'react'; | ||
// set the initial state of the input value and the selected flag | ||
this.setInitialState(() => { | ||
if (window.intlTelInputUtils && this.props.autoPlaceholder && this.selectedCountryData) { | ||
this.setPlaceholderAndMask(); | ||
} | ||
}); | ||
this.setInitialState(); | ||
// utils script, and auto country | ||
@@ -157,5 +153,2 @@ this.initRequests(); | ||
this.setInitialState(); | ||
if (window.intlTelInputUtils && this.props.autoPlaceholder && this.selectedCountryData) { | ||
this.setPlaceholderAndMask(); | ||
} | ||
}); | ||
@@ -238,20 +231,2 @@ | ||
setPlaceholderAndMask = () => { | ||
const numberType = window.intlTelInputUtils.numberType[this.props.numberType]; | ||
let placeholder = this.selectedCountryData.iso2 ? | ||
window.intlTelInputUtils.getExampleNumber(this.selectedCountryData.iso2, | ||
this.nationalMode, numberType) : ''; | ||
placeholder = this.beforeSetNumber(placeholder); | ||
if (typeof this.props.customPlaceholder === 'function') { | ||
placeholder = this.props.customPlaceholder(placeholder, this.selectedCountryData); | ||
} | ||
this.setState({ | ||
placeholder, | ||
mask: placeholder && placeholder.replace(/[0-9]/g, '9'), | ||
}); | ||
} | ||
// select the given flag, update the placeholder and the active list item | ||
@@ -490,3 +465,3 @@ // Note: called from setInitialState, updateFlagFromNumber, selectListItem, setCountry | ||
// set the initial state of the input value and the selected flag | ||
setInitialState(callback = () => {}) { | ||
setInitialState() { | ||
const val = this.props.value || this.props.defaultValue || ''; | ||
@@ -497,3 +472,2 @@ | ||
this.updateFlagFromNumber(val, true); | ||
callback(); | ||
} else if (this.tempCountry !== 'auto') { | ||
@@ -516,3 +490,3 @@ // see if we should select a flag | ||
value: `+${this.selectedCountryData.dialCode}`, | ||
}, callback); | ||
}); | ||
} | ||
@@ -828,3 +802,17 @@ } | ||
} else if (window.intlTelInputUtils && this.props.autoPlaceholder && this.selectedCountryData) { | ||
this.setPlaceholderAndMask(); | ||
const numberType = window.intlTelInputUtils.numberType[this.props.numberType]; | ||
let placeholder = this.selectedCountryData.iso2 ? | ||
window.intlTelInputUtils.getExampleNumber(this.selectedCountryData.iso2, | ||
this.nationalMode, numberType) : ''; | ||
placeholder = this.beforeSetNumber(placeholder); | ||
if (typeof this.props.customPlaceholder === 'function') { | ||
placeholder = this.props.customPlaceholder(placeholder, this.selectedCountryData); | ||
} | ||
this.setState({ | ||
placeholder, | ||
mask: placeholder && placeholder.replace(/[0-9]/g, '9'), | ||
}); | ||
} | ||
@@ -831,0 +819,0 @@ } |
@@ -8,3 +8,3 @@ import React, { Component } from 'react'; | ||
/* const loadJSONP = (url, callback) => { | ||
const loadJSONP = (url, callback) => { | ||
const ref = window.document.getElementsByTagName('script')[0]; | ||
@@ -18,6 +18,6 @@ const script = window.document.createElement('script'); | ||
}; | ||
}; */ | ||
}; | ||
/* const lookup = (callback) => { | ||
loadJSONP('//ipinfo.io', 'sendBack'); | ||
const lookup = (callback) => { | ||
loadJSONP('http://ipinfo.io', 'sendBack'); | ||
window.sendBack = (resp) => { | ||
@@ -28,3 +28,3 @@ const countryCode = (resp && resp.country) ? resp.country : ''; | ||
}; | ||
}; */ | ||
}; | ||
@@ -81,5 +81,5 @@ function log(...args) { | ||
onSelectFlag={ this.selectFlagHandler1 } | ||
defaultCountry="auto" | ||
defaultCountry={ 'auto' } | ||
value={ this.state.phone1 } | ||
// geoIpLookup={ lookup } | ||
geoIpLookup={ lookup } | ||
hideDialCode | ||
@@ -86,0 +86,0 @@ separateDialCode |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1661353
8866