@shopgate/pwa-common 7.30.0-alpha.9 → 7.30.0-beta.2

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 (106) hide show
  1. package/App.js +28 -13
  2. package/actions/app/handleUniversalLink.js +0 -2
  3. package/collections/AuthRoutes.js +15 -13
  4. package/collections/Configuration.js +11 -10
  5. package/collections/EmbeddedMedia.js +21 -19
  6. package/collections/PersistedReducers.js +11 -9
  7. package/collections/Redirects.js +15 -13
  8. package/collections/media-providers/MediaProvider.js +23 -21
  9. package/collections/media-providers/Vimeo.js +28 -22
  10. package/collections/media-providers/YouTube.js +17 -10
  11. package/components/Backdrop/index.js +15 -13
  12. package/components/Backdrop/spec.js +3 -2
  13. package/components/Button/index.js +41 -29
  14. package/components/Button/spec.js +16 -10
  15. package/components/Checkbox/index.js +36 -28
  16. package/components/Checkbox/spec.js +40 -27
  17. package/components/Consume/index.js +4 -1
  18. package/components/CountdownTimer/index.js +27 -20
  19. package/components/CountdownTimer/spec.js +2 -1
  20. package/components/Drawer/index.js +31 -23
  21. package/components/Drawer/spec.js +7 -6
  22. package/components/Dropdown/index.js +27 -18
  23. package/components/Ellipsis/index.js +5 -3
  24. package/components/Ellipsis/spec.js +5 -3
  25. package/components/EmbeddedMedia/index.js +9 -6
  26. package/components/EmbeddedMedia/spec.js +11 -2
  27. package/components/ErrorBoundary/index.js +26 -16
  28. package/components/Grid/components/Item/index.js +13 -6
  29. package/components/Grid/components/Item/spec.js +4 -3
  30. package/components/Grid/index.js +13 -6
  31. package/components/Grid/spec.js +4 -3
  32. package/components/HtmlSanitizer/index.js +42 -45
  33. package/components/HtmlSanitizer/spec.js +16 -12
  34. package/components/I18n/components/FormatDate/index.js +11 -4
  35. package/components/I18n/components/FormatDate/spec.js +22 -14
  36. package/components/I18n/components/FormatNumber/index.js +8 -6
  37. package/components/I18n/components/FormatNumber/spec.js +10 -5
  38. package/components/I18n/components/FormatPrice/index.js +5 -3
  39. package/components/I18n/components/FormatPrice/spec.js +22 -14
  40. package/components/I18n/components/FormatTime/index.js +11 -4
  41. package/components/I18n/components/FormatTime/spec.js +22 -14
  42. package/components/I18n/components/I18nProvider/index.js +18 -11
  43. package/components/I18n/components/I18nProvider/spec.js +2 -1
  44. package/components/I18n/components/Placeholder/index.js +10 -3
  45. package/components/I18n/components/Placeholder/spec.js +12 -5
  46. package/components/I18n/components/Translate/index.js +12 -8
  47. package/components/I18n/components/Translate/spec.js +9 -6
  48. package/components/Icon/index.js +2 -1
  49. package/components/Image/Image.js +23 -21
  50. package/components/Image/ImageInner.js +2 -1
  51. package/components/InfiniteContainer/index.js +59 -53
  52. package/components/InfiniteContainer/spec.js +10 -5
  53. package/components/Input/components/MultiLineInput.js +33 -26
  54. package/components/Input/components/SimpleInput.js +70 -54
  55. package/components/Input/index.js +7 -17
  56. package/components/Input/spec.js +12 -11
  57. package/components/KeyboardConsumer/index.js +19 -13
  58. package/components/Link/index.js +28 -20
  59. package/components/Link/spec.js +13 -9
  60. package/components/List/components/Item/index.js +5 -3
  61. package/components/List/index.js +5 -3
  62. package/components/List/spec.js +6 -9
  63. package/components/Loading/index.js +1 -3
  64. package/components/Modal/index.js +13 -10
  65. package/components/ModalContainer/spec.js +24 -20
  66. package/components/Picker/components/Button/index.js +18 -12
  67. package/components/Picker/components/List/index.js +19 -16
  68. package/components/Picker/components/Modal/index.js +34 -25
  69. package/components/Picker/index.js +44 -33
  70. package/components/Picker/spec.js +4 -1
  71. package/components/Portal/index.js +26 -17
  72. package/components/ProductCharacteristics/index.js +65 -57
  73. package/components/RangeSlider/components/Handle/index.js +7 -5
  74. package/components/RangeSlider/index.js +98 -84
  75. package/components/Route/RouteNotFound.js +30 -19
  76. package/components/Route/index.js +31 -21
  77. package/components/Router/index.js +51 -34
  78. package/components/ScannerContainer/index.js +17 -10
  79. package/components/Select/components/Item/index.js +5 -3
  80. package/components/Select/index.js +59 -47
  81. package/components/Select/spec.js +7 -6
  82. package/components/SelectBox/components/Item/index.js +23 -13
  83. package/components/SelectBox/index.js +83 -80
  84. package/components/SelectBox/spec.js +8 -5
  85. package/components/SurroundPortals/index.js +15 -11
  86. package/components/Swiper/components/SwiperItem/index.js +6 -5
  87. package/components/Swiper/components/SwiperItem/spec.js +8 -4
  88. package/components/Swiper/index.js +23 -20
  89. package/components/Toaster/index.js +4 -1
  90. package/components/Transition/index.js +19 -12
  91. package/components/Widgets/components/Widget/index.js +27 -16
  92. package/components/Widgets/components/Widget/spec.js +5 -4
  93. package/components/Widgets/components/WidgetGrid/index.js +27 -19
  94. package/components/Widgets/components/WidgetGrid/spec.js +4 -3
  95. package/components/Widgets/index.js +33 -26
  96. package/components/Widgets/spec.js +12 -13
  97. package/helpers/data/index.js +1 -1
  98. package/helpers/portals/portalCollection.js +13 -10
  99. package/helpers/redux/mutable.js +2 -2
  100. package/package.json +5 -5
  101. package/providers/loading/index.js +71 -57
  102. package/providers/toast/index.js +39 -28
  103. package/reducers/modal/index.js +1 -1
  104. package/store/index.js +1 -1
  105. package/subscriptions/helpers/buildRegisterUrl.js +1 -0
  106. package/components/Input/components/DateInput.js +0 -273
@@ -1,9 +1,11 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
2
  import React, { Component } from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import isEqual from 'lodash/isEqual';
4
5
  import { withThemeWidgets } from '@shopgate/engage/core/hocs';
5
6
  import WidgetGrid from "./components/WidgetGrid";
6
7
  import shouldShowWidget from "./helpers/shouldShowWidget";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
7
9
  const WIDGET_GRID_TYPE = '@shopgate/commerce-widgets/widget-grid';
8
10
  const GRID_COLUMNS = 12; // One grid row has 12 columns. // TODO: is it deprecated since css grid?
9
11
 
@@ -23,23 +25,26 @@ const createGridWrapper = (key, config, components) => (/*#__PURE__*/React.creat
23
25
  /**
24
26
  * The widgets component.
25
27
  */
26
- class Widgets extends Component {
28
+ let Widgets = /*#__PURE__*/function (_Component) {
27
29
  /**
28
30
  * @param {Object} props The component props.
29
31
  */
30
- constructor(props) {
31
- super(props);
32
- this.autoReloadInterval = undefined;
33
- if (this.hasSchedulableWidgets()) {
34
- this.startAutoRerender();
32
+ function Widgets(props) {
33
+ var _this;
34
+ _this = _Component.call(this, props) || this;
35
+ if (_this.hasSchedulableWidgets()) {
36
+ _this.startAutoRerender();
35
37
  }
38
+ return _this;
36
39
  }
37
40
 
38
41
  /**
39
42
  * @param {Object} nextProps The next component props.
40
43
  * @return {JSX}
41
44
  */
42
- shouldComponentUpdate(nextProps) {
45
+ _inheritsLoose(Widgets, _Component);
46
+ var _proto = Widgets.prototype;
47
+ _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
43
48
  if (!isEqual(this.props.themeWidgets, nextProps.themeWidgets)) {
44
49
  return true;
45
50
  }
@@ -51,8 +56,8 @@ class Widgets extends Component {
51
56
 
52
57
  /**
53
58
  * Component will unmount lifecycle method.
54
- */
55
- componentWillUnmount() {
59
+ */;
60
+ _proto.componentWillUnmount = function componentWillUnmount() {
56
61
  this.stopAutoRerender();
57
62
  }
58
63
 
@@ -60,15 +65,15 @@ class Widgets extends Component {
60
65
  * Checks if any widget is schedulable.
61
66
  * @param {Array} widgets Array of widgets.
62
67
  * @returns {boolean}
63
- */
64
- hasSchedulableWidgets() {
68
+ */;
69
+ _proto.hasSchedulableWidgets = function hasSchedulableWidgets() {
65
70
  return (this.props.widgets || []).some(widget => widget.settings.plan);
66
71
  }
67
72
 
68
73
  /**
69
74
  * Sets auto re-render.
70
- */
71
- startAutoRerender() {
75
+ */;
76
+ _proto.startAutoRerender = function startAutoRerender() {
72
77
  const minutesToRoundedHour = 60 - new Date().getMinutes();
73
78
  const nextRerenderIn = minutesToRoundedHour * 60000;
74
79
  this.autoReloadTimeout = setTimeout(() => this.doAutoRerender(), nextRerenderIn);
@@ -77,15 +82,15 @@ class Widgets extends Component {
77
82
  /**
78
83
  * Stops auto re-render. Must be called before component is unmounted to avoid
79
84
  * memory leak.
80
- */
81
- stopAutoRerender() {
85
+ */;
86
+ _proto.stopAutoRerender = function stopAutoRerender() {
82
87
  clearTimeout(this.autoReloadTimeout);
83
88
  }
84
89
 
85
90
  /**
86
91
  * Forces re-render and sets another timeout for next cycle.
87
- */
88
- doAutoRerender() {
92
+ */;
93
+ _proto.doAutoRerender = function doAutoRerender() {
89
94
  this.forceUpdate();
90
95
  this.startAutoRerender();
91
96
  }
@@ -93,8 +98,8 @@ class Widgets extends Component {
93
98
  /**
94
99
  * Create array of elements from widget configuration.
95
100
  * @returns {Array} Array of JSX elements.
96
- */
97
- createArrayOfElements() {
101
+ */;
102
+ _proto.createArrayOfElements = function createArrayOfElements() {
98
103
  const {
99
104
  widgets = [],
100
105
  themeWidgets: components
@@ -128,8 +133,8 @@ class Widgets extends Component {
128
133
 
129
134
  /**
130
135
  * @return {JSX}
131
- */
132
- render() {
136
+ */;
137
+ _proto.render = function render() {
133
138
  const {
134
139
  widgets,
135
140
  themeWidgets: components
@@ -137,11 +142,13 @@ class Widgets extends Component {
137
142
  if (!widgets) {
138
143
  return null;
139
144
  }
140
- return /*#__PURE__*/React.createElement("div", {
141
- className: "common__widgets"
142
- }, this.createArrayOfElements(widgets, components));
143
- }
144
- }
145
+ return /*#__PURE__*/_jsx("div", {
146
+ className: "common__widgets",
147
+ children: this.createArrayOfElements(widgets, components)
148
+ });
149
+ };
150
+ return Widgets;
151
+ }(Component);
145
152
  Widgets.defaultProps = {
146
153
  widgets: null
147
154
  };
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { mount } from 'enzyme';
3
3
  import { ThemeResourcesProvider } from '@shopgate/engage/core/providers';
4
4
  import Widgets from "./index";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
5
6
  jest.useFakeTimers();
6
7
  jest.mock('@shopgate/pwa-common/context', () => ({
7
8
  ThemeContext: {
@@ -15,7 +16,7 @@ jest.mock('@shopgate/pwa-common/context', () => ({
15
16
  * A mock Image component.
16
17
  * @returns {JSX}
17
18
  */
18
- const Image = () => /*#__PURE__*/React.createElement("img", {
19
+ const Image = () => /*#__PURE__*/_jsx("img", {
19
20
  alt: ""
20
21
  });
21
22
  /* eslint-disable react/prop-types */
@@ -26,9 +27,10 @@ const Image = () => /*#__PURE__*/React.createElement("img", {
26
27
  */
27
28
  const WidgetGrid = ({
28
29
  children
29
- }) => /*#__PURE__*/React.createElement("div", {
30
- className: "widget-grid"
31
- }, children);
30
+ }) => /*#__PURE__*/_jsx("div", {
31
+ className: "widget-grid",
32
+ children: children
33
+ });
32
34
  /* eslint-enable react/prop-types */
33
35
 
34
36
  const components = {
@@ -42,12 +44,13 @@ const components = {
42
44
  * @param {Object[]} widgets Widgets to be rendered.
43
45
  * @returns {JSX.Element}
44
46
  */
45
- const createWrapper = widgets => mount(/*#__PURE__*/React.createElement(ThemeResourcesProvider, {
47
+ const createWrapper = widgets => mount(/*#__PURE__*/_jsx(ThemeResourcesProvider, {
46
48
  widgets: components,
47
- components: {}
48
- }, /*#__PURE__*/React.createElement(Widgets, {
49
- widgets: widgets
50
- })));
49
+ components: {},
50
+ children: /*#__PURE__*/_jsx(Widgets, {
51
+ widgets: widgets
52
+ })
53
+ }));
51
54
  describe('<Widgets />', () => {
52
55
  it('should render a grid if height is defined', () => {
53
56
  const widgets = [{
@@ -146,8 +149,6 @@ describe('<Widgets />', () => {
146
149
 
147
150
  const scheduledFromMs = Date.now() + msToNextFullHour - 1;
148
151
  const scheduledToMs = Date.now() + minutesToNextFullHour + 1000;
149
-
150
- /* eslint-disable camelcase */
151
152
  const widgets = [{
152
153
  col: 0,
153
154
  row: 0,
@@ -164,8 +165,6 @@ describe('<Widgets />', () => {
164
165
  },
165
166
  type: '@shopgate/commerce-widgets/image'
166
167
  }];
167
- /* eslint-enable camelcase */
168
-
169
168
  const wrapper = createWrapper(widgets);
170
169
  const instance = wrapper.find('Widgets').instance();
171
170
  const clearSpy = jest.spyOn(global, 'clearTimeout');
@@ -194,7 +194,7 @@ export const validateSelectorParams = (selector, defaultResult = null) => (...pa
194
194
  if (params.some(param => param === null || typeof param === 'undefined')) {
195
195
  return defaultResult;
196
196
  }
197
- return selector(...params);
197
+ return selector.apply(void 0, params);
198
198
  };
199
199
 
200
200
  /**
@@ -1,37 +1,40 @@
1
1
  /**
2
2
  * The portals collection.
3
3
  */
4
- class PortalCollection {
4
+ let PortalCollection = /*#__PURE__*/function () {
5
+ function PortalCollection() {}
6
+ var _proto = PortalCollection.prototype;
5
7
  /**
6
8
  * Returns the portal definitions.
7
9
  * @return {Object}
8
10
  */
9
- getPortals() {
11
+ _proto.getPortals = function getPortals() {
10
12
  return this.portals;
11
13
  }
12
14
 
13
15
  /**
14
16
  * Registers the portal definitions.
15
17
  * @param {Object} [portals={}] The portals to register.
16
- */
17
- registerPortals(portals = {}) {
18
+ */;
19
+ _proto.registerPortals = function registerPortals(portals = {}) {
18
20
  this.portals = portals;
19
21
  }
20
22
 
21
23
  /**
22
24
  * Registers the portal config.
23
25
  * @param {Object} [config={}] The portals config.
24
- */
25
- registerConfig(config = {}) {
26
+ */;
27
+ _proto.registerConfig = function registerConfig(config = {}) {
26
28
  this.config = config;
27
29
  }
28
30
 
29
31
  /**
30
32
  * Returns the portal config.
31
33
  * @return {Object}
32
- */
33
- getConfig() {
34
+ */;
35
+ _proto.getConfig = function getConfig() {
34
36
  return this.config;
35
- }
36
- }
37
+ };
38
+ return PortalCollection;
39
+ }();
37
40
  export default new PortalCollection();
@@ -88,7 +88,7 @@ export const mutable = func => {
88
88
  if (steps.length > 0) {
89
89
  mutatedArgs = steps.reduce((acc, step, i, arr) => {
90
90
  // Call next step func in the pipeline with mutated args
91
- let res = step(...acc);
91
+ let res = step.apply(void 0, acc);
92
92
 
93
93
  // Keep params unchanged if the step did not perform any change action at all
94
94
  if (!isObject(res)) {
@@ -132,7 +132,7 @@ export const mutable = func => {
132
132
  }
133
133
 
134
134
  // Call the actual mutable
135
- return current(...mutatedArgs);
135
+ return current.apply(void 0, mutatedArgs);
136
136
  }
137
137
 
138
138
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-common",
3
- "version": "7.30.0-alpha.9",
3
+ "version": "7.30.0-beta.2",
4
4
  "description": "Common library for the Shopgate Connect PWA.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -17,7 +17,7 @@
17
17
  "dependencies": {
18
18
  "@redux-devtools/extension": "^3.3.0",
19
19
  "@sentry/browser": "6.0.1",
20
- "@shopgate/pwa-benchmark": "7.30.0-alpha.9",
20
+ "@shopgate/pwa-benchmark": "7.30.0-beta.2",
21
21
  "@virtuous/conductor": "~2.5.0",
22
22
  "@virtuous/react-conductor": "~2.5.0",
23
23
  "@virtuous/redux-persister": "1.1.0-beta.7",
@@ -41,11 +41,11 @@
41
41
  "url-search-params": "^0.10.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@shopgate/pwa-core": "7.30.0-alpha.9",
44
+ "@shopgate/pwa-core": "7.30.0-beta.2",
45
45
  "@types/react-portal": "^3.0.9",
46
46
  "lodash": "^4.17.21",
47
47
  "prop-types": "~15.8.1",
48
- "react": "~16.14.0",
49
- "react-dom": "~16.14.0"
48
+ "react": "^17.0.2",
49
+ "react-dom": "^17.0.2"
50
50
  }
51
51
  }
@@ -1,3 +1,4 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
2
  import React, { Component } from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import { UIEvents } from '@shopgate/pwa-core';
@@ -6,52 +7,30 @@ import LoadingContext from "./context";
6
7
  /**
7
8
  * The LoadingProvider component.
8
9
  */
9
- class LoadingProvider extends Component {
10
- /**
11
- * Adds or increases the loading counter for a path.
12
- * @param {string} path The path which loads.
13
- */
14
- static setLoading(path) {
15
- UIEvents.emit(LoadingProvider.SET, path);
16
- }
17
-
18
- /**
19
- * Resets the loading counter for a path.
20
- * @param {string} path The path which loads.
21
- */
22
- static resetLoading(path) {
23
- UIEvents.emit(LoadingProvider.RESET, path);
24
- }
25
-
26
- /**
27
- * Decreases the loading counter for a path.
28
- * @param {string} path The path which loads.
29
- */
30
- static unsetLoading(path) {
31
- UIEvents.emit(LoadingProvider.UNSET, path);
32
- }
33
-
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ let LoadingProvider = /*#__PURE__*/function (_Component) {
34
12
  /**
35
13
  * @param {Object} props The component props.
36
14
  */
37
- constructor(props) {
38
- super(props);
15
+ function LoadingProvider(props) {
16
+ var _this;
17
+ _this = _Component.call(this, props) || this;
39
18
  /**
40
19
  * Adds or increases the loading counter for a path.
41
20
  * @param {string} path The path which loads.
42
21
  */
43
- this.setLoading = path => {
22
+ _this.setLoading = path => {
44
23
  const {
45
24
  loading
46
- } = this;
25
+ } = _this;
47
26
  const newLoading = {
48
27
  ...loading,
49
28
  [path]: loading[path] ? loading[path] + 1 : 1
50
29
  };
51
30
 
52
31
  // Immediately updates state due to multiple sets before actual rerender.
53
- this.loading = newLoading;
54
- this.setState({
32
+ _this.loading = newLoading;
33
+ _this.setState({
55
34
  loading: newLoading
56
35
  });
57
36
  };
@@ -59,15 +38,15 @@ class LoadingProvider extends Component {
59
38
  * Resets the loading counter for a path.
60
39
  * @param {string} path The path which loads.
61
40
  */
62
- this.resetLoading = path => {
41
+ _this.resetLoading = path => {
63
42
  const {
64
43
  [path]: removedPath,
65
44
  ...remaining
66
- } = this.loading;
45
+ } = _this.loading;
67
46
 
68
47
  // Immediately updates state due to multiple sets before actual rerender.
69
- this.loading = remaining;
70
- this.setState({
48
+ _this.loading = remaining;
49
+ _this.setState({
71
50
  loading: remaining
72
51
  });
73
52
  };
@@ -75,15 +54,15 @@ class LoadingProvider extends Component {
75
54
  * Decreases the loading counter for a path.
76
55
  * @param {string} path The path which loads.
77
56
  */
78
- this.unsetLoading = path => {
57
+ _this.unsetLoading = path => {
79
58
  const {
80
59
  loading
81
- } = this;
60
+ } = _this;
82
61
  if (typeof loading[path] === 'undefined') {
83
62
  return;
84
63
  }
85
64
  if (loading[path] <= 1) {
86
- this.resetLoading(path);
65
+ _this.resetLoading(path);
87
66
  return;
88
67
  }
89
68
  const newLoading = {
@@ -92,8 +71,8 @@ class LoadingProvider extends Component {
92
71
  };
93
72
 
94
73
  // Immediately updates state due to multiple sets before actual rerender.
95
- this.loading = newLoading;
96
- this.setState({
74
+ _this.loading = newLoading;
75
+ _this.setState({
97
76
  loading: newLoading
98
77
  });
99
78
  };
@@ -102,44 +81,79 @@ class LoadingProvider extends Component {
102
81
  * @param {string} path The path it inspect.
103
82
  * @return {boolean}
104
83
  */
105
- this.isLoading = path => {
84
+ _this.isLoading = path => {
106
85
  const {
107
86
  loading
108
- } = this.state;
87
+ } = _this.state;
109
88
  return !!loading[path];
110
89
  };
111
- this.loading = {};
112
- this.state = {
90
+ _this.loading = {};
91
+ _this.contextValue = null;
92
+ _this.state = {
113
93
  loading: {}
114
94
  };
115
- UIEvents.addListener(this.constructor.SET, this.setLoading);
116
- UIEvents.addListener(this.constructor.RESET, this.resetLoading);
117
- UIEvents.addListener(this.constructor.UNSET, this.unsetLoading);
95
+ UIEvents.addListener(_this.constructor.SET, _this.setLoading);
96
+ UIEvents.addListener(_this.constructor.RESET, _this.resetLoading);
97
+ UIEvents.addListener(_this.constructor.UNSET, _this.unsetLoading);
98
+ return _this;
118
99
  }
119
100
 
120
101
  /**
121
102
  * Removes the event listeners when the component unmounts.
122
103
  */
123
- componentWillUnmount() {
104
+ _inheritsLoose(LoadingProvider, _Component);
105
+ /**
106
+ * Adds or increases the loading counter for a path.
107
+ * @param {string} path The path which loads.
108
+ */
109
+ LoadingProvider.setLoading = function setLoading(path) {
110
+ UIEvents.emit(LoadingProvider.SET, path);
111
+ }
112
+
113
+ /**
114
+ * Resets the loading counter for a path.
115
+ * @param {string} path The path which loads.
116
+ */;
117
+ LoadingProvider.resetLoading = function resetLoading(path) {
118
+ UIEvents.emit(LoadingProvider.RESET, path);
119
+ }
120
+
121
+ /**
122
+ * Decreases the loading counter for a path.
123
+ * @param {string} path The path which loads.
124
+ */;
125
+ LoadingProvider.unsetLoading = function unsetLoading(path) {
126
+ UIEvents.emit(LoadingProvider.UNSET, path);
127
+ };
128
+ var _proto = LoadingProvider.prototype;
129
+ _proto.componentWillUnmount = function componentWillUnmount() {
124
130
  UIEvents.removeListener(this.constructor.SET, this.setLoading);
125
131
  UIEvents.removeListener(this.constructor.RESET, this.resetLoading);
126
132
  UIEvents.removeListener(this.constructor.UNSET, this.unsetLoading);
127
- }
133
+ };
128
134
  /**
129
135
  * @return {JSX}
130
136
  */
131
- render() {
132
- const value = {
133
- loading: this.state.loading,
137
+ _proto.render = function render() {
138
+ const {
139
+ loading
140
+ } = this.state;
141
+ const nextValue = {
142
+ loading,
134
143
  setLoading: this.setLoading,
135
144
  unsetLoading: this.unsetLoading,
136
145
  isLoading: this.isLoading
137
146
  };
138
- return /*#__PURE__*/React.createElement(LoadingContext.Provider, {
139
- value: value
140
- }, this.props.children);
141
- }
142
- }
147
+ if (!this.contextValue || this.contextValue.loading !== loading) {
148
+ this.contextValue = nextValue;
149
+ }
150
+ return /*#__PURE__*/_jsx(LoadingContext.Provider, {
151
+ value: this.contextValue,
152
+ children: this.props.children
153
+ });
154
+ };
155
+ return LoadingProvider;
156
+ }(Component);
143
157
  LoadingProvider.SET = 'loading_set';
144
158
  LoadingProvider.RESET = 'loading_reset';
145
159
  LoadingProvider.UNSET = 'loading_unset';
@@ -1,8 +1,11 @@
1
+ import _createClass from "@babel/runtime/helpers/createClass";
2
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
3
  import React, { Component } from 'react';
2
4
  import PropTypes from 'prop-types';
3
5
  import { UIEvents } from '@shopgate/pwa-core';
4
6
  import { themeConfig } from '@shopgate/pwa-common/helpers/config';
5
7
  import ToastContext from "./context";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
6
9
  const {
7
10
  variables: {
8
11
  toast: {
@@ -14,23 +17,24 @@ const {
14
17
  /**
15
18
  * The ToastProvider component
16
19
  */
17
- class ToastProvider extends Component {
20
+ let ToastProvider = /*#__PURE__*/function (_Component) {
18
21
  /**
19
22
  * @param {Object} props The component props.
20
23
  */
21
- constructor(props) {
22
- super(props);
24
+ function ToastProvider(props) {
25
+ var _this;
26
+ _this = _Component.call(this, props) || this;
23
27
  /**
24
28
  * Adds a new, unique, toast to the list.
25
29
  * @param {Object} toast The toast object to add.
26
30
  */
27
- this.addToast = toast => {
31
+ _this.addToast = toast => {
28
32
  if (!toast.message) {
29
33
  return;
30
34
  }
31
35
  const {
32
36
  toasts
33
- } = this.state;
37
+ } = _this.state;
34
38
 
35
39
  // Check if the toast id already is present.
36
40
  const found = toasts.find(({
@@ -54,56 +58,63 @@ class ToastProvider extends Component {
54
58
  duration: toast.duration || duration
55
59
  });
56
60
  }
57
- this.setState({
61
+ _this.setState({
58
62
  toasts
59
63
  });
60
64
  };
61
65
  /**
62
66
  * Removes the first toast from the list.
63
67
  */
64
- this.removeToast = () => {
68
+ _this.removeToast = () => {
65
69
  const {
66
70
  toasts
67
- } = this.state;
71
+ } = _this.state;
68
72
  toasts.shift();
69
- this.setState({
73
+ _this.setState({
70
74
  toasts
71
75
  });
72
76
  };
73
- this.flushToasts = () => {
74
- if (this.state.toasts.length) {
75
- this.setState({
77
+ _this.flushToasts = () => {
78
+ if (_this.state.toasts.length) {
79
+ _this.setState({
76
80
  toasts: []
77
81
  });
78
82
  }
79
83
  };
80
- this.state = {
84
+ _this.state = {
81
85
  toasts: []
82
86
  };
83
- UIEvents.addListener(this.constructor.ADD, this.addToast);
84
- UIEvents.addListener(this.constructor.FLUSH, this.flushToasts);
87
+ UIEvents.addListener(_this.constructor.ADD, _this.addToast);
88
+ UIEvents.addListener(_this.constructor.FLUSH, _this.flushToasts);
89
+ return _this;
85
90
  }
86
91
 
87
92
  /**
88
93
  * Returns the context value to be passed to consumers.
89
94
  * @returns {Object}
90
95
  */
91
- get provided() {
92
- return {
93
- addToast: this.addToast,
94
- removeToast: this.removeToast,
95
- toasts: this.state.toasts
96
- };
97
- }
96
+ _inheritsLoose(ToastProvider, _Component);
97
+ var _proto = ToastProvider.prototype;
98
98
  /**
99
99
  * @returns {JSX}
100
100
  */
101
- render() {
102
- return /*#__PURE__*/React.createElement(ToastContext.Provider, {
103
- value: this.provided
104
- }, this.props.children);
105
- }
106
- }
101
+ _proto.render = function render() {
102
+ return /*#__PURE__*/_jsx(ToastContext.Provider, {
103
+ value: this.provided,
104
+ children: this.props.children
105
+ });
106
+ };
107
+ return _createClass(ToastProvider, [{
108
+ key: "provided",
109
+ get: function () {
110
+ return {
111
+ addToast: this.addToast,
112
+ removeToast: this.removeToast,
113
+ toasts: this.state.toasts
114
+ };
115
+ }
116
+ }]);
117
+ }(Component);
107
118
  ToastProvider.ADD = 'toast_add';
108
119
  ToastProvider.FLUSH = 'toast_flush';
109
120
  export default ToastProvider;
@@ -9,7 +9,7 @@ import { CREATE_MODAL, REMOVE_MODAL } from "../../constants/ActionTypes";
9
9
  export default function modalReducer(state = [], action) {
10
10
  switch (action.type) {
11
11
  case CREATE_MODAL:
12
- return [...state, action.options];
12
+ return [].concat(state, [action.options]);
13
13
  case REMOVE_MODAL:
14
14
  return state.filter(modal => modal.id !== action.id);
15
15
  default:
package/store/index.js CHANGED
@@ -46,7 +46,7 @@ export function configureStore(reducers, subscribers) {
46
46
  if (appConfig.benchmark) {
47
47
  benchmarkController.startup();
48
48
  }
49
- const store = createStore(makeRootReducer(reducers), getInitialState(), composeWithDevTools(applyMiddleware(...[thunk, ...(appConfig.benchmark ? [benchmarkMiddleware] : []), streams, logger]), persistState({
49
+ const store = createStore(makeRootReducer(reducers), getInitialState(), composeWithDevTools(applyMiddleware.apply(void 0, [thunk].concat(appConfig.benchmark ? [benchmarkMiddleware] : [], [streams, logger])), persistState({
50
50
  key: storeKey,
51
51
  paths: persistedReducers.getAll()
52
52
  })));
@@ -15,6 +15,7 @@ const getRegisterUrl = (url, redirect = '') => {
15
15
  const redirectTo = redirect && !redirect.startsWith(CHECKOUT_PATH) ? redirect : INDEX_PATH;
16
16
 
17
17
  // Build the callback data.
18
+
18
19
  parsed.query.sgcloud_callback_data = JSON.stringify({
19
20
  redirectTo
20
21
  });