@shopgate/engage 6.20.0-rc.3 → 6.20.0-rc.5

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.
@@ -1 +1 @@
1
- import React from'react';import{mount}from'enzyme';import MessageBar from"./index";var MESSAGE1='This is some information';var MESSAGE2='This is an error that happened here.';var MESSAGE3='This is just a warning. Nothing to freak out about.';var MESSAGE4='Normal pre-translated message.';var MESSAGE5='Normal pre-translated message.';var MESSAGE6='some.translation.string';var MESSAGE7='Message with messageParams';describe('<MessageBar />',function(){describe('General rendering',function(){it('should be empty if no messages have been set',function(){var wrapper=mount(/*#__PURE__*/React.createElement(MessageBar,{messages:[]}));expect(wrapper).toMatchSnapshot();});it('should render a message as info if type is missing',function(){var wrapper=mount(/*#__PURE__*/React.createElement(MessageBar,{messages:[{message:'something'}]}));expect(wrapper).toMatchSnapshot();});});describe('Multiple messages rendering',function(){it('should render messages without frontend translation',function(){var wrapper=mount(/*#__PURE__*/React.createElement(MessageBar,{messages:[{type:'info',message:MESSAGE1},{type:'error',message:MESSAGE2},{type:'warning',message:MESSAGE3},{message:MESSAGE4,translated:null},{message:MESSAGE5,translated:true}]}));expect(wrapper).toMatchSnapshot();});it('should translate and render all given messages',function(){var wrapper=mount(/*#__PURE__*/React.createElement(MessageBar,{messages:[{message:MESSAGE6,translated:false},{message:MESSAGE7,messageParams:{myCustomParam1:'-> TEST-VALUE #1 <-',myCustomParam2:'-> TEST-VALUE #2 <-'},translated:false}]}));expect(wrapper).toMatchSnapshot();});});it('should render with custom classNames',function(){var wrapper=mount(/*#__PURE__*/React.createElement(MessageBar,{messages:[{message:MESSAGE1}],classNames:{container:'cls-container',message:'cls-message'}}));expect(wrapper).toMatchSnapshot();});});
1
+ import React from'react';import{mount}from'enzyme';import MessageBar from"./index";var MESSAGE1='This is some information';var MESSAGE2='This is an error that happened here.';var MESSAGE3='This is just a warning. Nothing to freak out about.';var MESSAGE4='Normal pre-translated message.';var MESSAGE5='Other normal pre-translated message.';var MESSAGE6='some.translation.string';var MESSAGE7='Message with messageParams';describe('<MessageBar />',function(){describe('General rendering',function(){it('should be empty if no messages have been set',function(){var wrapper=mount(/*#__PURE__*/React.createElement(MessageBar,{messages:[]}));expect(wrapper).toMatchSnapshot();});it('should render a message as info if type is missing',function(){var wrapper=mount(/*#__PURE__*/React.createElement(MessageBar,{messages:[{message:'something'}]}));expect(wrapper).toMatchSnapshot();});});describe('Multiple messages rendering',function(){it('should render messages without frontend translation',function(){var wrapper=mount(/*#__PURE__*/React.createElement(MessageBar,{messages:[{type:'info',message:MESSAGE1},{type:'error',message:MESSAGE2},{type:'warning',message:MESSAGE3},{message:MESSAGE4,translated:null},{message:MESSAGE5,translated:true}]}));expect(wrapper).toMatchSnapshot();});it('should translate and render all given messages',function(){var wrapper=mount(/*#__PURE__*/React.createElement(MessageBar,{messages:[{message:MESSAGE6,translated:false},{message:MESSAGE7,messageParams:{myCustomParam1:'-> TEST-VALUE #1 <-',myCustomParam2:'-> TEST-VALUE #2 <-'},translated:false}]}));expect(wrapper).toMatchSnapshot();});});it('should render with custom classNames',function(){var wrapper=mount(/*#__PURE__*/React.createElement(MessageBar,{messages:[{message:MESSAGE1}],classNames:{container:'cls-container',message:'cls-message'}}));expect(wrapper).toMatchSnapshot();});});
@@ -3,7 +3,7 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
3
3
  * @param {Object} state The current application state.
4
4
  * @param {Object} props The current component props.
5
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'}),infoContainerRightTaxDisclaimer:css({marginRight:8}),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(),basePrice:css({fontSize:'0.6875rem',textAlign:'right'}).toString(),availability:css({fontSize:14,fontWeight:400}).toString()};/**
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,maxWidth:170,minWidth:126}).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'}),infoContainerRightTaxDisclaimer:css({marginRight:8}),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(),basePrice:css({fontSize:'0.6875rem',textAlign:'right'}).toString(),availability:css({fontSize:14,fontWeight:400}).toString()};/**
7
7
  * Favorite Item component
8
8
  * @return {JSX}
9
9
  */var FavoriteItem=function FavoriteItem(_ref){var _product$price,_product$price2,_product$price3,_product$price4;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 specialPrice=(_product$price3=product.price)===null||_product$price3===void 0?void 0:_product$price3.unitPriceStriked;var hasStrikePrice=((_product$price4=product.price)===null||_product$price4===void 0?void 0:_product$price4.discount)>0;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
@@ -1,14 +1,18 @@
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,{Fragment,useCallback,useEffect,useState}from'react';import PropTypes from'prop-types';import{connect}from'react-redux';import{css}from'glamor';import{i18n}from'@shopgate/engage/core';import appConfig,{themeConfig}from'@shopgate/pwa-common/helpers/config';import{Accordion,Card,ContextMenu,SurroundPortals,RippleButton}from'@shopgate/engage/components';import{getFavoritesCount,makeGetFavoritesIdsByList}from'@shopgate/pwa-common-commerce/favorites/selectors';import{FAVORITES_LIST_CONTEXT_MENU}from"../../constants/Portals";import Item from"../Item";import{ProductProvider}from"../../../product";import{FAVORITES_SHOW_LIMIT}from"../../constants/constants";var colors=themeConfig.colors,variables=themeConfig.variables;var styles={root:css({margin:'8px 8px 10px'}).toString(),rootNoFavoritesLists:css({background:colors.light,flexGrow:1,paddingTop:variables.gap.xsmall,paddingBottom:variables.gap.xxbig,paddingLeft:'16px',paddingRight:'16px'}).toString(),title:css({flex:1,textOverflow:'ellipsis',overflow:'hidden',whiteSpace:'nowrap'}).toString(),divider:css({height:1,width:'calc(100% + 32px)',backgroundColor:'rgb(234, 234, 234)',marginLeft:-16,marginRight:-16,marginBottom:16}).toString(),spacer:css({height:1,width:'calc(100% + 32px)',marginLeft:-16,marginRight:-16,marginBottom:16}).toString(),loadMoreButton:css({width:'calc(100% - 32px)',margin:'16px 16px 0 16px',borderRadius:5}).toString()};/**
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,{Fragment,useCallback,useEffect,useState}from'react';import PropTypes from'prop-types';import{connect}from'react-redux';import{css}from'glamor';import{i18n}from'@shopgate/engage/core';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{Accordion,Card,ContextMenu,SurroundPortals,RippleButton}from'@shopgate/engage/components';import{getFavoritesCount,makeGetFavoritesIdsByList,getHasMultipleFavoritesListsSupport}from'@shopgate/engage/favorites';import{FAVORITES_LIST_CONTEXT_MENU}from"../../constants/Portals";import Item from"../Item";import{ProductProvider}from"../../../product";import{FAVORITES_SHOW_LIMIT}from"../../constants/constants";var colors=themeConfig.colors,variables=themeConfig.variables;var styles={root:css({margin:'8px 8px 10px'}).toString(),rootNoFavoritesLists:css({background:colors.light,flexGrow:1,paddingTop:variables.gap.xsmall,paddingLeft:'16px',paddingRight:'16px'}).toString(),title:css({flex:1,textOverflow:'ellipsis',overflow:'hidden',whiteSpace:'nowrap'}).toString(),divider:css({height:1,width:'calc(100% + 32px)',backgroundColor:'rgb(234, 234, 234)',marginLeft:-16,marginRight:-16,marginBottom:16}).toString(),spacer:css({height:1,width:'calc(100% + 32px)',marginLeft:-16,marginRight:-16,marginBottom:16}).toString(),loadMoreButton:css({width:'calc(100% - 32px)',margin:'16px 16px 0 16px',borderRadius:5}).toString()};/**
2
2
  * Favorite List Label component
3
3
  * @return {JSX}
4
4
  */var FavoriteListLabel=function FavoriteListLabel(_ref){var id=_ref.id,title=_ref.title,rename=_ref.rename,remove=_ref.remove,disableRemoveList=_ref.disableRemoveList;return/*#__PURE__*/React.createElement(Fragment,null,/*#__PURE__*/React.createElement("span",{className:styles.title},title),/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_LIST_CONTEXT_MENU,portalProps:{id:id}},/*#__PURE__*/React.createElement(ContextMenu,null,/*#__PURE__*/React.createElement(ContextMenu.Item,{onClick:rename},i18n.text('favorites.rename_list')),/*#__PURE__*/React.createElement(ContextMenu.Item,{onClick:remove,disabled:disableRemoveList},i18n.text('favorites.remove_list')))));};/**
5
5
  * The content of a favorites list
6
6
  * @returns {JSX}
7
- */var FavoritesListContent=function FavoritesListContent(_ref2){var id=_ref2.id,productIds=_ref2.productIds,_addToCart=_ref2.addToCart,removeItem=_ref2.removeItem,shouldShowLoadMoreButton=_ref2.shouldShowLoadMoreButton,loadMore=_ref2.loadMore;return/*#__PURE__*/React.createElement(React.Fragment,null,appConfig.favoritesMode.hasMultipleFavoritesLists?/*#__PURE__*/React.createElement("div",{className:styles.divider}):/*#__PURE__*/React.createElement("div",{className:styles.spacer}),productIds.length===0?/*#__PURE__*/React.createElement("span",null,i18n.text('favorites.empty')):null,productIds.map(function(_ref3){var productId=_ref3.productId;return/*#__PURE__*/React.createElement(ProductProvider,{productId:productId,key:productId},function(_ref4){var product=_ref4.product;return product?/*#__PURE__*/React.createElement(Item,{key:product.id,product:product,listId:id,productId:product.id,addToCart:function addToCart(e){e.preventDefault();e.stopPropagation();return _addToCart(product);},remove:function remove(e){e.preventDefault();e.stopPropagation();removeItem(product.id);}}):null;});}),shouldShowLoadMoreButton&&/*#__PURE__*/React.createElement(RippleButton,{type:"primary",className:styles.loadMoreButton,onClick:loadMore},i18n.text('favorites.load_more_button')),/*#__PURE__*/React.createElement("div",{className:styles.spacer}));};/**
7
+ */var FavoritesListContent=function FavoritesListContent(_ref2){var id=_ref2.id,productIds=_ref2.productIds,_addToCart=_ref2.addToCart,removeItem=_ref2.removeItem,shouldShowLoadMoreButton=_ref2.shouldShowLoadMoreButton,loadMore=_ref2.loadMore,hasMultipleFavoritesListsSupport=_ref2.hasMultipleFavoritesListsSupport;return/*#__PURE__*/ (/**
8
+ * TODO find a way to indicate loading of the list. products are fetched via the ProductProvider,
9
+ * so there is not a reliable way to determine if product fetching is done, since we might not
10
+ * receive a product for every list item.
11
+ */React.createElement(React.Fragment,null,hasMultipleFavoritesListsSupport?/*#__PURE__*/React.createElement("div",{className:styles.divider}):/*#__PURE__*/React.createElement("div",{className:styles.spacer}),productIds.length===0?/*#__PURE__*/React.createElement("span",null,i18n.text('favorites.empty')):null,productIds.map(function(_ref3){var productId=_ref3.productId;return/*#__PURE__*/React.createElement(ProductProvider,{productId:productId,key:productId},function(_ref4){var product=_ref4.product;return product?/*#__PURE__*/React.createElement(Item,{key:product.id,product:product,listId:id,productId:product.id,addToCart:function addToCart(e){e.preventDefault();e.stopPropagation();return _addToCart(product);},remove:function remove(e){e.preventDefault();e.stopPropagation();removeItem(product.id);}}):null;});}),shouldShowLoadMoreButton&&/*#__PURE__*/React.createElement(RippleButton,{type:"primary",className:styles.loadMoreButton,onClick:loadMore},i18n.text('favorites.load_more_button')),/*#__PURE__*/React.createElement("div",{className:styles.spacer})));};FavoritesListContent.defaultProps={hasMultipleFavoritesListsSupport:false};/**
8
12
  * @param {Object} _ State
9
13
  * @param {Object} props Props
10
14
  * @returns {Object}
11
- */var makeMapStateToProps=function makeMapStateToProps(_,_ref5){var id=_ref5.id;var getFavoritesIds=makeGetFavoritesIdsByList(function(){return id;});return function(state){return{favoriteIds:getFavoritesIds(state),favoritesCount:getFavoritesCount(state)};};};/**
15
+ */var makeMapStateToProps=function makeMapStateToProps(_,_ref5){var id=_ref5.id;var getFavoritesIds=makeGetFavoritesIdsByList(function(){return id;});return function(state){return{favoriteIds:getFavoritesIds(state),favoritesCount:getFavoritesCount(state),hasMultipleFavoritesListsSupport:getHasMultipleFavoritesListsSupport(state)};};};/**
12
16
  * Favorite List component
13
17
  * @return {JSX}
14
- */var FavoriteList=function FavoriteList(_ref6){var id=_ref6.id,name=_ref6.name,favoriteIds=_ref6.favoriteIds,_rename=_ref6.rename,remove=_ref6.remove,removeItem=_ref6.removeItem,addToCart=_ref6.addToCart,disableRemoveList=_ref6.disableRemoveList;var _useState=useState(FAVORITES_SHOW_LIMIT),_useState2=_slicedToArray(_useState,2),offset=_useState2[0],setOffset=_useState2[1];var productIds=favoriteIds.slice(0,offset).map(function(productId){return{productId:productId};});var allFavoritesLoaded=favoriteIds.length-productIds.length>0;var _useState3=useState(allFavoritesLoaded),_useState4=_slicedToArray(_useState3,2),shouldShowLoadMoreButton=_useState4[0],setShouldShowLoadMoreButton=_useState4[1];var loadMore=useCallback(function(){setOffset(offset+FAVORITES_SHOW_LIMIT);},[offset]);useEffect(function(){setShouldShowLoadMoreButton(allFavoritesLoaded);},[offset,allFavoritesLoaded]);return appConfig.favoritesMode.hasMultipleFavoritesLists?/*#__PURE__*/React.createElement(Card,{className:styles.root},/*#__PURE__*/React.createElement(Accordion,{className:"",openWithChevron:true,renderLabel:function renderLabel(){return/*#__PURE__*/React.createElement(FavoriteListLabel,{id:id,title:name,rename:function rename(newName){return _rename(id,newName);},remove:remove,disableRemoveList:disableRemoveList});},chevronPosition:"left",startOpened:true,testId:id},/*#__PURE__*/React.createElement(FavoritesListContent,{addToCart:addToCart,id:id,loadMore:loadMore,productIds:productIds,removeItem:removeItem,shouldShowLoadMoreButton:shouldShowLoadMoreButton}))):/*#__PURE__*/React.createElement("div",{className:styles.rootNoFavoritesLists},/*#__PURE__*/React.createElement(FavoritesListContent,{addToCart:addToCart,id:id,loadMore:loadMore,productIds:productIds,removeItem:removeItem,shouldShowLoadMoreButton:shouldShowLoadMoreButton}));};export default connect(makeMapStateToProps)(FavoriteList);
18
+ */var FavoriteList=function FavoriteList(_ref6){var id=_ref6.id,name=_ref6.name,favoriteIds=_ref6.favoriteIds,_rename=_ref6.rename,remove=_ref6.remove,removeItem=_ref6.removeItem,addToCart=_ref6.addToCart,disableRemoveList=_ref6.disableRemoveList,hasMultipleFavoritesListsSupport=_ref6.hasMultipleFavoritesListsSupport;var _useState=useState(FAVORITES_SHOW_LIMIT),_useState2=_slicedToArray(_useState,2),offset=_useState2[0],setOffset=_useState2[1];var productIds=favoriteIds.slice(0,offset).map(function(productId){return{productId:productId};});var allFavoritesLoaded=favoriteIds.length-productIds.length>0;var _useState3=useState(allFavoritesLoaded),_useState4=_slicedToArray(_useState3,2),shouldShowLoadMoreButton=_useState4[0],setShouldShowLoadMoreButton=_useState4[1];var loadMore=useCallback(function(){setOffset(offset+FAVORITES_SHOW_LIMIT);},[offset]);useEffect(function(){setShouldShowLoadMoreButton(allFavoritesLoaded);},[offset,allFavoritesLoaded]);return hasMultipleFavoritesListsSupport?/*#__PURE__*/React.createElement(Card,{className:styles.root},/*#__PURE__*/React.createElement(Accordion,{className:"",openWithChevron:true,renderLabel:function renderLabel(){return/*#__PURE__*/React.createElement(FavoriteListLabel,{id:id,title:name,rename:function rename(newName){return _rename(id,newName);},remove:remove,disableRemoveList:disableRemoveList});},chevronPosition:"left",startOpened:true,testId:id},/*#__PURE__*/React.createElement(FavoritesListContent,{addToCart:addToCart,id:id,loadMore:loadMore,productIds:productIds,removeItem:removeItem,shouldShowLoadMoreButton:shouldShowLoadMoreButton,hasMultipleFavoritesListsSupport:hasMultipleFavoritesListsSupport}))):/*#__PURE__*/React.createElement("div",{className:styles.rootNoFavoritesLists},/*#__PURE__*/React.createElement(FavoritesListContent,{addToCart:addToCart,id:id,loadMore:loadMore,productIds:productIds,removeItem:removeItem,shouldShowLoadMoreButton:shouldShowLoadMoreButton}));};FavoriteList.defaultProps={hasMultipleFavoritesListsSupport:false};export default connect(makeMapStateToProps)(FavoriteList);
@@ -1,7 +1,7 @@
1
- import React from'react';import PropTypes from'prop-types';import{connect}from'react-redux';import{css}from'glamor';import{makeIsProductOnSpecificFavoriteList}from'@shopgate/pwa-common-commerce/favorites/selectors';import{i18n}from'@shopgate/engage/core';/**
1
+ import React from'react';import PropTypes from'prop-types';import{connect}from'react-redux';import{css}from'glamor';import{makeIsProductOnSpecificFavoriteList}from'@shopgate/pwa-common-commerce/favorites/selectors';import{i18n}from'@shopgate/engage/core';import{themeConfig}from'@shopgate/pwa-common/helpers/config';/**
2
2
  * @param {Object} state State.
3
3
  * @returns {Object}
4
- */var makeMapStateToProps=function makeMapStateToProps(){var getIsOnList=makeIsProductOnSpecificFavoriteList(function(_,props){return props.productId;},function(_,props){return props.listId;});return function(state,props){return{isOnList:getIsOnList(state,props)};};};var styles={remove:css({color:'var(--color-state-alert)'}).toString(),add:css({color:'var(--color-state-ok)'}).toString()};/**
4
+ */var makeMapStateToProps=function makeMapStateToProps(){var getIsOnList=makeIsProductOnSpecificFavoriteList(function(_,props){return props.productId;},function(_,props){return props.listId;});return function(state,props){return{isOnList:getIsOnList(state,props)};};};var styles={remove:css({color:"var(--color-state-alert, ".concat(themeConfig.colors.error,")")}).toString(),add:css({color:'var(--color-state-ok)'}).toString()};/**
5
5
  * @param {Object} props Props.
6
6
  * @returns {JSX}
7
7
  */var ListChooserItem=function ListChooserItem(_ref){var isOnList=_ref.isOnList;return isOnList?/*#__PURE__*/React.createElement("span",{className:styles.remove},i18n.text('favorites.list_chooser.remove')):/*#__PURE__*/React.createElement("span",{className:styles.add},i18n.text('favorites.list_chooser.add'));};export default connect(makeMapStateToProps)(ListChooserItem);
@@ -1,4 +1,4 @@
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,{useState,useCallback,useRef}from'react';import PropTypes from'prop-types';import{connect}from'react-redux';import{css}from'glamor';import{RippleButton,SurroundPortals}from'@shopgate/engage/components';import{i18n}from'@shopgate/engage/core';import appConfig from'@shopgate/pwa-common/helpers/config';import{getFavoritesLists,isInitialLoading}from'@shopgate/pwa-common-commerce/favorites/selectors';import addFavoritesList from'@shopgate/pwa-common-commerce/favorites/actions/addFavoritesList';import updateFavoritesList from'@shopgate/pwa-common-commerce/favorites/actions/updateFavoritesList';import removeFavoritesList from'@shopgate/pwa-common-commerce/favorites/actions/removeFavoritesList';import{removeFavorites}from'@shopgate/pwa-common-commerce/favorites/actions/toggleFavorites';import addProductsToCart from'@shopgate/pwa-common-commerce/cart/actions/addProductsToCart';import List from"../List";import ListsModal from"./ListsModal";import{FAVORITES_LIST_ADD_BUTTON,FAVORITES_LIST}from"../../constants/Portals";/**
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,{useState,useCallback,useRef}from'react';import PropTypes from'prop-types';import{connect}from'react-redux';import{css}from'glamor';import{RippleButton,SurroundPortals}from'@shopgate/engage/components';import{i18n}from'@shopgate/engage/core';import{getFavoritesLists,isInitialLoading,getHasMultipleFavoritesListsSupport,addFavoritesList,updateFavoritesList,removeFavoritesList,removeFavorites}from'@shopgate/engage/favorites';import{addProductsToCart}from'@shopgate/engage/cart';import List from"../List";import ListsModal from"./ListsModal";import{FAVORITES_LIST_ADD_BUTTON,FAVORITES_LIST}from"../../constants/Portals";/**
2
2
  * TODO
3
3
  *
4
4
  * This constant originally comes from PWA 7 shopSettings. If another mode is requested in the
@@ -7,15 +7,15 @@ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimi
7
7
  * @param {Object} state State
8
8
  * @param {Object} props Props
9
9
  * @returns {Object}
10
- */var mapStateToProps=function mapStateToProps(state){return{isInitializing:isInitialLoading(state),lists:getFavoritesLists(state),wishlistMode:WISHLIST_MODE_PERSIST_ON_ADD};};/**
10
+ */var mapStateToProps=function mapStateToProps(state){return{isInitializing:isInitialLoading(state),lists:getFavoritesLists(state),wishlistMode:WISHLIST_MODE_PERSIST_ON_ADD,hasMultipleFavoritesListsSupport:getHasMultipleFavoritesListsSupport(state)};};/**
11
11
  * @param {Object} dispatch Dispatch
12
12
  * @returns {Object}
13
13
  */var mapDispatchToProps=function mapDispatchToProps(dispatch){return{addList:function addList(name){return dispatch(addFavoritesList(name));},updateList:function updateList(id,name){return dispatch(updateFavoritesList(id,name));},removeList:function removeList(id){return dispatch(removeFavoritesList(id));},removeItem:function removeItem(listId,productId){return dispatch(removeFavorites(productId,false,listId));},addToCart:function addToCart(){return dispatch(addProductsToCart.apply(void 0,arguments));}};};var styles={root:css({}),addButton:css({width:'calc(100% - 32px)',margin:16,borderRadius:5}).toString()};/**
14
14
  * @param {Object} props Props
15
15
  * @returns {Object}
16
- */var FavoriteLists=function FavoriteLists(_ref){var addList=_ref.addList,updateList=_ref.updateList,removeList=_ref.removeList,_removeItem=_ref.removeItem,addToCart=_ref.addToCart,wishlistMode=_ref.wishlistMode,lists=_ref.lists,isInitializing=_ref.isInitializing;// Add to cart state.
16
+ */var FavoriteLists=function FavoriteLists(_ref){var addList=_ref.addList,updateList=_ref.updateList,removeList=_ref.removeList,_removeItem=_ref.removeItem,addToCart=_ref.addToCart,wishlistMode=_ref.wishlistMode,lists=_ref.lists,isInitializing=_ref.isInitializing,hasMultipleFavoritesListsSupport=_ref.hasMultipleFavoritesListsSupport;// Add to cart state.
17
17
  var promiseRef=useRef(null);var handleAddToCart=useCallback(function(listId,product){// Create promise to inform add to cart button when ready.
18
18
  var promise=new Promise(function(_resolve,reject){promiseRef.current={resolve:function resolve(){// Remove item from wishlist after adding to cart.
19
19
  if(wishlistMode!==WISHLIST_MODE_PERSIST_ON_ADD){_removeItem(listId,product.id);}_resolve();},reject:reject};});// If all options are already configured immediately add it to the cart.
20
20
  addToCart([{productId:product.id,quantity:1}]);promiseRef.current.resolve();return promise;},[addToCart,_removeItem,wishlistMode]);// Modal for renaming and adding.
21
- var _useState=useState(false),_useState2=_slicedToArray(_useState,2),modalOpen=_useState2[0],setModalOpen=_useState2[1];var _useState3=useState(null),_useState4=_slicedToArray(_useState3,2),modalType=_useState4[0],setModalType=_useState4[1];var _useState5=useState(null),_useState6=_slicedToArray(_useState5,2),modalTarget=_useState6[0],setModalTarget=_useState6[1];var openAddModal=useCallback(function(){setModalOpen(true);setModalType('add_list');setModalTarget(null);},[]);var openRenameModal=useCallback(function(code){setModalOpen(true);setModalType('rename_list');setModalTarget(code);},[]);var closeModal=useCallback(function(){setModalOpen(false);setModalType(null);setModalTarget(null);},[]);var confirmModal=useCallback(function(name){if(modalType==='add_list'){addList(name);}else if(modalType==='rename_list'){updateList(modalTarget,name);}closeModal();},[addList,closeModal,modalTarget,modalType,updateList]);if(isInitializing){return null;}return/*#__PURE__*/React.createElement("div",{className:styles.root},lists.map(function(list){return/*#__PURE__*/React.createElement(SurroundPortals,{key:list.id,portalName:FAVORITES_LIST,portalProps:list},/*#__PURE__*/React.createElement(List,{id:list.id,name:list.name,rename:openRenameModal,remove:function remove(){return removeList(list.id);},removeItem:function removeItem(productId){return _removeItem(list.id,productId);},addToCart:function addToCart(product){return handleAddToCart(list.id,product);},disableRemoveList:lists.length<2}));}),modalOpen?/*#__PURE__*/React.createElement(ListsModal,{type:modalType,onDismiss:closeModal,onConfirm:confirmModal}):null,/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_LIST_ADD_BUTTON},appConfig.favoritesMode.hasMultipleFavoritesLists?/*#__PURE__*/React.createElement(RippleButton,{type:"primary",className:styles.addButton,onClick:openAddModal,disabled:false},i18n.text('favorites.add_list')):null));};FavoriteLists.defaultProps={lists:[],isInitializing:true};export default connect(mapStateToProps,mapDispatchToProps)(FavoriteLists);
21
+ var _useState=useState(false),_useState2=_slicedToArray(_useState,2),modalOpen=_useState2[0],setModalOpen=_useState2[1];var _useState3=useState(null),_useState4=_slicedToArray(_useState3,2),modalType=_useState4[0],setModalType=_useState4[1];var _useState5=useState(null),_useState6=_slicedToArray(_useState5,2),modalTarget=_useState6[0],setModalTarget=_useState6[1];var openAddModal=useCallback(function(){setModalOpen(true);setModalType('add_list');setModalTarget(null);},[]);var openRenameModal=useCallback(function(code){setModalOpen(true);setModalType('rename_list');setModalTarget(code);},[]);var closeModal=useCallback(function(){setModalOpen(false);setModalType(null);setModalTarget(null);},[]);var confirmModal=useCallback(function(name){if(modalType==='add_list'){addList(name);}else if(modalType==='rename_list'){updateList(modalTarget,name);}closeModal();},[addList,closeModal,modalTarget,modalType,updateList]);if(isInitializing){return null;}return/*#__PURE__*/React.createElement("div",{className:styles.root},lists.map(function(list){return/*#__PURE__*/React.createElement(SurroundPortals,{key:list.id,portalName:FAVORITES_LIST,portalProps:list},/*#__PURE__*/React.createElement(List,{id:list.id,name:list.name,rename:openRenameModal,remove:function remove(){return removeList(list.id);},removeItem:function removeItem(productId){return _removeItem(list.id,productId);},addToCart:function addToCart(product){return handleAddToCart(list.id,product);},disableRemoveList:lists.length<2}));}),modalOpen?/*#__PURE__*/React.createElement(ListsModal,{type:modalType,onDismiss:closeModal,onConfirm:confirmModal}):null,/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_LIST_ADD_BUTTON},hasMultipleFavoritesListsSupport?/*#__PURE__*/React.createElement(RippleButton,{type:"primary",className:styles.addButton,onClick:openAddModal,disabled:false},i18n.text('favorites.add_list')):null));};FavoriteLists.defaultProps={lists:[],isInitializing:true,hasMultipleFavoritesListsSupport:false};export default connect(mapStateToProps,mapDispatchToProps)(FavoriteLists);
@@ -1,4 +1,6 @@
1
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,{useState,useCallback}from'react';import PropTypes from'prop-types';import{Dialog,TextField}from'@shopgate/engage/components';import{i18n}from'@shopgate/engage/core';import{css}from'glamor';var styles={root:css({display:'flex',flexDirection:'column'}),textField:css({textAlign:'left'})};/**
2
2
  * @param {Object} props Props
3
3
  * @returns {Object}
4
- */var ListsModal=function ListsModal(_ref){var type=_ref.type,onConfirm=_ref.onConfirm,onDismiss=_ref.onDismiss;var _useState=useState(''),_useState2=_slicedToArray(_useState,2),input=_useState2[0],setInput=_useState2[1];var _useState3=useState(null),_useState4=_slicedToArray(_useState3,2),error=_useState4[0],setError=_useState4[1];var onConfirmWrapped=useCallback(function(){if(input.length===0){setError(i18n.text('favorites.errors.invalid_name'));return;}onConfirm(input);},[input,onConfirm]);var onChange=useCallback(function(value){setInput(value);},[]);return/*#__PURE__*/React.createElement(Dialog,{onConfirm:onConfirmWrapped,onDismiss:onDismiss,modal:{title:i18n.text("favorites.".concat(type,"_modal.title")),dismiss:i18n.text("favorites.".concat(type,"_modal.dismiss")),confirm:i18n.text("favorites.".concat(type,"_modal.confirm")),content:/*#__PURE__*/React.createElement("div",{className:styles.root},/*#__PURE__*/React.createElement("span",null,i18n.text("favorites.".concat(type,"_modal.message"))),/*#__PURE__*/React.createElement(TextField,{name:"name",label:i18n.text("favorites.".concat(type,"_modal.label")),onChange:onChange,value:input,errorText:error||undefined,className:styles.textField,maxlength:"25"}))}});};export default ListsModal;
4
+ */var ListsModal=function ListsModal(_ref){var type=_ref.type,onConfirm=_ref.onConfirm,onDismiss=_ref.onDismiss;var _useState=useState(''),_useState2=_slicedToArray(_useState,2),input=_useState2[0],setInput=_useState2[1];var _useState3=useState(null),_useState4=_slicedToArray(_useState3,2),error=_useState4[0],setError=_useState4[1];var onConfirmWrapped=useCallback(function(){if(input.length===0){setError(i18n.text('favorites.errors.invalid_name'));return;}onConfirm(input);},[input,onConfirm]);var onChange=useCallback(function(value){setInput(value);},[]);/**
5
+ * Submit handler for the text input
6
+ */var handleKeyPress=useCallback(function(e){if(e.key==='Enter'){onConfirmWrapped();}},[onConfirmWrapped]);return/*#__PURE__*/React.createElement(Dialog,{onConfirm:onConfirmWrapped,onDismiss:onDismiss,modal:{title:i18n.text("favorites.".concat(type,"_modal.title")),dismiss:i18n.text("favorites.".concat(type,"_modal.dismiss")),confirm:i18n.text("favorites.".concat(type,"_modal.confirm")),content:/*#__PURE__*/React.createElement("div",{className:styles.root},/*#__PURE__*/React.createElement("span",null,i18n.text("favorites.".concat(type,"_modal.message"))),/*#__PURE__*/React.createElement(TextField,{name:"name",label:i18n.text("favorites.".concat(type,"_modal.label")),onChange:onChange,value:input,errorText:error||undefined,className:styles.textField,maxlength:"25",onKeyPress:handleKeyPress}))}});};export default ListsModal;
@@ -1,5 +1,5 @@
1
1
  /** @module favorites */ // ACTIONS
2
- export{default as fetchFavorites}from'@shopgate/pwa-common-commerce/favorites/actions/fetchFavorites';export{default as fetchFavoritesLists}from'@shopgate/pwa-common-commerce/favorites/actions/fetchFavoritesList';export{default as addFavoritesList}from'@shopgate/pwa-common-commerce/favorites/actions/addFavoritesList';export{addFavorite,removeFavorites,requestSync as toggleFavorites,toggleFavoriteWithListChooser,toggleFavorite}from'@shopgate/pwa-common-commerce/favorites/actions/toggleFavorites';// CONSTANTS
2
+ export{default as fetchFavorites}from'@shopgate/pwa-common-commerce/favorites/actions/fetchFavorites';export{default as fetchFavoritesLists}from'@shopgate/pwa-common-commerce/favorites/actions/fetchFavoritesLists';export{default as addFavoritesList}from'@shopgate/pwa-common-commerce/favorites/actions/addFavoritesList';export{default as updateFavoritesList}from'@shopgate/pwa-common-commerce/favorites/actions/updateFavoritesList';export{default as removeFavoritesList}from'@shopgate/pwa-common-commerce/favorites/actions/removeFavoritesList';export{addFavorite,removeFavorites,requestSync as toggleFavorites,toggleFavoriteWithListChooser,toggleFavorite}from'@shopgate/pwa-common-commerce/favorites/actions/toggleFavorites';// CONSTANTS
3
3
  export*from'@shopgate/pwa-common-commerce/favorites/constants/index';export*from'@shopgate/pwa-common-commerce/favorites/constants/Pipelines';export*from'@shopgate/pwa-common-commerce/favorites/constants/Portals';export*from"./constants/Portals";// SELECTORS
4
4
  export*from'@shopgate/pwa-common-commerce/favorites/selectors';// STREAMS
5
- export*from'@shopgate/pwa-common-commerce/favorites/streams';
5
+ export*from'@shopgate/pwa-common-commerce/favorites/streams';export{default as FavoriteLists}from"./components/Lists";export{default as FavoritesListChooser}from"./components/ListChooser";
@@ -1 +1 @@
1
- import React from'react';import{shallow}from'enzyme';import Label from"./index";describe('PriceSlider: <Label />',function(){it('should render',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Label,{priceLength:"5",priceMax:999,priceMin:25}));expect(wrapper).toMatchSnapshot();});});
1
+ import React from'react';import{shallow}from'enzyme';import Label from"./index";describe('PriceSlider: <Label />',function(){it('should render',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Label,{priceLength:"5",priceMax:999,priceMin:25,onChange:function onChange(){}}));expect(wrapper).toMatchSnapshot();});});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/engage",
3
- "version": "6.20.0-rc.3",
3
+ "version": "6.20.0-rc.5",
4
4
  "description": "Shopgate's ENGAGE library.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -15,12 +15,12 @@
15
15
  "connect"
16
16
  ],
17
17
  "dependencies": {
18
- "@shopgate/pwa-common": "6.20.0-rc.3",
19
- "@shopgate/pwa-common-commerce": "6.20.0-rc.3",
20
- "@shopgate/pwa-core": "6.20.0-rc.3",
21
- "@shopgate/pwa-ui-ios": "6.20.0-rc.3",
22
- "@shopgate/pwa-ui-material": "6.20.0-rc.3",
23
- "@shopgate/pwa-ui-shared": "6.20.0-rc.3",
18
+ "@shopgate/pwa-common": "6.20.0-rc.5",
19
+ "@shopgate/pwa-common-commerce": "6.20.0-rc.5",
20
+ "@shopgate/pwa-core": "6.20.0-rc.5",
21
+ "@shopgate/pwa-ui-ios": "6.20.0-rc.5",
22
+ "@shopgate/pwa-ui-material": "6.20.0-rc.5",
23
+ "@shopgate/pwa-ui-shared": "6.20.0-rc.5",
24
24
  "@virtuous/conductor": "~2.4.0",
25
25
  "babel-plugin-transform-es3-member-expression-literals": "^6.8.0",
26
26
  "babel-plugin-transform-es3-property-literals": "^6.8.0",
@@ -1,5 +1,8 @@
1
1
  import React,{Fragment}from'react';import PropTypes from'prop-types';import Portal from'@shopgate/pwa-common/components/Portal';import{PRODUCT_PRICE_STRIKED,PRODUCT_PRICE_STRIKED_AFTER,PRODUCT_PRICE_STRIKED_BEFORE}from'@shopgate/pwa-common-commerce/product/constants/Portals';import{withPriceCalculation}from'@shopgate/engage/product';import I18n from'@shopgate/pwa-common/components/I18n';import PlaceholderLabel from'@shopgate/pwa-ui-shared/PlaceholderLabel';import StrikePrice from'@shopgate/pwa-ui-shared/PriceStriked';import{useWidgetSettings}from'@shopgate/engage/core/hooks/useWidgetSettings';import connect from"./connector";import styles from"./style";/**
2
+ * @param {Object} props The component props.
3
+ * @return {JSX}
4
+ */var Content=function Content(_ref){var price=_ref.price;var _useWidgetSettings=useWidgetSettings('@shopgate/engage/product/components/Header/PriceStriked'),_useWidgetSettings$ms=_useWidgetSettings.msrpLabel,msrpLabel=_useWidgetSettings$ms===void 0?'price.msrp':_useWidgetSettings$ms,unitPriceStrikedLabel=_useWidgetSettings.unitPriceStrikedLabel;return/*#__PURE__*/React.createElement(PlaceholderLabel,{className:styles.placeholder,ready:price!==null},price&&price.msrp>0&&price.unitPrice!==price.msrp&&/*#__PURE__*/React.createElement(Fragment,null,!!msrpLabel&&/*#__PURE__*/React.createElement(I18n.Text,{string:msrpLabel,className:styles.msrp}),/*#__PURE__*/React.createElement(StrikePrice,{className:styles.msrpStriked,value:price.msrp,currency:price.currency})),price&&!price.msrp&&price.unitPriceStriked>0&&/*#__PURE__*/React.createElement(Fragment,null,!!unitPriceStrikedLabel&&/*#__PURE__*/React.createElement(I18n.Text,{string:unitPriceStrikedLabel,className:styles.msrp}),/*#__PURE__*/React.createElement(StrikePrice,{value:price.unitPriceStriked,currency:price.currency,className:unitPriceStrikedLabel?styles.msrpStriked:''})));};/**
2
5
  * The PriceStriked component.
3
6
  * @param {Object} props The component props.
4
7
  * @return {JSX}
5
- */var PriceStriked=function PriceStriked(_ref){var price=_ref.price;var _useWidgetSettings=useWidgetSettings('@shopgate/engage/product/components/Header/PriceStriked'),_useWidgetSettings$ms=_useWidgetSettings.msrpLabel,msrpLabel=_useWidgetSettings$ms===void 0?'price.msrp':_useWidgetSettings$ms,unitPriceStrikedLabel=_useWidgetSettings.unitPriceStrikedLabel;return/*#__PURE__*/React.createElement(Fragment,null,/*#__PURE__*/React.createElement(Portal,{name:PRODUCT_PRICE_STRIKED_BEFORE}),/*#__PURE__*/React.createElement(Portal,{name:PRODUCT_PRICE_STRIKED},/*#__PURE__*/React.createElement(PlaceholderLabel,{className:styles.placeholder,ready:price!==null},price&&price.msrp>0&&price.unitPrice!==price.msrp&&/*#__PURE__*/React.createElement(Fragment,null,!!msrpLabel&&/*#__PURE__*/React.createElement(I18n.Text,{string:msrpLabel,className:styles.msrp}),/*#__PURE__*/React.createElement(StrikePrice,{className:styles.msrpStriked,value:price.msrp,currency:price.currency})),price&&!price.msrp&&price.unitPriceStriked>0&&/*#__PURE__*/React.createElement(Fragment,null,!!unitPriceStrikedLabel&&/*#__PURE__*/React.createElement(I18n.Text,{string:unitPriceStrikedLabel,className:styles.msrp}),/*#__PURE__*/React.createElement(StrikePrice,{value:price.unitPriceStriked,currency:price.currency,className:unitPriceStrikedLabel?styles.msrpStriked:''})))),/*#__PURE__*/React.createElement(Portal,{name:PRODUCT_PRICE_STRIKED_AFTER}));};PriceStriked.defaultProps={price:null};export default connect(withPriceCalculation(PriceStriked));
8
+ */var PriceStriked=function PriceStriked(props){return/*#__PURE__*/React.createElement(Fragment,null,/*#__PURE__*/React.createElement(Portal,{name:PRODUCT_PRICE_STRIKED_BEFORE}),/*#__PURE__*/React.createElement(Portal,{name:PRODUCT_PRICE_STRIKED},/*#__PURE__*/React.createElement(Content,props)),/*#__PURE__*/React.createElement(Portal,{name:PRODUCT_PRICE_STRIKED_AFTER}));};Content.defaultProps={price:null};export default connect(withPriceCalculation(PriceStriked));
@@ -7,4 +7,4 @@ import React,{Fragment}from'react';import PropTypes from'prop-types';import{isBe
7
7
  * @param {boolean} props.hideName Whether the name should be hidden.
8
8
  * @param {number} props.titleRows The max number of rows for the product title.
9
9
  * @return {JSX}
10
- */function ProductCard(props){var product=props.product,hidePrice=props.hidePrice,hideRating=props.hideRating,hideName=props.hideName,titleRows=props.titleRows;var _getProductImageSetti=getProductImageSettings(),gridResolutions=_getProductImageSetti.ListImage;var _useWidgetSettings=useWidgetSettings('@shopgate/engage/rating'),_useWidgetSettings$sh=_useWidgetSettings.showEmptyRatingStars,showEmptyRatingStars=_useWidgetSettings$sh===void 0?false:_useWidgetSettings$sh;var showRatings=false;if(!hideRating&&product.rating&&product.rating.average>0){showRatings=true;}else if(!hideRating&&showEmptyRatingStars&&product.rating){showRatings=true;}return/*#__PURE__*/React.createElement(Link,{className:"engage__product-card",tagName:"a",href:getProductRoute(product.id),itemProp:"item",itemScope:true,itemType:"http://schema.org/Product"},isBeta()&&product.featuredMedia?/*#__PURE__*/React.createElement(FeaturedMedia,{type:product.featuredMedia.type,url:product.featuredMedia.url,altText:product.featuredMedia.altText}):/*#__PURE__*/React.createElement(ProductImage,{src:product.featuredImageBaseUrl,resolutions:gridResolutions,alt:product.name,itemProp:"image"}),/*#__PURE__*/React.createElement(ProductBadges,{location:location,productId:product.id},!!(!hidePrice&&product.price.discount)&&/*#__PURE__*/React.createElement("div",{className:styles.badgeWrapper},/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_DISCOUNT_BEFORE,props:{productId:product.id}}),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_DISCOUNT,props:{productId:product.id}},/*#__PURE__*/React.createElement(DiscountBadge,{text:"-".concat(product.price.discount,"%")})),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_DISCOUNT_AFTER,props:{productId:product.id}}))),!(hidePrice&&hideRating)&&/*#__PURE__*/React.createElement("div",{className:styles.details},showRatings&&/*#__PURE__*/React.createElement(RatingStars,{value:product.rating.average}),/*#__PURE__*/React.createElement(Swatches,{productId:product.id}),!hideName&&/*#__PURE__*/React.createElement("div",{itemProp:"name",className:styles.title,"data-test-id":"Productname: ".concat(product.name)},/*#__PURE__*/React.createElement(Ellipsis,{rows:titleRows||3},product.name)),/*#__PURE__*/React.createElement(MapPriceHint,{productId:product.id}),/*#__PURE__*/React.createElement(OrderQuantityHint,{productId:product.id}),!hidePrice&&/*#__PURE__*/React.createElement(Fragment,null,/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_PRICE_BEFORE,props:{productId:product.id,location:location}}),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_PRICE,props:{productId:product.id,location:location}},/*#__PURE__*/React.createElement(ProductGridPrice,{price:product.price})),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_PRICE_AFTER,props:{productId:product.id,location:location}}))));}export default ProductCard;
10
+ */function ProductCard(props){var product=props.product,hidePrice=props.hidePrice,hideRating=props.hideRating,hideName=props.hideName,titleRows=props.titleRows,linkState=props.linkState,linkReplace=props.linkReplace,linkHref=props.linkHref;var _getProductImageSetti=getProductImageSettings(),gridResolutions=_getProductImageSetti.ListImage;var _useWidgetSettings=useWidgetSettings('@shopgate/engage/rating'),_useWidgetSettings$sh=_useWidgetSettings.showEmptyRatingStars,showEmptyRatingStars=_useWidgetSettings$sh===void 0?false:_useWidgetSettings$sh;var showRatings=false;if(!hideRating&&product.rating&&product.rating.average>0){showRatings=true;}else if(!hideRating&&showEmptyRatingStars&&product.rating){showRatings=true;}return/*#__PURE__*/React.createElement(Link,{className:"engage__product-card",tagName:"a",href:linkHref||getProductRoute(product.id),itemProp:"item",itemScope:true,itemType:"http://schema.org/Product",state:linkState,replace:linkReplace},isBeta()&&product.featuredMedia?/*#__PURE__*/React.createElement(FeaturedMedia,{type:product.featuredMedia.type,url:product.featuredMedia.url,altText:product.featuredMedia.altText}):/*#__PURE__*/React.createElement(ProductImage,{src:product.featuredImageBaseUrl,resolutions:gridResolutions,alt:product.name,itemProp:"image"}),/*#__PURE__*/React.createElement(ProductBadges,{location:location,productId:product.id},!!(!hidePrice&&product.price.discount)&&/*#__PURE__*/React.createElement("div",{className:styles.badgeWrapper},/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_DISCOUNT_BEFORE,props:{productId:product.id}}),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_DISCOUNT,props:{productId:product.id}},/*#__PURE__*/React.createElement(DiscountBadge,{text:"-".concat(product.price.discount,"%")})),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_DISCOUNT_AFTER,props:{productId:product.id}}))),!(hidePrice&&hideRating)&&/*#__PURE__*/React.createElement("div",{className:styles.details},showRatings&&/*#__PURE__*/React.createElement(RatingStars,{value:product.rating.average}),/*#__PURE__*/React.createElement(Swatches,{productId:product.id}),!hideName&&/*#__PURE__*/React.createElement("div",{itemProp:"name",className:styles.title,"data-test-id":"Productname: ".concat(product.name)},/*#__PURE__*/React.createElement(Ellipsis,{rows:titleRows||3},product.name)),/*#__PURE__*/React.createElement(MapPriceHint,{productId:product.id}),/*#__PURE__*/React.createElement(OrderQuantityHint,{productId:product.id}),!hidePrice&&/*#__PURE__*/React.createElement(Fragment,null,/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_PRICE_BEFORE,props:{productId:product.id,location:location}}),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_PRICE,props:{productId:product.id,location:location}},/*#__PURE__*/React.createElement(ProductGridPrice,{price:product.price})),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_PRICE_AFTER,props:{productId:product.id,location:location}}))));}ProductCard.defaultProps={linkState:{},linkReplace:false,linkHref:''};export default ProductCard;
package/scanner/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /** @module scanner */ // ACTION-CREATORS
2
- export{default as startScanner}from'@shopgate/pwa-common-commerce/scanner//action-creators/startScanner';// ACTIONS
3
- export{default as handleBarCode}from'@shopgate/pwa-common-commerce/scanner/actions/handleBarCode';export{default as handleQrCode}from'@shopgate/pwa-common-commerce/scanner/actions/handleQrCode';export{default as scanner}from'@shopgate/pwa-core/classes/Scanner';// CONSTANTS
2
+ export{default as startScanner}from'@shopgate/pwa-common-commerce/scanner/action-creators/startScanner';export{default as successHandleScanner}from'@shopgate/pwa-common-commerce/scanner/action-creators/successHandleScanner';export{default as errorHandleScanner}from'@shopgate/pwa-common-commerce/scanner/action-creators/errorHandleScanner';// ACTIONS
3
+ export{default as handleBarCode}from'@shopgate/pwa-common-commerce/scanner/actions/handleBarCode';export{default as handleQrCode}from'@shopgate/pwa-common-commerce/scanner/actions/handleQrCode';export{default as handleSearch}from'@shopgate/pwa-common-commerce/scanner/actions/handleSearch';export{default as handleNoResults}from'@shopgate/pwa-common-commerce/scanner/actions/handleNoResults';export{default as scanner}from'@shopgate/pwa-core/classes/Scanner';// CONSTANTS
4
4
  export*from'@shopgate/pwa-common-commerce/scanner/constants';export*from'@shopgate/pwa-common-commerce/scanner/constants/Portals';export*from'@shopgate/pwa-core/constants/Scanner';// HELPERS
5
5
  export*from'@shopgate/pwa-common-commerce/scanner/helpers';// STREAMS
6
6
  export*from'@shopgate/pwa-common-commerce/scanner/streams';
@@ -1,5 +0,0 @@
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);
@@ -1,4 +0,0 @@
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);