@sprinklrjs/spaceweb 14.15.1 → 14.16.0
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/baseui/timepicker/timepicker.js +5 -5
- package/baseui/timepicker/types.d.ts +5 -0
- package/color-picker/ColorPalette.js +20 -3
- package/color-picker/GradientColorPicker.js +4 -1
- package/color-picker/Swatch.d.ts +3 -1
- package/color-picker/Swatch.js +8 -5
- package/color-picker/handleSwatchGroupKeyDown.d.ts +7 -0
- package/color-picker/handleSwatchGroupKeyDown.js +43 -0
- package/date-picker/DateInput.d.ts +4 -1
- package/date-picker/DateInput.js +7 -5
- package/date-picker/TimeInput.d.ts +6 -1
- package/date-picker/TimeInput.js +2 -2
- package/esm/baseui/timepicker/timepicker.js +5 -5
- package/esm/baseui/timepicker/types.d.ts +5 -0
- package/esm/color-picker/ColorPalette.js +20 -3
- package/esm/color-picker/GradientColorPicker.js +4 -1
- package/esm/color-picker/Swatch.d.ts +3 -1
- package/esm/color-picker/Swatch.js +8 -5
- package/esm/color-picker/handleSwatchGroupKeyDown.d.ts +7 -0
- package/esm/color-picker/handleSwatchGroupKeyDown.js +39 -0
- package/esm/date-picker/DateInput.d.ts +4 -1
- package/esm/date-picker/DateInput.js +7 -5
- package/esm/date-picker/TimeInput.d.ts +6 -1
- package/esm/date-picker/TimeInput.js +2 -2
- package/esm/list/divider.js +1 -1
- package/esm/list/list-item.js +14 -9
- package/esm/locale/en_US.js +5 -0
- package/esm/locale/types.d.ts +3 -0
- package/esm/menu/useKeyboardNavigation.js +10 -3
- package/esm/menu/useStatefulMenu.js +14 -8
- package/esm/modal/modal.js +2 -2
- 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/select/overlaySelect/hooks/useOverlaySelectOverrides.js +3 -0
- package/esm/select/selectMenuAdapter/CollapsibleSelectMenu.js +15 -7
- package/esm/select/selectMenuAdapter/NestedSelectMenuAdapter.js +1 -1
- package/esm/select/selectMenuAdapter/SelectMenuAdapter.js +8 -6
- package/esm/select/styled-component.js +3 -3
- package/esm/slider/slider.d.ts +1 -1
- package/esm/slider/slider.js +12 -2
- package/esm/slider/types.d.ts +3 -0
- package/esm/time-range-picker/RangeSelectorContainer.js +1 -1
- package/esm/time-range-picker/types.d.ts +1 -0
- package/esm/time-zone-picker/types.d.ts +1 -0
- package/esm/tooltip/actionable-tooltip.js +2 -1
- package/list/divider.js +1 -1
- package/list/list-item.js +14 -9
- package/locale/en_US.js +5 -0
- package/locale/types.d.ts +3 -0
- package/menu/useKeyboardNavigation.js +10 -3
- package/menu/useStatefulMenu.js +14 -8
- package/modal/modal.js +2 -2
- package/package.json +2 -4
- 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/select/overlaySelect/hooks/useOverlaySelectOverrides.js +3 -0
- package/select/selectMenuAdapter/CollapsibleSelectMenu.js +14 -6
- package/select/selectMenuAdapter/NestedSelectMenuAdapter.js +1 -1
- package/select/selectMenuAdapter/SelectMenuAdapter.js +8 -6
- package/select/styled-component.js +3 -3
- package/slider/slider.d.ts +1 -1
- package/slider/slider.js +12 -2
- package/slider/types.d.ts +3 -0
- package/time-range-picker/RangeSelectorContainer.js +1 -1
- package/time-range-picker/types.d.ts +1 -0
- package/time-zone-picker/types.d.ts +1 -0
- package/tooltip/actionable-tooltip.js +2 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -15,6 +15,7 @@ import { FieldIcon } from './InputFieldIcon';
|
|
|
15
15
|
import CalendarSolid from '../icon/components/calendar-solid';
|
|
16
16
|
import { isDDMM } from '../date-input/utils';
|
|
17
17
|
import { DEFAULT_FORMAT_STRING } from './constants';
|
|
18
|
+
import { useLocale } from '../locale';
|
|
18
19
|
var COMMON_STYLE = [
|
|
19
20
|
'px-0 py-0 rounded-2 text-center tabular-nums',
|
|
20
21
|
function (_a) {
|
|
@@ -74,8 +75,9 @@ export var DateInput = React.memo(
|
|
|
74
75
|
// eslint-disable-next-line max-statements -- works for functional component
|
|
75
76
|
function (_a) {
|
|
76
77
|
var _b, _c, _d, _e;
|
|
77
|
-
var dateHelpers = _a.dateHelpers, date = _a.date, onChange = _a.onChange, maxDate = _a.maxDate, minDate = _a.minDate, disabled = _a.disabled, size = _a.size, _f = _a.formatString, formatString = _f === void 0 ? DEFAULT_FORMAT_STRING : _f;
|
|
78
|
+
var dateHelpers = _a.dateHelpers, date = _a.date, onChange = _a.onChange, maxDate = _a.maxDate, minDate = _a.minDate, disabled = _a.disabled, size = _a.size, _f = _a.formatString, formatString = _f === void 0 ? DEFAULT_FORMAT_STRING : _f, id = _a.id, ariaLabelledBy = _a["aria-labelledby"], ariaDescribedBy = _a["aria-describedby"];
|
|
78
79
|
var theme = useTheme().theme;
|
|
80
|
+
var spacewebLocale = useLocale();
|
|
79
81
|
var _g = __read(React.useState(function () { return (date ? dateHelpers.formatDate(date, 'dd') : ''); }), 2), day = _g[0], setDay = _g[1];
|
|
80
82
|
var _h = __read(React.useState(function () { return (date ? dateHelpers.formatDate(date, 'MM') : ''); }), 2), month = _h[0], setMonth = _h[1];
|
|
81
83
|
var _j = __read(React.useState(function () { return (date ? dateHelpers.getYear(date) : ''); }), 2), year = _j[0], setYear = _j[1];
|
|
@@ -256,7 +258,7 @@ function (_a) {
|
|
|
256
258
|
var inputSizeTheme = getComponentSizeTheme(theme, 'input', size, defaultSize);
|
|
257
259
|
var inputClasses = input$Size[size !== null && size !== void 0 ? size : defaultSize];
|
|
258
260
|
var inputStyles = inputStyleVariables({ theme: theme }, { $size: size });
|
|
259
|
-
return (_jsxs(Box, __assign({ "data-testid": "date-input", className: [
|
|
261
|
+
return (_jsxs(Box, __assign({ "data-testid": "date-input", role: "group", id: id, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, className: [
|
|
260
262
|
'px-3 flex items-center border-1 border-solid border-box rounded-8',
|
|
261
263
|
error ? 'spr-support-error-border' : 'spr-border-03',
|
|
262
264
|
disabled ? 'spr-ui-02' : 'spr-ui-01',
|
|
@@ -276,10 +278,10 @@ function (_a) {
|
|
|
276
278
|
}
|
|
277
279
|
: {})),
|
|
278
280
|
], style: inputStyles }, { children: [_jsx(FieldIcon, { icon: CalendarSolid, disabled: disabled }), (function (isDayFirst) {
|
|
279
|
-
var DayInputMask = (_jsx(InputMask, __assign({ onBlur: dateBlur, onKeyDown: dateKeyDown, mask: "99", value: day, onChange: dayChange, maskChar: "_", disabled: disabled }, { children: function (props) { return (_jsx(Input, __assign({}, props, { className: DATE_CLASSNAME, overrides: DATE_OVERRIDES, placeholder: "dd", size: "small", disabled: disabled }))); } })));
|
|
280
|
-
var MonthInputMask = (_jsx(InputMask, __assign({ onBlur: monthBlur, onKeyDown: monthKeyDown, mask: "99", value: month, onChange: monthChange, maskChar: "_", disabled: disabled }, { children: function (props) { return (_jsx(Input, __assign({}, props, { className: MONTH_CLASSNAME, style: MONTH_STYLE, overrides: MONTH_OVERRIDES, placeholder: "mm", size: "small", disabled: disabled }))); } })));
|
|
281
|
+
var DayInputMask = (_jsx(InputMask, __assign({ onBlur: dateBlur, onKeyDown: dateKeyDown, mask: "99", value: day, onChange: dayChange, maskChar: "_", disabled: disabled }, { children: function (props) { return (_jsx(Input, __assign({}, props, { className: DATE_CLASSNAME, overrides: DATE_OVERRIDES, placeholder: "dd", size: "small", disabled: disabled, "aria-label": spacewebLocale.calendar.dateInputDayAriaLabel }))); } })));
|
|
282
|
+
var MonthInputMask = (_jsx(InputMask, __assign({ onBlur: monthBlur, onKeyDown: monthKeyDown, mask: "99", value: month, onChange: monthChange, maskChar: "_", disabled: disabled }, { children: function (props) { return (_jsx(Input, __assign({}, props, { className: MONTH_CLASSNAME, style: MONTH_STYLE, overrides: MONTH_OVERRIDES, placeholder: "mm", size: "small", disabled: disabled, "aria-label": spacewebLocale.calendar.dateInputMonthAriaLabel }))); } })));
|
|
281
283
|
if (isDayFirst)
|
|
282
284
|
return [DayInputMask, '/', MonthInputMask];
|
|
283
285
|
return [MonthInputMask, '/', DayInputMask];
|
|
284
|
-
})(isDDMM(formatString)), "/", _jsx(InputMask, __assign({ onBlur: yearBlur, onKeyDown: yearKeyDown, mask: "9999", value: year, onChange: yearChange, maskChar: "_", disabled: disabled }, { children: function (props) { return (_jsx(Input, __assign({}, props, { className: YEAR_CLASSNAME, overrides: YEAR_OVERRIDES, placeholder: "yyyy", size: "small", disabled: disabled }))); } }))] })));
|
|
286
|
+
})(isDDMM(formatString)), "/", _jsx(InputMask, __assign({ onBlur: yearBlur, onKeyDown: yearKeyDown, mask: "9999", value: year, onChange: yearChange, maskChar: "_", disabled: disabled }, { children: function (props) { return (_jsx(Input, __assign({}, props, { className: YEAR_CLASSNAME, overrides: YEAR_OVERRIDES, placeholder: "yyyy", size: "small", disabled: disabled, "aria-label": spacewebLocale.calendar.dateInputYearAriaLabel }))); } }))] })));
|
|
285
287
|
});
|
|
@@ -14,6 +14,11 @@ type TimeInputProps = {
|
|
|
14
14
|
adapter: DateIOAdapter<Date>;
|
|
15
15
|
getTimeRangesForDate?: GetTimeRangesForDate;
|
|
16
16
|
size?: InputSize;
|
|
17
|
+
id?: string;
|
|
18
|
+
'aria-labelledby'?: string;
|
|
19
|
+
'aria-describedby'?: string;
|
|
20
|
+
'aria-errormessage'?: string;
|
|
21
|
+
required?: boolean;
|
|
17
22
|
};
|
|
18
|
-
export declare const TimeInput: ({ overrides, time, onChange, dateHelpers, minTime, maxTime, disabled, adapter, getTimeRangesForDate, size, }: TimeInputProps) => JSX.Element;
|
|
23
|
+
export declare const TimeInput: ({ overrides, time, onChange, dateHelpers, minTime, maxTime, disabled, adapter, getTimeRangesForDate, size, id, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, required, }: TimeInputProps) => JSX.Element;
|
|
19
24
|
export {};
|
|
@@ -9,7 +9,7 @@ import { DropdownFieldIcon } from './InputFieldIcon';
|
|
|
9
9
|
var MS_IN_5_MINUTES = 60 * 1000 * 5;
|
|
10
10
|
var roundUpTime = function (minTime) { return new Date(Math.ceil(minTime.getTime() / MS_IN_5_MINUTES) * MS_IN_5_MINUTES); };
|
|
11
11
|
export var TimeInput = function (_a) {
|
|
12
|
-
var overrides = _a.overrides, time = _a.time, onChange = _a.onChange, dateHelpers = _a.dateHelpers, minTime = _a.minTime, maxTime = _a.maxTime, disabled = _a.disabled, adapter = _a.adapter, getTimeRangesForDate = _a.getTimeRangesForDate, size = _a.size;
|
|
12
|
+
var overrides = _a.overrides, time = _a.time, onChange = _a.onChange, dateHelpers = _a.dateHelpers, minTime = _a.minTime, maxTime = _a.maxTime, disabled = _a.disabled, adapter = _a.adapter, getTimeRangesForDate = _a.getTimeRangesForDate, size = _a.size, id = _a.id, ariaLabelledBy = _a["aria-labelledby"], ariaDescribedBy = _a["aria-describedby"], ariaErrorMessage = _a["aria-errormessage"], required = _a.required;
|
|
13
13
|
var _b = __read(useState(time), 2), value = _b[0], setValue = _b[1];
|
|
14
14
|
var _c = __read(useState(false), 2), error = _c[0], setError = _c[1];
|
|
15
15
|
useEffect(function () {
|
|
@@ -72,5 +72,5 @@ export var TimeInput = function (_a) {
|
|
|
72
72
|
}, [error, value, overrides, time, minTime, maxTime, dateHelpers]);
|
|
73
73
|
var _d = __read(useOverrides(mergedOverrides === null || mergedOverrides === void 0 ? void 0 : mergedOverrides.TimePicker, DefaultTimePicker), 2), TimePicker = _d[0], timeSelectProps = _d[1];
|
|
74
74
|
var timeRanges = useMemo(function () { return (time ? getTimeRangesForDate === null || getTimeRangesForDate === void 0 ? void 0 : getTimeRangesForDate(time) : undefined); }, [time, getTimeRangesForDate]);
|
|
75
|
-
return (_jsx(TimePicker, __assign({ adapter: adapter, value: value, onChange: handleChange, creatable: true, clearable: true, disabled: disabled, minTime: minTime && dateHelpers.isSameDay(value, minTime) ? roundUpTime(minTime) : undefined, maxTime: dateHelpers.isSameDay(value, maxTime) ? maxTime : undefined, timeRanges: timeRanges, size: size }, timeSelectProps)));
|
|
75
|
+
return (_jsx(TimePicker, __assign({ adapter: adapter, value: value, onChange: handleChange, creatable: true, clearable: true, disabled: disabled, minTime: minTime && dateHelpers.isSameDay(value, minTime) ? roundUpTime(minTime) : undefined, maxTime: dateHelpers.isSameDay(value, maxTime) ? maxTime : undefined, timeRanges: timeRanges, size: size, id: id, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, required: required }, timeSelectProps)));
|
|
76
76
|
};
|
package/esm/list/divider.js
CHANGED
|
@@ -14,7 +14,7 @@ var Divider = forwardRef(function (_a, ref) {
|
|
|
14
14
|
'spr-border-primary border-solid border-b-0 border-l-0 border-r-0 mx-0 rounded-0',
|
|
15
15
|
first ? 'border-t-0 pt-0' : 'border-t',
|
|
16
16
|
className,
|
|
17
|
-
]
|
|
17
|
+
] }, propsWithoutContainerAria, subHeaderProps, { ref: ref, role: "presentation" }, { children: children }))) : (_jsx(Separator, __assign({ "data-spaceweb": "divider", className: className }, propsWithoutContainerAria, { ref: ref }, separatorProps, { role: "presentation" })));
|
|
18
18
|
});
|
|
19
19
|
Divider.displayName = 'Divider';
|
|
20
20
|
export default Divider;
|
package/esm/list/list-item.js
CHANGED
|
@@ -9,8 +9,10 @@ import { StyledChildContainer, StyledEndEnhancer, StyledListItem, StyledStartEnh
|
|
|
9
9
|
import { useFocusVisible } from '../hooks/useFocusVisible';
|
|
10
10
|
import { Tooltip as DefaultTooltip } from '../tooltip';
|
|
11
11
|
import useListItemTooltip, { getListItemTooltipHandlers } from './useListItemTooltip';
|
|
12
|
+
import { isPresentationalRole } from './utils';
|
|
12
13
|
var ListItem = React.forwardRef(function (_a, ref) {
|
|
13
|
-
var
|
|
14
|
+
var _b, _c;
|
|
15
|
+
var startEnhancer = _a.startEnhancer, children = _a.children, className = _a.className, style = _a.style, _d = _a.alignItems, alignItems = _d === void 0 ? 'center' : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, endEnhancer = _a.endEnhancer, _f = _a.selected, selected = _f === void 0 ? false : _f, _g = _a.highlighted, highlighted = _g === void 0 ? false : _g, _h = _a.autoFocus, autoFocus = _h === void 0 ? false : _h, _j = _a.button, button = _j === void 0 ? false : _j, _k = _a.overrides, overrides = _k === void 0 ? {} : _k, _l = _a.tabIndex, tabIndex = _l === void 0 ? button ? 0 : undefined : _l, _m = _a.role, roleProp = _m === void 0 ? 'listitem' : _m, _o = _a.$as, $as = _o === void 0 ? 'li' : _o, onClick = _a.onClick, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, _p = _a.tooltipContent, tooltipContent = _p === void 0 ? '' : _p, restProps = __rest(_a, ["startEnhancer", "children", "className", "style", "alignItems", "disabled", "endEnhancer", "selected", "highlighted", "autoFocus", "button", "overrides", "tabIndex", "role", "$as", "onClick", "onKeyDown", "onFocus", "onBlur", "tooltipContent"]);
|
|
14
16
|
var ownRef = useRef(null);
|
|
15
17
|
var combinedRef = useCombinedRefs(ref, ownRef);
|
|
16
18
|
React.useEffect(function () {
|
|
@@ -31,10 +33,10 @@ var ListItem = React.forwardRef(function (_a, ref) {
|
|
|
31
33
|
onKeyDown(event);
|
|
32
34
|
}
|
|
33
35
|
}, [button, disabled, onClick, onKeyDown]);
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
36
|
+
var _q = __read(useOverrides(overrides.Root, StyledListItem), 2), Root = _q[0], rootProps = _q[1];
|
|
37
|
+
var _r = __read(useOverrides(overrides.ChildContainer, StyledChildContainer), 2), ChildContainer = _r[0], childContainerProps = _r[1];
|
|
38
|
+
var _s = __read(useOverrides(overrides.StartEnhancer, StyledStartEnhancer), 2), StartEnhancer = _s[0], startEnhancerProps = _s[1];
|
|
39
|
+
var _t = __read(useOverrides(overrides.EndEnhancer, StyledEndEnhancer), 2), EndEnhancer = _t[0], endEnhancerProps = _t[1];
|
|
38
40
|
var sharedProps = {
|
|
39
41
|
$withStartEnhancer: !!startEnhancer,
|
|
40
42
|
$withEndEnhancer: !!endEnhancer,
|
|
@@ -47,14 +49,17 @@ var ListItem = React.forwardRef(function (_a, ref) {
|
|
|
47
49
|
var renderEnhancer = function (enhancer) {
|
|
48
50
|
return typeof enhancer === 'function' ? enhancer(sharedProps) : enhancer;
|
|
49
51
|
};
|
|
50
|
-
var
|
|
52
|
+
var _u = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.StatefulTooltip, DefaultTooltip), 2), Tooltip = _u[0], tooltipProps = _u[1];
|
|
51
53
|
var tooltipControlProps = useListItemTooltip({
|
|
52
54
|
highlighted: highlighted,
|
|
53
55
|
tooltipHandlers: getListItemTooltipHandlers(tooltipProps),
|
|
54
56
|
});
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
var roleCandidate = (_b = rootProps === null || rootProps === void 0 ? void 0 : rootProps.role) !== null && _b !== void 0 ? _b : roleProp;
|
|
58
|
+
var role = typeof roleCandidate === 'string' ? roleCandidate : 'listitem';
|
|
59
|
+
var presentational = isPresentationalRole(role);
|
|
60
|
+
var explicitAriaDisabled = (_c = rootProps === null || rootProps === void 0 ? void 0 : rootProps['aria-disabled']) !== null && _c !== void 0 ? _c : restProps['aria-disabled'];
|
|
61
|
+
var ariaDisabled = presentational ? undefined : explicitAriaDisabled !== null && explicitAriaDisabled !== void 0 ? explicitAriaDisabled : (disabled ? true : undefined);
|
|
62
|
+
var listEl = (_jsxs(Root, __assign({ "data-spaceweb": "list-item", ref: combinedRef, tabIndex: tabIndex, "$as": $as, onClick: disabled ? _noop : onClick, onKeyDown: handleKeyDown, "data-highlighted": highlighted }, sharedProps, restProps, rootProps, useFocusVisibleProps, { "aria-disabled": ariaDisabled, role: role, style: [style, rootProps === null || rootProps === void 0 ? void 0 : rootProps.style], className: [className, rootProps === null || rootProps === void 0 ? void 0 : rootProps.className] }, { children: [startEnhancer && (_jsx(StartEnhancer, __assign({}, sharedProps, startEnhancerProps, { children: renderEnhancer(startEnhancer) }))), _jsx(ChildContainer, __assign({}, sharedProps, childContainerProps, { children: children })), endEnhancer && (_jsx(EndEnhancer, __assign({}, sharedProps, endEnhancerProps, { children: renderEnhancer(endEnhancer) })))] })));
|
|
58
63
|
return tooltipContent ? (_jsx(Tooltip, __assign({ placement: "bottom", showArrow: true, content: tooltipContent, viewportAsBoundary: true }, tooltipProps, tooltipControlProps, { children: listEl }))) : (listEl);
|
|
59
64
|
});
|
|
60
65
|
ListItem.displayName = 'ListItem';
|
package/esm/locale/en_US.js
CHANGED
|
@@ -43,6 +43,9 @@ export var DEFAULT_LOCALE = {
|
|
|
43
43
|
dateInputLabel: 'Date',
|
|
44
44
|
timePickerLabel: 'Time',
|
|
45
45
|
calendarButtonAriaLabel: 'Open Calendar',
|
|
46
|
+
dateInputDayAriaLabel: 'Day',
|
|
47
|
+
dateInputMonthAriaLabel: 'Month',
|
|
48
|
+
dateInputYearAriaLabel: 'Year',
|
|
46
49
|
},
|
|
47
50
|
datePicker: {
|
|
48
51
|
ariaLabelCalendar: 'Calendar.',
|
|
@@ -115,6 +118,8 @@ export var DEFAULT_LOCALE = {
|
|
|
115
118
|
countrySelectPlaceholder: 'Search',
|
|
116
119
|
inputAriaLabel: 'Please enter a phone number without the country dial code.',
|
|
117
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.',
|
|
118
123
|
},
|
|
119
124
|
menu: {
|
|
120
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/esm/locale/types.d.ts
CHANGED
|
@@ -23,6 +23,9 @@ export type Locale = {
|
|
|
23
23
|
dateInputLabel: string;
|
|
24
24
|
timePickerLabel: string;
|
|
25
25
|
calendarButtonAriaLabel: string;
|
|
26
|
+
dateInputDayAriaLabel: string;
|
|
27
|
+
dateInputMonthAriaLabel: string;
|
|
28
|
+
dateInputYearAriaLabel: string;
|
|
26
29
|
};
|
|
27
30
|
menu: {
|
|
28
31
|
nestedMenuItemAriaDescription: string;
|
|
@@ -40,10 +40,14 @@ var useKeyboardNavigation = function (_a) {
|
|
|
40
40
|
_setHighlightedItem(item);
|
|
41
41
|
setListItemFocusVisible(showFocusVisibleStyles);
|
|
42
42
|
}, []);
|
|
43
|
-
// highlight
|
|
43
|
+
// Re-target highlight when the previous item has left the DOM or is no longer highlightable
|
|
44
|
+
// (filter, unmount, disabled). If nothing is highlightable, clear so aria-activedescendant
|
|
45
|
+
// is not left pointing at a detached or disabled id.
|
|
44
46
|
useLayoutEffect(function () {
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
+
var shouldKeepHighlight = Boolean(highlightedItem) &&
|
|
48
|
+
Boolean(ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body.contains(highlightedItem)) &&
|
|
49
|
+
canHighlightItem(highlightedItem);
|
|
50
|
+
if (disableAutoHighlight || shouldKeepHighlight || !navigationEnabled || !listItemsContainerRef) {
|
|
47
51
|
return;
|
|
48
52
|
}
|
|
49
53
|
var firstHighlightableItem = getFirstHighlightableElement(listItemsContainerRef).firstHighlightableItem;
|
|
@@ -54,6 +58,9 @@ var useKeyboardNavigation = function (_a) {
|
|
|
54
58
|
}
|
|
55
59
|
setHighlightedItem(firstHighlightableItem, showFocusRing);
|
|
56
60
|
}
|
|
61
|
+
else {
|
|
62
|
+
setHighlightedItem(null);
|
|
63
|
+
}
|
|
57
64
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- run this hook only when children changes
|
|
58
65
|
}, [children]);
|
|
59
66
|
useEffect(function () {
|
|
@@ -48,18 +48,24 @@ var useStatefulMenu = function (_a) {
|
|
|
48
48
|
(_a = onHighlightedItemChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onHighlightedItemChangeRef, highlightedItem);
|
|
49
49
|
}, [highlightedItem, onHighlightedItemChangeRef]);
|
|
50
50
|
useEffect(function () {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
if (!navigationEnabled || !(highlightedItem === null || highlightedItem === void 0 ? void 0 : highlightedItem.id) || !highlightedItem.isConnected) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
var ownerDocument = highlightedItem.ownerDocument;
|
|
55
|
+
// menus keep focus on the list, so fall back to the focused element. Never use body.
|
|
56
|
+
var activeElement = ownerDocument.activeElement instanceof HTMLElement ? ownerDocument.activeElement : null;
|
|
57
|
+
var host = keyboardFocusRestoreTarget !== null && keyboardFocusRestoreTarget !== void 0 ? keyboardFocusRestoreTarget : activeElement;
|
|
58
|
+
if (!host || host === ownerDocument.body) {
|
|
59
|
+
return undefined;
|
|
56
60
|
}
|
|
61
|
+
var highlightedItemId = highlightedItem.id;
|
|
62
|
+
host.setAttribute('aria-activedescendant', highlightedItemId);
|
|
57
63
|
return function () {
|
|
58
|
-
if (
|
|
59
|
-
|
|
64
|
+
if (host.getAttribute('aria-activedescendant') === highlightedItemId) {
|
|
65
|
+
host.removeAttribute('aria-activedescendant');
|
|
60
66
|
}
|
|
61
67
|
};
|
|
62
|
-
}, [navigationEnabled, highlightedItem]);
|
|
68
|
+
}, [navigationEnabled, highlightedItem, keyboardFocusRestoreTarget]);
|
|
63
69
|
return {
|
|
64
70
|
highlightedItem: highlightedItem,
|
|
65
71
|
setHighlightedItem: setHighlightedItem,
|
package/esm/modal/modal.js
CHANGED
|
@@ -67,8 +67,8 @@ var Modal = function (_a) {
|
|
|
67
67
|
return {};
|
|
68
68
|
}, [size, px2rem]);
|
|
69
69
|
var dialogA11yProps = useMemo(function () { return ({
|
|
70
|
-
'aria-label': ariaLabel,
|
|
71
|
-
'aria-labelledby': ariaLabelledBy || headerTitleId,
|
|
70
|
+
'aria-label': ariaLabelledBy ? undefined : ariaLabel,
|
|
71
|
+
'aria-labelledby': ariaLabelledBy || (ariaLabel ? undefined : headerTitleId),
|
|
72
72
|
}); }, [ariaLabel, ariaLabelledBy, headerTitleId]);
|
|
73
73
|
var _overrides = useMemo(function () {
|
|
74
74
|
return mergeOverrides({
|
|
@@ -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
|
+
};
|
|
@@ -127,6 +127,7 @@ var useOverlaySelectOverrides = function (props) {
|
|
|
127
127
|
}, [closePopover, onChange, closeOnSelect]);
|
|
128
128
|
var _h = useStickyElement(), isSticky = _h.isSticky, setStickySentinelRef = _h.setStickySentinelRef;
|
|
129
129
|
var _j = useSearchContainerHeight(), containerHeight = _j.containerHeight, setContainerElement = _j.setContainerElement;
|
|
130
|
+
var ariaLabel = props['aria-label'];
|
|
130
131
|
var memoizedOverrides = useMemo(function () { return ({
|
|
131
132
|
// BaseSelect wil render this Popover component with DropdownContainer as content and ControlContainer as children/target
|
|
132
133
|
Popover: {
|
|
@@ -153,6 +154,7 @@ var useOverlaySelectOverrides = function (props) {
|
|
|
153
154
|
'aria-expanded': popoverOpen,
|
|
154
155
|
'aria-autocomplete': 'list',
|
|
155
156
|
'aria-haspopup': 'listbox',
|
|
157
|
+
'aria-label': ariaLabel,
|
|
156
158
|
overrides: {
|
|
157
159
|
After: isLoading ? SelectLoader : function () { return null; },
|
|
158
160
|
ClearIcon: {
|
|
@@ -242,6 +244,7 @@ var useOverlaySelectOverrides = function (props) {
|
|
|
242
244
|
scrollContainer,
|
|
243
245
|
scrollElement,
|
|
244
246
|
popoverOpen,
|
|
247
|
+
ariaLabel,
|
|
245
248
|
]);
|
|
246
249
|
var overrides = useMemo(function () { return mergeOverrides(memoizedOverrides, _omit(props.overrides, overridesToOmit)); }, [memoizedOverrides, props.overrides]);
|
|
247
250
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __assign, __read } from "tslib";
|
|
1
|
+
import { __assign, __read, __spreadArray } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import _isNumber from 'lodash/isNumber';
|
|
4
4
|
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
@@ -140,7 +140,7 @@ export var CollapsibleSelectMenu = function (_a) {
|
|
|
140
140
|
// https://ui5.sap.com/#/entity/sap.m.MultiComboBox/sample/sap.m.sample.MultiComboBoxSelectAll
|
|
141
141
|
role: "checkbox", className: ['m-2', baseuiMenuItemProps === null || baseuiMenuItemProps === void 0 ? void 0 : baseuiMenuItemProps.className] }), "select-all-option")) : null, groupConfig.map(function (_group, index) {
|
|
142
142
|
var _a;
|
|
143
|
-
var _b, _c;
|
|
143
|
+
var _b, _c, _d;
|
|
144
144
|
var groupId = _group.id, groupLabel = _group.label;
|
|
145
145
|
var itemsInGroup = groupedItems[groupId];
|
|
146
146
|
var group = _group;
|
|
@@ -158,11 +158,19 @@ export var CollapsibleSelectMenu = function (_a) {
|
|
|
158
158
|
_a[GROUP_SELECT_ALL_ID] = true,
|
|
159
159
|
_a.selected = groupSelectAllSelected,
|
|
160
160
|
_a);
|
|
161
|
-
|
|
161
|
+
var menuChildren = _isEmpty(itemsInGroup)
|
|
162
|
+
? [
|
|
163
|
+
_jsx(NoResultsOverriden, __assign({ msg: noResultsMsg, noResultsConfig: noResultsConfig, "$groupId": groupId }, noResultsProps), "no-results"),
|
|
164
|
+
]
|
|
165
|
+
: __spreadArray([
|
|
166
|
+
shouldDisplayGroupSelectAll ? (_jsx(SelectMenuItem, __assign({ overrides: menuItemOverrides, item: groupSelectAllItem, "data-testid": "".concat(group.label, "-group-select-all"), selected: groupSelectAllSelected, multi: multi, getItemLabel: getItemLabel, labelKey: labelKey, valueKey: valueKey, onItemSelect: onItemSelect, "$item": groupSelectAllItem, button: true, disabled: group.count <= countDisabledOptions, highlighted: isMenuItemHighlighted }, baseuiMenuItemProps), "select-all-option")) : null,
|
|
167
|
+
clearAsOptionItem ? (_jsx(SelectMenuItem, __assign({ overrides: menuItemOverrides, item: clearAsOptionItem, selected: false, multi: multi, getItemLabel: getItemLabel, labelKey: labelKey, valueKey: valueKey, onItemSelect: onItemSelect, "$item": clearAsOptionItem, button: true, highlighted: isMenuItemHighlighted }, baseuiMenuItemProps), "clear-option")) : null
|
|
168
|
+
], __read(itemsInGroup.map(function (item) {
|
|
169
|
+
var selected = selectedValuesSet.has(item[valueKey]);
|
|
170
|
+
return (_jsx(SelectMenuItem, __assign({ overrides: menuItemOverrides, item: item, selected: selected, multi: multi, getItemLabel: getItemLabel, labelKey: labelKey, valueKey: valueKey, onItemSelect: onItemSelect, "$item": item, button: true, highlighted: isMenuItemHighlighted }, baseuiMenuItemProps), item.isCreatable ? 'creatable-option' : item[valueKey]));
|
|
171
|
+
})), false).filter(Boolean);
|
|
172
|
+
return (_jsxs(Collapsible, __assign({ className: index === 0 && selectAllItem ? 'border-t-1 border-solid spr-border-primary' : '', group: group, expanded: disableWhenSelectAllChecked && globalSelectAllSelected ? false : groupId === expandedGroupId, disabled: disableWhenSelectAllChecked && globalSelectAllSelected, onClick: handleOnClick }, { children: [_jsx(HiddenElement, __assign({ id: menuDescriptionId !== null && menuDescriptionId !== void 0 ? menuDescriptionId : '' }, { children: "".concat(groupLabel, " ").concat(locale.groupExpandedSuffix) })), _jsx(MenuComponent, __assign({ resetMenuHighlightOnMouseLeave: true, focusWhenNavigationEnabled: false, disableAutoHighlight: isRootSelectAllHighlighted, keyboardFocusRestoreTarget: inputElement, tabIndex: -1, selectOnTab: selectOnTab, getActionsElement: getActionsElement }, menuProps, { role: "listbox", id: listboxId, "aria-label": (_d = menuProps === null || menuProps === void 0 ? void 0 : menuProps['aria-label']) !== null && _d !== void 0 ? _d : groupLabel, virtual: virtual && !_isEmpty(itemsInGroup), className: ['overflow-auto max-h-50 pt-0', menuProps === null || menuProps === void 0 ? void 0 : menuProps.className], onScroll: function (e) {
|
|
162
173
|
$onPaginate === null || $onPaginate === void 0 ? void 0 : $onPaginate(e, groupId);
|
|
163
|
-
}, onHighlightedItemChange: handleOnHighlightedItemChange, ref: menuRef }, { children:
|
|
164
|
-
var selected = selectedValuesSet.has(item[valueKey]);
|
|
165
|
-
return (_jsx(SelectMenuItem, __assign({ overrides: menuItemOverrides, item: item, selected: selected, multi: multi, getItemLabel: getItemLabel, labelKey: labelKey, valueKey: valueKey, onItemSelect: onItemSelect, "$item": item, button: true, highlighted: isMenuItemHighlighted }, baseuiMenuItemProps), item.isCreatable ? 'creatable-option' : item[valueKey]));
|
|
166
|
-
})] })))] }), groupId));
|
|
174
|
+
}, onHighlightedItemChange: handleOnHighlightedItemChange, ref: menuRef }, { children: menuChildren }))] }), groupId));
|
|
167
175
|
})] })));
|
|
168
176
|
};
|
|
@@ -79,6 +79,6 @@ var NestedSelectMenuAdapter = function (props) {
|
|
|
79
79
|
}
|
|
80
80
|
return null;
|
|
81
81
|
};
|
|
82
|
-
return totalCount ? (_jsx(MenuOverriden, __assign({ resetMenuHighlightOnMouseLeave: true, focusWhenNavigationEnabled: false, keyboardFocusRestoreTarget: inputElement, "$multi": multi, captureScroll: captureScroll, tabIndex: -1, "aria-label": "Menu", role: "listbox", getActionsElement: getActionsElement }, baseuiMenuListProps, { id: listboxId, virtual: virtual, overscanCount: overscanCount, items: props.items.__ungrouped, itemRenderer: itemRenderer }, menuProps, { getItemLabel: getItemLabel !== null && getItemLabel !== void 0 ? getItemLabel : defaultItemLabel }))) : (_jsx(Menu, __assign({ resetMenuHighlightOnMouseLeave: true, focusWhenNavigationEnabled: false, keyboardFocusRestoreTarget: inputElement, tabIndex: -1, "aria-label": "Menu", role: "listbox", getActionsElement: getActionsElement, id: listboxId }, { children: _jsx(NoResultsOverriden, __assign({
|
|
82
|
+
return totalCount ? (_jsx(MenuOverriden, __assign({ resetMenuHighlightOnMouseLeave: true, focusWhenNavigationEnabled: false, keyboardFocusRestoreTarget: inputElement, "$multi": multi, captureScroll: captureScroll, tabIndex: -1, "aria-label": "Menu", role: "listbox", getActionsElement: getActionsElement }, baseuiMenuListProps, { id: listboxId, virtual: virtual, overscanCount: overscanCount, items: props.items.__ungrouped, itemRenderer: itemRenderer }, menuProps, { getItemLabel: getItemLabel !== null && getItemLabel !== void 0 ? getItemLabel : defaultItemLabel }))) : (_jsx(Menu, __assign({ resetMenuHighlightOnMouseLeave: true, focusWhenNavigationEnabled: false, keyboardFocusRestoreTarget: inputElement, tabIndex: -1, "aria-label": "Menu", role: "listbox", getActionsElement: getActionsElement, id: listboxId }, { children: _jsx(NoResultsOverriden, __assign({ msg: noResultsMsg, noResultsConfig: noResultsConfig }, noResultsProps)) })));
|
|
83
83
|
};
|
|
84
84
|
export default NestedSelectMenuAdapter;
|
|
@@ -59,24 +59,26 @@ var SelectMenuAdapter = function (props) {
|
|
|
59
59
|
}); }, [mergedOverrides.ListItemText, mergedOverrides.MenuItem, mergedOverrides.Checkbox]);
|
|
60
60
|
var currentCount = 0;
|
|
61
61
|
var totalCount = normalizeOptions(groupedItems).length;
|
|
62
|
-
var
|
|
62
|
+
var optionItems = _flatten(Object.keys(removeUngroupedIfEmpty(groupedItems)).map(function (itemGroup, index) {
|
|
63
63
|
var itemsInGroup = groupedItems[itemGroup];
|
|
64
64
|
var menuItems = itemsInGroup.flatMap(function (item) {
|
|
65
65
|
currentCount += 1;
|
|
66
66
|
var selected = selectedValuesSet.has(item[valueKey]) || (item[SELECT_ALL_ID] && selectAllSelected);
|
|
67
67
|
var selectMenuItem = (_jsx(SelectMenuItem, __assign({ overrides: menuItemOverrides, item: item, selected: selected, multi: multi, getItemLabel: getItemLabel, labelKey: labelKey, valueKey: valueKey, onItemSelect: onItemSelect, "$item": item, "aria-posinset": currentCount, "aria-setsize": totalCount }, baseuiMenuItemProps), item.isCreatable ? 'creatable-option' : "".concat(item[valueKey], "-").concat(item.__optgroup)));
|
|
68
68
|
return item[SELECT_ALL_ID]
|
|
69
|
-
? [
|
|
69
|
+
? [
|
|
70
|
+
selectMenuItem,
|
|
71
|
+
_jsx(DividerOverriden, __assign({ "$item": item }, dividerProps, { role: "presentation" }), "divider-select-all"),
|
|
72
|
+
]
|
|
70
73
|
: selectMenuItem;
|
|
71
74
|
});
|
|
72
75
|
if (itemGroup !== UNGROUPED_ID) {
|
|
73
|
-
menuItems.unshift(_jsx(DividerOverriden, __assign({ first: index === 0 }, dividerProps, { children: _jsx(Typography, __assign({ variant: "body-xs", weight: "semibold", className: "spr-text-tertiary" }, { children: itemGroup })) }), "divider-".concat(itemGroup)));
|
|
76
|
+
menuItems.unshift(_jsx(DividerOverriden, __assign({ first: index === 0 }, dividerProps, { role: "presentation" }, { children: _jsx(Typography, __assign({ variant: "body-xs", weight: "semibold", className: "spr-text-tertiary" }, { children: itemGroup })) }), "divider-".concat(itemGroup)));
|
|
74
77
|
}
|
|
75
78
|
return menuItems;
|
|
76
79
|
}));
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
+
var hasOptions = !_isEmpty(optionItems);
|
|
81
|
+
var itemsToRender = hasOptions ? (optionItems) : (_jsx(NoResultsOverriden, __assign({ msg: noResultsMsg, noResultsConfig: noResultsConfig }, noResultsProps)));
|
|
80
82
|
return (
|
|
81
83
|
// focusWhenNavigationEnabled false, or else it will remove focus from select input
|
|
82
84
|
_jsx(MenuOverriden, __assign({ resetMenuHighlightOnMouseLeave: true, focusWhenNavigationEnabled: false, keyboardFocusRestoreTarget: inputElement, "$multi": multi, captureScroll: captureScroll, tabIndex: -1, "aria-label": "Menu", role: "listbox", getActionsElement: getActionsElement }, baseuiMenuListProps, { id: listboxId, virtual: virtual, overscanCount: overscanCount, selectOnTab: selectOnTab }, menuProps, { children: itemsToRender })));
|
|
@@ -2,8 +2,7 @@ import { __assign, __rest } from "tslib";
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef, memo, useRef, cloneElement, Children } from 'react';
|
|
4
4
|
import { useLocale } from '../locale';
|
|
5
|
-
import
|
|
6
|
-
import MenuItem from '../menu/menu-item';
|
|
5
|
+
import ListItem from '../list/list-item';
|
|
7
6
|
import { styled } from '../style';
|
|
8
7
|
import { getComponentSizeTheme, getDefaultSize } from '../helpers/themeHelpers';
|
|
9
8
|
import { HiddenElement } from './utils/hidden-element';
|
|
@@ -17,7 +16,8 @@ var NoResults = forwardRef(function (_a, ref) {
|
|
|
17
16
|
var msg = _a.msg, noResultsConfig = _a.noResultsConfig, props = __rest(_a, ["msg", "noResultsConfig"]);
|
|
18
17
|
var locale = useLocale();
|
|
19
18
|
var noResultsId = useSelectIds().noResultsId;
|
|
20
|
-
|
|
19
|
+
var message = msg || locale.select.noResultsMsg;
|
|
20
|
+
return (_jsx(ListItem, __assign({ ref: ref, button: false, id: noResultsId, role: "option", "aria-live": "polite", "aria-atomic": true, "aria-selected": false, "aria-disabled": !(noResultsConfig === null || noResultsConfig === void 0 ? void 0 : noResultsConfig.onButtonClick) }, props, { children: noResultsConfig ? _jsx(NoResultsMessage, __assign({}, noResultsConfig)) : message })));
|
|
21
21
|
});
|
|
22
22
|
export var StyledInputContainer = styled('div', inputContainerCVA,
|
|
23
23
|
// theme override styleFn
|
package/esm/slider/slider.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
2
|
import type { SliderProps } from './types';
|
|
3
3
|
declare const Slider: {
|
|
4
|
-
({ overrides, disabled, marks, onChange, onFinalChange, min: propMin, max: propMax, step, persistentThumb, valueToLabel, value: propProvidedValue, intent, className, style, getMarkLabel, markLabel, primaryIntentColor, secondaryIntentColor, trackColors, thumbColors, }: SliderProps): ReactElement;
|
|
4
|
+
({ overrides, disabled, marks, onChange, onFinalChange, min: propMin, max: propMax, step, persistentThumb, valueToLabel, value: propProvidedValue, intent, className, style, getMarkLabel, markLabel, primaryIntentColor, secondaryIntentColor, trackColors, thumbColors, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, }: SliderProps): ReactElement;
|
|
5
5
|
__standard: string;
|
|
6
6
|
};
|
|
7
7
|
export default Slider;
|
package/esm/slider/slider.js
CHANGED
|
@@ -22,7 +22,7 @@ var defaultMarkLabel = function (_a) {
|
|
|
22
22
|
return "".concat(($min || 0) + $markIndex * $step);
|
|
23
23
|
};
|
|
24
24
|
var Slider = function (_a) {
|
|
25
|
-
var _b = _a.overrides, overrides = _b === void 0 ? {} : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.marks, marks = _d === void 0 ? false : _d, _e = _a.onChange, onChange = _e === void 0 ? _noop : _e, _f = _a.onFinalChange, onFinalChange = _f === void 0 ? _noop : _f, _g = _a.min, propMin = _g === void 0 ? 0 : _g, _h = _a.max, propMax = _h === void 0 ? 100 : _h, _j = _a.step, step = _j === void 0 ? 1 : _j, _k = _a.persistentThumb, persistentThumb = _k === void 0 ? false : _k, _l = _a.valueToLabel, valueToLabel = _l === void 0 ? function (label) { return label; } : _l, propProvidedValue = _a.value, _m = _a.intent, intent = _m === void 0 ? 'default' : _m, className = _a.className, style = _a.style, _o = _a.getMarkLabel, getMarkLabel = _o === void 0 ? defaultMarkLabel : _o, markLabel = _a.markLabel, primaryIntentColor = _a.primaryIntentColor, secondaryIntentColor = _a.secondaryIntentColor, trackColors = _a.trackColors, thumbColors = _a.thumbColors;
|
|
25
|
+
var _b = _a.overrides, overrides = _b === void 0 ? {} : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.marks, marks = _d === void 0 ? false : _d, _e = _a.onChange, onChange = _e === void 0 ? _noop : _e, _f = _a.onFinalChange, onFinalChange = _f === void 0 ? _noop : _f, _g = _a.min, propMin = _g === void 0 ? 0 : _g, _h = _a.max, propMax = _h === void 0 ? 100 : _h, _j = _a.step, step = _j === void 0 ? 1 : _j, _k = _a.persistentThumb, persistentThumb = _k === void 0 ? false : _k, _l = _a.valueToLabel, valueToLabel = _l === void 0 ? function (label) { return label; } : _l, propProvidedValue = _a.value, _m = _a.intent, intent = _m === void 0 ? 'default' : _m, className = _a.className, style = _a.style, _o = _a.getMarkLabel, getMarkLabel = _o === void 0 ? defaultMarkLabel : _o, markLabel = _a.markLabel, primaryIntentColor = _a.primaryIntentColor, secondaryIntentColor = _a.secondaryIntentColor, trackColors = _a.trackColors, thumbColors = _a.thumbColors, ariaLabel = _a["aria-label"], ariaLabelledBy = _a["aria-labelledby"], ariaDescribedBy = _a["aria-describedby"];
|
|
26
26
|
var _p = __read(useState(-1), 2), hoveredThumbIndex = _p[0], setHoveredThumbIndex = _p[1];
|
|
27
27
|
var hasMounted = useHasMounted();
|
|
28
28
|
var _q = __read(useState(false), 2), isFocusVisible = _q[0], setIsFocusVisible = _q[1];
|
|
@@ -96,7 +96,17 @@ var Slider = function (_a) {
|
|
|
96
96
|
// In SSR, Thumbs are not properly positioned, hence hiding thumbs on server render.
|
|
97
97
|
// Refer https://github.com/tajo/react-range/issues/67#issuecomment-591703422
|
|
98
98
|
// Thumb is made ClientOnly to avoid Hydration mismatch error
|
|
99
|
-
|
|
99
|
+
var thumbLabel;
|
|
100
|
+
if (ariaLabel == null) {
|
|
101
|
+
thumbLabel = undefined;
|
|
102
|
+
}
|
|
103
|
+
else if (value.length > 1) {
|
|
104
|
+
thumbLabel = "".concat(ariaLabel, " ").concat(index + 1);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
thumbLabel = ariaLabel;
|
|
108
|
+
}
|
|
109
|
+
return (_jsxs(Thumb, __assign({}, props, (thumbLabel ? { 'aria-label': thumbLabel } : {}), (ariaLabelledBy ? { 'aria-labelledby': ariaLabelledBy } : {}), (ariaDescribedBy ? { 'aria-describedby': ariaDescribedBy } : {}), { "data-thumbIndex": index, onMouseEnter: function () { return setHoveredThumbIndex(index); }, onMouseLeave: function () { return setHoveredThumbIndex(-1); }, "$thumbIndex": index, "$isDragged": isDragged, style: __assign(__assign({ '--sw-bg-color': value.length > 2 ? thumbColors[index] : primaryIntentColor !== null && primaryIntentColor !== void 0 ? primaryIntentColor : intentColor(styleUtils, sharedProps), '--sw-bg-color-hover': value.length > 2
|
|
100
110
|
? thumbColors[index]
|
|
101
111
|
: primaryIntentColor !== null && primaryIntentColor !== void 0 ? primaryIntentColor : intentColor(styleUtils, sharedProps, theme.spr.interactiveHover), '--sw-shadow': isFocusVisible && focusedThumbIndex === index
|
|
102
112
|
? "0 0 0 3px ".concat(theme.spr.focus01)
|
package/esm/slider/types.d.ts
CHANGED
|
@@ -14,6 +14,9 @@ type GetMarkLabelFn = (props: SharedProps & {
|
|
|
14
14
|
$markIndex: number;
|
|
15
15
|
}) => React.ReactNode;
|
|
16
16
|
type CommonSliderProps = {
|
|
17
|
+
'aria-label'?: string;
|
|
18
|
+
'aria-labelledby'?: string;
|
|
19
|
+
'aria-describedby'?: string;
|
|
17
20
|
/** @deprecated */
|
|
18
21
|
intent?: Intent;
|
|
19
22
|
markLabel?: boolean;
|
|
@@ -114,7 +114,7 @@ var RangeSelectorContainer = function (_a) {
|
|
|
114
114
|
fill: theme.spr.clrRed,
|
|
115
115
|
});
|
|
116
116
|
} }), _jsx(Typography, __assign({ className: "my-0", variant: "bs3" }, { children: errMsg }))] }))) : null;
|
|
117
|
-
return (_jsxs(Box, __assign({ className: "spr-ui-01 rounded-8" }, { children: [_jsxs(Header, __assign({ "$setTimezone": setTimezone, "$onClose": props.onClose }, headerProps, { children: [_jsx(HeaderBeforeEnhancer, __assign({ variant: "heading-7", "$as": "span", className: "flex items-center" }, headerBeforeEnhancerProps, { children: locale.timeRangePicker.headerLabel })), disableTimezone ? null : (_jsx(TimezonePicker, __assign({ setTimezone: setTimezone, timezone: timezone, timezoneOptions: timezoneOptions }, timezonePickerProps, { className: ['w-0 grow max-w-md', timezonePickerProps === null || timezonePickerProps === void 0 ? void 0 : timezonePickerProps.className] })))] })), _jsx(RangeSelector, __assign({ overrides: props.overrides, timeSelect: props.timeSelect, timeRangePresets: timeRangePresets, timezone: timezone, timeRange: timeRange, preset: preset, onChange: onDateChange, adapter: adapter, peekNextMonth: props.peekNextMonth, excludeDates: props.excludeDates, filterDate: props.filterDate, minDate: minDate, maxDate: maxDate, formatString: props.formatString, locale: props.locale, fixedHeight: props.fixedHeight, monthsShown: monthsShown, hidePresetSearch: hidePresetSearch, footerContent: _jsx(Footer, __assign({ "$hasError": hasError, "$onSubmit": handleSubmit, "$onClose": props.onClose }, footerProps, { className: ['px-6 py-3 mt-2', footerProps.className] }, { children: _jsxs(Box, __assign({ className: "justify-between w-0 grow flex" }, { children: [_jsx(FooterBeforeEnhancer, __assign({}, footerBeforeEnhancerProps)), _jsxs(Stack, __assign({ direction: monthsShown === 1 ? 'vertical' : 'horizontal', gap: 3, className: monthsShown !== 1 ? 'items-center' : undefined, style: { maxWidth: 'fit-content' } }, { children: [monthsShown === 1 ? null : errorEl, _jsxs(StackItem, __assign({ className: "flex self-end" }, { children: [(footerProps === null || footerProps === void 0 ? void 0 : footerProps.showClearButton) ? (_jsx(Button, __assign({ size: "xs", onClick: footerProps.handleClearBtnClick, variant: "secondary", "data-testid": "clear", disabled: timeRange.length === 0 }, { children: locale.timeRangePicker.clearBtnLabel }))) : (_jsx(Button, __assign({ size: "xs", onClick: props.onClose, variant: "secondary", "data-testid": "cancel" }, { children: locale.timeRangePicker.cancelBtnLabel }))), _jsx(Button, __assign({ size: "xs", className: "ml-3", onClick: handleSubmit, disabled: hasError, "data-testid": "save" }, { children: locale.timeRangePicker.saveBtnLabel }))] })), monthsShown === 1 ? errorEl : null] }))] })) })) }, rangeSelectorProps))] })));
|
|
117
|
+
return (_jsxs(Box, __assign({ className: "spr-ui-01 rounded-8" }, { children: [_jsxs(Header, __assign({ "$setTimezone": setTimezone, "$onClose": props.onClose }, headerProps, { children: [_jsx(HeaderBeforeEnhancer, __assign({ variant: "heading-7", "$as": "span", className: "flex items-center" }, headerBeforeEnhancerProps, { children: locale.timeRangePicker.headerLabel })), disableTimezone ? null : (_jsx(TimezonePicker, __assign({ setTimezone: setTimezone, timezone: timezone, timezoneOptions: timezoneOptions }, timezonePickerProps, { "aria-label": locale.timeRangePicker.timezoneLabel, className: ['w-0 grow max-w-md', timezonePickerProps === null || timezonePickerProps === void 0 ? void 0 : timezonePickerProps.className] })))] })), _jsx(RangeSelector, __assign({ overrides: props.overrides, timeSelect: props.timeSelect, timeRangePresets: timeRangePresets, timezone: timezone, timeRange: timeRange, preset: preset, onChange: onDateChange, adapter: adapter, peekNextMonth: props.peekNextMonth, excludeDates: props.excludeDates, filterDate: props.filterDate, minDate: minDate, maxDate: maxDate, formatString: props.formatString, locale: props.locale, fixedHeight: props.fixedHeight, monthsShown: monthsShown, hidePresetSearch: hidePresetSearch, footerContent: _jsx(Footer, __assign({ "$hasError": hasError, "$onSubmit": handleSubmit, "$onClose": props.onClose }, footerProps, { className: ['px-6 py-3 mt-2', footerProps.className] }, { children: _jsxs(Box, __assign({ className: "justify-between w-0 grow flex" }, { children: [_jsx(FooterBeforeEnhancer, __assign({}, footerBeforeEnhancerProps)), _jsxs(Stack, __assign({ direction: monthsShown === 1 ? 'vertical' : 'horizontal', gap: 3, className: monthsShown !== 1 ? 'items-center' : undefined, style: { maxWidth: 'fit-content' } }, { children: [monthsShown === 1 ? null : errorEl, _jsxs(StackItem, __assign({ className: "flex self-end" }, { children: [(footerProps === null || footerProps === void 0 ? void 0 : footerProps.showClearButton) ? (_jsx(Button, __assign({ size: "xs", onClick: footerProps.handleClearBtnClick, variant: "secondary", "data-testid": "clear", disabled: timeRange.length === 0 }, { children: locale.timeRangePicker.clearBtnLabel }))) : (_jsx(Button, __assign({ size: "xs", onClick: props.onClose, variant: "secondary", "data-testid": "cancel" }, { children: locale.timeRangePicker.cancelBtnLabel }))), _jsx(Button, __assign({ size: "xs", className: "ml-3", onClick: handleSubmit, disabled: hasError, "data-testid": "save" }, { children: locale.timeRangePicker.saveBtnLabel }))] })), monthsShown === 1 ? errorEl : null] }))] })) })) }, rangeSelectorProps))] })));
|
|
118
118
|
};
|
|
119
119
|
RangeSelectorContainer.displayName = 'RangeSelectorContainer';
|
|
120
120
|
export default RangeSelectorContainer;
|