@shopgate/engage 7.32.0-beta.4 → 7.32.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/back-in-stock/components/Subscriptions/components/Subscription/index.js +2 -5
  2. package/cart/components/CartItem/CartItemProductLayout.js +1 -1
  3. package/cart/components/CartItem/CartItemProductLayoutWide.js +2 -2
  4. package/category/components/CategoryImage/index.js +11 -15
  5. package/components/constants.d.ts +6 -0
  6. package/components/constants.d.ts.map +1 -0
  7. package/core/helpers/getFullImageSource.d.ts +5 -1
  8. package/core/helpers/getFullImageSource.d.ts.map +1 -1
  9. package/core/helpers/getFullImageSource.js +30 -14
  10. package/core/helpers/i18n.d.ts +4 -0
  11. package/core/helpers/i18n.d.ts.map +1 -1
  12. package/core/helpers/i18n.js +3 -0
  13. package/core/hooks/html/useLoadImage.d.ts +3 -3
  14. package/core/hooks/html/useLoadImage.d.ts.map +1 -1
  15. package/core/hooks/html/useLoadImage.js +2 -2
  16. package/favorites/components/Item/Item.d.ts.map +1 -1
  17. package/favorites/components/Item/Item.js +2 -5
  18. package/favorites/components/List/List.d.ts +1 -1
  19. package/locations/components/StoreList/StoreListProduct.js +2 -3
  20. package/package.json +8 -8
  21. package/page/components/NotFound.d.ts +7 -0
  22. package/page/components/NotFound.d.ts.map +1 -0
  23. package/page/components/NotFound.js +1 -2
  24. package/page/components/ResponsiveWidgetImage/ResponsiveWidgetImage.d.ts +52 -0
  25. package/page/components/ResponsiveWidgetImage/ResponsiveWidgetImage.d.ts.map +1 -0
  26. package/page/components/ResponsiveWidgetImage/index.d.ts +2 -0
  27. package/page/components/ResponsiveWidgetImage/index.d.ts.map +1 -0
  28. package/page/components/WidgetRichText/WidgetRichText.d.ts +25 -0
  29. package/page/components/WidgetRichText/WidgetRichText.d.ts.map +1 -0
  30. package/page/components/WidgetRichText/index.d.ts +2 -0
  31. package/page/components/WidgetRichText/index.d.ts.map +1 -0
  32. package/page/components/WidgetVideo/WidgetVideo.d.ts +43 -0
  33. package/page/components/WidgetVideo/WidgetVideo.d.ts.map +1 -0
  34. package/page/components/WidgetVideo/WidgetVideo.js +33 -39
  35. package/page/components/WidgetVideo/index.d.ts +2 -0
  36. package/page/components/WidgetVideo/index.d.ts.map +1 -0
  37. package/page/components/Widgets/Overlay.d.ts +17 -0
  38. package/page/components/Widgets/Overlay.d.ts.map +1 -0
  39. package/page/components/Widgets/Overlay.js +24 -38
  40. package/page/components/Widgets/Tooltip.d.ts +20 -0
  41. package/page/components/Widgets/Tooltip.d.ts.map +1 -0
  42. package/page/components/Widgets/Tooltip.js +6 -10
  43. package/page/components/Widgets/Widget.d.ts +32 -0
  44. package/page/components/Widgets/Widget.d.ts.map +1 -0
  45. package/page/components/Widgets/Widget.js +7 -18
  46. package/page/components/Widgets/WidgetContext.d.ts +32 -38
  47. package/page/components/Widgets/WidgetContext.d.ts.map +1 -0
  48. package/page/components/Widgets/WidgetContext.js +2 -8
  49. package/page/components/Widgets/WidgetProvider.d.ts +25 -0
  50. package/page/components/Widgets/WidgetProvider.d.ts.map +1 -0
  51. package/page/components/Widgets/WidgetProvider.js +5 -12
  52. package/page/components/Widgets/Widgets.d.ts +16 -0
  53. package/page/components/Widgets/Widgets.d.ts.map +1 -0
  54. package/page/components/Widgets/Widgets.js +5 -12
  55. package/page/components/Widgets/WidgetsPreviewContext.d.ts +21 -0
  56. package/page/components/Widgets/WidgetsPreviewContext.d.ts.map +1 -0
  57. package/page/components/Widgets/WidgetsPreviewContext.js +5 -7
  58. package/page/components/Widgets/WidgetsPreviewProvider.d.ts +18 -0
  59. package/page/components/Widgets/WidgetsPreviewProvider.d.ts.map +1 -0
  60. package/page/components/Widgets/WidgetsPreviewProvider.js +5 -6
  61. package/page/components/Widgets/constants.d.ts +5 -0
  62. package/page/components/Widgets/constants.d.ts.map +1 -0
  63. package/page/components/Widgets/constants.js +3 -1
  64. package/page/components/Widgets/events.d.ts +38 -0
  65. package/page/components/Widgets/events.d.ts.map +1 -0
  66. package/page/components/Widgets/events.js +8 -12
  67. package/page/components/Widgets/helpers.d.ts +50 -0
  68. package/page/components/Widgets/helpers.d.ts.map +1 -0
  69. package/page/components/Widgets/helpers.js +8 -13
  70. package/page/components/Widgets/hooks.d.ts +13 -0
  71. package/page/components/Widgets/hooks.d.ts.map +1 -0
  72. package/page/components/Widgets/hooks.js +13 -11
  73. package/page/components/Widgets/index.d.ts +3 -0
  74. package/page/components/Widgets/index.d.ts.map +1 -0
  75. package/page/components/Widgets/types.d.ts +111 -113
  76. package/page/components/Widgets/types.d.ts.map +1 -0
  77. package/page/components/Widgets/types.js +1 -0
  78. package/page/components/index.d.ts +5 -0
  79. package/page/components/index.d.ts.map +1 -0
  80. package/page/constants/actionTypes.d.ts +4 -0
  81. package/page/constants/actionTypes.d.ts.map +1 -0
  82. package/page/constants/index.d.ts +25 -0
  83. package/page/constants/index.d.ts.map +1 -0
  84. package/page/helpers/index.d.ts +67 -62
  85. package/page/helpers/index.d.ts.map +1 -0
  86. package/page/helpers/index.js +24 -25
  87. package/page/hooks/index.d.ts +54 -53
  88. package/page/hooks/index.d.ts.map +1 -0
  89. package/page/hooks/index.js +20 -15
  90. package/page/selectors/index.d.ts +32 -0
  91. package/page/selectors/index.d.ts.map +1 -0
  92. package/page/widgets/ProductSlider/ProductSlider.js +1 -15
  93. package/page/widgets/Video/Video.d.ts +6 -0
  94. package/page/widgets/Video/Video.d.ts.map +1 -0
  95. package/page/widgets/Video/Video.js +0 -2
  96. package/page/widgets/Video/hooks.d.ts +53 -0
  97. package/page/widgets/Video/hooks.d.ts.map +1 -0
  98. package/page/widgets/Video/hooks.js +4 -12
  99. package/page/widgets/Video/index.d.ts +2 -0
  100. package/page/widgets/Video/index.d.ts.map +1 -0
  101. package/product/components/Media/FeaturedMedia.js +7 -1
  102. package/product/components/Media/MediaImage.js +24 -23
  103. package/product/components/Media/MediaPlaceholder.js +4 -7
  104. package/product/components/MediaSlider/components/MediaImage/index.js +6 -2
  105. package/product/components/MediaSlider/constants.js +1 -12
  106. package/product/components/ProductCard/index.js +3 -10
  107. package/product/components/ProductGrid/components/Item/components/ItemImage/index.js +2 -5
  108. package/product/components/ProductGrid/constants.d.ts +2 -0
  109. package/product/components/ProductGrid/constants.d.ts.map +1 -0
  110. package/product/components/ProductGrid/constants.js +1 -0
  111. package/product/components/ProductGrid/hooks.d.ts +11 -0
  112. package/product/components/ProductGrid/hooks.d.ts.map +1 -0
  113. package/product/components/ProductGrid/hooks.js +48 -0
  114. package/product/components/ProductGrid/index.js +3 -6
  115. package/product/components/ProductGrid/spec.js +3 -0
  116. package/product/components/ProductImage/ProductImage.d.ts +42 -0
  117. package/product/components/ProductImage/ProductImage.d.ts.map +1 -0
  118. package/product/components/ProductImage/ProductImage.js +153 -0
  119. package/product/components/ProductImage/ProductImagePlaceholder.d.ts +23 -0
  120. package/product/components/ProductImage/ProductImagePlaceholder.d.ts.map +1 -0
  121. package/product/components/ProductImage/ProductImagePlaceholder.js +9 -14
  122. package/product/components/ProductImage/constants.d.ts +7 -0
  123. package/product/components/ProductImage/constants.d.ts.map +1 -0
  124. package/product/components/ProductImage/constants.js +6 -0
  125. package/product/components/ProductImage/hooks.d.ts +8 -0
  126. package/product/components/ProductImage/hooks.d.ts.map +1 -0
  127. package/product/components/ProductImage/hooks.js +32 -0
  128. package/product/components/ProductImage/index.d.ts +3 -0
  129. package/product/components/ProductImage/index.d.ts.map +1 -0
  130. package/product/components/ProductImage/index.js +1 -201
  131. package/product/components/ProductImage/spec.js +115 -60
  132. package/product/components/ProductList/components/Item/index.js +5 -3
  133. package/product/components/ProductRatingStars/ProductRatingStars.js +2 -4
  134. package/product/components/ProductSlider/constants.d.ts +3 -0
  135. package/product/components/ProductSlider/constants.d.ts.map +1 -0
  136. package/product/components/ProductSlider/constants.js +2 -0
  137. package/product/components/ProductSlider/hooks.d.ts +7 -0
  138. package/product/components/ProductSlider/hooks.d.ts.map +1 -0
  139. package/product/components/ProductSlider/hooks.js +40 -0
  140. package/product/components/ProductSlider/index.js +4 -6
  141. package/product/components/ProductSlider/spec.js +2 -2
  142. package/product/components/Rating/index.js +2 -4
  143. package/product/helpers/index.js +29 -11
  144. package/product/hooks/index.js +3 -1
  145. package/product/hooks/useLoadProductImage.js +4 -2
  146. package/product/hooks/useShowEmptyRatingStars.d.ts +7 -0
  147. package/product/hooks/useShowEmptyRatingStars.d.ts.map +1 -0
  148. package/product/hooks/useShowEmptyRatingStars.js +21 -0
  149. package/product/index.js +0 -1
  150. package/settings/constants/appSettings.d.ts +3 -0
  151. package/settings/constants/appSettings.d.ts.map +1 -1
  152. package/settings/constants/appSettings.js +6 -1
  153. package/settings/constants/imageSettings.d.ts +52 -0
  154. package/settings/constants/imageSettings.d.ts.map +1 -0
  155. package/settings/constants/imageSettings.js +69 -0
  156. package/settings/helpers/index.d.ts +3 -0
  157. package/settings/helpers/index.d.ts.map +1 -0
  158. package/settings/helpers/index.js +1 -0
  159. package/settings/helpers/resolveImageSettings.d.ts +70 -0
  160. package/settings/helpers/resolveImageSettings.d.ts.map +1 -0
  161. package/settings/helpers/resolveImageSettings.js +171 -0
  162. package/settings/helpers/toImageQuality.d.ts +7 -0
  163. package/settings/helpers/toImageQuality.d.ts.map +1 -0
  164. package/settings/helpers/toImageQuality.js +44 -0
  165. package/settings/helpers/toThumborColor.d.ts +15 -0
  166. package/settings/helpers/toThumborColor.d.ts.map +1 -0
  167. package/settings/helpers/toThumborColor.js +51 -0
  168. package/settings/hooks/index.d.ts +2 -0
  169. package/settings/hooks/index.d.ts.map +1 -0
  170. package/settings/hooks/index.js +1 -0
  171. package/settings/hooks/useImageSettings.d.ts +28 -0
  172. package/settings/hooks/useImageSettings.d.ts.map +1 -0
  173. package/settings/hooks/useImageSettings.js +39 -0
  174. package/settings/reducers/appSettings.d.ts.map +1 -1
  175. package/settings/reducers/appSettings.js +66 -4
  176. package/settings/reducers/index.d.ts +2 -2
  177. package/settings/selectors/appSettings.d.ts +46 -0
  178. package/settings/selectors/appSettings.d.ts.map +1 -1
  179. package/settings/selectors/appSettings.js +26 -1
  180. package/settings/types/appSettings.d.ts +156 -0
  181. package/settings/types/appSettings.d.ts.map +1 -1
  182. package/styles/reset/root.js +23 -4
  183. package/styles/reset/typographyCustomProps.d.ts +12 -0
  184. package/styles/reset/typographyCustomProps.d.ts.map +1 -0
  185. package/styles/reset/typographyCustomProps.js +11 -0
  186. package/styles/theme/createTheme/createTypography.js +1 -0
  187. package/styles/theme/createTheme/helpers/cssVarsParser.d.ts.map +1 -1
  188. package/styles/theme/createTheme/helpers/cssVarsParser.js +10 -3
  189. package/product/collections/index.js +0 -1
  190. package/product/components/EffectivityDates/constants.d.ts +0 -3
  191. package/product/components/EffectivityDates/constants.d.ts.map +0 -1
  192. package/product/components/EffectivityDates/helpers.d.ts +0 -6
  193. package/product/components/EffectivityDates/helpers.d.ts.map +0 -1
  194. package/product/components/Media/helpers.d.ts +0 -2
  195. package/product/components/Media/helpers.d.ts.map +0 -1
  196. package/product/components/ProductImage/connector.js +0 -12
  197. package/product/helpers/index.d.ts +0 -13
  198. package/product/helpers/index.d.ts.map +0 -1
  199. package/product/helpers/redirects.d.ts +0 -2
  200. package/product/helpers/redirects.d.ts.map +0 -1
  201. package/product/selectors/helpers/filterProperties.d.ts +0 -8
  202. package/product/selectors/helpers/filterProperties.d.ts.map +0 -1
  203. package/product/selectors/helpers/index.d.ts +0 -3
  204. package/product/selectors/helpers/index.d.ts.map +0 -1
  205. package/product/selectors/helpers/wrapMemoizedSelector.d.ts +0 -2
  206. package/product/selectors/helpers/wrapMemoizedSelector.d.ts.map +0 -1
  207. package/product/selectors/product.d.ts +0 -112
  208. package/product/selectors/product.d.ts.map +0 -1
@@ -1,11 +1,19 @@
1
- import React, { useEffect, useMemo, useState } from 'react';
1
+ import { useEffect, useMemo, useState, useRef } from 'react';
2
2
  import { makeStyles } from '@shopgate/engage/styles';
3
3
  import { useReduceMotion } from '@shopgate/engage/a11y/hooks';
4
4
  import { usePrevious, useAppEventOnReturnFromBackground } from '@shopgate/engage/core/hooks';
5
- import { ConditionalWrapper, Link } from '@shopgate/engage/components';
6
- import PropTypes from 'prop-types';
5
+ import { ConditionalWrapper, Link as EngageLink } from '@shopgate/engage/components';
7
6
  import { isHttpsUrl } from "../../helpers";
7
+
8
+ // `Link` is a redux-connected component whose react-redux connect() typing resolves its own props
9
+ // (href/children) to `never`; alias it to its actual usable prop shape.
8
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
+ const Link = EngageLink;
12
+
13
+ /**
14
+ * Style parameters for the widget video.
15
+ */
16
+
9
17
  const useStyles = makeStyles()((_theme, {
10
18
  borderRadius
11
19
  }) => ({
@@ -36,28 +44,22 @@ const useStyles = makeStyles()((_theme, {
36
44
  }
37
45
  }));
38
46
 
47
+ /**
48
+ * Props of the {@link WidgetVideo} component.
49
+ */
50
+
39
51
  /**
40
52
  * The WidgetVideo component is used to display a video in a widget.
41
- * @param {Object} props The component props.
42
- * @param {boolean} props.isBanner Whether the video is used in a banner.
43
- * @param {string} props.url The video URL.
44
- * @param {boolean} props.muted Whether the video is muted.
45
- * @param {boolean} props.loop Whether the video is looping.
46
- * @param {boolean} props.controls Whether the video controls are shown.
47
- * @param {boolean} props.autoplay Whether the video should autoplay.
48
- * @param {number} props.borderRadius The border radius value.
49
- * @param {string} props.link The link URL.
50
- * @returns {JSX.Element}
51
53
  */
52
54
  const WidgetVideo = ({
53
- isBanner,
54
- url,
55
- muted,
56
- loop,
57
- controls,
58
- autoplay,
59
- borderRadius,
60
- link
55
+ isBanner = false,
56
+ url = null,
57
+ muted = false,
58
+ loop = false,
59
+ controls = false,
60
+ autoplay = false,
61
+ borderRadius = 0,
62
+ link = null
61
63
  }) => {
62
64
  const reduceMotion = useReduceMotion();
63
65
  const autoplayValue = reduceMotion ? false : isBanner || autoplay;
@@ -68,7 +70,7 @@ const WidgetVideo = ({
68
70
  borderRadius
69
71
  });
70
72
  const [hasError, setHasError] = useState(false);
71
- const videoRef = React.useRef(null);
73
+ const videoRef = useRef(null);
72
74
  const prevUrl = usePrevious(url);
73
75
  const isValidUrl = useMemo(() => url ? isHttpsUrl(url) : false, [url]);
74
76
  const showControls = useMemo(() => {
@@ -81,25 +83,27 @@ const WidgetVideo = ({
81
83
 
82
84
  // Resume video playback when app returned from background
83
85
  useAppEventOnReturnFromBackground(() => {
84
- if (!videoRef.current || reduceMotion || !autoplayValue) {
86
+ const video = videoRef.current;
87
+ if (!video || reduceMotion || !autoplayValue) {
85
88
  return;
86
89
  }
87
- videoRef.current.play();
90
+ video.play();
88
91
  });
89
92
  useEffect(() => {
90
- if (!videoRef.current) {
93
+ const video = videoRef.current;
94
+ if (!video) {
91
95
  return;
92
96
  }
93
97
  if (reduceMotion) {
94
98
  // Pause playback when reduced motion settings changed after video was rendered
95
- videoRef.current.pause();
99
+ video.pause();
96
100
  return;
97
101
  }
98
102
  if (autoplayValue) {
99
- videoRef.current.play();
103
+ video.play();
100
104
  } else {
101
- videoRef.current.pause();
102
- videoRef.current.currentTime = 0;
105
+ video.pause();
106
+ video.currentTime = 0;
103
107
  }
104
108
  }, [autoplayValue, reduceMotion]);
105
109
  useEffect(() => {
@@ -146,14 +150,4 @@ const WidgetVideo = ({
146
150
  })
147
151
  });
148
152
  };
149
- WidgetVideo.defaultProps = {
150
- isBanner: false,
151
- link: null,
152
- url: null,
153
- muted: false,
154
- loop: false,
155
- controls: false,
156
- autoplay: false,
157
- borderRadius: 0
158
- };
159
153
  export default WidgetVideo;
@@ -0,0 +1,2 @@
1
+ export { default } from './WidgetVideo';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../page/components/WidgetVideo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { type RefObject } from 'react';
2
+ /**
3
+ * Props of the {@link Overlay} component.
4
+ */
5
+ export interface OverlayProps {
6
+ /**
7
+ * The reference to the container element that holds the widgets.
8
+ */
9
+ containerRef: RefObject<HTMLDivElement>;
10
+ }
11
+ /**
12
+ * The Overlay component is used to highlight the active widget when preview mode is active.
13
+ * It also visualizes the margins of the widget and the borders to its sibling widgets.
14
+ */
15
+ declare const Overlay: ({ containerRef, }: OverlayProps) => import("react").JSX.Element | null;
16
+ export default Overlay;
17
+ //# sourceMappingURL=Overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Overlay.d.ts","sourceRoot":"","sources":["../../../../page/components/Widgets/Overlay.tsx"],"names":[],"mappings":"AAAA,OAAO,EACqC,KAAK,SAAS,EACzD,MAAM,OAAO,CAAC;AA+Ff;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;CACzC;AAED;;;GAGG;AACH,QAAA,MAAM,OAAO,GAAI,mBAEd,YAAY,uCAmNd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,5 +1,4 @@
1
- import React, { useState, useRef, useEffect, useCallback } from 'react';
2
- import PropTypes from 'prop-types';
1
+ import { useState, useRef, useEffect, useCallback } from 'react';
3
2
  import { makeStyles, keyframes, colorToRgba } from '@shopgate/engage/styles';
4
3
  import { useRoute } from '@shopgate/engage/core/hooks';
5
4
  import { getScrollContainer } from "./helpers";
@@ -7,19 +6,15 @@ import { useWidgetPreviewEvent } from "./events";
7
6
  import { useWidgetsPreview } from "./hooks";
8
7
 
9
8
  /**
10
- * @typedef {Object} OverlayStyle
11
- * @property {number} top Style for the top position of the overlay.
12
- * @property {number} left Style for the left position of the overlay.
13
- * @property {number} width Style for the width of the overlay.
14
- * @property {number} height Style for the height of the overlay.
9
+ * Position and dimensions of a single overlay rectangle.
15
10
  */
16
11
 
17
12
  /**
18
- * @typedef {Object} MarginOverlayStyles
19
- * @property {OverlayStyle} top Style for the top margin overlay.
20
- * @property {OverlayStyle} left Style for the left margin overlay.
21
- * @property {OverlayStyle} bottom Style for the bottom margin overlay.
22
- * @property {OverlayStyle} right Style for the right margin overlay.
13
+ * Styles for the four margin overlays surrounding the active widget.
14
+ */
15
+
16
+ /**
17
+ * Style parameters for the overlay.
23
18
  */
24
19
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
25
20
  const useStyles = makeStyles({
@@ -62,13 +57,13 @@ const useStyles = makeStyles({
62
57
  }
63
58
  }));
64
59
 
60
+ /**
61
+ * Props of the {@link Overlay} component.
62
+ */
63
+
65
64
  /**
66
65
  * The Overlay component is used to highlight the active widget when preview mode is active.
67
66
  * It also visualizes the margins of the widget and the borders to its sibling widgets.
68
- * @param {Object} props The component props.
69
- * @param {React.Ref<HTMLDivElement>} props.containerRef The reference to the container element that
70
- * holds the widgets.
71
- * @returns {JSX.Element|null}
72
67
  */
73
68
  const Overlay = ({
74
69
  containerRef
@@ -84,17 +79,10 @@ const Overlay = ({
84
79
  activeWidget
85
80
  } = useWidgetsPreview();
86
81
 
87
- /**
88
- * State to hold the style for the main overlay that highlights the active widget.
89
- * @type {[OverlayStyle|null, React.Dispatch<React.SetStateAction<OverlayStyle|null>>]}
90
- */
82
+ // State to hold the style for the main overlay that highlights the active widget.
91
83
  const [mainOverlayStyle, setMainOverlayStyle] = useState(null);
92
84
 
93
- /**
94
- * State to hold the styles for the margin overlays that visualize the widget margins.
95
- * @type {[MarginOverlayStyles|null,
96
- * React.Dispatch<React.SetStateAction<MarginOverlayStyles|null>>]}
97
- */
85
+ // State to hold the styles for the margin overlays that visualize the widget margins.
98
86
  const [marginOverlays, setMarginOverlays] = useState(null);
99
87
  const [isFlashing, setIsFlashing] = useState(false);
100
88
  const {
@@ -105,14 +93,7 @@ const Overlay = ({
105
93
  marginOverlayColor,
106
94
  isFlashing
107
95
  });
108
-
109
- /**
110
- * @type {import('react').MutableRefObject<ResizeObserver|null>}
111
- */
112
96
  const resizeRef = useRef(null);
113
- /**
114
- * @type {import('react').MutableRefObject<MutationObserver|null>}
115
- */
116
97
  const mutationRef = useRef(null);
117
98
 
118
99
  /**
@@ -128,6 +109,9 @@ const Overlay = ({
128
109
  return;
129
110
  }
130
111
  const scrollContainer = getScrollContainer();
112
+ if (!scrollContainer) {
113
+ return;
114
+ }
131
115
 
132
116
  // Get the computed styles of the active widget to calculate margins
133
117
  const styles = window.getComputedStyle(target);
@@ -191,33 +175,34 @@ const Overlay = ({
191
175
  if (!containerEl) return undefined;
192
176
 
193
177
  // Create a ResizeObserver to watch for size changes of children
194
- resizeRef.current = new ResizeObserver(() => {
178
+ const resizeObserver = new ResizeObserver(() => {
195
179
  // Whenever any observed child resizes, update overlay
196
180
  updateOverlay();
197
181
  });
182
+ resizeRef.current = resizeObserver;
198
183
 
199
184
  // Observe all existing children
200
185
  Array.from(containerEl.children).forEach(child => {
201
186
  if (child.nodeType === Node.ELEMENT_NODE) {
202
- resizeRef.current.observe(child);
187
+ resizeObserver.observe(child);
203
188
  }
204
189
  });
205
190
 
206
191
  // Create one MutationObserver on the container to watch for changes in the DOM
207
- mutationRef.current = new MutationObserver(mutations => {
192
+ const mutationObserver = new MutationObserver(mutations => {
208
193
  for (const mutation of mutations) {
209
194
  if (mutation.type === 'childList') {
210
195
  // Handle newly added nodes - observe them for size changes
211
196
  mutation.addedNodes.forEach(node => {
212
197
  if (node.nodeType === Node.ELEMENT_NODE) {
213
- resizeRef.current.observe(node);
198
+ resizeObserver.observe(node);
214
199
  }
215
200
  });
216
201
 
217
202
  // Handle removed nodes - remove them from observation
218
203
  mutation.removedNodes.forEach(node => {
219
204
  if (node.nodeType === Node.ELEMENT_NODE) {
220
- resizeRef.current.unobserve(node);
205
+ resizeObserver.unobserve(node);
221
206
  }
222
207
  });
223
208
 
@@ -231,11 +216,12 @@ const Overlay = ({
231
216
  }
232
217
  }
233
218
  });
219
+ mutationRef.current = mutationObserver;
234
220
 
235
221
  // Start observing:
236
222
  // - childList:true → to catch added/removed children
237
223
  // - subtree:true + attributes:true → to catch any class/style changes in descendants
238
- mutationRef.current.observe(containerEl, {
224
+ mutationObserver.observe(containerEl, {
239
225
  childList: true,
240
226
  subtree: true,
241
227
  attributes: true,
@@ -0,0 +1,20 @@
1
+ import { type ReactNode } from 'react';
2
+ /**
3
+ * Props of the {@link Tooltip} component.
4
+ */
5
+ export interface TooltipProps {
6
+ /**
7
+ * The child elements to wrap.
8
+ */
9
+ children: ReactNode;
10
+ /**
11
+ * The tooltip text to display.
12
+ */
13
+ text?: string | null;
14
+ }
15
+ /**
16
+ * AI generated Tooltip component to display additional information on hover.
17
+ */
18
+ declare function Tooltip({ children, text }: TooltipProps): import("react").JSX.Element;
19
+ export default Tooltip;
20
+ //# sourceMappingURL=Tooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../page/components/Widgets/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EACwB,KAAK,SAAS,EAC5C,MAAM,OAAO,CAAC;AAwDf;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;GAEG;AACH,iBAAS,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,YAAY,+BA0IhD;AAED,eAAe,OAAO,CAAC"}
@@ -1,6 +1,5 @@
1
- import React, { useState, useRef, useEffect } from 'react';
1
+ import { useState, useRef, useEffect } from 'react';
2
2
  import ReactDOM from 'react-dom';
3
- import PropTypes from 'prop-types';
4
3
  import { Typography } from '@shopgate/engage/components';
5
4
  import { makeStyles } from '@shopgate/engage/styles';
6
5
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -56,12 +55,12 @@ const useStyles = makeStyles()(theme => ({
56
55
  }
57
56
  }));
58
57
 
58
+ /**
59
+ * Props of the {@link Tooltip} component.
60
+ */
61
+
59
62
  /**
60
63
  * AI generated Tooltip component to display additional information on hover.
61
- * @param {Object} props The component props.
62
- * @param {React.ReactNode} props.children The child elements to wrap.
63
- * @param {string} props.text The tooltip text to display.
64
- * @returns {JSX.Element}
65
64
  */
66
65
  function Tooltip({
67
66
  children,
@@ -80,7 +79,7 @@ function Tooltip({
80
79
  top: 0
81
80
  });
82
81
  const [arrowLeft, setArrowLeft] = useState(null);
83
- const [positionState, setPositionState] = useState('top'); // 'top' or 'bottom'
82
+ const [positionState, setPositionState] = useState('top');
84
83
  const tooltipId = useRef(Math.random().toString(36).slice(2, 11));
85
84
 
86
85
  // Handle mounting/unmounting and trigger fade animation
@@ -196,7 +195,4 @@ function Tooltip({
196
195
  }), document.body)]
197
196
  });
198
197
  }
199
- Tooltip.defaultProps = {
200
- text: null
201
- };
202
198
  export default Tooltip;
@@ -0,0 +1,32 @@
1
+ import { type ComponentType } from 'react';
2
+ import { type WidgetDefinition } from './types';
3
+ /**
4
+ * Props of the {@link Widget} component.
5
+ */
6
+ export interface WidgetProps {
7
+ /**
8
+ * The widget component to render.
9
+ */
10
+ component: ComponentType<{
11
+ settings?: WidgetDefinition['widgetConfig'];
12
+ }>;
13
+ /**
14
+ * The widget definition data.
15
+ */
16
+ definition: WidgetDefinition;
17
+ /**
18
+ * Whether the widget is in preview mode.
19
+ */
20
+ isPreview: boolean;
21
+ /**
22
+ * Whether the widget is a legacy custom widget provided by an extension that's configured
23
+ * via an HTML comment inside a HTML widget.
24
+ */
25
+ isCustomLegacyWidget?: boolean;
26
+ }
27
+ /**
28
+ * The Widget component.
29
+ */
30
+ declare const Widget: ({ component: Component, definition, isPreview, isCustomLegacyWidget, }: WidgetProps) => import("react").JSX.Element | null;
31
+ export default Widget;
32
+ //# sourceMappingURL=Widget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Widget.d.ts","sourceRoot":"","sources":["../../../../page/components/Widgets/Widget.tsx"],"names":[],"mappings":"AAAA,OAAO,EACkB,KAAK,aAAa,EAC1C,MAAM,OAAO,CAAC;AAQf,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAiDhD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,SAAS,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAA;KAAE,CAAC,CAAC;IAC1E;;OAEG;IACH,UAAU,EAAE,gBAAgB,CAAC;IAC7B;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;GAEG;AACH,QAAA,MAAM,MAAM,GAAI,wEAKb,WAAW,uCAqEb,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,5 +1,4 @@
1
- import React, { Suspense, useCallback } from 'react';
2
- import PropTypes from 'prop-types';
1
+ import { Suspense, useCallback } from 'react';
3
2
  import { makeStyles } from '@shopgate/engage/styles';
4
3
  import { VisibilityOffIcon, TimeIcon, Loading } from '@shopgate/engage/components';
5
4
  import { usePressHandler } from '@shopgate/engage/core/hooks';
@@ -7,6 +6,10 @@ import WidgetProvider from "./WidgetProvider";
7
6
  import { dispatchWidgetPreviewEvent } from "./events";
8
7
  import { useWidgetsPreview } from "./hooks";
9
8
  import Tooltip from "./Tooltip";
9
+
10
+ /**
11
+ * Style parameters for the widget, derived from its layout margins.
12
+ */
10
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
14
  const useStyles = makeStyles()((theme, {
12
15
  marginTop,
@@ -46,28 +49,17 @@ const useStyles = makeStyles()((theme, {
46
49
  }));
47
50
 
48
51
  /**
49
- * @typedef {import('./types').WidgetDefinition} WidgetDefinition
50
- */
51
-
52
- /**
53
- * @typedef {import('./types').ScheduledStatus} ScheduledStatus
52
+ * Props of the {@link Widget} component.
54
53
  */
55
54
 
56
55
  /**
57
56
  * The Widget component.
58
- * @param {Object} props The component props.
59
- * @param {React.ComponentType} props.component The widget component to render.
60
- * @param {WidgetDefinition} props.definition The widget definition data.
61
- * @param {boolean} props.isPreview Whether the widget is in preview mode.
62
- * @param {boolean} props.isCustomLegacyWidget Whether the widget is a legacy custom widget provided
63
- * by an extension that's configured via an HTML comment inside a HTML widget.
64
- * @returns {JSX.Element}
65
57
  */
66
58
  const Widget = ({
67
59
  component: Component,
68
60
  definition,
69
61
  isPreview,
70
- isCustomLegacyWidget
62
+ isCustomLegacyWidget = false
71
63
  }) => {
72
64
  const {
73
65
  classes,
@@ -138,7 +130,4 @@ const Widget = ({
138
130
  })]
139
131
  });
140
132
  };
141
- Widget.defaultProps = {
142
- isCustomLegacyWidget: false
143
- };
144
133
  export default Widget;
@@ -1,42 +1,36 @@
1
- import { type Context } from 'react';
2
- import {
3
- type WidgetDefinitionLayout,
4
- type WidgetDefinitionVisibility,
5
- type WidgetDefinition,
6
- } from './types'
7
-
8
- export { WidgetDefinition } from './types';
9
-
10
- export interface WidgetContextType<C = Record<string, any>> {
11
- /**
12
- * The unique code of the widget instance
13
- */
14
- code: string;
15
- /**
16
- * The name of the widget
17
- */
18
- name: string;
19
- /**
20
- * The widget configuration
21
- */
22
- config: C;
23
- /**
24
- * The widget layout settings
25
- */
26
- layout: WidgetDefinitionLayout;
27
- /**
28
- * The widget visibility settings
29
- */
30
- visibility: WidgetDefinitionVisibility;
31
- /**
32
- * Whether the widget is rendered in preview mode
33
- */
34
- isPreview: boolean;
1
+ import { type WidgetDefinitionLayout, type WidgetDefinitionVisibility } from './types';
2
+ export { type WidgetDefinition } from './types';
3
+ /**
4
+ * Context value provided by the {@link WidgetContext} for a single widget instance.
5
+ */
6
+ export interface WidgetContextType<C = Record<string, unknown>> {
7
+ /**
8
+ * The unique code of the widget instance.
9
+ */
10
+ code: string;
11
+ /**
12
+ * The name of the widget.
13
+ */
14
+ name: string;
15
+ /**
16
+ * The widget configuration.
17
+ */
18
+ config: C;
19
+ /**
20
+ * The widget layout settings.
21
+ */
22
+ layout: WidgetDefinitionLayout;
23
+ /**
24
+ * The widget visibility settings.
25
+ */
26
+ visibility: WidgetDefinitionVisibility;
27
+ /**
28
+ * Whether the widget is rendered in preview mode.
29
+ */
30
+ isPreview: boolean;
35
31
  }
36
-
37
32
  /**
38
33
  * React context for widgets.
39
34
  */
40
- declare const WidgetContext: Context<WidgetContextType>;
41
-
42
- export default WidgetContext;
35
+ export declare const WidgetContext: import("react").Context<WidgetContextType<Record<string, unknown>>>;
36
+ //# sourceMappingURL=WidgetContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetContext.d.ts","sourceRoot":"","sources":["../../../../page/components/Widgets/WidgetContext.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAChC,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5D;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,EAAE,CAAC,CAAC;IACV;;OAEG;IACH,MAAM,EAAE,sBAAsB,CAAC;IAC/B;;OAEG;IACH,UAAU,EAAE,0BAA0B,CAAC;IACvC;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,qEAA4D,CAAC"}
@@ -1,16 +1,10 @@
1
1
  import { createContext } from 'react';
2
2
 
3
3
  /**
4
- * @typedef {import('./Widgets.jsx').WidgetDefinition} WidgetDefinition
4
+ * Context value provided by the {@link WidgetContext} for a single widget instance.
5
5
  */
6
6
 
7
7
  /**
8
- * @typedef {Object} WidgetContextType
9
- * @property {WidgetDefinition['code']} code The unique widget code.
10
- * @property {WidgetDefinition['widgetConfig']} config The widget configuration.
11
- * @property {WidgetDefinition['layout']} layout The widget layout settings.
12
- * @property {WidgetDefinition['visibility']} visibility The widget visibility settings.
8
+ * React context for widgets.
13
9
  */
14
-
15
- /** @type {React.Context<WidgetContextType>} */
16
10
  export const WidgetContext = /*#__PURE__*/createContext({});
@@ -0,0 +1,25 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type WidgetDefinition } from './types';
3
+ /**
4
+ * Props of the {@link WidgetProvider} component.
5
+ */
6
+ export interface WidgetProviderProps {
7
+ /**
8
+ * The child components to render.
9
+ */
10
+ children: ReactNode;
11
+ /**
12
+ * The widget definition data.
13
+ */
14
+ definition: WidgetDefinition;
15
+ /**
16
+ * Whether the widget is in preview mode.
17
+ */
18
+ isPreview: boolean;
19
+ }
20
+ /**
21
+ * The WidgetProvider component provides the context for a single widget.
22
+ */
23
+ declare const WidgetProvider: ({ children, definition, isPreview }: WidgetProviderProps) => import("react").JSX.Element;
24
+ export default WidgetProvider;
25
+ //# sourceMappingURL=WidgetProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetProvider.d.ts","sourceRoot":"","sources":["../../../../page/components/Widgets/WidgetProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,UAAU,EAAE,gBAAgB,CAAC;IAC7B;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,QAAA,MAAM,cAAc,GAAI,qCAAqC,mBAAmB,gCAoB/E,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,25 +1,18 @@
1
- import React, { useMemo } from 'react';
2
- import PropTypes from 'prop-types';
1
+ import { useMemo } from 'react';
3
2
  import { WidgetContext } from "./WidgetContext";
4
3
 
5
- /** @typedef {import('./WidgetContext').WidgetContextType} WidgetContextType */
6
- /** @typedef {import('./WidgetContext').WidgetDefinition} WidgetDefinition */
7
-
8
4
  /**
9
- * The WidgetProvider component provides the context for a single widget.
10
- * @param {Object} props The component props.
11
- * @param {WidgetDefinition} props.definition The widget definition data.
12
- * @param {boolean} props.isPreview Whether the widget is in preview mode.
13
- * @param {React.ReactNode} props.children The child components to render.
14
- * @returns {JSX.Element}
5
+ * Props of the {@link WidgetProvider} component.
15
6
  */
16
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
+ /**
9
+ * The WidgetProvider component provides the context for a single widget.
10
+ */
17
11
  const WidgetProvider = ({
18
12
  children,
19
13
  definition,
20
14
  isPreview
21
15
  }) => {
22
- /** @type {WidgetContextType} */
23
16
  const value = useMemo(() => {
24
17
  const {
25
18
  widgetConfig,
@@ -0,0 +1,16 @@
1
+ import { type WidgetDefinition } from './types';
2
+ /**
3
+ * Props of the {@link Widgets} component.
4
+ */
5
+ export interface WidgetsProps {
6
+ /**
7
+ * The list of widgets to render.
8
+ */
9
+ widgets?: WidgetDefinition[];
10
+ }
11
+ /**
12
+ * The Widgets component renders a list of widgets.
13
+ */
14
+ declare const Widgets: ({ widgets: widgetsProp, }: WidgetsProps) => import("react").JSX.Element | null;
15
+ export default Widgets;
16
+ //# sourceMappingURL=Widgets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Widgets.d.ts","sourceRoot":"","sources":["../../../../page/components/Widgets/Widgets.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAYhD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,QAAA,MAAM,OAAO,GAAI,2BAEd,YAAY,uCA+Dd,CAAC;AAEF,eAAe,OAAO,CAAC"}