import { DataGridElement } from '@toolbox-web/grid'; import { RefObject } from 'react'; /** * Options for {@link useGridOverlay}. * * @public * @since 1.4.0 */ export interface UseGridOverlayOptions { /** * Whether the overlay is currently open. * * Set to `false` to unregister the panel without unmounting it (e.g. when * the consumer toggles visibility via CSS rather than conditional render). * Defaults to `true`. */ open?: boolean; /** * Optional explicit grid element. When omitted, the hook resolves the * grid by: * * 1. Walking up the DOM from `panelRef.current` via `closest('tbw-grid, [data-tbw-grid]')` * (works for inline overlays). * 2. Falling back to the `GridElementContext` populated by * `` / `` (works for portal-rendered overlays * whose DOM is detached from the grid subtree). */ gridElement?: DataGridElement | null; } /** * Register a custom overlay panel (popover, listbox, calendar, color * picker) as part of the active editor so the grid does not commit and * exit row edit when focus or pointer interaction enters the panel. * * Mirrors the Angular `BaseOverlayEditor` contract for React custom * editors. Wires `registerExternalFocusContainer(panel)` on mount/open * and `unregisterExternalFocusContainer(panel)` on unmount/close. * * Pair with `ColumnEditorContext.grid` (see `DataGridElement`) when * the panel is rendered outside any `` provider. * * @example * ```tsx * function AutocompleteEditor({ value, commit, cancel }: GridEditorContext) { * const [open, setOpen] = useState(false); * const panelRef = useRef(null); * useGridOverlay(panelRef, { open }); * return ( * <> * setOpen(true)} * onKeyDown={(e) => e.key === 'Enter' && commit(e.currentTarget.value)} * /> * {open && * createPortal( *
* {options} *
, * document.body, * )} * * ); * } * ``` * * @param panelRef - Ref to the overlay panel DOM element. The hook is a * no-op while `panelRef.current` is `null`. * @param options - {@link UseGridOverlayOptions}. * * @public * @since 1.4.0 */ export declare function useGridOverlay(panelRef: RefObject, options?: UseGridOverlayOptions): void; //# sourceMappingURL=use-grid-overlay.d.ts.map