@shopgate/pwa-common 7.20.0-beta.13 → 7.20.0-beta.15

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,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 _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';/**
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){/**
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
@@ -16,6 +29,10 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
16
29
  * If the checkbox is uncontrolled, it keeps track of the value.
17
30
  */_defineProperty(_this2,"handleCheck",function(){if(_this2.props.disabled){return;}var checked=!_this2.isChecked();if(typeof _this2.props.defaultChecked!=='undefined'){// Uncontrolled.
18
31
  _this2.setState({checked:checked});}_this2.props.onCheck(checked);});/**
32
+ * Handler for keyDown events of the checkbox
33
+ * @param {Object} e The keyDown event payload
34
+ */_defineProperty(_this2,"handleKeyDown",function(e){if(e.key===' '){// Toggle checkbox on "space" - mocks behavior of native checkboxes
35
+ _this2.handleCheck();}});/**
19
36
  * Renders the checked/unchecked icon.
20
37
  * @returns {JSX}
21
38
  */_defineProperty(_this2,"renderIcon",function(){return _this2.isChecked()?_this2.props.checkedIcon:_this2.props.uncheckedIcon;});/**
@@ -34,4 +51,4 @@ _this2.state={checked:props.checked};}return _this2;}/**
34
51
  if(typeof this.props.defaultChecked==='undefined'){if(this.state.checked!==nextProps.checked){this.setState({checked:nextProps.checked});}}}},{key:"render",value:/**
35
52
  * Renders the checkbox component.
36
53
  * @returns {JSX}
37
- */function render(){return React.createElement("div",{className:classNames(this.props.className,'checkbox','common__checkbox'),onClick:this.handleCheck,"aria-hidden":true},this.renderInput(),this.renderLabelIfItIsOnThe('left'),this.renderIcon(),this.renderLabelIfItIsOnThe('right'));}}]);}(Component);_defineProperty(Checkbox,"defaultProps",{checked:undefined,className:undefined,defaultChecked:undefined,disabled:false,label:null,labelPosition:'left',name:undefined,onCheck:function onCheck(){}});export default Checkbox;
54
+ */function render(){return React.createElement("div",{className:classNames(this.props.className,'checkbox','common__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'));}}]);}(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.20.0-beta.13",
3
+ "version": "7.20.0-beta.15",
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.20.0-beta.13",
19
+ "@shopgate/pwa-benchmark": "7.20.0-beta.15",
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.20.0-beta.13",
47
+ "@shopgate/pwa-core": "7.20.0-beta.15",
48
48
  "lodash": "^4.17.4",
49
49
  "prop-types": "~15.7.2",
50
50
  "react": "~16.12.0",