/** * Spreadsheet-style layout helpers — cell merging + per-cell borders. * * These are *layout-only* augmentations on top of ``. They don't * change the grid's data model, sorting, or filtering — they just decorate * the rendered body cells. Bind the action to the wrapper around your * SvGrid and pass merge / border specs; the helper observes DOM mutations * and re-applies the layout whenever the grid re-renders. * * Limitations (worth knowing up front): * - Merges + borders index into the CURRENTLY-DISPLAYED rows (after * sort / filter), via the `data-svgrid-row` index the grid sets on * every body cell. If your data sorts or filters, recompute the * specs against the new display order. * - Merges use real `colspan` / `rowspan` plus `display:none` on * covered TDs. Column widths come from the inline styles SvGrid * emits on each TD; we don't fight those. * - For long row-merges across a virtualised window, only rows that * are actually rendered get the rowspan applied. Disable * virtualisation on grids that need a continuous merge. */ /** A single edge of a cell border. */ export type BorderSpec = { /** Thickness in pixels. Default 2. */ width?: number; /** CSS border-style. Default 'solid'. */ style?: 'solid' | 'dashed' | 'dotted' | 'double'; /** CSS color. Falls back to currentColor (i.e. text color). */ color?: string; }; /** A merge declaration. The cell at (rowIndex, columnId) is the ORIGIN; * it spans `colspan` columns to the right + `rowspan` rows downward. * Covered cells are hidden so the origin visually fills the region. */ export type MergeSpec = { /** Display-row index — the same value the grid puts on * `data-svgrid-row`. After sorting/filtering, recompute the spec * against the new display order. */ rowIndex: number; columnId: string; /** Default 1. */ rowspan?: number; /** Default 1. */ colspan?: number; }; /** A column with declarative spanning callbacks, as accepted by * `spansToMerges`. Matches the relevant slice of `ColumnDef`. */ export type SpanColumn> = { id: string; field?: string; colSpan?: (params: { data: TData; rowIndex: number; columnId: string; value: unknown; }) => number; rowSpan?: (params: { data: TData; rowIndex: number; columnId: string; value: unknown; }) => number; }; /** * Turn declarative per-column `colSpan` / `rowSpan` callbacks into a * `MergeSpec[]` you can hand to `spreadsheetLayout` - so value-driven, * AG-Grid-style spanning runs on the SAME real colspan/rowspan merge engine * instead of a second code path. Recompute after sort/filter (indexes are * display-row indexes). A common pattern is "merge runs of equal values": * * { field: 'region', rowSpan: ({ data, rowIndex }) => * rows.filter((r, i) => i >= rowIndex && r.region === data.region && * (i === rowIndex || rows[i-1].region === data.region)).length } */ export declare function spansToMerges>(rows: ReadonlyArray, columns: ReadonlyArray>, getValue?: (row: TData, columnId: string) => unknown): MergeSpec[]; /** Borders for one cell. Edges left unset render as the default * cell border (i.e. no override). */ export type CellBorderSpec = { rowIndex: number; columnId: string; top?: BorderSpec; right?: BorderSpec; bottom?: BorderSpec; left?: BorderSpec; }; /** What the Svelte action receives. Pass new values to update; pass * `null` / empty arrays to clear. */ export type SpreadsheetActionOptions = { merges?: ReadonlyArray | null; borders?: ReadonlyArray | null; /** Column id order the grid uses, in left-to-right order. Required * to translate `colspan` into the right set of covered column ids. * Pass `columns.map((c) => c.id)` from the consumer. */ columnOrder: ReadonlyArray; }; /** Svelte action. Attach to the element that hosts your `` so * the action can watch its DOM for re-renders. * * ```svelte *
* *
* ``` * * The action re-applies the layout whenever the grid's body mutates * (new rows, column reorder, virtualization scroll) and whenever the * options change. */ export declare function spreadsheetLayout(node: HTMLElement, opts: SpreadsheetActionOptions): { update(next: SpreadsheetActionOptions): void; destroy(): void; };