/** * useLocalStorage.ts * * Forma - localStorage 관리 훅 | localStorage management hook * useState와 유사한 패턴으로 localStorage 데이터를 관리합니다 * Manages localStorage data with a pattern similar to useState * * @license MIT License * @copyright 2025 KIM YOUNG JIN (Kim Young Jin) * @author KIM YOUNG JIN (ehfuse@gmail.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /** * useLocalStorage 훅의 반환 타입 | useLocalStorage hook return type */ export interface UseLocalStorageReturn { /** 현재 값 | Current value */ value: T; /** 값 설정 (함수형 업데이트 지원) | Set value (supports functional updates) */ setValue: (value: T | ((prev: T) => T)) => void; /** 저장된 값 삭제 | Remove stored value */ remove: () => void; /** 값 존재 여부 | Whether value exists */ has: boolean; } /** * useLocalStorage 훅 옵션 | useLocalStorage hook options */ export interface UseLocalStorageOptions { /** sessionStorage 사용 여부 (기본: localStorage) | Use sessionStorage instead (default: localStorage) */ session?: boolean; } /** * useState와 유사한 패턴의 localStorage 관리 훅 * localStorage management hook with useState-like pattern * * GlobalFormaProvider의 storagePrefix가 설정된 경우 자동으로 키에 prefix가 적용됩니다. * If GlobalFormaProvider's storagePrefix is set, it will be automatically applied to keys. * * @template T 저장할 값의 타입 | Type of value to store * @param key localStorage 키 | localStorage key * @param defaultValue 기본값 | Default value * @param options 옵션 | Options * @returns localStorage 관리 API | localStorage management API * * @example * ```typescript * // 기본 사용 * const { value: theme, setValue: setTheme } = useLocalStorage('theme', 'light'); * * // sessionStorage 사용 * const { value, setValue } = useLocalStorage('session-data', {}, { session: true }); * * // 객체 저장 * interface UserPrefs { * theme: 'light' | 'dark'; * fontSize: number; * } * const { value: prefs, setValue: setPrefs } = useLocalStorage('prefs', { * theme: 'light', * fontSize: 14 * }); * * // 함수형 업데이트 * setPrefs(prev => ({ ...prev, theme: 'dark' })); * * // GlobalFormaProvider와 함께 사용 (자동 prefix) * // * // 실제 키: "myapp:theme" * ``` */ export declare function useLocalStorage(key: string, defaultValue: T, options?: UseLocalStorageOptions): UseLocalStorageReturn; /** * storagePrefix를 가져오는 유틸리티 훅 | Utility hook to get storagePrefix * * @returns storagePrefix 값 | storagePrefix value * * @example * ```typescript * const prefix = useStoragePrefix(); * console.log(prefix); // "myapp" or undefined * ``` */ export declare function useStoragePrefix(): string | undefined; //# sourceMappingURL=useLocalStorage.d.ts.map