(
Component: ElementType,
slot: Slot<R>,
)
| 35 | } |
| 36 | |
| 37 | const withProvider = <T, P extends { className?: string | undefined }>( |
| 38 | Component: ElementType, |
| 39 | slot: Slot<R>, |
| 40 | ): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>> => { |
| 41 | const StyledComponent = styled(Component) |
| 42 | const StyledSlotProvider = forwardRef<T, P>((props, ref) => { |
| 43 | const [variantProps, otherProps] = recipe.splitVariantProps(props) |
| 44 | const slotStyles = recipe(variantProps) as Record<Slot<R>, string> |
| 45 | |
| 46 | return ( |
| 47 | <StyleContext.Provider value={slotStyles}> |
| 48 | <StyledComponent {...otherProps} ref={ref} className={cx(slotStyles?.[slot], props.className)} /> |
| 49 | </StyleContext.Provider> |
| 50 | ) |
| 51 | }) |
| 52 | // @ts-expect-error |
| 53 | StyledSlotProvider.displayName = Component.displayName || Component.name |
| 54 | |
| 55 | return StyledSlotProvider |
| 56 | } |
| 57 | |
| 58 | const withContext = <T, P extends { className?: string | undefined }>( |
| 59 | Component: ElementType, |
no test coverage detected