@eccenca/gui-elements
Version:
GUI elements based on other libraries, usable in React application, written in Typescript.
52 lines • 3.65 kB
JavaScript
;
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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Notification = void 0;
const react_1 = __importDefault(require("react"));
const core_1 = require("@blueprintjs/core");
const Intent_1 = require("../../common/Intent");
const constants_1 = require("../../configuration/constants");
const Icon_1 = __importDefault(require("./../Icon/Icon"));
/**
* Displays a notification message, optionally combined with depiction and further action buttons.
* By default it uses colorization of an blueish info alert.
*/
const Notification = (_a) => {
var _b;
var { actions, children, className, message, flexWidth = false, icon, timeout, wrapperProps, "data-test-id": dataTestId, "data-testid": dataTestid, intent = "info" } = _a, otherProps = __rest(_a, ["actions", "children", "className", "message", "flexWidth", "icon", "timeout", "wrapperProps", "data-test-id", "data-testid", "intent"]);
const intentClass = intent ? " " + Intent_1.ClassNames[intent.toUpperCase()] : "";
const intentIconSymbol = intent !== "neutral" ? `state-${intent}` : false;
let notificationIcon = icon !== false ? icon : undefined;
if (icon !== false && !notificationIcon && !!intentIconSymbol) {
notificationIcon = react_1.default.createElement(Icon_1.default, { name: intentIconSymbol });
}
const content = actions ? (react_1.default.createElement("div", { className: `${constants_1.CLASSPREFIX}-notification__content` },
react_1.default.createElement("div", { className: `${constants_1.CLASSPREFIX}-notification__messagebody` }, message ? message : children),
react_1.default.createElement("div", { className: `${constants_1.CLASSPREFIX}-notification__actions` }, actions))) : message ? (message) : (children);
const notification = (react_1.default.createElement(core_1.Toast2, Object.assign({ className: `${constants_1.CLASSPREFIX}-notification ` +
intentClass +
(className ? ` ${className}` : "") +
(flexWidth ? ` ${constants_1.CLASSPREFIX}-notification--flexwidth` : "") +
(otherProps.onDismiss ? "" : ` ${constants_1.CLASSPREFIX}-notification--static`), message: content, timeout: timeout ? timeout : 0, icon: notificationIcon
? react_1.default.cloneElement(notificationIcon, {
className: ((_b = notificationIcon.props.className) !== null && _b !== void 0 ? _b : "") + ` ${core_1.Classes.ICON}`,
})
: undefined }, otherProps)));
return wrapperProps || dataTestId || dataTestid ? (react_1.default.createElement("div", Object.assign({ className: `${constants_1.CLASSPREFIX}-notification__wrapper` }, (wrapperProps !== null && wrapperProps !== void 0 ? wrapperProps : {}), { "data-test-id": dataTestId, "data-testid": dataTestid }), notification)) : (react_1.default.createElement(react_1.default.Fragment, null, notification));
};
exports.Notification = Notification;
exports.default = exports.Notification;
//# sourceMappingURL=Notification.js.map