@invoicebox/ui 0.1.0-alpha.73 → 0.1.0-alpha.74
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/dist/components/form/PhoneInput/externalPhoneLogic.d.ts +1 -4
- package/dist/components/form/PhoneInput/externalPhoneLogic.js +2 -2
- package/dist/components/form/PhoneInput/index.js +1 -1
- package/dist/components/form/PhoneInput/phoneInputLogic.d.ts +6 -6
- package/dist/components/form/PhoneInput/phoneInputLogic.js +17 -10
- package/package.json +1 -1
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { TSupportedCountries } from './types';
|
|
2
2
|
declare class ExternalPhoneLogic {
|
|
3
|
-
getIsValidPhone(value: string, countries?: Array<
|
|
4
|
-
label: string;
|
|
5
|
-
value: TSupportedCountries;
|
|
6
|
-
}>): boolean;
|
|
3
|
+
getIsValidPhone(value: string, countries?: Array<TSupportedCountries>): boolean;
|
|
7
4
|
}
|
|
8
5
|
export declare const phoneLogic: ExternalPhoneLogic;
|
|
9
6
|
export {};
|
|
@@ -20,8 +20,8 @@ var ExternalPhoneLogic = /*#__PURE__*/function () {
|
|
|
20
20
|
key: "getIsValidPhone",
|
|
21
21
|
value: function getIsValidPhone(value, countries) {
|
|
22
22
|
var notFormattedValue = _phoneInputLogic.phoneInputLogic.getOnlyNumbersFromString(value);
|
|
23
|
-
var
|
|
24
|
-
var currentCountriesPhoneRules = _phoneInputLogic.phoneInputLogic.
|
|
23
|
+
var supportedCountries = _phoneInputLogic.phoneInputLogic.getSupportedCountriesByCountryNames(countries);
|
|
24
|
+
var currentCountriesPhoneRules = _phoneInputLogic.phoneInputLogic.getCountriesPhoneRulesByCountryNames(supportedCountries);
|
|
25
25
|
var country = Object.entries(currentCountriesPhoneRules).find(function (item) {
|
|
26
26
|
return _phoneInputLogic.phoneInputLogic.getIsHaveStartSequenceInString(notFormattedValue, item[1].startSubsequence);
|
|
27
27
|
});
|
|
@@ -45,7 +45,7 @@ var PhoneInput = exports.PhoneInput = function PhoneInput(_ref) {
|
|
|
45
45
|
return _phoneInputLogic.phoneInputLogic.getIsHaveCountriesSelectOptions(countrySelectOptions);
|
|
46
46
|
}, [countrySelectOptions]);
|
|
47
47
|
var currentCountriesPhoneRules = (0, _react.useMemo)(function () {
|
|
48
|
-
return _phoneInputLogic.phoneInputLogic.
|
|
48
|
+
return _phoneInputLogic.phoneInputLogic.getCountriesPhoneRulesBySelectOptions(countrySelectOptions);
|
|
49
49
|
}, [countrySelectOptions]);
|
|
50
50
|
var _useInputFocus = (0, _useInputFocus2.useInputFocus)({
|
|
51
51
|
onFocus: onFocus,
|
|
@@ -3,10 +3,7 @@ import { ChangeEvent } from 'react';
|
|
|
3
3
|
declare class PhoneInputLogic {
|
|
4
4
|
private getCaretPositionByRusValue;
|
|
5
5
|
getIsValidPhoneInputByCountry(value: string, country: TCountryRule): boolean;
|
|
6
|
-
|
|
7
|
-
label: string;
|
|
8
|
-
value: TSupportedCountries;
|
|
9
|
-
}>): boolean;
|
|
6
|
+
getSupportedCountriesByCountryNames(countries?: Array<TSupportedCountries>): ("RUS" | "BLR" | "KAZ" | "AZE" | "ARM" | "KGZ" | "TJK" | "UZB" | "UNKNOWN")[] | undefined;
|
|
10
7
|
getCountriesSelectOptions(countries?: Array<{
|
|
11
8
|
label: string;
|
|
12
9
|
value: TSupportedCountries;
|
|
@@ -16,8 +13,11 @@ declare class PhoneInputLogic {
|
|
|
16
13
|
label: string;
|
|
17
14
|
value: TSupportedCountries;
|
|
18
15
|
}[] | undefined;
|
|
19
|
-
getIsHaveCountriesSelectOptions(countrySelectOptions?: Array<TCountrySelectOption>): boolean;
|
|
20
|
-
|
|
16
|
+
getIsHaveCountriesSelectOptions(countrySelectOptions?: Array<TCountrySelectOption | TSupportedCountries>): boolean;
|
|
17
|
+
getCountriesPhoneRulesBySelectOptions(countrySelectOptions?: Array<TCountrySelectOption>): {
|
|
18
|
+
[k: string]: TCountryRule;
|
|
19
|
+
};
|
|
20
|
+
getCountriesPhoneRulesByCountryNames(countrySelectOptions?: Array<TSupportedCountries>): {
|
|
21
21
|
[k: string]: TCountryRule;
|
|
22
22
|
};
|
|
23
23
|
getIsHaveStartSequenceInString(value: string, subsequence: string): boolean;
|
|
@@ -41,15 +41,11 @@ var PhoneInputLogic = /*#__PURE__*/function () {
|
|
|
41
41
|
return !!value.match(country.regexp);
|
|
42
42
|
}
|
|
43
43
|
}, {
|
|
44
|
-
key: "
|
|
45
|
-
value: function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var currentCountriesPhoneRules = this.getCountriesPhoneRules(countrySelectOptions);
|
|
49
|
-
var country = Object.entries(currentCountriesPhoneRules).find(function (item) {
|
|
50
|
-
return phoneInputLogic.getIsHaveStartSequenceInString(notFormattedValue, item[1].startSubsequence);
|
|
44
|
+
key: "getSupportedCountriesByCountryNames",
|
|
45
|
+
value: function getSupportedCountriesByCountryNames(countries) {
|
|
46
|
+
return countries === null || countries === void 0 ? void 0 : countries.filter(function (country) {
|
|
47
|
+
return _constants.allCountriesPhoneRules[country];
|
|
51
48
|
});
|
|
52
|
-
return this.getIsValidPhoneInputByCountry(notFormattedValue, country ? country[1] : _constants.allCountriesPhoneRules.RUS);
|
|
53
49
|
}
|
|
54
50
|
}, {
|
|
55
51
|
key: "getCountriesSelectOptions",
|
|
@@ -71,8 +67,8 @@ var PhoneInputLogic = /*#__PURE__*/function () {
|
|
|
71
67
|
return !!(countrySelectOptions !== null && countrySelectOptions !== void 0 && countrySelectOptions.length);
|
|
72
68
|
}
|
|
73
69
|
}, {
|
|
74
|
-
key: "
|
|
75
|
-
value: function
|
|
70
|
+
key: "getCountriesPhoneRulesBySelectOptions",
|
|
71
|
+
value: function getCountriesPhoneRulesBySelectOptions(countrySelectOptions) {
|
|
76
72
|
return this.getIsHaveCountriesSelectOptions(countrySelectOptions) ? Object.fromEntries(Object.entries(_constants.allCountriesPhoneRules).filter(function (ruleItem) {
|
|
77
73
|
return countrySelectOptions === null || countrySelectOptions === void 0 ? void 0 : countrySelectOptions.find(function (countrySelectOption) {
|
|
78
74
|
return countrySelectOption.value === ruleItem[0];
|
|
@@ -81,6 +77,17 @@ var PhoneInputLogic = /*#__PURE__*/function () {
|
|
|
81
77
|
RUS: _constants.allCountriesPhoneRules.RUS
|
|
82
78
|
};
|
|
83
79
|
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "getCountriesPhoneRulesByCountryNames",
|
|
82
|
+
value: function getCountriesPhoneRulesByCountryNames(countrySelectOptions) {
|
|
83
|
+
return this.getIsHaveCountriesSelectOptions(countrySelectOptions) ? Object.fromEntries(Object.entries(_constants.allCountriesPhoneRules).filter(function (ruleItem) {
|
|
84
|
+
return countrySelectOptions === null || countrySelectOptions === void 0 ? void 0 : countrySelectOptions.find(function (countrySelectOption) {
|
|
85
|
+
return countrySelectOption === ruleItem[0];
|
|
86
|
+
});
|
|
87
|
+
})) : {
|
|
88
|
+
RUS: _constants.allCountriesPhoneRules.RUS
|
|
89
|
+
};
|
|
90
|
+
}
|
|
84
91
|
}, {
|
|
85
92
|
key: "getIsHaveStartSequenceInString",
|
|
86
93
|
value: function getIsHaveStartSequenceInString(value, subsequence) {
|