You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@radix-ui/react-slot

Package Overview
Dependencies
Maintainers
6
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-slot - npm Package Compare versions

Comparing version

to
0.1.3-rc.3

101

dist/index.js

@@ -1,2 +0,101 @@

var e,r,n,t=require("@radix-ui/react-compose-refs").composeRefs,l=(e={},r=require("react"),Object.keys(r).forEach((function(n){"default"!==n&&"__esModule"!==n&&Object.defineProperty(e,n,{enumerable:!0,get:function(){return r[n]}})})),e),o=(n=require("@babel/runtime/helpers/extends"))&&n.__esModule?n.default:n;const s=/*#__PURE__*/l.forwardRef(((e,r)=>{const{children:n,...t}=e;return l.Children.toArray(n).some(i)?/*#__PURE__*/l.createElement(l.Fragment,null,l.Children.map(n,(e=>i(e)?/*#__PURE__*/l.createElement(c,o({},t,{ref:r}),e.props.children):e))):/*#__PURE__*/l.createElement(c,o({},t,{ref:r}),n)}));exports.Slot=s,s.displayName="Slot";const c=/*#__PURE__*/l.forwardRef(((e,r)=>{const{children:n,...o}=e;/*#__PURE__*/return l.isValidElement(n)?/*#__PURE__*/l.cloneElement(n,{...u(o,n.props),ref:t(r,n.ref)}):l.Children.count(n)>1?l.Children.only(null):null}));c.displayName="SlotClone";const a=({children:e})=>/*#__PURE__*/l.createElement(l.Fragment,null,e);function i(e){/*#__PURE__*/return l.isValidElement(e)&&e.type===a}function u(e,r){const n={...r};for(const t in r){const l=e[t],o=r[t];/^on[A-Z]/.test(t)?n[t]=(...e)=>{null==o||o(...e),null==l||l(...e)}:"style"===t?n[t]={...l,...o}:"className"===t&&(n[t]=[l,o].filter(Boolean).join(" "))}return{...e,...n}}exports.Slottable=a;const d=s;exports.Root=d;
var $dAvBt$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
var $dAvBt$react = require("react");
var $dAvBt$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
function $parcel$exportWildcard(dest, source) {
Object.keys(source).forEach(function(key) {
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
return;
}
Object.defineProperty(dest, key, {
enumerable: true,
get: function get() {
return source[key];
}
});
});
return dest;
}
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
var $82dc8d030dec7549$exports = {};
$parcel$export($82dc8d030dec7549$exports, "Slot", () => $82dc8d030dec7549$export$8c6ed5c666ac1360);
$parcel$export($82dc8d030dec7549$exports, "Slottable", () => $82dc8d030dec7549$export$d9f1ccf0bdb05d45);
$parcel$export($82dc8d030dec7549$exports, "Root", () => $82dc8d030dec7549$export$be92b6f5f03c0fe9);
/* -------------------------------------------------------------------------------------------------
* Slot
* -----------------------------------------------------------------------------------------------*/ const $82dc8d030dec7549$export$8c6ed5c666ac1360 = /*#__PURE__*/ $dAvBt$react.forwardRef((props, forwardedRef)=>{
const { children: children , ...slotProps } = props;
if ($dAvBt$react.Children.toArray(children).some($82dc8d030dec7549$var$isSlottable)) return /*#__PURE__*/ $dAvBt$react.createElement($dAvBt$react.Fragment, null, $dAvBt$react.Children.map(children, (child)=>{
return $82dc8d030dec7549$var$isSlottable(child) ? /*#__PURE__*/ $dAvBt$react.createElement($82dc8d030dec7549$var$SlotClone, ($parcel$interopDefault($dAvBt$babelruntimehelpersextends))({}, slotProps, {
ref: forwardedRef
}), child.props.children) : child;
}));
return /*#__PURE__*/ $dAvBt$react.createElement($82dc8d030dec7549$var$SlotClone, ($parcel$interopDefault($dAvBt$babelruntimehelpersextends))({}, slotProps, {
ref: forwardedRef
}), children);
});
$82dc8d030dec7549$export$8c6ed5c666ac1360.displayName = 'Slot';
/* -------------------------------------------------------------------------------------------------
* SlotClone
* -----------------------------------------------------------------------------------------------*/ const $82dc8d030dec7549$var$SlotClone = /*#__PURE__*/ $dAvBt$react.forwardRef((props, forwardedRef)=>{
const { children: children , ...slotProps } = props;
if (/*#__PURE__*/ $dAvBt$react.isValidElement(children)) return /*#__PURE__*/ $dAvBt$react.cloneElement(children, {
...$82dc8d030dec7549$var$mergeProps(slotProps, children.props),
ref: $dAvBt$radixuireactcomposerefs.composeRefs(forwardedRef, children.ref)
});
return $dAvBt$react.Children.count(children) > 1 ? $dAvBt$react.Children.only(null) : null;
});
$82dc8d030dec7549$var$SlotClone.displayName = 'SlotClone';
/* -------------------------------------------------------------------------------------------------
* Slottable
* -----------------------------------------------------------------------------------------------*/ const $82dc8d030dec7549$export$d9f1ccf0bdb05d45 = ({ children: children })=>{
return /*#__PURE__*/ $dAvBt$react.createElement($dAvBt$react.Fragment, null, children);
};
/* ---------------------------------------------------------------------------------------------- */ function $82dc8d030dec7549$var$isSlottable(child) {
return /*#__PURE__*/ $dAvBt$react.isValidElement(child) && child.type === $82dc8d030dec7549$export$d9f1ccf0bdb05d45;
}
function $82dc8d030dec7549$var$mergeProps(slotProps, childProps) {
// all child props should override
const overrideProps = {
...childProps
};
for(const propName in childProps){
const slotPropValue = slotProps[propName];
const childPropValue = childProps[propName];
const isHandler = /^on[A-Z]/.test(propName); // if it's a handler, modify the override by composing the base handler
if (isHandler) overrideProps[propName] = (...args)=>{
childPropValue === null || childPropValue === void 0 || childPropValue(...args);
slotPropValue === null || slotPropValue === void 0 || slotPropValue(...args);
};
else if (propName === 'style') overrideProps[propName] = {
...slotPropValue,
...childPropValue
};
else if (propName === 'className') overrideProps[propName] = [
slotPropValue,
childPropValue
].filter(Boolean).join(' ');
}
return {
...slotProps,
...overrideProps
};
}
const $82dc8d030dec7549$export$be92b6f5f03c0fe9 = $82dc8d030dec7549$export$8c6ed5c666ac1360;
$parcel$exportWildcard(module.exports, $82dc8d030dec7549$exports);
//# sourceMappingURL=index.js.map

@@ -1,2 +0,82 @@

import{composeRefs as e}from"@radix-ui/react-compose-refs";import*as t from"react";import r from"@babel/runtime/helpers/esm/extends";export const Slot=/*#__PURE__*/t.forwardRef(((e,o)=>{const{children:a,...s}=e;return t.Children.toArray(a).some(l)?/*#__PURE__*/t.createElement(t.Fragment,null,t.Children.map(a,(e=>l(e)?/*#__PURE__*/t.createElement(n,r({},s,{ref:o}),e.props.children):e))):/*#__PURE__*/t.createElement(n,r({},s,{ref:o}),a)}));Slot.displayName="Slot";const n=/*#__PURE__*/t.forwardRef(((r,n)=>{const{children:l,...a}=r;/*#__PURE__*/return t.isValidElement(l)?/*#__PURE__*/t.cloneElement(l,{...o(a,l.props),ref:e(n,l.ref)}):t.Children.count(l)>1?t.Children.only(null):null}));n.displayName="SlotClone";export const Slottable=({children:e})=>/*#__PURE__*/t.createElement(t.Fragment,null,e);function l(e){/*#__PURE__*/return t.isValidElement(e)&&e.type===Slottable}function o(e,t){const r={...t};for(const n in t){const l=e[n],o=t[n];/^on[A-Z]/.test(n)?r[n]=(...e)=>{null==o||o(...e),null==l||l(...e)}:"style"===n?r[n]={...l,...o}:"className"===n&&(r[n]=[l,o].filter(Boolean).join(" "))}return{...e,...r}}export const Root=Slot;
import $9IrjX$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
import {forwardRef as $9IrjX$forwardRef, Children as $9IrjX$Children, createElement as $9IrjX$createElement, Fragment as $9IrjX$Fragment, isValidElement as $9IrjX$isValidElement, cloneElement as $9IrjX$cloneElement} from "react";
import {composeRefs as $9IrjX$composeRefs} from "@radix-ui/react-compose-refs";
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
var $5e63c961fc1ce211$exports = {};
$parcel$export($5e63c961fc1ce211$exports, "Slot", () => $5e63c961fc1ce211$export$8c6ed5c666ac1360);
$parcel$export($5e63c961fc1ce211$exports, "Slottable", () => $5e63c961fc1ce211$export$d9f1ccf0bdb05d45);
$parcel$export($5e63c961fc1ce211$exports, "Root", () => $5e63c961fc1ce211$export$be92b6f5f03c0fe9);
/* -------------------------------------------------------------------------------------------------
* Slot
* -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$export$8c6ed5c666ac1360 = /*#__PURE__*/ $9IrjX$forwardRef((props, forwardedRef)=>{
const { children: children , ...slotProps } = props;
if ($9IrjX$Children.toArray(children).some($5e63c961fc1ce211$var$isSlottable)) return /*#__PURE__*/ $9IrjX$createElement($9IrjX$Fragment, null, $9IrjX$Children.map(children, (child)=>{
return $5e63c961fc1ce211$var$isSlottable(child) ? /*#__PURE__*/ $9IrjX$createElement($5e63c961fc1ce211$var$SlotClone, $9IrjX$babelruntimehelpersesmextends({}, slotProps, {
ref: forwardedRef
}), child.props.children) : child;
}));
return /*#__PURE__*/ $9IrjX$createElement($5e63c961fc1ce211$var$SlotClone, $9IrjX$babelruntimehelpersesmextends({}, slotProps, {
ref: forwardedRef
}), children);
});
$5e63c961fc1ce211$export$8c6ed5c666ac1360.displayName = 'Slot';
/* -------------------------------------------------------------------------------------------------
* SlotClone
* -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$var$SlotClone = /*#__PURE__*/ $9IrjX$forwardRef((props, forwardedRef)=>{
const { children: children , ...slotProps } = props;
if (/*#__PURE__*/ $9IrjX$isValidElement(children)) return /*#__PURE__*/ $9IrjX$cloneElement(children, {
...$5e63c961fc1ce211$var$mergeProps(slotProps, children.props),
ref: $9IrjX$composeRefs(forwardedRef, children.ref)
});
return $9IrjX$Children.count(children) > 1 ? $9IrjX$Children.only(null) : null;
});
$5e63c961fc1ce211$var$SlotClone.displayName = 'SlotClone';
/* -------------------------------------------------------------------------------------------------
* Slottable
* -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 = ({ children: children })=>{
return /*#__PURE__*/ $9IrjX$createElement($9IrjX$Fragment, null, children);
};
/* ---------------------------------------------------------------------------------------------- */ function $5e63c961fc1ce211$var$isSlottable(child) {
return /*#__PURE__*/ $9IrjX$isValidElement(child) && child.type === $5e63c961fc1ce211$export$d9f1ccf0bdb05d45;
}
function $5e63c961fc1ce211$var$mergeProps(slotProps, childProps) {
// all child props should override
const overrideProps = {
...childProps
};
for(const propName in childProps){
const slotPropValue = slotProps[propName];
const childPropValue = childProps[propName];
const isHandler = /^on[A-Z]/.test(propName); // if it's a handler, modify the override by composing the base handler
if (isHandler) overrideProps[propName] = (...args)=>{
childPropValue === null || childPropValue === void 0 || childPropValue(...args);
slotPropValue === null || slotPropValue === void 0 || slotPropValue(...args);
};
else if (propName === 'style') overrideProps[propName] = {
...slotPropValue,
...childPropValue
};
else if (propName === 'className') overrideProps[propName] = [
slotPropValue,
childPropValue
].filter(Boolean).join(' ');
}
return {
...slotProps,
...overrideProps
};
}
const $5e63c961fc1ce211$export$be92b6f5f03c0fe9 = $5e63c961fc1ce211$export$8c6ed5c666ac1360;
export {$5e63c961fc1ce211$export$8c6ed5c666ac1360 as Slot, $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 as Slottable, $5e63c961fc1ce211$export$be92b6f5f03c0fe9 as Root};
//# sourceMappingURL=index.module.js.map

4

package.json
{
"name": "@radix-ui/react-slot",
"version": "0.1.3-rc.2",
"version": "0.1.3-rc.3",
"license": "MIT",

@@ -20,3 +20,3 @@ "source": "src/index.ts",

"@babel/runtime": "^7.13.10",
"@radix-ui/react-compose-refs": "0.1.1-rc.2"
"@radix-ui/react-compose-refs": "0.1.1-rc.3"
},

@@ -23,0 +23,0 @@ "peerDependencies": {

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