(
Component: ElementType,
slot: Slot<R>,
)
| 56 | } |
| 57 | |
| 58 | const withContext = <T, P extends { className?: string | undefined }>( |
| 59 | Component: ElementType, |
| 60 | slot: Slot<R>, |
| 61 | ): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>> => { |
| 62 | const StyledComponent = styled(Component) |
| 63 | const StyledSlotComponent = forwardRef<T, P>((props, ref) => { |
| 64 | const slotStyles = useContext(StyleContext) |
| 65 | return <StyledComponent {...props} ref={ref} className={cx(slotStyles?.[slot], props.className)} /> |
| 66 | }) |
| 67 | // @ts-expect-error |
| 68 | StyledSlotComponent.displayName = Component.displayName || Component.name |
| 69 | |
| 70 | return StyledSlotComponent |
| 71 | } |
| 72 | |
| 73 | return { |
| 74 | withRootProvider, |
no test coverage detected