import { type DOMAttributes } from "react"; type ColumnWidth = number | string; type ResizeProps = { ref: HTMLTableCellElement | null; /** * Controlled width of the column. * * Should only be used to fully control column width state. Otherwise, use `defaultWidth` and let the component handle resizing. */ width?: ColumnWidth; /** * Initial width of the column. Only used when `width` is not set. */ defaultWidth?: ColumnWidth; /** * Minimum width of the column. * * Should be used in conjunction with `width` or `defaultWidth` to set limits when resizing. */ minWidth?: ColumnWidth; /** * Maximum width of the column. * * Should be used in conjunction with `width` or `defaultWidth` to set limits when resizing. */ maxWidth?: ColumnWidth; /** * Called when the column width changes. */ onWidthChange?: (width: ColumnWidth) => void; /** * Forwarded styles */ style?: React.CSSProperties; /** * Forwarded colSpan */ colSpan?: number; }; type TableColumnResizeArgs = ResizeProps & {}; type TableColumnResizeResult = { style?: React.CSSProperties; resizeHandlerProps: { onMouseDown: DOMAttributes["onMouseDown"]; onTouchStart: DOMAttributes["onTouchStart"]; onKeyDown: DOMAttributes["onKeyDown"]; onBlur: DOMAttributes["onBlur"]; onDoubleClick: DOMAttributes["onDoubleClick"]; }; isResizingWithKeyboard: boolean; enabled: true; } | { style?: React.CSSProperties; enabled: false; }; /** * TODO: * - Do we allow % widths? * - Auto-width mode is hard now since that might cause layout-shifts on mount. But would be preferable to * be able to set "1fr" or similar and have it fill remaining space. */ declare function useTableColumnResize(args: TableColumnResizeArgs): TableColumnResizeResult; export { useTableColumnResize }; export type { ResizeProps };