@shopgate/engage 7.29.0-alpha.4 → 7.29.0-alpha.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/engage",
3
- "version": "7.29.0-alpha.4",
3
+ "version": "7.29.0-alpha.5",
4
4
  "description": "Shopgate's ENGAGE library.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -17,12 +17,12 @@
17
17
  "dependencies": {
18
18
  "@emotion/react": "^11.14.0",
19
19
  "@shopgate/native-modules": "1.0.0-beta.25",
20
- "@shopgate/pwa-common": "7.29.0-alpha.4",
21
- "@shopgate/pwa-common-commerce": "7.29.0-alpha.4",
22
- "@shopgate/pwa-core": "7.29.0-alpha.4",
23
- "@shopgate/pwa-ui-ios": "7.29.0-alpha.4",
24
- "@shopgate/pwa-ui-material": "7.29.0-alpha.4",
25
- "@shopgate/pwa-ui-shared": "7.29.0-alpha.4",
20
+ "@shopgate/pwa-common": "7.29.0-alpha.5",
21
+ "@shopgate/pwa-common-commerce": "7.29.0-alpha.5",
22
+ "@shopgate/pwa-core": "7.29.0-alpha.5",
23
+ "@shopgate/pwa-ui-ios": "7.29.0-alpha.5",
24
+ "@shopgate/pwa-ui-material": "7.29.0-alpha.5",
25
+ "@shopgate/pwa-ui-shared": "7.29.0-alpha.5",
26
26
  "@stripe/react-stripe-js": "^1.16.5",
27
27
  "@stripe/stripe-js": "^1.3.1",
28
28
  "@virtuous/conductor": "~2.5.0",
@@ -0,0 +1,4 @@
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{makeStyles}from'@shopgate/engage/styles';import{Swiper,Link,ConditionalWrapper}from'@shopgate/engage/components';import{useImageSliderWidget}from"./hooks";var useStyles=makeStyles()({image:{touchAction:'none',width:'100%'}});/**
2
+ * The ImageSliderWidget is used to display an image slider.
3
+ * @returns {JSX.Element}
4
+ */var ImageSliderWidget=function ImageSliderWidget(){var _useStyles=useStyles(),classes=_useStyles.classes;var _useImageSliderWidget=useImageSliderWidget(),slides=_useImageSliderWidget.slides,swiperProps=_useImageSliderWidget.swiperProps;if(slides.length===0){return null;}return React.createElement(Swiper,_extends({indicators:true},swiperProps),slides.map(function(slide){if(!slide.image.url){return null;}return React.createElement(Swiper.Item,{key:slide.image.url},React.createElement(ConditionalWrapper,{condition:!!slide.link,wrapper:function wrapper(children){return React.createElement(Link,{href:slide.link},children);}},React.createElement("img",{className:classes.image,loading:"lazy",src:slide.image.url,alt:slide.image.altText||''})));}));};export default ImageSliderWidget;
@@ -0,0 +1,32 @@
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 _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{useMemo}from'react';import{useWidget}from'@shopgate/engage/page/hooks';import{useTheme}from'@shopgate/engage/styles';/**
2
+ * @typedef {import('swiper/react').SwiperProps} SwiperCmpProps
3
+ */ /**
4
+ * @typedef {Object} ImageSliderImageData
5
+ * @property {string} url The image URL.
6
+ * @property {string} [altText] The image alt text.
7
+ */ /**
8
+ * @typedef {Object} ImageSliderImage
9
+ * @property {ImageSliderImageData} image The image data object.
10
+ * @property {string} [link] The link URL.
11
+ */ /**
12
+ * @typedef {Object} ImageWidgetConfig
13
+ * @property {ImageSliderImage[]} images The image objects.
14
+ * @property {boolean} slideAutomatic Whether the slider should automatically slide.
15
+ * @property {boolean} endlessSlider Whether the slider should loop endlessly.
16
+ * @property {number} sliderSpeed The speed (in ms) for the slider autoplay.
17
+ * @property {"default"|"dense"|"custom"} slidesPerView
18
+ * @property {number} slidesPerViewCustomSmall Slides per view for small screens.
19
+ * @property {number} slidesPerViewCustomMedium Slides per view for medium screens.
20
+ * @property {number} slidesPerViewCustomLarge Slides per view for large screens.
21
+ */ /**
22
+ * @typedef {ReturnType< typeof import('@shopgate/engage/page/hooks')
23
+ * .useWidget<ImageWidgetConfig> >} UseWidgetReturnType
24
+ */ // eslint-disable-next-line valid-jsdoc
25
+ /**
26
+ * Hook to access the ImageSlider widget configuration and data.
27
+ */export var useImageSliderWidget=function useImageSliderWidget(){/** @type {UseWidgetReturnType} */var _useWidget=useWidget(),config=_useWidget.config,isPreview=_useWidget.isPreview;var theme=useTheme();var images=config.images,slideAutomatic=config.slideAutomatic,endlessSlider=config.endlessSlider,sliderSpeed=config.sliderSpeed,slidesPerView=config.slidesPerView,slidesPerViewCustomSmall=config.slidesPerViewCustomSmall,slidesPerViewCustomMedium=config.slidesPerViewCustomMedium,slidesPerViewCustomLarge=config.slidesPerViewCustomLarge;/**
28
+ * @type {SwiperCmpProps}
29
+ */var swiperProps=useMemo(function(){var slidesPerViewSmall=1.0;var slidesPerViewMedium=1.3;var slidesPerViewLarge=1.6;if(slidesPerView==='dense'){slidesPerViewSmall=1.3;slidesPerViewMedium=1.8;slidesPerViewLarge=2.3;}else if(slidesPerView==='custom'){slidesPerViewSmall=slidesPerViewCustomSmall;slidesPerViewMedium=slidesPerViewCustomMedium;slidesPerViewLarge=slidesPerViewCustomLarge;}var breakpoints=_defineProperty(_defineProperty({},theme.breakpoints.values.sm,{slidesPerView:slidesPerViewMedium}),theme.breakpoints.values.md,{slidesPerView:slidesPerViewLarge});return _extends({autoplay:slideAutomatic?{delay:sliderSpeed}:false,loop:endlessSlider,slidesPerView:slidesPerViewSmall,breakpoints:breakpoints},isPreview?{// Improves interaction with the slider in the CMS preview iframe
30
+ touchStartPreventDefault:true,// Create a component key from breakpoint settings to force remount on breakpoint change.
31
+ // This fixes issues with the Swiper when breakpoint settings change during runtime.
32
+ key:JSON.stringify(_extends({slidesPerView:slidesPerView},breakpoints))}:{});},[isPreview,slidesPerView,slideAutomatic,sliderSpeed,endlessSlider,theme.breakpoints.values,slidesPerViewCustomMedium,slidesPerViewCustomLarge,slidesPerViewCustomSmall]);return{slides:images.filter(function(img){var _img$image;return img===null||img===void 0?void 0:(_img$image=img.image)===null||_img$image===void 0?void 0:_img$image.url;}),swiperProps:swiperProps};};
@@ -0,0 +1 @@
1
+ export{default}from"./ImageSlider";
@@ -1 +1 @@
1
- export{default as PlaceholderWidget}from"./Placeholder";export{default as ProductListWidget}from"./ProductList";export{default as CategoryListWidget}from"./CategoryList";export{default as HtmlWidget}from"./HTML";export{default as ProductSliderWidget}from"./ProductSlider";export{default as HeadlineWidget}from"./Headline";export{default as ImageWidget}from"./Image";
1
+ export{default as PlaceholderWidget}from"./Placeholder";export{default as ProductListWidget}from"./ProductList";export{default as CategoryListWidget}from"./CategoryList";export{default as HtmlWidget}from"./HTML";export{default as ProductSliderWidget}from"./ProductSlider";export{default as HeadlineWidget}from"./Headline";export{default as ImageWidget}from"./Image";export{default as ImageSliderWidget}from"./ImageSlider";
@@ -19,5 +19,8 @@
19
19
  },
20
20
  "@shopgate/widgets/imageWidget": {
21
21
  "path": "@shopgate/engage/page/widgets/Image"
22
+ },
23
+ "@shopgate/widgets/imageSliderWidget": {
24
+ "path": "@shopgate/engage/page/widgets/ImageSlider"
22
25
  }
23
26
  }
@@ -10,13 +10,13 @@ export interface Breakpoints {
10
10
  * // extra-small
11
11
  * xs: 0,
12
12
  * // small
13
- * sm: 600,
13
+ * sm: 480,
14
14
  * // medium
15
- * md: 900,
15
+ * md: 768,
16
16
  * // large
17
- * lg: 1200,
17
+ * lg: 1024,
18
18
  * // extra-large
19
- * xl: 1536,
19
+ * xl: 1280,
20
20
  * }
21
21
  */
22
22
  values: { [key in Breakpoint]: number };