se-design 1.0.76-dev1 → 1.0.76-dev2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +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';\n\nexport interface PopoverHandle {\n togglePopover: (focusFirst?: boolean | 'last') => void;\n}\n\nexport interface PopoverProps {\n className?: string;\n automationId?: string;\n popoverContentAutomationId?: string;\n renderPopoverContents: (props: { closePopoverCb: () => 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 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 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 // 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 });\n\n const calculatePositionOfPopover = (position: string = 'bottom-center') => {\n if (!srcElementRef.current) return { top: 0, left: 0 };\n\n let localPosition = position;\n\n const srcRect = srcElementRef.current.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\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 const popoverWidth = 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 viewport\n if (top < 0) {\n top = 0;\n }\n } else {\n // Keep at bottom but adjust to fit within viewport\n top = Math.max(0, viewportHeight - popoverHeight);\n }\n }\n if (top < 0) {\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(0, viewportHeight - popoverHeight);\n }\n }\n\n return { top, left };\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 // Initial position calculation\n const timeout1 = setTimeout(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n checkSourceVisibility();\n\n if (position) {\n setPortalPosition(position);\n }\n }, 0);\n\n // Recalculate after popover is rendered to get accurate dimensions\n const timeout2 = setTimeout(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }, 10);\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 clearTimeout(timeout1);\n clearTimeout(timeout2);\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 srcElementRef.current?.focus();\n } else if (e.key === 'Tab') {\n // 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 srcElementRef.current?.focus();\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 } 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 }), []);\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' : 'true'}\n tabIndex={disabled || disableClickToggle ? -1 : 0}\n aria-disabled={disableClickToggle ? undefined : disabled ? 'true' : 'false'}\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: () => setDisplayPopover(false) })}\n </div>\n )}\n {isWithPortal &&\n displayPopover &&\n isSrcElementVisible &&\n ReactDOM.createPortal(\n <div\n className={`popover-content-with-portal ${popoverContentClasses} ${\n contentWidth == 'full' ? 'w-full' : 'w-max'\n }`}\n style={{\n position: 'fixed',\n top: portalPosition.top,\n left: portalPosition.left,\n ...popoverContentStyleProperty\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={handlePopoverContentKeyDown}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: () => setDisplayPopover(false) })}\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","popoverContentStyleProperty","zIndex","borderColor","color","backgroundColor","disableClickToggle","noBorder","disableAutoClose","focusFirstOnOpen","props","ref","displayPopover","setDisplayPopover","useState","popoverPosition","setPopoverPosition","isSrcElementVisible","setIsSrcElementVisible","srcElementRef","useRef","popoverContentRef","accessibleNameProps","getA11yNameAttributes","ariaDescribedBy","undefined","onBlurCapture","onDismissBlurCapture","useDismissOnFocusOut","onFocusOut","closeOnEscape","portalPosition","setPortalPosition","top","left","calculatePositionOfPopover","current","localPosition","srcRect","getBoundingClientRect","viewportWidth","window","innerWidth","viewportHeight","innerHeight","bottom","right","width","height","popoverRect","popoverWidth","popoverHeight","Math","max","spaceAbove","spaceBelow","useEffect","document","body","addEventListener","clickListener","checkPopoverPosition","removeEventListener","scrollListenerForRepositioning","clickAndScrollListenerWithPortal","resizeListenerWithPortal","timeout1","setTimeout","checkSourceVisibility","timeout2","clearTimeout","rec","isVisible","firstFocusable","getFirstFocusableElement","container","includeRoles","activeElement","focus","includes","event","currentDropRef","target","isSourcePopover","contains","isPopoverContent","closestPopoverWrapper","closest","isAnotherPopoverSource","isNestedPopover","currentPopoverRef","type","togglePopover","focusFirst","wasOpen","prev","lastFocusable","getLastFocusableElement","handleArrowKeyNavigation","e","activeEl","tagName","focusableElements","Array","from","querySelectorAll","FOCUSABLE_WITH_ROLES_SELECTOR","filter","el","style","getComputedStyle","hasAttribute","getAttribute","display","visibility","tabIndex","length","currentIndex","findIndex","nextIndex","key","preventDefault","stopPropagation","handlePopoverContentKeyDown","shiftKey","srcEl","focusables","getFocusableElements","filterHidden","idx","indexOf","next","useImperativeHandle","popoverContentStyle","transform","popoverContentClasses","React","createElement","_extends","onClick","onKeyDown","currentRef","onBlur","nextFocused","relatedTarget","isFocusInSource","isFocusInPopover","role","closePopoverCb","ReactDOM","createPortal"],"mappings":";;;;;;;;;;;;;;;AAsCO,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,6BAAAA,IAA8B;AAAA,IAC5BC,QAAQ;AAAA,IACRC,aAAa;AAAA,IACbC,OAAO;AAAA,IACPC,iBAAiB;AAAA,EAAA;AAAA,EAEnBC,oBAAAA,IAAqB;AAAA,EACrBC,UAAAA,IAAW;AAAA,EACXC,kBAAAA,IAAmB;AAAA,EACnBC,kBAAAA,KAAmB;AAAA,EACnB,GAAGC;AACL,GACAC,OACG;AACH,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAK,GACpD,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,OAAA;AAAA,IACEtJ,WAAW,4BAA4BoJ,CAAqB,aAC1DhJ,KAAgB,SAAS,WAAW,OAAO;AAAA,IAE7CsH,OAAO;AAAA,MACL,GAAG5G;AAAAA,MACH,GAAGoI,GAAoBtH,CAAe;AAAA,IAAA;AAAA,IAExC4H,SAAUxC,CAAAA,MAAMA,EAAEuB,gBAAAA;AAAAA,IAClBkB,WAAWjB;AAAAA,IACXhH,KAAKU;AAAAA,IACL,sBAAoB/B;AAAAA,EAAAA,GAEnBE,EAAsB;AAAA,IAAE4J,gBAAgBA,MAAMvI,EAAkB,EAAK;AAAA,EAAA,CAAG,CACtE,GAENhB,KACCe,KACAK,MACAoI,gBAAAA,GAASC,aACPd,gBAAAA,EAAAC,cAAA,OAAA;AAAA,IACEtJ,WAAW,+BAA+BoJ,CAAqB,IAC7DhJ,KAAgB,SAAS,WAAW,OAAO;AAAA,IAE7CsH,OAAO;AAAA,MACLxH,UAAU;AAAA,MACV4C,KAAKF,EAAeE;AAAAA,MACpBC,MAAMH,EAAeG;AAAAA,MACrB,GAAGjC;AAAAA,IAAAA;AAAAA,IAEL0I,SAAUxC,CAAAA,MAAMA,EAAEuB,gBAAAA;AAAAA,IAClBkB,WAAWjB;AAAAA,IACXhH,KAAKU;AAAAA,IACL,sBAAoB/B;AAAAA,EAAAA,GAEnBE,EAAsB;AAAA,IAAE4J,gBAAgBA,MAAMvI,EAAkB,EAAK;AAAA,EAAA,CAAG,CACtE,GACL4C,SAASC,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';\n\nexport interface PopoverHandle {\n togglePopover: (focusFirst?: boolean | 'last') => void;\n}\n\nexport interface PopoverProps {\n className?: string;\n automationId?: string;\n popoverContentAutomationId?: string;\n renderPopoverContents: (props: { closePopoverCb: () => 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 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 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 // 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\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 const viewportWidth = window.innerWidth;\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 const popoverWidth = 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 viewport\n if (top < 0) {\n top = 0;\n }\n } else {\n // Keep at bottom but adjust to fit within viewport\n top = Math.max(0, viewportHeight - popoverHeight);\n }\n }\n if (top < 0) {\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(0, viewportHeight - popoverHeight);\n }\n }\n\n return { top, 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 // Initial position calculation\n const timeout1 = setTimeout(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n checkSourceVisibility();\n\n if (position) {\n setPortalPosition(position);\n }\n }, 0);\n\n // Recalculate after popover is rendered to get accurate dimensions\n const timeout2 = setTimeout(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }, 10);\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 clearTimeout(timeout1);\n clearTimeout(timeout2);\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 srcElementRef.current?.focus();\n } else if (e.key === 'Tab') {\n // 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 srcElementRef.current?.focus();\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 } 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 }), []);\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' : 'true'}\n tabIndex={disabled || disableClickToggle ? -1 : 0}\n aria-disabled={disableClickToggle ? undefined : disabled ? 'true' : 'false'}\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: () => setDisplayPopover(false) })}\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 ...(contentWidth === 'full' && portalPosition.srcWidth\n ? { width: `${portalPosition.srcWidth}px` }\n : {}),\n ...popoverContentStyleProperty\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={handlePopoverContentKeyDown}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: () => setDisplayPopover(false) })}\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","popoverContentStyleProperty","zIndex","borderColor","color","backgroundColor","disableClickToggle","noBorder","disableAutoClose","focusFirstOnOpen","props","ref","displayPopover","setDisplayPopover","useState","popoverPosition","setPopoverPosition","isSrcElementVisible","setIsSrcElementVisible","srcElementRef","useRef","popoverContentRef","accessibleNameProps","getA11yNameAttributes","ariaDescribedBy","undefined","onBlurCapture","onDismissBlurCapture","useDismissOnFocusOut","onFocusOut","closeOnEscape","portalPosition","setPortalPosition","top","left","srcWidth","calculatePositionOfPopover","current","localPosition","srcRect","getBoundingClientRect","viewportWidth","window","innerWidth","viewportHeight","innerHeight","bottom","right","width","height","popoverRect","popoverWidth","popoverHeight","Math","max","spaceAbove","spaceBelow","useEffect","document","body","addEventListener","clickListener","checkPopoverPosition","removeEventListener","scrollListenerForRepositioning","clickAndScrollListenerWithPortal","resizeListenerWithPortal","timeout1","setTimeout","checkSourceVisibility","timeout2","clearTimeout","rec","isVisible","firstFocusable","getFirstFocusableElement","container","includeRoles","activeElement","focus","includes","event","currentDropRef","target","isSourcePopover","contains","isPopoverContent","closestPopoverWrapper","closest","isAnotherPopoverSource","isNestedPopover","currentPopoverRef","type","togglePopover","focusFirst","wasOpen","prev","lastFocusable","getLastFocusableElement","handleArrowKeyNavigation","e","activeEl","tagName","focusableElements","Array","from","querySelectorAll","FOCUSABLE_WITH_ROLES_SELECTOR","filter","el","style","getComputedStyle","hasAttribute","getAttribute","display","visibility","tabIndex","length","currentIndex","findIndex","nextIndex","key","preventDefault","stopPropagation","handlePopoverContentKeyDown","shiftKey","srcEl","focusables","getFocusableElements","filterHidden","idx","indexOf","next","useImperativeHandle","popoverContentStyle","transform","popoverContentClasses","React","createElement","_extends","onClick","onKeyDown","currentRef","onBlur","nextFocused","relatedTarget","isFocusInSource","isFocusInPopover","role","closePopoverCb","ReactDOM","createPortal"],"mappings":";;;;;;;;;;;;;;;AAsCO,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,6BAAAA,IAA8B;AAAA,IAC5BC,QAAQ;AAAA,IACRC,aAAa;AAAA,IACbC,OAAO;AAAA,IACPC,iBAAiB;AAAA,EAAA;AAAA,EAEnBC,oBAAAA,IAAqB;AAAA,EACrBC,UAAAA,IAAW;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,EAASzB,CAAQ,GACzD,CAAC4B,IAAqBC,CAAsB,IAAIJ,EAAS,EAAK,GAC9DK,IAAgBC,EAAuB,IAAI,GAC3CC,IAAoBD,EAAuB,IAAI,GAG/CE,KAAsBC,GAAsB;AAAA,IAChDzB,WAAAA;AAAAA,IACAC,gBAAAA;AAAAA,IACAyB,iBAAiBC;AAAAA;AAAAA,EAAAA,CAClB,GAIK;AAAA,IAAEC,eAAeC;AAAAA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6H,SAAUxC,CAAAA,MAAMA,EAAEuB,gBAAAA;AAAAA,IAClBkB,WAAWjB;AAAAA,IACXjH,KAAKU;AAAAA,IACL,sBAAoB/B;AAAAA,EAAAA,GAEnBE,EAAsB;AAAA,IAAE6J,gBAAgBA,MAAMxI,EAAkB,EAAK;AAAA,EAAA,CAAG,CACtE,GAENhB,KACCe,KACAK,MACAqI,gBAAAA,GAASC,aACPd,gBAAAA,EAAAC,cAAA,OAAA;AAAA,IACEvJ,WAAW,wCAAwCqJ,CAAqB,IACtEjJ,KAAgB,SAAS,KAAK,OAAO;AAAA,IAEvCuH,OAAO;AAAA,MACLzH,UAAU;AAAA,MACV4C,KAAKF,EAAeE;AAAAA,MACpBC,MAAMH,EAAeG;AAAAA,MACrB,GAAI3C,MAAiB,UAAUwC,EAAeI,WAC1C;AAAA,QAAEa,OAAO,GAAGjB,EAAeI,QAAQ;AAAA,MAAA,IACnC,CAAA;AAAA,MACJ,GAAGlC;AAAAA,IAAAA;AAAAA,IAEL2I,SAAUxC,CAAAA,MAAMA,EAAEuB,gBAAAA;AAAAA,IAClBkB,WAAWjB;AAAAA,IACXjH,KAAKU;AAAAA,IACL,sBAAoB/B;AAAAA,EAAAA,GAEnBE,EAAsB;AAAA,IAAE6J,gBAAgBA,MAAMxI,EAAkB,EAAK;AAAA,EAAA,CAAG,CACtE,GACL6C,SAASC,IACX,CACC;AAET,CACF;"}
package/dist/index25.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import n, { useState as I, useRef as L, useEffect as D } from "react";
2
- import { Popover as Ie } from "./index19.js";
3
- import { Icon as G } from "./index6.js";
4
- import { Checkbox as De } from "./index23.js";
5
- import { Button as Y } from "./index4.js";
6
- import { InputWithIcon as ke } from "./index52.js";
7
- import { useStableId as Z } from "./index199.js";
8
- import { useCombobox as Ve } from "./index68.js";
2
+ import { Popover as De } from "./index19.js";
3
+ import { Icon as Y } from "./index6.js";
4
+ import { Checkbox as ke } from "./index23.js";
5
+ import { Button as Z } from "./index4.js";
6
+ import { InputWithIcon as Ve } from "./index52.js";
7
+ import { useStableId as ee } from "./index199.js";
8
+ import { useCombobox as Ne } from "./index68.js";
9
9
  function h() {
10
10
  return h = Object.assign ? Object.assign.bind() : function(t) {
11
11
  for (var m = 1; m < arguments.length; m++) {
@@ -15,30 +15,31 @@ function h() {
15
15
  return t;
16
16
  }, h.apply(null, arguments);
17
17
  }
18
- const Ke = (t) => {
19
- const m = t.selectedValue !== void 0, b = t.isOpen !== void 0, [v, ee] = I(!1), [k, R] = I(""), [i, S] = I(-1), [te, K] = I(() => t?.defaultSelectedValue ? Array.isArray(t?.defaultSelectedValue) ? t?.defaultSelectedValue : [t.defaultSelectedValue] : []), M = L(null), V = L(null), N = L(null), T = Z(void 0, "dropdown-label"), g = Z(void 0, "dropdown-listbox"), d = b ? t.isOpen : v, r = m ? Array.isArray(t.selectedValue) ? t.selectedValue : t.selectedValue ? [t.selectedValue] : [] : te, $ = (e) => {
20
- b || ee(e), t.onOpenChange?.(e);
21
- }, P = (e) => {
18
+ const Me = (t) => {
19
+ const m = t.selectedValue !== void 0, b = t.isOpen !== void 0, [v, te] = I(!1), [k, R] = I(""), [i, S] = I(-1), [oe, K] = I(() => t?.defaultSelectedValue ? Array.isArray(t?.defaultSelectedValue) ? t?.defaultSelectedValue : [t.defaultSelectedValue] : []), M = L(null), V = L(null), N = L(null), T = ee(void 0, "dropdown-label"), g = ee(void 0, "dropdown-listbox"), d = b ? t.isOpen : v, r = m ? Array.isArray(t.selectedValue) ? t.selectedValue : t.selectedValue ? [t.selectedValue] : [] : oe, P = (e) => {
20
+ b || te(e), t.onOpenChange?.(e);
21
+ }, $ = (e) => {
22
22
  m || K(e);
23
23
  }, {
24
24
  selectBy: x = "",
25
25
  optionsUniqueBy: u = "",
26
- displaySelected: oe = !1,
26
+ displaySelected: ne = !1,
27
27
  dropDownOptions: j,
28
28
  defaultText: f = "Select",
29
29
  iconColor: H = "var(--color-gray-700)",
30
30
  disabled: E = !1,
31
- dropdownClassName: ne = "",
31
+ dropdownClassName: ae = "",
32
32
  hasError: q = !1,
33
- errorMessage: ae = "",
33
+ errorMessage: le = "",
34
34
  customDropdownContent: F = null,
35
- isBorderless: le = !1,
35
+ isBorderless: re = !1,
36
36
  shouldShowSearch: y = !1,
37
- showSearchIcon: re = !0,
37
+ showSearchIcon: se = !0,
38
38
  searchPlaceholder: U = "Search...",
39
- searchResultEmptyMessage: _ = "No results found",
40
- ariaLabel: se = "",
41
- customSelectedValue: z = ""
39
+ searchResultEmptyMessage: W = "No results found",
40
+ ariaLabel: ce = "",
41
+ customSelectedValue: _ = "",
42
+ isWithPortal: z = !1
42
43
  } = t;
43
44
  D(() => {
44
45
  if (!m) {
@@ -55,26 +56,26 @@ const Ke = (t) => {
55
56
  d && y && N.current && requestAnimationFrame(() => N.current?.focus());
56
57
  }, [d, y]);
57
58
  const s = t?.type === "multi-select", A = () => k.trim() ? (j || []).filter((e) => (e?.[x]?.toString().toLowerCase() || "").includes(k.toLowerCase())) : j || [], O = (e) => {
58
- P([e]), $(!1), t?.onOptionClick?.(e);
59
+ $([e]), P(!1), t?.onOptionClick?.(e);
59
60
  }, C = A(), {
60
- listboxProps: ce,
61
- getOptionProps: ie,
62
- highlightedIndex: de,
63
- containerProps: ue,
61
+ listboxProps: ie,
62
+ getOptionProps: de,
63
+ highlightedIndex: ue,
64
+ containerProps: me,
64
65
  inputProps: c
65
- } = Ve({
66
+ } = Ne({
66
67
  items: s ? [] : C,
67
68
  // Only use for single-select
68
69
  isOpen: d && !s,
69
- onOpenChange: $,
70
+ onOpenChange: P,
70
71
  onSelect: (e) => {
71
72
  O(e);
72
73
  },
73
74
  listboxId: g,
74
75
  disabled: s || E,
75
76
  hasItems: C.length > 0
76
- }), me = (e, a = !1) => s ? f : a && z ? z : e?.[x] || f, fe = () => {
77
- P([]), t?.onClear?.();
77
+ }), fe = (e, a = !1) => s ? f : a && _ ? _ : e?.[x] || f, pe = () => {
78
+ $([]), t?.onClear?.();
78
79
  }, J = (e, a = !1) => {
79
80
  if (t?.renderOptionChip)
80
81
  return t?.renderOptionChip(e, a);
@@ -90,7 +91,7 @@ const Ke = (t) => {
90
91
  }
91
92
  return /* @__PURE__ */ n.createElement("p", {
92
93
  className: "option-chip flex flex-1 items-center justify-between"
93
- }, me(e, a));
94
+ }, fe(e, a));
94
95
  }, Q = () => {
95
96
  const e = y && !s ? {
96
97
  role: c.role,
@@ -103,8 +104,8 @@ const Ke = (t) => {
103
104
  } : {};
104
105
  return /* @__PURE__ */ n.createElement("div", {
105
106
  className: " w-full relative flex items-center border-b border-[var(--color-gray-300)]"
106
- }, /* @__PURE__ */ n.createElement(ke, {
107
- leftIcon: re ? {
107
+ }, /* @__PURE__ */ n.createElement(Ve, {
108
+ leftIcon: se ? {
108
109
  name: "search",
109
110
  position: "left",
110
111
  style: {
@@ -128,41 +129,41 @@ const Ke = (t) => {
128
129
  inputRef: N,
129
130
  inputProps: e
130
131
  }));
131
- }, pe = (e, a) => {
132
- const o = e[x], l = r[0]?.[x] || f, w = u?.length ? e[u] == r[0]?.[u] : !0, p = oe && o === l && w, Ee = de === a, Ce = s ? {} : ie(a, p);
132
+ }, be = (e, a) => {
133
+ const o = e[x], l = r[0]?.[x] || f, w = u?.length ? e[u] == r[0]?.[u] : !0, p = ne && o === l && w, Ce = ue === a, Ie = s ? {} : de(a, p);
133
134
  return /* @__PURE__ */ n.createElement("div", h({
134
135
  key: e.id || e.value,
135
- className: `option break-words px-3 py-2 hover:bg-gray-100 cursor-pointer select-none flex items-center justify-between ${p ? "selected" : ""} ${Ee ? "bg-gray-100" : ""}`,
136
+ className: `option break-words px-3 py-2 hover:bg-gray-100 cursor-pointer select-none flex items-center justify-between ${p ? "selected" : ""} ${Ce ? "bg-gray-100" : ""}`,
136
137
  onClick: () => O(e),
137
138
  onKeyDown: (B) => {
138
139
  (B.key === "Enter" || B.key === " ") && (B.preventDefault(), O(e));
139
140
  },
140
141
  tabIndex: -1,
141
142
  "data-automation-id": `dropdown-option-${e?.automationId || a}`
142
- }, Ce, {
143
+ }, Ie, {
143
144
  "aria-selected": p ? "true" : "false"
144
145
  }), J({
145
146
  ...e,
146
147
  isOptionSelected: p
147
- }, !1), p && /* @__PURE__ */ n.createElement(G, {
148
+ }, !1), p && /* @__PURE__ */ n.createElement(Y, {
148
149
  name: "checkmark",
149
150
  stroke: H
150
151
  }));
151
- }, be = () => /* @__PURE__ */ n.createElement("div", h({
152
+ }, ge = () => /* @__PURE__ */ n.createElement("div", h({
152
153
  className: "dropdown-content dropdown-options",
153
154
  "aria-label": `${f} options`
154
- }, ce), y && Q(), /* @__PURE__ */ n.createElement("div", {
155
+ }, ie), y && Q(), /* @__PURE__ */ n.createElement("div", {
155
156
  className: "flex flex-col max-h-80 overflow-y-auto"
156
- }, C.length > 0 ? C.map((e, a) => pe(e, a)) : /* @__PURE__ */ n.createElement("div", {
157
+ }, C.length > 0 ? C.map((e, a) => be(e, a)) : /* @__PURE__ */ n.createElement("div", {
157
158
  className: "px-3 py-4 text-center text-[var(--color-gray-700)] text-sm",
158
159
  role: "status",
159
160
  "aria-live": "polite"
160
- }, _))), W = (e, a) => {
161
+ }, W))), X = (e, a) => {
161
162
  let o = [];
162
- e ? o = [...r, a] : o = r?.filter((l) => l[u] !== a[u]), P(o);
163
- }, ge = () => {
163
+ e ? o = [...r, a] : o = r?.filter((l) => l[u] !== a[u]), $(o);
164
+ }, ye = () => {
164
165
  M.current?.togglePopover(), t?.onApply?.(r);
165
- }, ye = (e) => {
166
+ }, he = (e) => {
166
167
  const a = A();
167
168
  if (e.key === "ArrowDown")
168
169
  e.preventDefault(), e.stopPropagation(), S((o) => o < a.length - 1 ? o + 1 : o);
@@ -170,9 +171,9 @@ const Ke = (t) => {
170
171
  e.preventDefault(), e.stopPropagation(), S((o) => o > 0 ? o - 1 : 0);
171
172
  else if ((e.key === " " || e.key === "Enter") && (e.preventDefault(), i >= 0 && i < a.length)) {
172
173
  const o = a[i], l = r.some((w) => w[u] === o[u]);
173
- W(!l, o);
174
+ X(!l, o);
174
175
  }
175
- }, he = (e, a) => {
176
+ }, ve = (e, a) => {
176
177
  const o = r.some((p) => p[u] === e[u]), l = `${g}-option-${a}`, w = i === a;
177
178
  return /* @__PURE__ */ n.createElement("div", {
178
179
  key: e.id || e.value,
@@ -180,9 +181,9 @@ const Ke = (t) => {
180
181
  role: "option",
181
182
  "aria-selected": o,
182
183
  className: `option px-3 py-2 cursor-pointer select-none flex items-center gap-2 ${w ? "bg-gray-100" : "hover:bg-gray-100"}`,
183
- onClick: () => W(!o, e),
184
+ onClick: () => X(!o, e),
184
185
  "data-automation-id": `dropdown-option-${e?.automationId || a}`
185
- }, /* @__PURE__ */ n.createElement(De, {
186
+ }, /* @__PURE__ */ n.createElement(ke, {
186
187
  tabIndex: -1,
187
188
  ariaHidden: !0,
188
189
  checked: o,
@@ -191,7 +192,7 @@ const Ke = (t) => {
191
192
  }), /* @__PURE__ */ n.createElement("span", {
192
193
  className: "checkbox-label"
193
194
  }, e?.label));
194
- }, ve = () => {
195
+ }, xe = () => {
195
196
  const e = A(), a = i >= 0 ? `${g}-option-${i}` : void 0;
196
197
  return /* @__PURE__ */ n.createElement("div", {
197
198
  className: "dropdown-content dropdown-options",
@@ -209,37 +210,37 @@ const Ke = (t) => {
209
210
  outline: "none"
210
211
  },
211
212
  "aria-activedescendant": a,
212
- onKeyDown: ye,
213
+ onKeyDown: he,
213
214
  onFocus: () => {
214
215
  i === -1 && e.length > 0 && S(0);
215
216
  }
216
217
  }, y && Q(), /* @__PURE__ */ n.createElement("div", {
217
218
  className: "flex flex-col max-h-80 overflow-y-auto"
218
- }, e.length > 0 ? e.map((o, l) => he(o, l)) : /* @__PURE__ */ n.createElement("div", {
219
+ }, e.length > 0 ? e.map((o, l) => ve(o, l)) : /* @__PURE__ */ n.createElement("div", {
219
220
  className: "px-3 py-4 text-center text-[var(--color-gray-700)] text-sm",
220
221
  role: "status",
221
222
  "aria-live": "polite"
222
- }, _))), /* @__PURE__ */ n.createElement("div", {
223
+ }, W))), /* @__PURE__ */ n.createElement("div", {
223
224
  className: "flex items-center justify-end gap-4 p-3 border-t border-[var(--color-gray-200)]",
224
225
  onKeyDown: (o) => {
225
226
  o.key === "Tab" && o.shiftKey && (o.preventDefault(), o.stopPropagation(), V.current?.focus());
226
227
  }
227
- }, /* @__PURE__ */ n.createElement(Y, {
228
+ }, /* @__PURE__ */ n.createElement(Z, {
228
229
  label: "Clear",
229
230
  type: "link",
230
231
  size: "sm",
231
- onClick: fe,
232
+ onClick: pe,
232
233
  automationId: "se-design-dropdown-clear-button",
233
234
  ariaLabel: `Clear ${f} selection`
234
- }), /* @__PURE__ */ n.createElement(Y, {
235
+ }), /* @__PURE__ */ n.createElement(Z, {
235
236
  label: "Apply",
236
237
  type: "primary",
237
238
  size: "sm",
238
- onClick: ge,
239
+ onClick: ye,
239
240
  automationId: "se-design-dropdown-apply-button"
240
241
  })));
241
- }, xe = () => {
242
- const e = d ? "border-[var(--color-blue-500)]" : E ? "border-[var(--color-gray-300)]" : "border-[var(--color-gray-600)]", a = q ? "border-[var(--color-red-500)]" : "", o = `dropdown-src-element bg-[var(--color-white)] flex px-3 py-2 ${le ? "border-0" : `border rounded-md ${a || e}`} flex items-center ${ne}`;
242
+ }, we = () => {
243
+ const e = d ? "border-[var(--color-blue-500)]" : E ? "border-[var(--color-gray-300)]" : "border-[var(--color-gray-600)]", a = q ? "border-[var(--color-red-500)]" : "", o = `dropdown-src-element bg-[var(--color-white)] flex px-3 py-2 ${re ? "border-0" : `border rounded-md ${a || e}`} flex items-center ${ae}`;
243
244
  return /* @__PURE__ */ n.createElement("div", {
244
245
  className: o
245
246
  }, /* @__PURE__ */ n.createElement("div", {
@@ -248,13 +249,13 @@ const Ke = (t) => {
248
249
  }, J(r[0], !0)), /* @__PURE__ */ n.createElement("div", {
249
250
  className: "flex-shrink-0 ml-2",
250
251
  "aria-hidden": "true"
251
- }, /* @__PURE__ */ n.createElement(G, {
252
+ }, /* @__PURE__ */ n.createElement(Y, {
252
253
  name: "chevron",
253
254
  rotation: d ? "180" : "0",
254
255
  className: "transition-transform",
255
256
  stroke: H
256
257
  })));
257
- }, we = () => se || f || "Select option", X = y ? "button" : "combobox", Se = X === "combobox" && !s && c ? {
258
+ }, Se = () => ce || f || "Select option", G = y ? "button" : "combobox", Ee = G === "combobox" && !s && c ? {
258
259
  "aria-activedescendant": c["aria-activedescendant"],
259
260
  "aria-controls": c["aria-controls"],
260
261
  "aria-expanded": c["aria-expanded"]
@@ -268,31 +269,40 @@ const Ke = (t) => {
268
269
  }, t?.label), /* @__PURE__ */ n.createElement("div", h({
269
270
  style: t?.style,
270
271
  className: `${E ? "bg-[var(--color-gray-50)] rounded-md cursor-not-allowed" : ""}`
271
- }, s ? {} : ue), /* @__PURE__ */ n.createElement(Ie, h({
272
+ }, s ? {} : {
273
+ ...me,
274
+ // Portal content lives in document.body — focus moving into it looks like "focus out" to
275
+ // the container's blur handler, causing immediate close. Suppress it; the Popover's own
276
+ // onBlur handler checks both source and portal content and handles dismissal correctly.
277
+ ...z ? {
278
+ onBlurCapture: void 0
279
+ } : {}
280
+ }), /* @__PURE__ */ n.createElement(De, h({
272
281
  ref: M,
273
282
  isPopoverOpen: d,
274
- renderPopoverContents: F || (s ? ve : be),
283
+ isWithPortal: z,
284
+ renderPopoverContents: F || (s ? xe : ge),
275
285
  contentWidth: "full",
276
286
  renderPopoverSrcElement: t.renderSrcElement ? () => t.renderSrcElement({
277
287
  isOpen: d,
278
288
  selectedValue: r
279
- }) : xe,
289
+ }) : we,
280
290
  onPopoverToggle: (e) => {
281
- $(e), e && s && setTimeout(() => V.current?.focus(), 50);
291
+ P(e), e && s && setTimeout(() => V.current?.focus(), 50);
282
292
  },
283
293
  disabled: E,
284
294
  automationId: t?.dropDownSrcAutomationId,
285
295
  popoverContentAutomationId: t?.dropDownContentAutomationId,
286
296
  ariaLabelledBy: t?.label ? T : t?.ariaLabelledBy,
287
- ariaLabel: t?.label || t?.ariaLabelledBy ? void 0 : we(),
288
- sourceRole: X
289
- }, Se, s ? {
297
+ ariaLabel: t?.label || t?.ariaLabelledBy ? void 0 : Se(),
298
+ sourceRole: G
299
+ }, Ee, s ? {
290
300
  "aria-controls": g
291
301
  } : {}))), q && /* @__PURE__ */ n.createElement("div", {
292
302
  className: "text-[var(--color-red-500)] text-sm"
293
- }, ae));
303
+ }, le));
294
304
  };
295
305
  export {
296
- Ke as Dropdown
306
+ Me as Dropdown
297
307
  };
298
308
  //# sourceMappingURL=index25.js.map