@shopgate/engage 7.20.0-beta.1 → 7.20.0-beta.11
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/components/Account/Account.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/ChipLayout/style.js +2 -2
- package/components/ConditionalWrapper/ConditionalWrapper.js +7 -2
- package/components/QuantityInput/QuantityInput.js +5 -4
- package/components/ResponsiveContainer/ResponsiveContainer.js +2 -6
- package/components/ResponsiveContainer/breakpoints.js +2 -1
- package/components/ResponsiveContainer/hooks.js +20 -0
- package/components/ScrollHeader/index.js +2 -2
- package/components/ScrollHeader/style.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/hooks/index.js +1 -1
- package/core/streams/index.js +1 -1
- package/core/subscriptions/app.js +2 -2
- package/favorites/components/Item/Item.js +6 -6
- 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/PriceSlider/style.js +1 -3
- 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/i18n/locale/cs-cz/countries.json +255 -0
- package/i18n/locale/de-de/countries.json +26 -28
- package/i18n/locale/el-gr/countries.json +255 -0
- package/i18n/locale/en-us/countries.json +12 -14
- package/i18n/locale/es-es/countries.json +65 -67
- package/i18n/locale/fi-fi/countries.json +255 -0
- package/i18n/locale/fr-fr/countries.json +85 -87
- package/i18n/locale/hu-hu/countries.json +255 -0
- package/i18n/locale/it-it/countries.json +11 -13
- package/i18n/locale/nl-nl/countries.json +42 -44
- package/i18n/locale/pl-pl/countries.json +255 -0
- package/i18n/locale/pt-pt/countries.json +128 -130
- package/i18n/locale/ro-ro/countries.json +255 -0
- package/i18n/locale/sv-se/countries.json +255 -0
- package/locations/action-creators/receiveInventories.js +3 -5
- package/locations/components/StoreList/StoreListSearch.js +3 -1
- 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/Options/components/Content/spec.js +1 -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/Rating/spec.js +1 -1
- 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/product/selectors/product.js +12 -2
- 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/reviews/components/Reviews/components/Header/components/ReviewsExcerpt/style.js +1 -2
- package/reviews/components/Reviews/components/RatingCount/style.js +1 -2
- package/reviews/index.js +3 -1
- package/styles/helpers/initCSSCustomProperties.js +2 -2
- package/styles/helpers/loadCustomStyles.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/i18n/locale/ru-ru/countries.json +0 -251
- 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
|
@@ -1,4 +1,4 @@
|
|
|
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{PipelineRequest}from'@shopgate/engage/core';import{ADD_CUSTOMER_CONTACT,ADD_CUSTOMER_CONTACT_SUCCESS,ADD_CUSTOMER_CONTACT_ERROR}from"../constants/actions";/**
|
|
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{PipelineRequest}from'@shopgate/engage/core/classes';import{ADD_CUSTOMER_CONTACT,ADD_CUSTOMER_CONTACT_SUCCESS,ADD_CUSTOMER_CONTACT_ERROR}from"../constants/actions";/**
|
|
2
2
|
* Starts entering the checkout process for the customer.
|
|
3
3
|
* @returns {Function}
|
|
4
4
|
*/export var addCustomerContacts=function addCustomerContacts(_ref){var contacts=_ref.contacts;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var response;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:dispatch({type:ADD_CUSTOMER_CONTACT,contacts:contacts});_context.prev=1;_context.next=4;return new PipelineRequest('shopgate.customer.addContacts').setTrusted().setInput({contacts:contacts}).dispatch();case 4:response=_context.sent;dispatch({type:ADD_CUSTOMER_CONTACT_SUCCESS,contacts:contacts});_context.next=12;break;case 8:_context.prev=8;_context.t0=_context["catch"](1);dispatch({type:ADD_CUSTOMER_CONTACT_ERROR,contacts:contacts,error:_context.t0});throw _context.t0;case 12:return _context.abrupt("return",response);case 13:case"end":return _context.stop();}},_callee,null,[[1,8]]);}));return function(_x){return _ref2.apply(this,arguments);};}());};
|
|
@@ -1,4 +1,4 @@
|
|
|
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{PipelineRequest}from'@shopgate/engage/core';import{DELETE_CUSTOMER_CONTACT,DELETE_CUSTOMER_CONTACT_SUCCESS,DELETE_CUSTOMER_CONTACT_ERROR}from"../constants/actions";/**
|
|
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{PipelineRequest}from'@shopgate/engage/core/classes';import{DELETE_CUSTOMER_CONTACT,DELETE_CUSTOMER_CONTACT_SUCCESS,DELETE_CUSTOMER_CONTACT_ERROR}from"../constants/actions";/**
|
|
2
2
|
* Starts entering the checkout process for the customer.
|
|
3
3
|
* @param {Object} contactId Contact
|
|
4
4
|
* @returns {Function}
|
|
@@ -1,4 +1,4 @@
|
|
|
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{PipelineRequest}from'@shopgate/engage/core';import{successLogout}from'@shopgate/pwa-common/action-creators/user';import{DELETE_CUSTOMER,DELETE_CUSTOMER_SUCCESS,DELETE_CUSTOMER_ERROR}from"../constants/actions";/**
|
|
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{PipelineRequest}from'@shopgate/engage/core/classes';import{successLogout}from'@shopgate/pwa-common/action-creators/user';import{DELETE_CUSTOMER,DELETE_CUSTOMER_SUCCESS,DELETE_CUSTOMER_ERROR}from"../constants/actions";/**
|
|
2
2
|
* Starts entering the checkout process for the customer.
|
|
3
3
|
* @returns {Function}
|
|
4
4
|
*/export var deleteCustomer=function deleteCustomer(){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:dispatch({type:DELETE_CUSTOMER});_context.prev=1;_context.next=4;return new PipelineRequest('shopgate.customer.deleteCustomer').setTrusted().dispatch();case 4:dispatch({type:DELETE_CUSTOMER_SUCCESS});dispatch(successLogout(false));_context.next=12;break;case 8:_context.prev=8;_context.t0=_context["catch"](1);dispatch({type:DELETE_CUSTOMER_ERROR,error:_context.t0});throw _context.t0;case 12:case"end":return _context.stop();}},_callee,null,[[1,8]]);}));return function(_x){return _ref.apply(this,arguments);};}());};
|
|
@@ -1,4 +1,4 @@
|
|
|
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{PipelineRequest}from'@shopgate/engage/core';import{FETCH_CUSTOMER_CONTACTS,FETCH_CUSTOMER_CONTACTS_SUCCESS,FETCH_CUSTOMER_CONTACTS_ERROR}from"../constants/actions";/**
|
|
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{PipelineRequest}from'@shopgate/engage/core/classes';import{FETCH_CUSTOMER_CONTACTS,FETCH_CUSTOMER_CONTACTS_SUCCESS,FETCH_CUSTOMER_CONTACTS_ERROR}from"../constants/actions";/**
|
|
2
2
|
* Starts entering the checkout process for the customer.
|
|
3
3
|
* @returns {Function}
|
|
4
4
|
*/export var fetchCustomerContacts=function fetchCustomerContacts(){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var _ref3,contacts;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:dispatch({type:FETCH_CUSTOMER_CONTACTS});_context.prev=1;_context.next=4;return new PipelineRequest('shopgate.customer.getContacts').setTrusted().dispatch();case 4:_ref3=_context.sent;contacts=_ref3.contacts;dispatch({type:FETCH_CUSTOMER_CONTACTS_SUCCESS,contacts:contacts});return _context.abrupt("return",contacts);case 10:_context.prev=10;_context.t0=_context["catch"](1);dispatch({type:FETCH_CUSTOMER_CONTACTS_ERROR,error:_context.t0});throw _context.t0;case 14:case"end":return _context.stop();}},_callee,null,[[1,10]]);}));return function(_x){return _ref.apply(this,arguments);};}());};
|
|
@@ -1,4 +1,4 @@
|
|
|
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{PipelineRequest}from'@shopgate/engage/core';import{FETCH_CUSTOMER,FETCH_CUSTOMER_ERROR,FETCH_CUSTOMER_SUCCESS}from"../constants/actions";/**
|
|
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{PipelineRequest}from'@shopgate/engage/core/classes';import{FETCH_CUSTOMER,FETCH_CUSTOMER_ERROR,FETCH_CUSTOMER_SUCCESS}from"../constants/actions";/**
|
|
2
2
|
* Starts entering the checkout process for the customer.
|
|
3
3
|
* @returns {Function}
|
|
4
4
|
*/export var fetchCustomerData=function fetchCustomerData(){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var _ref3,customer;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:dispatch({type:FETCH_CUSTOMER});_context.prev=1;_context.next=4;return new PipelineRequest('shopgate.customer.getCustomer').setTrusted().dispatch();case 4:_ref3=_context.sent;customer=_ref3.customer;dispatch({type:FETCH_CUSTOMER_SUCCESS,customer:customer});return _context.abrupt("return",customer);case 10:_context.prev=10;_context.t0=_context["catch"](1);dispatch({type:FETCH_CUSTOMER_ERROR,error:_context.t0});throw _context.t0;case 14:case"end":return _context.stop();}},_callee,null,[[1,10]]);}));return function(_x){return _ref.apply(this,arguments);};}());};
|
|
@@ -1,4 +1,4 @@
|
|
|
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{PipelineRequest}from'@shopgate/engage/core';import{UPDATE_CUSTOMER_CONTACT,UPDATE_CUSTOMER_CONTACT_SUCCESS,UPDATE_CUSTOMER_CONTACT_ERROR}from"../constants/actions";/**
|
|
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{PipelineRequest}from'@shopgate/engage/core/classes';import{UPDATE_CUSTOMER_CONTACT,UPDATE_CUSTOMER_CONTACT_SUCCESS,UPDATE_CUSTOMER_CONTACT_ERROR}from"../constants/actions";/**
|
|
2
2
|
* Starts entering the checkout process for the customer.
|
|
3
3
|
* @returns {Function}
|
|
4
4
|
*/export var updateCustomerContact=function updateCustomerContact(_ref){var contactId=_ref.contactId,contact=_ref.contact;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:dispatch({type:UPDATE_CUSTOMER_CONTACT,contactId:contactId,contact:contact});_context.prev=1;_context.next=4;return new PipelineRequest('shopgate.customer.updateContact').setTrusted().setInput({contactId:contactId,contact:contact}).dispatch();case 4:dispatch({type:UPDATE_CUSTOMER_CONTACT_SUCCESS,contactId:contactId});_context.next=11;break;case 7:_context.prev=7;_context.t0=_context["catch"](1);dispatch({type:UPDATE_CUSTOMER_CONTACT_ERROR,contactId:contactId,error:_context.t0});throw _context.t0;case 11:case"end":return _context.stop();}},_callee,null,[[1,7]]);}));return function(_x){return _ref2.apply(this,arguments);};}());};
|
|
@@ -1,4 +1,4 @@
|
|
|
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{PipelineRequest}from'@shopgate/engage/core';import{UPDATE_CUSTOMER,UPDATE_CUSTOMER_SUCCESS,UPDATE_CUSTOMER_ERROR}from"../constants/actions";/**
|
|
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{PipelineRequest}from'@shopgate/engage/core/classes';import{UPDATE_CUSTOMER,UPDATE_CUSTOMER_SUCCESS,UPDATE_CUSTOMER_ERROR}from"../constants/actions";/**
|
|
2
2
|
* @param {Object} customer Customer
|
|
3
3
|
* @returns {Function}
|
|
4
4
|
*/export var updateCustomerData=function updateCustomerData(customer){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:dispatch({type:UPDATE_CUSTOMER,customer:customer});_context.prev=1;_context.next=4;return new PipelineRequest('shopgate.customer.updateCustomer').setInput({customer:customer}).setTrusted().dispatch();case 4:dispatch({type:UPDATE_CUSTOMER_SUCCESS,customer:customer});_context.next=11;break;case 7:_context.prev=7;_context.t0=_context["catch"](1);dispatch({type:UPDATE_CUSTOMER_ERROR,customer:customer,error:_context.t0});throw _context.t0;case 11:case"end":return _context.stop();}},_callee,null,[[1,7]]);}));return function(_x){return _ref.apply(this,arguments);};}());};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from'react';import PropTypes from'prop-types';import{hot}from'react-hot-loader/root';import I18n from'@shopgate/pwa-common/components/I18n';import appConfig from'@shopgate/pwa-common/helpers/config';import{i18n,useRoute}from'@shopgate/engage/core';import OrderHistory from"../../../orders/components/OrderHistory";import OrderHistoryProvider from"../../../orders/providers/OrderHistoryProvider";import{Tabs,Tab,TabPanel}from"../../../components/Tabs";import{tabs,title,tabPanel}from"./Account.style";import{ResponsiveContainer}from"../../../components";import Lists from"../../../favorites/components/Lists";import connect from"./Account.connector";import{TabContext}from"../../../components/Tabs/TabContext";import Profile from"../Profile";/**
|
|
2
2
|
* The Tabs components
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/var Account=function Account(_ref){var historyReplace=_ref.historyReplace;var _useRoute=useRoute(),_useRoute$params$tab=_useRoute.params.tab,tab=_useRoute$params$tab===void 0?'profile':_useRoute$params$tab;return React.createElement(React.Fragment,null,React.createElement(TabContext,{value:tab},React.createElement("div",{className:tabs},React.createElement(ResponsiveContainer,{webOnly:true,breakpoint:">xs"},React.createElement("div",{className:title},React.createElement(I18n.Text,{string:"titles.your_account"}))),React.createElement(Tabs,{indicatorColor:"primary",textColor:"primary",onChange:function onChange(event,newValue){return historyReplace({pathname:"/account/".concat(newValue)});},"aria-label":"disabled tabs example"},React.createElement(Tab,{value:"profile",label:i18n.text('titles.profile')}),React.createElement(Tab,{value:"orders",label:i18n.text('titles.order_history')}),appConfig.hasFavorites?React.createElement(Tab,{value:"wish-list",label:i18n.text('titles.
|
|
4
|
+
*/var Account=function Account(_ref){var historyReplace=_ref.historyReplace;var _useRoute=useRoute(),_useRoute$params$tab=_useRoute.params.tab,tab=_useRoute$params$tab===void 0?'profile':_useRoute$params$tab;return React.createElement(React.Fragment,null,React.createElement(TabContext,{value:tab},React.createElement("div",{className:tabs},React.createElement(ResponsiveContainer,{webOnly:true,breakpoint:">xs"},React.createElement("div",{className:title},React.createElement(I18n.Text,{string:"titles.your_account"}))),React.createElement(Tabs,{indicatorColor:"primary",textColor:"primary",onChange:function onChange(event,newValue){return historyReplace({pathname:"/account/".concat(newValue)});},"aria-label":"disabled tabs example"},React.createElement(Tab,{value:"profile",label:i18n.text('titles.profile')}),React.createElement(Tab,{value:"orders",label:i18n.text('titles.order_history')}),appConfig.hasFavorites?React.createElement(Tab,{value:"wish-list",label:i18n.text('titles.favorites')}):null)),React.createElement(TabPanel,{className:tabPanel,value:"profile"},React.createElement(Profile,null)),React.createElement(TabPanel,{className:tabPanel,value:"orders"},React.createElement(OrderHistoryProvider,null,React.createElement(OrderHistory,null))),appConfig.hasFavorites?React.createElement(TabPanel,{className:tabPanel,value:"wish-list"},React.createElement(Lists,null)):null));};export default hot(connect(Account));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{produce}from'immer';import{FETCH_CUSTOMER_CONTACTS,FETCH_CUSTOMER_CONTACTS_SUCCESS,FETCH_CUSTOMER_CONTACTS_ERROR,FETCH_CUSTOMER,FETCH_CUSTOMER_SUCCESS,FETCH_CUSTOMER_ERROR}from"../constants/actions";var initialState={customer:{isFetching:false,data:null},contacts:{isFetching:false,items:[]}};/**
|
|
1
|
+
import{produce}from'immer';import{SUCCESS_LOGOUT}from'@shopgate/engage/core/constants';import{FETCH_CUSTOMER_CONTACTS,FETCH_CUSTOMER_CONTACTS_SUCCESS,FETCH_CUSTOMER_CONTACTS_ERROR,FETCH_CUSTOMER,FETCH_CUSTOMER_SUCCESS,FETCH_CUSTOMER_ERROR}from"../constants/actions";var initialState={customer:{isFetching:false,data:null},contacts:{isFetching:false,items:[]}};/**
|
|
2
2
|
* The reducer for all checkout related state.
|
|
3
3
|
* @param {Object} state The application state.
|
|
4
4
|
* @param {Object} action The redux action.
|
|
5
5
|
* @returns {Object}
|
|
6
|
-
*/export default function checkoutReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:initialState;var action=arguments.length>1?arguments[1]:undefined;/* eslint-disable no-param-reassign */var producer=produce(function(draft){switch(action.type){case FETCH_CUSTOMER_CONTACTS:{draft.contacts.isFetching=true;break;}case FETCH_CUSTOMER_CONTACTS_ERROR:{draft.contacts.isFetching=false;break;}case FETCH_CUSTOMER_CONTACTS_SUCCESS:{draft.contacts.isFetching=false;draft.contacts.items=action.contacts;break;}case FETCH_CUSTOMER:{draft.customer.isFetching=true;break;}case FETCH_CUSTOMER_ERROR:{draft.customer.isFetching=false;break;}case FETCH_CUSTOMER_SUCCESS:{draft.customer.isFetching=false;draft.customer.data=action.customer;break;}default:break;}});/* eslint-enable no-param-reassign */return producer(state);}
|
|
6
|
+
*/export default function checkoutReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:initialState;var action=arguments.length>1?arguments[1]:undefined;/* eslint-disable no-param-reassign */var producer=produce(function(draft){switch(action.type){case FETCH_CUSTOMER_CONTACTS:{draft.contacts.isFetching=true;break;}case FETCH_CUSTOMER_CONTACTS_ERROR:{draft.contacts.isFetching=false;break;}case FETCH_CUSTOMER_CONTACTS_SUCCESS:{draft.contacts.isFetching=false;draft.contacts.items=action.contacts;break;}case FETCH_CUSTOMER:{draft.customer.isFetching=true;break;}case FETCH_CUSTOMER_ERROR:{draft.customer.isFetching=false;break;}case FETCH_CUSTOMER_SUCCESS:{draft.customer.isFetching=false;draft.customer.data=action.customer;break;}case SUCCESS_LOGOUT:{draft.customer=initialState.customer;draft.contacts=initialState.contacts;break;}default:break;}});/* eslint-enable no-param-reassign */return producer(state);}
|
package/cart/cart.helpers.js
CHANGED
|
@@ -5,4 +5,11 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
|
|
|
5
5
|
var groupedByBaseLineItemId=groupBy(merged,function(e){return e.baseLineItemId||e.id;});merged=merged.reduce(function(acc,_ref){var id=_ref.id;var group=groupedByBaseLineItemId===null||groupedByBaseLineItemId===void 0?void 0:groupedByBaseLineItemId[id];if(group){return[].concat(acc,group);}return acc;},[]);var enhanced=merged.map(function(item){if(!item.fulfillment||![ROPIS,BOPIS].includes(item.fulfillment.method)){return _extends({},item,{fulfillmentLocationId:null,fulfillmentMethod:null});}return _extends({},item,{fulfillmentLocationId:item.fulfillment.location.code,fulfillmentMethod:item.fulfillment.method});});return enhanced;}/**
|
|
6
6
|
* @param {Object} cartItem A cart item
|
|
7
7
|
* @returns {Object}
|
|
8
|
-
*/export var createCartItemPrices=function createCartItemPrices(){var cartItem=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{}
|
|
8
|
+
*/export var createCartItemPrices=function createCartItemPrices(){var cartItem=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};/**
|
|
9
|
+
* When PWA doesn't run with new services and uses a "shopgate.cart.getCart.v1" pipeline from one
|
|
10
|
+
* of the available cart extensions, we return a price array based on the response of those
|
|
11
|
+
* pipelines.
|
|
12
|
+
*/if(!hasNewServices()){var _cartItem$product3=cartItem.product,_cartItem$product4=_cartItem$product3===void 0?{}:_cartItem$product3,_cartItem$product2$pr2=_cartItem$product4.price,_price=_cartItem$product2$pr2===void 0?{}:_cartItem$product2$pr2;return{price:[],subtotal:typeof(_price===null||_price===void 0?void 0:_price.special)==='number'&&_price.special!==_price["default"]?[{price:_price["default"]},{price:_price.special}]:[{price:_price["default"]}]};}/**
|
|
13
|
+
* When running with the new services, the "shopgate.cart.getCart.v1" pipeline returns entities
|
|
14
|
+
* with different price properties. Those are handled here.
|
|
15
|
+
*/var _cartItem$product5=cartItem.product,product=_cartItem$product5===void 0?{}:_cartItem$product5,quantity=cartItem.quantity,price=cartItem.price,promoAmount=cartItem.promoAmount,extendedPrice=cartItem.extendedPrice,unitPromoAmount=cartItem.unitPromoAmount,unitDiscountAmount=cartItem.unitDiscountAmount;var _ref2=(product===null||product===void 0?void 0:product.price)||{},unit=_ref2.unit,unitSale=_ref2.unitSale,unitEffective=_ref2.unitEffective;var prices={price:[{price:unit}],subtotal:[]};if(unitSale&&unitSale!==unit){prices.price.push({price:unitSale});prices.subtotal.push({price:unit*quantity});}prices.subtotal.push({price:price});if(unitPromoAmount){prices.price.push({price:unitEffective+unitPromoAmount,isPromo:true});prices.subtotal.push({price:price+promoAmount,isPromo:true});}if(unitDiscountAmount){prices.price.push({price:unitEffective+unitPromoAmount+unitDiscountAmount,isCoupon:true});prices.subtotal.push({price:extendedPrice,isCoupon:true});}return prices;};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
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 _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,{useMemo}from'react';import classNames from'classnames';import{Grid,Link,TextLink,ProductProperties,SurroundPortals,ConditionalWrapper,I18n}from'@shopgate/engage/components';import{CART_ITEM_IMAGE,CART_ITEM_LINK,CART_ITEM_PROPERTIES,CART_ITEM_QUANTITY_PICKER}from'@shopgate/engage/cart';import{showTaxDisclaimer}from'@shopgate/engage/market';import{bin2hex}from'@shopgate/engage/core/helpers';import{useWidgetSettings}from'@shopgate/engage/core/hooks';import{ProductImage,PriceInfo,ITEM_PATH}from'@shopgate/engage/product';import{CartItemProductChangeLocation,CartChangeFulfillmentMethod}from'@shopgate/engage/locations';import{getLineItemActiveStatus}from'@shopgate/engage/orders';import{CartItemQuantityPicker}from"./CartItemQuantityPicker";import{CartItemProductTitle}from"./CartItemProductTitle";import CartItemProductOrderDetails from"./CartItemProductOrderDetails";import CartItemProductPriceList from"./CartItemProductPriceList";import{useCartItem,useCartItemProduct}from"./CartItem.hooks";import styles from"./CartItemProductLayout.style";/**
|
|
2
2
|
* The Cart Product Layout component.
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/export function CartItemProductLayout(){
|
|
4
|
+
*/export function CartItemProductLayout(){// Added with PWA 6 - CCP-2372
|
|
5
|
+
var _useWidgetSettings=useWidgetSettings('@shopgate/engage/components/TaxDisclaimer'),show=_useWidgetSettings.show;// use widget setting if set to true/false, otherwise use market logic
|
|
5
6
|
var showDisclaimer=typeof show==='boolean'?show:showTaxDisclaimer;var _useCartItem=useCartItem(),registerFulfillmentAction=_useCartItem.registerFulfillmentAction,isOrderDetails=_useCartItem.isOrderDetails,isCheckoutConfirmation=_useCartItem.isCheckoutConfirmation;var context=useCartItemProduct();var cartItem=context.cartItem,product=context.product,currency=context.currency,editMode=context.editMode,handleUpdate=context.handleUpdate,toggleEditMode=context.toggleEditMode,isEditable=context.isEditable;var portalProps=useMemo(function(){return _extends({},context,{isOrderDetails:isOrderDetails,isCheckoutConfirmation:isCheckoutConfirmation,quantity:cartItem.quantity});},[cartItem.quantity,context,isCheckoutConfirmation,isOrderDetails]);var isActive=!isOrderDetails?true:getLineItemActiveStatus(cartItem===null||cartItem===void 0?void 0:cartItem.status,cartItem===null||cartItem===void 0?void 0:cartItem.subStatus);var showLineItemPromotions=useMemo(function(){if(isOrderDetails||isCheckoutConfirmation){return false;}return((cartItem===null||cartItem===void 0?void 0:cartItem.appliedPromotions)||[]).length>0;},[cartItem,isCheckoutConfirmation,isOrderDetails]);return React.createElement(React.Fragment,null,React.createElement(Grid,{className:classNames(styles.item,_defineProperty({},styles.itemInactive,!isActive))},React.createElement(Grid.Item,{className:styles.content,grow:1},React.createElement(ConditionalWrapper,{condition:isEditable,wrapper:function wrapper(children){return React.createElement(TextLink,{href:"".concat(ITEM_PATH,"/").concat(bin2hex(product.id))},children);}},React.createElement(SurroundPortals,{portalName:CART_ITEM_LINK,portalProps:portalProps},React.createElement(CartItemProductTitle,{value:product.name}))),React.createElement(Grid,{className:styles.info},React.createElement(Grid.Item,{grow:1,className:styles.properties},React.createElement(SurroundPortals,{portalName:CART_ITEM_PROPERTIES,portalProps:portalProps},React.createElement(ProductProperties,{properties:product.properties,lineClamp:2})),isOrderDetails&&React.createElement(CartItemProductOrderDetails,null)),React.createElement(Grid.Item,{grow:1,className:styles.price},isOrderDetails&&React.createElement(I18n.Text,{string:"cart.subtotal",className:styles.orderDetailsSubtotalLabel}),!showLineItemPromotions&&React.createElement(React.Fragment,null,React.createElement(CartItemProductPriceList,{isSubtotal:true}),React.createElement(PriceInfo,{product:product,currency:currency,className:styles.priceInfo}))),showDisclaimer&&React.createElement(Grid.Item,{className:styles.disclaimerSpacer,grow:0,shrink:0})),showLineItemPromotions&&React.createElement(Grid,{className:classNames(styles.info,styles.promotionLine)},React.createElement(Grid.Item,null),React.createElement(Grid.Item,{className:styles.promotionLineItem},React.createElement(CartItemProductPriceList,{isSubtotal:true,showLabels:true}),React.createElement(PriceInfo,{product:product,currency:currency,className:styles.priceInfo})))),React.createElement(Grid.Item,{className:styles.leftColumn},React.createElement("div",{className:styles.image,"aria-hidden":true},React.createElement(ConditionalWrapper,{condition:isEditable,wrapper:function wrapper(children){return React.createElement(Link,{tagName:"a",href:"".concat(ITEM_PATH,"/").concat(bin2hex(product.id))},children);}},React.createElement(SurroundPortals,{portalName:CART_ITEM_IMAGE,portalProps:portalProps},React.createElement(ProductImage,{src:product.featuredImageBaseUrl||product.featuredImageUrl})))),!isOrderDetails&&React.createElement(SurroundPortals,{portalName:CART_ITEM_QUANTITY_PICKER,portalProps:portalProps},React.createElement(CartItemQuantityPicker,{unit:product.unit,hasCatchWeight:product.hasCatchWeight,quantity:cartItem.quantity,editMode:editMode,onChange:handleUpdate,onToggleEditMode:toggleEditMode,disabled:!isEditable})))),React.createElement(CartItemProductChangeLocation,{cartItem:cartItem,registerAction:registerFulfillmentAction}),React.createElement(CartChangeFulfillmentMethod,{cartItem:cartItem,registerAction:registerFulfillmentAction}));}
|
package/cart/index.js
CHANGED
|
@@ -4,7 +4,8 @@ export{default as setCouponFieldError}from'@shopgate/pwa-common-commerce/cart/ac
|
|
|
4
4
|
export*from'@shopgate/pwa-common-commerce/cart/constants/index';export*from'@shopgate/pwa-common-commerce/cart/constants/PipelineErrors';export*from'@shopgate/pwa-common-commerce/cart/constants/Pipelines';export*from'@shopgate/pwa-common-commerce/cart/constants/Portals';export{FLAG_ORDERABLE,FLAG_COUPONS,FLAG_TAX_INCLUDED,FLAG_MULTI_LINE_RESERVE,CART_MAX_ITEMS,CART_INPUT_AUTO_SCROLL_DELAY}from"./cart.constants";// HELPERS
|
|
5
5
|
export*from'@shopgate/pwa-common-commerce/cart/helpers';export*from'@shopgate/pwa-common-commerce/cart/helpers/config';export{default as createPipelineErrorList}from'@shopgate/pwa-common-commerce/cart/helpers/createPipelineErrorList';export*from'@shopgate/pwa-common-commerce/cart/helpers/shipping';export*from'@shopgate/pwa-common-commerce/cart/helpers/tax';export{sortCartItems}from"./cart.helpers";// SELECTORS
|
|
6
6
|
export*from'@shopgate/pwa-common-commerce/cart/selectors';export{makeIsAddToCartButtonDisabled,getAppliedPromotionsWithoutCoupons,getPromotionCoupons,hasLineItemPromotions,hasDirectShipItems,isDirectShipOnly}from"./cart.selectors";// STREAMS
|
|
7
|
-
|
|
7
|
+
// eslint-disable-next-line import/export
|
|
8
|
+
export*from"./streams";// CONTEXTS
|
|
8
9
|
export{CartContext}from"./cart.context";// COMPONENTS
|
|
9
10
|
export{PaymentBar}from"./components/PaymentBar";export{CartItemGroup,CartItems}from"./components/CartItems";export{CartItem}from"./components/CartItem";export{CartHeaderWide}from"./components/CartHeaderWide";export{default as CartSummaryWide}from"./components/CartSummaryWide/CartSummaryWide";export{SupplementalContent}from"./components/SupplementalContent";export{default as CartItemsSubstitution}from"./components/CartItems/CartItemsSubstitution";// HOOKS
|
|
10
11
|
export{useCartContext}from"./cart.hooks";// TYPES
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from'@shopgate/pwa-common-commerce/cart/streams';
|
|
@@ -5,4 +5,4 @@ import{i18n}from'@shopgate/engage/core';var pickupFieldActions=[{type:'setVisibi
|
|
|
5
5
|
* @param {Array} options.countrySortOrder Sort order for supported countries.
|
|
6
6
|
* @param {Object} options.userLocation User location for better phone picker defaults.
|
|
7
7
|
* @returns {Object}
|
|
8
|
-
*/var generateFormConfig=function generateFormConfig(_ref){var supportedCountries=_ref.supportedCountries,countrySortOrder=_ref.countrySortOrder,userLocation=_ref.userLocation;return{fields:{instructions:{type:'text',label:i18n.text('checkout.pickup_contact.form.instructions')
|
|
8
|
+
*/var generateFormConfig=function generateFormConfig(_ref){var supportedCountries=_ref.supportedCountries,countrySortOrder=_ref.countrySortOrder,userLocation=_ref.userLocation;return{fields:{instructions:{type:'text',label:i18n.text('checkout.pickup_contact.form.instructions')},pickupPerson:{type:'radio',label:i18n.text('checkout.pickup_contact.form.who_will_pickup'),options:{me:i18n.text('checkout.pickup_contact.form.me'),someoneElse:i18n.text('checkout.pickup_contact.form.someone_else')}},firstName:{type:'text',actions:pickupFieldActions,label:"".concat(i18n.text('checkout.pickup_contact.form.firstName')," *")},lastName:{type:'text',actions:pickupFieldActions,label:"".concat(i18n.text('checkout.pickup_contact.form.lastName')," *")},emailAddress:{type:'email',actions:pickupFieldActions,label:"".concat(i18n.text('checkout.pickup_contact.form.emailAddress')," *")},mobile:{type:'phone_picker',label:"".concat(i18n.text('checkout.pickup_contact.form.mobile')," *"),actions:pickupFieldActions,config:{supportedCountries:supportedCountries,countrySortOrder:countrySortOrder,userLocation:userLocation}}}};};export default generateFormConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{i18n}from'@shopgate/engage/core';/**
|
|
2
2
|
* Generates form configuration.
|
|
3
3
|
* @returns {Object}
|
|
4
|
-
*/var generateFormConfig=function generateFormConfig(){return{fields:{instructions:{type:'text',label:i18n.text('checkout.pickup_contact.form.instructions')
|
|
4
|
+
*/var generateFormConfig=function generateFormConfig(){return{fields:{instructions:{type:'text',label:i18n.text('checkout.pickup_contact.form.instructions')}}};};export default generateFormConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{CheckoutConfirmationPickUpContact,CheckoutConfirmationOrderContact,CheckoutConfirmationBilledTo,CheckoutConfirmationShippedTo,CheckoutConfirmationOrderSummary,CheckoutConfirmationSection}from"./CheckoutConfirmation";export{SupplementalContent}from"./SupplementalContent";
|
|
1
|
+
export{CheckoutConfirmationPickUpContact,CheckoutConfirmationOrderContact,CheckoutConfirmationBilledTo,CheckoutConfirmationShippedTo,CheckoutConfirmationOrderSummary,CheckoutConfirmationSection}from"./CheckoutConfirmation";export{SupplementalContent}from"./SupplementalContent";export{default as Checkout}from"./Checkout/Checkout";export{default as GuestCheckoutPayment}from"./GuestCheckout/GuestCheckout";export{default as CheckoutConfirmation}from"./CheckoutConfirmation/CheckoutConfirmation";export{default as AddressBook}from"./AddressBook";export{default as AddressBookContact}from"./AddressBookContact";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{CHECKOUT_PATTERN,GUEST_CHECKOUT_PATTERN,CHECKOUT_CONFIRMATION_PATTERN,GUEST_CHECKOUT_PAYMENT_PATTERN,CHECKOUT_ADDRESS_BOOK_PATTERN,CHECKOUT_ADDRESS_BOOK_CONTACT_PATTERN,checkoutRoutes}from"./routes";export var CHECKOUT_ACTIONS='checkout.actions';export var CHECKOUT_PICKUP_CONTACT_FORM='checkout.pickup-contact';export var CHECKOUT_MARKETING_OPTIN='checkout.marketing-optin';export var ADDRESS_TYPE_BILLING='billing';export var ADDRESS_TYPE_SHIPPING='shipping';export var ADDRESS_TYPE_PICKUP='pickup';
|
|
1
|
+
import{CHECKOUT_PATH}from'@shopgate/pwa-common/constants/RoutePaths';export*from'@shopgate/pwa-common-commerce/checkout/constants/index';export*from'@shopgate/pwa-common-commerce/checkout/constants/Pipelines';export{CHECKOUT_PATH};export{CHECKOUT_PATTERN,GUEST_CHECKOUT_PATTERN,CHECKOUT_CONFIRMATION_PATTERN,GUEST_CHECKOUT_PAYMENT_PATTERN,CHECKOUT_ADDRESS_BOOK_PATTERN,CHECKOUT_ADDRESS_BOOK_CONTACT_PATTERN,checkoutRoutes}from"./routes";export var CHECKOUT_ACTIONS='checkout.actions';export var CHECKOUT_PICKUP_CONTACT_FORM='checkout.pickup-contact';export var CHECKOUT_MARKETING_OPTIN='checkout.marketing-optin';export var ADDRESS_TYPE_BILLING='billing';export var ADDRESS_TYPE_SHIPPING='shipping';export var ADDRESS_TYPE_PICKUP='pickup';
|
package/checkout/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/** @module checkout */
|
|
1
|
+
/** @module checkout */ // ACTIONS
|
|
2
2
|
export{default as fetchCheckoutUrl}from'@shopgate/pwa-common-commerce/checkout/actions/fetchCheckoutUrl';export{fetchCheckoutOrder}from'@shopgate/engage/checkout/actions/fetchCheckoutOrder';export{updateCheckoutOrder}from'@shopgate/engage/checkout/actions/updateCheckoutOrder';export{submitCheckoutOrder}from'@shopgate/engage/checkout/actions/submitCheckoutOrder';export{initializeCheckout}from'@shopgate/engage/checkout/actions/initializeCheckout';export{fetchPaymentMethods}from'@shopgate/engage/checkout/actions/fetchPaymentMethods';export{prepareCheckout}from'@shopgate/engage/checkout/actions/prepareCheckout';export{clearCheckoutOrder,clearCheckoutCampaign}from'@shopgate/engage/checkout/action-creators';// CONSTANTS
|
|
3
|
-
export*from
|
|
3
|
+
export*from"./constants";// SELECTORS
|
|
4
4
|
export*from'@shopgate/pwa-common-commerce/checkout/selectors';export*from"./selectors/guestCheckout";export*from"./selectors/order";export*from"./selectors/route";// STREAMS
|
|
5
5
|
export*from'@shopgate/pwa-common-commerce/checkout/streams';// HOOKS
|
|
6
|
-
export*from"./hooks/common"
|
|
7
|
-
export{default as Checkout}from"./components/Checkout/Checkout";export{default as GuestCheckoutPayment}from"./components/GuestCheckout/GuestCheckout";export{default as CheckoutConfirmation}from"./components/CheckoutConfirmation/CheckoutConfirmation";export{default as AddressBook}from"./components/AddressBook";export{default as AddressBookContact}from"./components/AddressBookContact";
|
|
6
|
+
export*from"./hooks/common";
|
|
@@ -1,8 +1,9 @@
|
|
|
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{loadStripe}from'@stripe/stripe-js';
|
|
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{loadStripe}from'@stripe/stripe-js';import{logger}from'@shopgate/engage/core/helpers';// Write a log when sdk module loads - should not happen before entering native checkout
|
|
2
|
+
logger.warn('Stripe SDK loaded');var resolve;var reject;var stripe;export var promise=new Promise(function(res,rej){resolve=res;reject=rej;});var loaded=false;/**
|
|
2
3
|
* Loads the stripe sdk
|
|
3
4
|
* @param {string} publishableKey The publishable stripe key.
|
|
4
5
|
* @returns {Stripe}
|
|
5
|
-
*/export var loadSdk=function loadSdk(publishableKey){if(loaded){return promise;}loaded=true;/** */var fn=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var stripeObject;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;_context.next=3;return loadStripe(publishableKey);case 3:stripeObject=_context.sent;stripe=stripeObject;resolve(stripeObject);return _context.abrupt("return",stripeObject);case 9:_context.prev=9;_context.t0=_context["catch"](0);reject(_context.t0);throw _context.t0;case 13:case"end":return _context.stop();}},_callee,null,[[0,9]]);}));return function fn(){return _ref.apply(this,arguments);};}();return fn();};/**
|
|
6
|
+
*/export var loadSdk=function loadSdk(publishableKey){if(loaded||!publishableKey){return promise;}loaded=true;/** */var fn=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var stripeObject;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;_context.next=3;return loadStripe(publishableKey);case 3:stripeObject=_context.sent;stripe=stripeObject;resolve(stripeObject);return _context.abrupt("return",stripeObject);case 9:_context.prev=9;_context.t0=_context["catch"](0);reject(_context.t0);throw _context.t0;case 13:case"end":return _context.stop();}},_callee,null,[[0,9]]);}));return function fn(){return _ref.apply(this,arguments);};}();return fn();};/**
|
|
6
7
|
* Returns the sdk
|
|
7
8
|
* @returns {Object}
|
|
8
9
|
* */export var getSdk=function getSdk(){return stripe;};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var
|
|
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{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var variables=themeConfig.variables;/**
|
|
2
2
|
* Returns the styling based on the container height.
|
|
3
3
|
* @param {number} height The maximum height for the container.
|
|
4
4
|
* @returns {string}
|
|
5
|
-
*/var container=function container(height){return css({position:'relative',maxHeight:height,overflow:'hidden',marginBottom:variables.gap.small}).toString();};var layout=css({display:'flex',alignContent:'flex-start',flexWrap:'wrap',padding:'8px 5px',overflow:'hidden'}).toString();var moreButtonWrapper=css({position:'absolute',right:0,bottom:
|
|
5
|
+
*/var container=function container(height){return css({position:'relative',maxHeight:height,overflow:'hidden',marginBottom:variables.gap.small}).toString();};var layout=css({display:'flex',alignContent:'flex-start',flexWrap:'wrap',padding:'8px 5px',overflow:'hidden'}).toString();var moreButtonWrapper=css({position:'absolute',right:0,bottom:6,marginLeft:'auto'}).toString();var moreButtonBase={marginLeft:'auto',outline:0,padding:9,fontSize:'0.8rem',fontWeight:500,textTransform:'uppercase'};var moreButton=css(_extends({},moreButtonBase)).toString();var moreButtonInverted=css(_extends({},moreButtonBase)).toString();export default{container:container,layout:layout,moreButtonWrapper:moreButtonWrapper,moreButton:moreButton,moreButtonInverted:moreButtonInverted};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import PropTypes from'prop-types';/**
|
|
2
2
|
* Conditionally wraps React children with another component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var ConditionalWrapper=function ConditionalWrapper(_ref){var condition=_ref.condition,wrapper=_ref.wrapper,children=_ref.children;return
|
|
5
|
+
*/var ConditionalWrapper=function ConditionalWrapper(_ref){var condition=_ref.condition,wrapper=_ref.wrapper,wrapperFalsy=_ref.wrapperFalsy,children=_ref.children;if(condition){return wrapper(children);}return typeof wrapperFalsy==='function'?wrapperFalsy(children):children;};ConditionalWrapper.propTypes={/**
|
|
6
|
+
* When set to `true`, the component children will be wrapped by the React component which is
|
|
7
|
+
* defined in `wrapper`.
|
|
8
|
+
* When the to `false`, the component children will be wrapped by the React component which is
|
|
9
|
+
* optionally defined in `wrapperFalsy`.
|
|
10
|
+
*/condition:PropTypes.bool.isRequired,children:PropTypes.node,wrapper:PropTypes.elementType,wrapperFalsy:PropTypes.elementType};ConditionalWrapper.defaultProps={children:null,wrapper:null,wrapperFalsy:null};export default ConditionalWrapper;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
var _excluded=["className","onChange","onFocus","onBlur","value","maxDecimals","unit","minValue","maxValue"];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 _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import React,{useRef,useState,useCallback,useLayoutEffect,useEffect,forwardRef}from'react';import PropTypes from'prop-types';import{isIOs}from'@shopgate/pwa-core';import{parseFloatString,formatFloat}from"./helper";/**
|
|
1
|
+
var _excluded=["className","onChange","onFocus","onBlur","value","maxDecimals","unit","minValue","maxValue","onKeyDown"];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 _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import React,{useRef,useState,useCallback,useLayoutEffect,useEffect,forwardRef}from'react';import PropTypes from'prop-types';import noop from'lodash/noop';import{isIOs}from'@shopgate/pwa-core';import{parseFloatString,formatFloat}from"./helper";/**
|
|
2
2
|
* A Quantity Input with unit support.
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/var QuantityInput=forwardRef(function(_ref,outerInputRef){var className=_ref.className,onChange=_ref.onChange,customOnFocus=_ref.onFocus,customOnBlur=_ref.onBlur,value=_ref.value,maxDecimals=_ref.maxDecimals,unit=_ref.unit,minValue=_ref.minValue,maxValue=_ref.maxValue,inputProps=_objectWithoutProperties(_ref,_excluded);var inputRef=outerInputRef||useRef();var _useState=useState(formatFloat(value,maxDecimals)),_useState2=_slicedToArray(_useState,2),inputValue=_useState2[0],setInputValue=_useState2[1];var _useState3=useState(false),_useState4=_slicedToArray(_useState3,2),isFocused=_useState4[0],setIsFocused=_useState4[1];var onFocus=useCallback(function(event){customOnFocus(event);setIsFocused(true);},[customOnFocus]);var onBlur=useCallback(function(event){var newValue=parseFloatString(inputValue,maxDecimals);setIsFocused(false);// If invalid switch to old value.
|
|
5
|
-
if(Number.isNaN(parseFloat(inputValue))){setInputValue(formatFloat(value,maxDecimals));return;}if(newValue!==value){onChange(newValue);}customOnBlur(event,newValue);},[customOnBlur,inputValue,maxDecimals,onChange,value]);var handleChange=useCallback(function(event){var newValue=event.target.value;
|
|
4
|
+
*/var QuantityInput=forwardRef(function(_ref,outerInputRef){var className=_ref.className,onChange=_ref.onChange,customOnFocus=_ref.onFocus,customOnBlur=_ref.onBlur,value=_ref.value,maxDecimals=_ref.maxDecimals,unit=_ref.unit,minValue=_ref.minValue,maxValue=_ref.maxValue,onKeyDown=_ref.onKeyDown,inputProps=_objectWithoutProperties(_ref,_excluded);var inputRef=outerInputRef||useRef();var _useState=useState(formatFloat(value,maxDecimals)),_useState2=_slicedToArray(_useState,2),inputValue=_useState2[0],setInputValue=_useState2[1];var _useState3=useState(false),_useState4=_slicedToArray(_useState3,2),isFocused=_useState4[0],setIsFocused=_useState4[1];var onFocus=useCallback(function(event){customOnFocus(event);setIsFocused(true);},[customOnFocus]);var onBlur=useCallback(function(event){var newValue=parseFloatString(inputValue,maxDecimals);setIsFocused(false);// If invalid switch to old value.
|
|
5
|
+
if(Number.isNaN(parseFloat(inputValue))){setInputValue(formatFloat(value,maxDecimals));return;}if(minValue&&newValue<minValue){newValue=minValue;}if(maxValue&&newValue>maxValue){newValue=maxValue;}setInputValue("".concat(newValue));if(newValue!==value){onChange(newValue);}customOnBlur(event,newValue);},[customOnBlur,inputValue,maxDecimals,maxValue,minValue,onChange,value]);var handleChange=useCallback(function(event){var newValue=event.target.value;setInputValue(newValue);},[]);var handleKeyDown=useCallback(function(event){if(event.key==='Enter'){// Prevents false positive validation error when enter key is pressed inside input
|
|
6
|
+
event.preventDefault();if(inputRef.current){inputRef.current.blur();}}if(typeof onKeyDown==='function'){onKeyDown(event);}},[inputRef,onKeyDown]);// Select the current input value after focus.
|
|
6
7
|
useLayoutEffect(function(){if(isFocused&&isIOs){inputRef.current.select();}},[inputRef,isFocused]);// Sync actual float value with displayed content.
|
|
7
8
|
useEffect(function(){setInputValue(formatFloat(value,maxDecimals));},[maxDecimals,value]);// Stop the context menu from opening.
|
|
8
|
-
useLayoutEffect(function(){inputRef.current.addEventListener('contextmenu',function(event){event.preventDefault();event.stopPropagation();return false;});},[inputRef]);var displayedValue=!isFocused&&unit?"".concat(inputValue," ").concat(unit):inputValue;return React.createElement("input",_extends({ref:inputRef},inputProps,{inputMode:maxDecimals>0?'decimal':'numeric'/* Pattern signals some browsers to use specialized keyboard (if inputmode not supported */,pattern:maxDecimals>0?'[0-9.,]*':'[0–9]*',onFocus:onFocus,onBlur:onBlur,className:className,value:displayedValue,onChange:handleChange,onClick:function onClick(event){event.preventDefault();event.stopPropagation();if(inputRef.current){inputRef.current.focus();}}}));});QuantityInput.defaultProps={className:'',maxDecimals:2,unit:null,minValue:null,maxValue:null,onFocus:
|
|
9
|
+
useLayoutEffect(function(){inputRef.current.addEventListener('contextmenu',function(event){event.preventDefault();event.stopPropagation();return false;});},[inputRef]);var displayedValue=!isFocused&&unit?"".concat(inputValue," ").concat(unit):inputValue;return React.createElement("input",_extends({ref:inputRef},inputProps,{inputMode:maxDecimals>0?'decimal':'numeric'/* Pattern signals some browsers to use specialized keyboard (if inputmode not supported */,pattern:maxDecimals>0?'[0-9.,]*':'[0–9]*',onFocus:onFocus,onBlur:onBlur,className:className,value:displayedValue,onChange:handleChange,onKeyDown:handleKeyDown,onClick:function onClick(event){event.preventDefault();event.stopPropagation();if(inputRef.current){inputRef.current.focus();}}}));});QuantityInput.defaultProps={className:'',maxDecimals:2,unit:null,minValue:null,maxValue:null,onFocus:noop,onChange:noop,onBlur:noop,onKeyDown:noop};export default QuantityInput;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import PropTypes from'prop-types';import{useResponsiveValue}from"./hooks";/**
|
|
2
2
|
* Renders a responsive container that allows to render based on width.
|
|
3
3
|
* @param {Object} props Component props.
|
|
4
4
|
* @returns {React.Node}
|
|
5
|
-
*/var ResponsiveContainer=function ResponsiveContainer(_ref){var breakpoint=_ref.breakpoint,webOnly=_ref.webOnly,webAlways=_ref.webAlways,appOnly=_ref.appOnly,appAlways=_ref.appAlways,children=_ref.children
|
|
6
|
-
var _useState=useState(null),_useState2=_slicedToArray(_useState,2),activeBreakpoint=_useState2[0],setActiveBreakpoint=_useState2[1];// Calculate if should render due to visibility.
|
|
7
|
-
/* eslint-disable react-hooks/exhaustive-deps */var breakpointSafe=useMemo(function(){var parsed=parser(comparators,breakpoint,{breakpoint:breakpoint,webOnly:webOnly,webAlways:webAlways,appOnly:appOnly,appAlways:appAlways});return parsed;},[activeBreakpoint,breakpoint]);/* eslint-enable react-hooks/exhaustive-deps */ // Watch for resize changes.
|
|
8
|
-
useEffect(function(){return addListener(function(newBreakpoint){setActiveBreakpoint(newBreakpoint);});},[]);// Ignore rendering if one of given condition applies.
|
|
9
|
-
if(!breakpointSafe){return null;}return children;};ResponsiveContainer.propTypes={appAlways:PropTypes.bool,appOnly:PropTypes.bool,breakpoint:PropTypes.string,// eslint-disable-next-line react/forbid-prop-types
|
|
5
|
+
*/var ResponsiveContainer=function ResponsiveContainer(_ref){var breakpoint=_ref.breakpoint,webOnly=_ref.webOnly,webAlways=_ref.webAlways,appOnly=_ref.appOnly,appAlways=_ref.appAlways,children=_ref.children;var render=useResponsiveValue(breakpoint,{webOnly:webOnly,webAlways:webAlways,appOnly:appOnly,appAlways:appAlways});if(!render){return null;}return children;};ResponsiveContainer.propTypes={appAlways:PropTypes.bool,appOnly:PropTypes.bool,breakpoint:PropTypes.string,// eslint-disable-next-line react/forbid-prop-types
|
|
10
6
|
children:PropTypes.any,webAlways:PropTypes.bool,webOnly:PropTypes.bool};ResponsiveContainer.defaultProps={children:null,breakpoint:'>=xs',appAlways:false,webAlways:false,webOnly:false,appOnly:false};export default ResponsiveContainer;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// Ugly imports to avoid breaking tests due to circular dependencies
|
|
2
|
+
import{isIOSTheme}from'@shopgate/engage/core/helpers/isIOSTheme';import{hasWebBridge}from'@shopgate/engage/core/helpers/bridge';var iosThemeActive=isIOSTheme();/* eslint-disable extra-rules/no-single-line-objects */var breakpoints=[{name:'xs',from:0,to:600},{name:'sm',from:600,to:960},{name:'md',from:960,to:1280},{name:'lg',from:1280,to:1920},{name:'xl',from:1920,to:Number.MAX_VALUE}];/* eslint-enable extra-rules/no-single-line-objects */ /**
|
|
2
3
|
* Generates a media query for different breakpoints and platform.
|
|
3
4
|
* @param {Object} comparators Comparators.
|
|
4
5
|
* @param {string} breakpoint Breakpoint rule.
|
|
@@ -0,0 +1,20 @@
|
|
|
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;}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{useState,useMemo,useEffect}from'react';import{addListener}from"./listener";import{parser}from"./breakpoints";var comparators={'>=':function _(from,to,width){return width>=from;},'>':function _(from,to,width){return width>=to;},'<':function _(from,to,width){return width<from;},'<=':function _(from,to,width){return width<to;},'':function _(from,to,width){return width>=from&&width<to;}};/**
|
|
2
|
+
* Custom hook to determine the visibility or value based on the current active breakpoint
|
|
3
|
+
* and provided conditions.
|
|
4
|
+
* It listens for changes in the viewport or platform breakpoints and returns a value.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} [breakpoint=">=xs"] - The breakpoint condition to match (e.g., '>=md', '<lg').
|
|
7
|
+
* @param {Object} [options={}] - Additional options for customizing behavior.
|
|
8
|
+
* @param {*} [options.valueMatch=true] - Return value when the provided conditions match.
|
|
9
|
+
* @param {*} [options.valueMiss=false] - Return value when the provided conditions do not match.
|
|
10
|
+
* @param {boolean} [options.webOnly=false] If true, the hook will only match in PWA website mode.
|
|
11
|
+
* @param {boolean} [options.webAlways=false] If true, the hook will always match in PWA website
|
|
12
|
+
* mode regardless of the breakpoint.
|
|
13
|
+
* @param {boolean} [options.appOnly=false] If true, the hook will only match in PWA app mode.
|
|
14
|
+
* @param {boolean} [options.appAlways=false] If true, the hook will always match in PWA app mode,
|
|
15
|
+
* regardless of the breakpoint.
|
|
16
|
+
* @returns {boolean}
|
|
17
|
+
*/export var useResponsiveValue=function useResponsiveValue(){var breakpoint=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'>=xs';var options=arguments.length>1?arguments[1]:undefined;var _valueMatch$valueMiss=_extends({valueMatch:true,valueMiss:false,appAlways:false,appOnly:false,webAlways:false,webOnly:false},options),webOnly=_valueMatch$valueMiss.webOnly,webAlways=_valueMatch$valueMiss.webAlways,appOnly=_valueMatch$valueMiss.appOnly,appAlways=_valueMatch$valueMiss.appAlways,valueMiss=_valueMatch$valueMiss.valueMiss,valueMatch=_valueMatch$valueMiss.valueMatch;// Active breakpoint used for triggering rerenders on resize.
|
|
18
|
+
var _useState=useState(null),_useState2=_slicedToArray(_useState,2),activeBreakpoint=_useState2[0],setActiveBreakpoint=_useState2[1];// Calculate if we have a match for the conditions
|
|
19
|
+
/* eslint-disable react-hooks/exhaustive-deps */var isMatch=useMemo(function(){var parsed=parser(comparators,breakpoint,{breakpoint:breakpoint,webOnly:webOnly,webAlways:webAlways,appOnly:appOnly,appAlways:appAlways});return parsed;},[activeBreakpoint,breakpoint]);/* eslint-enable react-hooks/exhaustive-deps */ // Watch for resize changes.
|
|
20
|
+
useEffect(function(){return addListener(function(newBreakpoint){setActiveBreakpoint(newBreakpoint);});},[]);return isMatch?valueMatch:valueMiss;};
|
|
@@ -1,5 +1,5 @@
|
|
|
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,{useState,
|
|
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,{useState,useCallback,useEffect}from'react';import PropTypes from'prop-types';import classNames from'classnames';import{viewScroll$}from'@shopgate/engage/core/streams';import{root,scrolledIn,scrolledOut,transition}from"./style";/**
|
|
2
2
|
* Scroll Header component
|
|
3
3
|
* @param {Object} props props
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/function ScrollHeader(_ref){var className=_ref.className,children=_ref.children
|
|
5
|
+
*/function ScrollHeader(_ref){var className=_ref.className,children=_ref.children,hideOnScroll=_ref.hideOnScroll,scrollOffset=_ref.scrollOffset;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),shouldHideHeader=_useState2[0],setShouldHideHeader=_useState2[1];var onScroll=useCallback(function(scrollEvent){var scrollTop=scrollEvent.scrollTop,scrolled=scrollEvent.scrolled,scrollOut=scrollEvent.scrollOut,scrollIn=scrollEvent.scrollIn;if(!scrolled){return;}if(!shouldHideHeader&&scrollOut&&scrollTop>=scrollOffset){setShouldHideHeader(true);}if(shouldHideHeader&&scrollIn){setShouldHideHeader(false);}},[scrollOffset,shouldHideHeader]);useEffect(function(){if(hideOnScroll){var subscription=viewScroll$.subscribe(onScroll);return function(){return subscription.unsubscribe();};}return undefined;});return React.createElement("div",{className:classNames(root,transition,className,_defineProperty(_defineProperty({},scrolledIn,!shouldHideHeader),scrolledOut,shouldHideHeader))},children);}ScrollHeader.defaultProps={className:null,hideOnScroll:true,scrollOffset:100};export default ScrollHeader;
|
|
@@ -1 +1 @@
|
|
|
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{css}from'glamor';import{responsiveMediaQuery}from'@shopgate/engage/styles';export var
|
|
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{css}from'glamor';import{responsiveMediaQuery}from'@shopgate/engage/styles';export var root=css(_defineProperty({position:'sticky',left:0,backgroundColor:'#fff'},responsiveMediaQuery('<=xs',{appAlways:true}),{boxShadow:'rgba(0, 0, 0, 0.118) 0px 1px 6px, rgba(0, 0, 0, 0.118) 0px 1px 4px'}));export var scrolledIn=css({'&&':{transform:'translateY(0%)'}});export var scrolledOut=css({'&&':{transform:'translateY(-250%)'}});export var transition=css({transition:'transform 0.2s ease,transform 0.2s'});
|
package/core/constants/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{INDEX_PATH,INDEX_PATH_DEEPLINK,LOGIN_PATH}from'@shopgate/pwa-common/constants/RoutePaths';export{RECEIVE_SHOP_SETTINGS,ERROR_SHOP_SETTINGS,CACHE_LEASE_SHOP_SETTINGS,SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE,SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT,SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT,SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP,SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB,SHOP_SETTING_PRODUCTS_SORT_ORDER,SHOP_SETTING_COOKIE_CONSENT_MODE,SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT,SHOP_SETTING_IMAGES,SHOP_SETTING_IMAGES_PRODUCT_PLACEHOLDER,SHOP_SETTING_IMAGES_CATEGORY_PLACEHOLDER,SHOP_SETTING_IMAGES_FAVICON,SHOP_SETTING_NUMBER_OF_ADDRESS_LINES,SHOP_SETTING_REGISTRATION_MODE_SIMPLE,SHOP_SETTING_REGISTRATION_MODE_EXTENDED,SHOP_SETTING_WISHLIST_ITEM_QUANTITY_ENABLED,SHOP_SETTING_WISHLIST_ITEM_NOTES_ENABLED,SHOP_SETTING_LOAD_WISHLIST_ON_APP_START_ENABLED,SHOP_SETTING_SHOW_WISHLIST_ITEMS_COUNT_BADGE}from"./shopSettings";export{RECEIVE_MERCHANT_SETTINGS,MERCHANT_SETTINGS_LOCATION_BASED_SHOPPING_ENABLED,MERCHANT_SETTINGS_SUBSTITUTION_PREFERENCES_ENABLED,MERCHANT_SETTINGS_CUSTOMER_ATTRIBUTES,MERCHANT_SETTINGS_FULFILLMENT_SCHEDULED_ENABLED,MERCHANT_SETTINGS_RESTRICT_MULTI_LOCATION_ORDERS,MERCHANT_SETTINGS_DEFAULT_CURRENCY,MERCHANT_SETTINGS_ENABLE_WEB_INDEXING,MERCHANT_SETTINGS_PRODUCT_SHOW_ALTERNATIVE_LOCATION,MERCHANT_SETTINGS_PRODUCTLIST_SHOW_INVENTORY}from"./merchantSettings";export{SHOPGATE_CORE_GET_SHOP_SETTINGS,EUNAUTHORIZED,EAUTHENTICATION}from"./pipelines";export*from"./actionTypes";export*from"./appFeatures";export*from"./deviceTypes";export*from"./geolocationRequest";// Core Constants
|
|
2
|
-
export*from'@shopgate/pwa-core/constants/AppEvents';export*from'@shopgate/pwa-core/constants/AppPermissions';export*from'@shopgate/pwa-core/constants/ErrorHandleTypes';export*from'@shopgate/pwa-core/constants/Pipeline';export*from'@shopgate/pwa-core/constants/ProcessTypes';export*from'@shopgate/pwa-core/constants/Scanner';export*from'@shopgate/pwa-core/constants/Trilean';// Common Constants
|
|
2
|
+
export*from'@shopgate/pwa-core/constants/ErrorManager';export*from'@shopgate/pwa-core/constants/AppEvents';export*from'@shopgate/pwa-core/constants/AppPermissions';export*from'@shopgate/pwa-core/constants/ErrorHandleTypes';export*from'@shopgate/pwa-core/constants/Pipeline';export*from'@shopgate/pwa-core/constants/ProcessTypes';export*from'@shopgate/pwa-core/constants/Scanner';export*from'@shopgate/pwa-core/constants/Trilean';// Common Constants
|
|
3
3
|
export*from'@shopgate/pwa-common/constants/ActionTypes';export*from'@shopgate/pwa-common/constants/Configuration';export*from'@shopgate/pwa-common/constants/Device';export*from'@shopgate/pwa-common/constants/DisplayOptions';export*from'@shopgate/pwa-common/constants/Pipelines';export*from'@shopgate/pwa-common/constants/Portals';// CLIENT CONSTANTS
|
|
4
4
|
export*from'@shopgate/pwa-common/constants/client';// MENU CONSTANTS
|
|
5
5
|
export*from'@shopgate/pwa-common/constants/MenuIDs';// MODAL CONSTANTS
|
|
@@ -8,7 +8,8 @@ return false;}// Supported when the feature flags contain the push opt-in flag
|
|
|
8
8
|
return window.SGAppInfo.featureFlags.Push['1'].flags.includes(APP_FEATURE_PUSH_OPT_IN);};/**
|
|
9
9
|
* Determines if the app supports the cookie consent feature
|
|
10
10
|
* @returns {boolean}
|
|
11
|
-
*/export var appSupportsCookieConsent=function appSupportsCookieConsent(){var _window2,_window2$SGAppInfo,_window2$SGAppInfo$fe,_window2$SGAppInfo$fe2,_window2$SGAppInfo$fe3;if(
|
|
11
|
+
*/export var appSupportsCookieConsent=function appSupportsCookieConsent(){var _window2,_window2$SGAppInfo,_window2$SGAppInfo$fe,_window2$SGAppInfo$fe2,_window2$SGAppInfo$fe3;if(hasWebBridge()){// Deactivated in browser mode for now
|
|
12
|
+
return false;}if(!hasSGJavaScriptBridge()){// Always supported in development
|
|
12
13
|
return true;}if(!Array.isArray((_window2=window)===null||_window2===void 0?void 0:(_window2$SGAppInfo=_window2.SGAppInfo)===null||_window2$SGAppInfo===void 0?void 0:(_window2$SGAppInfo$fe=_window2$SGAppInfo.featureFlags)===null||_window2$SGAppInfo$fe===void 0?void 0:(_window2$SGAppInfo$fe2=_window2$SGAppInfo$fe.Analytics)===null||_window2$SGAppInfo$fe2===void 0?void 0:(_window2$SGAppInfo$fe3=_window2$SGAppInfo$fe2['1'])===null||_window2$SGAppInfo$fe3===void 0?void 0:_window2$SGAppInfo$fe3.flags)){// Not supported on app versions that don't provide the featureFlags object
|
|
13
14
|
return false;}// Supported when the feature flags contain the cookie consent flag
|
|
14
15
|
return window.SGAppInfo.featureFlags.Analytics['1'].flags.includes(APP_FEATURE_COOKIE_CONSENT);};
|
package/core/helpers/i18n.js
CHANGED
|
@@ -16,7 +16,7 @@ import get from'lodash/get';import{getTranslator,getPriceFormatter,getDateFormat
|
|
|
16
16
|
*/var I18n=function I18n(){var didInit=false;/**
|
|
17
17
|
* Function that throws when called. Used in a default instance of i18n to notify developer
|
|
18
18
|
* when the module is used without initialization.
|
|
19
|
-
*/var notReadyCb=function notReadyCb(){logger.error('i18n is not yet ready. Please postpone translations until App is bootstrapped.');};return{init:function init(_ref){var _this=this;var locales=_ref.locales,lang=_ref.lang,_ref$currencyLocale=_ref.currencyLocale,currencyLocale=_ref$currencyLocale===void 0?null:_ref$currencyLocale;if(didInit){logger.warn('Looks like i18n locales are already
|
|
19
|
+
*/var notReadyCb=function notReadyCb(){logger.error('i18n is not yet ready. Please postpone translations until App is bootstrapped.');};return{init:function init(_ref){var _this=this;var locales=_ref.locales,lang=_ref.lang,_ref$currencyLocale=_ref.currencyLocale,currencyLocale=_ref$currencyLocale===void 0?null:_ref$currencyLocale;if(didInit){logger.warn('Looks like i18n locales are already initialized. Changing locales now may lead to inconsistent translations.');}didInit=true;this.text=getTranslator(locales,lang);this.textWithDefault=function(key,defaultText){var text=_this.text(key);return text===key?defaultText:text;};this.price=getPriceFormatter(currencyLocale||lang);this.date=getDateFormatter(lang);this.time=getTimeFormatter(lang);this.number=getNumberFormatter(lang);this.getSupplementalData=function(){return locales.supplementalData||{};};this.getPath=function(path){return get(locales,path);};this.getLang=function(){return lang;};// If component decides to act accordingly this information should be exposed.
|
|
20
20
|
this.ready=true;},text:notReadyCb,textWithDefault:notReadyCb,price:notReadyCb,date:notReadyCb,time:notReadyCb,number:notReadyCb,getSupplementalData:notReadyCb,getPath:notReadyCb,getLang:notReadyCb,ready:false};};/**
|
|
21
21
|
* @type {I18nHelpers}
|
|
22
22
|
*/export var i18n=I18n();/**
|
package/core/helpers/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @module core */import{getCurrentRoute as getCurrentRouteHelper,router,history,parseQueryStringToObject,parseObjectToQueryString}from'@shopgate/pwa-common/helpers/router';export*from"./environment";export*from"./appFeatures";export*from"./appPermissions";export*from"./baseUrl";export*from"./bridge";export{isBeta}from"../config/isBeta";export{getFullImageSource}from"./getFullImageSource";export{getImageFormat}from"./getImageFormat";export{i18n,getWeekDaysOrder}from"./i18n";export{updateLegacyNavigationBar}from"./updateLegacyNavigationBar";export{default as nl2br}from"./nl2br";export*from"./string";export{isIOSTheme}from"./isIOSTheme";export{isTouchDevice}from"./isTouchDevice";export{generateGoogleMapsDirectionsUrl}from"./googleMaps";export{useScrollContainer}from"./scrollContainer";export{getDeviceTypeForCms}from"./deviceType";export*from"./featureFlag";// --------------- CORE --------------- //
|
|
2
|
-
export
|
|
2
|
+
export{logger,ajaxUrl,hasSGJavaScriptBridge,useBrowserConnector,hasWebBridgeCore,logDeprecationMessage}from'@shopgate/pwa-core/helpers';export{default as logGroup}from'@shopgate/pwa-core/helpers/logGroup';export*from'@shopgate/pwa-core/helpers/version';export*from'@shopgate/pwa-common/helpers/data';export*from'@shopgate/pwa-common/helpers/date';export*from'@shopgate/pwa-common/helpers/dom';export{env,isDev,isProd,isRemote,isStaging}from'@shopgate/pwa-common/helpers/environment';export{default as decodeHTML}from'@shopgate/pwa-common/helpers/html/decodeHTML';export*from'@shopgate/pwa-common/helpers/html/handleDOM';export{default as parseHTML}from'@shopgate/pwa-common/helpers/html/parseHTML';export{default as getTranslator}from'@shopgate/pwa-common/helpers/i18n/getTranslator';export{default as getPriceFormatter}from'@shopgate/pwa-common/helpers/i18n/getPriceFormatter';export{default as getDateFormatter}from'@shopgate/pwa-common/helpers/i18n/getDateFormatter';export{default as getTimeFormatter}from'@shopgate/pwa-common/helpers/i18n/getTimeFormatter';export{default as getNumberFormatter}from'@shopgate/pwa-common/helpers/i18n/getNumberFormatter';export*from'@shopgate/pwa-common/helpers/legacy';// TODO: Can only be exported once the theme uses it. causes issues with the custom routes feature.
|
|
3
3
|
/*
|
|
4
4
|
export { default as portalCollection } from '@shopgate/pwa-common/helpers/portals/portalCollection';
|
|
5
5
|
export { default as routePortals } from '@shopgate/pwa-common/helpers/portals/routePortals';
|
package/core/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{useAsyncMemo}from"./useAsyncMemo";export{useRoute}from"./useRoute";export{useTheme}from"./useTheme";export{useApp}from"./useApp";export{useCurrentProduct}from"./useCurrentProduct";export{useNavigation}from"./useNavigation";export{usePageConfig}from"./usePageConfig";export{usePageSettings}from"./usePageSettings";export{useWidgetConfig}from"./useWidgetConfig";export{useWidgetSettings}from"./useWidgetSettings";export{useWidgetStyles}from"./useWidgetStyles";export*from"./html";export{useScroll}from"./useScroll";export{usePrevious}from"./usePrevious";
|
|
1
|
+
export{useAsyncMemo}from"./useAsyncMemo";export{useRoute}from"./useRoute";export{useTheme}from"./useTheme";export{useApp}from"./useApp";export{useCurrentProduct}from"./useCurrentProduct";export{useNavigation}from"./useNavigation";export{usePageConfig}from"./usePageConfig";export{usePageSettings}from"./usePageSettings";export{useWidgetConfig}from"./useWidgetConfig";export{useWidgetSettings}from"./useWidgetSettings";export{useWidgetStyles}from"./useWidgetStyles";export*from"./html";export{useScroll}from"./useScroll";export{usePrevious}from"./usePrevious";export{useResponsiveValue}from'@shopgate/engage/components/ResponsiveContainer/hooks';
|
package/core/streams/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export*from"./app";export*from"./appPermissions";export*from'@shopgate/pwa-common/streams/main';export*from'@shopgate/pwa-common/streams/error';// --------------- APP --------------- //
|
|
1
|
+
export*from"./app";export*from"./appPermissions";export*from'@shopgate/pwa-common/streams/main';export*from'@shopgate/pwa-common/streams/error';export*from'@shopgate/pwa-common/streams/view';// --------------- APP --------------- //
|
|
2
2
|
export*from'@shopgate/pwa-common/streams/app';// --------------- CLIENT --------------- //
|
|
3
3
|
export*from'@shopgate/pwa-common/streams/client';// --------------- ROUTER --------------- //
|
|
4
4
|
export*from'@shopgate/pwa-common/streams/router';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{appWillStart$}from'@shopgate/
|
|
1
|
+
import{appWillStart$}from'@shopgate/engage/core/streams';import{configuration}from'@shopgate/engage/core/collections';import{hasNewServices}from'@shopgate/engage/core/helpers';import{CONFIGURATION_COLLECTION_KEY_BASE_URL}from'@shopgate/engage/core/constants';import{reloadApp$}from"../streams";import{reloadApp}from"../action-creators";/**
|
|
2
2
|
* App subscriptions
|
|
3
3
|
* @param {Function} subscribe The subscribe function
|
|
4
|
-
*/export default function app(subscribe){subscribe(appWillStart$,function(_ref){var dispatch=_ref.dispatch;// Add global function to enable PWA reload from the console
|
|
4
|
+
*/export default function app(subscribe){subscribe(appWillStart$,function(_ref){var dispatch=_ref.dispatch;console.log("%c\u2139\uFE0F PWA uses ".concat(hasNewServices()?'NEW':'OLD'," services"),'color: blue');// Add global function to enable PWA reload from the console
|
|
5
5
|
window.reloadSGApp=function(){dispatch(reloadApp());};});subscribe(reloadApp$,function(){// A deployed app can only be reloaded on the base url. So we first set this as current route
|
|
6
6
|
// before the reload happens.
|
|
7
7
|
window.history.replaceState({},null,configuration.get(CONFIGURATION_COLLECTION_KEY_BASE_URL));window.location.reload();});}
|
|
@@ -3,12 +3,12 @@ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimi
|
|
|
3
3
|
*/var makeMapStateToProps=function makeMapStateToProps(){var isRopeProductOrderable=makeIsRopeProductOrderable(function(state,props){var _getPreferredLocation;return(_getPreferredLocation=getPreferredLocation(state,props))===null||_getPreferredLocation===void 0?void 0:_getPreferredLocation.code;},function(state,props){return props.variantId||props.productId||null;});return function(state,props){return{isBaseProduct:isBaseProductSelector(state,props),hasVariants:hasProductVariants(state,props),isOrderable:isProductOrderable(state,props),isRopeProductOrderable:isRopeProductOrderable(state,props)};};};/**
|
|
4
4
|
* @param {Function} dispatch Dispatch.
|
|
5
5
|
* @returns {Object}
|
|
6
|
-
*/var mapDispatchToProps=function mapDispatchToProps(dispatch){return{showModal:function showModal(){return dispatch(showModalAction.apply(void 0,arguments));},historyPush:function historyPush(){return dispatch(historyPushAction.apply(void 0,arguments));},updateFavoriteItem:function updateFavoriteItem(productId,listId,quantity,notes){dispatch(updateFavorite(productId,listId,quantity,notes));},openCommentDialog:function openCommentDialog(productId,listId){return dispatch(openFavoritesCommentDialog(productId,listId));}};};var styles={root:css({display:'flex',position:'relative','&:not(:last-child)':{marginBottom:16}}).toString(),imageContainer:css(_defineProperty(_defineProperty(_defineProperty({flex:0.4,marginRight:18},responsiveMediaQuery('>=xs',{appAlways:true}),{maxWidth:120,minWidth:80}),responsiveMediaQuery('>=md',{webOnly:true}),{maxWidth:120,minWidth:80}),responsiveMediaQuery('>=md',{webOnly:true}),{width:120,flex:'none'})).toString(),infoContainer:css({flex:1,display:'flex',flexDirection:'column',flexWrap:'wrap',gap:8}).toString(),infoContainerRow:css({flexDirection:'row',display:'flex',justifyContent:'space-between'}).toString(),quantityContainer:css({flexDirection:'row',display:'flex',alignItems:'center',flexWrap:'wrap',gap:16}).toString(),priceContainer:css({minWidth:100}).toString(),priceInfo:css({wordBreak:'break-word',fontSize:'0.875rem',lineHeight:'0.875rem',color:'var(--color-text-low-emphasis)',padding:"".concat(variables.gap.xsmall,"px 0")}).toString(),titleWrapper:css({display:'flex',flexDirection:'column',gap:8}).toString(),titleContainer:css({marginRight:10,flex:1}).toString(),title:css({fontSize:17,fontWeight:600}).toString(),removeContainer:css({display:'flex',flexShrink:0,alignItems:'flex-start'})};/**
|
|
6
|
+
*/var mapDispatchToProps=function mapDispatchToProps(dispatch){return{showModal:function showModal(){return dispatch(showModalAction.apply(void 0,arguments));},historyPush:function historyPush(){return dispatch(historyPushAction.apply(void 0,arguments));},updateFavoriteItem:function updateFavoriteItem(productId,listId,quantity,notes){dispatch(updateFavorite(productId,listId,quantity,notes));},openCommentDialog:function openCommentDialog(productId,listId){return dispatch(openFavoritesCommentDialog(productId,listId));}};};var styles={root:css({display:'flex',position:'relative','&:not(:last-child)':{marginBottom:16}}).toString(),imageContainer:css(_defineProperty(_defineProperty(_defineProperty({flex:0.4,marginRight:18},responsiveMediaQuery('>=xs',{appAlways:true}),{maxWidth:120,minWidth:80}),responsiveMediaQuery('>=md',{webOnly:true}),{maxWidth:120,minWidth:80}),responsiveMediaQuery('>=md',{webOnly:true}),{width:120,flex:'none'})).toString(),infoContainer:css({flex:1,display:'flex',flexDirection:'column',flexWrap:'wrap',gap:8}).toString(),infoContainerRow:css({flexDirection:'row',display:'flex',justifyContent:'space-between'}).toString(),quantityContainer:css({flexDirection:'row',display:'flex',alignItems:'center',flexWrap:'wrap',gap:16}).toString(),priceContainer:css({minWidth:100}).toString(),priceContainerInner:css({display:'inline-block',textAlign:'right'}),price:css({justifyContent:'flex-end'}).toString(),priceInfo:css({wordBreak:'break-word',fontSize:'0.875rem',lineHeight:'0.875rem',color:'var(--color-text-low-emphasis)',padding:"".concat(variables.gap.xsmall,"px 0")}).toString(),titleWrapper:css({display:'flex',flexDirection:'column',gap:8}).toString(),titleContainer:css({marginRight:10,flex:1}).toString(),title:css({fontSize:17,fontWeight:600}).toString(),removeContainer:css({display:'flex',flexShrink:0,alignItems:'flex-start'})};/**
|
|
7
7
|
* Favorite Item component
|
|
8
|
-
* @return {JSX}
|
|
9
|
-
*/var FavoriteItem=function FavoriteItem(_ref){var _product$price,_product$price2,_product$price3;var listId=_ref.listId,product=_ref.product,notes=_ref.notes,quantity=_ref.quantity,remove=_ref.remove,addToCart=_ref.addToCart,isBaseProduct=_ref.isBaseProduct,isOrderable=_ref.isOrderable,isRopeProductOrderable=_ref.isRopeProductOrderable,hasVariants=_ref.hasVariants,showModal=_ref.showModal,historyPush=_ref.historyPush,updateFavoriteItem=_ref.updateFavoriteItem,openCommentDialog=_ref.openCommentDialog;var _ref2=getThemeSettings('AppImages')||{},gridResolutions=_ref2.ListImage;var _useState=useState(!isOrderable&&!hasVariants),_useState2=_slicedToArray(_useState,2),isDisabled=_useState2[0],setIsDisabled=_useState2[1];var currency=((_product$price=product.price)===null||_product$price===void 0?void 0:_product$price.currency)||'EUR';var defaultPrice=((_product$price2=product.price)===null||_product$price2===void 0?void 0:_product$price2.unitPrice)||0;var specialPrice=(_product$price3=product.price)===null||_product$price3===void 0?void 0:_product$price3.unitPriceStriked;var hasStrikePrice=typeof specialPrice==='number'&&specialPrice>
|
|
8
|
+
* @return {JSX.Element}
|
|
9
|
+
*/var FavoriteItem=function FavoriteItem(_ref){var _product$price,_product$price2,_product$price3;var listId=_ref.listId,product=_ref.product,notes=_ref.notes,quantity=_ref.quantity,remove=_ref.remove,addToCart=_ref.addToCart,isBaseProduct=_ref.isBaseProduct,isOrderable=_ref.isOrderable,isRopeProductOrderable=_ref.isRopeProductOrderable,hasVariants=_ref.hasVariants,showModal=_ref.showModal,historyPush=_ref.historyPush,updateFavoriteItem=_ref.updateFavoriteItem,openCommentDialog=_ref.openCommentDialog;var _ref2=getThemeSettings('AppImages')||{},gridResolutions=_ref2.ListImage;var _useState=useState(!isOrderable&&!hasVariants),_useState2=_slicedToArray(_useState,2),isDisabled=_useState2[0],setIsDisabled=_useState2[1];var currency=((_product$price=product.price)===null||_product$price===void 0?void 0:_product$price.currency)||'EUR';var defaultPrice=((_product$price2=product.price)===null||_product$price2===void 0?void 0:_product$price2.unitPrice)||0;var specialPrice=(_product$price3=product.price)===null||_product$price3===void 0?void 0:_product$price3.unitPriceStriked;var hasStrikePrice=typeof specialPrice==='number'&&specialPrice>defaultPrice;var characteristics=(product===null||product===void 0?void 0:product.characteristics)||[];var productLink="".concat(ITEM_PATH,"/").concat(bin2hex(product.id));var notesButtonRef=useRef();var _useState3=useState(quantity),_useState4=_slicedToArray(_useState3,2),internalQuantity=_useState4[0],setInternalQuantity=_useState4[1];useEffect(function(){setInternalQuantity(quantity);},[quantity]);useLayoutEffect(function(){setIsDisabled(!isOrderable&&!hasVariants);},[hasVariants,isOrderable]);var handleOpenComment=useCallback(function(e){e.preventDefault();e.stopPropagation();openCommentDialog(product.id,listId);},[listId,openCommentDialog,product.id]);var handleAddToCart=useCallback(function(e){e.preventDefault();e.stopPropagation();if(isBaseProduct&&hasVariants){// Called for a parent product. User needs to confirm the navigation to the PDP
|
|
10
10
|
showModal({title:null,type:MODAL_VARIANT_SELECT,message:'favorites.modal.message',confirm:'favorites.modal.confirm',dismiss:'common.cancel',params:{productId:product.id}});return false;}if(hasNewServices()&&!isRopeProductOrderable){// Product is not orderable for ROPE. So users need to do some corrections. Just redirect.
|
|
11
|
-
historyPush({pathname:productLink});return false;}broadcastLiveMessage('product.adding_item',{params:{count:1}});return addToCart(e);},[addToCart,hasVariants,historyPush,isBaseProduct,isRopeProductOrderable,product.id,productLink,showModal]);var commonPortalProps=useMemo(function(){var availability=product.availability,id=product.id,name=product.name;return{availability:availability,characteristics:characteristics,id:id,name:name,price:
|
|
11
|
+
historyPush({pathname:productLink});return false;}broadcastLiveMessage('product.adding_item',{params:{count:1}});return addToCart(e);},[addToCart,hasVariants,historyPush,isBaseProduct,isRopeProductOrderable,product.id,productLink,showModal]);var commonPortalProps=useMemo(function(){var availability=product.availability,id=product.id,name=product.name;return{availability:availability,characteristics:characteristics,id:id,name:name,price:defaultPrice,listId:listId};},[characteristics,defaultPrice,listId,product]);var ctaPortalProps=useMemo(function(){return{isLoading:false,noShadow:false,listId:listId,isBaseProduct:isBaseProduct,isDisabled:isDisabled,productId:product.id,handleRemoveFromCart:remove,handleAddToCart:handleAddToCart};},[handleAddToCart,isBaseProduct,isDisabled,listId,product.id,remove]);var handleChangeQuantity=useCallback(function(newQuantity){// Do nothing when quantity didn't change
|
|
12
12
|
if(newQuantity===quantity)return;updateFavoriteItem(product.id,listId,newQuantity,notes);},[listId,notes,product.id,quantity,updateFavoriteItem]);var handleDeleteComment=useCallback(function(event){event.preventDefault();event.stopPropagation();updateFavoriteItem(product.id,listId,quantity,'');setTimeout(function(){if(notesButtonRef===null||notesButtonRef===void 0?void 0:notesButtonRef.current){// Focus the add button after item deletion to improve a11y
|
|
13
|
-
notesButtonRef.current.focus();}broadcastLiveMessage('favorites.comments.removed');},300);},[listId,product.id,quantity,updateFavoriteItem]);return React.createElement(ProductListEntryProvider,{productId:product.id},React.createElement(SurroundPortals,{portalName:FAVORITES_LIST_ITEM,portalProps:product},React.createElement("div",{className:styles.root},React.createElement(Link,{className:styles.imageContainer,component:"div",href:productLink,"aria-hidden":true},React.createElement(ProductImage,{src:product.featuredImageBaseUrl,resolutions:gridResolutions})),React.createElement("div",{className:styles.infoContainer},React.createElement("div",{className:classNames(styles.infoContainerRow)},React.createElement("div",{className:styles.titleWrapper},React.createElement(SurroundPortals,{portalName:FAVORITES_PRODUCT_NAME,portalProps:commonPortalProps},React.createElement(TextLink,{href:productLink,tag:"span",className:styles.titleContainer},React.createElement("span",{className:styles.title// eslint-disable-next-line react/no-danger
|
|
14
|
-
,dangerouslySetInnerHTML:{__html:"".concat(product.name)}})))),React.createElement("div",{className:styles.removeContainer},React.createElement(Remove,{onClick:remove}))),React.createElement(ItemCharacteristics,{characteristics:characteristics}),!hasNewServices()?React.createElement(SurroundPortals,{portalName:FAVORITES_AVAILABILITY_TEXT,portalProps:commonPortalProps},React.createElement(AvailableText,{text:commonPortalProps.availability.text,state:commonPortalProps.availability.state,showWhenAvailable:true,className:styles.availability})):React.createElement(StockInfoLists,{product:product}),React.createElement("div",{className:styles.infoContainerRow},React.createElement("div",{className:styles.quantityContainer},React.createElement(SurroundPortals,{portalName:FAVORITES_QUANTITY,portalProps:commonPortalProps},React.createElement(ItemQuantity,{quantity:internalQuantity,onChange:handleChangeQuantity})),React.createElement(SurroundPortals,{portalName:FAVORITES_PRODUCT_PRICE,portalProps:commonPortalProps},React.createElement("div",{className:styles.priceContainer},hasStrikePrice?React.createElement(PriceStriked,{value:
|
|
13
|
+
notesButtonRef.current.focus();}broadcastLiveMessage('favorites.comments.removed');},300);},[listId,product.id,quantity,updateFavoriteItem]);return React.createElement(ProductListEntryProvider,{productId:product.id},React.createElement(SurroundPortals,{portalName:FAVORITES_LIST_ITEM,portalProps:product},React.createElement("div",{className:classNames(styles.root,'engage__favorites__item')},React.createElement(Link,{className:classNames(styles.imageContainer,'engage__favorites__item__image-container'),component:"div",href:productLink,"aria-hidden":true},React.createElement(ProductImage,{className:classNames('engage__favorites__item__image'),src:product.featuredImageBaseUrl,resolutions:gridResolutions})),React.createElement("div",{className:classNames(styles.infoContainer,'engage__favorites__item__info-container')},React.createElement("div",{className:classNames(styles.infoContainerRow)},React.createElement("div",{className:styles.titleWrapper},React.createElement(SurroundPortals,{portalName:FAVORITES_PRODUCT_NAME,portalProps:commonPortalProps},React.createElement(TextLink,{href:productLink,tag:"span",className:classNames(styles.titleContainer,'engage__favorites__item__title-container')},React.createElement("span",{className:styles.title// eslint-disable-next-line react/no-danger
|
|
14
|
+
,dangerouslySetInnerHTML:{__html:"".concat(product.name)}})))),React.createElement("div",{className:styles.removeContainer},React.createElement(Remove,{onClick:remove}))),React.createElement(ItemCharacteristics,{characteristics:characteristics}),!hasNewServices()?React.createElement(SurroundPortals,{portalName:FAVORITES_AVAILABILITY_TEXT,portalProps:commonPortalProps},React.createElement(AvailableText,{text:commonPortalProps.availability.text,state:commonPortalProps.availability.state,showWhenAvailable:true,className:styles.availability})):React.createElement(StockInfoLists,{product:product}),React.createElement("div",{className:styles.infoContainerRow},React.createElement("div",{className:styles.quantityContainer},React.createElement(SurroundPortals,{portalName:FAVORITES_QUANTITY,portalProps:commonPortalProps},React.createElement(ItemQuantity,{quantity:internalQuantity,onChange:handleChangeQuantity})),React.createElement(SurroundPortals,{portalName:FAVORITES_PRODUCT_PRICE,portalProps:commonPortalProps},React.createElement("div",{className:styles.priceContainer},React.createElement("div",{className:styles.priceContainerInner},hasStrikePrice?React.createElement(PriceStriked,{value:specialPrice,currency:currency}):null,React.createElement(Price,{currency:currency,discounted:hasStrikePrice,unitPrice:defaultPrice,className:styles.price})),React.createElement(PriceInfo,{product:product,currency:currency,className:styles.priceInfo})))),React.createElement(SurroundPortals,{portalName:FAVORITES_ADD_TO_CART,portalProps:ctaPortalProps},React.createElement(AddToCart,{onClick:handleAddToCart,isLoading:false,isDisabled:isDisabled,"aria-label":i18n.text('product.add_to_cart')}))),React.createElement(SurroundPortals,{portalName:FAVORITES_NOTES,portalProps:commonPortalProps},React.createElement(ItemNotes,{notes:notes,onClickDeleteComment:handleDeleteComment,onClickOpenComment:handleOpenComment,notesButtonRef:notesButtonRef}))))));};FavoriteItem.defaultProps={isBaseProduct:true,isOrderable:true,isRopeProductOrderable:true,hasVariants:false,notes:undefined,quantity:1};export default connect(makeMapStateToProps,mapDispatchToProps)(FavoriteItem);
|