import { BasePlugin } from '../base'; import StateManager from './stateManager'; import type { HeaderNodeData } from './stateManager/headersTree'; import type { HeaderVisibility } from './stateManager/utils'; import GhostTable from './utils/ghostTable'; /** * A single configured nested header. Declares the header label and how it spans and behaves. */ export interface NestedHeaderSettings { /** * The header label. */ label?: string; /** * The number of columns the header spans. */ colspan?: number; /** * The number of header rows the header spans. */ rowspan?: number; /** * CSS class name(s) added to the header element. */ headerClassName?: string; /** * For a header inside a collapsible group, sets in which collapse state it (and its columns) stays * visible: `'collapsed'` (only while collapsed), `'expanded'` (only while expanded), or `'always'` * (both states). When omitted, the header defaults to `'expanded'` - hidden when the group collapses. * See the `CollapsibleColumns` plugin. */ visibleWhen?: HeaderVisibility; [key: string]: unknown; } /** * A single cell in the `nestedHeaders` configuration: a plain label or a configured header object. */ export type NestedHeader = string | number | NestedHeaderSettings; export declare const PLUGIN_KEY = "nestedHeaders"; export declare const PLUGIN_PRIORITY = 280; /** * @plugin NestedHeaders * @class NestedHeaders * * @description * The plugin allows to create a nested header structure, using the HTML's colspan and rowspan attributes. * * To make any header wider (covering multiple table columns), it's corresponding configuration array element should be * provided as an object with `label` and `colspan` properties. The `label` property defines the header's label, * while the `colspan` property defines a number of columns that the header should cover. * * To make any header taller (covering multiple header rows), provide a `rowspan` property that defines the number * of header rows that the header should span. Cells covered by a rowspan can use an empty string `''` in the * corresponding positions in the lower header rows, but those placeholders are optional. * * You can also set custom class names to any of the headers by providing the `headerClassName` property. * * __Note__ that the plugin supports a *nested* structure, which means, any header cannot be wider than it's "parent". In * other words, headers cannot overlap each other. * @example * * ::: only-for javascript * ```js * const container = document.getElementById('example'); * const hot = new Handsontable(container, { * data: getData(), * nestedHeaders: [ * ['A', {label: 'B', colspan: 8, headerClassName: 'htRight'}, 'C'], * ['D', {label: 'E', colspan: 4}, {label: 'F', colspan: 4}, 'G'], * ['H', {label: 'I', colspan: 2}, {label: 'J', colspan: 2}, {label: 'K', colspan: 2}, {label: 'L', colspan: 2}, 'M'], * ['N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W'] * ], * ``` * ::: * * ::: only-for react * ```jsx * * ``` * ::: * * ::: only-for angular * ```ts * settings = { * data: getData(), * nestedHeaders: [ * ["A", { label: "B", colspan: 8, headerClassName: "htRight" }, "C"], * ["D", { label: "E", colspan: 4 }, { label: "F", colspan: 4 }, "G"], * [ * "H", * { label: "I", colspan: 2 }, * { label: "J", colspan: 2 }, * { label: "K", colspan: 2 }, * { label: "L", colspan: 2 }, * "M", * ], * ["N", "O", "P", "Q", "R", "S", "T", "U", "V", "W"], * ], * }; * ``` * * ```html * * ``` * ::: */ export declare class NestedHeaders extends BasePlugin { #private; /** * Returns the plugin key used to identify this plugin in Handsontable settings. */ static get PLUGIN_KEY(): string; /** * Returns the priority order used to determine the order in which plugins are initialized. */ static get PLUGIN_PRIORITY(): number; /** * Custom helper for getting widths of the nested headers. */ ghostTable: GhostTable; /** * The flag which determines that the nested header settings contains overlapping headers * configuration. */ detectedOverlappedHeaders: boolean; /** * Returns whether the plugin is enabled based on the presence of the `nestedHeaders` settings key. */ isEnabled(): boolean; /** * Enables the plugin by registering all required hooks and initializing the header state. */ enablePlugin(): void; /** * Updates the plugin state when Handsontable settings change, rebuilding the header tree and refreshing column widths. */ updatePlugin(): void; /** * Disables the plugin by removing all registered hooks, clearing header state, and resetting visual indicators. */ disablePlugin(): void; /** * Returns the internal state manager that tracks the nested header spans and their layout configuration. */ getStateManager(): StateManager; /** * Returns the number of nested header rows currently configured in the plugin. */ getLayersCount(): number; /** * Returns the header settings node for the specified header level and column index. */ getHeaderSettings(headerLevel: number, columnIndex: number): HeaderNodeData | null; /** * Removes all colspan and rowspan attributes from the rendered header cells in all overlays. */ clearColspans(): void; /** * Creates and returns a header renderer function for the specified header layer level. */ headerRendererFactory(headerLevel: number): (renderedColumnIndex: number, TH: HTMLTableCellElement) => void; /** * Returns the display value for a nested header cell at the given visual column index and header level. */ getColumnHeaderValue(visualColumnIndex: number, headerLevel: number): string | string[]; /** * Destroys the plugin instance. */ destroy(): void; /** * Returns the header tree node data for the given coordinates, or undefined if the coordinates do not point to a header cell. */ _getHeaderTreeNodeDataByCoords(coords: { row: number; col: number; }): HeaderNodeData | null | undefined; }