@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,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SocialSharingService = exports.SocialSharingServiceDefinition = void 0;
|
|
4
|
+
exports.loadSocialSharingServiceConfig = loadSocialSharingServiceConfig;
|
|
5
|
+
const services_definitions_1 = require("@wix/services-definitions");
|
|
6
|
+
const signals_1 = require("@wix/services-definitions/core-services/signals");
|
|
7
|
+
const social_platform_enums_1 = require("../enums/social-platform-enums");
|
|
8
|
+
exports.SocialSharingServiceDefinition = (0, services_definitions_1.defineService)('socialSharing');
|
|
9
|
+
exports.SocialSharingService = services_definitions_1.implementService.withConfig()(exports.SocialSharingServiceDefinition, ({ getService }) => {
|
|
10
|
+
const signalsService = getService(signals_1.SignalsServiceDefinition);
|
|
11
|
+
// Platform metadata is handled in components layer, only business logic here
|
|
12
|
+
const availablePlatforms = signalsService.signal([
|
|
13
|
+
{
|
|
14
|
+
name: 'Facebook',
|
|
15
|
+
icon: 'facebook',
|
|
16
|
+
color: '#1877F2',
|
|
17
|
+
shareUrl: social_platform_enums_1.SocialPlatformShareUrl.FACEBOOK,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'Twitter',
|
|
21
|
+
icon: 'twitter',
|
|
22
|
+
color: '#1DA1F2',
|
|
23
|
+
shareUrl: social_platform_enums_1.SocialPlatformShareUrl.TWITTER,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'LinkedIn',
|
|
27
|
+
icon: 'linkedin',
|
|
28
|
+
color: '#0A66C2',
|
|
29
|
+
shareUrl: social_platform_enums_1.SocialPlatformShareUrl.LINKEDIN,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'WhatsApp',
|
|
33
|
+
icon: 'whatsapp',
|
|
34
|
+
color: '#25D366',
|
|
35
|
+
shareUrl: social_platform_enums_1.SocialPlatformShareUrl.WHATSAPP,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'Email',
|
|
39
|
+
icon: 'mail',
|
|
40
|
+
color: '#EA4335',
|
|
41
|
+
shareUrl: social_platform_enums_1.SocialPlatformShareUrl.EMAIL,
|
|
42
|
+
},
|
|
43
|
+
]);
|
|
44
|
+
const shareCount = signalsService.signal(0);
|
|
45
|
+
const lastSharedPlatform = signalsService.signal(null);
|
|
46
|
+
const openShareWindow = (url, platform) => {
|
|
47
|
+
const width = 600;
|
|
48
|
+
const height = 400;
|
|
49
|
+
const left = (window.screen.width - width) / 2;
|
|
50
|
+
const top = (window.screen.height - height) / 2;
|
|
51
|
+
window.open(url, `share-${platform}`, `width=${width},height=${height},left=${left},top=${top},scrollbars=yes,resizable=yes`);
|
|
52
|
+
trackShare(platform);
|
|
53
|
+
};
|
|
54
|
+
const shareToFacebook = (url, title, description) => {
|
|
55
|
+
const shareUrl = new URL(social_platform_enums_1.SocialPlatformShareUrl.FACEBOOK);
|
|
56
|
+
shareUrl.searchParams.set('u', url);
|
|
57
|
+
shareUrl.searchParams.set('quote', `${title}${description ? ` - ${description}` : ''}`);
|
|
58
|
+
openShareWindow(shareUrl.toString(), social_platform_enums_1.SocialPlatform.FACEBOOK);
|
|
59
|
+
};
|
|
60
|
+
const shareToTwitter = (url, text, hashtags) => {
|
|
61
|
+
const shareUrl = new URL(social_platform_enums_1.SocialPlatformShareUrl.TWITTER);
|
|
62
|
+
shareUrl.searchParams.set('url', url);
|
|
63
|
+
shareUrl.searchParams.set('text', text);
|
|
64
|
+
if (hashtags && hashtags.length > 0) {
|
|
65
|
+
shareUrl.searchParams.set('hashtags', hashtags.join(','));
|
|
66
|
+
}
|
|
67
|
+
openShareWindow(shareUrl.toString(), social_platform_enums_1.SocialPlatform.TWITTER);
|
|
68
|
+
};
|
|
69
|
+
const shareToLinkedIn = (url, title, summary) => {
|
|
70
|
+
const shareUrl = new URL(social_platform_enums_1.SocialPlatformShareUrl.LINKEDIN);
|
|
71
|
+
shareUrl.searchParams.set('url', url);
|
|
72
|
+
shareUrl.searchParams.set('title', title);
|
|
73
|
+
if (summary) {
|
|
74
|
+
shareUrl.searchParams.set('summary', summary);
|
|
75
|
+
}
|
|
76
|
+
openShareWindow(shareUrl.toString(), social_platform_enums_1.SocialPlatform.LINKEDIN);
|
|
77
|
+
};
|
|
78
|
+
const shareToWhatsApp = (url, text) => {
|
|
79
|
+
const message = `${text} ${url}`;
|
|
80
|
+
const shareUrl = `${social_platform_enums_1.SocialPlatformShareUrl.WHATSAPP}?text=${encodeURIComponent(message)}`;
|
|
81
|
+
openShareWindow(shareUrl, social_platform_enums_1.SocialPlatform.WHATSAPP);
|
|
82
|
+
};
|
|
83
|
+
const shareToEmail = (url, subject, body) => {
|
|
84
|
+
const emailBody = `${body}\n\n${url}`;
|
|
85
|
+
const mailtoUrl = `${social_platform_enums_1.SocialPlatformShareUrl.EMAIL}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(emailBody)}`;
|
|
86
|
+
window.location.href = mailtoUrl;
|
|
87
|
+
trackShare(social_platform_enums_1.SocialPlatform.EMAIL);
|
|
88
|
+
};
|
|
89
|
+
const copyToClipboard = async (url) => {
|
|
90
|
+
try {
|
|
91
|
+
await navigator.clipboard.writeText(url);
|
|
92
|
+
trackShare(social_platform_enums_1.SocialPlatform.CLIPBOARD);
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
console.error('Failed to copy to clipboard:', err);
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const shareNative = async (data) => {
|
|
101
|
+
try {
|
|
102
|
+
if (navigator.share) {
|
|
103
|
+
await navigator.share(data);
|
|
104
|
+
trackShare(social_platform_enums_1.SocialPlatform.NATIVE);
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
console.error('Failed to share natively:', err);
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const trackShare = (platform) => {
|
|
115
|
+
const currentCount = shareCount.get();
|
|
116
|
+
shareCount.set(currentCount + 1);
|
|
117
|
+
lastSharedPlatform.set(platform);
|
|
118
|
+
console.log(`Shared to ${platform} - Total shares: ${currentCount + 1}`);
|
|
119
|
+
};
|
|
120
|
+
return {
|
|
121
|
+
availablePlatforms,
|
|
122
|
+
shareCount,
|
|
123
|
+
lastSharedPlatform,
|
|
124
|
+
shareToFacebook,
|
|
125
|
+
shareToTwitter,
|
|
126
|
+
shareToLinkedIn,
|
|
127
|
+
shareToWhatsApp,
|
|
128
|
+
shareToEmail,
|
|
129
|
+
copyToClipboard,
|
|
130
|
+
shareNative,
|
|
131
|
+
trackShare,
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
async function loadSocialSharingServiceConfig(productName, productUrl, productDescription, productImage) {
|
|
135
|
+
return {
|
|
136
|
+
productName,
|
|
137
|
+
productUrl,
|
|
138
|
+
productDescription,
|
|
139
|
+
productImage,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Signal } from '../../Signal';
|
|
2
|
+
import { SortType } from '../enums/sort-enums';
|
|
3
|
+
export type SortBy = SortType;
|
|
4
|
+
export interface SortServiceAPI {
|
|
5
|
+
currentSort: Signal<SortBy>;
|
|
6
|
+
setSortBy: (sortBy: SortBy) => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const SortServiceDefinition: string & {
|
|
9
|
+
__api: SortServiceAPI;
|
|
10
|
+
__config: {};
|
|
11
|
+
isServiceDefinition?: boolean;
|
|
12
|
+
} & SortServiceAPI;
|
|
13
|
+
export declare const defaultSort: SortBy;
|
|
14
|
+
export declare const SortService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
15
|
+
__api: SortServiceAPI;
|
|
16
|
+
__config: {};
|
|
17
|
+
isServiceDefinition?: boolean;
|
|
18
|
+
} & SortServiceAPI, {
|
|
19
|
+
initialSort?: SortBy;
|
|
20
|
+
}, import("@wix/services-definitions").ThreadMode.MAIN>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SortService = exports.defaultSort = exports.SortServiceDefinition = void 0;
|
|
4
|
+
const services_definitions_1 = require("@wix/services-definitions");
|
|
5
|
+
const signals_1 = require("@wix/services-definitions/core-services/signals");
|
|
6
|
+
const url_params_1 = require("../utils/url-params");
|
|
7
|
+
const sort_enums_1 = require("../enums/sort-enums");
|
|
8
|
+
exports.SortServiceDefinition = (0, services_definitions_1.defineService)('sort');
|
|
9
|
+
exports.defaultSort = sort_enums_1.DEFAULT_SORT_TYPE;
|
|
10
|
+
exports.SortService = services_definitions_1.implementService.withConfig()(exports.SortServiceDefinition, ({ getService, config }) => {
|
|
11
|
+
const signalsService = getService(signals_1.SignalsServiceDefinition);
|
|
12
|
+
const currentSort = signalsService.signal((config.initialSort || exports.defaultSort));
|
|
13
|
+
const setSortBy = async (sortBy) => {
|
|
14
|
+
currentSort.set(sortBy);
|
|
15
|
+
// Update URL with sort parameter
|
|
16
|
+
const currentParams = url_params_1.URLParamsUtils.getURLParams();
|
|
17
|
+
const urlParams = { ...currentParams };
|
|
18
|
+
if (sortBy !== sort_enums_1.SortType.NEWEST) {
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
urlParams.sort = sortBy;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
delete urlParams.sort;
|
|
25
|
+
}
|
|
26
|
+
url_params_1.URLParamsUtils.updateURL(urlParams);
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
currentSort,
|
|
30
|
+
setSortBy,
|
|
31
|
+
};
|
|
32
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.URLParamsUtils = void 0;
|
|
4
|
+
class URLParamsUtils {
|
|
5
|
+
static parseSearchParams(searchParams) {
|
|
6
|
+
const params = {};
|
|
7
|
+
// Parse all parameters
|
|
8
|
+
for (const [key, value] of searchParams.entries()) {
|
|
9
|
+
if (params[key]) {
|
|
10
|
+
// Convert to array if multiple values
|
|
11
|
+
if (Array.isArray(params[key])) {
|
|
12
|
+
params[key].push(value);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
params[key] = [params[key], value];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
params[key] = value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return params;
|
|
23
|
+
}
|
|
24
|
+
static updateURL(params) {
|
|
25
|
+
if (typeof window === "undefined")
|
|
26
|
+
return;
|
|
27
|
+
const url = new URL(window.location.href);
|
|
28
|
+
const urlParams = new URLSearchParams();
|
|
29
|
+
// Add all parameters
|
|
30
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
31
|
+
if (Array.isArray(value)) {
|
|
32
|
+
value.forEach((v) => urlParams.append(key, v));
|
|
33
|
+
}
|
|
34
|
+
else if (value) {
|
|
35
|
+
urlParams.set(key, value);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
// Update URL without page reload
|
|
39
|
+
const newURL = urlParams.toString()
|
|
40
|
+
? `${url.pathname}?${urlParams.toString()}`
|
|
41
|
+
: url.pathname;
|
|
42
|
+
window.history.replaceState({}, "", newURL);
|
|
43
|
+
}
|
|
44
|
+
static getURLParams() {
|
|
45
|
+
if (typeof window === "undefined")
|
|
46
|
+
return {};
|
|
47
|
+
return this.parseSearchParams(new URLSearchParams(window.location.search));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.URLParamsUtils = URLParamsUtils;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Business logic enums for social sharing platforms (headless layer)
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Enum for social sharing platforms (business identifiers)
|
|
6
|
+
*/
|
|
7
|
+
export declare enum SocialPlatform {
|
|
8
|
+
FACEBOOK = "facebook",
|
|
9
|
+
TWITTER = "twitter",
|
|
10
|
+
LINKEDIN = "linkedin",
|
|
11
|
+
WHATSAPP = "whatsapp",
|
|
12
|
+
EMAIL = "email",
|
|
13
|
+
CLIPBOARD = "clipboard",
|
|
14
|
+
NATIVE = "native"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Enum for social platform share URLs (business logic)
|
|
18
|
+
*/
|
|
19
|
+
export declare enum SocialPlatformShareUrl {
|
|
20
|
+
FACEBOOK = "https://www.facebook.com/sharer/sharer.php",
|
|
21
|
+
TWITTER = "https://twitter.com/intent/tweet",
|
|
22
|
+
LINKEDIN = "https://www.linkedin.com/sharing/share-offsite/",
|
|
23
|
+
WHATSAPP = "https://wa.me/",
|
|
24
|
+
EMAIL = "mailto:"
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Business logic enums for social sharing platforms (headless layer)
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Enum for social sharing platforms (business identifiers)
|
|
6
|
+
*/
|
|
7
|
+
export var SocialPlatform;
|
|
8
|
+
(function (SocialPlatform) {
|
|
9
|
+
SocialPlatform["FACEBOOK"] = "facebook";
|
|
10
|
+
SocialPlatform["TWITTER"] = "twitter";
|
|
11
|
+
SocialPlatform["LINKEDIN"] = "linkedin";
|
|
12
|
+
SocialPlatform["WHATSAPP"] = "whatsapp";
|
|
13
|
+
SocialPlatform["EMAIL"] = "email";
|
|
14
|
+
SocialPlatform["CLIPBOARD"] = "clipboard";
|
|
15
|
+
SocialPlatform["NATIVE"] = "native";
|
|
16
|
+
})(SocialPlatform || (SocialPlatform = {}));
|
|
17
|
+
/**
|
|
18
|
+
* Enum for social platform share URLs (business logic)
|
|
19
|
+
*/
|
|
20
|
+
export var SocialPlatformShareUrl;
|
|
21
|
+
(function (SocialPlatformShareUrl) {
|
|
22
|
+
SocialPlatformShareUrl["FACEBOOK"] = "https://www.facebook.com/sharer/sharer.php";
|
|
23
|
+
SocialPlatformShareUrl["TWITTER"] = "https://twitter.com/intent/tweet";
|
|
24
|
+
SocialPlatformShareUrl["LINKEDIN"] = "https://www.linkedin.com/sharing/share-offsite/";
|
|
25
|
+
SocialPlatformShareUrl["WHATSAPP"] = "https://wa.me/";
|
|
26
|
+
SocialPlatformShareUrl["EMAIL"] = "mailto:";
|
|
27
|
+
})(SocialPlatformShareUrl || (SocialPlatformShareUrl = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum for sort types used in the store
|
|
3
|
+
* Note: Cannot use SDK SortType as it's for aggregations (COUNT/VALUE)
|
|
4
|
+
* while this enum represents user-facing sort options
|
|
5
|
+
*/
|
|
6
|
+
export declare enum SortType {
|
|
7
|
+
NEWEST = "newest",
|
|
8
|
+
NAME_ASC = "name_asc",
|
|
9
|
+
NAME_DESC = "name_desc",
|
|
10
|
+
PRICE_ASC = "price_asc",
|
|
11
|
+
PRICE_DESC = "price_desc",
|
|
12
|
+
RECOMMENDED = "recommended"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Default sort type
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_SORT_TYPE = SortType.NEWEST;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum for sort types used in the store
|
|
3
|
+
* Note: Cannot use SDK SortType as it's for aggregations (COUNT/VALUE)
|
|
4
|
+
* while this enum represents user-facing sort options
|
|
5
|
+
*/
|
|
6
|
+
export var SortType;
|
|
7
|
+
(function (SortType) {
|
|
8
|
+
SortType["NEWEST"] = "newest";
|
|
9
|
+
SortType["NAME_ASC"] = "name_asc";
|
|
10
|
+
SortType["NAME_DESC"] = "name_desc";
|
|
11
|
+
SortType["PRICE_ASC"] = "price_asc";
|
|
12
|
+
SortType["PRICE_DESC"] = "price_desc";
|
|
13
|
+
SortType["RECOMMENDED"] = "recommended";
|
|
14
|
+
})(SortType || (SortType = {}));
|
|
15
|
+
/**
|
|
16
|
+
* Default sort type
|
|
17
|
+
*/
|
|
18
|
+
export const DEFAULT_SORT_TYPE = SortType.NEWEST;
|
package/dist/react/BuyNow.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type RedirectToCheckout = () => void;
|
|
2
1
|
/**
|
|
3
2
|
* Props passed to the render function of the BuyNow component
|
|
4
3
|
*/
|
|
@@ -8,7 +7,7 @@ export interface BuyNowRenderProps {
|
|
|
8
7
|
/** The name of the product being purchased */
|
|
9
8
|
productName: string;
|
|
10
9
|
/** Function to redirect the user to the checkout page */
|
|
11
|
-
redirectToCheckout:
|
|
10
|
+
redirectToCheckout: () => void;
|
|
12
11
|
/** The error message if the buy now operation fails */
|
|
13
12
|
error: string | null;
|
|
14
13
|
/** The price of the product being purchased */
|
|
@@ -20,13 +19,12 @@ export interface BuyNowRenderProps {
|
|
|
20
19
|
/** Whether the product is available for pre-order */
|
|
21
20
|
preOrderAvailable: boolean;
|
|
22
21
|
}
|
|
23
|
-
export type BuyNowChildren = (props: BuyNowRenderProps) => React.ReactNode;
|
|
24
22
|
/**
|
|
25
23
|
* Props for the BuyNow component
|
|
26
24
|
*/
|
|
27
25
|
export interface BuyNowProps {
|
|
28
26
|
/** Render function that receives buy now state and actions */
|
|
29
|
-
children:
|
|
27
|
+
children: (props: BuyNowRenderProps) => React.ReactNode;
|
|
30
28
|
}
|
|
31
29
|
/**
|
|
32
30
|
* A headless component that provides buy now functionality using the render props pattern.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Category } from '@wix/auto_sdk_categories_categories';
|
|
2
|
+
import React, { type ReactNode } from 'react';
|
|
3
|
+
export interface CategoryListProps {
|
|
4
|
+
children: (data: {
|
|
5
|
+
categories: Category[];
|
|
6
|
+
selectedCategory: string | null;
|
|
7
|
+
setSelectedCategory: (categoryId: string | null) => void;
|
|
8
|
+
}) => ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Headless component for displaying a list of categories
|
|
12
|
+
*
|
|
13
|
+
* @component
|
|
14
|
+
*/
|
|
15
|
+
export declare const List: React.FC<CategoryListProps>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useService } from '@wix/services-manager-react';
|
|
3
|
+
import { CategoryServiceDefinition } from '../services/category-service';
|
|
4
|
+
/**
|
|
5
|
+
* Headless component for displaying a list of categories
|
|
6
|
+
*
|
|
7
|
+
* @component
|
|
8
|
+
*/
|
|
9
|
+
export const List = ({ children }) => {
|
|
10
|
+
const service = useService(CategoryServiceDefinition);
|
|
11
|
+
const categories = service.categories.get();
|
|
12
|
+
const selectedCategory = service.selectedCategory.get();
|
|
13
|
+
return (_jsx(_Fragment, { children: children({
|
|
14
|
+
selectedCategory,
|
|
15
|
+
categories,
|
|
16
|
+
setSelectedCategory: service.setSelectedCategory,
|
|
17
|
+
}) }));
|
|
18
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { type V3Product } from '@wix/auto_sdk_stores_products-v-3';
|
|
2
|
+
/**
|
|
3
|
+
* Props for Grid headless component
|
|
4
|
+
*/
|
|
5
|
+
export interface GridProps {
|
|
6
|
+
/** Render prop function that receives product grid data */
|
|
7
|
+
children: (props: GridRenderProps) => React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Render props for Grid component
|
|
11
|
+
*/
|
|
12
|
+
export interface GridRenderProps {
|
|
13
|
+
/** Array of products */
|
|
14
|
+
products: V3Product[];
|
|
15
|
+
/** Whether products are loading */
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
/** Error message if any */
|
|
18
|
+
error: string | null;
|
|
19
|
+
/** Whether there are no products */
|
|
20
|
+
isEmpty: boolean;
|
|
21
|
+
/** Total number of products */
|
|
22
|
+
totalProducts: number;
|
|
23
|
+
/** Whether collection has products */
|
|
24
|
+
hasProducts: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Headless component for product grid
|
|
28
|
+
*
|
|
29
|
+
* @component
|
|
30
|
+
*/
|
|
31
|
+
export declare const Grid: (props: GridProps) => import("react").ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* Props for Item headless component
|
|
34
|
+
*/
|
|
35
|
+
export interface ItemProps {
|
|
36
|
+
/** Product data */
|
|
37
|
+
product: V3Product;
|
|
38
|
+
/** Render prop function that receives product item data */
|
|
39
|
+
children: (props: ItemRenderProps) => React.ReactNode;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Render props for Item component
|
|
43
|
+
*/
|
|
44
|
+
export interface ItemRenderProps {
|
|
45
|
+
/** Product ID */
|
|
46
|
+
id: string;
|
|
47
|
+
/** Product title */
|
|
48
|
+
title: string;
|
|
49
|
+
/** Product slug for URL */
|
|
50
|
+
slug: string;
|
|
51
|
+
/** Main product image URL */
|
|
52
|
+
image: string | null;
|
|
53
|
+
/** Product price */
|
|
54
|
+
price: string;
|
|
55
|
+
/** Compare at price (for strikethrough) */
|
|
56
|
+
compareAtPrice: string | null;
|
|
57
|
+
/** Product description */
|
|
58
|
+
description: string;
|
|
59
|
+
/** Whether product is available */
|
|
60
|
+
available: boolean;
|
|
61
|
+
/** Product URL */
|
|
62
|
+
href: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Headless component for individual product item
|
|
66
|
+
*
|
|
67
|
+
* @component
|
|
68
|
+
*/
|
|
69
|
+
export declare const Item: (props: ItemProps) => import("react").ReactNode;
|
|
70
|
+
/**
|
|
71
|
+
* Props for LoadMore headless component
|
|
72
|
+
*/
|
|
73
|
+
export interface LoadMoreProps {
|
|
74
|
+
/** Render prop function that receives load more data */
|
|
75
|
+
children: (props: LoadMoreRenderProps) => React.ReactNode;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Render props for LoadMore component
|
|
79
|
+
*/
|
|
80
|
+
export interface LoadMoreRenderProps {
|
|
81
|
+
/** Function to load more products */
|
|
82
|
+
loadMore: () => Promise<void>;
|
|
83
|
+
/** Function to refresh products */
|
|
84
|
+
refresh: () => Promise<void>;
|
|
85
|
+
/** Whether load more is currently loading */
|
|
86
|
+
isLoading: boolean;
|
|
87
|
+
/** Whether there are products */
|
|
88
|
+
hasProducts: boolean;
|
|
89
|
+
/** Total number of products currently loaded */
|
|
90
|
+
totalProducts: number;
|
|
91
|
+
/** Whether there are more products to load */
|
|
92
|
+
hasMoreProducts: boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Headless component for load more products functionality
|
|
96
|
+
* Note: V3 API uses simplified loading without traditional pagination
|
|
97
|
+
*
|
|
98
|
+
* @component
|
|
99
|
+
*/
|
|
100
|
+
export declare const LoadMore: (props: LoadMoreProps) => import("react").ReactNode;
|
|
101
|
+
/**
|
|
102
|
+
* Props for Header headless component
|
|
103
|
+
*/
|
|
104
|
+
export interface HeaderProps {
|
|
105
|
+
/** Render prop function that receives collection header data */
|
|
106
|
+
children: (props: HeaderRenderProps) => React.ReactNode;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Render props for Header component
|
|
110
|
+
*/
|
|
111
|
+
export interface HeaderRenderProps {
|
|
112
|
+
/** Total number of products */
|
|
113
|
+
totalProducts: number;
|
|
114
|
+
/** Whether collection is loading */
|
|
115
|
+
isLoading: boolean;
|
|
116
|
+
/** Whether collection has products */
|
|
117
|
+
hasProducts: boolean;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Headless component for collection header with product count
|
|
121
|
+
*
|
|
122
|
+
* @component
|
|
123
|
+
*/
|
|
124
|
+
export declare const Header: (props: HeaderProps) => import("react").ReactNode;
|
|
125
|
+
/**
|
|
126
|
+
* Props for Actions headless component
|
|
127
|
+
*/
|
|
128
|
+
export interface ActionsProps {
|
|
129
|
+
/** Render prop function that receives collection actions data */
|
|
130
|
+
children: (props: ActionsRenderProps) => React.ReactNode;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Render props for Actions component
|
|
134
|
+
*/
|
|
135
|
+
export interface ActionsRenderProps {
|
|
136
|
+
/** Function to refresh the collection */
|
|
137
|
+
refresh: () => Promise<void>;
|
|
138
|
+
/** Function to load more products */
|
|
139
|
+
loadMore: () => Promise<void>;
|
|
140
|
+
/** Whether actions are loading */
|
|
141
|
+
isLoading: boolean;
|
|
142
|
+
/** Error message if any */
|
|
143
|
+
error: string | null;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Headless component for collection actions (refresh, load more)
|
|
147
|
+
* Replaces traditional pagination for V3 API
|
|
148
|
+
*
|
|
149
|
+
* @component
|
|
150
|
+
*/
|
|
151
|
+
export declare const Actions: (props: ActionsProps) => import("react").ReactNode;
|