@wix/headless-stores 0.0.77 → 0.0.79

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.
Files changed (43) hide show
  1. package/cjs/dist/react/Category.d.ts +4 -8
  2. package/cjs/dist/react/Category.js +35 -29
  3. package/cjs/dist/react/CategoryList.d.ts +3 -2
  4. package/cjs/dist/react/CategoryList.js +4 -3
  5. package/cjs/dist/react/Product.d.ts +86 -0
  6. package/cjs/dist/react/Product.js +83 -2
  7. package/cjs/dist/react/ProductList.d.ts +1 -1
  8. package/cjs/dist/react/ProductList.js +1 -1
  9. package/cjs/dist/react/core/CategoryList.d.ts +11 -5
  10. package/cjs/dist/react/core/CategoryList.js +9 -4
  11. package/cjs/dist/react/core/ProductListFilters.d.ts +1 -1
  12. package/cjs/dist/react/index.d.ts +0 -1
  13. package/cjs/dist/react/index.js +0 -1
  14. package/cjs/dist/services/categories-list-service.d.ts +2 -1
  15. package/cjs/dist/services/index.d.ts +0 -1
  16. package/cjs/dist/services/index.js +0 -1
  17. package/cjs/dist/services/products-list-service.d.ts +2 -1
  18. package/dist/react/Category.d.ts +4 -8
  19. package/dist/react/Category.js +35 -29
  20. package/dist/react/CategoryList.d.ts +3 -2
  21. package/dist/react/CategoryList.js +4 -3
  22. package/dist/react/Product.d.ts +86 -0
  23. package/dist/react/Product.js +83 -2
  24. package/dist/react/ProductList.d.ts +1 -1
  25. package/dist/react/ProductList.js +1 -1
  26. package/dist/react/core/CategoryList.d.ts +11 -5
  27. package/dist/react/core/CategoryList.js +9 -4
  28. package/dist/react/core/ProductListFilters.d.ts +1 -1
  29. package/dist/react/index.d.ts +0 -1
  30. package/dist/react/index.js +0 -1
  31. package/dist/services/categories-list-service.d.ts +2 -1
  32. package/dist/services/index.d.ts +0 -1
  33. package/dist/services/index.js +0 -1
  34. package/dist/services/products-list-service.d.ts +2 -1
  35. package/package.json +1 -1
  36. package/cjs/dist/react/core/Category.d.ts +0 -98
  37. package/cjs/dist/react/core/Category.js +0 -81
  38. package/cjs/dist/services/category-service.d.ts +0 -161
  39. package/cjs/dist/services/category-service.js +0 -149
  40. package/dist/react/core/Category.d.ts +0 -98
  41. package/dist/react/core/Category.js +0 -81
  42. package/dist/services/category-service.d.ts +0 -161
  43. package/dist/services/category-service.js +0 -149
@@ -1,9 +1,15 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React from 'react';
3
- import * as CoreCategory from './core/Category.js';
4
- import { CategoryServiceDefinition, } from '../services/category-service.js';
5
- import { useService } from '@wix/services-manager-react';
6
3
  import { AsChildSlot } from '@wix/headless-utils/react';
4
+ import { CategoryFilter, } from './core/ProductListFilters.js';
5
+ const CategoryContext = React.createContext(null);
6
+ function useCategoryContext() {
7
+ const context = React.useContext(CategoryContext);
8
+ if (!context) {
9
+ throw new Error('useCategoryContext must be used within a Category.Root component');
10
+ }
11
+ return context;
12
+ }
7
13
  var TestIds;
8
14
  (function (TestIds) {
9
15
  TestIds["categoryItem"] = "category-item";
@@ -31,15 +37,18 @@ var TestIds;
31
37
  * ```
32
38
  */
33
39
  export function Root(props) {
34
- const { category, categoryServiceConfig, isSelected, children } = props;
35
- if (!category && !categoryServiceConfig) {
36
- throw new Error('Category.Root: category or categoryServiceConfig is required');
37
- }
38
- const serviceConfig = categoryServiceConfig || {
39
- category: category,
40
- isSelected,
41
- };
42
- return (_jsx(CoreCategory.Root, { categoryServiceConfig: serviceConfig, children: children }));
40
+ const { category, children } = props;
41
+ return (_jsx(CategoryFilter, { children: ({ selectedCategory, setSelectedCategory }) => {
42
+ // Determine if this category is selected by comparing with selectedCategory
43
+ const isSelected = selectedCategory?._id === category._id;
44
+ const contextValue = {
45
+ category,
46
+ isSelected,
47
+ selectedCategory,
48
+ setSelectedCategory,
49
+ };
50
+ return (_jsx(CategoryContext.Provider, { value: contextValue, children: children }));
51
+ } }));
43
52
  }
44
53
  /**
45
54
  * Interactive element for selecting or triggering category actions.
@@ -72,11 +81,17 @@ export function Root(props) {
72
81
  */
73
82
  export const Trigger = React.forwardRef((props, ref) => {
74
83
  const { asChild, children, onSelect, className } = props;
75
- const categoryService = useService(CategoryServiceDefinition);
76
- const category = categoryService.category.get();
77
- const isSelected = categoryService.isSelected.get();
78
- const setIsSelected = (isSelected) => categoryService.isSelected.set(isSelected);
84
+ const { category, isSelected, setSelectedCategory } = useCategoryContext();
79
85
  const handleSelect = () => {
86
+ // Use CategoryFilter's setSelectedCategory function
87
+ if (isSelected) {
88
+ // Deselect by passing null
89
+ setSelectedCategory(null);
90
+ }
91
+ else {
92
+ // Select this category
93
+ setSelectedCategory(category);
94
+ }
80
95
  if (onSelect) {
81
96
  onSelect(category);
82
97
  }
@@ -85,7 +100,6 @@ export const Trigger = React.forwardRef((props, ref) => {
85
100
  category,
86
101
  isSelected,
87
102
  onSelect: handleSelect,
88
- setIsSelected,
89
103
  }, content: category.name, children: _jsx("button", { children: category.name }) }));
90
104
  });
91
105
  /**
@@ -115,12 +129,8 @@ export const Trigger = React.forwardRef((props, ref) => {
115
129
  */
116
130
  export const Label = React.forwardRef((props, ref) => {
117
131
  const { asChild, children, className } = props;
118
- const categoryService = useService(CategoryServiceDefinition);
119
- const category = categoryService.category.get();
120
- const isSelected = categoryService.isSelected.get();
121
- return (_jsx(CoreCategory.Name, { children: ({ name }) => {
122
- return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.categoryLabel, "data-selected": isSelected ? 'true' : 'false', customElement: children, customElementProps: { name, category }, content: name, children: _jsx("span", { children: name }) }));
123
- } }));
132
+ const { category, isSelected } = useCategoryContext();
133
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.categoryLabel, "data-selected": isSelected ? 'true' : 'false', customElement: children, customElementProps: { name: category.name, category }, content: category.name, children: _jsx("span", { children: category.name }) }));
124
134
  });
125
135
  /**
126
136
  * Provides access to the category ID for advanced use cases.
@@ -149,9 +159,7 @@ export const Label = React.forwardRef((props, ref) => {
149
159
  */
150
160
  export const ID = React.forwardRef((props, ref) => {
151
161
  const { asChild, children, className } = props;
152
- const categoryService = useService(CategoryServiceDefinition);
153
- const category = categoryService.category.get();
154
- const isSelected = categoryService.isSelected.get();
162
+ const { category, isSelected } = useCategoryContext();
155
163
  const id = category._id || '';
156
164
  return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className || 'sr-only', "data-testid": TestIds.categoryId, "data-selected": isSelected ? 'true' : 'false', customElement: children, customElementProps: { id, category }, content: id, children: _jsx("span", { children: id }) }));
157
165
  });
@@ -179,8 +187,6 @@ export const ID = React.forwardRef((props, ref) => {
179
187
  */
180
188
  export const Raw = React.forwardRef((props, ref) => {
181
189
  const { asChild, children, className } = props;
182
- const categoryService = useService(CategoryServiceDefinition);
183
- const category = categoryService.category.get();
184
- const isSelected = categoryService.isSelected.get();
190
+ const { category, isSelected } = useCategoryContext();
185
191
  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) }) }));
186
192
  });
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { type Category as CategoryType } from '../services/category-service.js';
2
+ import { type Category as CategoryType } from './Category.js';
3
3
  import { type CategoriesListServiceConfig } from '../services/categories-list-service.js';
4
4
  /**
5
5
  * Props for CategoryList.Root component
@@ -41,6 +41,7 @@ export interface CategoryListCategoryRepeaterProps {
41
41
  /**
42
42
  * Root container that provides category list context to all child components.
43
43
  * This component sets up the necessary services for managing categories list state.
44
+ * Automatically connects to ProductList filtering when available.
44
45
  *
45
46
  * @order 1
46
47
  * @component
@@ -100,4 +101,4 @@ export declare const Loading: React.ForwardRefExoticComponent<CategoryListLoadin
100
101
  * }
101
102
  * ```
102
103
  */
103
- export declare const CategoryRepeater: React.ForwardRefExoticComponent<CategoryListCategoryRepeaterProps & React.RefAttributes<HTMLDivElement>>;
104
+ export declare function CategoryRepeater(props: CategoryListCategoryRepeaterProps): import("react/jsx-runtime").JSX.Element;
@@ -11,6 +11,7 @@ var TestIds;
11
11
  /**
12
12
  * Root container that provides category list context to all child components.
13
13
  * This component sets up the necessary services for managing categories list state.
14
+ * Automatically connects to ProductList filtering when available.
14
15
  *
15
16
  * @order 1
16
17
  * @component
@@ -78,11 +79,11 @@ export const Loading = React.forwardRef((props, ref) => {
78
79
  * }
79
80
  * ```
80
81
  */
81
- export const CategoryRepeater = React.forwardRef((props) => {
82
+ export function CategoryRepeater(props) {
82
83
  // const { children, asChild = false, className } = props;
83
84
  const { children } = props;
84
85
  // Note: maxDepth is not implemented yet as it depends on category hierarchy structure
85
86
  return (_jsx(CoreCategoryList.ItemContent, { children: ({ category }) => {
86
- return (_jsx(Category.Root, { categoryServiceConfig: { category }, children: children }, category._id));
87
+ return (_jsx(Category.Root, { category: category, children: children }, category._id));
87
88
  } }));
88
- });
89
+ }
@@ -860,6 +860,92 @@ export declare const Action: {
860
860
  /** Pre-order action button */
861
861
  readonly PreOrder: React.ForwardRefExoticComponent<ProductActionProps & React.RefAttributes<HTMLButtonElement>>;
862
862
  };
863
+ /**
864
+ * Props for ProductVariantSKU component
865
+ */
866
+ export interface ProductVariantSKUProps {
867
+ /** Whether to render as a child component */
868
+ asChild?: boolean;
869
+ /** Custom render function when using asChild */
870
+ children?: AsChildChildren<{
871
+ sku: string | null;
872
+ }>;
873
+ /** CSS classes to apply to the default element */
874
+ className?: string;
875
+ }
876
+ /**
877
+ * Displays the selected variant SKU with customizable rendering following the documented API.
878
+ *
879
+ * @component
880
+ * @example
881
+ * ```tsx
882
+ * // Default usage
883
+ * <Product.ProductVariant.SKU className="text-content-secondary" />
884
+ *
885
+ * // asChild with primitive
886
+ * <Product.ProductVariant.SKU asChild>
887
+ * <span className="sku-value" />
888
+ * </Product.ProductVariant.SKU>
889
+ *
890
+ * // asChild with react component
891
+ * <Product.ProductVariant.SKU asChild>
892
+ * {React.forwardRef(({sku, ...props}, ref) => (
893
+ * <span ref={ref} {...props}>
894
+ * {sku}
895
+ * </span>
896
+ * ))}
897
+ * </Product.ProductVariant.SKU>
898
+ * ```
899
+ */
900
+ export declare const ProductVariantSKU: React.ForwardRefExoticComponent<ProductVariantSKUProps & React.RefAttributes<HTMLElement>>;
901
+ /**
902
+ * Props for ProductVariantWeight component
903
+ */
904
+ export interface ProductVariantWeightProps {
905
+ /** Whether to render as a child component */
906
+ asChild?: boolean;
907
+ /** Custom render function when using asChild */
908
+ children?: AsChildChildren<{
909
+ weight: string | null;
910
+ }>;
911
+ /** CSS classes to apply to the default element */
912
+ className?: string;
913
+ }
914
+ /**
915
+ * Displays the selected variant weight with customizable rendering following the documented API.
916
+ *
917
+ * @component
918
+ * @example
919
+ * ```tsx
920
+ * // Default usage
921
+ * <Product.ProductVariant.Weight className="text-content-secondary" />
922
+ *
923
+ * // asChild with primitive
924
+ * <Product.ProductVariant.Weight asChild>
925
+ * <span className="weight-value" />
926
+ * </Product.ProductVariant.Weight>
927
+ *
928
+ * // asChild with react component
929
+ * <Product.ProductVariant.Weight asChild>
930
+ * {React.forwardRef(({weight, ...props}, ref) => (
931
+ * <span ref={ref} {...props}>
932
+ * {weight}
933
+ * </span>
934
+ * ))}
935
+ * </Product.ProductVariant.Weight>
936
+ * ```
937
+ */
938
+ export declare const ProductVariantWeight: React.ForwardRefExoticComponent<ProductVariantWeightProps & React.RefAttributes<HTMLElement>>;
939
+ /**
940
+ * ProductVariant namespace containing product variant components
941
+ * following the compound component pattern: Product.ProductVariant.SKU, Product.ProductVariant.Weight
942
+ */
943
+ export declare const ProductVariant: {
944
+ /** Product variant SKU component */
945
+ readonly SKU: React.ForwardRefExoticComponent<ProductVariantSKUProps & React.RefAttributes<HTMLElement>>;
946
+ /** Product variant weight component */
947
+ readonly Weight: React.ForwardRefExoticComponent<ProductVariantWeightProps & React.RefAttributes<HTMLElement>>;
948
+ };
863
949
  /**
864
950
  * Quantity namespace containing all product quantity components
865
951
  * following the compound component pattern: Product.Quantity.Root, Product.Quantity.Decrement, etc.
@@ -47,6 +47,9 @@ var TestIds;
47
47
  TestIds["productVariants"] = "product-variants";
48
48
  TestIds["productVariantOptions"] = "product-variant-options";
49
49
  TestIds["productVariantOption"] = "product-variant-option";
50
+ TestIds["productVariant"] = "product-variant";
51
+ TestIds["productVariantSku"] = "product-variant-sku";
52
+ TestIds["productVariantWeight"] = "product-variant-weight";
50
53
  TestIds["productModifiers"] = "product-modifiers";
51
54
  TestIds["productModifierOptions"] = "product-modifier-options";
52
55
  TestIds["productModifierOption"] = "product-modifier-option";
@@ -780,7 +783,7 @@ export const ProductQuantityDecrement = React.forwardRef((props, ref) => {
780
783
  if (asChild && children) {
781
784
  return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productQuantityDecrement, customElement: children, customElementProps: { disabled } }));
782
785
  }
783
- return (_jsx(QuantityComponent.Decrement, { className: className, ref: ref, "data-testid": TestIds.productQuantityDecrement, disabled: disabled }));
786
+ return (_jsx(QuantityComponent.Decrement, { className: className, ref: ref, "data-testid": TestIds.productQuantityDecrement, disabled }));
784
787
  } }));
785
788
  });
786
789
  /**
@@ -821,7 +824,7 @@ export const ProductQuantityIncrement = React.forwardRef((props, ref) => {
821
824
  if (asChild && children) {
822
825
  return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productQuantityIncrement, customElement: children, customElementProps: { disabled } }));
823
826
  }
824
- return (_jsx(QuantityComponent.Increment, { className: className, ref: ref, "data-testid": TestIds.productQuantityIncrement, disabled: disabled }));
827
+ return (_jsx(QuantityComponent.Increment, { className: className, ref: ref, "data-testid": TestIds.productQuantityIncrement, disabled }));
825
828
  } }));
826
829
  });
827
830
  /**
@@ -935,6 +938,84 @@ export const Action = {
935
938
  /** Pre-order action button */
936
939
  PreOrder: ProductActionPreOrder,
937
940
  };
941
+ /**
942
+ * Displays the selected variant SKU with customizable rendering following the documented API.
943
+ *
944
+ * @component
945
+ * @example
946
+ * ```tsx
947
+ * // Default usage
948
+ * <Product.ProductVariant.SKU className="text-content-secondary" />
949
+ *
950
+ * // asChild with primitive
951
+ * <Product.ProductVariant.SKU asChild>
952
+ * <span className="sku-value" />
953
+ * </Product.ProductVariant.SKU>
954
+ *
955
+ * // asChild with react component
956
+ * <Product.ProductVariant.SKU asChild>
957
+ * {React.forwardRef(({sku, ...props}, ref) => (
958
+ * <span ref={ref} {...props}>
959
+ * {sku}
960
+ * </span>
961
+ * ))}
962
+ * </Product.ProductVariant.SKU>
963
+ * ```
964
+ */
965
+ export const ProductVariantSKU = React.forwardRef((props, ref) => {
966
+ const { asChild, children, className } = props;
967
+ return (_jsx(SelectedVariant.Details, { children: ({ sku }) => {
968
+ // Don't render anything if there's no SKU
969
+ if (!sku) {
970
+ return null;
971
+ }
972
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productVariantSku, customElement: children, customElementProps: { sku }, content: sku, children: _jsx("span", { children: sku }) }));
973
+ } }));
974
+ });
975
+ /**
976
+ * Displays the selected variant weight with customizable rendering following the documented API.
977
+ *
978
+ * @component
979
+ * @example
980
+ * ```tsx
981
+ * // Default usage
982
+ * <Product.ProductVariant.Weight className="text-content-secondary" />
983
+ *
984
+ * // asChild with primitive
985
+ * <Product.ProductVariant.Weight asChild>
986
+ * <span className="weight-value" />
987
+ * </Product.ProductVariant.Weight>
988
+ *
989
+ * // asChild with react component
990
+ * <Product.ProductVariant.Weight asChild>
991
+ * {React.forwardRef(({weight, ...props}, ref) => (
992
+ * <span ref={ref} {...props}>
993
+ * {weight}
994
+ * </span>
995
+ * ))}
996
+ * </Product.ProductVariant.Weight>
997
+ * ```
998
+ */
999
+ export const ProductVariantWeight = React.forwardRef((props, ref) => {
1000
+ const { asChild, children, className } = props;
1001
+ return (_jsx(SelectedVariant.Details, { children: ({ weight }) => {
1002
+ // Don't render anything if there's no weight
1003
+ if (!weight) {
1004
+ return null;
1005
+ }
1006
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productVariantWeight, customElement: children, customElementProps: { weight }, content: weight, children: _jsx("span", { children: weight }) }));
1007
+ } }));
1008
+ });
1009
+ /**
1010
+ * ProductVariant namespace containing product variant components
1011
+ * following the compound component pattern: Product.ProductVariant.SKU, Product.ProductVariant.Weight
1012
+ */
1013
+ export const ProductVariant = {
1014
+ /** Product variant SKU component */
1015
+ SKU: ProductVariantSKU,
1016
+ /** Product variant weight component */
1017
+ Weight: ProductVariantWeight,
1018
+ };
938
1019
  /**
939
1020
  * Quantity namespace containing all product quantity components
940
1021
  * following the compound component pattern: Product.Quantity.Root, Product.Quantity.Decrement, etc.
@@ -4,7 +4,7 @@ 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, CategoryFilter, ResetTrigger as FilterResetTrigger, } from './core/ProductListFilters.js';
7
+ export { Filter, ResetTrigger as FilterResetTrigger, } from './core/ProductListFilters.js';
8
8
  /**
9
9
  * Props for the ProductList root component following the documented API
10
10
  */
@@ -8,7 +8,7 @@ import * as CoreProductListPagination from './core/ProductListPagination.js';
8
8
  import { ProductListSort as ProductListSortPrimitive } from './core/ProductListSort.js';
9
9
  import * as Product from './Product.js';
10
10
  import { AsChildSlot } from '@wix/headless-utils/react';
11
- export { Filter, CategoryFilter, ResetTrigger as FilterResetTrigger, } from './core/ProductListFilters.js';
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";
@@ -1,5 +1,7 @@
1
+ import React from 'react';
1
2
  import { type CategoriesListServiceConfig } from '../../services/categories-list-service.js';
2
- import { type Category } from '../../services/category-service.js';
3
+ import { categories } from '@wix/categories';
4
+ export type Category = categories.Category;
3
5
  export interface RootProps {
4
6
  children: React.ReactNode;
5
7
  categoriesListConfig: CategoriesListServiceConfig;
@@ -7,6 +9,7 @@ export interface RootProps {
7
9
  /**
8
10
  * Root component that provides the CategoryList service context to its children.
9
11
  * This component sets up the necessary services for managing categories list state.
12
+ * Optionally connects to ProductList filtering when connectToProductFilter is enabled.
10
13
  *
11
14
  * @order 1
12
15
  * @component
@@ -16,7 +19,10 @@ export interface RootProps {
16
19
  *
17
20
  * function CategoriesPage() {
18
21
  * return (
19
- * <CategoryList.Root categoriesListConfig={{ collectionId: 'my-collection' }}>
22
+ * <CategoryList.Root
23
+ * categoriesListConfig={{ categories: myCategories }}
24
+ * connectToProductFilter={true}
25
+ * >
20
26
  * <CategoryList.ItemContent>
21
27
  * {({ category }) => (
22
28
  * <div key={category._id}>
@@ -65,7 +71,7 @@ export interface EmptyStateRenderProps {
65
71
  * }
66
72
  * ```
67
73
  */
68
- export declare function EmptyState(props: EmptyStateProps): import("react").ReactNode;
74
+ export declare function EmptyState(props: EmptyStateProps): React.ReactNode;
69
75
  /**
70
76
  * Props for Loading headless component
71
77
  */
@@ -101,7 +107,7 @@ export interface LoadingRenderProps {
101
107
  * }
102
108
  * ```
103
109
  */
104
- export declare function Loading(props: LoadingProps): import("react").ReactNode;
110
+ export declare function Loading(props: LoadingProps): React.ReactNode;
105
111
  /**
106
112
  * Props for Error headless component
107
113
  */
@@ -142,7 +148,7 @@ export interface ErrorRenderProps {
142
148
  * }
143
149
  * ```
144
150
  */
145
- export declare function Error(props: ErrorProps): import("react").ReactNode;
151
+ export declare function Error(props: ErrorProps): React.ReactNode;
146
152
  /**
147
153
  * Props for ItemContent headless component
148
154
  */
@@ -1,11 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
2
3
  import { useService, WixServices } from '@wix/services-manager-react';
3
4
  import { createServicesMap } from '@wix/services-manager';
4
5
  import { CategoriesListService, CategoriesListServiceDefinition, } from '../../services/categories-list-service.js';
5
- import { Root as CategoryRoot } from './Category.js';
6
6
  /**
7
7
  * Root component that provides the CategoryList service context to its children.
8
8
  * This component sets up the necessary services for managing categories list state.
9
+ * Optionally connects to ProductList filtering when connectToProductFilter is enabled.
9
10
  *
10
11
  * @order 1
11
12
  * @component
@@ -15,7 +16,10 @@ import { Root as CategoryRoot } from './Category.js';
15
16
  *
16
17
  * function CategoriesPage() {
17
18
  * return (
18
- * <CategoryList.Root categoriesListConfig={{ collectionId: 'my-collection' }}>
19
+ * <CategoryList.Root
20
+ * categoriesListConfig={{ categories: myCategories }}
21
+ * connectToProductFilter={true}
22
+ * >
19
23
  * <CategoryList.ItemContent>
20
24
  * {({ category }) => (
21
25
  * <div key={category._id}>
@@ -29,7 +33,8 @@ import { Root as CategoryRoot } from './Category.js';
29
33
  * ```
30
34
  */
31
35
  export function Root(props) {
32
- return (_jsx(WixServices, { servicesMap: createServicesMap().addService(CategoriesListServiceDefinition, CategoriesListService, props.categoriesListConfig), children: props.children }));
36
+ const { categoriesListConfig, children } = props;
37
+ return (_jsx(WixServices, { servicesMap: createServicesMap().addService(CategoriesListServiceDefinition, CategoriesListService, categoriesListConfig), children: children }));
33
38
  }
34
39
  /**
35
40
  * Component that renders content when the categories list is empty.
@@ -166,7 +171,7 @@ export function ItemContent(props) {
166
171
  if (isLoading.get() || error.get() || categoriesValue.length === 0) {
167
172
  return null;
168
173
  }
169
- return categoriesValue.map((category) => (_jsx(CategoryRoot, { categoryServiceConfig: { category }, children: typeof props.children === 'function'
174
+ return categoriesValue.map((category) => (_jsx(React.Fragment, { children: typeof props.children === 'function'
170
175
  ? props.children({
171
176
  category,
172
177
  })
@@ -50,7 +50,7 @@ export interface ResetTriggerRenderProps {
50
50
  export declare function ResetTrigger(props: ResetTriggerProps): ReactNode;
51
51
  export interface CategoryFilterRenderProps {
52
52
  selectedCategory: Category | null;
53
- setSelectedCategory: (category: Category) => void;
53
+ setSelectedCategory: (category: Category | null) => void;
54
54
  }
55
55
  export interface CategoryFilterProps {
56
56
  /** Content to display (can be a render function receiving category data or ReactNode) */
@@ -1,5 +1,4 @@
1
1
  export * as CategoryListCore from './core/CategoryList.js';
2
- export * as CategoryCore from './core/Category.js';
3
2
  export * as ProductCore from './core/Product.js';
4
3
  export * as ProductModifiers from './core/ProductModifiers.js';
5
4
  export * as ProductListCore from './core/ProductList.js';
@@ -1,5 +1,4 @@
1
1
  export * as CategoryListCore from './core/CategoryList.js';
2
- export * as CategoryCore from './core/Category.js';
3
2
  export * as ProductCore from './core/Product.js';
4
3
  export * as ProductModifiers from './core/ProductModifiers.js';
5
4
  export * as ProductListCore from './core/ProductList.js';
@@ -1,5 +1,6 @@
1
1
  import { type Signal } from '@wix/services-definitions/core-services/signals';
2
- import { type Category } from './category-service.js';
2
+ import { categories } from '@wix/categories';
3
+ export type Category = categories.Category;
3
4
  /**
4
5
  * Configuration interface for the Categories List service.
5
6
  * Contains the initial categories data that will be loaded into the service.
@@ -1,4 +1,3 @@
1
- export { CategoryService, CategoryServiceDefinition, loadCategoryServiceConfig, CategoryServiceConfig, Category, } from './category-service.js';
2
1
  export { CategoriesListService, CategoriesListServiceDefinition, loadCategoriesListServiceConfig, CategoriesListServiceConfig, } from './categories-list-service.js';
3
2
  export { ProductModifiersService, ProductModifiersServiceDefinition, } from './product-modifiers-service.js';
4
3
  export { ProductService, ProductServiceDefinition, loadProductServiceConfig, } from './product-service.js';
@@ -1,4 +1,3 @@
1
- export { CategoryService, CategoryServiceDefinition, loadCategoryServiceConfig, } from './category-service.js';
2
1
  export { CategoriesListService, CategoriesListServiceDefinition, loadCategoriesListServiceConfig, } from './categories-list-service.js';
3
2
  export { ProductModifiersService, ProductModifiersServiceDefinition, } from './product-modifiers-service.js';
4
3
  export { ProductService, ProductServiceDefinition, loadProductServiceConfig, } from './product-service.js';
@@ -1,6 +1,7 @@
1
1
  import { type Signal, type ReadOnlySignal } from '@wix/services-definitions/core-services/signals';
2
2
  import { customizationsV3, productsV3 } from '@wix/stores';
3
- import { type Category } from './category-service.js';
3
+ import { categories } from '@wix/categories';
4
+ type Category = categories.Category;
4
5
  export declare const DEFAULT_QUERY_LIMIT = 100;
5
6
  import { SortType } from './../enums/sort-enums.js';
6
7
  export { SortType } from './../enums/sort-enums.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-stores",
3
- "version": "0.0.77",
3
+ "version": "0.0.79",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "prebuild": "cd ../media && yarn build && cd ../ecom && yarn build",
@@ -1,98 +0,0 @@
1
- import { type CategoryServiceConfig } from '../../services/category-service.js';
2
- export interface RootProps {
3
- children: React.ReactNode;
4
- categoryServiceConfig: CategoryServiceConfig;
5
- }
6
- /**
7
- * Root component that provides the Category service context to its children.
8
- * This component sets up the necessary services for managing category state.
9
- *
10
- * @order 1
11
- * @component
12
- * @example
13
- * ```tsx
14
- * import { CategoryCore } from '@wix/stores/components';
15
- *
16
- * function CategoryPage() {
17
- * return (
18
- * <Category.Root categoryServiceConfig={{ category: myCategory }}>
19
- * <Category.Name>
20
- * {({ name }) => <h1>{name}</h1>}
21
- * </Category.Name>
22
- * <Category.Slug>
23
- * {({ slug }) => <p>Slug: {slug}</p>}
24
- * </Category.Slug>
25
- * </Category.Root>
26
- * );
27
- * }
28
- * ```
29
- */
30
- export declare function Root(props: RootProps): React.ReactNode;
31
- /**
32
- * Props for Name headless component
33
- */
34
- export interface NameProps {
35
- /** Content to display (can be a render function receiving name data or ReactNode) */
36
- children: ((props: NameRenderProps) => React.ReactNode) | React.ReactNode;
37
- }
38
- /**
39
- * Render props for Name component
40
- */
41
- export interface NameRenderProps {
42
- /** Category name */
43
- name: string;
44
- }
45
- /**
46
- * Headless component for category name display
47
- *
48
- * @component
49
- * @example
50
- * ```tsx
51
- * import { CategoryCore } from '@wix/stores/components';
52
- *
53
- * function CategoryHeader() {
54
- * return (
55
- * <Category.Name>
56
- * {({ name }) => (
57
- * <h1 className="category-title">{name}</h1>
58
- * )}
59
- * </Category.Name>
60
- * );
61
- * }
62
- * ```
63
- */
64
- export declare function Name(props: NameProps): import("react").ReactNode;
65
- /**
66
- * Props for Slug headless component
67
- */
68
- export interface SlugProps {
69
- /** Content to display (can be a render function receiving slug data or ReactNode) */
70
- children: ((props: SlugRenderProps) => React.ReactNode) | React.ReactNode;
71
- }
72
- /**
73
- * Render props for Slug component
74
- */
75
- export interface SlugRenderProps {
76
- /** Category slug */
77
- slug: string;
78
- }
79
- /**
80
- * Headless component for category slug display
81
- *
82
- * @component
83
- * @example
84
- * ```tsx
85
- * import { CategoryCore } from '@wix/stores/components';
86
- *
87
- * function CategoryInfo() {
88
- * return (
89
- * <Category.Slug>
90
- * {({ slug }) => (
91
- * <p className="category-slug">Category slug: {slug}</p>
92
- * )}
93
- * </Category.Slug>
94
- * );
95
- * }
96
- * ```
97
- */
98
- export declare function Slug(props: SlugProps): import("react").ReactNode;