drab
Version:
Interactivity for You
25 lines (24 loc) • 1.04 kB
TypeScript
import { Base, type BaseAttributes } from "../base/index.js";
export type TableSortAttributes = BaseAttributes;
export type TableSortTriggerAttributes = {
"data-type": "string" | "boolean" | "number";
"data-value": string;
};
/**
* Wrap a `HTMLTableElement` in the `TableSort` element to have sortable column
* headers. Set each `th` that you want to sort to the `trigger`. Set the `tbody`
* element to the `content`.
*
* The values of each cell default to the cell's `textContent`. If you would like to
* provide an alternate value than what appears in the cell to sort by instead,
* you can set a different value using the `data-value` attribute on the cell.
*
* The cells will be sorted as `string` by default. If you want to provide a different
* datatype `number` or `boolean`, set `data-type="number"` on the corresponding
* `th`/`trigger` element. The data will be converted to the specified type before sorting.
*/
export declare class TableSort extends Base {
#private;
constructor();
mount(): void;
}