@shopgate/engage 7.32.0-beta.4 → 7.32.0-beta.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.
Files changed (95) hide show
  1. package/package.json +7 -7
  2. package/page/components/NotFound.d.ts +7 -0
  3. package/page/components/NotFound.d.ts.map +1 -0
  4. package/page/components/NotFound.js +1 -2
  5. package/page/components/ResponsiveWidgetImage/ResponsiveWidgetImage.d.ts +52 -0
  6. package/page/components/ResponsiveWidgetImage/ResponsiveWidgetImage.d.ts.map +1 -0
  7. package/page/components/ResponsiveWidgetImage/index.d.ts +2 -0
  8. package/page/components/ResponsiveWidgetImage/index.d.ts.map +1 -0
  9. package/page/components/WidgetRichText/WidgetRichText.d.ts +25 -0
  10. package/page/components/WidgetRichText/WidgetRichText.d.ts.map +1 -0
  11. package/page/components/WidgetRichText/index.d.ts +2 -0
  12. package/page/components/WidgetRichText/index.d.ts.map +1 -0
  13. package/page/components/WidgetVideo/WidgetVideo.d.ts +43 -0
  14. package/page/components/WidgetVideo/WidgetVideo.d.ts.map +1 -0
  15. package/page/components/WidgetVideo/WidgetVideo.js +33 -39
  16. package/page/components/WidgetVideo/index.d.ts +2 -0
  17. package/page/components/WidgetVideo/index.d.ts.map +1 -0
  18. package/page/components/Widgets/Overlay.d.ts +17 -0
  19. package/page/components/Widgets/Overlay.d.ts.map +1 -0
  20. package/page/components/Widgets/Overlay.js +24 -38
  21. package/page/components/Widgets/Tooltip.d.ts +20 -0
  22. package/page/components/Widgets/Tooltip.d.ts.map +1 -0
  23. package/page/components/Widgets/Tooltip.js +6 -10
  24. package/page/components/Widgets/Widget.d.ts +32 -0
  25. package/page/components/Widgets/Widget.d.ts.map +1 -0
  26. package/page/components/Widgets/Widget.js +7 -18
  27. package/page/components/Widgets/WidgetContext.d.ts +32 -38
  28. package/page/components/Widgets/WidgetContext.d.ts.map +1 -0
  29. package/page/components/Widgets/WidgetContext.js +2 -8
  30. package/page/components/Widgets/WidgetProvider.d.ts +25 -0
  31. package/page/components/Widgets/WidgetProvider.d.ts.map +1 -0
  32. package/page/components/Widgets/WidgetProvider.js +5 -12
  33. package/page/components/Widgets/Widgets.d.ts +16 -0
  34. package/page/components/Widgets/Widgets.d.ts.map +1 -0
  35. package/page/components/Widgets/Widgets.js +5 -12
  36. package/page/components/Widgets/WidgetsPreviewContext.d.ts +21 -0
  37. package/page/components/Widgets/WidgetsPreviewContext.d.ts.map +1 -0
  38. package/page/components/Widgets/WidgetsPreviewContext.js +5 -7
  39. package/page/components/Widgets/WidgetsPreviewProvider.d.ts +18 -0
  40. package/page/components/Widgets/WidgetsPreviewProvider.d.ts.map +1 -0
  41. package/page/components/Widgets/WidgetsPreviewProvider.js +5 -6
  42. package/page/components/Widgets/constants.d.ts +5 -0
  43. package/page/components/Widgets/constants.d.ts.map +1 -0
  44. package/page/components/Widgets/constants.js +3 -1
  45. package/page/components/Widgets/events.d.ts +38 -0
  46. package/page/components/Widgets/events.d.ts.map +1 -0
  47. package/page/components/Widgets/events.js +8 -12
  48. package/page/components/Widgets/helpers.d.ts +50 -0
  49. package/page/components/Widgets/helpers.d.ts.map +1 -0
  50. package/page/components/Widgets/helpers.js +8 -13
  51. package/page/components/Widgets/hooks.d.ts +13 -0
  52. package/page/components/Widgets/hooks.d.ts.map +1 -0
  53. package/page/components/Widgets/hooks.js +13 -11
  54. package/page/components/Widgets/index.d.ts +3 -0
  55. package/page/components/Widgets/index.d.ts.map +1 -0
  56. package/page/components/Widgets/types.d.ts +111 -113
  57. package/page/components/Widgets/types.d.ts.map +1 -0
  58. package/page/components/Widgets/types.js +1 -0
  59. package/page/components/index.d.ts +5 -0
  60. package/page/components/index.d.ts.map +1 -0
  61. package/page/constants/actionTypes.d.ts +4 -0
  62. package/page/constants/actionTypes.d.ts.map +1 -0
  63. package/page/constants/index.d.ts +25 -0
  64. package/page/constants/index.d.ts.map +1 -0
  65. package/page/helpers/index.d.ts +67 -62
  66. package/page/helpers/index.d.ts.map +1 -0
  67. package/page/helpers/index.js +24 -25
  68. package/page/hooks/index.d.ts +54 -53
  69. package/page/hooks/index.d.ts.map +1 -0
  70. package/page/hooks/index.js +20 -15
  71. package/page/selectors/index.d.ts +32 -0
  72. package/page/selectors/index.d.ts.map +1 -0
  73. package/page/widgets/Video/Video.d.ts +6 -0
  74. package/page/widgets/Video/Video.d.ts.map +1 -0
  75. package/page/widgets/Video/Video.js +0 -2
  76. package/page/widgets/Video/hooks.d.ts +53 -0
  77. package/page/widgets/Video/hooks.d.ts.map +1 -0
  78. package/page/widgets/Video/hooks.js +4 -12
  79. package/page/widgets/Video/index.d.ts +2 -0
  80. package/page/widgets/Video/index.d.ts.map +1 -0
  81. package/product/components/ProductGrid/constants.d.ts +2 -0
  82. package/product/components/ProductGrid/constants.d.ts.map +1 -0
  83. package/product/components/ProductGrid/constants.js +1 -0
  84. package/product/components/ProductGrid/hooks.d.ts +18 -0
  85. package/product/components/ProductGrid/hooks.d.ts.map +1 -0
  86. package/product/components/ProductGrid/hooks.js +49 -0
  87. package/product/components/ProductGrid/index.js +3 -6
  88. package/product/components/ProductGrid/spec.js +3 -0
  89. package/settings/reducers/appSettings.d.ts.map +1 -1
  90. package/settings/reducers/appSettings.js +8 -0
  91. package/settings/selectors/appSettings.d.ts +8 -0
  92. package/settings/selectors/appSettings.d.ts.map +1 -1
  93. package/settings/selectors/appSettings.js +6 -1
  94. package/settings/types/appSettings.d.ts +21 -0
  95. package/settings/types/appSettings.d.ts.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/engage",
3
- "version": "7.32.0-beta.4",
3
+ "version": "7.32.0-beta.5",
4
4
  "description": "Shopgate's ENGAGE library.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -18,12 +18,12 @@
18
18
  "dependencies": {
19
19
  "@emotion/react": "^11.14.0",
20
20
  "@shopgate/native-modules": "1.0.0-beta.32",
21
- "@shopgate/pwa-common": "7.32.0-beta.4",
22
- "@shopgate/pwa-common-commerce": "7.32.0-beta.4",
23
- "@shopgate/pwa-core": "7.32.0-beta.4",
24
- "@shopgate/pwa-ui-ios": "7.32.0-beta.4",
25
- "@shopgate/pwa-ui-material": "7.32.0-beta.4",
26
- "@shopgate/pwa-ui-shared": "7.32.0-beta.4",
21
+ "@shopgate/pwa-common": "7.32.0-beta.5",
22
+ "@shopgate/pwa-common-commerce": "7.32.0-beta.5",
23
+ "@shopgate/pwa-core": "7.32.0-beta.5",
24
+ "@shopgate/pwa-ui-ios": "7.32.0-beta.5",
25
+ "@shopgate/pwa-ui-material": "7.32.0-beta.5",
26
+ "@shopgate/pwa-ui-shared": "7.32.0-beta.5",
27
27
  "@stripe/react-stripe-js": "^1.16.5",
28
28
  "@stripe/stripe-js": "^1.44.1",
29
29
  "@virtuous/conductor": "~2.5.0",
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The NotFoundPage component renders a "Page Not Found" view
3
+ * with options to navigate back or to the home page.
4
+ */
5
+ declare const NotFound: () => import("react").JSX.Element;
6
+ export default NotFound;
7
+ //# sourceMappingURL=NotFound.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotFound.d.ts","sourceRoot":"","sources":["../../../page/components/NotFound.tsx"],"names":[],"mappings":"AA+BA;;;GAGG;AACH,QAAA,MAAM,QAAQ,mCA2Bb,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,4 +1,4 @@
1
- import React, { useCallback } from 'react';
1
+ import { useCallback } from 'react';
2
2
  import { useDispatch } from 'react-redux';
3
3
  import RippleButton from '@shopgate/pwa-ui-shared/RippleButton';
4
4
  import { I18n, Typography } from '@shopgate/engage/components';
@@ -32,7 +32,6 @@ const useStyles = makeStyles()(theme => ({
32
32
  /**
33
33
  * The NotFoundPage component renders a "Page Not Found" view
34
34
  * with options to navigate back or to the home page.
35
- * @returns {JSX.Element}
36
35
  */
37
36
  const NotFound = () => {
38
37
  const {
@@ -0,0 +1,52 @@
1
+ export default Protector;
2
+ export type OnImageRatioChange = (ratio: string) => any;
3
+ export type CustomResponsiveImageProps = {
4
+ /**
5
+ * Whether to enable the parallax effect.
6
+ */
7
+ enableParallax?: boolean | undefined;
8
+ /**
9
+ * The border radius to apply to the image.
10
+ */
11
+ borderRadius?: number | undefined;
12
+ /**
13
+ * The breakpoint from which on a higher resolution image should
14
+ * be loaded.
15
+ */
16
+ breakpoint?: import("../../../styles/theme").Breakpoint | undefined;
17
+ /**
18
+ * Whether the image is used as a banner (full width and height of
19
+ * its container).
20
+ */
21
+ isBanner?: boolean | undefined;
22
+ /**
23
+ * Called when the aspect ratio of the image
24
+ * changes.
25
+ */
26
+ onImageRatioChange?: OnImageRatioChange | undefined;
27
+ };
28
+ export type Theme = import("@shopgate/engage/styles").Theme;
29
+ export type Breakpoint = Theme["breakpoints"]["keys"][0];
30
+ export type ImgProps = React.ImgHTMLAttributes<HTMLImageElement>;
31
+ export type ResponsiveImageProps = CustomResponsiveImageProps & ImgProps;
32
+ /**
33
+ * The ResponsiveWidgetImage component renders an image that adapts to different screen sizes.
34
+ * It renders a image with higher resolution on larger screens
35
+ * It can apply a parallax effect when scrolling.
36
+ *
37
+ * @param {ResponsiveImageProps} props The component props.
38
+ * @returns {JSX.Element}
39
+ */
40
+ declare function Protector({ src, ...rest }: ResponsiveImageProps): JSX.Element;
41
+ declare namespace Protector {
42
+ namespace propTypes {
43
+ let src: PropTypes.Requireable<string>;
44
+ }
45
+ namespace defaultProps {
46
+ let src_1: null;
47
+ export { src_1 as src };
48
+ }
49
+ }
50
+ import React from 'react';
51
+ import PropTypes from 'prop-types';
52
+ //# sourceMappingURL=ResponsiveWidgetImage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResponsiveWidgetImage.d.ts","sourceRoot":"","sources":["../../../../page/components/ResponsiveWidgetImage/ResponsiveWidgetImage.jsx"],"names":[],"mappings":";yCASW,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;oBAeH,OAAO,yBAAyB,EAAE,KAAK;yBACvC,KAAK,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;uBAC/B,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC;mCACzC,0BAA0B,GAAG,QAAQ;AAgKnD;;;;;;;GAOG;AACH,6CAHW,oBAAoB,GAClB,GAAG,CAAC,OAAO,CASvB;;;;;;;;;;kBA1MmD,OAAO;sBACrC,YAAY"}
@@ -0,0 +1,2 @@
1
+ export { default } from "./ResponsiveWidgetImage";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../page/components/ResponsiveWidgetImage/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ export default WidgetRichText;
2
+ /**
3
+ * @param {Object} props The component props.
4
+ * @param {string} props.content The rich text content.
5
+ * @param {string} [props.className] An optional class name.
6
+ * @returns {JSX.Element}
7
+ */
8
+ declare function WidgetRichText({ content, className, }: {
9
+ content: string;
10
+ className?: string | undefined;
11
+ }): JSX.Element;
12
+ declare namespace WidgetRichText {
13
+ namespace propTypes {
14
+ let className: PropTypes.Requireable<string>;
15
+ let content: PropTypes.Requireable<string>;
16
+ }
17
+ namespace defaultProps {
18
+ let content_1: string;
19
+ export { content_1 as content };
20
+ let className_1: null;
21
+ export { className_1 as className };
22
+ }
23
+ }
24
+ import PropTypes from 'prop-types';
25
+ //# sourceMappingURL=WidgetRichText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetRichText.d.ts","sourceRoot":"","sources":["../../../../page/components/WidgetRichText/WidgetRichText.jsx"],"names":[],"mappings":";AA2DA;;;;;GAKG;AACH,yDAJG;IAAsB,OAAO,EAArB,MAAM;IACS,SAAS;CAChC,GAAU,GAAG,CAAC,OAAO,CAmBvB;;;;;;;;;;;;;sBAjFqB,YAAY"}
@@ -0,0 +1,2 @@
1
+ export { default } from "./WidgetRichText";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../page/components/WidgetRichText/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Props of the {@link WidgetVideo} component.
3
+ */
4
+ export interface WidgetVideoProps {
5
+ /**
6
+ * Whether the video is used in a banner.
7
+ */
8
+ isBanner?: boolean;
9
+ /**
10
+ * The video URL.
11
+ */
12
+ url?: string | null;
13
+ /**
14
+ * Whether the video is muted.
15
+ */
16
+ muted?: boolean;
17
+ /**
18
+ * Whether the video is looping.
19
+ */
20
+ loop?: boolean;
21
+ /**
22
+ * Whether the video controls are shown.
23
+ */
24
+ controls?: boolean;
25
+ /**
26
+ * Whether the video should autoplay.
27
+ */
28
+ autoplay?: boolean;
29
+ /**
30
+ * The border radius value.
31
+ */
32
+ borderRadius?: number;
33
+ /**
34
+ * The link URL.
35
+ */
36
+ link?: string | null;
37
+ }
38
+ /**
39
+ * The WidgetVideo component is used to display a video in a widget.
40
+ */
41
+ declare const WidgetVideo: ({ isBanner, url, muted, loop, controls, autoplay, borderRadius, link, }: WidgetVideoProps) => import("react").JSX.Element | null;
42
+ export default WidgetVideo;
43
+ //# sourceMappingURL=WidgetVideo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetVideo.d.ts","sourceRoot":"","sources":["../../../../page/components/WidgetVideo/WidgetVideo.tsx"],"names":[],"mappings":"AAsDA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;GAEG;AACH,QAAA,MAAM,WAAW,GAAI,yEASlB,gBAAgB,uCAsFlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -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;