@radix-ui/react-compose-refs 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
@@ -1,14 +1,15 @@
1
- import * as React from "react";
2
- type PossibleRef<T> = React.Ref<T> | undefined;
1
+ import * as React from 'react';
2
+
3
+ declare type PossibleRef<T> = React.Ref<T> | undefined;
3
4
  /**
4
5
  * A utility to compose multiple refs together
5
6
  * Accepts callback refs and RefObject(s)
6
7
  */
7
- export function composeRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
8
+ declare function composeRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
8
9
  /**
9
10
  * A custom hook that composes multiple refs
10
11
  * Accepts callback refs and RefObject(s)
11
12
  */
12
- export function useComposedRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
13
+ declare function useComposedRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
13
14
 
14
- //# sourceMappingURL=index.d.ts.map
15
+ export { composeRefs, useComposedRefs };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
- import * as React from "react";
2
- type PossibleRef<T> = React.Ref<T> | undefined;
1
+ import * as React from 'react';
2
+
3
+ declare type PossibleRef<T> = React.Ref<T> | undefined;
3
4
  /**
4
5
  * A utility to compose multiple refs together
5
6
  * Accepts callback refs and RefObject(s)
6
7
  */
7
- export function composeRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
8
+ declare function composeRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
8
9
  /**
9
10
  * A custom hook that composes multiple refs
10
11
  * Accepts callback refs and RefObject(s)
11
12
  */
12
- export function useComposedRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
13
+ declare function useComposedRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
13
14
 
14
- //# sourceMappingURL=index.d.ts.map
15
+ export { composeRefs, useComposedRefs };
package/dist/index.js CHANGED
@@ -1,36 +1,48 @@
1
- var $dJwbH$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, "composeRefs", () => $9c2aaba23466b352$export$43e446d32b3d21af);
8
- $parcel$export(module.exports, "useComposedRefs", () => $9c2aaba23466b352$export$c7b2cbe3552a0d05);
9
-
10
- /**
11
- * Set a given ref to a given value
12
- * This utility takes care of different types of refs: callback refs and RefObject(s)
13
- */ function $9c2aaba23466b352$var$setRef(ref, value) {
14
- if (typeof ref === 'function') ref(value);
15
- else if (ref !== null && ref !== undefined) ref.current = value;
16
- }
17
- /**
18
- * A utility to compose multiple refs together
19
- * Accepts callback refs and RefObject(s)
20
- */ function $9c2aaba23466b352$export$43e446d32b3d21af(...refs) {
21
- return (node)=>refs.forEach((ref)=>$9c2aaba23466b352$var$setRef(ref, node)
22
- )
23
- ;
24
- }
25
- /**
26
- * A custom hook that composes multiple refs
27
- * Accepts callback refs and RefObject(s)
28
- */ function $9c2aaba23466b352$export$c7b2cbe3552a0d05(...refs) {
29
- // eslint-disable-next-line react-hooks/exhaustive-deps
30
- return $dJwbH$react.useCallback($9c2aaba23466b352$export$43e446d32b3d21af(...refs), refs);
31
- }
32
-
33
-
34
-
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
+ ));
35
31
 
32
+ // packages/react/compose-refs/src/composeRefs.tsx
33
+ var React = __toESM(__require("react"));
34
+ function setRef(ref, value) {
35
+ if (typeof ref === "function") {
36
+ ref(value);
37
+ } else if (ref !== null && ref !== void 0) {
38
+ ref.current = value;
39
+ }
40
+ }
41
+ function composeRefs(...refs) {
42
+ return (node) => refs.forEach((ref) => setRef(ref, node));
43
+ }
44
+ function useComposedRefs(...refs) {
45
+ return React.useCallback(composeRefs(...refs), refs);
46
+ }
47
+ })();
36
48
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1,7 @@
1
- {"mappings":";;;;;;;;ACAA;AAIA;;;GAGA,CACA,SAASG,4BAAT,CAAmBC,GAAnB,EAAwCC,KAAxC,EAAkD;IAChD,IAAI,OAAOD,GAAP,KAAe,UAAnB,EACEA,GAAG,CAACC,KAAD,CAAH,CAAAD;SACK,IAAIA,GAAG,KAAK,IAAR,IAAgBA,GAAG,KAAKE,SAA5B,EACJF,GAAD,CAAmCG,OAAnC,GAA6CF,KAA7C,CAACD;CAEJ;AAED;;;GAGA,CACA,SAASJ,yCAAT,CAAwB,GAAGQ,IAA3B,EAAmD;IACjD,OAAQC,CAAAA,IAAD,GAAaD,IAAI,CAACE,OAAL,CAAcN,CAAAA,GAAD,GAASD,4BAAM,CAACC,GAAD,EAAMK,IAAN,CAA5B;QAAA,CAApB;IAAA,CAAA;CACD;AAED;;;GAGA,CACA,SAASR,yCAAT,CAA4B,GAAGO,IAA/B,EAAuD;IACrD,uDAAA;IACA,OAAON,wBAAA,CAAkBF,yCAAW,IAAIQ,IAAJ,CAA7B,EAAwCA,IAAxC,CAAP,CAAA;CACD;;AD/BD","sources":["packages/react/compose-refs/src/index.ts","packages/react/compose-refs/src/composeRefs.tsx"],"sourcesContent":["export { composeRefs, useComposedRefs } from './composeRefs';\n","import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref !== null && ref !== undefined) {\n (ref as React.MutableRefObject<T>).current = value;\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]) {\n return (node: T) => refs.forEach((ref) => setRef(ref, node));\n}\n\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n"],"names":["composeRefs","useComposedRefs","React","setRef","ref","value","undefined","current","refs","node","forEach","useCallback"],"version":3,"file":"index.js.map"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/composeRefs.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref !== null && ref !== undefined) {\n (ref as React.MutableRefObject<T>).current = value;\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]) {\n return (node: T) => refs.forEach((ref) => setRef(ref, node));\n}\n\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAuB;AAQvB,WAAS,OAAU,KAAqB,OAAU;AAChD,QAAI,OAAO,QAAQ,YAAY;AAC7B,UAAI,KAAK;AAAA,IACX,WAAW,QAAQ,QAAQ,QAAQ,QAAW;AAC5C,MAAC,IAAkC,UAAU;AAAA,IAC/C;AAAA,EACF;AAMA,WAAS,eAAkB,MAAwB;AACjD,WAAO,CAAC,SAAY,KAAK,QAAQ,CAAC,QAAQ,OAAO,KAAK,IAAI,CAAC;AAAA,EAC7D;AAMA,WAAS,mBAAsB,MAAwB;AAErD,WAAa,kBAAY,YAAY,GAAG,IAAI,GAAG,IAAI;AAAA,EACrD;",
6
+ "names": []
7
+ }
package/dist/index.mjs CHANGED
@@ -1,31 +1,20 @@
1
- import {useCallback as $3vqmr$useCallback} from "react";
2
-
3
-
4
- /**
5
- * Set a given ref to a given value
6
- * This utility takes care of different types of refs: callback refs and RefObject(s)
7
- */ function $6ed0406888f73fc4$var$setRef(ref, value) {
8
- if (typeof ref === 'function') ref(value);
9
- else if (ref !== null && ref !== undefined) ref.current = value;
1
+ // packages/react/compose-refs/src/composeRefs.tsx
2
+ import * as React from "react";
3
+ function setRef(ref, value) {
4
+ if (typeof ref === "function") {
5
+ ref(value);
6
+ } else if (ref !== null && ref !== void 0) {
7
+ ref.current = value;
8
+ }
10
9
  }
11
- /**
12
- * A utility to compose multiple refs together
13
- * Accepts callback refs and RefObject(s)
14
- */ function $6ed0406888f73fc4$export$43e446d32b3d21af(...refs) {
15
- return (node)=>refs.forEach((ref)=>$6ed0406888f73fc4$var$setRef(ref, node)
16
- )
17
- ;
10
+ function composeRefs(...refs) {
11
+ return (node) => refs.forEach((ref) => setRef(ref, node));
18
12
  }
19
- /**
20
- * A custom hook that composes multiple refs
21
- * Accepts callback refs and RefObject(s)
22
- */ function $6ed0406888f73fc4$export$c7b2cbe3552a0d05(...refs) {
23
- // eslint-disable-next-line react-hooks/exhaustive-deps
24
- return $3vqmr$useCallback($6ed0406888f73fc4$export$43e446d32b3d21af(...refs), refs);
13
+ function useComposedRefs(...refs) {
14
+ return React.useCallback(composeRefs(...refs), refs);
25
15
  }
26
-
27
-
28
-
29
-
30
- export {$6ed0406888f73fc4$export$43e446d32b3d21af as composeRefs, $6ed0406888f73fc4$export$c7b2cbe3552a0d05 as useComposedRefs};
16
+ export {
17
+ composeRefs,
18
+ useComposedRefs
19
+ };
31
20
  //# sourceMappingURL=index.mjs.map
@@ -1 +1,7 @@
1
- {"mappings":";;ACAA;AAIA;;;GAGA,CACA,SAASG,4BAAT,CAAmBC,GAAnB,EAAwCC,KAAxC,EAAkD;IAChD,IAAI,OAAOD,GAAP,KAAe,UAAnB,EACEA,GAAG,CAACC,KAAD,CAAH,CAAAD;SACK,IAAIA,GAAG,KAAK,IAAR,IAAgBA,GAAG,KAAKE,SAA5B,EACJF,GAAD,CAAmCG,OAAnC,GAA6CF,KAA7C,CAACD;CAEJ;AAED;;;GAGA,CACA,SAASJ,yCAAT,CAAwB,GAAGQ,IAA3B,EAAmD;IACjD,OAAQC,CAAAA,IAAD,GAAaD,IAAI,CAACE,OAAL,CAAcN,CAAAA,GAAD,GAASD,4BAAM,CAACC,GAAD,EAAMK,IAAN,CAA5B;QAAA,CAApB;IAAA,CAAA;CACD;AAED;;;GAGA,CACA,SAASR,yCAAT,CAA4B,GAAGO,IAA/B,EAAuD;IACrD,uDAAA;IACA,OAAON,kBAAA,CAAkBF,yCAAW,IAAIQ,IAAJ,CAA7B,EAAwCA,IAAxC,CAAP,CAAA;CACD;;AD/BD","sources":["packages/react/compose-refs/src/index.ts","packages/react/compose-refs/src/composeRefs.tsx"],"sourcesContent":["export { composeRefs, useComposedRefs } from './composeRefs';\n","import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref !== null && ref !== undefined) {\n (ref as React.MutableRefObject<T>).current = value;\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]) {\n return (node: T) => refs.forEach((ref) => setRef(ref, node));\n}\n\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n"],"names":["composeRefs","useComposedRefs","React","setRef","ref","value","undefined","current","refs","node","forEach","useCallback"],"version":3,"file":"index.mjs.map"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/composeRefs.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref !== null && ref !== undefined) {\n (ref as React.MutableRefObject<T>).current = value;\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]) {\n return (node: T) => refs.forEach((ref) => setRef(ref, node));\n}\n\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n"],
5
+ "mappings": ";AAAA,YAAY,WAAW;AAQvB,SAAS,OAAU,KAAqB,OAAU;AAChD,MAAI,OAAO,QAAQ,YAAY;AAC7B,QAAI,KAAK;AAAA,EACX,WAAW,QAAQ,QAAQ,QAAQ,QAAW;AAC5C,IAAC,IAAkC,UAAU;AAAA,EAC/C;AACF;AAMA,SAAS,eAAkB,MAAwB;AACjD,SAAO,CAAC,SAAY,KAAK,QAAQ,CAAC,QAAQ,OAAO,KAAK,IAAI,CAAC;AAC7D;AAMA,SAAS,mBAAsB,MAAwB;AAErD,SAAa,kBAAY,YAAY,GAAG,IAAI,GAAG,IAAI;AACrD;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-compose-refs",
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,iBAAiB,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AAc/C;;;GAGG;AACH,4BAAqB,CAAC,EAAE,GAAG,IAAI,EAAE,YAAY,CAAC,CAAC,EAAE,UACjC,CAAC,UAChB;AAED;;;GAGG;AACH,gCAAyB,CAAC,EAAE,GAAG,IAAI,EAAE,YAAY,CAAC,CAAC,EAAE,qBAGpD","sources":["packages/react/compose-refs/src/packages/react/compose-refs/src/composeRefs.tsx","packages/react/compose-refs/src/packages/react/compose-refs/src/index.ts","packages/react/compose-refs/src/index.ts"],"sourcesContent":[null,null,"export { composeRefs, useComposedRefs } from './composeRefs';\n"],"names":[],"version":3,"file":"index.d.ts.map"}