-
Added a validation console error message when an incorrect
valueis supplied: when supplied,valuemust be inE.164format (no punctuation). -
Fixed the demo page having an old copy of
libphonenumber-js.
- In response to a recently reported issue, changed the behavior of the "With Country Select" input in cases when the calling code corresponds to multiple possible countries (for example,
+1calling code corresponds to bothUSandCA): now it will prefer showing the country flag that was selected manually by the user, or the default country flag.
- Migrated to "ES Module" exports.
- Fixed erasing
react-hook-formcomponent's value.
- Fixed TypeScript "typings".
- Fixed formatting incomplete phone numbers having less than 3 leading digits.
-
Added TypeScript "typings".
-
The
/core"with country select" component now doesn't require acountrySelectComponentproperty because it now has a default value.
- Added
inputComponentproperty on a React Native "without country select" component.
- Fixed a small bug in a "without country select" input: when setting a
countrythat doesn't correspond to the currentvalueproperty it now changes thevalueproperty accordingly.
- Fixed React Native
{...rest}props passthrough.
- Fixed
addInternationalOption={false}React warning.
- Added
react-hook-form@7support.
- Fixed a minor small bug when
defaultCountryis selected as the country even when the initialvaluecouldn't possibly belong to that country.
- Added
react-hook-formcomponents.
- Fixed determining the
countryfor a very incompletevaluewhenvalueis set externally.
- Fixed entering phone number digits in "force international" mode when the prefix is selected.
-
Fixed "International" option not being added.
-
Added
"🌐"("International") option tocountryOptionsOrder.
- Fixed the ability to erase country calling code when
countryCallingCodeEditable={false}.
-
displayInitialValueAsLocalNumber={true}property is deprecated: it has been replaced withinitialValueFormat="national"property. The old property still works in version3.x. -
Added
countryCallingCodeEditable={false}property on a "with country select" component: wheninternationalistrue, then, by default, the "country calling code" part of a phone number is editable. PassingcountryCallingCodeEditable={false}property makes it non-editable.
-
Added
focusInputOnCountrySelection: booleanproperty. If set tofalse, will not focus the<input/>component when the user selects a country from the list of countries. This can be used to conform to the Web Content Accessibility Guidelines (WCAG). Quote: "On input: Changing the setting of any user interface component does not automatically cause a change of context unless the user has been advised of the behaviour before using the component". -
Added
international: falseproperty that doesn't allow international phone number format during input. Some hypothetical people could hypothetically already be passing something likeinternational={condition ? true : false}in their apps, meaning that this new version's behavior regardinginternational={false}could potentially come as a surprise for them, but that would be an indefinitely small minority, and it wouldn't strictly speaking break their apps because users would still be able to input their phone number.
-
Added
withCountryCallingCodeproperty on the/inputcomponent: whencountryis set andinternationalistrueandwithCountryCallingCodeistruethen the "country calling code" part of the phone number will be included in the<input/>field. -
Added an experimental React Native exported component (see the README).
-
"With country select" component in "force international mode" now appends "leading digits" for some countries when pre-populating the initial phone number prefix.
- Fixed a bug when resetting
defaultCountryproperty of a "with country select" component produced an error.
-
Removed
--PhoneInputCountryFlag-widthCSS variable. -
Added
--PhoneInputCountryFlag-aspectRatioCSS variable.
Relevant changes:
-
The component uses hooks now, so
react >= 16.8is required. -
refis now forwarded to the<input/>. -
style.cssnow uses native CSS variables. Native CSS variables work in all modern browsers, but older ones like Internet Explorer won't support them. For compatibility with such older browsers one can use a CSS transformer like PostCSS with a "CSS custom properties" plugin likepostcss-custom-properties. -
Renamed CSS classes, and refactored styles.
-
Changed the flags: now they're simpler, smaller in disk size, and have
3x2aspect ratio instead of4x3. -
Renamed CDN
bundlefiles:
react-phone-number-input-native->react-phone-number-input.react-phone-number-input-native-max->react-phone-number-input-max.react-phone-number-input-native-mobile->react-phone-number-input-mobile.react-phone-number-input-no-country-select->react-phone-number-input-input.- Removed
-react-responsive-uiand-smart-inputversions from CDNbundle.
-
CDN
bundleexported global variable is now calledwindow.PhoneInput.default(used to be calledwindow['react-phone-number-input']), and utility functions are accessible viawindow.PhoneInputvariable. -
Removed
locale/default.json(useen.jsoninstead) andlocale/br.json(usept.jsoninstead). -
Flags are now loaded from
country-flag-iconslibrary. -
Removed properties:
errordisablePhoneInputinputClassName(usenumberInputPropsinstead)countrySelectTabIndexandcountrySelectAriaLabel(usecountrySelectPropsinstead)showCountrySelect(use/inputsubpackage instead to render a component without country select).ext(this component now doesn't deal with phone number extensions at all).
-
Removed the former
inputComponentproperty, and renamednumberInputComponentproperty toinputComponent. -
Renamed properties:
international->addInternationalOptioncountryOptions->countryOptionsOrdercountry->defaultCountry
- Renamed
flagsPathproperty toflagUrl, and it's now a full URL template having{XX}in place of a country code in upper case or{xx}in place of a country code in lower case.
Other changes (miscellaneous):
-
Replaced
webpackwithrollupwhen generating CDN bundles. -
Removed
/libphonenumber,/native,/custom,/native-custom,/react-responsive-ui,/react-responsive-ui/custom,/basic-input,/basic-input-custom,/international-iconexports. -
Removed
parseRFC3966()andformatRFC3966()exported functions. -
Country select doesn't receive
iconproperty as part ofoptionsnow. Instead, it receivesiconComponentproperty, whereiconComponentreceives acountryproperty (for example,"US"). -
Removed
redux-formonBlurworkaround.redux-formis deprecated. -
internationalIconis now 4x3, like the rest of the flags (used to be square). -
Flags have been copied from
flag-icon-cssrepo's github pages to this repo's github pages. -
Added
unicodeFlagsproperty of country select (the demo page has a showcase).
- Added
inputStyleReset: booleanproperty that can be set totrueto prevent the library from applying decoration styles to the<input/>.
-
Temporarily reverted back to "smart input" instead of the "basic input" (with the
smartCaretproperty now beingtrueby default). The reason is that I've added a potential workaround for Android devices toinput-formatlibrary ("smart caret" implementation). We'll see if anyone reports anything. There have been some minor complaints about "basic caret" not being "smart" enough by always jumping to the end of the input field. -
Added
isPossiblePhoneNumber(string): booleanexported function: it checks if the phone number is "possible". Only checks the phone number length, doesn't check the number digits against any regular expressions likeisValidPhoneNumber()does. -
Added
getCountries(): string[]exported function (returns an array of all possible country codes). -
Added
international={true}property to "without country select" input. Ifcountryproperty is passed along withinternational={true}property then the phone input will be input in "international" format for thatcountry(without "country calling code"). For example, ifcountry="US"property is passed to "without country select" input then the phone number will be input in the "national" format forUS((213) 373-4253). But if bothcountry="US"andinternational={true}properties are passed then the phone number will be input in the "international" format forUS(213 373 4253) (without "country calling code"+1). This -
Added
defaultCountry: stringanduseNationalFormatForDefaultCountryValue: booleanproperties to "without country select" input. -
Added
smartCaretproperty to "without country select" input. It's the same one as thesmartCaretproperty of the default ("with country select") phone number input. That also means that "without country select" input now defaults to "smart caret" mode rather than "basic caret" mode. -
Added
countryCallingCodeproperty to "without country select" input. Whencountryproperty is passed along withinternational={true}property then by default the phone number will be input in the "international" format forUS(+1 213 373 4253). However, ifcountryCallingCode={false}property is passed then the country calling code part (+1) will be omitted, and the phone number will be input in the "international" format forUSwithout "country calling code" (213 373 4253). -
Removed
redux-formonBlur bug workaround from the recently introduced "without country select" component. If there're anyredux-formbugs then the new versions of this library won't be fixing them.redux-formhas been deprecated for a long time. -
Added
reset: anyproperty that resetsvalueandcountrywhenever it's changed. It's not implemented as some instance.reset()method becauserefwill likely be forwarded to<input/>.
-
The previous "patch" version bump that added
numberInputComponentproperty should actually have been a "feature" version bump, so bumping "feature" version now. -
The country is now reset in cases when a user erases a phone number that has been input in international format. This fixes the cases when a user tries to input their local phone number when no country has been selected and ends up with an international phone number and a randomly selected country. Then such user erases the
<input/>contents and tries inputting their local phone number again (now with the random country being selected) — this results in a seemingly-correct phone number but the reality is that the country of the phone number is completely unrelated (random). The change in this release fixes that: when a user erases all digits of an international number the random-selected country is reset. -
Added
numberInputPropsandcountrySelectProps. If a custominputComponentproperty has been specified then this newnumberInputPropsproperty might result in an"Unknown prop "inputProps" on <input> tag"React warning because this newnumberInputPropsproperty is most likely passed as{...rest}to the underlying<input/>. But such warning isn't considered a "breaking change", and it's unlikely that anyone actually passed their owninputComponentdue to the complexity. -
Added an
/inputsubpackage that exports the "Without country select" phone number input component. The previously proposed/basic-inputsubpackage is now deprecated. -
Added
prevInputargument toparseInput()function ofinput-control.js. It's unlikely that anyone used it directly asimport { parseInput } from 'react-phone-number-input/commonjs/input-control'. But if anyone did then such code would break because the function's arguments changed. -
(misc) Removed the unintuitive "magic" phone number digits conversion logic when a phone number in international format has been input and then the user decides to select another country: previously it replaced the "country calling code" of the previous country with the "country calling code" of the new country keeping the international format of the phone number. It has been noticed that selecting a country manually having an international phone number already typed in most likely corresponds to the cases when the user tried typing in a local phone number with no country selected resulting in an international number being input and a random country being selected. Then such user decides to select the correct country manually and expects his input to be corrected back to "local" format. See the original issue.
- Added
numberInputComponentproperty which is supposed to replaceinputComponentproperty for the end users: it turned out that passing custominputComponentrequired also implementing (copy-pasting) phone number parsing and formatting logic. The newnumberInputComponentcustomization property is different in this aspect: it's a customization property ofinputComponentitself. By defaultnumberInputComponentis"input"meaning thatinputComponentrenders a standard DOM<input/>by default. By passing a customnumberInputComponentthis standard DOM<input/>can be replaced by such custom number input component (for example, when using UI libraries like "Material UI" or "Bootstrap"). The formerinputComponentproperty still works, it's just now an undocumented one (too complex for the end users to implement). And it now also receives a newinputComponentproperty that is basically the newnumberInputComponentproperty, just with a shorter name — this new property might result in an"Unknown prop "inputComponent" on <input> tag"React warning, but that's only in the cases when a custominputComponentwas passed earlier which is unlikely (it's unlikely that anyone actually passed their owninputComponent).
-
Added
countrySelectAriaLabel: stringproperty. -
Added
getCountryCallingCode(country: string): stringexported function.
-
Added an exported
parsePhoneNumber(value)function because some people requested a function to getcountryfromvalue. -
Added
parseRFC3966()andformatRFC3966()exports (phone number extensions).
-
Changed the "International" flag icon.
-
Fixed
react-phone-number-input/flagsimport.
-
Recently I removed some of the countries from the list of selectable countries because they weren't supported by Google's
libphonenumber: previously I didn't check if all the selectable countries were supported (for some reason) so the list of countries contained some countries which weren't supported bylibphonenumberwhich in turn would result in incorrect phone number parsing/formatting (countries like Abkhazia and South Osetia, for example). -
I also added Kosovo to the list. It's not a country but a "territory" instead. I imagine people from Kosovo might be looking for "Kosovo" in the list and they'd be confused if it was missing. Google supports
XKterritory code and the flag forXKhas been recently added to the flags repo. Anyone using customflagsPathshould update their flag bundles accordingly. -
Also added
TAandACcountries to the list but they're usingSHflag for now, so no need to update flags for them yet. If the author of the flags repo adds the flags forTAandACthen the flags will have to be updated. See the issue in the flags repo for more info. -
Also note that when supplying custom
flagsPaththose custom-hosted flags might go out of sync with the list of countries. For example, there could be people hosting their own copy of flags, and thenXKflag is added to the flags repo and I add "Kosovo" territory to the list and nowXKflag is missing from all custom-hosted flag bundles and if those people update this library to the latest version without updating their custom-hosted flag bundled they'd get an "Image not found" error when selecting "Kosovo" territory from the list.
-
Migrated
input-control.jsto the latestlibphonenumber-jsAPI. -
Added
/min,/max,/mobileand/customsubpackages pre-wired with different flavors of metadata. See the relevant readme section for more info.
- Deprecated importing from
react-phone-number-input/libphonenumbersub-package (a workaround for ES6/CommonJS double import issue) because the ES6/CommonJS double import issue has been resolved.
- Added
.react-phone-number-input--focusCSS class. Issue.
- Changed the output of
AsYouTypeformatter. E.g. before forUSand input21it was outputting(21 )which is not good for phone number input (not intuitive and is confusing). Now it will not add closing braces which haven't been reached yet by the input cursor and it will also strip the corresponding opening braces, so forUSand input21it now is just21, and for213it is(213).
- Lowered React requirements back to
0.14(same as for version 1.x of this library).
-
(breaking change)
/nativeis now the default export.react-responsive-uiselect is now exported asreact-phone-number-input/react-responsive-ui. -
(breaking change) Migrated
react-responsive-uicountry select from0.10to0.13. It no longer has text input functionality (like "autocomplete") — it's just a<select/>now, without any text input field. Removedrrui.cssfile (usereact-responsive-ui/style.cssbundle instead, or import styles individually fromreact-responsive-ui/styles). RenamedmaxItemsproperty toscrollMaxItems. RemovedcountrySelectToggleClassNameproperty (unused). -
(breaking change)
smartCaretis nowfalseby default (previously wastrue). This was done because some Samsung Android phones were having issues withsmartCaret={true}(which was the default in version1.x).smartCarethas been removed for now, so that it doesn't includeinput-formatlibrary code. -
(breaking change)
internationalproperty is nowtrueby default meaning that by default there will always be the "International" option in the country<select/>. -
(breaking change) CSS changes: renamed
.react-phone-number-input__phone--nativeCSS class to.react-phone-number-input__phone, added new.react-phone-number-input__inputCSS class (the phone input). -
(breaking change) Removed undocumented exports.
-
(breaking change) For
/customcomponentlabelsandinternationalIconproperties are now required (previously werereact-phone-number-input/locales/default.jsonandreact-phone-number-input/commonjs/InternationalIconby default). -
(breaking change) Removed
/resourcesdirectory (due to not being used).
- Added
react-phone-number-input/basic-inputcomponent.
- Some CSS tweaks and code refactoring.
-
Added an isolated
react-phone-number-input/nativeexport (so that it doesn't includereact-responsive-uipackage in the resulting bundle). -
Some CSS tweaks.
-
countrySelectComponentonToggleproperty renamed tohidePhoneInputField.
-
Added
PhoneInputNativeexported component which deprecateds the oldnativeCountrySelect={true/false}property.PhoneInputNativecomponent doesn't requirerrui.css. It will be the default exported component in version2.x. -
Fixed a minor bug appering in React 16.4 which caused the currently selected country flag to be reset while typing.
- Added an optional
smartCaret={false}property for fixing Samsung Android phones.
-
(breaking change) Changed the properties passed to a custom
inputComponent, seeInput.jspropTypesfor more info. -
Added
BasicInput: an alternativeinputComponentfor working around the Samsung Galaxy caret positioning bug.
-
(breaking change) Rewrote
Input.js— there is a possibility that something could potentially break for users coming from previous versions. -
(breaking change) No longer exporting
libphonenumber-jsfunctions. -
(breaking change)
dictionary's"International"key renamed to"ZZ". -
(breaking change)
dictionaryproperty renamed tolabels. -
(breaking change)
nativeExpandedproperty renamed tonativeCountrySelect. -
(breaking change)
selectTabIndexproperty renamed tocountrySelectTabIndex. -
(breaking change)
selectMaxItemsproperty renamed tocountrySelectMaxItems. -
(breaking change)
selectAriaLabelproperty renamed tocountrySelectAriaLabel. -
(breaking change)
selectCloseAriaLabelproperty renamed tocountrySelectCloseAriaLabel. -
(breaking change)
selectComponentproperty renamed tocountrySelectComponent -
(breaking change)
flagComponent'scountryCodeproperty was renamed to justcountry. -
(breaking change) Renamed
countries with flags.jstoflags.jsand put them in the root folder. -
(breaking change)
flagsproperty changed: it can no longer be abooleanand can only be an object of flagReact.Components. -
(breaking change)
selectStyleandinputStyleproperties removed (due to not being used). -
(breaking change)
inputTabIndexproperty removed (usetabIndexinstead). -
(breaking change)
onCountryChangeproperty removed (no one actually used it). -
(breaking change)
convertToNationalproperty renamed todisplayInitialValueAsLocalNumber. -
(breaking change)
style.csschanged a bit (to accomodate phone number extension field). -
(breaking change) If someone did override
.rrui__input:not(.rrui__input--multiline)CSS rule then now it has been split into two CSS rules:.rrui__inputand.rrui__input--multiline. -
Added
locales for thelabelsproperty (ruanden). -
Added
extproperty for phone number extension input.
-
(breaking change) Fixed SVG flag icons for IE. This alters the markup a bit:
<img/>is now wrapped in a<div/>and the CSS class of the image becomes the CSS class of the div and also a new CSS class for the image is added. This could hypothetically be a breaking change in some advanced use cases hence the major version bump. -
Fixed
<Select/>scrolling to the top of the page in IE <= 11. -
Fixed validation error margin left.
- Updated
libphonenumber-jsto1.0.x. parsePhoneNumber(),isValidPhoneNumber()andformatPhoneNumber()no longer acceptundefinedphone number argument: it must be either astringor a parsed numberobjecthaving astringphoneproperty.
-
Added
errorandindicateInvalidproperties for displaying error label. -
(CSS breaking change)
react-phone-number-input<div/>is now wrapped by another<div/>and its CSS class name changed toreact-phone-number-input__rowandreact-phone-number-inputCSS class name goes to the wrapper.
- Returning
<input/>typeback totel. There used to be reports previously thatinput="tel"<input/>s on some non-stock Android devices with non-stock keyboards had issues with proper caret positioning during input. Well, those are non-stock Android bugs and therefore they should fix those there.type="tel"is better in terms of the digital input keyboard so it's now a default. Still can be overridden by passingtype="text"property.
This release contains some minor CSS class names refactoring which most likely won't introduce any issues in almost but all use cases.
(CSS breaking change) Refactored <Select/> CSS class names in react-responsive-ui:
-
.rrui__select__selected--autocomplete->.rrui__select__autocomplete -
.rrui__select__selected->.rrui__select__button -
.rrui__select__selected--nothing->.rrui__select__button--empty -
.rrui__select__selected--expanded->.rrui__select__button--expanded -
.rrui__select__selected--disabled->.rrui__select__button--disabled
(CSS breaking change) Added .rrui__text-input__input CSS class to the phone number <input/>.
(CSS breaking change) Added global .rrui__text-input__input styles to style.css
- Due to the reports stating that
type="tel"caret positioning doesn't work on Samsung devices the component had to revert back totype="text"by default (one can passtype="tel"property directly though).
- (breaking change) The default value of
convertToNationalproperty changed fromtruetofalse. The reason is that the newer generation grows up when there are no stationary phones and therefore everyone inputs phone numbers with a+in their smartphones so local phone numbers should now be considered obsolete.
- Now alphabetically sorting the supplied custom country names
- Fixed a bug when
valuewas not set toundefinedwhen the<input/>value was empty - Added
selectMaxItemsproperty for customizing the country select height
- (CSS breaking change) Removed vertical padding from the first and the last
<Select/><li/>options and moved it to.rrui__select__options<ul/>itself. So if someone customized.rrui__select__options-list-item:first-childand.rrui__select__options-list-item:last-childvertical padding then those padding customizations should be moved to.rrui__select__optionsitself. - (CSS breaking change) Added
.rrui__select__option:hoverand.rrui__select__option--focused:hoverbackground color for better UX.
- (might be a breaking change) Slightly refactored the component CSS improving it in a couple of places along with adding comments to it (see
style.css). - Added country code validation.
- (breaking change) Moved the
.cssfile to the root folder of the package and split it into two files (therruione is not required when already usingreact-responsive-ui).importing the CSS file via Webpack is the recommended way to go now. - (breaking change) Vendor prefixes dropped in favour of manually using autoprefixers.
- Added support for externally changing
valueproperty
- Added
inputTabIndexandselectTabIndexsettings
- Added
nativeExpandedsetting for native country<select/>
- The
.validproperty has been removed from "as you type" formatter, therefore dropping the.react-phone-number-input__phone--validCSS class. This doesn't affect functionality in any way nor does it break existing code therefore it's a "patch" version upgrade.
- (could be a breaking change) Moving CSS positioning properties from inline styles to the CSS file therefore if using an edited CSS file from older versions (when not doing it via Webpack
require(...)) update styles for.rrui__selectand.rrui__select__options. As well as.rrui__expandableand.rrui__shadowhave been added. Maybe (and most likely) something else, so better re-copy the entire CSS file.
- Fixed a small bug when an initially passed phone number
valuewasn't checked for country autodetection - A small enhancement: when an international phone number is erased to a single
+then the currently selected country is reset. And, analogous, when a country is selected, and the input is empty, and then the user enters a single+sign — the country is reset too.
- Fixed a small bug when the
countryproperty was set after page load programmatically and that caused the input taking focus (which displayed a keyboard on mobile devices)
@JeandeCampredonfixedConst declarations are not supported in strict modein module exports
- Added custom metadata feature (now developers have a way to reduce the resulting bundle size in case they decide they need that)
lockCountryproperty removed (usecountries={[country]}instead)- Added
internationalboolean property to explicitly indicate whether to show the "International" option in the list of countries - Not showing country
<Select/>whencountries.length === 1orcountries.length === 0 countriesproperty can now only be an array of country codes
- Fixed the flags bug introduced by adding
flags={ false }option
- Added
flags={ false }option
- Added
lockCountryoption - Added a possibility to specify
countriesas an array of country codes - Fixed country selection on
countryproperty update
- Optimized performance on mobile devices
- Added a bunch of CSS classes:
react-phone-number-input,react-phone-number-input--valid,react-phone-number-input__country,react-phone-number-input__phone,react-phone-number-input__phone--valid
- Now hiding the phone input while the country select is open
- Fixed collapsed select options being interactive in iOS 8 Safari
- A complete rewrite. Now supports all countries, all formats are hard-coded from Google Android's
libphonenumberlibrary.
- Hong Kong phone numbers fix by @nchan0154
- Added some popular country formats (and stubs for other countries)
- Small bug fix for trunk prefixed phone numbers
formatprop is now not required for the React component. Ifformatis not specified then the input switches itself into "auto" (iPhone style) mode.- input code rewrite
- (breaking change)
digitspassed to thetemplate()function don't include trunk prefix anymore - Introduced custom
valid(digits)phone number validation function for phone number format
-
format_phone_number(akaformatPhoneNumber) function now formats phone number internationally (with country code) if noformatargument was supplied (it tries to autodetect the correct phone number format from the phone number itself) -
Added
country(phone)function -
Added
country_from_locale(locale)(akacountryFromLocale(locale)) function
- Added
parse_phone_number(akaparsePhoneNumber) function
- Added
plaintext_local(akaplaintextLocal) andplaintext_international(akaplaintextInternational) methods
- Added custom phone formats
- Refactoring
- Removed
format_phone_number_international(akaformatPhoneNumberInternational)
- Added
disabledproperty
- Added
nameproperty (for javascriptless websites)
- Initial release