@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,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./sort-enums"), exports);
|
|
18
|
+
__exportStar(require("./social-platform-enums"), exports);
|
|
@@ -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,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Business logic enums for social sharing platforms (headless layer)
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SocialPlatformShareUrl = exports.SocialPlatform = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Enum for social sharing platforms (business identifiers)
|
|
9
|
+
*/
|
|
10
|
+
var SocialPlatform;
|
|
11
|
+
(function (SocialPlatform) {
|
|
12
|
+
SocialPlatform["FACEBOOK"] = "facebook";
|
|
13
|
+
SocialPlatform["TWITTER"] = "twitter";
|
|
14
|
+
SocialPlatform["LINKEDIN"] = "linkedin";
|
|
15
|
+
SocialPlatform["WHATSAPP"] = "whatsapp";
|
|
16
|
+
SocialPlatform["EMAIL"] = "email";
|
|
17
|
+
SocialPlatform["CLIPBOARD"] = "clipboard";
|
|
18
|
+
SocialPlatform["NATIVE"] = "native";
|
|
19
|
+
})(SocialPlatform || (exports.SocialPlatform = SocialPlatform = {}));
|
|
20
|
+
/**
|
|
21
|
+
* Enum for social platform share URLs (business logic)
|
|
22
|
+
*/
|
|
23
|
+
var SocialPlatformShareUrl;
|
|
24
|
+
(function (SocialPlatformShareUrl) {
|
|
25
|
+
SocialPlatformShareUrl["FACEBOOK"] = "https://www.facebook.com/sharer/sharer.php";
|
|
26
|
+
SocialPlatformShareUrl["TWITTER"] = "https://twitter.com/intent/tweet";
|
|
27
|
+
SocialPlatformShareUrl["LINKEDIN"] = "https://www.linkedin.com/sharing/share-offsite/";
|
|
28
|
+
SocialPlatformShareUrl["WHATSAPP"] = "https://wa.me/";
|
|
29
|
+
SocialPlatformShareUrl["EMAIL"] = "mailto:";
|
|
30
|
+
})(SocialPlatformShareUrl || (exports.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,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_SORT_TYPE = exports.SortType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Enum for sort types used in the store
|
|
6
|
+
* Note: Cannot use SDK SortType as it's for aggregations (COUNT/VALUE)
|
|
7
|
+
* while this enum represents user-facing sort options
|
|
8
|
+
*/
|
|
9
|
+
var SortType;
|
|
10
|
+
(function (SortType) {
|
|
11
|
+
SortType["NEWEST"] = "newest";
|
|
12
|
+
SortType["NAME_ASC"] = "name_asc";
|
|
13
|
+
SortType["NAME_DESC"] = "name_desc";
|
|
14
|
+
SortType["PRICE_ASC"] = "price_asc";
|
|
15
|
+
SortType["PRICE_DESC"] = "price_desc";
|
|
16
|
+
SortType["RECOMMENDED"] = "recommended";
|
|
17
|
+
})(SortType || (exports.SortType = SortType = {}));
|
|
18
|
+
/**
|
|
19
|
+
* Default sort type
|
|
20
|
+
*/
|
|
21
|
+
exports.DEFAULT_SORT_TYPE = SortType.NEWEST;
|
|
@@ -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,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.List = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
6
|
+
const category_service_1 = require("../services/category-service");
|
|
7
|
+
/**
|
|
8
|
+
* Headless component for displaying a list of categories
|
|
9
|
+
*
|
|
10
|
+
* @component
|
|
11
|
+
*/
|
|
12
|
+
const List = ({ children }) => {
|
|
13
|
+
const service = (0, services_manager_react_1.useService)(category_service_1.CategoryServiceDefinition);
|
|
14
|
+
const categories = service.categories.get();
|
|
15
|
+
const selectedCategory = service.selectedCategory.get();
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
|
|
17
|
+
selectedCategory,
|
|
18
|
+
categories,
|
|
19
|
+
setSelectedCategory: service.setSelectedCategory,
|
|
20
|
+
}) }));
|
|
21
|
+
};
|
|
22
|
+
exports.List = List;
|
|
@@ -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;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Actions = exports.Header = exports.LoadMore = exports.Item = exports.Grid = void 0;
|
|
4
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
5
|
+
const collection_service_1 = require("../services/collection-service");
|
|
6
|
+
const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
|
|
7
|
+
/**
|
|
8
|
+
* Headless component for product grid
|
|
9
|
+
*
|
|
10
|
+
* @component
|
|
11
|
+
*/
|
|
12
|
+
const Grid = (props) => {
|
|
13
|
+
const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
|
|
14
|
+
// Debug logging to help identify service issues
|
|
15
|
+
if (!service) {
|
|
16
|
+
console.error('CollectionService is undefined');
|
|
17
|
+
return props.children({
|
|
18
|
+
products: [],
|
|
19
|
+
isLoading: false,
|
|
20
|
+
error: 'Service not available',
|
|
21
|
+
isEmpty: true,
|
|
22
|
+
totalProducts: 0,
|
|
23
|
+
hasProducts: false,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
// Safely access service properties with error handling
|
|
27
|
+
try {
|
|
28
|
+
const productList = service.products?.get() || [];
|
|
29
|
+
const isLoading = service.isLoading?.get() || false;
|
|
30
|
+
const error = service.error?.get() || null;
|
|
31
|
+
const totalProducts = service.totalProducts?.get() || 0;
|
|
32
|
+
const hasProducts = service.hasProducts?.get() || false;
|
|
33
|
+
return props.children({
|
|
34
|
+
products: productList,
|
|
35
|
+
isLoading,
|
|
36
|
+
error,
|
|
37
|
+
isEmpty: !hasProducts && !isLoading,
|
|
38
|
+
totalProducts,
|
|
39
|
+
hasProducts,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
console.error('Error accessing service properties:', err);
|
|
44
|
+
return props.children({
|
|
45
|
+
products: [],
|
|
46
|
+
isLoading: false,
|
|
47
|
+
error: 'Failed to load products',
|
|
48
|
+
isEmpty: true,
|
|
49
|
+
totalProducts: 0,
|
|
50
|
+
hasProducts: false,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.Grid = Grid;
|
|
55
|
+
/**
|
|
56
|
+
* Headless component for individual product item
|
|
57
|
+
*
|
|
58
|
+
* @component
|
|
59
|
+
*/
|
|
60
|
+
const Item = (props) => {
|
|
61
|
+
const { product } = props;
|
|
62
|
+
// Use actual v3 API structure based on real data
|
|
63
|
+
// Images are in media.main.image, not media.itemsInfo.items
|
|
64
|
+
const image = product?.media?.main?.image || null;
|
|
65
|
+
// Create formatted price since formattedAmount is not available
|
|
66
|
+
const rawAmount = product.actualPriceRange?.minValue?.amount;
|
|
67
|
+
const price = rawAmount ? `$${rawAmount}` : '$0.00';
|
|
68
|
+
// Create formatted compare-at price
|
|
69
|
+
const rawCompareAmount = product.compareAtPriceRange?.minValue?.amount;
|
|
70
|
+
const compareAtPrice = rawCompareAmount ? `$${rawCompareAmount}` : null;
|
|
71
|
+
const availabilityStatus = product.inventory?.availabilityStatus;
|
|
72
|
+
const available = availabilityStatus === auto_sdk_stores_products_v_3_1.InventoryAvailabilityStatus.IN_STOCK ||
|
|
73
|
+
availabilityStatus === auto_sdk_stores_products_v_3_1.InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK;
|
|
74
|
+
const description = typeof product.description === 'string' ? product.description : '';
|
|
75
|
+
return props.children({
|
|
76
|
+
id: product._id || '',
|
|
77
|
+
title: product.name || '',
|
|
78
|
+
slug: product.slug || '',
|
|
79
|
+
image,
|
|
80
|
+
price,
|
|
81
|
+
compareAtPrice,
|
|
82
|
+
description,
|
|
83
|
+
available,
|
|
84
|
+
href: `/store/products/${product.slug}`,
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
exports.Item = Item;
|
|
88
|
+
/**
|
|
89
|
+
* Headless component for load more products functionality
|
|
90
|
+
* Note: V3 API uses simplified loading without traditional pagination
|
|
91
|
+
*
|
|
92
|
+
* @component
|
|
93
|
+
*/
|
|
94
|
+
const LoadMore = (props) => {
|
|
95
|
+
const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
|
|
96
|
+
// Error handling for undefined service
|
|
97
|
+
if (!service) {
|
|
98
|
+
console.error('CollectionService is undefined in LoadMore');
|
|
99
|
+
return props.children({
|
|
100
|
+
loadMore: async () => { },
|
|
101
|
+
refresh: async () => { },
|
|
102
|
+
isLoading: false,
|
|
103
|
+
hasProducts: false,
|
|
104
|
+
totalProducts: 0,
|
|
105
|
+
hasMoreProducts: false,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
const isLoading = service.isLoading?.get() || false;
|
|
110
|
+
const hasProducts = service.hasProducts?.get() || false;
|
|
111
|
+
const totalProducts = service.totalProducts?.get() || 0;
|
|
112
|
+
const hasMoreProducts = service.hasMoreProducts?.get() || false;
|
|
113
|
+
return props.children({
|
|
114
|
+
loadMore: service.loadMore || (async () => { }),
|
|
115
|
+
refresh: service.refresh || (async () => { }),
|
|
116
|
+
isLoading,
|
|
117
|
+
hasProducts,
|
|
118
|
+
totalProducts,
|
|
119
|
+
hasMoreProducts,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
console.error('Error in LoadMore:', err);
|
|
124
|
+
return props.children({
|
|
125
|
+
loadMore: async () => { },
|
|
126
|
+
refresh: async () => { },
|
|
127
|
+
isLoading: false,
|
|
128
|
+
hasProducts: false,
|
|
129
|
+
totalProducts: 0,
|
|
130
|
+
hasMoreProducts: false,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
exports.LoadMore = LoadMore;
|
|
135
|
+
/**
|
|
136
|
+
* Headless component for collection header with product count
|
|
137
|
+
*
|
|
138
|
+
* @component
|
|
139
|
+
*/
|
|
140
|
+
const Header = (props) => {
|
|
141
|
+
const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
|
|
142
|
+
// Error handling for undefined service
|
|
143
|
+
if (!service) {
|
|
144
|
+
console.error('CollectionService is undefined in Header');
|
|
145
|
+
return props.children({
|
|
146
|
+
totalProducts: 0,
|
|
147
|
+
isLoading: false,
|
|
148
|
+
hasProducts: false,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
const totalProducts = service.totalProducts?.get() || 0;
|
|
153
|
+
const isLoading = service.isLoading?.get() || false;
|
|
154
|
+
const hasProducts = service.hasProducts?.get() || false;
|
|
155
|
+
return props.children({
|
|
156
|
+
totalProducts,
|
|
157
|
+
isLoading,
|
|
158
|
+
hasProducts,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
console.error('Error in Header:', err);
|
|
163
|
+
return props.children({
|
|
164
|
+
totalProducts: 0,
|
|
165
|
+
isLoading: false,
|
|
166
|
+
hasProducts: false,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
exports.Header = Header;
|
|
171
|
+
/**
|
|
172
|
+
* Headless component for collection actions (refresh, load more)
|
|
173
|
+
* Replaces traditional pagination for V3 API
|
|
174
|
+
*
|
|
175
|
+
* @component
|
|
176
|
+
*/
|
|
177
|
+
const Actions = (props) => {
|
|
178
|
+
const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
|
|
179
|
+
// Error handling for undefined service
|
|
180
|
+
if (!service) {
|
|
181
|
+
console.error('CollectionService is undefined in Actions');
|
|
182
|
+
return props.children({
|
|
183
|
+
refresh: async () => { },
|
|
184
|
+
loadMore: async () => { },
|
|
185
|
+
isLoading: false,
|
|
186
|
+
error: 'Service not available',
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
const isLoading = service.isLoading?.get() || false;
|
|
191
|
+
const error = service.error?.get() || null;
|
|
192
|
+
return props.children({
|
|
193
|
+
refresh: service.refresh || (async () => { }),
|
|
194
|
+
loadMore: service.loadMore || (async () => { }),
|
|
195
|
+
isLoading,
|
|
196
|
+
error,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
catch (err) {
|
|
200
|
+
console.error('Error in Actions:', err);
|
|
201
|
+
return props.children({
|
|
202
|
+
refresh: async () => { },
|
|
203
|
+
loadMore: async () => { },
|
|
204
|
+
isLoading: false,
|
|
205
|
+
error: 'Failed to load actions',
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
exports.Actions = Actions;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { type AvailableOptions, type FilterServiceAPI, type Filter } from '../services/filter-service';
|
|
3
|
+
import { type V3Product } from '@wix/auto_sdk_stores_products-v-3';
|
|
4
|
+
import { type CollectionServiceAPI } from '../services/collection-service';
|
|
5
|
+
export interface FilteredCollectionProviderProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Headless component for providing a filtered collection
|
|
10
|
+
*
|
|
11
|
+
* @component
|
|
12
|
+
*/
|
|
13
|
+
export declare const Provider: React.FC<FilteredCollectionProviderProps>;
|
|
14
|
+
export declare const useFilteredCollection: () => {
|
|
15
|
+
filter: FilterServiceAPI | null;
|
|
16
|
+
collection: CollectionServiceAPI | null;
|
|
17
|
+
};
|
|
18
|
+
export interface FiltersLoadingProps {
|
|
19
|
+
children: (data: {
|
|
20
|
+
isFullyLoaded: boolean;
|
|
21
|
+
}) => ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Headless component for displaying a loading state for filters
|
|
25
|
+
*
|
|
26
|
+
* @component
|
|
27
|
+
*/
|
|
28
|
+
export declare const FiltersLoading: React.FC<FiltersLoadingProps>;
|
|
29
|
+
export interface FilteredGridProps {
|
|
30
|
+
children: (data: {
|
|
31
|
+
products: V3Product[];
|
|
32
|
+
totalProducts: number;
|
|
33
|
+
isLoading: boolean;
|
|
34
|
+
error: string | null;
|
|
35
|
+
isEmpty: boolean;
|
|
36
|
+
hasMoreProducts: boolean;
|
|
37
|
+
}) => ReactNode;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Headless component for displaying a grid of filtered products
|
|
41
|
+
*
|
|
42
|
+
* @component
|
|
43
|
+
*/
|
|
44
|
+
export declare const Grid: React.FC<FilteredGridProps>;
|
|
45
|
+
export interface FilteredItemProps {
|
|
46
|
+
product: V3Product;
|
|
47
|
+
children: (data: {
|
|
48
|
+
title: string;
|
|
49
|
+
image: string | null;
|
|
50
|
+
imageAltText: string | null;
|
|
51
|
+
price: string;
|
|
52
|
+
compareAtPrice: string | null;
|
|
53
|
+
available: boolean;
|
|
54
|
+
slug: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
}) => ReactNode;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Headless component for displaying an individual product item
|
|
60
|
+
*
|
|
61
|
+
* @component
|
|
62
|
+
*/
|
|
63
|
+
export declare const Item: React.FC<FilteredItemProps>;
|
|
64
|
+
export interface FilteredLoadMoreProps {
|
|
65
|
+
children: (data: {
|
|
66
|
+
loadMore: () => Promise<void>;
|
|
67
|
+
refresh: () => Promise<void>;
|
|
68
|
+
isLoading: boolean;
|
|
69
|
+
hasProducts: boolean;
|
|
70
|
+
totalProducts: number;
|
|
71
|
+
hasMoreProducts: boolean;
|
|
72
|
+
}) => ReactNode;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Headless component for displaying a load more button
|
|
76
|
+
*
|
|
77
|
+
* @component
|
|
78
|
+
*/
|
|
79
|
+
export declare const LoadMore: React.FC<FilteredLoadMoreProps>;
|
|
80
|
+
export interface FilteredFiltersProps {
|
|
81
|
+
children: (data: {
|
|
82
|
+
applyFilters: (filters: Filter) => void;
|
|
83
|
+
clearFilters: () => void;
|
|
84
|
+
currentFilters: Filter;
|
|
85
|
+
allProducts: V3Product[];
|
|
86
|
+
availableOptions: AvailableOptions;
|
|
87
|
+
isFiltered: boolean;
|
|
88
|
+
}) => ReactNode;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Headless component for displaying a filters component
|
|
92
|
+
*
|
|
93
|
+
* @component
|
|
94
|
+
*/
|
|
95
|
+
export declare const Filters: React.FC<FilteredFiltersProps>;
|