@shopgate/pwa-common 7.12.7-beta.1 → 7.20.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.js +6 -6
- package/actions/app/handleLink.js +7 -5
- package/actions/client/fetchClientInformation.js +1 -1
- package/actions/page/fetchPageConfig.js +2 -2
- package/actions/router/historyReplace.js +11 -1
- package/actions/user/getUser.js +1 -0
- package/actions/user/login.js +2 -2
- package/collections/AuthRoutes.js +3 -3
- package/collections/Configuration.js +3 -3
- package/collections/EmbeddedMedia.js +13 -3
- package/collections/PersistedReducers.js +2 -2
- package/collections/Redirects.js +3 -3
- package/collections/media-providers/MediaProvider.js +32 -4
- package/collections/media-providers/Vimeo.js +26 -7
- package/collections/media-providers/YouTube.js +10 -5
- package/collections/media-providers/style.js +2 -1
- package/components/Backdrop/index.js +11 -11
- package/components/Button/index.js +7 -7
- package/components/Checkbox/index.js +27 -14
- package/components/CountdownTimer/index.js +7 -7
- package/components/Drawer/index.js +13 -13
- package/components/Dropdown/index.js +5 -5
- package/components/Ellipsis/index.js +1 -1
- package/components/EmbeddedMedia/index.js +5 -5
- package/components/ErrorBoundary/index.js +5 -5
- package/components/Grid/components/Item/index.js +4 -4
- package/components/Grid/index.js +4 -4
- package/components/HtmlSanitizer/connector.js +9 -0
- package/components/HtmlSanitizer/index.js +11 -11
- package/components/HtmlSanitizer/spec.js +4 -4
- package/components/I18n/components/FormatPrice/index.js +2 -2
- package/components/I18n/components/I18nProvider/index.js +9 -9
- package/components/I18n/components/Translate/index.js +11 -7
- package/components/Icon/index.js +1 -1
- package/components/Image/index.js +9 -9
- package/components/Image/spec.js +2 -2
- package/components/InfiniteContainer/index.js +21 -21
- package/components/Input/components/DateInput.js +2 -2
- package/components/Input/components/MultiLineInput.js +10 -10
- package/components/Input/components/SimpleInput.js +27 -21
- package/components/KeyboardConsumer/index.js +7 -7
- package/components/Link/connector.js +1 -1
- package/components/Link/index.js +8 -5
- package/components/List/components/Item/index.js +1 -1
- package/components/List/index.js +1 -1
- package/components/Modal/style.js +1 -1
- package/components/Picker/components/List/index.js +1 -1
- package/components/Picker/components/Modal/index.js +7 -7
- package/components/Picker/index.js +19 -9
- package/components/Portal/index.js +15 -11
- package/components/ProductCharacteristics/helpers/index.js +1 -1
- package/components/ProductCharacteristics/index.js +27 -12
- package/components/RangeSlider/index.js +33 -24
- package/components/Route/RouteNotFound.js +3 -3
- package/components/Route/index.js +12 -5
- package/components/Router/index.js +18 -10
- package/components/ScannerContainer/index.js +3 -3
- package/components/Select/index.js +25 -15
- package/components/SelectBox/components/Item/index.js +5 -3
- package/components/SelectBox/index.js +17 -8
- package/components/Swiper/components/SwiperItem/spec.js +1 -1
- package/components/Swiper/index.js +3 -3
- package/components/Swiper/styles.js +4 -1
- package/components/Transition/index.js +4 -4
- package/components/Widgets/components/Widget/index.js +4 -4
- package/components/Widgets/components/WidgetGrid/index.js +5 -5
- package/components/Widgets/index.js +6 -6
- package/components/index.js +1 -2
- package/constants/Configuration.js +1 -1
- package/constants/Device.js +2 -2
- package/constants/Portals.js +2 -2
- package/helpers/config/mock.js +2 -2
- package/helpers/config/theme.js +2 -2
- package/helpers/dom/index.js +2 -1
- package/helpers/html/parseHTML.js +10 -3
- package/helpers/i18n/getNumberFormatter.js +1 -1
- package/helpers/i18n/getTranslator.js +10 -4
- package/helpers/i18n/index.js +1 -1
- package/helpers/i18n/mergeTranslations.js +1 -1
- package/helpers/portals/portalCollection.js +3 -3
- package/helpers/redux/shouldFetchData.js +1 -1
- package/helpers/style/index.js +2 -2
- package/package.json +5 -5
- package/providers/loading/index.js +24 -14
- package/providers/toast/index.js +10 -8
- package/reducers/page/index.js +1 -1
- package/reducers/router/index.js +1 -1
- package/selectors/client.js +9 -7
- package/streams/app.js +8 -2
- package/streams/main.js +1 -1
- package/streams/view.js +12 -0
- package/subscriptions/error.js +4 -4
- package/subscriptions/helpers/handleLinks.js +2 -2
- package/subscriptions/menu.js +4 -2
- package/subscriptions/router.js +6 -6
- package/subscriptions/user.js +1 -1
package/App.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import _regeneratorRuntime from"@babel/runtime/regenerator";function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}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 _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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);}import React,{Component}from'react';import PropTypes from'prop-types';import{Provider}from'react-redux';import{CookiesProvider}from'react-cookie';import{loadCustomStyles}from'@shopgate/engage/styles';import ErrorBoundary from"./components/ErrorBoundary";import{appDidStart}from"./action-creators/app";import I18n from"./components/I18n";import{getIsSessionExpired}from"./selectors/user";import logout from"./actions/user/logout";/**
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}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 _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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);}import React,{Component}from'react';import PropTypes from'prop-types';import{Provider}from'react-redux';import{CookiesProvider}from'react-cookie';import{loadCustomStyles}from'@shopgate/engage/styles';import ErrorBoundary from"./components/ErrorBoundary";import{appDidStart}from"./action-creators/app";import I18n from"./components/I18n";import{getIsSessionExpired}from"./selectors/user";import logout from"./actions/user/logout";/**
|
|
2
2
|
* The application component.
|
|
3
3
|
* It sets up the store and the react router. The router's children (routes) come from
|
|
4
4
|
* the theme's Main.jsx file which uses this component as the root element.
|
|
5
5
|
* @returns {JSX}
|
|
6
|
-
*/var App=/*#__PURE__*/function(_Component){
|
|
6
|
+
*/var App=/*#__PURE__*/function(_Component){function App(){_classCallCheck(this,App);return _callSuper(this,App,arguments);}_inherits(App,_Component);return _createClass(App,[{key:"componentDidMount",value:/**
|
|
7
7
|
* Registers the component for the native events and fires the onload AppCommand.
|
|
8
|
-
*/
|
|
8
|
+
*/function componentDidMount(){var _this2=this;/**
|
|
9
9
|
* Async helper function that performs optional steps before appDidStart action is dispatched
|
|
10
|
-
*/var performAppStart=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)
|
|
11
|
-
console.error('AppStartLogout failed',_context.t0);case 9:
|
|
10
|
+
*/var performAppStart=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(!getIsSessionExpired(_this2.props.store.getState())){_context.next=9;break;}_context.prev=1;_context.next=4;return _this2.props.store.dispatch(logout(undefined,true));case 4:_context.next=9;break;case 6:_context.prev=6;_context.t0=_context["catch"](1);// Noting to do here
|
|
11
|
+
console.error('AppStartLogout failed',_context.t0);case 9:_this2.props.store.dispatch(appDidStart("".concat(window.location.pathname).concat(window.location.search)));case 10:case"end":return _context.stop();}},_callee,null,[[1,6]]);}));return function performAppStart(){return _ref.apply(this,arguments);};}();performAppStart();loadCustomStyles();}/**
|
|
12
12
|
* Renders the component.
|
|
13
13
|
* @returns {JSX}
|
|
14
|
-
*/},{key:"render",value:function render(){return React.createElement(CookiesProvider,null,React.createElement(ErrorBoundary,{key:"error.root",store:this.props.store,isRoot:true},React.createElement(Provider,{store:this.props.store},React.createElement(I18n.Provider,null,React.createElement("div",null,this.props.children)))));}}]);
|
|
14
|
+
*/},{key:"render",value:function render(){return React.createElement(CookiesProvider,null,React.createElement(ErrorBoundary,{key:"error.root",store:this.props.store,isRoot:true},React.createElement(Provider,{store:this.props.store},React.createElement(I18n.Provider,null,React.createElement("div",null,this.props.children)))));}}]);}(Component);export default App;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import _regeneratorRuntime from"@babel/runtime/regenerator";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 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{logger}from'@shopgate/pwa-core/helpers';import{DEEPLINK_CART_ADD_PRODUCT_PATTERN}from'@shopgate/pwa-common-commerce/cart/constants';import fetchProduct from'@shopgate/pwa-common-commerce/product/actions/fetchProduct';import{historyPush,historyReset}from"../router";import{INDEX_PATH_DEEPLINK,INDEX_PATH}from"../../constants/RoutePaths";/**
|
|
2
2
|
* @param {Object} payload The link payload.
|
|
3
|
-
* @param {boolean}
|
|
3
|
+
* @param {boolean} allowExternalLinks Wether the function should open external links or should try
|
|
4
|
+
* to convert them to internal links
|
|
4
5
|
* @return {Function}
|
|
5
|
-
*/export default function handleLink(payload){var
|
|
6
|
-
link=String(link);if(!link.startsWith('http')){_context.next=11;break;}if(!
|
|
7
|
-
pathname=link.replace(/^(.*:)(\/\/)?/,'/');
|
|
6
|
+
*/export default function handleLink(payload){var allowExternalLinks=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var link,pathname,_ref2,_pathname$split3,_pathname$split4,productId;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:link=payload.link;if(link){_context.next=3;break;}return _context.abrupt("return");case 3:// cast to string
|
|
7
|
+
link=String(link);if(!link.startsWith('http')){_context.next=11;break;}if(!allowExternalLinks){_context.next=8;break;}dispatch(historyPush({pathname:link}));return _context.abrupt("return");case 8:try{_ref2=new URL(link);pathname=_ref2.pathname;}catch(linkParseError){logger.error("Could not parse link ".concat(link),linkParseError);}_context.next=13;break;case 11:// Remove the deeplink protocol from the link.
|
|
8
|
+
pathname=link.replace(/^(.*:)(\/\/)?/,'/');if(!pathname.startsWith('/')){// Take care that pathname starts with a slash. Otherwise routing can break
|
|
9
|
+
pathname="/".concat(pathname);}case 13:if(!(!pathname||pathname===INDEX_PATH||pathname.startsWith(INDEX_PATH_DEEPLINK))){_context.next=16;break;}/**
|
|
8
10
|
* Special treatment for the index page. To avoid multiple index pages within the history,
|
|
9
11
|
* the parsed link helper will only emit the openLink events for the link to inform the
|
|
10
12
|
* streams, but not open a real page. Additionally the history is reset.
|
|
11
|
-
*/dispatch(historyReset());return _context.abrupt("return");case
|
|
13
|
+
*/dispatch(historyReset());return _context.abrupt("return");case 16:if(!pathname.includes(DEEPLINK_CART_ADD_PRODUCT_PATTERN.split('/')[1])){_context.next=20;break;}_pathname$split3=pathname.split('/'),_pathname$split4=_slicedToArray(_pathname$split3,3),productId=_pathname$split4[2];_context.next=20;return dispatch(fetchProduct(decodeURIComponent(productId)));case 20:dispatch(historyPush({pathname:pathname}));case 21:case"end":return _context.stop();}},_callee);}));return function(_x){return _ref.apply(this,arguments);};}());}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{hasSGJavaScriptBridge,defaultClientInformation,getWebStorageEntry}from'@shopgate/pwa-core';import{requestClientInformation,receiveClientInformation,errorClientInformation}from"../../action-creators/client";/**
|
|
2
2
|
* Requests the client information from the web storage.
|
|
3
3
|
* @return {Function} A redux thunk.
|
|
4
|
-
*/function fetchClientInformation(){return function(dispatch){dispatch(requestClientInformation());if(!hasSGJavaScriptBridge()){dispatch(receiveClientInformation(defaultClientInformation));return;}getWebStorageEntry({name:'clientInformation'}).then(function(response){return dispatch(receiveClientInformation(response.value));})["catch"](function(){dispatch(errorClientInformation());});};}export default fetchClientInformation;
|
|
4
|
+
*/function fetchClientInformation(){return function(dispatch){dispatch(requestClientInformation());if(!hasSGJavaScriptBridge()){dispatch(receiveClientInformation(defaultClientInformation));return Promise.resolve({aga:0,value:defaultClientInformation});}var request=getWebStorageEntry({name:'clientInformation'});request.then(function(response){return dispatch(receiveClientInformation(response.value));})["catch"](function(){dispatch(errorClientInformation());});return request;};}export default fetchClientInformation;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{PipelineRequest}from'@shopgate/pwa-core';import{getDeviceTypeForCms}from'@shopgate/engage/core';import{SHOPGATE_CMS_GET_PAGE_CONFIG}from"../../constants/Pipelines";import{requestPageConfig,receivePageConfig,errorPageConfig}from"../../action-creators/page";import{shouldFetchData,mutable}from"../../helpers/redux";import{getPageConfigById}from"../../selectors/page";/**
|
|
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{PipelineRequest}from'@shopgate/pwa-core';import{getDeviceTypeForCms}from'@shopgate/engage/core';import{hasNewServices}from'@shopgate/engage/core/helpers';import{SHOPGATE_CMS_GET_PAGE_CONFIG}from"../../constants/Pipelines";import{requestPageConfig,receivePageConfig,errorPageConfig}from"../../action-creators/page";import{shouldFetchData,mutable}from"../../helpers/redux";import{getPageConfigById}from"../../selectors/page";/**
|
|
2
2
|
* Retrieves the config for a page.
|
|
3
3
|
* @param {string} pageId The ID of the page to request.
|
|
4
4
|
* @return {Function} The dispatched action.
|
|
5
|
-
*/function fetchPageConfig(pageId){return function(dispatch,getState){var state=getState();var pageConfig=getPageConfigById(state,{pageId:pageId});if(!shouldFetchData(pageConfig)){return Promise.resolve(null);}var deviceTypeOfCmsPage=getDeviceTypeForCms();dispatch(requestPageConfig(pageId));var request=new PipelineRequest(SHOPGATE_CMS_GET_PAGE_CONFIG).setInput({pageId:pageId,deviceType:deviceTypeOfCmsPage}).dispatch();request.then(function(result){dispatch(receivePageConfig(pageId,result));})["catch"](function(error){dispatch(errorPageConfig(pageId,error.code));});return request;};}/** @mixes {MutableFunction} */export default mutable(fetchPageConfig);
|
|
5
|
+
*/function fetchPageConfig(pageId){return function(dispatch,getState){var state=getState();var pageConfig=getPageConfigById(state,{pageId:pageId});if(!shouldFetchData(pageConfig)){return Promise.resolve(null);}var deviceTypeOfCmsPage=getDeviceTypeForCms();dispatch(requestPageConfig(pageId));var request=new PipelineRequest(SHOPGATE_CMS_GET_PAGE_CONFIG).setInput(_extends({pageId:pageId},hasNewServices()?{deviceType:deviceTypeOfCmsPage}:null)).dispatch();request.then(function(result){dispatch(receivePageConfig(pageId,result));})["catch"](function(error){dispatch(errorPageConfig(pageId,error.code));});return request;};}/** @mixes {MutableFunction} */export default mutable(fetchPageConfig);
|
|
@@ -1,5 +1,15 @@
|
|
|
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);}import{ACTION_REPLACE}from'@virtuous/conductor';import{navigate}from"../../action-creators/router";import{mutable}from"../../helpers/redux";/**
|
|
2
2
|
* @mixes {MutableFunction}
|
|
3
3
|
* @param {Object} params The history params.
|
|
4
|
+
* @param {Object} [options={}] Additional options for the action
|
|
5
|
+
* @param {boolean} [options.remountRoute=true] When set to "true", the target route will be forced
|
|
6
|
+
* to remount.
|
|
4
7
|
* @return {Function} The dispatched action.
|
|
5
|
-
*/export var historyReplace=mutable(function(params){return function(dispatch){dispatch(navigate(_extends({},params,{
|
|
8
|
+
*/export var historyReplace=mutable(function(params){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return function(dispatch){dispatch(navigate(_extends({},params,{},(options===null||options===void 0?void 0:options.remountRoute)!==false&&{state:_extends({},params.state,{/**
|
|
9
|
+
* When a route is "replaced" the router doesn't assign a new route id to the old route
|
|
10
|
+
* stack entry. This can cause issues when a route is replaced by itself, since the content
|
|
11
|
+
* will not remount out of the box.
|
|
12
|
+
*
|
|
13
|
+
* When the "replaceRouteId" state prop is injected, the Route component performs logic
|
|
14
|
+
* to enforce re-remounting routes which where replaced by itself.
|
|
15
|
+
*/replaceRouteId:Math.random().toString(36).substring(2,7)})},{action:ACTION_REPLACE})));};});
|
package/actions/user/getUser.js
CHANGED
package/actions/user/login.js
CHANGED
|
@@ -6,11 +6,11 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){
|
|
|
6
6
|
* @param {string} redirect The location to redirect to when logged in.
|
|
7
7
|
* @param {string} strategy basic or facebook, amazon, etc
|
|
8
8
|
* @return {Function} A redux thunk.
|
|
9
|
-
*/function login(parameters,redirect){var strategy=arguments.length>2&&arguments[2]!==undefined?arguments[2]:DEFAULT_LOGIN_STRATEGY;return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var _ref2,recaptchaEnabled,googleCloudSiteKey,recaptchaToken,request;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)
|
|
9
|
+
*/function login(parameters,redirect){var strategy=arguments.length>2&&arguments[2]!==undefined?arguments[2]:DEFAULT_LOGIN_STRATEGY;return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var _ref2,recaptchaEnabled,googleCloudSiteKey,recaptchaToken,request;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_ref2=(appConfig===null||appConfig===void 0?void 0:appConfig.recaptcha)||{},recaptchaEnabled=_ref2.enabled,googleCloudSiteKey=_ref2.googleCloudSiteKey;dispatch(requestLogin(parameters.login,parameters.password,strategy));if(!(recaptchaEnabled&&googleCloudSiteKey)){_context.next=13;break;}_context.prev=3;_context.next=6;return new Promise(function(resolve){return window.grecaptcha.enterprise.ready(resolve);});case 6:_context.next=8;return window.grecaptcha.enterprise.execute(googleCloudSiteKey,{action:'login'});case 8:recaptchaToken=_context.sent;_context.next=13;break;case 11:_context.prev=11;_context.t0=_context["catch"](3);case 13:request=new PipelineRequest(SHOPGATE_USER_LOGIN_USER).setTrusted().setErrorBlacklist([EINVALIDCALL,ELEGACYSGCONNECT,EINCOMPLETELOGIN]).setInput({strategy:strategy,parameters:_extends({},parameters,{},recaptchaToken?{recaptchaToken:recaptchaToken}:null)}).dispatch();request.then(function(result){var success=result.success,messages=result.messages,sessionLifetimeInSeconds=result.sessionLifetimeInSeconds;if(success){dispatch(successLogin(redirect,strategy,sessionLifetimeInSeconds));}else{dispatch(errorLogin(messages));}})["catch"](function(error){var code=error.code;if(code===EINVALIDCALL){/**
|
|
10
10
|
* This code is thrown when the login request failed, because the user was already logged
|
|
11
11
|
* in. In that situation the success action can also dispatch to trigger the necessary
|
|
12
12
|
* processes which has to happen after a successful login.
|
|
13
13
|
*/dispatch(successLogin(redirect,strategy));}else if(code===ELEGACYSGCONNECT){/**
|
|
14
14
|
* The app is connected to the shop system via the legacy shopgate connect. Login via
|
|
15
15
|
* the shop system credentials failed and further steps are necessary to login the user.
|
|
16
|
-
*/dispatch(errorLegacyConnectRegister());dispatch(errorLogin([],ELEGACYSGCONNECT));}else{dispatch(errorLogin([],code));}});return _context.abrupt("return",request);case 16:case"end":return _context.stop();}}
|
|
16
|
+
*/dispatch(errorLegacyConnectRegister());dispatch(errorLogin([],ELEGACYSGCONNECT));}else{dispatch(errorLogin([],code));}});return _context.abrupt("return",request);case 16:case"end":return _context.stop();}},_callee,null,[[3,11]]);}));return function(_x){return _ref.apply(this,arguments);};}());}/** @mixes {MutableFunction} */export default mutable(login);
|
|
@@ -6,7 +6,7 @@ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimi
|
|
|
6
6
|
* Finds a particular protected route.
|
|
7
7
|
* @param {string} pattern The pattern to find.
|
|
8
8
|
* @return {string|null}
|
|
9
|
-
*/_createClass(AuthRoutes,[{key:"get",value:function get(pattern){return this.routes.get(pattern)||null;}/**
|
|
9
|
+
*/return _createClass(AuthRoutes,[{key:"get",value:function get(pattern){return this.routes.get(pattern)||null;}/**
|
|
10
10
|
* Returns all protected routes.
|
|
11
11
|
* @return {Map}
|
|
12
12
|
*/},{key:"getAll",value:function getAll(){return this.routes;}/**
|
|
@@ -28,7 +28,7 @@ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimi
|
|
|
28
28
|
* If we didn't find a direct match then we need to match
|
|
29
29
|
* the given location against the protected patters.
|
|
30
30
|
*/if(!protector){// Get the protected patterns as an array.
|
|
31
|
-
var patterns=Array.from(this.routes.keys());var _location$
|
|
31
|
+
var patterns=Array.from(this.routes.keys());var _location$split3=location.split('?'),_location$split4=_slicedToArray(_location$split3,1),locationWithoutParams=_location$split4[0];// Loop over the patterns until a match is found.
|
|
32
32
|
patterns.some(function(pattern){// Check for a match.
|
|
33
33
|
var match=_this.matcher(pattern)(locationWithoutParams);// Match found, set the protector.
|
|
34
|
-
if(match){protector=_this.routes.get(pattern);}return match;});}return protector;}}]);
|
|
34
|
+
if(match){protector=_this.routes.get(pattern);}return match;});}return protector;}}]);}();export default new AuthRoutes();
|
|
@@ -7,7 +7,7 @@ function _classCallCheck(instance,Constructor){if(!(instance instanceof Construc
|
|
|
7
7
|
* @param {*} key config key
|
|
8
8
|
* @param {*} defaultValue defaultValue
|
|
9
9
|
* @returns {*|undefined}
|
|
10
|
-
*/_createClass(Configuration,[{key:"get",value:function get(key,defaultValue){return this.store.get(key)||defaultValue;}/**
|
|
10
|
+
*/return _createClass(Configuration,[{key:"get",value:function get(key,defaultValue){return this.store.get(key)||defaultValue;}/**
|
|
11
11
|
* Sets a configuration.
|
|
12
12
|
* @param {*} key key
|
|
13
13
|
* @param {*} value value
|
|
@@ -17,5 +17,5 @@ function _classCallCheck(instance,Constructor){if(!(instance instanceof Construc
|
|
|
17
17
|
* @param {*} key key
|
|
18
18
|
* @param {Function} updater function to update value
|
|
19
19
|
* @returns {Configuration}
|
|
20
|
-
*/},{key:"update",value:function update(key,updater){if(typeof updater!=='function'){logGroup('CONFIGURATION%c updater is not function',{key:key},'#e0061e');return this;}var prevValue=this.store.get(key);var newValue=updater(this.store.get(key));// eslint-disable-next-line extra-rules/no-single-line-objects
|
|
21
|
-
logGroup('CONFIGURATION%c changed',{key:key,prevValue:prevValue,newValue:newValue},'#069215');return this.set(key,newValue);}}]);
|
|
20
|
+
*/},{key:"update",value:function update(key,updater){if(!this.store.has(key)){logGroup('CONFIGURATION%c not found',{key:key},'#e0061e');return this;}if(typeof updater!=='function'){logGroup('CONFIGURATION%c updater is not function',{key:key},'#e0061e');return this;}var prevValue=this.store.get(key);var newValue=updater(this.store.get(key));// eslint-disable-next-line extra-rules/no-single-line-objects
|
|
21
|
+
logGroup('CONFIGURATION%c changed',{key:key,prevValue:prevValue,newValue:newValue},'#069215');return this.set(key,newValue);}}]);}();/** @type {Configuration} */export default new Configuration();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
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;}/* eslint-disable extra-rules/potential-point-free */ /**
|
|
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 _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;}/* eslint-disable extra-rules/potential-point-free */ /**
|
|
2
2
|
* Class to maintain embedded media within DOM containers.
|
|
3
3
|
*/var EmbeddedMedia=/*#__PURE__*/function(){/**
|
|
4
4
|
* Constructor
|
|
5
5
|
*/function EmbeddedMedia(){_classCallCheck(this,EmbeddedMedia);this.providers=new Set();}/**
|
|
6
6
|
* Add a provider for embedded media.
|
|
7
7
|
* @param {Object} provider A provider instance.
|
|
8
|
-
*/_createClass(EmbeddedMedia,[{key:"addProvider",value:function addProvider(provider){this.providers.add(provider);}/**
|
|
8
|
+
*/return _createClass(EmbeddedMedia,[{key:"addProvider",value:function addProvider(provider){this.providers.add(provider);}/**
|
|
9
9
|
* Remove a provider for embedded media.
|
|
10
10
|
* @param {Object} provider A provider instance.
|
|
11
11
|
*/},{key:"removeProvider",value:function removeProvider(provider){this.providers["delete"](provider);}/**
|
|
@@ -16,8 +16,18 @@ function _classCallCheck(instance,Constructor){if(!(instance instanceof Construc
|
|
|
16
16
|
* embedded media is unmounted.
|
|
17
17
|
* @param {ParentNode} container A DOM container.
|
|
18
18
|
*/},{key:"remove",value:function remove(container){this.providers.forEach(function(provider){provider.remove(container);});}/**
|
|
19
|
+
* Searches for embedded media and replaces it with a placeholder element when required cookie
|
|
20
|
+
* consent is not accepted.
|
|
21
|
+
* Should be invoked before container content is added to the DOM to fulfill all regulations.
|
|
22
|
+
* @param {ParentNode} container A DOM container.
|
|
23
|
+
* @param {Object} [cookieConsentSettings] Additional settings related to cookie consent.
|
|
24
|
+
* @param {boolean} [cookieConsentSettings.comfortCookiesAccepted] Whether comfort cookies
|
|
25
|
+
* are accepted.
|
|
26
|
+
* @param {boolean} [cookieConsentSettings.statisticsCookiesAccepted] Whether statistics cookies
|
|
27
|
+
* are accepted.
|
|
28
|
+
*/},{key:"handleCookieConsent",value:function handleCookieConsent(container){var cookieConsentSettings=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var cookieConsent=_extends({comfortCookiesAccepted:false,statisticsCookiesAccepted:false},cookieConsentSettings);this.providers.forEach(function(provider){if(provider.handleCookieConsent){provider.handleCookieConsent(container,cookieConsent);}});}/**
|
|
19
29
|
* Stops all playing media within the DOM containers.
|
|
20
30
|
*/},{key:"stop",value:function stop(){this.providers.forEach(function(provider){provider.stop();});}/**
|
|
21
31
|
* Check if we have media providers with not-ready SDK
|
|
22
32
|
* @returns {boolean}
|
|
23
|
-
*/},{key:"getHasPendingProviders",value:function getHasPendingProviders(){var hasPendingProviders=false;this.providers.forEach(function(provider){if(provider.isPending){hasPendingProviders=true;}});return hasPendingProviders;}}]);
|
|
33
|
+
*/},{key:"getHasPendingProviders",value:function getHasPendingProviders(){var hasPendingProviders=false;this.providers.forEach(function(provider){if(provider.isPending){hasPendingProviders=true;}});return hasPendingProviders;}}]);}();export default new EmbeddedMedia();/* eslint-enable extra-rules/potential-point-free */
|
|
@@ -5,7 +5,7 @@ function _classCallCheck(instance,Constructor){if(!(instance instanceof Construc
|
|
|
5
5
|
*/function PersistedReducers(){_classCallCheck(this,PersistedReducers);this.reducers=[];}/**
|
|
6
6
|
* Returns all reducers.
|
|
7
7
|
* @return {Array}
|
|
8
|
-
*/_createClass(PersistedReducers,[{key:"getAll",value:function getAll(){return this.reducers;}/**
|
|
8
|
+
*/return _createClass(PersistedReducers,[{key:"getAll",value:function getAll(){return this.reducers;}/**
|
|
9
9
|
* Sets a new reducers to be persisted.
|
|
10
10
|
* @param {string|Array} reducer The name of the reducer to persist.
|
|
11
11
|
* @return {PersistedReducers}
|
|
@@ -13,4 +13,4 @@ function _classCallCheck(instance,Constructor){if(!(instance instanceof Construc
|
|
|
13
13
|
* Removes a reducer from the list of persisted reducers.
|
|
14
14
|
* @param {string} reducer The name of the reducer to remove.
|
|
15
15
|
* @return {PersistedReducers}
|
|
16
|
-
*/},{key:"remove",value:function remove(reducer){this.reducers=this.reducers.filter(function(red){return red!==reducer;});return this;}}]);
|
|
16
|
+
*/},{key:"remove",value:function remove(reducer){this.reducers=this.reducers.filter(function(red){return red!==reducer;});return this;}}]);}();export default new PersistedReducers();
|
package/collections/Redirects.js
CHANGED
|
@@ -7,7 +7,7 @@ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimi
|
|
|
7
7
|
* @param {string} pathname The pathname to lookup.
|
|
8
8
|
* @private
|
|
9
9
|
* @returns {string|Function|Promise|null}
|
|
10
|
-
*/_createClass(Redirects,[{key:"get",value:function get(pathname){return this.redirects.get(pathname)||null;}/**
|
|
10
|
+
*/return _createClass(Redirects,[{key:"get",value:function get(pathname){return this.redirects.get(pathname)||null;}/**
|
|
11
11
|
* Returns the redirect for a passed pathname.
|
|
12
12
|
* @param {string} pathname The pathname to check.
|
|
13
13
|
* @return {string|Function|Promise|null}
|
|
@@ -18,7 +18,7 @@ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimi
|
|
|
18
18
|
* If we didn't find a direct match then we need to match
|
|
19
19
|
* the given pathname against the protected patters.
|
|
20
20
|
*/if(!redirect){// Get the protected patterns as an array.
|
|
21
|
-
var patterns=Array.from(this.redirects.keys());var _pathname$
|
|
21
|
+
var patterns=Array.from(this.redirects.keys());var _pathname$split3=pathname.split('?'),_pathname$split4=_slicedToArray(_pathname$split3,1),withoutParams=_pathname$split4[0];// Loop over the patterns until a match is found.
|
|
22
22
|
var patternMatch=patterns.find(function(pattern){return!!_this.matcher(pattern)(withoutParams);});// Match found, set the redirect.
|
|
23
23
|
if(patternMatch){redirect=this.redirects.get(patternMatch);}}return redirect;}/**
|
|
24
24
|
* @typedef RedirectExtendedData
|
|
@@ -43,4 +43,4 @@ var matcherResult=this.matcher(patternMatch)(url);result.matcher=patternMatch;re
|
|
|
43
43
|
*/},{key:"set",value:function set(){var from=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var force=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(!from||!to){return;}if(!force&&this.redirects.has(from)){return;}this.redirects.set(from,to);}/* eslint-disable extra-rules/potential-point-free */ /**
|
|
44
44
|
* Removes a specified element from the internal "redirects" Map object.
|
|
45
45
|
* @param {string} pathname The pathname to remove.
|
|
46
|
-
*/},{key:"unset",value:function unset(pathname){this.redirects["delete"](pathname);}/* eslint-enable extra-rules/potential-point-free */}]);
|
|
46
|
+
*/},{key:"unset",value:function unset(pathname){this.redirects["delete"](pathname);}/* eslint-enable extra-rules/potential-point-free */}]);}();export default new Redirects();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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;}import{logger}from'@shopgate/
|
|
1
|
+
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;}import{i18n,logger}from'@shopgate/engage/core/helpers';import{PRIVACY_SETTINGS_PATTERN}from'@shopgate/engage/tracking/constants';import{isRelativePosition,isAbsolutePosition}from"../../helpers/dom";import styles from"./style";var consentMessageIcon="\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox=\"0 0 110 84\"\n version=\"1.1\"\n class=\"".concat(styles.consentIcon,"\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g transform=\"matrix(1,0,0,1,-24.6099,-41.8178)\">\n <path d=\"M50.303,68.639L104.088,98.668L56.288,125.172C55.039,125.865 53.518,125.845 52.288,125.12C51.058,124.396 50.303,123.075 50.303,121.648L50.303,68.639ZM50.303,54.702L50.303,45.855C50.303,44.425 51.059,43.102 52.292,42.376C53.524,41.651 55.048,41.631 56.298,42.324C71.141,50.554 109.492,71.82 124.676,80.239C125.95,80.945 126.741,82.288 126.741,83.745C126.741,85.203 125.95,86.545 124.676,87.252L116.612,91.724L50.303,54.702Z\" />\n <g transform=\"matrix(0.944597,0.527391,-0.487489,0.873129,45.7069,-42.8282)\">\n <path d=\"M139,89C139,87.344 137.757,86 136.227,86L26.773,86C25.243,86 24,87.344 24,89C24,90.656 25.243,92 26.773,92L136.227,92C137.757,92 139,90.656 139,89Z\" />\n </g>\n </g>\n </svg>");/* eslint-disable class-methods-use-this */ /**
|
|
2
2
|
* The MediaProvider base class.
|
|
3
3
|
*/var MediaProvider=/*#__PURE__*/function(){/**
|
|
4
4
|
* Constructor.
|
|
@@ -6,16 +6,44 @@ function _classCallCheck(instance,Constructor){if(!(instance instanceof Construc
|
|
|
6
6
|
* Callback for when Provider script is loaded
|
|
7
7
|
* @callback
|
|
8
8
|
* @abstract
|
|
9
|
-
*/
|
|
9
|
+
*/return _createClass(MediaProvider,[{key:"onScriptLoaded",value:function onScriptLoaded(){logger.error('MediaProvider.onScriptLoaded() needs to be implemented within an inheriting class');}/**
|
|
10
|
+
* Callback to retrieve a list of media containers
|
|
11
|
+
* @callback
|
|
12
|
+
* @abstract
|
|
13
|
+
*/},{key:"getMediaContainers",value:function getMediaContainers(){logger.error('MediaProvider.getMediaContainers() needs to be implemented within an inheriting class');}/**
|
|
10
14
|
* Optimizes video container to make it responsive.
|
|
11
15
|
* @param {Element} container A DOM container.
|
|
12
16
|
* @returns {MediaProvider}
|
|
13
17
|
*/},{key:"responsify",value:function responsify(container){// Remove fixed dimensions from the container.
|
|
14
18
|
container.removeAttribute('height');container.removeAttribute('width');if(isRelativePosition(container.parentNode)&&isAbsolutePosition(container)){// Assume responsive embed code
|
|
15
19
|
container.parentNode.removeAttribute('style');}// Create the wrapper and apply styling.
|
|
16
|
-
var wrapper=document.createElement('div');wrapper.className=styles;// Add the wrapper right before the container into the DOM.
|
|
20
|
+
var wrapper=document.createElement('div');wrapper.className=styles.responsiveContainer;// Add the wrapper right before the container into the DOM.
|
|
17
21
|
container.parentNode.insertBefore(wrapper,container);// Move the container into the wrapper.
|
|
18
22
|
wrapper.appendChild(container);return this;}/**
|
|
23
|
+
* Searches for embedded media and replaces it with a placeholder element when comfort cookie
|
|
24
|
+
* consent is not accepted.
|
|
25
|
+
*
|
|
26
|
+
* Should be called before media container / markup is mounted to the DOM.
|
|
27
|
+
* @param {ParentNode} container A DOM container.
|
|
28
|
+
* @param {Object} [cookieConsentSettings] Additional settings related to cookie consent.
|
|
29
|
+
* @param {boolean} [cookieConsentSettings.comfortCookiesAccepted] Whether comfort cookies
|
|
30
|
+
* are accepted.
|
|
31
|
+
* @param {boolean} [cookieConsentSettings.statisticsCookiesAccepted] Whether statistics cookies
|
|
32
|
+
* are accepted.
|
|
33
|
+
* @returns {MediaProvider}
|
|
34
|
+
*/},{key:"handleCookieConsent",value:function handleCookieConsent(container){var _this=this;var cookieConsentSettings=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var iframes=this.getMediaContainers(container);if(!iframes.length||cookieConsentSettings.comfortCookiesAccepted!==false){return this;}iframes.forEach(function(iframe){// Add responsive container around iframes
|
|
35
|
+
_this.responsify(iframe);// Select the container and clear its content
|
|
36
|
+
var responsiveContainer=iframe.parentNode;responsiveContainer.textContent=null;// Add the consent message element to the container
|
|
37
|
+
_this.injectCookieConsentMessage(responsiveContainer);});return this;}/**
|
|
38
|
+
* Injects a cookie consent message element into a container
|
|
39
|
+
* @param {Element} container A DOM container.
|
|
40
|
+
* @returns {MediaProvider}
|
|
41
|
+
*/},{key:"injectCookieConsentMessage",value:function injectCookieConsentMessage(container){// Create the wrapper for the message element
|
|
42
|
+
var messageWrapper=document.createElement('div');messageWrapper.classList.add(styles.consentContainer,'common__media-provider_cookie-consent-message-container');// Add an SVG icon (implemented this way, since there where issues with document.createElement)
|
|
43
|
+
messageWrapper.innerHTML=consentMessageIcon;// Create the main message and add it to the wrapper
|
|
44
|
+
var message=document.createElement('span');message.classList.add('common__media-provider_cookie-consent-message-container_message');message.innerHTML=i18n.text('htmlSanitizer.videoCookieConsent.message');messageWrapper.appendChild(message);// Create the link and add it to the wrapper
|
|
45
|
+
var link=document.createElement('a');link.classList.add(styles.consentLink,'common__media-provider_cookie-consent-message-container_link');link.href=PRIVACY_SETTINGS_PATTERN;link.innerHTML=i18n.text('htmlSanitizer.videoCookieConsent.link');messageWrapper.appendChild(link);// Add the wrapper to the container
|
|
46
|
+
container.appendChild(messageWrapper);return this;}/**
|
|
19
47
|
* Add a DOM container with embedded videos.
|
|
20
48
|
* @param {NodeList} container A DOM container.
|
|
21
49
|
* @returns {MediaProvider}
|
|
@@ -26,4 +54,4 @@ wrapper.appendChild(container);return this;}/**
|
|
|
26
54
|
*/},{key:"remove",value:function remove(container){this.containers["delete"](container);return this;}/**
|
|
27
55
|
* Stops all playing videos within the DOM containers.
|
|
28
56
|
* @returns {MediaProvider}
|
|
29
|
-
*/},{key:"stop",value:function stop(){logger.error('MediaProvider.stop() needs to be implemented within an inheriting class');return this;}}]);
|
|
57
|
+
*/},{key:"stop",value:function stop(){logger.error('MediaProvider.stop() needs to be implemented within an inheriting class');return this;}}]);}();export default MediaProvider;/* eslint-enable class-methods-use-this */
|
|
@@ -1,11 +1,15 @@
|
|
|
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 _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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);}import MediaProvider from"./MediaProvider"
|
|
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 _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _get(target,property,receiver){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get;}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(receiver);}return desc.value;};}return _get(target,property,receiver||target);}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break;}return object;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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);}import MediaProvider from"./MediaProvider";/* eslint-disable class-methods-use-this */var scriptUrl='https://player.vimeo.com/api/player.js';/**
|
|
2
2
|
* The Vimeo media provider class.
|
|
3
|
-
*/var VimeoMediaProvider=/*#__PURE__*/function(_MediaProvider){
|
|
3
|
+
*/var VimeoMediaProvider=/*#__PURE__*/function(_MediaProvider){/**
|
|
4
4
|
* Constructor.
|
|
5
|
-
*/function VimeoMediaProvider(){var
|
|
6
|
-
|
|
5
|
+
*/function VimeoMediaProvider(){var _this2;_classCallCheck(this,VimeoMediaProvider);_this2=_callSuper(this,VimeoMediaProvider);// Need to check Vimeo.Player presence later
|
|
6
|
+
_this2.isPending=true;_this2.remoteScriptUrl=scriptUrl;_this2.deferred=[];return _this2;}/**
|
|
7
|
+
* Retrieves a list of media containers for Vimeo.
|
|
8
|
+
* @param {ParentNode} container A DOM container that may contain Vimeo iframes.
|
|
9
|
+
* @returns {NodeListOf<Element>}
|
|
10
|
+
*/_inherits(VimeoMediaProvider,_MediaProvider);return _createClass(VimeoMediaProvider,[{key:"getMediaContainers",value:function getMediaContainers(container){return container.querySelectorAll('iframe[src*="vimeo.com"]');}/**
|
|
7
11
|
* @inheritDoc
|
|
8
|
-
*/
|
|
12
|
+
*/},{key:"onScriptLoaded",value:function onScriptLoaded(){var _this3=this;this.isPending=false;if(this.deferred.length){this.deferred.forEach(function(container){_this3.add(container);});this.deferred=[];}}/**
|
|
9
13
|
* Check if the Provider script to be loaded externally is finished loading
|
|
10
14
|
* @returns {boolean}
|
|
11
15
|
*/},{key:"checkScriptLoadingStatus",value:function checkScriptLoadingStatus(){if(this.isPending&&typeof window.Vimeo!=='undefined'){this.isPending=false;}return!this.isPending;}/**
|
|
@@ -13,8 +17,23 @@ _this.isPending=true;_this.remoteScriptUrl=scriptUrl;_this.deferred=[];return _t
|
|
|
13
17
|
* @override
|
|
14
18
|
* @param {ParentNode} container A DOM container.
|
|
15
19
|
* @returns {VimeoMediaProvider}
|
|
16
|
-
*/},{key:"add",value:function add(container){var
|
|
20
|
+
*/},{key:"add",value:function add(container){var _this4=this;if(!this.checkScriptLoadingStatus()){this.deferred.push(container);return this;}var iframes=this.getMediaContainers(container);if(!iframes.length){return this;}var players=[];iframes.forEach(function(iframe,index){// Block clicks on Vimeo icon
|
|
21
|
+
iframes[index].sandbox='allow-forms allow-scripts allow-pointer-lock allow-same-origin allow-top-navigation';_this4.responsify(iframe);players.push(new window.Vimeo.Player(iframe));});this.containers.set(container,players);return this;}/**
|
|
17
22
|
* Stops all playing videos within the DOM containers.
|
|
18
23
|
* @override
|
|
19
24
|
* @returns {VimeoMediaProvider}
|
|
20
|
-
*/},{key:"stop",value:function stop(){this.containers.forEach(function(players){players.forEach(function(player){player.pause();});});return this;}
|
|
25
|
+
*/},{key:"stop",value:function stop(){this.containers.forEach(function(players){players.forEach(function(player){player.pause();});});return this;}/**
|
|
26
|
+
* Searches for embedded media and replaces it with a placeholder element when comfort cookie
|
|
27
|
+
* consent is not accepted.
|
|
28
|
+
*
|
|
29
|
+
* Should be called before media container / markup is mounted to the DOM.
|
|
30
|
+
* @param {ParentNode} container A DOM container.
|
|
31
|
+
* @param {Object} [cookieConsentSettings] Additional settings related to cookie consent.
|
|
32
|
+
* @param {boolean} [cookieConsentSettings.comfortCookiesAccepted] Whether comfort cookies
|
|
33
|
+
* are accepted.
|
|
34
|
+
* @param {boolean} [cookieConsentSettings.statisticsCookiesAccepted] Whether statistics cookies
|
|
35
|
+
* are accepted.
|
|
36
|
+
* @override
|
|
37
|
+
* @returns {VimeoMediaProvider}
|
|
38
|
+
*/},{key:"handleCookieConsent",value:function handleCookieConsent(container,cookieConsentSettings){// Remove Vimeo player scripts since the VimeoMediaProvider has custom logic for it
|
|
39
|
+
container.querySelectorAll('script[src*="vimeo.com"]').forEach(function(entry){entry.remove();});return _get(_getPrototypeOf(VimeoMediaProvider.prototype),"handleCookieConsent",this).call(this,container,cookieConsentSettings);}}]);}(MediaProvider);export default VimeoMediaProvider;/* eslint-enable class-methods-use-this */
|
|
@@ -1,15 +1,20 @@
|
|
|
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 _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 _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 _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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);}import URLSearchParams from'url-search-params';import MediaProvider from"./MediaProvider"
|
|
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 _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 _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 _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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);}import URLSearchParams from'url-search-params';import MediaProvider from"./MediaProvider";/* eslint-disable class-methods-use-this */ /**
|
|
2
2
|
* The YouTube media provider class.
|
|
3
|
-
*/var YouTubeMediaProvider=/*#__PURE__*/function(_MediaProvider){
|
|
3
|
+
*/var YouTubeMediaProvider=/*#__PURE__*/function(_MediaProvider){function YouTubeMediaProvider(){_classCallCheck(this,YouTubeMediaProvider);return _callSuper(this,YouTubeMediaProvider,arguments);}_inherits(YouTubeMediaProvider,_MediaProvider);return _createClass(YouTubeMediaProvider,[{key:"getMediaContainers",value:/**
|
|
4
|
+
* Retrieves a list of media containers for YouTube.
|
|
5
|
+
* @param {ParentNode} container A DOM container that may contain YouTube iframes.
|
|
6
|
+
* @returns {NodeListOf<Element>}
|
|
7
|
+
*/function getMediaContainers(container){return container.querySelectorAll('iframe[src*="youtube.com"], iframe[src*="youtube-nocookie.com"]');}/**
|
|
4
8
|
* Add a DOM container with embedded videos.
|
|
5
9
|
* @override
|
|
6
10
|
* @param {ParentNode} container A DOM container.
|
|
7
11
|
* @returns {YouTubeMediaProvider}
|
|
8
|
-
*/value:function add(container){var
|
|
9
|
-
iframes.forEach(function(iframe,index){
|
|
12
|
+
*/},{key:"add",value:function add(container){var _this2=this;var iframes=this.getMediaContainers(container);if(!iframes.length){return this;}// Update the video urls to enable stopping videos via the event API.
|
|
13
|
+
iframes.forEach(function(iframe,index){// Block clicks on YouTube icon
|
|
14
|
+
iframes[index].sandbox='allow-forms allow-scripts allow-pointer-lock allow-same-origin allow-top-navigation';_this2.responsify(iframe);var src=iframe.src;var _src$split=src.split('?'),_src$split2=_slicedToArray(_src$split,2),url=_src$split2[0],query=_src$split2[1];var urlParams=new URLSearchParams(query);// Enable the js api to allow sending events to the iframe.
|
|
10
15
|
urlParams.set('enablejsapi',1);// Enable controls to avoid the iframe not being resumable because of controls=0 param on ios.
|
|
11
16
|
urlParams.set('controls',1);iframes[index].src="".concat(url,"?").concat(urlParams.toString());});this.containers.set(container,iframes);return this;}/**
|
|
12
17
|
* Stops all playing videos within the DOM containers.
|
|
13
18
|
* @override
|
|
14
19
|
* @returns {YouTubeMediaProvider}
|
|
15
|
-
*/},{key:"stop",value:function stop(){this.containers.forEach(function(iframes){iframes.forEach(function(iframe){if(iframe.contentWindow&&iframe.contentWindow.postMessage){iframe.contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}','*');}});});return this;}}]);
|
|
20
|
+
*/},{key:"stop",value:function stop(){this.containers.forEach(function(iframes){iframes.forEach(function(iframe){if(iframe.contentWindow&&iframe.contentWindow.postMessage){iframe.contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}','*');}});});return this;}}]);}(MediaProvider);export default YouTubeMediaProvider;/* eslint-enable class-methods-use-this */
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
1
|
+
import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var colors=themeConfig.colors;var responsiveContainer=css({position:'relative',height:0,overflow:'hidden',padding:'56.25% 0 0 0',fontSize:'0.875rem',' iframe, object, embed':{position:'absolute',top:0,left:0,width:'100%',height:'100%',border:0}});var consentContainer=css({position:'absolute',height:'100%',width:'100%',padding:16,lineHeight:'1.2rem',display:'flex',flexDirection:'column',justifyContent:'center',textAlign:'center',gap:16,background:colors.shade10,border:"1px solid ".concat(colors.shade5),// Add a tiny little border radius to make the message container look nice with padding
|
|
2
|
+
borderRadius:4,top:0});var consentLink=css({textAlign:'center',color:colors.primary,fontWeight:500}).toString();var consentIcon=css({fill:colors.shade5,height:40});export default{responsiveContainer:responsiveContainer,consentContainer:consentContainer,consentLink:consentLink,consentIcon:consentIcon};
|
|
@@ -1,16 +1,10 @@
|
|
|
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 _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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,{Component}from'react';import PropTypes from'prop-types';import Transition from'react-inline-transition-group';import{toggleBodyScroll}from'@shopgate/engage/styles';import style from"./style";/**
|
|
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 _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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,{Component}from'react';import PropTypes from'prop-types';import Transition from'react-inline-transition-group';import{toggleBodyScroll}from'@shopgate/engage/styles';import style from"./style";/**
|
|
2
2
|
* Backdrop component.
|
|
3
|
-
*/var Backdrop=/*#__PURE__*/function(_Component){
|
|
4
|
-
* The component prop types.
|
|
5
|
-
* @type {Object}
|
|
6
|
-
*/ /**
|
|
7
|
-
* The component default props.
|
|
8
|
-
* @type {Object}
|
|
9
|
-
*/ /**
|
|
3
|
+
*/var Backdrop=/*#__PURE__*/function(_Component){/**
|
|
10
4
|
* @param {Object} props The component props
|
|
11
|
-
*/function Backdrop(props){var
|
|
5
|
+
*/function Backdrop(props){var _this2;_classCallCheck(this,Backdrop);_this2=_callSuper(this,Backdrop,[props]);_this2.bodyScrollRef=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15);return _this2;}/**
|
|
12
6
|
* Sets the initial state for the body scroll lock
|
|
13
|
-
*/_createClass(Backdrop,[{key:"componentDidMount",value:function componentDidMount(){var _this$props=this.props,isVisible=_this$props.isVisible,lockBodyScroll=_this$props.lockBodyScroll;if(lockBodyScroll){toggleBodyScroll(isVisible,this.bodyScrollRef);}}/**
|
|
7
|
+
*/_inherits(Backdrop,_Component);return _createClass(Backdrop,[{key:"componentDidMount",value:function componentDidMount(){var _this$props=this.props,isVisible=_this$props.isVisible,lockBodyScroll=_this$props.lockBodyScroll;if(lockBodyScroll){toggleBodyScroll(isVisible,this.bodyScrollRef);}}/**
|
|
14
8
|
* Toggles the body scroll lock when the visibility state changes
|
|
15
9
|
* @param {Object} nextProps The next component props
|
|
16
10
|
*/},{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){var isVisible=nextProps.isVisible,lockBodyScroll=nextProps.lockBodyScroll;if(isVisible===this.props.isVisible){return;}if(lockBodyScroll){toggleBodyScroll(isVisible,this.bodyScrollRef);}}/**
|
|
@@ -22,4 +16,10 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
|
|
|
22
16
|
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){var lockBodyScroll=this.props.lockBodyScroll;if(lockBodyScroll){toggleBodyScroll(false,this.bodyScrollRef);}}/**
|
|
23
17
|
* Renders the component.
|
|
24
18
|
* @returns {JSX}
|
|
25
|
-
*/},{key:"render",value:function render(){var opacity=this.props.opacity/100;var transition={base:{background:this.props.color,opacity:0,transition:"opacity ".concat(this.props.duration,"ms ease-out"),zIndex:this.props.level},appear:{opacity:opacity},enter:{opacity:opacity},leave:{opacity:0}};var className="".concat(style," ").concat(this.props.className);return React.createElement(Transition,{childrenStyles:transition},this.props.isVisible?React.createElement("div",{"data-test-id":"Backdrop","aria-hidden":true,className:className,onClick:this.props.onClick}):null);}}]);
|
|
19
|
+
*/},{key:"render",value:function render(){var opacity=this.props.opacity/100;var transition={base:{background:this.props.color,opacity:0,transition:"opacity ".concat(this.props.duration,"ms ease-out"),zIndex:this.props.level},appear:{opacity:opacity},enter:{opacity:opacity},leave:{opacity:0}};var className="".concat(style," ").concat(this.props.className," common__backdrop");return React.createElement(Transition,{childrenStyles:transition},this.props.isVisible?React.createElement("div",{"data-test-id":"Backdrop","aria-hidden":true,className:className,onClick:this.props.onClick}):null);}}]);}(Component);/**
|
|
20
|
+
* The component prop types.
|
|
21
|
+
* @type {Object}
|
|
22
|
+
*/ /**
|
|
23
|
+
* The component default props.
|
|
24
|
+
* @type {Object}
|
|
25
|
+
*/_defineProperty(Backdrop,"defaultProps",{className:'',color:'#000',duration:200,isVisible:false,level:2,onClick:function onClick(){},opacity:50,lockBodyScroll:true});export default Backdrop;
|
|
@@ -1,10 +1,10 @@
|
|
|
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 _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
|
|
1
|
+
var _excluded=["children","testId","className","disabled","onClick"];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 _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 _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 _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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,{Component}from'react';import PropTypes from'prop-types';import style from"./style";/**
|
|
2
2
|
* The button component.
|
|
3
|
-
*/var Button=/*#__PURE__*/function(_Component){
|
|
4
|
-
* Renders the component.
|
|
5
|
-
* @returns {JSX}
|
|
6
|
-
*/value:function render(){return(// eslint-disable-next-line react/button-has-type
|
|
7
|
-
React.createElement("button",_extends({"data-test-id":this.props.testId},this.buttonProps),this.props.children));}},{key:"buttonProps",/**
|
|
3
|
+
*/var Button=/*#__PURE__*/function(_Component){function Button(){_classCallCheck(this,Button);return _callSuper(this,Button,arguments);}_inherits(Button,_Component);return _createClass(Button,[{key:"buttonProps",get:/**
|
|
8
4
|
* Getter for the calculated button props.
|
|
9
5
|
* @returns {Object}
|
|
10
|
-
*/
|
|
6
|
+
*/function get(){var _this$props=this.props,children=_this$props.children,testId=_this$props.testId,className=_this$props.className,disabled=_this$props.disabled,onClick=_this$props.onClick,props=_objectWithoutProperties(_this$props,_excluded);var buttonProps=_extends({className:"".concat(className," ").concat(style," common__button"),disabled:disabled,onClick:disabled?null:onClick},props);return buttonProps;}/**
|
|
7
|
+
* Renders the component.
|
|
8
|
+
* @returns {JSX}
|
|
9
|
+
*/},{key:"render",value:function render(){return(// eslint-disable-next-line react/button-has-type
|
|
10
|
+
React.createElement("button",_extends({"data-test-id":this.props.testId},this.buttonProps),this.props.children));}}]);}(Component);_defineProperty(Button,"defaultProps",{className:'',disabled:false,onClick:null,testId:'Button'});export default Button;
|