@wix/headless-stores 0.0.104 → 0.0.106
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/Option.d.ts +1 -0
- package/cjs/dist/react/Product.d.ts +51 -4
- package/cjs/dist/react/Product.js +95 -15
- package/cjs/dist/react/ProductList.d.ts +2 -3
- package/cjs/dist/react/core/Product.d.ts +8 -8
- package/cjs/dist/react/core/ProductModifiers.d.ts +11 -9
- package/cjs/dist/react/core/ProductModifiers.js +6 -3
- package/cjs/dist/react/core/ProductVariantSelector.d.ts +13 -9
- package/cjs/dist/react/core/ProductVariantSelector.js +14 -8
- package/cjs/dist/services/buy-now-service.js +2 -2
- package/cjs/dist/services/product-modifiers-service.d.ts +1 -1
- package/cjs/dist/services/product-modifiers-service.js +1 -1
- package/cjs/dist/services/product-service.d.ts +17 -1
- package/cjs/dist/services/product-service.js +151 -1
- package/cjs/dist/services/selected-variant-service.d.ts +6 -6
- package/cjs/dist/services/selected-variant-service.js +15 -16
- package/dist/react/Option.d.ts +1 -0
- package/dist/react/Product.d.ts +51 -4
- package/dist/react/Product.js +95 -15
- package/dist/react/ProductList.d.ts +2 -3
- package/dist/react/core/Product.d.ts +8 -8
- package/dist/react/core/ProductModifiers.d.ts +11 -9
- package/dist/react/core/ProductModifiers.js +6 -3
- package/dist/react/core/ProductVariantSelector.d.ts +13 -9
- package/dist/react/core/ProductVariantSelector.js +14 -8
- package/dist/services/buy-now-service.js +2 -2
- package/dist/services/product-modifiers-service.d.ts +1 -1
- package/dist/services/product-modifiers-service.js +1 -1
- package/dist/services/product-service.d.ts +17 -1
- package/dist/services/product-service.js +151 -1
- package/dist/services/selected-variant-service.d.ts +6 -6
- package/dist/services/selected-variant-service.js +15 -16
- package/package.json +8 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import { productsV3 } from '@wix/stores';
|
|
3
2
|
import { AsChildChildren } from '@wix/headless-utils/react';
|
|
3
|
+
import React from 'react';
|
|
4
4
|
import { AsContent } from './types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Context for sharing variant options state between components
|
|
@@ -37,7 +37,7 @@ export type StockStatus = BasicStockStatus | 'can-pre-order';
|
|
|
37
37
|
*/
|
|
38
38
|
export interface ProductRootProps {
|
|
39
39
|
children: React.ReactNode;
|
|
40
|
-
product: V3Product;
|
|
40
|
+
product: productsV3.V3Product;
|
|
41
41
|
selectedVariant?: any;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
@@ -268,7 +268,7 @@ export interface RawProps {
|
|
|
268
268
|
asChild?: boolean;
|
|
269
269
|
/** Custom render function when using asChild */
|
|
270
270
|
children?: AsChildChildren<{
|
|
271
|
-
product: V3Product;
|
|
271
|
+
product: productsV3.V3Product;
|
|
272
272
|
}>;
|
|
273
273
|
/** CSS classes to apply to the default element */
|
|
274
274
|
className?: string;
|
|
@@ -885,6 +885,53 @@ export declare const Action: {
|
|
|
885
885
|
/** Pre-order action button */
|
|
886
886
|
readonly PreOrder: React.ForwardRefExoticComponent<ProductActionProps & React.RefAttributes<HTMLButtonElement>>;
|
|
887
887
|
};
|
|
888
|
+
/**
|
|
889
|
+
* Props for Product Link component
|
|
890
|
+
*/
|
|
891
|
+
export interface ProductLinkProps {
|
|
892
|
+
/** Whether to render as a child component */
|
|
893
|
+
asChild?: boolean;
|
|
894
|
+
/** Custom render function when using asChild */
|
|
895
|
+
children?: React.ReactNode;
|
|
896
|
+
/** CSS classes to apply to the link */
|
|
897
|
+
className?: string;
|
|
898
|
+
/** List or collection the product is part of (e.g., "Category: T-Shirts") */
|
|
899
|
+
list?: string;
|
|
900
|
+
/** Position of the product within a list or collection */
|
|
901
|
+
position?: string;
|
|
902
|
+
/** Event origin (e.g., "Search Results", "Related Products") */
|
|
903
|
+
origin?: string;
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Product link component that automatically tracks ClickProduct events.
|
|
907
|
+
* Wraps a link to the product page and fires analytics when clicked.
|
|
908
|
+
*
|
|
909
|
+
* @component
|
|
910
|
+
* @example
|
|
911
|
+
* ```tsx
|
|
912
|
+
* // Simple usage
|
|
913
|
+
* <Product.Link className="btn-secondary">
|
|
914
|
+
* View Product
|
|
915
|
+
* </Product.Link>
|
|
916
|
+
*
|
|
917
|
+
* // With tracking parameters
|
|
918
|
+
* <Product.Link
|
|
919
|
+
* list="Category: T-Shirts"
|
|
920
|
+
* position="3"
|
|
921
|
+
* className="btn-secondary"
|
|
922
|
+
* >
|
|
923
|
+
* View Product
|
|
924
|
+
* </Product.Link>
|
|
925
|
+
*
|
|
926
|
+
* // asChild with custom link
|
|
927
|
+
* <Product.Link asChild list="Search Results" position="5">
|
|
928
|
+
* <a href="/custom-url" className="custom-link">
|
|
929
|
+
* <Product.Name />
|
|
930
|
+
* </a>
|
|
931
|
+
* </Product.Link>
|
|
932
|
+
* ```
|
|
933
|
+
*/
|
|
934
|
+
export declare const Link: React.ForwardRefExoticComponent<ProductLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
888
935
|
/**
|
|
889
936
|
* Props for ProductVariantStock component
|
|
890
937
|
*/
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { productsV3 } from '@wix/stores';
|
|
3
|
+
import { Quantity as QuantityComponent } from '@wix/headless-components/react';
|
|
4
4
|
import { Commerce } from '@wix/headless-ecom/react';
|
|
5
|
-
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
6
5
|
import { MediaGallery } from '@wix/headless-media/react';
|
|
7
|
-
import {
|
|
6
|
+
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
7
|
+
import { useService } from '@wix/services-manager-react';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { DataComponentTags } from '../data-component-tags.js';
|
|
10
|
+
import { ProductServiceDefinition, SelectedVariantServiceDefinition, } from '../services/index.js';
|
|
8
11
|
import * as CoreProduct from './core/Product.js';
|
|
9
|
-
import * as CoreProductVariantSelector from './core/ProductVariantSelector.js';
|
|
10
12
|
import * as CoreProductModifiers from './core/ProductModifiers.js';
|
|
13
|
+
import * as CoreProductVariantSelector from './core/ProductVariantSelector.js';
|
|
11
14
|
import * as CoreSelectedVariant from './core/SelectedVariant.js';
|
|
12
15
|
import * as Option from './Option.js';
|
|
13
16
|
import { AsContent } from './types.js';
|
|
14
|
-
import { DataComponentTags } from '../data-component-tags.js';
|
|
15
17
|
const VariantsContext = React.createContext(null);
|
|
16
18
|
/**
|
|
17
19
|
* Hook to access variants context
|
|
@@ -61,6 +63,7 @@ var TestIds;
|
|
|
61
63
|
TestIds["productActionAddToCart"] = "product-action-add-to-cart";
|
|
62
64
|
TestIds["productActionBuyNow"] = "product-action-buy-now";
|
|
63
65
|
TestIds["productActionPreOrder"] = "product-action-can-pre-order";
|
|
66
|
+
TestIds["productLink"] = "product-link";
|
|
64
67
|
TestIds["productQuantity"] = "product-quantity";
|
|
65
68
|
TestIds["productQuantityDecrement"] = "product-quantity-decrement";
|
|
66
69
|
TestIds["productQuantityInput"] = "product-quantity-input";
|
|
@@ -403,15 +406,15 @@ export const Stock = React.forwardRef((props, ref) => {
|
|
|
403
406
|
let status;
|
|
404
407
|
let label;
|
|
405
408
|
switch (availabilityStatus) {
|
|
406
|
-
case InventoryAvailabilityStatus.IN_STOCK:
|
|
409
|
+
case productsV3.InventoryAvailabilityStatus.IN_STOCK:
|
|
407
410
|
status = 'in-stock';
|
|
408
411
|
label = finalLabels.inStock;
|
|
409
412
|
break;
|
|
410
|
-
case InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK:
|
|
413
|
+
case productsV3.InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK:
|
|
411
414
|
status = 'limited-stock';
|
|
412
415
|
label = finalLabels.limitedStock;
|
|
413
416
|
break;
|
|
414
|
-
case InventoryAvailabilityStatus.OUT_OF_STOCK:
|
|
417
|
+
case productsV3.InventoryAvailabilityStatus.OUT_OF_STOCK:
|
|
415
418
|
default:
|
|
416
419
|
status = 'out-of-stock';
|
|
417
420
|
label = finalLabels.outOfStock;
|
|
@@ -879,6 +882,19 @@ export const ProductVariantSelectorReset = React.forwardRef((props, ref) => {
|
|
|
879
882
|
*/
|
|
880
883
|
export const ProductActionAddToCart = React.forwardRef((props, ref) => {
|
|
881
884
|
const { asChild, children, className, label, loadingState } = props;
|
|
885
|
+
// Get services for tracking
|
|
886
|
+
const productService = useService(ProductServiceDefinition);
|
|
887
|
+
const variantService = useService(SelectedVariantServiceDefinition);
|
|
888
|
+
// Track after successful add to cart
|
|
889
|
+
const handleSuccess = async () => {
|
|
890
|
+
const choices = variantService.selectedChoices.get();
|
|
891
|
+
const quantity = variantService.selectedQuantity.get();
|
|
892
|
+
const variantString = Object.values(choices).join(' ') || undefined;
|
|
893
|
+
productService.reportAddToCartTrackEvent({
|
|
894
|
+
quantity,
|
|
895
|
+
variant: variantString,
|
|
896
|
+
});
|
|
897
|
+
};
|
|
882
898
|
return (_jsx(CoreSelectedVariant.Actions, { children: ({ lineItems, canAddToCart, isLoading, addToCart, isPreOrderEnabled, }) => {
|
|
883
899
|
if (isPreOrderEnabled) {
|
|
884
900
|
return null;
|
|
@@ -886,13 +902,13 @@ export const ProductActionAddToCart = React.forwardRef((props, ref) => {
|
|
|
886
902
|
const onClick = addToCart;
|
|
887
903
|
const disabled = !canAddToCart || isLoading;
|
|
888
904
|
if (asChild && children) {
|
|
889
|
-
return (_jsx(Commerce.Actions.AddToCart, { lineItems: lineItems, asChild: asChild, children: _jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productActionAddToCart, "data-in-progress": isLoading, customElement: children, customElementProps: {
|
|
905
|
+
return (_jsx(Commerce.Actions.AddToCart, { lineItems: lineItems, asChild: asChild, onSuccess: handleSuccess, children: _jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productActionAddToCart, "data-in-progress": isLoading, customElement: children, customElementProps: {
|
|
890
906
|
disabled,
|
|
891
907
|
isLoading,
|
|
892
908
|
onClick,
|
|
893
909
|
} }) }));
|
|
894
910
|
}
|
|
895
|
-
return (_jsx(Commerce.Actions.AddToCart, { ref: ref, label: label, lineItems: lineItems, className: className, disabled: disabled, loadingState: loadingState, "data-testid": TestIds.productActionAddToCart, "data-in-progress": isLoading }));
|
|
911
|
+
return (_jsx(Commerce.Actions.AddToCart, { ref: ref, label: label, lineItems: lineItems, className: className, disabled: disabled, loadingState: loadingState, onSuccess: handleSuccess, "data-testid": TestIds.productActionAddToCart, "data-in-progress": isLoading }));
|
|
896
912
|
} }));
|
|
897
913
|
});
|
|
898
914
|
/**
|
|
@@ -923,6 +939,19 @@ export const ProductActionBuyNow = React.forwardRef((props, ref) => {
|
|
|
923
939
|
*/
|
|
924
940
|
export const ProductActionPreOrder = React.forwardRef((props, ref) => {
|
|
925
941
|
const { asChild, children, className, label, loadingState } = props;
|
|
942
|
+
// Get services for tracking
|
|
943
|
+
const productService = useService(ProductServiceDefinition);
|
|
944
|
+
const variantService = useService(SelectedVariantServiceDefinition);
|
|
945
|
+
// Track after successful pre-order
|
|
946
|
+
const handleSuccess = async () => {
|
|
947
|
+
const choices = variantService.selectedChoices.get();
|
|
948
|
+
const quantity = variantService.selectedQuantity.get();
|
|
949
|
+
const variantString = Object.values(choices).join(' ') || undefined;
|
|
950
|
+
productService.reportAddToCartTrackEvent({
|
|
951
|
+
quantity,
|
|
952
|
+
variant: variantString,
|
|
953
|
+
});
|
|
954
|
+
};
|
|
926
955
|
return (_jsx(CoreSelectedVariant.Actions, { children: ({ lineItems, isLoading, addToCart, isPreOrderEnabled }) => {
|
|
927
956
|
if (!isPreOrderEnabled) {
|
|
928
957
|
return null;
|
|
@@ -931,13 +960,13 @@ export const ProductActionPreOrder = React.forwardRef((props, ref) => {
|
|
|
931
960
|
const onClick = addToCart;
|
|
932
961
|
const disabled = !canPreOrder;
|
|
933
962
|
if (asChild && children) {
|
|
934
|
-
return (_jsx(Commerce.Actions.AddToCart, { lineItems: lineItems, asChild: asChild, children: _jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productActionPreOrder, "data-in-progress": isLoading, customElement: children, customElementProps: {
|
|
963
|
+
return (_jsx(Commerce.Actions.AddToCart, { lineItems: lineItems, asChild: asChild, onSuccess: handleSuccess, children: _jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productActionPreOrder, "data-in-progress": isLoading, customElement: children, customElementProps: {
|
|
935
964
|
disabled,
|
|
936
965
|
isLoading,
|
|
937
966
|
onClick,
|
|
938
967
|
} }) }));
|
|
939
968
|
}
|
|
940
|
-
return (_jsx(Commerce.Actions.AddToCart, { ref: ref, label: label, lineItems: lineItems, className: className, disabled: disabled, loadingState: loadingState, "data-testid": TestIds.productActionPreOrder, "data-in-progress": isLoading }));
|
|
969
|
+
return (_jsx(Commerce.Actions.AddToCart, { ref: ref, label: label, lineItems: lineItems, className: className, disabled: disabled, loadingState: loadingState, onSuccess: handleSuccess, "data-testid": TestIds.productActionPreOrder, "data-in-progress": isLoading }));
|
|
941
970
|
} }));
|
|
942
971
|
});
|
|
943
972
|
/**
|
|
@@ -952,6 +981,57 @@ export const Action = {
|
|
|
952
981
|
/** Pre-order action button */
|
|
953
982
|
PreOrder: ProductActionPreOrder,
|
|
954
983
|
};
|
|
984
|
+
/**
|
|
985
|
+
* Product link component that automatically tracks ClickProduct events.
|
|
986
|
+
* Wraps a link to the product page and fires analytics when clicked.
|
|
987
|
+
*
|
|
988
|
+
* @component
|
|
989
|
+
* @example
|
|
990
|
+
* ```tsx
|
|
991
|
+
* // Simple usage
|
|
992
|
+
* <Product.Link className="btn-secondary">
|
|
993
|
+
* View Product
|
|
994
|
+
* </Product.Link>
|
|
995
|
+
*
|
|
996
|
+
* // With tracking parameters
|
|
997
|
+
* <Product.Link
|
|
998
|
+
* list="Category: T-Shirts"
|
|
999
|
+
* position="3"
|
|
1000
|
+
* className="btn-secondary"
|
|
1001
|
+
* >
|
|
1002
|
+
* View Product
|
|
1003
|
+
* </Product.Link>
|
|
1004
|
+
*
|
|
1005
|
+
* // asChild with custom link
|
|
1006
|
+
* <Product.Link asChild list="Search Results" position="5">
|
|
1007
|
+
* <a href="/custom-url" className="custom-link">
|
|
1008
|
+
* <Product.Name />
|
|
1009
|
+
* </a>
|
|
1010
|
+
* </Product.Link>
|
|
1011
|
+
* ```
|
|
1012
|
+
*/
|
|
1013
|
+
export const Link = React.forwardRef((props, ref) => {
|
|
1014
|
+
const { asChild, children, className, list, position, origin } = props;
|
|
1015
|
+
// Get services for tracking
|
|
1016
|
+
const productService = useService(ProductServiceDefinition);
|
|
1017
|
+
const variantService = useService(SelectedVariantServiceDefinition);
|
|
1018
|
+
return (_jsx(CoreProduct.Slug, { children: ({ slug }) => {
|
|
1019
|
+
const handleClick = () => {
|
|
1020
|
+
const choices = variantService.selectedChoices.get();
|
|
1021
|
+
const variantString = Object.values(choices).join(' ') || undefined;
|
|
1022
|
+
productService.reportClickProductTrackEvent({
|
|
1023
|
+
variant: variantString,
|
|
1024
|
+
list,
|
|
1025
|
+
position,
|
|
1026
|
+
origin,
|
|
1027
|
+
});
|
|
1028
|
+
};
|
|
1029
|
+
if (asChild && children) {
|
|
1030
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productLink, customElement: children, customElementProps: { onClick: handleClick } }));
|
|
1031
|
+
}
|
|
1032
|
+
return (_jsx("a", { ref: ref, href: `/${slug}`, onClick: handleClick, className: className, "data-testid": TestIds.productLink, children: children }));
|
|
1033
|
+
} }));
|
|
1034
|
+
});
|
|
955
1035
|
/**
|
|
956
1036
|
* Helper function to determine stock status and label based on availability and can-pre-order settings
|
|
957
1037
|
*/
|
|
@@ -966,12 +1046,12 @@ function getStockStatusMessage(inStock, isPreOrderEnabled, availabilityStatus, l
|
|
|
966
1046
|
// Handle stock status based on availability
|
|
967
1047
|
if (inStock) {
|
|
968
1048
|
switch (availabilityStatus) {
|
|
969
|
-
case InventoryAvailabilityStatus.IN_STOCK:
|
|
1049
|
+
case productsV3.InventoryAvailabilityStatus.IN_STOCK:
|
|
970
1050
|
return {
|
|
971
1051
|
status: 'in-stock',
|
|
972
1052
|
label: labels.inStock,
|
|
973
1053
|
};
|
|
974
|
-
case InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK:
|
|
1054
|
+
case productsV3.InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK:
|
|
975
1055
|
return {
|
|
976
1056
|
status: 'limited-stock',
|
|
977
1057
|
label: labels.limitedStock,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { V3Product } from '@wix/auto_sdk_stores_products-v-3';
|
|
2
1
|
import { Sort as SortPrimitive, GenericListTotalsRenderProps, GenericListLoadMoreRenderProps, ListVariant, GenericListRepeaterRenderProps } from '@wix/headless-components/react';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import type { ProductsListServiceConfig } from '../services/products-list-service.js';
|
|
@@ -9,7 +8,7 @@ import { AsChildChildren } from '@wix/headless-utils/react';
|
|
|
9
8
|
*/
|
|
10
9
|
export interface ProductListRootProps {
|
|
11
10
|
children: React.ReactNode;
|
|
12
|
-
products?: V3Product[];
|
|
11
|
+
products?: productsV3.V3Product[];
|
|
13
12
|
productsListConfig?: ProductsListServiceConfig;
|
|
14
13
|
className?: string;
|
|
15
14
|
variant?: ListVariant;
|
|
@@ -95,7 +94,7 @@ export declare const Products: React.ForwardRefExoticComponent<ProductsProps & R
|
|
|
95
94
|
/**
|
|
96
95
|
* Render props for ProductRepeater asChild pattern
|
|
97
96
|
*/
|
|
98
|
-
export type ProductRepeaterRenderProps = GenericListRepeaterRenderProps<V3Product>;
|
|
97
|
+
export type ProductRepeaterRenderProps = GenericListRepeaterRenderProps<productsV3.V3Product>;
|
|
99
98
|
/**
|
|
100
99
|
* Props for ProductList ProductRepeater component
|
|
101
100
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProductServiceConfig } from '../../services/product-service.js';
|
|
2
|
-
import
|
|
2
|
+
import { productsV3 } from '@wix/stores';
|
|
3
3
|
export interface RootProps {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
productServiceConfig: ProductServiceConfig;
|
|
@@ -81,18 +81,18 @@ export interface ProductDescriptionProps {
|
|
|
81
81
|
*/
|
|
82
82
|
export interface ProductDescriptionRenderProps {
|
|
83
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']>;
|
|
84
|
+
description: NonNullable<productsV3.V3Product['description']>;
|
|
85
85
|
/** Product description with plain html */
|
|
86
|
-
plainDescription: NonNullable<V3Product['plainDescription']>;
|
|
86
|
+
plainDescription: NonNullable<productsV3.V3Product['plainDescription']>;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Render props for ProductDescription component
|
|
90
90
|
*/
|
|
91
91
|
export interface ProductDescriptionRenderProps {
|
|
92
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']>;
|
|
93
|
+
description: NonNullable<productsV3.V3Product['description']>;
|
|
94
94
|
/** Product description with plain html */
|
|
95
|
-
plainDescription: NonNullable<V3Product['plainDescription']>;
|
|
95
|
+
plainDescription: NonNullable<productsV3.V3Product['plainDescription']>;
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
* Headless component for product description display
|
|
@@ -129,15 +129,15 @@ export interface ProductMediaProps {
|
|
|
129
129
|
children: (props: ProductMediaRenderProps) => React.ReactNode;
|
|
130
130
|
}
|
|
131
131
|
export interface ProductMediaRenderProps {
|
|
132
|
-
mediaItems: ProductMedia[];
|
|
133
|
-
mainMedia?: ProductMedia;
|
|
132
|
+
mediaItems: productsV3.ProductMedia[];
|
|
133
|
+
mainMedia?: productsV3.ProductMedia;
|
|
134
134
|
}
|
|
135
135
|
export declare function Media(props: ProductMediaProps): import("react").ReactNode;
|
|
136
136
|
export interface ProductProps {
|
|
137
137
|
children: (props: ProductRenderProps) => React.ReactNode;
|
|
138
138
|
}
|
|
139
139
|
export interface ProductRenderProps {
|
|
140
|
-
product: V3Product;
|
|
140
|
+
product: productsV3.V3Product;
|
|
141
141
|
}
|
|
142
142
|
export declare function Content(props: ProductProps): import("react").ReactNode;
|
|
143
143
|
export interface LoadingProps {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { productsV3 } from '@wix/stores';
|
|
2
2
|
export interface RootProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
}
|
|
@@ -89,7 +89,7 @@ export interface ModifiersProps {
|
|
|
89
89
|
*/
|
|
90
90
|
export interface ModifiersRenderProps {
|
|
91
91
|
/** Array of product modifiers */
|
|
92
|
-
modifiers: ConnectedModifier[];
|
|
92
|
+
modifiers: productsV3.ConnectedModifier[];
|
|
93
93
|
/** Whether product has modifiers */
|
|
94
94
|
hasModifiers: boolean;
|
|
95
95
|
/** Currently selected modifier values */
|
|
@@ -148,7 +148,7 @@ export declare function Modifiers(props: ModifiersProps): import("react").ReactN
|
|
|
148
148
|
*/
|
|
149
149
|
export interface ModifierProps {
|
|
150
150
|
/** Product modifier data */
|
|
151
|
-
modifier: ConnectedModifier;
|
|
151
|
+
modifier: productsV3.ConnectedModifier;
|
|
152
152
|
/** Render prop function that receives modifier data */
|
|
153
153
|
children: (props: ModifierRenderProps) => React.ReactNode;
|
|
154
154
|
}
|
|
@@ -156,14 +156,16 @@ export interface ModifierProps {
|
|
|
156
156
|
* Render props for Modifier component
|
|
157
157
|
*/
|
|
158
158
|
export interface ModifierRenderProps {
|
|
159
|
-
/** Modifier name */
|
|
159
|
+
/** Modifier name (may be translated) */
|
|
160
160
|
name: string;
|
|
161
|
+
/** Modifier key (unique identifier) */
|
|
162
|
+
key: string;
|
|
161
163
|
/** Modifier type */
|
|
162
164
|
type: any;
|
|
163
165
|
/** Whether this modifier is mandatory */
|
|
164
166
|
mandatory: boolean;
|
|
165
167
|
/** Array of choices for this modifier (for choice-based modifiers) */
|
|
166
|
-
choices: ConnectedModifierChoice[];
|
|
168
|
+
choices: productsV3.ConnectedModifierChoice[];
|
|
167
169
|
/** Currently selected value for this modifier */
|
|
168
170
|
selectedValue: any;
|
|
169
171
|
/** Whether this modifier has choices */
|
|
@@ -227,9 +229,9 @@ export declare function Modifier(props: ModifierProps): import("react").ReactNod
|
|
|
227
229
|
*/
|
|
228
230
|
export interface ChoiceProps {
|
|
229
231
|
/** Product modifier data */
|
|
230
|
-
modifier: ConnectedModifier;
|
|
232
|
+
modifier: productsV3.ConnectedModifier;
|
|
231
233
|
/** Choice data */
|
|
232
|
-
choice: ConnectedModifierChoice;
|
|
234
|
+
choice: productsV3.ConnectedModifierChoice;
|
|
233
235
|
/** Render prop function that receives choice data */
|
|
234
236
|
children: (props: ChoiceRenderProps) => React.ReactNode;
|
|
235
237
|
}
|
|
@@ -288,7 +290,7 @@ export declare function Choice(props: ChoiceProps): import("react").ReactNode;
|
|
|
288
290
|
*/
|
|
289
291
|
export interface FreeTextProps {
|
|
290
292
|
/** Product modifier data */
|
|
291
|
-
modifier: ConnectedModifier;
|
|
293
|
+
modifier: productsV3.ConnectedModifier;
|
|
292
294
|
/** Render prop function that receives free text data */
|
|
293
295
|
children: (props: FreeTextRenderProps) => React.ReactNode;
|
|
294
296
|
}
|
|
@@ -354,7 +356,7 @@ export declare function FreeText(props: FreeTextProps): import("react").ReactNod
|
|
|
354
356
|
*/
|
|
355
357
|
export interface ToggleFreeTextProps {
|
|
356
358
|
/** Product modifier data */
|
|
357
|
-
modifier: ConnectedModifier;
|
|
359
|
+
modifier: productsV3.ConnectedModifier;
|
|
358
360
|
/** Render prop function that receives toggle data */
|
|
359
361
|
children: (props: ToggleFreeTextRenderProps) => React.ReactNode;
|
|
360
362
|
}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { useService, WixServices } from '@wix/services-manager-react';
|
|
4
4
|
import { ProductModifiersServiceDefinition, ProductModifiersService, } from '../../services/product-modifiers-service.js';
|
|
5
|
-
import {
|
|
5
|
+
import { productsV3 } from '@wix/stores';
|
|
6
6
|
import { createServicesMap } from '@wix/services-manager';
|
|
7
7
|
/**
|
|
8
8
|
* Root component that provides the ProductModifiers service context to its children.
|
|
@@ -208,17 +208,20 @@ export function Modifier(props) {
|
|
|
208
208
|
const modifiersService = useModifiersService();
|
|
209
209
|
const { modifier } = props;
|
|
210
210
|
const name = modifier.name || '';
|
|
211
|
+
// @ts-expect-error - This field is currently INTERNAL but will be public in the future
|
|
212
|
+
const key = modifier.key || name;
|
|
211
213
|
const type = modifier.modifierRenderType;
|
|
212
214
|
const mandatory = modifier.mandatory || false;
|
|
213
215
|
const choices = modifier.choicesSettings?.choices || [];
|
|
214
216
|
const hasChoices = choices.length > 0;
|
|
215
|
-
const isFreeText = type === ModifierRenderType.FREE_TEXT;
|
|
217
|
+
const isFreeText = type === productsV3.ModifierRenderType.FREE_TEXT;
|
|
216
218
|
const freeTextSettings = modifier.freeTextSettings;
|
|
217
219
|
const maxChars = freeTextSettings?.maxLength;
|
|
218
220
|
const placeholder = freeTextSettings?.placeholder;
|
|
219
221
|
const selectedValue = modifiersService?.selectedModifiers.get()[name] || null;
|
|
220
222
|
return props.children({
|
|
221
223
|
name,
|
|
224
|
+
key,
|
|
222
225
|
type,
|
|
223
226
|
mandatory,
|
|
224
227
|
choices,
|
|
@@ -265,7 +268,7 @@ export function Choice(props) {
|
|
|
265
268
|
const modifierName = modifier.name || '';
|
|
266
269
|
const renderType = modifier.modifierRenderType;
|
|
267
270
|
// For TEXT_CHOICES, use choice.key; for SWATCH_CHOICES, use choice.name
|
|
268
|
-
const choiceValue = renderType === ModifierRenderType.TEXT_CHOICES
|
|
271
|
+
const choiceValue = renderType === productsV3.ModifierRenderType.TEXT_CHOICES
|
|
269
272
|
? choice.key || choice.name || ''
|
|
270
273
|
: choice.name || '';
|
|
271
274
|
const value = choice.name || ''; // Display name is always choice.name
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SelectedVariantServiceConfig } from '../../services/selected-variant-service.js';
|
|
2
|
-
import {
|
|
2
|
+
import { productsV3 } from '@wix/stores';
|
|
3
3
|
export interface RootProps {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
selectedVariantServiceConfig?: SelectedVariantServiceConfig;
|
|
@@ -55,7 +55,7 @@ export interface OptionsProps {
|
|
|
55
55
|
*/
|
|
56
56
|
export interface OptionsRenderProps {
|
|
57
57
|
/** Array of product options */
|
|
58
|
-
options: ConnectedOption[];
|
|
58
|
+
options: productsV3.ConnectedOption[];
|
|
59
59
|
/** Whether product has options */
|
|
60
60
|
hasOptions: boolean;
|
|
61
61
|
/** Currently selected choices */
|
|
@@ -99,7 +99,7 @@ export declare function Options(props: OptionsProps): import("react").ReactNode;
|
|
|
99
99
|
*/
|
|
100
100
|
export interface OptionProps {
|
|
101
101
|
/** Product option data */
|
|
102
|
-
option: ConnectedOption;
|
|
102
|
+
option: productsV3.ConnectedOption;
|
|
103
103
|
/** Render prop function that receives option data */
|
|
104
104
|
children: (props: OptionRenderProps) => React.ReactNode;
|
|
105
105
|
}
|
|
@@ -107,10 +107,12 @@ export interface OptionProps {
|
|
|
107
107
|
* Render props for Option component
|
|
108
108
|
*/
|
|
109
109
|
export interface OptionRenderProps {
|
|
110
|
-
/** Option name */
|
|
110
|
+
/** Option name (may be translated) */
|
|
111
111
|
name: string;
|
|
112
|
+
/** Option key (unique identifier) */
|
|
113
|
+
key: string;
|
|
112
114
|
/** Array of choices for this option */
|
|
113
|
-
choices: ConnectedOptionChoice[];
|
|
115
|
+
choices: productsV3.ConnectedOptionChoice[];
|
|
114
116
|
/** Currently selected value for this option */
|
|
115
117
|
selectedValue: string | null;
|
|
116
118
|
/** Whether this option has choices */
|
|
@@ -153,9 +155,9 @@ export declare function Option(props: OptionProps): import("react").ReactNode;
|
|
|
153
155
|
*/
|
|
154
156
|
export interface ChoiceProps {
|
|
155
157
|
/** Product option data */
|
|
156
|
-
option: ConnectedOption;
|
|
158
|
+
option: productsV3.ConnectedOption;
|
|
157
159
|
/** Choice data */
|
|
158
|
-
choice: ConnectedOptionChoice;
|
|
160
|
+
choice: productsV3.ConnectedOptionChoice;
|
|
159
161
|
/** Render prop function that receives choice data */
|
|
160
162
|
children: (props: ChoiceRenderProps) => React.ReactNode;
|
|
161
163
|
}
|
|
@@ -175,8 +177,10 @@ export interface ChoiceRenderProps {
|
|
|
175
177
|
isPreOrderEnabled: boolean;
|
|
176
178
|
/** Function to select this choice */
|
|
177
179
|
select: () => void;
|
|
178
|
-
/** Option name */
|
|
180
|
+
/** Option name (may be translated) */
|
|
179
181
|
optionName: string;
|
|
182
|
+
/** Option key (unique identifier) */
|
|
183
|
+
optionKey: string;
|
|
180
184
|
/** Choice value */
|
|
181
185
|
choiceValue: string;
|
|
182
186
|
}
|
|
@@ -223,7 +227,7 @@ export interface StockRenderProps {
|
|
|
223
227
|
/** Whether pre-order is enabled */
|
|
224
228
|
isPreOrderEnabled: boolean;
|
|
225
229
|
/** Raw inventory availability status */
|
|
226
|
-
availabilityStatus: InventoryAvailabilityStatus | string;
|
|
230
|
+
availabilityStatus: productsV3.InventoryAvailabilityStatus | string;
|
|
227
231
|
/** Whether stock tracking is enabled */
|
|
228
232
|
trackInventory: boolean;
|
|
229
233
|
/** Current variant id */
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useService, WixServices } from '@wix/services-manager-react';
|
|
3
3
|
import { SelectedVariantServiceDefinition, SelectedVariantService, } from '../../services/selected-variant-service.js';
|
|
4
4
|
import { createServicesMap } from '@wix/services-manager';
|
|
5
|
-
import {
|
|
5
|
+
import { productsV3 } from '@wix/stores';
|
|
6
6
|
/**
|
|
7
7
|
* Root component that provides the ProductVariantSelector service context to its children.
|
|
8
8
|
* This component sets up the necessary services for rendering and managing product variant selection.
|
|
@@ -122,10 +122,13 @@ export function Option(props) {
|
|
|
122
122
|
const selectedChoices = variantService.selectedChoices.get();
|
|
123
123
|
const { option } = props;
|
|
124
124
|
const name = option.name || '';
|
|
125
|
+
// @ts-expect-error - This field is currently INTERNAL but will be public in the future
|
|
126
|
+
const key = option.key || name;
|
|
125
127
|
const choices = option.choicesSettings?.choices || [];
|
|
126
128
|
const selectedValue = selectedChoices[name] || null;
|
|
127
129
|
return props.children({
|
|
128
130
|
name,
|
|
131
|
+
key,
|
|
129
132
|
choices,
|
|
130
133
|
selectedValue,
|
|
131
134
|
hasChoices: choices.length > 0,
|
|
@@ -162,19 +165,21 @@ export function Choice(props) {
|
|
|
162
165
|
const selectedChoices = variantService.selectedChoices.get();
|
|
163
166
|
const { option, choice } = props;
|
|
164
167
|
const optionName = option.name || '';
|
|
168
|
+
// @ts-expect-error - This field is currently INTERNAL but will be public in the future
|
|
169
|
+
const optionKey = option.key || optionName;
|
|
165
170
|
const choiceValue = choice.name || '';
|
|
166
|
-
const isSelected = selectedChoices[
|
|
171
|
+
const isSelected = selectedChoices[optionKey] === choiceValue;
|
|
167
172
|
// Check if this choice is available based on current selections
|
|
168
|
-
const isVisible = variantService.isChoiceAvailable(
|
|
173
|
+
const isVisible = variantService.isChoiceAvailable(optionKey, choiceValue);
|
|
169
174
|
// Check if this choice results in an in-stock variant
|
|
170
|
-
const isInStock = variantService.isChoiceInStock(
|
|
175
|
+
const isInStock = variantService.isChoiceInStock(optionKey, choiceValue);
|
|
171
176
|
// Check if this choice is available for pre-order
|
|
172
|
-
const isPreOrderEnabled = variantService.isChoicePreOrderEnabled(
|
|
177
|
+
const isPreOrderEnabled = variantService.isChoicePreOrderEnabled(optionKey, choiceValue);
|
|
173
178
|
const value = choiceValue;
|
|
174
179
|
const select = () => {
|
|
175
180
|
const newChoices = {
|
|
176
181
|
...selectedChoices,
|
|
177
|
-
[
|
|
182
|
+
[optionKey]: choiceValue,
|
|
178
183
|
};
|
|
179
184
|
variantService.setSelectedChoices(newChoices);
|
|
180
185
|
};
|
|
@@ -186,6 +191,7 @@ export function Choice(props) {
|
|
|
186
191
|
isPreOrderEnabled,
|
|
187
192
|
select,
|
|
188
193
|
optionName,
|
|
194
|
+
optionKey,
|
|
189
195
|
choiceValue,
|
|
190
196
|
});
|
|
191
197
|
}
|
|
@@ -230,8 +236,8 @@ export function Stock(props) {
|
|
|
230
236
|
const selectedQuantity = variantService.selectedQuantity.get();
|
|
231
237
|
// Return raw availability status - UI components will handle display conversion
|
|
232
238
|
const availabilityStatus = inStock
|
|
233
|
-
? InventoryAvailabilityStatus.IN_STOCK
|
|
234
|
-
: InventoryAvailabilityStatus.OUT_OF_STOCK;
|
|
239
|
+
? productsV3.InventoryAvailabilityStatus.IN_STOCK
|
|
240
|
+
: productsV3.InventoryAvailabilityStatus.OUT_OF_STOCK;
|
|
235
241
|
const incrementQuantity = () => {
|
|
236
242
|
variantService.incrementQuantity();
|
|
237
243
|
};
|
|
@@ -1,7 +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 { getCheckoutUrlForProduct } from '../utils/index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { productsV3 } from '@wix/stores';
|
|
5
5
|
/**
|
|
6
6
|
* Service definition for the Buy Now service.
|
|
7
7
|
* This defines the reactive API contract for managing buy now functionality.
|
|
@@ -136,7 +136,7 @@ export const BuyNowServiceImplementation = implementService.withConfig()(BuyNowS
|
|
|
136
136
|
* ```
|
|
137
137
|
*/
|
|
138
138
|
export const loadBuyNowServiceInitialData = async (productSlug, variantId) => {
|
|
139
|
-
const res = await getProductBySlug(productSlug, {
|
|
139
|
+
const res = await productsV3.getProductBySlug(productSlug, {
|
|
140
140
|
fields: ['CURRENCY'],
|
|
141
141
|
});
|
|
142
142
|
const product = res.product;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ServiceFactoryConfig } from '@wix/services-definitions';
|
|
2
2
|
import { type Signal, type ReadOnlySignal } from '@wix/services-definitions/core-services/signals';
|
|
3
|
-
import
|
|
3
|
+
import { productsV3 } from '@wix/stores';
|
|
4
4
|
export interface ModifierValue {
|
|
5
5
|
modifierName: string;
|
|
6
6
|
choiceValue?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineService, implementService, } from '@wix/services-definitions';
|
|
2
2
|
import { SignalsServiceDefinition, } from '@wix/services-definitions/core-services/signals';
|
|
3
|
-
import
|
|
3
|
+
import { productsV3 } from '@wix/stores';
|
|
4
4
|
import { ProductServiceDefinition } from './product-service.js';
|
|
5
5
|
export const ProductModifiersServiceDefinition = defineService('productModifiers');
|
|
6
6
|
export const ProductModifiersService = implementService.withConfig()(ProductModifiersServiceDefinition, ({ getService }) => {
|