@shopgate/pwa-common 7.12.7-beta.1 → 7.12.7-beta.2

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.
@@ -13,7 +13,8 @@ _this.isPending=true;_this.remoteScriptUrl=scriptUrl;_this.deferred=[];return _t
13
13
  * @override
14
14
  * @param {ParentNode} container A DOM container.
15
15
  * @returns {VimeoMediaProvider}
16
- */},{key:"add",value:function add(container){var _this3=this;if(!this.checkScriptLoadingStatus()){this.deferred.push(container);return this;}var iframes=container.querySelectorAll('iframe[src*="vimeo.com"]');if(!iframes.length){return this;}var players=[];iframes.forEach(function(iframe){_this3.responsify(iframe);players.push(new window.Vimeo.Player(iframe));});this.containers.set(container,players);return this;}/**
16
+ */},{key:"add",value:function add(container){var _this3=this;if(!this.checkScriptLoadingStatus()){this.deferred.push(container);return this;}var iframes=container.querySelectorAll('iframe[src*="vimeo.com"]');if(!iframes.length){return this;}var players=[];iframes.forEach(function(iframe,index){// Block clicks on Vimeo icon
17
+ iframes[index].sandbox='allow-forms allow-scripts allow-pointer-lock allow-same-origin allow-top-navigation';_this3.responsify(iframe);players.push(new window.Vimeo.Player(iframe));});this.containers.set(container,players);return this;}/**
17
18
  * Stops all playing videos within the DOM containers.
18
19
  * @override
19
20
  * @returns {VimeoMediaProvider}
@@ -6,7 +6,8 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
6
6
  * @param {ParentNode} container A DOM container.
7
7
  * @returns {YouTubeMediaProvider}
8
8
  */value:function add(container){var _this=this;var iframes=container.querySelectorAll('iframe[src*="youtube.com"], iframe[src*="youtube-nocookie.com"]');if(!iframes.length){return this;}// Update the video urls to enable stopping videos via the event API.
9
- iframes.forEach(function(iframe,index){_this.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.
9
+ iframes.forEach(function(iframe,index){// Block clicks on YouTube icon
10
+ iframes[index].sandbox='allow-forms allow-scripts allow-pointer-lock allow-same-origin allow-top-navigation';_this.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
11
  urlParams.set('enablejsapi',1);// Enable controls to avoid the iframe not being resumable because of controls=0 param on ios.
11
12
  urlParams.set('controls',1);iframes[index].src="".concat(url,"?").concat(urlParams.toString());});this.containers.set(container,iframes);return this;}/**
12
13
  * Stops all playing videos within the DOM containers.
@@ -1,6 +1,19 @@
1
1
  function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import classNames from'classnames';/**
2
+ * @typedef {Object} CheckboxProps
3
+ * @property {React.ReactNode} checkedIcon React component used as icon for the checked state
4
+ * @property {React.ReactNode} uncheckedIcon React component used as icon for the unchecked state
5
+ * @property {boolean} [checked] Current checked state of the checkbox
6
+ * @property {string} [className] Class name for the checkbox
7
+ * @property {boolean} [defaultChecked] Whether the checkbox is checked by default
8
+ * @property {boolean} [disabled] Disabled state of the checkbox (default `false`)
9
+ * @property {React.ReactNode | string} [label] Checkbox label. Can be a string or a component.
10
+ * @property {"left"|"right"} [labelPosition] Position for the lable (default `"left"`)
11
+ * @property {string} [name] Name for the hidden input tag
12
+ * @property {Function} [onCheck] Callback invoked when checkbox is toggled
13
+ */ /**
2
14
  * Base checkbox component.
3
- * @type {Object}
15
+ * @extends {React.Component<CheckboxProps>}
16
+ * @returns {JSX.Element}
4
17
  */var Checkbox=/*#__PURE__*/function(_Component){_inherits(Checkbox,_Component);/**
5
18
  * The checkbox component constructor.
6
19
  * It checks if the checkbox is a controlled or uncontrolled input and sets an internal state if
@@ -9,7 +22,8 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
9
22
  */function Checkbox(props){var _this;_classCallCheck(this,Checkbox);_this=_possibleConstructorReturn(this,_getPrototypeOf(Checkbox).call(this,props));_defineProperty(_assertThisInitialized(_this),"isChecked",function(){return typeof _this.props.defaultChecked==='undefined'?_this.props.checked// Controlled.
10
23
  :_this.state.checked// Uncontrolled.
11
24
  ;});_defineProperty(_assertThisInitialized(_this),"handleCheck",function(){if(_this.props.disabled){return;}var checked=!_this.isChecked();if(typeof _this.props.defaultChecked!=='undefined'){// Uncontrolled.
12
- _this.setState({checked:checked});}_this.props.onCheck(checked);});_defineProperty(_assertThisInitialized(_this),"renderIcon",function(){return _this.isChecked()?_this.props.checkedIcon:_this.props.uncheckedIcon;});_defineProperty(_assertThisInitialized(_this),"renderInput",function(){var _assertThisInitialize=_assertThisInitialized(_this),name=_assertThisInitialize.props.name,isChecked=_assertThisInitialize.isChecked;return _this.props.name?React.createElement("input",{className:"input",type:"hidden",name:name,value:isChecked()?1:0}):null;});_defineProperty(_assertThisInitialized(_this),"renderLabelIfItIsOnThe",function(side){return _this.props.labelPosition===side?_this.props.label:null;});if(typeof props.defaultChecked!=='undefined'){// Uncontrolled input.
25
+ _this.setState({checked:checked});}_this.props.onCheck(checked);});_defineProperty(_assertThisInitialized(_this),"handleKeyDown",function(e){if(e.key===' '){// Toggle checkbox on "space" - mocks behavior of native checkboxes
26
+ _this.handleCheck();}});_defineProperty(_assertThisInitialized(_this),"renderIcon",function(){return _this.isChecked()?_this.props.checkedIcon:_this.props.uncheckedIcon;});_defineProperty(_assertThisInitialized(_this),"renderInput",function(){var _assertThisInitialize=_assertThisInitialized(_this),name=_assertThisInitialize.props.name,isChecked=_assertThisInitialize.isChecked;return _this.props.name?React.createElement("input",{className:"input",type:"hidden",name:name,value:isChecked()?1:0}):null;});_defineProperty(_assertThisInitialized(_this),"renderLabelIfItIsOnThe",function(side){return _this.props.labelPosition===side?_this.props.label:null;});if(typeof props.defaultChecked!=='undefined'){// Uncontrolled input.
13
27
  _this.state={checked:props.defaultChecked};}else{// Controlled input
14
28
  _this.state={checked:props.checked};}return _this;}/**
15
29
  * Make sure state is updated with new checked value when input is controlled
@@ -21,4 +35,4 @@ if(typeof this.props.defaultChecked==='undefined'){if(this.state.checked!==nextP
21
35
  */},{key:"render",/**
22
36
  * Renders the checkbox component.
23
37
  * @returns {JSX}
24
- */value:function render(){return React.createElement("div",{className:classNames(this.props.className,'checkbox'),onClick:this.handleCheck,"aria-hidden":true},this.renderInput(),this.renderLabelIfItIsOnThe('left'),this.renderIcon(),this.renderLabelIfItIsOnThe('right'));}}]);return Checkbox;}(Component);_defineProperty(Checkbox,"defaultProps",{checked:undefined,className:undefined,defaultChecked:undefined,disabled:false,label:null,labelPosition:'left',name:undefined,onCheck:function onCheck(){}});export default Checkbox;
38
+ */value:function render(){return React.createElement("div",{className:classNames(this.props.className,'checkbox'),onClick:this.handleCheck,onKeyDown:this.handleKeyDown,role:"checkbox","aria-checked":this.props.checked,tabIndex:0},this.renderInput(),this.renderLabelIfItIsOnThe('left'),this.renderIcon(),this.renderLabelIfItIsOnThe('right'));}}]);return Checkbox;}(Component);_defineProperty(Checkbox,"defaultProps",{checked:undefined,className:undefined,defaultChecked:undefined,disabled:false,label:null,labelPosition:'left',name:undefined,onCheck:function onCheck(){}});export default Checkbox;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-common",
3
- "version": "7.12.7-beta.1",
3
+ "version": "7.12.7-beta.2",
4
4
  "description": "Common library for the Shopgate Connect PWA.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "@sentry/browser": "6.0.1",
19
- "@shopgate/pwa-benchmark": "7.12.7-beta.1",
19
+ "@shopgate/pwa-benchmark": "7.12.7-beta.2",
20
20
  "@virtuous/conductor": "~2.5.0",
21
21
  "@virtuous/react-conductor": "~2.5.0",
22
22
  "@virtuous/redux-persister": "1.1.0-beta.7",
@@ -44,7 +44,7 @@
44
44
  "url-search-params": "^0.10.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@shopgate/pwa-core": "7.12.7-beta.1",
47
+ "@shopgate/pwa-core": "7.12.7-beta.2",
48
48
  "lodash": "^4.17.4",
49
49
  "prop-types": "~15.7.2",
50
50
  "react": "~16.12.0",