@wix/headless-stores 0.0.81 → 0.0.83
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 +45 -0
- package/cjs/dist/react/Category.js +43 -3
- package/cjs/dist/react/ProductList.d.ts +100 -1
- package/cjs/dist/react/ProductList.js +123 -1
- package/cjs/dist/react/core/ProductListFilters.d.ts +1 -1
- package/cjs/dist/react/core/ProductListFilters.js +2 -2
- package/cjs/dist/react/core/SelectedVariant.js +2 -2
- package/cjs/dist/react/index.d.ts +0 -7
- package/cjs/dist/react/index.js +0 -7
- package/dist/react/Category.d.ts +45 -0
- package/dist/react/Category.js +43 -3
- package/dist/react/ProductList.d.ts +100 -1
- package/dist/react/ProductList.js +123 -1
- package/dist/react/core/ProductListFilters.d.ts +1 -1
- package/dist/react/core/ProductListFilters.js +2 -2
- package/dist/react/core/SelectedVariant.js +2 -2
- package/dist/react/index.d.ts +0 -7
- package/dist/react/index.js +0 -7
- package/package.json +2 -2
|
@@ -71,6 +71,22 @@ export interface CategoryRawProps {
|
|
|
71
71
|
/** CSS classes to apply to the default element */
|
|
72
72
|
className?: string;
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Props for CategoryFilter component
|
|
76
|
+
*/
|
|
77
|
+
export interface CategoryFilterProps {
|
|
78
|
+
/** Whether to render as a child component */
|
|
79
|
+
asChild?: boolean;
|
|
80
|
+
/** Custom render function when using asChild */
|
|
81
|
+
children?: AsChildChildren<{
|
|
82
|
+
selectedCategory: Category | null;
|
|
83
|
+
setSelectedCategory: (category: Category | null) => void;
|
|
84
|
+
}>;
|
|
85
|
+
/** CSS classes to apply to the default element */
|
|
86
|
+
className?: string;
|
|
87
|
+
/** Label for the selected category display */
|
|
88
|
+
label?: string;
|
|
89
|
+
}
|
|
74
90
|
/**
|
|
75
91
|
* Root container for a single category item.
|
|
76
92
|
* This component sets up the necessary services for managing category state
|
|
@@ -195,3 +211,32 @@ export declare const ID: React.ForwardRefExoticComponent<CategoryIDProps & React
|
|
|
195
211
|
* ```
|
|
196
212
|
*/
|
|
197
213
|
export declare const Raw: React.ForwardRefExoticComponent<CategoryRawProps & React.RefAttributes<HTMLElement>>;
|
|
214
|
+
/**
|
|
215
|
+
* Category filter component that provides category selection functionality.
|
|
216
|
+
* Provides selected category state and selection controls to custom render functions.
|
|
217
|
+
*
|
|
218
|
+
* @component
|
|
219
|
+
* @example
|
|
220
|
+
* ```tsx
|
|
221
|
+
* // Default usage
|
|
222
|
+
* <CategoryFilter className="category-filter" />
|
|
223
|
+
*
|
|
224
|
+
* // With custom label
|
|
225
|
+
* <CategoryFilter label="Current Category:" />
|
|
226
|
+
*
|
|
227
|
+
* // Custom rendering with forwardRef
|
|
228
|
+
* <CategoryFilter asChild>
|
|
229
|
+
* {React.forwardRef(({selectedCategory, setSelectedCategory, ...props}, ref) => (
|
|
230
|
+
* <div ref={ref} {...props} className="custom-category-filter">
|
|
231
|
+
* {selectedCategory && (
|
|
232
|
+
* <span>Selected: {selectedCategory.name}</span>
|
|
233
|
+
* )}
|
|
234
|
+
* <button onClick={() => setSelectedCategory(null)}>
|
|
235
|
+
* Clear Selection
|
|
236
|
+
* </button>
|
|
237
|
+
* </div>
|
|
238
|
+
* ))}
|
|
239
|
+
* </CategoryFilter>
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
export declare const CategoryFilter: React.ForwardRefExoticComponent<CategoryFilterProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
4
|
-
import
|
|
4
|
+
import * as CoreProductListFilters from './core/ProductListFilters.js';
|
|
5
5
|
const CategoryContext = React.createContext(null);
|
|
6
6
|
function useCategoryContext() {
|
|
7
7
|
const context = React.useContext(CategoryContext);
|
|
@@ -17,6 +17,7 @@ var TestIds;
|
|
|
17
17
|
TestIds["categoryLabel"] = "category-label";
|
|
18
18
|
TestIds["categoryId"] = "category-id";
|
|
19
19
|
TestIds["categoryRaw"] = "category-raw";
|
|
20
|
+
TestIds["categoryFilter"] = "category-filter";
|
|
20
21
|
})(TestIds || (TestIds = {}));
|
|
21
22
|
/**
|
|
22
23
|
* Root container for a single category item.
|
|
@@ -38,7 +39,7 @@ var TestIds;
|
|
|
38
39
|
*/
|
|
39
40
|
export function Root(props) {
|
|
40
41
|
const { category, children } = props;
|
|
41
|
-
return (_jsx(CategoryFilter, { children: ({ selectedCategory, setSelectedCategory }) => {
|
|
42
|
+
return (_jsx(CoreProductListFilters.CategoryFilter, { children: ({ selectedCategory, setSelectedCategory }) => {
|
|
42
43
|
// Determine if this category is selected by comparing with selectedCategory
|
|
43
44
|
const isSelected = selectedCategory?._id === category._id;
|
|
44
45
|
const contextValue = {
|
|
@@ -190,3 +191,42 @@ export const Raw = React.forwardRef((props, ref) => {
|
|
|
190
191
|
const { category, isSelected } = useCategoryContext();
|
|
191
192
|
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className || 'sr-only', "data-testid": TestIds.categoryRaw, "data-selected": isSelected ? 'true' : 'false', customElement: children, customElementProps: { category, isSelected }, children: _jsx("span", { children: JSON.stringify(category) }) }));
|
|
192
193
|
});
|
|
194
|
+
/**
|
|
195
|
+
* Category filter component that provides category selection functionality.
|
|
196
|
+
* Provides selected category state and selection controls to custom render functions.
|
|
197
|
+
*
|
|
198
|
+
* @component
|
|
199
|
+
* @example
|
|
200
|
+
* ```tsx
|
|
201
|
+
* // Default usage
|
|
202
|
+
* <CategoryFilter className="category-filter" />
|
|
203
|
+
*
|
|
204
|
+
* // With custom label
|
|
205
|
+
* <CategoryFilter label="Current Category:" />
|
|
206
|
+
*
|
|
207
|
+
* // Custom rendering with forwardRef
|
|
208
|
+
* <CategoryFilter asChild>
|
|
209
|
+
* {React.forwardRef(({selectedCategory, setSelectedCategory, ...props}, ref) => (
|
|
210
|
+
* <div ref={ref} {...props} className="custom-category-filter">
|
|
211
|
+
* {selectedCategory && (
|
|
212
|
+
* <span>Selected: {selectedCategory.name}</span>
|
|
213
|
+
* )}
|
|
214
|
+
* <button onClick={() => setSelectedCategory(null)}>
|
|
215
|
+
* Clear Selection
|
|
216
|
+
* </button>
|
|
217
|
+
* </div>
|
|
218
|
+
* ))}
|
|
219
|
+
* </CategoryFilter>
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
export const CategoryFilter = React.forwardRef((props, ref) => {
|
|
223
|
+
const { asChild, children, className } = props;
|
|
224
|
+
const label = props.label || 'Selected:';
|
|
225
|
+
return (_jsx(CoreProductListFilters.CategoryFilter, { children: ({ selectedCategory, setSelectedCategory }) => {
|
|
226
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.categoryFilter, "data-selected": selectedCategory ? 'true' : 'false', customElement: children, customElementProps: {
|
|
227
|
+
selectedCategory,
|
|
228
|
+
setSelectedCategory,
|
|
229
|
+
}, children: _jsx("div", { children: selectedCategory && (_jsxs("span", { children: [label, " ", selectedCategory.name] })) }) }));
|
|
230
|
+
} }));
|
|
231
|
+
});
|
|
232
|
+
CategoryFilter.displayName = 'CategoryFilter';
|
|
@@ -4,7 +4,6 @@ import React from 'react';
|
|
|
4
4
|
import type { ProductsListServiceConfig } from '../services/products-list-service.js';
|
|
5
5
|
import { productsV3 } from '@wix/stores';
|
|
6
6
|
import { AsChildChildren } from '@wix/headless-utils/react';
|
|
7
|
-
export { Filter, ResetTrigger as FilterResetTrigger, } from './core/ProductListFilters.js';
|
|
8
7
|
/**
|
|
9
8
|
* Props for the ProductList root component following the documented API
|
|
10
9
|
*/
|
|
@@ -284,3 +283,103 @@ export interface SortProps {
|
|
|
284
283
|
* @see {@link SortPrimitive.Root} for the primitive sort component
|
|
285
284
|
*/
|
|
286
285
|
export declare const Sort: React.ForwardRefExoticComponent<SortProps & React.RefAttributes<HTMLElement>>;
|
|
286
|
+
/**
|
|
287
|
+
* Props for ProductList Filter component
|
|
288
|
+
*/
|
|
289
|
+
export interface FilterProps {
|
|
290
|
+
/** Whether to render as a child component */
|
|
291
|
+
asChild?: boolean;
|
|
292
|
+
/** Child components that will have access to filter functionality */
|
|
293
|
+
children: React.ReactNode;
|
|
294
|
+
/** CSS classes to apply to the default element */
|
|
295
|
+
className?: string;
|
|
296
|
+
}
|
|
297
|
+
export declare const Filter: {
|
|
298
|
+
Root: React.ForwardRefExoticComponent<FilterProps & React.RefAttributes<HTMLElement>>;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Props for ProductList FilterResetTrigger component
|
|
302
|
+
*/
|
|
303
|
+
export interface FilterResetTriggerProps {
|
|
304
|
+
/** Whether to render as a child component */
|
|
305
|
+
asChild?: boolean;
|
|
306
|
+
/** Custom render function when using asChild */
|
|
307
|
+
children?: AsChildChildren<{
|
|
308
|
+
resetFilters: () => void;
|
|
309
|
+
isFiltered: boolean;
|
|
310
|
+
}>;
|
|
311
|
+
/** CSS classes to apply to the default element */
|
|
312
|
+
className?: string;
|
|
313
|
+
/** Label for the button */
|
|
314
|
+
label?: string;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Reset trigger component for clearing all applied filters.
|
|
318
|
+
* Provides reset functionality and filter state to custom render functions.
|
|
319
|
+
* Only renders when filters are applied.
|
|
320
|
+
*
|
|
321
|
+
* @component
|
|
322
|
+
* @example
|
|
323
|
+
* ```tsx
|
|
324
|
+
* // Default usage
|
|
325
|
+
* <ProductList.FilterResetTrigger className="reset-filters-btn" />
|
|
326
|
+
*
|
|
327
|
+
* // With custom label
|
|
328
|
+
* <ProductList.FilterResetTrigger label="Clear Filters" />
|
|
329
|
+
*
|
|
330
|
+
* // Custom rendering with forwardRef
|
|
331
|
+
* <ProductList.FilterResetTrigger asChild>
|
|
332
|
+
* {React.forwardRef(({resetFilters, isFiltered, ...props}, ref) => (
|
|
333
|
+
* <button
|
|
334
|
+
* ref={ref}
|
|
335
|
+
* {...props}
|
|
336
|
+
* onClick={resetFilters}
|
|
337
|
+
* disabled={!isFiltered}
|
|
338
|
+
* className="custom-reset-button disabled:opacity-50"
|
|
339
|
+
* >
|
|
340
|
+
* Reset All Filters
|
|
341
|
+
* </button>
|
|
342
|
+
* ))}
|
|
343
|
+
* </ProductList.FilterResetTrigger>
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
export declare const FilterResetTrigger: React.ForwardRefExoticComponent<FilterResetTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
347
|
+
/**
|
|
348
|
+
* Props for ProductList Error component
|
|
349
|
+
*/
|
|
350
|
+
export interface ErrorProps {
|
|
351
|
+
/** Whether to render as a child component */
|
|
352
|
+
asChild?: boolean;
|
|
353
|
+
/** Custom render function when using asChild */
|
|
354
|
+
children?: AsChildChildren<{
|
|
355
|
+
error: string | null;
|
|
356
|
+
}>;
|
|
357
|
+
/** CSS classes to apply to the default element */
|
|
358
|
+
className?: string;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Error component that displays product list errors.
|
|
362
|
+
* Provides error data to custom render functions.
|
|
363
|
+
* Only renders when there's an error.
|
|
364
|
+
*
|
|
365
|
+
* @component
|
|
366
|
+
* @example
|
|
367
|
+
* ```tsx
|
|
368
|
+
* // Default usage
|
|
369
|
+
* <ProductList.Error className="error-message" />
|
|
370
|
+
*
|
|
371
|
+
* // Custom rendering with forwardRef
|
|
372
|
+
* <ProductList.Error asChild>
|
|
373
|
+
* {React.forwardRef(({error, ...props}, ref) => (
|
|
374
|
+
* <div
|
|
375
|
+
* ref={ref}
|
|
376
|
+
* {...props}
|
|
377
|
+
* className="custom-error-container"
|
|
378
|
+
* >
|
|
379
|
+
* Error: {error}
|
|
380
|
+
* </div>
|
|
381
|
+
* ))}
|
|
382
|
+
* </ProductList.Error>
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
385
|
+
export declare const Error: React.ForwardRefExoticComponent<ErrorProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -6,9 +6,9 @@ import { ProductsListServiceDefinition } from '../services/products-list-service
|
|
|
6
6
|
import * as CoreProductList from './core/ProductList.js';
|
|
7
7
|
import * as CoreProductListPagination from './core/ProductListPagination.js';
|
|
8
8
|
import { ProductListSort as ProductListSortPrimitive } from './core/ProductListSort.js';
|
|
9
|
+
import * as CoreProductListFilters from './core/ProductListFilters.js';
|
|
9
10
|
import * as Product from './Product.js';
|
|
10
11
|
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
11
|
-
export { Filter, ResetTrigger as FilterResetTrigger, } from './core/ProductListFilters.js';
|
|
12
12
|
var TestIds;
|
|
13
13
|
(function (TestIds) {
|
|
14
14
|
TestIds["productListRoot"] = "product-list-root";
|
|
@@ -17,6 +17,9 @@ var TestIds;
|
|
|
17
17
|
TestIds["productListLoadMore"] = "product-list-load-more";
|
|
18
18
|
TestIds["productListTotalsDisplayed"] = "product-list-totals-displayed";
|
|
19
19
|
TestIds["productListSort"] = "product-list-sort";
|
|
20
|
+
TestIds["productListFilter"] = "product-list-filter";
|
|
21
|
+
TestIds["productListFilterResetTrigger"] = "product-list-filter-reset-trigger";
|
|
22
|
+
TestIds["productListError"] = "product-list-error";
|
|
20
23
|
})(TestIds || (TestIds = {}));
|
|
21
24
|
/**
|
|
22
25
|
* Root component that provides the ProductList service context for rendering product lists.
|
|
@@ -266,3 +269,122 @@ export const Sort = React.forwardRef(({ children, className, as, asChild }, ref)
|
|
|
266
269
|
}, sortOptions: sortOptions, as: as, className: className, "data-testid": TestIds.productListSort }));
|
|
267
270
|
} }));
|
|
268
271
|
});
|
|
272
|
+
/**
|
|
273
|
+
* Filter component that provides comprehensive filtering functionality for product lists.
|
|
274
|
+
* This component acts as a provider that integrates with the ProductList service.
|
|
275
|
+
*
|
|
276
|
+
* @component
|
|
277
|
+
* @example
|
|
278
|
+
* ```tsx
|
|
279
|
+
* // Default usage
|
|
280
|
+
* <ProductList.Filter.Root className="filter-container">
|
|
281
|
+
* <Filter.FilterOptions>
|
|
282
|
+
* <Filter.FilterOptionRepeater>
|
|
283
|
+
* <Filter.FilterOption.Label />
|
|
284
|
+
* <Filter.FilterOption.MultiFilter />
|
|
285
|
+
* </Filter.FilterOptionRepeater>
|
|
286
|
+
* </Filter.FilterOptions>
|
|
287
|
+
* </ProductList.Filter.Root>
|
|
288
|
+
*
|
|
289
|
+
* // With custom container using asChild
|
|
290
|
+
* <ProductList.Filter.Root asChild>
|
|
291
|
+
* <aside className="filter-sidebar">
|
|
292
|
+
* <Filter.FilterOptions>
|
|
293
|
+
* <Filter.FilterOptionRepeater>
|
|
294
|
+
* <Filter.FilterOption.Label />
|
|
295
|
+
* <Filter.FilterOption.MultiFilter />
|
|
296
|
+
* </Filter.FilterOptionRepeater>
|
|
297
|
+
* </Filter.FilterOptions>
|
|
298
|
+
* </aside>
|
|
299
|
+
* </ProductList.Filter.Root>
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
const FilterRoot = React.forwardRef((props, ref) => {
|
|
303
|
+
const { asChild, children, className } = props;
|
|
304
|
+
return (_jsx(CoreProductListFilters.FilterRoot, { asChild: asChild, className: className, children: _jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productListFilter, customElement: children, children: _jsx("div", { children: children }) }) }));
|
|
305
|
+
});
|
|
306
|
+
FilterRoot.displayName = 'ProductList.Filter';
|
|
307
|
+
export const Filter = {
|
|
308
|
+
Root: FilterRoot,
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* Reset trigger component for clearing all applied filters.
|
|
312
|
+
* Provides reset functionality and filter state to custom render functions.
|
|
313
|
+
* Only renders when filters are applied.
|
|
314
|
+
*
|
|
315
|
+
* @component
|
|
316
|
+
* @example
|
|
317
|
+
* ```tsx
|
|
318
|
+
* // Default usage
|
|
319
|
+
* <ProductList.FilterResetTrigger className="reset-filters-btn" />
|
|
320
|
+
*
|
|
321
|
+
* // With custom label
|
|
322
|
+
* <ProductList.FilterResetTrigger label="Clear Filters" />
|
|
323
|
+
*
|
|
324
|
+
* // Custom rendering with forwardRef
|
|
325
|
+
* <ProductList.FilterResetTrigger asChild>
|
|
326
|
+
* {React.forwardRef(({resetFilters, isFiltered, ...props}, ref) => (
|
|
327
|
+
* <button
|
|
328
|
+
* ref={ref}
|
|
329
|
+
* {...props}
|
|
330
|
+
* onClick={resetFilters}
|
|
331
|
+
* disabled={!isFiltered}
|
|
332
|
+
* className="custom-reset-button disabled:opacity-50"
|
|
333
|
+
* >
|
|
334
|
+
* Reset All Filters
|
|
335
|
+
* </button>
|
|
336
|
+
* ))}
|
|
337
|
+
* </ProductList.FilterResetTrigger>
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
export const FilterResetTrigger = React.forwardRef((props, ref) => {
|
|
341
|
+
const { asChild, children, className } = props;
|
|
342
|
+
const label = props.label || 'Reset All Filters';
|
|
343
|
+
return (_jsx(CoreProductListFilters.ResetTrigger, { children: ({ resetFilters, isFiltered }) => {
|
|
344
|
+
if (!isFiltered) {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onClick: resetFilters, disabled: !isFiltered, "data-testid": TestIds.productListFilterResetTrigger, "data-filtered": isFiltered ? 'true' : 'false', customElement: children, customElementProps: {
|
|
348
|
+
resetFilters,
|
|
349
|
+
isFiltered,
|
|
350
|
+
}, content: label, children: _jsx("button", { disabled: !isFiltered, children: label }) }));
|
|
351
|
+
} }));
|
|
352
|
+
});
|
|
353
|
+
FilterResetTrigger.displayName = 'ProductList.FilterResetTrigger';
|
|
354
|
+
/**
|
|
355
|
+
* Error component that displays product list errors.
|
|
356
|
+
* Provides error data to custom render functions.
|
|
357
|
+
* Only renders when there's an error.
|
|
358
|
+
*
|
|
359
|
+
* @component
|
|
360
|
+
* @example
|
|
361
|
+
* ```tsx
|
|
362
|
+
* // Default usage
|
|
363
|
+
* <ProductList.Error className="error-message" />
|
|
364
|
+
*
|
|
365
|
+
* // Custom rendering with forwardRef
|
|
366
|
+
* <ProductList.Error asChild>
|
|
367
|
+
* {React.forwardRef(({error, ...props}, ref) => (
|
|
368
|
+
* <div
|
|
369
|
+
* ref={ref}
|
|
370
|
+
* {...props}
|
|
371
|
+
* className="custom-error-container"
|
|
372
|
+
* >
|
|
373
|
+
* Error: {error}
|
|
374
|
+
* </div>
|
|
375
|
+
* ))}
|
|
376
|
+
* </ProductList.Error>
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
export const Error = React.forwardRef((props, ref) => {
|
|
380
|
+
const { asChild, children, className } = props;
|
|
381
|
+
return (_jsx(CoreProductList.Error, { children: ({ error }) => {
|
|
382
|
+
if (!error) {
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productListError, "data-error": error, customElement: children, customElementProps: {
|
|
386
|
+
error,
|
|
387
|
+
}, content: error, children: _jsx("div", { className: "text-status-error text-sm sm:text-base", children: error }) }));
|
|
388
|
+
} }));
|
|
389
|
+
});
|
|
390
|
+
Error.displayName = 'ProductList.Error';
|
|
@@ -135,4 +135,4 @@ export interface FilterProps {
|
|
|
135
135
|
* @see {@link FilterPrimitive.Root} for the primitive filter component
|
|
136
136
|
* @see {@link ResetTrigger} for filter reset functionality
|
|
137
137
|
*/
|
|
138
|
-
export declare const
|
|
138
|
+
export declare const FilterRoot: React.ForwardRefExoticComponent<FilterProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -233,10 +233,10 @@ function AllFilters(props) {
|
|
|
233
233
|
* @see {@link FilterPrimitive.Root} for the primitive filter component
|
|
234
234
|
* @see {@link ResetTrigger} for filter reset functionality
|
|
235
235
|
*/
|
|
236
|
-
export const
|
|
236
|
+
export const FilterRoot = React.forwardRef(({ children, className, asChild }, ref) => {
|
|
237
237
|
const Comp = asChild ? Slot : 'div';
|
|
238
238
|
return (_jsx(AllFilters, { children: ({ searchFilter }) => {
|
|
239
239
|
return (_jsx(FilterPrimitive.Root, { value: searchFilter.filterValue, onChange: searchFilter.updateFilter, filterOptions: searchFilter.filterOptions, children: _jsx(Comp, { className: className, ref: ref, children: children }) }));
|
|
240
240
|
} }));
|
|
241
241
|
});
|
|
242
|
-
|
|
242
|
+
FilterRoot.displayName = 'ProductList.Filter';
|
|
@@ -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 { Commerce } 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.
|
|
@@ -255,7 +255,7 @@ export function Actions(props) {
|
|
|
255
255
|
error,
|
|
256
256
|
};
|
|
257
257
|
if (checkoutService) {
|
|
258
|
-
return (_jsx(
|
|
258
|
+
return (_jsx(Commerce.CheckoutTrigger, { children: ({ createCheckout, isLoading: checkoutLoading, error: checkoutError, }) => props.children({
|
|
259
259
|
...commonProps,
|
|
260
260
|
isLoading: isLoading || checkoutLoading,
|
|
261
261
|
error: error || checkoutError,
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export * as CategoryListCore from './core/CategoryList.js';
|
|
2
|
-
export * as ProductCore from './core/Product.js';
|
|
3
|
-
export * as ProductModifiers from './core/ProductModifiers.js';
|
|
4
|
-
export * as ProductListCore from './core/ProductList.js';
|
|
5
|
-
export * as ProductListPagination from './core/ProductListPagination.js';
|
|
6
|
-
export * as ProductVariantSelector from './core/ProductVariantSelector.js';
|
|
7
|
-
export * as SelectedVariant from './core/SelectedVariant.js';
|
|
8
1
|
export * as Product from './Product.js';
|
|
9
2
|
export * as ProductList from './ProductList.js';
|
|
10
3
|
export * as Option from './Option.js';
|
package/cjs/dist/react/index.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export * as CategoryListCore from './core/CategoryList.js';
|
|
2
|
-
export * as ProductCore from './core/Product.js';
|
|
3
|
-
export * as ProductModifiers from './core/ProductModifiers.js';
|
|
4
|
-
export * as ProductListCore from './core/ProductList.js';
|
|
5
|
-
export * as ProductListPagination from './core/ProductListPagination.js';
|
|
6
|
-
export * as ProductVariantSelector from './core/ProductVariantSelector.js';
|
|
7
|
-
export * as SelectedVariant from './core/SelectedVariant.js';
|
|
8
1
|
export * as Product from './Product.js';
|
|
9
2
|
export * as ProductList from './ProductList.js';
|
|
10
3
|
export * as Option from './Option.js';
|
package/dist/react/Category.d.ts
CHANGED
|
@@ -71,6 +71,22 @@ export interface CategoryRawProps {
|
|
|
71
71
|
/** CSS classes to apply to the default element */
|
|
72
72
|
className?: string;
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Props for CategoryFilter component
|
|
76
|
+
*/
|
|
77
|
+
export interface CategoryFilterProps {
|
|
78
|
+
/** Whether to render as a child component */
|
|
79
|
+
asChild?: boolean;
|
|
80
|
+
/** Custom render function when using asChild */
|
|
81
|
+
children?: AsChildChildren<{
|
|
82
|
+
selectedCategory: Category | null;
|
|
83
|
+
setSelectedCategory: (category: Category | null) => void;
|
|
84
|
+
}>;
|
|
85
|
+
/** CSS classes to apply to the default element */
|
|
86
|
+
className?: string;
|
|
87
|
+
/** Label for the selected category display */
|
|
88
|
+
label?: string;
|
|
89
|
+
}
|
|
74
90
|
/**
|
|
75
91
|
* Root container for a single category item.
|
|
76
92
|
* This component sets up the necessary services for managing category state
|
|
@@ -195,3 +211,32 @@ export declare const ID: React.ForwardRefExoticComponent<CategoryIDProps & React
|
|
|
195
211
|
* ```
|
|
196
212
|
*/
|
|
197
213
|
export declare const Raw: React.ForwardRefExoticComponent<CategoryRawProps & React.RefAttributes<HTMLElement>>;
|
|
214
|
+
/**
|
|
215
|
+
* Category filter component that provides category selection functionality.
|
|
216
|
+
* Provides selected category state and selection controls to custom render functions.
|
|
217
|
+
*
|
|
218
|
+
* @component
|
|
219
|
+
* @example
|
|
220
|
+
* ```tsx
|
|
221
|
+
* // Default usage
|
|
222
|
+
* <CategoryFilter className="category-filter" />
|
|
223
|
+
*
|
|
224
|
+
* // With custom label
|
|
225
|
+
* <CategoryFilter label="Current Category:" />
|
|
226
|
+
*
|
|
227
|
+
* // Custom rendering with forwardRef
|
|
228
|
+
* <CategoryFilter asChild>
|
|
229
|
+
* {React.forwardRef(({selectedCategory, setSelectedCategory, ...props}, ref) => (
|
|
230
|
+
* <div ref={ref} {...props} className="custom-category-filter">
|
|
231
|
+
* {selectedCategory && (
|
|
232
|
+
* <span>Selected: {selectedCategory.name}</span>
|
|
233
|
+
* )}
|
|
234
|
+
* <button onClick={() => setSelectedCategory(null)}>
|
|
235
|
+
* Clear Selection
|
|
236
|
+
* </button>
|
|
237
|
+
* </div>
|
|
238
|
+
* ))}
|
|
239
|
+
* </CategoryFilter>
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
export declare const CategoryFilter: React.ForwardRefExoticComponent<CategoryFilterProps & React.RefAttributes<HTMLElement>>;
|
package/dist/react/Category.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
4
|
-
import
|
|
4
|
+
import * as CoreProductListFilters from './core/ProductListFilters.js';
|
|
5
5
|
const CategoryContext = React.createContext(null);
|
|
6
6
|
function useCategoryContext() {
|
|
7
7
|
const context = React.useContext(CategoryContext);
|
|
@@ -17,6 +17,7 @@ var TestIds;
|
|
|
17
17
|
TestIds["categoryLabel"] = "category-label";
|
|
18
18
|
TestIds["categoryId"] = "category-id";
|
|
19
19
|
TestIds["categoryRaw"] = "category-raw";
|
|
20
|
+
TestIds["categoryFilter"] = "category-filter";
|
|
20
21
|
})(TestIds || (TestIds = {}));
|
|
21
22
|
/**
|
|
22
23
|
* Root container for a single category item.
|
|
@@ -38,7 +39,7 @@ var TestIds;
|
|
|
38
39
|
*/
|
|
39
40
|
export function Root(props) {
|
|
40
41
|
const { category, children } = props;
|
|
41
|
-
return (_jsx(CategoryFilter, { children: ({ selectedCategory, setSelectedCategory }) => {
|
|
42
|
+
return (_jsx(CoreProductListFilters.CategoryFilter, { children: ({ selectedCategory, setSelectedCategory }) => {
|
|
42
43
|
// Determine if this category is selected by comparing with selectedCategory
|
|
43
44
|
const isSelected = selectedCategory?._id === category._id;
|
|
44
45
|
const contextValue = {
|
|
@@ -190,3 +191,42 @@ export const Raw = React.forwardRef((props, ref) => {
|
|
|
190
191
|
const { category, isSelected } = useCategoryContext();
|
|
191
192
|
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className || 'sr-only', "data-testid": TestIds.categoryRaw, "data-selected": isSelected ? 'true' : 'false', customElement: children, customElementProps: { category, isSelected }, children: _jsx("span", { children: JSON.stringify(category) }) }));
|
|
192
193
|
});
|
|
194
|
+
/**
|
|
195
|
+
* Category filter component that provides category selection functionality.
|
|
196
|
+
* Provides selected category state and selection controls to custom render functions.
|
|
197
|
+
*
|
|
198
|
+
* @component
|
|
199
|
+
* @example
|
|
200
|
+
* ```tsx
|
|
201
|
+
* // Default usage
|
|
202
|
+
* <CategoryFilter className="category-filter" />
|
|
203
|
+
*
|
|
204
|
+
* // With custom label
|
|
205
|
+
* <CategoryFilter label="Current Category:" />
|
|
206
|
+
*
|
|
207
|
+
* // Custom rendering with forwardRef
|
|
208
|
+
* <CategoryFilter asChild>
|
|
209
|
+
* {React.forwardRef(({selectedCategory, setSelectedCategory, ...props}, ref) => (
|
|
210
|
+
* <div ref={ref} {...props} className="custom-category-filter">
|
|
211
|
+
* {selectedCategory && (
|
|
212
|
+
* <span>Selected: {selectedCategory.name}</span>
|
|
213
|
+
* )}
|
|
214
|
+
* <button onClick={() => setSelectedCategory(null)}>
|
|
215
|
+
* Clear Selection
|
|
216
|
+
* </button>
|
|
217
|
+
* </div>
|
|
218
|
+
* ))}
|
|
219
|
+
* </CategoryFilter>
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
export const CategoryFilter = React.forwardRef((props, ref) => {
|
|
223
|
+
const { asChild, children, className } = props;
|
|
224
|
+
const label = props.label || 'Selected:';
|
|
225
|
+
return (_jsx(CoreProductListFilters.CategoryFilter, { children: ({ selectedCategory, setSelectedCategory }) => {
|
|
226
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.categoryFilter, "data-selected": selectedCategory ? 'true' : 'false', customElement: children, customElementProps: {
|
|
227
|
+
selectedCategory,
|
|
228
|
+
setSelectedCategory,
|
|
229
|
+
}, children: _jsx("div", { children: selectedCategory && (_jsxs("span", { children: [label, " ", selectedCategory.name] })) }) }));
|
|
230
|
+
} }));
|
|
231
|
+
});
|
|
232
|
+
CategoryFilter.displayName = 'CategoryFilter';
|
|
@@ -4,7 +4,6 @@ import React from 'react';
|
|
|
4
4
|
import type { ProductsListServiceConfig } from '../services/products-list-service.js';
|
|
5
5
|
import { productsV3 } from '@wix/stores';
|
|
6
6
|
import { AsChildChildren } from '@wix/headless-utils/react';
|
|
7
|
-
export { Filter, ResetTrigger as FilterResetTrigger, } from './core/ProductListFilters.js';
|
|
8
7
|
/**
|
|
9
8
|
* Props for the ProductList root component following the documented API
|
|
10
9
|
*/
|
|
@@ -284,3 +283,103 @@ export interface SortProps {
|
|
|
284
283
|
* @see {@link SortPrimitive.Root} for the primitive sort component
|
|
285
284
|
*/
|
|
286
285
|
export declare const Sort: React.ForwardRefExoticComponent<SortProps & React.RefAttributes<HTMLElement>>;
|
|
286
|
+
/**
|
|
287
|
+
* Props for ProductList Filter component
|
|
288
|
+
*/
|
|
289
|
+
export interface FilterProps {
|
|
290
|
+
/** Whether to render as a child component */
|
|
291
|
+
asChild?: boolean;
|
|
292
|
+
/** Child components that will have access to filter functionality */
|
|
293
|
+
children: React.ReactNode;
|
|
294
|
+
/** CSS classes to apply to the default element */
|
|
295
|
+
className?: string;
|
|
296
|
+
}
|
|
297
|
+
export declare const Filter: {
|
|
298
|
+
Root: React.ForwardRefExoticComponent<FilterProps & React.RefAttributes<HTMLElement>>;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Props for ProductList FilterResetTrigger component
|
|
302
|
+
*/
|
|
303
|
+
export interface FilterResetTriggerProps {
|
|
304
|
+
/** Whether to render as a child component */
|
|
305
|
+
asChild?: boolean;
|
|
306
|
+
/** Custom render function when using asChild */
|
|
307
|
+
children?: AsChildChildren<{
|
|
308
|
+
resetFilters: () => void;
|
|
309
|
+
isFiltered: boolean;
|
|
310
|
+
}>;
|
|
311
|
+
/** CSS classes to apply to the default element */
|
|
312
|
+
className?: string;
|
|
313
|
+
/** Label for the button */
|
|
314
|
+
label?: string;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Reset trigger component for clearing all applied filters.
|
|
318
|
+
* Provides reset functionality and filter state to custom render functions.
|
|
319
|
+
* Only renders when filters are applied.
|
|
320
|
+
*
|
|
321
|
+
* @component
|
|
322
|
+
* @example
|
|
323
|
+
* ```tsx
|
|
324
|
+
* // Default usage
|
|
325
|
+
* <ProductList.FilterResetTrigger className="reset-filters-btn" />
|
|
326
|
+
*
|
|
327
|
+
* // With custom label
|
|
328
|
+
* <ProductList.FilterResetTrigger label="Clear Filters" />
|
|
329
|
+
*
|
|
330
|
+
* // Custom rendering with forwardRef
|
|
331
|
+
* <ProductList.FilterResetTrigger asChild>
|
|
332
|
+
* {React.forwardRef(({resetFilters, isFiltered, ...props}, ref) => (
|
|
333
|
+
* <button
|
|
334
|
+
* ref={ref}
|
|
335
|
+
* {...props}
|
|
336
|
+
* onClick={resetFilters}
|
|
337
|
+
* disabled={!isFiltered}
|
|
338
|
+
* className="custom-reset-button disabled:opacity-50"
|
|
339
|
+
* >
|
|
340
|
+
* Reset All Filters
|
|
341
|
+
* </button>
|
|
342
|
+
* ))}
|
|
343
|
+
* </ProductList.FilterResetTrigger>
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
export declare const FilterResetTrigger: React.ForwardRefExoticComponent<FilterResetTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
347
|
+
/**
|
|
348
|
+
* Props for ProductList Error component
|
|
349
|
+
*/
|
|
350
|
+
export interface ErrorProps {
|
|
351
|
+
/** Whether to render as a child component */
|
|
352
|
+
asChild?: boolean;
|
|
353
|
+
/** Custom render function when using asChild */
|
|
354
|
+
children?: AsChildChildren<{
|
|
355
|
+
error: string | null;
|
|
356
|
+
}>;
|
|
357
|
+
/** CSS classes to apply to the default element */
|
|
358
|
+
className?: string;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Error component that displays product list errors.
|
|
362
|
+
* Provides error data to custom render functions.
|
|
363
|
+
* Only renders when there's an error.
|
|
364
|
+
*
|
|
365
|
+
* @component
|
|
366
|
+
* @example
|
|
367
|
+
* ```tsx
|
|
368
|
+
* // Default usage
|
|
369
|
+
* <ProductList.Error className="error-message" />
|
|
370
|
+
*
|
|
371
|
+
* // Custom rendering with forwardRef
|
|
372
|
+
* <ProductList.Error asChild>
|
|
373
|
+
* {React.forwardRef(({error, ...props}, ref) => (
|
|
374
|
+
* <div
|
|
375
|
+
* ref={ref}
|
|
376
|
+
* {...props}
|
|
377
|
+
* className="custom-error-container"
|
|
378
|
+
* >
|
|
379
|
+
* Error: {error}
|
|
380
|
+
* </div>
|
|
381
|
+
* ))}
|
|
382
|
+
* </ProductList.Error>
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
385
|
+
export declare const Error: React.ForwardRefExoticComponent<ErrorProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -6,9 +6,9 @@ import { ProductsListServiceDefinition } from '../services/products-list-service
|
|
|
6
6
|
import * as CoreProductList from './core/ProductList.js';
|
|
7
7
|
import * as CoreProductListPagination from './core/ProductListPagination.js';
|
|
8
8
|
import { ProductListSort as ProductListSortPrimitive } from './core/ProductListSort.js';
|
|
9
|
+
import * as CoreProductListFilters from './core/ProductListFilters.js';
|
|
9
10
|
import * as Product from './Product.js';
|
|
10
11
|
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
11
|
-
export { Filter, ResetTrigger as FilterResetTrigger, } from './core/ProductListFilters.js';
|
|
12
12
|
var TestIds;
|
|
13
13
|
(function (TestIds) {
|
|
14
14
|
TestIds["productListRoot"] = "product-list-root";
|
|
@@ -17,6 +17,9 @@ var TestIds;
|
|
|
17
17
|
TestIds["productListLoadMore"] = "product-list-load-more";
|
|
18
18
|
TestIds["productListTotalsDisplayed"] = "product-list-totals-displayed";
|
|
19
19
|
TestIds["productListSort"] = "product-list-sort";
|
|
20
|
+
TestIds["productListFilter"] = "product-list-filter";
|
|
21
|
+
TestIds["productListFilterResetTrigger"] = "product-list-filter-reset-trigger";
|
|
22
|
+
TestIds["productListError"] = "product-list-error";
|
|
20
23
|
})(TestIds || (TestIds = {}));
|
|
21
24
|
/**
|
|
22
25
|
* Root component that provides the ProductList service context for rendering product lists.
|
|
@@ -266,3 +269,122 @@ export const Sort = React.forwardRef(({ children, className, as, asChild }, ref)
|
|
|
266
269
|
}, sortOptions: sortOptions, as: as, className: className, "data-testid": TestIds.productListSort }));
|
|
267
270
|
} }));
|
|
268
271
|
});
|
|
272
|
+
/**
|
|
273
|
+
* Filter component that provides comprehensive filtering functionality for product lists.
|
|
274
|
+
* This component acts as a provider that integrates with the ProductList service.
|
|
275
|
+
*
|
|
276
|
+
* @component
|
|
277
|
+
* @example
|
|
278
|
+
* ```tsx
|
|
279
|
+
* // Default usage
|
|
280
|
+
* <ProductList.Filter.Root className="filter-container">
|
|
281
|
+
* <Filter.FilterOptions>
|
|
282
|
+
* <Filter.FilterOptionRepeater>
|
|
283
|
+
* <Filter.FilterOption.Label />
|
|
284
|
+
* <Filter.FilterOption.MultiFilter />
|
|
285
|
+
* </Filter.FilterOptionRepeater>
|
|
286
|
+
* </Filter.FilterOptions>
|
|
287
|
+
* </ProductList.Filter.Root>
|
|
288
|
+
*
|
|
289
|
+
* // With custom container using asChild
|
|
290
|
+
* <ProductList.Filter.Root asChild>
|
|
291
|
+
* <aside className="filter-sidebar">
|
|
292
|
+
* <Filter.FilterOptions>
|
|
293
|
+
* <Filter.FilterOptionRepeater>
|
|
294
|
+
* <Filter.FilterOption.Label />
|
|
295
|
+
* <Filter.FilterOption.MultiFilter />
|
|
296
|
+
* </Filter.FilterOptionRepeater>
|
|
297
|
+
* </Filter.FilterOptions>
|
|
298
|
+
* </aside>
|
|
299
|
+
* </ProductList.Filter.Root>
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
const FilterRoot = React.forwardRef((props, ref) => {
|
|
303
|
+
const { asChild, children, className } = props;
|
|
304
|
+
return (_jsx(CoreProductListFilters.FilterRoot, { asChild: asChild, className: className, children: _jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productListFilter, customElement: children, children: _jsx("div", { children: children }) }) }));
|
|
305
|
+
});
|
|
306
|
+
FilterRoot.displayName = 'ProductList.Filter';
|
|
307
|
+
export const Filter = {
|
|
308
|
+
Root: FilterRoot,
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* Reset trigger component for clearing all applied filters.
|
|
312
|
+
* Provides reset functionality and filter state to custom render functions.
|
|
313
|
+
* Only renders when filters are applied.
|
|
314
|
+
*
|
|
315
|
+
* @component
|
|
316
|
+
* @example
|
|
317
|
+
* ```tsx
|
|
318
|
+
* // Default usage
|
|
319
|
+
* <ProductList.FilterResetTrigger className="reset-filters-btn" />
|
|
320
|
+
*
|
|
321
|
+
* // With custom label
|
|
322
|
+
* <ProductList.FilterResetTrigger label="Clear Filters" />
|
|
323
|
+
*
|
|
324
|
+
* // Custom rendering with forwardRef
|
|
325
|
+
* <ProductList.FilterResetTrigger asChild>
|
|
326
|
+
* {React.forwardRef(({resetFilters, isFiltered, ...props}, ref) => (
|
|
327
|
+
* <button
|
|
328
|
+
* ref={ref}
|
|
329
|
+
* {...props}
|
|
330
|
+
* onClick={resetFilters}
|
|
331
|
+
* disabled={!isFiltered}
|
|
332
|
+
* className="custom-reset-button disabled:opacity-50"
|
|
333
|
+
* >
|
|
334
|
+
* Reset All Filters
|
|
335
|
+
* </button>
|
|
336
|
+
* ))}
|
|
337
|
+
* </ProductList.FilterResetTrigger>
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
export const FilterResetTrigger = React.forwardRef((props, ref) => {
|
|
341
|
+
const { asChild, children, className } = props;
|
|
342
|
+
const label = props.label || 'Reset All Filters';
|
|
343
|
+
return (_jsx(CoreProductListFilters.ResetTrigger, { children: ({ resetFilters, isFiltered }) => {
|
|
344
|
+
if (!isFiltered) {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onClick: resetFilters, disabled: !isFiltered, "data-testid": TestIds.productListFilterResetTrigger, "data-filtered": isFiltered ? 'true' : 'false', customElement: children, customElementProps: {
|
|
348
|
+
resetFilters,
|
|
349
|
+
isFiltered,
|
|
350
|
+
}, content: label, children: _jsx("button", { disabled: !isFiltered, children: label }) }));
|
|
351
|
+
} }));
|
|
352
|
+
});
|
|
353
|
+
FilterResetTrigger.displayName = 'ProductList.FilterResetTrigger';
|
|
354
|
+
/**
|
|
355
|
+
* Error component that displays product list errors.
|
|
356
|
+
* Provides error data to custom render functions.
|
|
357
|
+
* Only renders when there's an error.
|
|
358
|
+
*
|
|
359
|
+
* @component
|
|
360
|
+
* @example
|
|
361
|
+
* ```tsx
|
|
362
|
+
* // Default usage
|
|
363
|
+
* <ProductList.Error className="error-message" />
|
|
364
|
+
*
|
|
365
|
+
* // Custom rendering with forwardRef
|
|
366
|
+
* <ProductList.Error asChild>
|
|
367
|
+
* {React.forwardRef(({error, ...props}, ref) => (
|
|
368
|
+
* <div
|
|
369
|
+
* ref={ref}
|
|
370
|
+
* {...props}
|
|
371
|
+
* className="custom-error-container"
|
|
372
|
+
* >
|
|
373
|
+
* Error: {error}
|
|
374
|
+
* </div>
|
|
375
|
+
* ))}
|
|
376
|
+
* </ProductList.Error>
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
export const Error = React.forwardRef((props, ref) => {
|
|
380
|
+
const { asChild, children, className } = props;
|
|
381
|
+
return (_jsx(CoreProductList.Error, { children: ({ error }) => {
|
|
382
|
+
if (!error) {
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productListError, "data-error": error, customElement: children, customElementProps: {
|
|
386
|
+
error,
|
|
387
|
+
}, content: error, children: _jsx("div", { className: "text-status-error text-sm sm:text-base", children: error }) }));
|
|
388
|
+
} }));
|
|
389
|
+
});
|
|
390
|
+
Error.displayName = 'ProductList.Error';
|
|
@@ -135,4 +135,4 @@ export interface FilterProps {
|
|
|
135
135
|
* @see {@link FilterPrimitive.Root} for the primitive filter component
|
|
136
136
|
* @see {@link ResetTrigger} for filter reset functionality
|
|
137
137
|
*/
|
|
138
|
-
export declare const
|
|
138
|
+
export declare const FilterRoot: React.ForwardRefExoticComponent<FilterProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -233,10 +233,10 @@ function AllFilters(props) {
|
|
|
233
233
|
* @see {@link FilterPrimitive.Root} for the primitive filter component
|
|
234
234
|
* @see {@link ResetTrigger} for filter reset functionality
|
|
235
235
|
*/
|
|
236
|
-
export const
|
|
236
|
+
export const FilterRoot = React.forwardRef(({ children, className, asChild }, ref) => {
|
|
237
237
|
const Comp = asChild ? Slot : 'div';
|
|
238
238
|
return (_jsx(AllFilters, { children: ({ searchFilter }) => {
|
|
239
239
|
return (_jsx(FilterPrimitive.Root, { value: searchFilter.filterValue, onChange: searchFilter.updateFilter, filterOptions: searchFilter.filterOptions, children: _jsx(Comp, { className: className, ref: ref, children: children }) }));
|
|
240
240
|
} }));
|
|
241
241
|
});
|
|
242
|
-
|
|
242
|
+
FilterRoot.displayName = 'ProductList.Filter';
|
|
@@ -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 { Commerce } 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.
|
|
@@ -255,7 +255,7 @@ export function Actions(props) {
|
|
|
255
255
|
error,
|
|
256
256
|
};
|
|
257
257
|
if (checkoutService) {
|
|
258
|
-
return (_jsx(
|
|
258
|
+
return (_jsx(Commerce.CheckoutTrigger, { children: ({ createCheckout, isLoading: checkoutLoading, error: checkoutError, }) => props.children({
|
|
259
259
|
...commonProps,
|
|
260
260
|
isLoading: isLoading || checkoutLoading,
|
|
261
261
|
error: error || checkoutError,
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export * as CategoryListCore from './core/CategoryList.js';
|
|
2
|
-
export * as ProductCore from './core/Product.js';
|
|
3
|
-
export * as ProductModifiers from './core/ProductModifiers.js';
|
|
4
|
-
export * as ProductListCore from './core/ProductList.js';
|
|
5
|
-
export * as ProductListPagination from './core/ProductListPagination.js';
|
|
6
|
-
export * as ProductVariantSelector from './core/ProductVariantSelector.js';
|
|
7
|
-
export * as SelectedVariant from './core/SelectedVariant.js';
|
|
8
1
|
export * as Product from './Product.js';
|
|
9
2
|
export * as ProductList from './ProductList.js';
|
|
10
3
|
export * as Option from './Option.js';
|
package/dist/react/index.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export * as CategoryListCore from './core/CategoryList.js';
|
|
2
|
-
export * as ProductCore from './core/Product.js';
|
|
3
|
-
export * as ProductModifiers from './core/ProductModifiers.js';
|
|
4
|
-
export * as ProductListCore from './core/ProductList.js';
|
|
5
|
-
export * as ProductListPagination from './core/ProductListPagination.js';
|
|
6
|
-
export * as ProductVariantSelector from './core/ProductVariantSelector.js';
|
|
7
|
-
export * as SelectedVariant from './core/SelectedVariant.js';
|
|
8
1
|
export * as Product from './Product.js';
|
|
9
2
|
export * as ProductList from './ProductList.js';
|
|
10
3
|
export * as Option from './Option.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/headless-stores",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.83",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prebuild": "cd ../media && yarn build && cd ../ecom && yarn build",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@wix/ecom": "^1.0.1278",
|
|
64
64
|
"@wix/essentials": "^0.1.24",
|
|
65
65
|
"@wix/headless-components": "0.0.12",
|
|
66
|
-
"@wix/headless-ecom": "0.0.
|
|
66
|
+
"@wix/headless-ecom": "0.0.26",
|
|
67
67
|
"@wix/headless-media": "0.0.11",
|
|
68
68
|
"@wix/headless-utils": "0.0.3",
|
|
69
69
|
"@wix/redirects": "^1.0.83",
|