/** * Smart Link flag module — imperative singleton pattern. * * ## Why not a React context provider? * * The natural approach would be to render a `` inside the Card * component tree, managing flag state via React context. This was the original * implementation. However, it caused a critical bug: * * When a parent component of smart card changed, either swap or unmount, * it unmounts the entire card subtree including `FlagsProvider`. * Any flag that was visible at that moment is instantly destroyed and lost. * * ## Why an injected React root? * * This module manages a persistent `FlagGroup` at `document.body` via its own * `createRoot` — completely independent of any card component tree. The root is created * lazily on the first `showFlag` call and kept alive indefinitely, re-rendering with * the current flags array on every change. * * Benefits: * - Flags survive any card unmount/remount cycle * - No provider needed anywhere in the component tree * - Works identically for all card paths (Card, CardSSR) * - Same pattern as `EmbedModal/utils.tsx` but for a persistent group * * Usage: import `showFlag` and call it directly — no provider needed. */ import type { FlagProps } from '@atlaskit/flag/types'; /** * Show a flag notification. The FlagGroup root is created lazily on first call * and persists for the lifetime of the page — it is never torn down by card unmounts. * * If a flag with the same `id` already exists it is replaced in-place (idempotent). */ type ShowFlagOptions = Omit & { id?: FlagProps['id']; }; export declare const showFlag: (options: ShowFlagOptions) => void; /** * Resets all module-level singleton state and removes the DOM container. * * Only intended for use in tests — do not call in production code. * The `_` prefix signals this is a test-only utility. * * Why exported from this file rather than a separate test helper: * This module manages private `let` variables (`flagsState`, `root`, etc.) that cannot * be accessed from outside the module closure. Exporting a reset function is the only * clean way to reset them without using `jest.resetModules()` (which requires all tests * to use `require()` instead of top-level imports and is significantly slower). */ export declare const _resetFlagsForTesting: () => void; export {};