@shopgate/pwa-common 7.12.3-beta.1 → 7.20.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/App.js +6 -6
  2. package/actions/app/handleLink.js +7 -5
  3. package/actions/client/fetchClientInformation.js +1 -1
  4. package/actions/page/fetchPageConfig.js +2 -2
  5. package/actions/user/login.js +2 -2
  6. package/collections/AuthRoutes.js +3 -3
  7. package/collections/Configuration.js +3 -3
  8. package/collections/EmbeddedMedia.js +2 -2
  9. package/collections/PersistedReducers.js +2 -2
  10. package/collections/Redirects.js +3 -3
  11. package/collections/media-providers/MediaProvider.js +2 -2
  12. package/collections/media-providers/Vimeo.js +7 -7
  13. package/collections/media-providers/YouTube.js +5 -5
  14. package/components/Backdrop/index.js +11 -11
  15. package/components/Button/index.js +7 -7
  16. package/components/Checkbox/index.js +27 -14
  17. package/components/CountdownTimer/index.js +7 -7
  18. package/components/Drawer/index.js +13 -13
  19. package/components/Dropdown/index.js +5 -5
  20. package/components/Ellipsis/index.js +1 -1
  21. package/components/ErrorBoundary/index.js +5 -5
  22. package/components/Grid/components/Item/index.js +4 -4
  23. package/components/Grid/index.js +4 -4
  24. package/components/HtmlSanitizer/connector.js +5 -0
  25. package/components/HtmlSanitizer/index.js +10 -10
  26. package/components/HtmlSanitizer/spec.js +3 -3
  27. package/components/I18n/components/FormatPrice/index.js +2 -2
  28. package/components/I18n/components/I18nProvider/index.js +9 -9
  29. package/components/I18n/components/Translate/index.js +11 -7
  30. package/components/Icon/index.js +1 -1
  31. package/components/Image/index.js +9 -9
  32. package/components/Image/spec.js +2 -2
  33. package/components/InfiniteContainer/index.js +21 -21
  34. package/components/Input/components/DateInput.js +2 -2
  35. package/components/Input/components/MultiLineInput.js +10 -10
  36. package/components/Input/components/SimpleInput.js +27 -21
  37. package/components/KeyboardConsumer/index.js +7 -7
  38. package/components/Link/index.js +8 -5
  39. package/components/List/components/Item/index.js +1 -1
  40. package/components/List/index.js +1 -1
  41. package/components/Modal/index.js +1 -1
  42. package/components/Modal/style.js +1 -1
  43. package/components/Picker/components/List/index.js +1 -1
  44. package/components/Picker/components/Modal/index.js +7 -7
  45. package/components/Picker/index.js +19 -9
  46. package/components/Portal/index.js +15 -11
  47. package/components/ProductCharacteristics/helpers/index.js +1 -1
  48. package/components/ProductCharacteristics/index.js +27 -12
  49. package/components/RangeSlider/index.js +33 -24
  50. package/components/Route/RouteNotFound.js +3 -3
  51. package/components/Route/index.js +5 -5
  52. package/components/Router/index.js +18 -10
  53. package/components/ScannerContainer/index.js +3 -3
  54. package/components/Select/index.js +25 -15
  55. package/components/SelectBox/components/Item/index.js +5 -3
  56. package/components/SelectBox/index.js +17 -8
  57. package/components/Swiper/components/SwiperItem/spec.js +1 -1
  58. package/components/Swiper/index.js +3 -3
  59. package/components/Swiper/styles.js +4 -1
  60. package/components/Transition/index.js +4 -4
  61. package/components/Widgets/components/Widget/index.js +4 -4
  62. package/components/Widgets/components/WidgetGrid/index.js +5 -5
  63. package/components/Widgets/index.js +7 -7
  64. package/components/index.js +1 -2
  65. package/constants/Configuration.js +1 -1
  66. package/constants/Device.js +2 -2
  67. package/constants/Portals.js +2 -2
  68. package/helpers/config/mock.js +2 -2
  69. package/helpers/config/theme.js +2 -2
  70. package/helpers/i18n/getTranslator.js +10 -4
  71. package/helpers/portals/portalCollection.js +3 -3
  72. package/helpers/redux/mutable.js +3 -2
  73. package/helpers/redux/shouldFetchData.js +1 -1
  74. package/helpers/style/index.js +2 -2
  75. package/package.json +4 -4
  76. package/providers/loading/index.js +24 -14
  77. package/providers/toast/index.js +10 -8
  78. package/reducers/page/index.js +1 -1
  79. package/reducers/router/index.js +1 -1
  80. package/selectors/client.js +9 -7
  81. package/streams/app.js +8 -2
  82. package/streams/main.js +1 -1
  83. package/streams/view.js +12 -0
  84. package/subscriptions/error.js +4 -4
  85. package/subscriptions/helpers/handleLinks.js +2 -2
  86. package/subscriptions/menu.js +4 -2
  87. package/subscriptions/router.js +6 -6
  88. package/subscriptions/user.js +1 -1
@@ -1,23 +1,38 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import isMatch from'lodash/isMatch';import{broadcastLiveMessage}from'@shopgate/engage/a11y';import{responsiveCondition}from'@shopgate/engage/styles';import connect from"./connector";import VariantsContext from"./context";import{isCharacteristicEnabled,getSelectedValue,prepareState,selectCharacteristics}from"./helpers";/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _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 isMatch from'lodash/isMatch';import{broadcastLiveMessage}from'@shopgate/engage/a11y';import{responsiveCondition}from'@shopgate/engage/styles';import connect from"./connector";import VariantsContext from"./context";import{isCharacteristicEnabled,getSelectedValue,prepareState,selectCharacteristics}from"./helpers";/**
2
2
  * The ProductCharacteristics component.
3
3
  * @deprecated Please use the component via
4
4
  * `import { ProductCharacteristics } from '@shopgate/engage/product'`
5
- */var ProductCharacteristics=/*#__PURE__*/function(_Component){_inherits(ProductCharacteristics,_Component);function ProductCharacteristics(_props){var _this;_classCallCheck(this,ProductCharacteristics);_this=_possibleConstructorReturn(this,_getPrototypeOf(ProductCharacteristics).call(this,_props));_defineProperty(_assertThisInitialized(_this),"setRefs",function(props){var variants=props.variants;if(variants){variants.characteristics.forEach(function(_char){_this.refsStore[_char.id]=React.createRef();});}});_defineProperty(_assertThisInitialized(_this),"checkSelection",function(){var characteristics=_this.state.characteristics;var _this$props=_this.props,variants=_this$props.variants,variantId=_this$props.variantId;if(!variants){return true;}var filteredValues=Object.keys(characteristics).filter(function(key){return!!characteristics[key];});var selected=!!(filteredValues.length===variants.characteristics.length&&variantId);if(!selected){var firstUnselected=_this.findUnselectedCharacteristic();if(firstUnselected){var ref=_this.refsStore[firstUnselected.id];// Focus the item for screen readers and broadcast a related live message.
6
- ref.current.focus();var option=ref.current.innerText;broadcastLiveMessage('product.pick_option_first',{params:{option:option}});if(responsiveCondition('>xs',{webOnly:true})){ref.current.scrollIntoView({behavior:'smooth',block:'center'});}else{ref.current.scrollIntoView({behavior:'smooth'});}_this.setState({highlight:firstUnselected.id});}}return selected;});_defineProperty(_assertThisInitialized(_this),"checkSelectedCharacteristics",function(){var characteristics=_this.state.characteristics;var _this$props2=_this.props,variantId=_this$props2.variantId,variants=_this$props2.variants,finishTimeout=_this$props2.finishTimeout;if(!variants){return;}var filteredValues=Object.keys(characteristics).filter(function(key){return!!characteristics[key];});if(filteredValues.length!==variants.characteristics.length){return;}var products=variants.products.filter(function(product){return isMatch(product.characteristics,characteristics);});if(!products.length){return;}if(products[0].id===variantId){return;}setTimeout(function(){_this.props.navigate(products[0].id);},finishTimeout);});_defineProperty(_assertThisInitialized(_this),"handleSelection",function(selection){var _this$props3=_this.props,variants=_this$props3.variants,setCharacteristics=_this$props3.setCharacteristics;var id=selection.id,value=selection.value;_this.setState(function(_ref){var characteristics=_ref.characteristics;var state=prepareState(id,value,characteristics,variants.characteristics,variants.products);setCharacteristics(state);return{characteristics:_extends({},state),highlight:null};},_this.checkSelectedCharacteristics);});_defineProperty(_assertThisInitialized(_this),"buildValues",function(selections,charId,values,charIndex,selectedValue){// If this is the first characteristic then all values are selectable.
7
- if(charIndex===0){return values.map(function(value){return _extends({},value,{selectable:true,selected:selectedValue===value.id});});}var variants=_this.props.variants;var subset={};Object.keys(selections).forEach(function(item,index){if(index<charIndex){subset[item]=selections[item];}});// Filter products that match or partially match the current characteristic selection.
5
+ */var ProductCharacteristics=/*#__PURE__*/function(_Component){function ProductCharacteristics(_props){var _this2;_classCallCheck(this,ProductCharacteristics);_this2=_callSuper(this,ProductCharacteristics,[_props]);/**
6
+ * Sets the refs to the characteristics selects.
7
+ * @param {Object} props The props to check against.
8
+ */_defineProperty(_this2,"setRefs",function(props){var variants=props.variants;if(variants){variants.characteristics.forEach(function(_char){_this2.refsStore[_char.id]=React.createRef();});}});/**
9
+ * Checks if all selections have been made.
10
+ * @return {boolean}
11
+ */_defineProperty(_this2,"checkSelection",function(){var characteristics=_this2.state.characteristics;var _this2$props=_this2.props,variants=_this2$props.variants,variantId=_this2$props.variantId;if(!variants){return true;}var filteredValues=Object.keys(characteristics).filter(function(key){return!!characteristics[key];});var selected=!!(filteredValues.length===variants.characteristics.length&&variantId);if(!selected){var firstUnselected=_this2.findUnselectedCharacteristic();if(firstUnselected){var ref=_this2.refsStore[firstUnselected.id];// Focus the item for screen readers and broadcast a related live message.
12
+ ref.current.focus();var option=ref.current.innerText;broadcastLiveMessage('product.pick_option_first',{params:{option:option}});if(responsiveCondition('>xs',{webOnly:true})){ref.current.scrollIntoView({behavior:'smooth',block:'center'});}else{ref.current.scrollIntoView({behavior:'smooth'});}_this2.setState({highlight:firstUnselected.id});}}return selected;});_defineProperty(_this2,"checkSelectedCharacteristics",function(){var characteristics=_this2.state.characteristics;var _this2$props2=_this2.props,variantId=_this2$props2.variantId,variants=_this2$props2.variants,finishTimeout=_this2$props2.finishTimeout;if(!variants){return;}var filteredValues=Object.keys(characteristics).filter(function(key){return!!characteristics[key];});if(filteredValues.length!==variants.characteristics.length){return;}var products=variants.products.filter(function(product){return isMatch(product.characteristics,characteristics);});if(!products.length){return;}if(products[0].id===variantId){return;}setTimeout(function(){_this2.props.navigate(products[0].id);},finishTimeout);});/**
13
+ * Stores a selected characteristic into the local state.
14
+ * @param {Object} selection The selected item.
15
+ */_defineProperty(_this2,"handleSelection",function(selection){var _this2$props3=_this2.props,variants=_this2$props3.variants,setCharacteristics=_this2$props3.setCharacteristics;var id=selection.id,value=selection.value;_this2.setState(function(_ref){var characteristics=_ref.characteristics;var state=prepareState(id,value,characteristics,variants.characteristics,variants.products);setCharacteristics(state);return{characteristics:_extends({},state),highlight:null};},_this2.checkSelectedCharacteristics);});/**
16
+ * @param {Object} selections The selections stored in the state.
17
+ * @param {string} charId The current characteristic ID.
18
+ * @param {Array} values The characteristic values.
19
+ * @param {number} charIndex The characteristic index.
20
+ * @param {string|null} selectedValue selectedValue
21
+ * @return {Array}
22
+ */_defineProperty(_this2,"buildValues",function(selections,charId,values,charIndex,selectedValue){// If this is the first characteristic then all values are selectable.
23
+ if(charIndex===0){return values.map(function(value){return _extends({},value,{selectable:true,selected:selectedValue===value.id});});}var variants=_this2.props.variants;var subset={};Object.keys(selections).forEach(function(item,index){if(index<charIndex){subset[item]=selections[item];}});// Filter products that match or partially match the current characteristic selection.
8
24
  var products=variants.products.filter(function(_ref2){var characteristics=_ref2.characteristics;return isMatch(characteristics,subset);});// Check if any of the values are present inside any of the matching products.
9
- return values.map(function(value){var selectable=products.some(function(_ref3){var characteristics=_ref3.characteristics;return isMatch(characteristics,_defineProperty({},charId,value.id));});return _extends({},value,{selectable:selectable,selected:selectedValue===value.id});});});_defineProperty(_assertThisInitialized(_this),"resetHighlight",function(){_this.setState({highlight:null});});_this.refsStore={};_this.state={highlight:null,characteristics:selectCharacteristics(_props)};_this.setRefs(_props);_props.conditioner.addConditioner('product-variants',_this.checkSelection);return _this;}/** @inheritDoc */_createClass(ProductCharacteristics,[{key:"componentDidMount",value:function componentDidMount(){this.checkSelectedCharacteristics();}/**
25
+ return values.map(function(value){var selectable=products.some(function(_ref3){var characteristics=_ref3.characteristics;return isMatch(characteristics,_defineProperty({},charId,value.id));});return _extends({},value,{selectable:selectable,selected:selectedValue===value.id});});});/**
26
+ * Resets the highlight state
27
+ */_defineProperty(_this2,"resetHighlight",function(){_this2.setState({highlight:null});});_this2.refsStore={};_this2.state={highlight:null,characteristics:selectCharacteristics(_props)};_this2.setRefs(_props);_props.conditioner.addConditioner('product-variants',_this2.checkSelection);return _this2;}/** @inheritDoc */_inherits(ProductCharacteristics,_Component);return _createClass(ProductCharacteristics,[{key:"componentDidMount",value:function componentDidMount(){this.checkSelectedCharacteristics();}/**
10
28
  * @param {Object} nextProps The next component props.
11
29
  */},{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(!this.props.variants&&nextProps.variants){// Initialize refs and characteristics when the variants prop was updated with a valid value.
12
- this.setRefs(nextProps);this.setState({characteristics:selectCharacteristics(nextProps)},this.checkSelectedCharacteristics);}}/**
13
- * Sets the refs to the characteristics selects.
14
- * @param {Object} props The props to check against.
15
- */},{key:"findUnselectedCharacteristic",/**
30
+ this.setRefs(nextProps);this.setState({characteristics:selectCharacteristics(nextProps)},this.checkSelectedCharacteristics);}}},{key:"findUnselectedCharacteristic",value:/**
16
31
  * Finds the first unselected characteristic.
17
32
  * @return {Object|null}
18
- */value:function findUnselectedCharacteristic(){var characteristics=this.state.characteristics;var unselected=this.props.variants.characteristics.filter(function(_char2){return!characteristics.hasOwnProperty(_char2.id);});if(unselected.length){return unselected[0];}return null;}/**
33
+ */function findUnselectedCharacteristic(){var characteristics=this.state.characteristics;var unselected=this.props.variants.characteristics.filter(function(_char2){return!characteristics.hasOwnProperty(_char2.id);});if(unselected.length){return unselected[0];}return null;}/**
19
34
  * @return {JSX}
20
- */},{key:"render",value:function render(){var _this2=this;var characteristics=this.state.characteristics;var variants=this.props.variants;if(!variants){return null;}return React.createElement(VariantsContext.Provider,{value:this.state},variants.characteristics.map(function(_char3,index){var disabled=!isCharacteristicEnabled(characteristics,index);var selected=getSelectedValue(_char3.id,characteristics);var values=_this2.buildValues(characteristics,_char3.id,_char3.values,index,selected);return _this2.props.render({charRef:_this2.refsStore[_char3.id],disabled:disabled,highlight:_this2.state.highlight===_char3.id,id:_char3.id,key:_char3.id,label:_char3.label,swatch:!!_char3.swatch,// BETA
21
- select:_this2.handleSelection,selected:selected,values:values,resetHighlight:_this2.resetHighlight});}));}}]);return ProductCharacteristics;}(Component);_defineProperty(ProductCharacteristics,"defaultProps",{finishTimeout:0,variantId:null,variants:null/**
35
+ */},{key:"render",value:function render(){var _this3=this;var characteristics=this.state.characteristics;var variants=this.props.variants;if(!variants){return null;}return React.createElement(VariantsContext.Provider,{value:this.state},variants.characteristics.map(function(_char3,index){var disabled=!isCharacteristicEnabled(characteristics,index);var selected=getSelectedValue(_char3.id,characteristics);var values=_this3.buildValues(characteristics,_char3.id,_char3.values,index,selected);return _this3.props.render({charRef:_this3.refsStore[_char3.id],disabled:disabled,highlight:_this3.state.highlight===_char3.id,id:_char3.id,key:_char3.id,label:_char3.label,swatch:!!_char3.swatch,// BETA
36
+ select:_this3.handleSelection,selected:selected,values:values,resetHighlight:_this3.resetHighlight});}));}}]);}(Component);_defineProperty(ProductCharacteristics,"defaultProps",{finishTimeout:0,variantId:null,variants:null/**
22
37
  * @param {Object} props The component props.
23
38
  */});export default connect(ProductCharacteristics);
@@ -1,49 +1,58 @@
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{logger}from'@shopgate/pwa-core/helpers';import styles from"./style";import RangeSliderHandle from"./components/Handle";import{generateLinearEasingCallback,generateExponentialEasingCallback,getRangeStyle,getTouchPositionX,getAbsoluteValue,getRelativeValue}from"./helper";/**
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{logger}from'@shopgate/pwa-core/helpers';import styles from"./style";import RangeSliderHandle from"./components/Handle";import{generateLinearEasingCallback,generateExponentialEasingCallback,getRangeStyle,getTouchPositionX,getAbsoluteValue,getRelativeValue}from"./helper";/**
2
2
  * The range slider component.
3
3
  * @deprecated Will be remove in v7.0.0.
4
4
  * Please use `import { RangeSlider } from '@shopgate/engage/components'` instead.
5
- */var RangeSlider=/*#__PURE__*/function(_Component){_inherits(RangeSlider,_Component);/**
5
+ */var RangeSlider=/*#__PURE__*/function(_Component){/**
6
6
  * Constructor
7
7
  * @param {Object} props The component properties
8
- */function RangeSlider(props){var _this;_classCallCheck(this,RangeSlider);_this=_possibleConstructorReturn(this,_getPrototypeOf(RangeSlider).call(this,props));_defineProperty(_assertThisInitialized(_this),"handleTouchStart",function(event,index){_this.draggedHandle=index;// Calculate the relative offset to the handles center
8
+ */function RangeSlider(props){var _this2;_classCallCheck(this,RangeSlider);_this2=_callSuper(this,RangeSlider,[props]);/**
9
+ * Processes touch start events on handles.
10
+ * @param {Object} event The touch event
11
+ * @param {number} index The index of the touched handle.
12
+ */_defineProperty(_this2,"handleTouchStart",function(event,index){_this2.draggedHandle=index;// Calculate the relative offset to the handles center
9
13
  var handleDOMElement=event.target;// Get the handles bounding rectangle ...
10
14
  var handleRect=handleDOMElement.getBoundingClientRect();// ... and calculate its absolute center.
11
15
  var handleCenterX=handleRect.left+handleDOMElement.offsetWidth/2;// Store the signed distanced between the current touch offset and the handle center.
12
- _this.touchOffset=getTouchPositionX(event)-handleCenterX;});_defineProperty(_assertThisInitialized(_this),"handleTouchMove",function(event){if(_this.props.min===_this.props.max){return;}if(_this.draggedHandle===null){return;}var _this$domElement=_this.domElement,offsetWidth=_this$domElement.offsetWidth,offsetLeft=_this$domElement.offsetLeft;// Calculate the absolute offset where the element was touched...
13
- var deltaX=getTouchPositionX(event)-offsetLeft-_this.touchOffset;// ...and convert it into a relative value between [0...1].
14
- deltaX=Math.max(0,Math.min(1,deltaX/offsetWidth));var stateUpdate={};if(_this.draggedHandle===1){// Right handle dragged
15
- if(_this.state.rangeMin<deltaX){stateUpdate.rangeMax=Math.min(1,deltaX);_this.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMax-_this.state.rangeMax);}else{// Not in valid range, swap handles
16
- _this.draggedHandle=0;stateUpdate.rangeMax=_this.state.rangeMin;stateUpdate.rangeMin=deltaX;_this.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMin-_this.state.rangeMin);}}else if(_this.draggedHandle===0){// Left handle dragged
17
- if(_this.state.rangeMax>deltaX){stateUpdate.rangeMin=Math.max(0,deltaX);_this.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMin-_this.state.rangeMin);}else{// Not in valid range, swap handles
18
- _this.draggedHandle=1;stateUpdate.rangeMin=_this.state.rangeMax;stateUpdate.rangeMax=deltaX;_this.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMax-_this.state.rangeMax);}}_this.draggedHandlePixelOffset*=_this.domElement.offsetWidth;_this.setState(stateUpdate,_this.triggerChangeCallback);});_defineProperty(_assertThisInitialized(_this),"handleTouchEnd",function(){_this.touchOffset=0;_this.draggedHandle=null;});_defineProperty(_assertThisInitialized(_this),"handleRangeTouch",function(event){var _this$domElement2=_this.domElement,offsetWidth=_this$domElement2.offsetWidth,offsetLeft=_this$domElement2.offsetLeft;var dx=(getTouchPositionX(event)-offsetLeft)/offsetWidth;var d0=Math.abs(_this.state.rangeMin-dx);var d1=Math.abs(_this.state.rangeMax-dx);if(d0<d1){_this.draggedHandle=0;}else{_this.draggedHandle=1;}_this.handleTouchMove(event);});logger.warn('===== RangeSlider deprecated =====\nThe RangeSlider component and it\'s related components (@shopgate/pwa-common/component/RangeSlider) are deprecated and will be removed in @shopgate/engage v7.0.0.\nPlease use: import { RangeSlider } from \'@shopgate/engage/components\'.\n===================================');_this.draggedHandle=null;// 0 for left handle, 1 for right handle or null
19
- _this.domElement=null;_this.touchOffset=0;_this.draggedHandlePixelOffset=0;// The absolute pixel delta of the last handle move event.
20
- _this.state=_this.getRange(props);return _this;}/**
16
+ _this2.touchOffset=getTouchPositionX(event)-handleCenterX;});/**
17
+ * Processes move events on handles.
18
+ * @param {Object} event The touch event
19
+ */_defineProperty(_this2,"handleTouchMove",function(event){if(_this2.props.min===_this2.props.max){return;}if(_this2.draggedHandle===null){return;}var _this2$domElement=_this2.domElement,offsetWidth=_this2$domElement.offsetWidth,offsetLeft=_this2$domElement.offsetLeft;// Calculate the absolute offset where the element was touched...
20
+ var deltaX=getTouchPositionX(event)-offsetLeft-_this2.touchOffset;// ...and convert it into a relative value between [0...1].
21
+ deltaX=Math.max(0,Math.min(1,deltaX/offsetWidth));var stateUpdate={};if(_this2.draggedHandle===1){// Right handle dragged
22
+ if(_this2.state.rangeMin<deltaX){stateUpdate.rangeMax=Math.min(1,deltaX);_this2.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMax-_this2.state.rangeMax);}else{// Not in valid range, swap handles
23
+ _this2.draggedHandle=0;stateUpdate.rangeMax=_this2.state.rangeMin;stateUpdate.rangeMin=deltaX;_this2.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMin-_this2.state.rangeMin);}}else if(_this2.draggedHandle===0){// Left handle dragged
24
+ if(_this2.state.rangeMax>deltaX){stateUpdate.rangeMin=Math.max(0,deltaX);_this2.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMin-_this2.state.rangeMin);}else{// Not in valid range, swap handles
25
+ _this2.draggedHandle=1;stateUpdate.rangeMin=_this2.state.rangeMax;stateUpdate.rangeMax=deltaX;_this2.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMax-_this2.state.rangeMax);}}_this2.draggedHandlePixelOffset*=_this2.domElement.offsetWidth;_this2.setState(stateUpdate,_this2.triggerChangeCallback);});/**
26
+ * Processes global touch end events for handles.
27
+ * @param {Object} e The touch event
28
+ */_defineProperty(_this2,"handleTouchEnd",function(){_this2.touchOffset=0;_this2.draggedHandle=null;});/**
29
+ * Processes outer range touch end events.
30
+ * @param {Object} event The touch event
31
+ */_defineProperty(_this2,"handleRangeTouch",function(event){var _this2$domElement2=_this2.domElement,offsetWidth=_this2$domElement2.offsetWidth,offsetLeft=_this2$domElement2.offsetLeft;var dx=(getTouchPositionX(event)-offsetLeft)/offsetWidth;var d0=Math.abs(_this2.state.rangeMin-dx);var d1=Math.abs(_this2.state.rangeMax-dx);if(d0<d1){_this2.draggedHandle=0;}else{_this2.draggedHandle=1;}_this2.handleTouchMove(event);});logger.warn('===== RangeSlider deprecated =====\nThe RangeSlider component and it\'s related components (@shopgate/pwa-common/component/RangeSlider) are deprecated and will be removed in @shopgate/engage v7.0.0.\nPlease use: import { RangeSlider } from \'@shopgate/engage/components\'.\n===================================');_this2.draggedHandle=null;// 0 for left handle, 1 for right handle or null
32
+ _this2.domElement=null;_this2.touchOffset=0;_this2.draggedHandlePixelOffset=0;// The absolute pixel delta of the last handle move event.
33
+ _this2.state=_this2.getRange(props);return _this2;}/**
21
34
  * Sets the global event listeners when component mounts.
22
- */_createClass(RangeSlider,[{key:"componentDidMount",value:function componentDidMount(){document.addEventListener('touchend',this.handleTouchEnd);document.addEventListener('touchmove',this.handleTouchMove);}/**
35
+ */_inherits(RangeSlider,_Component);return _createClass(RangeSlider,[{key:"componentDidMount",value:function componentDidMount(){document.addEventListener('touchend',this.handleTouchEnd);document.addEventListener('touchmove',this.handleTouchMove);}/**
23
36
  * Updates the component properties.
24
37
  * @param {Object} newProps The new component properties.
25
38
  */},{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(newProps){this.setState(this.getRange(newProps));}/**
26
39
  * Removes the global event listeners when component unmounts.
27
40
  */},{key:"componentWillUnmount",value:function componentWillUnmount(){document.removeEventListener('touchend',this.handleTouchEnd);document.removeEventListener('touchmove',this.handleTouchMove);}/**
28
41
  * Get the easing function.
29
- */},{key:"getRange",/**
42
+ */},{key:"ease",get:function get(){return{linear:generateLinearEasingCallback(this.props.resolution),exponential:generateExponentialEasingCallback(this.props.factor)}[this.props.easing];}/**
43
+ * Get the function to invert an eased value to it's original value.
44
+ */},{key:"invertedEase",get:function get(){return{linear:generateLinearEasingCallback(this.props.resolution),exponential:generateExponentialEasingCallback(1/this.props.factor)}[this.props.easing];}/**
30
45
  * Get range min and max from props.
31
46
  * @param {Object} props The component props.
32
47
  * @returns {Object} The new state
33
- */value:function getRange(props){var value=props.value,min=props.min,max=props.max;return{rangeMin:this.invertedEase(getRelativeValue(value[0],min,max)),rangeMax:this.invertedEase(getRelativeValue(value[1],min,max))};}/**
34
- * Processes touch start events on handles.
35
- * @param {Object} event The touch event
36
- * @param {number} index The index of the touched handle.
37
- */},{key:"triggerChangeCallback",/**
48
+ */},{key:"getRange",value:function getRange(props){var value=props.value,min=props.min,max=props.max;return{rangeMin:this.invertedEase(getRelativeValue(value[0],min,max)),rangeMax:this.invertedEase(getRelativeValue(value[1],min,max))};}},{key:"triggerChangeCallback",value:/**
38
49
  * Calls the change callback in case of a state update.
39
- */value:function triggerChangeCallback(){var _this$props=this.props,value=_this$props.value,onChange=_this$props.onChange,min=_this$props.min,max=_this$props.max;if(!onChange){return;}var newRange=[getAbsoluteValue(this.ease(this.state.rangeMin),min,max,true),getAbsoluteValue(this.ease(this.state.rangeMax),min,max,true)];if(newRange!==value){onChange(newRange);}}/**
50
+ */function triggerChangeCallback(){var _this$props=this.props,value=_this$props.value,onChange=_this$props.onChange,min=_this$props.min,max=_this$props.max;if(!onChange){return;}var newRange=[getAbsoluteValue(this.ease(this.state.rangeMin),min,max,true),getAbsoluteValue(this.ease(this.state.rangeMax),min,max,true)];if(newRange!==value){onChange(newRange);}}/**
40
51
  * Creates a new handle component.
41
52
  * @param {number} index The index of the component. Must be either 0 or 1.
42
53
  * @returns {JSX}
43
54
  */},{key:"makeHandle",value:function makeHandle(index){return React.createElement(RangeSliderHandle,{index:index,onTouchStart:this.handleTouchStart,active:this.draggedHandle===index,classNames:this.props.classNames});}/**
44
55
  * Renders the component.
45
56
  * @returns {JSX}
46
- */},{key:"render",value:function render(){var _this2=this;// Calculate the animation speed.
47
- var animationSpeed=Math.round(1000/this.props.animationSpeed*this.draggedHandlePixelOffset);var rangeStyle=getRangeStyle(this.state.rangeMin,this.state.rangeMax,animationSpeed>10?animationSpeed:0);return React.createElement("div",{className:this.props.classNames.container||'',onTouchStart:this.handleRangeTouch},React.createElement("div",{className:"".concat(this.props.classNames.outerRange||''," ").concat(styles.outerRange),ref:function ref(_ref){_this2.domElement=_ref;}},React.createElement("div",{className:"".concat(this.props.classNames.range||''," ").concat(styles.range),style:rangeStyle},this.makeHandle(0),this.makeHandle(1))));}},{key:"ease",get:function get(){return{linear:generateLinearEasingCallback(this.props.resolution),exponential:generateExponentialEasingCallback(this.props.factor)}[this.props.easing];}/**
48
- * Get the function to invert an eased value to it's original value.
49
- */},{key:"invertedEase",get:function get(){return{linear:generateLinearEasingCallback(this.props.resolution),exponential:generateExponentialEasingCallback(1/this.props.factor)}[this.props.easing];}}]);return RangeSlider;}(Component);_defineProperty(RangeSlider,"defaultProps",{animationSpeed:500,classNames:{},easing:'linear',factor:2,max:100,min:0,resolution:1,value:[0,100],onChange:null});export default RangeSlider;
57
+ */},{key:"render",value:function render(){var _this3=this;// Calculate the animation speed.
58
+ var animationSpeed=Math.round(1000/this.props.animationSpeed*this.draggedHandlePixelOffset);var rangeStyle=getRangeStyle(this.state.rangeMin,this.state.rangeMax,animationSpeed>10?animationSpeed:0);return React.createElement("div",{className:"".concat(this.props.classNames.container||''," common__range-slider"),onTouchStart:this.handleRangeTouch},React.createElement("div",{className:"".concat(this.props.classNames.outerRange||''," ").concat(styles.outerRange),ref:function ref(_ref){_this3.domElement=_ref;}},React.createElement("div",{className:"".concat(this.props.classNames.range||''," ").concat(styles.range),style:rangeStyle},this.makeHandle(0),this.makeHandle(1))));}}]);}(Component);_defineProperty(RangeSlider,"defaultProps",{animationSpeed:500,classNames:{},easing:'linear',factor:2,max:100,min:0,resolution:1,value:[0,100],onChange:null});export default RangeSlider;
@@ -1,5 +1,5 @@
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 _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 _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 from'react';import PropTypes from'prop-types';import{router}from'@virtuous/conductor';import{RouteContext,RouterContext}from'@virtuous/react-conductor';import ErrorBoundary from"../ErrorBoundary";/**
1
+ var _excluded=["setPattern"];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 _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);}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 from'react';import PropTypes from'prop-types';import{router}from'@virtuous/conductor';import{RouteContext,RouterContext}from'@virtuous/react-conductor';import ErrorBoundary from"../ErrorBoundary";/**
2
2
  * The RouteNotFound component
3
- */var RouteNotFound=/*#__PURE__*/function(_React$Component){_inherits(RouteNotFound,_React$Component);function RouteNotFound(){_classCallCheck(this,RouteNotFound);return _possibleConstructorReturn(this,_getPrototypeOf(RouteNotFound).apply(this,arguments));}_createClass(RouteNotFound,[{key:"render",/**
3
+ */var RouteNotFound=/*#__PURE__*/function(_React$Component){function RouteNotFound(){_classCallCheck(this,RouteNotFound);return _callSuper(this,RouteNotFound,arguments);}_inherits(RouteNotFound,_React$Component);return _createClass(RouteNotFound,[{key:"currentRoute",get:function get(){var _this$context$stack$r=_slicedToArray(this.context.stack[router.routeIndex],2),route=_this$context$stack$r[1];return route;}/**
4
4
  * @returns {JSX}
5
- */value:function render(){if(router.match(this.currentRoute.pathname)){return null;}var Component=this.props.component;var _this$currentRoute=this.currentRoute,setPattern=_this$currentRoute.setPattern,context=_objectWithoutProperties(_this$currentRoute,["setPattern"]);context.open=true;context.visible=true;return React.createElement(ErrorBoundary,{key:"error.404"},React.createElement(RouteContext.Provider,{key:"404",value:context},React.createElement(Component,null)));}},{key:"currentRoute",get:function get(){var _this$context$stack$r=_slicedToArray(this.context.stack[router.routeIndex],2),route=_this$context$stack$r[1];return route;}}]);return RouteNotFound;}(React.Component);_defineProperty(RouteNotFound,"contextType",RouterContext);export default RouteNotFound;
5
+ */},{key:"render",value:function render(){if(router.match(this.currentRoute.pathname)){return null;}var Component=this.props.component;var _this$currentRoute=this.currentRoute,setPattern=_this$currentRoute.setPattern,context=_objectWithoutProperties(_this$currentRoute,_excluded);context.open=true;context.visible=true;context.pattern='';context.is404=true;return React.createElement(ErrorBoundary,{key:"error.404"},React.createElement(RouteContext.Provider,{key:"404",value:context},React.createElement(Component,null)));}}]);}(React.Component);_defineProperty(RouteNotFound,"contextType",RouterContext);export default RouteNotFound;
@@ -1,12 +1,12 @@
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 _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);}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,{Suspense}from'react';import PropTypes from'prop-types';import{router}from'@virtuous/conductor';import{RouteContext,RouterContext}from'@virtuous/react-conductor';import Loading from"../Loading";import ErrorBoundary from"../ErrorBoundary";import RouteNotFound from"./RouteNotFound";/**
1
+ var _excluded=["setPattern"];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 _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);}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,{Suspense}from'react';import PropTypes from'prop-types';import{router}from'@virtuous/conductor';import{RouteContext,RouterContext}from'@virtuous/react-conductor';import Loading from"../Loading";import ErrorBoundary from"../ErrorBoundary";import RouteNotFound from"./RouteNotFound";/**
2
2
  * The Route component.
3
- */var Route=/*#__PURE__*/function(_React$Component){_inherits(Route,_React$Component);function Route(props){var _this;_classCallCheck(this,Route);_this=_possibleConstructorReturn(this,_getPrototypeOf(Route).call(this,props));router.register(props.pattern,props.transform);return _this;}/**
3
+ */var Route=/*#__PURE__*/function(_React$Component){function Route(props){var _this2;_classCallCheck(this,Route);_this2=_callSuper(this,Route,[props]);router.register(props.pattern,props.transform);return _this2;}/**
4
4
  * TODO: Move to router
5
- */_createClass(Route,[{key:"render",/**
5
+ */_inherits(Route,_React$Component);return _createClass(Route,[{key:"currentRoute",get:function get(){var _this$context$stack$r=_slicedToArray(this.context.stack[router.routeIndex],2),route=_this$context$stack$r[1];return route;}/**
6
6
  * @returns {JSX}
7
- */value:function render(){var _this2=this;var _this$props=this.props,cache=_this$props.cache,Component=_this$props.component,pattern=_this$props.pattern;var matches=[];// If the current pattern does not match the whitelist but matches the current route
7
+ */},{key:"render",value:function render(){var _this3=this;var _this$props=this.props,cache=_this$props.cache,Component=_this$props.component,pattern=_this$props.pattern;var matches=[];// If the current pattern does not match the whitelist but matches the current route
8
8
  // then add the current route as the only match.
9
9
  if(!cache&&pattern===this.currentRoute.pattern){matches=[[this.currentRoute.id,this.currentRoute]];}else if(cache){var subset=this.context.stack.slice(0,router.routeIndex+1);// Find matching patterns.
10
- matches=subset.filter(function(_ref){var _ref2=_slicedToArray(_ref,2),route=_ref2[1];return route.pattern===pattern;});}if(!matches.length){return null;}return matches.map(function(_ref3){var _ref4=_slicedToArray(_ref3,2),route=_ref4[1];var setPattern=route.setPattern,context=_objectWithoutProperties(route,["setPattern"]);context.open=true;context.visible=route.id===_this2.currentRoute.id;return React.createElement(ErrorBoundary,{key:"error.".concat(route.id)},React.createElement(RouteContext.Provider,{key:route.id,value:context},React.createElement(Suspense,{fallback:React.createElement(Loading,null)},React.createElement(Component,null))));});}},{key:"currentRoute",get:function get(){var _this$context$stack$r=_slicedToArray(this.context.stack[router.routeIndex],2),route=_this$context$stack$r[1];return route;}}]);return Route;}(React.Component);_defineProperty(Route,"contextType",RouterContext);_defineProperty(Route,"NotFound",RouteNotFound);_defineProperty(Route,"defaultProps",{cache:false,transform:null/**
10
+ matches=subset.filter(function(_ref){var _ref2=_slicedToArray(_ref,2),route=_ref2[1];return route.pattern===pattern;});}if(!matches.length){return null;}return matches.map(function(_ref3){var _ref4=_slicedToArray(_ref3,2),route=_ref4[1];var setPattern=route.setPattern,context=_objectWithoutProperties(route,_excluded);context.open=true;context.visible=route.id===_this3.currentRoute.id;return React.createElement(ErrorBoundary,{key:"error.".concat(route.id)},React.createElement(RouteContext.Provider,{key:route.id,value:context},React.createElement(Suspense,{fallback:React.createElement(Loading,null)},React.createElement(Component,null))));});}}]);}(React.Component);_defineProperty(Route,"contextType",RouterContext);_defineProperty(Route,"NotFound",RouteNotFound);_defineProperty(Route,"defaultProps",{cache:false,transform:null/**
11
11
  * @param {Object} props The component props.
12
12
  */});export default Route;
@@ -1,4 +1,4 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React from'react';import PropTypes from'prop-types';import{router,stack as routeStack,onDidPush,onDidPop,onDidReplace,onDidReset,onUpdate,ACTION_POP}from'@virtuous/conductor';import Route from'@virtuous/conductor/Route';import{RouterContext,Router as OrigRouter}from'@virtuous/react-conductor';import{UIEvents}from'@shopgate/pwa-core';import{hasSGJavaScriptBridge}from'@shopgate/pwa-core/helpers';import{hasWebBridge}from'@shopgate/engage/core';import{sanitizeLink}from"../../subscriptions/helpers/handleLinks";import authRoutes from"../../collections/AuthRoutes";import{EVENT_USER_INITIALIZED}from"../../constants/user";import connect from"./connector";/**
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;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React from'react';import PropTypes from'prop-types';import{router,stack as routeStack,onDidPush,onDidPop,onDidReplace,onDidReset,onUpdate,ACTION_POP}from'@virtuous/conductor';import Route from'@virtuous/conductor/Route';import{RouterContext,Router as OrigRouter}from'@virtuous/react-conductor';import{UIEvents}from'@shopgate/pwa-core';import{hasSGJavaScriptBridge}from'@shopgate/pwa-core/helpers';import{hasWebBridge}from'@shopgate/engage/core';import{sanitizeLink}from"../../subscriptions/helpers/handleLinks";import authRoutes from"../../collections/AuthRoutes";import{EVENT_USER_INITIALIZED}from"../../constants/user";import connect from"./connector";/**
2
2
  * Adds additional history listeners to compensate bugs and improve the behaviour within
3
3
  * browser environments.
4
4
  */var createBrowserListeners=function createBrowserListeners(){var history=router.history;// Remove the original listener from the router.
@@ -14,16 +14,26 @@ var pathname="".concat(locationPathname).concat(search).concat(hash);if(action==
14
14
  * object. The routing methods expect those parameters as part of the pathname.
15
15
  */router.handleNativeEvent(_extends({},location,{pathname:pathname}),action);}).bind(router);};/**
16
16
  * The Router component.
17
- */var Router=/*#__PURE__*/function(_React$Component){_inherits(Router,_React$Component);/**
17
+ */var Router=/*#__PURE__*/function(_React$Component){/**
18
18
  * @param {Object} props The component props.
19
- */function Router(props){var _this;_classCallCheck(this,Router);_this=_possibleConstructorReturn(this,_getPrototypeOf(Router).call(this,props));_defineProperty(_assertThisInitialized(_this),"setUserInitialized",function(){_this.setState({userInitialized:true});});_defineProperty(_assertThisInitialized(_this),"getHistoryLocation",function(){var _router$history$locat=router.history.location,hash=_router$history$locat.hash,pathname=_router$history$locat.pathname,search=_router$history$locat.search;return sanitizeLink("".concat(pathname).concat(search).concat(hash));});_defineProperty(_assertThisInitialized(_this),"getRouteProtector",function(){return authRoutes.getProtector(_this.getHistoryLocation());});_defineProperty(_assertThisInitialized(_this),"update",function(data){var prev=data.prev,next=data.next;if(data===null||data===void 0?void 0:data.id){/**
19
+ */function Router(props){var _this2;_classCallCheck(this,Router);_this2=_callSuper(this,Router,[props]);/**
20
+ * Updates the user initialized component state
21
+ */_defineProperty(_this2,"setUserInitialized",function(){_this2.setState({userInitialized:true});});/**
22
+ * Determines the current location from the browser history
23
+ * @returns {string}
24
+ */_defineProperty(_this2,"getHistoryLocation",function(){var _router$history$locat=router.history.location,hash=_router$history$locat.hash,pathname=_router$history$locat.pathname,search=_router$history$locat.search;return sanitizeLink("".concat(pathname).concat(search).concat(hash));});/**
25
+ * Determines if the current route is a protected route
26
+ * @returns {null|string}
27
+ */_defineProperty(_this2,"getRouteProtector",function(){return authRoutes.getProtector(_this2.getHistoryLocation());});/**
28
+ * @param {Object} data Data for the update method
29
+ */_defineProperty(_this2,"update",function(data){var prev=data.prev,next=data.next;if(data===null||data===void 0?void 0:data.id){/**
20
30
  * The only change right now compared to the original component. When invoked for "onUpdate"
21
31
  * only the updated route is passed instead of an object with prev and next.
22
- */_this.setState({updated:Date.now()});return;}_this.setState({prev:prev?prev.id:null,next:next.id,updated:Date.now()});});if(typeof props.history==='function'){router.constructor(props.history);}_this.state={prev:null,next:null,updated:null,userInitialized:false,initialRouteProtected:!!_this.getRouteProtector()};UIEvents.addListener(EVENT_USER_INITIALIZED,_this.setUserInitialized);onDidPush(_this.update);onDidPop(_this.update);onDidReplace(_this.update);onDidReset(_this.update);onUpdate(_this.update);if(hasWebBridge()||hasSGJavaScriptBridge()){createBrowserListeners();}return _this;}/**
32
+ */_this2.setState({updated:Date.now()});return;}_this2.setState({prev:prev?prev.id:null,next:next.id,updated:Date.now()});});if(typeof props.history==='function'){router.constructor(props.history);}_this2.state={prev:null,next:null,updated:null,userInitialized:false,initialRouteProtected:!!_this2.getRouteProtector()};UIEvents.addListener(EVENT_USER_INITIALIZED,_this2.setUserInitialized);onDidPush(_this2.update);onDidPop(_this2.update);onDidReplace(_this2.update);onDidReset(_this2.update);onUpdate(_this2.update);if(hasWebBridge()||hasSGJavaScriptBridge()){createBrowserListeners();}return _this2;}/**
23
33
  * @param {Object} nextProps The next component props.
24
34
  * @param {Object} nextState The next component state.
25
35
  * @returns {boolean}
26
- */_createClass(Router,[{key:"shouldComponentUpdate",value:function shouldComponentUpdate(nextProps,nextState){var isUserLoggedIn=this.props.isUserLoggedIn;var _this$state=this.state,updated=_this$state.updated,userInitialized=_this$state.userInitialized;return updated!==nextState.updated||userInitialized!==nextState.userInitialized||isUserLoggedIn!==nextProps.isUserLoggedIn;}/**
36
+ */_inherits(Router,_React$Component);return _createClass(Router,[{key:"shouldComponentUpdate",value:function shouldComponentUpdate(nextProps,nextState){var isUserLoggedIn=this.props.isUserLoggedIn;var _this$state=this.state,updated=_this$state.updated,userInitialized=_this$state.userInitialized;return updated!==nextState.updated||userInitialized!==nextState.userInitialized||isUserLoggedIn!==nextProps.isUserLoggedIn;}/**
27
37
  * Replaces the initial route with a protector if necessary
28
38
  * @param {Object} nextProps The next component props
29
39
  * @param {Object} nextState The next components state
@@ -33,11 +43,9 @@ var state={redirect:{location:location}};var routeReplacement=new Route({id:id,s
33
43
  routeStack.update(id,routeReplacement);// Update the browser url with the protector route
34
44
  router.history.replace({pathname:protector,state:_extends({},state,{route:{id:id}})});this.setState({initialRouteProtected:false});}}/**
35
45
  * Removes the listener for the EVENT_USER_INITIALIZED event
36
- */},{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(EVENT_USER_INITIALIZED,this.setUserInitialized);}/**
37
- * Updates the user initialized component state
38
- */},{key:"render",/**
46
+ */},{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(EVENT_USER_INITIALIZED,this.setUserInitialized);}},{key:"render",value:/**
39
47
  * @returns {JSX}
40
- */value:function render(){var children=this.props.children;var _this$state2=this.state,prev=_this$state2.prev,next=_this$state2.next,initialRouteProtected=_this$state2.initialRouteProtected,userInitialized=_this$state2.userInitialized;if(initialRouteProtected&&!userInitialized){/**
48
+ */function render(){var children=this.props.children;var _this$state2=this.state,prev=_this$state2.prev,next=_this$state2.next,initialRouteProtected=_this$state2.initialRouteProtected,userInitialized=_this$state2.userInitialized;if(initialRouteProtected&&!userInitialized){/**
41
49
  * When the initial route is a protected route, the first rendering of the Router needs to
42
50
  * be postponed till we know the final login state of the user.
43
- */return null;}var stack=Array.from(routeStack.getAll());return React.createElement(RouterContext.Provider,{value:{prev:prev,next:next,stack:stack}},children);}}]);return Router;}(React.Component);_defineProperty(Router,"defaultProps",{history:null,isUserLoggedIn:false});_defineProperty(Router,"Push",OrigRouter.Push);_defineProperty(Router,"Pop",OrigRouter.Pop);_defineProperty(Router,"Replace",OrigRouter.Replace);_defineProperty(Router,"Reset",OrigRouter.Reset);_defineProperty(Router,"ResetTo",OrigRouter.ResetTo);export default connect(Router);
51
+ */return null;}var stack=Array.from(routeStack.getAll());return React.createElement(RouterContext.Provider,{value:{prev:prev,next:next,stack:stack}},children);}}]);}(React.Component);_defineProperty(Router,"defaultProps",{history:null,isUserLoggedIn:false});_defineProperty(Router,"Push",OrigRouter.Push);_defineProperty(Router,"Pop",OrigRouter.Pop);_defineProperty(Router,"Replace",OrigRouter.Replace);_defineProperty(Router,"Reset",OrigRouter.Reset);_defineProperty(Router,"ResetTo",OrigRouter.ResetTo);export default connect(Router);
@@ -1,11 +1,11 @@
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);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Fragment,PureComponent}from'react';import PropTypes from'prop-types';import AppScanner from'@shopgate/pwa-core/classes/Scanner';import connect from"./connector";/**
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);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Fragment,PureComponent}from'react';import PropTypes from'prop-types';import AppScanner from'@shopgate/pwa-core/classes/Scanner';import connect from"./connector";/**
2
2
  * Wraps the Scanner overlay with functionality to automatically open and close the scanner,
3
3
  * as well as triggering the removal and reset of the background.
4
- */var ScannerContainer=/*#__PURE__*/function(_PureComponent){_inherits(ScannerContainer,_PureComponent);function ScannerContainer(){_classCallCheck(this,ScannerContainer);return _possibleConstructorReturn(this,_getPrototypeOf(ScannerContainer).apply(this,arguments));}_createClass(ScannerContainer,[{key:"componentDidMount",value:function(){var _componentDidMount=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:if(this.props.hasScannerSupport){_context.next=2;break;}return _context.abrupt("return");case 2:_context.next=4;return AppScanner.open(this.props.scope,this.props.type);case 4:this.props.scannerDidOpen();case 5:case"end":return _context.stop();}}},_callee,this);}));function componentDidMount(){return _componentDidMount.apply(this,arguments);}return componentDidMount;}()/**
4
+ */var ScannerContainer=/*#__PURE__*/function(_PureComponent){function ScannerContainer(){_classCallCheck(this,ScannerContainer);return _callSuper(this,ScannerContainer,arguments);}_inherits(ScannerContainer,_PureComponent);return _createClass(ScannerContainer,[{key:"componentDidMount",value:function(){var _componentDidMount=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(this.props.hasScannerSupport){_context.next=2;break;}return _context.abrupt("return");case 2:_context.next=4;return AppScanner.open(this.props.scope,this.props.type);case 4:this.props.scannerDidOpen();case 5:case"end":return _context.stop();}},_callee,this);}));function componentDidMount(){return _componentDidMount.apply(this,arguments);}return componentDidMount;}()/**
5
5
  * Shut down the app scanner.
6
6
  */},{key:"componentWillUnmount",value:function componentWillUnmount(){if(!this.props.hasScannerSupport){return;}this.props.scannerDidClose();AppScanner.close();}/**
7
7
  * Does not render anything when the app does not support the scanner.
8
8
  * @returns {JSX}
9
- */},{key:"render",value:function render(){return React.createElement(Fragment,null,this.props.hasScannerSupport&&this.props.children);}}]);return ScannerContainer;}(PureComponent);_defineProperty(ScannerContainer,"defaultProps",{children:null,scannerDidClose:function scannerDidClose(){},scannerDidOpen:function scannerDidOpen(){}/**
9
+ */},{key:"render",value:function render(){return React.createElement(Fragment,null,this.props.hasScannerSupport&&this.props.children);}}]);}(PureComponent);_defineProperty(ScannerContainer,"defaultProps",{children:null,scannerDidClose:function scannerDidClose(){},scannerDidOpen:function scannerDidOpen(){}/**
10
10
  * Starts up the app scanner.
11
11
  */});export default connect(ScannerContainer);
@@ -1,4 +1,4 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import styles from"./style";import SelectItem from"./components/Item";var DEFAULT_PLACEHOLDER_TEXT='Select ...';/**
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 styles from"./style";import SelectItem from"./components/Item";var DEFAULT_PLACEHOLDER_TEXT='Select ...';/**
2
2
  * Finds an item in a list of items by value.
3
3
  * @param {Array} items - The list of items.
4
4
  * @param {*} value - The value to look for.
@@ -12,26 +12,36 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
12
12
  * The select component.
13
13
  * @param {Object} props - The component props.
14
14
  * @param {React.Children} props.children - Some content to display inside.
15
- */var Select=/*#__PURE__*/function(_Component){_inherits(Select,_Component);/**
16
- * The component prop types.
17
- * @type {Object}
18
- */ /**
19
- * The component default props.
20
- * @type {Object}
21
- */ /**
15
+ */var Select=/*#__PURE__*/function(_Component){/**
22
16
  * The constructor.
23
17
  * @param {Object} props - The component props.
24
- */function Select(props){var _this;_classCallCheck(this,Select);_this=_possibleConstructorReturn(this,_getPrototypeOf(Select).call(this,props));_defineProperty(_assertThisInitialized(_this),"triggerChangeCallback",function(nextState){if(_this.state.selected&&_this.state.selected.value===nextState.selected.value){return;}if(_this.props.onChange instanceof Function){_this.props.onChange(nextState.selected.value);}});_defineProperty(_assertThisInitialized(_this),"handleInteractionOutside",function(event){if(!_this.domElement.contains(event.target)){_this.setState({isOpen:false});}});_defineProperty(_assertThisInitialized(_this),"handleItemSelect",function(value,label){var stateUpdate={selected:{label:label,value:value},isOpen:false};_this.triggerChangeCallback(stateUpdate);_this.setState(stateUpdate);});_defineProperty(_assertThisInitialized(_this),"toggleOpenState",function(){_this.setState(function(_ref){var isOpen=_ref.isOpen;return{isOpen:!isOpen};});});_this.state={selected:null,isOpen:false};_this.domElement=null;if(props.value){_this.state.selected=normalizeItem(findItemByValue(props.items,props.value));}return _this;}/**
18
+ */function Select(props){var _this2;_classCallCheck(this,Select);_this2=_callSuper(this,Select,[props]);/**
19
+ * Triggers the onChange callback if the selected value has changed.
20
+ * @param {Object} nextState - The next state.
21
+ */_defineProperty(_this2,"triggerChangeCallback",function(nextState){if(_this2.state.selected&&_this2.state.selected.value===nextState.selected.value){return;}if(_this2.props.onChange instanceof Function){_this2.props.onChange(nextState.selected.value);}});/**
22
+ * Handles any interaction the user does outside of the component.
23
+ * In this case the select gets closed.
24
+ * @param {Event} event - The event of the user interaction (e.g. TouchEvent).
25
+ */_defineProperty(_this2,"handleInteractionOutside",function(event){if(!_this2.domElement.contains(event.target)){_this2.setState({isOpen:false});}});/**
26
+ * Gets called when a new item is selected
27
+ * @param {*} value - The selected value.
28
+ * @param {string} label - The selected label.
29
+ */_defineProperty(_this2,"handleItemSelect",function(value,label){var stateUpdate={selected:{label:label,value:value},isOpen:false};_this2.triggerChangeCallback(stateUpdate);_this2.setState(stateUpdate);});/**
30
+ * Toggles the open state of the component.
31
+ */_defineProperty(_this2,"toggleOpenState",function(){_this2.setState(function(_ref){var isOpen=_ref.isOpen;return{isOpen:!isOpen};});});_this2.state={selected:null,isOpen:false};_this2.domElement=null;if(props.value){_this2.state.selected=normalizeItem(findItemByValue(props.items,props.value));}return _this2;}/**
25
32
  * Adds event listener when the component is mounted.
26
- */_createClass(Select,[{key:"componentDidMount",value:function componentDidMount(){document.addEventListener('touchstart',this.handleInteractionOutside);}/**
33
+ */_inherits(Select,_Component);return _createClass(Select,[{key:"componentDidMount",value:function componentDidMount(){document.addEventListener('touchstart',this.handleInteractionOutside);}/**
27
34
  * Updates the selected item when the value prop changes.
28
35
  * @param {Object} nextProps - The next props.
29
36
  */},{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(!this.state.selected||nextProps.value!==this.state.selected.value){this.state.selected=normalizeItem(findItemByValue(nextProps.items,nextProps.value));}}/**
30
37
  * Removes event listener when the component will unmount.
31
- */},{key:"componentWillUnmount",value:function componentWillUnmount(){document.removeEventListener('touchstart',this.handleInteractionOutside);}/**
32
- * Triggers the onChange callback if the selected value has changed.
33
- * @param {Object} nextState - The next state.
34
- */},{key:"render",/**
38
+ */},{key:"componentWillUnmount",value:function componentWillUnmount(){document.removeEventListener('touchstart',this.handleInteractionOutside);}},{key:"render",value:/**
35
39
  * Renders the component.
36
40
  * @returns {JSX}
37
- */value:function render(){var _this2=this;var hasSelection=this.state.selected&&this.state.selected.value!==undefined;var selectedLabel=hasSelection?this.state.selected.label:this.props.placeholder;var items=this.state.isOpen?React.createElement("div",{className:styles.items},this.props.items.map(function(item){var normalizedItem=normalizeItem(item);var selected=hasSelection&&_this2.state.selected.value===normalizedItem.value;return React.createElement(SelectItem,{key:normalizedItem.value,value:normalizedItem.value,label:normalizedItem.label,selected:selected,onSelect:_this2.handleItemSelect});})):null;return React.createElement("div",{className:"".concat(styles.container," ").concat(this.props.className),ref:function ref(_ref2){_this2.domElement=_ref2;}},React.createElement("div",{onTouchStart:this.toggleOpenState},React.createElement("span",null,selectedLabel),React.createElement("span",{className:styles.selectHandle},"\u25BE")),items);}}]);return Select;}(Component);_defineProperty(Select,"defaultProps",{className:'',items:[],onChange:function onChange(){},placeholder:DEFAULT_PLACEHOLDER_TEXT,value:null});export default Select;
41
+ */function render(){var _this3=this;var hasSelection=this.state.selected&&this.state.selected.value!==undefined;var selectedLabel=hasSelection?this.state.selected.label:this.props.placeholder;var items=this.state.isOpen?React.createElement("div",{className:styles.items},this.props.items.map(function(item){var normalizedItem=normalizeItem(item);var selected=hasSelection&&_this3.state.selected.value===normalizedItem.value;return React.createElement(SelectItem,{key:normalizedItem.value,value:normalizedItem.value,label:normalizedItem.label,selected:selected,onSelect:_this3.handleItemSelect});})):null;return React.createElement("div",{className:"".concat(styles.container," ").concat(this.props.className," common_select"),ref:function ref(_ref2){_this3.domElement=_ref2;}},React.createElement("div",{onTouchStart:this.toggleOpenState},React.createElement("span",null,selectedLabel),React.createElement("span",{className:styles.selectHandle},"\u25BE")),items);}}]);}(Component);/**
42
+ * The component prop types.
43
+ * @type {Object}
44
+ */ /**
45
+ * The component default props.
46
+ * @type {Object}
47
+ */_defineProperty(Select,"defaultProps",{className:'',items:[],onChange:function onChange(){},placeholder:DEFAULT_PLACEHOLDER_TEXT,value:null});export default Select;
@@ -1,8 +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 _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 classNames from'classnames';import PropTypes from'prop-types';import I18n from"../../../I18n";import{item}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 classNames from'classnames';import PropTypes from'prop-types';import I18n from"../../../I18n";import{item}from"./style";/**
2
2
  * The SelectBoxItem component.
3
3
  * @param {Object} props The components props.
4
4
  * @returns {JSX}
5
- */var SelectBoxItem=/*#__PURE__*/function(_Component){_inherits(SelectBoxItem,_Component);function SelectBoxItem(){var _getPrototypeOf2;var _this;_classCallCheck(this,SelectBoxItem);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_possibleConstructorReturn(this,(_getPrototypeOf2=_getPrototypeOf(SelectBoxItem)).call.apply(_getPrototypeOf2,[this].concat(args)));_defineProperty(_assertThisInitialized(_this),"handleSelectionUpdate",function(){_this.props.handleSelectionUpdate(_this.props.value);});return _this;}_createClass(SelectBoxItem,[{key:"render",/**
5
+ */var SelectBoxItem=/*#__PURE__*/function(_Component){function SelectBoxItem(){var _this2;_classCallCheck(this,SelectBoxItem);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this2=_callSuper(this,SelectBoxItem,[].concat(args));/**
6
+ * Calls the handleSelectionUpdate prop and prevents further events.
7
+ */_defineProperty(_this2,"handleSelectionUpdate",function(){_this2.props.handleSelectionUpdate(_this2.props.value);});return _this2;}_inherits(SelectBoxItem,_Component);return _createClass(SelectBoxItem,[{key:"render",value:/**
6
8
  * Renders the component
7
9
  * @returns {JSX}
8
- */value:function render(){var Wrapper=this.props.wrapper;var _this$props$className=this.props.classNames,selectItem=_this$props$className.selectItem,selectItemSelected=_this$props$className.selectItemSelected;return React.createElement("li",{className:classNames(selectItem,item,_defineProperty({},selectItemSelected,this.props.isSelected)),onKeyUp:function onKeyUp(){},onClick:this.handleSelectionUpdate,"data-test-id":this.props.label,role:"menuitem",ref:this.props.forwardedRef,tabIndex:this.props.isSelected?'0':'-1',"aria-current":this.props.isSelected},React.createElement(Wrapper,null,React.createElement(I18n.Text,{string:this.props.label})));}}]);return SelectBoxItem;}(Component);_defineProperty(SelectBoxItem,"defaultProps",{forwardedRef:null,classNames:{}});export default SelectBoxItem;
10
+ */function render(){var Wrapper=this.props.wrapper;var _this$props$className=this.props.classNames,selectItem=_this$props$className.selectItem,selectItemSelected=_this$props$className.selectItemSelected;return React.createElement("li",{className:classNames(selectItem,item,_defineProperty({},selectItemSelected,this.props.isSelected)),onKeyUp:function onKeyUp(){},onClick:this.handleSelectionUpdate,"data-test-id":this.props.label,role:"menuitem",ref:this.props.forwardedRef,tabIndex:this.props.isSelected?'0':'-1',"aria-current":this.props.isSelected},React.createElement(Wrapper,null,React.createElement(I18n.Text,{string:this.props.label})));}}]);}(Component);_defineProperty(SelectBoxItem,"defaultProps",{forwardedRef:null,classNames:{}});export default SelectBoxItem;
@@ -1,15 +1,24 @@
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';import find from'lodash/find';import Dropdown from"../Dropdown";import I18n from"../I18n";import SelectBoxItem from"./components/Item";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 find from'lodash/find';import Dropdown from"../Dropdown";import I18n from"../I18n";import SelectBoxItem from"./components/Item";import styles from"./style";/**
2
2
  * The select box component.
3
- */var SelectBox=/*#__PURE__*/function(_Component){_inherits(SelectBox,_Component);/**
3
+ */var SelectBox=/*#__PURE__*/function(_Component){/**
4
4
  * Initializes the component.
5
5
  * @param {Object} props The components props.
6
- */function SelectBox(props){var _this;_classCallCheck(this,SelectBox);_this=_possibleConstructorReturn(this,_getPrototypeOf(SelectBox).call(this,props));_defineProperty(_assertThisInitialized(_this),"onDropdownComplete",function(){_this.dropdownCompleted=true;});_defineProperty(_assertThisInitialized(_this),"handleInteractionOutside",function(event){_this.setState({isOpen:false});event.preventDefault();event.stopPropagation();});_defineProperty(_assertThisInitialized(_this),"handleOpenList",function(){if(_this.state.isOpen){return;}_this.dropdownCompleted=false;_this.setState({isOpen:true});if(_this.firstItemRef){_this.firstItemRef.focus();}});_defineProperty(_assertThisInitialized(_this),"handleSelectionUpdate",function(value){var selection=find(_this.props.items,{value:value});_this.setState({selected:selection,isOpen:false});// Delay the callback to make sure actions are fired after animations are done.
7
- setTimeout(function(){_this.props.handleSelectionUpdate(selection.value);},_this.props.duration);if(_this.controlRef){_this.controlRef.focus();}});_defineProperty(_assertThisInitialized(_this),"setControlRef",function(ref){_this.controlRef=ref;});_defineProperty(_assertThisInitialized(_this),"setFirstItemRef",function(ref){_this.firstItemRef=ref;});_this.dropdownCompleted=false;_this.state={isOpen:false,selected:find(props.items,{value:props.initialValue})};return _this;}/**
6
+ */function SelectBox(props){var _this2;_classCallCheck(this,SelectBox);_this2=_callSuper(this,SelectBox,[props]);/**
7
+ * When dropdown animation is finished.
8
+ */_defineProperty(_this2,"onDropdownComplete",function(){_this2.dropdownCompleted=true;});/**
9
+ * Handles any interaction the user does outside of the component.
10
+ * In this case the select gets closed.
11
+ * @param {Object} event The event object.
12
+ */_defineProperty(_this2,"handleInteractionOutside",function(event){_this2.setState({isOpen:false});event.preventDefault();event.stopPropagation();});/**
13
+ * Sets the open state to true
14
+ */_defineProperty(_this2,"handleOpenList",function(){if(_this2.state.isOpen){return;}_this2.dropdownCompleted=false;_this2.setState({isOpen:true});if(_this2.firstItemRef){_this2.firstItemRef.focus();}});/**
15
+ * Sets the new active selection.
16
+ * @param {string} value Value of the selected item.
17
+ */_defineProperty(_this2,"handleSelectionUpdate",function(value){var selection=find(_this2.props.items,{value:value});_this2.setState({selected:selection,isOpen:false});// Delay the callback to make sure actions are fired after animations are done.
18
+ setTimeout(function(){_this2.props.handleSelectionUpdate(selection.value);},_this2.props.duration);if(_this2.controlRef){_this2.controlRef.focus();}});/** @param {HTMLElement} ref The element */_defineProperty(_this2,"setControlRef",function(ref){_this2.controlRef=ref;});/** @param {HTMLElement} ref The element */_defineProperty(_this2,"setFirstItemRef",function(ref){_this2.firstItemRef=ref;});_this2.dropdownCompleted=false;_this2.state={isOpen:false,selected:find(props.items,{value:props.initialValue})};return _this2;}/**
8
19
  * Reset selected when changing the initial value.
9
20
  * @param {Object} nextProps The next props the component will receive.
10
- */_createClass(SelectBox,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(this.props.initialValue!==nextProps.initialValue){this.setState({selected:find(nextProps.items,{value:nextProps.initialValue})});}}/**
11
- * When dropdown animation is finished.
12
- */},{key:"render",/**
21
+ */_inherits(SelectBox,_Component);return _createClass(SelectBox,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(this.props.initialValue!==nextProps.initialValue){this.setState({selected:find(nextProps.items,{value:nextProps.initialValue})});}}},{key:"render",value:/**
13
22
  * Renders the component
14
23
  * @returns {JSX}
15
- */value:function render(){var _this2=this;var Icon=this.props.icon;var _this$props$className=this.props.classNames,icon=_this$props$className.icon,_this$props$className2=_this$props$className.iconOpen,iconOpen=_this$props$className2===void 0?null:_this$props$className2,selection=_this$props$className.selection,button=_this$props$className.button,dropdown=_this$props$className.dropdown,selectItem=_this$props$className.selectItem,selectItemSelected=_this$props$className.selectItemSelected;var buttonLabel=this.state.selected?this.state.selected.label:this.props.defaultText;var iconClasses=classNames(icon,_defineProperty({},iconOpen,this.state.isOpen&&iconOpen!==null));return React.createElement("div",{className:this.props.className,"data-test-id":this.props.testId},React.createElement("button",{className:button,onClick:this.handleOpenList,"data-test-id":buttonLabel,type:"button","aria-haspopup":true,"aria-expanded":this.state.isOpen?true:null,"aria-controls":buttonLabel,ref:this.setControlRef},React.createElement("span",{className:selection},React.createElement(I18n.Text,{string:buttonLabel})),React.createElement("div",{className:iconClasses},React.createElement(Icon,null))),React.createElement(Dropdown,{className:dropdown,isOpen:this.state.isOpen,onComplete:this.onDropdownComplete,duration:this.props.duration},React.createElement("ul",{role:"menu",id:buttonLabel,tabIndex:"-1"},this.props.items.map(function(item){return React.createElement(SelectBoxItem,{classNames:{selectItem:selectItem,selectItemSelected:selectItemSelected},wrapper:_this2.props.item,key:item.value,value:item.value,label:item.label,handleSelectionUpdate:_this2.handleSelectionUpdate,isSelected:buttonLabel===item.label,forwardedRef:buttonLabel===item.label?_this2.setFirstItemRef:null});}))),this.state.isOpen&&React.createElement("button",{className:styles.overlay,onClick:this.handleInteractionOutside,onTouchMove:this.handleInteractionOutside,type:"button","aria-hidden":true}));}}]);return SelectBox;}(Component);_defineProperty(SelectBox,"defaultProps",{className:'',classNames:{},duration:225,defaultText:'filter.sort.default',handleSelectionUpdate:function handleSelectionUpdate(){},initialValue:null,testId:null});export default SelectBox;
24
+ */function render(){var _this3=this;var Icon=this.props.icon;var _this$props$className=this.props.classNames,icon=_this$props$className.icon,_this$props$className2=_this$props$className.iconOpen,iconOpen=_this$props$className2===void 0?null:_this$props$className2,selection=_this$props$className.selection,button=_this$props$className.button,dropdown=_this$props$className.dropdown,selectItem=_this$props$className.selectItem,selectItemSelected=_this$props$className.selectItemSelected;var buttonLabel=this.state.selected?this.state.selected.label:this.props.defaultText;var iconClasses=classNames(icon,_defineProperty({},iconOpen,this.state.isOpen&&iconOpen!==null));return React.createElement("div",{className:"".concat(this.props.className," common__select-box"),"data-test-id":this.props.testId},React.createElement("button",{className:button,onClick:this.handleOpenList,"data-test-id":buttonLabel,type:"button","aria-haspopup":true,"aria-expanded":this.state.isOpen?true:null,"aria-controls":buttonLabel,ref:this.setControlRef},React.createElement("span",{className:selection},React.createElement(I18n.Text,{string:buttonLabel})),React.createElement("div",{className:iconClasses},React.createElement(Icon,null))),React.createElement(Dropdown,{className:dropdown,isOpen:this.state.isOpen,onComplete:this.onDropdownComplete,duration:this.props.duration},React.createElement("ul",{role:"menu",id:buttonLabel,tabIndex:"-1"},this.props.items.map(function(item){return React.createElement(SelectBoxItem,{classNames:{selectItem:selectItem,selectItemSelected:selectItemSelected},wrapper:_this3.props.item,key:item.value,value:item.value,label:item.label,handleSelectionUpdate:_this3.handleSelectionUpdate,isSelected:buttonLabel===item.label,forwardedRef:buttonLabel===item.label?_this3.setFirstItemRef:null});}))),this.state.isOpen&&React.createElement("button",{className:styles.overlay,onClick:this.handleInteractionOutside,onTouchMove:this.handleInteractionOutside,type:"button","aria-hidden":true}));}}]);}(Component);_defineProperty(SelectBox,"defaultProps",{className:'',classNames:{},duration:225,defaultText:'filter.sort.default',handleSelectionUpdate:function handleSelectionUpdate(){},initialValue:null,testId:null});export default SelectBox;
@@ -1 +1 @@
1
- import React from'react';import{shallow}from'enzyme';import SwiperItem from'.';describe('<SwiperItem />',function(){it('should not render without children',function(){var wrapper=shallow(React.createElement(SwiperItem,null,React.createElement("div",null)));expect(wrapper).toMatchSnapshot();expect(wrapper.html()).toEqual('<div class="" data-test-id="Slider"><div></div></div>');});it('should add custom className',function(){var wrapper=shallow(React.createElement(SwiperItem,{className:"test"},React.createElement("div",null)));expect(wrapper).toMatchSnapshot();expect(wrapper.html()).toEqual('<div class="test" data-test-id="Slider"><div></div></div>');});});
1
+ import React from'react';import{shallow}from'enzyme';import SwiperItem from'.';describe('<SwiperItem />',function(){it('should not render without children',function(){var wrapper=shallow(React.createElement(SwiperItem,null,React.createElement("div",null)));expect(wrapper).toMatchSnapshot();expect(wrapper.html()).toEqual('<div class="css-10a4qrv" data-test-id="Slider"><div></div></div>');});it('should add custom className',function(){var wrapper=shallow(React.createElement(SwiperItem,{className:"test"},React.createElement("div",null)));expect(wrapper).toMatchSnapshot();expect(wrapper.html()).toEqual('<div class="css-10a4qrv test" data-test-id="Slider"><div></div></div>');});});