"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _context = require("../config-provider/context");

var _list = require("./list");

var ListItemHoc = function ListItemHoc(props, ref) {
  var actions = props.actions,
      extra = props.extra,
      children = props.children;

  var _React$useContext = _react.default.useContext(_list.ListContext),
      itemLayout = _React$useContext.itemLayout,
      size = _React$useContext.size,
      direction = _React$useContext.direction,
      split = _React$useContext.split;

  var _React$useContext2 = _react.default.useContext(_context.ConfigContext),
      getPrefixClassName = _React$useContext2.getPrefixClassName;

  var listItemPrefix = getPrefixClassName('list-item');
  return /*#__PURE__*/_react.default.createElement("div", {
    ref: ref,
    className: "".concat(listItemPrefix, "-container ").concat(size, " ").concat(itemLayout, " list-").concat(direction, " ").concat(split && 'split')
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(listItemPrefix, "-content")
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(listItemPrefix, "-slots")
  }, children), actions && actions.length > 0 ? /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(listItemPrefix, "-actions")
  }, actions.map(function (item) {
    return /*#__PURE__*/_react.default.createElement("div", {
      className: "".concat(listItemPrefix, "-actions-item")
    }, item);
  })) : null), extra && /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(listItemPrefix, "-extra")
  }, extra));
};

var Meta = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
  var avatar = props.avatar,
      description = props.description,
      title = props.title;

  var _React$useContext3 = _react.default.useContext(_context.ConfigContext),
      getPrefixClassName = _React$useContext3.getPrefixClassName;

  var listItemMetaPrefix = getPrefixClassName('list-item-meta');
  return /*#__PURE__*/_react.default.createElement("div", {
    ref: ref,
    className: "".concat(listItemMetaPrefix, "-container")
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(listItemMetaPrefix, "-avatar")
  }, typeof avatar === 'string' ? /*#__PURE__*/_react.default.createElement("img", {
    src: "",
    alt: ""
  }) : avatar), /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(listItemMetaPrefix, "-content")
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(listItemMetaPrefix, "-title")
  }, title), /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(listItemMetaPrefix, "-description")
  }, description)));
});

Meta.defaultProps = {
  avatar: '',
  description: '中列表，进店规则禁用于多网店模式和导流模式，单网店模式下，用户进入商家店铺',
  title: '列表标题'
};

var Card = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
  var title = props.title,
      children = props.children;

  var _React$useContext4 = _react.default.useContext(_context.ConfigContext),
      getPrefixClassName = _React$useContext4.getPrefixClassName;

  var listItemMetaPrefix = getPrefixClassName('list-item-card');
  return /*#__PURE__*/_react.default.createElement("div", {
    ref: ref,
    className: "".concat(listItemMetaPrefix, "-container")
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(listItemMetaPrefix, "-title")
  }, title), /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(listItemMetaPrefix, "-content")
  }, children));
});

Card.defaultProps = {};

var ListItem = /*#__PURE__*/_react.default.forwardRef(ListItemHoc);

ListItem.Meta = Meta;
ListItem.Card = Card;
ListItem.defaultProps = {};
var _default = ListItem;
exports.default = _default;