@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
@@ -1,39 +1,66 @@
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);}/**
1
+ /**
2
2
  * Tests if the prop is an array-object.
3
3
  * @param {*} prop The property to test.
4
4
  * @return {boolean}
5
- */export var isArray=function isArray(prop){return _typeof(prop)==='object'&&prop!==null&&prop.constructor===Array;};/**
5
+ */
6
+ export const isArray = prop => typeof prop === 'object' && prop !== null && prop.constructor === Array;
7
+
8
+ /**
6
9
  * Tests if the prop is an object.
7
10
  * @param {*} prop The property to test.
8
11
  * @return {boolean}
9
- */export var isObject=function isObject(prop){return _typeof(prop)==='object'&&prop!==null&&prop.constructor===Object;};/**
12
+ */
13
+ export const isObject = prop => typeof prop === 'object' && prop !== null && prop.constructor === Object;
14
+
15
+ /**
10
16
  * Checks if a passed value is numeric.
11
17
  * @param {*} prop The property to test.
12
18
  * @return {boolean}
13
- */export var isNumeric=function isNumeric(prop){return(// eslint-disable-next-line no-restricted-globals
14
- !Number.isNaN(parseFloat(prop))&&isFinite(prop));};/**
19
+ */
20
+ export const isNumeric = prop =>
21
+ // eslint-disable-next-line no-restricted-globals
22
+ !Number.isNaN(parseFloat(prop)) && isFinite(prop);
23
+
24
+ /**
15
25
  * Tests if the prop is a number.
16
26
  * @param {*} prop The property to test.
17
27
  * @return {boolean}
18
- */export var isNumber=function isNumber(prop){return(// eslint-disable-next-line no-restricted-globals
19
- typeof prop==='number'&&isFinite(prop));};/**
28
+ */
29
+ export const isNumber = prop =>
30
+ // eslint-disable-next-line no-restricted-globals
31
+ typeof prop === 'number' && isFinite(prop);
32
+
33
+ /**
20
34
  * Tests if the prop is an integer.
21
35
  * @param {*} prop The property to test.
22
36
  * @return {boolean}
23
- */export var isInteger=function isInteger(prop){return isNumber(prop)&&prop%1===0;};/**
37
+ */
38
+ export const isInteger = prop => isNumber(prop) && prop % 1 === 0;
39
+
40
+ /**
24
41
  * Tests if the prop is boolean.
25
42
  * @param {*} prop The property to test.
26
43
  * @return {boolean}
27
- */export var isBoolean=function isBoolean(prop){return typeof prop==='boolean';};/**
44
+ */
45
+ export const isBoolean = prop => typeof prop === 'boolean';
46
+
47
+ /**
28
48
  * Tests if the prop is function.
29
49
  * @param {*} prop The property to test.
30
50
  * @return {boolean}
31
- */export var isFunction=function isFunction(prop){return typeof prop==='function';};/**
51
+ */
52
+ export const isFunction = prop => typeof prop === 'function';
53
+
54
+ /**
32
55
  * Tests if the prop is undefined.
33
56
  * @param {*} prop The property to test.
34
57
  * @return {boolean}
35
- */export var isUndefined=function isUndefined(prop){return typeof prop==='undefined';};/**
58
+ */
59
+ export const isUndefined = prop => typeof prop === 'undefined';
60
+
61
+ /**
36
62
  * Tests if the prop is a promise.
37
63
  * @param {*} prop The property to test.
38
64
  * @return {boolean}
39
- */export var isPromise=function isPromise(prop){return prop!==null&&(_typeof(prop)==='object'||typeof prop==='function')&&typeof prop.then==='function';};
65
+ */
66
+ export const isPromise = prop => prop !== null && (typeof prop === 'object' || typeof prop === 'function') && typeof prop.then === 'function';
@@ -1 +1,10 @@
1
- import{isNumeric}from"./index";describe('helpers/validation',function(){describe('isNumeric',function(){describe('Non-regression, "123" is not numeric',function(){it('should treat numeric number as numeric',function(){expect(isNumeric('123')).toBe(true);});});});});
1
+ import { isNumeric } from "./index";
2
+ describe('helpers/validation', () => {
3
+ describe('isNumeric', () => {
4
+ describe('Non-regression, "123" is not numeric', () => {
5
+ it('should treat numeric number as numeric', () => {
6
+ expect(isNumeric('123')).toBe(true);
7
+ });
8
+ });
9
+ });
10
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-common",
3
- "version": "7.30.0-alpha.7",
3
+ "version": "7.30.0-alpha.8",
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.7",
20
+ "@shopgate/pwa-benchmark": "7.30.0-alpha.8",
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",
@@ -42,7 +42,7 @@
42
42
  "url-search-params": "^0.10.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@shopgate/pwa-core": "7.30.0-alpha.7",
45
+ "@shopgate/pwa-core": "7.30.0-alpha.8",
46
46
  "@types/react-portal": "^3.0.9",
47
47
  "lodash": "^4.17.21",
48
48
  "prop-types": "~15.8.1",
@@ -1 +1,4 @@
1
- export{default as LoadingProvider}from"./loading";export{default as LoadingContext}from"./loading/context";export{default as ToastProvider}from"./toast";export{default as ToastContext}from"./toast/context";
1
+ export { default as LoadingProvider } from "./loading";
2
+ export { default as LoadingContext } from "./loading/context";
3
+ export { default as ToastProvider } from "./toast";
4
+ export { default as ToastContext } from "./toast/context";
@@ -1 +1,2 @@
1
- import React from'react';export default React.createContext();
1
+ import React from 'react';
2
+ export default /*#__PURE__*/React.createContext();
@@ -1,31 +1,146 @@
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 _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 _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return _typeof(key)==="symbol"?key:String(key);}function _toPrimitive(input,hint){if(_typeof(input)!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(_typeof(res)!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return(hint==="string"?String:Number)(input);}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}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{UIEvents}from'@shopgate/pwa-core';import LoadingContext from"./context";/**
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { UIEvents } from '@shopgate/pwa-core';
4
+ import LoadingContext from "./context";
5
+
6
+ /**
2
7
  * The LoadingProvider component.
3
- */var LoadingProvider=/*#__PURE__*/function(_Component){/**
4
- * @param {Object} props The component props.
5
- */function LoadingProvider(props){var _this2;_classCallCheck(this,LoadingProvider);_this2=_callSuper(this,LoadingProvider,[props]);/**
8
+ */
9
+ class LoadingProvider extends Component {
10
+ /**
6
11
  * Adds or increases the loading counter for a path.
7
12
  * @param {string} path The path which loads.
8
- */_defineProperty(_this2,"setLoading",function(path){var _this3=_this2,loading=_this3.loading;var newLoading=_extends({},loading,_defineProperty({},path,loading[path]?loading[path]+1:1));// Immediately updates state due to multiple sets before actual rerender.
9
- _this2.loading=newLoading;_this2.setState({loading:newLoading});});/**
13
+ */
14
+ static setLoading(path) {
15
+ UIEvents.emit(LoadingProvider.SET, path);
16
+ }
17
+
18
+ /**
10
19
  * Resets the loading counter for a path.
11
20
  * @param {string} path The path which loads.
12
- */_defineProperty(_this2,"resetLoading",function(path){var _this2$loading=_this2.loading,removedPath=_this2$loading[path],remaining=_objectWithoutProperties(_this2$loading,[path].map(_toPropertyKey));// Immediately updates state due to multiple sets before actual rerender.
13
- _this2.loading=remaining;_this2.setState({loading:remaining});});/**
21
+ */
22
+ static resetLoading(path) {
23
+ UIEvents.emit(LoadingProvider.RESET, path);
24
+ }
25
+
26
+ /**
14
27
  * Decreases the loading counter for a path.
15
28
  * @param {string} path The path which loads.
16
- */_defineProperty(_this2,"unsetLoading",function(path){var _this4=_this2,loading=_this4.loading;if(typeof loading[path]==='undefined'){return;}if(loading[path]<=1){_this2.resetLoading(path);return;}var newLoading=_extends({},loading,_defineProperty({},path,loading[path]-1));// Immediately updates state due to multiple sets before actual rerender.
17
- _this2.loading=newLoading;_this2.setState({loading:newLoading});});/**
18
- * Checks if a path is loading.
19
- * @param {string} path The path it inspect.
20
- * @return {boolean}
21
- */_defineProperty(_this2,"isLoading",function(path){var loading=_this2.state.loading;return!!loading[path];});_this2.loading={};_this2.state={loading:{}};UIEvents.addListener(_this2.constructor.SET,_this2.setLoading);UIEvents.addListener(_this2.constructor.RESET,_this2.resetLoading);UIEvents.addListener(_this2.constructor.UNSET,_this2.unsetLoading);return _this2;}/**
29
+ */
30
+ static unsetLoading(path) {
31
+ UIEvents.emit(LoadingProvider.UNSET, path);
32
+ }
33
+
34
+ /**
35
+ * @param {Object} props The component props.
36
+ */
37
+ constructor(props) {
38
+ super(props);
39
+ /**
40
+ * Adds or increases the loading counter for a path.
41
+ * @param {string} path The path which loads.
42
+ */
43
+ this.setLoading = path => {
44
+ const {
45
+ loading
46
+ } = this;
47
+ const newLoading = {
48
+ ...loading,
49
+ [path]: loading[path] ? loading[path] + 1 : 1
50
+ };
51
+
52
+ // Immediately updates state due to multiple sets before actual rerender.
53
+ this.loading = newLoading;
54
+ this.setState({
55
+ loading: newLoading
56
+ });
57
+ };
58
+ /**
59
+ * Resets the loading counter for a path.
60
+ * @param {string} path The path which loads.
61
+ */
62
+ this.resetLoading = path => {
63
+ const {
64
+ [path]: removedPath,
65
+ ...remaining
66
+ } = this.loading;
67
+
68
+ // Immediately updates state due to multiple sets before actual rerender.
69
+ this.loading = remaining;
70
+ this.setState({
71
+ loading: remaining
72
+ });
73
+ };
74
+ /**
75
+ * Decreases the loading counter for a path.
76
+ * @param {string} path The path which loads.
77
+ */
78
+ this.unsetLoading = path => {
79
+ const {
80
+ loading
81
+ } = this;
82
+ if (typeof loading[path] === 'undefined') {
83
+ return;
84
+ }
85
+ if (loading[path] <= 1) {
86
+ this.resetLoading(path);
87
+ return;
88
+ }
89
+ const newLoading = {
90
+ ...loading,
91
+ [path]: loading[path] - 1
92
+ };
93
+
94
+ // Immediately updates state due to multiple sets before actual rerender.
95
+ this.loading = newLoading;
96
+ this.setState({
97
+ loading: newLoading
98
+ });
99
+ };
100
+ /**
101
+ * Checks if a path is loading.
102
+ * @param {string} path The path it inspect.
103
+ * @return {boolean}
104
+ */
105
+ this.isLoading = path => {
106
+ const {
107
+ loading
108
+ } = this.state;
109
+ return !!loading[path];
110
+ };
111
+ this.loading = {};
112
+ this.state = {
113
+ loading: {}
114
+ };
115
+ UIEvents.addListener(this.constructor.SET, this.setLoading);
116
+ UIEvents.addListener(this.constructor.RESET, this.resetLoading);
117
+ UIEvents.addListener(this.constructor.UNSET, this.unsetLoading);
118
+ }
119
+
120
+ /**
22
121
  * Removes the event listeners when the component unmounts.
23
- */_inherits(LoadingProvider,_Component);return _createClass(LoadingProvider,[{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(this.constructor.SET,this.setLoading);UIEvents.removeListener(this.constructor.RESET,this.resetLoading);UIEvents.removeListener(this.constructor.UNSET,this.unsetLoading);}},{key:"render",value:/**
122
+ */
123
+ componentWillUnmount() {
124
+ UIEvents.removeListener(this.constructor.SET, this.setLoading);
125
+ UIEvents.removeListener(this.constructor.RESET, this.resetLoading);
126
+ UIEvents.removeListener(this.constructor.UNSET, this.unsetLoading);
127
+ }
128
+ /**
24
129
  * @return {JSX}
25
- */function render(){var value={loading:this.state.loading,setLoading:this.setLoading,unsetLoading:this.unsetLoading,isLoading:this.isLoading};return React.createElement(LoadingContext.Provider,{value:value},this.props.children);}}],[{key:"setLoading",value:function setLoading(path){UIEvents.emit(LoadingProvider.SET,path);}/**
26
- * Resets the loading counter for a path.
27
- * @param {string} path The path which loads.
28
- */},{key:"resetLoading",value:function resetLoading(path){UIEvents.emit(LoadingProvider.RESET,path);}/**
29
- * Decreases the loading counter for a path.
30
- * @param {string} path The path which loads.
31
- */},{key:"unsetLoading",value:function unsetLoading(path){UIEvents.emit(LoadingProvider.UNSET,path);}}]);}(Component);_defineProperty(LoadingProvider,"SET",'loading_set');_defineProperty(LoadingProvider,"RESET",'loading_reset');_defineProperty(LoadingProvider,"UNSET",'loading_unset');export default LoadingProvider;
130
+ */
131
+ render() {
132
+ const value = {
133
+ loading: this.state.loading,
134
+ setLoading: this.setLoading,
135
+ unsetLoading: this.unsetLoading,
136
+ isLoading: this.isLoading
137
+ };
138
+ return /*#__PURE__*/React.createElement(LoadingContext.Provider, {
139
+ value: value
140
+ }, this.props.children);
141
+ }
142
+ }
143
+ LoadingProvider.SET = 'loading_set';
144
+ LoadingProvider.RESET = 'loading_reset';
145
+ LoadingProvider.UNSET = 'loading_unset';
146
+ export default LoadingProvider;
@@ -1 +1,2 @@
1
- import React from'react';export default React.createContext();
1
+ import React from 'react';
2
+ export default /*#__PURE__*/React.createContext();
@@ -1,15 +1,109 @@
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{UIEvents}from'@shopgate/pwa-core';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import ToastContext from"./context";var _themeConfig$variable=themeConfig.variables,_themeConfig$variable2=_themeConfig$variable===void 0?{}:_themeConfig$variable,_themeConfig$variable3=_themeConfig$variable2.toast,_themeConfig$variable4=_themeConfig$variable3===void 0?{}:_themeConfig$variable3,_themeConfig$variable5=_themeConfig$variable4.duration,duration=_themeConfig$variable5===void 0?5000:_themeConfig$variable5;/**
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { UIEvents } from '@shopgate/pwa-core';
4
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
5
+ import ToastContext from "./context";
6
+ const {
7
+ variables: {
8
+ toast: {
9
+ duration = 5000
10
+ } = {}
11
+ } = {}
12
+ } = themeConfig;
13
+
14
+ /**
2
15
  * The ToastProvider component
3
- */var ToastProvider=/*#__PURE__*/function(_Component){function ToastProvider(props){var _this2;_classCallCheck(this,ToastProvider);_this2=_callSuper(this,ToastProvider,[props]);/**
4
- * Adds a new, unique, toast to the list.
5
- * @param {Object} toast The toast object to add.
6
- */_defineProperty(_this2,"addToast",function(toast){if(!toast.message){return;}var toasts=_this2.state.toasts;// Check if the toast id already is present.
7
- var found=toasts.find(function(_ref){var id=_ref.id;return toast.id===id;});// If found, update the toast with the new data.
8
- if(found){found.action=toast.action;found.actionLabel=toast.actionLabel;found.message=toast.message;found.messageParams=toast.messageParams;found.duration=toast.duration||duration;}else{toasts.push({id:toast.id,action:toast.action,actionLabel:toast.actionLabel,message:toast.message,messageParams:toast.messageParams,duration:toast.duration||duration});}_this2.setState({toasts:toasts});});/**
9
- * Removes the first toast from the list.
10
- */_defineProperty(_this2,"removeToast",function(){var toasts=_this2.state.toasts;toasts.shift();_this2.setState({toasts:toasts});});_defineProperty(_this2,"flushToasts",function(){if(_this2.state.toasts.length){_this2.setState({toasts:[]});}});_this2.state={toasts:[]};UIEvents.addListener(_this2.constructor.ADD,_this2.addToast);UIEvents.addListener(_this2.constructor.FLUSH,_this2.flushToasts);return _this2;}/**
16
+ */
17
+ class ToastProvider extends Component {
18
+ /**
19
+ * @param {Object} props The component props.
20
+ */
21
+ constructor(props) {
22
+ super(props);
23
+ /**
24
+ * Adds a new, unique, toast to the list.
25
+ * @param {Object} toast The toast object to add.
26
+ */
27
+ this.addToast = toast => {
28
+ if (!toast.message) {
29
+ return;
30
+ }
31
+ const {
32
+ toasts
33
+ } = this.state;
34
+
35
+ // Check if the toast id already is present.
36
+ const found = toasts.find(({
37
+ id
38
+ }) => toast.id === id);
39
+
40
+ // If found, update the toast with the new data.
41
+ if (found) {
42
+ found.action = toast.action;
43
+ found.actionLabel = toast.actionLabel;
44
+ found.message = toast.message;
45
+ found.messageParams = toast.messageParams;
46
+ found.duration = toast.duration || duration;
47
+ } else {
48
+ toasts.push({
49
+ id: toast.id,
50
+ action: toast.action,
51
+ actionLabel: toast.actionLabel,
52
+ message: toast.message,
53
+ messageParams: toast.messageParams,
54
+ duration: toast.duration || duration
55
+ });
56
+ }
57
+ this.setState({
58
+ toasts
59
+ });
60
+ };
61
+ /**
62
+ * Removes the first toast from the list.
63
+ */
64
+ this.removeToast = () => {
65
+ const {
66
+ toasts
67
+ } = this.state;
68
+ toasts.shift();
69
+ this.setState({
70
+ toasts
71
+ });
72
+ };
73
+ this.flushToasts = () => {
74
+ if (this.state.toasts.length) {
75
+ this.setState({
76
+ toasts: []
77
+ });
78
+ }
79
+ };
80
+ this.state = {
81
+ toasts: []
82
+ };
83
+ UIEvents.addListener(this.constructor.ADD, this.addToast);
84
+ UIEvents.addListener(this.constructor.FLUSH, this.flushToasts);
85
+ }
86
+
87
+ /**
11
88
  * Returns the context value to be passed to consumers.
12
89
  * @returns {Object}
13
- */_inherits(ToastProvider,_Component);return _createClass(ToastProvider,[{key:"provided",get:function get(){return{addToast:this.addToast,removeToast:this.removeToast,toasts:this.state.toasts};}},{key:"render",value:/**
90
+ */
91
+ get provided() {
92
+ return {
93
+ addToast: this.addToast,
94
+ removeToast: this.removeToast,
95
+ toasts: this.state.toasts
96
+ };
97
+ }
98
+ /**
14
99
  * @returns {JSX}
15
- */function render(){return React.createElement(ToastContext.Provider,{value:this.provided},this.props.children);}}]);}(Component);_defineProperty(ToastProvider,"ADD",'toast_add');_defineProperty(ToastProvider,"FLUSH",'toast_flush');export default ToastProvider;
100
+ */
101
+ render() {
102
+ return /*#__PURE__*/React.createElement(ToastContext.Provider, {
103
+ value: this.provided
104
+ }, this.props.children);
105
+ }
106
+ }
107
+ ToastProvider.ADD = 'toast_add';
108
+ ToastProvider.FLUSH = 'toast_flush';
109
+ export default ToastProvider;
@@ -1,6 +1,26 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{RECEIVE_CLIENT_CONNECTIVITY}from"../../constants/ActionTypes";import{CONNECTIVITY_NETWORK_UNKNOWN,CONNECTIVITY_TYPE_UNKNOWN}from"../../constants/client";var defaultState={connected:true,network:CONNECTIVITY_NETWORK_UNKNOWN,type:CONNECTIVITY_TYPE_UNKNOWN};/**
1
+ import { RECEIVE_CLIENT_CONNECTIVITY } from "../../constants/ActionTypes";
2
+ import { CONNECTIVITY_NETWORK_UNKNOWN, CONNECTIVITY_TYPE_UNKNOWN } from "../../constants/client";
3
+ const defaultState = {
4
+ connected: true,
5
+ network: CONNECTIVITY_NETWORK_UNKNOWN,
6
+ type: CONNECTIVITY_TYPE_UNKNOWN
7
+ };
8
+
9
+ /**
2
10
  * Stores the client connectivity data.
3
11
  * @param {Object} [state] The current state.
4
12
  * @param {Object} action The action object.
5
13
  * @return {Object} The new state.
6
- */export default function clientConnectivityReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case RECEIVE_CLIENT_CONNECTIVITY:return _extends({},state,{},defaultState,{},action.data);default:return state;}}
14
+ */
15
+ export default function clientConnectivityReducer(state = defaultState, action) {
16
+ switch (action.type) {
17
+ case RECEIVE_CLIENT_CONNECTIVITY:
18
+ return {
19
+ ...state,
20
+ ...defaultState,
21
+ ...action.data
22
+ };
23
+ default:
24
+ return state;
25
+ }
26
+ }
@@ -1 +1,7 @@
1
- import{combineReducers}from'redux';import info from"./info";import connectivity from"./connectivity";export default combineReducers({info:info,connectivity:connectivity});
1
+ import { combineReducers } from 'redux';
2
+ import info from "./info";
3
+ import connectivity from "./connectivity";
4
+ export default combineReducers({
5
+ info,
6
+ connectivity
7
+ });
@@ -1,6 +1,31 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{REQUEST_CLIENT_INFORMATION,RECEIVE_CLIENT_INFORMATION,ERROR_CLIENT_INFORMATION}from"../../constants/ActionTypes";var defaultState={};/**
1
+ import { REQUEST_CLIENT_INFORMATION, RECEIVE_CLIENT_INFORMATION, ERROR_CLIENT_INFORMATION } from "../../constants/ActionTypes";
2
+ const defaultState = {};
3
+
4
+ /**
2
5
  * Stores all the client information.
3
6
  * @param {Object} [state] The current state.
4
7
  * @param {Object} action The action object.
5
8
  * @return {Object} The new state.
6
- */export default function clientInformationReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case REQUEST_CLIENT_INFORMATION:return _extends({},state,{isFetching:true});case RECEIVE_CLIENT_INFORMATION:return _extends({},state,{},action.data,{isFetching:false});case ERROR_CLIENT_INFORMATION:return _extends({},state,{isFetching:false});default:return state;}}
9
+ */
10
+ export default function clientInformationReducer(state = defaultState, action) {
11
+ switch (action.type) {
12
+ case REQUEST_CLIENT_INFORMATION:
13
+ return {
14
+ ...state,
15
+ isFetching: true
16
+ };
17
+ case RECEIVE_CLIENT_INFORMATION:
18
+ return {
19
+ ...state,
20
+ ...action.data,
21
+ isFetching: false
22
+ };
23
+ case ERROR_CLIENT_INFORMATION:
24
+ return {
25
+ ...state,
26
+ isFetching: false
27
+ };
28
+ default:
29
+ return state;
30
+ }
31
+ }
package/reducers/index.js CHANGED
@@ -1,7 +1,26 @@
1
- import configuration from"../collections/Configuration";import{RESET_APP_REDUCERS}from"../constants/Configuration";import{RESET_APP}from"../constants/ActionTypes";/**
1
+ import configuration from "../collections/Configuration";
2
+ import { RESET_APP_REDUCERS } from "../constants/Configuration";
3
+ import { RESET_APP } from "../constants/ActionTypes";
4
+
5
+ /**
2
6
  * The root reducer.
3
7
  * @param {Function} appReducers The app reducers from combineReducers.
4
8
  * @returns {Function}
5
- */var makeRootReducer=function makeRootReducer(appReducers){return function(state,action){if(action.type===RESET_APP){var resetReducers=action.reducers||configuration.get(RESET_APP_REDUCERS);if(Array.isArray(resetReducers)){resetReducers.forEach(function(reducer){if(typeof state[reducer]==='undefined'){return;}// Set reset reducer to undefined
6
- // eslint-disable-next-line no-param-reassign
7
- state[reducer]=undefined;});}}return appReducers(state,action);};};export default makeRootReducer;
9
+ */
10
+ const makeRootReducer = appReducers => (state, action) => {
11
+ if (action.type === RESET_APP) {
12
+ const resetReducers = action.reducers || configuration.get(RESET_APP_REDUCERS);
13
+ if (Array.isArray(resetReducers)) {
14
+ resetReducers.forEach(reducer => {
15
+ if (typeof state[reducer] === 'undefined') {
16
+ return;
17
+ }
18
+ // Set reset reducer to undefined
19
+ // eslint-disable-next-line no-param-reassign
20
+ state[reducer] = undefined;
21
+ });
22
+ }
23
+ }
24
+ return appReducers(state, action);
25
+ };
26
+ export default makeRootReducer;
@@ -1 +1,5 @@
1
- import{combineReducers}from'redux';import menusById from"./menusById";export default combineReducers({menusById:menusById});
1
+ import { combineReducers } from 'redux';
2
+ import menusById from "./menusById";
3
+ export default combineReducers({
4
+ menusById
5
+ });
@@ -1,6 +1,45 @@
1
- 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;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{REQUEST_MENU,RECEIVE_MENU,ERROR_MENU}from"../../constants/ActionTypes";/**
1
+ import { REQUEST_MENU, RECEIVE_MENU, ERROR_MENU } from "../../constants/ActionTypes";
2
+
3
+ /**
2
4
  * Stores the entries of the service menu.
3
5
  * @param {Object} [state] The current state.
4
6
  * @param {Object} action The action object.
5
7
  * @return {Object} The new state.
6
- */export default function menusByIdReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case REQUEST_MENU:{return _extends({},state,_defineProperty({},action.id,_extends({},state[action.id],{isFetching:true})));}case RECEIVE_MENU:{return _extends({},state,_defineProperty({},action.id,_extends({},state[action.id],{entries:action.entries,isFetching:false})));}case ERROR_MENU:{return _extends({},state,_defineProperty({},action.id,_extends({},state[action.id],{isFetching:false})));}default:return state;}}
8
+ */
9
+ export default function menusByIdReducer(state = {}, action) {
10
+ switch (action.type) {
11
+ case REQUEST_MENU:
12
+ {
13
+ return {
14
+ ...state,
15
+ [action.id]: {
16
+ ...state[action.id],
17
+ isFetching: true
18
+ }
19
+ };
20
+ }
21
+ case RECEIVE_MENU:
22
+ {
23
+ return {
24
+ ...state,
25
+ [action.id]: {
26
+ ...state[action.id],
27
+ entries: action.entries,
28
+ isFetching: false
29
+ }
30
+ };
31
+ }
32
+ case ERROR_MENU:
33
+ {
34
+ return {
35
+ ...state,
36
+ [action.id]: {
37
+ ...state[action.id],
38
+ isFetching: false
39
+ }
40
+ };
41
+ }
42
+ default:
43
+ return state;
44
+ }
45
+ }
@@ -1,6 +1,18 @@
1
- import{CREATE_MODAL,REMOVE_MODAL}from"../../constants/ActionTypes";/**
1
+ import { CREATE_MODAL, REMOVE_MODAL } from "../../constants/ActionTypes";
2
+
3
+ /**
2
4
  * Stores all the view information.
3
5
  * @param {Object} state The current state.
4
6
  * @param {Object} action The action object.
5
7
  * @return {Object} The new state.
6
- */export default function modalReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case CREATE_MODAL:return[].concat(state,[action.options]);case REMOVE_MODAL:return state.filter(function(modal){return modal.id!==action.id;});default:return state;}}
8
+ */
9
+ export default function modalReducer(state = [], action) {
10
+ switch (action.type) {
11
+ case CREATE_MODAL:
12
+ return [...state, action.options];
13
+ case REMOVE_MODAL:
14
+ return state.filter(modal => modal.id !== action.id);
15
+ default:
16
+ return state;
17
+ }
18
+ }