import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import React, { Component } from 'react';
import { Dialog, Button } from 'element-react';
import List from "./List";
import Style from "./index.module.scss";
var DialogBody = Dialog.Body,
  DialogFooter = Dialog.Footer;
var MaterialEdit = /*#__PURE__*/function (_Component) {
  _inheritsLoose(MaterialEdit, _Component);
  function MaterialEdit(props) {
    var _this;
    _this = _Component.call(this, props) || this;
    _this.state = {};
    return _this;
  }
  var _proto = MaterialEdit.prototype;
  _proto.render = function render() {
    var _this$props = this.props,
      name = _this$props.name,
      mediaType = _this$props.mediaType,
      dialogVisible = _this$props.dialogVisible,
      list = _this$props.list,
      listIndex = _this$props.listIndex,
      handleListIndex = _this$props.handleListIndex,
      header = _this$props.header,
      headerIndex = _this$props.headerIndex,
      handleHeaderIndex = _this$props.handleHeaderIndex,
      handleVisible = _this$props.handleVisible,
      content = _this$props.content,
      onSubmit = _this$props.onSubmit,
      onCancel = _this$props.onCancel;

    // body component
    var Body = function Body() {
      return /*#__PURE__*/React.createElement(DialogBody, null, /*#__PURE__*/React.createElement("div", {
        className: Style['xt-material-list'],
        style: {
          overflowY: list.length ? 'scroll' : 'hidden'
        }
      }, /*#__PURE__*/React.createElement(List, {
        mediaType: mediaType,
        list: list,
        listIndex: listIndex,
        handleListIndex: handleListIndex,
        header: header,
        headerIndex: headerIndex,
        handleHeaderIndex: handleHeaderIndex
      })), /*#__PURE__*/React.createElement("div", {
        className: Style['xt-material-edit']
      }, content));
    };

    // footer component
    var Footer = function Footer() {
      return /*#__PURE__*/React.createElement(DialogFooter, {
        className: "dialog-footer"
      }, /*#__PURE__*/React.createElement(Button, {
        type: "primary",
        onClick: onSubmit
      }, /*#__PURE__*/React.createElement("span", {
        className: Style['xt-save-icon'] + " xiatu-rich xt-baocun"
      }), "\u4FDD\u5B58", name));
    };
    return /*#__PURE__*/React.createElement("section", {
      className: Style['xt-material-container']
    }, /*#__PURE__*/React.createElement(Button, {
      onClick: function onClick() {
        return handleVisible(true);
      }
    }, "\u7F16\u8F91", name), /*#__PURE__*/React.createElement(Dialog, {
      title: "\u7F16\u8F91" + name + "\u5185\u5BB9",
      visible: dialogVisible,
      onCancel: onCancel,
      lockScroll: false
    }, /*#__PURE__*/React.createElement(Body, null), /*#__PURE__*/React.createElement(Footer, null)));
  };
  return MaterialEdit;
}(Component);
export { MaterialEdit as default };