@rh-support/components 2.6.45 → 2.6.46
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.
|
@@ -193,7 +193,7 @@ export const COUNTRY_DATA = [
|
|
|
193
193
|
['Israel', ['middle-east'], 'il', '972', '... ... ....'],
|
|
194
194
|
['Italy', ['europe', 'eu-union'], 'it', '39', '... .......', 0],
|
|
195
195
|
['Jamaica', ['america', 'carribean'], 'jm', '1876'],
|
|
196
|
-
['Japan', ['asia'], 'jp', '81', '
|
|
196
|
+
['Japan', ['asia'], 'jp', '81', '... .... ....'],
|
|
197
197
|
['Jordan', ['middle-east'], 'jo', '962'],
|
|
198
198
|
[
|
|
199
199
|
'Kazakhstan',
|
|
@@ -11,6 +11,7 @@ interface IProps {
|
|
|
11
11
|
isLoading?: boolean;
|
|
12
12
|
isDisabled?: boolean;
|
|
13
13
|
shouldNotSetCountryCode?: boolean;
|
|
14
|
+
preferredCountryIso2?: string;
|
|
14
15
|
}
|
|
15
16
|
export declare const getExactCountry: (phoneNumber: string) => any[] | {
|
|
16
17
|
name: string | number | string[];
|
|
@@ -27,6 +28,18 @@ export declare const getPhoneObj: (phoneNumber: string) => {
|
|
|
27
28
|
countryCode: string;
|
|
28
29
|
phoneLine: string;
|
|
29
30
|
};
|
|
31
|
+
export declare const getCountryByIso2: (iso2: string) => {
|
|
32
|
+
name: string | number | string[];
|
|
33
|
+
regions: string | number | string[];
|
|
34
|
+
iso2: string | number | string[];
|
|
35
|
+
countryCode: string | number | string[];
|
|
36
|
+
dialCode: string | number | string[];
|
|
37
|
+
format: string;
|
|
38
|
+
priority: string | number | string[];
|
|
39
|
+
areaCode: string | number | string[];
|
|
40
|
+
phoneInitials: string[];
|
|
41
|
+
};
|
|
42
|
+
export declare const getPreferredCountryIso2FromTimezone: (timezone?: string | null) => string;
|
|
30
43
|
export declare function PhoneInput(props: IProps): React.JSX.Element;
|
|
31
44
|
export {};
|
|
32
45
|
//# sourceMappingURL=PhoneInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../src/PhoneInput/PhoneInput.tsx"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAC;AAoB3B,OAAO,KAAsC,MAAM,OAAO,CAAC;AAM3D,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,CAAC,MAAM,KAAA,KAAK,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACtE,mBAAmB,CAAC,EAAE,CAAC,MAAM,KAAA,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,OAAO,KAAA,KAAK,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uBAAuB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../src/PhoneInput/PhoneInput.tsx"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAC;AAoB3B,OAAO,KAAsC,MAAM,OAAO,CAAC;AAM3D,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,CAAC,MAAM,KAAA,KAAK,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACtE,mBAAmB,CAAC,EAAE,CAAC,MAAM,KAAA,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,OAAO,KAAA,KAAK,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACjC;AAoDD,eAAO,MAAM,eAAe,GAAI,aAAa,MAAM;;;;;;;;;;CAmClD,CAAC;AA6CF,eAAO,MAAM,WAAW,GAAI,aAAa,MAAM;;;CAgB9C,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM;;;;;;;;;;CAG5C,CAAC;AAEF,eAAO,MAAM,mCAAmC,GAAI,WAAW,MAAM,GAAG,IAAI,KAAG,MAK9E,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,qBAoSvC"}
|
|
@@ -106,6 +106,9 @@ const formatNumber = (fullPhoneNumber, localFormat) => {
|
|
|
106
106
|
pattern += localFormat[j];
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
+
if (i < (phone === null || phone === void 0 ? void 0 : phone.length)) {
|
|
110
|
+
pattern += (pattern && !pattern.endsWith(' ') ? ' ' : '') + phone.slice(i);
|
|
111
|
+
}
|
|
109
112
|
const isPatternWithPrefix = (_a = pattern === null || pattern === void 0 ? void 0 : pattern.replace(/\s+/g, '')) === null || _a === void 0 ? void 0 : _a.startsWith(PREFIX);
|
|
110
113
|
// TODO: Temporary — return pattern without forcing + prefix for portal phone without country code.
|
|
111
114
|
pattern = isPatternWithPrefix ? pattern : pattern;
|
|
@@ -131,8 +134,21 @@ export const getPhoneObj = (phoneNumber) => {
|
|
|
131
134
|
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),
|
|
132
135
|
};
|
|
133
136
|
};
|
|
137
|
+
export const getCountryByIso2 = (iso2) => {
|
|
138
|
+
if (!iso2)
|
|
139
|
+
return undefined;
|
|
140
|
+
return initializedCountries.find((country) => isEqual(country.iso2, iso2.toLowerCase()));
|
|
141
|
+
};
|
|
142
|
+
export const getPreferredCountryIso2FromTimezone = (timezone) => {
|
|
143
|
+
if (!timezone)
|
|
144
|
+
return '';
|
|
145
|
+
const tz = timezone.toLowerCase();
|
|
146
|
+
if (tz.includes('tokyo') || tz.includes('osaka') || tz.endsWith('/japan'))
|
|
147
|
+
return 'jp';
|
|
148
|
+
return '';
|
|
149
|
+
};
|
|
134
150
|
export function PhoneInput(props) {
|
|
135
|
-
const { phoneValue, countryCode, onCountryCodeChange, onPhoneValueChange, validations, setInvalid, shouldNotSetCountryCode, } = props;
|
|
151
|
+
const { phoneValue, countryCode, onCountryCodeChange, onPhoneValueChange, validations, setInvalid, shouldNotSetCountryCode, preferredCountryIso2, } = props;
|
|
136
152
|
const { t } = useTranslation();
|
|
137
153
|
const [isOpen, setIsOpen] = useState(false);
|
|
138
154
|
const [iso2, setIso2] = useState('');
|
|
@@ -182,10 +198,10 @@ export function PhoneInput(props) {
|
|
|
182
198
|
!(phone === null || phone === void 0 ? void 0 : phone.trim().startsWith(PREFIX)) &&
|
|
183
199
|
regex.test(phone) &&
|
|
184
200
|
!isEqual(phone, '-')) {
|
|
185
|
-
onPhoneValueChange(PREFIX + (phone === null || phone === void 0 ? void 0 : phone.trim()));
|
|
201
|
+
onPhoneValueChange(_formattedNumber || PREFIX + (phone === null || phone === void 0 ? void 0 : phone.trim()));
|
|
186
202
|
}
|
|
187
203
|
else {
|
|
188
|
-
onPhoneValueChange(
|
|
204
|
+
onPhoneValueChange(_formattedNumber || phone);
|
|
189
205
|
}
|
|
190
206
|
/* TODO: Revert to previous logic after phone format handling is finalized.
|
|
191
207
|
if (!phone?.trim().startsWith(PREFIX) && regex.test(phone) && !isEqual(phone, '-')) {
|
|
@@ -208,8 +224,12 @@ export function PhoneInput(props) {
|
|
|
208
224
|
: '';
|
|
209
225
|
const phoneWithoutCountryCode = (_b = removeAllChars(phoneValue)) === null || _b === void 0 ? void 0 : _b.replace(prevCountryCode, '');
|
|
210
226
|
const formattedPhone = `${PREFIX}${selection.countryCode}${phoneWithoutCountryCode}`;
|
|
211
|
-
|
|
212
|
-
|
|
227
|
+
setIso2(String(selection.iso2));
|
|
228
|
+
onCountryCodeChange && onCountryCodeChange(PREFIX + selection.dialCode.toString());
|
|
229
|
+
const localFormattedPhone = selection.format.toString();
|
|
230
|
+
const formatted = formatNumber(formattedPhone, localFormattedPhone);
|
|
231
|
+
setFormattedNumber(formatted);
|
|
232
|
+
onPhoneValueChange(formatted);
|
|
213
233
|
setIsOpen(false);
|
|
214
234
|
setActiveItem(itemId);
|
|
215
235
|
}
|
|
@@ -233,11 +253,12 @@ export function PhoneInput(props) {
|
|
|
233
253
|
React.createElement("div", { className: "pf-v6-c-menu__item-main" },
|
|
234
254
|
React.createElement("div", { className: "pf-v6-c-menu__item-text" }, t('No results found')))));
|
|
235
255
|
}
|
|
256
|
+
const displayIso2 = iso2 || preferredCountryIso2 || '';
|
|
236
257
|
const placeholder = (React.createElement("div", { className: "phone-number-select-placeholder" },
|
|
237
258
|
React.createElement("div", { className: "pf-v6-u-display-inline-flex" },
|
|
238
259
|
React.createElement("svg", { className: "flag-class-selected" },
|
|
239
|
-
React.createElement("use", { xlinkHref: `#cc_${
|
|
240
|
-
|
|
260
|
+
React.createElement("use", { xlinkHref: `#cc_${displayIso2}` })),
|
|
261
|
+
displayIso2.toUpperCase())));
|
|
241
262
|
useEffect(() => {
|
|
242
263
|
// when user types +, it will be replaced by empty string
|
|
243
264
|
if (isEqual(phoneValue === null || phoneValue === void 0 ? void 0 : phoneValue.trim(), PREFIX) && isEmpty(iso2)) {
|
|
@@ -275,8 +296,9 @@ export function PhoneInput(props) {
|
|
|
275
296
|
setIso2('');
|
|
276
297
|
onCountryCodeChange && onCountryCodeChange('');
|
|
277
298
|
}
|
|
278
|
-
else {
|
|
279
|
-
|
|
299
|
+
else if (!isEmpty(countryCode)) {
|
|
300
|
+
const normalizedCountryCode = countryCode.startsWith(PREFIX) ? countryCode : PREFIX + countryCode;
|
|
301
|
+
onCountryCodeChange && onCountryCodeChange(normalizedCountryCode);
|
|
280
302
|
}
|
|
281
303
|
// TODO: Temporary — strip leading + when shouldNotSetCountryCode is true.
|
|
282
304
|
const normalizedPhone = shouldNotSetCountryCode
|
|
@@ -294,7 +316,7 @@ export function PhoneInput(props) {
|
|
|
294
316
|
*/
|
|
295
317
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
296
318
|
}, [shouldNotSetCountryCode]);
|
|
297
|
-
const toggle = (React.createElement(MenuToggle, { ref: toggleRef, onClick: () => setIsOpen(!isOpen), isExpanded: isOpen, className: "phone-number-select", "data-tracking-id": "case-phone-number-country-code", isDisabled: props.isDisabled, "aria-label": "Country Code" }, iso2 && phoneValue !== '' ? placeholder : t('Country Code')));
|
|
319
|
+
const toggle = (React.createElement(MenuToggle, { ref: toggleRef, onClick: () => setIsOpen(!isOpen), isExpanded: isOpen, className: "phone-number-select", "data-tracking-id": "case-phone-number-country-code", isDisabled: props.isDisabled, "aria-label": "Country Code" }, (iso2 && phoneValue !== '') || preferredCountryIso2 ? placeholder : t('Country Code')));
|
|
298
320
|
const menu = (React.createElement(Menu, { ref: menuRef, onSelect: onCountrySelect, activeItemId: activeItem, isScrollable: true },
|
|
299
321
|
React.createElement(MenuSearch, null,
|
|
300
322
|
React.createElement(MenuSearchInput, null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/components",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.46",
|
|
4
4
|
"description": "Contains all reusabel components for support app",
|
|
5
5
|
"author": "Vikas Rathee <vrathee@redhat.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"@patternfly/react-icons": "6.2.1",
|
|
63
63
|
"@patternfly/react-table": "6.2.1",
|
|
64
64
|
"@rh-support/types": "2.0.31",
|
|
65
|
-
"@rh-support/user-permissions": "2.6.
|
|
66
|
-
"@rh-support/utils": "2.6.
|
|
65
|
+
"@rh-support/user-permissions": "2.6.43",
|
|
66
|
+
"@rh-support/utils": "2.6.42",
|
|
67
67
|
"dompurify": "^2.2.6",
|
|
68
68
|
"js-worker-search": "^1.4.1",
|
|
69
69
|
"lazysizes": "^5.3.2",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"defaults and supports es6-module",
|
|
104
104
|
"maintained node versions"
|
|
105
105
|
],
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "f93a43376534c539511491878802f207d215360c"
|
|
107
107
|
}
|