@wix/headless-stores 0.0.56 → 0.0.58
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 +1 -0
- package/cjs/dist/react/Category.js +11 -22
- package/cjs/dist/react/CategoryList.js +2 -3
- package/cjs/dist/react/Product.d.ts +73 -30
- package/cjs/dist/react/Product.js +27 -145
- package/cjs/dist/react/ProductList.d.ts +9 -4
- package/cjs/dist/react/ProductList.js +4 -32
- package/cjs/dist/react/ProductListSort.d.ts +14 -0
- package/cjs/dist/react/ProductListSort.js +14 -0
- package/cjs/dist/react/core/ProductList.d.ts +3 -0
- package/cjs/dist/react/core/ProductList.js +2 -0
- package/cjs/dist/react/core/ProductListFilters.d.ts +8 -180
- package/cjs/dist/react/core/ProductListFilters.js +137 -171
- package/cjs/dist/react/core/ProductListPagination.d.ts +0 -192
- package/cjs/dist/react/core/ProductListPagination.js +2 -160
- package/cjs/dist/react/core/ProductListSort.d.ts +9 -57
- package/cjs/dist/react/core/ProductListSort.js +32 -52
- package/cjs/dist/react/core/SelectedVariant.js +2 -2
- package/cjs/dist/services/index.d.ts +2 -2
- package/cjs/dist/services/products-list-search-service.d.ts +3 -162
- package/cjs/dist/services/products-list-search-service.js +31 -424
- package/cjs/dist/services/products-list-service.d.ts +86 -4
- package/cjs/dist/services/products-list-service.js +125 -4
- package/cjs/dist/utils/renderChildren.d.ts +2 -1
- package/cjs/dist/utils/renderChildren.js +5 -2
- package/dist/react/Category.d.ts +1 -0
- package/dist/react/Category.js +11 -22
- package/dist/react/CategoryList.js +2 -3
- package/dist/react/Product.d.ts +73 -30
- package/dist/react/Product.js +27 -145
- package/dist/react/ProductList.d.ts +9 -4
- package/dist/react/ProductList.js +4 -32
- package/dist/react/ProductListSort.d.ts +14 -0
- package/dist/react/ProductListSort.js +14 -0
- package/dist/react/core/ProductList.d.ts +3 -0
- package/dist/react/core/ProductList.js +2 -0
- package/dist/react/core/ProductListFilters.d.ts +8 -180
- package/dist/react/core/ProductListFilters.js +137 -171
- package/dist/react/core/ProductListPagination.d.ts +0 -192
- package/dist/react/core/ProductListPagination.js +2 -160
- package/dist/react/core/ProductListSort.d.ts +9 -57
- package/dist/react/core/ProductListSort.js +32 -52
- package/dist/react/core/SelectedVariant.js +2 -2
- package/dist/services/index.d.ts +2 -2
- package/dist/services/products-list-search-service.d.ts +3 -162
- package/dist/services/products-list-search-service.js +31 -424
- package/dist/services/products-list-service.d.ts +86 -4
- package/dist/services/products-list-service.js +125 -4
- package/dist/utils/renderChildren.d.ts +2 -1
- package/dist/utils/renderChildren.js +5 -2
- package/package.json +4 -3
|
@@ -1,195 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Props for PageSize headless component
|
|
3
|
-
*/
|
|
4
|
-
export interface PageSizeProps {
|
|
5
|
-
/** Content to display (can be a render function receiving page size controls or ReactNode) */
|
|
6
|
-
children: ((props: PageSizeRenderProps) => React.ReactNode) | React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Render props for PageSize component
|
|
10
|
-
*/
|
|
11
|
-
export interface PageSizeRenderProps {
|
|
12
|
-
/** Current page size (items per page) */
|
|
13
|
-
currentLimit: number;
|
|
14
|
-
/** Function to update the page size */
|
|
15
|
-
setLimit: (limit: number) => void;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Headless component for managing page size (items per page)
|
|
19
|
-
*
|
|
20
|
-
* @component
|
|
21
|
-
* @example
|
|
22
|
-
* ```tsx
|
|
23
|
-
* import { ProductList, ProductListPagination } from '@wix/stores/components';
|
|
24
|
-
*
|
|
25
|
-
* function PageSizeSelector() {
|
|
26
|
-
* return (
|
|
27
|
-
* <ProductList.Root
|
|
28
|
-
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
29
|
-
* productsListSearchConfig={{ customizations: [] }}
|
|
30
|
-
* >
|
|
31
|
-
* <ProductListPagination.PageSize>
|
|
32
|
-
* {({ currentLimit, setLimit }) => (
|
|
33
|
-
* <div>
|
|
34
|
-
* <label>Items per page:</label>
|
|
35
|
-
* <select
|
|
36
|
-
* value={currentLimit}
|
|
37
|
-
* onChange={(e) => setLimit(Number(e.target.value))}
|
|
38
|
-
* >
|
|
39
|
-
* <option value={10}>10</option>
|
|
40
|
-
* <option value={20}>20</option>
|
|
41
|
-
* <option value={50}>50</option>
|
|
42
|
-
* </select>
|
|
43
|
-
* </div>
|
|
44
|
-
* )}
|
|
45
|
-
* </ProductListPagination.PageSize>
|
|
46
|
-
* </ProductList.Root>
|
|
47
|
-
* );
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export declare function PageSize(props: PageSizeProps): import("react").ReactNode;
|
|
52
|
-
/**
|
|
53
|
-
* Props for NextPageTrigger headless component
|
|
54
|
-
*/
|
|
55
|
-
export interface NextPageTriggerProps {
|
|
56
|
-
/** Content to display (can be a render function receiving next page controls or ReactNode) */
|
|
57
|
-
children: ((props: NextPageTriggerRenderProps) => React.ReactNode) | React.ReactNode;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Render props for NextPageTrigger component
|
|
61
|
-
*/
|
|
62
|
-
export interface NextPageTriggerRenderProps {
|
|
63
|
-
/** Function to navigate to the next page */
|
|
64
|
-
nextPage: () => void;
|
|
65
|
-
/** Whether there is a next page available */
|
|
66
|
-
hasNextPage: boolean;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Headless component for navigating to the next page
|
|
70
|
-
*
|
|
71
|
-
* @component
|
|
72
|
-
* @example
|
|
73
|
-
* ```tsx
|
|
74
|
-
* import { ProductList, ProductListPagination } from '@wix/stores/components';
|
|
75
|
-
*
|
|
76
|
-
* function NextPageButton() {
|
|
77
|
-
* return (
|
|
78
|
-
* <ProductList.Root
|
|
79
|
-
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
80
|
-
* productsListSearchConfig={{ customizations: [] }}
|
|
81
|
-
* >
|
|
82
|
-
* <ProductListPagination.NextPageTrigger>
|
|
83
|
-
* {({ nextPage, hasNextPage }) => (
|
|
84
|
-
* <button
|
|
85
|
-
* onClick={nextPage}
|
|
86
|
-
* disabled={!hasNextPage}
|
|
87
|
-
* className={hasNextPage ? 'enabled' : 'disabled'}
|
|
88
|
-
* >
|
|
89
|
-
* Next →
|
|
90
|
-
* </button>
|
|
91
|
-
* )}
|
|
92
|
-
* </ProductListPagination.NextPageTrigger>
|
|
93
|
-
* </ProductList.Root>
|
|
94
|
-
* );
|
|
95
|
-
* }
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
export declare function NextPageTrigger(props: NextPageTriggerProps): import("react").ReactNode;
|
|
99
|
-
/**
|
|
100
|
-
* Props for PreviousPageTrigger headless component
|
|
101
|
-
*/
|
|
102
|
-
export interface PreviousPageTriggerProps {
|
|
103
|
-
/** Content to display (can be a render function receiving previous page controls or ReactNode) */
|
|
104
|
-
children: ((props: PreviousPageTriggerRenderProps) => React.ReactNode) | React.ReactNode;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Render props for PreviousPageTrigger component
|
|
108
|
-
*/
|
|
109
|
-
export interface PreviousPageTriggerRenderProps {
|
|
110
|
-
/** Function to navigate to the previous page */
|
|
111
|
-
prevPage: () => void;
|
|
112
|
-
/** Whether there is a previous page available */
|
|
113
|
-
hasPrevPage: boolean;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Headless component for navigating to the previous page
|
|
117
|
-
*
|
|
118
|
-
* @component
|
|
119
|
-
* @example
|
|
120
|
-
* ```tsx
|
|
121
|
-
* import { ProductList, ProductListPagination } from '@wix/stores/components';
|
|
122
|
-
*
|
|
123
|
-
* function PrevPageButton() {
|
|
124
|
-
* return (
|
|
125
|
-
* <ProductList.Root
|
|
126
|
-
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
127
|
-
* productsListSearchConfig={{ customizations: [] }}
|
|
128
|
-
* >
|
|
129
|
-
* <ProductListPagination.PreviousPageTrigger>
|
|
130
|
-
* {({ prevPage, hasPrevPage }) => (
|
|
131
|
-
* <button
|
|
132
|
-
* onClick={prevPage}
|
|
133
|
-
* disabled={!hasPrevPage}
|
|
134
|
-
* className={hasPrevPage ? 'enabled' : 'disabled'}
|
|
135
|
-
* >
|
|
136
|
-
* ← Previous
|
|
137
|
-
* </button>
|
|
138
|
-
* )}
|
|
139
|
-
* </ProductListPagination.PreviousPageTrigger>
|
|
140
|
-
* </ProductList.Root>
|
|
141
|
-
* );
|
|
142
|
-
* }
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
|
-
export declare function PreviousPageTrigger(props: PreviousPageTriggerProps): import("react").ReactNode;
|
|
146
|
-
/**
|
|
147
|
-
* Props for FirstPageTrigger headless component
|
|
148
|
-
*/
|
|
149
|
-
export interface FirstPageTriggerProps {
|
|
150
|
-
/** Content to display (can be a render function receiving first page controls or ReactNode) */
|
|
151
|
-
children: ((props: FirstPageTriggerRenderProps) => React.ReactNode) | React.ReactNode;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Render props for FirstPageTrigger component
|
|
155
|
-
*/
|
|
156
|
-
export interface FirstPageTriggerRenderProps {
|
|
157
|
-
/** Function to navigate to the first page */
|
|
158
|
-
navigateToFirstPage: () => void;
|
|
159
|
-
/** Whether there is a previous page (indicating not on first page) */
|
|
160
|
-
hasPrevPage: boolean;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Headless component for navigating to the first page
|
|
164
|
-
*
|
|
165
|
-
* @component
|
|
166
|
-
* @example
|
|
167
|
-
* ```tsx
|
|
168
|
-
* import { ProductList, ProductListPagination } from '@wix/stores/components';
|
|
169
|
-
*
|
|
170
|
-
* function FirstPageButton() {
|
|
171
|
-
* return (
|
|
172
|
-
* <ProductList.Root
|
|
173
|
-
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
174
|
-
* productsListSearchConfig={{ customizations: [] }}
|
|
175
|
-
* >
|
|
176
|
-
* <ProductListPagination.FirstPageTrigger>
|
|
177
|
-
* {({ navigateToFirstPage, hasPrevPage }) => (
|
|
178
|
-
* <button
|
|
179
|
-
* onClick={navigateToFirstPage}
|
|
180
|
-
* disabled={!hasPrevPage}
|
|
181
|
-
* title="Go to first page"
|
|
182
|
-
* >
|
|
183
|
-
* ⏮ First
|
|
184
|
-
* </button>
|
|
185
|
-
* )}
|
|
186
|
-
* </ProductListPagination.FirstPageTrigger>
|
|
187
|
-
* </ProductList.Root>
|
|
188
|
-
* );
|
|
189
|
-
* }
|
|
190
|
-
* ```
|
|
191
|
-
*/
|
|
192
|
-
export declare function FirstPageTrigger(props: FirstPageTriggerProps): import("react").ReactNode;
|
|
193
1
|
/**
|
|
194
2
|
* Props for LoadMoreTrigger headless component
|
|
195
3
|
*/
|
|
@@ -1,162 +1,5 @@
|
|
|
1
1
|
import { useService } from '@wix/services-manager-react';
|
|
2
|
-
import { ProductsListSearchServiceDefinition } from '../../services/products-list-search-service.js';
|
|
3
2
|
import { ProductsListServiceDefinition } from '../../services/products-list-service.js';
|
|
4
|
-
/**
|
|
5
|
-
* Headless component for managing page size (items per page)
|
|
6
|
-
*
|
|
7
|
-
* @component
|
|
8
|
-
* @example
|
|
9
|
-
* ```tsx
|
|
10
|
-
* import { ProductList, ProductListPagination } from '@wix/stores/components';
|
|
11
|
-
*
|
|
12
|
-
* function PageSizeSelector() {
|
|
13
|
-
* return (
|
|
14
|
-
* <ProductList.Root
|
|
15
|
-
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
16
|
-
* productsListSearchConfig={{ customizations: [] }}
|
|
17
|
-
* >
|
|
18
|
-
* <ProductListPagination.PageSize>
|
|
19
|
-
* {({ currentLimit, setLimit }) => (
|
|
20
|
-
* <div>
|
|
21
|
-
* <label>Items per page:</label>
|
|
22
|
-
* <select
|
|
23
|
-
* value={currentLimit}
|
|
24
|
-
* onChange={(e) => setLimit(Number(e.target.value))}
|
|
25
|
-
* >
|
|
26
|
-
* <option value={10}>10</option>
|
|
27
|
-
* <option value={20}>20</option>
|
|
28
|
-
* <option value={50}>50</option>
|
|
29
|
-
* </select>
|
|
30
|
-
* </div>
|
|
31
|
-
* )}
|
|
32
|
-
* </ProductListPagination.PageSize>
|
|
33
|
-
* </ProductList.Root>
|
|
34
|
-
* );
|
|
35
|
-
* }
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export function PageSize(props) {
|
|
39
|
-
const service = useService(ProductsListSearchServiceDefinition);
|
|
40
|
-
const currentLimit = service.currentLimit.get();
|
|
41
|
-
const setLimit = service.setLimit;
|
|
42
|
-
return typeof props.children === 'function'
|
|
43
|
-
? props.children({ currentLimit, setLimit })
|
|
44
|
-
: props.children;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Headless component for navigating to the next page
|
|
48
|
-
*
|
|
49
|
-
* @component
|
|
50
|
-
* @example
|
|
51
|
-
* ```tsx
|
|
52
|
-
* import { ProductList, ProductListPagination } from '@wix/stores/components';
|
|
53
|
-
*
|
|
54
|
-
* function NextPageButton() {
|
|
55
|
-
* return (
|
|
56
|
-
* <ProductList.Root
|
|
57
|
-
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
58
|
-
* productsListSearchConfig={{ customizations: [] }}
|
|
59
|
-
* >
|
|
60
|
-
* <ProductListPagination.NextPageTrigger>
|
|
61
|
-
* {({ nextPage, hasNextPage }) => (
|
|
62
|
-
* <button
|
|
63
|
-
* onClick={nextPage}
|
|
64
|
-
* disabled={!hasNextPage}
|
|
65
|
-
* className={hasNextPage ? 'enabled' : 'disabled'}
|
|
66
|
-
* >
|
|
67
|
-
* Next →
|
|
68
|
-
* </button>
|
|
69
|
-
* )}
|
|
70
|
-
* </ProductListPagination.NextPageTrigger>
|
|
71
|
-
* </ProductList.Root>
|
|
72
|
-
* );
|
|
73
|
-
* }
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
export function NextPageTrigger(props) {
|
|
77
|
-
const service = useService(ProductsListSearchServiceDefinition);
|
|
78
|
-
const nextPage = service.nextPage;
|
|
79
|
-
const hasNextPage = service.hasNextPage.get();
|
|
80
|
-
return typeof props.children === 'function'
|
|
81
|
-
? props.children({ nextPage, hasNextPage })
|
|
82
|
-
: props.children;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Headless component for navigating to the previous page
|
|
86
|
-
*
|
|
87
|
-
* @component
|
|
88
|
-
* @example
|
|
89
|
-
* ```tsx
|
|
90
|
-
* import { ProductList, ProductListPagination } from '@wix/stores/components';
|
|
91
|
-
*
|
|
92
|
-
* function PrevPageButton() {
|
|
93
|
-
* return (
|
|
94
|
-
* <ProductList.Root
|
|
95
|
-
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
96
|
-
* productsListSearchConfig={{ customizations: [] }}
|
|
97
|
-
* >
|
|
98
|
-
* <ProductListPagination.PreviousPageTrigger>
|
|
99
|
-
* {({ prevPage, hasPrevPage }) => (
|
|
100
|
-
* <button
|
|
101
|
-
* onClick={prevPage}
|
|
102
|
-
* disabled={!hasPrevPage}
|
|
103
|
-
* className={hasPrevPage ? 'enabled' : 'disabled'}
|
|
104
|
-
* >
|
|
105
|
-
* ← Previous
|
|
106
|
-
* </button>
|
|
107
|
-
* )}
|
|
108
|
-
* </ProductListPagination.PreviousPageTrigger>
|
|
109
|
-
* </ProductList.Root>
|
|
110
|
-
* );
|
|
111
|
-
* }
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
|
-
export function PreviousPageTrigger(props) {
|
|
115
|
-
const service = useService(ProductsListSearchServiceDefinition);
|
|
116
|
-
const prevPage = service.prevPage;
|
|
117
|
-
const hasPrevPage = service.hasPrevPage.get();
|
|
118
|
-
return typeof props.children === 'function'
|
|
119
|
-
? props.children({ prevPage, hasPrevPage })
|
|
120
|
-
: props.children;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Headless component for navigating to the first page
|
|
124
|
-
*
|
|
125
|
-
* @component
|
|
126
|
-
* @example
|
|
127
|
-
* ```tsx
|
|
128
|
-
* import { ProductList, ProductListPagination } from '@wix/stores/components';
|
|
129
|
-
*
|
|
130
|
-
* function FirstPageButton() {
|
|
131
|
-
* return (
|
|
132
|
-
* <ProductList.Root
|
|
133
|
-
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
134
|
-
* productsListSearchConfig={{ customizations: [] }}
|
|
135
|
-
* >
|
|
136
|
-
* <ProductListPagination.FirstPageTrigger>
|
|
137
|
-
* {({ navigateToFirstPage, hasPrevPage }) => (
|
|
138
|
-
* <button
|
|
139
|
-
* onClick={navigateToFirstPage}
|
|
140
|
-
* disabled={!hasPrevPage}
|
|
141
|
-
* title="Go to first page"
|
|
142
|
-
* >
|
|
143
|
-
* ⏮ First
|
|
144
|
-
* </button>
|
|
145
|
-
* )}
|
|
146
|
-
* </ProductListPagination.FirstPageTrigger>
|
|
147
|
-
* </ProductList.Root>
|
|
148
|
-
* );
|
|
149
|
-
* }
|
|
150
|
-
* ```
|
|
151
|
-
*/
|
|
152
|
-
export function FirstPageTrigger(props) {
|
|
153
|
-
const service = useService(ProductsListSearchServiceDefinition);
|
|
154
|
-
const navigateToFirstPage = service.navigateToFirstPage;
|
|
155
|
-
const hasPrevPage = service.hasPrevPage.get();
|
|
156
|
-
return typeof props.children === 'function'
|
|
157
|
-
? props.children({ navigateToFirstPage, hasPrevPage })
|
|
158
|
-
: props.children;
|
|
159
|
-
}
|
|
160
3
|
/**
|
|
161
4
|
* Headless component for loading more products (infinite scroll pattern)
|
|
162
5
|
*
|
|
@@ -188,10 +31,9 @@ export function FirstPageTrigger(props) {
|
|
|
188
31
|
* ```
|
|
189
32
|
*/
|
|
190
33
|
export function LoadMoreTrigger(props) {
|
|
191
|
-
const service = useService(ProductsListSearchServiceDefinition);
|
|
192
34
|
const productsListService = useService(ProductsListServiceDefinition);
|
|
193
|
-
const loadMore =
|
|
194
|
-
const hasMoreProducts =
|
|
35
|
+
const loadMore = productsListService.loadMore;
|
|
36
|
+
const hasMoreProducts = productsListService.hasMoreProducts.get();
|
|
195
37
|
const isLoading = productsListService.isLoading.get();
|
|
196
38
|
return typeof props.children === 'function'
|
|
197
39
|
? props.children({ loadMore, hasMoreProducts, isLoading })
|
|
@@ -1,58 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Sort as SortPrimitive } from '@wix/headless-components/react';
|
|
2
|
+
import { productsV3 } from '@wix/stores';
|
|
3
|
+
export interface ProductListSortProps {
|
|
4
|
+
children: (props: {
|
|
5
|
+
currentSort: productsV3.V3ProductSearch['sort'];
|
|
6
|
+
sortOptions: SortPrimitive.SortOption[];
|
|
7
|
+
setSort: (sort: productsV3.V3ProductSearch['sort']) => void;
|
|
8
|
+
}) => React.ReactNode;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
* Render props for Options component
|
|
11
|
-
*/
|
|
12
|
-
export interface OptionsRenderProps {
|
|
13
|
-
/** Currently selected sort option value */
|
|
14
|
-
selectedSortOption: string;
|
|
15
|
-
/** Function to update the selected sort option */
|
|
16
|
-
updateSortOption: (sort: string) => void;
|
|
17
|
-
/** Available sort options */
|
|
18
|
-
sortOptions: SortType[];
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Headless component for managing product list sorting options
|
|
22
|
-
*
|
|
23
|
-
* @component
|
|
24
|
-
* @example
|
|
25
|
-
* ```tsx
|
|
26
|
-
* import { ProductList, ProductListSort } from '@wix/stores/components';
|
|
27
|
-
*
|
|
28
|
-
* function ProductSortDropdown() {
|
|
29
|
-
* return (
|
|
30
|
-
* <ProductList.Root
|
|
31
|
-
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
32
|
-
* productsListSearchConfig={{ customizations: [] }}
|
|
33
|
-
* >
|
|
34
|
-
* <ProductListSort.Options>
|
|
35
|
-
* {({ selectedSortOption, updateSortOption, sortOptions }) => (
|
|
36
|
-
* <div className="sort-container">
|
|
37
|
-
* <label htmlFor="sort-select">Sort by:</label>
|
|
38
|
-
* <select
|
|
39
|
-
* id="sort-select"
|
|
40
|
-
* value={selectedSortOption}
|
|
41
|
-
* onChange={(e) => updateSortOption(e.target.value)}
|
|
42
|
-
* className="sort-dropdown"
|
|
43
|
-
* >
|
|
44
|
-
* {sortOptions.map(option => (
|
|
45
|
-
* <option key={option} value={option}>
|
|
46
|
-
* {option}
|
|
47
|
-
* </option>
|
|
48
|
-
* ))}
|
|
49
|
-
* </select>
|
|
50
|
-
* </div>
|
|
51
|
-
* )}
|
|
52
|
-
* </ProductListSort.Options>
|
|
53
|
-
* </ProductList.Root>
|
|
54
|
-
* );
|
|
55
|
-
* }
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare function Options(props: OptionsProps): import("react").ReactNode;
|
|
10
|
+
export declare const ProductListSort: (props: ProductListSortProps) => import("react").ReactNode;
|
|
@@ -1,53 +1,33 @@
|
|
|
1
1
|
import { useService } from '@wix/services-manager-react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* )}
|
|
35
|
-
* </ProductListSort.Options>
|
|
36
|
-
* </ProductList.Root>
|
|
37
|
-
* );
|
|
38
|
-
* }
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export function Options(props) {
|
|
42
|
-
const service = useService(ProductsListSearchServiceDefinition);
|
|
43
|
-
const selectedSortOption = service.selectedSortOption.get();
|
|
44
|
-
const sortOptions = service.sortOptions;
|
|
45
|
-
const updateSortOption = service.setSelectedSortOption;
|
|
46
|
-
return typeof props.children === 'function'
|
|
47
|
-
? props.children({
|
|
48
|
-
selectedSortOption,
|
|
49
|
-
updateSortOption,
|
|
50
|
-
sortOptions,
|
|
51
|
-
})
|
|
52
|
-
: props.children;
|
|
53
|
-
}
|
|
2
|
+
import { ProductsListServiceDefinition } from '../../services/products-list-service.js';
|
|
3
|
+
export const ProductListSort = (props) => {
|
|
4
|
+
const productListService = useService(ProductsListServiceDefinition);
|
|
5
|
+
const currentSort = productListService.searchOptions.get().sort;
|
|
6
|
+
// Define sort options - primitive handles all conversion logic
|
|
7
|
+
const sortOptions = [
|
|
8
|
+
{ fieldName: 'name', order: 'ASC', label: 'Name (A-Z)' },
|
|
9
|
+
{ fieldName: 'name', order: 'DESC', label: 'Name (Z-A)' },
|
|
10
|
+
{
|
|
11
|
+
fieldName: 'actualPriceRange.minValue.amount',
|
|
12
|
+
order: 'ASC',
|
|
13
|
+
label: 'Price: Low to High',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
fieldName: 'actualPriceRange.minValue.amount',
|
|
17
|
+
order: 'DESC',
|
|
18
|
+
label: 'Price: High to Low',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
fieldName: 'name',
|
|
22
|
+
order: 'DESC',
|
|
23
|
+
label: 'Latest Arrivals',
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
return props.children({
|
|
27
|
+
currentSort,
|
|
28
|
+
sortOptions,
|
|
29
|
+
setSort: (sort) => {
|
|
30
|
+
productListService.setSort(sort);
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
};
|
|
@@ -3,7 +3,7 @@ import { useService, WixServices } from '@wix/services-manager-react';
|
|
|
3
3
|
import { SelectedVariantServiceDefinition, SelectedVariantService, } from '../../services/selected-variant-service.js';
|
|
4
4
|
import { ProductModifiersServiceDefinition } from '../../services/product-modifiers-service.js';
|
|
5
5
|
import { createServicesMap } from '@wix/services-manager';
|
|
6
|
-
import {
|
|
6
|
+
import { CheckoutCore } from '@wix/headless-ecom/react';
|
|
7
7
|
import { CheckoutServiceDefinition, CurrentCartServiceDefinition, } from '@wix/headless-ecom/services';
|
|
8
8
|
/**
|
|
9
9
|
* Root component that provides the SelectedVariant service context to its children.
|
|
@@ -254,7 +254,7 @@ export function Actions(props) {
|
|
|
254
254
|
error,
|
|
255
255
|
};
|
|
256
256
|
if (checkoutService) {
|
|
257
|
-
return (_jsx(
|
|
257
|
+
return (_jsx(CheckoutCore.Trigger, { children: ({ createCheckout, isLoading: checkoutLoading, error: checkoutError, }) => props.children({
|
|
258
258
|
...commonProps,
|
|
259
259
|
isLoading: isLoading || checkoutLoading,
|
|
260
260
|
error: error || checkoutError,
|
|
@@ -3,5 +3,5 @@ export { CategoriesListService, CategoriesListServiceDefinition, loadCategoriesL
|
|
|
3
3
|
export { ProductModifiersService, ProductModifiersServiceDefinition, } from './product-modifiers-service.js';
|
|
4
4
|
export { ProductService, ProductServiceDefinition, loadProductServiceConfig, } from './product-service.js';
|
|
5
5
|
export { SelectedVariantService, SelectedVariantServiceDefinition, } from './selected-variant-service.js';
|
|
6
|
-
export { ProductListService, ProductsListServiceDefinition, loadProductsListServiceConfig, ProductsListServiceConfig, } from './products-list-service.js';
|
|
7
|
-
export {
|
|
6
|
+
export { ProductListService, ProductsListServiceDefinition, loadProductsListServiceConfig, ProductsListServiceConfig, ProductOption, ProductChoice, } from './products-list-service.js';
|
|
7
|
+
export { InventoryStatusType, SortType, ProductsListSearchService, ProductsListSearchServiceDefinition, ProductsListSearchServiceConfig, loadProductsListSearchServiceConfig, parseUrlToSearchOptions, convertUrlSortToSortType, } from './products-list-search-service.js';
|