@wix/headless-stores 0.0.0
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/astro/actions/package.json +4 -0
- package/cjs/dist/astro/actions/custom-checkout.d.ts +50 -0
- package/cjs/dist/astro/actions/custom-checkout.js +53 -0
- package/cjs/dist/astro/actions/index.d.ts +1 -0
- package/cjs/dist/astro/actions/index.js +1 -0
- package/cjs/dist/data-component-tags.d.ts +8 -0
- package/cjs/dist/data-component-tags.js +9 -0
- package/cjs/dist/enums/index.d.ts +2 -0
- package/cjs/dist/enums/index.js +2 -0
- package/cjs/dist/enums/social-platform-enums.d.ts +25 -0
- package/cjs/dist/enums/social-platform-enums.js +27 -0
- package/cjs/dist/enums/sort-enums.d.ts +17 -0
- package/cjs/dist/enums/sort-enums.js +18 -0
- package/cjs/dist/react/Category.d.ts +242 -0
- package/cjs/dist/react/Category.js +235 -0
- package/cjs/dist/react/CategoryList.d.ts +107 -0
- package/cjs/dist/react/CategoryList.js +91 -0
- package/cjs/dist/react/Choice.d.ts +211 -0
- package/cjs/dist/react/Choice.js +213 -0
- package/cjs/dist/react/Option.d.ts +242 -0
- package/cjs/dist/react/Option.js +346 -0
- package/cjs/dist/react/Product.d.ts +1065 -0
- package/cjs/dist/react/Product.js +1157 -0
- package/cjs/dist/react/ProductList.d.ts +400 -0
- package/cjs/dist/react/ProductList.js +368 -0
- package/cjs/dist/react/core/CategoryList.d.ts +194 -0
- package/cjs/dist/react/core/CategoryList.js +180 -0
- package/cjs/dist/react/core/Product.d.ts +225 -0
- package/cjs/dist/react/core/Product.js +190 -0
- package/cjs/dist/react/core/ProductList.d.ts +235 -0
- package/cjs/dist/react/core/ProductList.js +217 -0
- package/cjs/dist/react/core/ProductListFilters.d.ts +138 -0
- package/cjs/dist/react/core/ProductListFilters.js +242 -0
- package/cjs/dist/react/core/ProductListPagination.d.ts +49 -0
- package/cjs/dist/react/core/ProductListPagination.js +41 -0
- package/cjs/dist/react/core/ProductListSort.d.ts +19 -0
- package/cjs/dist/react/core/ProductListSort.js +52 -0
- package/cjs/dist/react/core/ProductModifiers.d.ts +416 -0
- package/cjs/dist/react/core/ProductModifiers.js +413 -0
- package/cjs/dist/react/core/ProductVariantSelector.d.ts +313 -0
- package/cjs/dist/react/core/ProductVariantSelector.js +291 -0
- package/cjs/dist/react/core/SelectedVariant.d.ts +230 -0
- package/cjs/dist/react/core/SelectedVariant.js +269 -0
- package/cjs/dist/react/index.d.ts +6 -0
- package/cjs/dist/react/index.js +6 -0
- package/cjs/dist/react/types.d.ts +8 -0
- package/cjs/dist/react/types.js +9 -0
- package/cjs/dist/server-actions/custom-checkout-action.d.ts +49 -0
- package/cjs/dist/server-actions/custom-checkout-action.js +64 -0
- package/cjs/dist/server-actions/index.d.ts +1 -0
- package/cjs/dist/server-actions/index.js +1 -0
- package/cjs/dist/services/buy-now-service.d.ts +346 -0
- package/cjs/dist/services/buy-now-service.js +197 -0
- package/cjs/dist/services/categories-list-service.d.ts +164 -0
- package/cjs/dist/services/categories-list-service.js +148 -0
- package/cjs/dist/services/index.d.ts +5 -0
- package/cjs/dist/services/index.js +5 -0
- package/cjs/dist/services/pay-now-service.d.ts +214 -0
- package/cjs/dist/services/pay-now-service.js +156 -0
- package/cjs/dist/services/product-modifiers-service.d.ts +34 -0
- package/cjs/dist/services/product-modifiers-service.js +107 -0
- package/cjs/dist/services/product-service.d.ts +177 -0
- package/cjs/dist/services/product-service.js +190 -0
- package/cjs/dist/services/products-list-search-service.d.ts +1 -0
- package/cjs/dist/services/products-list-search-service.js +1 -0
- package/cjs/dist/services/products-list-service.d.ts +429 -0
- package/cjs/dist/services/products-list-service.js +893 -0
- package/cjs/dist/services/selected-variant-service.d.ts +66 -0
- package/cjs/dist/services/selected-variant-service.js +527 -0
- package/cjs/dist/utils/index.d.ts +1 -0
- package/cjs/dist/utils/index.js +30 -0
- package/cjs/dist/utils/url-params.d.ts +73 -0
- package/cjs/dist/utils/url-params.js +114 -0
- package/cjs/package.json +3 -0
- package/dist/astro/actions/custom-checkout.d.ts +50 -0
- package/dist/astro/actions/custom-checkout.js +53 -0
- package/dist/astro/actions/index.d.ts +1 -0
- package/dist/astro/actions/index.js +1 -0
- package/dist/data-component-tags.d.ts +8 -0
- package/dist/data-component-tags.js +9 -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/Category.d.ts +242 -0
- package/dist/react/Category.js +235 -0
- package/dist/react/CategoryList.d.ts +107 -0
- package/dist/react/CategoryList.js +91 -0
- package/dist/react/Choice.d.ts +211 -0
- package/dist/react/Choice.js +213 -0
- package/dist/react/Option.d.ts +242 -0
- package/dist/react/Option.js +346 -0
- package/dist/react/Product.d.ts +1065 -0
- package/dist/react/Product.js +1157 -0
- package/dist/react/ProductList.d.ts +400 -0
- package/dist/react/ProductList.js +368 -0
- package/dist/react/core/CategoryList.d.ts +194 -0
- package/dist/react/core/CategoryList.js +180 -0
- package/dist/react/core/Product.d.ts +225 -0
- package/dist/react/core/Product.js +190 -0
- package/dist/react/core/ProductList.d.ts +235 -0
- package/dist/react/core/ProductList.js +217 -0
- package/dist/react/core/ProductListFilters.d.ts +138 -0
- package/dist/react/core/ProductListFilters.js +242 -0
- package/dist/react/core/ProductListPagination.d.ts +49 -0
- package/dist/react/core/ProductListPagination.js +41 -0
- package/dist/react/core/ProductListSort.d.ts +19 -0
- package/dist/react/core/ProductListSort.js +52 -0
- package/dist/react/core/ProductModifiers.d.ts +416 -0
- package/dist/react/core/ProductModifiers.js +413 -0
- package/dist/react/core/ProductVariantSelector.d.ts +313 -0
- package/dist/react/core/ProductVariantSelector.js +291 -0
- package/dist/react/core/SelectedVariant.d.ts +230 -0
- package/dist/react/core/SelectedVariant.js +269 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.js +6 -0
- package/dist/react/types.d.ts +8 -0
- package/dist/react/types.js +9 -0
- package/dist/server-actions/custom-checkout-action.d.ts +49 -0
- package/dist/server-actions/custom-checkout-action.js +64 -0
- package/dist/server-actions/index.d.ts +1 -0
- package/dist/server-actions/index.js +1 -0
- package/dist/services/buy-now-service.d.ts +346 -0
- package/dist/services/buy-now-service.js +197 -0
- package/dist/services/categories-list-service.d.ts +164 -0
- package/dist/services/categories-list-service.js +148 -0
- package/dist/services/index.d.ts +5 -0
- package/dist/services/index.js +5 -0
- package/dist/services/pay-now-service.d.ts +214 -0
- package/dist/services/pay-now-service.js +156 -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 +177 -0
- package/dist/services/product-service.js +190 -0
- package/dist/services/products-list-search-service.d.ts +0 -0
- package/dist/services/products-list-search-service.js +1 -0
- package/dist/services/products-list-service.d.ts +429 -0
- package/dist/services/products-list-service.js +893 -0
- package/dist/services/selected-variant-service.d.ts +66 -0
- package/dist/services/selected-variant-service.js +527 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +30 -0
- package/dist/utils/url-params.d.ts +73 -0
- package/dist/utils/url-params.js +114 -0
- package/package.json +89 -0
- package/react/package.json +4 -0
- package/server-actions/package.json +4 -0
- package/services/package.json +4 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { type ProductsListServiceConfig } from '../../services/products-list-service.js';
|
|
2
|
+
import { productsV3 } from '@wix/stores';
|
|
3
|
+
import { CategoriesListServiceConfig } from '../../services/categories-list-service.js';
|
|
4
|
+
/**
|
|
5
|
+
* Props for Root headless component
|
|
6
|
+
*/
|
|
7
|
+
export interface RootProps {
|
|
8
|
+
/** Child components that will have access to the ProductList service */
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
/** Configuration for the ProductList service */
|
|
11
|
+
productsListConfig: ProductsListServiceConfig;
|
|
12
|
+
/** Configuration for the CategoriesList service */
|
|
13
|
+
categoriesListConfig?: CategoriesListServiceConfig;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Root component that provides both ProductList and ProductListSearch service contexts to its children.
|
|
17
|
+
* This component sets up the necessary services for managing products list state, including search,
|
|
18
|
+
* filtering, sorting, and pagination functionality.
|
|
19
|
+
*
|
|
20
|
+
* @order 1
|
|
21
|
+
* @component
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* import { ProductList, ProductListFilters, ProductListSort, ProductListPagination } from '@wix/stores/components';
|
|
25
|
+
*
|
|
26
|
+
* function ProductListPage() {
|
|
27
|
+
* return (
|
|
28
|
+
* <ProductList.Root
|
|
29
|
+
* productsListConfig={{
|
|
30
|
+
* products: myProducts,
|
|
31
|
+
* searchOptions: { query: { search: 'searchTerm' } },
|
|
32
|
+
* pagingMetadata: { count: 10, hasNext: true },
|
|
33
|
+
* aggregations: {}
|
|
34
|
+
* }}
|
|
35
|
+
* productsListSearchConfig={{
|
|
36
|
+
* customizations: [],
|
|
37
|
+
* initialSearchState: { sort: 'name_asc', limit: 20 }
|
|
38
|
+
* }}
|
|
39
|
+
* >
|
|
40
|
+
* <ProductListSort.Options>
|
|
41
|
+
* {({ selectedSortOption, updateSortOption, sortOptions }) => (
|
|
42
|
+
* <select value={selectedSortOption} onChange={(e) => updateSortOption(e.target.value)}>
|
|
43
|
+
* {sortOptions.map(option => <option key={option} value={option}>{option}</option>)}
|
|
44
|
+
* </select>
|
|
45
|
+
* )}
|
|
46
|
+
* </ProductListSort.Options>
|
|
47
|
+
*
|
|
48
|
+
* <ProductListFilters.PriceRange>
|
|
49
|
+
* {({ selectedMinPrice, setSelectedMinPrice }) => (
|
|
50
|
+
* <input value={selectedMinPrice} onChange={(e) => setSelectedMinPrice(Number(e.target.value))} />
|
|
51
|
+
* )}
|
|
52
|
+
* </ProductListFilters.PriceRange>
|
|
53
|
+
*
|
|
54
|
+
* <ProductList.ItemContent>
|
|
55
|
+
* {({ product }) => (
|
|
56
|
+
* <div key={product._id}>
|
|
57
|
+
* <h3>{product.name}</h3>
|
|
58
|
+
* <p>{product.actualPriceRange?.minValue?.formattedAmount}</p>
|
|
59
|
+
* </div>
|
|
60
|
+
* )}
|
|
61
|
+
* </ProductList.ItemContent>
|
|
62
|
+
*
|
|
63
|
+
* <ProductListPagination.NextPageTrigger>
|
|
64
|
+
* {({ nextPage, hasNextPage }) => (
|
|
65
|
+
* <button onClick={nextPage} disabled={!hasNextPage}>Next</button>
|
|
66
|
+
* )}
|
|
67
|
+
* </ProductListPagination.NextPageTrigger>
|
|
68
|
+
* </ProductList.Root>
|
|
69
|
+
* );
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function Root(props: RootProps): React.ReactNode;
|
|
74
|
+
/**
|
|
75
|
+
* Props for EmptyState headless component
|
|
76
|
+
*/
|
|
77
|
+
export interface EmptyStateProps {
|
|
78
|
+
/** Content to display when products list is empty (can be a render function or ReactNode) */
|
|
79
|
+
children: ((props: EmptyStateRenderProps) => React.ReactNode) | React.ReactNode;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Render props for EmptyState component
|
|
83
|
+
*/
|
|
84
|
+
export interface EmptyStateRenderProps {
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Component that renders content when the products list is empty.
|
|
88
|
+
* Only displays its children when there are no products, no loading state, and no errors.
|
|
89
|
+
*
|
|
90
|
+
* @component
|
|
91
|
+
* @example
|
|
92
|
+
* ```tsx
|
|
93
|
+
* import { ProductList } from '@wix/stores/components';
|
|
94
|
+
*
|
|
95
|
+
* function EmptyProductsMessage() {
|
|
96
|
+
* return (
|
|
97
|
+
* <ProductList.EmptyState>
|
|
98
|
+
* {() => (
|
|
99
|
+
* <div className="empty-state">
|
|
100
|
+
* <h3>No products found</h3>
|
|
101
|
+
* <p>Try adjusting your search or filter criteria</p>
|
|
102
|
+
* <button>Clear Filters</button>
|
|
103
|
+
* </div>
|
|
104
|
+
* )}
|
|
105
|
+
* </ProductList.EmptyState>
|
|
106
|
+
* );
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export declare function EmptyState(props: EmptyStateProps): React.ReactNode;
|
|
111
|
+
/**
|
|
112
|
+
* Props for Loading headless component
|
|
113
|
+
*/
|
|
114
|
+
export interface LoadingProps {
|
|
115
|
+
/** Content to display during loading (can be a render function or ReactNode) */
|
|
116
|
+
children: ((props: LoadingRenderProps) => React.ReactNode) | React.ReactNode;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Render props for Loading component
|
|
120
|
+
*/
|
|
121
|
+
export interface LoadingRenderProps {
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Component that renders content during loading state.
|
|
125
|
+
* Only displays its children when the products list is currently loading.
|
|
126
|
+
*
|
|
127
|
+
* @component
|
|
128
|
+
* @example
|
|
129
|
+
* ```tsx
|
|
130
|
+
* import { ProductList } from '@wix/stores/components';
|
|
131
|
+
*
|
|
132
|
+
* function ProductsLoading() {
|
|
133
|
+
* return (
|
|
134
|
+
* <ProductList.Loading>
|
|
135
|
+
* {() => (
|
|
136
|
+
* <div className="loading-spinner">
|
|
137
|
+
* <div>Loading products...</div>
|
|
138
|
+
* <div className="spinner"></div>
|
|
139
|
+
* </div>
|
|
140
|
+
* )}
|
|
141
|
+
* </ProductList.Loading>
|
|
142
|
+
* );
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export declare function Loading(props: LoadingProps): React.ReactNode;
|
|
147
|
+
/**
|
|
148
|
+
* Props for Error headless component
|
|
149
|
+
*/
|
|
150
|
+
export interface ErrorProps {
|
|
151
|
+
/** Content to display during error state (can be a render function or ReactNode) */
|
|
152
|
+
children: ((props: ErrorRenderProps) => React.ReactNode) | React.ReactNode;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Render props for Error component
|
|
156
|
+
*/
|
|
157
|
+
export interface ErrorRenderProps {
|
|
158
|
+
/** Error message */
|
|
159
|
+
error: string | null;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Component that renders content when there's an error loading products.
|
|
163
|
+
* Only displays its children when an error has occurred.
|
|
164
|
+
*
|
|
165
|
+
* @component
|
|
166
|
+
* @example
|
|
167
|
+
* ```tsx
|
|
168
|
+
* import { ProductList } from '@wix/stores/components';
|
|
169
|
+
*
|
|
170
|
+
* function ProductsError() {
|
|
171
|
+
* return (
|
|
172
|
+
* <ProductList.Error>
|
|
173
|
+
* {({ error }) => (
|
|
174
|
+
* <div className="error-state">
|
|
175
|
+
* <h3>Error loading products</h3>
|
|
176
|
+
* <p>{error}</p>
|
|
177
|
+
* <button onClick={() => window.location.reload()}>
|
|
178
|
+
* Try Again
|
|
179
|
+
* </button>
|
|
180
|
+
* </div>
|
|
181
|
+
* )}
|
|
182
|
+
* </ProductList.Error>
|
|
183
|
+
* );
|
|
184
|
+
* }
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
export declare function Error(props: ErrorProps): React.ReactNode;
|
|
188
|
+
/**
|
|
189
|
+
* Props for ItemContent headless component
|
|
190
|
+
*/
|
|
191
|
+
export interface ItemContentProps {
|
|
192
|
+
/** Content to display for each product (can be a render function receiving product data or ReactNode) */
|
|
193
|
+
children: ((props: ItemContentRenderProps) => React.ReactNode) | React.ReactNode;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Render props for ItemContent component
|
|
197
|
+
*/
|
|
198
|
+
export interface ItemContentRenderProps {
|
|
199
|
+
/** Product data */
|
|
200
|
+
product: productsV3.V3Product;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Component that renders content for each product in the list.
|
|
204
|
+
* Maps over all products and provides each product through a service context.
|
|
205
|
+
* Only renders when products are successfully loaded (not loading, no error, and has products).
|
|
206
|
+
*
|
|
207
|
+
* @component
|
|
208
|
+
* @example
|
|
209
|
+
* ```tsx
|
|
210
|
+
* import { ProductList } from '@wix/stores/components';
|
|
211
|
+
*
|
|
212
|
+
* function ProductsGrid() {
|
|
213
|
+
* return (
|
|
214
|
+
* <ProductList.ItemContent>
|
|
215
|
+
* {({ product }) => (
|
|
216
|
+
* <div className="product-card">
|
|
217
|
+
* <img src={product.media?.main?.image} alt={product.name} />
|
|
218
|
+
* <h3>{product.name}</h3>
|
|
219
|
+
* <p>{product.actualPriceRange?.minValue?.formattedAmount}</p>
|
|
220
|
+
* <button>View Details</button>
|
|
221
|
+
* </div>
|
|
222
|
+
* )}
|
|
223
|
+
* </ProductList.ItemContent>
|
|
224
|
+
* );
|
|
225
|
+
* }
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export declare function ItemContent(props: ItemContentProps): React.ReactNode;
|
|
229
|
+
export type ItemsProps = {
|
|
230
|
+
children: ((props: ItemsRenderProps) => React.ReactNode) | React.ReactNode;
|
|
231
|
+
};
|
|
232
|
+
export type ItemsRenderProps = {
|
|
233
|
+
products: productsV3.V3Product[];
|
|
234
|
+
};
|
|
235
|
+
export declare function Items(props: ItemsProps): import("react").ReactNode;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useService, WixServices } from '@wix/services-manager-react';
|
|
3
|
+
import { createServicesMap } from '@wix/services-manager';
|
|
4
|
+
import { ProductListService, ProductsListServiceDefinition, } from '../../services/products-list-service.js';
|
|
5
|
+
import { ProductService, ProductServiceDefinition, } from '../../services/product-service.js';
|
|
6
|
+
import { CategoriesListService, CategoriesListServiceDefinition, } from '../../services/categories-list-service.js';
|
|
7
|
+
/**
|
|
8
|
+
* Root component that provides both ProductList and ProductListSearch service contexts to its children.
|
|
9
|
+
* This component sets up the necessary services for managing products list state, including search,
|
|
10
|
+
* filtering, sorting, and pagination functionality.
|
|
11
|
+
*
|
|
12
|
+
* @order 1
|
|
13
|
+
* @component
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { ProductList, ProductListFilters, ProductListSort, ProductListPagination } from '@wix/stores/components';
|
|
17
|
+
*
|
|
18
|
+
* function ProductListPage() {
|
|
19
|
+
* return (
|
|
20
|
+
* <ProductList.Root
|
|
21
|
+
* productsListConfig={{
|
|
22
|
+
* products: myProducts,
|
|
23
|
+
* searchOptions: { query: { search: 'searchTerm' } },
|
|
24
|
+
* pagingMetadata: { count: 10, hasNext: true },
|
|
25
|
+
* aggregations: {}
|
|
26
|
+
* }}
|
|
27
|
+
* productsListSearchConfig={{
|
|
28
|
+
* customizations: [],
|
|
29
|
+
* initialSearchState: { sort: 'name_asc', limit: 20 }
|
|
30
|
+
* }}
|
|
31
|
+
* >
|
|
32
|
+
* <ProductListSort.Options>
|
|
33
|
+
* {({ selectedSortOption, updateSortOption, sortOptions }) => (
|
|
34
|
+
* <select value={selectedSortOption} onChange={(e) => updateSortOption(e.target.value)}>
|
|
35
|
+
* {sortOptions.map(option => <option key={option} value={option}>{option}</option>)}
|
|
36
|
+
* </select>
|
|
37
|
+
* )}
|
|
38
|
+
* </ProductListSort.Options>
|
|
39
|
+
*
|
|
40
|
+
* <ProductListFilters.PriceRange>
|
|
41
|
+
* {({ selectedMinPrice, setSelectedMinPrice }) => (
|
|
42
|
+
* <input value={selectedMinPrice} onChange={(e) => setSelectedMinPrice(Number(e.target.value))} />
|
|
43
|
+
* )}
|
|
44
|
+
* </ProductListFilters.PriceRange>
|
|
45
|
+
*
|
|
46
|
+
* <ProductList.ItemContent>
|
|
47
|
+
* {({ product }) => (
|
|
48
|
+
* <div key={product._id}>
|
|
49
|
+
* <h3>{product.name}</h3>
|
|
50
|
+
* <p>{product.actualPriceRange?.minValue?.formattedAmount}</p>
|
|
51
|
+
* </div>
|
|
52
|
+
* )}
|
|
53
|
+
* </ProductList.ItemContent>
|
|
54
|
+
*
|
|
55
|
+
* <ProductListPagination.NextPageTrigger>
|
|
56
|
+
* {({ nextPage, hasNextPage }) => (
|
|
57
|
+
* <button onClick={nextPage} disabled={!hasNextPage}>Next</button>
|
|
58
|
+
* )}
|
|
59
|
+
* </ProductListPagination.NextPageTrigger>
|
|
60
|
+
* </ProductList.Root>
|
|
61
|
+
* );
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export function Root(props) {
|
|
66
|
+
return (_jsx(WixServices, { servicesMap: createServicesMap()
|
|
67
|
+
.addService(CategoriesListServiceDefinition, CategoriesListService, props.categoriesListConfig)
|
|
68
|
+
.addService(ProductsListServiceDefinition, ProductListService, props.productsListConfig), children: props.children }));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Component that renders content when the products list is empty.
|
|
72
|
+
* Only displays its children when there are no products, no loading state, and no errors.
|
|
73
|
+
*
|
|
74
|
+
* @component
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* import { ProductList } from '@wix/stores/components';
|
|
78
|
+
*
|
|
79
|
+
* function EmptyProductsMessage() {
|
|
80
|
+
* return (
|
|
81
|
+
* <ProductList.EmptyState>
|
|
82
|
+
* {() => (
|
|
83
|
+
* <div className="empty-state">
|
|
84
|
+
* <h3>No products found</h3>
|
|
85
|
+
* <p>Try adjusting your search or filter criteria</p>
|
|
86
|
+
* <button>Clear Filters</button>
|
|
87
|
+
* </div>
|
|
88
|
+
* )}
|
|
89
|
+
* </ProductList.EmptyState>
|
|
90
|
+
* );
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export function EmptyState(props) {
|
|
95
|
+
const { isLoading, error, products } = useService(ProductsListServiceDefinition);
|
|
96
|
+
const isLoadingValue = isLoading.get();
|
|
97
|
+
const errorValue = error.get();
|
|
98
|
+
const productsValue = products.get();
|
|
99
|
+
if (!isLoadingValue && !errorValue && productsValue.length === 0) {
|
|
100
|
+
return typeof props.children === 'function'
|
|
101
|
+
? props.children({})
|
|
102
|
+
: props.children;
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Component that renders content during loading state.
|
|
108
|
+
* Only displays its children when the products list is currently loading.
|
|
109
|
+
*
|
|
110
|
+
* @component
|
|
111
|
+
* @example
|
|
112
|
+
* ```tsx
|
|
113
|
+
* import { ProductList } from '@wix/stores/components';
|
|
114
|
+
*
|
|
115
|
+
* function ProductsLoading() {
|
|
116
|
+
* return (
|
|
117
|
+
* <ProductList.Loading>
|
|
118
|
+
* {() => (
|
|
119
|
+
* <div className="loading-spinner">
|
|
120
|
+
* <div>Loading products...</div>
|
|
121
|
+
* <div className="spinner"></div>
|
|
122
|
+
* </div>
|
|
123
|
+
* )}
|
|
124
|
+
* </ProductList.Loading>
|
|
125
|
+
* );
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export function Loading(props) {
|
|
130
|
+
const { isLoading } = useService(ProductsListServiceDefinition);
|
|
131
|
+
const isLoadingValue = isLoading.get();
|
|
132
|
+
if (isLoadingValue) {
|
|
133
|
+
return typeof props.children === 'function'
|
|
134
|
+
? props.children({})
|
|
135
|
+
: props.children;
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Component that renders content when there's an error loading products.
|
|
141
|
+
* Only displays its children when an error has occurred.
|
|
142
|
+
*
|
|
143
|
+
* @component
|
|
144
|
+
* @example
|
|
145
|
+
* ```tsx
|
|
146
|
+
* import { ProductList } from '@wix/stores/components';
|
|
147
|
+
*
|
|
148
|
+
* function ProductsError() {
|
|
149
|
+
* return (
|
|
150
|
+
* <ProductList.Error>
|
|
151
|
+
* {({ error }) => (
|
|
152
|
+
* <div className="error-state">
|
|
153
|
+
* <h3>Error loading products</h3>
|
|
154
|
+
* <p>{error}</p>
|
|
155
|
+
* <button onClick={() => window.location.reload()}>
|
|
156
|
+
* Try Again
|
|
157
|
+
* </button>
|
|
158
|
+
* </div>
|
|
159
|
+
* )}
|
|
160
|
+
* </ProductList.Error>
|
|
161
|
+
* );
|
|
162
|
+
* }
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export function Error(props) {
|
|
166
|
+
const { error } = useService(ProductsListServiceDefinition);
|
|
167
|
+
const errorValue = error.get();
|
|
168
|
+
if (errorValue) {
|
|
169
|
+
return typeof props.children === 'function'
|
|
170
|
+
? props.children({ error: errorValue })
|
|
171
|
+
: props.children;
|
|
172
|
+
}
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Component that renders content for each product in the list.
|
|
177
|
+
* Maps over all products and provides each product through a service context.
|
|
178
|
+
* Only renders when products are successfully loaded (not loading, no error, and has products).
|
|
179
|
+
*
|
|
180
|
+
* @component
|
|
181
|
+
* @example
|
|
182
|
+
* ```tsx
|
|
183
|
+
* import { ProductList } from '@wix/stores/components';
|
|
184
|
+
*
|
|
185
|
+
* function ProductsGrid() {
|
|
186
|
+
* return (
|
|
187
|
+
* <ProductList.ItemContent>
|
|
188
|
+
* {({ product }) => (
|
|
189
|
+
* <div className="product-card">
|
|
190
|
+
* <img src={product.media?.main?.image} alt={product.name} />
|
|
191
|
+
* <h3>{product.name}</h3>
|
|
192
|
+
* <p>{product.actualPriceRange?.minValue?.formattedAmount}</p>
|
|
193
|
+
* <button>View Details</button>
|
|
194
|
+
* </div>
|
|
195
|
+
* )}
|
|
196
|
+
* </ProductList.ItemContent>
|
|
197
|
+
* );
|
|
198
|
+
* }
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
export function ItemContent(props) {
|
|
202
|
+
const { products, isLoading, error } = useService(ProductsListServiceDefinition);
|
|
203
|
+
const productsValue = products.get();
|
|
204
|
+
if (isLoading.get() || error.get() || productsValue.length === 0) {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
return productsValue.map((product) => (_jsx(WixServices, { servicesMap: createServicesMap().addService(ProductServiceDefinition, ProductService, { product }), children: typeof props.children === 'function'
|
|
208
|
+
? props.children({ product })
|
|
209
|
+
: props.children }, product._id)));
|
|
210
|
+
}
|
|
211
|
+
export function Items(props) {
|
|
212
|
+
const { products } = useService(ProductsListServiceDefinition);
|
|
213
|
+
const productsValue = products.get();
|
|
214
|
+
return typeof props.children === 'function'
|
|
215
|
+
? props.children({ products: productsValue })
|
|
216
|
+
: props.children;
|
|
217
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { Category } from '@wix/auto_sdk_categories_categories';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* Props for ResetTrigger headless component
|
|
6
|
+
*/
|
|
7
|
+
export interface ResetTriggerProps {
|
|
8
|
+
/** Content to display (can be a render function receiving reset controls or ReactNode) */
|
|
9
|
+
children: ((props: ResetTriggerRenderProps) => ReactNode) | ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Render props for ResetTrigger component
|
|
13
|
+
*/
|
|
14
|
+
export interface ResetTriggerRenderProps {
|
|
15
|
+
/** Function to reset all filters */
|
|
16
|
+
resetFilters: () => void;
|
|
17
|
+
/** Whether any filters are currently applied */
|
|
18
|
+
isFiltered: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Headless component for resetting all filters
|
|
22
|
+
*
|
|
23
|
+
* @component
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* import { ProductList, ProductListFilters } from '@wix/stores/components';
|
|
27
|
+
*
|
|
28
|
+
* function ResetFiltersButton() {
|
|
29
|
+
* return (
|
|
30
|
+
* <ProductList.Root
|
|
31
|
+
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
32
|
+
* productsListSearchConfig={{ customizations: [] }}
|
|
33
|
+
* >
|
|
34
|
+
* <ProductListFilters.ResetTrigger>
|
|
35
|
+
* {({ resetFilters, isFiltered }) => (
|
|
36
|
+
* <button
|
|
37
|
+
* onClick={resetFilters}
|
|
38
|
+
* disabled={!isFiltered}
|
|
39
|
+
* className={isFiltered ? 'active' : 'disabled'}
|
|
40
|
+
* >
|
|
41
|
+
* {isFiltered ? 'Clear Filters' : 'No Filters Applied'}
|
|
42
|
+
* </button>
|
|
43
|
+
* )}
|
|
44
|
+
* </ProductListFilters.ResetTrigger>
|
|
45
|
+
* </ProductList.Root>
|
|
46
|
+
* );
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function ResetTrigger(props: ResetTriggerProps): ReactNode;
|
|
51
|
+
export interface CategoryFilterRenderProps {
|
|
52
|
+
selectedCategory: Category | null;
|
|
53
|
+
setSelectedCategory: (category: Category | null) => void;
|
|
54
|
+
}
|
|
55
|
+
export interface CategoryFilterProps {
|
|
56
|
+
/** Content to display (can be a render function receiving category data or ReactNode) */
|
|
57
|
+
children: ((props: CategoryFilterRenderProps) => ReactNode) | ReactNode;
|
|
58
|
+
}
|
|
59
|
+
export declare function CategoryFilter(props: CategoryFilterProps): ReactNode;
|
|
60
|
+
/**
|
|
61
|
+
* Props for the ProductList Filter component
|
|
62
|
+
*/
|
|
63
|
+
export interface FilterProps {
|
|
64
|
+
/**
|
|
65
|
+
* Child components that will have access to filter functionality.
|
|
66
|
+
* Typically contains Filter primitive components like FilterOptions,
|
|
67
|
+
* FilterOptionRepeater, etc.
|
|
68
|
+
*/
|
|
69
|
+
children: ReactNode;
|
|
70
|
+
/**
|
|
71
|
+
* When true, the component will not render its own div wrapper but will
|
|
72
|
+
* delegate rendering to its child component. Useful for custom containers.
|
|
73
|
+
*
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
asChild?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* CSS classes to apply to the filter container.
|
|
79
|
+
* Only used when asChild is false (default).
|
|
80
|
+
*/
|
|
81
|
+
className?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Filter component that provides comprehensive filtering functionality for product lists.
|
|
85
|
+
*
|
|
86
|
+
* This component acts as a provider that integrates with the ProductList service to offer
|
|
87
|
+
* predefined filter options including:
|
|
88
|
+
* - **Price Range**: Min/max price filtering with currency formatting
|
|
89
|
+
* - **Product Options**: Dynamic filters for colors, sizes, and other product variants
|
|
90
|
+
* - **Inventory Status**: Filter by availability (In Stock, Out of Stock, Limited Stock)
|
|
91
|
+
*
|
|
92
|
+
* The component automatically extracts available filter options from the current product set
|
|
93
|
+
* and provides them to child Filter primitive components for rendering.
|
|
94
|
+
*
|
|
95
|
+
* @component
|
|
96
|
+
* @example
|
|
97
|
+
* ```tsx
|
|
98
|
+
* // Basic usage with styled filter components
|
|
99
|
+
* <ProductList.Filter>
|
|
100
|
+
* <Filter.FilterOptions>
|
|
101
|
+
* <Filter.FilterOptionRepeater>
|
|
102
|
+
* <Filter.FilterOption.Label />
|
|
103
|
+
* <Filter.FilterOption.MultiFilter />
|
|
104
|
+
* <Filter.FilterOption.RangeFilter />
|
|
105
|
+
* </Filter.FilterOptionRepeater>
|
|
106
|
+
* </Filter.FilterOptions>
|
|
107
|
+
* </ProductList.Filter>
|
|
108
|
+
*
|
|
109
|
+
* // With custom container using asChild
|
|
110
|
+
* <ProductList.Filter asChild>
|
|
111
|
+
* <aside className="filter-sidebar">
|
|
112
|
+
* <Filter.FilterOptions>
|
|
113
|
+
* <Filter.FilterOptionRepeater>
|
|
114
|
+
* <Filter.FilterOption.Label />
|
|
115
|
+
* <Filter.FilterOption.MultiFilter />
|
|
116
|
+
* </Filter.FilterOptionRepeater>
|
|
117
|
+
* </Filter.FilterOptions>
|
|
118
|
+
* </aside>
|
|
119
|
+
* </ProductList.Filter>
|
|
120
|
+
*
|
|
121
|
+
* // With reset functionality
|
|
122
|
+
* <ProductList.Filter className="filters-container">
|
|
123
|
+
* <Filter.Action.Clear label="Clear All" />
|
|
124
|
+
* <Filter.FilterOptions>
|
|
125
|
+
* <Filter.FilterOptionRepeater>
|
|
126
|
+
* <Filter.FilterOption.Label />
|
|
127
|
+
* <Filter.FilterOption.MultiFilter />
|
|
128
|
+
* <Filter.FilterOption.RangeFilter />
|
|
129
|
+
* </Filter.FilterOptionRepeater>
|
|
130
|
+
* </Filter.FilterOptions>
|
|
131
|
+
* </ProductList.Filter>
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @see {@link AllFilters} for the underlying filter data logic
|
|
135
|
+
* @see {@link FilterPrimitive.Root} for the primitive filter component
|
|
136
|
+
* @see {@link ResetTrigger} for filter reset functionality
|
|
137
|
+
*/
|
|
138
|
+
export declare const FilterRoot: React.ForwardRefExoticComponent<FilterProps & React.RefAttributes<HTMLDivElement>>;
|