import { BasePlugin } from "../-private/base.js"; import { Row, Table } from "../../index.js"; import { PluginSignature, RowApi } from "../../-private/interfaces/index.js"; interface Signature extends PluginSignature { Meta: { Table: TableMeta; Row: RowMeta; }; Options: { Plugin: { /** * A set of selected things using the same type of Identifier * returned from `key` */ selection: Set | Array; } & ({ /** * For a given row's data, how should the key be determined? * this could be a remote id from a database, or some other attribute * * This could be useful for indicating in UI if a particular item is selected. * * If not provided, the row's data will be used as the key */ key: (data: DataType) => Key; /** * When a row is clicked, this will be invoked, * allowing you to update your selection object */ onSelect: (item: Key, row: Row) => void; /** * When a row is clicked (and the row is selected), this will be invoked, * allowing you to update your selection object */ onDeselect: (item: Key, row: Row) => void; } | { /** * When a row is clicked (and the row is not selected), this will be invoked, * allowing you to update your selection object */ onSelect: (item: DataType | any, row: Row) => void; /** * When a row is clicked (and the row is selected), this will be invoked, * allowing you to update your selection object */ onDeselect: (item: DataType | any, row: Row) => void; }); }; } /** * This plugin provides a means of managing selection of a single row in a table. * * The state of what is actually selected is managed by you, but this plugin * will wire up the click listeners as well as let you know which *data* is clicked. */ declare class RowSelection extends BasePlugin> { #private; name: string; meta: { row: typeof RowMeta; table: typeof TableMeta; }; constructor(table: Table); rowModifier: (element: HTMLElement, { row }: RowApi>) => () => void; } declare class TableMeta { #private; constructor(table: Table); get selection(): Set; } declare class RowMeta { #private; constructor(row: Row); get isSelected(): boolean; toggle: () => void; select: () => void; deselect: () => void; } export { Signature, RowSelection };