@shopgate/pwa-common 7.12.7-beta.1 → 7.20.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) 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/router/historyReplace.js +11 -1
  6. package/actions/user/getUser.js +1 -0
  7. package/actions/user/login.js +2 -2
  8. package/collections/AuthRoutes.js +3 -3
  9. package/collections/Configuration.js +3 -3
  10. package/collections/EmbeddedMedia.js +13 -3
  11. package/collections/PersistedReducers.js +2 -2
  12. package/collections/Redirects.js +3 -3
  13. package/collections/media-providers/MediaProvider.js +32 -4
  14. package/collections/media-providers/Vimeo.js +26 -7
  15. package/collections/media-providers/YouTube.js +10 -5
  16. package/collections/media-providers/style.js +2 -1
  17. package/components/Backdrop/index.js +11 -11
  18. package/components/Button/index.js +7 -7
  19. package/components/Checkbox/index.js +27 -14
  20. package/components/CountdownTimer/index.js +7 -7
  21. package/components/Drawer/index.js +13 -13
  22. package/components/Dropdown/index.js +5 -5
  23. package/components/Ellipsis/index.js +1 -1
  24. package/components/EmbeddedMedia/index.js +5 -5
  25. package/components/ErrorBoundary/index.js +5 -5
  26. package/components/Grid/components/Item/index.js +4 -4
  27. package/components/Grid/index.js +4 -4
  28. package/components/HtmlSanitizer/connector.js +9 -0
  29. package/components/HtmlSanitizer/index.js +11 -11
  30. package/components/HtmlSanitizer/spec.js +4 -4
  31. package/components/I18n/components/FormatPrice/index.js +2 -2
  32. package/components/I18n/components/I18nProvider/index.js +9 -9
  33. package/components/I18n/components/Translate/index.js +11 -7
  34. package/components/Icon/index.js +1 -1
  35. package/components/Image/index.js +9 -9
  36. package/components/Image/spec.js +2 -2
  37. package/components/InfiniteContainer/index.js +21 -21
  38. package/components/Input/components/DateInput.js +2 -2
  39. package/components/Input/components/MultiLineInput.js +10 -10
  40. package/components/Input/components/SimpleInput.js +27 -21
  41. package/components/KeyboardConsumer/index.js +7 -7
  42. package/components/Link/connector.js +1 -1
  43. package/components/Link/index.js +8 -5
  44. package/components/List/components/Item/index.js +1 -1
  45. package/components/List/index.js +1 -1
  46. package/components/Modal/style.js +1 -1
  47. package/components/Picker/components/List/index.js +1 -1
  48. package/components/Picker/components/Modal/index.js +7 -7
  49. package/components/Picker/index.js +19 -9
  50. package/components/Portal/index.js +15 -11
  51. package/components/ProductCharacteristics/helpers/index.js +1 -1
  52. package/components/ProductCharacteristics/index.js +27 -12
  53. package/components/RangeSlider/index.js +33 -24
  54. package/components/Route/RouteNotFound.js +3 -3
  55. package/components/Route/index.js +12 -5
  56. package/components/Router/index.js +18 -10
  57. package/components/ScannerContainer/index.js +3 -3
  58. package/components/Select/index.js +25 -15
  59. package/components/SelectBox/components/Item/index.js +5 -3
  60. package/components/SelectBox/index.js +17 -8
  61. package/components/Swiper/components/SwiperItem/spec.js +1 -1
  62. package/components/Swiper/index.js +3 -3
  63. package/components/Swiper/styles.js +4 -1
  64. package/components/Transition/index.js +4 -4
  65. package/components/Widgets/components/Widget/index.js +4 -4
  66. package/components/Widgets/components/WidgetGrid/index.js +5 -5
  67. package/components/Widgets/index.js +6 -6
  68. package/components/index.js +1 -2
  69. package/constants/Configuration.js +1 -1
  70. package/constants/Device.js +2 -2
  71. package/constants/Portals.js +2 -2
  72. package/helpers/config/mock.js +2 -2
  73. package/helpers/config/theme.js +2 -2
  74. package/helpers/dom/index.js +2 -1
  75. package/helpers/html/parseHTML.js +10 -3
  76. package/helpers/i18n/getNumberFormatter.js +1 -1
  77. package/helpers/i18n/getTranslator.js +10 -4
  78. package/helpers/i18n/index.js +1 -1
  79. package/helpers/i18n/mergeTranslations.js +1 -1
  80. package/helpers/portals/portalCollection.js +3 -3
  81. package/helpers/redux/shouldFetchData.js +1 -1
  82. package/helpers/style/index.js +2 -2
  83. package/package.json +5 -5
  84. package/providers/loading/index.js +24 -14
  85. package/providers/toast/index.js +10 -8
  86. package/reducers/page/index.js +1 -1
  87. package/reducers/router/index.js +1 -1
  88. package/selectors/client.js +9 -7
  89. package/streams/app.js +8 -2
  90. package/streams/main.js +1 -1
  91. package/streams/view.js +12 -0
  92. package/subscriptions/error.js +4 -4
  93. package/subscriptions/helpers/handleLinks.js +2 -2
  94. package/subscriptions/menu.js +4 -2
  95. package/subscriptions/router.js +6 -6
  96. package/subscriptions/user.js +1 -1
@@ -1,8 +1,9 @@
1
- function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}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);}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);}import React,{Component}from'react';import PropTypes from'prop-types';import Portal from'react-portal';import{withForwardedRef}from'@shopgate/engage/core';import PickerModal from"./components/Modal";import PickerButton from"./components/Button";import PickerList from"./components/List";/**
1
+ function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}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);}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);}import React,{Component}from'react';import PropTypes from'prop-types';import Portal from'react-portal';import{withForwardedRef}from'@shopgate/engage/core';import PickerModal from"./components/Modal";import PickerButton from"./components/Button";import PickerList from"./components/List";/**
2
2
  * Converts an item of any type (e.g. string or number)
3
3
  * to an object representation containing value and label properties.
4
4
  * @param {*} item - An item of any type.
5
5
  * @returns {Object} An object representation of the item.
6
+ * @deprecated Use Picker from engage instead
6
7
  */var normalizeItem=function normalizeItem(item){if(item!==null&&typeof item!=='undefined'){var itemDefaults={value:item.value||item,label:item.label||item.value||item,disabled:item.disabled||false};if(_typeof(item)==='object'){return _extends({},itemDefaults,{},item);}return itemDefaults;}return null;};/**
7
8
  * Finds an item index in a list of items by value.
8
9
  * @param {Array} items - The list of items.
@@ -12,19 +13,28 @@ function _classCallCheck(instance,Constructor){if(!(instance instanceof Construc
12
13
  * The picker component (acts like a selectbox).
13
14
  * @deprecated Will be remove in Engage v7.0.0.
14
15
  * Please use `import { Picker } from '@shopgate/engage/components'` instead.
15
- */var Picker=/*#__PURE__*/function(_Component){_inherits(Picker,_Component);/**
16
+ */var Picker=/*#__PURE__*/function(_Component){/**
16
17
  * The constructor.
17
18
  * @param {Object} props - The component props.
18
- */function Picker(props){var _this;_classCallCheck(this,Picker);_this=_possibleConstructorReturn(this,_getPrototypeOf(Picker).call(this,props));_defineProperty(_assertThisInitialized(_this),"triggerChangeCallback",function(nextValue){var nextSelectedIndex=findItemIndexByValue(_this.props.items,nextValue);if(nextSelectedIndex>-1&&_this.state.selectedIndex!==nextSelectedIndex){_this.props.onChange(nextValue);}_this.props.onSelect(nextValue);});_defineProperty(_assertThisInitialized(_this),"triggerCloseCallback",function(nextOpenState){if(_this.state.isOpen&&!nextOpenState){_this.props.onClose();}});_defineProperty(_assertThisInitialized(_this),"handleItemSelect",function(value){_this.triggerChangeCallback(value);_this.setState({selectedIndex:findItemIndexByValue(_this.props.items,value)});});_defineProperty(_assertThisInitialized(_this),"toggleOpenState",function(open){_this.setState(function(_ref){var isOpen=_ref.isOpen;var nextIsOpen=typeof open==='boolean'?open:!isOpen;_this.triggerCloseCallback(nextIsOpen);return{isOpen:nextIsOpen};});});_this.state={selectedIndex:findItemIndexByValue(props.items,props.value),isOpen:props.isOpen};return _this;}/**
19
+ */function Picker(props){var _this2;_classCallCheck(this,Picker);_this2=_callSuper(this,Picker,[props]);/**
20
+ * Triggers the onChange callback if the selected value has changed.
21
+ * @param {Object} nextValue - The value the user picked.
22
+ */_defineProperty(_this2,"triggerChangeCallback",function(nextValue){var nextSelectedIndex=findItemIndexByValue(_this2.props.items,nextValue);if(nextSelectedIndex>-1&&_this2.state.selectedIndex!==nextSelectedIndex){_this2.props.onChange(nextValue);}_this2.props.onSelect(nextValue);});/**
23
+ * Triggers the onChange callback if the selected value has changed.
24
+ * @param {Object} nextOpenState - The value the user picked.
25
+ */_defineProperty(_this2,"triggerCloseCallback",function(nextOpenState){if(_this2.state.isOpen&&!nextOpenState){_this2.props.onClose();}});/**
26
+ * Gets called when a new item is selected
27
+ * @param {string} value - The selected value.
28
+ */_defineProperty(_this2,"handleItemSelect",function(value){_this2.triggerChangeCallback(value);_this2.setState({selectedIndex:findItemIndexByValue(_this2.props.items,value)});});/**
29
+ * Sets or toggles the open state of the component.
30
+ * @param {boolean} [open] New open state.
31
+ */_defineProperty(_this2,"toggleOpenState",function(open){_this2.setState(function(_ref){var isOpen=_ref.isOpen;var nextIsOpen=typeof open==='boolean'?open:!isOpen;_this2.triggerCloseCallback(nextIsOpen);return{isOpen:nextIsOpen};});});_this2.state={selectedIndex:findItemIndexByValue(props.items,props.value),isOpen:props.isOpen};return _this2;}/**
19
32
  * Updates the selected item when the value prop changes.
20
33
  * @param {Object} nextProps - The next props.
21
- */_createClass(Picker,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){// Only update if a value is present and also changed.
34
+ */_inherits(Picker,_Component);return _createClass(Picker,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){// Only update if a value is present and also changed.
22
35
  if(!this.selectedItem||nextProps.value!==this.selectedItem.value){this.setState({selectedIndex:findItemIndexByValue(nextProps.items,nextProps.value)});}if(this.props.isOpen!==nextProps.isOpen&&nextProps.isOpen!==this.state.isOpen){this.setState({isOpen:nextProps.isOpen});}}/**
23
36
  * Getter for the selected item.
24
- */},{key:"render",/**
37
+ */},{key:"selectedItem",get:function get(){return normalizeItem(this.props.items[this.state.selectedIndex]);}},{key:"render",value:/**
25
38
  * Renders the component.
26
39
  * @returns {JSX}
27
- */value:function render(){var _this2=this;var hasSelection=!!this.selectedItem;var buttonValue=hasSelection?this.selectedItem.label:'';var buttonLabel=hasSelection?this.props.label:this.props.placeholder;var buttonProps=_extends({},this.props.buttonProps,{label:buttonLabel,value:buttonValue,disabled:this.props.disabled,openList:this.props.disabled?null:function(){_this2.toggleOpenState(true);}});var modalProps={isOpen:this.state.isOpen,duration:this.props.duration,onClose:function onClose(){return _this2.toggleOpenState(false);}};var listProps={items:this.props.items.map(normalizeItem),selectedIndex:this.state.selectedIndex,onSelect:this.handleItemSelect};return React.createElement("div",{role:"button",className:this.props.className,ref:this.props.forwardedRef,tabIndex:0,"aria-haspopup":true},React.createElement(this.props.buttonComponent,buttonProps),React.createElement(Portal,{onClose:function onClose(){return _this2.toggleOpenState(false);},isOpened:true},React.createElement(this.props.modalComponent,modalProps,React.createElement(this.props.listComponent,listProps))));}},{key:"selectedItem",get:function get(){return normalizeItem(this.props.items[this.state.selectedIndex]);}/**
28
- * Triggers the onChange callback if the selected value has changed.
29
- * @param {Object} nextValue - The value the user picked.
30
- */}]);return Picker;}(Component);_defineProperty(Picker,"defaultProps",{buttonComponent:PickerButton,buttonProps:{},duration:300,disabled:false,forwardedRef:null,label:'',listComponent:PickerList,modalComponent:PickerModal,className:'',isOpen:false,items:[],onChange:function onChange(){},onClose:function onClose(){},onSelect:function onSelect(){},placeholder:'Pick ...',value:null});export default withForwardedRef(Picker);
40
+ */function render(){var _this3=this;var hasSelection=!!this.selectedItem;var buttonValue=hasSelection?this.selectedItem.label:'';var buttonLabel=hasSelection?this.props.label:this.props.placeholder;var buttonProps=_extends({},this.props.buttonProps,{label:buttonLabel,value:buttonValue,disabled:this.props.disabled,openList:this.props.disabled?null:function(){_this3.toggleOpenState(true);}});var modalProps={isOpen:this.state.isOpen,duration:this.props.duration,onClose:function onClose(){return _this3.toggleOpenState(false);}};var listProps={items:this.props.items.map(normalizeItem),selectedIndex:this.state.selectedIndex,onSelect:this.handleItemSelect};return React.createElement("div",{role:"button",className:"".concat(this.props.className," common__picker"),ref:this.props.forwardedRef,tabIndex:0,"aria-haspopup":true},React.createElement(this.props.buttonComponent,buttonProps),React.createElement(Portal,{onClose:function onClose(){return _this3.toggleOpenState(false);},isOpened:true},React.createElement(this.props.modalComponent,modalProps,React.createElement(this.props.listComponent,listProps))));}}]);}(Component);_defineProperty(Picker,"defaultProps",{buttonComponent:PickerButton,buttonProps:{},duration:300,disabled:false,forwardedRef:null,label:'',listComponent:PickerList,modalComponent:PickerModal,className:'',isOpen:false,items:[],onChange:function onChange(){},onClose:function onClose(){},onSelect:function onSelect(){},placeholder:'Pick ...',value:null});export default withForwardedRef(Picker);
@@ -1,23 +1,27 @@
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 _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 _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,{PureComponent,Suspense}from'react';import PropTypes from'prop-types';import{logger}from'@shopgate/pwa-core/helpers';import Loading from"../Loading";import portalCollection from"../../helpers/portals/portalCollection";import{componentsConfig}from"../../helpers/config";/**
1
+ var _excluded=["props"];function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent,Suspense}from'react';import PropTypes from'prop-types';import{logger}from'@shopgate/pwa-core/helpers';import Loading from"../Loading";import portalCollection from"../../helpers/portals/portalCollection";import{componentsConfig}from"../../helpers/config";/**
2
2
  * The Portal component.
3
- */var Portal=/*#__PURE__*/function(_PureComponent){_inherits(Portal,_PureComponent);/**
3
+ */var Portal=/*#__PURE__*/function(_PureComponent){/**
4
4
  * Constructor.
5
5
  * @param {Object} props The component props.
6
- */function Portal(_props){var _this;_classCallCheck(this,Portal);_this=_possibleConstructorReturn(this,_getPrototypeOf(Portal).call(this,_props));_defineProperty(_assertThisInitialized(_this),"getRenderedComponents",function(props){var propsFromProps=props.props,reducedProps=_objectWithoutProperties(props,["props"]);var componentProps=_extends({},propsFromProps,{},reducedProps);return _this.components.map(function(_ref){var PortalComponent=_ref.PortalComponent,key=_ref.key;return React.createElement(Suspense,{fallback:React.createElement(Loading,null),key:key},React.createElement(PortalComponent,componentProps));});});_defineProperty(_assertThisInitialized(_this),"getPortalComponents",function(name){var components=[];var portals=portalCollection.getPortals();if(!portals){return components;}var config=portalCollection.getConfig();if(!config){config=componentsConfig.portals;}// Loop over the portal keys.
6
+ */function Portal(_props){var _this2;_classCallCheck(this,Portal);_this2=_callSuper(this,Portal,[_props]);/**
7
+ * Returns the portal components.
8
+ * @param {Object} props - The props to pass to the component.
9
+ * @return {Array}
10
+ */_defineProperty(_this2,"getRenderedComponents",function(props){var propsFromProps=props.props,reducedProps=_objectWithoutProperties(props,_excluded);var componentProps=_extends({},propsFromProps,{},reducedProps);return _this2.components.map(function(_ref){var PortalComponent=_ref.PortalComponent,key=_ref.key;return React.createElement(Suspense,{fallback:React.createElement(Loading,null),key:key},React.createElement(PortalComponent,componentProps));});});/**
11
+ * Returns the portal components.
12
+ * @param {string} name Name of the portal position
13
+ * @return {Array}
14
+ */_defineProperty(_this2,"getPortalComponents",function(name){var components=[];var portals=portalCollection.getPortals();if(!portals){return components;}var config=portalCollection.getConfig();if(!config){config=componentsConfig.portals;}// Loop over the portal keys.
7
15
  Object.keys(config).forEach(function(key,index){var sourceTarget=config[key].target;var portalTarget=Array.isArray(sourceTarget)?sourceTarget:[sourceTarget];if(portalTarget.length===0){return;}portalTarget.forEach(function(target){// Stop if there is no key that matches the given name (prop).
8
16
  if(target!==name){return;}var PortalComponent=portals[key];// Check that the component is valid.
9
- if(PortalComponent){var componentKey="".concat(key,"-").concat(index);components.push({key:componentKey,PortalComponent:PortalComponent});}});});return components;});_this.state={hasError:false};_this.components=_this.getPortalComponents(_props.name);return _this;}/**
17
+ if(PortalComponent){var componentKey="".concat(key,"-").concat(index);components.push({key:componentKey,PortalComponent:PortalComponent});}});});return components;});_this2.state={hasError:false};_this2.components=_this2.getPortalComponents(_props.name);return _this2;}/**
10
18
  * Catches errors.
11
19
  * @param {Error} error The caught error.
12
20
  * @param {Object} info The stacktrace info.
13
- */_createClass(Portal,[{key:"componentDidCatch",value:function componentDidCatch(error,info){this.setState({hasError:true});logger.error(error,info);}/**
14
- * Returns the portal components.
15
- * @param {Object} props - The props to pass to the component.
16
- * @return {Array}
17
- */},{key:"render",/**
21
+ */_inherits(Portal,_PureComponent);return _createClass(Portal,[{key:"componentDidCatch",value:function componentDidCatch(error,info){this.setState({hasError:true});logger.error(error,info);}},{key:"render",value:/**
18
22
  * Renders the component.
19
23
  * @return {JSX}
20
- */value:function render(){var children=this.props.children;var hasError=this.state.hasError;var renderedComponents=this.getRenderedComponents(this.props);var hasComponents=renderedComponents.length>0;/**
24
+ */function render(){var children=this.props.children;var hasError=this.state.hasError;var renderedComponents=this.getRenderedComponents(this.props);var hasComponents=renderedComponents.length>0;/**
21
25
  * Render nothing if there are no children, matching components
22
26
  * via name or an error occurred.
23
27
  */if(hasError||!(hasComponents||children)){return null;}/**
@@ -26,4 +30,4 @@ if(PortalComponent){var componentKey="".concat(key,"-").concat(index);components
26
30
  */if(hasComponents){/**
27
31
  * If there is a child component then we treat the match as an override
28
32
  * and we render the last match only.
29
- */if(children){return renderedComponents[renderedComponents.length-1];}return renderedComponents;}return children;}}]);return Portal;}(PureComponent);_defineProperty(Portal,"defaultProps",{children:null,props:null});export default Portal;
33
+ */if(children){return renderedComponents[renderedComponents.length-1];}return renderedComponents;}return children;}}]);}(PureComponent);_defineProperty(Portal,"defaultProps",{children:null,props:null});export default Portal;
@@ -1,4 +1,4 @@
1
- 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 isMatch from'lodash/isMatch';import appConfig from'@shopgate/pwa-common/helpers/config';var variantSelectionMode=appConfig.variantSelectionMode,_appConfig$product=appConfig.product;_appConfig$product=_appConfig$product===void 0?{}:_appConfig$product;var variantPreselect=_appConfig$product.variantPreselect;var preselectVariant=variantPreselect||parseInt(variantSelectionMode,10)===1;/**
1
+ 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 isMatch from'lodash/isMatch';import appConfig from'@shopgate/pwa-common/helpers/config';var variantSelectionMode=appConfig.variantSelectionMode,_appConfig$product=appConfig.product,_appConfig$product2=_appConfig$product===void 0?{}:_appConfig$product,variantPreselect=_appConfig$product2.variantPreselect;var preselectVariant=variantPreselect||parseInt(variantSelectionMode,10)===1;/**
2
2
  * Returns the index of a particular characteristic from a set of characteristics.
3
3
  * @param {Array} characteristics The characteristics of a product.
4
4
  * @param {number} characteristicId The id of the characteristic to find.
@@ -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,19 @@
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 _context$state;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;/**
11
+ * When a route is "replaced" the router doesn't assign a new route id to the old route
12
+ * stack entry. This can cause issues when a route is replaced by itself, since the content
13
+ * will not remount out of the box.
14
+ *
15
+ * The "replaceRouteId" state prop is injected by the "historyReplace" action. It's used
16
+ * to enforce re-remounting routes which where replaced by itself.
17
+ */var replaceRouteId=(context===null||context===void 0?void 0:(_context$state=context.state)===null||_context$state===void 0?void 0:_context$state.replaceRouteId)||'';return React.createElement(ErrorBoundary,{key:"error.".concat(route.id,"_").concat(replaceRouteId)},React.createElement(RouteContext.Provider,{key:"".concat(route.id,"_").concat(replaceRouteId),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
18
  * @param {Object} props The component props.
12
19
  */});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);