import _Form from "@alifd/next/es/form";
import _extends from "@babel/runtime/helpers/extends";
import _Switch from "@alifd/next/es/switch";
import _Rating from "@alifd/next/es/rating";
import _TimePicker from "@alifd/next/es/time-picker2";
import _NumberPicker from "@alifd/next/es/number-picker";
import _DatePicker from "@alifd/next/es/date-picker2";
import _Input from "@alifd/next/es/input";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
//这是表单项组件
import React from 'react';
import "./index.scss";
var FormItem = /*#__PURE__*/function (_React$Component) {
  _inheritsLoose(FormItem, _React$Component);
  function FormItem(props) {
    var _this;
    _this = _React$Component.call(this, props) || this;
    // 控件类型
    _this.renderColumns = function () {
      var _this$props = _this.props,
        componentType = _this$props.componentType,
        placeholder = _this$props.placeholder,
        defaultValue = _this$props.defaultValue;
      if (componentType === 'Input') {
        return /*#__PURE__*/React.createElement(_Input, {
          placeholder: placeholder,
          defaultValue: defaultValue
        });
      }
      if (componentType === 'DatePicker') {
        return /*#__PURE__*/React.createElement(_DatePicker, {
          outputFormat: "YYYY-MM-DD",
          placeholder: placeholder,
          defaultValue: defaultValue
        });
      }
      if (componentType === 'TextArea') {
        return /*#__PURE__*/React.createElement(_Input.TextArea, {
          placeholder: placeholder,
          defaultValue: defaultValue
        });
      }
      if (componentType === 'NumberPicker') {
        return /*#__PURE__*/React.createElement(_NumberPicker, {
          defaultValue: defaultValue
        });
      }
      if (componentType === 'TimePicker') {
        return /*#__PURE__*/React.createElement(_TimePicker, {
          placeholder: placeholder,
          defaultValue: defaultValue
        });
      }
      if (componentType === 'Rating') {
        return /*#__PURE__*/React.createElement(_Rating, {
          defaultValue: defaultValue
        });
      }
      if (componentType === 'Switch') {
        return /*#__PURE__*/React.createElement(_Switch, {
          defaultChecked: defaultValue
        });
      }
      return /*#__PURE__*/React.createElement(_Input, {
        placeholder: placeholder,
        defaultValue: defaultValue
      });
    };
    return _this;
  }
  var _proto = FormItem.prototype;
  _proto.render = function render() {
    var _this$props2 = this.props,
      displayName = _this$props2.displayName,
      isPreview = _this$props2.isPreview,
      fieldName = _this$props2.fieldName,
      style = _this$props2.style,
      isEdit = _this$props2.isEdit,
      isEmpty = _this$props2.isEmpty,
      extraText = _this$props2.extraText;
    // 表单项
    var formItemLayoutItem = {
      labelCol: {
        span: 8
      },
      wrapperCol: {
        span: 14
      }
    };
    return /*#__PURE__*/React.createElement(_Form.Item, _extends({
      style: style,
      colon: true,
      name: fieldName
    }, formItemLayoutItem, {
      help: extraText,
      isPreview: !isPreview,
      required: isEmpty,
      disabled: isEdit,
      labelAlign: "left",
      label: displayName,
      requiredMessage: "\u8BF7\u8F93\u5165" + displayName
    }), this.renderColumns());
  };
  return FormItem;
}(React.Component);
FormItem.displayName = void 0;
export default FormItem;