import { TrackedMap } from 'tracked-built-ins'; import { BasePlugin } from "../-private/base.js"; import { PluginPreferences } from "../index.js"; import { Column, Table } from "../../index.js"; interface ColumnReorderingPreferences extends PluginPreferences { table: { order?: Record; }; } declare module "plugins/index" { interface Registry { ColumnReordering?: ColumnReorderingPreferences; } } interface Signature { Meta: { Column: ColumnMeta; Table: TableMeta; }; } declare class ColumnReordering extends BasePlugin { name: string; static features: string[]; meta: { readonly column: typeof ColumnMeta; readonly table: typeof TableMeta; }; reset(): void; get columns(): Column[]; } declare class ColumnMeta { #private; private column; constructor(column: Column); get position(): number; set position(value: number); get canMoveLeft(): boolean; get canMoveRight(): boolean; get cannotMoveLeft(): boolean; get cannotMoveRight(): boolean; /** * Move the column one spot to the left */ moveLeft: () => void; /** * Move the column one spot to the right */ moveRight: () => void; } declare class TableMeta { private table; constructor(table: Table); /** * @private * * We want to maintain the instance of this ColumnOrder class because * we allow the consumer of the table to swap out columns at any time. * When they do this, we want to maintain the order of the table, best we can. * This is also why the order of the columns is maintained via column key */ columnOrder: ColumnOrder; /** * Get the curret order/position of a column */ /** * Get the curret order/position of a column */ getPosition(column: Column): number; /** * Swap the column with the column at `newPosition` */ /** * Swap the column with the column at `newPosition` */ setPosition(column: Column, newPosition: number): false | undefined; /** * Using a `ColumnOrder` instance, set the order of all columns */ setOrder: (order: ColumnOrder) => void; /** * Revert to default config, delete preferences, * and clear the columnOrder */ /** * Revert to default config, delete preferences, * and clear the columnOrder */ reset(): void; /** * @private */ /** * @private */ save(map: Map): void; /** * @private */ /** * @private */ private read; get columns(): Column[]; /** * @private * This isn't our data to expose, but it is useful to alias */ private get availableColumns(); } /** * @private * Used for keeping track of and updating column order */ declare class ColumnOrder { private args; /** * This map will be empty until we re-order something. */ map: TrackedMap; constructor(args: { columns: () => Column[]; save?: (order: Map) => void; existingOrder?: Map; }); /** * To account for columnVisibilty, we need to: * - get the list of visible columns * - get the column order (which preserves the order of hidden columns) * - skip over non-visible columns when determining the previous "index" * - set the position to whatever that is. */ /** * To account for columnVisibilty, we need to: * - get the list of visible columns * - get the column order (which preserves the order of hidden columns) * - skip over non-visible columns when determining the previous "index" * - set the position to whatever that is. */ moveLeft(key: string): void; setAll: (map: Map) => void; /** * To account for columnVisibilty, we need to: * - get the list of visible columns * - get the column order (which preserves the order of hidden columns) * - skip over non-visible columns when determining the next "index" * - set the position to whatever that is. */ /** * To account for columnVisibilty, we need to: * - get the list of visible columns * - get the column order (which preserves the order of hidden columns) * - skip over non-visible columns when determining the next "index" * - set the position to whatever that is. */ moveRight(key: string): void; /** * Performs a swap of the column's position with the column at position */ /** * Performs a swap of the column's position with the column at position */ swapWith(key: string, position: number): false | undefined; get(key: string): number; /** * The same as this.map, but with all the columns' information */ get orderedMap(): ReadonlyMap; get orderedColumns(): Column[]; } /** * @private * * Utility for helping determine the percieved order of a set of columns * given the original (default) ordering, and then user-configurations */ declare function orderOf(columns: { key: string; }[], currentOrder: Map): Map; export { Signature, ColumnReordering, ColumnMeta, TableMeta, ColumnOrder, orderOf };