@radix-ui/react-slot 0.1.3-rc.2 → 0.1.3-rc.5
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.ts.map +1 -1
- package/dist/index.js +100 -1
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +81 -1
- package/dist/index.module.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";AAOA,0BAAoB,SAAQ,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC;IAC3D,QAAQ,CAAC,EAAE,MAAM,SAAS,CAAC;CAC5B;AAED,OAAA,MAAM,mFAwBJ,CAAC;AA+BH,OAAA,MAAM;cAAuC,MAAM,SAAS;iBAE3D,CAAC;AAqCF,OAAA,MAAM,mFAAW,CAAC","sources":["packages/react/slot/src/packages/react/slot/src/Slot.tsx","packages/react/slot/src/packages/react/slot/src/index.ts","packages/react/slot/src/index.ts"],"sourcesContent":[null,null,"export * from './Slot';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,101 @@
|
|
|
1
|
-
var
|
|
1
|
+
var $dAvBt$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
|
|
2
|
+
var $dAvBt$react = require("react");
|
|
3
|
+
var $dAvBt$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
|
|
4
|
+
|
|
5
|
+
function $parcel$exportWildcard(dest, source) {
|
|
6
|
+
Object.keys(source).forEach(function(key) {
|
|
7
|
+
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
Object.defineProperty(dest, key, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function get() {
|
|
14
|
+
return source[key];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return dest;
|
|
20
|
+
}
|
|
21
|
+
function $parcel$interopDefault(a) {
|
|
22
|
+
return a && a.__esModule ? a.default : a;
|
|
23
|
+
}
|
|
24
|
+
function $parcel$export(e, n, v, s) {
|
|
25
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
26
|
+
}
|
|
27
|
+
var $82dc8d030dec7549$exports = {};
|
|
28
|
+
|
|
29
|
+
$parcel$export($82dc8d030dec7549$exports, "Slot", () => $82dc8d030dec7549$export$8c6ed5c666ac1360);
|
|
30
|
+
$parcel$export($82dc8d030dec7549$exports, "Slottable", () => $82dc8d030dec7549$export$d9f1ccf0bdb05d45);
|
|
31
|
+
$parcel$export($82dc8d030dec7549$exports, "Root", () => $82dc8d030dec7549$export$be92b6f5f03c0fe9);
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
/* -------------------------------------------------------------------------------------------------
|
|
36
|
+
* Slot
|
|
37
|
+
* -----------------------------------------------------------------------------------------------*/ const $82dc8d030dec7549$export$8c6ed5c666ac1360 = /*#__PURE__*/ $dAvBt$react.forwardRef((props, forwardedRef)=>{
|
|
38
|
+
const { children: children , ...slotProps } = props;
|
|
39
|
+
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)=>{
|
|
40
|
+
return $82dc8d030dec7549$var$isSlottable(child) ? /*#__PURE__*/ $dAvBt$react.createElement($82dc8d030dec7549$var$SlotClone, ($parcel$interopDefault($dAvBt$babelruntimehelpersextends))({}, slotProps, {
|
|
41
|
+
ref: forwardedRef
|
|
42
|
+
}), child.props.children) : child;
|
|
43
|
+
}));
|
|
44
|
+
return /*#__PURE__*/ $dAvBt$react.createElement($82dc8d030dec7549$var$SlotClone, ($parcel$interopDefault($dAvBt$babelruntimehelpersextends))({}, slotProps, {
|
|
45
|
+
ref: forwardedRef
|
|
46
|
+
}), children);
|
|
47
|
+
});
|
|
48
|
+
$82dc8d030dec7549$export$8c6ed5c666ac1360.displayName = 'Slot';
|
|
49
|
+
/* -------------------------------------------------------------------------------------------------
|
|
50
|
+
* SlotClone
|
|
51
|
+
* -----------------------------------------------------------------------------------------------*/ const $82dc8d030dec7549$var$SlotClone = /*#__PURE__*/ $dAvBt$react.forwardRef((props, forwardedRef)=>{
|
|
52
|
+
const { children: children , ...slotProps } = props;
|
|
53
|
+
if (/*#__PURE__*/ $dAvBt$react.isValidElement(children)) return /*#__PURE__*/ $dAvBt$react.cloneElement(children, {
|
|
54
|
+
...$82dc8d030dec7549$var$mergeProps(slotProps, children.props),
|
|
55
|
+
ref: $dAvBt$radixuireactcomposerefs.composeRefs(forwardedRef, children.ref)
|
|
56
|
+
});
|
|
57
|
+
return $dAvBt$react.Children.count(children) > 1 ? $dAvBt$react.Children.only(null) : null;
|
|
58
|
+
});
|
|
59
|
+
$82dc8d030dec7549$var$SlotClone.displayName = 'SlotClone';
|
|
60
|
+
/* -------------------------------------------------------------------------------------------------
|
|
61
|
+
* Slottable
|
|
62
|
+
* -----------------------------------------------------------------------------------------------*/ const $82dc8d030dec7549$export$d9f1ccf0bdb05d45 = ({ children: children })=>{
|
|
63
|
+
return /*#__PURE__*/ $dAvBt$react.createElement($dAvBt$react.Fragment, null, children);
|
|
64
|
+
};
|
|
65
|
+
/* ---------------------------------------------------------------------------------------------- */ function $82dc8d030dec7549$var$isSlottable(child) {
|
|
66
|
+
return /*#__PURE__*/ $dAvBt$react.isValidElement(child) && child.type === $82dc8d030dec7549$export$d9f1ccf0bdb05d45;
|
|
67
|
+
}
|
|
68
|
+
function $82dc8d030dec7549$var$mergeProps(slotProps, childProps) {
|
|
69
|
+
// all child props should override
|
|
70
|
+
const overrideProps = {
|
|
71
|
+
...childProps
|
|
72
|
+
};
|
|
73
|
+
for(const propName in childProps){
|
|
74
|
+
const slotPropValue = slotProps[propName];
|
|
75
|
+
const childPropValue = childProps[propName];
|
|
76
|
+
const isHandler = /^on[A-Z]/.test(propName); // if it's a handler, modify the override by composing the base handler
|
|
77
|
+
if (isHandler) overrideProps[propName] = (...args)=>{
|
|
78
|
+
childPropValue === null || childPropValue === void 0 || childPropValue(...args);
|
|
79
|
+
slotPropValue === null || slotPropValue === void 0 || slotPropValue(...args);
|
|
80
|
+
};
|
|
81
|
+
else if (propName === 'style') overrideProps[propName] = {
|
|
82
|
+
...slotPropValue,
|
|
83
|
+
...childPropValue
|
|
84
|
+
};
|
|
85
|
+
else if (propName === 'className') overrideProps[propName] = [
|
|
86
|
+
slotPropValue,
|
|
87
|
+
childPropValue
|
|
88
|
+
].filter(Boolean).join(' ');
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
...slotProps,
|
|
92
|
+
...overrideProps
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const $82dc8d030dec7549$export$be92b6f5f03c0fe9 = $82dc8d030dec7549$export$8c6ed5c666ac1360;
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
$parcel$exportWildcard(module.exports, $82dc8d030dec7549$exports);
|
|
99
|
+
|
|
100
|
+
|
|
2
101
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A;;;ACGA;;oGAEA,CAMA,MAAME,yCAAI,GAAA,aAAGF,CAAAA,uBAAA,CAAyC,CAACI,KAAD,EAAQC,YAAR,GAAyB;IAC7E,MAAM,E,UAAEC,QAAF,CAAA,EAAY,GAAGC,SAAH,EAAZ,GAA6BH,KAAnC,AAAM;IAEN,IAAIJ,qBAAA,CAAeS,OAAf,CAAuBH,QAAvB,CAAA,CAAiCI,IAAjC,CAAsCC,iCAAtC,CAAJ,EACE,OAAA,aACE,CAAA,0BAAA,CAAA,qBAAA,EAAA,IAAA,EACGX,qBAAA,CAAeY,GAAf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,GAArD,CAA1B,CAAAT;KAEH;IAED,OAAO;QAAE,GAAGlB,SAAL;QAAgB,GAAGkB,aAAH;KAAvB,CAAO;CACR;AAED,MAAMU,yCAAI,GAAGjC,yCAAb,AAAA;;ADzGA","sources":["packages/react/slot/src/index.ts","packages/react/slot/src/Slot.tsx"],"sourcesContent":["export * from './Slot';\n","import * as React from 'react';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode;\n}\n\nconst Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n\n if (React.Children.toArray(children).some(isSlottable)) {\n return (\n <>\n {React.Children.map(children, (child) => {\n return isSlottable(child) ? (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {child.props.children}\n </SlotClone>\n ) : (\n child\n );\n })}\n </>\n );\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n );\n});\n\nSlot.displayName = 'Slot';\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode;\n}\n\nconst SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n\n if (React.isValidElement(children)) {\n return React.cloneElement(children, {\n ...mergeProps(slotProps, children.props),\n ref: composeRefs(forwardedRef, (children as any).ref),\n });\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null;\n});\n\nSlotClone.displayName = 'SlotClone';\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst Slottable = ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>;\n};\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>;\n\nfunction isSlottable(child: React.ReactNode): child is React.ReactElement {\n return React.isValidElement(child) && child.type === Slottable;\n}\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps) {\n // all child props should override\n const overrideProps = { ...childProps };\n\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n\n const isHandler = /^on[A-Z]/.test(propName);\n // if it's a handler, modify the override by composing the base handler\n if (isHandler) {\n overrideProps[propName] = (...args: unknown[]) => {\n childPropValue?.(...args);\n slotPropValue?.(...args);\n };\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');\n }\n }\n\n return { ...slotProps, ...overrideProps };\n}\n\nconst Root = Slot;\n\nexport {\n Slot,\n Slottable,\n //\n Root,\n};\nexport type { SlotProps };\n"],"names":["React","composeRefs","Slot","forwardRef","props","forwardedRef","children","slotProps","Children","toArray","some","isSlottable","map","child","displayName","SlotClone","isValidElement","cloneElement","mergeProps","ref","count","only","Slottable","type","childProps","overrideProps","propName","slotPropValue","childPropValue","isHandler","test","args","filter","Boolean","join","Root"],"version":3,"file":"index.js.map"}
|
package/dist/index.module.js
CHANGED
|
@@ -1,2 +1,82 @@
|
|
|
1
|
-
import
|
|
1
|
+
import $9IrjX$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
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";
|
|
3
|
+
import {composeRefs as $9IrjX$composeRefs} from "@radix-ui/react-compose-refs";
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
var $5e63c961fc1ce211$exports = {};
|
|
9
|
+
|
|
10
|
+
$parcel$export($5e63c961fc1ce211$exports, "Slot", () => $5e63c961fc1ce211$export$8c6ed5c666ac1360);
|
|
11
|
+
$parcel$export($5e63c961fc1ce211$exports, "Slottable", () => $5e63c961fc1ce211$export$d9f1ccf0bdb05d45);
|
|
12
|
+
$parcel$export($5e63c961fc1ce211$exports, "Root", () => $5e63c961fc1ce211$export$be92b6f5f03c0fe9);
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/* -------------------------------------------------------------------------------------------------
|
|
17
|
+
* Slot
|
|
18
|
+
* -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$export$8c6ed5c666ac1360 = /*#__PURE__*/ $9IrjX$forwardRef((props, forwardedRef)=>{
|
|
19
|
+
const { children: children , ...slotProps } = props;
|
|
20
|
+
if ($9IrjX$Children.toArray(children).some($5e63c961fc1ce211$var$isSlottable)) return /*#__PURE__*/ $9IrjX$createElement($9IrjX$Fragment, null, $9IrjX$Children.map(children, (child)=>{
|
|
21
|
+
return $5e63c961fc1ce211$var$isSlottable(child) ? /*#__PURE__*/ $9IrjX$createElement($5e63c961fc1ce211$var$SlotClone, $9IrjX$babelruntimehelpersesmextends({}, slotProps, {
|
|
22
|
+
ref: forwardedRef
|
|
23
|
+
}), child.props.children) : child;
|
|
24
|
+
}));
|
|
25
|
+
return /*#__PURE__*/ $9IrjX$createElement($5e63c961fc1ce211$var$SlotClone, $9IrjX$babelruntimehelpersesmextends({}, slotProps, {
|
|
26
|
+
ref: forwardedRef
|
|
27
|
+
}), children);
|
|
28
|
+
});
|
|
29
|
+
$5e63c961fc1ce211$export$8c6ed5c666ac1360.displayName = 'Slot';
|
|
30
|
+
/* -------------------------------------------------------------------------------------------------
|
|
31
|
+
* SlotClone
|
|
32
|
+
* -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$var$SlotClone = /*#__PURE__*/ $9IrjX$forwardRef((props, forwardedRef)=>{
|
|
33
|
+
const { children: children , ...slotProps } = props;
|
|
34
|
+
if (/*#__PURE__*/ $9IrjX$isValidElement(children)) return /*#__PURE__*/ $9IrjX$cloneElement(children, {
|
|
35
|
+
...$5e63c961fc1ce211$var$mergeProps(slotProps, children.props),
|
|
36
|
+
ref: $9IrjX$composeRefs(forwardedRef, children.ref)
|
|
37
|
+
});
|
|
38
|
+
return $9IrjX$Children.count(children) > 1 ? $9IrjX$Children.only(null) : null;
|
|
39
|
+
});
|
|
40
|
+
$5e63c961fc1ce211$var$SlotClone.displayName = 'SlotClone';
|
|
41
|
+
/* -------------------------------------------------------------------------------------------------
|
|
42
|
+
* Slottable
|
|
43
|
+
* -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 = ({ children: children })=>{
|
|
44
|
+
return /*#__PURE__*/ $9IrjX$createElement($9IrjX$Fragment, null, children);
|
|
45
|
+
};
|
|
46
|
+
/* ---------------------------------------------------------------------------------------------- */ function $5e63c961fc1ce211$var$isSlottable(child) {
|
|
47
|
+
return /*#__PURE__*/ $9IrjX$isValidElement(child) && child.type === $5e63c961fc1ce211$export$d9f1ccf0bdb05d45;
|
|
48
|
+
}
|
|
49
|
+
function $5e63c961fc1ce211$var$mergeProps(slotProps, childProps) {
|
|
50
|
+
// all child props should override
|
|
51
|
+
const overrideProps = {
|
|
52
|
+
...childProps
|
|
53
|
+
};
|
|
54
|
+
for(const propName in childProps){
|
|
55
|
+
const slotPropValue = slotProps[propName];
|
|
56
|
+
const childPropValue = childProps[propName];
|
|
57
|
+
const isHandler = /^on[A-Z]/.test(propName); // if it's a handler, modify the override by composing the base handler
|
|
58
|
+
if (isHandler) overrideProps[propName] = (...args)=>{
|
|
59
|
+
childPropValue === null || childPropValue === void 0 || childPropValue(...args);
|
|
60
|
+
slotPropValue === null || slotPropValue === void 0 || slotPropValue(...args);
|
|
61
|
+
};
|
|
62
|
+
else if (propName === 'style') overrideProps[propName] = {
|
|
63
|
+
...slotPropValue,
|
|
64
|
+
...childPropValue
|
|
65
|
+
};
|
|
66
|
+
else if (propName === 'className') overrideProps[propName] = [
|
|
67
|
+
slotPropValue,
|
|
68
|
+
childPropValue
|
|
69
|
+
].filter(Boolean).join(' ');
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
...slotProps,
|
|
73
|
+
...overrideProps
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const $5e63c961fc1ce211$export$be92b6f5f03c0fe9 = $5e63c961fc1ce211$export$8c6ed5c666ac1360;
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
export {$5e63c961fc1ce211$export$8c6ed5c666ac1360 as Slot, $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 as Slottable, $5e63c961fc1ce211$export$be92b6f5f03c0fe9 as Root};
|
|
2
82
|
//# sourceMappingURL=index.module.js.map
|
package/dist/index.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;A;;;ACGA;;oGAEA,CAMA,MAAME,yCAAI,GAAA,aAAGF,CAAAA,iBAAA,CAAyC,CAACI,KAAD,EAAQC,YAAR,GAAyB;IAC7E,MAAM,E,UAAEC,QAAF,CAAA,EAAY,GAAGC,SAAH,EAAZ,GAA6BH,KAAnC,AAAM;IAEN,IAAIJ,eAAA,CAAeS,OAAf,CAAuBH,QAAvB,CAAA,CAAiCI,IAAjC,CAAsCC,iCAAtC,CAAJ,EACE,OAAA,aACE,CAAA,oBAAA,CAAA,eAAA,EAAA,IAAA,EACGX,eAAA,CAAeY,GAAf,CAAmBN,QAAnB,EAA8BO,CAAAA,KAAD,GAAW;QACvC,OAAOF,iCAAW,CAACE,KAAD,CAAX,GAAA,aACL,CAAA,oBAAA,CAAC,+BAAD,EAAA,oCAAA,CAAA,EAAA,EAAeN,SAAf,EADF;YAC4B,GAAG,EAAEF,YAAL;SAA1B,CAAA,EACGQ,KAAK,CAACT,KAAN,CAAYE,QAD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,IAAN,KAAeD,yCAArD,CAAA;CACD;AAED,SAASJ,gCAAT,CAAoBX,SAApB,EAAyCiB,UAAzC,EAA+D;IAC7D,kCAAA;IACA,MAAMC,aAAa,GAAG;QAAE,GAAGD,UAA3B;KAAA,AAAsB;IAEtB,IAAK,MAAME,QAAX,IAAuBF,UAAvB,CAAmC;QACjC,MAAMG,aAAa,GAAGpB,SAAS,CAACmB,QAAD,CAA/B,AAAA;QACA,MAAME,cAAc,GAAGJ,UAAU,CAACE,QAAD,CAAjC,AAAA;QAEA,MAAMG,SAAS,GAAG,WAAWC,IAAX,CAAgBJ,QAAhB,CAAlB,AAJiC,EAKjC,uEADA;QAEA,IAAIG,SAAJ,EACEJ,aAAa,CAACC,QAAD,CAAb,GAA0B,CAAIK,GAAAA,IAAJ,GAAwB;YAChDH,cAAc,KAAA,IAAd,IAAAA,cAAc,KAAA,KAAA,CAAd,IAAAA,cAAc,IAAMG,IAAN,CAAd,CAAAH;YACAD,aAAa,KAAA,IAAb,IAAAA,aAAa,KAAA,KAAA,CAAb,IAAAA,aAAa,IAAMI,IAAN,CAAb,CAAAJ;SAFF,CAGC;aAGE,IAAID,QAAQ,KAAK,OAAjB,EACHD,aAAa,CAACC,QAAD,CAAb,GAA0B;YAAE,GAAGC,aAAL;YAAoB,GAAGC,cAAH;SAA9C,CAA0B;aACrB,IAAIF,QAAQ,KAAK,WAAjB,EACLD,aAAa,CAACC,QAAD,CAAb,GAA0B;YAACC,aAAD;YAAgBC,cAAhB;SAAA,CAAgCI,MAAhC,CAAuCC,OAAvC,CAAA,CAAgDC,IAAhD,CAAqD,GAArD,CAA1B,CAAAT;KAEH;IAED,OAAO;QAAE,GAAGlB,SAAL;QAAgB,GAAGkB,aAAH;KAAvB,CAAO;CACR;AAED,MAAMU,yCAAI,GAAGjC,yCAAb,AAAA;;ADzGA","sources":["packages/react/slot/src/index.ts","packages/react/slot/src/Slot.tsx"],"sourcesContent":["export * from './Slot';\n","import * as React from 'react';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode;\n}\n\nconst Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n\n if (React.Children.toArray(children).some(isSlottable)) {\n return (\n <>\n {React.Children.map(children, (child) => {\n return isSlottable(child) ? (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {child.props.children}\n </SlotClone>\n ) : (\n child\n );\n })}\n </>\n );\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n );\n});\n\nSlot.displayName = 'Slot';\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode;\n}\n\nconst SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n\n if (React.isValidElement(children)) {\n return React.cloneElement(children, {\n ...mergeProps(slotProps, children.props),\n ref: composeRefs(forwardedRef, (children as any).ref),\n });\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null;\n});\n\nSlotClone.displayName = 'SlotClone';\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst Slottable = ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>;\n};\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>;\n\nfunction isSlottable(child: React.ReactNode): child is React.ReactElement {\n return React.isValidElement(child) && child.type === Slottable;\n}\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps) {\n // all child props should override\n const overrideProps = { ...childProps };\n\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n\n const isHandler = /^on[A-Z]/.test(propName);\n // if it's a handler, modify the override by composing the base handler\n if (isHandler) {\n overrideProps[propName] = (...args: unknown[]) => {\n childPropValue?.(...args);\n slotPropValue?.(...args);\n };\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');\n }\n }\n\n return { ...slotProps, ...overrideProps };\n}\n\nconst Root = Slot;\n\nexport {\n Slot,\n Slottable,\n //\n Root,\n};\nexport type { SlotProps };\n"],"names":["React","composeRefs","Slot","forwardRef","props","forwardedRef","children","slotProps","Children","toArray","some","isSlottable","map","child","displayName","SlotClone","isValidElement","cloneElement","mergeProps","ref","count","only","Slottable","type","childProps","overrideProps","propName","slotPropValue","childPropValue","isHandler","test","args","filter","Boolean","join","Root"],"version":3,"file":"index.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-slot",
|
|
3
|
-
"version": "0.1.3-rc.
|
|
3
|
+
"version": "0.1.3-rc.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/runtime": "^7.13.10",
|
|
20
|
-
"@radix-ui/react-compose-refs": "0.1.1-rc.
|
|
20
|
+
"@radix-ui/react-compose-refs": "0.1.1-rc.5"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": "^16.8 || ^17.0 || ^18.0"
|