@wix/headless-stores 0.0.8 → 0.0.10
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/react/BuyNow.d.ts +1 -0
- package/cjs/dist/react/BuyNow.js +1 -0
- package/cjs/dist/react/Category.d.ts +17 -0
- package/cjs/dist/react/Category.js +37 -0
- package/cjs/dist/react/Collection.d.ts +141 -0
- package/cjs/dist/react/Collection.js +198 -0
- package/cjs/dist/react/FilteredCollection.d.ts +65 -0
- package/cjs/dist/react/FilteredCollection.js +117 -0
- package/cjs/dist/react/PayNow.d.ts +1 -0
- package/cjs/dist/react/PayNow.js +1 -0
- package/cjs/dist/react/Product.d.ts +70 -0
- package/cjs/dist/react/Product.js +56 -0
- package/cjs/dist/react/ProductMediaGallery.d.ts +128 -0
- package/cjs/dist/react/ProductMediaGallery.js +100 -0
- package/cjs/dist/react/ProductModifiers.d.ts +156 -0
- package/cjs/dist/react/ProductModifiers.js +159 -0
- package/cjs/dist/react/ProductVariantSelector.d.ts +169 -0
- package/cjs/dist/react/ProductVariantSelector.js +166 -0
- package/cjs/dist/react/RelatedProducts.d.ts +60 -0
- package/cjs/dist/react/RelatedProducts.js +68 -0
- package/cjs/dist/react/SocialSharing.d.ts +119 -0
- package/cjs/dist/react/SocialSharing.js +80 -0
- package/cjs/dist/react/Sort.d.ts +17 -0
- package/cjs/dist/react/Sort.js +41 -0
- package/cjs/dist/react/index.d.ts +10 -0
- package/cjs/dist/react/index.js +33 -0
- package/cjs/dist/services/catalog-options-service.d.ts +30 -0
- package/cjs/dist/services/catalog-options-service.js +162 -0
- package/cjs/dist/services/catalog-price-range-service.d.ts +23 -0
- package/cjs/dist/services/catalog-price-range-service.js +95 -0
- package/cjs/dist/services/category-service.d.ts +25 -0
- package/cjs/dist/services/category-service.js +67 -0
- package/cjs/dist/services/collection-service.d.ts +37 -0
- package/cjs/dist/services/collection-service.js +454 -0
- package/cjs/dist/services/filter-service.d.ts +56 -0
- package/cjs/dist/services/filter-service.js +155 -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 +36 -0
- package/cjs/dist/services/product-modifiers-service.js +104 -0
- package/cjs/dist/services/product-service.d.ts +27 -0
- package/cjs/dist/services/product-service.js +51 -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 +51 -0
- package/cjs/dist/services/selected-variant-service.js +396 -0
- package/cjs/dist/services/social-sharing-service.d.ts +41 -0
- package/cjs/dist/services/social-sharing-service.js +157 -0
- package/cjs/dist/services/sort-service.d.ts +19 -0
- package/cjs/dist/services/sort-service.js +37 -0
- package/cjs/dist/utils/url-params.d.ts +5 -0
- package/cjs/dist/utils/url-params.js +50 -0
- package/dist/react/BuyNow.d.ts +1 -0
- package/dist/react/BuyNow.js +1 -0
- package/dist/react/Category.d.ts +17 -0
- package/dist/react/Category.js +31 -0
- package/dist/react/Collection.d.ts +141 -0
- package/dist/react/Collection.js +190 -0
- package/dist/react/FilteredCollection.d.ts +65 -0
- package/dist/react/FilteredCollection.js +107 -0
- package/dist/react/PayNow.d.ts +1 -0
- package/dist/react/PayNow.js +1 -0
- package/dist/react/Product.d.ts +70 -0
- package/dist/react/Product.js +50 -0
- package/dist/react/ProductMediaGallery.d.ts +128 -0
- package/dist/react/ProductMediaGallery.js +92 -0
- package/dist/react/ProductModifiers.d.ts +156 -0
- package/dist/react/ProductModifiers.js +151 -0
- package/dist/react/ProductVariantSelector.d.ts +169 -0
- package/dist/react/ProductVariantSelector.js +157 -0
- package/dist/react/RelatedProducts.d.ts +60 -0
- package/dist/react/RelatedProducts.js +60 -0
- package/dist/react/SocialSharing.d.ts +119 -0
- package/dist/react/SocialSharing.js +71 -0
- package/dist/react/Sort.d.ts +17 -0
- package/dist/react/Sort.js +36 -0
- package/dist/react/index.d.ts +10 -0
- package/dist/react/index.js +10 -0
- package/dist/services/catalog-options-service.d.ts +30 -0
- package/dist/services/catalog-options-service.js +158 -0
- package/dist/services/catalog-price-range-service.d.ts +23 -0
- package/dist/services/catalog-price-range-service.js +91 -0
- package/dist/services/category-service.d.ts +25 -0
- package/dist/services/category-service.js +63 -0
- package/dist/services/collection-service.d.ts +37 -0
- package/dist/services/collection-service.js +417 -0
- package/dist/services/filter-service.d.ts +56 -0
- package/dist/services/filter-service.js +152 -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 +36 -0
- package/dist/services/product-modifiers-service.js +100 -0
- package/dist/services/product-service.d.ts +27 -0
- package/dist/services/product-service.js +47 -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 +51 -0
- package/dist/services/selected-variant-service.js +392 -0
- package/dist/services/social-sharing-service.d.ts +41 -0
- package/dist/services/social-sharing-service.js +153 -0
- package/dist/services/sort-service.d.ts +19 -0
- package/dist/services/sort-service.js +34 -0
- package/dist/utils/url-params.d.ts +5 -0
- package/dist/utils/url-params.js +46 -0
- package/package.json +2 -1
package/cjs/dist/react/BuyNow.js
CHANGED
|
@@ -30,6 +30,7 @@ const buy_now_service_1 = require("../services/buy-now-service");
|
|
|
30
30
|
* )}
|
|
31
31
|
* </BuyNow>
|
|
32
32
|
* ```
|
|
33
|
+
* @component
|
|
33
34
|
*/
|
|
34
35
|
function BuyNow(props) {
|
|
35
36
|
const { redirectToCheckout, loadingSignal, productName, errorSignal, price, currency, inStock, preOrderAvailable, } = (0, services_manager_react_1.useService)(buy_now_service_1.BuyNowServiceDefinition);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { type ReactNode } from "react";
|
|
2
|
+
import { type CategoryServiceAPI } from "../services/category-service";
|
|
3
|
+
import { categories } from "@wix/categories";
|
|
4
|
+
interface CategoryProviderProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const Provider: React.FC<CategoryProviderProps>;
|
|
8
|
+
export declare const useCategory: () => CategoryServiceAPI;
|
|
9
|
+
interface CategoryListProps {
|
|
10
|
+
children: (data: {
|
|
11
|
+
categories: categories.Category[];
|
|
12
|
+
selectedCategory: string | null;
|
|
13
|
+
setSelectedCategory: (categoryId: string | null) => void;
|
|
14
|
+
}) => ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare const List: React.FC<CategoryListProps>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.List = exports.useCategory = exports.Provider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
7
|
+
const category_service_1 = require("../services/category-service");
|
|
8
|
+
const CategoryContext = (0, react_1.createContext)(null);
|
|
9
|
+
const Provider = ({ children, }) => {
|
|
10
|
+
const service = (0, services_manager_react_1.useService)(category_service_1.CategoryServiceDefinition);
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(CategoryContext.Provider, { value: service, children: children }));
|
|
12
|
+
};
|
|
13
|
+
exports.Provider = Provider;
|
|
14
|
+
const useCategory = () => {
|
|
15
|
+
const context = (0, react_1.useContext)(CategoryContext);
|
|
16
|
+
if (!context) {
|
|
17
|
+
throw new Error("useCategory must be used within a CategoryProvider");
|
|
18
|
+
}
|
|
19
|
+
return context;
|
|
20
|
+
};
|
|
21
|
+
exports.useCategory = useCategory;
|
|
22
|
+
const List = ({ children }) => {
|
|
23
|
+
const service = (0, exports.useCategory)();
|
|
24
|
+
const [selectedCategory, setSelectedCategory] = (0, react_1.useState)(service.selectedCategory.get());
|
|
25
|
+
const categories = service.categories.get();
|
|
26
|
+
service.selectedCategory.subscribe((categoryId) => {
|
|
27
|
+
if (categoryId !== selectedCategory) {
|
|
28
|
+
setSelectedCategory(categoryId);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
|
|
32
|
+
selectedCategory,
|
|
33
|
+
categories,
|
|
34
|
+
setSelectedCategory: service.setSelectedCategory,
|
|
35
|
+
}) }));
|
|
36
|
+
};
|
|
37
|
+
exports.List = List;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { productsV3 } from "@wix/stores";
|
|
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: productsV3.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
|
+
export declare const Grid: (props: GridProps) => import("react").ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Props for Item headless component
|
|
32
|
+
*/
|
|
33
|
+
export interface ItemProps {
|
|
34
|
+
/** Product data */
|
|
35
|
+
product: productsV3.V3Product;
|
|
36
|
+
/** Render prop function that receives product item data */
|
|
37
|
+
children: (props: ItemRenderProps) => React.ReactNode;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Render props for Item component
|
|
41
|
+
*/
|
|
42
|
+
export interface ItemRenderProps {
|
|
43
|
+
/** Product ID */
|
|
44
|
+
id: string;
|
|
45
|
+
/** Product title */
|
|
46
|
+
title: string;
|
|
47
|
+
/** Product slug for URL */
|
|
48
|
+
slug: string;
|
|
49
|
+
/** Main product image URL */
|
|
50
|
+
image: string | null;
|
|
51
|
+
/** Product price */
|
|
52
|
+
price: string;
|
|
53
|
+
/** Compare at price (for strikethrough) */
|
|
54
|
+
compareAtPrice: string | null;
|
|
55
|
+
/** Product description */
|
|
56
|
+
description: string;
|
|
57
|
+
/** Whether product is available */
|
|
58
|
+
available: boolean;
|
|
59
|
+
/** Product URL */
|
|
60
|
+
href: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Headless component for individual product item
|
|
64
|
+
*/
|
|
65
|
+
export declare const Item: (props: ItemProps) => import("react").ReactNode;
|
|
66
|
+
/**
|
|
67
|
+
* Props for LoadMore headless component
|
|
68
|
+
*/
|
|
69
|
+
export interface LoadMoreProps {
|
|
70
|
+
/** Render prop function that receives load more data */
|
|
71
|
+
children: (props: LoadMoreRenderProps) => React.ReactNode;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Render props for LoadMore component
|
|
75
|
+
*/
|
|
76
|
+
export interface LoadMoreRenderProps {
|
|
77
|
+
/** Function to load more products */
|
|
78
|
+
loadMore: () => Promise<void>;
|
|
79
|
+
/** Function to refresh products */
|
|
80
|
+
refresh: () => Promise<void>;
|
|
81
|
+
/** Whether load more is currently loading */
|
|
82
|
+
isLoading: boolean;
|
|
83
|
+
/** Whether there are products */
|
|
84
|
+
hasProducts: boolean;
|
|
85
|
+
/** Total number of products currently loaded */
|
|
86
|
+
totalProducts: number;
|
|
87
|
+
/** Whether there are more products to load */
|
|
88
|
+
hasMoreProducts: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Headless component for load more products functionality
|
|
92
|
+
* Note: V3 API uses simplified loading without traditional pagination
|
|
93
|
+
*/
|
|
94
|
+
export declare const LoadMore: (props: LoadMoreProps) => import("react").ReactNode;
|
|
95
|
+
/**
|
|
96
|
+
* Props for Header headless component
|
|
97
|
+
*/
|
|
98
|
+
export interface HeaderProps {
|
|
99
|
+
/** Render prop function that receives collection header data */
|
|
100
|
+
children: (props: HeaderRenderProps) => React.ReactNode;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Render props for Header component
|
|
104
|
+
*/
|
|
105
|
+
export interface HeaderRenderProps {
|
|
106
|
+
/** Total number of products */
|
|
107
|
+
totalProducts: number;
|
|
108
|
+
/** Whether collection is loading */
|
|
109
|
+
isLoading: boolean;
|
|
110
|
+
/** Whether collection has products */
|
|
111
|
+
hasProducts: boolean;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Headless component for collection header with product count
|
|
115
|
+
*/
|
|
116
|
+
export declare const Header: (props: HeaderProps) => import("react").ReactNode;
|
|
117
|
+
/**
|
|
118
|
+
* Props for Actions headless component
|
|
119
|
+
*/
|
|
120
|
+
export interface ActionsProps {
|
|
121
|
+
/** Render prop function that receives collection actions data */
|
|
122
|
+
children: (props: ActionsRenderProps) => React.ReactNode;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Render props for Actions component
|
|
126
|
+
*/
|
|
127
|
+
export interface ActionsRenderProps {
|
|
128
|
+
/** Function to refresh the collection */
|
|
129
|
+
refresh: () => Promise<void>;
|
|
130
|
+
/** Function to load more products */
|
|
131
|
+
loadMore: () => Promise<void>;
|
|
132
|
+
/** Whether actions are loading */
|
|
133
|
+
isLoading: boolean;
|
|
134
|
+
/** Error message if any */
|
|
135
|
+
error: string | null;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Headless component for collection actions (refresh, load more)
|
|
139
|
+
* Replaces traditional pagination for V3 API
|
|
140
|
+
*/
|
|
141
|
+
export declare const Actions: (props: ActionsProps) => import("react").ReactNode;
|
|
@@ -0,0 +1,198 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* Headless component for product grid
|
|
8
|
+
*/
|
|
9
|
+
const Grid = (props) => {
|
|
10
|
+
const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
|
|
11
|
+
// Debug logging to help identify service issues
|
|
12
|
+
if (!service) {
|
|
13
|
+
console.error("CollectionService is undefined");
|
|
14
|
+
return props.children({
|
|
15
|
+
products: [],
|
|
16
|
+
isLoading: false,
|
|
17
|
+
error: "Service not available",
|
|
18
|
+
isEmpty: true,
|
|
19
|
+
totalProducts: 0,
|
|
20
|
+
hasProducts: false,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// Safely access service properties with error handling
|
|
24
|
+
try {
|
|
25
|
+
const productList = service.products?.get() || [];
|
|
26
|
+
const isLoading = service.isLoading?.get() || false;
|
|
27
|
+
const error = service.error?.get() || null;
|
|
28
|
+
const totalProducts = service.totalProducts?.get() || 0;
|
|
29
|
+
const hasProducts = service.hasProducts?.get() || false;
|
|
30
|
+
return props.children({
|
|
31
|
+
products: productList,
|
|
32
|
+
isLoading,
|
|
33
|
+
error,
|
|
34
|
+
isEmpty: !hasProducts && !isLoading,
|
|
35
|
+
totalProducts,
|
|
36
|
+
hasProducts,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
console.error("Error accessing service properties:", err);
|
|
41
|
+
return props.children({
|
|
42
|
+
products: [],
|
|
43
|
+
isLoading: false,
|
|
44
|
+
error: "Failed to load products",
|
|
45
|
+
isEmpty: true,
|
|
46
|
+
totalProducts: 0,
|
|
47
|
+
hasProducts: false,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.Grid = Grid;
|
|
52
|
+
/**
|
|
53
|
+
* Headless component for individual product item
|
|
54
|
+
*/
|
|
55
|
+
const Item = (props) => {
|
|
56
|
+
const { product } = props;
|
|
57
|
+
// Use actual v3 API structure based on real data
|
|
58
|
+
// Images are in media.main.image, not media.itemsInfo.items
|
|
59
|
+
const image = product?.media?.main?.image || null;
|
|
60
|
+
// Create formatted price since formattedAmount is not available
|
|
61
|
+
const rawAmount = product.actualPriceRange?.minValue?.amount;
|
|
62
|
+
const price = rawAmount ? `$${rawAmount}` : "$0.00";
|
|
63
|
+
// Create formatted compare-at price
|
|
64
|
+
const rawCompareAmount = product.compareAtPriceRange?.minValue?.amount;
|
|
65
|
+
const compareAtPrice = rawCompareAmount ? `$${rawCompareAmount}` : null;
|
|
66
|
+
const availabilityStatus = product.inventory?.availabilityStatus;
|
|
67
|
+
const available = availabilityStatus === "IN_STOCK" ||
|
|
68
|
+
availabilityStatus === "PARTIALLY_OUT_OF_STOCK";
|
|
69
|
+
const description = typeof product.description === "string" ? product.description : "";
|
|
70
|
+
return props.children({
|
|
71
|
+
id: product._id || "",
|
|
72
|
+
title: product.name || "",
|
|
73
|
+
slug: product.slug || "",
|
|
74
|
+
image,
|
|
75
|
+
price,
|
|
76
|
+
compareAtPrice,
|
|
77
|
+
description,
|
|
78
|
+
available,
|
|
79
|
+
href: `/store/products/${product.slug}`,
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
exports.Item = Item;
|
|
83
|
+
/**
|
|
84
|
+
* Headless component for load more products functionality
|
|
85
|
+
* Note: V3 API uses simplified loading without traditional pagination
|
|
86
|
+
*/
|
|
87
|
+
const LoadMore = (props) => {
|
|
88
|
+
const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
|
|
89
|
+
// Error handling for undefined service
|
|
90
|
+
if (!service) {
|
|
91
|
+
console.error("CollectionService is undefined in LoadMore");
|
|
92
|
+
return props.children({
|
|
93
|
+
loadMore: async () => { },
|
|
94
|
+
refresh: async () => { },
|
|
95
|
+
isLoading: false,
|
|
96
|
+
hasProducts: false,
|
|
97
|
+
totalProducts: 0,
|
|
98
|
+
hasMoreProducts: false,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
const isLoading = service.isLoading?.get() || false;
|
|
103
|
+
const hasProducts = service.hasProducts?.get() || false;
|
|
104
|
+
const totalProducts = service.totalProducts?.get() || 0;
|
|
105
|
+
const hasMoreProducts = service.hasMoreProducts?.get() || false;
|
|
106
|
+
return props.children({
|
|
107
|
+
loadMore: service.loadMore || (async () => { }),
|
|
108
|
+
refresh: service.refresh || (async () => { }),
|
|
109
|
+
isLoading,
|
|
110
|
+
hasProducts,
|
|
111
|
+
totalProducts,
|
|
112
|
+
hasMoreProducts,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
console.error("Error in LoadMore:", err);
|
|
117
|
+
return props.children({
|
|
118
|
+
loadMore: async () => { },
|
|
119
|
+
refresh: async () => { },
|
|
120
|
+
isLoading: false,
|
|
121
|
+
hasProducts: false,
|
|
122
|
+
totalProducts: 0,
|
|
123
|
+
hasMoreProducts: false,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
exports.LoadMore = LoadMore;
|
|
128
|
+
/**
|
|
129
|
+
* Headless component for collection header with product count
|
|
130
|
+
*/
|
|
131
|
+
const Header = (props) => {
|
|
132
|
+
const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
|
|
133
|
+
// Error handling for undefined service
|
|
134
|
+
if (!service) {
|
|
135
|
+
console.error("CollectionService is undefined in Header");
|
|
136
|
+
return props.children({
|
|
137
|
+
totalProducts: 0,
|
|
138
|
+
isLoading: false,
|
|
139
|
+
hasProducts: false,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
const totalProducts = service.totalProducts?.get() || 0;
|
|
144
|
+
const isLoading = service.isLoading?.get() || false;
|
|
145
|
+
const hasProducts = service.hasProducts?.get() || false;
|
|
146
|
+
return props.children({
|
|
147
|
+
totalProducts,
|
|
148
|
+
isLoading,
|
|
149
|
+
hasProducts,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
console.error("Error in Header:", err);
|
|
154
|
+
return props.children({
|
|
155
|
+
totalProducts: 0,
|
|
156
|
+
isLoading: false,
|
|
157
|
+
hasProducts: false,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
exports.Header = Header;
|
|
162
|
+
/**
|
|
163
|
+
* Headless component for collection actions (refresh, load more)
|
|
164
|
+
* Replaces traditional pagination for V3 API
|
|
165
|
+
*/
|
|
166
|
+
const Actions = (props) => {
|
|
167
|
+
const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
|
|
168
|
+
// Error handling for undefined service
|
|
169
|
+
if (!service) {
|
|
170
|
+
console.error("CollectionService is undefined in Actions");
|
|
171
|
+
return props.children({
|
|
172
|
+
refresh: async () => { },
|
|
173
|
+
loadMore: async () => { },
|
|
174
|
+
isLoading: false,
|
|
175
|
+
error: "Service not available",
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
const isLoading = service.isLoading?.get() || false;
|
|
180
|
+
const error = service.error?.get() || null;
|
|
181
|
+
return props.children({
|
|
182
|
+
refresh: service.refresh || (async () => { }),
|
|
183
|
+
loadMore: service.loadMore || (async () => { }),
|
|
184
|
+
isLoading,
|
|
185
|
+
error,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
catch (err) {
|
|
189
|
+
console.error("Error in Actions:", err);
|
|
190
|
+
return props.children({
|
|
191
|
+
refresh: async () => { },
|
|
192
|
+
loadMore: async () => { },
|
|
193
|
+
isLoading: false,
|
|
194
|
+
error: "Failed to load actions",
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
exports.Actions = Actions;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React, { type ReactNode } from "react";
|
|
2
|
+
import { type AvailableOptions, type FilterServiceAPI, type Filter } from "../services/filter-service";
|
|
3
|
+
import { productsV3 } from "@wix/stores";
|
|
4
|
+
import { type CollectionServiceAPI } from "../services/collection-service";
|
|
5
|
+
interface FilteredCollectionProviderProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const Provider: React.FC<FilteredCollectionProviderProps>;
|
|
9
|
+
export declare const useFilteredCollection: () => {
|
|
10
|
+
filter: FilterServiceAPI | null;
|
|
11
|
+
collection: CollectionServiceAPI | null;
|
|
12
|
+
};
|
|
13
|
+
interface FiltersLoadingProps {
|
|
14
|
+
children: (data: {
|
|
15
|
+
isFullyLoaded: boolean;
|
|
16
|
+
}) => ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export declare const FiltersLoading: React.FC<FiltersLoadingProps>;
|
|
19
|
+
interface FilteredGridProps {
|
|
20
|
+
children: (data: {
|
|
21
|
+
products: productsV3.V3Product[];
|
|
22
|
+
totalProducts: number;
|
|
23
|
+
isLoading: boolean;
|
|
24
|
+
error: string | null;
|
|
25
|
+
isEmpty: boolean;
|
|
26
|
+
hasMoreProducts: boolean;
|
|
27
|
+
}) => ReactNode;
|
|
28
|
+
}
|
|
29
|
+
export declare const Grid: React.FC<FilteredGridProps>;
|
|
30
|
+
interface FilteredItemProps {
|
|
31
|
+
product: productsV3.V3Product;
|
|
32
|
+
children: (data: {
|
|
33
|
+
title: string;
|
|
34
|
+
image: string | null;
|
|
35
|
+
price: string;
|
|
36
|
+
compareAtPrice: string | null;
|
|
37
|
+
available: boolean;
|
|
38
|
+
href: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
}) => ReactNode;
|
|
41
|
+
}
|
|
42
|
+
export declare const Item: React.FC<FilteredItemProps>;
|
|
43
|
+
interface FilteredLoadMoreProps {
|
|
44
|
+
children: (data: {
|
|
45
|
+
loadMore: () => Promise<void>;
|
|
46
|
+
refresh: () => Promise<void>;
|
|
47
|
+
isLoading: boolean;
|
|
48
|
+
hasProducts: boolean;
|
|
49
|
+
totalProducts: number;
|
|
50
|
+
hasMoreProducts: boolean;
|
|
51
|
+
}) => ReactNode;
|
|
52
|
+
}
|
|
53
|
+
export declare const LoadMore: React.FC<FilteredLoadMoreProps>;
|
|
54
|
+
interface FilteredFiltersProps {
|
|
55
|
+
children: (data: {
|
|
56
|
+
applyFilters: (filters: Filter) => void;
|
|
57
|
+
clearFilters: () => void;
|
|
58
|
+
currentFilters: Filter;
|
|
59
|
+
allProducts: productsV3.V3Product[];
|
|
60
|
+
availableOptions: AvailableOptions;
|
|
61
|
+
isFiltered: boolean;
|
|
62
|
+
}) => ReactNode;
|
|
63
|
+
}
|
|
64
|
+
export declare const Filters: React.FC<FilteredFiltersProps>;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Filters = exports.LoadMore = exports.Item = exports.Grid = exports.FiltersLoading = exports.useFilteredCollection = exports.Provider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const filter_service_1 = require("../services/filter-service");
|
|
7
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
8
|
+
const collection_service_1 = require("../services/collection-service");
|
|
9
|
+
const FilteredCollectionContext = (0, react_1.createContext)({ filter: null, collection: null });
|
|
10
|
+
const Provider = ({ children }) => {
|
|
11
|
+
const filter = (0, services_manager_react_1.useService)(filter_service_1.FilterServiceDefinition);
|
|
12
|
+
const collection = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(FilteredCollectionContext.Provider, { value: { filter, collection }, children: children }));
|
|
14
|
+
};
|
|
15
|
+
exports.Provider = Provider;
|
|
16
|
+
const useFilteredCollection = () => {
|
|
17
|
+
const context = (0, react_1.useContext)(FilteredCollectionContext);
|
|
18
|
+
if (!context) {
|
|
19
|
+
throw new Error("useFilteredCollection must be used within a FilteredCollectionProvider");
|
|
20
|
+
}
|
|
21
|
+
return context;
|
|
22
|
+
};
|
|
23
|
+
exports.useFilteredCollection = useFilteredCollection;
|
|
24
|
+
const FiltersLoading = ({ children }) => {
|
|
25
|
+
const { filter } = (0, exports.useFilteredCollection)();
|
|
26
|
+
const isFullyLoaded = filter.isFullyLoaded.get();
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({ isFullyLoaded }) }));
|
|
28
|
+
};
|
|
29
|
+
exports.FiltersLoading = FiltersLoading;
|
|
30
|
+
const Grid = ({ children }) => {
|
|
31
|
+
const { collection } = (0, exports.useFilteredCollection)();
|
|
32
|
+
const products = collection.products.get() || [];
|
|
33
|
+
const totalProducts = collection.totalProducts.get();
|
|
34
|
+
const isLoading = collection.isLoading.get();
|
|
35
|
+
const error = collection.error.get();
|
|
36
|
+
const hasProducts = collection.hasProducts.get();
|
|
37
|
+
const hasMoreProducts = collection.hasMoreProducts.get();
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
|
|
39
|
+
products,
|
|
40
|
+
isLoading,
|
|
41
|
+
error,
|
|
42
|
+
isEmpty: !hasProducts,
|
|
43
|
+
totalProducts,
|
|
44
|
+
hasMoreProducts,
|
|
45
|
+
}) }));
|
|
46
|
+
};
|
|
47
|
+
exports.Grid = Grid;
|
|
48
|
+
const Item = ({ product, children, }) => {
|
|
49
|
+
// Safe conversion of product data with type safety guards
|
|
50
|
+
const title = String(product.name || "");
|
|
51
|
+
const image = product.media?.main?.image || null;
|
|
52
|
+
const price = product.actualPriceRange?.minValue?.formattedAmount ||
|
|
53
|
+
product.actualPriceRange?.maxValue?.formattedAmount ||
|
|
54
|
+
(product.actualPriceRange?.minValue?.amount
|
|
55
|
+
? `$${product.actualPriceRange.minValue.amount}`
|
|
56
|
+
: "$0.00");
|
|
57
|
+
// Add compare at price
|
|
58
|
+
const compareAtPrice = product.compareAtPriceRange?.minValue?.formattedAmount ||
|
|
59
|
+
(product.compareAtPriceRange?.minValue?.amount
|
|
60
|
+
? `$${product.compareAtPriceRange.minValue.amount}`
|
|
61
|
+
: null);
|
|
62
|
+
const availabilityStatus = product.inventory?.availabilityStatus;
|
|
63
|
+
const available = availabilityStatus === "IN_STOCK" ||
|
|
64
|
+
availabilityStatus === "PARTIALLY_OUT_OF_STOCK";
|
|
65
|
+
const href = `/store/products/${String(product.slug || product._id || "")}`;
|
|
66
|
+
const description = product.plainDescription
|
|
67
|
+
? String(product.plainDescription)
|
|
68
|
+
: undefined;
|
|
69
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
|
|
70
|
+
title,
|
|
71
|
+
image,
|
|
72
|
+
price: String(price),
|
|
73
|
+
compareAtPrice,
|
|
74
|
+
available,
|
|
75
|
+
href,
|
|
76
|
+
description,
|
|
77
|
+
}) }));
|
|
78
|
+
};
|
|
79
|
+
exports.Item = Item;
|
|
80
|
+
const LoadMore = ({ children, }) => {
|
|
81
|
+
const { collection } = (0, exports.useFilteredCollection)();
|
|
82
|
+
const loadMore = collection.loadMore;
|
|
83
|
+
const refresh = collection.refresh;
|
|
84
|
+
const isLoading = collection.isLoading.get();
|
|
85
|
+
const hasProducts = collection.hasProducts.get();
|
|
86
|
+
const totalProducts = collection.totalProducts.get();
|
|
87
|
+
const hasMoreProducts = collection.hasMoreProducts.get();
|
|
88
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
|
|
89
|
+
loadMore,
|
|
90
|
+
refresh,
|
|
91
|
+
isLoading,
|
|
92
|
+
hasProducts,
|
|
93
|
+
totalProducts,
|
|
94
|
+
hasMoreProducts,
|
|
95
|
+
}) }));
|
|
96
|
+
};
|
|
97
|
+
exports.LoadMore = LoadMore;
|
|
98
|
+
const Filters = ({ children, }) => {
|
|
99
|
+
const { collection, filter } = (0, exports.useFilteredCollection)();
|
|
100
|
+
const applyFilters = filter.applyFilters;
|
|
101
|
+
const clearFilters = filter.clearFilters;
|
|
102
|
+
const currentFilters = filter.currentFilters.get();
|
|
103
|
+
const allProducts = collection.products.get();
|
|
104
|
+
const availableOptions = filter.availableOptions.get();
|
|
105
|
+
const isFiltered = currentFilters.priceRange.min !== availableOptions.priceRange.min ||
|
|
106
|
+
currentFilters.priceRange.max !== availableOptions.priceRange.max ||
|
|
107
|
+
Object.keys(currentFilters.selectedOptions).length > 0;
|
|
108
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
|
|
109
|
+
applyFilters,
|
|
110
|
+
clearFilters,
|
|
111
|
+
currentFilters,
|
|
112
|
+
allProducts,
|
|
113
|
+
availableOptions,
|
|
114
|
+
isFiltered,
|
|
115
|
+
}) }));
|
|
116
|
+
};
|
|
117
|
+
exports.Filters = Filters;
|
package/cjs/dist/react/PayNow.js
CHANGED
|
@@ -26,6 +26,7 @@ const pay_now_service_1 = require("../services/pay-now-service");
|
|
|
26
26
|
* )}
|
|
27
27
|
* </PayNow>
|
|
28
28
|
* ```
|
|
29
|
+
* @component
|
|
29
30
|
*/
|
|
30
31
|
function PayNow(props) {
|
|
31
32
|
const { redirectToCheckout, loadingSignal, errorSignal, } = (0, services_manager_react_1.useService)(pay_now_service_1.PayNowServiceDefinition);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for ProductName headless component
|
|
3
|
+
*/
|
|
4
|
+
export interface ProductNameProps {
|
|
5
|
+
/** Render prop function that receives product name data */
|
|
6
|
+
children: (props: ProductNameRenderProps) => React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Render props for ProductName component
|
|
10
|
+
*/
|
|
11
|
+
export interface ProductNameRenderProps {
|
|
12
|
+
/** Product name */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Whether product has a name */
|
|
15
|
+
hasName: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Headless component for product name display
|
|
19
|
+
*/
|
|
20
|
+
export declare const Name: (props: ProductNameProps) => import("react").ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Props for ProductDescription headless component
|
|
23
|
+
*/
|
|
24
|
+
export interface ProductDescriptionProps {
|
|
25
|
+
/** Render prop function that receives product description data */
|
|
26
|
+
children: (props: ProductDescriptionRenderProps) => React.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Render props for ProductDescription component
|
|
30
|
+
*/
|
|
31
|
+
export interface ProductDescriptionRenderProps {
|
|
32
|
+
/** Product description (may contain HTML) */
|
|
33
|
+
description: string;
|
|
34
|
+
/** Whether product has a description */
|
|
35
|
+
hasDescription: boolean;
|
|
36
|
+
/** Whether description contains HTML */
|
|
37
|
+
isHtml: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Headless component for product description display
|
|
41
|
+
*/
|
|
42
|
+
export declare const Description: (props: ProductDescriptionProps) => import("react").ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* Props for ProductDetails headless component
|
|
45
|
+
*/
|
|
46
|
+
export interface ProductDetailsProps {
|
|
47
|
+
/** Render prop function that receives product details data */
|
|
48
|
+
children: (props: ProductDetailsRenderProps) => React.ReactNode;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Render props for ProductDetails component
|
|
52
|
+
*/
|
|
53
|
+
export interface ProductDetailsRenderProps {
|
|
54
|
+
/** Product SKU */
|
|
55
|
+
sku: string | null;
|
|
56
|
+
/** Product weight */
|
|
57
|
+
weight: string | null;
|
|
58
|
+
/** Product dimensions (if available) */
|
|
59
|
+
dimensions: string | null;
|
|
60
|
+
/** Whether product has SKU */
|
|
61
|
+
hasSku: boolean;
|
|
62
|
+
/** Whether product has weight */
|
|
63
|
+
hasWeight: boolean;
|
|
64
|
+
/** Whether product has dimensions */
|
|
65
|
+
hasDimensions: boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Headless component for product details display
|
|
69
|
+
*/
|
|
70
|
+
export declare const Details: (props: ProductDetailsProps) => import("react").ReactNode;
|