@commercetools-frontend/application-components 22.8.4 → 22.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/commercetools-frontend-application-components.cjs.dev.js +372 -61
  2. package/dist/commercetools-frontend-application-components.cjs.prod.js +313 -40
  3. package/dist/commercetools-frontend-application-components.esm.js +370 -63
  4. package/dist/declarations/src/components/custom-views/custom-view-loader/custom-view-loader.d.ts +8 -0
  5. package/dist/declarations/src/components/custom-views/custom-view-loader/index.d.ts +1 -0
  6. package/dist/declarations/src/components/custom-views/custom-view-loader/messages.d.ts +7 -0
  7. package/dist/declarations/src/components/custom-views/custom-views-selector/custom-views-selector.d.ts +9 -0
  8. package/dist/declarations/src/components/custom-views/custom-views-selector/index.d.ts +1 -0
  9. package/dist/declarations/src/components/custom-views/custom-views-selector/messages.d.ts +7 -0
  10. package/dist/declarations/src/components/custom-views/custom-views-selector/use-custom-views-connector.d.ts +11 -0
  11. package/dist/declarations/src/components/detail-pages/custom-form-detail-page/custom-form-detail-page.d.ts +1 -0
  12. package/dist/declarations/src/components/detail-pages/form-detail-page/form-detail-page.d.ts +1 -0
  13. package/dist/declarations/src/components/detail-pages/info-detail-page/info-detail-page.d.ts +1 -0
  14. package/dist/declarations/src/components/detail-pages/tabular-detail-page/tabular-detail-page.d.ts +2 -0
  15. package/dist/declarations/src/components/main-pages/custom-form-main-page/custom-form-main-page.d.ts +1 -0
  16. package/dist/declarations/src/components/main-pages/form-main-page/form-main-page.d.ts +1 -0
  17. package/dist/declarations/src/components/main-pages/info-main-page/info-main-page.d.ts +1 -0
  18. package/dist/declarations/src/components/main-pages/tabular-main-page/tabular-main-page.d.ts +2 -0
  19. package/dist/declarations/src/components/modal-pages/custom-form-modal-page/custom-form-modal-page.d.ts +1 -0
  20. package/dist/declarations/src/components/modal-pages/form-modal-page/form-modal-page.d.ts +1 -0
  21. package/dist/declarations/src/components/modal-pages/info-modal-page/info-modal-page.d.ts +1 -0
  22. package/dist/declarations/src/components/modal-pages/internals/modal-page.d.ts +1 -0
  23. package/dist/declarations/src/components/modal-pages/tabular-modal-page/tabular-modal-page.d.ts +2 -0
  24. package/dist/declarations/src/hooks/use-custom-view-locator-selector/index.d.ts +1 -0
  25. package/dist/declarations/src/hooks/use-custom-view-locator-selector/use-custom-view-locator-selector.d.ts +5 -0
  26. package/dist/declarations/src/index.d.ts +2 -0
  27. package/dist/declarations/src/types/generated/settings.d.ts +1832 -0
  28. package/dist/{public-page-layout-971ae258.cjs.dev.js → public-page-layout-890c2dd3.cjs.dev.js} +7 -2
  29. package/dist/{public-page-layout-8cb7e83a.esm.js → public-page-layout-b0606764.esm.js} +7 -2
  30. package/dist/{public-page-layout-c1f12507.cjs.prod.js → public-page-layout-e13f8cb7.cjs.prod.js} +7 -2
  31. package/package.json +12 -7
@@ -35,12 +35,17 @@ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable
35
35
  var omitBy = require('lodash/omitBy');
36
36
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
37
37
  var _setTimeout = require('@babel/runtime-corejs3/core-js-stable/set-timeout');
38
+ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
39
+ var sentry = require('@commercetools-frontend/sentry');
40
+ var Constraints = require('@commercetools-uikit/constraints');
41
+ var actionsGlobal = require('@commercetools-frontend/actions-global');
42
+ var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
38
43
  var FlatButton = require('@commercetools-uikit/flat-button');
39
44
  var IconButton = require('@commercetools-uikit/icon-button');
40
- var Constraints = require('@commercetools-uikit/constraints');
45
+ var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
46
+ var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
41
47
  var PageNotFoundSVG = require('@commercetools-frontend/assets/images/page-not-found.svg');
42
48
  var FailedAuthorizationSVG = require('@commercetools-frontend/assets/images/doors-closed.svg');
43
- var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
44
49
  var useResizeObserver = require('@react-hook/resize-observer');
45
50
  var hooks = require('@commercetools-uikit/hooks');
46
51
 
@@ -66,16 +71,18 @@ var SecondaryButton__default = /*#__PURE__*/_interopDefault(SecondaryButton);
66
71
  var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
67
72
  var omitBy__default = /*#__PURE__*/_interopDefault(omitBy);
68
73
  var _setTimeout__default = /*#__PURE__*/_interopDefault(_setTimeout);
74
+ var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
75
+ var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
69
76
  var FlatButton__default = /*#__PURE__*/_interopDefault(FlatButton);
70
77
  var IconButton__default = /*#__PURE__*/_interopDefault(IconButton);
71
- var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
78
+ var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
79
+ var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
72
80
  var PageNotFoundSVG__default = /*#__PURE__*/_interopDefault(PageNotFoundSVG);
73
81
  var FailedAuthorizationSVG__default = /*#__PURE__*/_interopDefault(FailedAuthorizationSVG);
74
- var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
75
82
  var useResizeObserver__default = /*#__PURE__*/_interopDefault(useResizeObserver);
76
83
 
77
84
  // NOTE: This string will be replaced on build time with the package version.
78
- var version = "22.8.4";
85
+ var version = "22.10.0";
79
86
 
80
87
  var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9;
81
88
  const appKitSpacing55 = '40px';
@@ -145,9 +152,9 @@ var _ref$7 = {
145
152
  } ;
146
153
  const getLinkStyles = (isActive, isDisabled) => [/*#__PURE__*/react.css("font-size:", designSystem.designTokens.fontSizeDefault, ";padding:", designSystem.designTokens.spacingS, " ", designSystem.designTokens.spacingM, ";position:relative;text-align:center;display:inline-block;color:inherit;text-decoration:inherit;&:first-of-type{padding-left:", designTokens.paddingLeftForTabAsFirst, ";}", getBottomBorderStyles('transparent'), ";" + ("" ), "" ), isActive && /*#__PURE__*/react.css(getBottomBorderStyles(designSystem.designTokens.colorPrimary), " & h4{color:", designSystem.designTokens.colorPrimary, "!important;}" + ("" ), "" ), isDisabled && _ref$7, !isActive && !isDisabled && /*#__PURE__*/react.css(":hover,:focus,:active{& h4{color:", designSystem.designTokens.colorPrimary, "!important;}}" + ("" ), "" )];
147
154
 
148
- function ownKeys$6(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; }
149
- function _objectSpread$6(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$6(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$6(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
150
- const pathWithoutSearch = path => typeof path === 'string' ? path.split('?')[0] : path.pathname;
155
+ function ownKeys$7(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; }
156
+ function _objectSpread$7(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$7(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$7(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
157
+ const pathWithoutSearch$1 = path => typeof path === 'string' ? path.split('?')[0] : path.pathname;
151
158
  const warnIfMissingContent = props => {
152
159
  Boolean(props.intlMessage) || Boolean(props.label);
153
160
  };
@@ -168,7 +175,7 @@ const TabHeader = props => {
168
175
  const location = reactRouterDom.useLocation();
169
176
  const isActive = Boolean(reactRouterDom.matchPath(location.pathname, {
170
177
  // strip the search, otherwise the path won't match
171
- path: pathWithoutSearch(props.to),
178
+ path: pathWithoutSearch$1(props.to),
172
179
  exact: props.exactPathMatch,
173
180
  strict: false
174
181
  }));
@@ -178,7 +185,7 @@ const TabHeader = props => {
178
185
  label = intl.formatMessage(props.intlMessage);
179
186
  }
180
187
  warnIfMissingContent(props);
181
- return jsxRuntime.jsx(reactRouterDom.Link, _objectSpread$6(_objectSpread$6({
188
+ return jsxRuntime.jsx(reactRouterDom.Link, _objectSpread$7(_objectSpread$7({
182
189
  role: "tab",
183
190
  "aria-selected": isActive,
184
191
  to: props.to,
@@ -237,13 +244,13 @@ const getModalContentStyles = props => {
237
244
  const getOverlayStyles$1 = props => /*#__PURE__*/react.css("display:flex;position:absolute;z-index:", typeof props.zIndex === 'number' ? // Use `!important` to overwrite the default value assigned by the Stacking Layer System.
238
245
  "".concat(props.zIndex, " !important") : 'auto', ";top:0;width:100%;height:100%;background-color:rgba(32, 62, 72, 0.5);opacity:1;" + ("" ), "" );
239
246
 
240
- function ownKeys$5(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; }
241
- function _objectSpread$5(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$5(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$5(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
247
+ function ownKeys$6(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; }
248
+ function _objectSpread$6(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$6(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$6(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
242
249
  const getDefaultParentSelector$1 = () => document.querySelector("#".concat(constants.PORTALS_CONTAINER_ID));
243
250
  const getOverlayElement$1 = (props, contentElement) =>
244
251
  // Assign the `data-role` to the overlay container, which is used as
245
252
  // the CSS selector in the `<PortalsContainer>`.
246
- jsxRuntime.jsx("div", _objectSpread$5(_objectSpread$5({}, props), {}, {
253
+ jsxRuntime.jsx("div", _objectSpread$6(_objectSpread$6({}, props), {}, {
247
254
  "data-role": "dialog-overlay",
248
255
  children: contentElement
249
256
  }));
@@ -371,8 +378,8 @@ function filterDataAttributes(obj) {
371
378
  return omitBy__default["default"](obj, (_value, key) => !_startsWithInstanceProperty__default["default"](key).call(key, 'data-'));
372
379
  }
373
380
 
374
- 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; }
375
- 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; }
381
+ function ownKeys$5(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; }
382
+ function _objectSpread$5(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$5(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$5(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
376
383
  const defaultProps$g = {
377
384
  isPrimaryButtonDisabled: false,
378
385
  dataAttributesPrimaryButton: {},
@@ -387,11 +394,11 @@ const DialogFooter = props => {
387
394
  scale: "m",
388
395
  alignItems: "center",
389
396
  justifyContent: "flex-end",
390
- children: [jsxRuntime.jsx(SecondaryButton__default["default"], _objectSpread$4({
397
+ children: [jsxRuntime.jsx(SecondaryButton__default["default"], _objectSpread$5({
391
398
  label: getFormattedLabel(props.labelSecondary, intl),
392
399
  onClick: props.onCancel,
393
400
  iconLeft: props.iconLeftSecondaryButton
394
- }, filterDataAttributes(props.dataAttributesSecondaryButton))), jsxRuntime.jsx(PrimaryButton__default["default"], _objectSpread$4({
401
+ }, filterDataAttributes(props.dataAttributesSecondaryButton))), jsxRuntime.jsx(PrimaryButton__default["default"], _objectSpread$5({
395
402
  label: getFormattedLabel(props.labelPrimary, intl),
396
403
  onClick: props.onConfirm,
397
404
  isDisabled: props.isPrimaryButtonDisabled
@@ -560,6 +567,243 @@ const PageWrapper = /*#__PURE__*/_styled__default["default"]("div", {
560
567
  styles: "height:100%;display:flex;flex-direction:column"
561
568
  } );
562
569
 
570
+ const ContentWrapper = /*#__PURE__*/_styled__default["default"]("div", {
571
+ target: "e1alzj9m0"
572
+ } )("height:100%;padding:", designSystem.designTokens.spacing40, " 40px;" + ("" ));
573
+ function CustomPanel(props) {
574
+ return jsxRuntime.jsx(ModalPage, {
575
+ hidePathLabel: true,
576
+ isOpen: true,
577
+ onClose: props.onClose,
578
+ size: props.size,
579
+ title: props.title,
580
+ children: jsxRuntime.jsx(ContentWrapper, {
581
+ children: props.children
582
+ })
583
+ });
584
+ }
585
+ CustomPanel.propTypes = {};
586
+
587
+ const messages$4 = reactIntl.defineMessages({
588
+ loadError: {
589
+ id: 'CustomViewLoader.error.load',
590
+ defaultMessage: 'We could not load the Custom View. Please contact your administrator to check its configuration.'
591
+ }
592
+ });
593
+
594
+ const isIframeReady = iFrameElementRef => {
595
+ try {
596
+ var _iFrameElementRef$con;
597
+ return (iFrameElementRef === null || iFrameElementRef === void 0 || (_iFrameElementRef$con = iFrameElementRef.contentWindow) === null || _iFrameElementRef$con === void 0 ? void 0 : _iFrameElementRef$con.document.readyState) === 'complete';
598
+ } catch {
599
+ // Trying to access the contentWindow of a cross-origin iFrame will throw an error.
600
+ // We are not supposed to even get here because the iFrame must use
601
+ // a URL from our very same domain (the custom view is proxied through our http-proxy service).
602
+ return false;
603
+ }
604
+ };
605
+ const CustomPanelIframe = /*#__PURE__*/_styled__default["default"]("iframe", {
606
+ target: "ewwxuwo0"
607
+ } )({
608
+ name: "174lt7a",
609
+ styles: "height:100%;width:100%;border:none"
610
+ } );
611
+ function CustomViewLoader(props) {
612
+ var _props$customView$typ;
613
+ const iFrameElementRef = react$1.useRef(null);
614
+ const dataLocale = applicationShellConnectors.useApplicationContext(context => context.dataLocale);
615
+ const projectKey = applicationShellConnectors.useApplicationContext(context => {
616
+ var _context$project;
617
+ return (_context$project = context.project) === null || _context$project === void 0 ? void 0 : _context$project.key;
618
+ });
619
+ const iFrameCommunicationChannel = react$1.useRef(new MessageChannel());
620
+ const showNotification = actionsGlobal.useShowNotification();
621
+ const intl = reactIntl.useIntl();
622
+ const messageFromIFrameHandler = react$1.useCallback(event => {
623
+ if (event.data.origin === window.location.origin) {
624
+ console.log('message received from iframe port: ', event);
625
+ }
626
+ }, []);
627
+
628
+ // onLoad handler is called from the iFrame even where the URL is not valid
629
+ // (blocked by CORS, 404, etc.) so we need to make sure the iFrame is ready
630
+ const onLoadSuccessHandler = react$1.useCallback(() => {
631
+ var _iFrameElementRef$cur, _context;
632
+ // Show error and block if the iFrame is not ready
633
+ // (error loading it)
634
+ if (!isIframeReady(iFrameElementRef.current)) {
635
+ showNotification({
636
+ domain: constants.DOMAINS.PAGE,
637
+ kind: constants.NOTIFICATION_KINDS_PAGE.error,
638
+ text: intl.formatMessage(messages$4.loadError)
639
+ });
640
+ return;
641
+ }
642
+
643
+ // Listen for messages from the iFrame
644
+ iFrameCommunicationChannel.current.port1.onmessage = messageFromIFrameHandler;
645
+
646
+ // Transfer port2 to the iFrame so it can send messages back privately
647
+ (_iFrameElementRef$cur = iFrameElementRef.current) === null || _iFrameElementRef$cur === void 0 || (_iFrameElementRef$cur = _iFrameElementRef$cur.contentWindow) === null || _iFrameElementRef$cur === void 0 || _iFrameElementRef$cur.postMessage(constants.CUSTOM_VIEWS_EVENTS_NAMES.CUSTOM_VIEW_BOOTSTRAP, window.location.href, [iFrameCommunicationChannel.current.port2]);
648
+
649
+ // Send the initialization message to the iFrame
650
+ iFrameCommunicationChannel.current.port1.postMessage({
651
+ source: constants.CUSTOM_VIEWS_EVENTS_META.SOURCE,
652
+ destination: _concatInstanceProperty__default["default"](_context = "".concat(constants.CUSTOM_VIEWS_EVENTS_META.DESTINATION_PREFIX)).call(_context, props.customView.id),
653
+ eventName: constants.CUSTOM_VIEWS_EVENTS_NAMES.CUSTOM_VIEW_INITIALIZATION,
654
+ eventData: {
655
+ context: {
656
+ dataLocale,
657
+ projectKey,
658
+ customViewConfig: props.customView,
659
+ hostUrl: props.hostUrl || window.location.href
660
+ }
661
+ }
662
+ });
663
+
664
+ // We want the effect to run only once so we don't need the dependencies array.
665
+ // eslint-disable-next-line react-hooks/exhaustive-deps
666
+ }, []);
667
+ react$1.useEffect(() => {
668
+ // Close the channel when the component unmounts
669
+ const communicationChannel = iFrameCommunicationChannel.current;
670
+ return () => {
671
+ communicationChannel === null || communicationChannel === void 0 || communicationChannel.port1.close();
672
+ };
673
+ }, []);
674
+
675
+ // Currently we only support custom panels
676
+ if (props.customView.type !== 'CustomPanel') {
677
+ sentry.reportErrorToSentry(new Error("CustomViewLoader: Provided Custom View has an unsupported type: ".concat(props.customView.type, ". Supported types: ['CustomPanel'].")));
678
+ return null;
679
+ }
680
+ const panelSize = ((_props$customView$typ = props.customView.typeSettings) === null || _props$customView$typ === void 0 || (_props$customView$typ = _props$customView$typ.size) === null || _props$customView$typ === void 0 ? void 0 : _props$customView$typ.toLocaleLowerCase()) || 'large';
681
+ const iFrameUrl = [window.location.origin, 'custom-views', props.customView.id, 'projects', projectKey].join('/');
682
+ return jsxRuntime.jsx(CustomPanel, {
683
+ title: "Custom View: ".concat(props.customView.defaultLabel),
684
+ onClose: props.onClose,
685
+ size: panelSize,
686
+ children: jsxRuntime.jsx(CustomPanelIframe, {
687
+ id: "custom-view-".concat(props.customView.id),
688
+ title: "Custom View: ".concat(props.customView.defaultLabel),
689
+ ref: iFrameElementRef,
690
+ src: iFrameUrl,
691
+ onLoad: onLoadSuccessHandler
692
+ }, "custom-view-".concat(props.customView.id))
693
+ });
694
+ }
695
+ CustomViewLoader.propTypes = {};
696
+
697
+ var messages$3 = reactIntl.defineMessages({
698
+ title: {
699
+ id: 'CustomViewsSelector.title',
700
+ defaultMessage: 'Custom Views:'
701
+ }
702
+ });
703
+
704
+ var FetchCustomViewsQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchCustomViewsByLocator" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "customViewLocatorCode" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "allCustomViewsInstallationsByLocator" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "locator" }, value: { kind: "Variable", name: { kind: "Name", value: "customViewLocatorCode" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "customView" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "defaultLabel" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "url" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "typeSettings" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "size" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "locators" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "oAuthScopes" }, arguments: [], directives: [] }] } }] } }] } }] } }], loc: { start: 0, end: 405, source: { body: "query FetchCustomViewsByLocator($customViewLocatorCode: String!) {\n allCustomViewsInstallationsByLocator(locator: $customViewLocatorCode) {\n id\n customView {\n id\n defaultLabel\n labelAllLocales {\n locale\n value\n }\n url\n type\n typeSettings {\n size\n }\n locators\n permissions {\n name\n oAuthScopes\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
705
+ const useCustomViewsConnector = _ref => {
706
+ var _data$allCustomViewsI;
707
+ let customViewLocatorCode = _ref.customViewLocatorCode;
708
+ const _useMcQuery = applicationShellConnectors.useMcQuery(FetchCustomViewsQuery, {
709
+ variables: {
710
+ customViewLocatorCode
711
+ },
712
+ context: {
713
+ target: constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
714
+ }
715
+ }),
716
+ data = _useMcQuery.data,
717
+ error = _useMcQuery.error,
718
+ loading = _useMcQuery.loading;
719
+ return {
720
+ customViews: (data === null || data === void 0 || (_data$allCustomViewsI = data.allCustomViewsInstallationsByLocator) === null || _data$allCustomViewsI === void 0 ? void 0 : _mapInstanceProperty__default["default"](_data$allCustomViewsI).call(_data$allCustomViewsI, installation => installation.customView)) || [],
721
+ error,
722
+ loading
723
+ };
724
+ };
725
+
726
+ 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; }
727
+ 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; }
728
+ const COMPONENT_HEIGHT = '56px';
729
+ const Wrapper = /*#__PURE__*/_styled__default["default"]("div", {
730
+ target: "e16cb3zv1"
731
+ } )("height:", props => props.shouldRender ? COMPONENT_HEIGHT : '0', ";overflow:hidden;transition:height 0.3s ease-in-out;" + ("" ));
732
+ const Container$2 = /*#__PURE__*/_styled__default["default"]("div", {
733
+ target: "e16cb3zv0"
734
+ } )("background-color:", designSystem.designTokens.colorAccent98, ";padding:", designSystem.designTokens.spacing25, " ", designSystem.designTokens.spacing60, ";" + ("" ));
735
+ function CustomViewSelector(props) {
736
+ const _useState = react$1.useState(null),
737
+ _useState2 = _slicedToArray(_useState, 2),
738
+ selectedCustomView = _useState2[0],
739
+ setSelectedCustomView = _useState2[1];
740
+ const _useCustomViewsConnec = useCustomViewsConnector({
741
+ customViewLocatorCode: props.customViewLocatorCode
742
+ }),
743
+ customViews = _useCustomViewsConnec.customViews,
744
+ error = _useCustomViewsConnec.error,
745
+ loading = _useCustomViewsConnec.loading;
746
+ const onCustomViewsResolved = props.onCustomViewsResolved;
747
+ react$1.useEffect(() => {
748
+ if (!loading && !error && onCustomViewsResolved) {
749
+ onCustomViewsResolved(customViews);
750
+ }
751
+ }, [customViews, error, loading, onCustomViewsResolved]);
752
+ if (error) {
753
+ sentry.reportErrorToSentry(error, {
754
+ extra: {
755
+ customViewLocatorCode: props.customViewLocatorCode
756
+ }
757
+ });
758
+ return null;
759
+ }
760
+ return jsxRuntime.jsx(Wrapper, {
761
+ shouldRender: customViews.length > 0,
762
+ children: jsxRuntime.jsx(Container$2, {
763
+ children: jsxRuntime.jsxs(Constraints__default["default"].Horizontal, {
764
+ max: "scale",
765
+ children: [jsxRuntime.jsxs(Spacings__default["default"].Inline, {
766
+ scale: "m",
767
+ justifyContent: "flex-end",
768
+ alignItems: "center",
769
+ children: [jsxRuntime.jsxs(Spacings__default["default"].Inline, {
770
+ scale: "xs",
771
+ alignItems: "center",
772
+ children: [jsxRuntime.jsx(icons.SidebarCollapseIcon, {
773
+ size: "medium",
774
+ color: "neutral60"
775
+ }), jsxRuntime.jsx(Text__default["default"].Detail, {
776
+ tone: "secondary",
777
+ intlMessage: messages$3.title
778
+ })]
779
+ }), _mapInstanceProperty__default["default"](customViews).call(customViews, customView => jsxRuntime.jsx(SecondaryButton__default["default"], {
780
+ label: customView.defaultLabel,
781
+ size: "medium",
782
+ onClick: () => {
783
+ setSelectedCustomView(customView);
784
+ }
785
+ }, customView.id))]
786
+ }), selectedCustomView && jsxRuntime.jsx(CustomViewLoader, {
787
+ customView: selectedCustomView,
788
+ onClose: () => {
789
+ setSelectedCustomView(null);
790
+ }
791
+ })]
792
+ })
793
+ })
794
+ });
795
+ }
796
+ CustomViewSelector.propTypes = {};
797
+ const CustomViewSelectorOrNothing = props => {
798
+ if (!props.customViewLocatorCode) {
799
+ return null;
800
+ }
801
+ return jsxRuntime.jsx(CustomViewSelector, _objectSpread$4(_objectSpread$4({}, props), {}, {
802
+ customViewLocatorCode: props.customViewLocatorCode
803
+ }));
804
+ };
805
+ CustomViewSelectorOrNothing.propTypes = {};
806
+
563
807
  const messages$2 = reactIntl.defineMessages({
564
808
  back: {
565
809
  id: 'Components.ModalPage.TopBar.Back',
@@ -739,7 +983,9 @@ const ModalPage = props => {
739
983
  zIndex: props.zIndex
740
984
  }
741
985
  },
742
- children: [jsxRuntime.jsx(ModalPageTopBar, {
986
+ children: [jsxRuntime.jsx(CustomViewSelectorOrNothing, {
987
+ customViewLocatorCode: props.customViewLocatorCode
988
+ }), jsxRuntime.jsx(ModalPageTopBar, {
743
989
  color: props.topBarColor,
744
990
  onClose: handleClose,
745
991
  currentPathLabel: props.currentPathLabel,
@@ -764,6 +1010,7 @@ const InfoModalPage = props => jsxRuntime.jsxs(ModalPage, {
764
1010
  shouldDelayOnClose: props.shouldDelayOnClose,
765
1011
  getParentSelector: props.getParentSelector,
766
1012
  afterOpenStyles: props.afterOpenStyles,
1013
+ customViewLocatorCode: props.customViewLocatorCode,
767
1014
  children: [jsxRuntime.jsx(PageHeader, {
768
1015
  title: props.title,
769
1016
  subtitle: props.subtitle
@@ -841,6 +1088,7 @@ const CustomFormModalPage = props => jsxRuntime.jsxs(ModalPage, {
841
1088
  getParentSelector: props.getParentSelector,
842
1089
  shouldDelayOnClose: props.shouldDelayOnClose,
843
1090
  afterOpenStyles: props.afterOpenStyles,
1091
+ customViewLocatorCode: props.customViewLocatorCode,
844
1092
  children: [jsxRuntime.jsx(PageHeader, {
845
1093
  title: props.title,
846
1094
  subtitle: props.subtitle,
@@ -892,6 +1140,7 @@ const FormModalPage = props => jsxRuntime.jsx(CustomFormModalPage, {
892
1140
  dataAttributes: props.dataAttributesPrimaryButton
893
1141
  })]
894
1142
  }),
1143
+ customViewLocatorCode: props.customViewLocatorCode,
895
1144
  children: props.children
896
1145
  });
897
1146
  FormModalPage.propTypes = {};
@@ -901,6 +1150,26 @@ FormModalPage.defaultProps = defaultProps$a;
901
1150
  // The Intl messages can be used for button labels.
902
1151
  FormModalPage.Intl = i18n.sharedMessages;
903
1152
 
1153
+ const pathWithoutSearch = path => typeof path === 'string' ? path.split('?')[0] : path.pathname;
1154
+ const useCustomViewLocatorSelector = function () {
1155
+ var _context;
1156
+ let customViewLocatorCodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1157
+ const location = reactRouterDom.useLocation();
1158
+ const customViewLocator = _findInstanceProperty__default["default"](_context = _Object$entries__default["default"](customViewLocatorCodes)).call(_context, _ref => {
1159
+ let _ref2 = _slicedToArray(_ref, 2),
1160
+ locator = _ref2[1];
1161
+ return reactRouterDom.matchPath(location.pathname, {
1162
+ // strip the search, otherwise the path won't match
1163
+ path: pathWithoutSearch(locator),
1164
+ exact: false,
1165
+ strict: false
1166
+ });
1167
+ });
1168
+ return {
1169
+ currentCustomViewLocatorCode: customViewLocator === null || customViewLocator === void 0 ? void 0 : customViewLocator[0]
1170
+ };
1171
+ };
1172
+
904
1173
  const TabControls = /*#__PURE__*/_styled__default["default"]("div", {
905
1174
  target: "elpldre1"
906
1175
  } )("margin-top:", designSystem.designTokens.spacingS, ";" + ("" ));
@@ -931,6 +1200,8 @@ const defaultProps$8 = {
931
1200
  hideControls: false
932
1201
  };
933
1202
  const TabularModalPage = props => {
1203
+ const _useCustomViewLocator = useCustomViewLocatorSelector(props.customViewLocatorCodes),
1204
+ currentCustomViewLocatorCode = _useCustomViewLocator.currentCustomViewLocatorCode;
934
1205
  return jsxRuntime.jsxs(ModalPage, {
935
1206
  title: props.title,
936
1207
  isOpen: props.isOpen,
@@ -942,6 +1213,7 @@ const TabularModalPage = props => {
942
1213
  getParentSelector: props.getParentSelector,
943
1214
  shouldDelayOnClose: props.shouldDelayOnClose,
944
1215
  afterOpenStyles: props.afterOpenStyles,
1216
+ customViewLocatorCode: currentCustomViewLocatorCode,
945
1217
  children: [jsxRuntime.jsxs(TabularPageContainer, {
946
1218
  color: "neutral",
947
1219
  children: [props.customTitleRow || jsxRuntime.jsx(PageHeaderTitle, {
@@ -1014,7 +1286,9 @@ const defaultProps$6 = {
1014
1286
  const CustomFormDetailPage = props => {
1015
1287
  var _props$title;
1016
1288
  return jsxRuntime.jsxs(PageWrapper, {
1017
- children: [jsxRuntime.jsxs(DetailPageContainer, {
1289
+ children: [jsxRuntime.jsx(CustomViewSelectorOrNothing, {
1290
+ customViewLocatorCode: props.customViewLocatorCode
1291
+ }), jsxRuntime.jsxs(DetailPageContainer, {
1018
1292
  children: [jsxRuntime.jsx(PageTopBar, {
1019
1293
  color: "neutral",
1020
1294
  previousPathLabel: props.previousPathLabel,
@@ -1056,6 +1330,7 @@ const FormDetailPage = props => jsxRuntime.jsx(CustomFormDetailPage, {
1056
1330
  title: props.title,
1057
1331
  subtitle: props.subtitle,
1058
1332
  customTitleRow: props.customTitleRow,
1333
+ customViewLocatorCode: props.customViewLocatorCode,
1059
1334
  previousPathLabel: props.previousPathLabel,
1060
1335
  onPreviousPathClick: props.onPreviousPathClick,
1061
1336
  hideControls: props.hideControls,
@@ -1092,6 +1367,7 @@ const InfoDetailPage = props => jsxRuntime.jsx(CustomFormDetailPage, {
1092
1367
  subtitle: props.subtitle,
1093
1368
  customTitleRow: props.customTitleRow,
1094
1369
  previousPathLabel: props.previousPathLabel,
1370
+ customViewLocatorCode: props.customViewLocatorCode,
1095
1371
  onPreviousPathClick: props.onPreviousPathClick,
1096
1372
  children: props.children
1097
1373
  });
@@ -1106,8 +1382,12 @@ const defaultProps$4 = {
1106
1382
  };
1107
1383
  const TabularDetailPage = props => {
1108
1384
  var _props$title;
1385
+ const _useCustomViewLocator = useCustomViewLocatorSelector(props.customViewLocatorCodes),
1386
+ currentCustomViewLocatorCode = _useCustomViewLocator.currentCustomViewLocatorCode;
1109
1387
  return jsxRuntime.jsxs(PageWrapper, {
1110
- children: [jsxRuntime.jsxs(TabularPageContainer, {
1388
+ children: [jsxRuntime.jsx(CustomViewSelectorOrNothing, {
1389
+ customViewLocatorCode: currentCustomViewLocatorCode
1390
+ }), jsxRuntime.jsxs(TabularPageContainer, {
1111
1391
  color: "neutral",
1112
1392
  children: [jsxRuntime.jsx(PageTopBar, {
1113
1393
  color: "neutral",
@@ -1145,7 +1425,7 @@ TabularDetailPage.PageHeaderTitle = PageHeaderTitle;
1145
1425
  // This is a convenience proxy export to expose pre-defined Intl messages defined in the `@commercetools-frontend/i18n` package.
1146
1426
  TabularDetailPage.Intl = i18n.sharedMessages;
1147
1427
 
1148
- const PublicPageLayout = /*#__PURE__*/react$1.lazy(() => Promise.resolve().then(function () { return require('./public-page-layout-c1f12507.cjs.prod.js' /* webpackChunkName: "public-page-layout" */); }));
1428
+ const PublicPageLayout = /*#__PURE__*/react$1.lazy(() => Promise.resolve().then(function () { return require('./public-page-layout-e13f8cb7.cjs.prod.js' /* webpackChunkName: "public-page-layout" */); }));
1149
1429
 
1150
1430
  const MainPageContainer = /*#__PURE__*/_styled__default["default"]("div", {
1151
1431
  target: "ev8m2jf2"
@@ -1164,7 +1444,9 @@ const defaultProps$3 = {
1164
1444
  const CustomFormMainPage = props => {
1165
1445
  var _props$title;
1166
1446
  return jsxRuntime.jsxs(PageWrapper, {
1167
- children: [jsxRuntime.jsx(MainPageContainer, {
1447
+ children: [jsxRuntime.jsx(CustomViewSelectorOrNothing, {
1448
+ customViewLocatorCode: props.customViewLocatorCode
1449
+ }), jsxRuntime.jsx(MainPageContainer, {
1168
1450
  children: jsxRuntime.jsxs(Spacings__default["default"].Stack, {
1169
1451
  scale: "l",
1170
1452
  children: [props.customTitleRow || jsxRuntime.jsx(PageHeaderTitle, {
@@ -1207,6 +1489,7 @@ const FormMainPage = props => {
1207
1489
  title: props.title,
1208
1490
  subtitle: props.subtitle,
1209
1491
  customTitleRow: props.customTitleRow,
1492
+ customViewLocatorCode: props.customViewLocatorCode,
1210
1493
  hideControls: props.hideControls,
1211
1494
  formControls: jsxRuntime.jsxs(jsxRuntime.Fragment, {
1212
1495
  children: [jsxRuntime.jsx(CustomFormMainPage.FormSecondaryButton, {
@@ -1242,6 +1525,7 @@ const InfoMainPage = props => {
1242
1525
  title: props.title,
1243
1526
  subtitle: props.subtitle,
1244
1527
  customTitleRow: props.customTitleRow,
1528
+ customViewLocatorCode: props.customViewLocatorCode,
1245
1529
  hideDivider: true,
1246
1530
  children: props.children
1247
1531
  });
@@ -1257,8 +1541,12 @@ const defaultProps$1 = {
1257
1541
  };
1258
1542
  const TabularMainPage = props => {
1259
1543
  var _props$title;
1544
+ const _useCustomViewLocator = useCustomViewLocatorSelector(props.customViewLocatorCodes),
1545
+ currentCustomViewLocatorCode = _useCustomViewLocator.currentCustomViewLocatorCode;
1260
1546
  return jsxRuntime.jsxs(PageWrapper, {
1261
- children: [jsxRuntime.jsxs(TabularPageContainer, {
1547
+ children: [jsxRuntime.jsx(CustomViewSelectorOrNothing, {
1548
+ customViewLocatorCode: currentCustomViewLocatorCode
1549
+ }), jsxRuntime.jsxs(TabularPageContainer, {
1262
1550
  color: "surface",
1263
1551
  children: [props.customTitleRow || jsxRuntime.jsx(PageHeaderTitle, {
1264
1552
  title: (_props$title = props.title) !== null && _props$title !== void 0 ? _props$title : '',
@@ -1509,23 +1797,6 @@ function PageContentFull(props) {
1509
1797
  }
1510
1798
  PageContentFull.propTypes = {};
1511
1799
 
1512
- const ContentWrapper = /*#__PURE__*/_styled__default["default"]("div", {
1513
- target: "e1alzj9m0"
1514
- } )("height:100%;padding:", designSystem.designTokens.spacing40, " 40px;" + ("" ));
1515
- function CustomPanel(props) {
1516
- return jsxRuntime.jsx(ModalPage, {
1517
- hidePathLabel: true,
1518
- isOpen: true,
1519
- onClose: props.onClose,
1520
- size: props.size,
1521
- title: props.title,
1522
- children: jsxRuntime.jsx(ContentWrapper, {
1523
- children: props.children
1524
- })
1525
- });
1526
- }
1527
- CustomPanel.propTypes = {};
1528
-
1529
1800
  // The width of each indentation level.
1530
1801
  const indentationSize = '48px';
1531
1802
  const useObserverElementDimensions = element => {
@@ -1645,6 +1916,8 @@ exports.CustomFormDetailPage = CustomFormDetailPage;
1645
1916
  exports.CustomFormMainPage = CustomFormMainPage;
1646
1917
  exports.CustomFormModalPage = CustomFormModalPage;
1647
1918
  exports.CustomPanel = CustomPanel;
1919
+ exports.CustomViewLoader = CustomViewLoader;
1920
+ exports.CustomViewsSelector = CustomViewSelectorOrNothing;
1648
1921
  exports.FormDetailPage = FormDetailPage;
1649
1922
  exports.FormDialog = FormDialog;
1650
1923
  exports.FormMainPage = FormMainPage;