@alfalab/core-components-intl-phone-input 9.0.0 → 9.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{component-cff706a9.d.ts → component-45364492.d.ts} +0 -0
- package/{component-cff706a9.js → component-45364492.js} +1 -1
- package/component.js +24 -6
- package/components/flag-icon/component.js +2 -2
- package/components/flag-icon/index.css +261 -261
- package/components/index.js +1 -1
- package/components/select/component.js +2 -2
- package/components/select/index.css +6 -6
- package/components/select/index.js +1 -1
- package/components/select-field/component.js +1 -1
- package/components/select-field/index.css +9 -9
- package/components/select-field/index.d.ts +1 -1
- package/components/select-field/index.js +1 -1
- package/cssm/{component-6cde4bb4.d.ts → component-215a3963.d.ts} +0 -0
- package/cssm/{component-6cde4bb4.js → component-215a3963.js} +0 -0
- package/cssm/component.js +22 -4
- package/cssm/components/flag-icon/component.js +1 -1
- package/cssm/components/index.js +1 -1
- package/cssm/components/select/component.js +1 -1
- package/cssm/components/select/index.js +1 -1
- package/cssm/components/select-field/component.js +1 -1
- package/cssm/components/select-field/index.d.ts +1 -1
- package/cssm/components/select-field/index.js +1 -1
- package/cssm/index.js +1 -1
- package/esm/{component-ecacd04e.d.ts → component-122e7388.d.ts} +0 -0
- package/esm/{component-ecacd04e.js → component-122e7388.js} +1 -1
- package/esm/component.js +24 -6
- package/esm/components/flag-icon/component.js +2 -2
- package/esm/components/flag-icon/index.css +261 -261
- package/esm/components/index.js +1 -1
- package/esm/components/select/component.js +2 -2
- package/esm/components/select/index.css +6 -6
- package/esm/components/select/index.js +1 -1
- package/esm/components/select-field/component.js +1 -1
- package/esm/components/select-field/index.css +9 -9
- package/esm/components/select-field/index.d.ts +1 -1
- package/esm/components/select-field/index.js +1 -1
- package/esm/index.css +5 -5
- package/esm/index.js +1 -1
- package/esm/{libphonenumber-js.min-98e51f5c.d.ts → libphonenumber-js.min-60e0fae3.d.ts} +0 -0
- package/esm/{libphonenumber-js.min-98e51f5c.js → libphonenumber-js.min-60e0fae3.js} +0 -0
- package/index.css +5 -5
- package/index.js +1 -1
- package/{libphonenumber-js.min-189e6bdc.d.ts → libphonenumber-js.min-149ceb21.d.ts} +0 -0
- package/{libphonenumber-js.min-189e6bdc.js → libphonenumber-js.min-149ceb21.js} +0 -0
- package/modern/component.js +22 -5
- package/modern/components/flag-icon/component.js +2 -2
- package/modern/components/flag-icon/index.css +261 -261
- package/modern/components/select/component.js +1 -1
- package/modern/components/select/index.css +6 -6
- package/modern/components/select-field/component.js +1 -1
- package/modern/components/select-field/index.css +9 -9
- package/modern/index.css +5 -5
- package/modern/{libphonenumber-js.min-98e51f5c.d.ts → libphonenumber-js.min-60e0fae3.d.ts} +0 -0
- package/modern/{libphonenumber-js.min-98e51f5c.js → libphonenumber-js.min-60e0fae3.js} +0 -0
- package/package.json +5 -5
- package/send-stats.js +1 -1
|
File without changes
|
|
@@ -53,7 +53,7 @@ function __rest(s, e) {
|
|
|
53
53
|
return t;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
var styles = {"component":"intl-phone-
|
|
56
|
+
var styles = {"component":"intl-phone-input__component_l1c9p","flagIconContainer":"intl-phone-input__flagIconContainer_l1c9p","emptyCountryIcon":"intl-phone-input__emptyCountryIcon_l1c9p","disabled":"intl-phone-input__disabled_l1c9p","inner":"intl-phone-input__inner_l1c9p","l":"intl-phone-input__l_l1c9p","xl":"intl-phone-input__xl_l1c9p","focusVisible":"intl-phone-input__focusVisible_l1c9p"};
|
|
57
57
|
require('./components/select-field/index.css')
|
|
58
58
|
|
|
59
59
|
var EMPTY_COUNTRY_SELECT_FIELD = {
|
package/component.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var components_selectField_component = require('./component-
|
|
5
|
+
var components_selectField_component = require('./component-45364492.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var cn = require('classnames');
|
|
8
8
|
var coreComponentsInputAutocomplete = require('@alfalab/core-components-input-autocomplete');
|
|
@@ -24,7 +24,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
24
24
|
var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
|
|
25
25
|
var WorldMagnifierMIcon__default = /*#__PURE__*/_interopDefaultLegacy(WorldMagnifierMIcon);
|
|
26
26
|
|
|
27
|
-
var styles = {"addons":"intl-phone-
|
|
27
|
+
var styles = {"addons":"intl-phone-input__addons_288d9","l":"intl-phone-input__l_288d9","xl":"intl-phone-input__xl_288d9","flagIconWrapper":"intl-phone-input__flagIconWrapper_288d9","emptyCountryIcon":"intl-phone-input__emptyCountryIcon_288d9"};
|
|
28
28
|
require('./index.css')
|
|
29
29
|
|
|
30
30
|
var countriesHash = utils.getCountriesHash();
|
|
@@ -39,14 +39,15 @@ var IntlPhoneInput = React.forwardRef(function (_a, ref) {
|
|
|
39
39
|
var _r = React.useState(null), inputWrapperRef = _r[0], setInputWrapperRef = _r[1];
|
|
40
40
|
var _s = React.useState(), caretPos = _s[0], setCaretPos = _s[1];
|
|
41
41
|
var phoneLibUtils = React.useRef();
|
|
42
|
-
var formatPhone = function (inputValue) {
|
|
42
|
+
var formatPhone = function (inputValue, iso2) {
|
|
43
|
+
if (iso2 === void 0) { iso2 = countryIso2; }
|
|
43
44
|
var newValue = inputValue;
|
|
44
45
|
if (phoneLibUtils.current) {
|
|
45
46
|
var Utils = phoneLibUtils.current;
|
|
46
|
-
var utils = new Utils(
|
|
47
|
+
var utils = new Utils(iso2 ? iso2.toUpperCase() : undefined);
|
|
47
48
|
newValue = utils.input(inputValue);
|
|
48
49
|
}
|
|
49
|
-
if (
|
|
50
|
+
if (iso2 === 'ru') {
|
|
50
51
|
var parts = newValue.split(' ');
|
|
51
52
|
newValue = parts.reduce(function (acc, part, index) {
|
|
52
53
|
if (index === 0) {
|
|
@@ -275,7 +276,7 @@ var IntlPhoneInput = React.forwardRef(function (_a, ref) {
|
|
|
275
276
|
if (phoneLibUtils.current)
|
|
276
277
|
return;
|
|
277
278
|
Promise.resolve().then(function () { return require(
|
|
278
|
-
/* webpackChunkName: "libphonenumber" */ './libphonenumber-js.min-
|
|
279
|
+
/* webpackChunkName: "libphonenumber" */ './libphonenumber-js.min-149ceb21.js'); })
|
|
279
280
|
.then(function (utils) {
|
|
280
281
|
phoneLibUtils.current = utils.AsYouType;
|
|
281
282
|
if (canBeEmptyCountry) {
|
|
@@ -288,6 +289,23 @@ var IntlPhoneInput = React.forwardRef(function (_a, ref) {
|
|
|
288
289
|
.catch(function (error) { return "An error occurred while loading libphonenumber-js:\n" + error; });
|
|
289
290
|
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
|
290
291
|
}, [value]);
|
|
292
|
+
React.useEffect(function () {
|
|
293
|
+
if (value && value.length > 1 && !value.includes(' ')) {
|
|
294
|
+
var newCountry = getCountryByNumber(value);
|
|
295
|
+
if (newCountry && countryIso2 !== newCountry.iso2) {
|
|
296
|
+
setCountryIso2(newCountry.iso2);
|
|
297
|
+
handleCountryChange(newCountry.iso2);
|
|
298
|
+
}
|
|
299
|
+
else if (canBeEmptyCountry &&
|
|
300
|
+
!newCountry &&
|
|
301
|
+
countryIso2 !== defaultCountryIso2.toLowerCase()) {
|
|
302
|
+
setCountryIso2(undefined);
|
|
303
|
+
handleCountryChange(undefined);
|
|
304
|
+
}
|
|
305
|
+
onChange(formatPhone(value, newCountry === null || newCountry === void 0 ? void 0 : newCountry.iso2));
|
|
306
|
+
}
|
|
307
|
+
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
|
308
|
+
}, [value, canBeEmptyCountry, countryIso2, defaultCountryIso2]);
|
|
291
309
|
useCaretAvoidCountryCode.useCaretAvoidCountryCode({ inputRef: inputRef, countryCodeLength: countryCodeLength, clearableCountryCode: clearableCountryCode });
|
|
292
310
|
return (React__default['default'].createElement(coreComponentsInputAutocomplete.InputAutocomplete, components_selectField_component.__assign({}, restProps, { ref: ref, inputProps: components_selectField_component.__assign(components_selectField_component.__assign({ clear: clear && !isEmptyValue, onClear: handleClear }, inputProps), { ref: inputRef, wrapperRef: setInputWrapperRef, type: 'tel', colors: colors, className: cn__default['default'](className, styles[size]), addonsClassName: styles.addons, onKeyDown: handleKeyDown, onPaste: handlePaste, leftAddons: hideCountrySelect ? (React__default['default'].createElement("span", { className: styles.flagIconWrapper }, countryIso2 ? (React__default['default'].createElement(components_flagIcon_component.FlagIcon, { country: countryIso2 })) : (React__default['default'].createElement(WorldMagnifierMIcon__default['default'], { className: styles.emptyCountryIcon })))) : (countries.length > 1 && (React__default['default'].createElement(components_select_component.CountriesSelect, { dataTestId: 'countries-select', disabled: disabled || readOnly, size: size, selected: countryIso2, countries: countries, onChange: handleSelectChange, fieldWidth: inputWrapperRef && inputWrapperRef.getBoundingClientRect().width, preventFlip: preventFlip }))) }), optionsListWidth: 'field', closeOnSelect: true, onInput: handleInputChange, onChange: handleChange, options: options, disabled: disabled, readOnly: readOnly, size: size, className: className, value: value })));
|
|
293
311
|
});
|
|
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
10
10
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
11
11
|
var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
|
|
12
12
|
|
|
13
|
-
var styles = {"flagIcon":"intl-phone-
|
|
13
|
+
var styles = {"flagIcon":"intl-phone-input__flagIcon_130ue","ac":"intl-phone-input__ac_130ue","ad":"intl-phone-input__ad_130ue","ae":"intl-phone-input__ae_130ue","af":"intl-phone-input__af_130ue","ag":"intl-phone-input__ag_130ue","ai":"intl-phone-input__ai_130ue","al":"intl-phone-input__al_130ue","am":"intl-phone-input__am_130ue","ao":"intl-phone-input__ao_130ue","aq":"intl-phone-input__aq_130ue","ar":"intl-phone-input__ar_130ue","as":"intl-phone-input__as_130ue","at":"intl-phone-input__at_130ue","au":"intl-phone-input__au_130ue","aw":"intl-phone-input__aw_130ue","ax":"intl-phone-input__ax_130ue","az":"intl-phone-input__az_130ue","ba":"intl-phone-input__ba_130ue","bb":"intl-phone-input__bb_130ue","bd":"intl-phone-input__bd_130ue","be":"intl-phone-input__be_130ue","bf":"intl-phone-input__bf_130ue","bg":"intl-phone-input__bg_130ue","bh":"intl-phone-input__bh_130ue","bi":"intl-phone-input__bi_130ue","bj":"intl-phone-input__bj_130ue","bl":"intl-phone-input__bl_130ue","bm":"intl-phone-input__bm_130ue","bn":"intl-phone-input__bn_130ue","bo":"intl-phone-input__bo_130ue","bq":"intl-phone-input__bq_130ue","br":"intl-phone-input__br_130ue","bs":"intl-phone-input__bs_130ue","bt":"intl-phone-input__bt_130ue","bv":"intl-phone-input__bv_130ue","bw":"intl-phone-input__bw_130ue","by":"intl-phone-input__by_130ue","bz":"intl-phone-input__bz_130ue","ca":"intl-phone-input__ca_130ue","cc":"intl-phone-input__cc_130ue","cd":"intl-phone-input__cd_130ue","cf":"intl-phone-input__cf_130ue","cg":"intl-phone-input__cg_130ue","ch":"intl-phone-input__ch_130ue","ci":"intl-phone-input__ci_130ue","ck":"intl-phone-input__ck_130ue","cl":"intl-phone-input__cl_130ue","cm":"intl-phone-input__cm_130ue","cn":"intl-phone-input__cn_130ue","co":"intl-phone-input__co_130ue","cp":"intl-phone-input__cp_130ue","cr":"intl-phone-input__cr_130ue","cu":"intl-phone-input__cu_130ue","cv":"intl-phone-input__cv_130ue","cw":"intl-phone-input__cw_130ue","cx":"intl-phone-input__cx_130ue","cy":"intl-phone-input__cy_130ue","cz":"intl-phone-input__cz_130ue","de":"intl-phone-input__de_130ue","dg":"intl-phone-input__dg_130ue","dj":"intl-phone-input__dj_130ue","dk":"intl-phone-input__dk_130ue","dm":"intl-phone-input__dm_130ue","do":"intl-phone-input__do_130ue","dz":"intl-phone-input__dz_130ue","ea":"intl-phone-input__ea_130ue","ec":"intl-phone-input__ec_130ue","ee":"intl-phone-input__ee_130ue","eg":"intl-phone-input__eg_130ue","eh":"intl-phone-input__eh_130ue","er":"intl-phone-input__er_130ue","es":"intl-phone-input__es_130ue","et":"intl-phone-input__et_130ue","eu":"intl-phone-input__eu_130ue","fi":"intl-phone-input__fi_130ue","fj":"intl-phone-input__fj_130ue","fk":"intl-phone-input__fk_130ue","fm":"intl-phone-input__fm_130ue","fo":"intl-phone-input__fo_130ue","fr":"intl-phone-input__fr_130ue","ga":"intl-phone-input__ga_130ue","gb":"intl-phone-input__gb_130ue","gd":"intl-phone-input__gd_130ue","ge":"intl-phone-input__ge_130ue","gf":"intl-phone-input__gf_130ue","gg":"intl-phone-input__gg_130ue","gh":"intl-phone-input__gh_130ue","gi":"intl-phone-input__gi_130ue","gl":"intl-phone-input__gl_130ue","gm":"intl-phone-input__gm_130ue","gn":"intl-phone-input__gn_130ue","gp":"intl-phone-input__gp_130ue","gq":"intl-phone-input__gq_130ue","gr":"intl-phone-input__gr_130ue","gs":"intl-phone-input__gs_130ue","gt":"intl-phone-input__gt_130ue","gu":"intl-phone-input__gu_130ue","gw":"intl-phone-input__gw_130ue","gy":"intl-phone-input__gy_130ue","hk":"intl-phone-input__hk_130ue","hm":"intl-phone-input__hm_130ue","hn":"intl-phone-input__hn_130ue","hr":"intl-phone-input__hr_130ue","ht":"intl-phone-input__ht_130ue","hu":"intl-phone-input__hu_130ue","ic":"intl-phone-input__ic_130ue","id":"intl-phone-input__id_130ue","ie":"intl-phone-input__ie_130ue","il":"intl-phone-input__il_130ue","im":"intl-phone-input__im_130ue","in":"intl-phone-input__in_130ue","io":"intl-phone-input__io_130ue","iq":"intl-phone-input__iq_130ue","ir":"intl-phone-input__ir_130ue","is":"intl-phone-input__is_130ue","it":"intl-phone-input__it_130ue","je":"intl-phone-input__je_130ue","jm":"intl-phone-input__jm_130ue","jo":"intl-phone-input__jo_130ue","jp":"intl-phone-input__jp_130ue","ke":"intl-phone-input__ke_130ue","kg":"intl-phone-input__kg_130ue","kh":"intl-phone-input__kh_130ue","ki":"intl-phone-input__ki_130ue","km":"intl-phone-input__km_130ue","kn":"intl-phone-input__kn_130ue","kp":"intl-phone-input__kp_130ue","kr":"intl-phone-input__kr_130ue","kw":"intl-phone-input__kw_130ue","ky":"intl-phone-input__ky_130ue","kz":"intl-phone-input__kz_130ue","la":"intl-phone-input__la_130ue","lb":"intl-phone-input__lb_130ue","lc":"intl-phone-input__lc_130ue","li":"intl-phone-input__li_130ue","lk":"intl-phone-input__lk_130ue","lr":"intl-phone-input__lr_130ue","ls":"intl-phone-input__ls_130ue","lt":"intl-phone-input__lt_130ue","lu":"intl-phone-input__lu_130ue","lv":"intl-phone-input__lv_130ue","ly":"intl-phone-input__ly_130ue","ma":"intl-phone-input__ma_130ue","mc":"intl-phone-input__mc_130ue","md":"intl-phone-input__md_130ue","me":"intl-phone-input__me_130ue","mf":"intl-phone-input__mf_130ue","mg":"intl-phone-input__mg_130ue","mh":"intl-phone-input__mh_130ue","mk":"intl-phone-input__mk_130ue","ml":"intl-phone-input__ml_130ue","mm":"intl-phone-input__mm_130ue","mn":"intl-phone-input__mn_130ue","mo":"intl-phone-input__mo_130ue","mp":"intl-phone-input__mp_130ue","mq":"intl-phone-input__mq_130ue","mr":"intl-phone-input__mr_130ue","ms":"intl-phone-input__ms_130ue","mt":"intl-phone-input__mt_130ue","mu":"intl-phone-input__mu_130ue","mv":"intl-phone-input__mv_130ue","mw":"intl-phone-input__mw_130ue","mx":"intl-phone-input__mx_130ue","my":"intl-phone-input__my_130ue","mz":"intl-phone-input__mz_130ue","na":"intl-phone-input__na_130ue","nc":"intl-phone-input__nc_130ue","ne":"intl-phone-input__ne_130ue","nf":"intl-phone-input__nf_130ue","ng":"intl-phone-input__ng_130ue","ni":"intl-phone-input__ni_130ue","nl":"intl-phone-input__nl_130ue","no":"intl-phone-input__no_130ue","np":"intl-phone-input__np_130ue","nr":"intl-phone-input__nr_130ue","nu":"intl-phone-input__nu_130ue","nz":"intl-phone-input__nz_130ue","om":"intl-phone-input__om_130ue","pa":"intl-phone-input__pa_130ue","pe":"intl-phone-input__pe_130ue","pf":"intl-phone-input__pf_130ue","pg":"intl-phone-input__pg_130ue","ph":"intl-phone-input__ph_130ue","pk":"intl-phone-input__pk_130ue","pl":"intl-phone-input__pl_130ue","pm":"intl-phone-input__pm_130ue","pn":"intl-phone-input__pn_130ue","pr":"intl-phone-input__pr_130ue","ps":"intl-phone-input__ps_130ue","pt":"intl-phone-input__pt_130ue","pw":"intl-phone-input__pw_130ue","py":"intl-phone-input__py_130ue","qa":"intl-phone-input__qa_130ue","re":"intl-phone-input__re_130ue","ro":"intl-phone-input__ro_130ue","rs":"intl-phone-input__rs_130ue","ru":"intl-phone-input__ru_130ue","rw":"intl-phone-input__rw_130ue","sa":"intl-phone-input__sa_130ue","sb":"intl-phone-input__sb_130ue","sc":"intl-phone-input__sc_130ue","sd":"intl-phone-input__sd_130ue","se":"intl-phone-input__se_130ue","sg":"intl-phone-input__sg_130ue","sh":"intl-phone-input__sh_130ue","si":"intl-phone-input__si_130ue","sj":"intl-phone-input__sj_130ue","sk":"intl-phone-input__sk_130ue","sl":"intl-phone-input__sl_130ue","sm":"intl-phone-input__sm_130ue","sn":"intl-phone-input__sn_130ue","so":"intl-phone-input__so_130ue","sr":"intl-phone-input__sr_130ue","ss":"intl-phone-input__ss_130ue","st":"intl-phone-input__st_130ue","sv":"intl-phone-input__sv_130ue","sx":"intl-phone-input__sx_130ue","sy":"intl-phone-input__sy_130ue","sz":"intl-phone-input__sz_130ue","ta":"intl-phone-input__ta_130ue","tc":"intl-phone-input__tc_130ue","td":"intl-phone-input__td_130ue","tf":"intl-phone-input__tf_130ue","tg":"intl-phone-input__tg_130ue","th":"intl-phone-input__th_130ue","tj":"intl-phone-input__tj_130ue","tk":"intl-phone-input__tk_130ue","tl":"intl-phone-input__tl_130ue","tm":"intl-phone-input__tm_130ue","tn":"intl-phone-input__tn_130ue","to":"intl-phone-input__to_130ue","tr":"intl-phone-input__tr_130ue","tt":"intl-phone-input__tt_130ue","tv":"intl-phone-input__tv_130ue","tw":"intl-phone-input__tw_130ue","tz":"intl-phone-input__tz_130ue","ua":"intl-phone-input__ua_130ue","ug":"intl-phone-input__ug_130ue","um":"intl-phone-input__um_130ue","un":"intl-phone-input__un_130ue","us":"intl-phone-input__us_130ue","uy":"intl-phone-input__uy_130ue","uz":"intl-phone-input__uz_130ue","va":"intl-phone-input__va_130ue","vc":"intl-phone-input__vc_130ue","ve":"intl-phone-input__ve_130ue","vg":"intl-phone-input__vg_130ue","vi":"intl-phone-input__vi_130ue","vn":"intl-phone-input__vn_130ue","vu":"intl-phone-input__vu_130ue","wf":"intl-phone-input__wf_130ue","ws":"intl-phone-input__ws_130ue","xk":"intl-phone-input__xk_130ue","ye":"intl-phone-input__ye_130ue","yt":"intl-phone-input__yt_130ue","za":"intl-phone-input__za_130ue","zm":"intl-phone-input__zm_130ue","zw":"intl-phone-input__zw_130ue"};
|
|
14
14
|
require('./index.css')
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -18,7 +18,7 @@ require('./index.css')
|
|
|
18
18
|
*/
|
|
19
19
|
var FlagIcon = function (_a) {
|
|
20
20
|
var _b = _a.country, country = _b === void 0 ? '' : _b, className = _a.className;
|
|
21
|
-
return React__default['default'].createElement("span", { className: cn__default['default'](styles.flagIcon, styles[country], className) });
|
|
21
|
+
return (React__default['default'].createElement("span", { className: cn__default['default'](styles.flagIcon, styles[country], className) }));
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
exports.FlagIcon = FlagIcon;
|