import { type Updater } from '@tanstack/react-table'; import { type VirtualItem } from '@tanstack/react-virtual'; import { type ReactNode } from 'react'; import type { StylingProps } from '@dynatrace/strato-components/core'; import type { Row, Table, TableOptions, TableFeature, ColumnDef, RowModel } from '../../hooks/useTable/types.js'; import type { DataTableV2RowData } from '../../public.api.js'; /** * Props for row order. * @public */ export type DataTableV2RowOrderProps = DataTableV2RowOrderControlledProps | DataTableV2RowOrderUncontrolledProps; /** * Options for DataTableV2 row ordering. * @public */ export interface DataTableV2RowOrderBaseProps { /** * Enables row ordering. * @defaultValue false */ rowOrdering?: boolean | { /** * When enabled, a drag handle is be rendered in the first column for every row. */ enableDragAndDrop?: boolean; /** * Allows to disable the dragging of certain rows. */ disableRowDragAndDrop?: (row: TData) => boolean; /** * Locks rows with disabled drag and drop in place if they are sorted to the start or end of the table. */ lockDisabledRows?: boolean | 'start' | 'end'; }; /** * Callback triggered when row order is changed. * @param rowOrder - ordered set of row ids. */ onRowOrderChange?: (rowOrder: string[]) => void; } /** * Controlled props for row order. * @public */ export interface DataTableV2RowOrderControlledProps extends DataTableV2RowOrderBaseProps { /** * Ordered set of row ids. */ rowOrder?: string[]; defaultRowOrder?: never; } /** * Uncontrolled props for row order. * @public */ export interface DataTableV2RowOrderUncontrolledProps extends DataTableV2RowOrderBaseProps { /** * Ordered set of row ids. */ defaultRowOrder?: string[]; rowOrder?: never; } /** * Extension interface to extend the types from the tanstack table instance. * @internal */ export interface DataTableV2RowOrderInstance { /** * Internal storage for the row model with the changed order. * @internal */ _getRowOrderRowModel?: () => RowModel; /** * Allows access to the row order model if available. */ getRowOrderRowModel: () => RowModel; /** * Allows access to the row model which comes before the row order model. */ getPreRowOrderRowModel: () => RowModel; /** * Sets or updates the `state.rowOrder` state. */ setRowOrder: (updater: Updater) => void; /** * Sets the currently dragged row's id. */ setDraggingRowId: (rowId: string | undefined) => void; } /** * Extension interface for the table options. * @internal */ export interface DataTableV2RowOrderOptions { /** * Enables or disables row ordering. */ enableRowOrdering?: boolean; /** * Callback function fired when row order has changed. * @param rowOrder - new order of rows. Contains IDs of the rows. */ onRowOrderChange?: (rowOrder: string[]) => void; /** * RowModel option for the row order model. */ getRowOrderRowModel?: (table: Table) => () => RowModel; /** * - Enables drag and drop row ordering for all rows in the table OR * - A function that given a row, returns whether to enable/disable the drag and drop handle for that row */ enableRowOrderDragAndDrop?: boolean | ((row: Row) => boolean); /** * Locks rows with disabled drag and drop in place if they are sorted to the start or end of the table. */ lockDisabledRows?: boolean | 'start' | 'end'; } /** * Extension interface to extend the types of the `Row` from the tanstack table. * @internal */ export interface DataTableV2RowOrderRow { /** * Returns whether or not the row is draggable. */ getCanDrag: () => boolean; /** * Flag determining if the row should be locked in place if drag and drop is disabled * and the row is sorted to the start or end of the table. */ getDisabledRowDragAndDropLock: boolean | 'start' | 'end'; } /** @internal */ export interface DataTableV2RowOrderState { /** Order of rows. */ rowOrder: string[]; draggingRowId: string | undefined; } /** * @internal */ export interface DataTableV2RowOrderingCellProps extends StylingProps { row: Row; rowIndex: number; } /** * Configuration hook for the row order in the DataTableV2. * @internal */ export declare function useRowOrder(props: DataTableV2RowOrderProps, options: TableOptions): void; /** * Column definition for the row drag column. * @internal */ export declare const ROW_DRAG_COLUMN: ColumnDef; /** * Helper function to identify the ROW_DRAG_COLUMN. * @internal */ export declare function isRowDragColumnDef(column: ColumnDef): boolean; /** * Defines the row order table feature. */ export declare const DataTableV2RowOrder: TableFeature; /** * @internal */ export declare function RowOrderingDragAndDropContext({ children, rows, virtualColumns, rowSeparation, }: Readonly<{ children: ReactNode; rows: Row[]; virtualColumns: VirtualItem[]; rowSeparation: 'none' | 'horizontalDividers' | 'zebraStripes'; }>): import("react/jsx-runtime.js").JSX.Element | undefined;