"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
require("./index.scss");
var _close = _interopRequireDefault(require("../../assets/icon/search-history-list/close.png"));
var _time = _interopRequireDefault(require("../../assets/icon/search-history-list/time.png"));
var _childrenNodeHandle = require("../../../src/utils/children-node-handle");
var _excluded = ["iconSrc", "dataList", "isShowDelete", "isLeftIcon", "children"];
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var SearchHistoryList = function SearchHistoryList(props) {
  var _props$iconSrc = props.iconSrc,
    iconSrc = _props$iconSrc === void 0 ? '' : _props$iconSrc,
    dataList = props.dataList,
    _props$isShowDelete = props.isShowDelete,
    isShowDelete = _props$isShowDelete === void 0 ? true : _props$isShowDelete,
    isLeftIcon = props.isLeftIcon,
    children = props.children,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded);
  var deleteItem = function deleteItem(index) {
    dataList.splice(index, 1);
  };
  var _otherProps = otherProps || {};
  return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
    className: "search-history-list"
  }, _otherProps), dataList && dataList.map(function (item, index) {
    return /*#__PURE__*/React.createElement("div", {
      className: "search-history-item",
      key: index
    }, /*#__PURE__*/React.createElement("div", {
      className: "search-history-item-left"
    }, isLeftIcon && (0, _childrenNodeHandle.convertChildren)(children, 'image-1', {
      imgSrc: iconSrc || _time["default"],
      className: 'search-history-icon'
    }), (0, _childrenNodeHandle.convertChildren)(children, 'text-1', {
      children: item.content,
      className: 'search-history-content'
    })), isShowDelete && (0, _childrenNodeHandle.convertChildren)(children, 'image-2', {
      imgSrc: _close["default"],
      className: 'search-history-delete',
      onClick: function onClick() {
        return deleteItem(index);
      }
    }));
  }));
};
var _default = exports["default"] = SearchHistoryList;