@wix/headless-stores 0.0.78 → 0.0.80
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 +86 -0
- package/cjs/dist/react/Product.js +83 -2
- package/cjs/dist/react/ProductList.d.ts +22 -2
- package/cjs/dist/react/ProductList.js +6 -2
- package/dist/react/Product.d.ts +86 -0
- package/dist/react/Product.js +83 -2
- package/dist/react/ProductList.d.ts +22 -2
- package/dist/react/ProductList.js +6 -2
- package/package.json +1 -1
|
@@ -860,6 +860,92 @@ export declare const Action: {
|
|
|
860
860
|
/** Pre-order action button */
|
|
861
861
|
readonly PreOrder: React.ForwardRefExoticComponent<ProductActionProps & React.RefAttributes<HTMLButtonElement>>;
|
|
862
862
|
};
|
|
863
|
+
/**
|
|
864
|
+
* Props for ProductVariantSKU component
|
|
865
|
+
*/
|
|
866
|
+
export interface ProductVariantSKUProps {
|
|
867
|
+
/** Whether to render as a child component */
|
|
868
|
+
asChild?: boolean;
|
|
869
|
+
/** Custom render function when using asChild */
|
|
870
|
+
children?: AsChildChildren<{
|
|
871
|
+
sku: string | null;
|
|
872
|
+
}>;
|
|
873
|
+
/** CSS classes to apply to the default element */
|
|
874
|
+
className?: string;
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Displays the selected variant SKU with customizable rendering following the documented API.
|
|
878
|
+
*
|
|
879
|
+
* @component
|
|
880
|
+
* @example
|
|
881
|
+
* ```tsx
|
|
882
|
+
* // Default usage
|
|
883
|
+
* <Product.ProductVariant.SKU className="text-content-secondary" />
|
|
884
|
+
*
|
|
885
|
+
* // asChild with primitive
|
|
886
|
+
* <Product.ProductVariant.SKU asChild>
|
|
887
|
+
* <span className="sku-value" />
|
|
888
|
+
* </Product.ProductVariant.SKU>
|
|
889
|
+
*
|
|
890
|
+
* // asChild with react component
|
|
891
|
+
* <Product.ProductVariant.SKU asChild>
|
|
892
|
+
* {React.forwardRef(({sku, ...props}, ref) => (
|
|
893
|
+
* <span ref={ref} {...props}>
|
|
894
|
+
* {sku}
|
|
895
|
+
* </span>
|
|
896
|
+
* ))}
|
|
897
|
+
* </Product.ProductVariant.SKU>
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
export declare const ProductVariantSKU: React.ForwardRefExoticComponent<ProductVariantSKUProps & React.RefAttributes<HTMLElement>>;
|
|
901
|
+
/**
|
|
902
|
+
* Props for ProductVariantWeight component
|
|
903
|
+
*/
|
|
904
|
+
export interface ProductVariantWeightProps {
|
|
905
|
+
/** Whether to render as a child component */
|
|
906
|
+
asChild?: boolean;
|
|
907
|
+
/** Custom render function when using asChild */
|
|
908
|
+
children?: AsChildChildren<{
|
|
909
|
+
weight: string | null;
|
|
910
|
+
}>;
|
|
911
|
+
/** CSS classes to apply to the default element */
|
|
912
|
+
className?: string;
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Displays the selected variant weight with customizable rendering following the documented API.
|
|
916
|
+
*
|
|
917
|
+
* @component
|
|
918
|
+
* @example
|
|
919
|
+
* ```tsx
|
|
920
|
+
* // Default usage
|
|
921
|
+
* <Product.ProductVariant.Weight className="text-content-secondary" />
|
|
922
|
+
*
|
|
923
|
+
* // asChild with primitive
|
|
924
|
+
* <Product.ProductVariant.Weight asChild>
|
|
925
|
+
* <span className="weight-value" />
|
|
926
|
+
* </Product.ProductVariant.Weight>
|
|
927
|
+
*
|
|
928
|
+
* // asChild with react component
|
|
929
|
+
* <Product.ProductVariant.Weight asChild>
|
|
930
|
+
* {React.forwardRef(({weight, ...props}, ref) => (
|
|
931
|
+
* <span ref={ref} {...props}>
|
|
932
|
+
* {weight}
|
|
933
|
+
* </span>
|
|
934
|
+
* ))}
|
|
935
|
+
* </Product.ProductVariant.Weight>
|
|
936
|
+
* ```
|
|
937
|
+
*/
|
|
938
|
+
export declare const ProductVariantWeight: React.ForwardRefExoticComponent<ProductVariantWeightProps & React.RefAttributes<HTMLElement>>;
|
|
939
|
+
/**
|
|
940
|
+
* ProductVariant namespace containing product variant components
|
|
941
|
+
* following the compound component pattern: Product.ProductVariant.SKU, Product.ProductVariant.Weight
|
|
942
|
+
*/
|
|
943
|
+
export declare const ProductVariant: {
|
|
944
|
+
/** Product variant SKU component */
|
|
945
|
+
readonly SKU: React.ForwardRefExoticComponent<ProductVariantSKUProps & React.RefAttributes<HTMLElement>>;
|
|
946
|
+
/** Product variant weight component */
|
|
947
|
+
readonly Weight: React.ForwardRefExoticComponent<ProductVariantWeightProps & React.RefAttributes<HTMLElement>>;
|
|
948
|
+
};
|
|
863
949
|
/**
|
|
864
950
|
* Quantity namespace containing all product quantity components
|
|
865
951
|
* following the compound component pattern: Product.Quantity.Root, Product.Quantity.Decrement, etc.
|
|
@@ -47,6 +47,9 @@ var TestIds;
|
|
|
47
47
|
TestIds["productVariants"] = "product-variants";
|
|
48
48
|
TestIds["productVariantOptions"] = "product-variant-options";
|
|
49
49
|
TestIds["productVariantOption"] = "product-variant-option";
|
|
50
|
+
TestIds["productVariant"] = "product-variant";
|
|
51
|
+
TestIds["productVariantSku"] = "product-variant-sku";
|
|
52
|
+
TestIds["productVariantWeight"] = "product-variant-weight";
|
|
50
53
|
TestIds["productModifiers"] = "product-modifiers";
|
|
51
54
|
TestIds["productModifierOptions"] = "product-modifier-options";
|
|
52
55
|
TestIds["productModifierOption"] = "product-modifier-option";
|
|
@@ -780,7 +783,7 @@ export const ProductQuantityDecrement = React.forwardRef((props, ref) => {
|
|
|
780
783
|
if (asChild && children) {
|
|
781
784
|
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productQuantityDecrement, customElement: children, customElementProps: { disabled } }));
|
|
782
785
|
}
|
|
783
|
-
return (_jsx(QuantityComponent.Decrement, { className: className, ref: ref, "data-testid": TestIds.productQuantityDecrement, disabled
|
|
786
|
+
return (_jsx(QuantityComponent.Decrement, { className: className, ref: ref, "data-testid": TestIds.productQuantityDecrement, disabled }));
|
|
784
787
|
} }));
|
|
785
788
|
});
|
|
786
789
|
/**
|
|
@@ -821,7 +824,7 @@ export const ProductQuantityIncrement = React.forwardRef((props, ref) => {
|
|
|
821
824
|
if (asChild && children) {
|
|
822
825
|
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productQuantityIncrement, customElement: children, customElementProps: { disabled } }));
|
|
823
826
|
}
|
|
824
|
-
return (_jsx(QuantityComponent.Increment, { className: className, ref: ref, "data-testid": TestIds.productQuantityIncrement, disabled
|
|
827
|
+
return (_jsx(QuantityComponent.Increment, { className: className, ref: ref, "data-testid": TestIds.productQuantityIncrement, disabled }));
|
|
825
828
|
} }));
|
|
826
829
|
});
|
|
827
830
|
/**
|
|
@@ -935,6 +938,84 @@ export const Action = {
|
|
|
935
938
|
/** Pre-order action button */
|
|
936
939
|
PreOrder: ProductActionPreOrder,
|
|
937
940
|
};
|
|
941
|
+
/**
|
|
942
|
+
* Displays the selected variant SKU with customizable rendering following the documented API.
|
|
943
|
+
*
|
|
944
|
+
* @component
|
|
945
|
+
* @example
|
|
946
|
+
* ```tsx
|
|
947
|
+
* // Default usage
|
|
948
|
+
* <Product.ProductVariant.SKU className="text-content-secondary" />
|
|
949
|
+
*
|
|
950
|
+
* // asChild with primitive
|
|
951
|
+
* <Product.ProductVariant.SKU asChild>
|
|
952
|
+
* <span className="sku-value" />
|
|
953
|
+
* </Product.ProductVariant.SKU>
|
|
954
|
+
*
|
|
955
|
+
* // asChild with react component
|
|
956
|
+
* <Product.ProductVariant.SKU asChild>
|
|
957
|
+
* {React.forwardRef(({sku, ...props}, ref) => (
|
|
958
|
+
* <span ref={ref} {...props}>
|
|
959
|
+
* {sku}
|
|
960
|
+
* </span>
|
|
961
|
+
* ))}
|
|
962
|
+
* </Product.ProductVariant.SKU>
|
|
963
|
+
* ```
|
|
964
|
+
*/
|
|
965
|
+
export const ProductVariantSKU = React.forwardRef((props, ref) => {
|
|
966
|
+
const { asChild, children, className } = props;
|
|
967
|
+
return (_jsx(SelectedVariant.Details, { children: ({ sku }) => {
|
|
968
|
+
// Don't render anything if there's no SKU
|
|
969
|
+
if (!sku) {
|
|
970
|
+
return null;
|
|
971
|
+
}
|
|
972
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productVariantSku, customElement: children, customElementProps: { sku }, content: sku, children: _jsx("span", { children: sku }) }));
|
|
973
|
+
} }));
|
|
974
|
+
});
|
|
975
|
+
/**
|
|
976
|
+
* Displays the selected variant weight with customizable rendering following the documented API.
|
|
977
|
+
*
|
|
978
|
+
* @component
|
|
979
|
+
* @example
|
|
980
|
+
* ```tsx
|
|
981
|
+
* // Default usage
|
|
982
|
+
* <Product.ProductVariant.Weight className="text-content-secondary" />
|
|
983
|
+
*
|
|
984
|
+
* // asChild with primitive
|
|
985
|
+
* <Product.ProductVariant.Weight asChild>
|
|
986
|
+
* <span className="weight-value" />
|
|
987
|
+
* </Product.ProductVariant.Weight>
|
|
988
|
+
*
|
|
989
|
+
* // asChild with react component
|
|
990
|
+
* <Product.ProductVariant.Weight asChild>
|
|
991
|
+
* {React.forwardRef(({weight, ...props}, ref) => (
|
|
992
|
+
* <span ref={ref} {...props}>
|
|
993
|
+
* {weight}
|
|
994
|
+
* </span>
|
|
995
|
+
* ))}
|
|
996
|
+
* </Product.ProductVariant.Weight>
|
|
997
|
+
* ```
|
|
998
|
+
*/
|
|
999
|
+
export const ProductVariantWeight = React.forwardRef((props, ref) => {
|
|
1000
|
+
const { asChild, children, className } = props;
|
|
1001
|
+
return (_jsx(SelectedVariant.Details, { children: ({ weight }) => {
|
|
1002
|
+
// Don't render anything if there's no weight
|
|
1003
|
+
if (!weight) {
|
|
1004
|
+
return null;
|
|
1005
|
+
}
|
|
1006
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productVariantWeight, customElement: children, customElementProps: { weight }, content: weight, children: _jsx("span", { children: weight }) }));
|
|
1007
|
+
} }));
|
|
1008
|
+
});
|
|
1009
|
+
/**
|
|
1010
|
+
* ProductVariant namespace containing product variant components
|
|
1011
|
+
* following the compound component pattern: Product.ProductVariant.SKU, Product.ProductVariant.Weight
|
|
1012
|
+
*/
|
|
1013
|
+
export const ProductVariant = {
|
|
1014
|
+
/** Product variant SKU component */
|
|
1015
|
+
SKU: ProductVariantSKU,
|
|
1016
|
+
/** Product variant weight component */
|
|
1017
|
+
Weight: ProductVariantWeight,
|
|
1018
|
+
};
|
|
938
1019
|
/**
|
|
939
1020
|
* Quantity namespace containing all product quantity components
|
|
940
1021
|
* following the compound component pattern: Product.Quantity.Root, Product.Quantity.Decrement, etc.
|
|
@@ -120,9 +120,29 @@ export declare const ProductRepeater: React.ForwardRefExoticComponent<ProductRep
|
|
|
120
120
|
* Props for ProductList LoadMoreTrigger component
|
|
121
121
|
*/
|
|
122
122
|
export interface LoadMoreTriggerProps {
|
|
123
|
-
|
|
123
|
+
/** Custom render function when using asChild */
|
|
124
|
+
children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLButtonElement, {
|
|
125
|
+
isLoading: boolean;
|
|
126
|
+
hasMoreProducts: boolean;
|
|
127
|
+
loadMore: () => void;
|
|
128
|
+
}>;
|
|
129
|
+
/**
|
|
130
|
+
* Whether to render as a child component.
|
|
131
|
+
* @default false
|
|
132
|
+
*/
|
|
124
133
|
asChild?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* The CSS classes to apply to the button.
|
|
136
|
+
*/
|
|
125
137
|
className?: string;
|
|
138
|
+
/**
|
|
139
|
+
* The label to display inside the button.
|
|
140
|
+
*/
|
|
141
|
+
label?: string;
|
|
142
|
+
/**
|
|
143
|
+
* The loading state to display inside the button.
|
|
144
|
+
*/
|
|
145
|
+
loadingState?: React.ReactNode;
|
|
126
146
|
}
|
|
127
147
|
/**
|
|
128
148
|
* Displays a button to load more products. Not rendered if infiniteScroll is false or no products are left to load.
|
|
@@ -136,7 +156,7 @@ export interface LoadMoreTriggerProps {
|
|
|
136
156
|
* </ProductList.LoadMoreTrigger>
|
|
137
157
|
* ```
|
|
138
158
|
*/
|
|
139
|
-
export declare const LoadMoreTrigger: React.ForwardRefExoticComponent<LoadMoreTriggerProps & React.RefAttributes<
|
|
159
|
+
export declare const LoadMoreTrigger: React.ForwardRefExoticComponent<LoadMoreTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
140
160
|
/**
|
|
141
161
|
* Props for ProductList Totals Displayed component
|
|
142
162
|
*/
|
|
@@ -176,13 +176,17 @@ export const ProductRepeater = React.forwardRef((props, _ref) => {
|
|
|
176
176
|
* ```
|
|
177
177
|
*/
|
|
178
178
|
export const LoadMoreTrigger = React.forwardRef((props, ref) => {
|
|
179
|
-
const { asChild, children, className } = props;
|
|
179
|
+
const { asChild, children, className, label = 'Load More', loadingState = 'Loading...', } = props;
|
|
180
180
|
return (_jsx(CoreProductListPagination.LoadMoreTrigger, { children: ({ loadMore, hasMoreProducts, isLoading }) => {
|
|
181
181
|
// Don't render if no more products to load
|
|
182
182
|
if (!hasMoreProducts)
|
|
183
183
|
return null;
|
|
184
184
|
const handleClick = () => loadMore(10);
|
|
185
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onClick: handleClick, disabled: isLoading, "data-testid": TestIds.productListLoadMore, customElement: children,
|
|
185
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onClick: handleClick, disabled: isLoading, "data-testid": TestIds.productListLoadMore, customElement: children, customElementProps: {
|
|
186
|
+
loadMore,
|
|
187
|
+
hasMoreProducts,
|
|
188
|
+
isLoading,
|
|
189
|
+
}, children: _jsx("button", { children: isLoading ? loadingState : label }) }));
|
|
186
190
|
} }));
|
|
187
191
|
});
|
|
188
192
|
/**
|
package/dist/react/Product.d.ts
CHANGED
|
@@ -860,6 +860,92 @@ export declare const Action: {
|
|
|
860
860
|
/** Pre-order action button */
|
|
861
861
|
readonly PreOrder: React.ForwardRefExoticComponent<ProductActionProps & React.RefAttributes<HTMLButtonElement>>;
|
|
862
862
|
};
|
|
863
|
+
/**
|
|
864
|
+
* Props for ProductVariantSKU component
|
|
865
|
+
*/
|
|
866
|
+
export interface ProductVariantSKUProps {
|
|
867
|
+
/** Whether to render as a child component */
|
|
868
|
+
asChild?: boolean;
|
|
869
|
+
/** Custom render function when using asChild */
|
|
870
|
+
children?: AsChildChildren<{
|
|
871
|
+
sku: string | null;
|
|
872
|
+
}>;
|
|
873
|
+
/** CSS classes to apply to the default element */
|
|
874
|
+
className?: string;
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Displays the selected variant SKU with customizable rendering following the documented API.
|
|
878
|
+
*
|
|
879
|
+
* @component
|
|
880
|
+
* @example
|
|
881
|
+
* ```tsx
|
|
882
|
+
* // Default usage
|
|
883
|
+
* <Product.ProductVariant.SKU className="text-content-secondary" />
|
|
884
|
+
*
|
|
885
|
+
* // asChild with primitive
|
|
886
|
+
* <Product.ProductVariant.SKU asChild>
|
|
887
|
+
* <span className="sku-value" />
|
|
888
|
+
* </Product.ProductVariant.SKU>
|
|
889
|
+
*
|
|
890
|
+
* // asChild with react component
|
|
891
|
+
* <Product.ProductVariant.SKU asChild>
|
|
892
|
+
* {React.forwardRef(({sku, ...props}, ref) => (
|
|
893
|
+
* <span ref={ref} {...props}>
|
|
894
|
+
* {sku}
|
|
895
|
+
* </span>
|
|
896
|
+
* ))}
|
|
897
|
+
* </Product.ProductVariant.SKU>
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
export declare const ProductVariantSKU: React.ForwardRefExoticComponent<ProductVariantSKUProps & React.RefAttributes<HTMLElement>>;
|
|
901
|
+
/**
|
|
902
|
+
* Props for ProductVariantWeight component
|
|
903
|
+
*/
|
|
904
|
+
export interface ProductVariantWeightProps {
|
|
905
|
+
/** Whether to render as a child component */
|
|
906
|
+
asChild?: boolean;
|
|
907
|
+
/** Custom render function when using asChild */
|
|
908
|
+
children?: AsChildChildren<{
|
|
909
|
+
weight: string | null;
|
|
910
|
+
}>;
|
|
911
|
+
/** CSS classes to apply to the default element */
|
|
912
|
+
className?: string;
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Displays the selected variant weight with customizable rendering following the documented API.
|
|
916
|
+
*
|
|
917
|
+
* @component
|
|
918
|
+
* @example
|
|
919
|
+
* ```tsx
|
|
920
|
+
* // Default usage
|
|
921
|
+
* <Product.ProductVariant.Weight className="text-content-secondary" />
|
|
922
|
+
*
|
|
923
|
+
* // asChild with primitive
|
|
924
|
+
* <Product.ProductVariant.Weight asChild>
|
|
925
|
+
* <span className="weight-value" />
|
|
926
|
+
* </Product.ProductVariant.Weight>
|
|
927
|
+
*
|
|
928
|
+
* // asChild with react component
|
|
929
|
+
* <Product.ProductVariant.Weight asChild>
|
|
930
|
+
* {React.forwardRef(({weight, ...props}, ref) => (
|
|
931
|
+
* <span ref={ref} {...props}>
|
|
932
|
+
* {weight}
|
|
933
|
+
* </span>
|
|
934
|
+
* ))}
|
|
935
|
+
* </Product.ProductVariant.Weight>
|
|
936
|
+
* ```
|
|
937
|
+
*/
|
|
938
|
+
export declare const ProductVariantWeight: React.ForwardRefExoticComponent<ProductVariantWeightProps & React.RefAttributes<HTMLElement>>;
|
|
939
|
+
/**
|
|
940
|
+
* ProductVariant namespace containing product variant components
|
|
941
|
+
* following the compound component pattern: Product.ProductVariant.SKU, Product.ProductVariant.Weight
|
|
942
|
+
*/
|
|
943
|
+
export declare const ProductVariant: {
|
|
944
|
+
/** Product variant SKU component */
|
|
945
|
+
readonly SKU: React.ForwardRefExoticComponent<ProductVariantSKUProps & React.RefAttributes<HTMLElement>>;
|
|
946
|
+
/** Product variant weight component */
|
|
947
|
+
readonly Weight: React.ForwardRefExoticComponent<ProductVariantWeightProps & React.RefAttributes<HTMLElement>>;
|
|
948
|
+
};
|
|
863
949
|
/**
|
|
864
950
|
* Quantity namespace containing all product quantity components
|
|
865
951
|
* following the compound component pattern: Product.Quantity.Root, Product.Quantity.Decrement, etc.
|
package/dist/react/Product.js
CHANGED
|
@@ -47,6 +47,9 @@ var TestIds;
|
|
|
47
47
|
TestIds["productVariants"] = "product-variants";
|
|
48
48
|
TestIds["productVariantOptions"] = "product-variant-options";
|
|
49
49
|
TestIds["productVariantOption"] = "product-variant-option";
|
|
50
|
+
TestIds["productVariant"] = "product-variant";
|
|
51
|
+
TestIds["productVariantSku"] = "product-variant-sku";
|
|
52
|
+
TestIds["productVariantWeight"] = "product-variant-weight";
|
|
50
53
|
TestIds["productModifiers"] = "product-modifiers";
|
|
51
54
|
TestIds["productModifierOptions"] = "product-modifier-options";
|
|
52
55
|
TestIds["productModifierOption"] = "product-modifier-option";
|
|
@@ -780,7 +783,7 @@ export const ProductQuantityDecrement = React.forwardRef((props, ref) => {
|
|
|
780
783
|
if (asChild && children) {
|
|
781
784
|
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productQuantityDecrement, customElement: children, customElementProps: { disabled } }));
|
|
782
785
|
}
|
|
783
|
-
return (_jsx(QuantityComponent.Decrement, { className: className, ref: ref, "data-testid": TestIds.productQuantityDecrement, disabled
|
|
786
|
+
return (_jsx(QuantityComponent.Decrement, { className: className, ref: ref, "data-testid": TestIds.productQuantityDecrement, disabled }));
|
|
784
787
|
} }));
|
|
785
788
|
});
|
|
786
789
|
/**
|
|
@@ -821,7 +824,7 @@ export const ProductQuantityIncrement = React.forwardRef((props, ref) => {
|
|
|
821
824
|
if (asChild && children) {
|
|
822
825
|
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productQuantityIncrement, customElement: children, customElementProps: { disabled } }));
|
|
823
826
|
}
|
|
824
|
-
return (_jsx(QuantityComponent.Increment, { className: className, ref: ref, "data-testid": TestIds.productQuantityIncrement, disabled
|
|
827
|
+
return (_jsx(QuantityComponent.Increment, { className: className, ref: ref, "data-testid": TestIds.productQuantityIncrement, disabled }));
|
|
825
828
|
} }));
|
|
826
829
|
});
|
|
827
830
|
/**
|
|
@@ -935,6 +938,84 @@ export const Action = {
|
|
|
935
938
|
/** Pre-order action button */
|
|
936
939
|
PreOrder: ProductActionPreOrder,
|
|
937
940
|
};
|
|
941
|
+
/**
|
|
942
|
+
* Displays the selected variant SKU with customizable rendering following the documented API.
|
|
943
|
+
*
|
|
944
|
+
* @component
|
|
945
|
+
* @example
|
|
946
|
+
* ```tsx
|
|
947
|
+
* // Default usage
|
|
948
|
+
* <Product.ProductVariant.SKU className="text-content-secondary" />
|
|
949
|
+
*
|
|
950
|
+
* // asChild with primitive
|
|
951
|
+
* <Product.ProductVariant.SKU asChild>
|
|
952
|
+
* <span className="sku-value" />
|
|
953
|
+
* </Product.ProductVariant.SKU>
|
|
954
|
+
*
|
|
955
|
+
* // asChild with react component
|
|
956
|
+
* <Product.ProductVariant.SKU asChild>
|
|
957
|
+
* {React.forwardRef(({sku, ...props}, ref) => (
|
|
958
|
+
* <span ref={ref} {...props}>
|
|
959
|
+
* {sku}
|
|
960
|
+
* </span>
|
|
961
|
+
* ))}
|
|
962
|
+
* </Product.ProductVariant.SKU>
|
|
963
|
+
* ```
|
|
964
|
+
*/
|
|
965
|
+
export const ProductVariantSKU = React.forwardRef((props, ref) => {
|
|
966
|
+
const { asChild, children, className } = props;
|
|
967
|
+
return (_jsx(SelectedVariant.Details, { children: ({ sku }) => {
|
|
968
|
+
// Don't render anything if there's no SKU
|
|
969
|
+
if (!sku) {
|
|
970
|
+
return null;
|
|
971
|
+
}
|
|
972
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productVariantSku, customElement: children, customElementProps: { sku }, content: sku, children: _jsx("span", { children: sku }) }));
|
|
973
|
+
} }));
|
|
974
|
+
});
|
|
975
|
+
/**
|
|
976
|
+
* Displays the selected variant weight with customizable rendering following the documented API.
|
|
977
|
+
*
|
|
978
|
+
* @component
|
|
979
|
+
* @example
|
|
980
|
+
* ```tsx
|
|
981
|
+
* // Default usage
|
|
982
|
+
* <Product.ProductVariant.Weight className="text-content-secondary" />
|
|
983
|
+
*
|
|
984
|
+
* // asChild with primitive
|
|
985
|
+
* <Product.ProductVariant.Weight asChild>
|
|
986
|
+
* <span className="weight-value" />
|
|
987
|
+
* </Product.ProductVariant.Weight>
|
|
988
|
+
*
|
|
989
|
+
* // asChild with react component
|
|
990
|
+
* <Product.ProductVariant.Weight asChild>
|
|
991
|
+
* {React.forwardRef(({weight, ...props}, ref) => (
|
|
992
|
+
* <span ref={ref} {...props}>
|
|
993
|
+
* {weight}
|
|
994
|
+
* </span>
|
|
995
|
+
* ))}
|
|
996
|
+
* </Product.ProductVariant.Weight>
|
|
997
|
+
* ```
|
|
998
|
+
*/
|
|
999
|
+
export const ProductVariantWeight = React.forwardRef((props, ref) => {
|
|
1000
|
+
const { asChild, children, className } = props;
|
|
1001
|
+
return (_jsx(SelectedVariant.Details, { children: ({ weight }) => {
|
|
1002
|
+
// Don't render anything if there's no weight
|
|
1003
|
+
if (!weight) {
|
|
1004
|
+
return null;
|
|
1005
|
+
}
|
|
1006
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productVariantWeight, customElement: children, customElementProps: { weight }, content: weight, children: _jsx("span", { children: weight }) }));
|
|
1007
|
+
} }));
|
|
1008
|
+
});
|
|
1009
|
+
/**
|
|
1010
|
+
* ProductVariant namespace containing product variant components
|
|
1011
|
+
* following the compound component pattern: Product.ProductVariant.SKU, Product.ProductVariant.Weight
|
|
1012
|
+
*/
|
|
1013
|
+
export const ProductVariant = {
|
|
1014
|
+
/** Product variant SKU component */
|
|
1015
|
+
SKU: ProductVariantSKU,
|
|
1016
|
+
/** Product variant weight component */
|
|
1017
|
+
Weight: ProductVariantWeight,
|
|
1018
|
+
};
|
|
938
1019
|
/**
|
|
939
1020
|
* Quantity namespace containing all product quantity components
|
|
940
1021
|
* following the compound component pattern: Product.Quantity.Root, Product.Quantity.Decrement, etc.
|
|
@@ -120,9 +120,29 @@ export declare const ProductRepeater: React.ForwardRefExoticComponent<ProductRep
|
|
|
120
120
|
* Props for ProductList LoadMoreTrigger component
|
|
121
121
|
*/
|
|
122
122
|
export interface LoadMoreTriggerProps {
|
|
123
|
-
|
|
123
|
+
/** Custom render function when using asChild */
|
|
124
|
+
children?: React.ReactNode | React.ForwardRefRenderFunction<HTMLButtonElement, {
|
|
125
|
+
isLoading: boolean;
|
|
126
|
+
hasMoreProducts: boolean;
|
|
127
|
+
loadMore: () => void;
|
|
128
|
+
}>;
|
|
129
|
+
/**
|
|
130
|
+
* Whether to render as a child component.
|
|
131
|
+
* @default false
|
|
132
|
+
*/
|
|
124
133
|
asChild?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* The CSS classes to apply to the button.
|
|
136
|
+
*/
|
|
125
137
|
className?: string;
|
|
138
|
+
/**
|
|
139
|
+
* The label to display inside the button.
|
|
140
|
+
*/
|
|
141
|
+
label?: string;
|
|
142
|
+
/**
|
|
143
|
+
* The loading state to display inside the button.
|
|
144
|
+
*/
|
|
145
|
+
loadingState?: React.ReactNode;
|
|
126
146
|
}
|
|
127
147
|
/**
|
|
128
148
|
* Displays a button to load more products. Not rendered if infiniteScroll is false or no products are left to load.
|
|
@@ -136,7 +156,7 @@ export interface LoadMoreTriggerProps {
|
|
|
136
156
|
* </ProductList.LoadMoreTrigger>
|
|
137
157
|
* ```
|
|
138
158
|
*/
|
|
139
|
-
export declare const LoadMoreTrigger: React.ForwardRefExoticComponent<LoadMoreTriggerProps & React.RefAttributes<
|
|
159
|
+
export declare const LoadMoreTrigger: React.ForwardRefExoticComponent<LoadMoreTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
140
160
|
/**
|
|
141
161
|
* Props for ProductList Totals Displayed component
|
|
142
162
|
*/
|
|
@@ -176,13 +176,17 @@ export const ProductRepeater = React.forwardRef((props, _ref) => {
|
|
|
176
176
|
* ```
|
|
177
177
|
*/
|
|
178
178
|
export const LoadMoreTrigger = React.forwardRef((props, ref) => {
|
|
179
|
-
const { asChild, children, className } = props;
|
|
179
|
+
const { asChild, children, className, label = 'Load More', loadingState = 'Loading...', } = props;
|
|
180
180
|
return (_jsx(CoreProductListPagination.LoadMoreTrigger, { children: ({ loadMore, hasMoreProducts, isLoading }) => {
|
|
181
181
|
// Don't render if no more products to load
|
|
182
182
|
if (!hasMoreProducts)
|
|
183
183
|
return null;
|
|
184
184
|
const handleClick = () => loadMore(10);
|
|
185
|
-
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onClick: handleClick, disabled: isLoading, "data-testid": TestIds.productListLoadMore, customElement: children,
|
|
185
|
+
return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onClick: handleClick, disabled: isLoading, "data-testid": TestIds.productListLoadMore, customElement: children, customElementProps: {
|
|
186
|
+
loadMore,
|
|
187
|
+
hasMoreProducts,
|
|
188
|
+
isLoading,
|
|
189
|
+
}, children: _jsx("button", { children: isLoading ? loadingState : label }) }));
|
|
186
190
|
} }));
|
|
187
191
|
});
|
|
188
192
|
/**
|