import React__default from 'react';
import Icon from '../icon/index.js';
import { useFormContext, useField } from '../use-form/index.js';
import '../extends-C4cduGrv.js';
import '../objectWithoutProperties-TXwlfNxG.js';
import '@fortawesome/react-fontawesome';
import 'prop-types';
import '../icon/icons.js';
import '../icon/library.js';
import '@fortawesome/fontawesome-svg-core';
import '@fortawesome/pro-solid-svg-icons';
import '@fortawesome/pro-light-svg-icons';
import '@fortawesome/free-brands-svg-icons';
import '../slicedToArray-BB-AwwkK.js';
import '../defineProperty-CEd-kZQW.js';
import '../index-qSfOyGhk.js';
import '../typeof-CgC7Bq6K.js';
import '../auto-id.esm-Cly76abB.js';
import '../utils.esm-CKyxlHOy.js';
import '../warning-s9zGJbnw.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, {
    icon: "exclamation-circle",
    className: "text-red-500 mr-1"
  }), field.error);
}

export { InlineValidation as default };
