@shopgate/pwa-common 7.30.0-alpha.7 → 7.30.0-alpha.8

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 (306) hide show
  1. package/App.js +48 -6
  2. package/action-creators/app/index.js +75 -12
  3. package/action-creators/app/spec.js +96 -1
  4. package/action-creators/client/index.js +27 -5
  5. package/action-creators/client/spec.js +44 -1
  6. package/action-creators/error/index.js +15 -3
  7. package/action-creators/index.js +9 -1
  8. package/action-creators/menu/index.js +23 -4
  9. package/action-creators/menu/spec.js +37 -1
  10. package/action-creators/modal/index.js +15 -3
  11. package/action-creators/modal/spec.js +26 -1
  12. package/action-creators/page/index.js +24 -4
  13. package/action-creators/page/spec.js +38 -1
  14. package/action-creators/router/index.js +48 -7
  15. package/action-creators/url/index.js +24 -4
  16. package/action-creators/url/spec.js +45 -1
  17. package/action-creators/user/index.js +90 -13
  18. package/action-creators/user/spec.js +186 -2
  19. package/actions/app/handleDeepLink.js +11 -2
  20. package/actions/app/handleLink.js +62 -6
  21. package/actions/app/handlePushNotification.js +32 -4
  22. package/actions/app/handleUniversalLink.js +11 -2
  23. package/actions/app/registerLinkEvents.js +24 -3
  24. package/actions/client/fetchClientInformation.js +26 -2
  25. package/actions/menu/fetchMenu.js +23 -2
  26. package/actions/modal/closeModal.js +18 -2
  27. package/actions/modal/promiseMap.js +3 -1
  28. package/actions/modal/showModal.js +54 -8
  29. package/actions/page/fetchPageConfig.js +69 -2
  30. package/actions/page/getPageConfig.js +6 -2
  31. package/actions/page/index.js +1 -1
  32. package/actions/router/historyPop.js +12 -2
  33. package/actions/router/historyPopToRoute.js +27 -2
  34. package/actions/router/historyPush.js +12 -2
  35. package/actions/router/historyRedirect.js +21 -2
  36. package/actions/router/historyReplace.js +20 -3
  37. package/actions/router/historyReset.js +11 -2
  38. package/actions/router/historyResetTo.js +12 -2
  39. package/actions/router/index.js +17 -1
  40. package/actions/router/routeDidPop.js +11 -2
  41. package/actions/router/routeDidPush.js +13 -2
  42. package/actions/router/routeDidReplace.js +11 -2
  43. package/actions/router/routeDidReset.js +11 -2
  44. package/actions/router/routeDidUpdate.js +10 -2
  45. package/actions/router/routeWillPop.js +11 -2
  46. package/actions/router/routeWillPush.js +13 -2
  47. package/actions/router/routeWillReplace.js +11 -2
  48. package/actions/router/routeWillReset.js +11 -2
  49. package/actions/router/windowOpenOverride.js +10 -2
  50. package/actions/user/fetchRegisterUrl.js +36 -2
  51. package/actions/user/fetchUser.js +29 -3
  52. package/actions/user/getUser.js +6 -2
  53. package/actions/user/index.js +1 -1
  54. package/actions/user/login.js +76 -9
  55. package/actions/user/logout.js +30 -2
  56. package/collections/AuthRoutes.js +73 -14
  57. package/collections/Configuration.js +54 -7
  58. package/collections/EmbeddedMedia.js +84 -11
  59. package/collections/PersistedReducers.js +41 -6
  60. package/collections/Redirects.js +103 -17
  61. package/collections/index.js +5 -1
  62. package/collections/media-providers/MediaProvider.js +151 -26
  63. package/collections/media-providers/Vimeo.js +113 -19
  64. package/collections/media-providers/YouTube.js +74 -14
  65. package/collections/media-providers/index.js +3 -1
  66. package/collections/media-providers/style.js +52 -2
  67. package/components/Backdrop/index.js +95 -6
  68. package/components/Backdrop/spec.js +23 -1
  69. package/components/Backdrop/style.js +11 -2
  70. package/components/Button/index.js +47 -5
  71. package/components/Button/spec.js +36 -1
  72. package/components/Button/style.js +6 -1
  73. package/components/Checkbox/index.js +126 -32
  74. package/components/Checkbox/spec.js +94 -3
  75. package/components/Consume/helpers/buildParams.js +13 -2
  76. package/components/Consume/index.js +14 -2
  77. package/components/CountdownTimer/index.js +115 -17
  78. package/components/CountdownTimer/spec.js +126 -12
  79. package/components/Drawer/index.js +131 -16
  80. package/components/Drawer/spec.js +76 -1
  81. package/components/Drawer/style.js +37 -1
  82. package/components/Dropdown/index.js +65 -6
  83. package/components/Dropdown/style.js +4 -1
  84. package/components/Dropdown/transitions.js +34 -1
  85. package/components/Ellipsis/index.js +16 -2
  86. package/components/Ellipsis/spec.js +13 -1
  87. package/components/EmbeddedMedia/index.js +56 -6
  88. package/components/EmbeddedMedia/spec.js +52 -3
  89. package/components/ErrorBoundary/connector.js +9 -2
  90. package/components/ErrorBoundary/index.js +43 -7
  91. package/components/Grid/components/Item/index.js +40 -4
  92. package/components/Grid/components/Item/spec.js +23 -1
  93. package/components/Grid/components/Item/style.js +17 -3
  94. package/components/Grid/index.js +36 -4
  95. package/components/Grid/spec.js +23 -1
  96. package/components/Grid/style.js +11 -2
  97. package/components/HtmlSanitizer/connector.js +24 -3
  98. package/components/HtmlSanitizer/index.js +104 -12
  99. package/components/HtmlSanitizer/spec.js +207 -6
  100. package/components/I18n/components/FormatDate/index.js +26 -2
  101. package/components/I18n/components/FormatDate/spec.js +46 -1
  102. package/components/I18n/components/FormatNumber/index.js +34 -2
  103. package/components/I18n/components/FormatNumber/spec.js +41 -2
  104. package/components/I18n/components/FormatPrice/index.js +32 -2
  105. package/components/I18n/components/FormatPrice/spec.js +46 -1
  106. package/components/I18n/components/FormatTime/index.js +26 -2
  107. package/components/I18n/components/FormatTime/spec.js +43 -2
  108. package/components/I18n/components/I18nProvider/index.js +52 -9
  109. package/components/I18n/components/I18nProvider/spec.js +39 -1
  110. package/components/I18n/components/Placeholder/index.js +8 -2
  111. package/components/I18n/components/Placeholder/spec.js +30 -1
  112. package/components/I18n/components/Translate/index.js +68 -7
  113. package/components/I18n/components/Translate/spec.js +30 -1
  114. package/components/I18n/index.js +16 -1
  115. package/components/Icon/index.js +25 -2
  116. package/components/Icon/style.js +6 -1
  117. package/components/Image/Image.js +176 -19
  118. package/components/Image/ImageInner.js +48 -2
  119. package/components/Image/index.js +1 -1
  120. package/components/Image/style.js +29 -2
  121. package/components/InfiniteContainer/index.js +381 -49
  122. package/components/InfiniteContainer/spec.js +199 -10
  123. package/components/Input/components/DateInput.js +262 -6
  124. package/components/Input/components/MultiLineInput.js +98 -12
  125. package/components/Input/components/SimpleInput.js +207 -31
  126. package/components/Input/index.js +32 -3
  127. package/components/Input/spec.js +122 -1
  128. package/components/KeyboardConsumer/index.js +48 -7
  129. package/components/Link/connector.js +7 -1
  130. package/components/Link/index.js +96 -11
  131. package/components/Link/spec.js +56 -1
  132. package/components/Link/style.js +10 -1
  133. package/components/List/components/Item/index.js +35 -3
  134. package/components/List/components/Item/style.js +16 -1
  135. package/components/List/index.js +20 -2
  136. package/components/List/spec.js +31 -1
  137. package/components/Loading/index.js +6 -2
  138. package/components/Modal/index.js +38 -3
  139. package/components/Modal/style.js +36 -1
  140. package/components/ModalContainer/connector.js +17 -3
  141. package/components/ModalContainer/index.js +36 -3
  142. package/components/ModalContainer/spec.js +105 -5
  143. package/components/Picker/components/Button/index.js +34 -2
  144. package/components/Picker/components/Button/style.js +19 -1
  145. package/components/Picker/components/List/index.js +33 -2
  146. package/components/Picker/components/List/style.js +17 -1
  147. package/components/Picker/components/Modal/index.js +60 -7
  148. package/components/Picker/components/Modal/style.js +78 -1
  149. package/components/Picker/index.js +167 -21
  150. package/components/Picker/spec.js +83 -2
  151. package/components/Portal/index.js +130 -19
  152. package/components/ProductCharacteristics/connector.js +33 -4
  153. package/components/ProductCharacteristics/context.js +2 -1
  154. package/components/ProductCharacteristics/helpers/index.js +135 -21
  155. package/components/ProductCharacteristics/index.js +266 -31
  156. package/components/RangeSlider/components/Handle/index.js +25 -2
  157. package/components/RangeSlider/components/Handle/style.js +14 -1
  158. package/components/RangeSlider/helper.js +43 -8
  159. package/components/RangeSlider/index.js +228 -38
  160. package/components/RangeSlider/style.js +14 -1
  161. package/components/Route/RouteNotFound.js +46 -3
  162. package/components/Route/index.js +78 -10
  163. package/components/Router/connector.js +9 -2
  164. package/components/Router/index.js +237 -31
  165. package/components/ScannerContainer/connector.js +9 -2
  166. package/components/ScannerContainer/index.js +42 -6
  167. package/components/Select/components/Item/index.js +20 -4
  168. package/components/Select/components/Item/style.js +4 -1
  169. package/components/Select/index.js +149 -28
  170. package/components/Select/spec.js +86 -2
  171. package/components/Select/style.js +17 -1
  172. package/components/SelectBox/components/Item/index.js +47 -5
  173. package/components/SelectBox/components/Item/style.js +7 -1
  174. package/components/SelectBox/index.js +173 -17
  175. package/components/SelectBox/spec.js +59 -3
  176. package/components/SelectBox/style.js +18 -1
  177. package/components/Slider/index.js +6 -2
  178. package/components/SurroundPortals/index.js +26 -2
  179. package/components/Swiper/components/SwiperItem/index.js +28 -4
  180. package/components/Swiper/components/SwiperItem/spec.js +17 -1
  181. package/components/Swiper/components/SwiperItem/styles.js +5 -1
  182. package/components/Swiper/index.js +210 -18
  183. package/components/Swiper/styles.js +75 -7
  184. package/components/Toaster/index.js +10 -2
  185. package/components/Transition/index.js +89 -13
  186. package/components/Widgets/components/Widget/index.js +52 -4
  187. package/components/Widgets/components/Widget/spec.js +68 -3
  188. package/components/Widgets/components/Widget/style.js +21 -3
  189. package/components/Widgets/components/WidgetGrid/index.js +52 -7
  190. package/components/Widgets/components/WidgetGrid/spec.js +46 -2
  191. package/components/Widgets/components/WidgetGrid/style.js +8 -1
  192. package/components/Widgets/helpers/shouldShowWidget.js +44 -7
  193. package/components/Widgets/index.js +127 -15
  194. package/components/Widgets/spec.js +213 -6
  195. package/components/index.js +9 -1
  196. package/constants/ActionTypes.js +97 -19
  197. package/constants/Configuration.js +12 -2
  198. package/constants/Device.js +29 -2
  199. package/constants/DisplayOptions.js +8 -1
  200. package/constants/MenuIDs.js +2 -1
  201. package/constants/ModalTypes.js +1 -1
  202. package/constants/PageIDs.js +1 -1
  203. package/constants/Pipelines.js +7 -1
  204. package/constants/Portals.js +136 -3
  205. package/constants/Registration.js +3 -1
  206. package/constants/RoutePaths.js +13 -2
  207. package/constants/Tracking.js +3 -1
  208. package/constants/client.js +6 -1
  209. package/constants/ui.js +2 -1
  210. package/constants/user.js +6 -2
  211. package/context/index.js +33 -3
  212. package/helpers/config/index.js +139 -21
  213. package/helpers/config/mock.js +200 -8
  214. package/helpers/config/theme.js +50 -4
  215. package/helpers/data/index.js +204 -29
  216. package/helpers/data/spec.js +187 -7
  217. package/helpers/date/index.js +58 -6
  218. package/helpers/date/spec.js +92 -1
  219. package/helpers/dom/index.js +48 -11
  220. package/helpers/environment/index.js +14 -2
  221. package/helpers/html/decodeHTML.js +7 -1
  222. package/helpers/html/handleDOM.js +172 -21
  223. package/helpers/html/parseHTML.js +67 -12
  224. package/helpers/i18n/getDateFormatter.js +23 -4
  225. package/helpers/i18n/getNumberFormatter.js +32 -4
  226. package/helpers/i18n/getPriceFormatter.js +38 -4
  227. package/helpers/i18n/getTimeFormatter.js +23 -4
  228. package/helpers/i18n/getTranslator.js +62 -8
  229. package/helpers/i18n/index.js +5 -1
  230. package/helpers/i18n/mergeTranslations.js +36 -9
  231. package/helpers/i18n/messageCache.js +3 -1
  232. package/helpers/legacy/index.js +47 -9
  233. package/helpers/modal/withShowModal.js +13 -2
  234. package/helpers/portals/portalCollection.js +28 -6
  235. package/helpers/portals/routePortals.js +12 -1
  236. package/helpers/redux/compareObjects.js +7 -2
  237. package/helpers/redux/generateResultHash.js +36 -3
  238. package/helpers/redux/generateSortedHash.js +7 -2
  239. package/helpers/redux/hasExpired.js +10 -2
  240. package/helpers/redux/index.js +7 -1
  241. package/helpers/redux/mutable.js +143 -24
  242. package/helpers/redux/shouldFetchData.js +46 -10
  243. package/helpers/redux/shouldFetchFilters.js +17 -4
  244. package/helpers/router/index.js +49 -5
  245. package/helpers/style/index.js +43 -4
  246. package/helpers/style/spec.js +108 -2
  247. package/helpers/tracking/index.js +52 -9
  248. package/helpers/validation/index.js +39 -12
  249. package/helpers/validation/spec.js +10 -1
  250. package/package.json +3 -3
  251. package/providers/index.js +4 -1
  252. package/providers/loading/context.js +2 -1
  253. package/providers/loading/index.js +137 -22
  254. package/providers/toast/context.js +2 -1
  255. package/providers/toast/index.js +105 -11
  256. package/reducers/client/connectivity.js +22 -2
  257. package/reducers/client/index.js +7 -1
  258. package/reducers/client/info.js +27 -2
  259. package/reducers/index.js +23 -4
  260. package/reducers/menu/index.js +5 -1
  261. package/reducers/menu/menusById.js +41 -2
  262. package/reducers/modal/index.js +14 -2
  263. package/reducers/page/index.js +68 -5
  264. package/reducers/router/index.js +48 -2
  265. package/reducers/url/index.js +42 -3
  266. package/reducers/user/data.js +27 -2
  267. package/reducers/user/index.js +7 -1
  268. package/reducers/user/login.js +65 -2
  269. package/selectors/client.js +138 -21
  270. package/selectors/history.js +49 -11
  271. package/selectors/menu.js +34 -6
  272. package/selectors/modal.js +15 -4
  273. package/selectors/page.js +25 -4
  274. package/selectors/router.js +154 -30
  275. package/selectors/url.js +25 -4
  276. package/selectors/user.js +90 -13
  277. package/store/index.js +60 -6
  278. package/store/middelwares/logger.js +7 -1
  279. package/store/middelwares/streams.js +19 -2
  280. package/streams/app.js +60 -8
  281. package/streams/client.js +8 -2
  282. package/streams/error.js +14 -3
  283. package/streams/index.js +6 -1
  284. package/streams/interval.js +6 -2
  285. package/streams/main.js +27 -2
  286. package/streams/router.js +45 -8
  287. package/streams/user.js +89 -15
  288. package/streams/view.js +97 -25
  289. package/styles/reset/form.js +57 -5
  290. package/styles/reset/index.js +6 -1
  291. package/styles/reset/media.js +22 -1
  292. package/styles/reset/root.js +33 -1
  293. package/styles/reset/table.js +10 -1
  294. package/styles/reset/typography.js +26 -1
  295. package/subscriptions/app.js +148 -17
  296. package/subscriptions/error.js +292 -13
  297. package/subscriptions/helpers/buildRegisterUrl.js +25 -6
  298. package/subscriptions/helpers/clearUpInAppBrowser.js +14 -3
  299. package/subscriptions/helpers/handleLinks.js +267 -25
  300. package/subscriptions/helpers/pipeline.js +12 -1
  301. package/subscriptions/history.js +34 -6
  302. package/subscriptions/index.js +25 -4
  303. package/subscriptions/menu.js +22 -5
  304. package/subscriptions/mock.js +39 -7
  305. package/subscriptions/router.js +336 -23
  306. package/subscriptions/user.js +93 -3
@@ -3,30 +3,55 @@
3
3
  * @param {number} relativeValue The relative value between [0...1].
4
4
  * @param {number} resolution The resolution, must be a value between [0,1...1].
5
5
  * @returns {number} The interpolated value.
6
- */var easeLinear=function easeLinear(relativeValue,resolution){var inverseResolution=1.0/resolution;return relativeValue*inverseResolution/inverseResolution;};/**
6
+ */
7
+ const easeLinear = (relativeValue, resolution) => {
8
+ const inverseResolution = 1.0 / resolution;
9
+ return relativeValue * inverseResolution / inverseResolution;
10
+ };
11
+
12
+ /**
7
13
  * Generates a linear easing callback.
8
14
  * @param {number} resolution The discrete step size.
9
15
  * @returns {Function} The generated callback.
10
- */export var generateLinearEasingCallback=function generateLinearEasingCallback(){var resolution=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0.1;return function(relativeValue){return easeLinear(relativeValue,resolution);};};/**
16
+ */
17
+ export const generateLinearEasingCallback = (resolution = 0.1) => relativeValue => easeLinear(relativeValue, resolution);
18
+
19
+ /**
11
20
  * The exponential easing callback.
12
21
  * @param {number} relativeValue The relative value between [0...1].
13
22
  * @param {number} factor The exponential scale factor.
14
23
  * @returns {number} The interpolated value.
15
- */var easeExponential=function easeExponential(relativeValue,factor){return Math.pow(relativeValue,factor);};/**
24
+ */
25
+ const easeExponential = (relativeValue, factor) => relativeValue ** factor;
26
+
27
+ /**
16
28
  * Generates an exponential easing callback.
17
29
  * @param {number} factor The exponential scale factor.
18
30
  * @returns {Function} The generated callback.
19
- */export var generateExponentialEasingCallback=function generateExponentialEasingCallback(){var factor=arguments.length>0&&arguments[0]!==undefined?arguments[0]:2.5;return function(relativeValue){return easeExponential(relativeValue,factor);};};/**
31
+ */
32
+ export const generateExponentialEasingCallback = (factor = 2.5) => relativeValue => easeExponential(relativeValue, factor);
33
+
34
+ /**
20
35
  * Converts a range of [0...1] into a style object.
21
36
  * @param {number} min A value in interval [0...1]
22
37
  * @param {number} max A value in interval [0...1]
23
38
  * @param {number} transitionDuration The duration of the transition.
24
39
  * @returns {Object} The generated style object
25
- */export var getRangeStyle=function getRangeStyle(min,max,transitionDuration){return{left:"".concat(Math.min(1,Math.max(0,min))*100,"%"),right:"".concat((1-Math.min(1,Math.max(0,max)))*100,"%"),transition:transitionDuration>0?"left ".concat(transitionDuration,"ms, right ").concat(transitionDuration,"ms"):null};};/**
40
+ */
41
+ export const getRangeStyle = (min, max, transitionDuration) => ({
42
+ left: `${Math.min(1, Math.max(0, min)) * 100}%`,
43
+ right: `${(1 - Math.min(1, Math.max(0, max))) * 100}%`,
44
+ transition: transitionDuration > 0 ? `left ${transitionDuration}ms, right ${transitionDuration}ms` : null
45
+ });
46
+
47
+ /**
26
48
  * Shortcut for retrieving x position of a touch event.
27
49
  * @param {TouchEvent} event The TouchEvent
28
50
  * @returns {number} The x position
29
- */export var getTouchPositionX=function getTouchPositionX(event){return event.touches[0].pageX;};/**
51
+ */
52
+ export const getTouchPositionX = event => event.touches[0].pageX;
53
+
54
+ /**
30
55
  * Converts a relative slider value into an absolute value.
31
56
  * A relative value is a value between [0...1] indicating the position
32
57
  * on the slider given its absolute width.
@@ -37,7 +62,13 @@
37
62
  * @param {number} max The maximum.
38
63
  * @param {boolean} allowRealValues Whether the value should be rounded to the nearest integer.
39
64
  * @returns {number} The converted absolute value.
40
- */export var getAbsoluteValue=function getAbsoluteValue(value,min,max){var allowRealValues=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;var result=min+(max-min)*value;return Math.min(max,Math.max(min,allowRealValues?result:Math.round(result)));};/**
65
+ */
66
+ export const getAbsoluteValue = (value, min, max, allowRealValues = false) => {
67
+ const result = min + (max - min) * value;
68
+ return Math.min(max, Math.max(min, allowRealValues ? result : Math.round(result)));
69
+ };
70
+
71
+ /**
41
72
  * Converts an absolute slider value into a relative value.
42
73
  * An absolute value is a value in screen space coordinates. This value must be
43
74
  * between [0...offsetWidth] of the price range slider.
@@ -47,4 +78,8 @@
47
78
  * @param {number} min The minimum.
48
79
  * @param {number} max The maximum.
49
80
  * @returns {number} The converted relative value.
50
- */export var getRelativeValue=function getRelativeValue(value,min,max){var result=(value-min)/(max-min);return Math.min(1,Math.max(0,result));};
81
+ */
82
+ export const getRelativeValue = (value, min, max) => {
83
+ const result = (value - min) / (max - min);
84
+ return Math.min(1, Math.max(0, result));
85
+ };
@@ -1,58 +1,248 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import{logger}from'@shopgate/pwa-core/helpers';import styles from"./style";import RangeSliderHandle from"./components/Handle";import{generateLinearEasingCallback,generateExponentialEasingCallback,getRangeStyle,getTouchPositionX,getAbsoluteValue,getRelativeValue}from"./helper";/**
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { logger } from '@shopgate/pwa-core/helpers';
4
+ import styles from "./style";
5
+ import RangeSliderHandle from "./components/Handle";
6
+ import { generateLinearEasingCallback, generateExponentialEasingCallback, getRangeStyle, getTouchPositionX, getAbsoluteValue, getRelativeValue } from "./helper";
7
+
8
+ /**
2
9
  * The range slider component.
3
10
  * @deprecated Will be remove in v7.0.0.
4
11
  * Please use `import { RangeSlider } from '@shopgate/engage/components'` instead.
5
- */var RangeSlider=/*#__PURE__*/function(_Component){/**
12
+ */
13
+ class RangeSlider extends Component {
14
+ /**
6
15
  * Constructor
7
16
  * @param {Object} props The component properties
8
- */function RangeSlider(props){var _this2;_classCallCheck(this,RangeSlider);_this2=_callSuper(this,RangeSlider,[props]);/**
9
- * Processes touch start events on handles.
10
- * @param {Object} event The touch event
11
- * @param {number} index The index of the touched handle.
12
- */_defineProperty(_this2,"handleTouchStart",function(event,index){_this2.draggedHandle=index;// Calculate the relative offset to the handles center
13
- var handleDOMElement=event.target;// Get the handles bounding rectangle ...
14
- var handleRect=handleDOMElement.getBoundingClientRect();// ... and calculate its absolute center.
15
- var handleCenterX=handleRect.left+handleDOMElement.offsetWidth/2;// Store the signed distanced between the current touch offset and the handle center.
16
- _this2.touchOffset=getTouchPositionX(event)-handleCenterX;});/**
17
- * Processes move events on handles.
18
- * @param {Object} event The touch event
19
- */_defineProperty(_this2,"handleTouchMove",function(event){if(_this2.props.min===_this2.props.max){return;}if(_this2.draggedHandle===null){return;}var _this2$domElement=_this2.domElement,offsetWidth=_this2$domElement.offsetWidth,offsetLeft=_this2$domElement.offsetLeft;// Calculate the absolute offset where the element was touched...
20
- var deltaX=getTouchPositionX(event)-offsetLeft-_this2.touchOffset;// ...and convert it into a relative value between [0...1].
21
- deltaX=Math.max(0,Math.min(1,deltaX/offsetWidth));var stateUpdate={};if(_this2.draggedHandle===1){// Right handle dragged
22
- if(_this2.state.rangeMin<deltaX){stateUpdate.rangeMax=Math.min(1,deltaX);_this2.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMax-_this2.state.rangeMax);}else{// Not in valid range, swap handles
23
- _this2.draggedHandle=0;stateUpdate.rangeMax=_this2.state.rangeMin;stateUpdate.rangeMin=deltaX;_this2.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMin-_this2.state.rangeMin);}}else if(_this2.draggedHandle===0){// Left handle dragged
24
- if(_this2.state.rangeMax>deltaX){stateUpdate.rangeMin=Math.max(0,deltaX);_this2.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMin-_this2.state.rangeMin);}else{// Not in valid range, swap handles
25
- _this2.draggedHandle=1;stateUpdate.rangeMin=_this2.state.rangeMax;stateUpdate.rangeMax=deltaX;_this2.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMax-_this2.state.rangeMax);}}_this2.draggedHandlePixelOffset*=_this2.domElement.offsetWidth;_this2.setState(stateUpdate,_this2.triggerChangeCallback);});/**
26
- * Processes global touch end events for handles.
27
- * @param {Object} e The touch event
28
- */_defineProperty(_this2,"handleTouchEnd",function(){_this2.touchOffset=0;_this2.draggedHandle=null;});/**
29
- * Processes outer range touch end events.
30
- * @param {Object} event The touch event
31
- */_defineProperty(_this2,"handleRangeTouch",function(event){var _this2$domElement2=_this2.domElement,offsetWidth=_this2$domElement2.offsetWidth,offsetLeft=_this2$domElement2.offsetLeft;var dx=(getTouchPositionX(event)-offsetLeft)/offsetWidth;var d0=Math.abs(_this2.state.rangeMin-dx);var d1=Math.abs(_this2.state.rangeMax-dx);if(d0<d1){_this2.draggedHandle=0;}else{_this2.draggedHandle=1;}_this2.handleTouchMove(event);});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===================================');_this2.draggedHandle=null;// 0 for left handle, 1 for right handle or null
32
- _this2.domElement=null;_this2.touchOffset=0;_this2.draggedHandlePixelOffset=0;// The absolute pixel delta of the last handle move event.
33
- _this2.state=_this2.getRange(props);return _this2;}/**
17
+ */
18
+ constructor(props) {
19
+ super(props);
20
+ /**
21
+ * Processes touch start events on handles.
22
+ * @param {Object} event The touch event
23
+ * @param {number} index The index of the touched handle.
24
+ */
25
+ this.handleTouchStart = (event, index) => {
26
+ this.draggedHandle = index;
27
+
28
+ // Calculate the relative offset to the handles center
29
+ const handleDOMElement = event.target;
30
+ // Get the handles bounding rectangle ...
31
+ const handleRect = handleDOMElement.getBoundingClientRect();
32
+ // ... and calculate its absolute center.
33
+ const handleCenterX = handleRect.left + handleDOMElement.offsetWidth / 2;
34
+ // Store the signed distanced between the current touch offset and the handle center.
35
+ this.touchOffset = getTouchPositionX(event) - handleCenterX;
36
+ };
37
+ /**
38
+ * Processes move events on handles.
39
+ * @param {Object} event The touch event
40
+ */
41
+ this.handleTouchMove = event => {
42
+ if (this.props.min === this.props.max) {
43
+ return;
44
+ }
45
+ if (this.draggedHandle === null) {
46
+ return;
47
+ }
48
+ const {
49
+ offsetWidth,
50
+ offsetLeft
51
+ } = this.domElement;
52
+ // Calculate the absolute offset where the element was touched...
53
+ let deltaX = getTouchPositionX(event) - offsetLeft - this.touchOffset;
54
+
55
+ // ...and convert it into a relative value between [0...1].
56
+ deltaX = Math.max(0, Math.min(1, deltaX / offsetWidth));
57
+ const stateUpdate = {};
58
+ if (this.draggedHandle === 1) {
59
+ // Right handle dragged
60
+ if (this.state.rangeMin < deltaX) {
61
+ stateUpdate.rangeMax = Math.min(1, deltaX);
62
+ this.draggedHandlePixelOffset = Math.abs(stateUpdate.rangeMax - this.state.rangeMax);
63
+ } else {
64
+ // Not in valid range, swap handles
65
+ this.draggedHandle = 0;
66
+ stateUpdate.rangeMax = this.state.rangeMin;
67
+ stateUpdate.rangeMin = deltaX;
68
+ this.draggedHandlePixelOffset = Math.abs(stateUpdate.rangeMin - this.state.rangeMin);
69
+ }
70
+ } else if (this.draggedHandle === 0) {
71
+ // Left handle dragged
72
+ if (this.state.rangeMax > deltaX) {
73
+ stateUpdate.rangeMin = Math.max(0, deltaX);
74
+ this.draggedHandlePixelOffset = Math.abs(stateUpdate.rangeMin - this.state.rangeMin);
75
+ } else {
76
+ // Not in valid range, swap handles
77
+ this.draggedHandle = 1;
78
+ stateUpdate.rangeMin = this.state.rangeMax;
79
+ stateUpdate.rangeMax = deltaX;
80
+ this.draggedHandlePixelOffset = Math.abs(stateUpdate.rangeMax - this.state.rangeMax);
81
+ }
82
+ }
83
+ this.draggedHandlePixelOffset *= this.domElement.offsetWidth;
84
+ this.setState(stateUpdate, this.triggerChangeCallback);
85
+ };
86
+ /**
87
+ * Processes global touch end events for handles.
88
+ * @param {Object} e The touch event
89
+ */
90
+ this.handleTouchEnd = () => {
91
+ this.touchOffset = 0;
92
+ this.draggedHandle = null;
93
+ };
94
+ /**
95
+ * Processes outer range touch end events.
96
+ * @param {Object} event The touch event
97
+ */
98
+ this.handleRangeTouch = event => {
99
+ const {
100
+ offsetWidth,
101
+ offsetLeft
102
+ } = this.domElement;
103
+ const dx = (getTouchPositionX(event) - offsetLeft) / offsetWidth;
104
+ const d0 = Math.abs(this.state.rangeMin - dx);
105
+ const d1 = Math.abs(this.state.rangeMax - dx);
106
+ if (d0 < d1) {
107
+ this.draggedHandle = 0;
108
+ } else {
109
+ this.draggedHandle = 1;
110
+ }
111
+ this.handleTouchMove(event);
112
+ };
113
+ 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
+
119
+ this.state = this.getRange(props);
120
+ }
121
+
122
+ /**
34
123
  * Sets the global event listeners when component mounts.
35
- */_inherits(RangeSlider,_Component);return _createClass(RangeSlider,[{key:"componentDidMount",value:function componentDidMount(){document.addEventListener('touchend',this.handleTouchEnd);document.addEventListener('touchmove',this.handleTouchMove);}/**
124
+ */
125
+ componentDidMount() {
126
+ document.addEventListener('touchend', this.handleTouchEnd);
127
+ document.addEventListener('touchmove', this.handleTouchMove);
128
+ }
129
+
130
+ /**
36
131
  * Updates the component properties.
37
132
  * @param {Object} newProps The new component properties.
38
- */},{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(newProps){this.setState(this.getRange(newProps));}/**
133
+ */
134
+ UNSAFE_componentWillReceiveProps(newProps) {
135
+ this.setState(this.getRange(newProps));
136
+ }
137
+
138
+ /**
39
139
  * Removes the global event listeners when component unmounts.
40
- */},{key:"componentWillUnmount",value:function componentWillUnmount(){document.removeEventListener('touchend',this.handleTouchEnd);document.removeEventListener('touchmove',this.handleTouchMove);}/**
140
+ */
141
+ componentWillUnmount() {
142
+ document.removeEventListener('touchend', this.handleTouchEnd);
143
+ document.removeEventListener('touchmove', this.handleTouchMove);
144
+ }
145
+
146
+ /**
41
147
  * Get the easing function.
42
- */},{key:"ease",get:function get(){return{linear:generateLinearEasingCallback(this.props.resolution),exponential:generateExponentialEasingCallback(this.props.factor)}[this.props.easing];}/**
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
+ /**
43
157
  * Get the function to invert an eased value to it's original value.
44
- */},{key:"invertedEase",get:function get(){return{linear:generateLinearEasingCallback(this.props.resolution),exponential:generateExponentialEasingCallback(1/this.props.factor)}[this.props.easing];}/**
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
+
166
+ /**
45
167
  * Get range min and max from props.
46
168
  * @param {Object} props The component props.
47
169
  * @returns {Object} The new state
48
- */},{key:"getRange",value:function getRange(props){var value=props.value,min=props.min,max=props.max;return{rangeMin:this.invertedEase(getRelativeValue(value[0],min,max)),rangeMax:this.invertedEase(getRelativeValue(value[1],min,max))};}},{key:"triggerChangeCallback",value:/**
170
+ */
171
+ getRange(props) {
172
+ const {
173
+ value,
174
+ min,
175
+ max
176
+ } = props;
177
+ return {
178
+ rangeMin: this.invertedEase(getRelativeValue(value[0], min, max)),
179
+ rangeMax: this.invertedEase(getRelativeValue(value[1], min, max))
180
+ };
181
+ }
182
+ /**
49
183
  * Calls the change callback in case of a state update.
50
- */function triggerChangeCallback(){var _this$props=this.props,value=_this$props.value,onChange=_this$props.onChange,min=_this$props.min,max=_this$props.max;if(!onChange){return;}var newRange=[getAbsoluteValue(this.ease(this.state.rangeMin),min,max,true),getAbsoluteValue(this.ease(this.state.rangeMax),min,max,true)];if(newRange!==value){onChange(newRange);}}/**
184
+ */
185
+ triggerChangeCallback() {
186
+ const {
187
+ value,
188
+ onChange,
189
+ min,
190
+ max
191
+ } = this.props;
192
+ if (!onChange) {
193
+ return;
194
+ }
195
+ const newRange = [getAbsoluteValue(this.ease(this.state.rangeMin), min, max, true), getAbsoluteValue(this.ease(this.state.rangeMax), min, max, true)];
196
+ if (newRange !== value) {
197
+ onChange(newRange);
198
+ }
199
+ }
200
+
201
+ /**
51
202
  * Creates a new handle component.
52
203
  * @param {number} index The index of the component. Must be either 0 or 1.
53
204
  * @returns {JSX}
54
- */},{key:"makeHandle",value:function makeHandle(index){return React.createElement(RangeSliderHandle,{index:index,onTouchStart:this.handleTouchStart,active:this.draggedHandle===index,classNames:this.props.classNames});}/**
205
+ */
206
+ makeHandle(index) {
207
+ return /*#__PURE__*/React.createElement(RangeSliderHandle, {
208
+ index: index,
209
+ onTouchStart: this.handleTouchStart,
210
+ active: this.draggedHandle === index,
211
+ classNames: this.props.classNames
212
+ });
213
+ }
214
+
215
+ /**
55
216
  * Renders the component.
56
217
  * @returns {JSX}
57
- */},{key:"render",value:function render(){var _this3=this;// Calculate the animation speed.
58
- var animationSpeed=Math.round(1000/this.props.animationSpeed*this.draggedHandlePixelOffset);var rangeStyle=getRangeStyle(this.state.rangeMin,this.state.rangeMax,animationSpeed>10?animationSpeed:0);return React.createElement("div",{className:"".concat(this.props.classNames.container||''," common__range-slider"),onTouchStart:this.handleRangeTouch},React.createElement("div",{className:"".concat(this.props.classNames.outerRange||''," ").concat(styles.outerRange),ref:function ref(_ref){_this3.domElement=_ref;}},React.createElement("div",{className:"".concat(this.props.classNames.range||''," ").concat(styles.range),style:rangeStyle},this.makeHandle(0),this.makeHandle(1))));}}]);}(Component);_defineProperty(RangeSlider,"defaultProps",{animationSpeed:500,classNames:{},easing:'linear',factor:2,max:100,min:0,resolution:1,value:[0,100],onChange:null});export default RangeSlider;
218
+ */
219
+ render() {
220
+ // Calculate the animation speed.
221
+ const animationSpeed = Math.round(1000 / this.props.animationSpeed * this.draggedHandlePixelOffset);
222
+ const rangeStyle = getRangeStyle(this.state.rangeMin, this.state.rangeMax, animationSpeed > 10 ? animationSpeed : 0);
223
+ return /*#__PURE__*/React.createElement("div", {
224
+ 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
+ }
237
+ RangeSlider.defaultProps = {
238
+ animationSpeed: 500,
239
+ classNames: {},
240
+ easing: 'linear',
241
+ factor: 2,
242
+ max: 100,
243
+ min: 0,
244
+ resolution: 1,
245
+ value: [0, 100],
246
+ onChange: null
247
+ };
248
+ export default RangeSlider;
@@ -1 +1,14 @@
1
- import{css}from'glamor';var outerRange=css({minHeight:1,position:'relative'}).toString();var range=css({left:0,right:0,position:'absolute'}).toString();export default{outerRange:outerRange,range:range};
1
+ import { css } from 'glamor';
2
+ const outerRange = css({
3
+ minHeight: 1,
4
+ position: 'relative'
5
+ }).toString();
6
+ const range = css({
7
+ left: 0,
8
+ right: 0,
9
+ position: 'absolute'
10
+ }).toString();
11
+ export default {
12
+ outerRange,
13
+ range
14
+ };
@@ -1,5 +1,48 @@
1
- var _excluded=["setPattern"];function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React from'react';import PropTypes from'prop-types';import{router}from'@virtuous/conductor';import{RouteContext,RouterContext}from'@virtuous/react-conductor';import ErrorBoundary from"../ErrorBoundary";/**
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { router } from '@virtuous/conductor';
4
+ import { RouteContext, RouterContext } from '@virtuous/react-conductor';
5
+ import ErrorBoundary from "../ErrorBoundary";
6
+
7
+ /**
2
8
  * The RouteNotFound component
3
- */var RouteNotFound=/*#__PURE__*/function(_React$Component){function RouteNotFound(){_classCallCheck(this,RouteNotFound);return _callSuper(this,RouteNotFound,arguments);}_inherits(RouteNotFound,_React$Component);return _createClass(RouteNotFound,[{key:"currentRoute",get:function get(){var _this$context$stack$r=_slicedToArray(this.context.stack[router.routeIndex],2),route=_this$context$stack$r[1];return route;}/**
9
+ */
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;
19
+ }
20
+
21
+ /**
4
22
  * @returns {JSX}
5
- */},{key:"render",value:function render(){if(router.match(this.currentRoute.pathname)){return null;}var Component=this.props.component;var _this$currentRoute=this.currentRoute,setPattern=_this$currentRoute.setPattern,context=_objectWithoutProperties(_this$currentRoute,_excluded);context.open=true;context.visible=true;context.pattern='';context.is404=true;return React.createElement(ErrorBoundary,{key:"error.404"},React.createElement(RouteContext.Provider,{key:"404",value:context},React.createElement(Component,null)));}}]);}(React.Component);_defineProperty(RouteNotFound,"contextType",RouterContext);export default RouteNotFound;
23
+ */
24
+ render() {
25
+ if (router.match(this.currentRoute.pathname)) {
26
+ return null;
27
+ }
28
+ const {
29
+ component: Component
30
+ } = this.props;
31
+ const {
32
+ setPattern,
33
+ ...context
34
+ } = this.currentRoute;
35
+ context.open = true;
36
+ context.visible = true;
37
+ context.pattern = '';
38
+ 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
+ }
47
+ RouteNotFound.contextType = RouterContext;
48
+ export default RouteNotFound;
@@ -1,19 +1,87 @@
1
- var _excluded=["setPattern"];function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Suspense}from'react';import PropTypes from'prop-types';import{router}from'@virtuous/conductor';import{RouteContext,RouterContext}from'@virtuous/react-conductor';import Loading from"../Loading";import ErrorBoundary from"../ErrorBoundary";import RouteNotFound from"./RouteNotFound";/**
1
+ import React, { Suspense } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { router } from '@virtuous/conductor';
4
+ import { RouteContext, RouterContext } from '@virtuous/react-conductor';
5
+ import Loading from "../Loading";
6
+ import ErrorBoundary from "../ErrorBoundary";
7
+ import RouteNotFound from "./RouteNotFound";
8
+
9
+ /**
2
10
  * The Route component.
3
- */var Route=/*#__PURE__*/function(_React$Component){function Route(props){var _this2;_classCallCheck(this,Route);_this2=_callSuper(this,Route,[props]);router.register(props.pattern,props.transform);return _this2;}/**
11
+ */
12
+ class Route extends React.Component {
13
+ /**
14
+ * @param {Object} props The component props.
15
+ */
16
+ constructor(props) {
17
+ super(props);
18
+ router.register(props.pattern, props.transform);
19
+ }
20
+
21
+ /**
4
22
  * TODO: Move to router
5
- */_inherits(Route,_React$Component);return _createClass(Route,[{key:"currentRoute",get:function get(){var _this$context$stack$r=_slicedToArray(this.context.stack[router.routeIndex],2),route=_this$context$stack$r[1];return route;}/**
23
+ */
24
+ get currentRoute() {
25
+ const {
26
+ [router.routeIndex]: [, route]
27
+ } = this.context.stack;
28
+ return route;
29
+ }
30
+
31
+ /**
6
32
  * @returns {JSX}
7
- */},{key:"render",value:function render(){var _this3=this;var _this$props=this.props,cache=_this$props.cache,Component=_this$props.component,pattern=_this$props.pattern;var matches=[];// If the current pattern does not match the whitelist but matches the current route
8
- // then add the current route as the only match.
9
- if(!cache&&pattern===this.currentRoute.pattern){matches=[[this.currentRoute.id,this.currentRoute]];}else if(cache){var subset=this.context.stack.slice(0,router.routeIndex+1);// Find matching patterns.
10
- matches=subset.filter(function(_ref){var _ref2=_slicedToArray(_ref,2),route=_ref2[1];return route.pattern===pattern;});}if(!matches.length){return null;}return matches.map(function(_ref3){var _context$state;var _ref4=_slicedToArray(_ref3,2),route=_ref4[1];var setPattern=route.setPattern,context=_objectWithoutProperties(route,_excluded);context.open=true;context.visible=route.id===_this3.currentRoute.id;/**
33
+ */
34
+ render() {
35
+ const {
36
+ cache,
37
+ component: Component,
38
+ pattern
39
+ } = this.props;
40
+ let matches = [];
41
+
42
+ // If the current pattern does not match the whitelist but matches the current route
43
+ // then add the current route as the only match.
44
+ if (!cache && pattern === this.currentRoute.pattern) {
45
+ matches = [[this.currentRoute.id, this.currentRoute]];
46
+ } else if (cache) {
47
+ const subset = this.context.stack.slice(0, router.routeIndex + 1);
48
+ // Find matching patterns.
49
+ matches = subset.filter(([, route]) => route.pattern === pattern);
50
+ }
51
+ if (!matches.length) {
52
+ return null;
53
+ }
54
+ return matches.map(([, route]) => {
55
+ const {
56
+ setPattern,
57
+ ...context
58
+ } = route;
59
+ context.open = true;
60
+ context.visible = route.id === this.currentRoute.id;
61
+ /**
11
62
  * When a route is "replaced" the router doesn't assign a new route id to the old route
12
63
  * stack entry. This can cause issues when a route is replaced by itself, since the content
13
64
  * will not remount out of the box.
14
65
  *
15
66
  * The "replaceRouteId" state prop is injected by the "historyReplace" action. It's used
16
67
  * to enforce re-remounting routes which where replaced by itself.
17
- */var replaceRouteId=(context===null||context===void 0?void 0:(_context$state=context.state)===null||_context$state===void 0?void 0:_context$state.replaceRouteId)||'';return React.createElement(ErrorBoundary,{key:"error.".concat(route.id,"_").concat(replaceRouteId)},React.createElement(RouteContext.Provider,{key:"".concat(route.id,"_").concat(replaceRouteId),value:context},React.createElement(Suspense,{fallback:React.createElement(Loading,null)},React.createElement(Component,null))));});}}]);}(React.Component);_defineProperty(Route,"contextType",RouterContext);_defineProperty(Route,"NotFound",RouteNotFound);_defineProperty(Route,"defaultProps",{cache:false,transform:null/**
18
- * @param {Object} props The component props.
19
- */});export default Route;
68
+ */
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))));
78
+ });
79
+ }
80
+ }
81
+ Route.contextType = RouterContext;
82
+ Route.NotFound = RouteNotFound;
83
+ Route.defaultProps = {
84
+ cache: false,
85
+ transform: null
86
+ };
87
+ export default Route;
@@ -1,4 +1,11 @@
1
- import{connect}from'react-redux';import{isUserLoggedIn}from"../../selectors/user";/**
1
+ import { connect } from 'react-redux';
2
+ import { isUserLoggedIn } from "../../selectors/user";
3
+
4
+ /**
2
5
  * @param {Object} state The current application state.
3
6
  * @return {Object} The extended component props.
4
- */var mapStateToProps=function mapStateToProps(state){return{isUserLoggedIn:isUserLoggedIn(state)};};export default connect(mapStateToProps);
7
+ */
8
+ const mapStateToProps = state => ({
9
+ isUserLoggedIn: isUserLoggedIn(state)
10
+ });
11
+ export default connect(mapStateToProps);