import { createElement, Fragment } from "react";
import { EntityListSubTree } from "@contember/binding";
import { DataGridContainer } from "../base/DataGridContainer/DataGridContainer.js";
const renderGrid = ({ setIsColumnHidden, setFilter, setOrderBy, updatePaging, setLayout }, treeRootId, displayedState, desiredState, environment, containerProps = {}, component, componentProps) => {
  const {
    entities,
    paging: { pageIndex, itemsPerPage },
    hiddenColumns,
    filter,
    columns,
    orderBy
  } = displayedState;
  return /* @__PURE__ */ createElement(EntityListSubTree, {
    entities: {
      ...entities,
      filter
    },
    treeRootId,
    offset: itemsPerPage === null ? void 0 : itemsPerPage * pageIndex,
    limit: itemsPerPage === null ? void 0 : itemsPerPage,
    orderBy,
    listComponent: component ?? DataGridContainer,
    listProps: {
      desiredState,
      displayedState,
      entityName: entities.entityName,
      filter,
      onEntityClick: containerProps.onEntityClick,
      selectedEntityKeys: containerProps.selectedEntityIds,
      tile: containerProps.tile,
      tileSize: containerProps.tileSize,
      setIsColumnHidden,
      setFilter,
      setOrderBy,
      setLayout,
      updatePaging,
      emptyMessageComponentExtraProps: containerProps.emptyMessageComponentExtraProps,
      emptyMessageComponent: containerProps.emptyMessageComponent,
      emptyMessage: containerProps.emptyMessage,
      ...componentProps
    }
  }, containerProps.tile, Array.from(columns).filter(([key]) => !hiddenColumns[key]).map(([key, props]) => /* @__PURE__ */ createElement(Fragment, {
    key
  }, props.header, props.children)));
};
export { renderGrid };
//# sourceMappingURL=renderGrid.js.map
