@cp949/mui-react19 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.file-drop.md +843 -0
  2. package/README.md +211 -0
  3. package/dist/chunk-3KMZF7M6.cjs +2 -0
  4. package/dist/chunk-3KMZF7M6.cjs.map +1 -0
  5. package/dist/chunk-4C666HHU.js +2 -0
  6. package/dist/chunk-4C666HHU.js.map +1 -0
  7. package/dist/chunk-M4G6J7DP.cjs +2 -0
  8. package/dist/chunk-M4G6J7DP.cjs.map +1 -0
  9. package/dist/chunk-T37ZYZXP.js +2 -0
  10. package/dist/chunk-T37ZYZXP.js.map +1 -0
  11. package/dist/closables-BK0Db72u.d.cts +135 -0
  12. package/dist/closables-BK0Db72u.d.ts +135 -0
  13. package/dist/file-drop/index.cjs +2 -0
  14. package/dist/file-drop/index.cjs.map +1 -0
  15. package/dist/file-drop/index.d.cts +748 -0
  16. package/dist/file-drop/index.d.ts +748 -0
  17. package/dist/file-drop/index.js +2 -0
  18. package/dist/file-drop/index.js.map +1 -0
  19. package/dist/helper/index.cjs +2 -0
  20. package/dist/helper/index.cjs.map +1 -0
  21. package/dist/helper/index.d.cts +113 -0
  22. package/dist/helper/index.d.ts +113 -0
  23. package/dist/helper/index.js +2 -0
  24. package/dist/helper/index.js.map +1 -0
  25. package/dist/hooks/index.cjs +2 -0
  26. package/dist/hooks/index.cjs.map +1 -0
  27. package/dist/hooks/index.d.cts +1319 -0
  28. package/dist/hooks/index.d.ts +1319 -0
  29. package/dist/hooks/index.js +2 -0
  30. package/dist/hooks/index.js.map +1 -0
  31. package/dist/index.cjs +2 -0
  32. package/dist/index.cjs.map +1 -0
  33. package/dist/index.d.cts +910 -0
  34. package/dist/index.d.ts +910 -0
  35. package/dist/index.js +2 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/parallel-map-M764G6IE.js +2 -0
  38. package/dist/parallel-map-M764G6IE.js.map +1 -0
  39. package/dist/parallel-map-V2OVUIFQ.cjs +2 -0
  40. package/dist/parallel-map-V2OVUIFQ.cjs.map +1 -0
  41. package/package.json +117 -0
@@ -0,0 +1,1319 @@
1
+ import * as react from 'react';
2
+ import react__default, { DependencyList, EffectCallback, SetStateAction, useEffect, Dispatch } from 'react';
3
+ import { C as Closables } from '../closables-BK0Db72u.cjs';
4
+ import { UseMediaQueryOptions } from '@mui/material';
5
+ import 'rxjs';
6
+
7
+ /**
8
+ * 주어진 요소의 좌측,상단 위치를 리턴한다.
9
+ */
10
+ declare function useAbsolutePosition<E extends Element = Element>(deps: react__default.DependencyList, options?: {
11
+ intervalMs?: number;
12
+ }): [(element: E | null) => void, {
13
+ x: number;
14
+ y: number;
15
+ }];
16
+
17
+ /**
18
+ * 사용자의 입력(터치, 클릭, 키보드 등)을 감지하여 오디오가 활성화되었는지(unlocked) 상태를 관리하는 커스텀 훅입니다.
19
+ *
20
+ * 이 훅은 사용자의 입력 이벤트를 통해 오디오가 활성화되었는지 확인하고, 활성화 시 제공된 콜백 함수를 호출합니다.
21
+ * 활성화 여부는 `sessionStorage`를 사용하여 상태를 유지합니다.
22
+ *
23
+ * @param options - 훅의 동작을 제어하는 옵션 객체
24
+ * @param options.onUnlocked - 오디오가 활성화되었을 때 호출되는 콜백 함수
25
+ *
26
+ * @returns `boolean` 값으로 오디오 활성화 상태를 반환합니다.
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * const isAudioUnlocked = useAudioUnlocked({
31
+ * onUnlocked: () => {
32
+ * console.log('오디오가 활성화되었습니다!');
33
+ * },
34
+ * });
35
+ *
36
+ * return (
37
+ * <div>
38
+ * {isAudioUnlocked ? "오디오 활성화됨" : "오디오 비활성화됨"}
39
+ * </div>
40
+ * );
41
+ * ```
42
+ */
43
+ declare function useAudioUnlocked(options: {
44
+ onUnlocked: () => void;
45
+ }): boolean;
46
+
47
+ interface Observable<T> {
48
+ subscribe: (listener: (value: T) => void) => {
49
+ unsubscribe: () => void;
50
+ };
51
+ }
52
+ interface BehaviorSubject<T> extends Observable<T> {
53
+ value: T;
54
+ }
55
+ type DependenciesComparator<Deps extends DependencyList = DependencyList> = (a: Deps, b: Deps) => boolean;
56
+
57
+ type Fn<T> = () => T;
58
+ declare function useBehaviorSubject<TItem>(subject: BehaviorSubject<TItem> | Fn<BehaviorSubject<TItem>>): TItem;
59
+
60
+ /**
61
+ * React 컴포넌트에서 최신의 콜백을 안전하게 참조하기 위한 커스텀 훅.
62
+ *
63
+ * `useCallbackRef`는 콜백 함수가 렌더링 사이에서 변경되더라도 최신 콜백을 안전하게 사용할 수 있도록 도와줍니다.
64
+ * 메모리 누수를 방지하거나 이벤트 핸들러의 최신 상태를 유지하기 위해 유용합니다.
65
+ *
66
+ * @template T - 콜백 함수의 타입.
67
+ * @param callback - 최신 콜백 함수 또는 `undefined`.
68
+ * @returns 최신 콜백 함수를 호출할 수 있는 메모이제이션된 함수.
69
+ *
70
+ * @example
71
+ * ```tsx
72
+ * const Component = () => {
73
+ * const [count, setCount] = useState(0);
74
+ * const handleClick = useCallbackRef(() => {
75
+ * console.log(`현재 카운트는 ${count}입니다.`);
76
+ * });
77
+ *
78
+ * useEffect(() => {
79
+ * const timer = setInterval(() => {
80
+ * handleClick();
81
+ * }, 1000);
82
+ * return () => clearInterval(timer);
83
+ * }, [handleClick]);
84
+ *
85
+ * return <button onClick={() => setCount(count + 1)}>카운트 증가</button>;
86
+ * };
87
+ * ```
88
+ */
89
+ declare function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T;
90
+
91
+ /**
92
+ * 특정 요소가 뷰포트의 세로 중앙에 위치해 있는지를 감지하는 커스텀 React 훅입니다.
93
+ *
94
+ * 요소의 세로 중심점이 뷰포트 중심(`window.innerHeight / 2`)과의 거리 차가
95
+ * 지정된 오차 범위(`offset`) 이내에 있는 경우, `isCenter` 값이 `true`가 됩니다.
96
+ *
97
+ * 이 훅은 요소가 뷰포트 중앙에 시각적으로 들어왔는지를 감지하는 데 유용합니다.
98
+ *
99
+ * @param offset - 중심 간 거리 차이 허용 범위(px). 기본값은 0이며, 값이 클수록 더 넓은 범위를 "중앙"으로 인식합니다.
100
+ * @returns 객체 형태로 `ref`와 `isCenter`를 반환합니다.
101
+ *
102
+ * @example
103
+ * ```tsx
104
+ * const { ref, isCenter } = useCenterInView(50);
105
+ *
106
+ * return (
107
+ * <div ref={ref}>
108
+ * {isCenter ? '중앙에 있어요!' : '중앙이 아님'}
109
+ * </div>
110
+ * );
111
+ * ```
112
+ */
113
+ declare function useCenterInView(offset?: number): {
114
+ ref: React.RefObject<HTMLDivElement | null>;
115
+ isCenter: boolean;
116
+ };
117
+
118
+ /**
119
+ * 클립보드 복사 기능을 제공하는 React 훅입니다.
120
+ *
121
+ * @param options - 옵션 객체입니다.
122
+ * @param options.timeout - 복사 완료 상태가 유지되는 시간(밀리초)입니다. 기본값은 2000ms입니다.
123
+ * @returns
124
+ * - `copy`: 문자열을 클립보드에 복사하는 함수
125
+ * - `reset`: 상태를 초기화하는 함수
126
+ * - `error`: 클립보드 복사 중 발생한 오류
127
+ * - `copied`: 복사 성공 여부
128
+ *
129
+ * @example
130
+ * ```tsx
131
+ * const { copy, reset, error, copied } = useClipboard({ timeout: 3000 });
132
+ *
133
+ * return (
134
+ * <div>
135
+ * <button onClick={() => copy('복사할 내용')}>복사</button>
136
+ * {copied && <span>복사되었습니다!</span>}
137
+ * {error && <span>복사 실패: {error.message}</span>}
138
+ * <button onClick={reset}>초기화</button>
139
+ * </div>
140
+ * );
141
+ * ```
142
+ */
143
+ declare function useClipboard({ timeout }?: {
144
+ timeout?: number | undefined;
145
+ }): {
146
+ copy: (valueToCopy: string) => void;
147
+ reset: () => void;
148
+ error: Error | null;
149
+ copied: boolean;
150
+ };
151
+
152
+ type Callback = ((closable: Closables) => VoidFunction | undefined) | ((closable: Closables) => void);
153
+ declare function useClosableEffect(callback: Callback, deps: unknown[]): void;
154
+
155
+ type PossibleRef<T> = React.Ref<T> | undefined;
156
+ /**
157
+ * A utility to compose multiple refs together
158
+ * Accepts callback refs and RefObject(s)
159
+ */
160
+ declare function composeRefs<T>(...refs: PossibleRef<T>[]): (node: T | null) => void;
161
+ /**
162
+ * A custom hook that composes multiple refs
163
+ * Accepts callback refs and RefObject(s)
164
+ */
165
+ declare function useComposedRefs<T>(...refs: PossibleRef<T>[]): (node: T | null) => void;
166
+
167
+ declare function useConstant<T>(fn: () => T): T;
168
+
169
+ type DepsEqualFnType<TDeps extends DependencyList> = (prevDeps: TDeps, nextDeps: TDeps) => boolean;
170
+ /**
171
+ * 사용자 정의 비교 함수를 사용하여 `useEffect`의 의존성 배열을 커스텀 비교 방식으로 처리할 수 있는 커스텀 훅입니다.
172
+ *
173
+ * 이 훅은 의존성 배열이 React의 기본 비교 방식(얕은 비교)을 따르지 않고, 사용자가 제공한 비교 함수(`depsEqual`)를 통해
174
+ * 의존성 변경 여부를 판단합니다. 이를 통해 중첩된 객체나 배열 등의 복잡한 데이터 구조를 의존성 배열로 사용할 때,
175
+ * React의 `useEffect`를 더욱 유연하게 활용할 수 있습니다.
176
+ *
177
+ * @template TDeps - 의존성 배열의 타입. `DependencyList`를 확장하여 일반적으로 배열 형태를 기대합니다.
178
+ *
179
+ * @param effect - 실행할 효과 함수. `useEffect`의 콜백 함수와 동일한 형태입니다.
180
+ * @param deps - 의존성 배열. 훅에서 이 배열의 변경 여부를 감지하여 효과 함수를 실행합니다.
181
+ * @param depsEqual - 사용자 정의 비교 함수. 이전 의존성과 새로운 의존성을 비교하여 같으면 `true`, 다르면 `false`를 반환해야 합니다.
182
+ *
183
+ * @example
184
+ * ```tsx
185
+ * import { useCustomCompareEffect } from './useCustomCompareEffect';
186
+ *
187
+ * function MyComponent({ complexObject }: { complexObject: { key: string } }) {
188
+ * const customCompare = (prevDeps: [{ key: string }], nextDeps: [{ key: string }]) =>
189
+ * prevDeps[0].key === nextDeps[0].key;
190
+ *
191
+ * useCustomCompareEffect(
192
+ * () => {
193
+ * console.log('complexObject가 변경되었습니다.');
194
+ * },
195
+ * [complexObject],
196
+ * customCompare
197
+ * );
198
+ *
199
+ * return <div>Custom Compare Effect Example</div>;
200
+ * }
201
+ * ```
202
+ *
203
+ * @why
204
+ * - 기본 `useEffect`는 의존성 배열에서 얕은 비교(참조 비교)를 수행하기 때문에, 중첩 객체나 배열 등의 복잡한 데이터 구조를 의존성으로 사용할 때 부적합합니다.
205
+ * - `useCustomCompareEffect`는 사용자 정의 비교 함수를 제공함으로써, 이러한 제한을 해결하고 더 세밀한 비교 로직을 구현할 수 있도록 합니다.
206
+ *
207
+ * @warning
208
+ * - **빈 의존성 배열 사용 금지**: 이 훅은 의존성이 없는 경우(`[]`) 적합하지 않으므로, 기본 `useEffect`를 사용하는 것이 좋습니다.
209
+ * - **모두 기본 값(primitive)인 의존성 배열 사용 금지**: 의존성 배열이 모두 기본 값일 경우 기본 `useEffect`를 사용하는 것이 더 적합합니다.
210
+ * - **`depsEqual` 콜백 필수**: `depsEqual`은 의존성을 비교하기 위한 필수 콜백입니다.
211
+ *
212
+ * @internalDetails
213
+ * - `useRef`를 사용하여 이전 의존성을 저장합니다.
214
+ * - 사용자가 제공한 `depsEqual` 함수로 이전 의존성과 새 의존성을 비교합니다.
215
+ * - 비교 결과가 다르면 `effect`를 실행하고, 새 의존성을 `ref`에 저장합니다.
216
+ *
217
+ * @returns 없음. 이 훅은 `useEffect`와 동일하게 부수 효과를 실행하며, 반환값은 없습니다.
218
+ */
219
+ declare const useCustomCompareEffect: <TDeps extends DependencyList>(effect: EffectCallback, deps: TDeps, depsEqual: DepsEqualFnType<TDeps>) => void;
220
+
221
+ /**
222
+ * Like useMemo but uses provided comparator function to validate dependency changes.
223
+ *
224
+ * @param factory useMemo factory function
225
+ * @param deps useMemo dependency list
226
+ * @param comparator function to validate dependency changes
227
+ * @returns useMemo result
228
+ */
229
+ declare const useCustomCompareMemo: <T, Deps extends DependencyList>(factory: () => T, deps: Deps, comparator: DependenciesComparator<Deps>) => T;
230
+
231
+ interface UseDebouncedCallbackOptions {
232
+ leading?: boolean;
233
+ trailing?: boolean;
234
+ }
235
+ /**
236
+ * useDebouncedCallback
237
+ *
238
+ * 디바운싱된 콜백 함수를 반환하는 React 훅
239
+ *
240
+ * @param callback - 디바운스 처리할 콜백 함수
241
+ * @param wait - 디바운스 대기 시간(ms)
242
+ * @param options - leading, trailing 설정
243
+ *
244
+ * @returns 디바운스된 콜백과 취소 함수가 포함된 객체
245
+ *
246
+ * @example
247
+ * ```tsx
248
+ * const debouncedUpdate = useDebouncedCallback(
249
+ * () => {
250
+ * console.log("Debounced!");
251
+ * },
252
+ * 200,
253
+ * { leading: true, trailing: false }
254
+ * );
255
+ *
256
+ * // 호출
257
+ * debouncedUpdate(); // 즉시 실행
258
+ * debouncedUpdate(); // 무시됨
259
+ *
260
+ * // 취소
261
+ * debouncedUpdate.cancel();
262
+ * ```
263
+ */
264
+ declare function useDebouncedCallback<T extends (...args: any[]) => void>(callback: T, wait: number, options?: UseDebouncedCallbackOptions): T & {
265
+ cancel: () => void;
266
+ };
267
+
268
+ /**
269
+ * 상태 업데이트를 지연시키는 커스텀 훅.
270
+ * `useState`와 비슷하지만 상태 업데이트를 지연(debounce)시킬 수 있는 React 커스텀 훅입니다.
271
+ *
272
+ * @template T - 상태 값의 타입. 기본값은 `any`입니다.
273
+ * @param defaultValue - 초기 상태 값.
274
+ * @param wait - 상태 업데이트 지연 시간(밀리초 단위).
275
+ * @param options - 상태 업데이트 동작 방식을 설정하는 옵션 객체. 기본값은 `{ leading: false }`입니다.
276
+ * - `leading`: `true`일 경우, 상태 업데이트가 지연 없이 즉시 한 번 발생하며 이후 변경은 지연됩니다.
277
+ *
278
+ * @returns 반환값은 다음과 같습니다:
279
+ * - `value`: 현재 상태 값.
280
+ * - `debouncedSetValue`: 상태를 업데이트하는 함수로, 업데이트가 지연됩니다.
281
+ *
282
+ * @example
283
+ * ```tsx
284
+ * const [value, setValue] = useDebouncedState("", 500, { leading: true });
285
+ *
286
+ * const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
287
+ * setValue(e.target.value);
288
+ * };
289
+ *
290
+ * return (
291
+ * <input value={value} onChange={handleChange} />
292
+ * );
293
+ * ```
294
+ */
295
+ declare function useDebouncedState<T>(defaultValue: T, // 초기 상태 값
296
+ wait: number, // 지연 시간 (밀리초)
297
+ options?: {
298
+ leading: boolean;
299
+ }): readonly [T, (newValue: SetStateAction<T>) => void];
300
+
301
+ /**
302
+ * 값의 변화를 지연시키는 커스텀 훅
303
+ *
304
+ * @template T - 값의 타입. 기본값은 `any`.
305
+ * @param value - 지연 처리할 값.
306
+ * @param wait - 지연 시간(밀리초 단위).
307
+ * @param options - 지연 처리 동작 방식을 설정하는 옵션.
308
+ * - `leading`: 첫 번째 업데이트를 즉시 처리할지 여부 (기본값: `false`).
309
+ *
310
+ * @returns 지연 처리된 값과 타이머를 취소하는 함수.
311
+ */
312
+ declare function useDebouncedValue<T>(
313
+ /** 지연 처리할 값 */
314
+ value: T,
315
+ /** 지연 시간(밀리초 단위) */
316
+ wait: number,
317
+ /** 옵션: 첫 업데이트 즉시 처리 여부 */
318
+ options?: {
319
+ leading: boolean;
320
+ }): readonly [T, () => void];
321
+
322
+ interface DebounceOptions$1 {
323
+ wait?: number;
324
+ leading?: boolean;
325
+ trailing?: boolean;
326
+ maxWait?: number;
327
+ }
328
+ /**
329
+ * 디바운스 처리된 `effect`를 제공하는 React 커스텀 훅입니다.
330
+ * 특정 의존성 배열(`deps`)이 변경될 때, 지정된 지연 시간(`wait`) 이후에 `effect`가 실행됩니다.
331
+ * 이 훅은 디바운스 옵션을 지원하며, `useDebounceFn` 및 `useUpdateEffect`를 활용하여 구현되었습니다.
332
+ *
333
+ * @param effect 디바운스 처리 후 실행할 이펙트 콜백 함수. React의 `useEffect`와 동일한 방식으로 동작합니다.
334
+ * @param deps 이펙트가 다시 실행될 때 참조할 의존성 배열. 기본값은 빈 배열(`[]`)입니다.
335
+ * @param options 디바운스 옵션 객체
336
+ * @param options.wait 함수 실행을 지연할 시간(밀리초). 기본값은 1000ms.
337
+ * @param options.leading `true`로 설정하면, 지연 타이머가 시작될 때 함수가 즉시 실행됩니다. 기본값은 `false`.
338
+ * @param options.trailing `true`로 설정하면, 지연 타이머가 종료될 때 함수가 실행됩니다. 기본값은 `true`.
339
+ * @param options.maxWait 함수가 지연될 수 있는 최대 시간. 설정하지 않으면 무제한입니다.
340
+ *
341
+ * @example
342
+ * ```typescript
343
+ * import { useDebounceEffect } from "./useDebounceEffect";
344
+ * import React, { useState } from "react";
345
+ *
346
+ * const ExampleComponent = () => {
347
+ * const [value, setValue] = useState("");
348
+ *
349
+ * useDebounceEffect(() => {
350
+ * console.log("Debounced effect:", value);
351
+ * }, [value], { wait: 500 });
352
+ *
353
+ * return (
354
+ * <input
355
+ * type="text"
356
+ * value={value}
357
+ * onChange={(e) => setValue(e.target.value)}
358
+ * placeholder="Type something..."
359
+ * />
360
+ * );
361
+ * };
362
+ * ```
363
+ *
364
+ * @remarks
365
+ * 이 훅은 두 단계로 동작합니다:
366
+ * 1. `deps` 배열이 변경될 때 `useDebounceFn`을 통해 디바운스 처리된 콜백이 실행됩니다.
367
+ * 2. 디바운스 처리된 콜백이 완료되면 `effect`가 실행됩니다.
368
+ *
369
+ * @see `useDebounceFn` 디바운스 처리된 함수 생성에 사용됩니다.
370
+ * @see `useUpdateEffect` 업데이트 시점에 이펙트를 실행하는 데 사용됩니다.
371
+ */
372
+ declare function useDebounceEffect(effect: EffectCallback, deps?: DependencyList, options?: DebounceOptions$1): void;
373
+
374
+ interface DebounceOptions {
375
+ wait?: number;
376
+ leading?: boolean;
377
+ trailing?: boolean;
378
+ maxWait?: number;
379
+ }
380
+ type noop = (...args: any[]) => any;
381
+ /**
382
+ * 주어진 함수 `fn`을 디바운스 처리하여, 특정 시간(`wait`) 동안 호출이 연속적으로 발생하지 않으면 실행되도록 합니다.
383
+ * 디바운스된 함수는 `run`, `cancel`, `flush` 메서드를 제공합니다.
384
+ *
385
+ * @param fn 디바운스 처리할 함수
386
+ * @param options 디바운스 옵션
387
+ * @param options.wait 함수 실행을 지연할 시간(밀리초). 기본값은 1000ms.
388
+ * @param options.leading `true`로 설정하면, 지연 타이머가 시작될 때 함수가 즉시 실행됩니다. 기본값은 `false`.
389
+ * @param options.trailing `true`로 설정하면, 지연 타이머가 종료될 때 함수가 실행됩니다. 기본값은 `true`.
390
+ * @param options.maxWait 함수가 지연될 수 있는 최대 시간. 설정하지 않으면 무제한입니다.
391
+ * @returns 디바운스된 함수와 제어 메서드를 포함하는 객체를 반환합니다.
392
+ * @returns.run 디바운스된 함수 실행
393
+ * @returns.cancel 지연 중인 함수 실행 취소
394
+ * @returns.flush 지연 중인 함수를 즉시 실행
395
+ *
396
+ * @example
397
+ * ```typescript
398
+ * const MyComponent = () => {
399
+ * const { run, cancel, flush } = useDebounceFn(
400
+ * (value: string) => {
401
+ * console.log(value);
402
+ * },
403
+ * { wait: 500, leading: true, trailing: false }
404
+ * );
405
+ *
406
+ * return (
407
+ * <input
408
+ * type="text"
409
+ * onChange={(e) => run(e.target.value)}
410
+ * onBlur={() => flush()}
411
+ * />
412
+ * );
413
+ * };
414
+ * ```
415
+ */
416
+ declare function useDebounceFn<T extends noop>(fn: T, options?: DebounceOptions): {
417
+ run: ((...args: Parameters<T>) => ReturnType<T>) & {
418
+ cancel: () => void;
419
+ flush: () => ReturnType<T> | undefined;
420
+ };
421
+ cancel: () => void;
422
+ flush: () => ReturnType<T> | undefined;
423
+ };
424
+
425
+ /**
426
+ * 의존성 배열의 깊은 비교(Deep Comparison)를 수행하여 `useEffect`를 실행하는 커스텀 훅입니다.
427
+ *
428
+ * React의 기본 `useEffect`는 의존성 배열의 얕은 비교(Shallow Comparison)를 통해 변화 여부를 판단합니다.
429
+ * 이 훅은 `deepEq` 함수를 사용하여 의존성 배열의 깊은 비교를 수행하고, 배열의 복잡한 데이터 구조(중첩 객체, 배열 등)에서도
430
+ * 적절히 변경 사항을 감지하여 효과를 실행할 수 있도록 지원합니다.
431
+ *
432
+ * @param effect - 실행할 효과 함수. `useEffect`와 동일한 형태로, 컴포넌트가 렌더링될 때 실행됩니다.
433
+ * @param deps - 의존성 배열. 이 배열의 변경 여부를 깊은 비교를 통해 판단하여 `effect`를 실행합니다.
434
+ *
435
+ * @example
436
+ * ```tsx
437
+ * import React, { useState } from 'react';
438
+ * import { useDeepCompareEffect } from './useDeepCompareEffect';
439
+ *
440
+ * function MyComponent() {
441
+ * const [data, setData] = useState({ key: 'value' });
442
+ *
443
+ * useDeepCompareEffect(() => {
444
+ * console.log('데이터가 변경되었습니다:', data);
445
+ * }, [data]);
446
+ *
447
+ * return (
448
+ * <button onClick={() => setData({ key: 'value' })}>
449
+ * 데이터 변경 시도
450
+ * </button>
451
+ * );
452
+ * }
453
+ * ```
454
+ *
455
+ * @why
456
+ * - 기본 `useEffect`는 의존성 배열의 얕은 비교를 수행하므로, 객체나 배열과 같은 복잡한 데이터 구조의 변경 여부를 제대로 감지하지 못할 수 있습니다.
457
+ * - `useDeepCompareEffect`는 의존성 배열의 깊은 비교를 수행하여 이러한 문제를 해결합니다.
458
+ *
459
+ * @warning
460
+ * - **빈 의존성 배열 사용 금지**: 의존성 배열이 비어 있는 경우 기본 `useEffect`를 사용하는 것이 적합합니다.
461
+ * - **모든 값이 기본 값(Primitive)인 경우**: 의존성 배열이 모두 기본 값이라면 기본 `useEffect`를 사용하는 것이 더 효율적입니다.
462
+ * - **깊은 비교 비용**: `deepEq` 함수는 깊은 비교를 수행하므로, 의존성 배열이 매우 크거나 복잡한 경우 성능에 영향을 줄 수 있습니다.
463
+ *
464
+ * @internalDetails
465
+ * - `useCustomCompareEffect`를 내부적으로 호출하며, `deepEq`를 비교 함수로 사용하여 의존성 배열의 깊은 비교를 수행합니다.
466
+ * - 개발 환경에서는 `deps`에 대해 여러 가지 유효성 검사를 수행하여 잘못된 사용을 방지합니다.
467
+ *
468
+ * @returns 없음. 이 훅은 `useEffect`와 동일하게 부수 효과를 실행하며, 반환값은 없습니다.
469
+ */
470
+ declare const useDeepCompareEffect: (effect: EffectCallback, deps: DependencyList) => void;
471
+
472
+ /**
473
+ * Like useMemo but validates dependency changes using deep equality check instead of reference check.
474
+ *
475
+ * @param factory Function calculating the value to be memoized.
476
+ * @param deps The list of all reactive values referenced inside `factory`.
477
+ * @returns Initially returns the result of calling `factory`. On subsequent renders, it will return
478
+ * the same value, if dependencies haven't changed, or the result of calling `factory` again, if they have changed.
479
+ */
480
+ declare function useDeepCompareMemo<T, Deps extends DependencyList>(factory: () => T, deps: Deps): T;
481
+
482
+ declare function useDidUpdate(fn: EffectCallback, dependencies?: DependencyList): void;
483
+
484
+ /**
485
+ * 컴포넌트가 마운트될 때 한 번만 실행되는 `useEffect`를 구현하기 위한 커스텀 훅입니다.
486
+ *
487
+ * React의 `useEffect`는 의존성 배열을 통해 특정 조건에서만 실행되도록 제어할 수 있습니다.
488
+ * 이 훅은 의존성 배열을 빈 배열(`[]`)로 고정하여 **컴포넌트가 처음 렌더링될 때** 한 번만 실행되는 효과를 단순화합니다.
489
+ *
490
+ * @param effect - 컴포넌트가 처음 렌더링될 때 실행될 효과 함수. `useEffect`에서 사용하는 것과 동일한 형태입니다.
491
+ *
492
+ * @example
493
+ * ```tsx
494
+ * function MyComponent() {
495
+ * useEffectOnce(() => {
496
+ * console.log("컴포넌트가 마운트되었습니다.");
497
+ * return () => {
498
+ * console.log("컴포넌트가 언마운트되었습니다.");
499
+ * };
500
+ * });
501
+ *
502
+ * return <div>My Component</div>;
503
+ * }
504
+ * ```
505
+ * @returns 없음. `useEffect`와 동일하게 동작하며, 반환값은 없습니다.
506
+ */
507
+ declare const useEffectOnce: (effect: EffectCallback) => void;
508
+
509
+ /**
510
+ * 요소의 참조(ref)와 해당 요소의 너비(width) 및 높이(height)를 제공하는 커스텀 React 훅.
511
+ * `useResizeObserver` 훅을 활용하여 요소의 크기를 관찰합니다.
512
+ *
513
+ * @template T - 관찰할 HTML 요소의 타입. 기본값은 `HTMLElement`입니다.
514
+ * @param options - 관찰을 설정하기 위한 선택적인 `ResizeObserverOptions` 객체.
515
+ * @returns 객체 형태의 반환값:
516
+ * - `ref`: 관찰할 요소에 연결하기 위한 React 참조 객체.
517
+ * - `width`: 관찰된 요소의 현재 너비.
518
+ * - `height`: 관찰된 요소의 현재 높이.
519
+ *
520
+ * @example
521
+ * ```tsx
522
+ * const { ref, width, height } = useElementSize();
523
+ *
524
+ * return (
525
+ * <div ref={ref} style={{ resize: "both", overflow: "auto" }}>
526
+ * Width: {width}, Height: {height}
527
+ * </div>
528
+ * );
529
+ * ```
530
+ */
531
+ declare function useElementSize<T extends HTMLElement = HTMLElement>(options?: ResizeObserverOptions): {
532
+ ref: react.RefObject<T | null>;
533
+ width: number;
534
+ height: number;
535
+ };
536
+
537
+ declare function useEventListener<K extends keyof HTMLElementEventMap, T extends HTMLElement = HTMLElement>(type: K, listener: (this: T, ev: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): react.RefObject<T | undefined>;
538
+
539
+ declare function useId(staticId?: string): string;
540
+
541
+ /**
542
+ * 사용자의 비활성 상태를 감지하고, 비활성 여부를 반환하는 커스텀 훅입니다.
543
+ *
544
+ * 이 훅은 사용자의 특정 이벤트(마우스 움직임, 키보드 입력 등)를 감지하여 비활성 상태인지(active 상태가 아닌지)를 판단합니다.
545
+ * 사용자가 지정한 시간(`ms`) 동안 이벤트가 발생하지 않으면 비활성 상태로 간주됩니다.
546
+ *
547
+ * @param ms - 비활성 상태로 간주하기 위한 시간(밀리초). 기본값은 1분(60,000ms)입니다.
548
+ * @param initialState - 초기 비활성 상태 값. 기본값은 `false`입니다(초기에는 활성 상태로 간주).
549
+ * @param events - 비활성 상태를 해제하기 위해 감지할 이벤트 배열. 기본값은 `["mousemove", "mousedown", "resize", "keydown", "touchstart", "wheel"]`입니다.
550
+ *
551
+ * @returns `boolean` 값으로 현재 비활성 상태인지 여부를 반환합니다.
552
+ *
553
+ * @example
554
+ * ```tsx
555
+ * import React from "react";
556
+ * import { useIdle } from "./useIdle";
557
+ *
558
+ * function MyComponent() {
559
+ * const isIdle = useIdle(5000); // 5초 동안 사용자 입력이 없으면 비활성 상태로 간주
560
+ *
561
+ * return (
562
+ * <div>
563
+ * {isIdle ? "사용자가 비활성 상태입니다." : "사용자가 활성 상태입니다."}
564
+ * </div>
565
+ * );
566
+ * }
567
+ * ```
568
+ *
569
+ * @why
570
+ * - 사용자의 비활성 상태를 감지하여 자동 로그아웃, 화면 잠금, 에너지 절약 모드 전환 등의 기능을 구현할 때 유용합니다.
571
+ * - 기본적으로 여러 사용자 입력 이벤트를 감지하며, 필요에 따라 감지할 이벤트를 커스터마이징할 수 있습니다.
572
+ * - `lodash.throttle`를 사용하여 이벤트 핸들러 호출 빈도를 줄여 성능을 최적화합니다.
573
+ *
574
+ * @internalDetails
575
+ * - 이벤트 핸들러는 `throttle`을 사용하여 50ms 간격으로 호출됩니다.
576
+ * - `window`와 `document`에 여러 이벤트 리스너를 등록하여 사용자 입력을 감지합니다.
577
+ * - `setTimeout`을 사용하여 지정된 시간(`ms`) 동안 이벤트가 없으면 비활성 상태로 전환합니다.
578
+ * - `visibilitychange` 이벤트를 감지하여 사용자가 브라우저 탭을 다시 활성화했을 때 상태를 업데이트합니다.
579
+ *
580
+ * @warning
581
+ * - **이벤트 배열 변경 시**: `events`가 변경되면 기존 리스너가 모두 제거되고 새로운 리스너가 등록됩니다.
582
+ * - **성능 주의**: 감지할 이벤트가 많을 경우 성능에 영향을 미칠 수 있으므로, 필요 없는 이벤트는 제거하는 것이 좋습니다.
583
+ *
584
+ * @returns `boolean` 값으로 비활성 상태(`true`) 또는 활성 상태(`false`)를 나타냅니다.
585
+ */
586
+ declare const useIdle: (ms?: number, initialState?: boolean, events?: string[]) => boolean;
587
+
588
+ /**
589
+ * 이미지 로드 상태를 감지하고 로드 또는 실패 시 콜백을 호출하는 React 훅입니다.
590
+ *
591
+ * @param img - 감지할 대상 `HTMLImageElement`입니다. `null`이면 훅이 동작하지 않습니다.
592
+ * @param options - 이미지 로드 상태와 관련된 설정 및 콜백 함수들입니다.
593
+ * @param options.keepListening - `true`로 설정하면 이미지의 `src` 속성이 변경될 때마다 이벤트를 감시합니다.
594
+ * `false`로 설정하면 첫 로드 이후 감시를 중단합니다. 기본값은 `false`입니다.
595
+ * @param options.onLoaded - 이미지가 성공적으로 로드되었을 때 호출되는 콜백 함수입니다. `img`를 인수로 받습니다.
596
+ * @param options.onError - 이미지 로드에 실패했을 때 호출되는 선택적 콜백 함수입니다. `img`와 오류 객체를 인수로 받습니다.
597
+ * @param deps - 의존성 배열로, 해당 배열의 값이 변경되면 훅이 다시 실행됩니다. 기본값은 빈 배열입니다.
598
+ *
599
+ * @returns 없음
600
+ *
601
+ * @example
602
+ * ```tsx
603
+ * const imgRef = useRef<HTMLImageElement | null>(null);
604
+ *
605
+ * useImageLoadCallback(imgRef.current, {
606
+ * keepListening: true,
607
+ * onLoaded: (img) => console.log("Image loaded:", img.src),
608
+ * onError: (img, error) => console.error("Image load failed:", img.src, error),
609
+ * });
610
+ *
611
+ * return <img ref={imgRef} src="https://via.placeholder.com/300" alt="Example" />;
612
+ * ```
613
+ *
614
+ * @remarks
615
+ * - 이미지가 이미 로드된 경우 (`img.complete`)에도 콜백이 호출됩니다.
616
+ * - `MutationObserver`를 사용하여 이미지의 `src` 속성 변경을 감지하고 다시 로드 상태를 확인합니다.
617
+ * - `keepListening` 설정에 따라 로드 상태를 지속적으로 감시할 수 있습니다.
618
+ *
619
+ * @dependencies
620
+ * - React: `useEffect`, `useRef`, `useState`
621
+ * - DOM API: `addEventListener`, `removeEventListener`, `MutationObserver`
622
+ */
623
+ declare function useImageLoadCallback(img: HTMLImageElement | null, options: {
624
+ keepListening?: boolean;
625
+ onLoaded: (img: HTMLImageElement) => void;
626
+ onError?: (img: HTMLImageElement, error: unknown) => void;
627
+ }, deps?: react__default.DependencyList): void;
628
+
629
+ /**
630
+ * 파일 업로드의 결과를 나타내는 데이터 구조.
631
+ *
632
+ * 파일 업로드가 성공적으로 완료된 후 반환되는 정보를 정의합니다.
633
+ */
634
+ interface FileUploadResult {
635
+ /**
636
+ * 업로드된 파일의 고유 ID.
637
+ * 서버 또는 데이터베이스에서 파일을 식별하는 데 사용됩니다.
638
+ */
639
+ id: string;
640
+ /**
641
+ * 업로드된 파일의 URL.
642
+ * 업로드된 파일에 접근하거나 다운로드할 수 있는 경로를 제공합니다.
643
+ */
644
+ url: string;
645
+ /**
646
+ * 업로드된 파일의 총 크기(바이트 단위).
647
+ * 선택적 속성으로, 서버가 파일 크기를 반환하지 않는 경우 undefined일 수 있습니다.
648
+ */
649
+ totalBytes?: number;
650
+ /**
651
+ * 업로드된 파일의 이름.
652
+ * 파일의 원래 이름 또는 서버에서 생성한 이름일 수 있습니다.
653
+ */
654
+ fileName?: string;
655
+ /**
656
+ * 업로드된 파일의 MIME 타입.
657
+ * 예: `image/jpeg`, `application/pdf` 등 파일의 유형을 나타냅니다.
658
+ */
659
+ contentType?: string;
660
+ }
661
+ /**
662
+ * React 커스텀 훅으로 이미지를 업로드하고 업로드 상태를 관리합니다.
663
+ *
664
+ * 이 훅은 Blob 파일을 업로드하는 비동기 작업을 처리하며, 업로드 완료 시 결과를 콜백으로 반환합니다.
665
+ * 또한, 업로드 상태(loading)를 관리합니다.
666
+ *
667
+ * @param file - 업로드할 파일(Blob). null 또는 undefined인 경우 업로드를 중단합니다.
668
+ * @param handleFileUpload - 파일 업로드를 처리하는 비동기 함수. Blob 파일을 받아 서버에 업로드하고 업로드 결과를 반환해야 합니다.
669
+ * @param callback - 업로드 완료 또는 실패 시 호출되는 콜백. 업로드 성공 시 결과(`FileUploadResult` 객체)를, 실패 또는 취소 시 null을 전달합니다.
670
+ *
671
+ * @returns 업로드가 진행 중인 상태를 나타내는 boolean 값. `true`면 업로드 중이고, `false`면 업로드가 완료되었거나 중단된 상태입니다.
672
+ *
673
+ * @example
674
+ * ```tsx
675
+ * import { useImageUpload } from './useImageUpload';
676
+ *
677
+ * function FileUploader() {
678
+ * const [file, setFile] = useState<Blob | null>(null);
679
+ * const loading = useImageUpload(
680
+ * file,
681
+ * async (file) => {
682
+ * // 서버에 파일 업로드 로직
683
+ * const response = await uploadFileToServer(file);
684
+ * return {
685
+ * id: response.id,
686
+ * url: response.url,
687
+ * totalBytes: response.size,
688
+ * fileName: response.name,
689
+ * contentType: response.type,
690
+ * };
691
+ * },
692
+ * (result) => {
693
+ * if (result) {
694
+ * console.log('Upload success:', result.url);
695
+ * } else {
696
+ * console.log('Upload canceled or failed');
697
+ * }
698
+ * }
699
+ * );
700
+ *
701
+ * const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
702
+ * const file = event.target.files?.[0];
703
+ * if (file) {
704
+ * setFile(file);
705
+ * }
706
+ * };
707
+ *
708
+ * return (
709
+ * <div>
710
+ * <input type="file" onChange={handleChange} />
711
+ * {loading && <p>Uploading...</p>}
712
+ * </div>
713
+ * );
714
+ * }
715
+ * ```
716
+ */
717
+ declare function useImageUpload(file: Blob | null | undefined, handleFileUpload: (file: Blob) => Promise<FileUploadResult>, callback: (imageUrl: FileUploadResult | null) => void): boolean;
718
+
719
+ interface UseIntervalOptions {
720
+ /** If set, the interval will start automatically when the component is mounted, `false` by default */
721
+ autoInvoke?: boolean;
722
+ }
723
+ /**
724
+ * 특정 작업을 주어진 간격으로 실행할 수 있는 React Hook입니다.
725
+ *
726
+ * @param fn - 주어진 간격마다 호출될 콜백 함수입니다.
727
+ * @param interval - 작업을 실행할 간격(밀리초)입니다.
728
+ * @param options - 옵션 객체입니다.
729
+ * @param options.autoInvoke - 컴포넌트가 마운트될 때 자동으로 interval을 시작할지 여부를 설정합니다. 기본값은 `false`입니다.
730
+ *
731
+ * @returns `{ start, stop, toggle, active }`
732
+ * - `start`: interval을 시작하는 함수입니다.
733
+ * - `stop`: interval을 중지하는 함수입니다.
734
+ * - `toggle`: interval의 상태를 토글(시작/중지)하는 함수입니다.
735
+ * - `active`: interval이 활성화되었는지 여부를 나타내는 boolean 값입니다.
736
+ *
737
+ * @example
738
+ * ```tsx
739
+ * function Counter() {
740
+ * const [count, setCount] = useState(0);
741
+ * const { start, stop, toggle, active } = useInterval(() => {
742
+ * setCount((prev) => prev + 1);
743
+ * }, 1000, { autoInvoke: true });
744
+ *
745
+ * return (
746
+ * <div>
747
+ * <p>Count: {count}</p>
748
+ * <button onClick={start}>Start</button>
749
+ * <button onClick={stop}>Stop</button>
750
+ * <button onClick={toggle}>{active ? 'Pause' : 'Resume'}</button>
751
+ * </div>
752
+ * );
753
+ * }
754
+ * ```
755
+ *
756
+ * @remarks
757
+ * - 이 Hook은 `window.setInterval`을 내부적으로 사용하여 특정 작업을 반복 실행합니다.
758
+ * - `fn`이 변경되면 최신 함수 참조를 유지하며, interval은 자동으로 최신 함수로 업데이트됩니다.
759
+ * - `autoInvoke`가 `true`로 설정되면, 컴포넌트가 마운트될 때 자동으로 interval이 시작됩니다.
760
+ * - 컴포넌트가 언마운트될 때 interval은 자동으로 정리됩니다.
761
+ */
762
+ declare function useInterval(fn: () => void, interval: number, { autoInvoke }?: UseIntervalOptions): {
763
+ start: () => void;
764
+ stop: () => void;
765
+ toggle: () => void;
766
+ active: boolean;
767
+ };
768
+
769
+ /**
770
+ * 브라우저와 서버 환경 모두에서 안전하게 사용할 수 있는 React 효과 훅.
771
+ *
772
+ * - 클라이언트 환경: `useLayoutEffect` 사용 (DOM 업데이트 후 즉시 실행)
773
+ * - 서버 환경: `useEffect` 사용 (SSR 시 경고 방지)
774
+ *
775
+ * @returns React의 `useLayoutEffect` 또는 `useEffect`.
776
+ *
777
+ * @example
778
+ * ```tsx
779
+ * import { useIsomorphicEffect } from './useIsomorphicEffect';
780
+ *
781
+ * const Component = () => {
782
+ * useIsomorphicEffect(() => {
783
+ * console.log('렌더링 완료 후 실행');
784
+ * }, []);
785
+ *
786
+ * return <div>내용</div>;
787
+ * };
788
+ * ```
789
+ */
790
+ declare const useIsomorphicEffect: typeof useEffect;
791
+
792
+ declare function useLatest<T>(value: T): react.RefObject<T>;
793
+
794
+ declare function useLgOrUp(options?: UseMediaQueryOptions): boolean;
795
+
796
+ /**
797
+ * This hook provides a console log when the component mounts, updates and unmounts.
798
+ *
799
+ * @param componentName Provides the name of the component in which the life cycle is being logged
800
+ * @param deps Dependencies list, as for `useEffect` hook
801
+ */
802
+ declare function useLifecycleLogger(componentName: string, deps?: DependencyList): void;
803
+
804
+ /**
805
+ * 로딩 지연 훅
806
+ * 용도: 예를 들어, 100ms내로 작업이 빠르게 완료되는 경우
807
+ * 로딩중 UI를 표시 않는 것이 나을 수 있습니다.
808
+ * 그래서 postponeTime을 통해, 로딩중 UI표시를 지연시킬 시간을
809
+ * 설정합니다.
810
+ *
811
+ * 예시1) postponeTime=100ms이고, 작업시간이 1000ms인 경우
812
+ * 900ms동안만 로딩중 UI가 표시됩니다.
813
+ * 예시2) postponeTime=100ms이고, 작업시간이 150ms인 경우
814
+ * 50ms동안만 로딩중 UI가 표시됩니다.
815
+ *
816
+ * 예시2의 50ms는 너무 짧아서 로딩중 UI가 제대로 표시되지 못할 것입니다.
817
+ * 짧게라도 반드시 로딩중 UI를 반드시 표시하고 싶다면,
818
+ * minVisibleTime을 설정할 수 있습니다.
819
+ *
820
+ * postponeTime=200ms, minVisibleTime=300ms를 설정하였고
821
+ * 작업시간은 400ms라고 가정하면,
822
+ * setLoading(true)를 호출하면, 아래와 같은 타임라인으로 동작합니다.
823
+ * 0ms: setLoading(true) 호출
824
+ * 200ms: 로딩중 UI 표시
825
+ * 400ms: 작업이 완료하여 setLoading(false)를 호출, false지만 로딩중 UI는 표시됨
826
+ * 500ms: 로딩중 UI 감춤
827
+ */
828
+ interface Options$1 {
829
+ minVisibleTime?: number;
830
+ postponeTime?: number;
831
+ }
832
+ declare function useLoadingVisible(paramLoading: boolean, opts?: Options$1): boolean;
833
+
834
+ type parserOptions$1<T> = {
835
+ raw: true;
836
+ } | {
837
+ raw: false;
838
+ serializer: (value: T) => string;
839
+ deserializer: (value: string) => T;
840
+ };
841
+ declare const useLocalStorage: <T>(key: string, initialValue?: T, options?: parserOptions$1<T>) => [T | undefined, Dispatch<SetStateAction<T | undefined>>, () => void];
842
+
843
+ /**
844
+ * A codec that can encode and decode values of type V to and from strings.
845
+ * @typeParam V The type of values that can be encoded and decoded.
846
+ */
847
+ interface Codec<V> {
848
+ /**
849
+ * Decodes a string value into a value of type V.
850
+ * @param value The value to decode.
851
+ * @returns The decoded value.
852
+ */
853
+ parse: (value: string) => V;
854
+ /**
855
+ * Encodes a value of type V into a string.
856
+ * @param value The value to encode.
857
+ * @returns The encoded value.
858
+ */
859
+ stringify: (value: V) => string;
860
+ }
861
+
862
+ type StorageStateInitializer<T> = () => T | null;
863
+ type UseStorageStateHookResult<T> = [
864
+ T | null,
865
+ react.Dispatch<react.SetStateAction<T | null>>
866
+ ];
867
+ interface DefaultStorageStateoptions<T = string> {
868
+ codec?: Codec<T>;
869
+ }
870
+ interface StorageStateOptions<T> extends DefaultStorageStateoptions<T> {
871
+ codec: Codec<T>;
872
+ }
873
+ interface UseStorageState {
874
+ /**
875
+ * Sync state to local or session storage so that it persists through a page refresh. Usage is
876
+ * similar to useState except we pass in a storage key that uniquely identifies the value.
877
+ * @param key The key to use for storing the value in local or session storage.
878
+ * @param initializer The initial value to use if the key is not present in storage.
879
+ * @param options Additional options for the storage state.
880
+ */
881
+ (key: string | null, initializer?: string | null | StorageStateInitializer<string>, options?: DefaultStorageStateoptions): UseStorageStateHookResult<string>;
882
+ /**
883
+ * Sync state to local or session storage so that it persists through a page refresh. Usage is
884
+ * similar to useState except we pass in a storage key that uniquely identifies the value.
885
+ * @param key The key to use for storing the value in local or session storage.
886
+ * @param initializer The initial value to use if the key is not present in storage.
887
+ * @param options Additional options for the storage state.
888
+ */
889
+ <T>(key: string | null, initializer: T | null | StorageStateInitializer<T>, options: StorageStateOptions<T>): UseStorageStateHookResult<T>;
890
+ /**
891
+ * Sync state to local or session storage so that it persists through a page refresh. Usage is
892
+ * similar to useState except we pass in a storage key that uniquely identifies the value.
893
+ * @param key The key to use for storing the value in local or session storage.
894
+ * @param initializer The initial value to use if the key is not present in storage.
895
+ * @param options Additional options for the storage state.
896
+ */
897
+ <T>(key: string | null, initializer?: T | null | StorageStateInitializer<T>, options?: StorageStateOptions<T>): UseStorageStateHookResult<T>;
898
+ }
899
+
900
+ /**
901
+ * @deprecated use useLocalStorage()
902
+ */
903
+ declare const useLocalStorageState: UseStorageState;
904
+
905
+ declare function useMdOrDown(options?: UseMediaQueryOptions): boolean;
906
+
907
+ declare function useMdOrUp(options?: UseMediaQueryOptions): boolean;
908
+
909
+ /**
910
+ * 컴포넌트가 마운트될 때 한 번만 실행되는 로직을 처리하기 위한 커스텀 훅입니다.
911
+ *
912
+ * 이 훅은 `useEffectOnce`를 기반으로 동작하며, 컴포넌트가 마운트될 때 전달된 콜백 함수를 실행합니다.
913
+ * `useEffectOnce`를 직접 사용하는 것보다 `useMount`라는 명확한 이름을 통해 의도를 더 직관적으로 나타냅니다.
914
+ *
915
+ * @param fn - 컴포넌트가 마운트될 때 실행할 콜백 함수. 이 함수는 마운트 시점에 한 번만 호출됩니다.
916
+ *
917
+ * @example
918
+ * ```tsx
919
+ * import React from "react";
920
+ * import { useMount } from "./useMount";
921
+ *
922
+ * function MyComponent() {
923
+ * useMount(() => {
924
+ * console.log("컴포넌트가 마운트되었습니다.");
925
+ * });
926
+ *
927
+ * return <div>My Component</div>;
928
+ * }
929
+ * ```
930
+ * @returns 없음. 이 훅은 단지 전달된 콜백 함수를 실행하며 반환값은 없습니다.
931
+ */
932
+ declare const useMount: (fn: () => void) => void;
933
+
934
+ /**
935
+ * 컴포넌트가 마운트되었는지 여부를 반환하는 React 훅입니다.
936
+ *
937
+ * SSR 환경에서 서버 렌더링 시에는 `false`를 반환하고,
938
+ * 클라이언트에서 마운트된 후에는 `true`를 반환합니다.
939
+ *
940
+ * @returns 컴포넌트가 마운트되었으면 `true`, 아니면 `false`
941
+ *
942
+ * @example
943
+ * ```tsx
944
+ * function MyComponent() {
945
+ * const mounted = useMounted();
946
+ *
947
+ * // 클라이언트 전용 렌더링
948
+ * if (!mounted) return null;
949
+ *
950
+ * return <div>Client-side only content</div>;
951
+ * }
952
+ * ```
953
+ */
954
+ declare function useMounted(): boolean;
955
+
956
+ /**
957
+ * 컴포넌트가 마운트 상태인지 여부를 반환하는 커스텀 훅입니다.
958
+ *
959
+ * 이 훅은 컴포넌트의 현재 마운트 상태를 안전하게 확인하기 위해 사용됩니다.
960
+ * 비동기 작업이나 이벤트 핸들러 내에서 컴포넌트가 마운트된 상태인지 확인할 때 유용합니다.
961
+ *
962
+ * @returns `() => boolean` 함수를 반환하며, 호출 시 컴포넌트가 현재 마운트 상태인지(`true` 또는 `false`)를 반환합니다.
963
+ *
964
+ * @example
965
+ * ```tsx
966
+ * import React, { useState, useEffect } from 'react';
967
+ * import useMountedState from './useMountedState';
968
+ *
969
+ * function MyComponent() {
970
+ * const isMounted = useMountedState();
971
+ * const [data, setData] = useState<string | null>(null);
972
+ *
973
+ * useEffect(() => {
974
+ * setTimeout(() => {
975
+ * if (isMounted()) {
976
+ * setData('데이터가 성공적으로 로드되었습니다.');
977
+ * }
978
+ * }, 3000);
979
+ * }, [isMounted]);
980
+ *
981
+ * return <div>{data || '로딩 중...'}</div>;
982
+ * }
983
+ * ```
984
+ *
985
+ * @internalDetails
986
+ * - `mountedRef`는 컴포넌트의 마운트 상태를 저장합니다.
987
+ * - `useEffect`는 컴포넌트가 마운트되면 `true`, 언마운트되면 `false`로 설정합니다.
988
+ * - `useCallback`을 사용하여 `get` 함수가 항상 동일한 참조를 가지도록 보장합니다.
989
+ */
990
+ declare function useMountedState(): () => boolean;
991
+
992
+ /**
993
+ * DOM의 변화를 감지하고 콜백을 실행하는 React 훅
994
+ *
995
+ * @template T - 감시 대상 HTMLElement의 타입 (기본값은 `any`)
996
+ * @param callback - DOM 변경을 감지했을 때 호출되는 MutationCallback
997
+ * @param options - MutationObserver를 초기화할 때 사용하는 옵션 (MutationObserverInit 객체)
998
+ * @param target - 감시할 대상 요소 또는 해당 요소를 반환하는 함수 (선택적, 기본값은 `ref`를 사용)
999
+ * @returns `ref` - DOM 요소에 바인딩할 수 있는 React Ref 객체
1000
+ *
1001
+ * @example
1002
+ * ```tsx
1003
+ * const App = () => {
1004
+ * const callback = (mutations: MutationRecord[]) => {
1005
+ * mutations.forEach(mutation => {
1006
+ * console.log(mutation);
1007
+ * });
1008
+ * };
1009
+ *
1010
+ * const ref = useMutationObserver<HTMLDivElement>(callback, { childList: true });
1011
+ *
1012
+ * return <div ref={ref}>감시 대상 요소</div>;
1013
+ * };
1014
+ * ```
1015
+ */
1016
+ declare function useMutationObserver<T extends HTMLElement = HTMLElement>(callback: MutationCallback, options: MutationObserverInit, target?: HTMLElement | (() => HTMLElement) | null): React.RefObject<T | null>;
1017
+
1018
+ declare function useObservable<T>(observable: null | undefined | Observable<T> | (() => Observable<T>)): T | undefined;
1019
+ declare function useObservable<T>(observable: null | undefined | Observable<T> | (() => Observable<T>), initialValue: T): T;
1020
+
1021
+ type SetStateFn$1<T> = (value: T | undefined) => void;
1022
+ type GetFn$1<T> = () => T;
1023
+ declare function useObservableLocalStorage<T>(key: string, initialValue: T | GetFn$1<T>): [T, SetStateFn$1<T | null>];
1024
+
1025
+ type SetStateFn<T> = (value: T | undefined) => void;
1026
+ type GetFn<T> = () => T;
1027
+ declare function useObservableSessionStorage<T>(key: string, initialValue: T | GetFn<T>): [T, SetStateFn<T | null>];
1028
+
1029
+ type OS = 'undetermined' | 'macos' | 'ios' | 'windows' | 'android' | 'linux';
1030
+ interface UseOsOptions {
1031
+ getValueInEffect: boolean;
1032
+ }
1033
+ declare function useOs(options?: UseOsOptions): OS;
1034
+
1035
+ declare const useRafState: <S>(initialState: S | (() => S)) => [S, Dispatch<SetStateAction<S>>];
1036
+
1037
+ type ObserverRect = Omit<DOMRectReadOnly, 'toJSON'>;
1038
+ /**
1039
+ * 요소에 대한 `ref`를 제공하고 크기 조정(resize) 이벤트를 관찰하는 커스텀 React 훅.
1040
+ * 이 훅은 요소의 크기와 위치(DOMRect)를 반환합니다.
1041
+ *
1042
+ * @template T - 관찰할 HTML 요소의 타입. 기본값은 `HTMLElement`입니다.
1043
+ * @param options - 관찰을 설정하기 위한 선택적인 `ResizeObserverOptions` 객체.
1044
+ * @returns 튜플 형태의 반환값:
1045
+ * - `ref`: 관찰할 요소에 연결하기 위한 React 참조 객체.
1046
+ * - `rect`: 관찰된 요소의 DOMRect 속성(크기와 위치).
1047
+ *
1048
+ * @example
1049
+ * ```tsx
1050
+ * const [ref, rect] = useResizeObserver();
1051
+ *
1052
+ * return (
1053
+ * <div ref={ref} style={{ resize: "both", overflow: "auto" }}>
1054
+ * Width: {rect.width}, Height: {rect.height}
1055
+ * </div>
1056
+ * );
1057
+ * ```
1058
+ */
1059
+ declare function useResizeObserver<T extends HTMLElement = HTMLElement>(options?: ResizeObserverOptions): readonly [react.RefObject<T | null>, ObserverRect];
1060
+
1061
+ type LoadingState = 'unknown' | 'loading' | 'ready' | 'error';
1062
+ declare function useScript(src: string, options?: {
1063
+ removeOnUnmount?: boolean;
1064
+ }): LoadingState;
1065
+
1066
+ type parserOptions<T> = {
1067
+ raw: true;
1068
+ } | {
1069
+ raw: false;
1070
+ serializer: (value: T) => string;
1071
+ deserializer: (value: string) => T;
1072
+ };
1073
+ /**
1074
+ * Persist state in sessionStorage.
1075
+ *
1076
+ * Returns `[value, setValue, removeValue]`.
1077
+ * - `setValue(next)` writes to sessionStorage and updates state.
1078
+ * - `removeValue()` removes the key from sessionStorage and resets state to `undefined`.
1079
+ *
1080
+ * On SSR/non-browser environments the hook returns `initialValue` and the setter/remove are no-ops.
1081
+ */
1082
+ declare const useSessionStorage: <T>(key: string, initialValue?: T, options?: parserOptions<T>) => [T | undefined, Dispatch<SetStateAction<T | undefined>>, () => void];
1083
+
1084
+ /**
1085
+ * @deprecated use useSessionStorage()
1086
+ */
1087
+ declare const useSessionStorageState: UseStorageState;
1088
+
1089
+ declare function useSmOrDown(options?: UseMediaQueryOptions): boolean;
1090
+
1091
+ declare function useSmOrUp(options?: UseMediaQueryOptions): boolean;
1092
+
1093
+ /**
1094
+ * 주어진 콜백 함수를 지정된 시간 간격(`wait`)으로 호출하도록 제한하는 간단한 쓰로틀링 React 훅.
1095
+ *
1096
+ * 내부적으로 `useThrottledCallbackWithClearTimeout`을 사용하며, 타이머 정리 기능 없이 쓰로틀링된 콜백 함수만 반환합니다.
1097
+ *
1098
+ * @template T - 콜백 함수의 타입.
1099
+ * @param callback - 쓰로틀링할 콜백 함수.
1100
+ * @param wait - 호출 간격(밀리초 단위).
1101
+ * @returns 쓰로틀링된 콜백 함수.
1102
+ *
1103
+ * @example
1104
+ * ```tsx
1105
+ * const throttledClick = useThrottledCallback(() => {
1106
+ * console.log("클릭!");
1107
+ * }, 1000);
1108
+ *
1109
+ * return <button onClick={throttledClick}>클릭</button>;
1110
+ * ```
1111
+ */
1112
+ declare function useThrottledCallback<T extends (...args: any[]) => any>(callback: T, // 쓰로틀링할 콜백 함수
1113
+ wait: number): (...args: Parameters<T>) => void;
1114
+
1115
+ /**
1116
+ * 주어진 콜백 함수를 지정된 시간 간격(`wait`)으로 호출하는 커스텀 React 훅.
1117
+ *
1118
+ * 이 훅은 마지막 호출 이후 일정 시간이 지나야 콜백이 다시 호출되도록 제한합니다(Throttle).
1119
+ * 또한 타이머를 수동으로 정리할 수 있는 기능을 제공합니다.
1120
+ *
1121
+ * @template T - 콜백 함수의 타입.
1122
+ * @param callback - 쓰로틀링할 콜백 함수.
1123
+ * @param wait - 호출 간격(밀리초 단위).
1124
+ * @returns 배열 형태의 반환값:
1125
+ * - `throttled`: 쓰로틀링된 콜백 함수.
1126
+ * - `clearTimeout`: 현재 실행 중인 타이머를 취소하는 함수.
1127
+ *
1128
+ * @example
1129
+ * ```tsx
1130
+ * const [throttledClick, clearThrottle] = useThrottledCallbackWithClearTimeout(() => {
1131
+ * console.log("클릭!");
1132
+ * }, 1000);
1133
+ *
1134
+ * return (
1135
+ * <button onClick={throttledClick}>클릭</button>
1136
+ * <button onClick={clearThrottle}>쓰로틀링 취소</button>
1137
+ * );
1138
+ * ```
1139
+ */
1140
+ declare function useThrottledCallbackWithClearTimeout<T extends (...args: any[]) => any>(callback: T, // 쓰로틀링할 콜백 함수
1141
+ wait: number): readonly [(...args: Parameters<T>) => void, () => void];
1142
+
1143
+ /**
1144
+ * 쓰로틀링된 상태(state)와 상태를 업데이트하는 함수를 제공하는 React 커스텀 훅.
1145
+ *
1146
+ * 이 훅은 상태 업데이트를 지정된 시간 간격(`wait`)으로 제한하여, 불필요한 연속 업데이트를 방지합니다.
1147
+ *
1148
+ * @template T - 상태 값의 타입. 기본값은 `any`.
1149
+ * @param defaultValue - 초기 상태 값.
1150
+ * @param wait - 상태 업데이트 간격(밀리초 단위).
1151
+ * @returns 배열 형태의 반환값:
1152
+ * - `value`: 현재 상태 값.
1153
+ * - `setThrottledValue`: 상태를 쓰로틀링하여 업데이트하는 함수.
1154
+ *
1155
+ * @example
1156
+ * ```tsx
1157
+ * const [value, setValue] = useThrottledState(0, 1000);
1158
+ *
1159
+ * const handleClick = () => setValue(value + 1);
1160
+ *
1161
+ * return (
1162
+ * <div>
1163
+ * <p>값: {value}</p>
1164
+ * <button onClick={handleClick}>값 증가</button>
1165
+ * </div>
1166
+ * );
1167
+ * ```
1168
+ */
1169
+ declare function useThrottledState<T>(defaultValue: T, // 초기 상태 값
1170
+ wait: number): readonly [T, (value: react.SetStateAction<T>) => void];
1171
+
1172
+ /**
1173
+ * 주어진 값을 쓰로틀링하여 지정된 시간 간격(`wait`) 후에 최신 값을 반환하는 커스텀 React 훅.
1174
+ *
1175
+ * 이 훅은 입력 값(`value`)이 변경될 때마다, 지정된 `wait` 시간 간격으로 업데이트된 값을 제공합니다.
1176
+ *
1177
+ * @template T - 쓰로틀링할 값의 타입.
1178
+ * @param value - 쓰로틀링할 값.
1179
+ * @param wait - 값 업데이트 간격(밀리초 단위).
1180
+ * @returns 쓰로틀링된 값을 반환.
1181
+ *
1182
+ * @example
1183
+ * ```tsx
1184
+ * const throttledValue = useThrottledValue(inputValue, 500);
1185
+ *
1186
+ * return <p>쓰로틀링된 값: {throttledValue}</p>;
1187
+ * ```
1188
+ */
1189
+ declare function useThrottledValue<T>(value: T, wait: number): T;
1190
+
1191
+ /**
1192
+ * 특정 작업을 일정 시간 후 실행할 수 있는 타이머 훅
1193
+ *
1194
+ * 이 훅은 `setTimeout`과 `clearTimeout`을 관리하는 기능을 캡슐화하여, 타이머를 쉽게 시작하거나 정리할 수 있게 합니다.
1195
+ * 옵션에 따라 자동 실행(`autoInvoke`)도 지원합니다.
1196
+ *
1197
+ * @param callback - 지연 시간이 지난 후 실행할 함수.
1198
+ * @param delay - 타이머 지연 시간(밀리초).
1199
+ * @param options - 타이머 동작 방식을 설정하는 옵션 객체. 기본값은 `{ autoInvoke: false }`.
1200
+ * - `autoInvoke`: `true`일 경우, 컴포넌트가 마운트될 때 타이머가 자동으로 시작됩니다.
1201
+ *
1202
+ * @returns 객체 형태의 반환값:
1203
+ * - `start`: 타이머를 시작하는 함수.
1204
+ * - `clear`: 타이머를 취소하는 함수.
1205
+ *
1206
+ * @example
1207
+ * ```tsx
1208
+ * const { start, clear } = useTimeout(() => {
1209
+ * console.log("5초 후 실행");
1210
+ * }, 5000, { autoInvoke: true });
1211
+ *
1212
+ * return (
1213
+ * <button onClick={start}>타이머 시작</button>
1214
+ * <button onClick={clear}>타이머 정리</button>
1215
+ * );
1216
+ * ```
1217
+ */
1218
+ declare function useTimeout(callback: (...callbackParams: unknown[]) => void, // 지연 시간이 지난 후 실행할 함수
1219
+ delay: number, // 타이머 지연 시간 (밀리초)
1220
+ options?: {
1221
+ autoInvoke: boolean;
1222
+ }): {
1223
+ start: (...callbackParams: unknown[]) => void;
1224
+ clear: () => void;
1225
+ };
1226
+
1227
+ /**
1228
+ * 시간이 지나면 자동으로 사라지는 데이터
1229
+ */
1230
+ declare function useTimeoutData<T>(timeoutMs: number): [T | null, (t: T | null) => void];
1231
+
1232
+ interface UseUncontrolledInput<T> {
1233
+ /**
1234
+ * 제어 상태 값 (controlled state).
1235
+ * 값이 전달되면 해당 값이 항상 반환됩니다.
1236
+ */
1237
+ value?: T;
1238
+ /**
1239
+ * 비제어 상태의 초기 값 (uncontrolled state).
1240
+ * `value`가 제공되지 않았을 때 사용됩니다.
1241
+ */
1242
+ defaultValue?: T;
1243
+ /**
1244
+ * `value`와 `defaultValue`가 모두 제공되지 않을 때 사용되는 최종 기본 값.
1245
+ */
1246
+ finalValue?: T;
1247
+ /**
1248
+ * 제어 상태 변화 시 호출되는 콜백 함수.
1249
+ *
1250
+ * @param value - 변경된 값
1251
+ * @param payload - 추가 데이터
1252
+ */
1253
+ onChange?: (value: T, ...payload: unknown[]) => void;
1254
+ }
1255
+ /**
1256
+ * 제어 상태와 비제어 상태를 동시에 지원하는 React 훅.
1257
+ *
1258
+ * 이 훅은 컴포넌트가 "제어 상태(controlled state)"와
1259
+ * "비제어 상태(uncontrolled state)"를 쉽게 다룰 수 있도록 설계되었습니다.
1260
+ *
1261
+ * @template T - 상태 값의 타입
1262
+ * @param params - 제어 상태와 비제어 상태를 관리하기 위한 입력 값
1263
+ * @returns [현재 상태 값, 상태를 업데이트하는 함수, 제어 상태 여부]
1264
+ *
1265
+ * @example
1266
+ * ```tsx
1267
+ * const [value, setValue, isControlled] = useUncontrolled({
1268
+ * value: controlledValue, // 제어 상태 값
1269
+ * defaultValue: 10, // 초기 값
1270
+ * finalValue: 0, // 최종 기본 값
1271
+ * onChange: (val) => console.log(val), // 변경 시 콜백
1272
+ * });
1273
+ * ```
1274
+ */
1275
+ declare function useUncontrolled<T>({ value, defaultValue, finalValue, onChange, }: UseUncontrolledInput<T>): [T, (value: T, ...payload: unknown[]) => void, boolean];
1276
+
1277
+ declare const useUnmount: (fn: () => void) => void;
1278
+
1279
+ declare const useUpdate: () => () => void;
1280
+
1281
+ declare const useUpdateEffect: (effect: EffectCallback, deps?: DependencyList) => void;
1282
+
1283
+ declare const useUpdateLayoutEffect: (effect: EffectCallback, deps?: DependencyList) => void;
1284
+
1285
+ /**
1286
+ * 지정된 타입의 윈도우 이벤트를 등록하고 관리하는 React 커스텀 훅.
1287
+ *
1288
+ * @template K - 이벤트 타입을 나타내는 문자열 타입.
1289
+ * @param type - 등록할 윈도우 이벤트의 타입(예: "resize", "click").
1290
+ * @param listener - 이벤트가 발생했을 때 실행될 콜백 함수.
1291
+ * - 표준 이벤트 타입(`WindowEventMap`)의 경우 타입에 맞는 이벤트 객체를 전달받음.
1292
+ * - 사용자 정의 이벤트의 경우 `CustomEvent` 객체를 전달받음.
1293
+ * @param options - 이벤트 리스너 등록 시 사용할 옵션(선택 사항).
1294
+ * - `boolean` 또는 `AddEventListenerOptions`를 지원.
1295
+ *
1296
+ * @example
1297
+ * ```tsx
1298
+ * useWindowEvent("resize", () => {
1299
+ * console.log("창 크기가 변경되었습니다.");
1300
+ * });
1301
+ * ```
1302
+ */
1303
+ declare function useWindowEvent<K extends string>(type: K, // 등록할 윈도우 이벤트의 타입
1304
+ listener: K extends keyof WindowEventMap ? (this: Window, ev: WindowEventMap[K]) => void : (this: Window, ev: CustomEvent) => void, // 사용자 정의 이벤트 리스너
1305
+ options?: boolean | AddEventListenerOptions): void;
1306
+
1307
+ interface Options {
1308
+ initialWidth?: number;
1309
+ initialHeight?: number;
1310
+ onChange?: (width: number, height: number) => void;
1311
+ }
1312
+ declare const useWindowSize: ({ initialWidth, initialHeight, onChange, }?: Options) => {
1313
+ width: number;
1314
+ height: number;
1315
+ };
1316
+
1317
+ declare function useXsOrDown(options?: UseMediaQueryOptions): boolean;
1318
+
1319
+ export { type FileUploadResult, type OS, composeRefs, useAbsolutePosition, useAudioUnlocked, useBehaviorSubject, useCallbackRef, useCenterInView, useClipboard, useClosableEffect, useComposedRefs, useConstant, useCustomCompareEffect, useCustomCompareMemo, useDebounceEffect, useDebounceFn, useDebouncedCallback, useDebouncedState, useDebouncedValue, useDeepCompareEffect, useDeepCompareMemo, useDidUpdate, useEffectOnce, useElementSize, useEventListener, useId, useIdle, useImageLoadCallback, useImageUpload, useInterval, useIsomorphicEffect, useLatest, useLgOrUp, useLifecycleLogger, useLoadingVisible, useLocalStorage, useLocalStorageState, useMdOrDown, useMdOrUp, useMount, useMounted, useMountedState, useMutationObserver, useObservable, useObservableLocalStorage, useObservableSessionStorage, useOs, useRafState, useResizeObserver, useScript, useSessionStorage, useSessionStorageState, useSmOrDown, useSmOrUp, useThrottledCallback, useThrottledCallbackWithClearTimeout, useThrottledState, useThrottledValue, useTimeout, useTimeoutData, useUncontrolled, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWindowEvent, useWindowSize, useXsOrDown };