/** * Source for the null-rendering `TqCollapsibleTextOverflow` helper shipped into * every Next project's `_app` (via `injectSiblingIntoApp`, the same mechanism the * analytics tracker and nav active-link highlighter use). * * Why a global helper and not per-node JS: the Collapsible Text primitive * decomposes to plain elements — a clamped view (`-webkit-line-clamp`), an * expanded view, and Show more / See less labels gated by a boolean state. None * of that can know whether the text ACTUALLY overflows its clamp, because that * depends on the rendered content, the column width, and the font — a runtime * measurement. This helper measures each collapsed view (`scrollHeight > * clientHeight`) and stamps `data-tq-overflows` on the root; a CSS rule then * hides the Show more label when the content already fits, so short text gets no * dangling toggle. It re-measures on resize and on DOM changes (SPA route * changes, and the expand/collapse remounting the clamped view). * * Self-contained: pure DOM, no npm dependency, and a no-op on any page that has * no collapsible-text blocks. */ export declare const COLLAPSIBLE_TEXT_OVERFLOW_COMPONENT_SOURCE = "import React from 'react';\n\nvar STYLE_ID = 'tq-collapsible-text-overflow-style';\n// When a root is measured as NOT overflowing, its Show more label is hidden.\nvar STYLE_CONTENT =\n '[data-tq-overflows=\"false\"] [data-tq-collapsible-more]{display:none !important;}';\n\nfunction ensureStyle() {\n if (typeof document === 'undefined' || document.getElementById(STYLE_ID)) {\n return;\n }\n var style = document.createElement('style');\n style.id = STYLE_ID;\n style.textContent = STYLE_CONTENT;\n document.head.appendChild(style);\n}\n\nfunction measureRoot(root) {\n // The clamped view is only in the DOM while collapsed. When expanded the Show\n // more label is already gone (See less shows instead), so a missing clamp means\n // \"leave the last measurement in place\" rather than forcing a false negative.\n var clamp = root.querySelector('[data-tq-collapsible-clamp]');\n if (!clamp) {\n return;\n }\n var overflows = clamp.scrollHeight - clamp.clientHeight > 1;\n root.setAttribute('data-tq-overflows', overflows ? 'true' : 'false');\n}\n\nfunction measureAll() {\n if (typeof document === 'undefined') {\n return;\n }\n var roots = document.querySelectorAll('[data-tq-collapsible-root]');\n for (var i = 0; i < roots.length; i++) {\n measureRoot(roots[i]);\n }\n}\n\nexport default function TqCollapsibleTextOverflow() {\n React.useEffect(function () {\n if (typeof document === 'undefined' || typeof window === 'undefined') {\n return undefined;\n }\n ensureStyle();\n\n var frame = 0;\n var schedule = function () {\n if (frame) {\n return;\n }\n frame = window.requestAnimationFrame(function () {\n frame = 0;\n measureAll();\n });\n };\n\n // Initial pass (rAF so layout + web fonts have settled).\n schedule();\n\n window.addEventListener('resize', schedule);\n\n // Re-measure when the DOM changes: client-side route changes, async content,\n // and the expand/collapse conditional remounting the clamped view.\n var observer =\n typeof MutationObserver !== 'undefined'\n ? new MutationObserver(function () {\n schedule();\n })\n : null;\n if (observer && document.body) {\n observer.observe(document.body, { childList: true, subtree: true });\n }\n\n return function () {\n if (frame) {\n window.cancelAnimationFrame(frame);\n }\n window.removeEventListener('resize', schedule);\n if (observer) {\n observer.disconnect();\n }\n };\n }, []);\n\n return null;\n}\n"; //# sourceMappingURL=collapsible-text-overflow-component.d.ts.map