@shopgate/engage 6.20.0-beta.3 → 6.20.0-beta.4
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/a11y/components/LiveMessage/__tests__/index.spec.js +1 -1
- package/a11y/components/LiveMessage/index.js +1 -1
- package/a11y/components/LiveMessenger/__tests__/index.spec.js +1 -1
- package/a11y/components/LiveMessenger/helpers.js +1 -1
- package/a11y/components/LiveMessenger/index.js +2 -2
- package/a11y/components/Navigation/__tests__/index.spec.js +1 -1
- package/a11y/components/Navigation/index.js +1 -1
- package/a11y/components/Section/__tests__/index.spec.js +1 -1
- package/a11y/components/Section/index.js +2 -2
- package/a11y/index.spec.js +1 -1
- package/account/constants/index.js +1 -0
- package/account/constants/routes.js +1 -0
- package/account/index.js +1 -0
- package/app-rating/actions/showModal.js +2 -2
- package/cart/index.spec.js +1 -1
- package/category/components/CategoryList/index.js +1 -1
- package/category/index.spec.js +1 -1
- package/checkout/index.spec.js +1 -1
- package/components/ChipLayout/index.js +11 -11
- package/components/ChipLayout/spec.js +1 -1
- package/components/Footer/Footer.js +9 -9
- package/components/Footer/__tests__/Footer.spec.js +4 -4
- package/components/Form/Builder/Builder.js +10 -10
- package/components/Form/Builder/Builder.spec.js +4 -4
- package/components/Form/Builder/ElementCheckbox.js +1 -1
- package/components/Form/Builder/ElementRadio.js +1 -1
- package/components/Form/Builder/ElementSelect.js +1 -1
- package/components/Form/Builder/ElementText.js +1 -1
- package/components/Form/Builder/classes/ActionListener.js +3 -3
- package/components/Form/Builder/helpers/buildCountryList.js +1 -1
- package/components/Form/Builder/helpers/buildFormDefaults.js +1 -1
- package/components/Form/Builder/helpers/buildFormElements.js +2 -2
- package/components/Form/Builder/helpers/buildFormElements.spec.js +2 -2
- package/components/Form/Builder/helpers/buildProvinceList.js +1 -1
- package/components/Form/Form.js +8 -8
- package/components/IntersectionVisibility/index.js +5 -5
- package/components/Logo/index.js +1 -1
- package/components/Logo/spec.js +1 -1
- package/components/MessageBar/index.js +1 -1
- package/components/MessageBar/spec.js +1 -1
- package/components/NavigationHandler/index.js +5 -5
- package/components/NavigationHandler/spec.js +1 -1
- package/components/Picker/components/Button/index.js +1 -1
- package/components/Picker/components/List/index.js +1 -1
- package/components/Picker/components/Modal/index.js +5 -5
- package/components/Picker/index.js +9 -9
- package/components/Picker/spec.js +1 -1
- package/components/PickerUtilize/components/Button/index.js +1 -1
- package/components/PickerUtilize/index.js +6 -6
- package/components/PickerUtilize/spec.js +1 -1
- package/components/QuantityInput/QuantityInput.js +4 -4
- package/components/RangeSlider/components/Handle/index.js +1 -1
- package/components/RangeSlider/index.js +11 -11
- package/components/RangeSlider/spec.js +4 -4
- package/components/ScrollHeader/index.js +2 -2
- package/components/SheetDrawer/index.js +1 -1
- package/components/SheetList/components/Item/index.js +5 -5
- package/components/SheetList/components/Item/spec.js +2 -2
- package/components/SheetList/index.js +4 -4
- package/components/SheetList/spec.js +1 -1
- package/components/SnackBarContainer/index.js +1 -1
- package/components/TimeBoundary/index.js +5 -5
- package/components/TimeBoundary/spec.js +3 -3
- package/components/VideoPlayer/index.js +6 -6
- package/components/View/__mocks__/index.js +1 -1
- package/components/View/__tests__/index.spec.js +1 -1
- package/components/View/__tests__/provider.spec.js +1 -1
- package/components/View/components/Above/__tests__/index.spec.js +1 -1
- package/components/View/components/Above/index.js +1 -1
- package/components/View/components/Below/__tests__/index.spec.js +1 -1
- package/components/View/components/Below/index.js +1 -1
- package/components/View/components/Content/__tests__/index.spec.js +1 -1
- package/components/View/components/Content/index.js +9 -9
- package/components/View/context.js +1 -1
- package/components/View/index.js +2 -2
- package/components/View/provider.js +6 -4
- package/components/index.spec.js +1 -1
- package/core/actions/__tests__/getGeolocation.spec.js +2 -2
- package/core/actions/__tests__/grantPermissions.spec.js +1 -1
- package/core/actions/getGeolocation.js +1 -1
- package/core/actions/grantPermissions.js +3 -3
- package/core/classes/GeolocationRequest.js +3 -3
- package/core/config/ThemeConfigResolver.js +1 -1
- package/core/constants/shopSettings.js +2 -0
- package/core/contexts/AppContext.js +1 -1
- package/core/helpers/getFullImageSource.js +2 -2
- package/core/helpers/updateLegacyNavigationBar.js +1 -1
- package/core/hocs/__mocks__/withWidgetSettings.js +1 -1
- package/core/hocs/__tests__/withApp.spec.js +1 -1
- package/core/hocs/__tests__/withCurrentProduct.spec.js +1 -1
- package/core/hocs/__tests__/withForwardedRef.spec.js +1 -1
- package/core/hocs/__tests__/withNavigation.spec.js +1 -1
- package/core/hocs/__tests__/withRoute.spec.js +1 -1
- package/core/hocs/__tests__/withTheme.spec.js +2 -2
- package/core/hocs/__tests__/withWidgetSettings.spec.js +1 -1
- package/core/hocs/__tests__/withWidgetStyles.spec.js +1 -1
- package/core/hocs/withApp.js +1 -1
- package/core/hocs/withCurrentProduct.js +1 -1
- package/core/hocs/withForwardedRef.js +1 -1
- package/core/hocs/withNavigation.js +1 -1
- package/core/hocs/withRoute.js +1 -1
- package/core/hocs/withTheme.js +2 -2
- package/core/hocs/withWidgetSettings.js +1 -1
- package/core/hocs/withWidgetStyles.js +1 -1
- package/core/hooks/__tests__/useNavigation.spec.js +1 -1
- package/core/hooks/html/useLoadImage.js +1 -1
- package/core/hooks/useTheme.js +2 -2
- package/core/index.spec.js +1 -1
- package/core/providers/AppProvider.js +9 -7
- package/core/providers/__tests__/AppProvider.spec.js +2 -2
- package/core/selectors/index.js +1 -0
- package/core/selectors/shopSettings.js +14 -0
- package/favorites/components/FavoriteProvider/connector.js +5 -0
- package/favorites/components/FavoriteProvider/index.js +4 -0
- package/favorites/components/Item/Item.js +10 -0
- package/favorites/components/Item/ItemCharacteristics.js +4 -0
- package/favorites/components/Item/index.js +1 -0
- package/favorites/components/List/List.js +16 -0
- package/favorites/components/List/index.js +1 -0
- package/favorites/components/ListChooser/ListChooser.js +10 -0
- package/favorites/components/ListChooser/ListChooserItem.js +7 -0
- package/favorites/components/ListChooser/index.js +1 -0
- package/favorites/components/Lists/Lists.js +16 -0
- package/favorites/components/Lists/ListsModal.js +4 -0
- package/favorites/components/Lists/index.js +1 -0
- package/favorites/components/RemoveButton/RemoveButton.js +4 -0
- package/favorites/components/RemoveButton/index.js +1 -0
- package/favorites/constants/Portals.js +2 -0
- package/favorites/index.js +3 -4
- package/favorites/index.spec.js +1 -1
- package/filter/components/FilterItem/index.js +1 -1
- package/filter/components/FilterItem/spec.js +1 -1
- package/filter/components/PriceSlider/components/Label/index.js +2 -2
- package/filter/components/PriceSlider/components/Label/spec.js +1 -1
- package/filter/components/PriceSlider/index.js +6 -6
- package/filter/components/PriceSlider/spec.js +1 -1
- package/filter/helpers/__tests__/buildUpdatedFilters.spec.js +1 -1
- package/filter/helpers/buildInitialFilters.js +1 -1
- package/filter/helpers/buildUpdatedFilters.js +2 -2
- package/filter/index.spec.js +1 -1
- package/index.spec.js +1 -1
- package/market/index.spec.js +1 -1
- package/orders/index.spec.js +1 -1
- package/package.json +7 -7
- package/page/index.spec.js +1 -1
- package/product/components/Characteristics/Characteristic/components/Sheet/index.js +4 -4
- package/product/components/Characteristics/Characteristic/components/SheetItem/index.js +3 -3
- package/product/components/Characteristics/Characteristic/components/VariantAvailability/index.js +3 -3
- package/product/components/Characteristics/Characteristic/index.js +5 -5
- package/product/components/Characteristics/Swatch/index.js +5 -5
- package/product/components/Characteristics/index.js +3 -3
- package/product/components/Description/__tests__/Description.spec.js +1 -1
- package/product/components/Description/index.js +2 -2
- package/product/components/EffectivityDates/index.js +1 -1
- package/product/components/Header/PriceStriked/index.js +1 -1
- package/product/components/Header/Shipping/components/Label/index.js +2 -2
- package/product/components/Header/Shipping/index.js +1 -1
- package/product/components/Header/Shipping/spec.js +1 -1
- package/product/components/Header/Tiers/components/Tier/index.js +2 -2
- package/product/components/Header/Tiers/components/Tier/spec.js +1 -1
- package/product/components/Header/Tiers/index.js +1 -1
- package/product/components/Header/Tiers/spec.js +1 -1
- package/product/components/MapPriceHint/index.js +1 -1
- package/product/components/Media/FeaturedMedia.js +1 -1
- package/product/components/Media/MediaImage.js +2 -2
- package/product/components/Media/MediaPlaceholder.js +1 -1
- package/product/components/Media/helpers.js +2 -2
- package/product/components/MediaSlider/components/MediaImage/index.js +1 -1
- package/product/components/MediaSlider/components/MediaVideo/index.js +1 -1
- package/product/components/MediaSlider/index.js +1 -1
- package/product/components/Options/components/Content/index.js +6 -6
- package/product/components/Options/components/Content/spec.js +1 -1
- package/product/components/Options/components/Option/index.js +1 -1
- package/product/components/Options/components/TextOption/components/OptionInfo/index.js +2 -2
- package/product/components/Options/components/TextOption/components/OptionInfo/spec.js +1 -1
- package/product/components/Options/components/TextOption/index.js +6 -6
- package/product/components/Options/index.js +1 -1
- package/product/components/OrderQuantityHint/index.js +1 -1
- package/product/components/PriceDifference/index.js +1 -1
- package/product/components/ProductBadges/index.js +2 -2
- package/product/components/ProductCard/index.js +2 -2
- package/product/components/ProductCharacteristics/context.js +1 -1
- package/product/components/ProductCharacteristics/index.js +9 -9
- package/product/components/ProductDiscountBadge/index.js +1 -1
- package/product/components/ProductDiscountBadge/spec.js +1 -1
- package/product/components/ProductGridPrice/index.js +1 -1
- package/product/components/ProductGridPrice/index.spec.js +1 -1
- package/product/components/ProductImage/index.js +7 -7
- package/product/components/ProductImage/spec.js +1 -1
- package/product/components/ProductList/components/Item/index.js +1 -1
- package/product/components/ProductList/components/Iterator/index.js +1 -1
- package/product/components/ProductList/components/Layout/index.js +1 -1
- package/product/components/ProductList/index.js +1 -1
- package/product/components/ProductProperties/Content.js +2 -2
- package/product/components/ProductProperties/Group.js +1 -1
- package/product/components/ProductProperties/GroupedProperties.js +1 -1
- package/product/components/ProductProperties/Lists.js +1 -1
- package/product/components/ProductProperties/ProductProperties.js +1 -1
- package/product/components/ProductProperties/Row.js +1 -1
- package/product/components/ProductProperties/Rows.js +1 -1
- package/product/components/ProductProperties/Wrapper.js +1 -1
- package/product/components/ProductProperties/__tests__/Content.spec.js +1 -1
- package/product/components/ProductProperties/__tests__/Group.spec.js +1 -1
- package/product/components/ProductProperties/__tests__/GroupedProperties.spec.js +1 -1
- package/product/components/ProductProperties/__tests__/Lists.spec.js +1 -1
- package/product/components/ProductProperties/__tests__/ProductProperties.spec.js +1 -1
- package/product/components/ProductProperties/__tests__/Row.spec.js +1 -1
- package/product/components/ProductProperties/__tests__/Rows.spec.js +1 -1
- package/product/components/ProductProvider/index.js +1 -1
- package/product/components/ProductSlider/index.js +1 -1
- package/product/components/ProductSlider/spec.js +1 -1
- package/product/components/QuantityPicker/index.js +2 -2
- package/product/components/Rating/index.js +2 -2
- package/product/components/Rating/spec.js +1 -1
- package/product/components/RelationsSlider/RelationsSheet.js +2 -2
- package/product/components/RelationsSlider/RelationsSlider.js +1 -1
- package/product/components/RelationsSlider/RelationsSliderContent.js +1 -1
- package/product/components/Swatch/Swatch.js +1 -1
- package/product/components/Swatch/SwatchContent.js +1 -1
- package/product/components/Swatch/VariantSwatch.js +1 -1
- package/product/components/Swatches/Swatches.js +1 -1
- package/product/components/UnitQuantityPicker/ProductUnitQuantityPicker.js +1 -1
- package/product/components/UnitQuantityPicker/UnitQuantityPicker.js +1 -1
- package/product/components/UnitQuantityPicker/UnitQuantityPickerWithSection.js +1 -1
- package/product/components/__mocks__/context.js +1 -1
- package/product/components/context.js +1 -1
- package/product/helpers/index.js +1 -1
- package/product/hocs/withMapPricing.js +4 -4
- package/product/hocs/withPriceCalculation.js +2 -2
- package/product/hooks/useLoadProductImage.js +1 -1
- package/product/index.spec.js +1 -1
- package/reviews/components/Reviews/components/AllReviewsLink/index.js +1 -1
- package/reviews/components/Reviews/components/Header/components/AverageRating/index.js +2 -2
- package/reviews/components/Reviews/components/Header/components/NoReviews/index.js +1 -1
- package/reviews/components/Reviews/components/Header/components/ReviewsExcerpt/index.js +1 -1
- package/reviews/components/Reviews/components/Header/components/WriteReviewLink/index.js +1 -1
- package/reviews/components/Reviews/components/Header/components/WriteReviewLink/spec.js +1 -1
- package/reviews/components/Reviews/components/Header/index.js +1 -1
- package/reviews/components/Reviews/components/Header/spec.js +1 -1
- package/reviews/components/Reviews/components/List/components/Info/components/Author/index.js +1 -1
- package/reviews/components/Reviews/components/List/components/Info/components/ReviewDate/index.js +1 -1
- package/reviews/components/Reviews/components/List/components/Info/index.js +2 -2
- package/reviews/components/Reviews/components/List/components/Rating/index.js +1 -1
- package/reviews/components/Reviews/components/List/components/Review/index.js +1 -1
- package/reviews/components/Reviews/components/List/components/Text/index.js +1 -1
- package/reviews/components/Reviews/components/List/components/Title/index.js +1 -1
- package/reviews/components/Reviews/components/List/index.js +3 -3
- package/reviews/components/Reviews/components/List/spec.js +1 -1
- package/reviews/components/Reviews/components/RatingCount/index.js +1 -1
- package/reviews/components/Reviews/components/RatingCount/spec.js +1 -1
- package/reviews/components/Reviews/index.js +1 -1
- package/reviews/components/Reviews/spec.js +2 -2
- package/reviews/index.spec.js +1 -1
- package/scanner/index.spec.js +1 -1
- package/search/index.spec.js +1 -1
- package/user/index.spec.js +1 -1
- package/core/helpers/getImageFormat.js +0 -4
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
function _typeof(obj){
|
|
1
|
+
function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_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);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}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}});Object.defineProperty(subClass,"prototype",{writable:false});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 _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}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 _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent}from'react';import PropTypes from'prop-types';import cxs from'classnames';import styles from"./style";import Handle from"./components/Handle";import{generateLinearEasingCallback,generateExponentialEasingCallback,getRangeStyle,getTouchPositionX,getAbsoluteValue,getRelativeValue}from"./helper";/**
|
|
2
2
|
* The range slider component.
|
|
3
|
-
*/var RangeSlider=/*#__PURE__*/function(_PureComponent){_inherits(RangeSlider,_PureComponent);/**
|
|
3
|
+
*/var RangeSlider=/*#__PURE__*/function(_PureComponent){_inherits(RangeSlider,_PureComponent);var _super=_createSuper(RangeSlider);/**
|
|
4
4
|
* Constructor
|
|
5
5
|
* @param {Object} props The component properties
|
|
6
|
-
*/function RangeSlider(props){var _this;_classCallCheck(this,RangeSlider);_this=
|
|
6
|
+
*/function RangeSlider(props){var _this;_classCallCheck(this,RangeSlider);_this=_super.call(this,props);_defineProperty(_assertThisInitialized(_this),"handleTouchStart",function(event,index){_this.draggedHandle=index;// Calculate the relative offset to the handles center
|
|
7
7
|
var handleDOMElement=event.target;// Get the handles bounding rectangle ...
|
|
8
8
|
var handleRect=handleDOMElement.getBoundingClientRect();// ... and calculate its absolute center.
|
|
9
9
|
var handleCenterX=handleRect.left+handleDOMElement.offsetWidth/2;// Store the signed distanced between the current touch offset and the handle center.
|
|
@@ -14,7 +14,7 @@ if(_this.state.rangeMin<deltaX){stateUpdate.rangeMax=Math.min(1,deltaX);_this.dr
|
|
|
14
14
|
_this.draggedHandle=0;stateUpdate.rangeMax=_this.state.rangeMin;stateUpdate.rangeMin=deltaX;_this.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMin-_this.state.rangeMin);}}else if(_this.draggedHandle===0){// Left handle dragged
|
|
15
15
|
if(_this.state.rangeMax>deltaX){stateUpdate.rangeMin=Math.max(0,deltaX);_this.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMin-_this.state.rangeMin);}else{// Not in valid range, swap handles
|
|
16
16
|
_this.draggedHandle=1;stateUpdate.rangeMin=_this.state.rangeMax;stateUpdate.rangeMax=deltaX;_this.draggedHandlePixelOffset=Math.abs(stateUpdate.rangeMax-_this.state.rangeMax);}}_this.draggedHandlePixelOffset*=_this.domElement.current.offsetWidth;_this.setState(stateUpdate,_this.triggerChangeCallback);});_defineProperty(_assertThisInitialized(_this),"handleTouchEnd",function(){_this.touchOffset=0;_this.draggedHandle=null;});_defineProperty(_assertThisInitialized(_this),"handleRangeTouch",function(event){var _this$domElement$curr2=_this.domElement.current,offsetWidth=_this$domElement$curr2.offsetWidth,offsetLeft=_this$domElement$curr2.offsetLeft;var dx=(getTouchPositionX(event)-offsetLeft)/offsetWidth;var d0=Math.abs(_this.state.rangeMin-dx);var d1=Math.abs(_this.state.rangeMax-dx);if(d0<d1){_this.draggedHandle=0;}else{_this.draggedHandle=1;}_this.handleTouchMove(event);});_defineProperty(_assertThisInitialized(_this),"handleInputChange",function(event){var max=_this.props.max;var _event$target=event.target,value=_event$target.value,id=_event$target.id;var delta=Math.max(0,Math.min(1,value/(max/100)));var state=id==='price_from'?{rangeMin:delta}:{rangeMax:delta};_this.setState(state);});_this.draggedHandle=null;// 0 for left handle, 1 for right handle or null
|
|
17
|
-
_this.domElement
|
|
17
|
+
_this.domElement=/*#__PURE__*/React.createRef();_this.touchOffset=0;_this.draggedHandlePixelOffset=0;// The absolute pixel delta of the last handle move event.
|
|
18
18
|
_this.state=_this.getRange(props);return _this;}/**
|
|
19
19
|
* Sets the global event listeners when component mounts.
|
|
20
20
|
*/_createClass(RangeSlider,[{key:"componentDidMount",value:function componentDidMount(){document.addEventListener('touchend',this.handleTouchEnd);document.addEventListener('touchmove',this.handleTouchMove);}/**
|
|
@@ -24,19 +24,19 @@ _this.state=_this.getRange(props);return _this;}/**
|
|
|
24
24
|
* Removes the global event listeners when component unmounts.
|
|
25
25
|
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){document.removeEventListener('touchend',this.handleTouchEnd);document.removeEventListener('touchmove',this.handleTouchMove);}/**
|
|
26
26
|
* Get the easing function.
|
|
27
|
-
*/},{key:"
|
|
27
|
+
*/},{key:"ease",get:function get(){return{linear:generateLinearEasingCallback(this.props.resolution),exponential:generateExponentialEasingCallback(this.props.factor)}[this.props.easing];}/**
|
|
28
|
+
* Get the function to invert an eased value to it's original value.
|
|
29
|
+
*/},{key:"invertedEase",get:function get(){return{linear:generateLinearEasingCallback(this.props.resolution),exponential:generateExponentialEasingCallback(1/this.props.factor)}[this.props.easing];}/**
|
|
28
30
|
* Get range min and max from props.
|
|
29
31
|
* @param {Object} props The component props.
|
|
30
32
|
* @returns {Object} The new state
|
|
31
|
-
*/value:function getRange(props){var value=props.value,min=props.min,max=props.max;return{rangeMin:this.invertedEase(getRelativeValue(value[0],min,max)),rangeMax:this.invertedEase(getRelativeValue(value[1],min,max))};}/**
|
|
33
|
+
*/},{key:"getRange",value:function getRange(props){var value=props.value,min=props.min,max=props.max;return{rangeMin:this.invertedEase(getRelativeValue(value[0],min,max)),rangeMax:this.invertedEase(getRelativeValue(value[1],min,max))};}/**
|
|
32
34
|
* Processes touch start events on handles.
|
|
33
35
|
* @param {Object} event The touch event
|
|
34
36
|
* @param {number} index The index of the touched handle.
|
|
35
|
-
*/},{key:"triggerChangeCallback"
|
|
37
|
+
*/},{key:"triggerChangeCallback",value:/**
|
|
36
38
|
* Calls the change callback in case of a state update.
|
|
37
|
-
*/
|
|
39
|
+
*/function triggerChangeCallback(){var _this$props=this.props,value=_this$props.value,onChange=_this$props.onChange,min=_this$props.min,max=_this$props.max;if(!onChange){return;}var newRange=[getAbsoluteValue(this.ease(this.state.rangeMin),min,max,true),getAbsoluteValue(this.ease(this.state.rangeMax),min,max,true)];if(newRange!==value){onChange(newRange);}}/**
|
|
38
40
|
* Renders the component.
|
|
39
41
|
* @returns {JSX}
|
|
40
|
-
*/},{key:"render",value:function render(){var _this$props2=this.props,classNames=_this$props2.classNames,animationSpeed=_this$props2.animationSpeed;var speed=Math.round(1000/animationSpeed*this.draggedHandlePixelOffset);var rangeStyle=getRangeStyle(this.state.rangeMin,this.state.rangeMax,speed>10?speed:0);return
|
|
41
|
-
* Get the function to invert an eased value to it's original value.
|
|
42
|
-
*/},{key:"invertedEase",get:function get(){return{linear:generateLinearEasingCallback(this.props.resolution),exponential:generateExponentialEasingCallback(1/this.props.factor)}[this.props.easing];}}]);return RangeSlider;}(PureComponent);_defineProperty(RangeSlider,"defaultProps",{animationSpeed:500,classNames:{},easing:'linear',factor:2,max:100,min:0,resolution:1,value:[0,100],onChange:null});export default RangeSlider;
|
|
42
|
+
*/},{key:"render",value:function render(){var _this$props2=this.props,classNames=_this$props2.classNames,animationSpeed=_this$props2.animationSpeed;var speed=Math.round(1000/animationSpeed*this.draggedHandlePixelOffset);var rangeStyle=getRangeStyle(this.state.rangeMin,this.state.rangeMax,speed>10?speed:0);return/*#__PURE__*/React.createElement("div",{className:cxs(classNames.container,'engage__range-slider'),onTouchStart:this.handleRangeTouch,"aria-hidden":true},/*#__PURE__*/React.createElement("div",{className:cxs(classNames.outerRange,styles.outerRange),ref:this.domElement},/*#__PURE__*/React.createElement("div",{className:cxs(classNames.range,styles.range),style:rangeStyle},/*#__PURE__*/React.createElement(Handle,{index:0,onTouchStart:this.handleTouchStart,active:this.draggedHandle===0,classNames:classNames}),/*#__PURE__*/React.createElement(Handle,{index:1,onTouchStart:this.handleTouchStart,active:this.draggedHandle===1,classNames:classNames}))));}}]);return RangeSlider;}(PureComponent);_defineProperty(RangeSlider,"defaultProps",{animationSpeed:500,classNames:{},easing:'linear',factor:2,max:100,min:0,resolution:1,value:[0,100],onChange:null});export default RangeSlider;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e
|
|
1
|
+
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React from'react';import{shallow,mount}from'enzyme';import RangeSlider from"./index";import RangeSliderHandle from"./components/Handle";import{generateLinearEasingCallback,generateExponentialEasingCallback,getAbsoluteValue,getRelativeValue}from"./helper";/**
|
|
2
2
|
* Creates a (fake) touch event.
|
|
3
3
|
* @param {number} pageX the x page offset of the simulated touch event
|
|
4
4
|
* @returns {Object} the new fake event containing only the properties required for testing.
|
|
@@ -19,10 +19,10 @@ left:pageX-simulatedHandleHalfWidth};}},touches:[{pageX:pageX}]};return touchEve
|
|
|
19
19
|
* @param {Array} simulateSteps A set of relative horizontal pixel movements to simulate.
|
|
20
20
|
* @param {Function} testCallback An optional callback for the onChange event of the slider.
|
|
21
21
|
*/var simulateInputTest=function simulateInputTest(pxWidth,pxOffset,min,max,value,easing,resolutionOrFactor,simulateSteps,testCallback){var config={totalPixelWidth:pxWidth,leftPixelOffset:pxOffset,min:min,max:max,easing:easing,resolution:resolutionOrFactor,factor:resolutionOrFactor,initialValue:value,valuePixelSize:pxWidth/(max-min),currentTouchDeltaX:0};config.currentTouchDeltaX=config.valuePixelSize*value[1];var ease={linear:generateLinearEasingCallback(config.resolution),exponential:generateExponentialEasingCallback(config.factor)}[config.easing];// eslint-disable-next-line require-jsdoc
|
|
22
|
-
var callback=function callback(_ref){var _ref2=_slicedToArray(_ref,2),from=_ref2[0],to=_ref2[1];var currentTouchDeltaX=config.currentTouchDeltaX,valuePixelSize=config.valuePixelSize;var relativeValue=getRelativeValue(currentTouchDeltaX/valuePixelSize,min,max);var expected=getAbsoluteValue(ease(relativeValue),config.min,config.max,true);expect(expected===from||expected===to).toBe(true);if(testCallback){testCallback(config,from,to);}};var wrapper=mount(React.createElement(RangeSlider,{min:config.min,max:config.max,value:config.initialValue,easing:easing,resolution:config.resolution,factor:config.factor,onChange:callback}));expect(wrapper).toMatchSnapshot();// Create a simulated touch event.
|
|
22
|
+
var callback=function callback(_ref){var _ref2=_slicedToArray(_ref,2),from=_ref2[0],to=_ref2[1];var currentTouchDeltaX=config.currentTouchDeltaX,valuePixelSize=config.valuePixelSize;var relativeValue=getRelativeValue(currentTouchDeltaX/valuePixelSize,min,max);var expected=getAbsoluteValue(ease(relativeValue),config.min,config.max,true);expect(expected===from||expected===to).toBe(true);if(testCallback){testCallback(config,from,to);}};var wrapper=mount(/*#__PURE__*/React.createElement(RangeSlider,{min:config.min,max:config.max,value:config.initialValue,easing:easing,resolution:config.resolution,factor:config.factor,onChange:callback}));expect(wrapper).toMatchSnapshot();// Create a simulated touch event.
|
|
23
23
|
var pageX=config.leftPixelOffset+config.currentTouchDeltaX;var touchEvent=createTouchEvent(pageX);var inst=wrapper.instance();inst.handleTouchStart(touchEvent,1);simulateSteps.forEach(function(deltaX){config.currentTouchDeltaX+=deltaX;touchEvent.touches[0].pageX=config.leftPixelOffset+config.currentTouchDeltaX;Object.defineProperty(inst.domElement,'offsetLeft',{get:function get(){return config.leftPixelOffset;},configurable:true});Object.defineProperty(inst.domElement,'offsetWidth',{get:function get(){return config.totalPixelWidth;},configurable:true});inst.handleTouchMove(touchEvent);});inst.handleTouchEnd();};describe.skip('<RangeSlider />',function(){/**
|
|
24
24
|
* Simple attribute tests
|
|
25
|
-
*/it('renders with boundaries',function(){var wrapper=shallow(React.createElement(RangeSlider,{min:0,max:100}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(RangeSliderHandle).length).toBe(2);});it('renders without boundaries',function(){var wrapper=shallow(React.createElement(RangeSlider,null));expect(wrapper).toMatchSnapshot();expect(wrapper.find(RangeSliderHandle).length).toBe(2);});it('renders without a value pair',function(){var wrapper=shallow(React.createElement(RangeSlider,{value:[10,50]}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(RangeSliderHandle).length).toBe(2);});/**
|
|
25
|
+
*/it('renders with boundaries',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(RangeSlider,{min:0,max:100}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(RangeSliderHandle).length).toBe(2);});it('renders without boundaries',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(RangeSlider,null));expect(wrapper).toMatchSnapshot();expect(wrapper.find(RangeSliderHandle).length).toBe(2);});it('renders without a value pair',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(RangeSlider,{value:[10,50]}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(RangeSliderHandle).length).toBe(2);});/**
|
|
26
26
|
* Callback tests
|
|
27
27
|
*/it('emits onChange if handle was touched (linear)',function(){simulateInputTest(100,73,// Range slider pixel width and offset.
|
|
28
28
|
0,100,// Range slider minimum and maximum value.
|
|
@@ -37,5 +37,5 @@ var pageX=config.leftPixelOffset+config.currentTouchDeltaX;var touchEvent=create
|
|
|
37
37
|
0.01,// Resolution.
|
|
38
38
|
[// A series of pixel offsets to move the slider handle.
|
|
39
39
|
+10,+10,+10,+10,+10,+10,+10,+10,-10,-10,-10,-10,-10,-10,-10,-10,+3,-15,+17,-80,+104,-23,-12,+67]);});it('emits onChange if the outer range was touched',function(){// eslint-disable-next-line require-jsdoc
|
|
40
|
-
var callback=function callback(value){return expect(value).toEqual([-80,0]);};var wrapper=mount(React.createElement(RangeSlider,{min:-100,max:100,value:[0,0],onChange:callback}));// Create a simulated touch event at a page x offset of 20px.
|
|
40
|
+
var callback=function callback(value){return expect(value).toEqual([-80,0]);};var wrapper=mount(/*#__PURE__*/React.createElement(RangeSlider,{min:-100,max:100,value:[0,0],onChange:callback}));// Create a simulated touch event at a page x offset of 20px.
|
|
41
41
|
var touchEvent=createTouchEvent(20);var inst=wrapper.instance();Object.defineProperty(inst.domElement,'offsetLeft',{get:function get(){return 0;},configurable:true});Object.defineProperty(inst.domElement,'offsetWidth',{get:function get(){return 200;},configurable:true});inst.handleRangeTouch(touchEvent);});});
|
|
@@ -1,6 +1,6 @@
|
|
|
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);}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e
|
|
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);}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useState,useCallback,useEffect}from'react';import PropTypes from'prop-types';import{viewScroll$}from'@shopgate/pwa-common/streams/view';import{scrolledIn,scrolledOut,transition}from"./style";/**
|
|
2
2
|
* Scroll Header component
|
|
3
3
|
* @param {Object} props props
|
|
4
4
|
* @returns {JSX}
|
|
5
5
|
*
|
|
6
|
-
*/function ScrollHeader(_ref){var children=_ref.children,hideOnScroll=_ref.hideOnScroll,scrollOffset=_ref.scrollOffset;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),shouldHideHeader=_useState2[0],setShouldHideHeader=_useState2[1];var onScroll=useCallback(function(scrollEvent){var scrollTop=scrollEvent.scrollTop,scrolled=scrollEvent.scrolled,scrollOut=scrollEvent.scrollOut,scrollIn=scrollEvent.scrollIn;if(scrolled){if(!shouldHideHeader&&scrollOut&&scrollTop>=scrollOffset){setShouldHideHeader(true);}if(shouldHideHeader&&scrollIn){setShouldHideHeader(false);}}},[scrollOffset,shouldHideHeader]);useEffect(function(){if(hideOnScroll){var subscription=viewScroll$.subscribe(onScroll);return function(){return subscription.unsubscribe();};}return undefined;});var className=shouldHideHeader?scrolledOut:scrolledIn;return
|
|
6
|
+
*/function ScrollHeader(_ref){var children=_ref.children,hideOnScroll=_ref.hideOnScroll,scrollOffset=_ref.scrollOffset;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),shouldHideHeader=_useState2[0],setShouldHideHeader=_useState2[1];var onScroll=useCallback(function(scrollEvent){var scrollTop=scrollEvent.scrollTop,scrolled=scrollEvent.scrolled,scrollOut=scrollEvent.scrollOut,scrollIn=scrollEvent.scrollIn;if(scrolled){if(!shouldHideHeader&&scrollOut&&scrollTop>=scrollOffset){setShouldHideHeader(true);}if(shouldHideHeader&&scrollIn){setShouldHideHeader(false);}}},[scrollOffset,shouldHideHeader]);useEffect(function(){if(hideOnScroll){var subscription=viewScroll$.subscribe(onScroll);return function(){return subscription.unsubscribe();};}return undefined;});var className=shouldHideHeader?scrolledOut:scrolledIn;return/*#__PURE__*/React.cloneElement(children,_extends({},children.props,{className:"".concat(children.props.className.toString()," ").concat(className," ").concat(transition)}));}ScrollHeader.defaultProps={hideOnScroll:true,scrollOffset:100};export default ScrollHeader;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from'react';import{createPortal}from'react-dom';import Sheet from'@shopgate/pwa-ui-shared/Sheet';var node=document.getElementById('portals');/**
|
|
2
2
|
* @param {Object} props The props to be passed to the Sheet.
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/function SheetDrawer(props){return
|
|
4
|
+
*/function SheetDrawer(props){return/*#__PURE__*/createPortal(/*#__PURE__*/React.createElement(Sheet,props),node);}export default SheetDrawer;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
function _typeof(obj){
|
|
1
|
+
function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_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);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}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}});Object.defineProperty(subClass,"prototype",{writable:false});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 _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}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 _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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{withForwardedRef}from'@shopgate/engage/core';import Grid from'@shopgate/pwa-common/components/Grid';import Link from'@shopgate/pwa-common/components/Link';import Glow from'@shopgate/pwa-ui-shared/Glow';import styles from"./style";/**
|
|
2
2
|
* The list item component.
|
|
3
|
-
*/var Item=/*#__PURE__*/function(_Component){_inherits(Item,_Component);function Item(){_classCallCheck(this,Item);return
|
|
3
|
+
*/var Item=/*#__PURE__*/function(_Component){_inherits(Item,_Component);var _super=_createSuper(Item);function Item(){_classCallCheck(this,Item);return _super.apply(this,arguments);}_createClass(Item,[{key:"shouldComponentUpdate",value:/**
|
|
4
4
|
* Should only update what the `selected` or `disabled` props change.
|
|
5
5
|
* @param {Object} nextProps The next set of component props.
|
|
6
6
|
* @returns {JSX}
|
|
7
|
-
*/
|
|
7
|
+
*/function shouldComponentUpdate(nextProps){return this.props.isSelected!==nextProps.isSelected||this.props.isDisabled!==nextProps.isDisabled;}/**
|
|
8
8
|
* Renders the bulk of the content.
|
|
9
9
|
* @param {boolean} [isNested=true] Tells if the content is rendered nested.
|
|
10
10
|
* @returns {JSX}
|
|
11
|
-
*/},{key:"renderContent",value:function renderContent(){var _gridStyles,_titleStyles;var isNested=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var _this$props=this.props,isDisabled=_this$props.isDisabled,isSelected=_this$props.isSelected,title=_this$props.title,image=_this$props.image,rightComponent=_this$props.rightComponent,forwardedRef=_this$props.forwardedRef;var gridStyles=(_gridStyles={},_defineProperty(_gridStyles,styles.grid,true),_defineProperty(_gridStyles,styles.selected,isSelected),_gridStyles);var titleStyles=(_titleStyles={},_defineProperty(_titleStyles,styles.title,true),_defineProperty(_titleStyles,styles.disabled,isDisabled),_titleStyles);var ref=isNested?null:forwardedRef;return
|
|
11
|
+
*/},{key:"renderContent",value:function renderContent(){var _gridStyles,_titleStyles;var isNested=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var _this$props=this.props,isDisabled=_this$props.isDisabled,isSelected=_this$props.isSelected,title=_this$props.title,image=_this$props.image,rightComponent=_this$props.rightComponent,forwardedRef=_this$props.forwardedRef;var gridStyles=(_gridStyles={},_defineProperty(_gridStyles,styles.grid,true),_defineProperty(_gridStyles,styles.selected,isSelected),_gridStyles);var titleStyles=(_titleStyles={},_defineProperty(_titleStyles,styles.title,true),_defineProperty(_titleStyles,styles.disabled,isDisabled),_titleStyles);var ref=isNested?null:forwardedRef;return/*#__PURE__*/React.createElement("div",{"data-test-id":this.props.testId,ref:ref,className:"engage__sheet-list__item"},/*#__PURE__*/React.createElement(Grid,{className:classNames(gridStyles),component:"div"},image!==null&&/*#__PURE__*/React.createElement("div",{className:styles.image},image),/*#__PURE__*/React.createElement(Grid.Item,{className:classNames(titleStyles),component:"div",grow:1},title),rightComponent!==null&&/*#__PURE__*/React.createElement(Grid.Item,{component:"div",grow:1},rightComponent)));}/**
|
|
12
12
|
* @returns {JSX}
|
|
13
13
|
*/},{key:"render",value:function render(){var _this$props2=this.props,link=_this$props2.link,linkState=_this$props2.linkState,onClick=_this$props2.onClick,className=_this$props2.className,isDisabled=_this$props2.isDisabled,testId=_this$props2.testId,forwardedRef=_this$props2.forwardedRef,isSelected=_this$props2.isSelected;/**
|
|
14
14
|
* If this item is disabled, selected or doesn't have a valid
|
|
15
15
|
* link or click handler then wrap the content with other components.
|
|
16
16
|
*/if(isDisabled||!link&&!onClick){return this.renderContent(false);}// Wrap with a <Link> if the `link` prop is set.
|
|
17
|
-
if(link){return
|
|
17
|
+
if(link){return/*#__PURE__*/React.createElement(Glow,{ref:forwardedRef,className:className,styles:{hover:styles.glowHover}},/*#__PURE__*/React.createElement(Link,{href:link,onClick:onClick,state:linkState,tabIndex:0},this.renderContent()));}return/*#__PURE__*/React.createElement("div",{onKeyPress:function onKeyPress(){},onClick:onClick,"data-test-id":testId,ref:forwardedRef,tabIndex:0,role:"option","aria-selected":isSelected},/*#__PURE__*/React.createElement(Glow,{className:className,styles:{hover:styles.glowHover}},this.renderContent()));}}]);return Item;}(Component);_defineProperty(Item,"defaultProps",{className:null,forwardedRef:null,image:null,isDisabled:false,isSelected:false,link:null,linkState:null,onClick:null,rightComponent:null,testId:null});export default withForwardedRef(Item);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
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 Glow from'@shopgate/pwa-ui-shared/Glow';import Item from"./index";jest.mock('@shopgate/pwa-common/components/Link',function(){/**
|
|
2
2
|
* Mocked LinkComponent.
|
|
3
3
|
* @return {JSX}
|
|
4
|
-
*/var Link=function Link(){return
|
|
4
|
+
*/var Link=function Link(){return/*#__PURE__*/React.createElement("div",null);};return Link;});describe('<SheetList.Item />',function(){var title='My Title';it('should render with a title but no image',function(){var wrapper=mount(/*#__PURE__*/React.createElement(Item,{title:title}));expect(wrapper).toMatchSnapshot();expect(wrapper.find('img').exists()).toBeFalsy();});it('should render with an image',function(){var image=/*#__PURE__*/React.createElement("img",{src:"url/to/image",alt:"Alternative text"});var wrapper=mount(/*#__PURE__*/React.createElement(Item,{title:title,image:image}));expect(wrapper).toMatchSnapshot();expect(wrapper.find('img').exists()).toBeTruthy();});it('should render with a right component',function(){var rightComponent=/*#__PURE__*/React.createElement("span",null,"I`m a span.");var wrapper=mount(/*#__PURE__*/React.createElement(Item,{title:title,rightComponent:rightComponent}));expect(wrapper).toMatchSnapshot();expect(wrapper.contains(/*#__PURE__*/React.createElement("span",null,"I`m a span."))).toEqual(true);});it('should render without a Glow when selected',function(){var wrapper=mount(/*#__PURE__*/React.createElement(Item,{title:title,isSelected:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(Glow).exists()).toBeFalsy();});it('should render without a Glow when disabled',function(){var wrapper=mount(/*#__PURE__*/React.createElement(Item,{title:title,isDisabled:true}));expect(wrapper).toMatchSnapshot();expect(wrapper.find(Glow).exists()).toBeFalsy();});it('should render with a link',function(){var wrapper=mount(/*#__PURE__*/React.createElement(Item,{title:title,link:"url/to/somewhere"}));expect(wrapper).toMatchSnapshot();expect(wrapper.find('Link').exists()).toBeTruthy();});it('should render with an onClick element',function(){var spy=jest.fn();// eslint-disable-next-line require-jsdoc
|
|
5
5
|
var clickHandler=function clickHandler(){/**
|
|
6
6
|
* The spy can't be assigned directly to the event, since the snapshot gets too big
|
|
7
7
|
* and the test execution is heavily slowed down.
|
|
8
|
-
*/spy();};var wrapper=mount(React.createElement(Item,{title:title,onClick:clickHandler}));wrapper.simulate('click');expect(wrapper).toMatchSnapshot();expect(spy).toHaveBeenCalledTimes(1);});it('should update the component when the isDisabled prop changed',function(){var wrapper=mount(React.createElement(Item,{title:title,isDisabled:true}));var props=wrapper.props();var updated=wrapper.find('Item').instance().shouldComponentUpdate(_extends({},props,{isDisabled:false}));expect(updated).toBe(true);});it('should update the component when the isSelected prop changed',function(){var wrapper=mount(React.createElement(Item,{title:title,isSelected:true}));var props=wrapper.props();var updated=wrapper.find('Item').instance().shouldComponentUpdate(_extends({},props,{isSelected:false}));expect(updated).toBe(true);});});
|
|
8
|
+
*/spy();};var wrapper=mount(/*#__PURE__*/React.createElement(Item,{title:title,onClick:clickHandler}));wrapper.simulate('click');expect(wrapper).toMatchSnapshot();expect(spy).toHaveBeenCalledTimes(1);});it('should update the component when the isDisabled prop changed',function(){var wrapper=mount(/*#__PURE__*/React.createElement(Item,{title:title,isDisabled:true}));var props=wrapper.props();var updated=wrapper.find('Item').instance().shouldComponentUpdate(_extends({},props,{isDisabled:false}));expect(updated).toBe(true);});it('should update the component when the isSelected prop changed',function(){var wrapper=mount(/*#__PURE__*/React.createElement(Item,{title:title,isSelected:true}));var props=wrapper.props();var updated=wrapper.find('Item').instance().shouldComponentUpdate(_extends({},props,{isSelected:false}));expect(updated).toBe(true);});});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
function _typeof(obj){
|
|
1
|
+
function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_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);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}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}});Object.defineProperty(subClass,"prototype",{writable:false});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 _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}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 _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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 List from'@shopgate/pwa-common/components/List';import Item from"./components/Item";import styles from"./style";/**
|
|
2
2
|
* The SheetList component.
|
|
3
3
|
* Styled sheet for List component
|
|
4
|
-
*/var SheetList=/*#__PURE__*/function(_Component){_inherits(SheetList,_Component);function SheetList(){_classCallCheck(this,SheetList);return
|
|
4
|
+
*/var SheetList=/*#__PURE__*/function(_Component){_inherits(SheetList,_Component);var _super=_createSuper(SheetList);function SheetList(){_classCallCheck(this,SheetList);return _super.apply(this,arguments);}_createClass(SheetList,[{key:"render",value:/**
|
|
5
5
|
* Renders the component.
|
|
6
6
|
* @returns {JSX}
|
|
7
|
-
*/
|
|
7
|
+
*/function render(){var _itemClasses;var _this$props=this.props,children=_this$props.children,className=_this$props.className,hasImages=_this$props.hasImages,testId=_this$props.testId;if(!React.Children.count(children)){return null;}var itemClasses=(_itemClasses={},_defineProperty(_itemClasses,styles.item,true),_defineProperty(_itemClasses,styles.itemWithImage,hasImages),_itemClasses);return/*#__PURE__*/React.createElement(List,{className:"".concat(className," engage__sheet-list"),role:"listbox"},React.Children.map(children,function(child,index){var _childClasses;if(!/*#__PURE__*/React.isValidElement(child)){return null;}// The key for each child.
|
|
8
8
|
var key="child-".concat(index);// Selected state for the child.
|
|
9
|
-
var isSelected=child.props.isSelected;var childClasses=(_childClasses={},_defineProperty(_childClasses,styles.itemSelected,isSelected),_defineProperty(_childClasses,styles.itemNotLast,!isSelected),_childClasses);return
|
|
9
|
+
var isSelected=child.props.isSelected;var childClasses=(_childClasses={},_defineProperty(_childClasses,styles.itemSelected,isSelected),_defineProperty(_childClasses,styles.itemNotLast,!isSelected),_childClasses);return/*#__PURE__*/React.createElement(List.Item,{className:classNames(itemClasses,childClasses),isSelected:isSelected,key:key,tabIndex:0},/*#__PURE__*/React.createElement("div",{className:styles.innerContainer,"data-test-id":testId},child));}));}}]);return SheetList;}(Component);_defineProperty(SheetList,"Item",Item);_defineProperty(SheetList,"defaultProps",{children:null,className:null,hasImages:false,testId:null});export default SheetList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import{mount}from'enzyme';import BaseListItem from'@shopgate/pwa-common/components/List/components/Item';import SheetList from"./index";import styles from"./style";describe('<SheetList />',function(){it('should render with two children',function(){var wrapper=mount(React.createElement(SheetList,null
|
|
1
|
+
import React from'react';import{mount}from'enzyme';import BaseListItem from'@shopgate/pwa-common/components/List/components/Item';import SheetList from"./index";import styles from"./style";describe('<SheetList />',function(){it('should render with two children',function(){var wrapper=mount(/*#__PURE__*/React.createElement(SheetList,null,/*#__PURE__*/React.createElement(SheetList.Item,{title:"List Item"}),/*#__PURE__*/React.createElement(SheetList.Item,{title:"List Item"})));expect(wrapper).toMatchSnapshot();expect(wrapper.find(SheetList.Item).length).toEqual(2);});it('should render a child and add styles for list items with images',function(){var wrapper=mount(/*#__PURE__*/React.createElement(SheetList,{hasImages:true},/*#__PURE__*/React.createElement(SheetList.Item,{title:"List Item"})));expect(wrapper).toMatchSnapshot();expect(wrapper.find(SheetList.Item).length).toEqual(1);expect(wrapper.find(BaseListItem).first().hasClass(styles.itemWithImage)).toBeTruthy();});it('should not render without children',function(){var wrapper=mount(/*#__PURE__*/React.createElement(SheetList,null));expect(wrapper).toMatchSnapshot();expect(wrapper.find(SheetList).html()).toBe(null);});it('should not render invalid children',function(){var wrapper=mount(/*#__PURE__*/React.createElement(SheetList,null,/*#__PURE__*/React.createElement(SheetList.Item,{title:"List Item"}),"xxx"));expect(wrapper).toMatchSnapshot();expect(wrapper.find(SheetList.Item).length).toEqual(1);});});
|
|
@@ -2,4 +2,4 @@ import React from'react';import{createPortal}from'react-dom';import{SnackBar}fro
|
|
|
2
2
|
* The SnackBarContainer component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/function SnackBarContainer(props){if(!props.toasts.length){return null;}return
|
|
5
|
+
*/function SnackBarContainer(props){if(!props.toasts.length){return null;}return/*#__PURE__*/createPortal(/*#__PURE__*/React.createElement(SnackBar,props),document.getElementById('portals'));}export default SnackBarContainer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}import _isEqual from"lodash/isEqual";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);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}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}});Object.defineProperty(subClass,"prototype",{writable:false});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 _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}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 _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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,Fragment}from'react';import PropTypes from'prop-types';import{isBefore,isAfter,isBetween}from'@shopgate/pwa-common/helpers/date';import{second$}from'@shopgate/pwa-common/streams/interval';/**
|
|
2
2
|
* The TimeBoundary component.
|
|
3
3
|
* @example
|
|
4
4
|
* <TimeBoundary
|
|
@@ -9,13 +9,13 @@ import _isEqual from"lodash/isEqual";function _typeof(obj){if(typeof Symbol==="f
|
|
|
9
9
|
{between && <div>Content is inside time boundary</div>}
|
|
10
10
|
)}
|
|
11
11
|
* </TimeBoundary>
|
|
12
|
-
*/var TimeBoundary=/*#__PURE__*/function(_Component){_inherits(TimeBoundary,_Component);/**
|
|
12
|
+
*/var TimeBoundary=/*#__PURE__*/function(_Component){_inherits(TimeBoundary,_Component);var _super=_createSuper(TimeBoundary);/**
|
|
13
13
|
* @inheritDoc
|
|
14
|
-
*/function TimeBoundary(props){var _this;_classCallCheck(this,TimeBoundary);_this=
|
|
14
|
+
*/function TimeBoundary(props){var _this;_classCallCheck(this,TimeBoundary);_this=_super.call(this,props);_defineProperty(_assertThisInitialized(_this),"clear",function(){if(_this.intervalSubscription){_this.intervalSubscription.unsubscribe();}});_defineProperty(_assertThisInitialized(_this),"checkBoundary",function(){var now=Date.now();var newState={before:isBefore(now,_this.props.start),between:isBetween(now,_this.props.start,_this.props.end),after:isAfter(now,_this.props.end)};if(_isEqual(newState,_this.state)){return;}_this.setState(newState);if(newState.after){// already after, stop timer
|
|
15
15
|
_this.clear();}});_this.state={before:false,between:false,after:false};return _this;}/**
|
|
16
16
|
* @inheritDoc
|
|
17
17
|
*/_createClass(TimeBoundary,[{key:"componentDidMount",value:function componentDidMount(){this.intervalSubscription=second$.subscribe(this.checkBoundary);this.checkBoundary();}/**
|
|
18
18
|
* @inheritDoc
|
|
19
|
-
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){this.clear();}/** Clear interval if valid */},{key:"render"
|
|
19
|
+
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){this.clear();}/** Clear interval if valid */},{key:"render",value:/**
|
|
20
20
|
* @returns {JSX}
|
|
21
|
-
*/
|
|
21
|
+
*/function render(){return/*#__PURE__*/React.createElement(Fragment,null,this.props.children(this.state));}}]);return TimeBoundary;}(Component);export default TimeBoundary;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable extra-rules/no-single-line-objects */import React from'react';import{mount}from'enzyme';import{second$}from'@shopgate/pwa-common/streams/interval';import TimeBoundary from"./index";describe('<TimeBoundary>',function(){var nowMs=new Date().getTime();var subscription;var subscribeSpy;var children;beforeEach(function(){subscription={unsubscribe:jest.fn()};subscribeSpy=jest.spyOn(second$,'subscribe').mockReturnValue(subscription);children=jest.fn();});afterEach(function(){jest.clearAllMocks();});it('should render valid time span',function(){expect.assertions(1);// -30sec < wrapper < +30sec
|
|
2
|
-
mount(React.createElement(TimeBoundary,{start:new Date(nowMs-30000),end:new Date(nowMs+30000)},children));expect(children).toHaveBeenCalledWith({before:false,between:true,after:false});});it('should not render expired time span',function(){expect.assertions(1);// -60sec < wrapper < -30sec
|
|
3
|
-
mount(React.createElement(TimeBoundary,{start:new Date(nowMs-60000),end:new Date(nowMs-30000)},children));expect(children).toHaveBeenCalledWith({before:false,between:false,after:true});});it('should hide after time span expired',function(){expect.assertions(4);// -30sec < wrapper < +2sec
|
|
4
|
-
var wrapper=mount(React.createElement(TimeBoundary,{start:new Date(nowMs-30000),end:new Date(nowMs+2000)},children));var checkBoundaryMethod=wrapper.instance().checkBoundary;expect(subscribeSpy).toHaveBeenCalledTimes(1);expect(subscribeSpy).toHaveBeenCalledWith(checkBoundaryMethod);// Simulate time is over
|
|
2
|
+
mount(/*#__PURE__*/React.createElement(TimeBoundary,{start:new Date(nowMs-30000),end:new Date(nowMs+30000)},children));expect(children).toHaveBeenCalledWith({before:false,between:true,after:false});});it('should not render expired time span',function(){expect.assertions(1);// -60sec < wrapper < -30sec
|
|
3
|
+
mount(/*#__PURE__*/React.createElement(TimeBoundary,{start:new Date(nowMs-60000),end:new Date(nowMs-30000)},children));expect(children).toHaveBeenCalledWith({before:false,between:false,after:true});});it('should hide after time span expired',function(){expect.assertions(4);// -30sec < wrapper < +2sec
|
|
4
|
+
var wrapper=mount(/*#__PURE__*/React.createElement(TimeBoundary,{start:new Date(nowMs-30000),end:new Date(nowMs+2000)},children));var checkBoundaryMethod=wrapper.instance().checkBoundary;expect(subscribeSpy).toHaveBeenCalledTimes(1);expect(subscribeSpy).toHaveBeenCalledWith(checkBoundaryMethod);// Simulate time is over
|
|
5
5
|
jest.spyOn(Date,'now').mockReturnValue(new Date(nowMs+3000));// simulate rxjs emitting
|
|
6
6
|
checkBoundaryMethod();wrapper.update();expect(subscription.unsubscribe).toHaveBeenCalledTimes(1);expect(children.mock.calls).toEqual([[{after:false,before:false,between:false}],[{after:false,before:false,between:true}],[{after:true,before:false,between:false}]]);});});/* eslint-enable extra-rules/no-single-line-objects */
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
function _typeof(obj){
|
|
1
|
+
function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_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);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}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}});Object.defineProperty(subClass,"prototype",{writable:false});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 _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}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 _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent}from'react';import ReactPlayer from'react-player';import{UIEvents}from'@shopgate/pwa-core';import{UI_VISIBILITY_CHANGE}from'@shopgate/pwa-common/constants/ui';/**
|
|
2
2
|
* Video player component
|
|
3
3
|
* @param {Object} props props
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var VideoPlayer=/*#__PURE__*/function(_PureComponent){_inherits(VideoPlayer,_PureComponent);function VideoPlayer(){var
|
|
5
|
+
*/var VideoPlayer=/*#__PURE__*/function(_PureComponent){_inherits(VideoPlayer,_PureComponent);var _super=_createSuper(VideoPlayer);function VideoPlayer(){var _this;_classCallCheck(this,VideoPlayer);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_super.call.apply(_super,[this].concat(args));_defineProperty(_assertThisInitialized(_this),"state",{ready:false,playing:_this.props.playing,userPaused:false});_defineProperty(_assertThisInitialized(_this),"getPlayingState",function(){return _this.state.ready&&!_this.state.userPaused&&_this.state.playing;});_defineProperty(_assertThisInitialized(_this),"handleReady",function(){_this.setState({ready:true});});_defineProperty(_assertThisInitialized(_this),"handleError",function(error){if(error&&error.name==='NotAllowedError'){_this.setState({playing:false});}});_defineProperty(_assertThisInitialized(_this),"handlePause",function(){// Check if was not paused programmatically
|
|
6
|
+
if(_this.state.playing){_this.setState({userPaused:true,playing:false});}});_defineProperty(_assertThisInitialized(_this),"handlePlay",function(){if(!_this.state.playing){_this.setState({userPaused:false,playing:true});}});_defineProperty(_assertThisInitialized(_this),"handleVisibilityChange",function(){_this.setState({playing:false});});return _this;}_createClass(VideoPlayer,[{key:"componentDidMount",value:/**
|
|
6
7
|
* @inheritDoc
|
|
7
|
-
*/
|
|
8
|
-
if(_this.state.playing){_this.setState({userPaused:true,playing:false});}});_defineProperty(_assertThisInitialized(_this),"handlePlay",function(){if(!_this.state.playing){_this.setState({userPaused:false,playing:true});}});_defineProperty(_assertThisInitialized(_this),"handleVisibilityChange",function(){_this.setState({playing:false});});return _this;}_createClass(VideoPlayer,[{key:"componentDidMount",value:function componentDidMount(){UIEvents.addListener(UI_VISIBILITY_CHANGE,this.handleVisibilityChange);}/**
|
|
8
|
+
*/function componentDidMount(){UIEvents.addListener(UI_VISIBILITY_CHANGE,this.handleVisibilityChange);}/**
|
|
9
9
|
* @inheritDoc
|
|
10
10
|
*/},{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){var nextState={playing:nextProps.playing};if(this.props.url!==nextProps.url){nextState.ready=false;}this.setState(nextState);}/**
|
|
11
11
|
* @inheritDoc
|
|
12
|
-
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(UI_VISIBILITY_CHANGE,this.handleVisibilityChange);}/** @returns {boolean} */},{key:"render"
|
|
12
|
+
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(UI_VISIBILITY_CHANGE,this.handleVisibilityChange);}/** @returns {boolean} */},{key:"render",value:/**
|
|
13
13
|
* @returns {JSX}
|
|
14
|
-
*/
|
|
14
|
+
*/function render(){return/*#__PURE__*/React.createElement(ReactPlayer,_extends({playsinline:true},this.props,{playing:this.getPlayingState(),onReady:this.handleReady,onPause:this.handlePause,onPlay:this.handlePlay,onError:this.handleError}));}}]);return VideoPlayer;}(PureComponent);_defineProperty(VideoPlayer,"defaultProps",ReactPlayer.defaultProps);export default VideoPlayer;
|
|
@@ -2,4 +2,4 @@ import React from'react';import PropTypes from'prop-types';// Export context moc
|
|
|
2
2
|
export{ViewContext}from"./context";/**
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @return {JSX}
|
|
5
|
-
*/var MockedView=function MockedView(_ref){var children=_ref.children;return
|
|
5
|
+
*/var MockedView=function MockedView(_ref){var children=_ref.children;return/*#__PURE__*/React.createElement("div",null,children);};MockedView.defaultProps={children:null};export default MockedView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import{shallow}from'enzyme';import{mockThemeConfig}from'@shopgate/pwa-common/helpers/config/mock';import{setBackgroundColor}from"../style";import View from"../index";jest.mock('@shopgate/pwa-common/helpers/config',function(){return{themeConfig:mockThemeConfig};});jest.mock('@shopgate/pwa-common/context',function(){return{RouteContext:{Consumer:jest.fn(function(_ref){var children=_ref.children;return children({visible:true});})}};});jest.mock("../provider",function(){return function(_ref2){var children=_ref2.children;return children;};});jest.mock("../context");jest.mock("../style",function(){return{__esModule:true,"default":jest.requireActual('../style')["default"],setBackgroundColor:jest.fn()};});describe('engage > components > view > index',function(){beforeEach(jest.clearAllMocks);var wrapper;beforeAll(function(){wrapper=shallow(React.createElement(View,null
|
|
1
|
+
import React from'react';import{shallow}from'enzyme';import{mockThemeConfig}from'@shopgate/pwa-common/helpers/config/mock';import{setBackgroundColor}from"../style";import View from"../index";jest.mock('@shopgate/pwa-common/helpers/config',function(){return{themeConfig:mockThemeConfig};});jest.mock('@shopgate/pwa-common/context',function(){return{RouteContext:{Consumer:jest.fn(function(_ref){var children=_ref.children;return children({visible:true});})}};});jest.mock("../provider",function(){return function(_ref2){var children=_ref2.children;return children;};});jest.mock("../context");jest.mock("../style",function(){return{__esModule:true,"default":jest.requireActual('../style')["default"],setBackgroundColor:jest.fn()};});describe('engage > components > view > index',function(){beforeEach(jest.clearAllMocks);var wrapper;beforeAll(function(){wrapper=shallow(/*#__PURE__*/React.createElement(View,null,/*#__PURE__*/React.createElement("div",null,"Page #1")));});it('should initialize with visible route',function(){expect(wrapper.dive()).toMatchSnapshot();});it('should have structured content',function(){expect(wrapper.dive().dive().dive().dive()).toMatchSnapshot();});it('should set background on intialization',function(){wrapper=shallow(/*#__PURE__*/React.createElement(View,{background:"#990000"},/*#__PURE__*/React.createElement("div",null,"Page #1"))).dive().dive();expect(setBackgroundColor).toBeCalledWith('#990000');});});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import{shallow}from'enzyme';import Provider from"../provider";jest.mock("../context");describe('engage > components > view > provider',function(){it('should initialize and provider context',function(){var wrapper=shallow(React.createElement(Provider,null
|
|
1
|
+
import React from'react';import{shallow}from'enzyme';import Provider from"../provider";jest.mock("../context");describe('engage > components > view > provider',function(){it('should initialize and provider context',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Provider,null,/*#__PURE__*/React.createElement("div",null,"Page #1")));expect(wrapper).toMatchSnapshot();});});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import{shallow}from'enzyme';import Above from"../index";jest.mock("../../../context");describe('engage > components > view > components > above',function(){it('should render above',function(){var wrapper=shallow(React.createElement(Above,null)).dive();expect(wrapper).toMatchSnapshot();});});
|
|
1
|
+
import React from'react';import{shallow}from'enzyme';import Above from"../index";jest.mock("../../../context");describe('engage > components > view > components > above',function(){it('should render above',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Above,null)).dive();expect(wrapper).toMatchSnapshot();});});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from'react';import{ViewContext}from"../../context";/**
|
|
2
2
|
* @returns {JSX}
|
|
3
|
-
*/function ViewAbove(){return
|
|
3
|
+
*/function ViewAbove(){return/*#__PURE__*/React.createElement(ViewContext.Consumer,null,function(_ref){var top=_ref.top;if(!top){return null;}var styles={flexShrink:0,height:"calc(".concat(top,"px + var(--safe-area-inset-top))")};return/*#__PURE__*/React.createElement("div",{"aria-hidden":true,style:styles,className:"engage__view__above"});});}export default ViewAbove;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';import{shallow}from'enzyme';import Below from"../index";jest.mock("../../../context");describe('engage > components > view > components > below',function(){it('should render below',function(){var wrapper=shallow(React.createElement(Below,null)).dive();expect(wrapper).toMatchSnapshot();});});
|
|
1
|
+
import React from'react';import{shallow}from'enzyme';import Below from"../index";jest.mock("../../../context");describe('engage > components > view > components > below',function(){it('should render below',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Below,null)).dive();expect(wrapper).toMatchSnapshot();});});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from'react';import{ViewContext}from"../../context";/**
|
|
2
2
|
* @returns {JSX}
|
|
3
|
-
*/function ViewBelow(){return
|
|
3
|
+
*/function ViewBelow(){return/*#__PURE__*/React.createElement(ViewContext.Consumer,null,function(_ref){var bottom=_ref.bottom;if(!bottom){return null;}var styles={flexShrink:0,height:"calc(".concat(bottom,"px + var(--safe-area-inset-bottom))")};return/*#__PURE__*/React.createElement("div",{"aria-hidden":true,style:styles,className:"engage__view__below"});});}export default ViewBelow;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import React from'react';import{shallow}from'enzyme';import Content from"../index";jest.mock('@shopgate/pwa-common/helpers/config',function(){return{shopName:'Test Shop'};});jest.mock('@shopgate/pwa-common/context',function(){return{RouteContext:{Consumer:jest.fn(function(_ref){var children=_ref.children;return children({visible:true,pattern:'page/:pageId,'});})}};});describe('engage > components > view > components > content',function(){beforeEach(jest.clearAllMocks);it('should render content',function(){var wrapper=shallow(React.createElement(Content,{setContentRef:jest.fn()}
|
|
1
|
+
import React from'react';import{shallow}from'enzyme';import Content from"../index";jest.mock('@shopgate/pwa-common/helpers/config',function(){return{shopName:'Test Shop'};});jest.mock('@shopgate/pwa-common/context',function(){return{RouteContext:{Consumer:jest.fn(function(_ref){var children=_ref.children;return children({visible:true,pattern:'page/:pageId,'});})}};});describe('engage > components > view > components > content',function(){beforeEach(jest.clearAllMocks);it('should render content',function(){var wrapper=shallow(/*#__PURE__*/React.createElement(Content,{setContentRef:jest.fn()},/*#__PURE__*/React.createElement("div",null,"Page #1")),{disableLifecycleMethods:true})// Dive through Route context and into render component
|
|
2
2
|
.dive().dive();expect(wrapper).toMatchSnapshot();});});
|
|
@@ -1,21 +1,21 @@
|
|
|
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);}function
|
|
1
|
+
function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_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);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}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}});Object.defineProperty(subClass,"prototype",{writable:false});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 _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}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 _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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 Swipeable from'react-swipeable';import Helmet from'react-helmet';import appConfig from'@shopgate/pwa-common/helpers/config';import event from'@shopgate/pwa-core/classes/Event';import{router}from'@virtuous/conductor';import{RouteContext}from'@shopgate/pwa-common/context';import{EVENT_KEYBOARD_WILL_CHANGE}from'@shopgate/pwa-core/constants/AppEvents';import SurroundPortals from'@shopgate/pwa-common/components/SurroundPortals';import{VIEW_CONTENT}from'@shopgate/pwa-common/constants/Portals';import ConditionalWrapper from"../../../ConditionalWrapper";import Above from"../Above";import Below from"../Below";import styles from"./style";/**
|
|
2
2
|
* The ViewContent component.
|
|
3
|
-
*/var ViewContent=/*#__PURE__*/function(_Component){_inherits(ViewContent,_Component);/**
|
|
3
|
+
*/var ViewContent=/*#__PURE__*/function(_Component){_inherits(ViewContent,_Component);var _super=_createSuper(ViewContent);/**
|
|
4
4
|
* @param {Object} props The component props.
|
|
5
|
-
*/function ViewContent(props){var _this;_classCallCheck(this,ViewContent);_this=
|
|
5
|
+
*/function ViewContent(props){var _this;_classCallCheck(this,ViewContent);_this=_super.call(this,props);_defineProperty(_assertThisInitialized(_this),"handleKeyboardChange",function(_ref){var open=_ref.open,overlap=_ref.overlap;var height=open?overlap:0;if(_this.props.visible&&height!==_this.state.keyboardHeight){_this.setState({keyboardHeight:height});}});_defineProperty(_assertThisInitialized(_this),"handleSwipe",function(e,x,y,isFlick,velocity){var swipeEvent=new CustomEvent('swipe',{detail:{event:e,x:x,y:y,isFlick:isFlick,velocity:velocity}});_this.ref.current.dispatchEvent(swipeEvent);});_this.ref=/*#__PURE__*/React.createRef();_this.state={keyboardHeight:0};_this.props.setContentRef(_this.ref);event.addCallback(EVENT_KEYBOARD_WILL_CHANGE,_this.handleKeyboardChange);return _this;}/**
|
|
6
6
|
* @param {Object} props The component props.
|
|
7
7
|
* @param {Object} state The component state.
|
|
8
8
|
* @returns {Object}
|
|
9
|
-
*/_createClass(ViewContent,[{key:"componentDidMount"
|
|
9
|
+
*/_createClass(ViewContent,[{key:"componentDidMount",value:/**
|
|
10
10
|
* Restore the scroll position of the page.
|
|
11
|
-
*/
|
|
11
|
+
*/function componentDidMount(){this.ref.current.scrollTop=this.context.state.scrollTop;}/**
|
|
12
12
|
* Removes the keyboardWillChange listener.
|
|
13
13
|
*/},{key:"componentWillUnmount",value:function componentWillUnmount(){router.update(this.context.id,{scrollTop:this.ref.current.scrollTop},false);event.removeCallback(EVENT_KEYBOARD_WILL_CHANGE,this.handleKeyboardChange);}/**
|
|
14
14
|
* @returns {Object}
|
|
15
|
-
*/},{key:"
|
|
16
|
-
* @return {JSX}
|
|
17
|
-
*/value:function render(){return React.createElement(Swipeable,{onSwiped:this.handleSwipe,flickThreshold:0.6,delta:10},React.createElement("article",{className:"".concat(styles," engage__view__content ").concat(this.props.className),ref:this.ref,style:this.style},React.createElement(Helmet,{title:appConfig.shopName}),React.createElement(Above,null),React.createElement(ConditionalWrapper,{condition:!this.props.noContentPortal,wrapper:function wrapper(children){return React.createElement(SurroundPortals,{portalName:VIEW_CONTENT},children);}},this.props.children),React.createElement(Below,null)));}},{key:"style",get:function get(){var noScrollOnKeyboard=this.props.noScrollOnKeyboard;var keyboardHeight=this.state.keyboardHeight;return{overflow:noScrollOnKeyboard&&keyboardHeight>0?'hidden':'auto',paddingBottom:"calc(var(--tabbar-height) + ".concat(keyboardHeight,"px)")};}/**
|
|
15
|
+
*/},{key:"style",get:function get(){var noScrollOnKeyboard=this.props.noScrollOnKeyboard;var keyboardHeight=this.state.keyboardHeight;return{overflow:noScrollOnKeyboard&&keyboardHeight>0?'hidden':'auto',paddingBottom:"calc(var(--tabbar-height) + ".concat(keyboardHeight,"px)")};}/**
|
|
18
16
|
* Handles a keyboard change event.
|
|
19
17
|
* @param {boolean} open If the keyboard is now open.
|
|
20
18
|
* @param {boolean} overlap The height of the keyboard.
|
|
21
|
-
*/}
|
|
19
|
+
*/},{key:"render",value:/**
|
|
20
|
+
* @return {JSX}
|
|
21
|
+
*/function render(){return/*#__PURE__*/React.createElement(Swipeable,{onSwiped:this.handleSwipe,flickThreshold:0.6,delta:10},/*#__PURE__*/React.createElement("article",{className:"".concat(styles," engage__view__content ").concat(this.props.className),ref:this.ref,style:this.style},/*#__PURE__*/React.createElement(Helmet,{title:appConfig.shopName}),/*#__PURE__*/React.createElement(Above,null),/*#__PURE__*/React.createElement(ConditionalWrapper,{condition:!this.props.noContentPortal,wrapper:function wrapper(children){return/*#__PURE__*/React.createElement(SurroundPortals,{portalName:VIEW_CONTENT},children);}},this.props.children),/*#__PURE__*/React.createElement(Below,null)));}}],[{key:"getDerivedStateFromProps",value:function getDerivedStateFromProps(props,state){if(props.visible||state.keyboardHeight===0){return null;}return{keyboardHeight:0};}}]);return ViewContent;}(Component);_defineProperty(ViewContent,"contextType",RouteContext);_defineProperty(ViewContent,"defaultProps",{className:'',children:null,noScrollOnKeyboard:false,noContentPortal:false});export default(function(props){return/*#__PURE__*/React.createElement(RouteContext.Consumer,null,function(_ref2){var visible=_ref2.visible,_ref2$pattern=_ref2.pattern,pattern=_ref2$pattern===void 0?'':_ref2$pattern;return/*#__PURE__*/React.createElement(ViewContent,_extends({},props,{visible:visible,className:"route_".concat(pattern.replace(/[:/]/g,'_'))}));});});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from'react';export var ViewContext
|
|
1
|
+
import React from'react';export var ViewContext=/*#__PURE__*/React.createContext();
|
package/components/View/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export{ViewContext};/**
|
|
|
3
3
|
* The View container component.
|
|
4
4
|
* @param {Object} props The component props.
|
|
5
5
|
* @return {JSX}
|
|
6
|
-
*/function ViewContainer(_ref){var background=_ref.background,children=_ref.children,noScrollOnKeyboard=_ref.noScrollOnKeyboard,visible=_ref.visible,ariaHidden=_ref['aria-hidden'],noContentPortal=_ref.noContentPortal;if(visible){setBackgroundColor(background);}var style={display:visible?'block':'none'};return
|
|
6
|
+
*/function ViewContainer(_ref){var background=_ref.background,children=_ref.children,noScrollOnKeyboard=_ref.noScrollOnKeyboard,visible=_ref.visible,ariaHidden=_ref['aria-hidden'],noContentPortal=_ref.noContentPortal;if(visible){setBackgroundColor(background);}var style={display:visible?'block':'none'};return/*#__PURE__*/React.createElement(ViewProvider,null,/*#__PURE__*/React.createElement(ViewContext.Consumer,null,function(_ref2){var setContentRef=_ref2.setContentRef,ariaHiddenContext=_ref2.ariaHidden;return/*#__PURE__*/React.createElement("section",{className:"".concat(styles," engage__view"),style:style,"aria-hidden":ariaHidden||ariaHiddenContext},/*#__PURE__*/React.createElement(Content,{noScrollOnKeyboard:noScrollOnKeyboard,setContentRef:setContentRef,noContentPortal:noContentPortal},children));}));}ViewContainer.defaultProps={'aria-hidden':true,background:colors.light,children:null,noScrollOnKeyboard:false,noContentPortal:false};/**
|
|
7
7
|
* @param {Object} props The component props.
|
|
8
8
|
* @returns {JSX}
|
|
9
|
-
*/export default function View(props){return
|
|
9
|
+
*/export default function View(props){return/*#__PURE__*/React.createElement(RouteContext.Consumer,null,function(_ref3){var visible=_ref3.visible;return/*#__PURE__*/React.createElement(ViewContainer,_extends({},props,{visible:visible}));});}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
function _typeof(obj){
|
|
1
|
+
function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_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);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}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}});Object.defineProperty(subClass,"prototype",{writable:false});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 _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}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 _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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 delay from'lodash/delay';import UIEvents from'@shopgate/pwa-core/emitters/ui';import{emitScrollEvents}from'@shopgate/pwa-common/streams/view';import{MODAL_EVENTS}from'@shopgate/pwa-common/components/ModalContainer';import{ViewContext}from"./context";/**
|
|
2
2
|
* The ViewProvider component.
|
|
3
|
-
*/var ViewProvider=/*#__PURE__*/function(_Component){_inherits(ViewProvider,_Component);
|
|
3
|
+
*/var ViewProvider=/*#__PURE__*/function(_Component){_inherits(ViewProvider,_Component);var _super=_createSuper(ViewProvider);/**
|
|
4
|
+
* @param {Object} props The component props.
|
|
5
|
+
*/function ViewProvider(props){var _this;_classCallCheck(this,ViewProvider);_this=_super.call(this,props);_defineProperty(_assertThisInitialized(_this),"handleModalShow",function(){_this.activeElement=document.activeElement;_this.setAriaHidden(true);});_defineProperty(_assertThisInitialized(_this),"handleModalHide",function(){if(_this.activeElement&&_this.activeElement.focus){_this.activeElement.focus();}_this.setAriaHidden(false);});_defineProperty(_assertThisInitialized(_this),"setTop",function(value){_this.set('top',value);});_defineProperty(_assertThisInitialized(_this),"setBottom",function(value){_this.set('bottom',value);});_defineProperty(_assertThisInitialized(_this),"setAriaHidden",function(value){_this.set('ariaHidden',value);});_defineProperty(_assertThisInitialized(_this),"setContentRef",function(ref){_this.set('contentRef',ref);// Delay to dispatch actual DOM node
|
|
4
6
|
delay(function(){return emitScrollEvents(ref.current);},250);});_defineProperty(_assertThisInitialized(_this),"getContentRef",function(){return _this.state.contentRef;});_defineProperty(_assertThisInitialized(_this),"scrollTop",function(){var value=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;var current=_this.state.contentRef.current;if(current){current.scrollTop=value;}});_defineProperty(_assertThisInitialized(_this),"set",function(property,value){if(_this.state[property]!==value){_this.setState(_defineProperty({},property,value));}});_this.state={top:0,bottom:0,contentRef:{current:null},ariaHidden:false};// Last view active element
|
|
5
7
|
_this.activeElement=null;return _this;}/** @inheritDoc */_createClass(ViewProvider,[{key:"componentDidMount",value:function componentDidMount(){UIEvents.addListener(MODAL_EVENTS.SHOW,this.handleModalShow);UIEvents.addListener(MODAL_EVENTS.HIDE,this.handleModalHide);}/** @inheritDoc */},{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(MODAL_EVENTS.SHOW,this.handleModalShow);UIEvents.removeListener(MODAL_EVENTS.HIDE,this.handleModalHide);}/**
|
|
6
8
|
* @returns {Object}
|
|
7
|
-
*/},{key:"render"
|
|
9
|
+
*/},{key:"providerContext",get:function get(){return _extends({},this.state,{set:this.set,setTop:this.setTop,setBottom:this.setBottom,setAriaHidden:this.setAriaHidden,setContentRef:this.setContentRef,getContentRef:this.getContentRef,scrollTop:this.scrollTop});}},{key:"render",value:/**
|
|
8
10
|
* @returns {JSX}
|
|
9
|
-
*/
|
|
11
|
+
*/function render(){return/*#__PURE__*/React.createElement(ViewContext.Provider,{value:this.providerContext},this.props.children);}}]);return ViewProvider;}(Component);export default ViewProvider;
|