import React from 'react'; import { useIntl } from 'react-intl'; import noop from 'lodash/noop'; import { GridList } from '@box/blueprint-web'; import { ItemDate, ItemOptions, ItemTypeIcon } from '../item'; import { isThumbnailAvailable } from '../utils'; import { TYPE_FOLDER, TYPE_WEBLINK, VIEW_MODE_GRID } from '../../../constants'; import messages from './messages'; import type { BoxItem, View } from '../../../common/types/core'; import type { ItemAction, ItemEventHandlers, ItemEventPermissions } from '../item'; import './ItemGrid.scss'; export interface ItemGridProps extends ItemEventHandlers, ItemEventPermissions { gridColumnCount?: number; isTouch?: boolean; itemActions?: ItemAction[]; items: BoxItem[]; portalElement?: HTMLElement; view: View; } const ItemGrid = ({ canPreview, gridColumnCount = 1, isTouch, items, onItemClick = noop, view, ...rest }: ItemGridProps) => { const { formatMessage } = useIntl(); return ( {items.map(item => { const { id, name, thumbnailUrl, type } = item; const handleAction = () => { if (type === TYPE_FOLDER || (!isTouch && (type === TYPE_WEBLINK || canPreview))) { onItemClick(item); } }; return ( {thumbnailUrl && isThumbnailAvailable(item) ? ( {name} ) : (
)}
{name}
); })}
); }; export default ItemGrid;