import type { Column, TableFeature, TableOptions } from '../../hooks/useTable/types.js'; import type { DataTableV2ColumnDef, DataTableV2RowData } from '../../public.api.js'; /** * @public */ export interface DataTableV2ColumnOrderBaseProps { /** * Enables column ordering functionality in the table. */ columnOrdering?: boolean; /** * Callback that is called when the column order of any column is changed. * It provides the changed column order along with the underlying trigger that indicates * if the change was triggered by a user interaction or internally. */ onColumnOrderChange?: (columnOrder: string[], trigger: 'user' | 'internal') => void; } /** * @public */ export interface DataTableV2ColumnOrderControlledProps extends DataTableV2ColumnOrderBaseProps { /** * Lets you control the column order of the individual columns. */ columnOrder?: string[]; /** * Lets you set the initial column order of the individual columns. */ defaultColumnOrder?: never; } /** * @public */ export interface DataTableV2ColumnOrderUncontrolledProps extends DataTableV2ColumnOrderBaseProps { /** * Lets you control the column order of the individual columns. */ columnOrder?: never; /** * Lets you set the initial column order of the individual columns. */ defaultColumnOrder?: string[]; } /** * Interface defining the props on the DataTableV2 that control the column order feature. * @public */ export type DataTableV2ColumnOrderProps = DataTableV2ColumnOrderControlledProps | DataTableV2ColumnOrderUncontrolledProps; /** * Extension interface to extend the tanstack table column order state. * @internal */ export interface DataTableV2ColumnOrderOptions { /** * The initial column order. */ originalColumnOrder?: string[]; /** * Enables column ordering. */ enableColumnOrdering?: boolean; } /** @internal */ export interface DataTableV2ColumnOrderState { /** * The id of the currently dragged header. */ draggedHeaderColumn?: Column; } /** * @internal */ export interface DataTableV2ColumnOrderInstance { _getOrderColumnsFn: () => (columns: Column[]) => Column[]; /** * Returns an array of all leaf-node columns without the builtin prefix/suffix columns. */ getLeafColumnsWithoutBuiltin: () => Column[]; /** * Sets or updates the `state.draggedHeaderId` state. */ setDraggedHeaderColumn: (column?: Column) => void; } /** * Extension interface to extend the tanstack table header instance. * @internal */ export interface DataTableV2ColumnOrderHeader { /** * Defines the drag and drop interaction mode for the current header. * - 'none': Drag and drop is disabled. * - 'enabled': Drag and drop is enabled along with other interactions. * - 'only': Drag and drop is the only interaction (no menu/sorting). */ getColumnDragAndDropMode: () => 'none' | 'enabled' | 'only'; /** * Whether drag and drop is disabled on the header (if a child column is dragged). */ getIsDragAndDropDisabled: () => boolean; } /** * @internal */ export interface DataTableV2ColumnOrderColumn { /** * Returns whether a column can be moved to the left. If the column is the first column overall or the first column in a group this function returns `false`. * For usage in the column settings modal, it is possible to pass local columns that should be considered, instead of the ones from the current table state. * @param localLeafColumns - ordered leaf columns to compare with, including hidden ones * @param localSiblings - ordered sibling columns to compare with, including hidden ones */ getCanMoveColumnLeft: (localLeafColumns?: Column[], localSibilings?: Column[]) => boolean; /** * Returns whether a column can be moved to the right. If the column is the last column overall or the last column in a group this function returns `false`. * For usage in the column settings modal, it is possible to pass local columns that should be considered, instead of the ones from the current table state. * @param localLeafColumns - ordered leaf columns to compare with, including hidden ones * @param localSiblings - ordered sibling columns to compare with, including hidden ones */ getCanMoveColumnRight: (localLeafColumns?: Column[], localSibilings?: Column[]) => boolean; /** * Moves a column to the left and returns the updated column order. * For usage in the column settings modal, it is possible to pass the ordered local columns and column order that should be considered, instead of using the current table state. * The table state is only updated if no local columns are passed. * @param localLeafColumns - ordered leaf columns to compare with, including hidden ones * @param localColumnOrder - the initial column order that should be adjusted */ moveColumnLeft: (localLeafColumns?: Column[], localColumnOrder?: string[]) => string[]; /** * Moves a column to the right and returns the updated column order. * For usage in the column settings modal, it is possible to pass the ordered local columns and column order that should be considered, instead of using the current table state. * The table state is only updated if no local columns are passed. * @param localLeafColumns - ordered leaf columns to compare with, including hidden ones * @param localColumnOrder - the initial column order that should be adjusted */ moveColumnRight: (localLeafColumns?: Column[], localColumnOrder?: string[]) => string[]; } /** * Additional feature implementation for column order. * @internal */ export declare const DataTableV2ColumnOrder: TableFeature; /** * Configuration hook for the DataTableV2 ColumnOrder feature. * @internal */ export declare function useColumnOrder(props: DataTableV2ColumnOrderProps & { columns: DataTableV2ColumnDef[]; }, options: TableOptions): void;