import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["forwardedRef"];
import React from 'react';
var FormContext = /*#__PURE__*/React.createContext({});
export default FormContext;
export function connect(Component) {
  function WrappedField(props) {
    var forwardedRef = props.forwardedRef,
        other = _objectWithoutProperties(props, _excluded);

    return /*#__PURE__*/React.createElement(FormContext.Consumer, null, function (context) {
      return /*#__PURE__*/React.createElement(Component, _extends({}, context, other, {
        ref: forwardedRef
      }));
    });
  }

  function forwardRef(props, ref) {
    return /*#__PURE__*/React.createElement(WrappedField, _extends({}, props, {
      forwardedRef: ref
    }));
  } // Give this component a more helpful display name in DevTools.


  var name = Component.displayName || Component.name;
  forwardRef.displayName = "WithFormValues(".concat(name, ")");
  return /*#__PURE__*/React.forwardRef(forwardRef);
}