@sprinklrjs/spaceweb 14.15.2 → 14.16.1
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 +3 -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/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 +4 -6
- 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/RangeSelector.js +2 -2
- 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 +3 -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/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 +4 -6
- package/slider/slider.d.ts +1 -1
- package/slider/slider.js +12 -2
- package/slider/types.d.ts +3 -0
- package/time-range-picker/RangeSelector.js +2 -2
- 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.',
|
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({
|
|
@@ -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
|
|
@@ -74,9 +74,7 @@ var InputContainer = function (_a) {
|
|
|
74
74
|
var ariaDescribedBy = commaSeparatedValues ? "".concat(selectedValuesId, " ").concat(baseAriaDescribedBy) : baseAriaDescribedBy;
|
|
75
75
|
var containerRef = useRef(null);
|
|
76
76
|
if (!props.$searchable) {
|
|
77
|
-
return (_jsxs(_Fragment, { children: [commaSeparatedValues ? (_jsx(HiddenElement, __assign({ id: selectedValuesId }, { children: "".concat(commaSeparatedValues, " ").concat(props.$multi ? locale.select.multiValueNavigationDescription : '') }))) : null, _jsx(StyledInputContainer, __assign({}, props, { "$selectSize": size, "aria-controls": props.$isOpen ? listboxId : undefined, "aria-owns": props.$isOpen ? listboxId : null, "aria-describedby": ariaDescribedBy, "aria-expanded": props.$isOpen, "aria-autocomplete": "list", role: "combobox", ref: containerRef },
|
|
78
|
-
? {}
|
|
79
|
-
: { 'aria-placeholder': placeholder !== null && placeholder !== void 0 ? placeholder : locale.select.selectPlaceholder }), { "aria-haspopup": "listbox" }, { children: props.children
|
|
77
|
+
return (_jsxs(_Fragment, { children: [commaSeparatedValues ? (_jsx(HiddenElement, __assign({ id: selectedValuesId }, { children: "".concat(commaSeparatedValues, " ").concat(props.$multi ? locale.select.multiValueNavigationDescription : '') }))) : null, _jsx(StyledInputContainer, __assign({}, props, { "$selectSize": size, "aria-controls": props.$isOpen ? listboxId : undefined, "aria-owns": props.$isOpen ? listboxId : null, "aria-describedby": ariaDescribedBy, "aria-expanded": props.$isOpen, "aria-autocomplete": "list", role: "combobox", ref: containerRef, "aria-haspopup": "listbox" }, { children: props.children
|
|
80
78
|
? cloneElement(Children.only(props.children), __assign({ onFocus: function () { var _a; return (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.focus(); } }, ($value && $value.length > 0 ? {} : { placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : locale.select.selectPlaceholder })))
|
|
81
79
|
: null }))] }));
|
|
82
80
|
}
|
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;
|
|
@@ -14,8 +14,8 @@ var RangeSelector = function (_a) {
|
|
|
14
14
|
var TIME_RANGE_LIST_OVERRIDES = useMemo(function () {
|
|
15
15
|
return mergeOverrides({ Menu: { props: { overrides: { List: { props: { overrides: { Root: { className: 'h-0' } } } } } } } }, overrides);
|
|
16
16
|
}, [overrides]);
|
|
17
|
-
return (_jsxs(Box, __assign({ className: "flex border-0 border-t-1 border-solid spr-border-01" }, { children: [props.timeRangePresets.length !== 1 ? (_jsx(TimeRangeList, __assign({ onChange: onChange, timeRange: timeRange, preset: preset, timeRangePresets: props.timeRangePresets, overrides: TIME_RANGE_LIST_OVERRIDES, hidePresetSearch: hidePresetSearch }, restTimeRangeListProps))) : null, _jsxs(Box, __assign({ className: "overflow-y-auto" }, { children: [_jsx(Calendar, __assign({ timeSelectEnd: props.timeSelect, timeSelectStart: props.timeSelect, value: timeRange, onChange: onChange, peekNextMonth: props.peekNextMonth, excludeDates: props.excludeDates, filterDate: props.filterDate, minDate: props.minDate, maxDate: props.maxDate, range: true, monthsShown: props.monthsShown, locale: props.locale, formatString: formatString,
|
|
18
|
-
// @ts-
|
|
17
|
+
return (_jsxs(Box, __assign({ className: "flex flex-1 min-h-0 overflow-y-auto border-0 border-t-1 border-solid spr-border-01", "data-testid": "time-range-selector-scroll" }, { children: [props.timeRangePresets.length !== 1 ? (_jsx(TimeRangeList, __assign({ onChange: onChange, timeRange: timeRange, preset: preset, timeRangePresets: props.timeRangePresets, overrides: TIME_RANGE_LIST_OVERRIDES, hidePresetSearch: hidePresetSearch }, restTimeRangeListProps))) : null, _jsxs(Box, __assign({ className: "overflow-y-auto" }, { children: [_jsx(Calendar, __assign({ timeSelectEnd: props.timeSelect, timeSelectStart: props.timeSelect, value: timeRange, onChange: onChange, peekNextMonth: props.peekNextMonth, excludeDates: props.excludeDates, filterDate: props.filterDate, minDate: props.minDate, maxDate: props.maxDate, range: true, monthsShown: props.monthsShown, locale: props.locale, formatString: formatString,
|
|
18
|
+
// @ts-expect-error Calendar overrides type does not include date-picker overrides shape
|
|
19
19
|
overrides: props.overrides, fixedHeight: props.fixedHeight }, calendarProps)), footerContent] }))] })));
|
|
20
20
|
};
|
|
21
21
|
RangeSelector.displayName = 'RangeSelector';
|
|
@@ -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 flex flex-col", style: { maxHeight: '100vh' }, "data-testid": "time-range-selector-panel" }, { 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;
|
|
@@ -24,6 +24,7 @@ export type TimezonePickerProps = {
|
|
|
24
24
|
size?: Size;
|
|
25
25
|
clearable?: boolean;
|
|
26
26
|
placeholder?: string;
|
|
27
|
+
'aria-label'?: string;
|
|
27
28
|
/**
|
|
28
29
|
* When true, filters out deprecated timezone abbreviations (e.g., EST, PST, CET)
|
|
29
30
|
* and shows only modern IANA timezone identifiers (e.g., America/New_York).
|
|
@@ -5,6 +5,7 @@ import { Button } from '../button';
|
|
|
5
5
|
import { Stack, StackItem } from '../stack';
|
|
6
6
|
import { Typography } from '../typography';
|
|
7
7
|
import { StatefulPopover } from '../popover';
|
|
8
|
+
import { ACCESSIBILITY_TYPE } from '../baseui/popover';
|
|
8
9
|
/** @deprecated */
|
|
9
10
|
var ActionableTooltip = function (_a) {
|
|
10
11
|
var action = _a.action, renderFooter = _a.renderFooter, content = _a.content, children = _a.children, restProps = __rest(_a, ["action", "renderFooter", "content", "children"]);
|
|
@@ -16,6 +17,6 @@ var ActionableTooltip = function (_a) {
|
|
|
16
17
|
return renderPopoverContent(content({ close: close }));
|
|
17
18
|
}
|
|
18
19
|
: renderPopoverContent(content);
|
|
19
|
-
return (_jsx(StatefulPopover, __assign({ content: el, showArrow: true, autoFocus: false, triggerType: "hover" }, restProps, { children: children })));
|
|
20
|
+
return (_jsx(StatefulPopover, __assign({ content: el, showArrow: true, autoFocus: false, triggerType: "hover", accessibilityType: ACCESSIBILITY_TYPE.tooltip }, restProps, { children: children })));
|
|
20
21
|
};
|
|
21
22
|
export default ActionableTooltip;
|
package/list/divider.js
CHANGED
|
@@ -16,7 +16,7 @@ var Divider = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
16
16
|
'spr-border-primary border-solid border-b-0 border-l-0 border-r-0 mx-0 rounded-0',
|
|
17
17
|
first ? 'border-t-0 pt-0' : 'border-t',
|
|
18
18
|
className,
|
|
19
|
-
]
|
|
19
|
+
] }, propsWithoutContainerAria, subHeaderProps, { ref: ref, role: "presentation" }, { children: children }))) : ((0, jsx_runtime_1.jsx)(Separator, tslib_1.__assign({ "data-spaceweb": "divider", className: className }, propsWithoutContainerAria, { ref: ref }, separatorProps, { role: "presentation" })));
|
|
20
20
|
});
|
|
21
21
|
Divider.displayName = 'Divider';
|
|
22
22
|
exports.default = Divider;
|