@wix/headless-stores 0.0.45 → 0.0.46
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/Product.d.ts +14 -0
- package/cjs/dist/react/Product.js +14 -0
- package/cjs/dist/services/product-service.d.ts +2 -1
- package/cjs/dist/services/product-service.js +4 -1
- package/dist/react/Product.d.ts +14 -0
- package/dist/react/Product.js +14 -0
- package/dist/services/product-service.d.ts +2 -1
- package/dist/services/product-service.js +4 -1
- package/package.json +1 -1
|
@@ -132,3 +132,17 @@ export interface ProductMediaRenderProps {
|
|
|
132
132
|
media: ProductMedia[];
|
|
133
133
|
}
|
|
134
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;
|
|
@@ -110,3 +110,17 @@ export function Media(props) {
|
|
|
110
110
|
media,
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
+
export function Content(props) {
|
|
114
|
+
const service = useService(ProductServiceDefinition);
|
|
115
|
+
const product = service.product.get();
|
|
116
|
+
return props.children({
|
|
117
|
+
product,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
export function Loading(props) {
|
|
121
|
+
const service = useService(ProductServiceDefinition);
|
|
122
|
+
const isLoading = service.isLoading.get();
|
|
123
|
+
return props.children({
|
|
124
|
+
isLoading,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
@@ -35,7 +35,8 @@ export declare const ProductServiceDefinition: string & {
|
|
|
35
35
|
*/
|
|
36
36
|
export interface ProductServiceConfig {
|
|
37
37
|
/** The initial product data to configure the service with */
|
|
38
|
-
product
|
|
38
|
+
product?: productsV3.V3Product;
|
|
39
|
+
productSlug?: string;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
42
|
* Implementation of the Product service that manages reactive product data.
|
|
@@ -44,7 +44,7 @@ export const ProductServiceDefinition = defineService("product");
|
|
|
44
44
|
export const ProductService = implementService.withConfig()(ProductServiceDefinition, ({ getService, config }) => {
|
|
45
45
|
const signalsService = getService(SignalsServiceDefinition);
|
|
46
46
|
const product = signalsService.signal(config.product);
|
|
47
|
-
const isLoading = signalsService.signal(
|
|
47
|
+
const isLoading = signalsService.signal(!!config.productSlug);
|
|
48
48
|
const error = signalsService.signal(null);
|
|
49
49
|
const loadProduct = async (slug) => {
|
|
50
50
|
isLoading.set(true);
|
|
@@ -58,6 +58,9 @@ export const ProductService = implementService.withConfig()(ProductServiceDefini
|
|
|
58
58
|
}
|
|
59
59
|
isLoading.set(false);
|
|
60
60
|
};
|
|
61
|
+
if (config.productSlug) {
|
|
62
|
+
loadProduct(config.productSlug);
|
|
63
|
+
}
|
|
61
64
|
return {
|
|
62
65
|
product,
|
|
63
66
|
isLoading,
|
package/dist/react/Product.d.ts
CHANGED
|
@@ -132,3 +132,17 @@ export interface ProductMediaRenderProps {
|
|
|
132
132
|
media: ProductMedia[];
|
|
133
133
|
}
|
|
134
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;
|
package/dist/react/Product.js
CHANGED
|
@@ -110,3 +110,17 @@ export function Media(props) {
|
|
|
110
110
|
media,
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
+
export function Content(props) {
|
|
114
|
+
const service = useService(ProductServiceDefinition);
|
|
115
|
+
const product = service.product.get();
|
|
116
|
+
return props.children({
|
|
117
|
+
product,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
export function Loading(props) {
|
|
121
|
+
const service = useService(ProductServiceDefinition);
|
|
122
|
+
const isLoading = service.isLoading.get();
|
|
123
|
+
return props.children({
|
|
124
|
+
isLoading,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
@@ -35,7 +35,8 @@ export declare const ProductServiceDefinition: string & {
|
|
|
35
35
|
*/
|
|
36
36
|
export interface ProductServiceConfig {
|
|
37
37
|
/** The initial product data to configure the service with */
|
|
38
|
-
product
|
|
38
|
+
product?: productsV3.V3Product;
|
|
39
|
+
productSlug?: string;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
42
|
* Implementation of the Product service that manages reactive product data.
|
|
@@ -44,7 +44,7 @@ export const ProductServiceDefinition = defineService("product");
|
|
|
44
44
|
export const ProductService = implementService.withConfig()(ProductServiceDefinition, ({ getService, config }) => {
|
|
45
45
|
const signalsService = getService(SignalsServiceDefinition);
|
|
46
46
|
const product = signalsService.signal(config.product);
|
|
47
|
-
const isLoading = signalsService.signal(
|
|
47
|
+
const isLoading = signalsService.signal(!!config.productSlug);
|
|
48
48
|
const error = signalsService.signal(null);
|
|
49
49
|
const loadProduct = async (slug) => {
|
|
50
50
|
isLoading.set(true);
|
|
@@ -58,6 +58,9 @@ export const ProductService = implementService.withConfig()(ProductServiceDefini
|
|
|
58
58
|
}
|
|
59
59
|
isLoading.set(false);
|
|
60
60
|
};
|
|
61
|
+
if (config.productSlug) {
|
|
62
|
+
loadProduct(config.productSlug);
|
|
63
|
+
}
|
|
61
64
|
return {
|
|
62
65
|
product,
|
|
63
66
|
isLoading,
|