import _Form from "@alifd/next/es/form";
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
var _excluded = ["componentType", "mode"];
import _regeneratorRuntime from "@babel/runtime/regenerator";
//这是表单项组件
import React from 'react';
import "./index.scss";
// import { data } from './data'
// import { getChildList } from './api'
import RenderChild from "../common-table/components/render-child";
var FormItem = /*#__PURE__*/function (_React$Component) {
  _inheritsLoose(FormItem, _React$Component);
  function FormItem(props) {
    var _this;
    _this = _React$Component.call(this, props) || this;
    _this._renderChildren = function () {
      var _this$props = _this.props,
        componentType = _this$props.componentType,
        mode = _this$props.mode,
        otherProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
      var isPreview = mode === 'browse' ? true : false;
      return /*#__PURE__*/React.createElement(RenderChild, _extends({
        isPreview: isPreview,
        componentType: componentType
      }, otherProps));
    };
    _this.state = {
      childList: []
    };
    return _this;
  }
  var _proto = FormItem.prototype;
  _proto.componentDidMount = /*#__PURE__*/function () {
    var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
      return _regeneratorRuntime.wrap(function _callee$(_context) {
        while (1) switch (_context.prev = _context.next) {
          case 0:
          case "end":
            return _context.stop();
        }
      }, _callee);
    }));
    function componentDidMount() {
      return _componentDidMount.apply(this, arguments);
    }
    return componentDidMount;
  }();
  _proto.componentWillUnmount = function componentWillUnmount() {
    // events.off('getData', () => this.getData);
  };
  _proto.render = function render() {
    var _this$props2 = this.props,
      displayName = _this$props2.displayName,
      fieldName = _this$props2.fieldName,
      isDisabled = _this$props2.isDisabled,
      isRequired = _this$props2.isRequired;
    // 表单项
    var formItemLayoutItem = {
      labelCol: {
        span: 8
      },
      wrapperCol: {
        span: 14
      }
    };

    // isShow = isShow === undefined ? true : isShow
    return /*#__PURE__*/React.createElement(_Form.Item, _extends({
      colon: true,
      name: fieldName
    }, formItemLayoutItem, {
      requiredMessage: "\u8BF7\u8F93\u5165" + displayName,
      required: isRequired,
      disabled: isDisabled,
      labelAlign: "left",
      label: displayName
    }), this._renderChildren());
  };
  return FormItem;
}(React.Component);
FormItem.displayName = void 0;
FormItem.displayName = 'FormItem';
export default FormItem;