import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["iconSrc", "dataList", "isShowDelete", "isLeftIcon", "children"];
import * as React from 'react';
import "./index.scss";
import closeIcon from "../../assets/icon/search-history-list/close.png";
import timeIcon from "../../assets/icon/search-history-list/time.png";
import { convertChildren } from "../../../src/utils/children-node-handle";
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 = _objectWithoutPropertiesLoose(props, _excluded);
  var deleteItem = function deleteItem(index) {
    dataList.splice(index, 1);
  };
  var _otherProps = otherProps || {};
  return /*#__PURE__*/React.createElement("div", _extends({
    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 && convertChildren(children, 'image-1', {
      imgSrc: iconSrc || timeIcon,
      className: 'search-history-icon'
    }), convertChildren(children, 'text-1', {
      children: item.content,
      className: 'search-history-content'
    })), isShowDelete && convertChildren(children, 'image-2', {
      imgSrc: closeIcon,
      className: 'search-history-delete',
      onClick: function onClick() {
        return deleteItem(index);
      }
    }));
  }));
};
export default SearchHistoryList;