use-good-hooks 1.0.34 → 1.0.35
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/dist/use-debounce.d.ts +1 -1
- package/dist/use-debounce.js +2 -2
- package/dist/use-history-state.d.ts +1 -1
- package/dist/use-history-state.js +8 -8
- package/dist/use-temporary-state.d.ts +1 -1
- package/dist/use-temporary-state.js +4 -4
- package/dist/use-throttle.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -244,7 +244,7 @@ const TextEditor = () => {
|
|
|
244
244
|
- `initialState`: The initial state value
|
|
245
245
|
- `options`: (Optional) Configuration options:
|
|
246
246
|
- `debounceSettings`: Debounce settings object (default: { leading: true, trailing: false })
|
|
247
|
-
- `
|
|
247
|
+
- `debounceMs`: Time in milliseconds to debounce the state changes (default: 0)
|
|
248
248
|
- `immutable`: Boolean indicating if the state should be treated as immutable (default: false)
|
|
249
249
|
- `maxCapacity`: Maximum number of history entries to keep (default: 10)
|
|
250
250
|
- `onChange`: Function to call when the state changes
|
|
@@ -516,7 +516,7 @@ const [state, setState] = useTemporaryState('initial', 1000);
|
|
|
516
516
|
#### Parameters
|
|
517
517
|
|
|
518
518
|
- `initialState`: The initial state value
|
|
519
|
-
- `
|
|
519
|
+
- `ms`: The timeout duration in milliseconds (default: 3000)
|
|
520
520
|
|
|
521
521
|
#### Returns
|
|
522
522
|
|
package/dist/use-debounce.d.ts
CHANGED
package/dist/use-debounce.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState as s, useRef as d, useEffect as n } from "react";
|
|
2
2
|
import f from "lodash/debounce";
|
|
3
|
-
const b = 300,
|
|
3
|
+
const b = 300, p = (e, o = b) => {
|
|
4
4
|
const [u, r] = s(e), c = d(
|
|
5
5
|
f((t) => {
|
|
6
6
|
r(t);
|
|
@@ -16,5 +16,5 @@ const b = 300, D = (e, o = b) => {
|
|
|
16
16
|
}, []), u;
|
|
17
17
|
};
|
|
18
18
|
export {
|
|
19
|
-
|
|
19
|
+
p as default
|
|
20
20
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { useRef as M, useReducer as T, useCallback as d } from "react";
|
|
2
|
+
import H from "lodash/cloneDeep";
|
|
3
|
+
import J from "lodash/isNil";
|
|
4
4
|
import E from "lodash/size";
|
|
5
5
|
import k from "./use-debounce-fn.js";
|
|
6
6
|
const q = {
|
|
7
7
|
future: [],
|
|
8
8
|
past: [],
|
|
9
9
|
present: null
|
|
10
|
-
}, l = (e, r) => r ? e :
|
|
10
|
+
}, l = (e, r) => r ? e : H(e), v = (e, r, y) => y ? e === r : JSON.stringify(e) === JSON.stringify(r), z = ({
|
|
11
11
|
action: e,
|
|
12
12
|
immutable: r,
|
|
13
13
|
maxCapacity: y,
|
|
@@ -77,7 +77,7 @@ const q = {
|
|
|
77
77
|
}), w;
|
|
78
78
|
}
|
|
79
79
|
let u = [...n];
|
|
80
|
-
p !== null && (u = [...u, l(p, r)]), !
|
|
80
|
+
p !== null && (u = [...u, l(p, r)]), !J(y) && y > 0 && E(u) > y && (u = u.slice(E(u) - y));
|
|
81
81
|
const c = {
|
|
82
82
|
future: [],
|
|
83
83
|
past: u,
|
|
@@ -106,9 +106,9 @@ const q = {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}, G = (e, r) => {
|
|
109
|
-
const { maxCapacity: y,
|
|
110
|
-
(i,
|
|
111
|
-
action:
|
|
109
|
+
const { maxCapacity: y, debounceMs: t, debounceSettings: f, onChange: o, immutable: n } = r || {}, S = M(e), [p, s] = T(
|
|
110
|
+
(i, F) => z({
|
|
111
|
+
action: F,
|
|
112
112
|
immutable: n,
|
|
113
113
|
maxCapacity: y,
|
|
114
114
|
onChange: o,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Dispatch } from 'react';
|
|
2
2
|
import { SetStateAction } from 'react';
|
|
3
3
|
|
|
4
|
-
declare const useTemporaryState: <T>(initialState: T,
|
|
4
|
+
declare const useTemporaryState: <T>(initialState: T, ms: number) => readonly [T, Dispatch<SetStateAction<T>>];
|
|
5
5
|
export default useTemporaryState;
|
|
6
6
|
|
|
7
7
|
export { }
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { useRef as
|
|
1
|
+
import { useRef as s, useState as c, useEffect as n } from "react";
|
|
2
2
|
const m = (e, r) => {
|
|
3
|
-
const t =
|
|
3
|
+
const t = s(null), [u, o] = c(e);
|
|
4
4
|
return n(() => (clearTimeout(t.current), t.current = setTimeout(() => {
|
|
5
|
-
|
|
5
|
+
o(e);
|
|
6
6
|
}, r), () => {
|
|
7
7
|
clearTimeout(t.current);
|
|
8
|
-
}), [e, u, r]), [u,
|
|
8
|
+
}), [e, u, r]), [u, o];
|
|
9
9
|
};
|
|
10
10
|
export {
|
|
11
11
|
m as default
|
package/dist/use-throttle.d.ts
CHANGED
package/package.json
CHANGED