import TableRow from "./TableRow";
import React from "react";
import { Droppable } from "react-beautiful-dnd";
const TableBody = (props) => {
    const getBody = (provided) => {
        // Mobile view: render as list
        if (props.isMobile) {
            return (React.createElement("div", Object.assign({ id: props.id, ref: provided === null || provided === void 0 ? void 0 : provided.innerRef }, provided === null || provided === void 0 ? void 0 : provided.droppableProps, { className: "divide-y divide-gray-200 bg-white" }),
                props.data &&
                    props.data.map((item, i) => {
                        var _a;
                        return (React.createElement(TableRow, { isBulkActionsEnabled: props.isBulkActionsEnabled, onItemSelected: props.onItemSelected, onItemDeselected: props.onItemDeselected, isItemSelected: ((_a = props.selectedItems) === null || _a === void 0 ? void 0 : _a.filter((selectedItem) => {
                                var _a, _b;
                                if (props.matchBulkSelectedItemByField === undefined) {
                                    return false;
                                }
                                return (((_a = selectedItem[props.matchBulkSelectedItemByField]) === null || _a === void 0 ? void 0 : _a.toString()) ===
                                    ((_b = item[props.matchBulkSelectedItemByField]) === null || _b === void 0 ? void 0 : _b.toString()));
                            }).length) > 0 || false, dragAndDropScope: props.dragAndDropScope, enableDragAndDrop: props.enableDragAndDrop, key: i, item: item, columns: props.columns, actionButtons: props.actionButtons, dragDropIdField: props.dragDropIdField, dragDropIndexField: props.dragDropIndexField, isMobile: true }));
                    }), provided === null || provided === void 0 ? void 0 :
                provided.placeholder));
        }
        // Desktop view: render as table
        return (React.createElement("tbody", Object.assign({ id: props.id, ref: provided === null || provided === void 0 ? void 0 : provided.innerRef }, provided === null || provided === void 0 ? void 0 : provided.droppableProps, { className: "divide-y divide-gray-200 bg-white" }),
            props.data &&
                props.data.map((item, i) => {
                    var _a;
                    return (React.createElement(TableRow, { isBulkActionsEnabled: props.isBulkActionsEnabled, onItemSelected: props.onItemSelected, onItemDeselected: props.onItemDeselected, isItemSelected: ((_a = props.selectedItems) === null || _a === void 0 ? void 0 : _a.filter((selectedItem) => {
                            var _a, _b;
                            if (props.matchBulkSelectedItemByField === undefined) {
                                return false;
                            }
                            return (((_a = selectedItem[props.matchBulkSelectedItemByField]) === null || _a === void 0 ? void 0 : _a.toString()) ===
                                ((_b = item[props.matchBulkSelectedItemByField]) === null || _b === void 0 ? void 0 : _b.toString()));
                        }).length) > 0 || false, dragAndDropScope: props.dragAndDropScope, enableDragAndDrop: props.enableDragAndDrop, key: i, item: item, columns: props.columns, actionButtons: props.actionButtons, dragDropIdField: props.dragDropIdField, dragDropIndexField: props.dragDropIndexField, isMobile: false }));
                }), provided === null || provided === void 0 ? void 0 :
            provided.placeholder));
    };
    if (props.enableDragAndDrop) {
        return (React.createElement(Droppable, { droppableId: props.dragAndDropScope || "" }, (provided) => {
            return getBody(provided);
        }));
    }
    return getBody();
};
export default TableBody;
//# sourceMappingURL=TableBody.js.map