import { BasePlugin } from "../-private/base.js"; import { SortDirection, Sort, SortItem } from "./types.js"; import { ColumnApi, PluginPreferences } from "../index.js"; import { Column, Table } from "../../index.js"; interface SortingPreferences extends PluginPreferences { table: { sorts?: Sort[]; }; } declare module "plugins/index" { interface Registry { Sorting?: SortingPreferences; } } interface Signature { Meta: { Column: ColumnMeta; Table: TableMeta; }; Options: { Plugin: Options; Column: ColumnOptions; }; } interface Options { /** * Handler for interpreting sort requests from the headless table. * * Does not actually do the sorting. * * if omitted, the DataSorting plugin will disable itself */ onSort?: (sorts: SortItem[]) => void; /** * Provided sorts that the table should assume are true. * * if omitted, the DataSorting plugin will disable itself */ sorts?: SortItem[]; } interface ColumnOptions { /** * Opt in or out of sorting for a particular column. * Default is true. */ isSortable?: boolean; /** * Use this key instead of the `key` on the column config. * This has no bearing on any behavior in the plugin, *other than*, * swapping out the `property`'s value on the `SortItem`s passed to * the table plugin config's `onSort` callback */ sortProperty?: string; } /** * Manages basic data-sorting behaviors. Ascending -> Descending -> None * * This plugin requires a table plugin configuration, `onSort` for handling *how* sorting happens. * communicating back to the table that sorting has succeeded can be done by setting the `sorts` * property in the table plugin configuration. * * Note that this plugin doesn't actually sort the data, as data management is not the responsibility * of the table, but of the surrounding context providing the data to the table. So sorting can happen * client-side still, just in a component -- much the same way you'd handel sorting via API requests. * * This plugin is for *conveying* what the current sorts are, rather than _doing_ the sorting. */ declare class Sorting extends BasePlugin> { name: string; meta: { column: typeof ColumnMeta; table: typeof TableMeta; }; headerCellModifier: (element: HTMLElement, { column }: ColumnApi) => void; } declare class ColumnMeta { private column; constructor(column: Column); get options(): Partial; get isSortable(): boolean; get tableMeta(): TableMeta; get sortDirection(): SortDirection; get isAscending(): boolean; get isDescending(): boolean; get isUnsorted(): boolean; get sortProperty(): string; } declare class TableMeta { private table; constructor(table: Table); get options(): Partial>; get sorts(): SortItem[]; get isSortable(): boolean; get onSort(): ((sorts: SortItem[]) => void) | undefined; handleSort(column: Column): void; toggleAscending(column: Column): void; toggleDescending(column: Column): void; } export { Signature, Sorting, ColumnMeta, TableMeta };