@wix/headless-stores 0.0.85 → 0.0.86
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 +17 -9
- package/cjs/dist/react/Product.js +10 -10
- package/dist/react/Product.d.ts +17 -9
- package/dist/react/Product.js +10 -10
- package/package.json +1 -1
|
@@ -24,6 +24,14 @@ interface ModifiersContextValue {
|
|
|
24
24
|
* Hook to access modifiers context
|
|
25
25
|
*/
|
|
26
26
|
export declare function useModifiersContext(): ModifiersContextValue;
|
|
27
|
+
/**
|
|
28
|
+
* Basic stock status type for product availability states
|
|
29
|
+
*/
|
|
30
|
+
export type BasicStockStatus = 'in-stock' | 'limited-stock' | 'out-of-stock';
|
|
31
|
+
/**
|
|
32
|
+
* Extended stock status type including pre-order capability
|
|
33
|
+
*/
|
|
34
|
+
export type StockStatus = BasicStockStatus | 'can-pre-order';
|
|
27
35
|
/**
|
|
28
36
|
* Props for the Product root component following the documented API
|
|
29
37
|
*/
|
|
@@ -328,7 +336,7 @@ export interface StockProps {
|
|
|
328
336
|
asChild?: boolean;
|
|
329
337
|
/** Custom render function when using asChild */
|
|
330
338
|
children?: AsChildChildren<{
|
|
331
|
-
status:
|
|
339
|
+
status: BasicStockStatus;
|
|
332
340
|
label: string;
|
|
333
341
|
}>;
|
|
334
342
|
/** CSS classes to apply to the default element */
|
|
@@ -675,7 +683,7 @@ export interface ProductQuantitySubComponentProps {
|
|
|
675
683
|
}
|
|
676
684
|
/**
|
|
677
685
|
* Product quantity selector component that integrates with the selected variant.
|
|
678
|
-
* Provides quantity controls with stock validation and pre-order support.
|
|
686
|
+
* Provides quantity controls with stock validation and can-pre-order support.
|
|
679
687
|
* Uses a compound component pattern with Root, Decrement, Input, Increment, and Raw sub-components.
|
|
680
688
|
*
|
|
681
689
|
* @component
|
|
@@ -737,7 +745,7 @@ export interface ProductQuantitySubComponentProps {
|
|
|
737
745
|
export declare const ProductQuantity: React.ForwardRefExoticComponent<ProductQuantityProps & React.RefAttributes<HTMLDivElement>>;
|
|
738
746
|
/**
|
|
739
747
|
* Product Quantity Decrement component.
|
|
740
|
-
* Automatically handles disabled state based on stock and pre-order settings.
|
|
748
|
+
* Automatically handles disabled state based on stock and can-pre-order settings.
|
|
741
749
|
* Must be used within Product.Quantity.Root.
|
|
742
750
|
*
|
|
743
751
|
* @component
|
|
@@ -859,7 +867,7 @@ export declare const ProductActionAddToCart: React.ForwardRefExoticComponent<Pro
|
|
|
859
867
|
export declare const ProductActionBuyNow: React.ForwardRefExoticComponent<ProductActionProps & React.RefAttributes<HTMLButtonElement>>;
|
|
860
868
|
/**
|
|
861
869
|
* Pre-Order action button component following the documented API.
|
|
862
|
-
* Handles pre-order functionality when products are not in stock.
|
|
870
|
+
* Handles can-pre-order functionality when products are not in stock.
|
|
863
871
|
*/
|
|
864
872
|
export declare const ProductActionPreOrder: React.ForwardRefExoticComponent<ProductActionProps & React.RefAttributes<HTMLButtonElement>>;
|
|
865
873
|
/**
|
|
@@ -882,7 +890,7 @@ export interface ProductVariantStockProps {
|
|
|
882
890
|
asChild?: boolean;
|
|
883
891
|
/** Custom render function when using asChild */
|
|
884
892
|
children?: AsChildChildren<{
|
|
885
|
-
status:
|
|
893
|
+
status: StockStatus;
|
|
886
894
|
label: string;
|
|
887
895
|
}>;
|
|
888
896
|
/** CSS classes to apply to the default element */
|
|
@@ -895,13 +903,13 @@ export interface ProductVariantStockProps {
|
|
|
895
903
|
limitedStock?: string;
|
|
896
904
|
/** Label for out of stock state */
|
|
897
905
|
outOfStock?: string;
|
|
898
|
-
/** Label for pre-order state */
|
|
906
|
+
/** Label for can-pre-order state */
|
|
899
907
|
preOrder?: string;
|
|
900
908
|
};
|
|
901
909
|
}
|
|
902
910
|
/**
|
|
903
911
|
* Displays the selected variant stock status with customizable rendering and labels,
|
|
904
|
-
* including pre-order support. Similar to Product.Stock but for the selected variant.
|
|
912
|
+
* including can-pre-order support. Similar to Product.Stock but for the selected variant.
|
|
905
913
|
*
|
|
906
914
|
* @component
|
|
907
915
|
* @example
|
|
@@ -936,9 +944,9 @@ export interface ProductVariantStockProps {
|
|
|
936
944
|
* <div
|
|
937
945
|
* ref={ref}
|
|
938
946
|
* {...props}
|
|
939
|
-
* className="flex items-center gap-2 data-[state='in-stock']:text-green-600 data-[state='limited-stock']:text-yellow-600 data-[state='out-of-stock']:text-red-600 data-[state='pre-order']:text-blue-600"
|
|
947
|
+
* className="flex items-center gap-2 data-[state='in-stock']:text-green-600 data-[state='limited-stock']:text-yellow-600 data-[state='out-of-stock']:text-red-600 data-[state='can-pre-order']:text-blue-600"
|
|
940
948
|
* >
|
|
941
|
-
* <div className="w-3 h-3 rounded-full data-[state='in-stock']:bg-green-500 data-[state='limited-stock']:bg-yellow-500 data-[state='out-of-stock']:bg-red-500 data-[state='pre-order']:bg-blue-500" />
|
|
949
|
+
* <div className="w-3 h-3 rounded-full data-[state='in-stock']:bg-green-500 data-[state='limited-stock']:bg-yellow-500 data-[state='out-of-stock']:bg-red-500 data-[state='can-pre-order']:bg-blue-500" />
|
|
942
950
|
* <span className="text-sm font-medium">
|
|
943
951
|
* {label}
|
|
944
952
|
* </span>
|
|
@@ -59,7 +59,7 @@ var TestIds;
|
|
|
59
59
|
TestIds["productAddToCart"] = "product-add-to-cart";
|
|
60
60
|
TestIds["productActionAddToCart"] = "product-action-add-to-cart";
|
|
61
61
|
TestIds["productActionBuyNow"] = "product-action-buy-now";
|
|
62
|
-
TestIds["productActionPreOrder"] = "product-action-pre-order";
|
|
62
|
+
TestIds["productActionPreOrder"] = "product-action-can-pre-order";
|
|
63
63
|
TestIds["productQuantity"] = "product-quantity";
|
|
64
64
|
TestIds["productQuantityDecrement"] = "product-quantity-decrement";
|
|
65
65
|
TestIds["productQuantityInput"] = "product-quantity-input";
|
|
@@ -692,7 +692,7 @@ export const ProductMediaGallery = React.forwardRef((props, ref) => {
|
|
|
692
692
|
export { ProductMediaGallery as MediaGallery };
|
|
693
693
|
/**
|
|
694
694
|
* Product quantity selector component that integrates with the selected variant.
|
|
695
|
-
* Provides quantity controls with stock validation and pre-order support.
|
|
695
|
+
* Provides quantity controls with stock validation and can-pre-order support.
|
|
696
696
|
* Uses a compound component pattern with Root, Decrement, Input, Increment, and Raw sub-components.
|
|
697
697
|
*
|
|
698
698
|
* @component
|
|
@@ -769,7 +769,7 @@ export const ProductQuantity = React.forwardRef((props, ref) => {
|
|
|
769
769
|
});
|
|
770
770
|
/**
|
|
771
771
|
* Product Quantity Decrement component.
|
|
772
|
-
* Automatically handles disabled state based on stock and pre-order settings.
|
|
772
|
+
* Automatically handles disabled state based on stock and can-pre-order settings.
|
|
773
773
|
* Must be used within Product.Quantity.Root.
|
|
774
774
|
*
|
|
775
775
|
* @component
|
|
@@ -917,7 +917,7 @@ export const ProductActionBuyNow = React.forwardRef((props, ref) => {
|
|
|
917
917
|
});
|
|
918
918
|
/**
|
|
919
919
|
* Pre-Order action button component following the documented API.
|
|
920
|
-
* Handles pre-order functionality when products are not in stock.
|
|
920
|
+
* Handles can-pre-order functionality when products are not in stock.
|
|
921
921
|
*/
|
|
922
922
|
export const ProductActionPreOrder = React.forwardRef((props, ref) => {
|
|
923
923
|
const { asChild, children, className, label, loadingState } = props;
|
|
@@ -951,13 +951,13 @@ export const Action = {
|
|
|
951
951
|
PreOrder: ProductActionPreOrder,
|
|
952
952
|
};
|
|
953
953
|
/**
|
|
954
|
-
* Helper function to determine stock status and label based on availability and pre-order settings
|
|
954
|
+
* Helper function to determine stock status and label based on availability and can-pre-order settings
|
|
955
955
|
*/
|
|
956
956
|
function getStockStatusMessage(inStock, isPreOrderEnabled, availabilityStatus, labels) {
|
|
957
957
|
// Pre-order takes precedence
|
|
958
|
-
if (isPreOrderEnabled) {
|
|
958
|
+
if (isPreOrderEnabled && !inStock) {
|
|
959
959
|
return {
|
|
960
|
-
status: 'pre-order',
|
|
960
|
+
status: 'can-pre-order',
|
|
961
961
|
label: labels.preOrder,
|
|
962
962
|
};
|
|
963
963
|
}
|
|
@@ -988,7 +988,7 @@ function getStockStatusMessage(inStock, isPreOrderEnabled, availabilityStatus, l
|
|
|
988
988
|
}
|
|
989
989
|
/**
|
|
990
990
|
* Displays the selected variant stock status with customizable rendering and labels,
|
|
991
|
-
* including pre-order support. Similar to Product.Stock but for the selected variant.
|
|
991
|
+
* including can-pre-order support. Similar to Product.Stock but for the selected variant.
|
|
992
992
|
*
|
|
993
993
|
* @component
|
|
994
994
|
* @example
|
|
@@ -1023,9 +1023,9 @@ function getStockStatusMessage(inStock, isPreOrderEnabled, availabilityStatus, l
|
|
|
1023
1023
|
* <div
|
|
1024
1024
|
* ref={ref}
|
|
1025
1025
|
* {...props}
|
|
1026
|
-
* className="flex items-center gap-2 data-[state='in-stock']:text-green-600 data-[state='limited-stock']:text-yellow-600 data-[state='out-of-stock']:text-red-600 data-[state='pre-order']:text-blue-600"
|
|
1026
|
+
* className="flex items-center gap-2 data-[state='in-stock']:text-green-600 data-[state='limited-stock']:text-yellow-600 data-[state='out-of-stock']:text-red-600 data-[state='can-pre-order']:text-blue-600"
|
|
1027
1027
|
* >
|
|
1028
|
-
* <div className="w-3 h-3 rounded-full data-[state='in-stock']:bg-green-500 data-[state='limited-stock']:bg-yellow-500 data-[state='out-of-stock']:bg-red-500 data-[state='pre-order']:bg-blue-500" />
|
|
1028
|
+
* <div className="w-3 h-3 rounded-full data-[state='in-stock']:bg-green-500 data-[state='limited-stock']:bg-yellow-500 data-[state='out-of-stock']:bg-red-500 data-[state='can-pre-order']:bg-blue-500" />
|
|
1029
1029
|
* <span className="text-sm font-medium">
|
|
1030
1030
|
* {label}
|
|
1031
1031
|
* </span>
|
package/dist/react/Product.d.ts
CHANGED
|
@@ -24,6 +24,14 @@ interface ModifiersContextValue {
|
|
|
24
24
|
* Hook to access modifiers context
|
|
25
25
|
*/
|
|
26
26
|
export declare function useModifiersContext(): ModifiersContextValue;
|
|
27
|
+
/**
|
|
28
|
+
* Basic stock status type for product availability states
|
|
29
|
+
*/
|
|
30
|
+
export type BasicStockStatus = 'in-stock' | 'limited-stock' | 'out-of-stock';
|
|
31
|
+
/**
|
|
32
|
+
* Extended stock status type including pre-order capability
|
|
33
|
+
*/
|
|
34
|
+
export type StockStatus = BasicStockStatus | 'can-pre-order';
|
|
27
35
|
/**
|
|
28
36
|
* Props for the Product root component following the documented API
|
|
29
37
|
*/
|
|
@@ -328,7 +336,7 @@ export interface StockProps {
|
|
|
328
336
|
asChild?: boolean;
|
|
329
337
|
/** Custom render function when using asChild */
|
|
330
338
|
children?: AsChildChildren<{
|
|
331
|
-
status:
|
|
339
|
+
status: BasicStockStatus;
|
|
332
340
|
label: string;
|
|
333
341
|
}>;
|
|
334
342
|
/** CSS classes to apply to the default element */
|
|
@@ -675,7 +683,7 @@ export interface ProductQuantitySubComponentProps {
|
|
|
675
683
|
}
|
|
676
684
|
/**
|
|
677
685
|
* Product quantity selector component that integrates with the selected variant.
|
|
678
|
-
* Provides quantity controls with stock validation and pre-order support.
|
|
686
|
+
* Provides quantity controls with stock validation and can-pre-order support.
|
|
679
687
|
* Uses a compound component pattern with Root, Decrement, Input, Increment, and Raw sub-components.
|
|
680
688
|
*
|
|
681
689
|
* @component
|
|
@@ -737,7 +745,7 @@ export interface ProductQuantitySubComponentProps {
|
|
|
737
745
|
export declare const ProductQuantity: React.ForwardRefExoticComponent<ProductQuantityProps & React.RefAttributes<HTMLDivElement>>;
|
|
738
746
|
/**
|
|
739
747
|
* Product Quantity Decrement component.
|
|
740
|
-
* Automatically handles disabled state based on stock and pre-order settings.
|
|
748
|
+
* Automatically handles disabled state based on stock and can-pre-order settings.
|
|
741
749
|
* Must be used within Product.Quantity.Root.
|
|
742
750
|
*
|
|
743
751
|
* @component
|
|
@@ -859,7 +867,7 @@ export declare const ProductActionAddToCart: React.ForwardRefExoticComponent<Pro
|
|
|
859
867
|
export declare const ProductActionBuyNow: React.ForwardRefExoticComponent<ProductActionProps & React.RefAttributes<HTMLButtonElement>>;
|
|
860
868
|
/**
|
|
861
869
|
* Pre-Order action button component following the documented API.
|
|
862
|
-
* Handles pre-order functionality when products are not in stock.
|
|
870
|
+
* Handles can-pre-order functionality when products are not in stock.
|
|
863
871
|
*/
|
|
864
872
|
export declare const ProductActionPreOrder: React.ForwardRefExoticComponent<ProductActionProps & React.RefAttributes<HTMLButtonElement>>;
|
|
865
873
|
/**
|
|
@@ -882,7 +890,7 @@ export interface ProductVariantStockProps {
|
|
|
882
890
|
asChild?: boolean;
|
|
883
891
|
/** Custom render function when using asChild */
|
|
884
892
|
children?: AsChildChildren<{
|
|
885
|
-
status:
|
|
893
|
+
status: StockStatus;
|
|
886
894
|
label: string;
|
|
887
895
|
}>;
|
|
888
896
|
/** CSS classes to apply to the default element */
|
|
@@ -895,13 +903,13 @@ export interface ProductVariantStockProps {
|
|
|
895
903
|
limitedStock?: string;
|
|
896
904
|
/** Label for out of stock state */
|
|
897
905
|
outOfStock?: string;
|
|
898
|
-
/** Label for pre-order state */
|
|
906
|
+
/** Label for can-pre-order state */
|
|
899
907
|
preOrder?: string;
|
|
900
908
|
};
|
|
901
909
|
}
|
|
902
910
|
/**
|
|
903
911
|
* Displays the selected variant stock status with customizable rendering and labels,
|
|
904
|
-
* including pre-order support. Similar to Product.Stock but for the selected variant.
|
|
912
|
+
* including can-pre-order support. Similar to Product.Stock but for the selected variant.
|
|
905
913
|
*
|
|
906
914
|
* @component
|
|
907
915
|
* @example
|
|
@@ -936,9 +944,9 @@ export interface ProductVariantStockProps {
|
|
|
936
944
|
* <div
|
|
937
945
|
* ref={ref}
|
|
938
946
|
* {...props}
|
|
939
|
-
* className="flex items-center gap-2 data-[state='in-stock']:text-green-600 data-[state='limited-stock']:text-yellow-600 data-[state='out-of-stock']:text-red-600 data-[state='pre-order']:text-blue-600"
|
|
947
|
+
* className="flex items-center gap-2 data-[state='in-stock']:text-green-600 data-[state='limited-stock']:text-yellow-600 data-[state='out-of-stock']:text-red-600 data-[state='can-pre-order']:text-blue-600"
|
|
940
948
|
* >
|
|
941
|
-
* <div className="w-3 h-3 rounded-full data-[state='in-stock']:bg-green-500 data-[state='limited-stock']:bg-yellow-500 data-[state='out-of-stock']:bg-red-500 data-[state='pre-order']:bg-blue-500" />
|
|
949
|
+
* <div className="w-3 h-3 rounded-full data-[state='in-stock']:bg-green-500 data-[state='limited-stock']:bg-yellow-500 data-[state='out-of-stock']:bg-red-500 data-[state='can-pre-order']:bg-blue-500" />
|
|
942
950
|
* <span className="text-sm font-medium">
|
|
943
951
|
* {label}
|
|
944
952
|
* </span>
|
package/dist/react/Product.js
CHANGED
|
@@ -59,7 +59,7 @@ var TestIds;
|
|
|
59
59
|
TestIds["productAddToCart"] = "product-add-to-cart";
|
|
60
60
|
TestIds["productActionAddToCart"] = "product-action-add-to-cart";
|
|
61
61
|
TestIds["productActionBuyNow"] = "product-action-buy-now";
|
|
62
|
-
TestIds["productActionPreOrder"] = "product-action-pre-order";
|
|
62
|
+
TestIds["productActionPreOrder"] = "product-action-can-pre-order";
|
|
63
63
|
TestIds["productQuantity"] = "product-quantity";
|
|
64
64
|
TestIds["productQuantityDecrement"] = "product-quantity-decrement";
|
|
65
65
|
TestIds["productQuantityInput"] = "product-quantity-input";
|
|
@@ -692,7 +692,7 @@ export const ProductMediaGallery = React.forwardRef((props, ref) => {
|
|
|
692
692
|
export { ProductMediaGallery as MediaGallery };
|
|
693
693
|
/**
|
|
694
694
|
* Product quantity selector component that integrates with the selected variant.
|
|
695
|
-
* Provides quantity controls with stock validation and pre-order support.
|
|
695
|
+
* Provides quantity controls with stock validation and can-pre-order support.
|
|
696
696
|
* Uses a compound component pattern with Root, Decrement, Input, Increment, and Raw sub-components.
|
|
697
697
|
*
|
|
698
698
|
* @component
|
|
@@ -769,7 +769,7 @@ export const ProductQuantity = React.forwardRef((props, ref) => {
|
|
|
769
769
|
});
|
|
770
770
|
/**
|
|
771
771
|
* Product Quantity Decrement component.
|
|
772
|
-
* Automatically handles disabled state based on stock and pre-order settings.
|
|
772
|
+
* Automatically handles disabled state based on stock and can-pre-order settings.
|
|
773
773
|
* Must be used within Product.Quantity.Root.
|
|
774
774
|
*
|
|
775
775
|
* @component
|
|
@@ -917,7 +917,7 @@ export const ProductActionBuyNow = React.forwardRef((props, ref) => {
|
|
|
917
917
|
});
|
|
918
918
|
/**
|
|
919
919
|
* Pre-Order action button component following the documented API.
|
|
920
|
-
* Handles pre-order functionality when products are not in stock.
|
|
920
|
+
* Handles can-pre-order functionality when products are not in stock.
|
|
921
921
|
*/
|
|
922
922
|
export const ProductActionPreOrder = React.forwardRef((props, ref) => {
|
|
923
923
|
const { asChild, children, className, label, loadingState } = props;
|
|
@@ -951,13 +951,13 @@ export const Action = {
|
|
|
951
951
|
PreOrder: ProductActionPreOrder,
|
|
952
952
|
};
|
|
953
953
|
/**
|
|
954
|
-
* Helper function to determine stock status and label based on availability and pre-order settings
|
|
954
|
+
* Helper function to determine stock status and label based on availability and can-pre-order settings
|
|
955
955
|
*/
|
|
956
956
|
function getStockStatusMessage(inStock, isPreOrderEnabled, availabilityStatus, labels) {
|
|
957
957
|
// Pre-order takes precedence
|
|
958
|
-
if (isPreOrderEnabled) {
|
|
958
|
+
if (isPreOrderEnabled && !inStock) {
|
|
959
959
|
return {
|
|
960
|
-
status: 'pre-order',
|
|
960
|
+
status: 'can-pre-order',
|
|
961
961
|
label: labels.preOrder,
|
|
962
962
|
};
|
|
963
963
|
}
|
|
@@ -988,7 +988,7 @@ function getStockStatusMessage(inStock, isPreOrderEnabled, availabilityStatus, l
|
|
|
988
988
|
}
|
|
989
989
|
/**
|
|
990
990
|
* Displays the selected variant stock status with customizable rendering and labels,
|
|
991
|
-
* including pre-order support. Similar to Product.Stock but for the selected variant.
|
|
991
|
+
* including can-pre-order support. Similar to Product.Stock but for the selected variant.
|
|
992
992
|
*
|
|
993
993
|
* @component
|
|
994
994
|
* @example
|
|
@@ -1023,9 +1023,9 @@ function getStockStatusMessage(inStock, isPreOrderEnabled, availabilityStatus, l
|
|
|
1023
1023
|
* <div
|
|
1024
1024
|
* ref={ref}
|
|
1025
1025
|
* {...props}
|
|
1026
|
-
* className="flex items-center gap-2 data-[state='in-stock']:text-green-600 data-[state='limited-stock']:text-yellow-600 data-[state='out-of-stock']:text-red-600 data-[state='pre-order']:text-blue-600"
|
|
1026
|
+
* className="flex items-center gap-2 data-[state='in-stock']:text-green-600 data-[state='limited-stock']:text-yellow-600 data-[state='out-of-stock']:text-red-600 data-[state='can-pre-order']:text-blue-600"
|
|
1027
1027
|
* >
|
|
1028
|
-
* <div className="w-3 h-3 rounded-full data-[state='in-stock']:bg-green-500 data-[state='limited-stock']:bg-yellow-500 data-[state='out-of-stock']:bg-red-500 data-[state='pre-order']:bg-blue-500" />
|
|
1028
|
+
* <div className="w-3 h-3 rounded-full data-[state='in-stock']:bg-green-500 data-[state='limited-stock']:bg-yellow-500 data-[state='out-of-stock']:bg-red-500 data-[state='can-pre-order']:bg-blue-500" />
|
|
1029
1029
|
* <span className="text-sm font-medium">
|
|
1030
1030
|
* {label}
|
|
1031
1031
|
* </span>
|