@xyo-network/react-shared 2.37.24 → 2.37.26

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.
@@ -2,4 +2,5 @@ export * from './GradientStyles';
2
2
  export * from './useDataState';
3
3
  export * from './useIsMobile';
4
4
  export * from './useMediaQuery';
5
+ export * from './useShareForwardRef';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA"}
@@ -2,4 +2,5 @@ export * from './GradientStyles';
2
2
  export * from './useDataState';
3
3
  export * from './useIsMobile';
4
4
  export * from './useMediaQuery';
5
+ export * from './useShareForwardRef';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { ForwardedRef } from 'react';
2
+ export declare const useShareForwardedRef: <T>(forwardedRef: ForwardedRef<T>, refresh?: number) => import("react").RefObject<T>;
3
+ //# sourceMappingURL=useShareForwardRef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useShareForwardRef.d.ts","sourceRoot":"","sources":["../../../src/hooks/useShareForwardRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAqB,MAAM,OAAO,CAAA;AAEvD,eAAO,MAAM,oBAAoB,sFAiBhC,CAAA"}
@@ -0,0 +1,19 @@
1
+ import { useEffect, useRef } from 'react';
2
+ export const useShareForwardedRef = (forwardedRef, refresh = 0) => {
3
+ // final ref that will share value with forward ref. this is the one to be attached to components
4
+ const innerRef = useRef(null);
5
+ useEffect(() => {
6
+ if (!forwardedRef) {
7
+ return;
8
+ }
9
+ if (typeof forwardedRef === 'function') {
10
+ forwardedRef(innerRef.current);
11
+ return;
12
+ }
13
+ else {
14
+ forwardedRef.current = innerRef.current;
15
+ }
16
+ }, [forwardedRef, refresh]);
17
+ return innerRef;
18
+ };
19
+ //# sourceMappingURL=useShareForwardRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useShareForwardRef.js","sourceRoot":"","sources":["../../../src/hooks/useShareForwardRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAEvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAI,YAA6B,EAAE,OAAO,GAAG,CAAC,EAAE,EAAE;IACpF,iGAAiG;IACjG,MAAM,QAAQ,GAAG,MAAM,CAAI,IAAI,CAAC,CAAA;IAEhC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,YAAY,EAAE;YACjB,OAAM;SACP;QACD,IAAI,OAAO,YAAY,KAAK,UAAU,EAAE;YACtC,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;YAC9B,OAAM;SACP;aAAM;YACL,YAAY,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAA;SACxC;IACH,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAA;IAE3B,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA"}
package/package.json CHANGED
@@ -69,5 +69,5 @@
69
69
  },
70
70
  "sideEffects": false,
71
71
  "types": "dist/esm/index.d.ts",
72
- "version": "2.37.24"
72
+ "version": "2.37.26"
73
73
  }
@@ -2,3 +2,4 @@ export * from './GradientStyles'
2
2
  export * from './useDataState'
3
3
  export * from './useIsMobile'
4
4
  export * from './useMediaQuery'
5
+ export * from './useShareForwardRef'
@@ -0,0 +1,20 @@
1
+ import { ForwardedRef, useEffect, useRef } from 'react'
2
+
3
+ export const useShareForwardedRef = <T>(forwardedRef: ForwardedRef<T>, refresh = 0) => {
4
+ // final ref that will share value with forward ref. this is the one to be attached to components
5
+ const innerRef = useRef<T>(null)
6
+
7
+ useEffect(() => {
8
+ if (!forwardedRef) {
9
+ return
10
+ }
11
+ if (typeof forwardedRef === 'function') {
12
+ forwardedRef(innerRef.current)
13
+ return
14
+ } else {
15
+ forwardedRef.current = innerRef.current
16
+ }
17
+ }, [forwardedRef, refresh])
18
+
19
+ return innerRef
20
+ }