@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,4 +1,12 @@
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;}import IntlMessageFormat from'intl-messageformat';import curry from'lodash/curry';import appConfig from'@shopgate/pwa-common/helpers/config';import messageCache from"./messageCache";var showPriceGrouping=appConfig.showPriceGrouping;/**
1
+ import IntlMessageFormat from 'intl-messageformat';
2
+ import curry from 'lodash/curry';
3
+ import appConfig from '@shopgate/pwa-common/helpers/config';
4
+ import messageCache from "./messageCache";
5
+ const {
6
+ showPriceGrouping
7
+ } = appConfig;
8
+
9
+ /**
2
10
  * Returns an instance of IntlMessageFormat from cache based on a hash.
3
11
  * The hash is generated from given language code and translation key.
4
12
  * If no instance exists yet, a new instance will be created and returned.
@@ -6,12 +14,38 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
6
14
  * @param {string} currency The current currency.
7
15
  * @param {boolean} fractions With or without fraction digits.
8
16
  * @returns {IntlMessageFormat}
9
- */var getFormattedPriceFromCache=function getFormattedPriceFromCache(langCode,currency,fractions){var hash="".concat(langCode,"_price_").concat(currency,"_").concat(fractions);// Check if a cached instance already exists.
10
- if(messageCache[hash]){return messageCache[hash];}messageCache[hash]=new IntlMessageFormat("{price, number, ".concat(currency,"}"),langCode,{number:_defineProperty({},currency,{style:'currency',currency:currency,minimumFractionDigits:fractions?2:0,maximumFractionDigits:fractions?2:0,useGrouping:showPriceGrouping})});return messageCache[hash];};/**
17
+ */
18
+ const getFormattedPriceFromCache = (langCode, currency, fractions) => {
19
+ const hash = `${langCode}_price_${currency}_${fractions}`;
20
+
21
+ // Check if a cached instance already exists.
22
+ if (messageCache[hash]) {
23
+ return messageCache[hash];
24
+ }
25
+ messageCache[hash] = new IntlMessageFormat(`{price, number, ${currency}}`, langCode, {
26
+ number: {
27
+ [currency]: {
28
+ style: 'currency',
29
+ currency,
30
+ minimumFractionDigits: fractions ? 2 : 0,
31
+ maximumFractionDigits: fractions ? 2 : 0,
32
+ useGrouping: showPriceGrouping
33
+ }
34
+ }
35
+ });
36
+ return messageCache[hash];
37
+ };
38
+
39
+ /**
11
40
  * Get a formatted price by currency and language code.
12
41
  * @param {string} langCode A language code.
13
42
  * @param {number} price The price to format.
14
43
  * @param {string} currency The current currency.
15
44
  * @param {boolean} fractions With or without fraction digits.
16
45
  * @returns {string}
17
- */var formatPrice=function formatPrice(langCode,price,currency,fractions){return getFormattedPriceFromCache(langCode,currency,fractions).format({price:price});};var getPriceFormatter=curry(formatPrice);export default getPriceFormatter;
46
+ */
47
+ const formatPrice = (langCode, price, currency, fractions) => getFormattedPriceFromCache(langCode, currency, fractions).format({
48
+ price
49
+ });
50
+ const getPriceFormatter = curry(formatPrice);
51
+ export default getPriceFormatter;
@@ -1,4 +1,8 @@
1
- import IntlMessageFormat from'intl-messageformat';import curry from'lodash/curry';import messageCache from"./messageCache";/**
1
+ import IntlMessageFormat from 'intl-messageformat';
2
+ import curry from 'lodash/curry';
3
+ import messageCache from "./messageCache";
4
+
5
+ /**
2
6
  * Returns an instance of IntlMessageFormat from cache based on a hash.
3
7
  * The hash is generated from given language code and translation key.
4
8
  * If no instance exists yet, a new instance will be created and returned.
@@ -6,12 +10,27 @@ import IntlMessageFormat from'intl-messageformat';import curry from'lodash/curry
6
10
  * @param {string} format The time format.
7
11
  * Possible values: 'short', 'medium' (default), 'long','full'
8
12
  * @returns {IntlMessageFormat}
9
- */var getFormattedTimeFromCache=function getFormattedTimeFromCache(langCode,format){var hash="".concat(langCode,"_time_").concat(format);// Check if a cached instance already exists.
10
- if(messageCache[hash]){return messageCache[hash];}messageCache[hash]=new IntlMessageFormat("{timestamp, time, ".concat(format,"}"),langCode);return messageCache[hash];};/**
13
+ */
14
+ const getFormattedTimeFromCache = (langCode, format) => {
15
+ const hash = `${langCode}_time_${format}`;
16
+
17
+ // Check if a cached instance already exists.
18
+ if (messageCache[hash]) {
19
+ return messageCache[hash];
20
+ }
21
+ messageCache[hash] = new IntlMessageFormat(`{timestamp, time, ${format}}`, langCode);
22
+ return messageCache[hash];
23
+ };
24
+
25
+ /**
11
26
  * Get a formatted time from a timestamp.
12
27
  * @param {string} langCode A language code.
13
28
  * @param {number} timestamp The current time's timestamp.
14
29
  * @param {string} [format='medium'] The time format.
15
30
  * Possible values: 'short', 'medium', 'long','full'
16
31
  * @returns {string}
17
- */var formatTime=function formatTime(langCode,timestamp){var format=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'medium';return getFormattedTimeFromCache(langCode,format).format({timestamp:timestamp});};export default curry(formatTime);
32
+ */
33
+ const formatTime = (langCode, timestamp, format = 'medium') => getFormattedTimeFromCache(langCode, format).format({
34
+ timestamp
35
+ });
36
+ export default curry(formatTime);
@@ -1,9 +1,21 @@
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);}import IntlMessageFormat from'intl-messageformat';import curry from'lodash/curry';// eslint-disable-next-line import/no-named-default
2
- import{default as getPath}from'lodash/get';import moment from'moment';import messageCache from"./messageCache";/**
1
+ import "core-js/modules/es.array.reduce.js";
2
+ import IntlMessageFormat from 'intl-messageformat';
3
+ import curry from 'lodash/curry';
4
+ // eslint-disable-next-line import/no-named-default
5
+ import { default as getPath } from 'lodash/get';
6
+ import moment from 'moment';
7
+ import messageCache from "./messageCache";
8
+
9
+ /**
3
10
  * Pure function to return original key whet Intl message not found
4
11
  * @param {*} key origin intl key to return
5
12
  * @returns {*}
6
- */var pureReturn=function pureReturn(key){return{format:function format(){return key;}};};/**
13
+ */
14
+ const pureReturn = key => ({
15
+ format: () => key
16
+ });
17
+
18
+ /**
7
19
  * Returns an instance of IntlMessageFormat from cache based on a hash.
8
20
  * The hash is generated from given language code and translation key.
9
21
  * If no instance exists yet, a new instance will be created and returned.
@@ -14,9 +26,32 @@ import{default as getPath}from'lodash/get';import moment from'moment';import mes
14
26
  * @param {boolean} [options.acceptPlainTextWithPlaceholders = false] When set to TRUE, the
15
27
  * translator can also handle human readable texts that contain text replacement placeholders.
16
28
  * @returns {IntlMessageFormat}
17
- */var getMessageFromCache=function getMessageFromCache(locales,langCode,key){var options=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var _options$acceptPlainT=options.acceptPlainTextWithPlaceholders,acceptPlainTextWithPlaceholders=_options$acceptPlainT===void 0?false:_options$acceptPlainT;var hash="".concat(langCode,"_").concat(key,"_").concat(acceptPlainTextWithPlaceholders?1:0);// Check if a cached instance already exists.
18
- if(messageCache[hash]){return messageCache[hash];}var message=getPath(locales,key,acceptPlainTextWithPlaceholders?key:undefined);if(typeof message!=='string'||message.length===0){return pureReturn(key);}// Prevent the app from crashing when strings (like product names) don't comply with the format
19
- try{messageCache[hash]=new IntlMessageFormat(message,langCode,getPath(locales,'formats'));}catch(e){messageCache[hash]=pureReturn(key);}return messageCache[hash];};/**
29
+ */
30
+ const getMessageFromCache = (locales, langCode, key, options = {}) => {
31
+ const {
32
+ acceptPlainTextWithPlaceholders = false
33
+ } = options;
34
+ const hash = `${langCode}_${key}_${acceptPlainTextWithPlaceholders ? 1 : 0}`;
35
+
36
+ // Check if a cached instance already exists.
37
+ if (messageCache[hash]) {
38
+ return messageCache[hash];
39
+ }
40
+ const message = getPath(locales, key, acceptPlainTextWithPlaceholders ? key : undefined);
41
+ if (typeof message !== 'string' || message.length === 0) {
42
+ return pureReturn(key);
43
+ }
44
+
45
+ // Prevent the app from crashing when strings (like product names) don't comply with the format
46
+ try {
47
+ messageCache[hash] = new IntlMessageFormat(message, langCode, getPath(locales, 'formats'));
48
+ } catch (e) {
49
+ messageCache[hash] = pureReturn(key);
50
+ }
51
+ return messageCache[hash];
52
+ };
53
+
54
+ /**
20
55
  * Get a translation for a given key.
21
56
  * @param {Object} locales A locales object.
22
57
  * @param {string} langCode A language code.
@@ -26,6 +61,25 @@ try{messageCache[hash]=new IntlMessageFormat(message,langCode,getPath(locales,'f
26
61
  * @param {boolean} [options.acceptPlainTextWithPlaceholders = false] When set to TRUE, the
27
62
  * translator can also handle human readable texts that contain text replacement placeholders.
28
63
  * @returns {string}
29
- */var translate=function translate(locales,langCode,key){var args=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var options=arguments.length>4&&arguments[4]!==undefined?arguments[4]:{};/**
64
+ */
65
+ const translate = (locales, langCode, key, args = {}, options = {}) => {
66
+ /**
30
67
  * @returns {Object}
31
- */var sanitizeArgs=function sanitizeArgs(){if(_typeof(args)!=='object'||args===null){return args;}return Object.keys(args).reduce(function(acc,arg){var date=moment(args[arg],moment.ISO_8601,true);if(date.isValid()&&date.toISOString()===args[arg]){acc[arg]=new Date(args[arg]).getTime();}else{acc[arg]=args[arg];}return acc;},{});};return getMessageFromCache(locales,langCode,key,options).format(sanitizeArgs());};export default curry(translate);
68
+ */
69
+ const sanitizeArgs = () => {
70
+ if (typeof args !== 'object' || args === null) {
71
+ return args;
72
+ }
73
+ return Object.keys(args).reduce((acc, arg) => {
74
+ const date = moment(args[arg], moment.ISO_8601, true);
75
+ if (date.isValid() && date.toISOString() === args[arg]) {
76
+ acc[arg] = new Date(args[arg]).getTime();
77
+ } else {
78
+ acc[arg] = args[arg];
79
+ }
80
+ return acc;
81
+ }, {});
82
+ };
83
+ return getMessageFromCache(locales, langCode, key, options).format(sanitizeArgs());
84
+ };
85
+ export default curry(translate);
@@ -1 +1,5 @@
1
- export{default as getTranslator}from"./getTranslator";export{default as getPriceFormatter}from"./getPriceFormatter";export{default as getDateFormatter}from"./getDateFormatter";export{default as getTimeFormatter}from"./getTimeFormatter";export{default as getNumberFormatter}from"./getNumberFormatter";
1
+ export { default as getTranslator } from "./getTranslator";
2
+ export { default as getPriceFormatter } from "./getPriceFormatter";
3
+ export { default as getDateFormatter } from "./getDateFormatter";
4
+ export { default as getTimeFormatter } from "./getTimeFormatter";
5
+ export { default as getNumberFormatter } from "./getNumberFormatter";
@@ -1,21 +1,48 @@
1
- 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;}import isPlainObject from'lodash/isPlainObject';import cloneDeep from'lodash/cloneDeep';import merge from'lodash/merge';/**
1
+ import "core-js/modules/es.array.reduce.js";
2
+ import isPlainObject from 'lodash/isPlainObject';
3
+ import cloneDeep from 'lodash/cloneDeep';
4
+ import merge from 'lodash/merge';
5
+
6
+ /**
2
7
  * Checks if an extension locale matches the theme locale.
3
8
  * @param {string} themeLocale The locale of the theme.
4
9
  * @param {string} extensionLocale The locale of an extension.
5
10
  * @return {boolean}
6
- */var localesMatch=function localesMatch(themeLocale,extensionLocale){// Extract the actual locale string from the extension locale.
7
- var _extensionLocale$spli=extensionLocale.split('/').reverse(),_extensionLocale$spli2=_slicedToArray(_extensionLocale$spli,1),locale=_extensionLocale$spli2[0];// Extract the language from the theme locale.
8
- var _themeLocale$split=themeLocale.split('-'),_themeLocale$split2=_slicedToArray(_themeLocale$split,1),themeLanguage=_themeLocale$split2[0];/**
11
+ */
12
+ const localesMatch = (themeLocale, extensionLocale) => {
13
+ // Extract the actual locale string from the extension locale.
14
+ const [locale] = extensionLocale.split('/').reverse();
15
+ // Extract the language from the theme locale.
16
+ const [themeLanguage] = themeLocale.split('-');
17
+
18
+ /**
9
19
  * Theme locales always contain language and region (en-US). But extension locales
10
20
  * might only scoped for a language (en). To be sure that all extension translations
11
21
  * are considered for the merge, both variants are checked.
12
- */return locale.toLowerCase()===themeLocale.toLowerCase()||locale.toLowerCase()===themeLanguage;};/**
22
+ */
23
+ return locale.toLowerCase() === themeLocale.toLowerCase() || locale.toLowerCase() === themeLanguage;
24
+ };
25
+
26
+ /**
13
27
  * Merges extension translations into the theme translations.
14
28
  * @param {Object} theme The translations object of a theme.
15
29
  * @param {Object} extensions The extension translations.
16
30
  * @param {string} [locale=process.env.LOCALE_FILE] The current active locale of the theme.
17
31
  * @return {Object}
18
- */var mergeTranslations=function mergeTranslations(theme,extensions){var locale=arguments.length>2&&arguments[2]!==undefined?arguments[2]:process.env.LOCALE_FILE;if(!isPlainObject(extensions)||Object.keys(extensions).length===0){// No extension translations provided.
19
- return cloneDeep(theme);}return Object.keys(extensions).reduce(function(result,extensionLocale){if(!localesMatch(locale,extensionLocale)){// Continue if the current extension locale doesn't match the theme locale.
20
- return result;}// Merge the current extensions into the result.
21
- return merge(result,extensions[extensionLocale]);},cloneDeep(theme));};export default mergeTranslations;
32
+ */
33
+ const mergeTranslations = (theme, extensions, locale = process.env.LOCALE_FILE) => {
34
+ if (!isPlainObject(extensions) || Object.keys(extensions).length === 0) {
35
+ // No extension translations provided.
36
+ return cloneDeep(theme);
37
+ }
38
+ return Object.keys(extensions).reduce((result, extensionLocale) => {
39
+ if (!localesMatch(locale, extensionLocale)) {
40
+ // Continue if the current extension locale doesn't match the theme locale.
41
+ return result;
42
+ }
43
+
44
+ // Merge the current extensions into the result.
45
+ return merge(result, extensions[extensionLocale]);
46
+ }, cloneDeep(theme));
47
+ };
48
+ export default mergeTranslations;
@@ -1,4 +1,6 @@
1
1
  /**
2
2
  * A hash-based cache for instances of IntlMessageFormat.
3
3
  * @type {Object}
4
- */var messageCache={};export default messageCache;
4
+ */
5
+ const messageCache = {};
6
+ export default messageCache;
@@ -1,21 +1,59 @@
1
- import hideMenuBar from'@shopgate/pwa-core/commands/hideMenuBar';import broadcastEvent from'@shopgate/pwa-core/commands/broadcastEvent';import showTab from'@shopgate/pwa-core/commands/showTab';import{appSupportsAndroidEdgeToEdge}from'@shopgate/engage/core/helpers';/**
1
+ import hideMenuBar from '@shopgate/pwa-core/commands/hideMenuBar';
2
+ import broadcastEvent from '@shopgate/pwa-core/commands/broadcastEvent';
3
+ import showTab from '@shopgate/pwa-core/commands/showTab';
4
+ import { appSupportsAndroidEdgeToEdge } from '@shopgate/engage/core/helpers';
5
+
6
+ /**
2
7
  * Page context that comes from the app.
3
8
  * @type {Object}
4
- */var currentPageContext={};/**
9
+ */
10
+ let currentPageContext = {};
11
+
12
+ /**
5
13
  * Get Page context if available.
6
14
  * @returns {Object}
7
- */export var getPageContext=function getPageContext(){return currentPageContext;};/**
15
+ */
16
+ export const getPageContext = () => currentPageContext;
17
+
18
+ /**
8
19
  * Prepares the NavigationBar and the MenuBar of the app legacy part for the PWA.
9
- */export var prepareLegacyNavigation=function prepareLegacyNavigation(){// Logic below causes issues on Android app with edge-to-edge screens. For compatibility reasons
10
- // logic is skipped for now on those devices. Function could potentially be removed in the future.
11
- if(appSupportsAndroidEdgeToEdge()){return;}/**
20
+ */
21
+ export const prepareLegacyNavigation = () => {
22
+ // Logic below causes issues on Android app with edge-to-edge screens. For compatibility reasons
23
+ // logic is skipped for now on those devices. Function could potentially be removed in the future.
24
+ if (appSupportsAndroidEdgeToEdge()) {
25
+ return;
26
+ }
27
+ /**
12
28
  * Broadcasts an event to the pwa_navigation_bar webview and updates the navigation bar with
13
29
  * type "none". Event parameters are defined accordingly to the specification of the native
14
30
  * updateNavigationBar event.
15
- */broadcastEvent({event:'updateNavigationBar',parameters:['','none',{type:'none'}]});hideMenuBar({animation:null});};/**
31
+ */
32
+ broadcastEvent({
33
+ event: 'updateNavigationBar',
34
+ parameters: ['', 'none', {
35
+ type: 'none'
36
+ }]
37
+ });
38
+ hideMenuBar({
39
+ animation: null
40
+ });
41
+ };
42
+
43
+ /**
16
44
  * Shows the main tab when legacy system requests the previous tab.
17
45
  * @param {Object} context The page context from the app.
18
46
  * @param {string} context.tab The tab where the page is opened.
19
- */export var pageContext=function pageContext(context){currentPageContext=context;};/**
47
+ */
48
+ export const pageContext = context => {
49
+ currentPageContext = context;
50
+ };
51
+
52
+ /**
20
53
  * Shows the main tab when legacy system requests the previous tab.
21
- */export var showPreviousTab=function showPreviousTab(){showTab({targetTab:currentPageContext.tab?currentPageContext.tab:'main'});};
54
+ */
55
+ export const showPreviousTab = () => {
56
+ showTab({
57
+ targetTab: currentPageContext.tab ? currentPageContext.tab : 'main'
58
+ });
59
+ };
@@ -1,4 +1,15 @@
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{connect}from'react-redux';import _showModal from'@shopgate/pwa-common/actions/modal/showModal';/**
1
+ import { connect } from 'react-redux';
2
+ import showModal from '@shopgate/pwa-common/actions/modal/showModal';
3
+
4
+ /**
2
5
  * @param {Function} dispatch The redux dispatch function
3
6
  * @return {Object}
4
- */var mapDispatchToProps=function mapDispatchToProps(dispatch){return{showModal:function showModal(options){return dispatch(_showModal(_extends({confirm:'modal.ok',dismiss:null},options)));}};};export default connect(null,mapDispatchToProps);
7
+ */
8
+ const mapDispatchToProps = dispatch => ({
9
+ showModal: options => dispatch(showModal({
10
+ confirm: 'modal.ok',
11
+ dismiss: null,
12
+ ...options
13
+ }))
14
+ });
15
+ export default connect(null, mapDispatchToProps);
@@ -1,15 +1,37 @@
1
- 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;}/**
1
+ /**
2
2
  * The portals collection.
3
- */var PortalCollection=/*#__PURE__*/function(){function PortalCollection(){_classCallCheck(this,PortalCollection);}return _createClass(PortalCollection,[{key:"getPortals",value:/**
3
+ */
4
+ class PortalCollection {
5
+ /**
4
6
  * Returns the portal definitions.
5
7
  * @return {Object}
6
- */function getPortals(){return this.portals;}/**
8
+ */
9
+ getPortals() {
10
+ return this.portals;
11
+ }
12
+
13
+ /**
7
14
  * Registers the portal definitions.
8
15
  * @param {Object} [portals={}] The portals to register.
9
- */},{key:"registerPortals",value:function registerPortals(){var portals=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};this.portals=portals;}/**
16
+ */
17
+ registerPortals(portals = {}) {
18
+ this.portals = portals;
19
+ }
20
+
21
+ /**
10
22
  * Registers the portal config.
11
23
  * @param {Object} [config={}] The portals config.
12
- */},{key:"registerConfig",value:function registerConfig(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};this.config=config;}/**
24
+ */
25
+ registerConfig(config = {}) {
26
+ this.config = config;
27
+ }
28
+
29
+ /**
13
30
  * Returns the portal config.
14
31
  * @return {Object}
15
- */},{key:"getConfig",value:function getConfig(){return this.config;}}]);}();export default new PortalCollection();
32
+ */
33
+ getConfig() {
34
+ return this.config;
35
+ }
36
+ }
37
+ export default new PortalCollection();
@@ -1 +1,12 @@
1
- import{componentsConfig}from"../config";import collection from"./portalCollection";import{APP_ROUTES}from"../../constants/Portals";var portals=collection.getPortals();var config=collection.getConfig()||componentsConfig.portals;var routes=Object.keys(config).map(function(component){if(config[component].target!==APP_ROUTES){return null;}return portals[component]();}).filter(Boolean);export default routes;
1
+ import { componentsConfig } from "../config";
2
+ import collection from "./portalCollection";
3
+ import { APP_ROUTES } from "../../constants/Portals";
4
+ const portals = collection.getPortals();
5
+ const config = collection.getConfig() || componentsConfig.portals;
6
+ const routes = Object.keys(config).map(component => {
7
+ if (config[component].target !== APP_ROUTES) {
8
+ return null;
9
+ }
10
+ return portals[component]();
11
+ }).filter(Boolean);
12
+ export default routes;
@@ -1,6 +1,11 @@
1
- import{generateSortedHash}from"./generateSortedHash";/**
1
+ import { generateSortedHash } from "./generateSortedHash";
2
+
3
+ /**
2
4
  * Deep compares two objects.
3
5
  * @param {Object} input1 The first object.
4
6
  * @param {Object} input2 The second object.
5
7
  * @return {boolean}
6
- */export function compareObjects(input1,input2){return generateSortedHash(input1)===generateSortedHash(input2);}
8
+ */
9
+ export function compareObjects(input1, input2) {
10
+ return generateSortedHash(input1) === generateSortedHash(input2);
11
+ }
@@ -1,11 +1,44 @@
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{logger}from'@shopgate/pwa-core/helpers';import*as pipelines from"../../constants/Pipelines";import{generateSortedHash}from"./generateSortedHash";/**
1
+ import { logger } from '@shopgate/pwa-core/helpers';
2
+ import * as pipelines from "../../constants/Pipelines";
3
+ import { generateSortedHash } from "./generateSortedHash";
4
+
5
+ /**
2
6
  * Generates a hash for product collection results.
3
7
  * @param {Object} params The request parameters.
4
8
  * @param {boolean} [includeSort=true] Whether to include the sorting in the hash.
5
9
  * @param {boolean} [includeFilters=true] Whether to include the filters in the hash.
6
10
  * @param {string} [defaultSort=null] A default value for the sort parameter
7
11
  * @return {string} The generated hash.
8
- */export function generateResultHash(params){var includeSort=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var includeFilters=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;var defaultSort=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var defaultParams=_extends({pipeline:pipelines.SHOPGATE_CATALOG_GET_PRODUCTS},includeFilters&&{filters:{}},{},includeSort&&defaultSort&&{sort:defaultSort});var mergedParams=_extends({},defaultParams,{},params);if(includeSort&&!mergedParams.sort){logger.error('generateResultHash() needs to be called with a sort parameter when the sort is supposed to be included');}if(!includeSort&&mergedParams.sort){delete mergedParams.sort;}var searchPhrase=mergedParams.searchPhrase;if(searchPhrase){/**
12
+ */
13
+ export function generateResultHash(params, includeSort = true, includeFilters = true, defaultSort = null) {
14
+ const defaultParams = {
15
+ pipeline: pipelines.SHOPGATE_CATALOG_GET_PRODUCTS,
16
+ ...(includeFilters && {
17
+ filters: {}
18
+ }),
19
+ ...(includeSort && defaultSort && {
20
+ sort: defaultSort
21
+ })
22
+ };
23
+ const mergedParams = {
24
+ ...defaultParams,
25
+ ...params
26
+ };
27
+ if (includeSort && !mergedParams.sort) {
28
+ logger.error('generateResultHash() needs to be called with a sort parameter when the sort is supposed to be included');
29
+ }
30
+ if (!includeSort && mergedParams.sort) {
31
+ delete mergedParams.sort;
32
+ }
33
+ const {
34
+ searchPhrase
35
+ } = mergedParams;
36
+ if (searchPhrase) {
37
+ /**
9
38
  * We trim the search phrase here, because otherwise we will create different hash and cache
10
39
  * entries for the same search term (because whitespaces don't influence the search results)
11
- */mergedParams.searchPhrase=searchPhrase.trim();}return generateSortedHash(mergedParams);}
40
+ */
41
+ mergedParams.searchPhrase = searchPhrase.trim();
42
+ }
43
+ return generateSortedHash(mergedParams);
44
+ }
@@ -1,5 +1,10 @@
1
- import{sortObject}from"../data";/**
1
+ import { sortObject } from "../data";
2
+
3
+ /**
2
4
  * Generates a hash from an object with sorted values.
3
5
  * @param {Object} input The input object.
4
6
  * @return {string} The generated hash.
5
- */export function generateSortedHash(input){return JSON.stringify(sortObject(input));}
7
+ */
8
+ export function generateSortedHash(input) {
9
+ return JSON.stringify(sortObject(input));
10
+ }
@@ -2,5 +2,13 @@
2
2
  * Determines if an item has expired and therefore should fetch or re-fetch it's data.
3
3
  * @param {Object} item The item to determine if it has expired.
4
4
  * @return {boolean}
5
- */export function hasExpired(item){if(!item.isFetching){// If the expiry date has expired or is set to 0 (initial value).
6
- if(item.expires===0||item.expires&&item.expires>0&&item.expires<Date.now()){return true;}}return false;}
5
+ */
6
+ export function hasExpired(item) {
7
+ if (!item.isFetching) {
8
+ // If the expiry date has expired or is set to 0 (initial value).
9
+ if (item.expires === 0 || item.expires && item.expires > 0 && item.expires < Date.now()) {
10
+ return true;
11
+ }
12
+ }
13
+ return false;
14
+ }
@@ -1 +1,7 @@
1
- export{hasExpired}from"./hasExpired";export{shouldFetchData}from"./shouldFetchData";export{shouldFetchFilters}from"./shouldFetchFilters";export{compareObjects}from"./compareObjects";export{generateSortedHash}from"./generateSortedHash";export{generateResultHash}from"./generateResultHash";export{mutable,mutableActions}from"./mutable";
1
+ export { hasExpired } from "./hasExpired";
2
+ export { shouldFetchData } from "./shouldFetchData";
3
+ export { shouldFetchFilters } from "./shouldFetchFilters";
4
+ export { compareObjects } from "./compareObjects";
5
+ export { generateSortedHash } from "./generateSortedHash";
6
+ export { generateResultHash } from "./generateResultHash";
7
+ export { mutable, mutableActions } from "./mutable";