@wix/headless-stores 0.0.80 → 0.0.82
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/Product.d.ts +14 -0
- package/cjs/dist/react/Product.js +11 -0
- package/cjs/dist/react/ProductList.d.ts +61 -1
- package/cjs/dist/react/ProductList.js +85 -1
- package/cjs/dist/react/core/ProductListFilters.d.ts +1 -1
- package/cjs/dist/react/core/ProductListFilters.js +2 -2
- package/dist/react/Category.d.ts +45 -0
- package/dist/react/Category.js +43 -3
- package/dist/react/Product.d.ts +14 -0
- package/dist/react/Product.js +11 -0
- package/dist/react/ProductList.d.ts +61 -1
- package/dist/react/ProductList.js +85 -1
- package/dist/react/core/ProductListFilters.d.ts +1 -1
- package/dist/react/core/ProductListFilters.js +2 -2
- package/package.json +1 -1
|
@@ -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';
|
|
@@ -833,6 +833,20 @@ export interface ProductQuantityRawSubComponentProps {
|
|
|
833
833
|
* ```
|
|
834
834
|
*/
|
|
835
835
|
export declare const ProductQuantityRaw: React.ForwardRefExoticComponent<ProductQuantityRawSubComponentProps & React.RefAttributes<HTMLElement>>;
|
|
836
|
+
export interface ProductVariantSelectorResetProps {
|
|
837
|
+
/** Whether to render as a child component */
|
|
838
|
+
asChild?: boolean;
|
|
839
|
+
/** Custom render function when using asChild */
|
|
840
|
+
children?: AsChildChildren<{
|
|
841
|
+
reset: () => void;
|
|
842
|
+
hasSelections: boolean;
|
|
843
|
+
}>;
|
|
844
|
+
/** CSS classes to apply to the default element */
|
|
845
|
+
className?: string;
|
|
846
|
+
/** Label for the reset button */
|
|
847
|
+
label?: string;
|
|
848
|
+
}
|
|
849
|
+
export declare const ProductVariantSelectorReset: React.ForwardRefExoticComponent<ProductVariantSelectorResetProps & React.RefAttributes<HTMLButtonElement>>;
|
|
836
850
|
/**
|
|
837
851
|
* Add to cart action button component following the documented API.
|
|
838
852
|
* Automatically integrates with the selected variant and handles loading states.
|
|
@@ -46,6 +46,7 @@ var TestIds;
|
|
|
46
46
|
TestIds["productStock"] = "product-stock";
|
|
47
47
|
TestIds["productVariants"] = "product-variants";
|
|
48
48
|
TestIds["productVariantOptions"] = "product-variant-options";
|
|
49
|
+
TestIds["productVariantSelectorReset"] = "product-variant-selector-reset";
|
|
49
50
|
TestIds["productVariantOption"] = "product-variant-option";
|
|
50
51
|
TestIds["productVariant"] = "product-variant";
|
|
51
52
|
TestIds["productVariantSku"] = "product-variant-sku";
|
|
@@ -859,6 +860,16 @@ export const ProductQuantityRaw = React.forwardRef((props, ref) => {
|
|
|
859
860
|
return (_jsx(AsChildSlot, { ref: ref, customElement: children, asChild: asChild, className: className, "data-testid": TestIds.productQuantityRaw, customElementProps: renderProps }));
|
|
860
861
|
} }));
|
|
861
862
|
});
|
|
863
|
+
export const ProductVariantSelectorReset = React.forwardRef((props, ref) => {
|
|
864
|
+
const { asChild, children, className } = props;
|
|
865
|
+
return (_jsx(ProductVariantSelector.Reset, { children: (renderProps) => {
|
|
866
|
+
if (!renderProps.hasSelections) {
|
|
867
|
+
return null;
|
|
868
|
+
}
|
|
869
|
+
const label = props.label || 'Reset Selections';
|
|
870
|
+
return (_jsx(AsChildSlot, { ref: ref, customElement: children, asChild: asChild, className: className, "data-testid": TestIds.productVariantSelectorReset, customElementProps: renderProps, children: _jsx("button", { onClick: renderProps.reset, children: label }) }));
|
|
871
|
+
} }));
|
|
872
|
+
});
|
|
862
873
|
/**
|
|
863
874
|
* Add to cart action button component following the documented API.
|
|
864
875
|
* Automatically integrates with the selected variant and handles loading states.
|
|
@@ -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,64 @@ 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>>;
|
|
@@ -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,8 @@ 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";
|
|
20
22
|
})(TestIds || (TestIds = {}));
|
|
21
23
|
/**
|
|
22
24
|
* Root component that provides the ProductList service context for rendering product lists.
|
|
@@ -266,3 +268,85 @@ export const Sort = React.forwardRef(({ children, className, as, asChild }, ref)
|
|
|
266
268
|
}, sortOptions: sortOptions, as: as, className: className, "data-testid": TestIds.productListSort }));
|
|
267
269
|
} }));
|
|
268
270
|
});
|
|
271
|
+
/**
|
|
272
|
+
* Filter component that provides comprehensive filtering functionality for product lists.
|
|
273
|
+
* This component acts as a provider that integrates with the ProductList service.
|
|
274
|
+
*
|
|
275
|
+
* @component
|
|
276
|
+
* @example
|
|
277
|
+
* ```tsx
|
|
278
|
+
* // Default usage
|
|
279
|
+
* <ProductList.Filter.Root className="filter-container">
|
|
280
|
+
* <Filter.FilterOptions>
|
|
281
|
+
* <Filter.FilterOptionRepeater>
|
|
282
|
+
* <Filter.FilterOption.Label />
|
|
283
|
+
* <Filter.FilterOption.MultiFilter />
|
|
284
|
+
* </Filter.FilterOptionRepeater>
|
|
285
|
+
* </Filter.FilterOptions>
|
|
286
|
+
* </ProductList.Filter.Root>
|
|
287
|
+
*
|
|
288
|
+
* // With custom container using asChild
|
|
289
|
+
* <ProductList.Filter.Root asChild>
|
|
290
|
+
* <aside className="filter-sidebar">
|
|
291
|
+
* <Filter.FilterOptions>
|
|
292
|
+
* <Filter.FilterOptionRepeater>
|
|
293
|
+
* <Filter.FilterOption.Label />
|
|
294
|
+
* <Filter.FilterOption.MultiFilter />
|
|
295
|
+
* </Filter.FilterOptionRepeater>
|
|
296
|
+
* </Filter.FilterOptions>
|
|
297
|
+
* </aside>
|
|
298
|
+
* </ProductList.Filter.Root>
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
const FilterRoot = React.forwardRef((props, ref) => {
|
|
302
|
+
const { asChild, children, className } = props;
|
|
303
|
+
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 }) }) }));
|
|
304
|
+
});
|
|
305
|
+
FilterRoot.displayName = 'ProductList.Filter';
|
|
306
|
+
export const Filter = {
|
|
307
|
+
Root: FilterRoot,
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* Reset trigger component for clearing all applied filters.
|
|
311
|
+
* Provides reset functionality and filter state to custom render functions.
|
|
312
|
+
* Only renders when filters are applied.
|
|
313
|
+
*
|
|
314
|
+
* @component
|
|
315
|
+
* @example
|
|
316
|
+
* ```tsx
|
|
317
|
+
* // Default usage
|
|
318
|
+
* <ProductList.FilterResetTrigger className="reset-filters-btn" />
|
|
319
|
+
*
|
|
320
|
+
* // With custom label
|
|
321
|
+
* <ProductList.FilterResetTrigger label="Clear Filters" />
|
|
322
|
+
*
|
|
323
|
+
* // Custom rendering with forwardRef
|
|
324
|
+
* <ProductList.FilterResetTrigger asChild>
|
|
325
|
+
* {React.forwardRef(({resetFilters, isFiltered, ...props}, ref) => (
|
|
326
|
+
* <button
|
|
327
|
+
* ref={ref}
|
|
328
|
+
* {...props}
|
|
329
|
+
* onClick={resetFilters}
|
|
330
|
+
* disabled={!isFiltered}
|
|
331
|
+
* className="custom-reset-button disabled:opacity-50"
|
|
332
|
+
* >
|
|
333
|
+
* Reset All Filters
|
|
334
|
+
* </button>
|
|
335
|
+
* ))}
|
|
336
|
+
* </ProductList.FilterResetTrigger>
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
export const FilterResetTrigger = React.forwardRef((props, ref) => {
|
|
340
|
+
const { asChild, children, className } = props;
|
|
341
|
+
const label = props.label || 'Reset All Filters';
|
|
342
|
+
return (_jsx(CoreProductListFilters.ResetTrigger, { children: ({ resetFilters, isFiltered }) => {
|
|
343
|
+
if (!isFiltered) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
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: {
|
|
347
|
+
resetFilters,
|
|
348
|
+
isFiltered,
|
|
349
|
+
}, content: label, children: _jsx("button", { disabled: !isFiltered, children: label }) }));
|
|
350
|
+
} }));
|
|
351
|
+
});
|
|
352
|
+
FilterResetTrigger.displayName = 'ProductList.FilterResetTrigger';
|
|
@@ -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';
|
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';
|
package/dist/react/Product.d.ts
CHANGED
|
@@ -833,6 +833,20 @@ export interface ProductQuantityRawSubComponentProps {
|
|
|
833
833
|
* ```
|
|
834
834
|
*/
|
|
835
835
|
export declare const ProductQuantityRaw: React.ForwardRefExoticComponent<ProductQuantityRawSubComponentProps & React.RefAttributes<HTMLElement>>;
|
|
836
|
+
export interface ProductVariantSelectorResetProps {
|
|
837
|
+
/** Whether to render as a child component */
|
|
838
|
+
asChild?: boolean;
|
|
839
|
+
/** Custom render function when using asChild */
|
|
840
|
+
children?: AsChildChildren<{
|
|
841
|
+
reset: () => void;
|
|
842
|
+
hasSelections: boolean;
|
|
843
|
+
}>;
|
|
844
|
+
/** CSS classes to apply to the default element */
|
|
845
|
+
className?: string;
|
|
846
|
+
/** Label for the reset button */
|
|
847
|
+
label?: string;
|
|
848
|
+
}
|
|
849
|
+
export declare const ProductVariantSelectorReset: React.ForwardRefExoticComponent<ProductVariantSelectorResetProps & React.RefAttributes<HTMLButtonElement>>;
|
|
836
850
|
/**
|
|
837
851
|
* Add to cart action button component following the documented API.
|
|
838
852
|
* Automatically integrates with the selected variant and handles loading states.
|
package/dist/react/Product.js
CHANGED
|
@@ -46,6 +46,7 @@ var TestIds;
|
|
|
46
46
|
TestIds["productStock"] = "product-stock";
|
|
47
47
|
TestIds["productVariants"] = "product-variants";
|
|
48
48
|
TestIds["productVariantOptions"] = "product-variant-options";
|
|
49
|
+
TestIds["productVariantSelectorReset"] = "product-variant-selector-reset";
|
|
49
50
|
TestIds["productVariantOption"] = "product-variant-option";
|
|
50
51
|
TestIds["productVariant"] = "product-variant";
|
|
51
52
|
TestIds["productVariantSku"] = "product-variant-sku";
|
|
@@ -859,6 +860,16 @@ export const ProductQuantityRaw = React.forwardRef((props, ref) => {
|
|
|
859
860
|
return (_jsx(AsChildSlot, { ref: ref, customElement: children, asChild: asChild, className: className, "data-testid": TestIds.productQuantityRaw, customElementProps: renderProps }));
|
|
860
861
|
} }));
|
|
861
862
|
});
|
|
863
|
+
export const ProductVariantSelectorReset = React.forwardRef((props, ref) => {
|
|
864
|
+
const { asChild, children, className } = props;
|
|
865
|
+
return (_jsx(ProductVariantSelector.Reset, { children: (renderProps) => {
|
|
866
|
+
if (!renderProps.hasSelections) {
|
|
867
|
+
return null;
|
|
868
|
+
}
|
|
869
|
+
const label = props.label || 'Reset Selections';
|
|
870
|
+
return (_jsx(AsChildSlot, { ref: ref, customElement: children, asChild: asChild, className: className, "data-testid": TestIds.productVariantSelectorReset, customElementProps: renderProps, children: _jsx("button", { onClick: renderProps.reset, children: label }) }));
|
|
871
|
+
} }));
|
|
872
|
+
});
|
|
862
873
|
/**
|
|
863
874
|
* Add to cart action button component following the documented API.
|
|
864
875
|
* Automatically integrates with the selected variant and handles loading states.
|
|
@@ -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,64 @@ 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>>;
|
|
@@ -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,8 @@ 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";
|
|
20
22
|
})(TestIds || (TestIds = {}));
|
|
21
23
|
/**
|
|
22
24
|
* Root component that provides the ProductList service context for rendering product lists.
|
|
@@ -266,3 +268,85 @@ export const Sort = React.forwardRef(({ children, className, as, asChild }, ref)
|
|
|
266
268
|
}, sortOptions: sortOptions, as: as, className: className, "data-testid": TestIds.productListSort }));
|
|
267
269
|
} }));
|
|
268
270
|
});
|
|
271
|
+
/**
|
|
272
|
+
* Filter component that provides comprehensive filtering functionality for product lists.
|
|
273
|
+
* This component acts as a provider that integrates with the ProductList service.
|
|
274
|
+
*
|
|
275
|
+
* @component
|
|
276
|
+
* @example
|
|
277
|
+
* ```tsx
|
|
278
|
+
* // Default usage
|
|
279
|
+
* <ProductList.Filter.Root className="filter-container">
|
|
280
|
+
* <Filter.FilterOptions>
|
|
281
|
+
* <Filter.FilterOptionRepeater>
|
|
282
|
+
* <Filter.FilterOption.Label />
|
|
283
|
+
* <Filter.FilterOption.MultiFilter />
|
|
284
|
+
* </Filter.FilterOptionRepeater>
|
|
285
|
+
* </Filter.FilterOptions>
|
|
286
|
+
* </ProductList.Filter.Root>
|
|
287
|
+
*
|
|
288
|
+
* // With custom container using asChild
|
|
289
|
+
* <ProductList.Filter.Root asChild>
|
|
290
|
+
* <aside className="filter-sidebar">
|
|
291
|
+
* <Filter.FilterOptions>
|
|
292
|
+
* <Filter.FilterOptionRepeater>
|
|
293
|
+
* <Filter.FilterOption.Label />
|
|
294
|
+
* <Filter.FilterOption.MultiFilter />
|
|
295
|
+
* </Filter.FilterOptionRepeater>
|
|
296
|
+
* </Filter.FilterOptions>
|
|
297
|
+
* </aside>
|
|
298
|
+
* </ProductList.Filter.Root>
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
const FilterRoot = React.forwardRef((props, ref) => {
|
|
302
|
+
const { asChild, children, className } = props;
|
|
303
|
+
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 }) }) }));
|
|
304
|
+
});
|
|
305
|
+
FilterRoot.displayName = 'ProductList.Filter';
|
|
306
|
+
export const Filter = {
|
|
307
|
+
Root: FilterRoot,
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* Reset trigger component for clearing all applied filters.
|
|
311
|
+
* Provides reset functionality and filter state to custom render functions.
|
|
312
|
+
* Only renders when filters are applied.
|
|
313
|
+
*
|
|
314
|
+
* @component
|
|
315
|
+
* @example
|
|
316
|
+
* ```tsx
|
|
317
|
+
* // Default usage
|
|
318
|
+
* <ProductList.FilterResetTrigger className="reset-filters-btn" />
|
|
319
|
+
*
|
|
320
|
+
* // With custom label
|
|
321
|
+
* <ProductList.FilterResetTrigger label="Clear Filters" />
|
|
322
|
+
*
|
|
323
|
+
* // Custom rendering with forwardRef
|
|
324
|
+
* <ProductList.FilterResetTrigger asChild>
|
|
325
|
+
* {React.forwardRef(({resetFilters, isFiltered, ...props}, ref) => (
|
|
326
|
+
* <button
|
|
327
|
+
* ref={ref}
|
|
328
|
+
* {...props}
|
|
329
|
+
* onClick={resetFilters}
|
|
330
|
+
* disabled={!isFiltered}
|
|
331
|
+
* className="custom-reset-button disabled:opacity-50"
|
|
332
|
+
* >
|
|
333
|
+
* Reset All Filters
|
|
334
|
+
* </button>
|
|
335
|
+
* ))}
|
|
336
|
+
* </ProductList.FilterResetTrigger>
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
export const FilterResetTrigger = React.forwardRef((props, ref) => {
|
|
340
|
+
const { asChild, children, className } = props;
|
|
341
|
+
const label = props.label || 'Reset All Filters';
|
|
342
|
+
return (_jsx(CoreProductListFilters.ResetTrigger, { children: ({ resetFilters, isFiltered }) => {
|
|
343
|
+
if (!isFiltered) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
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: {
|
|
347
|
+
resetFilters,
|
|
348
|
+
isFiltered,
|
|
349
|
+
}, content: label, children: _jsx("button", { disabled: !isFiltered, children: label }) }));
|
|
350
|
+
} }));
|
|
351
|
+
});
|
|
352
|
+
FilterResetTrigger.displayName = 'ProductList.FilterResetTrigger';
|
|
@@ -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';
|