@commercetools-frontend/notifications 22.2.1 → 22.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ var _Map__default = /*#__PURE__*/_interopDefault(_Map);
30
30
  var _setTimeout__default = /*#__PURE__*/_interopDefault(_setTimeout);
31
31
 
32
32
  // NOTE: This string will be replaced on build time with the package version.
33
- var version = "22.2.1";
33
+ var version = "22.3.0";
34
34
 
35
35
  const ADD_NOTIFICATION = 'ADD_NOTIFICATION';
36
36
  const REMOVE_NOTIFICATION = 'REMOVE_NOTIFICATION';
@@ -53,52 +53,40 @@ function removeNotification(id) {
53
53
  }
54
54
 
55
55
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
56
-
57
56
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
58
-
59
57
  // Force TS cast of generic action to TNotificationAction
60
58
  const isNotificationAction = action => {
61
59
  var _context;
62
-
63
60
  return _includesInstanceProperty__default["default"](_context = [ADD_NOTIFICATION, REMOVE_NOTIFICATION]).call(_context, action.type);
64
61
  };
65
-
66
62
  const dismissCallbacksMap = new _Map__default["default"]();
67
63
  let id = 0;
68
-
69
64
  const middleware = _ref => {
70
65
  let dispatch = _ref.dispatch;
71
66
  return next => action => {
72
67
  if (!isNotificationAction(action)) {
73
68
  return next(action);
74
69
  }
75
-
76
70
  switch (action.type) {
77
71
  case ADD_NOTIFICATION:
78
72
  {
79
73
  id += 1;
80
-
81
74
  const notification = _objectSpread(_objectSpread({}, action.payload), {}, {
82
75
  id
83
76
  });
84
-
85
77
  const dismissCallback = () => {
86
78
  dispatch(removeNotification(notification.id));
87
79
  };
88
-
89
80
  if (action.meta) {
90
81
  if (action.meta.dismissAfter) _setTimeout__default["default"](dismissCallback, action.meta.dismissAfter);
91
82
  if (typeof action.meta.onDismiss === 'function') dismissCallbacksMap.set(notification.id, action.meta.onDismiss);
92
83
  }
93
-
94
84
  const nextAction = _objectSpread(_objectSpread({}, action), {}, {
95
85
  payload: notification,
96
86
  dismiss: dismissCallback
97
87
  });
98
-
99
88
  return next(nextAction);
100
89
  }
101
-
102
90
  case REMOVE_NOTIFICATION:
103
91
  {
104
92
  const notificationId = action.payload.id;
@@ -107,7 +95,6 @@ const middleware = _ref => {
107
95
  dismissCallbacksMap.delete(notificationId);
108
96
  return next(action);
109
97
  }
110
-
111
98
  default:
112
99
  return next(action);
113
100
  }
@@ -118,16 +105,13 @@ function notificationsReducer() {
118
105
  let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
119
106
  let action = arguments.length > 1 ? arguments[1] : undefined;
120
107
  if (!action || !action.type) return state;
121
-
122
108
  switch (action.type) {
123
109
  case ADD_NOTIFICATION:
124
110
  {
125
111
  return [action.payload, ...state];
126
112
  }
127
-
128
113
  case REMOVE_NOTIFICATION:
129
114
  return _filterInstanceProperty__default["default"](state).call(state, notification => action.payload.id !== notification.id);
130
-
131
115
  default:
132
116
  return state;
133
117
  }
@@ -30,7 +30,7 @@ var _Map__default = /*#__PURE__*/_interopDefault(_Map);
30
30
  var _setTimeout__default = /*#__PURE__*/_interopDefault(_setTimeout);
31
31
 
32
32
  // NOTE: This string will be replaced on build time with the package version.
33
- var version = "22.2.1";
33
+ var version = "22.3.0";
34
34
 
35
35
  const ADD_NOTIFICATION = 'ADD_NOTIFICATION';
36
36
  const REMOVE_NOTIFICATION = 'REMOVE_NOTIFICATION';
@@ -53,52 +53,40 @@ function removeNotification(id) {
53
53
  }
54
54
 
55
55
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
56
-
57
56
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
58
-
59
57
  // Force TS cast of generic action to TNotificationAction
60
58
  const isNotificationAction = action => {
61
59
  var _context;
62
-
63
60
  return _includesInstanceProperty__default["default"](_context = [ADD_NOTIFICATION, REMOVE_NOTIFICATION]).call(_context, action.type);
64
61
  };
65
-
66
62
  const dismissCallbacksMap = new _Map__default["default"]();
67
63
  let id = 0;
68
-
69
64
  const middleware = _ref => {
70
65
  let dispatch = _ref.dispatch;
71
66
  return next => action => {
72
67
  if (!isNotificationAction(action)) {
73
68
  return next(action);
74
69
  }
75
-
76
70
  switch (action.type) {
77
71
  case ADD_NOTIFICATION:
78
72
  {
79
73
  id += 1;
80
-
81
74
  const notification = _objectSpread(_objectSpread({}, action.payload), {}, {
82
75
  id
83
76
  });
84
-
85
77
  const dismissCallback = () => {
86
78
  dispatch(removeNotification(notification.id));
87
79
  };
88
-
89
80
  if (action.meta) {
90
81
  if (action.meta.dismissAfter) _setTimeout__default["default"](dismissCallback, action.meta.dismissAfter);
91
82
  if (typeof action.meta.onDismiss === 'function') dismissCallbacksMap.set(notification.id, action.meta.onDismiss);
92
83
  }
93
-
94
84
  const nextAction = _objectSpread(_objectSpread({}, action), {}, {
95
85
  payload: notification,
96
86
  dismiss: dismissCallback
97
87
  });
98
-
99
88
  return next(nextAction);
100
89
  }
101
-
102
90
  case REMOVE_NOTIFICATION:
103
91
  {
104
92
  const notificationId = action.payload.id;
@@ -107,7 +95,6 @@ const middleware = _ref => {
107
95
  dismissCallbacksMap.delete(notificationId);
108
96
  return next(action);
109
97
  }
110
-
111
98
  default:
112
99
  return next(action);
113
100
  }
@@ -118,16 +105,13 @@ function notificationsReducer() {
118
105
  let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
119
106
  let action = arguments.length > 1 ? arguments[1] : undefined;
120
107
  if (!action || !action.type) return state;
121
-
122
108
  switch (action.type) {
123
109
  case ADD_NOTIFICATION:
124
110
  {
125
111
  return [action.payload, ...state];
126
112
  }
127
-
128
113
  case REMOVE_NOTIFICATION:
129
114
  return _filterInstanceProperty__default["default"](state).call(state, notification => action.payload.id !== notification.id);
130
-
131
115
  default:
132
116
  return state;
133
117
  }
@@ -12,7 +12,7 @@ import _Map from '@babel/runtime-corejs3/core-js-stable/map';
12
12
  import _setTimeout from '@babel/runtime-corejs3/core-js-stable/set-timeout';
13
13
 
14
14
  // NOTE: This string will be replaced on build time with the package version.
15
- var version = "22.2.1";
15
+ var version = "22.3.0";
16
16
 
17
17
  const ADD_NOTIFICATION = 'ADD_NOTIFICATION';
18
18
  const REMOVE_NOTIFICATION = 'REMOVE_NOTIFICATION';
@@ -35,52 +35,40 @@ function removeNotification(id) {
35
35
  }
36
36
 
37
37
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
38
-
39
38
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
40
-
41
39
  // Force TS cast of generic action to TNotificationAction
42
40
  const isNotificationAction = action => {
43
41
  var _context;
44
-
45
42
  return _includesInstanceProperty(_context = [ADD_NOTIFICATION, REMOVE_NOTIFICATION]).call(_context, action.type);
46
43
  };
47
-
48
44
  const dismissCallbacksMap = new _Map();
49
45
  let id = 0;
50
-
51
46
  const middleware = _ref => {
52
47
  let dispatch = _ref.dispatch;
53
48
  return next => action => {
54
49
  if (!isNotificationAction(action)) {
55
50
  return next(action);
56
51
  }
57
-
58
52
  switch (action.type) {
59
53
  case ADD_NOTIFICATION:
60
54
  {
61
55
  id += 1;
62
-
63
56
  const notification = _objectSpread(_objectSpread({}, action.payload), {}, {
64
57
  id
65
58
  });
66
-
67
59
  const dismissCallback = () => {
68
60
  dispatch(removeNotification(notification.id));
69
61
  };
70
-
71
62
  if (action.meta) {
72
63
  if (action.meta.dismissAfter) _setTimeout(dismissCallback, action.meta.dismissAfter);
73
64
  if (typeof action.meta.onDismiss === 'function') dismissCallbacksMap.set(notification.id, action.meta.onDismiss);
74
65
  }
75
-
76
66
  const nextAction = _objectSpread(_objectSpread({}, action), {}, {
77
67
  payload: notification,
78
68
  dismiss: dismissCallback
79
69
  });
80
-
81
70
  return next(nextAction);
82
71
  }
83
-
84
72
  case REMOVE_NOTIFICATION:
85
73
  {
86
74
  const notificationId = action.payload.id;
@@ -89,7 +77,6 @@ const middleware = _ref => {
89
77
  dismissCallbacksMap.delete(notificationId);
90
78
  return next(action);
91
79
  }
92
-
93
80
  default:
94
81
  return next(action);
95
82
  }
@@ -100,16 +87,13 @@ function notificationsReducer() {
100
87
  let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
101
88
  let action = arguments.length > 1 ? arguments[1] : undefined;
102
89
  if (!action || !action.type) return state;
103
-
104
90
  switch (action.type) {
105
91
  case ADD_NOTIFICATION:
106
92
  {
107
93
  return [action.payload, ...state];
108
94
  }
109
-
110
95
  case REMOVE_NOTIFICATION:
111
96
  return _filterInstanceProperty(state).call(state, notification => action.payload.id !== notification.id);
112
-
113
97
  default:
114
98
  return state;
115
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/notifications",
3
- "version": "22.2.1",
3
+ "version": "22.3.0",
4
4
  "description": "A general-purpose notification system built on top of redux",
5
5
  "bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
6
6
  "repository": {
@@ -9,14 +9,24 @@
9
9
  "directory": "packages/notifications"
10
10
  },
11
11
  "homepage": "https://docs.commercetools.com/custom-applications",
12
- "keywords": ["javascript", "frontend", "react", "toolkit"],
12
+ "keywords": [
13
+ "javascript",
14
+ "frontend",
15
+ "react",
16
+ "toolkit"
17
+ ],
13
18
  "license": "MIT",
14
19
  "publishConfig": {
15
20
  "access": "public"
16
21
  },
17
22
  "main": "dist/commercetools-frontend-notifications.cjs.js",
18
23
  "module": "dist/commercetools-frontend-notifications.esm.js",
19
- "files": ["dist", "package.json", "LICENSE", "README.md"],
24
+ "files": [
25
+ "dist",
26
+ "package.json",
27
+ "LICENSE",
28
+ "README.md"
29
+ ],
20
30
  "dependencies": {
21
31
  "@babel/runtime": "^7.20.13",
22
32
  "@babel/runtime-corejs3": "^7.20.13"
@@ -27,4 +37,4 @@
27
37
  "peerDependencies": {
28
38
  "redux": "4.x"
29
39
  }
30
- }
40
+ }