import type { HotInstance } from '../../core/types'; import type { CellProperties } from '../../settings'; /** * Cell meta shape for cells that carry custom borders - types the `borders` option on top of the base * cell properties, so reads through `getCellMeta` are not widened to `any`. */ export interface BordersCellProperties extends CellProperties { borders?: unknown; } /** * Describes style properties for a single border side or corner. */ export interface BorderSettings { width?: number; color?: string; cornerVisible?: boolean | ((...args: unknown[]) => boolean); hide?: boolean; className?: string; [key: string]: unknown; } /** * Internal shape of a stored border object, used by the plugin's bookkeeping. */ export interface BorderObject { id: string; row: number; col: number; top?: BorderSettings; bottom?: BorderSettings; start?: BorderSettings; end?: BorderSettings; border?: Record; range?: { from: { row: number; col: number; }; to: { row: number; col: number; }; }; [key: string]: unknown; } /** * Minimal interface the contextMenuItem functions need from the CustomBorders plugin instance. */ export interface CustomBordersPlugin { hot: HotInstance; prepareBorder(selected: Record[], place: string, remove: boolean | undefined): void; } /** * Describes a single user-provided custom border configuration entry. */ export interface CustomBorderConfig { row?: number; col?: number; top?: BorderSettings; bottom?: BorderSettings; start?: BorderSettings; end?: BorderSettings; left?: BorderSettings; right?: BorderSettings; border?: Record; range?: { from: { row: number; col: number; }; to: { row: number; col: number; }; }; [key: string]: unknown; } /** * Create separated id for borders for each cell. * * @param {number} row Visual row index. * @param {number} col Visual column index. * @returns {string} */ export declare function createId(row: number, col: number): string; /** * Computes the new position of a coordinate index after `amount` rows/columns are inserted * at `insertionIndex`. An index at or after the insertion point moves down/right by `amount`; * an index before it stays put. * * @param {number} index The visual index to shift. * @param {number} insertionIndex The visual index at which the insertion starts. * @param {number} amount The number of inserted rows/columns. * @returns {number} */ export declare function getShiftedIndexAfterInsert(index: number, insertionIndex: number, amount: number): number; /** * Computes the new position of a coordinate index after `amount` rows/columns are removed * starting at `removalIndex`. An index below the removed range moves up/left by `amount`; * an index inside the removed range returns `-1` (the border no longer has a cell); an index * above the removed range stays put. * * @param {number} index The visual index to shift. * @param {number} removalIndex The visual index at which the removal starts. * @param {number} amount The number of removed rows/columns. * @returns {number} */ export declare function getShiftedIndexAfterRemove(index: number, removalIndex: number, amount: number): number; /** * Builds the disjoint, ascending list of visual-index ranges the viewport working set must cover * on one axis: the frozen-start area, the master rendered range (clipped so the ranges stay * disjoint), and the frozen-end area. Frozen rows and columns are rendered by the overlay clones * even when the master rendered range excludes them, so the working set must always include them. * * @param {number} firstIndex First visual index of the master rendered range. * @param {number} lastIndex Last visual index of the master rendered range. * @param {number} fixedStartCount Number of frozen indexes at the start of the axis. * @param {number} fixedEndCount Number of frozen indexes at the end of the axis. * @param {number} totalCount Total number of indexes on the axis. * @returns {Array} Array of `[from, to]` tuples, disjoint and ascending. */ export declare function getViewportUnionRanges(firstIndex: number, lastIndex: number, fixedStartCount: number, fixedEndCount: number, totalCount: number): Array<[number, number]>; /** * Checks whether a visual index lies inside the viewport working window on one axis: the * frozen-start area, the frozen-end area, or the master rendered range. * * @param {number} index The visual index to test. * @param {number} firstIndex First visual index of the master rendered range. * @param {number} lastIndex Last visual index of the master rendered range. * @param {number} fixedStartCount Number of frozen indexes at the start of the axis. * @param {number} fixedEndCount Number of frozen indexes at the end of the axis. * @param {number} totalCount Total number of indexes on the axis. * @returns {boolean} */ export declare function isIndexInViewportUnion(index: number, firstIndex: number, lastIndex: number, fixedStartCount: number, fixedEndCount: number, totalCount: number): boolean; /** * Resolves the style of a single border side declared inside a range configuration. An explicit * per-side style object takes precedence and is used unchanged. An enabled but unstyled side * (an empty object `{}`, an empty string, or `true`) inherits the range-level `border` object's * style (width, color, and line style) so it renders with the configured look instead of the * default 1px black. When no range-level `border` is provided the raw side value is kept, which * preserves the previous behavior. * * @param {object} [rawSide] The side value from the range configuration. * @param {object} [rangeBorder] The range-level `border` object shared by all sides. * @returns {object} */ export declare function resolveRangeBorderSide(rawSide: BorderSettings | undefined, rangeBorder: Record | undefined): BorderSettings | undefined; /** * Create default single border for each position (top/right/bottom/left). * * @returns {object} `{{width: number, color: string}}`. */ export declare function createDefaultCustomBorder(): BorderSettings; /** * Create default object for empty border. * * @returns {object} `{{hide: boolean}}`. */ export declare function createSingleEmptyBorder(): BorderSettings; /** * Create default Handsontable border object. * * @returns {object} `{{width: number, color: string, cornerVisible: boolean}}`. */ export declare function createDefaultHtBorder(): { width: number; color: string; cornerVisible: boolean; }; /** * Normalizes the border object to be compatible with the Border API from the Walkontable. * The function translates the "left"/"right" properties to "start"/"end" prop names. * * @param {object} border The configuration object of the border. * @returns {object} */ export declare function normalizeBorder>(border: T): T; /** * Denormalizes the border object to be backward compatible with the previous version of the CustomBorders * plugin API. The function extends the border configuration object for the backward compatible "left"/"right" * properties. * * @param {object} border The configuration object of the border. * @returns {object} */ export declare function denormalizeBorder>(border: T): T; /** * Prepare empty border for each cell with all custom borders hidden. * * @param {number} row Visual row index. * @param {number} col Visual column index. * @returns {BorderObject} Returns border configuration containing visual indexes. */ export declare function createEmptyBorders(row: number, col: number): BorderObject; /** * @param {object} defaultBorder The default border object. * @param {object} customBorder The border object with custom settings. * @returns {object} */ export declare function extendDefaultBorder(defaultBorder: BorderObject, customBorder: CustomBorderConfig): BorderObject; /** * Check if selection has border. * * @param {Core} hot The Handsontable instance. * @param {string} [direction] If set ('left' or 'top') then only the specified border side will be checked. * @returns {boolean} */ export declare function checkSelectionBorders(hot: HotInstance, direction?: string): boolean; /** * Mark label in contextMenu as selected. * * @param {string} label The label text. * @returns {string} */ export declare function markSelected(label: string): string; /** * Checks if in the borders config there are defined "left" or "right" border properties. * * @param {object[]} borders The custom border plugin's options. * @returns {boolean} */ export declare function hasLeftRightTypeOptions(borders: CustomBorderConfig[]): boolean; /** * Checks if in the borders config there are defined "start" or "end" border properties. * * @param {object[]} borders The custom border plugin's options. * @returns {boolean} */ export declare function hasStartEndTypeOptions(borders: CustomBorderConfig[]): boolean; /** * Translates the physical horizontal direction to logical ones. If not known property name is * passed it will be returned without modification. * * @param {string} propName The physical direction property name ("left" or "right"). * @returns {string} */ export declare function toInlinePropName(propName: string): string;