function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import React from 'react';
import { useToasts } from 'react-toast-notifications';
import { ToastProvider, Toast } from '.';
import { Button } from '../Button';
export default {
  component: Toast,
  subcomponents: {
    ToastProvider: ToastProvider
  },
  title: 'Toast',
  parameters: {
    actions: {
      argTypesRegex: '^on.*'
    },
    docs: {
      description: {
        component: 'This component wraps a popular open-source library. See comprehensive documentation [here](https://github.com/jossmac/react-toast-notifications#readme).'
      }
    }
  }
};
var LABEL = 'Example label';
var DESCRIPTION = 'This is an example toast message';
var DATE_TIME = new Date('Tue, 18 Feb 2020 14:36:43 GMT');
var ToastButton = function ToastButton(_ref) {
  var _ref$appearance = _ref.appearance,
    appearance = _ref$appearance === void 0 ? 'info' : _ref$appearance,
    _ref$autoDismiss = _ref.autoDismiss,
    autoDismiss = _ref$autoDismiss === void 0 ? false : _ref$autoDismiss,
    onDismiss = _ref.onDismiss;
  var _useToasts = useToasts(),
    addToast = _useToasts.addToast;
  return /*#__PURE__*/React.createElement(Button, {
    onClick: function onClick(_) {
      addToast(DESCRIPTION, {
        label: LABEL,
        appearance: appearance,
        autoDismiss: autoDismiss,
        onDismiss: onDismiss
      });
    }
  }, "Add Toast");
};
export var Default = function Default(props) {
  return /*#__PURE__*/React.createElement(ToastProvider, null, /*#__PURE__*/React.createElement(ToastButton, props));
};
Default.args = {};
export var AutoDismiss = function AutoDismiss(props) {
  return /*#__PURE__*/React.createElement(ToastProvider, null, /*#__PURE__*/React.createElement(ToastButton, _extends({}, props, {
    appearance: "info",
    autoDismiss: true
  })));
};
AutoDismiss.storyName = 'Auto dismiss';
export var ComponentOnly = function ComponentOnly(props) {
  return /*#__PURE__*/React.createElement(Toast, _extends({}, props, {
    appearance: "info",
    autoDismiss: false,
    autoDismissTimeout: 300,
    isRunning: false,
    placement: "top-right",
    transitionDuration: 300,
    transitionState: "entered",
    label: LABEL,
    dateTime: DATE_TIME
  }), DESCRIPTION);
};
ComponentOnly.storyName = 'Component only';
export var Danger = function Danger(props) {
  return /*#__PURE__*/React.createElement(Toast, _extends({}, props, {
    appearance: "error",
    autoDismiss: false,
    autoDismissTimeout: 300,
    isRunning: false,
    placement: "top-right",
    transitionDuration: 300,
    transitionState: "entered",
    label: LABEL,
    dateTime: DATE_TIME
  }), DESCRIPTION);
};
Danger.storyName = 'Danger';
export var Success = function Success(props) {
  return /*#__PURE__*/React.createElement(Toast, _extends({}, props, {
    appearance: "success",
    autoDismiss: false,
    autoDismissTimeout: 300,
    isRunning: false,
    placement: "top-right",
    transitionDuration: 300,
    transitionState: "entered",
    label: LABEL,
    dateTime: DATE_TIME
  }), DESCRIPTION);
};
Success.storyName = 'Success';
export var Warning = function Warning(props) {
  return /*#__PURE__*/React.createElement(Toast, _extends({}, props, {
    appearance: "warning",
    autoDismiss: false,
    autoDismissTimeout: 300,
    isRunning: false,
    placement: "top-right",
    transitionDuration: 300,
    transitionState: "entered",
    label: LABEL,
    dateTime: DATE_TIME
  }), DESCRIPTION);
};
Warning.storyName = 'Warning';