@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,5 +1,4 @@
1
- import React, { useMemo, useRef } from 'react';
2
- import PropTypes from 'prop-types';
1
+ import { useMemo, useRef } from 'react';
3
2
  import { makeStyles } from '@shopgate/engage/styles';
4
3
  import { useRoute, useThemeWidgets } from '@shopgate/engage/core/hooks';
5
4
  import { PAGE_PREVIEW_PATTERN } from '@shopgate/engage/page/constants';
@@ -10,10 +9,6 @@ import Widget from "./Widget";
10
9
  import Overlay from "./Overlay";
11
10
  import { checkScheduled } from "./helpers";
12
11
  import { usePreviewIframeCommunication } from "./hooks";
13
-
14
- /**
15
- * @typedef {import('./types').WidgetDefinition} WidgetDefinition
16
- */
17
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
13
  const PLACEHOLDER_COMPONENT = '@shopgate/widgetsInternal/Placeholder';
19
14
  const useStyles = makeStyles()({
@@ -24,11 +19,12 @@ const useStyles = makeStyles()({
24
19
  }
25
20
  });
26
21
 
22
+ /**
23
+ * Props of the {@link Widgets} component.
24
+ */
25
+
27
26
  /**
28
27
  * The Widgets component renders a list of widgets.
29
- * @param {Object} props The component props.
30
- * @param {Array<WidgetDefinition>} props.widgets The list of widgets to render.
31
- * @returns {JSX.Element}
32
28
  */
33
29
  const Widgets = ({
34
30
  widgets: widgetsProp = []
@@ -85,7 +81,4 @@ const Widgets = ({
85
81
  })
86
82
  });
87
83
  };
88
- Widgets.defaultProps = {
89
- widgets: null
90
- };
91
84
  export default Widgets;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Sets the active widget in the preview context.
3
+ * @param code The code of the widget to set as active.
4
+ * @param highlight Whether to highlight the widget after setting it as active.
5
+ */
6
+ export type SetActiveWidget = (code: string, highlight?: boolean) => void;
7
+ /**
8
+ * Context value provided by the {@link WidgetsPreviewContext}.
9
+ */
10
+ export interface WidgetsPreviewContextType {
11
+ /**
12
+ * The code of the currently active widget.
13
+ */
14
+ activeWidget: string | null;
15
+ /**
16
+ * A function to set the active widget code.
17
+ */
18
+ setActiveWidget: SetActiveWidget;
19
+ }
20
+ export declare const WidgetsPreviewContext: import("react").Context<WidgetsPreviewContextType>;
21
+ //# sourceMappingURL=WidgetsPreviewContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetsPreviewContext.d.ts","sourceRoot":"","sources":["../../../../page/components/Widgets/WidgetsPreviewContext.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;OAEG;IACH,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,eAAO,MAAM,qBAAqB,oDAGhC,CAAC"}
@@ -1,18 +1,16 @@
1
1
  import _noop from "lodash/noop";
2
2
  import { createContext } from 'react';
3
+
3
4
  /**
4
- * @callback SetActiveWidget
5
- * @param {string} code The code of the widget to set as active.
6
- * @param {boolean} [highlight=false] Whether to highlight the widget after setting it as active.
5
+ * Sets the active widget in the preview context.
6
+ * @param code The code of the widget to set as active.
7
+ * @param highlight Whether to highlight the widget after setting it as active.
7
8
  */
8
9
 
9
10
  /**
10
- * @typedef {Object} WidgetsPreviewContextType
11
- * @property {string} activeWidget The code of the currently active widget.
12
- * @property {SetActiveWidget} setActiveWidget A function to set the active widget code
11
+ * Context value provided by the {@link WidgetsPreviewContext}.
13
12
  */
14
13
 
15
- /** @type {React.Context<WidgetsPreviewContextType>} */
16
14
  export const WidgetsPreviewContext = /*#__PURE__*/createContext({
17
15
  activeWidget: null,
18
16
  setActiveWidget: _noop
@@ -0,0 +1,18 @@
1
+ import { type ReactNode } from 'react';
2
+ /**
3
+ * Props of the {@link WidgetsPreviewProvider} component.
4
+ */
5
+ export interface WidgetsPreviewProviderProps {
6
+ /**
7
+ * The child components to render.
8
+ */
9
+ children: ReactNode;
10
+ }
11
+ /**
12
+ * The WidgetsPreviewProvider component is used by the Widgets component when it's rendered
13
+ * in preview mode. It provides functionality for the Widget component that's needed when
14
+ * the widgets are rendered in the preview iframe.
15
+ */
16
+ declare const WidgetsPreviewProvider: ({ children }: WidgetsPreviewProviderProps) => import("react").JSX.Element;
17
+ export default WidgetsPreviewProvider;
18
+ //# sourceMappingURL=WidgetsPreviewProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetsPreviewProvider.d.ts","sourceRoot":"","sources":["../../../../page/components/Widgets/WidgetsPreviewProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAC2B,KAAK,SAAS,EAC/C,MAAM,OAAO,CAAC;AAOf;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;GAIG;AACH,QAAA,MAAM,sBAAsB,GAAI,cAAc,2BAA2B,gCAyBxE,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -1,17 +1,16 @@
1
- import React, { useMemo, useState, useCallback } from 'react';
2
- import PropTypes from 'prop-types';
1
+ import { useMemo, useState, useCallback } from 'react';
3
2
  import { useWidgetPreviewEvent, dispatchWidgetPreviewEvent } from "./events";
4
3
  import { WidgetsPreviewContext } from "./WidgetsPreviewContext";
5
4
 
5
+ /**
6
+ * Props of the {@link WidgetsPreviewProvider} component.
7
+ */
8
+ import { jsx as _jsx } from "react/jsx-runtime";
6
9
  /**
7
10
  * The WidgetsPreviewProvider component is used by the Widgets component when it's rendered
8
11
  * in preview mode. It provides functionality for the Widget component that's needed when
9
12
  * the widgets are rendered in the preview iframe.
10
- * @param {Object} props The component props.
11
- * @param {React.ReactNode} props.children The child components to render.
12
- * @returns {JSX.Element}
13
13
  */
14
- import { jsx as _jsx } from "react/jsx-runtime";
15
14
  const WidgetsPreviewProvider = ({
16
15
  children
17
16
  }) => {
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Whether to consider vertical margins when calculating the overlay position.
3
+ */
4
+ export declare const CONSIDER_CONTAINER_MARGINS_ON_SCROLL_DEFAULT = false;
5
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../page/components/Widgets/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,4CAA4C,QAAQ,CAAC"}
@@ -1,2 +1,4 @@
1
- // Whether to consider vertical margins when calculating the overlay position.
1
+ /**
2
+ * Whether to consider vertical margins when calculating the overlay position.
3
+ */
2
4
  export const CONSIDER_CONTAINER_MARGINS_ON_SCROLL_DEFAULT = false;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Names of the events that are dispatched in the context of widget preview iframe communication.
3
+ */
4
+ export type WidgetPreviewEventName = 'highlight-widget' | 'widget-clicked' | 'set-active-widget-id';
5
+ /**
6
+ * Detail payload of a widget preview event.
7
+ */
8
+ export interface WidgetPreviewEventDetail {
9
+ /**
10
+ * The code of the widget related to the event.
11
+ */
12
+ widgetCode: string;
13
+ /**
14
+ * Optional payload data related to the event.
15
+ */
16
+ payload?: unknown;
17
+ }
18
+ /**
19
+ * Handler for a widget preview event.
20
+ */
21
+ export type WidgetPreviewEventHandler = (event: CustomEvent<WidgetPreviewEventDetail>) => void;
22
+ /**
23
+ * Hook to listen for widget preview events.
24
+ * These events are dispatched in the context of iFrame communication at the widget preview.
25
+ * @param eventName Name of the listened event
26
+ * @param handler A callback function to handle the event
27
+ */
28
+ export declare const useWidgetPreviewEvent: (eventName: WidgetPreviewEventName, handler: WidgetPreviewEventHandler) => void;
29
+ /**
30
+ * Dispatches widget preview related events.
31
+ * Used to trigger iFrame postMessage events to the parent window or to react on incoming
32
+ * postMessage events from the parent window.
33
+ * @param eventName Name of the event to dispatch
34
+ * @param widgetCode Code of the widget to dispatch the event for
35
+ * @param payload Optional payload to include with the event
36
+ */
37
+ export declare const dispatchWidgetPreviewEvent: (eventName: WidgetPreviewEventName, widgetCode: string, payload?: unknown) => void;
38
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../page/components/Widgets/events.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,sBAAsB,CAAC;AAEpG;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,wBAAwB,CAAC,KAAK,IAAI,CAAC;AAE/F;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAChC,WAAW,sBAAsB,EACjC,SAAS,yBAAyB,SASnC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,GACrC,WAAW,sBAAsB,EACjC,YAAY,MAAM,EAClB,UAAS,OAAc,SAUxB,CAAC"}
@@ -1,26 +1,22 @@
1
1
  import { useEffect } from 'react';
2
2
 
3
3
  /**
4
- * @typedef {"highlight-widget"|"widget-clicked"|"set-active-widget-id"} WidgetPreviewEventName
4
+ * Names of the events that are dispatched in the context of widget preview iframe communication.
5
5
  */
6
6
 
7
7
  /**
8
- * @typedef {Object} WidgetPreviewEventDetail
9
- * @property {string} widgetCode The code of the widget related to the event.
10
- * @property {any} [payload] Optional payload data related to the event.
8
+ * Detail payload of a widget preview event.
11
9
  */
12
10
 
13
11
  /**
14
- * @callback WidgetPreviewEventHandler
15
- * @param {CustomEvent<WidgetPreviewEventDetail>} event The custom event dispatched for the widget
16
- * preview.
12
+ * Handler for a widget preview event.
17
13
  */
18
14
 
19
15
  /**
20
16
  * Hook to listen for widget preview events.
21
17
  * These events are dispatched in the context of iFrame communication at the widget preview.
22
- * @param {WidgetPreviewEventName} eventName Name of the listened event
23
- * @param {WidgetPreviewEventHandler} handler A callback function to handle the event
18
+ * @param eventName Name of the listened event
19
+ * @param handler A callback function to handle the event
24
20
  */
25
21
  export const useWidgetPreviewEvent = (eventName, handler) => {
26
22
  useEffect(() => {
@@ -35,9 +31,9 @@ export const useWidgetPreviewEvent = (eventName, handler) => {
35
31
  * Dispatches widget preview related events.
36
32
  * Used to trigger iFrame postMessage events to the parent window or to react on incoming
37
33
  * postMessage events from the parent window.
38
- * @param {WidgetPreviewEventName} eventName Name of the event to dispatch
39
- * @param {string} widgetCode Code of the widget to dispatch the event for
40
- * @param {Object} [payload] Optional payload to include with the event
34
+ * @param eventName Name of the event to dispatch
35
+ * @param widgetCode Code of the widget to dispatch the event for
36
+ * @param payload Optional payload to include with the event
41
37
  */
42
38
  export const dispatchWidgetPreviewEvent = (eventName, widgetCode, payload = null) => {
43
39
  const event = new CustomEvent(`widget-preview-${eventName}`, {
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Retrieves the scroll container for the current page. Depending on the PWA mode this can be
3
+ * a scrollable article element or the window.
4
+ * @returns The scroll container element, or null if it could not be found.
5
+ */
6
+ export declare const getScrollContainer: () => HTMLElement | null;
7
+ /**
8
+ * Parameters for {@link checkScheduled}.
9
+ */
10
+ export interface ScheduledParams {
11
+ /**
12
+ * The start date of the scheduling in ISO format.
13
+ */
14
+ from?: string;
15
+ /**
16
+ * The end date of the scheduling in ISO format.
17
+ */
18
+ to?: string;
19
+ /**
20
+ * The timezone offset in minutes. If not provided, the local timezone offset will be used.
21
+ */
22
+ timezoneOffset?: number;
23
+ }
24
+ /**
25
+ * The scheduling status of a widget.
26
+ */
27
+ export interface ScheduledStatus {
28
+ /**
29
+ * Indicates if the widget is scheduled.
30
+ */
31
+ isScheduled: boolean;
32
+ /**
33
+ * Indicates if the widget is currently active within the scheduled time frame.
34
+ */
35
+ isActive: boolean;
36
+ /**
37
+ * Indicates if the scheduled time frame has expired.
38
+ */
39
+ isExpired: boolean;
40
+ }
41
+ /**
42
+ * Retrieves the scheduling status of a widget based on the provided parameters.
43
+ * @param params The parameters for the function.
44
+ * @param params.from The start date of the scheduling in ISO format.
45
+ * @param params.to The end date of the scheduling in ISO format.
46
+ * @param params.timezoneOffset The timezone offset in minutes.
47
+ * @returns An object containing the scheduling status.
48
+ */
49
+ export declare function checkScheduled({ from, to, timezoneOffset }?: ScheduledParams): ScheduledStatus;
50
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../page/components/Widgets/helpers.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAO,WAAW,GAAG,IACwC,CAAC;AAE7F;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,EAAE,IAAI,EAAE,EAAE,EAAE,cAAc,EAAE,GAAE,eAAoB,GACjD,eAAe,CAqBjB"}
@@ -4,30 +4,25 @@ import { PAGE_PREVIEW_PATTERN } from '@shopgate/engage/page/constants';
4
4
  /**
5
5
  * Retrieves the scroll container for the current page. Depending on the PWA mode this can be
6
6
  * a scrollable article element or the window.
7
- * @returns {HTMLElement|null}
7
+ * @returns The scroll container element, or null if it could not be found.
8
8
  */
9
9
  export const getScrollContainer = () => document.querySelector(`.route__${PAGE_PREVIEW_PATTERN.replace(/^\/+/, '')}`);
10
10
 
11
11
  /**
12
- * @typedef {Object} ScheduledParams
13
- * @property {string} [from] The start date of the scheduling in ISO format.
14
- * @property {string} [to] The end date of the scheduling in ISO format.
15
- * @property {number} [timezoneOffset] The timezone offset in minutes. If not provided, the local
16
- * timezone offset will be used.
12
+ * Parameters for {@link checkScheduled}.
17
13
  */
18
14
 
19
15
  /**
20
- * @typedef {Object} ScheduledStatus
21
- * @property {boolean} isScheduled Indicates if the widget is scheduled.
22
- * @property {boolean} isActive Indicates if the widget is currently active within the
23
- * scheduled time frame.
24
- * @property {boolean} isExpired Indicates if the scheduled time frame has expired.
16
+ * The scheduling status of a widget.
25
17
  */
26
18
 
27
19
  /**
28
20
  * Retrieves the scheduling status of a widget based on the provided parameters.
29
- * @param {ScheduledParams} [params] The parameters for the function.
30
- * @returns {ScheduledStatus} An object containing the scheduling status.
21
+ * @param params The parameters for the function.
22
+ * @param params.from The start date of the scheduling in ISO format.
23
+ * @param params.to The end date of the scheduling in ISO format.
24
+ * @param params.timezoneOffset The timezone offset in minutes.
25
+ * @returns An object containing the scheduling status.
31
26
  */
32
27
  export function checkScheduled({
33
28
  from,
@@ -0,0 +1,13 @@
1
+ import { type WidgetsPreviewContextType } from './WidgetsPreviewContext';
2
+ /**
3
+ * Hook to handle communication with the parent window in a page preview iframe.
4
+ * @param isActive Whether the preview communication is active.
5
+ */
6
+ export declare const usePreviewIframeCommunication: (isActive?: boolean) => void;
7
+ /**
8
+ * The useWidgetsPreview hook provides access to the context that is wrapped around the Widgets
9
+ * component when it's rendered in preview mode.
10
+ * @returns The widget preview context.
11
+ */
12
+ export declare const useWidgetsPreview: () => WidgetsPreviewContextType;
13
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../../page/components/Widgets/hooks.ts"],"names":[],"mappings":"AAcA,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,yBAAyB,CAAC;AAoBjC;;;GAGG;AACH,eAAO,MAAM,6BAA6B,GAAI,kBAAgB,SAyG7D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAO,yBAA8D,CAAC"}
@@ -10,9 +10,13 @@ import { getScrollContainer } from "./helpers";
10
10
  import { WidgetsPreviewContext } from "./WidgetsPreviewContext";
11
11
  import { dispatchWidgetPreviewEvent, useWidgetPreviewEvent } from "./events";
12
12
 
13
+ /**
14
+ * Message payload exchanged with the parent window in the page preview iframe.
15
+ */
16
+
13
17
  /**
14
18
  * Hook to handle communication with the parent window in a page preview iframe.
15
- * @param {boolean} isActive Whether the preview communication is active.
19
+ * @param isActive Whether the preview communication is active.
16
20
  */
17
21
  export const usePreviewIframeCommunication = (isActive = false) => {
18
22
  const dispatch = useDispatch();
@@ -37,12 +41,15 @@ export const usePreviewIframeCommunication = (isActive = false) => {
37
41
  dispatch(receivePageConfigV2({
38
42
  type: 'cms',
39
43
  slug: PAGE_PREVIEW_SLUG,
40
- data: data.payload
44
+ data: data.payload ?? {}
41
45
  }));
42
46
  } else if (data.type === 'scrollToWidget' && data.payload?.widgetCode) {
43
47
  // Parent window requested to scroll to a specific widget.
48
+ const {
49
+ widgetCode
50
+ } = data.payload;
44
51
  const scrollContainer = getScrollContainer();
45
- const target = scrollContainer.querySelector(`#widget-code-${data.payload.widgetCode}`);
52
+ const target = scrollContainer?.querySelector(`#widget-code-${widgetCode}`);
46
53
  if (scrollContainer && target) {
47
54
  let marginTop = 0;
48
55
  if (considerVerticalMargins) {
@@ -56,13 +63,13 @@ export const usePreviewIframeCommunication = (isActive = false) => {
56
63
  const actualScrollTop = Math.min(scrollOffset, maxScrollTop);
57
64
 
58
65
  // Register the target element as the active widget.
59
- dispatchWidgetPreviewEvent('set-active-widget-id', data.payload.widgetCode);
66
+ dispatchWidgetPreviewEvent('set-active-widget-id', widgetCode);
60
67
 
61
68
  /**
62
69
  * Callback to highlight the widget after scrolling.
63
70
  */
64
71
  const highlightWidget = () => {
65
- dispatchWidgetPreviewEvent('highlight-widget', data.payload.widgetCode);
72
+ dispatchWidgetPreviewEvent('highlight-widget', widgetCode);
66
73
  };
67
74
 
68
75
  // Add listener to onScrollEnd if available, otherwise use scroll event.
@@ -117,14 +124,9 @@ export const usePreviewIframeCommunication = (isActive = false) => {
117
124
  });
118
125
  };
119
126
 
120
- /**
121
- * @typedef {import('./WidgetsPreviewContext.js').WidgetsPreviewContextType}
122
- * WidgetsPreviewContextType
123
- */
124
-
125
127
  /**
126
128
  * The useWidgetsPreview hook provides access to the context that is wrapped around the Widgets
127
129
  * component when it's rendered in preview mode.
128
- * @returns {WidgetsPreviewContextType} The widget context.
130
+ * @returns The widget preview context.
129
131
  */
130
132
  export const useWidgetsPreview = () => useContext(WidgetsPreviewContext);
@@ -0,0 +1,3 @@
1
+ export { default } from './Widgets';
2
+ export { WidgetContext, type WidgetContextType } from './WidgetContext';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../page/components/Widgets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}