@purr-core/hooks.sync-state-with-props 0.0.7 → 0.0.9

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/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const r=require("react"),a=(t,e=!1)=>{const[u,s]=r.useState(t),c=r.useCallback(n=>{e&&s(n)},[e]);return{currentValue:e?u:t,setCurrentValue:c}};module.exports=a;
1
+ 'use strict';var react=require('react');var l=(t,e=false)=>{let[r,u]=react.useState(t),V=react.useCallback(a=>{e&&u(a);},[e]);return {currentValue:e?r:t,setCurrentValue:V}},o=l;module.exports=o;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The return type of the useSyncStateWithProps hook.
3
+ *
4
+ * @interface ISyncStateWithPropsReturnType<V>
5
+ * @property {V} currentValue - The current value.
6
+ * @property {function} setCurrentValue - The function to set the current value.
7
+ */
8
+ interface ISyncStateWithPropsReturnType<V> {
9
+ currentValue: V;
10
+ setCurrentValue: (value: V) => void;
11
+ }
12
+ /**
13
+ * A hook that syncs the value with the props.
14
+ *
15
+ * @param {V} value - The value to sync.
16
+ * @param {boolean} [isStandalone=false] - Whether the value is standalone.
17
+ * @returns {ISyncStateWithPropsReturnType<V>} The return value of the hook.
18
+ */
19
+ declare const useSyncStateWithProps: <V>(value: V, isStandalone?: boolean) => ISyncStateWithPropsReturnType<V>;
20
+
21
+ export { useSyncStateWithProps as default };
package/dist/index.d.ts CHANGED
@@ -1 +1,21 @@
1
- export { default } from './_hook';
1
+ /**
2
+ * The return type of the useSyncStateWithProps hook.
3
+ *
4
+ * @interface ISyncStateWithPropsReturnType<V>
5
+ * @property {V} currentValue - The current value.
6
+ * @property {function} setCurrentValue - The function to set the current value.
7
+ */
8
+ interface ISyncStateWithPropsReturnType<V> {
9
+ currentValue: V;
10
+ setCurrentValue: (value: V) => void;
11
+ }
12
+ /**
13
+ * A hook that syncs the value with the props.
14
+ *
15
+ * @param {V} value - The value to sync.
16
+ * @param {boolean} [isStandalone=false] - Whether the value is standalone.
17
+ * @returns {ISyncStateWithPropsReturnType<V>} The return value of the hook.
18
+ */
19
+ declare const useSyncStateWithProps: <V>(value: V, isStandalone?: boolean) => ISyncStateWithPropsReturnType<V>;
20
+
21
+ export { useSyncStateWithProps as default };
package/dist/index.js CHANGED
@@ -1,16 +1 @@
1
- import { useState as c, useCallback as l } from "react";
2
- const o = (t, e = !1) => {
3
- const [r, u] = c(t), s = l(
4
- (a) => {
5
- e && u(a);
6
- },
7
- [e]
8
- );
9
- return {
10
- currentValue: e ? r : t,
11
- setCurrentValue: s
12
- };
13
- };
14
- export {
15
- o as default
16
- };
1
+ import {useState,useCallback}from'react';var l=(t,e=false)=>{let[r,u]=useState(t),V=useCallback(a=>{e&&u(a);},[e]);return {currentValue:e?r:t,setCurrentValue:V}},o=l;export{o as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purr-core/hooks.sync-state-with-props",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -31,6 +31,8 @@
31
31
  "scripts": {
32
32
  "dev": "vite build --watch",
33
33
  "build": "tsc && vite build",
34
+ "build:vite": "tsc && vite build",
35
+ "build:tsup": "tsup",
34
36
  "lint": "eslint . --ext ts,tsx --max-warnings 0"
35
37
  }
36
38
  }
package/dist/_hook.d.ts DELETED
@@ -1,5 +0,0 @@
1
- declare const useSyncStateWithProps: <V>(value: V, isStandalone?: boolean) => {
2
- currentValue: V;
3
- setCurrentValue: (value: V) => void;
4
- };
5
- export default useSyncStateWithProps;