@cp949/mui-react19 2.2.0 → 2.3.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.
- package/dist/components/CopyButtonWrapper.cjs +1 -1
- package/dist/components/CopyButtonWrapper.cjs.map +1 -1
- package/dist/components/CopyButtonWrapper.d.cts +24 -5
- package/dist/components/CopyButtonWrapper.d.ts +24 -5
- package/dist/components/CopyButtonWrapper.js +1 -1
- package/dist/components/CopyButtonWrapper.js.map +1 -1
- package/dist/components/FileButton.d.cts +1 -0
- package/dist/components/FileButton.d.ts +1 -0
- package/dist/components/LengthLimitHelperText.d.cts +1 -0
- package/dist/components/LengthLimitHelperText.d.ts +1 -0
- package/dist/components/flex/FlexColumn.d.cts +1 -0
- package/dist/components/flex/FlexColumn.d.ts +1 -0
- package/dist/components/flex/FlexRow.d.cts +1 -0
- package/dist/components/flex/FlexRow.d.ts +1 -0
- package/dist/components/stack/StackColumn.d.cts +1 -0
- package/dist/components/stack/StackColumn.d.ts +1 -0
- package/dist/components/stack/StackRow.d.cts +1 -0
- package/dist/components/stack/StackRow.d.ts +1 -0
- package/dist/hooks/index.d.cts +2 -2
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/useBehaviorSubject.d.cts +1 -0
- package/dist/hooks/useBehaviorSubject.d.ts +1 -0
- package/dist/hooks/useClipboard.cjs +1 -1
- package/dist/hooks/useClipboard.cjs.map +1 -1
- package/dist/hooks/useClipboard.d.cts +31 -8
- package/dist/hooks/useClipboard.d.ts +31 -8
- package/dist/hooks/useClipboard.js +1 -1
- package/dist/hooks/useClipboard.js.map +1 -1
- package/dist/hooks/useClosableEffect.d.cts +1 -0
- package/dist/hooks/useClosableEffect.d.ts +1 -0
- package/dist/hooks/useCustomCompareEffect.d.cts +1 -0
- package/dist/hooks/useCustomCompareEffect.d.ts +1 -0
- package/dist/hooks/useDebounceEffect.d.cts +1 -0
- package/dist/hooks/useDebounceEffect.d.ts +1 -0
- package/dist/hooks/useDebounceFn.d.cts +1 -0
- package/dist/hooks/useDebounceFn.d.ts +1 -0
- package/dist/hooks/useDebouncedCallback.d.cts +1 -0
- package/dist/hooks/useDebouncedCallback.d.ts +1 -0
- package/dist/hooks/useDebouncedState.d.cts +5 -5
- package/dist/hooks/useDebouncedState.d.ts +5 -5
- package/dist/hooks/useInterval.d.cts +1 -0
- package/dist/hooks/useInterval.d.ts +1 -0
- package/dist/hooks/useLoadingVisible.d.cts +1 -0
- package/dist/hooks/useLoadingVisible.d.ts +1 -0
- package/dist/hooks/useLocalStorage.d.cts +1 -0
- package/dist/hooks/useLocalStorage.d.ts +1 -0
- package/dist/hooks/useObservableLocalStorage.d.cts +1 -0
- package/dist/hooks/useObservableLocalStorage.d.ts +1 -0
- package/dist/hooks/useObservableSessionStorage.d.cts +1 -0
- package/dist/hooks/useObservableSessionStorage.d.ts +1 -0
- package/dist/hooks/useOs.d.cts +1 -0
- package/dist/hooks/useOs.d.ts +1 -0
- package/dist/hooks/useResizeObserver.d.cts +1 -0
- package/dist/hooks/useResizeObserver.d.ts +1 -0
- package/dist/hooks/useScript.d.cts +1 -0
- package/dist/hooks/useScript.d.ts +1 -0
- package/dist/hooks/useSessionStorage.d.cts +1 -0
- package/dist/hooks/useSessionStorage.d.ts +1 -0
- package/dist/hooks/useThrottledCallback.d.cts +2 -2
- package/dist/hooks/useThrottledCallback.d.ts +2 -2
- package/dist/hooks/useThrottledCallbackWithClearTimeout.d.cts +2 -2
- package/dist/hooks/useThrottledCallbackWithClearTimeout.d.ts +2 -2
- package/dist/hooks/useThrottledState.d.cts +2 -2
- package/dist/hooks/useThrottledState.d.ts +2 -2
- package/dist/hooks/useTimeout.d.cts +5 -5
- package/dist/hooks/useTimeout.d.ts +5 -5
- package/dist/hooks/useUncontrolled.d.cts +1 -0
- package/dist/hooks/useUncontrolled.d.ts +1 -0
- package/dist/hooks/useWindowEvent.d.cts +3 -3
- package/dist/hooks/useWindowEvent.d.ts +3 -3
- package/dist/hooks/useWindowSize.d.cts +1 -0
- package/dist/hooks/useWindowSize.d.ts +1 -0
- package/dist/util/closables.d.cts +1 -0
- package/dist/util/closables.d.ts +1 -0
- package/llm.txt +3 -2
- package/package.json +8 -8
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../hooks/useClipboard.cjs");let t=require("react/jsx-runtime");function n(n){let{children:r,onCopySuccess:i,
|
|
1
|
+
"use client";const e=require("../hooks/useClipboard.cjs");let t=require("react/jsx-runtime");function n(n){let{children:r,onCopySuccess:i,onCopyFailed:a,value:o,timeout:s=1e3}=n,c=e.useClipboard({timeout:s,onError:a});return/* @__PURE__ */ (0,t.jsx)(t.Fragment,{children:r({copy:()=>{let e;try{e=typeof o==`function`?o():o}catch(e){let t=e instanceof Error?e:Error(String(e));c.fail(t),a?.(t,void 0);return}typeof e==`string`&&e.length>0&&c.copy(e).then(t=>{t&&i?.(e)})},copied:c.copied,failed:c.failed})})}exports.CopyButtonWrapper=n;
|
|
2
2
|
//# sourceMappingURL=CopyButtonWrapper.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyButtonWrapper.cjs","names":["useClipboard","require_useClipboard","react_jsx_runtime","CopyButtonWrapper","props","clipboard","children","v","value","copied","onCopySuccess"],"sources":["../../src/components/CopyButtonWrapper.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport { useClipboard } from '../hooks/useClipboard.js';\n\nexport interface CopyButtonWrapperProps {\n /**\n * 자식 컴포넌트 렌더링을 위한 콜백 함수입니다.\n * 현재 복사 상태(`copied`)와 복사 함수(`copy`)를 인자로 제공합니다.\n *\n * @param payload - 현재 상태 및 복사 함수\n * @param payload.copied - 복사
|
|
1
|
+
{"version":3,"file":"CopyButtonWrapper.cjs","names":["useClipboard","require_useClipboard","react_jsx_runtime","CopyButtonWrapper","props","clipboard","onCopyFailed","children","v","value","err","error","copied","onCopySuccess"],"sources":["../../src/components/CopyButtonWrapper.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport { useClipboard } from '../hooks/useClipboard.js';\n\nexport interface CopyButtonWrapperProps {\n /**\n * 자식 컴포넌트 렌더링을 위한 콜백 함수입니다.\n * 현재 복사 상태(`copied`, `failed`)와 복사 함수(`copy`)를 인자로 제공합니다.\n *\n * @param payload - 현재 상태 및 복사 함수\n * @param payload.copied - 가장 최근 복사 시도가 성공했는지 나타내는 상태\n * @param payload.failed - 가장 최근 복사 시도가 실패했는지 나타내는 상태. `copied`와 동시에 켜지지 않습니다.\n * @param payload.copy - 값을 클립보드에 복사하는 함수\n *\n * @example\n * ```tsx\n * <CopyButtonWrapper value=\"복사할 텍스트\">\n * {({ copy, copied, failed }) => (\n * <button onClick={copy}>\n * {failed ? \"복사 실패\" : copied ? \"복사 완료!\" : \"복사하기\"}\n * </button>\n * )}\n * </CopyButtonWrapper>\n * ```\n */\n children: (payload: { copied: boolean; failed: boolean; copy: () => void }) => ReactNode;\n\n /**\n * 버튼 클릭 시 클립보드에 복사될 값입니다.\n * 문자열 또는 문자열을 반환하는 함수 형태를 지원합니다.\n *\n * @example\n * ```tsx\n * <CopyButtonWrapper value=\"복사할 텍스트\">\n * ...\n * </CopyButtonWrapper>\n *\n * <CopyButtonWrapper value={() => dynamicValue()}>\n * ...\n * </CopyButtonWrapper>\n * ```\n */\n value: string | null | undefined | (() => string | null | undefined);\n\n /**\n * 복사 성공(`copied`), 실패(`failed`) 상태가 유지되는 시간(밀리초)입니다. 기본값은 `1000`ms입니다.\n *\n * @default 1000\n */\n timeout?: number;\n\n /**\n * 클립보드 복사가 성공했을 때 호출되는 콜백 함수입니다.\n *\n * @param value - 클립보드에 복사된 문자열\n */\n onCopySuccess?: (value: string) => void;\n\n /**\n * 클립보드 복사가 실패했을 때 호출되는 콜백 함수입니다.\n * `navigator.clipboard`를 쓸 수 없거나 `writeText`가 실패한 경우, `value` 함수가 예외를 던진 경우에 호출됩니다.\n * `value`가 비어 있어 복사를 건너뛴 경우는 실패로 보지 않으며 호출하지 않습니다.\n * 연속으로 복사하면 시도마다 자기 `value`로 호출됩니다.\n *\n * @param error - 실패 원인\n * @param value - 복사하려던 문자열. `value` 함수가 예외를 던진 경우에는 `undefined`입니다.\n *\n * @example\n * ```tsx\n * <CopyButtonWrapper value=\"복사할 텍스트\" onCopyFailed={(error) => showToast(error.message)}>\n * ...\n * </CopyButtonWrapper>\n * ```\n */\n onCopyFailed?: (error: Error, value: string | undefined) => void;\n}\n\n/**\n * 클립보드 복사 버튼을 쉽게 구현하기 위한 래퍼 컴포넌트입니다.\n *\n * @param props - `CopyButtonWrapper`의 속성\n * @returns 자식 콜백 함수로 전달된 UI 요소를 렌더링합니다.\n *\n * @example\n * ```tsx\n * <CopyButtonWrapper value=\"복사할 텍스트\" timeout={2000}>\n * {({ copy, copied }) => (\n * <button onClick={copy}>\n * {copied ? \"복사되었습니다!\" : \"복사\"}\n * </button>\n * )}\n * </CopyButtonWrapper>\n * ```\n */\nexport function CopyButtonWrapper(props: CopyButtonWrapperProps) {\n const { children, onCopySuccess, onCopyFailed, value, timeout = 1000 } = props;\n const clipboard = useClipboard({ timeout, onError: onCopyFailed });\n\n // 클립보드에 값을 복사합니다. `value`가 함수인 경우 값을 동적으로 평가합니다.\n const copy = () => {\n let v: string | null | undefined;\n try {\n v = typeof value === 'function' ? value() : value;\n } catch (err) {\n // 복사할 값을 만들지 못한 경우도 실패 상태로 기록한다. 클립보드는 호출하지 않는다.\n const error = err instanceof Error ? err : new Error(String(err));\n clipboard.fail(error);\n onCopyFailed?.(error, undefined);\n return;\n }\n if (typeof v === 'string' && v.length > 0) {\n void clipboard.copy(v).then((copied) => {\n if (copied) {\n onCopySuccess?.(v);\n }\n });\n }\n };\n\n return <>{children({ copy, copied: clipboard.copied, failed: clipboard.failed })}</>;\n}\n"],"mappings":"6FA+FA,SAAgBG,EAAkB,EAA+B,CAC/D,GAAM,CAAE,WAAU,gBAAe,eAAc,QAAO,UAAU,KAASC,EACnEC,EAAYL,EAAAA,aAAa,CAAE,UAAS,QAASM,CAAa,CAAC,EAuBjE,MAAO,iBAAA,EAAAJ,EAAA,IAAA,CAAAA,EAAA,SAAA,CAAA,SAAGK,EAAS,CAAE,SApBF,CACjB,IAAIC,EACJ,GAAI,CACF,EAAI,OAAOC,GAAU,WAAaA,EAAM,EAAIA,CAC9C,OAASC,EAAK,CAEZ,IAAMC,EAAQD,aAAe,MAAQA,EAAU,MAAM,OAAOA,CAAG,CAAC,EAChEL,EAAU,KAAKM,CAAK,EACpBL,IAAeK,EAAO,IAAA,EAAS,EAC/B,MACF,CACI,OAAOH,GAAM,UAAYA,EAAE,OAAS,GACtCH,EAAe,KAAKG,CAAC,CAAC,CAAC,KAAM,GAAW,CAClCI,GACFC,IAAgBL,CAAC,CAErB,CAAC,CAEL,EAE2B,OAAQH,EAAU,OAAQ,OAAQA,EAAU,MAAO,CAAC,CAAI,CAAA,CACrF"}
|
|
@@ -3,18 +3,19 @@ import { ReactNode } from "react";
|
|
|
3
3
|
export interface CopyButtonWrapperProps {
|
|
4
4
|
/**
|
|
5
5
|
* 자식 컴포넌트 렌더링을 위한 콜백 함수입니다.
|
|
6
|
-
* 현재 복사 상태(`copied`)와 복사 함수(`copy`)를 인자로 제공합니다.
|
|
6
|
+
* 현재 복사 상태(`copied`, `failed`)와 복사 함수(`copy`)를 인자로 제공합니다.
|
|
7
7
|
*
|
|
8
8
|
* @param payload - 현재 상태 및 복사 함수
|
|
9
|
-
* @param payload.copied - 복사
|
|
9
|
+
* @param payload.copied - 가장 최근 복사 시도가 성공했는지 나타내는 상태
|
|
10
|
+
* @param payload.failed - 가장 최근 복사 시도가 실패했는지 나타내는 상태. `copied`와 동시에 켜지지 않습니다.
|
|
10
11
|
* @param payload.copy - 값을 클립보드에 복사하는 함수
|
|
11
12
|
*
|
|
12
13
|
* @example
|
|
13
14
|
* ```tsx
|
|
14
15
|
* <CopyButtonWrapper value="복사할 텍스트">
|
|
15
|
-
* {({ copy, copied }) => (
|
|
16
|
+
* {({ copy, copied, failed }) => (
|
|
16
17
|
* <button onClick={copy}>
|
|
17
|
-
* {copied ? "복사 완료!" : "복사하기"}
|
|
18
|
+
* {failed ? "복사 실패" : copied ? "복사 완료!" : "복사하기"}
|
|
18
19
|
* </button>
|
|
19
20
|
* )}
|
|
20
21
|
* </CopyButtonWrapper>
|
|
@@ -22,6 +23,7 @@ export interface CopyButtonWrapperProps {
|
|
|
22
23
|
*/
|
|
23
24
|
children: (payload: {
|
|
24
25
|
copied: boolean;
|
|
26
|
+
failed: boolean;
|
|
25
27
|
copy: () => void;
|
|
26
28
|
}) => ReactNode;
|
|
27
29
|
/**
|
|
@@ -41,7 +43,7 @@ export interface CopyButtonWrapperProps {
|
|
|
41
43
|
*/
|
|
42
44
|
value: string | null | undefined | (() => string | null | undefined);
|
|
43
45
|
/**
|
|
44
|
-
* 복사 성공 상태가 유지되는 시간(밀리초)입니다. 기본값은 `1000`ms입니다.
|
|
46
|
+
* 복사 성공(`copied`), 실패(`failed`) 상태가 유지되는 시간(밀리초)입니다. 기본값은 `1000`ms입니다.
|
|
45
47
|
*
|
|
46
48
|
* @default 1000
|
|
47
49
|
*/
|
|
@@ -52,6 +54,23 @@ export interface CopyButtonWrapperProps {
|
|
|
52
54
|
* @param value - 클립보드에 복사된 문자열
|
|
53
55
|
*/
|
|
54
56
|
onCopySuccess?: (value: string) => void;
|
|
57
|
+
/**
|
|
58
|
+
* 클립보드 복사가 실패했을 때 호출되는 콜백 함수입니다.
|
|
59
|
+
* `navigator.clipboard`를 쓸 수 없거나 `writeText`가 실패한 경우, `value` 함수가 예외를 던진 경우에 호출됩니다.
|
|
60
|
+
* `value`가 비어 있어 복사를 건너뛴 경우는 실패로 보지 않으며 호출하지 않습니다.
|
|
61
|
+
* 연속으로 복사하면 시도마다 자기 `value`로 호출됩니다.
|
|
62
|
+
*
|
|
63
|
+
* @param error - 실패 원인
|
|
64
|
+
* @param value - 복사하려던 문자열. `value` 함수가 예외를 던진 경우에는 `undefined`입니다.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx
|
|
68
|
+
* <CopyButtonWrapper value="복사할 텍스트" onCopyFailed={(error) => showToast(error.message)}>
|
|
69
|
+
* ...
|
|
70
|
+
* </CopyButtonWrapper>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
onCopyFailed?: (error: Error, value: string | undefined) => void;
|
|
55
74
|
}
|
|
56
75
|
/**
|
|
57
76
|
* 클립보드 복사 버튼을 쉽게 구현하기 위한 래퍼 컴포넌트입니다.
|
|
@@ -3,18 +3,19 @@ import { ReactNode } from "react";
|
|
|
3
3
|
export interface CopyButtonWrapperProps {
|
|
4
4
|
/**
|
|
5
5
|
* 자식 컴포넌트 렌더링을 위한 콜백 함수입니다.
|
|
6
|
-
* 현재 복사 상태(`copied`)와 복사 함수(`copy`)를 인자로 제공합니다.
|
|
6
|
+
* 현재 복사 상태(`copied`, `failed`)와 복사 함수(`copy`)를 인자로 제공합니다.
|
|
7
7
|
*
|
|
8
8
|
* @param payload - 현재 상태 및 복사 함수
|
|
9
|
-
* @param payload.copied - 복사
|
|
9
|
+
* @param payload.copied - 가장 최근 복사 시도가 성공했는지 나타내는 상태
|
|
10
|
+
* @param payload.failed - 가장 최근 복사 시도가 실패했는지 나타내는 상태. `copied`와 동시에 켜지지 않습니다.
|
|
10
11
|
* @param payload.copy - 값을 클립보드에 복사하는 함수
|
|
11
12
|
*
|
|
12
13
|
* @example
|
|
13
14
|
* ```tsx
|
|
14
15
|
* <CopyButtonWrapper value="복사할 텍스트">
|
|
15
|
-
* {({ copy, copied }) => (
|
|
16
|
+
* {({ copy, copied, failed }) => (
|
|
16
17
|
* <button onClick={copy}>
|
|
17
|
-
* {copied ? "복사 완료!" : "복사하기"}
|
|
18
|
+
* {failed ? "복사 실패" : copied ? "복사 완료!" : "복사하기"}
|
|
18
19
|
* </button>
|
|
19
20
|
* )}
|
|
20
21
|
* </CopyButtonWrapper>
|
|
@@ -22,6 +23,7 @@ export interface CopyButtonWrapperProps {
|
|
|
22
23
|
*/
|
|
23
24
|
children: (payload: {
|
|
24
25
|
copied: boolean;
|
|
26
|
+
failed: boolean;
|
|
25
27
|
copy: () => void;
|
|
26
28
|
}) => ReactNode;
|
|
27
29
|
/**
|
|
@@ -41,7 +43,7 @@ export interface CopyButtonWrapperProps {
|
|
|
41
43
|
*/
|
|
42
44
|
value: string | null | undefined | (() => string | null | undefined);
|
|
43
45
|
/**
|
|
44
|
-
* 복사 성공 상태가 유지되는 시간(밀리초)입니다. 기본값은 `1000`ms입니다.
|
|
46
|
+
* 복사 성공(`copied`), 실패(`failed`) 상태가 유지되는 시간(밀리초)입니다. 기본값은 `1000`ms입니다.
|
|
45
47
|
*
|
|
46
48
|
* @default 1000
|
|
47
49
|
*/
|
|
@@ -52,6 +54,23 @@ export interface CopyButtonWrapperProps {
|
|
|
52
54
|
* @param value - 클립보드에 복사된 문자열
|
|
53
55
|
*/
|
|
54
56
|
onCopySuccess?: (value: string) => void;
|
|
57
|
+
/**
|
|
58
|
+
* 클립보드 복사가 실패했을 때 호출되는 콜백 함수입니다.
|
|
59
|
+
* `navigator.clipboard`를 쓸 수 없거나 `writeText`가 실패한 경우, `value` 함수가 예외를 던진 경우에 호출됩니다.
|
|
60
|
+
* `value`가 비어 있어 복사를 건너뛴 경우는 실패로 보지 않으며 호출하지 않습니다.
|
|
61
|
+
* 연속으로 복사하면 시도마다 자기 `value`로 호출됩니다.
|
|
62
|
+
*
|
|
63
|
+
* @param error - 실패 원인
|
|
64
|
+
* @param value - 복사하려던 문자열. `value` 함수가 예외를 던진 경우에는 `undefined`입니다.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx
|
|
68
|
+
* <CopyButtonWrapper value="복사할 텍스트" onCopyFailed={(error) => showToast(error.message)}>
|
|
69
|
+
* ...
|
|
70
|
+
* </CopyButtonWrapper>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
onCopyFailed?: (error: Error, value: string | undefined) => void;
|
|
55
74
|
}
|
|
56
75
|
/**
|
|
57
76
|
* 클립보드 복사 버튼을 쉽게 구현하기 위한 래퍼 컴포넌트입니다.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{useClipboard as e}from"../hooks/useClipboard.js";import{Fragment as t,jsx as n}from"react/jsx-runtime";function r(r){let{children:i,onCopySuccess:a,
|
|
1
|
+
"use client";import{useClipboard as e}from"../hooks/useClipboard.js";import{Fragment as t,jsx as n}from"react/jsx-runtime";function r(r){let{children:i,onCopySuccess:a,onCopyFailed:o,value:s,timeout:c=1e3}=r,l=e({timeout:c,onError:o});return/* @__PURE__ */ n(t,{children:i({copy:()=>{let e;try{e=typeof s==`function`?s():s}catch(e){let t=e instanceof Error?e:Error(String(e));l.fail(t),o?.(t,void 0);return}typeof e==`string`&&e.length>0&&l.copy(e).then(t=>{t&&a?.(e)})},copied:l.copied,failed:l.failed})})}export{r as CopyButtonWrapper};
|
|
2
2
|
//# sourceMappingURL=CopyButtonWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyButtonWrapper.js","names":["CopyButtonWrapper","props","clipboard","useClipboard","Fragment","children","v","value","copied","onCopySuccess"],"sources":["../../src/components/CopyButtonWrapper.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport { useClipboard } from '../hooks/useClipboard.js';\n\nexport interface CopyButtonWrapperProps {\n /**\n * 자식 컴포넌트 렌더링을 위한 콜백 함수입니다.\n * 현재 복사 상태(`copied`)와 복사 함수(`copy`)를 인자로 제공합니다.\n *\n * @param payload - 현재 상태 및 복사 함수\n * @param payload.copied - 복사
|
|
1
|
+
{"version":3,"file":"CopyButtonWrapper.js","names":["CopyButtonWrapper","props","clipboard","useClipboard","onCopyFailed","Fragment","children","v","value","err","error","copied","onCopySuccess"],"sources":["../../src/components/CopyButtonWrapper.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport { useClipboard } from '../hooks/useClipboard.js';\n\nexport interface CopyButtonWrapperProps {\n /**\n * 자식 컴포넌트 렌더링을 위한 콜백 함수입니다.\n * 현재 복사 상태(`copied`, `failed`)와 복사 함수(`copy`)를 인자로 제공합니다.\n *\n * @param payload - 현재 상태 및 복사 함수\n * @param payload.copied - 가장 최근 복사 시도가 성공했는지 나타내는 상태\n * @param payload.failed - 가장 최근 복사 시도가 실패했는지 나타내는 상태. `copied`와 동시에 켜지지 않습니다.\n * @param payload.copy - 값을 클립보드에 복사하는 함수\n *\n * @example\n * ```tsx\n * <CopyButtonWrapper value=\"복사할 텍스트\">\n * {({ copy, copied, failed }) => (\n * <button onClick={copy}>\n * {failed ? \"복사 실패\" : copied ? \"복사 완료!\" : \"복사하기\"}\n * </button>\n * )}\n * </CopyButtonWrapper>\n * ```\n */\n children: (payload: { copied: boolean; failed: boolean; copy: () => void }) => ReactNode;\n\n /**\n * 버튼 클릭 시 클립보드에 복사될 값입니다.\n * 문자열 또는 문자열을 반환하는 함수 형태를 지원합니다.\n *\n * @example\n * ```tsx\n * <CopyButtonWrapper value=\"복사할 텍스트\">\n * ...\n * </CopyButtonWrapper>\n *\n * <CopyButtonWrapper value={() => dynamicValue()}>\n * ...\n * </CopyButtonWrapper>\n * ```\n */\n value: string | null | undefined | (() => string | null | undefined);\n\n /**\n * 복사 성공(`copied`), 실패(`failed`) 상태가 유지되는 시간(밀리초)입니다. 기본값은 `1000`ms입니다.\n *\n * @default 1000\n */\n timeout?: number;\n\n /**\n * 클립보드 복사가 성공했을 때 호출되는 콜백 함수입니다.\n *\n * @param value - 클립보드에 복사된 문자열\n */\n onCopySuccess?: (value: string) => void;\n\n /**\n * 클립보드 복사가 실패했을 때 호출되는 콜백 함수입니다.\n * `navigator.clipboard`를 쓸 수 없거나 `writeText`가 실패한 경우, `value` 함수가 예외를 던진 경우에 호출됩니다.\n * `value`가 비어 있어 복사를 건너뛴 경우는 실패로 보지 않으며 호출하지 않습니다.\n * 연속으로 복사하면 시도마다 자기 `value`로 호출됩니다.\n *\n * @param error - 실패 원인\n * @param value - 복사하려던 문자열. `value` 함수가 예외를 던진 경우에는 `undefined`입니다.\n *\n * @example\n * ```tsx\n * <CopyButtonWrapper value=\"복사할 텍스트\" onCopyFailed={(error) => showToast(error.message)}>\n * ...\n * </CopyButtonWrapper>\n * ```\n */\n onCopyFailed?: (error: Error, value: string | undefined) => void;\n}\n\n/**\n * 클립보드 복사 버튼을 쉽게 구현하기 위한 래퍼 컴포넌트입니다.\n *\n * @param props - `CopyButtonWrapper`의 속성\n * @returns 자식 콜백 함수로 전달된 UI 요소를 렌더링합니다.\n *\n * @example\n * ```tsx\n * <CopyButtonWrapper value=\"복사할 텍스트\" timeout={2000}>\n * {({ copy, copied }) => (\n * <button onClick={copy}>\n * {copied ? \"복사되었습니다!\" : \"복사\"}\n * </button>\n * )}\n * </CopyButtonWrapper>\n * ```\n */\nexport function CopyButtonWrapper(props: CopyButtonWrapperProps) {\n const { children, onCopySuccess, onCopyFailed, value, timeout = 1000 } = props;\n const clipboard = useClipboard({ timeout, onError: onCopyFailed });\n\n // 클립보드에 값을 복사합니다. `value`가 함수인 경우 값을 동적으로 평가합니다.\n const copy = () => {\n let v: string | null | undefined;\n try {\n v = typeof value === 'function' ? value() : value;\n } catch (err) {\n // 복사할 값을 만들지 못한 경우도 실패 상태로 기록한다. 클립보드는 호출하지 않는다.\n const error = err instanceof Error ? err : new Error(String(err));\n clipboard.fail(error);\n onCopyFailed?.(error, undefined);\n return;\n }\n if (typeof v === 'string' && v.length > 0) {\n void clipboard.copy(v).then((copied) => {\n if (copied) {\n onCopySuccess?.(v);\n }\n });\n }\n };\n\n return <>{children({ copy, copied: clipboard.copied, failed: clipboard.failed })}</>;\n}\n"],"mappings":"2HA+FA,SAAgBA,EAAkB,EAA+B,CAC/D,GAAM,CAAE,WAAU,gBAAe,eAAc,QAAO,UAAU,KAASC,EACnEC,EAAYC,EAAa,CAAE,UAAS,QAASC,CAAa,CAAC,EAuBjE,MAAO,kBAAAC,EAAA,CAAA,SAAGC,EAAS,CAAE,SApBF,CACjB,IAAIC,EACJ,GAAI,CACF,EAAI,OAAOC,GAAU,WAAaA,EAAM,EAAIA,CAC9C,OAASC,EAAK,CAEZ,IAAMC,EAAQD,aAAe,MAAQA,EAAU,MAAM,OAAOA,CAAG,CAAC,EAChEP,EAAU,KAAKQ,CAAK,EACpBN,IAAeM,EAAO,IAAA,EAAS,EAC/B,MACF,CACI,OAAOH,GAAM,UAAYA,EAAE,OAAS,GACtCL,EAAe,KAAKK,CAAC,CAAC,CAAC,KAAM,GAAW,CAClCI,GACFC,IAAgBL,CAAC,CAErB,CAAC,CAEL,EAE2B,OAAQL,EAAU,OAAQ,OAAQA,EAAU,MAAO,CAAC,CAAI,CAAA,CACrF"}
|
package/dist/hooks/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import { useAudioUnlocked } from "./useAudioUnlocked.cjs";
|
|
|
3
3
|
import { useBehaviorSubject } from "./useBehaviorSubject.cjs";
|
|
4
4
|
import { useCallbackRef } from "./useCallbackRef.cjs";
|
|
5
5
|
import { useCenterInView } from "./useCenterInView.cjs";
|
|
6
|
-
import { useClipboard } from "./useClipboard.cjs";
|
|
6
|
+
import { UseClipboardOptions, useClipboard } from "./useClipboard.cjs";
|
|
7
7
|
import { useClosableEffect } from "./useClosableEffect.cjs";
|
|
8
8
|
import { composeRefs, useComposedRefs } from "./useComposedRefs.cjs";
|
|
9
9
|
import { useConstant } from "./useConstant.cjs";
|
|
@@ -66,4 +66,4 @@ import { useUpdateLayoutEffect } from "./useUpdateLayoutEffect.cjs";
|
|
|
66
66
|
import { useWindowEvent } from "./useWindowEvent.cjs";
|
|
67
67
|
import { useWindowSize } from "./useWindowSize.cjs";
|
|
68
68
|
import { useXsOrDown } from "./useXsOrDown.cjs";
|
|
69
|
-
export { CleanupCallback, FileUploadResult, OS, UseDebouncedParamsOptions, UseDebouncedParamsResult, composeRefs, useAbsolutePosition, useAudioUnlocked, useBehaviorSubject, useCallbackRef, useCenterInView, useClipboard, useClosableEffect, useComposedRefs, useConstant, useCooldown, useCustomCompareEffect, useCustomCompareMemo, useDebounceEffect, useDebounceFn, useDebouncedCallback, useDebouncedParams, 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, useRefEffect, useResizeObserver, useScript, useSessionStorage, useSessionStorageState, useSmOrDown, useSmOrUp, useThrottledCallback, useThrottledCallbackWithClearTimeout, useThrottledState, useThrottledValue, useTimeout, useTimeoutData, useUncontrolled, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWindowEvent, useWindowSize, useXsOrDown };
|
|
69
|
+
export { CleanupCallback, FileUploadResult, OS, UseClipboardOptions, UseDebouncedParamsOptions, UseDebouncedParamsResult, composeRefs, useAbsolutePosition, useAudioUnlocked, useBehaviorSubject, useCallbackRef, useCenterInView, useClipboard, useClosableEffect, useComposedRefs, useConstant, useCooldown, useCustomCompareEffect, useCustomCompareMemo, useDebounceEffect, useDebounceFn, useDebouncedCallback, useDebouncedParams, 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, useRefEffect, useResizeObserver, useScript, useSessionStorage, useSessionStorageState, useSmOrDown, useSmOrUp, useThrottledCallback, useThrottledCallbackWithClearTimeout, useThrottledState, useThrottledValue, useTimeout, useTimeoutData, useUncontrolled, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWindowEvent, useWindowSize, useXsOrDown };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { useAudioUnlocked } from "./useAudioUnlocked.js";
|
|
|
3
3
|
import { useBehaviorSubject } from "./useBehaviorSubject.js";
|
|
4
4
|
import { useCallbackRef } from "./useCallbackRef.js";
|
|
5
5
|
import { useCenterInView } from "./useCenterInView.js";
|
|
6
|
-
import { useClipboard } from "./useClipboard.js";
|
|
6
|
+
import { UseClipboardOptions, useClipboard } from "./useClipboard.js";
|
|
7
7
|
import { useClosableEffect } from "./useClosableEffect.js";
|
|
8
8
|
import { composeRefs, useComposedRefs } from "./useComposedRefs.js";
|
|
9
9
|
import { useConstant } from "./useConstant.js";
|
|
@@ -66,4 +66,4 @@ import { useUpdateLayoutEffect } from "./useUpdateLayoutEffect.js";
|
|
|
66
66
|
import { useWindowEvent } from "./useWindowEvent.js";
|
|
67
67
|
import { useWindowSize } from "./useWindowSize.js";
|
|
68
68
|
import { useXsOrDown } from "./useXsOrDown.js";
|
|
69
|
-
export { CleanupCallback, FileUploadResult, OS, UseDebouncedParamsOptions, UseDebouncedParamsResult, composeRefs, useAbsolutePosition, useAudioUnlocked, useBehaviorSubject, useCallbackRef, useCenterInView, useClipboard, useClosableEffect, useComposedRefs, useConstant, useCooldown, useCustomCompareEffect, useCustomCompareMemo, useDebounceEffect, useDebounceFn, useDebouncedCallback, useDebouncedParams, 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, useRefEffect, useResizeObserver, useScript, useSessionStorage, useSessionStorageState, useSmOrDown, useSmOrUp, useThrottledCallback, useThrottledCallbackWithClearTimeout, useThrottledState, useThrottledValue, useTimeout, useTimeoutData, useUncontrolled, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWindowEvent, useWindowSize, useXsOrDown };
|
|
69
|
+
export { CleanupCallback, FileUploadResult, OS, UseClipboardOptions, UseDebouncedParamsOptions, UseDebouncedParamsResult, composeRefs, useAbsolutePosition, useAudioUnlocked, useBehaviorSubject, useCallbackRef, useCenterInView, useClipboard, useClosableEffect, useComposedRefs, useConstant, useCooldown, useCustomCompareEffect, useCustomCompareMemo, useDebounceEffect, useDebounceFn, useDebouncedCallback, useDebouncedParams, 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, useRefEffect, useResizeObserver, useScript, useSessionStorage, useSessionStorageState, useSmOrDown, useSmOrUp, useThrottledCallback, useThrottledCallbackWithClearTimeout, useThrottledState, useThrottledValue, useTimeout, useTimeoutData, useUncontrolled, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWindowEvent, useWindowSize, useXsOrDown };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";let e=require("react");
|
|
1
|
+
"use client";let e=require("react");const t=e=>e instanceof Error?e:Error(String(e));function n({timeout:n=1e3,onError:r}={}){let[i,a]=(0,e.useState)(null),[o,s]=(0,e.useState)(!1),[c,l]=(0,e.useState)(!1),u=(0,e.useRef)(null),d=(0,e.useRef)(0);(0,e.useEffect)(()=>()=>{d.current+=1,u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]);let f=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},p=()=>(d.current+=1,f(),s(!1),l(!1),a(null),d.current),m=()=>{u.current=window.setTimeout(()=>{u.current=null,s(!1),l(!1)},n)},h=(e,t)=>{e===d.current&&(a(t),l(!0),m())};return{copy:async e=>{let n=p(),i=i=>{let a=t(i);return h(n,a),r?.(a,e),!1};if(!(`clipboard`in navigator))return i(/* @__PURE__ */ Error(`useClipboard: navigator.clipboard is not supported`));try{await navigator.clipboard.writeText(e)}catch(e){return i(e)}return n===d.current&&(s(!0),m()),!0},reset:()=>{s(!1),l(!1),a(null),f()},fail:e=>{h(p(),t(e))},error:i,copied:o,failed:c}}exports.useClipboard=n;
|
|
2
2
|
//# sourceMappingURL=useClipboard.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClipboard.cjs","names":["useState","react","useClipboard","error","setError","copied","setCopied","
|
|
1
|
+
{"version":3,"file":"useClipboard.cjs","names":["useState","useRef","react","toError","cause","useClipboard","error","setError","copied","setCopied","failed","setFailed","timerRef","attemptRef","clearTimer","beginAttempt","scheduleStateOff","timeout","settleFailure","attempt","handleFailure","failure","onError","valueToCopy","err"],"sources":["../../src/hooks/useClipboard.ts"],"sourcesContent":["'use client';\n\n// copy from mantine\nimport { useEffect, useRef, useState } from 'react';\n\nexport interface UseClipboardOptions {\n /**\n * `copied`, `failed` 상태가 유지되는 시간(밀리초)입니다. 기본값은 1000ms입니다.\n *\n * @default 1000\n */\n timeout?: number;\n\n /**\n * 복사에 실패했을 때 호출되는 콜백입니다.\n * 시도마다 자기 `value`로 호출되며, 더 새로운 시도가 있어도 이전 시도의 실패는 그대로 전달됩니다.\n *\n * @param error - 실패 원인\n * @param value - 복사하려던 문자열\n */\n onError?: (error: Error, value: string) => void;\n}\n\nconst toError = (cause: unknown): Error =>\n cause instanceof Error ? cause : new Error(String(cause));\n\n/**\n * 클립보드 복사 기능을 제공하는 React 훅입니다.\n *\n * @param options - 옵션 객체입니다.\n * @param options.timeout - `copied`, `failed` 상태가 유지되는 시간(밀리초)입니다. 기본값은 1000ms입니다.\n * @param options.onError - 복사에 실패했을 때 오류와 값을 인자로 호출되는 콜백입니다.\n * @returns\n * - `copy`: 문자열을 클립보드에 복사하고 성공 여부를 반환하는 함수\n * - `reset`: 상태를 초기화하는 함수\n * - `fail`: 클립보드를 거치지 않고 실패 상태를 직접 기록하는 함수. 복사할 값을 만들지 못한 경우에 사용합니다.\n * - `error`: 가장 최근 시도에서 발생한 오류. 새 시도가 시작되면 비워집니다.\n * - `copied`: 가장 최근 시도가 성공했는지 여부\n * - `failed`: 가장 최근 시도가 실패했는지 여부. `copied`와 동시에 켜지지 않습니다.\n *\n * @remarks\n * 여러 번 연속으로 `copy`를 호출하면 마지막 시도가 `copied`, `failed`, `error`를 정합니다.\n * 먼저 시작한 시도가 나중에 끝나도 상태를 덮어쓰지 않습니다.\n *\n * @example\n * ```tsx\n * const { copy, reset, error, copied, failed } = useClipboard({ timeout: 3000 });\n *\n * return (\n * <div>\n * <button onClick={() => copy('복사할 내용')}>복사</button>\n * {copied && <span>복사되었습니다!</span>}\n * {failed && <span>복사 실패: {error?.message}</span>}\n * <button onClick={reset}>초기화</button>\n * </div>\n * );\n * ```\n */\nexport function useClipboard({ timeout = 1000, onError }: UseClipboardOptions = {}) {\n const [error, setError] = useState<Error | null>(null); // 가장 최근 시도에서 발생한 오류 상태\n const [copied, setCopied] = useState(false); // 가장 최근 시도가 성공했는지 여부\n const [failed, setFailed] = useState(false); // 가장 최근 시도가 실패했는지 여부\n const timerRef = useRef<number | null>(null); // copied/failed 해제 타이머 ID\n const attemptRef = useRef(0); // 시도 번호. 마지막 시도만 상태를 정하게 한다\n\n // 언마운트되면 타이머를 정리하고 진행 중인 시도의 상태 반영을 막는다\n useEffect(\n () => () => {\n attemptRef.current += 1;\n if (timerRef.current !== null) {\n window.clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n },\n [],\n );\n\n const clearTimer = () => {\n if (timerRef.current !== null) {\n window.clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n };\n\n // 새 시도를 시작한다. 이전 상태와 타이머를 비우고 시도 번호를 반환한다.\n const beginAttempt = () => {\n attemptRef.current += 1;\n clearTimer();\n setCopied(false);\n setFailed(false);\n setError(null);\n return attemptRef.current;\n };\n\n // copied/failed를 timeout 뒤에 끈다. error는 다음 시도나 reset까지 남긴다.\n const scheduleStateOff = () => {\n timerRef.current = window.setTimeout(() => {\n timerRef.current = null;\n setCopied(false);\n setFailed(false);\n }, timeout);\n };\n\n // 마지막 시도일 때만 실패 상태를 반영한다\n const settleFailure = (attempt: number, cause: Error) => {\n if (attempt !== attemptRef.current) return;\n setError(cause);\n setFailed(true);\n scheduleStateOff();\n };\n\n /**\n * 클립보드에 문자열을 복사합니다.\n *\n * @param valueToCopy - 복사할 문자열\n * @returns 이 시도의 성공 여부. 더 새로운 시도가 있어도 이 시도의 결과를 그대로 반환합니다.\n */\n const copy = async (valueToCopy: string) => {\n const attempt = beginAttempt();\n\n const handleFailure = (cause: unknown) => {\n const failure = toError(cause);\n settleFailure(attempt, failure);\n onError?.(failure, valueToCopy);\n return false;\n };\n\n // 브라우저가 clipboard API를 지원하지 않을 경우 오류 처리\n if (!('clipboard' in navigator)) {\n return handleFailure(new Error('useClipboard: navigator.clipboard is not supported'));\n }\n\n try {\n // writeText가 동기로 던져도 같은 경로로 처리한다\n await navigator.clipboard.writeText(valueToCopy);\n } catch (err) {\n return handleFailure(err);\n }\n\n if (attempt === attemptRef.current) {\n setCopied(true);\n scheduleStateOff();\n }\n return true;\n };\n\n /**\n * 복사 시도 없이 실패 상태를 기록합니다. `onError`는 호출하지 않습니다.\n *\n * @param cause - 실패 원인\n */\n const fail = (cause: unknown) => {\n settleFailure(beginAttempt(), toError(cause));\n };\n\n /**\n * 복사 상태와 오류를 초기화합니다.\n */\n const reset = () => {\n setCopied(false); // 복사 상태 초기화\n setFailed(false); // 실패 상태 초기화\n setError(null); // 오류 초기화\n clearTimer(); // 기존 타이머 초기화\n };\n\n // 훅에서 반환되는 값\n return { copy, reset, fail, error, copied, failed };\n}\n"],"mappings":"oCAuBA,MAAMG,EAAW,GACfC,aAAiB,MAAQA,EAAY,MAAM,OAAOA,CAAK,CAAC,EAkC1D,SAAgBC,EAAa,CAAE,UAAU,IAAM,WAAiC,CAAC,EAAG,CAClF,GAAM,CAACC,EAAOC,IAAA,EAAYP,EAAAA,SAAAA,CAAuB,IAAI,EAC/C,CAACQ,EAAQC,IAAA,EAAaT,EAAAA,SAAAA,CAAS,EAAK,EACpC,CAACU,EAAQC,IAAA,EAAaX,EAAAA,SAAAA,CAAS,EAAK,EACpCY,GAAA,EAAWX,EAAAA,OAAAA,CAAsB,IAAI,EACrCY,GAAA,EAAaZ,EAAAA,OAAAA,CAAO,CAAC,GAG3B,EAAAC,EAAA,UAAA,SACc,CACV,EAAW,SAAW,EAClBU,EAAS,UAAY,OACvB,OAAO,aAAaA,EAAS,OAAO,EACpC,EAAS,QAAU,KAEvB,EACA,CAAC,CACH,EAEA,IAAME,MAAmB,CACnBF,EAAS,UAAY,OACvB,OAAO,aAAaA,EAAS,OAAO,EACpC,EAAS,QAAU,KAEvB,EAGMG,OACJ,EAAW,SAAW,EACtBD,EAAW,EACXL,EAAU,EAAK,EACfE,EAAU,EAAK,EACfJ,EAAS,IAAI,EACNM,EAAW,SAIdG,MAAyB,CAC7B,EAAS,QAAU,OAAO,eAAiB,CACzC,EAAS,QAAU,KACnBP,EAAU,EAAK,EACfE,EAAU,EAAK,CACjB,EAAGM,CAAO,CACZ,EAGMC,GAAiB,EAAiB,IAAiB,CACnDC,IAAYN,EAAW,UAC3BN,EAASH,CAAK,EACdO,EAAU,EAAI,EACdK,EAAiB,EACnB,EAyDA,MAAO,CAAE,UAjDW,IAAwB,CAC1C,IAAMG,EAAUJ,EAAa,EAEvBK,EAAiB,GAAmB,CACxC,IAAMC,EAAUlB,EAAQC,CAAK,EAG7B,OAFAc,EAAcC,EAASE,CAAO,EAC9BC,IAAUD,EAASE,CAAW,EACvB,EACT,EAGA,GAAI,EAAE,cAAe,WACnB,OAAOH,EAAc,gBAAI,MAAM,oDAAoD,CAAC,EAGtF,GAAI,CAEF,MAAM,UAAU,UAAU,UAAUG,CAAW,CACjD,OAASC,EAAK,CACZ,OAAOJ,EAAcI,CAAG,CAC1B,CAMA,OAJIL,IAAYN,EAAW,UACzBJ,EAAU,EAAI,EACdO,EAAiB,GAEZ,EACT,EAsBe,UARK,CAClBP,EAAU,EAAK,EACfE,EAAU,EAAK,EACfJ,EAAS,IAAI,EACbO,EAAW,CACb,EAGsB,KAfR,GAAmB,CAC/BI,EAAcH,EAAa,EAAGZ,EAAQC,CAAK,CAAC,CAC9C,EAa4B,QAAO,SAAQ,QAAO,CACpD"}
|
|
@@ -1,36 +1,59 @@
|
|
|
1
1
|
//#region src/hooks/useClipboard.d.ts
|
|
2
|
+
export interface UseClipboardOptions {
|
|
3
|
+
/**
|
|
4
|
+
* `copied`, `failed` 상태가 유지되는 시간(밀리초)입니다. 기본값은 1000ms입니다.
|
|
5
|
+
*
|
|
6
|
+
* @default 1000
|
|
7
|
+
*/
|
|
8
|
+
timeout?: number;
|
|
9
|
+
/**
|
|
10
|
+
* 복사에 실패했을 때 호출되는 콜백입니다.
|
|
11
|
+
* 시도마다 자기 `value`로 호출되며, 더 새로운 시도가 있어도 이전 시도의 실패는 그대로 전달됩니다.
|
|
12
|
+
*
|
|
13
|
+
* @param error - 실패 원인
|
|
14
|
+
* @param value - 복사하려던 문자열
|
|
15
|
+
*/
|
|
16
|
+
onError?: (error: Error, value: string) => void;
|
|
17
|
+
}
|
|
2
18
|
/**
|
|
3
19
|
* 클립보드 복사 기능을 제공하는 React 훅입니다.
|
|
4
20
|
*
|
|
5
21
|
* @param options - 옵션 객체입니다.
|
|
6
|
-
* @param options.timeout -
|
|
22
|
+
* @param options.timeout - `copied`, `failed` 상태가 유지되는 시간(밀리초)입니다. 기본값은 1000ms입니다.
|
|
23
|
+
* @param options.onError - 복사에 실패했을 때 오류와 값을 인자로 호출되는 콜백입니다.
|
|
7
24
|
* @returns
|
|
8
25
|
* - `copy`: 문자열을 클립보드에 복사하고 성공 여부를 반환하는 함수
|
|
9
26
|
* - `reset`: 상태를 초기화하는 함수
|
|
10
|
-
* - `
|
|
11
|
-
* - `
|
|
27
|
+
* - `fail`: 클립보드를 거치지 않고 실패 상태를 직접 기록하는 함수. 복사할 값을 만들지 못한 경우에 사용합니다.
|
|
28
|
+
* - `error`: 가장 최근 시도에서 발생한 오류. 새 시도가 시작되면 비워집니다.
|
|
29
|
+
* - `copied`: 가장 최근 시도가 성공했는지 여부
|
|
30
|
+
* - `failed`: 가장 최근 시도가 실패했는지 여부. `copied`와 동시에 켜지지 않습니다.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* 여러 번 연속으로 `copy`를 호출하면 마지막 시도가 `copied`, `failed`, `error`를 정합니다.
|
|
34
|
+
* 먼저 시작한 시도가 나중에 끝나도 상태를 덮어쓰지 않습니다.
|
|
12
35
|
*
|
|
13
36
|
* @example
|
|
14
37
|
* ```tsx
|
|
15
|
-
* const { copy, reset, error, copied } = useClipboard({ timeout: 3000 });
|
|
38
|
+
* const { copy, reset, error, copied, failed } = useClipboard({ timeout: 3000 });
|
|
16
39
|
*
|
|
17
40
|
* return (
|
|
18
41
|
* <div>
|
|
19
42
|
* <button onClick={() => copy('복사할 내용')}>복사</button>
|
|
20
43
|
* {copied && <span>복사되었습니다!</span>}
|
|
21
|
-
* {
|
|
44
|
+
* {failed && <span>복사 실패: {error?.message}</span>}
|
|
22
45
|
* <button onClick={reset}>초기화</button>
|
|
23
46
|
* </div>
|
|
24
47
|
* );
|
|
25
48
|
* ```
|
|
26
49
|
*/
|
|
27
|
-
export declare function useClipboard({ timeout }?: {
|
|
28
|
-
timeout?: number | undefined;
|
|
29
|
-
}): {
|
|
50
|
+
export declare function useClipboard({ timeout, onError }?: UseClipboardOptions): {
|
|
30
51
|
copy: (valueToCopy: string) => Promise<boolean>;
|
|
31
52
|
reset: () => void;
|
|
53
|
+
fail: (cause: unknown) => void;
|
|
32
54
|
error: Error | null;
|
|
33
55
|
copied: boolean;
|
|
56
|
+
failed: boolean;
|
|
34
57
|
};
|
|
35
58
|
//#endregion
|
|
36
59
|
//# sourceMappingURL=useClipboard.d.cts.map
|
|
@@ -1,36 +1,59 @@
|
|
|
1
1
|
//#region src/hooks/useClipboard.d.ts
|
|
2
|
+
export interface UseClipboardOptions {
|
|
3
|
+
/**
|
|
4
|
+
* `copied`, `failed` 상태가 유지되는 시간(밀리초)입니다. 기본값은 1000ms입니다.
|
|
5
|
+
*
|
|
6
|
+
* @default 1000
|
|
7
|
+
*/
|
|
8
|
+
timeout?: number;
|
|
9
|
+
/**
|
|
10
|
+
* 복사에 실패했을 때 호출되는 콜백입니다.
|
|
11
|
+
* 시도마다 자기 `value`로 호출되며, 더 새로운 시도가 있어도 이전 시도의 실패는 그대로 전달됩니다.
|
|
12
|
+
*
|
|
13
|
+
* @param error - 실패 원인
|
|
14
|
+
* @param value - 복사하려던 문자열
|
|
15
|
+
*/
|
|
16
|
+
onError?: (error: Error, value: string) => void;
|
|
17
|
+
}
|
|
2
18
|
/**
|
|
3
19
|
* 클립보드 복사 기능을 제공하는 React 훅입니다.
|
|
4
20
|
*
|
|
5
21
|
* @param options - 옵션 객체입니다.
|
|
6
|
-
* @param options.timeout -
|
|
22
|
+
* @param options.timeout - `copied`, `failed` 상태가 유지되는 시간(밀리초)입니다. 기본값은 1000ms입니다.
|
|
23
|
+
* @param options.onError - 복사에 실패했을 때 오류와 값을 인자로 호출되는 콜백입니다.
|
|
7
24
|
* @returns
|
|
8
25
|
* - `copy`: 문자열을 클립보드에 복사하고 성공 여부를 반환하는 함수
|
|
9
26
|
* - `reset`: 상태를 초기화하는 함수
|
|
10
|
-
* - `
|
|
11
|
-
* - `
|
|
27
|
+
* - `fail`: 클립보드를 거치지 않고 실패 상태를 직접 기록하는 함수. 복사할 값을 만들지 못한 경우에 사용합니다.
|
|
28
|
+
* - `error`: 가장 최근 시도에서 발생한 오류. 새 시도가 시작되면 비워집니다.
|
|
29
|
+
* - `copied`: 가장 최근 시도가 성공했는지 여부
|
|
30
|
+
* - `failed`: 가장 최근 시도가 실패했는지 여부. `copied`와 동시에 켜지지 않습니다.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* 여러 번 연속으로 `copy`를 호출하면 마지막 시도가 `copied`, `failed`, `error`를 정합니다.
|
|
34
|
+
* 먼저 시작한 시도가 나중에 끝나도 상태를 덮어쓰지 않습니다.
|
|
12
35
|
*
|
|
13
36
|
* @example
|
|
14
37
|
* ```tsx
|
|
15
|
-
* const { copy, reset, error, copied } = useClipboard({ timeout: 3000 });
|
|
38
|
+
* const { copy, reset, error, copied, failed } = useClipboard({ timeout: 3000 });
|
|
16
39
|
*
|
|
17
40
|
* return (
|
|
18
41
|
* <div>
|
|
19
42
|
* <button onClick={() => copy('복사할 내용')}>복사</button>
|
|
20
43
|
* {copied && <span>복사되었습니다!</span>}
|
|
21
|
-
* {
|
|
44
|
+
* {failed && <span>복사 실패: {error?.message}</span>}
|
|
22
45
|
* <button onClick={reset}>초기화</button>
|
|
23
46
|
* </div>
|
|
24
47
|
* );
|
|
25
48
|
* ```
|
|
26
49
|
*/
|
|
27
|
-
export declare function useClipboard({ timeout }?: {
|
|
28
|
-
timeout?: number | undefined;
|
|
29
|
-
}): {
|
|
50
|
+
export declare function useClipboard({ timeout, onError }?: UseClipboardOptions): {
|
|
30
51
|
copy: (valueToCopy: string) => Promise<boolean>;
|
|
31
52
|
reset: () => void;
|
|
53
|
+
fail: (cause: unknown) => void;
|
|
32
54
|
error: Error | null;
|
|
33
55
|
copied: boolean;
|
|
56
|
+
failed: boolean;
|
|
34
57
|
};
|
|
35
58
|
//#endregion
|
|
36
59
|
//# sourceMappingURL=useClipboard.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useEffect as e,useRef as t,useState as n}from"react";const r=e=>e instanceof Error?e:Error(String(e));function i({timeout:i=1e3,onError:a}={}){let[o,s]=n(null),[c,l]=n(!1),[u,d]=n(!1),f=t(null),p=t(0);e(()=>()=>{p.current+=1,f.current!==null&&(window.clearTimeout(f.current),f.current=null)},[]);let m=()=>{f.current!==null&&(window.clearTimeout(f.current),f.current=null)},h=()=>(p.current+=1,m(),l(!1),d(!1),s(null),p.current),g=()=>{f.current=window.setTimeout(()=>{f.current=null,l(!1),d(!1)},i)},_=(e,t)=>{e===p.current&&(s(t),d(!0),g())};return{copy:async e=>{let t=h(),n=n=>{let i=r(n);return _(t,i),a?.(i,e),!1};if(!(`clipboard`in navigator))return n(/* @__PURE__ */ Error(`useClipboard: navigator.clipboard is not supported`));try{await navigator.clipboard.writeText(e)}catch(e){return n(e)}return t===p.current&&(l(!0),g()),!0},reset:()=>{l(!1),d(!1),s(null),m()},fail:e=>{_(h(),r(e))},error:o,copied:c,failed:u}}export{i as useClipboard};
|
|
2
2
|
//# sourceMappingURL=useClipboard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClipboard.js","names":["useClipboard","error","setError","useState","copied","setCopied","
|
|
1
|
+
{"version":3,"file":"useClipboard.js","names":["toError","cause","useClipboard","error","setError","useState","copied","setCopied","failed","setFailed","timerRef","useRef","attemptRef","useEffect","clearTimer","beginAttempt","scheduleStateOff","timeout","settleFailure","attempt","handleFailure","failure","onError","valueToCopy","err"],"sources":["../../src/hooks/useClipboard.ts"],"sourcesContent":["'use client';\n\n// copy from mantine\nimport { useEffect, useRef, useState } from 'react';\n\nexport interface UseClipboardOptions {\n /**\n * `copied`, `failed` 상태가 유지되는 시간(밀리초)입니다. 기본값은 1000ms입니다.\n *\n * @default 1000\n */\n timeout?: number;\n\n /**\n * 복사에 실패했을 때 호출되는 콜백입니다.\n * 시도마다 자기 `value`로 호출되며, 더 새로운 시도가 있어도 이전 시도의 실패는 그대로 전달됩니다.\n *\n * @param error - 실패 원인\n * @param value - 복사하려던 문자열\n */\n onError?: (error: Error, value: string) => void;\n}\n\nconst toError = (cause: unknown): Error =>\n cause instanceof Error ? cause : new Error(String(cause));\n\n/**\n * 클립보드 복사 기능을 제공하는 React 훅입니다.\n *\n * @param options - 옵션 객체입니다.\n * @param options.timeout - `copied`, `failed` 상태가 유지되는 시간(밀리초)입니다. 기본값은 1000ms입니다.\n * @param options.onError - 복사에 실패했을 때 오류와 값을 인자로 호출되는 콜백입니다.\n * @returns\n * - `copy`: 문자열을 클립보드에 복사하고 성공 여부를 반환하는 함수\n * - `reset`: 상태를 초기화하는 함수\n * - `fail`: 클립보드를 거치지 않고 실패 상태를 직접 기록하는 함수. 복사할 값을 만들지 못한 경우에 사용합니다.\n * - `error`: 가장 최근 시도에서 발생한 오류. 새 시도가 시작되면 비워집니다.\n * - `copied`: 가장 최근 시도가 성공했는지 여부\n * - `failed`: 가장 최근 시도가 실패했는지 여부. `copied`와 동시에 켜지지 않습니다.\n *\n * @remarks\n * 여러 번 연속으로 `copy`를 호출하면 마지막 시도가 `copied`, `failed`, `error`를 정합니다.\n * 먼저 시작한 시도가 나중에 끝나도 상태를 덮어쓰지 않습니다.\n *\n * @example\n * ```tsx\n * const { copy, reset, error, copied, failed } = useClipboard({ timeout: 3000 });\n *\n * return (\n * <div>\n * <button onClick={() => copy('복사할 내용')}>복사</button>\n * {copied && <span>복사되었습니다!</span>}\n * {failed && <span>복사 실패: {error?.message}</span>}\n * <button onClick={reset}>초기화</button>\n * </div>\n * );\n * ```\n */\nexport function useClipboard({ timeout = 1000, onError }: UseClipboardOptions = {}) {\n const [error, setError] = useState<Error | null>(null); // 가장 최근 시도에서 발생한 오류 상태\n const [copied, setCopied] = useState(false); // 가장 최근 시도가 성공했는지 여부\n const [failed, setFailed] = useState(false); // 가장 최근 시도가 실패했는지 여부\n const timerRef = useRef<number | null>(null); // copied/failed 해제 타이머 ID\n const attemptRef = useRef(0); // 시도 번호. 마지막 시도만 상태를 정하게 한다\n\n // 언마운트되면 타이머를 정리하고 진행 중인 시도의 상태 반영을 막는다\n useEffect(\n () => () => {\n attemptRef.current += 1;\n if (timerRef.current !== null) {\n window.clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n },\n [],\n );\n\n const clearTimer = () => {\n if (timerRef.current !== null) {\n window.clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n };\n\n // 새 시도를 시작한다. 이전 상태와 타이머를 비우고 시도 번호를 반환한다.\n const beginAttempt = () => {\n attemptRef.current += 1;\n clearTimer();\n setCopied(false);\n setFailed(false);\n setError(null);\n return attemptRef.current;\n };\n\n // copied/failed를 timeout 뒤에 끈다. error는 다음 시도나 reset까지 남긴다.\n const scheduleStateOff = () => {\n timerRef.current = window.setTimeout(() => {\n timerRef.current = null;\n setCopied(false);\n setFailed(false);\n }, timeout);\n };\n\n // 마지막 시도일 때만 실패 상태를 반영한다\n const settleFailure = (attempt: number, cause: Error) => {\n if (attempt !== attemptRef.current) return;\n setError(cause);\n setFailed(true);\n scheduleStateOff();\n };\n\n /**\n * 클립보드에 문자열을 복사합니다.\n *\n * @param valueToCopy - 복사할 문자열\n * @returns 이 시도의 성공 여부. 더 새로운 시도가 있어도 이 시도의 결과를 그대로 반환합니다.\n */\n const copy = async (valueToCopy: string) => {\n const attempt = beginAttempt();\n\n const handleFailure = (cause: unknown) => {\n const failure = toError(cause);\n settleFailure(attempt, failure);\n onError?.(failure, valueToCopy);\n return false;\n };\n\n // 브라우저가 clipboard API를 지원하지 않을 경우 오류 처리\n if (!('clipboard' in navigator)) {\n return handleFailure(new Error('useClipboard: navigator.clipboard is not supported'));\n }\n\n try {\n // writeText가 동기로 던져도 같은 경로로 처리한다\n await navigator.clipboard.writeText(valueToCopy);\n } catch (err) {\n return handleFailure(err);\n }\n\n if (attempt === attemptRef.current) {\n setCopied(true);\n scheduleStateOff();\n }\n return true;\n };\n\n /**\n * 복사 시도 없이 실패 상태를 기록합니다. `onError`는 호출하지 않습니다.\n *\n * @param cause - 실패 원인\n */\n const fail = (cause: unknown) => {\n settleFailure(beginAttempt(), toError(cause));\n };\n\n /**\n * 복사 상태와 오류를 초기화합니다.\n */\n const reset = () => {\n setCopied(false); // 복사 상태 초기화\n setFailed(false); // 실패 상태 초기화\n setError(null); // 오류 초기화\n clearTimer(); // 기존 타이머 초기화\n };\n\n // 훅에서 반환되는 값\n return { copy, reset, fail, error, copied, failed };\n}\n"],"mappings":"yEAuBA,MAAMA,EAAW,GACfC,aAAiB,MAAQA,EAAY,MAAM,OAAOA,CAAK,CAAC,EAkC1D,SAAgBC,EAAa,CAAE,UAAU,IAAM,WAAiC,CAAC,EAAG,CAClF,GAAM,CAACC,EAAOC,GAAYC,EAAuB,IAAI,EAC/C,CAACC,EAAQC,GAAaF,EAAS,EAAK,EACpC,CAACG,EAAQC,GAAaJ,EAAS,EAAK,EACpCK,EAAWC,EAAsB,IAAI,EACrCC,EAAaD,EAAO,CAAC,EAG3BE,UACc,CACV,EAAW,SAAW,EAClBH,EAAS,UAAY,OACvB,OAAO,aAAaA,EAAS,OAAO,EACpC,EAAS,QAAU,KAEvB,EACA,CAAC,CACH,EAEA,IAAMI,MAAmB,CACnBJ,EAAS,UAAY,OACvB,OAAO,aAAaA,EAAS,OAAO,EACpC,EAAS,QAAU,KAEvB,EAGMK,OACJ,EAAW,SAAW,EACtBD,EAAW,EACXP,EAAU,EAAK,EACfE,EAAU,EAAK,EACfL,EAAS,IAAI,EACNQ,EAAW,SAIdI,MAAyB,CAC7B,EAAS,QAAU,OAAO,eAAiB,CACzC,EAAS,QAAU,KACnBT,EAAU,EAAK,EACfE,EAAU,EAAK,CACjB,EAAGQ,CAAO,CACZ,EAGMC,GAAiB,EAAiB,IAAiB,CACnDC,IAAYP,EAAW,UAC3BR,EAASH,CAAK,EACdQ,EAAU,EAAI,EACdO,EAAiB,EACnB,EAyDA,MAAO,CAAE,UAjDW,IAAwB,CAC1C,IAAMG,EAAUJ,EAAa,EAEvBK,EAAiB,GAAmB,CACxC,IAAMC,EAAUrB,EAAQC,CAAK,EAG7B,OAFAiB,EAAcC,EAASE,CAAO,EAC9BC,IAAUD,EAASE,CAAW,EACvB,EACT,EAGA,GAAI,EAAE,cAAe,WACnB,OAAOH,EAAc,gBAAI,MAAM,oDAAoD,CAAC,EAGtF,GAAI,CAEF,MAAM,UAAU,UAAU,UAAUG,CAAW,CACjD,OAASC,EAAK,CACZ,OAAOJ,EAAcI,CAAG,CAC1B,CAMA,OAJIL,IAAYP,EAAW,UACzBL,EAAU,EAAI,EACdS,EAAiB,GAEZ,EACT,EAsBe,UARK,CAClBT,EAAU,EAAK,EACfE,EAAU,EAAK,EACfL,EAAS,IAAI,EACbU,EAAW,CACb,EAGsB,KAfR,GAAmB,CAC/BI,EAAcH,EAAa,EAAGf,EAAQC,CAAK,CAAC,CAC9C,EAa4B,QAAO,SAAQ,QAAO,CACpD"}
|
|
@@ -3,4 +3,5 @@ import { Closables } from "../util/closables.cjs";
|
|
|
3
3
|
type Callback = ((closable: Closables) => VoidFunction | undefined) | ((closable: Closables) => void);
|
|
4
4
|
export declare function useClosableEffect(callback: Callback, deps: unknown[]): void;
|
|
5
5
|
//#endregion
|
|
6
|
+
export {};
|
|
6
7
|
//# sourceMappingURL=useClosableEffect.d.cts.map
|
|
@@ -3,4 +3,5 @@ import { Closables } from "../util/closables.js";
|
|
|
3
3
|
type Callback = ((closable: Closables) => VoidFunction | undefined) | ((closable: Closables) => void);
|
|
4
4
|
export declare function useClosableEffect(callback: Callback, deps: unknown[]): void;
|
|
5
5
|
//#endregion
|
|
6
|
+
export {};
|
|
6
7
|
//# sourceMappingURL=useClosableEffect.d.ts.map
|
|
@@ -52,4 +52,5 @@ type DepsEqualFnType<TDeps extends DependencyList> = (prevDeps: TDeps, nextDeps:
|
|
|
52
52
|
*/
|
|
53
53
|
export declare const useCustomCompareEffect: <TDeps extends DependencyList>(effect: EffectCallback, deps: TDeps, depsEqual: DepsEqualFnType<TDeps>) => void;
|
|
54
54
|
//#endregion
|
|
55
|
+
export {};
|
|
55
56
|
//# sourceMappingURL=useCustomCompareEffect.d.cts.map
|
|
@@ -52,4 +52,5 @@ type DepsEqualFnType<TDeps extends DependencyList> = (prevDeps: TDeps, nextDeps:
|
|
|
52
52
|
*/
|
|
53
53
|
export declare const useCustomCompareEffect: <TDeps extends DependencyList>(effect: EffectCallback, deps: TDeps, depsEqual: DepsEqualFnType<TDeps>) => void;
|
|
54
54
|
//#endregion
|
|
55
|
+
export {};
|
|
55
56
|
//# sourceMappingURL=useCustomCompareEffect.d.ts.map
|
|
@@ -27,10 +27,10 @@ import { SetStateAction } from "react";
|
|
|
27
27
|
* );
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
export declare function useDebouncedState<T>(defaultValue: T // 초기 상태 값
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}): readonly [T, (next: SetStateAction<T>) => void];
|
|
30
|
+
export declare function useDebouncedState<T>(defaultValue: T, // 초기 상태 값
|
|
31
|
+
wait: number, // 지연 시간 (밀리초)
|
|
32
|
+
options?: {
|
|
33
|
+
leading: boolean;
|
|
34
|
+
}): readonly [T, (next: SetStateAction<T>) => void];
|
|
35
35
|
//#endregion
|
|
36
36
|
//# sourceMappingURL=useDebouncedState.d.cts.map
|
|
@@ -27,10 +27,10 @@ import { SetStateAction } from "react";
|
|
|
27
27
|
* );
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
export declare function useDebouncedState<T>(defaultValue: T // 초기 상태 값
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}): readonly [T, (next: SetStateAction<T>) => void];
|
|
30
|
+
export declare function useDebouncedState<T>(defaultValue: T, // 초기 상태 값
|
|
31
|
+
wait: number, // 지연 시간 (밀리초)
|
|
32
|
+
options?: {
|
|
33
|
+
leading: boolean;
|
|
34
|
+
}): readonly [T, (next: SetStateAction<T>) => void];
|
|
35
35
|
//#endregion
|
|
36
36
|
//# sourceMappingURL=useDebouncedState.d.ts.map
|
|
@@ -9,4 +9,5 @@ type parserOptions<T> = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const useLocalStorage: <T>(key: string, initialValue?: T, options?: parserOptions<T>) => [T | undefined, Dispatch<SetStateAction<T | undefined>>, () => void];
|
|
11
11
|
//#endregion
|
|
12
|
+
export {};
|
|
12
13
|
//# sourceMappingURL=useLocalStorage.d.cts.map
|
|
@@ -9,4 +9,5 @@ type parserOptions<T> = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const useLocalStorage: <T>(key: string, initialValue?: T, options?: parserOptions<T>) => [T | undefined, Dispatch<SetStateAction<T | undefined>>, () => void];
|
|
11
11
|
//#endregion
|
|
12
|
+
export {};
|
|
12
13
|
//# sourceMappingURL=useLocalStorage.d.ts.map
|
|
@@ -3,4 +3,5 @@ type SetStateFn<T> = (value: T | undefined) => void;
|
|
|
3
3
|
type GetFn<T> = () => T;
|
|
4
4
|
export declare function useObservableLocalStorage<T>(key: string, initialValue: T | GetFn<T>): [T, SetStateFn<T | null>];
|
|
5
5
|
//#endregion
|
|
6
|
+
export {};
|
|
6
7
|
//# sourceMappingURL=useObservableLocalStorage.d.cts.map
|
|
@@ -3,4 +3,5 @@ type SetStateFn<T> = (value: T | undefined) => void;
|
|
|
3
3
|
type GetFn<T> = () => T;
|
|
4
4
|
export declare function useObservableLocalStorage<T>(key: string, initialValue: T | GetFn<T>): [T, SetStateFn<T | null>];
|
|
5
5
|
//#endregion
|
|
6
|
+
export {};
|
|
6
7
|
//# sourceMappingURL=useObservableLocalStorage.d.ts.map
|
|
@@ -3,4 +3,5 @@ type SetStateFn<T> = (value: T | undefined) => void;
|
|
|
3
3
|
type GetFn<T> = () => T;
|
|
4
4
|
export declare function useObservableSessionStorage<T>(key: string, initialValue: T | GetFn<T>): [T, SetStateFn<T | null>];
|
|
5
5
|
//#endregion
|
|
6
|
+
export {};
|
|
6
7
|
//# sourceMappingURL=useObservableSessionStorage.d.cts.map
|
|
@@ -3,4 +3,5 @@ type SetStateFn<T> = (value: T | undefined) => void;
|
|
|
3
3
|
type GetFn<T> = () => T;
|
|
4
4
|
export declare function useObservableSessionStorage<T>(key: string, initialValue: T | GetFn<T>): [T, SetStateFn<T | null>];
|
|
5
5
|
//#endregion
|
|
6
|
+
export {};
|
|
6
7
|
//# sourceMappingURL=useObservableSessionStorage.d.ts.map
|
package/dist/hooks/useOs.d.cts
CHANGED
package/dist/hooks/useOs.d.ts
CHANGED
|
@@ -23,4 +23,5 @@ type ObserverRect = Omit<DOMRectReadOnly, 'toJSON'>;
|
|
|
23
23
|
*/
|
|
24
24
|
export declare function useResizeObserver<T extends HTMLElement = HTMLElement>(options?: ResizeObserverOptions): readonly [import("react").RefObject<T | null>, ObserverRect];
|
|
25
25
|
//#endregion
|
|
26
|
+
export {};
|
|
26
27
|
//# sourceMappingURL=useResizeObserver.d.cts.map
|
|
@@ -23,4 +23,5 @@ type ObserverRect = Omit<DOMRectReadOnly, 'toJSON'>;
|
|
|
23
23
|
*/
|
|
24
24
|
export declare function useResizeObserver<T extends HTMLElement = HTMLElement>(options?: ResizeObserverOptions): readonly [import("react").RefObject<T | null>, ObserverRect];
|
|
25
25
|
//#endregion
|
|
26
|
+
export {};
|
|
26
27
|
//# sourceMappingURL=useResizeObserver.d.ts.map
|
|
@@ -18,4 +18,5 @@ type parserOptions<T> = {
|
|
|
18
18
|
*/
|
|
19
19
|
export declare const useSessionStorage: <T>(key: string, initialValue?: T, options?: parserOptions<T>) => [T | undefined, Dispatch<SetStateAction<T | undefined>>, () => void];
|
|
20
20
|
//#endregion
|
|
21
|
+
export {};
|
|
21
22
|
//# sourceMappingURL=useSessionStorage.d.cts.map
|
|
@@ -18,4 +18,5 @@ type parserOptions<T> = {
|
|
|
18
18
|
*/
|
|
19
19
|
export declare const useSessionStorage: <T>(key: string, initialValue?: T, options?: parserOptions<T>) => [T | undefined, Dispatch<SetStateAction<T | undefined>>, () => void];
|
|
20
20
|
//#endregion
|
|
21
|
+
export {};
|
|
21
22
|
//# sourceMappingURL=useSessionStorage.d.ts.map
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* return <button onClick={throttledClick}>클릭</button>;
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
export declare function useThrottledCallback<T extends (...args: any[]) => any>(callback: T // 쓰로틀링할 콜백 함수
|
|
22
|
-
|
|
21
|
+
export declare function useThrottledCallback<T extends (...args: any[]) => any>(callback: T, // 쓰로틀링할 콜백 함수
|
|
22
|
+
wait: number): (...args: Parameters<T>) => void;
|
|
23
23
|
//#endregion
|
|
24
24
|
//# sourceMappingURL=useThrottledCallback.d.cts.map
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* return <button onClick={throttledClick}>클릭</button>;
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
export declare function useThrottledCallback<T extends (...args: any[]) => any>(callback: T // 쓰로틀링할 콜백 함수
|
|
22
|
-
|
|
21
|
+
export declare function useThrottledCallback<T extends (...args: any[]) => any>(callback: T, // 쓰로틀링할 콜백 함수
|
|
22
|
+
wait: number): (...args: Parameters<T>) => void;
|
|
23
23
|
//#endregion
|
|
24
24
|
//# sourceMappingURL=useThrottledCallback.d.ts.map
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* );
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
export declare function useThrottledCallbackWithClearTimeout<T extends (...args: any[]) => any>(callback: T // 쓰로틀링할 콜백 함수
|
|
28
|
-
|
|
27
|
+
export declare function useThrottledCallbackWithClearTimeout<T extends (...args: any[]) => any>(callback: T, // 쓰로틀링할 콜백 함수
|
|
28
|
+
wait: number): readonly [(...args: Parameters<T>) => void, () => void];
|
|
29
29
|
//#endregion
|
|
30
30
|
//# sourceMappingURL=useThrottledCallbackWithClearTimeout.d.cts.map
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* );
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
export declare function useThrottledCallbackWithClearTimeout<T extends (...args: any[]) => any>(callback: T // 쓰로틀링할 콜백 함수
|
|
28
|
-
|
|
27
|
+
export declare function useThrottledCallbackWithClearTimeout<T extends (...args: any[]) => any>(callback: T, // 쓰로틀링할 콜백 함수
|
|
28
|
+
wait: number): readonly [(...args: Parameters<T>) => void, () => void];
|
|
29
29
|
//#endregion
|
|
30
30
|
//# sourceMappingURL=useThrottledCallbackWithClearTimeout.d.ts.map
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* );
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
export declare function useThrottledState<T>(defaultValue: T // 초기 상태 값
|
|
29
|
-
|
|
28
|
+
export declare function useThrottledState<T>(defaultValue: T, // 초기 상태 값
|
|
29
|
+
wait: number): readonly [T, (value: import("react").SetStateAction<T>) => void];
|
|
30
30
|
//#endregion
|
|
31
31
|
//# sourceMappingURL=useThrottledState.d.cts.map
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* );
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
export declare function useThrottledState<T>(defaultValue: T // 초기 상태 값
|
|
29
|
-
|
|
28
|
+
export declare function useThrottledState<T>(defaultValue: T, // 초기 상태 값
|
|
29
|
+
wait: number): readonly [T, (value: import("react").SetStateAction<T>) => void];
|
|
30
30
|
//#endregion
|
|
31
31
|
//# sourceMappingURL=useThrottledState.d.ts.map
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
* );
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
|
-
export declare function useTimeout(callback: (...callbackParams: unknown[]) => void // 지연 시간이 지난 후 실행할 함수
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}): {
|
|
29
|
+
export declare function useTimeout(callback: (...callbackParams: unknown[]) => void, // 지연 시간이 지난 후 실행할 함수
|
|
30
|
+
delay: number, // 타이머 지연 시간 (밀리초)
|
|
31
|
+
options?: {
|
|
32
|
+
autoInvoke: boolean;
|
|
33
|
+
}): {
|
|
34
34
|
start: (...callbackParams: unknown[]) => void;
|
|
35
35
|
clear: () => void;
|
|
36
36
|
};
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
* );
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
|
-
export declare function useTimeout(callback: (...callbackParams: unknown[]) => void // 지연 시간이 지난 후 실행할 함수
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}): {
|
|
29
|
+
export declare function useTimeout(callback: (...callbackParams: unknown[]) => void, // 지연 시간이 지난 후 실행할 함수
|
|
30
|
+
delay: number, // 타이머 지연 시간 (밀리초)
|
|
31
|
+
options?: {
|
|
32
|
+
autoInvoke: boolean;
|
|
33
|
+
}): {
|
|
34
34
|
start: (...callbackParams: unknown[]) => void;
|
|
35
35
|
clear: () => void;
|
|
36
36
|
};
|
|
@@ -44,4 +44,5 @@ interface UseUncontrolledInput<T> {
|
|
|
44
44
|
*/
|
|
45
45
|
export declare function useUncontrolled<T>({ value, defaultValue, finalValue, onChange }: UseUncontrolledInput<T>): [T, (value: T, ...payload: unknown[]) => void, boolean];
|
|
46
46
|
//#endregion
|
|
47
|
+
export {};
|
|
47
48
|
//# sourceMappingURL=useUncontrolled.d.cts.map
|
|
@@ -44,4 +44,5 @@ interface UseUncontrolledInput<T> {
|
|
|
44
44
|
*/
|
|
45
45
|
export declare function useUncontrolled<T>({ value, defaultValue, finalValue, onChange }: UseUncontrolledInput<T>): [T, (value: T, ...payload: unknown[]) => void, boolean];
|
|
46
46
|
//#endregion
|
|
47
|
+
export {};
|
|
47
48
|
//# sourceMappingURL=useUncontrolled.d.ts.map
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* });
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
export declare function useWindowEvent<K extends string>(type: K // 등록할 윈도우 이벤트의 타입
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
export declare function useWindowEvent<K extends string>(type: K, // 등록할 윈도우 이벤트의 타입
|
|
21
|
+
listener: K extends keyof WindowEventMap ? (this: Window, ev: WindowEventMap[K]) => void : (this: Window, ev: CustomEvent) => void, // 사용자 정의 이벤트 리스너
|
|
22
|
+
options?: boolean | AddEventListenerOptions): void;
|
|
23
23
|
//#endregion
|
|
24
24
|
//# sourceMappingURL=useWindowEvent.d.cts.map
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* });
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
export declare function useWindowEvent<K extends string>(type: K // 등록할 윈도우 이벤트의 타입
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
export declare function useWindowEvent<K extends string>(type: K, // 등록할 윈도우 이벤트의 타입
|
|
21
|
+
listener: K extends keyof WindowEventMap ? (this: Window, ev: WindowEventMap[K]) => void : (this: Window, ev: CustomEvent) => void, // 사용자 정의 이벤트 리스너
|
|
22
|
+
options?: boolean | AddEventListenerOptions): void;
|
|
23
23
|
//#endregion
|
|
24
24
|
//# sourceMappingURL=useWindowEvent.d.ts.map
|
package/dist/util/closables.d.ts
CHANGED
package/llm.txt
CHANGED
|
@@ -140,7 +140,7 @@ Types:
|
|
|
140
140
|
- `interface CooldownButtonBaseProps extends ButtonBaseProps { cooldown?: number; }`
|
|
141
141
|
- `interface CooldownButtonProps extends ButtonProps { cooldown?: number; }`
|
|
142
142
|
- `interface CooldownIconButtonProps extends IconButtonProps { cooldown?: number; }`
|
|
143
|
-
- `interface CopyButtonWrapperProps { children: (payload: { copied: boolean; copy: () => void; }) => ReactNode; value: string | null | undefined | (() => string | null | undefined); timeout?: number; onCopySuccess?: (value: string) => void; }`
|
|
143
|
+
- `interface CopyButtonWrapperProps { children: (payload: { copied: boolean; failed: boolean; copy: () => void; }) => ReactNode; value: string | null | undefined | (() => string | null | undefined); timeout?: number; onCopySuccess?: (value: string) => void; onCopyFailed?: (error: Error, value: string | undefined) => void; }`
|
|
144
144
|
- `interface CustomTableBodyProps extends TableBodyProps { loading?: boolean; stripe?: boolean; }`
|
|
145
145
|
- `interface DebouncedButtonBaseProps extends ButtonBaseProps { debounce?: number; }`
|
|
146
146
|
- `interface DebouncedButtonProps extends ButtonProps { debounce?: number; }`
|
|
@@ -197,7 +197,7 @@ Values:
|
|
|
197
197
|
- `useBehaviorSubject<TItem>(subject: BehaviorSubject<TItem> | Fn<BehaviorSubject<TItem>>): TItem`
|
|
198
198
|
- `useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T`
|
|
199
199
|
- `useCenterInView(offset?: number | undefined): { ref: RefObject<HTMLDivElement | null>; isCenter: boolean; }`
|
|
200
|
-
- `useClipboard({ timeout }?:
|
|
200
|
+
- `useClipboard({ timeout, onError }?: UseClipboardOptions | undefined): { copy: (valueToCopy: string) => Promise<boolean>; reset: () => void; fail: (cause: unknown) => void; error: Error | null; copied: boolean; failed: boolean; }`
|
|
201
201
|
- `useClosableEffect(callback: Callback, deps: unknown[]): void`
|
|
202
202
|
- `useComposedRefs<T>(...refs: PossibleRef<T>[]): (node: T | null) => void`
|
|
203
203
|
- `useConstant<T>(fn: () => T): T`
|
|
@@ -270,6 +270,7 @@ Types:
|
|
|
270
270
|
- `type CleanupCallback = () => void`
|
|
271
271
|
- `interface FileUploadResult { id: string; url: string; totalBytes?: number; fileName?: string; contentType?: string; }`
|
|
272
272
|
- `type OS = 'undetermined' | 'macos' | 'ios' | 'windows' | 'android' | 'linux'`
|
|
273
|
+
- `interface UseClipboardOptions { timeout?: number; onError?: (error: Error, value: string) => void; }`
|
|
273
274
|
- `interface UseDebouncedParamsOptions { delayMs?: number; }`
|
|
274
275
|
- `interface UseDebouncedParamsResult<T> { params: Partial<T>; onChange: (updated: Partial<T>) => void; flush: () => void; }`
|
|
275
276
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cp949/mui-react19",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "React UI components and hooks built on MUI (Material-UI)",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@mui/material": "^9.5.0",
|
|
21
21
|
"@mui/system": "^9.5.0",
|
|
22
|
-
"@types/node": "^26.6.
|
|
22
|
+
"@types/node": "^26.6.5",
|
|
23
23
|
"@types/react": "^19.3.0",
|
|
24
24
|
"@types/react-dom": "^19.3.0",
|
|
25
|
-
"@vitest/ui": "^5.0.
|
|
26
|
-
"happy-dom": "^
|
|
27
|
-
"react": "^19.3.
|
|
28
|
-
"react-dom": "^19.3.
|
|
25
|
+
"@vitest/ui": "^5.0.5",
|
|
26
|
+
"happy-dom": "^21.0.3",
|
|
27
|
+
"react": "^19.3.1",
|
|
28
|
+
"react-dom": "^19.3.1",
|
|
29
29
|
"rxjs": "^7.8.2",
|
|
30
|
-
"tsdown": "^0.23.
|
|
30
|
+
"tsdown": "^0.23.1",
|
|
31
31
|
"typescript": "^6.0.3",
|
|
32
|
-
"vitest": "^5.0.
|
|
32
|
+
"vitest": "^5.0.5"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@mui/material": "^9",
|