import React__default from 'react';
import { I as Icon } from '../index-CMfVNfTW.js';
import { useFormContext, useField } from '../use-form/index.js';
import '../extends-C4cduGrv.js';
import '../defineProperty-CEd-kZQW.js';
import '../slicedToArray-BB-AwwkK.js';
import '../objectWithoutProperties-TXwlfNxG.js';
import '../typeof-CgC7Bq6K.js';
import '../toConsumableArray-dKQYsfpV.js';
import '../index-qSfOyGhk.js';
import 'react-dom';
import 'prop-types';
import 'classnames';
import '../icon/assets/icon-map/index.js';
import '../social-icon/index.js';
import '@fortawesome/react-fontawesome';
import '../social-icon/icons.js';
import '../social-icon/library.js';
import '@fortawesome/fontawesome-svg-core';
import '@fortawesome/free-solid-svg-icons';
import '@fortawesome/free-brands-svg-icons';
import '../tooltip/index.js';
import '../auto-id.esm-CjaDlg7r.js';
import '../utils.esm-BKUEBdyY.js';
import '../warning-s9zGJbnw.js';
import '../portal.esm-D9LQ40g_.js';
import '@reach/visually-hidden';
import '../portal/index.js';
import '../use-rerender-once/index.js';
import '../use-force-update/index.js';
import '../button/button-group.js';
import '../inject-css-BqVV5N0s.js';
import '../_commonjsHelpers-_1FafXWI.js';
import '../use-progress/index.js';
import '../use-trailing-debounce/index.js';

function InlineValidation(_ref) {
  var name = _ref.name;
  var context = useFormContext();
  var config = (context === null || context === void 0 ? void 0 : context.config) || {};
  var field = useField({
    name: name
  }); // To support previous behavior of the validation errors all in one place
  // on the form, we won't show this unless opted in to the new behavior.

  if (!config.validation) return null;
  if (!field.touched) return null;
  if (!field.error) return null;
  return /*#__PURE__*/React__default.createElement("div", {
    className: "text-xs",
    style: {
      height: "17px"
    },
    role: "alert"
  }, /*#__PURE__*/React__default.createElement(Icon, {
    name: "alert-circle",
    size: "sm",
    className: "text-red-500 mr-1"
  }), field.error);
}

export { InlineValidation as default };
