@momentum-ui/react-collaboration
Version:
Cisco Momentum UI Framework for React Collaboration Applications
60 lines • 3.35 kB
JavaScript
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, { Children, cloneElement, isValidElement } from 'react';
import classnames from 'classnames';
import { DEFAULTS, STYLE } from './AlertBanner.constants';
import './AlertBanner.style.scss';
/**
* @deprecated Use the equivalent from momentum.design (NPM: `@momentum-design/components/dist/react`)
*/
var AlertBanner = function (props) {
var buttons = props.buttons, isCentered = props.isCentered, children = props.children, className = props.className, color = props.color, isGrown = props.isGrown, id = props.id, image = props.image, label = props.label, isPilled = props.isPilled, isStatic = props.isStatic, size = props.size, style = props.style, otherProps = __rest(props, ["buttons", "isCentered", "children", "className", "color", "isGrown", "id", "image", "label", "isPilled", "isStatic", "size", "style"]);
var mutatedButtons = Children.map(buttons, function (button) {
return cloneElement(button, {
className: classnames(STYLE.button, button.props.className),
});
});
var buttonsComponent = React.createElement("div", { className: STYLE.buttons }, mutatedButtons);
var imageComponent = image ? (React.createElement("div", { className: STYLE.image }, cloneElement(image, {
className: classnames(image.props.className),
}))) : (React.createElement("div", { className: STYLE.image }));
var labelComponent;
if (label) {
labelComponent = React.createElement("p", { className: STYLE.label }, label);
}
else if (typeof children === 'string' || typeof children === 'number') {
labelComponent = React.createElement("p", { className: STYLE.label }, children);
}
else if (isValidElement(children)) {
labelComponent = React.createElement("div", { className: STYLE.label }, children);
}
else {
labelComponent = React.createElement("p", { className: STYLE.label });
}
return (React.createElement("div", __assign({ "data-centered": isCentered || DEFAULTS.IS_CENTERED, className: classnames(STYLE.wrapper, className), "data-color": isStatic ? undefined : color || DEFAULTS.COLOR, "data-grow": isGrown || DEFAULTS.IS_GROWN, "data-pill": isPilled || DEFAULTS.IS_PILLED, "data-size": size || DEFAULTS.SIZE, "data-static": isStatic || DEFAULTS.IS_STATIC, id: id, style: style }, otherProps),
imageComponent,
labelComponent,
buttonsComponent));
};
export default AlertBanner;
//# sourceMappingURL=AlertBanner.js.map