@dxos/react-hooks 0.8.4-main.5ad4a44 → 0.8.4-main.66e292d
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/lib/browser/index.mjs +117 -88
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +117 -88
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/useControlledState.d.ts +2 -2
- package/dist/types/src/useControlledState.d.ts.map +1 -1
- package/dist/types/src/useDynamicRef.d.ts +3 -3
- package/dist/types/src/useDynamicRef.d.ts.map +1 -1
- package/dist/types/src/useForwardedRef.d.ts +23 -3
- package/dist/types/src/useForwardedRef.d.ts.map +1 -1
- package/dist/types/src/useMediaQuery.d.ts +1 -1
- package/dist/types/src/useMediaQuery.d.ts.map +1 -1
- package/dist/types/src/useSignals.d.ts.map +1 -1
- package/dist/types/src/useViewportResize.d.ts +3 -0
- package/dist/types/src/useViewportResize.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -4
- package/src/index.ts +3 -1
- package/src/useControlledState.ts +22 -12
- package/src/useDynamicRef.ts +3 -4
- package/src/useForwardedRef.ts +48 -13
- package/src/useMediaQuery.ts +7 -7
- package/src/useMulticastObservable.test.ts +1 -1
- package/src/useSignals.ts +1 -2
- package/src/{useResize.ts → useViewportResize.ts} +1 -1
- package/dist/types/src/useResize.d.ts +0 -3
- package/dist/types/src/useResize.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useControlledState.d.ts","sourceRoot":"","sources":["../../../src/useControlledState.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"useControlledState.d.ts","sourceRoot":"","sources":["../../../src/useControlledState.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAA4C,MAAM,OAAO,CAAC;AAIrG;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAClC,YAAY,CAAC,EACb,WAAW,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KAC5B,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAkBjC,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type Dispatch, type
|
|
1
|
+
import { type Dispatch, type RefObject, type SetStateAction } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* Like `useState` but with an additional dynamic value.
|
|
4
4
|
*/
|
|
5
|
-
export declare const useStateWithRef: <T>(valueParam: T) => [T, Dispatch<SetStateAction<T>>,
|
|
5
|
+
export declare const useStateWithRef: <T>(valueParam: T) => [T, Dispatch<SetStateAction<T>>, RefObject<T>];
|
|
6
6
|
/**
|
|
7
7
|
* Ref that is updated by a dependency.
|
|
8
8
|
*/
|
|
9
|
-
export declare const useDynamicRef: <T>(value: T) =>
|
|
9
|
+
export declare const useDynamicRef: <T>(value: T) => RefObject<T>;
|
|
10
10
|
//# sourceMappingURL=useDynamicRef.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDynamicRef.d.ts","sourceRoot":"","sources":["../../../src/useDynamicRef.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDynamicRef.d.ts","sourceRoot":"","sources":["../../../src/useDynamicRef.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAA4C,MAAM,OAAO,CAAC;AAErH;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,YAAY,CAAC,KAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAgB/F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,SAAS,CAAC,CAAC,CAOtD,CAAC"}
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
import { type ForwardedRef } from 'react';
|
|
1
|
+
import { type ForwardedRef, type Ref, type RefCallback } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* Combines a possibly undefined forwarded ref with a locally defined ref.
|
|
4
|
-
*
|
|
4
|
+
* Returns a stable ref object that synchronizes with the forwarded ref.
|
|
5
|
+
*
|
|
6
|
+
* Best practice: This hook creates a stable local ref and synchronizes it with the forwarded ref.
|
|
7
|
+
* The returned ref object is stable across renders, preventing infinite loops caused by ref identity changes.
|
|
8
|
+
*
|
|
9
|
+
* NOTE: This pattern doesn't update refs once they are set. If this is required, use `useMergeRefs`.
|
|
5
10
|
*/
|
|
6
|
-
export declare const useForwardedRef: <T>(
|
|
11
|
+
export declare const useForwardedRef: <T>(forwardedRef: ForwardedRef<T>) => import("react").RefObject<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Sets a value on a React ref, handling both callback refs and ref objects.
|
|
14
|
+
* Returns a cleanup function if the ref is a callback ref.
|
|
15
|
+
*/
|
|
16
|
+
export declare function setRef<T>(ref: Ref<T> | undefined | null, value: T | null): ReturnType<RefCallback<T>>;
|
|
17
|
+
/**
|
|
18
|
+
* Merges multiple refs into a single ref callback.
|
|
19
|
+
* Returns a ref callback that synchronizes all provided refs and handles cleanup.
|
|
20
|
+
*/
|
|
21
|
+
export declare const mergeRefs: <T>(refs: (Ref<T> | undefined)[]) => Ref<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Hook that merges multiple refs into a single stable ref callback.
|
|
24
|
+
* The returned ref is memoized and only changes when the refs array changes.
|
|
25
|
+
*/
|
|
26
|
+
export declare const useMergeRefs: <T>(refs: (Ref<T> | undefined)[]) => Ref<T>;
|
|
7
27
|
//# sourceMappingURL=useForwardedRef.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForwardedRef.d.ts","sourceRoot":"","sources":["../../../src/useForwardedRef.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"useForwardedRef.d.ts","sourceRoot":"","sources":["../../../src/useForwardedRef.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,GAAG,EAAE,KAAK,WAAW,EAA8B,MAAM,OAAO,CAAC;AAElG;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,cAAc,YAAY,CAAC,CAAC,CAAC,iCAO/D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAMrG;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,KAAG,GAAG,CAAC,CAAC,CAYhE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,KAAG,GAAG,CAAC,CAAC,CAEnE,CAAC"}
|
|
@@ -3,7 +3,7 @@ export type UseMediaQueryOptions = {
|
|
|
3
3
|
ssr?: boolean;
|
|
4
4
|
};
|
|
5
5
|
/**
|
|
6
|
-
* React hook that tracks state of a CSS media query
|
|
6
|
+
* React hook that tracks state of a CSS media query.
|
|
7
7
|
*
|
|
8
8
|
* @param query the media query to match, or a recognized breakpoint token
|
|
9
9
|
* @param options the media query options { fallback, ssr }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../../src/useMediaQuery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../../src/useMediaQuery.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC;IAC/B,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,GAAG,MAAM,EAAE,EAAE,UAAS,oBAAyB,KAAG,OAAO,EA0DnG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignals.d.ts","sourceRoot":"","sources":["../../../src/useSignals.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSignals.d.ts","sourceRoot":"","sources":["../../../src/useSignals.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,cAAc,EAA8B,MAAM,OAAO,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,IAAI,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE,OAAO,cAAc,SAQpF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,IAAI,MAAM,CAAC,EAAE,OAAO,cAAc,MAEnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useViewportResize.d.ts","sourceRoot":"","sources":["../../../src/useViewportResize.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAW,MAAM,OAAO,CAAC;AAEjD,eAAO,MAAM,iBAAiB,GAC5B,SAAS,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,EAChC,OAAM,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAM,EAChD,QAAO,MAAY,SAiBpB,CAAC"}
|