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.
@@ -1 +1 @@
1
- {"version":3,"file":"index16.js","sources":["../src/components/Tooltip/index.tsx"],"sourcesContent":["import React, { useEffect, useState, useRef } from 'react';\nimport ReactDOM, { flushSync } from 'react-dom';\nimport { useStableId } from '../../utils/useStableId';\nimport { useDismissOnFocusOut } from '../../utils/a11y';\n\nexport interface TooltipProps {\n /**\n * Tooltip contents\n */\n content: string | React.ReactNode;\n /**\n * Tooltip position\n */\n position?:\n | 'top-left'\n | 'top-center'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'bottom-right'\n | 'left-top'\n | 'left-center'\n | 'left-bottom'\n | 'right-top'\n | 'right-center'\n | 'right-bottom';\n /**\n * Display tooltip on Hover, Click or Always\n */\n displayOn?: 'hover' | 'click' | 'always-on';\n /**\n * Tooltip trigger contents\n */\n tooltipSrc?: React.ReactNode;\n /**\n * Tooltip trigger contents ref\n */\n tooltipSrcRef?: React.RefObject<HTMLElement>;\n /**\n * When true, the real trigger is disabled and cannot receive focus.\n * Tooltip will make its wrapper focusable and treat it as a \"button\" that reveals tooltip content.\n */\n isTriggerDisabled?: boolean;\n /**\n * Required when isTriggerDisabled is true. Provides an accessible name for the focusable wrapper trigger.\n */\n disabledTriggerAriaLabel?: string;\n /**\n * Max width of the tooltip content\n */\n maxWidth?: number;\n /**\n * Whether to use portal for the tooltip content\n */\n isWithPortal?: boolean;\n /**\n * Tooltip content classes\n */\n tooltipContentClasses?: string;\n /**\n * Tooltip offset\n */\n tooltipOffset?: number;\n /**\n * Automation ID for testing\n */\n automationId?: string;\n}\n\nexport const Tooltip = ({\n content,\n tooltipSrc,\n position = 'bottom-center',\n displayOn = 'hover',\n maxWidth = 240,\n isWithPortal = false,\n tooltipSrcRef = undefined,\n isTriggerDisabled = false,\n disabledTriggerAriaLabel = undefined,\n tooltipContentClasses = '',\n tooltipOffset = 8,\n automationId = ''\n}: TooltipProps) => {\n const [displayTooltip, setDisplayTooltip] = useState(false);\n const tooltipContentRef = useRef<HTMLDivElement>(null);\n // Support for external ref when provided\n const internalToolTipSrcRef = useRef<HTMLDivElement>(null);\n const tooltipSourceRef = (tooltipSrcRef || internalToolTipSrcRef) as React.RefObject<HTMLElement>;\n const [tooltipPortalStyle, setTooltipPortalStyle] = useState({});\n const [isPortalPositioned, setIsPortalPositioned] = useState(false);\n const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isContentString = typeof content === 'string';\n const tooltipContentId = useStableId(undefined, 'tooltip-content');\n\n // Helper to clear hide timeout\n const clearHideTimeout = () => {\n if (hideTimeoutRef.current) {\n clearTimeout(hideTimeoutRef.current);\n hideTimeoutRef.current = null;\n }\n };\n\n // Helper to schedule hide\n const scheduleHide = () => {\n if (displayOn !== 'always-on') {\n clearHideTimeout();\n hideTimeoutRef.current = setTimeout(() => setDisplayTooltip(false), 150);\n }\n };\n\n const showTooltip = () => {\n clearHideTimeout();\n setDisplayTooltip(true);\n };\n\n const onDisabledTriggerKeyDown = (e: React.KeyboardEvent) => {\n if (!isTriggerDisabled) return;\n if (e.key === 'Escape') {\n e.preventDefault();\n setDisplayTooltip(false);\n return;\n }\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n setDisplayTooltip((prev) => !prev);\n }\n };\n\n // Enabled trigger: use React focus/blur capture handlers (no native event listeners).\n // This keeps the tooltip open while focus stays anywhere inside the tooltip wrapper.\n const dismissOnFocusOutProps = useDismissOnFocusOut<HTMLDivElement>({\n disabled: isTriggerDisabled,\n onFocusIn: showTooltip,\n onFocusOut: scheduleHide,\n onEscape: () => setDisplayTooltip(false)\n });\n\n useEffect(() => {\n const tooltipContent = tooltipContentRef.current;\n\n if (!tooltipContent) {\n return;\n }\n\n if (position == 'bottom-center') {\n tooltipContent.setAttribute('style', `left: 50%;transform: translateX(-50%);`);\n tooltipContent.classList.add(`before:left-[calc(50%-7px)]`);\n tooltipContent.classList.add(`before:top-[-7px]`);\n } else if (position == 'bottom-left') {\n tooltipContent.classList.add(`before:left-[calc(10%-7px)]`);\n tooltipContent.classList.add(`before:top-[-7px]`);\n } else if (position == 'bottom-right') {\n tooltipContent.setAttribute('style', `right: 0;`);\n tooltipContent.classList.add(`before:right-[calc(10%+7px)]`);\n tooltipContent.classList.add(`before:top-[-7px]`);\n } else if (position == 'top-center') {\n tooltipContent.setAttribute('style', `left: 50%;transform: translateX(-50%);bottom: calc(100% + 8px);`);\n tooltipContent.classList.add(`before:left-[calc(50%-7px)]`);\n tooltipContent.classList.add(`before:bottom-[-7px]`);\n } else if (position == 'top-left') {\n tooltipContent.setAttribute('style', `bottom: calc(100% + 8px);`);\n tooltipContent.classList.add(`before:left-[calc(10%-7px)]`);\n tooltipContent.classList.add(`before:bottom-[-7px]`);\n } else if (position == 'top-right') {\n tooltipContent.setAttribute('style', `right: 0;bottom: calc(100% + 8px);`);\n tooltipContent.classList.add(`before:right-[calc(10%+7px)]`);\n tooltipContent.classList.add(`before:bottom-[-7px]`);\n } else if (position == 'left-top') {\n tooltipContent.setAttribute('style', `right: calc(100% + 10px);top:0;`);\n tooltipContent.classList.add(`before:right-[-6px]`);\n tooltipContent.classList.add(`before:top-[7px]`);\n } else if (position == 'left-center') {\n tooltipContent.setAttribute('style', `right: calc(100% + 10px);top: 50%;transform: translateY(-50%);`);\n tooltipContent.classList.add(`before:right-[-6px]`);\n tooltipContent.classList.add(`before:top-[calc(50%-7px)]`);\n } else if (position == 'left-bottom') {\n tooltipContent.setAttribute('style', `right: calc(100% + 10px);bottom:0;`);\n tooltipContent.classList.add(`before:right-[-6px]`);\n tooltipContent.classList.add(`before:bottom-[7px]`);\n } else if (position == 'right-top') {\n tooltipContent.setAttribute('style', `left: calc(100% + 10px);top:0;`);\n tooltipContent.classList.add(`before:left-[-6px]`);\n tooltipContent.classList.add(`before:top-[7px]`);\n } else if (position == 'right-center') {\n tooltipContent.setAttribute('style', `left: calc(100% + 10px);top: 50%;transform: translateY(-50%);`);\n tooltipContent.classList.add(`before:left-[-6px]`);\n tooltipContent.classList.add(`before:top-[calc(50%-7px)]`);\n } else if (position == 'right-bottom') {\n tooltipContent.setAttribute('style', `left: calc(100% + 10px);bottom:0;`);\n tooltipContent.classList.add(`before:left-[-6px]`);\n tooltipContent.classList.add(`before:bottom-[7px]`);\n }\n\n if (displayOn == 'hover') {\n tooltipContent.classList.add(`group-hover:visible`);\n }\n }, [content]);\n\n useEffect(() => {\n const tooltipContent = tooltipContentRef.current;\n\n if (!tooltipContent) {\n return;\n }\n if (displayTooltip) {\n tooltipContent.classList.remove(`invisible`);\n } else {\n tooltipContent.classList.add(`invisible`);\n }\n }, [displayTooltip]);\n\n // Ensure tooltip stays open when displayOn is always-on\n useEffect(() => {\n if (displayOn === 'always-on') {\n setDisplayTooltip(true);\n }\n }, [displayOn]);\n\n const onTooltipSrcClick = () => {\n if (displayOn == 'click') {\n setDisplayTooltip((displayTooltip) => !displayTooltip);\n }\n };\n\n const toggleTooltip = () => {\n setDisplayTooltip((displayTooltip) => !displayTooltip);\n };\n\n const events = {\n ...(displayOn === 'click' && { onClick: toggleTooltip }),\n ...(displayOn === 'hover' && {\n onMouseEnter: () => setDisplayTooltip(true),\n onMouseLeave: () => setDisplayTooltip(false)\n })\n };\n\n const calculateTooltipPortalStyle = () => {\n const refToUse = tooltipSourceRef.current;\n if (!refToUse) {\n return {};\n }\n\n const srcRect = refToUse.getBoundingClientRect();\n const scrollX = window.scrollX || window.pageXOffset;\n const scrollY = window.scrollY || window.pageYOffset;\n const arrowSize = 14; // 14px (3.5 * 4 = 14px in Tailwind)\n\n // Get tooltip content dimensions if available\n const tooltipElement = document.getElementById(tooltipContentId);\n const tooltipWidth = tooltipElement?.offsetWidth || 0;\n const tooltipHeight = tooltipElement?.offsetHeight || 0;\n\n let top = 0;\n let left = 0;\n let arrowLeft = 0;\n let arrowTop = 0;\n\n switch (position) {\n case 'bottom-center':\n top = srcRect.bottom + scrollY + tooltipOffset;\n left = srcRect.left + scrollX + srcRect.width / 2 - tooltipWidth / 2;\n arrowLeft = tooltipWidth / 2 - arrowSize / 2;\n arrowTop = -arrowSize / 2;\n break;\n case 'bottom-left':\n top = srcRect.bottom + scrollY + tooltipOffset;\n left = srcRect.left + scrollX;\n arrowLeft = tooltipWidth * 0.1 - arrowSize / 2;\n arrowTop = -arrowSize / 2;\n break;\n case 'bottom-right':\n top = srcRect.bottom + scrollY + tooltipOffset;\n left = srcRect.right + scrollX - tooltipWidth;\n arrowLeft = tooltipWidth - tooltipWidth * 0.1 - arrowSize / 2;\n arrowTop = -arrowSize / 2;\n break;\n case 'top-center':\n top = srcRect.top + scrollY - tooltipHeight - tooltipOffset;\n left = srcRect.left + scrollX + srcRect.width / 2 - tooltipWidth / 2;\n arrowLeft = tooltipWidth / 2 - arrowSize / 2;\n arrowTop = tooltipHeight - arrowSize / 2;\n break;\n case 'top-left':\n top = srcRect.top + scrollY - tooltipHeight - tooltipOffset;\n left = srcRect.left + scrollX;\n arrowLeft = tooltipWidth * 0.1 - arrowSize / 2;\n arrowTop = tooltipHeight - arrowSize / 2;\n break;\n case 'top-right':\n top = srcRect.top + scrollY - tooltipHeight - tooltipOffset;\n left = srcRect.right + scrollX - tooltipWidth;\n arrowLeft = tooltipWidth - tooltipWidth * 0.1 - arrowSize / 2;\n arrowTop = tooltipHeight - arrowSize / 2;\n break;\n case 'left-top':\n top = srcRect.top + scrollY;\n left = srcRect.left + scrollX - tooltipWidth - tooltipOffset;\n arrowLeft = tooltipWidth - arrowSize / 2;\n arrowTop = arrowSize / 2;\n break;\n case 'left-center':\n top = srcRect.top + scrollY + srcRect.height / 2 - tooltipHeight / 2;\n left = srcRect.left + scrollX - tooltipWidth - tooltipOffset;\n arrowLeft = tooltipWidth - arrowSize / 2;\n arrowTop = tooltipHeight / 2 - arrowSize / 2;\n break;\n case 'left-bottom':\n top = srcRect.bottom + scrollY - tooltipHeight;\n left = srcRect.left + scrollX - tooltipWidth - tooltipOffset;\n arrowLeft = tooltipWidth - arrowSize / 2;\n arrowTop = tooltipHeight - arrowSize / 2;\n break;\n case 'right-top':\n top = srcRect.top + scrollY;\n left = srcRect.right + scrollX + tooltipOffset;\n arrowLeft = -arrowSize / 2;\n arrowTop = arrowSize / 2;\n break;\n case 'right-center':\n top = srcRect.top + scrollY + srcRect.height / 2 - tooltipHeight / 2;\n left = srcRect.right + scrollX + tooltipOffset;\n arrowLeft = -arrowSize / 2;\n arrowTop = tooltipHeight / 2 - arrowSize / 2;\n break;\n case 'right-bottom':\n top = srcRect.bottom + scrollY - tooltipHeight;\n left = srcRect.right + scrollX + tooltipOffset;\n arrowLeft = -arrowSize / 2;\n arrowTop = tooltipHeight - arrowSize / 2;\n break;\n default:\n top = srcRect.bottom + scrollY + tooltipOffset;\n left = srcRect.left + scrollX + srcRect.width / 2 - tooltipWidth / 2;\n arrowLeft = tooltipWidth / 2 - arrowSize / 2;\n arrowTop = -arrowSize / 2;\n break;\n }\n\n return {\n position: 'absolute',\n top: `${top}px`,\n left: `${left}px`,\n zIndex: 9999,\n '--arrow-left': `${arrowLeft}px`,\n '--arrow-top': `${arrowTop}px`\n } as React.CSSProperties & { '--arrow-left': string; '--arrow-top': string };\n };\n\n useEffect(() => {\n if (!displayTooltip || !isWithPortal) {\n setIsPortalPositioned(false);\n return;\n }\n\n const updatePosition = () => {\n const tooltipElement = document.getElementById(tooltipContentId);\n\n // Wait for tooltip to be rendered and have valid dimensions\n if (!tooltipElement || tooltipElement.offsetHeight === 0) {\n requestAnimationFrame(updatePosition);\n return;\n }\n\n const calculatedStyle = calculateTooltipPortalStyle();\n \n // Batch both state updates into a single synchronous render using flushSync\n flushSync(() => {\n setTooltipPortalStyle(calculatedStyle);\n setIsPortalPositioned(true);\n });\n };\n\n // Initial position calculation\n const timeout = setTimeout(updatePosition, tooltipSrcRef ? 60 : 10);\n\n const handleClick = (e: MouseEvent) => {\n const tooltip = document.getElementById(tooltipContentId);\n const source = tooltipSourceRef.current;\n const target = e.target as Node;\n\n if (tooltip && source && !tooltip.contains(target) && !source.contains(target)) {\n setDisplayTooltip(false);\n }\n };\n\n // Only add click listener if not always-on\n const shouldAddClickListener = displayOn !== 'always-on';\n if (shouldAddClickListener) {\n document.body.addEventListener('click', handleClick, true);\n }\n window.addEventListener('scroll', updatePosition, true);\n window.addEventListener('resize', updatePosition);\n\n // Watch for style changes on the source element when tooltipSrcRef is provided\n // This ensures the tooltip position updates when the blocker is repositioned\n let mutationObserver: MutationObserver | null = null;\n if (tooltipSrcRef && tooltipSourceRef.current) {\n mutationObserver = new MutationObserver(() => {\n updatePosition();\n });\n mutationObserver.observe(tooltipSourceRef.current, {\n attributes: true,\n attributeFilter: ['style', 'class']\n });\n }\n\n return () => {\n clearTimeout(timeout);\n clearHideTimeout();\n if (shouldAddClickListener) {\n document.body.removeEventListener('click', handleClick, true);\n }\n window.removeEventListener('scroll', updatePosition, true);\n window.removeEventListener('resize', updatePosition);\n if (mutationObserver) {\n mutationObserver.disconnect();\n }\n };\n }, [displayTooltip, isWithPortal, position, displayOn, tooltipSrcRef, tooltipContentId]);\n\n // For enabled triggers: link trigger to tooltip content via aria-describedby so screen\n // readers announce tooltip text on focus. Native elements need kebab-case only;\n // se-design components (Icon, Button) also accept camelCase ariaDescribedBy prop.\n // Disabled trigger already wires aria-describedby in disabledTriggerProps.\n const linkedTooltipSrc =\n !isTriggerDisabled && React.isValidElement(tooltipSrc)\n ? React.cloneElement(tooltipSrc as React.ReactElement<any>, {\n 'aria-describedby': tooltipContentId,\n ...(typeof tooltipSrc.type !== 'string' && { ariaDescribedBy: tooltipContentId })\n })\n : tooltipSrc;\n\n const disabledTriggerProps = isTriggerDisabled\n ? {\n tabIndex: 0,\n role: 'button' as const,\n 'aria-label': disabledTriggerAriaLabel,\n 'aria-describedby': tooltipContentId,\n onFocus: showTooltip,\n onBlur: scheduleHide,\n onKeyDown: onDisabledTriggerKeyDown\n }\n : undefined;\n\n const enabledTriggerProps = !isTriggerDisabled\n ? dismissOnFocusOutProps\n : undefined;\n\n return !isWithPortal ? (\n <div\n className=\"se-design-tooltip group relative\"\n onClick={onTooltipSrcClick}\n {...disabledTriggerProps}\n {...enabledTriggerProps}\n >\n <div className=\"cursor-pointer\">\n {linkedTooltipSrc}\n </div>\n <div\n ref={tooltipContentRef}\n id={tooltipContentId}\n role=\"tooltip\"\n className={`flex justify-center px-3 py-2 min-w-24 max-w-[${maxWidth}px]\n absolute top-[calc(100%+8px)] w-max bg-[var(--color-gray-800)] text-[var(--color-white)] text-base rounded-[3px]\n before:content-[' '] before:w-3.5 before:h-3.5 before:bg-[var(--color-gray-800)] before:inline-block\n before:absolute before:rounded-tl-sm before:rotate-45`}\n data-automation-id={automationId || 'tooltip-content'}\n >\n {isContentString ? <p className=\"leading-normal\">{content}</p> : content}\n </div>\n </div>\n ) : (\n <div\n className=\"se-design-tooltip group relative\"\n {...events}\n {...disabledTriggerProps}\n {...enabledTriggerProps}\n >\n <div\n className=\"cursor-pointer\"\n ref={tooltipSrcRef ? undefined : (tooltipSourceRef as React.RefObject<HTMLDivElement>)}\n onMouseEnter={displayOn === 'always-on' ? undefined : clearHideTimeout}\n onMouseLeave={scheduleHide}\n >\n {linkedTooltipSrc}\n </div>\n {displayTooltip &&\n ReactDOM.createPortal(\n <>\n <style>\n {`#${tooltipContentId}::before {\n left: var(--arrow-left, 0);\n top: var(--arrow-top, 0);\n }`}\n </style>\n <div\n id={tooltipContentId}\n role=\"tooltip\"\n className={`flex justify-center px-3 py-2 min-w-24 bg-[var(--color-gray-800)] text-[var(--color-white)] text-base rounded-[3px]\n before:content-[' '] before:w-3.5 before:h-3.5 before:bg-[var(--color-gray-800)] before:inline-block\n before:absolute before:rounded-tl-sm before:rotate-45 ${tooltipContentClasses}`}\n style={{\n ...tooltipPortalStyle,\n maxWidth: `${maxWidth}px`,\n wordBreak: 'break-word',\n overflowWrap: 'break-word',\n visibility: isPortalPositioned ? 'visible' : 'hidden',\n opacity: isPortalPositioned ? 1 : 0,\n pointerEvents: isPortalPositioned ? 'auto' : 'none',\n transition: isPortalPositioned ? 'opacity 0.15s ease-in' : 'none',\n // Ensure it stays at 0,0 until positioned to avoid any visual flash\n ...(isPortalPositioned ? {} : { position: 'fixed', top: '0px', left: '0px' })\n }}\n onMouseEnter={displayOn === 'always-on' ? undefined : clearHideTimeout}\n onMouseLeave={scheduleHide}\n >\n {isContentString ? <p className=\"leading-normal\">{content}</p> : content}\n </div>\n </>,\n document.body\n )}\n </div>\n );\n};\n"],"names":["Tooltip","content","tooltipSrc","position","displayOn","maxWidth","isWithPortal","tooltipSrcRef","undefined","isTriggerDisabled","disabledTriggerAriaLabel","tooltipContentClasses","tooltipOffset","automationId","displayTooltip","setDisplayTooltip","useState","tooltipContentRef","useRef","internalToolTipSrcRef","tooltipSourceRef","tooltipPortalStyle","setTooltipPortalStyle","isPortalPositioned","setIsPortalPositioned","hideTimeoutRef","isContentString","tooltipContentId","useStableId","clearHideTimeout","current","clearTimeout","scheduleHide","setTimeout","showTooltip","onDisabledTriggerKeyDown","e","key","preventDefault","prev","dismissOnFocusOutProps","useDismissOnFocusOut","disabled","onFocusIn","onFocusOut","onEscape","useEffect","tooltipContent","setAttribute","classList","add","remove","onTooltipSrcClick","events","onClick","toggleTooltip","onMouseEnter","onMouseLeave","calculateTooltipPortalStyle","refToUse","srcRect","getBoundingClientRect","scrollX","window","pageXOffset","scrollY","pageYOffset","arrowSize","tooltipElement","document","getElementById","tooltipWidth","offsetWidth","tooltipHeight","offsetHeight","top","left","arrowLeft","arrowTop","bottom","width","right","height","zIndex","updatePosition","requestAnimationFrame","calculatedStyle","flushSync","timeout","handleClick","tooltip","source","target","contains","shouldAddClickListener","body","addEventListener","mutationObserver","MutationObserver","observe","attributes","attributeFilter","removeEventListener","disconnect","linkedTooltipSrc","React","isValidElement","cloneElement","type","ariaDescribedBy","disabledTriggerProps","tabIndex","role","onFocus","onBlur","onKeyDown","enabledTriggerProps","createElement","_extends","className","ref","ReactDOM","createPortal","Fragment","id","style","wordBreak","overflowWrap","visibility","opacity","pointerEvents","transition"],"mappings":";;;;;;;;;;;;;;AAqEO,MAAMA,KAAUA,CAAC;AAAA,EACtBC,SAAAA;AAAAA,EACAC,YAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,WAAAA,IAAY;AAAA,EACZC,UAAAA,IAAW;AAAA,EACXC,cAAAA,IAAe;AAAA,EACfC,eAAAA,IAAgBC;AAAAA,EAChBC,mBAAAA,IAAoB;AAAA,EACpBC,0BAAAA,IAA2BF;AAAAA,EAC3BG,uBAAAA,IAAwB;AAAA,EACxBC,eAAAA,IAAgB;AAAA,EAChBC,cAAAA,IAAe;AACH,MAAM;AAClB,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAK,GACpDC,IAAoBC,EAAuB,IAAI,GAE/CC,IAAwBD,EAAuB,IAAI,GACnDE,IAAoBb,KAAiBY,GACrC,CAACE,GAAoBC,CAAqB,IAAIN,EAAS,CAAA,CAAE,GACzD,CAACO,GAAoBC,CAAqB,IAAIR,EAAS,EAAK,GAC5DS,IAAiBP,EAA6C,IAAI,GAClEQ,IAAkB,OAAOzB,KAAY,UACrC0B,IAAmBC,GAAYpB,QAAW,iBAAiB,GAG3DqB,IAAmBA,MAAM;AAC7B,IAAIJ,EAAeK,YACjBC,aAAaN,EAAeK,OAAO,GACnCL,EAAeK,UAAU;AAAA,EAE7B,GAGME,IAAeA,MAAM;AACzB,IAAI5B,MAAc,gBAChByB,EAAAA,GACAJ,EAAeK,UAAUG,WAAW,MAAMlB,EAAkB,EAAK,GAAG,GAAG;AAAA,EAE3E,GAEMmB,IAAcA,MAAM;AACxBL,IAAAA,EAAAA,GACAd,EAAkB,EAAI;AAAA,EACxB,GAEMoB,IAA2BA,CAACC,MAA2B;AAC3D,QAAK3B,GACL;AAAA,UAAI2B,EAAEC,QAAQ,UAAU;AACtBD,UAAEE,eAAAA,GACFvB,EAAkB,EAAK;AACvB;A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AAIA,CAC9D,CACL,GACFoE,SAAS0B,IACX,CACC,IAxELU,gBAAAA,EAAAY,qBAAAC,EAAA;AAAA,IACEC,WAAU;AAAA,IACVjE,SAASF;AAAAA,EAAAA,GACL0D,GACAM,CAAmB,GAEvBX,gBAAAA,EAAAY,cAAA,OAAA;AAAA,IAAKE,WAAU;AAAA,EAAA,GACZf,CACE,GACLC,gBAAAA,EAAAY,cAAA,OAAA;AAAA,IACEG,KAAKvG;AAAAA,IACL2G,IAAIjG;AAAAA,IACJqF,MAAK;AAAA,IACLO,WAAW,iDAAiDlH,CAAQ;AAAA;AAAA;AAAA;AAAA,IAIpE,sBAAoBQ,KAAgB;AAAA,EAAA,GAEnCa,IAAkB+E,gBAAAA,EAAAY,cAAA,KAAA;AAAA,IAAGE,WAAU;AAAA,EAAA,GAAkBtH,CAAW,IAAIA,CAC9D,CACF;AAqDT;"}
1
+ {"version":3,"file":"index16.js","sources":["../src/components/Tooltip/index.tsx"],"sourcesContent":["import React, { useEffect, useState, useRef } from 'react';\nimport ReactDOM, { flushSync } from 'react-dom';\nimport { useStableId } from '../../utils/useStableId';\nimport { useDismissOnFocusOut } from '../../utils/a11y';\n\nexport interface TooltipProps {\n /**\n * Tooltip contents\n */\n content: string | React.ReactNode;\n /**\n * Tooltip position\n */\n position?:\n | 'top-left'\n | 'top-center'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'bottom-right'\n | 'left-top'\n | 'left-center'\n | 'left-bottom'\n | 'right-top'\n | 'right-center'\n | 'right-bottom';\n /**\n * Display tooltip on Hover, Click or Always\n */\n displayOn?: 'hover' | 'click' | 'always-on';\n /**\n * Tooltip trigger contents\n */\n tooltipSrc?: React.ReactNode;\n /**\n * Tooltip trigger contents ref\n */\n tooltipSrcRef?: React.RefObject<HTMLElement>;\n /**\n * When true, the real trigger is disabled and cannot receive focus.\n * Tooltip will make its wrapper focusable and treat it as a \"button\" that reveals tooltip content.\n */\n isTriggerDisabled?: boolean;\n /**\n * Required when isTriggerDisabled is true. Provides an accessible name for the focusable wrapper trigger.\n */\n disabledTriggerAriaLabel?: string;\n /**\n * Max width of the tooltip content\n */\n maxWidth?: number;\n /**\n * Whether to use portal for the tooltip content\n */\n isWithPortal?: boolean;\n /**\n * Tooltip content classes\n */\n tooltipContentClasses?: string;\n /**\n * Tooltip offset\n */\n tooltipOffset?: number;\n /**\n * Automation ID for testing\n */\n automationId?: string;\n}\n\nexport const Tooltip = ({\n content,\n tooltipSrc,\n position = 'bottom-center',\n displayOn = 'hover',\n maxWidth = 240,\n isWithPortal = false,\n tooltipSrcRef = undefined,\n isTriggerDisabled = false,\n disabledTriggerAriaLabel = undefined,\n tooltipContentClasses = '',\n tooltipOffset = 8,\n automationId = ''\n}: TooltipProps) => {\n const [displayTooltip, setDisplayTooltip] = useState(false);\n const tooltipContentRef = useRef<HTMLDivElement>(null);\n // Support for external ref when provided\n const internalToolTipSrcRef = useRef<HTMLDivElement>(null);\n const tooltipSourceRef = (tooltipSrcRef || internalToolTipSrcRef) as React.RefObject<HTMLElement>;\n const [tooltipPortalStyle, setTooltipPortalStyle] = useState({});\n const [isPortalPositioned, setIsPortalPositioned] = useState(false);\n const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isContentString = typeof content === 'string';\n const tooltipContentId = useStableId(undefined, 'tooltip-content');\n\n // Helper to clear hide timeout\n const clearHideTimeout = () => {\n if (hideTimeoutRef.current) {\n clearTimeout(hideTimeoutRef.current);\n hideTimeoutRef.current = null;\n }\n };\n\n // Helper to schedule hide\n const scheduleHide = () => {\n if (displayOn !== 'always-on') {\n clearHideTimeout();\n hideTimeoutRef.current = setTimeout(() => setDisplayTooltip(false), 150);\n }\n };\n\n const showTooltip = () => {\n clearHideTimeout();\n setDisplayTooltip(true);\n };\n\n const onDisabledTriggerKeyDown = (e: React.KeyboardEvent) => {\n if (!isTriggerDisabled) return;\n if (e.key === 'Escape') {\n e.preventDefault();\n setDisplayTooltip(false);\n return;\n }\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n setDisplayTooltip((prev) => !prev);\n }\n };\n\n // Enabled trigger: use React focus/blur capture handlers (no native event listeners).\n // This keeps the tooltip open while focus stays anywhere inside the tooltip wrapper.\n const dismissOnFocusOutProps = useDismissOnFocusOut<HTMLDivElement>({\n disabled: isTriggerDisabled,\n onFocusIn: showTooltip,\n onFocusOut: scheduleHide,\n onEscape: () => setDisplayTooltip(false)\n });\n\n useEffect(() => {\n const tooltipContent = tooltipContentRef.current;\n\n if (!tooltipContent) {\n return;\n }\n\n if (position == 'bottom-center') {\n tooltipContent.setAttribute('style', `left: 50%;transform: translateX(-50%);`);\n tooltipContent.classList.add(`before:left-[calc(50%-7px)]`);\n tooltipContent.classList.add(`before:top-[-7px]`);\n } else if (position == 'bottom-left') {\n tooltipContent.classList.add(`before:left-[calc(10%-7px)]`);\n tooltipContent.classList.add(`before:top-[-7px]`);\n } else if (position == 'bottom-right') {\n tooltipContent.setAttribute('style', `right: 0;`);\n tooltipContent.classList.add(`before:right-[calc(10%+7px)]`);\n tooltipContent.classList.add(`before:top-[-7px]`);\n } else if (position == 'top-center') {\n tooltipContent.setAttribute('style', `left: 50%;transform: translateX(-50%);bottom: calc(100% + 8px);`);\n tooltipContent.classList.add(`before:left-[calc(50%-7px)]`);\n tooltipContent.classList.add(`before:bottom-[-7px]`);\n } else if (position == 'top-left') {\n tooltipContent.setAttribute('style', `bottom: calc(100% + 8px);`);\n tooltipContent.classList.add(`before:left-[calc(10%-7px)]`);\n tooltipContent.classList.add(`before:bottom-[-7px]`);\n } else if (position == 'top-right') {\n tooltipContent.setAttribute('style', `right: 0;bottom: calc(100% + 8px);`);\n tooltipContent.classList.add(`before:right-[calc(10%+7px)]`);\n tooltipContent.classList.add(`before:bottom-[-7px]`);\n } else if (position == 'left-top') {\n tooltipContent.setAttribute('style', `right: calc(100% + 10px);top:0;`);\n tooltipContent.classList.add(`before:right-[-6px]`);\n tooltipContent.classList.add(`before:top-[7px]`);\n } else if (position == 'left-center') {\n tooltipContent.setAttribute('style', `right: calc(100% + 10px);top: 50%;transform: translateY(-50%);`);\n tooltipContent.classList.add(`before:right-[-6px]`);\n tooltipContent.classList.add(`before:top-[calc(50%-7px)]`);\n } else if (position == 'left-bottom') {\n tooltipContent.setAttribute('style', `right: calc(100% + 10px);bottom:0;`);\n tooltipContent.classList.add(`before:right-[-6px]`);\n tooltipContent.classList.add(`before:bottom-[7px]`);\n } else if (position == 'right-top') {\n tooltipContent.setAttribute('style', `left: calc(100% + 10px);top:0;`);\n tooltipContent.classList.add(`before:left-[-6px]`);\n tooltipContent.classList.add(`before:top-[7px]`);\n } else if (position == 'right-center') {\n tooltipContent.setAttribute('style', `left: calc(100% + 10px);top: 50%;transform: translateY(-50%);`);\n tooltipContent.classList.add(`before:left-[-6px]`);\n tooltipContent.classList.add(`before:top-[calc(50%-7px)]`);\n } else if (position == 'right-bottom') {\n tooltipContent.setAttribute('style', `left: calc(100% + 10px);bottom:0;`);\n tooltipContent.classList.add(`before:left-[-6px]`);\n tooltipContent.classList.add(`before:bottom-[7px]`);\n }\n\n if (displayOn == 'hover') {\n tooltipContent.classList.add(`group-hover:visible`);\n }\n }, [content]);\n\n useEffect(() => {\n const tooltipContent = tooltipContentRef.current;\n\n if (!tooltipContent) {\n return;\n }\n if (displayTooltip) {\n tooltipContent.classList.remove(`invisible`);\n } else {\n tooltipContent.classList.add(`invisible`);\n }\n }, [displayTooltip]);\n\n // Ensure tooltip stays open when displayOn is always-on\n useEffect(() => {\n if (displayOn === 'always-on') {\n setDisplayTooltip(true);\n }\n }, [displayOn]);\n\n const onTooltipSrcClick = () => {\n if (displayOn == 'click') {\n setDisplayTooltip((displayTooltip) => !displayTooltip);\n }\n };\n\n const toggleTooltip = () => {\n setDisplayTooltip((displayTooltip) => !displayTooltip);\n };\n\n const events = {\n ...(displayOn === 'click' && { onClick: toggleTooltip }),\n ...(displayOn === 'hover' && {\n onMouseEnter: () => setDisplayTooltip(true),\n onMouseLeave: () => setDisplayTooltip(false)\n })\n };\n\n const calculateTooltipPortalStyle = () => {\n const refToUse = tooltipSourceRef.current;\n if (!refToUse) {\n return {};\n }\n\n const srcRect = refToUse.getBoundingClientRect();\n const scrollX = window.scrollX || window.pageXOffset;\n const scrollY = window.scrollY || window.pageYOffset;\n const arrowSize = 14; // 14px (3.5 * 4 = 14px in Tailwind)\n\n // Get tooltip content dimensions if available\n const tooltipElement = document.getElementById(tooltipContentId);\n const tooltipWidth = tooltipElement?.offsetWidth || 0;\n const tooltipHeight = tooltipElement?.offsetHeight || 0;\n\n let top = 0;\n let left = 0;\n let arrowLeft = 0;\n let arrowTop = 0;\n\n switch (position) {\n case 'bottom-center':\n top = srcRect.bottom + scrollY + tooltipOffset;\n left = srcRect.left + scrollX + srcRect.width / 2 - tooltipWidth / 2;\n arrowLeft = tooltipWidth / 2 - arrowSize / 2;\n arrowTop = -arrowSize / 2;\n break;\n case 'bottom-left':\n top = srcRect.bottom + scrollY + tooltipOffset;\n left = srcRect.left + scrollX;\n arrowLeft = tooltipWidth * 0.1 - arrowSize / 2;\n arrowTop = -arrowSize / 2;\n break;\n case 'bottom-right':\n top = srcRect.bottom + scrollY + tooltipOffset;\n left = srcRect.right + scrollX - tooltipWidth;\n arrowLeft = tooltipWidth - tooltipWidth * 0.1 - arrowSize / 2;\n arrowTop = -arrowSize / 2;\n break;\n case 'top-center':\n top = srcRect.top + scrollY - tooltipHeight - tooltipOffset;\n left = srcRect.left + scrollX + srcRect.width / 2 - tooltipWidth / 2;\n arrowLeft = tooltipWidth / 2 - arrowSize / 2;\n arrowTop = tooltipHeight - arrowSize / 2;\n break;\n case 'top-left':\n top = srcRect.top + scrollY - tooltipHeight - tooltipOffset;\n left = srcRect.left + scrollX;\n arrowLeft = tooltipWidth * 0.1 - arrowSize / 2;\n arrowTop = tooltipHeight - arrowSize / 2;\n break;\n case 'top-right':\n top = srcRect.top + scrollY - tooltipHeight - tooltipOffset;\n left = srcRect.right + scrollX - tooltipWidth;\n arrowLeft = tooltipWidth - tooltipWidth * 0.1 - arrowSize / 2;\n arrowTop = tooltipHeight - arrowSize / 2;\n break;\n case 'left-top':\n top = srcRect.top + scrollY;\n left = srcRect.left + scrollX - tooltipWidth - tooltipOffset;\n arrowLeft = tooltipWidth - arrowSize / 2;\n arrowTop = arrowSize / 2;\n break;\n case 'left-center':\n top = srcRect.top + scrollY + srcRect.height / 2 - tooltipHeight / 2;\n left = srcRect.left + scrollX - tooltipWidth - tooltipOffset;\n arrowLeft = tooltipWidth - arrowSize / 2;\n arrowTop = tooltipHeight / 2 - arrowSize / 2;\n break;\n case 'left-bottom':\n top = srcRect.bottom + scrollY - tooltipHeight;\n left = srcRect.left + scrollX - tooltipWidth - tooltipOffset;\n arrowLeft = tooltipWidth - arrowSize / 2;\n arrowTop = tooltipHeight - arrowSize / 2;\n break;\n case 'right-top':\n top = srcRect.top + scrollY;\n left = srcRect.right + scrollX + tooltipOffset;\n arrowLeft = -arrowSize / 2;\n arrowTop = arrowSize / 2;\n break;\n case 'right-center':\n top = srcRect.top + scrollY + srcRect.height / 2 - tooltipHeight / 2;\n left = srcRect.right + scrollX + tooltipOffset;\n arrowLeft = -arrowSize / 2;\n arrowTop = tooltipHeight / 2 - arrowSize / 2;\n break;\n case 'right-bottom':\n top = srcRect.bottom + scrollY - tooltipHeight;\n left = srcRect.right + scrollX + tooltipOffset;\n arrowLeft = -arrowSize / 2;\n arrowTop = tooltipHeight - arrowSize / 2;\n break;\n default:\n top = srcRect.bottom + scrollY + tooltipOffset;\n left = srcRect.left + scrollX + srcRect.width / 2 - tooltipWidth / 2;\n arrowLeft = tooltipWidth / 2 - arrowSize / 2;\n arrowTop = -arrowSize / 2;\n break;\n }\n\n return {\n position: 'absolute',\n top: `${top}px`,\n left: `${left}px`,\n zIndex: 9999,\n '--arrow-left': `${arrowLeft}px`,\n '--arrow-top': `${arrowTop}px`\n } as React.CSSProperties & { '--arrow-left': string; '--arrow-top': string };\n };\n\n useEffect(() => {\n if (!displayTooltip || !isWithPortal) {\n setIsPortalPositioned(false);\n return;\n }\n\n const updatePosition = () => {\n const tooltipElement = document.getElementById(tooltipContentId);\n\n // Wait for tooltip to be rendered and have valid dimensions\n if (!tooltipElement || tooltipElement.offsetHeight === 0) {\n requestAnimationFrame(updatePosition);\n return;\n }\n\n const calculatedStyle = calculateTooltipPortalStyle();\n \n // Batch both state updates into a single synchronous render using flushSync\n flushSync(() => {\n setTooltipPortalStyle(calculatedStyle);\n setIsPortalPositioned(true);\n });\n };\n\n // Initial position calculation\n const timeout = setTimeout(updatePosition, tooltipSrcRef ? 60 : 10);\n\n const handleClick = (e: MouseEvent) => {\n const tooltip = document.getElementById(tooltipContentId);\n const source = tooltipSourceRef.current;\n const target = e.target as Node;\n\n if (tooltip && source && !tooltip.contains(target) && !source.contains(target)) {\n setDisplayTooltip(false);\n }\n };\n\n // Only add click listener if not always-on\n const shouldAddClickListener = displayOn !== 'always-on';\n if (shouldAddClickListener) {\n document.body.addEventListener('click', handleClick, true);\n }\n window.addEventListener('scroll', updatePosition, true);\n window.addEventListener('resize', updatePosition);\n\n // Watch for style changes on the source element when tooltipSrcRef is provided\n // This ensures the tooltip position updates when the blocker is repositioned\n let mutationObserver: MutationObserver | null = null;\n if (tooltipSrcRef && tooltipSourceRef.current) {\n mutationObserver = new MutationObserver(() => {\n updatePosition();\n });\n mutationObserver.observe(tooltipSourceRef.current, {\n attributes: true,\n attributeFilter: ['style', 'class']\n });\n }\n\n return () => {\n clearTimeout(timeout);\n clearHideTimeout();\n if (shouldAddClickListener) {\n document.body.removeEventListener('click', handleClick, true);\n }\n window.removeEventListener('scroll', updatePosition, true);\n window.removeEventListener('resize', updatePosition);\n if (mutationObserver) {\n mutationObserver.disconnect();\n }\n };\n }, [displayTooltip, isWithPortal, position, displayOn, tooltipSrcRef, tooltipContentId]);\n\n // For enabled triggers: link trigger to tooltip content via aria-describedby so screen\n // readers announce tooltip text on focus. Native elements need kebab-case only;\n // se-design components (Icon, Button) also accept camelCase ariaDescribedBy prop.\n // Disabled trigger already wires aria-describedby in disabledTriggerProps.\n const linkedTooltipSrc =\n !isTriggerDisabled && React.isValidElement(tooltipSrc)\n ? React.cloneElement(tooltipSrc as React.ReactElement<any>, {\n 'aria-describedby': tooltipContentId,\n ...(typeof tooltipSrc.type !== 'string' && { ariaDescribedBy: tooltipContentId })\n })\n : tooltipSrc;\n\n const disabledTriggerProps = isTriggerDisabled\n ? {\n tabIndex: 0,\n role: 'button' as const,\n 'aria-label': disabledTriggerAriaLabel,\n 'aria-describedby': tooltipContentId,\n onFocus: showTooltip,\n onBlur: scheduleHide,\n onKeyDown: onDisabledTriggerKeyDown\n }\n : undefined;\n\n const enabledTriggerProps = !isTriggerDisabled\n ? dismissOnFocusOutProps\n : undefined;\n\n return !isWithPortal ? (\n <div\n className=\"se-design-tooltip group relative inline-flex items-center\"\n onClick={onTooltipSrcClick}\n {...disabledTriggerProps}\n {...enabledTriggerProps}\n >\n <div className=\"cursor-pointer flex items-center\">\n {linkedTooltipSrc}\n </div>\n <div\n ref={tooltipContentRef}\n id={tooltipContentId}\n role=\"tooltip\"\n className={`flex justify-center px-3 py-2 min-w-24 max-w-[${maxWidth}px]\n absolute top-[calc(100%+8px)] w-max bg-[var(--color-gray-800)] text-[var(--color-white)] text-base rounded-[3px]\n before:content-[' '] before:w-3.5 before:h-3.5 before:bg-[var(--color-gray-800)] before:inline-block\n before:absolute before:rounded-tl-sm before:rotate-45`}\n data-automation-id={automationId || 'tooltip-content'}\n >\n {isContentString ? <p className=\"leading-normal\">{content}</p> : content}\n </div>\n </div>\n ) : (\n <div\n className=\"se-design-tooltip group relative inline-flex items-center\"\n {...events}\n {...disabledTriggerProps}\n {...enabledTriggerProps}\n >\n <div\n className=\"cursor-pointer flex items-center\"\n ref={tooltipSrcRef ? undefined : (tooltipSourceRef as React.RefObject<HTMLDivElement>)}\n onMouseEnter={displayOn === 'always-on' ? undefined : clearHideTimeout}\n onMouseLeave={scheduleHide}\n >\n {linkedTooltipSrc}\n </div>\n {displayTooltip &&\n ReactDOM.createPortal(\n <>\n <style>\n {`#${tooltipContentId}::before {\n left: var(--arrow-left, 0);\n top: var(--arrow-top, 0);\n }`}\n </style>\n <div\n id={tooltipContentId}\n role=\"tooltip\"\n className={`flex justify-center px-3 py-2 min-w-24 bg-[var(--color-gray-800)] text-[var(--color-white)] text-base rounded-[3px]\n before:content-[' '] before:w-3.5 before:h-3.5 before:bg-[var(--color-gray-800)] before:inline-block\n before:absolute before:rounded-tl-sm before:rotate-45 ${tooltipContentClasses}`}\n style={{\n ...tooltipPortalStyle,\n maxWidth: `${maxWidth}px`,\n wordBreak: 'break-word',\n overflowWrap: 'break-word',\n visibility: isPortalPositioned ? 'visible' : 'hidden',\n opacity: isPortalPositioned ? 1 : 0,\n pointerEvents: isPortalPositioned ? 'auto' : 'none',\n transition: isPortalPositioned ? 'opacity 0.15s ease-in' : 'none',\n // Ensure it stays at 0,0 until positioned to avoid any visual flash\n ...(isPortalPositioned ? {} : { position: 'fixed', top: '0px', left: '0px' })\n }}\n onMouseEnter={displayOn === 'always-on' ? undefined : clearHideTimeout}\n onMouseLeave={scheduleHide}\n >\n {isContentString ? <p className=\"leading-normal\">{content}</p> : content}\n </div>\n </>,\n document.body\n )}\n </div>\n );\n};\n"],"names":["Tooltip","content","tooltipSrc","position","displayOn","maxWidth","isWithPortal","tooltipSrcRef","undefined","isTriggerDisabled","disabledTriggerAriaLabel","tooltipContentClasses","tooltipOffset","automationId","displayTooltip","setDisplayTooltip","useState","tooltipContentRef","useRef","internalToolTipSrcRef","tooltipSourceRef","tooltipPortalStyle","setTooltipPortalStyle","isPortalPositioned","setIsPortalPositioned","hideTimeoutRef","isContentString","tooltipContentId","useStableId","clearHideTimeout","current","clearTimeout","scheduleHide","setTimeout","showTooltip","onDisabledTriggerKeyDown","e","key","preventDefault","prev","dismissOnFocusOutProps","useDismissOnFocusOut","disabled","onFocusIn","onFocusOut","onEscape","useEffect","tooltipContent","setAttribute","classList","add","remove","onTooltipSrcClick","events","onClick","toggleTooltip","onMouseEnter","onMouseLeave","calculateTooltipPortalStyle","refToUse","srcRect","getBoundingClientRect","scrollX","window","pageXOffset","scrollY","pageYOffset","arrowSize","tooltipElement","document","getElementById","tooltipWidth","offsetWidth","tooltipHeight","offsetHeight","top","left","arrowLeft","arrowTop","bottom","width","right","height","zIndex","updatePosition","requestAnimationFrame","calculatedStyle","flushSync","timeout","handleClick","tooltip","source","target","contains","shouldAddClickListener","body","addEventListener","mutationObserver","MutationObserver","observe","attributes","attributeFilter","removeEventListener","disconnect","linkedTooltipSrc","React","isValidElement","cloneElement","type","ariaDescribedBy","disabledTriggerProps","tabIndex","role","onFocus","onBlur","onKeyDown","enabledTriggerProps","createElement","_extends","className","ref","ReactDOM","createPortal","Fragment","id","style","wordBreak","overflowWrap","visibility","opacity","pointerEvents","transition"],"mappings":";;;;;;;;;;;;;;AAqEO,MAAMA,KAAUA,CAAC;AAAA,EACtBC,SAAAA;AAAAA,EACAC,YAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,WAAAA,IAAY;AAAA,EACZC,UAAAA,IAAW;AAAA,EACXC,cAAAA,IAAe;AAAA,EACfC,eAAAA,IAAgBC;AAAAA,EAChBC,mBAAAA,IAAoB;AAAA,EACpBC,0BAAAA,IAA2BF;AAAAA,EAC3BG,uBAAAA,IAAwB;AAAA,EACxBC,eAAAA,IAAgB;AAAA,EAChBC,cAAAA,IAAe;AACH,MAAM;AAClB,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAK,GACpDC,IAAoBC,EAAuB,IAAI,GAE/CC,IAAwBD,EAAuB,IAAI,GACnDE,IAAoBb,KAAiBY,GACrC,CAACE,GAAoBC,CAAqB,IAAIN,EAAS,CAAA,CAAE,GACzD,CAACO,GAAoBC,CAAqB,IAAIR,EAAS,EAAK,GAC5DS,IAAiBP,EAA6C,IAAI,GAClEQ,IAAkB,OAAOzB,KAAY,UACrC0B,IAAmBC,GAAYpB,QAAW,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AAc;AAAA,MACdC,YAAYzG,IAAqB,YAAY;AAAA,MAC7C0G,SAAS1G,IAAqB,IAAI;AAAA,MAClC2G,eAAe3G,IAAqB,SAAS;AAAA,MAC7C4G,YAAY5G,IAAqB,0BAA0B;AAAA;AAAA,MAE3D,GAAIA,IAAqB,CAAA,IAAK;AAAA,QAAEpB,UAAU;AAAA,QAASwE,KAAK;AAAA,QAAOC,MAAM;AAAA,MAAA;AAAA,IAAM;AAAA,IAE7EpB,cAAcpD,MAAc,cAAcI,SAAYqB;AAAAA,IACtD4B,cAAczB;AAAAA,EAAAA,GAEbN,IAAkB+E,gBAAAA,EAAAY,cAAA,KAAA;AAAA,IAAGE,WAAU;AAAA,EAAA,GAAkBtH,CAAW,IAAIA,CAC9D,CACL,GACFoE,SAAS0B,IACX,CACC,IAxELU,gBAAAA,EAAAY,qBAAAC,EAAA;AAAA,IACEC,WAAU;AAAA,IACVjE,SAASF;AAAAA,EAAAA,GACL0D,GACAM,CAAmB,GAEvBX,gBAAAA,EAAAY,cAAA,OAAA;AAAA,IAAKE,WAAU;AAAA,EAAA,GACZf,CACE,GACLC,gBAAAA,EAAAY,cAAA,OAAA;AAAA,IACEG,KAAKvG;AAAAA,IACL2G,IAAIjG;AAAAA,IACJqF,MAAK;AAAA,IACLO,WAAW,iDAAiDlH,CAAQ;AAAA;AAAA;AAAA;AAAA,IAIpE,sBAAoBQ,KAAgB;AAAA,EAAA,GAEnCa,IAAkB+E,gBAAAA,EAAAY,cAAA,KAAA;AAAA,IAAGE,WAAU;AAAA,EAAA,GAAkBtH,CAAW,IAAIA,CAC9D,CACF;AAqDT;"}
package/dist/index18.js CHANGED
@@ -1,65 +1,70 @@
1
- import n, { forwardRef as F, useState as C, useRef as P, useMemo as b } from "react";
2
- import { MenuItem as O } from "./index17.js";
3
- import { InputWithIcon as S } from "./index52.js";
4
- import { useRovingFocus as _ } from "./index70.js";
5
- function i() {
6
- return i = Object.assign ? Object.assign.bind() : function(a) {
7
- for (var o = 1; o < arguments.length; o++) {
8
- var r = arguments[o];
9
- for (var s in r) ({}).hasOwnProperty.call(r, s) && (a[s] = r[s]);
1
+ import n, { forwardRef as M, useState as C, useRef as P, useEffect as O, useMemo as h } from "react";
2
+ import { MenuItem as S } from "./index17.js";
3
+ import { InputWithIcon as _ } from "./index52.js";
4
+ import { useRovingFocus as j } from "./index70.js";
5
+ import { announce as B } from "./index75.js";
6
+ function f() {
7
+ return f = Object.assign ? Object.assign.bind() : function(o) {
8
+ for (var a = 1; a < arguments.length; a++) {
9
+ var r = arguments[a];
10
+ for (var s in r) ({}).hasOwnProperty.call(r, s) && (o[s] = r[s]);
10
11
  }
11
- return a;
12
- }, i.apply(null, arguments);
12
+ return o;
13
+ }, f.apply(null, arguments);
13
14
  }
14
- const j = /* @__PURE__ */ F(({
15
- items: a,
16
- maxHeight: o,
15
+ const Q = /* @__PURE__ */ M(({
16
+ items: o,
17
+ maxHeight: a,
17
18
  shouldShowSearch: r = !1,
18
19
  searchPlaceholder: s = "Search...",
19
- searchBy: h = "label",
20
- searchResultEmptyMessage: w = "No results found",
21
- className: m = ""
20
+ searchBy: w = "label",
21
+ searchResultEmptyMessage: d = "No results found",
22
+ className: y = ""
22
23
  }, x) => {
23
- const [d, D] = C(""), y = P(null), u = d.trim() ? a.filter((e) => (e[h]?.toString().toLowerCase() || "").includes(d.toLowerCase())) : a, E = o ? {
24
- maxHeight: o,
24
+ const [c, D] = C(""), g = P(null), l = c.trim() ? o.filter((e) => (e[w]?.toString().toLowerCase() || "").includes(c.toLowerCase())) : o;
25
+ O(() => {
26
+ l.length === 0 && c.trim() && B(d);
27
+ }, [l.length, c, d]);
28
+ const E = a ? {
29
+ maxHeight: a,
25
30
  overflowY: "auto"
26
- } : {}, f = b(() => {
31
+ } : {}, m = h(() => {
27
32
  const e = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new Set();
28
- return a.forEach((l, v) => {
29
- const I = l.id || l.automationId || `menu-item-${v}`;
30
- let c = I;
31
- t.has(c) && (c = `${I}-${v}`), t.add(c), e.set(l, c);
33
+ return o.forEach((u, I) => {
34
+ const b = u.id || u.automationId || `menu-item-${I}`;
35
+ let i = b;
36
+ t.has(i) && (i = `${b}-${I}`), t.add(i), e.set(u, i);
32
37
  }), e;
33
- }, [a]), p = b(() => u.filter((e) => e.type !== "header" && e.type !== "separator").map((e) => f.get(e)), [u, f]), {
38
+ }, [o]), p = h(() => l.filter((e) => e.type !== "header" && e.type !== "separator").map((e) => m.get(e)), [l, m]), {
34
39
  getRovingItemProps: K,
35
- handleKeyDown: R,
36
- setFocusedId: k,
37
- focusItem: g,
38
- getContainerProps: M
39
- } = _({
40
+ handleKeyDown: k,
41
+ setFocusedId: N,
42
+ focusItem: v,
43
+ getContainerProps: $
44
+ } = j({
40
45
  itemIds: p,
41
46
  orientation: "vertical",
42
47
  loop: !0,
43
48
  role: "menu"
44
- }), N = (e) => {
49
+ }), L = (e) => {
45
50
  if (r && e.key === "Tab" && e.shiftKey) {
46
- e.preventDefault(), y.current?.focus();
51
+ e.preventDefault(), g.current?.focus();
47
52
  return;
48
53
  }
49
- R(e);
50
- }, $ = (e) => {
54
+ k(e);
55
+ }, R = (e) => {
51
56
  if (e.key === "ArrowDown") {
52
57
  e.preventDefault();
53
58
  const t = p[0];
54
- t && g(t);
59
+ t && v(t);
55
60
  } else if (e.key === "Tab" && !e.shiftKey) {
56
61
  e.preventDefault();
57
62
  const t = p[0];
58
- t && g(t);
63
+ t && v(t);
59
64
  }
60
- }, L = () => /* @__PURE__ */ n.createElement("div", {
65
+ }, F = () => /* @__PURE__ */ n.createElement("div", {
61
66
  className: "w-full relative flex items-center border-b border-[var(--color-gray-300)] px-1"
62
- }, /* @__PURE__ */ n.createElement(S, {
67
+ }, /* @__PURE__ */ n.createElement(_, {
63
68
  leftIcon: {
64
69
  name: "search",
65
70
  position: "left",
@@ -67,7 +72,7 @@ const j = /* @__PURE__ */ F(({
67
72
  color: "var(--color-gray-500)"
68
73
  }
69
74
  },
70
- value: d,
75
+ value: c,
71
76
  onChange: (e) => D(e),
72
77
  placeholder: s,
73
78
  style: {
@@ -81,21 +86,21 @@ const j = /* @__PURE__ */ F(({
81
86
  },
82
87
  automationId: "se-design-menu-list-search",
83
88
  ariaLabel: s,
84
- inputRef: y,
89
+ inputRef: g,
85
90
  inputProps: {
86
- onKeyDown: $
91
+ onKeyDown: R
87
92
  }
88
93
  }));
89
94
  return /* @__PURE__ */ n.createElement("div", {
90
95
  ref: x,
91
- className: `se-design-menu-list border border-[var(--color-gray-200)] rounded shadow-md ${r ? "" : "py-2"}${m ? ` ${m}` : ""}`
92
- }, r && L(), /* @__PURE__ */ n.createElement("div", i({
96
+ className: `se-design-menu-list border border-[var(--color-gray-200)] rounded shadow-md ${r ? "" : "py-2"}${y ? ` ${y}` : ""}`
97
+ }, r && F(), /* @__PURE__ */ n.createElement("div", f({
93
98
  style: E,
94
99
  className: `overflow-y-auto ${r ? "py-2" : ""}`
95
- }, M({
100
+ }, $({
96
101
  ariaLabel: "Menu"
97
- })), u.length > 0 ? u.map((e) => {
98
- const t = f.get(e);
102
+ })), l.length > 0 ? l.map((e) => {
103
+ const t = m.get(e);
99
104
  if (e.type === "separator")
100
105
  return /* @__PURE__ */ n.createElement("hr", {
101
106
  key: t,
@@ -107,22 +112,20 @@ const j = /* @__PURE__ */ F(({
107
112
  className: "se-design-menu-header cursor-default px-2 mx-1 text-sm pt-2 text-[var(--color-gray-650)]",
108
113
  role: "presentation"
109
114
  }, e.label);
110
- const l = K(t);
111
- return /* @__PURE__ */ n.createElement(O, i({}, e, {
115
+ const u = K(t);
116
+ return /* @__PURE__ */ n.createElement(S, f({}, e, {
112
117
  key: t,
113
- ref: l.ref,
114
- tabIndex: l.tabIndex,
115
- onKeyDown: N,
116
- onFocus: () => k(t)
118
+ ref: u.ref,
119
+ tabIndex: u.tabIndex,
120
+ onKeyDown: L,
121
+ onFocus: () => N(t)
117
122
  }));
118
123
  }) : /* @__PURE__ */ n.createElement("div", {
119
- className: "px-3 py-4 text-center text-[var(--color-gray-700)] text-sm",
120
- role: "status",
121
- "aria-live": "polite"
122
- }, w)));
124
+ className: "px-3 py-4 text-center text-[var(--color-gray-700)] text-sm"
125
+ }, d)));
123
126
  });
124
- j.displayName = "MenuList";
127
+ Q.displayName = "MenuList";
125
128
  export {
126
- j as MenuList
129
+ Q as MenuList
127
130
  };
128
131
  //# sourceMappingURL=index18.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index18.js","sources":["../src/components/MenuList/index.tsx"],"sourcesContent":["import React, { forwardRef, useState, useMemo, useRef } from 'react';\nimport { MenuItem, MenuItemProps } from 'src/components/MenuItem';\nimport { InputWithIcon } from '../InputWithIcon';\nimport { useRovingFocus } from 'src/utils/a11y/useRovingFocus';\n\nexport type MenuListProps = {\n items: MenuItemProps[];\n maxHeight?: string;\n shouldShowSearch?: boolean;\n searchPlaceholder?: string;\n searchBy?: string;\n searchResultEmptyMessage?: string;\n className?: string;\n};\n\nexport const MenuList = forwardRef<HTMLDivElement, MenuListProps>(({\n items,\n maxHeight,\n shouldShowSearch = false,\n searchPlaceholder = 'Search...',\n searchBy = 'label',\n searchResultEmptyMessage = 'No results found',\n className = ''\n}, ref) => {\n const [searchQuery, setSearchQuery] = useState('');\n const searchInputRef = useRef<HTMLInputElement>(null);\n\n const getFilteredItems = () => {\n if (!searchQuery.trim()) {\n return items;\n }\n return items.filter((item) => {\n const searchValue = item[searchBy as keyof MenuItemProps]?.toString().toLowerCase() || '';\n return searchValue.includes(searchQuery.toLowerCase());\n });\n };\n\n const filteredItems = getFilteredItems();\n const containerStyle = maxHeight\n ? {\n maxHeight,\n overflowY: 'auto' as const\n }\n : {};\n\n const itemIdByRef = useMemo(() => {\n const map = new WeakMap<MenuItemProps, string>();\n const seen = new Set<string>();\n\n items.forEach((item, index) => {\n const baseId = item.id || item.automationId || `menu-item-${index}`;\n let uniqueId = baseId;\n\n if (seen.has(uniqueId)) {\n uniqueId = `${baseId}-${index}`;\n }\n\n seen.add(uniqueId);\n map.set(item, uniqueId);\n });\n\n return map;\n }, [items]);\n\n const itemIds = useMemo(() => {\n return filteredItems\n .filter((item) => item.type !== 'header' && item.type !== 'separator')\n .map((item) => itemIdByRef.get(item) as string);\n }, [filteredItems, itemIdByRef]);\n\n // Use roving focus for arrow key navigation\n const { getRovingItemProps, handleKeyDown: rovingHandleKeyDown, setFocusedId, focusItem, getContainerProps } = useRovingFocus({\n itemIds,\n orientation: 'vertical',\n loop: true,\n role: 'menu'\n });\n\n // Wrap roving keydown: when on a menu item, Shift+Tab goes back to search input\n const handleMenuItemKeyDown = (e: React.KeyboardEvent) => {\n if (shouldShowSearch && e.key === 'Tab' && e.shiftKey) {\n e.preventDefault();\n searchInputRef.current?.focus();\n return;\n }\n rovingHandleKeyDown(e);\n };\n\n // Search input keydown: ArrowDown enters the menu, Tab moves to first menu item\n const handleSearchKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n const firstId = itemIds[0];\n if (firstId) focusItem(firstId);\n } else if (e.key === 'Tab' && !e.shiftKey) {\n e.preventDefault();\n const firstId = itemIds[0];\n if (firstId) focusItem(firstId);\n }\n };\n\n const renderSearchBar = () => {\n return (\n <div className=\"w-full relative flex items-center border-b border-[var(--color-gray-300)] px-1\">\n <InputWithIcon\n leftIcon={{ name: 'search', position: 'left', style: { color: 'var(--color-gray-500)' } }}\n value={searchQuery}\n onChange={(value: string) => setSearchQuery(value)}\n placeholder={searchPlaceholder}\n style={{ margin: 0, gap: 0 }}\n inputStyle={{ width: '100%', border: 'none', outline: 'none' }}\n automationId=\"se-design-menu-list-search\"\n ariaLabel={searchPlaceholder}\n inputRef={searchInputRef}\n inputProps={{ onKeyDown: handleSearchKeyDown }}\n />\n </div>\n );\n };\n\n return (\n <div\n ref={ref}\n className={`se-design-menu-list border border-[var(--color-gray-200)] rounded shadow-md ${\n shouldShowSearch ? '' : 'py-2'\n }${className ? ` ${className}` : ''}`}\n >\n {shouldShowSearch && renderSearchBar()}\n <div\n style={containerStyle}\n className={`overflow-y-auto ${shouldShowSearch ? 'py-2' : ''}`}\n {...getContainerProps({ ariaLabel: 'Menu' })}\n >\n {filteredItems.length > 0 ? (\n filteredItems.map((item) => {\n const stableId = itemIdByRef.get(item) as string;\n\n if (item.type === 'separator') {\n return (\n <hr key={stableId} className=\"se-design-menu-separator cursor-default border-[var(--color-gray-200)]\" />\n );\n }\n\n if (item.type === 'header') {\n return (\n <div\n key={stableId}\n className=\"se-design-menu-header cursor-default px-2 mx-1 text-sm pt-2 text-[var(--color-gray-650)]\"\n role=\"presentation\"\n >\n {item.label}\n </div>\n );\n }\n\n const rovingProps = getRovingItemProps(stableId);\n return (\n <MenuItem\n {...item}\n key={stableId}\n ref={rovingProps.ref}\n tabIndex={rovingProps.tabIndex}\n onKeyDown={handleMenuItemKeyDown}\n onFocus={() => setFocusedId(stableId)}\n />\n );\n })\n ) : (\n <div className=\"px-3 py-4 text-center text-[var(--color-gray-700)] text-sm\" role=\"status\" aria-live=\"polite\">{searchResultEmptyMessage}</div>\n )}\n </div>\n </div>\n );\n});\n\nMenuList.displayName = 'MenuList';\n"],"names":["MenuList","items","maxHeight","shouldShowSearch","searchPlaceholder","searchBy","searchResultEmptyMessage","className","ref","searchQuery","setSearchQuery","useState","searchInputRef","useRef","filteredItems","trim","filter","item","toString","toLowerCase","includes","containerStyle","overflowY","itemIdByRef","useMemo","map","WeakMap","seen","Set","forEach","index","baseId","id","automationId","uniqueId","has","add","set","itemIds","type","get","getRovingItemProps","handleKeyDown","rovingHandleKeyDown","setFocusedId","focusItem","getContainerProps","useRovingFocus","orientation","loop","role","handleMenuItemKeyDown","e","key","shiftKey","preventDefault","current","focus","handleSearchKeyDown","firstId","renderSearchBar","React","createElement","InputWithIcon","leftIcon","name","position","style","color","value","onChange","placeholder","margin","gap","inputStyle","width","border","outline","ariaLabel","inputRef","inputProps","onKeyDown","_extends","length","stableId","label","rovingProps","MenuItem","tabIndex","onFocus","displayName"],"mappings":";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U;AAAA,EAAA,GAAU5C,CAA8B,CAE3I,CACF;AAET,CAAC;AAEDN,EAAS0F,cAAc;"}
1
+ {"version":3,"file":"index18.js","sources":["../src/components/MenuList/index.tsx"],"sourcesContent":["import React, { forwardRef, useState, useMemo, useRef, useEffect } from 'react';\nimport { MenuItem, MenuItemProps } from 'src/components/MenuItem';\nimport { InputWithIcon } from '../InputWithIcon';\nimport { useRovingFocus } from 'src/utils/a11y/useRovingFocus';\nimport { announce } from '../../utils/a11y/liveAnnouncer';\n\nexport type MenuListProps = {\n items: MenuItemProps[];\n maxHeight?: string;\n shouldShowSearch?: boolean;\n searchPlaceholder?: string;\n searchBy?: string;\n searchResultEmptyMessage?: string;\n className?: string;\n};\n\nexport const MenuList = forwardRef<HTMLDivElement, MenuListProps>(({\n items,\n maxHeight,\n shouldShowSearch = false,\n searchPlaceholder = 'Search...',\n searchBy = 'label',\n searchResultEmptyMessage = 'No results found',\n className = ''\n}, ref) => {\n const [searchQuery, setSearchQuery] = useState('');\n const searchInputRef = useRef<HTMLInputElement>(null);\n\n const getFilteredItems = () => {\n if (!searchQuery.trim()) {\n return items;\n }\n return items.filter((item) => {\n const searchValue = item[searchBy as keyof MenuItemProps]?.toString().toLowerCase() || '';\n return searchValue.includes(searchQuery.toLowerCase());\n });\n };\n\n const filteredItems = getFilteredItems();\n\n useEffect(() => {\n if (filteredItems.length === 0 && searchQuery.trim()) {\n announce(searchResultEmptyMessage);\n }\n }, [filteredItems.length, searchQuery, searchResultEmptyMessage]);\n\n const containerStyle = maxHeight\n ? {\n maxHeight,\n overflowY: 'auto' as const\n }\n : {};\n\n const itemIdByRef = useMemo(() => {\n const map = new WeakMap<MenuItemProps, string>();\n const seen = new Set<string>();\n\n items.forEach((item, index) => {\n const baseId = item.id || item.automationId || `menu-item-${index}`;\n let uniqueId = baseId;\n\n if (seen.has(uniqueId)) {\n uniqueId = `${baseId}-${index}`;\n }\n\n seen.add(uniqueId);\n map.set(item, uniqueId);\n });\n\n return map;\n }, [items]);\n\n const itemIds = useMemo(() => {\n return filteredItems\n .filter((item) => item.type !== 'header' && item.type !== 'separator')\n .map((item) => itemIdByRef.get(item) as string);\n }, [filteredItems, itemIdByRef]);\n\n // Use roving focus for arrow key navigation\n const { getRovingItemProps, handleKeyDown: rovingHandleKeyDown, setFocusedId, focusItem, getContainerProps } = useRovingFocus({\n itemIds,\n orientation: 'vertical',\n loop: true,\n role: 'menu'\n });\n\n // Wrap roving keydown: when on a menu item, Shift+Tab goes back to search input\n const handleMenuItemKeyDown = (e: React.KeyboardEvent) => {\n if (shouldShowSearch && e.key === 'Tab' && e.shiftKey) {\n e.preventDefault();\n searchInputRef.current?.focus();\n return;\n }\n rovingHandleKeyDown(e);\n };\n\n // Search input keydown: ArrowDown enters the menu, Tab moves to first menu item\n const handleSearchKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n const firstId = itemIds[0];\n if (firstId) focusItem(firstId);\n } else if (e.key === 'Tab' && !e.shiftKey) {\n e.preventDefault();\n const firstId = itemIds[0];\n if (firstId) focusItem(firstId);\n }\n };\n\n const renderSearchBar = () => {\n return (\n <div className=\"w-full relative flex items-center border-b border-[var(--color-gray-300)] px-1\">\n <InputWithIcon\n leftIcon={{ name: 'search', position: 'left', style: { color: 'var(--color-gray-500)' } }}\n value={searchQuery}\n onChange={(value: string) => setSearchQuery(value)}\n placeholder={searchPlaceholder}\n style={{ margin: 0, gap: 0 }}\n inputStyle={{ width: '100%', border: 'none', outline: 'none' }}\n automationId=\"se-design-menu-list-search\"\n ariaLabel={searchPlaceholder}\n inputRef={searchInputRef}\n inputProps={{ onKeyDown: handleSearchKeyDown }}\n />\n </div>\n );\n };\n\n return (\n <div\n ref={ref}\n className={`se-design-menu-list border border-[var(--color-gray-200)] rounded shadow-md ${\n shouldShowSearch ? '' : 'py-2'\n }${className ? ` ${className}` : ''}`}\n >\n {shouldShowSearch && renderSearchBar()}\n <div\n style={containerStyle}\n className={`overflow-y-auto ${shouldShowSearch ? 'py-2' : ''}`}\n {...getContainerProps({ ariaLabel: 'Menu' })}\n >\n {filteredItems.length > 0 ? (\n filteredItems.map((item) => {\n const stableId = itemIdByRef.get(item) as string;\n\n if (item.type === 'separator') {\n return (\n <hr key={stableId} className=\"se-design-menu-separator cursor-default border-[var(--color-gray-200)]\" />\n );\n }\n\n if (item.type === 'header') {\n return (\n <div\n key={stableId}\n className=\"se-design-menu-header cursor-default px-2 mx-1 text-sm pt-2 text-[var(--color-gray-650)]\"\n role=\"presentation\"\n >\n {item.label}\n </div>\n );\n }\n\n const rovingProps = getRovingItemProps(stableId);\n return (\n <MenuItem\n {...item}\n key={stableId}\n ref={rovingProps.ref}\n tabIndex={rovingProps.tabIndex}\n onKeyDown={handleMenuItemKeyDown}\n onFocus={() => setFocusedId(stableId)}\n />\n );\n })\n ) : (\n <div className=\"px-3 py-4 text-center text-[var(--color-gray-700)] text-sm\">{searchResultEmptyMessage}</div>\n )}\n </div>\n </div>\n );\n});\n\nMenuList.displayName = 'MenuList';\n"],"names":["MenuList","items","maxHeight","shouldShowSearch","searchPlaceholder","searchBy","searchResultEmptyMessage","className","ref","searchQuery","setSearchQuery","useState","searchInputRef","useRef","filteredItems","trim","filter","item","toString","toLowerCase","includes","useEffect","length","announce","containerStyle","overflowY","itemIdByRef","useMemo","map","WeakMap","seen","Set","forEach","index","baseId","id","automationId","uniqueId","has","add","set","itemIds","type","get","getRovingItemProps","handleKeyDown","rovingHandleKeyDown","setFocusedId","focusItem","getContainerProps","useRovingFocus","orientation","loop","role","handleMenuItemKeyDown","e","key","shiftKey","preventDefault","current","focus","handleSearchKeyDown","firstId","renderSearchBar","React","createElement","InputWithIcon","leftIcon","name","position","style","color","value","onChange","placeholder","margin","gap","inputStyle","width","border","outline","ariaLabel","inputRef","inputProps","onKeyDown","_extends","stableId","label","rovingProps","MenuItem","tabIndex","onFocus","displayName"],"mappings":";;;;;;;;;;;;;;AAgBO,MAAMA,sBAAqD,CAAC;AAAA,E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,CACvC;AAAA,EAEL,CAAC,IAEDtB,gBAAAA,EAAAC,cAAA,OAAA;AAAA,IAAK1D,WAAU;AAAA,EAAA,GAA8DD,CAA8B,CAE1G,CACF;AAET,CAAC;AAEDN,EAAS4F,cAAc;"}
package/dist/index19.js CHANGED
@@ -6,17 +6,17 @@ import { getFirstFocusableElement as D, getLastFocusableElement as Ee, getFocusa
6
6
  import "./index72.js";
7
7
  import { useRegisterPortalWithFocusTrap as Pe } from "./index208.js";
8
8
  function T() {
9
- return T = Object.assign ? Object.assign.bind() : function(b) {
10
- for (var y = 1; y < arguments.length; y++) {
11
- var m = arguments[y];
12
- for (var h in m) ({}).hasOwnProperty.call(m, h) && (b[h] = m[h]);
9
+ return T = Object.assign ? Object.assign.bind() : function(y) {
10
+ for (var E = 1; E < arguments.length; E++) {
11
+ var m = arguments[E];
12
+ for (var h in m) ({}).hasOwnProperty.call(m, h) && (y[h] = m[h]);
13
13
  }
14
- return b;
14
+ return y;
15
15
  }, T.apply(null, arguments);
16
16
  }
17
17
  const He = /* @__PURE__ */ we(({
18
- className: b = "",
19
- automationId: y = "",
18
+ className: y = "",
19
+ automationId: E = "",
20
20
  position: m = "bottom-center",
21
21
  popoverContentAutomationId: h = "",
22
22
  contentWidth: R = "max",
@@ -24,7 +24,7 @@ const He = /* @__PURE__ */ we(({
24
24
  renderPopoverSrcElement: oe,
25
25
  onPopoverToggle: z,
26
26
  isPopoverOpen: C,
27
- disabled: E = !1,
27
+ disabled: k = !1,
28
28
  isWithPortal: f = !1,
29
29
  ariaLabel: ne,
30
30
  ariaLabelledBy: re,
@@ -42,7 +42,7 @@ const He = /* @__PURE__ */ we(({
42
42
  focusFirstOnOpen: ie = !1,
43
43
  ...ce
44
44
  }, ae) => {
45
- const [i, p] = F(!1), [k, U] = F(m), [le, V] = F(!1), l = te(null), c = te(null);
45
+ const [i, p] = F(!1), [P, U] = F(m), [le, V] = F(!1), l = te(null), c = te(null);
46
46
  Pe(c, f && i);
47
47
  const ue = be({
48
48
  ariaLabel: ne,
@@ -59,14 +59,14 @@ const He = /* @__PURE__ */ we(({
59
59
  top: 0,
60
60
  left: 0,
61
61
  srcWidth: 0
62
- }), [pe, W] = F(!1), P = () => {
62
+ }), [pe, W] = F(!1), b = () => {
63
63
  g ? (D({
64
64
  container: l.current,
65
65
  includeRoles: !0
66
66
  }) ?? l.current)?.focus() : l.current?.focus();
67
67
  }, X = (e) => {
68
68
  p(!1), e?.returnFocus !== !1 && requestAnimationFrame(() => {
69
- e?.returnFocusTo ? (e.returnFocusTo instanceof HTMLElement ? e.returnFocusTo : e.returnFocusTo.current)?.focus() : P();
69
+ e?.returnFocusTo ? (e.returnFocusTo instanceof HTMLElement ? e.returnFocusTo : e.returnFocusTo.current)?.focus() : b();
70
70
  });
71
71
  }, O = (e = "bottom-center") => {
72
72
  if (!l.current) return {
@@ -119,13 +119,13 @@ const He = /* @__PURE__ */ we(({
119
119
  if (i && f) {
120
120
  v ? window.addEventListener("scroll", G) : (document.body.addEventListener("click", I, !0), window.addEventListener("scroll", I)), window.addEventListener("resize", Y);
121
121
  const e = (r) => {
122
- r.key === "Escape" && c.current?.contains(document.activeElement) && (r.preventDefault(), r.stopPropagation(), p(!1), requestAnimationFrame(() => P()));
122
+ r.key === "Escape" && c.current?.contains(document.activeElement) && (r.preventDefault(), r.stopPropagation(), p(!1), requestAnimationFrame(() => b()));
123
123
  };
124
124
  window.addEventListener("keydown", e, !0), H();
125
125
  let o, t;
126
126
  return o = requestAnimationFrame(() => {
127
127
  t = requestAnimationFrame(() => {
128
- const r = O(k);
128
+ const r = O(P);
129
129
  r && A(r), W(!0);
130
130
  });
131
131
  }), () => {
@@ -165,7 +165,7 @@ const He = /* @__PURE__ */ we(({
165
165
  const o = l.current, t = c.current;
166
166
  if (!o) return;
167
167
  if (H(), e.type === "scroll" && i) {
168
- const w = O(k);
168
+ const w = O(P);
169
169
  w && A(w);
170
170
  }
171
171
  const r = e.target, u = o.contains(r), a = t?.contains(r), s = r.closest?.(".se-design-popover-wrapper"), d = s && s !== o, x = c.current?.contains(s);
@@ -173,13 +173,13 @@ const He = /* @__PURE__ */ we(({
173
173
  }, Y = () => {
174
174
  if (i && f && l.current) {
175
175
  H();
176
- const e = O(k);
176
+ const e = O(P);
177
177
  e && A(e);
178
178
  }
179
179
  }, G = () => {
180
180
  if (i && f && l.current) {
181
181
  H();
182
- const e = O(k);
182
+ const e = O(P);
183
183
  e && A(e);
184
184
  }
185
185
  }, S = (e = !1) => {
@@ -214,7 +214,7 @@ const He = /* @__PURE__ */ we(({
214
214
  e.key === "ArrowDown" ? (e.preventDefault(), e.stopPropagation(), a = u < r.length - 1 ? u + 1 : 0) : e.key === "ArrowUp" ? (e.preventDefault(), e.stopPropagation(), a = u > 0 ? u - 1 : r.length - 1) : e.key === "Home" ? (e.preventDefault(), e.stopPropagation(), a = 0) : e.key === "End" && (e.preventDefault(), e.stopPropagation(), a = r.length - 1), a >= 0 && r[a] ? r[a].focus() : u === -1 && r.length > 0 && r[0].focus();
215
215
  }, Q = (e) => {
216
216
  if (e.key === "Escape")
217
- e.preventDefault(), e.stopPropagation(), p(!1), requestAnimationFrame(() => P());
217
+ e.preventDefault(), e.stopPropagation(), p(!1), requestAnimationFrame(() => b());
218
218
  else if (e.key === "Tab") {
219
219
  if (_ === "dialog") {
220
220
  const o = N({
@@ -222,7 +222,7 @@ const He = /* @__PURE__ */ we(({
222
222
  filterHidden: !0
223
223
  }), t = o.indexOf(e.target), r = t === o.length - 1, u = t === 0 || t === -1;
224
224
  if (e.shiftKey && u)
225
- e.preventDefault(), p(!1), P();
225
+ e.preventDefault(), p(!1), b();
226
226
  else if (!e.shiftKey && r && (p(!1), f)) {
227
227
  e.preventDefault();
228
228
  const a = l.current, n = N({
@@ -232,7 +232,7 @@ const He = /* @__PURE__ */ we(({
232
232
  d ? d.focus() : a?.focus();
233
233
  }
234
234
  } else if (p(!1), e.shiftKey)
235
- e.preventDefault(), P();
235
+ e.preventDefault(), b();
236
236
  else if (f) {
237
237
  e.preventDefault();
238
238
  const o = l.current, t = N({
@@ -245,7 +245,7 @@ const He = /* @__PURE__ */ we(({
245
245
  };
246
246
  ge(ae, () => ({
247
247
  togglePopover: S,
248
- focusTrigger: () => l.current?.focus(),
248
+ focusTrigger: () => b(),
249
249
  element: l.current
250
250
  }), []);
251
251
  const me = {
@@ -277,13 +277,13 @@ const He = /* @__PURE__ */ we(({
277
277
  }
278
278
  }, Z = se ? "" : "shadow-md border rounded-md";
279
279
  return /* @__PURE__ */ B.createElement("div", T({
280
- className: "se-design-popover-wrapper cursor-pointer relative focus-outline rounded-md" + (b.length > 0 ? ` ${b}` : "") + (i ? " open" : "") + (E ? " opacity-50 cursor-not-allowed pointer-events-none" : ""),
280
+ className: "se-design-popover-wrapper cursor-pointer relative focus-outline rounded-md" + (y.length > 0 ? ` ${y}` : "") + (i ? " open" : "") + (k ? " opacity-50 cursor-not-allowed pointer-events-none" : ""),
281
281
  ref: l,
282
282
  onClick: (e) => {
283
- E || g || (e.stopPropagation(), S());
283
+ k || g || (e.stopPropagation(), S());
284
284
  },
285
285
  onKeyDown: (e) => {
286
- if (!(E || g))
286
+ if (!(k || g))
287
287
  if (e.key === "Enter" || e.key === " ") {
288
288
  e.preventDefault(), e.stopPropagation();
289
289
  const o = i;
@@ -316,10 +316,10 @@ const He = /* @__PURE__ */ we(({
316
316
  role: g ? "none" : q,
317
317
  "aria-expanded": g ? void 0 : i ? "true" : "false",
318
318
  "aria-haspopup": g ? void 0 : q === "combobox" ? "listbox" : _,
319
- tabIndex: E || g ? -1 : 0,
320
- "aria-disabled": g ? void 0 : E ? "true" : void 0
319
+ tabIndex: k || g ? -1 : 0,
320
+ "aria-disabled": g ? void 0 : k ? "true" : void 0
321
321
  }, ue, {
322
- "data-automation-id": y
322
+ "data-automation-id": E
323
323
  }, ce), oe({
324
324
  displayPopover: i,
325
325
  togglePopover: S
@@ -327,7 +327,7 @@ const He = /* @__PURE__ */ we(({
327
327
  className: `popover-content absolute ${Z} z-[1000] ${R == "full" ? "w-full" : "w-max"}`,
328
328
  style: {
329
329
  ...$,
330
- ...me[k]
330
+ ...me[P]
331
331
  },
332
332
  onClick: (e) => e.stopPropagation(),
333
333
  onKeyDown: Q,