UNPKG

@eccenca/gui-elements

Version:

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

56 lines 3.82 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 { Classes as BlueprintClassNames, Toast2 as BlueprintToast, } from "@blueprintjs/core"; import { ClassNames as IntentClassNames } from "../../common/Intent/index.js"; import { CLASSPREFIX as eccgui } from "../../configuration/constants.js"; import Icon from "./../Icon/Icon.js"; /** * Displays a notification message, optionally combined with depiction and further action buttons. * By default it uses colorization of an blueish info alert. */ export var Notification = function (_a) { var _b; var actions = _a.actions, children = _a.children, className = _a.className, message = _a.message, _c = _a.flexWidth, flexWidth = _c === void 0 ? false : _c, icon = _a.icon, timeout = _a.timeout, wrapperProps = _a.wrapperProps, dataTestId = _a["data-test-id"], dataTestid = _a["data-testid"], _d = _a.intent, intent = _d === void 0 ? "info" : _d, otherProps = __rest(_a, ["actions", "children", "className", "message", "flexWidth", "icon", "timeout", "wrapperProps", "data-test-id", "data-testid", "intent"]); var intentClass = intent ? " " + IntentClassNames[intent.toUpperCase()] : ""; var intentIconSymbol = intent !== "neutral" ? "state-".concat(intent) : false; var notificationIcon = icon !== false ? icon : undefined; if (icon !== false && !notificationIcon && !!intentIconSymbol) { notificationIcon = React.createElement(Icon, { name: intentIconSymbol }); } var content = actions ? (React.createElement("div", { className: "".concat(eccgui, "-notification__content") }, React.createElement("div", { className: "".concat(eccgui, "-notification__messagebody") }, message ? message : children), React.createElement("div", { className: "".concat(eccgui, "-notification__actions") }, actions))) : message ? (message) : (children); var notification = (React.createElement(BlueprintToast, __assign({ className: "".concat(eccgui, "-notification ") + intentClass + (className ? " ".concat(className) : "") + (flexWidth ? " ".concat(eccgui, "-notification--flexwidth") : "") + (otherProps.onDismiss ? "" : " ".concat(eccgui, "-notification--static")), message: content, timeout: timeout ? timeout : 0, icon: notificationIcon ? React.cloneElement(notificationIcon, { className: ((_b = notificationIcon.props.className) !== null && _b !== void 0 ? _b : "") + " ".concat(BlueprintClassNames.ICON), }) : undefined }, otherProps))); return wrapperProps || dataTestId || dataTestid ? (React.createElement("div", __assign({ className: "".concat(eccgui, "-notification__wrapper") }, (wrapperProps !== null && wrapperProps !== void 0 ? wrapperProps : {}), { "data-test-id": dataTestId, "data-testid": dataTestid }), notification)) : (React.createElement(React.Fragment, null, notification)); }; export default Notification; //# sourceMappingURL=Notification.js.map