@muraldevkit/ui-toolkit 4.62.0-dev-3JXS.1 → 4.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,4 +32,3 @@ export * from './rovingTabindex';
32
32
  export * from './toolbar';
33
33
  export * from './filter';
34
34
  export * from './breadcrumb';
35
- export * from './image';
@@ -7,7 +7,7 @@ export interface MrlMenuProps {
7
7
  /** Children to be rendered within the menu component*/
8
8
  children: React.ReactNode;
9
9
  /** Event to close the menu */
10
- clickOutsideEvent?: 'mouseup' | 'mousedown' | 'click';
10
+ clickOutsideEvent?: 'mousedown' | 'mouseup' | 'click';
11
11
  /**
12
12
  * Enables closing the menu when scrolling. Default is false.
13
13
  *
@@ -0,0 +1,40 @@
1
+ import { RefObject } from 'react';
2
+ import { MenuPosition } from '../constants';
3
+ interface UseMenuScrollResult {
4
+ /** The constrained max height for the menu list when scrolling is active */
5
+ maxHeight: number | undefined;
6
+ /** Whether the menu content exceeds available space and requires internal scrolling */
7
+ isScrolling: boolean;
8
+ }
9
+ /**
10
+ * useMenuScroll hook
11
+ *
12
+ * Detects when a menu cannot fit on screen in either its preferred or flipped position,
13
+ * and constrains its height to enable internal scrolling.
14
+ *
15
+ * Behavior by position:
16
+ * - **top/bottom**: If the menu doesn't fit in the preferred direction AND doesn't fit
17
+ * in the opposite direction (flip), it reverts to the original position and constrains
18
+ * the height to the space between the trigger edge and the viewport edge.
19
+ * - **left/right**: Only checks vertical overflow. If the menu is taller than the viewport,
20
+ * it constrains the height to the available vertical space.
21
+ *
22
+ * Uses `scrollHeight` on the list element to determine the natural (unconstrained) content
23
+ * height. This value remains stable even when `maxHeight` is applied, preventing feedback
24
+ * loops with external positioning hooks that use ResizeObserver.
25
+ *
26
+ * Uses `useLayoutEffect` for the initial calculation so that `maxHeight` is applied
27
+ * synchronously before the browser paints. This prevents visible flicker when the menu
28
+ * opens in a constrained space, because the positioning hook (useTriggerPosition) will
29
+ * see the already-constrained height on its first measurement via requestAnimationFrame.
30
+ *
31
+ * @param triggerRef - Reference to the trigger element that opens the menu
32
+ * @param listRef - Reference to the ul element inside the menu (the scrollable container)
33
+ * @param position - The preferred menu position relative to the trigger
34
+ * @param menuOffset - The gap between the trigger and the menu in pixels
35
+ * @param isOpen - Whether the menu is currently open
36
+ * @param disable - Whether to disable the hook entirely
37
+ * @returns An object with `maxHeight` (inline style value) and `isScrolling` (class toggle)
38
+ */
39
+ export declare const useMenuScroll: (triggerRef: RefObject<HTMLElement> | undefined, listRef: RefObject<HTMLUListElement>, position: MenuPosition, menuOffset: number, isOpen: boolean, disable: boolean) => UseMenuScrollResult;
40
+ export {};
@@ -1,13 +1,8 @@
1
1
  import * as React from 'react';
2
- export type MrlPanelContextState = {
3
- hasScrollbar: boolean;
4
- scrollbarWidth: number;
5
- };
6
- export declare const initialState: {
7
- hasScrollbar: boolean;
8
- scrollbarWidth: number;
9
- };
10
- export declare const MrlPanelContext: React.Context<MrlPanelContextState>;
2
+ import { ScrollbarInfo } from '../../../hooks';
3
+ export type MrlPanelContextState = ScrollbarInfo;
4
+ export declare const initialState: MrlPanelContextState;
5
+ export declare const MrlPanelContext: React.Context<ScrollbarInfo>;
11
6
  /**
12
7
  * Returns the MrlPanelContext state.
13
8
  *
@@ -21,7 +21,7 @@ type UseMrlPopoverEventHandlersReturn = {
21
21
  hideMenuHover: (e: MouseEvent) => void;
22
22
  showMenuHover: () => void;
23
23
  toggleMenuKey: (e: KeyboardEvent) => void;
24
- toggleMenuMouse: () => void;
24
+ toggleMenuTrigger: () => void;
25
25
  };
26
26
  /**
27
27
  * Creates all of the required event handlers for the MrlPopover component
@@ -2,4 +2,3 @@ export * from './useCoordinate';
2
2
  export * from './useBreakpoint';
3
3
  export * from './useElementDimensions';
4
4
  export * from './useScrollbarInfo';
5
- export * from './useReducedMotion';
@@ -1,14 +1,24 @@
1
1
  import * as React from 'react';
2
- export type UseScrollbarInfoReturn<T extends HTMLElement> = {
2
+ export type ScrollbarInfo = {
3
+ /** Indicates if a horizontal scrollbar is present */
3
4
  hasHorizontalScrollbar: boolean;
5
+ /** Indicates if a vertical scrollbar is present */
4
6
  hasVerticalScrollbar: boolean;
7
+ /** Width in pixels of the vertical scrollbar (0 for overlay scrollbars) */
8
+ verticalScrollbarWidth: number;
9
+ /** Height in pixels of the horizontal scrollbar (0 for overlay scrollbars) */
10
+ horizontalScrollbarHeight: number;
11
+ };
12
+ /**
13
+ * Return type for the `useScrollbarInfo` hook.
14
+ */
15
+ export type UseScrollbarInfoReturn<T extends HTMLElement> = ScrollbarInfo & {
5
16
  scrollableContainerRef: React.MutableRefObject<T | null>;
6
- scrollbarWidth: number;
7
17
  };
8
18
  /**
9
- * Custom hook that provides information about the presence and width of scrollbars
19
+ * Custom hook that provides information about the presence and dimensions of vertical and horizontal scrollbars
10
20
  * in a scrollable container.
11
21
  *
12
- * @returns {UseScrollbarInfoReturn} hasHorizontalScrollbar, hasVerticalScrollbar and scrollbarWidth values.
22
+ * @returns {UseScrollbarInfoReturn} Returns the scrollbar information and a ref to attach to the scrollable container
13
23
  */
14
24
  export declare function useScrollbarInfo<T extends HTMLElement>(): UseScrollbarInfoReturn<T>;