import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { mapToCssModules, tagPropType } from './utils'; import Fade from './Fade'; var propTypes = { children: PropTypes.node, className: PropTypes.string, closeClassName: PropTypes.string, closeAriaLabel: PropTypes.string, cssModule: PropTypes.object, color: PropTypes.string, fade: PropTypes.bool, isOpen: PropTypes.bool, toggle: PropTypes.func, tag: tagPropType, transition: PropTypes.shape(Fade.propTypes), innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.func]) }; var defaultProps = { color: 'success', isOpen: true, tag: 'div', closeAriaLabel: 'Close', fade: true, transition: _objectSpread(_objectSpread({}, Fade.defaultProps), {}, { unmountOnExit: true }) }; function Alert(props) { var className = props.className, closeClassName = props.closeClassName, closeAriaLabel = props.closeAriaLabel, cssModule = props.cssModule, Tag = props.tag, color = props.color, isOpen = props.isOpen, toggle = props.toggle, children = props.children, transition = props.transition, fade = props.fade, innerRef = props.innerRef, attributes = _objectWithoutPropertiesLoose(props, ["className", "closeClassName", "closeAriaLabel", "cssModule", "tag", "color", "isOpen", "toggle", "children", "transition", "fade", "innerRef"]); var classes = mapToCssModules(classNames(className, 'alert', "alert-" + color, { 'alert-dismissible': toggle }), cssModule); var closeClasses = mapToCssModules(classNames('close', closeClassName), cssModule); var alertTransition = _objectSpread(_objectSpread(_objectSpread({}, Fade.defaultProps), transition), {}, { baseClass: fade ? transition.baseClass : '', timeout: fade ? transition.timeout : 0 }); return /*#__PURE__*/React.createElement(Fade, _extends({}, attributes, alertTransition, { tag: Tag, className: classes, in: isOpen, role: "alert", innerRef: innerRef }), toggle ? /*#__PURE__*/React.createElement("button", { type: "button", className: closeClasses, "aria-label": closeAriaLabel, onClick: toggle }, /*#__PURE__*/React.createElement("span", { "aria-hidden": "true" }, "\xD7")) : null, children); } Alert.propTypes = propTypes; Alert.defaultProps = defaultProps; export default Alert;