function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import React, { useState, useRef, useEffect } from 'react';
import { action } from '@storybook/addon-actions';
import ToastMessage from './ToastMessage';
import { Display } from '../../common/Display';
import { Icon, Button, PageWrapper, Flexbox, Box, Badge } from '../..';
export default {
  title: 'Molecules / ToastMessage ',
  parameters: {
    component: ToastMessage
  }
};
export var DifferentVariantToastMessages = {
  render: function render() {
    return React.createElement(React.Fragment, null, React.createElement(Display, {
      items: [{
        title: 'primary',
        component: React.createElement(ToastMessage, {
          label: "Link copied to clipboard",
          icon: React.createElement(Icon.CheckCircleFill24, {
            color: function color(t) {
              return t.colorTokens.positive.icon_default;
            }
          }),
          isVisible: true,
          linkButton: React.createElement(Button, {
            onClick: action('clicked'),
            variant: "neutral",
            color: function color(t) {
              return t.colorTokens.action.text_focus;
            }
          }, "View")
        })
      }]
    }));
  },
  name: 'Different variants'
};
export var HoverUsage = {
  render: function render() {
    var Example = function Example() {
      var _useState = useState(false),
        _useState2 = _slicedToArray(_useState, 2),
        visible = _useState2[0],
        setVisible = _useState2[1];
      return React.createElement(PageWrapper, {
        background: function background(t) {
          return t.colorTokens.neutral.background_brand_white;
        }
      }, React.createElement(Flexbox, null, React.createElement(Box, {
        onMouseEnter: function onMouseEnter() {
          return setVisible(!visible);
        },
        p: 4
      }, React.createElement(Badge.Status, {
        variant: "create",
        badgeSize: "xl",
        label: "Hover me"
      }))), React.createElement(Flexbox, {
        container: true,
        gap: 10
      }, React.createElement(ToastMessage, {
        label: "Link copied to clipboard",
        icon: React.createElement(Icon.CheckCircleFill24, {
          color: function color(t) {
            return t.colorTokens.positive.icon_default;
          }
        }),
        isVisible: visible,
        linkButton: React.createElement(Button, {
          onClick: action('clicked'),
          variant: "neutral",
          color: function color(t) {
            return t.colorTokens.action.text_focus;
          }
        }, "View")
      })));
    };
    return React.createElement(Example, null);
  },
  name: 'With Hover'
};
export var WithLabelUsage = {
  render: function render() {
    var Example = function Example() {
      var _useState3 = useState(false),
        _useState4 = _slicedToArray(_useState3, 2),
        visible = _useState4[0],
        setVisible = _useState4[1];
      return React.createElement(PageWrapper, {
        background: function background(t) {
          return t.colorTokens.neutral.background_brand_white;
        }
      }, React.createElement(Flexbox, null, React.createElement(Button, {
        variant: "primary",
        onMouseEnter: function onMouseEnter() {
          return setVisible(!visible);
        }
      }, "Hover me")), React.createElement(Flexbox, {
        container: true,
        gap: 10
      }, React.createElement(ToastMessage, {
        label: "Saved to watchlist",
        isVisible: visible
      })));
    };
    return React.createElement(Example, null);
  },
  name: 'With label'
};
export var WithLabelUsageLink = {
  render: function render() {
    var Example = function Example() {
      var _useState5 = useState(false),
        _useState6 = _slicedToArray(_useState5, 2),
        visible = _useState6[0],
        setVisible = _useState6[1];
      return React.createElement(PageWrapper, {
        background: function background(t) {
          return t.colorTokens.neutral.background_brand_white;
        }
      }, React.createElement(Flexbox, null, React.createElement(Button, {
        variant: "primary",
        onMouseEnter: function onMouseEnter() {
          return setVisible(true);
        }
      }, "Hover me")), React.createElement(Flexbox, {
        container: true,
        gap: 10
      }, React.createElement(ToastMessage, {
        label: "Saved to watchlist",
        isVisible: visible,
        linkButton: React.createElement(Button, {
          onClick: action('clicked'),
          variant: "neutral",
          color: function color(t) {
            return t.colorTokens.action.text_focus;
          }
        }, "View")
      })));
    };
    return React.createElement(Example, null);
  },
  name: 'With label and link View'
};
export var OnClickToastMessages = {
  render: function render() {
    var Example = function Example() {
      var childRef = useRef();
      var handleClick = function handleClick() {
        childRef.current.setVisible();
      };
      return React.createElement(PageWrapper, {
        background: function background(t) {
          return t.colorTokens.neutral.background_brand_white;
        }
      }, React.createElement(Flexbox, null, React.createElement(Button, {
        variant: "primary",
        onClick: function onClick() {
          return handleClick();
        }
      }, "use setVisible ref method")), React.createElement(ToastMessage, {
        ref: childRef,
        label: "Link copied to clipboard",
        icon: React.createElement(Icon.CheckCircleFill24, {
          color: function color(t) {
            return t.colorTokens.positive.icon_default;
          }
        }),
        linkButton: React.createElement(Button, {
          onClick: action('clicked'),
          variant: "neutral",
          color: function color(t) {
            return t.colorTokens.action.text_focus;
          }
        }, "View")
      }));
    };
    return React.createElement(Example, null);
  },
  name: 'OnClick set ToastMessage'
};
export var ControlledTimeOut = {
  render: function render() {
    var Example = function Example() {
      var _useState7 = useState(false),
        _useState8 = _slicedToArray(_useState7, 2),
        visible = _useState8[0],
        setVisible = _useState8[1];
      return React.createElement(PageWrapper, {
        background: function background(t) {
          return t.colorTokens.neutral.background_brand_white;
        }
      }, React.createElement(Flexbox, null, React.createElement(Button, {
        variant: "primary",
        onClick: function onClick() {
          return setVisible(!visible);
        }
      }, "Click me")), React.createElement(ToastMessage, {
        label: "Link copied to clipboard",
        icon: React.createElement(Icon.CheckCircleFill24, {
          color: function color(t) {
            return t.colorTokens.positive.icon_default;
          }
        }),
        isVisible: visible,
        timeout: 10000,
        linkButton: React.createElement(Button, {
          onClick: action('clicked'),
          variant: "neutral",
          color: function color(t) {
            return t.colorTokens.action.text_focus;
          }
        }, "View")
      }));
    };
    return React.createElement(Example, null);
  },
  name: 'Controlled timeout ToastMessage'
};
export var OnClickToastMessages2 = {
  render: function render() {
    var Example = function Example() {
      var childRef = useRef();
      var _useState9 = useState(0),
        _useState10 = _slicedToArray(_useState9, 2),
        value = _useState10[0],
        setValue = _useState10[1];
      useEffect(function () {
        if (value >= 3) {
          childRef.current.setVisible();
        }
      }, [value]);
      return React.createElement(PageWrapper, {
        background: function background(t) {
          return t.colorTokens.neutral.background_brand_white;
        }
      }, React.createElement(Flexbox, {
        container: true,
        direction: "column",
        gap: 3
      }, "Conditional call", React.createElement(Flexbox, {
        container: true,
        gap: 3
      }, Array.from({
        length: 5
      }).map(function (_, index) {
        return React.createElement(Button, {
          variant: "primary",
          onClick: function onClick() {
            return setValue(index + 1);
          }
        }, index + 1);
      })), "setVisible if value is 3 or more"), React.createElement(ToastMessage, {
        ref: childRef,
        label: "You have reached the maximum number of attempts",
        icon: React.createElement(Icon.Warning24, {
          color: function color(t) {
            return t.colorTokens.error.background_default;
          }
        }),
        linkButton: React.createElement(Button, {
          onClick: action('clicked'),
          variant: "neutral",
          color: function color(t) {
            return t.colorTokens.action.text_focus;
          }
        }, "View")
      }));
    };
    return React.createElement(Example, null);
  },
  name: 'Conditional call to setVisible'
};