@sprinklrjs/spaceweb 14.11.0 → 14.11.4
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/asyncSelect/hooks/useAsyncSelect.d.ts +3 -3
- package/asyncSelect/hooks/useGroupedAsyncSelect.d.ts +3 -3
- package/baseui/datepicker/styled-components.js +2 -2
- package/checkbox/checkbox.d.ts +1 -1
- package/checkbox/checkbox.js +5 -4
- package/checkbox/types.d.ts +8 -6
- package/color-picker/CustomColorSelector.d.ts +1 -1
- package/color-picker/CustomColorSelector.js +25 -8
- package/date-picker/DatePickerInput.d.ts +2 -2
- package/date-picker/DatePickerInput.js +1 -0
- package/esm/asyncSelect/hooks/useAsyncSelect.d.ts +3 -3
- package/esm/asyncSelect/hooks/useGroupedAsyncSelect.d.ts +3 -3
- package/esm/baseui/datepicker/styled-components.js +2 -2
- package/esm/checkbox/checkbox.d.ts +1 -1
- package/esm/checkbox/checkbox.js +6 -5
- package/esm/checkbox/types.d.ts +8 -6
- package/esm/color-picker/CustomColorSelector.d.ts +1 -1
- package/esm/color-picker/CustomColorSelector.js +26 -9
- package/esm/date-picker/DatePickerInput.d.ts +2 -2
- package/esm/date-picker/DatePickerInput.js +1 -0
- package/esm/helpers/colors.d.ts +1 -0
- package/esm/helpers/colors.js +14 -5
- package/esm/list/list.d.ts +1 -0
- package/esm/list/list.js +5 -4
- package/esm/list/types.d.ts +8 -4
- package/esm/list/utils.d.ts +5 -1
- package/esm/list/utils.js +15 -0
- package/esm/menu/ActionsIconButton.d.ts +5 -2
- package/esm/menu/StatefulSubMenu.d.ts +2 -1
- package/esm/menu/SubMenu.d.ts +2 -1
- package/esm/menu/SubMenu.js +2 -1
- package/esm/menu/index.d.ts +1 -1
- package/esm/menu/menu-item.js +35 -23
- package/esm/menu/menu.d.ts +2 -1
- package/esm/menu/types.d.ts +10 -2
- package/esm/progress/circular/CircularProgress.d.ts +3 -3
- package/esm/progress/circular/CircularProgress.js +3 -3
- package/esm/progress/linear/LinearProgress.d.ts +3 -3
- package/esm/progress/linear/LinearProgress.js +3 -3
- package/esm/select/selectMenuAdapter/CollapsibleSelectMenu.d.ts +1 -1
- package/esm/select/selectMenuAdapter/CollapsibleSelectMenu.js +21 -6
- package/esm/select/selectMenuAdapter/SelectMenuItem.d.ts +2 -1
- package/esm/tag/tag.d.ts +1 -0
- package/esm/tag/tag.js +2 -2
- package/esm/tag/types.d.ts +5 -4
- package/esm/time-range-picker/RangeSelectorContainer.d.ts +2 -2
- package/esm/time-range-picker/RangeSelectorContainer.js +13 -3
- package/helpers/colors.d.ts +1 -0
- package/helpers/colors.js +16 -6
- package/list/list.d.ts +1 -0
- package/list/list.js +3 -2
- package/list/types.d.ts +8 -4
- package/list/utils.d.ts +5 -1
- package/list/utils.js +17 -1
- package/menu/ActionsIconButton.d.ts +5 -2
- package/menu/StatefulSubMenu.d.ts +2 -1
- package/menu/SubMenu.d.ts +2 -1
- package/menu/SubMenu.js +2 -1
- package/menu/index.d.ts +1 -1
- package/menu/menu-item.js +34 -22
- package/menu/menu.d.ts +2 -1
- package/menu/types.d.ts +10 -2
- package/package.json +5 -4
- package/progress/circular/CircularProgress.d.ts +3 -3
- package/progress/circular/CircularProgress.js +2 -2
- package/progress/linear/LinearProgress.d.ts +3 -3
- package/progress/linear/LinearProgress.js +2 -2
- package/select/selectMenuAdapter/CollapsibleSelectMenu.d.ts +1 -1
- package/select/selectMenuAdapter/CollapsibleSelectMenu.js +21 -6
- package/select/selectMenuAdapter/SelectMenuItem.d.ts +2 -1
- package/tag/tag.d.ts +1 -0
- package/tag/tag.js +2 -2
- package/tag/types.d.ts +5 -4
- package/time-range-picker/RangeSelectorContainer.d.ts +2 -2
- package/time-range-picker/RangeSelectorContainer.js +12 -2
- package/tsconfig.build.tsbuildinfo +1 -1
package/helpers/colors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.noAlphaHex = exports.HslToRgb = exports.RgbToHsl = exports.getContrastRatio = exports.getRelativeLuminance = exports.RgbToHex = exports.hexToRgb = exports.isValidHex = void 0;
|
|
3
|
+
exports.normalizeHexWithAlpha = exports.noAlphaHex = exports.HslToRgb = exports.RgbToHsl = exports.getContrastRatio = exports.getRelativeLuminance = exports.RgbToHex = exports.hexToRgb = exports.isValidHex = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var memoize_1 = tslib_1.__importDefault(require("lodash/memoize"));
|
|
6
6
|
var isValidHex = function (hex) {
|
|
@@ -18,19 +18,20 @@ exports.isValidHex = isValidHex;
|
|
|
18
18
|
* @return {{r, g, b, a}} an object with rgba
|
|
19
19
|
*/
|
|
20
20
|
function hexToRgb(_hex) {
|
|
21
|
-
var hex = _hex.replace(/^#?/, '
|
|
21
|
+
var hex = _hex.replace(/^#?/, '');
|
|
22
22
|
if (!(0, exports.isValidHex)(hex))
|
|
23
23
|
return { r: 0, g: 0, b: 0 };
|
|
24
24
|
var isShortHand = hex.length === 3 || hex.length === 4;
|
|
25
|
-
var r = parseInt(isShortHand ? hex.substring(
|
|
26
|
-
var g = parseInt(isShortHand ? hex.substring(
|
|
27
|
-
var b = parseInt(isShortHand ? hex.substring(
|
|
28
|
-
var a = parseInt(isShortHand ? hex.substring(
|
|
25
|
+
var r = parseInt(isShortHand ? hex.substring(0, 1).repeat(2) : hex.substring(0, 2), 16);
|
|
26
|
+
var g = parseInt(isShortHand ? hex.substring(1, 2).repeat(2) : hex.substring(2, 4), 16);
|
|
27
|
+
var b = parseInt(isShortHand ? hex.substring(2, 3).repeat(2) : hex.substring(4, 6), 16);
|
|
28
|
+
var a = parseInt(isShortHand ? hex.substring(3, 4).repeat(2) : hex.substring(6, 8), 16);
|
|
29
29
|
return tslib_1.__assign({ r: r, g: g, b: b }, (a < 255 ? { a: a / 255 } : undefined));
|
|
30
30
|
}
|
|
31
31
|
exports.hexToRgb = hexToRgb;
|
|
32
32
|
function RgbToHex(_a) {
|
|
33
33
|
var r = _a.r, g = _a.g, b = _a.b, a = _a.a;
|
|
34
|
+
// eslint-disable-next-line react-google-translate/no-return-text-nodes -- This isn't a React Element
|
|
34
35
|
return "#".concat(tslib_1.__spreadArray([r, g, b], tslib_1.__read((a < 1 ? [Math.round(a * 255)] : [])), false).map(function (n) { return (Number.isNaN(n) ? 10 : Math.round(Math.min(Math.max(n, 0), 255))).toString(16).padStart(2, '0'); })
|
|
35
36
|
.join(''));
|
|
36
37
|
}
|
|
@@ -94,3 +95,12 @@ function noAlphaHex(inputHex) {
|
|
|
94
95
|
return inputHex;
|
|
95
96
|
}
|
|
96
97
|
exports.noAlphaHex = noAlphaHex;
|
|
98
|
+
function normalizeHexWithAlpha(hex, alpha) {
|
|
99
|
+
if (typeof alpha !== 'number' || alpha === 1 || !hex)
|
|
100
|
+
return hex;
|
|
101
|
+
return (hex +
|
|
102
|
+
Math.floor(alpha * 255)
|
|
103
|
+
.toString(16)
|
|
104
|
+
.padStart(2, '0'));
|
|
105
|
+
}
|
|
106
|
+
exports.normalizeHexWithAlpha = normalizeHexWithAlpha;
|
package/list/list.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponen
|
|
|
6
6
|
} & {
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
virtual?: boolean | undefined;
|
|
9
|
+
keepFirstItemMounted?: boolean | undefined;
|
|
9
10
|
overrides?: {
|
|
10
11
|
Root?: import("../overrides").Override<Record<string, any>> | undefined;
|
|
11
12
|
} | undefined;
|
package/list/list.js
CHANGED
|
@@ -23,8 +23,8 @@ var getCloneElement = function (item, virtualRow, totalCount) {
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
var List = React.forwardRef(function (_a, forwardedRef) {
|
|
26
|
-
var _b = _a.overrides, overrides = _b === void 0 ? {} : _b, children = _a.children, virtual = _a.virtual, scrollElement = _a.scrollElement, _c = _a.overscanCount, overscanCount = _c === void 0 ? constants_1.DEFAULT_OVER_SCAN_COUNT : _c, _d = _a.estimateItemSize, estimateItemSize = _d === void 0 ? constants_1.DEFAULT_LIST_ITEM_HEIGHT : _d, _e = _a.role, role = _e === void 0 ? 'list' : _e, autoScrollToSelectedItem = _a.autoScrollToSelectedItem, style = _a.style, className = _a.className, restProps = tslib_1.__rest(_a, ["overrides", "children", "virtual", "scrollElement", "overscanCount", "estimateItemSize", "role", "autoScrollToSelectedItem", "style", "className"]);
|
|
27
|
-
var
|
|
26
|
+
var _b = _a.overrides, overrides = _b === void 0 ? {} : _b, children = _a.children, virtual = _a.virtual, scrollElement = _a.scrollElement, _c = _a.overscanCount, overscanCount = _c === void 0 ? constants_1.DEFAULT_OVER_SCAN_COUNT : _c, _d = _a.estimateItemSize, estimateItemSize = _d === void 0 ? constants_1.DEFAULT_LIST_ITEM_HEIGHT : _d, _e = _a.role, role = _e === void 0 ? 'list' : _e, autoScrollToSelectedItem = _a.autoScrollToSelectedItem, style = _a.style, className = _a.className, _f = _a.keepFirstItemMounted, keepFirstItemMounted = _f === void 0 ? false : _f, restProps = tslib_1.__rest(_a, ["overrides", "children", "virtual", "scrollElement", "overscanCount", "estimateItemSize", "role", "autoScrollToSelectedItem", "style", "className", "keepFirstItemMounted"]);
|
|
27
|
+
var _g = tslib_1.__read((0, overrides_1.useOverrides)(overrides.Root, styled_component_1.StyledList), 2), Root = _g[0], rootProps = _g[1];
|
|
28
28
|
var parentRef = React.useRef(null);
|
|
29
29
|
var combinedRef = (0, useCombinedRef_1.default)(parentRef, forwardedRef);
|
|
30
30
|
var childrenArr = React.Children.toArray(children);
|
|
@@ -35,6 +35,7 @@ var List = React.forwardRef(function (_a, forwardedRef) {
|
|
|
35
35
|
estimateSize: function () { return estimateItemSize; },
|
|
36
36
|
overscan: overscanCount,
|
|
37
37
|
measureElement: utils_1.measureElement,
|
|
38
|
+
rangeExtractor: keepFirstItemMounted ? utils_1.customRangeExtractor : react_virtual_1.defaultRangeExtractor,
|
|
38
39
|
});
|
|
39
40
|
React.useEffect(function () {
|
|
40
41
|
if (!autoScrollToSelectedItem) {
|
package/list/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
|
-
import { Override } from '../overrides/types';
|
|
3
|
-
import { SpacewebComponentProps } from '../types';
|
|
4
|
-
import { StatefulTooltipProps } from '../tooltip';
|
|
1
|
+
import type { KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
|
+
import type { Override } from '../overrides/types';
|
|
3
|
+
import type { SpacewebComponentProps } from '../types';
|
|
4
|
+
import type { StatefulTooltipProps } from '../tooltip';
|
|
5
5
|
export type AlignItems = 'start' | 'center';
|
|
6
6
|
export type Enhancer<SharedProps> = ReactNode | ((props: SharedProps) => ReactNode);
|
|
7
7
|
export type ListItemSharedProps = {
|
|
@@ -36,6 +36,10 @@ export type ListItemProps = SpacewebComponentProps & {
|
|
|
36
36
|
export type ListProps = SpacewebComponentProps & {
|
|
37
37
|
children?: ReactNode;
|
|
38
38
|
virtual?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Forces the first item to stay mounted even when out of overscan range in virtualized list
|
|
41
|
+
*/
|
|
42
|
+
keepFirstItemMounted?: boolean;
|
|
39
43
|
overrides?: {
|
|
40
44
|
Root?: Override<Record<string, any>>;
|
|
41
45
|
};
|
package/list/utils.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import type { measureElement as measureElementType } from '@tanstack/react-virtual';
|
|
1
|
+
import type { measureElement as measureElementType, Range } from '@tanstack/react-virtual';
|
|
2
2
|
export declare const measureElement: typeof measureElementType;
|
|
3
|
+
/**
|
|
4
|
+
* Keeps the first item mounted even when it falls outside the range.
|
|
5
|
+
*/
|
|
6
|
+
export declare const customRangeExtractor: (range: Range) => number[];
|
package/list/utils.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.measureElement = void 0;
|
|
3
|
+
exports.customRangeExtractor = exports.measureElement = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_virtual_1 = require("@tanstack/react-virtual");
|
|
4
6
|
var parseMeasurement = function (str) { return parseFloat(str) || 0; };
|
|
5
7
|
// by default react-virtual uses getBoundingClientRect to calculate dimensions.
|
|
6
8
|
// overriding it to use height + margin, so that we do not have to wrap each ListItem with another element
|
|
@@ -12,3 +14,17 @@ var measureElement = function (element, instance) {
|
|
|
12
14
|
return instance.options.horizontal ? boundingRect.width + marginX : boundingRect.height + marginY;
|
|
13
15
|
};
|
|
14
16
|
exports.measureElement = measureElement;
|
|
17
|
+
/**
|
|
18
|
+
* Keeps the first item mounted even when it falls outside the range.
|
|
19
|
+
*/
|
|
20
|
+
var customRangeExtractor = function (range) {
|
|
21
|
+
var defaultIndices = (0, react_virtual_1.defaultRangeExtractor)(range);
|
|
22
|
+
// Find the actual start index of the range including overscan
|
|
23
|
+
var virtualRangeStart = Math.max(range.startIndex - range.overscan, 0);
|
|
24
|
+
// If the first item is already in the virtual range, return the default indices.
|
|
25
|
+
if (virtualRangeStart === 0)
|
|
26
|
+
return defaultIndices;
|
|
27
|
+
// Otherwise, prepend the first item to the default indices.
|
|
28
|
+
return tslib_1.__spreadArray([0], tslib_1.__read(defaultIndices), false);
|
|
29
|
+
};
|
|
30
|
+
exports.customRangeExtractor = customRangeExtractor;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type IconButtonProps } from '../button';
|
|
3
|
-
export type ActionsIconButtonProps = IconButtonProps
|
|
4
|
-
|
|
3
|
+
export type ActionsIconButtonProps = IconButtonProps & {
|
|
4
|
+
/** When true, the action stays visible even when the row is not hovered or keyboard-highlighted. */
|
|
5
|
+
alwaysVisible?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const ActionsIconButton: import("react").ForwardRefExoticComponent<ActionsIconButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
5
8
|
export default ActionsIconButton;
|
|
@@ -19,7 +19,7 @@ declare const StatefulSubMenu: import("react").ForwardRefExoticComponent<Omit<Me
|
|
|
19
19
|
onItemSelect?: ((item: SubMenuItem, event?: MouseEvent) => void) | undefined;
|
|
20
20
|
overrides?: {
|
|
21
21
|
Menu?: Override<Omit<import("../list").ListProps, "overrides"> & {
|
|
22
|
-
getActionsElement?: import("./types").MenuItemActions<import("./types").MenuActionItem
|
|
22
|
+
getActionsElement?: import("./types").MenuItemActions<import("./types").MenuActionItem> | undefined;
|
|
23
23
|
disableNavigationOnMount?: boolean | undefined;
|
|
24
24
|
focusWhenNavigationEnabled?: boolean | undefined;
|
|
25
25
|
keyboardFocusRestoreTarget?: HTMLElement | null | undefined;
|
|
@@ -31,6 +31,7 @@ declare const StatefulSubMenu: import("react").ForwardRefExoticComponent<Omit<Me
|
|
|
31
31
|
} & {
|
|
32
32
|
children?: ReactNode;
|
|
33
33
|
virtual?: boolean | undefined;
|
|
34
|
+
keepFirstItemMounted?: boolean | undefined;
|
|
34
35
|
overrides?: {
|
|
35
36
|
Root?: Override<Record<string, any>> | undefined;
|
|
36
37
|
} | undefined;
|
package/menu/SubMenu.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ declare const SubMenu: import("react").ForwardRefExoticComponent<Omit<MenuProps,
|
|
|
20
20
|
onItemSelect: (item: SubMenuItem, event?: MouseEvent) => void;
|
|
21
21
|
overrides?: {
|
|
22
22
|
Menu?: Override<Omit<import("../list").ListProps, "overrides"> & {
|
|
23
|
-
getActionsElement?: import("./types").MenuItemActions<import("./types").MenuActionItem
|
|
23
|
+
getActionsElement?: import("./types").MenuItemActions<import("./types").MenuActionItem> | undefined;
|
|
24
24
|
disableNavigationOnMount?: boolean | undefined;
|
|
25
25
|
focusWhenNavigationEnabled?: boolean | undefined;
|
|
26
26
|
keyboardFocusRestoreTarget?: HTMLElement | null | undefined;
|
|
@@ -32,6 +32,7 @@ declare const SubMenu: import("react").ForwardRefExoticComponent<Omit<MenuProps,
|
|
|
32
32
|
} & {
|
|
33
33
|
children?: ReactNode;
|
|
34
34
|
virtual?: boolean | undefined;
|
|
35
|
+
keepFirstItemMounted?: boolean | undefined;
|
|
35
36
|
overrides?: {
|
|
36
37
|
Root?: Override<Record<string, any>> | undefined;
|
|
37
38
|
} | undefined;
|
package/menu/SubMenu.js
CHANGED
|
@@ -37,7 +37,8 @@ var SubMenu = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
37
37
|
var itemsToRender = items.length
|
|
38
38
|
? (0, flatten_1.default)(items.map(function (item) { var _a; return (_a = itemRenderer === null || itemRenderer === void 0 ? void 0 : itemRenderer(item, onItemSelect)) !== null && _a !== void 0 ? _a : defaultItemRenderer(item, onItemSelect); }))
|
|
39
39
|
: (_c = emptyStateRenderer === null || emptyStateRenderer === void 0 ? void 0 : emptyStateRenderer(currentHeaderItem)) !== null && _c !== void 0 ? _c : null;
|
|
40
|
-
|
|
40
|
+
var shouldPinHeader = !!(props.virtual && currentHeaderItem !== undefined);
|
|
41
|
+
return ((0, jsx_runtime_1.jsxs)(MenuOverriden, tslib_1.__assign({ "aria-label": "Menu" }, props, menuProps, { keepFirstItemMounted: shouldPinHeader, ref: ref }, { children: [currentHeaderItem && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(box_1.Box, { ref: setStickySentinelRef }), (0, jsx_runtime_1.jsx)(HeaderMenuItem, tslib_1.__assign({ startEnhancer: (0, jsx_runtime_1.jsx)(chevron_left_1.default, {}), "aria-label": locale.menu.subMenuBackButtonAriaLabel }, (_b = {}, _b[helpers_1.SUBMENU_BACK_ROW_ATTR] = '', _b), menuItemProps, { className: [
|
|
41
42
|
'sticky top-0 w-full z-1 mb-1',
|
|
42
43
|
function (_, _a) {
|
|
43
44
|
var $highlighted = _a.$highlighted;
|
package/menu/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export { default as ActionsIconButton, type ActionsIconButtonProps } from './Act
|
|
|
4
4
|
export { default as NestedMenuProvider } from './nested-menu-context';
|
|
5
5
|
export { SubMenu, type SubMenuProps } from './SubMenu';
|
|
6
6
|
export { StatefulSubMenu, type StatefulSubMenuProps } from './StatefulSubMenu';
|
|
7
|
-
export type { MenuItemProps, ContextValue, MenuProps, MenuRef, SubMenuItem, MenuItemActions, MenuItemActionsParams, MenuActionItem, } from './types';
|
|
7
|
+
export type { MenuItemProps, ContextValue, MenuProps, MenuRef, SubMenuItem, MenuItemActions, MenuItemActionsParams, MenuItemActionsConfig, MenuActionItem, } from './types';
|
|
8
8
|
export { default as useStatefulSubMenu } from './useStatefulSubmenu';
|
package/menu/menu-item.js
CHANGED
|
@@ -19,12 +19,24 @@ var classNames_1 = tslib_1.__importDefault(require("../classNames"));
|
|
|
19
19
|
function resolveMenuActions(getActionsElement, item) {
|
|
20
20
|
if (!getActionsElement)
|
|
21
21
|
return null;
|
|
22
|
+
var menuActions;
|
|
22
23
|
if (typeof getActionsElement === 'function') {
|
|
23
24
|
if (item == null)
|
|
24
25
|
return null;
|
|
25
|
-
|
|
26
|
+
menuActions = getActionsElement({ item: item });
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
else {
|
|
29
|
+
menuActions = getActionsElement;
|
|
30
|
+
}
|
|
31
|
+
return menuActions.filter(function (action) {
|
|
32
|
+
// If array item is null | undefined
|
|
33
|
+
if (!action)
|
|
34
|
+
return false;
|
|
35
|
+
// If action object in array as no actionEl
|
|
36
|
+
if ('actionEl' in action && !action.actionEl)
|
|
37
|
+
return false;
|
|
38
|
+
return true;
|
|
39
|
+
});
|
|
28
40
|
}
|
|
29
41
|
var listItemOverrides = {
|
|
30
42
|
ListItem: {
|
|
@@ -63,8 +75,17 @@ var ACTION_CONTAINER_HANDLER_PROPS = {
|
|
|
63
75
|
},
|
|
64
76
|
};
|
|
65
77
|
function MenuActionContainer(_a) {
|
|
66
|
-
var sharedProps = _a.sharedProps,
|
|
67
|
-
return ((0, jsx_runtime_1.
|
|
78
|
+
var sharedProps = _a.sharedProps, renderedActions = _a.renderedActions;
|
|
79
|
+
return ((0, jsx_runtime_1.jsx)(box_1.Box, tslib_1.__assign({ className: ['flex items-center', sharedProps.$highlighted ? 'pointer-events-auto' : 'pointer-events-none'], "data-menu-action-container": "true" }, ACTION_CONTAINER_HANDLER_PROPS, { children: renderedActions.map(function (action, index) {
|
|
80
|
+
var _a;
|
|
81
|
+
var _b = 'actionEl' in action ? action : { actionEl: action, alwaysVisible: false }, actionEl = _b.actionEl, alwaysVisible = _b.alwaysVisible;
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)(box_1.Box, tslib_1.__assign({
|
|
83
|
+
// Only show actions that are always visible or whose parent item is highlighted
|
|
84
|
+
className: [
|
|
85
|
+
index === 0 ? 'ml-0' : 'ml-1',
|
|
86
|
+
alwaysVisible || sharedProps.$highlighted ? 'visible' : 'invisible w-0 ml-0',
|
|
87
|
+
] }, { children: React.cloneElement(actionEl, { tabIndex: -1 }) }), (_a = actionEl.key) !== null && _a !== void 0 ? _a : "menu-action-".concat(index)));
|
|
88
|
+
}) })));
|
|
68
89
|
}
|
|
69
90
|
function buildListItemAriaProps(itemRole, selected, ChildMenu) {
|
|
70
91
|
var props = {};
|
|
@@ -77,19 +98,9 @@ function buildListItemAriaProps(itemRole, selected, ChildMenu) {
|
|
|
77
98
|
return props;
|
|
78
99
|
}
|
|
79
100
|
function useResolvedMenuEndEnhancer(resolvedItemActions, shouldRenderActions, endEnhancer, ChildMenu) {
|
|
80
|
-
var renderedActions = (0, react_1.useMemo)(function () {
|
|
81
|
-
return shouldRenderActions
|
|
82
|
-
? React.Children.map(resolvedItemActions, function (action, index) {
|
|
83
|
-
var _a;
|
|
84
|
-
if (!React.isValidElement(action))
|
|
85
|
-
return action;
|
|
86
|
-
return React.cloneElement(action, { key: (_a = action.key) !== null && _a !== void 0 ? _a : "menu-action-".concat(index) });
|
|
87
|
-
})
|
|
88
|
-
: null;
|
|
89
|
-
}, [resolvedItemActions, shouldRenderActions]);
|
|
90
101
|
return (0, react_1.useMemo)(function () {
|
|
91
102
|
if (shouldRenderActions) {
|
|
92
|
-
return function (sharedProps) { return ((0, jsx_runtime_1.jsx)(MenuActionContainer, { sharedProps: sharedProps, endEnhancer: endEnhancer
|
|
103
|
+
return function (sharedProps) { return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(MenuActionContainer, { sharedProps: sharedProps, renderedActions: resolvedItemActions !== null && resolvedItemActions !== void 0 ? resolvedItemActions : [] }), typeof endEnhancer === 'function' ? endEnhancer(sharedProps) : endEnhancer !== null && endEnhancer !== void 0 ? endEnhancer : null] })); };
|
|
93
104
|
}
|
|
94
105
|
if (endEnhancer)
|
|
95
106
|
return endEnhancer;
|
|
@@ -97,7 +108,7 @@ function useResolvedMenuEndEnhancer(resolvedItemActions, shouldRenderActions, en
|
|
|
97
108
|
return (0, jsx_runtime_1.jsx)(chevron_down_1.default, { size: 14, className: "transform -rotate-90" });
|
|
98
109
|
}
|
|
99
110
|
return undefined;
|
|
100
|
-
}, [ChildMenu, endEnhancer,
|
|
111
|
+
}, [ChildMenu, endEnhancer, resolvedItemActions, shouldRenderActions]);
|
|
101
112
|
}
|
|
102
113
|
function useMenuItemInteractionHandlers(onMouseOver, ownRef, setHighlightedItem, setNestedMenuOpen) {
|
|
103
114
|
var onMouseOverRef = (0, useLatest_1.useLatest)(onMouseOver);
|
|
@@ -119,12 +130,13 @@ function useMenuItemInteractionHandlers(onMouseOver, ownRef, setHighlightedItem,
|
|
|
119
130
|
return { handleMouseOver: handleMouseOver, handleMouseMove: handleMouseMove, resetMenu: resetMenu, closeNestedMenu: closeNestedMenu };
|
|
120
131
|
}
|
|
121
132
|
var MenuItem = React.forwardRef(function MenuItem(_a, ref) {
|
|
133
|
+
var _b;
|
|
122
134
|
var selected = _a.selected, highlighted = _a.highlighted, overrides = _a.overrides, getChildMenu = _a.getChildMenu, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave, onMouseOver = _a.onMouseOver, endEnhancer = _a.endEnhancer, hideInlineActions = _a.hideInlineActions, renderAll = _a.renderAll, explicitRole = _a.role, $item = _a.$item, restProps = tslib_1.__rest(_a, ["selected", "highlighted", "overrides", "getChildMenu", "onMouseEnter", "onMouseLeave", "onMouseOver", "endEnhancer", "hideInlineActions", "renderAll", "role", "$item"]);
|
|
123
|
-
var
|
|
135
|
+
var _c = tslib_1.__read((0, react_1.useState)(false), 2), hovered = _c[0], setHovered = _c[1];
|
|
124
136
|
var ChildMenu = getChildMenu === null || getChildMenu === void 0 ? void 0 : getChildMenu();
|
|
125
137
|
var ownRef = (0, react_1.useRef)(null);
|
|
126
138
|
var itemRef = (0, useCombinedRef_1.default)(ref, ownRef);
|
|
127
|
-
var
|
|
139
|
+
var _d = (0, MenuContext_1.useMenuContext)(), getActionsElement = _d.getActionsElement, highlightedItem = _d.highlightedItem, setHighlightedItem = _d.setHighlightedItem, setMenuContainerRef = _d.setMenuContainerRef, listItemFocusVisible = _d.listItemFocusVisible, nestedMenuOpen = _d.nestedMenuOpen, setNestedMenuOpen = _d.setNestedMenuOpen;
|
|
128
140
|
var itemRole = explicitRole !== null && explicitRole !== void 0 ? explicitRole : 'menuitem';
|
|
129
141
|
(0, react_1.useEffect)(function () {
|
|
130
142
|
var _a, _b;
|
|
@@ -132,12 +144,12 @@ var MenuItem = React.forwardRef(function MenuItem(_a, ref) {
|
|
|
132
144
|
}, [setMenuContainerRef]);
|
|
133
145
|
var isItemHighlighted = highlighted || (highlightedItem !== null && highlightedItem === ownRef.current);
|
|
134
146
|
var resolvedItemActions = (0, react_1.useMemo)(function () { return resolveMenuActions(getActionsElement, $item); }, [getActionsElement, $item]);
|
|
135
|
-
var shouldRenderActions =
|
|
147
|
+
var shouldRenderActions = ((_b = resolvedItemActions === null || resolvedItemActions === void 0 ? void 0 : resolvedItemActions.length) !== null && _b !== void 0 ? _b : 0) > 0 && !ChildMenu && !hideInlineActions;
|
|
136
148
|
var resolvedEndEnhancer = useResolvedMenuEndEnhancer(resolvedItemActions, shouldRenderActions, endEnhancer, ChildMenu);
|
|
137
149
|
var mergedOverrides = (0, react_1.useMemo)(function () { return (0, overrides_1.mergeOverrides)(listItemOverrides, overrides); }, [overrides]);
|
|
138
|
-
var
|
|
139
|
-
var
|
|
140
|
-
var
|
|
150
|
+
var _e = tslib_1.__read((0, overrides_1.useOverrides)(mergedOverrides === null || mergedOverrides === void 0 ? void 0 : mergedOverrides.ListItem, list_item_1.default), 2), ListItemOverride = _e[0], listItemProps = _e[1];
|
|
151
|
+
var _f = tslib_1.__read((0, overrides_1.useOverrides)(mergedOverrides === null || mergedOverrides === void 0 ? void 0 : mergedOverrides.Popover, popover_1.Popover), 2), PopoverOverride = _f[0], popoverProps = _f[1];
|
|
152
|
+
var _g = useMenuItemInteractionHandlers(onMouseOver, ownRef, setHighlightedItem, setNestedMenuOpen), handleMouseOver = _g.handleMouseOver, handleMouseMove = _g.handleMouseMove, resetMenu = _g.resetMenu, closeNestedMenu = _g.closeNestedMenu;
|
|
141
153
|
var id = (0, useUniqueId_1.default)();
|
|
142
154
|
var listItem = ((0, jsx_runtime_1.jsx)(ListItemOverride, tslib_1.__assign({ id: id.toString(), ref: itemRef, role: itemRole, selected: selected, "data-haschildmenu": Boolean(ChildMenu), "data-hasactions": shouldRenderActions, highlighted: isItemHighlighted, "$outlined": isItemHighlighted && listItemFocusVisible, endEnhancer: resolvedEndEnhancer, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, "$item": $item }, buildListItemAriaProps(itemRole, selected, ChildMenu), restProps, { onMouseOver: handleMouseOver, onMouseMove: handleMouseMove }, listItemProps)));
|
|
143
155
|
var handleMouseEnter = (0, useCombinedHandler_1.default)(function () { return setHovered(true); }, onMouseEnter);
|
package/menu/menu.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { MenuRef } from './types';
|
|
3
3
|
import type { ClassName, Styles } from '../types';
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<import("../list").ListProps, "overrides"> & {
|
|
5
|
-
getActionsElement?: import("./types").MenuItemActions<import("./types").MenuActionItem
|
|
5
|
+
getActionsElement?: import("./types").MenuItemActions<import("./types").MenuActionItem> | undefined;
|
|
6
6
|
disableNavigationOnMount?: boolean | undefined;
|
|
7
7
|
focusWhenNavigationEnabled?: boolean | undefined;
|
|
8
8
|
keyboardFocusRestoreTarget?: HTMLElement | null | undefined;
|
|
@@ -14,6 +14,7 @@ declare const _default: import("react").MemoExoticComponent<import("react").Forw
|
|
|
14
14
|
} & {
|
|
15
15
|
children?: import("react").ReactNode;
|
|
16
16
|
virtual?: boolean | undefined;
|
|
17
|
+
keepFirstItemMounted?: boolean | undefined;
|
|
17
18
|
overrides?: {
|
|
18
19
|
Root?: import("../overrides").Override<Record<string, any>> | undefined;
|
|
19
20
|
} | undefined;
|
package/menu/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Dispatch, MutableRefObject, ReactElement,
|
|
1
|
+
import type { Dispatch, MutableRefObject, ReactElement, SetStateAction } from 'react';
|
|
2
2
|
import type { ListItemProps, ListItemSharedProps, ListProps } from '../list';
|
|
3
3
|
import type { Override } from '../overrides';
|
|
4
4
|
import type { PopoverProps } from '../popover';
|
|
@@ -32,7 +32,15 @@ export type MenuItemActionsParams<TItem extends MenuActionItem = MenuActionItem>
|
|
|
32
32
|
* Inline row actions: a static node for every row, or `({ item }) => …` for per-row actions
|
|
33
33
|
* (permissions, conditional buttons, etc.). Function form requires `$item` on {@link MenuItem}.
|
|
34
34
|
*/
|
|
35
|
-
export type
|
|
35
|
+
export type MenuItemActionsConfig = (ReactElement | null | undefined | {
|
|
36
|
+
actionEl: ReactElement | null | undefined;
|
|
37
|
+
alwaysVisible?: boolean;
|
|
38
|
+
})[];
|
|
39
|
+
export type ResolvedMenuItemActionsConfig = (ReactElement | {
|
|
40
|
+
actionEl: ReactElement;
|
|
41
|
+
alwaysVisible?: boolean;
|
|
42
|
+
})[];
|
|
43
|
+
export type MenuItemActions<TItem extends MenuActionItem = MenuActionItem> = MenuItemActionsConfig | ((params: MenuItemActionsParams<TItem>) => MenuItemActionsConfig);
|
|
36
44
|
export type MenuProps = Omit<ListProps, 'overrides'> & {
|
|
37
45
|
/**
|
|
38
46
|
* Action buttons rendered for each MenuItem (skips submenu items). Pass `({ item }) => …` to vary actions per row.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprinklrjs/spaceweb",
|
|
3
|
-
"version": "14.11.
|
|
3
|
+
"version": "14.11.4",
|
|
4
4
|
"description": "Components for SpaceWeb",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
"clean": "rm -rf dist && rm -f tsconfig.build.tsbuildinfo",
|
|
17
17
|
"test": "jest",
|
|
18
18
|
"test:watch": "jest --watch",
|
|
19
|
+
"test-a11y": "jest --config jest.a11y.config.js",
|
|
19
20
|
"//": "COLLECT_COVERAGE needs to be true to include VRT in the tests run during coverage",
|
|
20
21
|
"test:coverage": "COLLECT_COVERAGE=true jest --coverage",
|
|
21
|
-
"tsc": "
|
|
22
|
+
"tsc": "tsc",
|
|
22
23
|
"validateCoverageReport": "ts-node ./scripts/validateCoverageReport.ts"
|
|
23
24
|
},
|
|
24
25
|
"author": "",
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"@types/react-color": "^3.0.12",
|
|
34
35
|
"@types/styletron-engine-atomic": "^1.1.0",
|
|
35
36
|
"@types/styletron-react": "^5.0.2",
|
|
36
|
-
"any-date-parser": "2.2.
|
|
37
|
+
"any-date-parser": "2.2.3",
|
|
37
38
|
"body-scroll-lock": "3.1.5",
|
|
38
39
|
"card-validator": "^6.2.0",
|
|
39
40
|
"class-variance-authority": "^0.7.0",
|
|
@@ -99,7 +100,7 @@
|
|
|
99
100
|
"ts-node": "^10.4.0"
|
|
100
101
|
},
|
|
101
102
|
"peerDependencies": {
|
|
102
|
-
"@sprinklrjs/spaceweb-themes": "14.11.
|
|
103
|
+
"@sprinklrjs/spaceweb-themes": "14.11.4",
|
|
103
104
|
"react": ">=17.0.2 <19.0.0",
|
|
104
105
|
"react-dom": ">=17.0.2 <19.0.0"
|
|
105
106
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { CircularProgressProps } from './types';
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { CircularProgressProps } from './types';
|
|
3
3
|
declare const CircularProgress: {
|
|
4
|
-
({ intent, infinite, label, backgroundColor, value, className, style, color, size, thickness, overrides, }: CircularProgressProps): ReactElement;
|
|
4
|
+
({ intent, infinite, label, backgroundColor, value, className, style, color, size, thickness, overrides, ...restProps }: CircularProgressProps): ReactElement;
|
|
5
5
|
__standard: string;
|
|
6
6
|
};
|
|
7
7
|
export default CircularProgress;
|
|
@@ -8,7 +8,7 @@ var styled_component_1 = require("./styled-component");
|
|
|
8
8
|
var style_1 = require("../../style");
|
|
9
9
|
var helper_1 = require("../helper");
|
|
10
10
|
var CircularProgress = function (_a) {
|
|
11
|
-
var _b = _a.intent, intent = _b === void 0 ? 'default' : _b, _c = _a.infinite, infinite = _c === void 0 ? false : _c, label = _a.label, backgroundColor = _a.backgroundColor, _d = _a.value, value = _d === void 0 ? 0 : _d, className = _a.className, style = _a.style, color = _a.color, _e = _a.size, size = _e === void 0 ? 50 : _e, _f = _a.thickness, thickness = _f === void 0 ? 3 : _f, overrides = _a.overrides;
|
|
11
|
+
var _b = _a.intent, intent = _b === void 0 ? 'default' : _b, _c = _a.infinite, infinite = _c === void 0 ? false : _c, label = _a.label, backgroundColor = _a.backgroundColor, _d = _a.value, value = _d === void 0 ? 0 : _d, className = _a.className, style = _a.style, color = _a.color, _e = _a.size, size = _e === void 0 ? 50 : _e, _f = _a.thickness, thickness = _f === void 0 ? 3 : _f, overrides = _a.overrides, restProps = tslib_1.__rest(_a, ["intent", "infinite", "label", "backgroundColor", "value", "className", "style", "color", "size", "thickness", "overrides"]);
|
|
12
12
|
var strokeWidth = (styled_component_1.VIEWBOX_SIZE / size) * thickness;
|
|
13
13
|
var _g = (0, style_1.useStyle)(), px2rem = _g.px2rem, theme = _g.theme;
|
|
14
14
|
var sharedProps = tslib_1.__assign(tslib_1.__assign({}, (0, helpers_1.add$props)({ intent: intent, infinite: infinite, backgroundColor: backgroundColor, value: value, color: color, size: size, thickness: thickness, strokeWidth: strokeWidth })), { $withLabel: !!label });
|
|
@@ -19,7 +19,7 @@ var CircularProgress = function (_a) {
|
|
|
19
19
|
var _m = tslib_1.__read((0, overrides_1.useOverrides)(overrides === null || overrides === void 0 ? void 0 : overrides.Progress, styled_component_1.StyledProgress), 2), Progress = _m[0], progressProps = _m[1];
|
|
20
20
|
var _o = tslib_1.__read((0, overrides_1.useOverrides)(overrides === null || overrides === void 0 ? void 0 : overrides.LabelContainer, styled_component_1.StyledLabelContainer), 2), LabelContainer = _o[0], labelContainerProps = _o[1];
|
|
21
21
|
var _p = tslib_1.__read((0, overrides_1.useOverrides)(overrides === null || overrides === void 0 ? void 0 : overrides.Label, styled_component_1.StyledLabel), 2), Label = _p[0], labelProps = _p[1];
|
|
22
|
-
return ((0, jsx_runtime_1.jsxs)(Root, tslib_1.__assign({ role: "progressbar", "aria-valuenow": !infinite ? Math.round(value) : undefined, "aria-valuemin": !infinite ? 0 : undefined, "aria-valuemax": !infinite ? 100 : undefined }, sharedProps, rootProps, { style: [
|
|
22
|
+
return ((0, jsx_runtime_1.jsxs)(Root, tslib_1.__assign({ role: "progressbar", "aria-valuenow": !infinite ? Math.round(value) : undefined, "aria-valuemin": !infinite ? 0 : undefined, "aria-valuemax": !infinite ? 100 : undefined }, sharedProps, restProps, rootProps, { style: [
|
|
23
23
|
{
|
|
24
24
|
'--sw-height': px2rem(size),
|
|
25
25
|
'--sw-width': px2rem(size),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ReactElement, PropsWithChildren } from 'react';
|
|
2
|
-
import { LinearProgressProps } from './types';
|
|
1
|
+
import type { ReactElement, PropsWithChildren } from 'react';
|
|
2
|
+
import type { LinearProgressProps } from './types';
|
|
3
3
|
declare const LinearProgress: {
|
|
4
|
-
({ intent, value, backgroundColor, color, label, style, className, infinite, overrides, children, }: PropsWithChildren<LinearProgressProps>): ReactElement;
|
|
4
|
+
({ intent, value, backgroundColor, color, label, style, className, infinite, overrides, children, ...restProps }: PropsWithChildren<LinearProgressProps>): ReactElement;
|
|
5
5
|
__standard: string;
|
|
6
6
|
};
|
|
7
7
|
export default LinearProgress;
|
|
@@ -8,14 +8,14 @@ var styled_component_1 = require("./styled-component");
|
|
|
8
8
|
var helper_1 = require("../helper");
|
|
9
9
|
var style_1 = require("../../style");
|
|
10
10
|
var LinearProgress = function (_a) {
|
|
11
|
-
var _b = _a.intent, intent = _b === void 0 ? 'default' : _b, _c = _a.value, value = _c === void 0 ? 0 : _c, backgroundColor = _a.backgroundColor, color = _a.color, label = _a.label, style = _a.style, className = _a.className, _d = _a.infinite, infinite = _d === void 0 ? false : _d, overrides = _a.overrides, children = _a.children;
|
|
11
|
+
var _b = _a.intent, intent = _b === void 0 ? 'default' : _b, _c = _a.value, value = _c === void 0 ? 0 : _c, backgroundColor = _a.backgroundColor, color = _a.color, label = _a.label, style = _a.style, className = _a.className, _d = _a.infinite, infinite = _d === void 0 ? false : _d, overrides = _a.overrides, children = _a.children, restProps = tslib_1.__rest(_a, ["intent", "value", "backgroundColor", "color", "label", "style", "className", "infinite", "overrides", "children"]);
|
|
12
12
|
var sharedProps = tslib_1.__assign(tslib_1.__assign({}, (0, helpers_1.add$props)({ intent: intent, value: value, backgroundColor: backgroundColor, color: color, infinite: infinite })), { $withLabel: !!label });
|
|
13
13
|
var theme = (0, style_1.useStyle)().theme;
|
|
14
14
|
var _e = tslib_1.__read((0, overrides_1.useOverrides)(overrides === null || overrides === void 0 ? void 0 : overrides.Root, styled_component_1.StyledRoot), 2), Root = _e[0], rootProps = _e[1];
|
|
15
15
|
var _f = tslib_1.__read((0, overrides_1.useOverrides)(overrides === null || overrides === void 0 ? void 0 : overrides.Bar, styled_component_1.StyledBar), 2), Bar = _f[0], barProps = _f[1];
|
|
16
16
|
var _g = tslib_1.__read((0, overrides_1.useOverrides)(overrides === null || overrides === void 0 ? void 0 : overrides.Progress, styled_component_1.StyledProgress), 2), Progress = _g[0], progressProps = _g[1];
|
|
17
17
|
var _h = tslib_1.__read((0, overrides_1.useOverrides)(overrides === null || overrides === void 0 ? void 0 : overrides.Label, styled_component_1.StyledLabel), 2), Label = _h[0], labelProps = _h[1];
|
|
18
|
-
return ((0, jsx_runtime_1.jsxs)(Root, tslib_1.__assign({ "data-spaceweb": "linear-progress", role: "progressbar", "aria-valuenow": !infinite ? Math.round(value) : undefined, "aria-valuemin": !infinite ? 0 : undefined, "aria-valuemax": !infinite ? 100 : undefined }, sharedProps, rootProps, { style: [style, rootProps === null || rootProps === void 0 ? void 0 : rootProps.style], className: [className, rootProps === null || rootProps === void 0 ? void 0 : rootProps.className] }, { children: [(0, jsx_runtime_1.jsx)(Bar, tslib_1.__assign({ "data-testid": "track" }, sharedProps, barProps, { style: [{ '--sw-bg-color': backgroundColor || theme.spr.tag02 }, barProps === null || barProps === void 0 ? void 0 : barProps.style] }, { children: children || ((0, jsx_runtime_1.jsx)(Progress, tslib_1.__assign({ "data-testid": "filled-track" }, sharedProps, progressProps, { style: [
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)(Root, tslib_1.__assign({ "data-spaceweb": "linear-progress", role: "progressbar", "aria-valuenow": !infinite ? Math.round(value) : undefined, "aria-valuemin": !infinite ? 0 : undefined, "aria-valuemax": !infinite ? 100 : undefined }, sharedProps, restProps, rootProps, { style: [style, rootProps === null || rootProps === void 0 ? void 0 : rootProps.style], className: [className, rootProps === null || rootProps === void 0 ? void 0 : rootProps.className] }, { children: [(0, jsx_runtime_1.jsx)(Bar, tslib_1.__assign({ "data-testid": "track" }, sharedProps, barProps, { style: [{ '--sw-bg-color': backgroundColor || theme.spr.tag02 }, barProps === null || barProps === void 0 ? void 0 : barProps.style] }, { children: children || ((0, jsx_runtime_1.jsx)(Progress, tslib_1.__assign({ "data-testid": "filled-track" }, sharedProps, progressProps, { style: [
|
|
19
19
|
tslib_1.__assign({ '--sw-bg-color': color || (0, helper_1.getIntentColor)(intent, theme) }, (!infinite ? { '--sw-width': "".concat(value, "%") } : {})),
|
|
20
20
|
progressProps === null || progressProps === void 0 ? void 0 : progressProps.style,
|
|
21
21
|
] }))) })), label ? ((0, jsx_runtime_1.jsx)(Label, tslib_1.__assign({}, sharedProps, labelProps, { children: typeof label === 'function' ? label(sharedProps) : label }))) : null] })));
|
|
@@ -114,7 +114,7 @@ export declare const CollapsibleSelectMenu: ({ overrides, value, items: groupedI
|
|
|
114
114
|
virtual?: boolean | undefined;
|
|
115
115
|
overscanCount?: number | undefined;
|
|
116
116
|
selectOnTab?: boolean | undefined;
|
|
117
|
-
getActionsElement?: import("../../menu").MenuItemActions;
|
|
117
|
+
getActionsElement?: import("../../menu").MenuItemActions | undefined;
|
|
118
118
|
inputElement?: HTMLInputElement | null | undefined;
|
|
119
119
|
} & {
|
|
120
120
|
$onPaginate?: ((event: UIEvent<HTMLElement>, itemGroup: string) => void) | undefined;
|
|
@@ -25,8 +25,13 @@ var locale_1 = require("../../locale");
|
|
|
25
25
|
var DocumentProvider_1 = require("../../spacewebProvider/DocumentProvider");
|
|
26
26
|
var hidden_element_1 = require("../utils/hidden-element");
|
|
27
27
|
var SelectIdsContext_1 = require("../SelectIdsContext");
|
|
28
|
+
var number_1 = require("../../number");
|
|
28
29
|
var Collapsible = function (_a) {
|
|
30
|
+
var _b;
|
|
29
31
|
var children = _a.children, group = _a.group, expanded = _a.expanded, onClick = _a.onClick, disabled = _a.disabled, className = _a.className;
|
|
32
|
+
var formattedCount = (0, number_1.useNumber)({
|
|
33
|
+
value: (_b = group.count) !== null && _b !== void 0 ? _b : 0,
|
|
34
|
+
});
|
|
30
35
|
return ((0, jsx_runtime_1.jsxs)(box_1.Box, tslib_1.__assign({ className: "rounded-inherit" }, { children: [(0, jsx_runtime_1.jsxs)(base_button_1.BaseButton, tslib_1.__assign({ tabIndex: -1, disabled: disabled, onClick: function () { return onClick(group.id); },
|
|
31
36
|
// @ts-ignore -- css variable declaration in style props
|
|
32
37
|
style: { '--sw-padding-block-start': '0.55rem', '--sw-padding-block-end': '0.55rem' }, className: [
|
|
@@ -34,7 +39,7 @@ var Collapsible = function (_a) {
|
|
|
34
39
|
'pt-[--sw-padding-block-start] pb-[--sw-padding-block-end] pl-2 pr-2.5',
|
|
35
40
|
'disabled:opacity-60 disabled:cursor-not-allowed focus-visible:outline-none',
|
|
36
41
|
className,
|
|
37
|
-
], type: "button" }, { children: [(0, jsx_runtime_1.jsxs)(typography_1.Typography, tslib_1.__assign({ className: "block text-left", variant: "body-sm", weight: "bold", maxLines: 2 }, { children: [(0, jsx_runtime_1.jsx)(box_1.Box, tslib_1.__assign({ "$as": "span" }, { children: group.label })), (0, isNumber_1.default)(group.count) ? (0, jsx_runtime_1.jsx)(box_1.Box, tslib_1.__assign({ "$as": "span" }, { children: " (".concat(
|
|
42
|
+
], type: "button" }, { children: [(0, jsx_runtime_1.jsxs)(typography_1.Typography, tslib_1.__assign({ className: "block text-left", variant: "body-sm", weight: "bold", maxLines: 2 }, { children: [(0, jsx_runtime_1.jsx)(box_1.Box, tslib_1.__assign({ "$as": "span" }, { children: group.label })), (0, isNumber_1.default)(group.count) ? (0, jsx_runtime_1.jsx)(box_1.Box, tslib_1.__assign({ "$as": "span" }, { children: " (".concat(formattedCount, ")") })) : null] })), (0, jsx_runtime_1.jsx)(chevron_down_1.default, { size: 12, className: "transition-transform duration-200 ml-1 cursor-pointer spr-icon-primary ".concat(expanded ? 'rotate-180' : ''), "data-testid": expanded ? "".concat(group.id, "-expanded") : "".concat(group.id, "-collapsed") })] })), (0, jsx_runtime_1.jsx)(collapse_1.Collapse, tslib_1.__assign({ unmountOnExit: true, mountOnEnter: true, visible: expanded }, { children: children }))] })));
|
|
38
43
|
};
|
|
39
44
|
var CollapsibleSelectMenu = function (_a) {
|
|
40
45
|
var _b, _c, _d, _e;
|
|
@@ -76,13 +81,16 @@ var CollapsibleSelectMenu = function (_a) {
|
|
|
76
81
|
}); }, [mergedOverrides.ListItemText, mergedOverrides.MenuItem]);
|
|
77
82
|
(0, react_1.useEffect)(function () {
|
|
78
83
|
var keydownHandler = function (event) {
|
|
79
|
-
var expandedGroupIndex =
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
var expandedGroupIndex = groupConfig.findIndex(function (group) { return group.id === expandedGroupId; });
|
|
85
|
+
var noGroupExpanded = expandedGroupIndex === -1;
|
|
86
|
+
if (event.key === 'ArrowDown' && (event.shiftKey || noGroupExpanded || isLastItemHighlighted.current)) {
|
|
87
|
+
var nextGroupIndex = noGroupExpanded ? 0 : Math.min(expandedGroupIndex + 1, groupConfig.length - 1);
|
|
88
|
+
setExpandedGroupId(groupConfig[nextGroupIndex].id);
|
|
82
89
|
event.stopPropagation(); // prevents the menu to move to the second item of the next group
|
|
83
90
|
}
|
|
84
|
-
else if (event.key === 'ArrowUp' && (event.shiftKey || isFirstItemHighlighted.current)) {
|
|
85
|
-
|
|
91
|
+
else if (event.key === 'ArrowUp' && (event.shiftKey || noGroupExpanded || isFirstItemHighlighted.current)) {
|
|
92
|
+
var prevGroupIndex = noGroupExpanded ? groupConfig.length - 1 : Math.max(expandedGroupIndex - 1, 0);
|
|
93
|
+
setExpandedGroupId(groupConfig[prevGroupIndex].id);
|
|
86
94
|
}
|
|
87
95
|
};
|
|
88
96
|
ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body.addEventListener('keydown', keydownHandler);
|
|
@@ -90,6 +98,13 @@ var CollapsibleSelectMenu = function (_a) {
|
|
|
90
98
|
ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body.removeEventListener('keydown', keydownHandler);
|
|
91
99
|
};
|
|
92
100
|
}, [ownerDocument, expandedGroupId, groupConfig, setExpandedGroupId]);
|
|
101
|
+
// when the NoResults component is rendered, handleOnHighlightedItemChange is not triggered
|
|
102
|
+
(0, react_1.useEffect)(function () {
|
|
103
|
+
if (expandedGroupId && (0, isEmpty_1.default)(groupedItems[expandedGroupId])) {
|
|
104
|
+
isFirstItemHighlighted.current = true;
|
|
105
|
+
isLastItemHighlighted.current = true;
|
|
106
|
+
}
|
|
107
|
+
}, [expandedGroupId, groupedItems]);
|
|
93
108
|
var handleOnHighlightedItemChange = function (item) {
|
|
94
109
|
var _a;
|
|
95
110
|
var nextHighlightableElement = (0, helpers_1.getNextItemIndexToHighlight)(item !== null && item !== void 0 ? item : null, menuRef.current, helpers_1.nextItem);
|
|
@@ -23,7 +23,6 @@ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponen
|
|
|
23
23
|
} & {
|
|
24
24
|
alignItems?: import("../../list").AlignItems | undefined;
|
|
25
25
|
autoFocus?: boolean | undefined;
|
|
26
|
-
/** Select-all, group-select-all, clear, and creatable rows do not show `getActionsElement` by default. */
|
|
27
26
|
button?: boolean | undefined;
|
|
28
27
|
children?: React.ReactNode;
|
|
29
28
|
disabled?: boolean | undefined;
|
|
@@ -65,8 +64,10 @@ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponen
|
|
|
65
64
|
Checkbox?: Override<Omit<{
|
|
66
65
|
'aria-describedby'?: string | undefined;
|
|
67
66
|
'aria-errormessage'?: string | undefined;
|
|
67
|
+
'aria-hidden'?: boolean | "false" | "true" | undefined;
|
|
68
68
|
ariaLabel?: string | undefined;
|
|
69
69
|
'aria-label'?: string | undefined;
|
|
70
|
+
tabIndex?: number | undefined;
|
|
70
71
|
children?: React.ReactNode;
|
|
71
72
|
containsInteractiveElement?: boolean | undefined;
|
|
72
73
|
overrides?: import("../../checkbox").CheckboxOverrides | undefined;
|
package/tag/tag.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
declare const Tag: import("react").ForwardRefExoticComponent<Omit<{
|
|
3
3
|
closeable?: boolean | undefined;
|
|
4
|
+
closeAriaLabel?: string | undefined;
|
|
4
5
|
isFocused?: boolean | undefined;
|
|
5
6
|
isHovered?: boolean | undefined;
|
|
6
7
|
children?: import("react").ReactNode;
|
package/tag/tag.js
CHANGED
|
@@ -19,7 +19,7 @@ var locale_1 = require("../locale");
|
|
|
19
19
|
var useTruncateWithTooltip_1 = require("../truncateWithTooltip/hooks/useTruncateWithTooltip");
|
|
20
20
|
var utils_1 = require("./utils");
|
|
21
21
|
var Tag = (0, react_1.forwardRef)(function (props, ref) {
|
|
22
|
-
var children = props.children, _a = props.closeable, closeable = _a === void 0 ? true : _a, _size = props.size, _b = props.shape, shape = _b === void 0 ? 'default' : _b, _c = props.isFocused, isFocused = _c === void 0 ? false : _c, _d = props.isHovered, isHovered = _d === void 0 ? false : _d, onActionClick = props.onActionClick, onActionKeyDown = props.onActionKeyDown, _e = props.onClick, onClick = _e === void 0 ? null : _e, _f = props.onKeyDown, onKeyDown = _f === void 0 ? null : _f, overrides = props.overrides, title = props.title, _g = props.variant, variant = _g === void 0 ? 'light' : _g, _h = props.intent, intent = _h === void 0 ? 'default' : _h, _j = props.appearance, appearance = _j === void 0 ? 'gray' : _j, className = props.className, startEnhancer = props.startEnhancer, noTooltipOnTruncation = props.noTooltipOnTruncation, restProps = tslib_1.__rest(props, ["children", "closeable", "size", "shape", "isFocused", "isHovered", "onActionClick", "onActionKeyDown", "onClick", "onKeyDown", "overrides", "title", "variant", "intent", "appearance", "className", "startEnhancer", "noTooltipOnTruncation"]);
|
|
22
|
+
var children = props.children, _a = props.closeable, closeable = _a === void 0 ? true : _a, closeAriaLabel = props.closeAriaLabel, _size = props.size, _b = props.shape, shape = _b === void 0 ? 'default' : _b, _c = props.isFocused, isFocused = _c === void 0 ? false : _c, _d = props.isHovered, isHovered = _d === void 0 ? false : _d, onActionClick = props.onActionClick, onActionKeyDown = props.onActionKeyDown, _e = props.onClick, onClick = _e === void 0 ? null : _e, _f = props.onKeyDown, onKeyDown = _f === void 0 ? null : _f, overrides = props.overrides, title = props.title, _g = props.variant, variant = _g === void 0 ? 'light' : _g, _h = props.intent, intent = _h === void 0 ? 'default' : _h, _j = props.appearance, appearance = _j === void 0 ? 'gray' : _j, className = props.className, startEnhancer = props.startEnhancer, noTooltipOnTruncation = props.noTooltipOnTruncation, restProps = tslib_1.__rest(props, ["children", "closeable", "closeAriaLabel", "size", "shape", "isFocused", "isHovered", "onActionClick", "onActionKeyDown", "onClick", "onKeyDown", "overrides", "title", "variant", "intent", "appearance", "className", "startEnhancer", "noTooltipOnTruncation"]);
|
|
23
23
|
var _k = (0, useFocusVisible_1.useFocusVisible)(), $isFocusVisible = _k.$isFocusVisible, onBlur = _k.onBlur, onFocus = _k.onFocus;
|
|
24
24
|
var theme = (0, style_1.useStyle)().theme;
|
|
25
25
|
var locale = (0, locale_1.useLocale)();
|
|
@@ -69,7 +69,7 @@ var Tag = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
69
69
|
actionIconButtonOverrides,
|
|
70
70
|
], style: {
|
|
71
71
|
'--sw-color': theme.spr.iconTertiary,
|
|
72
|
-
}, "aria-label": locale.tag.closeAriaLabel, tabIndex: actionProps === null || actionProps === void 0 ? void 0 : actionProps.tabIndex }, { children: (0, jsx_runtime_1.jsx)(ActionIcon, tslib_1.__assign({ size: clearableIconSize }, actionIconProps)) })) }))) : null] })));
|
|
72
|
+
}, "aria-label": closeAriaLabel !== null && closeAriaLabel !== void 0 ? closeAriaLabel : locale.tag.closeAriaLabel, tabIndex: actionProps === null || actionProps === void 0 ? void 0 : actionProps.tabIndex }, { children: (0, jsx_runtime_1.jsx)(ActionIcon, tslib_1.__assign({ size: clearableIconSize }, actionIconProps)) })) }))) : null] })));
|
|
73
73
|
});
|
|
74
74
|
Tag.displayName = 'Tag';
|
|
75
75
|
Tag.__standard = 'Component';
|