@shopgate/engage 7.20.0-beta.2 → 7.20.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/account/reducers/index.js +2 -2
  2. package/cart/cart.helpers.js +8 -1
  3. package/cart/index.js +2 -1
  4. package/cart/streams/index.js +1 -0
  5. package/checkout/constants/index.js +1 -1
  6. package/checkout/index.js +2 -2
  7. package/components/ConditionalWrapper/ConditionalWrapper.js +7 -2
  8. package/components/QuantityInput/QuantityInput.js +1 -1
  9. package/core/constants/index.js +1 -1
  10. package/core/helpers/appFeatures.js +2 -1
  11. package/core/helpers/i18n.js +1 -1
  12. package/core/helpers/index.js +1 -1
  13. package/core/subscriptions/app.js +2 -2
  14. package/favorites/components/List/List.js +17 -6
  15. package/favorites/components/List/ListAccordionLabel.js +4 -0
  16. package/favorites/components/List/ListContent.js +8 -0
  17. package/favorites/components/List/ListItemWrapper.js +6 -0
  18. package/favorites/components/List/styles.js +1 -0
  19. package/favorites/components/Lists/Lists.js +4 -4
  20. package/favorites/components/Lists/ListsModal.js +3 -2
  21. package/favorites/constants/index.js +1 -0
  22. package/filter/actions/index.js +1 -0
  23. package/filter/components/index.js +1 -0
  24. package/filter/constants/index.js +1 -1
  25. package/filter/helpers/buildInitialFilters.js +1 -1
  26. package/filter/helpers/translateFilterLabel.js +3 -3
  27. package/filter/index.js +2 -7
  28. package/filter/selectors/index.js +1 -1
  29. package/filter/streams/index.js +1 -0
  30. package/locations/subscriptions.js +2 -2
  31. package/package.json +7 -7
  32. package/page/selectors/index.js +7 -1
  33. package/product/components/ProductSlider/index.js +1 -1
  34. package/product/components/QuantityPicker/hooks.js +5 -0
  35. package/product/components/QuantityPicker/index.js +2 -2
  36. package/product/components/UnitQuantityPicker/CartUnitQuantityPicker.js +2 -2
  37. package/product/components/UnitQuantityPicker/ProductUnitQuantityPicker.js +3 -2
  38. package/product/components/UnitQuantityPicker/UnitQuantityPicker.js +6 -3
  39. package/product/components/UnitQuantityPicker/UnitQuantityPickerWithSection.js +7 -0
  40. package/product/components/UnitQuantityPicker/index.js +1 -1
  41. package/product/components/index.js +1 -1
  42. package/product/providers/ProductListType/context.js +2 -1
  43. package/product/providers/ProductListType/index.js +2 -1
  44. package/product/providers/index.js +1 -1
  45. package/push-opt-in/components/PushOptInModal/index.js +5 -6
  46. package/push-opt-in/subscriptions/optInTrigger.js +3 -5
  47. package/tracking/action-creators/cookieConsent.js +24 -0
  48. package/tracking/action-creators/index.js +1 -4
  49. package/tracking/actions/cookieConsent.js +21 -0
  50. package/tracking/actions/index.js +1 -0
  51. package/tracking/components/CookieConsentModal/connector.js +6 -0
  52. package/tracking/components/CookieConsentModal/index.js +9 -0
  53. package/tracking/components/CookieConsentModal/style.js +1 -0
  54. package/tracking/components/CookieConsentModal/tracking-opt-in.svg +18 -0
  55. package/tracking/components/PrivacySettings/connector.js +6 -0
  56. package/tracking/components/PrivacySettings/index.js +4 -0
  57. package/tracking/components/PrivacySettings/style.js +1 -0
  58. package/tracking/components/index.js +1 -1
  59. package/tracking/constants/index.js +0 -1
  60. package/tracking/reducers/cookieConsentModal.js +6 -0
  61. package/tracking/reducers/cookieSettings.js +6 -0
  62. package/tracking/reducers/index.js +1 -0
  63. package/tracking/selectors/cookieConsent.js +35 -0
  64. package/tracking/selectors/index.js +1 -4
  65. package/tracking/streams/cookieConsent.js +46 -0
  66. package/tracking/streams/index.js +1 -1
  67. package/tracking/subscriptions/analytics.js +11 -0
  68. package/tracking/subscriptions/cookieConsent.js +13 -0
  69. package/tracking/subscriptions/index.js +1 -4
  70. package/product/components/QuantityPicker/helpers.js +0 -5
  71. package/tracking/components/CookieConsent/CookieConsent.connector.js +0 -4
  72. package/tracking/components/CookieConsent/CookieConsent.js +0 -4
  73. package/tracking/components/CookieConsent/CookieConsentButtons.js +0 -3
  74. package/tracking/components/CookieConsent/CookieConsentCheckboxes.js +0 -3
  75. package/tracking/components/CookieConsent/CookieConsentContent.js +0 -4
  76. package/tracking/components/CookieConsent/CookieConsentMessage.js +0 -4
  77. package/tracking/components/CookieConsent/index.js +0 -1
  78. package/tracking/helpers/index.js +0 -7
  79. package/tracking/hooks/index.js +0 -4
  80. package/tracking/index.js +0 -1
  81. package/tracking/providers/CookieConsentProvider.connector.js +0 -4
  82. package/tracking/providers/CookieConsentProvider.context.js +0 -1
  83. package/tracking/providers/CookieConsentProvider.js +0 -8
  84. /package/product/{components/ProductProvider → providers/Product}/connector.js +0 -0
  85. /package/product/{components/ProductProvider → providers/Product}/index.js +0 -0
@@ -1,9 +1,12 @@
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)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useCallback,useEffect,useState,useRef}from'react';import PropTypes from'prop-types';import{i18n,UIEvents}from'@shopgate/engage/core';import{css}from'glamor';import classNames from'classnames';import{themeConfig}from'@shopgate/engage';import{RippleButton,QuantityInput}from'@shopgate/engage/components';import{broadcastLiveMessage}from'@shopgate/engage/a11y';var variables=themeConfig.variables,colors=themeConfig.colors;var styles={root:css({display:'flex',flexDirection:'row',position:'relative',zIndex:5}).toString(),backdrop:css({zIndex:4,top:0,left:0,height:'100%',width:'100%',position:'fixed'}),input:css({padding:"0 ".concat(variables.gap.small,"px"),textAlign:'center',flex:1,fontSize:15,height:28,width:'100%',backgroundColor:"var(--color-background-accent, ".concat(colors.shade8,")")}).toString(),inputWrapper:css({width:'100%'}),button:css({width:28,' &&':{minWidth:28,padding:0},height:28}).toString(),buttonRipple:css({padding:0}).toString(),buttonNoRadiusLeft:css({' &&':{borderTopLeftRadius:0,borderBottomLeftRadius:0}}).toString(),buttonNoRadiusRight:css({' &&':{borderTopRightRadius:0,borderBottomRightRadius:0}}).toString(),disabled:css({' > div':{padding:0}}).toString()};/**
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)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _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,{useCallback,useEffect,useState,useRef,useMemo}from'react';import PropTypes from'prop-types';import{i18n,hasNewServices}from'@shopgate/engage/core/helpers';import{UIEvents}from'@shopgate/engage/core';import{useWidgetSettings}from'@shopgate/engage/core/hooks';import{css}from'glamor';import classNames from'classnames';import{themeConfig}from'@shopgate/engage';import{RippleButton,QuantityInput}from'@shopgate/engage/components';import{broadcastLiveMessage}from'@shopgate/engage/a11y/helpers';var variables=themeConfig.variables,colors=themeConfig.colors;var styles={root:css({display:'flex',flexDirection:'row',position:'relative',zIndex:5}).toString(),backdrop:css({zIndex:4,top:0,left:0,height:'100%',width:'100%',position:'fixed'}),inputWrapper:function inputWrapper(_ref){var inputColor=_ref.inputColor,inputBgColor=_ref.inputBgColor;return css(_extends({display:'flex',alignItems:'center',width:'100%',fontSize:16,backgroundColor:"var(--color-background-accent, ".concat(colors.shade8,")")},inputColor&&{color:"".concat(inputColor," !important")},{},inputBgColor&&{backgroundColor:"".concat(inputBgColor," !important")},{' .quantity-label':{paddingLeft:variables.gap.small,paddingRight:4,textAlign:'center',width:'calc(100% - 32px)',textOverflow:'ellipsis',overflow:'hidden',whiteSpace:'nowrap'}}));},input:function input(_ref2){var inputColor=_ref2.inputColor,inputBgColor=_ref2.inputBgColor,hasLabel=_ref2.hasLabel,size=_ref2.size;var fontWeight=size==='large'?600:'normal';return css(_extends({padding:"0 ".concat(variables.gap.small,"px"),textAlign:hasLabel?'left':'center',fontWeight:fontWeight,height:'100%',width:'100%'},inputColor&&{color:"".concat(inputColor)},{},inputBgColor&&{backgroundColor:"".concat(inputBgColor," !important")},{},hasLabel&&{paddingLeft:0},{outline:'none','&:focus:not(:focus-visible)':{outline:'none'}})).toString();},button:function button(_ref3){var _ref3$size=_ref3.size,size=_ref3$size===void 0?'default':_ref3$size,buttonColor=_ref3.buttonColor,buttonBgColor=_ref3.buttonBgColor;var sizeValue=size==='large'?36:28;return css({width:sizeValue,' &&':{minWidth:sizeValue,padding:0},height:sizeValue,fontSize:"".concat(Math.floor(sizeValue/28*100),"% !important"),'&:not(:disabled)':_extends({},buttonColor&&{color:"".concat(buttonColor," !important")},{},buttonBgColor&&{backgroundColor:"".concat(buttonBgColor," !important")})});},buttonRipple:css({padding:0}).toString(),buttonNoRadiusLeft:css({' &&':{borderTopLeftRadius:0,borderBottomLeftRadius:0}}).toString(),buttonNoRadiusRight:css({' &&':{borderTopRightRadius:0,borderBottomRightRadius:0}}).toString(),disabled:css({' > div':{padding:0}}).toString()};/**
2
2
  * A Quantity Picker with unit support.
3
3
  * @returns {JSX.Element}
4
- */var UnitQuantityPicker=function UnitQuantityPicker(_ref){var className=_ref.className,onChange=_ref.onChange,value=_ref.value,allowDecrement=_ref.allowDecrement,allowIncrement=_ref.allowIncrement,allowZero=_ref.allowZero,decrementStep=_ref.decrementStep,incrementStep=_ref.incrementStep,maxDecimals=_ref.maxDecimals,unit=_ref.unit,disabled=_ref.disabled,minValue=_ref.minValue,maxValue=_ref.maxValue,toggleTabBarOnFocus=_ref.toggleTabBarOnFocus;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),isFocused=_useState2[0],setIsFocused=_useState2[1];var inputRef=useRef(null);var handleOnFocus=useCallback(function(){setIsFocused(true);if(toggleTabBarOnFocus){UIEvents.emit('HIDE_TAB_BAR');}},[toggleTabBarOnFocus]);var handleOnBlur=useCallback(function(){setIsFocused(false);if(toggleTabBarOnFocus){UIEvents.emit('SHOW_TAB_BAR');}},[toggleTabBarOnFocus]);var handleManualChange=useCallback(function(newValue){onChange(newValue);var message;if(newValue<value){message='product.decreased_quantity_to';}if(newValue>value){message='product.increased_quantity_to';}if(message){broadcastLiveMessage(message,{params:{quantity:newValue}});}},[onChange,value]);var handleDecrement=useCallback(function(event){var newValue=value-decrementStep;if(newValue<=0&&!allowZero||minValue&&newValue<minValue){newValue=value;}handleManualChange(newValue);event.preventDefault();event.stopPropagation();},[allowZero,decrementStep,handleManualChange,minValue,value]);var handleIncrement=useCallback(function(event){var newValue=value+incrementStep;if(maxValue&&newValue>maxValue){newValue=value;}handleManualChange(newValue);event.preventDefault();event.stopPropagation();},[handleManualChange,incrementStep,maxValue,value]);useEffect(function(){if(minValue&&value<minValue){onChange(minValue);}if(maxValue&&value>maxValue){onChange(maxValue);}/* eslint-disable react-hooks/exhaustive-deps */},[]);/* eslint-enable react-hooks/exhaustive-deps */ /**
4
+ */var UnitQuantityPicker=function UnitQuantityPicker(_ref4){var className=_ref4.className,onChange=_ref4.onChange,value=_ref4.value,allowDecrement=_ref4.allowDecrement,allowIncrement=_ref4.allowIncrement,allowZero=_ref4.allowZero,decrementStep=_ref4.decrementStep,incrementStep=_ref4.incrementStep,maxDecimals=_ref4.maxDecimals,unit=_ref4.unit,disabled=_ref4.disabled,minValue=_ref4.minValue,maxValue=_ref4.maxValue,size=_ref4.size,toggleTabBarOnFocus=_ref4.toggleTabBarOnFocus,quantityLabel=_ref4.quantityLabel;var widgetDefaults=useMemo(function(){if(hasNewServices()){// The widget configuration was introduced with CCP-2449 in PWA6. It's inactive for now
5
+ // when running on new services, since for those shops it never existed and the default
6
+ // values would introduce breaking changes.
7
+ return{};}return{buttonColor:colors.shade8,buttonBgColor:colors.primary,inputColor:colors.dark,inputBgColor:colors.shade8,showLabel:true};},[]);var _useWidgetSettings=useWidgetSettings('@shopgate/engage/product/components/UnitQuantityPicker'),_useWidgetSettings$bu=_useWidgetSettings.buttonColor,buttonColor=_useWidgetSettings$bu===void 0?widgetDefaults.buttonColor:_useWidgetSettings$bu,_useWidgetSettings$bu2=_useWidgetSettings.buttonBgColor,buttonBgColor=_useWidgetSettings$bu2===void 0?widgetDefaults.buttonBgColor:_useWidgetSettings$bu2,_useWidgetSettings$in=_useWidgetSettings.inputColor,inputColor=_useWidgetSettings$in===void 0?widgetDefaults.inputColor:_useWidgetSettings$in,_useWidgetSettings$in2=_useWidgetSettings.inputBgColor,inputBgColor=_useWidgetSettings$in2===void 0?widgetDefaults.inputBgColor:_useWidgetSettings$in2,_useWidgetSettings$sh=_useWidgetSettings.showLabel,showLabel=_useWidgetSettings$sh===void 0?widgetDefaults.showLabel:_useWidgetSettings$sh;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),isFocused=_useState2[0],setIsFocused=_useState2[1];var inputRef=useRef(null);var handleOnFocus=useCallback(function(){setIsFocused(true);if(toggleTabBarOnFocus){UIEvents.emit('HIDE_TAB_BAR');}},[toggleTabBarOnFocus]);var handleOnBlur=useCallback(function(){setIsFocused(false);if(toggleTabBarOnFocus){UIEvents.emit('SHOW_TAB_BAR');}},[toggleTabBarOnFocus]);var handleManualChange=useCallback(function(newValue){onChange(newValue);var message;if(newValue<value){message='product.decreased_quantity_to';}if(newValue>value){message='product.increased_quantity_to';}if(message){broadcastLiveMessage(message,{params:{quantity:newValue}});}},[onChange,value]);var handleDecrement=useCallback(function(event){var newValue=value-decrementStep;if(newValue<=0&&!allowZero||minValue&&newValue<minValue){newValue=value;}handleManualChange(newValue);event.preventDefault();event.stopPropagation();},[allowZero,decrementStep,handleManualChange,minValue,value]);var handleIncrement=useCallback(function(event){var newValue=value+incrementStep;if(maxValue&&newValue>maxValue){newValue=value;}handleManualChange(newValue);event.preventDefault();event.stopPropagation();},[handleManualChange,incrementStep,maxValue,value]);useEffect(function(){if(minValue&&value<minValue){onChange(minValue);}if(maxValue&&value>maxValue){onChange(maxValue);}/* eslint-disable react-hooks/exhaustive-deps */},[]);/* eslint-enable react-hooks/exhaustive-deps */ /**
5
8
  * Handler for pressing "enter" on Android
6
9
  */var handleKeyDown=useCallback(function(event){if(event.key==='Enter'&&inputRef.current!==null){try{inputRef.current.blur();}catch(e){// nothing to do here
7
10
  }}},[]);return React.createElement(React.Fragment,null,isFocused&&// Show hidden backdrop when focused to avoid side effects when user blurs the input
8
11
  // e.g. opening links unintended
9
- React.createElement("div",{className:styles.backdrop}),React.createElement("div",{className:"".concat(styles.root," ").concat(className)},React.createElement(RippleButton,{rippleClassName:styles.buttonRipple,className:classNames(styles.button,styles.buttonNoRadiusRight,_defineProperty({},styles.disabled,disabled)),type:"secondary",disabled:!allowDecrement||disabled,onClick:handleDecrement,"aria-label":i18n.text('product.decrease_quantity')},"-"),React.createElement("span",null,React.createElement(QuantityInput,{className:styles.input,value:value,onChange:onChange,maxDecimals:maxDecimals,unit:unit,disabled:disabled,minValue:minValue,maxValue:maxValue,"aria-label":i18n.text('product.quantity'),onFocus:handleOnFocus,onBlur:handleOnBlur,onKeyDown:handleKeyDown,ref:inputRef})),React.createElement(RippleButton,{type:"secondary",disabled:!allowIncrement||disabled,rippleClassName:styles.buttonRipple,className:classNames(styles.button,styles.buttonNoRadiusLeft,_defineProperty({},styles.disabled,disabled)),onClick:handleIncrement,"aria-label":i18n.text('product.increase_quantity')},"+")));};UnitQuantityPicker.defaultProps={className:'',allowZero:false,allowIncrement:true,allowDecrement:true,incrementStep:0.25,decrementStep:0.25,maxDecimals:2,unit:null,disabled:false,minValue:null,maxValue:null,toggleTabBarOnFocus:false};export default UnitQuantityPicker;
12
+ React.createElement("div",{className:styles.backdrop}),React.createElement("div",{className:"".concat(styles.root," ").concat(className)},React.createElement(RippleButton,{type:"secondary",disabled:!allowDecrement||disabled,rippleClassName:styles.buttonRipple,className:classNames(styles.button({size:size,buttonColor:buttonColor,buttonBgColor:buttonBgColor}),styles.buttonNoRadiusRight,_defineProperty({},styles.disabled,!allowDecrement||disabled)),onClick:handleDecrement,"aria-label":i18n.text('product.decrease_quantity')},"-"),React.createElement("span",{className:styles.inputWrapper({inputColor:inputColor,inputBgColor:inputBgColor})},quantityLabel&&showLabel&&React.createElement("span",{"aria-hidden":true,className:"quantity-label"},quantityLabel),React.createElement(QuantityInput,{className:styles.input({inputColor:inputColor,inputBgColor:inputBgColor,hasLabel:showLabel&&!!quantityLabel,size:size}),value:value,onChange:onChange,maxDecimals:maxDecimals,unit:unit,disabled:disabled,minValue:minValue,maxValue:maxValue,"aria-label":i18n.text('product.quantity'),onFocus:handleOnFocus,onBlur:handleOnBlur,onKeyDown:handleKeyDown,ref:inputRef})),React.createElement(RippleButton,{type:"secondary",disabled:!allowIncrement||disabled,rippleClassName:styles.buttonRipple,className:classNames(styles.button({size:size,buttonColor:buttonColor,buttonBgColor:buttonBgColor}),styles.buttonNoRadiusLeft,_defineProperty({},styles.disabled,!allowIncrement||disabled)),onClick:handleIncrement,"aria-label":i18n.text('product.increase_quantity')},"+")));};UnitQuantityPicker.defaultProps={className:'',allowZero:false,allowIncrement:true,allowDecrement:true,incrementStep:0.25,decrementStep:0.25,maxDecimals:2,unit:null,disabled:false,minValue:null,size:'default',maxValue:null,quantityLabel:null,toggleTabBarOnFocus:false};export default UnitQuantityPicker;
@@ -0,0 +1,7 @@
1
+ import React,{useMemo}from'react';import{css}from'glamor';import PropTypes from'prop-types';import{connect}from'react-redux';import{hasNewServices,i18n}from'@shopgate/engage/core/helpers';import{useWidgetSettings}from'@shopgate/engage/core/hooks';import{withCurrentProduct,withWidgetSettings}from'@shopgate/engage/core/hocs';import{Section}from'@shopgate/engage/a11y/components';import{makeGetCurrentProductPropertyByLabel}from'@shopgate/engage/product/selectors/product';import ProductUnitQuantityPicker from"./ProductUnitQuantityPicker";import OrderQuantityHint from"../OrderQuantityHint";var styles={quantityPicker:css({display:'flex',flexDirection:'column'}).toString(),quantityPickerPicker:css({width:'100%'}).toString(),quantityHint:css({'&:not(:empty)':{paddingTop:8,marginBottom:-4}}).toString()};/**
2
+ * A Quantity Picker with unit support.
3
+ * @returns {JSX.Element}
4
+ */var UnitQuantityPickerWithSection=function UnitQuantityPickerWithSection(_ref){var productId=_ref.productId,variantId=_ref.variantId,productProperty=_ref.productProperty;var _useWidgetSettings=useWidgetSettings('@shopgate/engage/product/components/UnitQuantityPicker'),_useWidgetSettings$sh=_useWidgetSettings.show,show=_useWidgetSettings$sh===void 0?hasNewServices():_useWidgetSettings$sh;var quantityLabel=useMemo(function(){var _ref2;if(!show){return null;}var label=i18n.text('product.sections.quantity');if(((_ref2=productProperty===null||productProperty===void 0?void 0:productProperty.value)!==null&&_ref2!==void 0?_ref2:'')!==''){label=productProperty.value;}return label;},[productProperty,show]);if(!show){return null;}return React.createElement(Section,{title:"product.sections.quantity"},React.createElement(ProductUnitQuantityPicker,{className:styles.quantityPicker,classes:{picker:styles.quantityPickerPicker},size:"large",quantityLabel:quantityLabel,hideHeadline:true},React.createElement(OrderQuantityHint,{productId:variantId||productId,className:styles.quantityHint})));};UnitQuantityPickerWithSection.defaultProps={productId:null,variantId:null,productProperty:null};/**
5
+ * Creates the mapStateToProps connector function.
6
+ * @returns {Function}
7
+ */var makeMapStateToProps=function makeMapStateToProps(){var getCurrentProductPropertyByLabel=makeGetCurrentProductPropertyByLabel();return function(state,props){return{productProperty:getCurrentProductPropertyByLabel(state,props)};};};export default withWidgetSettings(withCurrentProduct(connect(makeMapStateToProps)(UnitQuantityPickerWithSection)),'@shopgate/engage/product/components/UnitQuantityPicker');
@@ -1 +1 @@
1
- export{default as UnitQuantityPicker}from"./UnitQuantityPicker";export{default as ProductUnitQuantityPicker}from"./ProductUnitQuantityPicker";export{default as CartUnitQuantityPicker}from"./CartUnitQuantityPicker";
1
+ export{default as CartUnitQuantityPicker}from"./CartUnitQuantityPicker";export{default as ProductUnitQuantityPicker}from"./ProductUnitQuantityPicker";export{default as UnitQuantityPicker}from"./UnitQuantityPicker";export{default as UnitQuantityPickerWithSection}from"./UnitQuantityPickerWithSection";
@@ -1 +1 @@
1
- export*from"./Availability";export{default as Characteristics}from"./Characteristics";export{default as Description}from"./Description";export{default as EffectivityDates}from"./EffectivityDates";export{default as MapPriceHint}from"./MapPriceHint";export*from"./Media";export{default as MediaSlider}from"./MediaSlider";export{default as Options}from"./Options";export{default as OrderQuantityHint}from"./OrderQuantityHint";export{default as PriceDifference}from"./PriceDifference";export*from"./PriceInfo";export{default as ProductBadges}from"./ProductBadges";export{default as ProductCard}from"./ProductCard";export{default as ProductCharacteristics}from"./ProductCharacteristics";export{default as ProductDiscountBadge}from"./ProductDiscountBadge";export{default as ProductGridPrice}from"./ProductGridPrice";export{default as ProductImage}from"./ProductImage";export{default as ProductList}from"./ProductList";export*from"./ProductName";export{default as ProductProperties}from"./ProductProperties/ProductProperties";export{default as ProductProvider}from"./ProductProvider";export{default as ProductSlider}from"./ProductSlider";export*from"./ProductVariants";export{default as QuantityPicker}from"./QuantityPicker";export{default as Rating}from"./Rating";export*from"./RelationsSlider";export*from"./Swatch";export*from"./Swatches";export*from"./UnitQuantityPicker";
1
+ export*from"./Availability";export{default as Characteristics}from"./Characteristics";export{default as Description}from"./Description";export{default as EffectivityDates}from"./EffectivityDates";export{default as MapPriceHint}from"./MapPriceHint";export*from"./Media";export{default as MediaSlider}from"./MediaSlider";export{default as Options}from"./Options";export{default as OrderQuantityHint}from"./OrderQuantityHint";export{default as PriceDifference}from"./PriceDifference";export*from"./PriceInfo";export{default as ProductBadges}from"./ProductBadges";export{default as ProductCard}from"./ProductCard";export{default as ProductCharacteristics}from"./ProductCharacteristics";export{default as ProductDiscountBadge}from"./ProductDiscountBadge";export{default as ProductGridPrice}from"./ProductGridPrice";export{default as ProductImage}from"./ProductImage";export{default as ProductList}from"./ProductList";export*from"./ProductName";export{default as ProductProperties}from"./ProductProperties/ProductProperties";export{default as ProductSlider}from"./ProductSlider";export*from"./ProductVariants";export{default as QuantityPicker}from"./QuantityPicker";export{default as Rating}from"./Rating";export*from"./RelationsSlider";export*from"./Swatch";export*from"./Swatches";export*from"./UnitQuantityPicker";
@@ -9,4 +9,5 @@ import React from'react';/* eslint-disable max-len */ /**
9
9
  * @property {ProductListTypeContextSubType} [subType=null] Optional sub type of the active
10
10
  * ProductListTypeContext. Depending on its usage it can make a statement about in which context
11
11
  * the product list is used e.g. "widgets".
12
- */export{};export default React.createContext({type:null,subType:null});
12
+ * @property {Object} [meta=null] Optional meta information that can be used by child components
13
+ */export{};export default React.createContext({type:null,subType:null,meta:null});
@@ -10,5 +10,6 @@ import React,{useMemo}from'react';import PropTypes from'prop-types';import Conte
10
10
  * @param {string} param.type Type of the context e.g. "productSlider" or "productGrid".
11
11
  * @param {string} param.subType Optional sub type of the context. Depending on its usage it can
12
12
  * make a statement about in which context the product list is used e.g. "widgets".
13
+ * @param {Object} param.meta Optional meta information that can be used by child components
13
14
  * @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 React.createElement(Context.Provider,{value:value},children);}ProductListTypeProvider.defaultProps={children:null,subType:null};export default ProductListTypeProvider;
15
+ */function ProductListTypeProvider(_ref){var children=_ref.children,type=_ref.type,subType=_ref.subType,meta=_ref.meta;var value=useMemo(function(){return{type:type,subType:subType,meta:meta};},[meta,subType,type]);return React.createElement(Context.Provider,{value:value},children);}ProductListTypeProvider.defaultProps={children:null,subType:null,meta:null};export default ProductListTypeProvider;
@@ -1 +1 @@
1
- export{default as ProductListTypeProvider}from"./ProductListType";export{default as ProductListEntryProvider}from"./ProductListEntry";
1
+ export{default as ProductProvider}from"./Product";export{default as ProductListTypeProvider}from"./ProductListType";export{default as ProductListEntryProvider}from"./ProductListEntry";
@@ -2,9 +2,8 @@ import React,{useMemo}from'react';import PropTypes from'prop-types';import class
2
2
  * The Push opt-in modal component.
3
3
  * @param {Object} props The component props.
4
4
  * @returns {JSX.Element}
5
- */var PushOptInModal=function PushOptInModal(_ref){var isPushOptInModalVisible=_ref.isPushOptInModalVisible,allowPushOptIn=_ref.allowPushOptIn,denyPushOptIn=_ref.denyPushOptIn;var _appConfig$pushOptIn=appConfig.pushOptIn,_appConfig$pushOptIn2=_appConfig$pushOptIn===void 0?{}:_appConfig$pushOptIn,modalMessage=_appConfig$pushOptIn2.modalMessage,modalTitle=_appConfig$pushOptIn2.modalTitle,modalButtonDeny=_appConfig$pushOptIn2.modalButtonDeny,modalButtonAllow=_appConfig$pushOptIn2.modalButtonAllow,modalImageURL=_appConfig$pushOptIn2.modalImageURL,modalImageSVG=_appConfig$pushOptIn2.modalImageSVG;var imageSRC=useMemo(function(){// No overwrite configured -> use default image
6
- if(!modalImageURL&&!modalImageSVG){return pushImage;}// URL overwrite configured -> use it
7
- if(modalImageURL){return modalImageURL;}// SVG overwrite configured -> create data url
8
- try{// Remove any characters outside the Latin1 range
9
- var decoded=decodeURIComponent(encodeURIComponent(modalImageSVG));// Now we can use btoa to convert the svg to base64
10
- var base64=btoa(decoded);return"data:image/svg+xml;base64,".concat(base64);}catch(e){return pushImage;}},[modalImageSVG,modalImageURL]);if(!isPushOptInModalVisible){return null;}return React.createElement(Modal,{isOpened:isPushOptInModalVisible,classes:{content:styles.modalContent,layout:styles.modalLayout}},React.createElement(Grid,{className:classNames(styles.container,'push-opt-in-modal__container'),role:"alertdialog","aria-modal":true,"aria-labelledby":"pushOptInDialogTitle","aria-describedby":"pushOptInDialogMessage"},React.createElement(Grid.Item,{className:styles.item},React.createElement("img",{src:imageSRC,className:classNames(styles.image,'push-opt-in-modal__image'),alt:"","aria-hidden":"true"}),React.createElement(I18n.Text,{className:classNames(styles.title,'push-opt-in-modal__title'),string:modalTitle||'pushOptInModal.title',id:"pushOptInDialogTitle"}),React.createElement(I18n.Text,{className:classNames('push-opt-in-modal__message'),string:modalMessage||'pushOptInModal.message',id:"pushOptInDialogMessage"}),React.createElement(Button,{onClick:allowPushOptIn,type:"primary",className:classNames(styles.button,'push-opt-in-modal__button-allow')},React.createElement(I18n.Text,{string:modalButtonAllow||'pushOptInModal.buttonAllow'})),React.createElement(Button,{onClick:denyPushOptIn,type:"plain",className:classNames(styles.button,'push-opt-in-modal__button-deny')},React.createElement(I18n.Text,{string:modalButtonDeny||'pushOptInModal.buttonDeny',className:styles.buttonText})))));};export default connect(PushOptInModal);
5
+ */var PushOptInModal=function PushOptInModal(_ref){var isPushOptInModalVisible=_ref.isPushOptInModalVisible,allowPushOptIn=_ref.allowPushOptIn,denyPushOptIn=_ref.denyPushOptIn;var _appConfig$pushOptIn=appConfig.pushOptIn,_appConfig$pushOptIn2=_appConfig$pushOptIn===void 0?{}:_appConfig$pushOptIn,modalMessage=_appConfig$pushOptIn2.modalMessage,modalTitle=_appConfig$pushOptIn2.modalTitle,modalButtonDeny=_appConfig$pushOptIn2.modalButtonDeny,modalButtonAllow=_appConfig$pushOptIn2.modalButtonAllow,modalImageURL=_appConfig$pushOptIn2.modalImageURL,modalImageSVG=_appConfig$pushOptIn2.modalImageSVG;var imageSRC=useMemo(function(){if(!modalImageURL&&!modalImageSVG){return pushImage;}if(modalImageURL){return modalImageURL;}// SVG overwrite configured -> create data url
6
+ try{// encode SVG string to UTF-8 byte array to handle non-Latin1 characters
7
+ // (e.g. Unicode characters like emojis)
8
+ var utf8Encoder=new TextEncoder();var svgBytes=utf8Encoder.encode(modalImageSVG);// Convert the byte array to a Base64 string
9
+ var base64Svg=btoa(String.fromCharCode.apply(null,svgBytes));return"data:image/svg+xml;base64,".concat(base64Svg);}catch(e){return pushImage;}},[modalImageSVG,modalImageURL]);if(!isPushOptInModalVisible){return null;}return React.createElement(Modal,{isOpened:isPushOptInModalVisible,classes:{content:styles.modalContent,layout:styles.modalLayout}},React.createElement(Grid,{className:classNames(styles.container,'push-opt-in-modal__container'),role:"alertdialog","aria-modal":true,"aria-labelledby":"pushOptInDialogTitle","aria-describedby":"pushOptInDialogMessage"},React.createElement(Grid.Item,{className:styles.item},React.createElement("img",{src:imageSRC,className:classNames(styles.image,'push-opt-in-modal__image'),alt:"","aria-hidden":"true"}),React.createElement(I18n.Text,{className:classNames(styles.title,'push-opt-in-modal__title'),string:modalTitle||'pushOptInModal.title',id:"pushOptInDialogTitle"}),React.createElement(I18n.Text,{className:classNames('push-opt-in-modal__message'),string:modalMessage||'pushOptInModal.message',id:"pushOptInDialogMessage"}),React.createElement(Button,{onClick:allowPushOptIn,type:"primary",className:classNames(styles.button,'push-opt-in-modal__button-allow')},React.createElement(I18n.Text,{string:modalButtonAllow||'pushOptInModal.buttonAllow'})),React.createElement(Button,{onClick:denyPushOptIn,type:"plain",className:classNames(styles.button,'push-opt-in-modal__button-deny')},React.createElement(I18n.Text,{string:modalButtonDeny||'pushOptInModal.buttonDeny',className:styles.buttonText})))));};export default connect(PushOptInModal);
@@ -1,6 +1,4 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function 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{appConfig}from'@shopgate/engage';import{main$,appDidStart$}from'@shopgate/engage/core/streams';import{event}from'@shopgate/engage/core/classes';import{appSupportsPushOptIn,logger}from'@shopgate/engage/core/helpers';import{PERMISSION_ID_PUSH,PERMISSION_STATUS_NOT_DETERMINED}from'@shopgate/engage/core/constants';import{requestAppPermissionStatus}from'@shopgate/engage/core/actions';// TODO replace appDidStart$ with cookieConsentInitialized$ after cookie consent feature is merged
2
- // import { cookieConsentInitialized$ } from '@shopgate/engage/tracking/streams';
3
- import{increaseAppStartCount,resetAppStartCount,increaseOrdersPlacedCount,resetOrdersPlacedCount,setLastPopupTimestamp,increaseRejectionCount,showPushOptInModal}from"../action-creators";import{PUSH_OPT_IN_OPT_IN_POSTPONED}from"../constants";import{getPushOptInTriggerState}from"../selectors";var DAY_IN_MS=1000*60*60*24;var increaseRejectionCount$=main$.filter(function(_ref){var action=_ref.action;return action.type===PUSH_OPT_IN_OPT_IN_POSTPONED;});/**
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function 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{appConfig}from'@shopgate/engage';import{main$}from'@shopgate/engage/core/streams';import{event}from'@shopgate/engage/core/classes';import{appSupportsPushOptIn,logger}from'@shopgate/engage/core/helpers';import{PERMISSION_ID_PUSH,PERMISSION_STATUS_NOT_DETERMINED}from'@shopgate/engage/core/constants';import{requestAppPermissionStatus}from'@shopgate/engage/core/actions';import{cookieConsentInitialized$}from'@shopgate/engage/tracking/streams';import{increaseAppStartCount,resetAppStartCount,increaseOrdersPlacedCount,resetOrdersPlacedCount,setLastPopupTimestamp,increaseRejectionCount,showPushOptInModal}from"../action-creators";import{PUSH_OPT_IN_OPT_IN_POSTPONED}from"../constants";import{getPushOptInTriggerState}from"../selectors";var DAY_IN_MS=1000*60*60*24;var increaseRejectionCount$=main$.filter(function(_ref){var action=_ref.action;return action.type===PUSH_OPT_IN_OPT_IN_POSTPONED;});/**
4
2
  * Push opt in subscriptions
5
3
  * @param {Function} subscribe The subscribe function
6
4
  */export default function pushOptIn(subscribe){/**
@@ -10,5 +8,5 @@ import{increaseAppStartCount,resetAppStartCount,increaseOrdersPlacedCount,resetO
10
8
  * @returns {void}
11
9
  */var showOptInAfterChecks=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2,configKey,increaseCountAction){var dispatch,getState,_appConfig$pushOptIn,_appConfig$pushOptIn2,appStarts,ordersPlaced,rejectionMaxCount,minDaysBetweenOptIns,_ref4,pushStatus,state,configValue,resetAction,resetCountState,configCountState,mustShowModal,hasRepeats,minDaysElapsed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:dispatch=_ref2.dispatch,getState=_ref2.getState;if(appSupportsPushOptIn()){_context.next=3;break;}return _context.abrupt("return");case 3:_appConfig$pushOptIn=appConfig.pushOptIn,_appConfig$pushOptIn2=_appConfig$pushOptIn===void 0?{}:_appConfig$pushOptIn,appStarts=_appConfig$pushOptIn2.appStarts,ordersPlaced=_appConfig$pushOptIn2.ordersPlaced,rejectionMaxCount=_appConfig$pushOptIn2.rejectionMaxCount,minDaysBetweenOptIns=_appConfig$pushOptIn2.minDaysBetweenOptIns;// Deactivate feature when config is invalid
12
10
  if(!(typeof minDaysBetweenOptIns!=='number'||typeof rejectionMaxCount!=='number'||_typeof(ordersPlaced)!=='object'||_typeof(appStarts)!=='object')){_context.next=7;break;}logger.error('PushOptInTrigger - Config invalid',appConfig===null||appConfig===void 0?void 0:appConfig.pushOptIn);return _context.abrupt("return");case 7:_context.next=9;return dispatch(requestAppPermissionStatus({permissionId:PERMISSION_ID_PUSH}));case 9:_ref4=_context.sent;pushStatus=_ref4.status;if(!(pushStatus!==PERMISSION_STATUS_NOT_DETERMINED)){_context.next=13;break;}return _context.abrupt("return");case 13:dispatch(increaseCountAction());state=getPushOptInTriggerState(getState());configValue=appStarts;resetAction=resetAppStartCount;resetCountState=state.appStartResetCount;configCountState=state.appStartCount;if(configKey==='ordersPlaced'){configValue=ordersPlaced;resetAction=resetOrdersPlacedCount;resetCountState=state.ordersPlacedResetCount;configCountState=state.ordersPlacedCount;}if(!(state.rejectionCount>=rejectionMaxCount)){_context.next=22;break;}return _context.abrupt("return");case 22:mustShowModal=Number(configValue.value)>0&&configCountState>=configValue.value;hasRepeats=configValue.repeats===null||resetCountState<=configValue.repeats;minDaysElapsed=Date.now()-state.lastPopupAt>=minDaysBetweenOptIns*DAY_IN_MS;if(mustShowModal&&hasRepeats&&minDaysElapsed){dispatch(setLastPopupTimestamp());dispatch(resetAction());dispatch(showPushOptInModal());}case 26:case"end":return _context.stop();}},_callee);}));return function showOptInAfterChecks(_x,_x2,_x3){return _ref3.apply(this,arguments);};}();// event subscriber to handle app start based push opt in
13
- subscribe(appDidStart$,/*#__PURE__*/function(){var _ref6=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref5){var dispatch,getState;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:dispatch=_ref5.dispatch,getState=_ref5.getState;_context2.next=3;return showOptInAfterChecks({dispatch:dispatch,getState:getState},'appStarts',increaseAppStartCount);case 3:case"end":return _context2.stop();}},_callee2);}));return function(_x4){return _ref6.apply(this,arguments);};}());// event subscriber to handle order based push opt in
14
- subscribe(appDidStart$,function(_ref7){var dispatch=_ref7.dispatch,getState=_ref7.getState;event.addCallback('checkoutSuccess',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(){return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return showOptInAfterChecks({dispatch:dispatch,getState:getState},'ordersPlaced',increaseOrdersPlacedCount);case 2:case"end":return _context3.stop();}},_callee3);})));});subscribe(increaseRejectionCount$,function(_ref9){var dispatch=_ref9.dispatch;dispatch(increaseRejectionCount());});}
11
+ subscribe(cookieConsentInitialized$,/*#__PURE__*/function(){var _ref6=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref5){var dispatch,getState;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:dispatch=_ref5.dispatch,getState=_ref5.getState;_context2.next=3;return showOptInAfterChecks({dispatch:dispatch,getState:getState},'appStarts',increaseAppStartCount);case 3:case"end":return _context2.stop();}},_callee2);}));return function(_x4){return _ref6.apply(this,arguments);};}());// event subscriber to handle order based push opt in
12
+ subscribe(cookieConsentInitialized$,function(_ref7){var dispatch=_ref7.dispatch,getState=_ref7.getState;event.addCallback('checkoutSuccess',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(){return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return showOptInAfterChecks({dispatch:dispatch,getState:getState},'ordersPlaced',increaseOrdersPlacedCount);case 2:case"end":return _context3.stop();}},_callee3);})));});subscribe(increaseRejectionCount$,function(_ref9){var dispatch=_ref9.dispatch;dispatch(increaseRejectionCount());});}
@@ -0,0 +1,24 @@
1
+ import{appConfig}from'@shopgate/engage';import{UPDATE_COOKIE_CONSENT,COOKIE_CONSENT_HANDLED,HIDE_COOKIE_CONSENT_MODAL,SHOW_COOKIE_CONSENT_MODAL}from"../constants";var _appConfig$cookieCons=appConfig.cookieConsent,_appConfig$cookieCons2=_appConfig$cookieCons===void 0?{}:_appConfig$cookieCons,showComfortCookiesToggle=_appConfig$cookieCons2.showComfortCookiesToggle;/**
2
+ * action to be dispatched when the cookie consent modal should be shown
3
+ * @returns {Function}
4
+ */export var showCookieConsentModal=function showCookieConsentModal(){return{type:SHOW_COOKIE_CONSENT_MODAL};};/**
5
+ * action to be dispatched when the cookie consent modal should be hidden
6
+ * @returns {Function}
7
+ */export var hideCookieConsentModal=function hideCookieConsentModal(){return{type:HIDE_COOKIE_CONSENT_MODAL};};/**
8
+ * action to be dispatched when the user accepted the selected cookies in the custom modal
9
+ * @param {Object} params Action params
10
+ * @param {boolean} [params.comfortCookiesAccepted=false] whether this cookie type was accepted
11
+ * by user
12
+ * @param {boolean} [params.statisticsCookiesAccepted=false] whether this cookie type was accepted
13
+ * by user
14
+ * @returns {Function}
15
+ */export var updateCookieConsent=function updateCookieConsent(_ref){var _ref$comfortCookiesAc=_ref.comfortCookiesAccepted,comfortCookiesAccepted=_ref$comfortCookiesAc===void 0?false:_ref$comfortCookiesAc,_ref$statisticsCookie=_ref.statisticsCookiesAccepted,statisticsCookiesAccepted=_ref$statisticsCookie===void 0?false:_ref$statisticsCookie;return{type:UPDATE_COOKIE_CONSENT,comfortCookiesAccepted:showComfortCookiesToggle===true?comfortCookiesAccepted:true,statisticsCookiesAccepted:statisticsCookiesAccepted};};/**
16
+ * action to be dispatched when the cookies have been handled either by user or by merchant
17
+ * and native modal should be triggered for setting the permission
18
+ * @param {Object} params Action params
19
+ * @param {boolean} [params.comfortCookiesAccepted=false] whether this cookie type was accepted
20
+ * by user
21
+ * @param {boolean} [params.statisticsCookiesAccepted=false] whether this cookie type was accepted
22
+ * by user
23
+ * @returns {Function}
24
+ */export var handleCookieConsent=function handleCookieConsent(_ref2){var _ref2$comfortCookiesA=_ref2.comfortCookiesAccepted,comfortCookiesAccepted=_ref2$comfortCookiesA===void 0?false:_ref2$comfortCookiesA,_ref2$statisticsCooki=_ref2.statisticsCookiesAccepted,statisticsCookiesAccepted=_ref2$statisticsCooki===void 0?false:_ref2$statisticsCooki;return{type:COOKIE_CONSENT_HANDLED,comfortCookiesAccepted:comfortCookiesAccepted,statisticsCookiesAccepted:statisticsCookiesAccepted};};
@@ -1,4 +1 @@
1
- import{INITIALIZE_TRACKING}from"../constants";/**
2
- * Creates the dispatched INITIALIZE_TRACKING action object.
3
- * @returns {Object} The dispatched action object.
4
- */export var initTracking=function initTracking(){return{type:INITIALIZE_TRACKING};};
1
+ export*from"./cookieConsent";
@@ -0,0 +1,21 @@
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{historyPush,grantAppTrackingTransparencyPermission}from'@shopgate/engage/core/actions';import{updateCookieConsent,hideCookieConsentModal}from"../action-creators";import{PRIVACY_SETTINGS_PATTERN}from"../constants";/**
2
+ * action to be dispatched when the user accepted all cookies in the custom modal
3
+ * and native modal should be triggered for setting the permission
4
+ * @returns {Function}
5
+ */export var acceptAllCookies=function acceptAllCookies(){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=2;return dispatch(grantAppTrackingTransparencyPermission());case 2:dispatch(updateCookieConsent({comfortCookiesAccepted:true,statisticsCookiesAccepted:true}));dispatch(hideCookieConsentModal());case 4:case"end":return _context.stop();}},_callee);}));return function(_x){return _ref.apply(this,arguments);};}());};/**
6
+ * action to be dispatched when the user accepted the selected cookies in the custom modal
7
+ * and native modal should be triggered for setting the permission
8
+ * @param {Object} params Action params
9
+ * @param {boolean|null} params.comfortCookiesAccepted whether this cookie type was accepted
10
+ * by user
11
+ * @param {boolean|null} params.statisticsCookiesAccepted whether this cookie type was accepted
12
+ * by user
13
+ * @returns {Function}
14
+ */export var acceptSelectedCookies=function acceptSelectedCookies(_ref2){var comfortCookiesAccepted=_ref2.comfortCookiesAccepted,statisticsCookiesAccepted=_ref2.statisticsCookiesAccepted;return(/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(dispatch){return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(!(comfortCookiesAccepted||statisticsCookiesAccepted)){_context2.next=3;break;}_context2.next=3;return dispatch(grantAppTrackingTransparencyPermission());case 3:dispatch(updateCookieConsent({comfortCookiesAccepted:comfortCookiesAccepted,statisticsCookiesAccepted:statisticsCookiesAccepted}));dispatch(hideCookieConsentModal());case 5:case"end":return _context2.stop();}},_callee2);}));return function(_x2){return _ref3.apply(this,arguments);};}());};/**
15
+ * action to be dispatched when the user selected only the required cookies in the custom modal
16
+ * and native modal should be triggered for setting the permission
17
+ * @returns {Function}
18
+ */export var acceptRequiredCookies=function acceptRequiredCookies(){return function(dispatch){dispatch(updateCookieConsent({comfortCookiesAccepted:false,statisticsCookiesAccepted:false}));dispatch(hideCookieConsentModal());};};/**
19
+ * action to be dispatched when the user opted to configure cookie settings in the custom modal
20
+ * @returns {Function}
21
+ */export var openPrivacySettings=function openPrivacySettings(){return function(dispatch){dispatch(historyPush({pathname:PRIVACY_SETTINGS_PATTERN}));};};
@@ -0,0 +1 @@
1
+ export*from"./cookieConsent";
@@ -0,0 +1,6 @@
1
+ import{connect}from'react-redux';import{makeGetPrivacyPolicyLink}from'@shopgate/engage/page/selectors';import{getIsCookieConsentModalVisible}from"../../selectors/cookieConsent";import{acceptAllCookies,acceptRequiredCookies,openPrivacySettings}from"../../actions";/**
2
+ * @return {Object} The extended component props.
3
+ */var makeMapStateToProps=function makeMapStateToProps(){var getPrivacyPolicyLink=makeGetPrivacyPolicyLink();return function(state){return{isCookieConsentModalVisible:getIsCookieConsentModalVisible(state),privacyPolicyLink:getPrivacyPolicyLink(state)};};};/**
4
+ * Connects the dispatch function to a callable function in the props.
5
+ * @return {Object} The extended component props.
6
+ */var mapDispatchToProps={acceptAllCookies:acceptAllCookies,acceptRequiredCookies:acceptRequiredCookies,openPrivacySettings:openPrivacySettings};export default connect(makeMapStateToProps,mapDispatchToProps);
@@ -0,0 +1,9 @@
1
+ import React,{useMemo}from'react';import PropTypes from'prop-types';import{Grid,I18n,Button,Modal,Link,ConditionalWrapper}from'@shopgate/engage/components';import{appConfig}from'@shopgate/engage';import classNames from'classnames';import connect from"./connector";import cookieImage from"./tracking-opt-in.svg";import styles from"./style";/**
2
+ * The cookie consent modal component.
3
+ * @param {Object} props The component props.
4
+ * @returns {JSX.Element}
5
+ */var CookieConsentModal=function CookieConsentModal(_ref){var isCookieConsentModalVisible=_ref.isCookieConsentModalVisible,acceptAllCookies=_ref.acceptAllCookies,acceptRequiredCookies=_ref.acceptRequiredCookies,openPrivacySettings=_ref.openPrivacySettings,privacyPolicyLink=_ref.privacyPolicyLink;var _appConfig$cookieCons=appConfig.cookieConsent,_appConfig$cookieCons2=_appConfig$cookieCons===void 0?{}:_appConfig$cookieCons,modalMessage=_appConfig$cookieCons2.modalMessage,modalTitle=_appConfig$cookieCons2.modalTitle,modalButtonConfigureSettings=_appConfig$cookieCons2.modalButtonConfigureSettings,modalButtonOnlyRequired=_appConfig$cookieCons2.modalButtonOnlyRequired,modalButtonAcceptAll=_appConfig$cookieCons2.modalButtonAcceptAll,modalImageURL=_appConfig$cookieCons2.modalImageURL,modalImageSVG=_appConfig$cookieCons2.modalImageSVG,showRequiredCookiesButton=_appConfig$cookieCons2.showRequiredCookiesButton;var imageSRC=useMemo(function(){if(!modalImageURL&&!modalImageSVG){return cookieImage;}if(modalImageURL){return modalImageURL;}// if SVG overwrite configured: create data url
6
+ try{// encode SVG string to UTF-8 byte array to handle non-Latin1 characters
7
+ // (e.g. Unicode characters like emojis)
8
+ var utf8Encoder=new TextEncoder();var svgBytes=utf8Encoder.encode(modalImageSVG);// Convert the byte array to a Base64 string
9
+ var base64Svg=btoa(String.fromCharCode.apply(null,svgBytes));return"data:image/svg+xml;base64,".concat(base64Svg);}catch(e){return cookieImage;}},[modalImageSVG,modalImageURL]);if(!isCookieConsentModalVisible){return null;}return React.createElement(Modal,{isOpened:isCookieConsentModalVisible,classes:{content:styles.modalContent,layout:styles.modalLayout}},React.createElement(Grid,{component:"div",className:classNames(styles.container,'cookie-consent-modal__container'),role:"alertdialog","aria-modal":true,"aria-labelledby":"cookieConsentDialogTitle","aria-describedby":"cookieConsentDialogMessage"},React.createElement(Grid.Item,{component:"div",className:styles.item},React.createElement("img",{src:imageSRC,className:classNames(styles.image,'cookie-consent-modal__image'),alt:"","aria-hidden":"true"}),React.createElement(I18n.Text,{className:classNames(styles.title,'cookie-consent-modal__title'),string:modalTitle||'cookieConsentModal.title',id:"cookieConsentDialogTitle"}),React.createElement(I18n.Text,{string:modalMessage||'cookieConsentModal.message',className:classNames('cookie-consent-modal__message'),acceptPlainTextWithPlaceholders:true,id:"cookieConsentDialogMessage"},React.createElement(I18n.Placeholder,{forKey:"privacyLink"},React.createElement(ConditionalWrapper,{condition:!!privacyPolicyLink,wrapper:function wrapper(children){return React.createElement(Link,{href:privacyPolicyLink,tag:"span"},children);}},React.createElement(I18n.Text,{string:"cookieConsentModal.privacyText",className:styles.link})))),React.createElement(Grid.Item,{component:"div",className:styles.buttonWrapper},React.createElement(Button,{onClick:acceptAllCookies,type:"primary",className:classNames(styles.button,'cookie-consent-modal__button-accept-all')},React.createElement(I18n.Text,{string:modalButtonAcceptAll||'cookieConsentModal.buttonAcceptAll'})),showRequiredCookiesButton?React.createElement(Button,{onClick:acceptRequiredCookies,type:"simple",className:classNames(styles.button,'cookie-consent-modal__button-accept-required')},React.createElement(I18n.Text,{string:modalButtonOnlyRequired||'cookieConsentModal.modalButtonOnlyRequired'})):null,React.createElement(Button,{onClick:openPrivacySettings,type:"simple",className:classNames(styles.button,'cookie-consent-modal__button-open-settings')},React.createElement(I18n.Text,{string:modalButtonConfigureSettings||'cookieConsentModal.buttonConfigure'}))))));};CookieConsentModal.defaultProps={privacyPolicyLink:null};export default connect(CookieConsentModal);
@@ -0,0 +1 @@
1
+ import{css}from'glamor';import{themeColors}from'@shopgate/pwa-common/helpers/config';var modalContent=css({width:'100%'}).toString();var modalLayout=css({backgroundColor:themeColors.lightOverlay}).toString();var container=css({backgroundColor:themeColors.lightOverlay,padding:'30px',justifyContent:'center',display:'flex',flexDirection:'column',textAlign:'center'}).toString();var title=css({fontWeight:'bold',fontSize:'1.35rem',paddingTop:'30px',paddingBottom:'30px'}).toString();var item=css({display:'flex',flexDirection:'column',alignItems:'center'}).toString();var link=css({color:themeColors.accent,textDecoration:'underline'}).toString();var image=css({width:'60%',maxWidth:400}).toString();var button=css({marginTop:'20px'}).toString();var buttonText=css({color:themeColors.gray}).toString();var buttonWrapper=css({display:'flex',flexDirection:'column',marginBottom:'30px',width:'100%'}).toString();export default{modalContent:modalContent,modalLayout:modalLayout,container:container,item:item,title:title,link:link,image:image,button:button,buttonText:buttonText,buttonWrapper:buttonWrapper};
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg width="100%" height="100%" viewBox="0 0 895 895" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
4
+ <g transform="matrix(1,0,0,1,-197.772,-376.125)">
5
+ <g transform="matrix(1.28727,0,0,1.28727,-185.288,-236.524)">
6
+ <g transform="matrix(1.25456,0,0,1.25456,-164.192,-209.593)">
7
+ <circle cx="645" cy="823.354" r="276.929" style="fill:rgb(235,235,235);"/>
8
+ </g>
9
+ <g transform="matrix(17.6233,0,0,17.6233,433.521,611.874)">
10
+ <path d="M12,0C8.629,2.866 6.516,3 3,3L3,14.535C3,19.138 6.203,20.339 12,24C17.797,20.339 21,19.138 21,14.535L21,3C17.484,3 15.371,2.866 12,0Z" style="fill:rgb(255,115,115);fill-rule:nonzero;"/>
11
+ <path d="M12.99,-1.164C12.419,-1.649 11.581,-1.649 11.01,-1.164C8.014,1.383 6.125,1.472 3,1.472C2.156,1.472 1.472,2.156 1.472,3L1.472,14.535C1.472,17.357 2.45,19.137 4.32,20.771C5.891,22.144 8.2,23.407 11.184,25.292C11.682,25.607 12.318,25.607 12.816,25.292C15.8,23.407 18.109,22.144 19.68,20.771C21.55,19.137 22.528,17.357 22.528,14.535L22.528,3C22.528,2.156 21.844,1.472 21,1.472C17.875,1.472 15.986,1.383 12.99,-1.164ZM12,0C8.629,2.866 6.516,3 3,3L3,14.535C3,19.138 6.203,20.339 12,24C17.797,20.339 21,19.138 21,14.535L21,3C17.484,3 15.371,2.866 12,0Z" style="fill:rgb(216,216,216);"/>
12
+ </g>
13
+ <g transform="matrix(24.4351,0,0,24.4351,340.416,541.775)">
14
+ <path d="M15.762,8.047L11.381,12.522L9.166,10.399L7.93,11.638L11.381,15L17,9.285L15.762,8.047Z" style="fill:white;fill-rule:nonzero;"/>
15
+ </g>
16
+ </g>
17
+ </g>
18
+ </svg>
@@ -0,0 +1,6 @@
1
+ import{connect}from'react-redux';import{makeGetPrivacyPolicyLink}from'@shopgate/engage/page/selectors';import{acceptAllCookies,acceptSelectedCookies}from"../../actions";import{getAreComfortCookiesAcceptedInternal,getAreStatisticsCookiesAcceptedInternal}from"../../selectors/cookieConsent";/**
2
+ * @return {Object} The extended component props.
3
+ */var makeMapStateToProps=function makeMapStateToProps(){var getPrivacyPolicyLink=makeGetPrivacyPolicyLink();return function(state){return{comfortCookiesAcceptedState:getAreComfortCookiesAcceptedInternal(state),statisticsCookiesAcceptedState:getAreStatisticsCookiesAcceptedInternal(state),privacyPolicyLink:getPrivacyPolicyLink(state)};};};/**
4
+ * Connects the dispatch function to a callable function in the props.
5
+ * @return {Object} The extended component props.
6
+ */var mapDispatchToProps={acceptAllCookies:acceptAllCookies,acceptSelectedCookies:acceptSelectedCookies};export default connect(makeMapStateToProps,mapDispatchToProps);
@@ -0,0 +1,4 @@
1
+ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useCallback,useState}from'react';import{Button,Grid,I18n,Link,Switch,ConditionalWrapper}from'@shopgate/engage/components';import PropTypes from'prop-types';import{appConfig}from'@shopgate/engage';import{i18n}from'@shopgate/engage/core';import classNames from'classnames';import styles from"./style";import connect from"./connector";/**
2
+ * The PrivacySettings component.
3
+ * @returns {JSX.Element}
4
+ */var PrivacySettings=function PrivacySettings(_ref){var acceptAllCookies=_ref.acceptAllCookies,acceptSelectedCookies=_ref.acceptSelectedCookies,comfortCookiesAcceptedState=_ref.comfortCookiesAcceptedState,statisticsCookiesAcceptedState=_ref.statisticsCookiesAcceptedState,privacyPolicyLink=_ref.privacyPolicyLink;var _appConfig$cookieCons=appConfig.cookieConsent,_appConfig$cookieCons2=_appConfig$cookieCons===void 0?{}:_appConfig$cookieCons,settingsComfortText=_appConfig$cookieCons2.settingsComfortText,settingsComfortTitle=_appConfig$cookieCons2.settingsComfortTitle,settingsStatisticsText=_appConfig$cookieCons2.settingsStatisticsText,settingsStatisticsTitle=_appConfig$cookieCons2.settingsStatisticsTitle,settingsRequiredText=_appConfig$cookieCons2.settingsRequiredText,settingsRequiredTitle=_appConfig$cookieCons2.settingsRequiredTitle,showComfortCookiesToggle=_appConfig$cookieCons2.showComfortCookiesToggle;var _useState=useState(comfortCookiesAcceptedState!==null?comfortCookiesAcceptedState:false),_useState2=_slicedToArray(_useState,2),areComfortCookiesSelected=_useState2[0],setAreComfortCookiesSelected=_useState2[1];var _useState3=useState(statisticsCookiesAcceptedState!==null?statisticsCookiesAcceptedState:false),_useState4=_slicedToArray(_useState3,2),areStatisticsCookiesSelected=_useState4[0],setAreStatisticsCookiesSelected=_useState4[1];var handleChangeComfortCookies=useCallback(function(){setAreComfortCookiesSelected(!areComfortCookiesSelected);},[areComfortCookiesSelected]);var handleChangeStatisticsCookies=useCallback(function(){setAreStatisticsCookiesSelected(!areStatisticsCookiesSelected);},[areStatisticsCookiesSelected]);var handleAcceptAllCookies=useCallback(function(){setAreStatisticsCookiesSelected(true);setAreComfortCookiesSelected(true);acceptAllCookies();},[acceptAllCookies]);return React.createElement(Grid,{component:"div",className:styles.container},React.createElement(Grid.Item,{component:"div",className:styles.item},showComfortCookiesToggle?React.createElement(Grid.Item,{component:"div",className:styles.switchWrapper},React.createElement(Switch,{onChange:handleChangeComfortCookies,checked:areComfortCookiesSelected,a11yFallbackText:"".concat(i18n.text(settingsComfortTitle||'cookieSettings.comfortTitle'),". ").concat(i18n.text(settingsComfortText||'cookieSettings.comfort'))},React.createElement("span",{className:styles.title},React.createElement(I18n.Text,{string:settingsComfortTitle||'cookieSettings.comfortTitle'})),React.createElement("span",null,React.createElement(I18n.Text,{string:settingsComfortText||'cookieSettings.comfort'})))):null,React.createElement(Grid.Item,{component:"div",className:styles.switchWrapper},React.createElement(Switch,{onChange:handleChangeStatisticsCookies,checked:areStatisticsCookiesSelected,a11yFallbackText:"".concat(i18n.text(settingsStatisticsTitle||'cookieSettings.statisticsTitle'),". ").concat(i18n.text(settingsStatisticsText||'cookieSettings.statistics'))},React.createElement("span",{className:styles.title},React.createElement(I18n.Text,{string:settingsStatisticsTitle||'cookieSettings.statisticsTitle'})),React.createElement("span",null,React.createElement(I18n.Text,{string:settingsStatisticsText||'cookieSettings.statistics'})))),React.createElement(Grid.Item,{component:"div",className:styles.switchWrapper},React.createElement(Switch,{disabled:true,checked:true,a11yFallbackText:"".concat(i18n.text(settingsRequiredTitle||'cookieSettings.requiredTitle'),". ").concat(i18n.text(settingsRequiredText||'cookieSettings.required'))},React.createElement("span",{className:styles.title},React.createElement(I18n.Text,{string:settingsRequiredTitle||'cookieSettings.requiredTitle'})),React.createElement("span",null,React.createElement(I18n.Text,{string:settingsRequiredText||'cookieSettings.required'}))))),React.createElement(Grid.Item,{component:"div",className:styles.buttonWrapper},React.createElement(Button,{onClick:function onClick(){return handleAcceptAllCookies();},type:"primary",className:classNames(styles.button,'privacy-settings__button-accept-all')},React.createElement(I18n.Text,{string:"cookieConsentModal.buttonAcceptAll"})),React.createElement(Button,{onClick:function onClick(){return acceptSelectedCookies({comfortCookiesAccepted:areComfortCookiesSelected,statisticsCookiesAccepted:areStatisticsCookiesSelected});},type:"simple",className:classNames(styles.button,'privacy-settings__button-accept-selected')},React.createElement(I18n.Text,{string:"cookieConsentModal.modalButtonConfirmSelected"}))),React.createElement(Grid.Item,{component:"div"},React.createElement(I18n.Text,{string:"cookieSettings.privacy"},React.createElement(I18n.Placeholder,{forKey:"privacyLink"},React.createElement(ConditionalWrapper,{condition:!!privacyPolicyLink,wrapper:function wrapper(children){return React.createElement(Link,{href:privacyPolicyLink,tag:"span"},children);}},React.createElement(I18n.Text,{string:"cookieConsentModal.privacyText",className:styles.link}))))));};PrivacySettings.defaultProps={comfortCookiesAcceptedState:null,statisticsCookiesAcceptedState:null,privacyPolicyLink:null};export default connect(PrivacySettings);
@@ -0,0 +1 @@
1
+ import{css}from'glamor';import{themeColors}from'@shopgate/pwa-common/helpers/config';var button=css({marginTop:'20px'}).toString();var container=css({flexDirection:'column',height:'100vh',textAlign:'center',padding:'30px',justifyContent:'center',display:'flex'}).toString();var buttonWrapper=css({display:'flex',flexDirection:'column',marginBottom:'30px'}).toString();var item=css({display:'flex',flexDirection:'column'}).toString();var link=css({color:themeColors.accent,textDecoration:'underline'}).toString();var switchWrapper=css({marginBottom:'25px',display:'flex',textAlign:'left',justifyContent:'space-between'}).toString();var title=css({fontWeight:'bold',display:'block'});export default{button:button,container:container,buttonWrapper:buttonWrapper,link:link,item:item,switchWrapper:switchWrapper,title:title};
@@ -1 +1 @@
1
- export{CookieConsent}from"./CookieConsent";
1
+ export{default as CookieConsentModal}from"./CookieConsentModal";export{default as PrivacySettings}from"./PrivacySettings";
@@ -1,2 +1 @@
1
- export var COOKIE_CONSENT_COOKIE_NAME_STATUS='sg-cookie-banner-status';export var COOKIE_CONSENT_COOKIE_NAME_PREFS='sg-cookie-banner-pref';export var COOKIE_CONSENT_STATUS_ALLOW='allow';export var COOKIE_CONSENT_STATUS_DENY='deny';export var COOKIE_CONSENT_PREF_NEEDED='needed';export var COOKIE_CONSENT_PREF_ANALYTICS='analytics';export var COOKIE_CONSENT_MODE_OFF='off';export var COOKIE_CONSENT_MODE_STANDARD='standard';export var COOKIE_CONSENT_MODE_STRICT='strict';export var INITIALIZE_TRACKING='INITIALIZE_TRACKING';// PWA6 cookie consent constants
2
1
  export var SHOW_COOKIE_CONSENT_MODAL='SHOW_COOKIE_CONSENT_MODAL';export var HIDE_COOKIE_CONSENT_MODAL='HIDE_COOKIE_CONSENT_MODAL';export var UPDATE_COOKIE_CONSENT='UPDATE_COOKIE_CONSENT';export var COOKIE_CONSENT_HANDLED='COOKIE_CONSENT_HANDLED';export var PRIVACY_SETTINGS_PATTERN='/privacy-settings';
@@ -0,0 +1,6 @@
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{HIDE_COOKIE_CONSENT_MODAL,SHOW_COOKIE_CONSENT_MODAL}from"../constants";var defaultState={isCookieConsentModalVisible:false};/**
2
+ * Stores all states of the cookie consent modal.
3
+ * @param {Object} [state] The current state.
4
+ * @param {Object} action The action object.
5
+ * @return {Object} The new state.
6
+ */var cookieConsentModalReducer=function cookieConsentModalReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case SHOW_COOKIE_CONSENT_MODAL:{return _extends({},state,{isCookieConsentModalVisible:true});}case HIDE_COOKIE_CONSENT_MODAL:{return _extends({},state,{isCookieConsentModalVisible:false});}default:return state;}};export default cookieConsentModalReducer;
@@ -0,0 +1,6 @@
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{UPDATE_COOKIE_CONSENT}from"../constants";var defaultState={comfortCookiesAccepted:null,statisticsCookiesAccepted:null};/**
2
+ * Stores all states of the cookie settings.
3
+ * @param {Object} [state] The current state.
4
+ * @param {Object} action The action object.
5
+ * @return {Object} The new state.
6
+ */var cookieSettingsReducer=function cookieSettingsReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case UPDATE_COOKIE_CONSENT:{return _extends({},state,{comfortCookiesAccepted:action.comfortCookiesAccepted,statisticsCookiesAccepted:action.statisticsCookiesAccepted});}default:return state;}};export default cookieSettingsReducer;
@@ -0,0 +1 @@
1
+ import{combineReducers}from'redux';import cookieConsentModal from"./cookieConsentModal";import cookieSettings from"./cookieSettings";export default combineReducers({cookieConsentModal:cookieConsentModal,cookieSettings:cookieSettings});
@@ -0,0 +1,35 @@
1
+ import{createSelector}from'reselect';import{appConfig}from'@shopgate/engage';import{appSupportsCookieConsent}from'@shopgate/engage/core/helpers';var _appConfig$cookieCons=appConfig.cookieConsent,_appConfig$cookieCons2=_appConfig$cookieCons===void 0?{}:_appConfig$cookieCons,isCookieConsentActivated=_appConfig$cookieCons2.isCookieConsentActivated,showComfortCookiesToggle=_appConfig$cookieCons2.showComfortCookiesToggle;/**
2
+ * Selects the cookie consent modal state.
3
+ * @param {Object} state The current state of the cookie consent modal.
4
+ * @returns {Object} whether cookie consent modal is shown.
5
+ */export var getCookieConsentModalState=function getCookieConsentModalState(state){var _state$tracking;return(state===null||state===void 0?void 0:(_state$tracking=state.tracking)===null||_state$tracking===void 0?void 0:_state$tracking.cookieConsentModal)||{};};/**
6
+ * Selects the cookie settings state.
7
+ * @param {Object} state The current state of the cookie settings.
8
+ * @returns {Object} whether cookies have been accepted by the user.
9
+ */export var getCookieSettingsState=function getCookieSettingsState(state){var _state$tracking2;return(state===null||state===void 0?void 0:(_state$tracking2=state.tracking)===null||_state$tracking2===void 0?void 0:_state$tracking2.cookieSettings)||{};};/**
10
+ * Determines whether the cookie consent process is finished (selection happened before, feature is
11
+ * inactive, app doesn't support the feature).
12
+ * @returns {boolean} Whether the cookie consent process is handled either by user
13
+ * or by app/feature settings
14
+ */export var getIsCookieConsentHandled=createSelector(getCookieSettingsState,function(settingsState){if(!isCookieConsentActivated||!appSupportsCookieConsent()){return true;}return(settingsState===null||settingsState===void 0?void 0:settingsState.comfortCookiesAccepted)!==null||(settingsState===null||settingsState===void 0?void 0:settingsState.statisticsCookiesAccepted)!==null;});/**
15
+ * Selects the property of the comfort cookie settings.
16
+ * @private This selector is intended to be used internally. When a cookie consent status needs
17
+ * to be checked for a feature, please use `getAreComfortCookiesAccepted` instead.
18
+ * @returns {boolean|null} whether comfort cookies have been selected by the user.
19
+ */export var getAreComfortCookiesAcceptedInternal=createSelector(getCookieSettingsState,function(settingsState){return settingsState.comfortCookiesAccepted;});/**
20
+ * Selects the property of the statistics cookie settings.
21
+ * @private This selector is intended to be used internally. When a cookie consent status needs
22
+ * to be checked for a feature, please use `getAreStatisticsCookiesAccepted` instead.
23
+ * @returns {boolean|null} whether statistics cookies have been selected by the user.
24
+ */export var getAreStatisticsCookiesAcceptedInternal=createSelector(getCookieSettingsState,function(settingsState){return settingsState.statisticsCookiesAccepted;});/**
25
+ * Determines if comfort cookies were accepted in the cookie consent process. When cookie
26
+ * consent is inactive, the selector will also return true.
27
+ * @returns {boolean} whether comfort cookies are set and should activate tracking.
28
+ */export var getAreComfortCookiesAccepted=createSelector(getCookieSettingsState,getIsCookieConsentHandled,function(settingsState,consentHandled){if(!consentHandled)return false;if(!isCookieConsentActivated||!showComfortCookiesToggle)return true;if(settingsState.comfortCookiesAccepted===null)return true;return settingsState.comfortCookiesAccepted;});/**
29
+ * Determines if statistics cookies were accepted in the cookie consent process. When cookie
30
+ * consent is inactive, the selector will also return true.
31
+ * @returns {boolean} whether statistics cookies are set and should activate tracking.
32
+ */export var getAreStatisticsCookiesAccepted=createSelector(getCookieSettingsState,getIsCookieConsentHandled,function(settingsState,consentHandled){if(!consentHandled)return false;if(!isCookieConsentActivated)return true;if(settingsState.statisticsCookiesAccepted===null)return true;return settingsState.statisticsCookiesAccepted;});/**
33
+ * Selects the visibility property of the cookie consent modal.
34
+ * @returns {boolean} whether cookie consent modal is shown.
35
+ */export var getIsCookieConsentModalVisible=createSelector(getCookieConsentModalState,getAreComfortCookiesAcceptedInternal,getAreStatisticsCookiesAcceptedInternal,function(modalState,comfortCookiesState,statisticsCookiesState){return modalState.isCookieConsentModalVisible&&comfortCookiesState===null&&statisticsCookiesState===null;});
@@ -1,4 +1 @@
1
- import{createSelector}from'reselect';import{makeGetMenu,makeGetIsFetchingMenu,makeGetShopSettingByKey,SHOP_SETTING_COOKIE_CONSENT_MODE,hasWebBridge}from'@shopgate/engage/core';import{LEGAL_MENU}from'@shopgate/pwa-common/constants/MenuIDs';import{COOKIE_CONSENT_MODE_OFF,COOKIE_CONSENT_MODE_STANDARD,COOKIE_CONSENT_MODE_STRICT}from"../constants";/**
2
- * Creates a selector that retrieves the privacy polity link.
3
- * @returns {string}
4
- */export var makeGetPrivacyPolicyLink=function makeGetPrivacyPolicyLink(){var getMenu=makeGetMenu(LEGAL_MENU);var getIsFetchingMenu=makeGetIsFetchingMenu(LEGAL_MENU);return createSelector(getMenu,getIsFetchingMenu,function(menu,fetching){if(fetching||!menu){return null;}var entry=menu.find(function(item){return item.url.includes('privacy');})||{};return(entry===null||entry===void 0?void 0:entry.url)||null;});};var getCookieConsentShopSetting=makeGetShopSettingByKey(SHOP_SETTING_COOKIE_CONSENT_MODE,COOKIE_CONSENT_MODE_OFF);export var hasCookieConsent=createSelector(getCookieConsentShopSetting,function(setting){if(!hasWebBridge()){return false;}return[COOKIE_CONSENT_MODE_STANDARD,COOKIE_CONSENT_MODE_STRICT].includes(setting);});export var hasStrictCookieConsent=createSelector(getCookieConsentShopSetting,function(setting){return setting===COOKIE_CONSENT_MODE_STRICT;});
1
+ export{getAreComfortCookiesAccepted}from"./cookieConsent";export{getAreStatisticsCookiesAccepted}from"./cookieConsent";
@@ -0,0 +1,46 @@
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);}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import{main$,routeWillEnter$}from'@shopgate/engage/core/streams';import'rxjs/add/observable/of';import{Observable}from'rxjs/Observable';import{makeGetPrivacyPolicyLink}from'@shopgate/engage/page/selectors';import{COOKIE_CONSENT_HANDLED,UPDATE_COOKIE_CONSENT,PRIVACY_SETTINGS_PATTERN}from"../constants";import{getIsCookieConsentHandled}from"../selectors/cookieConsent";/**
2
+ * Gets triggered when the cookie consent has been updated by the user or handled already.
3
+ * This stream is only for internal usage and will be triggered independent of changed payload.
4
+ * @type {Observable}
5
+ */var cookieConsentSetInternal$=main$.filter(function(_ref){var action=_ref.action;return action.type===UPDATE_COOKIE_CONSENT||action.type===COOKIE_CONSENT_HANDLED;});/**
6
+ * Gets triggered when the cookie consent has been initially configured by the user or is
7
+ * handled already.
8
+ * @type {Observable}
9
+ */export var cookieConsentInitialized$=cookieConsentSetInternal$.first();/**
10
+ * Gets triggered when the cookie consent was initialized / handled by user. In that case
11
+ * the UPDATE_COOKIE_CONSENT action is dispatched. When handled automatically the
12
+ * COOKIE_CONSENT_HANDLED action is dispatched.
13
+ */export var cookieConsentInitializedByUserInternal$=cookieConsentInitialized$.filter(function(_ref2){var action=_ref2.action;return action.type===UPDATE_COOKIE_CONSENT;});/**
14
+ * Gets triggered when the user interacted with the buttons on the privacy settings page,
15
+ * but no settings was changed. Needed to navigate back to the previous page.
16
+ * When a setting was changed, the "cookieConsentUpdated$" stream triggers which will cause
17
+ * an app reload.
18
+ * @type {Observable}
19
+ */export var privacySettingsConfirmedWithoutChangeInternal$=cookieConsentSetInternal$.pairwise().filter(function(_ref3){var _ref4=_slicedToArray(_ref3,2),actionPrev=_ref4[0].action,actionCurrent=_ref4[1].action;return actionPrev.comfortCookiesAccepted===actionCurrent.comfortCookiesAccepted&&actionPrev.statisticsCookiesAccepted===actionCurrent.statisticsCookiesAccepted;}).switchMap(function(_ref5){var _ref6=_slicedToArray(_ref5,2),latest=_ref6[1];return Observable.of(latest);});/**
20
+ * Gets triggered when cookie consent settings changed after initialization
21
+ * @type {Observable}
22
+ */export var cookieConsentUpdated$=cookieConsentSetInternal$.pairwise().filter(function(_ref7){var _ref8=_slicedToArray(_ref7,2),actionPrev=_ref8[0].action,actionCurrent=_ref8[1].action;return actionPrev.comfortCookiesAccepted!==actionCurrent.comfortCookiesAccepted||actionPrev.statisticsCookiesAccepted!==actionCurrent.statisticsCookiesAccepted;}).switchMap(function(_ref9){var _ref10=_slicedToArray(_ref9,2),latest=_ref10[1];return Observable.of(latest);});/**
23
+ * Gets triggered when the cookie consent has been updated by the user or handled already.
24
+ * @type {Observable}
25
+ */export var cookieConsentSet$=cookieConsentInitialized$.merge(cookieConsentUpdated$);/**
26
+ * Gets triggered when the cookie consent has been set either by user or merchant.
27
+ * @type {Observable}
28
+ */export var comfortCookiesAccepted$=cookieConsentSet$.filter(function(_ref11){var action=_ref11.action;return action.comfortCookiesAccepted===true;});/**
29
+ * Gets triggered when the cookie consent has been set either by user or merchant.
30
+ * @type {Observable}
31
+ */export var statisticsCookiesAccepted$=cookieConsentSet$.filter(function(_ref12){var action=_ref12.action;return action.statisticsCookiesAccepted===true;});/**
32
+ * Gets triggered when comfort cookies where accepted first and declined afterwards during an
33
+ * app session.
34
+ * @type {Observable}
35
+ */export var comfortCookiesDeclined$=comfortCookiesAccepted$.switchMap(function(){return cookieConsentSet$.filter(function(_ref13){var action=_ref13.action;return action.comfortCookiesAccepted===false;}).first();});/**
36
+ * Gets triggered when statistics cookies where accepted first and declined afterwards during an
37
+ * app session.
38
+ * @type {Observable}
39
+ */export var statisticsCookiesDeclined$=statisticsCookiesAccepted$.switchMap(function(){return cookieConsentSet$.filter(function(_ref14){var action=_ref14.action;return action.statisticsCookiesAccepted===false;}).first();});/**
40
+ * Emit when the cookie consent modal is supposed to be shown / hidden on route changes.
41
+ *
42
+ * When cookie consent is not handled yet, the modal should overlay every route, except the
43
+ * pages with privacy polity and privacy settings when extended consent decisions are taken.
44
+ */export var cookieConsentModalShouldToggleInternal$=routeWillEnter$// Stop the stream after cookie consent is handled
45
+ .takeUntil(cookieConsentInitialized$).switchMap(function(input){var action=input.action,getState=input.getState;var isCookieConsentHandled=getIsCookieConsentHandled(getState());var showConsentModal=false;// Only run extended logic when cookie consent is active and still need to be handled
46
+ if(!isCookieConsentHandled){var _action$route;var pagesWithoutModal=[PRIVACY_SETTINGS_PATTERN,makeGetPrivacyPolicyLink()(getState())];showConsentModal=!pagesWithoutModal.includes(action===null||action===void 0?void 0:(_action$route=action.route)===null||_action$route===void 0?void 0:_action$route.pathname);}return Observable.of(_extends({},input,{showConsentModal:showConsentModal}));});
@@ -1 +1 @@
1
- import{main$}from'@shopgate/pwa-common/streams';import{INITIALIZE_TRACKING}from"../constants";export var initializeTracking$=main$.filter(function(_ref){var action=_ref.action;return action.type===INITIALIZE_TRACKING;});
1
+ export{cookieConsentInitialized$,cookieConsentUpdated$,cookieConsentSet$,comfortCookiesAccepted$,comfortCookiesDeclined$,statisticsCookiesAccepted$,statisticsCookiesDeclined$}from"./cookieConsent";
@@ -0,0 +1,11 @@
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{reloadApp}from'@shopgate/engage/core/action-creators';import{appSupportsCookieConsent,hasSGJavaScriptBridge}from'@shopgate/engage/core/helpers';import{analyticsSetConsent}from'@shopgate/engage/core/commands';import{cookieConsentInitialized$,cookieConsentUpdated$}from"../streams";/**
2
+ * Analytics subscriptions
3
+ * @param {Function} subscribe The subscribe function
4
+ */export default function analytics(subscribe){/**
5
+ * Sends cookie consent decisions to the app
6
+ * @param {Object} params Function params
7
+ * @param {Object} params.action Cookie consent update action
8
+ */var sendConsentToApp=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref){var action,statisticsCookiesAccepted,comfortCookiesAccepted;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:action=_ref.action;if(!(!appSupportsCookieConsent()||!hasSGJavaScriptBridge())){_context.next=3;break;}return _context.abrupt("return");case 3:statisticsCookiesAccepted=action.statisticsCookiesAccepted,comfortCookiesAccepted=action.comfortCookiesAccepted;// Send consent decisions to the app
9
+ _context.next=6;return analyticsSetConsent({statistics:statisticsCookiesAccepted,comfort:comfortCookiesAccepted});case 6:case"end":return _context.stop();}},_callee);}));return function sendConsentToApp(_x){return _ref2.apply(this,arguments);};}();subscribe(cookieConsentInitialized$,/*#__PURE__*/function(){var _ref4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3){var action;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:action=_ref3.action;_context2.next=3;return sendConsentToApp({action:action});case 3:case"end":return _context2.stop();}},_callee2);}));return function(_x2){return _ref4.apply(this,arguments);};}());subscribe(cookieConsentUpdated$,/*#__PURE__*/function(){var _ref6=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref5){var dispatch,action;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:dispatch=_ref5.dispatch,action=_ref5.action;_context3.next=3;return sendConsentToApp({action:action});case 3:// The PWA is reloaded whenever cookie consent settings changed to guarantee that all trackers
10
+ // are turned off
11
+ dispatch(reloadApp());case 4:case"end":return _context3.stop();}},_callee3);}));return function(_x3){return _ref6.apply(this,arguments);};}());}
@@ -0,0 +1,13 @@
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{appDidStart$}from'@shopgate/engage/core/streams';import{appSupportsCookieConsent}from'@shopgate/engage/core/helpers';import{grantAppTrackingTransparencyPermission,historyReset,historyPop}from'@shopgate/engage/core/actions';import{handleCookieConsent,showCookieConsentModal,hideCookieConsentModal}from"../action-creators";import{getIsCookieConsentHandled,getAreComfortCookiesAccepted,getAreStatisticsCookiesAccepted}from"../selectors/cookieConsent";import{cookieConsentInitializedByUserInternal$,privacySettingsConfirmedWithoutChangeInternal$,cookieConsentModalShouldToggleInternal$}from"../streams/cookieConsent";/**
2
+ * determine whether to show the cookie consent modal at app start
3
+ * @param {Function} subscribe The subscribe function
4
+ */export default function cookieConsent(subscribe){subscribe(appDidStart$,/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref){var dispatch,getState,state,isCookieConsentHandled,comfortCookiesAccepted,statisticsCookiesAccepted;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:dispatch=_ref.dispatch,getState=_ref.getState;state=getState();isCookieConsentHandled=getIsCookieConsentHandled(state);/**
5
+ * if merchant has not activated the cookie feature OR if merchant has activated cookie feature
6
+ * and user has chosen cookies already trigger stream to run code that depends on the cookie
7
+ * consent.
8
+ */if(!isCookieConsentHandled){_context.next=12;break;}comfortCookiesAccepted=getAreComfortCookiesAccepted(state);statisticsCookiesAccepted=getAreStatisticsCookiesAccepted(state);dispatch(handleCookieConsent({comfortCookiesAccepted:comfortCookiesAccepted,statisticsCookiesAccepted:statisticsCookiesAccepted}));if(!(appSupportsCookieConsent()&&(comfortCookiesAccepted||statisticsCookiesAccepted))){_context.next=10;break;}_context.next=10;return dispatch(grantAppTrackingTransparencyPermission());case 10:_context.next=13;break;case 12:// if merchant has activated cookie feature but user has not chosen cookies yet:
9
+ // show cookie consent modal to make user choose them
10
+ dispatch(showCookieConsentModal());case 13:case"end":return _context.stop();}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}());subscribe(cookieConsentInitializedByUserInternal$,function(_ref3){var dispatch=_ref3.dispatch;// Reset history after consent initialization to guarantee an empty history
11
+ dispatch(historyReset());});subscribe(privacySettingsConfirmedWithoutChangeInternal$,function(_ref4){var dispatch=_ref4.dispatch;// Remove privacy settings route from route stack when any button was clicked but no settings
12
+ // where changed. When something was changed, app will reset via the "analytics" streams.
13
+ dispatch(historyPop());});subscribe(cookieConsentModalShouldToggleInternal$,function(_ref5){var dispatch=_ref5.dispatch,showConsentModal=_ref5.showConsentModal;dispatch(showConsentModal?showCookieConsentModal():hideCookieConsentModal());});}
@@ -1,4 +1 @@
1
- import{appDidStart$}from'@shopgate/engage/core';import{isTrackingAllowed}from"../helpers";import{hasCookieConsent}from"../selectors";import{initTracking}from"../action-creators";/**
2
- * Orders subscriptions.
3
- * @param {Function} subscribe The subscribe function.
4
- */var tracking=function tracking(subscribe){subscribe(appDidStart$,function(_ref){var getState=_ref.getState,dispatch=_ref.dispatch;var hasConsent=hasCookieConsent(getState());if(!hasConsent||isTrackingAllowed()){dispatch(initTracking());}});};export default tracking;
1
+ import analytics from"./analytics";import cookieConsent from"./cookieConsent";export default(function(subscribe){analytics(subscribe);cookieConsent(subscribe);});
@@ -1,5 +0,0 @@
1
- import{useWidgetSettings}from"../../../core";/**
2
- * @param {Object} [productStock={}] product.stock object
3
- * @returns {Object}
4
- */export var getQuantityRange=function getQuantityRange(){var productStock=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var settings=useWidgetSettings('@shopgate/engage/product/QuantityPicker');var min=settings.minOrderQuantity;if(productStock.minOrderQuantity>0){min=productStock.minOrderQuantity;}var max=settings.maxOrderQuantity;if(productStock.maxOrderQuantity>0){max=Math.min(Math.max(min,settings.maxOrderQuantity),productStock.maxOrderQuantity);}// Normalize min if max is finally less then min
5
- min=Math.min(min,max);return{min:min,max:max};};
@@ -1,4 +0,0 @@
1
- import{connect}from'react-redux';import{hasCookieConsent}from"../../selectors";/**
2
- * Creates the mapStateToProps connector function.
3
- * @returns {Function}
4
- */var makeMapStateToProps=function makeMapStateToProps(){return function(state){return{hasCookieConsent:hasCookieConsent(state)};};};export default connect(makeMapStateToProps);
@@ -1,4 +0,0 @@
1
- import React from'react';import PropTypes from'prop-types';import CookieConsentProvider from"../../providers/CookieConsentProvider";import CookieConsentContent from"./CookieConsentContent";import connect from"./CookieConsent.connector";/**
2
- * The CookieConsent component
3
- * @returns {JSX}
4
- */var CookieConsent=function CookieConsent(_ref){var hasCookieConsent=_ref.hasCookieConsent;if(!hasCookieConsent){return null;}return React.createElement(CookieConsentProvider,null,React.createElement(CookieConsentContent,null));};CookieConsent.defaultProps={hasCookieConsent:false};export default connect(CookieConsent);
@@ -1,3 +0,0 @@
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;}import React from'react';import classNames from'classnames';import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{responsiveMediaQuery}from'@shopgate/engage/styles';import{RippleButton,I18n}from'@shopgate/engage/components';import{useCookieConsent}from"../../hooks";var variables=themeConfig.variables;var styles={container:css(_defineProperty({display:'flex',justifyContent:'flex-end'},responsiveMediaQuery('<sm'),{justifyContent:'flex-start'})).toString(),button:css({borderRadius:'6px !important',margin:"0 ".concat(variables.gap.small,"px"),fontSize:'.875rem !important',whiteSpace:'nowrap'}).toString(),buttonSecondary:css(_defineProperty({},responsiveMediaQuery('<sm'),{marginLeft:0,paddingLeft:0,' > div':{paddingLeft:0}})).toString(),buttonPrimary:css({minWidth:'150px !important'}).toString(),labelSelected:css({color:'var(--color-text-medium-emphasis)'}).toString()};/**
2
- * @returns {JSX}
3
- */var CookieConsentButtons=function CookieConsentButtons(){var _useCookieConsent=useCookieConsent(),onClickSecondary=_useCookieConsent.onClickSecondary,onClickPrimary=_useCookieConsent.onClickPrimary,buttonLabels=_useCookieConsent.buttonLabels;return React.createElement("div",{className:styles.container},React.createElement(RippleButton,{className:classNames(styles.button,styles.buttonSecondary),flat:true,onClick:onClickSecondary},React.createElement(I18n.Text,{string:buttonLabels.secondary,className:styles.labelSelected})),React.createElement(RippleButton,{className:classNames(styles.button,styles.buttonPrimary),type:"secondary",onClick:onClickPrimary},React.createElement(I18n.Text,{string:buttonLabels.primary})));};export default CookieConsentButtons;
@@ -1,3 +0,0 @@
1
- import React from'react';import{css}from'glamor';import classNames from'classnames';import{Checkbox}from'@shopgate/pwa-ui-shared';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{i18n}from'@shopgate/engage/core';import{useCookieConsent}from"../../hooks";var variables=themeConfig.variables,colors=themeConfig.colors;var styles={container:css({display:'flex',alignItems:'center'}),label:css({fontWeight:500,marginRight:variables.gap.big}).toString(),checkboxContainer:css({display:'flex',padding:"0 ".concat(variables.gap.small,"px"),alignItems:'center',' > svg':{maxWidth:'inherit'}}).toString(),checkbox:css({marginLeft:variables.gap.xsmall,cursor:'pointer'}).toString(),checked:css({color:'var(--color-primary)'}).toString(),unchecked:css({color:colors.shade6}).toString(),disabled:css({opacity:0.5,color:colors.shade6,cursor:'not-allowed'}).toString()};/**
2
- * @returns {JSX}
3
- */var CookieConsentCheckboxes=function CookieConsentCheckboxes(){var _useCookieConsent=useCookieConsent(),allowAnalytics=_useCookieConsent.allowAnalytics,onClickAllowAnalytics=_useCookieConsent.onClickAllowAnalytics;return React.createElement("div",{className:styles.container},React.createElement("span",{className:styles.label},"".concat(i18n.text('tracking.cookieConsent.preferences'),":")),React.createElement(Checkbox,{checked:true,disabled:true,className:styles.checkboxContainer,checkedClassName:classNames(styles.disabled,styles.checkbox),label:i18n.text('tracking.cookieConsent.needed'),labelPosition:"left"}),React.createElement(Checkbox,{checked:allowAnalytics,className:styles.checkboxContainer,checkedClassName:classNames(styles.checkbox,styles.checked),unCheckedClassName:classNames(styles.checkbox,styles.unchecked),onCheck:onClickAllowAnalytics,label:i18n.text('tracking.cookieConsent.analytics'),labelPosition:"left"}));};export default CookieConsentCheckboxes;
@@ -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);}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _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,{useState}from'react';import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{responsiveMediaQuery}from'@shopgate/engage/styles';import Transition from'react-transition-group/Transition';import{useCookieConsent}from"../../hooks";import CookieConsentMessage from"./CookieConsentMessage";import CookieConsentButtons from"./CookieConsentButtons";import CookieConsentCheckboxes from"./CookieConsentCheckboxes";var variables=themeConfig.variables,colors=themeConfig.colors;var containerPadding=12;var styles={container:css({fontSize:'.875rem',position:'fixed',background:'var(--color-background-accent)',borderTop:"1px solid ".concat(colors.shade7),bottom:0,zIndex:10000,width:'100%',display:'flex',justifyContent:'center',padding:"".concat(containerPadding,"px ").concat(containerPadding,"px calc(var(--safe-area-inset-bottom) + ").concat(containerPadding,"px) ").concat(variables.gap.big,"px"),userSelect:'none'}),content:css(_defineProperty(_defineProperty({display:'grid',gridTemplateColumns:'auto 1fr',gridTemplateRows:'auto auto',gridTemplateAreas:"\n \"message buttons\"\n \"checkboxes buttons\"\n ",rowGap:12,width:'100%'},responsiveMediaQuery('>=sm',{webOnly:true}),{width:'calc(var(--page-content-width) + 208px)'}),responsiveMediaQuery('<sm'),{gridTemplateColumns:'auto',gridTemplateRows:'auto auto auto',gridTemplateAreas:"\n \"message\"\n \"checkboxes\"\n \"buttons\"\n "})),message:css({gridArea:'message'}),buttons:css(_defineProperty({gridArea:'buttons'},responsiveMediaQuery('>=sm'),{justifySelf:'end'})),checkboxes:css({gridArea:'checkboxes'})};var transitionDuration=500;var defaultTransitionStyle={transition:"opacity ".concat(transitionDuration,"ms ease-in-out"),opacity:1};var transitionStyles={entering:{opacity:1},entered:{opacity:1},exiting:{opacity:0},exited:{opacity:0}};/**
2
- * The CookieConsentContent component
3
- * @returns {JSX}
4
- */var CookieConsentContent=function CookieConsentContent(){var _useCookieConsent=useCookieConsent(),isVisible=_useCookieConsent.isVisible;var _useState=useState(isVisible),_useState2=_slicedToArray(_useState,1),wasVisible=_useState2[0];if(!wasVisible){return null;}return React.createElement(Transition,{"in":isVisible,unmountOnExit:true,timeout:transitionDuration},function(state){return React.createElement("div",{className:styles.container,style:_extends({},defaultTransitionStyle,{},transitionStyles[state])},React.createElement("div",{className:styles.content},React.createElement("div",{className:styles.message},React.createElement(CookieConsentMessage,null)),React.createElement("div",{className:styles.buttons},React.createElement(CookieConsentButtons,null)),React.createElement("div",{className:styles.checkboxes},React.createElement(CookieConsentCheckboxes,null))));});};export default CookieConsentContent;
@@ -1,4 +0,0 @@
1
- import React,{Fragment}from'react';import{i18n}from'@shopgate/engage/core/helpers/i18n';import{TextLink,I18n}from'@shopgate/engage/components';import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{useCookieConsent}from"../../hooks";var variables=themeConfig.variables;var styles={container:css({}),message:css({paddingRight:variables.gap.xsmall}).toString(),link:css({textDecoration:'underline'}).toString()};/**
2
- * The CookieConsentMessage component
3
- * @returns {JSX}
4
- */var CookieConsentMessage=function CookieConsentMessage(){var _useCookieConsent=useCookieConsent(),privacyPolicyLink=_useCookieConsent.privacyPolicyLink;return React.createElement("div",{className:styles.container},React.createElement(I18n.Text,{string:"tracking.cookieConsent.message",className:styles.message}),privacyPolicyLink&&React.createElement(Fragment,null,React.createElement(TextLink,{className:styles.link,href:privacyPolicyLink},i18n.text('tracking.cookieConsent.learnMore')),"."));};export default CookieConsentMessage;