@muraldevkit/ui-toolkit 4.77.0 → 4.77.2-dev-kdxV.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.
Files changed (37) hide show
  1. package/dist/cjs/components/form/label/MrlLabel/MrlLabel.js.map +1 -1
  2. package/dist/cjs/components/form/legacy-select/MrlLegacySelect/MrlLegacySelect.js.map +1 -1
  3. package/dist/cjs/components/form/text-input/MrlTextInput/MrlTextInput.js.map +1 -1
  4. package/dist/cjs/components/link/MrlLink/MrlLink.js.map +1 -1
  5. package/dist/cjs/components/menu/MrlMenu/MrlMenu.js +12 -1
  6. package/dist/cjs/components/menu/MrlMenu/MrlMenu.js.map +1 -1
  7. package/dist/cjs/components/popover/MrlPopover/MrlPopover.js +6 -1
  8. package/dist/cjs/components/popover/MrlPopover/MrlPopover.js.map +1 -1
  9. package/dist/cjs/hooks/useTriggerPosition/index.js +27 -2
  10. package/dist/cjs/hooks/useTriggerPosition/index.js.map +1 -1
  11. package/dist/cjs/version.js +1 -1
  12. package/dist/cjs/version.js.map +1 -1
  13. package/dist/components/form/label/MrlLabel/MrlLabel.d.ts +5 -1
  14. package/dist/components/form/legacy-select/MrlLegacySelect/MrlLegacySelect.d.ts +2 -0
  15. package/dist/components/form/text-input/MrlTextInput/MrlTextInput.d.ts +5 -1
  16. package/dist/components/link/MrlLink/MrlLink.d.ts +2 -0
  17. package/dist/esm/components/form/label/MrlLabel/MrlLabel.js.map +1 -1
  18. package/dist/esm/components/form/legacy-select/MrlLegacySelect/MrlLegacySelect.js.map +1 -1
  19. package/dist/esm/components/form/text-input/MrlTextInput/MrlTextInput.js.map +1 -1
  20. package/dist/esm/components/link/MrlLink/MrlLink.js.map +1 -1
  21. package/dist/esm/components/menu/MrlMenu/MrlMenu.js +12 -1
  22. package/dist/esm/components/menu/MrlMenu/MrlMenu.js.map +1 -1
  23. package/dist/esm/components/popover/MrlPopover/MrlPopover.js +6 -1
  24. package/dist/esm/components/popover/MrlPopover/MrlPopover.js.map +1 -1
  25. package/dist/esm/hooks/useTriggerPosition/index.js +29 -4
  26. package/dist/esm/hooks/useTriggerPosition/index.js.map +1 -1
  27. package/dist/esm/version.js +1 -1
  28. package/dist/esm/version.js.map +1 -1
  29. package/dist/hooks/useTriggerPosition/constants.d.ts +4 -0
  30. package/dist/hooks/useTriggerPosition/index.d.ts +3 -3
  31. package/dist/types/components/form/label/MrlLabel/MrlLabel.d.ts +5 -1
  32. package/dist/types/components/form/legacy-select/MrlLegacySelect/MrlLegacySelect.d.ts +2 -0
  33. package/dist/types/components/form/text-input/MrlTextInput/MrlTextInput.d.ts +5 -1
  34. package/dist/types/components/link/MrlLink/MrlLink.d.ts +2 -0
  35. package/dist/types/hooks/useTriggerPosition/constants.d.ts +4 -0
  36. package/dist/types/hooks/useTriggerPosition/index.d.ts +3 -3
  37. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"MrlPopover.js","sources":["../../../../../src/components/popover/MrlPopover/MrlPopover.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { close } from '@muraldevkit/ds-icons';\nimport { MrlIconButton } from '../../button/MrlIconButton/MrlIconButton';\nimport { MrlFocusTrap } from '../../focus-trap/MrlFocusTrap/MrlFocusTrap';\nimport { MrlPortal, PortalProps } from '../../portal/MrlPortal';\nimport { MrlSvg } from '../../svg/MrlSvg/MrlSvg';\nimport { useTriggerPosition } from '../../../hooks/useTriggerPosition';\nimport { useBrowserEdgeScroll } from '../../menu/hooks/useBrowserEdgeScroll';\nimport { useClickOutside } from '../../../hooks/useClickOutside';\nimport { useSubMenuElementPosition } from '../../menu/hooks/useSubMenuElementPosition';\nimport { MenuPosition, MenuAlignment, ActionState, CustomMenuPosition } from '../../menu/constants';\nimport {\n\tpreventDefault,\n\tgetFocusableElementsInsideElement,\n\tfindAdjacentInteractiveElement,\n\tisElementAriaDisabled\n} from '../../../utils';\nimport { PORTAL_LAYERS } from '../../../utils/layers';\nimport { useTransition, animated } from '@react-spring/web';\nimport { SELECT_MENU_LIST_CLASS_NAME } from '../../form/select/MrlSelect/MrlSelect';\nimport { MULTI_SELECT_MENU_LIST_CLASS_NAME } from '../../form/select/MrlMultiSelect/MrlMultiSelect';\nimport styles from './MrlPopover.module.scss';\nimport { flipPosition } from '../../menu/utilities/flip-position';\nimport { getDataPoint } from './utilities/get-data-point';\nimport { getOffset } from './utilities/get-offset';\nimport { useMrlPopoverEventHandlers } from './hooks/use-mrl-popover-event-handlers';\nimport { MrlPopoverContext } from './context/MrlPopoverContext';\nimport { MrlPopoverScrollContainer } from './MrlPopoverScrollContainer';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nconst POPOVER_CLICKOUTSIDE_WHITELIST = [\n\t'#mrl-select-portal',\n\t'#mrl-popover-menu-portal',\n\t`.${SELECT_MENU_LIST_CLASS_NAME}`,\n\t`.${MULTI_SELECT_MENU_LIST_CLASS_NAME}`\n];\n\ntype RenderPropFn = ({ closeMenu }: { closeMenu: () => void }) => JSX.Element;\n\nexport interface MrlPopoverProps {\n\t/**\n\t * Set initial state of menu\n\t * @default { actionType: null, isOpen: false }\n\t */\n\tactionState?: ActionState;\n\n\t/** Label for the popover */\n\tariaLabel?: string;\n\n\t/** ID of element to associate a label */\n\tariaLabelledBy?: string;\n\n\t/** Children to be rendered within the menu component*/\n\tchildren: React.ReactNode | RenderPropFn;\n\n\t/** Custom class names for the popover */\n\tclassName?: string;\n\n\t/** Custom position for the menu */\n\tcustomPosition?: CustomMenuPosition;\n\n\t/**\n\t * If the popover should disable click to open\n\t *\n\t * Example usage: if you do not want your component opened via click, set to true\n\t */\n\tdisableClickToOpen?: boolean;\n\n\t/**\n\t * If the popover should close when clicking outside of the menu\n\t *\n\t * Example usage: MrlCallout component should not close when clicking outside, so it's set to true\n\t */\n\tdisableClickOutside?: boolean;\n\n\t/**\n\t * Disable flipping of the popover when it goes off the screen\n\t * @default false\n\t */\n\tdisableFlipping?: boolean;\n\n\t/**\n\t * If the popover should disable focus trap\n\t *\n\t * The impact of enabling or disabling focus trap:\n\t * - enabled : focus will remain trapped in the popover until a user closes the popover\n\t * - disabled : focus will move to the next interactive element in the DOM when the user\n\t * tabs out of the popover. Focus will move to the trigger when the user shift+tabs out of the popover\n\t *\n\t * Additional scenarios to consider with focus trap is disabled. When hasCloseButton is set to true/false:\n\t * - true : if a user shows the close button, the popover will stay open until explicitly dismissed\n\t * - false : if a user hides the close button, the popover will close when a user tabs out of it from the beginning or end\n\t */\n\tdisableFocusTrap?: boolean;\n\n\t/** If the popover should have a close button */\n\thasCloseButton?: boolean;\n\n\t/** Unique identifier for the menu */\n\tid?: string;\n\n\t/** If the menu is a submenu */\n\tisSubMenu?: boolean;\n\n\t/**\n\t * Horizontal and vertical alignment of the menu relative to the trigger element\n\t *\n\t * This does not impact submenus\n\t * @default 'bottom'\n\t */\n\tposition?: MenuPosition;\n\n\t/**\n\t * Alignment of the popover along the axis perpendicular to its position\n\t * - For position 'top'/'bottom': 'start' = left, 'end' = right, 'center' = center horizontally\n\t * - For position 'left'/'right': 'start' = top, 'end' = bottom, 'center' = center vertically\n\t *\n\t * @default 'center'\n\t *\n\t * This does not impact submenus\n\t */\n\talignment?: MenuAlignment;\n\n\t/**\n\t * spacing of menu\n\t * - 'default' has 16px padding\n\t * - 'compact' has 12px padding\n\t */\n\tspacing?: 'default' | 'compact';\n\n\t/**\n\t * Reference to the DOM element that triggers this menu.\n\t */\n\ttriggerRef?: React.RefObject<HTMLElement>;\n\n\t/**\n\t * If the menu should be rendered with the inverse theme\n\t * @default 'primary'\n\t */\n\tkind?: 'primary' | 'inverse';\n\n\t/**\n\t * If the menu should have a pointer element\n\t * @default false\n\t */\n\tpoint?: boolean;\n\n\t/**\n\t * Configuration for the portal component\n\t */\n\tportalProps?: Omit<PortalProps, 'children'>;\n\n\t/**\n\t * Offset in pixels for the popover\n\t *\n\t * The popover automatically calculates the proper offset based on the position and alignment\n\t * this prop will override those values.\n\t */\n\toffset?: number;\n\n\t/**\n\t * Callback to be called when the menu is opened\n\t */\n\tonOpen?: () => void;\n\n\t/**\n\t * Callback to be called when the menu is closed\n\t * @param type - type of close event\n\t */\n\tonClose?: (type?: string) => void;\n\n\t/**\n\t * data-qa attribute for the popover\n\t */\n\t['data-qa']?: string;\n\n\t/**\n\t * Enables interaction tracking for this popover. Provide a stable, non-PII id\n\t * (e.g. 'sticky-note-color-picker'). When omitted, the popover emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * MrlPopover\n *\n * Renders a popover component with position and alignment relative to a trigger element\n * @param {MrlPopoverProps} props - The props for the MrlPopover component\n * @returns {Element} - rendered MrlPopover component\n */\nexport function MrlPopover({\n\talignment = 'center',\n\tariaLabel,\n\tariaLabelledBy,\n\tchildren,\n\tclassName,\n\tcustomPosition,\n\tdisableClickToOpen = false,\n\tdisableClickOutside = false,\n\tdisableFlipping = false,\n\tdisableFocusTrap = false,\n\thasCloseButton = false,\n\tspacing = 'default',\n\tid,\n\tisSubMenu = false,\n\tactionState = { actionType: null, isOpen: false },\n\tposition = 'bottom',\n\tpoint = true,\n\tportalProps = { id: PORTAL_LAYERS.POPOVER.name },\n\tkind = 'primary',\n\toffset,\n\tonClose,\n\tonOpen,\n\teventId,\n\ttriggerRef,\n\t...rest\n}: MrlPopoverProps): JSX.Element {\n\tconst [state, setState] = React.useState({\n\t\tactionType: null,\n\t\tisOpen: actionState.isOpen || false\n\t} as ActionState);\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlPopover', eventId);\n\t// the popover opens and closes from several paths (trigger click, keyboard, click\n\t// outside, close button), so open/close is emitted from the resulting state.\n\tconst wasOpenRef = React.useRef(actionState.isOpen || false);\n\n\tReact.useEffect(() => {\n\t\tif (wasOpenRef.current === state.isOpen) return;\n\n\t\twasOpenRef.current = state.isOpen;\n\n\t\ttrackInteraction({\n\t\t\taction: state.isOpen ? 'open' : 'close',\n\t\t\tmetadata: { isSubMenu },\n\t\t\tvariant: position\n\t\t});\n\t}, [state.isOpen, isSubMenu, position, trackInteraction]);\n\n\t// stores all of the interactive elements in the popover for focus management\n\tconst [interactiveElements, setInteractiveElements] = React.useState<HTMLElement[]>([]);\n\tconst [menuRect, setMenuRect] = React.useState<DOMRect | null>(null);\n\tconst menuRef = React.useRef<HTMLDivElement>(null);\n\t/** Snapshot of trigger `aria-expanded` before we manage it; restored on popover unmount only. */\n\tconst triggerExpandedRestoreRef = React.useRef<{\n\t\tel: HTMLElement;\n\t\tvalue: string | null;\n\t} | null>(null);\n\n\t/**\n\t * Checks if the trigger element is disabled\n\t * @returns {boolean} - true if the trigger element is disabled, false otherwise\n\t */\n\tconst isTriggerDisabled = React.useCallback((): boolean => {\n\t\treturn isElementAriaDisabled(triggerRef?.current);\n\t}, [triggerRef]);\n\n\t/**\n\t * Opening and closing the menu\n\t */\n\tconst closeMenu = React.useCallback(() => {\n\t\tsetState({ actionType: null, isOpen: false });\n\t\tonClose?.();\n\t}, [onClose]);\n\n\tconst {\n\t\thandleClose,\n\t\thandleMenuKey,\n\t\thideMenuHover,\n\t\thandleTriggerSiblingKey,\n\t\ttoggleMenuKey,\n\t\ttoggleMenuTrigger,\n\t\tshowMenuHover\n\t} = useMrlPopoverEventHandlers({\n\t\tcloseMenu,\n\t\tdisableClickToOpen,\n\t\tdisableFocusTrap,\n\t\thasCloseButton,\n\t\tinteractiveElements,\n\t\tisSubMenu,\n\t\tisTriggerDisabled,\n\t\tmenuRef,\n\t\tsetState,\n\t\tstate,\n\t\ttriggerRef\n\t});\n\n\tuseClickOutside(\n\t\tmenuRef,\n\t\ttriggerRef,\n\t\t'mouseup',\n\t\tcloseMenu,\n\t\tdisableClickOutside || !state.isOpen,\n\t\tPOPOVER_CLICKOUTSIDE_WHITELIST\n\t);\n\n\tReact.useEffect(() => {\n\t\tif (isTriggerDisabled()) return;\n\n\t\tif (!isSubMenu) {\n\t\t\tsetState({ actionType: actionState.actionType, isOpen: actionState.isOpen });\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [isSubMenu, actionState.actionType, actionState.isOpen]);\n\n\t// This use effect handles storing the rect in state for positioning calculations\n\tReact.useLayoutEffect(() => {\n\t\tif (!state.isOpen) return;\n\n\t\t// For consistent calculations, we are storing the menu rect in state\n\t\t// Anytime we need to use the menu rect, we want to make sure the values are based\n\t\t// on the original state of the menu for proper transformations\n\t\tif (!menuRect && menuRef.current) {\n\t\t\tconst newRect = menuRef.current?.getBoundingClientRect();\n\t\t\tsetMenuRect(newRect || null);\n\t\t}\n\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [state.isOpen, isSubMenu]);\n\n\t// This use effect handles getting and setting the interactive elements in the popover.\n\t// These elements are used for focus management when focus trap is not enabled to ensure\n\t// that our tab order matches the visual order of the page\n\tReact.useEffect(() => {\n\t\tif (state.isOpen && !isSubMenu && menuRef.current) {\n\t\t\tif (disableFocusTrap) {\n\t\t\t\t// set the interactive elements so we can track focus location\n\t\t\t\tconst elements = getFocusableElementsInsideElement(menuRef.current as HTMLElement);\n\t\t\t\tsetInteractiveElements(elements);\n\n\t\t\t\t// without focus trap enabled, we want to focus the first interactive element\n\t\t\t\telements[0].focus();\n\t\t\t}\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [state.isOpen, menuRef.current]);\n\n\t// This use effect handles setting all of the event handlers for different parts of the component.\n\t// - trigger event handlers\n\t// - submenu event handlers\n\t// - menu event handlers\n\t// - \"next element\" event handlers, which are event handlers attached to the next interactive element after the trigger\n\t//\n\tReact.useEffect(() => {\n\t\tconst triggerElement = triggerRef?.current;\n\t\tconst menuElement = menuRef?.current;\n\t\tconst nextElement = findAdjacentInteractiveElement(triggerRef, 'next');\n\n\t\tif (triggerElement) {\n\t\t\ttriggerElement.addEventListener('mousedown', (e) => e.stopPropagation());\n\t\t\ttriggerElement.addEventListener('click', toggleMenuTrigger);\n\t\t\ttriggerElement.addEventListener('keydown', toggleMenuKey);\n\n\t\t\tif (nextElement) nextElement.addEventListener('keydown', handleTriggerSiblingKey);\n\n\t\t\t// Setup event listeners for when the menu is a submenu\n\t\t\tif (isSubMenu) {\n\t\t\t\tconst menuElement = menuRef?.current;\n\n\t\t\t\ttriggerElement.addEventListener('mouseover', showMenuHover);\n\t\t\t\ttriggerElement.addEventListener('mouseout', hideMenuHover);\n\n\t\t\t\tif (menuElement) {\n\t\t\t\t\tmenuElement.addEventListener('mouseover', showMenuHover);\n\t\t\t\t\tmenuElement.addEventListener('mouseout', hideMenuHover);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\ttriggerElement.removeEventListener('mousedown', preventDefault);\n\t\t\t\ttriggerElement.removeEventListener('click', toggleMenuTrigger);\n\t\t\t\ttriggerElement.removeEventListener('keydown', toggleMenuKey);\n\n\t\t\t\tif (nextElement) nextElement.removeEventListener('keydown', handleTriggerSiblingKey);\n\n\t\t\t\tif (isSubMenu) {\n\t\t\t\t\ttriggerElement.removeEventListener('mouseover', showMenuHover);\n\t\t\t\t\ttriggerElement.removeEventListener('mouseout', hideMenuHover);\n\n\t\t\t\t\tif (menuElement) {\n\t\t\t\t\t\tmenuElement.removeEventListener('mouseover', showMenuHover);\n\t\t\t\t\t\tmenuElement.removeEventListener('mouseout', hideMenuHover);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [\n\t\tcloseMenu,\n\t\tisSubMenu,\n\t\ttoggleMenuKey,\n\t\ttoggleMenuTrigger,\n\t\ttriggerRef?.current,\n\t\thideMenuHover,\n\t\tshowMenuHover,\n\t\thasCloseButton,\n\t\thandleClose\n\t]);\n\n\t/**\n\t * Popover triggers are not necessarily modal dialogs; use the generic 'true' (see ARIA in HTML).\n\t * Restore the previous DOM value when the trigger changes or this popover unmounts so host-owned\n\t * ARIA (e.g. aria-haspopup=\"menu\") is not left stale after a callout dismisses.\n\t */\n\tReact.useEffect(() => {\n\t\tconst el = triggerRef?.current;\n\t\tif (!el) return;\n\n\t\tconst previousValue = el.getAttribute('aria-haspopup');\n\t\tel.setAttribute('aria-haspopup', 'true');\n\n\t\t// Restore the previous value of the aria-haspopup attribute when the callout is removed from the DOM\n\t\treturn () => {\n\t\t\tif (previousValue === null) {\n\t\t\t\tel.removeAttribute('aria-haspopup');\n\t\t\t} else {\n\t\t\t\tel.setAttribute('aria-haspopup', previousValue);\n\t\t\t}\n\t\t};\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [triggerRef?.current]);\n\n\tReact.useEffect(() => {\n\t\tconst el = triggerRef?.current;\n\t\tif (!el) return;\n\n\t\t// Store the previous value of the aria-expanded attribute when the callout is added to the DOM\n\t\tif (!triggerExpandedRestoreRef.current || triggerExpandedRestoreRef.current.el !== el) {\n\t\t\ttriggerExpandedRestoreRef.current = {\n\t\t\t\tel,\n\t\t\t\tvalue: el.hasAttribute('aria-expanded') ? el.getAttribute('aria-expanded') : null\n\t\t\t};\n\t\t}\n\n\t\t// Set the aria-expanded attribute to the current state of the popover\n\t\tel.setAttribute('aria-expanded', state.isOpen.toString());\n\n\t\tif (state.isOpen) onOpen?.();\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [state.isOpen, onOpen, triggerRef?.current]);\n\n\t/**\n\t * Restore the previous value of the aria-expanded attribute when the callout is removed from the DOM\n\t */\n\tReact.useEffect(() => {\n\t\treturn () => {\n\t\t\tconst snap = triggerExpandedRestoreRef.current;\n\t\t\tif (!snap) return;\n\t\t\tconst { el, value } = snap;\n\n\t\t\tif (!document?.documentElement?.contains(el)) return;\n\n\t\t\tif (value === null) {\n\t\t\t\tel.removeAttribute('aria-expanded');\n\t\t\t} else {\n\t\t\t\tel.setAttribute('aria-expanded', value);\n\t\t\t}\n\t\t};\n\t}, []);\n\n\t/**\n\t * Setup positioning styles, submenu positioning styles, scroll styles, and transition.\n\t */\n\tconst memoizedCustomPosition = React.useMemo(() => customPosition, [customPosition]);\n\tconst customPopoverPosition = memoizedCustomPosition || { left: 0, top: 0 };\n\n\tconst menuPosition = useTriggerPosition(\n\t\ttriggerRef,\n\t\tmenuRef,\n\t\t{\n\t\t\talign: alignment,\n\t\t\tcustomPosition: customPopoverPosition,\n\t\t\tposition: position\n\t\t},\n\t\tstate.isOpen,\n\t\toffset || getOffset(position, point),\n\t\tisSubMenu,\n\t\tdisableFlipping\n\t);\n\n\tconst subMenuPosition = useSubMenuElementPosition(\n\t\ttriggerRef,\n\t\tmenuRef,\n\t\tisSubMenu,\n\t\tstate.isOpen,\n\t\tmenuRect,\n\t\t!isSubMenu\n\t);\n\n\tconst menuPositionState = menuPosition.flipped ? flipPosition(position) : position;\n\tconst scrollStyles = useBrowserEdgeScroll(menuRef, menuPositionState, alignment);\n\n\tconst inlineStyles = {\n\t\tmenu: {\n\t\t\tleft: menuPosition.left,\n\t\t\tposition: 'fixed' as const,\n\t\t\ttop: menuPosition.top\n\t\t},\n\t\tsubmenu: {\n\t\t\tleft: subMenuPosition.left,\n\t\t\ttop: subMenuPosition.top\n\t\t}\n\t};\n\n\t/**\n\t * React Spring transitions for the menu\n\t */\n\tconst transitions = useTransition(state.isOpen, {\n\t\tconfig: { duration: 150 },\n\t\tenter: { opacity: 1, transform: 'translateY(0)' },\n\t\tfrom: { opacity: 0, transform: 'translateY(4px)' },\n\t\tleave: { opacity: 0, transform: 'translateY(4px)' }\n\t});\n\n\tconst menuClasses = classnames(\n\t\tstyles['MrlPopover'],\n\t\t'MrlPopover',\n\t\tstyles['MrlPopover--scrolling'],\n\t\tclassName,\n\t\t{\n\t\t\t[styles['MrlPopover--submenu']]: isSubMenu,\n\t\t\t[styles['inverse']]: kind === 'inverse',\n\t\t\t[styles['primary']]: kind === 'primary',\n\t\t\t[styles['compact']]: spacing === 'compact',\n\t\t\t[styles['default']]: spacing === 'default'\n\t\t}\n\t);\n\n\tconst positionStyles = isSubMenu ? inlineStyles.submenu : inlineStyles.menu;\n\n\tconst renderMenu = () => {\n\t\tconst inlineScrollStyles = isSubMenu ? {} : scrollStyles ? scrollStyles.styles : {};\n\t\tconst scrollClasses = classnames(\n\t\t\tstyles['MrlPopover--content'],\n\t\t\tstyles['MrlPopover--scrolling--content']\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{transitions(\n\t\t\t\t\t(style, item) =>\n\t\t\t\t\t\titem && (\n\t\t\t\t\t\t\t<MrlFocusTrap disabled={disableFocusTrap} containerRef={menuRef}>\n\t\t\t\t\t\t\t\t<animated.div\n\t\t\t\t\t\t\t\t\taria-label={ariaLabel}\n\t\t\t\t\t\t\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\t\t\t\t\t\t\tclassName={menuClasses}\n\t\t\t\t\t\t\t\t\tid={id}\n\t\t\t\t\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\t\t\t\t\tstyle={{ ...positionStyles, ...style }}\n\t\t\t\t\t\t\t\t\tonKeyDown={handleMenuKey}\n\t\t\t\t\t\t\t\t\tref={menuRef}\n\t\t\t\t\t\t\t\t\t{...rest}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<MrlPopoverScrollContainer className={scrollClasses} style={inlineScrollStyles}>\n\t\t\t\t\t\t\t\t\t\t{typeof children === 'function' && children({ closeMenu })}\n\t\t\t\t\t\t\t\t\t\t{typeof children !== 'function' && children}\n\t\t\t\t\t\t\t\t\t\t{hasCloseButton && (\n\t\t\t\t\t\t\t\t\t\t\t<MrlIconButton\n\t\t\t\t\t\t\t\t\t\t\t\tdata-qa=\"popover-close-button\"\n\t\t\t\t\t\t\t\t\t\t\t\twrapperClassName={styles['MrlPopover--close']}\n\t\t\t\t\t\t\t\t\t\t\t\ticon={<MrlSvg svg={close} />}\n\t\t\t\t\t\t\t\t\t\t\t\tkind={kind === 'inverse' ? 'ghost-inverse' : 'ghost'}\n\t\t\t\t\t\t\t\t\t\t\t\ttext=\"Close\"\n\t\t\t\t\t\t\t\t\t\t\t\tstate=\"default\"\n\t\t\t\t\t\t\t\t\t\t\t\tposition=\"right\"\n\t\t\t\t\t\t\t\t\t\t\t\ttipAnchor=\"center\"\n\t\t\t\t\t\t\t\t\t\t\t\tonMouseUp={closeMenu}\n\t\t\t\t\t\t\t\t\t\t\t\tonKeyDown={handleClose}\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t{point && (\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tclassName={styles['MrlPopover--point']}\n\t\t\t\t\t\t\t\t\t\t\t\tdata-point={getDataPoint(menuPositionState, alignment)}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t</MrlPopoverScrollContainer>\n\t\t\t\t\t\t\t\t</animated.div>\n\t\t\t\t\t\t\t</MrlFocusTrap>\n\t\t\t\t\t\t)\n\t\t\t\t)}\n\t\t\t</>\n\t\t);\n\t};\n\n\t/* eslint-disable */\n\treturn (\n\t\t<MrlPopoverContext.Provider\n\t\t\tvalue={{\n\t\t\t\tcloseMenu\n\t\t\t}}\n\t\t>\n\t\t\t{isSubMenu ? (\n\t\t\t\trenderMenu()\n\t\t\t) : (\n\t\t\t\t<MrlPortal layer={portalProps.layer || PORTAL_LAYERS.POPOVER} {...portalProps}>\n\t\t\t\t\t{renderMenu()}\n\t\t\t\t</MrlPortal>\n\t\t\t)}\n\t\t</MrlPopoverContext.Provider>\n\t);\n\t/* eslint-enable */\n}\n\nMrlPopover.componentType = 'Popover';\n"],"names":["POPOVER_CLICKOUTSIDE_WHITELIST","concat","SELECT_MENU_LIST_CLASS_NAME","MULTI_SELECT_MENU_LIST_CLASS_NAME","MrlPopover","_ref","_ref$alignment","alignment","ariaLabel","ariaLabelledBy","children","className","customPosition","_ref$disableClickToOp","disableClickToOpen","_ref$disableClickOuts","disableClickOutside","_ref$disableFlipping","disableFlipping","_ref$disableFocusTrap","disableFocusTrap","_ref$hasCloseButton","hasCloseButton","_ref$spacing","spacing","id","_ref$isSubMenu","isSubMenu","_ref$actionState","actionState","actionType","isOpen","_ref$position","position","_ref$point","point","_ref$portalProps","portalProps","PORTAL_LAYERS","POPOVER","name","_ref$kind","kind","offset","onClose","onOpen","eventId","triggerRef","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_React$useState2","_slicedToArray","state","setState","trackInteraction","useMrlTrackInteraction","wasOpenRef","useRef","useEffect","current","action","metadata","variant","_React$useState3","_React$useState4","interactiveElements","setInteractiveElements","_React$useState5","_React$useState6","menuRect","setMenuRect","menuRef","triggerExpandedRestoreRef","isTriggerDisabled","useCallback","isElementAriaDisabled","closeMenu","_useMrlPopoverEventHa","useMrlPopoverEventHandlers","handleClose","handleMenuKey","hideMenuHover","handleTriggerSiblingKey","toggleMenuKey","toggleMenuTrigger","showMenuHover","useClickOutside","useLayoutEffect","_menuRef$current","newRect","getBoundingClientRect","elements","getFocusableElementsInsideElement","focus","triggerElement","menuElement","nextElement","findAdjacentInteractiveElement","addEventListener","e","stopPropagation","removeEventListener","preventDefault","el","previousValue","getAttribute","setAttribute","removeAttribute","value","hasAttribute","toString","_document","_document$documentEle","snap","document","documentElement","contains","memoizedCustomPosition","useMemo","customPopoverPosition","left","top","menuPosition","useTriggerPosition","align","getOffset","subMenuPosition","useSubMenuElementPosition","menuPositionState","flipped","flipPosition","scrollStyles","useBrowserEdgeScroll","inlineStyles","menu","submenu","transitions","useTransition","config","duration","enter","opacity","transform","from","leave","menuClasses","classnames","styles","positionStyles","renderMenu","inlineScrollStyles","scrollClasses","createElement","Fragment","style","item","MrlFocusTrap","disabled","containerRef","animated","div","_extends","tabIndex","_objectSpread","onKeyDown","ref","MrlPopoverScrollContainer","MrlIconButton","wrapperClassName","icon","MrlSvg","svg","close","text","tipAnchor","onMouseUp","size","getDataPoint","MrlPopoverContext","Provider","MrlPortal","layer","component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AAAA,SAAS,EAAEnG,SAAU;AACrBwF,MAAAA,SAAS,EAAErF,WAAY;AACvBiG,MAAAA,IAAI,EAAC;AAAO,KACZ,CACD,EACAjJ,KAAK,iBACLiB,KAAA,CAAAwG,aAAA,CAAA,KAAA,EAAA;AACCjJ,MAAAA,SAAS,EAAE4I,MAAM,CAAC,mBAAmB,CAAE;AACvC,MAAA,YAAA,EAAY8B,YAAY,CAACjD,iBAAiB,EAAE7H,SAAS;AAAE,KACvD,CAEwB,CACd,CACD,CAEjB,CACC,CAAC;EAEL,CAAC;;AAED;AACA,EAAA,oBACC6C,KAAA,CAAAwG,aAAA,CAAC0B,iBAAiB,CAACC,QAAQ,EAAA;AAC1BvE,IAAAA,KAAK,EAAE;AACNhC,MAAAA;AACD;AAAE,GAAA,EAEDrD,SAAS,GACT8H,UAAU,EAAE,gBAEZrG,KAAA,CAAAwG,aAAA,CAAC4B,SAAS,EAAAnB,QAAA,CAAA;AAACoB,IAAAA,KAAK,EAAEpJ,WAAW,CAACoJ,KAAK,IAAInJ,aAAa,CAACC;AAAQ,GAAA,EAAKF,WAAW,CAAA,EAC3EoH,UAAU,EACD,CAEe,CAAC;AAE9B;AACD;AAEArJ,UAAU,CAACsL,aAAa,GAAG,SAAS;;;;"}
1
+ {"version":3,"file":"MrlPopover.js","sources":["../../../../../src/components/popover/MrlPopover/MrlPopover.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { close } from '@muraldevkit/ds-icons';\nimport { MrlIconButton } from '../../button/MrlIconButton/MrlIconButton';\nimport { MrlFocusTrap } from '../../focus-trap/MrlFocusTrap/MrlFocusTrap';\nimport { MrlPortal, PortalProps } from '../../portal/MrlPortal';\nimport { MrlSvg } from '../../svg/MrlSvg/MrlSvg';\nimport { useTriggerPosition } from '../../../hooks/useTriggerPosition';\nimport { useBrowserEdgeScroll } from '../../menu/hooks/useBrowserEdgeScroll';\nimport { useClickOutside } from '../../../hooks/useClickOutside';\nimport { useSubMenuElementPosition } from '../../menu/hooks/useSubMenuElementPosition';\nimport { MenuPosition, MenuAlignment, ActionState, CustomMenuPosition } from '../../menu/constants';\nimport {\n\tpreventDefault,\n\tgetFocusableElementsInsideElement,\n\tfindAdjacentInteractiveElement,\n\tisElementAriaDisabled\n} from '../../../utils';\nimport { PORTAL_LAYERS } from '../../../utils/layers';\nimport { useTransition, animated } from '@react-spring/web';\nimport { SELECT_MENU_LIST_CLASS_NAME } from '../../form/select/MrlSelect/MrlSelect';\nimport { MULTI_SELECT_MENU_LIST_CLASS_NAME } from '../../form/select/MrlMultiSelect/MrlMultiSelect';\nimport styles from './MrlPopover.module.scss';\nimport { flipPosition } from '../../menu/utilities/flip-position';\nimport { getDataPoint } from './utilities/get-data-point';\nimport { getOffset } from './utilities/get-offset';\nimport { useMrlPopoverEventHandlers } from './hooks/use-mrl-popover-event-handlers';\nimport { MrlPopoverContext } from './context/MrlPopoverContext';\nimport { MrlPopoverScrollContainer } from './MrlPopoverScrollContainer';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nconst POPOVER_CLICKOUTSIDE_WHITELIST = [\n\t'#mrl-select-portal',\n\t'#mrl-popover-menu-portal',\n\t`.${SELECT_MENU_LIST_CLASS_NAME}`,\n\t`.${MULTI_SELECT_MENU_LIST_CLASS_NAME}`\n];\n\ntype RenderPropFn = ({ closeMenu }: { closeMenu: () => void }) => JSX.Element;\n\nexport interface MrlPopoverProps {\n\t/**\n\t * Set initial state of menu\n\t * @default { actionType: null, isOpen: false }\n\t */\n\tactionState?: ActionState;\n\n\t/** Label for the popover */\n\tariaLabel?: string;\n\n\t/** ID of element to associate a label */\n\tariaLabelledBy?: string;\n\n\t/** Children to be rendered within the menu component*/\n\tchildren: React.ReactNode | RenderPropFn;\n\n\t/** Custom class names for the popover */\n\tclassName?: string;\n\n\t/** Custom position for the menu */\n\tcustomPosition?: CustomMenuPosition;\n\n\t/**\n\t * If the popover should disable click to open\n\t *\n\t * Example usage: if you do not want your component opened via click, set to true\n\t */\n\tdisableClickToOpen?: boolean;\n\n\t/**\n\t * If the popover should close when clicking outside of the menu\n\t *\n\t * Example usage: MrlCallout component should not close when clicking outside, so it's set to true\n\t */\n\tdisableClickOutside?: boolean;\n\n\t/**\n\t * Disable flipping of the popover when it goes off the screen\n\t * @default false\n\t */\n\tdisableFlipping?: boolean;\n\n\t/**\n\t * If the popover should disable focus trap\n\t *\n\t * The impact of enabling or disabling focus trap:\n\t * - enabled : focus will remain trapped in the popover until a user closes the popover\n\t * - disabled : focus will move to the next interactive element in the DOM when the user\n\t * tabs out of the popover. Focus will move to the trigger when the user shift+tabs out of the popover\n\t *\n\t * Additional scenarios to consider with focus trap is disabled. When hasCloseButton is set to true/false:\n\t * - true : if a user shows the close button, the popover will stay open until explicitly dismissed\n\t * - false : if a user hides the close button, the popover will close when a user tabs out of it from the beginning or end\n\t */\n\tdisableFocusTrap?: boolean;\n\n\t/** If the popover should have a close button */\n\thasCloseButton?: boolean;\n\n\t/** Unique identifier for the menu */\n\tid?: string;\n\n\t/** If the menu is a submenu */\n\tisSubMenu?: boolean;\n\n\t/**\n\t * Horizontal and vertical alignment of the menu relative to the trigger element\n\t *\n\t * This does not impact submenus\n\t * @default 'bottom'\n\t */\n\tposition?: MenuPosition;\n\n\t/**\n\t * Alignment of the popover along the axis perpendicular to its position\n\t * - For position 'top'/'bottom': 'start' = left, 'end' = right, 'center' = center horizontally\n\t * - For position 'left'/'right': 'start' = top, 'end' = bottom, 'center' = center vertically\n\t *\n\t * @default 'center'\n\t *\n\t * This does not impact submenus\n\t */\n\talignment?: MenuAlignment;\n\n\t/**\n\t * spacing of menu\n\t * - 'default' has 16px padding\n\t * - 'compact' has 12px padding\n\t */\n\tspacing?: 'default' | 'compact';\n\n\t/**\n\t * Reference to the DOM element that triggers this menu.\n\t */\n\ttriggerRef?: React.RefObject<HTMLElement>;\n\n\t/**\n\t * If the menu should be rendered with the inverse theme\n\t * @default 'primary'\n\t */\n\tkind?: 'primary' | 'inverse';\n\n\t/**\n\t * If the menu should have a pointer element\n\t * @default false\n\t */\n\tpoint?: boolean;\n\n\t/**\n\t * Configuration for the portal component\n\t */\n\tportalProps?: Omit<PortalProps, 'children'>;\n\n\t/**\n\t * Offset in pixels for the popover\n\t *\n\t * The popover automatically calculates the proper offset based on the position and alignment\n\t * this prop will override those values.\n\t */\n\toffset?: number;\n\n\t/**\n\t * Callback to be called when the menu is opened\n\t */\n\tonOpen?: () => void;\n\n\t/**\n\t * Callback to be called when the menu is closed\n\t * @param type - type of close event\n\t */\n\tonClose?: (type?: string) => void;\n\n\t/**\n\t * data-qa attribute for the popover\n\t */\n\t['data-qa']?: string;\n\n\t/**\n\t * Enables interaction tracking for this popover. Provide a stable, non-PII id\n\t * (e.g. 'sticky-note-color-picker'). When omitted, the popover emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * MrlPopover\n *\n * Renders a popover component with position and alignment relative to a trigger element\n * @param {MrlPopoverProps} props - The props for the MrlPopover component\n * @returns {Element} - rendered MrlPopover component\n */\nexport function MrlPopover({\n\talignment = 'center',\n\tariaLabel,\n\tariaLabelledBy,\n\tchildren,\n\tclassName,\n\tcustomPosition,\n\tdisableClickToOpen = false,\n\tdisableClickOutside = false,\n\tdisableFlipping = false,\n\tdisableFocusTrap = false,\n\thasCloseButton = false,\n\tspacing = 'default',\n\tid,\n\tisSubMenu = false,\n\tactionState = { actionType: null, isOpen: false },\n\tposition = 'bottom',\n\tpoint = true,\n\tportalProps = { id: PORTAL_LAYERS.POPOVER.name },\n\tkind = 'primary',\n\toffset,\n\tonClose,\n\tonOpen,\n\teventId,\n\ttriggerRef,\n\t...rest\n}: MrlPopoverProps): JSX.Element {\n\tconst [state, setState] = React.useState({\n\t\tactionType: null,\n\t\tisOpen: actionState.isOpen || false\n\t} as ActionState);\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlPopover', eventId);\n\t// the popover opens and closes from several paths (trigger click, keyboard, click\n\t// outside, close button), so open/close is emitted from the resulting state.\n\tconst wasOpenRef = React.useRef(actionState.isOpen || false);\n\n\tReact.useEffect(() => {\n\t\tif (wasOpenRef.current === state.isOpen) return;\n\n\t\twasOpenRef.current = state.isOpen;\n\n\t\ttrackInteraction({\n\t\t\taction: state.isOpen ? 'open' : 'close',\n\t\t\tmetadata: { isSubMenu },\n\t\t\tvariant: position\n\t\t});\n\t}, [state.isOpen, isSubMenu, position, trackInteraction]);\n\n\t// stores all of the interactive elements in the popover for focus management\n\tconst [interactiveElements, setInteractiveElements] = React.useState<HTMLElement[]>([]);\n\tconst [menuRect, setMenuRect] = React.useState<DOMRect | null>(null);\n\tconst menuRef = React.useRef<HTMLDivElement>(null);\n\t/** Snapshot of trigger `aria-expanded` before we manage it; restored on popover unmount only. */\n\tconst triggerExpandedRestoreRef = React.useRef<{\n\t\tel: HTMLElement;\n\t\tvalue: string | null;\n\t} | null>(null);\n\n\t/**\n\t * Checks if the trigger element is disabled\n\t * @returns {boolean} - true if the trigger element is disabled, false otherwise\n\t */\n\tconst isTriggerDisabled = React.useCallback((): boolean => {\n\t\treturn isElementAriaDisabled(triggerRef?.current);\n\t}, [triggerRef]);\n\n\t/**\n\t * Opening and closing the menu\n\t */\n\tconst closeMenu = React.useCallback(() => {\n\t\tsetState({ actionType: null, isOpen: false });\n\t\tonClose?.();\n\t}, [onClose]);\n\n\tconst {\n\t\thandleClose,\n\t\thandleMenuKey,\n\t\thideMenuHover,\n\t\thandleTriggerSiblingKey,\n\t\ttoggleMenuKey,\n\t\ttoggleMenuTrigger,\n\t\tshowMenuHover\n\t} = useMrlPopoverEventHandlers({\n\t\tcloseMenu,\n\t\tdisableClickToOpen,\n\t\tdisableFocusTrap,\n\t\thasCloseButton,\n\t\tinteractiveElements,\n\t\tisSubMenu,\n\t\tisTriggerDisabled,\n\t\tmenuRef,\n\t\tsetState,\n\t\tstate,\n\t\ttriggerRef\n\t});\n\n\tuseClickOutside(\n\t\tmenuRef,\n\t\ttriggerRef,\n\t\t'mouseup',\n\t\tcloseMenu,\n\t\tdisableClickOutside || !state.isOpen,\n\t\tPOPOVER_CLICKOUTSIDE_WHITELIST\n\t);\n\n\tReact.useEffect(() => {\n\t\tif (isTriggerDisabled()) return;\n\n\t\tif (!isSubMenu) {\n\t\t\tsetState({ actionType: actionState.actionType, isOpen: actionState.isOpen });\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [isSubMenu, actionState.actionType, actionState.isOpen]);\n\n\t// This use effect handles storing the rect in state for positioning calculations\n\tReact.useLayoutEffect(() => {\n\t\tif (!state.isOpen) return;\n\n\t\t// For consistent calculations, we are storing the menu rect in state\n\t\t// Anytime we need to use the menu rect, we want to make sure the values are based\n\t\t// on the original state of the menu for proper transformations\n\t\tif (!menuRect && menuRef.current) {\n\t\t\tconst newRect = menuRef.current?.getBoundingClientRect();\n\t\t\tsetMenuRect(newRect || null);\n\t\t}\n\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [state.isOpen, isSubMenu]);\n\n\t// This use effect handles getting and setting the interactive elements in the popover.\n\t// These elements are used for focus management when focus trap is not enabled to ensure\n\t// that our tab order matches the visual order of the page\n\tReact.useEffect(() => {\n\t\tif (state.isOpen && !isSubMenu && menuRef.current) {\n\t\t\tif (disableFocusTrap) {\n\t\t\t\t// set the interactive elements so we can track focus location\n\t\t\t\tconst elements = getFocusableElementsInsideElement(menuRef.current as HTMLElement);\n\t\t\t\tsetInteractiveElements(elements);\n\n\t\t\t\t// without focus trap enabled, we want to focus the first interactive element\n\t\t\t\telements[0].focus();\n\t\t\t}\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [state.isOpen, menuRef.current]);\n\n\t// This use effect handles setting all of the event handlers for different parts of the component.\n\t// - trigger event handlers\n\t// - submenu event handlers\n\t// - menu event handlers\n\t// - \"next element\" event handlers, which are event handlers attached to the next interactive element after the trigger\n\t//\n\tReact.useEffect(() => {\n\t\tconst triggerElement = triggerRef?.current;\n\t\tconst menuElement = menuRef?.current;\n\t\tconst nextElement = findAdjacentInteractiveElement(triggerRef, 'next');\n\n\t\tif (triggerElement) {\n\t\t\ttriggerElement.addEventListener('mousedown', (e) => e.stopPropagation());\n\t\t\ttriggerElement.addEventListener('click', toggleMenuTrigger);\n\t\t\ttriggerElement.addEventListener('keydown', toggleMenuKey);\n\n\t\t\tif (nextElement) nextElement.addEventListener('keydown', handleTriggerSiblingKey);\n\n\t\t\t// Setup event listeners for when the menu is a submenu\n\t\t\tif (isSubMenu) {\n\t\t\t\tconst menuElement = menuRef?.current;\n\n\t\t\t\ttriggerElement.addEventListener('mouseover', showMenuHover);\n\t\t\t\ttriggerElement.addEventListener('mouseout', hideMenuHover);\n\n\t\t\t\tif (menuElement) {\n\t\t\t\t\tmenuElement.addEventListener('mouseover', showMenuHover);\n\t\t\t\t\tmenuElement.addEventListener('mouseout', hideMenuHover);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\ttriggerElement.removeEventListener('mousedown', preventDefault);\n\t\t\t\ttriggerElement.removeEventListener('click', toggleMenuTrigger);\n\t\t\t\ttriggerElement.removeEventListener('keydown', toggleMenuKey);\n\n\t\t\t\tif (nextElement) nextElement.removeEventListener('keydown', handleTriggerSiblingKey);\n\n\t\t\t\tif (isSubMenu) {\n\t\t\t\t\ttriggerElement.removeEventListener('mouseover', showMenuHover);\n\t\t\t\t\ttriggerElement.removeEventListener('mouseout', hideMenuHover);\n\n\t\t\t\t\tif (menuElement) {\n\t\t\t\t\t\tmenuElement.removeEventListener('mouseover', showMenuHover);\n\t\t\t\t\t\tmenuElement.removeEventListener('mouseout', hideMenuHover);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [\n\t\tcloseMenu,\n\t\tisSubMenu,\n\t\ttoggleMenuKey,\n\t\ttoggleMenuTrigger,\n\t\ttriggerRef?.current,\n\t\thideMenuHover,\n\t\tshowMenuHover,\n\t\thasCloseButton,\n\t\thandleClose\n\t]);\n\n\t/**\n\t * Popover triggers are not necessarily modal dialogs; use the generic 'true' (see ARIA in HTML).\n\t * Restore the previous DOM value when the trigger changes or this popover unmounts so host-owned\n\t * ARIA (e.g. aria-haspopup=\"menu\") is not left stale after a callout dismisses.\n\t */\n\tReact.useEffect(() => {\n\t\tconst el = triggerRef?.current;\n\t\tif (!el) return;\n\n\t\tconst previousValue = el.getAttribute('aria-haspopup');\n\t\tel.setAttribute('aria-haspopup', 'true');\n\n\t\t// Restore the previous value of the aria-haspopup attribute when the callout is removed from the DOM\n\t\treturn () => {\n\t\t\tif (previousValue === null) {\n\t\t\t\tel.removeAttribute('aria-haspopup');\n\t\t\t} else {\n\t\t\t\tel.setAttribute('aria-haspopup', previousValue);\n\t\t\t}\n\t\t};\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [triggerRef?.current]);\n\n\tReact.useEffect(() => {\n\t\tconst el = triggerRef?.current;\n\t\tif (!el) return;\n\n\t\t// Store the previous value of the aria-expanded attribute when the callout is added to the DOM\n\t\tif (!triggerExpandedRestoreRef.current || triggerExpandedRestoreRef.current.el !== el) {\n\t\t\ttriggerExpandedRestoreRef.current = {\n\t\t\t\tel,\n\t\t\t\tvalue: el.hasAttribute('aria-expanded') ? el.getAttribute('aria-expanded') : null\n\t\t\t};\n\t\t}\n\n\t\t// Set the aria-expanded attribute to the current state of the popover\n\t\tel.setAttribute('aria-expanded', state.isOpen.toString());\n\n\t\tif (state.isOpen) onOpen?.();\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [state.isOpen, onOpen, triggerRef?.current]);\n\n\t/**\n\t * Restore the previous value of the aria-expanded attribute when the callout is removed from the DOM\n\t */\n\tReact.useEffect(() => {\n\t\treturn () => {\n\t\t\tconst snap = triggerExpandedRestoreRef.current;\n\t\t\tif (!snap) return;\n\t\t\tconst { el, value } = snap;\n\n\t\t\tif (!document?.documentElement?.contains(el)) return;\n\n\t\t\tif (value === null) {\n\t\t\t\tel.removeAttribute('aria-expanded');\n\t\t\t} else {\n\t\t\t\tel.setAttribute('aria-expanded', value);\n\t\t\t}\n\t\t};\n\t}, []);\n\n\t/**\n\t * Setup positioning styles, submenu positioning styles, scroll styles, and transition.\n\t */\n\tconst memoizedCustomPosition = React.useMemo(() => customPosition, [customPosition]);\n\tconst customPopoverPosition = memoizedCustomPosition || { left: 0, top: 0 };\n\n\tconst menuPosition = useTriggerPosition(\n\t\ttriggerRef,\n\t\tmenuRef,\n\t\t{\n\t\t\talign: alignment,\n\t\t\tcustomPosition: customPopoverPosition,\n\t\t\tposition: position\n\t\t},\n\t\tstate.isOpen,\n\t\toffset || getOffset(position, point),\n\t\tisSubMenu,\n\t\tdisableFlipping\n\t);\n\n\tconst isAwaitingPosition = !isSubMenu && !menuPosition.isPositioned;\n\tconst hideUntilPositionedStyles = isAwaitingPosition\n\t\t? { opacity: 0, pointerEvents: 'none' as const }\n\t\t: undefined;\n\n\tconst subMenuPosition = useSubMenuElementPosition(\n\t\ttriggerRef,\n\t\tmenuRef,\n\t\tisSubMenu,\n\t\tstate.isOpen,\n\t\tmenuRect,\n\t\t!isSubMenu\n\t);\n\n\tconst menuPositionState = menuPosition.flipped ? flipPosition(position) : position;\n\tconst scrollStyles = useBrowserEdgeScroll(menuRef, menuPositionState, alignment);\n\n\tconst inlineStyles = {\n\t\tmenu: {\n\t\t\tleft: menuPosition.left,\n\t\t\tposition: 'fixed' as const,\n\t\t\ttop: menuPosition.top\n\t\t},\n\t\tsubmenu: {\n\t\t\tleft: subMenuPosition.left,\n\t\t\ttop: subMenuPosition.top\n\t\t}\n\t};\n\n\t/**\n\t * React Spring transitions for the menu\n\t */\n\tconst transitions = useTransition(state.isOpen, {\n\t\tconfig: { duration: 150 },\n\t\tenter: { opacity: 1, transform: 'translateY(0)' },\n\t\tfrom: { opacity: 0, transform: 'translateY(4px)' },\n\t\tleave: { opacity: 0, transform: 'translateY(4px)' }\n\t});\n\n\tconst menuClasses = classnames(\n\t\tstyles['MrlPopover'],\n\t\t'MrlPopover',\n\t\tstyles['MrlPopover--scrolling'],\n\t\tclassName,\n\t\t{\n\t\t\t[styles['MrlPopover--submenu']]: isSubMenu,\n\t\t\t[styles['inverse']]: kind === 'inverse',\n\t\t\t[styles['primary']]: kind === 'primary',\n\t\t\t[styles['compact']]: spacing === 'compact',\n\t\t\t[styles['default']]: spacing === 'default'\n\t\t}\n\t);\n\n\tconst positionStyles = isSubMenu ? inlineStyles.submenu : inlineStyles.menu;\n\n\tconst renderMenu = () => {\n\t\tconst inlineScrollStyles = isSubMenu ? {} : scrollStyles ? scrollStyles.styles : {};\n\t\tconst scrollClasses = classnames(\n\t\t\tstyles['MrlPopover--content'],\n\t\t\tstyles['MrlPopover--scrolling--content']\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{transitions(\n\t\t\t\t\t(style, item) =>\n\t\t\t\t\t\titem && (\n\t\t\t\t\t\t\t<MrlFocusTrap disabled={disableFocusTrap} containerRef={menuRef}>\n\t\t\t\t\t\t\t\t<animated.div\n\t\t\t\t\t\t\t\t\taria-label={ariaLabel}\n\t\t\t\t\t\t\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\t\t\t\t\t\t\tclassName={menuClasses}\n\t\t\t\t\t\t\t\t\tid={id}\n\t\t\t\t\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\t\t\t\t\tstyle={{ ...positionStyles, ...style, ...hideUntilPositionedStyles }}\n\t\t\t\t\t\t\t\t\tonKeyDown={handleMenuKey}\n\t\t\t\t\t\t\t\t\tref={menuRef}\n\t\t\t\t\t\t\t\t\t{...rest}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<MrlPopoverScrollContainer className={scrollClasses} style={inlineScrollStyles}>\n\t\t\t\t\t\t\t\t\t\t{typeof children === 'function' && children({ closeMenu })}\n\t\t\t\t\t\t\t\t\t\t{typeof children !== 'function' && children}\n\t\t\t\t\t\t\t\t\t\t{hasCloseButton && (\n\t\t\t\t\t\t\t\t\t\t\t<MrlIconButton\n\t\t\t\t\t\t\t\t\t\t\t\tdata-qa=\"popover-close-button\"\n\t\t\t\t\t\t\t\t\t\t\t\twrapperClassName={styles['MrlPopover--close']}\n\t\t\t\t\t\t\t\t\t\t\t\ticon={<MrlSvg svg={close} />}\n\t\t\t\t\t\t\t\t\t\t\t\tkind={kind === 'inverse' ? 'ghost-inverse' : 'ghost'}\n\t\t\t\t\t\t\t\t\t\t\t\ttext=\"Close\"\n\t\t\t\t\t\t\t\t\t\t\t\tstate=\"default\"\n\t\t\t\t\t\t\t\t\t\t\t\tposition=\"right\"\n\t\t\t\t\t\t\t\t\t\t\t\ttipAnchor=\"center\"\n\t\t\t\t\t\t\t\t\t\t\t\tonMouseUp={closeMenu}\n\t\t\t\t\t\t\t\t\t\t\t\tonKeyDown={handleClose}\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t{point && (\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tclassName={styles['MrlPopover--point']}\n\t\t\t\t\t\t\t\t\t\t\t\tdata-point={getDataPoint(menuPositionState, alignment)}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t</MrlPopoverScrollContainer>\n\t\t\t\t\t\t\t\t</animated.div>\n\t\t\t\t\t\t\t</MrlFocusTrap>\n\t\t\t\t\t\t)\n\t\t\t\t)}\n\t\t\t</>\n\t\t);\n\t};\n\n\t/* eslint-disable */\n\treturn (\n\t\t<MrlPopoverContext.Provider\n\t\t\tvalue={{\n\t\t\t\tcloseMenu\n\t\t\t}}\n\t\t>\n\t\t\t{isSubMenu ? (\n\t\t\t\trenderMenu()\n\t\t\t) : (\n\t\t\t\t<MrlPortal layer={portalProps.layer || PORTAL_LAYERS.POPOVER} {...portalProps}>\n\t\t\t\t\t{renderMenu()}\n\t\t\t\t</MrlPortal>\n\t\t\t)}\n\t\t</MrlPopoverContext.Provider>\n\t);\n\t/* eslint-enable */\n}\n\nMrlPopover.componentType = 'Popover';\n"],"names":["POPOVER_CLICKOUTSIDE_WHITELIST","concat","SELECT_MENU_LIST_CLASS_NAME","MULTI_SELECT_MENU_LIST_CLASS_NAME","MrlPopover","_ref","_ref$alignment","alignment","ariaLabel","ariaLabelledBy","children","className","customPosition","_ref$disableClickToOp","disableClickToOpen","_ref$disableClickOuts","disableClickOutside","_ref$disableFlipping","disableFlipping","_ref$disableFocusTrap","disableFocusTrap","_ref$hasCloseButton","hasCloseButton","_ref$spacing","spacing","id","_ref$isSubMenu","isSubMenu","_ref$actionState","actionState","actionType","isOpen","_ref$position","position","_ref$point","point","_ref$portalProps","portalProps","PORTAL_LAYERS","POPOVER","name","_ref$kind","kind","offset","onClose","onOpen","eventId","triggerRef","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_React$useState2","_slicedToArray","state","setState","trackInteraction","useMrlTrackInteraction","wasOpenRef","useRef","useEffect","current","action","metadata","variant","_React$useState3","_React$useState4","interactiveElements","setInteractiveElements","_React$useState5","_React$useState6","menuRect","setMenuRect","menuRef","triggerExpandedRestoreRef","isTriggerDisabled","useCallback","isElementAriaDisabled","closeMenu","_useMrlPopoverEventHa","useMrlPopoverEventHandlers","handleClose","handleMenuKey","hideMenuHover","handleTriggerSiblingKey","toggleMenuKey","toggleMenuTrigger","showMenuHover","useClickOutside","useLayoutEffect","_menuRef$current","newRect","getBoundingClientRect","elements","getFocusableElementsInsideElement","focus","triggerElement","menuElement","nextElement","findAdjacentInteractiveElement","addEventListener","e","stopPropagation","removeEventListener","preventDefault","el","previousValue","getAttribute","setAttribute","removeAttribute","value","hasAttribute","toString","_document","_document$documentEle","snap","document","documentElement","contains","memoizedCustomPosition","useMemo","customPopoverPosition","left","top","menuPosition","useTriggerPosition","align","getOffset","isAwaitingPosition","isPositioned","hideUntilPositionedStyles","opacity","pointerEvents","undefined","subMenuPosition","useSubMenuElementPosition","menuPositionState","flipped","flipPosition","scrollStyles","useBrowserEdgeScroll","inlineStyles","menu","submenu","transitions","useTransition","config","duration","enter","transform","from","leave","menuClasses","classnames","styles","positionStyles","renderMenu","inlineScrollStyles","scrollClasses","createElement","Fragment","style","item","MrlFocusTrap","disabled","containerRef","animated","div","_extends","tabIndex","_objectSpread","onKeyDown","ref","MrlPopoverScrollContainer","MrlIconButton","wrapperClassName","icon","MrlSvg","svg","close","text","tipAnchor","onMouseUp","size","getDataPoint","MrlPopoverContext","Provider","MrlPortal","layer","componentType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAMA,8BAA8B,GAAG,CACtC,oBAAoB,EACpB,0BAA0B,EAAA,GAAA,CAAAC,MAAA,CACtBC,2BAA2B,CAAA,EAAA,GAAA,CAAAD,MAAA,CAC3BE,iCAAiC,CAAA,CACrC;AAoJD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,UAAUA,CAAAC,IAAA,EA0BO;AAAA,EAAA,IAAAC,cAAA,GAAAD,IAAA,CAzBhCE,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAA,MAAA,GAAG,QAAQ,GAAAA,cAAA;IACpBE,SAAS,GAAAH,IAAA,CAATG,SAAS;IACTC,cAAc,GAAAJ,IAAA,CAAdI,cAAc;IACdC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IACRC,SAAS,GAAAN,IAAA,CAATM,SAAS;IACTC,cAAc,GAAAP,IAAA,CAAdO,cAAc;IAAAC,qBAAA,GAAAR,IAAA,CACdS,kBAAkB;AAAlBA,IAAAA,kBAAkB,GAAAD,qBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,qBAAA;IAAAE,qBAAA,GAAAV,IAAA,CAC1BW,mBAAmB;AAAnBA,IAAAA,mBAAmB,GAAAD,qBAAA,KAAA,MAAA,GAAG,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,aAAA,CAAC4B,SAAS,EAAAnB,QAAA,CAAA;AAACoB,IAAAA,KAAK,EAAEzJ,WAAW,CAACyJ,KAAK,IAAIxJ,aAAa,CAACC;AAAQ,GAAA,EAAKF,WAAW,CAAA,EAC3EyH,UAAU,EACD,CAEe,CAAC;AAE9B;AACD;AAEA1J,UAAU,CAAC2L,aAAa,GAAG,SAAS;;;;"}
@@ -1,5 +1,5 @@
1
- import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
- import { useState, useMemo, useCallback, useEffect, useLayoutEffect } from 'react';
1
+ import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { useState, useRef, useMemo, useCallback, useEffect, useLayoutEffect } from 'react';
3
3
  import { getPosition } from './utilities.js';
4
4
  import debounce from 'lodash.debounce';
5
5
 
@@ -15,7 +15,7 @@ import debounce from 'lodash.debounce';
15
15
  * @param menuOffset - The offset of the menu from the trigger element.
16
16
  * @param disable - Whether to disable the hook.
17
17
  * @param disableFlipping - Whether to disable flipping logic when the menu overflows the screen.
18
- * @returns {Position} The calculated position of the menu element.
18
+ * @returns {TriggerPosition} The calculated position of the menu element and whether it has been calculated yet.
19
19
  */
20
20
  var useTriggerPosition = function useTriggerPosition(triggerRef, elementRef, menuAlign) {
21
21
  var isElementVisible = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
@@ -34,6 +34,16 @@ var useTriggerPosition = function useTriggerPosition(triggerRef, elementRef, men
34
34
  menuPosition = _useState2[0],
35
35
  setMenuPosition = _useState2[1];
36
36
 
37
+ // The first position is calculated in a requestAnimationFrame, after the element has
38
+ // already rendered. Consumers can use this flag to hide the element until then.
39
+ var _useState3 = useState(false),
40
+ _useState4 = _slicedToArray(_useState3, 2),
41
+ isPositioned = _useState4[0],
42
+ setIsPositioned = _useState4[1];
43
+
44
+ // Read inside requestAnimationFrame callbacks, which can run after the element was hidden
45
+ var isVisibleRef = useRef(isElementVisible);
46
+
37
47
  // Memoize alignment so it only recalculates when specific props change
38
48
  var alignment = useMemo(() => ({
39
49
  align: menuAlign.align,
@@ -52,6 +62,10 @@ var useTriggerPosition = function useTriggerPosition(triggerRef, elementRef, men
52
62
  var triggerRect = triggerRef === null || triggerRef === void 0 ? void 0 : (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.getBoundingClientRect();
53
63
  var elementRect = (_elementRef$current = elementRef.current) === null || _elementRef$current === void 0 ? void 0 : _elementRef$current.getBoundingClientRect();
54
64
 
65
+ // Set before the size check so the element is never hidden indefinitely
66
+ // (e.g. environments without layout, where every rect is empty)
67
+ if (isVisibleRef.current) setIsPositioned(true);
68
+
55
69
  // Don't update if the element is not visible/rendered
56
70
  if (!elementRect || elementRect.height === 0 || elementRect.width === 0) return;
57
71
  var newPosition = getPosition(alignment, offset, elementRect, triggerRect, disableFlipping);
@@ -137,7 +151,18 @@ var useTriggerPosition = function useTriggerPosition(triggerRef, elementRef, men
137
151
  requestAnimationFrame(updatePosition);
138
152
  }
139
153
  }, [isElementVisible, updatePosition, disable, elementRef, triggerRef]);
140
- return menuPosition;
154
+
155
+ /**
156
+ * Resets isPositioned when the element is hidden, so the next time it is shown
157
+ * it is not reported as positioned until a fresh calculation has run.
158
+ */
159
+ useLayoutEffect(() => {
160
+ isVisibleRef.current = isElementVisible;
161
+ if (!isElementVisible) setIsPositioned(false);
162
+ }, [isElementVisible]);
163
+ return useMemo(() => _objectSpread2(_objectSpread2({}, menuPosition), {}, {
164
+ isPositioned
165
+ }), [menuPosition, isPositioned]);
141
166
  };
142
167
 
143
168
  export { useTriggerPosition };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/hooks/useTriggerPosition/index.tsx"],"sourcesContent":["import { useMemo, useState, RefObject, useEffect, useCallback, useLayoutEffect } from 'react';\nimport { Alignment, Position } from './constants';\nimport { getPosition } from './utilities';\nimport debounce from 'lodash.debounce';\n\n/**\n * useTriggerPosition hook.\n *\n * Calculates the position of a menu element based on the alignment settings relative to a trigger element.\n *\n * @param triggerRef - Reference to the DOM element that triggers the menu.\n * @param elementRef - Reference to the DOM element that is the menu.\n * @param menuAlign - The alignment configuration of the menu.\n * @param isElementVisible - Tells the hook if the element is visible. If false, the hook will not calculate the position.\n * @param menuOffset - The offset of the menu from the trigger element.\n * @param disable - Whether to disable the hook.\n * @param disableFlipping - Whether to disable flipping logic when the menu overflows the screen.\n * @returns {Position} The calculated position of the menu element.\n */\nexport const useTriggerPosition = (\n\ttriggerRef: RefObject<HTMLElement> | undefined,\n\telementRef: RefObject<HTMLElement>,\n\tmenuAlign: Alignment,\n\tisElementVisible: boolean = true,\n\tmenuOffset: number = 10,\n\tdisable = false,\n\tdisableFlipping = false\n): Position => {\n\tconst offset = menuOffset;\n\n\t// Holds the current calculated position of the menu\n\tconst [menuPosition, setMenuPosition] = useState<Position>({ flipped: false, left: 0, top: 0 });\n\n\t// Memoize alignment so it only recalculates when specific props change\n\tconst alignment = useMemo(\n\t\t() => ({\n\t\t\talign: menuAlign.align,\n\t\t\tcustomPosition: menuAlign.customPosition,\n\t\t\tposition: menuAlign.position\n\t\t}),\n\t\t[menuAlign.align, menuAlign.position, menuAlign.customPosition]\n\t);\n\n\t/**\n\t * Calculates and updates the menu position relative to the trigger.\n\t * Uses requestAnimationFrame to ensure layout is stable before measuring.\n\t */\n\tconst updatePosition = useCallback(() => {\n\t\tif (!elementRef.current || !isElementVisible) return;\n\n\t\trequestAnimationFrame(() => {\n\t\t\tconst triggerRect = triggerRef?.current?.getBoundingClientRect();\n\t\t\tconst elementRect = elementRef.current?.getBoundingClientRect();\n\n\t\t\t// Don't update if the element is not visible/rendered\n\t\t\tif (!elementRect || elementRect.height === 0 || elementRect.width === 0) return;\n\n\t\t\tconst newPosition = getPosition(alignment, offset, elementRect, triggerRect, disableFlipping);\n\n\t\t\t// Only update state if the position has changed\n\t\t\tsetMenuPosition((prevPosition) => {\n\t\t\t\tif (prevPosition.left !== newPosition.left || prevPosition.top !== newPosition.top) {\n\t\t\t\t\treturn newPosition;\n\t\t\t\t}\n\t\t\t\treturn prevPosition;\n\t\t\t});\n\t\t});\n\t}, [alignment, elementRef, isElementVisible, offset, triggerRef, disableFlipping]);\n\n\t/**\n\t * Debounced version of the updatePosition function used for scroll and resize events.\n\t * 5ms debounce gives a balance between performance and responsiveness.\n\t */\n\tconst debouncedUpdatePosition = useMemo(() => debounce(updatePosition, 5), [updatePosition]);\n\n\tuseEffect(() => {\n\t\tif (disable) return;\n\n\t\tconst currentElement = elementRef.current;\n\n\t\t/**\n\t\t * We need to debounce the resize observer to prevent \"resize loops\"\n\t\t * There are instances where the ResizeObserver will trigger a resize event\n\t\t * before the browser has painted, which causes a loop of resize events\n\t\t * and can throw errors or performance issues.\n\t\t *\n\t\t * The observers are purposefully using a different debounce than the event listeners.\n\t\t * Observers need to be more aggressively debounced to prevent loops,\n\t\t * while event listeners (resize/scroll) should update positioning more responsively.\n\t\t */\n\t\tconst resizeObserver = new ResizeObserver(debounce(updatePosition));\n\t\tconst mutationObserver = new MutationObserver(debounce(updatePosition));\n\n\t\t// Observe changes in size and style/className\n\t\tif (currentElement) {\n\t\t\tresizeObserver.observe(currentElement);\n\t\t\tmutationObserver.observe(currentElement, {\n\t\t\t\tattributeFilter: ['style', 'class'],\n\t\t\t\tattributes: true\n\t\t\t});\n\t\t}\n\n\t\t// Add listeners on open to respond to browser resizing and scrolling\n\t\tif (isElementVisible) {\n\t\t\tupdatePosition();\n\t\t\twindow.addEventListener('resize', debouncedUpdatePosition);\n\t\t\twindow.addEventListener('scroll', debouncedUpdatePosition);\n\t\t}\n\n\t\t// Cleanup observers and listeners on unmount or re-render\n\t\treturn () => {\n\t\t\tif (currentElement) {\n\t\t\t\tresizeObserver.unobserve(currentElement);\n\t\t\t\tmutationObserver.disconnect();\n\t\t\t}\n\t\t\twindow.removeEventListener('resize', debouncedUpdatePosition);\n\t\t\twindow.removeEventListener('scroll', debouncedUpdatePosition);\n\t\t};\n\t}, [\n\t\tdisable,\n\t\ttriggerRef,\n\t\telementRef,\n\t\talignment,\n\t\toffset,\n\t\tisElementVisible,\n\t\tupdatePosition,\n\t\tdebouncedUpdatePosition\n\t]);\n\n\t/**\n\t * This effect handles an edge case where the menu is rendered,\n\t * but its size is not immediately available in the first frame.\n\t * A short timeout ensures we recalculate the position once layout stabilizes.\n\t */\n\tuseEffect(() => {\n\t\tif (!disable && isElementVisible) {\n\t\t\tconst timeoutId = setTimeout(updatePosition, 10);\n\n\t\t\treturn () => clearTimeout(timeoutId);\n\t\t}\n\t}, [isElementVisible, disable, updatePosition]);\n\n\t/**\n\t * useLayoutEffect ensures the position is recalculated during the layout phase,\n\t * just after DOM mutations but before the browser paints.\n\t */\n\tuseLayoutEffect(() => {\n\t\tif (!disable && isElementVisible && elementRef.current && triggerRef?.current) {\n\t\t\tupdatePosition();\n\t\t\trequestAnimationFrame(updatePosition);\n\t\t}\n\t}, [isElementVisible, updatePosition, disable, elementRef, triggerRef]);\n\n\treturn menuPosition;\n};\n"],"names":["useTriggerPosition","triggerRef","elementRef","menuAlign","isElementVisible","arguments","length","undefined","menuOffset","disable","disableFlipping","offset","_useState","useState","flipped","left","top","_useState2","_slicedToArray","menuPosition","setMenuPosition","alignment","useMemo","align","customPosition","position","updatePosition","useCallback","current","requestAnimationFrame","_triggerRef$current","_elementRef$current","triggerRect","getBoundingClientRect","elementRect","height","width","newPosition","getPosition","prevPosition","debouncedUpdatePosition","debounce","useEffect","currentElement","resizeObserver","ResizeObserver","mutationObserver","MutationObserver","observe","attributeFilter","attributes","window","addEventListener","unobserve","disconnect","removeEventListener","timeoutId","setTimeout","clearTimeout","useLayoutEffect"],"mappings":";;;;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAkBA,CAC9BC,UAA8C,EAC9CC,UAAkC,EAClCC,SAAoB,EA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QAAQ,EAAEf,uBAAuB,CAAC;IAC9D,CAAC;AACF,EAAA,CAAC,EAAE,CACF/B,OAAO,EACPR,UAAU,EACVC,UAAU,EACVmB,SAAS,EACTV,MAAM,EACNP,gBAAgB,EAChBsB,cAAc,EACdc,uBAAuB,CACvB,CAAC;;AAEF;AACD;AACA;AACA;AACA;AACCE,EAAAA,SAAS,CAAC,MAAM;AACf,IAAA,IAAI,CAACjC,OAAO,IAAIL,gBAAgB,EAAE;AACjC,MAAA,IAAMoD,SAAS,GAAGC,UAAU,CAAC/B,cAAc,EAAE,EAAE,CAAC;AAEhD,MAAA,OAAO,MAAMgC,YAAY,CAACF,SAAS,CAAC;AACrC,IAAA;EACD,CAAC,EAAE,CAACpD,gBAAgB,EAAEK,OAAO,EAAEiB,cAAc,CAAC,CAAC;;AAE/C;AACD;AACA;AACA;AACCiC,EAAAA,eAAe,CAAC,MAAM;AACrB,IAAA,IAAI,CAAClD,OAAO,IAAIL,gBAAgB,IAAIF,UAAU,CAAC0B,OAAO,IAAI3B,UAAU,aAAVA,UAAU,KAAA,MAAA,IAAVA,UAAU,CAAE2B,OAAO,EAAE;AAC9EF,MAAAA,cAAc,EAAE;MAChBG,qBAAqB,CAACH,cAAc,CAAC;AACtC,IAAA;AACD,EAAA,CAAC,EAAE,CAACtB,gBAAgB,EAAEsB,cAAc,EAAEjB,OAAO,EAAEP,UAAU,EAAED,UAAU,CAAC,CAAC;AAEvE,EAAA,OAAOkB,YAAY;AACpB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/hooks/useTriggerPosition/index.tsx"],"sourcesContent":["import {\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tRefObject,\n\tuseEffect,\n\tuseCallback,\n\tuseLayoutEffect\n} from 'react';\nimport { Alignment, Position, TriggerPosition } from './constants';\nimport { getPosition } from './utilities';\nimport debounce from 'lodash.debounce';\n\n/**\n * useTriggerPosition hook.\n *\n * Calculates the position of a menu element based on the alignment settings relative to a trigger element.\n *\n * @param triggerRef - Reference to the DOM element that triggers the menu.\n * @param elementRef - Reference to the DOM element that is the menu.\n * @param menuAlign - The alignment configuration of the menu.\n * @param isElementVisible - Tells the hook if the element is visible. If false, the hook will not calculate the position.\n * @param menuOffset - The offset of the menu from the trigger element.\n * @param disable - Whether to disable the hook.\n * @param disableFlipping - Whether to disable flipping logic when the menu overflows the screen.\n * @returns {TriggerPosition} The calculated position of the menu element and whether it has been calculated yet.\n */\nexport const useTriggerPosition = (\n\ttriggerRef: RefObject<HTMLElement> | undefined,\n\telementRef: RefObject<HTMLElement>,\n\tmenuAlign: Alignment,\n\tisElementVisible: boolean = true,\n\tmenuOffset: number = 10,\n\tdisable = false,\n\tdisableFlipping = false\n): TriggerPosition => {\n\tconst offset = menuOffset;\n\n\t// Holds the current calculated position of the menu\n\tconst [menuPosition, setMenuPosition] = useState<Position>({ flipped: false, left: 0, top: 0 });\n\n\t// The first position is calculated in a requestAnimationFrame, after the element has\n\t// already rendered. Consumers can use this flag to hide the element until then.\n\tconst [isPositioned, setIsPositioned] = useState(false);\n\n\t// Read inside requestAnimationFrame callbacks, which can run after the element was hidden\n\tconst isVisibleRef = useRef(isElementVisible);\n\n\t// Memoize alignment so it only recalculates when specific props change\n\tconst alignment = useMemo(\n\t\t() => ({\n\t\t\talign: menuAlign.align,\n\t\t\tcustomPosition: menuAlign.customPosition,\n\t\t\tposition: menuAlign.position\n\t\t}),\n\t\t[menuAlign.align, menuAlign.position, menuAlign.customPosition]\n\t);\n\n\t/**\n\t * Calculates and updates the menu position relative to the trigger.\n\t * Uses requestAnimationFrame to ensure layout is stable before measuring.\n\t */\n\tconst updatePosition = useCallback(() => {\n\t\tif (!elementRef.current || !isElementVisible) return;\n\n\t\trequestAnimationFrame(() => {\n\t\t\tconst triggerRect = triggerRef?.current?.getBoundingClientRect();\n\t\t\tconst elementRect = elementRef.current?.getBoundingClientRect();\n\n\t\t\t// Set before the size check so the element is never hidden indefinitely\n\t\t\t// (e.g. environments without layout, where every rect is empty)\n\t\t\tif (isVisibleRef.current) setIsPositioned(true);\n\n\t\t\t// Don't update if the element is not visible/rendered\n\t\t\tif (!elementRect || elementRect.height === 0 || elementRect.width === 0) return;\n\n\t\t\tconst newPosition = getPosition(alignment, offset, elementRect, triggerRect, disableFlipping);\n\n\t\t\t// Only update state if the position has changed\n\t\t\tsetMenuPosition((prevPosition) => {\n\t\t\t\tif (prevPosition.left !== newPosition.left || prevPosition.top !== newPosition.top) {\n\t\t\t\t\treturn newPosition;\n\t\t\t\t}\n\t\t\t\treturn prevPosition;\n\t\t\t});\n\t\t});\n\t}, [alignment, elementRef, isElementVisible, offset, triggerRef, disableFlipping]);\n\n\t/**\n\t * Debounced version of the updatePosition function used for scroll and resize events.\n\t * 5ms debounce gives a balance between performance and responsiveness.\n\t */\n\tconst debouncedUpdatePosition = useMemo(() => debounce(updatePosition, 5), [updatePosition]);\n\n\tuseEffect(() => {\n\t\tif (disable) return;\n\n\t\tconst currentElement = elementRef.current;\n\n\t\t/**\n\t\t * We need to debounce the resize observer to prevent \"resize loops\"\n\t\t * There are instances where the ResizeObserver will trigger a resize event\n\t\t * before the browser has painted, which causes a loop of resize events\n\t\t * and can throw errors or performance issues.\n\t\t *\n\t\t * The observers are purposefully using a different debounce than the event listeners.\n\t\t * Observers need to be more aggressively debounced to prevent loops,\n\t\t * while event listeners (resize/scroll) should update positioning more responsively.\n\t\t */\n\t\tconst resizeObserver = new ResizeObserver(debounce(updatePosition));\n\t\tconst mutationObserver = new MutationObserver(debounce(updatePosition));\n\n\t\t// Observe changes in size and style/className\n\t\tif (currentElement) {\n\t\t\tresizeObserver.observe(currentElement);\n\t\t\tmutationObserver.observe(currentElement, {\n\t\t\t\tattributeFilter: ['style', 'class'],\n\t\t\t\tattributes: true\n\t\t\t});\n\t\t}\n\n\t\t// Add listeners on open to respond to browser resizing and scrolling\n\t\tif (isElementVisible) {\n\t\t\tupdatePosition();\n\t\t\twindow.addEventListener('resize', debouncedUpdatePosition);\n\t\t\twindow.addEventListener('scroll', debouncedUpdatePosition);\n\t\t}\n\n\t\t// Cleanup observers and listeners on unmount or re-render\n\t\treturn () => {\n\t\t\tif (currentElement) {\n\t\t\t\tresizeObserver.unobserve(currentElement);\n\t\t\t\tmutationObserver.disconnect();\n\t\t\t}\n\t\t\twindow.removeEventListener('resize', debouncedUpdatePosition);\n\t\t\twindow.removeEventListener('scroll', debouncedUpdatePosition);\n\t\t};\n\t}, [\n\t\tdisable,\n\t\ttriggerRef,\n\t\telementRef,\n\t\talignment,\n\t\toffset,\n\t\tisElementVisible,\n\t\tupdatePosition,\n\t\tdebouncedUpdatePosition\n\t]);\n\n\t/**\n\t * This effect handles an edge case where the menu is rendered,\n\t * but its size is not immediately available in the first frame.\n\t * A short timeout ensures we recalculate the position once layout stabilizes.\n\t */\n\tuseEffect(() => {\n\t\tif (!disable && isElementVisible) {\n\t\t\tconst timeoutId = setTimeout(updatePosition, 10);\n\n\t\t\treturn () => clearTimeout(timeoutId);\n\t\t}\n\t}, [isElementVisible, disable, updatePosition]);\n\n\t/**\n\t * useLayoutEffect ensures the position is recalculated during the layout phase,\n\t * just after DOM mutations but before the browser paints.\n\t */\n\tuseLayoutEffect(() => {\n\t\tif (!disable && isElementVisible && elementRef.current && triggerRef?.current) {\n\t\t\tupdatePosition();\n\t\t\trequestAnimationFrame(updatePosition);\n\t\t}\n\t}, [isElementVisible, updatePosition, disable, elementRef, triggerRef]);\n\n\t/**\n\t * Resets isPositioned when the element is hidden, so the next time it is shown\n\t * it is not reported as positioned until a fresh calculation has run.\n\t */\n\tuseLayoutEffect(() => {\n\t\tisVisibleRef.current = isElementVisible;\n\n\t\tif (!isElementVisible) setIsPositioned(false);\n\t}, [isElementVisible]);\n\n\treturn useMemo(() => ({ ...menuPosition, isPositioned }), [menuPosition, isPositioned]);\n};\n"],"names":["useTriggerPosition","triggerRef","elementRef","menuAlign","isElementVisible","arguments","length","undefined","menuOffset","disable","disableFlipping","offset","_useState","useState","flipped","left","top","_useState2","_slicedToArray","menuPosition","setMenuPosition","_useState3","_useState4","isPositioned","setIsPositioned","isVisibleRef","useRef","alignment","useMemo","align","customPosition","position","updatePosition","useCallback","current","requestAnimationFrame","_triggerRef$current","_elementRef$current","triggerRect","getBoundingClientRect","elementRect","height","width","newPosition","getPosition","prevPosition","debouncedUpdatePosition","debounce","useEffect","currentElement","resizeObserver","ResizeObserver","mutationObserver","MutationObserver","observe","attributeFilter","attributes","window","addEventListener","unobserve","disconnect","removeEventListener","timeoutId","setTimeout","clearTimeout","useLayoutEffect","_objectSpread"],"mappings":";;;;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAkBA,CAC9BC,UAA8C,EAC9CC,UAAkC,EAClCC,SAAoB,EAKC;AAAA,EAAA,IAJrBC,gBAAyB,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,IAAI;AAAA,EAAA,IAChCG,UAAkB,GAAAH,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE;AAAA,EAAA,IACvBI,OAAO,GAAAJ,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,KAAK;AAAA,EAAA,IACfK,eAAe,GAAAL,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,KAAK;EAEvB,IAAMM,MAAM,GAAGH,UAAU;;AAEzB;EACA,IAAAI,SAAA,GAAwCC,QAAQ,CAAW;AAAEC,MAAAA,OAAO,EAAE,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C,UAAU,CAAC/B,cAAc,EAAE,EAAE,CAAC;AAEhD,MAAA,OAAO,MAAMgC,YAAY,CAACF,SAAS,CAAC;AACrC,IAAA;EACD,CAAC,EAAE,CAAC1D,gBAAgB,EAAEK,OAAO,EAAEuB,cAAc,CAAC,CAAC;;AAE/C;AACD;AACA;AACA;AACCiC,EAAAA,eAAe,CAAC,MAAM;AACrB,IAAA,IAAI,CAACxD,OAAO,IAAIL,gBAAgB,IAAIF,UAAU,CAACgC,OAAO,IAAIjC,UAAU,aAAVA,UAAU,KAAA,MAAA,IAAVA,UAAU,CAAEiC,OAAO,EAAE;AAC9EF,MAAAA,cAAc,EAAE;MAChBG,qBAAqB,CAACH,cAAc,CAAC;AACtC,IAAA;AACD,EAAA,CAAC,EAAE,CAAC5B,gBAAgB,EAAE4B,cAAc,EAAEvB,OAAO,EAAEP,UAAU,EAAED,UAAU,CAAC,CAAC;;AAEvE;AACD;AACA;AACA;AACCgE,EAAAA,eAAe,CAAC,MAAM;IACrBxC,YAAY,CAACS,OAAO,GAAG9B,gBAAgB;AAEvC,IAAA,IAAI,CAACA,gBAAgB,EAAEoB,eAAe,CAAC,KAAK,CAAC;AAC9C,EAAA,CAAC,EAAE,CAACpB,gBAAgB,CAAC,CAAC;AAEtB,EAAA,OAAOwB,OAAO,CAAC,MAAAsC,cAAA,CAAAA,cAAA,KAAY/C,YAAY,CAAA,EAAA,EAAA,EAAA;AAAEI,IAAAA;AAAY,GAAA,CAAG,EAAE,CAACJ,YAAY,EAAEI,YAAY,CAAC,CAAC;AACxF;;;;"}
@@ -1,4 +1,4 @@
1
- var TOOLKIT_VERSION = "4.77.0";
1
+ var TOOLKIT_VERSION = "4.77.2-dev-kdxV.1";
2
2
 
3
3
  export { TOOLKIT_VERSION };
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.77.0\";"],"names":["TOOLKIT_VERSION"],"mappings":"AAAO,IAAMA,eAAe,GAAG;;;;"}
1
+ {"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.77.2-dev-kdxV.1\";"],"names":["TOOLKIT_VERSION"],"mappings":"AAAO,IAAMA,eAAe,GAAG;;;;"}
@@ -9,3 +9,7 @@ export interface Position {
9
9
  left: number;
10
10
  flipped: boolean;
11
11
  }
12
+ export interface TriggerPosition extends Position {
13
+ /** True once the position has been calculated for the current visible state */
14
+ isPositioned: boolean;
15
+ }
@@ -1,5 +1,5 @@
1
1
  import { RefObject } from 'react';
2
- import { Alignment, Position } from './constants';
2
+ import { Alignment, TriggerPosition } from './constants';
3
3
  /**
4
4
  * useTriggerPosition hook.
5
5
  *
@@ -12,6 +12,6 @@ import { Alignment, Position } from './constants';
12
12
  * @param menuOffset - The offset of the menu from the trigger element.
13
13
  * @param disable - Whether to disable the hook.
14
14
  * @param disableFlipping - Whether to disable flipping logic when the menu overflows the screen.
15
- * @returns {Position} The calculated position of the menu element.
15
+ * @returns {TriggerPosition} The calculated position of the menu element and whether it has been calculated yet.
16
16
  */
17
- export declare const useTriggerPosition: (triggerRef: RefObject<HTMLElement> | undefined, elementRef: RefObject<HTMLElement>, menuAlign: Alignment, isElementVisible?: boolean, menuOffset?: number, disable?: boolean, disableFlipping?: boolean) => Position;
17
+ export declare const useTriggerPosition: (triggerRef: RefObject<HTMLElement> | undefined, elementRef: RefObject<HTMLElement>, menuAlign: Alignment, isElementVisible?: boolean, menuOffset?: number, disable?: boolean, disableFlipping?: boolean) => TriggerPosition;
@@ -2,7 +2,11 @@ import * as React from 'react';
2
2
  import { AttrsObject } from '../../../../utils';
3
3
  import { LabelKind, LabelStates, StaticIconConfig } from '../../constants';
4
4
  interface MrlLabelProps extends React.HTMLAttributes<HTMLLabelElement> {
5
- /** Applies additional HTML attributes to the label element */
5
+ /**
6
+ * Applies additional HTML attributes to the label element
7
+ *
8
+ * @deprecated - use the regular HTML attributes instead.
9
+ */
6
10
  attrs?: AttrsObject;
7
11
  /** Informs the user of the form element's purpose */
8
12
  text: string;
@@ -32,6 +32,8 @@ export interface MrlLegacySelectProptypes extends React.HTMLAttributes<HTMLDivEl
32
32
  * When using in a framework wrapper (e.g., React), treat it as an object and don't stringify.
33
33
  * Otherwise, the value object needs to be stringified to not receive `"[Object object]"`.
34
34
  * Example: `attrs='{ "tabindex": "1" }'`
35
+ *
36
+ * @deprecated - use the regular HTML attributes instead.
35
37
  */
36
38
  attrs?: AttrsObject;
37
39
  /**
@@ -6,7 +6,11 @@ import { RightActionConfig, InputStates } from '../../constants';
6
6
  * @todo - we need to add static icon support for right
7
7
  */
8
8
  interface MrlTextInputProps extends Omit<MrlComponentProps, 'style'>, React.ComponentProps<'input'> {
9
- /** Applies additional HTML attributes to the text input element */
9
+ /**
10
+ * Applies additional HTML attributes to the text input element
11
+ *
12
+ * @deprecated - use the regular HTML attributes instead. `data-maxlength` is still read from `attrs` only.
13
+ */
10
14
  attrs?: AttrsObject;
11
15
  /** Additional function to be run when the input's value is cleared */
12
16
  hookClear?: () => void;
@@ -35,6 +35,8 @@ export interface MrlLinkProptypes extends React.ComponentProps<'a'> {
35
35
  /**
36
36
  * Applies additional HTML attributes to the nested anchor (`a`) element.
37
37
  * Example: `attrs='{ "aria-label": "Special message for screen reader users" }'`
38
+ *
39
+ * @deprecated - use the regular HTML attributes instead.
38
40
  */
39
41
  attrs?: AttrsObject;
40
42
  /**
@@ -9,3 +9,7 @@ export interface Position {
9
9
  left: number;
10
10
  flipped: boolean;
11
11
  }
12
+ export interface TriggerPosition extends Position {
13
+ /** True once the position has been calculated for the current visible state */
14
+ isPositioned: boolean;
15
+ }
@@ -1,5 +1,5 @@
1
1
  import { RefObject } from 'react';
2
- import { Alignment, Position } from './constants';
2
+ import { Alignment, TriggerPosition } from './constants';
3
3
  /**
4
4
  * useTriggerPosition hook.
5
5
  *
@@ -12,6 +12,6 @@ import { Alignment, Position } from './constants';
12
12
  * @param menuOffset - The offset of the menu from the trigger element.
13
13
  * @param disable - Whether to disable the hook.
14
14
  * @param disableFlipping - Whether to disable flipping logic when the menu overflows the screen.
15
- * @returns {Position} The calculated position of the menu element.
15
+ * @returns {TriggerPosition} The calculated position of the menu element and whether it has been calculated yet.
16
16
  */
17
- export declare const useTriggerPosition: (triggerRef: RefObject<HTMLElement> | undefined, elementRef: RefObject<HTMLElement>, menuAlign: Alignment, isElementVisible?: boolean, menuOffset?: number, disable?: boolean, disableFlipping?: boolean) => Position;
17
+ export declare const useTriggerPosition: (triggerRef: RefObject<HTMLElement> | undefined, elementRef: RefObject<HTMLElement>, menuAlign: Alignment, isElementVisible?: boolean, menuOffset?: number, disable?: boolean, disableFlipping?: boolean) => TriggerPosition;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muraldevkit/ui-toolkit",
3
- "version": "4.77.0",
3
+ "version": "4.77.2-dev-kdxV.1",
4
4
  "description": "Mural's UI Toolkit",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",