@pdg/react-hook 1.0.21 → 1.0.23
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/clearIntervalRef.d.ts +4 -0
- package/dist/clearTimeoutRef.d.ts +4 -0
- package/dist/index.d.ts +17 -13
- package/dist/index.esm.js +39 -5
- package/dist/index.js +39 -5
- package/dist/useAutoForceUpdate.d.ts +2 -1
- package/dist/useAutoUpdateLayoutRef.d.ts +2 -1
- package/dist/useAutoUpdateLayoutRefState.d.ts +4 -3
- package/dist/useAutoUpdateLayoutState.d.ts +4 -3
- package/dist/useAutoUpdateRef.d.ts +2 -1
- package/dist/useAutoUpdateRefState.d.ts +4 -3
- package/dist/useAutoUpdateState.d.ts +4 -3
- package/dist/useFirstSkipEffect.d.ts +2 -1
- package/dist/useFirstSkipLayoutEffect.d.ts +2 -1
- package/dist/useForceUpdate.d.ts +1 -1
- package/dist/useForwardRef.d.ts +2 -1
- package/dist/useIntervalRef.d.ts +8 -0
- package/dist/useLayoutPerformance.d.ts +2 -1
- package/dist/usePerformance.d.ts +2 -1
- package/dist/useTimeoutRef.d.ts +8 -0
- package/package.json +2 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
1
|
+
export * from './useAutoUpdateState';
|
|
2
|
+
export * from './useAutoUpdateLayoutState';
|
|
3
|
+
export * from './useFirstSkipEffect';
|
|
4
|
+
export * from './useFirstSkipLayoutEffect';
|
|
5
|
+
export * from './useAutoUpdateRefState';
|
|
6
|
+
export * from './useAutoUpdateLayoutRefState';
|
|
7
|
+
export * from './useForwardRef';
|
|
8
|
+
export * from './useAutoUpdateRef';
|
|
9
|
+
export * from './useAutoUpdateLayoutRef';
|
|
10
|
+
export * from './usePerformance';
|
|
11
|
+
export * from './useLayoutPerformance';
|
|
12
|
+
export * from './useAutoForceUpdate';
|
|
13
|
+
export * from './useForceUpdate';
|
|
14
|
+
export * from './useTimeoutRef';
|
|
15
|
+
export * from './clearTimeoutRef';
|
|
16
|
+
export * from './useIntervalRef';
|
|
17
|
+
export * from './clearIntervalRef';
|
package/dist/index.esm.js
CHANGED
|
@@ -174,9 +174,43 @@ function useAutoUpdateLayoutRefState(state, callback) {
|
|
|
174
174
|
clearInterval(tm);
|
|
175
175
|
};
|
|
176
176
|
}, [interval]);
|
|
177
|
-
}function
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
}function clearTimeoutRef(ref) {
|
|
178
|
+
if (ref.current) {
|
|
179
|
+
clearTimeout(ref.current);
|
|
180
|
+
ref.current = undefined;
|
|
181
|
+
}
|
|
182
|
+
}function useTimeoutRef() {
|
|
183
|
+
var ref = useRef();
|
|
184
|
+
useEffect(function () {
|
|
185
|
+
return function () {
|
|
186
|
+
clearTimeoutRef(ref);
|
|
187
|
+
};
|
|
188
|
+
}, []);
|
|
189
|
+
var setTimeoutFunc = useCallback(function (callback, ms) {
|
|
190
|
+
clearTimeoutRef(ref);
|
|
191
|
+
ref.current = setTimeout(function () {
|
|
192
|
+
ref.current = undefined;
|
|
193
|
+
callback();
|
|
194
|
+
}, ms);
|
|
195
|
+
}, []);
|
|
196
|
+
return [ref, setTimeoutFunc];
|
|
197
|
+
}function clearIntervalRef(ref) {
|
|
198
|
+
if (ref.current) {
|
|
199
|
+
clearInterval(ref.current);
|
|
200
|
+
ref.current = undefined;
|
|
201
|
+
}
|
|
202
|
+
}function useIntervalRef() {
|
|
203
|
+
var ref = useRef();
|
|
204
|
+
useEffect(function () {
|
|
205
|
+
return function () {
|
|
206
|
+
clearIntervalRef(ref);
|
|
207
|
+
};
|
|
208
|
+
}, []);
|
|
209
|
+
var setIntervalFunc = useCallback(function (callback, ms) {
|
|
210
|
+
clearIntervalRef(ref);
|
|
211
|
+
ref.current = setInterval(function () {
|
|
212
|
+
callback(ref);
|
|
213
|
+
}, ms);
|
|
181
214
|
}, []);
|
|
182
|
-
|
|
215
|
+
return [ref, setIntervalFunc];
|
|
216
|
+
}export{clearIntervalRef,clearTimeoutRef,useAutoForceUpdate,useAutoUpdateLayoutRef,useAutoUpdateLayoutRefState,useAutoUpdateLayoutState,useAutoUpdateRef,useAutoUpdateRefState,useAutoUpdateState,useFirstSkipEffect,useFirstSkipLayoutEffect,useForwardRef,useIntervalRef,useLayoutPerformance,usePerformance,useTimeoutRef};
|
package/dist/index.js
CHANGED
|
@@ -174,9 +174,43 @@ function useAutoUpdateLayoutRefState(state, callback) {
|
|
|
174
174
|
clearInterval(tm);
|
|
175
175
|
};
|
|
176
176
|
}, [interval]);
|
|
177
|
-
}function
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
}function clearTimeoutRef(ref) {
|
|
178
|
+
if (ref.current) {
|
|
179
|
+
clearTimeout(ref.current);
|
|
180
|
+
ref.current = undefined;
|
|
181
|
+
}
|
|
182
|
+
}function useTimeoutRef() {
|
|
183
|
+
var ref = react.useRef();
|
|
184
|
+
react.useEffect(function () {
|
|
185
|
+
return function () {
|
|
186
|
+
clearTimeoutRef(ref);
|
|
187
|
+
};
|
|
188
|
+
}, []);
|
|
189
|
+
var setTimeoutFunc = react.useCallback(function (callback, ms) {
|
|
190
|
+
clearTimeoutRef(ref);
|
|
191
|
+
ref.current = setTimeout(function () {
|
|
192
|
+
ref.current = undefined;
|
|
193
|
+
callback();
|
|
194
|
+
}, ms);
|
|
195
|
+
}, []);
|
|
196
|
+
return [ref, setTimeoutFunc];
|
|
197
|
+
}function clearIntervalRef(ref) {
|
|
198
|
+
if (ref.current) {
|
|
199
|
+
clearInterval(ref.current);
|
|
200
|
+
ref.current = undefined;
|
|
201
|
+
}
|
|
202
|
+
}function useIntervalRef() {
|
|
203
|
+
var ref = react.useRef();
|
|
204
|
+
react.useEffect(function () {
|
|
205
|
+
return function () {
|
|
206
|
+
clearIntervalRef(ref);
|
|
207
|
+
};
|
|
208
|
+
}, []);
|
|
209
|
+
var setIntervalFunc = react.useCallback(function (callback, ms) {
|
|
210
|
+
clearIntervalRef(ref);
|
|
211
|
+
ref.current = setInterval(function () {
|
|
212
|
+
callback(ref);
|
|
213
|
+
}, ms);
|
|
181
214
|
}, []);
|
|
182
|
-
|
|
215
|
+
return [ref, setIntervalFunc];
|
|
216
|
+
}exports.clearIntervalRef=clearIntervalRef;exports.clearTimeoutRef=clearTimeoutRef;exports.useAutoForceUpdate=useAutoForceUpdate;exports.useAutoUpdateLayoutRef=useAutoUpdateLayoutRef;exports.useAutoUpdateLayoutRefState=useAutoUpdateLayoutRefState;exports.useAutoUpdateLayoutState=useAutoUpdateLayoutState;exports.useAutoUpdateRef=useAutoUpdateRef;exports.useAutoUpdateRefState=useAutoUpdateRefState;exports.useAutoUpdateState=useAutoUpdateState;exports.useFirstSkipEffect=useFirstSkipEffect;exports.useFirstSkipLayoutEffect=useFirstSkipLayoutEffect;exports.useForwardRef=useForwardRef;exports.useIntervalRef=useIntervalRef;exports.useLayoutPerformance=useLayoutPerformance;exports.usePerformance=usePerformance;exports.useTimeoutRef=useTimeoutRef;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function useAutoForceUpdate(name: string, interval: number): void;
|
|
2
|
+
export default useAutoForceUpdate;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { MutableRefObject, SetStateAction } from 'react';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
2
|
+
export declare function useAutoUpdateLayoutRefState<T>(state: Exclude<T, (...args: any[]) => any>): [MutableRefObject<T>, T, (value: SetStateAction<T>) => T];
|
|
3
|
+
export declare function useAutoUpdateLayoutRefState<T>(state: Exclude<T, (...args: any[]) => any>, callback: (state: T) => T): [MutableRefObject<T>, T, (value: SetStateAction<T>, skipCallback?: boolean) => T];
|
|
4
|
+
export declare function useAutoUpdateLayoutRefState<T = never, StateT = never>(state: Exclude<StateT, (...args: any[]) => any>, callback: (state: T | StateT) => T extends never ? StateT : T): [
|
|
5
5
|
MutableRefObject<T extends never ? StateT : T>,
|
|
6
6
|
T extends never ? StateT : T,
|
|
7
7
|
(value: SetStateAction<T | StateT>, skipCallback?: boolean) => T extends never ? StateT : T
|
|
8
8
|
];
|
|
9
|
+
export default useAutoUpdateLayoutRefState;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SetStateAction } from 'react';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
2
|
+
export declare function useAutoUpdateLayoutState<T>(state: Exclude<T, (...args: any[]) => any>): [T, (value: SetStateAction<T>) => T];
|
|
3
|
+
export declare function useAutoUpdateLayoutState<T>(state: Exclude<T, (...args: any[]) => any>, callback: (state: T) => T): [T, (value: SetStateAction<T>, skipCallback?: boolean) => T];
|
|
4
|
+
export declare function useAutoUpdateLayoutState<T = never, StateT = never>(state: Exclude<StateT, (...args: any[]) => any>, callback: (state: T | StateT) => T extends never ? StateT : T): [
|
|
5
5
|
T extends never ? StateT : T,
|
|
6
6
|
(value: SetStateAction<T | StateT>, skipCallback?: boolean) => T extends never ? StateT : T
|
|
7
7
|
];
|
|
8
|
+
export default useAutoUpdateLayoutState;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { MutableRefObject, SetStateAction } from 'react';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
2
|
+
export declare function useAutoUpdateRefState<T>(state: Exclude<T, (...args: any[]) => any>): [MutableRefObject<T>, T, (value: SetStateAction<T>) => T];
|
|
3
|
+
export declare function useAutoUpdateRefState<T>(state: Exclude<T, (...args: any[]) => any>, callback: (state: T) => T): [MutableRefObject<T>, T, (value: SetStateAction<T>, skipCallback?: boolean) => T];
|
|
4
|
+
export declare function useAutoUpdateRefState<T = never, StateT = never>(state: Exclude<StateT, (...args: any[]) => any>, callback: (state: T | StateT) => T extends never ? StateT : T): [
|
|
5
5
|
MutableRefObject<T extends never ? StateT : T>,
|
|
6
6
|
T extends never ? StateT : T,
|
|
7
7
|
(value: SetStateAction<T | StateT>, skipCallback?: boolean) => T extends never ? StateT : T
|
|
8
8
|
];
|
|
9
|
+
export default useAutoUpdateRefState;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SetStateAction } from 'react';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
2
|
+
export declare function useAutoUpdateState<T>(state: Exclude<T, (...args: any[]) => any>): [T, (value: SetStateAction<T>) => T];
|
|
3
|
+
export declare function useAutoUpdateState<T>(state: Exclude<T, (...args: any[]) => any>, callback: (state: T) => T): [T, (value: SetStateAction<T>, skipCallback?: boolean) => T];
|
|
4
|
+
export declare function useAutoUpdateState<T = never, StateT = never>(state: Exclude<StateT, (...args: any[]) => any>, callback: (state: T | StateT) => T extends never ? StateT : T): [
|
|
5
5
|
T extends never ? StateT : T,
|
|
6
6
|
(value: SetStateAction<T | StateT>, skipCallback?: boolean) => T extends never ? StateT : T
|
|
7
7
|
];
|
|
8
|
+
export default useAutoUpdateState;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { DependencyList, EffectCallback } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export declare function useFirstSkipEffect(effect: EffectCallback, deps?: DependencyList): void;
|
|
3
|
+
export default useFirstSkipEffect;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { DependencyList, EffectCallback } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export declare function useFirstSkipLayoutEffect(effect: EffectCallback, deps?: DependencyList): void;
|
|
3
|
+
export default useFirstSkipLayoutEffect;
|
package/dist/useForceUpdate.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function useForceUpdate(): () => void;
|
|
1
|
+
export default function useForceUpdate(delay?: number): () => void;
|
package/dist/useForwardRef.d.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type UseIntervalReturnValue = [
|
|
4
|
+
React.MutableRefObject<NodeJS.Timeout | undefined>,
|
|
5
|
+
(callback: (ref: React.MutableRefObject<NodeJS.Timeout | undefined>) => void, ms?: number) => void
|
|
6
|
+
];
|
|
7
|
+
export declare function useIntervalRef(): UseIntervalReturnValue;
|
|
8
|
+
export default useIntervalRef;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function useLayoutPerformance(name: string): void;
|
|
2
|
+
export default useLayoutPerformance;
|
package/dist/usePerformance.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function usePerformance(name: string): void;
|
|
2
|
+
export default usePerformance;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type UseTimeoutReturnValue = [
|
|
4
|
+
React.MutableRefObject<NodeJS.Timeout | undefined>,
|
|
5
|
+
(callback: (args: void) => void, ms?: number) => void
|
|
6
|
+
];
|
|
7
|
+
export declare function useTimeoutRef(): UseTimeoutReturnValue;
|
|
8
|
+
export default useTimeoutRef;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdg/react-hook",
|
|
3
3
|
"title": "React Hook",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.23",
|
|
5
5
|
"description": "React Hook",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -40,8 +40,7 @@
|
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@pdg/util": "^1.0.22",
|
|
42
42
|
"@types/react": "^17.0.0 || ^18.0.0",
|
|
43
|
-
"react": "^17.0.0 || ^18.0.0"
|
|
44
|
-
"react-dom": "^17.0.0 || ^18.0.0"
|
|
43
|
+
"react": "^17.0.0 || ^18.0.0"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@rollup/plugin-commonjs": "^25.0.7",
|