import { GridMetricCalculator, type GridMetrics, type GridMetricState, type ModelIndex, type ModelSizeMap, type VisibleIndex } from '@deephaven/grid'; import type IrisGridModel from './IrisGridModel'; import { type IrisGridStateOverride, type ColumnName } from './CommonTypes'; import type ColumnHeaderGroup from './ColumnHeaderGroup'; export type IrisGridMetricState = GridMetricState & IrisGridStateOverride; type GridMetricCalculatorOptions = NonNullable[0]>; export type IrisGridMetricCalculatorOptions = GridMetricCalculatorOptions & { /** * Map of user-set column widths keyed by column name. This is the source * of truth for hidden/manually-sized columns across model swaps (e.g. * applying or removing a rollup), where the model's column indices * change but names are stable. Entries for columns absent from the * current model are preserved and re-projected onto the by-index map * whenever the model swaps. */ userColumnWidthsByName?: Map; }; export declare class IrisGridMetricCalculator extends GridMetricCalculator { private userColumnWidthsByName; private cachedModelColumnNames; private cachedHeaderGroupNames; private cachedPaddingMaps; constructor(options?: IrisGridMetricCalculatorOptions); static getModelColumnRoot(model: IrisGridModel, modelColumn: ModelIndex): ColumnHeaderGroup | undefined; /** * Builds a TreeNode from the model header groups and columns for padding calculation * @param name The name of the root node to build the tree for * @param model The IrisGridModel containing columns and header groups * @param getLeafValue Function to get the value for leaf nodes (columns) * @param getGroupValue Function to get the value for group nodes (header groups) * @returns The TreeNode structure */ private static buildNode; /** * Gets the header padding for a specific column based on the widths of its group tree nodes. * We only adjust paddings on the column, because the group widths are automatically sized to fit their children. * @param state The current IrisGridMetricState * @param modelColumn The column index to get the padding for * @param maxColumnWidth Maximum allowed column width, applies only to leaf nodes * @returns The calculated header padding for the column */ private getHeaderPadding; private getCachedCurrentModelColumnNames; private getCachedCurrentHeaderGroupNames; private updateCalculatedColumnWidths; /** * Updates the user column widths based on the current model state * @param model The current IrisGridModel */ private updateUserColumnWidths; /** * Updates the user and calculated column widths if the model columns have changed * @param model The current IrisGridModel */ private updateColumnWidthsIfNecessary; resetCalculatedHeaderGroupWidths(): void; resetCalculatedColumnWidths(): void; getGridY(state: IrisGridMetricState): number; /** * Gets the metrics for the current state. This method has to be called before setColumnSize or resetColumnSize. * @param state The current IrisGridMetricState * @returns The metrics for the current state */ getMetrics(state: IrisGridMetricState): GridMetrics; /** * Sets the width for a specific column by index * @param column The index of the column to set * @param size The new width for the column */ setColumnWidth(column: number, size: number): void; /** * Resets the width for a specific column by index * @param column The index of the column to reset */ resetColumnWidth(column: number): void; /** * Resets the user width for a column by its name. Works regardless of * whether the column is currently present in the model, so it is safe to * call when the model is about to be swapped (e.g. when applying a rollup). * @param name The name of the column to reset */ resetColumnWidthByName(name: ColumnName): void; /** * Resets all user column widths */ resetAllColumnWidths(): void; /** * Gets the user column widths * @returns A map of user column widths */ getUserColumnWidths(): ModelSizeMap; /** * Gets the user column widths keyed by column name. This is the source * of truth for hidden/manually-sized columns across model swaps and * persistence boundaries. * @returns A map of user column widths keyed by column name */ getUserColumnWidthsByName(): ReadonlyMap; getCalculatedColumnWidths(): ModelSizeMap; /** * Calculate the width of the specified column's header * @param modelColumn ModelIndex of the column to get the header width for * @param state The grid metric state * @param maxColumnWidth Maximum allowed column width, applies only to leaf nodes * @returns The calculated width of the column header */ calculateColumnHeaderWidth(modelColumn: ModelIndex, state: IrisGridMetricState, maxColumnWidth: number): number; getColumnHeaderGroupWidth(modelColumn: ModelIndex, depth: number, state: IrisGridMetricState, maxColumnWidth: number): number; /** * Get metrics for positioning the filter bar input field. * @param index The visible index of the column to get the filter box coordinates for * @param state The current IrisGridMetricState * @param metrics The grid metrics * @returns Coordinates for the filter input field, or null if positioning cannot be calculated */ getFilterInputCoordinates(index: VisibleIndex, state: IrisGridMetricState, metrics: GridMetrics): { x: number; y: number; width: number; height: number; } | null; /** * Calculate the new left index to bring the given column into view. * @param column The column that should be scrolled into view * @param state The current IrisGridMetricState * @param metrics The grid metrics * @returns The left column index to scroll to, or null if no scroll is needed */ getScrollLeftForColumn(column: VisibleIndex, state: IrisGridMetricState, metrics: GridMetrics): VisibleIndex | null; /** * Get the coordinates for the advanced filter button positioned in the filter bar. * @param index The column index * @param state The current IrisGridMetricState * @param metrics The grid metrics * @returns Coordinates for the advanced filter button, or null if it should not be shown */ getAdvancedFilterButtonCoordinates(index: VisibleIndex, state: IrisGridMetricState, metrics: GridMetrics): { x: number; y: number; } | null; } export default IrisGridMetricCalculator; //# sourceMappingURL=IrisGridMetricCalculator.d.ts.map