@commercetools-frontend/application-shell-connectors 21.23.10 → 21.24.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.
@@ -18,13 +18,12 @@ var react = require('react');
18
18
  var moment = require('moment-timezone');
19
19
  var sentry = require('@commercetools-frontend/sentry');
20
20
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
21
- var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
22
21
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
23
22
  var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
24
23
  var _valuesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/values');
25
24
  var jsxRuntime = require('@emotion/react/jsx-runtime');
26
- var warning = require('tiny-warning');
27
25
  var react$1 = require('@apollo/client/react');
26
+ var warning = require('tiny-warning');
28
27
  var constants = require('@commercetools-frontend/constants');
29
28
 
30
29
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -47,12 +46,12 @@ var _valuesInstanceProperty__default = /*#__PURE__*/_interopDefault(_valuesInsta
47
46
  var warning__default = /*#__PURE__*/_interopDefault(warning);
48
47
 
49
48
  // NOTE: This string will be replaced on build time with the package version.
50
- var version = "21.23.10";
49
+ var version = "21.24.1";
51
50
 
52
- var mcHostnameRegex = /^mc(-(\d){4,})?\.(.*)$/;
53
- var mcPreviewHostnameRegex = /^.*\.mc-preview\.(.*)$/;
51
+ const mcHostnameRegex = /^mc(-(\d){4,})?\.(.*)$/;
52
+ const mcPreviewHostnameRegex = /^.*\.mc-preview\.(.*)$/;
54
53
 
55
- var getMcOriginTld = function getMcOriginTld(host) {
54
+ const getMcOriginTld = host => {
56
55
  if (host.match(mcPreviewHostnameRegex)) {
57
56
  return host.replace(mcPreviewHostnameRegex, '$1');
58
57
  }
@@ -60,22 +59,20 @@ var getMcOriginTld = function getMcOriginTld(host) {
60
59
  return host.replace(mcHostnameRegex, '$3');
61
60
  };
62
61
 
63
- var getMcApiUrlFromOrigin = function getMcApiUrlFromOrigin(origin) {
62
+ const getMcApiUrlFromOrigin = origin => {
64
63
  var _context;
65
64
 
66
- var url = new _URL__default["default"](origin);
67
- var originTld = getMcOriginTld(url.host);
65
+ const url = new _URL__default["default"](origin);
66
+ const originTld = getMcOriginTld(url.host);
68
67
  return _concatInstanceProperty__default["default"](_context = "".concat(url.protocol, "//mc-api.")).call(_context, originTld);
69
68
  };
70
69
 
71
- var parseAsBoolean = function parseAsBoolean(value) {
72
- return value === true || value === 'true';
73
- };
70
+ const parseAsBoolean = value => value === true || value === 'true';
74
71
 
75
72
  function getMcApiUrl() {
76
- var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.app;
77
- var origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.origin;
78
- var isServedByProxy = parseAsBoolean(environment.servedByProxy);
73
+ let environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.app;
74
+ let origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.origin;
75
+ const isServedByProxy = parseAsBoolean(environment.servedByProxy);
79
76
  /**
80
77
  * Prefer using the origin URL for the MC API based on the origin value
81
78
  * of the browser's `window.location`.
@@ -91,7 +88,7 @@ function getMcApiUrl() {
91
88
  }
92
89
 
93
90
  // From https://github.com/acdlite/recompose/blob/master/src/packages/recompose/getDisplayName.js
94
- var getDisplayName = function getDisplayName(Component) {
91
+ const getDisplayName = Component => {
95
92
  if (typeof Component === 'string') {
96
93
  return Component;
97
94
  }
@@ -105,7 +102,7 @@ var getDisplayName = function getDisplayName(Component) {
105
102
 
106
103
  function ownKeys$2(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; }
107
104
 
108
- function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context5 = ownKeys$2(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context6 = ownKeys$2(Object(source))).call(_context6, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
105
+ function _objectSpread$2(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$2(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$2(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
109
106
  // Menu visibilities
110
107
  // Permissions
111
108
  // Action rights
@@ -129,66 +126,76 @@ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) {
129
126
  * the fetching logic. Given this mapping needs to be used elsewere feel free
130
127
  * to move this over to `permissions` and export it there.
131
128
  */
132
- var normalizeAllAppliedPermissions = function normalizeAllAppliedPermissions(allAppliedPermissions) {
129
+ const normalizeAllAppliedPermissions = allAppliedPermissions => {
133
130
  if (!allAppliedPermissions || allAppliedPermissions.length === 0) {
134
131
  return null;
135
132
  }
136
133
 
137
- return _reduceInstanceProperty__default["default"](allAppliedPermissions).call(allAppliedPermissions, function (transformedAllApplied, allApplied) {
134
+ return _reduceInstanceProperty__default["default"](allAppliedPermissions).call(allAppliedPermissions, (transformedAllApplied, allApplied) => {
138
135
  if (!allApplied) return transformedAllApplied;
139
- return _objectSpread$2(_objectSpread$2({}, transformedAllApplied), {}, _defineProperty({}, allApplied.name, allApplied.value));
136
+ return _objectSpread$2(_objectSpread$2({}, transformedAllApplied), {}, {
137
+ [allApplied.name]: allApplied.value
138
+ });
140
139
  }, {});
141
140
  };
142
- var normalizeAllAppliedMenuVisibilities = function normalizeAllAppliedMenuVisibilities(allAppliedMenuVisibilities) {
141
+ const normalizeAllAppliedMenuVisibilities = allAppliedMenuVisibilities => {
143
142
  if (!allAppliedMenuVisibilities || allAppliedMenuVisibilities.length === 0) {
144
143
  return null;
145
144
  }
146
145
 
147
- return _reduceInstanceProperty__default["default"](allAppliedMenuVisibilities).call(allAppliedMenuVisibilities, function (transformedAllApplied, allApplied) {
146
+ return _reduceInstanceProperty__default["default"](allAppliedMenuVisibilities).call(allAppliedMenuVisibilities, (transformedAllApplied, allApplied) => {
148
147
  if (!allApplied) return transformedAllApplied;
149
- return _objectSpread$2(_objectSpread$2({}, transformedAllApplied), {}, _defineProperty({}, allApplied.name, allApplied.value));
148
+ return _objectSpread$2(_objectSpread$2({}, transformedAllApplied), {}, {
149
+ [allApplied.name]: allApplied.value
150
+ });
150
151
  }, {});
151
152
  };
152
- var normalizeAllAppliedActionRights = function normalizeAllAppliedActionRights(allAppliedActionRights) {
153
+ const normalizeAllAppliedActionRights = allAppliedActionRights => {
153
154
  if (!allAppliedActionRights || allAppliedActionRights.length === 0) {
154
155
  return null;
155
156
  }
156
157
 
157
- return _reduceInstanceProperty__default["default"](allAppliedActionRights).call(allAppliedActionRights, function (transformedAllApplied, allApplied) {
158
+ return _reduceInstanceProperty__default["default"](allAppliedActionRights).call(allAppliedActionRights, (transformedAllApplied, allApplied) => {
158
159
  if (!allApplied) return transformedAllApplied;
159
- var previousAllAppliedGroup = transformedAllApplied[allApplied.group];
160
- return _objectSpread$2(_objectSpread$2({}, transformedAllApplied), {}, _defineProperty({}, allApplied.group, _objectSpread$2(_objectSpread$2({}, previousAllAppliedGroup), {}, _defineProperty({}, allApplied.name, allApplied.value))));
160
+ const previousAllAppliedGroup = transformedAllApplied[allApplied.group];
161
+ return _objectSpread$2(_objectSpread$2({}, transformedAllApplied), {}, {
162
+ [allApplied.group]: _objectSpread$2(_objectSpread$2({}, previousAllAppliedGroup), {}, {
163
+ [allApplied.name]: allApplied.value
164
+ })
165
+ });
161
166
  }, {});
162
167
  };
163
168
 
164
- var normalizeAppliedDataFencesForStoresByResourceType = function normalizeAppliedDataFencesForStoresByResourceType(dataFences) {
165
- var _context2;
166
-
167
- var groupedByResourceType = _reduceInstanceProperty__default["default"](dataFences).call(dataFences, function (previousGroupsOfSameType, appliedDataFence) {
168
- var _context;
169
+ const normalizeAppliedDataFencesForStoresByResourceType = dataFences => {
170
+ var _context;
169
171
 
172
+ const groupedByResourceType = _reduceInstanceProperty__default["default"](dataFences).call(dataFences, (previousGroupsOfSameType, appliedDataFence) => {
170
173
  if (!appliedDataFence) return previousGroupsOfSameType;
171
- var previousGroup = previousGroupsOfSameType[appliedDataFence.group];
172
- return _objectSpread$2(_objectSpread$2({}, previousGroupsOfSameType), {}, _defineProperty({}, appliedDataFence.group, _concatInstanceProperty__default["default"](_context = []).call(_context, _toConsumableArray(previousGroup || []), [appliedDataFence])));
174
+ const previousGroup = previousGroupsOfSameType[appliedDataFence.group];
175
+ return _objectSpread$2(_objectSpread$2({}, previousGroupsOfSameType), {}, {
176
+ [appliedDataFence.group]: [...(previousGroup || []), appliedDataFence]
177
+ });
173
178
  }, {});
174
179
 
175
- return _reduceInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](groupedByResourceType)).call(_context2, function (previousGroupedByResourceType, _ref) {
176
- var _ref2 = _slicedToArray(_ref, 2),
180
+ return _reduceInstanceProperty__default["default"](_context = _Object$entries__default["default"](groupedByResourceType)).call(_context, (previousGroupedByResourceType, _ref) => {
181
+ let _ref2 = _slicedToArray(_ref, 2),
177
182
  resourceType = _ref2[0],
178
183
  dataFences = _ref2[1];
179
184
 
180
- var groupByDataFenceName = _reduceInstanceProperty__default["default"](dataFences).call(dataFences, function (nextDataFenceValues, dataFence) {
181
- var _context3;
182
-
183
- var dataFenceByName = nextDataFenceValues[dataFence.name] || {
185
+ const groupByDataFenceName = _reduceInstanceProperty__default["default"](dataFences).call(dataFences, (nextDataFenceValues, dataFence) => {
186
+ const dataFenceByName = nextDataFenceValues[dataFence.name] || {
184
187
  values: []
185
188
  };
186
- return _objectSpread$2(_objectSpread$2({}, nextDataFenceValues), {}, _defineProperty({}, dataFence.name, _objectSpread$2(_objectSpread$2({}, dataFenceByName), {}, {
187
- values: _concatInstanceProperty__default["default"](_context3 = []).call(_context3, _toConsumableArray(_valuesInstanceProperty__default["default"](dataFenceByName)), [dataFence.value])
188
- })));
189
+ return _objectSpread$2(_objectSpread$2({}, nextDataFenceValues), {}, {
190
+ [dataFence.name]: _objectSpread$2(_objectSpread$2({}, dataFenceByName), {}, {
191
+ values: [..._valuesInstanceProperty__default["default"](dataFenceByName), dataFence.value]
192
+ })
193
+ });
189
194
  }, {});
190
195
 
191
- return _objectSpread$2(_objectSpread$2({}, previousGroupedByResourceType), {}, _defineProperty({}, resourceType, groupByDataFenceName));
196
+ return _objectSpread$2(_objectSpread$2({}, previousGroupedByResourceType), {}, {
197
+ [resourceType]: groupByDataFenceName
198
+ });
192
199
  }, {});
193
200
  }; // input:
194
201
  // [
@@ -222,20 +229,20 @@ var normalizeAppliedDataFencesForStoresByResourceType = function normalizeApplie
222
229
  // }
223
230
 
224
231
 
225
- var normalizeAllAppliedDataFences = function normalizeAllAppliedDataFences(allAppliedDataFences) {
232
+ const normalizeAllAppliedDataFences = allAppliedDataFences => {
226
233
  if (!allAppliedDataFences || allAppliedDataFences.length === 0) {
227
234
  return null;
228
235
  }
229
236
 
230
- var groupedByType = _reduceInstanceProperty__default["default"](allAppliedDataFences).call(allAppliedDataFences, function (previousGroupsOfSameType, appliedDataFence) {
231
- var _context4;
232
-
237
+ const groupedByType = _reduceInstanceProperty__default["default"](allAppliedDataFences).call(allAppliedDataFences, (previousGroupsOfSameType, appliedDataFence) => {
233
238
  if (!appliedDataFence) return previousGroupsOfSameType;
234
- var previousGroup = previousGroupsOfSameType[appliedDataFence.type];
235
- return _objectSpread$2(_objectSpread$2({}, previousGroupsOfSameType), {}, _defineProperty({}, appliedDataFence.type, _concatInstanceProperty__default["default"](_context4 = []).call(_context4, _toConsumableArray(previousGroup || []), [appliedDataFence])));
239
+ const previousGroup = previousGroupsOfSameType[appliedDataFence.type];
240
+ return _objectSpread$2(_objectSpread$2({}, previousGroupsOfSameType), {}, {
241
+ [appliedDataFence.type]: [...(previousGroup || []), appliedDataFence]
242
+ });
236
243
  }, {});
237
244
 
238
- var normalizedDataFences = _objectSpread$2({}, 'store' in groupedByType ? {
245
+ const normalizedDataFences = _objectSpread$2({}, 'store' in groupedByType ? {
239
246
  store: normalizeAppliedDataFencesForStoresByResourceType(groupedByType.store)
240
247
  } : {});
241
248
 
@@ -246,13 +253,13 @@ var normalizeAllAppliedDataFences = function normalizeAllAppliedDataFences(allAp
246
253
  function ownKeys$1(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; }
247
254
 
248
255
  function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
249
- var Context$1 = /*#__PURE__*/react.createContext({});
250
- var defaultTimeZone = moment__default["default"].tz.guess() || 'Etc/UTC'; // Expose only certain fields as some of them are only meant to
256
+ const Context$1 = /*#__PURE__*/react.createContext({});
257
+ const defaultTimeZone = moment__default["default"].tz.guess() || 'Etc/UTC'; // Expose only certain fields as some of them are only meant to
251
258
  // be used internally in the AppShell
252
259
 
253
- var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(user) {
260
+ const mapUserToApplicationContextUser = user => {
254
261
  if (!user) return null;
255
- var applicationContextUser = {
262
+ let applicationContextUser = {
256
263
  id: user.id,
257
264
  email: user.email,
258
265
  createdAt: user.createdAt,
@@ -267,7 +274,7 @@ var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(u
267
274
  }; // This property will only be populated when user has logged in using SSO
268
275
 
269
276
  if (user.idTokenUserInfo) {
270
- var additionalClaims = {};
277
+ let additionalClaims = {};
271
278
 
272
279
  try {
273
280
  additionalClaims = JSON.parse(user.idTokenUserInfo.additionalClaims || '{}');
@@ -280,22 +287,20 @@ var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(u
280
287
  }
281
288
 
282
289
  applicationContextUser.idTokenUserInfo = _objectSpread$1(_objectSpread$1({}, user.idTokenUserInfo), {}, {
283
- additionalClaims: additionalClaims
290
+ additionalClaims
284
291
  });
285
292
  }
286
293
 
287
294
  return applicationContextUser;
288
295
  }; // Adjust certain fields which depend e.g. on the origin
289
296
 
290
- var mapEnvironmentToApplicationContextEnvironment = function mapEnvironmentToApplicationContextEnvironment(environment, origin) {
291
- return _objectSpread$1(_objectSpread$1({}, environment), {}, {
292
- // NOTE: The `mcApiUrl` depends on `servedByProxy`
293
- mcApiUrl: getMcApiUrl(environment, origin)
294
- });
295
- }; // Expose only certain fields as some of them are only meant to
297
+ const mapEnvironmentToApplicationContextEnvironment = (environment, origin) => _objectSpread$1(_objectSpread$1({}, environment), {}, {
298
+ // NOTE: The `mcApiUrl` depends on `servedByProxy`
299
+ mcApiUrl: getMcApiUrl(environment, origin)
300
+ }); // Expose only certain fields as some of them are only meant to
296
301
  // be used internally in the AppShell
297
302
 
298
- var mapProjectToApplicationContextProject = function mapProjectToApplicationContextProject(project) {
303
+ const mapProjectToApplicationContextProject = project => {
299
304
  if (!project) return null;
300
305
  return {
301
306
  key: project.key,
@@ -309,24 +314,20 @@ var mapProjectToApplicationContextProject = function mapProjectToApplicationCont
309
314
  };
310
315
  };
311
316
 
312
- var createApplicationContext = function createApplicationContext(environment, user, project, projectDataLocale) {
313
- return {
314
- environment: mapEnvironmentToApplicationContextEnvironment(environment),
315
- user: mapUserToApplicationContextUser(user),
316
- project: mapProjectToApplicationContextProject(project),
317
- permissions: normalizeAllAppliedPermissions(project === null || project === void 0 ? void 0 : project.allAppliedPermissions),
318
- actionRights: normalizeAllAppliedActionRights(project === null || project === void 0 ? void 0 : project.allAppliedActionRights),
319
- dataFences: normalizeAllAppliedDataFences(project === null || project === void 0 ? void 0 : project.allAppliedDataFences),
320
- dataLocale: projectDataLocale || null
321
- };
322
- };
317
+ const createApplicationContext = (environment, user, project, projectDataLocale) => ({
318
+ environment: mapEnvironmentToApplicationContextEnvironment(environment),
319
+ user: mapUserToApplicationContextUser(user),
320
+ project: mapProjectToApplicationContextProject(project),
321
+ permissions: normalizeAllAppliedPermissions(project === null || project === void 0 ? void 0 : project.allAppliedPermissions),
322
+ actionRights: normalizeAllAppliedActionRights(project === null || project === void 0 ? void 0 : project.allAppliedActionRights),
323
+ dataFences: normalizeAllAppliedDataFences(project === null || project === void 0 ? void 0 : project.allAppliedDataFences),
324
+ dataLocale: projectDataLocale || null
325
+ });
323
326
 
324
- var ApplicationContextProvider = function ApplicationContextProvider(props) {
325
- return jsxRuntime.jsx(Context$1.Provider, {
326
- value: createApplicationContext(props.environment, props.user, props.project, props.projectDataLocale),
327
- children: props.children
328
- });
329
- };
327
+ const ApplicationContextProvider = props => jsxRuntime.jsx(Context$1.Provider, {
328
+ value: createApplicationContext(props.environment, props.user, props.project, props.projectDataLocale),
329
+ children: props.children
330
+ });
330
331
 
331
332
  ApplicationContextProvider.propTypes = process.env.NODE_ENV !== "production" ? {
332
333
  projectDataLocale: _pt__default["default"].string,
@@ -334,18 +335,16 @@ ApplicationContextProvider.propTypes = process.env.NODE_ENV !== "production" ? {
334
335
  } : {};
335
336
  ApplicationContextProvider.displayName = 'ApplicationContextProvider';
336
337
 
337
- var ApplicationContext = function ApplicationContext(props) {
338
- return jsxRuntime.jsx(Context$1.Consumer, {
339
- children: function children(context) {
340
- // Because of the way the ApplicationShell configures the Context.Provider,
341
- // we ensure that, when we read from the context, we always get actual
342
- // context object and not the initial value.
343
- // Therefore, we can safely cast the value to be out `TApplicationContext` type.
344
- var applicationContext = context;
345
- return props.render(applicationContext);
346
- }
347
- });
348
- };
338
+ const ApplicationContext = props => jsxRuntime.jsx(Context$1.Consumer, {
339
+ children: context => {
340
+ // Because of the way the ApplicationShell configures the Context.Provider,
341
+ // we ensure that, when we read from the context, we always get actual
342
+ // context object and not the initial value.
343
+ // Therefore, we can safely cast the value to be out `TApplicationContext` type.
344
+ const applicationContext = context;
345
+ return props.render(applicationContext);
346
+ }
347
+ });
349
348
 
350
349
  ApplicationContext.propTypes = process.env.NODE_ENV !== "production" ? {
351
350
  render: _pt__default["default"].func.isRequired
@@ -353,17 +352,15 @@ ApplicationContext.propTypes = process.env.NODE_ENV !== "production" ? {
353
352
  ApplicationContext.displayName = 'ApplicationContext';
354
353
 
355
354
  function withApplicationContext(mapApplicationContextToProps) {
356
- return function (Component) {
357
- var WrappedComponent = function WrappedComponent(props) {
358
- return jsxRuntime.jsx(ApplicationContext, {
359
- render: function render(applicationContext) {
360
- var mappedProps = mapApplicationContextToProps ? mapApplicationContextToProps(applicationContext) : {
361
- applicationContext: applicationContext
362
- };
363
- return jsxRuntime.jsx(Component, _objectSpread$1(_objectSpread$1({}, props), mappedProps));
364
- }
365
- });
366
- };
355
+ return Component => {
356
+ const WrappedComponent = props => jsxRuntime.jsx(ApplicationContext, {
357
+ render: applicationContext => {
358
+ const mappedProps = mapApplicationContextToProps ? mapApplicationContextToProps(applicationContext) : {
359
+ applicationContext
360
+ };
361
+ return jsxRuntime.jsx(Component, _objectSpread$1(_objectSpread$1({}, props), mappedProps));
362
+ }
363
+ });
367
364
 
368
365
  WrappedComponent.displayName = "withApplicationContext(".concat(getDisplayName(Component), ")");
369
366
  return WrappedComponent;
@@ -375,56 +372,56 @@ function withApplicationContext(mapApplicationContextToProps) {
375
372
  // Then implement the function. Typescript will pick the appropriate signature
376
373
  // based on the function arguments.
377
374
  function useApplicationContextHook(selector) {
378
- var context = react.useContext(Context$1); // Because of the way the ApplicationShell configures the Context.Provider,
375
+ const context = react.useContext(Context$1); // Because of the way the ApplicationShell configures the Context.Provider,
379
376
  // we ensure that, when we read from the context, we always get actual
380
377
  // context object and not the initial value.
381
378
  // Therefore, we can safely cast the value to be out `TApplicationContext` type.
382
379
 
383
- var applicationContext = context;
380
+ const applicationContext = context;
384
381
  return selector ? selector(applicationContext) : applicationContext;
385
382
  } // This is a workaround to trick babel/rollup to correctly export the function.
386
383
  // Most likely the problem arises with the use of overloading.
387
384
  // See related issue: https://github.com/babel/babel/issues/8361
388
385
 
389
386
 
390
- var useApplicationContext = useApplicationContextHook; // Exports
387
+ const useApplicationContext = useApplicationContextHook; // Exports
391
388
 
392
389
  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; }
393
390
 
394
391
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
395
392
  var FetchProjectExtensionImageRegex = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchProjectExtensionImageRegex" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "projectExtension" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "imageRegex" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "thumb" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "FragmentSpread", name: { kind: "Name", value: "ImageRegex" }, directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "small" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "FragmentSpread", name: { kind: "Name", value: "ImageRegex" }, directives: [] }] } }] } }] } }] } }, { kind: "FragmentDefinition", name: { kind: "Name", value: "ImageRegex" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "ImageRegexOptions" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "flag" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "search" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "replace" }, arguments: [], directives: [] }] } }], loc: { start: 0, end: 256, source: { body: "query FetchProjectExtensionImageRegex {\n projectExtension {\n id\n imageRegex {\n thumb {\n ...ImageRegex\n }\n small {\n ...ImageRegex\n }\n }\n }\n}\nfragment ImageRegex on ImageRegexOptions {\n flag\n search\n replace\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
396
393
 
397
- var useWarning = function useWarning(condition, message) {
398
- react.useEffect(function () {
394
+ const useWarning = (condition, message) => {
395
+ react.useEffect(() => {
399
396
  process.env.NODE_ENV !== "production" ? warning__default["default"](condition, message) : void 0; // eslint-disable-next-line react-hooks/exhaustive-deps
400
397
  }, []);
401
398
  };
402
399
 
403
- var Context = /*#__PURE__*/react.createContext({
400
+ const Context = /*#__PURE__*/react.createContext({
404
401
  isLoading: false
405
402
  });
406
403
 
407
- var useProjectExtensionImageRegex = function useProjectExtensionImageRegex() {
408
- var _useContext = react.useContext(Context),
409
- isLoading = _useContext.isLoading,
410
- imageRegex = _useContext.imageRegex;
404
+ const useProjectExtensionImageRegex = () => {
405
+ const _useContext = react.useContext(Context),
406
+ isLoading = _useContext.isLoading,
407
+ imageRegex = _useContext.imageRegex;
411
408
 
412
409
  return {
413
- isLoading: isLoading,
414
- imageRegex: imageRegex
410
+ isLoading,
411
+ imageRegex
415
412
  };
416
413
  };
417
414
 
418
- var ProjectExtensionProviderForImageRegex = function ProjectExtensionProviderForImageRegex(props) {
419
- var _useQuery = react$1.useQuery(FetchProjectExtensionImageRegex, {
415
+ const ProjectExtensionProviderForImageRegex = props => {
416
+ const _useQuery = react$1.useQuery(FetchProjectExtensionImageRegex, {
420
417
  skip: props.skip,
421
418
  onError: sentry.reportErrorToSentry,
422
419
  context: {
423
420
  target: constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
424
421
  }
425
422
  }),
426
- loading = _useQuery.loading,
427
- data = _useQuery.data;
423
+ loading = _useQuery.loading,
424
+ data = _useQuery.data;
428
425
 
429
426
  return jsxRuntime.jsx(Context.Provider, {
430
427
  value: {
@@ -441,12 +438,10 @@ ProjectExtensionProviderForImageRegex.propTypes = process.env.NODE_ENV !== "prod
441
438
  } : {};
442
439
  ProjectExtensionProviderForImageRegex.displayName = 'ProjectExtensionProviderForImageRegex';
443
440
 
444
- var GetProjectExtensionImageRegex = function GetProjectExtensionImageRegex(props) {
441
+ const GetProjectExtensionImageRegex = props => {
445
442
  useWarning(false, "@commercetools-frontend/application-shell-connectors: It is not recommended to use the 'GetProjectExtensionImageRegex' anymore. Please use the 'useProjectExtensionImageRegex' hook instead.");
446
443
  return jsxRuntime.jsx(Context.Consumer, {
447
- children: function children(imageRegexContext) {
448
- return props.render(imageRegexContext);
449
- }
444
+ children: imageRegexContext => props.render(imageRegexContext)
450
445
  });
451
446
  };
452
447
 
@@ -456,15 +451,15 @@ GetProjectExtensionImageRegex.propTypes = process.env.NODE_ENV !== "production"
456
451
  GetProjectExtensionImageRegex.displayName = 'GetProjectExtensionImageRegex';
457
452
 
458
453
  function withProjectExtensionImageRegex() {
459
- var propKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'imageRegexData';
460
- return function (Component) {
461
- var WrappedComponent = function WrappedComponent(props) {
454
+ let propKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'imageRegexData';
455
+ return Component => {
456
+ const WrappedComponent = props => {
462
457
  useWarning(false, "@commercetools-frontend/application-shell-connectors: It is not recommended to use the 'withProjectExtensionImageRegex' high order component anymore. Please use the 'useProjectExtensionImageRegex' hook instead.");
463
- var imageregexContext = useProjectExtensionImageRegex();
458
+ const imageregexContext = useProjectExtensionImageRegex();
464
459
  return jsxRuntime.jsx(GetProjectExtensionImageRegex, {
465
- render: function render() {
466
- return jsxRuntime.jsx(Component, _objectSpread(_objectSpread({}, props), _defineProperty({}, propKey, imageregexContext)));
467
- }
460
+ render: () => jsxRuntime.jsx(Component, _objectSpread(_objectSpread({}, props), {}, {
461
+ [propKey]: imageregexContext
462
+ }))
468
463
  });
469
464
  };
470
465