@shopgate/engage 6.20.0-beta.1 → 6.20.0-beta.4

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 (257) hide show
  1. package/a11y/components/LiveMessage/__tests__/index.spec.js +1 -1
  2. package/a11y/components/LiveMessage/index.js +1 -1
  3. package/a11y/components/LiveMessenger/__tests__/index.spec.js +1 -1
  4. package/a11y/components/LiveMessenger/helpers.js +1 -1
  5. package/a11y/components/LiveMessenger/index.js +2 -2
  6. package/a11y/components/Navigation/__tests__/index.spec.js +1 -1
  7. package/a11y/components/Navigation/index.js +1 -1
  8. package/a11y/components/Section/__tests__/index.spec.js +1 -1
  9. package/a11y/components/Section/index.js +2 -2
  10. package/a11y/index.spec.js +1 -1
  11. package/account/constants/index.js +1 -0
  12. package/account/constants/routes.js +1 -0
  13. package/account/index.js +1 -0
  14. package/app-rating/actions/showModal.js +2 -2
  15. package/cart/index.spec.js +1 -1
  16. package/category/components/CategoryList/index.js +1 -1
  17. package/category/index.spec.js +1 -1
  18. package/checkout/index.spec.js +1 -1
  19. package/components/ChipLayout/index.js +11 -11
  20. package/components/ChipLayout/spec.js +1 -1
  21. package/components/Footer/Footer.js +9 -9
  22. package/components/Footer/__tests__/Footer.spec.js +4 -4
  23. package/components/Form/Builder/Builder.js +10 -10
  24. package/components/Form/Builder/Builder.spec.js +4 -4
  25. package/components/Form/Builder/ElementCheckbox.js +1 -1
  26. package/components/Form/Builder/ElementRadio.js +1 -1
  27. package/components/Form/Builder/ElementSelect.js +1 -1
  28. package/components/Form/Builder/ElementText.js +1 -1
  29. package/components/Form/Builder/classes/ActionListener.js +3 -3
  30. package/components/Form/Builder/helpers/buildCountryList.js +1 -1
  31. package/components/Form/Builder/helpers/buildFormDefaults.js +1 -1
  32. package/components/Form/Builder/helpers/buildFormElements.js +2 -2
  33. package/components/Form/Builder/helpers/buildFormElements.spec.js +2 -2
  34. package/components/Form/Builder/helpers/buildProvinceList.js +1 -1
  35. package/components/Form/Form.js +8 -8
  36. package/components/IntersectionVisibility/index.js +5 -5
  37. package/components/Logo/index.js +1 -1
  38. package/components/Logo/spec.js +1 -1
  39. package/components/MessageBar/index.js +1 -1
  40. package/components/MessageBar/spec.js +1 -1
  41. package/components/NavigationHandler/index.js +5 -5
  42. package/components/NavigationHandler/spec.js +1 -1
  43. package/components/Picker/components/Button/index.js +1 -1
  44. package/components/Picker/components/List/index.js +1 -1
  45. package/components/Picker/components/Modal/index.js +5 -5
  46. package/components/Picker/index.js +9 -9
  47. package/components/Picker/spec.js +1 -1
  48. package/components/PickerUtilize/components/Button/index.js +1 -1
  49. package/components/PickerUtilize/index.js +6 -6
  50. package/components/PickerUtilize/spec.js +1 -1
  51. package/components/QuantityInput/QuantityInput.js +4 -4
  52. package/components/RangeSlider/components/Handle/index.js +1 -1
  53. package/components/RangeSlider/index.js +11 -11
  54. package/components/RangeSlider/spec.js +4 -4
  55. package/components/ScrollHeader/index.js +2 -2
  56. package/components/SheetDrawer/index.js +1 -1
  57. package/components/SheetList/components/Item/index.js +5 -5
  58. package/components/SheetList/components/Item/spec.js +2 -2
  59. package/components/SheetList/index.js +4 -4
  60. package/components/SheetList/spec.js +1 -1
  61. package/components/SnackBarContainer/index.js +1 -1
  62. package/components/TimeBoundary/index.js +5 -5
  63. package/components/TimeBoundary/spec.js +3 -3
  64. package/components/VideoPlayer/index.js +6 -6
  65. package/components/View/__mocks__/index.js +1 -1
  66. package/components/View/__tests__/index.spec.js +1 -1
  67. package/components/View/__tests__/provider.spec.js +1 -1
  68. package/components/View/components/Above/__tests__/index.spec.js +1 -1
  69. package/components/View/components/Above/index.js +1 -1
  70. package/components/View/components/Below/__tests__/index.spec.js +1 -1
  71. package/components/View/components/Below/index.js +1 -1
  72. package/components/View/components/Content/__tests__/index.spec.js +1 -1
  73. package/components/View/components/Content/index.js +9 -9
  74. package/components/View/context.js +1 -1
  75. package/components/View/index.js +2 -2
  76. package/components/View/provider.js +6 -4
  77. package/components/index.spec.js +1 -1
  78. package/core/actions/__tests__/getGeolocation.spec.js +2 -2
  79. package/core/actions/__tests__/grantPermissions.spec.js +1 -1
  80. package/core/actions/getGeolocation.js +1 -1
  81. package/core/actions/grantPermissions.js +3 -3
  82. package/core/classes/GeolocationRequest.js +3 -3
  83. package/core/config/ThemeConfigResolver.js +1 -1
  84. package/core/constants/shopSettings.js +2 -0
  85. package/core/contexts/AppContext.js +1 -1
  86. package/core/helpers/getFullImageSource.js +2 -2
  87. package/core/helpers/updateLegacyNavigationBar.js +1 -1
  88. package/core/hocs/__mocks__/withWidgetSettings.js +1 -1
  89. package/core/hocs/__tests__/withApp.spec.js +1 -1
  90. package/core/hocs/__tests__/withCurrentProduct.spec.js +1 -1
  91. package/core/hocs/__tests__/withForwardedRef.spec.js +1 -1
  92. package/core/hocs/__tests__/withNavigation.spec.js +1 -1
  93. package/core/hocs/__tests__/withRoute.spec.js +1 -1
  94. package/core/hocs/__tests__/withTheme.spec.js +2 -2
  95. package/core/hocs/__tests__/withWidgetSettings.spec.js +1 -1
  96. package/core/hocs/__tests__/withWidgetStyles.spec.js +1 -1
  97. package/core/hocs/withApp.js +1 -1
  98. package/core/hocs/withCurrentProduct.js +1 -1
  99. package/core/hocs/withForwardedRef.js +1 -1
  100. package/core/hocs/withNavigation.js +1 -1
  101. package/core/hocs/withRoute.js +1 -1
  102. package/core/hocs/withTheme.js +2 -2
  103. package/core/hocs/withWidgetSettings.js +1 -1
  104. package/core/hocs/withWidgetStyles.js +1 -1
  105. package/core/hooks/__tests__/useNavigation.spec.js +1 -1
  106. package/core/hooks/html/useLoadImage.js +1 -1
  107. package/core/hooks/useTheme.js +2 -2
  108. package/core/index.spec.js +1 -1
  109. package/core/providers/AppProvider.js +9 -7
  110. package/core/providers/__tests__/AppProvider.spec.js +2 -2
  111. package/core/selectors/index.js +1 -0
  112. package/core/selectors/shopSettings.js +14 -0
  113. package/favorites/components/FavoriteProvider/connector.js +5 -0
  114. package/favorites/components/FavoriteProvider/index.js +4 -0
  115. package/favorites/components/Item/Item.js +10 -0
  116. package/favorites/components/Item/ItemCharacteristics.js +4 -0
  117. package/favorites/components/Item/index.js +1 -0
  118. package/favorites/components/List/List.js +16 -0
  119. package/favorites/components/List/index.js +1 -0
  120. package/favorites/components/ListChooser/ListChooser.js +10 -0
  121. package/favorites/components/ListChooser/ListChooserItem.js +7 -0
  122. package/favorites/components/ListChooser/index.js +1 -0
  123. package/favorites/components/Lists/Lists.js +16 -0
  124. package/favorites/components/Lists/ListsModal.js +4 -0
  125. package/favorites/components/Lists/index.js +1 -0
  126. package/favorites/components/RemoveButton/RemoveButton.js +4 -0
  127. package/favorites/components/RemoveButton/index.js +1 -0
  128. package/favorites/constants/Portals.js +2 -0
  129. package/favorites/index.js +3 -4
  130. package/favorites/index.spec.js +1 -1
  131. package/filter/components/FilterItem/index.js +1 -1
  132. package/filter/components/FilterItem/spec.js +1 -1
  133. package/filter/components/PriceSlider/components/Label/index.js +2 -2
  134. package/filter/components/PriceSlider/components/Label/spec.js +1 -1
  135. package/filter/components/PriceSlider/index.js +6 -6
  136. package/filter/components/PriceSlider/spec.js +1 -1
  137. package/filter/helpers/__tests__/buildUpdatedFilters.spec.js +1 -1
  138. package/filter/helpers/buildInitialFilters.js +1 -1
  139. package/filter/helpers/buildUpdatedFilters.js +2 -2
  140. package/filter/index.spec.js +1 -1
  141. package/index.spec.js +1 -1
  142. package/market/index.spec.js +1 -1
  143. package/orders/index.spec.js +1 -1
  144. package/package.json +7 -7
  145. package/page/index.spec.js +1 -1
  146. package/product/components/Characteristics/Characteristic/components/Sheet/index.js +4 -4
  147. package/product/components/Characteristics/Characteristic/components/SheetItem/index.js +3 -3
  148. package/product/components/Characteristics/Characteristic/components/VariantAvailability/index.js +3 -3
  149. package/product/components/Characteristics/Characteristic/index.js +5 -5
  150. package/product/components/Characteristics/Swatch/index.js +5 -5
  151. package/product/components/Characteristics/index.js +3 -3
  152. package/product/components/Description/__tests__/Description.spec.js +1 -1
  153. package/product/components/Description/index.js +2 -2
  154. package/product/components/EffectivityDates/index.js +1 -1
  155. package/product/components/Header/PriceStriked/index.js +1 -1
  156. package/product/components/Header/Shipping/components/Label/index.js +2 -2
  157. package/product/components/Header/Shipping/index.js +1 -1
  158. package/product/components/Header/Shipping/spec.js +1 -1
  159. package/product/components/Header/Tiers/components/Tier/index.js +2 -2
  160. package/product/components/Header/Tiers/components/Tier/spec.js +1 -1
  161. package/product/components/Header/Tiers/index.js +1 -1
  162. package/product/components/Header/Tiers/spec.js +1 -1
  163. package/product/components/MapPriceHint/index.js +1 -1
  164. package/product/components/Media/FeaturedMedia.js +1 -1
  165. package/product/components/Media/MediaImage.js +2 -2
  166. package/product/components/Media/MediaPlaceholder.js +1 -1
  167. package/product/components/Media/helpers.js +2 -2
  168. package/product/components/MediaSlider/components/MediaImage/index.js +1 -1
  169. package/product/components/MediaSlider/components/MediaVideo/index.js +1 -1
  170. package/product/components/MediaSlider/index.js +1 -1
  171. package/product/components/Options/components/Content/index.js +6 -6
  172. package/product/components/Options/components/Content/spec.js +1 -1
  173. package/product/components/Options/components/Option/index.js +1 -1
  174. package/product/components/Options/components/TextOption/components/OptionInfo/index.js +2 -2
  175. package/product/components/Options/components/TextOption/components/OptionInfo/spec.js +1 -1
  176. package/product/components/Options/components/TextOption/index.js +6 -6
  177. package/product/components/Options/index.js +1 -1
  178. package/product/components/OrderQuantityHint/index.js +1 -1
  179. package/product/components/PriceDifference/index.js +1 -1
  180. package/product/components/ProductBadges/index.js +2 -2
  181. package/product/components/ProductCard/index.js +2 -2
  182. package/product/components/ProductCharacteristics/context.js +1 -1
  183. package/product/components/ProductCharacteristics/index.js +9 -9
  184. package/product/components/ProductDiscountBadge/index.js +1 -1
  185. package/product/components/ProductDiscountBadge/spec.js +1 -1
  186. package/product/components/ProductGridPrice/index.js +1 -1
  187. package/product/components/ProductGridPrice/index.spec.js +1 -1
  188. package/product/components/ProductImage/index.js +7 -7
  189. package/product/components/ProductImage/spec.js +1 -1
  190. package/product/components/ProductList/components/Item/index.js +1 -1
  191. package/product/components/ProductList/components/Iterator/index.js +1 -1
  192. package/product/components/ProductList/components/Layout/index.js +1 -1
  193. package/product/components/ProductList/index.js +1 -1
  194. package/product/components/ProductProperties/Content.js +2 -2
  195. package/product/components/ProductProperties/Group.js +1 -1
  196. package/product/components/ProductProperties/GroupedProperties.js +1 -1
  197. package/product/components/ProductProperties/Lists.js +1 -1
  198. package/product/components/ProductProperties/ProductProperties.js +1 -1
  199. package/product/components/ProductProperties/Row.js +1 -1
  200. package/product/components/ProductProperties/Rows.js +1 -1
  201. package/product/components/ProductProperties/Wrapper.js +1 -1
  202. package/product/components/ProductProperties/__tests__/Content.spec.js +1 -1
  203. package/product/components/ProductProperties/__tests__/Group.spec.js +1 -1
  204. package/product/components/ProductProperties/__tests__/GroupedProperties.spec.js +1 -1
  205. package/product/components/ProductProperties/__tests__/Lists.spec.js +1 -1
  206. package/product/components/ProductProperties/__tests__/ProductProperties.spec.js +1 -1
  207. package/product/components/ProductProperties/__tests__/Row.spec.js +1 -1
  208. package/product/components/ProductProperties/__tests__/Rows.spec.js +1 -1
  209. package/product/components/ProductProvider/index.js +1 -1
  210. package/product/components/ProductSlider/index.js +1 -1
  211. package/product/components/ProductSlider/spec.js +1 -1
  212. package/product/components/QuantityPicker/index.js +2 -2
  213. package/product/components/Rating/index.js +2 -2
  214. package/product/components/Rating/spec.js +1 -1
  215. package/product/components/RelationsSlider/RelationsSheet.js +2 -2
  216. package/product/components/RelationsSlider/RelationsSlider.js +1 -1
  217. package/product/components/RelationsSlider/RelationsSliderContent.js +1 -1
  218. package/product/components/Swatch/Swatch.js +1 -1
  219. package/product/components/Swatch/SwatchContent.js +1 -1
  220. package/product/components/Swatch/VariantSwatch.js +1 -1
  221. package/product/components/Swatches/Swatches.js +1 -1
  222. package/product/components/UnitQuantityPicker/ProductUnitQuantityPicker.js +1 -1
  223. package/product/components/UnitQuantityPicker/UnitQuantityPicker.js +1 -1
  224. package/product/components/UnitQuantityPicker/UnitQuantityPickerWithSection.js +1 -1
  225. package/product/components/__mocks__/context.js +1 -1
  226. package/product/components/context.js +1 -1
  227. package/product/helpers/index.js +1 -1
  228. package/product/hocs/withMapPricing.js +4 -4
  229. package/product/hocs/withPriceCalculation.js +2 -2
  230. package/product/hooks/useLoadProductImage.js +1 -1
  231. package/product/index.spec.js +1 -1
  232. package/reviews/components/Reviews/components/AllReviewsLink/index.js +1 -1
  233. package/reviews/components/Reviews/components/Header/components/AverageRating/index.js +2 -2
  234. package/reviews/components/Reviews/components/Header/components/NoReviews/index.js +1 -1
  235. package/reviews/components/Reviews/components/Header/components/ReviewsExcerpt/index.js +1 -1
  236. package/reviews/components/Reviews/components/Header/components/WriteReviewLink/index.js +1 -1
  237. package/reviews/components/Reviews/components/Header/components/WriteReviewLink/spec.js +1 -1
  238. package/reviews/components/Reviews/components/Header/index.js +1 -1
  239. package/reviews/components/Reviews/components/Header/spec.js +1 -1
  240. package/reviews/components/Reviews/components/List/components/Info/components/Author/index.js +1 -1
  241. package/reviews/components/Reviews/components/List/components/Info/components/ReviewDate/index.js +1 -1
  242. package/reviews/components/Reviews/components/List/components/Info/index.js +2 -2
  243. package/reviews/components/Reviews/components/List/components/Rating/index.js +1 -1
  244. package/reviews/components/Reviews/components/List/components/Review/index.js +1 -1
  245. package/reviews/components/Reviews/components/List/components/Text/index.js +1 -1
  246. package/reviews/components/Reviews/components/List/components/Title/index.js +1 -1
  247. package/reviews/components/Reviews/components/List/index.js +3 -3
  248. package/reviews/components/Reviews/components/List/spec.js +1 -1
  249. package/reviews/components/Reviews/components/RatingCount/index.js +1 -1
  250. package/reviews/components/Reviews/components/RatingCount/spec.js +1 -1
  251. package/reviews/components/Reviews/index.js +1 -1
  252. package/reviews/components/Reviews/spec.js +2 -2
  253. package/reviews/index.spec.js +1 -1
  254. package/scanner/index.spec.js +1 -1
  255. package/search/index.spec.js +1 -1
  256. package/user/index.spec.js +1 -1
  257. package/core/helpers/getImageFormat.js +0 -4
@@ -1 +1 @@
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*as components from'.';describe('engage > components',function(){it('should have exports',function(){expect(_typeof(components)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(components).forEach(function(exportKey){expect(typeof components[exportKey]!=='undefined').toBe(true);});});});
1
+ function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import*as components from'.';describe('engage > components',function(){it('should have exports',function(){expect(_typeof(components)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(components).forEach(function(exportKey){expect(typeof components[exportKey]!=='undefined').toBe(true);});});});
@@ -1,2 +1,2 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}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;}import grantGeolocationPermissions from"../grantGeolocationPermissions";import getGeolocation from"../getGeolocation";import{GEOLOCATION_ERROR_DENIED}from"../../constants/geolocationRequest";var mockedPosition={coords:{accuracy:25,latitude:50.4330,longitude:8.67447},timestamp:1563873516224};var mockedGeolocationRequest=jest.fn().mockResolvedValue(mockedPosition);jest.mock("../grantGeolocationPermissions",function(){return jest.fn().mockResolvedValue(true);});jest.mock("../../classes/GeolocationRequest",function(){return(/*#__PURE__*/function(){function Foo(){_classCallCheck(this,Foo);}_createClass(Foo,[{key:"dispatch",// eslint-disable-next-line require-jsdoc, class-methods-use-this
2
- value:function dispatch(){return mockedGeolocationRequest();}}]);return Foo;}());});describe('engage > core > actions > grantCameraPermissions',function(){var dispatch=jest.fn(function(action){return action;});beforeEach(function(){jest.clearAllMocks();});it('should resolve the with current position',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var position;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return getGeolocation()(dispatch);case 2:position=_context.sent;expect(position).toBe(mockedPosition);expect(dispatch).toHaveBeenCalledTimes(1);expect(grantGeolocationPermissions).toHaveBeenCalledTimes(1);expect(grantGeolocationPermissions).toHaveBeenCalledWith({});expect(mockedGeolocationRequest).toHaveBeenCalledTimes(1);case 8:case"end":return _context.stop();}}},_callee);})));it('should pass through the options to the grantGeolocationPermissions action call',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(){var options;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:options={useSettingsModal:true,modal:{message:'Modal message',confirm:'Confirm label'}};_context2.next=3;return expect(getGeolocation(options)(dispatch)).resolves.toBe(mockedPosition);case 3:expect(grantGeolocationPermissions).toHaveBeenCalledWith(options);case 4:case"end":return _context2.stop();}}},_callee2);})));it('should reject with an error when permissions are not granted',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(){return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:grantGeolocationPermissions.mockResolvedValueOnce(false);expect.assertions(4);_context3.prev=2;_context3.next=5;return getGeolocation()(dispatch);case 5:_context3.next=13;break;case 7:_context3.prev=7;_context3.t0=_context3["catch"](2);expect(_context3.t0).toBeInstanceOf(Error);expect(_context3.t0.code).toBe(GEOLOCATION_ERROR_DENIED);expect(grantGeolocationPermissions).toHaveBeenCalledTimes(1);expect(mockedGeolocationRequest).not.toHaveBeenCalled();case 13:case"end":return _context3.stop();}}},_callee3,null,[[2,7]]);})));it('should reject with an error when permissions are not granted',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(){return _regeneratorRuntime.wrap(function _callee4$(_context4){while(1){switch(_context4.prev=_context4.next){case 0:mockedGeolocationRequest.mockRejectedValueOnce(new Error());expect.assertions(3);_context4.prev=2;_context4.next=5;return getGeolocation()(dispatch);case 5:_context4.next=12;break;case 7:_context4.prev=7;_context4.t0=_context4["catch"](2);expect(_context4.t0).toBeInstanceOf(Error);expect(grantGeolocationPermissions).toHaveBeenCalledTimes(1);expect(mockedGeolocationRequest).toHaveBeenCalledTimes(1);case 12:case"end":return _context4.stop();}}},_callee4,null,[[2,7]]);})));});
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}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);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}import grantGeolocationPermissions from"../grantGeolocationPermissions";import getGeolocation from"../getGeolocation";import{GEOLOCATION_ERROR_DENIED}from"../../constants/geolocationRequest";var mockedPosition={coords:{accuracy:25,latitude:50.4330,longitude:8.67447},timestamp:1563873516224};var mockedGeolocationRequest=jest.fn().mockResolvedValue(mockedPosition);jest.mock("../grantGeolocationPermissions",function(){return jest.fn().mockResolvedValue(true);});jest.mock("../../classes/GeolocationRequest",function(){return/*#__PURE__*/function(){function Foo(){_classCallCheck(this,Foo);}_createClass(Foo,[{key:"dispatch",value:// eslint-disable-next-line require-jsdoc, class-methods-use-this
2
+ function dispatch(){return mockedGeolocationRequest();}}]);return Foo;}();});describe('engage > core > actions > grantCameraPermissions',function(){var dispatch=jest.fn(function(action){return action;});beforeEach(function(){jest.clearAllMocks();});it('should resolve the with current position',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var position;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return getGeolocation()(dispatch);case 2:position=_context.sent;expect(position).toBe(mockedPosition);expect(dispatch).toHaveBeenCalledTimes(1);expect(grantGeolocationPermissions).toHaveBeenCalledTimes(1);expect(grantGeolocationPermissions).toHaveBeenCalledWith({});expect(mockedGeolocationRequest).toHaveBeenCalledTimes(1);case 8:case"end":return _context.stop();}}},_callee);})));it('should pass through the options to the grantGeolocationPermissions action call',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(){var options;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:options={useSettingsModal:true,modal:{message:'Modal message',confirm:'Confirm label'}};_context2.next=3;return expect(getGeolocation(options)(dispatch)).resolves.toBe(mockedPosition);case 3:expect(grantGeolocationPermissions).toHaveBeenCalledWith(options);case 4:case"end":return _context2.stop();}}},_callee2);})));it('should reject with an error when permissions are not granted',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(){return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:grantGeolocationPermissions.mockResolvedValueOnce(false);expect.assertions(4);_context3.prev=2;_context3.next=5;return getGeolocation()(dispatch);case 5:_context3.next=13;break;case 7:_context3.prev=7;_context3.t0=_context3["catch"](2);expect(_context3.t0).toBeInstanceOf(Error);expect(_context3.t0.code).toBe(GEOLOCATION_ERROR_DENIED);expect(grantGeolocationPermissions).toHaveBeenCalledTimes(1);expect(mockedGeolocationRequest).not.toHaveBeenCalled();case 13:case"end":return _context3.stop();}}},_callee3,null,[[2,7]]);})));it('should reject with an error when permissions are not granted',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(){return _regeneratorRuntime.wrap(function _callee4$(_context4){while(1){switch(_context4.prev=_context4.next){case 0:mockedGeolocationRequest.mockRejectedValueOnce(new Error());expect.assertions(3);_context4.prev=2;_context4.next=5;return getGeolocation()(dispatch);case 5:_context4.next=12;break;case 7:_context4.prev=7;_context4.t0=_context4["catch"](2);expect(_context4.t0).toBeInstanceOf(Error);expect(grantGeolocationPermissions).toHaveBeenCalledTimes(1);expect(mockedGeolocationRequest).toHaveBeenCalledTimes(1);case 12:case"end":return _context4.stop();}}},_callee4,null,[[2,7]]);})));});
@@ -1,4 +1,4 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";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 asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import event from'@shopgate/pwa-core/classes/Event';import{APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND}from'@shopgate/pwa-core/constants/AppEvents';import openAppSettings from'@shopgate/pwa-core/commands/openAppSettings';import showModal from'@shopgate/pwa-common/actions/modal/showModal';import{STATUS_DENIED,STATUS_GRANTED,STATUS_NOT_DETERMINED,STATUS_NOT_SUPPORTED,PERMISSION_ID_CAMERA}from'@shopgate/pwa-core/constants/AppPermissions';import{getAppPermissions,requestAppPermissions}from'@shopgate/pwa-core/commands/appPermissions';import{logger}from'@shopgate/pwa-core/helpers';import grantPermissions from"../grantPermissions";jest.mock('@shopgate/pwa-core/classes/Event');jest.mock('@shopgate/pwa-core/commands/openAppSettings');jest.mock('@shopgate/pwa-core/commands/appPermissions',function(){return{getAppPermissions:jest.fn(),requestAppPermissions:jest.fn()};});jest.mock('@shopgate/pwa-common/actions/modal/showModal',function(){return jest.fn();});jest.mock('@shopgate/pwa-core/helpers',function(){return{logger:{error:jest.fn()}};});/**
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 _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import event from'@shopgate/pwa-core/classes/Event';import{APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND}from'@shopgate/pwa-core/constants/AppEvents';import openAppSettings from'@shopgate/pwa-core/commands/openAppSettings';import showModal from'@shopgate/pwa-common/actions/modal/showModal';import{STATUS_DENIED,STATUS_GRANTED,STATUS_NOT_DETERMINED,STATUS_NOT_SUPPORTED,PERMISSION_ID_CAMERA}from'@shopgate/pwa-core/constants/AppPermissions';import{getAppPermissions,requestAppPermissions}from'@shopgate/pwa-core/commands/appPermissions';import{logger}from'@shopgate/pwa-core/helpers';import grantPermissions from"../grantPermissions";jest.mock('@shopgate/pwa-core/classes/Event');jest.mock('@shopgate/pwa-core/commands/openAppSettings');jest.mock('@shopgate/pwa-core/commands/appPermissions',function(){return{getAppPermissions:jest.fn(),requestAppPermissions:jest.fn()};});jest.mock('@shopgate/pwa-common/actions/modal/showModal',function(){return jest.fn();});jest.mock('@shopgate/pwa-core/helpers',function(){return{logger:{error:jest.fn()}};});/**
2
2
  * @param {string} status The desired permission status.
3
3
  * @returns {Array}
4
4
  */var getPermissionsResponse=function getPermissionsResponse(){var status=arguments.length>0&&arguments[0]!==undefined?arguments[0]:STATUS_GRANTED;return[{status:status}];};/**
@@ -11,4 +11,4 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
11
11
  * @param {string} options.modal.dismiss Label for the dismiss button.
12
12
  * @param {Object} options.modal.params Additional parameters for i18n strings.
13
13
  * @return { Function } A redux thunk.
14
- */var getGeolocation=function getGeolocation(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var granted,error;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return dispatch(grantGeolocationPermissions(options));case 2:granted=_context.sent;if(granted){_context.next=7;break;}error=new Error('Geolocation permissions not granted.');error.code=GEOLOCATION_ERROR_DENIED;throw error;case 7:return _context.abrupt("return",new GeolocationRequest().dispatch());case 8:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref.apply(this,arguments);};}());};export default getGeolocation;
14
+ */var getGeolocation=function getGeolocation(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var granted,error;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return dispatch(grantGeolocationPermissions(options));case 2:granted=_context.sent;if(granted){_context.next=7;break;}error=new Error('Geolocation permissions not granted.');error.code=GEOLOCATION_ERROR_DENIED;throw error;case 7:return _context.abrupt("return",new GeolocationRequest().dispatch());case 8:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref.apply(this,arguments);};}();};export default getGeolocation;
@@ -1,4 +1,4 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import event from'@shopgate/pwa-core/classes/Event';import{APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND}from'@shopgate/pwa-core/constants/AppEvents';import openAppSettings from'@shopgate/pwa-core/commands/openAppSettings';import showModal from'@shopgate/pwa-common/actions/modal/showModal';import{STATUS_DENIED,STATUS_GRANTED,STATUS_NOT_DETERMINED,STATUS_NOT_SUPPORTED,availablePermissionsIds}from'@shopgate/pwa-core/constants/AppPermissions';import{getAppPermissions,requestAppPermissions}from'@shopgate/pwa-core/commands/appPermissions';import{logger}from'@shopgate/pwa-core/helpers';/**
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import event from'@shopgate/pwa-core/classes/Event';import{APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND}from'@shopgate/pwa-core/constants/AppEvents';import openAppSettings from'@shopgate/pwa-core/commands/openAppSettings';import showModal from'@shopgate/pwa-common/actions/modal/showModal';import{STATUS_DENIED,STATUS_GRANTED,STATUS_NOT_DETERMINED,STATUS_NOT_SUPPORTED,availablePermissionsIds}from'@shopgate/pwa-core/constants/AppPermissions';import{getAppPermissions,requestAppPermissions}from'@shopgate/pwa-core/commands/appPermissions';import{logger}from'@shopgate/pwa-core/helpers';/**
2
2
  * Determines the current state of a specific permission for an app feature. If not already
3
3
  * happened, the user will be prompted to grant permissions.
4
4
  * The action returns a promise which resolves with a boolean value, that indicates the state.
@@ -13,9 +13,9 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _slicedToAr
13
13
  * @param {string} options.modal.dismiss Label for the dismiss button.
14
14
  * @param {Object} options.modal.params Additional parameters for i18n strings.
15
15
  * @return { Function } A redux thunk.
16
- */var grantPermissions=function grantPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){return new Promise(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve){var permissionId,_options$useSettingsM,useSettingsModal,_options$modal,modalOptions,status,_ref2,_ref3,_ref4,_ref5,openSettings,handler;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:permissionId=options.permissionId,_options$useSettingsM=options.useSettingsModal,useSettingsModal=_options$useSettingsM===void 0?false:_options$useSettingsM,_options$modal=options.modal,modalOptions=_options$modal===void 0?{}:_options$modal;if(availablePermissionsIds.includes(permissionId)){_context2.next=5;break;}logger.error('grandPermissions: %s is no valid permission id',permissionId);resolve(false);return _context2.abrupt("return");case 5:_context2.next=7;return getAppPermissions([permissionId]);case 7:_ref2=_context2.sent;_ref3=_slicedToArray(_ref2,1);status=_ref3[0].status;if(!(status===STATUS_NOT_SUPPORTED)){_context2.next=13;break;}resolve(false);return _context2.abrupt("return");case 13:if(!(status===STATUS_NOT_DETERMINED)){_context2.next=22;break;}_context2.next=16;return requestAppPermissions([{permissionId:permissionId}]);case 16:_ref4=_context2.sent;_ref5=_slicedToArray(_ref4,1);status=_ref5[0].status;if(![STATUS_DENIED,STATUS_NOT_DETERMINED].includes(status)){_context2.next=22;break;}resolve(false);return _context2.abrupt("return");case 22:if(!(status===STATUS_GRANTED)){_context2.next=25;break;}resolve(true);return _context2.abrupt("return");case 25:if(!(status===STATUS_DENIED)){_context2.next=38;break;}if(useSettingsModal){_context2.next=29;break;}resolve(false);return _context2.abrupt("return");case 29:_context2.next=31;return dispatch(showModal({title:modalOptions.title||null,message:modalOptions.message,confirm:modalOptions.confirm,dismiss:modalOptions.dismiss,params:modalOptions.params}));case 31:openSettings=_context2.sent;if(openSettings){_context2.next=35;break;}resolve(false);return _context2.abrupt("return");case 35:/**
16
+ */var grantPermissions=function grantPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){return new Promise(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve){var permissionId,_options$useSettingsM,useSettingsModal,_options$modal,modalOptions,status,_yield$getAppPermissi,_yield$getAppPermissi2,_yield$requestAppPerm,_yield$requestAppPerm2,openSettings,handler;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:permissionId=options.permissionId,_options$useSettingsM=options.useSettingsModal,useSettingsModal=_options$useSettingsM===void 0?false:_options$useSettingsM,_options$modal=options.modal,modalOptions=_options$modal===void 0?{}:_options$modal;if(availablePermissionsIds.includes(permissionId)){_context2.next=5;break;}logger.error('grandPermissions: %s is no valid permission id',permissionId);resolve(false);return _context2.abrupt("return");case 5:_context2.next=7;return getAppPermissions([permissionId]);case 7:_yield$getAppPermissi=_context2.sent;_yield$getAppPermissi2=_slicedToArray(_yield$getAppPermissi,1);status=_yield$getAppPermissi2[0].status;if(!(status===STATUS_NOT_SUPPORTED)){_context2.next=13;break;}resolve(false);return _context2.abrupt("return");case 13:if(!(status===STATUS_NOT_DETERMINED)){_context2.next=22;break;}_context2.next=16;return requestAppPermissions([{permissionId:permissionId}]);case 16:_yield$requestAppPerm=_context2.sent;_yield$requestAppPerm2=_slicedToArray(_yield$requestAppPerm,1);status=_yield$requestAppPerm2[0].status;if(![STATUS_DENIED,STATUS_NOT_DETERMINED].includes(status)){_context2.next=22;break;}resolve(false);return _context2.abrupt("return");case 22:if(!(status===STATUS_GRANTED)){_context2.next=25;break;}resolve(true);return _context2.abrupt("return");case 25:if(!(status===STATUS_DENIED)){_context2.next=38;break;}if(useSettingsModal){_context2.next=29;break;}resolve(false);return _context2.abrupt("return");case 29:_context2.next=31;return dispatch(showModal({title:modalOptions.title||null,message:modalOptions.message,confirm:modalOptions.confirm,dismiss:modalOptions.dismiss,params:modalOptions.params}));case 31:openSettings=_context2.sent;if(openSettings){_context2.next=35;break;}resolve(false);return _context2.abrupt("return");case 35:/**
17
17
  * Handler for the app event.
18
- */handler=/*#__PURE__*/function(){var _ref6=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var _ref7,_ref8;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:event.removeCallback(APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,handler);_context.next=3;return getAppPermissions([permissionId]);case 3:_ref7=_context.sent;_ref8=_slicedToArray(_ref7,1);status=_ref8[0].status;resolve(status===STATUS_GRANTED);case 7:case"end":return _context.stop();}}},_callee);}));return function handler(){return _ref6.apply(this,arguments);};}();/**
18
+ */handler=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var _yield$getAppPermissi3,_yield$getAppPermissi4;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:event.removeCallback(APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,handler);_context.next=3;return getAppPermissions([permissionId]);case 3:_yield$getAppPermissi3=_context.sent;_yield$getAppPermissi4=_slicedToArray(_yield$getAppPermissi3,1);status=_yield$getAppPermissi4[0].status;resolve(status===STATUS_GRANTED);case 7:case"end":return _context.stop();}}},_callee);}));return function handler(){return _ref2.apply(this,arguments);};}();/**
19
19
  * Register an event handler, so that we can perform the permissions check again,
20
20
  * when the user comes back from the settings.
21
21
  */event.addCallback(APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,handler);// Open the settings (protected by a timeout, so that the modal closes before the app is left).
@@ -1,10 +1,10 @@
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;}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{GEOLOCATION_ERROR_UNKNOWN,GEOLOCATION_ERROR_DENIED,GEOLOCATION_ERROR_UNAVAILABLE,GEOLOCATION_ERROR_TIMEOUT}from"../constants/geolocationRequest";var errorMapping=[GEOLOCATION_ERROR_UNKNOWN,GEOLOCATION_ERROR_DENIED,GEOLOCATION_ERROR_UNAVAILABLE,GEOLOCATION_ERROR_TIMEOUT];export var GEOLOCATION_DEFAULT_TIMEOUT=10000;/**
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);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}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{GEOLOCATION_ERROR_UNKNOWN,GEOLOCATION_ERROR_DENIED,GEOLOCATION_ERROR_UNAVAILABLE,GEOLOCATION_ERROR_TIMEOUT}from"../constants/geolocationRequest";var errorMapping=[GEOLOCATION_ERROR_UNKNOWN,GEOLOCATION_ERROR_DENIED,GEOLOCATION_ERROR_UNAVAILABLE,GEOLOCATION_ERROR_TIMEOUT];export var GEOLOCATION_DEFAULT_TIMEOUT=10000;/**
2
2
  * The GeolocationRequest class enables to retrieve the current geolocation of the device.
3
- */var GeolocationRequest=/*#__PURE__*/function(){function GeolocationRequest(){_classCallCheck(this,GeolocationRequest);_defineProperty(this,"options",{timeout:10000/**
3
+ */var GeolocationRequest=/*#__PURE__*/function(){function GeolocationRequest(){_classCallCheck(this,GeolocationRequest);_defineProperty(this,"options",{timeout:10000});}_createClass(GeolocationRequest,[{key:"setTimeout",value:/**
4
4
  * Sets a timeout for the location request.
5
5
  * @param {number} [value=10000] The timeout in ms.
6
6
  * @returns {GeolocationRequest}
7
- */});}_createClass(GeolocationRequest,[{key:"setTimeout",value:function setTimeout(){var value=arguments.length>0&&arguments[0]!==undefined?arguments[0]:GEOLOCATION_DEFAULT_TIMEOUT;this.options.timeout=value;return this;}/**
7
+ */function setTimeout(){var value=arguments.length>0&&arguments[0]!==undefined?arguments[0]:GEOLOCATION_DEFAULT_TIMEOUT;this.options.timeout=value;return this;}/**
8
8
  * Dispatches the request. If no further provisions are made, it will trigger the geolocation
9
9
  * permission dialog if permissions are not already granted.
10
10
  * @returns {Promise}
@@ -1,4 +1,4 @@
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;}/* eslint-disable class-methods-use-this */import get from'lodash/get';import appConfig,{writeToConfig,equalStructureComparator}from'@shopgate/pwa-common/helpers/config';/**
1
+ function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_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);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}/* eslint-disable class-methods-use-this */import get from'lodash/get';import appConfig,{writeToConfig,equalStructureComparator}from'@shopgate/pwa-common/helpers/config';/**
2
2
  * Parses a JSON object and resolves placeholders with values from the object.
3
3
  */export var ThemeConfigResolver=/*#__PURE__*/function(){/**
4
4
  * @param {Object} config The configuration to resolve references for.
@@ -0,0 +1,2 @@
1
+ export var RECEIVE_SHOP_SETTINGS='RECEIVE_SHOP_SETTINGS';export var ERROR_SHOP_SETTINGS='ERROR_SHOP_SETTINGS';export var CACHE_LEASE_SHOP_SETTINGS=10*60*1000;// 10 minutes in milliseconds
2
+ export var SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE='googleSiteVerificationCode';export var SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT='cartSupplementalContent';export var SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT='orderSupplementalContent';export var SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP='showShopLogoInApp';export var SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB='showShopLogoInWeb';export var SHOP_SETTING_PRODUCTS_SORT_ORDER='productsSortOrder';export var SHOP_SETTING_WISHLIST_MODE='wishlistMode';export var SHOP_SETTING_COOKIE_CONSENT_MODE='cookieConsentMode';export var SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT='displayPricePerMeasureUnit';export var SHOP_SETTING_IMAGES='images';export var SHOP_SETTING_IMAGES_PRODUCT_PLACEHOLDER='productPlaceholder';export var SHOP_SETTING_IMAGES_CATEGORY_PLACEHOLDER='categoryPlaceholder';export var SHOP_SETTING_IMAGES_FAVICON='favicon';export var SHOP_SETTING_NUMBER_OF_ADDRESS_LINES='numberOfAddressLines';export var SHOP_SETTINGS_SHOW_CATEGORY_IMAGES='showCategoryImages';export var WISHLIST_MODE_PERSIST_ON_ADD='persistOnAdd';
@@ -1 +1 @@
1
- import React from'react';export default React.createContext();
1
+ import React from'react';export default/*#__PURE__*/React.createContext();
@@ -1,8 +1,8 @@
1
- import{getProductImageSettings}from"../../product/helpers";import{getImageFormat}from"./getImageFormat";/**
1
+ import{isAndroidOs}from'@shopgate/pwa-core';import{getProductImageSettings}from"../../product/helpers";/**
2
2
  * Returns the actual url to the image, by adding url parameters with the dimensions for img-cdn
3
3
  * @param {string} src Source to the image.
4
4
  * @param {Object} dimension Dimension of the requested image.
5
5
  * @param {number} dimension.width Width in pixels.
6
6
  * @param {number} dimension.height Height in pixels.
7
7
  * @returns {string}
8
- */export var getFullImageSource=function getFullImageSource(src,_ref){var width=_ref.width,height=_ref.height;if(src&&src.includes('images.shopgate.services/v2/images')){var _getProductImageSetti=getProductImageSettings(),fillColor=_getProductImageSetti.fillColor,quality=_getProductImageSetti.quality;var format=getImageFormat();return"".concat(src,"&format=").concat(format,"&width=").concat(width,"&height=").concat(height,"&quality=").concat(quality,"&fill=").concat(fillColor.replace('#',''));}if(src&&src.startsWith('https://img-cdn.shopgate.com')&&!src.includes('?')){return"".concat(src,"?w=").concat(width,"&h=").concat(height,"&q=70&zc=resize&fillc=FFFFFF");}return src;};
8
+ */export var getFullImageSource=function getFullImageSource(src,_ref){var width=_ref.width,height=_ref.height;if(src&&src.includes('images.shopgate.services/v2/images')){var _getProductImageSetti=getProductImageSettings(),fillColor=_getProductImageSetti.fillColor,quality=_getProductImageSetti.quality;var format=isAndroidOs?'webp':'jpeg';return"".concat(src,"&format=").concat(format,"&width=").concat(width,"&height=").concat(height,"&quality=").concat(quality,"&fill=").concat(fillColor.replace('#',''));}if(src&&src.startsWith('https://img-cdn.shopgate.com')&&!src.includes('?')){return"".concat(src,"?w=").concat(width,"&h=").concat(height,"&q=70&zc=resize&fillc=FFFFFF");}return src;};
@@ -1,4 +1,4 @@
1
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 Color from'color';import broadcastEvent from'@shopgate/pwa-core/commands/broadcastEvent';/**
2
2
  * Updates the styles of the navigation bar of iOS devices.
3
3
  * @param {Object} options Options for the status bar.
4
- */export var updateLegacyNavigationBar=function updateLegacyNavigationBar(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var targetTab=options.targetTab||'main';var isDefault=options.isDefault;var styles=_extends({},options.color&&{color:options.color},{},options.background&&{background:options.background},{},options.buttonColor&&{buttonColor:options.buttonColor},{},options.buttonColorDisabled&&{buttonColorDisabled:options.buttonColorDisabled},{},options.statusBarBackground&&{statusBarBackground:options.statusBarBackground});if(!styles.statusBarBackground&&styles.background){styles.statusBarBackground=styles.background;}var statusBarStyle;if(options.statusBarStyle){statusBarStyle=options.statusBarStyle;}else if(styles.statusBarBackground){statusBarStyle=Color(styles.statusBarBackground).isDark()?'light':'dark';}broadcastEvent({event:'updateNavigationBarStyle',parameters:[_extends({},statusBarStyle&&{statusBarStyle:statusBarStyle},{},isDefault&&{isDefault:isDefault},{targetTab:targetTab,styles:styles})]});};
4
+ */export var updateLegacyNavigationBar=function updateLegacyNavigationBar(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var targetTab=options.targetTab||'main';var isDefault=options.isDefault;var styles=_extends({},options.color&&{color:options.color},options.background&&{background:options.background},options.buttonColor&&{buttonColor:options.buttonColor},options.buttonColorDisabled&&{buttonColorDisabled:options.buttonColorDisabled},options.statusBarBackground&&{statusBarBackground:options.statusBarBackground});if(!styles.statusBarBackground&&styles.background){styles.statusBarBackground=styles.background;}var statusBarStyle;if(options.statusBarStyle){statusBarStyle=options.statusBarStyle;}else if(styles.statusBarBackground){statusBarStyle=Color(styles.statusBarBackground).isDark()?'light':'dark';}broadcastEvent({event:'updateNavigationBarStyle',parameters:[_extends({},statusBarStyle&&{statusBarStyle:statusBarStyle},isDefault&&{isDefault:isDefault},{targetTab:targetTab,styles:styles})]});};
@@ -2,4 +2,4 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
2
2
  * Mock for the withWidgetSettings HOC.
3
3
  * @param {Function} WrappedComponent The react component to wrap.
4
4
  * @returns {JSX}
5
- */export function withWidgetSettings(WrappedComponent){var settings={mocked:'widgetSetting'};return function(props){return React.createElement(WrappedComponent,_extends({widgetSettings:settings},props));};}
5
+ */export function withWidgetSettings(WrappedComponent){var settings={mocked:'widgetSetting'};return function(props){return/*#__PURE__*/React.createElement(WrappedComponent,_extends({widgetSettings:settings},props));};}
@@ -1,2 +1,2 @@
1
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 React from'react';import{mount}from'enzyme';import{withApp}from"../withApp";var mockApp={some:'prop'};var mockContext=jest.fn().mockReturnValue(mockApp);jest.mock("../../contexts/AppContext",function(){return{Consumer:function Consumer(_ref){var children=_ref.children;return children(mockContext());}};});// eslint-disable-next-line require-jsdoc
2
- var MockComponent=function MockComponent(){return null;};describe('engage > core > hocs > withApp',function(){beforeEach(function(){jest.clearAllMocks();});it('should inject a property called "app" into the component',function(){var ComposedComponent=withApp(MockComponent);var wrapper=mount(React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual({someProp:true,app:_extends({},mockApp)});});});
2
+ var MockComponent=function MockComponent(){return null;};describe('engage > core > hocs > withApp',function(){beforeEach(function(){jest.clearAllMocks();});it('should inject a property called "app" into the component',function(){var ComposedComponent=withApp(MockComponent);var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual({someProp:true,app:_extends({},mockApp)});});});
@@ -1,2 +1,2 @@
1
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 React from'react';import{mount}from'enzyme';import{withCurrentProduct}from"../withCurrentProduct";var mockCurrentProduct={id:'123',name:'acme',price:{currency:'EUR',unitPrice:22.95,unitPriceStriked:25.95}};var mockContext=jest.fn().mockReturnValue(mockCurrentProduct);jest.mock('@shopgate/pwa-common/context',function(){return{ThemeContext:{Consumer:function Consumer(_ref){var themeChildren=_ref.children;return themeChildren({contexts:{ProductContext:{Consumer:function Consumer(_ref2){var productChildren=_ref2.children;return productChildren(mockContext());}}}});}}};});// eslint-disable-next-line require-jsdoc
2
- var MockComponent=function MockComponent(){return null;};describe('engage > core > hocs > withCurrentProduct',function(){beforeEach(function(){jest.clearAllMocks();});it('should inject the context properties into the component',function(){var ComposedComponent=withCurrentProduct(MockComponent);var wrapper=mount(React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual(_extends({someProp:true},mockCurrentProduct));});it('should inject a single property with the context into the component',function(){var ComposedComponent=withCurrentProduct(MockComponent,{prop:'product'});var wrapper=mount(React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual({someProp:true,product:_extends({},mockCurrentProduct)});});});
2
+ var MockComponent=function MockComponent(){return null;};describe('engage > core > hocs > withCurrentProduct',function(){beforeEach(function(){jest.clearAllMocks();});it('should inject the context properties into the component',function(){var ComposedComponent=withCurrentProduct(MockComponent);var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual(_extends({someProp:true},mockCurrentProduct));});it('should inject a single property with the context into the component',function(){var ComposedComponent=withCurrentProduct(MockComponent,{prop:'product'});var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual({someProp:true,product:_extends({},mockCurrentProduct)});});});
@@ -1 +1 @@
1
- /* eslint-disable require-jsdoc, react/prop-types */import React,{createRef}from'react';import{renderIntoDocument}from'react-dom/test-utils';import{shallow}from'enzyme';import{withForwardedRef}from"../withForwardedRef";var MockComponent=function MockComponent(_ref){var children=_ref.children,className=_ref.className,forwardedRef=_ref.forwardedRef;return React.createElement("div",{className:className,ref:forwardedRef},children);};describe('engage > core > hocs > withForwardedRef',function(){it('should render',function(){var ComposedComponent=withForwardedRef(MockComponent);var ref=createRef();var wrapper=shallow(React.createElement(ComposedComponent,{className:"foo",ref:ref},"Testing 123"));expect(wrapper).toMatchSnapshot();expect(wrapper.props()).toEqual({className:'foo',children:'Testing 123',forwardedRef:{current:null}});});it('should inject the ref with a custom prop name',function(){var ComposedComponent=withForwardedRef(MockComponent,{prop:'custom'});var ref=createRef();var wrapper=shallow(React.createElement(ComposedComponent,{className:"foo",ref:ref},"Testing 123"));expect(wrapper).toMatchSnapshot();expect(wrapper.props()).toEqual({className:'foo',children:'Testing 123',custom:{current:null}});});it('should create a ref that points to a HTMLDivElement',function(){var ComposedComponent=withForwardedRef(MockComponent);var ref=createRef();renderIntoDocument(React.createElement(ComposedComponent,{className:"foo",ref:ref},"Testing 123"));expect(ref.current).toBeInstanceOf(HTMLDivElement);});});/* eslint-enable require-jsdoc, react/prop-types */
1
+ /* eslint-disable require-jsdoc, react/prop-types */import React,{createRef}from'react';import{renderIntoDocument}from'react-dom/test-utils';import{shallow}from'enzyme';import{withForwardedRef}from"../withForwardedRef";var MockComponent=function MockComponent(_ref){var children=_ref.children,className=_ref.className,forwardedRef=_ref.forwardedRef;return/*#__PURE__*/React.createElement("div",{className:className,ref:forwardedRef},children);};describe('engage > core > hocs > withForwardedRef',function(){it('should render',function(){var ComposedComponent=withForwardedRef(MockComponent);var ref=/*#__PURE__*/createRef();var wrapper=shallow(/*#__PURE__*/React.createElement(ComposedComponent,{className:"foo",ref:ref},"Testing 123"));expect(wrapper).toMatchSnapshot();expect(wrapper.props()).toEqual({className:'foo',children:'Testing 123',forwardedRef:{current:null}});});it('should inject the ref with a custom prop name',function(){var ComposedComponent=withForwardedRef(MockComponent,{prop:'custom'});var ref=/*#__PURE__*/createRef();var wrapper=shallow(/*#__PURE__*/React.createElement(ComposedComponent,{className:"foo",ref:ref},"Testing 123"));expect(wrapper).toMatchSnapshot();expect(wrapper.props()).toEqual({className:'foo',children:'Testing 123',custom:{current:null}});});it('should create a ref that points to a HTMLDivElement',function(){var ComposedComponent=withForwardedRef(MockComponent);var ref=/*#__PURE__*/createRef();renderIntoDocument(/*#__PURE__*/React.createElement(ComposedComponent,{className:"foo",ref:ref},"Testing 123"));expect(ref.current).toBeInstanceOf(HTMLDivElement);});});/* eslint-enable require-jsdoc, react/prop-types */
@@ -1,2 +1,2 @@
1
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 React from'react';import{mount}from'enzyme';import{push,pop,replace,reset,update}from"../../router/helpers";import{withNavigation}from"../withNavigation";var navigationProps={historyPush:push,historyPop:pop,historyReplace:replace,historyReset:reset,historyUpdate:update};// eslint-disable-next-line require-jsdoc
2
- var MockComponent=function MockComponent(){return null;};describe('engage > core > hocs > withNavigation',function(){beforeEach(function(){jest.clearAllMocks();});it('should inject the navigation properties into the component',function(){var ComposedComponent=withNavigation(MockComponent);var wrapper=mount(React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual(_extends({someProp:true},navigationProps));});it('should inject a single property with the navigation into the component',function(){var ComposedComponent=withNavigation(MockComponent,{prop:'navigation'});var wrapper=mount(React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual({someProp:true,navigation:_extends({},navigationProps)});});});
2
+ var MockComponent=function MockComponent(){return null;};describe('engage > core > hocs > withNavigation',function(){beforeEach(function(){jest.clearAllMocks();});it('should inject the navigation properties into the component',function(){var ComposedComponent=withNavigation(MockComponent);var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual(_extends({someProp:true},navigationProps));});it('should inject a single property with the navigation into the component',function(){var ComposedComponent=withNavigation(MockComponent,{prop:'navigation'});var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual({someProp:true,navigation:_extends({},navigationProps)});});});
@@ -1,2 +1,2 @@
1
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 React from'react';import{mount}from'enzyme';import{withRoute}from"../withRoute";var mockRoute={id:'32d55',pathname:'/',pattern:'/',state:{}};var mockContext=jest.fn().mockReturnValue(mockRoute);jest.mock('@shopgate/pwa-common/context',function(){return{RouteContext:{Consumer:function Consumer(_ref){var children=_ref.children;return children(mockContext());}}};});// eslint-disable-next-line require-jsdoc
2
- var MockComponent=function MockComponent(){return null;};describe('engage > core > hocs > withRoute',function(){beforeEach(function(){jest.clearAllMocks();});it('should inject the context properties into the component',function(){var ComposedComponent=withRoute(MockComponent);var wrapper=mount(React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual(_extends({someProp:true},mockRoute));});it('should inject a single property with the context into the component',function(){var ComposedComponent=withRoute(MockComponent,{prop:'route'});var wrapper=mount(React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual({someProp:true,route:_extends({},mockRoute)});});});
2
+ var MockComponent=function MockComponent(){return null;};describe('engage > core > hocs > withRoute',function(){beforeEach(function(){jest.clearAllMocks();});it('should inject the context properties into the component',function(){var ComposedComponent=withRoute(MockComponent);var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual(_extends({someProp:true},mockRoute));});it('should inject a single property with the context into the component',function(){var ComposedComponent=withRoute(MockComponent,{prop:'route'});var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual({someProp:true,route:_extends({},mockRoute)});});});
@@ -1,2 +1,2 @@
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 React from'react';import{mount}from'enzyme';import{withTheme}from"../withTheme";var mockTheme={ComponentOne:function ComponentOne(){return React.createElement("div",null);},ComponentTwo:function ComponentTwo(){return React.createElement("div",null);}};var mockContext=jest.fn().mockReturnValue(mockTheme);jest.mock('@shopgate/pwa-common/context',function(){return{ThemeContext:{Consumer:function Consumer(_ref){var children=_ref.children;return children(mockContext());}}};});// eslint-disable-next-line require-jsdoc
2
- var MockComponent=function MockComponent(){return null;};describe('engage > core > hocs > withTheme',function(){beforeEach(function(){jest.clearAllMocks();});it('should inject the context properties into the component',function(){var ComposedComponent=withTheme(MockComponent);var wrapper=mount(React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual(_extends({someProp:true},mockTheme));});it('should inject a single property with the context into the component',function(){var ComposedComponent=withTheme(MockComponent,{prop:'theme'});var wrapper=mount(React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual({someProp:true,theme:_extends({},mockTheme)});});});
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 React from'react';import{mount}from'enzyme';import{withTheme}from"../withTheme";var mockTheme={ComponentOne:function ComponentOne(){return/*#__PURE__*/React.createElement("div",null);},ComponentTwo:function ComponentTwo(){return/*#__PURE__*/React.createElement("div",null);}};var mockContext=jest.fn().mockReturnValue(mockTheme);jest.mock('@shopgate/pwa-common/context',function(){return{ThemeContext:{Consumer:function Consumer(_ref){var children=_ref.children;return children(mockContext());}}};});// eslint-disable-next-line require-jsdoc
2
+ var MockComponent=function MockComponent(){return null;};describe('engage > core > hocs > withTheme',function(){beforeEach(function(){jest.clearAllMocks();});it('should inject the context properties into the component',function(){var ComposedComponent=withTheme(MockComponent);var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual(_extends({someProp:true},mockTheme));});it('should inject a single property with the context into the component',function(){var ComposedComponent=withTheme(MockComponent,{prop:'theme'});var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,{someProp:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).props()).toEqual({someProp:true,theme:_extends({},mockTheme)});});});
@@ -1,2 +1,2 @@
1
1
  import React from'react';import{mount}from'enzyme';import{withWidgetSettings}from"../withWidgetSettings";import{useWidgetSettings}from"../../hooks/useWidgetSettings";jest.mock("../../hooks/useWidgetSettings",function(){return{useWidgetSettings:jest.fn()};});// eslint-disable-next-line require-jsdoc
2
- var MockComponent=function MockComponent(){return null;};var widgetSettings={some:'setting'};describe('engage > core > hocs > withWidgetSettings',function(){beforeEach(function(){useWidgetSettings.mockReturnValue(widgetSettings);});it('should merge add the widget settings to a wrapped component',function(){var ComposedComponent=withWidgetSettings(MockComponent);var wrapper=mount(React.createElement(ComposedComponent,null));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).prop('widgetSettings')).toEqual(widgetSettings);});});
2
+ var MockComponent=function MockComponent(){return null;};var widgetSettings={some:'setting'};describe('engage > core > hocs > withWidgetSettings',function(){beforeEach(function(){useWidgetSettings.mockReturnValue(widgetSettings);});it('should merge add the widget settings to a wrapped component',function(){var ComposedComponent=withWidgetSettings(MockComponent);var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,null));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).prop('widgetSettings')).toEqual(widgetSettings);});});
@@ -1,2 +1,2 @@
1
1
  import React from'react';import{mount}from'enzyme';import{withWidgetStyles}from"../withWidgetStyles";import{useWidgetStyles}from"../../hooks/useWidgetStyles";jest.mock("../../hooks/useWidgetStyles",function(){return{useWidgetStyles:jest.fn()};});// eslint-disable-next-line require-jsdoc
2
- var MockComponent=function MockComponent(){return null;};var widgetStyles={some:'style'};describe('engage > core > hocs > withWidgetStyles',function(){beforeEach(function(){useWidgetStyles.mockReturnValue(widgetStyles);});it('should merge add the widget settings to a wrapped component',function(){var ComposedComponent=withWidgetStyles(MockComponent);var wrapper=mount(React.createElement(ComposedComponent,null));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).prop('widgetStyles')).toEqual(widgetStyles);});});
2
+ var MockComponent=function MockComponent(){return null;};var widgetStyles={some:'style'};describe('engage > core > hocs > withWidgetStyles',function(){beforeEach(function(){useWidgetStyles.mockReturnValue(widgetStyles);});it('should merge add the widget settings to a wrapped component',function(){var ComposedComponent=withWidgetStyles(MockComponent);var wrapper=mount(/*#__PURE__*/React.createElement(ComposedComponent,null));expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).prop('widgetStyles')).toEqual(widgetStyles);});});
@@ -6,4 +6,4 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
6
6
  * The actual HOC.
7
7
  * @param {Object} props The component props.
8
8
  * @returns {JSX}
9
- */var WithApp=function WithApp(props){return React.createElement(AppContext.Consumer,null,function(appContext){return React.createElement(WrappedComponent,_extends({app:appContext},props));});};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithApp.displayName="WithApp(".concat(displayName,")");return WithApp;}
9
+ */var WithApp=function WithApp(props){return/*#__PURE__*/React.createElement(AppContext.Consumer,null,function(appContext){return/*#__PURE__*/React.createElement(WrappedComponent,_extends({app:appContext},props));});};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithApp.displayName="WithApp(".concat(displayName,")");return WithApp;}
@@ -13,4 +13,4 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
13
13
  * The actual HOC.
14
14
  * @param {Object} props The component props.
15
15
  * @returns {JSX}
16
- */var WithCurrentProduct=function WithCurrentProduct(props){return React.createElement(ThemeContext.Consumer,null,function(_ref2){var ProductContext=_ref2.contexts.ProductContext;return React.createElement(ProductContext.Consumer,null,function(productProps){return React.createElement(WrappedComponent,_extends({},getInjectedProps(productProps,options.prop),props));});});};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithCurrentProduct.displayName="WithCurrentProduct(".concat(displayName,")");return WithCurrentProduct;}
16
+ */var WithCurrentProduct=function WithCurrentProduct(props){return/*#__PURE__*/React.createElement(ThemeContext.Consumer,null,function(_ref2){var ProductContext=_ref2.contexts.ProductContext;return/*#__PURE__*/React.createElement(ProductContext.Consumer,null,function(productProps){return/*#__PURE__*/React.createElement(WrappedComponent,_extends({},getInjectedProps(productProps,options.prop),props));});});};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithCurrentProduct.displayName="WithCurrentProduct(".concat(displayName,")");return WithCurrentProduct;}
@@ -10,4 +10,4 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
10
10
  * @param {Object} props The component props.
11
11
  * @param {Object} ref The forwarded ref.
12
12
  * @returns {JSX}
13
- */var WithForwardedRef=function WithForwardedRef(props,ref){var injected=_defineProperty({},options.prop||'forwardedRef',ref);return React.createElement(WrappedComponent,_extends({},props,injected));};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithForwardedRef.displayName="WithForwardedRef(".concat(displayName,")");return forwardRef(WithForwardedRef);}
13
+ */var WithForwardedRef=function WithForwardedRef(props,ref){var injected=_defineProperty({},options.prop||'forwardedRef',ref);return/*#__PURE__*/React.createElement(WrappedComponent,_extends({},props,injected));};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithForwardedRef.displayName="WithForwardedRef(".concat(displayName,")");return/*#__PURE__*/forwardRef(WithForwardedRef);}
@@ -12,4 +12,4 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
12
12
  * The actual HOC.
13
13
  * @param {Object} props The component props.
14
14
  * @returns {JSX}
15
- */var WithNavigation=function WithNavigation(props){return React.createElement(WrappedComponent,_extends({},getInjectedProps(options.prop),props));};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithNavigation.displayName="WithNavigation(".concat(displayName,")");return WithNavigation;}
15
+ */var WithNavigation=function WithNavigation(props){return/*#__PURE__*/React.createElement(WrappedComponent,_extends({},getInjectedProps(options.prop),props));};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithNavigation.displayName="WithNavigation(".concat(displayName,")");return WithNavigation;}
@@ -13,4 +13,4 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
13
13
  * The actual HOC.
14
14
  * @param {Object} props The component props.
15
15
  * @returns {JSX}
16
- */var WithRoute=function WithRoute(props){return React.createElement(RouteContext.Consumer,null,function(routeContext){return React.createElement(WrappedComponent,_extends({},getInjectedProps(routeContext,options.prop),props));});};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithRoute.displayName="WithRoute(".concat(displayName,")");return WithRoute;}
16
+ */var WithRoute=function WithRoute(props){return/*#__PURE__*/React.createElement(RouteContext.Consumer,null,function(routeContext){return/*#__PURE__*/React.createElement(WrappedComponent,_extends({},getInjectedProps(routeContext,options.prop),props));});};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithRoute.displayName="WithRoute(".concat(displayName,")");return WithRoute;}
@@ -1,4 +1,4 @@
1
- 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 _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 React from'react';import{ThemeContext}from'@shopgate/pwa-common/context';/**
1
+ var _excluded=["contexts"];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 _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 React from'react';import{ThemeContext}from'@shopgate/pwa-common/context';/**
2
2
  * Gets the context props for the wrapped component.
3
3
  * @param {Object} context The context.
4
4
  * @param {string|null} prop The optional prop name.
@@ -13,5 +13,5 @@ function _objectWithoutProperties(source,excluded){if(source==null)return{};var
13
13
  * The actual HOC.
14
14
  * @param {Object} props The component props.
15
15
  * @returns {JSX}
16
- */var WithTheme=function WithTheme(props){return React.createElement(ThemeContext.Consumer,null,function(_ref2){var contexts=_ref2.contexts,themeContext=_objectWithoutProperties(_ref2,["contexts"]);return(// The contexts are left out in favor of other HOCs.
16
+ */var WithTheme=function WithTheme(props){return/*#__PURE__*/React.createElement(ThemeContext.Consumer,null,function(_ref2){var contexts=_ref2.contexts,themeContext=_objectWithoutProperties(_ref2,_excluded);return/*#__PURE__*/ (// The contexts are left out in favor of other HOCs.
17
17
  React.createElement(WrappedComponent,_extends({},getInjectedProps(themeContext,options.prop),props)));});};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithTheme.displayName="WithTheme(".concat(displayName,")");return WithTheme;}
@@ -10,4 +10,4 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
10
10
  * The actual HOC.
11
11
  * @param {Object} props The component props.
12
12
  * @returns {JSX}
13
- */var WithWidgetSettings=function WithWidgetSettings(props){var settings=useWidgetSettings(widgetId,index);return React.createElement(WrappedComponent,_extends({widgetSettings:settings},props));};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithWidgetSettings.displayName="WithWidgetSettings(".concat(displayName,")");return WithWidgetSettings;}
13
+ */var WithWidgetSettings=function WithWidgetSettings(props){var settings=useWidgetSettings(widgetId,index);return/*#__PURE__*/React.createElement(WrappedComponent,_extends({widgetSettings:settings},props));};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithWidgetSettings.displayName="WithWidgetSettings(".concat(displayName,")");return WithWidgetSettings;}
@@ -8,4 +8,4 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
8
8
  * The actual HOC.
9
9
  * @param {Object} props The component props.
10
10
  * @returns {JSX}
11
- */var WithWidgetStyles=function WithWidgetStyles(props){var styles=useWidgetStyles(widgetId,index);return React.createElement(WrappedComponent,_extends({widgetStyles:styles},props));};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithWidgetStyles.displayName="WithWidgetStyles(".concat(displayName,")");return WithWidgetStyles;}
11
+ */var WithWidgetStyles=function WithWidgetStyles(props){var styles=useWidgetStyles(widgetId,index);return/*#__PURE__*/React.createElement(WrappedComponent,_extends({widgetStyles:styles},props));};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithWidgetStyles.displayName="WithWidgetStyles(".concat(displayName,")");return WithWidgetStyles;}
@@ -1 +1 @@
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{useNavigation}from"../useNavigation";describe('engage > core > hooks',function(){describe('useNavigation()',function(){it('should return the push() function',function(){var result=useNavigation();expect(result.hasOwnProperty('push')).toBe(true);expect(_typeof(result.push)).toBe('function');});it('should return the pop() function',function(){var result=useNavigation();expect(result.hasOwnProperty('pop')).toBe(true);expect(_typeof(result.pop)).toBe('function');});it('should return the replace() function',function(){var result=useNavigation();expect(result.hasOwnProperty('replace')).toBe(true);expect(_typeof(result.replace)).toBe('function');});it('should return the reset() function',function(){var result=useNavigation();expect(result.hasOwnProperty('reset')).toBe(true);expect(_typeof(result.reset)).toBe('function');});it('should return the update() function',function(){var result=useNavigation();expect(result.hasOwnProperty('update')).toBe(true);expect(_typeof(result.update)).toBe('function');});});});
1
+ function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import{useNavigation}from"../useNavigation";describe('engage > core > hooks',function(){describe('useNavigation()',function(){it('should return the push() function',function(){var result=useNavigation();expect(result.hasOwnProperty('push')).toBe(true);expect(_typeof(result.push)).toBe('function');});it('should return the pop() function',function(){var result=useNavigation();expect(result.hasOwnProperty('pop')).toBe(true);expect(_typeof(result.pop)).toBe('function');});it('should return the replace() function',function(){var result=useNavigation();expect(result.hasOwnProperty('replace')).toBe(true);expect(_typeof(result.replace)).toBe('function');});it('should return the reset() function',function(){var result=useNavigation();expect(result.hasOwnProperty('reset')).toBe(true);expect(_typeof(result.reset)).toBe('function');});it('should return the update() function',function(){var result=useNavigation();expect(result.hasOwnProperty('update')).toBe(true);expect(_typeof(result.update)).toBe('function');});});});
@@ -1,4 +1,4 @@
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{useState,useEffect}from'react';import{loadImage}from'@shopgate/pwa-common/helpers/html/handleDOM';/**
1
+ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_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{useState,useEffect}from'react';import{loadImage}from'@shopgate/pwa-common/helpers/html/handleDOM';/**
2
2
  * Load image hook
3
3
  * @param {string} src .
4
4
  * @returns {boolean}
@@ -1,5 +1,5 @@
1
- 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;}import{useContext}from'react';import{ThemeContext}from'@shopgate/pwa-common/context';/**
1
+ var _excluded=["contexts"];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;}import{useContext}from'react';import{ThemeContext}from'@shopgate/pwa-common/context';/**
2
2
  * Provides the theme API. This does not include the contexts.
3
3
  * @returns {Object}
4
4
  */export function useTheme(){// The contexts are left out in favor of other hooks.
5
- var _useContext=useContext(ThemeContext),contexts=_useContext.contexts,themeContext=_objectWithoutProperties(_useContext,["contexts"]);return themeContext;}
5
+ var _useContext=useContext(ThemeContext),contexts=_useContext.contexts,themeContext=_objectWithoutProperties(_useContext,_excluded);return themeContext;}
@@ -1 +1 @@
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*as core from'.';describe('engage > core',function(){it('should have exports',function(){expect(_typeof(core)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(core).forEach(function(exportKey){expect(typeof core[exportKey]!=='undefined').toBe(true);});});});
1
+ function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import*as core from'.';describe('engage > core',function(){it('should have exports',function(){expect(_typeof(core)).toEqual('object');});it('should not do undefined exports',function(){Object.keys(core).forEach(function(exportKey){expect(typeof core[exportKey]!=='undefined').toBe(true);});});});
@@ -1,16 +1,18 @@
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 _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}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 appConfig from'@shopgate/pwa-common/helpers/config';import{APP_EVENT_VIEW_WILL_APPEAR,APP_EVENT_VIEW_WILL_DISAPPEAR}from'@shopgate/pwa-core/constants/AppEvents';import event from'@shopgate/pwa-core/classes/Event';import AppContext from"../contexts/AppContext";/**
1
+ function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_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);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}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}});Object.defineProperty(subClass,"prototype",{writable:false});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 _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}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 _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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 appConfig from'@shopgate/pwa-common/helpers/config';import{APP_EVENT_VIEW_WILL_APPEAR,APP_EVENT_VIEW_WILL_DISAPPEAR}from'@shopgate/pwa-core/constants/AppEvents';import event from'@shopgate/pwa-core/classes/Event';import AppContext from"../contexts/AppContext";/**
2
2
  * The AppProvider component.
3
- */var AppProvider=/*#__PURE__*/function(_Component){_inherits(AppProvider,_Component);function AppProvider(props){var _this;_classCallCheck(this,AppProvider);_this=_possibleConstructorReturn(this,_getPrototypeOf(AppProvider).call(this,props));_defineProperty(_assertThisInitialized(_this),"setVisible",function(){_this.setIsVisible(true);});_defineProperty(_assertThisInitialized(_this),"setHidden",function(){_this.setIsVisible(false);});_this.state={isVisible:true};event.addCallback(APP_EVENT_VIEW_WILL_APPEAR,_this.setVisible);event.addCallback(APP_EVENT_VIEW_WILL_DISAPPEAR,_this.setHidden);return _this;}/**
3
+ */var AppProvider=/*#__PURE__*/function(_Component){_inherits(AppProvider,_Component);var _super=_createSuper(AppProvider);/**
4
+ * @param {Object} props The component props.
5
+ */function AppProvider(props){var _this;_classCallCheck(this,AppProvider);_this=_super.call(this,props);_defineProperty(_assertThisInitialized(_this),"setVisible",function(){_this.setIsVisible(true);});_defineProperty(_assertThisInitialized(_this),"setHidden",function(){_this.setIsVisible(false);});_this.state={isVisible:true};event.addCallback(APP_EVENT_VIEW_WILL_APPEAR,_this.setVisible);event.addCallback(APP_EVENT_VIEW_WILL_DISAPPEAR,_this.setHidden);return _this;}/**
4
6
  * Removes the event listeners when the component unmounts.
5
7
  */_createClass(AppProvider,[{key:"componentWillUnmount",value:function componentWillUnmount(){event.removeCallback(APP_EVENT_VIEW_WILL_APPEAR,this.setVisible);event.removeCallback(APP_EVENT_VIEW_WILL_DISAPPEAR,this.setHidden);}/**
6
8
  * Returns the context value to be passed to consumers.
7
9
  * @returns {Object}
8
- */},{key:"setIsVisible",/**
10
+ */},{key:"provided",get:function get(){return{appConfig:appConfig,isVisible:this.state.isVisible,setIsVisible:this.setIsVisible};}/**
11
+ * Sets the isVisible state to TRUE.
12
+ */},{key:"setIsVisible",value:/**
9
13
  * Sets the isVisible state. It indicates if Engage is visible,
10
14
  * or another WebView is presented to the user.
11
15
  * @param {boolean} value The new value
12
- */value:function setIsVisible(value){this.setState({isVisible:value});}/**
16
+ */function setIsVisible(value){this.setState({isVisible:value});}/**
13
17
  * @returns {JSX}
14
- */},{key:"render",value:function render(){return React.createElement(AppContext.Provider,{value:this.provided},this.props.children);}},{key:"provided",get:function get(){return{appConfig:appConfig,isVisible:this.state.isVisible,setIsVisible:this.setIsVisible};}/**
15
- * Sets the isVisible state to TRUE.
16
- */}]);return AppProvider;}(Component);export default AppProvider;
18
+ */},{key:"render",value:function render(){return/*#__PURE__*/React.createElement(AppContext.Provider,{value:this.provided},this.props.children);}}]);return AppProvider;}(Component);export default AppProvider;
@@ -1,2 +1,2 @@
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 React from'react';import{shallow}from'enzyme';import appConfig from'@shopgate/pwa-common/helpers/config';import event from'@shopgate/pwa-core/classes/Event';import{APP_EVENT_VIEW_WILL_APPEAR,APP_EVENT_VIEW_WILL_DISAPPEAR}from'@shopgate/pwa-core/constants/AppEvents';import AppProvider from"../AppProvider";jest.mock('@shopgate/pwa-common/helpers/config',function(){return{some:'prop'};});jest.mock('@shopgate/pwa-core/classes/Event',function(){return{addCallback:jest.fn(),removeCallback:jest.fn()};});// eslint-disable-next-line require-jsdoc
2
- var MockComponent=function MockComponent(){return null;};describe('engage > core > providers > AppProvider',function(){beforeEach(function(){jest.clearAllMocks();});it('should initialize as expected',function(){var wrapper=shallow(React.createElement(AppProvider,null,React.createElement(MockComponent,null)));var instance=wrapper.instance();expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).length).toEqual(1);expect(wrapper.prop('value')).toEqual({appConfig:appConfig,isVisible:true,setIsVisible:instance.setIsVisible});expect(event.addCallback).toHaveBeenCalledTimes(2);expect(event.addCallback).toHaveBeenCalledWith(APP_EVENT_VIEW_WILL_APPEAR,instance.setVisible);expect(event.addCallback).toHaveBeenCalledWith(APP_EVENT_VIEW_WILL_DISAPPEAR,instance.setHidden);});it('should handle calls of setIsVisible() as expected',function(){var wrapper=shallow(React.createElement(AppProvider,null,React.createElement(MockComponent,null)));var instance=wrapper.instance();var _wrapper$prop=wrapper.prop('value'),isVisible=_wrapper$prop.isVisible;expect(isVisible).toBe(true);instance.setIsVisible(false);var _wrapper$prop2=wrapper.prop('value');isVisible=_wrapper$prop2.isVisible;expect(isVisible).toBe(false);instance.setIsVisible(true);var _wrapper$prop3=wrapper.prop('value');isVisible=_wrapper$prop3.isVisible;expect(isVisible).toBe(true);});it('should handle event calls as expected',function(){var wrapper=shallow(React.createElement(AppProvider,null,React.createElement(MockComponent,null)));var _event$addCallback$mo=_slicedToArray(event.addCallback.mock.calls,2),_event$addCallback$mo2=_slicedToArray(_event$addCallback$mo[0],2),setVisible=_event$addCallback$mo2[1],_event$addCallback$mo3=_slicedToArray(_event$addCallback$mo[1],2),setHidden=_event$addCallback$mo3[1];var _wrapper$prop4=wrapper.prop('value'),isVisible=_wrapper$prop4.isVisible;expect(isVisible).toBe(true);setHidden();var _wrapper$prop5=wrapper.prop('value');isVisible=_wrapper$prop5.isVisible;expect(isVisible).toBe(false);setVisible();var _wrapper$prop6=wrapper.prop('value');isVisible=_wrapper$prop6.isVisible;expect(isVisible).toBe(true);});it('should remove the event listeners on unmount',function(){var wrapper=shallow(React.createElement(AppProvider,null,React.createElement(MockComponent,null)));var instance=wrapper.instance();wrapper.unmount();expect(event.removeCallback).toHaveBeenCalledTimes(2);expect(event.removeCallback).toHaveBeenCalledWith(APP_EVENT_VIEW_WILL_APPEAR,instance.setVisible);expect(event.removeCallback).toHaveBeenCalledWith(APP_EVENT_VIEW_WILL_DISAPPEAR,instance.setHidden);});});
1
+ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_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 React from'react';import{shallow}from'enzyme';import appConfig from'@shopgate/pwa-common/helpers/config';import event from'@shopgate/pwa-core/classes/Event';import{APP_EVENT_VIEW_WILL_APPEAR,APP_EVENT_VIEW_WILL_DISAPPEAR}from'@shopgate/pwa-core/constants/AppEvents';import AppProvider from"../AppProvider";jest.mock('@shopgate/pwa-common/helpers/config',function(){return{some:'prop'};});jest.mock('@shopgate/pwa-core/classes/Event',function(){return{addCallback:jest.fn(),removeCallback:jest.fn()};});// eslint-disable-next-line require-jsdoc
2
+ var MockComponent=function MockComponent(){return null;};describe('engage > core > providers > AppProvider',function(){beforeEach(function(){jest.clearAllMocks();});it('should initialize as expected',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(AppProvider,null,/*#__PURE__*/React.createElement(MockComponent,null)));var instance=wrapper.instance();expect(wrapper).toMatchSnapshot();expect(wrapper.find(MockComponent).length).toEqual(1);expect(wrapper.prop('value')).toEqual({appConfig:appConfig,isVisible:true,setIsVisible:instance.setIsVisible});expect(event.addCallback).toHaveBeenCalledTimes(2);expect(event.addCallback).toHaveBeenCalledWith(APP_EVENT_VIEW_WILL_APPEAR,instance.setVisible);expect(event.addCallback).toHaveBeenCalledWith(APP_EVENT_VIEW_WILL_DISAPPEAR,instance.setHidden);});it('should handle calls of setIsVisible() as expected',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(AppProvider,null,/*#__PURE__*/React.createElement(MockComponent,null)));var instance=wrapper.instance();var _wrapper$prop=wrapper.prop('value'),isVisible=_wrapper$prop.isVisible;expect(isVisible).toBe(true);instance.setIsVisible(false);var _wrapper$prop2=wrapper.prop('value');isVisible=_wrapper$prop2.isVisible;expect(isVisible).toBe(false);instance.setIsVisible(true);var _wrapper$prop3=wrapper.prop('value');isVisible=_wrapper$prop3.isVisible;expect(isVisible).toBe(true);});it('should handle event calls as expected',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(AppProvider,null,/*#__PURE__*/React.createElement(MockComponent,null)));var _event$addCallback$mo=_slicedToArray(event.addCallback.mock.calls,2),_event$addCallback$mo2=_slicedToArray(_event$addCallback$mo[0],2),setVisible=_event$addCallback$mo2[1],_event$addCallback$mo3=_slicedToArray(_event$addCallback$mo[1],2),setHidden=_event$addCallback$mo3[1];var _wrapper$prop4=wrapper.prop('value'),isVisible=_wrapper$prop4.isVisible;expect(isVisible).toBe(true);setHidden();var _wrapper$prop5=wrapper.prop('value');isVisible=_wrapper$prop5.isVisible;expect(isVisible).toBe(false);setVisible();var _wrapper$prop6=wrapper.prop('value');isVisible=_wrapper$prop6.isVisible;expect(isVisible).toBe(true);});it('should remove the event listeners on unmount',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(AppProvider,null,/*#__PURE__*/React.createElement(MockComponent,null)));var instance=wrapper.instance();wrapper.unmount();expect(event.removeCallback).toHaveBeenCalledTimes(2);expect(event.removeCallback).toHaveBeenCalledWith(APP_EVENT_VIEW_WILL_APPEAR,instance.setVisible);expect(event.removeCallback).toHaveBeenCalledWith(APP_EVENT_VIEW_WILL_DISAPPEAR,instance.setHidden);});});
@@ -0,0 +1 @@
1
+ export{getState as getShopSettingsState,makeGetShopSettingByKey,makeGetShopSettings,getProductImagePlaceholder,getCategoryImagePlaceholder,getFavicon,getNumberOfAddressLines,getGoogleSiteVerificationCode}from"./shopSettings";
@@ -0,0 +1,14 @@
1
+ import{createSelector}from'reselect';import{WISHLIST_MODE_PERSIST_ON_ADD,SHOP_SETTING_WISHLIST_MODE}from"../constants/shopSettings";/**
2
+ * Retrieves the shopSettings state from the store.
3
+ * @param {Object} state The current application state.
4
+ * @return {Object} The locations state.
5
+ */export var getState=function getState(state){var _state$settings;return(state===null||state===void 0?void 0:(_state$settings=state.settings)===null||_state$settings===void 0?void 0:_state$settings.shopSettings)||{};};/**
6
+ * Creates a selector to retrieve a single shop setting.
7
+ * @param {string} key The key of the shop setting
8
+ * @param {*} [fallback=null] The fallback value when no value can be determined.
9
+ * @returns {Function}
10
+ */export var makeGetShopSettingByKey=function makeGetShopSettingByKey(key){var fallback=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;return createSelector(getState,function(state){return typeof(state===null||state===void 0?void 0:state[key])!=='undefined'?state===null||state===void 0?void 0:state[key]:fallback;});};/**
11
+ * Creates a selector to retrieve multiple shop setting.
12
+ * @param {Array} [keys=[]] Optional keys to filter.
13
+ * @returns {Function}
14
+ */export var makeGetShopSettings=function makeGetShopSettings(){var keys=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];return createSelector(getState,function(state){var result=Object.keys(state).filter(function(key){if(Array.isArray(keys)&&keys.length>0){return keys.includes(key);}return true;}).reduce(function(acc,key){if(state!==null&&state!==void 0&&state[key]){acc[key]=state[key];}return acc;},{});return result;});};/** Selects the current wishlist mode */export var getWishlistMode=makeGetShopSettingByKey(SHOP_SETTING_WISHLIST_MODE,WISHLIST_MODE_PERSIST_ON_ADD);
@@ -0,0 +1,5 @@
1
+ import{connect}from'react-redux';import provideProduct from'@shopgate/pwa-common-commerce/product/action-creators/provideProduct';import fetchFavorites from'@shopgate/pwa-common-commerce/favorites/actions/fetchFavorites';/**
2
+ * @param {Object} state .
3
+ * @param {Object} props .
4
+ * @return {Object}
5
+ */var mapStateToProps=function mapStateToProps(state,props){return{product:fetchFavorites(state,props)};};var mapDispatchToProps={provideProduct:provideProduct};export default connect(mapStateToProps,mapDispatchToProps);
@@ -0,0 +1,4 @@
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 React,{useEffect}from'react';import PropTypes from'prop-types';import connect from"./connector";/**
2
+ * The FavoriteProvider component.
3
+ * @return {JSX}
4
+ */var FavoriteProvider=function FavoriteProvider(_ref){var children=_ref.children,productId=_ref.productId,provideProduct=_ref.provideProduct,product=_ref.product;useEffect(function(){if(!product){provideProduct(productId);}},[provideProduct,product,productId]);var props={productId:productId,product:product};if(typeof children==='function'){return children(props);}return/*#__PURE__*/React.cloneElement(children,_extends({},props,children.props));};FavoriteProvider.defaultProps={product:null};export default connect(FavoriteProvider);
@@ -0,0 +1,10 @@
1
+ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_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 React,{useCallback,useMemo,useLayoutEffect,useState}from'react';import PropTypes from'prop-types';import{connect}from'react-redux';import{css}from'glamor';import{MODAL_VARIANT_SELECT}from'@shopgate/pwa-ui-shared/Dialog/constants';import{ProductImage,ITEM_PATH,isBaseProduct as isBaseProductSelector,isProductOrderable,hasProductVariants}from'@shopgate/engage/product';import{bin2hex,showModal as showModalAction,historyPush as historyPushAction,getThemeSettings,i18n}from'@shopgate/engage/core';import{Link,SurroundPortals}from'@shopgate/engage/components';import{FAVORITES_PRODUCT_NAME,FAVORITES_PRODUCT_PRICE,FAVORITES_ADD_TO_CART}from'@shopgate/engage/favorites';import Price from'@shopgate/pwa-ui-shared/Price';import AddToCart from'@shopgate/pwa-ui-shared/AddToCartButton';import Remove from"../RemoveButton";import ItemCharacteristics from"./ItemCharacteristics";import{FAVORITES_LIST_ITEM,FAVORITES_LIST_ITEM_ACTIONS}from"../../constants/Portals";/**
2
+ * The extended component props.
3
+ * @param {Object} state The current application state.
4
+ * @param {Object} props The current component props.
5
+ * @return {Object} The populated component props.
6
+ */var mapStateToProps=function mapStateToProps(state,props){return{isBaseProduct:isBaseProductSelector(state,props),hasVariants:hasProductVariants(state,props),isOrderable:isProductOrderable(state,props)};};var mapDispatchToProps={showModal:showModalAction,historyPush:historyPushAction};var styles={root:css({display:'flex',position:'relative','&:not(:last-child)':{marginBottom:48},'&:last-child':{marginBottom:16}}).toString(),imageContainer:css({flex:0.4,marginRight:18}).toString(),infoContainer:css({flex:1,display:'flex',flexDirection:'column',minWidth:0}).toString(),innerInfoContainer:css({flex:1,display:'flex',flexDirection:'row',minWidth:0}),infoContainerLeft:css({flex:1,display:'flex',flexDirection:'column',minWidth:0}),infoContainerRight:css({display:'flex',flexDirection:'column',minWidth:0,marginLeft:8,alignItems:'flex-end'}),title:css({fontSize:17,color:'var(--color-text-high-emphasis)',fontWeight:600,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis',marginBottom:10}),actions:css({position:'absolute',bottom:-24,display:'flex',flexDirection:'row',justifyContent:'space-between',alignItems:'center',width:90}).toString()};/**
7
+ * Favorite Item component
8
+ * @return {JSX}
9
+ */var FavoriteItem=function FavoriteItem(_ref){var _product$price,_product$price2;var listId=_ref.listId,product=_ref.product,remove=_ref.remove,addToCart=_ref.addToCart,isBaseProduct=_ref.isBaseProduct,isOrderable=_ref.isOrderable,hasVariants=_ref.hasVariants,showModal=_ref.showModal;var _ref2=getThemeSettings('AppImages')||{},gridResolutions=_ref2.ListImage;var _useState=useState(!isOrderable&&!hasVariants),_useState2=_slicedToArray(_useState,2),isDisabled=_useState2[0],setIsDisabled=_useState2[1];var currency=((_product$price=product.price)===null||_product$price===void 0?void 0:_product$price.currency)||'EUR';var defaultPrice=((_product$price2=product.price)===null||_product$price2===void 0?void 0:_product$price2.unitPrice)||0;var price=defaultPrice;var characteristics=(product===null||product===void 0?void 0:product.characteristics)||[];var productLink="".concat(ITEM_PATH,"/").concat(bin2hex(product.id));useLayoutEffect(function(){setIsDisabled(!isOrderable&&!hasVariants);},[hasVariants,isOrderable]);var handleAddToCart=useCallback(function(e){e.preventDefault();e.stopPropagation();if(isBaseProduct&&hasVariants){// Called for a parent product. Users needs to confirm the navigation to the PDP
10
+ showModal({title:null,type:MODAL_VARIANT_SELECT,message:'favorites.modal.message',confirm:'favorites.modal.confirm',dismiss:'common.cancel',params:{productId:product.id}});return false;}return addToCart(e);},[addToCart,hasVariants,isBaseProduct,product.id,showModal]);var commonPortalProps=useMemo(function(){var availability=product.availability,id=product.id,name=product.name;return{availability:availability,characteristics:characteristics,id:id,name:name,price:price,listId:listId};},[characteristics,listId,price,product]);var ctaPortalProps=useMemo(function(){return{isLoading:false,noShadow:false,listId:listId,isBaseProduct:isBaseProduct,isDisabled:isDisabled,productId:product.id,handleRemoveFromCart:remove,handleAddToCart:handleAddToCart};},[handleAddToCart,isBaseProduct,isDisabled,listId,product.id,remove]);return/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_LIST_ITEM,portalProps:product},/*#__PURE__*/React.createElement("div",{className:styles.root},/*#__PURE__*/React.createElement(Link,{className:styles.imageContainer,component:"div",href:productLink},/*#__PURE__*/React.createElement(ProductImage,{src:product.featuredImageBaseUrl,resolutions:gridResolutions})),/*#__PURE__*/React.createElement(Link,{className:styles.infoContainer,component:"div",href:productLink},/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_PRODUCT_NAME,portalProps:commonPortalProps},/*#__PURE__*/React.createElement("span",{className:styles.title},product.name)),/*#__PURE__*/React.createElement("div",{className:styles.innerInfoContainer},/*#__PURE__*/React.createElement("div",{className:styles.infoContainerLeft},/*#__PURE__*/React.createElement(ItemCharacteristics,{characteristics:characteristics})),/*#__PURE__*/React.createElement("div",{className:styles.infoContainerRight},/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_PRODUCT_PRICE,portalProps:commonPortalProps},/*#__PURE__*/React.createElement(Price,{currency:currency,taxDisclaimer:true,unitPrice:price}))))),/*#__PURE__*/React.createElement("div",{className:styles.actions},/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_LIST_ITEM_ACTIONS,portalProps:ctaPortalProps},/*#__PURE__*/React.createElement(Remove,{onClick:remove}),/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_ADD_TO_CART,portalProps:ctaPortalProps},/*#__PURE__*/React.createElement(AddToCart,{onClick:handleAddToCart,isLoading:false,isDisabled:isDisabled,"aria-label":i18n.text('product.add_to_cart')}))))));};FavoriteItem.defaultProps={isBaseProduct:true,isOrderable:true,hasVariants:false};export default connect(mapStateToProps,mapDispatchToProps)(FavoriteItem);
@@ -0,0 +1,4 @@
1
+ import React from'react';import PropTypes from'prop-types';import{css}from'glamor';var styles={property:css({fontSize:14,color:'var(--color-text-low-emphasis)',fontWeight:400,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis'})};/**
2
+ * @param {Object} props The component props
3
+ * @returns {JSX}
4
+ */var ItemCharacteristics=function ItemCharacteristics(_ref){var characteristics=_ref.characteristics;if(!characteristics||characteristics.length===0){return null;}return/*#__PURE__*/React.createElement("ul",null,characteristics.map(function(_ref2){var label=_ref2.label,value=_ref2.value;return/*#__PURE__*/React.createElement("li",{key:"".concat(label,"-").concat(value),className:styles.property},label,': ',value);}));};ItemCharacteristics.defaultProps={characteristics:null};export default ItemCharacteristics;
@@ -0,0 +1 @@
1
+ export{default}from"./Item";