@wix/headless-stores 0.0.9 → 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 +15 -0
- package/cjs/dist/react/Category.js +22 -0
- package/cjs/dist/react/Collection.d.ts +151 -0
- package/cjs/dist/react/Collection.js +209 -0
- package/cjs/dist/react/FilteredCollection.d.ts +95 -0
- package/cjs/dist/react/FilteredCollection.js +150 -0
- package/cjs/dist/react/PayNow.d.ts +2 -4
- package/cjs/dist/react/Product.d.ts +43 -0
- package/cjs/dist/react/Product.js +35 -0
- package/cjs/dist/react/ProductActions.d.ts +42 -0
- package/cjs/dist/react/ProductActions.js +83 -0
- package/cjs/dist/react/ProductModifiers.d.ts +164 -0
- package/cjs/dist/react/ProductModifiers.js +168 -0
- package/cjs/dist/react/ProductVariantSelector.d.ts +153 -0
- package/cjs/dist/react/ProductVariantSelector.js +138 -0
- package/cjs/dist/react/RelatedProducts.d.ts +64 -0
- package/cjs/dist/react/RelatedProducts.js +73 -0
- package/cjs/dist/react/SelectedVariant.d.ts +66 -0
- package/cjs/dist/react/SelectedVariant.js +52 -0
- package/cjs/dist/react/SocialSharing.d.ts +112 -0
- package/cjs/dist/react/SocialSharing.js +86 -0
- package/cjs/dist/react/Sort.d.ts +14 -0
- package/cjs/dist/react/Sort.js +17 -0
- package/cjs/dist/react/index.d.ts +11 -0
- package/cjs/dist/react/index.js +34 -0
- package/cjs/dist/services/buy-now-service.js +2 -2
- package/cjs/dist/services/catalog-options-service.d.ts +30 -0
- package/cjs/dist/services/catalog-options-service.js +156 -0
- package/cjs/dist/services/catalog-price-range-service.d.ts +23 -0
- package/cjs/dist/services/catalog-price-range-service.js +97 -0
- package/cjs/dist/services/category-service.d.ts +26 -0
- package/cjs/dist/services/category-service.js +71 -0
- package/cjs/dist/services/collection-service.d.ts +37 -0
- package/cjs/dist/services/collection-service.js +569 -0
- package/cjs/dist/services/filter-service.d.ts +56 -0
- package/cjs/dist/services/filter-service.js +147 -0
- package/cjs/dist/services/product-media-gallery-service.d.ts +25 -0
- package/cjs/dist/services/product-media-gallery-service.js +105 -0
- package/cjs/dist/services/product-modifiers-service.d.ts +34 -0
- package/cjs/dist/services/product-modifiers-service.js +111 -0
- package/cjs/dist/services/product-service.d.ts +28 -0
- package/cjs/dist/services/product-service.js +68 -0
- package/cjs/dist/services/related-products-service.d.ts +25 -0
- package/cjs/dist/services/related-products-service.js +54 -0
- package/cjs/dist/services/selected-variant-service.d.ts +59 -0
- package/cjs/dist/services/selected-variant-service.js +541 -0
- package/cjs/dist/services/social-sharing-service.d.ts +41 -0
- package/cjs/dist/services/social-sharing-service.js +141 -0
- package/cjs/dist/services/sort-service.d.ts +20 -0
- package/cjs/dist/services/sort-service.js +32 -0
- package/cjs/dist/utils/url-params.d.ts +5 -0
- package/cjs/dist/utils/url-params.js +50 -0
- 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 +15 -0
- package/dist/react/Category.js +18 -0
- package/dist/react/Collection.d.ts +151 -0
- package/dist/react/Collection.js +201 -0
- package/dist/react/FilteredCollection.d.ts +95 -0
- package/dist/react/FilteredCollection.js +140 -0
- package/dist/react/PayNow.d.ts +2 -4
- package/dist/react/Product.d.ts +43 -0
- package/dist/react/Product.js +30 -0
- package/dist/react/ProductActions.d.ts +42 -0
- package/dist/react/ProductActions.js +79 -0
- package/dist/react/ProductModifiers.d.ts +164 -0
- package/dist/react/ProductModifiers.js +160 -0
- package/dist/react/ProductVariantSelector.d.ts +153 -0
- package/dist/react/ProductVariantSelector.js +130 -0
- package/dist/react/RelatedProducts.d.ts +64 -0
- package/dist/react/RelatedProducts.js +65 -0
- package/dist/react/SelectedVariant.d.ts +66 -0
- package/dist/react/SelectedVariant.js +46 -0
- package/dist/react/SocialSharing.d.ts +112 -0
- package/dist/react/SocialSharing.js +77 -0
- package/dist/react/Sort.d.ts +14 -0
- package/dist/react/Sort.js +14 -0
- package/dist/react/index.d.ts +11 -0
- package/dist/react/index.js +11 -0
- package/dist/services/buy-now-service.js +2 -2
- package/dist/services/catalog-options-service.d.ts +30 -0
- package/dist/services/catalog-options-service.js +152 -0
- package/dist/services/catalog-price-range-service.d.ts +23 -0
- package/dist/services/catalog-price-range-service.js +93 -0
- package/dist/services/category-service.d.ts +26 -0
- package/dist/services/category-service.js +67 -0
- package/dist/services/collection-service.d.ts +37 -0
- package/dist/services/collection-service.js +532 -0
- package/dist/services/filter-service.d.ts +56 -0
- package/dist/services/filter-service.js +144 -0
- package/dist/services/product-media-gallery-service.d.ts +25 -0
- package/dist/services/product-media-gallery-service.js +101 -0
- package/dist/services/product-modifiers-service.d.ts +34 -0
- package/dist/services/product-modifiers-service.js +107 -0
- package/dist/services/product-service.d.ts +28 -0
- package/dist/services/product-service.js +64 -0
- package/dist/services/related-products-service.d.ts +25 -0
- package/dist/services/related-products-service.js +50 -0
- package/dist/services/selected-variant-service.d.ts +59 -0
- package/dist/services/selected-variant-service.js +538 -0
- package/dist/services/social-sharing-service.d.ts +41 -0
- package/dist/services/social-sharing-service.js +137 -0
- package/dist/services/sort-service.d.ts +20 -0
- package/dist/services/sort-service.js +29 -0
- package/dist/utils/url-params.d.ts +5 -0
- package/dist/utils/url-params.js +46 -0
- package/package.json +8 -1
- 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/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,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SKU = exports.Price = exports.Details = void 0;
|
|
4
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
5
|
+
const selected_variant_service_1 = require("../services/selected-variant-service");
|
|
6
|
+
/**
|
|
7
|
+
* Headless component for selected variant details display
|
|
8
|
+
*
|
|
9
|
+
* @component
|
|
10
|
+
*/
|
|
11
|
+
const Details = (props) => {
|
|
12
|
+
const selectedVariantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
|
|
13
|
+
const selectedVariant = selectedVariantService.currentVariant?.get();
|
|
14
|
+
let sku = selectedVariant?.sku || null;
|
|
15
|
+
let weight = selectedVariant?.physicalProperties?.weight?.toString() || null;
|
|
16
|
+
return props.children({
|
|
17
|
+
sku,
|
|
18
|
+
weight,
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
exports.Details = Details;
|
|
22
|
+
/**
|
|
23
|
+
* Headless component for product price display
|
|
24
|
+
*
|
|
25
|
+
* @component
|
|
26
|
+
*/
|
|
27
|
+
const Price = (props) => {
|
|
28
|
+
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
|
|
29
|
+
const price = variantService.currentPrice.get();
|
|
30
|
+
const compareAtPrice = variantService.currentCompareAtPrice.get();
|
|
31
|
+
const currency = variantService.currency.get();
|
|
32
|
+
return props.children({
|
|
33
|
+
price,
|
|
34
|
+
compareAtPrice,
|
|
35
|
+
currency,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
exports.Price = Price;
|
|
39
|
+
/**
|
|
40
|
+
* Headless component for product SKU display
|
|
41
|
+
*
|
|
42
|
+
* @component
|
|
43
|
+
*/
|
|
44
|
+
const SKU = (props) => {
|
|
45
|
+
const selectedVariantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
|
|
46
|
+
const selectedVariant = selectedVariantService.currentVariant?.get();
|
|
47
|
+
const sku = selectedVariant?.sku || null;
|
|
48
|
+
return props.children({
|
|
49
|
+
sku,
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
exports.SKU = SKU;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SharingPlatform } from '../services/social-sharing-service';
|
|
3
|
+
/**
|
|
4
|
+
* Props for Root headless component
|
|
5
|
+
*/
|
|
6
|
+
export interface RootProps {
|
|
7
|
+
/** Render prop function that receives sharing data */
|
|
8
|
+
children: (props: RootRenderProps) => React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Render props for Root component
|
|
12
|
+
*/
|
|
13
|
+
export interface RootRenderProps {
|
|
14
|
+
/** Available sharing platforms */
|
|
15
|
+
platforms: SharingPlatform[];
|
|
16
|
+
/** Total share count */
|
|
17
|
+
shareCount: number;
|
|
18
|
+
/** Last shared platform */
|
|
19
|
+
lastShared: string | null;
|
|
20
|
+
/** Share to Facebook */
|
|
21
|
+
shareFacebook: (url: string, title: string, description?: string) => void;
|
|
22
|
+
/** Share to Twitter */
|
|
23
|
+
shareTwitter: (url: string, text: string, hashtags?: string[]) => void;
|
|
24
|
+
/** Share to LinkedIn */
|
|
25
|
+
shareLinkedIn: (url: string, title: string, summary?: string) => void;
|
|
26
|
+
/** Share to WhatsApp */
|
|
27
|
+
shareWhatsApp: (url: string, text: string) => void;
|
|
28
|
+
/** Share via Email */
|
|
29
|
+
shareEmail: (url: string, subject: string, body: string) => void;
|
|
30
|
+
/** Copy to clipboard */
|
|
31
|
+
copyLink: (url: string) => Promise<boolean>;
|
|
32
|
+
/** Native share API */
|
|
33
|
+
shareNative: (data: {
|
|
34
|
+
title: string;
|
|
35
|
+
text: string;
|
|
36
|
+
url: string;
|
|
37
|
+
}) => Promise<boolean>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Headless component for social sharing root
|
|
41
|
+
*
|
|
42
|
+
* @component
|
|
43
|
+
*/
|
|
44
|
+
export declare const Root: (props: RootProps) => React.ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* Props for Platform headless component
|
|
47
|
+
*/
|
|
48
|
+
export interface PlatformProps {
|
|
49
|
+
/** Platform data */
|
|
50
|
+
platform: SharingPlatform;
|
|
51
|
+
/** Click handler */
|
|
52
|
+
onClick: () => void;
|
|
53
|
+
/** Render prop function that receives platform data */
|
|
54
|
+
children: (props: PlatformRenderProps) => React.ReactNode;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Render props for Platform component
|
|
58
|
+
*/
|
|
59
|
+
export interface PlatformRenderProps {
|
|
60
|
+
/** Platform data */
|
|
61
|
+
platform: SharingPlatform;
|
|
62
|
+
/** Platform click handler */
|
|
63
|
+
onSelect: () => void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Headless component for individual social platform
|
|
67
|
+
*
|
|
68
|
+
* @component
|
|
69
|
+
*/
|
|
70
|
+
export declare const Platform: (props: PlatformProps) => React.ReactNode;
|
|
71
|
+
/**
|
|
72
|
+
* Props for Platforms headless component
|
|
73
|
+
*/
|
|
74
|
+
export interface PlatformsProps {
|
|
75
|
+
/** URL to share */
|
|
76
|
+
url: string;
|
|
77
|
+
/** Share title */
|
|
78
|
+
title: string;
|
|
79
|
+
/** Share description */
|
|
80
|
+
description?: string;
|
|
81
|
+
/** Hashtags for sharing */
|
|
82
|
+
hashtags?: string[];
|
|
83
|
+
/** Render prop function that receives platforms data */
|
|
84
|
+
children: (props: PlatformsRenderProps) => React.ReactNode;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Render props for Platforms component
|
|
88
|
+
*/
|
|
89
|
+
export interface PlatformsRenderProps {
|
|
90
|
+
/** Available platforms */
|
|
91
|
+
platforms: SharingPlatform[];
|
|
92
|
+
/** Share to Facebook */
|
|
93
|
+
shareFacebook: () => void;
|
|
94
|
+
/** Share to Twitter */
|
|
95
|
+
shareTwitter: () => void;
|
|
96
|
+
/** Share to LinkedIn */
|
|
97
|
+
shareLinkedIn: () => void;
|
|
98
|
+
/** Share to WhatsApp */
|
|
99
|
+
shareWhatsApp: () => void;
|
|
100
|
+
/** Share via Email */
|
|
101
|
+
shareEmail: () => void;
|
|
102
|
+
/** Copy link to clipboard */
|
|
103
|
+
copyLink: () => Promise<boolean>;
|
|
104
|
+
/** Share natively */
|
|
105
|
+
shareNative: () => Promise<boolean>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Headless component for social sharing platforms with logic
|
|
109
|
+
*
|
|
110
|
+
* @component
|
|
111
|
+
*/
|
|
112
|
+
export declare const Platforms: (props: PlatformsProps) => React.ReactNode;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Platforms = exports.Platform = exports.Root = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
9
|
+
const social_sharing_service_1 = require("../services/social-sharing-service");
|
|
10
|
+
/**
|
|
11
|
+
* Headless component for social sharing root
|
|
12
|
+
*
|
|
13
|
+
* @component
|
|
14
|
+
*/
|
|
15
|
+
const Root = (props) => {
|
|
16
|
+
const service = (0, services_manager_react_1.useService)(social_sharing_service_1.SocialSharingServiceDefinition);
|
|
17
|
+
const [platforms, setPlatforms] = react_1.default.useState([]);
|
|
18
|
+
const [shareCount, setShareCount] = react_1.default.useState(0);
|
|
19
|
+
const [lastShared, setLastShared] = react_1.default.useState(null);
|
|
20
|
+
react_1.default.useEffect(() => {
|
|
21
|
+
const unsubscribes = [
|
|
22
|
+
service.availablePlatforms.subscribe(setPlatforms),
|
|
23
|
+
service.shareCount.subscribe(setShareCount),
|
|
24
|
+
service.lastSharedPlatform.subscribe(setLastShared),
|
|
25
|
+
];
|
|
26
|
+
return () => unsubscribes.forEach(fn => fn());
|
|
27
|
+
}, [service]);
|
|
28
|
+
return props.children({
|
|
29
|
+
platforms,
|
|
30
|
+
shareCount,
|
|
31
|
+
lastShared,
|
|
32
|
+
shareFacebook: service.shareToFacebook,
|
|
33
|
+
shareTwitter: service.shareToTwitter,
|
|
34
|
+
shareLinkedIn: service.shareToLinkedIn,
|
|
35
|
+
shareWhatsApp: service.shareToWhatsApp,
|
|
36
|
+
shareEmail: service.shareToEmail,
|
|
37
|
+
copyLink: service.copyToClipboard,
|
|
38
|
+
shareNative: service.shareNative,
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
exports.Root = Root;
|
|
42
|
+
/**
|
|
43
|
+
* Headless component for individual social platform
|
|
44
|
+
*
|
|
45
|
+
* @component
|
|
46
|
+
*/
|
|
47
|
+
const Platform = (props) => {
|
|
48
|
+
const { platform, onClick } = props;
|
|
49
|
+
return props.children({
|
|
50
|
+
platform,
|
|
51
|
+
onSelect: onClick,
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
exports.Platform = Platform;
|
|
55
|
+
/**
|
|
56
|
+
* Headless component for social sharing platforms with logic
|
|
57
|
+
*
|
|
58
|
+
* @component
|
|
59
|
+
*/
|
|
60
|
+
const Platforms = (props) => {
|
|
61
|
+
const { url, title, description = '', hashtags = [] } = props;
|
|
62
|
+
const service = (0, services_manager_react_1.useService)(social_sharing_service_1.SocialSharingServiceDefinition);
|
|
63
|
+
const [platforms, setPlatforms] = react_1.default.useState([]);
|
|
64
|
+
react_1.default.useEffect(() => {
|
|
65
|
+
const unsubscribe = service.availablePlatforms.subscribe(setPlatforms);
|
|
66
|
+
return unsubscribe;
|
|
67
|
+
}, [service]);
|
|
68
|
+
const shareFacebook = () => service.shareToFacebook(url, title, description);
|
|
69
|
+
const shareTwitter = () => service.shareToTwitter(url, title, hashtags);
|
|
70
|
+
const shareLinkedIn = () => service.shareToLinkedIn(url, title, description);
|
|
71
|
+
const shareWhatsApp = () => service.shareToWhatsApp(url, `${title} - ${description}`);
|
|
72
|
+
const shareEmail = () => service.shareToEmail(url, title, description);
|
|
73
|
+
const copyLink = () => service.copyToClipboard(url);
|
|
74
|
+
const shareNative = () => service.shareNative({ title, text: description, url });
|
|
75
|
+
return props.children({
|
|
76
|
+
platforms,
|
|
77
|
+
shareFacebook,
|
|
78
|
+
shareTwitter,
|
|
79
|
+
shareLinkedIn,
|
|
80
|
+
shareWhatsApp,
|
|
81
|
+
shareEmail,
|
|
82
|
+
copyLink,
|
|
83
|
+
shareNative,
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
exports.Platforms = Platforms;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SortBy } from '../services/sort-service';
|
|
3
|
+
export interface ControllerProps {
|
|
4
|
+
children: (props: {
|
|
5
|
+
currentSort: SortBy;
|
|
6
|
+
setSortBy: (sortBy: SortBy) => void;
|
|
7
|
+
}) => React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Headless component for sorting products
|
|
11
|
+
*
|
|
12
|
+
* @component
|
|
13
|
+
*/
|
|
14
|
+
export declare function Controller({ children }: ControllerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Controller = Controller;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
6
|
+
const sort_service_1 = require("../services/sort-service");
|
|
7
|
+
/**
|
|
8
|
+
* Headless component for sorting products
|
|
9
|
+
*
|
|
10
|
+
* @component
|
|
11
|
+
*/
|
|
12
|
+
function Controller({ children }) {
|
|
13
|
+
const sortService = (0, services_manager_react_1.useService)(sort_service_1.SortServiceDefinition);
|
|
14
|
+
const currentSort = sortService.currentSort.get();
|
|
15
|
+
const setSortBy = sortService.setSortBy;
|
|
16
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({ currentSort, setSortBy }) });
|
|
17
|
+
}
|
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
export * from "./BuyNow";
|
|
2
2
|
export * from "./PayNow";
|
|
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/cjs/dist/react/index.js
CHANGED
|
@@ -10,9 +10,43 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
16
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ProductActions = exports.SelectedVariant = exports.ProductModifiers = exports.Product = exports.Collection = exports.SocialSharing = exports.RelatedProducts = exports.ProductVariantSelector = exports.FilteredCollection = exports.Category = exports.Sort = void 0;
|
|
17
40
|
__exportStar(require("./BuyNow"), exports);
|
|
18
41
|
__exportStar(require("./PayNow"), exports);
|
|
42
|
+
exports.Sort = __importStar(require("./Sort"));
|
|
43
|
+
exports.Category = __importStar(require("./Category"));
|
|
44
|
+
exports.FilteredCollection = __importStar(require("./FilteredCollection"));
|
|
45
|
+
exports.ProductVariantSelector = __importStar(require("./ProductVariantSelector"));
|
|
46
|
+
exports.RelatedProducts = __importStar(require("./RelatedProducts"));
|
|
47
|
+
exports.SocialSharing = __importStar(require("./SocialSharing"));
|
|
48
|
+
exports.Collection = __importStar(require("./Collection"));
|
|
49
|
+
exports.Product = __importStar(require("./Product"));
|
|
50
|
+
exports.ProductModifiers = __importStar(require("./ProductModifiers"));
|
|
51
|
+
exports.SelectedVariant = __importStar(require("./SelectedVariant"));
|
|
52
|
+
exports.ProductActions = __importStar(require("./ProductActions"));
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.buyNowServiceBinding = exports.loadBuyNowServiceInitialData = exports.BuyNowServiceImplementation = exports.BuyNowServiceDefinition = void 0;
|
|
4
4
|
const services_definitions_1 = require("@wix/services-definitions");
|
|
5
5
|
const signals_1 = require("@wix/services-definitions/core-services/signals");
|
|
6
|
-
const stores_1 = require("@wix/stores");
|
|
7
6
|
const utils_1 = require("../utils");
|
|
7
|
+
const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
|
|
8
8
|
exports.BuyNowServiceDefinition = (0, services_definitions_1.defineService)("BuyNow");
|
|
9
9
|
exports.BuyNowServiceImplementation = services_definitions_1.implementService.withConfig()(exports.BuyNowServiceDefinition, ({ getService, config }) => {
|
|
10
10
|
const signalsService = getService(signals_1.SignalsServiceDefinition);
|
|
@@ -34,7 +34,7 @@ exports.BuyNowServiceImplementation = services_definitions_1.implementService.wi
|
|
|
34
34
|
};
|
|
35
35
|
});
|
|
36
36
|
const loadBuyNowServiceInitialData = async (productSlug, variantId) => {
|
|
37
|
-
const res = await
|
|
37
|
+
const res = await (0, auto_sdk_stores_products_v_3_1.getProductBySlug)(productSlug, {
|
|
38
38
|
fields: ["CURRENCY"],
|
|
39
39
|
});
|
|
40
40
|
const product = res.product;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ServiceFactoryConfig } from '@wix/services-definitions';
|
|
2
|
+
import type { Signal } from '../../Signal';
|
|
3
|
+
export interface ProductOption {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
choices: ProductChoice[];
|
|
7
|
+
optionRenderType?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ProductChoice {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
colorCode?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CatalogOptionsServiceAPI {
|
|
15
|
+
catalogOptions: Signal<ProductOption[] | null>;
|
|
16
|
+
isLoading: Signal<boolean>;
|
|
17
|
+
error: Signal<string | null>;
|
|
18
|
+
loadCatalogOptions: (categoryId?: string) => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export declare const CatalogOptionsServiceDefinition: string & {
|
|
21
|
+
__api: CatalogOptionsServiceAPI;
|
|
22
|
+
__config: {};
|
|
23
|
+
isServiceDefinition?: boolean;
|
|
24
|
+
} & CatalogOptionsServiceAPI;
|
|
25
|
+
export declare const CatalogOptionsService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
26
|
+
__api: CatalogOptionsServiceAPI;
|
|
27
|
+
__config: {};
|
|
28
|
+
isServiceDefinition?: boolean;
|
|
29
|
+
} & CatalogOptionsServiceAPI, {}, import("@wix/services-definitions").ThreadMode.MAIN>;
|
|
30
|
+
export declare function loadCatalogOptionsServiceConfig(): Promise<ServiceFactoryConfig<typeof CatalogOptionsService>>;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CatalogOptionsService = exports.CatalogOptionsServiceDefinition = void 0;
|
|
4
|
+
exports.loadCatalogOptionsServiceConfig = loadCatalogOptionsServiceConfig;
|
|
5
|
+
const services_definitions_1 = require("@wix/services-definitions");
|
|
6
|
+
const signals_1 = require("@wix/services-definitions/core-services/signals");
|
|
7
|
+
const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
|
|
8
|
+
const auto_sdk_stores_customizations_v_3_1 = require("@wix/auto_sdk_stores_customizations-v-3");
|
|
9
|
+
// Helper functions
|
|
10
|
+
const extractAggregationValues = (aggregationResponse, name) => {
|
|
11
|
+
const aggregation = aggregationResponse.aggregations?.[name] ||
|
|
12
|
+
aggregationResponse.aggregationData?.results?.find((r) => r.name === name);
|
|
13
|
+
return aggregation?.values?.results?.map((item) => item.value) || [];
|
|
14
|
+
};
|
|
15
|
+
const matchesAggregationName = (name, aggregationNames) => {
|
|
16
|
+
return aggregationNames.some(aggName => aggName.toLowerCase() === name.toLowerCase());
|
|
17
|
+
};
|
|
18
|
+
const sortChoicesIntelligently = (choices) => {
|
|
19
|
+
return [...choices].sort((a, b) => {
|
|
20
|
+
const aIsNumber = /^\d+$/.test(a.name);
|
|
21
|
+
const bIsNumber = /^\d+$/.test(b.name);
|
|
22
|
+
if (aIsNumber && bIsNumber) {
|
|
23
|
+
return parseInt(b.name) - parseInt(a.name);
|
|
24
|
+
}
|
|
25
|
+
if (aIsNumber && !bIsNumber)
|
|
26
|
+
return -1;
|
|
27
|
+
if (!aIsNumber && bIsNumber)
|
|
28
|
+
return 1;
|
|
29
|
+
return a.name.localeCompare(b.name);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
const buildCategoryFilter = (categoryId) => {
|
|
33
|
+
if (!categoryId) {
|
|
34
|
+
return { visible: true };
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
visible: true,
|
|
38
|
+
'allCategoriesInfo.categories': {
|
|
39
|
+
$matchItems: [{ _id: { $in: [categoryId] } }],
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
exports.CatalogOptionsServiceDefinition = (0, services_definitions_1.defineService)('catalogOptions');
|
|
44
|
+
exports.CatalogOptionsService = services_definitions_1.implementService.withConfig()(exports.CatalogOptionsServiceDefinition, ({ getService }) => {
|
|
45
|
+
const signalsService = getService(signals_1.SignalsServiceDefinition);
|
|
46
|
+
const catalogOptions = signalsService.signal(null);
|
|
47
|
+
const isLoading = signalsService.signal(false);
|
|
48
|
+
const error = signalsService.signal(null);
|
|
49
|
+
const loadCatalogOptions = async (categoryId) => {
|
|
50
|
+
isLoading.set(true);
|
|
51
|
+
error.set(null);
|
|
52
|
+
try {
|
|
53
|
+
// Step 1: Get unique option and choice names from catalog via aggregation (no products returned)
|
|
54
|
+
const aggregationRequest = {
|
|
55
|
+
aggregations: [
|
|
56
|
+
{
|
|
57
|
+
name: 'optionNames',
|
|
58
|
+
fieldPath: 'options.name',
|
|
59
|
+
type: auto_sdk_stores_products_v_3_1.SortType.VALUE,
|
|
60
|
+
value: {
|
|
61
|
+
limit: 20,
|
|
62
|
+
sortType: auto_sdk_stores_products_v_3_1.SortType.VALUE,
|
|
63
|
+
sortDirection: auto_sdk_stores_products_v_3_1.SortDirection.ASC,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'choiceNames',
|
|
68
|
+
fieldPath: 'options.choicesSettings.choices.name',
|
|
69
|
+
type: auto_sdk_stores_products_v_3_1.SortType.VALUE,
|
|
70
|
+
value: {
|
|
71
|
+
limit: 50,
|
|
72
|
+
sortType: auto_sdk_stores_products_v_3_1.SortType.VALUE,
|
|
73
|
+
sortDirection: auto_sdk_stores_products_v_3_1.SortDirection.ASC,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'inventoryStatus',
|
|
78
|
+
fieldPath: 'inventory.availabilityStatus',
|
|
79
|
+
type: auto_sdk_stores_products_v_3_1.SortType.VALUE,
|
|
80
|
+
value: {
|
|
81
|
+
limit: 10,
|
|
82
|
+
sortType: auto_sdk_stores_products_v_3_1.SortType.VALUE,
|
|
83
|
+
sortDirection: auto_sdk_stores_products_v_3_1.SortDirection.ASC,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
filter: buildCategoryFilter(categoryId),
|
|
88
|
+
includeProducts: false,
|
|
89
|
+
cursorPaging: { limit: 0 },
|
|
90
|
+
};
|
|
91
|
+
const aggregationResponse = await (0, auto_sdk_stores_products_v_3_1.searchProducts)(aggregationRequest);
|
|
92
|
+
const optionNames = extractAggregationValues(aggregationResponse, 'optionNames');
|
|
93
|
+
const choiceNames = extractAggregationValues(aggregationResponse, 'choiceNames');
|
|
94
|
+
const inventoryStatuses = extractAggregationValues(aggregationResponse, 'inventoryStatus');
|
|
95
|
+
// Step 2: Get option structure from customizations API
|
|
96
|
+
const customizationsResponse = await (0, auto_sdk_stores_customizations_v_3_1.queryCustomizations)().find();
|
|
97
|
+
const customizations = customizationsResponse.items || [];
|
|
98
|
+
// Step 3: Build options by matching customizations with aggregation data
|
|
99
|
+
const options = customizations
|
|
100
|
+
.filter(customization => customization.name &&
|
|
101
|
+
customization._id &&
|
|
102
|
+
customization.customizationType ===
|
|
103
|
+
auto_sdk_stores_customizations_v_3_1.CustomizationType.PRODUCT_OPTION &&
|
|
104
|
+
matchesAggregationName(customization.name, optionNames))
|
|
105
|
+
.map(customization => {
|
|
106
|
+
const choices = (customization.choicesSettings?.choices || [])
|
|
107
|
+
.filter(choice => choice._id &&
|
|
108
|
+
choice.name &&
|
|
109
|
+
matchesAggregationName(choice.name, choiceNames))
|
|
110
|
+
.map(choice => ({
|
|
111
|
+
id: choice._id,
|
|
112
|
+
name: choice.name,
|
|
113
|
+
colorCode: choice.colorCode,
|
|
114
|
+
}));
|
|
115
|
+
return {
|
|
116
|
+
id: customization._id,
|
|
117
|
+
name: customization.name,
|
|
118
|
+
choices: sortChoicesIntelligently(choices),
|
|
119
|
+
optionRenderType: customization.customizationRenderType,
|
|
120
|
+
};
|
|
121
|
+
})
|
|
122
|
+
.filter(option => option.choices.length > 0);
|
|
123
|
+
// Step 4: Add inventory filter if there are multiple inventory statuses
|
|
124
|
+
if (inventoryStatuses.length > 1) {
|
|
125
|
+
const inventoryChoices = inventoryStatuses.map(status => ({
|
|
126
|
+
id: status.toUpperCase(), // Use uppercase to match actual availabilityStatus values
|
|
127
|
+
name: status.toUpperCase(), // Use raw status value - UI components will handle display conversion
|
|
128
|
+
}));
|
|
129
|
+
options.push({
|
|
130
|
+
id: 'inventory-filter',
|
|
131
|
+
name: 'Availability',
|
|
132
|
+
choices: inventoryChoices,
|
|
133
|
+
optionRenderType: auto_sdk_stores_products_v_3_1.ModifierRenderType.TEXT_CHOICES,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
catalogOptions.set(options);
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
console.error('Failed to load catalog options:', err);
|
|
140
|
+
error.set(err instanceof Error ? err.message : 'Failed to load catalog options');
|
|
141
|
+
catalogOptions.set([]);
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
isLoading.set(false);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
return {
|
|
148
|
+
catalogOptions,
|
|
149
|
+
isLoading,
|
|
150
|
+
error,
|
|
151
|
+
loadCatalogOptions,
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
async function loadCatalogOptionsServiceConfig() {
|
|
155
|
+
return {};
|
|
156
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ServiceFactoryConfig } from '@wix/services-definitions';
|
|
2
|
+
import type { Signal } from '../../Signal';
|
|
3
|
+
export interface CatalogPriceRange {
|
|
4
|
+
minPrice: number;
|
|
5
|
+
maxPrice: number;
|
|
6
|
+
}
|
|
7
|
+
export interface CatalogPriceRangeServiceAPI {
|
|
8
|
+
catalogPriceRange: Signal<CatalogPriceRange | null>;
|
|
9
|
+
isLoading: Signal<boolean>;
|
|
10
|
+
error: Signal<string | null>;
|
|
11
|
+
loadCatalogPriceRange: (categoryId?: string) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare const CatalogPriceRangeServiceDefinition: string & {
|
|
14
|
+
__api: CatalogPriceRangeServiceAPI;
|
|
15
|
+
__config: {};
|
|
16
|
+
isServiceDefinition?: boolean;
|
|
17
|
+
} & CatalogPriceRangeServiceAPI;
|
|
18
|
+
export declare const CatalogPriceRangeService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
19
|
+
__api: CatalogPriceRangeServiceAPI;
|
|
20
|
+
__config: {};
|
|
21
|
+
isServiceDefinition?: boolean;
|
|
22
|
+
} & CatalogPriceRangeServiceAPI, {}, import("@wix/services-definitions").ThreadMode.MAIN>;
|
|
23
|
+
export declare function loadCatalogPriceRangeServiceConfig(): Promise<ServiceFactoryConfig<typeof CatalogPriceRangeService>>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CatalogPriceRangeService = exports.CatalogPriceRangeServiceDefinition = void 0;
|
|
4
|
+
exports.loadCatalogPriceRangeServiceConfig = loadCatalogPriceRangeServiceConfig;
|
|
5
|
+
const services_definitions_1 = require("@wix/services-definitions");
|
|
6
|
+
const signals_1 = require("@wix/services-definitions/core-services/signals");
|
|
7
|
+
const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
|
|
8
|
+
// Helper function to extract scalar aggregation values
|
|
9
|
+
const extractScalarAggregationValue = (aggregationResponse, name) => {
|
|
10
|
+
const aggregation = aggregationResponse.aggregations?.[name] ||
|
|
11
|
+
aggregationResponse.aggregationData?.results?.find((r) => r.name === name);
|
|
12
|
+
const value = aggregation?.scalar?.value;
|
|
13
|
+
return value !== undefined && value !== null ? parseFloat(value) : null;
|
|
14
|
+
};
|
|
15
|
+
const buildCategoryFilter = (categoryId) => {
|
|
16
|
+
if (!categoryId) {
|
|
17
|
+
return { visible: true };
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
visible: true,
|
|
21
|
+
'allCategoriesInfo.categories': {
|
|
22
|
+
$matchItems: [{ _id: { $in: [categoryId] } }],
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
exports.CatalogPriceRangeServiceDefinition = (0, services_definitions_1.defineService)('catalogPriceRange');
|
|
27
|
+
exports.CatalogPriceRangeService = services_definitions_1.implementService.withConfig()(exports.CatalogPriceRangeServiceDefinition, ({ getService }) => {
|
|
28
|
+
const signalsService = getService(signals_1.SignalsServiceDefinition);
|
|
29
|
+
// Signal declarations
|
|
30
|
+
const catalogPriceRange = signalsService.signal(null);
|
|
31
|
+
const isLoading = signalsService.signal(false);
|
|
32
|
+
const error = signalsService.signal(null);
|
|
33
|
+
/**
|
|
34
|
+
* Load the catalog-wide price range using a single aggregation query
|
|
35
|
+
* This fetches min/max prices from ALL products in the catalog using SCALAR aggregations
|
|
36
|
+
*/
|
|
37
|
+
const loadCatalogPriceRange = async (categoryId) => {
|
|
38
|
+
isLoading.set(true);
|
|
39
|
+
error.set(null);
|
|
40
|
+
try {
|
|
41
|
+
// Single aggregation request to get both min and max prices (no products returned)
|
|
42
|
+
const aggregationRequest = {
|
|
43
|
+
aggregations: [
|
|
44
|
+
{
|
|
45
|
+
name: 'minPrice',
|
|
46
|
+
fieldPath: 'actualPriceRange.minValue.amount',
|
|
47
|
+
type: 'SCALAR',
|
|
48
|
+
scalar: { type: 'MIN' },
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'maxPrice',
|
|
52
|
+
fieldPath: 'actualPriceRange.maxValue.amount',
|
|
53
|
+
type: 'SCALAR',
|
|
54
|
+
scalar: { type: 'MAX' },
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
filter: buildCategoryFilter(categoryId),
|
|
58
|
+
includeProducts: false,
|
|
59
|
+
cursorPaging: { limit: 0 },
|
|
60
|
+
};
|
|
61
|
+
const aggregationResponse = await (0, auto_sdk_stores_products_v_3_1.searchProducts)(aggregationRequest);
|
|
62
|
+
const minPrice = extractScalarAggregationValue(aggregationResponse, 'minPrice');
|
|
63
|
+
const maxPrice = extractScalarAggregationValue(aggregationResponse, 'maxPrice');
|
|
64
|
+
// Only set price range if we found valid prices
|
|
65
|
+
if (minPrice !== null &&
|
|
66
|
+
maxPrice !== null &&
|
|
67
|
+
(minPrice > 0 || maxPrice > 0)) {
|
|
68
|
+
catalogPriceRange.set({
|
|
69
|
+
minPrice,
|
|
70
|
+
maxPrice,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// No products found or no valid prices - don't show the filter
|
|
75
|
+
catalogPriceRange.set(null);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
console.error('Failed to load catalog price range:', err);
|
|
80
|
+
error.set(err instanceof Error ? err.message : 'Failed to load price range');
|
|
81
|
+
// Don't set fallback values - let the component handle the error state
|
|
82
|
+
catalogPriceRange.set(null);
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
isLoading.set(false);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
catalogPriceRange,
|
|
90
|
+
isLoading,
|
|
91
|
+
error,
|
|
92
|
+
loadCatalogPriceRange,
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
async function loadCatalogPriceRangeServiceConfig() {
|
|
96
|
+
return {};
|
|
97
|
+
}
|