@shopgate/engage 7.20.0-beta.2 → 7.20.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/account/actions/addContacts.js +1 -1
- package/account/actions/deleteContact.js +1 -1
- package/account/actions/deleteCustomer.js +1 -1
- package/account/actions/fetchContacts.js +1 -1
- package/account/actions/fetchCustomer.js +1 -1
- package/account/actions/updateContact.js +1 -1
- package/account/actions/updateCustomer.js +1 -1
- package/account/reducers/index.js +2 -2
- package/cart/cart.helpers.js +8 -1
- package/cart/components/CartItem/CartItemProductLayout.js +2 -1
- package/cart/index.js +2 -1
- package/cart/streams/index.js +1 -0
- package/checkout/components/Checkout/CheckoutPickupContactForm.config.js +1 -1
- package/checkout/components/GuestCheckout/GuestCheckoutPickupNotes.config.js +1 -1
- package/checkout/components/index.js +1 -1
- package/checkout/constants/index.js +1 -1
- package/checkout/index.js +3 -4
- package/checkout/paymentMethods/stripe/sdk.js +3 -2
- package/components/ConditionalWrapper/ConditionalWrapper.js +7 -2
- package/components/QuantityInput/QuantityInput.js +1 -1
- package/core/constants/index.js +1 -1
- package/core/helpers/appFeatures.js +2 -1
- package/core/helpers/i18n.js +1 -1
- package/core/helpers/index.js +1 -1
- package/core/subscriptions/app.js +2 -2
- package/favorites/components/Item/Item.js +3 -3
- package/favorites/components/List/List.js +17 -6
- package/favorites/components/List/ListAccordionLabel.js +4 -0
- package/favorites/components/List/ListContent.js +8 -0
- package/favorites/components/List/ListItemWrapper.js +6 -0
- package/favorites/components/List/styles.js +1 -0
- package/favorites/components/Lists/Lists.js +4 -4
- package/favorites/components/Lists/ListsModal.js +3 -2
- package/favorites/constants/index.js +1 -0
- package/filter/actions/index.js +1 -0
- package/filter/components/index.js +1 -0
- package/filter/constants/index.js +1 -1
- package/filter/helpers/buildInitialFilters.js +1 -1
- package/filter/helpers/translateFilterLabel.js +3 -3
- package/filter/index.js +2 -7
- package/filter/selectors/index.js +1 -1
- package/filter/streams/index.js +1 -0
- package/locations/subscriptions.js +2 -2
- package/orders/index.js +1 -1
- package/package.json +7 -7
- package/page/selectors/index.js +7 -1
- package/product/components/ProductSlider/index.js +1 -1
- package/product/components/QuantityPicker/hooks.js +5 -0
- package/product/components/QuantityPicker/index.js +2 -2
- package/product/components/UnitQuantityPicker/CartUnitQuantityPicker.js +2 -2
- package/product/components/UnitQuantityPicker/ProductUnitQuantityPicker.js +3 -2
- package/product/components/UnitQuantityPicker/UnitQuantityPicker.js +6 -3
- package/product/components/UnitQuantityPicker/UnitQuantityPickerWithSection.js +7 -0
- package/product/components/UnitQuantityPicker/index.js +1 -1
- package/product/components/index.js +1 -1
- package/product/providers/ProductListType/context.js +2 -1
- package/product/providers/ProductListType/index.js +2 -1
- package/product/providers/index.js +1 -1
- package/push-opt-in/components/PushOptInModal/index.js +5 -6
- package/push-opt-in/subscriptions/optInTrigger.js +3 -5
- package/registration/components/index.js +1 -0
- package/registration/index.js +1 -1
- package/registration/streams/index.js +4 -0
- package/registration/subscriptions/index.js +4 -4
- package/styles/helpers/initCSSCustomProperties.js +2 -2
- package/styles/helpers/setPageBackgroundColor.js +2 -1
- package/tracking/action-creators/cookieConsent.js +24 -0
- package/tracking/action-creators/index.js +1 -4
- package/tracking/actions/cookieConsent.js +21 -0
- package/tracking/actions/index.js +1 -0
- package/tracking/components/CookieConsentModal/connector.js +6 -0
- package/tracking/components/CookieConsentModal/index.js +9 -0
- package/tracking/components/CookieConsentModal/style.js +1 -0
- package/tracking/components/CookieConsentModal/tracking-opt-in.svg +18 -0
- package/tracking/components/PrivacySettings/connector.js +6 -0
- package/tracking/components/PrivacySettings/index.js +4 -0
- package/tracking/components/PrivacySettings/style.js +1 -0
- package/tracking/components/index.js +1 -1
- package/tracking/constants/index.js +0 -1
- package/tracking/reducers/cookieConsentModal.js +6 -0
- package/tracking/reducers/cookieSettings.js +6 -0
- package/tracking/reducers/index.js +1 -0
- package/tracking/selectors/cookieConsent.js +35 -0
- package/tracking/selectors/index.js +1 -4
- package/tracking/streams/cookieConsent.js +46 -0
- package/tracking/streams/index.js +1 -1
- package/tracking/subscriptions/analytics.js +11 -0
- package/tracking/subscriptions/cookieConsent.js +13 -0
- package/tracking/subscriptions/index.js +1 -4
- package/user/index.js +1 -1
- package/product/components/QuantityPicker/helpers.js +0 -5
- package/tracking/components/CookieConsent/CookieConsent.connector.js +0 -4
- package/tracking/components/CookieConsent/CookieConsent.js +0 -4
- package/tracking/components/CookieConsent/CookieConsentButtons.js +0 -3
- package/tracking/components/CookieConsent/CookieConsentCheckboxes.js +0 -3
- package/tracking/components/CookieConsent/CookieConsentContent.js +0 -4
- package/tracking/components/CookieConsent/CookieConsentMessage.js +0 -4
- package/tracking/components/CookieConsent/index.js +0 -1
- package/tracking/helpers/index.js +0 -7
- package/tracking/hooks/index.js +0 -4
- package/tracking/index.js +0 -1
- package/tracking/providers/CookieConsentProvider.connector.js +0 -4
- package/tracking/providers/CookieConsentProvider.context.js +0 -1
- package/tracking/providers/CookieConsentProvider.js +0 -8
- /package/product/{components/ProductProvider → providers/Product}/connector.js +0 -0
- /package/product/{components/ProductProvider → providers/Product}/index.js +0 -0
|
@@ -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{
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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);});
|
package/user/index.js
CHANGED
|
@@ -3,4 +3,4 @@ export{disableLogin}from'@shopgate/pwa-common/action-creators/user';// ACTIONS
|
|
|
3
3
|
export{default as fetchRegisterUrl}from'@shopgate/pwa-common/actions/user/fetchRegisterUrl';export{default as fetchUser}from'@shopgate/pwa-common/actions/user/fetchUser';export{default as login}from'@shopgate/pwa-common/actions/user/login';export{default as logout}from'@shopgate/pwa-common/actions/user/logout';// CONSTANTS
|
|
4
4
|
export*from'@shopgate/pwa-common/constants/Registration';export*from'@shopgate/pwa-common/constants/user';export{REGISTER_PATH,LOGIN_PATH};// SELECTORS
|
|
5
5
|
export*from'@shopgate/pwa-common/selectors/user';export*from"./selectors/login";export*from"./selectors/data";// STREAMS
|
|
6
|
-
export*from'@shopgate/pwa-common/streams/user';
|
|
6
|
+
export*from'@shopgate/pwa-common/streams/user';export{registrationSuccess$}from'@shopgate/engage/registration/streams';
|
|
@@ -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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{default as CookieConsent}from"./CookieConsent";
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{COOKIE_CONSENT_COOKIE_NAME_STATUS,COOKIE_CONSENT_COOKIE_NAME_PREFS,COOKIE_CONSENT_STATUS_ALLOW,COOKIE_CONSENT_PREF_ANALYTICS}from"../constants";/**
|
|
2
|
-
* @param {string} name The cookie name
|
|
3
|
-
* @returns {string}
|
|
4
|
-
*/var getCookieValue=function getCookieValue(name){var b=document.cookie.match("(^|;)\\s*".concat(name,"\\s*=\\s*([^;]+)"));return b?b.pop():'';};/**
|
|
5
|
-
* Checks if tracking is allowed
|
|
6
|
-
* @returns {bool}
|
|
7
|
-
*/export var isTrackingAllowed=function isTrackingAllowed(){var status=getCookieValue(COOKIE_CONSENT_COOKIE_NAME_STATUS);var prefs=getCookieValue(COOKIE_CONSENT_COOKIE_NAME_PREFS);if(status!==COOKIE_CONSENT_STATUS_ALLOW){return false;}try{prefs=JSON.parse(decodeURIComponent(prefs));if(!Array.isArray(prefs)){prefs=[];}}catch(e){prefs=[];}return prefs.includes(COOKIE_CONSENT_PREF_ANALYTICS);};
|
package/tracking/hooks/index.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import React from'react';import CookieConsent from"../providers/CookieConsentProvider.context";/**
|
|
2
|
-
* Returns the value of the cookie consent provider state.
|
|
3
|
-
* @returns {Object}
|
|
4
|
-
*/export var useCookieConsent=function useCookieConsent(){return React.useContext(CookieConsent);};
|
package/tracking/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{CookieConsent}from"./components";export{initializeTracking$}from"./streams";
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{connect}from'react-redux';import{initTracking}from"../action-creators";import{hasCookieConsent,hasStrictCookieConsent,makeGetPrivacyPolicyLink}from"../selectors";/**
|
|
2
|
-
* Creates the mapStateToProps connector function.
|
|
3
|
-
* @returns {Function}
|
|
4
|
-
*/var makeMapStateToProps=function makeMapStateToProps(){var getPrivacyPolicyLink=makeGetPrivacyPolicyLink();return function(state){return{privacyPolicyLink:getPrivacyPolicyLink(state),hasCookieConsent:hasCookieConsent(state),hasStrictCookieConsent:hasStrictCookieConsent(state)};};};var mapDispatchToProps={initTracking:initTracking};export default connect(makeMapStateToProps,mapDispatchToProps);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React from'react';var initialContext={};export default React.createContext(initialContext);
|
|
@@ -1,8 +0,0 @@
|
|
|
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,{useMemo,useCallback,useState,useLayoutEffect}from'react';import PropTypes from'prop-types';import{useCookies}from'react-cookie';import{i18n}from'@shopgate/engage/core';import{COOKIE_CONSENT_COOKIE_NAME_STATUS,COOKIE_CONSENT_COOKIE_NAME_PREFS,COOKIE_CONSENT_STATUS_ALLOW,COOKIE_CONSENT_STATUS_DENY,COOKIE_CONSENT_PREF_NEEDED,COOKIE_CONSENT_PREF_ANALYTICS}from"../constants";import Context from"./CookieConsentProvider.context";import connect from"./CookieConsentProvider.connector";/**
|
|
2
|
-
* @returns {JSX}
|
|
3
|
-
*/var CookieConsentProvider=function CookieConsentProvider(_ref){var privacyPolicyLink=_ref.privacyPolicyLink,hasCookieConsent=_ref.hasCookieConsent,hasStrictCookieConsent=_ref.hasStrictCookieConsent,initTracking=_ref.initTracking,children=_ref.children;var _useCookies=useCookies([COOKIE_CONSENT_COOKIE_NAME_STATUS,COOKIE_CONSENT_COOKIE_NAME_PREFS]),_useCookies2=_slicedToArray(_useCookies,2),cookies=_useCookies2[0],setCookie=_useCookies2[1];var _useState=useState(hasCookieConsent&&![COOKIE_CONSENT_STATUS_ALLOW,COOKIE_CONSENT_STATUS_DENY].includes(cookies[COOKIE_CONSENT_COOKIE_NAME_STATUS])),_useState2=_slicedToArray(_useState,2),isVisible=_useState2[0],setIsVisible=_useState2[1];var _useState3=useState(false),_useState4=_slicedToArray(_useState3,2),allowAnalytics=_useState4[0],setAllowAnalytics=_useState4[1];var _useState5=useState(0),_useState6=_slicedToArray(_useState5,2),fadeOutDelay=_useState6[0],setFadeOutDelay=_useState6[1];useLayoutEffect(function(){var status=cookies[COOKIE_CONSENT_COOKIE_NAME_STATUS];if([COOKIE_CONSENT_STATUS_ALLOW,COOKIE_CONSENT_STATUS_DENY].includes(status)){setTimeout(function(){setIsVisible(false);},fadeOutDelay);}},[cookies,fadeOutDelay]);var saveCookies=useCallback(function(){var allowed=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var analyticsAllowed=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var status=allowed?COOKIE_CONSENT_STATUS_ALLOW:COOKIE_CONSENT_STATUS_DENY;var prefs=[COOKIE_CONSENT_PREF_NEEDED].concat(analyticsAllowed?[COOKIE_CONSENT_PREF_ANALYTICS]:[]);var expires=new Date();expires.setFullYear(expires.getFullYear()+1);setCookie(COOKIE_CONSENT_COOKIE_NAME_STATUS,status,{expires:expires});setCookie(COOKIE_CONSENT_COOKIE_NAME_PREFS,prefs,{expires:expires});if(analyticsAllowed){// Initialize the tracking if allowed
|
|
4
|
-
initTracking();}},[initTracking,setCookie]);var onClickPrimary=useCallback(function(){if(hasStrictCookieConsent){// In strict mode the button saves the current configuration
|
|
5
|
-
saveCookies(true,allowAnalytics);return;}// In normal mode analytics are accepted
|
|
6
|
-
setAllowAnalytics(true);// Removal of the banner needs to be postponed, so that the user can see the added checkmark
|
|
7
|
-
setFadeOutDelay(1000);saveCookies(true,true);},[allowAnalytics,hasStrictCookieConsent,saveCookies]);var onClickSecondary=useCallback(function(){var strict=hasStrictCookieConsent;// In strict mode the button denies cookies
|
|
8
|
-
saveCookies(!strict,strict?false:allowAnalytics);},[allowAnalytics,hasStrictCookieConsent,saveCookies]);var onClickAllowAnalytics=useCallback(function(){setAllowAnalytics(!allowAnalytics);},[allowAnalytics]);var buttonLabels=useMemo(function(){if(hasStrictCookieConsent){return{secondary:i18n.text('tracking.cookieConsent.decline'),primary:i18n.text('tracking.cookieConsent.save')};}return{secondary:i18n.text('tracking.cookieConsent.allowSelected'),primary:i18n.text('tracking.cookieConsent.allowAll')};},[hasStrictCookieConsent]);var value=useMemo(function(){return{isVisible:isVisible,allowAnalytics:allowAnalytics,privacyPolicyLink:privacyPolicyLink,buttonLabels:buttonLabels,onClickPrimary:onClickPrimary,onClickSecondary:onClickSecondary,onClickAllowAnalytics:onClickAllowAnalytics};},[isVisible,allowAnalytics,privacyPolicyLink,buttonLabels,onClickPrimary,onClickSecondary,onClickAllowAnalytics]);return React.createElement(Context.Provider,{value:value},children);};CookieConsentProvider.defaultProps={children:null,privacyPolicyLink:null,hasCookieConsent:false,hasStrictCookieConsent:false};export default connect(CookieConsentProvider);
|
|
File without changes
|
|
File without changes
|