/** * Table utility functions and constants for nv-table component * * This module contains pure utility functions for table column resizing logic, * pointer event handling calculations, and related helper functions. */ /** * Constants for table column resizing behavior */ export declare const TABLE_CONSTANTS: Readonly<{ /** Handle width for fine pointers (mouse) in pixels */ readonly HANDLE_W: 12; /** Handle width for coarse pointers (touch) in pixels */ readonly HANDLE_W_TOUCH: 24; /** Minimum column width in pixels */ readonly MIN_W: 40; }>; /** * Determines the appropriate handle width based on the current pointer type * @returns {number} Handle width in pixels (10px for fine pointers, 24px for coarse/touch) */ export declare function getHandleWidthForCurrentPointer(): number; /** * Calculates the pointer's horizontal offset within a table cell * @param {PointerEvent} event - The pointer event * @param {HTMLTableCellElement} cell - The table cell element * @returns {number} The horizontal offset from the left edge of the cell */ export declare function getPointerOffsetInCell(event: PointerEvent, cell: HTMLTableCellElement): number; /** * Determines if the pointer is within the resize handle area of a table cell * @param {number} offsetX - Horizontal offset within the cell * @param {number} cellWidth - Total width of the cell * @param {number} handleWidth - Width of the resize handle area * @returns {boolean} True if the pointer is in the resize handle area */ export declare function isInResizeHandle(offsetX: number, cellWidth: number, handleWidth: number): boolean; /** * Calculates the new column width based on resize delta and constraints * @param {number} startWidth - Original width of the column * @param {number} delta - Change in pixels from the start position * @param {number} minWidth - Minimum allowed width for the column * @returns {number} The calculated new width, constrained by minimum */ export declare function calculateNewWidth(startWidth: number, delta: number, minWidth?: number): number; /** * Validates that a table cell element is suitable for resizing * @param {HTMLElement | null} element - The element to check * @returns {element is HTMLTableCellElement} Type guard for table cell elements */ export declare function isValidTableCell(element: HTMLElement | null): element is HTMLTableCellElement; /** * Finds the closest table cell element from an event target * @param {EventTarget | null} target - The event target * @returns {HTMLTableCellElement | null} The closest table cell or null */ export declare function getClosestTableCell(target: EventTarget | null): HTMLTableCellElement | null; /** * Sets up pointer capture for consistent drag behavior across browsers * @param {HTMLTableCellElement} cell - The table cell element * @param {number} pointerId - The pointer ID from the pointer event * @returns {boolean} True if capture was successfully set */ export declare function setPointerCapture(cell: HTMLTableCellElement, pointerId: number): boolean; /** * Releases pointer capture * @param {HTMLTableCellElement} cell - The table cell element * @param {number} pointerId - The pointer ID from the pointer event * @returns {boolean} True if release was successful */ export declare function releasePointerCapture(cell: HTMLTableCellElement, pointerId: number): boolean; /** * Prevents text selection during drag operations * @param {boolean} prevent - Whether to prevent selection */ export declare function setUserSelectPrevention(prevent: boolean): void; /** * Gets the current width of a table cell element * @param {HTMLTableCellElement} cell - The table cell element * @returns {number} The current width in pixels */ export declare function getCellWidth(cell: HTMLTableCellElement): number; /** * Applies a width to a table cell element * @param {HTMLTableCellElement} cell - The table cell element * @param {number} width - The width to apply in pixels */ export declare function setCellWidth(cell: HTMLTableCellElement, width: number): void; /** * Calculates the delta (change) in horizontal position between two pointer events * @param {number} currentX - Current clientX position * @param {number} startX - Starting clientX position * @returns {number} The horizontal delta */ export declare function calculatePointerDelta(currentX: number, startX: number): number; /** * Interface for resize operation state */ export interface ResizeState { /** The table cell being resized */ resizingCell: HTMLTableCellElement; /** The pointer ID for this resize operation */ pointerId: number; /** Starting X coordinate */ startX: number; /** Starting width of the cell */ startWidth: number; } /** * Creates a new resize state object * @param {HTMLTableCellElement} cell - The cell being resized * @param {PointerEvent} event - The initiating pointer event * @returns {ResizeState} A new resize state object */ export declare function createResizeState(cell: HTMLTableCellElement, event: PointerEvent): ResizeState; /** * Validates that a resize state is active and matches the given pointer event * @param {ResizeState | null} state - The current resize state * @param {PointerEvent} event - The pointer event to validate against * @returns {boolean} True if the state is valid for this event */ export declare function isValidResizeState(state: ResizeState | null, event: PointerEvent): boolean; /** * Updates the width of a cell during a resize operation * @param {ResizeState} state - The current resize state * @param {PointerEvent} event - The current pointer event * @param {number} minWidth - Minimum width constraint */ export declare function updateCellWidthFromResize(state: ResizeState, event: PointerEvent, minWidth?: number): void;