@sprinklrjs/spaceweb 14.14.5 → 14.14.6
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/date-input/DateInput.js +10 -5
- package/esm/date-input/DateInput.js +10 -5
- package/esm/locale/en_US.js +2 -0
- package/esm/phone-input/country-select.js +1 -0
- package/esm/phone-input/flag-container.d.ts +1 -1
- package/esm/phone-input/flag-container.js +4 -4
- package/esm/phone-input/locale.d.ts +2 -0
- package/esm/phone-input/phone-input.js +4 -2
- package/esm/phone-input/types.d.ts +1 -1
- package/esm/phone-input/utils.d.ts +3 -0
- package/esm/phone-input/utils.js +13 -0
- package/locale/en_US.js +2 -0
- package/package.json +2 -2
- package/phone-input/country-select.js +1 -0
- package/phone-input/flag-container.d.ts +1 -1
- package/phone-input/flag-container.js +3 -3
- package/phone-input/locale.d.ts +2 -0
- package/phone-input/phone-input.js +3 -1
- package/phone-input/types.d.ts +1 -1
- package/phone-input/utils.d.ts +3 -0
- package/phone-input/utils.js +16 -1
- package/tsconfig.build.tsbuildinfo +1 -1
package/date-input/DateInput.js
CHANGED
|
@@ -202,14 +202,19 @@ var DateInput = function (_a) {
|
|
|
202
202
|
}, [_onKeyDown, closeDatePicker]);
|
|
203
203
|
var onBlur = (0, useLatestCallback_1.useLatestCallback)(function (e) {
|
|
204
204
|
var _a;
|
|
205
|
-
setIsContainerFocused(false);
|
|
206
205
|
var contentEl = contentRef.current;
|
|
207
206
|
// The Year/Month selector menu (which gets autofocused on open) is rendered as a sibling of contentEl
|
|
208
207
|
// We check contentEl.parentElement(Popover.Inner) as a potential container for events
|
|
208
|
+
// While open, the popover's focus lock blurs the chevron towards a non-element (null / document)
|
|
209
|
+
if ((isOpen && !(e.relatedTarget instanceof Element)) ||
|
|
210
|
+
e.currentTarget.contains(e.relatedTarget) ||
|
|
211
|
+
((_a = contentEl === null || contentEl === void 0 ? void 0 : contentEl.parentElement) === null || _a === void 0 ? void 0 : _a.contains(e.relatedTarget)) ||
|
|
212
|
+
(contentEl === null || contentEl === void 0 ? void 0 : contentEl.contains(e.relatedTarget))) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
setIsContainerFocused(false);
|
|
209
216
|
if (isOpen) {
|
|
210
|
-
|
|
211
|
-
closeDatePicker();
|
|
212
|
-
}
|
|
217
|
+
closeDatePicker();
|
|
213
218
|
}
|
|
214
219
|
// on blur, clear the input if the value is malformed
|
|
215
220
|
if (!value && inputValue) {
|
|
@@ -230,7 +235,7 @@ var DateInput = function (_a) {
|
|
|
230
235
|
else
|
|
231
236
|
we close the Popover.
|
|
232
237
|
*/
|
|
233
|
-
getTimeRangesForDate: getTimeRangesForDate, disableTimezoneSwitch: disableTimezoneSwitch }, contentProps), timezoneAdaptedValue === null || timezoneAdaptedValue === void 0 ? void 0 : timezoneAdaptedValue.getTime()) }, popoverProps, { children: (0, jsx_runtime_1.jsx)(Root, tslib_1.__assign({}, rootProps, { children: (0, jsx_runtime_1.jsx)(Input, tslib_1.__assign({ value: inputValue, onChange: handleInputChange, disabled: restProps.disabled, onFocus: onFocus,
|
|
238
|
+
getTimeRangesForDate: getTimeRangesForDate, disableTimezoneSwitch: disableTimezoneSwitch }, contentProps), timezoneAdaptedValue === null || timezoneAdaptedValue === void 0 ? void 0 : timezoneAdaptedValue.getTime()) }, popoverProps, { children: (0, jsx_runtime_1.jsx)(Root, tslib_1.__assign({ onBlur: onBlur }, rootProps, { children: (0, jsx_runtime_1.jsx)(Input, tslib_1.__assign({ value: inputValue, onChange: handleInputChange, disabled: restProps.disabled, onFocus: onFocus, onKeyDown: handleKeyDown }, restProps, { placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : formatString.toLowerCase(), intent: error ? 'error' : intent }, inputProps, { inputRef: (0, useCombinedRef_1.combineRefs)(inputRef, inputProps.ref) })) })) })));
|
|
234
239
|
};
|
|
235
240
|
exports.DateInput = DateInput;
|
|
236
241
|
exports.DateInput.__standard = 'Component';
|
|
@@ -199,14 +199,19 @@ export var DateInput = function (_a) {
|
|
|
199
199
|
}, [_onKeyDown, closeDatePicker]);
|
|
200
200
|
var onBlur = useLatestCallback(function (e) {
|
|
201
201
|
var _a;
|
|
202
|
-
setIsContainerFocused(false);
|
|
203
202
|
var contentEl = contentRef.current;
|
|
204
203
|
// The Year/Month selector menu (which gets autofocused on open) is rendered as a sibling of contentEl
|
|
205
204
|
// We check contentEl.parentElement(Popover.Inner) as a potential container for events
|
|
205
|
+
// While open, the popover's focus lock blurs the chevron towards a non-element (null / document)
|
|
206
|
+
if ((isOpen && !(e.relatedTarget instanceof Element)) ||
|
|
207
|
+
e.currentTarget.contains(e.relatedTarget) ||
|
|
208
|
+
((_a = contentEl === null || contentEl === void 0 ? void 0 : contentEl.parentElement) === null || _a === void 0 ? void 0 : _a.contains(e.relatedTarget)) ||
|
|
209
|
+
(contentEl === null || contentEl === void 0 ? void 0 : contentEl.contains(e.relatedTarget))) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
setIsContainerFocused(false);
|
|
206
213
|
if (isOpen) {
|
|
207
|
-
|
|
208
|
-
closeDatePicker();
|
|
209
|
-
}
|
|
214
|
+
closeDatePicker();
|
|
210
215
|
}
|
|
211
216
|
// on blur, clear the input if the value is malformed
|
|
212
217
|
if (!value && inputValue) {
|
|
@@ -227,6 +232,6 @@ export var DateInput = function (_a) {
|
|
|
227
232
|
else
|
|
228
233
|
we close the Popover.
|
|
229
234
|
*/
|
|
230
|
-
getTimeRangesForDate: getTimeRangesForDate, disableTimezoneSwitch: disableTimezoneSwitch }, contentProps), timezoneAdaptedValue === null || timezoneAdaptedValue === void 0 ? void 0 : timezoneAdaptedValue.getTime()) }, popoverProps, { children: _jsx(Root, __assign({}, rootProps, { children: _jsx(Input, __assign({ value: inputValue, onChange: handleInputChange, disabled: restProps.disabled, onFocus: onFocus,
|
|
235
|
+
getTimeRangesForDate: getTimeRangesForDate, disableTimezoneSwitch: disableTimezoneSwitch }, contentProps), timezoneAdaptedValue === null || timezoneAdaptedValue === void 0 ? void 0 : timezoneAdaptedValue.getTime()) }, popoverProps, { children: _jsx(Root, __assign({ onBlur: onBlur }, rootProps, { children: _jsx(Input, __assign({ value: inputValue, onChange: handleInputChange, disabled: restProps.disabled, onFocus: onFocus, onKeyDown: handleKeyDown }, restProps, { placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : formatString.toLowerCase(), intent: error ? 'error' : intent }, inputProps, { inputRef: combineRefs(inputRef, inputProps.ref) })) })) })));
|
|
231
236
|
};
|
|
232
237
|
DateInput.__standard = 'Component';
|
package/esm/locale/en_US.js
CHANGED
|
@@ -115,6 +115,8 @@ export var DEFAULT_LOCALE = {
|
|
|
115
115
|
countrySelectPlaceholder: 'Search',
|
|
116
116
|
inputAriaLabel: 'Please enter a phone number without the country dial code.',
|
|
117
117
|
flagContainerAriaLabel: 'Press the enter key to navigate country select dropdown. Press the up or down arrow key to interact with the dropdown and select a country. Press the escape button to close the dropdown.',
|
|
118
|
+
flagContainerSelectedAriaLabel: '${countryName} ${dialCode} selected.',
|
|
119
|
+
inputSelectedDialCodeAriaLabel: '${dialCode} selected.',
|
|
118
120
|
},
|
|
119
121
|
menu: {
|
|
120
122
|
nestedMenuItemAriaDescription: 'You are currently at an item that opens a nested menu. Press right arrow or spacebar to enter that element and left arrow or escape to return.',
|
|
@@ -83,6 +83,7 @@ var CountrySelect = function (props) {
|
|
|
83
83
|
size: size,
|
|
84
84
|
disabled: disabled,
|
|
85
85
|
value: value,
|
|
86
|
+
mapIsoToLabel: mapIsoToLabel,
|
|
86
87
|
overrides: _pick(overrides, ['FlagContainer']),
|
|
87
88
|
};
|
|
88
89
|
return (_jsx(Select, __assign({ type: "overlay", options: countries !== null && countries !== void 0 ? countries : COUNTRY_SELECT_OPTIONS, value: [value.country], onChange: function (params) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare const FlagContainer: import("react").ForwardRefExoticComponent<Pick<import("./types").CountrySelectContainerProps, "value" | "size" | "disabled"> & {
|
|
2
|
+
declare const FlagContainer: import("react").ForwardRefExoticComponent<Pick<import("./types").CountrySelectContainerProps, "value" | "size" | "disabled" | "mapIsoToLabel"> & {
|
|
3
3
|
overrides?: Pick<import("./types").PhoneInputOverrides, "FlagContainer"> | undefined;
|
|
4
4
|
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
5
5
|
export default FlagContainer;
|
|
@@ -4,20 +4,20 @@ import { forwardRef } from 'react';
|
|
|
4
4
|
import { Button as DefaultButton } from '../button';
|
|
5
5
|
import { useOverrides } from '../overrides';
|
|
6
6
|
import { useLocale } from '../locale';
|
|
7
|
-
import { iso2FlagEmoji } from './utils';
|
|
7
|
+
import { getFlagContainerAriaLabel, iso2FlagEmoji } from './utils';
|
|
8
8
|
import { add$props } from '../helpers';
|
|
9
9
|
import { flagContainerCVA } from './cvaConfigs';
|
|
10
10
|
import { getFlagContainerOverrides } from './styled-components';
|
|
11
11
|
var FlagContainer = forwardRef(function (props, ref) {
|
|
12
|
-
var inputSize = props.size, country = props.value.country, overrides = props.overrides, rest = __rest(props, ["size", "value", "overrides"]);
|
|
12
|
+
var inputSize = props.size, country = props.value.country, mapIsoToLabel = props.mapIsoToLabel, overrides = props.overrides, rest = __rest(props, ["size", "value", "mapIsoToLabel", "overrides"]);
|
|
13
13
|
var iso = country.id;
|
|
14
14
|
var locale = useLocale();
|
|
15
15
|
var sharedProps = add$props({ iso: iso, inputSize: inputSize });
|
|
16
16
|
var _a = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.FlagContainer, DefaultButton), 2), Button = _a[0], buttonProps = _a[1];
|
|
17
|
-
return (_jsx(Button, __assign({ "aria-label": locale.phoneInput
|
|
17
|
+
return (_jsx(Button, __assign({ "aria-label": getFlagContainerAriaLabel(locale.phoneInput, country, mapIsoToLabel), variant: "minimal", size: "xxxs", type: "button", className: [
|
|
18
18
|
'min-w-0 spr-ui-05 px-2 py-0.5 text-16 rounded-4 mr-0',
|
|
19
19
|
flagContainerCVA,
|
|
20
|
-
// @ts-
|
|
20
|
+
// @ts-expect-error -- ClassName does not include CSSStylesStyleFn (TS2345)
|
|
21
21
|
getFlagContainerOverrides,
|
|
22
22
|
], "data-iso": iso, ref: ref }, sharedProps, buttonProps, rest, { children: iso2FlagEmoji(iso) })));
|
|
23
23
|
});
|
|
@@ -5,7 +5,7 @@ import _pick from 'lodash/pick';
|
|
|
5
5
|
import { Input as DefaultInput } from '../input';
|
|
6
6
|
import CountrySelectContainer from './country-select-container';
|
|
7
7
|
import { getRootClasses, getInputClasses } from './styled-components';
|
|
8
|
-
import { getDefaultValue, sanitize } from './utils';
|
|
8
|
+
import { getDefaultValue, getPhoneInputAriaLabel, sanitize } from './utils';
|
|
9
9
|
import { useOverrides, mergeOverrides } from '../overrides';
|
|
10
10
|
import { useLocale } from '../locale';
|
|
11
11
|
import defaultProps from './default-props';
|
|
@@ -54,7 +54,9 @@ var PhoneInput = function (props) {
|
|
|
54
54
|
},
|
|
55
55
|
}, overrides);
|
|
56
56
|
var _d = __read(useOverrides(mergedOverrides === null || mergedOverrides === void 0 ? void 0 : mergedOverrides.Input, DefaultInput), 2), Input = _d[0], inputProps = _d[1];
|
|
57
|
-
return (_jsx(Input, __assign({ "aria-label":
|
|
57
|
+
return (_jsx(Input, __assign({ "aria-label": value.country
|
|
58
|
+
? getPhoneInputAriaLabel(locale.phoneInput, value.country.dialCode)
|
|
59
|
+
: locale.phoneInput.inputAriaLabel, size: size, variant: variant, intent: intent, disabled: disabled, onChange: function (e) {
|
|
58
60
|
var number = sanitize(e.currentTarget.value);
|
|
59
61
|
if (onChange) {
|
|
60
62
|
onChange(__assign(__assign({}, value), { phoneNumber: number }));
|
|
@@ -67,7 +67,7 @@ export type CountrySelectContainerProps = Required<Pick<PhoneInputProps, 'size'
|
|
|
67
67
|
export type CountrySelectProps = Omit<CountrySelectContainerProps, 'overrides'> & {
|
|
68
68
|
overrides?: Pick<PhoneInputOverrides, 'CountrySelect' | 'FlagContainer'>;
|
|
69
69
|
};
|
|
70
|
-
export type FlagContainerProps = Pick<CountrySelectContainerProps, 'size' | 'disabled' | 'value'> & {
|
|
70
|
+
export type FlagContainerProps = Pick<CountrySelectContainerProps, 'size' | 'disabled' | 'value' | 'mapIsoToLabel'> & {
|
|
71
71
|
overrides?: Pick<PhoneInputOverrides, 'FlagContainer'>;
|
|
72
72
|
};
|
|
73
73
|
export type DialCodeProps = Omit<CountrySelectContainerProps, 'overrides'> & {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Value as ValueT } from '../select/types';
|
|
2
2
|
import type { Value, Country, CustomCountryLabel } from './types';
|
|
3
|
+
import type { PhoneInputLocale } from './locale';
|
|
3
4
|
export declare const iso2FlagEmoji: (iso: string) => string | undefined;
|
|
4
5
|
export declare const sanitize: (value?: string) => string;
|
|
5
6
|
export declare const getPhoneNumberWithCountryDialCode: (value: Value) => string | undefined;
|
|
@@ -35,3 +36,5 @@ export declare const getCountryLabelParts: ({ label, nativeName, nativeLang }: C
|
|
|
35
36
|
* visible text is flattened into `primaryName` so display stays correct without invalid markup.
|
|
36
37
|
*/
|
|
37
38
|
export declare const resolveCountryLabelParts: (country: Country, mapIsoToLabel?: ((iso: string) => string | CustomCountryLabel) | undefined) => CountryLabelParts;
|
|
39
|
+
export declare const getFlagContainerAriaLabel: (locale: PhoneInputLocale, country: Country, mapIsoToLabel?: ((iso: string) => string | CustomCountryLabel) | undefined) => string;
|
|
40
|
+
export declare const getPhoneInputAriaLabel: (locale: PhoneInputLocale, dialCode: string) => string;
|
package/esm/phone-input/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __assign, __read, __spreadArray } from "tslib";
|
|
2
2
|
import _isEmpty from 'lodash/isEmpty';
|
|
3
3
|
import { filterOptions } from '../select/utils/default-filter-options';
|
|
4
|
+
import getInterpolatedString from '../baseui/helpers/i18n-interpolation';
|
|
4
5
|
import { COUNTRIES, ISO_REGEX, ISO_TO_FLAG_OFFSET } from './constants';
|
|
5
6
|
import { defaultValue } from './default-props';
|
|
6
7
|
export var iso2FlagEmoji = function (iso) {
|
|
@@ -79,3 +80,15 @@ export var resolveCountryLabelParts = function (country, mapIsoToLabel) {
|
|
|
79
80
|
nativeLang: mapped.nativeLang,
|
|
80
81
|
};
|
|
81
82
|
};
|
|
83
|
+
export var getFlagContainerAriaLabel = function (locale, country, mapIsoToLabel) {
|
|
84
|
+
var primaryName = resolveCountryLabelParts(country, mapIsoToLabel).primaryName;
|
|
85
|
+
var selected = getInterpolatedString(locale.flagContainerSelectedAriaLabel, {
|
|
86
|
+
countryName: primaryName,
|
|
87
|
+
dialCode: country.dialCode,
|
|
88
|
+
});
|
|
89
|
+
return "".concat(selected, " ").concat(locale.flagContainerAriaLabel);
|
|
90
|
+
};
|
|
91
|
+
export var getPhoneInputAriaLabel = function (locale, dialCode) {
|
|
92
|
+
var selected = getInterpolatedString(locale.inputSelectedDialCodeAriaLabel, { dialCode: dialCode });
|
|
93
|
+
return "".concat(locale.inputAriaLabel, " ").concat(selected);
|
|
94
|
+
};
|
package/locale/en_US.js
CHANGED
|
@@ -118,6 +118,8 @@ exports.DEFAULT_LOCALE = {
|
|
|
118
118
|
countrySelectPlaceholder: 'Search',
|
|
119
119
|
inputAriaLabel: 'Please enter a phone number without the country dial code.',
|
|
120
120
|
flagContainerAriaLabel: 'Press the enter key to navigate country select dropdown. Press the up or down arrow key to interact with the dropdown and select a country. Press the escape button to close the dropdown.',
|
|
121
|
+
flagContainerSelectedAriaLabel: '${countryName} ${dialCode} selected.',
|
|
122
|
+
inputSelectedDialCodeAriaLabel: '${dialCode} selected.',
|
|
121
123
|
},
|
|
122
124
|
menu: {
|
|
123
125
|
nestedMenuItemAriaDescription: 'You are currently at an item that opens a nested menu. Press right arrow or spacebar to enter that element and left arrow or escape to return.',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprinklrjs/spaceweb",
|
|
3
|
-
"version": "14.14.
|
|
3
|
+
"version": "14.14.6",
|
|
4
4
|
"description": "Components for SpaceWeb",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"typescript": "~5.0.0"
|
|
103
103
|
},
|
|
104
104
|
"peerDependencies": {
|
|
105
|
-
"@sprinklrjs/spaceweb-themes": "14.14.
|
|
105
|
+
"@sprinklrjs/spaceweb-themes": "14.14.6",
|
|
106
106
|
"react": ">=17.0.2 <19.0.0",
|
|
107
107
|
"react-dom": ">=17.0.2 <19.0.0"
|
|
108
108
|
}
|
|
@@ -85,6 +85,7 @@ var CountrySelect = function (props) {
|
|
|
85
85
|
size: size,
|
|
86
86
|
disabled: disabled,
|
|
87
87
|
value: value,
|
|
88
|
+
mapIsoToLabel: mapIsoToLabel,
|
|
88
89
|
overrides: (0, pick_1.default)(overrides, ['FlagContainer']),
|
|
89
90
|
};
|
|
90
91
|
return ((0, jsx_runtime_1.jsx)(Select, tslib_1.__assign({ type: "overlay", options: countries !== null && countries !== void 0 ? countries : constants_1.COUNTRY_SELECT_OPTIONS, value: [value.country], onChange: function (params) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare const FlagContainer: import("react").ForwardRefExoticComponent<Pick<import("./types").CountrySelectContainerProps, "value" | "size" | "disabled"> & {
|
|
2
|
+
declare const FlagContainer: import("react").ForwardRefExoticComponent<Pick<import("./types").CountrySelectContainerProps, "value" | "size" | "disabled" | "mapIsoToLabel"> & {
|
|
3
3
|
overrides?: Pick<import("./types").PhoneInputOverrides, "FlagContainer"> | undefined;
|
|
4
4
|
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
5
5
|
export default FlagContainer;
|
|
@@ -11,15 +11,15 @@ var helpers_1 = require("../helpers");
|
|
|
11
11
|
var cvaConfigs_1 = require("./cvaConfigs");
|
|
12
12
|
var styled_components_1 = require("./styled-components");
|
|
13
13
|
var FlagContainer = (0, react_1.forwardRef)(function (props, ref) {
|
|
14
|
-
var inputSize = props.size, country = props.value.country, overrides = props.overrides, rest = tslib_1.__rest(props, ["size", "value", "overrides"]);
|
|
14
|
+
var inputSize = props.size, country = props.value.country, mapIsoToLabel = props.mapIsoToLabel, overrides = props.overrides, rest = tslib_1.__rest(props, ["size", "value", "mapIsoToLabel", "overrides"]);
|
|
15
15
|
var iso = country.id;
|
|
16
16
|
var locale = (0, locale_1.useLocale)();
|
|
17
17
|
var sharedProps = (0, helpers_1.add$props)({ iso: iso, inputSize: inputSize });
|
|
18
18
|
var _a = tslib_1.__read((0, overrides_1.useOverrides)(overrides === null || overrides === void 0 ? void 0 : overrides.FlagContainer, button_1.Button), 2), Button = _a[0], buttonProps = _a[1];
|
|
19
|
-
return ((0, jsx_runtime_1.jsx)(Button, tslib_1.__assign({ "aria-label": locale.phoneInput
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(Button, tslib_1.__assign({ "aria-label": (0, utils_1.getFlagContainerAriaLabel)(locale.phoneInput, country, mapIsoToLabel), variant: "minimal", size: "xxxs", type: "button", className: [
|
|
20
20
|
'min-w-0 spr-ui-05 px-2 py-0.5 text-16 rounded-4 mr-0',
|
|
21
21
|
cvaConfigs_1.flagContainerCVA,
|
|
22
|
-
// @ts-
|
|
22
|
+
// @ts-expect-error -- ClassName does not include CSSStylesStyleFn (TS2345)
|
|
23
23
|
styled_components_1.getFlagContainerOverrides,
|
|
24
24
|
], "data-iso": iso, ref: ref }, sharedProps, buttonProps, rest, { children: (0, utils_1.iso2FlagEmoji)(iso) })));
|
|
25
25
|
});
|
package/phone-input/locale.d.ts
CHANGED
|
@@ -56,7 +56,9 @@ var PhoneInput = function (props) {
|
|
|
56
56
|
},
|
|
57
57
|
}, overrides);
|
|
58
58
|
var _d = tslib_1.__read((0, overrides_1.useOverrides)(mergedOverrides === null || mergedOverrides === void 0 ? void 0 : mergedOverrides.Input, input_1.Input), 2), Input = _d[0], inputProps = _d[1];
|
|
59
|
-
return ((0, jsx_runtime_1.jsx)(Input, tslib_1.__assign({ "aria-label":
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)(Input, tslib_1.__assign({ "aria-label": value.country
|
|
60
|
+
? (0, utils_1.getPhoneInputAriaLabel)(locale.phoneInput, value.country.dialCode)
|
|
61
|
+
: locale.phoneInput.inputAriaLabel, size: size, variant: variant, intent: intent, disabled: disabled, onChange: function (e) {
|
|
60
62
|
var number = (0, utils_1.sanitize)(e.currentTarget.value);
|
|
61
63
|
if (onChange) {
|
|
62
64
|
onChange(tslib_1.__assign(tslib_1.__assign({}, value), { phoneNumber: number }));
|
package/phone-input/types.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export type CountrySelectContainerProps = Required<Pick<PhoneInputProps, 'size'
|
|
|
67
67
|
export type CountrySelectProps = Omit<CountrySelectContainerProps, 'overrides'> & {
|
|
68
68
|
overrides?: Pick<PhoneInputOverrides, 'CountrySelect' | 'FlagContainer'>;
|
|
69
69
|
};
|
|
70
|
-
export type FlagContainerProps = Pick<CountrySelectContainerProps, 'size' | 'disabled' | 'value'> & {
|
|
70
|
+
export type FlagContainerProps = Pick<CountrySelectContainerProps, 'size' | 'disabled' | 'value' | 'mapIsoToLabel'> & {
|
|
71
71
|
overrides?: Pick<PhoneInputOverrides, 'FlagContainer'>;
|
|
72
72
|
};
|
|
73
73
|
export type DialCodeProps = Omit<CountrySelectContainerProps, 'overrides'> & {
|
package/phone-input/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Value as ValueT } from '../select/types';
|
|
2
2
|
import type { Value, Country, CustomCountryLabel } from './types';
|
|
3
|
+
import type { PhoneInputLocale } from './locale';
|
|
3
4
|
export declare const iso2FlagEmoji: (iso: string) => string | undefined;
|
|
4
5
|
export declare const sanitize: (value?: string) => string;
|
|
5
6
|
export declare const getPhoneNumberWithCountryDialCode: (value: Value) => string | undefined;
|
|
@@ -35,3 +36,5 @@ export declare const getCountryLabelParts: ({ label, nativeName, nativeLang }: C
|
|
|
35
36
|
* visible text is flattened into `primaryName` so display stays correct without invalid markup.
|
|
36
37
|
*/
|
|
37
38
|
export declare const resolveCountryLabelParts: (country: Country, mapIsoToLabel?: ((iso: string) => string | CustomCountryLabel) | undefined) => CountryLabelParts;
|
|
39
|
+
export declare const getFlagContainerAriaLabel: (locale: PhoneInputLocale, country: Country, mapIsoToLabel?: ((iso: string) => string | CustomCountryLabel) | undefined) => string;
|
|
40
|
+
export declare const getPhoneInputAriaLabel: (locale: PhoneInputLocale, dialCode: string) => string;
|
package/phone-input/utils.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveCountryLabelParts = exports.getCountryLabelParts = exports.getDefaultValue = exports.countrySelectFilterOptions = exports.getPhoneNumberWithCountryDialCode = exports.sanitize = exports.iso2FlagEmoji = void 0;
|
|
3
|
+
exports.getPhoneInputAriaLabel = exports.getFlagContainerAriaLabel = exports.resolveCountryLabelParts = exports.getCountryLabelParts = exports.getDefaultValue = exports.countrySelectFilterOptions = exports.getPhoneNumberWithCountryDialCode = exports.sanitize = exports.iso2FlagEmoji = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
6
6
|
var default_filter_options_1 = require("../select/utils/default-filter-options");
|
|
7
|
+
var i18n_interpolation_1 = tslib_1.__importDefault(require("../baseui/helpers/i18n-interpolation"));
|
|
7
8
|
var constants_1 = require("./constants");
|
|
8
9
|
var default_props_1 = require("./default-props");
|
|
9
10
|
var iso2FlagEmoji = function (iso) {
|
|
@@ -89,3 +90,17 @@ var resolveCountryLabelParts = function (country, mapIsoToLabel) {
|
|
|
89
90
|
};
|
|
90
91
|
};
|
|
91
92
|
exports.resolveCountryLabelParts = resolveCountryLabelParts;
|
|
93
|
+
var getFlagContainerAriaLabel = function (locale, country, mapIsoToLabel) {
|
|
94
|
+
var primaryName = (0, exports.resolveCountryLabelParts)(country, mapIsoToLabel).primaryName;
|
|
95
|
+
var selected = (0, i18n_interpolation_1.default)(locale.flagContainerSelectedAriaLabel, {
|
|
96
|
+
countryName: primaryName,
|
|
97
|
+
dialCode: country.dialCode,
|
|
98
|
+
});
|
|
99
|
+
return "".concat(selected, " ").concat(locale.flagContainerAriaLabel);
|
|
100
|
+
};
|
|
101
|
+
exports.getFlagContainerAriaLabel = getFlagContainerAriaLabel;
|
|
102
|
+
var getPhoneInputAriaLabel = function (locale, dialCode) {
|
|
103
|
+
var selected = (0, i18n_interpolation_1.default)(locale.inputSelectedDialCodeAriaLabel, { dialCode: dialCode });
|
|
104
|
+
return "".concat(locale.inputAriaLabel, " ").concat(selected);
|
|
105
|
+
};
|
|
106
|
+
exports.getPhoneInputAriaLabel = getPhoneInputAriaLabel;
|