var _excluded = ["span", "ellipsis", "inputExtra", "extra", "error", "children"],
  _excluded2 = ["span", "ellipsis"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React, { useImperativeHandle, forwardRef, useRef, useContext } from 'react';
import Div from "./../../Letter/Base";
import FormContext from "./../FormContext";
import getExtraNode from "./getExtraNode";
var FormMain = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var span = _ref.span,
    ellipsis = _ref.ellipsis,
    inputExtra = _ref.inputExtra,
    extra = _ref.extra,
    error = _ref.error,
    children = _ref.children,
    props = _objectWithoutProperties(_ref, _excluded);
  // 获取全局配置
  var _useContext = useContext(FormContext),
    layout = _useContext.layout,
    mainCol = _useContext.mainCol;
  var rootRef = useRef(null);

  // Expose
  useImperativeHandle(ref, function () {
    return {
      rootDOM: rootRef.current,
      getRootDOM: function getRootDOM() {
        return rootRef.current;
      }
    };
  });
  var _ref2 = mainCol || {},
    globalSpan = _ref2.span,
    globalEllipsis = _ref2.ellipsis,
    mainColProps = _objectWithoutProperties(_ref2, _excluded2);
  return /*#__PURE__*/React.createElement("div", _extends({}, mainColProps, props, {
    className: "form-item-main".concat(props.className ? ' ' + props.className : '').concat(layout === 'horizontal' ? " col col-".concat(span || globalSpan || 16) : ''),
    ref: rootRef
  }), /*#__PURE__*/React.createElement("div", {
    className: "form-item-main-input"
  }, ellipsis !== null && ellipsis !== void 0 && ellipsis.rows && typeof children === 'string' ? /*#__PURE__*/React.createElement(Div, {
    ellipsis: ellipsis || globalEllipsis
  }, children) : children, getExtraNode(inputExtra, {
    className: 'form-item-main-input-extra'
  })), error && /*#__PURE__*/React.createElement("div", {
    className: "form-item-main-error"
  }, error), getExtraNode(extra, {
    className: 'form-item-main-extra'
  }));
});
export default FormMain;