@commercetools-frontend/react-notifications 22.3.0 → 22.3.1
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.
- package/dist/commercetools-frontend-react-notifications.cjs.dev.js +39 -45
- package/dist/commercetools-frontend-react-notifications.cjs.prod.js +32 -37
- package/dist/commercetools-frontend-react-notifications.esm.js +40 -45
- package/dist/declarations/src/components/notification/notification.styles.d.ts +0 -1
- package/dist/declarations/src/components/notification-kinds/api-error-message/api-error-message.d.ts +12 -13
- package/package.json +5 -5
|
@@ -16,9 +16,7 @@ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/obje
|
|
|
16
16
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
17
17
|
var reactIntl = require('react-intl');
|
|
18
18
|
var constants = require('@commercetools-frontend/constants');
|
|
19
|
-
var designSystem = require('@commercetools-uikit/design-system');
|
|
20
19
|
var hooks = require('@commercetools-uikit/hooks');
|
|
21
|
-
var IconButton = require('@commercetools-uikit/icon-button');
|
|
22
20
|
var icons = require('@commercetools-uikit/icons');
|
|
23
21
|
var SecondaryIconButton = require('@commercetools-uikit/secondary-icon-button');
|
|
24
22
|
var utils = require('@commercetools-uikit/utils');
|
|
@@ -26,6 +24,7 @@ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable
|
|
|
26
24
|
var omitBy = require('lodash/omitBy');
|
|
27
25
|
var _taggedTemplateLiteral = require('@babel/runtime-corejs3/helpers/taggedTemplateLiteral');
|
|
28
26
|
var react$1 = require('@emotion/react');
|
|
27
|
+
var designSystem = require('@commercetools-uikit/design-system');
|
|
29
28
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
30
29
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
31
30
|
var _valuesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/values');
|
|
@@ -51,7 +50,6 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
51
50
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
52
51
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
53
52
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
54
|
-
var IconButton__default = /*#__PURE__*/_interopDefault(IconButton);
|
|
55
53
|
var SecondaryIconButton__default = /*#__PURE__*/_interopDefault(SecondaryIconButton);
|
|
56
54
|
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
57
55
|
var omitBy__default = /*#__PURE__*/_interopDefault(omitBy);
|
|
@@ -64,7 +62,7 @@ var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanc
|
|
|
64
62
|
var isNumber__default = /*#__PURE__*/_interopDefault(isNumber);
|
|
65
63
|
|
|
66
64
|
// NOTE: This string will be replaced on build time with the package version.
|
|
67
|
-
var version = "22.3.
|
|
65
|
+
var version = "22.3.1";
|
|
68
66
|
|
|
69
67
|
const Context = /*#__PURE__*/react.createContext(() => null);
|
|
70
68
|
function NotificationProviderForCustomComponent(props) {
|
|
@@ -121,10 +119,10 @@ const getBorderColor = notificationKind => {
|
|
|
121
119
|
const showNotificationAnimation = react$1.keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% {\n max-height: 0;\n padding-top: 0;\n padding-bottom: 0;\n overflow: hidden;\n }\n 100% {\n max-height: 200px;\n }\n"])));
|
|
122
120
|
const showNotificationSideAnimation = react$1.keyframes(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n 0% {\n transform: translateX(50px);\n }\n 100% {\n transform: translateX(0);\n }\n"])));
|
|
123
121
|
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), ";" + ("" ), "" );
|
|
124
|
-
const getStylesForCloseIcon = props => /*#__PURE__*/react$1.css("display:flex;justify-content:center
|
|
122
|
+
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 + '; }' : '', ";" + ("" ), "" );
|
|
125
123
|
const getStylesForContent = props => {
|
|
126
124
|
const fontColor = props.domain === constants.NOTIFICATION_DOMAINS.SIDE ? designSystem.designTokens.colorSolid : designSystem.designTokens.colorSurface;
|
|
127
|
-
return /*#__PURE__*/react$1.css("flex-basis:100%;flex-grow:1;padding:0 "
|
|
125
|
+
return /*#__PURE__*/react$1.css("flex-basis:100%;flex-grow:1;padding:", "0 ".concat(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;}" + ("" ), "" );
|
|
128
126
|
};
|
|
129
127
|
const getStylesForNotification = props => {
|
|
130
128
|
const baseStyles = /*#__PURE__*/react$1.css("position:relative;display:flex;align-items:center;padding:", designSystem.designTokens.spacingM, ";color:", designSystem.designTokens.colorSurface, ";" + ("" ), "" );
|
|
@@ -136,7 +134,7 @@ const getStylesForNotification = props => {
|
|
|
136
134
|
return pageStyles;
|
|
137
135
|
case constants.NOTIFICATION_DOMAINS.SIDE:
|
|
138
136
|
{
|
|
139
|
-
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 ",
|
|
137
|
+
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;" + ("" ), "" );
|
|
140
138
|
if (props.fixed) return sideStyles;
|
|
141
139
|
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%;" + ("" ), "" );
|
|
142
140
|
}
|
|
@@ -155,9 +153,7 @@ const NotificationIcon = props => {
|
|
|
155
153
|
});
|
|
156
154
|
}
|
|
157
155
|
if (props.type === constants.NOTIFICATION_KINDS_SIDE.info) {
|
|
158
|
-
return
|
|
159
|
-
color: props.color
|
|
160
|
-
}) : jsxRuntime.jsx(icons.InfoIcon, {
|
|
156
|
+
return jsxRuntime.jsx(icons.InformationIcon, {
|
|
161
157
|
color: props.color
|
|
162
158
|
});
|
|
163
159
|
}
|
|
@@ -178,28 +174,18 @@ const defaultProps$1 = {
|
|
|
178
174
|
const Notification = props => {
|
|
179
175
|
const intl = reactIntl.useIntl();
|
|
180
176
|
const id = hooks.useFieldId(undefined, sequentialId);
|
|
181
|
-
const _useTheme = designSystem.useTheme(),
|
|
182
|
-
isNewTheme = _useTheme.isNewTheme,
|
|
183
|
-
themedValue = _useTheme.themedValue;
|
|
184
|
-
const Button = themedValue(IconButton__default["default"], SecondaryIconButton__default["default"]);
|
|
185
177
|
return jsxRuntime.jsxs("div", _objectSpread$4(_objectSpread$4({
|
|
186
178
|
role: "alertdialog",
|
|
187
179
|
"aria-describedby": id,
|
|
188
|
-
css: getStylesForNotification(
|
|
189
|
-
isNewTheme
|
|
190
|
-
}))
|
|
180
|
+
css: getStylesForNotification(props)
|
|
191
181
|
}, filterDataAttributes(props)), {}, {
|
|
192
182
|
children: [jsxRuntime.jsx("div", {
|
|
193
183
|
id: id,
|
|
194
|
-
css: getStylesForContent(
|
|
195
|
-
isNewTheme
|
|
196
|
-
})),
|
|
184
|
+
css: getStylesForContent(props),
|
|
197
185
|
children: props.children
|
|
198
186
|
}), props.onCloseClick ? jsxRuntime.jsx("div", {
|
|
199
|
-
css: getStylesForCloseIcon(
|
|
200
|
-
|
|
201
|
-
})),
|
|
202
|
-
children: jsxRuntime.jsx(Button, {
|
|
187
|
+
css: getStylesForCloseIcon(props),
|
|
188
|
+
children: jsxRuntime.jsx(SecondaryIconButton__default["default"], {
|
|
203
189
|
label: intl.formatMessage(messages.hideNotification),
|
|
204
190
|
onClick: props.onCloseClick,
|
|
205
191
|
icon: jsxRuntime.jsx(icons.CloseBoldIcon, {}),
|
|
@@ -209,8 +195,7 @@ const Notification = props => {
|
|
|
209
195
|
css: getStylesForNotificationIcon(props),
|
|
210
196
|
children: jsxRuntime.jsx(NotificationIcon, {
|
|
211
197
|
type: props.type,
|
|
212
|
-
color: "surface"
|
|
213
|
-
isNewTheme: isNewTheme
|
|
198
|
+
color: "surface"
|
|
214
199
|
})
|
|
215
200
|
}) : null]
|
|
216
201
|
}));
|
|
@@ -363,17 +348,27 @@ var apiErrorMessages = reactIntl.defineMessages({
|
|
|
363
348
|
function ownKeys$3(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; }
|
|
364
349
|
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var _context6, _context7; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys$3(Object(source), !0)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys$3(Object(source))).call(_context7, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
365
350
|
const regexInvalidOperationRequiredAttribute = /Required attribute '(.*)' cannot be removed/;
|
|
351
|
+
|
|
352
|
+
// `error` fields for REST errors
|
|
353
|
+
// `error.extensions` fields for GraphQL errors
|
|
366
354
|
// The values passed to the Intl message must be a map of scalar values.
|
|
367
355
|
// Some of the message values are already mapped in the `getSpecialFormattedMessageByErrorCode`
|
|
368
356
|
// function. Here we map other possible error properties that can be
|
|
369
357
|
// used in the message.
|
|
370
358
|
const mapErrorFieldsToMessageValues = error => {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
359
|
+
var _error$extensions, _error$extensions2;
|
|
360
|
+
const errorField = ((_error$extensions = error.extensions) === null || _error$extensions === void 0 ? void 0 : _error$extensions.field) || error.field;
|
|
361
|
+
if (errorField) {
|
|
362
|
+
return {
|
|
363
|
+
field: errorField
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
const errorReferencedBy = ((_error$extensions2 = error.extensions) === null || _error$extensions2 === void 0 ? void 0 : _error$extensions2.referencedBy) || error.referencedBy;
|
|
367
|
+
if (errorReferencedBy) {
|
|
368
|
+
return {
|
|
369
|
+
referencedBy: errorReferencedBy
|
|
370
|
+
};
|
|
371
|
+
}
|
|
377
372
|
return {};
|
|
378
373
|
};
|
|
379
374
|
|
|
@@ -427,8 +422,8 @@ const ApiErrorMessage = props => {
|
|
|
427
422
|
ApiErrorMessage.propTypes = {};
|
|
428
423
|
ApiErrorMessage.displayName = 'ApiErrorMessage';
|
|
429
424
|
function getSpecialFormattedMessageByErrorCode(error, intl) {
|
|
430
|
-
var _error$extensions$cod, _error$
|
|
431
|
-
const extensionErrorCode = (_error$extensions$cod = (_error$
|
|
425
|
+
var _error$extensions$cod, _error$extensions3, _context3, _context4, _context5;
|
|
426
|
+
const extensionErrorCode = (_error$extensions$cod = (_error$extensions3 = error.extensions) === null || _error$extensions3 === void 0 ? void 0 : _error$extensions3.code) !== null && _error$extensions$cod !== void 0 ? _error$extensions$cod : error.code;
|
|
432
427
|
if (error.errorByExtension) {
|
|
433
428
|
let extensionMessage;
|
|
434
429
|
if (error.localizedMessage) {
|
|
@@ -441,9 +436,9 @@ function getSpecialFormattedMessageByErrorCode(error, intl) {
|
|
|
441
436
|
// TODO: this is a temporary solution until we have proper pages about 403
|
|
442
437
|
if (extensionErrorCode === 'insufficient_scope') return intl.formatMessage(apiErrorMessages.Forbidden);
|
|
443
438
|
if (extensionErrorCode === 'DuplicateField') {
|
|
444
|
-
var _error$
|
|
445
|
-
const errorField = ((_error$
|
|
446
|
-
const errorDuplicateValue = ((_error$
|
|
439
|
+
var _error$extensions4, _error$extensions5;
|
|
440
|
+
const errorField = ((_error$extensions4 = error.extensions) === null || _error$extensions4 === void 0 ? void 0 : _error$extensions4.field) || error.field;
|
|
441
|
+
const errorDuplicateValue = ((_error$extensions5 = error.extensions) === null || _error$extensions5 === void 0 ? void 0 : _error$extensions5.duplicateValue) || error.duplicateValue;
|
|
447
442
|
if (errorField === 'slug') {
|
|
448
443
|
return intl.formatMessage(apiErrorMessages.DuplicateSlug, {
|
|
449
444
|
slugValue: errorDuplicateValue
|