57 lines
1.8 KiB
JavaScript
57 lines
1.8 KiB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
import _objectSpread2 from "@babel/runtime/helpers/esm/objectSpread";
|
|
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,
|
|
cssModule: PropTypes.object,
|
|
fade: PropTypes.bool,
|
|
isOpen: PropTypes.bool,
|
|
tag: tagPropType,
|
|
transition: PropTypes.shape(Fade.propTypes),
|
|
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.func])
|
|
};
|
|
var defaultProps = {
|
|
isOpen: true,
|
|
tag: 'div',
|
|
fade: true,
|
|
transition: _objectSpread2({}, Fade.defaultProps, {
|
|
unmountOnExit: true
|
|
})
|
|
};
|
|
|
|
function Toast(props) {
|
|
var className = props.className,
|
|
cssModule = props.cssModule,
|
|
Tag = props.tag,
|
|
isOpen = props.isOpen,
|
|
children = props.children,
|
|
transition = props.transition,
|
|
fade = props.fade,
|
|
innerRef = props.innerRef,
|
|
attributes = _objectWithoutPropertiesLoose(props, ["className", "cssModule", "tag", "isOpen", "children", "transition", "fade", "innerRef"]);
|
|
|
|
var classes = mapToCssModules(classNames(className, 'toast'), cssModule);
|
|
|
|
var toastTransition = _objectSpread2({}, Fade.defaultProps, {}, transition, {
|
|
baseClass: fade ? transition.baseClass : '',
|
|
timeout: fade ? transition.timeout : 0
|
|
});
|
|
|
|
return React.createElement(Fade, _extends({}, attributes, toastTransition, {
|
|
tag: Tag,
|
|
className: classes,
|
|
in: isOpen,
|
|
role: "alert",
|
|
innerRef: innerRef
|
|
}), children);
|
|
}
|
|
|
|
Toast.propTypes = propTypes;
|
|
Toast.defaultProps = defaultProps;
|
|
export default Toast; |