@shopgate/engage 6.22.0-beta.12 → 6.22.0-beta.14

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.
@@ -10,5 +10,5 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
10
10
  * @param {Function} props.addBackInStockSubscription Add product to back in stock list
11
11
  * @param {Function} props.grantPushPermissions Request / Set push permission
12
12
  * @return {JSX.Element}
13
- */var BackInStockButton=function BackInStockButton(_ref){var productId=_ref.productId,_ref$isLinkToBackInSt=_ref.isLinkToBackInStockEnabled,isLinkToBackInStockEnabled=_ref$isLinkToBackInSt===void 0?false:_ref$isLinkToBackInSt,subscription=_ref.subscription,_ref$stopPropagation=_ref.stopPropagation,stopPropagation=_ref$stopPropagation===void 0?false:_ref$stopPropagation,addBackInStockSubscription=_ref.addBackInStockSubscription,grantPushPermissions=_ref.grantPushPermissions,alignRight=_ref.alignRight,showAsButton=_ref.showAsButton;var handleClick=useCallback(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(event){var allowed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:if(stopPropagation){event.stopPropagation();}_context.next=3;return grantPushPermissions({useRationaleModal:true,useSettingsModal:true,rationaleModal:{message:'back_in_stock.rationale.message',confirm:'back_in_stock.rationale.confirm',dismiss:'common.cancel'}});case 3:allowed=_context.sent;if(allowed){addBackInStockSubscription({productId:productId});}case 5:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}(),[addBackInStockSubscription,grantPushPermissions,productId,stopPropagation]);if((subscription===null||subscription===void 0?void 0:subscription.status)==='active'){return/*#__PURE__*/React.createElement(Link,{href:BACK_IN_STOCK_PATTERN,disabled:!isLinkToBackInStockEnabled,className:classNames(styles.backInStockMessageContainer,_defineProperty({},styles.rightAligned,alignRight)),tag:"span"},/*#__PURE__*/React.createElement(CheckedIcon,{color:colors.success,className:styles.icon}),/*#__PURE__*/React.createElement("span",{className:styles.backInStockMessage},i18n.text('back_in_stock.we_will_remind_you')));}if(showAsButton){return/*#__PURE__*/React.createElement(Button,{type:"primary",tabIndex:0,onClick:handleClick,className:styles.button},/*#__PURE__*/React.createElement("span",{className:styles.buttonText},i18n.text('back_in_stock.get_notified')));}return/*#__PURE__*/ (// eslint-disable-next-line jsx-a11y/anchor-is-valid,jsx-a11y/click-events-have-key-events
13
+ */var BackInStockButton=function BackInStockButton(_ref){var productId=_ref.productId,_ref$isLinkToBackInSt=_ref.isLinkToBackInStockEnabled,isLinkToBackInStockEnabled=_ref$isLinkToBackInSt===void 0?false:_ref$isLinkToBackInSt,subscription=_ref.subscription,_ref$stopPropagation=_ref.stopPropagation,stopPropagation=_ref$stopPropagation===void 0?false:_ref$stopPropagation,addBackInStockSubscription=_ref.addBackInStockSubscription,grantPushPermissions=_ref.grantPushPermissions,alignRight=_ref.alignRight,showAsButton=_ref.showAsButton;var handleClick=useCallback(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(event){var allowed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:if(stopPropagation){event.stopPropagation();}_context.next=3;return grantPushPermissions({useRationaleModal:true,useSettingsModal:true,rationaleModal:{message:'back_in_stock.rationale.message',confirm:'back_in_stock.rationale.confirm',dismiss:'common.cancel'}});case 3:allowed=_context.sent;if(allowed){addBackInStockSubscription({productId:productId});}case 5:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}(),[addBackInStockSubscription,grantPushPermissions,productId,stopPropagation]);if((subscription===null||subscription===void 0?void 0:subscription.status)==='active'){return/*#__PURE__*/React.createElement(Link,{href:BACK_IN_STOCK_PATTERN,disabled:!isLinkToBackInStockEnabled,className:classNames(styles.backInStockMessageContainer,_defineProperty({},styles.rightAligned,alignRight)),tag:"span"},/*#__PURE__*/React.createElement(CheckedIcon,{color:colors.success,className:alignRight?styles.icon:classNames(styles.iconCentered,styles.icon)}),/*#__PURE__*/React.createElement("span",{className:styles.backInStockMessage},i18n.text('back_in_stock.we_will_remind_you')));}if(showAsButton){return/*#__PURE__*/React.createElement(Button,{type:"primary",tabIndex:0,onClick:handleClick,className:styles.button},/*#__PURE__*/React.createElement("span",{className:styles.buttonText},i18n.text('back_in_stock.get_notified')));}return/*#__PURE__*/ (// eslint-disable-next-line jsx-a11y/anchor-is-valid,jsx-a11y/click-events-have-key-events
14
14
  React.createElement("a",{role:"button",tabIndex:0,onClick:handleClick,className:classNames(styles.button,_defineProperty({},styles.rightAligned,alignRight))},/*#__PURE__*/React.createElement(NotificationIcon,{color:colors.primary,className:styles.icon}),/*#__PURE__*/React.createElement("span",{className:styles.buttonText},i18n.text('back_in_stock.get_notified'))));};BackInStockButton.defaultProps={stopPropagation:false,isLinkToBackInStockEnabled:false,showAsButton:false,alignRight:false,subscription:null,productId:null};export default connect(BackInStockButton);
@@ -1 +1 @@
1
- import{css}from'glamor';import{themeConfig}from'@shopgate/engage';export default{button:css({lineHeight:'16.5px',color:themeConfig.colors.warning,width:'100%'}).toString(),buttonContent:css({display:'flex',alignItems:'center'}).toString(),backInStockMessageContainer:css({lineHeight:'16.5px',display:'flex',alignItems:'center',width:'auto'}).toString(),rightAligned:css({display:'inline-block',textAlign:'right'}).toString(),backInStockMessage:css({verticalAlign:'middle',fontSize:'0.875rem'}).toString(),buttonText:css({fontSize:'0.875rem'}).toString(),icon:css({marginRight:4,marginTop:-1,verticalAlign:'middle',flexShrink:0,alignSelf:'flex-start',display:'inline-flex'}).toString()};
1
+ import{css}from'glamor';import{themeConfig}from'@shopgate/engage';export default{button:css({lineHeight:'16.5px',color:themeConfig.colors.warning,width:'100%'}).toString(),buttonContent:css({display:'flex',alignItems:'center'}).toString(),backInStockMessageContainer:css({lineHeight:'16.5px',display:'flex',alignItems:'center',width:'auto'}).toString(),rightAligned:css({display:'inline-block',textAlign:'right'}).toString(),backInStockMessage:css({verticalAlign:'middle',fontSize:'0.875rem'}).toString(),buttonText:css({fontSize:'0.875rem'}).toString(),icon:css({marginRight:4,marginTop:-1,verticalAlign:'middle',flexShrink:0,alignSelf:'flex-start',display:'inline-flex'}).toString(),iconCentered:css({alignSelf:'center',marginLeft:'-2px',marginRight:'8px'}).toString()};
@@ -1,7 +1,7 @@
1
- import React from'react';import PropTypes from'prop-types';import{bin2hex}from'@shopgate/pwa-common/helpers/data';import{CATEGORY_PATH}from'@shopgate/pwa-common-commerce/category/constants';import Portal from'@shopgate/pwa-common/components/Portal';import{Placeholder}from'@shopgate/pwa-ui-shared';import{CATEGORY_ITEM}from'@shopgate/pwa-common-commerce/category/constants/Portals';import{SheetList}from"../../../components";import styles from"./style";/**
1
+ import React from'react';import PropTypes from'prop-types';import{bin2hex}from'@shopgate/pwa-common/helpers/data';import{CATEGORY_PATH}from'@shopgate/pwa-common-commerce/category/constants';import Portal from'@shopgate/pwa-common/components/Portal';import{Placeholder}from'@shopgate/pwa-ui-shared';import{CATEGORY_ITEM}from'@shopgate/pwa-common-commerce/category/constants/Portals';import{i18n}from'@shopgate/engage/core';import{getShowAllProductsFilters}from'@shopgate/engage/category';import{SheetList}from"../../../components";import styles from"./style";/**
2
2
  * The CategoryList component.
3
3
  * @param {Object} props The component props.
4
4
  * @param {Array} props.categories The categories to display.
5
5
  * @param {Array} props.categories The number of rows to prerender.
6
6
  * @returns {JSX}
7
- */var CategoryList=function CategoryList(_ref){var categories=_ref.categories,prerender=_ref.prerender;if(!categories||!categories.length){if(prerender===0){return null;}return/*#__PURE__*/React.createElement(SheetList,{className:"".concat(styles," engage__category__category-list")},[].concat(Array(prerender)).map(function(val,index){var key="placeholder-".concat(index);return/*#__PURE__*/React.createElement(Placeholder,{height:20,key:key,left:0,top:18,width:220});}));}return/*#__PURE__*/React.createElement(SheetList,{className:"".concat(styles," engage__category__category-list")},categories.map(function(category){return/*#__PURE__*/React.createElement(Portal,{key:category.id,name:CATEGORY_ITEM,props:{categoryId:category.id}},/*#__PURE__*/React.createElement(SheetList.Item,{link:"".concat(CATEGORY_PATH,"/").concat(bin2hex(category.id)),title:category.name,linkState:{categoryId:category.id,title:category.name},testId:category.name}));}));};CategoryList.defaultProps={categories:null,prerender:0};export default CategoryList;
7
+ */var CategoryList=function CategoryList(_ref){var categories=_ref.categories,parentCategory=_ref.parentCategory,prerender=_ref.prerender,showAllProducts=_ref.showAllProducts;if(!categories||!categories.length){if(prerender===0){return null;}return/*#__PURE__*/React.createElement(SheetList,{className:"".concat(styles," engage__category__category-list")},[].concat(Array(prerender)).map(function(val,index){var key="placeholder-".concat(index);return/*#__PURE__*/React.createElement(Placeholder,{height:20,key:key,left:0,top:18,width:220});}));}var filters=getShowAllProductsFilters(parentCategory);return/*#__PURE__*/React.createElement(SheetList,{className:"".concat(styles.sheet," engage__category__category-list")},showAllProducts?/*#__PURE__*/React.createElement("div",{className:"".concat(styles.showAllProducts," engage__category__category-show-all-products")},/*#__PURE__*/React.createElement(Portal,{key:parentCategory.id,name:"category.show-all-products",props:{categoryId:parentCategory.id}},/*#__PURE__*/React.createElement(SheetList.Item,{link:"".concat(CATEGORY_PATH,"/").concat(bin2hex(parentCategory.id),"/all"),title:i18n.text('category.showAllProducts.label'),linkState:{categoryName:parentCategory.name,categoryId:parentCategory.id,filters:filters},testId:"showAllProducts"}))):null,categories.map(function(category){return/*#__PURE__*/React.createElement(Portal,{key:category.id,name:CATEGORY_ITEM,props:{categoryId:category.id}},/*#__PURE__*/React.createElement(SheetList.Item,{link:"".concat(CATEGORY_PATH,"/").concat(bin2hex(category.id)),title:category.name,linkState:{categoryId:category.id,title:category.name},testId:category.name}));}));};CategoryList.defaultProps={categories:null,parentCategory:null,prerender:0,showAllProducts:false};export default CategoryList;
@@ -1 +1 @@
1
- import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var colors=themeConfig.colors;export default css({background:colors.light});
1
+ import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var colors=themeConfig.colors;var sheet=css({background:colors.light}).toString();var showAllProducts=css({fontWeight:800}).toString();export default{sheet:sheet,showAllProducts:showAllProducts};
@@ -0,0 +1,9 @@
1
+ var _excluded=["useForFetchFilters"],_excluded2=["useForFetchFilters"];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 _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import isPlainObject from'lodash/isPlainObject';/**
2
+ * Creates the filter params to be used with a fetchFilters request.
3
+ * @param {Object} filters All configured filters
4
+ * @return {Object}
5
+ */var buildFilterParamsForFetchFiltersRequest=function buildFilterParamsForFetchFiltersRequest(){var filters=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(!isPlainObject(filters)){return null;}var sanitizedFilters=Object.keys(filters).reduce(function(acc,filterId){var filter=filters[filterId];if(filter!==null&&filter!==void 0&&filter.useForFetchFilters){// flag is set on filter level - remove flag and add to the result object
6
+ var useForFetchFilters=filter.useForFetchFilters,sanitizedFilter=_objectWithoutProperties(filter,_excluded);acc[filterId]=sanitizedFilter;}else if(Array.isArray(filter.value)){// check for flags on value level
7
+ var _sanitizedFilter=_extends({},filter,{value:filter.value.reduce(function(valueAcc,currentValue){var useForFetchFilters=currentValue.useForFetchFilters,sanitizedValue=_objectWithoutProperties(currentValue,_excluded2);if(currentValue!==null&&currentValue!==void 0&&currentValue.useForFetchFilters){// flag is set on value level - consider value for the results object
8
+ valueAcc.push(sanitizedValue);}return valueAcc;},[])});if(_sanitizedFilter.value.length){// only add the filter when it has values that are supposed to be used for a filter request
9
+ acc[filterId]=_sanitizedFilter;}}return acc;},{});return Object.keys(sanitizedFilters).length?sanitizedFilters:null;};export default buildFilterParamsForFetchFiltersRequest;
package/filter/index.js CHANGED
@@ -4,4 +4,4 @@ export*from'@shopgate/pwa-common-commerce/filter/constants/index';export*from'@s
4
4
  export*from'@shopgate/pwa-common-commerce/filter/selectors';// STREAMS
5
5
  export*from'@shopgate/pwa-common-commerce/filter/streams';// COMPONENTS
6
6
  export{default as FilterItem}from"./components/FilterItem";export{default as PriceSlider}from"./components/PriceSlider";// HELPERS
7
- export{default as buildInitialFilters}from"./helpers/buildInitialFilters";export{default as buildUpdatedFilters}from"./helpers/buildUpdatedFilters";export{translateFilterLabel}from"./helpers/translateFilterLabel";
7
+ export{default as buildInitialFilters}from"./helpers/buildInitialFilters";export{default as buildUpdatedFilters}from"./helpers/buildUpdatedFilters";export{default as buildFilterParamsForFetchFiltersRequest}from"./helpers/buildFilterParamsForFetchFiltersRequest";export{translateFilterLabel}from"./helpers/translateFilterLabel";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/engage",
3
- "version": "6.22.0-beta.12",
3
+ "version": "6.22.0-beta.14",
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.22.0-beta.12",
19
- "@shopgate/pwa-common-commerce": "6.22.0-beta.12",
20
- "@shopgate/pwa-core": "6.22.0-beta.12",
21
- "@shopgate/pwa-ui-ios": "6.22.0-beta.12",
22
- "@shopgate/pwa-ui-material": "6.22.0-beta.12",
23
- "@shopgate/pwa-ui-shared": "6.22.0-beta.12",
18
+ "@shopgate/pwa-common": "6.22.0-beta.14",
19
+ "@shopgate/pwa-common-commerce": "6.22.0-beta.14",
20
+ "@shopgate/pwa-core": "6.22.0-beta.14",
21
+ "@shopgate/pwa-ui-ios": "6.22.0-beta.14",
22
+ "@shopgate/pwa-ui-material": "6.22.0-beta.14",
23
+ "@shopgate/pwa-ui-shared": "6.22.0-beta.14",
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",