@attivio/suit
Version:
Attivio SUIT, the Search UI Toolkit, is a library for creating search clients for searching the Attivio platform.
157 lines (134 loc) • 4.89 kB
JavaScript
;
exports.__esModule = true;
exports.default = exports.ContextHelpInfo = undefined;
var _class2, _temp;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Describes the help to display in a particular context.
*/
var ContextHelpInfo =
/** The label to use for showing more information. If not set, no link to more information will be shown. */
/** The title to show for the help. */
exports.ContextHelpInfo = function ContextHelpInfo(id, title, paragraphs) {
var moreName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
var moreLink = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
_classCallCheck(this, ContextHelpInfo);
// eslint-disable-line max-len
this.id = id;
this.title = title;
this.paragraphs = paragraphs;
this.moreName = moreName;
this.moreLink = moreLink;
}
/** A URL for more information. */
/** The contents of the help, separated into paragraphs. */
/** An ID for the help topic. */
;
/**
* Component to display contextual help.
*/
var ContextHelp = (_temp = _class2 = function (_React$Component) {
_inherits(ContextHelp, _React$Component);
function ContextHelp() {
_classCallCheck(this, ContextHelp);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
ContextHelp.prototype.render = function render() {
var info = this.props.info;
if (info) {
var paragraphs = info.paragraphs ? info.paragraphs.map(function (paragraph, index) {
return _react2.default.createElement(
'p',
{ key: index + ':' + paragraph },
paragraph
); // eslint-disable-line react/no-array-index-key
}) : null;
var more = null;
if (info.moreLink) {
if (info.moreName) {
more = _react2.default.createElement(
'p',
null,
'To learn more about ',
info.moreName,
', visit',
'\xA0',
_react2.default.createElement(
'a',
{
ref: info.moreLink,
target: '_blank',
rel: 'noopener noreferrer'
},
'Attivio Answers'
),
'.'
);
} else {
more = _react2.default.createElement(
'p',
null,
'To learn more, visit',
'\xA0',
_react2.default.createElement(
'a',
{ href: info.moreLink, target: '_blank', rel: 'noopener noreferrer' },
'Attivio Answers'
),
'.'
);
}
}
return _react2.default.createElement(
'div',
null,
_react2.default.createElement(
'h4',
null,
_react2.default.createElement('span', {
className: 'attivio-icon-help',
style: {
display: 'inline-block',
width: '1em',
transform: 'scale(1.5, 1.5)'
}
}),
info.title
),
paragraphs,
more
);
}
// No help available
return _react2.default.createElement(
'div',
null,
_react2.default.createElement(
'h4',
null,
_react2.default.createElement('span', {
className: 'attivio-icon-help',
style: {
display: 'inline-block',
width: '1em',
transform: 'scale(1.5, 1.5)'
}
}),
'Help'
),
_react2.default.createElement(
'p',
null,
'No context help is currently available.'
)
);
};
return ContextHelp;
}(_react2.default.Component), _class2.displayName = 'ContextHelp', _temp);
exports.default = ContextHelp;
ContextHelp.ContextHelpInfo = ContextHelpInfo;