@wix/headless-stores 0.0.51 → 0.0.53
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/astro/actions/custom-checkout.d.ts +1 -1
- package/cjs/dist/astro/actions/custom-checkout.js +2 -2
- package/cjs/dist/astro/actions/index.d.ts +1 -1
- package/cjs/dist/astro/actions/index.js +1 -1
- package/cjs/dist/enums/index.d.ts +2 -2
- package/cjs/dist/enums/index.js +2 -2
- package/cjs/dist/react/Category.d.ts +168 -67
- package/cjs/dist/react/Category.js +166 -50
- package/cjs/dist/react/CategoryList.d.ts +56 -138
- package/cjs/dist/react/CategoryList.js +44 -129
- package/cjs/dist/react/Choice.d.ts +193 -0
- package/cjs/dist/react/Choice.js +259 -0
- package/cjs/dist/react/Option.d.ts +224 -0
- package/cjs/dist/react/Option.js +388 -0
- package/cjs/dist/react/Product.d.ts +339 -96
- package/cjs/dist/react/Product.js +507 -94
- package/cjs/dist/react/{BuyNow.js → core/BuyNow.js} +2 -2
- package/cjs/dist/react/core/Category.d.ts +98 -0
- package/cjs/dist/react/core/Category.js +81 -0
- package/cjs/dist/react/core/CategoryList.d.ts +185 -0
- package/cjs/dist/react/core/CategoryList.js +174 -0
- package/{dist/react → cjs/dist/react/core}/PayNow.js +2 -2
- package/cjs/dist/react/core/Product.d.ts +148 -0
- package/cjs/dist/react/core/Product.js +126 -0
- package/cjs/dist/react/{ProductList.d.ts → core/ProductList.d.ts} +3 -3
- package/cjs/dist/react/{ProductList.js → core/ProductList.js} +10 -10
- package/{dist/react → cjs/dist/react/core}/ProductListFilters.d.ts +3 -3
- package/{dist/react → cjs/dist/react/core}/ProductListFilters.js +7 -7
- package/cjs/dist/react/{ProductListPagination.js → core/ProductListPagination.js} +8 -8
- package/{dist/react → cjs/dist/react/core}/ProductListSort.d.ts +1 -1
- package/cjs/dist/react/{ProductListSort.js → core/ProductListSort.js} +3 -3
- package/{dist/react → cjs/dist/react/core}/ProductModifiers.d.ts +1 -1
- package/{dist/react → cjs/dist/react/core}/ProductModifiers.js +13 -13
- package/{dist/react → cjs/dist/react/core}/ProductVariantSelector.d.ts +2 -2
- package/{dist/react → cjs/dist/react/core}/ProductVariantSelector.js +7 -10
- package/{dist/react → cjs/dist/react/core}/SelectedVariant.d.ts +2 -2
- package/{dist/react → cjs/dist/react/core}/SelectedVariant.js +43 -15
- package/cjs/dist/react/index.d.ts +15 -10
- package/cjs/dist/react/index.js +15 -10
- package/cjs/dist/react/types.d.ts +8 -0
- package/cjs/dist/react/types.js +9 -0
- package/cjs/dist/server-actions/custom-checkout-action.js +14 -10
- package/cjs/dist/server-actions/index.d.ts +1 -1
- package/cjs/dist/server-actions/index.js +1 -1
- package/cjs/dist/services/buy-now-service.d.ts +1 -1
- package/cjs/dist/services/buy-now-service.js +6 -6
- package/cjs/dist/services/categories-list-service.d.ts +4 -4
- package/cjs/dist/services/categories-list-service.js +10 -10
- package/cjs/dist/services/category-service.d.ts +18 -22
- package/cjs/dist/services/category-service.js +12 -10
- package/cjs/dist/services/index.d.ts +7 -7
- package/cjs/dist/services/index.js +7 -7
- package/cjs/dist/services/pay-now-service.d.ts +1 -1
- package/cjs/dist/services/pay-now-service.js +4 -4
- package/cjs/dist/services/product-modifiers-service.d.ts +3 -3
- package/cjs/dist/services/product-modifiers-service.js +7 -7
- package/cjs/dist/services/product-service.d.ts +4 -4
- package/cjs/dist/services/product-service.js +18 -18
- package/cjs/dist/services/products-list-search-service.d.ts +5 -5
- package/cjs/dist/services/products-list-search-service.js +117 -117
- package/cjs/dist/services/products-list-service.d.ts +4 -4
- package/cjs/dist/services/products-list-service.js +12 -12
- package/cjs/dist/services/selected-variant-service.d.ts +6 -2
- package/cjs/dist/services/selected-variant-service.js +92 -87
- package/cjs/dist/utils/index.d.ts +1 -0
- package/cjs/dist/utils/index.js +5 -4
- package/cjs/dist/utils/renderAsChild.d.ts +96 -0
- package/cjs/dist/utils/renderAsChild.js +66 -0
- package/cjs/dist/utils/renderChildren.d.ts +41 -0
- package/cjs/dist/utils/renderChildren.js +44 -0
- package/cjs/dist/utils/url-params.js +3 -3
- package/dist/astro/actions/custom-checkout.d.ts +1 -1
- package/dist/astro/actions/custom-checkout.js +2 -2
- package/dist/astro/actions/index.d.ts +1 -1
- package/dist/astro/actions/index.js +1 -1
- package/dist/enums/index.d.ts +2 -2
- package/dist/enums/index.js +2 -2
- package/dist/react/Category.d.ts +168 -67
- package/dist/react/Category.js +166 -50
- package/dist/react/CategoryList.d.ts +56 -138
- package/dist/react/CategoryList.js +44 -129
- package/dist/react/Choice.d.ts +193 -0
- package/dist/react/Choice.js +259 -0
- package/dist/react/Option.d.ts +224 -0
- package/dist/react/Option.js +388 -0
- package/dist/react/Product.d.ts +339 -96
- package/dist/react/Product.js +507 -94
- package/dist/react/{BuyNow.js → core/BuyNow.js} +2 -2
- package/dist/react/core/Category.d.ts +98 -0
- package/dist/react/core/Category.js +81 -0
- package/dist/react/core/CategoryList.d.ts +185 -0
- package/dist/react/core/CategoryList.js +174 -0
- package/{cjs/dist/react → dist/react/core}/PayNow.js +2 -2
- package/dist/react/core/Product.d.ts +148 -0
- package/dist/react/core/Product.js +126 -0
- package/dist/react/{ProductList.d.ts → core/ProductList.d.ts} +3 -3
- package/dist/react/{ProductList.js → core/ProductList.js} +10 -10
- package/{cjs/dist/react → dist/react/core}/ProductListFilters.d.ts +3 -3
- package/{cjs/dist/react → dist/react/core}/ProductListFilters.js +7 -7
- package/dist/react/{ProductListPagination.js → core/ProductListPagination.js} +8 -8
- package/{cjs/dist/react → dist/react/core}/ProductListSort.d.ts +1 -1
- package/dist/react/{ProductListSort.js → core/ProductListSort.js} +3 -3
- package/{cjs/dist/react → dist/react/core}/ProductModifiers.d.ts +1 -1
- package/{cjs/dist/react → dist/react/core}/ProductModifiers.js +13 -13
- package/{cjs/dist/react → dist/react/core}/ProductVariantSelector.d.ts +2 -2
- package/{cjs/dist/react → dist/react/core}/ProductVariantSelector.js +7 -10
- package/{cjs/dist/react → dist/react/core}/SelectedVariant.d.ts +2 -2
- package/{cjs/dist/react → dist/react/core}/SelectedVariant.js +43 -15
- package/dist/react/index.d.ts +15 -10
- package/dist/react/index.js +15 -10
- package/dist/react/types.d.ts +8 -0
- package/dist/react/types.js +9 -0
- package/dist/server-actions/custom-checkout-action.js +14 -10
- package/dist/server-actions/index.d.ts +1 -1
- package/dist/server-actions/index.js +1 -1
- package/dist/services/buy-now-service.d.ts +1 -1
- package/dist/services/buy-now-service.js +6 -6
- package/dist/services/categories-list-service.d.ts +4 -4
- package/dist/services/categories-list-service.js +10 -10
- package/dist/services/category-service.d.ts +18 -22
- package/dist/services/category-service.js +12 -10
- package/dist/services/index.d.ts +7 -7
- package/dist/services/index.js +7 -7
- package/dist/services/pay-now-service.d.ts +1 -1
- package/dist/services/pay-now-service.js +4 -4
- package/dist/services/product-modifiers-service.d.ts +3 -3
- package/dist/services/product-modifiers-service.js +7 -7
- package/dist/services/product-service.d.ts +4 -4
- package/dist/services/product-service.js +18 -18
- package/dist/services/products-list-search-service.d.ts +5 -5
- package/dist/services/products-list-search-service.js +117 -117
- package/dist/services/products-list-service.d.ts +4 -4
- package/dist/services/products-list-service.js +12 -12
- package/dist/services/selected-variant-service.d.ts +6 -2
- package/dist/services/selected-variant-service.js +92 -87
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +5 -4
- package/dist/utils/renderAsChild.d.ts +96 -0
- package/dist/utils/renderAsChild.js +66 -0
- package/dist/utils/renderChildren.d.ts +41 -0
- package/dist/utils/renderChildren.js +44 -0
- package/dist/utils/url-params.js +3 -3
- package/package.json +7 -3
- /package/cjs/dist/react/{BuyNow.d.ts → core/BuyNow.d.ts} +0 -0
- /package/cjs/dist/react/{PayNow.d.ts → core/PayNow.d.ts} +0 -0
- /package/cjs/dist/react/{ProductListPagination.d.ts → core/ProductListPagination.d.ts} +0 -0
- /package/dist/react/{BuyNow.d.ts → core/BuyNow.d.ts} +0 -0
- /package/dist/react/{PayNow.d.ts → core/PayNow.d.ts} +0 -0
- /package/dist/react/{ProductListPagination.d.ts → core/ProductListPagination.d.ts} +0 -0
|
@@ -0,0 +1,98 @@
|
|
|
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;
|
|
@@ -0,0 +1,81 @@
|
|
|
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';
|
|
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.
|
|
8
|
+
*
|
|
9
|
+
* @order 1
|
|
10
|
+
* @component
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { CategoryCore } from '@wix/stores/components';
|
|
14
|
+
*
|
|
15
|
+
* function CategoryPage() {
|
|
16
|
+
* return (
|
|
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 { CategoryCore } 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 { CategoryCore } 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,185 @@
|
|
|
1
|
+
import { type CategoriesListServiceConfig } from '../../services/categories-list-service.js';
|
|
2
|
+
import { type Category } from '../../services/category-service.js';
|
|
3
|
+
export interface RootProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
categoriesListConfig: CategoriesListServiceConfig;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Root component that provides the CategoryList service context to its children.
|
|
9
|
+
* This component sets up the necessary services for managing categories list state.
|
|
10
|
+
*
|
|
11
|
+
* @order 1
|
|
12
|
+
* @component
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import { CategoryListCore } from '@wix/stores/components';
|
|
16
|
+
*
|
|
17
|
+
* function CategoriesPage() {
|
|
18
|
+
* return (
|
|
19
|
+
* <CategoryList.Root categoriesListConfig={{ collectionId: 'my-collection' }}>
|
|
20
|
+
* <CategoryList.ItemContent>
|
|
21
|
+
* {({ category }) => (
|
|
22
|
+
* <div key={category._id}>
|
|
23
|
+
* <h2>{category.name}</h2>
|
|
24
|
+
* </div>
|
|
25
|
+
* )}
|
|
26
|
+
* </CategoryList.ItemContent>
|
|
27
|
+
* </CategoryList.Root>
|
|
28
|
+
* );
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function Root(props: RootProps): React.ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* Props for EmptyState headless component
|
|
35
|
+
*/
|
|
36
|
+
export interface EmptyStateProps {
|
|
37
|
+
/** Content to display when categories list is empty (can be a render function or ReactNode) */
|
|
38
|
+
children: ((props: EmptyStateRenderProps) => React.ReactNode) | React.ReactNode;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Render props for EmptyState component
|
|
42
|
+
*/
|
|
43
|
+
export interface EmptyStateRenderProps {
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Component that renders content when the categories list is empty.
|
|
47
|
+
* Only displays its children when there are no categories, no loading state, and no errors.
|
|
48
|
+
*
|
|
49
|
+
* @component
|
|
50
|
+
* @example
|
|
51
|
+
* ```tsx
|
|
52
|
+
* import { CategoryListCore } from '@wix/stores/components';
|
|
53
|
+
*
|
|
54
|
+
* function EmptyCategoriesMessage() {
|
|
55
|
+
* return (
|
|
56
|
+
* <CategoryList.EmptyState>
|
|
57
|
+
* {() => (
|
|
58
|
+
* <div className="empty-state">
|
|
59
|
+
* <h3>No categories found</h3>
|
|
60
|
+
* <p>Categories will appear here once they are created</p>
|
|
61
|
+
* </div>
|
|
62
|
+
* )}
|
|
63
|
+
* </CategoryList.EmptyState>
|
|
64
|
+
* );
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function EmptyState(props: EmptyStateProps): import("react").ReactNode;
|
|
69
|
+
/**
|
|
70
|
+
* Props for Loading headless component
|
|
71
|
+
*/
|
|
72
|
+
export interface LoadingProps {
|
|
73
|
+
/** Content to display during loading (can be a render function or ReactNode) */
|
|
74
|
+
children: ((props: LoadingRenderProps) => React.ReactNode) | React.ReactNode;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Render props for Loading component
|
|
78
|
+
*/
|
|
79
|
+
export interface LoadingRenderProps {
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Component that renders content during loading state.
|
|
83
|
+
* Only displays its children when the categories list is currently loading.
|
|
84
|
+
*
|
|
85
|
+
* @component
|
|
86
|
+
* @example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* import { CategoryListCore } from '@wix/stores/components';
|
|
89
|
+
*
|
|
90
|
+
* function CategoriesLoading() {
|
|
91
|
+
* return (
|
|
92
|
+
* <CategoryList.Loading>
|
|
93
|
+
* {() => (
|
|
94
|
+
* <div className="loading-spinner">
|
|
95
|
+
* <div>Loading categories...</div>
|
|
96
|
+
* <div className="spinner"></div>
|
|
97
|
+
* </div>
|
|
98
|
+
* )}
|
|
99
|
+
* </CategoryList.Loading>
|
|
100
|
+
* );
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare function Loading(props: LoadingProps): import("react").ReactNode;
|
|
105
|
+
/**
|
|
106
|
+
* Props for Error headless component
|
|
107
|
+
*/
|
|
108
|
+
export interface ErrorProps {
|
|
109
|
+
/** Content to display during error state (can be a render function or ReactNode) */
|
|
110
|
+
children: ((props: ErrorRenderProps) => React.ReactNode) | React.ReactNode;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Render props for Error component
|
|
114
|
+
*/
|
|
115
|
+
export interface ErrorRenderProps {
|
|
116
|
+
/** Error message */
|
|
117
|
+
error: string | null;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Component that renders content when there's an error loading categories.
|
|
121
|
+
* Only displays its children when an error has occurred.
|
|
122
|
+
*
|
|
123
|
+
* @component
|
|
124
|
+
* @example
|
|
125
|
+
* ```tsx
|
|
126
|
+
* import { CategoryListCore } from '@wix/stores/components';
|
|
127
|
+
*
|
|
128
|
+
* function CategoriesError() {
|
|
129
|
+
* return (
|
|
130
|
+
* <CategoryList.Error>
|
|
131
|
+
* {({ error }) => (
|
|
132
|
+
* <div className="error-state">
|
|
133
|
+
* <h3>Error loading categories</h3>
|
|
134
|
+
* <p>{error}</p>
|
|
135
|
+
* <button onClick={() => window.location.reload()}>
|
|
136
|
+
* Try Again
|
|
137
|
+
* </button>
|
|
138
|
+
* </div>
|
|
139
|
+
* )}
|
|
140
|
+
* </CategoryList.Error>
|
|
141
|
+
* );
|
|
142
|
+
* }
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export declare function Error(props: ErrorProps): import("react").ReactNode;
|
|
146
|
+
/**
|
|
147
|
+
* Props for ItemContent headless component
|
|
148
|
+
*/
|
|
149
|
+
export interface ItemContentProps {
|
|
150
|
+
/** Content to display for each category (can be a render function receiving category data or ReactNode) */
|
|
151
|
+
children: ((props: ItemContentRenderProps) => React.ReactNode) | React.ReactNode;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Render props for ItemContent component
|
|
155
|
+
*/
|
|
156
|
+
export interface ItemContentRenderProps {
|
|
157
|
+
/** Category data */
|
|
158
|
+
category: Category;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Component that renders content for each category in the list.
|
|
162
|
+
* Maps over all categories and provides each category through a service context.
|
|
163
|
+
* Only renders when categories are successfully loaded (not loading, no error, and has categories).
|
|
164
|
+
*
|
|
165
|
+
* @component
|
|
166
|
+
* @example
|
|
167
|
+
* ```tsx
|
|
168
|
+
* import { CategoryListCore } from '@wix/stores/components';
|
|
169
|
+
*
|
|
170
|
+
* function CategoriesGrid() {
|
|
171
|
+
* return (
|
|
172
|
+
* <CategoryList.ItemContent>
|
|
173
|
+
* {({ category }) => (
|
|
174
|
+
* <div className="category-card">
|
|
175
|
+
* <h3>{category.name}</h3>
|
|
176
|
+
* <p>{category.description}</p>
|
|
177
|
+
* <a href={`/categories/${category.slug}`}>View Category</a>
|
|
178
|
+
* </div>
|
|
179
|
+
* )}
|
|
180
|
+
* </CategoryList.ItemContent>
|
|
181
|
+
* );
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
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 { CategoryListCore } 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 { CategoryListCore } 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 { CategoryListCore } 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 { CategoryListCore } 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 { CategoryListCore } 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
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useService } from
|
|
2
|
-
import { PayNowServiceDefinition } from
|
|
1
|
+
import { useService } from '@wix/services-manager-react';
|
|
2
|
+
import { PayNowServiceDefinition } from '../../services/pay-now-service.js';
|
|
3
3
|
/**
|
|
4
4
|
* A headless component that provides pay now functionality using the render props pattern.
|
|
5
5
|
*
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { ProductServiceConfig } from '../../services/product-service.js';
|
|
2
|
+
import type { V3Product, ProductMedia } from '@wix/auto_sdk_stores_products-v-3';
|
|
3
|
+
export interface RootProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
productServiceConfig: ProductServiceConfig;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Root component that provides the Product service context to its children.
|
|
9
|
+
* This component sets up the necessary services for rendering and managing a single product's data.
|
|
10
|
+
*
|
|
11
|
+
* @order 1
|
|
12
|
+
* @component
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import { Product } from '@wix/stores/components';
|
|
16
|
+
*
|
|
17
|
+
* function ProductPage() {
|
|
18
|
+
* return (
|
|
19
|
+
* <Product.Root productServiceConfig={{ product: myProduct }}>
|
|
20
|
+
* <div>
|
|
21
|
+
* <Product.Name>
|
|
22
|
+
* {({ name }) => (
|
|
23
|
+
* <h1
|
|
24
|
+
* className="text-4xl font-bold text-content-primary mb-4"
|
|
25
|
+
* data-testid="product-name"
|
|
26
|
+
* >
|
|
27
|
+
* {name}
|
|
28
|
+
* </h1>
|
|
29
|
+
* )}
|
|
30
|
+
* </Product.Name>
|
|
31
|
+
* </div>
|
|
32
|
+
* </Product.Root>
|
|
33
|
+
* );
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function Root(props: RootProps): React.ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Props for ProductName headless component
|
|
40
|
+
*/
|
|
41
|
+
export interface ProductNameProps {
|
|
42
|
+
/** Render prop function that receives product name data */
|
|
43
|
+
children: (props: ProductNameRenderProps) => React.ReactNode;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Render props for ProductName component
|
|
47
|
+
*/
|
|
48
|
+
export interface ProductNameRenderProps {
|
|
49
|
+
/** Product name */
|
|
50
|
+
name: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Headless component for product name display
|
|
54
|
+
*
|
|
55
|
+
* @component
|
|
56
|
+
* @example
|
|
57
|
+
* ```tsx
|
|
58
|
+
* import { Product } from '@wix/stores/components';
|
|
59
|
+
*
|
|
60
|
+
* function ProductHeader() {
|
|
61
|
+
* return (
|
|
62
|
+
* <Product.Name>
|
|
63
|
+
* {({ name }) => (
|
|
64
|
+
* <h1>{name}</h1>
|
|
65
|
+
* )}
|
|
66
|
+
* </Product.Name>
|
|
67
|
+
* );
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare function Name(props: ProductNameProps): import("react").ReactNode;
|
|
72
|
+
/**
|
|
73
|
+
* Props for ProductDescription headless component
|
|
74
|
+
*/
|
|
75
|
+
export interface ProductDescriptionProps {
|
|
76
|
+
/** Render prop function that receives product description data */
|
|
77
|
+
children: (props: ProductDescriptionRenderProps) => React.ReactNode;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Render props for ProductDescription component
|
|
81
|
+
*/
|
|
82
|
+
export interface ProductDescriptionRenderProps {
|
|
83
|
+
/** Product description using the RICOS (Rich Content Object) format. See https://dev.wix.com/docs/ricos/api-reference/ricos-document */
|
|
84
|
+
description: NonNullable<V3Product['description']>;
|
|
85
|
+
/** Product description with plain html */
|
|
86
|
+
plainDescription: NonNullable<V3Product['plainDescription']>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Render props for ProductDescription component
|
|
90
|
+
*/
|
|
91
|
+
export interface ProductDescriptionRenderProps {
|
|
92
|
+
/** Product description using the RICOS (Rich Content Object) format. See https://dev.wix.com/docs/ricos/api-reference/ricos-document */
|
|
93
|
+
description: NonNullable<V3Product['description']>;
|
|
94
|
+
/** Product description with plain html */
|
|
95
|
+
plainDescription: NonNullable<V3Product['plainDescription']>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Headless component for product description display
|
|
99
|
+
*
|
|
100
|
+
* @component
|
|
101
|
+
* @example
|
|
102
|
+
* ```tsx
|
|
103
|
+
* import { Product } from '@wix/stores/components';
|
|
104
|
+
*
|
|
105
|
+
* function ProductDescription() {
|
|
106
|
+
* return (
|
|
107
|
+
* <Product.Description>
|
|
108
|
+
* {({ plainDescription, description }) => (
|
|
109
|
+
* <div>
|
|
110
|
+
* {plainDescription && (
|
|
111
|
+
* <div
|
|
112
|
+
* dangerouslySetInnerHTML={{
|
|
113
|
+
* __html: plainDescription,
|
|
114
|
+
* }}
|
|
115
|
+
* />
|
|
116
|
+
* )}
|
|
117
|
+
* {description && (
|
|
118
|
+
* <div>Rich content description available</div>
|
|
119
|
+
* )}
|
|
120
|
+
* </div>
|
|
121
|
+
* )}
|
|
122
|
+
* </Product.Description>
|
|
123
|
+
* );
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare function Description(props: ProductDescriptionProps): import("react").ReactNode;
|
|
128
|
+
export interface ProductMediaProps {
|
|
129
|
+
children: (props: ProductMediaRenderProps) => React.ReactNode;
|
|
130
|
+
}
|
|
131
|
+
export interface ProductMediaRenderProps {
|
|
132
|
+
media: ProductMedia[];
|
|
133
|
+
}
|
|
134
|
+
export declare function Media(props: ProductMediaProps): import("react").ReactNode;
|
|
135
|
+
export interface ProductProps {
|
|
136
|
+
children: (props: ProductRenderProps) => React.ReactNode;
|
|
137
|
+
}
|
|
138
|
+
export interface ProductRenderProps {
|
|
139
|
+
product: V3Product;
|
|
140
|
+
}
|
|
141
|
+
export declare function Content(props: ProductProps): import("react").ReactNode;
|
|
142
|
+
export interface LoadingProps {
|
|
143
|
+
children: (props: LoadingRenderProps) => React.ReactNode;
|
|
144
|
+
}
|
|
145
|
+
export interface LoadingRenderProps {
|
|
146
|
+
isLoading: boolean;
|
|
147
|
+
}
|
|
148
|
+
export declare function Loading(props: LoadingProps): import("react").ReactNode;
|