Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
5.0 KiB
Plaintext
1 line
5.0 KiB
Plaintext
{"version":3,"file":"index.js","names":["React","useEffect","useIntersect","Tooltip","props","alignCaret","boundingRef","children","className","delay","position","positionFromProps","show","showFromProps","staticPositioning","setShow","useState","setPosition","getTitleAttribute","content","ref","intersectionEntry","root","current","rootMargin","threshold","timerID","setTimeout","clearTimeout","isIntersecting","_jsxs","Fragment","_jsx","filter","Boolean","join","style","opacity","title"],"sources":["../../../src/elements/Tooltip/index.tsx"],"sourcesContent":["'use client'\nimport React, { useEffect } from 'react'\n\nimport { useIntersect } from '../../hooks/useIntersect.js'\nimport './index.scss'\n\nexport type Props = {\n alignCaret?: 'center' | 'left' | 'right'\n boundingRef?: React.RefObject<HTMLElement | null>\n children: React.ReactNode\n className?: string\n delay?: number\n position?: 'bottom' | 'top'\n show?: boolean\n /**\n * If the tooltip position should not change depending on if the toolbar is outside the boundingRef. @default false\n */\n staticPositioning?: boolean\n}\n\nexport const Tooltip: React.FC<Props> = (props) => {\n const {\n alignCaret = 'center',\n boundingRef,\n children,\n className,\n delay = 350,\n position: positionFromProps,\n show: showFromProps = true,\n staticPositioning = false,\n } = props\n\n const [show, setShow] = React.useState(showFromProps)\n const [position, setPosition] = React.useState<'bottom' | 'top'>('top')\n\n const getTitleAttribute = (content) => (typeof content === 'string' ? content : '')\n\n const [ref, intersectionEntry] = useIntersect(\n {\n root: boundingRef?.current || null,\n rootMargin: '-145px 0px 0px 100px',\n threshold: 0,\n },\n staticPositioning,\n )\n\n useEffect(() => {\n let timerID: NodeJS.Timeout\n\n // do not use the delay on transition-out\n if (delay && showFromProps) {\n timerID = setTimeout(() => {\n setShow(showFromProps)\n }, delay)\n } else {\n setShow(showFromProps)\n }\n\n return () => {\n if (timerID) {\n clearTimeout(timerID)\n }\n }\n }, [showFromProps, delay])\n\n useEffect(() => {\n if (staticPositioning) {\n return\n }\n setPosition(intersectionEntry?.isIntersecting ? 'top' : 'bottom')\n }, [intersectionEntry, staticPositioning])\n\n // The first aside is always on top. The purpose of that is that it can reliably be used for the interaction observer (as it's not moving around), to calculate the position of the actual tooltip.\n return (\n <React.Fragment>\n {!staticPositioning && (\n <aside\n aria-hidden=\"true\"\n className={['tooltip', className, `tooltip--caret-${alignCaret}`, 'tooltip--position-top']\n .filter(Boolean)\n .join(' ')}\n ref={ref}\n style={{ opacity: '0' }}\n >\n <div className=\"tooltip-content\">{children}</div>\n </aside>\n )}\n <aside\n className={[\n 'tooltip',\n className,\n show && 'tooltip--show',\n `tooltip--caret-${alignCaret}`,\n `tooltip--position-${positionFromProps || position}`,\n ]\n .filter(Boolean)\n .join(' ')}\n title={getTitleAttribute(children)}\n >\n <div className=\"tooltip-content\">{children}</div>\n </aside>\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,IAASC,SAAS,QAAQ;AAEjC,SAASC,YAAY,QAAQ;AAC7B,OAAO;AAgBP,OAAO,MAAMC,OAAA,GAA4BC,KAAA;EACvC,MAAM;IACJC,UAAA,GAAa,QAAQ;IACrBC,WAAW;IACXC,QAAQ;IACRC,SAAS;IACTC,KAAA,GAAQ,GAAG;IACXC,QAAA,EAAUC,iBAAiB;IAC3BC,IAAA,EAAMC,aAAA,GAAgB,IAAI;IAC1BC,iBAAA,GAAoB;EAAK,CAC1B,GAAGV,KAAA;EAEJ,MAAM,CAACQ,IAAA,EAAMG,OAAA,CAAQ,GAAGf,KAAA,CAAMgB,QAAQ,CAACH,aAAA;EACvC,MAAM,CAACH,QAAA,EAAUO,WAAA,CAAY,GAAGjB,KAAA,CAAMgB,QAAQ,CAAmB;EAEjE,M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