@shopgate/pwa-common 7.25.0-beta.4 → 7.25.0-beta.6

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.
@@ -1 +1,2 @@
1
- import{css}from'glamor';export default css({position:'fixed',top:0,right:0,bottom:0,left:0});
1
+ import{css}from'glamor';export default css({position:'fixed',top:0,right:0,bottom:0,left:0,// Prevents that content behind the backdrop is clickable
2
+ pointerEvents:'all',touchAction:'none'});
@@ -33,5 +33,5 @@ var deltaTime=Math.max(0,this.remainingTime);var isExpired=deltaTime<=0;if(isExp
33
33
  clearInterval(this.intervalHandle);this.intervalHandle=null;// The timer just expired, invoke the callback.
34
34
  if(this.props.onExpire){this.props.onExpire();}}this.setState({formattedTime:createFormattedTime(deltaTime)});}/**
35
35
  * Renders the element.
36
- * @return {JSX}
36
+ * @return {JSX.Element}
37
37
  */},{key:"render",value:function render(){return React.createElement(I18n.Text,{string:this.state.formattedTime.string,params:this.state.formattedTime.params,className:"".concat(this.props.className," common__countdown-timer")});}}]);}(Component);_defineProperty(CountdownTimer,"defaultProps",{className:'',onExpire:null});export default CountdownTimer;
@@ -1,25 +1,25 @@
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 classNames from'classnames';import{FocusTrap}from'@shopgate/engage/a11y/components';import styles 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 classNames from'classnames';import styles from"./style";/**
2
2
  * Drawer component.
3
3
  */var Drawer=/*#__PURE__*/function(_Component){/**
4
4
  * Initializes the Drawer component.
5
5
  * @param {Object} props The components props.
6
6
  */function Drawer(props){var _this2;_classCallCheck(this,Drawer);_this2=_callSuper(this,Drawer,[props]);/**
7
7
  * Syncs the internal active state when an animation ends.
8
- */_defineProperty(_this2,"handleAnimationEnd",function(){_this2.setState({active:_this2.props.isOpen});if(!_this2.props.isOpen){_this2.props.onDidClose();}else{_this2.props.onDidOpen();}});_this2.sheetRef=React.createRef();_this2.state={active:props.isOpen};return _this2;}/**
8
+ */_defineProperty(_this2,"handleAnimationEnd",function(){_this2.setState({active:_this2.props.isOpen});if(!_this2.props.isOpen){_this2.props.onDidClose();}else{_this2.props.onDidOpen();}});_this2.sheetRef=React.createRef();_this2.state={active:props.isOpen};return _this2;}/** inheritdoc */_inherits(Drawer,_Component);return _createClass(Drawer,[{key:"componentDidMount",value:function componentDidMount(){if(this.props.isOpen){if(this.sheetRef.current){this.sheetRef.current.focus();}}}/**
9
9
  * Update state when isOpen changes.
10
10
  * @param {Object} nextProps The next component props.
11
- */_inherits(Drawer,_Component);return _createClass(Drawer,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(this.props.isOpen!==nextProps.isOpen){if(nextProps.isOpen){if(typeof nextProps.onOpen==='function'){nextProps.onOpen();}this.setState({active:true});}else if(typeof nextProps.onClose==='function'){nextProps.onClose();}}}/**
11
+ */},{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(this.props.isOpen!==nextProps.isOpen){if(nextProps.isOpen){if(typeof nextProps.onOpen==='function'){nextProps.onOpen();}this.setState({active:true});}else if(typeof nextProps.onClose==='function'){nextProps.onClose();}}}/**
12
12
  * Set focus for a11y when sheet opens
13
13
  * @param {Object} prevProps The previous component props.
14
14
  */},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(!prevProps.isOpen&&this.props.isOpen){if(this.sheetRef.current){this.sheetRef.current.focus();}}}},{key:"render",value:/**
15
15
  * Renders the component.
16
16
  * @returns {JSX}
17
- */function render(){var _this3=this;var _this$props=this.props,alwaysActive=_this$props.alwaysActive,className=_this$props.className,children=_this$props.children,isOpen=_this$props.isOpen,animation=_this$props.animation;var active=this.state.active;var animationIn=animation["in"]||styles.animation["in"];var animationOut=animation.out||styles.animation.out;var combinedClassName=classNames(className,styles.container,_defineProperty({},animationIn,isOpen),_defineProperty({},animationOut,!isOpen),'common__drawer');var style={};if(typeof animation.duration==='number'){style.animationDuration="".concat(animation.duration,"ms");}return active||alwaysActive?React.createElement(FocusTrap,{active:isOpen},React.createElement("div",{ref:this.sheetRef,className:combinedClassName,style:style,onAnimationEnd:function onAnimationEnd(){var _this3$sheetRef;_this3.handleAnimationEnd();// clear any residual animation style to fix a11y issue on Android
17
+ */function render(){var _this3=this;var _this$props=this.props,className=_this$props.className,children=_this$props.children,isOpen=_this$props.isOpen,animation=_this$props.animation;var active=this.state.active;var animationIn=animation["in"]||styles.animation["in"];var animationOut=animation.out||styles.animation.out;var combinedClassName=classNames(className,styles.container,_defineProperty({},animationIn,isOpen),_defineProperty({},animationOut,!isOpen),'common__drawer');var style={};if(typeof animation.duration==='number'){style.animationDuration="".concat(animation.duration,"ms");}return active?React.createElement("div",{ref:this.sheetRef,className:combinedClassName,style:style,onAnimationEnd:function onAnimationEnd(){var _this3$sheetRef;_this3.handleAnimationEnd();// clear any residual animation style to fix a11y issue on Android
18
18
  // (focus ring is misaligned)
19
- if((_this3$sheetRef=_this3.sheetRef)===null||_this3$sheetRef===void 0?void 0:_this3$sheetRef.style){_this3.sheetRef.style.animation='';_this3.sheetRef.style.transform='none';}},role:"dialog","aria-modal":true,tabIndex:-1},children)):null;}}]);}(Component);/**
19
+ if((_this3$sheetRef=_this3.sheetRef)===null||_this3$sheetRef===void 0?void 0:_this3$sheetRef.style){_this3.sheetRef.style.animation='';_this3.sheetRef.style.transform='none';}},role:"dialog","aria-modal":true,tabIndex:-1},children):null;}}]);}(Component);/**
20
20
  * The component prop types.
21
21
  * @type {Object}
22
22
  */ /**
23
23
  * The component default props.
24
24
  * @type {Object}
25
- */_defineProperty(Drawer,"defaultProps",{alwaysActive:false,className:'',children:null,isOpen:false,onOpen:function onOpen(){},onClose:function onClose(){},onDidClose:function onDidClose(){},onDidOpen:function onDidOpen(){},animation:{duration:null,"in":'',out:''}});export default Drawer;
25
+ */_defineProperty(Drawer,"defaultProps",{className:'',children:null,isOpen:false,onOpen:function onOpen(){},onClose:function onClose(){},onDidClose:function onDidClose(){},onDidOpen:function onDidOpen(){},animation:{duration:null,"in":'',out:''}});export default Drawer;
@@ -1,11 +1,7 @@
1
- import React,{useEffect}from'react';import PropTypes from'prop-types';import{ConnectedReactPortal,MODAL_EVENTS}from'@shopgate/engage/components';import{UIEvents}from'@shopgate/engage/core';import classNames from'classnames';import styles from"./style";var activeModals=0;/**
1
+ var _excluded=["children","classes"];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;}import React,{forwardRef}from'react';import PropTypes from'prop-types';import{createPortal}from'react-dom';import{useTrackModalState}from'@shopgate/engage/a11y/hooks';import classNames from'classnames';import styles from"./style";/**
2
2
  * The Modal component.
3
3
  * @param {Object} props The component props.
4
- * @param {boolean} props.disableA11YFocusHandling Whether the internal A11Y focus handling
5
- * should be disabled since it's already handled outside the dialog.
4
+ * @param {Object} props.classes The component classes.
6
5
  * @returns {JSX.Element}
7
- */var Modal=function Modal(_ref){var children=_ref.children,classes=_ref.classes,disableA11YFocusHandling=_ref.disableA11YFocusHandling;useEffect(function(){if(disableA11YFocusHandling){return null;}activeModals+=1;// Create a MutationObserver to watch for changes in the DOM. We need to dispatch an UI event
8
- // when the modal is shown, so that the main content is hidden from screen readers.
9
- var observer=new MutationObserver(function(){var target=document.querySelector('.engage__view');if(target){// Dispatch an UI event to hide the main content from screen readers.
10
- UIEvents.emit(MODAL_EVENTS.SHOW);}});observer.observe(document.body,{childList:true,subtree:true});return function(){observer.disconnect();activeModals-=1;if(activeModals<=0){// Dispatch an UI event to make the main content visible for screen readers again.
11
- UIEvents.emit(MODAL_EVENTS.HIDE);}};},[disableA11YFocusHandling]);return React.createElement(ConnectedReactPortal,{isOpened:true},React.createElement("div",{className:classNames(styles.container,classes===null||classes===void 0?void 0:classes.container,'common__modal'),role:"alertdialog","aria-modal":true},React.createElement("div",{className:classNames(styles.layout,classes===null||classes===void 0?void 0:classes.layout)},React.createElement("div",{className:classNames(styles.content,classes===null||classes===void 0?void 0:classes.content)},children))));};Modal.defaultProps={children:null,disableA11YFocusHandling:false,classes:{container:'',layout:'',content:''}};export default Modal;
6
+ */var Modal=forwardRef(function(_ref,ref){var children=_ref.children,classes=_ref.classes,props=_objectWithoutProperties(_ref,_excluded);// Track modal visibility for accessibility purposes.
7
+ useTrackModalState();return createPortal(React.createElement("div",_extends({className:classNames(styles.container,classes===null||classes===void 0?void 0:classes.container,'common__modal'),role:"alertdialog","aria-modal":true},props,{ref:ref}),React.createElement("div",{className:classNames(styles.layout,classes===null||classes===void 0?void 0:classes.layout)},React.createElement("div",{className:classNames(styles.content,classes===null||classes===void 0?void 0:classes.content)},children))),document.getElementById('portals'));});Modal.defaultProps={children:null,classes:{container:'',layout:'',content:''}};export default Modal;
@@ -1,7 +1,7 @@
1
- import React,{useEffect,useRef}from'react';import PropTypes from'prop-types';import UIEvents from'@shopgate/pwa-core/emitters/ui';import connect from"./connector";export var MODAL_EVENTS={SHOW:'Modal.show',HIDE:'Modal.hide'};/**
1
+ import React from'react';import PropTypes from'prop-types';import connect from"./connector";export var MODAL_EVENTS={SHOW:'Modal.show',HIDE:'Modal.hide'};/**
2
2
  * The ModalContainer is connected to the modal state
3
3
  * and renders the currently active modal.
4
4
  * @param {Object} props The component props.
5
5
  * @returns {JSX.Element}
6
- */var ModalContainer=function ModalContainer(_ref){var component=_ref.component,confirm=_ref.confirm,dismiss=_ref.dismiss,modal=_ref.modal;var ref=useRef(false);useEffect(function(){if(modal&&!ref.current){ref.current=true;UIEvents.emit(MODAL_EVENTS.SHOW);}if(!modal&&ref.current){ref.current=false;UIEvents.emit(MODAL_EVENTS.HIDE);}},[modal]);if(!modal){return null;}var componentProps={modal:modal,// A11Y focus is handled by the modal container itself.
7
- disableA11YFocusHandling:true,onConfirm:function onConfirm(){return confirm(modal.id);},onDismiss:function onDismiss(){return dismiss(modal.id);}};if(React.isValidElement(component)){return React.cloneElement(component,componentProps);}return React.createElement(component,componentProps);};ModalContainer.defaultProps={confirm:function confirm(){},dismiss:function dismiss(){},modal:null};export default connect(ModalContainer);
6
+ */var ModalContainer=function ModalContainer(_ref){var component=_ref.component,confirm=_ref.confirm,dismiss=_ref.dismiss,modal=_ref.modal;if(!modal){return null;}var componentProps={modal:modal,// A11Y focus is handled by the modal container itself.
7
+ onConfirm:function onConfirm(){return confirm(modal.id);},onDismiss:function onDismiss(){return dismiss(modal.id);}};if(React.isValidElement(component)){return React.cloneElement(component,componentProps);}return React.createElement(component,componentProps);};ModalContainer.defaultProps={confirm:function confirm(){},dismiss:function dismiss(){},modal:null};export default connect(ModalContainer);
@@ -16,6 +16,10 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
16
16
  * @param {string} url The URL to check.
17
17
  * @return {boolean}
18
18
  */export var isExternal=function isExternal(url){return url.includes('http://')||url.includes('https://')||url.includes('//');};/**
19
+ * Checks whether the url is an HTTPS url.
20
+ * @param {string} url The url to open.
21
+ * @return {boolean}
22
+ */export var isHTTPS=function isHTTPS(){var url=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return url.startsWith('https://');};/**
19
23
  * Returns the actual url to the image, by adding url parameters with the dimensions for img-cdn
20
24
  * @param {string} src Source to the image.
21
25
  * @param {Object} dimension Dimension of the requested image.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-common",
3
- "version": "7.25.0-beta.4",
3
+ "version": "7.25.0-beta.6",
4
4
  "description": "Common library for the Shopgate Connect PWA.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -17,7 +17,7 @@
17
17
  "dependencies": {
18
18
  "@redux-devtools/extension": "^3.3.0",
19
19
  "@sentry/browser": "6.0.1",
20
- "@shopgate/pwa-benchmark": "7.25.0-beta.4",
20
+ "@shopgate/pwa-benchmark": "7.25.0-beta.6",
21
21
  "@virtuous/conductor": "~2.5.0",
22
22
  "@virtuous/react-conductor": "~2.5.0",
23
23
  "@virtuous/redux-persister": "1.1.0-beta.7",
@@ -43,7 +43,7 @@
43
43
  "url-search-params": "^0.10.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@shopgate/pwa-core": "7.25.0-beta.4",
46
+ "@shopgate/pwa-core": "7.25.0-beta.6",
47
47
  "@types/react-portal": "^3.0.9",
48
48
  "lodash": "^4.17.4",
49
49
  "prop-types": "~15.8.1",