@muraldevkit/ui-toolkit 4.66.0-dev-7K0j.1 → 4.66.0-dev-DhSN.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -45,6 +45,7 @@ const __1 = require("../../");
|
|
|
45
45
|
const useTriggerPosition_1 = require("../../../hooks/useTriggerPosition");
|
|
46
46
|
const useBrowserEdgeScroll_1 = require("../../menu/hooks/useBrowserEdgeScroll");
|
|
47
47
|
const useClickOutside_1 = require("../../../hooks/useClickOutside");
|
|
48
|
+
const useScrollbarInfo_1 = require("../../../hooks/useScrollbarInfo");
|
|
48
49
|
const useSubMenuElementPosition_1 = require("../../menu/hooks/useSubMenuElementPosition");
|
|
49
50
|
const utils_1 = require("../../../utils");
|
|
50
51
|
const layers_1 = require("../../../utils/layers");
|
|
@@ -63,6 +64,20 @@ const POPOVER_CLICKOUTSIDE_WHITELIST = [
|
|
|
63
64
|
`.${MrlSelect_1.SELECT_MENU_LIST_CLASS_NAME}`,
|
|
64
65
|
`.${MrlMultiSelect_1.MULTI_SELECT_MENU_LIST_CLASS_NAME}`
|
|
65
66
|
];
|
|
67
|
+
/**
|
|
68
|
+
* Scrollable wrapper for the popover content. Lives as its own component so
|
|
69
|
+
* `useScrollbarInfo` mounts together with the scrollable element (the popover
|
|
70
|
+
* content only exists while the popover is open) and can compensate the right
|
|
71
|
+
* padding when a space-consuming scrollbar appears.
|
|
72
|
+
* @param {object} props - The props for the scroll container
|
|
73
|
+
* @returns {Element} - rendered scrollable popover content wrapper
|
|
74
|
+
*/
|
|
75
|
+
function MrlPopoverScrollContainer({ className, style, children }) {
|
|
76
|
+
const { scrollableContainerRef, verticalScrollbarWidth } = (0, useScrollbarInfo_1.useScrollbarInfo)();
|
|
77
|
+
return (React.createElement("div", { ref: scrollableContainerRef, className: className, style: Object.assign(Object.assign({}, style), (verticalScrollbarWidth > 0 && {
|
|
78
|
+
paddingRight: `calc(var(--mrl-popover-padding) - ${verticalScrollbarWidth}px)`
|
|
79
|
+
})) }, children));
|
|
80
|
+
}
|
|
66
81
|
/**
|
|
67
82
|
* MrlPopover
|
|
68
83
|
*
|
|
@@ -306,7 +321,7 @@ function MrlPopover(_a) {
|
|
|
306
321
|
const scrollClasses = (0, classnames_1.default)(MrlPopover_module_scss_1.default['MrlPopover--content'], MrlPopover_module_scss_1.default['MrlPopover--scrolling--content']);
|
|
307
322
|
return (React.createElement(React.Fragment, null, transitions((style, item) => item && (React.createElement(__1.MrlFocusTrap, { disabled: disableFocusTrap, containerRef: menuRef },
|
|
308
323
|
React.createElement(web_1.animated.div, Object.assign({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, className: menuClasses, id: id, tabIndex: -1, style: Object.assign(Object.assign({}, positionStyles), style), onKeyDown: handleMenuKey, ref: menuRef }, rest),
|
|
309
|
-
React.createElement(
|
|
324
|
+
React.createElement(MrlPopoverScrollContainer, { className: scrollClasses, style: inlineScrollStyles },
|
|
310
325
|
typeof children === 'function' && children({ closeMenu }),
|
|
311
326
|
typeof children !== 'function' && children,
|
|
312
327
|
hasCloseButton && (React.createElement(__1.MrlIconButton, { "data-qa": "popover-close-button", wrapperClassName: MrlPopover_module_scss_1.default['MrlPopover--close'], icon: React.createElement(__1.MrlSvg, { svg: ds_icons_1.close }), kind: kind === 'inverse' ? 'ghost-inverse' : 'ghost', text: "Close", state: "default", position: "right", tipAnchor: "center", onMouseUp: closeMenu, onKeyDown: handleClose, size: "small" })),
|
|
@@ -16,6 +16,7 @@ import { MrlFocusTrap, MrlIconButton, MrlPortal, MrlSvg } from '../../';
|
|
|
16
16
|
import { useTriggerPosition } from '../../../hooks/useTriggerPosition';
|
|
17
17
|
import { useBrowserEdgeScroll } from '../../menu/hooks/useBrowserEdgeScroll';
|
|
18
18
|
import { useClickOutside } from '../../../hooks/useClickOutside';
|
|
19
|
+
import { useScrollbarInfo } from '../../../hooks/useScrollbarInfo';
|
|
19
20
|
import { useSubMenuElementPosition } from '../../menu/hooks/useSubMenuElementPosition';
|
|
20
21
|
import { preventDefault, getFocusableElementsInsideElement, findAdjacentInteractiveElement, isElementAriaDisabled } from '../../../utils';
|
|
21
22
|
import { PORTAL_LAYERS } from '../../../utils/layers';
|
|
@@ -34,6 +35,20 @@ const POPOVER_CLICKOUTSIDE_WHITELIST = [
|
|
|
34
35
|
`.${SELECT_MENU_LIST_CLASS_NAME}`,
|
|
35
36
|
`.${MULTI_SELECT_MENU_LIST_CLASS_NAME}`
|
|
36
37
|
];
|
|
38
|
+
/**
|
|
39
|
+
* Scrollable wrapper for the popover content. Lives as its own component so
|
|
40
|
+
* `useScrollbarInfo` mounts together with the scrollable element (the popover
|
|
41
|
+
* content only exists while the popover is open) and can compensate the right
|
|
42
|
+
* padding when a space-consuming scrollbar appears.
|
|
43
|
+
* @param {object} props - The props for the scroll container
|
|
44
|
+
* @returns {Element} - rendered scrollable popover content wrapper
|
|
45
|
+
*/
|
|
46
|
+
function MrlPopoverScrollContainer({ className, style, children }) {
|
|
47
|
+
const { scrollableContainerRef, verticalScrollbarWidth } = useScrollbarInfo();
|
|
48
|
+
return (React.createElement("div", { ref: scrollableContainerRef, className: className, style: Object.assign(Object.assign({}, style), (verticalScrollbarWidth > 0 && {
|
|
49
|
+
paddingRight: `calc(var(--mrl-popover-padding) - ${verticalScrollbarWidth}px)`
|
|
50
|
+
})) }, children));
|
|
51
|
+
}
|
|
37
52
|
/**
|
|
38
53
|
* MrlPopover
|
|
39
54
|
*
|
|
@@ -277,7 +292,7 @@ export function MrlPopover(_a) {
|
|
|
277
292
|
const scrollClasses = classnames(styles['MrlPopover--content'], styles['MrlPopover--scrolling--content']);
|
|
278
293
|
return (React.createElement(React.Fragment, null, transitions((style, item) => item && (React.createElement(MrlFocusTrap, { disabled: disableFocusTrap, containerRef: menuRef },
|
|
279
294
|
React.createElement(animated.div, Object.assign({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, className: menuClasses, id: id, tabIndex: -1, style: Object.assign(Object.assign({}, positionStyles), style), onKeyDown: handleMenuKey, ref: menuRef }, rest),
|
|
280
|
-
React.createElement(
|
|
295
|
+
React.createElement(MrlPopoverScrollContainer, { className: scrollClasses, style: inlineScrollStyles },
|
|
281
296
|
typeof children === 'function' && children({ closeMenu }),
|
|
282
297
|
typeof children !== 'function' && children,
|
|
283
298
|
hasCloseButton && (React.createElement(MrlIconButton, { "data-qa": "popover-close-button", wrapperClassName: styles['MrlPopover--close'], icon: React.createElement(MrlSvg, { svg: close }), kind: kind === 'inverse' ? 'ghost-inverse' : 'ghost', text: "Close", state: "default", position: "right", tipAnchor: "center", onMouseUp: closeMenu, onKeyDown: handleClose, size: "small" })),
|