import type { ItemScrollerProps } from '@graphcommerce/next-ui' import { ItemScroller, RenderType, responsiveVal } from '@graphcommerce/next-ui' import type { ContainerProps, SxProps, Theme, TypographyProps } from '@mui/material' import { Box, Container, Typography, useTheme } from '@mui/material' import React, { forwardRef, useContext } from 'react' import { AddProductsToCartContext, AddProductsToCartForm } from '../AddProductsToCart' import type { ProductListItemProps } from '../ProductListItem/ProductListItem' import type { ProductListItemRenderer, ProductListItemType } from '../ProductListItems/renderer' export type ProductScrollerProps = { title?: React.ReactNode items: ProductListItemType[] productListRenderer: ProductListItemRenderer imageOnly?: ProductListItemProps['imageOnly'] sx?: SxProps containerProps?: ContainerProps titleProps?: TypographyProps itemScrollerProps?: Omit sizes?: string } export const ProductScroller = forwardRef( (props: ProductScrollerProps, ref) => { const { title = '', items, productListRenderer, imageOnly = false, sx = [], containerProps, titleProps, itemScrollerProps, sizes = responsiveVal(200, 300), } = props const theme = useTheme() const Wrapper = useContext(AddProductsToCartContext) ? React.Fragment : AddProductsToCartForm if (!items || !items.length) return null return ( {title && ( {title} )} {!!items.length && ( {items.map((item) => ( ))} )} ) }, )