@oneplatformdev/hooks 0.0.1-beta.7 → 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.
Files changed (181) hide show
  1. package/README.md +2 -2
  2. package/package.json +29 -30
  3. package/index.d.ts +0 -35
  4. package/index.mjs +0 -72
  5. package/useBoolean/index.d.ts +0 -1
  6. package/useBoolean/index.mjs +0 -4
  7. package/useBoolean/package.json +0 -7
  8. package/useBoolean/useBoolean.d.ts +0 -29
  9. package/useBoolean/useBoolean.mjs +0 -16
  10. package/useClickAnyWhere/index.d.ts +0 -1
  11. package/useClickAnyWhere/index.mjs +0 -4
  12. package/useClickAnyWhere/package.json +0 -7
  13. package/useClickAnyWhere/useClickAnyWhere.d.ts +0 -16
  14. package/useClickAnyWhere/useClickAnyWhere.mjs +0 -9
  15. package/useCopyToClipboard/index.d.ts +0 -1
  16. package/useCopyToClipboard/index.mjs +0 -4
  17. package/useCopyToClipboard/package.json +0 -7
  18. package/useCopyToClipboard/useCopyToClipboard.d.ts +0 -33
  19. package/useCopyToClipboard/useCopyToClipboard.mjs +0 -16
  20. package/useCountdown/index.d.ts +0 -1
  21. package/useCountdown/index.mjs +0 -4
  22. package/useCountdown/package.json +0 -7
  23. package/useCountdown/useCountdown.d.ts +0 -46
  24. package/useCountdown/useCountdown.mjs +0 -33
  25. package/useCounter/index.d.ts +0 -1
  26. package/useCounter/index.mjs +0 -4
  27. package/useCounter/package.json +0 -7
  28. package/useCounter/useCounter.d.ts +0 -28
  29. package/useCounter/useCounter.mjs +0 -20
  30. package/useDarkMode/index.d.ts +0 -1
  31. package/useDarkMode/index.mjs +0 -4
  32. package/useDarkMode/package.json +0 -7
  33. package/useDarkMode/useDarkMode.d.ts +0 -45
  34. package/useDarkMode/useDarkMode.mjs +0 -38
  35. package/useDebounceCallback/index.d.ts +0 -2
  36. package/useDebounceCallback/index.mjs +0 -5
  37. package/useDebounceCallback/package.json +0 -7
  38. package/useDebounceCallback/useDebounceCallback.d.ts +0 -61
  39. package/useDebounceCallback/useDebounceCallback.mjs +0 -101
  40. package/useDebounceValue/index.d.ts +0 -1
  41. package/useDebounceValue/index.mjs +0 -4
  42. package/useDebounceValue/package.json +0 -7
  43. package/useDebounceValue/useDebounceValue.d.ts +0 -40
  44. package/useDebounceValue/useDebounceValue.mjs +0 -13
  45. package/useDocumentTitle/index.d.ts +0 -1
  46. package/useDocumentTitle/index.mjs +0 -4
  47. package/useDocumentTitle/package.json +0 -7
  48. package/useDocumentTitle/useDocumentTitle.d.ts +0 -18
  49. package/useDocumentTitle/useDocumentTitle.mjs +0 -16
  50. package/useEventCallback/index.d.ts +0 -1
  51. package/useEventCallback/index.mjs +0 -4
  52. package/useEventCallback/package.json +0 -7
  53. package/useEventCallback/useEventCallback.d.ts +0 -17
  54. package/useEventCallback/useEventCallback.mjs +0 -16
  55. package/useEventListener/index.d.ts +0 -1
  56. package/useEventListener/index.mjs +0 -4
  57. package/useEventListener/package.json +0 -7
  58. package/useEventListener/useEventListener.d.ts +0 -7
  59. package/useEventListener/useEventListener.mjs +0 -20
  60. package/useHover/index.d.ts +0 -1
  61. package/useHover/index.mjs +0 -4
  62. package/useHover/package.json +0 -7
  63. package/useHover/useHover.d.ts +0 -17
  64. package/useHover/useHover.mjs +0 -13
  65. package/useIntersectionObserver/index.d.ts +0 -1
  66. package/useIntersectionObserver/index.mjs +0 -4
  67. package/useIntersectionObserver/package.json +0 -7
  68. package/useIntersectionObserver/useIntersectionObserver.d.ts +0 -71
  69. package/useIntersectionObserver/useIntersectionObserver.mjs +0 -55
  70. package/useInterval/index.d.ts +0 -1
  71. package/useInterval/index.mjs +0 -4
  72. package/useInterval/package.json +0 -7
  73. package/useInterval/useInterval.d.ts +0 -15
  74. package/useInterval/useInterval.mjs +0 -20
  75. package/useIsClient/index.d.ts +0 -1
  76. package/useIsClient/index.mjs +0 -4
  77. package/useIsClient/package.json +0 -7
  78. package/useIsClient/useIsClient.d.ts +0 -12
  79. package/useIsClient/useIsClient.mjs +0 -10
  80. package/useIsMobile/index.d.ts +0 -2
  81. package/useIsMobile/index.mjs +0 -4
  82. package/useIsMobile/package.json +0 -7
  83. package/useIsMobile/types.d.ts +0 -3
  84. package/useIsMobile/types.mjs +0 -1
  85. package/useIsMobile/useIsMobile.d.ts +0 -3
  86. package/useIsMobile/useIsMobile.mjs +0 -16
  87. package/useIsMounted/index.d.ts +0 -1
  88. package/useIsMounted/index.mjs +0 -4
  89. package/useIsMounted/package.json +0 -7
  90. package/useIsMounted/useIsMounted.d.ts +0 -1
  91. package/useIsMounted/useIsMounted.mjs +0 -10
  92. package/useIsomorphicLayoutEffect/index.d.ts +0 -1
  93. package/useIsomorphicLayoutEffect/index.mjs +0 -4
  94. package/useIsomorphicLayoutEffect/package.json +0 -7
  95. package/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts +0 -16
  96. package/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs +0 -5
  97. package/useLocalStorage/index.d.ts +0 -1
  98. package/useLocalStorage/index.mjs +0 -4
  99. package/useLocalStorage/package.json +0 -7
  100. package/useLocalStorage/useLocalStorage.d.ts +0 -39
  101. package/useLocalStorage/useLocalStorage.mjs +0 -65
  102. package/useLockBody/index.d.ts +0 -1
  103. package/useLockBody/index.mjs +0 -4
  104. package/useLockBody/package.json +0 -7
  105. package/useLockBody/useLockBody.d.ts +0 -1
  106. package/useLockBody/useLockBody.mjs +0 -12
  107. package/useMap/index.d.ts +0 -1
  108. package/useMap/index.mjs +0 -4
  109. package/useMap/package.json +0 -7
  110. package/useMap/useMap.d.ts +0 -47
  111. package/useMap/useMap.mjs +0 -27
  112. package/useMediaQuery/index.d.ts +0 -1
  113. package/useMediaQuery/index.mjs +0 -4
  114. package/useMediaQuery/package.json +0 -7
  115. package/useMediaQuery/useMediaQuery.d.ts +0 -28
  116. package/useMediaQuery/useMediaQuery.mjs +0 -21
  117. package/useOnClickOutside/index.d.ts +0 -1
  118. package/useOnClickOutside/index.mjs +0 -4
  119. package/useOnClickOutside/package.json +0 -7
  120. package/useOnClickOutside/useOnClickOutside.d.ts +0 -24
  121. package/useOnClickOutside/useOnClickOutside.mjs +0 -17
  122. package/useReadLocalStorage/index.d.ts +0 -1
  123. package/useReadLocalStorage/index.mjs +0 -4
  124. package/useReadLocalStorage/package.json +0 -7
  125. package/useReadLocalStorage/useReadLocalStorage.d.ts +0 -13
  126. package/useReadLocalStorage/useReadLocalStorage.mjs +0 -48
  127. package/useResizeObserver/index.d.ts +0 -1
  128. package/useResizeObserver/index.mjs +0 -4
  129. package/useResizeObserver/package.json +0 -7
  130. package/useResizeObserver/useResizeObserver.d.ts +0 -44
  131. package/useResizeObserver/useResizeObserver.mjs +0 -31
  132. package/useScreen/index.d.ts +0 -1
  133. package/useScreen/index.mjs +0 -4
  134. package/useScreen/package.json +0 -7
  135. package/useScreen/useScreen.d.ts +0 -19
  136. package/useScreen/useScreen.mjs +0 -48
  137. package/useScript/index.d.ts +0 -1
  138. package/useScript/index.mjs +0 -4
  139. package/useScript/package.json +0 -7
  140. package/useScript/useScript.d.ts +0 -23
  141. package/useScript/useScript.mjs +0 -45
  142. package/useScrollLock/index.d.ts +0 -1
  143. package/useScrollLock/index.mjs +0 -4
  144. package/useScrollLock/package.json +0 -7
  145. package/useScrollLock/useScrollLock.d.ts +0 -53
  146. package/useScrollLock/useScrollLock.mjs +0 -26
  147. package/useSessionStorage/index.d.ts +0 -1
  148. package/useSessionStorage/index.mjs +0 -4
  149. package/useSessionStorage/package.json +0 -7
  150. package/useSessionStorage/useSessionStorage.d.ts +0 -39
  151. package/useSessionStorage/useSessionStorage.mjs +0 -65
  152. package/useStep/index.d.ts +0 -1
  153. package/useStep/index.mjs +0 -4
  154. package/useStep/package.json +0 -7
  155. package/useStep/useStep.d.ts +0 -31
  156. package/useStep/useStep.mjs +0 -34
  157. package/useTernaryDarkMode/index.d.ts +0 -1
  158. package/useTernaryDarkMode/index.mjs +0 -4
  159. package/useTernaryDarkMode/package.json +0 -7
  160. package/useTernaryDarkMode/useTernaryDarkMode.d.ts +0 -46
  161. package/useTernaryDarkMode/useTernaryDarkMode.mjs +0 -27
  162. package/useTimeout/index.d.ts +0 -1
  163. package/useTimeout/index.mjs +0 -4
  164. package/useTimeout/package.json +0 -7
  165. package/useTimeout/useTimeout.d.ts +0 -16
  166. package/useTimeout/useTimeout.mjs +0 -20
  167. package/useToggle/index.d.ts +0 -1
  168. package/useToggle/index.mjs +0 -4
  169. package/useToggle/package.json +0 -7
  170. package/useToggle/useToggle.d.ts +0 -18
  171. package/useToggle/useToggle.mjs +0 -10
  172. package/useUnmount/index.d.ts +0 -1
  173. package/useUnmount/index.mjs +0 -4
  174. package/useUnmount/package.json +0 -7
  175. package/useUnmount/useUnmount.d.ts +0 -13
  176. package/useUnmount/useUnmount.mjs +0 -13
  177. package/useWindowSize/index.d.ts +0 -1
  178. package/useWindowSize/index.mjs +0 -4
  179. package/useWindowSize/package.json +0 -7
  180. package/useWindowSize/useWindowSize.d.ts +0 -29
  181. package/useWindowSize/useWindowSize.mjs +0 -31
package/README.md CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  This library was generated with [Nx](https://nx.dev).
4
4
 
5
- ## Running unit tests
5
+ ## Building
6
6
 
7
- Run `nx test hooks` to execute the unit tests via [Vitest](https://vitest.dev/).
7
+ Run `nx build hooks` to build the library.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneplatformdev/hooks",
3
- "version": "0.0.1-beta.7",
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
- "homepage": "private package",
20
+ "license": "MIT",
21
21
  "type": "module",
22
- "source": "./index.ts",
23
- "main": "./index.mjs",
24
- "module": "./index.mjs",
25
- "default": "./index.mjs",
26
- "types": "./index.d.ts",
27
- "sideEffects": false,
28
- "publishConfig": {
29
- "directory": "build",
30
- "registry": "https://registry.npmjs.org/"
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
- "@types/lodash.debounce": {
46
- "optional": true
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
- "lodash.debounce": "^4.0.8"
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
- };
@@ -1 +0,0 @@
1
- export * from './useBoolean';
@@ -1,4 +0,0 @@
1
- import { useBoolean as r } from "./useBoolean.mjs";
2
- export {
3
- r as useBoolean
4
- };
@@ -1,7 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "main": "./index.mjs",
4
- "module": "./index.mjs",
5
- "default": "./index.mjs",
6
- "types": "./index.d.ts"
7
- }
@@ -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,4 +0,0 @@
1
- import { useClickAnyWhere as o } from "./useClickAnyWhere.mjs";
2
- export {
3
- o as useClickAnyWhere
4
- };
@@ -1,7 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "main": "./index.mjs",
4
- "module": "./index.mjs",
5
- "default": "./index.mjs",
6
- "types": "./index.d.ts"
7
- }
@@ -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,9 +0,0 @@
1
- import { useEventListener as n } from "../useEventListener/useEventListener.mjs";
2
- function t(e) {
3
- n("click", (i) => {
4
- e(i);
5
- });
6
- }
7
- export {
8
- t as useClickAnyWhere
9
- };
@@ -1 +0,0 @@
1
- export * from './useCopyToClipboard';
@@ -1,4 +0,0 @@
1
- import { useCopyToClipboard as r } from "./useCopyToClipboard.mjs";
2
- export {
3
- r as useCopyToClipboard
4
- };
@@ -1,7 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "main": "./index.mjs",
4
- "module": "./index.mjs",
5
- "default": "./index.mjs",
6
- "types": "./index.d.ts"
7
- }
@@ -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
- };
@@ -1 +0,0 @@
1
- export * from './useCountdown';
@@ -1,4 +0,0 @@
1
- import { useCountdown as n } from "./useCountdown.mjs";
2
- export {
3
- n as useCountdown
4
- };
@@ -1,7 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "main": "./index.mjs",
4
- "module": "./index.mjs",
5
- "default": "./index.mjs",
6
- "types": "./index.d.ts"
7
- }
@@ -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
- };
@@ -1 +0,0 @@
1
- export * from './useCounter';
@@ -1,4 +0,0 @@
1
- import { useCounter as r } from "./useCounter.mjs";
2
- export {
3
- r as useCounter
4
- };
@@ -1,7 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "main": "./index.mjs",
4
- "module": "./index.mjs",
5
- "default": "./index.mjs",
6
- "types": "./index.d.ts"
7
- }
@@ -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
- };
@@ -1 +0,0 @@
1
- export * from './useDarkMode';
@@ -1,4 +0,0 @@
1
- import { useDarkMode as r } from "./useDarkMode.mjs";
2
- export {
3
- r as useDarkMode
4
- };
@@ -1,7 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "main": "./index.mjs",
4
- "module": "./index.mjs",
5
- "default": "./index.mjs",
6
- "types": "./index.d.ts"
7
- }
@@ -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
- };
@@ -1,2 +0,0 @@
1
- export * from './useDebounceCallback';
2
- export { useDebounceCallback as default } from './useDebounceCallback';