@wix/headless-stores 0.0.36 → 0.0.37

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 (129) hide show
  1. package/cjs/dist/react/Category.d.ts +65 -59
  2. package/cjs/dist/react/Category.js +50 -83
  3. package/cjs/dist/react/CategoryList.d.ts +184 -0
  4. package/cjs/dist/react/CategoryList.js +174 -0
  5. package/cjs/dist/react/Product.d.ts +3 -3
  6. package/cjs/dist/react/Product.js +6 -6
  7. package/cjs/dist/react/ProductActions.d.ts +1 -1
  8. package/cjs/dist/react/ProductActions.js +2 -2
  9. package/{dist/react/ProductsList.d.ts → cjs/dist/react/ProductList.d.ts} +71 -38
  10. package/cjs/dist/react/{ProductsList.js → ProductList.js} +30 -26
  11. package/cjs/dist/react/ProductListFilters.d.ts +244 -0
  12. package/cjs/dist/react/ProductListFilters.js +216 -0
  13. package/cjs/dist/react/ProductListPagination.d.ts +246 -0
  14. package/cjs/dist/react/ProductListPagination.js +207 -0
  15. package/cjs/dist/react/ProductListSort.d.ts +87 -0
  16. package/cjs/dist/react/ProductListSort.js +85 -0
  17. package/cjs/dist/react/ProductModifiers.d.ts +5 -5
  18. package/cjs/dist/react/ProductModifiers.js +10 -10
  19. package/cjs/dist/react/ProductVariantSelector.d.ts +5 -5
  20. package/cjs/dist/react/ProductVariantSelector.js +13 -10
  21. package/cjs/dist/react/SelectedVariant.d.ts +3 -3
  22. package/cjs/dist/react/SelectedVariant.js +6 -6
  23. package/cjs/dist/react/index.d.ts +7 -9
  24. package/cjs/dist/react/index.js +7 -9
  25. package/cjs/dist/services/buy-now-service.d.ts +208 -0
  26. package/cjs/dist/services/buy-now-service.js +132 -1
  27. package/cjs/dist/services/categories-list-service.d.ts +163 -0
  28. package/cjs/dist/services/categories-list-service.js +148 -0
  29. package/cjs/dist/services/category-service.d.ts +115 -70
  30. package/cjs/dist/services/category-service.js +101 -110
  31. package/cjs/dist/services/index.d.ts +6 -7
  32. package/cjs/dist/services/index.js +5 -16
  33. package/cjs/dist/services/pay-now-service.d.ts +146 -0
  34. package/cjs/dist/services/pay-now-service.js +112 -1
  35. package/cjs/dist/services/product-service.d.ts +71 -0
  36. package/cjs/dist/services/product-service.js +47 -0
  37. package/cjs/dist/services/products-list-filters-service.d.ts +292 -0
  38. package/cjs/dist/services/products-list-filters-service.js +446 -0
  39. package/cjs/dist/services/products-list-pagination-service.d.ts +186 -0
  40. package/cjs/dist/services/products-list-pagination-service.js +179 -0
  41. package/cjs/dist/services/products-list-service.d.ts +138 -52
  42. package/cjs/dist/services/products-list-service.js +98 -51
  43. package/cjs/dist/services/products-list-sort-service.d.ts +117 -0
  44. package/cjs/dist/services/products-list-sort-service.js +144 -0
  45. package/cjs/dist/utils/url-params.d.ts +68 -0
  46. package/cjs/dist/utils/url-params.js +72 -4
  47. package/dist/react/Category.d.ts +65 -59
  48. package/dist/react/Category.js +50 -83
  49. package/dist/react/CategoryList.d.ts +184 -0
  50. package/dist/react/CategoryList.js +174 -0
  51. package/dist/react/Product.d.ts +3 -3
  52. package/dist/react/Product.js +6 -6
  53. package/dist/react/ProductActions.d.ts +1 -1
  54. package/dist/react/ProductActions.js +2 -2
  55. package/{cjs/dist/react/ProductsList.d.ts → dist/react/ProductList.d.ts} +71 -38
  56. package/dist/react/{ProductsList.js → ProductList.js} +30 -26
  57. package/dist/react/ProductListFilters.d.ts +244 -0
  58. package/dist/react/ProductListFilters.js +216 -0
  59. package/dist/react/ProductListPagination.d.ts +246 -0
  60. package/dist/react/ProductListPagination.js +207 -0
  61. package/dist/react/ProductListSort.d.ts +87 -0
  62. package/dist/react/ProductListSort.js +85 -0
  63. package/dist/react/ProductModifiers.d.ts +5 -5
  64. package/dist/react/ProductModifiers.js +10 -10
  65. package/dist/react/ProductVariantSelector.d.ts +5 -5
  66. package/dist/react/ProductVariantSelector.js +13 -10
  67. package/dist/react/SelectedVariant.d.ts +3 -3
  68. package/dist/react/SelectedVariant.js +6 -6
  69. package/dist/react/index.d.ts +7 -9
  70. package/dist/react/index.js +7 -9
  71. package/dist/services/buy-now-service.d.ts +208 -0
  72. package/dist/services/buy-now-service.js +132 -1
  73. package/dist/services/categories-list-service.d.ts +163 -0
  74. package/dist/services/categories-list-service.js +148 -0
  75. package/dist/services/category-service.d.ts +115 -70
  76. package/dist/services/category-service.js +101 -110
  77. package/dist/services/index.d.ts +6 -7
  78. package/dist/services/index.js +5 -16
  79. package/dist/services/pay-now-service.d.ts +146 -0
  80. package/dist/services/pay-now-service.js +112 -1
  81. package/dist/services/product-service.d.ts +71 -0
  82. package/dist/services/product-service.js +47 -0
  83. package/dist/services/products-list-filters-service.d.ts +292 -0
  84. package/dist/services/products-list-filters-service.js +446 -0
  85. package/dist/services/products-list-pagination-service.d.ts +186 -0
  86. package/dist/services/products-list-pagination-service.js +179 -0
  87. package/dist/services/products-list-service.d.ts +138 -52
  88. package/dist/services/products-list-service.js +98 -51
  89. package/dist/services/products-list-sort-service.d.ts +117 -0
  90. package/dist/services/products-list-sort-service.js +144 -0
  91. package/dist/utils/url-params.d.ts +68 -0
  92. package/dist/utils/url-params.js +72 -4
  93. package/package.json +3 -3
  94. package/cjs/dist/react/Collection.d.ts +0 -294
  95. package/cjs/dist/react/Collection.js +0 -345
  96. package/cjs/dist/react/FilteredCollection.d.ts +0 -299
  97. package/cjs/dist/react/FilteredCollection.js +0 -352
  98. package/cjs/dist/react/RelatedProducts.d.ts +0 -169
  99. package/cjs/dist/react/RelatedProducts.js +0 -180
  100. package/cjs/dist/react/Sort.d.ts +0 -37
  101. package/cjs/dist/react/Sort.js +0 -36
  102. package/cjs/dist/services/catalog-service.d.ts +0 -36
  103. package/cjs/dist/services/catalog-service.js +0 -193
  104. package/cjs/dist/services/collection-service.d.ts +0 -124
  105. package/cjs/dist/services/collection-service.js +0 -628
  106. package/cjs/dist/services/filter-service.d.ts +0 -35
  107. package/cjs/dist/services/filter-service.js +0 -119
  108. package/cjs/dist/services/related-products-service.d.ts +0 -100
  109. package/cjs/dist/services/related-products-service.js +0 -127
  110. package/cjs/dist/services/sort-service.d.ts +0 -20
  111. package/cjs/dist/services/sort-service.js +0 -27
  112. package/dist/react/Collection.d.ts +0 -294
  113. package/dist/react/Collection.js +0 -345
  114. package/dist/react/FilteredCollection.d.ts +0 -299
  115. package/dist/react/FilteredCollection.js +0 -352
  116. package/dist/react/RelatedProducts.d.ts +0 -169
  117. package/dist/react/RelatedProducts.js +0 -180
  118. package/dist/react/Sort.d.ts +0 -37
  119. package/dist/react/Sort.js +0 -36
  120. package/dist/services/catalog-service.d.ts +0 -36
  121. package/dist/services/catalog-service.js +0 -193
  122. package/dist/services/collection-service.d.ts +0 -124
  123. package/dist/services/collection-service.js +0 -628
  124. package/dist/services/filter-service.d.ts +0 -35
  125. package/dist/services/filter-service.js +0 -119
  126. package/dist/services/related-products-service.d.ts +0 -100
  127. package/dist/services/related-products-service.js +0 -127
  128. package/dist/services/sort-service.d.ts +0 -20
  129. package/dist/services/sort-service.js +0 -27
@@ -1,10 +1,8 @@
1
- import { type Category } from "@wix/auto_sdk_categories_categories";
2
- import React, { type ReactNode } from "react";
1
+ import type { PropsWithChildren, ReactNode } from "react";
3
2
  import { type CategoryServiceConfig } from "../services/category-service.js";
4
- import type { PropsWithChildren } from "react";
5
3
  /**
6
4
  * Root component that provides the Category service context to its children.
7
- * This component sets up the necessary services for managing category functionality.
5
+ * This component sets up the necessary services for managing category state.
8
6
  *
9
7
  * @order 1
10
8
  * @component
@@ -12,80 +10,88 @@ import type { PropsWithChildren } from "react";
12
10
  * ```tsx
13
11
  * import { Category } from '@wix/stores/components';
14
12
  *
15
- * function CategoryNavigation({ categories }) {
13
+ * function CategoryPage() {
16
14
  * return (
17
- * <Category.Root categoryServiceConfig={{ categories }}>
18
- * <div>
19
- * <Category.List>
20
- * {({ categories, selectedCategory, setSelectedCategory }) => (
21
- * <nav>
22
- * <button
23
- * onClick={() => setSelectedCategory(null)}
24
- * className={selectedCategory === null ? 'active' : ''}
25
- * >
26
- * All Categories
27
- * </button>
28
- * {categories.map(category => (
29
- * <button
30
- * key={category.id}
31
- * onClick={() => setSelectedCategory(category.id)}
32
- * className={selectedCategory === category.id ? 'active' : ''}
33
- * >
34
- * {category.name}
35
- * </button>
36
- * ))}
37
- * </nav>
38
- * )}
39
- * </Category.List>
40
- * </div>
15
+ * <Category.Root categoryServiceConfig={{ category: myCategory }}>
16
+ * <Category.Name>
17
+ * {({ name }) => <h1>{name}</h1>}
18
+ * </Category.Name>
19
+ * <Category.Slug>
20
+ * {({ slug }) => <p>Slug: {slug}</p>}
21
+ * </Category.Slug>
41
22
  * </Category.Root>
42
23
  * );
43
24
  * }
44
25
  * ```
45
26
  */
46
27
  export declare function Root(props: PropsWithChildren<{
47
- categoryServiceConfig?: CategoryServiceConfig;
28
+ categoryServiceConfig: CategoryServiceConfig;
48
29
  }>): import("react/jsx-runtime").JSX.Element;
49
- export interface CategoryListProps {
50
- children: (data: {
51
- categories: Category[];
52
- selectedCategory: string | null;
53
- setSelectedCategory: (categoryId: string | null) => void;
54
- }) => ReactNode;
30
+ /**
31
+ * Props for Name headless component
32
+ */
33
+ export interface NameProps {
34
+ /** Content to display (can be a render function receiving name data or ReactNode) */
35
+ children: ((props: NameRenderProps) => ReactNode) | ReactNode;
36
+ }
37
+ /**
38
+ * Render props for Name component
39
+ */
40
+ export interface NameRenderProps {
41
+ /** Category name */
42
+ name: string;
43
+ }
44
+ /**
45
+ * Headless component for category name display
46
+ *
47
+ * @component
48
+ * @example
49
+ * ```tsx
50
+ * import { Category } from '@wix/stores/components';
51
+ *
52
+ * function CategoryHeader() {
53
+ * return (
54
+ * <Category.Name>
55
+ * {({ name }) => (
56
+ * <h1 className="category-title">{name}</h1>
57
+ * )}
58
+ * </Category.Name>
59
+ * );
60
+ * }
61
+ * ```
62
+ */
63
+ export declare function Name(props: NameProps): ReactNode;
64
+ /**
65
+ * Props for Slug headless component
66
+ */
67
+ export interface SlugProps {
68
+ /** Content to display (can be a render function receiving slug data or ReactNode) */
69
+ children: ((props: SlugRenderProps) => ReactNode) | ReactNode;
70
+ }
71
+ /**
72
+ * Render props for Slug component
73
+ */
74
+ export interface SlugRenderProps {
75
+ /** Category slug */
76
+ slug: string;
55
77
  }
56
78
  /**
57
- * Headless component for displaying a list of categories
79
+ * Headless component for category slug display
58
80
  *
59
81
  * @component
60
82
  * @example
61
83
  * ```tsx
62
84
  * import { Category } from '@wix/stores/components';
63
85
  *
64
- * function CategoryNavigation() {
86
+ * function CategoryInfo() {
65
87
  * return (
66
- * <Category.List>
67
- * {({ categories, selectedCategory, setSelectedCategory }) => (
68
- * <nav>
69
- * <button
70
- * onClick={() => setSelectedCategory(null)}
71
- * className={selectedCategory === null ? 'active' : ''}
72
- * >
73
- * All Categories
74
- * </button>
75
- * {categories.map(category => (
76
- * <button
77
- * key={category.id}
78
- * onClick={() => setSelectedCategory(category.id)}
79
- * className={selectedCategory === category.id ? 'active' : ''}
80
- * >
81
- * {category.name}
82
- * </button>
83
- * ))}
84
- * </nav>
88
+ * <Category.Slug>
89
+ * {({ slug }) => (
90
+ * <p className="category-slug">Category slug: {slug}</p>
85
91
  * )}
86
- * </Category.List>
92
+ * </Category.Slug>
87
93
  * );
88
94
  * }
89
95
  * ```
90
96
  */
91
- export declare const List: React.FC<CategoryListProps>;
97
+ export declare function Slug(props: SlugProps): ReactNode;
@@ -1,25 +1,10 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useService, WixServices } from "@wix/services-manager-react";
3
- import { CategoryServiceDefinition, CategoryService, } from "../services/category-service.js";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
4
2
  import { createServicesMap } from "@wix/services-manager";
5
- // Create navigation handler for category URLs
6
- const handleCategoryChange = (categoryId, category) => {
7
- if (typeof window !== "undefined") {
8
- let newPath = "/category";
9
- if (categoryId !== null) {
10
- // Use category slug for URL
11
- if (!category?.slug) {
12
- console.warn(`Category ${categoryId} has no slug, using category ID as fallback`);
13
- }
14
- const categorySlug = category?.slug || categoryId;
15
- newPath = `/category/${categorySlug}`;
16
- }
17
- window.history.pushState(null, "Showing Category " + category?.name, newPath);
18
- }
19
- };
3
+ import { useService, WixServices } from "@wix/services-manager-react";
4
+ import { CategoryService, CategoryServiceDefinition, } from "../services/category-service.js";
20
5
  /**
21
6
  * Root component that provides the Category service context to its children.
22
- * This component sets up the necessary services for managing category functionality.
7
+ * This component sets up the necessary services for managing category state.
23
8
  *
24
9
  * @order 1
25
10
  * @component
@@ -27,88 +12,70 @@ const handleCategoryChange = (categoryId, category) => {
27
12
  * ```tsx
28
13
  * import { Category } from '@wix/stores/components';
29
14
  *
30
- * function CategoryNavigation({ categories }) {
15
+ * function CategoryPage() {
31
16
  * return (
32
- * <Category.Root categoryServiceConfig={{ categories }}>
33
- * <div>
34
- * <Category.List>
35
- * {({ categories, selectedCategory, setSelectedCategory }) => (
36
- * <nav>
37
- * <button
38
- * onClick={() => setSelectedCategory(null)}
39
- * className={selectedCategory === null ? 'active' : ''}
40
- * >
41
- * All Categories
42
- * </button>
43
- * {categories.map(category => (
44
- * <button
45
- * key={category.id}
46
- * onClick={() => setSelectedCategory(category.id)}
47
- * className={selectedCategory === category.id ? 'active' : ''}
48
- * >
49
- * {category.name}
50
- * </button>
51
- * ))}
52
- * </nav>
53
- * )}
54
- * </Category.List>
55
- * </div>
17
+ * <Category.Root categoryServiceConfig={{ category: myCategory }}>
18
+ * <Category.Name>
19
+ * {({ name }) => <h1>{name}</h1>}
20
+ * </Category.Name>
21
+ * <Category.Slug>
22
+ * {({ slug }) => <p>Slug: {slug}</p>}
23
+ * </Category.Slug>
56
24
  * </Category.Root>
57
25
  * );
58
26
  * }
59
27
  * ```
60
28
  */
61
29
  export function Root(props) {
62
- return (_jsx(WixServices, { servicesMap: createServicesMap().addService(CategoryServiceDefinition, CategoryService, {
63
- ...(props.categoryServiceConfig ?? {
64
- categories: [],
65
- initialCategoryId: null,
66
- }),
67
- onCategoryChange: handleCategoryChange,
68
- }), children: props.children }));
30
+ return (_jsx(WixServices, { servicesMap: createServicesMap().addService(CategoryServiceDefinition, CategoryService, props.categoryServiceConfig), children: props.children }));
69
31
  }
70
32
  /**
71
- * Headless component for displaying a list of categories
33
+ * Headless component for category name display
72
34
  *
73
35
  * @component
74
36
  * @example
75
37
  * ```tsx
76
38
  * import { Category } from '@wix/stores/components';
77
39
  *
78
- * function CategoryNavigation() {
40
+ * function CategoryHeader() {
79
41
  * return (
80
- * <Category.List>
81
- * {({ categories, selectedCategory, setSelectedCategory }) => (
82
- * <nav>
83
- * <button
84
- * onClick={() => setSelectedCategory(null)}
85
- * className={selectedCategory === null ? 'active' : ''}
86
- * >
87
- * All Categories
88
- * </button>
89
- * {categories.map(category => (
90
- * <button
91
- * key={category.id}
92
- * onClick={() => setSelectedCategory(category.id)}
93
- * className={selectedCategory === category.id ? 'active' : ''}
94
- * >
95
- * {category.name}
96
- * </button>
97
- * ))}
98
- * </nav>
42
+ * <Category.Name>
43
+ * {({ name }) => (
44
+ * <h1 className="category-title">{name}</h1>
99
45
  * )}
100
- * </Category.List>
46
+ * </Category.Name>
101
47
  * );
102
48
  * }
103
49
  * ```
104
50
  */
105
- export const List = ({ children }) => {
106
- const service = useService(CategoryServiceDefinition);
107
- const categories = service.categories.get();
108
- const selectedCategory = service.selectedCategory.get();
109
- return (_jsx(_Fragment, { children: children({
110
- selectedCategory,
111
- categories,
112
- setSelectedCategory: service.setSelectedCategory,
113
- }) }));
114
- };
51
+ export function Name(props) {
52
+ const categoryService = useService(CategoryServiceDefinition);
53
+ return typeof props.children === "function"
54
+ ? props.children({ name: categoryService.category.get().name })
55
+ : props.children;
56
+ }
57
+ /**
58
+ * Headless component for category slug display
59
+ *
60
+ * @component
61
+ * @example
62
+ * ```tsx
63
+ * import { Category } from '@wix/stores/components';
64
+ *
65
+ * function CategoryInfo() {
66
+ * return (
67
+ * <Category.Slug>
68
+ * {({ slug }) => (
69
+ * <p className="category-slug">Category slug: {slug}</p>
70
+ * )}
71
+ * </Category.Slug>
72
+ * );
73
+ * }
74
+ * ```
75
+ */
76
+ export function Slug(props) {
77
+ const categoryService = useService(CategoryServiceDefinition);
78
+ return typeof props.children === "function"
79
+ ? props.children({ slug: categoryService.category.get().slug })
80
+ : props.children;
81
+ }
@@ -0,0 +1,184 @@
1
+ import { type CategoriesListServiceConfig } from "../services/categories-list-service.js";
2
+ import type { PropsWithChildren, ReactNode } from "react";
3
+ import { categories } from "@wix/categories";
4
+ /**
5
+ * Root component that provides the CategoryList service context to its children.
6
+ * This component sets up the necessary services for managing categories list state.
7
+ *
8
+ * @order 1
9
+ * @component
10
+ * @example
11
+ * ```tsx
12
+ * import { CategoryList } from '@wix/stores/components';
13
+ *
14
+ * function CategoriesPage() {
15
+ * return (
16
+ * <CategoryList.Root categoriesListConfig={{ collectionId: 'my-collection' }}>
17
+ * <CategoryList.ItemContent>
18
+ * {({ category }) => (
19
+ * <div key={category._id}>
20
+ * <h2>{category.name}</h2>
21
+ * </div>
22
+ * )}
23
+ * </CategoryList.ItemContent>
24
+ * </CategoryList.Root>
25
+ * );
26
+ * }
27
+ * ```
28
+ */
29
+ export declare function Root(props: PropsWithChildren<{
30
+ categoriesListConfig: CategoriesListServiceConfig;
31
+ }>): import("react/jsx-runtime").JSX.Element;
32
+ /**
33
+ * Props for EmptyState headless component
34
+ */
35
+ export interface EmptyStateProps {
36
+ /** Content to display when categories list is empty (can be a render function or ReactNode) */
37
+ children: ((props: EmptyStateRenderProps) => ReactNode) | ReactNode;
38
+ }
39
+ /**
40
+ * Render props for EmptyState component
41
+ */
42
+ export interface EmptyStateRenderProps {
43
+ }
44
+ /**
45
+ * Component that renders content when the categories list is empty.
46
+ * Only displays its children when there are no categories, no loading state, and no errors.
47
+ *
48
+ * @component
49
+ * @example
50
+ * ```tsx
51
+ * import { CategoryList } from '@wix/stores/components';
52
+ *
53
+ * function EmptyCategoriesMessage() {
54
+ * return (
55
+ * <CategoryList.EmptyState>
56
+ * {() => (
57
+ * <div className="empty-state">
58
+ * <h3>No categories found</h3>
59
+ * <p>Categories will appear here once they are created</p>
60
+ * </div>
61
+ * )}
62
+ * </CategoryList.EmptyState>
63
+ * );
64
+ * }
65
+ * ```
66
+ */
67
+ export declare function EmptyState(props: EmptyStateProps): ReactNode;
68
+ /**
69
+ * Props for Loading headless component
70
+ */
71
+ export interface LoadingProps {
72
+ /** Content to display during loading (can be a render function or ReactNode) */
73
+ children: ((props: LoadingRenderProps) => ReactNode) | ReactNode;
74
+ }
75
+ /**
76
+ * Render props for Loading component
77
+ */
78
+ export interface LoadingRenderProps {
79
+ }
80
+ /**
81
+ * Component that renders content during loading state.
82
+ * Only displays its children when the categories list is currently loading.
83
+ *
84
+ * @component
85
+ * @example
86
+ * ```tsx
87
+ * import { CategoryList } from '@wix/stores/components';
88
+ *
89
+ * function CategoriesLoading() {
90
+ * return (
91
+ * <CategoryList.Loading>
92
+ * {() => (
93
+ * <div className="loading-spinner">
94
+ * <div>Loading categories...</div>
95
+ * <div className="spinner"></div>
96
+ * </div>
97
+ * )}
98
+ * </CategoryList.Loading>
99
+ * );
100
+ * }
101
+ * ```
102
+ */
103
+ export declare function Loading(props: LoadingProps): ReactNode;
104
+ /**
105
+ * Props for Error headless component
106
+ */
107
+ export interface ErrorProps {
108
+ /** Content to display during error state (can be a render function or ReactNode) */
109
+ children: ((props: ErrorRenderProps) => ReactNode) | ReactNode;
110
+ }
111
+ /**
112
+ * Render props for Error component
113
+ */
114
+ export interface ErrorRenderProps {
115
+ /** Error message */
116
+ error: string | null;
117
+ }
118
+ /**
119
+ * Component that renders content when there's an error loading categories.
120
+ * Only displays its children when an error has occurred.
121
+ *
122
+ * @component
123
+ * @example
124
+ * ```tsx
125
+ * import { CategoryList } from '@wix/stores/components';
126
+ *
127
+ * function CategoriesError() {
128
+ * return (
129
+ * <CategoryList.Error>
130
+ * {({ error }) => (
131
+ * <div className="error-state">
132
+ * <h3>Error loading categories</h3>
133
+ * <p>{error}</p>
134
+ * <button onClick={() => window.location.reload()}>
135
+ * Try Again
136
+ * </button>
137
+ * </div>
138
+ * )}
139
+ * </CategoryList.Error>
140
+ * );
141
+ * }
142
+ * ```
143
+ */
144
+ export declare function Error(props: ErrorProps): ReactNode;
145
+ /**
146
+ * Props for ItemContent headless component
147
+ */
148
+ export interface ItemContentProps {
149
+ /** Content to display for each category (can be a render function receiving category data or ReactNode) */
150
+ children: ((props: ItemContentRenderProps) => ReactNode) | ReactNode;
151
+ }
152
+ /**
153
+ * Render props for ItemContent component
154
+ */
155
+ export interface ItemContentRenderProps {
156
+ /** Category data */
157
+ category: categories.Category;
158
+ }
159
+ /**
160
+ * Component that renders content for each category in the list.
161
+ * Maps over all categories and provides each category through a service context.
162
+ * Only renders when categories are successfully loaded (not loading, no error, and has categories).
163
+ *
164
+ * @component
165
+ * @example
166
+ * ```tsx
167
+ * import { CategoryList } from '@wix/stores/components';
168
+ *
169
+ * function CategoriesGrid() {
170
+ * return (
171
+ * <CategoryList.ItemContent>
172
+ * {({ category }) => (
173
+ * <div className="category-card">
174
+ * <h3>{category.name}</h3>
175
+ * <p>{category.description}</p>
176
+ * <a href={`/categories/${category.slug}`}>View Category</a>
177
+ * </div>
178
+ * )}
179
+ * </CategoryList.ItemContent>
180
+ * );
181
+ * }
182
+ * ```
183
+ */
184
+ export declare function ItemContent(props: ItemContentProps): import("react/jsx-runtime").JSX.Element[] | null;
@@ -0,0 +1,174 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useService, WixServices } from "@wix/services-manager-react";
3
+ import { createServicesMap } from "@wix/services-manager";
4
+ import { CategoriesListService, CategoriesListServiceDefinition, } from "../services/categories-list-service.js";
5
+ import { Root as CategoryRoot } from "./Category.js";
6
+ /**
7
+ * Root component that provides the CategoryList service context to its children.
8
+ * This component sets up the necessary services for managing categories list state.
9
+ *
10
+ * @order 1
11
+ * @component
12
+ * @example
13
+ * ```tsx
14
+ * import { CategoryList } from '@wix/stores/components';
15
+ *
16
+ * function CategoriesPage() {
17
+ * return (
18
+ * <CategoryList.Root categoriesListConfig={{ collectionId: 'my-collection' }}>
19
+ * <CategoryList.ItemContent>
20
+ * {({ category }) => (
21
+ * <div key={category._id}>
22
+ * <h2>{category.name}</h2>
23
+ * </div>
24
+ * )}
25
+ * </CategoryList.ItemContent>
26
+ * </CategoryList.Root>
27
+ * );
28
+ * }
29
+ * ```
30
+ */
31
+ export function Root(props) {
32
+ return (_jsx(WixServices, { servicesMap: createServicesMap().addService(CategoriesListServiceDefinition, CategoriesListService, props.categoriesListConfig), children: props.children }));
33
+ }
34
+ /**
35
+ * Component that renders content when the categories list is empty.
36
+ * Only displays its children when there are no categories, no loading state, and no errors.
37
+ *
38
+ * @component
39
+ * @example
40
+ * ```tsx
41
+ * import { CategoryList } from '@wix/stores/components';
42
+ *
43
+ * function EmptyCategoriesMessage() {
44
+ * return (
45
+ * <CategoryList.EmptyState>
46
+ * {() => (
47
+ * <div className="empty-state">
48
+ * <h3>No categories found</h3>
49
+ * <p>Categories will appear here once they are created</p>
50
+ * </div>
51
+ * )}
52
+ * </CategoryList.EmptyState>
53
+ * );
54
+ * }
55
+ * ```
56
+ */
57
+ export function EmptyState(props) {
58
+ const { isLoading, error, categories } = useService(CategoriesListServiceDefinition);
59
+ const isLoadingValue = isLoading.get();
60
+ const errorValue = error.get();
61
+ const categoriesValue = categories.get();
62
+ if (!isLoadingValue && !errorValue && categoriesValue.length === 0) {
63
+ return typeof props.children === "function"
64
+ ? props.children({})
65
+ : props.children;
66
+ }
67
+ return null;
68
+ }
69
+ /**
70
+ * Component that renders content during loading state.
71
+ * Only displays its children when the categories list is currently loading.
72
+ *
73
+ * @component
74
+ * @example
75
+ * ```tsx
76
+ * import { CategoryList } from '@wix/stores/components';
77
+ *
78
+ * function CategoriesLoading() {
79
+ * return (
80
+ * <CategoryList.Loading>
81
+ * {() => (
82
+ * <div className="loading-spinner">
83
+ * <div>Loading categories...</div>
84
+ * <div className="spinner"></div>
85
+ * </div>
86
+ * )}
87
+ * </CategoryList.Loading>
88
+ * );
89
+ * }
90
+ * ```
91
+ */
92
+ export function Loading(props) {
93
+ const { isLoading } = useService(CategoriesListServiceDefinition);
94
+ const isLoadingValue = isLoading.get();
95
+ if (isLoadingValue) {
96
+ return typeof props.children === "function"
97
+ ? props.children({})
98
+ : props.children;
99
+ }
100
+ return null;
101
+ }
102
+ /**
103
+ * Component that renders content when there's an error loading categories.
104
+ * Only displays its children when an error has occurred.
105
+ *
106
+ * @component
107
+ * @example
108
+ * ```tsx
109
+ * import { CategoryList } from '@wix/stores/components';
110
+ *
111
+ * function CategoriesError() {
112
+ * return (
113
+ * <CategoryList.Error>
114
+ * {({ error }) => (
115
+ * <div className="error-state">
116
+ * <h3>Error loading categories</h3>
117
+ * <p>{error}</p>
118
+ * <button onClick={() => window.location.reload()}>
119
+ * Try Again
120
+ * </button>
121
+ * </div>
122
+ * )}
123
+ * </CategoryList.Error>
124
+ * );
125
+ * }
126
+ * ```
127
+ */
128
+ export function Error(props) {
129
+ const { error } = useService(CategoriesListServiceDefinition);
130
+ const errorValue = error.get();
131
+ if (errorValue) {
132
+ return typeof props.children === "function"
133
+ ? props.children({ error: errorValue })
134
+ : props.children;
135
+ }
136
+ return null;
137
+ }
138
+ /**
139
+ * Component that renders content for each category in the list.
140
+ * Maps over all categories and provides each category through a service context.
141
+ * Only renders when categories are successfully loaded (not loading, no error, and has categories).
142
+ *
143
+ * @component
144
+ * @example
145
+ * ```tsx
146
+ * import { CategoryList } from '@wix/stores/components';
147
+ *
148
+ * function CategoriesGrid() {
149
+ * return (
150
+ * <CategoryList.ItemContent>
151
+ * {({ category }) => (
152
+ * <div className="category-card">
153
+ * <h3>{category.name}</h3>
154
+ * <p>{category.description}</p>
155
+ * <a href={`/categories/${category.slug}`}>View Category</a>
156
+ * </div>
157
+ * )}
158
+ * </CategoryList.ItemContent>
159
+ * );
160
+ * }
161
+ * ```
162
+ */
163
+ export function ItemContent(props) {
164
+ const { categories, isLoading, error } = useService(CategoriesListServiceDefinition);
165
+ const categoriesValue = categories.get();
166
+ if (isLoading.get() || error.get() || categoriesValue.length === 0) {
167
+ return null;
168
+ }
169
+ return categoriesValue.map((category) => (_jsx(CategoryRoot, { categoryServiceConfig: { category }, children: typeof props.children === "function"
170
+ ? props.children({
171
+ category,
172
+ })
173
+ : props.children }, category._id)));
174
+ }