"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _react = _interopRequireWildcard(require("react"));
var _elementReact = require("element-react");
var _List = _interopRequireDefault(require("./List"));
var _indexModule = _interopRequireDefault(require("./index.module.scss"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var DialogBody = _elementReact.Dialog.Body,
  DialogFooter = _elementReact.Dialog.Footer;
var MaterialEdit = /*#__PURE__*/function (_Component) {
  (0, _inheritsLoose2["default"])(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["default"].createElement(DialogBody, null, /*#__PURE__*/_react["default"].createElement("div", {
        className: _indexModule["default"]['xt-material-list'],
        style: {
          overflowY: list.length ? 'scroll' : 'hidden'
        }
      }, /*#__PURE__*/_react["default"].createElement(_List["default"], {
        mediaType: mediaType,
        list: list,
        listIndex: listIndex,
        handleListIndex: handleListIndex,
        header: header,
        headerIndex: headerIndex,
        handleHeaderIndex: handleHeaderIndex
      })), /*#__PURE__*/_react["default"].createElement("div", {
        className: _indexModule["default"]['xt-material-edit']
      }, content));
    };

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