import { UseModuleStateReturn } from '../types'; /** * Options for useModuleState hook. */ export interface UseModuleStateOptions { /** Initial state value */ initialValue: T; /** Storage key for persistence */ storageKey?: string; /** Whether to persist to sessionStorage instead of localStorage */ useSessionStorage?: boolean; /** Custom serializer */ serialize?: (value: T) => string; /** Custom deserializer */ deserialize?: (value: string) => T; /** Validation function */ validate?: (value: unknown) => value is T; /** Callback when state changes */ onChange?: (value: T, previousValue: T) => void; } /** * Hook for managing isolated module state. * Provides state isolation within module boundaries with optional persistence. * * @param key - State key (unique within module) * @param options - State options * @returns State value and setter utilities * @throws Error if used outside a ModuleBoundary * * @example * ```tsx * function Counter() { * const { state, setState } = useModuleState('count', { * initialValue: 0, * storageKey: 'counter-value', * }); * * return ( *
*

Count: {state}

* * *
* ); * } * ``` */ export declare function useModuleState(key: string, options: UseModuleStateOptions): UseModuleStateReturn; /** * Simplified hook for module state without persistence. * @param key - State key * @param initialValue - Initial value * @returns State and setter * * @example * ```tsx * const [name, setName] = useSimpleModuleState('userName', ''); * ``` */ export declare function useSimpleModuleState(key: string, initialValue: T): [T, (value: T | ((prev: T) => T)) => void]; /** * Hook for boolean module state with toggle functionality. * @param key - State key * @param initialValue - Initial boolean value * @returns Boolean state with utilities * * @example * ```tsx * const { value, toggle, setTrue, setFalse } = useBooleanModuleState('isOpen', false); * ``` */ export declare function useBooleanModuleState(key: string, initialValue?: boolean): { value: boolean; toggle: () => void; setTrue: () => void; setFalse: () => void; setValue: (value: boolean) => void; }; /** * Hook for array module state with common array operations. * @param key - State key * @param initialValue - Initial array value * @returns Array state with utilities * * @example * ```tsx * const { items, add, remove, update, clear } = useArrayModuleState('todos', []); * * // Add item * add({ id: '1', text: 'New todo' }); * * // Remove item * remove((item) => item.id === '1'); * ``` */ export declare function useArrayModuleState(key: string, initialValue?: T[]): { items: T[]; add: (item: T) => void; addMany: (items: T[]) => void; remove: (predicate: (item: T) => boolean) => void; update: (predicate: (item: T) => boolean, updater: (item: T) => T) => void; clear: () => void; setItems: (items: T[] | ((prev: T[]) => T[])) => void; }; /** * Hook for map/record module state. * @param key - State key * @param initialValue - Initial record value * @returns Record state with utilities */ export declare function useRecordModuleState(key: string, initialValue?: Record): { record: Record; get: (key: K) => V | undefined; set: (key: K, value: V) => void; remove: (key: K) => void; has: (key: K) => boolean; clear: () => void; setRecord: (record: Record) => void; };