@commercetools-frontend/react-notifications 0.0.0-FEC-157-preview-releases-20241126230331

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.
Files changed (35) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -0
  3. package/dist/commercetools-frontend-react-notifications.cjs.d.ts +2 -0
  4. package/dist/commercetools-frontend-react-notifications.cjs.d.ts.map +1 -0
  5. package/dist/commercetools-frontend-react-notifications.cjs.dev.js +845 -0
  6. package/dist/commercetools-frontend-react-notifications.cjs.js +7 -0
  7. package/dist/commercetools-frontend-react-notifications.cjs.prod.js +816 -0
  8. package/dist/commercetools-frontend-react-notifications.esm.js +811 -0
  9. package/dist/declarations/src/components/map-notification-to-component/index.d.ts +4 -0
  10. package/dist/declarations/src/components/map-notification-to-component/map-notification-to-component.d.ts +12 -0
  11. package/dist/declarations/src/components/notification/index.d.ts +1 -0
  12. package/dist/declarations/src/components/notification/messages.d.ts +8 -0
  13. package/dist/declarations/src/components/notification/notification.d.ts +15 -0
  14. package/dist/declarations/src/components/notification/notification.styles.d.ts +12 -0
  15. package/dist/declarations/src/components/notification-kinds/api-error/api-error.d.ts +16 -0
  16. package/dist/declarations/src/components/notification-kinds/api-error/index.d.ts +1 -0
  17. package/dist/declarations/src/components/notification-kinds/api-error-message/api-error-message.d.ts +34 -0
  18. package/dist/declarations/src/components/notification-kinds/api-error-message/index.d.ts +1 -0
  19. package/dist/declarations/src/components/notification-kinds/api-error-message/messages.d.ts +153 -0
  20. package/dist/declarations/src/components/notification-kinds/generic/generic.d.ts +15 -0
  21. package/dist/declarations/src/components/notification-kinds/generic/index.d.ts +1 -0
  22. package/dist/declarations/src/components/notification-kinds/unexpected-error/index.d.ts +1 -0
  23. package/dist/declarations/src/components/notification-kinds/unexpected-error/unexpected-error.d.ts +16 -0
  24. package/dist/declarations/src/components/notifications-list/index.d.ts +1 -0
  25. package/dist/declarations/src/components/notifications-list/notifications-list.d.ts +9 -0
  26. package/dist/declarations/src/components/notifications-list/notifications-list.styles.d.ts +6 -0
  27. package/dist/declarations/src/components/notifications-list/selectors.d.ts +18 -0
  28. package/dist/declarations/src/components/notifications-list/types.d.ts +4 -0
  29. package/dist/declarations/src/components/notifier/index.d.ts +1 -0
  30. package/dist/declarations/src/components/notifier/notifier.d.ts +16 -0
  31. package/dist/declarations/src/export-types.d.ts +2 -0
  32. package/dist/declarations/src/index.d.ts +8 -0
  33. package/dist/declarations/src/utils/filter-data-attributes.d.ts +1 -0
  34. package/dist/declarations/src/version.d.ts +2 -0
  35. package/package.json +79 -0
@@ -0,0 +1,816 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _pt = require('prop-types');
6
+ var react = require('react');
7
+ var jsxRuntime = require('@emotion/react/jsx-runtime');
8
+ var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
9
+ var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
10
+ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
11
+ var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
12
+ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
13
+ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
14
+ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
15
+ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
16
+ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
17
+ var reactIntl = require('react-intl');
18
+ var constants = require('@commercetools-frontend/constants');
19
+ var hooks = require('@commercetools-uikit/hooks');
20
+ var icons = require('@commercetools-uikit/icons');
21
+ var SecondaryIconButton = require('@commercetools-uikit/secondary-icon-button');
22
+ var utils = require('@commercetools-uikit/utils');
23
+ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
24
+ var omitBy = require('lodash/omitBy');
25
+ var react$1 = require('@emotion/react');
26
+ var designSystem = require('@commercetools-uikit/design-system');
27
+ var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
28
+ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
29
+ var _valuesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/values');
30
+ var reactRedux = require('react-redux');
31
+ var notifications = require('@commercetools-frontend/notifications');
32
+ var sentry = require('@commercetools-frontend/sentry');
33
+ var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
34
+ var has = require('lodash/has');
35
+ var Spacings = require('@commercetools-uikit/spacings');
36
+ var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
37
+ var reselect = require('reselect');
38
+ var isNumber = require('lodash/isNumber');
39
+ var actionsGlobal = require('@commercetools-frontend/actions-global');
40
+
41
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
42
+
43
+ var _pt__default = /*#__PURE__*/_interopDefault(_pt);
44
+ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
45
+ var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
46
+ var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
47
+ var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
48
+ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
49
+ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
50
+ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
51
+ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
52
+ var SecondaryIconButton__default = /*#__PURE__*/_interopDefault(SecondaryIconButton);
53
+ var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
54
+ var omitBy__default = /*#__PURE__*/_interopDefault(omitBy);
55
+ var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
56
+ var _valuesInstanceProperty__default = /*#__PURE__*/_interopDefault(_valuesInstanceProperty);
57
+ var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
58
+ var has__default = /*#__PURE__*/_interopDefault(has);
59
+ var Spacings__default = /*#__PURE__*/_interopDefault(Spacings);
60
+ var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
61
+ var isNumber__default = /*#__PURE__*/_interopDefault(isNumber);
62
+
63
+ // NOTE: This string will be replaced on build time with the package version.
64
+ var version = "22.35.1";
65
+
66
+ const Context = /*#__PURE__*/react.createContext(() => null);
67
+ function NotificationProviderForCustomComponent(props) {
68
+ return jsxRuntime.jsx(Context.Provider, {
69
+ value: props.mapNotificationToComponent,
70
+ children: props.children
71
+ });
72
+ }
73
+ NotificationProviderForCustomComponent.propTypes = {};
74
+ NotificationProviderForCustomComponent.displayName = 'NotificationProviderForCustomComponent';
75
+ const useCustomNotificationComponent = () => react.useContext(Context);
76
+
77
+ function filterDataAttributes(obj) {
78
+ return omitBy__default["default"](obj, (_value, key) => !_startsWithInstanceProperty__default["default"](key).call(key, 'data-'));
79
+ }
80
+
81
+ var messages = reactIntl.defineMessages({
82
+ hideNotification: {
83
+ id: 'Notification.hideNotification',
84
+ description: 'Label for button to hide notification',
85
+ defaultMessage: 'Hide notification'
86
+ }
87
+ });
88
+
89
+ const getColorByType = value => {
90
+ switch (value) {
91
+ case constants.NOTIFICATION_KINDS_SIDE.success:
92
+ return designSystem.designTokens.colorSuccess;
93
+ case constants.NOTIFICATION_KINDS_SIDE.info:
94
+ return designSystem.designTokens.colorInfo;
95
+ case constants.NOTIFICATION_KINDS_SIDE.error:
96
+ return designSystem.designTokens.colorError;
97
+ case constants.NOTIFICATION_KINDS_SIDE.warning:
98
+ return designSystem.designTokens.colorWarning60;
99
+ default:
100
+ return 'transparent';
101
+ }
102
+ };
103
+ const getBorderColor = notificationKind => {
104
+ switch (notificationKind) {
105
+ case constants.NOTIFICATION_KINDS_SIDE.success:
106
+ return designSystem.designTokens.colorSuccess85;
107
+ case constants.NOTIFICATION_KINDS_SIDE.info:
108
+ return designSystem.designTokens.colorInfo85;
109
+ case constants.NOTIFICATION_KINDS_SIDE.error:
110
+ return designSystem.designTokens.colorError85;
111
+ case constants.NOTIFICATION_KINDS_SIDE.warning:
112
+ return designSystem.designTokens.colorWarning85;
113
+ default:
114
+ return 'transparent';
115
+ }
116
+ };
117
+ const showNotificationAnimation = react$1.keyframes`
118
+ 0% {
119
+ max-height: 0;
120
+ padding-top: 0;
121
+ padding-bottom: 0;
122
+ overflow: hidden;
123
+ }
124
+ 100% {
125
+ max-height: 200px;
126
+ }
127
+ `;
128
+ const showNotificationSideAnimation = react$1.keyframes`
129
+ 0% {
130
+ transform: translateX(50px);
131
+ }
132
+ 100% {
133
+ transform: translateX(0);
134
+ }
135
+ `;
136
+ const getStylesForNotificationIcon = props => /*#__PURE__*/react$1.css("display:flex;align-items:center;justify-content:center;position:absolute;left:0;top:0;width:48px;height:100%;color:", designSystem.designTokens.colorSurface, ";border-radius:3px 0 0 3px;background:", getColorByType(props.type), ";" + ("" ), "" );
137
+ const getStylesForCloseIcon = props => /*#__PURE__*/react$1.css("display:flex;justify-content:center;& svg{width:16px;height:16px;}", props.domain !== constants.NOTIFICATION_DOMAINS.SIDE ? '& svg { fill: ' + designSystem.designTokens.colorSurface + '; }' : '', ";" + ("" ), "" );
138
+ const getStylesForContent = props => {
139
+ const fontColor = props.domain === constants.NOTIFICATION_DOMAINS.SIDE ? designSystem.designTokens.colorSolid : designSystem.designTokens.colorSurface;
140
+ return /*#__PURE__*/react$1.css("flex-basis:100%;flex-grow:1;padding:", `0 ${designSystem.designTokens.spacingM}`, ";margin:0;font-size:", props.domain === constants.NOTIFICATION_DOMAINS.SIDE ? '1rem' : 'inherit', ";color:", fontColor, ";p{color:", fontColor, ";}ul{padding:0;margin:0;list-style:none;}" + ("" ), "" );
141
+ };
142
+ const getStylesForNotification = props => {
143
+ const baseStyles = /*#__PURE__*/react$1.css("position:relative;display:flex;align-items:center;padding:", designSystem.designTokens.spacingM, ";color:", designSystem.designTokens.colorSurface, ";" + ("" ), "" );
144
+ const pageStyles = /*#__PURE__*/react$1.css(baseStyles, ";animation:", showNotificationAnimation, " 0.3s forwards;text-align:center;background-color:", props.fixed ? 'transparent' : getColorByType(props.type), ";>*+*{margin-left:", designSystem.designTokens.spacingS, ";}" + ("" ), "" );
145
+ switch (props.domain) {
146
+ case constants.NOTIFICATION_DOMAINS.GLOBAL:
147
+ return /*#__PURE__*/react$1.css(pageStyles, ";background-color:", getColorByType(props.type), ";" + ("" ), "" );
148
+ case constants.NOTIFICATION_DOMAINS.PAGE:
149
+ return pageStyles;
150
+ case constants.NOTIFICATION_DOMAINS.SIDE:
151
+ {
152
+ const sideStyles = /*#__PURE__*/react$1.css(baseStyles, ";animation:", showNotificationAnimation, " 0.3s forwards;padding:", designSystem.designTokens.spacingM, " ", designSystem.designTokens.spacingM, " ", designSystem.designTokens.spacingM, " 50px!important;text-align:left;background:", designSystem.designTokens.colorSurface, ";border:1px solid ", getBorderColor(props.type), ";box-shadow:0px 2px 5px 0px rgba(0, 0, 0, 0.15);border-radius:", designSystem.designTokens.borderRadius6, ";word-break:break-word;hyphens:auto;" + ("" ), "" );
153
+ if (props.fixed) return sideStyles;
154
+ return /*#__PURE__*/react$1.css(sideStyles, ";animation:", showNotificationSideAnimation, " 0.3s forwards;position:relative;z-index:10000;margin-top:", designSystem.designTokens.spacingL, "!important;right:", designSystem.designTokens.spacingXl, ";float:right;clear:both;max-width:50%;" + ("" ), "" );
155
+ }
156
+ default:
157
+ return /*#__PURE__*/react$1.css("" , "" );
158
+ }
159
+ };
160
+
161
+ function ownKeys$4(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
162
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$4(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$4(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
163
+ const sequentialId = utils.createSequentialId('notification-');
164
+ const NotificationIcon = props => {
165
+ if (props.type === constants.NOTIFICATION_KINDS_SIDE.error) {
166
+ return jsxRuntime.jsx(icons.ErrorIcon, {
167
+ color: props.color
168
+ });
169
+ }
170
+ if (props.type === constants.NOTIFICATION_KINDS_SIDE.info) {
171
+ return jsxRuntime.jsx(icons.InformationIcon, {
172
+ color: props.color
173
+ });
174
+ }
175
+ if (props.type === constants.NOTIFICATION_KINDS_SIDE.warning) {
176
+ return jsxRuntime.jsx(icons.WarningIcon, {
177
+ color: props.color
178
+ });
179
+ }
180
+ return jsxRuntime.jsx(icons.CheckBoldIcon, {
181
+ color: props.color
182
+ });
183
+ };
184
+ NotificationIcon.propTypes = {};
185
+ NotificationIcon.displayName = 'NotificationIcon';
186
+ const defaultProps$1 = {
187
+ fixed: false
188
+ };
189
+ const Notification = props => {
190
+ const intl = reactIntl.useIntl();
191
+ const id = hooks.useFieldId(undefined, sequentialId);
192
+ return jsxRuntime.jsxs("div", _objectSpread$4(_objectSpread$4({
193
+ role: "alertdialog",
194
+ "aria-describedby": id,
195
+ css: getStylesForNotification(props)
196
+ }, filterDataAttributes(props)), {}, {
197
+ children: [jsxRuntime.jsx("div", {
198
+ id: id,
199
+ css: getStylesForContent(props),
200
+ children: props.children
201
+ }), props.onCloseClick ? jsxRuntime.jsx("div", {
202
+ css: getStylesForCloseIcon(props),
203
+ children: jsxRuntime.jsx(SecondaryIconButton__default["default"], {
204
+ label: intl.formatMessage(messages.hideNotification),
205
+ onClick: props.onCloseClick,
206
+ icon: jsxRuntime.jsx(icons.CloseBoldIcon, {}),
207
+ size: "30"
208
+ })
209
+ }) : null, props.domain === constants.NOTIFICATION_DOMAINS.SIDE ? jsxRuntime.jsx("div", {
210
+ css: getStylesForNotificationIcon(props),
211
+ children: jsxRuntime.jsx(NotificationIcon, {
212
+ type: props.type,
213
+ color: "surface"
214
+ })
215
+ }) : null]
216
+ }));
217
+ };
218
+ Notification.propTypes = {};
219
+ Notification.displayName = 'Notification';
220
+ Notification.defaultProps = defaultProps$1;
221
+
222
+ var apiErrorMessages = reactIntl.defineMessages({
223
+ General: {
224
+ id: 'ApiError.General',
225
+ description: 'A general error message, usually because of internal application problems. The user should not know the details of the error.',
226
+ defaultMessage: 'Sorry, but there seems to be something wrong. Please try again. If you are seeing this message for the second time, please contact our support team.'
227
+ },
228
+ // Custom API Error messages (without a matching error.code)
229
+ OverlappingPrices: {
230
+ id: 'ApiError.OverlappingPrices',
231
+ description: '',
232
+ defaultMessage: 'Sorry, but a price with these details already exists. Please amend the price details so that they do not overlap with another price before saving.'
233
+ },
234
+ ConcurrentModificationBulkEdit: {
235
+ id: 'ApiError.ConcurrentModificationBulkEdit',
236
+ description: 'User does a bulk update but someone else has saved changes for that element',
237
+ defaultMessage: 'Sorry, but we were unable to save your changes as someone else made changes to this same source while you were editing.'
238
+ },
239
+ // API errors
240
+ ConcurrentModification: {
241
+ id: 'ApiError.ConcurrentModification',
242
+ description: 'User edits form and clicks Save but someone else has saved changes for this element while they were editing',
243
+ defaultMessage: 'Sorry, but we were unable to save your changes as someone else made changes to this same source while you were editing. Please refresh the page and re-enter your changes.'
244
+ },
245
+ DuplicateAttributeValue: {
246
+ id: 'ApiError.DuplicateAttributeValue',
247
+ description: 'User tries to enter the same attribute value for an attribute with the Unique constraint',
248
+ defaultMessage: 'This value has already been used for another variant. The "{name}" value must be unique for all variants for this product. Please enter a different value.'
249
+ },
250
+ DuplicateAttributeValues: {
251
+ id: 'ApiError.DuplicateAttributeValues',
252
+ description: 'User tries to enter existing attribute values for a combination of attributes with the CombinationUnique constraint',
253
+ defaultMessage: 'This combination has already been used for another variant. The combination of these attributes must be unique across all variants. Please enter a different version.'
254
+ },
255
+ DuplicateField: {
256
+ id: 'ApiError.DuplicateField',
257
+ description: 'The given field must be unique across the project',
258
+ defaultMessage: 'The value for the field "{field}" has already been used. Please choose another value for this field.'
259
+ },
260
+ DuplicateSlug: {
261
+ id: 'ApiError.DuplicateSlug',
262
+ description: 'User tries to create a resource with an already existing slug',
263
+ defaultMessage: '"{slugValue}" is already in use. Please enter a new slug value for this product.'
264
+ },
265
+ DuplicatePriceScope: {
266
+ id: 'ApiError.DuplicatePriceScope',
267
+ description: 'User tries to create a price with the exact same values as for an already existing price',
268
+ defaultMessage: 'A price with the same scope already exists for this product variant. Make sure that the combination of currency, country, customer group, channel and valid dates is unique per price.'
269
+ },
270
+ DuplicateStandalonePriceScope: {
271
+ id: 'ApiError.DuplicateStandalonePriceScope',
272
+ description: 'User tries to create a standalone price with the exact same values as for an already existing standalone price',
273
+ defaultMessage: 'A price with the same scope already exists for this product variant. The combination of currency, country, customer group, channel and validity date must be unique for each price per SKU.'
274
+ },
275
+ DuplicateVariantValues: {
276
+ id: 'ApiError.DuplicateVariantValues',
277
+ description: 'User tries to generate a variant with the same SKU or attribute values',
278
+ defaultMessage: 'The same variant already exists for this product. Please enter different values for the fields.'
279
+ },
280
+ InvalidDateRange: {
281
+ id: 'ApiError.InvalidDateRange',
282
+ description: 'User tries to input an invalid date range',
283
+ defaultMessage: 'The value entered for the field {field} is invalid. The start date must be before the end date'
284
+ },
285
+ InvalidField: {
286
+ id: 'ApiError.InvalidField',
287
+ description: 'User enters an invalid value for a field.',
288
+ defaultMessage: 'The value entered is not valid for the field "{field}".'
289
+ },
290
+ InvalidSlug: {
291
+ id: 'ApiError.InvalidSlug',
292
+ description: 'User enters an invalid value for the product slug',
293
+ defaultMessage: 'Slugs may only contain alphanumeric (0-9A-Z) characters, underscores and hyphens and must have a length between 2 and 256 characters.'
294
+ },
295
+ OverlappingPriceValidity: {
296
+ id: 'ApiError.OverlappingPriceValidity',
297
+ description: 'Returned when a given price validity period conflicts with an existing one',
298
+ defaultMessage: 'Another price with overlapping validity dates exists. Each price combination needs to have unique validity dates.'
299
+ },
300
+ OverlappingStandalonePriceValidity: {
301
+ id: 'ApiError.OverlappingStandalonePriceValidity',
302
+ description: 'Returned when a given standalone price validity period conflicts with an existing one',
303
+ defaultMessage: 'Another price with overlapping validity dates exists. Each price combination needs to have unique validity dates.'
304
+ },
305
+ PendingOperation: {
306
+ id: 'ApiError.PendingOperation',
307
+ description: 'User tries to start a new process when one is already underway',
308
+ defaultMessage: 'Sorry, but we are still processing the previous request. Please try again once it is complete.'
309
+ },
310
+ ResourceNotFound: {
311
+ id: 'ApiError.ResourceNotFound',
312
+ description: 'System cannot find the functionality or screen that the user is trying to access.',
313
+ defaultMessage: 'Sorry, but we cannot find what you are looking for.'
314
+ },
315
+ ReferenceExists: {
316
+ id: 'ApiError.ReferenceExists',
317
+ description: 'User tries to delete an element that has an existing reference to it from another element',
318
+ defaultMessage: 'Can not delete a source while it is referenced from at least one "{referencedBy}".'
319
+ },
320
+ RequiredField: {
321
+ id: 'ApiError.RequiredField',
322
+ description: 'User does not enter a required field',
323
+ defaultMessage: '"{field}" is a required field. Please enter a value.'
324
+ },
325
+ RequiredFields: {
326
+ // Client side validation
327
+ id: 'ApiError.RequiredFields',
328
+ description: 'User submits a form without having completed all mandatory fields',
329
+ defaultMessage: 'Please enter values for the following required fields: {fields}'
330
+ },
331
+ SemanticError: {
332
+ id: 'ApiError.SemanticError',
333
+ description: 'User enters a predicate query that throws a system semantic error',
334
+ defaultMessage: 'Semantic error: the given Predicate is not valid. Please read the documentation to define a correct predicate.'
335
+ },
336
+ SyntaxError: {
337
+ id: 'ApiError.SyntaxError',
338
+ description: 'User enters a predicate query that throws a system syntax error',
339
+ defaultMessage: 'Syntax error: the given Predicate is not valid. Please read the documentation to define a correct predicate.'
340
+ },
341
+ Unauthorized: {
342
+ id: 'ApiError.Unauthorized',
343
+ description: 'The access token is not valid anymore, or the user does not have a valid one',
344
+ defaultMessage: 'Sorry, but you are not authorized to access this feature.'
345
+ },
346
+ Forbidden: {
347
+ id: 'ApiError.Forbidden',
348
+ description: 'User tries to access a view that they do not have permission for',
349
+ defaultMessage: 'You are not authorized to access this feature. Please contact your system administrator with any further questions.'
350
+ },
351
+ ExtensionNoResponse: {
352
+ id: 'ApiError.ExtensionNoResponse',
353
+ description: 'User tries to access a view that they do not have permission for',
354
+ defaultMessage: 'Sorry, we could not perform the requested action due to an API extension not responding.'
355
+ },
356
+ ExtensionBadResponse: {
357
+ id: 'ApiError.ExtensionBadResponse',
358
+ description: 'User tries to access a view that they do not have permission for',
359
+ defaultMessage: 'Sorry, we could not perform the requested action due to failed processing of an API extension response.'
360
+ },
361
+ ExtensionUpdateActionsFailed: {
362
+ id: 'ApiError.ExtensionUpdateActionsFailed',
363
+ description: 'User tries to access a view that they do not have permission for',
364
+ defaultMessage: 'Sorry, we could not perform the requested action. It is not possible to perform the update actions as instructed by the API extension.'
365
+ },
366
+ TaxCategoryDuplicateCountry: {
367
+ id: 'ApiError.TaxCategoryDuplicateCountry',
368
+ description: 'User inputs duplicate country and/or state into tax category form',
369
+ defaultMessage: 'Duplicate tax rates submitted. Please remove the duplicates.'
370
+ },
371
+ MaxResourceLimitExceeded: {
372
+ id: 'ApiError.MaxResourceLimitExceeded',
373
+ description: 'User attempts to create a resource while having already reached the limit',
374
+ defaultMessage: 'The project reached the limit for the resource. To add more resources delete existing ones or reach out to the administrator or contact customer support.'
375
+ }
376
+ });
377
+
378
+ function ownKeys$3(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
379
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys$3(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys$3(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
380
+ const regexInvalidOperationRequiredAttribute = /^Required attribute '(.*)' cannot be removed/;
381
+
382
+ // `error` fields for REST errors
383
+ // `error.extensions` fields for GraphQL errors
384
+
385
+ // The values passed to the Intl message must be a map of scalar values.
386
+ // Some of the message values are already mapped in the `getSpecialFormattedMessageByErrorCode`
387
+ // function. Here we map other possible error properties that can be
388
+ // used in the message.
389
+ const mapErrorFieldsToMessageValues = error => {
390
+ const errorField = error.extensions?.field || error.field;
391
+ if (errorField) {
392
+ return {
393
+ field: errorField
394
+ };
395
+ }
396
+ const errorReferencedBy = error.extensions?.referencedBy || error.referencedBy;
397
+ if (errorReferencedBy) {
398
+ return {
399
+ referencedBy: errorReferencedBy
400
+ };
401
+ }
402
+ return {};
403
+ };
404
+
405
+ // Type-guard validation for error code to be included in the message object keys.
406
+ const hasErrorCodeAMatchingMessage = errorCode => errorCode in apiErrorMessages;
407
+ const FormattedErrorMessage = props => {
408
+ var _context2;
409
+ const intl = reactIntl.useIntl();
410
+ // Attempt to map the error by code
411
+ const extensionErrorCode = props.error.extensions?.code ?? props.error.code;
412
+ const messageCode = extensionErrorCode && hasErrorCodeAMatchingMessage(extensionErrorCode) ? apiErrorMessages[extensionErrorCode] : undefined;
413
+ react.useEffect(() => {
414
+ if (!messageCode) {
415
+ var _context;
416
+ // This error is not mapped / translated yet,
417
+ // we log, report it to sentry and show the original error, unless `error.code` is `invalid_scope`
418
+ // which an error code emitted for expired project(s)
419
+ if (extensionErrorCode !== 'invalid_scope' && !_includesInstanceProperty__default["default"](_context = props.error.message).call(_context, 'has expired')) {
420
+ sentry.reportErrorToSentry(new Error('Unmapped error'), {
421
+ extra: props.error
422
+ });
423
+ }
424
+ }
425
+ }, [extensionErrorCode, messageCode, props.error]);
426
+ if (messageCode) {
427
+ // The `error` object might contain extra fields for the specific `code`.
428
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
429
+ children: intl.formatMessage(messageCode, mapErrorFieldsToMessageValues(props.error))
430
+ });
431
+ }
432
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
433
+ children: _filterInstanceProperty__default["default"](_context2 = [props.error.message, props.error.detailedErrorMessage && `(${props.error.detailedErrorMessage})`]).call(_context2, Boolean).join(' ')
434
+ });
435
+ };
436
+ FormattedErrorMessage.propTypes = {
437
+ error: _pt__default["default"].any.isRequired
438
+ };
439
+ FormattedErrorMessage.displayName = 'FormattedErrorMessage';
440
+ const ApiErrorMessage = props => {
441
+ const intl = reactIntl.useIntl();
442
+
443
+ // Attempt to map the error to a specific error message
444
+ const specialFormattedMessage = getSpecialFormattedMessageByErrorCode(props.error, intl);
445
+ if (specialFormattedMessage) {
446
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
447
+ children: specialFormattedMessage
448
+ });
449
+ }
450
+ return jsxRuntime.jsx(FormattedErrorMessage, _objectSpread$3({}, props));
451
+ };
452
+ ApiErrorMessage.propTypes = {};
453
+ ApiErrorMessage.displayName = 'ApiErrorMessage';
454
+ function getSpecialFormattedMessageByErrorCode(error, intl) {
455
+ var _context3, _context4, _context5;
456
+ const extensionErrorCode = error.extensions?.code ?? error.code;
457
+ if (error.errorByExtension) {
458
+ let extensionMessage;
459
+ if (error.localizedMessage) {
460
+ extensionMessage = error.localizedMessage[intl.locale];
461
+ }
462
+ return extensionMessage || error.message;
463
+ }
464
+ if (!extensionErrorCode || extensionErrorCode === 'InvalidInput') return intl.formatMessage(apiErrorMessages.General);
465
+
466
+ // TODO: this is a temporary solution until we have proper pages about 403
467
+ if (extensionErrorCode === 'insufficient_scope') return intl.formatMessage(apiErrorMessages.Forbidden);
468
+ if (extensionErrorCode === 'DuplicateField') {
469
+ const errorField = error.extensions?.field || error.field;
470
+ const errorDuplicateValue = error.extensions?.duplicateValue || error.duplicateValue;
471
+ if (errorField === 'slug') {
472
+ return intl.formatMessage(apiErrorMessages.DuplicateSlug, {
473
+ slugValue: errorDuplicateValue
474
+ });
475
+ } else {
476
+ return intl.formatMessage(apiErrorMessages.DuplicateField, {
477
+ field: errorField
478
+ });
479
+ }
480
+ }
481
+
482
+ // Try to match the error with a custom error message
483
+ if (has__default["default"](error, 'invalidValue') && has__default["default"](error.invalidValue, 'overlappingPrices')) return intl.formatMessage(apiErrorMessages.OverlappingPrices);
484
+ if (extensionErrorCode === 'InvalidOperation' && _includesInstanceProperty__default["default"](_context3 = error.message).call(_context3, 'validFrom') && _includesInstanceProperty__default["default"](_context4 = error.message).call(_context4, 'validUntil')) {
485
+ return intl.formatMessage(apiErrorMessages.InvalidDateRange, {
486
+ field: 'validFrom'
487
+ });
488
+ }
489
+ if (extensionErrorCode === 'InvalidOperation' && _includesInstanceProperty__default["default"](_context5 = error.message).call(_context5, 'Duplicate tax rate for')) {
490
+ return intl.formatMessage(apiErrorMessages.TaxCategoryDuplicateCountry);
491
+ }
492
+ if (extensionErrorCode === 'InvalidOperation' && regexInvalidOperationRequiredAttribute.test(error.message)) {
493
+ const attrName = error.message.replace(regexInvalidOperationRequiredAttribute, '$1');
494
+ return intl.formatMessage(apiErrorMessages.RequiredField, {
495
+ field: attrName
496
+ });
497
+ }
498
+
499
+ // TODO: A concern has be raised that we can't accurately distinguish
500
+ // this error (invalid start / end dates with prices) from other price
501
+ // errors. We should investigate this further.
502
+ if (extensionErrorCode === 'InvalidField' && error.field === 'price' && has__default["default"](error, 'invalidValue') && has__default["default"](error.invalidValue, 'validFrom') && has__default["default"](error.invalidValue, 'validUntil')) return intl.formatMessage(apiErrorMessages.InvalidDateRange, {
503
+ field: error.field
504
+ });
505
+ if (extensionErrorCode === 'DuplicateAttributeValue' && error.attribute) {
506
+ return intl.formatMessage(apiErrorMessages.DuplicateAttributeValue, {
507
+ name: error.attribute.name
508
+ });
509
+ }
510
+ if (extensionErrorCode === 'MaxResourceLimitExceeded') {
511
+ return intl.formatMessage(apiErrorMessages.MaxResourceLimitExceeded);
512
+ }
513
+ return;
514
+ }
515
+
516
+ const ApiErrorNotification = props => {
517
+ var _context;
518
+ return jsxRuntime.jsx(Notification, {
519
+ type: "error",
520
+ domain: props.notification.domain,
521
+ onCloseClick: props.dismiss,
522
+ children: jsxRuntime.jsx("ul", {
523
+ children: _valuesInstanceProperty__default["default"](props.notification) && _mapInstanceProperty__default["default"](_context = _valuesInstanceProperty__default["default"](props.notification).errors).call(_context, (error, idx) => {
524
+ const extensionErrorCode = error.extensions?.code ?? error.code;
525
+ const shouldLogErrorToConsole = !extensionErrorCode && "production" === 'development';
526
+ if (shouldLogErrorToConsole) {
527
+ /**
528
+ * NOTE: This is an API error which usually contains
529
+ * a `code` property such as `DuplicateField` or `InvalidOperation`.
530
+ * If this `code` does not exist the API is not conforming to its
531
+ * own error specification.
532
+ */
533
+ // eslint-disable-next-line no-console
534
+ console.error('Unknown API error', error);
535
+ }
536
+ return jsxRuntime.jsx("li", {
537
+ children: jsxRuntime.jsx(ApiErrorMessage, {
538
+ error: error
539
+ })
540
+ }, idx);
541
+ })
542
+ })
543
+ });
544
+ };
545
+ ApiErrorNotification.propTypes = {};
546
+ ApiErrorNotification.displayName = 'ApiErrorNotification';
547
+
548
+ const GenericNotification = props => jsxRuntime.jsx(Notification, {
549
+ domain: props.notification.domain,
550
+ type: props.notification.kind,
551
+ onCloseClick: props.dismiss,
552
+ children: props.notification.text
553
+ });
554
+ GenericNotification.propTypes = {};
555
+ GenericNotification.displayName = 'GenericNotification';
556
+
557
+ function ownKeys$2(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
558
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$2(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
559
+ const UnexpectedErrorNotification = props => jsxRuntime.jsx(Notification, {
560
+ type: "error",
561
+ domain: props.notification.domain,
562
+ onCloseClick: props.dismiss,
563
+ children: jsxRuntime.jsxs(Spacings__default["default"].Stack, {
564
+ children: [jsxRuntime.jsx("div", {
565
+ children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$2({}, apiErrorMessages.General))
566
+ }), _valuesInstanceProperty__default["default"](props.notification) && _valuesInstanceProperty__default["default"](props.notification).errorId && jsxRuntime.jsx("div", {
567
+ children: `ID (${_valuesInstanceProperty__default["default"](props.notification).errorId})`
568
+ })]
569
+ })
570
+ });
571
+ UnexpectedErrorNotification.propTypes = {};
572
+ UnexpectedErrorNotification.displayName = 'UnexpectedErrorNotification';
573
+
574
+ const getStyles = props => {
575
+ const baseStyles = /*#__PURE__*/react$1.css("color:", designSystem.customProperties.colorSurface, ";position:relative;width:100%;z-index:19999;" + ("" ), "" );
576
+ switch (props.domain) {
577
+ case constants.NOTIFICATION_DOMAINS.GLOBAL:
578
+ return /*#__PURE__*/react$1.css(baseStyles, ";text-align:center;width:100%!important;" + ("" ), "" );
579
+ case constants.NOTIFICATION_DOMAINS.PAGE:
580
+ return /*#__PURE__*/react$1.css(baseStyles, ";" + ("" ), "" );
581
+ case constants.NOTIFICATION_DOMAINS.SIDE:
582
+ return /*#__PURE__*/react$1.css(baseStyles, ";position:absolute;text-align:left;height:0;overflow:visible;" + ("" ), "" );
583
+ default:
584
+ return /*#__PURE__*/react$1.css("" , "" );
585
+ }
586
+ };
587
+
588
+ // These selectors are okay memoization-wise, but once a single notifications
589
+ // is added or removed the memoization for all domain selectors is reset
590
+ const selectNotifications = state => state.notifications;
591
+ const selectGlobalNotifications = reselect.createSelector(selectNotifications, notifications => {
592
+ var _context;
593
+ return _sliceInstanceProperty__default["default"](_context = _filterInstanceProperty__default["default"](notifications).call(notifications, notification => notification.domain === constants.NOTIFICATION_DOMAINS.GLOBAL)
594
+ // Return only 1 at a time
595
+ ).call(_context, 0, 1);
596
+ });
597
+ const selectPageNotifications = reselect.createSelector(selectNotifications, notifications => _filterInstanceProperty__default["default"](notifications).call(notifications, notification => notification.domain === constants.NOTIFICATION_DOMAINS.PAGE));
598
+ const selectSideNotifications = reselect.createSelector(selectNotifications, notifications => _filterInstanceProperty__default["default"](notifications).call(notifications, notification => notification.domain === constants.NOTIFICATION_DOMAINS.SIDE));
599
+
600
+ const _excluded = ["values"],
601
+ _excluded2 = ["text"],
602
+ _excluded3 = ["values"],
603
+ _excluded4 = ["text"],
604
+ _excluded5 = ["text"];
605
+ function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
606
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
607
+ const NotificationsListGlobal = props => {
608
+ const dispatch = reactRedux.useDispatch();
609
+ const mapCustomNotificationToComponent = useCustomNotificationComponent();
610
+ const notifications$1 = reactRedux.useSelector(selectGlobalNotifications);
611
+ return jsxRuntime.jsx("div", {
612
+ id: `notifications-${props.domain}`,
613
+ css: getStyles(props),
614
+ children: _mapInstanceProperty__default["default"](notifications$1).call(notifications$1, notification => {
615
+ // 1. Check if there is a custom notification component first
616
+ const CustomNotificationComponent = mapCustomNotificationToComponent(notification);
617
+ if (CustomNotificationComponent) {
618
+ return jsxRuntime.jsx(CustomNotificationComponent, {
619
+ notification: notification,
620
+ dismiss: () => {
621
+ dispatch(notifications.removeNotification(notification.id));
622
+ }
623
+ }, notification.id);
624
+ }
625
+ switch (notification.kind) {
626
+ case constants.NOTIFICATION_KINDS_GLOBAL.error:
627
+ case constants.NOTIFICATION_KINDS_GLOBAL.warning:
628
+ case constants.NOTIFICATION_KINDS_GLOBAL.info:
629
+ case constants.NOTIFICATION_KINDS_GLOBAL.success:
630
+ {
631
+ _valuesInstanceProperty__default["default"](notification);
632
+ const genericNotification = _objectWithoutProperties(notification, _excluded);
633
+ return jsxRuntime.jsx(GenericNotification, {
634
+ notification: genericNotification,
635
+ dismiss: () => {
636
+ dispatch(notifications.removeNotification(notification.id));
637
+ }
638
+ }, notification.id);
639
+ }
640
+ case constants.NOTIFICATION_KINDS_GLOBAL['unexpected-error']:
641
+ {
642
+ notification.text;
643
+ const errorNotification = _objectWithoutProperties(notification, _excluded2);
644
+ return jsxRuntime.jsx(UnexpectedErrorNotification, {
645
+ notification: errorNotification,
646
+ dismiss: () => {
647
+ dispatch(notifications.removeNotification(notification.id));
648
+ }
649
+ }, notification.id);
650
+ }
651
+ default:
652
+ {
653
+ return null;
654
+ }
655
+ }
656
+ })
657
+ });
658
+ };
659
+ const NotificationsListPage = props => {
660
+ const dispatch = reactRedux.useDispatch();
661
+ const mapCustomNotificationToComponent = useCustomNotificationComponent();
662
+ const notifications$1 = reactRedux.useSelector(selectPageNotifications);
663
+ return jsxRuntime.jsx("div", {
664
+ id: `notifications-${props.domain}`,
665
+ css: getStyles(props),
666
+ children: _mapInstanceProperty__default["default"](notifications$1).call(notifications$1, notification => {
667
+ // 1. Check if there is a custom notification component first
668
+ const CustomNotificationComponent = mapCustomNotificationToComponent(notification);
669
+ if (CustomNotificationComponent) {
670
+ return jsxRuntime.jsx(CustomNotificationComponent, {
671
+ notification: notification,
672
+ dismiss: () => {
673
+ dispatch(notifications.removeNotification(notification.id));
674
+ }
675
+ }, notification.id);
676
+ }
677
+ switch (notification.kind) {
678
+ case constants.NOTIFICATION_KINDS_PAGE.error:
679
+ case constants.NOTIFICATION_KINDS_PAGE.warning:
680
+ case constants.NOTIFICATION_KINDS_PAGE.info:
681
+ case constants.NOTIFICATION_KINDS_PAGE.success:
682
+ {
683
+ _valuesInstanceProperty__default["default"](notification);
684
+ const genericNotification = _objectWithoutProperties(notification, _excluded3);
685
+ return jsxRuntime.jsx(GenericNotification, {
686
+ notification: _objectSpread$1(_objectSpread$1({}, genericNotification), {}, {
687
+ kind: notification.kind
688
+ }),
689
+ dismiss: () => {
690
+ dispatch(notifications.removeNotification(notification.id));
691
+ }
692
+ }, notification.id);
693
+ }
694
+ case constants.NOTIFICATION_KINDS_PAGE['api-error']:
695
+ {
696
+ notification.text;
697
+ const errorNotification = _objectWithoutProperties(notification, _excluded4);
698
+ return jsxRuntime.jsx(ApiErrorNotification, {
699
+ notification: errorNotification,
700
+ dismiss: () => {
701
+ dispatch(notifications.removeNotification(notification.id));
702
+ }
703
+ }, notification.id);
704
+ }
705
+ case constants.NOTIFICATION_KINDS_PAGE['unexpected-error']:
706
+ {
707
+ notification.text;
708
+ const errorNotification = _objectWithoutProperties(notification, _excluded5);
709
+ return jsxRuntime.jsx(UnexpectedErrorNotification, {
710
+ notification: _objectSpread$1(_objectSpread$1({}, errorNotification), {}, {
711
+ values: _valuesInstanceProperty__default["default"](notification)
712
+ }),
713
+ dismiss: () => {
714
+ dispatch(notifications.removeNotification(notification.id));
715
+ }
716
+ }, notification.id);
717
+ }
718
+ default:
719
+ return null;
720
+ }
721
+ })
722
+ });
723
+ };
724
+ const NotificationsListSide = props => {
725
+ const dispatch = reactRedux.useDispatch();
726
+ const mapCustomNotificationToComponent = useCustomNotificationComponent();
727
+ const notifications$1 = reactRedux.useSelector(selectSideNotifications);
728
+ return jsxRuntime.jsx("div", {
729
+ id: `notifications-${props.domain}`,
730
+ css: getStyles(props),
731
+ children: _mapInstanceProperty__default["default"](notifications$1).call(notifications$1, notification => {
732
+ // 1. Check if there is a custom notification component first
733
+ const CustomNotificationComponent = mapCustomNotificationToComponent(notification);
734
+ if (CustomNotificationComponent) {
735
+ return jsxRuntime.jsx(CustomNotificationComponent, {
736
+ notification: notification,
737
+ dismiss: () => {
738
+ dispatch(notifications.removeNotification(notification.id));
739
+ }
740
+ }, notification.id);
741
+ }
742
+ switch (notification.kind) {
743
+ case constants.NOTIFICATION_KINDS_SIDE.error:
744
+ case constants.NOTIFICATION_KINDS_SIDE.warning:
745
+ case constants.NOTIFICATION_KINDS_SIDE.info:
746
+ case constants.NOTIFICATION_KINDS_SIDE.success:
747
+ return jsxRuntime.jsx(GenericNotification, {
748
+ notification: notification,
749
+ dismiss: () => {
750
+ dispatch(notifications.removeNotification(notification.id));
751
+ }
752
+ }, notification.id);
753
+ default:
754
+ return null;
755
+ }
756
+ })
757
+ });
758
+ };
759
+ const NotificationsList = props => {
760
+ switch (props.domain) {
761
+ case constants.NOTIFICATION_DOMAINS.GLOBAL:
762
+ return jsxRuntime.jsx(NotificationsListGlobal, _objectSpread$1({}, props));
763
+ case constants.NOTIFICATION_DOMAINS.PAGE:
764
+ return jsxRuntime.jsx(NotificationsListPage, _objectSpread$1({}, props));
765
+ case constants.NOTIFICATION_DOMAINS.SIDE:
766
+ return jsxRuntime.jsx(NotificationsListSide, _objectSpread$1({}, props));
767
+ default:
768
+ return null;
769
+ }
770
+ };
771
+ NotificationsList.displayName = 'NotificationsList';
772
+
773
+ function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
774
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
775
+ const defaultProps = {
776
+ domain: constants.NOTIFICATION_DOMAINS.SIDE,
777
+ kind: constants.NOTIFICATION_KINDS_SIDE.success
778
+ };
779
+ const Notifier = props => {
780
+ const showNotification = actionsGlobal.useShowNotification();
781
+ react.useEffect(() => {
782
+ const notification = showNotification({
783
+ domain: props.domain,
784
+ kind: props.kind,
785
+ text: props.text
786
+ }, isNumber__default["default"](props.dismissAfter) ? _objectSpread(_objectSpread({}, props.meta), {}, {
787
+ dismissAfter: props.dismissAfter
788
+ }) : props.meta);
789
+ return () => {
790
+ // Remove notification when component "unmounts"
791
+ notification.dismiss && notification.dismiss();
792
+ };
793
+ // eslint-disable-next-line react-hooks/exhaustive-deps
794
+ }, []); // We want to run this only once, when the component mounts the first time. Therefore we need to pass an empty array, even though the eslint rule shows a warning.
795
+
796
+ return null;
797
+ };
798
+ Notifier.propTypes = {
799
+ domain: _pt__default["default"].any.isRequired,
800
+ kind: _pt__default["default"].any.isRequired,
801
+ text: _pt__default["default"].string,
802
+ meta: _pt__default["default"].objectOf(_pt__default["default"].any),
803
+ dismissAfter: _pt__default["default"].number
804
+ };
805
+ Notifier.displayName = 'Notifier';
806
+ Notifier.defaultProps = defaultProps;
807
+
808
+ exports.ApiErrorMessage = ApiErrorMessage;
809
+ exports.Notification = Notification;
810
+ exports.NotificationProviderForCustomComponent = NotificationProviderForCustomComponent;
811
+ exports.NotificationsList = NotificationsList;
812
+ exports.Notifier = Notifier;
813
+ exports.selectGlobalNotifications = selectGlobalNotifications;
814
+ exports.selectPageNotifications = selectPageNotifications;
815
+ exports.selectSideNotifications = selectSideNotifications;
816
+ exports.version = version;