"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactBootstrap = require("react-bootstrap");
var _actions = require("./actions");
var _aliasModalBody = _interopRequireDefault(require("./alias-modal-body"));
var _reactFontawesome = require("@fortawesome/react-fontawesome");
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _reactRedux = require("react-redux");
var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
/*
* 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.
*/
/**
* Container component. The AliasEditor component contains a number of AliasRow
* elements, and renders these inside a modal, which appears when the show
* property of the component is set.
*
* @param {Object} props - The properties passed to the component.
* @param {Array} props.aliases - The list of aliases to be rendered in the
* editor.
* @param {Array} props.languageOptions - The list of possible languages for an
* alias.
* @param {Function} props.onClose - A function to be called when the button to
* close the editor is clicked.
* @param {boolean} props.show - Whether or not the editor modal should be
* visible.
* @returns {ReactElement} React element containing the rendered AliasEditor.
*/
var AliasEditor = function AliasEditor(_ref) {
var languageOptions = _ref.languageOptions,
onClose = _ref.onClose,
show = _ref.show;
var helpText = "Variant names for an entity such as alternate spelling, different script, stylistic representation, acronyms, etc.\n\t\tRefer to the help page for more details and examples.";
var helpIconElement = /*#__PURE__*/_react.default.createElement(_reactBootstrap.OverlayTrigger, {
delay: 50,
overlay: /*#__PURE__*/_react.default.createElement(_reactBootstrap.Tooltip, {
id: "alias-editor-tooltip"
}, helpText),
placement: "right"
}, /*#__PURE__*/_react.default.createElement(_reactFontawesome.FontAwesomeIcon, {
className: "fa-sm",
icon: _freeSolidSvgIcons.faQuestionCircle
}));
return /*#__PURE__*/_react.default.createElement(_reactBootstrap.Modal, {
show: show,
size: "lg",
onHide: onClose
}, /*#__PURE__*/_react.default.createElement(_reactBootstrap.Modal.Header, null, /*#__PURE__*/_react.default.createElement(_reactBootstrap.Modal.Title, null, "Alias Editor ", helpIconElement)), /*#__PURE__*/_react.default.createElement(_reactBootstrap.Modal.Body, null, /*#__PURE__*/_react.default.createElement(_aliasModalBody.default, {
languageOptions: languageOptions
})), /*#__PURE__*/_react.default.createElement(_reactBootstrap.Modal.Footer, null, /*#__PURE__*/_react.default.createElement(_reactBootstrap.Button, {
variant: "primary",
onClick: onClose
}, "Close")));
};
AliasEditor.displayName = 'AliasEditor';
AliasEditor.propTypes = {
languageOptions: _propTypes.default.array.isRequired,
onClose: _propTypes.default.func.isRequired,
show: _propTypes.default.bool
};
AliasEditor.defaultProps = {
show: false
};
function mapDispatchToProps(dispatch) {
return {
onClose: function onClose() {
dispatch((0, _actions.hideAliasEditor)());
dispatch((0, _actions.removeEmptyAliases)());
}
};
}
var _default = (0, _reactRedux.connect)(null, mapDispatchToProps)(AliasEditor);
exports.default = _default;
//# sourceMappingURL=alias-editor.js.map