var _excluded = ["className", "style", "layout", "footer", "children", "colon", "border", "labelAlign", "inputAlign", "showValidateMessage"];

function _extends() { _extends = Object.assign || 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 _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, { forwardRef, useContext } from 'react';
import clsx from 'clsx';
import RcForm from 'rc-field-form';
import ConfigProviderContext from '../config-provider/ConfigProviderContext';
import { FormContext } from './FormContext';
var Form = /*#__PURE__*/forwardRef(function (props, ref) {
  var _useContext = useContext(ConfigProviderContext),
      prefixCls = _useContext.prefixCls,
      createNamespace = _useContext.createNamespace;

  var _createNamespace = createNamespace('form', prefixCls),
      bem = _createNamespace[0];

  var className = props.className,
      style = props.style,
      layout = props.layout,
      footer = props.footer,
      children = props.children,
      colon = props.colon,
      border = props.border,
      labelAlign = props.labelAlign,
      inputAlign = props.inputAlign,
      showValidateMessage = props.showValidateMessage,
      formProps = _objectWithoutPropertiesLoose(props, _excluded);

  return /*#__PURE__*/React.createElement(FormContext.Provider, {
    value: {
      layout: layout,
      colon: colon,
      border: border,
      showValidateMessage: showValidateMessage,
      inputAlign: inputAlign,
      labelAlign: labelAlign
    }
  }, /*#__PURE__*/React.createElement(RcForm, _extends({
    className: clsx(bem(), className),
    style: style,
    ref: ref
  }, formProps), children, footer && /*#__PURE__*/React.createElement("div", {
    className: clsx(bem('footer'))
  }, footer)));
});
Form.defaultProps = {
  showValidateMessage: true
};
export default Form;