import { BooleanInput } from '@angular/cdk/coercion'; import { AfterViewInit, ChangeDetectorRef, EventEmitter, InjectionToken } from '@angular/core'; import { MatTable } from '@angular/material/table'; import { CanDestroyNotify } from '@mtna/lib-ui'; import { Subscription } from 'rxjs'; import * as i0 from "@angular/core"; export interface MtnaResizableTableDefaultOptions { /** Character width based on the default font-size set in mat-table css. Defaults to 8. */ charSize: number; /** Table cell padding based on the padding set in base-table mixin. Defaults to 24. */ cellPadding: number; maxAutoColWidth: number; /** Minimum column width. Defaults to 50. */ minColWidth: number; } export declare const MTNA_RESIZABLE_TABLE_DEFAULT_OPTIONS: InjectionToken; declare const MtnaResizableTable_base: import("@mtna/lib-ui").CanDestroyNotifyCtor & { new (): {}; }; export declare abstract class MtnaResizableTable extends MtnaResizableTable_base implements AfterViewInit, CanDestroyNotify { protected cdr: ChangeDetectorRef; static ngAcceptInputType_resizableColumns: BooleanInput; table: MatTable; /** Map of user-customized column widths (in px) */ set columnWidths(widths: { [id: string]: number; }); /** Whether to enable column resize, defaults to false. */ get resizableColumns(): boolean; set resizableColumns(enable: boolean); private _resizableColumns; /** Emitted after a column is finished being resized. */ resizeColumn: EventEmitter<{ [id: string]: number; }>; /** Whether the columns have been set. Helps to determine when to initialize widths. */ abstract get areColumnsSet(): boolean; /** The table columns to render */ displayedColumns: Array; /** Width of column before it is resized */ _columnStartWidth: number | undefined; /** Map of column IDs to column width */ _columnWidth: { [id: string]: number; }; /** ID of the column being resized */ _currentResizeId: string | undefined; /** Horizontal coordinate where the mouse was clicked when starting to drag */ _dragEventStartX: number | undefined; /** Subscription for the mouse move event */ _mousemoveSub: Subscription | undefined; /** Subscription for the mouse up event */ _mouseupSub: Subscription | undefined; /** Whether a column is being resized */ _resizingColumn: boolean; /** Default options for the resizable table. Can be set via injection token. */ protected defaults: MtnaResizableTableDefaultOptions; constructor(cdr: ChangeDetectorRef, defaults?: MtnaResizableTableDefaultOptions); /** * Returns the cell width with the largest content in a column. * @param id ID of the table column */ abstract getLargestContentWidth(id: string): number; ngAfterViewInit(): void; /** * Handle a 'dblclick' event when a column is being auto resized via the drag handle * @param event 'dblclick `MouseEvent` * @param id ID of the column being resized */ _onAutoResize(event: MouseEvent, id: string | null | undefined): void; /** * Handle the `mousedown` event when a column is being resized via the drag handle * @param event mousedown `MouseEvent` * @param id ID of the column being resized */ _onResizeColumn(event: MouseEvent, id: string | null | undefined): void; protected calculateCellWidth(contentLength: number): number; /** * Determine the initial column width for any column. * You may want to override this and add extra logic if you want to change the logic. * i.e. if you want ghost columns or numeric columns to have a smaller width * * @param id The ID of the column */ protected getColumnWidth(id: string | null | undefined): number; /** * Initialize columns widths when resize is enabled. * The displaytedColumns need to be set prior this initialization. */ protected initializeColumnWidths(): void; /** Updates the underlying CDK table's sticky column styles */ protected updateStickyColumnStyles(): void; /** * Update a column's width * * @param id ID of the column to update * @param width new width to set */ private _updateColumnWidth; /** * Listen for `mousemove` events to resize the column and listen for the `mouseup` event to stop. * * @param id ID of the column being resized */ private _watchMouseDragMovement; static ɵfac: i0.ɵɵFactoryDeclaration, [null, { optional: true; }]>; static ɵdir: i0.ɵɵDirectiveDeclaration, never, never, { "columnWidths": "columnWidths"; "resizableColumns": "resizableColumns"; }, { "resizeColumn": "resizeColumn"; }, never>; } export {};