@willbooster/shared-lib-react 3.2.10 → 3.2.11

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.
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react");exports.useInterval=function(r,t){const s=e.useRef(),a=e.useCallback((()=>{globalThis.clearInterval(s.current)}),[]);return e.useEffect((()=>(void 0!==t&&(s.current=globalThis.setInterval(r,t)),a)),[t]),a};
1
+ "use strict";var e=require("react");exports.useInterval=function(r,t){const s=e.useRef(),u=e.useRef(r);u.current=r;const c=e.useCallback((()=>{globalThis.clearInterval(s.current)}),[]);return e.useEffect((()=>(void 0!==t&&(s.current=globalThis.setInterval((()=>u.current()),t)),c)),[t]),c};
2
2
  //# sourceMappingURL=useInterval.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useInterval.cjs","sources":["../../src/hooks/useInterval.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\n\nexport function useInterval(nonReactiveCallback: () => void, reactiveMilliseconds?: number): () => void {\n const timerId = useRef<number | NodeJS.Timeout>();\n\n const clearInterval = useCallback(() => {\n globalThis.clearInterval(timerId.current);\n }, []);\n\n useEffect(() => {\n if (reactiveMilliseconds !== undefined) {\n timerId.current = globalThis.setInterval(nonReactiveCallback, reactiveMilliseconds);\n }\n return clearInterval;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [reactiveMilliseconds]);\n\n return clearInterval;\n}\n"],"names":["nonReactiveCallback","reactiveMilliseconds","timerId","useRef","clearInterval","useCallback","globalThis","current","useEffect","undefined","setInterval"],"mappings":"wDAEO,SAAqBA,EAAiCC,GAC3D,MAAMC,EAAUC,EAAAA,SAEVC,EAAgBC,EAAAA,aAAY,KAChCC,WAAWF,cAAcF,EAAQK,QAAQ,GACxC,IAUH,OARAC,EAAAA,WAAU,UACqBC,IAAzBR,IACFC,EAAQK,QAAUD,WAAWI,YAAYV,EAAqBC,IAEzDG,IAEN,CAACH,IAEGG,CACT"}
1
+ {"version":3,"file":"useInterval.cjs","sources":["../../src/hooks/useInterval.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\n\n/**\n * A custom React hook that sets up an interval and returns a function to clear it.\n *\n * This hook ensures that the latest callback is always used, even if it changes between renders.\n * The interval can be dynamically started, stopped, or adjusted by changing the `milliseconds` parameter.\n *\n * @param callback - The function to be called at each interval. It is guaranteed to be the most recent version.\n * @param milliseconds - The interval duration in milliseconds. If undefined, the interval is cleared.\n * @returns A function to manually clear the interval.\n *\n * @example\n * const clearInterval = useInterval(() => {\n * console.log('This will run every 1000ms');\n * }, 1000);\n *\n * // To manually stop the interval:\n * clearInterval();\n */\nexport function useInterval(callback: () => void, milliseconds?: number): () => void {\n const timerId = useRef<number | NodeJS.Timeout>();\n const callbackRef = useRef(callback);\n callbackRef.current = callback;\n\n const clearInterval = useCallback(() => {\n globalThis.clearInterval(timerId.current);\n }, []);\n\n useEffect(() => {\n if (milliseconds !== undefined) {\n timerId.current = globalThis.setInterval(() => callbackRef.current(), milliseconds);\n }\n return clearInterval;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [milliseconds]);\n\n return clearInterval;\n}\n"],"names":["callback","milliseconds","timerId","useRef","callbackRef","current","clearInterval","useCallback","globalThis","useEffect","undefined","setInterval"],"mappings":"wDAoBO,SAAqBA,EAAsBC,GAChD,MAAMC,EAAUC,EAAAA,SACVC,EAAcD,SAAOH,GAC3BI,EAAYC,QAAUL,EAEtB,MAAMM,EAAgBC,EAAAA,aAAY,KAChCC,WAAWF,cAAcJ,EAAQG,QAAQ,GACxC,IAUH,OARAI,EAAAA,WAAU,UACaC,IAAjBT,IACFC,EAAQG,QAAUG,WAAWG,aAAY,IAAMP,EAAYC,WAAWJ,IAEjEK,IAEN,CAACL,IAEGK,CACT"}
@@ -1 +1,19 @@
1
- export declare function useInterval(nonReactiveCallback: () => void, reactiveMilliseconds?: number): () => void;
1
+ /**
2
+ * A custom React hook that sets up an interval and returns a function to clear it.
3
+ *
4
+ * This hook ensures that the latest callback is always used, even if it changes between renders.
5
+ * The interval can be dynamically started, stopped, or adjusted by changing the `milliseconds` parameter.
6
+ *
7
+ * @param callback - The function to be called at each interval. It is guaranteed to be the most recent version.
8
+ * @param milliseconds - The interval duration in milliseconds. If undefined, the interval is cleared.
9
+ * @returns A function to manually clear the interval.
10
+ *
11
+ * @example
12
+ * const clearInterval = useInterval(() => {
13
+ * console.log('This will run every 1000ms');
14
+ * }, 1000);
15
+ *
16
+ * // To manually stop the interval:
17
+ * clearInterval();
18
+ */
19
+ export declare function useInterval(callback: () => void, milliseconds?: number): () => void;
@@ -1,2 +1,2 @@
1
- import{useRef as r,useCallback as t,useEffect as e}from"react";function n(n,o){const l=r(),a=t((()=>{globalThis.clearInterval(l.current)}),[]);return e((()=>(void 0!==o&&(l.current=globalThis.setInterval(n,o)),a)),[o]),a}export{n as useInterval};
1
+ import{useRef as r,useCallback as t,useEffect as e}from"react";function n(n,c){const o=r(),l=r(n);l.current=n;const a=t((()=>{globalThis.clearInterval(o.current)}),[]);return e((()=>(void 0!==c&&(o.current=globalThis.setInterval((()=>l.current()),c)),a)),[c]),a}export{n as useInterval};
2
2
  //# sourceMappingURL=useInterval.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useInterval.js","sources":["../../src/hooks/useInterval.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\n\nexport function useInterval(nonReactiveCallback: () => void, reactiveMilliseconds?: number): () => void {\n const timerId = useRef<number | NodeJS.Timeout>();\n\n const clearInterval = useCallback(() => {\n globalThis.clearInterval(timerId.current);\n }, []);\n\n useEffect(() => {\n if (reactiveMilliseconds !== undefined) {\n timerId.current = globalThis.setInterval(nonReactiveCallback, reactiveMilliseconds);\n }\n return clearInterval;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [reactiveMilliseconds]);\n\n return clearInterval;\n}\n"],"names":["useInterval","nonReactiveCallback","reactiveMilliseconds","timerId","useRef","clearInterval","useCallback","globalThis","current","useEffect","undefined","setInterval"],"mappings":"+DAEO,SAASA,EAAYC,EAAiCC,GAC3D,MAAMC,EAAUC,IAEVC,EAAgBC,GAAY,KAChCC,WAAWF,cAAcF,EAAQK,QAAQ,GACxC,IAUH,OARAC,GAAU,UACqBC,IAAzBR,IACFC,EAAQK,QAAUD,WAAWI,YAAYV,EAAqBC,IAEzDG,IAEN,CAACH,IAEGG,CACT"}
1
+ {"version":3,"file":"useInterval.js","sources":["../../src/hooks/useInterval.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\n\n/**\n * A custom React hook that sets up an interval and returns a function to clear it.\n *\n * This hook ensures that the latest callback is always used, even if it changes between renders.\n * The interval can be dynamically started, stopped, or adjusted by changing the `milliseconds` parameter.\n *\n * @param callback - The function to be called at each interval. It is guaranteed to be the most recent version.\n * @param milliseconds - The interval duration in milliseconds. If undefined, the interval is cleared.\n * @returns A function to manually clear the interval.\n *\n * @example\n * const clearInterval = useInterval(() => {\n * console.log('This will run every 1000ms');\n * }, 1000);\n *\n * // To manually stop the interval:\n * clearInterval();\n */\nexport function useInterval(callback: () => void, milliseconds?: number): () => void {\n const timerId = useRef<number | NodeJS.Timeout>();\n const callbackRef = useRef(callback);\n callbackRef.current = callback;\n\n const clearInterval = useCallback(() => {\n globalThis.clearInterval(timerId.current);\n }, []);\n\n useEffect(() => {\n if (milliseconds !== undefined) {\n timerId.current = globalThis.setInterval(() => callbackRef.current(), milliseconds);\n }\n return clearInterval;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [milliseconds]);\n\n return clearInterval;\n}\n"],"names":["useInterval","callback","milliseconds","timerId","useRef","callbackRef","current","clearInterval","useCallback","globalThis","useEffect","undefined","setInterval"],"mappings":"+DAoBO,SAASA,EAAYC,EAAsBC,GAChD,MAAMC,EAAUC,IACVC,EAAcD,EAAOH,GAC3BI,EAAYC,QAAUL,EAEtB,MAAMM,EAAgBC,GAAY,KAChCC,WAAWF,cAAcJ,EAAQG,QAAQ,GACxC,IAUH,OARAI,GAAU,UACaC,IAAjBT,IACFC,EAAQG,QAAUG,WAAWG,aAAY,IAAMP,EAAYC,WAAWJ,IAEjEK,IAEN,CAACL,IAEGK,CACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/shared-lib-react",
3
- "version": "3.2.10",
3
+ "version": "3.2.11",
4
4
  "license": "Apache-2.0",
5
5
  "author": "WillBooster Inc.",
6
6
  "sideEffects": false,
@@ -33,36 +33,36 @@
33
33
  },
34
34
  "prettier": "@willbooster/prettier-config",
35
35
  "devDependencies": {
36
- "@babel/core": "7.25.2",
36
+ "@babel/core": "7.25.8",
37
37
  "@mdx-js/react": "3.0.1",
38
- "@storybook/addon-actions": "8.2.9",
39
- "@storybook/addon-docs": "8.2.9",
40
- "@storybook/addon-essentials": "8.2.9",
41
- "@storybook/addon-interactions": "8.2.9",
42
- "@storybook/addon-links": "8.2.9",
38
+ "@storybook/addon-actions": "8.3.5",
39
+ "@storybook/addon-docs": "8.3.5",
40
+ "@storybook/addon-essentials": "8.3.5",
41
+ "@storybook/addon-interactions": "8.3.5",
42
+ "@storybook/addon-links": "8.3.5",
43
43
  "@storybook/builder-webpack4": "6.5.16",
44
44
  "@storybook/manager-webpack4": "6.5.16",
45
- "@storybook/react": "8.2.9",
45
+ "@storybook/react": "8.3.5",
46
46
  "@storybook/testing-library": "0.2.2",
47
47
  "@types/eslint": "8.56.10",
48
48
  "@types/micromatch": "4.0.9",
49
- "@types/react": "18.3.5",
50
- "@types/react-dom": "18.3.0",
51
- "@typescript-eslint/eslint-plugin": "8.3.0",
52
- "@typescript-eslint/parser": "8.3.0",
49
+ "@types/react": "18.3.11",
50
+ "@types/react-dom": "18.3.1",
51
+ "@typescript-eslint/eslint-plugin": "8.9.0",
52
+ "@typescript-eslint/parser": "8.9.0",
53
53
  "@willbooster/eslint-config-ts-react": "10.2.0",
54
54
  "@willbooster/prettier-config": "9.1.2",
55
- "babel-loader": "9.1.3",
55
+ "babel-loader": "9.2.1",
56
56
  "build-ts": "13.1.8",
57
57
  "eslint": "8.57.0",
58
58
  "eslint-config-prettier": "9.1.0",
59
59
  "eslint-import-resolver-typescript": "3.6.3",
60
- "eslint-plugin-import": "2.29.1",
61
- "eslint-plugin-react": "7.35.0",
60
+ "eslint-plugin-import": "2.31.0",
61
+ "eslint-plugin-react": "7.37.1",
62
62
  "eslint-plugin-react-hooks": "4.6.2",
63
63
  "eslint-plugin-sort-class-members": "1.20.0",
64
64
  "eslint-plugin-sort-destructure-keys": "2.0.0",
65
- "eslint-plugin-storybook": "0.8.0",
65
+ "eslint-plugin-storybook": "0.9.0",
66
66
  "eslint-plugin-unicorn": "55.0.0",
67
67
  "lint-staged": "15.2.10",
68
68
  "micromatch": "4.0.8",
@@ -70,8 +70,8 @@
70
70
  "react": "18.3.1",
71
71
  "react-dom": "18.3.1",
72
72
  "sort-package-json": "2.10.1",
73
- "typescript": "5.5.4",
74
- "vitest": "2.0.5"
73
+ "typescript": "5.6.3",
74
+ "vitest": "2.1.3"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "react": "~18.2.0 || ~18.3.0",