UNPKG

@eccenca/gui-elements

Version:

GUI elements based on other libraries, usable in React application, written in Typescript.

39 lines 2.14 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import React from "react"; import { MenuItem as BlueprintMenuItem } from "@blueprintjs/core"; import { openInNewTab } from "../../common/utils/openInNewTab.js"; import { CLASSPREFIX as eccgui } from "../../configuration/constants.js"; import Icon from "../Icon/Icon.js"; import Tooltip from "../Tooltip/Tooltip.js"; /** * Single item, used as child inside `Menu`. */ export var MenuItem = function (_a) { var children = _a.children, _b = _a.className, className = _b === void 0 ? "" : _b, icon = _a.icon, onClick = _a.onClick, href = _a.href, text = _a.text, tooltip = _a.tooltip, restProps = __rest(_a, ["children", "className", "icon", "onClick", "href", "text", "tooltip"]); return (React.createElement(BlueprintMenuItem, __assign({}, restProps, { text: tooltip ? (React.createElement(Tooltip, { content: tooltip, fill: true }, text)) : (text), href: href, onClick: function (e) { return openInNewTab(e, onClick, href); }, className: "".concat(eccgui, "-menu__item ") + className, icon: icon ? typeof icon === "string" || Array.isArray(icon) ? React.createElement(Icon, { name: icon }) : icon : false }), children !== null && children !== void 0 ? children : null)); }; export default MenuItem; //# sourceMappingURL=MenuItem.js.map