"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _typeof = require("@babel/runtime/helpers/typeof");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _react = _interopRequireWildcard(require("react"));

var _iconsReact = require("@wfp/icons-react");

var _classnames = _interopRequireDefault(require("classnames"));

var _js = require("../../globals/js");

var _Tooltip = _interopRequireDefault(require("../Tooltip/Tooltip"));

var _excluded = ["className", "children", "description", "icon"];

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var prefix = _js.settings.prefix;
/** FormHint allows you to add a longer explanation to an input element. */

var FormHint = function FormHint(_ref) {
  var className = _ref.className,
      children = _ref.children,
      description = _ref.description,
      icon = _ref.icon,
      other = (0, _objectWithoutProperties2.default)(_ref, _excluded);
  var formHintClasses = (0, _classnames.default)("".concat(prefix, "--form-hint"), className);
  return /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
    content: children
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: formHintClasses
  }, /*#__PURE__*/_react.default.createElement(_iconsReact.InfoSolid16, {
    width: "15",
    height: "15",
    description: children
  })));
};

FormHint.propTypes = {
  /**
   * Specify an optional className to be applied to the wrapper node
   */
  className: _propTypes.default.string,

  /**
   * The tooltips content can be a string or an component
   */
  children: _propTypes.default.node,

  /**
   * Specify a custom icon for the hint
   */
  icon: _propTypes.default.object
};
FormHint.defaultProps = {
  icon: _iconsReact.InfoSolid16
};
var _default = FormHint;
exports.default = _default;