@sprinklrjs/spaceweb 14.14.4 → 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 -3
- package/esm/date-input/DateInput.js +10 -3
- package/esm/input/enhancer-button.d.ts +1 -0
- package/esm/input/enhancer-button.js +6 -1
- 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/esm/singleton/createSingletonInstance.d.ts +9 -0
- package/esm/singleton/createSingletonInstance.js +26 -0
- package/esm/styleEngine/styleEngine.js +24 -23
- package/input/enhancer-button.d.ts +1 -0
- package/input/enhancer-button.js +6 -1
- package/locale/en_US.js +2 -0
- package/package.json +4 -3
- 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/singleton/createSingletonInstance.d.ts +9 -0
- package/singleton/createSingletonInstance.js +32 -0
- package/styleEngine/styleEngine.js +24 -23
- package/tsconfig.build.tsbuildinfo +1 -1
package/date-input/DateInput.js
CHANGED
|
@@ -202,11 +202,18 @@ 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
|
|
209
|
-
|
|
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);
|
|
216
|
+
if (isOpen) {
|
|
210
217
|
closeDatePicker();
|
|
211
218
|
}
|
|
212
219
|
// on blur, clear the input if the value is malformed
|
|
@@ -228,7 +235,7 @@ var DateInput = function (_a) {
|
|
|
228
235
|
else
|
|
229
236
|
we close the Popover.
|
|
230
237
|
*/
|
|
231
|
-
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) })) })) })));
|
|
232
239
|
};
|
|
233
240
|
exports.DateInput = DateInput;
|
|
234
241
|
exports.DateInput.__standard = 'Component';
|
|
@@ -199,11 +199,18 @@ 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
|
|
206
|
-
|
|
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);
|
|
213
|
+
if (isOpen) {
|
|
207
214
|
closeDatePicker();
|
|
208
215
|
}
|
|
209
216
|
// on blur, clear the input if the value is malformed
|
|
@@ -225,6 +232,6 @@ export var DateInput = function (_a) {
|
|
|
225
232
|
else
|
|
226
233
|
we close the Popover.
|
|
227
234
|
*/
|
|
228
|
-
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) })) })) })));
|
|
229
236
|
};
|
|
230
237
|
DateInput.__standard = 'Component';
|
|
@@ -9,6 +9,7 @@ export type FieldEnhancerSharedProps = {
|
|
|
9
9
|
$intent?: Intent;
|
|
10
10
|
$isFocused?: boolean;
|
|
11
11
|
$isPseudoFocused?: boolean;
|
|
12
|
+
$isSelected?: boolean;
|
|
12
13
|
};
|
|
13
14
|
export type FieldEnhancerButtonProps = Omit<ButtonProps, 'size' | 'disabled' | 'intent'>;
|
|
14
15
|
export type FieldEnhancerButtonConfig = FieldEnhancerButtonProps | ((sharedProps: FieldEnhancerSharedProps) => FieldEnhancerButtonProps);
|
|
@@ -34,7 +34,12 @@ export var renderFieldEnhancerButton = function (position, sharedProps, config)
|
|
|
34
34
|
BaseButton: {
|
|
35
35
|
className: [
|
|
36
36
|
'h-full min-h-0 spr-bg-secondary hover:spr-bg-secondary focus:spr-bg-secondary',
|
|
37
|
-
|
|
37
|
+
function (_, _a) {
|
|
38
|
+
var $isSelected = _a.$isSelected;
|
|
39
|
+
return isStart
|
|
40
|
+
? "rounded-r-0 ".concat(!$isSelected ? 'border-r-[--sw-border-right-color]' : '')
|
|
41
|
+
: "rounded-l-0 ".concat(!$isSelected ? 'border-l-[--sw-border-left-color]' : '');
|
|
42
|
+
},
|
|
38
43
|
],
|
|
39
44
|
// @ts-ignore -- Variable needed for styling
|
|
40
45
|
style: isStart ? { '--sw-border-right-color': 'transparent' } : { '--sw-border-left-color': 'transparent' },
|
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
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file should be used within spaceweb repository only. Using this outside may lead to breaking behavior.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum SingletonInstanceIdentifier {
|
|
5
|
+
STYLETRON_ENGINE = "STYLETRON_ENGINE"
|
|
6
|
+
}
|
|
7
|
+
export declare function createSingletonInstance<T>(instanceGetter: () => T, identifier: SingletonInstanceIdentifier): T;
|
|
8
|
+
export declare function getSingletonInstance<T>(identifier: string): T | undefined;
|
|
9
|
+
export declare function setSingletonInstance<T>(identifier: string, instance: T): T;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file should be used within spaceweb repository only. Using this outside may lead to breaking behavior.
|
|
3
|
+
*/
|
|
4
|
+
/*
|
|
5
|
+
* Please refer the following doc - https://sprinklr.atlassian.net/wiki/spaces/Frontend/pages/5506367561/ModuleFederation+Handbook#Using-Singleton-Context
|
|
6
|
+
*/
|
|
7
|
+
export var SingletonInstanceIdentifier;
|
|
8
|
+
(function (SingletonInstanceIdentifier) {
|
|
9
|
+
SingletonInstanceIdentifier["STYLETRON_ENGINE"] = "STYLETRON_ENGINE";
|
|
10
|
+
})(SingletonInstanceIdentifier || (SingletonInstanceIdentifier = {}));
|
|
11
|
+
var allInstances = {};
|
|
12
|
+
export function createSingletonInstance(instanceGetter, identifier) {
|
|
13
|
+
if (allInstances[identifier]) {
|
|
14
|
+
return allInstances[identifier];
|
|
15
|
+
}
|
|
16
|
+
var singletonInstance = instanceGetter();
|
|
17
|
+
allInstances[identifier] = singletonInstance;
|
|
18
|
+
return singletonInstance;
|
|
19
|
+
}
|
|
20
|
+
export function getSingletonInstance(identifier) {
|
|
21
|
+
return allInstances[identifier];
|
|
22
|
+
}
|
|
23
|
+
export function setSingletonInstance(identifier, instance) {
|
|
24
|
+
allInstances[identifier] = instance;
|
|
25
|
+
return instance;
|
|
26
|
+
}
|
|
@@ -4,6 +4,7 @@ import { useMemo } from 'react';
|
|
|
4
4
|
import { Client, Server } from 'styletron-engine-atomic';
|
|
5
5
|
import { DebugEngine, Provider as StyletronProvider } from 'styletron-react';
|
|
6
6
|
import { useDocument } from '../spacewebProvider/DocumentProvider';
|
|
7
|
+
import { getSingletonInstance, setSingletonInstance, SingletonInstanceIdentifier, } from '@sprinklrjs/spaceweb/singleton/createSingletonInstance';
|
|
7
8
|
export var SPACEWEB_STYLE_PREFIX = 'sw--';
|
|
8
9
|
export var SPACEWEB_STYLE_CONTAINER_ID = 'spaceweb-style-cache';
|
|
9
10
|
export var isServer = typeof window === 'undefined';
|
|
@@ -13,9 +14,13 @@ var NoopDebugEngine = /** @class */ (function () {
|
|
|
13
14
|
}
|
|
14
15
|
return NoopDebugEngine;
|
|
15
16
|
}());
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
var getStyletron = function () {
|
|
18
|
+
return getSingletonInstance(SingletonInstanceIdentifier.STYLETRON_ENGINE);
|
|
19
|
+
};
|
|
20
|
+
var setStyletron = function (engine) {
|
|
21
|
+
return setSingletonInstance(SingletonInstanceIdentifier.STYLETRON_ENGINE, engine);
|
|
22
|
+
};
|
|
23
|
+
var hasStyletron = function () { return typeof getStyletron() !== 'undefined'; };
|
|
19
24
|
// Throws and error if not called from the server.
|
|
20
25
|
var ensureServer = function () {
|
|
21
26
|
if (!isServer) {
|
|
@@ -38,26 +43,22 @@ export var hydrate = function (ownerDocument) {
|
|
|
38
43
|
};
|
|
39
44
|
// Gets isomorphic Styletron engine.
|
|
40
45
|
export var getStyleEngine = function (ownerDocument, nonce) {
|
|
46
|
+
var styletron = getStyletron();
|
|
41
47
|
if (isServer) {
|
|
42
|
-
|
|
43
|
-
return styletron;
|
|
44
|
-
styletron = new Server({ prefix: SPACEWEB_STYLE_PREFIX });
|
|
48
|
+
return styletron !== null && styletron !== void 0 ? styletron : setStyletron(new Server({ prefix: SPACEWEB_STYLE_PREFIX }));
|
|
45
49
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return styletron;
|
|
51
|
-
}
|
|
52
|
-
// adds a style tag in document.head to make sure only one instance of styletron is created in an app.
|
|
53
|
-
appendCacheContainer(ownerDocument, nonce);
|
|
54
|
-
styletron = new Client({
|
|
55
|
-
hydrate: hydrate(ownerDocument),
|
|
56
|
-
prefix: SPACEWEB_STYLE_PREFIX,
|
|
57
|
-
container: ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.head,
|
|
58
|
-
});
|
|
50
|
+
var doc = ownerDocument || document;
|
|
51
|
+
var el = doc.getElementById(SPACEWEB_STYLE_CONTAINER_ID);
|
|
52
|
+
if (el && styletron) {
|
|
53
|
+
return styletron;
|
|
59
54
|
}
|
|
60
|
-
|
|
55
|
+
// adds a style tag in document.head to make sure only one instance of styletron is created in an app.
|
|
56
|
+
appendCacheContainer(ownerDocument, nonce);
|
|
57
|
+
return setStyletron(new Client({
|
|
58
|
+
hydrate: hydrate(ownerDocument),
|
|
59
|
+
prefix: SPACEWEB_STYLE_PREFIX,
|
|
60
|
+
container: ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.head,
|
|
61
|
+
}));
|
|
61
62
|
};
|
|
62
63
|
// @ts-ignore
|
|
63
64
|
StyletronProvider.displayName = 'StyletronProvider';
|
|
@@ -72,17 +73,17 @@ StyleProvider.displayName = 'StyleProvider';
|
|
|
72
73
|
export var getStylesheets = function () {
|
|
73
74
|
ensureServer();
|
|
74
75
|
ensureEngine();
|
|
75
|
-
return
|
|
76
|
+
return getStyletron().getStylesheets();
|
|
76
77
|
};
|
|
77
78
|
// Gets hydration stylesheets HTML code as string.
|
|
78
79
|
export var getStylesheetsHtml = function () {
|
|
79
80
|
ensureServer();
|
|
80
81
|
ensureEngine();
|
|
81
|
-
return
|
|
82
|
+
return getStyletron().getStylesheetsHtml();
|
|
82
83
|
};
|
|
83
84
|
export var deprecatedRenderKeyframes = function (keyframes) {
|
|
84
85
|
ensureEngine();
|
|
85
|
-
return
|
|
86
|
+
return getStyletron().renderKeyframes(keyframes);
|
|
86
87
|
};
|
|
87
88
|
// Appends cache styles to the DOM and returns element's instance.
|
|
88
89
|
export var appendCacheContainer = function (ownerDocument, nonce) {
|
|
@@ -9,6 +9,7 @@ export type FieldEnhancerSharedProps = {
|
|
|
9
9
|
$intent?: Intent;
|
|
10
10
|
$isFocused?: boolean;
|
|
11
11
|
$isPseudoFocused?: boolean;
|
|
12
|
+
$isSelected?: boolean;
|
|
12
13
|
};
|
|
13
14
|
export type FieldEnhancerButtonProps = Omit<ButtonProps, 'size' | 'disabled' | 'intent'>;
|
|
14
15
|
export type FieldEnhancerButtonConfig = FieldEnhancerButtonProps | ((sharedProps: FieldEnhancerSharedProps) => FieldEnhancerButtonProps);
|
package/input/enhancer-button.js
CHANGED
|
@@ -40,7 +40,12 @@ var renderFieldEnhancerButton = function (position, sharedProps, config) {
|
|
|
40
40
|
BaseButton: {
|
|
41
41
|
className: [
|
|
42
42
|
'h-full min-h-0 spr-bg-secondary hover:spr-bg-secondary focus:spr-bg-secondary',
|
|
43
|
-
|
|
43
|
+
function (_, _a) {
|
|
44
|
+
var $isSelected = _a.$isSelected;
|
|
45
|
+
return isStart
|
|
46
|
+
? "rounded-r-0 ".concat(!$isSelected ? 'border-r-[--sw-border-right-color]' : '')
|
|
47
|
+
: "rounded-l-0 ".concat(!$isSelected ? 'border-l-[--sw-border-left-color]' : '');
|
|
48
|
+
},
|
|
44
49
|
],
|
|
45
50
|
// @ts-ignore -- Variable needed for styling
|
|
46
51
|
style: isStart ? { '--sw-border-right-color': 'transparent' } : { '--sw-border-left-color': 'transparent' },
|
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",
|
|
@@ -98,10 +98,11 @@
|
|
|
98
98
|
"postcss": "^7.0.27",
|
|
99
99
|
"postcss-js": "^2.0.3",
|
|
100
100
|
"react-test-renderer": "^17.0.2",
|
|
101
|
-
"ts-node": "^10.4.0"
|
|
101
|
+
"ts-node": "^10.4.0",
|
|
102
|
+
"typescript": "~5.0.0"
|
|
102
103
|
},
|
|
103
104
|
"peerDependencies": {
|
|
104
|
-
"@sprinklrjs/spaceweb-themes": "14.14.
|
|
105
|
+
"@sprinklrjs/spaceweb-themes": "14.14.6",
|
|
105
106
|
"react": ">=17.0.2 <19.0.0",
|
|
106
107
|
"react-dom": ">=17.0.2 <19.0.0"
|
|
107
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file should be used within spaceweb repository only. Using this outside may lead to breaking behavior.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum SingletonInstanceIdentifier {
|
|
5
|
+
STYLETRON_ENGINE = "STYLETRON_ENGINE"
|
|
6
|
+
}
|
|
7
|
+
export declare function createSingletonInstance<T>(instanceGetter: () => T, identifier: SingletonInstanceIdentifier): T;
|
|
8
|
+
export declare function getSingletonInstance<T>(identifier: string): T | undefined;
|
|
9
|
+
export declare function setSingletonInstance<T>(identifier: string, instance: T): T;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This file should be used within spaceweb repository only. Using this outside may lead to breaking behavior.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.setSingletonInstance = exports.getSingletonInstance = exports.createSingletonInstance = exports.SingletonInstanceIdentifier = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Please refer the following doc - https://sprinklr.atlassian.net/wiki/spaces/Frontend/pages/5506367561/ModuleFederation+Handbook#Using-Singleton-Context
|
|
9
|
+
*/
|
|
10
|
+
var SingletonInstanceIdentifier;
|
|
11
|
+
(function (SingletonInstanceIdentifier) {
|
|
12
|
+
SingletonInstanceIdentifier["STYLETRON_ENGINE"] = "STYLETRON_ENGINE";
|
|
13
|
+
})(SingletonInstanceIdentifier = exports.SingletonInstanceIdentifier || (exports.SingletonInstanceIdentifier = {}));
|
|
14
|
+
var allInstances = {};
|
|
15
|
+
function createSingletonInstance(instanceGetter, identifier) {
|
|
16
|
+
if (allInstances[identifier]) {
|
|
17
|
+
return allInstances[identifier];
|
|
18
|
+
}
|
|
19
|
+
var singletonInstance = instanceGetter();
|
|
20
|
+
allInstances[identifier] = singletonInstance;
|
|
21
|
+
return singletonInstance;
|
|
22
|
+
}
|
|
23
|
+
exports.createSingletonInstance = createSingletonInstance;
|
|
24
|
+
function getSingletonInstance(identifier) {
|
|
25
|
+
return allInstances[identifier];
|
|
26
|
+
}
|
|
27
|
+
exports.getSingletonInstance = getSingletonInstance;
|
|
28
|
+
function setSingletonInstance(identifier, instance) {
|
|
29
|
+
allInstances[identifier] = instance;
|
|
30
|
+
return instance;
|
|
31
|
+
}
|
|
32
|
+
exports.setSingletonInstance = setSingletonInstance;
|