@wix/headless-stores 0.0.44 → 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 +3 -2
- package/cjs/dist/services/product-service.js +5 -2
- package/dist/react/Product.d.ts +14 -0
- package/dist/react/Product.js +14 -0
- package/dist/services/product-service.d.ts +3 -2
- package/dist/services/product-service.js +5 -2
- 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.
|
|
@@ -139,7 +140,7 @@ export interface NotFoundProductServiceConfigResult {
|
|
|
139
140
|
* import { Product } from '@wix/stores/components';
|
|
140
141
|
*
|
|
141
142
|
* interface ProductPageProps {
|
|
142
|
-
* productConfig: Awaited<ReturnType<typeof loadProductServiceConfig
|
|
143
|
+
* productConfig: Extract<Awaited<ReturnType<typeof loadProductServiceConfig>>, { type: 'success' }>['config'];
|
|
143
144
|
* }
|
|
144
145
|
*
|
|
145
146
|
* export const getServerSideProps: GetServerSideProps<ProductPageProps> = async ({ params }) => {
|
|
@@ -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,
|
|
@@ -132,7 +135,7 @@ const loadProductBySlug = async (slug) => {
|
|
|
132
135
|
* import { Product } from '@wix/stores/components';
|
|
133
136
|
*
|
|
134
137
|
* interface ProductPageProps {
|
|
135
|
-
* productConfig: Awaited<ReturnType<typeof loadProductServiceConfig
|
|
138
|
+
* productConfig: Extract<Awaited<ReturnType<typeof loadProductServiceConfig>>, { type: 'success' }>['config'];
|
|
136
139
|
* }
|
|
137
140
|
*
|
|
138
141
|
* export const getServerSideProps: GetServerSideProps<ProductPageProps> = async ({ params }) => {
|
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.
|
|
@@ -139,7 +140,7 @@ export interface NotFoundProductServiceConfigResult {
|
|
|
139
140
|
* import { Product } from '@wix/stores/components';
|
|
140
141
|
*
|
|
141
142
|
* interface ProductPageProps {
|
|
142
|
-
* productConfig: Awaited<ReturnType<typeof loadProductServiceConfig
|
|
143
|
+
* productConfig: Extract<Awaited<ReturnType<typeof loadProductServiceConfig>>, { type: 'success' }>['config'];
|
|
143
144
|
* }
|
|
144
145
|
*
|
|
145
146
|
* export const getServerSideProps: GetServerSideProps<ProductPageProps> = async ({ params }) => {
|
|
@@ -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,
|
|
@@ -132,7 +135,7 @@ const loadProductBySlug = async (slug) => {
|
|
|
132
135
|
* import { Product } from '@wix/stores/components';
|
|
133
136
|
*
|
|
134
137
|
* interface ProductPageProps {
|
|
135
|
-
* productConfig: Awaited<ReturnType<typeof loadProductServiceConfig
|
|
138
|
+
* productConfig: Extract<Awaited<ReturnType<typeof loadProductServiceConfig>>, { type: 'success' }>['config'];
|
|
136
139
|
* }
|
|
137
140
|
*
|
|
138
141
|
* export const getServerSideProps: GetServerSideProps<ProductPageProps> = async ({ params }) => {
|