"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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

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

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

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

var React = _interopRequireWildcard(require("react"));

var _bem = require("@zarm-design/bem");

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

var ListItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var className = props.className,
      prefix = props.prefix,
      suffix = props.suffix,
      title = props.title,
      description = props.description,
      children = props.children,
      onClick = props.onClick,
      hasArrow = props.hasArrow,
      restProps = (0, _objectWithoutProperties2.default)(props, ["className", "prefix", "suffix", "title", "description", "children", "onClick", "hasArrow"]);

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

  var bem = (0, _bem.createBEM)('list-item', {
    prefixCls: prefixCls
  });
  var cls = bem([{
    link: !!onClick,
    inline: !!children,
    arrow: !!onClick && hasArrow
  }, className]);
  var prefixRender = prefix && /*#__PURE__*/React.createElement("div", {
    className: bem('prefix')
  }, prefix);
  var suffixRender = suffix && /*#__PURE__*/React.createElement("div", {
    className: bem('suffix')
  }, suffix);
  var titleRender = title && /*#__PURE__*/React.createElement("div", {
    className: bem('title')
  }, title);
  var contentRender = children && /*#__PURE__*/React.createElement("div", {
    className: bem('content')
  }, children);
  var descriptionRender = description && /*#__PURE__*/React.createElement("div", {
    className: bem('description')
  }, description);
  var arrowRender = !!onClick && hasArrow && /*#__PURE__*/React.createElement("div", {
    className: bem('arrow')
  });
  return /*#__PURE__*/React.createElement("li", (0, _extends2.default)({
    ref: ref,
    className: cls,
    onClick: onClick,
    onTouchStart: function onTouchStart() {}
  }, restProps), prefixRender, /*#__PURE__*/React.createElement("div", {
    className: bem('wrapper')
  }, /*#__PURE__*/React.createElement("div", {
    className: bem('inner')
  }, titleRender, contentRender, suffixRender, arrowRender), descriptionRender));
});
ListItem.displayName = 'ListItem';
ListItem.defaultProps = {
  hasArrow: true
};
var _default = ListItem;
exports.default = _default;