@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,3 +1,5 @@
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 { logger } from '@shopgate/pwa-core/helpers';
@@ -10,20 +12,22 @@ import { generateLinearEasingCallback, generateExponentialEasingCallback, getRan
10
12
  * @deprecated Will be remove in v7.0.0.
11
13
  * Please use `import { RangeSlider } from '@shopgate/engage/components'` instead.
12
14
  */
13
- class RangeSlider extends Component {
15
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
+ let RangeSlider = /*#__PURE__*/function (_Component) {
14
17
  /**
15
18
  * Constructor
16
19
  * @param {Object} props The component properties
17
20
  */
18
- constructor(props) {
19
- super(props);
21
+ function RangeSlider(props) {
22
+ var _this;
23
+ _this = _Component.call(this, props) || this;
20
24
  /**
21
25
  * Processes touch start events on handles.
22
26
  * @param {Object} event The touch event
23
27
  * @param {number} index The index of the touched handle.
24
28
  */
25
- this.handleTouchStart = (event, index) => {
26
- this.draggedHandle = index;
29
+ _this.handleTouchStart = (event, index) => {
30
+ _this.draggedHandle = index;
27
31
 
28
32
  // Calculate the relative offset to the handles center
29
33
  const handleDOMElement = event.target;
@@ -32,97 +36,100 @@ class RangeSlider extends Component {
32
36
  // ... and calculate its absolute center.
33
37
  const handleCenterX = handleRect.left + handleDOMElement.offsetWidth / 2;
34
38
  // Store the signed distanced between the current touch offset and the handle center.
35
- this.touchOffset = getTouchPositionX(event) - handleCenterX;
39
+ _this.touchOffset = getTouchPositionX(event) - handleCenterX;
36
40
  };
37
41
  /**
38
42
  * Processes move events on handles.
39
43
  * @param {Object} event The touch event
40
44
  */
41
- this.handleTouchMove = event => {
42
- if (this.props.min === this.props.max) {
45
+ _this.handleTouchMove = event => {
46
+ if (_this.props.min === _this.props.max) {
43
47
  return;
44
48
  }
45
- if (this.draggedHandle === null) {
49
+ if (_this.draggedHandle === null) {
46
50
  return;
47
51
  }
48
52
  const {
49
53
  offsetWidth,
50
54
  offsetLeft
51
- } = this.domElement;
55
+ } = _this.domElement;
52
56
  // Calculate the absolute offset where the element was touched...
53
- let deltaX = getTouchPositionX(event) - offsetLeft - this.touchOffset;
57
+ let deltaX = getTouchPositionX(event) - offsetLeft - _this.touchOffset;
54
58
 
55
59
  // ...and convert it into a relative value between [0...1].
56
60
  deltaX = Math.max(0, Math.min(1, deltaX / offsetWidth));
57
61
  const stateUpdate = {};
58
- if (this.draggedHandle === 1) {
62
+ if (_this.draggedHandle === 1) {
59
63
  // Right handle dragged
60
- if (this.state.rangeMin < deltaX) {
64
+ if (_this.state.rangeMin < deltaX) {
61
65
  stateUpdate.rangeMax = Math.min(1, deltaX);
62
- this.draggedHandlePixelOffset = Math.abs(stateUpdate.rangeMax - this.state.rangeMax);
66
+ _this.draggedHandlePixelOffset = Math.abs(stateUpdate.rangeMax - _this.state.rangeMax);
63
67
  } else {
64
68
  // Not in valid range, swap handles
65
- this.draggedHandle = 0;
66
- stateUpdate.rangeMax = this.state.rangeMin;
69
+ _this.draggedHandle = 0;
70
+ stateUpdate.rangeMax = _this.state.rangeMin;
67
71
  stateUpdate.rangeMin = deltaX;
68
- this.draggedHandlePixelOffset = Math.abs(stateUpdate.rangeMin - this.state.rangeMin);
72
+ _this.draggedHandlePixelOffset = Math.abs(stateUpdate.rangeMin - _this.state.rangeMin);
69
73
  }
70
- } else if (this.draggedHandle === 0) {
74
+ } else if (_this.draggedHandle === 0) {
71
75
  // Left handle dragged
72
- if (this.state.rangeMax > deltaX) {
76
+ if (_this.state.rangeMax > deltaX) {
73
77
  stateUpdate.rangeMin = Math.max(0, deltaX);
74
- this.draggedHandlePixelOffset = Math.abs(stateUpdate.rangeMin - this.state.rangeMin);
78
+ _this.draggedHandlePixelOffset = Math.abs(stateUpdate.rangeMin - _this.state.rangeMin);
75
79
  } else {
76
80
  // Not in valid range, swap handles
77
- this.draggedHandle = 1;
78
- stateUpdate.rangeMin = this.state.rangeMax;
81
+ _this.draggedHandle = 1;
82
+ stateUpdate.rangeMin = _this.state.rangeMax;
79
83
  stateUpdate.rangeMax = deltaX;
80
- this.draggedHandlePixelOffset = Math.abs(stateUpdate.rangeMax - this.state.rangeMax);
84
+ _this.draggedHandlePixelOffset = Math.abs(stateUpdate.rangeMax - _this.state.rangeMax);
81
85
  }
82
86
  }
83
- this.draggedHandlePixelOffset *= this.domElement.offsetWidth;
84
- this.setState(stateUpdate, this.triggerChangeCallback);
87
+ _this.draggedHandlePixelOffset *= _this.domElement.offsetWidth;
88
+ _this.setState(stateUpdate, _this.triggerChangeCallback);
85
89
  };
86
90
  /**
87
91
  * Processes global touch end events for handles.
88
92
  * @param {Object} e The touch event
89
93
  */
90
- this.handleTouchEnd = () => {
91
- this.touchOffset = 0;
92
- this.draggedHandle = null;
94
+ _this.handleTouchEnd = () => {
95
+ _this.touchOffset = 0;
96
+ _this.draggedHandle = null;
93
97
  };
94
98
  /**
95
99
  * Processes outer range touch end events.
96
100
  * @param {Object} event The touch event
97
101
  */
98
- this.handleRangeTouch = event => {
102
+ _this.handleRangeTouch = event => {
99
103
  const {
100
104
  offsetWidth,
101
105
  offsetLeft
102
- } = this.domElement;
106
+ } = _this.domElement;
103
107
  const dx = (getTouchPositionX(event) - offsetLeft) / offsetWidth;
104
- const d0 = Math.abs(this.state.rangeMin - dx);
105
- const d1 = Math.abs(this.state.rangeMax - dx);
108
+ const d0 = Math.abs(_this.state.rangeMin - dx);
109
+ const d1 = Math.abs(_this.state.rangeMax - dx);
106
110
  if (d0 < d1) {
107
- this.draggedHandle = 0;
111
+ _this.draggedHandle = 0;
108
112
  } else {
109
- this.draggedHandle = 1;
113
+ _this.draggedHandle = 1;
110
114
  }
111
- this.handleTouchMove(event);
115
+ _this.handleTouchMove(event);
112
116
  };
113
117
  logger.warn('===== RangeSlider deprecated =====\nThe RangeSlider component and it\'s related components (@shopgate/pwa-common/component/RangeSlider) are deprecated and will be removed in @shopgate/engage v7.0.0.\nPlease use: import { RangeSlider } from \'@shopgate/engage/components\'.\n===================================');
114
- this.draggedHandle = null; // 0 for left handle, 1 for right handle or null
115
- this.domElement = null;
116
- this.touchOffset = 0;
117
- this.draggedHandlePixelOffset = 0; // The absolute pixel delta of the last handle move event.
118
+ _this.draggedHandle = null; // 0 for left handle, 1 for right handle or null
119
+ _this.domElement = null;
120
+ _this.touchOffset = 0;
121
+ _this.draggedHandlePixelOffset = 0; // The absolute pixel delta of the last handle move event.
118
122
 
119
- this.state = this.getRange(props);
123
+ _this.state = _this.getRange(props);
124
+ return _this;
120
125
  }
121
126
 
122
127
  /**
123
128
  * Sets the global event listeners when component mounts.
124
129
  */
125
- componentDidMount() {
130
+ _inheritsLoose(RangeSlider, _Component);
131
+ var _proto = RangeSlider.prototype;
132
+ _proto.componentDidMount = function componentDidMount() {
126
133
  document.addEventListener('touchend', this.handleTouchEnd);
127
134
  document.addEventListener('touchmove', this.handleTouchMove);
128
135
  }
@@ -130,45 +137,28 @@ class RangeSlider extends Component {
130
137
  /**
131
138
  * Updates the component properties.
132
139
  * @param {Object} newProps The new component properties.
133
- */
134
- UNSAFE_componentWillReceiveProps(newProps) {
140
+ */;
141
+ _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(newProps) {
135
142
  this.setState(this.getRange(newProps));
136
143
  }
137
144
 
138
145
  /**
139
146
  * Removes the global event listeners when component unmounts.
140
- */
141
- componentWillUnmount() {
147
+ */;
148
+ _proto.componentWillUnmount = function componentWillUnmount() {
142
149
  document.removeEventListener('touchend', this.handleTouchEnd);
143
150
  document.removeEventListener('touchmove', this.handleTouchMove);
144
151
  }
145
152
 
146
153
  /**
147
154
  * Get the easing function.
148
- */
149
- get ease() {
150
- return {
151
- linear: generateLinearEasingCallback(this.props.resolution),
152
- exponential: generateExponentialEasingCallback(this.props.factor)
153
- }[this.props.easing];
154
- }
155
-
156
- /**
157
- * Get the function to invert an eased value to it's original value.
158
- */
159
- get invertedEase() {
160
- return {
161
- linear: generateLinearEasingCallback(this.props.resolution),
162
- exponential: generateExponentialEasingCallback(1 / this.props.factor)
163
- }[this.props.easing];
164
- }
165
-
155
+ */;
166
156
  /**
167
157
  * Get range min and max from props.
168
158
  * @param {Object} props The component props.
169
159
  * @returns {Object} The new state
170
160
  */
171
- getRange(props) {
161
+ _proto.getRange = function getRange(props) {
172
162
  const {
173
163
  value,
174
164
  min,
@@ -178,11 +168,11 @@ class RangeSlider extends Component {
178
168
  rangeMin: this.invertedEase(getRelativeValue(value[0], min, max)),
179
169
  rangeMax: this.invertedEase(getRelativeValue(value[1], min, max))
180
170
  };
181
- }
171
+ };
182
172
  /**
183
173
  * Calls the change callback in case of a state update.
184
174
  */
185
- triggerChangeCallback() {
175
+ _proto.triggerChangeCallback = function triggerChangeCallback() {
186
176
  const {
187
177
  value,
188
178
  onChange,
@@ -202,9 +192,9 @@ class RangeSlider extends Component {
202
192
  * Creates a new handle component.
203
193
  * @param {number} index The index of the component. Must be either 0 or 1.
204
194
  * @returns {JSX}
205
- */
206
- makeHandle(index) {
207
- return /*#__PURE__*/React.createElement(RangeSliderHandle, {
195
+ */;
196
+ _proto.makeHandle = function makeHandle(index) {
197
+ return /*#__PURE__*/_jsx(RangeSliderHandle, {
208
198
  index: index,
209
199
  onTouchStart: this.handleTouchStart,
210
200
  active: this.draggedHandle === index,
@@ -215,25 +205,49 @@ class RangeSlider extends Component {
215
205
  /**
216
206
  * Renders the component.
217
207
  * @returns {JSX}
218
- */
219
- render() {
208
+ */;
209
+ _proto.render = function render() {
220
210
  // Calculate the animation speed.
221
211
  const animationSpeed = Math.round(1000 / this.props.animationSpeed * this.draggedHandlePixelOffset);
222
212
  const rangeStyle = getRangeStyle(this.state.rangeMin, this.state.rangeMax, animationSpeed > 10 ? animationSpeed : 0);
223
- return /*#__PURE__*/React.createElement("div", {
213
+ return /*#__PURE__*/_jsx("div", {
224
214
  className: `${this.props.classNames.container || ''} common__range-slider`,
225
- onTouchStart: this.handleRangeTouch
226
- }, /*#__PURE__*/React.createElement("div", {
227
- className: `${this.props.classNames.outerRange || ''} ${styles.outerRange}`,
228
- ref: ref => {
229
- this.domElement = ref;
230
- }
231
- }, /*#__PURE__*/React.createElement("div", {
232
- className: `${this.props.classNames.range || ''} ${styles.range}`,
233
- style: rangeStyle
234
- }, this.makeHandle(0), this.makeHandle(1))));
235
- }
236
- }
215
+ onTouchStart: this.handleRangeTouch,
216
+ children: /*#__PURE__*/_jsx("div", {
217
+ className: `${this.props.classNames.outerRange || ''} ${styles.outerRange}`,
218
+ ref: ref => {
219
+ this.domElement = ref;
220
+ },
221
+ children: /*#__PURE__*/_jsxs("div", {
222
+ className: `${this.props.classNames.range || ''} ${styles.range}`,
223
+ style: rangeStyle,
224
+ children: [this.makeHandle(0), this.makeHandle(1)]
225
+ })
226
+ })
227
+ });
228
+ };
229
+ return _createClass(RangeSlider, [{
230
+ key: "ease",
231
+ get: function () {
232
+ return {
233
+ linear: generateLinearEasingCallback(this.props.resolution),
234
+ exponential: generateExponentialEasingCallback(this.props.factor)
235
+ }[this.props.easing];
236
+ }
237
+
238
+ /**
239
+ * Get the function to invert an eased value to it's original value.
240
+ */
241
+ }, {
242
+ key: "invertedEase",
243
+ get: function () {
244
+ return {
245
+ linear: generateLinearEasingCallback(this.props.resolution),
246
+ exponential: generateExponentialEasingCallback(1 / this.props.factor)
247
+ }[this.props.easing];
248
+ }
249
+ }]);
250
+ }(Component);
237
251
  RangeSlider.defaultProps = {
238
252
  animationSpeed: 500,
239
253
  classNames: {},
@@ -1,3 +1,5 @@
1
+ import _createClass from "@babel/runtime/helpers/createClass";
2
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
3
  import React from 'react';
2
4
  import PropTypes from 'prop-types';
3
5
  import { router } from '@virtuous/conductor';
@@ -7,21 +9,17 @@ import ErrorBoundary from "../ErrorBoundary";
7
9
  /**
8
10
  * The RouteNotFound component
9
11
  */
10
- class RouteNotFound extends React.Component {
11
- /**
12
- * @returns {Object}
13
- */
14
- get currentRoute() {
15
- const {
16
- [router.routeIndex]: [, route]
17
- } = this.context.stack;
18
- return route;
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ let RouteNotFound = /*#__PURE__*/function (_React$Component) {
14
+ function RouteNotFound() {
15
+ return _React$Component.apply(this, arguments) || this;
19
16
  }
20
-
17
+ _inheritsLoose(RouteNotFound, _React$Component);
18
+ var _proto = RouteNotFound.prototype;
21
19
  /**
22
20
  * @returns {JSX}
23
21
  */
24
- render() {
22
+ _proto.render = function render() {
25
23
  if (router.match(this.currentRoute.pathname)) {
26
24
  return null;
27
25
  }
@@ -36,13 +34,26 @@ class RouteNotFound extends React.Component {
36
34
  context.visible = true;
37
35
  context.pattern = '';
38
36
  context.is404 = true;
39
- return /*#__PURE__*/React.createElement(ErrorBoundary, {
40
- key: "error.404"
41
- }, /*#__PURE__*/React.createElement(RouteContext.Provider, {
42
- key: "404",
43
- value: context
44
- }, /*#__PURE__*/React.createElement(Component, null)));
45
- }
46
- }
37
+ return /*#__PURE__*/_jsx(ErrorBoundary, {
38
+ children: /*#__PURE__*/_jsx(RouteContext.Provider, {
39
+ value: context,
40
+ children: /*#__PURE__*/_jsx(Component, {})
41
+ }, "404")
42
+ }, "error.404");
43
+ };
44
+ return _createClass(RouteNotFound, [{
45
+ key: "currentRoute",
46
+ get:
47
+ /**
48
+ * @returns {Object}
49
+ */
50
+ function () {
51
+ const {
52
+ [router.routeIndex]: [, route]
53
+ } = this.context.stack;
54
+ return route;
55
+ }
56
+ }]);
57
+ }(React.Component);
47
58
  RouteNotFound.contextType = RouterContext;
48
59
  export default RouteNotFound;
@@ -1,3 +1,5 @@
1
+ import _createClass from "@babel/runtime/helpers/createClass";
2
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
3
  import React, { Suspense } from 'react';
2
4
  import PropTypes from 'prop-types';
3
5
  import { router } from '@virtuous/conductor';
@@ -9,29 +11,27 @@ import RouteNotFound from "./RouteNotFound";
9
11
  /**
10
12
  * The Route component.
11
13
  */
12
- class Route extends React.Component {
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ let Route = /*#__PURE__*/function (_React$Component) {
13
16
  /**
14
17
  * @param {Object} props The component props.
15
18
  */
16
- constructor(props) {
17
- super(props);
19
+ function Route(props) {
20
+ var _this;
21
+ _this = _React$Component.call(this, props) || this;
18
22
  router.register(props.pattern, props.transform);
23
+ return _this;
19
24
  }
20
25
 
21
26
  /**
22
27
  * TODO: Move to router
23
28
  */
24
- get currentRoute() {
25
- const {
26
- [router.routeIndex]: [, route]
27
- } = this.context.stack;
28
- return route;
29
- }
30
-
29
+ _inheritsLoose(Route, _React$Component);
30
+ var _proto = Route.prototype;
31
31
  /**
32
32
  * @returns {JSX}
33
33
  */
34
- render() {
34
+ _proto.render = function render() {
35
35
  const {
36
36
  cache,
37
37
  component: Component,
@@ -67,17 +67,27 @@ class Route extends React.Component {
67
67
  * to enforce re-remounting routes which where replaced by itself.
68
68
  */
69
69
  const replaceRouteId = context?.state?.replaceRouteId || '';
70
- return /*#__PURE__*/React.createElement(ErrorBoundary, {
71
- key: `error.${route.id}_${replaceRouteId}`
72
- }, /*#__PURE__*/React.createElement(RouteContext.Provider, {
73
- key: `${route.id}_${replaceRouteId}`,
74
- value: context
75
- }, /*#__PURE__*/React.createElement(Suspense, {
76
- fallback: /*#__PURE__*/React.createElement(Loading, null)
77
- }, /*#__PURE__*/React.createElement(Component, null))));
70
+ return /*#__PURE__*/_jsx(ErrorBoundary, {
71
+ children: /*#__PURE__*/_jsx(RouteContext.Provider, {
72
+ value: context,
73
+ children: /*#__PURE__*/_jsx(Suspense, {
74
+ fallback: /*#__PURE__*/_jsx(Loading, {}),
75
+ children: /*#__PURE__*/_jsx(Component, {})
76
+ })
77
+ }, `${route.id}_${replaceRouteId}`)
78
+ }, `error.${route.id}_${replaceRouteId}`);
78
79
  });
79
- }
80
- }
80
+ };
81
+ return _createClass(Route, [{
82
+ key: "currentRoute",
83
+ get: function () {
84
+ const {
85
+ [router.routeIndex]: [, route]
86
+ } = this.context.stack;
87
+ return route;
88
+ }
89
+ }]);
90
+ }(React.Component);
81
91
  Route.contextType = RouterContext;
82
92
  Route.NotFound = RouteNotFound;
83
93
  Route.defaultProps = {
@@ -1,3 +1,4 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
1
2
  import "core-js/modules/es.string.replace.js";
2
3
  import React from 'react';
3
4
  import PropTypes from 'prop-types';
@@ -16,6 +17,7 @@ import connect from "./connector";
16
17
  * Adds additional history listeners to compensate bugs and improve the behaviour within
17
18
  * browser environments.
18
19
  */
20
+ import { jsx as _jsx } from "react/jsx-runtime";
19
21
  const createBrowserListeners = () => {
20
22
  const {
21
23
  history
@@ -63,17 +65,18 @@ const createBrowserListeners = () => {
63
65
  /**
64
66
  * The Router component.
65
67
  */
66
- class Router extends React.Component {
68
+ let Router = /*#__PURE__*/function (_React$Component) {
67
69
  /**
68
70
  * @param {Object} props The component props.
69
71
  */
70
- constructor(props) {
71
- super(props);
72
+ function Router(props) {
73
+ var _this;
74
+ _this = _React$Component.call(this, props) || this;
72
75
  /**
73
76
  * Updates the user initialized component state
74
77
  */
75
- this.setUserInitialized = () => {
76
- this.setState({
78
+ _this.setUserInitialized = () => {
79
+ _this.setState({
77
80
  userInitialized: true
78
81
  });
79
82
  };
@@ -81,7 +84,7 @@ class Router extends React.Component {
81
84
  * Determines the current location from the browser history
82
85
  * @returns {string}
83
86
  */
84
- this.getHistoryLocation = () => {
87
+ _this.getHistoryLocation = () => {
85
88
  const {
86
89
  hash,
87
90
  pathname,
@@ -93,11 +96,11 @@ class Router extends React.Component {
93
96
  * Determines if the current route is a protected route
94
97
  * @returns {null|string}
95
98
  */
96
- this.getRouteProtector = () => authRoutes.getProtector(this.getHistoryLocation());
99
+ _this.getRouteProtector = () => authRoutes.getProtector(_this.getHistoryLocation());
97
100
  /**
98
101
  * @param {Object} data Data for the update method
99
102
  */
100
- this.update = data => {
103
+ _this.update = data => {
101
104
  const {
102
105
  prev,
103
106
  next
@@ -107,12 +110,12 @@ class Router extends React.Component {
107
110
  * The only change right now compared to the original component. When invoked for "onUpdate"
108
111
  * only the updated route is passed instead of an object with prev and next.
109
112
  */
110
- this.setState({
113
+ _this.setState({
111
114
  updated: Date.now()
112
115
  });
113
116
  return;
114
117
  }
115
- this.setState({
118
+ _this.setState({
116
119
  prev: prev ? prev.id : null,
117
120
  next: next.id,
118
121
  updated: Date.now()
@@ -121,22 +124,24 @@ class Router extends React.Component {
121
124
  if (typeof props.history === 'function') {
122
125
  router.constructor(props.history);
123
126
  }
124
- this.state = {
127
+ _this.contextValue = null;
128
+ _this.state = {
125
129
  prev: null,
126
130
  next: null,
127
131
  updated: null,
128
132
  userInitialized: false,
129
- initialRouteProtected: !!this.getRouteProtector()
133
+ initialRouteProtected: !!_this.getRouteProtector()
130
134
  };
131
- UIEvents.addListener(EVENT_USER_INITIALIZED, this.setUserInitialized);
132
- onDidPush(this.update);
133
- onDidPop(this.update);
134
- onDidReplace(this.update);
135
- onDidReset(this.update);
136
- onUpdate(this.update);
135
+ UIEvents.addListener(EVENT_USER_INITIALIZED, _this.setUserInitialized);
136
+ onDidPush(_this.update);
137
+ onDidPop(_this.update);
138
+ onDidReplace(_this.update);
139
+ onDidReset(_this.update);
140
+ onUpdate(_this.update);
137
141
  if (hasWebBridge() || hasSGJavaScriptBridge()) {
138
142
  createBrowserListeners();
139
143
  }
144
+ return _this;
140
145
  }
141
146
 
142
147
  /**
@@ -144,7 +149,9 @@ class Router extends React.Component {
144
149
  * @param {Object} nextState The next component state.
145
150
  * @returns {boolean}
146
151
  */
147
- shouldComponentUpdate(nextProps, nextState) {
152
+ _inheritsLoose(Router, _React$Component);
153
+ var _proto = Router.prototype;
154
+ _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
148
155
  const {
149
156
  isUserLoggedIn
150
157
  } = this.props;
@@ -159,8 +166,8 @@ class Router extends React.Component {
159
166
  * Replaces the initial route with a protector if necessary
160
167
  * @param {Object} nextProps The next component props
161
168
  * @param {Object} nextState The next components state
162
- */
163
- UNSAFE_componentWillUpdate(nextProps, nextState) {
169
+ */;
170
+ _proto.UNSAFE_componentWillUpdate = function UNSAFE_componentWillUpdate(nextProps, nextState) {
164
171
  const {
165
172
  isUserLoggedIn
166
173
  } = nextProps;
@@ -203,6 +210,8 @@ class Router extends React.Component {
203
210
  }
204
211
  }
205
212
  });
213
+
214
+ // eslint-disable-next-line react/no-will-update-set-state
206
215
  this.setState({
207
216
  initialRouteProtected: false
208
217
  });
@@ -211,14 +220,14 @@ class Router extends React.Component {
211
220
 
212
221
  /**
213
222
  * Removes the listener for the EVENT_USER_INITIALIZED event
214
- */
215
- componentWillUnmount() {
223
+ */;
224
+ _proto.componentWillUnmount = function componentWillUnmount() {
216
225
  UIEvents.removeListener(EVENT_USER_INITIALIZED, this.setUserInitialized);
217
- }
226
+ };
218
227
  /**
219
228
  * @returns {JSX}
220
229
  */
221
- render() {
230
+ _proto.render = function render() {
222
231
  const {
223
232
  children
224
233
  } = this.props;
@@ -236,15 +245,23 @@ class Router extends React.Component {
236
245
  return null;
237
246
  }
238
247
  const stack = Array.from(routeStack.getAll());
239
- return /*#__PURE__*/React.createElement(RouterContext.Provider, {
240
- value: {
241
- prev,
242
- next,
243
- stack
244
- }
245
- }, children);
246
- }
247
- }
248
+ const nextContextValue = {
249
+ prev,
250
+ next,
251
+ stack
252
+ };
253
+
254
+ // Only update the reference if something actually changed.
255
+ if (!this.contextValue || this.contextValue.prev !== prev || this.contextValue.next !== next || this.contextValue.stack !== stack) {
256
+ this.contextValue = nextContextValue;
257
+ }
258
+ return /*#__PURE__*/_jsx(RouterContext.Provider, {
259
+ value: this.contextValue,
260
+ children: children
261
+ });
262
+ };
263
+ return Router;
264
+ }(React.Component);
248
265
  Router.defaultProps = {
249
266
  history: null,
250
267
  isUserLoggedIn: false