var _excluded = ["serverActions", "refManager"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React, { forwardRef, useMemo } from 'react';
import Pagination from "../../../Pagination";
import withContainer from "../../utils/withContainer";
import { getText } from "../../../../locales";
var WithPagination = /*#__PURE__*/forwardRef(function (props) {
  var listAction = props.serverActions.list,
    refManager = props.refManager,
    otherProps = _objectWithoutProperties(props, _excluded);
  var pagination = listAction.pagination,
    data = listAction.data;

  /** 分页配置属性 */
  var paginationProps = useMemo(function () {
    return {
      showTotal: function showTotal(total) {
        return getText('table-pagination-total')((pagination === null || pagination === void 0 ? void 0 : pagination.pageNumber) || 1, Math.ceil(total / ((pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) || 10)));
      },
      total: (data === null || data === void 0 ? void 0 : data.count) || 0,
      current: (pagination === null || pagination === void 0 ? void 0 : pagination.pageNumber) || 1,
      pageSize: (pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) || 10,
      onChange: listAction.onPageChange
    };
  }, [pagination === null || pagination === void 0 ? void 0 : pagination.pageNumber, pagination === null || pagination === void 0 ? void 0 : pagination.pageSize, data === null || data === void 0 ? void 0 : data.count, listAction.onPageChange]);
  if (!pagination) {
    console.error('分页功能未启用');
    return null;
  }
  return /*#__PURE__*/React.createElement(Pagination, _extends({
    showTotal: function showTotal(total) {
      return getText('table-pagination-total')((pagination === null || pagination === void 0 ? void 0 : pagination.pageNumber) || 1, total);
    }
  }, otherProps, {
    total: (data === null || data === void 0 ? void 0 : data.count) || 0,
    current: (pagination === null || pagination === void 0 ? void 0 : pagination.pageNumber) || 1,
    pageSize: (pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) || 10,
    onChange: listAction.onPageChange
  }));
});
export default withContainer(WithPagination, 'pagination');