interface UseStateWithHistoryOptions { /** * Maximum number of history entries to store * @default 10 */ capacity?: number; /** * Initial history entries * @default [] */ initialHistory?: T[]; } interface StateWithHistoryResult { /** Current state value */ state: T; /** All history entries */ history: T[]; /** Index of the current state in history */ currentIndex: number; /** Set state and add to history */ setState: (value: T | ((prev: T) => T)) => void; /** Go back to the previous state in history */ undo: () => void; /** Go forward to the next state in history */ redo: () => void; /** Whether there's a previous state to go back to */ canUndo: boolean; /** Whether there's a next state to go forward to */ canRedo: boolean; /** Go to a specific point in history by index */ goTo: (index: number) => void; /** Clear all history except current state */ clearHistory: () => void; } /** * A hook that provides state management with history tracking for undo/redo functionality. * * @param initialState - The initial state value * @param options - Configuration options for history management * @returns An object containing the current state, history, and methods to navigate through history * * @example * ```tsx * const { * state, * setState, * undo, * redo, * canUndo, * canRedo * } = useStateWithHistory({ count: 0 }); * * // Update state * setState({ count: state.count + 1 }); * * // Undo last action if possible * if (canUndo) undo(); * * // Redo last undone action if possible * if (canRedo) redo(); * ``` */ export declare function useStateWithHistory(initialState: T, options?: UseStateWithHistoryOptions): StateWithHistoryResult; export {};