UNPKG

box-ui-elements-mlh

Version:
76 lines (67 loc) 3.55 kB
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread 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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } 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; } import * as React from 'react'; import { IntlProvider } from 'react-intl'; import { State, Store } from '@sambego/storybook-state'; import Button from '../../button/Button'; import PrimaryButton from '../../primary-button/PrimaryButton'; import Notification from '../Notification'; import NotificationsWrapper from '../NotificationsWrapper'; import notes from './NotificationsWrapper.stories.md'; export var example = function example() { var DATE = new Date('May 13, 2002 23:15:30').toTimeString(); var componentStore = new Store({ id: 0, notifications: new Map() }); var closeNotification = function closeNotification(id) { var notifications = componentStore.get('notifications'); notifications.delete(id); componentStore.set({ notifications: notifications }); }; var addNotification = function addNotification(duration, type) { var id = componentStore.get('id'); var notifications = componentStore.get('notifications'); var notification = /*#__PURE__*/React.createElement(Notification, { key: id, duration: duration, onClose: function onClose() { return closeNotification(id); }, type: type }, /*#__PURE__*/React.createElement("span", null, "Hello world! I was made at ", DATE), /*#__PURE__*/React.createElement(Button, null, "Okay")); componentStore.set({ notifications: notifications.set(id, notification), id: id + 1 }); }; return /*#__PURE__*/React.createElement(State, { store: componentStore }, function (state) { return /*#__PURE__*/React.createElement(IntlProvider, { locale: "en" }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(NotificationsWrapper, null, _toConsumableArray(state.notifications.values())), /*#__PURE__*/React.createElement(Button, { onClick: function onClick() { return addNotification('short', 'info'); } }, "Display timed notification"), /*#__PURE__*/React.createElement(PrimaryButton, { onClick: function onClick() { return addNotification(undefined, 'warn'); } }, "Display persistent notification"))); }); }; export default { title: 'Components|Notifications/NotificationsWrapper', component: NotificationsWrapper, parameters: { notes: notes } }; //# sourceMappingURL=NotificationsWrapper.stories.js.map