import type { ImageProps } from '@graphcommerce/image' import { extendableComponent, sxx } from '@graphcommerce/next-ui' import type { SxProps, Theme } from '@mui/material' import { Skeleton } from '@mui/material' import React from 'react' import type { ProductListItemFragment } from '../../graphql' import { productLink } from '../../hooks/useProductLink' import { ProductListPrice } from '../ProductListPrice/ProductListPrice' import { ProductDiscountLabel } from './ProductDiscountLabel' import type { ProductListItemImageProps } from './ProductListItemImage' import { ProductListItemImage, ProductListItemImageSkeleton } from './ProductListItemImage' import type { ProductListsItemImageAreaProps } from './ProductListItemImageContainer' import { ProductImageContainer, ProductListItemImageAreas } from './ProductListItemImageContainer' import type { ProductListItemLinkOrDivProps } from './ProductListItemLinkOrDiv' import { ProductListItemLinkOrDiv } from './ProductListItemLinkOrDiv' import type { ProductListItemTitleAndPriceProps } from './ProductListItemTitleAndPrice' import { ProductListItemTitleAndPrice } from './ProductListItemTitleAndPrice' import { ProductNewLabel } from './ProductNewLabel' const { classes } = extendableComponent('ProductListItem', [ 'root', 'item', 'title', 'titleContainer', 'subtitle', 'price', 'overlayItems', 'topLeft', 'topRight', 'bottomLeft', 'bottomRight', 'imageContainer', 'placeholder', 'image', 'discount', 'new', ] as const) type StyleProps = { imageOnly?: boolean } export type BaseProps = { imageOnly?: boolean children?: React.ReactNode sx?: SxProps onClick?: ( event: React.MouseEvent, item: ProductListItemFragment, ) => void slotProps?: { root?: Partial image?: Partial imageAreas?: Partial titleAndPrice?: Partial } } & StyleProps & Omit & Omit & Omit & Pick export type ProductListItemSkeletonProps = BaseProps & { __typename: 'Skeleton' } export type ProductListItemRealProps = BaseProps & ProductListItemFragment /** @public */ export function ProductListItemReal(props: ProductListItemRealProps) { const { subTitle, topLeft, topRight, bottomLeft, bottomRight, small_image, name, price_range, children, imageOnly = false, loading, sizes, dontReportWronglySizedImages, aspectRatio = [4, 3], titleComponent = 'h2', sx = [], onClick, slotProps = {}, } = props return ( ) => onClick?.(e, props)} {...slotProps.root} sx={sxx(sx, slotProps.root?.sx)} ref={slotProps.root?.ref as React.Ref} > {!imageOnly && ( {topLeft} } {...slotProps.imageAreas} /> )} {!imageOnly && ( <> {children} )} ) } /** @public */ export function ProductListItemSkeleton(props: BaseProps) { const { children, imageOnly = false, aspectRatio, titleComponent = 'h2', sx = [], slotProps = {}, } = props return ( } > {!imageOnly && ( <> } subTitle={} {...slotProps.titleAndPrice} > {children} )} ) }