@radix-ui/react-use-callback-ref 1.0.1 → 1.1.0-rc.2

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.d.mts CHANGED
@@ -2,6 +2,6 @@
2
2
  * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
3
3
  * prop or avoid re-executing effects when passed as a dependency
4
4
  */
5
- export function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T;
5
+ declare function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T;
6
6
 
7
- //# sourceMappingURL=index.d.ts.map
7
+ export { useCallbackRef };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,6 @@
2
2
  * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
3
3
  * prop or avoid re-executing effects when passed as a dependency
4
4
  */
5
- export function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T;
5
+ declare function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T;
6
6
 
7
- //# sourceMappingURL=index.d.ts.map
7
+ export { useCallbackRef };
package/dist/index.js CHANGED
@@ -1,27 +1,42 @@
1
- var $92muK$react = require("react");
2
-
3
- function $parcel$export(e, n, v, s) {
4
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
5
- }
6
-
7
- $parcel$export(module.exports, "useCallbackRef", () => $28e03942f763e819$export$25bec8c6f54ee79a);
8
-
9
- /**
10
- * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
11
- * prop or avoid re-executing effects when passed as a dependency
12
- */ function $28e03942f763e819$export$25bec8c6f54ee79a(callback) {
13
- const callbackRef = $92muK$react.useRef(callback);
14
- $92muK$react.useEffect(()=>{
15
- callbackRef.current = callback;
16
- }); // https://github.com/facebook/react/issues/19240
17
- return $92muK$react.useMemo(()=>(...args)=>{
18
- var _callbackRef$current;
19
- return (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef, ...args);
20
- }
21
- , []);
22
- }
23
-
24
-
25
-
1
+ "use strict";
2
+ (() => {
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
+ }) : x)(function(x) {
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
26
31
 
32
+ // packages/react/use-callback-ref/src/useCallbackRef.tsx
33
+ var React = __toESM(__require("react"));
34
+ function useCallbackRef(callback) {
35
+ const callbackRef = React.useRef(callback);
36
+ React.useEffect(() => {
37
+ callbackRef.current = callback;
38
+ });
39
+ return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);
40
+ }
41
+ })();
27
42
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1,7 @@
1
- {"mappings":";;;;;;;ACAA;AAEA;;;GAGA,CACA,SAASA,yCAAT,CAA2DE,QAA3D,EAAuF;IACrF,MAAMC,WAAW,GAAGF,mBAAA,CAAaC,QAAb,CAApB,AAAA;IAEAD,sBAAA,CAAgB,IAAM;QACpBE,WAAW,CAACG,OAAZ,GAAsBJ,QAAtB,CAAAC;KADF,CAAA,CAHqF,CAOrF,iDAFC;IAGD,OAAOF,oBAAA,CAAc,IAAO,CAAIO,GAAAA,IAAJ,GAA5B;YAA4B,IAAA,oBAAA,AAAA;YAAA,OAAA,AAAA,CAAA,oBAAA,GAAaL,WAAW,CAACG,OAAzB,CAAA,KAAA,IAAA,IAAA,oBAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAa,oBAAA,CAAA,IAAA,CAAAH,WAAW,KAAcK,IAAd,CAAxB,CAAA;SAArB;IAAA,EAAwE,EAAxE,CAAP,CAA4B;CAC7B;;ADfD","sources":["packages/react/use-callback-ref/src/index.ts","packages/react/use-callback-ref/src/useCallbackRef.tsx"],"sourcesContent":["export { useCallbackRef } from './useCallbackRef';\n","import * as React from 'react';\n\n/**\n * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a\n * prop or avoid re-executing effects when passed as a dependency\n */\nfunction useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T {\n const callbackRef = React.useRef(callback);\n\n React.useEffect(() => {\n callbackRef.current = callback;\n });\n\n // https://github.com/facebook/react/issues/19240\n return React.useMemo(() => ((...args) => callbackRef.current?.(...args)) as T, []);\n}\n\nexport { useCallbackRef };\n"],"names":["useCallbackRef","React","callback","callbackRef","useRef","useEffect","current","useMemo","args"],"version":3,"file":"index.js.map"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/useCallbackRef.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\n\n/**\n * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a\n * prop or avoid re-executing effects when passed as a dependency\n */\nfunction useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T {\n const callbackRef = React.useRef(callback);\n\n React.useEffect(() => {\n callbackRef.current = callback;\n });\n\n // https://github.com/facebook/react/issues/19240\n return React.useMemo(() => ((...args) => callbackRef.current?.(...args)) as T, []);\n}\n\nexport { useCallbackRef };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAuB;AAMvB,WAAS,eAAkD,UAA4B;AACrF,UAAM,cAAoB,aAAO,QAAQ;AAEzC,IAAM,gBAAU,MAAM;AACpB,kBAAY,UAAU;AAAA,IACxB,CAAC;AAGD,WAAa,cAAQ,MAAO,IAAI,SAAS,YAAY,UAAU,GAAG,IAAI,GAAS,CAAC,CAAC;AAAA,EACnF;",
6
+ "names": []
7
+ }
package/dist/index.mjs CHANGED
@@ -1,23 +1,13 @@
1
- import {useRef as $lwiWj$useRef, useEffect as $lwiWj$useEffect, useMemo as $lwiWj$useMemo} from "react";
2
-
3
-
4
- /**
5
- * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
6
- * prop or avoid re-executing effects when passed as a dependency
7
- */ function $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(callback) {
8
- const callbackRef = $lwiWj$useRef(callback);
9
- $lwiWj$useEffect(()=>{
10
- callbackRef.current = callback;
11
- }); // https://github.com/facebook/react/issues/19240
12
- return $lwiWj$useMemo(()=>(...args)=>{
13
- var _callbackRef$current;
14
- return (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef, ...args);
15
- }
16
- , []);
1
+ // packages/react/use-callback-ref/src/useCallbackRef.tsx
2
+ import * as React from "react";
3
+ function useCallbackRef(callback) {
4
+ const callbackRef = React.useRef(callback);
5
+ React.useEffect(() => {
6
+ callbackRef.current = callback;
7
+ });
8
+ return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);
17
9
  }
18
-
19
-
20
-
21
-
22
- export {$b1b2314f5f9a1d84$export$25bec8c6f54ee79a as useCallbackRef};
10
+ export {
11
+ useCallbackRef
12
+ };
23
13
  //# sourceMappingURL=index.mjs.map
@@ -1 +1,7 @@
1
- {"mappings":";;ACAA;AAEA;;;GAGA,CACA,SAASA,yCAAT,CAA2DE,QAA3D,EAAuF;IACrF,MAAMC,WAAW,GAAGF,aAAA,CAAaC,QAAb,CAApB,AAAA;IAEAD,gBAAA,CAAgB,IAAM;QACpBE,WAAW,CAACG,OAAZ,GAAsBJ,QAAtB,CAAAC;KADF,CAAA,CAHqF,CAOrF,iDAFC;IAGD,OAAOF,cAAA,CAAc,IAAO,CAAIO,GAAAA,IAAJ,GAA5B;YAA4B,IAAA,oBAAA,AAAA;YAAA,OAAA,AAAA,CAAA,oBAAA,GAAaL,WAAW,CAACG,OAAzB,CAAA,KAAA,IAAA,IAAA,oBAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAa,oBAAA,CAAA,IAAA,CAAAH,WAAW,KAAcK,IAAd,CAAxB,CAAA;SAArB;IAAA,EAAwE,EAAxE,CAAP,CAA4B;CAC7B;;ADfD","sources":["packages/react/use-callback-ref/src/index.ts","packages/react/use-callback-ref/src/useCallbackRef.tsx"],"sourcesContent":["export { useCallbackRef } from './useCallbackRef';\n","import * as React from 'react';\n\n/**\n * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a\n * prop or avoid re-executing effects when passed as a dependency\n */\nfunction useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T {\n const callbackRef = React.useRef(callback);\n\n React.useEffect(() => {\n callbackRef.current = callback;\n });\n\n // https://github.com/facebook/react/issues/19240\n return React.useMemo(() => ((...args) => callbackRef.current?.(...args)) as T, []);\n}\n\nexport { useCallbackRef };\n"],"names":["useCallbackRef","React","callback","callbackRef","useRef","useEffect","current","useMemo","args"],"version":3,"file":"index.mjs.map"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/useCallbackRef.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\n\n/**\n * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a\n * prop or avoid re-executing effects when passed as a dependency\n */\nfunction useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T {\n const callbackRef = React.useRef(callback);\n\n React.useEffect(() => {\n callbackRef.current = callback;\n });\n\n // https://github.com/facebook/react/issues/19240\n return React.useMemo(() => ((...args) => callbackRef.current?.(...args)) as T, []);\n}\n\nexport { useCallbackRef };\n"],
5
+ "mappings": ";AAAA,YAAY,WAAW;AAMvB,SAAS,eAAkD,UAA4B;AACrF,QAAM,cAAoB,aAAO,QAAQ;AAEzC,EAAM,gBAAU,MAAM;AACpB,gBAAY,UAAU;AAAA,EACxB,CAAC;AAGD,SAAa,cAAQ,MAAO,IAAI,SAAS,YAAY,UAAU,GAAG,IAAI,GAAS,CAAC,CAAC;AACnF;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-use-callback-ref",
3
- "version": "1.0.1",
3
+ "version": "1.1.0-rc.2",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {
@@ -44,7 +44,5 @@
44
44
  "bugs": {
45
45
  "url": "https://github.com/radix-ui/primitives/issues"
46
46
  },
47
- "dependencies": {
48
- "@babel/runtime": "^7.13.10"
49
- }
47
+ "stableVersion": "1.0.1"
50
48
  }
@@ -1 +0,0 @@
1
- {"mappings":"AAEA;;;GAGG;AACH,+BAAwB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC,CASrF","sources":["packages/react/use-callback-ref/src/packages/react/use-callback-ref/src/useCallbackRef.tsx","packages/react/use-callback-ref/src/packages/react/use-callback-ref/src/index.ts","packages/react/use-callback-ref/src/index.ts"],"sourcesContent":[null,null,"export { useCallbackRef } from './useCallbackRef';\n"],"names":[],"version":3,"file":"index.d.ts.map"}