import React from "react";
import "./index.less";

import IconFont from '../../../themeComponents/IconFont'
import VList from '../../../components/VList'


export default class ClearList extends React.Component {
  deleteItem = (item, e) => {
    e.stopPropagation();
    e.preventDefault();
    const { deleteItem } = this.props;
    deleteItem && deleteItem(item);
  };

  render() {
    const { className = "" , deleteItem, renderItemExt, ...props } = this.props;
    return (
      <VList.CheckList
        {...props}
        className={`lm-c-clear-list-wrapper ${className}`}
        renderItemExt={item =>
          renderItemExt
            ? renderItemExt(item)
            : deleteItem && (
                <span className="clear-item" onClick={e => this.deleteItem(item, e)}>
                  <IconFont type="icon-S_Edit_LineClose" title="删除" />
                </span>
              )
        }
      />
    );
  }
}
