import { ReactNode } from 'react'; /** * Imperative handle exposed by PortalManager via ref. */ export interface PortalManagerHandle { /** * Add or update a portal entry. The update is batched — * all calls within the same microtask are coalesced into * a single React commit via `flushSync`. */ renderPortal(key: string, container: HTMLElement, element: ReactNode): void; /** * Remove a portal by key. * @param key unique key of the portal to remove * @param sync - When true, flush the removal synchronously via `flushSync` * so the caller can safely mutate the container DOM immediately after. * Use this in cleanup callbacks that precede external DOM clearing * (e.g., tool panel accordion collapse sets `innerHTML = ''`). * While a batch is open via {@link beginBatch}, the sync flush is * suppressed and the deletion rides the batch's deferred render — * the caller is then responsible for ensuring the affected container * is detached before {@link endBatch} runs. */ removePortal(key: string, sync?: boolean): void; /** * Open a teardown batch. While open, sync portal removals do NOT trigger * `flushSync` per call. Multiple bulk-cleanup paths (`_clearRowPool`, * row-pool shrink, row rebuild) can release N portals without emitting * N `flushSync was called from inside a lifecycle method` warnings. * * Calls nest; only the outermost {@link endBatch} schedules the flush. * * Caller MUST detach every affected container from the DOM before * `endBatch()` runs — otherwise the deferred render commits an unmount * against a container whose children were already wiped, reproducing * the original `removeChild` `NotFoundError` that issue #250 fixed. * Bulk paths in grid core (`_clearRowPool`, pool-shrink, `renderInlineRow`) * satisfy this naturally because they wipe the parent (`bodyEl.innerHTML = ''`, * `el.remove()`, `rowEl.innerHTML = ''`) AFTER the per-cell release loop. */ beginBatch(): void; /** * Close a teardown batch. When the depth returns to zero, schedules a * single render so the manager's render-time `isConnected` filter drops * any portals whose containers are now detached. No `flushSync` is used. */ endBatch(): void; /** Remove all portals. */ clear(): void; } /** * React component that manages portal-based rendering for the grid adapter. * * Mount this inside the application's React tree (inside all providers) * so that portal content inherits the full context chain. * * @internal */ export declare const PortalManager: import('react').ForwardRefExoticComponent>; //# sourceMappingURL=portal-manager.d.ts.map