@wix/headless-stores 0.0.35 → 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 (131) hide show
  1. package/cjs/dist/react/Category.d.ts +83 -31
  2. package/cjs/dist/react/Category.js +68 -35
  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/{dist/react/ProductsList.js → cjs/dist/react/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/services/selected-variant-service.js +0 -1
  46. package/cjs/dist/utils/url-params.d.ts +68 -0
  47. package/cjs/dist/utils/url-params.js +72 -4
  48. package/dist/react/Category.d.ts +83 -31
  49. package/dist/react/Category.js +68 -35
  50. package/dist/react/CategoryList.d.ts +184 -0
  51. package/dist/react/CategoryList.js +174 -0
  52. package/dist/react/Product.d.ts +3 -3
  53. package/dist/react/Product.js +6 -6
  54. package/dist/react/ProductActions.d.ts +1 -1
  55. package/dist/react/ProductActions.js +2 -2
  56. package/{cjs/dist/react/ProductsList.d.ts → dist/react/ProductList.d.ts} +71 -38
  57. package/{cjs/dist/react/ProductsList.js → dist/react/ProductList.js} +30 -26
  58. package/dist/react/ProductListFilters.d.ts +244 -0
  59. package/dist/react/ProductListFilters.js +216 -0
  60. package/dist/react/ProductListPagination.d.ts +246 -0
  61. package/dist/react/ProductListPagination.js +207 -0
  62. package/dist/react/ProductListSort.d.ts +87 -0
  63. package/dist/react/ProductListSort.js +85 -0
  64. package/dist/react/ProductModifiers.d.ts +5 -5
  65. package/dist/react/ProductModifiers.js +10 -10
  66. package/dist/react/ProductVariantSelector.d.ts +5 -5
  67. package/dist/react/ProductVariantSelector.js +13 -10
  68. package/dist/react/SelectedVariant.d.ts +3 -3
  69. package/dist/react/SelectedVariant.js +6 -6
  70. package/dist/react/index.d.ts +7 -9
  71. package/dist/react/index.js +7 -9
  72. package/dist/services/buy-now-service.d.ts +208 -0
  73. package/dist/services/buy-now-service.js +132 -1
  74. package/dist/services/categories-list-service.d.ts +163 -0
  75. package/dist/services/categories-list-service.js +148 -0
  76. package/dist/services/category-service.d.ts +115 -70
  77. package/dist/services/category-service.js +101 -110
  78. package/dist/services/index.d.ts +6 -7
  79. package/dist/services/index.js +5 -16
  80. package/dist/services/pay-now-service.d.ts +146 -0
  81. package/dist/services/pay-now-service.js +112 -1
  82. package/dist/services/product-service.d.ts +71 -0
  83. package/dist/services/product-service.js +47 -0
  84. package/dist/services/products-list-filters-service.d.ts +292 -0
  85. package/dist/services/products-list-filters-service.js +446 -0
  86. package/dist/services/products-list-pagination-service.d.ts +186 -0
  87. package/dist/services/products-list-pagination-service.js +179 -0
  88. package/dist/services/products-list-service.d.ts +138 -52
  89. package/dist/services/products-list-service.js +98 -51
  90. package/dist/services/products-list-sort-service.d.ts +117 -0
  91. package/dist/services/products-list-sort-service.js +144 -0
  92. package/dist/services/selected-variant-service.js +0 -1
  93. package/dist/utils/url-params.d.ts +68 -0
  94. package/dist/utils/url-params.js +72 -4
  95. package/package.json +3 -3
  96. package/cjs/dist/react/Collection.d.ts +0 -294
  97. package/cjs/dist/react/Collection.js +0 -345
  98. package/cjs/dist/react/FilteredCollection.d.ts +0 -216
  99. package/cjs/dist/react/FilteredCollection.js +0 -256
  100. package/cjs/dist/react/RelatedProducts.d.ts +0 -169
  101. package/cjs/dist/react/RelatedProducts.js +0 -180
  102. package/cjs/dist/react/Sort.d.ts +0 -37
  103. package/cjs/dist/react/Sort.js +0 -36
  104. package/cjs/dist/services/catalog-service.d.ts +0 -36
  105. package/cjs/dist/services/catalog-service.js +0 -193
  106. package/cjs/dist/services/collection-service.d.ts +0 -124
  107. package/cjs/dist/services/collection-service.js +0 -628
  108. package/cjs/dist/services/filter-service.d.ts +0 -35
  109. package/cjs/dist/services/filter-service.js +0 -119
  110. package/cjs/dist/services/related-products-service.d.ts +0 -100
  111. package/cjs/dist/services/related-products-service.js +0 -127
  112. package/cjs/dist/services/sort-service.d.ts +0 -20
  113. package/cjs/dist/services/sort-service.js +0 -27
  114. package/dist/react/Collection.d.ts +0 -294
  115. package/dist/react/Collection.js +0 -345
  116. package/dist/react/FilteredCollection.d.ts +0 -216
  117. package/dist/react/FilteredCollection.js +0 -256
  118. package/dist/react/RelatedProducts.d.ts +0 -169
  119. package/dist/react/RelatedProducts.js +0 -180
  120. package/dist/react/Sort.d.ts +0 -37
  121. package/dist/react/Sort.js +0 -36
  122. package/dist/services/catalog-service.d.ts +0 -36
  123. package/dist/services/catalog-service.js +0 -193
  124. package/dist/services/collection-service.d.ts +0 -124
  125. package/dist/services/collection-service.js +0 -628
  126. package/dist/services/filter-service.d.ts +0 -35
  127. package/dist/services/filter-service.js +0 -119
  128. package/dist/services/related-products-service.d.ts +0 -100
  129. package/dist/services/related-products-service.js +0 -127
  130. package/dist/services/sort-service.d.ts +0 -20
  131. package/dist/services/sort-service.js +0 -27
@@ -1,45 +1,97 @@
1
- import { type Category } from "@wix/auto_sdk_categories_categories";
2
- import React, { type ReactNode } from "react";
3
- export interface CategoryListProps {
4
- children: (data: {
5
- categories: Category[];
6
- selectedCategory: string | null;
7
- setSelectedCategory: (categoryId: string | null) => void;
8
- }) => ReactNode;
1
+ import type { PropsWithChildren, ReactNode } from "react";
2
+ import { type CategoryServiceConfig } from "../services/category-service.js";
3
+ /**
4
+ * Root component that provides the Category service context to its children.
5
+ * This component sets up the necessary services for managing category state.
6
+ *
7
+ * @order 1
8
+ * @component
9
+ * @example
10
+ * ```tsx
11
+ * import { Category } from '@wix/stores/components';
12
+ *
13
+ * function CategoryPage() {
14
+ * return (
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>
22
+ * </Category.Root>
23
+ * );
24
+ * }
25
+ * ```
26
+ */
27
+ export declare function Root(props: PropsWithChildren<{
28
+ categoryServiceConfig: CategoryServiceConfig;
29
+ }>): import("react/jsx-runtime").JSX.Element;
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;
9
77
  }
10
78
  /**
11
- * Headless component for displaying a list of categories
79
+ * Headless component for category slug display
12
80
  *
13
81
  * @component
14
82
  * @example
15
83
  * ```tsx
16
84
  * import { Category } from '@wix/stores/components';
17
85
  *
18
- * function CategoryNavigation() {
86
+ * function CategoryInfo() {
19
87
  * return (
20
- * <Category.List>
21
- * {({ categories, selectedCategory, setSelectedCategory }) => (
22
- * <nav>
23
- * <button
24
- * onClick={() => setSelectedCategory(null)}
25
- * className={selectedCategory === null ? 'active' : ''}
26
- * >
27
- * All Categories
28
- * </button>
29
- * {categories.map(category => (
30
- * <button
31
- * key={category.id}
32
- * onClick={() => setSelectedCategory(category.id)}
33
- * className={selectedCategory === category.id ? 'active' : ''}
34
- * >
35
- * {category.name}
36
- * </button>
37
- * ))}
38
- * </nav>
88
+ * <Category.Slug>
89
+ * {({ slug }) => (
90
+ * <p className="category-slug">Category slug: {slug}</p>
39
91
  * )}
40
- * </Category.List>
92
+ * </Category.Slug>
41
93
  * );
42
94
  * }
43
95
  * ```
44
96
  */
45
- export declare const List: React.FC<CategoryListProps>;
97
+ export declare function Slug(props: SlugProps): ReactNode;
@@ -1,48 +1,81 @@
1
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
- import { useService } from "@wix/services-manager-react";
3
- import { CategoryServiceDefinition } from "../services/category-service.js";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createServicesMap } from "@wix/services-manager";
3
+ import { useService, WixServices } from "@wix/services-manager-react";
4
+ import { CategoryService, CategoryServiceDefinition, } from "../services/category-service.js";
4
5
  /**
5
- * Headless component for displaying a list of categories
6
+ * Root component that provides the Category service context to its children.
7
+ * This component sets up the necessary services for managing category state.
6
8
  *
9
+ * @order 1
7
10
  * @component
8
11
  * @example
9
12
  * ```tsx
10
13
  * import { Category } from '@wix/stores/components';
11
14
  *
12
- * function CategoryNavigation() {
15
+ * function CategoryPage() {
13
16
  * return (
14
- * <Category.List>
15
- * {({ categories, selectedCategory, setSelectedCategory }) => (
16
- * <nav>
17
- * <button
18
- * onClick={() => setSelectedCategory(null)}
19
- * className={selectedCategory === null ? 'active' : ''}
20
- * >
21
- * All Categories
22
- * </button>
23
- * {categories.map(category => (
24
- * <button
25
- * key={category.id}
26
- * onClick={() => setSelectedCategory(category.id)}
27
- * className={selectedCategory === category.id ? 'active' : ''}
28
- * >
29
- * {category.name}
30
- * </button>
31
- * ))}
32
- * </nav>
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>
24
+ * </Category.Root>
25
+ * );
26
+ * }
27
+ * ```
28
+ */
29
+ export function Root(props) {
30
+ return (_jsx(WixServices, { servicesMap: createServicesMap().addService(CategoryServiceDefinition, CategoryService, props.categoryServiceConfig), children: props.children }));
31
+ }
32
+ /**
33
+ * Headless component for category name display
34
+ *
35
+ * @component
36
+ * @example
37
+ * ```tsx
38
+ * import { Category } from '@wix/stores/components';
39
+ *
40
+ * function CategoryHeader() {
41
+ * return (
42
+ * <Category.Name>
43
+ * {({ name }) => (
44
+ * <h1 className="category-title">{name}</h1>
45
+ * )}
46
+ * </Category.Name>
47
+ * );
48
+ * }
49
+ * ```
50
+ */
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>
33
70
  * )}
34
- * </Category.List>
71
+ * </Category.Slug>
35
72
  * );
36
73
  * }
37
74
  * ```
38
75
  */
39
- export const List = ({ children }) => {
40
- const service = useService(CategoryServiceDefinition);
41
- const categories = service.categories.get();
42
- const selectedCategory = service.selectedCategory.get();
43
- return (_jsx(_Fragment, { children: children({
44
- selectedCategory,
45
- categories,
46
- setSelectedCategory: service.setSelectedCategory,
47
- }) }));
48
- };
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
+ }
@@ -67,7 +67,7 @@ export interface ProductNameRenderProps {
67
67
  * }
68
68
  * ```
69
69
  */
70
- export declare const Name: (props: ProductNameProps) => import("react").ReactNode;
70
+ export declare function Name(props: ProductNameProps): import("react").ReactNode;
71
71
  /**
72
72
  * Props for ProductDescription headless component
73
73
  */
@@ -123,11 +123,11 @@ export interface ProductDescriptionRenderProps {
123
123
  * }
124
124
  * ```
125
125
  */
126
- export declare const Description: (props: ProductDescriptionProps) => import("react").ReactNode;
126
+ export declare function Description(props: ProductDescriptionProps): import("react").ReactNode;
127
127
  export interface ProductMediaProps {
128
128
  children: (props: ProductMediaRenderProps) => React.ReactNode;
129
129
  }
130
130
  export interface ProductMediaRenderProps {
131
131
  media: ProductMedia[];
132
132
  }
133
- export declare const Media: (props: ProductMediaProps) => import("react").ReactNode;
133
+ export declare function Media(props: ProductMediaProps): import("react").ReactNode;
@@ -54,14 +54,14 @@ export function Root(props) {
54
54
  * }
55
55
  * ```
56
56
  */
57
- export const Name = (props) => {
57
+ export function Name(props) {
58
58
  const service = useService(ProductServiceDefinition);
59
59
  const product = service.product.get();
60
60
  const name = product.name;
61
61
  return props.children({
62
62
  name,
63
63
  });
64
- };
64
+ }
65
65
  /**
66
66
  * Headless component for product description display
67
67
  *
@@ -92,7 +92,7 @@ export const Name = (props) => {
92
92
  * }
93
93
  * ```
94
94
  */
95
- export const Description = (props) => {
95
+ export function Description(props) {
96
96
  const service = useService(ProductServiceDefinition);
97
97
  const product = service.product.get();
98
98
  const descriptionRichContent = product.description;
@@ -101,12 +101,12 @@ export const Description = (props) => {
101
101
  description: descriptionRichContent,
102
102
  plainDescription: plainDescription,
103
103
  });
104
- };
105
- export const Media = (props) => {
104
+ }
105
+ export function Media(props) {
106
106
  const service = useService(ProductServiceDefinition);
107
107
  const product = service.product.get();
108
108
  const media = product.media?.itemsInfo?.items ?? [];
109
109
  return props.children({
110
110
  media,
111
111
  });
112
- };
112
+ }
@@ -67,4 +67,4 @@ export interface ActionsRenderProps {
67
67
  * }
68
68
  * ```
69
69
  */
70
- export declare const Actions: (props: ActionsProps) => import("react").ReactNode;
70
+ export declare function Actions(props: ActionsProps): import("react").ReactNode;
@@ -37,7 +37,7 @@ import { CurrentCartServiceDefinition } from "@wix/headless-ecom/services";
37
37
  * }
38
38
  * ```
39
39
  */
40
- export const Actions = (props) => {
40
+ export function Actions(props) {
41
41
  const variantService = useService(SelectedVariantServiceDefinition);
42
42
  const cartService = useService(CurrentCartServiceDefinition);
43
43
  // Try to get modifiers service - it may not exist for all products
@@ -101,4 +101,4 @@ export const Actions = (props) => {
101
101
  error,
102
102
  availableQuantity,
103
103
  });
104
- };
104
+ }