@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.
- package/package.json +7 -7
- package/page/components/NotFound.d.ts +7 -0
- package/page/components/NotFound.d.ts.map +1 -0
- package/page/components/NotFound.js +1 -2
- package/page/components/ResponsiveWidgetImage/ResponsiveWidgetImage.d.ts +52 -0
- package/page/components/ResponsiveWidgetImage/ResponsiveWidgetImage.d.ts.map +1 -0
- package/page/components/ResponsiveWidgetImage/index.d.ts +2 -0
- package/page/components/ResponsiveWidgetImage/index.d.ts.map +1 -0
- package/page/components/WidgetRichText/WidgetRichText.d.ts +25 -0
- package/page/components/WidgetRichText/WidgetRichText.d.ts.map +1 -0
- package/page/components/WidgetRichText/index.d.ts +2 -0
- package/page/components/WidgetRichText/index.d.ts.map +1 -0
- package/page/components/WidgetVideo/WidgetVideo.d.ts +43 -0
- package/page/components/WidgetVideo/WidgetVideo.d.ts.map +1 -0
- package/page/components/WidgetVideo/WidgetVideo.js +33 -39
- package/page/components/WidgetVideo/index.d.ts +2 -0
- package/page/components/WidgetVideo/index.d.ts.map +1 -0
- package/page/components/Widgets/Overlay.d.ts +17 -0
- package/page/components/Widgets/Overlay.d.ts.map +1 -0
- package/page/components/Widgets/Overlay.js +24 -38
- package/page/components/Widgets/Tooltip.d.ts +20 -0
- package/page/components/Widgets/Tooltip.d.ts.map +1 -0
- package/page/components/Widgets/Tooltip.js +6 -10
- package/page/components/Widgets/Widget.d.ts +32 -0
- package/page/components/Widgets/Widget.d.ts.map +1 -0
- package/page/components/Widgets/Widget.js +7 -18
- package/page/components/Widgets/WidgetContext.d.ts +32 -38
- package/page/components/Widgets/WidgetContext.d.ts.map +1 -0
- package/page/components/Widgets/WidgetContext.js +2 -8
- package/page/components/Widgets/WidgetProvider.d.ts +25 -0
- package/page/components/Widgets/WidgetProvider.d.ts.map +1 -0
- package/page/components/Widgets/WidgetProvider.js +5 -12
- package/page/components/Widgets/Widgets.d.ts +16 -0
- package/page/components/Widgets/Widgets.d.ts.map +1 -0
- package/page/components/Widgets/Widgets.js +5 -12
- package/page/components/Widgets/WidgetsPreviewContext.d.ts +21 -0
- package/page/components/Widgets/WidgetsPreviewContext.d.ts.map +1 -0
- package/page/components/Widgets/WidgetsPreviewContext.js +5 -7
- package/page/components/Widgets/WidgetsPreviewProvider.d.ts +18 -0
- package/page/components/Widgets/WidgetsPreviewProvider.d.ts.map +1 -0
- package/page/components/Widgets/WidgetsPreviewProvider.js +5 -6
- package/page/components/Widgets/constants.d.ts +5 -0
- package/page/components/Widgets/constants.d.ts.map +1 -0
- package/page/components/Widgets/constants.js +3 -1
- package/page/components/Widgets/events.d.ts +38 -0
- package/page/components/Widgets/events.d.ts.map +1 -0
- package/page/components/Widgets/events.js +8 -12
- package/page/components/Widgets/helpers.d.ts +50 -0
- package/page/components/Widgets/helpers.d.ts.map +1 -0
- package/page/components/Widgets/helpers.js +8 -13
- package/page/components/Widgets/hooks.d.ts +13 -0
- package/page/components/Widgets/hooks.d.ts.map +1 -0
- package/page/components/Widgets/hooks.js +13 -11
- package/page/components/Widgets/index.d.ts +3 -0
- package/page/components/Widgets/index.d.ts.map +1 -0
- package/page/components/Widgets/types.d.ts +111 -113
- package/page/components/Widgets/types.d.ts.map +1 -0
- package/page/components/Widgets/types.js +1 -0
- package/page/components/index.d.ts +5 -0
- package/page/components/index.d.ts.map +1 -0
- package/page/constants/actionTypes.d.ts +4 -0
- package/page/constants/actionTypes.d.ts.map +1 -0
- package/page/constants/index.d.ts +25 -0
- package/page/constants/index.d.ts.map +1 -0
- package/page/helpers/index.d.ts +67 -62
- package/page/helpers/index.d.ts.map +1 -0
- package/page/helpers/index.js +24 -25
- package/page/hooks/index.d.ts +54 -53
- package/page/hooks/index.d.ts.map +1 -0
- package/page/hooks/index.js +20 -15
- package/page/selectors/index.d.ts +32 -0
- package/page/selectors/index.d.ts.map +1 -0
- package/page/widgets/Video/Video.d.ts +6 -0
- package/page/widgets/Video/Video.d.ts.map +1 -0
- package/page/widgets/Video/Video.js +0 -2
- package/page/widgets/Video/hooks.d.ts +53 -0
- package/page/widgets/Video/hooks.d.ts.map +1 -0
- package/page/widgets/Video/hooks.js +4 -12
- package/page/widgets/Video/index.d.ts +2 -0
- package/page/widgets/Video/index.d.ts.map +1 -0
- package/product/components/ProductGrid/constants.d.ts +2 -0
- package/product/components/ProductGrid/constants.d.ts.map +1 -0
- package/product/components/ProductGrid/constants.js +1 -0
- package/product/components/ProductGrid/hooks.d.ts +18 -0
- package/product/components/ProductGrid/hooks.d.ts.map +1 -0
- package/product/components/ProductGrid/hooks.js +49 -0
- package/product/components/ProductGrid/index.js +3 -6
- package/product/components/ProductGrid/spec.js +3 -0
- package/settings/reducers/appSettings.d.ts.map +1 -1
- package/settings/reducers/appSettings.js +8 -0
- package/settings/selectors/appSettings.d.ts +8 -0
- package/settings/selectors/appSettings.d.ts.map +1 -1
- package/settings/selectors/appSettings.js +6 -1
- package/settings/types/appSettings.d.ts +21 -0
- package/settings/types/appSettings.d.ts.map +1 -1
package/page/hooks/index.d.ts
CHANGED
|
@@ -1,60 +1,61 @@
|
|
|
1
|
-
import type
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
*
|
|
56
|
-
*
|
|
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
|
|
59
|
-
|
|
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"}
|
package/page/hooks/index.js
CHANGED
|
@@ -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
|
|
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
|
|
37
|
-
* @returns
|
|
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 @@
|
|
|
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
|
-
*
|
|
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
|
-
*
|
|
17
|
-
*
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../page/widgets/Video/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../product/components/ProductGrid/constants.js"],"names":[],"mappings":"AAAA,wBAAyB,sCAAsC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const WIDGET_ID = '@shopgate/engage/product/ProductGrid';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves the number of product columns for the ProductGrid, keyed by the
|
|
3
|
+
* active breakpoint.
|
|
4
|
+
*
|
|
5
|
+
* Precedence:
|
|
6
|
+
* - Once the app settings are hydrated from a source (admin sync / jsonp), they
|
|
7
|
+
* are authoritative everywhere.
|
|
8
|
+
* - Before hydration, when the grid is rendered outside a page-builder widget
|
|
9
|
+
* (Category / Search / legacy Products widget), the single legacy
|
|
10
|
+
* `useWidgetSettings` scalar is honored flat across all breakpoints. This
|
|
11
|
+
* reproduces the old theme grid and preserves the merchant's configured value.
|
|
12
|
+
* - Otherwise (inside a widget, pre-hydration) the built-in responsive default
|
|
13
|
+
* from the app settings is used ({ xs: 2, md: 4 }), so the inherited legacy
|
|
14
|
+
* `columns: 2` default no longer pins tablet to 2.
|
|
15
|
+
* @returns The resolved number of columns for the active breakpoint.
|
|
16
|
+
*/
|
|
17
|
+
export declare const useProductGridColumns: () => number;
|
|
18
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../../product/components/ProductGrid/hooks.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,qBAAqB,QAAO,MAwBxC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
|
+
import { useSelector } from 'react-redux';
|
|
3
|
+
import { WidgetContext } from '@shopgate/engage/page/components/Widgets/WidgetContext';
|
|
4
|
+
import { useWidgetSettings } from '@shopgate/engage/core/hooks';
|
|
5
|
+
import { useResponsiveValue } from '@shopgate/engage/styles';
|
|
6
|
+
import { getAreAppSettingsHydrated, getProductGridColumns } from '@shopgate/engage/settings/selectors/appSettings';
|
|
7
|
+
import { WIDGET_ID } from "./constants";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the number of product columns for the ProductGrid, keyed by the
|
|
11
|
+
* active breakpoint.
|
|
12
|
+
*
|
|
13
|
+
* Precedence:
|
|
14
|
+
* - Once the app settings are hydrated from a source (admin sync / jsonp), they
|
|
15
|
+
* are authoritative everywhere.
|
|
16
|
+
* - Before hydration, when the grid is rendered outside a page-builder widget
|
|
17
|
+
* (Category / Search / legacy Products widget), the single legacy
|
|
18
|
+
* `useWidgetSettings` scalar is honored flat across all breakpoints. This
|
|
19
|
+
* reproduces the old theme grid and preserves the merchant's configured value.
|
|
20
|
+
* - Otherwise (inside a widget, pre-hydration) the built-in responsive default
|
|
21
|
+
* from the app settings is used ({ xs: 2, md: 4 }), so the inherited legacy
|
|
22
|
+
* `columns: 2` default no longer pins tablet to 2.
|
|
23
|
+
* @returns The resolved number of columns for the active breakpoint.
|
|
24
|
+
*/
|
|
25
|
+
export const useProductGridColumns = () => {
|
|
26
|
+
// Widget-scope detection: the WidgetContext carries a `code` only when the
|
|
27
|
+
// grid renders inside a page-builder widget (WidgetProvider).
|
|
28
|
+
const {
|
|
29
|
+
code: widgetCode
|
|
30
|
+
} = useContext(WidgetContext);
|
|
31
|
+
const isInsideWidget = Boolean(widgetCode);
|
|
32
|
+
const areAppSettingsHydrated = useSelector(getAreAppSettingsHydrated);
|
|
33
|
+
// The built-in default { xs: 2, md: 4 } until hydrated, the source value after.
|
|
34
|
+
const appSettingsColumns = useSelector(getProductGridColumns);
|
|
35
|
+
const {
|
|
36
|
+
columns: legacyColumns
|
|
37
|
+
} = useWidgetSettings(WIDGET_ID) || {};
|
|
38
|
+
const breakpoints = useMemo(() => {
|
|
39
|
+
// Only special case: pre-hydration, outside a widget, honor the legacy
|
|
40
|
+
// scalar flat across every breakpoint.
|
|
41
|
+
if (!areAppSettingsHydrated && !isInsideWidget && typeof legacyColumns === 'number') {
|
|
42
|
+
return {
|
|
43
|
+
xs: legacyColumns
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return appSettingsColumns;
|
|
47
|
+
}, [areAppSettingsHydrated, isInsideWidget, legacyColumns, appSettingsColumns]);
|
|
48
|
+
return useResponsiveValue(breakpoints);
|
|
49
|
+
};
|
|
@@ -4,11 +4,11 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import { ViewContext, InfiniteContainer, LoadingIndicator } from '@shopgate/engage/components';
|
|
5
5
|
import { ProductListTypeProvider } from '@shopgate/engage/product';
|
|
6
6
|
import { ITEMS_PER_LOAD } from '@shopgate/engage/core/constants';
|
|
7
|
-
import { useResponsiveValue } from '@shopgate/engage/styles';
|
|
8
7
|
import Iterator from "./components/Iterator";
|
|
9
8
|
import Layout from "./components/Layout";
|
|
9
|
+
import { useProductGridColumns } from "./hooks";
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
export
|
|
11
|
+
export { WIDGET_ID } from "./constants";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* The Product Grid component.
|
|
@@ -46,10 +46,7 @@ const ProductGrid = ({
|
|
|
46
46
|
const {
|
|
47
47
|
getContentRef
|
|
48
48
|
} = useContext(ViewContext);
|
|
49
|
-
const columns =
|
|
50
|
-
xs: 2,
|
|
51
|
-
md: 4
|
|
52
|
-
});
|
|
49
|
+
const columns = useProductGridColumns();
|
|
53
50
|
if (!infiniteLoad) {
|
|
54
51
|
return /*#__PURE__*/_jsx(Layout, {
|
|
55
52
|
columns: columns,
|
|
@@ -23,6 +23,9 @@ jest.mock('@shopgate/engage/components', () => {
|
|
|
23
23
|
jest.mock("./components/Iterator", () => function Iterator() {
|
|
24
24
|
return null;
|
|
25
25
|
});
|
|
26
|
+
jest.mock("./hooks", () => ({
|
|
27
|
+
useProductGridColumns: jest.fn(() => 2)
|
|
28
|
+
}));
|
|
26
29
|
jest.mock('@shopgate/engage/product', () => ({
|
|
27
30
|
ProductListTypeProvider: ({
|
|
28
31
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appSettings.d.ts","sourceRoot":"","sources":["../../../settings/reducers/appSettings.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAG/E,KAAK,iBAAiB,GAAG,wBAAwB,GAAG,aAAa,CAAC;AAQlE;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"appSettings.d.ts","sourceRoot":"","sources":["../../../settings/reducers/appSettings.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAG/E,KAAK,iBAAiB,GAAG,wBAAwB,GAAG,aAAa,CAAC;AAQlE;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,gBAqBlC,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,WAAW,EAAE,OAAO,CAAC,gBAAgB,EAAE,iBAAiB,CAW5D,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
|
@@ -41,4 +41,12 @@ export declare const getTabBarSettings: ((state: AppSettingsState) => {
|
|
|
41
41
|
}> & {
|
|
42
42
|
clearCache: () => void;
|
|
43
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Selects the ProductGrid columns setting (keyed by breakpoint).
|
|
46
|
+
*/
|
|
47
|
+
export declare const getProductGridColumns: ((state: AppSettingsState) => Partial<Record<import("../../styles/theme").Breakpoint, number>>) & import("reselect").OutputSelectorFields<(args_0: AppSettingsSlice) => Partial<Record<import("../../styles/theme").Breakpoint, number>>, {
|
|
48
|
+
clearCache: () => void;
|
|
49
|
+
}> & {
|
|
50
|
+
clearCache: () => void;
|
|
51
|
+
};
|
|
44
52
|
//# sourceMappingURL=appSettings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appSettings.d.ts","sourceRoot":"","sources":["../../../settings/selectors/appSettings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG/E;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,gBAAgB,KAAG,gBACR,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB;;;;CAGrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;CAG7B,CAAC"}
|
|
1
|
+
{"version":3,"file":"appSettings.d.ts","sourceRoot":"","sources":["../../../settings/selectors/appSettings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG/E;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,gBAAgB,KAAG,gBACR,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB;;;;CAGrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;CAG7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;CAGjC,CAAC"}
|
|
@@ -20,4 +20,9 @@ export const getAreAppSettingsHydrated = createSelector(getAppSettingsState, app
|
|
|
20
20
|
/**
|
|
21
21
|
* Selects the tab bar settings.
|
|
22
22
|
*/
|
|
23
|
-
export const getTabBarSettings = createSelector(getAppSettingsState, appSettings => appSettings.navigation.tabBar);
|
|
23
|
+
export const getTabBarSettings = createSelector(getAppSettingsState, appSettings => appSettings.navigation.tabBar);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Selects the ProductGrid columns setting (keyed by breakpoint).
|
|
27
|
+
*/
|
|
28
|
+
export const getProductGridColumns = createSelector(getAppSettingsState, appSettings => appSettings.productList.grid.columns);
|
|
@@ -1,8 +1,28 @@
|
|
|
1
|
+
import type { Breakpoint } from '@shopgate/engage/styles/theme';
|
|
1
2
|
export interface AppSettingsState {
|
|
2
3
|
settings: {
|
|
3
4
|
appSettings: AppSettingsSlice;
|
|
4
5
|
};
|
|
5
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Number of product columns to render, keyed by breakpoint. Partial: any unset
|
|
9
|
+
* breakpoint cascades down to the next smaller defined value (see
|
|
10
|
+
* useResponsiveValue).
|
|
11
|
+
*/
|
|
12
|
+
export type ProductColumns = Partial<Record<Breakpoint, number>>;
|
|
13
|
+
/**
|
|
14
|
+
* Settings for the ProductGrid list type.
|
|
15
|
+
*/
|
|
16
|
+
export interface ProductGridSettings {
|
|
17
|
+
columns: ProductColumns;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Settings for the various product-list types. Add a key and its own settings
|
|
21
|
+
* interface per future type (e.g. slider).
|
|
22
|
+
*/
|
|
23
|
+
export interface ProductListSettings {
|
|
24
|
+
grid: ProductGridSettings;
|
|
25
|
+
}
|
|
6
26
|
export interface AppSettings {
|
|
7
27
|
navigation: {
|
|
8
28
|
tabBar: {
|
|
@@ -15,6 +35,7 @@ export interface AppSettings {
|
|
|
15
35
|
};
|
|
16
36
|
};
|
|
17
37
|
};
|
|
38
|
+
productList: ProductListSettings;
|
|
18
39
|
}
|
|
19
40
|
/**
|
|
20
41
|
* The stored app settings slice. Extends the raw {@link AppSettings} values
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appSettings.d.ts","sourceRoot":"","sources":["../../../settings/types/appSettings.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE;QACR,WAAW,EAAE,gBAAgB,CAAC;KAC/B,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE;QACV,MAAM,EAAE;YACN,OAAO,EAAE,OAAO,GAAG,UAAU,CAAA;YAC7B,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;YAC7B,UAAU,EAAE,OAAO,CAAC;YACpB,YAAY,EAAE,OAAO,CAAC;YACtB,KAAK,EAAE;gBACL,aAAa,EAAE,OAAO,CAAC;aACxB,CAAA;SACF,CAAA;KACF,CAAA;
|
|
1
|
+
{"version":3,"file":"appSettings.d.ts","sourceRoot":"","sources":["../../../settings/types/appSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE;QACR,WAAW,EAAE,gBAAgB,CAAC;KAC/B,CAAC;CACH;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,cAAc,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE;QACV,MAAM,EAAE;YACN,OAAO,EAAE,OAAO,GAAG,UAAU,CAAA;YAC7B,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;YAC7B,UAAU,EAAE,OAAO,CAAC;YACpB,YAAY,EAAE,OAAO,CAAC;YACtB,KAAK,EAAE;gBACL,aAAa,EAAE,OAAO,CAAC;aACxB,CAAA;SACF,CAAA;KACF,CAAA;IACD,WAAW,EAAE,mBAAmB,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD;;;;OAIG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB"}
|