@shopgate/engage 6.20.0-rc.2 → 6.20.0-rc.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.
- package/components/MessageBar/spec.js +1 -1
- package/favorites/components/List/List.js +8 -4
- package/favorites/components/ListChooser/ListChooserItem.js +2 -2
- package/favorites/components/Lists/Lists.js +4 -4
- package/favorites/components/Lists/ListsModal.js +3 -1
- package/favorites/index.js +2 -2
- package/filter/components/PriceSlider/components/Label/spec.js +1 -1
- package/package.json +7 -7
- package/product/components/Characteristics/index.js +1 -1
- package/product/components/Header/PriceStriked/index.js +4 -1
- package/product/components/ProductCard/index.js +1 -1
- package/product/components/ProductCharacteristics/index.js +9 -7
- package/product/components/ProductList/index.js +1 -1
- package/scanner/index.js +2 -2
- package/favorites/components/FavoriteProvider/connector.js +0 -5
- package/favorites/components/FavoriteProvider/index.js +0 -4
|
@@ -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='
|
|
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();});});
|
|
@@ -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
|
|
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
|
|
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
|
|
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:
|
|
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
|
|
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},
|
|
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);},[])
|
|
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;
|
package/favorites/index.js
CHANGED
|
@@ -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/
|
|
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
|
+
"version": "6.20.0-rc.4",
|
|
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.
|
|
19
|
-
"@shopgate/pwa-common-commerce": "6.20.0-rc.
|
|
20
|
-
"@shopgate/pwa-core": "6.20.0-rc.
|
|
21
|
-
"@shopgate/pwa-ui-ios": "6.20.0-rc.
|
|
22
|
-
"@shopgate/pwa-ui-material": "6.20.0-rc.
|
|
23
|
-
"@shopgate/pwa-ui-shared": "6.20.0-rc.
|
|
18
|
+
"@shopgate/pwa-common": "6.20.0-rc.4",
|
|
19
|
+
"@shopgate/pwa-common-commerce": "6.20.0-rc.4",
|
|
20
|
+
"@shopgate/pwa-core": "6.20.0-rc.4",
|
|
21
|
+
"@shopgate/pwa-ui-ios": "6.20.0-rc.4",
|
|
22
|
+
"@shopgate/pwa-ui-material": "6.20.0-rc.4",
|
|
23
|
+
"@shopgate/pwa-ui-shared": "6.20.0-rc.4",
|
|
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,5 @@
|
|
|
1
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,{PureComponent,Fragment}from'react';import PropTypes from'prop-types';import{isBeta}from'@shopgate/engage/core';import Portal from'@shopgate/pwa-common/components/Portal';import{PRODUCT_VARIANT_SELECT,PRODUCT_VARIANT_SELECT_AFTER,PRODUCT_VARIANT_SELECT_BEFORE}from'@shopgate/pwa-common-commerce/product/constants/Portals';import{ProductCharacteristics,ProductContext}from'@shopgate/engage/product';import Characteristic from"./Characteristic";import Swatch from"./Swatch";/**
|
|
2
2
|
* The Characteristics component.
|
|
3
|
-
*/var Characteristics=/*#__PURE__*/function(_PureComponent){_inherits(Characteristics,_PureComponent);var _super=_createSuper(Characteristics);function Characteristics(){var _this;_classCallCheck(this,Characteristics);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_super.call.apply(_super,[this].concat(args));_defineProperty(_assertThisInitialized(_this),"consumeRenderer",function(_ref){var conditioner=_ref.conditioner,setCharacteristics=_ref.setCharacteristics;var _this$props=_this.props,productId=_this$props.productId,variantId=_this$props.variantId;return/*#__PURE__*/React.createElement(ProductCharacteristics,{productId:productId,variantId:variantId,render:_this.renderer,conditioner:conditioner,finishTimeout:200,setCharacteristics:setCharacteristics});});_defineProperty(_assertThisInitialized(_this),"renderer",function(props){if(isBeta()&&!!props.swatch){return/*#__PURE__*/React.createElement(Swatch,props);}return/*#__PURE__*/React.createElement(Characteristic,props);});return _this;}_createClass(Characteristics,[{key:"render",value:/**
|
|
3
|
+
*/var Characteristics=/*#__PURE__*/function(_PureComponent){_inherits(Characteristics,_PureComponent);var _super=_createSuper(Characteristics);function Characteristics(){var _this;_classCallCheck(this,Characteristics);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_super.call.apply(_super,[this].concat(args));_defineProperty(_assertThisInitialized(_this),"consumeRenderer",function(_ref){var conditioner=_ref.conditioner,setCharacteristics=_ref.setCharacteristics,characteristics=_ref.characteristics;var _this$props=_this.props,productId=_this$props.productId,variantId=_this$props.variantId;return/*#__PURE__*/React.createElement(ProductCharacteristics,{productId:productId,variantId:variantId,render:_this.renderer,conditioner:conditioner,finishTimeout:200,setCharacteristics:setCharacteristics,characteristics:characteristics});});_defineProperty(_assertThisInitialized(_this),"renderer",function(props){if(isBeta()&&!!props.swatch){return/*#__PURE__*/React.createElement(Swatch,props);}return/*#__PURE__*/React.createElement(Characteristic,props);});return _this;}_createClass(Characteristics,[{key:"render",value:/**
|
|
4
4
|
* @returns {JSX}
|
|
5
5
|
*/function render(){return/*#__PURE__*/React.createElement(Fragment,null,/*#__PURE__*/React.createElement(Portal,{name:PRODUCT_VARIANT_SELECT_BEFORE}),/*#__PURE__*/React.createElement(Portal,{name:PRODUCT_VARIANT_SELECT},/*#__PURE__*/React.createElement(ProductContext.Consumer,null,this.consumeRenderer)),/*#__PURE__*/React.createElement(Portal,{name:PRODUCT_VARIANT_SELECT_AFTER}));}}]);return Characteristics;}(PureComponent);_defineProperty(Characteristics,"defaultProps",{productId:null,variantId:null});Characteristics.defaultProps={productId:null,variantId:null};export default Characteristics;
|
|
@@ -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(
|
|
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;
|
|
@@ -1,15 +1,17 @@
|
|
|
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 _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);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 isMatch from'lodash/isMatch';import{broadcastLiveMessage}from'@shopgate/engage/a11y';import connect from"./connector";import VariantsContext from"./context";import{isCharacteristicEnabled,getSelectedValue,prepareState,selectCharacteristics}from"./helpers";/**
|
|
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 _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);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 isMatch from'lodash/isMatch';import isEqual from'lodash/isEqual';import{broadcastLiveMessage}from'@shopgate/engage/a11y';import connect from"./connector";import VariantsContext from"./context";import{isCharacteristicEnabled,getSelectedValue,prepareState,selectCharacteristics}from"./helpers";/**
|
|
2
2
|
* The ProductCharacteristics component.
|
|
3
3
|
*/var ProductCharacteristics=/*#__PURE__*/function(_Component){_inherits(ProductCharacteristics,_Component);var _super=_createSuper(ProductCharacteristics);/**
|
|
4
4
|
* @param {Object} props The component props.
|
|
5
5
|
*/function ProductCharacteristics(_props){var _this;_classCallCheck(this,ProductCharacteristics);_this=_super.call(this,_props);_defineProperty(_assertThisInitialized(_this),"setRefs",function(props){var variants=props.variants;if(variants){variants.characteristics.forEach(function(_char){_this.refsStore[_char.id]=/*#__PURE__*/React.createRef();});}});_defineProperty(_assertThisInitialized(_this),"checkSelection",function(){var characteristics=_this.state.characteristics;var _this$props=_this.props,variants=_this$props.variants,variantId=_this$props.variantId;if(!variants){return true;}var filteredValues=Object.keys(characteristics).filter(function(key){return!!characteristics[key];});var selected=!!(filteredValues.length===variants.characteristics.length&&variantId);if(!selected){var firstUnselected=_this.findUnselectedCharacteristic();if(firstUnselected){var ref=_this.refsStore[firstUnselected.id];// Focus the item for screen readers and broadcast a related live message.
|
|
6
|
-
ref.current.focus();var option=ref.current.innerText;broadcastLiveMessage('product.pick_option_first',{params:{option:option}});ref.current.scrollIntoView({behavior:'smooth'});_this.setState({highlight:firstUnselected.id});}}return selected;});_defineProperty(_assertThisInitialized(_this),"checkSelectedCharacteristics",function(){var characteristics=_this.state.characteristics;var _this$props2=_this.props,variantId=_this$props2.variantId,variants=_this$props2.variants,finishTimeout=_this$props2.finishTimeout;if(!variants){return;}var filteredValues=Object.keys(characteristics).filter(function(key){return!!characteristics[key];});if(filteredValues.length!==variants.characteristics.length){return;}var products=variants.products.filter(function(product){return isMatch(product.characteristics,characteristics);});if(!products.length){return;}if(products[0].id===variantId){return;}setTimeout(function(){_this.props.navigate(products[0].id);},finishTimeout);});_defineProperty(_assertThisInitialized(_this),"handleSelection",function(selection){var _this$props3=_this.props,variants=_this$props3.variants,setCharacteristics=_this$props3.setCharacteristics;var id=selection.id,value=selection.value;_this.setState(function(_ref){var characteristics=_ref.characteristics;var state=prepareState(id,value,characteristics,variants.characteristics,variants.products);setCharacteristics(state);return{characteristics:_extends({},state),highlight:null};},_this.checkSelectedCharacteristics);});_defineProperty(_assertThisInitialized(_this),"buildValues",function(selections,charId,values,charIndex,selectedValue){// If this is the first characteristic then all values are selectable.
|
|
7
|
-
if(charIndex===0){return values.map(function(value){return _extends({},value,{selectable
|
|
6
|
+
ref.current.focus();var option=ref.current.innerText;broadcastLiveMessage('product.pick_option_first',{params:{option:option}});ref.current.scrollIntoView({behavior:'smooth'});_this.setState({highlight:firstUnselected.id});}}return selected;});_defineProperty(_assertThisInitialized(_this),"checkSelectedCharacteristics",function(){var characteristics=_this.state.characteristics;var _this$props2=_this.props,variantId=_this$props2.variantId,variants=_this$props2.variants,finishTimeout=_this$props2.finishTimeout;if(!variants){return;}var filteredValues=Object.keys(characteristics).filter(function(key){return!!characteristics[key];});if(filteredValues.length!==variants.characteristics.length){return;}var products=variants.products.filter(function(product){return isMatch(product.characteristics,characteristics);});if(!products.length){return;}if(products[0].id===variantId){return;}setTimeout(function(){_this.props.navigate(products[0].id);},finishTimeout);});_defineProperty(_assertThisInitialized(_this),"handleSelection",function(selection){var _this$props3=_this.props,variants=_this$props3.variants,setCharacteristics=_this$props3.setCharacteristics;var id=selection.id,value=selection.value;_this.setState(function(_ref){var characteristics=_ref.characteristics;var state=prepareState(id,value,characteristics,variants.characteristics,variants.products);setCharacteristics(state);return{characteristics:_extends({},state),highlight:null};},_this.checkSelectedCharacteristics);});_defineProperty(_assertThisInitialized(_this),"buildValues",function(selections,charId,values,charIndex,selectedValue,charDisabled){// If this is the first characteristic then all values are selectable.
|
|
7
|
+
if(charIndex===0){return values.map(function(value){return _extends({},value,{selectable:!charDisabled,selected:selectedValue===value.id});});}var variants=_this.props.variants;var subset={};Object.keys(selections).forEach(function(item,index){if(index<charIndex){subset[item]=selections[item];}});// Filter products that match or partially match the current characteristic selection.
|
|
8
8
|
var products=variants.products.filter(function(_ref2){var characteristics=_ref2.characteristics;return isMatch(characteristics,subset);});// Check if any of the values are present inside any of the matching products.
|
|
9
|
-
return values.map(function(value){var selectable=products.some(function(_ref3){var characteristics=_ref3.characteristics;return isMatch(characteristics,_defineProperty({},charId,value.id));});return _extends({},value,{selectable:selectable,selected:selectedValue===value.id});});});_defineProperty(_assertThisInitialized(_this),"resetHighlight",function(){_this.setState({highlight:null});});_this.refsStore={};_this.state={highlight:null,characteristics:
|
|
9
|
+
return values.map(function(value){var selectable=products.some(function(_ref3){var characteristics=_ref3.characteristics;return isMatch(characteristics,_defineProperty({},charId,value.id));});return _extends({},value,{selectable:charDisabled?false:selectable,selected:selectedValue===value.id});});});_defineProperty(_assertThisInitialized(_this),"resetHighlight",function(){_this.setState({highlight:null});});_this.refsStore={};var _characteristics=selectCharacteristics(_props);_this.state={highlight:null,characteristics:_characteristics};_props.setCharacteristics(_characteristics);_this.setRefs(_props);_props.conditioner.addConditioner('product-variants',_this.checkSelection);return _this;}/** @inheritDoc */_createClass(ProductCharacteristics,[{key:"componentDidMount",value:function componentDidMount(){this.checkSelectedCharacteristics();}/**
|
|
10
10
|
* @param {Object} nextProps The next component props.
|
|
11
11
|
*/},{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(!this.props.variants&&nextProps.variants){// Initialize refs and characteristics when the variants prop was updated with a valid value.
|
|
12
|
-
this.setRefs(nextProps);this.setState({characteristics:
|
|
12
|
+
this.setRefs(nextProps);var characteristics=selectCharacteristics(nextProps);this.setState({characteristics:characteristics},this.checkSelectedCharacteristics);// Inform parent component about potential updates e.g. preselected characteristic values
|
|
13
|
+
nextProps.setCharacteristics(characteristics);}else if(nextProps.characteristics&&!isEqual(this.state.characteristics,nextProps.characteristics)){// Sync back characteristics from parent if set
|
|
14
|
+
this.setState({characteristics:nextProps.characteristics});}}/**
|
|
13
15
|
* Sets the refs to the characteristics selects.
|
|
14
16
|
* @param {Object} props The props to check against.
|
|
15
17
|
*/},{key:"findUnselectedCharacteristic",value:/**
|
|
@@ -19,5 +21,5 @@ this.setRefs(nextProps);this.setState({characteristics:selectCharacteristics(nex
|
|
|
19
21
|
* Resets the highlight state
|
|
20
22
|
*/},{key:"render",value:/**
|
|
21
23
|
* @return {JSX}
|
|
22
|
-
*/function render(){var _this2=this;var characteristics=this.state.characteristics;var variants=this.props.variants;if(!variants){return null;}return/*#__PURE__*/React.createElement(VariantsContext.Provider,{value:this.state},variants.characteristics.map(function(_char3,index){var disabled=!isCharacteristicEnabled(characteristics,index);var selected=getSelectedValue(_char3.id,characteristics);var values=_this2.buildValues(characteristics,_char3.id,_char3.values,index,selected);return _this2.props.render({charRef:_this2.refsStore[_char3.id],disabled:disabled,highlight:_this2.state.highlight===_char3.id,id:_char3.id,key:_char3.id,label:_char3.label,swatch:!!_char3.swatch,// BETA
|
|
23
|
-
select:_this2.handleSelection,selected:selected,values:values,resetHighlight:_this2.resetHighlight});}));}}]);return ProductCharacteristics;}(Component);_defineProperty(ProductCharacteristics,"defaultProps",{finishTimeout:0,variantId:null,variants:null});export default connect(ProductCharacteristics);
|
|
24
|
+
*/function render(){var _this2=this;var characteristics=this.state.characteristics;var variants=this.props.variants;if(!variants){return null;}return/*#__PURE__*/React.createElement(VariantsContext.Provider,{value:this.state},variants.characteristics.map(function(_char3,index){var disabled=!isCharacteristicEnabled(characteristics,index);var selected=getSelectedValue(_char3.id,characteristics);var values=_this2.buildValues(characteristics,_char3.id,_char3.values,index,selected,disabled);return _this2.props.render({charRef:_this2.refsStore[_char3.id],disabled:disabled,highlight:_this2.state.highlight===_char3.id,id:_char3.id,key:_char3.id,label:_char3.label,swatch:!!_char3.swatch,// BETA
|
|
25
|
+
select:_this2.handleSelection,selected:selected,values:values,resetHighlight:_this2.resetHighlight});}));}}]);return ProductCharacteristics;}(Component);_defineProperty(ProductCharacteristics,"defaultProps",{finishTimeout:0,variantId:null,variants:null,characteristics:null});export default connect(ProductCharacteristics);
|
|
@@ -2,4 +2,4 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
|
|
|
2
2
|
* The Product List component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var ProductList=function ProductList(_ref){var flags=_ref.flags,infiniteLoad=_ref.infiniteLoad,handleGetProducts=_ref.handleGetProducts,products=_ref.products,totalProductCount=_ref.totalProductCount,requestHash=_ref.requestHash;if(!infiniteLoad){return/*#__PURE__*/React.createElement(Layout,null,products.map(function(product){return/*#__PURE__*/React.createElement(Iterator,_extends({display:flags,id:product.id,key:product.id},product));}));}return/*#__PURE__*/React.createElement(ViewContext.Consumer,null,function(_ref2){var getContentRef=_ref2.getContentRef;return/*#__PURE__*/React.createElement(InfiniteContainer,{containerRef:getContentRef(),wrapper:Layout,iterator:Iterator,loader:handleGetProducts,items:products,loadingIndicator:/*#__PURE__*/React.createElement(LoadingIndicator,null),totalItems:totalProductCount,initialLimit:10,limit:ITEMS_PER_LOAD,requestHash:requestHash});});};ProductList.defaultProps={flags:null,handleGetProducts:function handleGetProducts(){},infiniteLoad:true,products:null,requestHash:null,totalProductCount:null};export default ProductList;
|
|
5
|
+
*/var ProductList=function ProductList(_ref){var flags=_ref.flags,infiniteLoad=_ref.infiniteLoad,handleGetProducts=_ref.handleGetProducts,products=_ref.products,totalProductCount=_ref.totalProductCount,requestHash=_ref.requestHash;if(!infiniteLoad){return/*#__PURE__*/React.createElement(Layout,null,products.map(function(product){return/*#__PURE__*/React.createElement(Iterator,_extends({display:flags,id:product.id,key:product.id},product));}));}return/*#__PURE__*/React.createElement(ViewContext.Consumer,null,function(_ref2){var getContentRef=_ref2.getContentRef;return/*#__PURE__*/React.createElement(InfiniteContainer,{containerRef:getContentRef(),wrapper:Layout,iterator:Iterator,loader:handleGetProducts,items:products,loadingIndicator:/*#__PURE__*/React.createElement(LoadingIndicator,null),totalItems:totalProductCount,initialLimit:10,limit:ITEMS_PER_LOAD,requestHash:requestHash,enablePromiseBasedLoading:true});});};ProductList.defaultProps={flags:null,handleGetProducts:function handleGetProducts(){},infiniteLoad:true,products:null,requestHash:null,totalProductCount:null};export default ProductList;
|
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
|
|
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);
|