@rh-support/components 2.1.70 → 2.1.72
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/lib/esm/Functional/CaseContactsSelectorExternal.d.ts +1 -0
- package/lib/esm/Functional/CaseContactsSelectorExternal.d.ts.map +1 -1
- package/lib/esm/Functional/CaseContactsSelectorExternal.js +2 -1
- package/lib/esm/PhoneInput/PhoneInput.d.ts +11 -0
- package/lib/esm/PhoneInput/PhoneInput.d.ts.map +1 -1
- package/lib/esm/PhoneInput/PhoneInput.js +36 -31
- package/package.json +2 -2
|
@@ -22,6 +22,7 @@ interface IProps<T extends TypeaheadModel> extends IDClassNameProps, Omit<Typeah
|
|
|
22
22
|
isExportingPDF?: boolean;
|
|
23
23
|
newSelectionPrefix?: React.ReactNode;
|
|
24
24
|
customEmails?: IAccountNotificationAddresses[];
|
|
25
|
+
isDisabled?: boolean;
|
|
25
26
|
}
|
|
26
27
|
declare const renderMenuItemChildren: (option: INotificationContact, p: any) => React.JSX.Element;
|
|
27
28
|
declare const getHydraContactLabel: (user: INotificationContact) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaseContactsSelectorExternal.d.ts","sourceRoot":"","sources":["../../../src/Functional/CaseContactsSelectorExternal.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAuB,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAMxD,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAA0C,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAKnH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAA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AAE,OAAO,CAAC;CACxB;AAED,QAAA,MAAM,sBAAsB,WAAY,oBAAoB,8BAI3D,CAAC;AAcF,QAAA,MAAM,oBAAoB,SAAU,oBAAoB,KAAG,MAa1D,CAAC;AAEF,iBAAS,4BAA4B,CAAC,CAAC,SAAS,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,qBAqN/E;AAED,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -153,7 +153,8 @@ function CaseContactsSelectorExternal(props) {
|
|
|
153
153
|
const isDisabled = (props.loggedInUserRights.isExternal() &&
|
|
154
154
|
props.loggedInUserRights.isNonOrgAdminWithSameAccount(props.selectedAccountNumber)) ||
|
|
155
155
|
props.isUpdating ||
|
|
156
|
-
contactList.isFetching
|
|
156
|
+
contactList.isFetching ||
|
|
157
|
+
props.isDisabled;
|
|
157
158
|
const renderMenu = (results, menuProps, state) => {
|
|
158
159
|
const contacts = results.map((item, index) => {
|
|
159
160
|
if (item.customOption) {
|
|
@@ -12,6 +12,17 @@ interface IProps {
|
|
|
12
12
|
isDisabled?: boolean;
|
|
13
13
|
shouldNotSetCountryCode?: boolean;
|
|
14
14
|
}
|
|
15
|
+
export declare const getExactCountry: (phoneNumber: string) => any[] | {
|
|
16
|
+
name: string | number | string[];
|
|
17
|
+
regions: string | number | string[];
|
|
18
|
+
iso2: string | number | string[];
|
|
19
|
+
countryCode: string | number | string[];
|
|
20
|
+
dialCode: string | number | string[];
|
|
21
|
+
format: string;
|
|
22
|
+
priority: string | number | string[];
|
|
23
|
+
areaCode: string | number | string[];
|
|
24
|
+
phoneInitials: string[];
|
|
25
|
+
};
|
|
15
26
|
export declare const getPhoneObj: (phoneNumber: string) => {
|
|
16
27
|
countryCode: string;
|
|
17
28
|
phoneLine: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../src/PhoneInput/PhoneInput.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E,OAAO,CAAC;CACrC;AAoDD,eAAO,MAAM,eAAe,gBAAiB,MAAM;;;;;;;;;;CAmClD,CAAC;AAqCF,eAAO,MAAM,WAAW,gBAAiB,MAAM;;;CAgB9C,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,qBAwLvC"}
|
|
@@ -55,6 +55,30 @@ const removeAllChars = (value) => {
|
|
|
55
55
|
// to remove all chars, brackets and have only digits
|
|
56
56
|
return value === null || value === void 0 ? void 0 : value.replace(/[^0-9]/g, '');
|
|
57
57
|
};
|
|
58
|
+
// guess exact country for any given phone
|
|
59
|
+
export const getExactCountry = (phoneNumber) => {
|
|
60
|
+
let localPhone = removeAllChars(phoneNumber);
|
|
61
|
+
// Guessing countries according to user input
|
|
62
|
+
const possibleCountries = initializedCountries === null || initializedCountries === void 0 ? void 0 : initializedCountries.filter((country) => localPhone === null || localPhone === void 0 ? void 0 : localPhone.startsWith(country.dialCode.toString()));
|
|
63
|
+
const possibleCountriesPhoneInitials = possibleCountries === null || possibleCountries === void 0 ? void 0 : possibleCountries.map((country) => country.phoneInitials);
|
|
64
|
+
// Function to find the matching country index based on user phone input
|
|
65
|
+
const findMatchingIndex = (possibleCountry, phone) => {
|
|
66
|
+
for (let i = 0; i < (possibleCountry === null || possibleCountry === void 0 ? void 0 : possibleCountry.length); i++) {
|
|
67
|
+
const country = possibleCountry[i];
|
|
68
|
+
for (let j = 0; j < (country === null || country === void 0 ? void 0 : country.length); j++) {
|
|
69
|
+
if (phone.startsWith(country[j])) {
|
|
70
|
+
return i;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return -1; // Return -1 if no match is found
|
|
75
|
+
};
|
|
76
|
+
const countryMatchingIndex = findMatchingIndex(possibleCountriesPhoneInitials, localPhone);
|
|
77
|
+
const defaultCountry = possibleCountries === null || possibleCountries === void 0 ? void 0 : possibleCountries.filter((country) => (localPhone === null || localPhone === void 0 ? void 0 : localPhone.startsWith(country.dialCode.toString())) && isEqual(country.priority, 0));
|
|
78
|
+
const possibleDefaultCountry = !isEmpty(defaultCountry[0]) && !isUndefined(defaultCountry[0]) ? defaultCountry[0] : []; // default country when phone didn't match with any country's area code
|
|
79
|
+
const exactCountry = countryMatchingIndex < 0 ? possibleDefaultCountry : possibleCountries[countryMatchingIndex];
|
|
80
|
+
return exactCountry;
|
|
81
|
+
};
|
|
58
82
|
// Formatting phone numbers according to country
|
|
59
83
|
const formatNumber = (fullPhoneNumber, localFormat) => {
|
|
60
84
|
var _a;
|
|
@@ -82,27 +106,25 @@ const formatNumber = (fullPhoneNumber, localFormat) => {
|
|
|
82
106
|
pattern += localFormat[j];
|
|
83
107
|
}
|
|
84
108
|
}
|
|
85
|
-
const isPatternWithPrefix = (_a = pattern.replace(/\s+/g, '')) === null || _a === void 0 ? void 0 : _a.startsWith(PREFIX);
|
|
109
|
+
const isPatternWithPrefix = (_a = pattern === null || pattern === void 0 ? void 0 : pattern.replace(/\s+/g, '')) === null || _a === void 0 ? void 0 : _a.startsWith(PREFIX);
|
|
86
110
|
pattern = isPatternWithPrefix ? pattern : !isEmpty(isPatternWithPrefix) ? PREFIX + pattern : '';
|
|
87
111
|
return pattern;
|
|
88
112
|
};
|
|
89
113
|
// return phoneline and countrycode for any given phone
|
|
90
114
|
export const getPhoneObj = (phoneNumber) => {
|
|
91
|
-
var _a
|
|
115
|
+
var _a;
|
|
92
116
|
let localPhone = removeAllChars(phoneNumber);
|
|
93
117
|
let countryCode = '';
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (!isEmpty(exactCountry)) {
|
|
98
|
-
countryCode = PREFIX + ((_a = exactCountry[0]) === null || _a === void 0 ? void 0 : _a.dialCode.toString());
|
|
118
|
+
const exactCountry = getExactCountry(localPhone);
|
|
119
|
+
if (!isEmpty(exactCountry) && !isEmpty(exactCountry['dialCode'].toString())) {
|
|
120
|
+
countryCode = PREFIX + exactCountry['dialCode'].toString();
|
|
99
121
|
}
|
|
100
|
-
else
|
|
101
|
-
countryCode =
|
|
122
|
+
else {
|
|
123
|
+
countryCode = '';
|
|
102
124
|
}
|
|
103
125
|
return {
|
|
104
126
|
countryCode: countryCode,
|
|
105
|
-
phoneLine: localPhone === null || localPhone === void 0 ? void 0 : localPhone.substring((
|
|
127
|
+
phoneLine: localPhone === null || localPhone === void 0 ? void 0 : localPhone.substring((_a = trimAndReplacePlusFromPhone(countryCode)) === null || _a === void 0 ? void 0 : _a.length, localPhone === null || localPhone === void 0 ? void 0 : localPhone.length),
|
|
106
128
|
};
|
|
107
129
|
};
|
|
108
130
|
export function PhoneInput(props) {
|
|
@@ -117,25 +139,7 @@ export function PhoneInput(props) {
|
|
|
117
139
|
return DEFAULT_FORMAT; // default format for portal phone without country code
|
|
118
140
|
}
|
|
119
141
|
let localFormat;
|
|
120
|
-
|
|
121
|
-
const possibleCountries = initializedCountries.filter((country) => localPhone === null || localPhone === void 0 ? void 0 : localPhone.startsWith(country.dialCode.toString()));
|
|
122
|
-
const possibleCountriesPhoneInitials = possibleCountries === null || possibleCountries === void 0 ? void 0 : possibleCountries.map((country) => country.phoneInitials);
|
|
123
|
-
// Function to find the matching country index based on user phone input
|
|
124
|
-
const findMatchingIndex = (possibleCountry, phone) => {
|
|
125
|
-
for (let i = 0; i < (possibleCountry === null || possibleCountry === void 0 ? void 0 : possibleCountry.length); i++) {
|
|
126
|
-
const country = possibleCountry[i];
|
|
127
|
-
for (let j = 0; j < (country === null || country === void 0 ? void 0 : country.length); j++) {
|
|
128
|
-
if (phone.startsWith(country[j])) {
|
|
129
|
-
return i;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return -1; // Return -1 if no match is found
|
|
134
|
-
};
|
|
135
|
-
const countryMatchingIndex = findMatchingIndex(possibleCountriesPhoneInitials, localPhone);
|
|
136
|
-
const defaultCountry = possibleCountries === null || possibleCountries === void 0 ? void 0 : possibleCountries.filter((country) => (localPhone === null || localPhone === void 0 ? void 0 : localPhone.startsWith(country.dialCode.toString())) && isEqual(country.priority, 0));
|
|
137
|
-
const possibleDefaultCountry = !isUndefined(defaultCountry[0]) ? defaultCountry[0] : []; // default country when phone didn't match with any country's area code
|
|
138
|
-
const exactCountry = countryMatchingIndex < 0 ? possibleDefaultCountry : possibleCountries[countryMatchingIndex];
|
|
142
|
+
const exactCountry = getExactCountry(localPhone);
|
|
139
143
|
if (!isEmpty(exactCountry)) {
|
|
140
144
|
setIso2(exactCountry['iso2'].toString());
|
|
141
145
|
localFormat = exactCountry['format'].toString();
|
|
@@ -172,10 +176,11 @@ export function PhoneInput(props) {
|
|
|
172
176
|
setIsOpen(isOpen);
|
|
173
177
|
};
|
|
174
178
|
const onCountrySelect = (event, selection) => {
|
|
179
|
+
var _a, _b;
|
|
175
180
|
const prevCountryCode = !shouldNotSetCountryCode // fetching previous country code to remove it from the phone
|
|
176
|
-
? trimAndReplacePlusFromPhone(getPhoneObj(phoneValue).countryCode)
|
|
181
|
+
? trimAndReplacePlusFromPhone((_a = getPhoneObj(phoneValue)) === null || _a === void 0 ? void 0 : _a.countryCode)
|
|
177
182
|
: '';
|
|
178
|
-
const phoneWithoutCountryCode = removeAllChars(phoneValue).replace(prevCountryCode, '');
|
|
183
|
+
const phoneWithoutCountryCode = (_b = removeAllChars(phoneValue)) === null || _b === void 0 ? void 0 : _b.replace(prevCountryCode, '');
|
|
179
184
|
onPhoneValueChange(`${PREFIX}${selection.countryCode} ${trimAndReplacePlusFromPhone(phoneWithoutCountryCode)}`);
|
|
180
185
|
setIsOpen(!isOpen);
|
|
181
186
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/components",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.72",
|
|
4
4
|
"description": "Contains all reusabel components for support app",
|
|
5
5
|
"author": "Vikas Rathee <vrathee@redhat.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
"defaults and supports es6-module",
|
|
110
110
|
"maintained node versions"
|
|
111
111
|
],
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "0ac109442e5a6ae740af1bb340072a579e1a937f"
|
|
113
113
|
}
|