@muraldevkit/ui-toolkit 2.29.0 → 2.29.2

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.
@@ -1,10 +1,23 @@
1
1
  import React, { RefObject } from 'react';
2
- import { MenuPosition, VerticalAlign, HorizontalAlign, ActionState } from '../constants';
2
+ import { MenuPosition, MenuAlignment, ActionState, CustomMenuPosition } from '../constants';
3
3
  export interface MrlMenuProps {
4
+ /** Custom position for the menu */
5
+ customPosition?: CustomMenuPosition;
4
6
  /** Children to be rendered within the menu component*/
5
7
  children: React.ReactNode;
8
+ /** Event to close the menu */
9
+ clickOutsideEvent?: 'mouseup' | 'mousedown' | 'click';
6
10
  /** Unique identifier for the menu */
7
11
  id?: string;
12
+ /**
13
+ * Use when the menu is embedded within another component
14
+ * Removes the following styles:
15
+ * - padding on the menu
16
+ * - drop shadow and border
17
+ *
18
+ * @default false
19
+ */
20
+ isInternal?: boolean;
8
21
  /**
9
22
  * Private isSubMenu prop for use with MrlMenuItem
10
23
  *
@@ -28,6 +41,9 @@ export interface MrlMenuProps {
28
41
  menuOffset?: number;
29
42
  /**
30
43
  * Horizontal and vertical alignment of the menu relative to the trigger element
44
+ * - position 'left', 'right', 'top', 'bottom' position relative to the trigger
45
+ * - position 'static' renders the menu in place, not using the portal
46
+ * - position 'ignore' will not position the menu, allowing you to use the customPosition prop to position the element
31
47
  *
32
48
  * @default 'bottom'
33
49
  */
@@ -43,17 +59,23 @@ export interface MrlMenuProps {
43
59
  */
44
60
  triggerRef?: RefObject<HTMLButtonElement>;
45
61
  /**
46
- * Vertical alignment of the menu relative to the trigger element
62
+ * Trigger stop propagation on click
47
63
  *
48
- * @default 'center'
64
+ * In some instances we may want the trigger element to stop propogation to the
65
+ * rest of the DOM. Use this flag to enable and disable it.
66
+ *
67
+ * @default false
49
68
  */
50
- verticalAlign?: VerticalAlign;
69
+ triggerStopPropagation?: boolean;
51
70
  /**
52
- * Horizontal alignment of the menu relative to the trigger element
71
+ * Vertical and horizontal alignment of the menu relative to the position of the menu with the trigger
72
+ * - 'left' and 'right' work with position 'top' and 'bottom'
73
+ * - 'top' and 'bottom' work with position 'left' and 'right'
74
+ * - 'center' works with all positions
53
75
  *
54
- * @default 'left'
76
+ * This does not impact submenus
55
77
  */
56
- horizontalAlign?: HorizontalAlign;
78
+ alignment?: MenuAlignment;
57
79
  /**
58
80
  * Callback to be called when the menu is closed
59
81
  *
@@ -69,4 +91,7 @@ export interface MrlMenuProps {
69
91
  * @param {MrlMenuProps} props - The props for the MrlMenu component
70
92
  * @returns {Element} - rendered MrlMenu component
71
93
  */
72
- export declare function MrlMenu({ children, id, isSubMenu, spacing, menuOffset, position, actionState, verticalAlign, horizontalAlign, onClose, triggerRef }: MrlMenuProps): JSX.Element;
94
+ export declare function MrlMenu({ actionState, alignment, children, customPosition, clickOutsideEvent, id, isInternal, isSubMenu, spacing, menuOffset, position, triggerStopPropagation, onClose, triggerRef }: MrlMenuProps): JSX.Element;
95
+ export declare namespace MrlMenu {
96
+ var componentType: string;
97
+ }
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  export interface MrlMenuGroupPropTypes {
3
3
  children: React.ReactNode;
4
4
  divider?: boolean;
5
- groupLabel: string;
5
+ groupLabel?: string;
6
6
  }
7
7
  /**
8
8
  * MrlMenuGroup
@@ -8,6 +8,8 @@ interface MrlMenuItemProps {
8
8
  children: React.ReactNode | string;
9
9
  /** If the menu item is disabled */
10
10
  disabled?: boolean;
11
+ /** Icon for menu item */
12
+ icon?: Record<string, unknown>;
11
13
  /** Unique ID for the menu item */
12
14
  id?: string;
13
15
  /** Callback to be called when the menu item is clicked */
@@ -25,5 +27,5 @@ interface MrlMenuItemProps {
25
27
  * @param {MrlMenuItemProps} props - The props for the MrlMenuItem component
26
28
  * @returns {Element} - rendered MrlMenuItem component
27
29
  */
28
- export declare function MrlMenuItem({ ariaDescribedBy, children, dataQa, disabled, id, onClick, selected }: MrlMenuItemProps): JSX.Element;
30
+ export declare function MrlMenuItem({ ariaDescribedBy, children, dataQa, disabled, icon, id, onClick, selected }: MrlMenuItemProps): JSX.Element;
29
31
  export {};
@@ -6,6 +6,8 @@ interface MrlMenuItemLinkProps {
6
6
  Children to be rendered within the menu component
7
7
  */
8
8
  children: React.ReactNode | string;
9
+ /** Class names for the menu item */
10
+ className?: string;
9
11
  /** If the menu item is disabled */
10
12
  disabled?: boolean;
11
13
  /** Href for the menu item */
@@ -29,5 +31,5 @@ interface MrlMenuItemLinkProps {
29
31
  * @param {MrlMenuItemLinkProps} props - The props for the MrlMenuItem component
30
32
  * @returns {Element} - rendered MrlMenuItem component
31
33
  */
32
- export declare function MrlMenuItemLink({ ariaDescribedBy, children, dataQa, disabled, href, id, onClick, selected, target }: MrlMenuItemLinkProps): JSX.Element;
34
+ export declare function MrlMenuItemLink({ ariaDescribedBy, children, className, dataQa, disabled, href, id, onClick, selected, target }: MrlMenuItemLinkProps): JSX.Element;
33
35
  export {};
@@ -1,9 +1,20 @@
1
- export type MenuPosition = 'bottom' | 'left' | 'right' | 'top' | 'below';
1
+ /// <reference types="react" />
2
+ export type MenuPosition = 'bottom' | 'left' | 'right' | 'top' | 'static' | MenuIgnore;
3
+ export type MenuAlignment = HorizontalAlign | VerticalAlign | MenuIgnore;
2
4
  export type HorizontalAlign = 'left' | 'right' | 'center';
3
5
  export type VerticalAlign = 'top' | 'bottom' | 'center';
4
6
  export type MenuIgnore = 'ignore';
7
+ export interface CustomMenuPosition {
8
+ left: number;
9
+ top: number;
10
+ }
5
11
  export type ActionType = 'ArrowUp' | 'ArrowDown' | 'ArrowRight' | 'Enter' | 'Escape' | ' ' | 'click' | null;
6
12
  export interface ActionState {
7
13
  actionType: ActionType;
8
14
  isOpen: boolean;
15
+ disableTriggerFocus?: boolean;
16
+ }
17
+ export type SubMenuTypes = 'Menu' | 'Popover';
18
+ export interface ComponentWithComponentType extends React.FunctionComponent {
19
+ componentType?: SubMenuTypes;
9
20
  }
@@ -1,10 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { MenuPosition, VerticalAlign, HorizontalAlign, ActionState } from '../constants';
2
+ import { MenuPosition, MenuAlignment, ActionState } from '../constants';
3
3
  interface MenuWithLinkProps {
4
4
  menuAlign?: MenuPosition;
5
5
  kind?: 'default' | 'compact';
6
- verticalAlign?: VerticalAlign;
7
- horizontalAlign?: HorizontalAlign;
6
+ alignment?: MenuAlignment;
8
7
  menuState?: ActionState;
9
8
  onClose?: () => void;
10
9
  triggerAlignment?: 'left' | 'right' | 'center';
@@ -15,5 +14,5 @@ interface MenuWithLinkProps {
15
14
  * @param {MenuWithLinkProps} props - The props for the menu with trigger
16
15
  * @returns {Element} The menu with trigger demo
17
16
  */
18
- export declare const MenuWithLink: ({ menuAlign, verticalAlign, horizontalAlign, menuState, onClose, triggerAlignment }: MenuWithLinkProps) => JSX.Element;
17
+ export declare const MenuWithLink: ({ menuAlign, alignment, menuState, onClose, triggerAlignment }: MenuWithLinkProps) => JSX.Element;
19
18
  export {};
@@ -1,10 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { MenuPosition, VerticalAlign, HorizontalAlign, ActionState } from '../constants';
2
+ import { MenuPosition, ActionState, MenuAlignment } from '../constants';
3
3
  interface MenuWithPopoverProps {
4
4
  position?: MenuPosition;
5
5
  spacing?: 'default' | 'compact';
6
- verticalAlign?: VerticalAlign;
7
- horizontalAlign?: HorizontalAlign;
6
+ alignment?: MenuAlignment;
8
7
  actionState?: ActionState;
9
8
  onClose?: () => void;
10
9
  triggerAlignment?: 'left' | 'right' | 'center';
@@ -15,5 +14,5 @@ interface MenuWithPopoverProps {
15
14
  * @param {MenuWithPopoverProps} props - The props for the menu with trigger
16
15
  * @returns {Element} The menu with trigger demo
17
16
  */
18
- export declare const MenuWithPopover: ({ position, verticalAlign, horizontalAlign, spacing, actionState, onClose, triggerAlignment }: MenuWithPopoverProps) => JSX.Element;
17
+ export declare const MenuWithPopover: ({ alignment, position, spacing, actionState, onClose, triggerAlignment }: MenuWithPopoverProps) => JSX.Element;
19
18
  export {};
@@ -1,10 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { MenuPosition, VerticalAlign, HorizontalAlign, ActionState } from '../constants';
2
+ import { MenuPosition, ActionState, MenuAlignment } from '../constants';
3
3
  interface MenuWithSubmenuProps {
4
4
  position?: MenuPosition;
5
5
  spacing?: 'default' | 'compact';
6
- verticalAlign?: VerticalAlign;
7
- horizontalAlign?: HorizontalAlign;
6
+ alignment?: MenuAlignment;
8
7
  actionState?: ActionState;
9
8
  onClose?: () => void;
10
9
  triggerAlignment?: 'left' | 'right' | 'center';
@@ -15,5 +14,5 @@ interface MenuWithSubmenuProps {
15
14
  * @param {MenuWithSubmenuProps} props - The props for the menu with trigger
16
15
  * @returns {Element} The menu with trigger demo
17
16
  */
18
- export declare const MenuWithSubmenu: ({ position, verticalAlign, horizontalAlign, spacing, actionState, onClose, triggerAlignment }: MenuWithSubmenuProps) => JSX.Element;
17
+ export declare const MenuWithSubmenu: ({ alignment, position, spacing, actionState, onClose, triggerAlignment }: MenuWithSubmenuProps) => JSX.Element;
19
18
  export {};
@@ -1,12 +1,13 @@
1
1
  /// <reference types="react" />
2
- import { MenuPosition, VerticalAlign, HorizontalAlign, ActionState } from '../constants';
2
+ import { CustomMenuPosition } from '../';
3
+ import { MenuPosition, ActionState, MenuAlignment } from '../constants';
3
4
  interface MenuWithTriggerProps {
4
5
  position?: MenuPosition;
5
6
  spacing?: 'default' | 'compact';
6
- verticalAlign?: VerticalAlign;
7
- horizontalAlign?: HorizontalAlign;
7
+ alignment?: MenuAlignment;
8
8
  actionState?: ActionState;
9
9
  onClose?: () => void;
10
+ customPosition?: CustomMenuPosition;
10
11
  triggerAlignment?: 'left' | 'right' | 'center';
11
12
  }
12
13
  /**
@@ -15,5 +16,5 @@ interface MenuWithTriggerProps {
15
16
  * @param {MenuWithTriggerProps} props - The props for the menu with trigger
16
17
  * @returns {Element} The menu with trigger demo
17
18
  */
18
- export declare const MenuWithTrigger: ({ position, verticalAlign, horizontalAlign, spacing, actionState, onClose, triggerAlignment }: MenuWithTriggerProps) => JSX.Element;
19
+ export declare const MenuWithTrigger: ({ alignment, position, spacing, actionState, customPosition, onClose, triggerAlignment }: MenuWithTriggerProps) => JSX.Element;
19
20
  export {};
@@ -2,3 +2,4 @@ export * from './MrlMenu';
2
2
  export * from './MrlMenuItem';
3
3
  export * from './MrlMenuItemLink';
4
4
  export * from './MrlMenuGroup';
5
+ export * from './constants';
@@ -1,5 +1,5 @@
1
1
  import React, { RefObject } from 'react';
2
- import { MenuPosition, VerticalAlign, HorizontalAlign, ActionState } from '../../menu/constants';
2
+ import { MenuPosition, MenuAlignment, ActionState } from '../../menu/constants';
3
3
  export interface MrlPopoverProps {
4
4
  /** Label for the popover */
5
5
  ariaLabel?: string;
@@ -24,6 +24,8 @@ export interface MrlPopoverProps {
24
24
  /**
25
25
  * Horizontal and vertical alignment of the menu relative to the trigger element
26
26
  *
27
+ * This does not impact submenus
28
+ *
27
29
  * @default 'bottom'
28
30
  */
29
31
  position?: MenuPosition;
@@ -38,17 +40,14 @@ export interface MrlPopoverProps {
38
40
  */
39
41
  triggerRef?: RefObject<HTMLButtonElement>;
40
42
  /**
41
- * Vertical alignment of the menu relative to the trigger element
43
+ * Vertical and horizontal alignment of the popover relative to the position with the trigger
44
+ * - 'left' and 'right' work with position 'top' and 'bottom'
45
+ * - 'top' and 'bottom' work with position 'left' and 'right'
46
+ * - 'center' works with all positions
42
47
  *
43
- * @default 'center'
48
+ * This does not impact submenus
44
49
  */
45
- verticalAlign?: VerticalAlign;
46
- /**
47
- * Horizontal alignment of the menu relative to the trigger element
48
- *
49
- * @default 'left'
50
- */
51
- horizontalAlign?: HorizontalAlign;
50
+ alignment?: MenuAlignment;
52
51
  /**
53
52
  * If the menu should be rendered with the inverse theme
54
53
  *
@@ -76,4 +75,7 @@ export interface MrlPopoverProps {
76
75
  * @param {MrlPopoverProps} props - The props for the MrlPopover component
77
76
  * @returns {Element} - rendered MrlPopover component
78
77
  */
79
- export declare function MrlPopover({ ariaLabel, ariaLabelledBy, children, disableClickOutside, hasCloseButton, spacing, id, isSubMenu, actionState, position, verticalAlign, horizontalAlign, point, kind, onClose, triggerRef, ...rest }: MrlPopoverProps): JSX.Element;
78
+ export declare function MrlPopover({ alignment, ariaLabel, ariaLabelledBy, children, disableClickOutside, hasCloseButton, spacing, id, isSubMenu, actionState, position, point, kind, onClose, triggerRef, ...rest }: MrlPopoverProps): JSX.Element;
79
+ export declare namespace MrlPopover {
80
+ var componentType: string;
81
+ }
@@ -1,11 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { MenuPosition, VerticalAlign, HorizontalAlign, ActionState } from '../../menu/constants';
2
+ import { MenuPosition, ActionState, MenuAlignment } from '../../menu/constants';
3
3
  interface PopoverWithTriggerProps {
4
4
  hasCloseButton?: boolean;
5
5
  menuAlign?: MenuPosition;
6
6
  spacing?: 'default' | 'compact';
7
- verticalAlign?: VerticalAlign;
8
- horizontalAlign?: HorizontalAlign;
7
+ alignment?: MenuAlignment;
9
8
  actionState?: ActionState;
10
9
  onClose?: () => void;
11
10
  triggerAlignment?: 'left' | 'right' | 'center';
@@ -18,5 +17,5 @@ interface PopoverWithTriggerProps {
18
17
  * @param {PopoverWithTriggerProps} props - The props for the menu with trigger
19
18
  * @returns {Element} The menu with trigger demo
20
19
  */
21
- export declare const PopoverWithTrigger: ({ menuAlign, verticalAlign, horizontalAlign, actionState, onClose, triggerAlignment, spacing, kind, point, hasCloseButton }: PopoverWithTriggerProps) => JSX.Element;
20
+ export declare const PopoverWithTrigger: ({ menuAlign, alignment, actionState, onClose, triggerAlignment, spacing, kind, point, hasCloseButton }: PopoverWithTriggerProps) => JSX.Element;
22
21
  export {};
@@ -1,9 +1,10 @@
1
- import { RefObject } from 'react';
2
1
  /**
3
2
  * Hook to detect clicks outside of a given DOM element.
4
3
  *
5
4
  * @param menuRef - Reference to the DOM element that caused this menu to be shown.
5
+ * @param triggerRef - Reference to the DOM element that caused this menu to be shown.
6
+ * @param eventType - Event type to listen for
6
7
  * @param onOutsideClick - Function to call when a click is detected outside the menuRef element
7
8
  * @param disabled - If the hook should be disabled
8
9
  */
9
- export declare const useClickOutside: (menuRef: RefObject<HTMLElement>, onOutsideClick: () => void, disabled?: boolean) => void;
10
+ export declare const useClickOutside: (menuRef: React.RefObject<HTMLElement>, triggerRef: React.RefObject<HTMLElement> | undefined, eventType: "click" | "mousedown" | "mouseup" | undefined, onOutsideClick: () => void, disabled?: boolean) => void;
@@ -1,8 +1,8 @@
1
- import { VerticalAlign, HorizontalAlign, MenuPosition } from '../../components/menu/constants';
1
+ import { MenuPosition, MenuAlignment, CustomMenuPosition } from '../../components/menu/constants';
2
2
  export interface Alignment {
3
- vertical: VerticalAlign;
4
- horizontal: HorizontalAlign;
5
- align: MenuPosition;
3
+ align: MenuAlignment;
4
+ position: MenuPosition;
5
+ customPosition?: CustomMenuPosition;
6
6
  }
7
7
  export interface Position {
8
8
  top: number;
@@ -1,11 +1,11 @@
1
1
  import { Alignment, Position } from './constants';
2
2
  /**
3
- * Position object
3
+ * Calculates the position of the menu based on the alignment and offset
4
4
  *
5
- * @param triggerRect - Rect of the trigger element
6
- * @param elementRect - Rect of the element to be positioned
7
- * @param menuAlign - Alignment object
8
- * @param offset - Offset value
9
- * @returns Position object
5
+ * @param menuAlign - the alignment of the menu
6
+ * @param offset - the offset from the trigger
7
+ * @param elementRect - the bounding client rect of the menu
8
+ * @param triggerRect - the bounding client rect of the trigger
9
+ * @returns - the position of the menu
10
10
  */
11
- export declare const calculatePosition: (triggerRect: DOMRect, elementRect: DOMRect, menuAlign: Alignment, offset: number) => Position;
11
+ export declare const calculatePosition: (menuAlign: Alignment, offset: number, elementRect: DOMRect, triggerRect?: DOMRect) => Position;