import type { TableFeature } from "../core/table.js"; import type { OnChangeFn, Updater } from "../types.js"; import type { ColumnPinningPosition } from "./pinning.js"; export interface ColumnSizingTableState { columnSizing: ColumnSizingState; columnSizingInfo: ColumnSizingInfoState; } export type ColumnSizingState = Record; export interface ColumnSizingInfoState { columnSizingStart: [string, number][]; deltaOffset: null | number; deltaPercentage: null | number; isResizingColumn: false | string; startOffset: null | number; startSize: null | number; } export type ColumnResizeMode = "onChange" | "onEnd"; export type ColumnResizeDirection = "ltr" | "rtl"; export interface ColumnSizingOptions { /** * Enables or disables right-to-left support for resizing the column. defaults to * 'ltr'. */ columnResizeDirection?: ColumnResizeDirection; /** * Determines when the columnSizing state is updated. `onChange` updates the state * when the user is dragging the resize handle. `onEnd` updates the state when the * user releases the resize handle. */ columnResizeMode?: ColumnResizeMode; /** * Enables or disables column resizing for the column. */ enableColumnResizing?: boolean; /** * If provided, this function will be called with an `updaterFn` when * `state.columnSizing` changes. This overrides the default internal state * management, so you will also need to supply `state.columnSizing` from your own * managed state. */ onColumnSizingChange?: OnChangeFn; /** * If provided, this function will be called with an `updaterFn` when * `state.columnSizingInfo` changes. This overrides the default internal state * management, so you will also need to supply `state.columnSizingInfo` from your * own managed state. */ onColumnSizingInfoChange?: OnChangeFn; } export type ColumnSizingDefaultOptions = Pick; export interface ColumnSizingInstance { /** * If pinning, returns the total size of the center portion of the table by * calculating the sum of the sizes of all unpinned/center leaf-columns. */ getCenterTotalSize: () => number; /** * Returns the total size of the left portion of the table by calculating the sum * of the sizes of all left leaf-columns. */ getLeftTotalSize: () => number; /** * Returns the total size of the right portion of the table by calculating the sum * of the sizes of all right leaf-columns. */ getRightTotalSize: () => number; /** * Returns the total size of the table by calculating the sum of the sizes of all * leaf-columns. */ getTotalSize: () => number; /** * Resets column sizing to its initial state. If `defaultState` is `true`, the * default state for the table will be used instead of the initialValue provided * to the table. */ resetColumnSizing: (defaultState?: boolean) => void; /** * Resets column sizing info to its initial state. If `defaultState` is `true`, * the default state for the table will be used instead of the initialValue * provided to the table. */ resetHeaderSizeInfo: (defaultState?: boolean) => void; /** * Sets the column sizing state using an updater function or a value. This will * trigger the underlying `onColumnSizingChange` function if one is passed to the * table options, otherwise the state will be managed automatically by the table. */ setColumnSizing: (updater: Updater) => void; /** * Sets the column sizing info state using an updater function or a value. This * will trigger the underlying `onColumnSizingInfoChange` function if one is * passed to the table options, otherwise the state will be managed automatically * by the table. */ setColumnSizingInfo: (updater: Updater) => void; } export interface ColumnSizingColumnDef { /** * Enables or disables column resizing for the column. */ enableResizing?: boolean; /** * The maximum allowed size for the column */ maxSize?: number; /** * The minimum allowed size for the column */ minSize?: number; /** * The desired size for the column */ size?: number; } export interface ColumnSizingColumn { /** * Returns `true` if the column can be resized. */ getCanResize: () => boolean; /** * Returns `true` if the column is currently being resized. */ getIsResizing: () => boolean; /** * Returns the current size of the column. */ getSize: () => number; /** * Returns the offset measurement along the row-axis (usually the x-axis for * standard tables) for the header. This is effectively a sum of the offset * measurements of all preceding headers. */ getStart: (position?: ColumnPinningPosition) => number; /** * Resets the column to its initial size. */ resetSize: () => void; } export interface ColumnSizingHeader { /** * Returns an event handler function that can be used to resize the header. It can * be used as an: * - `onMouseDown` handler * - `onTouchStart` handler * * The dragging and release events are automatically handled for you. */ getResizeHandler: () => (event: unknown) => void; /** * Returns the current size of the header. */ getSize: () => number; /** * Returns the offset measurement along the row-axis (usually the x-axis for * standard tables) for the header. This is effectively a sum of the offset * measurements of all preceding headers. */ getStart: (position?: ColumnPinningPosition) => number; } export declare const defaultColumnSizing: { maxSize: number; minSize: number; size: number; }; export declare const ColumnSizing: TableFeature; export declare function passiveEventSupported(): boolean; //# sourceMappingURL=column-sizing.d.ts.map