import { UndoRedoAction } from '@toolbox-web/grid/plugins/undo-redo'; export type { _Augmentation as _UndoRedoAugmentation } from '@toolbox-web/grid/features/undo-redo'; /** * Undo/Redo methods returned from useGridUndoRedo. */ export interface UndoRedoMethods { /** * Undo the last edit action. * @returns The undone action (or compound action), or null if nothing to undo */ undo: () => UndoRedoAction | null; /** * Redo the last undone action. * @returns The redone action (or compound action), or null if nothing to redo */ redo: () => UndoRedoAction | null; /** * Check if there are any actions that can be undone. */ canUndo: () => boolean; /** * Check if there are any actions that can be redone. */ canRedo: () => boolean; /** * Clear all undo/redo history. */ clearHistory: () => void; /** * Get a copy of the current undo stack. */ getUndoStack: () => UndoRedoAction[]; /** * Get a copy of the current redo stack. */ getRedoStack: () => UndoRedoAction[]; /** * Manually record an edit action. * If a transaction is active, the action is buffered; otherwise it's pushed to the undo stack. */ recordEdit: (rowIndex: number, field: string, oldValue: unknown, newValue: unknown) => void; /** * Begin a transaction. All edits recorded until `endTransaction()` are grouped * into a single compound action for undo/redo. * @throws If a transaction is already active */ beginTransaction: () => void; /** * End the active transaction and push the compound action to the undo stack. * If only one edit was recorded, it's pushed as a plain EditAction. * If no edits were recorded, the transaction is discarded. * @throws If no transaction is active */ endTransaction: () => void; } /** * Hook for programmatic undo/redo control. * * Must be used within a DataGrid component tree with undoRedo and editing enabled. * * @example * ```tsx * import { useGridUndoRedo } from '@toolbox-web/grid-react/features/undo-redo'; * * function UndoRedoControls() { * const { undo, redo, canUndo, canRedo, clearHistory } = useGridUndoRedo(); * * return ( *
* * * *
* ); * } * ``` * @param selector - Optional CSS selector to target a specific grid element via * DOM query instead of using React context. Use when the component contains * multiple grids, e.g. `'tbw-grid.primary'` or `'#my-grid'`. */ export declare function useGridUndoRedo(selector?: string): UndoRedoMethods; //# sourceMappingURL=undo-redo.d.ts.map