@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/esm/list/list.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __assign, __read, __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
4
|
+
import { useVirtualizer, defaultRangeExtractor } from '@tanstack/react-virtual';
|
|
5
5
|
import { useOverrides } from '../overrides';
|
|
6
6
|
import useCombinedRef, { combineRefs } from '../hooks/useCombinedRef';
|
|
7
7
|
import { LIST_MIN_WIDTH, StyledList } from './styled-component';
|
|
8
8
|
import { Box } from '../box';
|
|
9
|
-
import { measureElement } from './utils';
|
|
9
|
+
import { customRangeExtractor, measureElement } from './utils';
|
|
10
10
|
import { DEFAULT_LIST_ITEM_HEIGHT, DEFAULT_OVER_SCAN_COUNT } from './constants';
|
|
11
11
|
import { useStyle } from '../style';
|
|
12
12
|
var getCloneElement = function (item, virtualRow, totalCount) {
|
|
@@ -21,8 +21,8 @@ var getCloneElement = function (item, virtualRow, totalCount) {
|
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
23
|
var List = React.forwardRef(function (_a, forwardedRef) {
|
|
24
|
-
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 ? DEFAULT_OVER_SCAN_COUNT : _c, _d = _a.estimateItemSize, estimateItemSize = _d === void 0 ? DEFAULT_LIST_ITEM_HEIGHT : _d, _e = _a.role, role = _e === void 0 ? 'list' : _e, autoScrollToSelectedItem = _a.autoScrollToSelectedItem, style = _a.style, className = _a.className, restProps = __rest(_a, ["overrides", "children", "virtual", "scrollElement", "overscanCount", "estimateItemSize", "role", "autoScrollToSelectedItem", "style", "className"]);
|
|
25
|
-
var
|
|
24
|
+
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 ? DEFAULT_OVER_SCAN_COUNT : _c, _d = _a.estimateItemSize, estimateItemSize = _d === void 0 ? 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 = __rest(_a, ["overrides", "children", "virtual", "scrollElement", "overscanCount", "estimateItemSize", "role", "autoScrollToSelectedItem", "style", "className", "keepFirstItemMounted"]);
|
|
25
|
+
var _g = __read(useOverrides(overrides.Root, StyledList), 2), Root = _g[0], rootProps = _g[1];
|
|
26
26
|
var parentRef = React.useRef(null);
|
|
27
27
|
var combinedRef = useCombinedRef(parentRef, forwardedRef);
|
|
28
28
|
var childrenArr = React.Children.toArray(children);
|
|
@@ -33,6 +33,7 @@ var List = React.forwardRef(function (_a, forwardedRef) {
|
|
|
33
33
|
estimateSize: function () { return estimateItemSize; },
|
|
34
34
|
overscan: overscanCount,
|
|
35
35
|
measureElement: measureElement,
|
|
36
|
+
rangeExtractor: keepFirstItemMounted ? customRangeExtractor : defaultRangeExtractor,
|
|
36
37
|
});
|
|
37
38
|
React.useEffect(function () {
|
|
38
39
|
if (!autoScrollToSelectedItem) {
|
package/esm/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/esm/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/esm/list/utils.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
|
+
import { defaultRangeExtractor } from '@tanstack/react-virtual';
|
|
1
3
|
var parseMeasurement = function (str) { return parseFloat(str) || 0; };
|
|
2
4
|
// by default react-virtual uses getBoundingClientRect to calculate dimensions.
|
|
3
5
|
// overriding it to use height + margin, so that we do not have to wrap each ListItem with another element
|
|
@@ -8,3 +10,16 @@ export var measureElement = function (element, instance) {
|
|
|
8
10
|
var boundingRect = element.getBoundingClientRect();
|
|
9
11
|
return instance.options.horizontal ? boundingRect.width + marginX : boundingRect.height + marginY;
|
|
10
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Keeps the first item mounted even when it falls outside the range.
|
|
15
|
+
*/
|
|
16
|
+
export var customRangeExtractor = function (range) {
|
|
17
|
+
var defaultIndices = defaultRangeExtractor(range);
|
|
18
|
+
// Find the actual start index of the range including overscan
|
|
19
|
+
var virtualRangeStart = Math.max(range.startIndex - range.overscan, 0);
|
|
20
|
+
// If the first item is already in the virtual range, return the default indices.
|
|
21
|
+
if (virtualRangeStart === 0)
|
|
22
|
+
return defaultIndices;
|
|
23
|
+
// Otherwise, prepend the first item to the default indices.
|
|
24
|
+
return __spreadArray([0], __read(defaultIndices), false);
|
|
25
|
+
};
|
|
@@ -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/esm/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/esm/menu/SubMenu.js
CHANGED
|
@@ -34,7 +34,8 @@ var SubMenu = forwardRef(function (_a, ref) {
|
|
|
34
34
|
var itemsToRender = items.length
|
|
35
35
|
? _flatten(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); }))
|
|
36
36
|
: (_c = emptyStateRenderer === null || emptyStateRenderer === void 0 ? void 0 : emptyStateRenderer(currentHeaderItem)) !== null && _c !== void 0 ? _c : null;
|
|
37
|
-
|
|
37
|
+
var shouldPinHeader = !!(props.virtual && currentHeaderItem !== undefined);
|
|
38
|
+
return (_jsxs(MenuOverriden, __assign({ "aria-label": "Menu" }, props, menuProps, { keepFirstItemMounted: shouldPinHeader, ref: ref }, { children: [currentHeaderItem && (_jsxs(_Fragment, { children: [_jsx(Box, { ref: setStickySentinelRef }), _jsx(HeaderMenuItem, __assign({ startEnhancer: _jsx(ChevronLeft, {}), "aria-label": locale.menu.subMenuBackButtonAriaLabel }, (_b = {}, _b[SUBMENU_BACK_ROW_ATTR] = '', _b), menuItemProps, { className: [
|
|
38
39
|
'sticky top-0 w-full z-1 mb-1',
|
|
39
40
|
function (_, _a) {
|
|
40
41
|
var $highlighted = _a.$highlighted;
|
package/esm/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/esm/menu/menu-item.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign, __read, __rest } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { Box } from '../box';
|
|
@@ -17,12 +17,24 @@ import cx from '../classNames';
|
|
|
17
17
|
function resolveMenuActions(getActionsElement, item) {
|
|
18
18
|
if (!getActionsElement)
|
|
19
19
|
return null;
|
|
20
|
+
var menuActions;
|
|
20
21
|
if (typeof getActionsElement === 'function') {
|
|
21
22
|
if (item == null)
|
|
22
23
|
return null;
|
|
23
|
-
|
|
24
|
+
menuActions = getActionsElement({ item: item });
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
else {
|
|
27
|
+
menuActions = getActionsElement;
|
|
28
|
+
}
|
|
29
|
+
return menuActions.filter(function (action) {
|
|
30
|
+
// If array item is null | undefined
|
|
31
|
+
if (!action)
|
|
32
|
+
return false;
|
|
33
|
+
// If action object in array as no actionEl
|
|
34
|
+
if ('actionEl' in action && !action.actionEl)
|
|
35
|
+
return false;
|
|
36
|
+
return true;
|
|
37
|
+
});
|
|
26
38
|
}
|
|
27
39
|
var listItemOverrides = {
|
|
28
40
|
ListItem: {
|
|
@@ -61,8 +73,17 @@ var ACTION_CONTAINER_HANDLER_PROPS = {
|
|
|
61
73
|
},
|
|
62
74
|
};
|
|
63
75
|
function MenuActionContainer(_a) {
|
|
64
|
-
var sharedProps = _a.sharedProps,
|
|
65
|
-
return (
|
|
76
|
+
var sharedProps = _a.sharedProps, renderedActions = _a.renderedActions;
|
|
77
|
+
return (_jsx(Box, __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) {
|
|
78
|
+
var _a;
|
|
79
|
+
var _b = 'actionEl' in action ? action : { actionEl: action, alwaysVisible: false }, actionEl = _b.actionEl, alwaysVisible = _b.alwaysVisible;
|
|
80
|
+
return (_jsx(Box, __assign({
|
|
81
|
+
// Only show actions that are always visible or whose parent item is highlighted
|
|
82
|
+
className: [
|
|
83
|
+
index === 0 ? 'ml-0' : 'ml-1',
|
|
84
|
+
alwaysVisible || sharedProps.$highlighted ? 'visible' : 'invisible w-0 ml-0',
|
|
85
|
+
] }, { children: React.cloneElement(actionEl, { tabIndex: -1 }) }), (_a = actionEl.key) !== null && _a !== void 0 ? _a : "menu-action-".concat(index)));
|
|
86
|
+
}) })));
|
|
66
87
|
}
|
|
67
88
|
function buildListItemAriaProps(itemRole, selected, ChildMenu) {
|
|
68
89
|
var props = {};
|
|
@@ -75,19 +96,9 @@ function buildListItemAriaProps(itemRole, selected, ChildMenu) {
|
|
|
75
96
|
return props;
|
|
76
97
|
}
|
|
77
98
|
function useResolvedMenuEndEnhancer(resolvedItemActions, shouldRenderActions, endEnhancer, ChildMenu) {
|
|
78
|
-
var renderedActions = useMemo(function () {
|
|
79
|
-
return shouldRenderActions
|
|
80
|
-
? React.Children.map(resolvedItemActions, function (action, index) {
|
|
81
|
-
var _a;
|
|
82
|
-
if (!React.isValidElement(action))
|
|
83
|
-
return action;
|
|
84
|
-
return React.cloneElement(action, { key: (_a = action.key) !== null && _a !== void 0 ? _a : "menu-action-".concat(index) });
|
|
85
|
-
})
|
|
86
|
-
: null;
|
|
87
|
-
}, [resolvedItemActions, shouldRenderActions]);
|
|
88
99
|
return useMemo(function () {
|
|
89
100
|
if (shouldRenderActions) {
|
|
90
|
-
return function (sharedProps) { return (_jsx(MenuActionContainer, { sharedProps: sharedProps, endEnhancer: endEnhancer
|
|
101
|
+
return function (sharedProps) { return (_jsxs(_Fragment, { children: [_jsx(MenuActionContainer, { sharedProps: sharedProps, renderedActions: resolvedItemActions !== null && resolvedItemActions !== void 0 ? resolvedItemActions : [] }), typeof endEnhancer === 'function' ? endEnhancer(sharedProps) : endEnhancer !== null && endEnhancer !== void 0 ? endEnhancer : null] })); };
|
|
91
102
|
}
|
|
92
103
|
if (endEnhancer)
|
|
93
104
|
return endEnhancer;
|
|
@@ -95,7 +106,7 @@ function useResolvedMenuEndEnhancer(resolvedItemActions, shouldRenderActions, en
|
|
|
95
106
|
return _jsx(ChevronDown, { size: 14, className: "transform -rotate-90" });
|
|
96
107
|
}
|
|
97
108
|
return undefined;
|
|
98
|
-
}, [ChildMenu, endEnhancer,
|
|
109
|
+
}, [ChildMenu, endEnhancer, resolvedItemActions, shouldRenderActions]);
|
|
99
110
|
}
|
|
100
111
|
function useMenuItemInteractionHandlers(onMouseOver, ownRef, setHighlightedItem, setNestedMenuOpen) {
|
|
101
112
|
var onMouseOverRef = useLatest(onMouseOver);
|
|
@@ -117,12 +128,13 @@ function useMenuItemInteractionHandlers(onMouseOver, ownRef, setHighlightedItem,
|
|
|
117
128
|
return { handleMouseOver: handleMouseOver, handleMouseMove: handleMouseMove, resetMenu: resetMenu, closeNestedMenu: closeNestedMenu };
|
|
118
129
|
}
|
|
119
130
|
var MenuItem = React.forwardRef(function MenuItem(_a, ref) {
|
|
131
|
+
var _b;
|
|
120
132
|
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 = __rest(_a, ["selected", "highlighted", "overrides", "getChildMenu", "onMouseEnter", "onMouseLeave", "onMouseOver", "endEnhancer", "hideInlineActions", "renderAll", "role", "$item"]);
|
|
121
|
-
var
|
|
133
|
+
var _c = __read(useState(false), 2), hovered = _c[0], setHovered = _c[1];
|
|
122
134
|
var ChildMenu = getChildMenu === null || getChildMenu === void 0 ? void 0 : getChildMenu();
|
|
123
135
|
var ownRef = useRef(null);
|
|
124
136
|
var itemRef = useCombinedRefs(ref, ownRef);
|
|
125
|
-
var
|
|
137
|
+
var _d = useMenuContext(), getActionsElement = _d.getActionsElement, highlightedItem = _d.highlightedItem, setHighlightedItem = _d.setHighlightedItem, setMenuContainerRef = _d.setMenuContainerRef, listItemFocusVisible = _d.listItemFocusVisible, nestedMenuOpen = _d.nestedMenuOpen, setNestedMenuOpen = _d.setNestedMenuOpen;
|
|
126
138
|
var itemRole = explicitRole !== null && explicitRole !== void 0 ? explicitRole : 'menuitem';
|
|
127
139
|
useEffect(function () {
|
|
128
140
|
var _a, _b;
|
|
@@ -130,12 +142,12 @@ var MenuItem = React.forwardRef(function MenuItem(_a, ref) {
|
|
|
130
142
|
}, [setMenuContainerRef]);
|
|
131
143
|
var isItemHighlighted = highlighted || (highlightedItem !== null && highlightedItem === ownRef.current);
|
|
132
144
|
var resolvedItemActions = useMemo(function () { return resolveMenuActions(getActionsElement, $item); }, [getActionsElement, $item]);
|
|
133
|
-
var shouldRenderActions =
|
|
145
|
+
var shouldRenderActions = ((_b = resolvedItemActions === null || resolvedItemActions === void 0 ? void 0 : resolvedItemActions.length) !== null && _b !== void 0 ? _b : 0) > 0 && !ChildMenu && !hideInlineActions;
|
|
134
146
|
var resolvedEndEnhancer = useResolvedMenuEndEnhancer(resolvedItemActions, shouldRenderActions, endEnhancer, ChildMenu);
|
|
135
147
|
var mergedOverrides = useMemo(function () { return mergeOverrides(listItemOverrides, overrides); }, [overrides]);
|
|
136
|
-
var
|
|
137
|
-
var
|
|
138
|
-
var
|
|
148
|
+
var _e = __read(useOverrides(mergedOverrides === null || mergedOverrides === void 0 ? void 0 : mergedOverrides.ListItem, ListItem), 2), ListItemOverride = _e[0], listItemProps = _e[1];
|
|
149
|
+
var _f = __read(useOverrides(mergedOverrides === null || mergedOverrides === void 0 ? void 0 : mergedOverrides.Popover, Popover), 2), PopoverOverride = _f[0], popoverProps = _f[1];
|
|
150
|
+
var _g = useMenuItemInteractionHandlers(onMouseOver, ownRef, setHighlightedItem, setNestedMenuOpen), handleMouseOver = _g.handleMouseOver, handleMouseMove = _g.handleMouseMove, resetMenu = _g.resetMenu, closeNestedMenu = _g.closeNestedMenu;
|
|
139
151
|
var id = useUniqueId();
|
|
140
152
|
var listItem = (_jsx(ListItemOverride, __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)));
|
|
141
153
|
var handleMouseEnter = useCombinedHandler(function () { return setHovered(true); }, onMouseEnter);
|
package/esm/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/esm/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.
|
|
@@ -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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __assign, __read } from "tslib";
|
|
1
|
+
import { __assign, __read, __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { add$props } from '../../helpers';
|
|
4
4
|
import { useOverrides } from '../../overrides';
|
|
@@ -6,7 +6,7 @@ import { StyledBar, StyledBarContainer, StyledLabel, StyledLabelContainer, Style
|
|
|
6
6
|
import { useStyle } from '../../style';
|
|
7
7
|
import { getIntentColor } from '../helper';
|
|
8
8
|
var CircularProgress = function (_a) {
|
|
9
|
-
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;
|
|
9
|
+
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 = __rest(_a, ["intent", "infinite", "label", "backgroundColor", "value", "className", "style", "color", "size", "thickness", "overrides"]);
|
|
10
10
|
var strokeWidth = (VIEWBOX_SIZE / size) * thickness;
|
|
11
11
|
var _g = useStyle(), px2rem = _g.px2rem, theme = _g.theme;
|
|
12
12
|
var sharedProps = __assign(__assign({}, add$props({ intent: intent, infinite: infinite, backgroundColor: backgroundColor, value: value, color: color, size: size, thickness: thickness, strokeWidth: strokeWidth })), { $withLabel: !!label });
|
|
@@ -17,7 +17,7 @@ var CircularProgress = function (_a) {
|
|
|
17
17
|
var _m = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.Progress, StyledProgress), 2), Progress = _m[0], progressProps = _m[1];
|
|
18
18
|
var _o = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.LabelContainer, StyledLabelContainer), 2), LabelContainer = _o[0], labelContainerProps = _o[1];
|
|
19
19
|
var _p = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.Label, StyledLabel), 2), Label = _p[0], labelProps = _p[1];
|
|
20
|
-
return (_jsxs(Root, __assign({ role: "progressbar", "aria-valuenow": !infinite ? Math.round(value) : undefined, "aria-valuemin": !infinite ? 0 : undefined, "aria-valuemax": !infinite ? 100 : undefined }, sharedProps, rootProps, { style: [
|
|
20
|
+
return (_jsxs(Root, __assign({ role: "progressbar", "aria-valuenow": !infinite ? Math.round(value) : undefined, "aria-valuemin": !infinite ? 0 : undefined, "aria-valuemax": !infinite ? 100 : undefined }, sharedProps, restProps, rootProps, { style: [
|
|
21
21
|
{
|
|
22
22
|
'--sw-height': px2rem(size),
|
|
23
23
|
'--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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __assign, __read } from "tslib";
|
|
1
|
+
import { __assign, __read, __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { add$props } from '../../helpers';
|
|
4
4
|
import { useOverrides } from '../../overrides';
|
|
@@ -6,14 +6,14 @@ import { StyledBar, StyledLabel, StyledProgress, StyledRoot } from './styled-com
|
|
|
6
6
|
import { getIntentColor } from '../helper';
|
|
7
7
|
import { useStyle } from '../../style';
|
|
8
8
|
var LinearProgress = function (_a) {
|
|
9
|
-
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;
|
|
9
|
+
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 = __rest(_a, ["intent", "value", "backgroundColor", "color", "label", "style", "className", "infinite", "overrides", "children"]);
|
|
10
10
|
var sharedProps = __assign(__assign({}, add$props({ intent: intent, value: value, backgroundColor: backgroundColor, color: color, infinite: infinite })), { $withLabel: !!label });
|
|
11
11
|
var theme = useStyle().theme;
|
|
12
12
|
var _e = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.Root, StyledRoot), 2), Root = _e[0], rootProps = _e[1];
|
|
13
13
|
var _f = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.Bar, StyledBar), 2), Bar = _f[0], barProps = _f[1];
|
|
14
14
|
var _g = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.Progress, StyledProgress), 2), Progress = _g[0], progressProps = _g[1];
|
|
15
15
|
var _h = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.Label, StyledLabel), 2), Label = _h[0], labelProps = _h[1];
|
|
16
|
-
return (_jsxs(Root, __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: [_jsx(Bar, __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 || (_jsx(Progress, __assign({ "data-testid": "filled-track" }, sharedProps, progressProps, { style: [
|
|
16
|
+
return (_jsxs(Root, __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: [_jsx(Bar, __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 || (_jsx(Progress, __assign({ "data-testid": "filled-track" }, sharedProps, progressProps, { style: [
|
|
17
17
|
__assign({ '--sw-bg-color': color || getIntentColor(intent, theme) }, (!infinite ? { '--sw-width': "".concat(value, "%") } : {})),
|
|
18
18
|
progressProps === null || progressProps === void 0 ? void 0 : progressProps.style,
|
|
19
19
|
] }))) })), label ? (_jsx(Label, __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;
|
|
@@ -22,8 +22,13 @@ import { useLocale } from '../../locale';
|
|
|
22
22
|
import { useDocument } from '../../spacewebProvider/DocumentProvider';
|
|
23
23
|
import { HiddenElement } from '../utils/hidden-element';
|
|
24
24
|
import { useSelectIds } from '../SelectIdsContext';
|
|
25
|
+
import { useNumber } from '../../number';
|
|
25
26
|
var Collapsible = function (_a) {
|
|
27
|
+
var _b;
|
|
26
28
|
var children = _a.children, group = _a.group, expanded = _a.expanded, onClick = _a.onClick, disabled = _a.disabled, className = _a.className;
|
|
29
|
+
var formattedCount = useNumber({
|
|
30
|
+
value: (_b = group.count) !== null && _b !== void 0 ? _b : 0,
|
|
31
|
+
});
|
|
27
32
|
return (_jsxs(Box, __assign({ className: "rounded-inherit" }, { children: [_jsxs(BaseButton, __assign({ tabIndex: -1, disabled: disabled, onClick: function () { return onClick(group.id); },
|
|
28
33
|
// @ts-ignore -- css variable declaration in style props
|
|
29
34
|
style: { '--sw-padding-block-start': '0.55rem', '--sw-padding-block-end': '0.55rem' }, className: [
|
|
@@ -31,7 +36,7 @@ var Collapsible = function (_a) {
|
|
|
31
36
|
'pt-[--sw-padding-block-start] pb-[--sw-padding-block-end] pl-2 pr-2.5',
|
|
32
37
|
'disabled:opacity-60 disabled:cursor-not-allowed focus-visible:outline-none',
|
|
33
38
|
className,
|
|
34
|
-
], type: "button" }, { children: [_jsxs(Typography, __assign({ className: "block text-left", variant: "body-sm", weight: "bold", maxLines: 2 }, { children: [_jsx(Box, __assign({ "$as": "span" }, { children: group.label })), _isNumber(group.count) ? _jsx(Box, __assign({ "$as": "span" }, { children: " (".concat(
|
|
39
|
+
], type: "button" }, { children: [_jsxs(Typography, __assign({ className: "block text-left", variant: "body-sm", weight: "bold", maxLines: 2 }, { children: [_jsx(Box, __assign({ "$as": "span" }, { children: group.label })), _isNumber(group.count) ? _jsx(Box, __assign({ "$as": "span" }, { children: " (".concat(formattedCount, ")") })) : null] })), _jsx(ChevronDown, { 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") })] })), _jsx(Collapse, __assign({ unmountOnExit: true, mountOnEnter: true, visible: expanded }, { children: children }))] })));
|
|
35
40
|
};
|
|
36
41
|
export var CollapsibleSelectMenu = function (_a) {
|
|
37
42
|
var _b, _c, _d, _e;
|
|
@@ -73,13 +78,16 @@ export var CollapsibleSelectMenu = function (_a) {
|
|
|
73
78
|
}); }, [mergedOverrides.ListItemText, mergedOverrides.MenuItem]);
|
|
74
79
|
useEffect(function () {
|
|
75
80
|
var keydownHandler = function (event) {
|
|
76
|
-
var expandedGroupIndex =
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
var expandedGroupIndex = groupConfig.findIndex(function (group) { return group.id === expandedGroupId; });
|
|
82
|
+
var noGroupExpanded = expandedGroupIndex === -1;
|
|
83
|
+
if (event.key === 'ArrowDown' && (event.shiftKey || noGroupExpanded || isLastItemHighlighted.current)) {
|
|
84
|
+
var nextGroupIndex = noGroupExpanded ? 0 : Math.min(expandedGroupIndex + 1, groupConfig.length - 1);
|
|
85
|
+
setExpandedGroupId(groupConfig[nextGroupIndex].id);
|
|
79
86
|
event.stopPropagation(); // prevents the menu to move to the second item of the next group
|
|
80
87
|
}
|
|
81
|
-
else if (event.key === 'ArrowUp' && (event.shiftKey || isFirstItemHighlighted.current)) {
|
|
82
|
-
|
|
88
|
+
else if (event.key === 'ArrowUp' && (event.shiftKey || noGroupExpanded || isFirstItemHighlighted.current)) {
|
|
89
|
+
var prevGroupIndex = noGroupExpanded ? groupConfig.length - 1 : Math.max(expandedGroupIndex - 1, 0);
|
|
90
|
+
setExpandedGroupId(groupConfig[prevGroupIndex].id);
|
|
83
91
|
}
|
|
84
92
|
};
|
|
85
93
|
ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body.addEventListener('keydown', keydownHandler);
|
|
@@ -87,6 +95,13 @@ export var CollapsibleSelectMenu = function (_a) {
|
|
|
87
95
|
ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body.removeEventListener('keydown', keydownHandler);
|
|
88
96
|
};
|
|
89
97
|
}, [ownerDocument, expandedGroupId, groupConfig, setExpandedGroupId]);
|
|
98
|
+
// when the NoResults component is rendered, handleOnHighlightedItemChange is not triggered
|
|
99
|
+
useEffect(function () {
|
|
100
|
+
if (expandedGroupId && _isEmpty(groupedItems[expandedGroupId])) {
|
|
101
|
+
isFirstItemHighlighted.current = true;
|
|
102
|
+
isLastItemHighlighted.current = true;
|
|
103
|
+
}
|
|
104
|
+
}, [expandedGroupId, groupedItems]);
|
|
90
105
|
var handleOnHighlightedItemChange = function (item) {
|
|
91
106
|
var _a;
|
|
92
107
|
var nextHighlightableElement = getNextItemIndexToHighlight(item !== null && item !== void 0 ? item : null, menuRef.current, 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/esm/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/esm/tag/tag.js
CHANGED
|
@@ -17,7 +17,7 @@ import { useLocale } from '../locale';
|
|
|
17
17
|
import { useTruncateWithTooltip } from '../truncateWithTooltip/hooks/useTruncateWithTooltip';
|
|
18
18
|
import { getActionIconButtonOverrides, getDefaultTagSize, getTagSizeTheme, getTextFromChildren } from './utils';
|
|
19
19
|
var Tag = forwardRef(function (props, ref) {
|
|
20
|
-
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 = __rest(props, ["children", "closeable", "size", "shape", "isFocused", "isHovered", "onActionClick", "onActionKeyDown", "onClick", "onKeyDown", "overrides", "title", "variant", "intent", "appearance", "className", "startEnhancer", "noTooltipOnTruncation"]);
|
|
20
|
+
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 = __rest(props, ["children", "closeable", "closeAriaLabel", "size", "shape", "isFocused", "isHovered", "onActionClick", "onActionKeyDown", "onClick", "onKeyDown", "overrides", "title", "variant", "intent", "appearance", "className", "startEnhancer", "noTooltipOnTruncation"]);
|
|
21
21
|
var _k = useFocusVisible(), $isFocusVisible = _k.$isFocusVisible, onBlur = _k.onBlur, onFocus = _k.onFocus;
|
|
22
22
|
var theme = useStyle().theme;
|
|
23
23
|
var locale = useLocale();
|
|
@@ -67,7 +67,7 @@ var Tag = forwardRef(function (props, ref) {
|
|
|
67
67
|
actionIconButtonOverrides,
|
|
68
68
|
], style: {
|
|
69
69
|
'--sw-color': theme.spr.iconTertiary,
|
|
70
|
-
}, "aria-label": locale.tag.closeAriaLabel, tabIndex: actionProps === null || actionProps === void 0 ? void 0 : actionProps.tabIndex }, { children: _jsx(ActionIcon, __assign({ size: clearableIconSize }, actionIconProps)) })) }))) : null] })));
|
|
70
|
+
}, "aria-label": closeAriaLabel !== null && closeAriaLabel !== void 0 ? closeAriaLabel : locale.tag.closeAriaLabel, tabIndex: actionProps === null || actionProps === void 0 ? void 0 : actionProps.tabIndex }, { children: _jsx(ActionIcon, __assign({ size: clearableIconSize }, actionIconProps)) })) }))) : null] })));
|
|
71
71
|
});
|
|
72
72
|
Tag.displayName = 'Tag';
|
|
73
73
|
Tag.__standard = 'Component';
|
package/esm/tag/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { AvatarProps } from '../avatar';
|
|
3
|
-
import { Override } from '../overrides';
|
|
4
|
-
import { ClassName, SpacewebComponentProps } from '../types';
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { AvatarProps } from '../avatar';
|
|
3
|
+
import type { Override } from '../overrides';
|
|
4
|
+
import type { ClassName, SpacewebComponentProps } from '../types';
|
|
5
5
|
export type Intent = 'success' | 'error' | 'warning' | 'info' | 'default' | 'ai';
|
|
6
6
|
export type Appearance = 'gray' | 'white' | 'outline';
|
|
7
7
|
export type Variant = 'solid' | 'light';
|
|
@@ -16,6 +16,7 @@ export type TagOverrides = {
|
|
|
16
16
|
};
|
|
17
17
|
export type TagProps = SpacewebComponentProps<{
|
|
18
18
|
closeable?: boolean;
|
|
19
|
+
closeAriaLabel?: string;
|
|
19
20
|
isFocused?: boolean;
|
|
20
21
|
isHovered?: boolean;
|
|
21
22
|
children?: React.ReactNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { RangeSelectorContainerProps } from './types';
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { RangeSelectorContainerProps } from './types';
|
|
3
3
|
declare const RangeSelectorContainer: {
|
|
4
4
|
({ adapter, timeRangePresets, onChange, onSubmit, timezone: selectedTimezone, value: selectedValue, timeRange: selectedTimeRange, preset: selectedPreset, minDate: _minDate, maxDate: _maxDate, monthsShown, disableTimezone, timezoneOptions, hidePresetSearch, ...props }: RangeSelectorContainerProps): ReactElement;
|
|
5
5
|
displayName: string;
|
|
@@ -13,7 +13,7 @@ import DefaultTimezonePicker from './TimezonePicker';
|
|
|
13
13
|
import ErrorIcon from '../icon/components/error';
|
|
14
14
|
import { StyledFooter, StyledFooterBeforeEnhancer } from '../date-picker/styled-components';
|
|
15
15
|
import { useLocale } from '../locale';
|
|
16
|
-
import { getRangeError, getSelectedTimeRange, getValidRange, getMinMaxDateInTimezone } from './utils';
|
|
16
|
+
import { getRangeError, getSelectedTimeRange, getValidRange, getMinMaxDateInTimezone, convertDateFromSystemTzToTargetTz, } from './utils';
|
|
17
17
|
import { useOverrides } from '../overrides';
|
|
18
18
|
var getPresetId = function (selectedPreset, selectedValue) {
|
|
19
19
|
if (selectedPreset) {
|
|
@@ -74,7 +74,7 @@ var RangeSelectorContainer = function (_a) {
|
|
|
74
74
|
dateHelpers: dateHelpers,
|
|
75
75
|
maxDate: maxDate,
|
|
76
76
|
minDate: minDate,
|
|
77
|
-
});
|
|
77
|
+
}).map(function (time) { return new Date(convertDateFromSystemTzToTargetTz(time, timezone, timezoneOptions)); });
|
|
78
78
|
setPreset(_preset);
|
|
79
79
|
setTimeRange(nextDate);
|
|
80
80
|
onChange === null || onChange === void 0 ? void 0 : onChange(__assign({ value: _preset, date: nextDate, preset: _preset }, (disableTimezone ? {} : { timezone: timezone })));
|
|
@@ -92,7 +92,17 @@ var RangeSelectorContainer = function (_a) {
|
|
|
92
92
|
setPreset('CUSTOM');
|
|
93
93
|
onChange === null || onChange === void 0 ? void 0 : onChange(__assign({ value: nextDate, date: nextDate, preset: 'CUSTOM' }, (disableTimezone ? {} : { timezone: timezone })));
|
|
94
94
|
}
|
|
95
|
-
}, [
|
|
95
|
+
}, [
|
|
96
|
+
setTimeRange,
|
|
97
|
+
dateHelpers,
|
|
98
|
+
timeRangePresets,
|
|
99
|
+
onChange,
|
|
100
|
+
timezone,
|
|
101
|
+
disableTimezone,
|
|
102
|
+
minDate,
|
|
103
|
+
maxDate,
|
|
104
|
+
timezoneOptions,
|
|
105
|
+
]);
|
|
96
106
|
var handleSubmit = useCallback(function () {
|
|
97
107
|
return onSubmit(__assign({ timeRange: timeRange, preset: preset }, (disableTimezone ? {} : { timezone: timezone })));
|
|
98
108
|
}, [timeRange, preset, timezone, onSubmit, disableTimezone]);
|
package/helpers/colors.d.ts
CHANGED
|
@@ -16,3 +16,4 @@ export declare function getContrastRatio(color1: string, color2: string): number
|
|
|
16
16
|
export declare function RgbToHsl({ r, g, b, a }: RGBColor): HSLA;
|
|
17
17
|
export declare function HslToRgb(hsl: HSLA): RGBColor;
|
|
18
18
|
export declare function noAlphaHex(inputHex?: string): string | undefined;
|
|
19
|
+
export declare function normalizeHexWithAlpha<T extends string | undefined>(hex: T, alpha: number | undefined): T;
|