import React from 'react';
import PropTypes from 'prop-types';
import { b as classNames, a as withNano } from '../chunk-566df01b.js';
import InfoIcon from '../Icons/Info/index.js';
import ExitIcon from '../Icons/Exit/index.js';
import Text from '../Text/index.js';
import '../chunk-aeb80e51.js';
import '../chunk-aad905a2.js';
import '../Icons/Icon/index.js';

var styles = (function (theme) {
  return {
    root: {
      display: 'flex',
      padding: '8px 16px',
      position: 'sticky',
      borderTop: 'solid 1px #d3d3db',
      justifyContent: 'space-between',
      bottom: 0,
      borderRadius: 4,
      boxShadow: '0 2px 8px 0 rgba(36, 47, 51, 0.1)',
      border: 'solid 1px ' + theme.palette.grey80,
      backgroundColor: theme.palette.white
    },
    type: {
      borderLeft: function borderLeft(_ref) {
        var type = _ref.type;

        if (type === 'info') return 'solid 4px ' + theme.palette.blue;
        if (type === 'correct') return 'solid 4px ' + theme.palette.green;
        if (type === 'warning') return 'solid 4px ' + theme.palette.lightRed;
      }
    },
    infoIcon: {
      marginRight: 10
    },
    content: {
      display: 'flex',
      justifyContent: 'flex-start'
    },
    exit: {
      outline: 'none'
    }
  };
});

var colors = {
  warning: 'lightRed',
  info: 'blue',
  correct: 'green'
};

var Toast = function Toast(_ref) {
  var label = _ref.label,
      type = _ref.type,
      classes = _ref.classes,
      onClose = _ref.onClose;
  return React.createElement(
    'div',
    { className: classNames(classes.root, type && classes.type) },
    React.createElement(
      'div',
      { className: classes.content },
      React.createElement(
        'div',
        null,
        React.createElement(InfoIcon, { color: colors[type], className: classes.infoIcon, display: 'block' })
      ),
      React.createElement(
        Text,
        { size: 'md' },
        label
      )
    ),
    React.createElement(
      'div',
      {
        className: classes.exit,
        role: 'button',
        tabIndex: 0,
        onClick: onClose || null,
        onKeyDown: function onKeyDown(e) {
          if (e.keyCode === 'ESC' && onClose) onClose();
        }
      },
      React.createElement(ExitIcon, { className: classes.exitIcon, color: 'grey90', hoverColor: 'black' })
    )
  );
};

Toast.defaultProps = {
  type: 'warning'
};

Toast.propTypes = {
  label: PropTypes.string,
  type: PropTypes.oneOf(['info', 'correct', 'warning']),
  classes: PropTypes.object,
  onClose: PropTypes.func
};

var Toast$1 = withNano(styles)(Toast);

export default Toast$1;
//# sourceMappingURL=index.js.map
