import type { ColumnDef, Row, TableFeature, TableOptions } from '../../hooks/useTable/types.js'; import type { DataTableV2RowData } from '../../public.api.js'; /** * @public */ export interface DataTableV2RowSelectionBaseProps { /** * Enables row selection. Either accepts a boolean to enable the * row selection on the entire table or a config object. * The config object accepts a function that will get the row data as * the parameter and should return true or false if the row should be * selectable or not. In the config object, the 'select all' behavior * can also be configured and a selection 'limit' can also be set. * * Note: For the case where this prop is a config object, it needs * to be memoized, to avoid updates if it is identical. Same as for all * for other props with type object. * * @defaultValue false */ selectableRows?: boolean | { /** * Allows to disable the selection of certain rows. */ disableRowSelection?: (row: TData) => boolean; /** * Allows to configure if the select all will only select * the current page or the entire. * @defaultValue 'page' */ selectAllBehavior?: 'page' | 'all'; /** * Allows to set a number limit on how many items are allowed * to be selected. Limit number needs to be a positive integer. */ limit?: number; }; /** * Callback triggered when selection is changed. */ onRowSelectionChange?: (selectedRows: Record) => void; } /** * @public */ export interface DataTableV2RowSelectionControlledProps extends DataTableV2RowSelectionBaseProps { /** * Controlled property to define the selected rows. **/ selectedRows?: Record; /** * Uncontrolled property to define the selected rows. **/ defaultSelectedRows?: never; } /** * @public */ export interface DataTableV2RowSelectionUncontrolledProps extends DataTableV2RowSelectionBaseProps { /** * Controlled property to define the selected rows. **/ defaultSelectedRows?: Record; /** * Uncontrolled property to define the selected rows. **/ selectedRows?: never; } /** * Options for DataTableV2 row selection * @public */ export type DataTableV2RowSelectionProps = DataTableV2RowSelectionControlledProps | DataTableV2RowSelectionUncontrolledProps; /** * Extension interface for the table options * @internal */ export interface DataTableV2RowSelectionOptions { /** * Defines the select all mode for the row selection in the header. * @defaultValue 'page' */ rowSelectionSelectAllMode?: 'page' | 'all'; /** * Defines a limit of the maximum amount of elements that should be selectable. */ rowSelectionLimit?: number; /** * - Enables/disables row selection for all rows in the table OR * - A function that given a row, returns whether to enable/disable row selection for that row */ enableRowSelection?: boolean | ((row: Row) => boolean); } /** * Extension interface for the table instance * @internal */ export interface DataTableV2RowSelectionInstance { /** * Returns a count of currently selected elements. */ getSelectionCount: () => number; /** * Returns a handler that can be used to toggle all rows on the current page respecting the configured limit. */ getToggleAllLimitedPageRowsSelectedHandler: () => (event: unknown) => void; /** * Returns a handler that can be used to toggle all rows in the table respecting the configured limit. */ getToggleAllLimitedRowsSelectedHandler: () => (event: unknown) => void; /** * Selects/deselects all rows on the current page respecting the configured limit. */ toggleAllLimitedPageRowsSelected: (value?: boolean) => void; /** * Selects/deselects all rows in the table respecting the configured limit. */ toggleAllLimitedRowsSelected: (value?: boolean) => void; /** * Returns whether row selection limit is reached. */ getIsRowSelectionLimitReached: (rowSelectionState?: Record) => boolean; /** * Returns true, if row selection is disabled for all rows on the current page, false otherwise. */ getIsAllPageRowsSelectionDisabled: () => boolean; /** * Returns true, if row selection is disabled for all rows in the table, false otherwise. */ getIsAllRowsSelectionDisabled: () => boolean; } /** * Extension interface to extend the types of the `Row` from the tanstack table. * @internal */ export interface DataTableV2RowSelectionRow { /** * Selects/deselects one or multiple rows. When the shift key is pressed while selecting, all rows between this and the previous selection are selected/deselected. */ batchSelect: (value?: boolean, shiftKey?: boolean) => void; /** * Selects/deselects the row. */ toggleSelected: (value?: boolean) => void; /** * Returns whether row selection should be disabled. */ getShouldDisableRowSelection: () => boolean; } /** * Helper function to identify the ROW_SELECTION_COLUMN * @internal */ export declare function isRowSelectionColumnDef(column: ColumnDef): boolean; /** * Column definition for the selection column * @internal */ export declare const ROW_SELECTION_COLUMN: ColumnDef; /** * @internal */ export declare const DataTableV2RowSelection: TableFeature; /** * Configuration hook for the DataTableV2 UserActions feature * @internal */ export declare function useRowSelection(props: DataTableV2RowSelectionProps, options: TableOptions): void;