@wix/headless-stores 0.0.10 → 0.0.12
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/enums/index.d.ts +2 -0
- package/cjs/dist/enums/index.js +18 -0
- package/cjs/dist/enums/social-platform-enums.d.ts +25 -0
- package/cjs/dist/enums/social-platform-enums.js +30 -0
- package/cjs/dist/enums/sort-enums.d.ts +17 -0
- package/cjs/dist/enums/sort-enums.js +21 -0
- package/cjs/dist/react/BuyNow.d.ts +2 -4
- package/cjs/dist/react/Category.d.ts +9 -11
- package/cjs/dist/react/Category.js +8 -23
- package/cjs/dist/react/Collection.d.ts +13 -3
- package/cjs/dist/react/Collection.js +30 -19
- package/cjs/dist/react/FilteredCollection.d.ts +46 -15
- package/cjs/dist/react/FilteredCollection.js +45 -12
- package/cjs/dist/react/PayNow.d.ts +2 -4
- package/cjs/dist/react/Product.d.ts +8 -35
- package/cjs/dist/react/Product.js +10 -31
- package/cjs/dist/react/ProductActions.d.ts +42 -0
- package/cjs/dist/react/ProductActions.js +83 -0
- package/cjs/dist/react/ProductModifiers.d.ts +16 -8
- package/cjs/dist/react/ProductModifiers.js +19 -10
- package/cjs/dist/react/ProductVariantSelector.d.ts +52 -68
- package/cjs/dist/react/ProductVariantSelector.js +58 -86
- package/cjs/dist/react/RelatedProducts.d.ts +8 -4
- package/cjs/dist/react/RelatedProducts.js +12 -7
- package/cjs/dist/react/SelectedVariant.d.ts +66 -0
- package/cjs/dist/react/SelectedVariant.js +52 -0
- package/cjs/dist/react/SocialSharing.d.ts +24 -30
- package/cjs/dist/react/SocialSharing.js +8 -2
- package/cjs/dist/react/Sort.d.ts +12 -15
- package/cjs/dist/react/Sort.js +11 -34
- package/cjs/dist/react/index.d.ts +11 -10
- package/cjs/dist/react/index.js +3 -2
- package/cjs/dist/services/buy-now-service.js +2 -2
- package/cjs/dist/services/catalog-options-service.d.ts +2 -2
- package/cjs/dist/services/catalog-options-service.js +39 -45
- package/cjs/dist/services/catalog-price-range-service.d.ts +2 -2
- package/cjs/dist/services/catalog-price-range-service.js +13 -11
- package/cjs/dist/services/category-service.d.ts +7 -6
- package/cjs/dist/services/category-service.js +15 -11
- package/cjs/dist/services/collection-service.d.ts +8 -8
- package/cjs/dist/services/collection-service.js +182 -67
- package/cjs/dist/services/filter-service.d.ts +1 -1
- package/cjs/dist/services/filter-service.js +15 -23
- package/cjs/dist/services/product-media-gallery-service.d.ts +3 -3
- package/cjs/dist/services/product-modifiers-service.d.ts +6 -8
- package/cjs/dist/services/product-modifiers-service.js +14 -7
- package/cjs/dist/services/product-service.d.ts +8 -7
- package/cjs/dist/services/product-service.js +36 -19
- package/cjs/dist/services/related-products-service.d.ts +4 -4
- package/cjs/dist/services/related-products-service.js +4 -4
- package/cjs/dist/services/selected-variant-service.d.ts +24 -16
- package/cjs/dist/services/selected-variant-service.js +271 -126
- package/cjs/dist/services/social-sharing-service.d.ts +2 -2
- package/cjs/dist/services/social-sharing-service.js +47 -63
- package/cjs/dist/services/sort-service.d.ts +3 -2
- package/cjs/dist/services/sort-service.js +8 -13
- package/dist/enums/index.d.ts +2 -0
- package/dist/enums/index.js +2 -0
- package/dist/enums/social-platform-enums.d.ts +25 -0
- package/dist/enums/social-platform-enums.js +27 -0
- package/dist/enums/sort-enums.d.ts +17 -0
- package/dist/enums/sort-enums.js +18 -0
- package/dist/react/BuyNow.d.ts +2 -4
- package/dist/react/Category.d.ts +9 -11
- package/dist/react/Category.js +10 -23
- package/dist/react/Collection.d.ts +13 -3
- package/dist/react/Collection.js +32 -21
- package/dist/react/FilteredCollection.d.ts +46 -15
- package/dist/react/FilteredCollection.js +49 -16
- package/dist/react/PayNow.d.ts +2 -4
- package/dist/react/Product.d.ts +8 -35
- package/dist/react/Product.js +11 -31
- package/dist/react/ProductActions.d.ts +42 -0
- package/dist/react/ProductActions.js +79 -0
- package/dist/react/ProductModifiers.d.ts +16 -8
- package/dist/react/ProductModifiers.js +22 -13
- package/dist/react/ProductVariantSelector.d.ts +52 -68
- package/dist/react/ProductVariantSelector.js +57 -84
- package/dist/react/RelatedProducts.d.ts +8 -4
- package/dist/react/RelatedProducts.js +15 -10
- package/dist/react/SelectedVariant.d.ts +66 -0
- package/dist/react/SelectedVariant.js +46 -0
- package/dist/react/SocialSharing.d.ts +24 -30
- package/dist/react/SocialSharing.js +11 -5
- package/dist/react/Sort.d.ts +12 -15
- package/dist/react/Sort.js +13 -34
- package/dist/react/index.d.ts +11 -10
- package/dist/react/index.js +11 -10
- package/dist/services/buy-now-service.js +2 -2
- package/dist/services/catalog-options-service.d.ts +2 -2
- package/dist/services/catalog-options-service.js +41 -47
- package/dist/services/catalog-price-range-service.d.ts +2 -2
- package/dist/services/catalog-price-range-service.js +15 -13
- package/dist/services/category-service.d.ts +7 -6
- package/dist/services/category-service.js +17 -13
- package/dist/services/collection-service.d.ts +8 -8
- package/dist/services/collection-service.js +188 -73
- package/dist/services/filter-service.d.ts +1 -1
- package/dist/services/filter-service.js +20 -28
- package/dist/services/product-media-gallery-service.d.ts +3 -3
- package/dist/services/product-modifiers-service.d.ts +6 -8
- package/dist/services/product-modifiers-service.js +16 -9
- package/dist/services/product-service.d.ts +8 -7
- package/dist/services/product-service.js +38 -21
- package/dist/services/related-products-service.d.ts +4 -4
- package/dist/services/related-products-service.js +6 -6
- package/dist/services/selected-variant-service.d.ts +24 -16
- package/dist/services/selected-variant-service.js +273 -127
- package/dist/services/social-sharing-service.d.ts +2 -2
- package/dist/services/social-sharing-service.js +49 -65
- package/dist/services/sort-service.d.ts +3 -2
- package/dist/services/sort-service.js +11 -16
- package/package.json +7 -1
- package/cjs/dist/react/ProductMediaGallery.d.ts +0 -128
- package/cjs/dist/react/ProductMediaGallery.js +0 -100
- package/dist/astro/BuyNowServiceContext.d.ts +0 -2
- package/dist/astro/BuyNowServiceContext.js +0 -6
- package/dist/astro/ManagerProviderContext.d.ts +0 -2
- package/dist/astro/ManagerProviderContext.js +0 -7
- package/dist/astro/withBuyButtonService.d.ts +0 -2
- package/dist/astro/withBuyButtonService.js +0 -16
- package/dist/react/CurrentCartServiceProvider.d.ts +0 -5
- package/dist/react/CurrentCartServiceProvider.js +0 -12
- package/dist/react/ProductMediaGallery.d.ts +0 -128
- package/dist/react/ProductMediaGallery.js +0 -92
- package/dist/react/VariantSelectorServiceProvider.d.ts +0 -7
- package/dist/react/VariantSelectorServiceProvider.js +0 -22
- package/dist/react/hookim/index.d.ts +0 -5
- package/dist/react/hookim/index.js +0 -22
- package/dist/services/CurrentCartService.d.ts +0 -18
- package/dist/services/CurrentCartService.js +0 -9
- package/dist/services/VariantSelectorServices.d.ts +0 -8
- package/dist/services/VariantSelectorServices.js +0 -20
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Reset = exports.Stock = exports.Choice = exports.Option = exports.Options = void 0;
|
|
4
4
|
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
5
5
|
const selected_variant_service_1 = require("../services/selected-variant-service");
|
|
6
|
-
const
|
|
6
|
+
const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
|
|
7
7
|
/**
|
|
8
8
|
* Headless component for all product options
|
|
9
|
+
*
|
|
10
|
+
* @component
|
|
9
11
|
*/
|
|
10
12
|
const Options = (props) => {
|
|
11
13
|
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
|
|
@@ -20,12 +22,14 @@ const Options = (props) => {
|
|
|
20
22
|
exports.Options = Options;
|
|
21
23
|
/**
|
|
22
24
|
* Headless component for choices within a specific product option
|
|
25
|
+
*
|
|
26
|
+
* @component
|
|
23
27
|
*/
|
|
24
28
|
const Option = (props) => {
|
|
25
29
|
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
|
|
26
30
|
const selectedChoices = variantService.selectedChoices.get();
|
|
27
31
|
const { option } = props;
|
|
28
|
-
const name = option.name ||
|
|
32
|
+
const name = option.name || '';
|
|
29
33
|
const choices = option.choicesSettings?.choices || [];
|
|
30
34
|
const selectedValue = selectedChoices[name] || null;
|
|
31
35
|
return props.children({
|
|
@@ -39,16 +43,22 @@ const Option = (props) => {
|
|
|
39
43
|
exports.Option = Option;
|
|
40
44
|
/**
|
|
41
45
|
* Headless component for individual choice selection
|
|
46
|
+
*
|
|
47
|
+
* @component
|
|
42
48
|
*/
|
|
43
49
|
const Choice = (props) => {
|
|
44
50
|
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
|
|
45
51
|
const selectedChoices = variantService.selectedChoices.get();
|
|
46
52
|
const { option, choice } = props;
|
|
47
|
-
const optionName = option.name ||
|
|
48
|
-
const choiceValue = choice.name ||
|
|
53
|
+
const optionName = option.name || '';
|
|
54
|
+
const choiceValue = choice.name || '';
|
|
49
55
|
const isSelected = selectedChoices[optionName] === choiceValue;
|
|
50
56
|
// Check if this choice is available based on current selections
|
|
51
|
-
const
|
|
57
|
+
const isVisible = variantService.isChoiceAvailable(optionName, choiceValue);
|
|
58
|
+
// Check if this choice results in an in-stock variant
|
|
59
|
+
const isInStock = variantService.isChoiceInStock(optionName, choiceValue);
|
|
60
|
+
// Check if this choice is available for pre-order
|
|
61
|
+
const isPreOrderEnabled = variantService.isChoicePreOrderEnabled(optionName, choiceValue);
|
|
52
62
|
const value = choiceValue;
|
|
53
63
|
const onSelect = () => {
|
|
54
64
|
const newChoices = {
|
|
@@ -61,7 +71,9 @@ const Choice = (props) => {
|
|
|
61
71
|
value,
|
|
62
72
|
description: undefined, // v3 choices don't have separate description field
|
|
63
73
|
isSelected,
|
|
64
|
-
|
|
74
|
+
isVisible,
|
|
75
|
+
isInStock,
|
|
76
|
+
isPreOrderEnabled,
|
|
65
77
|
onSelect,
|
|
66
78
|
optionName,
|
|
67
79
|
choiceValue,
|
|
@@ -69,98 +81,58 @@ const Choice = (props) => {
|
|
|
69
81
|
};
|
|
70
82
|
exports.Choice = Choice;
|
|
71
83
|
/**
|
|
72
|
-
* Headless component for
|
|
84
|
+
* Headless component for product stock status
|
|
85
|
+
*
|
|
86
|
+
* @component
|
|
73
87
|
*/
|
|
74
|
-
const
|
|
88
|
+
const Stock = (props) => {
|
|
75
89
|
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
|
|
76
|
-
// Try to get modifiers service - it may not exist for all products
|
|
77
|
-
let modifiersService = null;
|
|
78
|
-
try {
|
|
79
|
-
modifiersService = (0, services_manager_react_1.useService)(product_modifiers_service_1.ProductModifiersServiceDefinition);
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
// Modifiers service not available for this product
|
|
83
|
-
modifiersService = null;
|
|
84
|
-
}
|
|
85
|
-
const price = variantService.currentPrice.get();
|
|
86
90
|
const inStock = variantService.isInStock.get();
|
|
87
91
|
const isPreOrderEnabled = variantService.isPreOrderEnabled.get();
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
await variantService.addToCart(quantity, modifiersData);
|
|
92
|
+
const trackInventory = variantService.trackQuantity.get();
|
|
93
|
+
const currentVariantId = variantService.selectedVariantId.get();
|
|
94
|
+
const availableQuantity = variantService.quantityAvailable.get();
|
|
95
|
+
const selectedQuantity = variantService.selectedQuantity.get();
|
|
96
|
+
// const currentVariant = variantService.currentVariant.get();
|
|
97
|
+
// const allVariantsAreOutOfStock = variantService.IsAllVariantsAreOutOfStock();
|
|
98
|
+
// Return raw availability status - UI components will handle display conversion
|
|
99
|
+
const availabilityStatus = inStock
|
|
100
|
+
? auto_sdk_stores_products_v_3_1.InventoryAvailabilityStatus.IN_STOCK
|
|
101
|
+
: auto_sdk_stores_products_v_3_1.InventoryAvailabilityStatus.OUT_OF_STOCK;
|
|
102
|
+
const incrementQuantity = () => {
|
|
103
|
+
variantService.incrementQuantity();
|
|
104
|
+
};
|
|
105
|
+
const decrementQuantity = () => {
|
|
106
|
+
variantService.decrementQuantity();
|
|
106
107
|
};
|
|
107
108
|
return props.children({
|
|
108
|
-
onAddToCart,
|
|
109
|
-
canAddToCart,
|
|
110
|
-
isLoading,
|
|
111
|
-
price,
|
|
112
109
|
inStock,
|
|
110
|
+
availableQuantity,
|
|
113
111
|
isPreOrderEnabled,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
*/
|
|
121
|
-
const Price = (props) => {
|
|
122
|
-
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
|
|
123
|
-
const price = variantService.currentPrice.get();
|
|
124
|
-
const compareAtPrice = variantService.currentCompareAtPrice.get();
|
|
125
|
-
const currentVariant = variantService.currentVariant.get();
|
|
126
|
-
const currency = variantService.currency.get();
|
|
127
|
-
const isVariantPrice = !!currentVariant;
|
|
128
|
-
return props.children({
|
|
129
|
-
price,
|
|
130
|
-
compareAtPrice,
|
|
131
|
-
isVariantPrice,
|
|
132
|
-
currency,
|
|
112
|
+
currentVariantId,
|
|
113
|
+
availabilityStatus,
|
|
114
|
+
trackInventory,
|
|
115
|
+
selectedQuantity,
|
|
116
|
+
incrementQuantity,
|
|
117
|
+
decrementQuantity,
|
|
133
118
|
});
|
|
134
119
|
};
|
|
135
|
-
exports.
|
|
120
|
+
exports.Stock = Stock;
|
|
136
121
|
/**
|
|
137
|
-
* Headless component for
|
|
122
|
+
* Headless component for resetting variant selections
|
|
123
|
+
*
|
|
124
|
+
* @component
|
|
138
125
|
*/
|
|
139
|
-
const
|
|
126
|
+
const Reset = (props) => {
|
|
140
127
|
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
// Determine status based on stock and pre-order availability
|
|
147
|
-
let status;
|
|
148
|
-
if (inStock) {
|
|
149
|
-
status = "In Stock";
|
|
150
|
-
}
|
|
151
|
-
else if (isPreOrderEnabled) {
|
|
152
|
-
status = "Available for Pre-Order";
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
status = "Out of Stock";
|
|
156
|
-
}
|
|
128
|
+
const selectedChoices = variantService.selectedChoices.get();
|
|
129
|
+
const hasSelections = Object.keys(selectedChoices).length > 0;
|
|
130
|
+
const onReset = () => {
|
|
131
|
+
variantService.resetSelections();
|
|
132
|
+
};
|
|
157
133
|
return props.children({
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
currentVariantId,
|
|
161
|
-
status,
|
|
162
|
-
quantity,
|
|
163
|
-
trackInventory,
|
|
134
|
+
onReset,
|
|
135
|
+
hasSelections,
|
|
164
136
|
});
|
|
165
137
|
};
|
|
166
|
-
exports.
|
|
138
|
+
exports.Reset = Reset;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type V3Product } from '@wix/auto_sdk_stores_products-v-3';
|
|
3
3
|
/**
|
|
4
4
|
* Props for List headless component
|
|
5
5
|
*/
|
|
@@ -12,7 +12,7 @@ export interface ListProps {
|
|
|
12
12
|
*/
|
|
13
13
|
export interface ListRenderProps {
|
|
14
14
|
/** Array of related products */
|
|
15
|
-
products:
|
|
15
|
+
products: V3Product[];
|
|
16
16
|
/** Whether products are loading */
|
|
17
17
|
isLoading: boolean;
|
|
18
18
|
/** Error message if any */
|
|
@@ -24,6 +24,8 @@ export interface ListRenderProps {
|
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Headless component for displaying related products list
|
|
27
|
+
*
|
|
28
|
+
* @component
|
|
27
29
|
*/
|
|
28
30
|
export declare const List: (props: ListProps) => React.ReactNode;
|
|
29
31
|
/**
|
|
@@ -31,7 +33,7 @@ export declare const List: (props: ListProps) => React.ReactNode;
|
|
|
31
33
|
*/
|
|
32
34
|
export interface ItemProps {
|
|
33
35
|
/** Product data */
|
|
34
|
-
product:
|
|
36
|
+
product: V3Product;
|
|
35
37
|
/** Render prop function that receives item data */
|
|
36
38
|
children: (props: ItemRenderProps) => React.ReactNode;
|
|
37
39
|
}
|
|
@@ -56,5 +58,7 @@ export interface ItemRenderProps {
|
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
58
60
|
* Headless component for individual related product item
|
|
61
|
+
*
|
|
62
|
+
* @component
|
|
59
63
|
*/
|
|
60
64
|
export declare const Item: (props: ItemProps) => React.ReactNode;
|
|
@@ -7,8 +7,11 @@ exports.Item = exports.List = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
9
9
|
const related_products_service_1 = require("../services/related-products-service");
|
|
10
|
+
const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
|
|
10
11
|
/**
|
|
11
12
|
* Headless component for displaying related products list
|
|
13
|
+
*
|
|
14
|
+
* @component
|
|
12
15
|
*/
|
|
13
16
|
const List = (props) => {
|
|
14
17
|
const service = (0, services_manager_react_1.useService)(related_products_service_1.RelatedProductsServiceDefinition);
|
|
@@ -23,7 +26,7 @@ const List = (props) => {
|
|
|
23
26
|
service.error.subscribe(setError),
|
|
24
27
|
service.hasRelatedProducts.subscribe(setHasProducts),
|
|
25
28
|
];
|
|
26
|
-
return () => unsubscribes.forEach(
|
|
29
|
+
return () => unsubscribes.forEach(fn => fn());
|
|
27
30
|
}, [service]);
|
|
28
31
|
return props.children({
|
|
29
32
|
products,
|
|
@@ -36,24 +39,26 @@ const List = (props) => {
|
|
|
36
39
|
exports.List = List;
|
|
37
40
|
/**
|
|
38
41
|
* Headless component for individual related product item
|
|
42
|
+
*
|
|
43
|
+
* @component
|
|
39
44
|
*/
|
|
40
45
|
const Item = (props) => {
|
|
41
46
|
const { product } = props;
|
|
42
|
-
const title = product.name ||
|
|
47
|
+
const title = product.name || 'Unknown Product';
|
|
43
48
|
// Use actual v3 media structure - image is directly a string URL
|
|
44
49
|
const image = product.media?.main?.image || null;
|
|
45
50
|
// Create formatted price from raw amount since formattedAmount may not be available
|
|
46
51
|
const rawPrice = product.actualPriceRange?.minValue?.amount;
|
|
47
|
-
const price = rawPrice ? `$${rawPrice}` :
|
|
52
|
+
const price = rawPrice ? `$${rawPrice}` : 'Price unavailable';
|
|
48
53
|
const availabilityStatus = product.inventory?.availabilityStatus;
|
|
49
|
-
const available = availabilityStatus ===
|
|
50
|
-
availabilityStatus ===
|
|
54
|
+
const available = availabilityStatus === auto_sdk_stores_products_v_3_1.InventoryAvailabilityStatus.IN_STOCK ||
|
|
55
|
+
availabilityStatus === auto_sdk_stores_products_v_3_1.InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK;
|
|
51
56
|
const href = `/store/example-2/${product.slug}`;
|
|
52
|
-
const description = typeof product.description ===
|
|
57
|
+
const description = typeof product.description === 'string' ? product.description : '';
|
|
53
58
|
const handleQuickAdd = () => {
|
|
54
59
|
// This would typically add the product to cart
|
|
55
60
|
// For now, we'll just log it
|
|
56
|
-
console.log(
|
|
61
|
+
console.log('Quick add:', product.name);
|
|
57
62
|
};
|
|
58
63
|
return props.children({
|
|
59
64
|
title,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for ProductDetails headless component
|
|
3
|
+
*/
|
|
4
|
+
export interface ProductDetailsProps {
|
|
5
|
+
/** Render prop function that receives product details data */
|
|
6
|
+
children: (props: ProductDetailsRenderProps) => React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Render props for ProductDetails component
|
|
10
|
+
*/
|
|
11
|
+
export interface ProductDetailsRenderProps {
|
|
12
|
+
/** Product SKU */
|
|
13
|
+
sku: string | null;
|
|
14
|
+
/** Product weight */
|
|
15
|
+
weight: string | null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Headless component for selected variant details display
|
|
19
|
+
*
|
|
20
|
+
* @component
|
|
21
|
+
*/
|
|
22
|
+
export declare const Details: (props: ProductDetailsProps) => import("react").ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* Props for Price headless component
|
|
25
|
+
*/
|
|
26
|
+
export interface PriceProps {
|
|
27
|
+
/** Render prop function that receives price data */
|
|
28
|
+
children: (props: PriceRenderProps) => React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Render props for Price component
|
|
32
|
+
*/
|
|
33
|
+
export interface PriceRenderProps {
|
|
34
|
+
/** Current price (formatted) */
|
|
35
|
+
price: string;
|
|
36
|
+
/** Compare at price (formatted) - null if no compare price */
|
|
37
|
+
compareAtPrice: string | null;
|
|
38
|
+
/** Currency code */
|
|
39
|
+
currency: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Headless component for product price display
|
|
43
|
+
*
|
|
44
|
+
* @component
|
|
45
|
+
*/
|
|
46
|
+
export declare const Price: (props: PriceProps) => import("react").ReactNode;
|
|
47
|
+
/**
|
|
48
|
+
* Props for SKU headless component
|
|
49
|
+
*/
|
|
50
|
+
export interface SKUProps {
|
|
51
|
+
/** Render prop function that receives SKU data */
|
|
52
|
+
children: (props: SKURenderProps) => React.ReactNode;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Render props for SKU component
|
|
56
|
+
*/
|
|
57
|
+
export interface SKURenderProps {
|
|
58
|
+
/** Product SKU */
|
|
59
|
+
sku: string | null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Headless component for product SKU display
|
|
63
|
+
*
|
|
64
|
+
* @component
|
|
65
|
+
*/
|
|
66
|
+
export declare const SKU: (props: SKUProps) => import("react").ReactNode;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SKU = exports.Price = exports.Details = void 0;
|
|
4
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
5
|
+
const selected_variant_service_1 = require("../services/selected-variant-service");
|
|
6
|
+
/**
|
|
7
|
+
* Headless component for selected variant details display
|
|
8
|
+
*
|
|
9
|
+
* @component
|
|
10
|
+
*/
|
|
11
|
+
const Details = (props) => {
|
|
12
|
+
const selectedVariantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
|
|
13
|
+
const selectedVariant = selectedVariantService.currentVariant?.get();
|
|
14
|
+
let sku = selectedVariant?.sku || null;
|
|
15
|
+
let weight = selectedVariant?.physicalProperties?.weight?.toString() || null;
|
|
16
|
+
return props.children({
|
|
17
|
+
sku,
|
|
18
|
+
weight,
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
exports.Details = Details;
|
|
22
|
+
/**
|
|
23
|
+
* Headless component for product price display
|
|
24
|
+
*
|
|
25
|
+
* @component
|
|
26
|
+
*/
|
|
27
|
+
const Price = (props) => {
|
|
28
|
+
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
|
|
29
|
+
const price = variantService.currentPrice.get();
|
|
30
|
+
const compareAtPrice = variantService.currentCompareAtPrice.get();
|
|
31
|
+
const currency = variantService.currency.get();
|
|
32
|
+
return props.children({
|
|
33
|
+
price,
|
|
34
|
+
compareAtPrice,
|
|
35
|
+
currency,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
exports.Price = Price;
|
|
39
|
+
/**
|
|
40
|
+
* Headless component for product SKU display
|
|
41
|
+
*
|
|
42
|
+
* @component
|
|
43
|
+
*/
|
|
44
|
+
const SKU = (props) => {
|
|
45
|
+
const selectedVariantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
|
|
46
|
+
const selectedVariant = selectedVariantService.currentVariant?.get();
|
|
47
|
+
const sku = selectedVariant?.sku || null;
|
|
48
|
+
return props.children({
|
|
49
|
+
sku,
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
exports.SKU = SKU;
|
|
@@ -1,25 +1,13 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { SharingPlatform } from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SharingPlatform } from '../services/social-sharing-service';
|
|
3
3
|
export type { SharingPlatform };
|
|
4
|
-
export type RootChildren = (props: RootRenderProps) => React.ReactNode;
|
|
5
4
|
/**
|
|
6
5
|
* Props for Root headless component
|
|
7
6
|
*/
|
|
8
7
|
export interface RootProps {
|
|
9
8
|
/** Render prop function that receives sharing data */
|
|
10
|
-
children:
|
|
9
|
+
children: (props: RootRenderProps) => React.ReactNode;
|
|
11
10
|
}
|
|
12
|
-
export type ShareFacebook = (url: string, title: string, description?: string) => void;
|
|
13
|
-
export type ShareTwitter = (url: string, text: string, hashtags?: string[]) => void;
|
|
14
|
-
export type ShareLinkedIn = (url: string, title: string, summary?: string) => void;
|
|
15
|
-
export type ShareWhatsApp = (url: string, text: string) => void;
|
|
16
|
-
export type ShareEmail = (url: string, subject: string, body: string) => void;
|
|
17
|
-
export type CopyLink = (url: string) => Promise<boolean>;
|
|
18
|
-
export type ShareNative = (data: {
|
|
19
|
-
title: string;
|
|
20
|
-
text: string;
|
|
21
|
-
url: string;
|
|
22
|
-
}) => Promise<boolean>;
|
|
23
11
|
/**
|
|
24
12
|
* Render props for Root component
|
|
25
13
|
*/
|
|
@@ -31,26 +19,30 @@ export interface RootRenderProps {
|
|
|
31
19
|
/** Last shared platform */
|
|
32
20
|
lastShared: string | null;
|
|
33
21
|
/** Share to Facebook */
|
|
34
|
-
shareFacebook:
|
|
22
|
+
shareFacebook: (url: string, title: string, description?: string) => void;
|
|
35
23
|
/** Share to Twitter */
|
|
36
|
-
shareTwitter:
|
|
24
|
+
shareTwitter: (url: string, text: string, hashtags?: string[]) => void;
|
|
37
25
|
/** Share to LinkedIn */
|
|
38
|
-
shareLinkedIn:
|
|
26
|
+
shareLinkedIn: (url: string, title: string, summary?: string) => void;
|
|
39
27
|
/** Share to WhatsApp */
|
|
40
|
-
shareWhatsApp:
|
|
28
|
+
shareWhatsApp: (url: string, text: string) => void;
|
|
41
29
|
/** Share via Email */
|
|
42
|
-
shareEmail:
|
|
30
|
+
shareEmail: (url: string, subject: string, body: string) => void;
|
|
43
31
|
/** Copy to clipboard */
|
|
44
|
-
copyLink:
|
|
32
|
+
copyLink: (url: string) => Promise<boolean>;
|
|
45
33
|
/** Native share API */
|
|
46
|
-
shareNative:
|
|
34
|
+
shareNative: (data: {
|
|
35
|
+
title: string;
|
|
36
|
+
text: string;
|
|
37
|
+
url: string;
|
|
38
|
+
}) => Promise<boolean>;
|
|
47
39
|
}
|
|
48
40
|
/**
|
|
49
41
|
* Headless component for social sharing root
|
|
42
|
+
*
|
|
43
|
+
* @component
|
|
50
44
|
*/
|
|
51
45
|
export declare const Root: (props: RootProps) => React.ReactNode;
|
|
52
|
-
export type OnClick = () => void;
|
|
53
|
-
export type PlatformChildren = (props: PlatformRenderProps) => React.ReactNode;
|
|
54
46
|
/**
|
|
55
47
|
* Props for Platform headless component
|
|
56
48
|
*/
|
|
@@ -58,11 +50,10 @@ export interface PlatformProps {
|
|
|
58
50
|
/** Platform data */
|
|
59
51
|
platform: SharingPlatform;
|
|
60
52
|
/** Click handler */
|
|
61
|
-
onClick:
|
|
53
|
+
onClick: () => void;
|
|
62
54
|
/** Render prop function that receives platform data */
|
|
63
|
-
children:
|
|
55
|
+
children: (props: PlatformRenderProps) => React.ReactNode;
|
|
64
56
|
}
|
|
65
|
-
export type OnSelect = () => void;
|
|
66
57
|
/**
|
|
67
58
|
* Render props for Platform component
|
|
68
59
|
*/
|
|
@@ -70,13 +61,14 @@ export interface PlatformRenderProps {
|
|
|
70
61
|
/** Platform data */
|
|
71
62
|
platform: SharingPlatform;
|
|
72
63
|
/** Platform click handler */
|
|
73
|
-
onSelect:
|
|
64
|
+
onSelect: () => void;
|
|
74
65
|
}
|
|
75
66
|
/**
|
|
76
67
|
* Headless component for individual social platform
|
|
68
|
+
*
|
|
69
|
+
* @component
|
|
77
70
|
*/
|
|
78
71
|
export declare const Platform: (props: PlatformProps) => React.ReactNode;
|
|
79
|
-
export type PlatformsChildren = (props: PlatformsRenderProps) => React.ReactNode;
|
|
80
72
|
/**
|
|
81
73
|
* Props for Platforms headless component
|
|
82
74
|
*/
|
|
@@ -90,7 +82,7 @@ export interface PlatformsProps {
|
|
|
90
82
|
/** Hashtags for sharing */
|
|
91
83
|
hashtags?: string[];
|
|
92
84
|
/** Render prop function that receives platforms data */
|
|
93
|
-
children:
|
|
85
|
+
children: (props: PlatformsRenderProps) => React.ReactNode;
|
|
94
86
|
}
|
|
95
87
|
/**
|
|
96
88
|
* Render props for Platforms component
|
|
@@ -115,5 +107,7 @@ export interface PlatformsRenderProps {
|
|
|
115
107
|
}
|
|
116
108
|
/**
|
|
117
109
|
* Headless component for social sharing platforms with logic
|
|
110
|
+
*
|
|
111
|
+
* @component
|
|
118
112
|
*/
|
|
119
113
|
export declare const Platforms: (props: PlatformsProps) => React.ReactNode;
|
|
@@ -9,6 +9,8 @@ const services_manager_react_1 = require("@wix/services-manager-react");
|
|
|
9
9
|
const social_sharing_service_1 = require("../services/social-sharing-service");
|
|
10
10
|
/**
|
|
11
11
|
* Headless component for social sharing root
|
|
12
|
+
*
|
|
13
|
+
* @component
|
|
12
14
|
*/
|
|
13
15
|
const Root = (props) => {
|
|
14
16
|
const service = (0, services_manager_react_1.useService)(social_sharing_service_1.SocialSharingServiceDefinition);
|
|
@@ -21,7 +23,7 @@ const Root = (props) => {
|
|
|
21
23
|
service.shareCount.subscribe(setShareCount),
|
|
22
24
|
service.lastSharedPlatform.subscribe(setLastShared),
|
|
23
25
|
];
|
|
24
|
-
return () => unsubscribes.forEach(
|
|
26
|
+
return () => unsubscribes.forEach(fn => fn());
|
|
25
27
|
}, [service]);
|
|
26
28
|
return props.children({
|
|
27
29
|
platforms,
|
|
@@ -39,6 +41,8 @@ const Root = (props) => {
|
|
|
39
41
|
exports.Root = Root;
|
|
40
42
|
/**
|
|
41
43
|
* Headless component for individual social platform
|
|
44
|
+
*
|
|
45
|
+
* @component
|
|
42
46
|
*/
|
|
43
47
|
const Platform = (props) => {
|
|
44
48
|
const { platform, onClick } = props;
|
|
@@ -50,9 +54,11 @@ const Platform = (props) => {
|
|
|
50
54
|
exports.Platform = Platform;
|
|
51
55
|
/**
|
|
52
56
|
* Headless component for social sharing platforms with logic
|
|
57
|
+
*
|
|
58
|
+
* @component
|
|
53
59
|
*/
|
|
54
60
|
const Platforms = (props) => {
|
|
55
|
-
const { url, title, description =
|
|
61
|
+
const { url, title, description = '', hashtags = [] } = props;
|
|
56
62
|
const service = (0, services_manager_react_1.useService)(social_sharing_service_1.SocialSharingServiceDefinition);
|
|
57
63
|
const [platforms, setPlatforms] = react_1.default.useState([]);
|
|
58
64
|
react_1.default.useEffect(() => {
|
package/cjs/dist/react/Sort.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { type SortBy } from
|
|
3
|
-
interface SortContextValue {
|
|
4
|
-
currentSort: SortBy;
|
|
5
|
-
setSortBy: (sortBy: SortBy) => void;
|
|
6
|
-
}
|
|
7
|
-
export declare function useSortContext(): SortContextValue;
|
|
8
|
-
export interface ProviderProps {
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
}
|
|
11
|
-
export declare function Provider({ children }: ProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export type SortControllerChildren = (props: SortContextValue) => React.ReactNode;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SortBy } from '../services/sort-service';
|
|
13
3
|
export interface ControllerProps {
|
|
14
|
-
children:
|
|
4
|
+
children: (props: {
|
|
5
|
+
currentSort: SortBy;
|
|
6
|
+
setSortBy: (sortBy: SortBy) => void;
|
|
7
|
+
}) => React.ReactNode;
|
|
15
8
|
}
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Headless component for sorting products
|
|
11
|
+
*
|
|
12
|
+
* @component
|
|
13
|
+
*/
|
|
14
|
+
export declare function Controller(props: ControllerProps): React.ReactNode;
|
package/cjs/dist/react/Sort.js
CHANGED
|
@@ -1,41 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useSortContext = useSortContext;
|
|
4
|
-
exports.Provider = Provider;
|
|
5
3
|
exports.Controller = Controller;
|
|
6
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const sort_service_1 = require("../services/sort-service");
|
|
9
5
|
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
function Provider({ children }) {
|
|
6
|
+
const sort_service_1 = require("../services/sort-service");
|
|
7
|
+
/**
|
|
8
|
+
* Headless component for sorting products
|
|
9
|
+
*
|
|
10
|
+
* @component
|
|
11
|
+
*/
|
|
12
|
+
function Controller(props) {
|
|
13
|
+
const { children } = props;
|
|
19
14
|
const sortService = (0, services_manager_react_1.useService)(sort_service_1.SortServiceDefinition);
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
setCurrentSort(sort);
|
|
24
|
-
});
|
|
25
|
-
// Initialize with current value
|
|
26
|
-
setCurrentSort(sortService.currentSort.get());
|
|
27
|
-
return unsubscribe;
|
|
28
|
-
}, [sortService]);
|
|
29
|
-
const setSortBy = (sortBy) => {
|
|
30
|
-
sortService.setSortBy(sortBy);
|
|
31
|
-
};
|
|
32
|
-
const contextValue = {
|
|
33
|
-
currentSort,
|
|
34
|
-
setSortBy,
|
|
35
|
-
};
|
|
36
|
-
return ((0, jsx_runtime_1.jsx)(SortContext.Provider, { value: contextValue, children: children }));
|
|
37
|
-
}
|
|
38
|
-
function Controller({ children }) {
|
|
39
|
-
const context = useSortContext();
|
|
40
|
-
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children(context) });
|
|
15
|
+
const currentSort = sortService.currentSort.get();
|
|
16
|
+
const setSortBy = sortService.setSortBy;
|
|
17
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({ currentSort, setSortBy }) });
|
|
41
18
|
}
|