mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-23 00:45:16 +00:00
62 lines
2.7 KiB
JavaScript
62 lines
2.7 KiB
JavaScript
|
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,
|
||
|
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: _objectSpread(_objectSpread({}, 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 = _objectSpread(_objectSpread(_objectSpread({}, Fade.defaultProps), transition), {}, {
|
||
|
baseClass: fade ? transition.baseClass : '',
|
||
|
timeout: fade ? transition.timeout : 0
|
||
|
});
|
||
|
|
||
|
return /*#__PURE__*/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;
|