@wix/headless-stores 0.0.10 → 0.0.11
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/cjs/dist/enums/index.d.ts +2 -0
- package/cjs/dist/enums/index.js +18 -0
- package/cjs/dist/enums/social-platform-enums.d.ts +25 -0
- package/cjs/dist/enums/social-platform-enums.js +30 -0
- package/cjs/dist/enums/sort-enums.d.ts +17 -0
- package/cjs/dist/enums/sort-enums.js +21 -0
- package/cjs/dist/react/BuyNow.d.ts +2 -4
- package/cjs/dist/react/Category.d.ts +9 -11
- package/cjs/dist/react/Category.js +8 -23
- package/cjs/dist/react/Collection.d.ts +13 -3
- package/cjs/dist/react/Collection.js +30 -19
- package/cjs/dist/react/FilteredCollection.d.ts +45 -15
- package/cjs/dist/react/FilteredCollection.js +45 -12
- package/cjs/dist/react/PayNow.d.ts +2 -4
- package/cjs/dist/react/Product.d.ts +8 -35
- package/cjs/dist/react/Product.js +10 -31
- package/cjs/dist/react/ProductActions.d.ts +42 -0
- package/cjs/dist/react/ProductActions.js +83 -0
- package/cjs/dist/react/ProductModifiers.d.ts +16 -8
- package/cjs/dist/react/ProductModifiers.js +19 -10
- package/cjs/dist/react/ProductVariantSelector.d.ts +52 -68
- package/cjs/dist/react/ProductVariantSelector.js +58 -86
- package/cjs/dist/react/RelatedProducts.d.ts +8 -4
- package/cjs/dist/react/RelatedProducts.js +12 -7
- package/cjs/dist/react/SelectedVariant.d.ts +66 -0
- package/cjs/dist/react/SelectedVariant.js +52 -0
- package/cjs/dist/react/SocialSharing.d.ts +24 -31
- package/cjs/dist/react/SocialSharing.js +8 -2
- package/cjs/dist/react/Sort.d.ts +11 -14
- package/cjs/dist/react/Sort.js +10 -34
- package/cjs/dist/react/index.d.ts +11 -10
- package/cjs/dist/react/index.js +3 -2
- package/cjs/dist/services/buy-now-service.js +2 -2
- package/cjs/dist/services/catalog-options-service.d.ts +2 -2
- package/cjs/dist/services/catalog-options-service.js +39 -45
- package/cjs/dist/services/catalog-price-range-service.d.ts +2 -2
- package/cjs/dist/services/catalog-price-range-service.js +13 -11
- package/cjs/dist/services/category-service.d.ts +7 -6
- package/cjs/dist/services/category-service.js +15 -11
- package/cjs/dist/services/collection-service.d.ts +8 -8
- package/cjs/dist/services/collection-service.js +182 -67
- package/cjs/dist/services/filter-service.d.ts +1 -1
- package/cjs/dist/services/filter-service.js +15 -23
- package/cjs/dist/services/product-media-gallery-service.d.ts +3 -3
- package/cjs/dist/services/product-modifiers-service.d.ts +6 -8
- package/cjs/dist/services/product-modifiers-service.js +14 -7
- package/cjs/dist/services/product-service.d.ts +8 -7
- package/cjs/dist/services/product-service.js +36 -19
- package/cjs/dist/services/related-products-service.d.ts +4 -4
- package/cjs/dist/services/related-products-service.js +4 -4
- package/cjs/dist/services/selected-variant-service.d.ts +24 -16
- package/cjs/dist/services/selected-variant-service.js +271 -126
- package/cjs/dist/services/social-sharing-service.d.ts +2 -2
- package/cjs/dist/services/social-sharing-service.js +47 -63
- package/cjs/dist/services/sort-service.d.ts +3 -2
- package/cjs/dist/services/sort-service.js +8 -13
- package/dist/enums/index.d.ts +2 -0
- package/dist/enums/index.js +2 -0
- package/dist/enums/social-platform-enums.d.ts +25 -0
- package/dist/enums/social-platform-enums.js +27 -0
- package/dist/enums/sort-enums.d.ts +17 -0
- package/dist/enums/sort-enums.js +18 -0
- package/dist/react/BuyNow.d.ts +2 -4
- package/dist/react/Category.d.ts +9 -11
- package/dist/react/Category.js +10 -23
- package/dist/react/Collection.d.ts +13 -3
- package/dist/react/Collection.js +32 -21
- package/dist/react/FilteredCollection.d.ts +45 -15
- package/dist/react/FilteredCollection.js +49 -16
- package/dist/react/PayNow.d.ts +2 -4
- package/dist/react/Product.d.ts +8 -35
- package/dist/react/Product.js +11 -31
- package/dist/react/ProductActions.d.ts +42 -0
- package/dist/react/ProductActions.js +79 -0
- package/dist/react/ProductModifiers.d.ts +16 -8
- package/dist/react/ProductModifiers.js +22 -13
- package/dist/react/ProductVariantSelector.d.ts +52 -68
- package/dist/react/ProductVariantSelector.js +57 -84
- package/dist/react/RelatedProducts.d.ts +8 -4
- package/dist/react/RelatedProducts.js +15 -10
- package/dist/react/SelectedVariant.d.ts +66 -0
- package/dist/react/SelectedVariant.js +46 -0
- package/dist/react/SocialSharing.d.ts +24 -31
- package/dist/react/SocialSharing.js +11 -5
- package/dist/react/Sort.d.ts +11 -14
- package/dist/react/Sort.js +12 -34
- package/dist/react/index.d.ts +11 -10
- package/dist/react/index.js +11 -10
- package/dist/services/buy-now-service.js +2 -2
- package/dist/services/catalog-options-service.d.ts +2 -2
- package/dist/services/catalog-options-service.js +41 -47
- package/dist/services/catalog-price-range-service.d.ts +2 -2
- package/dist/services/catalog-price-range-service.js +15 -13
- package/dist/services/category-service.d.ts +7 -6
- package/dist/services/category-service.js +17 -13
- package/dist/services/collection-service.d.ts +8 -8
- package/dist/services/collection-service.js +188 -73
- package/dist/services/filter-service.d.ts +1 -1
- package/dist/services/filter-service.js +20 -28
- package/dist/services/product-media-gallery-service.d.ts +3 -3
- package/dist/services/product-modifiers-service.d.ts +6 -8
- package/dist/services/product-modifiers-service.js +16 -9
- package/dist/services/product-service.d.ts +8 -7
- package/dist/services/product-service.js +38 -21
- package/dist/services/related-products-service.d.ts +4 -4
- package/dist/services/related-products-service.js +6 -6
- package/dist/services/selected-variant-service.d.ts +24 -16
- package/dist/services/selected-variant-service.js +273 -127
- package/dist/services/social-sharing-service.d.ts +2 -2
- package/dist/services/social-sharing-service.js +49 -65
- package/dist/services/sort-service.d.ts +3 -2
- package/dist/services/sort-service.js +11 -16
- package/package.json +7 -1
- package/cjs/dist/react/ProductMediaGallery.d.ts +0 -128
- package/cjs/dist/react/ProductMediaGallery.js +0 -100
- package/dist/astro/BuyNowServiceContext.d.ts +0 -2
- package/dist/astro/BuyNowServiceContext.js +0 -6
- package/dist/astro/ManagerProviderContext.d.ts +0 -2
- package/dist/astro/ManagerProviderContext.js +0 -7
- package/dist/astro/withBuyButtonService.d.ts +0 -2
- package/dist/astro/withBuyButtonService.js +0 -16
- package/dist/react/CurrentCartServiceProvider.d.ts +0 -5
- package/dist/react/CurrentCartServiceProvider.js +0 -12
- package/dist/react/ProductMediaGallery.d.ts +0 -128
- package/dist/react/ProductMediaGallery.js +0 -92
- package/dist/react/VariantSelectorServiceProvider.d.ts +0 -7
- package/dist/react/VariantSelectorServiceProvider.js +0 -22
- package/dist/react/hookim/index.d.ts +0 -5
- package/dist/react/hookim/index.js +0 -22
- package/dist/services/CurrentCartService.d.ts +0 -18
- package/dist/services/CurrentCartService.js +0 -9
- package/dist/services/VariantSelectorServices.d.ts +0 -8
- package/dist/services/VariantSelectorServices.js +0 -20
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useService } from '@wix/services-manager-react';
|
|
2
|
+
import { SelectedVariantServiceDefinition } from '../services/selected-variant-service';
|
|
3
|
+
/**
|
|
4
|
+
* Headless component for selected variant details display
|
|
5
|
+
*
|
|
6
|
+
* @component
|
|
7
|
+
*/
|
|
8
|
+
export const Details = (props) => {
|
|
9
|
+
const selectedVariantService = useService(SelectedVariantServiceDefinition);
|
|
10
|
+
const selectedVariant = selectedVariantService.currentVariant?.get();
|
|
11
|
+
let sku = selectedVariant?.sku || null;
|
|
12
|
+
let weight = selectedVariant?.physicalProperties?.weight?.toString() || null;
|
|
13
|
+
return props.children({
|
|
14
|
+
sku,
|
|
15
|
+
weight,
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Headless component for product price display
|
|
20
|
+
*
|
|
21
|
+
* @component
|
|
22
|
+
*/
|
|
23
|
+
export const Price = (props) => {
|
|
24
|
+
const variantService = useService(SelectedVariantServiceDefinition);
|
|
25
|
+
const price = variantService.currentPrice.get();
|
|
26
|
+
const compareAtPrice = variantService.currentCompareAtPrice.get();
|
|
27
|
+
const currency = variantService.currency.get();
|
|
28
|
+
return props.children({
|
|
29
|
+
price,
|
|
30
|
+
compareAtPrice,
|
|
31
|
+
currency,
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Headless component for product SKU display
|
|
36
|
+
*
|
|
37
|
+
* @component
|
|
38
|
+
*/
|
|
39
|
+
export const SKU = (props) => {
|
|
40
|
+
const selectedVariantService = useService(SelectedVariantServiceDefinition);
|
|
41
|
+
const selectedVariant = selectedVariantService.currentVariant?.get();
|
|
42
|
+
const sku = selectedVariant?.sku || null;
|
|
43
|
+
return props.children({
|
|
44
|
+
sku,
|
|
45
|
+
});
|
|
46
|
+
};
|
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { SharingPlatform } from
|
|
3
|
-
export type { SharingPlatform };
|
|
4
|
-
export type RootChildren = (props: RootRenderProps) => React.ReactNode;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SharingPlatform } from '../services/social-sharing-service';
|
|
5
3
|
/**
|
|
6
4
|
* Props for Root headless component
|
|
7
5
|
*/
|
|
8
6
|
export interface RootProps {
|
|
9
7
|
/** Render prop function that receives sharing data */
|
|
10
|
-
children:
|
|
8
|
+
children: (props: RootRenderProps) => React.ReactNode;
|
|
11
9
|
}
|
|
12
|
-
export type ShareFacebook = (url: string, title: string, description?: string) => void;
|
|
13
|
-
export type ShareTwitter = (url: string, text: string, hashtags?: string[]) => void;
|
|
14
|
-
export type ShareLinkedIn = (url: string, title: string, summary?: string) => void;
|
|
15
|
-
export type ShareWhatsApp = (url: string, text: string) => void;
|
|
16
|
-
export type ShareEmail = (url: string, subject: string, body: string) => void;
|
|
17
|
-
export type CopyLink = (url: string) => Promise<boolean>;
|
|
18
|
-
export type ShareNative = (data: {
|
|
19
|
-
title: string;
|
|
20
|
-
text: string;
|
|
21
|
-
url: string;
|
|
22
|
-
}) => Promise<boolean>;
|
|
23
10
|
/**
|
|
24
11
|
* Render props for Root component
|
|
25
12
|
*/
|
|
@@ -31,26 +18,30 @@ export interface RootRenderProps {
|
|
|
31
18
|
/** Last shared platform */
|
|
32
19
|
lastShared: string | null;
|
|
33
20
|
/** Share to Facebook */
|
|
34
|
-
shareFacebook:
|
|
21
|
+
shareFacebook: (url: string, title: string, description?: string) => void;
|
|
35
22
|
/** Share to Twitter */
|
|
36
|
-
shareTwitter:
|
|
23
|
+
shareTwitter: (url: string, text: string, hashtags?: string[]) => void;
|
|
37
24
|
/** Share to LinkedIn */
|
|
38
|
-
shareLinkedIn:
|
|
25
|
+
shareLinkedIn: (url: string, title: string, summary?: string) => void;
|
|
39
26
|
/** Share to WhatsApp */
|
|
40
|
-
shareWhatsApp:
|
|
27
|
+
shareWhatsApp: (url: string, text: string) => void;
|
|
41
28
|
/** Share via Email */
|
|
42
|
-
shareEmail:
|
|
29
|
+
shareEmail: (url: string, subject: string, body: string) => void;
|
|
43
30
|
/** Copy to clipboard */
|
|
44
|
-
copyLink:
|
|
31
|
+
copyLink: (url: string) => Promise<boolean>;
|
|
45
32
|
/** Native share API */
|
|
46
|
-
shareNative:
|
|
33
|
+
shareNative: (data: {
|
|
34
|
+
title: string;
|
|
35
|
+
text: string;
|
|
36
|
+
url: string;
|
|
37
|
+
}) => Promise<boolean>;
|
|
47
38
|
}
|
|
48
39
|
/**
|
|
49
40
|
* Headless component for social sharing root
|
|
41
|
+
*
|
|
42
|
+
* @component
|
|
50
43
|
*/
|
|
51
44
|
export declare const Root: (props: RootProps) => React.ReactNode;
|
|
52
|
-
export type OnClick = () => void;
|
|
53
|
-
export type PlatformChildren = (props: PlatformRenderProps) => React.ReactNode;
|
|
54
45
|
/**
|
|
55
46
|
* Props for Platform headless component
|
|
56
47
|
*/
|
|
@@ -58,11 +49,10 @@ export interface PlatformProps {
|
|
|
58
49
|
/** Platform data */
|
|
59
50
|
platform: SharingPlatform;
|
|
60
51
|
/** Click handler */
|
|
61
|
-
onClick:
|
|
52
|
+
onClick: () => void;
|
|
62
53
|
/** Render prop function that receives platform data */
|
|
63
|
-
children:
|
|
54
|
+
children: (props: PlatformRenderProps) => React.ReactNode;
|
|
64
55
|
}
|
|
65
|
-
export type OnSelect = () => void;
|
|
66
56
|
/**
|
|
67
57
|
* Render props for Platform component
|
|
68
58
|
*/
|
|
@@ -70,13 +60,14 @@ export interface PlatformRenderProps {
|
|
|
70
60
|
/** Platform data */
|
|
71
61
|
platform: SharingPlatform;
|
|
72
62
|
/** Platform click handler */
|
|
73
|
-
onSelect:
|
|
63
|
+
onSelect: () => void;
|
|
74
64
|
}
|
|
75
65
|
/**
|
|
76
66
|
* Headless component for individual social platform
|
|
67
|
+
*
|
|
68
|
+
* @component
|
|
77
69
|
*/
|
|
78
70
|
export declare const Platform: (props: PlatformProps) => React.ReactNode;
|
|
79
|
-
export type PlatformsChildren = (props: PlatformsRenderProps) => React.ReactNode;
|
|
80
71
|
/**
|
|
81
72
|
* Props for Platforms headless component
|
|
82
73
|
*/
|
|
@@ -90,7 +81,7 @@ export interface PlatformsProps {
|
|
|
90
81
|
/** Hashtags for sharing */
|
|
91
82
|
hashtags?: string[];
|
|
92
83
|
/** Render prop function that receives platforms data */
|
|
93
|
-
children:
|
|
84
|
+
children: (props: PlatformsRenderProps) => React.ReactNode;
|
|
94
85
|
}
|
|
95
86
|
/**
|
|
96
87
|
* Render props for Platforms component
|
|
@@ -115,5 +106,7 @@ export interface PlatformsRenderProps {
|
|
|
115
106
|
}
|
|
116
107
|
/**
|
|
117
108
|
* Headless component for social sharing platforms with logic
|
|
109
|
+
*
|
|
110
|
+
* @component
|
|
118
111
|
*/
|
|
119
112
|
export declare const Platforms: (props: PlatformsProps) => React.ReactNode;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { useService } from
|
|
3
|
-
import { SocialSharingServiceDefinition, } from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useService } from '@wix/services-manager-react';
|
|
3
|
+
import { SocialSharingServiceDefinition, } from '../services/social-sharing-service';
|
|
4
4
|
/**
|
|
5
5
|
* Headless component for social sharing root
|
|
6
|
+
*
|
|
7
|
+
* @component
|
|
6
8
|
*/
|
|
7
9
|
export const Root = (props) => {
|
|
8
10
|
const service = useService(SocialSharingServiceDefinition);
|
|
@@ -15,7 +17,7 @@ export const Root = (props) => {
|
|
|
15
17
|
service.shareCount.subscribe(setShareCount),
|
|
16
18
|
service.lastSharedPlatform.subscribe(setLastShared),
|
|
17
19
|
];
|
|
18
|
-
return () => unsubscribes.forEach(
|
|
20
|
+
return () => unsubscribes.forEach(fn => fn());
|
|
19
21
|
}, [service]);
|
|
20
22
|
return props.children({
|
|
21
23
|
platforms,
|
|
@@ -32,6 +34,8 @@ export const Root = (props) => {
|
|
|
32
34
|
};
|
|
33
35
|
/**
|
|
34
36
|
* Headless component for individual social platform
|
|
37
|
+
*
|
|
38
|
+
* @component
|
|
35
39
|
*/
|
|
36
40
|
export const Platform = (props) => {
|
|
37
41
|
const { platform, onClick } = props;
|
|
@@ -42,9 +46,11 @@ export const Platform = (props) => {
|
|
|
42
46
|
};
|
|
43
47
|
/**
|
|
44
48
|
* Headless component for social sharing platforms with logic
|
|
49
|
+
*
|
|
50
|
+
* @component
|
|
45
51
|
*/
|
|
46
52
|
export const Platforms = (props) => {
|
|
47
|
-
const { url, title, description =
|
|
53
|
+
const { url, title, description = '', hashtags = [] } = props;
|
|
48
54
|
const service = useService(SocialSharingServiceDefinition);
|
|
49
55
|
const [platforms, setPlatforms] = React.useState([]);
|
|
50
56
|
React.useEffect(() => {
|
package/dist/react/Sort.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { type SortBy } from
|
|
3
|
-
interface SortContextValue {
|
|
4
|
-
currentSort: SortBy;
|
|
5
|
-
setSortBy: (sortBy: SortBy) => void;
|
|
6
|
-
}
|
|
7
|
-
export declare function useSortContext(): SortContextValue;
|
|
8
|
-
export interface ProviderProps {
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
}
|
|
11
|
-
export declare function Provider({ children }: ProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export type SortControllerChildren = (props: SortContextValue) => React.ReactNode;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SortBy } from '../services/sort-service';
|
|
13
3
|
export interface ControllerProps {
|
|
14
|
-
children:
|
|
4
|
+
children: (props: {
|
|
5
|
+
currentSort: SortBy;
|
|
6
|
+
setSortBy: (sortBy: SortBy) => void;
|
|
7
|
+
}) => React.ReactNode;
|
|
15
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Headless component for sorting products
|
|
11
|
+
*
|
|
12
|
+
* @component
|
|
13
|
+
*/
|
|
16
14
|
export declare function Controller({ children }: ControllerProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
export {};
|
package/dist/react/Sort.js
CHANGED
|
@@ -1,36 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { SortServiceDefinition } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
throw new Error("useSortContext must be used within a Sort.SortProvider");
|
|
10
|
-
}
|
|
11
|
-
return context;
|
|
12
|
-
}
|
|
13
|
-
export function Provider({ children }) {
|
|
14
|
-
const sortService = useService(SortServiceDefinition);
|
|
15
|
-
const [currentSort, setCurrentSort] = useState("");
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
const unsubscribe = sortService.currentSort.subscribe((sort) => {
|
|
18
|
-
setCurrentSort(sort);
|
|
19
|
-
});
|
|
20
|
-
// Initialize with current value
|
|
21
|
-
setCurrentSort(sortService.currentSort.get());
|
|
22
|
-
return unsubscribe;
|
|
23
|
-
}, [sortService]);
|
|
24
|
-
const setSortBy = (sortBy) => {
|
|
25
|
-
sortService.setSortBy(sortBy);
|
|
26
|
-
};
|
|
27
|
-
const contextValue = {
|
|
28
|
-
currentSort,
|
|
29
|
-
setSortBy,
|
|
30
|
-
};
|
|
31
|
-
return (_jsx(SortContext.Provider, { value: contextValue, children: children }));
|
|
32
|
-
}
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useService } from '@wix/services-manager-react';
|
|
3
|
+
import { SortServiceDefinition } from '../services/sort-service';
|
|
4
|
+
/**
|
|
5
|
+
* Headless component for sorting products
|
|
6
|
+
*
|
|
7
|
+
* @component
|
|
8
|
+
*/
|
|
33
9
|
export function Controller({ children }) {
|
|
34
|
-
const
|
|
35
|
-
|
|
10
|
+
const sortService = useService(SortServiceDefinition);
|
|
11
|
+
const currentSort = sortService.currentSort.get();
|
|
12
|
+
const setSortBy = sortService.setSortBy;
|
|
13
|
+
return _jsx(_Fragment, { children: children({ currentSort, setSortBy }) });
|
|
36
14
|
}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export * from "./BuyNow";
|
|
2
2
|
export * from "./PayNow";
|
|
3
|
-
export * as Sort from
|
|
4
|
-
export * as Category from
|
|
5
|
-
export * as FilteredCollection from
|
|
6
|
-
export * as ProductVariantSelector from
|
|
7
|
-
export * as RelatedProducts from
|
|
8
|
-
export * as SocialSharing from
|
|
9
|
-
export * as Collection from
|
|
10
|
-
export * as Product from
|
|
11
|
-
export * as
|
|
12
|
-
export * as
|
|
3
|
+
export * as Sort from './Sort';
|
|
4
|
+
export * as Category from './Category';
|
|
5
|
+
export * as FilteredCollection from './FilteredCollection';
|
|
6
|
+
export * as ProductVariantSelector from './ProductVariantSelector';
|
|
7
|
+
export * as RelatedProducts from './RelatedProducts';
|
|
8
|
+
export * as SocialSharing from './SocialSharing';
|
|
9
|
+
export * as Collection from './Collection';
|
|
10
|
+
export * as Product from './Product';
|
|
11
|
+
export * as ProductModifiers from './ProductModifiers';
|
|
12
|
+
export * as SelectedVariant from './SelectedVariant';
|
|
13
|
+
export * as ProductActions from './ProductActions';
|
package/dist/react/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export * from "./BuyNow";
|
|
2
2
|
export * from "./PayNow";
|
|
3
|
-
export * as Sort from
|
|
4
|
-
export * as Category from
|
|
5
|
-
export * as FilteredCollection from
|
|
6
|
-
export * as ProductVariantSelector from
|
|
7
|
-
export * as RelatedProducts from
|
|
8
|
-
export * as SocialSharing from
|
|
9
|
-
export * as Collection from
|
|
10
|
-
export * as Product from
|
|
11
|
-
export * as
|
|
12
|
-
export * as
|
|
3
|
+
export * as Sort from './Sort';
|
|
4
|
+
export * as Category from './Category';
|
|
5
|
+
export * as FilteredCollection from './FilteredCollection';
|
|
6
|
+
export * as ProductVariantSelector from './ProductVariantSelector';
|
|
7
|
+
export * as RelatedProducts from './RelatedProducts';
|
|
8
|
+
export * as SocialSharing from './SocialSharing';
|
|
9
|
+
export * as Collection from './Collection';
|
|
10
|
+
export * as Product from './Product';
|
|
11
|
+
export * as ProductModifiers from './ProductModifiers';
|
|
12
|
+
export * as SelectedVariant from './SelectedVariant';
|
|
13
|
+
export * as ProductActions from './ProductActions';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineService, implementService, } from "@wix/services-definitions";
|
|
2
2
|
import { SignalsServiceDefinition } from "@wix/services-definitions/core-services/signals";
|
|
3
|
-
import { productsV3 } from "@wix/stores";
|
|
4
3
|
import { getCheckoutUrlForProduct } from "../utils";
|
|
4
|
+
import { getProductBySlug } from "@wix/auto_sdk_stores_products-v-3";
|
|
5
5
|
export const BuyNowServiceDefinition = defineService("BuyNow");
|
|
6
6
|
export const BuyNowServiceImplementation = implementService.withConfig()(BuyNowServiceDefinition, ({ getService, config }) => {
|
|
7
7
|
const signalsService = getService(SignalsServiceDefinition);
|
|
@@ -31,7 +31,7 @@ export const BuyNowServiceImplementation = implementService.withConfig()(BuyNowS
|
|
|
31
31
|
};
|
|
32
32
|
});
|
|
33
33
|
export const loadBuyNowServiceInitialData = async (productSlug, variantId) => {
|
|
34
|
-
const res = await
|
|
34
|
+
const res = await getProductBySlug(productSlug, {
|
|
35
35
|
fields: ["CURRENCY"],
|
|
36
36
|
});
|
|
37
37
|
const product = res.product;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ServiceFactoryConfig } from
|
|
2
|
-
import type { Signal } from
|
|
1
|
+
import { type ServiceFactoryConfig } from '@wix/services-definitions';
|
|
2
|
+
import type { Signal } from '../../Signal';
|
|
3
3
|
export interface ProductOption {
|
|
4
4
|
id: string;
|
|
5
5
|
name: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { defineService, implementService, } from
|
|
2
|
-
import { SignalsServiceDefinition } from
|
|
3
|
-
import {
|
|
1
|
+
import { defineService, implementService, } from '@wix/services-definitions';
|
|
2
|
+
import { SignalsServiceDefinition } from '@wix/services-definitions/core-services/signals';
|
|
3
|
+
import { ModifierRenderType, searchProducts, SortDirection, SortType as SDKSortType, } from '@wix/auto_sdk_stores_products-v-3';
|
|
4
|
+
import { CustomizationType, queryCustomizations, } from '@wix/auto_sdk_stores_customizations-v-3';
|
|
4
5
|
// Helper functions
|
|
5
6
|
const extractAggregationValues = (aggregationResponse, name) => {
|
|
6
7
|
const aggregation = aggregationResponse.aggregations?.[name] ||
|
|
@@ -8,7 +9,7 @@ const extractAggregationValues = (aggregationResponse, name) => {
|
|
|
8
9
|
return aggregation?.values?.results?.map((item) => item.value) || [];
|
|
9
10
|
};
|
|
10
11
|
const matchesAggregationName = (name, aggregationNames) => {
|
|
11
|
-
return aggregationNames.some(
|
|
12
|
+
return aggregationNames.some(aggName => aggName.toLowerCase() === name.toLowerCase());
|
|
12
13
|
};
|
|
13
14
|
const sortChoicesIntelligently = (choices) => {
|
|
14
15
|
return [...choices].sort((a, b) => {
|
|
@@ -30,12 +31,12 @@ const buildCategoryFilter = (categoryId) => {
|
|
|
30
31
|
}
|
|
31
32
|
return {
|
|
32
33
|
visible: true,
|
|
33
|
-
|
|
34
|
+
'allCategoriesInfo.categories': {
|
|
34
35
|
$matchItems: [{ _id: { $in: [categoryId] } }],
|
|
35
36
|
},
|
|
36
37
|
};
|
|
37
38
|
};
|
|
38
|
-
export const CatalogOptionsServiceDefinition = defineService(
|
|
39
|
+
export const CatalogOptionsServiceDefinition = defineService('catalogOptions');
|
|
39
40
|
export const CatalogOptionsService = implementService.withConfig()(CatalogOptionsServiceDefinition, ({ getService }) => {
|
|
40
41
|
const signalsService = getService(SignalsServiceDefinition);
|
|
41
42
|
const catalogOptions = signalsService.signal(null);
|
|
@@ -49,33 +50,33 @@ export const CatalogOptionsService = implementService.withConfig()(CatalogOption
|
|
|
49
50
|
const aggregationRequest = {
|
|
50
51
|
aggregations: [
|
|
51
52
|
{
|
|
52
|
-
name:
|
|
53
|
-
fieldPath:
|
|
54
|
-
type:
|
|
53
|
+
name: 'optionNames',
|
|
54
|
+
fieldPath: 'options.name',
|
|
55
|
+
type: SDKSortType.VALUE,
|
|
55
56
|
value: {
|
|
56
57
|
limit: 20,
|
|
57
|
-
sortType:
|
|
58
|
-
sortDirection:
|
|
58
|
+
sortType: SDKSortType.VALUE,
|
|
59
|
+
sortDirection: SortDirection.ASC,
|
|
59
60
|
},
|
|
60
61
|
},
|
|
61
62
|
{
|
|
62
|
-
name:
|
|
63
|
-
fieldPath:
|
|
64
|
-
type:
|
|
63
|
+
name: 'choiceNames',
|
|
64
|
+
fieldPath: 'options.choicesSettings.choices.name',
|
|
65
|
+
type: SDKSortType.VALUE,
|
|
65
66
|
value: {
|
|
66
67
|
limit: 50,
|
|
67
|
-
sortType:
|
|
68
|
-
sortDirection:
|
|
68
|
+
sortType: SDKSortType.VALUE,
|
|
69
|
+
sortDirection: SortDirection.ASC,
|
|
69
70
|
},
|
|
70
71
|
},
|
|
71
72
|
{
|
|
72
|
-
name:
|
|
73
|
-
fieldPath:
|
|
74
|
-
type:
|
|
73
|
+
name: 'inventoryStatus',
|
|
74
|
+
fieldPath: 'inventory.availabilityStatus',
|
|
75
|
+
type: SDKSortType.VALUE,
|
|
75
76
|
value: {
|
|
76
77
|
limit: 10,
|
|
77
|
-
sortType:
|
|
78
|
-
sortDirection:
|
|
78
|
+
sortType: SDKSortType.VALUE,
|
|
79
|
+
sortDirection: SortDirection.ASC,
|
|
79
80
|
},
|
|
80
81
|
},
|
|
81
82
|
],
|
|
@@ -83,27 +84,26 @@ export const CatalogOptionsService = implementService.withConfig()(CatalogOption
|
|
|
83
84
|
includeProducts: false,
|
|
84
85
|
cursorPaging: { limit: 0 },
|
|
85
86
|
};
|
|
86
|
-
const aggregationResponse = await
|
|
87
|
-
const optionNames = extractAggregationValues(aggregationResponse,
|
|
88
|
-
const choiceNames = extractAggregationValues(aggregationResponse,
|
|
89
|
-
const inventoryStatuses = extractAggregationValues(aggregationResponse,
|
|
87
|
+
const aggregationResponse = await searchProducts(aggregationRequest);
|
|
88
|
+
const optionNames = extractAggregationValues(aggregationResponse, 'optionNames');
|
|
89
|
+
const choiceNames = extractAggregationValues(aggregationResponse, 'choiceNames');
|
|
90
|
+
const inventoryStatuses = extractAggregationValues(aggregationResponse, 'inventoryStatus');
|
|
90
91
|
// Step 2: Get option structure from customizations API
|
|
91
|
-
const customizationsResponse = await
|
|
92
|
-
.queryCustomizations()
|
|
93
|
-
.find();
|
|
92
|
+
const customizationsResponse = await queryCustomizations().find();
|
|
94
93
|
const customizations = customizationsResponse.items || [];
|
|
95
94
|
// Step 3: Build options by matching customizations with aggregation data
|
|
96
95
|
const options = customizations
|
|
97
|
-
.filter(
|
|
96
|
+
.filter(customization => customization.name &&
|
|
98
97
|
customization._id &&
|
|
99
|
-
customization.customizationType ===
|
|
98
|
+
customization.customizationType ===
|
|
99
|
+
CustomizationType.PRODUCT_OPTION &&
|
|
100
100
|
matchesAggregationName(customization.name, optionNames))
|
|
101
|
-
.map(
|
|
101
|
+
.map(customization => {
|
|
102
102
|
const choices = (customization.choicesSettings?.choices || [])
|
|
103
|
-
.filter(
|
|
103
|
+
.filter(choice => choice._id &&
|
|
104
104
|
choice.name &&
|
|
105
105
|
matchesAggregationName(choice.name, choiceNames))
|
|
106
|
-
.map(
|
|
106
|
+
.map(choice => ({
|
|
107
107
|
id: choice._id,
|
|
108
108
|
name: choice.name,
|
|
109
109
|
colorCode: choice.colorCode,
|
|
@@ -115,31 +115,25 @@ export const CatalogOptionsService = implementService.withConfig()(CatalogOption
|
|
|
115
115
|
optionRenderType: customization.customizationRenderType,
|
|
116
116
|
};
|
|
117
117
|
})
|
|
118
|
-
.filter(
|
|
118
|
+
.filter(option => option.choices.length > 0);
|
|
119
119
|
// Step 4: Add inventory filter if there are multiple inventory statuses
|
|
120
120
|
if (inventoryStatuses.length > 1) {
|
|
121
|
-
const inventoryChoices = inventoryStatuses.map(
|
|
121
|
+
const inventoryChoices = inventoryStatuses.map(status => ({
|
|
122
122
|
id: status.toUpperCase(), // Use uppercase to match actual availabilityStatus values
|
|
123
|
-
name: status.toUpperCase()
|
|
124
|
-
? "In Stock"
|
|
125
|
-
: status.toUpperCase() === "OUT_OF_STOCK"
|
|
126
|
-
? "Out of Stock"
|
|
127
|
-
: status.toUpperCase() === "PARTIALLY_OUT_OF_STOCK"
|
|
128
|
-
? "Partially out of stock"
|
|
129
|
-
: status,
|
|
123
|
+
name: status.toUpperCase(), // Use raw status value - UI components will handle display conversion
|
|
130
124
|
}));
|
|
131
125
|
options.push({
|
|
132
|
-
id:
|
|
133
|
-
name:
|
|
126
|
+
id: 'inventory-filter',
|
|
127
|
+
name: 'Availability',
|
|
134
128
|
choices: inventoryChoices,
|
|
135
|
-
optionRenderType:
|
|
129
|
+
optionRenderType: ModifierRenderType.TEXT_CHOICES,
|
|
136
130
|
});
|
|
137
131
|
}
|
|
138
132
|
catalogOptions.set(options);
|
|
139
133
|
}
|
|
140
134
|
catch (err) {
|
|
141
|
-
console.error(
|
|
142
|
-
error.set(err instanceof Error ? err.message :
|
|
135
|
+
console.error('Failed to load catalog options:', err);
|
|
136
|
+
error.set(err instanceof Error ? err.message : 'Failed to load catalog options');
|
|
143
137
|
catalogOptions.set([]);
|
|
144
138
|
}
|
|
145
139
|
finally {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ServiceFactoryConfig } from
|
|
2
|
-
import type { Signal } from
|
|
1
|
+
import { type ServiceFactoryConfig } from '@wix/services-definitions';
|
|
2
|
+
import type { Signal } from '../../Signal';
|
|
3
3
|
export interface CatalogPriceRange {
|
|
4
4
|
minPrice: number;
|
|
5
5
|
maxPrice: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineService, implementService, } from
|
|
2
|
-
import { SignalsServiceDefinition } from
|
|
3
|
-
import {
|
|
1
|
+
import { defineService, implementService, } from '@wix/services-definitions';
|
|
2
|
+
import { SignalsServiceDefinition } from '@wix/services-definitions/core-services/signals';
|
|
3
|
+
import { searchProducts } from '@wix/auto_sdk_stores_products-v-3';
|
|
4
4
|
// Helper function to extract scalar aggregation values
|
|
5
5
|
const extractScalarAggregationValue = (aggregationResponse, name) => {
|
|
6
6
|
const aggregation = aggregationResponse.aggregations?.[name] ||
|
|
@@ -15,11 +15,11 @@ const buildCategoryFilter = (categoryId) => {
|
|
|
15
15
|
return {
|
|
16
16
|
visible: true,
|
|
17
17
|
'allCategoriesInfo.categories': {
|
|
18
|
-
$matchItems: [{ _id: { $in: [categoryId] } }]
|
|
19
|
-
}
|
|
18
|
+
$matchItems: [{ _id: { $in: [categoryId] } }],
|
|
19
|
+
},
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
export const CatalogPriceRangeServiceDefinition = defineService(
|
|
22
|
+
export const CatalogPriceRangeServiceDefinition = defineService('catalogPriceRange');
|
|
23
23
|
export const CatalogPriceRangeService = implementService.withConfig()(CatalogPriceRangeServiceDefinition, ({ getService }) => {
|
|
24
24
|
const signalsService = getService(SignalsServiceDefinition);
|
|
25
25
|
// Signal declarations
|
|
@@ -41,27 +41,29 @@ export const CatalogPriceRangeService = implementService.withConfig()(CatalogPri
|
|
|
41
41
|
name: 'minPrice',
|
|
42
42
|
fieldPath: 'actualPriceRange.minValue.amount',
|
|
43
43
|
type: 'SCALAR',
|
|
44
|
-
scalar: { type: 'MIN' }
|
|
44
|
+
scalar: { type: 'MIN' },
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
name: 'maxPrice',
|
|
48
48
|
fieldPath: 'actualPriceRange.maxValue.amount',
|
|
49
49
|
type: 'SCALAR',
|
|
50
|
-
scalar: { type: 'MAX' }
|
|
51
|
-
}
|
|
50
|
+
scalar: { type: 'MAX' },
|
|
51
|
+
},
|
|
52
52
|
],
|
|
53
53
|
filter: buildCategoryFilter(categoryId),
|
|
54
54
|
includeProducts: false,
|
|
55
|
-
cursorPaging: { limit: 0 }
|
|
55
|
+
cursorPaging: { limit: 0 },
|
|
56
56
|
};
|
|
57
|
-
const aggregationResponse = await
|
|
57
|
+
const aggregationResponse = await searchProducts(aggregationRequest);
|
|
58
58
|
const minPrice = extractScalarAggregationValue(aggregationResponse, 'minPrice');
|
|
59
59
|
const maxPrice = extractScalarAggregationValue(aggregationResponse, 'maxPrice');
|
|
60
60
|
// Only set price range if we found valid prices
|
|
61
|
-
if (minPrice !== null &&
|
|
61
|
+
if (minPrice !== null &&
|
|
62
|
+
maxPrice !== null &&
|
|
63
|
+
(minPrice > 0 || maxPrice > 0)) {
|
|
62
64
|
catalogPriceRange.set({
|
|
63
65
|
minPrice,
|
|
64
|
-
maxPrice
|
|
66
|
+
maxPrice,
|
|
65
67
|
});
|
|
66
68
|
}
|
|
67
69
|
else {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { Signal } from
|
|
2
|
-
import {
|
|
1
|
+
import type { Signal } from '../../Signal';
|
|
2
|
+
import { type Category } from '@wix/auto_sdk_categories_categories';
|
|
3
3
|
export interface CategoryServiceAPI {
|
|
4
4
|
selectedCategory: Signal<string | null>;
|
|
5
|
-
categories: Signal<
|
|
5
|
+
categories: Signal<Category[]>;
|
|
6
6
|
setSelectedCategory: (categoryId: string | null) => void;
|
|
7
|
+
loadCategories: () => Promise<void>;
|
|
7
8
|
}
|
|
8
9
|
export declare const CategoryServiceDefinition: string & {
|
|
9
10
|
__api: CategoryServiceAPI;
|
|
@@ -11,9 +12,9 @@ export declare const CategoryServiceDefinition: string & {
|
|
|
11
12
|
isServiceDefinition?: boolean;
|
|
12
13
|
} & CategoryServiceAPI;
|
|
13
14
|
export interface CategoryServiceConfig {
|
|
14
|
-
categories:
|
|
15
|
+
categories: Category[];
|
|
15
16
|
initialCategoryId?: string | null;
|
|
16
|
-
onCategoryChange?: (categoryId: string | null, category:
|
|
17
|
+
onCategoryChange?: (categoryId: string | null, category: Category | null) => void;
|
|
17
18
|
}
|
|
18
19
|
export declare const CategoryService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
19
20
|
__api: CategoryServiceAPI;
|
|
@@ -21,5 +22,5 @@ export declare const CategoryService: import("@wix/services-definitions").Servic
|
|
|
21
22
|
isServiceDefinition?: boolean;
|
|
22
23
|
} & CategoryServiceAPI, CategoryServiceConfig, import("@wix/services-definitions").ThreadMode.MAIN>;
|
|
23
24
|
export declare function loadCategoriesConfig(): Promise<{
|
|
24
|
-
categories:
|
|
25
|
+
categories: Category[];
|
|
25
26
|
}>;
|