@shopgate/engage 6.20.1 → 6.21.0-rc.2
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/favorites/components/Item/Item.js +2 -2
- package/favorites/components/List/List.js +2 -2
- package/package.json +7 -7
- package/product/components/ProductList/components/Iterator/index.js +2 -2
- package/product/components/ProductList/index.js +2 -2
- package/product/components/ProductSlider/index.js +2 -2
- package/product/components/ProductSlider/spec.js +1 -1
- package/product/hocs/withProductListEntry.js +11 -0
- package/product/hocs/withProductListType.js +11 -0
- package/product/hooks/useProductListEntry.js +5 -0
- package/product/hooks/useProductListType.js +5 -0
- package/product/index.js +4 -3
- package/product/providers/ProductListEntry/context.js +9 -0
- package/product/providers/ProductListEntry/index.js +11 -0
- package/product/providers/ProductListType/context.js +12 -0
- package/product/providers/ProductListType/index.js +14 -0
- package/reviews/components/Reviews/components/ReviewsInfo/index.js +5 -0
- package/reviews/components/Reviews/index.js +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useCallback,useMemo,useLayoutEffect,useState}from'react';import PropTypes from'prop-types';import{connect}from'react-redux';import{css}from'glamor';import classNames from'classnames';import{MODAL_VARIANT_SELECT}from'@shopgate/pwa-ui-shared/Dialog/constants';import{ProductImage,ITEM_PATH,isBaseProduct as isBaseProductSelector,isProductOrderable,hasProductVariants}from'@shopgate/engage/product';import{bin2hex,showModal as showModalAction,historyPush as historyPushAction,getThemeSettings,i18n}from'@shopgate/engage/core';import{Link,SurroundPortals}from'@shopgate/engage/components';import{FAVORITES_PRODUCT_NAME,FAVORITES_PRODUCT_PRICE,FAVORITES_ADD_TO_CART}from'@shopgate/engage/favorites';import AvailableText from'@shopgate/pwa-ui-shared/Availability';import Price from'@shopgate/pwa-ui-shared/Price';import PriceInfo from'@shopgate/pwa-ui-shared/PriceInfo';import PriceStriked from'@shopgate/pwa-ui-shared/PriceStriked';import AddToCart from'@shopgate/pwa-ui-shared/AddToCartButton';import Remove from"../RemoveButton";import ItemCharacteristics from"./ItemCharacteristics";import{FAVORITES_LIST_ITEM,FAVORITES_LIST_ITEM_ACTIONS,FAVORITES_AVAILABILITY_TEXT}from"../../constants/Portals";/**
|
|
1
|
+
function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useCallback,useMemo,useLayoutEffect,useState}from'react';import PropTypes from'prop-types';import{connect}from'react-redux';import{css}from'glamor';import classNames from'classnames';import{MODAL_VARIANT_SELECT}from'@shopgate/pwa-ui-shared/Dialog/constants';import{ProductImage,ITEM_PATH,isBaseProduct as isBaseProductSelector,isProductOrderable,hasProductVariants,ProductListEntryProvider}from'@shopgate/engage/product';import{bin2hex,showModal as showModalAction,historyPush as historyPushAction,getThemeSettings,i18n}from'@shopgate/engage/core';import{Link,SurroundPortals}from'@shopgate/engage/components';import{FAVORITES_PRODUCT_NAME,FAVORITES_PRODUCT_PRICE,FAVORITES_ADD_TO_CART}from'@shopgate/engage/favorites';import AvailableText from'@shopgate/pwa-ui-shared/Availability';import Price from'@shopgate/pwa-ui-shared/Price';import PriceInfo from'@shopgate/pwa-ui-shared/PriceInfo';import PriceStriked from'@shopgate/pwa-ui-shared/PriceStriked';import AddToCart from'@shopgate/pwa-ui-shared/AddToCartButton';import Remove from"../RemoveButton";import ItemCharacteristics from"./ItemCharacteristics";import{FAVORITES_LIST_ITEM,FAVORITES_LIST_ITEM_ACTIONS,FAVORITES_AVAILABILITY_TEXT}from"../../constants/Portals";/**
|
|
2
2
|
* The extended component props.
|
|
3
3
|
* @param {Object} state The current application state.
|
|
4
4
|
* @param {Object} props The current component props.
|
|
@@ -7,4 +7,4 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
|
|
|
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
|
|
10
|
-
showModal({title:null,type:MODAL_VARIANT_SELECT,message:'favorites.modal.message',confirm:'favorites.modal.confirm',dismiss:'common.cancel',params:{productId:product.id}});return false;}return addToCart(e);},[addToCart,hasVariants,isBaseProduct,product.id,showModal]);var commonPortalProps=useMemo(function(){var availability=product.availability,id=product.id,name=product.name;return{availability:availability,characteristics:characteristics,id:id,name:name,listId:listId};},[characteristics,listId,product]);var ctaPortalProps=useMemo(function(){return{isLoading:false,noShadow:false,listId:listId,isBaseProduct:isBaseProduct,isDisabled:isDisabled,productId:product.id,handleRemoveFromCart:remove,handleAddToCart:handleAddToCart};},[handleAddToCart,isBaseProduct,isDisabled,listId,product.id,remove]);var taxDisclaimer=false;var priceClassNames=classNames(styles.infoContainerRight,_defineProperty({},styles.infoContainerRightTaxDisclaimer,taxDisclaimer));return/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_LIST_ITEM,portalProps:product},/*#__PURE__*/React.createElement("div",{className:styles.root},/*#__PURE__*/React.createElement(Link,{className:styles.imageContainer,component:"div",href:productLink},/*#__PURE__*/React.createElement(ProductImage,{src:product.featuredImageBaseUrl,resolutions:gridResolutions})),/*#__PURE__*/React.createElement(Link,{className:styles.infoContainer,component:"div",href:productLink},/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_PRODUCT_NAME,portalProps:commonPortalProps},/*#__PURE__*/React.createElement("span",{className:styles.title},product.name)),/*#__PURE__*/React.createElement("div",{className:styles.innerInfoContainer},/*#__PURE__*/React.createElement("div",{className:styles.infoContainerLeft},/*#__PURE__*/React.createElement(ItemCharacteristics,{characteristics:characteristics}),/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_AVAILABILITY_TEXT,portalProps:commonPortalProps},/*#__PURE__*/React.createElement(AvailableText,{text:commonPortalProps.availability.text,state:commonPortalProps.availability.state,showWhenAvailable:true,className:styles.availability}))),/*#__PURE__*/React.createElement("div",{className:priceClassNames},/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_PRODUCT_PRICE,portalProps:commonPortalProps},hasStrikePrice?/*#__PURE__*/React.createElement(PriceStriked,{value:specialPrice,currency:currency}):null,/*#__PURE__*/React.createElement(Price,{currency:currency,discounted:hasStrikePrice,taxDisclaimer:taxDisclaimer,unitPrice:defaultPrice}),!!product.price.info&&/*#__PURE__*/React.createElement(PriceInfo,{text:product.price.info,className:styles.basePrice}))))),/*#__PURE__*/React.createElement("div",{className:styles.actions},/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_LIST_ITEM_ACTIONS,portalProps:ctaPortalProps},/*#__PURE__*/React.createElement(Remove,{onClick:remove}),/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_ADD_TO_CART,portalProps:ctaPortalProps},/*#__PURE__*/React.createElement(AddToCart,{onClick:handleAddToCart,isLoading:false,isDisabled:isDisabled,"aria-label":i18n.text('product.add_to_cart')}))))));};FavoriteItem.defaultProps={isBaseProduct:true,isOrderable:true,hasVariants:false};export default connect(mapStateToProps,mapDispatchToProps)(FavoriteItem);
|
|
10
|
+
showModal({title:null,type:MODAL_VARIANT_SELECT,message:'favorites.modal.message',confirm:'favorites.modal.confirm',dismiss:'common.cancel',params:{productId:product.id}});return false;}return addToCart(e);},[addToCart,hasVariants,isBaseProduct,product.id,showModal]);var commonPortalProps=useMemo(function(){var availability=product.availability,id=product.id,name=product.name;return{availability:availability,characteristics:characteristics,id:id,name:name,listId:listId};},[characteristics,listId,product]);var ctaPortalProps=useMemo(function(){return{isLoading:false,noShadow:false,listId:listId,isBaseProduct:isBaseProduct,isDisabled:isDisabled,productId:product.id,handleRemoveFromCart:remove,handleAddToCart:handleAddToCart};},[handleAddToCart,isBaseProduct,isDisabled,listId,product.id,remove]);var taxDisclaimer=false;var priceClassNames=classNames(styles.infoContainerRight,_defineProperty({},styles.infoContainerRightTaxDisclaimer,taxDisclaimer));return/*#__PURE__*/React.createElement(ProductListEntryProvider,{productId:product.id},/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_LIST_ITEM,portalProps:product},/*#__PURE__*/React.createElement("div",{className:styles.root},/*#__PURE__*/React.createElement(Link,{className:styles.imageContainer,component:"div",href:productLink},/*#__PURE__*/React.createElement(ProductImage,{src:product.featuredImageBaseUrl,resolutions:gridResolutions})),/*#__PURE__*/React.createElement(Link,{className:styles.infoContainer,component:"div",href:productLink},/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_PRODUCT_NAME,portalProps:commonPortalProps},/*#__PURE__*/React.createElement("span",{className:styles.title},product.name)),/*#__PURE__*/React.createElement("div",{className:styles.innerInfoContainer},/*#__PURE__*/React.createElement("div",{className:styles.infoContainerLeft},/*#__PURE__*/React.createElement(ItemCharacteristics,{characteristics:characteristics}),/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_AVAILABILITY_TEXT,portalProps:commonPortalProps},/*#__PURE__*/React.createElement(AvailableText,{text:commonPortalProps.availability.text,state:commonPortalProps.availability.state,showWhenAvailable:true,className:styles.availability}))),/*#__PURE__*/React.createElement("div",{className:priceClassNames},/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_PRODUCT_PRICE,portalProps:commonPortalProps},hasStrikePrice?/*#__PURE__*/React.createElement(PriceStriked,{value:specialPrice,currency:currency}):null,/*#__PURE__*/React.createElement(Price,{currency:currency,discounted:hasStrikePrice,taxDisclaimer:taxDisclaimer,unitPrice:defaultPrice}),!!product.price.info&&/*#__PURE__*/React.createElement(PriceInfo,{text:product.price.info,className:styles.basePrice}))))),/*#__PURE__*/React.createElement("div",{className:styles.actions},/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_LIST_ITEM_ACTIONS,portalProps:ctaPortalProps},/*#__PURE__*/React.createElement(Remove,{onClick:remove}),/*#__PURE__*/React.createElement(SurroundPortals,{portalName:FAVORITES_ADD_TO_CART,portalProps:ctaPortalProps},/*#__PURE__*/React.createElement(AddToCart,{onClick:handleAddToCart,isLoading:false,isDisabled:isDisabled,"aria-label":i18n.text('product.add_to_cart')})))))));};FavoriteItem.defaultProps={isBaseProduct:true,isOrderable:true,hasVariants:false};export default connect(mapStateToProps,mapDispatchToProps)(FavoriteItem);
|
|
@@ -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 _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import React,{Fragment,useCallback,useEffect,useState}from'react';import PropTypes from'prop-types';import{connect}from'react-redux';import{css}from'glamor';import{i18n,showModal}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()};/**
|
|
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 _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import React,{Fragment,useCallback,useEffect,useState}from'react';import PropTypes from'prop-types';import{connect}from'react-redux';import{css}from'glamor';import{i18n,showModal}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{ProductListTypeProvider}from'@shopgate/engage/product';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')))));};/**
|
|
@@ -8,7 +8,7 @@ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimi
|
|
|
8
8
|
* TODO find a way to indicate loading of the list. products are fetched via the ProductProvider,
|
|
9
9
|
* so there is not a reliable way to determine if product fetching is done, since we might not
|
|
10
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};/**
|
|
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,/*#__PURE__*/React.createElement(ProductListTypeProvider,{type:"favoritesList"},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};/**
|
|
12
12
|
* @param {Object} _ State
|
|
13
13
|
* @param {Object} props Props
|
|
14
14
|
* @returns {Object}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/engage",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.21.0-rc.2",
|
|
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.
|
|
19
|
-
"@shopgate/pwa-common-commerce": "6.
|
|
20
|
-
"@shopgate/pwa-core": "6.
|
|
21
|
-
"@shopgate/pwa-ui-ios": "6.
|
|
22
|
-
"@shopgate/pwa-ui-material": "6.
|
|
23
|
-
"@shopgate/pwa-ui-shared": "6.
|
|
18
|
+
"@shopgate/pwa-common": "6.21.0-rc.2",
|
|
19
|
+
"@shopgate/pwa-common-commerce": "6.21.0-rc.2",
|
|
20
|
+
"@shopgate/pwa-core": "6.21.0-rc.2",
|
|
21
|
+
"@shopgate/pwa-ui-ios": "6.21.0-rc.2",
|
|
22
|
+
"@shopgate/pwa-ui-material": "6.21.0-rc.2",
|
|
23
|
+
"@shopgate/pwa-ui-shared": "6.21.0-rc.2",
|
|
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
|
-
import React from'react';import PropTypes from'prop-types';import List from'@shopgate/pwa-common/components/List';import Portal from'@shopgate/pwa-common/components/Portal';import*as portals from'@shopgate/pwa-common-commerce/category/constants/Portals';import Item from"../Item";import styles from"./style";/**
|
|
1
|
+
import React from'react';import PropTypes from'prop-types';import List from'@shopgate/pwa-common/components/List';import Portal from'@shopgate/pwa-common/components/Portal';import*as portals from'@shopgate/pwa-common-commerce/category/constants/Portals';import{ProductListEntryProvider}from'@shopgate/engage/product';import Item from"../Item";import styles from"./style";/**
|
|
2
2
|
* The Product List Iterator component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @return {JSX}
|
|
5
|
-
*/var Iterator=function Iterator(props){return/*#__PURE__*/React.createElement(List.Item,{key:props.id,itemProp:"itemListElement",itemScope:true,itemType:"http://schema.org/ListItem",className:styles.item},/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_BEFORE,props:{productId:props.id}}),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM,props:{productId:props.id}},/*#__PURE__*/React.createElement(Item,{product:props,display:props.display})),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_AFTER,props:{productId:props.id}}));};Iterator.defaultProps={display:null};export default Iterator;
|
|
5
|
+
*/var Iterator=function Iterator(props){return/*#__PURE__*/React.createElement(List.Item,{key:props.id,itemProp:"itemListElement",itemScope:true,itemType:"http://schema.org/ListItem",className:styles.item},/*#__PURE__*/React.createElement(ProductListEntryProvider,{productId:props.id},/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_BEFORE,props:{productId:props.id}}),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM,props:{productId:props.id}},/*#__PURE__*/React.createElement(Item,{product:props,display:props.display})),/*#__PURE__*/React.createElement(Portal,{name:portals.PRODUCT_ITEM_AFTER,props:{productId:props.id}})));};Iterator.defaultProps={display:null};export default Iterator;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React from'react';import PropTypes from'prop-types';import{ITEMS_PER_LOAD}from'@shopgate/pwa-common/constants/DisplayOptions';import InfiniteContainer from'@shopgate/pwa-common/components/InfiniteContainer';import LoadingIndicator from'@shopgate/pwa-ui-shared/LoadingIndicator';import{ViewContext}from'@shopgate/engage/components/View';import Iterator from"./components/Iterator";import Layout from"./components/Layout";/**
|
|
1
|
+
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React from'react';import PropTypes from'prop-types';import{ProductListTypeProvider}from'@shopgate/engage/product';import{ITEMS_PER_LOAD}from'@shopgate/pwa-common/constants/DisplayOptions';import InfiniteContainer from'@shopgate/pwa-common/components/InfiniteContainer';import LoadingIndicator from'@shopgate/pwa-ui-shared/LoadingIndicator';import{ViewContext}from'@shopgate/engage/components/View';import Iterator from"./components/Iterator";import Layout from"./components/Layout";/**
|
|
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,enablePromiseBasedLoading:true});});};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,scope=_ref.scope;if(!infiniteLoad){return/*#__PURE__*/React.createElement(Layout,null,/*#__PURE__*/React.createElement(ProductListTypeProvider,{type:"productList",subType:scope},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(ProductListTypeProvider,{type:"productList",subType:scope},/*#__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,scope:null};export default ProductList;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from'react';import PropTypes from'prop-types';import{useWidgetSettings}from'@shopgate/engage/core';import{Swiper}from'@shopgate/engage/components';import{Theme}from'@shopgate/pwa-common/context';import{container,items}from"./style";export var WIDGET_ID='@shopgate/engage/product/ProductSlider';/**
|
|
1
|
+
import React from'react';import PropTypes from'prop-types';import{useWidgetSettings}from'@shopgate/engage/core';import{Swiper}from'@shopgate/engage/components';import{ProductListTypeProvider,ProductListEntryProvider}from'@shopgate/engage/product';import{Theme}from'@shopgate/pwa-common/context';import{container,items}from"./style";export var WIDGET_ID='@shopgate/engage/product/ProductSlider';/**
|
|
2
2
|
* @param {Object} props The component props.
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/function ProductSlider(props){var autoplay=props.autoplay,className=props.className,delay=props.delay,productIds=props.productIds,snap=props.snap;var widgetSettings=useWidgetSettings(WIDGET_ID)||{};var _ref=props.slidesPerView?props:widgetSettings,_ref$slidesPerView=_ref.slidesPerView,slidesPerView=_ref$slidesPerView===void 0?2.3:_ref$slidesPerView;return/*#__PURE__*/React.createElement(Theme,null,function(_ref2){var ProductCard=_ref2.ProductCard;var Item=props.item||ProductCard;return/*#__PURE__*/React.createElement(Swiper,{autoPlay:autoplay,className:"".concat(className," engage__product__product-slider"),controls:false,indicators:false,interval:delay,loop:false,freeMode:!snap,slidesPerView:slidesPerView},productIds.map(function(id){return/*#__PURE__*/React.createElement(Swiper.Item,{key:id,className:container},/*#__PURE__*/React.createElement(Item,{productId:id,style:items}));}));});}ProductSlider.defaultProps={autoplay:false,className:null,delay:10,item:null,slidesPerView:null,snap:false};export default ProductSlider;
|
|
4
|
+
*/function ProductSlider(props){var autoplay=props.autoplay,className=props.className,delay=props.delay,productIds=props.productIds,snap=props.snap,scope=props.scope;var widgetSettings=useWidgetSettings(WIDGET_ID)||{};var _ref=props.slidesPerView?props:widgetSettings,_ref$slidesPerView=_ref.slidesPerView,slidesPerView=_ref$slidesPerView===void 0?2.3:_ref$slidesPerView;return/*#__PURE__*/React.createElement(Theme,null,function(_ref2){var ProductCard=_ref2.ProductCard;var Item=props.item||ProductCard;return/*#__PURE__*/React.createElement(ProductListTypeProvider,{type:"productSlider",subType:scope},/*#__PURE__*/React.createElement(Swiper,{autoPlay:autoplay,className:"".concat(className," engage__product__product-slider"),controls:false,indicators:false,interval:delay,loop:false,freeMode:!snap,slidesPerView:slidesPerView},productIds.map(function(id){return/*#__PURE__*/React.createElement(Swiper.Item,{key:id,className:container},/*#__PURE__*/React.createElement(ProductListEntryProvider,{productId:id},/*#__PURE__*/React.createElement(Item,{productId:id,style:items})));})));});}ProductSlider.defaultProps={autoplay:false,className:null,delay:10,item:null,slidesPerView:null,snap:false,scope:null};export default ProductSlider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/* eslint-disable require-jsdoc */import React from'react';import{shallow}from'enzyme';import ProductSlider from"./index";jest.mock('@shopgate/engage/core',function(){return{useWidgetSettings:jest.fn()};});jest.mock('@shopgate/engage/components',function(){var Swiper=function Swiper(_ref){var children=_ref.children;return children;};Swiper.Item=function(_ref2){var children=_ref2.children;return children;};Swiper.Item.displayName='Swiper.Item';return{Swiper:Swiper};});jest.mock('@shopgate/pwa-common/context',function(){var ProductCard=function ProductCard(props){return/*#__PURE__*/React.createElement(ProductCard,props);};return{Theme:function Theme(
|
|
1
|
+
/* eslint-disable require-jsdoc */import React from'react';import{shallow}from'enzyme';import ProductSlider from"./index";jest.mock('@shopgate/engage/core',function(){return{useWidgetSettings:jest.fn()};});jest.mock('@shopgate/engage/components',function(){var Swiper=function Swiper(_ref){var children=_ref.children;return children;};Swiper.Item=function(_ref2){var children=_ref2.children;return children;};Swiper.Item.displayName='Swiper.Item';return{Swiper:Swiper};});jest.mock('@shopgate/engage/product',function(){return{ProductListTypeProvider:function ProductListTypeProvider(_ref3){var children=_ref3.children;return children;}};});jest.mock('@shopgate/pwa-common/context',function(){var ProductCard=function ProductCard(props){return/*#__PURE__*/React.createElement(ProductCard,props);};return{Theme:function Theme(_ref4){var children=_ref4.children;return children({ProductCard:ProductCard});}};});describe('<ProductSlider />',function(){it('should match snapshot',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(ProductSlider,{productIds:['prod1']})).dive();expect(wrapper).toMatchSnapshot();});});/* eslint-enable require-jsdoc */
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React from'react';import ProductListEntryContext from"../providers/ProductListEntry/context";/**
|
|
2
|
+
* Injects the ProductListEntryContext properties into the desired component. Properties will be
|
|
3
|
+
* accessible via the "productListEntry" prop.
|
|
4
|
+
*
|
|
5
|
+
* @param {Function} WrappedComponent The react component to wrap.
|
|
6
|
+
* @returns {JSX}
|
|
7
|
+
*/export default function withProductListEntry(WrappedComponent){/**
|
|
8
|
+
* The actual HOC.
|
|
9
|
+
* @param {Object} props The component props.
|
|
10
|
+
* @returns {JSX}
|
|
11
|
+
*/var WithApp=function WithApp(props){return/*#__PURE__*/React.createElement(ProductListEntryContext.Consumer,null,function(contextValue){return/*#__PURE__*/React.createElement(WrappedComponent,_extends({},props,{productListEntry:contextValue}));});};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithApp.displayName="WithProductListEntry(".concat(displayName,")");return WithApp;}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React from'react';import ProductListTypeContext from"../providers/ProductListType/context";/**
|
|
2
|
+
* Injects the ProductListTypeContext properties into the desired component. Properties will be
|
|
3
|
+
* accessible via the "productListType" prop.
|
|
4
|
+
*
|
|
5
|
+
* @param {Function} WrappedComponent The react component to wrap.
|
|
6
|
+
* @returns {JSX}
|
|
7
|
+
*/export default function withProductListType(WrappedComponent){/**
|
|
8
|
+
* The actual HOC.
|
|
9
|
+
* @param {Object} props The component props.
|
|
10
|
+
* @returns {JSX}
|
|
11
|
+
*/var WithApp=function WithApp(props){return/*#__PURE__*/React.createElement(ProductListTypeContext.Consumer,null,function(contextValue){return/*#__PURE__*/React.createElement(WrappedComponent,_extends({},props,{productListType:contextValue}));});};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithApp.displayName="WithProductListType(".concat(displayName,")");return WithApp;}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{useContext}from'react';import ProductListEntryContext,{// eslint-disable-next-line import/named, no-unused-vars
|
|
2
|
+
ProductListEntryContextValue}from"../providers/ProductListEntry/context";/**
|
|
3
|
+
* Provides the properties of the ProductListEntryContext.
|
|
4
|
+
* @returns {ProductListEntryContextValue}
|
|
5
|
+
*/export default function useProductListEntry(){var context=useContext(ProductListEntryContext);return context;}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{useContext}from'react';import ProductListTypeContext,{// eslint-disable-next-line import/named, no-unused-vars
|
|
2
|
+
ProductListTypeContextValue}from"../providers/ProductListType/context";/**
|
|
3
|
+
* Provides the properties of the ProductListTypeContext.
|
|
4
|
+
* @returns {ProductListTypeContextValue}
|
|
5
|
+
*/export default function useProductListType(){var context=useContext(ProductListTypeContext);return context;}
|
package/product/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export*from'@shopgate/pwa-common-commerce/product/helpers';export*from"./helpers
|
|
|
7
7
|
export*from'@shopgate/pwa-common-commerce/product/selectors/options';export*from'@shopgate/pwa-common-commerce/product/selectors/page';export*from'@shopgate/pwa-common-commerce/product/selectors/price';export*from'@shopgate/pwa-common-commerce/product/selectors/product';export*from'@shopgate/pwa-common-commerce/product/selectors/relations';export*from'@shopgate/pwa-common-commerce/product/selectors/variants';export*from"./selectors/media";export{makeGetProductProperties,makeGetProductEffectivityDates,makeGetProductCharacteristics,makeGetProductFeaturedMedia,makeIsProductActive,makeIsBaseProductActive}from"./selectors/product";export*from"./selectors/price";export*from"./selectors/variants";export*from"./selectors/relations";// STREAMS
|
|
8
8
|
export*from'@shopgate/pwa-common-commerce/product/streams';// COMPONENTS
|
|
9
9
|
export{default as ProductProperties}from"./components/ProductProperties/ProductProperties";export{default as MapPriceHint}from"./components/MapPriceHint";export{default as OrderQuantityHint}from"./components/OrderQuantityHint";export{default as ProductImage}from"./components/ProductImage";export{default as MediaSlider}from"./components/MediaSlider";export{default as QuantityPicker}from"./components/QuantityPicker";export{default as EffectivityDates}from"./components/EffectivityDates";export{default as PriceDifference}from"./components/PriceDifference";export{FeaturedMedia,MediaImage}from"./components/Media";export{VariantSwatch}from"./components/Swatch";export{Swatches}from"./components/Swatches";export{RelationsSlider}from"./components/RelationsSlider";export{default as ProductCard}from"./components/ProductCard";export{default as ProductGridPrice}from"./components/ProductGridPrice";export{default as ProductCharacteristics}from"./components/ProductCharacteristics";export{default as Description}from"./components/Description";export{default as ProductList}from"./components/ProductList";export{default as ProductSlider}from"./components/ProductSlider";export{default as Options}from"./components/Options";export{default as Characteristics}from"./components/Characteristics";export{default as Rating}from"./components/Rating";export{default as ProductProvider}from"./components/ProductProvider";export{default as ProductBadges}from"./components/ProductBadges";// HOCs
|
|
10
|
-
export{default as withPriceCalculation}from"./hocs/withPriceCalculation";export{default as withProductStock}from"./hocs/withProductStock";// HOOKs
|
|
11
|
-
export{useLoadProductImage}from"./hooks/useLoadProductImage";// CONTEXTS
|
|
12
|
-
export{default as VariantContext}from"./components/ProductCharacteristics/context";export{ProductContext}from"./components/context";export{
|
|
10
|
+
export{default as withPriceCalculation}from"./hocs/withPriceCalculation";export{default as withProductStock}from"./hocs/withProductStock";export{default as withProductListType}from"./hocs/withProductListType";export{default as withProductListEntry}from"./hocs/withProductListEntry";// HOOKs
|
|
11
|
+
export{useLoadProductImage}from"./hooks/useLoadProductImage";export{default as useProductListType}from"./hooks/useProductListType";export{default as useProductListEntry}from"./hooks/useProductListEntry";// CONTEXTS
|
|
12
|
+
export{default as VariantContext}from"./components/ProductCharacteristics/context";export{ProductContext}from"./components/context";export{default as ProductListTypeContext}from"./providers/ProductListType/context";export{default as ProductListEntryContext}from"./providers/ProductListEntry/context";// PROVIDERS
|
|
13
|
+
export{default as ProductListTypeProvider}from"./providers/ProductListType";export{default as ProductListEntryProvider}from"./providers/ProductListEntry";export{ProductUnitQuantityPicker,UnitQuantityPicker}from"./components/UnitQuantityPicker";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from'react';/* eslint-disable import/named, no-unused-vars */import{ProductListTypeContextType,ProductListTypeContextSubType}from"../ProductListType/context";/* eslint-enable import/named, no-unused-vars */ /**
|
|
2
|
+
* @typedef ProductListEntryContextValue
|
|
3
|
+
* @property {string} productId A product identifier.
|
|
4
|
+
* @property {ProductListTypeContextType} [productListType=null] Type of the active
|
|
5
|
+
* ProductListTypeContext e.g. "productSlider" or "productGrid".
|
|
6
|
+
* @property {ProductListTypeContextSubType} [productListSubType=null] Optional sub type of the
|
|
7
|
+
* active ProductListTypeContext. Depending on its usage it can make a statement about in which
|
|
8
|
+
* context the product list is used e.g. "widgets".
|
|
9
|
+
*/export{};export default/*#__PURE__*/React.createContext({productListType:null,productListSubType:null,productId:null});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React,{useMemo}from'react';import PropTypes from'prop-types';import useProductListType from"../../hooks/useProductListType";import Context from"./context";/**
|
|
2
|
+
* The ProductListEntryProvider is usually wrapped around components that render products and
|
|
3
|
+
* provides basic information about them.
|
|
4
|
+
*
|
|
5
|
+
* Context values can be accessed via the `useProductListEntry` hook, or injected into a class
|
|
6
|
+
* component via the `withProductListEntry` HOC. Both can be imported via `@shopgate/engage/product`
|
|
7
|
+
*
|
|
8
|
+
* @param {Object} param The component props
|
|
9
|
+
* @param {string} param.productId Product identifier.
|
|
10
|
+
* @returns {JSX}
|
|
11
|
+
*/function ProductListEntryProvider(_ref){var children=_ref.children,productId=_ref.productId;var _useProductListType=useProductListType(),type=_useProductListType.type,subType=_useProductListType.subType;var value=useMemo(function(){return{productListType:type,productListSubType:subType,productId:productId};},[productId,subType,type]);return/*#__PURE__*/React.createElement(Context.Provider,{value:value},children);}ProductListEntryProvider.defaultProps={children:null};export default ProductListEntryProvider;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from'react';/* eslint-disable max-len */ /**
|
|
2
|
+
* @typedef {"productSlider"|"productGrid"|"productList"|"favoritesList"|"cart"|"liveshopping"|"pdp"|"productGallery"} ProductListTypeContextType
|
|
3
|
+
*/export{};/**
|
|
4
|
+
* @typedef {"widgets"|"category"} ProductListTypeContextSubType
|
|
5
|
+
*/export{};/* eslint-enable max-len */ /**
|
|
6
|
+
* @typedef ProductListTypeContextValue
|
|
7
|
+
* @property {ProductListTypeContextType} [type=null] Type of the active ProductListTypeContext
|
|
8
|
+
* e.g. "productSlider" or "productGrid".
|
|
9
|
+
* @property {ProductListTypeContextSubType} [subType=null] Optional sub type of the active
|
|
10
|
+
* ProductListTypeContext. Depending on its usage it can make a statement about in which context
|
|
11
|
+
* the product list is used e.g. "widgets".
|
|
12
|
+
*/export{};export default/*#__PURE__*/React.createContext({type:null,subType:null});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React,{useMemo}from'react';import PropTypes from'prop-types';import Context from"./context";/**
|
|
2
|
+
* The ProductListTypeProvider is usually wrapped around components that render product lists.
|
|
3
|
+
* It provides information about the type / purpose of those product lists which can be used
|
|
4
|
+
* by child components or extensions to determine how they are supposed to render their content.
|
|
5
|
+
*
|
|
6
|
+
* Context values can be accessed via the `useProductListType` hook, or injected into a class
|
|
7
|
+
* component via the `withProductListType` HOC. Both can be imported from `@shopgate/engage/product`
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} param The component props
|
|
10
|
+
* @param {string} param.type Type of the context e.g. "productSlider" or "productGrid".
|
|
11
|
+
* @param {string} param.subType Optional sub type of the context. Depending on its usage it can
|
|
12
|
+
* make a statement about in which context the product list is used e.g. "widgets".
|
|
13
|
+
* @returns {JSX}
|
|
14
|
+
*/function ProductListTypeProvider(_ref){var children=_ref.children,type=_ref.type,subType=_ref.subType;var value=useMemo(function(){return{type:type,subType:subType};},[subType,type]);return/*#__PURE__*/React.createElement(Context.Provider,{value:value},children);}ProductListTypeProvider.defaultProps={children:null,subType:null};export default ProductListTypeProvider;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from'react';import{css}from'glamor';import classNames from'classnames';import appConfig from'@shopgate/pwa-common/helpers/config';import{Link}from'@shopgate/engage/components';var styles={root:css({textAlign:'center',marginTop:8,fontSize:'.875rem',fontWeight:300,lineHeight:1.5,padding:'0 1rem 1rem'}).toString(),link:css({textAlign:'center',fontWeight:600,marginTop:8}).toString()};var _appConfig$reviewsInf=appConfig.reviewsInfo;_appConfig$reviewsInf=_appConfig$reviewsInf===void 0?{}:_appConfig$reviewsInf;var text=_appConfig$reviewsInf.text,linkText=_appConfig$reviewsInf.linkText,linkUrl=_appConfig$reviewsInf.linkUrl;/**
|
|
2
|
+
* The ReviewsInfo component
|
|
3
|
+
* @param {Object} props The component props
|
|
4
|
+
* @returns {JSX}
|
|
5
|
+
*/var ReviewsInfo=function ReviewsInfo(){if(!text){return null;}return/*#__PURE__*/React.createElement("div",{className:classNames(styles.root,'engage__reviews__review_info_text')},/*#__PURE__*/React.createElement("div",null,text,linkText&&linkUrl&&/*#__PURE__*/React.createElement(Link,{href:linkUrl,className:styles.link},linkText)));};export default ReviewsInfo;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from'react';import PropTypes from'prop-types';import appConfig from'@shopgate/pwa-common/helpers/config';import{SurroundPortals}from'@shopgate/engage/components';import{PRODUCT_REVIEWS}from'@shopgate/engage/product';import List from"./components/List";import Header from"./components/Header";import AllReviewsLink from"./components/AllReviewsLink";import styles from"./style";import connect from"./connector";/**
|
|
1
|
+
import React from'react';import PropTypes from'prop-types';import appConfig from'@shopgate/pwa-common/helpers/config';import{SurroundPortals}from'@shopgate/engage/components';import{PRODUCT_REVIEWS}from'@shopgate/engage/product';import List from"./components/List";import Header from"./components/Header";import AllReviewsLink from"./components/AllReviewsLink";import ReviewsInfo from"./components/ReviewsInfo";import styles from"./style";import connect from"./connector";/**
|
|
2
2
|
* @param {Object} props The component props.
|
|
3
3
|
* @param {Object} props.productId The id of the product, the review belongs to.
|
|
4
4
|
* @param {Array} props.reviews Reviews which should be shown in the product page.
|
|
5
5
|
* @returns {JSX}
|
|
6
|
-
*/function Reviews(_ref){var productId=_ref.productId,reviews=_ref.reviews;return/*#__PURE__*/React.createElement(SurroundPortals,{portalName:PRODUCT_REVIEWS,portalProps:{productId:productId}},appConfig.hasReviews&&/*#__PURE__*/React.createElement("div",{className:"".concat(styles.container," engage__reviews__reviews"),"data-test-id":"reviewSection"},/*#__PURE__*/React.createElement(Header,{productId:productId}),/*#__PURE__*/React.createElement(List,{productId:productId,reviews:reviews}),/*#__PURE__*/React.createElement(AllReviewsLink,{productId:productId})));}Reviews.defaultProps={productId:null,reviews:null};export default connect(Reviews);
|
|
6
|
+
*/function Reviews(_ref){var productId=_ref.productId,reviews=_ref.reviews;return/*#__PURE__*/React.createElement(SurroundPortals,{portalName:PRODUCT_REVIEWS,portalProps:{productId:productId}},appConfig.hasReviews&&/*#__PURE__*/React.createElement("div",{className:"".concat(styles.container," engage__reviews__reviews"),"data-test-id":"reviewSection"},/*#__PURE__*/React.createElement(Header,{productId:productId}),/*#__PURE__*/React.createElement(List,{productId:productId,reviews:reviews}),/*#__PURE__*/React.createElement(AllReviewsLink,{productId:productId}),/*#__PURE__*/React.createElement(ReviewsInfo,null)));}Reviews.defaultProps={productId:null,reviews:null};export default connect(Reviews);
|