Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-compose-refs

Package Overview
Dependencies
Maintainers
6
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-compose-refs - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0-rc.1

11

dist/index.d.ts

@@ -1,3 +0,4 @@

import * as React from "react";
type PossibleRef<T> = React.Ref<T> | undefined;
import * as React from 'react';
declare type PossibleRef<T> = React.Ref<T> | undefined;
/**

@@ -7,3 +8,3 @@ * A utility to compose multiple refs together

*/
export function composeRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
declare function composeRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
/**

@@ -13,4 +14,4 @@ * A custom hook that composes multiple refs

*/
export function useComposedRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
declare function useComposedRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
//# sourceMappingURL=index.d.ts.map
export { composeRefs, useComposedRefs };

@@ -1,36 +0,48 @@

var $dJwbH$react = require("react");
"use strict";
(() => {
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "composeRefs", () => $9c2aaba23466b352$export$43e446d32b3d21af);
$parcel$export(module.exports, "useComposedRefs", () => $9c2aaba23466b352$export$c7b2cbe3552a0d05);
/**
* Set a given ref to a given value
* This utility takes care of different types of refs: callback refs and RefObject(s)
*/ function $9c2aaba23466b352$var$setRef(ref, value) {
if (typeof ref === 'function') ref(value);
else if (ref !== null && ref !== undefined) ref.current = value;
}
/**
* A utility to compose multiple refs together
* Accepts callback refs and RefObject(s)
*/ function $9c2aaba23466b352$export$43e446d32b3d21af(...refs) {
return (node)=>refs.forEach((ref)=>$9c2aaba23466b352$var$setRef(ref, node)
)
;
}
/**
* A custom hook that composes multiple refs
* Accepts callback refs and RefObject(s)
*/ function $9c2aaba23466b352$export$c7b2cbe3552a0d05(...refs) {
// eslint-disable-next-line react-hooks/exhaustive-deps
return $dJwbH$react.useCallback($9c2aaba23466b352$export$43e446d32b3d21af(...refs), refs);
}
// packages/react/compose-refs/src/composeRefs.tsx
var React = __toESM(__require("react"));
function setRef(ref, value) {
if (typeof ref === "function") {
ref(value);
} else if (ref !== null && ref !== void 0) {
ref.current = value;
}
}
function composeRefs(...refs) {
return (node) => refs.forEach((ref) => setRef(ref, node));
}
function useComposedRefs(...refs) {
return React.useCallback(composeRefs(...refs), refs);
}
})();
//# sourceMappingURL=index.js.map
{
"name": "@radix-ui/react-compose-refs",
"version": "1.0.1",
"version": "1.1.0-rc.1",
"license": "MIT",

@@ -47,5 +47,3 @@ "exports": {

},
"dependencies": {
"@babel/runtime": "^7.13.10"
}
"stableVersion": "1.0.1"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc