@wix/headless-stores 0.0.28 → 0.0.30
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/ProductsList.d.ts +35 -42
- package/cjs/dist/react/ProductsList.js +1 -16
- package/cjs/dist/services/products-list-service.d.ts +2 -2
- package/cjs/dist/services/products-list-service.js +1 -0
- package/dist/react/ProductsList.d.ts +35 -42
- package/dist/react/ProductsList.js +1 -16
- package/dist/services/products-list-service.d.ts +2 -2
- package/dist/services/products-list-service.js +1 -0
- package/package.json +1 -1
|
@@ -1,77 +1,70 @@
|
|
|
1
1
|
import { type ProductsListServiceConfig } from "../services/products-list-service.js";
|
|
2
|
-
import type { PropsWithChildren, ReactNode } from "react";
|
|
3
2
|
import { productsV3 } from "@wix/stores";
|
|
3
|
+
export interface RootProps {
|
|
4
|
+
/** Child components that will have access to the ProductsList service */
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/** Configuration for the ProductsList service */
|
|
7
|
+
productsListConfig: ProductsListServiceConfig;
|
|
8
|
+
}
|
|
4
9
|
/**
|
|
5
10
|
* Root component that provides the ProductsList service context to its children.
|
|
6
11
|
* This component sets up the necessary services for managing products list state.
|
|
7
12
|
*
|
|
8
13
|
* @component
|
|
9
|
-
* @param props - Component props
|
|
10
|
-
* @param props.children - Child components that will have access to the ProductsList service
|
|
11
|
-
* @param props.productsListConfig - Configuration for the ProductsList service
|
|
12
|
-
* @returns JSX element wrapping children with ProductsList service context
|
|
13
14
|
*/
|
|
14
|
-
export declare function Root(props:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
export declare function Root(props: RootProps): React.ReactNode;
|
|
16
|
+
export interface EmptyStateProps {
|
|
17
|
+
/** Content to display when products list is empty (can be a render function or ReactNode) */
|
|
18
|
+
children: (props: EmptyStateRenderProps) => React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export interface EmptyStateRenderProps {
|
|
21
|
+
}
|
|
21
22
|
/**
|
|
22
23
|
* Component that renders content when the products list is empty.
|
|
23
24
|
* Only displays its children when there are no products, no loading state, and no errors.
|
|
24
25
|
*
|
|
25
26
|
* @component
|
|
26
|
-
* @param props - Component props
|
|
27
|
-
* @param props.children - Content to display when products list is empty (can be a render function or ReactNode)
|
|
28
|
-
* @returns JSX element or null based on products list state
|
|
29
27
|
*/
|
|
30
|
-
export declare function EmptyState(props: EmptyStateProps): ReactNode;
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
export declare function EmptyState(props: EmptyStateProps): React.ReactNode;
|
|
29
|
+
export interface LoadingProps {
|
|
30
|
+
/** Content to display during loading (can be a render function or ReactNode) */
|
|
31
|
+
children: (props: LoadingRenderProps) => React.ReactNode;
|
|
32
|
+
}
|
|
33
|
+
export interface LoadingRenderProps {
|
|
34
|
+
}
|
|
35
35
|
/**
|
|
36
36
|
* Component that renders content during loading state.
|
|
37
37
|
* Only displays its children when the products list is currently loading.
|
|
38
38
|
*
|
|
39
39
|
* @component
|
|
40
|
-
* @param props - Component props
|
|
41
|
-
* @param props.children - Content to display during loading (can be a render function or ReactNode)
|
|
42
|
-
* @returns JSX element or null based on loading state
|
|
43
40
|
*/
|
|
44
|
-
export declare function Loading(props: LoadingProps): ReactNode;
|
|
45
|
-
export
|
|
46
|
-
children: ((props: ErrorRenderProps) => ReactNode) | ReactNode;
|
|
47
|
-
};
|
|
48
|
-
export type ErrorRenderProps = {
|
|
41
|
+
export declare function Loading(props: LoadingProps): React.ReactNode;
|
|
42
|
+
export interface ErrorRenderProps {
|
|
49
43
|
error: string | null;
|
|
50
|
-
}
|
|
44
|
+
}
|
|
45
|
+
export interface ErrorProps {
|
|
46
|
+
/** Content to display during error state (can be a render function or ReactNode) */
|
|
47
|
+
children: (props: ErrorRenderProps) => React.ReactNode;
|
|
48
|
+
}
|
|
51
49
|
/**
|
|
52
50
|
* Component that renders content when there's an error loading products.
|
|
53
51
|
* Only displays its children when an error has occurred.
|
|
54
52
|
*
|
|
55
53
|
* @component
|
|
56
|
-
* @param props - Component props
|
|
57
|
-
* @param props.children - Content to display during error state (can be a render function or ReactNode)
|
|
58
|
-
* @returns JSX element or null based on error state
|
|
59
54
|
*/
|
|
60
|
-
export declare function Error(props: ErrorProps): ReactNode;
|
|
61
|
-
export
|
|
55
|
+
export declare function Error(props: ErrorProps): React.ReactNode;
|
|
56
|
+
export interface ItemContentRenderProps {
|
|
62
57
|
product: productsV3.V3Product;
|
|
63
|
-
}
|
|
64
|
-
export
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
}
|
|
59
|
+
export interface ItemContentProps {
|
|
60
|
+
/** Content to display for each product (can be a render function receiving product data or ReactNode) */
|
|
61
|
+
children: (props: ItemContentRenderProps) => React.ReactNode;
|
|
62
|
+
}
|
|
67
63
|
/**
|
|
68
64
|
* Component that renders content for each product in the list.
|
|
69
65
|
* Maps over all products and provides each product through a service context.
|
|
70
66
|
* Only renders when products are successfully loaded (not loading, no error, and has products).
|
|
71
67
|
*
|
|
72
68
|
* @component
|
|
73
|
-
* @param props - Component props
|
|
74
|
-
* @param props.children - Content to display for each product (can be a render function receiving product data or ReactNode)
|
|
75
|
-
* @returns Array of JSX elements for each product or null if no products to display
|
|
76
69
|
*/
|
|
77
|
-
export declare function ItemContent(props: ItemContentProps):
|
|
70
|
+
export declare function ItemContent(props: ItemContentProps): React.ReactNode;
|
|
@@ -8,10 +8,6 @@ import { ProductService, ProductServiceDefinition, } from "@wix/headless-stores/
|
|
|
8
8
|
* This component sets up the necessary services for managing products list state.
|
|
9
9
|
*
|
|
10
10
|
* @component
|
|
11
|
-
* @param props - Component props
|
|
12
|
-
* @param props.children - Child components that will have access to the ProductsList service
|
|
13
|
-
* @param props.productsListConfig - Configuration for the ProductsList service
|
|
14
|
-
* @returns JSX element wrapping children with ProductsList service context
|
|
15
11
|
*/
|
|
16
12
|
export function Root(props) {
|
|
17
13
|
return (_jsx(WixServices, { servicesMap: createServicesMap().addService(ProductsListServiceDefinition, ProductListService, props.productsListConfig), children: props.children }));
|
|
@@ -21,9 +17,6 @@ export function Root(props) {
|
|
|
21
17
|
* Only displays its children when there are no products, no loading state, and no errors.
|
|
22
18
|
*
|
|
23
19
|
* @component
|
|
24
|
-
* @param props - Component props
|
|
25
|
-
* @param props.children - Content to display when products list is empty (can be a render function or ReactNode)
|
|
26
|
-
* @returns JSX element or null based on products list state
|
|
27
20
|
*/
|
|
28
21
|
export function EmptyState(props) {
|
|
29
22
|
const { isLoading, error, products } = useService(ProductsListServiceDefinition);
|
|
@@ -42,9 +35,6 @@ export function EmptyState(props) {
|
|
|
42
35
|
* Only displays its children when the products list is currently loading.
|
|
43
36
|
*
|
|
44
37
|
* @component
|
|
45
|
-
* @param props - Component props
|
|
46
|
-
* @param props.children - Content to display during loading (can be a render function or ReactNode)
|
|
47
|
-
* @returns JSX element or null based on loading state
|
|
48
38
|
*/
|
|
49
39
|
export function Loading(props) {
|
|
50
40
|
const { isLoading } = useService(ProductsListServiceDefinition);
|
|
@@ -56,14 +46,12 @@ export function Loading(props) {
|
|
|
56
46
|
}
|
|
57
47
|
return null;
|
|
58
48
|
}
|
|
49
|
+
;
|
|
59
50
|
/**
|
|
60
51
|
* Component that renders content when there's an error loading products.
|
|
61
52
|
* Only displays its children when an error has occurred.
|
|
62
53
|
*
|
|
63
54
|
* @component
|
|
64
|
-
* @param props - Component props
|
|
65
|
-
* @param props.children - Content to display during error state (can be a render function or ReactNode)
|
|
66
|
-
* @returns JSX element or null based on error state
|
|
67
55
|
*/
|
|
68
56
|
export function Error(props) {
|
|
69
57
|
const { error } = useService(ProductsListServiceDefinition);
|
|
@@ -81,9 +69,6 @@ export function Error(props) {
|
|
|
81
69
|
* Only renders when products are successfully loaded (not loading, no error, and has products).
|
|
82
70
|
*
|
|
83
71
|
* @component
|
|
84
|
-
* @param props - Component props
|
|
85
|
-
* @param props.children - Content to display for each product (can be a render function receiving product data or ReactNode)
|
|
86
|
-
* @returns Array of JSX elements for each product or null if no products to display
|
|
87
72
|
*/
|
|
88
73
|
export function ItemContent(props) {
|
|
89
74
|
const { products, isLoading, error } = useService(ProductsListServiceDefinition);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type Signal } from "@wix/services-definitions/core-services/signals";
|
|
2
2
|
import { productsV3 } from "@wix/stores";
|
|
3
|
-
export
|
|
3
|
+
export interface ProductsListServiceConfig {
|
|
4
4
|
products: productsV3.V3Product[];
|
|
5
5
|
searchOptions: Parameters<typeof productsV3.searchProducts>[0];
|
|
6
6
|
pagingMetadata: productsV3.CommonCursorPagingMetadata;
|
|
7
7
|
aggregations: productsV3.AggregationData;
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
9
|
export declare function loadProductsListServiceConfig(searchOptions: Parameters<typeof productsV3.searchProducts>[0]): Promise<ProductsListServiceConfig>;
|
|
10
10
|
export declare const ProductsListServiceDefinition: string & {
|
|
11
11
|
__api: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineService, implementService } from "@wix/services-definitions";
|
|
2
2
|
import { SignalsServiceDefinition, } from "@wix/services-definitions/core-services/signals";
|
|
3
3
|
import { productsV3 } from "@wix/stores";
|
|
4
|
+
;
|
|
4
5
|
export async function loadProductsListServiceConfig(searchOptions) {
|
|
5
6
|
const result = await productsV3.searchProducts(searchOptions);
|
|
6
7
|
return {
|
|
@@ -1,77 +1,70 @@
|
|
|
1
1
|
import { type ProductsListServiceConfig } from "../services/products-list-service.js";
|
|
2
|
-
import type { PropsWithChildren, ReactNode } from "react";
|
|
3
2
|
import { productsV3 } from "@wix/stores";
|
|
3
|
+
export interface RootProps {
|
|
4
|
+
/** Child components that will have access to the ProductsList service */
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/** Configuration for the ProductsList service */
|
|
7
|
+
productsListConfig: ProductsListServiceConfig;
|
|
8
|
+
}
|
|
4
9
|
/**
|
|
5
10
|
* Root component that provides the ProductsList service context to its children.
|
|
6
11
|
* This component sets up the necessary services for managing products list state.
|
|
7
12
|
*
|
|
8
13
|
* @component
|
|
9
|
-
* @param props - Component props
|
|
10
|
-
* @param props.children - Child components that will have access to the ProductsList service
|
|
11
|
-
* @param props.productsListConfig - Configuration for the ProductsList service
|
|
12
|
-
* @returns JSX element wrapping children with ProductsList service context
|
|
13
14
|
*/
|
|
14
|
-
export declare function Root(props:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
export declare function Root(props: RootProps): React.ReactNode;
|
|
16
|
+
export interface EmptyStateProps {
|
|
17
|
+
/** Content to display when products list is empty (can be a render function or ReactNode) */
|
|
18
|
+
children: (props: EmptyStateRenderProps) => React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export interface EmptyStateRenderProps {
|
|
21
|
+
}
|
|
21
22
|
/**
|
|
22
23
|
* Component that renders content when the products list is empty.
|
|
23
24
|
* Only displays its children when there are no products, no loading state, and no errors.
|
|
24
25
|
*
|
|
25
26
|
* @component
|
|
26
|
-
* @param props - Component props
|
|
27
|
-
* @param props.children - Content to display when products list is empty (can be a render function or ReactNode)
|
|
28
|
-
* @returns JSX element or null based on products list state
|
|
29
27
|
*/
|
|
30
|
-
export declare function EmptyState(props: EmptyStateProps): ReactNode;
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
export declare function EmptyState(props: EmptyStateProps): React.ReactNode;
|
|
29
|
+
export interface LoadingProps {
|
|
30
|
+
/** Content to display during loading (can be a render function or ReactNode) */
|
|
31
|
+
children: (props: LoadingRenderProps) => React.ReactNode;
|
|
32
|
+
}
|
|
33
|
+
export interface LoadingRenderProps {
|
|
34
|
+
}
|
|
35
35
|
/**
|
|
36
36
|
* Component that renders content during loading state.
|
|
37
37
|
* Only displays its children when the products list is currently loading.
|
|
38
38
|
*
|
|
39
39
|
* @component
|
|
40
|
-
* @param props - Component props
|
|
41
|
-
* @param props.children - Content to display during loading (can be a render function or ReactNode)
|
|
42
|
-
* @returns JSX element or null based on loading state
|
|
43
40
|
*/
|
|
44
|
-
export declare function Loading(props: LoadingProps): ReactNode;
|
|
45
|
-
export
|
|
46
|
-
children: ((props: ErrorRenderProps) => ReactNode) | ReactNode;
|
|
47
|
-
};
|
|
48
|
-
export type ErrorRenderProps = {
|
|
41
|
+
export declare function Loading(props: LoadingProps): React.ReactNode;
|
|
42
|
+
export interface ErrorRenderProps {
|
|
49
43
|
error: string | null;
|
|
50
|
-
}
|
|
44
|
+
}
|
|
45
|
+
export interface ErrorProps {
|
|
46
|
+
/** Content to display during error state (can be a render function or ReactNode) */
|
|
47
|
+
children: (props: ErrorRenderProps) => React.ReactNode;
|
|
48
|
+
}
|
|
51
49
|
/**
|
|
52
50
|
* Component that renders content when there's an error loading products.
|
|
53
51
|
* Only displays its children when an error has occurred.
|
|
54
52
|
*
|
|
55
53
|
* @component
|
|
56
|
-
* @param props - Component props
|
|
57
|
-
* @param props.children - Content to display during error state (can be a render function or ReactNode)
|
|
58
|
-
* @returns JSX element or null based on error state
|
|
59
54
|
*/
|
|
60
|
-
export declare function Error(props: ErrorProps): ReactNode;
|
|
61
|
-
export
|
|
55
|
+
export declare function Error(props: ErrorProps): React.ReactNode;
|
|
56
|
+
export interface ItemContentRenderProps {
|
|
62
57
|
product: productsV3.V3Product;
|
|
63
|
-
}
|
|
64
|
-
export
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
}
|
|
59
|
+
export interface ItemContentProps {
|
|
60
|
+
/** Content to display for each product (can be a render function receiving product data or ReactNode) */
|
|
61
|
+
children: (props: ItemContentRenderProps) => React.ReactNode;
|
|
62
|
+
}
|
|
67
63
|
/**
|
|
68
64
|
* Component that renders content for each product in the list.
|
|
69
65
|
* Maps over all products and provides each product through a service context.
|
|
70
66
|
* Only renders when products are successfully loaded (not loading, no error, and has products).
|
|
71
67
|
*
|
|
72
68
|
* @component
|
|
73
|
-
* @param props - Component props
|
|
74
|
-
* @param props.children - Content to display for each product (can be a render function receiving product data or ReactNode)
|
|
75
|
-
* @returns Array of JSX elements for each product or null if no products to display
|
|
76
69
|
*/
|
|
77
|
-
export declare function ItemContent(props: ItemContentProps):
|
|
70
|
+
export declare function ItemContent(props: ItemContentProps): React.ReactNode;
|
|
@@ -8,10 +8,6 @@ import { ProductService, ProductServiceDefinition, } from "@wix/headless-stores/
|
|
|
8
8
|
* This component sets up the necessary services for managing products list state.
|
|
9
9
|
*
|
|
10
10
|
* @component
|
|
11
|
-
* @param props - Component props
|
|
12
|
-
* @param props.children - Child components that will have access to the ProductsList service
|
|
13
|
-
* @param props.productsListConfig - Configuration for the ProductsList service
|
|
14
|
-
* @returns JSX element wrapping children with ProductsList service context
|
|
15
11
|
*/
|
|
16
12
|
export function Root(props) {
|
|
17
13
|
return (_jsx(WixServices, { servicesMap: createServicesMap().addService(ProductsListServiceDefinition, ProductListService, props.productsListConfig), children: props.children }));
|
|
@@ -21,9 +17,6 @@ export function Root(props) {
|
|
|
21
17
|
* Only displays its children when there are no products, no loading state, and no errors.
|
|
22
18
|
*
|
|
23
19
|
* @component
|
|
24
|
-
* @param props - Component props
|
|
25
|
-
* @param props.children - Content to display when products list is empty (can be a render function or ReactNode)
|
|
26
|
-
* @returns JSX element or null based on products list state
|
|
27
20
|
*/
|
|
28
21
|
export function EmptyState(props) {
|
|
29
22
|
const { isLoading, error, products } = useService(ProductsListServiceDefinition);
|
|
@@ -42,9 +35,6 @@ export function EmptyState(props) {
|
|
|
42
35
|
* Only displays its children when the products list is currently loading.
|
|
43
36
|
*
|
|
44
37
|
* @component
|
|
45
|
-
* @param props - Component props
|
|
46
|
-
* @param props.children - Content to display during loading (can be a render function or ReactNode)
|
|
47
|
-
* @returns JSX element or null based on loading state
|
|
48
38
|
*/
|
|
49
39
|
export function Loading(props) {
|
|
50
40
|
const { isLoading } = useService(ProductsListServiceDefinition);
|
|
@@ -56,14 +46,12 @@ export function Loading(props) {
|
|
|
56
46
|
}
|
|
57
47
|
return null;
|
|
58
48
|
}
|
|
49
|
+
;
|
|
59
50
|
/**
|
|
60
51
|
* Component that renders content when there's an error loading products.
|
|
61
52
|
* Only displays its children when an error has occurred.
|
|
62
53
|
*
|
|
63
54
|
* @component
|
|
64
|
-
* @param props - Component props
|
|
65
|
-
* @param props.children - Content to display during error state (can be a render function or ReactNode)
|
|
66
|
-
* @returns JSX element or null based on error state
|
|
67
55
|
*/
|
|
68
56
|
export function Error(props) {
|
|
69
57
|
const { error } = useService(ProductsListServiceDefinition);
|
|
@@ -81,9 +69,6 @@ export function Error(props) {
|
|
|
81
69
|
* Only renders when products are successfully loaded (not loading, no error, and has products).
|
|
82
70
|
*
|
|
83
71
|
* @component
|
|
84
|
-
* @param props - Component props
|
|
85
|
-
* @param props.children - Content to display for each product (can be a render function receiving product data or ReactNode)
|
|
86
|
-
* @returns Array of JSX elements for each product or null if no products to display
|
|
87
72
|
*/
|
|
88
73
|
export function ItemContent(props) {
|
|
89
74
|
const { products, isLoading, error } = useService(ProductsListServiceDefinition);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type Signal } from "@wix/services-definitions/core-services/signals";
|
|
2
2
|
import { productsV3 } from "@wix/stores";
|
|
3
|
-
export
|
|
3
|
+
export interface ProductsListServiceConfig {
|
|
4
4
|
products: productsV3.V3Product[];
|
|
5
5
|
searchOptions: Parameters<typeof productsV3.searchProducts>[0];
|
|
6
6
|
pagingMetadata: productsV3.CommonCursorPagingMetadata;
|
|
7
7
|
aggregations: productsV3.AggregationData;
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
9
|
export declare function loadProductsListServiceConfig(searchOptions: Parameters<typeof productsV3.searchProducts>[0]): Promise<ProductsListServiceConfig>;
|
|
10
10
|
export declare const ProductsListServiceDefinition: string & {
|
|
11
11
|
__api: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineService, implementService } from "@wix/services-definitions";
|
|
2
2
|
import { SignalsServiceDefinition, } from "@wix/services-definitions/core-services/signals";
|
|
3
3
|
import { productsV3 } from "@wix/stores";
|
|
4
|
+
;
|
|
4
5
|
export async function loadProductsListServiceConfig(searchOptions) {
|
|
5
6
|
const result = await productsV3.searchProducts(searchOptions);
|
|
6
7
|
return {
|