import type { ScrollToOptions } from '@tanstack/react-virtual'; import { type FocusEvent as ReactFocusEvent, type KeyboardEvent as ReactKeyboardEvent, type MouseEvent as ReactMouseEvent } from 'react'; import type { Row, TableFeature, TableOptions, Updater } from '../../hooks/useTable/types.js'; import type { DataTableV2RowData } from '../../public.api.js'; /** * Event that caused a row to become active (e.g. mouse click). * @public */ export type DataTableV2RowActivationEvent = ReactMouseEvent | ReactKeyboardEvent | ReactFocusEvent; /** * @public */ export interface DataTableV2RowInteractivityBaseProps { /** * Enables row interactivity. * * @defaultValue false */ interactiveRows?: boolean | { /** * The `autoActivate` setting controls whether a focused row immediately activates it, * making stepping through interactive rows with a keyboard more accessible. * @defaultValue true */ autoActivate: boolean; }; /** * Callback triggered when active row is changed. * @param activeRow - the active row's ID. * @param event - the event that caused a row to become active. */ onActiveRowChange?: (activeRow: string | null, event?: DataTableV2RowActivationEvent) => void; } /** * @public */ export interface DataTableV2RowInteractivityControlledProps extends DataTableV2RowInteractivityBaseProps { /** * Lets you control the active row. **/ activeRow?: string | null; defaultActiveRow?: never; } /** * @public */ export interface DataTableV2RowInteractivityUncontrolledProps extends DataTableV2RowInteractivityBaseProps { /** * Lets you set the initially active row. **/ defaultActiveRow?: string | null; activeRow?: never; } /** * Options for DataTableV2 row interactivity * @public */ export type DataTableV2RowInteractivityProps = DataTableV2RowInteractivityControlledProps | DataTableV2RowInteractivityUncontrolledProps; /** * Extension interface for the table options * @internal */ export interface DataTableV2RowInteractivityOptions { enableRowInteractivity?: boolean; onActiveRowChange?: (updater: Updater, event?: DataTableV2RowActivationEvent) => void; enableAutoActivation?: boolean; } /** * Extension interface for the table state * @internal */ export interface DataTableV2RowInteractivityState { activeRow?: string | null; } /** * @internal */ export interface DataTableV2RowInteractivityInstance { /** * Updates the active row state of the table via an update function or value. */ setActiveRow: (updater: Updater, event?: DataTableV2RowActivationEvent) => void; /** * Updates the currently hovered row. */ setHoveredRow: (rowId: string | null) => void; /** * Gets the currently hovered row. */ getHoveredRow: () => string | null; /** * Gets the interactive row event handlers on the table level. */ getInteractiveRowMouseOverHandler: () => (event: ReactMouseEvent) => void; /** * Gets the interactive row event handlers on the table level. */ getInteractiveRowMouseLeaveHandler: () => (event: ReactMouseEvent) => void; /** * Gets the interactive row event handlers on the table level. */ getInteractiveRowClickHandler: () => (event: ReactMouseEvent) => void; } /** * Extension interface to extend the types of the `Row` from the tanstack table. * @internal */ export interface DataTableV2RowInteractivityRow { /** * Returns a boolean value if the row can be activated. */ getCanActivateRow: () => boolean; /** * Returns a boolean value if the row is currently activated. */ getIsActivated: () => boolean; /** * Activates the row, if it is not activated. * Deactivates the row, if it is currently activated. */ toggleActivated: (event?: DataTableV2RowActivationEvent) => void; } /** * Provides all necessary props for an interactive row element. * * @param row - the table row element * @param scrollToIndex - rowVirtualizer function for scrolling to the row with the specified index * @returns className and props for the row element */ export declare function useRowInteractivityProps(row: Row, scrollToIndex: (index: number, options?: ScrollToOptions) => void): { rowInteractivityClassName: string; rowInteractivityProps: Record | undefined; }; /** * Defines the user action table feature * @internal */ export declare const DataTableV2RowInteractivity: TableFeature; /** * Configuration hook for the rowInteractivity in the DataTableV2 * @internal */ export declare function useRowInteractivity(props: DataTableV2RowInteractivityProps, options: TableOptions): void;