@shopgate/engage 7.32.0-beta.3 → 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 (166) hide show
  1. package/admin-preview/components/FrontendSettingsPreviewBridge/FrontendSettingsPreviewBridge.d.ts +2 -1
  2. package/admin-preview/components/FrontendSettingsPreviewBridge/FrontendSettingsPreviewBridge.d.ts.map +1 -1
  3. package/admin-preview/components/FrontendSettingsPreviewBridge/FrontendSettingsPreviewBridge.js +23 -1
  4. package/admin-preview/components/FrontendSettingsPreviewBridge/helpers.d.ts +7 -1
  5. package/admin-preview/components/FrontendSettingsPreviewBridge/helpers.d.ts.map +1 -1
  6. package/admin-preview/components/FrontendSettingsPreviewBridge/helpers.js +14 -2
  7. package/admin-preview/components/FrontendSettingsPreviewBridge/types.d.ts +6 -0
  8. package/admin-preview/components/FrontendSettingsPreviewBridge/types.d.ts.map +1 -1
  9. package/components/Badge/Badge.d.ts +30 -0
  10. package/components/Badge/Badge.d.ts.map +1 -0
  11. package/components/Badge/Badge.js +48 -0
  12. package/components/Badge/index.d.ts +3 -0
  13. package/components/Badge/index.d.ts.map +1 -0
  14. package/components/Badge/index.js +1 -0
  15. package/components/Badge/spec.d.ts +2 -0
  16. package/components/Badge/spec.d.ts.map +1 -0
  17. package/components/Badge/spec.js +75 -0
  18. package/components/View/components/Content/index.d.ts.map +1 -1
  19. package/components/View/components/Content/index.js +4 -1
  20. package/components/index.d.ts +1 -0
  21. package/components/index.d.ts.map +1 -1
  22. package/components/index.js +2 -1
  23. package/core/hooks/useLocalStorage.d.ts +8 -0
  24. package/core/hooks/useLocalStorage.d.ts.map +1 -1
  25. package/core/hooks/useLocalStorage.js +22 -15
  26. package/core/initialization/fetchSettings.d.ts +12 -0
  27. package/core/initialization/fetchSettings.d.ts.map +1 -0
  28. package/core/initialization/fetchSettings.js +134 -0
  29. package/core/initialization/index.d.ts +33 -2
  30. package/core/initialization/index.d.ts.map +1 -1
  31. package/core/initialization/index.js +25 -103
  32. package/package.json +9 -9
  33. package/page/components/NotFound.d.ts +7 -0
  34. package/page/components/NotFound.d.ts.map +1 -0
  35. package/page/components/NotFound.js +1 -2
  36. package/page/components/ResponsiveWidgetImage/ResponsiveWidgetImage.d.ts +52 -0
  37. package/page/components/ResponsiveWidgetImage/ResponsiveWidgetImage.d.ts.map +1 -0
  38. package/page/components/ResponsiveWidgetImage/index.d.ts +2 -0
  39. package/page/components/ResponsiveWidgetImage/index.d.ts.map +1 -0
  40. package/page/components/WidgetRichText/WidgetRichText.d.ts +25 -0
  41. package/page/components/WidgetRichText/WidgetRichText.d.ts.map +1 -0
  42. package/page/components/WidgetRichText/index.d.ts +2 -0
  43. package/page/components/WidgetRichText/index.d.ts.map +1 -0
  44. package/page/components/WidgetVideo/WidgetVideo.d.ts +43 -0
  45. package/page/components/WidgetVideo/WidgetVideo.d.ts.map +1 -0
  46. package/page/components/WidgetVideo/WidgetVideo.js +33 -39
  47. package/page/components/WidgetVideo/index.d.ts +2 -0
  48. package/page/components/WidgetVideo/index.d.ts.map +1 -0
  49. package/page/components/Widgets/Overlay.d.ts +17 -0
  50. package/page/components/Widgets/Overlay.d.ts.map +1 -0
  51. package/page/components/Widgets/Overlay.js +24 -38
  52. package/page/components/Widgets/Tooltip.d.ts +20 -0
  53. package/page/components/Widgets/Tooltip.d.ts.map +1 -0
  54. package/page/components/Widgets/Tooltip.js +6 -10
  55. package/page/components/Widgets/Widget.d.ts +32 -0
  56. package/page/components/Widgets/Widget.d.ts.map +1 -0
  57. package/page/components/Widgets/Widget.js +7 -18
  58. package/page/components/Widgets/WidgetContext.d.ts +32 -38
  59. package/page/components/Widgets/WidgetContext.d.ts.map +1 -0
  60. package/page/components/Widgets/WidgetContext.js +2 -8
  61. package/page/components/Widgets/WidgetProvider.d.ts +25 -0
  62. package/page/components/Widgets/WidgetProvider.d.ts.map +1 -0
  63. package/page/components/Widgets/WidgetProvider.js +5 -12
  64. package/page/components/Widgets/Widgets.d.ts +16 -0
  65. package/page/components/Widgets/Widgets.d.ts.map +1 -0
  66. package/page/components/Widgets/Widgets.js +5 -12
  67. package/page/components/Widgets/WidgetsPreviewContext.d.ts +21 -0
  68. package/page/components/Widgets/WidgetsPreviewContext.d.ts.map +1 -0
  69. package/page/components/Widgets/WidgetsPreviewContext.js +5 -7
  70. package/page/components/Widgets/WidgetsPreviewProvider.d.ts +18 -0
  71. package/page/components/Widgets/WidgetsPreviewProvider.d.ts.map +1 -0
  72. package/page/components/Widgets/WidgetsPreviewProvider.js +5 -6
  73. package/page/components/Widgets/constants.d.ts +5 -0
  74. package/page/components/Widgets/constants.d.ts.map +1 -0
  75. package/page/components/Widgets/constants.js +3 -1
  76. package/page/components/Widgets/events.d.ts +38 -0
  77. package/page/components/Widgets/events.d.ts.map +1 -0
  78. package/page/components/Widgets/events.js +8 -12
  79. package/page/components/Widgets/helpers.d.ts +50 -0
  80. package/page/components/Widgets/helpers.d.ts.map +1 -0
  81. package/page/components/Widgets/helpers.js +8 -13
  82. package/page/components/Widgets/hooks.d.ts +13 -0
  83. package/page/components/Widgets/hooks.d.ts.map +1 -0
  84. package/page/components/Widgets/hooks.js +13 -11
  85. package/page/components/Widgets/index.d.ts +3 -0
  86. package/page/components/Widgets/index.d.ts.map +1 -0
  87. package/page/components/Widgets/types.d.ts +111 -113
  88. package/page/components/Widgets/types.d.ts.map +1 -0
  89. package/page/components/Widgets/types.js +1 -0
  90. package/page/components/index.d.ts +5 -0
  91. package/page/components/index.d.ts.map +1 -0
  92. package/page/constants/actionTypes.d.ts +4 -0
  93. package/page/constants/actionTypes.d.ts.map +1 -0
  94. package/page/constants/index.d.ts +25 -0
  95. package/page/constants/index.d.ts.map +1 -0
  96. package/page/helpers/index.d.ts +67 -62
  97. package/page/helpers/index.d.ts.map +1 -0
  98. package/page/helpers/index.js +24 -25
  99. package/page/hooks/index.d.ts +54 -53
  100. package/page/hooks/index.d.ts.map +1 -0
  101. package/page/hooks/index.js +20 -15
  102. package/page/selectors/index.d.ts +32 -0
  103. package/page/selectors/index.d.ts.map +1 -0
  104. package/page/widgets/Video/Video.d.ts +6 -0
  105. package/page/widgets/Video/Video.d.ts.map +1 -0
  106. package/page/widgets/Video/Video.js +0 -2
  107. package/page/widgets/Video/hooks.d.ts +53 -0
  108. package/page/widgets/Video/hooks.d.ts.map +1 -0
  109. package/page/widgets/Video/hooks.js +4 -12
  110. package/page/widgets/Video/index.d.ts +2 -0
  111. package/page/widgets/Video/index.d.ts.map +1 -0
  112. package/product/components/Description/index.js +0 -2
  113. package/product/components/ProductCard/index.js +1 -0
  114. package/product/components/ProductGrid/components/Item/components/ItemDetails/index.js +1 -1
  115. package/product/components/ProductGrid/components/Item/components/ItemImage/index.js +10 -0
  116. package/product/components/ProductGrid/components/Item/components/ItemName/index.js +1 -0
  117. package/product/components/ProductGrid/components/Item/index.js +0 -1
  118. package/product/components/ProductGrid/components/Layout/index.js +17 -3
  119. package/product/components/ProductGrid/constants.d.ts +2 -0
  120. package/product/components/ProductGrid/constants.d.ts.map +1 -0
  121. package/product/components/ProductGrid/constants.js +1 -0
  122. package/product/components/ProductGrid/hooks.d.ts +18 -0
  123. package/product/components/ProductGrid/hooks.d.ts.map +1 -0
  124. package/product/components/ProductGrid/hooks.js +49 -0
  125. package/product/components/ProductGrid/index.js +3 -6
  126. package/product/components/ProductGrid/spec.js +3 -0
  127. package/product/components/ProductList/components/Layout/index.js +8 -20
  128. package/settings/reducers/appSettings.d.ts.map +1 -1
  129. package/settings/reducers/appSettings.js +8 -0
  130. package/settings/selectors/appSettings.d.ts +8 -0
  131. package/settings/selectors/appSettings.d.ts.map +1 -1
  132. package/settings/selectors/appSettings.js +6 -1
  133. package/settings/types/appSettings.d.ts +21 -0
  134. package/settings/types/appSettings.d.ts.map +1 -1
  135. package/styles/helpers/index.d.ts +1 -0
  136. package/styles/helpers/index.js +1 -0
  137. package/styles/helpers/loadThemeCss.d.ts +14 -0
  138. package/styles/helpers/loadThemeCss.d.ts.map +1 -0
  139. package/styles/helpers/loadThemeCss.js +112 -0
  140. package/styles/index.d.ts +1 -1
  141. package/styles/index.d.ts.map +1 -1
  142. package/styles/reset/root.js +1 -1
  143. package/styles/theme/createDefaultThemeOptions/index.d.ts.map +1 -1
  144. package/styles/theme/createDefaultThemeOptions/index.js +12 -1
  145. package/styles/theme/createTheme/createComponents.types.d.ts +22 -0
  146. package/styles/theme/createTheme/createComponents.types.d.ts.map +1 -1
  147. package/styles/theme/createTheme/createComponents.types.js +23 -1
  148. package/styles/theme/createTheme/createCssVarsForColorSchemeThemes.d.ts.map +1 -1
  149. package/styles/theme/createTheme/createCssVarsForColorSchemeThemes.js +4 -1
  150. package/styles/theme/createTheme/index.d.ts +1 -0
  151. package/styles/theme/createTheme/index.d.ts.map +1 -1
  152. package/styles/theme/createTheme/index.js +2 -0
  153. package/styles/theme/createTheme/types.d.ts +2 -2
  154. package/styles/theme/createTheme/types.d.ts.map +1 -1
  155. package/styles/theme/createTheme/types.js +2 -3
  156. package/styles/theme/hooks/useColorScheme.d.ts +4 -3
  157. package/styles/theme/hooks/useColorScheme.d.ts.map +1 -1
  158. package/styles/theme/hooks/useColorScheme.js +4 -3
  159. package/styles/theme/index.d.ts +1 -1
  160. package/styles/theme/index.d.ts.map +1 -1
  161. package/styles/theme/providers/ColorSchemeContext.d.ts +19 -0
  162. package/styles/theme/providers/ColorSchemeContext.d.ts.map +1 -0
  163. package/styles/theme/providers/ColorSchemeContext.js +6 -0
  164. package/styles/theme/providers/ThemeProvider.d.ts +2 -12
  165. package/styles/theme/providers/ThemeProvider.d.ts.map +1 -1
  166. package/styles/theme/providers/ThemeProvider.js +32 -8
@@ -1,84 +1,89 @@
1
- export type ProductsWidgetInputConfig = {
2
- /**
3
- * A search term to filter products by
4
- */
5
- searchTerm: string;
6
- /**
7
- * A brand to filter products by
8
- */
9
- brand: string;
10
- /**
11
- * A category to filter products by
12
- */
13
- category: string;
14
- /**
15
- * Array of product item numbers (selected via manual input)
16
- */
17
- manualItemNumbers: string[];
18
- /**
19
- * Array of product item numbers (selected via product selector)
20
- */
21
- selectorItemNumbers: string[];
1
+ /**
2
+ * Configuration of the "Products" widget input.
3
+ */
4
+ export interface ProductsWidgetInputConfig {
5
+ /**
6
+ * A search term to filter products by.
7
+ */
8
+ searchTerm: string;
9
+ /**
10
+ * A brand to filter products by.
11
+ */
12
+ brand: string;
13
+ /**
14
+ * A category to filter products by.
15
+ */
16
+ category: string;
17
+ /**
18
+ * Array of product item numbers (selected via manual input).
19
+ */
20
+ manualItemNumbers: string[];
21
+ /**
22
+ * Array of product item numbers (selected via product selector).
23
+ */
24
+ selectorItemNumbers: string[];
22
25
  }
23
-
24
- export type GetProductSearchParamsFromProductsInputConfigReturnValue = {
25
- /**
26
- * The type of product search to perform.
27
- */
28
- productsSearchType: 'searchTerm' | 'brand' | 'category' | 'productIds';
29
- /**
30
- * The value to use for the product search. Can be a string or an array of strings (for product IDs).
31
- */
32
- productsSearchValue: string | string[];
26
+ /**
27
+ * Return value of {@link getProductSearchParamsFromProductsInputConfig}.
28
+ */
29
+ export interface GetProductSearchParamsFromProductsInputConfigReturnValue {
30
+ /**
31
+ * The type of product search to perform.
32
+ */
33
+ productsSearchType: 'searchTerm' | 'brand' | 'category' | 'productIds';
34
+ /**
35
+ * The value to use for the product search. Can be a string or an array of strings
36
+ * (for product IDs).
37
+ */
38
+ productsSearchValue: string | string[];
33
39
  }
34
-
35
40
  /**
36
41
  * Helper to extract relevant search parameters from the widget configuration of the "Products"
37
42
  * input.
38
- *
39
43
  * The return value can be used to e.g. parametrize the useWidgetProducts hook.
44
+ * @param products Config object of the "Products" input.
45
+ * @returns The extracted product search parameters.
40
46
  */
41
- export declare function getProductSearchParamsFromProductsInputConfig(
42
- products: ProductsWidgetInputConfig
43
- ): GetProductSearchParamsFromProductsInputConfigReturnValue;
44
-
47
+ export declare const getProductSearchParamsFromProductsInputConfig: (products?: Partial<ProductsWidgetInputConfig>) => GetProductSearchParamsFromProductsInputConfigReturnValue;
45
48
  /**
46
- * Helper to parse the image URL to return a high resolution version if required.
49
+ * Parses the image URL to return a high resolution version if required.
50
+ * @param url The original image URL.
51
+ * @param useHighRes Whether to return a high resolution version.
52
+ * @returns The parsed image URL.
47
53
  */
48
- export declare function parseImageUrl(
49
- url: string,
50
- useHighRes?: boolean
51
- ): string;
52
-
53
- type BorderRadiusParams = {
54
- /**
55
- * The border radius option
56
- */
57
- borderRadius: 'default' | 'none' |'rounded' | 'custom';
58
- /**
59
- * The custom border radius value
60
- */
61
- customBorderRadius?: number
62
- };
63
-
54
+ export declare const parseImageUrl: (url: string, useHighRes?: boolean) => string;
55
+ /**
56
+ * Parameters for {@link resolveBorderRadiusFromWidgetConfig}.
57
+ */
58
+ interface BorderRadiusParams {
59
+ /**
60
+ * The border radius option.
61
+ */
62
+ borderRadius: 'default' | 'none' | 'rounded' | 'custom';
63
+ /**
64
+ * The custom border radius value.
65
+ */
66
+ borderRadiusCustom?: number;
67
+ }
64
68
  /**
65
- * Retrieves the border radius based on the widget config
66
- * @returns The resolved border radius
69
+ * Retrieves the border radius based on the widget config.
70
+ * @param params The helper parameters.
71
+ * @param params.borderRadius The border radius option.
72
+ * @param params.borderRadiusCustom The custom border radius value.
73
+ * @returns The resolved border radius.
67
74
  */
68
- export declare function resolveBorderRadiusFromWidgetConfig(
69
- params: BorderRadiusParams
70
- )
71
-
75
+ export declare const resolveBorderRadiusFromWidgetConfig: ({ borderRadius, borderRadiusCustom }: BorderRadiusParams) => number;
72
76
  /**
73
77
  * Validator factory for regular expressions.
74
78
  * @param regex The regular expression to match.
75
79
  * @returns A function that validates if a value matches the regex.
76
80
  */
77
- export declare function matchesRegex(regex: RegExp): (val: string) => boolean;
78
-
81
+ export declare const matchesRegex: (regex: RegExp) => (val: string) => boolean;
79
82
  /**
80
83
  * Validates if a given string is a valid HTTPS URL.
81
84
  * @param val The string to validate.
82
85
  * @returns True if the string is a valid HTTPS URL, false otherwise.
83
86
  */
84
87
  export declare const isHttpsUrl: (val: string) => boolean;
88
+ export {};
89
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../page/helpers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B;;OAEG;IACH,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,wDAAwD;IACvE;;OAEG;IACH,kBAAkB,EAAE,YAAY,GAAG,OAAO,GAAG,UAAU,GAAG,YAAY,CAAC;IACvE;;;OAGG;IACH,mBAAmB,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACxC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,6CAA6C,GACxD,WAAU,OAAO,CAAC,yBAAyB,CAAM,KAChD,wDAyBF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,EAAE,aAAa,OAAO,KAAG,MAQjE,CAAC;AAEF;;GAEG;AACH,UAAU,kBAAkB;IAC1B;;OAEG;IACH,YAAY,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;IACxD;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mCAAmC,GAC9C,sCAAsC,kBAAkB,KACvD,MAKF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,MAAM,KAAK,MAAM,KAAG,OAAkC,CAAC;AAEjG;;;;GAIG;AACH,eAAO,MAAM,UAAU,QAP8B,MAAM,KAAG,OAOgB,CAAC"}
@@ -1,21 +1,17 @@
1
- /* eslint-disable max-len */
2
-
3
1
  /**
4
- * @typedef {import('./').ProductsWidgetInputConfig} ProductsWidgetInputConfig
2
+ * Configuration of the "Products" widget input.
5
3
  */
6
4
 
7
5
  /**
8
- * @typedef {import('./').GetProductSearchParamsFromProductsInputConfigReturnValue} GetProductSearchParamsFromProductsInputConfigReturnValue
6
+ * Return value of {@link getProductSearchParamsFromProductsInputConfig}.
9
7
  */
10
8
 
11
- /* eslint-enable max-len */
12
-
13
9
  /**
14
10
  * Helper to extract relevant search parameters from the widget configuration of the "Products"
15
11
  * input.
16
12
  * The return value can be used to e.g. parametrize the useWidgetProducts hook.
17
- * @param {ProductsWidgetInputConfig} products Config object of the "Products" input.
18
- * @returns {GetProductSearchParamsFromProductsInputConfigReturnValue}
13
+ * @param products Config object of the "Products" input.
14
+ * @returns The extracted product search parameters.
19
15
  */
20
16
  export const getProductSearchParamsFromProductsInputConfig = (products = {}) => {
21
17
  const {
@@ -28,8 +24,7 @@ export const getProductSearchParamsFromProductsInputConfig = (products = {}) =>
28
24
  const mapping = [['brand', brand], ['category', category], ['searchTerm', searchTerm], ['productIds', manualItemNumbers], ['productIds', selectorItemNumbers]];
29
25
 
30
26
  // Pick the first non-undefined value
31
- // eslint-disable-next-line prefer-const
32
- let [productsSearchType, productsSearchValue] = mapping.find(([, value]) => value !== undefined) || ['searchTerm', searchTerm];
27
+ const [productsSearchType, productsSearchValue] = mapping.find(([, value]) => value !== undefined) || ['searchTerm', searchTerm];
33
28
  return {
34
29
  productsSearchType,
35
30
  productsSearchValue
@@ -38,9 +33,9 @@ export const getProductSearchParamsFromProductsInputConfig = (products = {}) =>
38
33
 
39
34
  /**
40
35
  * Parses the image URL to return a high resolution version if required.
41
- * @param {string} url The original image URL.
42
- * @param {boolean} useHighRes Whether to return a high resolution version.
43
- * @returns {string} The parsed image URL.
36
+ * @param url The original image URL.
37
+ * @param useHighRes Whether to return a high resolution version.
38
+ * @returns The parsed image URL.
44
39
  */
45
40
  export const parseImageUrl = (url, useHighRes) => {
46
41
  if (!url || !useHighRes) {
@@ -51,11 +46,15 @@ export const parseImageUrl = (url, useHighRes) => {
51
46
  };
52
47
 
53
48
  /**
54
- * Retrieves the border radius based on the widget config
55
- * @param {Object} params The helper parameters.
56
- * @param {"default"|"none"|"rounded"|"custom"} params.borderRadius The border radius option.
57
- * @param {number} params.borderRadiusCustom The custom border radius value.
58
- * @returns {number} The resolved border radius.
49
+ * Parameters for {@link resolveBorderRadiusFromWidgetConfig}.
50
+ */
51
+
52
+ /**
53
+ * Retrieves the border radius based on the widget config.
54
+ * @param params The helper parameters.
55
+ * @param params.borderRadius The border radius option.
56
+ * @param params.borderRadiusCustom The custom border radius value.
57
+ * @returns The resolved border radius.
59
58
  */
60
59
  export const resolveBorderRadiusFromWidgetConfig = ({
61
60
  borderRadius,
@@ -68,15 +67,15 @@ export const resolveBorderRadiusFromWidgetConfig = ({
68
67
  };
69
68
 
70
69
  /**
71
- * Validator factory for regular expressions
72
- * @param {RegExp} regex the regex
73
- * @return {Function}
70
+ * Validator factory for regular expressions.
71
+ * @param regex The regular expression to match.
72
+ * @returns A function that validates if a value matches the regex.
74
73
  */
75
74
  export const matchesRegex = regex => val => !val || regex.test(val);
76
75
 
77
76
  /**
78
- * Returns a function that validates if input is a valid url with the https protocol
79
- * @param {string} val the string to be validated
80
- * @return {boolean}
77
+ * Validates if a given string is a valid HTTPS URL.
78
+ * @param val The string to validate.
79
+ * @returns True if the string is a valid HTTPS URL, false otherwise.
81
80
  */
82
- export const isHttpsUrl = matchesRegex(new RegExp('^\\s*https://[^\\s/$.?#].[^\\s]*\\s*$', 'i'));
81
+ export const isHttpsUrl = matchesRegex(/^\s*https:\/\/[^\s/$.?#].[^\s]*\s*$/i);
@@ -1,60 +1,61 @@
1
- import type { WidgetContextType } from '../components/Widgets/WidgetContext';
2
-
1
+ import { type WidgetContextType } from '@shopgate/engage/page/components/Widgets';
3
2
  /**
4
3
  * The useWidget hook provides access to the context that is wrapped around a widget.
5
4
  * @returns The widget context.
6
5
  */
7
- export declare function useWidget<C = Record<string, any>>(): WidgetContextType<C>
8
-
9
-
10
- export type UseWidgetProductsOptions = {
11
- /**
12
- * The search value to use for the product search
13
- */
14
- value: string;
15
- /**
16
- * The type of product search to perform.
17
- */
18
- type: 'searchTerm' | 'productIds' | 'brand' | 'category' | 'highlights';
19
- /**
20
- * The number of products to return per page.
21
- * @default 32
22
- */
23
- limit?: number;
24
- /**
25
- * Sort order for the products
26
- * @default 'relevance'
27
- */
28
- sort?: 'relevance' | 'priceAsc' | 'priceDesc' | 'nameAsc' | 'nameDesc';
29
- };
30
-
31
- export type UseWidgetProductsResult = {
32
- /**
33
- * Function to fetch the next page of products.
34
- */
35
- fetchNext: () => void;
36
- /**
37
- * Whether there are more products to fetch.
38
- */
39
- hasNext: boolean;
40
- /**
41
- * Whether the products are currently being fetched.
42
- */
43
- isFetching: boolean;
44
- /**
45
- * Number of products available in the current result set.
46
- */
47
- totalResultCount: number;
48
- /**
49
- * Array of product results.
50
- */
51
- results: Object[];
6
+ export declare const useWidget: <C = Record<string, unknown>>() => WidgetContextType<C>;
7
+ /**
8
+ * Options for the {@link useWidgetProducts} hook.
9
+ */
10
+ export interface UseWidgetProductsOptions {
11
+ /**
12
+ * The search value to use for the product search.
13
+ */
14
+ value: string;
15
+ /**
16
+ * The type of product search to perform.
17
+ */
18
+ type: 'searchTerm' | 'productIds' | 'brand' | 'category' | 'highlights';
19
+ /**
20
+ * The number of products to return per page.
21
+ * @default 32
22
+ */
23
+ limit?: number;
24
+ /**
25
+ * Sort order for the products.
26
+ * @default 'relevance'
27
+ */
28
+ sort?: 'relevance' | 'priceAsc' | 'priceDesc' | 'nameAsc' | 'nameDesc';
29
+ }
30
+ /**
31
+ * Result of the {@link useWidgetProducts} hook.
32
+ */
33
+ export interface UseWidgetProductsResult {
34
+ /**
35
+ * Function to fetch the next page of products.
36
+ */
37
+ fetchNext: () => void;
38
+ /**
39
+ * Whether there are more products to fetch.
40
+ */
41
+ hasNext: boolean;
42
+ /**
43
+ * Whether the products are currently being fetched.
44
+ */
45
+ isFetching: boolean;
46
+ /**
47
+ * Number of products available in the current result set.
48
+ */
49
+ totalResultCount: number;
50
+ /**
51
+ * Array of product results.
52
+ */
53
+ results: unknown[];
52
54
  }
53
-
54
55
  /**
55
- * The useWidgetProducts hook provides an easy way to retrieve products based on a search term or
56
- * other criteria.
56
+ * Retrieves the products for the current widget.
57
+ * @param options Hook options.
58
+ * @returns The products and a function to fetch more products.
57
59
  */
58
- export declare function useWidgetProducts(
59
- options: UseWidgetProductsOptions
60
- ): UseWidgetProductsResult;
60
+ export declare const useWidgetProducts: (options?: UseWidgetProductsOptions) => UseWidgetProductsResult;
61
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../page/hooks/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAMjG;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,OAAK,iBAAiB,CAAC,CAAC,CAC1B,CAAC;AA2CpD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,EAAE,YAAY,GAAG,YAAY,GAAG,OAAO,GAAG,UAAU,GAAG,YAAY,CAAC;IACxE;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;CACxE;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAS,wBAAyD,KACjE,uBAyIF,CAAC"}
@@ -6,21 +6,9 @@ import { transformDisplayOptions } from '@shopgate/engage/core/helpers';
6
6
  import { fetchProductsByQuery } from '@shopgate/engage/product';
7
7
  import { makeGetWidgetProducts } from "../selectors";
8
8
 
9
- /**
10
- * @typedef {import('../components/Widgets/WidgetContext').WidgetContextType WidgetContextType}
11
- */
12
-
13
- /**
14
- * @typedef {import('./index').UseWidgetProductsOptions} UseWidgetProductsOptions
15
- */
16
-
17
- /**
18
- * @typedef {import('./index').UseWidgetProductsResult} UseWidgetProductsResult
19
- */
20
-
21
9
  /**
22
10
  * The useWidget hook provides access to the context that is wrapped around a widget.
23
- * @returns {WidgetContextType} The widget context.
11
+ * @returns The widget context.
24
12
  */
25
13
  export const useWidget = () => useContext(WidgetContext);
26
14
  const REQUEST_TYPE_MAPPING = {
@@ -31,10 +19,27 @@ const REQUEST_TYPE_MAPPING = {
31
19
  category: 5
32
20
  };
33
21
 
22
+ /**
23
+ * Shape of the memoized widget products selector result. The underlying selector and its
24
+ * dependencies live in untyped JS, so the shape is described here at the consumption boundary.
25
+ */
26
+
27
+ /**
28
+ * Shape of the result returned by the (untyped) `fetchProductsByQuery` thunk.
29
+ */
30
+
31
+ /**
32
+ * Options for the {@link useWidgetProducts} hook.
33
+ */
34
+
35
+ /**
36
+ * Result of the {@link useWidgetProducts} hook.
37
+ */
38
+
34
39
  /**
35
40
  * Retrieves the products for the current widget.
36
- * @param {UseWidgetProductsOptions} options Hook options
37
- * @returns {UseWidgetProductsResult} The products and a function to fetch more products.
41
+ * @param options Hook options.
42
+ * @returns The products and a function to fetch more products.
38
43
  */
39
44
  export const useWidgetProducts = (options = {}) => {
40
45
  const {
@@ -0,0 +1,32 @@
1
+ export * from "@shopgate/pwa-common/selectors/page";
2
+ export function makeGetPrivacyPolicyLink(): string | null;
3
+ export function makeGetPage({ type, slug, }: {
4
+ type?: PageType | undefined;
5
+ slug?: string | null | undefined;
6
+ }): Function;
7
+ export function makeGetWidgetsFromPage({ type, slug, dropzone, }: {
8
+ type?: PageType | undefined;
9
+ dropzone?: "cmsWidgetList" | undefined;
10
+ slug?: string | null | undefined;
11
+ }): Function;
12
+ /**
13
+ * Determines whether the new CMS version 2 is enabled.
14
+ */
15
+ export const getIsCms2Enabled: ((state: any, ...params: any) => boolean) & import("reselect").OutputSelectorFields<(args_0: boolean, args_1: boolean) => boolean, {
16
+ clearCache: () => void;
17
+ }> & {
18
+ clearCache: () => void;
19
+ };
20
+ export function makeGetUnifiedCMSPageData({ slug }: {
21
+ slug: string;
22
+ }): Function;
23
+ export function makeGetWidgetProducts(type: "searchTerm" | "productIds" | "brand" | "category" | "highlights", options: Object, id: string): Function;
24
+ /**
25
+ * List of available page types.
26
+ */
27
+ export type PageType = "cms" | "category";
28
+ /**
29
+ * List of available dropzone types.
30
+ */
31
+ export type DropzoneType = "cmsWidgetList";
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../page/selectors/index.js"],"names":[],"mappings":";AAmCO,4CAFM,MAAM,GAAC,IAAI,CAuBvB;AAyBM,6CAJJ;IAA0B,IAAI;IACD,IAAI;CACjC,YAcF;AAYM,kEANJ;IAA0B,IAAI;IACA,QAAQ;IAET,IAAI;CACjC,YAqBF;AAED;;GAEG;AACH;;;;EAIE;AASK,oDAHJ;IAAuB,IAAI,EAAnB,MAAM;CACd,YAwCF;AA2FM,4CANI,YAAY,GAAG,YAAY,GAAG,OAAO,GAAG,UAAU,GAAE,YAAY,WAEhE,MAAM,MACN,MAAM,YAkBhB;;;;uBA5NY,KAAK,GAAG,UAAU;;;;2BAKlB,eAAe"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The VideoWidget is used to display a video.
3
+ */
4
+ declare const Video: () => import("react").JSX.Element;
5
+ export default Video;
6
+ //# sourceMappingURL=Video.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Video.d.ts","sourceRoot":"","sources":["../../../../page/widgets/Video/Video.tsx"],"names":[],"mappings":"AAGA;;GAEG;AACH,QAAA,MAAM,KAAK,mCAgBV,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -1,10 +1,8 @@
1
- import React from 'react';
2
1
  import { useVideoWidget } from "./hooks";
3
2
  import WidgetVideo from "../../components/WidgetVideo";
4
3
 
5
4
  /**
6
5
  * The VideoWidget is used to display a video.
7
- * @returns {JSX.Element}
8
6
  */
9
7
  import { jsx as _jsx } from "react/jsx-runtime";
10
8
  const Video = () => {
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Configuration of the Video widget.
3
+ */
4
+ export interface VideoWidgetConfig {
5
+ /**
6
+ * The video URL.
7
+ */
8
+ url: string;
9
+ /**
10
+ * Whether the video should be muted.
11
+ */
12
+ muted?: boolean;
13
+ /**
14
+ * Whether the video should loop.
15
+ */
16
+ loop?: boolean;
17
+ /**
18
+ * Whether the video should display controls.
19
+ */
20
+ controls?: boolean;
21
+ /**
22
+ * Whether the video should autoplay.
23
+ */
24
+ autoplay?: boolean;
25
+ /**
26
+ * The border radius option.
27
+ */
28
+ borderRadius: 'default' | 'none' | 'rounded' | 'custom';
29
+ /**
30
+ * The custom border radius value.
31
+ */
32
+ borderRadiusCustom?: number;
33
+ /**
34
+ * The link URL.
35
+ */
36
+ link?: string;
37
+ }
38
+ /**
39
+ * Resolved data returned by {@link useVideoWidget}. Reuses the field docs from
40
+ * {@link VideoWidgetConfig} for the pass-through fields via `Pick`.
41
+ */
42
+ export interface UseVideoWidgetResult extends Pick<VideoWidgetConfig, 'url' | 'muted' | 'loop' | 'controls' | 'autoplay' | 'link'> {
43
+ /**
44
+ * The resolved border radius value in pixels.
45
+ */
46
+ borderRadius: number;
47
+ }
48
+ /**
49
+ * Hook to access the Video widget configuration and data.
50
+ * @returns The resolved Video widget data.
51
+ */
52
+ export declare const useVideoWidget: () => UseVideoWidgetResult;
53
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../../page/widgets/Video/hooks.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;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,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;IACxD;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAChD,iBAAiB,EACjB,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAC5D;IACC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,QAAO,oBAoBjC,CAAC"}
@@ -2,27 +2,19 @@ import { useWidget } from '@shopgate/engage/page/hooks';
2
2
  import { resolveBorderRadiusFromWidgetConfig } from "../../helpers";
3
3
 
4
4
  /**
5
- * @typedef {Object} VideoWidgetConfig
6
- * @property {string} url The video URL.
7
- * @property {boolean} [muted] Whether the video should be muted.
8
- * @property {boolean} [loop] Whether the video should loop.
9
- * @property {boolean} [controls] Whether the video should display controls.
10
- * @property {boolean} [autoplay] Whether the video should autoplay.
11
- * @property {number} [borderRadius] The border radius preset.
12
- * @property {string} [link] The link URL.
5
+ * Configuration of the Video widget.
13
6
  */
14
7
 
15
8
  /**
16
- * @typedef {ReturnType< typeof import('@shopgate/engage/page/hooks')
17
- * .useWidget<VideoWidgetConfig> >} UseWidgetReturnType
9
+ * Resolved data returned by {@link useVideoWidget}. Reuses the field docs from
10
+ * {@link VideoWidgetConfig} for the pass-through fields via `Pick`.
18
11
  */
19
12
 
20
- // eslint-disable-next-line valid-jsdoc
21
13
  /**
22
14
  * Hook to access the Video widget configuration and data.
15
+ * @returns The resolved Video widget data.
23
16
  */
24
17
  export const useVideoWidget = () => {
25
- /** @type {UseWidgetReturnType} */
26
18
  const {
27
19
  config
28
20
  } = useWidget();
@@ -0,0 +1,2 @@
1
+ export { default } from './Video';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../page/widgets/Video/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC"}
@@ -16,7 +16,6 @@ const useStyles = makeStyles()(theme => ({
16
16
  lineHeight: 1.7,
17
17
  overflow: 'hidden',
18
18
  wordBreak: ['break-all', 'break-word'],
19
- color: theme.palette.text.primary,
20
19
  hyphens: 'auto',
21
20
  ' ul': {
22
21
  listStyle: 'disc'
@@ -69,7 +68,6 @@ function Description({
69
68
  variant: "h5",
70
69
  component: "div",
71
70
  className: cx(classes.title, 'theme__description_heading'),
72
- color: "textPrimary",
73
71
  children: /*#__PURE__*/_jsx(I18n.Text, {
74
72
  string: "product.description_heading"
75
73
  })
@@ -16,6 +16,7 @@ const useStyles = makeStyles()(theme => ({
16
16
  padding: '12px 16px'
17
17
  },
18
18
  title: {
19
+ fontSize: theme.typography.body2.fontSize,
19
20
  fontWeight: theme.typography.fontWeightMedium,
20
21
  lineHeight: 1.15,
21
22
  marginTop: 1
@@ -12,7 +12,7 @@ const useStyles = makeStyles()({
12
12
  root: {
13
13
  lineHeight: 1.2,
14
14
  ':not(:empty)': {
15
- padding: '12px 0 16px'
15
+ padding: '16px 8px 8px'
16
16
  }
17
17
  },
18
18
  quantityHint: {
@@ -3,10 +3,16 @@ import PropTypes from 'prop-types';
3
3
  import { SurroundPortals } from '@shopgate/engage/components';
4
4
  import { PRODUCT_ITEM_IMAGE } from '@shopgate/engage/category/constants';
5
5
  import { getProductImageSettings, ProductImage } from '@shopgate/engage/product';
6
+ import { makeStyles } from '@shopgate/engage/styles';
6
7
  import { jsx as _jsx } from "react/jsx-runtime";
7
8
  const {
8
9
  ListImage: gridResolutions
9
10
  } = getProductImageSettings();
11
+ const useStyles = makeStyles()(theme => ({
12
+ image: {
13
+ background: theme.palette.background.surface
14
+ }
15
+ }));
10
16
 
11
17
  /**
12
18
  * The item image component.
@@ -18,6 +24,9 @@ const ItemImage = ({
18
24
  name,
19
25
  imageUrl
20
26
  }) => {
27
+ const {
28
+ classes
29
+ } = useStyles();
21
30
  const portalProps = useMemo(() => ({
22
31
  productId
23
32
  }), [productId]);
@@ -25,6 +34,7 @@ const ItemImage = ({
25
34
  portalName: PRODUCT_ITEM_IMAGE,
26
35
  portalProps: portalProps,
27
36
  children: /*#__PURE__*/_jsx(ProductImage, {
37
+ className: classes.image,
28
38
  alt: name,
29
39
  src: imageUrl,
30
40
  resolutions: gridResolutions,