@wix/headless-stores 0.0.36 → 0.0.38
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 +65 -59
- package/cjs/dist/react/Category.js +50 -83
- 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/{dist/react/ProductsList.d.ts → cjs/dist/react/ProductList.d.ts} +71 -38
- package/cjs/dist/react/{ProductsList.js → 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 +66 -3
- package/cjs/dist/react/SelectedVariant.js +106 -7
- package/cjs/dist/react/index.d.ts +6 -9
- package/cjs/dist/react/index.js +6 -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 +185 -54
- 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/utils/url-params.d.ts +68 -0
- package/cjs/dist/utils/url-params.js +72 -4
- package/dist/react/Category.d.ts +65 -59
- package/dist/react/Category.js +50 -83
- 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/{cjs/dist/react/ProductsList.d.ts → dist/react/ProductList.d.ts} +71 -38
- package/dist/react/{ProductsList.js → 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 +66 -3
- package/dist/react/SelectedVariant.js +106 -7
- package/dist/react/index.d.ts +6 -9
- package/dist/react/index.js +6 -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 +185 -54
- package/dist/services/products-list-sort-service.d.ts +117 -0
- package/dist/services/products-list-sort-service.js +144 -0
- 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 -299
- package/cjs/dist/react/FilteredCollection.js +0 -352
- package/cjs/dist/react/ProductActions.d.ts +0 -70
- package/cjs/dist/react/ProductActions.js +0 -104
- 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 -299
- package/dist/react/FilteredCollection.js +0 -352
- package/dist/react/ProductActions.d.ts +0 -70
- package/dist/react/ProductActions.js +0 -104
- 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
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createServicesMap } from "@wix/services-manager";
|
|
3
|
+
import { useService, WixServices } from "@wix/services-manager-react";
|
|
4
|
+
import { ProductsListPaginationService, ProductsListPaginationServiceDefinition, } from "../services/products-list-pagination-service.js";
|
|
5
|
+
import { ProductsListServiceDefinition } from "../services/products-list-service.js";
|
|
6
|
+
/**
|
|
7
|
+
* Root component that provides the ProductListPagination service context to its children.
|
|
8
|
+
* This component sets up the necessary services for managing products list pagination.
|
|
9
|
+
*
|
|
10
|
+
* @order 1
|
|
11
|
+
* @component
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { ProductListPagination } from '@wix/stores/components';
|
|
15
|
+
*
|
|
16
|
+
* function PaginationSection() {
|
|
17
|
+
* return (
|
|
18
|
+
* <ProductListPagination.Root>
|
|
19
|
+
* <ProductListPagination.NextPageTrigger>
|
|
20
|
+
* {({ nextPage, hasNextPage }) => (
|
|
21
|
+
* <button
|
|
22
|
+
* onClick={nextPage}
|
|
23
|
+
* disabled={!hasNextPage}
|
|
24
|
+
* >
|
|
25
|
+
* Next Page
|
|
26
|
+
* </button>
|
|
27
|
+
* )}
|
|
28
|
+
* </ProductListPagination.NextPageTrigger>
|
|
29
|
+
* </ProductListPagination.Root>
|
|
30
|
+
* );
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export function Root(props) {
|
|
35
|
+
return (_jsx(WixServices, { servicesMap: createServicesMap().addService(ProductsListPaginationServiceDefinition, ProductsListPaginationService), children: props.children }));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Headless component for managing page size (items per page)
|
|
39
|
+
*
|
|
40
|
+
* @component
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* import { ProductListPagination } from '@wix/stores/components';
|
|
44
|
+
*
|
|
45
|
+
* function PageSizeSelector() {
|
|
46
|
+
* return (
|
|
47
|
+
* <ProductListPagination.PageSize>
|
|
48
|
+
* {({ currentLimit, setLimit }) => (
|
|
49
|
+
* <div>
|
|
50
|
+
* <label>Items per page:</label>
|
|
51
|
+
* <select
|
|
52
|
+
* value={currentLimit}
|
|
53
|
+
* onChange={(e) => setLimit(Number(e.target.value))}
|
|
54
|
+
* >
|
|
55
|
+
* <option value={10}>10</option>
|
|
56
|
+
* <option value={20}>20</option>
|
|
57
|
+
* <option value={50}>50</option>
|
|
58
|
+
* </select>
|
|
59
|
+
* </div>
|
|
60
|
+
* )}
|
|
61
|
+
* </ProductListPagination.PageSize>
|
|
62
|
+
* );
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export function PageSize(props) {
|
|
67
|
+
const service = useService(ProductsListPaginationServiceDefinition);
|
|
68
|
+
const currentLimit = service.currentLimit.get();
|
|
69
|
+
const setLimit = service.setLimit;
|
|
70
|
+
return typeof props.children === "function"
|
|
71
|
+
? props.children({ currentLimit, setLimit })
|
|
72
|
+
: props.children;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Headless component for navigating to the next page
|
|
76
|
+
*
|
|
77
|
+
* @component
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* import { ProductListPagination } from '@wix/stores/components';
|
|
81
|
+
*
|
|
82
|
+
* function NextPageButton() {
|
|
83
|
+
* return (
|
|
84
|
+
* <ProductListPagination.NextPageTrigger>
|
|
85
|
+
* {({ nextPage, hasNextPage }) => (
|
|
86
|
+
* <button
|
|
87
|
+
* onClick={nextPage}
|
|
88
|
+
* disabled={!hasNextPage}
|
|
89
|
+
* className={hasNextPage ? 'enabled' : 'disabled'}
|
|
90
|
+
* >
|
|
91
|
+
* Next →
|
|
92
|
+
* </button>
|
|
93
|
+
* )}
|
|
94
|
+
* </ProductListPagination.NextPageTrigger>
|
|
95
|
+
* );
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export function NextPageTrigger(props) {
|
|
100
|
+
const service = useService(ProductsListPaginationServiceDefinition);
|
|
101
|
+
const nextPage = service.nextPage;
|
|
102
|
+
const hasNextPage = service.hasNextPage.get();
|
|
103
|
+
return typeof props.children === "function"
|
|
104
|
+
? props.children({ nextPage, hasNextPage })
|
|
105
|
+
: props.children;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Headless component for navigating to the previous page
|
|
109
|
+
*
|
|
110
|
+
* @component
|
|
111
|
+
* @example
|
|
112
|
+
* ```tsx
|
|
113
|
+
* import { ProductListPagination } from '@wix/stores/components';
|
|
114
|
+
*
|
|
115
|
+
* function PrevPageButton() {
|
|
116
|
+
* return (
|
|
117
|
+
* <ProductListPagination.PreviousPageTrigger>
|
|
118
|
+
* {({ prevPage, hasPrevPage }) => (
|
|
119
|
+
* <button
|
|
120
|
+
* onClick={prevPage}
|
|
121
|
+
* disabled={!hasPrevPage}
|
|
122
|
+
* className={hasPrevPage ? 'enabled' : 'disabled'}
|
|
123
|
+
* >
|
|
124
|
+
* ← Previous
|
|
125
|
+
* </button>
|
|
126
|
+
* )}
|
|
127
|
+
* </ProductListPagination.PreviousPageTrigger>
|
|
128
|
+
* );
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export function PreviousPageTrigger(props) {
|
|
133
|
+
const service = useService(ProductsListPaginationServiceDefinition);
|
|
134
|
+
const prevPage = service.prevPage;
|
|
135
|
+
const hasPrevPage = service.hasPrevPage.get();
|
|
136
|
+
return typeof props.children === "function"
|
|
137
|
+
? props.children({ prevPage, hasPrevPage })
|
|
138
|
+
: props.children;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Headless component for navigating to the first page
|
|
142
|
+
*
|
|
143
|
+
* @component
|
|
144
|
+
* @example
|
|
145
|
+
* ```tsx
|
|
146
|
+
* import { ProductListPagination } from '@wix/stores/components';
|
|
147
|
+
*
|
|
148
|
+
* function FirstPageButton() {
|
|
149
|
+
* return (
|
|
150
|
+
* <ProductListPagination.FirstPageTrigger>
|
|
151
|
+
* {({ goToFirstPage, hasPrevPage }) => (
|
|
152
|
+
* <button
|
|
153
|
+
* onClick={goToFirstPage}
|
|
154
|
+
* disabled={!hasPrevPage}
|
|
155
|
+
* title="Go to first page"
|
|
156
|
+
* >
|
|
157
|
+
* ⏮ First
|
|
158
|
+
* </button>
|
|
159
|
+
* )}
|
|
160
|
+
* </ProductListPagination.FirstPageTrigger>
|
|
161
|
+
* );
|
|
162
|
+
* }
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export function FirstPageTrigger(props) {
|
|
166
|
+
const service = useService(ProductsListPaginationServiceDefinition);
|
|
167
|
+
const goToFirstPage = service.goToFirstPage;
|
|
168
|
+
const hasPrevPage = service.hasPrevPage.get();
|
|
169
|
+
return typeof props.children === "function"
|
|
170
|
+
? props.children({ goToFirstPage, hasPrevPage })
|
|
171
|
+
: props.children;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Headless component for loading more products (infinite scroll pattern)
|
|
175
|
+
*
|
|
176
|
+
* @component
|
|
177
|
+
* @example
|
|
178
|
+
* ```tsx
|
|
179
|
+
* import { ProductListPagination } from '@wix/stores/components';
|
|
180
|
+
*
|
|
181
|
+
* function LoadMoreButton() {
|
|
182
|
+
* return (
|
|
183
|
+
* <ProductListPagination.LoadMoreTrigger>
|
|
184
|
+
* {({ loadMore, hasMoreProducts, isLoading }) => (
|
|
185
|
+
* <button
|
|
186
|
+
* onClick={() => loadMore(10)}
|
|
187
|
+
* disabled={!hasMoreProducts || isLoading}
|
|
188
|
+
* className="load-more-btn"
|
|
189
|
+
* >
|
|
190
|
+
* {isLoading ? 'Loading...' : hasMoreProducts ? 'Load More' : 'No More Products'}
|
|
191
|
+
* </button>
|
|
192
|
+
* )}
|
|
193
|
+
* </ProductListPagination.LoadMoreTrigger>
|
|
194
|
+
* );
|
|
195
|
+
* }
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
export function LoadMoreTrigger(props) {
|
|
199
|
+
const service = useService(ProductsListPaginationServiceDefinition);
|
|
200
|
+
const productsListService = useService(ProductsListServiceDefinition);
|
|
201
|
+
const loadMore = service.loadMore;
|
|
202
|
+
const hasMoreProducts = service.hasNextPage.get();
|
|
203
|
+
const isLoading = productsListService.isLoading.get();
|
|
204
|
+
return typeof props.children === "function"
|
|
205
|
+
? props.children({ loadMore, hasMoreProducts, isLoading })
|
|
206
|
+
: props.children;
|
|
207
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { PropsWithChildren, ReactNode } from "react";
|
|
2
|
+
import { SortType } from "../services/products-list-sort-service.js";
|
|
3
|
+
/**
|
|
4
|
+
* Root component that provides the ProductListSort service context to its children.
|
|
5
|
+
* This component sets up the necessary services for managing products list sorting.
|
|
6
|
+
*
|
|
7
|
+
* @order 1
|
|
8
|
+
* @component
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { ProductListSort } from '@wix/stores/components';
|
|
12
|
+
*
|
|
13
|
+
* function SortSection() {
|
|
14
|
+
* return (
|
|
15
|
+
* <ProductListSort.Root>
|
|
16
|
+
* <ProductListSort.Options>
|
|
17
|
+
* {({ selectedSortOption, setSelectedSortOption, sortOptions }) => (
|
|
18
|
+
* <select
|
|
19
|
+
* value={selectedSortOption}
|
|
20
|
+
* onChange={(e) => setSelectedSortOption(e.target.value)}
|
|
21
|
+
* >
|
|
22
|
+
* {sortOptions.map(option => (
|
|
23
|
+
* <option key={option.value} value={option.value}>
|
|
24
|
+
* {option.label}
|
|
25
|
+
* </option>
|
|
26
|
+
* ))}
|
|
27
|
+
* </select>
|
|
28
|
+
* )}
|
|
29
|
+
* </ProductListSort.Options>
|
|
30
|
+
* </ProductListSort.Root>
|
|
31
|
+
* );
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function Root(props: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
/**
|
|
37
|
+
* Props for Options headless component
|
|
38
|
+
*/
|
|
39
|
+
export interface OptionsProps {
|
|
40
|
+
/** Content to display (can be a render function receiving sort controls or ReactNode) */
|
|
41
|
+
children: ((props: OptionsRenderProps) => ReactNode) | ReactNode;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Render props for Options component
|
|
45
|
+
*/
|
|
46
|
+
export interface OptionsRenderProps {
|
|
47
|
+
/** Currently selected sort option value */
|
|
48
|
+
selectedSortOption: string;
|
|
49
|
+
/** Function to update the selected sort option */
|
|
50
|
+
setSelectedSortOption: (sort: string) => void;
|
|
51
|
+
/** Available sort options */
|
|
52
|
+
sortOptions: SortType[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Headless component for managing product list sorting options
|
|
56
|
+
*
|
|
57
|
+
* @component
|
|
58
|
+
* @example
|
|
59
|
+
* ```tsx
|
|
60
|
+
* import { ProductListSort } from '@wix/stores/components';
|
|
61
|
+
*
|
|
62
|
+
* function ProductSortDropdown() {
|
|
63
|
+
* return (
|
|
64
|
+
* <ProductListSort.Options>
|
|
65
|
+
* {({ selectedSortOption, setSelectedSortOption, sortOptions }) => (
|
|
66
|
+
* <div className="sort-container">
|
|
67
|
+
* <label htmlFor="sort-select">Sort by:</label>
|
|
68
|
+
* <select
|
|
69
|
+
* id="sort-select"
|
|
70
|
+
* value={selectedSortOption}
|
|
71
|
+
* onChange={(e) => setSelectedSortOption(e.target.value)}
|
|
72
|
+
* className="sort-dropdown"
|
|
73
|
+
* >
|
|
74
|
+
* {sortOptions.map(option => (
|
|
75
|
+
* <option key={option.value} value={option.value}>
|
|
76
|
+
* {option.label}
|
|
77
|
+
* </option>
|
|
78
|
+
* ))}
|
|
79
|
+
* </select>
|
|
80
|
+
* </div>
|
|
81
|
+
* )}
|
|
82
|
+
* </ProductListSort.Options>
|
|
83
|
+
* );
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare function Options(props: OptionsProps): ReactNode;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createServicesMap } from "@wix/services-manager";
|
|
3
|
+
import { useService, WixServices } from "@wix/services-manager-react";
|
|
4
|
+
import { ProductsListSortService, ProductsListSortServiceDefinition, } from "../services/products-list-sort-service.js";
|
|
5
|
+
/**
|
|
6
|
+
* Root component that provides the ProductListSort service context to its children.
|
|
7
|
+
* This component sets up the necessary services for managing products list sorting.
|
|
8
|
+
*
|
|
9
|
+
* @order 1
|
|
10
|
+
* @component
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { ProductListSort } from '@wix/stores/components';
|
|
14
|
+
*
|
|
15
|
+
* function SortSection() {
|
|
16
|
+
* return (
|
|
17
|
+
* <ProductListSort.Root>
|
|
18
|
+
* <ProductListSort.Options>
|
|
19
|
+
* {({ selectedSortOption, setSelectedSortOption, sortOptions }) => (
|
|
20
|
+
* <select
|
|
21
|
+
* value={selectedSortOption}
|
|
22
|
+
* onChange={(e) => setSelectedSortOption(e.target.value)}
|
|
23
|
+
* >
|
|
24
|
+
* {sortOptions.map(option => (
|
|
25
|
+
* <option key={option.value} value={option.value}>
|
|
26
|
+
* {option.label}
|
|
27
|
+
* </option>
|
|
28
|
+
* ))}
|
|
29
|
+
* </select>
|
|
30
|
+
* )}
|
|
31
|
+
* </ProductListSort.Options>
|
|
32
|
+
* </ProductListSort.Root>
|
|
33
|
+
* );
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function Root(props) {
|
|
38
|
+
return (_jsx(WixServices, { servicesMap: createServicesMap().addService(ProductsListSortServiceDefinition, ProductsListSortService, {}), children: props.children }));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Headless component for managing product list sorting options
|
|
42
|
+
*
|
|
43
|
+
* @component
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* import { ProductListSort } from '@wix/stores/components';
|
|
47
|
+
*
|
|
48
|
+
* function ProductSortDropdown() {
|
|
49
|
+
* return (
|
|
50
|
+
* <ProductListSort.Options>
|
|
51
|
+
* {({ selectedSortOption, setSelectedSortOption, sortOptions }) => (
|
|
52
|
+
* <div className="sort-container">
|
|
53
|
+
* <label htmlFor="sort-select">Sort by:</label>
|
|
54
|
+
* <select
|
|
55
|
+
* id="sort-select"
|
|
56
|
+
* value={selectedSortOption}
|
|
57
|
+
* onChange={(e) => setSelectedSortOption(e.target.value)}
|
|
58
|
+
* className="sort-dropdown"
|
|
59
|
+
* >
|
|
60
|
+
* {sortOptions.map(option => (
|
|
61
|
+
* <option key={option.value} value={option.value}>
|
|
62
|
+
* {option.label}
|
|
63
|
+
* </option>
|
|
64
|
+
* ))}
|
|
65
|
+
* </select>
|
|
66
|
+
* </div>
|
|
67
|
+
* )}
|
|
68
|
+
* </ProductListSort.Options>
|
|
69
|
+
* );
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function Options(props) {
|
|
74
|
+
const service = useService(ProductsListSortServiceDefinition);
|
|
75
|
+
const selectedSortOption = service.selectedSortOption.get();
|
|
76
|
+
const sortOptions = service.sortOptions;
|
|
77
|
+
const setSelectedSortOption = service.setSelectedSortOption;
|
|
78
|
+
return typeof props.children === "function"
|
|
79
|
+
? props.children({
|
|
80
|
+
selectedSortOption,
|
|
81
|
+
setSelectedSortOption,
|
|
82
|
+
sortOptions,
|
|
83
|
+
})
|
|
84
|
+
: props.children;
|
|
85
|
+
}
|
|
@@ -140,7 +140,7 @@ export interface ModifiersRenderProps {
|
|
|
140
140
|
* }
|
|
141
141
|
* ```
|
|
142
142
|
*/
|
|
143
|
-
export declare
|
|
143
|
+
export declare function Modifiers(props: ModifiersProps): import("react").ReactNode;
|
|
144
144
|
/**
|
|
145
145
|
* Props for Modifier headless component
|
|
146
146
|
*/
|
|
@@ -219,7 +219,7 @@ export interface ModifierRenderProps {
|
|
|
219
219
|
* }
|
|
220
220
|
* ```
|
|
221
221
|
*/
|
|
222
|
-
export declare
|
|
222
|
+
export declare function Modifier(props: ModifierProps): import("react").ReactNode;
|
|
223
223
|
/**
|
|
224
224
|
* Props for ModifierChoice headless component
|
|
225
225
|
*/
|
|
@@ -280,7 +280,7 @@ export interface ChoiceRenderProps {
|
|
|
280
280
|
* }
|
|
281
281
|
* ```
|
|
282
282
|
*/
|
|
283
|
-
export declare
|
|
283
|
+
export declare function Choice(props: ChoiceProps): import("react").ReactNode;
|
|
284
284
|
/**
|
|
285
285
|
* Props for ModifierFreeText headless component
|
|
286
286
|
*/
|
|
@@ -346,7 +346,7 @@ export interface FreeTextRenderProps {
|
|
|
346
346
|
* }
|
|
347
347
|
* ```
|
|
348
348
|
*/
|
|
349
|
-
export declare
|
|
349
|
+
export declare function FreeText(props: FreeTextProps): import("react").ReactNode;
|
|
350
350
|
/**
|
|
351
351
|
* Props for ModifierToggleFreeText headless component
|
|
352
352
|
*/
|
|
@@ -411,4 +411,4 @@ export interface ToggleFreeTextRenderProps {
|
|
|
411
411
|
* }
|
|
412
412
|
* ```
|
|
413
413
|
*/
|
|
414
|
-
export declare
|
|
414
|
+
export declare function ToggleFreeText(props: ToggleFreeTextProps): import("react").ReactNode;
|
|
@@ -137,7 +137,7 @@ function useModifiersService() {
|
|
|
137
137
|
* }
|
|
138
138
|
* ```
|
|
139
139
|
*/
|
|
140
|
-
export
|
|
140
|
+
export function Modifiers(props) {
|
|
141
141
|
const modifiersService = useModifiersService();
|
|
142
142
|
if (!modifiersService) {
|
|
143
143
|
return props.children({
|
|
@@ -157,7 +157,7 @@ export const Modifiers = (props) => {
|
|
|
157
157
|
selectedModifiers,
|
|
158
158
|
areAllRequiredModifiersFilled,
|
|
159
159
|
});
|
|
160
|
-
}
|
|
160
|
+
}
|
|
161
161
|
/**
|
|
162
162
|
* Headless component for a specific product modifier
|
|
163
163
|
*
|
|
@@ -204,7 +204,7 @@ export const Modifiers = (props) => {
|
|
|
204
204
|
* }
|
|
205
205
|
* ```
|
|
206
206
|
*/
|
|
207
|
-
export
|
|
207
|
+
export function Modifier(props) {
|
|
208
208
|
const modifiersService = useModifiersService();
|
|
209
209
|
const { modifier } = props;
|
|
210
210
|
const name = modifier.name || "";
|
|
@@ -228,7 +228,7 @@ export const Modifier = (props) => {
|
|
|
228
228
|
maxChars,
|
|
229
229
|
placeholder,
|
|
230
230
|
});
|
|
231
|
-
}
|
|
231
|
+
}
|
|
232
232
|
/**
|
|
233
233
|
* Headless component for individual modifier choice selection
|
|
234
234
|
*
|
|
@@ -259,7 +259,7 @@ export const Modifier = (props) => {
|
|
|
259
259
|
* }
|
|
260
260
|
* ```
|
|
261
261
|
*/
|
|
262
|
-
export
|
|
262
|
+
export function Choice(props) {
|
|
263
263
|
const modifiersService = useModifiersService();
|
|
264
264
|
const { modifier, choice } = props;
|
|
265
265
|
const modifierName = modifier.name || "";
|
|
@@ -285,7 +285,7 @@ export const Choice = (props) => {
|
|
|
285
285
|
choiceValue,
|
|
286
286
|
colorCode,
|
|
287
287
|
});
|
|
288
|
-
}
|
|
288
|
+
}
|
|
289
289
|
/**
|
|
290
290
|
* Headless component for free text modifier input
|
|
291
291
|
*
|
|
@@ -321,7 +321,7 @@ export const Choice = (props) => {
|
|
|
321
321
|
* }
|
|
322
322
|
* ```
|
|
323
323
|
*/
|
|
324
|
-
export
|
|
324
|
+
export function FreeText(props) {
|
|
325
325
|
const modifiersService = useModifiersService();
|
|
326
326
|
const { modifier } = props;
|
|
327
327
|
const modifierName = modifier.name || "";
|
|
@@ -348,7 +348,7 @@ export const FreeText = (props) => {
|
|
|
348
348
|
isOverLimit,
|
|
349
349
|
modifierName,
|
|
350
350
|
});
|
|
351
|
-
}
|
|
351
|
+
}
|
|
352
352
|
/**
|
|
353
353
|
* Headless component for toggling free text modifier input
|
|
354
354
|
* Used for optional free text modifiers where a checkbox shows/hides the input
|
|
@@ -391,7 +391,7 @@ export const FreeText = (props) => {
|
|
|
391
391
|
* }
|
|
392
392
|
* ```
|
|
393
393
|
*/
|
|
394
|
-
export
|
|
394
|
+
export function ToggleFreeText(props) {
|
|
395
395
|
const modifiersService = useModifiersService();
|
|
396
396
|
const { modifier } = props;
|
|
397
397
|
const modifierName = modifier.name || "";
|
|
@@ -410,4 +410,4 @@ export const ToggleFreeText = (props) => {
|
|
|
410
410
|
mandatory,
|
|
411
411
|
modifierName,
|
|
412
412
|
});
|
|
413
|
-
}
|
|
413
|
+
}
|
|
@@ -92,7 +92,7 @@ export interface OptionsRenderProps {
|
|
|
92
92
|
* }
|
|
93
93
|
* ```
|
|
94
94
|
*/
|
|
95
|
-
export declare
|
|
95
|
+
export declare function Options(props: OptionsProps): import("react").ReactNode;
|
|
96
96
|
/**
|
|
97
97
|
* Props for Option headless component
|
|
98
98
|
*/
|
|
@@ -148,7 +148,7 @@ export interface OptionRenderProps {
|
|
|
148
148
|
* }
|
|
149
149
|
* ```
|
|
150
150
|
*/
|
|
151
|
-
export declare
|
|
151
|
+
export declare function Option(props: OptionProps): import("react").ReactNode;
|
|
152
152
|
/**
|
|
153
153
|
* Props for Choice headless component
|
|
154
154
|
*/
|
|
@@ -209,7 +209,7 @@ export interface ChoiceRenderProps {
|
|
|
209
209
|
* }
|
|
210
210
|
* ```
|
|
211
211
|
*/
|
|
212
|
-
export declare
|
|
212
|
+
export declare function Choice(props: ChoiceProps): import("react").ReactNode;
|
|
213
213
|
/**
|
|
214
214
|
* Props for Stock headless component
|
|
215
215
|
*/
|
|
@@ -271,7 +271,7 @@ export interface StockRenderProps {
|
|
|
271
271
|
* }
|
|
272
272
|
* ```
|
|
273
273
|
*/
|
|
274
|
-
export declare
|
|
274
|
+
export declare function Stock(props: StockProps): import("react").ReactNode;
|
|
275
275
|
/**
|
|
276
276
|
* Props for Reset headless component
|
|
277
277
|
*/
|
|
@@ -311,4 +311,4 @@ export interface ResetRenderProps {
|
|
|
311
311
|
* }
|
|
312
312
|
* ```
|
|
313
313
|
*/
|
|
314
|
-
export declare
|
|
314
|
+
export declare function Reset(props: ResetProps): import("react").ReactNode;
|
|
@@ -76,7 +76,7 @@ export function Root(props) {
|
|
|
76
76
|
* }
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
|
-
export
|
|
79
|
+
export function Options(props) {
|
|
80
80
|
const variantService = useService(SelectedVariantServiceDefinition);
|
|
81
81
|
const selectedChoices = variantService.selectedChoices.get();
|
|
82
82
|
const options = variantService.productOptions.get();
|
|
@@ -85,7 +85,7 @@ export const Options = (props) => {
|
|
|
85
85
|
hasOptions: options.length > 0,
|
|
86
86
|
selectedChoices,
|
|
87
87
|
});
|
|
88
|
-
}
|
|
88
|
+
}
|
|
89
89
|
/**
|
|
90
90
|
* Headless component for choices within a specific product option
|
|
91
91
|
*
|
|
@@ -117,7 +117,7 @@ export const Options = (props) => {
|
|
|
117
117
|
* }
|
|
118
118
|
* ```
|
|
119
119
|
*/
|
|
120
|
-
export
|
|
120
|
+
export function Option(props) {
|
|
121
121
|
const variantService = useService(SelectedVariantServiceDefinition);
|
|
122
122
|
const selectedChoices = variantService.selectedChoices.get();
|
|
123
123
|
const { option } = props;
|
|
@@ -131,7 +131,7 @@ export const Option = (props) => {
|
|
|
131
131
|
selectedValue,
|
|
132
132
|
hasChoices: choices.length > 0,
|
|
133
133
|
});
|
|
134
|
-
}
|
|
134
|
+
}
|
|
135
135
|
/**
|
|
136
136
|
* Headless component for individual choice selection
|
|
137
137
|
*
|
|
@@ -158,7 +158,7 @@ export const Option = (props) => {
|
|
|
158
158
|
* }
|
|
159
159
|
* ```
|
|
160
160
|
*/
|
|
161
|
-
export
|
|
161
|
+
export function Choice(props) {
|
|
162
162
|
const variantService = useService(SelectedVariantServiceDefinition);
|
|
163
163
|
const selectedChoices = variantService.selectedChoices.get();
|
|
164
164
|
const { option, choice } = props;
|
|
@@ -190,7 +190,8 @@ export const Choice = (props) => {
|
|
|
190
190
|
optionName,
|
|
191
191
|
choiceValue,
|
|
192
192
|
});
|
|
193
|
-
}
|
|
193
|
+
}
|
|
194
|
+
;
|
|
194
195
|
/**
|
|
195
196
|
* Headless component for product stock status
|
|
196
197
|
*
|
|
@@ -222,7 +223,7 @@ export const Choice = (props) => {
|
|
|
222
223
|
* }
|
|
223
224
|
* ```
|
|
224
225
|
*/
|
|
225
|
-
export
|
|
226
|
+
export function Stock(props) {
|
|
226
227
|
const variantService = useService(SelectedVariantServiceDefinition);
|
|
227
228
|
const inStock = variantService.isInStock.get();
|
|
228
229
|
const isPreOrderEnabled = variantService.isPreOrderEnabled.get();
|
|
@@ -251,7 +252,8 @@ export const Stock = (props) => {
|
|
|
251
252
|
incrementQuantity,
|
|
252
253
|
decrementQuantity,
|
|
253
254
|
});
|
|
254
|
-
}
|
|
255
|
+
}
|
|
256
|
+
;
|
|
255
257
|
/**
|
|
256
258
|
* Headless component for resetting variant selections
|
|
257
259
|
*
|
|
@@ -275,7 +277,7 @@ export const Stock = (props) => {
|
|
|
275
277
|
* }
|
|
276
278
|
* ```
|
|
277
279
|
*/
|
|
278
|
-
export
|
|
280
|
+
export function Reset(props) {
|
|
279
281
|
const variantService = useService(SelectedVariantServiceDefinition);
|
|
280
282
|
const selectedChoices = variantService.selectedChoices.get();
|
|
281
283
|
const hasSelections = Object.keys(selectedChoices).length > 0;
|
|
@@ -286,4 +288,5 @@ export const Reset = (props) => {
|
|
|
286
288
|
onReset,
|
|
287
289
|
hasSelections,
|
|
288
290
|
});
|
|
289
|
-
}
|
|
291
|
+
}
|
|
292
|
+
;
|