"use strict";
require("core-js/modules/es.array.iterator.js");
require("core-js/modules/es.object.get-own-property-descriptor.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/es.string.iterator.js");
require("core-js/modules/es.weak-map.js");
require("core-js/modules/web.dom-collections.iterator.js");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var React = _interopRequireWildcard(require("react"));
var _reactBootstrap = require("react-bootstrap");
var _reactFontawesome = require("@fortawesome/react-fontawesome");
var _validationLabel = _interopRequireDefault(require("../common/validation-label"));
var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
var _reactI18next = require("react-i18next");
var _excluded = ["defaultValue", "empty", "error", "label", "onChange", "tooltipText", "warn"];
/*
* Copyright (C) 2016 Ben Ockmore
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
var cache;
function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
/**
* Presentational component. This component renders a plain text input and a
* ValidationLabel for a field labelled 'Name'.
*
* @param {Object} props - The properties passed to the component.
* @param {boolean} props.error - Passed to the ValidationLabel within the
* component to indicate a validation error.
* @param {boolean} props.warn - Passed to the ValidationLabel within the
* component to indicate a validation warning.
* @param {boolean} props.empty - Passed to the ValidationLabel within the
* component to indicate that the field is empty.
* @returns {Object} a React component containing the rendered input
*/
function NameField(_ref) {
var _ref$defaultValue = _ref.defaultValue,
defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
_ref$empty = _ref.empty,
empty = _ref$empty === void 0 ? false : _ref$empty,
_ref$error = _ref.error,
error = _ref$error === void 0 ? false : _ref$error,
_ref$label = _ref.label,
label = _ref$label === void 0 ? '' : _ref$label,
_ref$onChange = _ref.onChange,
onChange = _ref$onChange === void 0 ? null : _ref$onChange,
_ref$tooltipText = _ref.tooltipText,
tooltipText = _ref$tooltipText === void 0 ? null : _ref$tooltipText,
_ref$warn = _ref.warn,
warn = _ref$warn === void 0 ? false : _ref$warn,
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
var _useTranslation = (0, _reactI18next.useTranslation)(),
translate = _useTranslation.t;
var inputLabel = /*#__PURE__*/React.createElement(_validationLabel.default, {
empty: empty,
error: error,
warn: warn
}, !label ? translate('common.name') : label);
var helpIconElement = tooltipText && /*#__PURE__*/React.createElement(_reactBootstrap.OverlayTrigger, {
delay: 50,
overlay: /*#__PURE__*/React.createElement(_reactBootstrap.Tooltip, null, tooltipText)
}, /*#__PURE__*/React.createElement(_reactFontawesome.FontAwesomeIcon, {
className: "margin-left-0-5",
icon: _freeSolidSvgIcons.faQuestionCircle
}));
return /*#__PURE__*/React.createElement(_reactBootstrap.Form.Group, null, /*#__PURE__*/React.createElement(_reactBootstrap.Form.Label, null, inputLabel, helpIconElement), /*#__PURE__*/React.createElement(_reactBootstrap.Form.Control, (0, _extends2.default)({
defaultValue: defaultValue,
type: "text",
onChange: onChange
}, rest)));
}
NameField.displayName = 'NameField';
var _default = exports.default = NameField;
//# sourceMappingURL=name-field.js.map