@radix-ui/react-slot
Advanced tools
Comparing version 1.1.0-rc.3 to 1.1.0-rc.4
@@ -0,1 +1,2 @@ | ||
import * as react_jsx_runtime from 'react/jsx-runtime'; | ||
import * as React from 'react'; | ||
@@ -9,5 +10,5 @@ | ||
children: React.ReactNode; | ||
}) => JSX.Element; | ||
}) => react_jsx_runtime.JSX.Element; | ||
declare const Root: React.ForwardRefExoticComponent<SlotProps & React.RefAttributes<HTMLElement>>; | ||
export { Root, Slot, type SlotProps, Slottable }; |
@@ -65,5 +65,7 @@ "use strict"; | ||
if (React.isValidElement(children)) { | ||
const childrenRef = getElementRef(children); | ||
return React.cloneElement(children, { | ||
...mergeProps(slotProps, children.props), | ||
ref: forwardedRef ? (0, import_react_compose_refs.composeRefs)(forwardedRef, children.ref) : children.ref | ||
// @ts-ignore | ||
ref: forwardedRef ? (0, import_react_compose_refs.composeRefs)(forwardedRef, childrenRef) : childrenRef | ||
}); | ||
@@ -103,3 +105,16 @@ } | ||
} | ||
function getElementRef(element) { | ||
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get; | ||
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning; | ||
if (mayWarn) { | ||
return element.ref; | ||
} | ||
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get; | ||
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning; | ||
if (mayWarn) { | ||
return element.props.ref; | ||
} | ||
return element.props.ref || element.ref; | ||
} | ||
var Root = Slot; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@radix-ui/react-slot", | ||
"version": "1.1.0-rc.3", | ||
"version": "1.1.0-rc.4", | ||
"license": "MIT", | ||
@@ -31,7 +31,7 @@ "exports": { | ||
"dependencies": { | ||
"@radix-ui/react-compose-refs": "1.1.0-rc.3" | ||
"@radix-ui/react-compose-refs": "1.1.0-rc.4" | ||
}, | ||
"peerDependencies": { | ||
"@types/react": "*", | ||
"react": "^16.8 || ^17.0 || ^18.0" | ||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "peerDependenciesMeta": { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25431
212
+ Added@radix-ui/react-compose-refs@1.1.0-rc.4(transitive)
- Removed@radix-ui/react-compose-refs@1.1.0-rc.3(transitive)