// import useMemo from '@/components/rc-util/hooks/useMemo';
import React from 'react';
import { ConfigContext } from '../config-provider/context';
import ListItem from './list-item';
import Pagination from '../pagination/index';
export var ListContext = /*#__PURE__*/React.createContext({});

var ListHoc = function ListHoc(props, ref) {
  var dataSource = props.dataSource,
      renderItem = props.renderItem,
      split = props.split,
      direction = props.direction,
      pagination = props.pagination,
      loadMore = props.loadMore,
      itemLayout = props.itemLayout,
      size = props.size,
      locale = props.locale;

  var _React$useContext = React.useContext(ConfigContext),
      getPrefixClassName = _React$useContext.getPrefixClassName;

  var listPrefix = getPrefixClassName('list');

  var renderEmptyFunc = function renderEmptyFunc(prefixCls) {
    return /*#__PURE__*/React.createElement("div", {
      className: "".concat(prefixCls, "-empty")
    }, locale);
  };

  return /*#__PURE__*/React.createElement(ListContext.Provider, {
    value: {
      itemLayout: itemLayout,
      size: size,
      direction: direction,
      split: split
    }
  }, /*#__PURE__*/React.createElement("div", {
    ref: ref,
    className: "".concat(listPrefix, "-container")
  }, dataSource.length > 0 ? /*#__PURE__*/React.createElement("div", {
    className: "".concat(listPrefix, "-list ").concat(direction)
  }, dataSource === null || dataSource === void 0 ? void 0 : dataSource.map(function (item) {
    return renderItem === null || renderItem === void 0 ? void 0 : renderItem(item);
  })) : renderEmptyFunc(listPrefix), pagination && /*#__PURE__*/React.createElement("div", {
    className: "".concat(listPrefix, "-pagination")
  }, /*#__PURE__*/React.createElement(Pagination, Object.assign({}, pagination))), !pagination && loadMore));
};

var List = /*#__PURE__*/React.forwardRef(ListHoc);
List.Item = ListItem;
List.defaultProps = {
  dataSource: [],
  itemLayout: 'horizontal',
  size: 'default',
  split: true,
  direction: 'vertical'
};
export default List;