@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.
- package/App.js +6 -6
- package/actions/app/handleLink.js +7 -5
- package/actions/client/fetchClientInformation.js +1 -1
- package/actions/page/fetchPageConfig.js +2 -2
- package/actions/router/historyReplace.js +11 -1
- package/actions/user/getUser.js +1 -0
- package/actions/user/login.js +2 -2
- package/collections/AuthRoutes.js +3 -3
- package/collections/Configuration.js +3 -3
- package/collections/EmbeddedMedia.js +13 -3
- package/collections/PersistedReducers.js +2 -2
- package/collections/Redirects.js +3 -3
- package/collections/media-providers/MediaProvider.js +32 -4
- package/collections/media-providers/Vimeo.js +26 -7
- package/collections/media-providers/YouTube.js +10 -5
- package/collections/media-providers/style.js +2 -1
- package/components/Backdrop/index.js +11 -11
- package/components/Button/index.js +7 -7
- package/components/Checkbox/index.js +27 -14
- package/components/CountdownTimer/index.js +7 -7
- package/components/Drawer/index.js +13 -13
- package/components/Dropdown/index.js +5 -5
- package/components/Ellipsis/index.js +1 -1
- package/components/EmbeddedMedia/index.js +5 -5
- package/components/ErrorBoundary/index.js +5 -5
- package/components/Grid/components/Item/index.js +4 -4
- package/components/Grid/index.js +4 -4
- package/components/HtmlSanitizer/connector.js +9 -0
- package/components/HtmlSanitizer/index.js +11 -11
- package/components/HtmlSanitizer/spec.js +4 -4
- package/components/I18n/components/FormatPrice/index.js +2 -2
- package/components/I18n/components/I18nProvider/index.js +9 -9
- package/components/I18n/components/Translate/index.js +11 -7
- package/components/Icon/index.js +1 -1
- package/components/Image/index.js +9 -9
- package/components/Image/spec.js +2 -2
- package/components/InfiniteContainer/index.js +21 -21
- package/components/Input/components/DateInput.js +2 -2
- package/components/Input/components/MultiLineInput.js +10 -10
- package/components/Input/components/SimpleInput.js +27 -21
- package/components/KeyboardConsumer/index.js +7 -7
- package/components/Link/connector.js +1 -1
- package/components/Link/index.js +8 -5
- package/components/List/components/Item/index.js +1 -1
- package/components/List/index.js +1 -1
- package/components/Modal/style.js +1 -1
- package/components/Picker/components/List/index.js +1 -1
- package/components/Picker/components/Modal/index.js +7 -7
- package/components/Picker/index.js +19 -9
- package/components/Portal/index.js +15 -11
- package/components/ProductCharacteristics/helpers/index.js +1 -1
- package/components/ProductCharacteristics/index.js +27 -12
- package/components/RangeSlider/index.js +33 -24
- package/components/Route/RouteNotFound.js +3 -3
- package/components/Route/index.js +12 -5
- package/components/Router/index.js +18 -10
- package/components/ScannerContainer/index.js +3 -3
- package/components/Select/index.js +25 -15
- package/components/SelectBox/components/Item/index.js +5 -3
- package/components/SelectBox/index.js +17 -8
- package/components/Swiper/components/SwiperItem/spec.js +1 -1
- package/components/Swiper/index.js +3 -3
- package/components/Swiper/styles.js +4 -1
- package/components/Transition/index.js +4 -4
- package/components/Widgets/components/Widget/index.js +4 -4
- package/components/Widgets/components/WidgetGrid/index.js +5 -5
- package/components/Widgets/index.js +6 -6
- package/components/index.js +1 -2
- package/constants/Configuration.js +1 -1
- package/constants/Device.js +2 -2
- package/constants/Portals.js +2 -2
- package/helpers/config/mock.js +2 -2
- package/helpers/config/theme.js +2 -2
- package/helpers/dom/index.js +2 -1
- package/helpers/html/parseHTML.js +10 -3
- package/helpers/i18n/getNumberFormatter.js +1 -1
- package/helpers/i18n/getTranslator.js +10 -4
- package/helpers/i18n/index.js +1 -1
- package/helpers/i18n/mergeTranslations.js +1 -1
- package/helpers/portals/portalCollection.js +3 -3
- package/helpers/redux/shouldFetchData.js +1 -1
- package/helpers/style/index.js +2 -2
- package/package.json +5 -5
- package/providers/loading/index.js +24 -14
- package/providers/toast/index.js +10 -8
- package/reducers/page/index.js +1 -1
- package/reducers/router/index.js +1 -1
- package/selectors/client.js +9 -7
- package/streams/app.js +8 -2
- package/streams/main.js +1 -1
- package/streams/view.js +12 -0
- package/subscriptions/error.js +4 -4
- package/subscriptions/helpers/handleLinks.js +2 -2
- package/subscriptions/menu.js +4 -2
- package/subscriptions/router.js +6 -6
- package/subscriptions/user.js +1 -1
|
@@ -1,24 +1,37 @@
|
|
|
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
|
|
1
|
+
function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import classNames from'classnames';/**
|
|
2
2
|
* Base checkbox component.
|
|
3
3
|
* @type {Object}
|
|
4
|
-
*/var Checkbox=/*#__PURE__*/function(_Component){
|
|
4
|
+
*/var Checkbox=/*#__PURE__*/function(_Component){/**
|
|
5
5
|
* The checkbox component constructor.
|
|
6
6
|
* It checks if the checkbox is a controlled or uncontrolled input and sets an internal state if
|
|
7
7
|
* uncontrolled to keep track of th checked-state.
|
|
8
8
|
* @param {Object} props The Checkbox properties.
|
|
9
|
-
*/function Checkbox(props){var
|
|
10
|
-
:_this.state.checked// Uncontrolled.
|
|
11
|
-
;});_defineProperty(_assertThisInitialized(_this),"handleCheck",function(){if(_this.props.disabled){return;}var checked=!_this.isChecked();if(typeof _this.props.defaultChecked!=='undefined'){// Uncontrolled.
|
|
12
|
-
_this.setState({checked:checked});}_this.props.onCheck(checked);});_defineProperty(_assertThisInitialized(_this),"renderIcon",function(){return _this.isChecked()?_this.props.checkedIcon:_this.props.uncheckedIcon;});_defineProperty(_assertThisInitialized(_this),"renderInput",function(){var _assertThisInitialize=_assertThisInitialized(_this),name=_assertThisInitialize.props.name,isChecked=_assertThisInitialize.isChecked;return _this.props.name?React.createElement("input",{className:"input",type:"hidden",name:name,value:isChecked()?1:0}):null;});_defineProperty(_assertThisInitialized(_this),"renderLabelIfItIsOnThe",function(side){return _this.props.labelPosition===side?_this.props.label:null;});if(typeof props.defaultChecked!=='undefined'){// Uncontrolled input.
|
|
13
|
-
_this.state={checked:props.defaultChecked};}else{// Controlled input
|
|
14
|
-
_this.state={checked:props.checked};}return _this;}/**
|
|
15
|
-
* Make sure state is updated with new checked value when input is controlled
|
|
16
|
-
* @param {Object} nextProps Contains the new "checked" status
|
|
17
|
-
*/_createClass(Checkbox,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){// Update only for controlled input
|
|
18
|
-
if(typeof this.props.defaultChecked==='undefined'){if(this.state.checked!==nextProps.checked){this.setState({checked:nextProps.checked});}}}/**
|
|
9
|
+
*/function Checkbox(props){var _this2;_classCallCheck(this,Checkbox);_this2=_callSuper(this,Checkbox,[props]);/**
|
|
19
10
|
* Returns if the checkbox is checked or not.
|
|
20
11
|
* @return {boolean} Is the checkbox checked?
|
|
21
|
-
*/
|
|
12
|
+
*/_defineProperty(_this2,"isChecked",function(){return typeof _this2.props.defaultChecked==='undefined'?_this2.props.checked// Controlled.
|
|
13
|
+
:_this2.state.checked// Uncontrolled.
|
|
14
|
+
;});/**
|
|
15
|
+
* Inverts the current "checked" value and calls the callback function with it.
|
|
16
|
+
* If the checkbox is uncontrolled, it keeps track of the value.
|
|
17
|
+
*/_defineProperty(_this2,"handleCheck",function(){if(_this2.props.disabled){return;}var checked=!_this2.isChecked();if(typeof _this2.props.defaultChecked!=='undefined'){// Uncontrolled.
|
|
18
|
+
_this2.setState({checked:checked});}_this2.props.onCheck(checked);});/**
|
|
19
|
+
* Renders the checked/unchecked icon.
|
|
20
|
+
* @returns {JSX}
|
|
21
|
+
*/_defineProperty(_this2,"renderIcon",function(){return _this2.isChecked()?_this2.props.checkedIcon:_this2.props.uncheckedIcon;});/**
|
|
22
|
+
* Renders an input if a "name" prop is provided.
|
|
23
|
+
* @returns {JSX}
|
|
24
|
+
*/_defineProperty(_this2,"renderInput",function(){var _this3=_this2,name=_this3.props.name,isChecked=_this3.isChecked;return _this2.props.name?React.createElement("input",{className:"input",type:"hidden",name:name,value:isChecked()?1:0}):null;});/**
|
|
25
|
+
* Renders the label if "side" matches he labelPosition prop.
|
|
26
|
+
* @param {string} side Used to check against which side to render the label on.
|
|
27
|
+
* @returns {JSX}
|
|
28
|
+
*/_defineProperty(_this2,"renderLabelIfItIsOnThe",function(side){return _this2.props.labelPosition===side?_this2.props.label:null;});if(typeof props.defaultChecked!=='undefined'){// Uncontrolled input.
|
|
29
|
+
_this2.state={checked:props.defaultChecked};}else{// Controlled input
|
|
30
|
+
_this2.state={checked:props.checked};}return _this2;}/**
|
|
31
|
+
* Make sure state is updated with new checked value when input is controlled
|
|
32
|
+
* @param {Object} nextProps Contains the new "checked" status
|
|
33
|
+
*/_inherits(Checkbox,_Component);return _createClass(Checkbox,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){// Update only for controlled input
|
|
34
|
+
if(typeof this.props.defaultChecked==='undefined'){if(this.state.checked!==nextProps.checked){this.setState({checked:nextProps.checked});}}}},{key:"render",value:/**
|
|
22
35
|
* Renders the checkbox component.
|
|
23
36
|
* @returns {JSX}
|
|
24
|
-
*/
|
|
37
|
+
*/function render(){return React.createElement("div",{className:classNames(this.props.className,'checkbox','common__checkbox'),onClick:this.handleCheck,"aria-hidden":true},this.renderInput(),this.renderLabelIfItIsOnThe('left'),this.renderIcon(),this.renderLabelIfItIsOnThe('right'));}}]);}(Component);_defineProperty(Checkbox,"defaultProps",{checked:undefined,className:undefined,defaultChecked:undefined,disabled:false,label:null,labelPosition:'left',name:undefined,onCheck:function onCheck(){}});export default Checkbox;
|
|
@@ -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 _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 padStart from'lodash/padStart';import I18n from"../I18n";/**
|
|
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 padStart from'lodash/padStart';import I18n from"../I18n";/**
|
|
2
2
|
* Creates the appropriate format for a given time period.
|
|
3
3
|
* @param {number} days The remaining days.
|
|
4
4
|
* @param {number} hours The remaining hours.
|
|
@@ -12,17 +12,17 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
|
|
|
12
12
|
*/var createFormattedTime=function createFormattedTime(timeSpanInput){var timeSpan=Math.max(0,timeSpanInput);// Calculate remaining days, hours, minutes and seconds.
|
|
13
13
|
var days=Math.floor(timeSpan/86400);var hours=Math.floor(timeSpan%86400/3600);var minutes=Math.floor(timeSpan%3600/60);var seconds=timeSpan%60;return getFormattedTimeString(days,hours,minutes,seconds);};/**
|
|
14
14
|
* The Countdown timer component.
|
|
15
|
-
*/var CountdownTimer=/*#__PURE__*/function(_Component){
|
|
15
|
+
*/var CountdownTimer=/*#__PURE__*/function(_Component){/**
|
|
16
16
|
* The component constructor.
|
|
17
17
|
* @param {Object} props The component properties.
|
|
18
|
-
*/function CountdownTimer(props){var
|
|
19
|
-
|
|
18
|
+
*/function CountdownTimer(props){var _this2;_classCallCheck(this,CountdownTimer);_this2=_callSuper(this,CountdownTimer,[props]);_this2.intervalHandle=null;_this2.remainingTime=_this2.getRemainingTime();_this2.expired=_this2.remainingTime<=0;// Calculate the initial formatted time string.
|
|
19
|
+
_this2.state={formattedTime:createFormattedTime(_this2.remainingTime)};return _this2;}/**
|
|
20
20
|
* Installs a new interval to update the timer if the component did mount.
|
|
21
|
-
*/_createClass(CountdownTimer,[{key:"componentDidMount",value:function componentDidMount(){var
|
|
21
|
+
*/_inherits(CountdownTimer,_Component);return _createClass(CountdownTimer,[{key:"componentDidMount",value:function componentDidMount(){var _this3=this;// Install the interval.
|
|
22
22
|
this.intervalHandle=setInterval(function(){/**
|
|
23
23
|
* To allow mocked tests of the timing functions and still be able to deal
|
|
24
24
|
* with paused execution, the delta time is expected to be at least 1.
|
|
25
|
-
*/
|
|
25
|
+
*/_this3.remainingTime=_this3.getRemainingTime();_this3.updateTimer();},1000);}/**
|
|
26
26
|
* Clears the timer interval.
|
|
27
27
|
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){if(this.intervalHandle){clearInterval(this.intervalHandle);}}/**
|
|
28
28
|
* @returns {number} The remaining time until the timer runs out.
|
|
@@ -34,4 +34,4 @@ clearInterval(this.intervalHandle);this.intervalHandle=null;// The timer just ex
|
|
|
34
34
|
if(this.props.onExpire){this.props.onExpire();}}this.setState({formattedTime:createFormattedTime(deltaTime)});}/**
|
|
35
35
|
* Renders the element.
|
|
36
36
|
* @return {JSX}
|
|
37
|
-
*/},{key:"render",value:function render(){return React.createElement(I18n.Text,{string:this.state.formattedTime.string,params:this.state.formattedTime.params,className:this.props.className});}}]);
|
|
37
|
+
*/},{key:"render",value:function render(){return React.createElement(I18n.Text,{string:this.state.formattedTime.string,params:this.state.formattedTime.params,className:"".concat(this.props.className," common__countdown-timer")});}}]);}(Component);_defineProperty(CountdownTimer,"defaultProps",{className:'',onExpire:null});export default CountdownTimer;
|
|
@@ -1,20 +1,20 @@
|
|
|
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
|
|
1
|
+
function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import classNames from'classnames';import styles from"./style";/**
|
|
2
2
|
* Drawer component.
|
|
3
|
-
*/var Drawer=/*#__PURE__*/function(_Component){
|
|
4
|
-
* The component prop types.
|
|
5
|
-
* @type {Object}
|
|
6
|
-
*/ /**
|
|
7
|
-
* The component default props.
|
|
8
|
-
* @type {Object}
|
|
9
|
-
*/ /**
|
|
3
|
+
*/var Drawer=/*#__PURE__*/function(_Component){/**
|
|
10
4
|
* Initializes the Drawer component.
|
|
11
5
|
* @param {Object} props The components props.
|
|
12
|
-
*/function Drawer(props){var
|
|
6
|
+
*/function Drawer(props){var _this2;_classCallCheck(this,Drawer);_this2=_callSuper(this,Drawer,[props]);/**
|
|
7
|
+
* Syncs the internal active state when an animation ends.
|
|
8
|
+
*/_defineProperty(_this2,"handleAnimationEnd",function(){_this2.setState({active:_this2.props.isOpen});if(!_this2.props.isOpen){_this2.props.onDidClose();}else{_this2.props.onDidOpen();}});_this2.state={active:props.isOpen};return _this2;}/**
|
|
13
9
|
* Update state when isOpen changes.
|
|
14
10
|
* @param {Object} nextProps The next component props.
|
|
15
|
-
*/_createClass(Drawer,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(this.props.isOpen!==nextProps.isOpen){if(nextProps.isOpen){if(typeof nextProps.onOpen==='function'){nextProps.onOpen();}this.setState({active:true});}else if(typeof nextProps.onClose==='function'){nextProps.onClose();}}}
|
|
16
|
-
* Syncs the internal active state when an animation ends.
|
|
17
|
-
*/},{key:"render",/**
|
|
11
|
+
*/_inherits(Drawer,_Component);return _createClass(Drawer,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(this.props.isOpen!==nextProps.isOpen){if(nextProps.isOpen){if(typeof nextProps.onOpen==='function'){nextProps.onOpen();}this.setState({active:true});}else if(typeof nextProps.onClose==='function'){nextProps.onClose();}}}},{key:"render",value:/**
|
|
18
12
|
* Renders the component.
|
|
19
13
|
* @returns {JSX}
|
|
20
|
-
*/
|
|
14
|
+
*/function render(){var _this$props=this.props,alwaysActive=_this$props.alwaysActive,className=_this$props.className,children=_this$props.children,isOpen=_this$props.isOpen,animation=_this$props.animation;var active=this.state.active;var animationIn=animation["in"]||styles.animation["in"];var animationOut=animation.out||styles.animation.out;var combinedClassName=classNames(className,styles.container,_defineProperty({},animationIn,isOpen),_defineProperty({},animationOut,!isOpen),'common__drawer');var style={};if(typeof animation.duration==='number'){style.animationDuration="".concat(animation.duration,"ms");}return active||alwaysActive?React.createElement("div",{className:combinedClassName,style:style,onAnimationEnd:this.handleAnimationEnd,role:"dialog","aria-modal":true},children):null;}}]);}(Component);/**
|
|
15
|
+
* The component prop types.
|
|
16
|
+
* @type {Object}
|
|
17
|
+
*/ /**
|
|
18
|
+
* The component default props.
|
|
19
|
+
* @type {Object}
|
|
20
|
+
*/_defineProperty(Drawer,"defaultProps",{alwaysActive:false,className:'',children:null,isOpen:false,onOpen:function onOpen(){},onClose:function onClose(){},onDidClose:function onDidClose(){},onDidOpen:function onDidOpen(){},animation:{duration:null,"in":'',out:''}});export default Drawer;
|
|
@@ -1,17 +1,17 @@
|
|
|
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 _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 Transition from"../Transition";import styles from"./style";import transitions from"./transitions";/**
|
|
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 Transition from"../Transition";import styles from"./style";import transitions from"./transitions";/**
|
|
2
2
|
* This component slides it's child content up or down based on it's isOpen property.
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/var Dropdown=/*#__PURE__*/function(_Component){
|
|
4
|
+
*/var Dropdown=/*#__PURE__*/function(_Component){/**
|
|
5
5
|
* Constructor
|
|
6
6
|
* @param {Object} props Props of the Component
|
|
7
|
-
*/function Dropdown(props){var
|
|
7
|
+
*/function Dropdown(props){var _this2;_classCallCheck(this,Dropdown);_this2=_callSuper(this,Dropdown,[props]);_this2.state={initialRender:true};return _this2;}/**
|
|
8
8
|
* Update the initialRender state if the isOpen state changes from false to true
|
|
9
9
|
* @param {Object} nextProps The new props
|
|
10
|
-
*/_createClass(Dropdown,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(this.props.isOpen===false&&nextProps.isOpen===true){this.setState({initialRender:false});}}/**
|
|
10
|
+
*/_inherits(Dropdown,_Component);return _createClass(Dropdown,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){if(this.props.isOpen===false&&nextProps.isOpen===true){this.setState({initialRender:false});}}/**
|
|
11
11
|
* Only update the component if isOpen changed
|
|
12
12
|
* @param {Object} nextProps The new props
|
|
13
13
|
* @returns {boolean}
|
|
14
14
|
*/},{key:"shouldComponentUpdate",value:function shouldComponentUpdate(nextProps){return this.props.isOpen!==nextProps.isOpen;}/**
|
|
15
15
|
* Renders the component.
|
|
16
16
|
* @returns {JSX}
|
|
17
|
-
*/},{key:"render",value:function render(){var transitionProps;if(this.props.isOpen){transitionProps=this.state.initialRender?transitions.initialOpen:transitions.open;}else{transitionProps=this.state.initialRender?transitions.initialClose:transitions.close;}return React.createElement(Transition,_extends({},transitionProps,{onComplete:this.props.onComplete,onStart:this.props.onStart,duration:this.props.duration,easing:this.props.easing}),React.createElement("div",{className:"".concat(styles," ").concat(this.props.className),"aria-hidden":!this.props.isOpen},this.props.children));}}]);
|
|
17
|
+
*/},{key:"render",value:function render(){var transitionProps;if(this.props.isOpen){transitionProps=this.state.initialRender?transitions.initialOpen:transitions.open;}else{transitionProps=this.state.initialRender?transitions.initialClose:transitions.close;}return React.createElement(Transition,_extends({},transitionProps,{onComplete:this.props.onComplete,onStart:this.props.onStart,duration:this.props.duration,easing:this.props.easing}),React.createElement("div",{className:"".concat(styles," ").concat(this.props.className," common__dropdown"),"aria-hidden":!this.props.isOpen},this.props.children));}}]);}(Component);_defineProperty(Dropdown,"defaultProps",{className:'',children:null,duration:150,easing:null,isOpen:false,onComplete:function onComplete(){},onStart:function onStart(){}});export default Dropdown;
|
|
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';import Dotdotdot from
|
|
|
2
2
|
* The ellipsis text component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var Ellipsis=function Ellipsis(props){return React.createElement(Dotdotdot,{clamp:props.rows,ellipsis:props.ellipsis,className:props.className,useNativeClamp:true},props.children);};Ellipsis.defaultProps={className:'',ellipsis:'...',rows:3};export default Ellipsis;
|
|
5
|
+
*/var Ellipsis=function Ellipsis(props){return React.createElement(Dotdotdot,{clamp:props.rows,ellipsis:props.ellipsis,className:"".concat(props.className," common__ellipsis"),useNativeClamp:true},props.children);};Ellipsis.defaultProps={className:'',ellipsis:'...',rows:3};export default Ellipsis;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React,{Fragment}from'react';import PropTypes from'prop-types';import Helmet from'react-helmet';import{embeddedMedia}from'@shopgate/pwa-common/collections';/**
|
|
2
|
-
* EmbeddedMedia component.
|
|
1
|
+
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,{Fragment,useMemo}from'react';import PropTypes from'prop-types';import Helmet from'react-helmet';import{embeddedMedia}from'@shopgate/pwa-common/collections';/**
|
|
2
|
+
* EmbeddedMedia component. Handles loading of media related scripts e.g. the Vimeo Player.
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/var EmbeddedMedia=function EmbeddedMedia(_ref){var children=_ref.children;if(!embeddedMedia.getHasPendingProviders()){return children;}// Get all pending providers
|
|
5
|
-
var pendingProviders=
|
|
4
|
+
*/var EmbeddedMedia=function EmbeddedMedia(_ref){var children=_ref.children,cookieConsentSettings=_ref.cookieConsentSettings;var cookieConsent=useMemo(function(){return _extends({comfortCookiesAccepted:false,statisticsCookiesAccepted:false},cookieConsentSettings);},[cookieConsentSettings]);if(!embeddedMedia.getHasPendingProviders()||!cookieConsent.comfortCookiesAccepted){return children;}// Get all pending providers
|
|
5
|
+
var pendingProviders=Array.from(embeddedMedia.providers).filter(function(p){return p.isPending;});/**
|
|
6
6
|
* Inject onLoad cb to script tags
|
|
7
7
|
* @param {Element[]} scriptTags script tags to listen for
|
|
8
8
|
* @param {MediaProvider} provider Provider
|
|
9
9
|
*/var updateProviderScripts=function updateProviderScripts(_ref2){var scriptTags=_ref2.scriptTags;if(scriptTags){scriptTags.forEach(function(scriptTag){var provider=pendingProviders.find(function(p){return p.remoteScriptUrl===scriptTag.getAttribute('src');});// eslint-disable-next-line no-param-reassign
|
|
10
10
|
scriptTag.onload=function(){provider.onScriptLoaded();};});}};var scripts=pendingProviders.map(function(provider){return{src:provider.remoteScriptUrl,type:'text/javascript'};});return React.createElement(Fragment,null,React.createElement(Helmet,{script:scripts// Helmet doesn't support `onload` in script objects so we have to hack in our own
|
|
11
|
-
,onChangeClientState:function onChangeClientState(newState,addedTags){return updateProviderScripts(addedTags);}}),children);};export default EmbeddedMedia;
|
|
11
|
+
,onChangeClientState:function onChangeClientState(newState,addedTags){return updateProviderScripts(addedTags);}}),children);};EmbeddedMedia.defaultProps={cookieConsentSettings:{comfortCookiesAccepted:false,statisticsCookiesAccepted:false}};export default EmbeddedMedia;
|
|
@@ -1,11 +1,11 @@
|
|
|
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
|
|
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{PureComponent}from'react';import PropTypes from'prop-types';import connector from"./connector";/**
|
|
2
2
|
* The App error boundary component.
|
|
3
|
-
*/var ErrorBoundary=/*#__PURE__*/function(_PureComponent){
|
|
3
|
+
*/var ErrorBoundary=/*#__PURE__*/function(_PureComponent){function ErrorBoundary(){var _this2;_classCallCheck(this,ErrorBoundary);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this2=_callSuper(this,ErrorBoundary,[].concat(args));_defineProperty(_this2,"state",{hasError:false});return _this2;}_inherits(ErrorBoundary,_PureComponent);return _createClass(ErrorBoundary,[{key:"componentDidCatch",value:/**
|
|
4
4
|
* @param {Object} error The error object.
|
|
5
5
|
* @param {Object} errorInfo The error information.
|
|
6
|
-
*/
|
|
6
|
+
*/function componentDidCatch(error,errorInfo){// eslint-disable-next-line no-param-reassign
|
|
7
7
|
error.stack=errorInfo.componentStack;this.props.appError(error);}/**
|
|
8
8
|
* @returns {JSX}
|
|
9
|
-
*/},{key:"render",value:function render(){if(this.state.hasError){return this.props.fallbackUi;}return this.props.children;}}],[{key:"getDerivedStateFromError"
|
|
9
|
+
*/},{key:"render",value:function render(){if(this.state.hasError){return this.props.fallbackUi;}return this.props.children;}}],[{key:"getDerivedStateFromError",value:/**
|
|
10
10
|
* @returns {{hasError: boolean}}
|
|
11
|
-
*/
|
|
11
|
+
*/function getDerivedStateFromError(){return{hasError:true};}}]);}(PureComponent);_defineProperty(ErrorBoundary,"defaultProps",{fallbackUi:null});export default connector(ErrorBoundary);
|
|
@@ -1,9 +1,9 @@
|
|
|
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 _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{objectWithoutProps}from"../../../../helpers/data";import styles from"./style";/**
|
|
1
|
+
function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _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{objectWithoutProps}from"../../../../helpers/data";import styles from"./style";/**
|
|
2
2
|
* The grid item component.
|
|
3
|
-
*/var GridItem=/*#__PURE__*/function(_Component){
|
|
3
|
+
*/var GridItem=/*#__PURE__*/function(_Component){function GridItem(){_classCallCheck(this,GridItem);return _callSuper(this,GridItem,arguments);}_inherits(GridItem,_Component);return _createClass(GridItem,[{key:"getProps",value:/**
|
|
4
4
|
* Composes the props.
|
|
5
5
|
* @returns {Object} The composed props.
|
|
6
|
-
*/
|
|
6
|
+
*/function getProps(){var className=this.props.className;if(this.props.grow!==0){className+=" ".concat(styles.grow(this.props.grow));}if(this.props.shrink!==1){className+=" ".concat(styles.shrink(this.props.shrink));}var props=_extends({},this.props,{className:className});return objectWithoutProps(props,['component','grow','shrink']);}/**
|
|
7
7
|
* Renders the component.
|
|
8
8
|
* @returns {JSX}
|
|
9
|
-
*/},{key:"render",value:function render(){return React.createElement(this.props.component,this.getProps());}}]);
|
|
9
|
+
*/},{key:"render",value:function render(){return React.createElement(this.props.component,this.getProps());}}]);}(Component);_defineProperty(GridItem,"defaultProps",{className:'',component:'li',grow:0,shrink:1});export default GridItem;
|
package/components/Grid/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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 _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{objectWithoutProps}from"../../helpers/data";import GridItem from"./components/Item";import styles,{wrap}from"./style";/**
|
|
1
|
+
function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _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{objectWithoutProps}from"../../helpers/data";import GridItem from"./components/Item";import styles,{wrap}from"./style";/**
|
|
2
2
|
* The grid component.
|
|
3
|
-
*/var Grid=/*#__PURE__*/function(_Component){
|
|
3
|
+
*/var Grid=/*#__PURE__*/function(_Component){function Grid(){_classCallCheck(this,Grid);return _callSuper(this,Grid,arguments);}_inherits(Grid,_Component);return _createClass(Grid,[{key:"getProps",value:/**
|
|
4
4
|
* Composes the props.
|
|
5
5
|
* @returns {Object} The composed props.
|
|
6
|
-
*/
|
|
6
|
+
*/function getProps(){var className="".concat(this.props.className," ").concat(styles," common__grid");if(this.props.wrap){className+=" ".concat(wrap(this.props.wrap));}var props=_extends({},this.props,{className:className});return objectWithoutProps(props,['wrap','component']);}/**
|
|
7
7
|
* Renders the component.
|
|
8
8
|
* @returns {JSX}
|
|
9
|
-
*/},{key:"render",value:function render(){return React.createElement(this.props.component,this.getProps());}}]);
|
|
9
|
+
*/},{key:"render",value:function render(){return React.createElement(this.props.component,this.getProps());}}]);}(Component);_defineProperty(Grid,"Item",GridItem);_defineProperty(Grid,"defaultProps",{className:'',component:'ul',wrap:false});export default Grid;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
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{connect}from'react-redux';import{getAreComfortCookiesAccepted,getAreStatisticsCookiesAccepted}from'@shopgate/engage/tracking/selectors';import{historyPush}from"../../actions/router";/**
|
|
2
|
+
* Maps the current application state to the component props.
|
|
3
|
+
* @param {Object} state The current application state.
|
|
4
|
+
* @return {Object} The populated component props.
|
|
5
|
+
*/var mapStateToProps=function mapStateToProps(state){return{comfortCookiesAccepted:getAreComfortCookiesAccepted(state),statisticsCookiesAccepted:getAreStatisticsCookiesAccepted(state)};};/**
|
|
6
|
+
* Connects the dispatch function to a callable function in the props.
|
|
7
|
+
* @param {Function} dispatch The redux dispatch function.
|
|
8
|
+
* @return {Object} The extended component props.
|
|
9
|
+
*/var mapDispatchToProps=function mapDispatchToProps(dispatch){return{navigate:function navigate(pathname,target){return dispatch(historyPush(_extends({pathname:pathname},target&&{state:{target:target}})));}};};export default connect(mapStateToProps,mapDispatchToProps);
|
|
@@ -1,22 +1,22 @@
|
|
|
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
|
|
1
|
+
function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import classNames from'classnames';import{embeddedMedia}from'@shopgate/pwa-common/collections';import EmbeddedMedia from"../EmbeddedMedia";import parseHTML from"../../helpers/html/parseHTML";import connect from"./connector";/**
|
|
2
2
|
* HtmlSanitizer component.
|
|
3
|
-
*/var HtmlSanitizer=/*#__PURE__*/function(_Component){
|
|
3
|
+
*/var HtmlSanitizer=/*#__PURE__*/function(_Component){/**
|
|
4
4
|
* @param {Object} props The component props.
|
|
5
|
-
*/function HtmlSanitizer(props){var
|
|
5
|
+
*/function HtmlSanitizer(props){var _this2;_classCallCheck(this,HtmlSanitizer);_this2=_callSuper(this,HtmlSanitizer,[props]);/**
|
|
6
|
+
* If the user tapped a link element, prevent the default behavior.
|
|
7
|
+
* @param {Object} event The touchstart event.
|
|
8
|
+
*/_defineProperty(_this2,"handleTap",function(event){var linkTag=event.target.closest('a');if(linkTag){var _linkTag$attributes3=linkTag.attributes,_linkTag$attributes4=_linkTag$attributes3===void 0?{}:_linkTag$attributes3,_linkTag$attributes2$7=_linkTag$attributes4.href,_linkTag$attributes2$8=_linkTag$attributes2$7===void 0?{}:_linkTag$attributes2$7,_linkTag$attributes2$9=_linkTag$attributes2$8.value,href=_linkTag$attributes2$9===void 0?'':_linkTag$attributes2$9,_linkTag$attributes2$10=_linkTag$attributes4.target,_linkTag$attributes2$11=_linkTag$attributes2$10===void 0?{}:_linkTag$attributes2$10,_linkTag$attributes2$12=_linkTag$attributes2$11.value,target=_linkTag$attributes2$12===void 0?'':_linkTag$attributes2$12;if(href){event.preventDefault();if(_this2.props.settings.handleClick){_this2.props.settings.handleClick(href,target);}else{_this2.props.navigate(href,target);}}}});_this2.htmlContainer=React.createRef();return _this2;}/**
|
|
6
9
|
* Registers the event handler for when the user taps inside the html content.
|
|
7
|
-
*/_createClass(HtmlSanitizer,[{key:"componentDidMount",value:function componentDidMount(){this.htmlContainer.current.addEventListener('click',this.handleTap,true);embeddedMedia.add(this.htmlContainer.current);}/**
|
|
10
|
+
*/_inherits(HtmlSanitizer,_Component);return _createClass(HtmlSanitizer,[{key:"componentDidMount",value:function componentDidMount(){this.htmlContainer.current.addEventListener('click',this.handleTap,true);embeddedMedia.add(this.htmlContainer.current);}/**
|
|
8
11
|
* Only update if the HTML changed.
|
|
9
12
|
* @param {Object} nextProps The next props for the component.
|
|
10
13
|
* @return {boolean}
|
|
11
|
-
*/},{key:"shouldComponentUpdate",value:function shouldComponentUpdate(nextProps){return nextProps.children!==this.props.children;}/**
|
|
14
|
+
*/},{key:"shouldComponentUpdate",value:function shouldComponentUpdate(nextProps){return nextProps.children!==this.props.children||nextProps.comfortCookiesAccepted!==this.props.comfortCookiesAccepted||nextProps.statisticsCookiesAccepted!==this.props.statisticsCookiesAccepted;}/**
|
|
12
15
|
* Updates embedded media within the html container.
|
|
13
16
|
*/},{key:"componentDidUpdate",value:function componentDidUpdate(){embeddedMedia.add(this.htmlContainer.current);}/**
|
|
14
17
|
* Removes the event handler.
|
|
15
|
-
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){this.htmlContainer.current.removeEventListener('click',this.handleTap,true);embeddedMedia.remove(this.htmlContainer.current);}
|
|
16
|
-
* If the user tapped a link element, prevent the default behavior.
|
|
17
|
-
* @param {Object} event The touchstart event.
|
|
18
|
-
*/},{key:"render",/**
|
|
18
|
+
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){this.htmlContainer.current.removeEventListener('click',this.handleTap,true);embeddedMedia.remove(this.htmlContainer.current);}},{key:"render",value:/**
|
|
19
19
|
* Renders the component.
|
|
20
20
|
* @returns {JSX}
|
|
21
|
-
*/
|
|
22
|
-
dangerouslySetInnerHTML:innerHTML,ref:this.htmlContainer,className:this.props.className}));}}]);
|
|
21
|
+
*/function render(){var cookieConsentSettings={comfortCookiesAccepted:this.props.comfortCookiesAccepted,statisticsCookiesAccepted:this.props.statisticsCookiesAccepted};var innerHTML={__html:parseHTML(this.props.children,this.props.decode,this.props.settings,this.props.processStyles,cookieConsentSettings)};var Wrapper=this.props.wrapper;return React.createElement(Wrapper,{cookieConsentSettings:cookieConsentSettings},React.createElement("div",{// eslint-disable-next-line react/no-danger
|
|
22
|
+
dangerouslySetInnerHTML:innerHTML,ref:this.htmlContainer,className:classNames(this.props.className,'common__html-sanitizer')}));}}]);}(Component);_defineProperty(HtmlSanitizer,"defaultProps",{children:'',className:'',decode:false,processStyles:false,settings:{},wrapper:EmbeddedMedia,comfortCookiesAccepted:false,statisticsCookiesAccepted:false});export default connect(HtmlSanitizer);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
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{mount}from'enzyme';import{JSDOM}from'jsdom';import{embeddedMedia}from'@shopgate/pwa-common/collections';import HtmlSanitizer from"./index";jest.mock(
|
|
1
|
+
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{mount}from'enzyme';import{JSDOM}from'jsdom';import{embeddedMedia}from'@shopgate/pwa-common/collections';import HtmlSanitizer from"./index";jest.mock("../EmbeddedMedia",function(){return function(_ref){var children=_ref.children;return children;};});jest.mock("./connector",function(){return function(Cmp){return Cmp;};});/**
|
|
2
2
|
* @param {string} html HTML markup.
|
|
3
3
|
* @param {Object} props Component props.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var createWrapper=function createWrapper(html){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return mount(React.createElement(HtmlSanitizer,_extends({navigate:function navigate(){}},props),html));};describe('<HtmlSanitizer />',function(){beforeEach(function(){jest.clearAllMocks();});it('should render the HtmlSanitizer',function(){/**
|
|
5
|
+
*/var createWrapper=function createWrapper(html){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return mount(React.createElement(HtmlSanitizer,_extends({navigate:function navigate(){}},props),html));};describe('<HtmlSanitizer />',function(){var embeddedMediaAddSpy;var embeddedMediaRemoveSpy;var embeddedMediaHandleCookieConsentSpy;beforeEach(function(){jest.clearAllMocks();embeddedMediaAddSpy=jest.spyOn(embeddedMedia,'add');embeddedMediaRemoveSpy=jest.spyOn(embeddedMedia,'remove');embeddedMediaHandleCookieConsentSpy=jest.spyOn(embeddedMedia,'handleCookieConsent');});it('should render the HtmlSanitizer',function(){/**
|
|
6
6
|
* The value for html is the HTML-escaped equivalent of the following:
|
|
7
7
|
* <h1>Hello World!</h1>
|
|
8
8
|
* @type {string}
|
|
9
9
|
*/var html='<h1>Hello World!</h1>';var wrapper=createWrapper(html,{decode:true});// Test result of dangerouslySetInnerHTML.
|
|
10
|
-
expect(wrapper.html()).toEqual('<div><h1>Hello World!</h1></div>');expect(wrapper.render()).toMatchSnapshot();});it('should add and remove handlers for embedded media',function(){var wrapper=createWrapper('<div></div>',{decode:true});var ref=wrapper.instance().htmlContainer.current;expect(
|
|
10
|
+
expect(wrapper.html()).toEqual('<div class="common__html-sanitizer"><h1>Hello World!</h1></div>');expect(wrapper.render()).toMatchSnapshot();});it('should add and remove handlers for embedded media',function(){var wrapper=createWrapper('<div></div>',{decode:true});var ref=wrapper.instance().htmlContainer.current;expect(embeddedMediaAddSpy).toHaveBeenCalledTimes(1);expect(embeddedMediaAddSpy).toHaveBeenCalledWith(ref);expect(embeddedMediaRemoveSpy).toHaveBeenCalledTimes(0);wrapper.setProps({children:'<span></span>'});expect(embeddedMediaAddSpy).toHaveBeenCalledTimes(2);expect(embeddedMediaAddSpy).toHaveBeenCalledWith(ref);expect(embeddedMediaRemoveSpy).toHaveBeenCalledTimes(0);wrapper.unmount();expect(embeddedMediaAddSpy).toHaveBeenCalledTimes(2);expect(embeddedMediaRemoveSpy).toHaveBeenCalledTimes(1);expect(embeddedMediaRemoveSpy).toHaveBeenCalledWith(ref);});it('strips out images with relative paths',function(){var html="\n <div>\n <style>a { color: red }</style>\n <a href=\"foo\">\n <img src=\"bar.jpg\" />\n </a>\n </div>\n ";var wrapper=createWrapper(html);expect(wrapper.html()).not.toContain('<img');expect(wrapper.html()).toContain('<style>');expect(wrapper.render()).toMatchSnapshot();});it('should move style blocks out of the content',function(){var html="\n <div>\n <style>a { color: red }</style>\n <a href=\"foo\">\n <img src=\"bar.jpg\" />\n </a>\n </div>\n ";var wrapper=createWrapper(html,{processStyles:true});expect(wrapper.html()).not.toContain('<style>');});it('does not strip out images with absolute paths',function(){var html="\n <div>\n <a href=\"foo\">\n <img src=\"http://google.de/bar.jpg\" />\n </a>\n </div>\n ";var wrapper=createWrapper(html);expect(wrapper.html()).toContain('<img');expect(wrapper.render()).toMatchSnapshot();});it('strips out the script tags',function(){/**
|
|
11
11
|
* The value for html is the HTML-escaped equivalent of the following:
|
|
12
12
|
* <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
|
|
13
13
|
* <script type="text/javascript">var x = 42;</script>
|
|
@@ -15,4 +15,4 @@ expect(wrapper.html()).toEqual('<div><h1>Hello World!</h1></div>');expect(wrappe
|
|
|
15
15
|
* <script>var y = 23;</script>
|
|
16
16
|
* @type {string}
|
|
17
17
|
*/var html='<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script> <script type="text/javascript">var x = 42;</script> <p>Foo Bar</p> <script>var y = 23;</script>';var wrapper=createWrapper(html,{decode:true});// Test result of dangerouslySetInnerHTML.
|
|
18
|
-
expect(wrapper.html()).toEqual('<div> <p>Foo Bar</p> </div>');expect(wrapper).toMatchSnapshot();});describe('Link handling',function(){var mockedHandleClick=jest.fn();beforeEach(function(){mockedHandleClick.mockClear();});it('follows a link from a plain <a>',function(){var doc=new JSDOM('<!doctype html><html><body><div>/<div></body></html>').window.document;var html='<a id="link" href="#follow-me-and-everything-is-alright">Plain Link</a>';var wrapper=mount(React.createElement(HtmlSanitizer,{decode:true,settings:{handleClick:mockedHandleClick},navigate:function navigate(){}},html),{attachTo:doc.getElementsByTagName('div')[0]});var aTag=doc.getElementsByTagName('a')[0];aTag.closest=function(){return aTag;};var event={target:aTag,preventDefault:function preventDefault(){}};wrapper.instance().handleTap(event);expect(mockedHandleClick).toHaveBeenCalledTimes(1);expect(mockedHandleClick).toHaveBeenCalledWith('#follow-me-and-everything-is-alright','');});it('follows a link from a <a> with other HTML inside',function(){var doc=new JSDOM('<!doctype html><html><body><div>/<div></body></html>').window.document;var html='<a id="link" target="_blank" href="#I-ll-be-the-one-to-tuck-you-in-at-night"><span>Span Link</span></a>';var wrapper=mount(React.createElement(HtmlSanitizer,{decode:true,settings:{handleClick:mockedHandleClick},navigate:function navigate(){}},html),{attachTo:doc.getElementsByTagName('div')[0]});var aTag=doc.getElementsByTagName('a')[0];var spanTag=doc.getElementsByTagName('span')[0];spanTag.closest=function(){return aTag;};var event={target:spanTag,preventDefault:function preventDefault(){}};wrapper.instance().handleTap(event);expect(mockedHandleClick).toHaveBeenCalledTimes(1);expect(mockedHandleClick).toHaveBeenCalledWith('#I-ll-be-the-one-to-tuck-you-in-at-night','_blank');});});});
|
|
18
|
+
expect(wrapper.html()).toEqual('<div class="common__html-sanitizer"> <p>Foo Bar</p> </div>');expect(wrapper).toMatchSnapshot();});describe('Link handling',function(){var mockedHandleClick=jest.fn();beforeEach(function(){mockedHandleClick.mockClear();});it('follows a link from a plain <a>',function(){var doc=new JSDOM('<!doctype html><html><body><div>/<div></body></html>').window.document;var html='<a id="link" href="#follow-me-and-everything-is-alright">Plain Link</a>';var wrapper=mount(React.createElement(HtmlSanitizer,{decode:true,settings:{handleClick:mockedHandleClick},navigate:function navigate(){}},html),{attachTo:doc.getElementsByTagName('div')[0]});var aTag=doc.getElementsByTagName('a')[0];aTag.closest=function(){return aTag;};var event={target:aTag,preventDefault:function preventDefault(){}};wrapper.instance().handleTap(event);expect(mockedHandleClick).toHaveBeenCalledTimes(1);expect(mockedHandleClick).toHaveBeenCalledWith('#follow-me-and-everything-is-alright','');});it('follows a link from a <a> with other HTML inside',function(){var doc=new JSDOM('<!doctype html><html><body><div>/<div></body></html>').window.document;var html='<a id="link" target="_blank" href="#I-ll-be-the-one-to-tuck-you-in-at-night"><span>Span Link</span></a>';var wrapper=mount(React.createElement(HtmlSanitizer,{decode:true,settings:{handleClick:mockedHandleClick},navigate:function navigate(){}},html),{attachTo:doc.getElementsByTagName('div')[0]});var aTag=doc.getElementsByTagName('a')[0];var spanTag=doc.getElementsByTagName('span')[0];spanTag.closest=function(){return aTag;};var event={target:spanTag,preventDefault:function preventDefault(){}};wrapper.instance().handleTap(event);expect(mockedHandleClick).toHaveBeenCalledTimes(1);expect(mockedHandleClick).toHaveBeenCalledWith('#I-ll-be-the-one-to-tuck-you-in-at-night','_blank');});});describe('Cookie consent handling',function(){it('should invoke handleCookieConsent method of embedded media with default cookie consent settings',function(){createWrapper('<div></div>',{decode:true});expect(embeddedMediaHandleCookieConsentSpy).toHaveBeenCalledTimes(1);expect(embeddedMediaHandleCookieConsentSpy).toHaveBeenCalledWith(expect.any(Document),{comfortCookiesAccepted:false,statisticsCookiesAccepted:false});});it('should invoke handleCookieConsent method of embedded media with accepted comfort cookies',function(){createWrapper('<div></div>',{decode:true,comfortCookiesAccepted:true});expect(embeddedMediaHandleCookieConsentSpy).toHaveBeenCalledTimes(1);expect(embeddedMediaHandleCookieConsentSpy).toHaveBeenCalledWith(expect.any(Document),{comfortCookiesAccepted:true,statisticsCookiesAccepted:false});});it('should invoke handleCookieConsent method of embedded media with accepted statistics cookies',function(){createWrapper('<div></div>',{decode:true,statisticsCookiesAccepted:true});expect(embeddedMediaHandleCookieConsentSpy).toHaveBeenCalledTimes(1);expect(embeddedMediaHandleCookieConsentSpy).toHaveBeenCalledWith(expect.any(Document),{comfortCookiesAccepted:false,statisticsCookiesAccepted:true});});it('should invoke handleCookieConsent method of embedded media with all cookies accepted',function(){createWrapper('<div></div>',{decode:true,comfortCookiesAccepted:true,statisticsCookiesAccepted:true});expect(embeddedMediaHandleCookieConsentSpy).toHaveBeenCalledTimes(1);expect(embeddedMediaHandleCookieConsentSpy).toHaveBeenCalledWith(expect.any(Document),{comfortCookiesAccepted:true,statisticsCookiesAccepted:true});});});});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import React,{memo}from'react';import PropTypes from'prop-types';import{i18n}from'@shopgate/engage/core/helpers/i18n';/**
|
|
1
|
+
var _excluded=["className"];function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import React,{memo}from'react';import PropTypes from'prop-types';import{i18n}from'@shopgate/engage/core/helpers/i18n';/**
|
|
2
2
|
* Formats a price.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var FormatPrice=function FormatPrice(props){var className=props.className,formatProps=_objectWithoutProperties(props,
|
|
5
|
+
*/var FormatPrice=function FormatPrice(props){var className=props.className,formatProps=_objectWithoutProperties(props,_excluded);if(!className){return FormatPrice.format(formatProps);}return React.createElement("span",{className:className},FormatPrice.format(formatProps));};FormatPrice.format=function(_ref){var price=_ref.price,currency=_ref.currency,fractions=_ref.fractions;if(!i18n.ready){return price;}return i18n.price(price,currency,fractions);};FormatPrice.defaultProps={className:null,fractions:true};export default memo(FormatPrice);
|
|
@@ -1,16 +1,16 @@
|
|
|
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
|
|
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{i18n}from'@shopgate/engage/core/helpers/i18n';import{logger}from'@shopgate/pwa-core/helpers';/**
|
|
2
2
|
* A React component that provides child components with i18n features.
|
|
3
3
|
* @returns {React.Component}
|
|
4
|
-
*/var I18nProvider=/*#__PURE__*/function(_Component){
|
|
4
|
+
*/var I18nProvider=/*#__PURE__*/function(_Component){/**
|
|
5
5
|
* @inheritDoc
|
|
6
|
-
*/function I18nProvider(props){var
|
|
7
|
-
|
|
8
|
-
* Provides context for child components.
|
|
9
|
-
* @returns {Object}
|
|
10
|
-
*/_createClass(I18nProvider,[{key:"getChildContext",value:function getChildContext(){return{i18n:this.getI18nInstance};}/**
|
|
6
|
+
*/function I18nProvider(props){var _this2;_classCallCheck(this,I18nProvider);_this2=_callSuper(this,I18nProvider,[props]);// eslint-disable-next-line react/prop-types
|
|
7
|
+
/**
|
|
11
8
|
* Gets a shortcut to i18n functionality with preset language.
|
|
12
9
|
* @returns {Object}
|
|
13
|
-
*/
|
|
10
|
+
*/_defineProperty(_this2,"getI18nInstance",function(){return{__:i18n.text,_p:i18n.price,_d:i18n.date,_t:i18n.time,_n:i18n.number};});if(_this2.props.lang||_this2.props.locales){logger.warn("===== I18nProvider deprecated =====\nI18nProvider and it's related components (@shopgate/pwa-common/component/I18n) or context types are deprecated and will be removed in @shopgate/engage v7.0.0.\nPlease use { i18n } from @shopgate/engage/core.\n===================================\n ");}return _this2;}/**
|
|
11
|
+
* Provides context for child components.
|
|
12
|
+
* @returns {Object}
|
|
13
|
+
*/_inherits(I18nProvider,_Component);return _createClass(I18nProvider,[{key:"getChildContext",value:function getChildContext(){return{i18n:this.getI18nInstance};}},{key:"render",value:/**
|
|
14
14
|
* Renders the component.
|
|
15
15
|
* @returns {JSX}
|
|
16
|
-
*/
|
|
16
|
+
*/function render(){var children=this.props.children;return children?React.cloneElement(children):null;}}]);}(Component);_defineProperty(I18nProvider,"childContextTypes",{i18n:PropTypes.func.isRequired});_defineProperty(I18nProvider,"defaultProps",{children:null});export{I18nProvider as default};
|
|
@@ -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);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import React from'react';import PropTypes from'prop-types';import{renderToString}from'react-dom/server';import{logger}from'@shopgate/pwa-core';import{i18n}from'@shopgate/engage/core/helpers/i18n';/**
|
|
1
|
+
var _excluded=["string","children","params","className","role","transform","acceptPlainTextWithPlaceholders"];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 _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import React from'react';import PropTypes from'prop-types';import{renderToString}from'react-dom/server';import{logger}from'@shopgate/pwa-core';import{i18n}from'@shopgate/engage/core/helpers/i18n';/**
|
|
2
2
|
* Returns a translation and replaces placeholder with children output.
|
|
3
3
|
* It is possible to either pass JSX components or plain strings as replacement for
|
|
4
4
|
* the translation keys.
|
|
@@ -6,14 +6,18 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
|
|
|
6
6
|
* and pass the JSX nodes as children.
|
|
7
7
|
* @param {Object} props The component props.
|
|
8
8
|
* @param {Object} props.string The string to translate.
|
|
9
|
-
* @param {
|
|
9
|
+
* @param {Object} [props.params] Object with translation placeholder replacements
|
|
10
|
+
* @param {Array} [props.children] Children to use as placeholders. Must be one of the components
|
|
10
11
|
* provided by I18n.
|
|
11
|
-
* @param {string} props.className Additional classes to append to the translated wrapper element.
|
|
12
|
+
* @param {string} [props.className] Additional classes to append to the translated wrapper element.
|
|
13
|
+
* @param {string} [props.role] Optional aria role
|
|
12
14
|
* @param {Function} [props.transform] Input a function to modify the resulting string.
|
|
13
|
-
* @
|
|
14
|
-
|
|
15
|
+
* @param {boolean} [acceptPlainTextWithPlaceholders=false] When set to TRUE, the component can
|
|
16
|
+
* also handle human readable texts that contain text replacement placeholders.
|
|
17
|
+
* @returns {JSX.Element} The translated string as JSX component.
|
|
18
|
+
*/var Translate=function Translate(_ref){var string=_ref.string,children=_ref.children,params=_ref.params,className=_ref.className,role=_ref.role,transform=_ref.transform,acceptPlainTextWithPlaceholders=_ref.acceptPlainTextWithPlaceholders,rest=_objectWithoutProperties(_ref,_excluded);if(typeof string!=='string'||string.length===0){return string;}if(!i18n.ready){return React.createElement("span",_extends({className:className,role:role},rest),string);}// When the input string is malformed, return the original string rather than raising an error.
|
|
15
19
|
var formatted=string;try{// First replace every occurrence of a translation key with a separator.
|
|
16
20
|
var separator='__%S%__';var childrenArray=React.Children.toArray(children);var values=childrenArray.reduce(function(obj,child){return child.props&&child.props.forKey?_extends({},obj,_defineProperty({},child.props.forKey,separator)):obj;},_extends({},params));// Split the tokenized string at the separators.
|
|
17
|
-
var stringParts=i18n.text(string,values).split(separator);// Create a new array containing the separated chunks of the text and merge the substitutions.
|
|
21
|
+
var stringParts=i18n.text(string,values,{acceptPlainTextWithPlaceholders:acceptPlainTextWithPlaceholders}).split(separator);// Create a new array containing the separated chunks of the text and merge the substitutions.
|
|
18
22
|
// The result can be an array with multiple strings and will be joined together.
|
|
19
|
-
formatted=stringParts.reduce(function(result,text,index){return[].concat(result,[text,childrenArray[index]]);},[]);}catch(e){logger.error('i18n error for string %s',string,e);}return React.createElement("span",_extends({className:className,role:role},rest),!transform?formatted:transform(renderToString(formatted)));};Translate.defaultProps={children:null,className:null,params:{},role:null,transform:null};export default Translate;
|
|
23
|
+
formatted=stringParts.reduce(function(result,text,index){return[].concat(result,[text,childrenArray[index]]);},[]);}catch(e){logger.error('i18n error for string %s',string,e);}return React.createElement("span",_extends({className:className,role:role},rest),!transform?formatted:transform(renderToString(formatted)));};Translate.defaultProps={children:null,className:null,params:{},role:null,transform:null,acceptPlainTextWithPlaceholders:false};export default Translate;
|
package/components/Icon/index.js
CHANGED
|
@@ -6,4 +6,4 @@ import React from'react';import PropTypes from'prop-types';import styles from"./
|
|
|
6
6
|
* @param {string} [props.viewBox] The viewBox attribute passed to the SVG
|
|
7
7
|
* @param {number} [props.size=24] The icon size
|
|
8
8
|
* @returns {JSX}
|
|
9
|
-
*/var Icon=function Icon(props){return React.createElement("svg",{className:"".concat(styles," ").concat(props.className),viewBox:props.viewBox,xmlns:"http://www.w3.org/2000/svg",dangerouslySetInnerHTML:{__html:props.content},style:{fontSize:props.size,fill:props.color}});};Icon.defaultProps={className:'',color:null,viewBox:'0 0 24 24',size:'inherit'};export default Icon;
|
|
9
|
+
*/var Icon=function Icon(props){return React.createElement("svg",{className:"".concat(styles," ").concat(props.className," common__icon"),viewBox:props.viewBox,xmlns:"http://www.w3.org/2000/svg",dangerouslySetInnerHTML:{__html:props.content},style:{fontSize:props.size,fill:props.color}});};Icon.defaultProps={className:'',color:null,viewBox:'0 0 24 24',size:'inherit'};export default Icon;
|