@oneplatformdev/hooks 0.0.1-beta.6 → 0.1.1-1
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/README.md +2 -2
- package/package.json +29 -30
- package/index.d.ts +0 -35
- package/index.mjs +0 -72
- package/useBoolean/index.d.ts +0 -1
- package/useBoolean/index.mjs +0 -4
- package/useBoolean/package.json +0 -7
- package/useBoolean/useBoolean.d.ts +0 -29
- package/useBoolean/useBoolean.mjs +0 -16
- package/useClickAnyWhere/index.d.ts +0 -1
- package/useClickAnyWhere/index.mjs +0 -4
- package/useClickAnyWhere/package.json +0 -7
- package/useClickAnyWhere/useClickAnyWhere.d.ts +0 -16
- package/useClickAnyWhere/useClickAnyWhere.mjs +0 -9
- package/useCopyToClipboard/index.d.ts +0 -1
- package/useCopyToClipboard/index.mjs +0 -4
- package/useCopyToClipboard/package.json +0 -7
- package/useCopyToClipboard/useCopyToClipboard.d.ts +0 -33
- package/useCopyToClipboard/useCopyToClipboard.mjs +0 -16
- package/useCountdown/index.d.ts +0 -1
- package/useCountdown/index.mjs +0 -4
- package/useCountdown/package.json +0 -7
- package/useCountdown/useCountdown.d.ts +0 -46
- package/useCountdown/useCountdown.mjs +0 -33
- package/useCounter/index.d.ts +0 -1
- package/useCounter/index.mjs +0 -4
- package/useCounter/package.json +0 -7
- package/useCounter/useCounter.d.ts +0 -28
- package/useCounter/useCounter.mjs +0 -20
- package/useDarkMode/index.d.ts +0 -1
- package/useDarkMode/index.mjs +0 -4
- package/useDarkMode/package.json +0 -7
- package/useDarkMode/useDarkMode.d.ts +0 -45
- package/useDarkMode/useDarkMode.mjs +0 -38
- package/useDebounceCallback/index.d.ts +0 -2
- package/useDebounceCallback/index.mjs +0 -5
- package/useDebounceCallback/package.json +0 -7
- package/useDebounceCallback/useDebounceCallback.d.ts +0 -61
- package/useDebounceCallback/useDebounceCallback.mjs +0 -101
- package/useDebounceValue/index.d.ts +0 -1
- package/useDebounceValue/index.mjs +0 -4
- package/useDebounceValue/package.json +0 -7
- package/useDebounceValue/useDebounceValue.d.ts +0 -40
- package/useDebounceValue/useDebounceValue.mjs +0 -13
- package/useDocumentTitle/index.d.ts +0 -1
- package/useDocumentTitle/index.mjs +0 -4
- package/useDocumentTitle/package.json +0 -7
- package/useDocumentTitle/useDocumentTitle.d.ts +0 -18
- package/useDocumentTitle/useDocumentTitle.mjs +0 -16
- package/useEventCallback/index.d.ts +0 -1
- package/useEventCallback/index.mjs +0 -4
- package/useEventCallback/package.json +0 -7
- package/useEventCallback/useEventCallback.d.ts +0 -17
- package/useEventCallback/useEventCallback.mjs +0 -16
- package/useEventListener/index.d.ts +0 -1
- package/useEventListener/index.mjs +0 -4
- package/useEventListener/package.json +0 -7
- package/useEventListener/useEventListener.d.ts +0 -7
- package/useEventListener/useEventListener.mjs +0 -20
- package/useHover/index.d.ts +0 -1
- package/useHover/index.mjs +0 -4
- package/useHover/package.json +0 -7
- package/useHover/useHover.d.ts +0 -17
- package/useHover/useHover.mjs +0 -13
- package/useIntersectionObserver/index.d.ts +0 -1
- package/useIntersectionObserver/index.mjs +0 -4
- package/useIntersectionObserver/package.json +0 -7
- package/useIntersectionObserver/useIntersectionObserver.d.ts +0 -71
- package/useIntersectionObserver/useIntersectionObserver.mjs +0 -55
- package/useInterval/index.d.ts +0 -1
- package/useInterval/index.mjs +0 -4
- package/useInterval/package.json +0 -7
- package/useInterval/useInterval.d.ts +0 -15
- package/useInterval/useInterval.mjs +0 -20
- package/useIsClient/index.d.ts +0 -1
- package/useIsClient/index.mjs +0 -4
- package/useIsClient/package.json +0 -7
- package/useIsClient/useIsClient.d.ts +0 -12
- package/useIsClient/useIsClient.mjs +0 -10
- package/useIsMobile/index.d.ts +0 -2
- package/useIsMobile/index.mjs +0 -4
- package/useIsMobile/package.json +0 -7
- package/useIsMobile/types.d.ts +0 -3
- package/useIsMobile/types.mjs +0 -1
- package/useIsMobile/useIsMobile.d.ts +0 -3
- package/useIsMobile/useIsMobile.mjs +0 -16
- package/useIsMounted/index.d.ts +0 -1
- package/useIsMounted/index.mjs +0 -4
- package/useIsMounted/package.json +0 -7
- package/useIsMounted/useIsMounted.d.ts +0 -1
- package/useIsMounted/useIsMounted.mjs +0 -10
- package/useIsomorphicLayoutEffect/index.d.ts +0 -1
- package/useIsomorphicLayoutEffect/index.mjs +0 -4
- package/useIsomorphicLayoutEffect/package.json +0 -7
- package/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts +0 -16
- package/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs +0 -5
- package/useLocalStorage/index.d.ts +0 -1
- package/useLocalStorage/index.mjs +0 -4
- package/useLocalStorage/package.json +0 -7
- package/useLocalStorage/useLocalStorage.d.ts +0 -39
- package/useLocalStorage/useLocalStorage.mjs +0 -65
- package/useLockBody/index.d.ts +0 -1
- package/useLockBody/index.mjs +0 -4
- package/useLockBody/package.json +0 -7
- package/useLockBody/useLockBody.d.ts +0 -1
- package/useLockBody/useLockBody.mjs +0 -12
- package/useMap/index.d.ts +0 -1
- package/useMap/index.mjs +0 -4
- package/useMap/package.json +0 -7
- package/useMap/useMap.d.ts +0 -47
- package/useMap/useMap.mjs +0 -27
- package/useMediaQuery/index.d.ts +0 -1
- package/useMediaQuery/index.mjs +0 -4
- package/useMediaQuery/package.json +0 -7
- package/useMediaQuery/useMediaQuery.d.ts +0 -28
- package/useMediaQuery/useMediaQuery.mjs +0 -21
- package/useOnClickOutside/index.d.ts +0 -1
- package/useOnClickOutside/index.mjs +0 -4
- package/useOnClickOutside/package.json +0 -7
- package/useOnClickOutside/useOnClickOutside.d.ts +0 -24
- package/useOnClickOutside/useOnClickOutside.mjs +0 -17
- package/useReadLocalStorage/index.d.ts +0 -1
- package/useReadLocalStorage/index.mjs +0 -4
- package/useReadLocalStorage/package.json +0 -7
- package/useReadLocalStorage/useReadLocalStorage.d.ts +0 -13
- package/useReadLocalStorage/useReadLocalStorage.mjs +0 -48
- package/useResizeObserver/index.d.ts +0 -1
- package/useResizeObserver/index.mjs +0 -4
- package/useResizeObserver/package.json +0 -7
- package/useResizeObserver/useResizeObserver.d.ts +0 -44
- package/useResizeObserver/useResizeObserver.mjs +0 -31
- package/useScreen/index.d.ts +0 -1
- package/useScreen/index.mjs +0 -4
- package/useScreen/package.json +0 -7
- package/useScreen/useScreen.d.ts +0 -19
- package/useScreen/useScreen.mjs +0 -48
- package/useScript/index.d.ts +0 -1
- package/useScript/index.mjs +0 -4
- package/useScript/package.json +0 -7
- package/useScript/useScript.d.ts +0 -23
- package/useScript/useScript.mjs +0 -45
- package/useScrollLock/index.d.ts +0 -1
- package/useScrollLock/index.mjs +0 -4
- package/useScrollLock/package.json +0 -7
- package/useScrollLock/useScrollLock.d.ts +0 -53
- package/useScrollLock/useScrollLock.mjs +0 -26
- package/useSessionStorage/index.d.ts +0 -1
- package/useSessionStorage/index.mjs +0 -4
- package/useSessionStorage/package.json +0 -7
- package/useSessionStorage/useSessionStorage.d.ts +0 -39
- package/useSessionStorage/useSessionStorage.mjs +0 -65
- package/useStep/index.d.ts +0 -1
- package/useStep/index.mjs +0 -4
- package/useStep/package.json +0 -7
- package/useStep/useStep.d.ts +0 -31
- package/useStep/useStep.mjs +0 -34
- package/useTernaryDarkMode/index.d.ts +0 -1
- package/useTernaryDarkMode/index.mjs +0 -4
- package/useTernaryDarkMode/package.json +0 -7
- package/useTernaryDarkMode/useTernaryDarkMode.d.ts +0 -46
- package/useTernaryDarkMode/useTernaryDarkMode.mjs +0 -27
- package/useTimeout/index.d.ts +0 -1
- package/useTimeout/index.mjs +0 -4
- package/useTimeout/package.json +0 -7
- package/useTimeout/useTimeout.d.ts +0 -16
- package/useTimeout/useTimeout.mjs +0 -20
- package/useToggle/index.d.ts +0 -1
- package/useToggle/index.mjs +0 -4
- package/useToggle/package.json +0 -7
- package/useToggle/useToggle.d.ts +0 -18
- package/useToggle/useToggle.mjs +0 -10
- package/useUnmount/index.d.ts +0 -1
- package/useUnmount/index.mjs +0 -4
- package/useUnmount/package.json +0 -7
- package/useUnmount/useUnmount.d.ts +0 -13
- package/useUnmount/useUnmount.mjs +0 -13
- package/useWindowSize/index.d.ts +0 -1
- package/useWindowSize/index.mjs +0 -4
- package/useWindowSize/package.json +0 -7
- package/useWindowSize/useWindowSize.d.ts +0 -29
- package/useWindowSize/useWindowSize.mjs +0 -31
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneplatformdev/hooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1-1",
|
|
4
4
|
"description": "React hook library",
|
|
5
5
|
"author": "One Platform Development Team",
|
|
6
6
|
"keywords": [
|
|
@@ -11,42 +11,41 @@
|
|
|
11
11
|
],
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/oneplatformdev/core.git",
|
|
14
|
+
"url": "git+https://github.com/oneplatformdev/core-web.git",
|
|
15
15
|
"directory": "packages/hooks"
|
|
16
16
|
},
|
|
17
17
|
"bugs": {
|
|
18
|
-
"url": "https://github.com/oneplatformdev/core/issues"
|
|
18
|
+
"url": "https://github.com/oneplatformdev/core-web/issues"
|
|
19
19
|
},
|
|
20
|
-
"
|
|
20
|
+
"license": "MIT",
|
|
21
21
|
"type": "module",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"peerDependency": {
|
|
33
|
-
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
34
|
-
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
35
|
-
"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
36
|
-
"@types/lodash.debounce": "^4.0.9"
|
|
37
|
-
},
|
|
38
|
-
"peerDependenciesMeta": {
|
|
39
|
-
"@types/react": {
|
|
40
|
-
"optional": true
|
|
41
|
-
},
|
|
42
|
-
"@types/react-dom": {
|
|
43
|
-
"optional": true
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"module": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
"./package.json": "./package.json",
|
|
27
|
+
".": {
|
|
28
|
+
"@oneplatformdev/workspace": "./src/index.ts",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"default": "./dist/index.js"
|
|
44
32
|
},
|
|
45
|
-
"
|
|
46
|
-
"
|
|
33
|
+
"./*": {
|
|
34
|
+
"types": "./dist/*.d.ts",
|
|
35
|
+
"import": "./dist/*.js",
|
|
36
|
+
"default": "./dist/*.js"
|
|
47
37
|
}
|
|
48
38
|
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"README.md",
|
|
42
|
+
"!**/*.tsbuildinfo"
|
|
43
|
+
],
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"react": ">=18",
|
|
46
|
+
"react-dom": ">=18"
|
|
47
|
+
},
|
|
49
48
|
"dependencies": {
|
|
50
|
-
"
|
|
49
|
+
"tslib": "^2.3.0"
|
|
51
50
|
}
|
|
52
|
-
}
|
|
51
|
+
}
|
package/index.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export * from './useBoolean';
|
|
2
|
-
export * from './useClickAnyWhere';
|
|
3
|
-
export * from './useCopyToClipboard';
|
|
4
|
-
export * from './useCountdown';
|
|
5
|
-
export * from './useCounter';
|
|
6
|
-
export * from './useDarkMode';
|
|
7
|
-
export * from './useDebounceCallback';
|
|
8
|
-
export * from './useDebounceValue';
|
|
9
|
-
export * from './useDocumentTitle';
|
|
10
|
-
export * from './useEventCallback';
|
|
11
|
-
export * from './useEventListener';
|
|
12
|
-
export * from './useHover';
|
|
13
|
-
export * from './useIntersectionObserver';
|
|
14
|
-
export * from './useInterval';
|
|
15
|
-
export * from './useIsClient';
|
|
16
|
-
export * from './useIsMobile';
|
|
17
|
-
export * from './useIsMounted';
|
|
18
|
-
export * from './useIsomorphicLayoutEffect';
|
|
19
|
-
export * from './useLocalStorage';
|
|
20
|
-
export * from './useLockBody';
|
|
21
|
-
export * from './useMap';
|
|
22
|
-
export * from './useMediaQuery';
|
|
23
|
-
export * from './useOnClickOutside';
|
|
24
|
-
export * from './useReadLocalStorage';
|
|
25
|
-
export * from './useResizeObserver';
|
|
26
|
-
export * from './useScreen';
|
|
27
|
-
export * from './useScript';
|
|
28
|
-
export * from './useScrollLock';
|
|
29
|
-
export * from './useSessionStorage';
|
|
30
|
-
export * from './useStep';
|
|
31
|
-
export * from './useTernaryDarkMode';
|
|
32
|
-
export * from './useTimeout';
|
|
33
|
-
export * from './useToggle';
|
|
34
|
-
export * from './useUnmount';
|
|
35
|
-
export * from './useWindowSize';
|
package/index.mjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { useBoolean as r } from "./useBoolean/useBoolean.mjs";
|
|
2
|
-
import { useClickAnyWhere as s } from "./useClickAnyWhere/useClickAnyWhere.mjs";
|
|
3
|
-
import { useCopyToClipboard as p } from "./useCopyToClipboard/useCopyToClipboard.mjs";
|
|
4
|
-
import { useCountdown as f } from "./useCountdown/useCountdown.mjs";
|
|
5
|
-
import { useCounter as n } from "./useCounter/useCounter.mjs";
|
|
6
|
-
import { useDarkMode as l } from "./useDarkMode/useDarkMode.mjs";
|
|
7
|
-
import { useDebounceCallback as i } from "./useDebounceCallback/useDebounceCallback.mjs";
|
|
8
|
-
import { useDebounceValue as C } from "./useDebounceValue/useDebounceValue.mjs";
|
|
9
|
-
import { useDocumentTitle as b } from "./useDocumentTitle/useDocumentTitle.mjs";
|
|
10
|
-
import { useEventCallback as v } from "./useEventCallback/useEventCallback.mjs";
|
|
11
|
-
import { useEventListener as I } from "./useEventListener/useEventListener.mjs";
|
|
12
|
-
import { useHover as M } from "./useHover/useHover.mjs";
|
|
13
|
-
import { useIntersectionObserver as D } from "./useIntersectionObserver/useIntersectionObserver.mjs";
|
|
14
|
-
import { useInterval as O } from "./useInterval/useInterval.mjs";
|
|
15
|
-
import { useIsClient as h } from "./useIsClient/useIsClient.mjs";
|
|
16
|
-
import { useIsMobile as z } from "./useIsMobile/useIsMobile.mjs";
|
|
17
|
-
import { useIsMounted as R } from "./useIsMounted/useIsMounted.mjs";
|
|
18
|
-
import { useIsomorphicLayoutEffect as A } from "./useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs";
|
|
19
|
-
import { useLocalStorage as Q } from "./useLocalStorage/useLocalStorage.mjs";
|
|
20
|
-
import { useLockBody as V } from "./useLockBody/useLockBody.mjs";
|
|
21
|
-
import { useMap as q } from "./useMap/useMap.mjs";
|
|
22
|
-
import { useMediaQuery as G } from "./useMediaQuery/useMediaQuery.mjs";
|
|
23
|
-
import { useOnClickOutside as K } from "./useOnClickOutside/useOnClickOutside.mjs";
|
|
24
|
-
import { useReadLocalStorage as P } from "./useReadLocalStorage/useReadLocalStorage.mjs";
|
|
25
|
-
import { useResizeObserver as Y } from "./useResizeObserver/useResizeObserver.mjs";
|
|
26
|
-
import { useScreen as _ } from "./useScreen/useScreen.mjs";
|
|
27
|
-
import { useScript as ee } from "./useScript/useScript.mjs";
|
|
28
|
-
import { useScrollLock as re } from "./useScrollLock/useScrollLock.mjs";
|
|
29
|
-
import { useSessionStorage as se } from "./useSessionStorage/useSessionStorage.mjs";
|
|
30
|
-
import { useStep as pe } from "./useStep/useStep.mjs";
|
|
31
|
-
import { useTernaryDarkMode as fe } from "./useTernaryDarkMode/useTernaryDarkMode.mjs";
|
|
32
|
-
import { useTimeout as ne } from "./useTimeout/useTimeout.mjs";
|
|
33
|
-
import { useToggle as le } from "./useToggle/useToggle.mjs";
|
|
34
|
-
import { useUnmount as ie } from "./useUnmount/useUnmount.mjs";
|
|
35
|
-
import { useWindowSize as Ce } from "./useWindowSize/useWindowSize.mjs";
|
|
36
|
-
export {
|
|
37
|
-
r as useBoolean,
|
|
38
|
-
s as useClickAnyWhere,
|
|
39
|
-
p as useCopyToClipboard,
|
|
40
|
-
f as useCountdown,
|
|
41
|
-
n as useCounter,
|
|
42
|
-
l as useDarkMode,
|
|
43
|
-
i as useDebounceCallback,
|
|
44
|
-
C as useDebounceValue,
|
|
45
|
-
b as useDocumentTitle,
|
|
46
|
-
v as useEventCallback,
|
|
47
|
-
I as useEventListener,
|
|
48
|
-
M as useHover,
|
|
49
|
-
D as useIntersectionObserver,
|
|
50
|
-
O as useInterval,
|
|
51
|
-
h as useIsClient,
|
|
52
|
-
z as useIsMobile,
|
|
53
|
-
R as useIsMounted,
|
|
54
|
-
A as useIsomorphicLayoutEffect,
|
|
55
|
-
Q as useLocalStorage,
|
|
56
|
-
V as useLockBody,
|
|
57
|
-
q as useMap,
|
|
58
|
-
G as useMediaQuery,
|
|
59
|
-
K as useOnClickOutside,
|
|
60
|
-
P as useReadLocalStorage,
|
|
61
|
-
Y as useResizeObserver,
|
|
62
|
-
_ as useScreen,
|
|
63
|
-
ee as useScript,
|
|
64
|
-
re as useScrollLock,
|
|
65
|
-
se as useSessionStorage,
|
|
66
|
-
pe as useStep,
|
|
67
|
-
fe as useTernaryDarkMode,
|
|
68
|
-
ne as useTimeout,
|
|
69
|
-
le as useToggle,
|
|
70
|
-
ie as useUnmount,
|
|
71
|
-
Ce as useWindowSize
|
|
72
|
-
};
|
package/useBoolean/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useBoolean';
|
package/useBoolean/index.mjs
DELETED
package/useBoolean/package.json
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
|
|
3
|
-
/** The useBoolean return type. */
|
|
4
|
-
type UseBooleanReturn = {
|
|
5
|
-
/** The current boolean state value. */
|
|
6
|
-
value: boolean;
|
|
7
|
-
/** Function to set the boolean state directly. */
|
|
8
|
-
setValue: Dispatch<SetStateAction<boolean>>;
|
|
9
|
-
/** Function to set the boolean state to `true`. */
|
|
10
|
-
setTrue: () => void;
|
|
11
|
-
/** Function to set the boolean state to `false`. */
|
|
12
|
-
setFalse: () => void;
|
|
13
|
-
/** Function to toggle the boolean state. */
|
|
14
|
-
toggle: () => void;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Custom hook that handles boolean state with useful utility functions.
|
|
18
|
-
* @param {boolean} [defaultValue] - The initial value for the boolean state (default is `false`).
|
|
19
|
-
* @returns {UseBooleanReturn} An object containing the boolean state value and utility functions to manipulate the state.
|
|
20
|
-
* @throws Will throw an error if `defaultValue` is an invalid boolean value.
|
|
21
|
-
* @public
|
|
22
|
-
* @see [Documentation](https://usehooks-ts.com/react-hook/use-boolean)
|
|
23
|
-
* @example
|
|
24
|
-
* ```tsx
|
|
25
|
-
* const { value, setTrue, setFalse, toggle } = useBoolean(true);
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare function useBoolean(defaultValue?: boolean): UseBooleanReturn;
|
|
29
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useState as n, useCallback as t } from "react";
|
|
2
|
-
function c(o = !1) {
|
|
3
|
-
if (typeof o != "boolean")
|
|
4
|
-
throw new Error("defaultValue must be `true` or `false`");
|
|
5
|
-
const [s, e] = n(o), r = t(() => {
|
|
6
|
-
e(!0);
|
|
7
|
-
}, []), a = t(() => {
|
|
8
|
-
e(!1);
|
|
9
|
-
}, []), l = t(() => {
|
|
10
|
-
e((u) => !u);
|
|
11
|
-
}, []);
|
|
12
|
-
return { value: s, setValue: e, setTrue: r, setFalse: a, toggle: l };
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
c as useBoolean
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useClickAnyWhere';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom hook that handles click events anywhere on the document.
|
|
3
|
-
* @param {Function} handler - The function to be called when a click event is detected anywhere on the document.
|
|
4
|
-
* @public
|
|
5
|
-
* @see [Documentation](https://usehooks-ts.com/react-hook/use-click-any-where)
|
|
6
|
-
* @example
|
|
7
|
-
* ```tsx
|
|
8
|
-
* const handleClick = (event) => {
|
|
9
|
-
* console.log('Document clicked!', event);
|
|
10
|
-
* };
|
|
11
|
-
*
|
|
12
|
-
* // Attach click event handler to document
|
|
13
|
-
* useClickAnywhere(handleClick);
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare function useClickAnyWhere(handler: (event: MouseEvent) => void): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useCopyToClipboard';
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The copied text as `string` or `null` if nothing has been copied yet.
|
|
3
|
-
*/
|
|
4
|
-
type CopiedValue = string | null;
|
|
5
|
-
/**
|
|
6
|
-
* Function to copy text to the clipboard.
|
|
7
|
-
* @param text - The text to copy to the clipboard.
|
|
8
|
-
* @returns {Promise<boolean>} A promise that resolves to `true` if the text was copied successfully, or `false` otherwise.
|
|
9
|
-
*/
|
|
10
|
-
type CopyFn = (text: string) => Promise<boolean>;
|
|
11
|
-
/**
|
|
12
|
-
* Custom hook that copies text to the clipboard using the [`Clipboard API`](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API).
|
|
13
|
-
* @returns {[CopiedValue, CopyFn]} An tuple containing the copied text and a function to copy text to the clipboard.
|
|
14
|
-
* @public
|
|
15
|
-
* @see [Documentation](https://usehooks-ts.com/react-hook/use-copy-to-clipboard)
|
|
16
|
-
* @example
|
|
17
|
-
* ```tsx
|
|
18
|
-
* const [copiedText, copyToClipboard] = useCopyToClipboard();
|
|
19
|
-
* const textToCopy = 'Hello, world!';
|
|
20
|
-
*
|
|
21
|
-
* // Attempt to copy text to the clipboard
|
|
22
|
-
* copyToClipboard(textToCopy)
|
|
23
|
-
* .then(success => {
|
|
24
|
-
* if (success) {
|
|
25
|
-
* console.log(`Text "${textToCopy}" copied to clipboard successfully.`);
|
|
26
|
-
* } else {
|
|
27
|
-
* console.error('Failed to copy text to clipboard.');
|
|
28
|
-
* }
|
|
29
|
-
* });
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare function useCopyToClipboard(): [CopiedValue, CopyFn];
|
|
33
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useState as n, useCallback as l } from "react";
|
|
2
|
-
function c() {
|
|
3
|
-
const [e, r] = n(null), t = l(async (o) => {
|
|
4
|
-
if (!(navigator != null && navigator.clipboard))
|
|
5
|
-
return console.warn("Clipboard not supported"), !1;
|
|
6
|
-
try {
|
|
7
|
-
return await navigator.clipboard.writeText(o), r(o), !0;
|
|
8
|
-
} catch (a) {
|
|
9
|
-
return console.warn("Copy failed", a), r(null), !1;
|
|
10
|
-
}
|
|
11
|
-
}, []);
|
|
12
|
-
return [e, t];
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
c as useCopyToClipboard
|
|
16
|
-
};
|
package/useCountdown/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useCountdown';
|
package/useCountdown/index.mjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/** The countdown's options. */
|
|
2
|
-
type CountdownOptions = {
|
|
3
|
-
/** The countdown's starting number, initial value of the returned number. */
|
|
4
|
-
countStart: number;
|
|
5
|
-
/**
|
|
6
|
-
* The countdown's interval, in milliseconds.
|
|
7
|
-
* @default 1000
|
|
8
|
-
*/
|
|
9
|
-
intervalMs?: number;
|
|
10
|
-
/**
|
|
11
|
-
* True if the countdown is increment.
|
|
12
|
-
* @default false
|
|
13
|
-
*/
|
|
14
|
-
isIncrement?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* The countdown's stopping number. Pass `-Infinity` to decrease forever.
|
|
17
|
-
* @default 0
|
|
18
|
-
*/
|
|
19
|
-
countStop?: number;
|
|
20
|
-
};
|
|
21
|
-
/** The countdown's controllers. */
|
|
22
|
-
type CountdownControllers = {
|
|
23
|
-
/** Start the countdown. */
|
|
24
|
-
startCountdown: () => void;
|
|
25
|
-
/** Stop the countdown. */
|
|
26
|
-
stopCountdown: () => void;
|
|
27
|
-
/** Reset the countdown. */
|
|
28
|
-
resetCountdown: () => void;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Custom hook that manages countdown.
|
|
32
|
-
* @param {CountdownOptions} countdownOptions - The countdown's options.
|
|
33
|
-
* @returns {[number, CountdownControllers]} An array containing the countdown's count and its controllers.
|
|
34
|
-
* @public
|
|
35
|
-
* @see [Documentation](https://usehooks-ts.com/react-hook/use-countdown)
|
|
36
|
-
* @example
|
|
37
|
-
* ```tsx
|
|
38
|
-
* const [counter, { start, stop, reset }] = useCountdown({
|
|
39
|
-
* countStart: 10,
|
|
40
|
-
* intervalMs: 1000,
|
|
41
|
-
* isIncrement: false,
|
|
42
|
-
* });
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
export declare function useCountdown({ countStart, countStop, intervalMs, isIncrement, }: CountdownOptions): [number, CountdownControllers];
|
|
46
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useCallback as l } from "react";
|
|
2
|
-
import { useBoolean as d } from "../useBoolean/useBoolean.mjs";
|
|
3
|
-
import { useCounter as w } from "../useCounter/useCounter.mjs";
|
|
4
|
-
import { useInterval as p } from "../useInterval/useInterval.mjs";
|
|
5
|
-
function x({
|
|
6
|
-
countStart: a,
|
|
7
|
-
countStop: n = 0,
|
|
8
|
-
intervalMs: c = 1e3,
|
|
9
|
-
isIncrement: t = !1
|
|
10
|
-
}) {
|
|
11
|
-
const {
|
|
12
|
-
count: o,
|
|
13
|
-
increment: r,
|
|
14
|
-
decrement: s,
|
|
15
|
-
reset: u
|
|
16
|
-
} = w(a), {
|
|
17
|
-
value: f,
|
|
18
|
-
setTrue: i,
|
|
19
|
-
setFalse: e
|
|
20
|
-
} = d(!1), m = l(() => {
|
|
21
|
-
e(), u();
|
|
22
|
-
}, [e, u]), C = l(() => {
|
|
23
|
-
if (o === n) {
|
|
24
|
-
e();
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
t ? r() : s();
|
|
28
|
-
}, [o, n, s, r, t, e]);
|
|
29
|
-
return p(C, f ? c : null), [o, { startCountdown: i, stopCountdown: e, resetCountdown: m }];
|
|
30
|
-
}
|
|
31
|
-
export {
|
|
32
|
-
x as useCountdown
|
|
33
|
-
};
|
package/useCounter/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useCounter';
|
package/useCounter/index.mjs
DELETED
package/useCounter/package.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
|
|
3
|
-
/** The hook return type. */
|
|
4
|
-
type UseCounterReturn = {
|
|
5
|
-
/** The current count value. */
|
|
6
|
-
count: number;
|
|
7
|
-
/** Function to increment the counter by 1. */
|
|
8
|
-
increment: () => void;
|
|
9
|
-
/** Function to decrement the counter by 1. */
|
|
10
|
-
decrement: () => void;
|
|
11
|
-
/** Function to reset the counter to its initial value. */
|
|
12
|
-
reset: () => void;
|
|
13
|
-
/** Function to set a specific value to the counter. */
|
|
14
|
-
setCount: Dispatch<SetStateAction<number>>;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Custom hook that manages a counter with increment, decrement, reset, and setCount functionalities.
|
|
18
|
-
* @param {number} [initialValue] - The initial value for the counter.
|
|
19
|
-
* @returns {UseCounterReturn} An object containing the current count and functions to interact with the counter.
|
|
20
|
-
* @public
|
|
21
|
-
* @see [Documentation](https://usehooks-ts.com/react-hook/use-counter)
|
|
22
|
-
* @example
|
|
23
|
-
* ```tsx
|
|
24
|
-
* const { count, increment, decrement, reset, setCount } = useCounter(5);
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare function useCounter(initialValue?: number): UseCounterReturn;
|
|
28
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useState as m, useCallback as o } from "react";
|
|
2
|
-
function f(e) {
|
|
3
|
-
const [c, t] = m(e ?? 0), r = o(() => {
|
|
4
|
-
t((n) => n + 1);
|
|
5
|
-
}, []), s = o(() => {
|
|
6
|
-
t((n) => n - 1);
|
|
7
|
-
}, []), u = o(() => {
|
|
8
|
-
t(e ?? 0);
|
|
9
|
-
}, [e]);
|
|
10
|
-
return {
|
|
11
|
-
count: c,
|
|
12
|
-
increment: r,
|
|
13
|
-
decrement: s,
|
|
14
|
-
reset: u,
|
|
15
|
-
setCount: t
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
f as useCounter
|
|
20
|
-
};
|
package/useDarkMode/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useDarkMode';
|
package/useDarkMode/index.mjs
DELETED
package/useDarkMode/package.json
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/** The hook options. */
|
|
2
|
-
type DarkModeOptions = {
|
|
3
|
-
/**
|
|
4
|
-
* The initial value of the dark mode.
|
|
5
|
-
* @default false
|
|
6
|
-
*/
|
|
7
|
-
defaultValue?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* The key to use in the local storage.
|
|
10
|
-
* @default 'usehooks-ts-dark-mode'
|
|
11
|
-
*/
|
|
12
|
-
localStorageKey?: string;
|
|
13
|
-
/**
|
|
14
|
-
* If `true` (default), the hook will initialize reading `localStorage`.
|
|
15
|
-
* In SSR, you should set it to `false`, returning the `defaultValue` or `false` initially.
|
|
16
|
-
* @default true
|
|
17
|
-
*/
|
|
18
|
-
initializeWithValue?: boolean;
|
|
19
|
-
};
|
|
20
|
-
/** The hook return type. */
|
|
21
|
-
type DarkModeReturn = {
|
|
22
|
-
/** The current state of the dark mode. */
|
|
23
|
-
isDarkMode: boolean;
|
|
24
|
-
/** Function to toggle the dark mode. */
|
|
25
|
-
toggle: () => void;
|
|
26
|
-
/** Function to enable the dark mode. */
|
|
27
|
-
enable: () => void;
|
|
28
|
-
/** Function to disable the dark mode. */
|
|
29
|
-
disable: () => void;
|
|
30
|
-
/** Function to set a specific value to the dark mode. */
|
|
31
|
-
set: (value: boolean) => void;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Custom hook that returns the current state of the dark mode.
|
|
35
|
-
* @param {?DarkModeOptions} [options] - The initial value of the dark mode, default `false`.
|
|
36
|
-
* @returns {DarkModeReturn} An object containing the dark mode's state and its controllers.
|
|
37
|
-
* @public
|
|
38
|
-
* @see [Documentation](https://usehooks-ts.com/react-hook/use-dark-mode)
|
|
39
|
-
* @example
|
|
40
|
-
* ```tsx
|
|
41
|
-
* const { isDarkMode, toggle, enable, disable, set } = useDarkMode({ defaultValue: true });
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export declare function useDarkMode(options?: DarkModeOptions): DarkModeReturn;
|
|
45
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { useIsomorphicLayoutEffect as l } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs";
|
|
2
|
-
import { useLocalStorage as c } from "../useLocalStorage/useLocalStorage.mjs";
|
|
3
|
-
import { useMediaQuery as f } from "../useMediaQuery/useMediaQuery.mjs";
|
|
4
|
-
const n = "(prefers-color-scheme: dark)", d = "usehooks-ts-dark-mode";
|
|
5
|
-
function E(i = {}) {
|
|
6
|
-
const {
|
|
7
|
-
defaultValue: t,
|
|
8
|
-
localStorageKey: u = d,
|
|
9
|
-
initializeWithValue: s = !0
|
|
10
|
-
} = i, o = f(n, {
|
|
11
|
-
initializeWithValue: s,
|
|
12
|
-
defaultValue: t
|
|
13
|
-
}), [a, e] = c(
|
|
14
|
-
u,
|
|
15
|
-
t ?? o ?? !1,
|
|
16
|
-
{ initializeWithValue: s }
|
|
17
|
-
);
|
|
18
|
-
return l(() => {
|
|
19
|
-
o !== a && e(o);
|
|
20
|
-
}, [o]), {
|
|
21
|
-
isDarkMode: a,
|
|
22
|
-
toggle: () => {
|
|
23
|
-
e((r) => !r);
|
|
24
|
-
},
|
|
25
|
-
enable: () => {
|
|
26
|
-
e(!0);
|
|
27
|
-
},
|
|
28
|
-
disable: () => {
|
|
29
|
-
e(!1);
|
|
30
|
-
},
|
|
31
|
-
set: (r) => {
|
|
32
|
-
e(r);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export {
|
|
37
|
-
E as useDarkMode
|
|
38
|
-
};
|