se-design 1.0.83 → 1.0.84-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/style.css +1 -1
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/InfoTooltip/index.d.ts +6 -1
- package/dist/components/TableLayout/index.d.ts +10 -0
- package/dist/index16.js +4 -4
- package/dist/index16.js.map +1 -1
- package/dist/index18.js +61 -58
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +27 -27
- package/dist/index19.js.map +1 -1
- package/dist/index207.js +16 -15
- package/dist/index207.js.map +1 -1
- package/dist/index215.js +17 -12
- package/dist/index215.js.map +1 -1
- package/dist/index22.js +51 -46
- package/dist/index22.js.map +1 -1
- package/dist/index25.js +257 -212
- package/dist/index25.js.map +1 -1
- package/dist/index28.js +49 -45
- package/dist/index28.js.map +1 -1
- package/dist/index31.js +43 -36
- package/dist/index31.js.map +1 -1
- package/dist/index38.js +184 -172
- package/dist/index38.js.map +1 -1
- package/dist/index4.js +53 -48
- package/dist/index4.js.map +1 -1
- package/dist/index43.js +30 -30
- package/dist/index43.js.map +1 -1
- package/dist/index48.js +15 -12
- package/dist/index48.js.map +1 -1
- package/dist/index53.js +22 -17
- package/dist/index53.js.map +1 -1
- package/dist/index61.js +57 -47
- package/dist/index61.js.map +1 -1
- package/dist/index68.js +46 -49
- package/dist/index68.js.map +1 -1
- package/dist/index75.js +107 -44
- package/dist/index75.js.map +1 -1
- package/package.json +1 -1
package/dist/index19.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index19.js","sources":["../src/components/Popover/index.tsx"],"sourcesContent":["import React, { useState, useRef, ReactNode, useEffect, forwardRef, ForwardedRef, useImperativeHandle } from 'react';\nimport ReactDOM from 'react-dom';\nimport {\n getA11yNameAttributes,\n useDismissOnFocusOut,\n FOCUSABLE_WITH_ROLES_SELECTOR,\n getFocusableElements,\n getFirstFocusableElement,\n getLastFocusableElement\n} from '../../utils/a11y';\nimport { useRegisterPortalWithFocusTrap } from '../../utils/a11y/FocusTrapPortalContext';\n\nexport interface PopoverHandle {\n togglePopover: (focusFirst?: boolean | 'last') => void;\n /** Focus the popover source/trigger element. */\n focusTrigger: () => void;\n /** The wrapper element that acts as the popover trigger. Stable DOM node with tabIndex=0. */\n element: HTMLElement | null;\n}\n\nexport interface PopoverProps {\n className?: string;\n automationId?: string;\n popoverContentAutomationId?: string;\n renderPopoverContents: (props: { closePopoverCb: (options?: { returnFocus?: boolean; returnFocusTo?: HTMLElement | React.RefObject<HTMLElement> }) => void }) => ReactNode;\n renderPopoverSrcElement: (props: { displayPopover: boolean; togglePopover: (focusFirst?: boolean | 'last') => void }) => ReactNode;\n position?: 'bottom-center' | 'bottom-left' | 'bottom-right' | 'top-center' | 'top-left' | 'top-right';\n onPopoverToggle?: (displayPopover: boolean) => void;\n contentWidth?: 'full' | 'max';\n isPopoverOpen?: boolean;\n disabled?: boolean;\n isWithPortal?: boolean;\n noBorder?: boolean;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n sourceRole?: 'button' | 'combobox';\n popupType?: 'menu' | 'listbox' | 'dialog' | 'true';\n popoverContentStyleProperty?: React.CSSProperties;\n disableClickToggle?: boolean;\n disableAutoClose?: boolean;\n /** Focus the first focusable element when the popover opens via isPopoverOpen (external state). */\n focusFirstOnOpen?: boolean;\n}\n\nexport const Popover = forwardRef<PopoverHandle, PopoverProps>(\n (\n {\n className = '',\n automationId = '',\n position = 'bottom-center',\n popoverContentAutomationId = '',\n contentWidth = 'max',\n renderPopoverContents,\n renderPopoverSrcElement,\n onPopoverToggle,\n isPopoverOpen,\n disabled = false,\n isWithPortal = false,\n ariaLabel,\n ariaLabelledBy,\n sourceRole = 'button',\n popupType = 'true',\n popoverContentStyleProperty = {\n zIndex: 1000,\n borderColor: 'var(--color-gray-200)',\n color: 'var(--color-gray-900)',\n backgroundColor: 'var(--color-white)'\n },\n disableClickToggle = false,\n noBorder = false,\n disableAutoClose = false,\n focusFirstOnOpen = false,\n ...props\n },\n ref: ForwardedRef<PopoverHandle>\n ) => {\n const [displayPopover, setDisplayPopover] = useState(false);\n const [popoverPosition, setPopoverPosition] = useState(position);\n const [isSrcElementVisible, setIsSrcElementVisible] = useState(false);\n const srcElementRef = useRef<HTMLDivElement>(null);\n const popoverContentRef = useRef<HTMLDivElement>(null);\n\n // Register portal content with the nearest ancestor focus trap (e.g., Modal)\n // so the focus trap's safety net allows focus to move into portal content.\n useRegisterPortalWithFocusTrap(popoverContentRef, isWithPortal && displayPopover);\n\n // Compute accessible name/description props with correct precedence\n const accessibleNameProps = getA11yNameAttributes({\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy: undefined // Popover doesn't support describedBy yet\n });\n\n // Use shared focus-out dismissal for non-portal popovers.\n // Portal content lives outside the wrapper, so portal uses a dedicated onBlur fallback below.\n const { onBlurCapture: onDismissBlurCapture } = useDismissOnFocusOut<HTMLDivElement>({\n disabled: !displayPopover || disableAutoClose || isWithPortal,\n onFocusOut: () => setDisplayPopover(false),\n closeOnEscape: false\n });\n\n const [portalPosition, setPortalPosition] = useState({ top: 0, left: 0, srcWidth: 0 });\n const [isPortalMeasured, setIsPortalMeasured] = useState(false);\n\n // Focus the actual trigger element on popover close.\n // When disableClickToggle=true the wrapper is role=\"none\"/tabIndex=-1 — focus the\n // first focusable child (the inner Button/Icon) instead.\n const focusTriggerElement = () => {\n if (disableClickToggle) {\n const inner = getFirstFocusableElement({ container: srcElementRef.current, includeRoles: true });\n (inner ?? srcElementRef.current)?.focus();\n } else {\n srcElementRef.current?.focus();\n }\n };\n\n const closePopover = (options?: { returnFocus?: boolean; returnFocusTo?: HTMLElement | React.RefObject<HTMLElement> }) => {\n setDisplayPopover(false);\n if (options?.returnFocus !== false) {\n requestAnimationFrame(() => {\n if (options?.returnFocusTo) {\n const target = options.returnFocusTo instanceof HTMLElement\n ? options.returnFocusTo\n : options.returnFocusTo.current;\n target?.focus();\n } else {\n focusTriggerElement();\n }\n });\n }\n };\n\n const calculatePositionOfPopover = (position: string = 'bottom-center') => {\n if (!srcElementRef.current) return { top: 0, left: 0, srcWidth: 0 };\n\n let localPosition = position;\n\n const srcRect = srcElementRef.current.getBoundingClientRect();\n // Subtract scrollbar width so portal content doesn't render behind a scrollbar.\n // document.documentElement.clientWidth excludes any visible scrollbar;\n // fall back to a 16px buffer (max scrollbar width across OS/browsers) when\n // body overflow is hidden and the scrollbar belongs to a nested container.\n const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;\n const viewportWidth = window.innerWidth - Math.max(scrollbarWidth, 16);\n const viewportHeight = window.innerHeight;\n\n // Calculate position for portal\n let top = 0;\n let left = 0;\n\n switch (localPosition) {\n case 'bottom-left':\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n case 'bottom-right':\n top = srcRect.bottom;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'bottom-center':\n top = srcRect.bottom;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n case 'top-left':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.left;\n break;\n case 'top-right':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'top-center':\n top = srcRect.top - srcRect.height * 1.9;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n default:\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n }\n\n // Get popover dimensions if available\n const popoverRect = popoverContentRef.current?.getBoundingClientRect();\n // When contentWidth='full', the panel will be sized to srcRect.width after measurement.\n // Use srcRect.width directly so centering and viewport clamping use the correct final width.\n const popoverWidth = (contentWidth === 'full' ? Math.max(srcRect.width, popoverRect?.width || 0) : popoverRect?.width) || 0;\n const popoverHeight = popoverRect?.height || 0;\n\n // Adjust center positions to account for popover width\n if (localPosition === 'bottom-center' || localPosition === 'top-center') {\n // Center the popover by subtracting half its width from the source center\n left = left - popoverWidth / 2;\n }\n\n // Adjust position to keep popover within viewport bounds\n // Horizontal adjustments\n if (left + popoverWidth > viewportWidth) {\n // Popover extends beyond right edge, shift it left\n left = Math.max(0, viewportWidth - popoverWidth);\n }\n if (left < 0) {\n // Popover extends beyond left edge, shift it right\n left = 0;\n }\n\n // Vertical adjustments\n if (top + popoverHeight > viewportHeight) {\n // Popover extends beyond bottom edge\n // Try to position it above the source element\n const spaceAbove = srcRect.top;\n const spaceBelow = viewportHeight - srcRect.bottom;\n\n if (spaceAbove >= popoverHeight || spaceAbove > spaceBelow) {\n // Position above if there's enough space or more space above\n top = srcRect.top - popoverHeight;\n // Ensure it doesn't go above the topbar (48px fixed header)\n if (top < 48) {\n top = 48;\n }\n } else {\n // Keep at bottom but adjust to fit within viewport\n top = Math.max(48, viewportHeight - popoverHeight);\n }\n }\n if (top < 48) {\n // Popover extends beyond top edge, position it below the source element\n top = srcRect.bottom;\n // Ensure it doesn't go below viewport\n if (top + popoverHeight > viewportHeight) {\n top = Math.max(48, viewportHeight - popoverHeight);\n }\n }\n\n return { top: Math.round(top), left: Math.round(left), srcWidth: srcRect.width };\n };\n\n useEffect(() => {\n if (onPopoverToggle) {\n onPopoverToggle(displayPopover);\n }\n\n if (displayPopover && !isWithPortal) {\n // Add click listener for auto-close behavior only if not disabled\n if (!disableAutoClose) {\n document.body.addEventListener('click', clickListener, true);\n }\n checkPopoverPosition();\n return () => {\n if (!disableAutoClose) {\n document.body.removeEventListener('click', clickListener, true);\n }\n };\n } else if (displayPopover && isWithPortal) {\n // Add click/scroll listeners for auto-close behavior only if not disabled\n if (!disableAutoClose) {\n document.body.addEventListener('click', clickAndScrollListenerWithPortal, true);\n window.addEventListener('scroll', clickAndScrollListenerWithPortal);\n } else {\n // When disableAutoClose is true, still listen to scroll for repositioning\n window.addEventListener('scroll', scrollListenerForRepositioning);\n }\n // Always add resize listener for repositioning\n window.addEventListener('resize', resizeListenerWithPortal);\n\n // Escape on window capture phase — must fire before document-capture listeners\n // (e.g. useDismissOnEscape in Modal) so Escape closes the portal Dropdown without\n // also dismissing the modal behind it.\n const escapeHandler = (e: KeyboardEvent) => {\n if (e.key !== 'Escape') return;\n if (!popoverContentRef.current?.contains(document.activeElement)) return;\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n requestAnimationFrame(() => focusTriggerElement());\n };\n window.addEventListener('keydown', escapeHandler, true);\n\n // Trigger source visibility check immediately\n checkSourceVisibility();\n\n // Use double-rAF to measure portal after browser has completed layout,\n // guaranteeing real dimensions are available for flip/clamp calculations.\n // Portal is hidden via visibility:hidden until this completes (no flash).\n let rafId1: number;\n let rafId2: number;\n rafId1 = requestAnimationFrame(() => {\n rafId2 = requestAnimationFrame(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n setIsPortalMeasured(true);\n });\n });\n\n return () => {\n if (!disableAutoClose) {\n document.body.removeEventListener('click', clickAndScrollListenerWithPortal, true);\n window.removeEventListener('scroll', clickAndScrollListenerWithPortal);\n } else {\n window.removeEventListener('scroll', scrollListenerForRepositioning);\n }\n window.removeEventListener('resize', resizeListenerWithPortal);\n window.removeEventListener('keydown', escapeHandler, true);\n cancelAnimationFrame(rafId1);\n cancelAnimationFrame(rafId2);\n setIsPortalMeasured(false);\n };\n }\n }, [displayPopover, isWithPortal, disableAutoClose]);\n\n const checkSourceVisibility = () => {\n if (!srcElementRef.current) {\n setIsSrcElementVisible(false);\n return;\n }\n\n const rec = srcElementRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n const viewportWidth = window.innerWidth;\n\n const isVisible = rec.top < viewportHeight && rec.bottom > 0 && rec.left < viewportWidth && rec.right > 0;\n\n setIsSrcElementVisible(isVisible);\n };\n\n useEffect(() => {\n setDisplayPopover(isPopoverOpen ?? false);\n }, [isPopoverOpen]);\n\n useEffect(() => {\n // Focus first focusable element when popover opens.\n // For portal, delay longer so isSrcElementVisible can be set and portal can mount first.\n if (displayPopover) {\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable && (focusFirstOnOpen || document.activeElement === srcElementRef.current)) {\n firstFocusable.focus();\n }\n }, isWithPortal ? 60 : 0);\n }\n }, [displayPopover]);\n\n //Function to check popover position\n const checkPopoverPosition = () => {\n if (!popoverContentRef.current) return;\n\n const popoverRect = popoverContentRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n\n if (popoverRect?.bottom > viewportHeight) {\n setPopoverPosition(\n position.includes('left') ? 'top-left' : position.includes('right') ? 'top-right' : 'top-center'\n );\n } else if (popoverRect?.top < 0) {\n // If popover extends beyond top of viewport, switch to bottom position\n setPopoverPosition(\n position.includes('left') ? 'bottom-left' : position.includes('right') ? 'bottom-right' : 'bottom-center'\n );\n }\n };\n\n const clickListener = (event: MouseEvent) => {\n const currentDropRef = srcElementRef.current;\n if (!currentDropRef) return;\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = popoverContentRef.current?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if (disableAutoClose) return;\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const clickAndScrollListenerWithPortal = (event: Event) => {\n const currentDropRef = srcElementRef.current;\n const currentPopoverRef = popoverContentRef.current;\n if (!currentDropRef) return;\n checkSourceVisibility();\n\n // Recalculate position on scroll\n if (event.type === 'scroll' && displayPopover) {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = currentPopoverRef?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n if (disableAutoClose) return;\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const resizeListenerWithPortal = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const scrollListenerForRepositioning = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const togglePopover = (focusFirst: boolean | 'last' = false) => {\n const wasOpen = displayPopover;\n setDisplayPopover((prev) => !prev);\n if (!wasOpen && focusFirst) {\n setTimeout(() => {\n if (focusFirst === 'last') {\n const lastFocusable = getLastFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (lastFocusable) lastFocusable.focus();\n } else {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }\n }, 50);\n }\n };\n\n const handleArrowKeyNavigation = (e: React.KeyboardEvent, container: HTMLDivElement | null) => {\n if (!container) return;\n\n // Native form controls own their arrow key behavior — don't intercept.\n // (e.g. a SearchBox inside a Popover should keep focus while typing/navigating)\n const activeEl = document.activeElement;\n if (activeEl?.tagName === 'INPUT' || activeEl?.tagName === 'TEXTAREA' || activeEl?.tagName === 'SELECT') {\n return;\n }\n\n const focusableElements = Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_WITH_ROLES_SELECTOR)).filter((el) => {\n // Filter out disabled and hidden elements.\n // Note: check aria-disabled VALUE not just presence — React always writes aria-disabled=\"false\"\n // on elements like MenuItem even when not disabled, so hasAttribute would wrongly exclude them.\n const style = window.getComputedStyle(el);\n return (\n !el.hasAttribute('disabled') &&\n el.getAttribute('aria-disabled') !== 'true' &&\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n (el.tabIndex >= 0 || el.hasAttribute('role'))\n );\n });\n\n if (focusableElements.length === 0) return;\n\n const currentIndex = focusableElements.findIndex((el) => el === document.activeElement);\n let nextIndex = -1;\n\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex < focusableElements.length - 1 ? currentIndex + 1 : 0;\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex > 0 ? currentIndex - 1 : focusableElements.length - 1;\n } else if (e.key === 'Home') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = 0;\n } else if (e.key === 'End') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = focusableElements.length - 1;\n }\n\n if (nextIndex >= 0 && focusableElements[nextIndex]) {\n focusableElements[nextIndex].focus();\n } else if (currentIndex === -1 && focusableElements.length > 0) {\n // If no element is currently focused, focus the first one\n focusableElements[0].focus();\n }\n };\n\n const handlePopoverContentKeyDown = (e: React.KeyboardEvent) => {\n // Allow Escape key to close popover when focus is on content\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n // Defer focus restoration to after React re-renders and portal unmounts.\n // Synchronous focus() during the event can be displaced by the portal\n // teardown in some browsers, especially when isWithPortal=true.\n requestAnimationFrame(() => focusTriggerElement());\n } else if (e.key === 'Tab') {\n if (popupType === 'dialog') {\n // Dialog popovers: let Tab flow naturally within the content.\n // Only close when focus would actually leave the popover.\n const focusables = getFocusableElements({ container: popoverContentRef.current, filterHidden: true });\n const currentIndex = focusables.indexOf(e.target as HTMLElement);\n const isOnLast = currentIndex === focusables.length - 1;\n const isOnFirst = currentIndex === 0 || currentIndex === -1;\n\n if (e.shiftKey && isOnFirst) {\n // Shift+Tab past first element — close and return focus to trigger\n e.preventDefault();\n setDisplayPopover(false);\n focusTriggerElement();\n } else if (!e.shiftKey && isOnLast) {\n // Tab past last element — close popover\n setDisplayPopover(false);\n if (isWithPortal) {\n e.preventDefault();\n const srcEl = srcElementRef.current;\n const allFocusables = getFocusableElements({ container: document.body, filterHidden: true });\n const idx = srcEl ? allFocusables.indexOf(srcEl) : -1;\n const next = allFocusables[idx + 1];\n if (next) next.focus();\n else srcEl?.focus();\n }\n }\n // Otherwise: let browser handle Tab naturally within the popover content\n } else {\n // Non-dialog: close popover when Tab exits the menu\n setDisplayPopover(false);\n if (e.shiftKey) {\n // Shift+Tab: prevent default (would go to wrapper) and focus trigger instead\n e.preventDefault();\n focusTriggerElement();\n } else if (isWithPortal) {\n // Portal forward Tab: portal content is at document.body so natural Tab order\n // skips back to the top of the page. Manually advance to the next focusable\n // element after the trigger in the main document instead.\n e.preventDefault();\n const srcEl = srcElementRef.current;\n const focusables = getFocusableElements({ container: document.body, filterHidden: true });\n const idx = srcEl ? focusables.indexOf(srcEl) : -1;\n const next = focusables[idx + 1];\n if (next) next.focus();\n else srcEl?.focus();\n }\n // Non-portal forward Tab: do NOT preventDefault — browser moves focus to next element naturally\n }\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Home' || e.key === 'End') {\n // Handle arrow key navigation for focusable elements inside popover\n handleArrowKeyNavigation(e, popoverContentRef.current);\n } else if (e.key === 'Enter' || e.key === ' ') {\n // Prevent Enter/Space from bubbling to wrapper (mirrors click stopPropagation)\n e.stopPropagation();\n }\n };\n\n useImperativeHandle(ref, () => ({ togglePopover, focusTrigger: () => srcElementRef.current?.focus(), element: srcElementRef.current }), []);\n\n const popoverContentStyle = {\n 'bottom-left': { left: '0', top: '100%' },\n 'bottom-right': { right: '0', top: '100%' },\n 'bottom-center': { left: '50%', transform: 'translateX(-50%)', top: '100%' },\n 'top-left': { left: '0', bottom: '100%' },\n 'top-right': { right: '0', bottom: '100%' },\n 'top-center': { left: '50%', transform: 'translateX(-50%)', bottom: '100%' }\n };\n const popoverContentClasses = noBorder ? '' : 'shadow-md border rounded-md';\n\n return (\n <div\n className={\n 'se-design-popover-wrapper cursor-pointer relative focus-outline rounded-md' +\n (className.length > 0 ? ` ${className}` : '') +\n (displayPopover ? ' open' : '') +\n (disabled ? ' opacity-50 cursor-not-allowed pointer-events-none' : '')\n }\n ref={srcElementRef}\n onClick={(e) => {\n if (disabled || disableClickToggle) return;\n e.stopPropagation();\n togglePopover();\n }}\n onKeyDown={(e) => {\n if (disabled || disableClickToggle) return;\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n const wasOpen = displayPopover;\n togglePopover();\n // Focus first focusable element when opening.\n // Portal content isn't mounted until isSrcElementVisible resolves (via setTimeout 0),\n // so use a longer delay for portal to ensure popoverContentRef.current is set.\n if (!wasOpen) {\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }, isWithPortal ? 60 : 0);\n }\n } else if (e.key === 'Escape' && displayPopover) {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n } else if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && displayPopover) {\n // Handle arrow keys when popover is open\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n handleArrowKeyNavigation(e, currentRef);\n }\n } else if (e.key === 'ArrowDown' && !displayPopover) {\n // Open popover and focus first item when ArrowDown is pressed\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(true);\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }, 0);\n }\n }}\n onBlurCapture={onDismissBlurCapture}\n onBlur={(e) => {\n // Portal content is rendered outside wrapper, so keep explicit check for that case.\n if (!displayPopover || disableAutoClose || !isWithPortal) return;\n\n const nextFocused = e.relatedTarget as Node | null;\n const isFocusInSource = !!(nextFocused && srcElementRef.current?.contains(nextFocused));\n const isFocusInPopover = !!(nextFocused && popoverContentRef.current?.contains(nextFocused));\n\n // Close only when focus leaves both source and portal content.\n if (!isFocusInSource && !isFocusInPopover) {\n setDisplayPopover(false);\n }\n }}\n role={disableClickToggle ? 'none' : sourceRole}\n aria-expanded={disableClickToggle ? undefined : displayPopover ? 'true' : 'false'}\n aria-haspopup={disableClickToggle ? undefined : sourceRole === 'combobox' ? 'listbox' : popupType}\n tabIndex={disabled || disableClickToggle ? -1 : 0}\n aria-disabled={disableClickToggle ? undefined : disabled ? 'true' : undefined}\n {...accessibleNameProps}\n data-automation-id={automationId}\n {...props}\n >\n {renderPopoverSrcElement({ displayPopover, togglePopover })}\n\n {displayPopover && !isWithPortal && (\n <div\n className={`popover-content absolute ${popoverContentClasses} z-[1000] ${\n contentWidth == 'full' ? 'w-full' : 'w-max'\n }`}\n style={{\n ...popoverContentStyleProperty,\n ...popoverContentStyle[popoverPosition]\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={handlePopoverContentKeyDown}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: closePopover })}\n </div>\n )}\n {isWithPortal &&\n displayPopover &&\n isSrcElementVisible &&\n ReactDOM.createPortal(\n <div\n className={`popover-content-with-portal z-[2002] ${popoverContentClasses} ${\n contentWidth == 'full' ? '' : 'w-max'\n }`}\n style={{\n position: 'fixed',\n top: portalPosition.top,\n left: portalPosition.left,\n visibility: isPortalMeasured ? 'visible' : 'hidden',\n maxHeight: 'calc(100vh - 96px)',\n overflowY: 'hidden',\n ...(contentWidth === 'full' && portalPosition.srcWidth\n ? { width: `${portalPosition.srcWidth}px` }\n : {}),\n ...popoverContentStyleProperty,\n zIndex: 2002\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={handlePopoverContentKeyDown}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: closePopover })}\n </div>,\n document.body\n )}\n </div>\n );\n }\n);\n"],"names":["Popover","className","automationId","position","popoverContentAutomationId","contentWidth","renderPopoverContents","renderPopoverSrcElement","onPopoverToggle","isPopoverOpen","disabled","isWithPortal","ariaLabel","ariaLabelledBy","sourceRole","popupType","popoverContentStyleProperty","zIndex","borderColor","color","backgroundColor","disableClickToggle","noBorder","disableAutoClose","focusFirstOnOpen","props","ref","displayPopover","setDisplayPopover","useState","popoverPosition","setPopoverPosition","isSrcElementVisible","setIsSrcElementVisible","srcElementRef","useRef","popoverContentRef","useRegisterPortalWithFocusTrap","accessibleNameProps","getA11yNameAttributes","ariaDescribedBy","undefined","onBlurCapture","onDismissBlurCapture","useDismissOnFocusOut","onFocusOut","closeOnEscape","portalPosition","setPortalPosition","top","left","srcWidth","isPortalMeasured","setIsPortalMeasured","focusTriggerElement","getFirstFocusableElement","container","current","includeRoles","focus","closePopover","options","returnFocus","requestAnimationFrame","returnFocusTo","HTMLElement","calculatePositionOfPopover","localPosition","srcRect","getBoundingClientRect","scrollbarWidth","window","innerWidth","document","documentElement","clientWidth","viewportWidth","Math","max","viewportHeight","innerHeight","bottom","right","width","height","popoverRect","popoverWidth","popoverHeight","spaceAbove","spaceBelow","round","useEffect","body","addEventListener","clickListener","checkPopoverPosition","removeEventListener","scrollListenerForRepositioning","clickAndScrollListenerWithPortal","resizeListenerWithPortal","escapeHandler","e","key","contains","activeElement","preventDefault","stopPropagation","checkSourceVisibility","rafId1","rafId2","cancelAnimationFrame","rec","isVisible","setTimeout","firstFocusable","includes","event","currentDropRef","target","isSourcePopover","isPopoverContent","closestPopoverWrapper","closest","isAnotherPopoverSource","isNestedPopover","currentPopoverRef","type","togglePopover","focusFirst","wasOpen","prev","lastFocusable","getLastFocusableElement","handleArrowKeyNavigation","activeEl","tagName","focusableElements","Array","from","querySelectorAll","FOCUSABLE_WITH_ROLES_SELECTOR","filter","el","style","getComputedStyle","hasAttribute","getAttribute","display","visibility","tabIndex","length","currentIndex","findIndex","nextIndex","handlePopoverContentKeyDown","focusables","getFocusableElements","filterHidden","indexOf","isOnLast","isOnFirst","shiftKey","srcEl","allFocusables","idx","next","useImperativeHandle","focusTrigger","element","popoverContentStyle","transform","popoverContentClasses","React","createElement","_extends","onClick","onKeyDown","currentRef","onBlur","nextFocused","relatedTarget","isFocusInSource","isFocusInPopover","role","closePopoverCb","ReactDOM","createPortal","maxHeight","overflowY"],"mappings":";;;;;;;;;;;;;;;;AA4CO,MAAMA,wBACX,CACE;AAAA,EACEC,WAAAA,IAAY;AAAA,EACZC,cAAAA,IAAe;AAAA,EACfC,UAAAA,IAAW;AAAA,EACXC,4BAAAA,IAA6B;AAAA,EAC7BC,cAAAA,IAAe;AAAA,EACfC,uBAAAA;AAAAA,EACAC,yBAAAA;AAAAA,EACAC,iBAAAA;AAAAA,EACAC,eAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,cAAAA,IAAe;AAAA,EACfC,WAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,YAAAA,IAAa;AAAA,EACbC,WAAAA,IAAY;AAAA,EACZC,6BAAAA,IAA8B;AAAA,IAC5BC,QAAQ;AAAA,IACRC,aAAa;AAAA,IACbC,OAAO;AAAA,IACPC,iBAAiB;AAAA,EAAA;AAAA,EAEnBC,oBAAAA,IAAqB;AAAA,EACrBC,UAAAA,KAAW;AAAA,EACXC,kBAAAA,IAAmB;AAAA,EACnBC,kBAAAA,KAAmB;AAAA,EACnB,GAAGC;AACL,GACAC,OACG;AACH,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAK,GACpD,CAACC,GAAiBC,CAAkB,IAAIF,EAAS1B,CAAQ,GACzD,CAAC6B,IAAqBC,CAAsB,IAAIJ,E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AAeE;AAAAA,MACpBC,MAAMH,EAAeG;AAAAA,MACrBkG,YAAYhG,KAAmB,YAAY;AAAA,MAC3CuI,WAAW;AAAA,MACXC,WAAW;AAAA,MACX,GAAIvL,MAAiB,UAAU0C,EAAeI,WAC1C;AAAA,QAAEgC,OAAO,GAAGpC,EAAeI,QAAQ;AAAA,MAAA,IACnC,CAAA;AAAA,MACJ,GAAGnC;AAAAA,MACHC,QAAQ;AAAA,IAAA;AAAA,IAEV8J,SAAU1E,CAAAA,MAAMA,EAAEK,gBAAAA;AAAAA,IAClBsE,WAAWtB;AAAAA,IACXhI,KAAKU;AAAAA,IACL,sBAAoBhC;AAAAA,EAAAA,GAEnBE,EAAsB;AAAA,IAAEkL,gBAAgB5H;AAAAA,EAAAA,CAAc,CACpD,GACLa,SAASmB,IACX,CACC;AAET,CACF;"}
|
|
1
|
+
{"version":3,"file":"index19.js","sources":["../src/components/Popover/index.tsx"],"sourcesContent":["import React, { useState, useRef, ReactNode, useEffect, forwardRef, ForwardedRef, useImperativeHandle } from 'react';\nimport ReactDOM from 'react-dom';\nimport {\n getA11yNameAttributes,\n useDismissOnFocusOut,\n FOCUSABLE_WITH_ROLES_SELECTOR,\n getFocusableElements,\n getFirstFocusableElement,\n getLastFocusableElement\n} from '../../utils/a11y';\nimport { useRegisterPortalWithFocusTrap } from '../../utils/a11y/FocusTrapPortalContext';\n\nexport interface PopoverHandle {\n togglePopover: (focusFirst?: boolean | 'last') => void;\n /** Focus the popover source/trigger element. */\n focusTrigger: () => void;\n /** The wrapper element that acts as the popover trigger. Stable DOM node with tabIndex=0. */\n element: HTMLElement | null;\n}\n\nexport interface PopoverProps {\n className?: string;\n automationId?: string;\n popoverContentAutomationId?: string;\n renderPopoverContents: (props: { closePopoverCb: (options?: { returnFocus?: boolean; returnFocusTo?: HTMLElement | React.RefObject<HTMLElement> }) => void }) => ReactNode;\n renderPopoverSrcElement: (props: { displayPopover: boolean; togglePopover: (focusFirst?: boolean | 'last') => void }) => ReactNode;\n position?: 'bottom-center' | 'bottom-left' | 'bottom-right' | 'top-center' | 'top-left' | 'top-right';\n onPopoverToggle?: (displayPopover: boolean) => void;\n contentWidth?: 'full' | 'max';\n isPopoverOpen?: boolean;\n disabled?: boolean;\n isWithPortal?: boolean;\n noBorder?: boolean;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n sourceRole?: 'button' | 'combobox';\n popupType?: 'menu' | 'listbox' | 'dialog' | 'true';\n popoverContentStyleProperty?: React.CSSProperties;\n disableClickToggle?: boolean;\n disableAutoClose?: boolean;\n /** Focus the first focusable element when the popover opens via isPopoverOpen (external state). */\n focusFirstOnOpen?: boolean;\n}\n\nexport const Popover = forwardRef<PopoverHandle, PopoverProps>(\n (\n {\n className = '',\n automationId = '',\n position = 'bottom-center',\n popoverContentAutomationId = '',\n contentWidth = 'max',\n renderPopoverContents,\n renderPopoverSrcElement,\n onPopoverToggle,\n isPopoverOpen,\n disabled = false,\n isWithPortal = false,\n ariaLabel,\n ariaLabelledBy,\n sourceRole = 'button',\n popupType = 'true',\n popoverContentStyleProperty = {\n zIndex: 1000,\n borderColor: 'var(--color-gray-200)',\n color: 'var(--color-gray-900)',\n backgroundColor: 'var(--color-white)'\n },\n disableClickToggle = false,\n noBorder = false,\n disableAutoClose = false,\n focusFirstOnOpen = false,\n ...props\n },\n ref: ForwardedRef<PopoverHandle>\n ) => {\n const [displayPopover, setDisplayPopover] = useState(false);\n const [popoverPosition, setPopoverPosition] = useState(position);\n const [isSrcElementVisible, setIsSrcElementVisible] = useState(false);\n const srcElementRef = useRef<HTMLDivElement>(null);\n const popoverContentRef = useRef<HTMLDivElement>(null);\n\n // Register portal content with the nearest ancestor focus trap (e.g., Modal)\n // so the focus trap's safety net allows focus to move into portal content.\n useRegisterPortalWithFocusTrap(popoverContentRef, isWithPortal && displayPopover);\n\n // Compute accessible name/description props with correct precedence\n const accessibleNameProps = getA11yNameAttributes({\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy: undefined // Popover doesn't support describedBy yet\n });\n\n // Use shared focus-out dismissal for non-portal popovers.\n // Portal content lives outside the wrapper, so portal uses a dedicated onBlur fallback below.\n const { onBlurCapture: onDismissBlurCapture } = useDismissOnFocusOut<HTMLDivElement>({\n disabled: !displayPopover || disableAutoClose || isWithPortal,\n onFocusOut: () => setDisplayPopover(false),\n closeOnEscape: false\n });\n\n const [portalPosition, setPortalPosition] = useState({ top: 0, left: 0, srcWidth: 0 });\n const [isPortalMeasured, setIsPortalMeasured] = useState(false);\n\n // Focus the actual trigger element on popover close.\n // When disableClickToggle=true the wrapper is role=\"none\"/tabIndex=-1 — focus the\n // first focusable child (the inner Button/Icon) instead.\n const focusTriggerElement = () => {\n if (disableClickToggle) {\n const inner = getFirstFocusableElement({ container: srcElementRef.current, includeRoles: true });\n (inner ?? srcElementRef.current)?.focus();\n } else {\n srcElementRef.current?.focus();\n }\n };\n\n const closePopover = (options?: { returnFocus?: boolean; returnFocusTo?: HTMLElement | React.RefObject<HTMLElement> }) => {\n setDisplayPopover(false);\n if (options?.returnFocus !== false) {\n requestAnimationFrame(() => {\n if (options?.returnFocusTo) {\n const target = options.returnFocusTo instanceof HTMLElement\n ? options.returnFocusTo\n : options.returnFocusTo.current;\n target?.focus();\n } else {\n focusTriggerElement();\n }\n });\n }\n };\n\n const calculatePositionOfPopover = (position: string = 'bottom-center') => {\n if (!srcElementRef.current) return { top: 0, left: 0, srcWidth: 0 };\n\n let localPosition = position;\n\n const srcRect = srcElementRef.current.getBoundingClientRect();\n // Subtract scrollbar width so portal content doesn't render behind a scrollbar.\n // document.documentElement.clientWidth excludes any visible scrollbar;\n // fall back to a 16px buffer (max scrollbar width across OS/browsers) when\n // body overflow is hidden and the scrollbar belongs to a nested container.\n const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;\n const viewportWidth = window.innerWidth - Math.max(scrollbarWidth, 16);\n const viewportHeight = window.innerHeight;\n\n // Calculate position for portal\n let top = 0;\n let left = 0;\n\n switch (localPosition) {\n case 'bottom-left':\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n case 'bottom-right':\n top = srcRect.bottom;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'bottom-center':\n top = srcRect.bottom;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n case 'top-left':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.left;\n break;\n case 'top-right':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'top-center':\n top = srcRect.top - srcRect.height * 1.9;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n default:\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n }\n\n // Get popover dimensions if available\n const popoverRect = popoverContentRef.current?.getBoundingClientRect();\n // When contentWidth='full', the panel will be sized to srcRect.width after measurement.\n // Use srcRect.width directly so centering and viewport clamping use the correct final width.\n const popoverWidth = (contentWidth === 'full' ? Math.max(srcRect.width, popoverRect?.width || 0) : popoverRect?.width) || 0;\n const popoverHeight = popoverRect?.height || 0;\n\n // Adjust center positions to account for popover width\n if (localPosition === 'bottom-center' || localPosition === 'top-center') {\n // Center the popover by subtracting half its width from the source center\n left = left - popoverWidth / 2;\n }\n\n // Adjust position to keep popover within viewport bounds\n // Horizontal adjustments\n if (left + popoverWidth > viewportWidth) {\n // Popover extends beyond right edge, shift it left\n left = Math.max(0, viewportWidth - popoverWidth);\n }\n if (left < 0) {\n // Popover extends beyond left edge, shift it right\n left = 0;\n }\n\n // Vertical adjustments\n if (top + popoverHeight > viewportHeight) {\n // Popover extends beyond bottom edge\n // Try to position it above the source element\n const spaceAbove = srcRect.top;\n const spaceBelow = viewportHeight - srcRect.bottom;\n\n if (spaceAbove >= popoverHeight || spaceAbove > spaceBelow) {\n // Position above if there's enough space or more space above\n top = srcRect.top - popoverHeight;\n // Ensure it doesn't go above the topbar (48px fixed header)\n if (top < 48) {\n top = 48;\n }\n } else {\n // Keep at bottom but adjust to fit within viewport\n top = Math.max(48, viewportHeight - popoverHeight);\n }\n }\n if (top < 48) {\n // Popover extends beyond top edge, position it below the source element\n top = srcRect.bottom;\n // Ensure it doesn't go below viewport\n if (top + popoverHeight > viewportHeight) {\n top = Math.max(48, viewportHeight - popoverHeight);\n }\n }\n\n return { top: Math.round(top), left: Math.round(left), srcWidth: srcRect.width };\n };\n\n useEffect(() => {\n if (onPopoverToggle) {\n onPopoverToggle(displayPopover);\n }\n\n if (displayPopover && !isWithPortal) {\n // Add click listener for auto-close behavior only if not disabled\n if (!disableAutoClose) {\n document.body.addEventListener('click', clickListener, true);\n }\n checkPopoverPosition();\n return () => {\n if (!disableAutoClose) {\n document.body.removeEventListener('click', clickListener, true);\n }\n };\n } else if (displayPopover && isWithPortal) {\n // Add click/scroll listeners for auto-close behavior only if not disabled\n if (!disableAutoClose) {\n document.body.addEventListener('click', clickAndScrollListenerWithPortal, true);\n window.addEventListener('scroll', clickAndScrollListenerWithPortal);\n } else {\n // When disableAutoClose is true, still listen to scroll for repositioning\n window.addEventListener('scroll', scrollListenerForRepositioning);\n }\n // Always add resize listener for repositioning\n window.addEventListener('resize', resizeListenerWithPortal);\n\n // Escape on window capture phase — must fire before document-capture listeners\n // (e.g. useDismissOnEscape in Modal) so Escape closes the portal Dropdown without\n // also dismissing the modal behind it.\n const escapeHandler = (e: KeyboardEvent) => {\n if (e.key !== 'Escape') return;\n if (!popoverContentRef.current?.contains(document.activeElement)) return;\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n requestAnimationFrame(() => focusTriggerElement());\n };\n window.addEventListener('keydown', escapeHandler, true);\n\n // Trigger source visibility check immediately\n checkSourceVisibility();\n\n // Use double-rAF to measure portal after browser has completed layout,\n // guaranteeing real dimensions are available for flip/clamp calculations.\n // Portal is hidden via visibility:hidden until this completes (no flash).\n let rafId1: number;\n let rafId2: number;\n rafId1 = requestAnimationFrame(() => {\n rafId2 = requestAnimationFrame(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n setIsPortalMeasured(true);\n });\n });\n\n return () => {\n if (!disableAutoClose) {\n document.body.removeEventListener('click', clickAndScrollListenerWithPortal, true);\n window.removeEventListener('scroll', clickAndScrollListenerWithPortal);\n } else {\n window.removeEventListener('scroll', scrollListenerForRepositioning);\n }\n window.removeEventListener('resize', resizeListenerWithPortal);\n window.removeEventListener('keydown', escapeHandler, true);\n cancelAnimationFrame(rafId1);\n cancelAnimationFrame(rafId2);\n setIsPortalMeasured(false);\n };\n }\n }, [displayPopover, isWithPortal, disableAutoClose]);\n\n const checkSourceVisibility = () => {\n if (!srcElementRef.current) {\n setIsSrcElementVisible(false);\n return;\n }\n\n const rec = srcElementRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n const viewportWidth = window.innerWidth;\n\n const isVisible = rec.top < viewportHeight && rec.bottom > 0 && rec.left < viewportWidth && rec.right > 0;\n\n setIsSrcElementVisible(isVisible);\n };\n\n useEffect(() => {\n setDisplayPopover(isPopoverOpen ?? false);\n }, [isPopoverOpen]);\n\n useEffect(() => {\n // Focus first focusable element when popover opens.\n // For portal, delay longer so isSrcElementVisible can be set and portal can mount first.\n if (displayPopover) {\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable && (focusFirstOnOpen || document.activeElement === srcElementRef.current)) {\n firstFocusable.focus();\n }\n }, isWithPortal ? 60 : 0);\n }\n }, [displayPopover]);\n\n //Function to check popover position\n const checkPopoverPosition = () => {\n if (!popoverContentRef.current) return;\n\n const popoverRect = popoverContentRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n\n if (popoverRect?.bottom > viewportHeight) {\n setPopoverPosition(\n position.includes('left') ? 'top-left' : position.includes('right') ? 'top-right' : 'top-center'\n );\n } else if (popoverRect?.top < 0) {\n // If popover extends beyond top of viewport, switch to bottom position\n setPopoverPosition(\n position.includes('left') ? 'bottom-left' : position.includes('right') ? 'bottom-right' : 'bottom-center'\n );\n }\n };\n\n const clickListener = (event: MouseEvent) => {\n const currentDropRef = srcElementRef.current;\n if (!currentDropRef) return;\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = popoverContentRef.current?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if (disableAutoClose) return;\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const clickAndScrollListenerWithPortal = (event: Event) => {\n const currentDropRef = srcElementRef.current;\n const currentPopoverRef = popoverContentRef.current;\n if (!currentDropRef) return;\n checkSourceVisibility();\n\n // Recalculate position on scroll\n if (event.type === 'scroll' && displayPopover) {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = currentPopoverRef?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n if (disableAutoClose) return;\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const resizeListenerWithPortal = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const scrollListenerForRepositioning = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const togglePopover = (focusFirst: boolean | 'last' = false) => {\n const wasOpen = displayPopover;\n setDisplayPopover((prev) => !prev);\n if (!wasOpen && focusFirst) {\n setTimeout(() => {\n if (focusFirst === 'last') {\n const lastFocusable = getLastFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (lastFocusable) lastFocusable.focus();\n } else {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }\n }, 50);\n }\n };\n\n const handleArrowKeyNavigation = (e: React.KeyboardEvent, container: HTMLDivElement | null) => {\n if (!container) return;\n\n // Native form controls own their arrow key behavior — don't intercept.\n // (e.g. a SearchBox inside a Popover should keep focus while typing/navigating)\n const activeEl = document.activeElement;\n if (activeEl?.tagName === 'INPUT' || activeEl?.tagName === 'TEXTAREA' || activeEl?.tagName === 'SELECT') {\n return;\n }\n\n const focusableElements = Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_WITH_ROLES_SELECTOR)).filter((el) => {\n // Filter out disabled and hidden elements.\n // Note: check aria-disabled VALUE not just presence — React always writes aria-disabled=\"false\"\n // on elements like MenuItem even when not disabled, so hasAttribute would wrongly exclude them.\n const style = window.getComputedStyle(el);\n return (\n !el.hasAttribute('disabled') &&\n el.getAttribute('aria-disabled') !== 'true' &&\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n (el.tabIndex >= 0 || el.hasAttribute('role'))\n );\n });\n\n if (focusableElements.length === 0) return;\n\n const currentIndex = focusableElements.findIndex((el) => el === document.activeElement);\n let nextIndex = -1;\n\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex < focusableElements.length - 1 ? currentIndex + 1 : 0;\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex > 0 ? currentIndex - 1 : focusableElements.length - 1;\n } else if (e.key === 'Home') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = 0;\n } else if (e.key === 'End') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = focusableElements.length - 1;\n }\n\n if (nextIndex >= 0 && focusableElements[nextIndex]) {\n focusableElements[nextIndex].focus();\n } else if (currentIndex === -1 && focusableElements.length > 0) {\n // If no element is currently focused, focus the first one\n focusableElements[0].focus();\n }\n };\n\n const handlePopoverContentKeyDown = (e: React.KeyboardEvent) => {\n // Allow Escape key to close popover when focus is on content\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n // Defer focus restoration to after React re-renders and portal unmounts.\n // Synchronous focus() during the event can be displaced by the portal\n // teardown in some browsers, especially when isWithPortal=true.\n requestAnimationFrame(() => focusTriggerElement());\n } else if (e.key === 'Tab') {\n if (popupType === 'dialog') {\n // Dialog popovers: let Tab flow naturally within the content.\n // Only close when focus would actually leave the popover.\n const focusables = getFocusableElements({ container: popoverContentRef.current, filterHidden: true });\n const currentIndex = focusables.indexOf(e.target as HTMLElement);\n const isOnLast = currentIndex === focusables.length - 1;\n const isOnFirst = currentIndex === 0 || currentIndex === -1;\n\n if (e.shiftKey && isOnFirst) {\n // Shift+Tab past first element — close and return focus to trigger\n e.preventDefault();\n setDisplayPopover(false);\n focusTriggerElement();\n } else if (!e.shiftKey && isOnLast) {\n // Tab past last element — close popover\n setDisplayPopover(false);\n if (isWithPortal) {\n e.preventDefault();\n const srcEl = srcElementRef.current;\n const allFocusables = getFocusableElements({ container: document.body, filterHidden: true });\n const idx = srcEl ? allFocusables.indexOf(srcEl) : -1;\n const next = allFocusables[idx + 1];\n if (next) next.focus();\n else srcEl?.focus();\n }\n }\n // Otherwise: let browser handle Tab naturally within the popover content\n } else {\n // Non-dialog: close popover when Tab exits the menu\n setDisplayPopover(false);\n if (e.shiftKey) {\n // Shift+Tab: prevent default (would go to wrapper) and focus trigger instead\n e.preventDefault();\n focusTriggerElement();\n } else if (isWithPortal) {\n // Portal forward Tab: portal content is at document.body so natural Tab order\n // skips back to the top of the page. Manually advance to the next focusable\n // element after the trigger in the main document instead.\n e.preventDefault();\n const srcEl = srcElementRef.current;\n const focusables = getFocusableElements({ container: document.body, filterHidden: true });\n const idx = srcEl ? focusables.indexOf(srcEl) : -1;\n const next = focusables[idx + 1];\n if (next) next.focus();\n else srcEl?.focus();\n }\n // Non-portal forward Tab: do NOT preventDefault — browser moves focus to next element naturally\n }\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Home' || e.key === 'End') {\n // Handle arrow key navigation for focusable elements inside popover\n handleArrowKeyNavigation(e, popoverContentRef.current);\n } else if (e.key === 'Enter' || e.key === ' ') {\n // Prevent Enter/Space from bubbling to wrapper (mirrors click stopPropagation)\n e.stopPropagation();\n }\n };\n\n useImperativeHandle(ref, () => ({ togglePopover, focusTrigger: () => focusTriggerElement(), element: srcElementRef.current }), []);\n\n const popoverContentStyle = {\n 'bottom-left': { left: '0', top: '100%' },\n 'bottom-right': { right: '0', top: '100%' },\n 'bottom-center': { left: '50%', transform: 'translateX(-50%)', top: '100%' },\n 'top-left': { left: '0', bottom: '100%' },\n 'top-right': { right: '0', bottom: '100%' },\n 'top-center': { left: '50%', transform: 'translateX(-50%)', bottom: '100%' }\n };\n const popoverContentClasses = noBorder ? '' : 'shadow-md border rounded-md';\n\n return (\n <div\n className={\n 'se-design-popover-wrapper cursor-pointer relative focus-outline rounded-md' +\n (className.length > 0 ? ` ${className}` : '') +\n (displayPopover ? ' open' : '') +\n (disabled ? ' opacity-50 cursor-not-allowed pointer-events-none' : '')\n }\n ref={srcElementRef}\n onClick={(e) => {\n if (disabled || disableClickToggle) return;\n e.stopPropagation();\n togglePopover();\n }}\n onKeyDown={(e) => {\n if (disabled || disableClickToggle) return;\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n const wasOpen = displayPopover;\n togglePopover();\n // Focus first focusable element when opening.\n // Portal content isn't mounted until isSrcElementVisible resolves (via setTimeout 0),\n // so use a longer delay for portal to ensure popoverContentRef.current is set.\n if (!wasOpen) {\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }, isWithPortal ? 60 : 0);\n }\n } else if (e.key === 'Escape' && displayPopover) {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n } else if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && displayPopover) {\n // Handle arrow keys when popover is open\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n handleArrowKeyNavigation(e, currentRef);\n }\n } else if (e.key === 'ArrowDown' && !displayPopover) {\n // Open popover and focus first item when ArrowDown is pressed\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(true);\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }, 0);\n }\n }}\n onBlurCapture={onDismissBlurCapture}\n onBlur={(e) => {\n // Portal content is rendered outside wrapper, so keep explicit check for that case.\n if (!displayPopover || disableAutoClose || !isWithPortal) return;\n\n const nextFocused = e.relatedTarget as Node | null;\n const isFocusInSource = !!(nextFocused && srcElementRef.current?.contains(nextFocused));\n const isFocusInPopover = !!(nextFocused && popoverContentRef.current?.contains(nextFocused));\n\n // Close only when focus leaves both source and portal content.\n if (!isFocusInSource && !isFocusInPopover) {\n setDisplayPopover(false);\n }\n }}\n role={disableClickToggle ? 'none' : sourceRole}\n aria-expanded={disableClickToggle ? undefined : displayPopover ? 'true' : 'false'}\n aria-haspopup={disableClickToggle ? undefined : sourceRole === 'combobox' ? 'listbox' : popupType}\n tabIndex={disabled || disableClickToggle ? -1 : 0}\n aria-disabled={disableClickToggle ? undefined : disabled ? 'true' : undefined}\n {...accessibleNameProps}\n data-automation-id={automationId}\n {...props}\n >\n {renderPopoverSrcElement({ displayPopover, togglePopover })}\n\n {displayPopover && !isWithPortal && (\n <div\n className={`popover-content absolute ${popoverContentClasses} z-[1000] ${\n contentWidth == 'full' ? 'w-full' : 'w-max'\n }`}\n style={{\n ...popoverContentStyleProperty,\n ...popoverContentStyle[popoverPosition]\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={handlePopoverContentKeyDown}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: closePopover })}\n </div>\n )}\n {isWithPortal &&\n displayPopover &&\n isSrcElementVisible &&\n ReactDOM.createPortal(\n <div\n className={`popover-content-with-portal z-[2002] ${popoverContentClasses} ${\n contentWidth == 'full' ? '' : 'w-max'\n }`}\n style={{\n position: 'fixed',\n top: portalPosition.top,\n left: portalPosition.left,\n visibility: isPortalMeasured ? 'visible' : 'hidden',\n maxHeight: 'calc(100vh - 96px)',\n overflowY: 'hidden',\n ...(contentWidth === 'full' && portalPosition.srcWidth\n ? { width: `${portalPosition.srcWidth}px` }\n : {}),\n ...popoverContentStyleProperty,\n zIndex: 2002\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={handlePopoverContentKeyDown}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: closePopover })}\n </div>,\n document.body\n )}\n </div>\n );\n }\n);\n"],"names":["Popover","className","automationId","position","popoverContentAutomationId","contentWidth","renderPopoverContents","renderPopoverSrcElement","onPopoverToggle","isPopoverOpen","disabled","isWithPortal","ariaLabel","ariaLabelledBy","sourceRole","popupType","popoverContentStyleProperty","zIndex","borderColor","color","backgroundColor","disableClickToggle","noBorder","disableAutoClose","focusFirstOnOpen","props","ref","displayPopover","setDisplayPopover","useState","popoverPosition","setPopoverPosition","isSrcElementVisible","setIsSrcElementVisible","srcElementRef","useRef","popoverContentRef","useRegisterPortalWithFocusTrap","accessibleNameProps","getA11yNameAttributes","ariaDescribedBy","undefined","onBlurCapture","onDismissBlurCapture","useDismissOnFocusOut","onFocusOut","closeOnEscape","portalPosition","setPortalPosition","top","left","srcWidth","isPortalMeasured","setIsPortalMeasured","focusTriggerElement","getFirstFocusableElement","container","current","includeRoles","focus","closePopover","options","returnFocus","requestAnimationFrame","returnFocusTo","HTMLElement","calculatePositionOfPopover","localPosition","srcRect","getBoundingClientRect","scrollbarWidth","window","innerWidth","document","documentElement","clientWidth","viewportWidth","Math","max","viewportHeight","innerHeight","bottom","right","width","height","popoverRect","popoverWidth","popoverHeight","spaceAbove","spaceBelow","round","useEffect","body","addEventListener","clickListener","checkPopoverPosition","removeEventListener","scrollListenerForRepositioning","clickAndScrollListenerWithPortal","resizeListenerWithPortal","escapeHandler","e","key","contains","activeElement","preventDefault","stopPropagation","checkSourceVisibility","rafId1","rafId2","cancelAnimationFrame","rec","isVisible","setTimeout","firstFocusable","includes","event","currentDropRef","target","isSourcePopover","isPopoverContent","closestPopoverWrapper","closest","isAnotherPopoverSource","isNestedPopover","currentPopoverRef","type","togglePopover","focusFirst","wasOpen","prev","lastFocusable","getLastFocusableElement","handleArrowKeyNavigation","activeEl","tagName","focusableElements","Array","from","querySelectorAll","FOCUSABLE_WITH_ROLES_SELECTOR","filter","el","style","getComputedStyle","hasAttribute","getAttribute","display","visibility","tabIndex","length","currentIndex","findIndex","nextIndex","handlePopoverContentKeyDown","focusables","getFocusableElements","filterHidden","indexOf","isOnLast","isOnFirst","shiftKey","srcEl","allFocusables","idx","next","useImperativeHandle","focusTrigger","element","popoverContentStyle","transform","popoverContentClasses","React","createElement","_extends","onClick","onKeyDown","currentRef","onBlur","nextFocused","relatedTarget","isFocusInSource","isFocusInPopover","role","closePopoverCb","ReactDOM","createPortal","maxHeight","overflowY"],"mappings":";;;;;;;;;;;;;;;;AA4CO,MAAMA,wBACX,CAC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Ac,CACpD,GACLa,SAASmB,IACX,CACC;AAET,CACF;"}
|
package/dist/index207.js
CHANGED
|
@@ -1,42 +1,43 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { useFocusTrap as
|
|
1
|
+
import { useRef as l } from "react";
|
|
2
|
+
import { useFocusTrap as d } from "./index72.js";
|
|
3
3
|
import { useDismissOnEscape as c } from "./index215.js";
|
|
4
4
|
import { getA11yNameAttributes as f } from "./index81.js";
|
|
5
5
|
import { useStableId as p } from "./index205.js";
|
|
6
6
|
function x({
|
|
7
|
-
isOpen:
|
|
7
|
+
isOpen: t,
|
|
8
8
|
onDismiss: s,
|
|
9
9
|
ariaLabel: o,
|
|
10
|
-
ariaLabelledBy:
|
|
11
|
-
titleIdPrefix:
|
|
10
|
+
ariaLabelledBy: i,
|
|
11
|
+
titleIdPrefix: a = "modal-title",
|
|
12
12
|
initialFocus: m = "first",
|
|
13
13
|
portalContainerRefs: n
|
|
14
14
|
}) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
enabled:
|
|
18
|
-
containerRef:
|
|
15
|
+
const e = l(null), r = p(void 0, a);
|
|
16
|
+
d({
|
|
17
|
+
enabled: t,
|
|
18
|
+
containerRef: e,
|
|
19
19
|
restoreFocus: !0,
|
|
20
20
|
initialFocus: m,
|
|
21
21
|
portalContainerRefs: n
|
|
22
22
|
}), c({
|
|
23
|
-
containerRef:
|
|
23
|
+
containerRef: e,
|
|
24
24
|
onDismiss: s,
|
|
25
|
-
enabled:
|
|
25
|
+
enabled: t,
|
|
26
|
+
useDocumentListener: !0
|
|
26
27
|
});
|
|
27
|
-
const
|
|
28
|
+
const u = {
|
|
28
29
|
role: "dialog",
|
|
29
30
|
"aria-modal": !0,
|
|
30
31
|
tabIndex: -1,
|
|
31
32
|
...f({
|
|
32
|
-
ariaLabelledBy:
|
|
33
|
+
ariaLabelledBy: i ?? (o ? void 0 : r),
|
|
33
34
|
ariaLabel: o
|
|
34
35
|
})
|
|
35
36
|
};
|
|
36
37
|
return {
|
|
37
|
-
containerRef:
|
|
38
|
+
containerRef: e,
|
|
38
39
|
titleId: r,
|
|
39
|
-
dialogProps:
|
|
40
|
+
dialogProps: u
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
43
|
export {
|
package/dist/index207.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index207.js","sources":["../src/utils/a11y/useModalA11y.ts"],"sourcesContent":["import { useRef } from 'react';\nimport type { MutableRefObject, RefObject } from 'react';\nimport { useFocusTrap } from './useFocusTrap';\nimport { useDismissOnEscape } from './useDismissOnEscape';\nimport { getA11yNameAttributes } from './accessibleName';\nimport { useStableId } from 'src/utils/useStableId';\n\nexport interface UseModalA11yOptions {\n /**\n * Whether the modal is open. Controls focus trap and Escape handler activation.\n */\n isOpen: boolean;\n /**\n * Called when Escape is pressed while focus is within the modal.\n * If undefined, Escape dismissal is disabled.\n */\n onDismiss?: () => void;\n /**\n * aria-label for modals without a visible title heading.\n * Only used when `ariaLabelledBy` is not provided.\n */\n ariaLabel?: string;\n /**\n * ID of an existing visible element (e.g. an h2 inside the modal content) that labels\n * the dialog. Preferred over ariaLabel when a visible heading already exists in the content.\n * Only used when `title` is not provided.\n */\n ariaLabelledBy?: string;\n /**\n * Prefix for the auto-generated title element id. Default: 'modal-title'.\n */\n titleIdPrefix?: string;\n /**\n * Initial focus target when the modal opens. Forwarded to useFocusTrap.\n * - 'first': Focus first focusable element (default)\n * - 'container': Focus the dialog container itself\n * - 'none': Skip — browser handles it (e.g. autofocus attribute on inner element)\n * - CSS selector string: Focus matching element\n * - HTMLElement: Focus specific element\n */\n initialFocus?: 'first' | 'container' | 'none' | string | HTMLElement;\n /**\n * Additional container refs for portal content that is logically part of this modal.\n * Passed through to useFocusTrap and useDismissOnEscape so their safety nets\n * allow focus to move into portal-rendered content (e.g., Dropdown with isWithPortal).\n */\n portalContainerRefs?: MutableRefObject<RefObject<HTMLElement | null>[]>;\n}\n\nexport interface UseModalA11yReturn {\n /**\n * Ref to attach to the dialog container element.\n */\n containerRef: React.RefObject<HTMLDivElement | null>;\n /**\n * Stable ID to set on the visible title element: `<h2 id={titleId}>`.\n * Only relevant when `title` is provided.\n */\n titleId: string;\n /**\n * Spread onto the dialog container element.\n * Includes: role=\"dialog\", aria-modal, tabIndex, aria-labelledby or aria-label.\n */\n dialogProps: {\n role: 'dialog';\n 'aria-modal': true;\n tabIndex: number;\n [key: string]: unknown;\n };\n}\n\n/**\n * Bundles all WCAG dialog semantics into a single hook.\n *\n * Handles:\n * - Stable ID for title element (aria-labelledby association)\n * - Focus trap: moves focus into modal on open, wraps Tab, restores focus on close\n * - Escape dismissal: calls onDismiss when Escape is pressed within the modal\n * - dialogProps: role=\"dialog\", aria-modal, tabIndex, aria-labelledby / aria-label\n *\n * @example Modal with a visible title (most common)\n * ```tsx\n * const MyModal = ({ isOpen, onClose }) => {\n * const { containerRef, titleId, dialogProps } = useModalA11y({\n * isOpen,\n * onDismiss: onClose,\n * });\n *\n * return (\n * <div ref={containerRef} {...dialogProps} className=\"modal-content\">\n * <h2 id={titleId}>My Title</h2>\n * ...\n * </div>\n * );\n * };\n * ```\n *\n * @example Modal without a visible title\n * ```tsx\n * const { containerRef, dialogProps } = useModalA11y({\n * isOpen,\n * onDismiss: onClose,\n * ariaLabel: 'Upload document',\n * });\n * ```\n *\n * @example Custom initial focus (specific button) or skip (autofocus)\n * ```tsx\n * useModalA11y({ isOpen, onDismiss, initialFocus: '.my-cta-btn' });\n * useModalA11y({ isOpen, onDismiss, initialFocus: 'none' }); // autofocus on inner element\n * ```\n */\nexport function useModalA11y({\n isOpen,\n onDismiss,\n ariaLabel,\n ariaLabelledBy,\n titleIdPrefix = 'modal-title',\n initialFocus = 'first',\n portalContainerRefs,\n}: UseModalA11yOptions): UseModalA11yReturn {\n const containerRef = useRef<HTMLDivElement>(null);\n const titleId = useStableId(undefined, titleIdPrefix);\n\n useFocusTrap({\n enabled: isOpen,\n containerRef,\n restoreFocus: true,\n initialFocus,\n portalContainerRefs,\n });\n\n useDismissOnEscape({\n containerRef,\n onDismiss,\n enabled: isOpen,\n });\n\n const nameAttrs = getA11yNameAttributes({\n ariaLabelledBy: ariaLabelledBy ?? (ariaLabel ? undefined : titleId),\n ariaLabel: ariaLabel,\n });\n\n const dialogProps = {\n role: 'dialog' as const,\n 'aria-modal': true as const,\n tabIndex: -1,\n ...nameAttrs,\n };\n\n return { containerRef, titleId, dialogProps };\n}\n"],"names":["useRef","useFocusTrap","useDismissOnEscape","getA11yNameAttributes","useStableId","useModalA11y","isOpen","onDismiss","ariaLabel","ariaLabelledBy","titleIdPrefix","initialFocus","portalContainerRefs","containerRef","titleId","undefined","enabled","restoreFocus","dialogProps","role","tabIndex","nameAttrs"],"mappings":"AAgHO,SAAA,UAAAA,SAAA;AAAA,SAAA,gBAAAC,SAAA;AAAA,SAAA,sBAAAC,SAAA;AAAA,SAAA,yBAAAC,SAAA;AAAA,SAAA,eAAAC,SAAA;AAAA,SAASC,EAAa;AAAA,EAC3BC,QAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,eAAAA,IAAgB;AAAA,EAChBC,cAAAA,IAAe;AAAA,EACfC,qBAAAA;AACmB,GAAuB;AAC1C,QAAMC,IAAeb,EAAuB,IAAI,GAC1Cc,IAAUV,EAAYW,QAAWL,CAAa;AAEpDT,EAAAA,EAAa;AAAA,IACXe,SAASV;AAAAA,IACTO,cAAAA;AAAAA,IACAI,cAAc;AAAA,IACdN,cAAAA;AAAAA,IACAC,qBAAAA;AAAAA,EAAAA,CACD,GAEDV,EAAmB;AAAA,IACjBW,cAAAA;AAAAA,IACAN,WAAAA;AAAAA,IACAS,SAASV;AAAAA,
|
|
1
|
+
{"version":3,"file":"index207.js","sources":["../src/utils/a11y/useModalA11y.ts"],"sourcesContent":["import { useRef } from 'react';\nimport type { MutableRefObject, RefObject } from 'react';\nimport { useFocusTrap } from './useFocusTrap';\nimport { useDismissOnEscape } from './useDismissOnEscape';\nimport { getA11yNameAttributes } from './accessibleName';\nimport { useStableId } from 'src/utils/useStableId';\n\nexport interface UseModalA11yOptions {\n /**\n * Whether the modal is open. Controls focus trap and Escape handler activation.\n */\n isOpen: boolean;\n /**\n * Called when Escape is pressed while focus is within the modal.\n * If undefined, Escape dismissal is disabled.\n */\n onDismiss?: () => void;\n /**\n * aria-label for modals without a visible title heading.\n * Only used when `ariaLabelledBy` is not provided.\n */\n ariaLabel?: string;\n /**\n * ID of an existing visible element (e.g. an h2 inside the modal content) that labels\n * the dialog. Preferred over ariaLabel when a visible heading already exists in the content.\n * Only used when `title` is not provided.\n */\n ariaLabelledBy?: string;\n /**\n * Prefix for the auto-generated title element id. Default: 'modal-title'.\n */\n titleIdPrefix?: string;\n /**\n * Initial focus target when the modal opens. Forwarded to useFocusTrap.\n * - 'first': Focus first focusable element (default)\n * - 'container': Focus the dialog container itself\n * - 'none': Skip — browser handles it (e.g. autofocus attribute on inner element)\n * - CSS selector string: Focus matching element\n * - HTMLElement: Focus specific element\n */\n initialFocus?: 'first' | 'container' | 'none' | string | HTMLElement;\n /**\n * Additional container refs for portal content that is logically part of this modal.\n * Passed through to useFocusTrap and useDismissOnEscape so their safety nets\n * allow focus to move into portal-rendered content (e.g., Dropdown with isWithPortal).\n */\n portalContainerRefs?: MutableRefObject<RefObject<HTMLElement | null>[]>;\n}\n\nexport interface UseModalA11yReturn {\n /**\n * Ref to attach to the dialog container element.\n */\n containerRef: React.RefObject<HTMLDivElement | null>;\n /**\n * Stable ID to set on the visible title element: `<h2 id={titleId}>`.\n * Only relevant when `title` is provided.\n */\n titleId: string;\n /**\n * Spread onto the dialog container element.\n * Includes: role=\"dialog\", aria-modal, tabIndex, aria-labelledby or aria-label.\n */\n dialogProps: {\n role: 'dialog';\n 'aria-modal': true;\n tabIndex: number;\n [key: string]: unknown;\n };\n}\n\n/**\n * Bundles all WCAG dialog semantics into a single hook.\n *\n * Handles:\n * - Stable ID for title element (aria-labelledby association)\n * - Focus trap: moves focus into modal on open, wraps Tab, restores focus on close\n * - Escape dismissal: calls onDismiss when Escape is pressed within the modal\n * - dialogProps: role=\"dialog\", aria-modal, tabIndex, aria-labelledby / aria-label\n *\n * @example Modal with a visible title (most common)\n * ```tsx\n * const MyModal = ({ isOpen, onClose }) => {\n * const { containerRef, titleId, dialogProps } = useModalA11y({\n * isOpen,\n * onDismiss: onClose,\n * });\n *\n * return (\n * <div ref={containerRef} {...dialogProps} className=\"modal-content\">\n * <h2 id={titleId}>My Title</h2>\n * ...\n * </div>\n * );\n * };\n * ```\n *\n * @example Modal without a visible title\n * ```tsx\n * const { containerRef, dialogProps } = useModalA11y({\n * isOpen,\n * onDismiss: onClose,\n * ariaLabel: 'Upload document',\n * });\n * ```\n *\n * @example Custom initial focus (specific button) or skip (autofocus)\n * ```tsx\n * useModalA11y({ isOpen, onDismiss, initialFocus: '.my-cta-btn' });\n * useModalA11y({ isOpen, onDismiss, initialFocus: 'none' }); // autofocus on inner element\n * ```\n */\nexport function useModalA11y({\n isOpen,\n onDismiss,\n ariaLabel,\n ariaLabelledBy,\n titleIdPrefix = 'modal-title',\n initialFocus = 'first',\n portalContainerRefs,\n}: UseModalA11yOptions): UseModalA11yReturn {\n const containerRef = useRef<HTMLDivElement>(null);\n const titleId = useStableId(undefined, titleIdPrefix);\n\n useFocusTrap({\n enabled: isOpen,\n containerRef,\n restoreFocus: true,\n initialFocus,\n portalContainerRefs,\n });\n\n useDismissOnEscape({\n containerRef,\n onDismiss,\n enabled: isOpen,\n useDocumentListener: true,\n });\n\n const nameAttrs = getA11yNameAttributes({\n ariaLabelledBy: ariaLabelledBy ?? (ariaLabel ? undefined : titleId),\n ariaLabel: ariaLabel,\n });\n\n const dialogProps = {\n role: 'dialog' as const,\n 'aria-modal': true as const,\n tabIndex: -1,\n ...nameAttrs,\n };\n\n return { containerRef, titleId, dialogProps };\n}\n"],"names":["useRef","useFocusTrap","useDismissOnEscape","getA11yNameAttributes","useStableId","useModalA11y","isOpen","onDismiss","ariaLabel","ariaLabelledBy","titleIdPrefix","initialFocus","portalContainerRefs","containerRef","titleId","undefined","enabled","restoreFocus","useDocumentListener","dialogProps","role","tabIndex","nameAttrs"],"mappings":"AAgHO,SAAA,UAAAA,SAAA;AAAA,SAAA,gBAAAC,SAAA;AAAA,SAAA,sBAAAC,SAAA;AAAA,SAAA,yBAAAC,SAAA;AAAA,SAAA,eAAAC,SAAA;AAAA,SAASC,EAAa;AAAA,EAC3BC,QAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,eAAAA,IAAgB;AAAA,EAChBC,cAAAA,IAAe;AAAA,EACfC,qBAAAA;AACmB,GAAuB;AAC1C,QAAMC,IAAeb,EAAuB,IAAI,GAC1Cc,IAAUV,EAAYW,QAAWL,CAAa;AAEpDT,EAAAA,EAAa;AAAA,IACXe,SAASV;AAAAA,IACTO,cAAAA;AAAAA,IACAI,cAAc;AAAA,IACdN,cAAAA;AAAAA,IACAC,qBAAAA;AAAAA,EAAAA,CACD,GAEDV,EAAmB;AAAA,IACjBW,cAAAA;AAAAA,IACAN,WAAAA;AAAAA,IACAS,SAASV;AAAAA,IACTY,qBAAqB;AAAA,EAAA,CACtB;AAOD,QAAMC,IAAc;AAAA,IAClBC,MAAM;AAAA,IACN,cAAc;AAAA,IACdC,UAAU;AAAA,IACV,GATgBlB,EAAsB;AAAA,MACtCM,gBAAgBA,MAAmBD,IAAYO,SAAYD;AAAAA,MAC3DN,WAAAA;AAAAA,IAAAA,CACD;AAAA,EAMIc;AAGL,SAAO;AAAA,IAAET,cAAAA;AAAAA,IAAcC,SAAAA;AAAAA,IAASK,aAAAA;AAAAA,EAAAA;AAClC;"}
|
package/dist/index215.js
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
import { useEffect as d } from "react";
|
|
1
|
+
import { useCallback as y, useEffect as d } from "react";
|
|
2
2
|
function p({
|
|
3
|
-
containerRef:
|
|
3
|
+
containerRef: E,
|
|
4
4
|
onDismiss: e,
|
|
5
|
-
enabled:
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
enabled: t = !0,
|
|
6
|
+
useDocumentListener: u = !1,
|
|
7
|
+
preventDefault: c = !0,
|
|
8
|
+
stopPropagation: n = !0
|
|
8
9
|
}) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const f = y((r) => {
|
|
11
|
+
!t || !e || r.key !== "Escape" || (c && r.preventDefault(), n && r.stopPropagation(), e());
|
|
12
|
+
}, [t, e, c, n]);
|
|
13
|
+
return d(() => {
|
|
14
|
+
if (!u || !t || !e) return;
|
|
15
|
+
const r = E?.current, a = (o) => {
|
|
16
|
+
o.key === "Escape" && (r && !r.contains(document.activeElement) || (c && o.preventDefault(), n && o.stopPropagation(), e()));
|
|
15
17
|
};
|
|
16
18
|
return document.addEventListener("keydown", a, {
|
|
17
19
|
capture: !0
|
|
18
20
|
}), () => document.removeEventListener("keydown", a, {
|
|
19
21
|
capture: !0
|
|
20
22
|
});
|
|
21
|
-
}, [
|
|
23
|
+
}, [u, t, e, E, c, n]), {
|
|
24
|
+
onKeyDown: u ? () => {
|
|
25
|
+
} : f
|
|
26
|
+
};
|
|
22
27
|
}
|
|
23
28
|
export {
|
|
24
29
|
p as useDismissOnEscape
|
package/dist/index215.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index215.js","sources":["../src/utils/a11y/useDismissOnEscape.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { RefObject } from 'react';\n\nexport interface UseDismissOnEscapeOptions<T extends HTMLElement = HTMLElement> {\n /**\n * Container element ref
|
|
1
|
+
{"version":3,"file":"index215.js","sources":["../src/utils/a11y/useDismissOnEscape.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react';\nimport type { RefObject } from 'react';\n\nexport interface UseDismissOnEscapeOptions<T extends HTMLElement = HTMLElement> {\n /**\n * Container element ref — used for focus-check in document-level mode,\n * and for the returned onKeyDown in React-event mode.\n */\n containerRef?: RefObject<T | null>;\n /**\n * Callback when Escape key is pressed.\n */\n onDismiss?: () => void;\n /**\n * Whether the Escape handler is active.\n * Default: true\n */\n enabled?: boolean;\n /**\n * Use a native document-level capture listener instead of React's event system.\n * Only use this when React events can't reach the container (e.g. portals outside\n * the container's DOM tree). Prefer the default (false) for layered dismiss support.\n * Default: false\n */\n useDocumentListener?: boolean;\n /**\n * Whether to call e.preventDefault() on Escape.\n * Default: true\n */\n preventDefault?: boolean;\n /**\n * Whether to call e.stopPropagation() on Escape.\n * In React-event mode this is the layered-dismiss mechanism — set false only if\n * you want the event to continue bubbling to a parent dismiss handler.\n * Default: true\n */\n stopPropagation?: boolean;\n}\n\nexport interface UseDismissOnEscapeReturn {\n /**\n * Spread on the container element. In document-listener mode this is a no-op object.\n */\n onKeyDown: (e: React.KeyboardEvent) => void;\n}\n\n/**\n * Hook to handle Escape key dismissal.\n *\n * Default mode: returns an onKeyDown handler for the container element.\n * Uses React's synthetic events so child stopPropagation() is respected,\n * enabling layered dismiss (e.g. dropdown closes before sidebar).\n *\n * Document-listener mode (useDocumentListener: true): registers a native\n * capture listener on document. Use only when focus may be in a portal\n * outside the container's DOM tree.\n */\nexport function useDismissOnEscape<T extends HTMLElement = HTMLElement>({\n containerRef,\n onDismiss,\n enabled = true,\n useDocumentListener = false,\n preventDefault = true,\n stopPropagation = true,\n}: UseDismissOnEscapeOptions<T>): UseDismissOnEscapeReturn {\n // React-event mode: return handler to spread on container\n const onKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (!enabled || !onDismiss || e.key !== 'Escape') return;\n preventDefault && e.preventDefault();\n stopPropagation && e.stopPropagation();\n onDismiss();\n },\n [enabled, onDismiss, preventDefault, stopPropagation]\n );\n\n // Document-listener mode: native capture handler\n useEffect(() => {\n if (!useDocumentListener || !enabled || !onDismiss) return;\n\n const container = containerRef?.current;\n\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key !== 'Escape') return;\n // Only fire if focus is within the container (if provided)\n if (container && !container.contains(document.activeElement)) return;\n preventDefault && e.preventDefault();\n stopPropagation && e.stopPropagation();\n onDismiss();\n };\n\n document.addEventListener('keydown', handleEscape, { capture: true });\n return () => document.removeEventListener('keydown', handleEscape, { capture: true });\n }, [useDocumentListener, enabled, onDismiss, containerRef, preventDefault, stopPropagation]);\n\n return { onKeyDown: useDocumentListener ? (() => {}) : onKeyDown };\n}\n"],"names":["useCallback","useEffect","useDismissOnEscape","containerRef","onDismiss","enabled","useDocumentListener","preventDefault","stopPropagation","onKeyDown","e","key","container","current","handleEscape","contains","document","activeElement","addEventListener","capture","removeEventListener"],"mappings":"AAyDO,SAAA,eAAAA,GAAA,aAAAC,SAAA;AAAA,SAASC,EAAwD;AAAA,EACtEC,cAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,SAAAA,IAAU;AAAA,EACVC,qBAAAA,IAAsB;AAAA,EACtBC,gBAAAA,IAAiB;AAAA,EACjBC,iBAAAA,IAAkB;AACU,GAA6B;AAEzD,QAAMC,IAAYT,EAChB,CAACU,MAA2B;AAC1B,IAAI,CAACL,KAAW,CAACD,KAAaM,EAAEC,QAAQ,aACxCJ,KAAkBG,EAAEH,eAAAA,GACpBC,KAAmBE,EAAEF,gBAAAA,GACrBJ,EAAAA;AAAAA,EACF,GACA,CAACC,GAASD,GAAWG,GAAgBC,CAAe,CACtD;AAGAP,SAAAA,EAAU,MAAM;AACd,QAAI,CAACK,KAAuB,CAACD,KAAW,CAACD,EAAW;AAEpD,UAAMQ,IAAYT,GAAcU,SAE1BC,IAAeA,CAACJ,MAAqB;AACzC,MAAIA,EAAEC,QAAQ,aAEVC,KAAa,CAACA,EAAUG,SAASC,SAASC,aAAa,MAC3DV,KAAkBG,EAAEH,eAAAA,GACpBC,KAAmBE,EAAEF,gBAAAA,GACrBJ,EAAAA;AAAAA,IACF;AAEAY,oBAASE,iBAAiB,WAAWJ,GAAc;AAAA,MAAEK,SAAS;AAAA,IAAA,CAAM,GAC7D,MAAMH,SAASI,oBAAoB,WAAWN,GAAc;AAAA,MAAEK,SAAS;AAAA,IAAA,CAAM;AAAA,EACtF,GAAG,CAACb,GAAqBD,GAASD,GAAWD,GAAcI,GAAgBC,CAAe,CAAC,GAEpF;AAAA,IAAEC,WAAWH,IAAuB,MAAM;AAAA,IAAC,IAAKG;AAAAA,EAAAA;AACzD;"}
|
package/dist/index22.js
CHANGED
|
@@ -1,64 +1,69 @@
|
|
|
1
|
-
import t, { useRef as
|
|
2
|
-
import { TableContentLoader as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import t, { useRef as i, useEffect as L } from "react";
|
|
2
|
+
import { TableContentLoader as O } from "./index27.js";
|
|
3
|
+
import { announce as b } from "./index75.js";
|
|
4
|
+
function f() {
|
|
5
|
+
return f = Object.assign ? Object.assign.bind() : function(r) {
|
|
6
|
+
for (var l = 1; l < arguments.length; l++) {
|
|
7
|
+
var e = arguments[l];
|
|
8
|
+
for (var a in e) ({}).hasOwnProperty.call(e, a) && (r[a] = e[a]);
|
|
8
9
|
}
|
|
9
|
-
return
|
|
10
|
-
},
|
|
10
|
+
return r;
|
|
11
|
+
}, f.apply(null, arguments);
|
|
11
12
|
}
|
|
12
|
-
const
|
|
13
|
-
className:
|
|
14
|
-
automationId:
|
|
13
|
+
const _ = ({
|
|
14
|
+
className: r = "",
|
|
15
|
+
automationId: l = "",
|
|
15
16
|
loading: e,
|
|
16
|
-
headerColSpan:
|
|
17
|
-
headerData:
|
|
18
|
-
tableData:
|
|
19
|
-
renderTableContentLoader:
|
|
20
|
-
getTableHeaders:
|
|
21
|
-
getTableBody:
|
|
22
|
-
getTableFooter:
|
|
23
|
-
onSortUiUpdate:
|
|
24
|
-
onRowClick:
|
|
25
|
-
tableId:
|
|
26
|
-
ariaDescribedBy:
|
|
27
|
-
ariaLabel:
|
|
28
|
-
|
|
17
|
+
headerColSpan: a = [],
|
|
18
|
+
headerData: c,
|
|
19
|
+
tableData: o,
|
|
20
|
+
renderTableContentLoader: R,
|
|
21
|
+
getTableHeaders: m,
|
|
22
|
+
getTableBody: p,
|
|
23
|
+
getTableFooter: v,
|
|
24
|
+
onSortUiUpdate: d,
|
|
25
|
+
onRowClick: h,
|
|
26
|
+
tableId: E,
|
|
27
|
+
ariaDescribedBy: x,
|
|
28
|
+
ariaLabel: w,
|
|
29
|
+
loadingAnnouncement: s,
|
|
30
|
+
loadedAnnouncement: n,
|
|
31
|
+
...y
|
|
29
32
|
}) => {
|
|
30
|
-
const
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
},
|
|
33
|
+
const g = i(null), u = i(!1);
|
|
34
|
+
return L(() => {
|
|
35
|
+
e !== u.current && (u.current = e, e && s ? b(s) : !e && n && b(n));
|
|
36
|
+
}, [e, s, n]), /* @__PURE__ */ t.createElement("div", f({
|
|
37
|
+
className: "se-design-table-layout-wrapper flex flex-col flex-1 min-h-0" + (r.length > 0 ? ` ${r}` : "") + (e ? " table-data-loading" : "")
|
|
38
|
+
}, y), /* @__PURE__ */ t.createElement("div", {
|
|
34
39
|
className: "se-design-table-scroll-area flex-1 min-h-0 overflow-y-auto"
|
|
35
40
|
}, /* @__PURE__ */ t.createElement("table", {
|
|
36
41
|
className: "se-design-table w-full bg-[var(--color-white)] border-collapse table-fixed",
|
|
37
|
-
ref:
|
|
38
|
-
"data-automation-id":
|
|
39
|
-
id:
|
|
40
|
-
"aria-describedby":
|
|
41
|
-
"aria-label":
|
|
42
|
-
}, /* @__PURE__ */ t.createElement("thead", null, /* @__PURE__ */ t.createElement("tr", null,
|
|
43
|
-
headerData:
|
|
42
|
+
ref: g,
|
|
43
|
+
"data-automation-id": l,
|
|
44
|
+
id: E,
|
|
45
|
+
"aria-describedby": x,
|
|
46
|
+
"aria-label": w
|
|
47
|
+
}, /* @__PURE__ */ t.createElement("thead", null, /* @__PURE__ */ t.createElement("tr", null, m({
|
|
48
|
+
headerData: c,
|
|
44
49
|
sortData: {},
|
|
45
|
-
onSortUiUpdate:
|
|
50
|
+
onSortUiUpdate: d,
|
|
46
51
|
loading: e
|
|
47
|
-
}))), /* @__PURE__ */ t.createElement("tbody", null, e ? /* @__PURE__ */ t.createElement(
|
|
48
|
-
noOfColumns:
|
|
49
|
-
colSpan:
|
|
50
|
-
}) :
|
|
51
|
-
tableData:
|
|
52
|
-
onRowClick:
|
|
52
|
+
}))), /* @__PURE__ */ t.createElement("tbody", null, e ? /* @__PURE__ */ t.createElement(O, {
|
|
53
|
+
noOfColumns: c?.length,
|
|
54
|
+
colSpan: a
|
|
55
|
+
}) : p({
|
|
56
|
+
tableData: o,
|
|
57
|
+
onRowClick: h,
|
|
53
58
|
loading: e
|
|
54
59
|
})))), /* @__PURE__ */ t.createElement("div", {
|
|
55
60
|
className: "se-design-table-footer w-full bg-[var(--color-white)] flex-shrink-0"
|
|
56
|
-
},
|
|
57
|
-
tableData:
|
|
61
|
+
}, v({
|
|
62
|
+
tableData: o,
|
|
58
63
|
loading: e
|
|
59
64
|
})));
|
|
60
65
|
};
|
|
61
66
|
export {
|
|
62
|
-
|
|
67
|
+
_ as TableLayout
|
|
63
68
|
};
|
|
64
69
|
//# sourceMappingURL=index22.js.map
|
package/dist/index22.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index22.js","sources":["../src/components/TableLayout/index.tsx"],"sourcesContent":["import React, { FC, ReactNode, useRef } from 'react';\nimport { TableContentLoader } from 'components/TableContentLoader';\n\nexport interface TableLayoutProps {\n className?: string;\n automationId?: string;\n loading: boolean;\n headerData: any[];\n tableData: any[];\n headerColSpan?: number[];\n renderTableContentLoader?: (noOfColumns: number) => ReactNode;\n getTableHeaders: (props: { headerData: any[]; sortData: any; onSortUiUpdate: any; loading: boolean }) => ReactNode;\n getTableBody: (props: { tableData: any[]; onRowClick: any; loading: boolean }) => ReactNode;\n getTableFooter: (props: { tableData: any[]; loading: boolean }) => ReactNode;\n onSortUiUpdate: (newSortData: any) => void;\n onRowClick: (rowData: any) => void;\n tableId: string;\n /**\n * ID of element that describes the table (e.g., sort instructions for screen readers)\n */\n ariaDescribedBy?: string;\n /**\n * Accessible name for the table element\n */\n ariaLabel?: string;\n}\n\nexport const TableLayout: FC<TableLayoutProps> = ({\n className = '',\n automationId = '',\n loading,\n headerColSpan = [],\n headerData,\n tableData,\n renderTableContentLoader,\n getTableHeaders,\n getTableBody,\n getTableFooter,\n onSortUiUpdate,\n onRowClick,\n tableId,\n ariaDescribedBy,\n ariaLabel,\n ...props\n}) => {\n const tableRef = useRef<HTMLTableElement>(null);\n\n return (\n <div className={'se-design-table-layout-wrapper flex flex-col flex-1 min-h-0' + (className.length > 0 ? ` ${className}` : '') + (loading? ' table-data-loading' : '')} {...props}>\n <div className=\"se-design-table-scroll-area flex-1 min-h-0 overflow-y-auto\">\n <table\n className={'se-design-table w-full bg-[var(--color-white)] border-collapse table-fixed'}\n ref={tableRef}\n data-automation-id={automationId}\n id={tableId}\n aria-describedby={ariaDescribedBy}\n aria-label={ariaLabel}\n >\n <thead>\n <tr>{getTableHeaders({ headerData, sortData: {}, onSortUiUpdate, loading })}</tr>\n </thead>\n <tbody>\n {loading ? (\n <TableContentLoader noOfColumns={headerData?.length} colSpan={headerColSpan} />\n ) : (\n getTableBody({ tableData, onRowClick, loading })\n )}\n </tbody>\n </table>\n </div>\n <div className=\"se-design-table-footer w-full bg-[var(--color-white)] flex-shrink-0\">\n {getTableFooter({ tableData, loading })}\n </div>\n </div>\n );\n};\n"],"names":["TableLayout","className","automationId","loading","headerColSpan","headerData","tableData","renderTableContentLoader","getTableHeaders","getTableBody","getTableFooter","onSortUiUpdate","onRowClick","tableId","ariaDescribedBy","ariaLabel","props","tableRef","useRef","React","createElement","_extends","length","ref","id","sortData","TableContentLoader","noOfColumns","colSpan"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index22.js","sources":["../src/components/TableLayout/index.tsx"],"sourcesContent":["import React, { FC, ReactNode, useEffect, useRef } from 'react';\nimport { TableContentLoader } from 'components/TableContentLoader';\nimport { announce } from 'src/utils/a11y/liveAnnouncer/LiveAnnouncer';\n\nexport interface TableLayoutProps {\n className?: string;\n automationId?: string;\n loading: boolean;\n headerData: any[];\n tableData: any[];\n headerColSpan?: number[];\n renderTableContentLoader?: (noOfColumns: number) => ReactNode;\n getTableHeaders: (props: { headerData: any[]; sortData: any; onSortUiUpdate: any; loading: boolean }) => ReactNode;\n getTableBody: (props: { tableData: any[]; onRowClick: any; loading: boolean }) => ReactNode;\n getTableFooter: (props: { tableData: any[]; loading: boolean }) => ReactNode;\n onSortUiUpdate: (newSortData: any) => void;\n onRowClick: (rowData: any) => void;\n tableId: string;\n /**\n * ID of element that describes the table (e.g., sort instructions for screen readers)\n */\n ariaDescribedBy?: string;\n /**\n * Accessible name for the table element\n */\n ariaLabel?: string;\n /**\n * Announced to screen readers when loading begins.\n * Pass a translated string from the consumer (e.g. \"Loading documents\").\n */\n loadingAnnouncement?: string;\n /**\n * Announced to screen readers when loading completes.\n * Pass a translated string from the consumer (e.g. \"Documents loaded\").\n */\n loadedAnnouncement?: string;\n}\n\nexport const TableLayout: FC<TableLayoutProps> = ({\n className = '',\n automationId = '',\n loading,\n headerColSpan = [],\n headerData,\n tableData,\n renderTableContentLoader,\n getTableHeaders,\n getTableBody,\n getTableFooter,\n onSortUiUpdate,\n onRowClick,\n tableId,\n ariaDescribedBy,\n ariaLabel,\n loadingAnnouncement,\n loadedAnnouncement,\n ...props\n}) => {\n const tableRef = useRef<HTMLTableElement>(null);\n const prevLoadingRef = useRef(false);\n\n useEffect(() => {\n if (loading === prevLoadingRef.current) return;\n prevLoadingRef.current = loading;\n if (loading && loadingAnnouncement) {\n announce(loadingAnnouncement);\n } else if (!loading && loadedAnnouncement) {\n announce(loadedAnnouncement);\n }\n }, [loading, loadingAnnouncement, loadedAnnouncement]);\n\n return (\n <div className={'se-design-table-layout-wrapper flex flex-col flex-1 min-h-0' + (className.length > 0 ? ` ${className}` : '') + (loading? ' table-data-loading' : '')} {...props}>\n <div className=\"se-design-table-scroll-area flex-1 min-h-0 overflow-y-auto\">\n <table\n className={'se-design-table w-full bg-[var(--color-white)] border-collapse table-fixed'}\n ref={tableRef}\n data-automation-id={automationId}\n id={tableId}\n aria-describedby={ariaDescribedBy}\n aria-label={ariaLabel}\n >\n <thead>\n <tr>{getTableHeaders({ headerData, sortData: {}, onSortUiUpdate, loading })}</tr>\n </thead>\n <tbody>\n {loading ? (\n <TableContentLoader noOfColumns={headerData?.length} colSpan={headerColSpan} />\n ) : (\n getTableBody({ tableData, onRowClick, loading })\n )}\n </tbody>\n </table>\n </div>\n <div className=\"se-design-table-footer w-full bg-[var(--color-white)] flex-shrink-0\">\n {getTableFooter({ tableData, loading })}\n </div>\n </div>\n );\n};\n"],"names":["TableLayout","className","automationId","loading","headerColSpan","headerData","tableData","renderTableContentLoader","getTableHeaders","getTableBody","getTableFooter","onSortUiUpdate","onRowClick","tableId","ariaDescribedBy","ariaLabel","loadingAnnouncement","loadedAnnouncement","props","tableRef","useRef","prevLoadingRef","useEffect","current","announce","React","createElement","_extends","length","ref","id","sortData","TableContentLoader","noOfColumns","colSpan"],"mappings":";;;;;;;;;;;;AAsCO,MAAMA,IAAoCA,CAAC;AAAA,EAChDC,WAAAA,IAAY;AAAA,EACZC,cAAAA,IAAe;AAAA,EACfC,SAAAA;AAAAA,EACAC,eAAAA,IAAgB,CAAA;AAAA,EAChBC,YAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,0BAAAA;AAAAA,EACAC,iBAAAA;AAAAA,EACAC,cAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,YAAAA;AAAAA,EACAC,SAAAA;AAAAA,EACAC,iBAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,qBAAAA;AAAAA,EACAC,oBAAAA;AAAAA,EACA,GAAGC;AACL,MAA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