import React from 'react'; import PropTypes from 'prop-types'; import { Checkbox } from '@buffetjs/core'; import { get } from 'lodash'; import Card from '../Card'; import CardControlsWrapper from '../CardControlsWrapper'; import ListWrapper from '../ListWrapper'; import ListCell from './ListCell'; const List = ({ clickable, data, onChange, onCardClick, selectedItems, small, canSelect, renderCardControl, }) => { const handleClick = e => { e.stopPropagation(); }; return (
{data.map(item => { const { id } = item; const url = get(item, ['formats', 'thumbnail', 'url'], item.url); const checked = selectedItems.findIndex(file => file.id === id) !== -1; const fileUrl = url.startsWith('/') ? `${strapi.backendURL}${url}` : url; return ( {(checked || canSelect) && ( <> {renderCardControl && ( {renderCardControl(id)} )} )} ); })}
); }; List.defaultProps = { clickable: false, canSelect: true, data: [], onChange: () => {}, onCardClick: () => {}, renderCardControl: null, selectedItems: [], small: false, }; List.propTypes = { clickable: PropTypes.bool, canSelect: PropTypes.bool, data: PropTypes.array, onChange: PropTypes.func, onCardClick: PropTypes.func, renderCardControl: PropTypes.func, selectedItems: PropTypes.array, small: PropTypes.bool, }; export default List;