@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.
- package/cjs/dist/react/Category.d.ts +83 -31
- package/cjs/dist/react/Category.js +68 -35
- package/cjs/dist/react/CategoryList.d.ts +184 -0
- package/cjs/dist/react/CategoryList.js +174 -0
- package/cjs/dist/react/Product.d.ts +3 -3
- package/cjs/dist/react/Product.js +6 -6
- package/cjs/dist/react/ProductActions.d.ts +1 -1
- package/cjs/dist/react/ProductActions.js +2 -2
- package/{dist/react/ProductsList.d.ts → cjs/dist/react/ProductList.d.ts} +71 -38
- package/{dist/react/ProductsList.js → cjs/dist/react/ProductList.js} +30 -26
- package/cjs/dist/react/ProductListFilters.d.ts +244 -0
- package/cjs/dist/react/ProductListFilters.js +216 -0
- package/cjs/dist/react/ProductListPagination.d.ts +246 -0
- package/cjs/dist/react/ProductListPagination.js +207 -0
- package/cjs/dist/react/ProductListSort.d.ts +87 -0
- package/cjs/dist/react/ProductListSort.js +85 -0
- package/cjs/dist/react/ProductModifiers.d.ts +5 -5
- package/cjs/dist/react/ProductModifiers.js +10 -10
- package/cjs/dist/react/ProductVariantSelector.d.ts +5 -5
- package/cjs/dist/react/ProductVariantSelector.js +13 -10
- package/cjs/dist/react/SelectedVariant.d.ts +3 -3
- package/cjs/dist/react/SelectedVariant.js +6 -6
- package/cjs/dist/react/index.d.ts +7 -9
- package/cjs/dist/react/index.js +7 -9
- package/cjs/dist/services/buy-now-service.d.ts +208 -0
- package/cjs/dist/services/buy-now-service.js +132 -1
- package/cjs/dist/services/categories-list-service.d.ts +163 -0
- package/cjs/dist/services/categories-list-service.js +148 -0
- package/cjs/dist/services/category-service.d.ts +115 -70
- package/cjs/dist/services/category-service.js +101 -110
- package/cjs/dist/services/index.d.ts +6 -7
- package/cjs/dist/services/index.js +5 -16
- package/cjs/dist/services/pay-now-service.d.ts +146 -0
- package/cjs/dist/services/pay-now-service.js +112 -1
- package/cjs/dist/services/product-service.d.ts +71 -0
- package/cjs/dist/services/product-service.js +47 -0
- package/cjs/dist/services/products-list-filters-service.d.ts +292 -0
- package/cjs/dist/services/products-list-filters-service.js +446 -0
- package/cjs/dist/services/products-list-pagination-service.d.ts +186 -0
- package/cjs/dist/services/products-list-pagination-service.js +179 -0
- package/cjs/dist/services/products-list-service.d.ts +138 -52
- package/cjs/dist/services/products-list-service.js +98 -51
- package/cjs/dist/services/products-list-sort-service.d.ts +117 -0
- package/cjs/dist/services/products-list-sort-service.js +144 -0
- package/cjs/dist/services/selected-variant-service.js +0 -1
- package/cjs/dist/utils/url-params.d.ts +68 -0
- package/cjs/dist/utils/url-params.js +72 -4
- package/dist/react/Category.d.ts +83 -31
- package/dist/react/Category.js +68 -35
- package/dist/react/CategoryList.d.ts +184 -0
- package/dist/react/CategoryList.js +174 -0
- package/dist/react/Product.d.ts +3 -3
- package/dist/react/Product.js +6 -6
- package/dist/react/ProductActions.d.ts +1 -1
- package/dist/react/ProductActions.js +2 -2
- package/{cjs/dist/react/ProductsList.d.ts → dist/react/ProductList.d.ts} +71 -38
- package/{cjs/dist/react/ProductsList.js → dist/react/ProductList.js} +30 -26
- package/dist/react/ProductListFilters.d.ts +244 -0
- package/dist/react/ProductListFilters.js +216 -0
- package/dist/react/ProductListPagination.d.ts +246 -0
- package/dist/react/ProductListPagination.js +207 -0
- package/dist/react/ProductListSort.d.ts +87 -0
- package/dist/react/ProductListSort.js +85 -0
- package/dist/react/ProductModifiers.d.ts +5 -5
- package/dist/react/ProductModifiers.js +10 -10
- package/dist/react/ProductVariantSelector.d.ts +5 -5
- package/dist/react/ProductVariantSelector.js +13 -10
- package/dist/react/SelectedVariant.d.ts +3 -3
- package/dist/react/SelectedVariant.js +6 -6
- package/dist/react/index.d.ts +7 -9
- package/dist/react/index.js +7 -9
- package/dist/services/buy-now-service.d.ts +208 -0
- package/dist/services/buy-now-service.js +132 -1
- package/dist/services/categories-list-service.d.ts +163 -0
- package/dist/services/categories-list-service.js +148 -0
- package/dist/services/category-service.d.ts +115 -70
- package/dist/services/category-service.js +101 -110
- package/dist/services/index.d.ts +6 -7
- package/dist/services/index.js +5 -16
- package/dist/services/pay-now-service.d.ts +146 -0
- package/dist/services/pay-now-service.js +112 -1
- package/dist/services/product-service.d.ts +71 -0
- package/dist/services/product-service.js +47 -0
- package/dist/services/products-list-filters-service.d.ts +292 -0
- package/dist/services/products-list-filters-service.js +446 -0
- package/dist/services/products-list-pagination-service.d.ts +186 -0
- package/dist/services/products-list-pagination-service.js +179 -0
- package/dist/services/products-list-service.d.ts +138 -52
- package/dist/services/products-list-service.js +98 -51
- package/dist/services/products-list-sort-service.d.ts +117 -0
- package/dist/services/products-list-sort-service.js +144 -0
- package/dist/services/selected-variant-service.js +0 -1
- package/dist/utils/url-params.d.ts +68 -0
- package/dist/utils/url-params.js +72 -4
- package/package.json +3 -3
- package/cjs/dist/react/Collection.d.ts +0 -294
- package/cjs/dist/react/Collection.js +0 -345
- package/cjs/dist/react/FilteredCollection.d.ts +0 -216
- package/cjs/dist/react/FilteredCollection.js +0 -256
- package/cjs/dist/react/RelatedProducts.d.ts +0 -169
- package/cjs/dist/react/RelatedProducts.js +0 -180
- package/cjs/dist/react/Sort.d.ts +0 -37
- package/cjs/dist/react/Sort.js +0 -36
- package/cjs/dist/services/catalog-service.d.ts +0 -36
- package/cjs/dist/services/catalog-service.js +0 -193
- package/cjs/dist/services/collection-service.d.ts +0 -124
- package/cjs/dist/services/collection-service.js +0 -628
- package/cjs/dist/services/filter-service.d.ts +0 -35
- package/cjs/dist/services/filter-service.js +0 -119
- package/cjs/dist/services/related-products-service.d.ts +0 -100
- package/cjs/dist/services/related-products-service.js +0 -127
- package/cjs/dist/services/sort-service.d.ts +0 -20
- package/cjs/dist/services/sort-service.js +0 -27
- package/dist/react/Collection.d.ts +0 -294
- package/dist/react/Collection.js +0 -345
- package/dist/react/FilteredCollection.d.ts +0 -216
- package/dist/react/FilteredCollection.js +0 -256
- package/dist/react/RelatedProducts.d.ts +0 -169
- package/dist/react/RelatedProducts.js +0 -180
- package/dist/react/Sort.d.ts +0 -37
- package/dist/react/Sort.js +0 -36
- package/dist/services/catalog-service.d.ts +0 -36
- package/dist/services/catalog-service.js +0 -193
- package/dist/services/collection-service.d.ts +0 -124
- package/dist/services/collection-service.js +0 -628
- package/dist/services/filter-service.d.ts +0 -35
- package/dist/services/filter-service.js +0 -119
- package/dist/services/related-products-service.d.ts +0 -100
- package/dist/services/related-products-service.js +0 -127
- package/dist/services/sort-service.d.ts +0 -20
- package/dist/services/sort-service.js +0 -27
|
@@ -1,45 +1,97 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
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
|
|
86
|
+
* function CategoryInfo() {
|
|
19
87
|
* return (
|
|
20
|
-
* <Category.
|
|
21
|
-
* {({
|
|
22
|
-
* <
|
|
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.
|
|
92
|
+
* </Category.Slug>
|
|
41
93
|
* );
|
|
42
94
|
* }
|
|
43
95
|
* ```
|
|
44
96
|
*/
|
|
45
|
-
export declare
|
|
97
|
+
export declare function Slug(props: SlugProps): ReactNode;
|
|
@@ -1,48 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
-
*
|
|
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
|
|
15
|
+
* function CategoryPage() {
|
|
13
16
|
* return (
|
|
14
|
-
* <Category.
|
|
15
|
-
*
|
|
16
|
-
* <
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
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.
|
|
71
|
+
* </Category.Slug>
|
|
35
72
|
* );
|
|
36
73
|
* }
|
|
37
74
|
* ```
|
|
38
75
|
*/
|
|
39
|
-
export
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
+
}
|
|
@@ -37,7 +37,7 @@ import { CurrentCartServiceDefinition } from "@wix/headless-ecom/services";
|
|
|
37
37
|
* }
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
|
-
export
|
|
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
|
+
}
|