import React__default from 'react';
import Icon from '../icon/index.js';
import { useFormContext, useField } from '../use-form/index.js';
import '../extends-e61fd370.js';
import '../objectWithoutProperties-72d23964.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-5b664d46.js';
import '../defineProperty-18999f8e.js';
import '../index-81a9bdac.js';
import '../typeof-6c6d8d7a.js';
import '../auto-id.esm-2b54f757.js';
import '../utils.esm-514fad91.js';
import '../warning-ed2bf294.js';
import '../_commonjsHelpers-57e89916.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 };
