@muraldevkit/ui-toolkit 2.56.0 → 2.57.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,14 @@ export interface MrlIconButtonProps extends Omit<MrlComponentProps, 'style'>, Re
45
45
  * onClick event for the button.
46
46
  */
47
47
  onClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;
48
+ /**
49
+ * onKeyDown event for the button.
50
+ */
51
+ onKeyUp?: (e: React.KeyboardEvent<HTMLButtonElement>) => void;
52
+ /**
53
+ * onMouseUp event for the button.
54
+ */
55
+ onMouseUp?: (e: React.MouseEvent<HTMLButtonElement>) => void;
48
56
  /**
49
57
  * The placement of the tooltip in relation to the button.
50
58
  */
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { MrlPopoverProps } from '../../popover';
3
+ import '../../../styles/layers/layers.scss';
4
+ export type MrlCalloutPopoverProps = Omit<MrlPopoverProps, 'children' | 'actionState' | 'isSubMenu' | 'triggerRef' | 'kind'>;
5
+ interface MrlCalloutCTA {
6
+ onClick: () => void;
7
+ dataQa?: string;
8
+ text: string;
9
+ }
10
+ export type CalloutKind = 'primary' | 'secondary';
11
+ export interface MrlCalloutProps extends MrlCalloutPopoverProps {
12
+ /** a unique id that binds the callout content and the trigger for assistive technologies */
13
+ ariaControls?: string;
14
+ autoFocus?: boolean;
15
+ children: React.ReactElement;
16
+ disableClickOutside?: boolean;
17
+ description?: string | JSX.Element;
18
+ eyebrow?: string;
19
+ id?: string;
20
+ image?: JSX.Element;
21
+ kind?: CalloutKind;
22
+ renderWithPortal?: boolean;
23
+ show: boolean;
24
+ title?: string;
25
+ primaryCta?: MrlCalloutCTA;
26
+ secondaryCta?: MrlCalloutCTA;
27
+ }
28
+ /**
29
+ * MrlCallout component.
30
+ *
31
+ * @param props - The props.
32
+ * @returns {React.ReactElement} The MrlCallout component.
33
+ */
34
+ export declare const MrlCallout: ({ ariaControls, alignment, children, description, disableClickOutside, disableFocusTrap, eyebrow, hasCloseButton, image, kind, onOpen, onClose, point, position, primaryCta, secondaryCta, show, spacing, title, ...rest }: MrlCalloutProps) => React.ReactElement;
35
+ export {};
@@ -0,0 +1 @@
1
+ export * from './MrlCallout';
@@ -0,0 +1 @@
1
+ export * from './MrlCallout';
@@ -24,3 +24,4 @@ export * from './navigation-sidebar';
24
24
  export * from './skeleton';
25
25
  export * from './empty';
26
26
  export * from './live-region';
27
+ export * from './callout';
@@ -8,13 +8,31 @@ export interface CustomMenuPosition {
8
8
  left: number;
9
9
  top: number;
10
10
  }
11
+ /**
12
+ * The type of action that is being performed.
13
+ *
14
+ * Used in conjunction with the `ActionState` interface.
15
+ */
11
16
  export type ActionType = 'ArrowUp' | 'ArrowDown' | 'ArrowRight' | 'Enter' | 'Escape' | ' ' | 'click' | null;
17
+ /**
18
+ * The state of the menu you are interacting with.
19
+ *
20
+ * @property {ActionType} actionType - The type of action that is being performed.
21
+ * @property {boolean} isOpen - Whether the menu is open or not.
22
+ */
12
23
  export interface ActionState {
13
24
  actionType: ActionType;
14
25
  isOpen: boolean;
15
- disableTriggerFocus?: boolean;
16
26
  }
27
+ /**
28
+ * Accepted component types for use as a submenu
29
+ */
17
30
  export type SubMenuTypes = 'Menu' | 'Popover';
31
+ /**
32
+ * Extension of the React.FunctionComponent type to include a componentType property.
33
+ *
34
+ * Allows custom component types to be used to render a submenu.
35
+ */
18
36
  export interface ComponentWithComponentType extends React.FunctionComponent {
19
37
  componentType?: SubMenuTypes;
20
38
  }
@@ -1,22 +1,51 @@
1
1
  import React, { RefObject } from 'react';
2
- import { MenuPosition, MenuAlignment, ActionState } from '../../menu/constants';
2
+ import { PortalProps } from '../../';
3
+ import { MenuPosition, MenuAlignment, ActionState, CustomMenuPosition } from '../../menu/constants';
4
+ import '../../../styles/layers/layers.scss';
3
5
  export interface MrlPopoverProps {
6
+ /**
7
+ * Set initial state of menu
8
+ *
9
+ * @default { actionType: null, isOpen: false }
10
+ */
11
+ actionState?: ActionState;
4
12
  /** Label for the popover */
5
13
  ariaLabel?: string;
6
14
  /** ID of element to associate a label */
7
15
  ariaLabelledBy?: string;
8
16
  /** Children to be rendered within the menu component*/
9
17
  children: React.ReactNode;
10
- /** If the popover should have a close button */
11
- hasCloseButton?: boolean;
12
- /** If the popover should close when clicking outside of the menu */
18
+ /** Custom class names for the popover */
19
+ className?: string;
20
+ /** Custom position for the menu */
21
+ customPosition?: CustomMenuPosition;
22
+ /**
23
+ * If the popover should disable click to open
24
+ *
25
+ * Example usage: if you do not want your component opened via click, set to true
26
+ */
27
+ disableClickToOpen?: boolean;
28
+ /**
29
+ * If the popover should close when clicking outside of the menu
30
+ *
31
+ * Example usage: MrlCallout component should not close when clicking outside, so it's set to true
32
+ */
13
33
  disableClickOutside?: boolean;
14
34
  /**
15
- * spacing of menu
16
- * - 'default' has 16px padding
17
- * - 'compact' has 12px padding
35
+ * If the popover should disable focus trap
36
+ *
37
+ * The impact of enabling or disabling focus trap:
38
+ * - enabled : focus will remain trapped in the popover until a user closes the popover
39
+ * - disabled : focus will move to the next interactive element in the DOM when the user
40
+ * tabs out of the popover. Focus will move to the trigger when the user shift+tabs out of the popover
41
+ *
42
+ * Additional scenarios to consider with focus trap is disabled. When hasCloseButton is set to true/false:
43
+ * - true : if a user shows the close button, the popover will stay open until explicitly dismissed
44
+ * - false : if a user hides the close button, the popover will close when a user tabs out of it from the beginning or end
18
45
  */
19
- spacing?: 'default' | 'compact';
46
+ disableFocusTrap?: boolean;
47
+ /** If the popover should have a close button */
48
+ hasCloseButton?: boolean;
20
49
  /** Unique identifier for the menu */
21
50
  id?: string;
22
51
  /** If the menu is a submenu */
@@ -29,16 +58,6 @@ export interface MrlPopoverProps {
29
58
  * @default 'bottom'
30
59
  */
31
60
  position?: MenuPosition;
32
- /**
33
- * Set initial state of menu
34
- *
35
- * @default { actionType: null, isOpen: false }
36
- */
37
- actionState?: ActionState;
38
- /**
39
- * Reference to the DOM element that triggers this menu.
40
- */
41
- triggerRef?: RefObject<HTMLButtonElement>;
42
61
  /**
43
62
  * Vertical and horizontal alignment of the popover relative to the position with the trigger
44
63
  * - 'left' and 'right' work with position 'top' and 'bottom'
@@ -48,6 +67,16 @@ export interface MrlPopoverProps {
48
67
  * This does not impact submenus
49
68
  */
50
69
  alignment?: MenuAlignment;
70
+ /**
71
+ * spacing of menu
72
+ * - 'default' has 16px padding
73
+ * - 'compact' has 12px padding
74
+ */
75
+ spacing?: 'default' | 'compact';
76
+ /**
77
+ * Reference to the DOM element that triggers this menu.
78
+ */
79
+ triggerRef?: RefObject<HTMLElement>;
51
80
  /**
52
81
  * If the menu should be rendered with the inverse theme
53
82
  *
@@ -60,12 +89,31 @@ export interface MrlPopoverProps {
60
89
  * @default false
61
90
  */
62
91
  point?: boolean;
92
+ /**
93
+ * Configuration for the portal component
94
+ */
95
+ portalProps?: Omit<PortalProps, 'children'>;
96
+ /**
97
+ * Offset in pixels for the popover
98
+ *
99
+ * The popover automatically calculates the proper offset based on the position and alignment
100
+ * this prop will override those values.
101
+ */
102
+ offset?: number;
103
+ /**
104
+ * Callback to be called when the menu is opened
105
+ */
106
+ onOpen?: () => void;
63
107
  /**
64
108
  * Callback to be called when the menu is closed
65
109
  *
66
110
  * @param type - type of close event
67
111
  */
68
112
  onClose?: (type?: string) => void;
113
+ /**
114
+ * data-qa attribute for the popover
115
+ */
116
+ ['data-qa']?: string;
69
117
  }
70
118
  /**
71
119
  * MrlPopover
@@ -75,7 +123,7 @@ export interface MrlPopoverProps {
75
123
  * @param {MrlPopoverProps} props - The props for the MrlPopover component
76
124
  * @returns {Element} - rendered MrlPopover component
77
125
  */
78
- export declare function MrlPopover({ alignment, ariaLabel, ariaLabelledBy, children, disableClickOutside, hasCloseButton, spacing, id, isSubMenu, actionState, position, point, kind, onClose, triggerRef, ...rest }: MrlPopoverProps): JSX.Element;
126
+ export declare function MrlPopover({ alignment, ariaLabel, ariaLabelledBy, children, className, customPosition, disableClickToOpen, disableClickOutside, disableFocusTrap, hasCloseButton, spacing, id, isSubMenu, actionState, position, point, portalProps, kind, offset, onClose, onOpen, triggerRef, ...rest }: MrlPopoverProps): JSX.Element;
79
127
  export declare namespace MrlPopover {
80
128
  var componentType: string;
81
129
  }
@@ -10,6 +10,7 @@ interface PopoverWithTriggerProps {
10
10
  triggerAlignment?: 'left' | 'right' | 'center';
11
11
  kind?: 'inverse' | 'primary';
12
12
  point?: boolean;
13
+ disableFocusTrap?: boolean;
13
14
  }
14
15
  /**
15
16
  * Demo of a menu with a trigger for stories and testing
@@ -17,5 +18,5 @@ interface PopoverWithTriggerProps {
17
18
  * @param {PopoverWithTriggerProps} props - The props for the menu with trigger
18
19
  * @returns {Element} The menu with trigger demo
19
20
  */
20
- export declare const PopoverWithTrigger: ({ menuAlign, alignment, actionState, onClose, triggerAlignment, spacing, kind, point, hasCloseButton }: PopoverWithTriggerProps) => JSX.Element;
21
+ export declare const PopoverWithTrigger: ({ menuAlign, alignment, actionState, onClose, triggerAlignment, spacing, kind, point, hasCloseButton, disableFocusTrap }: PopoverWithTriggerProps) => JSX.Element;
21
22
  export {};
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
+ import '../../styles/layers/layers.scss';
2
3
  export interface PortalProps extends React.HTMLAttributes<HTMLDivElement> {
3
4
  children: React.ReactNode;
4
5
  className?: string;
6
+ ['data-qa']?: string;
5
7
  id?: string;
6
8
  }
7
- export declare const MRL_PORTAL_ID = "mrl-root-portal";
9
+ export declare const MRL_PORTAL_ID: "mrl-root-portal";
8
10
  /**
9
11
  * Dynamically creates a single portal and send your children to the portal.
10
12
  * Where they will live outside of the normal document flow
@@ -4,7 +4,7 @@ import { SVGSize } from '../constants';
4
4
  export type DSIcons = typeof import('@muraldevkit/ds-icons');
5
5
  export type DSPictograms = typeof import('@muraldevkit/ds-pictograms');
6
6
  export type DSIconType = DSIcons[keyof DSIcons] | DSPictograms[keyof DSPictograms];
7
- export interface SvgPropTypes extends Omit<MrlComponentProps, 'style'>, React.ComponentProps<'svg'> {
7
+ export interface SvgPropTypes extends Omit<MrlComponentProps, 'style'>, Omit<React.ComponentProps<'svg'>, 'ref'> {
8
8
  /** Any additional classes to style the SVG's container */
9
9
  className?: string;
10
10
  /**
@@ -30,4 +30,4 @@ export interface SvgPropTypes extends Omit<MrlComponentProps, 'style'>, React.Co
30
30
  * @param {SvgPropTypes} props the props for your MrlSvg
31
31
  * @returns {React.ReactElement} a rendered SVG
32
32
  */
33
- export declare const MrlSvg: (props: SvgPropTypes) => React.ReactElement;
33
+ export declare const MrlSvg: React.MemoExoticComponent<(props: SvgPropTypes) => React.ReactElement>;
@@ -1,8 +1,12 @@
1
1
  import React from 'react';
2
2
  import { AttrsObject } from '../../../utils';
3
3
  import { LevelType, HeadingHierarchies, HeadingSizes, TextSizes, HeadingKinds } from '../constants';
4
- interface MrlTextHeadingProps {
5
- /** Applies additional HTML attributes to the text element */
4
+ interface MrlTextHeadingProps extends React.ComponentPropsWithRef<'h1'> {
5
+ /**
6
+ * Applies additional HTML attributes to the text element
7
+ *
8
+ * @deprecated - use `attrs` instead
9
+ */
6
10
  attrs?: AttrsObject;
7
11
  /** Children to be rendered within the text heading component */
8
12
  children?: React.ReactNode;
@@ -30,5 +34,5 @@ interface MrlTextHeadingProps {
30
34
  * @param {MrlTextHeadingProps} props - MrlTextHeading component props
31
35
  * @returns a heading element
32
36
  */
33
- export declare function MrlTextHeading({ attrs, children, hierarchy, kind, level, size, text }: MrlTextHeadingProps): JSX.Element;
37
+ export declare function MrlTextHeading({ attrs, children, className, hierarchy, kind, level, size, text }: MrlTextHeadingProps): JSX.Element;
34
38
  export {};
@@ -2,6 +2,7 @@ import React, { ReactElement } from 'react';
2
2
  import { AttrsObject } from '../../../utils';
3
3
  import { MrlTooltipAnchor, MrlTooltipPosition, MrlTooltipVariant } from '../constants';
4
4
  import '../../../styles/shared/a11y-helpers/a11y.global.scss';
5
+ import '../../../styles/layers/layers.scss';
5
6
  interface MrlTooltipProps {
6
7
  /** The arrow position of the tooltip in relation to its trigger's content */
7
8
  anchor?: MrlTooltipAnchor;