import { observer } from 'mobx-react-lite'; import { GridCardItem } from './GridCardItem'; import React, { ReactElement } from 'react'; import { ActionCellAPI, GridBaseState } from '../../state'; import { FiltersMap } from '@wix/bex-core'; import { AddItemProps } from '@wix/design-system'; import { ActionCellProps } from '../ActionCell'; import { SupportedCardGalleryItemProps } from './SupportedCardGalleryItemProps'; import { GridDragAndDrop } from '../GridDragAndDropDndKit/GridDragAndDrop'; import type { Preset } from './Grid.types'; export interface GridItemProps { state: GridBaseState; preset?: Preset; renderAddItem?: () => ReactElement; renderItem?: ( item: T, index: number, ) => Partial; index: number; rowIndex?: number; columnIndex?: number; actionCell?: | ActionCellProps | ((item: T, index: number, api: ActionCellAPI) => ActionCellProps); dragAndDrop?: typeof GridDragAndDrop; isOverlay?: boolean; } function _GridItem(props: GridItemProps) { const { state, preset, index, rowIndex, columnIndex, renderItem, renderAddItem, actionCell, dragAndDrop, isOverlay, } = props; const renderType = state.getItemRenderTypeAt(index); const { collection: { query: { hasNonPersistentActiveFilters }, }, } = state; if (renderType === null) { return null; } if (renderType === 'trailing') { if (hasNonPersistentActiveFilters) { return null; } return (
state.onAddItemClick()} > {renderAddItem?.()}
); } let child = ( ); if (dragAndDrop) { const { DraggableCard } = dragAndDrop; child = ( {child} ); } return child; } export const GridItem = observer(_GridItem);