import { BasePlugin } from "../-private/base.js"; import { ColumnApi, PluginPreferences } from "../index.js"; import { Column, Table } from "../../index.js"; interface ColumnResizePreferences extends PluginPreferences { columns: { [columnKey: string]: { width?: number; }; }; } declare module "plugins/index" { interface Registry { ColumnResize?: ColumnResizePreferences; } } interface ColumnOptions { /** * Force a starting width * This may not be less than the minWidth */ width?: number; /** * Default: 128px */ minWidth?: number; /** * Flip if the column is resizable or not. * The default is whatever the table's plugin option is set to * (and then yet again true, if not set at all) */ isResizable?: boolean; } interface TableOptions { /** * Toggle whether the table is able to be resized at all * * default :true */ enabled?: boolean; /** * By default, each column's "handle" position is on the * left-hand side of the column. * * If, for style-reasons, you want to move it to the right, * this option should reflect that so that the calculations can be * updated to match the expected behavior of which column(s) grow/shrink * * Valid values are 'left' or 'right' */ handlePosition?: string; } interface Signature { Meta: { Column: ColumnMeta; Table: TableMeta; }; Options: { Plugin: TableOptions; Column: ColumnOptions; }; } /** * One instance of a plugin exists per table * but a plugin can have a "Meta" for each column */ declare class ColumnResizing extends BasePlugin { name: string; static features: string[]; meta: { column: typeof ColumnMeta; table: typeof TableMeta; }; headerCellModifier: (element: HTMLElement, { column }: ColumnApi) => void; /** * This is what ends up calling resize when the browser changes * (assuming that the containing element's styles stretch to fill the space) * * Later, when container queries are more broadly supported, we'll want to watch * the container instead of the window to prevent unneeded updates (as a window can change * size without the container changing size) */ containerModifier: typeof resizeObserver; reset(): void; } /** * @private * * Contains resizable information for a particular column */ declare class ColumnMeta { private column; constructor(column: Column); _width?: number; isResizing: boolean; get tableMeta(): TableMeta; get options(): { /** * Force a starting width * This may not be less than the minWidth */ width?: number | undefined; minWidth: number; /** * Flip if the column is resizable or not. * The default is whatever the table's plugin option is set to * (and then yet again true, if not set at all) */ isResizable?: boolean | undefined; }; get key(): string; get minWidth(): number; get initialWidth(): number | undefined; get canShrink(): boolean | 0; get roomToShrink(): number; get isResizable(): boolean; get hasResizeHandle(): boolean; get width(): number; set width(value: number); get style(): Partial>; resize(delta: number): void; save(): void; } /** * @private * * Contains resizable and width information regarding the table as a whole */ declare class TableMeta { #private; private table; constructor(table: Table); scrollContainerHeight?: number; scrollContainerWidth?: number; get options(): Partial; get isResizable(): boolean; get defaultColumnWidth(): number | undefined; get visibleColumnMetas(): ColumnMeta[]; get totalInitialColumnWidths(): number; get columnsWithoutInitialWidth(): ColumnMeta[]; get totalVisibleColumnsWidth(): number; saveColWidths(visibleColumnMetas: ColumnMeta[]): void; reset(): void; onTableResize(entry: ResizeObserverEntry): void; resizeColumn(column: Column, delta: number): void; } /** * @private * included in the same file as the plugin due to circular dependency * * This goes on the containing element * * @example * ```hbs *
* * ``` */ declare function resizeObserver(element: HTMLElement, table: Table): () => void; export { ColumnOptions, TableOptions, ColumnResizing, ColumnMeta, TableMeta };