@wix/headless-stores 0.0.35 → 0.0.37
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/Category.d.ts +83 -31
- package/cjs/dist/react/Category.js +68 -35
- package/cjs/dist/react/CategoryList.d.ts +184 -0
- package/cjs/dist/react/CategoryList.js +174 -0
- package/cjs/dist/react/Product.d.ts +3 -3
- package/cjs/dist/react/Product.js +6 -6
- package/cjs/dist/react/ProductActions.d.ts +1 -1
- package/cjs/dist/react/ProductActions.js +2 -2
- package/{dist/react/ProductsList.d.ts → cjs/dist/react/ProductList.d.ts} +71 -38
- package/{dist/react/ProductsList.js → cjs/dist/react/ProductList.js} +30 -26
- package/cjs/dist/react/ProductListFilters.d.ts +244 -0
- package/cjs/dist/react/ProductListFilters.js +216 -0
- package/cjs/dist/react/ProductListPagination.d.ts +246 -0
- package/cjs/dist/react/ProductListPagination.js +207 -0
- package/cjs/dist/react/ProductListSort.d.ts +87 -0
- package/cjs/dist/react/ProductListSort.js +85 -0
- package/cjs/dist/react/ProductModifiers.d.ts +5 -5
- package/cjs/dist/react/ProductModifiers.js +10 -10
- package/cjs/dist/react/ProductVariantSelector.d.ts +5 -5
- package/cjs/dist/react/ProductVariantSelector.js +13 -10
- package/cjs/dist/react/SelectedVariant.d.ts +3 -3
- package/cjs/dist/react/SelectedVariant.js +6 -6
- package/cjs/dist/react/index.d.ts +7 -9
- package/cjs/dist/react/index.js +7 -9
- package/cjs/dist/services/buy-now-service.d.ts +208 -0
- package/cjs/dist/services/buy-now-service.js +132 -1
- package/cjs/dist/services/categories-list-service.d.ts +163 -0
- package/cjs/dist/services/categories-list-service.js +148 -0
- package/cjs/dist/services/category-service.d.ts +115 -70
- package/cjs/dist/services/category-service.js +101 -110
- package/cjs/dist/services/index.d.ts +6 -7
- package/cjs/dist/services/index.js +5 -16
- package/cjs/dist/services/pay-now-service.d.ts +146 -0
- package/cjs/dist/services/pay-now-service.js +112 -1
- package/cjs/dist/services/product-service.d.ts +71 -0
- package/cjs/dist/services/product-service.js +47 -0
- package/cjs/dist/services/products-list-filters-service.d.ts +292 -0
- package/cjs/dist/services/products-list-filters-service.js +446 -0
- package/cjs/dist/services/products-list-pagination-service.d.ts +186 -0
- package/cjs/dist/services/products-list-pagination-service.js +179 -0
- package/cjs/dist/services/products-list-service.d.ts +138 -52
- package/cjs/dist/services/products-list-service.js +98 -51
- package/cjs/dist/services/products-list-sort-service.d.ts +117 -0
- package/cjs/dist/services/products-list-sort-service.js +144 -0
- package/cjs/dist/services/selected-variant-service.js +0 -1
- package/cjs/dist/utils/url-params.d.ts +68 -0
- package/cjs/dist/utils/url-params.js +72 -4
- package/dist/react/Category.d.ts +83 -31
- package/dist/react/Category.js +68 -35
- package/dist/react/CategoryList.d.ts +184 -0
- package/dist/react/CategoryList.js +174 -0
- package/dist/react/Product.d.ts +3 -3
- package/dist/react/Product.js +6 -6
- package/dist/react/ProductActions.d.ts +1 -1
- package/dist/react/ProductActions.js +2 -2
- package/{cjs/dist/react/ProductsList.d.ts → dist/react/ProductList.d.ts} +71 -38
- package/{cjs/dist/react/ProductsList.js → dist/react/ProductList.js} +30 -26
- package/dist/react/ProductListFilters.d.ts +244 -0
- package/dist/react/ProductListFilters.js +216 -0
- package/dist/react/ProductListPagination.d.ts +246 -0
- package/dist/react/ProductListPagination.js +207 -0
- package/dist/react/ProductListSort.d.ts +87 -0
- package/dist/react/ProductListSort.js +85 -0
- package/dist/react/ProductModifiers.d.ts +5 -5
- package/dist/react/ProductModifiers.js +10 -10
- package/dist/react/ProductVariantSelector.d.ts +5 -5
- package/dist/react/ProductVariantSelector.js +13 -10
- package/dist/react/SelectedVariant.d.ts +3 -3
- package/dist/react/SelectedVariant.js +6 -6
- package/dist/react/index.d.ts +7 -9
- package/dist/react/index.js +7 -9
- package/dist/services/buy-now-service.d.ts +208 -0
- package/dist/services/buy-now-service.js +132 -1
- package/dist/services/categories-list-service.d.ts +163 -0
- package/dist/services/categories-list-service.js +148 -0
- package/dist/services/category-service.d.ts +115 -70
- package/dist/services/category-service.js +101 -110
- package/dist/services/index.d.ts +6 -7
- package/dist/services/index.js +5 -16
- package/dist/services/pay-now-service.d.ts +146 -0
- package/dist/services/pay-now-service.js +112 -1
- package/dist/services/product-service.d.ts +71 -0
- package/dist/services/product-service.js +47 -0
- package/dist/services/products-list-filters-service.d.ts +292 -0
- package/dist/services/products-list-filters-service.js +446 -0
- package/dist/services/products-list-pagination-service.d.ts +186 -0
- package/dist/services/products-list-pagination-service.js +179 -0
- package/dist/services/products-list-service.d.ts +138 -52
- package/dist/services/products-list-service.js +98 -51
- package/dist/services/products-list-sort-service.d.ts +117 -0
- package/dist/services/products-list-sort-service.js +144 -0
- package/dist/services/selected-variant-service.js +0 -1
- package/dist/utils/url-params.d.ts +68 -0
- package/dist/utils/url-params.js +72 -4
- package/package.json +3 -3
- package/cjs/dist/react/Collection.d.ts +0 -294
- package/cjs/dist/react/Collection.js +0 -345
- package/cjs/dist/react/FilteredCollection.d.ts +0 -216
- package/cjs/dist/react/FilteredCollection.js +0 -256
- package/cjs/dist/react/RelatedProducts.d.ts +0 -169
- package/cjs/dist/react/RelatedProducts.js +0 -180
- package/cjs/dist/react/Sort.d.ts +0 -37
- package/cjs/dist/react/Sort.js +0 -36
- package/cjs/dist/services/catalog-service.d.ts +0 -36
- package/cjs/dist/services/catalog-service.js +0 -193
- package/cjs/dist/services/collection-service.d.ts +0 -124
- package/cjs/dist/services/collection-service.js +0 -628
- package/cjs/dist/services/filter-service.d.ts +0 -35
- package/cjs/dist/services/filter-service.js +0 -119
- package/cjs/dist/services/related-products-service.d.ts +0 -100
- package/cjs/dist/services/related-products-service.js +0 -127
- package/cjs/dist/services/sort-service.d.ts +0 -20
- package/cjs/dist/services/sort-service.js +0 -27
- package/dist/react/Collection.d.ts +0 -294
- package/dist/react/Collection.js +0 -345
- package/dist/react/FilteredCollection.d.ts +0 -216
- package/dist/react/FilteredCollection.js +0 -256
- package/dist/react/RelatedProducts.d.ts +0 -169
- package/dist/react/RelatedProducts.js +0 -180
- package/dist/react/Sort.d.ts +0 -37
- package/dist/react/Sort.js +0 -36
- package/dist/services/catalog-service.d.ts +0 -36
- package/dist/services/catalog-service.js +0 -193
- package/dist/services/collection-service.d.ts +0 -124
- package/dist/services/collection-service.js +0 -628
- package/dist/services/filter-service.d.ts +0 -35
- package/dist/services/filter-service.js +0 -119
- package/dist/services/related-products-service.d.ts +0 -100
- package/dist/services/related-products-service.js +0 -127
- package/dist/services/sort-service.d.ts +0 -20
- package/dist/services/sort-service.js +0 -27
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import { type ProductsListServiceConfig } from "../services/products-list-service.js";
|
|
2
2
|
import { productsV3 } from "@wix/stores";
|
|
3
|
+
/**
|
|
4
|
+
* Props for Root headless component
|
|
5
|
+
*/
|
|
3
6
|
export interface RootProps {
|
|
4
|
-
/** Child components that will have access to the
|
|
7
|
+
/** Child components that will have access to the ProductList service */
|
|
5
8
|
children: React.ReactNode;
|
|
6
|
-
/** Configuration for the
|
|
9
|
+
/** Configuration for the ProductList service */
|
|
7
10
|
productsListConfig: ProductsListServiceConfig;
|
|
8
11
|
}
|
|
9
12
|
/**
|
|
10
|
-
* Root component that provides the
|
|
13
|
+
* Root component that provides the ProductList service context to its children.
|
|
11
14
|
* This component sets up the necessary services for managing products list state.
|
|
12
15
|
*
|
|
13
16
|
* @order 1
|
|
14
17
|
* @component
|
|
15
18
|
* @example
|
|
16
19
|
* ```tsx
|
|
17
|
-
* import {
|
|
20
|
+
* import { ProductList } from '@wix/stores/components';
|
|
18
21
|
*
|
|
19
|
-
* function
|
|
22
|
+
* function ProductListPage() {
|
|
20
23
|
* return (
|
|
21
|
-
* <
|
|
24
|
+
* <ProductList.Root
|
|
22
25
|
* productsListConfig={{
|
|
23
26
|
* products: myProducts,
|
|
24
27
|
* searchOptions: { query: { search: 'searchTerm' } },
|
|
@@ -26,27 +29,30 @@ export interface RootProps {
|
|
|
26
29
|
* aggregations: {}
|
|
27
30
|
* }}
|
|
28
31
|
* >
|
|
29
|
-
* <
|
|
30
|
-
* {({
|
|
31
|
-
* <div>
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* {products.map(product => (
|
|
35
|
-
* <div key={product.id}>{product.name}</div>
|
|
36
|
-
* ))}
|
|
32
|
+
* <ProductList.ItemContent>
|
|
33
|
+
* {({ product }) => (
|
|
34
|
+
* <div key={product._id}>
|
|
35
|
+
* <h3>{product.name}</h3>
|
|
36
|
+
* <p>{product.actualPriceRange?.minValue?.formattedAmount}</p>
|
|
37
37
|
* </div>
|
|
38
38
|
* )}
|
|
39
|
-
* </
|
|
40
|
-
* </
|
|
39
|
+
* </ProductList.ItemContent>
|
|
40
|
+
* </ProductList.Root>
|
|
41
41
|
* );
|
|
42
42
|
* }
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
45
|
export declare function Root(props: RootProps): React.ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* Props for EmptyState headless component
|
|
48
|
+
*/
|
|
46
49
|
export interface EmptyStateProps {
|
|
47
50
|
/** Content to display when products list is empty (can be a render function or ReactNode) */
|
|
48
|
-
children: (props: EmptyStateRenderProps) => React.ReactNode;
|
|
51
|
+
children: ((props: EmptyStateRenderProps) => React.ReactNode) | React.ReactNode;
|
|
49
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Render props for EmptyState component
|
|
55
|
+
*/
|
|
50
56
|
export interface EmptyStateRenderProps {
|
|
51
57
|
}
|
|
52
58
|
/**
|
|
@@ -56,11 +62,11 @@ export interface EmptyStateRenderProps {
|
|
|
56
62
|
* @component
|
|
57
63
|
* @example
|
|
58
64
|
* ```tsx
|
|
59
|
-
* import {
|
|
65
|
+
* import { ProductList } from '@wix/stores/components';
|
|
60
66
|
*
|
|
61
67
|
* function EmptyProductsMessage() {
|
|
62
68
|
* return (
|
|
63
|
-
* <
|
|
69
|
+
* <ProductList.EmptyState>
|
|
64
70
|
* {() => (
|
|
65
71
|
* <div className="empty-state">
|
|
66
72
|
* <h3>No products found</h3>
|
|
@@ -68,16 +74,22 @@ export interface EmptyStateRenderProps {
|
|
|
68
74
|
* <button>Clear Filters</button>
|
|
69
75
|
* </div>
|
|
70
76
|
* )}
|
|
71
|
-
* </
|
|
77
|
+
* </ProductList.EmptyState>
|
|
72
78
|
* );
|
|
73
79
|
* }
|
|
74
80
|
* ```
|
|
75
81
|
*/
|
|
76
82
|
export declare function EmptyState(props: EmptyStateProps): React.ReactNode;
|
|
83
|
+
/**
|
|
84
|
+
* Props for Loading headless component
|
|
85
|
+
*/
|
|
77
86
|
export interface LoadingProps {
|
|
78
87
|
/** Content to display during loading (can be a render function or ReactNode) */
|
|
79
|
-
children: (props: LoadingRenderProps) => React.ReactNode;
|
|
88
|
+
children: ((props: LoadingRenderProps) => React.ReactNode) | React.ReactNode;
|
|
80
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Render props for Loading component
|
|
92
|
+
*/
|
|
81
93
|
export interface LoadingRenderProps {
|
|
82
94
|
}
|
|
83
95
|
/**
|
|
@@ -87,29 +99,36 @@ export interface LoadingRenderProps {
|
|
|
87
99
|
* @component
|
|
88
100
|
* @example
|
|
89
101
|
* ```tsx
|
|
90
|
-
* import {
|
|
102
|
+
* import { ProductList } from '@wix/stores/components';
|
|
91
103
|
*
|
|
92
104
|
* function ProductsLoading() {
|
|
93
105
|
* return (
|
|
94
|
-
* <
|
|
106
|
+
* <ProductList.Loading>
|
|
95
107
|
* {() => (
|
|
96
108
|
* <div className="loading-spinner">
|
|
97
109
|
* <div>Loading products...</div>
|
|
98
110
|
* <div className="spinner"></div>
|
|
99
111
|
* </div>
|
|
100
112
|
* )}
|
|
101
|
-
* </
|
|
113
|
+
* </ProductList.Loading>
|
|
102
114
|
* );
|
|
103
115
|
* }
|
|
104
116
|
* ```
|
|
105
117
|
*/
|
|
106
118
|
export declare function Loading(props: LoadingProps): React.ReactNode;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Props for Error headless component
|
|
121
|
+
*/
|
|
110
122
|
export interface ErrorProps {
|
|
111
123
|
/** Content to display during error state (can be a render function or ReactNode) */
|
|
112
|
-
children: (props: ErrorRenderProps) => React.ReactNode;
|
|
124
|
+
children: ((props: ErrorRenderProps) => React.ReactNode) | React.ReactNode;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Render props for Error component
|
|
128
|
+
*/
|
|
129
|
+
export interface ErrorRenderProps {
|
|
130
|
+
/** Error message */
|
|
131
|
+
error: string | null;
|
|
113
132
|
}
|
|
114
133
|
/**
|
|
115
134
|
* Component that renders content when there's an error loading products.
|
|
@@ -118,11 +137,11 @@ export interface ErrorProps {
|
|
|
118
137
|
* @component
|
|
119
138
|
* @example
|
|
120
139
|
* ```tsx
|
|
121
|
-
* import {
|
|
140
|
+
* import { ProductList } from '@wix/stores/components';
|
|
122
141
|
*
|
|
123
142
|
* function ProductsError() {
|
|
124
143
|
* return (
|
|
125
|
-
* <
|
|
144
|
+
* <ProductList.Error>
|
|
126
145
|
* {({ error }) => (
|
|
127
146
|
* <div className="error-state">
|
|
128
147
|
* <h3>Error loading products</h3>
|
|
@@ -132,18 +151,25 @@ export interface ErrorProps {
|
|
|
132
151
|
* </button>
|
|
133
152
|
* </div>
|
|
134
153
|
* )}
|
|
135
|
-
* </
|
|
154
|
+
* </ProductList.Error>
|
|
136
155
|
* );
|
|
137
156
|
* }
|
|
138
157
|
* ```
|
|
139
158
|
*/
|
|
140
159
|
export declare function Error(props: ErrorProps): React.ReactNode;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
160
|
+
/**
|
|
161
|
+
* Props for ItemContent headless component
|
|
162
|
+
*/
|
|
144
163
|
export interface ItemContentProps {
|
|
145
164
|
/** Content to display for each product (can be a render function receiving product data or ReactNode) */
|
|
146
|
-
children: (props: ItemContentRenderProps) => React.ReactNode;
|
|
165
|
+
children: ((props: ItemContentRenderProps) => React.ReactNode) | React.ReactNode;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Render props for ItemContent component
|
|
169
|
+
*/
|
|
170
|
+
export interface ItemContentRenderProps {
|
|
171
|
+
/** Product data */
|
|
172
|
+
product: productsV3.V3Product;
|
|
147
173
|
}
|
|
148
174
|
/**
|
|
149
175
|
* Component that renders content for each product in the list.
|
|
@@ -153,11 +179,11 @@ export interface ItemContentProps {
|
|
|
153
179
|
* @component
|
|
154
180
|
* @example
|
|
155
181
|
* ```tsx
|
|
156
|
-
* import {
|
|
182
|
+
* import { ProductList } from '@wix/stores/components';
|
|
157
183
|
*
|
|
158
184
|
* function ProductsGrid() {
|
|
159
185
|
* return (
|
|
160
|
-
* <
|
|
186
|
+
* <ProductList.ItemContent>
|
|
161
187
|
* {({ product }) => (
|
|
162
188
|
* <div className="product-card">
|
|
163
189
|
* <img src={product.media?.main?.image} alt={product.name} />
|
|
@@ -166,9 +192,16 @@ export interface ItemContentProps {
|
|
|
166
192
|
* <button>View Details</button>
|
|
167
193
|
* </div>
|
|
168
194
|
* )}
|
|
169
|
-
* </
|
|
195
|
+
* </ProductList.ItemContent>
|
|
170
196
|
* );
|
|
171
197
|
* }
|
|
172
198
|
* ```
|
|
173
199
|
*/
|
|
174
200
|
export declare function ItemContent(props: ItemContentProps): React.ReactNode;
|
|
201
|
+
export type ItemsProps = {
|
|
202
|
+
children: ((props: ItemsRenderProps) => React.ReactNode) | React.ReactNode;
|
|
203
|
+
};
|
|
204
|
+
export type ItemsRenderProps = {
|
|
205
|
+
products: productsV3.V3Product[];
|
|
206
|
+
};
|
|
207
|
+
export declare function Items(props: ItemsProps): import("react").ReactNode;
|
|
@@ -4,18 +4,18 @@ import { createServicesMap } from "@wix/services-manager";
|
|
|
4
4
|
import { ProductListService, ProductsListServiceDefinition, } from "../services/products-list-service.js";
|
|
5
5
|
import { ProductService, ProductServiceDefinition, } from "@wix/headless-stores/services";
|
|
6
6
|
/**
|
|
7
|
-
* Root component that provides the
|
|
7
|
+
* Root component that provides the ProductList service context to its children.
|
|
8
8
|
* This component sets up the necessary services for managing products list state.
|
|
9
9
|
*
|
|
10
10
|
* @order 1
|
|
11
11
|
* @component
|
|
12
12
|
* @example
|
|
13
13
|
* ```tsx
|
|
14
|
-
* import {
|
|
14
|
+
* import { ProductList } from '@wix/stores/components';
|
|
15
15
|
*
|
|
16
|
-
* function
|
|
16
|
+
* function ProductListPage() {
|
|
17
17
|
* return (
|
|
18
|
-
* <
|
|
18
|
+
* <ProductList.Root
|
|
19
19
|
* productsListConfig={{
|
|
20
20
|
* products: myProducts,
|
|
21
21
|
* searchOptions: { query: { search: 'searchTerm' } },
|
|
@@ -23,18 +23,15 @@ import { ProductService, ProductServiceDefinition, } from "@wix/headless-stores/
|
|
|
23
23
|
* aggregations: {}
|
|
24
24
|
* }}
|
|
25
25
|
* >
|
|
26
|
-
* <
|
|
27
|
-
* {({
|
|
28
|
-
* <div>
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* {products.map(product => (
|
|
32
|
-
* <div key={product.id}>{product.name}</div>
|
|
33
|
-
* ))}
|
|
26
|
+
* <ProductList.ItemContent>
|
|
27
|
+
* {({ product }) => (
|
|
28
|
+
* <div key={product._id}>
|
|
29
|
+
* <h3>{product.name}</h3>
|
|
30
|
+
* <p>{product.actualPriceRange?.minValue?.formattedAmount}</p>
|
|
34
31
|
* </div>
|
|
35
32
|
* )}
|
|
36
|
-
* </
|
|
37
|
-
* </
|
|
33
|
+
* </ProductList.ItemContent>
|
|
34
|
+
* </ProductList.Root>
|
|
38
35
|
* );
|
|
39
36
|
* }
|
|
40
37
|
* ```
|
|
@@ -49,11 +46,11 @@ export function Root(props) {
|
|
|
49
46
|
* @component
|
|
50
47
|
* @example
|
|
51
48
|
* ```tsx
|
|
52
|
-
* import {
|
|
49
|
+
* import { ProductList } from '@wix/stores/components';
|
|
53
50
|
*
|
|
54
51
|
* function EmptyProductsMessage() {
|
|
55
52
|
* return (
|
|
56
|
-
* <
|
|
53
|
+
* <ProductList.EmptyState>
|
|
57
54
|
* {() => (
|
|
58
55
|
* <div className="empty-state">
|
|
59
56
|
* <h3>No products found</h3>
|
|
@@ -61,7 +58,7 @@ export function Root(props) {
|
|
|
61
58
|
* <button>Clear Filters</button>
|
|
62
59
|
* </div>
|
|
63
60
|
* )}
|
|
64
|
-
* </
|
|
61
|
+
* </ProductList.EmptyState>
|
|
65
62
|
* );
|
|
66
63
|
* }
|
|
67
64
|
* ```
|
|
@@ -85,18 +82,18 @@ export function EmptyState(props) {
|
|
|
85
82
|
* @component
|
|
86
83
|
* @example
|
|
87
84
|
* ```tsx
|
|
88
|
-
* import {
|
|
85
|
+
* import { ProductList } from '@wix/stores/components';
|
|
89
86
|
*
|
|
90
87
|
* function ProductsLoading() {
|
|
91
88
|
* return (
|
|
92
|
-
* <
|
|
89
|
+
* <ProductList.Loading>
|
|
93
90
|
* {() => (
|
|
94
91
|
* <div className="loading-spinner">
|
|
95
92
|
* <div>Loading products...</div>
|
|
96
93
|
* <div className="spinner"></div>
|
|
97
94
|
* </div>
|
|
98
95
|
* )}
|
|
99
|
-
* </
|
|
96
|
+
* </ProductList.Loading>
|
|
100
97
|
* );
|
|
101
98
|
* }
|
|
102
99
|
* ```
|
|
@@ -118,11 +115,11 @@ export function Loading(props) {
|
|
|
118
115
|
* @component
|
|
119
116
|
* @example
|
|
120
117
|
* ```tsx
|
|
121
|
-
* import {
|
|
118
|
+
* import { ProductList } from '@wix/stores/components';
|
|
122
119
|
*
|
|
123
120
|
* function ProductsError() {
|
|
124
121
|
* return (
|
|
125
|
-
* <
|
|
122
|
+
* <ProductList.Error>
|
|
126
123
|
* {({ error }) => (
|
|
127
124
|
* <div className="error-state">
|
|
128
125
|
* <h3>Error loading products</h3>
|
|
@@ -132,7 +129,7 @@ export function Loading(props) {
|
|
|
132
129
|
* </button>
|
|
133
130
|
* </div>
|
|
134
131
|
* )}
|
|
135
|
-
* </
|
|
132
|
+
* </ProductList.Error>
|
|
136
133
|
* );
|
|
137
134
|
* }
|
|
138
135
|
* ```
|
|
@@ -155,11 +152,11 @@ export function Error(props) {
|
|
|
155
152
|
* @component
|
|
156
153
|
* @example
|
|
157
154
|
* ```tsx
|
|
158
|
-
* import {
|
|
155
|
+
* import { ProductList } from '@wix/stores/components';
|
|
159
156
|
*
|
|
160
157
|
* function ProductsGrid() {
|
|
161
158
|
* return (
|
|
162
|
-
* <
|
|
159
|
+
* <ProductList.ItemContent>
|
|
163
160
|
* {({ product }) => (
|
|
164
161
|
* <div className="product-card">
|
|
165
162
|
* <img src={product.media?.main?.image} alt={product.name} />
|
|
@@ -168,7 +165,7 @@ export function Error(props) {
|
|
|
168
165
|
* <button>View Details</button>
|
|
169
166
|
* </div>
|
|
170
167
|
* )}
|
|
171
|
-
* </
|
|
168
|
+
* </ProductList.ItemContent>
|
|
172
169
|
* );
|
|
173
170
|
* }
|
|
174
171
|
* ```
|
|
@@ -183,3 +180,10 @@ export function ItemContent(props) {
|
|
|
183
180
|
? props.children({ product })
|
|
184
181
|
: props.children }, product._id)));
|
|
185
182
|
}
|
|
183
|
+
export function Items(props) {
|
|
184
|
+
const { products } = useService(ProductsListServiceDefinition);
|
|
185
|
+
const productsValue = products.get();
|
|
186
|
+
return typeof props.children === "function"
|
|
187
|
+
? props.children({ products: productsValue })
|
|
188
|
+
: props.children;
|
|
189
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { InventoryStatusType, type ProductOption, ProductsListFiltersServiceConfig } from "../services/products-list-filters-service.js";
|
|
3
|
+
export interface RootProps {
|
|
4
|
+
/** Child components that will have access to the ProductListFilters service */
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/** Configuration for the ProductListFilters service */
|
|
7
|
+
productsListFiltersConfig: ProductsListFiltersServiceConfig;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Root component that provides the ProductListFilters service context to its children.
|
|
11
|
+
* This component sets up the necessary services for managing products list filters.
|
|
12
|
+
*
|
|
13
|
+
* @order 1
|
|
14
|
+
* @component
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* import { ProductListFilters } from '@wix/stores/components';
|
|
18
|
+
*
|
|
19
|
+
* function FiltersSection() {
|
|
20
|
+
* return (
|
|
21
|
+
* <ProductListFilters.Root
|
|
22
|
+
* productsListFiltersConfig={{
|
|
23
|
+
* minPrice: 0,
|
|
24
|
+
* maxPrice: 1000
|
|
25
|
+
* }}
|
|
26
|
+
* >
|
|
27
|
+
* <ProductListFilters.MinPrice>
|
|
28
|
+
* {({ minPrice, setMinPrice }) => (
|
|
29
|
+
* <input
|
|
30
|
+
* type="number"
|
|
31
|
+
* value={minPrice}
|
|
32
|
+
* onChange={(e) => setMinPrice(Number(e.target.value))}
|
|
33
|
+
* placeholder="Min price"
|
|
34
|
+
* />
|
|
35
|
+
* )}
|
|
36
|
+
* </ProductListFilters.MinPrice>
|
|
37
|
+
* </ProductListFilters.Root>
|
|
38
|
+
* );
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function Root(props: RootProps): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
/**
|
|
44
|
+
* Props for InventoryStatus headless component
|
|
45
|
+
*/
|
|
46
|
+
export interface InventoryStatusProps {
|
|
47
|
+
/** Content to display (can be a render function receiving inventory status controls or ReactNode) */
|
|
48
|
+
children: ((props: InventoryStatusRenderProps) => ReactNode) | ReactNode;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Render props for InventoryStatus component
|
|
52
|
+
*/
|
|
53
|
+
export interface InventoryStatusRenderProps {
|
|
54
|
+
/** Available inventory status options */
|
|
55
|
+
availableInventoryStatuses: InventoryStatusType[];
|
|
56
|
+
/** Currently selected inventory statuses */
|
|
57
|
+
selectedInventoryStatuses: InventoryStatusType[];
|
|
58
|
+
/** Function to toggle an inventory status filter */
|
|
59
|
+
toggleInventoryStatus: (status: InventoryStatusType) => void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Headless component for managing inventory status filters
|
|
63
|
+
*
|
|
64
|
+
* @component
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* import { ProductListFilters } from '@wix/stores/components';
|
|
68
|
+
*
|
|
69
|
+
* function InventoryStatusFilter() {
|
|
70
|
+
* return (
|
|
71
|
+
* <ProductListFilters.InventoryStatus>
|
|
72
|
+
* {({ availableInventoryStatuses, selectedInventoryStatuses, toggleInventoryStatus }) => (
|
|
73
|
+
* <div>
|
|
74
|
+
* <h4>Inventory Status:</h4>
|
|
75
|
+
* {availableInventoryStatuses.map(status => (
|
|
76
|
+
* <label key={status}>
|
|
77
|
+
* <input
|
|
78
|
+
* type="checkbox"
|
|
79
|
+
* checked={selectedInventoryStatuses.includes(status)}
|
|
80
|
+
* onChange={() => toggleInventoryStatus(status)}
|
|
81
|
+
* />
|
|
82
|
+
* {status}
|
|
83
|
+
* </label>
|
|
84
|
+
* ))}
|
|
85
|
+
* </div>
|
|
86
|
+
* )}
|
|
87
|
+
* </ProductListFilters.InventoryStatus>
|
|
88
|
+
* );
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function InventoryStatus(props: InventoryStatusProps): ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* Props for ResetTrigger headless component
|
|
95
|
+
*/
|
|
96
|
+
export interface ResetTriggerProps {
|
|
97
|
+
/** Content to display (can be a render function receiving reset controls or ReactNode) */
|
|
98
|
+
children: ((props: ResetTriggerRenderProps) => ReactNode) | ReactNode;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Render props for ResetTrigger component
|
|
102
|
+
*/
|
|
103
|
+
export interface ResetTriggerRenderProps {
|
|
104
|
+
/** Function to reset all filters */
|
|
105
|
+
resetFilters: () => void;
|
|
106
|
+
/** Whether any filters are currently applied */
|
|
107
|
+
isFiltered: boolean;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Headless component for resetting all filters
|
|
111
|
+
*
|
|
112
|
+
* @component
|
|
113
|
+
* @example
|
|
114
|
+
* ```tsx
|
|
115
|
+
* import { ProductListFilters } from '@wix/stores/components';
|
|
116
|
+
*
|
|
117
|
+
* function ResetFiltersButton() {
|
|
118
|
+
* return (
|
|
119
|
+
* <ProductListFilters.ResetTrigger>
|
|
120
|
+
* {({ resetFilters, isFiltered }) => (
|
|
121
|
+
* <button
|
|
122
|
+
* onClick={resetFilters}
|
|
123
|
+
* disabled={!isFiltered}
|
|
124
|
+
* className={isFiltered ? 'active' : 'disabled'}
|
|
125
|
+
* >
|
|
126
|
+
* {isFiltered ? 'Clear Filters' : 'No Filters Applied'}
|
|
127
|
+
* </button>
|
|
128
|
+
* )}
|
|
129
|
+
* </ProductListFilters.ResetTrigger>
|
|
130
|
+
* );
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function ResetTrigger(props: ResetTriggerProps): ReactNode;
|
|
135
|
+
/**
|
|
136
|
+
* Props for PriceRange headless component
|
|
137
|
+
*/
|
|
138
|
+
export interface PriceRangeProps {
|
|
139
|
+
/** Content to display (can be a render function receiving price range controls or ReactNode) */
|
|
140
|
+
children: ((props: PriceRangeRenderProps) => ReactNode) | ReactNode;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Render props for PriceRange component
|
|
144
|
+
*/
|
|
145
|
+
export interface PriceRangeRenderProps {
|
|
146
|
+
/** Current minimum price filter value */
|
|
147
|
+
minPrice: number;
|
|
148
|
+
/** Current maximum price filter value */
|
|
149
|
+
maxPrice: number;
|
|
150
|
+
/** Function to update the minimum price filter */
|
|
151
|
+
setMinPrice: (minPrice: number) => void;
|
|
152
|
+
/** Function to update the maximum price filter */
|
|
153
|
+
setMaxPrice: (maxPrice: number) => void;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Headless component for managing price range filters (combined min/max)
|
|
157
|
+
*
|
|
158
|
+
* @component
|
|
159
|
+
* @example
|
|
160
|
+
* ```tsx
|
|
161
|
+
* import { ProductListFilters } from '@wix/stores/components';
|
|
162
|
+
*
|
|
163
|
+
* function PriceRangeFilter() {
|
|
164
|
+
* return (
|
|
165
|
+
* <ProductListFilters.PriceRange>
|
|
166
|
+
* {({ minPrice, maxPrice, setMinPrice, setMaxPrice }) => (
|
|
167
|
+
* <div className="price-range">
|
|
168
|
+
* <h4>Price Range:</h4>
|
|
169
|
+
* <div className="price-inputs">
|
|
170
|
+
* <input
|
|
171
|
+
* type="number"
|
|
172
|
+
* value={minPrice}
|
|
173
|
+
* onChange={(e) => setMinPrice(Number(e.target.value))}
|
|
174
|
+
* placeholder="Min"
|
|
175
|
+
* />
|
|
176
|
+
* <span>to</span>
|
|
177
|
+
* <input
|
|
178
|
+
* type="number"
|
|
179
|
+
* value={maxPrice}
|
|
180
|
+
* onChange={(e) => setMaxPrice(Number(e.target.value))}
|
|
181
|
+
* placeholder="Max"
|
|
182
|
+
* />
|
|
183
|
+
* </div>
|
|
184
|
+
* </div>
|
|
185
|
+
* )}
|
|
186
|
+
* </ProductListFilters.PriceRange>
|
|
187
|
+
* );
|
|
188
|
+
* }
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export declare function PriceRange(props: PriceRangeProps): ReactNode;
|
|
192
|
+
/**
|
|
193
|
+
* Props for ProductOptions headless component
|
|
194
|
+
*/
|
|
195
|
+
export interface ProductOptionsProps {
|
|
196
|
+
/** Content to display (can be a render function receiving product option data or ReactNode) */
|
|
197
|
+
children: ((props: ProductOptionRenderProps) => ReactNode) | ReactNode;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Render props for ProductOption component
|
|
201
|
+
*/
|
|
202
|
+
export interface ProductOptionRenderProps {
|
|
203
|
+
/** Product option data */
|
|
204
|
+
option: ProductOption;
|
|
205
|
+
/** Currently selected choice IDs for this option */
|
|
206
|
+
selectedChoices: string[];
|
|
207
|
+
/** Function to toggle a choice selection */
|
|
208
|
+
toggleChoice: (choiceId: string) => void;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Headless component that renders content for each product option in the list.
|
|
212
|
+
* Maps over all available product options and provides each option through a render prop.
|
|
213
|
+
* Only renders when options are available (not loading, no error, and has options).
|
|
214
|
+
* This follows the same collection pattern as ProductList.ItemContent and CategoryList.ItemContent.
|
|
215
|
+
*
|
|
216
|
+
* @component
|
|
217
|
+
* @example
|
|
218
|
+
* ```tsx
|
|
219
|
+
* import { ProductListFilters } from '@wix/stores/components';
|
|
220
|
+
*
|
|
221
|
+
* function ProductOptionsFilter() {
|
|
222
|
+
* return (
|
|
223
|
+
* <ProductListFilters.ProductOptions>
|
|
224
|
+
* {({ option, selectedChoices, toggleChoice }) => (
|
|
225
|
+
* <div key={option.id}>
|
|
226
|
+
* <h4>{option.name}</h4>
|
|
227
|
+
* {option.choices.map(choice => (
|
|
228
|
+
* <label key={choice.id}>
|
|
229
|
+
* <input
|
|
230
|
+
* type="checkbox"
|
|
231
|
+
* checked={selectedChoices.includes(choice.id)}
|
|
232
|
+
* onChange={() => toggleChoice(choice.id)}
|
|
233
|
+
* />
|
|
234
|
+
* {choice.name}
|
|
235
|
+
* </label>
|
|
236
|
+
* ))}
|
|
237
|
+
* </div>
|
|
238
|
+
* )}
|
|
239
|
+
* </ProductListFilters.ProductOptions>
|
|
240
|
+
* );
|
|
241
|
+
* }
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
export declare function ProductOptions(props: ProductOptionsProps): import("react/jsx-runtime").JSX.Element | null;
|