1 | "use strict";
|
2 |
|
3 | require("core-js/modules/es.symbol.js");
|
4 |
|
5 | require("core-js/modules/es.symbol.description.js");
|
6 |
|
7 | require("core-js/modules/es.symbol.iterator.js");
|
8 |
|
9 | require("core-js/modules/es.array.iterator.js");
|
10 |
|
11 | require("core-js/modules/es.string.iterator.js");
|
12 |
|
13 | require("core-js/modules/web.dom-collections.iterator.js");
|
14 |
|
15 | require("core-js/modules/es.array.from.js");
|
16 |
|
17 | require("core-js/modules/es.array.slice.js");
|
18 |
|
19 | require("core-js/modules/es.function.name.js");
|
20 |
|
21 | require("core-js/modules/es.regexp.exec.js");
|
22 |
|
23 | Object.defineProperty(exports, "__esModule", {
|
24 | value: true
|
25 | });
|
26 | exports.init = void 0;
|
27 |
|
28 | require("core-js/modules/es.array.concat.js");
|
29 |
|
30 | require("core-js/modules/es.array.filter.js");
|
31 |
|
32 | require("core-js/modules/es.object.to-string.js");
|
33 |
|
34 | require("core-js/modules/es.array.find.js");
|
35 |
|
36 | function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
37 |
|
38 | 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."); }
|
39 |
|
40 | 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); }
|
41 |
|
42 | function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
43 |
|
44 | function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
45 |
|
46 | 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; }
|
47 |
|
48 | var init = function init(_ref) {
|
49 | var store = _ref.store;
|
50 | var api = {
|
51 | addNotification: function addNotification(notification) {
|
52 |
|
53 | api.clearNotification(notification.id);
|
54 |
|
55 | var _store$getState = store.getState(),
|
56 | notifications = _store$getState.notifications;
|
57 |
|
58 | store.setState({
|
59 | notifications: [].concat(_toConsumableArray(notifications), [notification])
|
60 | });
|
61 | },
|
62 | clearNotification: function clearNotification(id) {
|
63 | var _store$getState2 = store.getState(),
|
64 | notifications = _store$getState2.notifications;
|
65 |
|
66 | store.setState({
|
67 | notifications: notifications.filter(function (n) {
|
68 | return n.id !== id;
|
69 | })
|
70 | });
|
71 | var notification = notifications.find(function (n) {
|
72 | return n.id === id;
|
73 | });
|
74 |
|
75 | if (notification && notification.onClear) {
|
76 | notification.onClear();
|
77 | }
|
78 | }
|
79 | };
|
80 | var state = {
|
81 | notifications: []
|
82 | };
|
83 | return {
|
84 | api: api,
|
85 | state: state
|
86 | };
|
87 | };
|
88 |
|
89 | exports.init = init; |
\ | No newline at end of file |