/** * In-place cell updates for the viewport Virtual DOM. * * The patcher never creates or replaces a `.pg-cell` element. It writes into * the element the initial render produced, which is what preserves everything * the browser and the grid have attached to it: DOM focus, the active cell * editor, range-selection and active-cell classes, hover state, ARIA * attributes, and any listeners a custom renderer registered on its own * subtree. * * @packageDocumentation */ import type { ColumnDef } from '../../types/column.types'; import type { RowNode } from '../../types/row.types'; import type { CellRenderer } from '../cell-renderer'; import type { IconRenderer } from '../../icons/icon-renderer'; import { CellPatchKind } from './vdom.types'; import type { VirtualCell, VDomRenderContext } from './vdom.types'; /** * Applies value changes to live cell elements. * * Stateless apart from the collaborators it is constructed with, so a single * instance serves the whole grid. */ export declare class CellPatcher { private readonly cellRenderer; private readonly iconRenderer; /** * @param cellRenderer - Shared renderer; reused so a patched cell goes * through the exact same content code path as a freshly * built one. * @param iconRenderer - Icon renderer required by the render context. */ constructor(cellRenderer: CellRenderer, iconRenderer: IconRenderer); /** * Writes a cell's new value into its existing element. * * Chooses the cheapest correct strategy: * 1. **Deferred** — the cell is being edited; the DOM is left alone. * 2. **Text** — a plain-text column: one `textContent` write, no allocation * and no element creation. * 3. **Content** — a custom renderer or a rich built-in type: the cell's * inner content is rebuilt in place, leaving the cell element (and its * state) intact. * * The virtual cell is updated to match whatever was written, so the next diff * compares against reality. * * @param vcell - Virtual cell to update; its `value` is refreshed in place. * @param row - Row node supplying the new data. * @param colDef - Column definition for the cell. * @param ctx - Formatting/lookup context matching the initial render. * @param value - Logical value already read by the diff (not re-read here). * @returns Which strategy was applied. */ patch(vcell: VirtualCell, row: RowNode, colDef: ColumnDef, ctx: VDomRenderContext, value: unknown): CellPatchKind; /** * Resolves the dynamic class a cell would carry for a given value. * * Used when adopting freshly rendered cells into the virtual tree so the * recorded class matches what `CellRenderer` applied at build time. * * @param value - Logical value. * @param rawValue - Underlying field value. * @param row - Owning row node. * @param colDef - Column definition. * @param colIndex - Global column index of the cell. * @param ctx - Formatting/lookup context. */ resolveDynamicClass(value: unknown, rawValue: unknown, row: RowNode, colDef: ColumnDef, colIndex: number, ctx: VDomRenderContext): string; /** `true` when the column renders as plain text and can take the fast path. */ isTextOnlyColumn(colDef: ColumnDef): boolean; /** * Re-evaluates `ColumnDef.cellCssClass` and swaps the applied class only when * it actually changed. * * A value-dependent class (e.g. red for a falling price) is part of the * cell's appearance, so it must track the value — but the class list is * shared with selection, hover and alignment classes, so only the previously * applied dynamic class is removed rather than resetting `className`. */ private syncDynamicClass; /** * Produces the display string for a text-only column, matching * `CellRenderer.renderDefaultCell`'s default branch exactly — a column-level * `valueFormatter` wins, otherwise the built-in type formatting applies. */ private formatText; } //# sourceMappingURL=cell-patcher.d.ts.map