@carbon/ibm-security
Version:
Carbon for Cloud & Cognitive IBM Security UI components
70 lines (69 loc) • 2.79 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["onCloseButtonClick", "iconDescription", "className", "caption", "subtitle", "title", "hideCloseButton", "statusIconDescription"];
/**
* @file Stacked notification.
* @copyright IBM Security 2019, 2021
*/
import { bool, func, node, string } from 'prop-types';
import React from 'react';
import classnames from 'classnames';
import { ToastNotification } from '../Notification';
import { getComponentNamespace } from '../../globals/namespace';
var namespace = getComponentNamespace('stacked-notification');
var StackedNotification = function StackedNotification(_ref) {
var onCloseButtonClick = _ref.onCloseButtonClick,
iconDescription = _ref.iconDescription,
className = _ref.className,
caption = _ref.caption,
subtitle = _ref.subtitle,
title = _ref.title,
hideCloseButton = _ref.hideCloseButton,
statusIconDescription = _ref.statusIconDescription,
other = _objectWithoutProperties(_ref, _excluded);
var classes = classnames(namespace, className);
return /*#__PURE__*/React.createElement(ToastNotification, _extends({
className: classes,
kind: "info",
notificationType: "toast",
title: title,
subtitle: subtitle,
caption: caption,
iconDescription: iconDescription,
onClick: onCloseButtonClick,
hideCloseButton: hideCloseButton,
statusIconDescription: statusIconDescription
}, other));
};
StackedNotification.propTypes = {
/* Specify the caption. */
caption: node,
/* Pass in the children that will be rendered within the notification. */
children: node,
/* Specify an optional className to be applied to the notification wrapper. */
className: string,
/* Specify whether the close button should be disabled. */
hideCloseButton: bool,
/* Provide a description for "close" icon that can be read by screen readers. */
iconDescription: string.isRequired,
/* Provide a function that is called when menu is closed. */
onCloseButtonClick: func,
/* By default, this value is "alert". You can provide an alternate role if it makes sense for accessibility. */
role: string,
/* Provide a description for "status" icon that can be read by screen readers. */
statusIconDescription: string,
/* Specify the sub-title. */
subtitle: node.isRequired,
/* Specify the title. */
title: string.isRequired
};
StackedNotification.defaultProps = {
caption: 'provide a caption',
children: undefined,
className: null,
role: 'alert',
onCloseButtonClick: function onCloseButtonClick() {},
hideCloseButton: false,
statusIconDescription: 'provide a description for the status icon'
};
export default StackedNotification;