@shopgate/engage 7.8.0-beta.2 → 7.8.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/checkout/components/Checkout/CheckoutSection.js +1 -1
  2. package/checkout/components/ShippingMethods/ShippingMethods.js +2 -2
  3. package/checkout/paymentMethods/index.js +2 -2
  4. package/checkout/paymentMethods/paypal/PaypalPayButton.js +1 -1
  5. package/checkout/paymentMethods/stripe/StripeCreditCard.js +1 -1
  6. package/components/Form/Builder/stylePresets.js +1 -1
  7. package/core/constants/index.js +1 -1
  8. package/core/constants/shopSettings.js +1 -1
  9. package/core/index.js +1 -1
  10. package/core/selectors/index.js +1 -1
  11. package/core/selectors/shopSettings.js +5 -2
  12. package/login/components/ForgotPassword/ForgotPassword.js +1 -1
  13. package/login/components/ForgotPassword/ForgotPassword.style.js +1 -1
  14. package/package.json +7 -7
  15. package/registration/components/Registration/Registration.js +2 -2
  16. package/registration/components/Registration/RegistrationContent.js +4 -0
  17. package/registration/components/Registration/RegistrationContent.style.js +2 -0
  18. package/registration/components/Registration/RegistrationFormActions.js +1 -1
  19. package/registration/components/Registration/RegistrationFormBase.config.js +2 -2
  20. package/registration/components/Registration/RegistrationFormBase.js +2 -2
  21. package/registration/components/Registration/RegistrationFormBilling.js +2 -2
  22. package/registration/components/Registration/RegistrationFormExtra.js +1 -1
  23. package/registration/components/Registration/RegistrationFormShipping.js +1 -1
  24. package/registration/components/Registration/RegistrationFormToggle.js +1 -1
  25. package/registration/providers/GuestRegistrationProvider.js +7 -2
  26. package/registration/providers/RegistrationProvider.actions.js +3 -2
  27. package/registration/providers/RegistrationProvider.connector.js +2 -2
  28. package/registration/providers/RegistrationProvider.constraints.js +22 -2
  29. package/registration/providers/RegistrationProvider.js +4 -4
  30. package/registration/components/Registration/Registration.style.js +0 -2
@@ -1,4 +1,4 @@
1
- function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _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,{Fragment}from'react';import{css}from'glamor';import classNames from'classnames';import PropTypes from'prop-types';import{Card,Link}from'@shopgate/engage/components';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{isIOSTheme}from'@shopgate/engage/core';import CheckoutSectionInfo from"./CheckoutSectionInfo";import CheckoutSectionMessages from"./CheckoutSectionMessages";import{i18n}from"../../../core/helpers/i18n";var colors=themeConfig.colors,variables=themeConfig.variables;var styles={headline:css(_extends({color:colors.shade3,fontSize:'1.25rem',fontWeight:'normal',textTransform:'uppercase',margin:"0 0 ".concat(variables.gap.small,"px 0")},!isIOSTheme()?{color:'var(--color-text-high-emphasis)',textTransform:'none'}:{})),card:css(_extends({display:'flex',flexDirection:'row',fontSize:15,padding:variables.gap.big,width:'100%',overflow:'inherit !important',marginBottom:variables.gap.big},!isIOSTheme()?{background:'var(--color-background-accent)',boxShadow:'none',padding:"".concat(variables.gap.small,"px ").concat(variables.gap.big,"px"),margin:0}:{})),cardWithForm:css(_extends({},!isIOSTheme()?{background:'inherit !important',boxShadow:'none !important',padding:'0px !important'}:{})).toString(),table:css({' td':{padding:"".concat(variables.gap.xsmall,"px 0")},' td:last-child':{textAlign:'right',whiteSpace:'pre-wrap',paddingLeft:variables.gap.xsmall},' tr:nth-last-child(2) td':{paddingBottom:8},' tr:last-child td':{paddingTop:8,borderTop:'1px solid #979797',fontWeight:'600'}}),actionsContainer:css({flex:1,display:'table',width:'100%'}).toString(),link:css({fontSize:'0.875rem',color:'var(--color-primary)',textTransform:'uppercase'}).toString(),actions:css({paddingTop:8}).toString(),labelWithInfoIcon:css({paddingRight:variables.gap.small}).toString()};/**
1
+ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Fragment}from'react';import{css}from'glamor';import classNames from'classnames';import PropTypes from'prop-types';import{Card,Link}from'@shopgate/engage/components';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import CheckoutSectionInfo from"./CheckoutSectionInfo";import CheckoutSectionMessages from"./CheckoutSectionMessages";import{i18n}from"../../../core/helpers/i18n";var variables=themeConfig.variables;var styles={headline:css({fontSize:'1.25rem',fontWeight:'normal',margin:"0 0 ".concat(variables.gap.small,"px 0"),color:'var(--color-text-high-emphasis)',textTransform:'none'}),card:css({display:'flex',flexDirection:'row',fontSize:15,width:'100%',overflow:'inherit !important',marginBottom:variables.gap.big,boxShadow:'none',background:'var(--color-background-accent)',padding:"".concat(variables.gap.small,"px ").concat(variables.gap.big,"px"),margin:0}),cardWithForm:css({background:'inherit !important',boxShadow:'none !important',padding:'0px !important'}).toString(),table:css({' td':{padding:"".concat(variables.gap.xsmall,"px 0")},' td:last-child':{textAlign:'right',whiteSpace:'pre-wrap',paddingLeft:variables.gap.xsmall},' tr:nth-last-child(2) td':{paddingBottom:8},' tr:last-child td':{paddingTop:8,borderTop:'1px solid #979797',fontWeight:'600'}}),actionsContainer:css({flex:1,display:'table',width:'100%'}).toString(),link:css({fontSize:'0.875rem',color:'var(--color-primary)',textTransform:'uppercase'}).toString(),actions:css({paddingTop:8}).toString(),labelWithInfoIcon:css({paddingRight:variables.gap.small}).toString()};/**
2
2
  * CheckoutSection component
3
3
  * @returns {JSX}
4
4
  */var CheckoutSection=function CheckoutSection(_ref){var title=_ref.title,className=_ref.className,content=_ref.content,children=_ref.children,hasForm=_ref.hasForm,editLink=_ref.editLink,editLabel=_ref.editLabel,id=_ref.id;return React.createElement(Fragment,null,title&&React.createElement("h3",{className:styles.headline,id:id},i18n.text(title)),React.createElement(Card,{className:classNames(styles.card.toString(),_defineProperty({},styles.cardWithForm.toString(),hasForm)),id:!title?id:null},React.createElement("div",{className:"".concat(styles.actionsContainer," ").concat(className)},children||null,content&&React.createElement("table",{className:styles.table},React.createElement("tbody",null,content.map(function(_ref2){var label=_ref2.label,text=_ref2.text,info=_ref2.info,messages=_ref2.messages;var hasMessages=Array.isArray(messages)&&messages.length>0;var hasError=false;if(hasMessages){hasError=!!messages.find(function(_ref3){var type=_ref3.type;return type==='error';});}return React.createElement(Fragment,{key:label},React.createElement("tr",null,React.createElement("td",null,React.createElement(Fragment,null,React.createElement("span",{className:classNames(_defineProperty({},styles.labelWithInfoIcon,!!info))},label),!hasError&&React.createElement(CheckoutSectionInfo,{text:info}))),React.createElement("td",null,text)),hasMessages&&React.createElement("tr",null,React.createElement("td",{colSpan:"2",style:{textAlign:'left',paddingLeft:0}},React.createElement(CheckoutSectionMessages,{messages:messages}),hasError&&React.createElement(CheckoutSectionInfo,{text:info,renderIcon:false}))));})))),editLink?React.createElement("div",{className:styles.actions},React.createElement(Link,{tag:"a",className:styles.link,href:editLink},i18n.text(editLabel))):null));};CheckoutSection.defaultProps={title:null,className:'',children:null,content:null,hasForm:false,editLink:null,editLabel:'checkout.billing.edit',id:null};export default CheckoutSection;
@@ -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);});};}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;}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{hot}from'react-hot-loader/root';import React,{useCallback,useEffect,useMemo,useState}from'react';import PropTypes from'prop-types';import{css}from'glamor';import classNames from'classnames';import CryptoJs from'crypto-js';import sortBy from'lodash/sortBy';import uniqBy from'lodash/uniqBy';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{isIOSTheme,i18n}from'@shopgate/engage/core';import{RadioGroupV2 as RadioGroup,RadioCard,MessageBar,Card,ConditionalWrapper}from'@shopgate/engage/components';import{useCheckoutContext}from'@shopgate/engage/checkout/hooks/common';import ShippingMethod from"./ShippingMethod";import connect from"./connector";var colors=themeConfig.colors,variables=themeConfig.variables;var styles={root:css({padding:"0 ".concat(variables.gap.big,"px ").concat(variables.gap[isIOSTheme()?'big':'xbig'],"px")}).toString(),headline:css(_extends({color:colors.shade3,fontSize:'1.25rem',fontWeight:'normal',textTransform:'uppercase',padding:"0 ".concat(variables.gap.small,"px 0 0"),margin:"0 0 ".concat(variables.gap.small,"px 0")},!isIOSTheme()?{color:'var(--color-text-high-emphasis)',textTransform:'none'}:{})).toString(),container:css(_extends({},!isIOSTheme()?{border:'1px solid #eaeaea'}:{},{' li:nth-child(2n)':{background:'var(--color-background-accent)'}})).toString(),containerSingle:css(_extends({},!isIOSTheme()?{padding:variables.gap.small}:{padding:variables.gap.big})).toString(),card:css(_extends({display:'flex',alignItems:'center'},isIOSTheme()?{padding:"".concat(variables.gap.xsmall,"px ").concat(variables.gap.small,"px 0 ").concat(variables.gap.xsmall,"px")}:{})).toString(),errorMessage:css({margin:0}).toString(),iOSCard:css({width:'100%',overflow:'hidden',marginBottom:variables.gap.big}).toString()};/**
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);});};}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}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{hot}from'react-hot-loader/root';import React,{useCallback,useEffect,useMemo,useState}from'react';import PropTypes from'prop-types';import{css}from'glamor';import classNames from'classnames';import CryptoJs from'crypto-js';import sortBy from'lodash/sortBy';import uniqBy from'lodash/uniqBy';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{i18n}from'@shopgate/engage/core';import{RadioGroupV2 as RadioGroup,RadioCard,MessageBar}from'@shopgate/engage/components';import{useCheckoutContext}from'@shopgate/engage/checkout/hooks/common';import ShippingMethod from"./ShippingMethod";import connect from"./connector";var variables=themeConfig.variables;var styles={root:css({padding:"0 ".concat(variables.gap.big,"px ").concat(variables.gap.xbig,"px")}).toString(),headline:css({fontSize:'1.25rem',fontWeight:'normal',padding:"0 ".concat(variables.gap.small,"px 0 0"),margin:"0 0 ".concat(variables.gap.small,"px 0"),color:'var(--color-text-high-emphasis)',textTransform:'none'}).toString(),container:css({border:'1px solid #eaeaea',' li:nth-child(2n)':{background:'var(--color-background-accent)'}}).toString(),containerSingle:css({padding:variables.gap.small}).toString(),card:css({display:'flex',alignItems:'center'}).toString(),errorMessage:css({margin:0}).toString(),iOSCard:css({width:'100%',overflow:'hidden',marginBottom:variables.gap.big}).toString()};/**
2
2
  * Hashes a shipping method
3
3
  * @param {Object} method A shipping method
4
4
  * @returns {string}
@@ -20,4 +20,4 @@ var dedupedLevels=uniqBy(unsortedLevels,function(_ref4){var _serviceLevel$carrie
20
20
  return sortBy(dedupedLevels,['serviceLevel.cost','serviceLevel.name']);},[availableShippingMethods]);var onChange=useCallback(/*#__PURE__*/function(){var _ref5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(event,value){var _shippingMethod$servi,_shippingMethod$servi2,_shippingMethod$servi3;var shippingMethod;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:// Determine the selected shipping method by its hash
21
21
  shippingMethod=shippingMethods.find(function(_ref6){var hash=_ref6.hash;return value===hash;});if(shippingMethod){_context.next=3;break;}return _context.abrupt("return");case 3:// Update the local state
22
22
  setSelectedHash(shippingMethod===null||shippingMethod===void 0?void 0:shippingMethod.hash);// Perform the update request
23
- _context.next=6;return updateShippingMethod({code:shippingMethod===null||shippingMethod===void 0?void 0:shippingMethod.code,serviceLevel:{code:shippingMethod===null||shippingMethod===void 0?void 0:(_shippingMethod$servi=shippingMethod.serviceLevel)===null||_shippingMethod$servi===void 0?void 0:_shippingMethod$servi.code,carrier:{code:shippingMethod===null||shippingMethod===void 0?void 0:(_shippingMethod$servi2=shippingMethod.serviceLevel)===null||_shippingMethod$servi2===void 0?void 0:(_shippingMethod$servi3=_shippingMethod$servi2.carrier)===null||_shippingMethod$servi3===void 0?void 0:_shippingMethod$servi3.code}}});case 6:case"end":return _context.stop();}}},_callee);}));return function(_x,_x2){return _ref5.apply(this,arguments);};}(),[shippingMethods,updateShippingMethod]);if((order===null||order===void 0?void 0:order.status)!=='new'||!orderHasDirectShipItems){return null;}if(shippingMethods.length===0){return React.createElement("div",{className:styles.root},React.createElement("h3",{className:styles.headline},i18n.text('checkout.shippingMethod.title')),React.createElement(MessageBar,{messages:[{type:'error',message:i18n.text("checkout.shippingMethod.errors.".concat(!shippingAddress?'noShippingAddress':'invalidShippingAddress'))}],classNames:{container:styles.errorMessage},showIcons:true}));}return React.createElement("div",{className:styles.root},React.createElement("h3",{className:styles.headline},i18n.text('checkout.shippingMethod.title')),React.createElement(ConditionalWrapper,{condition:isIOSTheme(),wrapper:function wrapper(children){return React.createElement(Card,{className:styles.iOSCard},children);}},shippingMethods.length===1?React.createElement("div",{className:classNames(styles.container,styles.containerSingle)},React.createElement(ShippingMethod,{shippingMethod:shippingMethods[0]})):React.createElement(RadioGroup,{name:"shipping-methods",value:selectedHash,onChange:onChange,component:"ul",classes:{root:styles.container},disabled:isLoading},shippingMethods.map(function(shippingMethod){return React.createElement(RadioCard,{renderCard:CardComponent,value:shippingMethod.hash,key:shippingMethod.hash},React.createElement(ShippingMethod,{shippingMethod:shippingMethod}));}))));};ShippingMethods.defaultProps={orderHasDirectShipItems:false};export default hot(connect(ShippingMethods));
23
+ _context.next=6;return updateShippingMethod({code:shippingMethod===null||shippingMethod===void 0?void 0:shippingMethod.code,serviceLevel:{code:shippingMethod===null||shippingMethod===void 0?void 0:(_shippingMethod$servi=shippingMethod.serviceLevel)===null||_shippingMethod$servi===void 0?void 0:_shippingMethod$servi.code,carrier:{code:shippingMethod===null||shippingMethod===void 0?void 0:(_shippingMethod$servi2=shippingMethod.serviceLevel)===null||_shippingMethod$servi2===void 0?void 0:(_shippingMethod$servi3=_shippingMethod$servi2.carrier)===null||_shippingMethod$servi3===void 0?void 0:_shippingMethod$servi3.code}}});case 6:case"end":return _context.stop();}}},_callee);}));return function(_x,_x2){return _ref5.apply(this,arguments);};}(),[shippingMethods,updateShippingMethod]);if((order===null||order===void 0?void 0:order.status)!=='new'||!orderHasDirectShipItems){return null;}if(shippingMethods.length===0){return React.createElement("div",{className:styles.root},React.createElement("h3",{className:styles.headline},i18n.text('checkout.shippingMethod.title')),React.createElement(MessageBar,{messages:[{type:'error',message:i18n.text("checkout.shippingMethod.errors.".concat(!shippingAddress?'noShippingAddress':'invalidShippingAddress'))}],classNames:{container:styles.errorMessage},showIcons:true}));}return React.createElement("div",{className:styles.root},React.createElement("h3",{className:styles.headline},i18n.text('checkout.shippingMethod.title')),shippingMethods.length===1?React.createElement("div",{className:classNames(styles.container,styles.containerSingle)},React.createElement(ShippingMethod,{shippingMethod:shippingMethods[0]})):React.createElement(RadioGroup,{name:"shipping-methods",value:selectedHash,onChange:onChange,component:"ul",classes:{root:styles.container},disabled:isLoading},shippingMethods.map(function(shippingMethod){return React.createElement(RadioCard,{renderCard:CardComponent,value:shippingMethod.hash,key:shippingMethod.hash},React.createElement(ShippingMethod,{shippingMethod:shippingMethod}));})));};ShippingMethods.defaultProps={orderHasDirectShipItems:false};export default hot(connect(ShippingMethods));
@@ -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);});};}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React,{useContext,useCallback,useEffect,useMemo,useRef,useState}from'react';import{connect}from'react-redux';import PropTypes from'prop-types';import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{isIOSTheme}from'@shopgate/engage/core';import{getPaymentMethods}from"../selectors/payment";import{getCheckoutOrder}from"../selectors/order";import CheckoutContext from"../providers/CheckoutProvider.context";import{updateCheckoutOrder}from"../actions/updateCheckoutOrder";import{fetchCheckoutOrder}from"../actions/fetchCheckoutOrder";import{i18n}from"../../core/helpers/i18n";import Context from"./context";import paypal from"./paypal";import stripe from"./stripe";var AVAILABLE_PAYMENT_METHOD=[paypal,stripe];/**
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";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 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);});};}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,{useContext,useCallback,useEffect,useMemo,useRef,useState}from'react';import{connect}from'react-redux';import PropTypes from'prop-types';import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{getPaymentMethods}from"../selectors/payment";import{getCheckoutOrder}from"../selectors/order";import CheckoutContext from"../providers/CheckoutProvider.context";import{updateCheckoutOrder}from"../actions/updateCheckoutOrder";import{fetchCheckoutOrder}from"../actions/fetchCheckoutOrder";import{i18n}from"../../core/helpers/i18n";import Context from"./context";import paypal from"./paypal";import stripe from"./stripe";var AVAILABLE_PAYMENT_METHOD=[paypal,stripe];/**
2
2
  * Maps state to props
3
3
  * @param {Object} state State
4
4
  * @returns {Object}
@@ -6,7 +6,7 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
6
6
  * Dispatch
7
7
  * @param {Object} dispatch Dispatch
8
8
  * @returns {Object}
9
- */var mapDispatchToProps=function mapDispatchToProps(dispatch){return{updateOrder:function updateOrder(order){return dispatch(updateCheckoutOrder(order));},fetchOrder:function fetchOrder(){return dispatch(fetchCheckoutOrder());}};};var colors=themeConfig.colors,variables=themeConfig.variables;var styles={headline:css(_extends({color:colors.shade3,fontSize:'1.25rem',fontWeight:'normal',textTransform:'uppercase',margin:"0 0 ".concat(variables.gap.small,"px 0"),marginLeft:16,marginRight:8},!isIOSTheme()?{color:'var(--color-text-high-emphasis)',textTransform:'none'}:{})).toString(),section:css(_extends({marginBottom:0,marginTop:4},isIOSTheme()?{marginBottom:32}:{})).toString(),buttons:css(_extends({marginLeft:16,marginRight:16,marginBottom:16,display:'flex',flexDirection:'row'},isIOSTheme()?{marginBottom:32}:{})).toString()};/**
9
+ */var mapDispatchToProps=function mapDispatchToProps(dispatch){return{updateOrder:function updateOrder(order){return dispatch(updateCheckoutOrder(order));},fetchOrder:function fetchOrder(){return dispatch(fetchCheckoutOrder());}};};var variables=themeConfig.variables;var styles={headline:css({fontSize:'1.25rem',fontWeight:'normal',margin:"0 0 ".concat(variables.gap.small,"px 0"),marginLeft:16,marginRight:8,color:'var(--color-text-high-emphasis)',textTransform:'none'}).toString(),section:css({marginBottom:0,marginTop:4}).toString(),buttons:css({marginLeft:16,marginRight:16,marginBottom:16,display:'flex',flexDirection:'row'}).toString()};/**
10
10
  * PaymentMethodProvider
11
11
  * @param {Object} props Props
12
12
  * @returns {JSX}
@@ -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);});};}function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React,{useLayoutEffect,useEffect,useRef,useState,Fragment}from'react';import PropTypes from'prop-types';import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{isIOSTheme,getThemeSettings,showModal,MODAL_PIPELINE_ERROR}from'@shopgate/engage/core';import{connect}from'react-redux';import{i18n}from"../../../core/helpers/i18n";import{useCheckoutContext}from"../../hooks/common";import{usePaypal}from"./sdk";var colors=themeConfig.colors;var styles={headline:css(_extends({color:colors.shade3,fontSize:'1.25rem',fontWeight:'normal',textTransform:'uppercase',margin:'12px 0 12px 0'},!isIOSTheme()?{color:'var(--color-text-high-emphasis)',textTransform:'none'}:{})).toString()};/**
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";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 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);});};}function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _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,{useLayoutEffect,useEffect,useRef,useState,Fragment}from'react';import PropTypes from'prop-types';import{css}from'glamor';import{getThemeSettings,showModal,MODAL_PIPELINE_ERROR}from'@shopgate/engage/core';import{connect}from'react-redux';import{i18n}from"../../../core/helpers/i18n";import{useCheckoutContext}from"../../hooks/common";import{usePaypal}from"./sdk";var styles={headline:css({fontSize:'1.25rem',fontWeight:'normal',margin:'12px 0 12px 0',color:'var(--color-text-high-emphasis)',textTransform:'none'}).toString()};/**
2
2
  * Paypal Pay button
3
3
  * @returns {JSX}
4
4
  */var PaypalPayButton=function PaypalPayButton(_ref){var disabled=_ref.disabled,onSubmit=_ref.onSubmit,onValidate=_ref.onValidate,showModal=_ref.showModal;var _useCheckoutContext=useCheckoutContext(),paymentData=_useCheckoutContext.paymentData,paymentTransactions=_useCheckoutContext.paymentTransactions;var _useState=useState(null),_useState2=_slicedToArray(_useState,2),paypalActions=_useState2[0],setPaypalActions=_useState2[1];var paypal=usePaypal();var paypalButton=useRef(null);var button=useRef(null);var fundingSource=paymentData===null||paymentData===void 0?void 0:paymentData.meta;// Store form actions inside ref as they would trigger
@@ -1,4 +1,4 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}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,{useContext}from'react';import{css}from'glamor';import{themeConfig}from'@shopgate/engage';import{isIOSTheme,i18n}from'@shopgate/engage/core';import{TextField}from'@shopgate/engage/components';import{getCSSCustomProp}from'@shopgate/engage/styles';import{CardNumberElement,CardCvcElement,CardExpiryElement}from'@stripe/react-stripe-js';import Section from"../../components/Checkout/CheckoutSection";import{useCheckoutContext}from"../../hooks/common";import StripeContext from"./StripeProvider.context";var colors=themeConfig.colors;var styles={root:css({padding:'0 16px',display:'flex',flexDirection:'column',flex:'0 0 auto',' .formElement':_extends({},!isIOSTheme()?{background:"var(--color-background-accent, ".concat(colors.shade8,")"),padding:0,marginBottom:38,borderTopLeftRadius:4,borderTopRightRadius:4,borderBottom:"1px solid ".concat(colors.shade12)}:{}),' .formElement label':_extends({},!isIOSTheme()?{color:'var(--color-text-low-emphasis)',paddingLeft:24}:{}),' .underline':_extends({},!isIOSTheme()?{marginBottom:0,borderBottom:'none'}:{}),' .errorText':_extends({},!isIOSTheme()?{bottom:-20,left:18}:{}),' .StripeElement':_extends({},!isIOSTheme()?{paddingLeft:16}:{})}).toString(),secondRow:css({display:'flex',flexDirection:'row'}).toString(),cvc:css({flex:1.5,marginRight:16}).toString(),expiry:css({flex:1}).toString()};/* eslint-disable react/prop-types */ /**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _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 _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{useContext}from'react';import{css}from'glamor';import{themeConfig}from'@shopgate/engage';import{i18n}from'@shopgate/engage/core';import{TextField}from'@shopgate/engage/components';import{getCSSCustomProp}from'@shopgate/engage/styles';import{CardNumberElement,CardCvcElement,CardExpiryElement}from'@stripe/react-stripe-js';import Section from"../../components/Checkout/CheckoutSection";import{useCheckoutContext}from"../../hooks/common";import StripeContext from"./StripeProvider.context";var colors=themeConfig.colors;var styles={root:css({padding:'0 16px',display:'flex',flexDirection:'column',flex:'0 0 auto',' .formElement':{background:"var(--color-background-accent, ".concat(colors.shade8,")"),padding:0,marginBottom:38,borderTopLeftRadius:4,borderTopRightRadius:4,borderBottom:"1px solid ".concat(colors.shade12)},' .formElement label':{color:'var(--color-text-low-emphasis)',paddingLeft:24},' .underline':{marginBottom:0,borderBottom:'none'},' .errorText':{bottom:-20,left:18},' .StripeElement':{paddingLeft:16}}).toString(),secondRow:css({display:'flex',flexDirection:'row'}).toString(),cvc:css({flex:1.5,marginRight:16}).toString(),expiry:css({flex:1}).toString()};/* eslint-disable react/prop-types */ /**
2
2
  * Wrapper
3
3
  * @param {Object} Element element
4
4
  * @returns {Object}
@@ -1 +1 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _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{isIOSTheme}from'@shopgate/engage/core';import{themeConfig}from'@shopgate/engage';import{responsiveMediaQuery}from'@shopgate/engage/styles';var colors=themeConfig.colors,variables=themeConfig.variables;export var TWO_COLUMN_LAYOUT=_defineProperty({},responsiveMediaQuery('>=md',{webOnly:false}),{display:'flex',flexDirection:'row',flexWrap:'wrap',margin:-8,marginTop:16,marginBottom:8,'>div':{flex:'1 1 50%',padding:'0 8px',maxWidth:'50%'},'>.phonePicker':{marginLeft:8,marginRight:8,flexBasis:'calc(50% - 16px)'}});export var OUTLINED_FORM_FIELDS={' .formHelper':_extends({},!isIOSTheme()?{minHeight:32}:{minHeight:12},{' .errorText':_extends({position:'relative',textOverflow:'unset',whiteSpace:'unset',lineHeight:'15px',bottom:'unset'},!isIOSTheme()?{padding:'8px 8px 8px 16px'}:{})}),' .formBuilderField':{' .textField, .formElement:not(.radioGroup):not(.checkbox), .phonePicker':{marginBottom:'unset',paddingBottom:'unset'}},' .radioGroup + .formHelper, .checkbox + .formHelper':{minHeight:16},' .checkbox':{paddingBottom:0},' .textField, .formElement:not(.radioGroup):not(.checkbox), .phonePicker':_extends({paddingBottom:8},!isIOSTheme()?{background:"var(--color-background-accent, ".concat(colors.shade8,")"),padding:0,marginBottom:32,borderTopLeftRadius:4,borderTopRightRadius:4,borderBottom:"1px solid ".concat(colors.shade12)}:{}),' .phonePickerError':_extends({},!isIOSTheme()?{borderBottom:"2px solid var(--color-state-alert, ".concat(colors.error,")")}:{}),' .phonePickerFocused:not(.phonePickerError)':_extends({},!isIOSTheme()?{borderBottom:'2px solid var(--color-primary)'}:{}),' .formElement:not(.radioGroup) label':_extends({},!isIOSTheme()?{paddingLeft:24,color:'var(--color-text-low-emphasis)',transform:'translate3d(0, -18px, 0) scale3d(0.75, 0.75, 0.75)'}:{}),' .textField label':_extends({},!isIOSTheme()?{paddingLeft:17,color:'var(--color-text-low-emphasis)','.floating':{transform:'translate3d(3px, -18px, 0) scale3d(0.75, 0.75, 0.75)'}}:{}),' .formElement:not(.radioGroup) select, .formElement .info-field':_extends({},!isIOSTheme()?{paddingLeft:16,color:'var(--color-text-high-emphasis)'}:{}),' .formElement:not(.radioGroup):not(.checkbox) svg':_extends({},!isIOSTheme()?{marginTop:8,right:8}:{}),' .formElement:not(.radioGroup) .placeholder':_extends({},!isIOSTheme()?{paddingLeft:20,color:'var(--color-text-low-emphasis)'}:{}),' .formElement.disabled, .textField.disabled':{' input, select, svg':{opacity:0.28},' .label':{opacity:0.6}},' .textField input':_extends({},!isIOSTheme()?{paddingLeft:16,color:'var(--color-text-high-emphasis)'}:{}),' .underline':_extends({},!isIOSTheme()?{marginBottom:0,borderBottom:'none'}:{}),' .errorText':_extends({},!isIOSTheme()?{bottom:-20,paddingLeft:16}:{bottom:0}),' .phonePicker':_extends({paddingTop:variables.gap.big},isIOSTheme()?{paddingBottom:2}:{paddingTop:23,paddingLeft:8}),' .phonePicker .PhoneInputInput':_extends({},!isIOSTheme()?{borderBottom:'none',color:'var(--color-text-high-emphasis)','&:focus':{borderBottom:'none'},'::placeholder':{color:'var(--color-text-low-emphasis)'}}:{}),' .phonePicker .errorText':_extends({},!isIOSTheme()?{marginLeft:-8}:{marginLeft:0,bottom:-11,overflow:'initial'}),' .PhoneInputCountryIcon':_extends({},!isIOSTheme()?{marginBottom:8,marginLeft:16}:{}),' .PhoneInputCountrySelectArrow':_extends({},!isIOSTheme()?{marginRight:6,marginLeft:10,marginBottom:8}:{}),' .placeholder':{color:colors.shade12}};
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{themeConfig}from'@shopgate/engage';import{responsiveMediaQuery}from'@shopgate/engage/styles';var colors=themeConfig.colors;export var TWO_COLUMN_LAYOUT=_defineProperty({},responsiveMediaQuery('>=md',{webOnly:false}),{display:'flex',flexDirection:'row',flexWrap:'wrap',margin:-8,marginTop:16,marginBottom:8,'>div':{flex:'1 1 50%',padding:'0 8px',maxWidth:'50%'},'>.phonePicker':{marginLeft:8,marginRight:8,flexBasis:'calc(50% - 16px)'}});export var OUTLINED_FORM_FIELDS={' .formHelper':{minHeight:32,' .errorText':{position:'relative',textOverflow:'unset',whiteSpace:'unset',lineHeight:'15px',bottom:'unset',padding:'8px 8px 8px 16px'}},' .formBuilderField':{' .textField, .formElement:not(.radioGroup):not(.checkbox), .phonePicker':{marginBottom:'unset',paddingBottom:'unset'}},' .radioGroup + .formHelper, .checkbox + .formHelper':{minHeight:16},' .checkbox':{paddingBottom:0},' .textField, .formElement:not(.radioGroup):not(.checkbox), .phonePicker':{paddingBottom:8,background:"var(--color-background-accent, ".concat(colors.shade8,")"),padding:0,marginBottom:32,borderTopLeftRadius:4,borderTopRightRadius:4,borderBottom:"1px solid ".concat(colors.shade12)},' .phonePickerError':{borderBottom:"2px solid var(--color-state-alert, ".concat(colors.error,")")},' .phonePickerFocused:not(.phonePickerError)':{borderBottom:'2px solid var(--color-primary)'},' .formElement:not(.radioGroup) label':{paddingLeft:24,color:'var(--color-text-low-emphasis)',transform:'translate3d(0, -18px, 0) scale3d(0.75, 0.75, 0.75)'},' .textField label':{paddingLeft:17,color:'var(--color-text-low-emphasis)','.floating':{transform:'translate3d(3px, -18px, 0) scale3d(0.75, 0.75, 0.75)'}},' .formElement:not(.radioGroup) select, .formElement .info-field':{paddingLeft:16,color:'var(--color-text-high-emphasis)'},' .formElement:not(.radioGroup):not(.checkbox) svg':{marginTop:8,right:8},' .formElement:not(.radioGroup) .placeholder':{paddingLeft:20,color:'var(--color-text-low-emphasis)'},' .formElement.disabled, .textField.disabled':{' input, select, svg':{opacity:0.28},' .label':{opacity:0.6}},' .textField input':{paddingLeft:16,color:'var(--color-text-high-emphasis)'},' .underline':{marginBottom:0,borderBottom:'none'},' .errorText':{bottom:-20,paddingLeft:16},' .phonePicker':{paddingTop:24,paddingBottom:2},' .phonePicker .PhoneInputInput':{borderBottom:'none',color:'var(--color-text-high-emphasis)','&:focus':{borderBottom:'none'},'::placeholder':{color:'var(--color-text-low-emphasis)'}},' .phonePicker .errorText':{marginLeft:-8},' .PhoneInputCountryIcon':{marginBottom:8,marginLeft:16},' .PhoneInputCountrySelectArrow':{marginRight:6,marginLeft:10,marginBottom:8},' .placeholder':{color:colors.shade12}};
@@ -1 +1 @@
1
- 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}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";
1
+ 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}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";
@@ -1,2 +1,2 @@
1
1
  export var RECEIVE_SHOP_SETTINGS='RECEIVE_SHOP_SETTINGS';export var ERROR_SHOP_SETTINGS='ERROR_SHOP_SETTINGS';export var CACHE_LEASE_SHOP_SETTINGS=10*60*1000;// 10 minutes in milliseconds
2
- export var SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE='googleSiteVerificationCode';export var SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT='cartSupplementalContent';export var SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT='orderSupplementalContent';export var SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP='showShopLogoInApp';export var SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB='showShopLogoInWeb';export var SHOP_SETTING_PRODUCTS_SORT_ORDER='productsSortOrder';export var SHOP_SETTING_WISHLIST_MODE='wishlistMode';export var SHOP_SETTING_COOKIE_CONSENT_MODE='cookieConsentMode';export var SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT='displayPricePerMeasureUnit';export var SHOP_SETTING_IMAGES='images';export var SHOP_SETTING_IMAGES_PRODUCT_PLACEHOLDER='productPlaceholder';export var SHOP_SETTING_IMAGES_CATEGORY_PLACEHOLDER='categoryPlaceholder';export var SHOP_SETTING_IMAGES_FAVICON='favicon';export var SHOP_SETTING_NUMBER_OF_ADDRESS_LINES='numberOfAddressLines';export var SHOP_SETTINGS_SHOW_CATEGORY_IMAGES='showCategoryImages';export var WISHLIST_MODE_PERSIST_ON_ADD='persistOnAdd';
2
+ export var SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE='googleSiteVerificationCode';export var SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT='cartSupplementalContent';export var SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT='orderSupplementalContent';export var SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP='showShopLogoInApp';export var SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB='showShopLogoInWeb';export var SHOP_SETTING_PRODUCTS_SORT_ORDER='productsSortOrder';export var SHOP_SETTING_WISHLIST_MODE='wishlistMode';export var SHOP_SETTING_COOKIE_CONSENT_MODE='cookieConsentMode';export var SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT='displayPricePerMeasureUnit';export var SHOP_SETTING_IMAGES='images';export var SHOP_SETTING_IMAGES_PRODUCT_PLACEHOLDER='productPlaceholder';export var SHOP_SETTING_IMAGES_CATEGORY_PLACEHOLDER='categoryPlaceholder';export var SHOP_SETTING_IMAGES_FAVICON='favicon';export var SHOP_SETTING_NUMBER_OF_ADDRESS_LINES='numberOfAddressLines';export var SHOP_SETTINGS_SHOW_CATEGORY_IMAGES='showCategoryImages';export var SHOP_SETTING_REGISTRATION_MODE='registrationMode';export var SHOP_SETTING_REGISTRATION_MODE_SIMPLE='simple';export var SHOP_SETTING_REGISTRATION_MODE_EXTENDED='extended';export var WISHLIST_MODE_PERSIST_ON_ADD='persistOnAdd';
package/core/index.js CHANGED
@@ -49,4 +49,4 @@ export{withTheme}from"./hocs/withTheme";export{withRoute}from"./hocs/withRoute";
49
49
  export{ThemeConfigResolver}from"./config/ThemeConfigResolver";export{isBeta}from"./config/isBeta";export{getThemeConfig}from"./config/getThemeConfig";export{getThemeSettings}from"./config/getThemeSettings";export{getThemeColors}from"./config/getThemeColors";export{getThemeAssets}from"./config/getThemeAssets";export{getPageConfig}from"./config/getPageConfig";export{getPageSettings}from"./config/getPageSettings";export{getWidgetConfig}from"./config/getWidgetConfig";export{getWidgetSettings}from"./config/getWidgetSettings";// -------------- HELPERS -------------- //
50
50
  export{i18n,getWeekDaysOrder}from"./helpers/i18n";export{default as nl2br}from"./helpers/nl2br";export*from"./helpers/string";export{updateLegacyNavigationBar}from"./helpers/updateLegacyNavigationBar";export{getFullImageSource}from"./helpers/getFullImageSource";export{isIOSTheme}from"./helpers/isIOSTheme";export{isTouchDevice}from"./helpers/isTouchDevice";export{generateGoogleMapsDirectionsUrl}from"./helpers/googleMaps";export{hasWebBridge}from"./helpers/bridge";export{useScrollContainer}from"./helpers/scrollContainer";export{getDeviceTypeForCms}from"./helpers/deviceType";export*from"./helpers/featureFlag";// -------------- CONFIG -------------- //
51
51
  export*from"./config/config.actions";export*from"./config/config.selectors";export*from"./config/config.streams";export*from"./initialization";// -------------- VALIDATION -------------- //
52
- export*from"./validation";export{default as errorBehavior}from"./helpers/errorBehavior";export{makeGetShopSettingByKey,makeGetShopSettings,getIsLocationBasedShopping,getRestrictMultiLocationOrders,getFulfillmentSchedulingEnabled,getProductImagePlaceholder,getCategoryImagePlaceholder,getFavicon,getDefaultCurrency,getEnableWebIndexing,getNumberOfAddressLines,getGoogleSiteVerificationCode}from"./selectors";export{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,EUNAUTHORIZED,EAUTHENTICATION}from"./constants";
52
+ export*from"./validation";export{default as errorBehavior}from"./helpers/errorBehavior";export{makeGetShopSettingByKey,makeGetShopSettings,getIsLocationBasedShopping,getRestrictMultiLocationOrders,getFulfillmentSchedulingEnabled,getProductImagePlaceholder,getCategoryImagePlaceholder,getFavicon,getDefaultCurrency,getEnableWebIndexing,getNumberOfAddressLines,getGoogleSiteVerificationCode,getRegistrationMode}from"./selectors";export{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_REGISTRATION_MODE_SIMPLE,SHOP_SETTING_REGISTRATION_MODE_EXTENDED,EUNAUTHORIZED,EAUTHENTICATION}from"./constants";
@@ -1 +1 @@
1
- export{getState as getShopSettingsState,makeGetShopSettingByKey,makeGetShopSettings,getProductImagePlaceholder,getCategoryImagePlaceholder,getFavicon,getNumberOfAddressLines,getGoogleSiteVerificationCode}from"./shopSettings";export{getIsLocationBasedShopping,getFulfillmentSchedulingEnabled,getRestrictMultiLocationOrders,getDefaultCurrency,getEnableWebIndexing,getProductShowAlternativeLocation,getProductListShowInventory}from"./merchantSettings";
1
+ export{getState as getShopSettingsState,makeGetShopSettingByKey,makeGetShopSettings,getProductImagePlaceholder,getCategoryImagePlaceholder,getFavicon,getNumberOfAddressLines,getGoogleSiteVerificationCode,getRegistrationMode}from"./shopSettings";export{getIsLocationBasedShopping,getFulfillmentSchedulingEnabled,getRestrictMultiLocationOrders,getDefaultCurrency,getEnableWebIndexing,getProductShowAlternativeLocation,getProductListShowInventory}from"./merchantSettings";
@@ -1,4 +1,4 @@
1
- import{createSelector}from'reselect';import{WISHLIST_MODE_PERSIST_ON_ADD,SHOP_SETTING_WISHLIST_MODE,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_GOOGLE_SITE_VERIFICATION_CODE,SHOP_SETTINGS_SHOW_CATEGORY_IMAGES}from"../constants/shopSettings";/**
1
+ import{createSelector}from'reselect';import{WISHLIST_MODE_PERSIST_ON_ADD,SHOP_SETTING_WISHLIST_MODE,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_GOOGLE_SITE_VERIFICATION_CODE,SHOP_SETTINGS_SHOW_CATEGORY_IMAGES,SHOP_SETTING_REGISTRATION_MODE,SHOP_SETTING_REGISTRATION_MODE_EXTENDED}from"../constants/shopSettings";/**
2
2
  * Retrieves the shopSettings state from the store.
3
3
  * @param {Object} state The current application state.
4
4
  * @return {Object} The locations state.
@@ -19,4 +19,7 @@ import{createSelector}from'reselect';import{WISHLIST_MODE_PERSIST_ON_ADD,SHOP_SE
19
19
  * Selects the placeholder image for products
20
20
  */export var getFavicon=createSelector(getShopSettingImages,function(images){return(images===null||images===void 0?void 0:images[SHOP_SETTING_IMAGES_FAVICON])||null;});/**
21
21
  * Selects the number of address lines for registration / address forms
22
- */export var getNumberOfAddressLines=makeGetShopSettingByKey(SHOP_SETTING_NUMBER_OF_ADDRESS_LINES,2);export var getGoogleSiteVerificationCode=makeGetShopSettingByKey(SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE,'');export var getShowCategoryImages=makeGetShopSettingByKey(SHOP_SETTINGS_SHOW_CATEGORY_IMAGES,true);
22
+ */export var getNumberOfAddressLines=makeGetShopSettingByKey(SHOP_SETTING_NUMBER_OF_ADDRESS_LINES,2);export var getGoogleSiteVerificationCode=makeGetShopSettingByKey(SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE,'');export var getShowCategoryImages=makeGetShopSettingByKey(SHOP_SETTINGS_SHOW_CATEGORY_IMAGES,true);/**
23
+ * Creates a selector to retrieve the current active registration mode.
24
+ * When the selector returns "simple" the form will not contain any address related fields.
25
+ */export var getRegistrationMode=makeGetShopSettingByKey(SHOP_SETTING_REGISTRATION_MODE,SHOP_SETTING_REGISTRATION_MODE_EXTENDED);
@@ -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);});};}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{hot}from'react-hot-loader/root';import React,{Fragment,useCallback,useState}from'react';import PropTypes from'prop-types';import{RippleButton,TextField,I18n,ArrowIcon}from'@shopgate/engage/components';import{i18n,EUSERNOTFOUND}from'@shopgate/engage/core';import{container,headline,subline,form,input,button,buttonContainer,resetInstructions,resetInstructionsEmail,goBackButtonContainer,goBackButton,goBackButtonIcon}from"./ForgotPassword.style";import connect from"./ForgotPassword.connector";/**
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);});};}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{hot}from'react-hot-loader/root';import React,{Fragment,useCallback,useState}from'react';import PropTypes from'prop-types';import{RippleButton,I18n,ArrowIcon}from'@shopgate/engage/components';import TextField from'@shopgate/pwa-ui-shared/TextField';import{i18n,EUSERNOTFOUND}from'@shopgate/engage/core';import{container,headline,subline,form,input,button,buttonContainer,resetInstructions,resetInstructionsEmail,goBackButtonContainer,goBackButton,goBackButtonIcon}from"./ForgotPassword.style";import connect from"./ForgotPassword.connector";/**
2
2
  * The ForgotPassword component.
3
3
  * @param {Object} props The component props.
4
4
  * @returns {JSX}
@@ -1 +1 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _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';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{StylePresets}from'@shopgate/engage/components/Form';var variables=themeConfig.variables,colors=themeConfig.colors;export var container=css(_defineProperty({flexGrow:1,padding:"".concat(variables.gap.small*3,"px ").concat(variables.gap.big,"px")},responsiveMediaQuery('>sm',{webOnly:true}),{width:'50%'}));export var headline=css(_defineProperty({fontSize:'2.1875rem',lineHeight:1,fontWeight:500},responsiveMediaQuery('>sm',{webOnly:true}),{fontSize:'2rem',fontWeight:'normal',paddingBottom:variables.gap.big}));export var subline=css({fontSize:'1.125rem',color:"var(--color-text-low-emphasis, ".concat(colors.shade6,")"),marginBottom:variables.gap.big,marginTop:4});export var form=css(_defineProperty({paddingTop:24},responsiveMediaQuery('>sm',{webOnly:true}),_extends({},StylePresets.OUTLINED_FORM_FIELDS,{' .simpleInput':{paddingLeft:variables.gap.big}})));export var buttonContainer=css({paddingTop:variables.gap.big*2,paddingBottom:variables.gap.big*1.5}).toString();export var button=css({width:'100%'}).toString();export var input=css({' .label':{color:'var(--color-text-low-emphasis)'},' .placeholder':{color:'var(--color-text-low-emphasis)'},' .simpleInput':{color:'var(--color-text-heigh-emphasis)'}}).toString();export var resetInstructions=css({paddingTop:variables.gap.big,display:'flex',alignItems:'center'});export var resetInstructionsEmail=css({fontWeight:'bold',color:'var(--color-secondary)'});export var goBackButtonContainer=css({padding:"".concat(variables.gap.big,"px 0")}).toString();export var goBackButton=css({fontSize:'0.875rem !important',padding:'0 !important',' > div ':{padding:0,display:'flex'}}).toString();export var goBackButtonIcon=css({display:'inline-block',fontSize:'1.375rem !important',alignSelf:'center',marginRight:variables.gap.xsmall,marginLeft:-3,marginTop:-2}).toString();
1
+ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _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';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{StylePresets}from'@shopgate/engage/components/Form';var variables=themeConfig.variables,colors=themeConfig.colors;export var container=css(_defineProperty({flexGrow:1,padding:"".concat(variables.gap.small*3,"px ").concat(variables.gap.big,"px")},responsiveMediaQuery('>sm',{webOnly:true}),{width:'50%'}));export var headline=css(_defineProperty({fontSize:'2.1875rem',lineHeight:1,fontWeight:500,paddingBottom:variables.gap.big},responsiveMediaQuery('>sm',{webOnly:true}),{fontSize:'2rem',fontWeight:'normal'}));export var subline=css({fontSize:'1.125rem',color:"var(--color-text-low-emphasis, ".concat(colors.shade6,")"),marginBottom:variables.gap.big,marginTop:4});export var form=css(_extends({paddingTop:24},StylePresets.OUTLINED_FORM_FIELDS,{' .simpleInput':{paddingLeft:variables.gap.big}})).toString();export var buttonContainer=css({paddingTop:variables.gap.big*2,paddingBottom:variables.gap.big*1.5}).toString();export var button=css({width:'100%'}).toString();export var input=css({' .label':{color:'var(--color-text-low-emphasis)'},' .placeholder':{color:'var(--color-text-low-emphasis)'},' .simpleInput':{color:'var(--color-text-heigh-emphasis)'}}).toString();export var resetInstructions=css({paddingTop:variables.gap.big,display:'flex',alignItems:'center'});export var resetInstructionsEmail=css({fontWeight:'bold',color:'var(--color-secondary)'});export var goBackButtonContainer=css({padding:"".concat(variables.gap.big,"px 0")}).toString();export var goBackButton=css({fontSize:'0.875rem !important',padding:'0 !important',' > div ':{padding:0,display:'flex'}}).toString();export var goBackButtonIcon=css({display:'inline-block',fontSize:'1.375rem !important',alignSelf:'center',marginRight:variables.gap.xsmall,marginLeft:-3,marginTop:-2}).toString();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/engage",
3
- "version": "7.8.0-beta.2",
3
+ "version": "7.8.0-beta.4",
4
4
  "description": "Shopgate's ENGAGE library.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -16,12 +16,12 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "@shopgate/native-modules": "1.0.0-beta.18",
19
- "@shopgate/pwa-common": "7.8.0-beta.2",
20
- "@shopgate/pwa-common-commerce": "7.8.0-beta.2",
21
- "@shopgate/pwa-core": "7.8.0-beta.2",
22
- "@shopgate/pwa-ui-ios": "7.8.0-beta.2",
23
- "@shopgate/pwa-ui-material": "7.8.0-beta.2",
24
- "@shopgate/pwa-ui-shared": "7.8.0-beta.2",
19
+ "@shopgate/pwa-common": "7.8.0-beta.4",
20
+ "@shopgate/pwa-common-commerce": "7.8.0-beta.4",
21
+ "@shopgate/pwa-core": "7.8.0-beta.4",
22
+ "@shopgate/pwa-ui-ios": "7.8.0-beta.4",
23
+ "@shopgate/pwa-ui-material": "7.8.0-beta.4",
24
+ "@shopgate/pwa-ui-shared": "7.8.0-beta.4",
25
25
  "@stripe/react-stripe-js": "^1.1.2",
26
26
  "@stripe/stripe-js": "^1.3.1",
27
27
  "@virtuous/conductor": "~2.5.0",
@@ -1,4 +1,4 @@
1
- import React,{useRef}from'react';import RegistrationProvider from"../../providers/RegistrationProvider";import RegistrationFormBase from"./RegistrationFormBase";import RegistrationFormBilling from"./RegistrationFormBilling";import RegistrationFormShipping from"./RegistrationFormShipping";import RegistrationFormActions from"./RegistrationFormActions";import RegistrationFormExtra from"./RegistrationFormExtra";import RegistrationFormToggle from"./RegistrationFormToggle";import{container,containerItem}from"./Registration.style";/**
1
+ import React,{useRef}from'react';import RegistrationProvider from"../../providers/RegistrationProvider";import RegistrationContent from"./RegistrationContent";/**
2
2
  * The Registration component.
3
3
  * @returns {JSX}
4
- */var Registration=function Registration(){var formContainerRef=useRef(null);return React.createElement(RegistrationProvider,{formContainerRef:formContainerRef},React.createElement("div",{className:container,ref:formContainerRef},React.createElement("div",{className:containerItem},React.createElement(RegistrationFormBase,null)),React.createElement("div",{className:containerItem},React.createElement(RegistrationFormBilling,null),React.createElement(RegistrationFormToggle,null),React.createElement(RegistrationFormShipping,null),React.createElement(RegistrationFormExtra,null))),React.createElement(RegistrationFormActions,null));};export default Registration;
4
+ */var Registration=function Registration(){var formContainerRef=useRef(null);return React.createElement(RegistrationProvider,{formContainerRef:formContainerRef},React.createElement(RegistrationContent,{ref:formContainerRef}));};export default Registration;
@@ -0,0 +1,4 @@
1
+ import React,{forwardRef}from'react';import{SHOP_SETTING_REGISTRATION_MODE_SIMPLE}from'@shopgate/engage/core';import RegistrationFormBase from"./RegistrationFormBase";import RegistrationFormBilling from"./RegistrationFormBilling";import RegistrationFormShipping from"./RegistrationFormShipping";import RegistrationFormActions from"./RegistrationFormActions";import RegistrationFormExtra from"./RegistrationFormExtra";import RegistrationFormToggle from"./RegistrationFormToggle";import{container,containerItem}from"./RegistrationContent.style";import{useRegistration}from"../../hooks";/**
2
+ * The Registration component.
3
+ * @returns {JSX}
4
+ */var Registration=forwardRef(function(_,ref){var _useRegistration=useRegistration(),registrationMode=_useRegistration.registrationMode;var renderSingleColumn=registrationMode===SHOP_SETTING_REGISTRATION_MODE_SIMPLE;return React.createElement(React.Fragment,null,React.createElement("div",{className:container,ref:ref},React.createElement("div",{className:containerItem},!renderSingleColumn&&React.createElement(RegistrationFormBase,null)),React.createElement("div",{className:containerItem},renderSingleColumn&&React.createElement(RegistrationFormBase,null),React.createElement(RegistrationFormBilling,null),React.createElement(RegistrationFormToggle,null),React.createElement(RegistrationFormShipping,null),React.createElement(RegistrationFormExtra,null))),React.createElement(RegistrationFormActions,null));});export default Registration;
@@ -0,0 +1,2 @@
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';import{StylePresets}from'@shopgate/engage/components/Form';import{isIOSTheme}from'@shopgate/engage/core';var variables=themeConfig.variables;export var container=css(_extends({padding:"".concat(variables.gap.big,"px ").concat(variables.gap.big,"px 0"),display:'flex',flex:'0 0 auto',flexDirection:'column'},!isIOSTheme()?{'@media(min-width: 768px)':{flexDirection:'row-reverse','> :not(:first-child)':{marginRight:variables.gap.big}}}:null));export var containerItem=css(_extends({flexGrow:1,flexShrink:0},!isIOSTheme()?{'@media(min-width: 768px)':{width:"calc(50% - ".concat(variables.gap.big,"px)")}}:null));export var form=css(_extends({},StylePresets.OUTLINED_FORM_FIELDS,{' .registrationOptInMarketingOptIn':{paddingTop:0,paddingBottom:variables.gap.big}}));export var section=css({// marginBottom: variables.gap.big * 1.5,
2
+ }).toString();export var shippingFormSection=css({paddingBottom:32}).toString();export var hidden=css({display:'none'}).toString();export var submitButtonContainer=css(_extends({margin:"0 ".concat(variables.gap.big,"px ").concat(variables.gap.big,"px")},!isIOSTheme()?{'@media(min-width: 768px)':{width:"calc(50% - ".concat(variables.gap.big,"px)")}}:null));export var submitButton=css({width:'100%',marginTop:8}).toString();
@@ -1,4 +1,4 @@
1
- import React,{useMemo}from'react';import PropTypes from'prop-types';import{i18n}from'@shopgate/engage/core';import{RippleButton}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import{submitButton,submitButtonContainer}from"./Registration.style";/**
1
+ import React,{useMemo}from'react';import PropTypes from'prop-types';import{i18n}from'@shopgate/engage/core';import{RippleButton}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import{submitButton,submitButtonContainer}from"./RegistrationContent.style";/**
2
2
  * PickupContactForm
3
3
  * @param {Object} props The component props
4
4
  * @returns {JSX}
@@ -1,4 +1,4 @@
1
- import{i18n}from'@shopgate/engage/core';/**
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{i18n,SHOP_SETTING_REGISTRATION_MODE_SIMPLE,SHOP_SETTING_REGISTRATION_MODE_EXTENDED}from'@shopgate/engage/core';/**
2
2
  * Generates form configuration.
3
3
  * @returns {Object}
4
- */var generateFormConfig=function generateFormConfig(){return{fields:{emailAddress:{type:'email',label:"".concat(i18n.text('checkout.pickup_contact.form.emailAddress')," *")},password:{type:'password',label:i18n.text('checkout.pickup_contact.form.password')},passwordConfirm:{type:'password',label:i18n.text('checkout.pickup_contact.form.passwordConfirm')}}};};export default generateFormConfig;
4
+ */var generateFormConfig=function generateFormConfig(_ref){var _ref$registrationMode=_ref.registrationMode,registrationMode=_ref$registrationMode===void 0?SHOP_SETTING_REGISTRATION_MODE_EXTENDED:_ref$registrationMode;return{fields:_extends({},registrationMode===SHOP_SETTING_REGISTRATION_MODE_SIMPLE?{firstName:{type:'text',label:"".concat(i18n.text('checkout.pickup_contact.form.firstName')," *")},lastName:{type:'text',label:"".concat(i18n.text('checkout.pickup_contact.form.lastName')," *")}}:null,{emailAddress:{type:'email',label:"".concat(i18n.text('checkout.pickup_contact.form.emailAddress')," *")},password:{type:'password',label:i18n.text('checkout.pickup_contact.form.password')},passwordConfirm:{type:'password',label:i18n.text('checkout.pickup_contact.form.passwordConfirm')}})};};export default generateFormConfig;
@@ -1,4 +1,4 @@
1
- import React,{useMemo,useCallback}from'react';import{FormBuilder}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import Section from"../../../checkout/components/Checkout/CheckoutSection";import generateFormConfig from"./RegistrationFormBase.config";import{form,section}from"./Registration.style";/**
1
+ import React,{useMemo,useCallback}from'react';import{FormBuilder}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import Section from"../../../checkout/components/Checkout/CheckoutSection";import generateFormConfig from"./RegistrationFormBase.config";import{form,section}from"./RegistrationContent.style";/**
2
2
  * The RegistrationFormBase component.
3
3
  * @returns {JSX}
4
- */var RegistrationFormBase=function RegistrationFormBase(){var _useRegistration=useRegistration(),defaultBaseFormState=_useRegistration.defaultBaseFormState,baseFormValidationErrors=_useRegistration.baseFormValidationErrors,updateBaseForm=_useRegistration.updateBaseForm;var formConfig=useMemo(function(){return generateFormConfig();},[]);var handleUpdate=useCallback(function(values){updateBaseForm(values);},[updateBaseForm]);return React.createElement(Section,{title:"registration.headlines.create_new_account",className:section,hasForm:true},React.createElement(FormBuilder,{className:form,name:"RegistrationBase",config:formConfig,defaults:defaultBaseFormState,validationErrors:baseFormValidationErrors,handleUpdate:handleUpdate}));};export default RegistrationFormBase;
4
+ */var RegistrationFormBase=function RegistrationFormBase(){var _useRegistration=useRegistration(),defaultBaseFormState=_useRegistration.defaultBaseFormState,baseFormValidationErrors=_useRegistration.baseFormValidationErrors,updateBaseForm=_useRegistration.updateBaseForm,registrationMode=_useRegistration.registrationMode;var formConfig=useMemo(function(){return generateFormConfig({registrationMode:registrationMode});},[registrationMode]);var handleUpdate=useCallback(function(values){updateBaseForm(values);},[updateBaseForm]);return React.createElement(Section,{title:"registration.headlines.create_new_account",className:section,hasForm:true},React.createElement(FormBuilder,{className:form,name:"RegistrationBase",config:formConfig,defaults:defaultBaseFormState,validationErrors:baseFormValidationErrors,handleUpdate:handleUpdate}));};export default RegistrationFormBase;
@@ -1,5 +1,5 @@
1
- import React,{useMemo,useCallback}from'react';import PropTypes from'prop-types';import{FormBuilder}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import Section from"../../../checkout/components/Checkout/CheckoutSection";import{ELEMENT_ID_BILLING_CONTACT}from"../../constants";import generateFormConfig from"./RegistrationFormBilling.config";import{form,section}from"./Registration.style";/**
1
+ import React,{useMemo,useCallback}from'react';import PropTypes from'prop-types';import{FormBuilder}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import Section from"../../../checkout/components/Checkout/CheckoutSection";import{ELEMENT_ID_BILLING_CONTACT}from"../../constants";import generateFormConfig from"./RegistrationFormBilling.config";import{form,section}from"./RegistrationContent.style";/**
2
2
  * The RegistrationFormBilling component.
3
3
  * @param {Object} props The component props
4
4
  * @returns {JSX}
5
- */var RegistrationFormBilling=function RegistrationFormBilling(_ref){var isGuest=_ref.isGuest;var _useRegistration=useRegistration(isGuest),supportedCountries=_useRegistration.supportedCountries,userLocation=_useRegistration.userLocation,defaultBillingFormState=_useRegistration.defaultBillingFormState,billingFormValidationErrors=_useRegistration.billingFormValidationErrors,updateBillingForm=_useRegistration.updateBillingForm,numberOfAddressLines=_useRegistration.numberOfAddressLines,orderReserveOnly=_useRegistration.orderReserveOnly;var formConfig=useMemo(function(){return generateFormConfig({supportedCountries:supportedCountries,userLocation:userLocation,numberOfAddressLines:numberOfAddressLines,isGuest:isGuest,isReserveOnly:orderReserveOnly});},[isGuest,numberOfAddressLines,orderReserveOnly,supportedCountries,userLocation]);var title=useMemo(function(){if(isGuest&&orderReserveOnly){return'registration.headlines.billing_address_reserve';}return'registration.headlines.billing_address';},[isGuest,orderReserveOnly]);var handleUpdate=useCallback(function(values){updateBillingForm(values);},[updateBillingForm]);return React.createElement(Section,{title:title,className:section,hasForm:true,id:ELEMENT_ID_BILLING_CONTACT},React.createElement(FormBuilder,{className:form,name:"RegistrationBilling",config:formConfig,defaults:defaultBillingFormState,validationErrors:billingFormValidationErrors,handleUpdate:handleUpdate}));};RegistrationFormBilling.defaultProps={isGuest:false};export default RegistrationFormBilling;
5
+ */var RegistrationFormBilling=function RegistrationFormBilling(_ref){var isGuest=_ref.isGuest;var _useRegistration=useRegistration(isGuest),supportedCountries=_useRegistration.supportedCountries,userLocation=_useRegistration.userLocation,defaultBillingFormState=_useRegistration.defaultBillingFormState,billingFormValidationErrors=_useRegistration.billingFormValidationErrors,updateBillingForm=_useRegistration.updateBillingForm,numberOfAddressLines=_useRegistration.numberOfAddressLines,orderReserveOnly=_useRegistration.orderReserveOnly,isBillingAddressSelectionEnabled=_useRegistration.isBillingAddressSelectionEnabled;var formConfig=useMemo(function(){return generateFormConfig({supportedCountries:supportedCountries,userLocation:userLocation,numberOfAddressLines:numberOfAddressLines,isGuest:isGuest,isReserveOnly:orderReserveOnly});},[isGuest,numberOfAddressLines,orderReserveOnly,supportedCountries,userLocation]);var title=useMemo(function(){if(isGuest&&orderReserveOnly){return'registration.headlines.billing_address_reserve';}return'registration.headlines.billing_address';},[isGuest,orderReserveOnly]);var handleUpdate=useCallback(function(values){updateBillingForm(values);},[updateBillingForm]);if(!isBillingAddressSelectionEnabled){return null;}return React.createElement(Section,{title:title,className:section,hasForm:true,id:ELEMENT_ID_BILLING_CONTACT},React.createElement(FormBuilder,{className:form,name:"RegistrationBilling",config:formConfig,defaults:defaultBillingFormState,validationErrors:billingFormValidationErrors,handleUpdate:handleUpdate}));};RegistrationFormBilling.defaultProps={isGuest:false};export default RegistrationFormBilling;
@@ -1,4 +1,4 @@
1
- import React,{useMemo,useCallback}from'react';import PropTypes from'prop-types';import{FormBuilder}from'@shopgate/engage/components';import Section from"../../../checkout/components/Checkout/CheckoutSection";import{useRegistration}from"../../hooks";import{ELEMENT_ID_CUSTOMER_ATTRIBUTES}from"../../constants";import generateFormConfig from"./RegistrationFormExtra.config";import{form,section}from"./Registration.style";/**
1
+ import React,{useMemo,useCallback}from'react';import PropTypes from'prop-types';import{FormBuilder}from'@shopgate/engage/components';import Section from"../../../checkout/components/Checkout/CheckoutSection";import{useRegistration}from"../../hooks";import{ELEMENT_ID_CUSTOMER_ATTRIBUTES}from"../../constants";import generateFormConfig from"./RegistrationFormExtra.config";import{form,section}from"./RegistrationContent.style";/**
2
2
  * The RegistrationFormExtra component.
3
3
  * @param {Object} props The component props
4
4
  * @returns {JSX}
@@ -1,4 +1,4 @@
1
- import React,{useMemo,useCallback}from'react';import PropTypes from'prop-types';import classNames from'classnames';import{FormBuilder}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import Section from"../../../checkout/components/Checkout/CheckoutSection";import{ELEMENT_ID_SHIPPING_CONTACT}from"../../constants";import generateFormConfig from"./RegistrationFormShipping.config";import{form,section,shippingFormSection}from"./Registration.style";/**
1
+ import React,{useMemo,useCallback}from'react';import PropTypes from'prop-types';import classNames from'classnames';import{FormBuilder}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import Section from"../../../checkout/components/Checkout/CheckoutSection";import{ELEMENT_ID_SHIPPING_CONTACT}from"../../constants";import generateFormConfig from"./RegistrationFormShipping.config";import{form,section,shippingFormSection}from"./RegistrationContent.style";/**
2
2
  * The RegistrationFormShipping component.
3
3
  * @param {Object} props The component props
4
4
  * @returns {JSX}
@@ -1,4 +1,4 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React,{useCallback}from'react';import PropTypes from'prop-types';import{css}from'glamor';import{i18n,isIOSTheme}from'@shopgate/engage/core';import{Toggle}from'@shopgate/engage/components';import{ELEMENT_ID_SHIPPING_CONTACT_TOGGLE}from"../../constants";import{useRegistration}from"../../hooks";var styles={root:css(_extends({display:'flex',justifyContent:'space-between',paddingBottom:24},isIOSTheme()?{padding:'16px 0'}:{})).toString(),label:css({paddingRight:8}).toString()};/**
1
+ import React,{useCallback}from'react';import PropTypes from'prop-types';import{css}from'glamor';import{i18n}from'@shopgate/engage/core';import{Toggle}from'@shopgate/engage/components';import{ELEMENT_ID_SHIPPING_CONTACT_TOGGLE}from"../../constants";import{useRegistration}from"../../hooks";var styles={root:css({display:'flex',justifyContent:'space-between',paddingBottom:24}).toString(),label:css({paddingRight:8}).toString()};/**
2
2
  * @param {Object} props The component props
3
3
  * @returns {JSX}
4
4
  */var RegistrationFormToggle=function RegistrationFormToggle(_ref){var isGuest=_ref.isGuest;var _useRegistration=useRegistration(isGuest),isShippingAddressSelectionEnabled=_useRegistration.isShippingAddressSelectionEnabled,isShippingFormVisible=_useRegistration.isShippingFormVisible,setIsShippingFormVisible=_useRegistration.setIsShippingFormVisible;var handleChange=useCallback(function(e){setIsShippingFormVisible(e.target.checked);},[setIsShippingFormVisible]);if(!isShippingAddressSelectionEnabled){return null;}return React.createElement("div",{className:styles.root,id:ELEMENT_ID_SHIPPING_CONTACT_TOGGLE},React.createElement("span",{className:styles.label},i18n.text('registration.different_shipping_address_label')),React.createElement(Toggle,{id:"toggle-shipping-form",checked:isShippingFormVisible,onChange:handleChange}));};RegistrationFormToggle.defaultProps={isGuest:false};export default RegistrationFormToggle;
@@ -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);});};}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React,{useMemo,useState,useCallback,useEffect}from'react';import PropTypes from'prop-types';import pickBy from'lodash/pickBy';import identity from'lodash/identity';import appConfig from'@shopgate/pwa-common/helpers/config';import{useFormState}from'@shopgate/engage/core/hooks/useFormState';import{useScrollTo}from'@shopgate/engage/core/hooks/useScrollTo';import{LoadingProvider,i18n,useAsyncMemo,useRoute}from'@shopgate/engage/core';import{ADDRESS_TYPE_SHIPPING,ADDRESS_TYPE_PICKUP}from'@shopgate/engage/checkout';import{extractDefaultValues}from"../../account/helper/form";import{GUEST_CHECKOUT_PATTERN,GUEST_CHECKOUT_PAYMENT_PATTERN}from"../../checkout/constants/routes";import Context from"./GuestRegistrationProvider.context";import{generateBillingConstraints,generateShippingConstraints,generatePickupConstraints,generateSelfPickupConstraints,generateExtraConstraints}from"./GuestRegistrationProvider.constraints";import{MARKETING_OPT_IN_DEFAULT,ELEMENT_ID_SHIPPING_CONTACT,ELEMENT_ID_SHIPPING_CONTACT_TOGGLE,ELEMENT_ID_PICKUP_CONTACT}from"../constants";import connect from"./GuestRegistrationProvider.connector";var initialAddressFormState={firstName:'',lastName:'',company:'',address1:'',address2:'',city:'',country:'',postalCode:'',mobile:''};var initialBillingFormState=_extends({},initialAddressFormState);var initialShippingFormState=_extends({},initialAddressFormState);var initialPickupFormState={pickupPerson:'me',firstName:'',lastName:'',mobile:'',emailAddress:''};var initialOptInFormState={marketingOptIn:MARKETING_OPT_IN_DEFAULT};/**
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);});};}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React,{useMemo,useState,useCallback,useEffect}from'react';import PropTypes from'prop-types';import pickBy from'lodash/pickBy';import identity from'lodash/identity';import appConfig from'@shopgate/pwa-common/helpers/config';import{useFormState}from'@shopgate/engage/core/hooks/useFormState';import{useScrollTo}from'@shopgate/engage/core/hooks/useScrollTo';import{LoadingProvider,i18n,useAsyncMemo,useRoute,SHOP_SETTING_REGISTRATION_MODE_EXTENDED}from'@shopgate/engage/core';import{ADDRESS_TYPE_SHIPPING,ADDRESS_TYPE_PICKUP}from'@shopgate/engage/checkout';import{extractDefaultValues}from"../../account/helper/form";import{GUEST_CHECKOUT_PATTERN,GUEST_CHECKOUT_PAYMENT_PATTERN}from"../../checkout/constants/routes";import Context from"./GuestRegistrationProvider.context";import{generateBillingConstraints,generateShippingConstraints,generatePickupConstraints,generateSelfPickupConstraints,generateExtraConstraints}from"./GuestRegistrationProvider.constraints";import{MARKETING_OPT_IN_DEFAULT,ELEMENT_ID_SHIPPING_CONTACT,ELEMENT_ID_SHIPPING_CONTACT_TOGGLE,ELEMENT_ID_PICKUP_CONTACT}from"../constants";import connect from"./GuestRegistrationProvider.connector";var initialAddressFormState={firstName:'',lastName:'',company:'',address1:'',address2:'',city:'',country:'',postalCode:'',mobile:''};var initialBillingFormState=_extends({},initialAddressFormState);var initialShippingFormState=_extends({},initialAddressFormState);var initialPickupFormState={pickupPerson:'me',firstName:'',lastName:'',mobile:'',emailAddress:''};var initialOptInFormState={marketingOptIn:MARKETING_OPT_IN_DEFAULT};/**
2
2
  * Converts validation errors into errors for form builder.
3
3
  * @param {Object} validationErrors The validation errors.
4
4
  * @returns {Array}
@@ -14,4 +14,9 @@ var defaultPickupFormState=useMemo(function(){return _extends({},initialPickupFo
14
14
  var defaultExtraFormState=useMemo(function(){return _extends({},initialOptInFormState,{},extractDefaultValues((customer===null||customer===void 0?void 0:customer.attributes)||[]));},[customer]);var extraConstraints=useMemo(function(){return generateExtraConstraints(customerAttributes);},[customerAttributes]);var handleExtraFormSubmit=useCallback(function(){setIsExtraFormSubmitted(true);},[]);var extraFormState=useFormState(defaultExtraFormState,handleExtraFormSubmit,extraConstraints,formContainerRef);var handleSubmit=useCallback(function(){billingFormState.handleSubmit();shippingFormState.handleSubmit();pickupFormState.handleSubmit();extraFormState.handleSubmit();},[billingFormState,extraFormState,pickupFormState,shippingFormState]);useEffect(function(){if(!isBillingFormSubmitted||!isShippingFormSubmitted||!isPickupFormSubmitted||!isExtraFormSubmitted){return;}// Break the process when one of the forms has validation errors from the constraints
15
15
  if(!billingFormState.valid||!shippingFormState.valid||!pickupFormState.valid||!extraFormState.valid){setIsBillingFormSubmitted(false);setIsShippingFormSubmitted(false);setIsPickupFormSubmitted(false);setIsExtraFormSubmitted(false);}/** Async wrapper for submit registration */var fn=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(){var response,_ref4,errors;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:setIsLocked(true);_context2.prev=1;_context2.next=4;return submitGuestRegistration(_extends({billingFormData:billingFormState.values},isShippingFormVisible?{shippingFormData:shippingFormState.values}:{},{},isPickupContactSelectionEnabled?{pickupFormData:pickupFormState.values}:{},{extraFormData:extraFormState.values,processShipping:isShippingAddressSelectionEnabled}));case 4:response=_context2.sent;_context2.next=11;break;case 7:_context2.prev=7;_context2.t0=_context2["catch"](1);setIsLocked(false);return _context2.abrupt("return");case 11:_ref4=response||{},errors=_ref4.errors;if(errors){_context2.next=17;break;}setIsLocked(false);LoadingProvider.setLoading(GUEST_CHECKOUT_PAYMENT_PATTERN);if(guestRegistrationEditMode){historyPop();}else{historyPush({pathname:GUEST_CHECKOUT_PAYMENT_PATTERN});}return _context2.abrupt("return");case 17:// Updated the request validation errors
16
16
  setBillingFormRequestErrors((errors===null||errors===void 0?void 0:errors.billingFormData)||null);setShippingFormRequestErrors((errors===null||errors===void 0?void 0:errors.shippingFormData)||null);setPickupFormRequestErrors((errors===null||errors===void 0?void 0:errors.pickupFormData)||null);setExtraFormRequestErrors((errors===null||errors===void 0?void 0:errors.extraFormData)||null);// Release forms for additional submits
17
- setIsBillingFormSubmitted(false);setIsShippingFormSubmitted(false);setIsPickupFormSubmitted(false);setIsExtraFormSubmitted(false);setIsLocked(false);case 26:case"end":return _context2.stop();}}},_callee2,null,[[1,7]]);}));return function fn(){return _ref3.apply(this,arguments);};}();fn();/* eslint-disable react-hooks/exhaustive-deps */},[isBillingFormSubmitted,isShippingFormSubmitted,isPickupFormSubmitted,isExtraFormSubmitted]);/* eslint-enable react-hooks/exhaustive-deps */ /* eslint-disable react-hooks/exhaustive-deps */useEffect(function(){billingFormState.scrollToError();},[billingFormRequestErrors,shippingFormRequestErrors,pickupFormRequestErrors,billingFormState.scrollToError]);/* eslint-enable react-hooks/exhaustive-deps */useEffect(function(){if(isLocked){LoadingProvider.setLoading(GUEST_CHECKOUT_PATTERN);return;}LoadingProvider.unsetLoading(GUEST_CHECKOUT_PATTERN);},[isLocked]);useEffect(function(){var timer=setTimeout(function(){if(!guestRegistrationEditMode){return;}var scrollToElement;if(guestRegistrationEditMode===ADDRESS_TYPE_SHIPPING){if(isShippingFormVisible){scrollToElement=ELEMENT_ID_SHIPPING_CONTACT;}else{scrollToElement=ELEMENT_ID_SHIPPING_CONTACT_TOGGLE;}}else if(guestRegistrationEditMode===ADDRESS_TYPE_PICKUP){scrollToElement=ELEMENT_ID_PICKUP_CONTACT;}if(scrollToElement){scrollTo("#".concat(scrollToElement));}},500);return function(){return clearTimeout(timer);};/* eslint-disable react-hooks/exhaustive-deps */},[]);/* eslint-enable react-hooks/exhaustive-deps */var value=useMemo(function(){return{isShippingFormEnabled:isShippingFormEnabled,isShippingFormVisible:isShippingFormVisible,setIsShippingFormVisible:setIsShippingFormVisible,orderReserveOnly:orderReserveOnly,orderNeedsPayment:orderNeedsPayment,guestRegistrationEditMode:guestRegistrationEditMode,defaultBillingFormState:defaultBillingFormState,updateBillingForm:billingFormState.setValues,defaultShippingFormState:defaultShippingFormState,updateShippingForm:shippingFormState.setValues,defaultPickupFormState:defaultPickupFormState,updatePickupForm:pickupFormState.setValues,defaultExtraFormState:defaultExtraFormState,updateExtraForm:extraFormState.setValues,billingFormValidationErrors:convertValidationErrors(billingFormState.validationErrors||billingFormRequestErrors||{}),shippingFormValidationErrors:convertValidationErrors(shippingFormState.validationErrors||shippingFormRequestErrors||{}),pickupFormValidationErrors:convertValidationErrors(pickupFormState.validationErrors||pickupFormRequestErrors||{}),extraFormValidationErrors:convertValidationErrors(extraFormState.validationErrors||extraFormRequestErrors||{}),isShippingAddressSelectionEnabled:isShippingAddressSelectionEnabled,isPickupContactSelectionEnabled:isPickupContactSelectionEnabled,customerAttributes:customerAttributes,numberOfAddressLines:numberOfAddressLines,userLocation:userLocation,supportedCountries:shopSettings.supportedCountries,isLocked:isLocked,handleSubmit:handleSubmit};},[isShippingFormEnabled,isShippingFormVisible,defaultBillingFormState,billingFormState.setValues,billingFormState.validationErrors,defaultShippingFormState,shippingFormState.setValues,shippingFormState.validationErrors,defaultExtraFormState,extraFormState.setValues,extraFormState.validationErrors,extraFormRequestErrors,defaultPickupFormState,pickupFormState.setValues,pickupFormState.validationErrors,billingFormRequestErrors,shippingFormRequestErrors,pickupFormRequestErrors,orderReserveOnly,orderNeedsPayment,guestRegistrationEditMode,isShippingAddressSelectionEnabled,isPickupContactSelectionEnabled,customerAttributes,numberOfAddressLines,userLocation,shopSettings.supportedCountries,isLocked,handleSubmit]);if(!isDataReady||!isInitialized){return null;}return React.createElement(Context.Provider,{value:value},children);};GuestRegistrationProvider.defaultProps={children:null,customer:null,formContainerRef:null,billingAddress:null,shippingAddress:null,pickupAddress:null,billingPickupEquals:true,billingShippingEquals:true,cartHasDirectShipItems:false,orderReserveOnly:false,orderNeedsPayment:false,numberOfAddressLines:null,isShippingAddressSelectionEnabled:false,isPickupContactSelectionEnabled:false};export default connect(GuestRegistrationProvider);
17
+ setIsBillingFormSubmitted(false);setIsShippingFormSubmitted(false);setIsPickupFormSubmitted(false);setIsExtraFormSubmitted(false);setIsLocked(false);case 26:case"end":return _context2.stop();}}},_callee2,null,[[1,7]]);}));return function fn(){return _ref3.apply(this,arguments);};}();fn();/* eslint-disable react-hooks/exhaustive-deps */},[isBillingFormSubmitted,isShippingFormSubmitted,isPickupFormSubmitted,isExtraFormSubmitted]);/* eslint-enable react-hooks/exhaustive-deps */ /* eslint-disable react-hooks/exhaustive-deps */useEffect(function(){billingFormState.scrollToError();},[billingFormRequestErrors,shippingFormRequestErrors,pickupFormRequestErrors,billingFormState.scrollToError]);/* eslint-enable react-hooks/exhaustive-deps */useEffect(function(){if(isLocked){LoadingProvider.setLoading(GUEST_CHECKOUT_PATTERN);return;}LoadingProvider.unsetLoading(GUEST_CHECKOUT_PATTERN);},[isLocked]);useEffect(function(){var timer=setTimeout(function(){if(!guestRegistrationEditMode){return;}var scrollToElement;if(guestRegistrationEditMode===ADDRESS_TYPE_SHIPPING){if(isShippingFormVisible){scrollToElement=ELEMENT_ID_SHIPPING_CONTACT;}else{scrollToElement=ELEMENT_ID_SHIPPING_CONTACT_TOGGLE;}}else if(guestRegistrationEditMode===ADDRESS_TYPE_PICKUP){scrollToElement=ELEMENT_ID_PICKUP_CONTACT;}if(scrollToElement){scrollTo("#".concat(scrollToElement));}},500);return function(){return clearTimeout(timer);};/* eslint-disable react-hooks/exhaustive-deps */},[]);/* eslint-enable react-hooks/exhaustive-deps */var value=useMemo(function(){return{isShippingFormEnabled:isShippingFormEnabled,isShippingFormVisible:isShippingFormVisible,setIsShippingFormVisible:setIsShippingFormVisible,orderReserveOnly:orderReserveOnly,orderNeedsPayment:orderNeedsPayment,guestRegistrationEditMode:guestRegistrationEditMode,defaultBillingFormState:defaultBillingFormState,updateBillingForm:billingFormState.setValues,defaultShippingFormState:defaultShippingFormState,updateShippingForm:shippingFormState.setValues,defaultPickupFormState:defaultPickupFormState,updatePickupForm:pickupFormState.setValues,defaultExtraFormState:defaultExtraFormState,updateExtraForm:extraFormState.setValues,billingFormValidationErrors:convertValidationErrors(billingFormState.validationErrors||billingFormRequestErrors||{}),shippingFormValidationErrors:convertValidationErrors(shippingFormState.validationErrors||shippingFormRequestErrors||{}),pickupFormValidationErrors:convertValidationErrors(pickupFormState.validationErrors||pickupFormRequestErrors||{}),extraFormValidationErrors:convertValidationErrors(extraFormState.validationErrors||extraFormRequestErrors||{}),isShippingAddressSelectionEnabled:isShippingAddressSelectionEnabled,isPickupContactSelectionEnabled:isPickupContactSelectionEnabled,customerAttributes:customerAttributes,numberOfAddressLines:numberOfAddressLines,userLocation:userLocation,supportedCountries:shopSettings.supportedCountries,isLocked:isLocked,handleSubmit:handleSubmit,/**
18
+ * Handling of registrationMode "simple" is not implemented for checkout. But since
19
+ * the guest registration is actually an order update and not a real registration, we
20
+ * hardcode the registration mode here, since the provider value will be used inside
21
+ * the shared form components.
22
+ */registrationMode:SHOP_SETTING_REGISTRATION_MODE_EXTENDED,isBillingAddressSelectionEnabled:true};},[isShippingFormEnabled,isShippingFormVisible,defaultBillingFormState,billingFormState.setValues,billingFormState.validationErrors,defaultShippingFormState,shippingFormState.setValues,shippingFormState.validationErrors,defaultExtraFormState,extraFormState.setValues,extraFormState.validationErrors,extraFormRequestErrors,defaultPickupFormState,pickupFormState.setValues,pickupFormState.validationErrors,billingFormRequestErrors,shippingFormRequestErrors,pickupFormRequestErrors,orderReserveOnly,orderNeedsPayment,guestRegistrationEditMode,isShippingAddressSelectionEnabled,isPickupContactSelectionEnabled,customerAttributes,numberOfAddressLines,userLocation,shopSettings.supportedCountries,isLocked,handleSubmit]);if(!isDataReady||!isInitialized){return null;}return React.createElement(Context.Provider,{value:value},children);};GuestRegistrationProvider.defaultProps={children:null,customer:null,formContainerRef:null,billingAddress:null,shippingAddress:null,pickupAddress:null,billingPickupEquals:true,billingShippingEquals:true,cartHasDirectShipItems:false,orderReserveOnly:false,orderNeedsPayment:false,numberOfAddressLines:null,isShippingAddressSelectionEnabled:false,isPickupContactSelectionEnabled:false};export default connect(GuestRegistrationProvider);
@@ -1,7 +1,8 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}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{EVALIDATION}from'@shopgate/engage/core';import{extractAttributes,convertPipelineValidationErrors}from'@shopgate/engage/account/helper/form';import{getMerchantCustomerAttributes}from'@shopgate/engage/core/selectors/merchantSettings';import{submitRegistration as submit}from"../actions";/**
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}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{EVALIDATION,getRegistrationMode,SHOP_SETTING_REGISTRATION_MODE_SIMPLE}from'@shopgate/engage/core';import{extractAttributes,convertPipelineValidationErrors}from'@shopgate/engage/account/helper/form';import{getMerchantCustomerAttributes}from'@shopgate/engage/core/selectors/merchantSettings';import{submitRegistration as submit}from"../actions";/**
2
2
  * Submits registration form data.
3
3
  * @param {Object} baseFormData Data from the base form
4
4
  * @param {Object} shippingFormData Data from the shipping form
5
5
  * @param {Object} additionalData Additional data for the request.
6
6
  * @returns {Function}
7
- */export var submitRegistration=function submitRegistration(_ref){var baseFormData=_ref.baseFormData,billingFormData=_ref.billingFormData,shippingFormData=_ref.shippingFormData,additionalFormData=_ref.additionalFormData;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var customerAttributes,marketingOptIn,attributeData,attributes,emailAddress,password,firstName,lastName,customer,errors,code,validationErrors,converted,_converted$validation2,_converted$validation3,_converted$validation4,_converted$validation5,_converted$validation6,_converted$validation,errEmailAddress,errPassword,billing,shipping,extra;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:customerAttributes=getMerchantCustomerAttributes(getState());marketingOptIn=additionalFormData.marketingOptIn,attributeData=_objectWithoutProperties(additionalFormData,["marketingOptIn"]);attributes=extractAttributes(customerAttributes,attributeData);emailAddress=baseFormData.emailAddress,password=baseFormData.password;firstName=billingFormData.firstName,lastName=billingFormData.lastName;customer={firstName:firstName,lastName:lastName,emailAddress:emailAddress,password:password,attributes:attributes,settings:{marketingOptIn:marketingOptIn}};customer.contacts=[_extends({},billingFormData,{emailAddress:emailAddress,isDefaultBilling:true,isDefaultShipping:!shippingFormData})].concat(shippingFormData?[_extends({},shippingFormData,{emailAddress:emailAddress,isDefaultBilling:false,isDefaultShipping:true})]:[]);_context.prev=7;_context.next=10;return dispatch(submit(customer));case 10:_context.next=17;break;case 12:_context.prev=12;_context.t0=_context["catch"](7);code=_context.t0.code;validationErrors=_context.t0.errors;if(code===EVALIDATION){errors=validationErrors;}case 17:converted=convertPipelineValidationErrors(errors,attributes);if(!((converted===null||converted===void 0?void 0:converted.validation)&&Object.keys(converted.validation).length>0)){_context.next=24;break;}_converted$validation=converted.validation,errEmailAddress=_converted$validation.emailAddress,errPassword=_converted$validation.password;billing=(converted===null||converted===void 0?void 0:(_converted$validation2=converted.validation)===null||_converted$validation2===void 0?void 0:(_converted$validation3=_converted$validation2.contacts)===null||_converted$validation3===void 0?void 0:_converted$validation3['0'])||{};shipping=(converted===null||converted===void 0?void 0:(_converted$validation4=converted.validation)===null||_converted$validation4===void 0?void 0:(_converted$validation5=_converted$validation4.contacts)===null||_converted$validation5===void 0?void 0:_converted$validation5['1'])||{};extra=(converted===null||converted===void 0?void 0:(_converted$validation6=converted.validation)===null||_converted$validation6===void 0?void 0:_converted$validation6.attributes)||{};return _context.abrupt("return",{errors:{baseFormData:_extends({},errEmailAddress?{emailAddress:errEmailAddress}:{},{},errPassword?{password:errPassword}:{}),billingFormData:_extends({},billing),shippingFormData:_extends({},shipping),extraFormData:_extends({},extra)}});case 24:return _context.abrupt("return",null);case 25:case"end":return _context.stop();}}},_callee,null,[[7,12]]);}));return function(_x,_x2){return _ref2.apply(this,arguments);};}());};
7
+ */export var submitRegistration=function submitRegistration(_ref){var baseFormData=_ref.baseFormData,billingFormData=_ref.billingFormData,shippingFormData=_ref.shippingFormData,additionalFormData=_ref.additionalFormData;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var customerAttributes,registrationMode,marketingOptIn,attributeData,attributes,emailAddress,password,firstName,lastName,customer,errors,code,validationErrors,converted,_converted$validation2,_converted$validation3,_converted$validation4,_converted$validation5,_converted$validation6,_converted$validation,errEmailAddress,errPassword,billing,shipping,extra;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:customerAttributes=getMerchantCustomerAttributes(getState());registrationMode=getRegistrationMode(getState());marketingOptIn=additionalFormData.marketingOptIn,attributeData=_objectWithoutProperties(additionalFormData,["marketingOptIn"]);attributes=extractAttributes(customerAttributes,attributeData);emailAddress=baseFormData.emailAddress,password=baseFormData.password;if(registrationMode===SHOP_SETTING_REGISTRATION_MODE_SIMPLE){firstName=baseFormData.firstName;lastName=baseFormData.lastName;}else{firstName=billingFormData.firstName;lastName=billingFormData.lastName;}customer={firstName:firstName,lastName:lastName,emailAddress:emailAddress,password:password,attributes:attributes,settings:{marketingOptIn:marketingOptIn}};if(registrationMode!==SHOP_SETTING_REGISTRATION_MODE_SIMPLE){// No contacts creation at "simple" registration mode
8
+ customer.contacts=[_extends({},billingFormData,{emailAddress:emailAddress,isDefaultBilling:true,isDefaultShipping:!shippingFormData})].concat(shippingFormData?[_extends({},shippingFormData,{emailAddress:emailAddress,isDefaultBilling:false,isDefaultShipping:true})]:[]);}_context.prev=8;_context.next=11;return dispatch(submit(customer));case 11:_context.next=18;break;case 13:_context.prev=13;_context.t0=_context["catch"](8);code=_context.t0.code;validationErrors=_context.t0.errors;if(code===EVALIDATION){errors=validationErrors;}case 18:converted=convertPipelineValidationErrors(errors,attributes);if(!((converted===null||converted===void 0?void 0:converted.validation)&&Object.keys(converted.validation).length>0)){_context.next=25;break;}_converted$validation=converted.validation,errEmailAddress=_converted$validation.emailAddress,errPassword=_converted$validation.password;billing=(converted===null||converted===void 0?void 0:(_converted$validation2=converted.validation)===null||_converted$validation2===void 0?void 0:(_converted$validation3=_converted$validation2.contacts)===null||_converted$validation3===void 0?void 0:_converted$validation3['0'])||{};shipping=(converted===null||converted===void 0?void 0:(_converted$validation4=converted.validation)===null||_converted$validation4===void 0?void 0:(_converted$validation5=_converted$validation4.contacts)===null||_converted$validation5===void 0?void 0:_converted$validation5['1'])||{};extra=(converted===null||converted===void 0?void 0:(_converted$validation6=converted.validation)===null||_converted$validation6===void 0?void 0:_converted$validation6.attributes)||{};return _context.abrupt("return",{errors:{baseFormData:_extends({},errEmailAddress?{emailAddress:errEmailAddress}:{},{},errPassword?{password:errPassword}:{}),billingFormData:_extends({},billing),shippingFormData:_extends({},shipping),extraFormData:_extends({},extra)}});case 25:return _context.abrupt("return",null);case 26:case"end":return _context.stop();}}},_callee,null,[[8,13]]);}));return function(_x,_x2){return _ref2.apply(this,arguments);};}());};
@@ -1,6 +1,6 @@
1
- import{connect}from'react-redux';import{getShopSettings,getConfigFetching}from'@shopgate/engage/core/config';import{getNumberOfAddressLines}from'@shopgate/engage/core';import{hasDirectShipItems}from'@shopgate/engage/cart';import{getPreferredLocationAddress}from'@shopgate/engage/locations/selectors';import{getMerchantCustomerAttributes}from'@shopgate/engage/core/selectors/merchantSettings';import{submitRegistration}from"./RegistrationProvider.actions";/**
1
+ import{connect}from'react-redux';import{getShopSettings,getConfigFetching}from'@shopgate/engage/core/config';import{getNumberOfAddressLines,getRegistrationMode}from'@shopgate/engage/core';import{hasDirectShipItems}from'@shopgate/engage/cart';import{getPreferredLocationAddress}from'@shopgate/engage/locations/selectors';import{getMerchantCustomerAttributes}from'@shopgate/engage/core/selectors/merchantSettings';import{submitRegistration}from"./RegistrationProvider.actions";/**
2
2
  * @returns {Function}
3
3
  */function makeMapStateToProps(){/**
4
4
  * @param {Object} state The application state.
5
5
  * @returns {Object}
6
- */return function(state){return{isDataReady:!getConfigFetching(state),shopSettings:getShopSettings(state),userLocation:getPreferredLocationAddress(state),customerAttributes:getMerchantCustomerAttributes(state),cartHasDirectShipItems:hasDirectShipItems(state),numberOfAddressLines:getNumberOfAddressLines(state)};};}var mapDispatchToProps={submitRegistration:submitRegistration};export default connect(makeMapStateToProps,mapDispatchToProps);
6
+ */return function(state){return{isDataReady:!getConfigFetching(state),shopSettings:getShopSettings(state),userLocation:getPreferredLocationAddress(state),customerAttributes:getMerchantCustomerAttributes(state),cartHasDirectShipItems:hasDirectShipItems(state),numberOfAddressLines:getNumberOfAddressLines(state),registrationMode:getRegistrationMode(state)};};}var mapDispatchToProps={submitRegistration:submitRegistration};export default connect(makeMapStateToProps,mapDispatchToProps);
@@ -1,6 +1,26 @@
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{generateFormConstraints}from'@shopgate/engage/account/helper/form';/**
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{SHOP_SETTING_REGISTRATION_MODE_EXTENDED,SHOP_SETTING_REGISTRATION_MODE_SIMPLE}from'@shopgate/engage/core';import{generateFormConstraints}from'@shopgate/engage/account/helper/form';/**
2
+ * Helper to generate base constraints
3
+ * @param {Object} params Options for the helper
4
+ * @param {string} params.registrationMode Current active registration mode
2
5
  * @returns {Object}
3
- */export var generateBaseConstraints=function generateBaseConstraints(){return{emailAddress:{presence:{message:'validation.required',allowEmpty:false},email:{message:'validation.email'}},password:{presence:{message:'validation.required',allowEmpty:false}},passwordConfirm:{presence:{message:'validation.required',allowEmpty:false},equality:{attribute:'password',message:'validation.passwordMismatch',comparator:function comparator(v1,v2){return JSON.stringify(v1)===JSON.stringify(v2);}}}};};var addressConstraints={firstName:{presence:{message:'validation.required',allowEmpty:false}},lastName:{presence:{message:'validation.required',allowEmpty:false}},address1:{presence:{message:'validation.required',allowEmpty:false}},city:{presence:{message:'validation.required',allowEmpty:false}},country:{presence:{message:'validation.required',allowEmpty:false}},postalCode:{presence:{message:'validation.required',allowEmpty:false}},mobile:{presence:{message:'validation.required',allowEmpty:false},format:{pattern:'^[+0-9]+',message:'validation.mobileNumber'}}};export var billingConstraints=_extends({},addressConstraints);export var shippingConstraints=_extends({},addressConstraints);/**
6
+ */export var generateBaseConstraints=function generateBaseConstraints(_ref){var _ref$registrationMode=_ref.registrationMode,registrationMode=_ref$registrationMode===void 0?SHOP_SETTING_REGISTRATION_MODE_EXTENDED:_ref$registrationMode;return _extends({},registrationMode===SHOP_SETTING_REGISTRATION_MODE_SIMPLE?{firstName:{presence:{message:'validation.required',allowEmpty:false}},lastName:{presence:{message:'validation.required',allowEmpty:false}}}:null,{emailAddress:{presence:{message:'validation.required',allowEmpty:false},email:{message:'validation.email'}},password:{presence:{message:'validation.required',allowEmpty:false}},passwordConfirm:{presence:{message:'validation.required',allowEmpty:false},equality:{attribute:'password',message:'validation.passwordMismatch',comparator:function comparator(v1,v2){return JSON.stringify(v1)===JSON.stringify(v2);}}}});};/**
7
+ * Helper to generate address constraints
8
+ * @param {Object} params Options for the helper
9
+ * @param {string} params.registrationMode Current active registration mode
10
+ * @returns {Object}
11
+ */var generateAddressConstraints=function generateAddressConstraints(_ref2){var _ref2$registrationMod=_ref2.registrationMode,registrationMode=_ref2$registrationMod===void 0?SHOP_SETTING_REGISTRATION_MODE_EXTENDED:_ref2$registrationMod;return _extends({},registrationMode===SHOP_SETTING_REGISTRATION_MODE_EXTENDED?{firstName:{presence:{message:'validation.required',allowEmpty:false}},lastName:{presence:{message:'validation.required',allowEmpty:false}},address1:{presence:{message:'validation.required',allowEmpty:false}},city:{presence:{message:'validation.required',allowEmpty:false}},country:{presence:{message:'validation.required',allowEmpty:false}},postalCode:{presence:{message:'validation.required',allowEmpty:false}},mobile:{presence:{message:'validation.required',allowEmpty:false},format:{pattern:'^[+0-9]+',message:'validation.mobileNumber'}}}:null);};/**
12
+ * Helper to generate billing form constraints
13
+ * @param {Object} params Options for the helper
14
+ * @param {string} [params.registrationMode] Current active registration mode
15
+ * @returns {Object}
16
+ */export var generateBillingConstraints=function generateBillingConstraints(_ref3){var _ref3$registrationMod=_ref3.registrationMode,registrationMode=_ref3$registrationMod===void 0?SHOP_SETTING_REGISTRATION_MODE_EXTENDED:_ref3$registrationMod;return generateAddressConstraints({registrationMode:registrationMode});};/**
17
+ * Helper to generate shipping form constraints
18
+ * @param {Object} params Options for the helper
19
+ * @param {string} [params.registrationMode] Current active registration mode
20
+ * @returns {Object}
21
+ */export var generateShippingConstraints=function generateShippingConstraints(_ref4){var _ref4$registrationMod=_ref4.registrationMode,registrationMode=_ref4$registrationMod===void 0?SHOP_SETTING_REGISTRATION_MODE_EXTENDED:_ref4$registrationMod;return registrationMode===SHOP_SETTING_REGISTRATION_MODE_EXTENDED// Only at "extended" mode there will be constraints for the shipping form since "simple" has no
22
+ // shipping form.
23
+ ?generateAddressConstraints({registrationMode:registrationMode}):{};};/**
4
24
  * Generates constraints for the "extra" form.
5
25
  * @param {Object} customerAttributes Customer attributes.
6
26
  * @returns {Object}
@@ -1,12 +1,12 @@
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);});};}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React,{useMemo,useState,useEffect,useCallback}from'react';import{REGISTER_PATH}from'@shopgate/pwa-common/constants/RoutePaths';import{LoadingProvider,i18n,useRoute}from'@shopgate/engage/core';import{useFormState}from'@shopgate/engage/core/hooks/useFormState';import appConfig from'@shopgate/pwa-common/helpers/config';import{extractDefaultValues}from"../../account/helper/form";import Context from"./RegistrationProvider.context";import{generateBaseConstraints,billingConstraints,shippingConstraints,generateExtraConstraints}from"./RegistrationProvider.constraints";import connect from"./RegistrationProvider.connector";import{MARKETING_OPT_IN_DEFAULT}from"../constants";var initialBaseFormState={emailAddress:'',password:'',passwordConfirm:''};var initialAddressFormState={firstName:'',lastName:'',company:'',address1:'',address2:'',city:'',country:'',postalCode:'',mobile:''};var initialBillingFormState=_extends({},initialAddressFormState);var initialShippingFormState=_extends({},initialAddressFormState);var initialOptInFormState={marketingOptIn:MARKETING_OPT_IN_DEFAULT};/**
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);});};}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React,{useMemo,useState,useEffect,useCallback}from'react';import{REGISTER_PATH}from'@shopgate/pwa-common/constants/RoutePaths';import{LoadingProvider,i18n,useRoute,SHOP_SETTING_REGISTRATION_MODE_SIMPLE}from'@shopgate/engage/core';import{useFormState}from'@shopgate/engage/core/hooks/useFormState';import appConfig from'@shopgate/pwa-common/helpers/config';import{extractDefaultValues}from"../../account/helper/form";import Context from"./RegistrationProvider.context";import{generateBaseConstraints,generateBillingConstraints,generateShippingConstraints,generateExtraConstraints}from"./RegistrationProvider.constraints";import connect from"./RegistrationProvider.connector";import{MARKETING_OPT_IN_DEFAULT}from"../constants";var initialBaseFormState={emailAddress:'',password:'',passwordConfirm:''};var initialAddressFormState={firstName:'',lastName:'',company:'',address1:'',address2:'',city:'',country:'',postalCode:'',mobile:''};var initialBillingFormState=_extends({},initialAddressFormState);var initialShippingFormState=_extends({},initialAddressFormState);var initialOptInFormState={marketingOptIn:MARKETING_OPT_IN_DEFAULT};/**
2
2
  * Converts validation errors into errors for form builder.
3
3
  * @param {Object} validationErrors The validation errors.
4
4
  * @returns {Array}
5
5
  */var convertValidationErrors=function convertValidationErrors(validationErrors){return Object.keys(validationErrors).map(function(key){return{path:key,message:i18n.text(validationErrors[key])};});};/**
6
6
  * Registration Provider
7
7
  * @returns {JSX}
8
- */var RegistrationProvider=function RegistrationProvider(_ref){var isDataReady=_ref.isDataReady,cartHasDirectShipItems=_ref.cartHasDirectShipItems,shopSettings=_ref.shopSettings,userLocation=_ref.userLocation,customerAttributes=_ref.customerAttributes,numberOfAddressLines=_ref.numberOfAddressLines,submitRegistration=_ref.submitRegistration,children=_ref.children,formContainerRef=_ref.formContainerRef;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),isLocked=_useState2[0],setLocked=_useState2[1];var _useState3=useState(false),_useState4=_slicedToArray(_useState3,2),isBaseFormSubmitted=_useState4[0],setIsBaseFormSubmitted=_useState4[1];var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),isBillingFormSubmitted=_useState6[0],setIsBillingFormSubmitted=_useState6[1];var _useState7=useState(false),_useState8=_slicedToArray(_useState7,2),isShippingFormSubmitted=_useState8[0],setIsShippingFormSubmitted=_useState8[1];var _useState9=useState(false),_useState10=_slicedToArray(_useState9,2),isExtraFormSubmitted=_useState10[0],setIsExtraFormSubmitted=_useState10[1];var _useState11=useState(null),_useState12=_slicedToArray(_useState11,2),baseFormRequestErrors=_useState12[0],setBaseFormRequestErrors=_useState12[1];var _useState13=useState(null),_useState14=_slicedToArray(_useState13,2),billingFormRequestErrors=_useState14[0],setBillingFormRequestErrors=_useState14[1];var _useState15=useState(null),_useState16=_slicedToArray(_useState15,2),shippingFormRequestErrors=_useState16[0],setShippingFormRequestErrors=_useState16[1];var _useState17=useState(null),_useState18=_slicedToArray(_useState17,2),extraFormRequestErrors=_useState18[0],setExtraFormRequestErrors=_useState18[1];var _useState19=useState(false),_useState20=_slicedToArray(_useState19,2),isShippingFormVisible=_useState20[0],setIsShippingFormVisible=_useState20[1];var _useRoute=useRoute(),query=_useRoute.query;var isShippingAddressSelectionEnabled=useMemo(function(){return(query===null||query===void 0?void 0:query.checkout)&&cartHasDirectShipItems;},[cartHasDirectShipItems,query]);// Determine values to prefill some form fields
9
- var userCountry=useMemo(function(){return(userLocation===null||userLocation===void 0?void 0:userLocation.country)||(appConfig===null||appConfig===void 0?void 0:appConfig.marketId)||null;},[userLocation]);var userRegion=useMemo(function(){return(userLocation===null||userLocation===void 0?void 0:userLocation.region)||null;},[userLocation]);var baseConstraints=useMemo(function(){return generateBaseConstraints();},[]);var extraConstraints=useMemo(function(){return generateExtraConstraints(customerAttributes);},[customerAttributes]);// Default form states
8
+ */var RegistrationProvider=function RegistrationProvider(_ref){var isDataReady=_ref.isDataReady,cartHasDirectShipItems=_ref.cartHasDirectShipItems,shopSettings=_ref.shopSettings,userLocation=_ref.userLocation,customerAttributes=_ref.customerAttributes,numberOfAddressLines=_ref.numberOfAddressLines,registrationMode=_ref.registrationMode,submitRegistration=_ref.submitRegistration,children=_ref.children,formContainerRef=_ref.formContainerRef;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),isLocked=_useState2[0],setLocked=_useState2[1];var _useState3=useState(false),_useState4=_slicedToArray(_useState3,2),isBaseFormSubmitted=_useState4[0],setIsBaseFormSubmitted=_useState4[1];var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),isBillingFormSubmitted=_useState6[0],setIsBillingFormSubmitted=_useState6[1];var _useState7=useState(false),_useState8=_slicedToArray(_useState7,2),isShippingFormSubmitted=_useState8[0],setIsShippingFormSubmitted=_useState8[1];var _useState9=useState(false),_useState10=_slicedToArray(_useState9,2),isExtraFormSubmitted=_useState10[0],setIsExtraFormSubmitted=_useState10[1];var _useState11=useState(null),_useState12=_slicedToArray(_useState11,2),baseFormRequestErrors=_useState12[0],setBaseFormRequestErrors=_useState12[1];var _useState13=useState(null),_useState14=_slicedToArray(_useState13,2),billingFormRequestErrors=_useState14[0],setBillingFormRequestErrors=_useState14[1];var _useState15=useState(null),_useState16=_slicedToArray(_useState15,2),shippingFormRequestErrors=_useState16[0],setShippingFormRequestErrors=_useState16[1];var _useState17=useState(null),_useState18=_slicedToArray(_useState17,2),extraFormRequestErrors=_useState18[0],setExtraFormRequestErrors=_useState18[1];var _useState19=useState(false),_useState20=_slicedToArray(_useState19,2),isShippingFormVisible=_useState20[0],setIsShippingFormVisible=_useState20[1];var _useRoute=useRoute(),query=_useRoute.query;var isShippingAddressSelectionEnabled=useMemo(function(){return(query===null||query===void 0?void 0:query.checkout)&&cartHasDirectShipItems&&registrationMode!==SHOP_SETTING_REGISTRATION_MODE_SIMPLE;},[cartHasDirectShipItems,query,registrationMode]);var isBillingAddressSelectionEnabled=useMemo(function(){return registrationMode!==SHOP_SETTING_REGISTRATION_MODE_SIMPLE;},[registrationMode]);// Determine values to prefill some form fields
9
+ var userCountry=useMemo(function(){return(userLocation===null||userLocation===void 0?void 0:userLocation.country)||(appConfig===null||appConfig===void 0?void 0:appConfig.marketId)||null;},[userLocation]);var userRegion=useMemo(function(){return(userLocation===null||userLocation===void 0?void 0:userLocation.region)||null;},[userLocation]);var baseConstraints=useMemo(function(){return generateBaseConstraints({registrationMode:registrationMode});},[registrationMode]);var billingConstraints=useMemo(function(){return generateBillingConstraints({registrationMode:registrationMode});},[registrationMode]);var shippingConstraints=useMemo(function(){return generateShippingConstraints({registrationMode:registrationMode});},[registrationMode]);var extraConstraints=useMemo(function(){return generateExtraConstraints(customerAttributes);},[customerAttributes]);// Default form states
10
10
  var defaultBaseFormState=_extends({},initialBaseFormState);var defaultBillingFormState=useMemo(function(){return _extends({},initialBillingFormState,{country:userCountry,region:userRegion});},[userCountry,userRegion]);var defaultShippingFormState=useMemo(function(){return _extends({},initialShippingFormState,{country:userCountry,region:userRegion});},[userCountry,userRegion]);var defaultExtraFormState=useMemo(function(){return _extends({},initialOptInFormState,{},extractDefaultValues(customerAttributes));},[customerAttributes]);// Form submit handlers
11
11
  var handleBaseFormSubmit=useCallback(function(){setIsBaseFormSubmitted(true);},[setIsBaseFormSubmitted]);var handleBillingFormSubmit=useCallback(function(){setIsBillingFormSubmitted(true);},[setIsBillingFormSubmitted]);var handleShippingFormSubmit=useCallback(function(){setIsShippingFormSubmitted(true);},[setIsShippingFormSubmitted]);var handleExtraFormSubmit=useCallback(function(){setIsExtraFormSubmitted(true);},[]);// Form states
12
12
  var baseFormState=useFormState(defaultBaseFormState,handleBaseFormSubmit,baseConstraints,formContainerRef);var billingFormState=useFormState(defaultBillingFormState,handleBillingFormSubmit,billingConstraints,formContainerRef);var shippingFormState=useFormState(defaultShippingFormState,handleShippingFormSubmit,shippingConstraints,formContainerRef);var extraFormState=useFormState(defaultExtraFormState,handleExtraFormSubmit,extraConstraints,formContainerRef);// Central submit handler
@@ -14,4 +14,4 @@ var handleSubmit=useCallback(function(){baseFormState.handleSubmit(new Event('su
14
14
  if(!isBaseFormSubmitted||!isBillingFormSubmitted||!isShippingFormSubmitted||!isExtraFormSubmitted){return;}// Break the process when one of the forms has validation errors from the constraints
15
15
  if(!baseFormState.valid||!billingFormState.valid||isShippingFormVisible&&!shippingFormState.valid||!extraFormState.valid){setIsBaseFormSubmitted(false);setIsBillingFormSubmitted(false);setIsShippingFormSubmitted(false);setIsExtraFormSubmitted(false);return;}/** Async wrapper for submit registration */var fn=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var response,_ref3,errors;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:setLocked(true);_context.next=3;return submitRegistration(_extends({baseFormData:baseFormState.values,billingFormData:billingFormState.values,additionalFormData:extraFormState.values},isShippingFormVisible?{shippingFormData:shippingFormState.values}:{}));case 3:response=_context.sent;_ref3=response||{},errors=_ref3.errors;// Updated the request validation errors
16
16
  setBaseFormRequestErrors((errors===null||errors===void 0?void 0:errors.baseFormData)||null);setBillingFormRequestErrors((errors===null||errors===void 0?void 0:errors.billingFormData)||null);setShippingFormRequestErrors((errors===null||errors===void 0?void 0:errors.shippingFormData)||null);setExtraFormRequestErrors((errors===null||errors===void 0?void 0:errors.extraFormData)||null);// Release forms for additional submits
17
- setIsBaseFormSubmitted(false);setIsBillingFormSubmitted(false);setIsShippingFormSubmitted(false);setIsExtraFormSubmitted(false);setLocked(false);case 14:case"end":return _context.stop();}}},_callee);}));return function fn(){return _ref2.apply(this,arguments);};}();fn();/* eslint-disable react-hooks/exhaustive-deps */},[isBaseFormSubmitted,isBillingFormSubmitted,isShippingFormSubmitted,isExtraFormSubmitted,baseFormState.valid,billingFormState.valid,shippingFormState.valid,extraFormState.valid,isShippingFormVisible,submitRegistration]);/* eslint-enable react-hooks/exhaustive-deps */ /* eslint-disable react-hooks/exhaustive-deps */useEffect(function(){baseFormState.scrollToError();},[baseFormRequestErrors,billingFormRequestErrors,shippingFormRequestErrors,baseFormState.scrollToError]);/* eslint-enable react-hooks/exhaustive-deps */ /* eslint-disable react-hooks/exhaustive-deps */useEffect(function(){shippingFormState.setIgnoreErrors(!isShippingFormVisible);},[isShippingFormVisible]);/* eslint-enable react-hooks/exhaustive-deps */useEffect(function(){if(isLocked){LoadingProvider.setLoading(REGISTER_PATH);return;}LoadingProvider.unsetLoading(REGISTER_PATH);},[isLocked]);var value=useMemo(function(){return{supportedCountries:shopSettings.supportedCountries||[],customerAttributes:customerAttributes,userLocation:userLocation,defaultBaseFormState:defaultBaseFormState,defaultBillingFormState:defaultBillingFormState,defaultShippingFormState:defaultShippingFormState,defaultExtraFormState:defaultExtraFormState,baseFormValidationErrors:convertValidationErrors(baseFormState.validationErrors||baseFormRequestErrors||{}),billingFormValidationErrors:convertValidationErrors(billingFormState.validationErrors||billingFormRequestErrors||{}),shippingFormValidationErrors:convertValidationErrors(shippingFormState.validationErrors||shippingFormRequestErrors||{}),extraFormValidationErrors:convertValidationErrors(extraFormState.validationErrors||extraFormRequestErrors||{}),handleSubmit:handleSubmit,updateBaseForm:baseFormState.setValues,updateBillingForm:billingFormState.setValues,updateShippingForm:shippingFormState.setValues,updateExtraForm:extraFormState.setValues,isShippingAddressSelectionEnabled:isShippingAddressSelectionEnabled,isShippingFormVisible:isShippingFormVisible,setIsShippingFormVisible:setIsShippingFormVisible,numberOfAddressLines:numberOfAddressLines};},[shopSettings.supportedCountries,customerAttributes,userLocation,defaultBaseFormState,defaultBillingFormState,defaultShippingFormState,baseFormState.validationErrors,baseFormState.setValues,baseFormRequestErrors,billingFormState.validationErrors,billingFormState.setValues,billingFormRequestErrors,shippingFormState.validationErrors,shippingFormState.setValues,shippingFormRequestErrors,handleSubmit,defaultExtraFormState,extraFormState.setValues,extraFormState.validationErrors,extraFormRequestErrors,isShippingAddressSelectionEnabled,isShippingFormVisible,setIsShippingFormVisible,numberOfAddressLines]);if(!isDataReady){return null;}return React.createElement(Context.Provider,{value:value},children);};RegistrationProvider.defaultProps={formContainerRef:null,cartHasDirectShipItems:false,numberOfAddressLines:null};export default connect(RegistrationProvider);
17
+ setIsBaseFormSubmitted(false);setIsBillingFormSubmitted(false);setIsShippingFormSubmitted(false);setIsExtraFormSubmitted(false);setLocked(false);case 14:case"end":return _context.stop();}}},_callee);}));return function fn(){return _ref2.apply(this,arguments);};}();fn();/* eslint-disable react-hooks/exhaustive-deps */},[isBaseFormSubmitted,isBillingFormSubmitted,isShippingFormSubmitted,isExtraFormSubmitted,baseFormState.valid,billingFormState.valid,shippingFormState.valid,extraFormState.valid,isShippingFormVisible,submitRegistration]);/* eslint-enable react-hooks/exhaustive-deps */ /* eslint-disable react-hooks/exhaustive-deps */useEffect(function(){baseFormState.scrollToError();},[baseFormRequestErrors,billingFormRequestErrors,shippingFormRequestErrors,baseFormState.scrollToError]);/* eslint-enable react-hooks/exhaustive-deps */ /* eslint-disable react-hooks/exhaustive-deps */useEffect(function(){shippingFormState.setIgnoreErrors(!isShippingFormVisible);},[isShippingFormVisible]);/* eslint-enable react-hooks/exhaustive-deps */useEffect(function(){if(isLocked){LoadingProvider.setLoading(REGISTER_PATH);return;}LoadingProvider.unsetLoading(REGISTER_PATH);},[isLocked]);var value=useMemo(function(){return{supportedCountries:shopSettings.supportedCountries||[],customerAttributes:customerAttributes,userLocation:userLocation,defaultBaseFormState:defaultBaseFormState,defaultBillingFormState:defaultBillingFormState,defaultShippingFormState:defaultShippingFormState,defaultExtraFormState:defaultExtraFormState,baseFormValidationErrors:convertValidationErrors(baseFormState.validationErrors||baseFormRequestErrors||{}),billingFormValidationErrors:convertValidationErrors(billingFormState.validationErrors||billingFormRequestErrors||{}),shippingFormValidationErrors:convertValidationErrors(shippingFormState.validationErrors||shippingFormRequestErrors||{}),extraFormValidationErrors:convertValidationErrors(extraFormState.validationErrors||extraFormRequestErrors||{}),handleSubmit:handleSubmit,updateBaseForm:baseFormState.setValues,updateBillingForm:billingFormState.setValues,updateShippingForm:shippingFormState.setValues,updateExtraForm:extraFormState.setValues,isShippingAddressSelectionEnabled:isShippingAddressSelectionEnabled,isBillingAddressSelectionEnabled:isBillingAddressSelectionEnabled,isShippingFormVisible:isShippingFormVisible,setIsShippingFormVisible:setIsShippingFormVisible,numberOfAddressLines:numberOfAddressLines,registrationMode:registrationMode};},[shopSettings.supportedCountries,customerAttributes,userLocation,defaultBaseFormState,defaultBillingFormState,defaultShippingFormState,baseFormState.validationErrors,baseFormState.setValues,baseFormRequestErrors,billingFormState.validationErrors,billingFormState.setValues,billingFormRequestErrors,shippingFormState.validationErrors,shippingFormState.setValues,shippingFormRequestErrors,handleSubmit,defaultExtraFormState,extraFormState.setValues,extraFormState.validationErrors,extraFormRequestErrors,isShippingAddressSelectionEnabled,isBillingAddressSelectionEnabled,isShippingFormVisible,setIsShippingFormVisible,numberOfAddressLines,registrationMode]);if(!isDataReady){return null;}return React.createElement(Context.Provider,{value:value},children);};RegistrationProvider.defaultProps={formContainerRef:null,cartHasDirectShipItems:false,numberOfAddressLines:null};export default connect(RegistrationProvider);
@@ -1,2 +0,0 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{isIOSTheme}from'@shopgate/engage/core';import{StylePresets}from'@shopgate/engage/components/Form';var variables=themeConfig.variables;export var container=css({padding:"".concat(variables.gap.big,"px ").concat(variables.gap.big,"px 0"),display:'flex',flex:'0 0 auto',flexDirection:'column','@media(min-width: 768px)':{flexDirection:'row-reverse','> :not(:first-child)':{marginRight:variables.gap.big}}});export var containerItem=css({flexGrow:1,flexShrink:0,'@media(min-width: 768px)':{width:"calc(50% - ".concat(variables.gap.big,"px)")}});export var form=css(_extends({},StylePresets.OUTLINED_FORM_FIELDS,{' .registrationOptInMarketingOptIn':_extends({' .checkbox':_extends({},isIOSTheme()?{paddingBottom:0}:{})},!isIOSTheme()?{paddingTop:0,paddingBottom:variables.gap.big}:{})}));export var section=css({// marginBottom: variables.gap.big * 1.5,
2
- }).toString();export var shippingFormSection=css({paddingBottom:32}).toString();export var hidden=css({display:'none'}).toString();export var submitButtonContainer=css({margin:"0 ".concat(variables.gap.big,"px ").concat(variables.gap.big,"px"),'@media(min-width: 768px)':{width:"calc(50% - ".concat(variables.gap.big,"px)")}});export var submitButton=css({width:'100%'}).toString();