@wix/headless-stores 0.0.110 → 0.0.111
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/astro/actions/custom-checkout.d.ts +1 -3
- package/cjs/dist/astro/actions/custom-checkout.js +8 -4
- package/cjs/dist/astro/actions/index.js +17 -1
- package/cjs/dist/data-component-tags.js +5 -2
- package/cjs/dist/enums/index.js +18 -2
- package/cjs/dist/enums/social-platform-enums.js +7 -4
- package/cjs/dist/enums/sort-enums.js +6 -3
- package/cjs/dist/react/Category.js +64 -25
- package/cjs/dist/react/CategoryList.js +55 -14
- package/cjs/dist/react/Choice.js +32 -25
- package/cjs/dist/react/Option.js +68 -29
- package/cjs/dist/react/Product.js +194 -155
- package/cjs/dist/react/ProductList.js +84 -45
- package/cjs/dist/react/core/CategoryList.js +26 -16
- package/cjs/dist/react/core/Product.js +30 -20
- package/cjs/dist/react/core/ProductList.js +29 -21
- package/cjs/dist/react/core/ProductListFilters.js +30 -22
- package/cjs/dist/react/core/ProductListPagination.js +7 -4
- package/cjs/dist/react/core/ProductListSort.js +11 -6
- package/cjs/dist/react/core/ProductModifiers.js +25 -17
- package/cjs/dist/react/core/ProductVariantSelector.js +27 -19
- package/cjs/dist/react/core/SelectedVariant.js +28 -21
- package/cjs/dist/react/index.js +42 -6
- package/cjs/dist/react/types.js +5 -2
- package/cjs/dist/server-actions/custom-checkout-action.js +11 -8
- package/cjs/dist/server-actions/index.js +17 -1
- package/cjs/dist/services/buy-now-service.js +20 -15
- package/cjs/dist/services/categories-list-service.js +12 -8
- package/cjs/dist/services/index.js +25 -5
- package/cjs/dist/services/pay-now-service.js +16 -11
- package/cjs/dist/services/product-modifiers-service.js +16 -12
- package/cjs/dist/services/product-service.js +16 -12
- package/cjs/dist/services/products-list-search-service.d.ts +0 -1
- package/cjs/dist/services/products-list-search-service.js +1 -1
- package/cjs/dist/services/products-list-service.js +66 -59
- package/cjs/dist/services/selected-variant-service.js +21 -18
- package/cjs/dist/utils/index.js +9 -6
- package/cjs/dist/utils/url-params.js +5 -1
- package/dist/astro/actions/custom-checkout.d.ts +1 -3
- package/package.json +5 -5
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoadMoreTrigger = LoadMoreTrigger;
|
|
4
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
5
|
+
const products_list_service_js_1 = require("../../services/products-list-service.js");
|
|
3
6
|
/**
|
|
4
7
|
* Headless component for loading more products (infinite scroll pattern)
|
|
5
8
|
*
|
|
@@ -30,8 +33,8 @@ import { ProductsListServiceDefinition } from '../../services/products-list-serv
|
|
|
30
33
|
* }
|
|
31
34
|
* ```
|
|
32
35
|
*/
|
|
33
|
-
|
|
34
|
-
const productsListService = useService(ProductsListServiceDefinition);
|
|
36
|
+
function LoadMoreTrigger(props) {
|
|
37
|
+
const productsListService = (0, services_manager_react_1.useService)(products_list_service_js_1.ProductsListServiceDefinition);
|
|
35
38
|
const loadMore = productsListService.loadMore;
|
|
36
39
|
const hasMoreProducts = productsListService.hasMoreProducts.get();
|
|
37
40
|
const isLoading = productsListService.isLoading.get();
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProductListSort = void 0;
|
|
4
|
+
exports.ProductListSeperateSort = ProductListSeperateSort;
|
|
5
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
6
|
+
const products_list_service_js_1 = require("../../services/products-list-service.js");
|
|
7
|
+
const ProductListSort = (props) => {
|
|
8
|
+
const productListService = (0, services_manager_react_1.useService)(products_list_service_js_1.ProductsListServiceDefinition);
|
|
5
9
|
const currentSort = productListService.searchOptions.get().sort;
|
|
6
10
|
// Define sort options - primitive handles all conversion logic
|
|
7
11
|
const sortOptions = [
|
|
@@ -26,8 +30,9 @@ export const ProductListSort = (props) => {
|
|
|
26
30
|
},
|
|
27
31
|
});
|
|
28
32
|
};
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
exports.ProductListSort = ProductListSort;
|
|
34
|
+
function ProductListSeperateSort(props) {
|
|
35
|
+
const productListService = (0, services_manager_react_1.useService)(products_list_service_js_1.ProductsListServiceDefinition);
|
|
31
36
|
const currentSort = productListService.searchOptions.get().sort;
|
|
32
37
|
// Define sort options - primitive handles all conversion logic
|
|
33
38
|
const sortFieldOptions = [
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Root = Root;
|
|
4
|
+
exports.Modifiers = Modifiers;
|
|
5
|
+
exports.Modifier = Modifier;
|
|
6
|
+
exports.Choice = Choice;
|
|
7
|
+
exports.FreeText = FreeText;
|
|
8
|
+
exports.ToggleFreeText = ToggleFreeText;
|
|
9
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
12
|
+
const product_modifiers_service_js_1 = require("../../services/product-modifiers-service.js");
|
|
13
|
+
const stores_1 = require("@wix/stores");
|
|
14
|
+
const services_manager_1 = require("@wix/services-manager");
|
|
7
15
|
/**
|
|
8
16
|
* Root component that provides the ProductModifiers service context to its children.
|
|
9
17
|
* This component sets up the necessary services for managing product modifier functionality.
|
|
@@ -78,15 +86,15 @@ import { createServicesMap } from '@wix/services-manager';
|
|
|
78
86
|
* }
|
|
79
87
|
* ```
|
|
80
88
|
*/
|
|
81
|
-
|
|
82
|
-
return (
|
|
89
|
+
function Root(props) {
|
|
90
|
+
return ((0, jsx_runtime_1.jsx)(services_manager_react_1.WixServices, { servicesMap: (0, services_manager_1.createServicesMap)().addService(product_modifiers_service_js_1.ProductModifiersServiceDefinition, product_modifiers_service_js_1.ProductModifiersService, {}), children: props.children }));
|
|
83
91
|
}
|
|
84
92
|
/**
|
|
85
93
|
* Custom hook to safely get the modifiers service
|
|
86
94
|
*/
|
|
87
95
|
function useModifiersService() {
|
|
88
96
|
try {
|
|
89
|
-
return useService(ProductModifiersServiceDefinition);
|
|
97
|
+
return (0, services_manager_react_1.useService)(product_modifiers_service_js_1.ProductModifiersServiceDefinition);
|
|
90
98
|
}
|
|
91
99
|
catch {
|
|
92
100
|
return null;
|
|
@@ -137,7 +145,7 @@ function useModifiersService() {
|
|
|
137
145
|
* }
|
|
138
146
|
* ```
|
|
139
147
|
*/
|
|
140
|
-
|
|
148
|
+
function Modifiers(props) {
|
|
141
149
|
const modifiersService = useModifiersService();
|
|
142
150
|
if (!modifiersService) {
|
|
143
151
|
return props.children({
|
|
@@ -204,7 +212,7 @@ export function Modifiers(props) {
|
|
|
204
212
|
* }
|
|
205
213
|
* ```
|
|
206
214
|
*/
|
|
207
|
-
|
|
215
|
+
function Modifier(props) {
|
|
208
216
|
const modifiersService = useModifiersService();
|
|
209
217
|
const { modifier } = props;
|
|
210
218
|
const name = modifier.name || '';
|
|
@@ -214,7 +222,7 @@ export function Modifier(props) {
|
|
|
214
222
|
const mandatory = modifier.mandatory || false;
|
|
215
223
|
const choices = modifier.choicesSettings?.choices || [];
|
|
216
224
|
const hasChoices = choices.length > 0;
|
|
217
|
-
const isFreeText = type === productsV3.ModifierRenderType.FREE_TEXT;
|
|
225
|
+
const isFreeText = type === stores_1.productsV3.ModifierRenderType.FREE_TEXT;
|
|
218
226
|
const freeTextSettings = modifier.freeTextSettings;
|
|
219
227
|
const maxChars = freeTextSettings?.maxLength;
|
|
220
228
|
const placeholder = freeTextSettings?.placeholder;
|
|
@@ -262,13 +270,13 @@ export function Modifier(props) {
|
|
|
262
270
|
* }
|
|
263
271
|
* ```
|
|
264
272
|
*/
|
|
265
|
-
|
|
273
|
+
function Choice(props) {
|
|
266
274
|
const modifiersService = useModifiersService();
|
|
267
275
|
const { modifier, choice } = props;
|
|
268
276
|
const modifierName = modifier.name || '';
|
|
269
277
|
const renderType = modifier.modifierRenderType;
|
|
270
278
|
// For TEXT_CHOICES, use choice.key; for SWATCH_CHOICES, use choice.name
|
|
271
|
-
const choiceValue = renderType === productsV3.ModifierRenderType.TEXT_CHOICES
|
|
279
|
+
const choiceValue = renderType === stores_1.productsV3.ModifierRenderType.TEXT_CHOICES
|
|
272
280
|
? choice.key || choice.name || ''
|
|
273
281
|
: choice.name || '';
|
|
274
282
|
const value = choice.name || ''; // Display name is always choice.name
|
|
@@ -324,7 +332,7 @@ export function Choice(props) {
|
|
|
324
332
|
* }
|
|
325
333
|
* ```
|
|
326
334
|
*/
|
|
327
|
-
|
|
335
|
+
function FreeText(props) {
|
|
328
336
|
const modifiersService = useModifiersService();
|
|
329
337
|
const { modifier } = props;
|
|
330
338
|
const modifierName = modifier.name || '';
|
|
@@ -394,12 +402,12 @@ export function FreeText(props) {
|
|
|
394
402
|
* }
|
|
395
403
|
* ```
|
|
396
404
|
*/
|
|
397
|
-
|
|
405
|
+
function ToggleFreeText(props) {
|
|
398
406
|
const modifiersService = useModifiersService();
|
|
399
407
|
const { modifier } = props;
|
|
400
408
|
const modifierName = modifier.name || '';
|
|
401
409
|
const mandatory = modifier.mandatory || false;
|
|
402
|
-
const [isTextInputShown, setIsTextInputShown] = useState(mandatory);
|
|
410
|
+
const [isTextInputShown, setIsTextInputShown] = (0, react_1.useState)(mandatory);
|
|
403
411
|
const toggle = () => {
|
|
404
412
|
const newState = !isTextInputShown;
|
|
405
413
|
setIsTextInputShown(newState);
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Root = Root;
|
|
4
|
+
exports.Options = Options;
|
|
5
|
+
exports.Option = Option;
|
|
6
|
+
exports.Choice = Choice;
|
|
7
|
+
exports.Stock = Stock;
|
|
8
|
+
exports.Reset = Reset;
|
|
9
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
10
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
11
|
+
const selected_variant_service_js_1 = require("../../services/selected-variant-service.js");
|
|
12
|
+
const services_manager_1 = require("@wix/services-manager");
|
|
13
|
+
const stores_1 = require("@wix/stores");
|
|
6
14
|
/**
|
|
7
15
|
* Root component that provides the ProductVariantSelector service context to its children.
|
|
8
16
|
* This component sets up the necessary services for rendering and managing product variant selection.
|
|
@@ -41,8 +49,8 @@ import { productsV3 } from '@wix/stores';
|
|
|
41
49
|
* }
|
|
42
50
|
* ```
|
|
43
51
|
*/
|
|
44
|
-
|
|
45
|
-
return (
|
|
52
|
+
function Root(props) {
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(services_manager_react_1.WixServices, { servicesMap: (0, services_manager_1.createServicesMap)().addService(selected_variant_service_js_1.SelectedVariantServiceDefinition, selected_variant_service_js_1.SelectedVariantService, props.selectedVariantServiceConfig), children: props.children }));
|
|
46
54
|
}
|
|
47
55
|
/**
|
|
48
56
|
* Headless component for all product options
|
|
@@ -76,8 +84,8 @@ export function Root(props) {
|
|
|
76
84
|
* }
|
|
77
85
|
* ```
|
|
78
86
|
*/
|
|
79
|
-
|
|
80
|
-
const variantService = useService(SelectedVariantServiceDefinition);
|
|
87
|
+
function Options(props) {
|
|
88
|
+
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_js_1.SelectedVariantServiceDefinition);
|
|
81
89
|
const selectedChoices = variantService.selectedChoices.get();
|
|
82
90
|
const options = variantService.productOptions.get();
|
|
83
91
|
return props.children({
|
|
@@ -117,8 +125,8 @@ export function Options(props) {
|
|
|
117
125
|
* }
|
|
118
126
|
* ```
|
|
119
127
|
*/
|
|
120
|
-
|
|
121
|
-
const variantService = useService(SelectedVariantServiceDefinition);
|
|
128
|
+
function Option(props) {
|
|
129
|
+
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_js_1.SelectedVariantServiceDefinition);
|
|
122
130
|
const selectedChoices = variantService.selectedChoices.get();
|
|
123
131
|
const { option } = props;
|
|
124
132
|
const name = option.name || '';
|
|
@@ -160,8 +168,8 @@ export function Option(props) {
|
|
|
160
168
|
* }
|
|
161
169
|
* ```
|
|
162
170
|
*/
|
|
163
|
-
|
|
164
|
-
const variantService = useService(SelectedVariantServiceDefinition);
|
|
171
|
+
function Choice(props) {
|
|
172
|
+
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_js_1.SelectedVariantServiceDefinition);
|
|
165
173
|
const selectedChoices = variantService.selectedChoices.get();
|
|
166
174
|
const { option, choice } = props;
|
|
167
175
|
const optionName = option.name || '';
|
|
@@ -229,8 +237,8 @@ export function Choice(props) {
|
|
|
229
237
|
* }
|
|
230
238
|
* ```
|
|
231
239
|
*/
|
|
232
|
-
|
|
233
|
-
const variantService = useService(SelectedVariantServiceDefinition);
|
|
240
|
+
function Stock(props) {
|
|
241
|
+
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_js_1.SelectedVariantServiceDefinition);
|
|
234
242
|
const inStock = variantService.isInStock.get();
|
|
235
243
|
const isPreOrderEnabled = variantService.isPreOrderEnabled.get();
|
|
236
244
|
const trackInventory = variantService.trackQuantity.get();
|
|
@@ -239,8 +247,8 @@ export function Stock(props) {
|
|
|
239
247
|
const selectedQuantity = variantService.selectedQuantity.get();
|
|
240
248
|
// Return raw availability status - UI components will handle display conversion
|
|
241
249
|
const availabilityStatus = inStock
|
|
242
|
-
? productsV3.InventoryAvailabilityStatus.IN_STOCK
|
|
243
|
-
: productsV3.InventoryAvailabilityStatus.OUT_OF_STOCK;
|
|
250
|
+
? stores_1.productsV3.InventoryAvailabilityStatus.IN_STOCK
|
|
251
|
+
: stores_1.productsV3.InventoryAvailabilityStatus.OUT_OF_STOCK;
|
|
244
252
|
const incrementQuantity = () => {
|
|
245
253
|
variantService.incrementQuantity();
|
|
246
254
|
};
|
|
@@ -286,8 +294,8 @@ export function Stock(props) {
|
|
|
286
294
|
* }
|
|
287
295
|
* ```
|
|
288
296
|
*/
|
|
289
|
-
|
|
290
|
-
const variantService = useService(SelectedVariantServiceDefinition);
|
|
297
|
+
function Reset(props) {
|
|
298
|
+
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_js_1.SelectedVariantServiceDefinition);
|
|
291
299
|
const selectedChoices = variantService.selectedChoices.get();
|
|
292
300
|
const hasSelections = Object.keys(selectedChoices).length > 0;
|
|
293
301
|
const reset = () => {
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Root = Root;
|
|
4
|
+
exports.Details = Details;
|
|
5
|
+
exports.Price = Price;
|
|
6
|
+
exports.SKU = SKU;
|
|
7
|
+
exports.Actions = Actions;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
10
|
+
const selected_variant_service_js_1 = require("../../services/selected-variant-service.js");
|
|
11
|
+
const product_modifiers_service_js_1 = require("../../services/product-modifiers-service.js");
|
|
12
|
+
const services_manager_1 = require("@wix/services-manager");
|
|
13
|
+
const react_1 = require("@wix/headless-ecom/react");
|
|
14
|
+
const services_1 = require("@wix/headless-ecom/services");
|
|
8
15
|
/**
|
|
9
16
|
* Root component that provides the SelectedVariant service context to its children.
|
|
10
17
|
* This component sets up the necessary services for rendering and managing selected variant data.
|
|
@@ -38,8 +45,8 @@ import { CheckoutServiceDefinition, CurrentCartServiceDefinition, } from '@wix/h
|
|
|
38
45
|
* }
|
|
39
46
|
* ```
|
|
40
47
|
*/
|
|
41
|
-
|
|
42
|
-
return (
|
|
48
|
+
function Root(props) {
|
|
49
|
+
return ((0, jsx_runtime_1.jsx)(services_manager_react_1.WixServices, { servicesMap: (0, services_manager_1.createServicesMap)().addService(selected_variant_service_js_1.SelectedVariantServiceDefinition, selected_variant_service_js_1.SelectedVariantService, props.selectedVariantServiceConfig), children: props.children }));
|
|
43
50
|
}
|
|
44
51
|
/**
|
|
45
52
|
* Headless component for selected variant details display
|
|
@@ -63,8 +70,8 @@ export function Root(props) {
|
|
|
63
70
|
* }
|
|
64
71
|
* ```
|
|
65
72
|
*/
|
|
66
|
-
|
|
67
|
-
const selectedVariantService = useService(SelectedVariantServiceDefinition);
|
|
73
|
+
function Details(props) {
|
|
74
|
+
const selectedVariantService = (0, services_manager_react_1.useService)(selected_variant_service_js_1.SelectedVariantServiceDefinition);
|
|
68
75
|
const selectedVariant = selectedVariantService.currentVariant?.get();
|
|
69
76
|
let sku = selectedVariant?.sku || null;
|
|
70
77
|
let weight = selectedVariant?.physicalProperties?.weight?.toString() || null;
|
|
@@ -100,8 +107,8 @@ export function Details(props) {
|
|
|
100
107
|
* }
|
|
101
108
|
* ```
|
|
102
109
|
*/
|
|
103
|
-
|
|
104
|
-
const variantService = useService(SelectedVariantServiceDefinition);
|
|
110
|
+
function Price(props) {
|
|
111
|
+
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_js_1.SelectedVariantServiceDefinition);
|
|
105
112
|
const price = variantService.currentPrice.get();
|
|
106
113
|
const compareAtPrice = variantService.currentCompareAtPrice.get();
|
|
107
114
|
const currency = variantService.currency.get();
|
|
@@ -136,8 +143,8 @@ export function Price(props) {
|
|
|
136
143
|
* }
|
|
137
144
|
* ```
|
|
138
145
|
*/
|
|
139
|
-
|
|
140
|
-
const selectedVariantService = useService(SelectedVariantServiceDefinition);
|
|
146
|
+
function SKU(props) {
|
|
147
|
+
const selectedVariantService = (0, services_manager_react_1.useService)(selected_variant_service_js_1.SelectedVariantServiceDefinition);
|
|
141
148
|
const selectedVariant = selectedVariantService.currentVariant?.get();
|
|
142
149
|
const sku = selectedVariant?.sku || null;
|
|
143
150
|
return props.children({
|
|
@@ -178,13 +185,13 @@ export function SKU(props) {
|
|
|
178
185
|
* }
|
|
179
186
|
* ```
|
|
180
187
|
*/
|
|
181
|
-
|
|
182
|
-
const variantService = useService(SelectedVariantServiceDefinition);
|
|
183
|
-
const cartService = useService(CurrentCartServiceDefinition);
|
|
188
|
+
function Actions(props) {
|
|
189
|
+
const variantService = (0, services_manager_react_1.useService)(selected_variant_service_js_1.SelectedVariantServiceDefinition);
|
|
190
|
+
const cartService = (0, services_manager_react_1.useService)(services_1.CurrentCartServiceDefinition);
|
|
184
191
|
// Try to get checkout service - it may not be available
|
|
185
192
|
let checkoutService = null;
|
|
186
193
|
try {
|
|
187
|
-
checkoutService = useService(CheckoutServiceDefinition);
|
|
194
|
+
checkoutService = (0, services_manager_react_1.useService)(services_1.CheckoutServiceDefinition);
|
|
188
195
|
}
|
|
189
196
|
catch {
|
|
190
197
|
// Checkout service not available
|
|
@@ -193,7 +200,7 @@ export function Actions(props) {
|
|
|
193
200
|
// Try to get modifiers service - it may not exist for all products
|
|
194
201
|
let modifiersService = null;
|
|
195
202
|
try {
|
|
196
|
-
modifiersService = useService(ProductModifiersServiceDefinition);
|
|
203
|
+
modifiersService = (0, services_manager_react_1.useService)(product_modifiers_service_js_1.ProductModifiersServiceDefinition);
|
|
197
204
|
}
|
|
198
205
|
catch {
|
|
199
206
|
// Modifiers service not available for this product
|
|
@@ -255,7 +262,7 @@ export function Actions(props) {
|
|
|
255
262
|
error,
|
|
256
263
|
};
|
|
257
264
|
if (checkoutService) {
|
|
258
|
-
return (
|
|
265
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Commerce.CheckoutTrigger, { children: ({ createCheckout, isLoading: checkoutLoading, error: checkoutError, }) => props.children({
|
|
259
266
|
...commonProps,
|
|
260
267
|
isLoading: isLoading || checkoutLoading,
|
|
261
268
|
error: error || checkoutError,
|
package/cjs/dist/react/index.js
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Category = exports.CategoryList = exports.Choice = exports.Option = exports.ProductList = exports.Product = void 0;
|
|
37
|
+
exports.Product = __importStar(require("./Product.js"));
|
|
38
|
+
exports.ProductList = __importStar(require("./ProductList.js"));
|
|
39
|
+
exports.Option = __importStar(require("./Option.js"));
|
|
40
|
+
exports.Choice = __importStar(require("./Choice.js"));
|
|
41
|
+
exports.CategoryList = __importStar(require("./CategoryList.js"));
|
|
42
|
+
exports.Category = __importStar(require("./Category.js"));
|
package/cjs/dist/react/types.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsContent = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Enum for content rendering formats
|
|
3
6
|
*/
|
|
4
|
-
|
|
7
|
+
var AsContent;
|
|
5
8
|
(function (AsContent) {
|
|
6
9
|
AsContent["Plain"] = "plain";
|
|
7
10
|
AsContent["Html"] = "html";
|
|
8
11
|
AsContent["Ricos"] = "ricos";
|
|
9
|
-
})(AsContent || (AsContent = {}));
|
|
12
|
+
})(AsContent || (exports.AsContent = AsContent = {}));
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCustomLineItemCheckoutURLFactory = getCustomLineItemCheckoutURLFactory;
|
|
4
|
+
const ecom_1 = require("@wix/ecom");
|
|
5
|
+
const redirects_1 = require("@wix/redirects");
|
|
6
|
+
const essentials_1 = require("@wix/essentials");
|
|
4
7
|
/**
|
|
5
8
|
* Creates a factory function to generate checkout URLs for custom line items with a fixed price.
|
|
6
9
|
* This is useful when you have a single product or service with a known price,
|
|
@@ -9,7 +12,7 @@ import { auth } from '@wix/essentials';
|
|
|
9
12
|
* @param factoryOpts - The options for the factory, including the price.
|
|
10
13
|
* @returns A function that takes `CustomLineItemCheckoutOptions` and returns a checkout URL.
|
|
11
14
|
*/
|
|
12
|
-
|
|
15
|
+
function getCustomLineItemCheckoutURLFactory(factoryOpts) {
|
|
13
16
|
/**
|
|
14
17
|
* Generates a checkout URL for a custom line item.
|
|
15
18
|
* @param opts - The options for the custom line item checkout.
|
|
@@ -18,7 +21,7 @@ export function getCustomLineItemCheckoutURLFactory(factoryOpts) {
|
|
|
18
21
|
*/
|
|
19
22
|
return async function getCustomLineItemCheckoutURL() {
|
|
20
23
|
try {
|
|
21
|
-
const checkoutResult = await auth.elevate(checkout.createCheckout)({
|
|
24
|
+
const checkoutResult = await essentials_1.auth.elevate(ecom_1.checkout.createCheckout)({
|
|
22
25
|
customLineItems: [
|
|
23
26
|
{
|
|
24
27
|
productName: {
|
|
@@ -27,7 +30,7 @@ export function getCustomLineItemCheckoutURLFactory(factoryOpts) {
|
|
|
27
30
|
price: factoryOpts.price,
|
|
28
31
|
quantity: factoryOpts.quantity || 1,
|
|
29
32
|
itemType: {
|
|
30
|
-
preset: checkout.ItemTypePreset.PHYSICAL,
|
|
33
|
+
preset: ecom_1.checkout.ItemTypePreset.PHYSICAL,
|
|
31
34
|
},
|
|
32
35
|
priceDescription: {
|
|
33
36
|
original: factoryOpts.priceDescription,
|
|
@@ -35,7 +38,7 @@ export function getCustomLineItemCheckoutURLFactory(factoryOpts) {
|
|
|
35
38
|
policies: factoryOpts.policies || [],
|
|
36
39
|
},
|
|
37
40
|
],
|
|
38
|
-
channelType: checkout.ChannelType.WEB,
|
|
41
|
+
channelType: ecom_1.checkout.ChannelType.WEB,
|
|
39
42
|
...(factoryOpts.currency
|
|
40
43
|
? {
|
|
41
44
|
checkoutInfo: {
|
|
@@ -47,7 +50,7 @@ export function getCustomLineItemCheckoutURLFactory(factoryOpts) {
|
|
|
47
50
|
if (!checkoutResult._id) {
|
|
48
51
|
throw new Error(`Failed to create checkout for custom line item ${factoryOpts.productName}`);
|
|
49
52
|
}
|
|
50
|
-
const { redirectSession } = await redirects.createRedirectSession({
|
|
53
|
+
const { redirectSession } = await redirects_1.redirects.createRedirectSession({
|
|
51
54
|
ecomCheckout: { checkoutId: checkoutResult._id },
|
|
52
55
|
callbacks: {
|
|
53
56
|
...(factoryOpts.postFlowUrl
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./custom-checkout-action.js"), exports);
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buyNowServiceBinding = exports.loadBuyNowServiceInitialData = exports.BuyNowServiceImplementation = exports.BuyNowServiceDefinition = void 0;
|
|
4
|
+
const services_definitions_1 = require("@wix/services-definitions");
|
|
5
|
+
const signals_1 = require("@wix/services-definitions/core-services/signals");
|
|
6
|
+
const index_js_1 = require("../utils/index.js");
|
|
7
|
+
const stores_1 = require("@wix/stores");
|
|
5
8
|
/**
|
|
6
9
|
* Service definition for the Buy Now service.
|
|
7
10
|
* This defines the reactive API contract for managing buy now functionality.
|
|
8
11
|
*
|
|
9
12
|
* @constant
|
|
10
13
|
*/
|
|
11
|
-
|
|
14
|
+
exports.BuyNowServiceDefinition = (0, services_definitions_1.defineService)('BuyNow');
|
|
12
15
|
/**
|
|
13
16
|
* Implementation of the Buy Now service that manages buy now functionality.
|
|
14
17
|
* This service provides signals for loading state, stock status, and error handling,
|
|
@@ -56,8 +59,8 @@ export const BuyNowServiceDefinition = defineService('BuyNow');
|
|
|
56
59
|
* }
|
|
57
60
|
* ```
|
|
58
61
|
*/
|
|
59
|
-
|
|
60
|
-
const signalsService = getService(SignalsServiceDefinition);
|
|
62
|
+
exports.BuyNowServiceImplementation = services_definitions_1.implementService.withConfig()(exports.BuyNowServiceDefinition, ({ getService, config }) => {
|
|
63
|
+
const signalsService = getService(signals_1.SignalsServiceDefinition);
|
|
61
64
|
const loadingSignal = signalsService.signal(false);
|
|
62
65
|
const errorSignal = signalsService.signal(null);
|
|
63
66
|
const inStockSignal = signalsService.signal(config.inStock);
|
|
@@ -66,7 +69,7 @@ export const BuyNowServiceImplementation = implementService.withConfig()(BuyNowS
|
|
|
66
69
|
redirectToCheckout: async () => {
|
|
67
70
|
loadingSignal.set(true);
|
|
68
71
|
try {
|
|
69
|
-
const checkoutUrl = await getCheckoutUrlForProduct(config.productId, config.variantId);
|
|
72
|
+
const checkoutUrl = await (0, index_js_1.getCheckoutUrlForProduct)(config.productId, config.variantId);
|
|
70
73
|
window.location.href = checkoutUrl;
|
|
71
74
|
}
|
|
72
75
|
catch (error) {
|
|
@@ -135,8 +138,8 @@ export const BuyNowServiceImplementation = implementService.withConfig()(BuyNowS
|
|
|
135
138
|
* };
|
|
136
139
|
* ```
|
|
137
140
|
*/
|
|
138
|
-
|
|
139
|
-
const res = await productsV3.getProductBySlug(productSlug, {
|
|
141
|
+
const loadBuyNowServiceInitialData = async (productSlug, variantId) => {
|
|
142
|
+
const res = await stores_1.productsV3.getProductBySlug(productSlug, {
|
|
140
143
|
fields: ['CURRENCY'],
|
|
141
144
|
});
|
|
142
145
|
const product = res.product;
|
|
@@ -148,7 +151,7 @@ export const loadBuyNowServiceInitialData = async (productSlug, variantId) => {
|
|
|
148
151
|
const inStock = selectedVariant?.inventoryStatus?.inStock;
|
|
149
152
|
const preOrderAvailable = selectedVariant?.inventoryStatus?.preorderEnabled;
|
|
150
153
|
return {
|
|
151
|
-
[BuyNowServiceDefinition]: {
|
|
154
|
+
[exports.BuyNowServiceDefinition]: {
|
|
152
155
|
productId: product._id,
|
|
153
156
|
productName: product.name,
|
|
154
157
|
price: price,
|
|
@@ -159,6 +162,7 @@ export const loadBuyNowServiceInitialData = async (productSlug, variantId) => {
|
|
|
159
162
|
},
|
|
160
163
|
};
|
|
161
164
|
};
|
|
165
|
+
exports.loadBuyNowServiceInitialData = loadBuyNowServiceInitialData;
|
|
162
166
|
/**
|
|
163
167
|
* Helper function to create a buy now service binding with configuration.
|
|
164
168
|
* This function simplifies the process of binding the buy now service with its configuration
|
|
@@ -185,13 +189,14 @@ export const loadBuyNowServiceInitialData = async (productSlug, variantId) => {
|
|
|
185
189
|
* const services = createServicesMap([buyNowBinding]);
|
|
186
190
|
* ```
|
|
187
191
|
*/
|
|
188
|
-
|
|
192
|
+
const buyNowServiceBinding = (servicesConfigs, additionalConfig = {}) => {
|
|
189
193
|
return [
|
|
190
|
-
BuyNowServiceDefinition,
|
|
191
|
-
BuyNowServiceImplementation,
|
|
194
|
+
exports.BuyNowServiceDefinition,
|
|
195
|
+
exports.BuyNowServiceImplementation,
|
|
192
196
|
{
|
|
193
|
-
...servicesConfigs[BuyNowServiceDefinition],
|
|
197
|
+
...servicesConfigs[exports.BuyNowServiceDefinition],
|
|
194
198
|
...additionalConfig,
|
|
195
199
|
},
|
|
196
200
|
];
|
|
197
201
|
};
|
|
202
|
+
exports.buyNowServiceBinding = buyNowServiceBinding;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CategoriesListService = exports.CategoriesListServiceDefinition = void 0;
|
|
4
|
+
exports.loadCategoriesListServiceConfig = loadCategoriesListServiceConfig;
|
|
5
|
+
const services_definitions_1 = require("@wix/services-definitions");
|
|
6
|
+
const signals_1 = require("@wix/services-definitions/core-services/signals");
|
|
7
|
+
const categories_1 = require("@wix/categories");
|
|
4
8
|
/**
|
|
5
9
|
* Service definition for the Categories List service.
|
|
6
10
|
* This defines the reactive API contract for managing a list of product categories.
|
|
7
11
|
*
|
|
8
12
|
* @constant
|
|
9
13
|
*/
|
|
10
|
-
|
|
14
|
+
exports.CategoriesListServiceDefinition = (0, services_definitions_1.defineService)('categories-list');
|
|
11
15
|
/**
|
|
12
16
|
* Implementation of the Categories List service that manages reactive categories data.
|
|
13
17
|
* This service provides signals for categories data, loading state, and error handling.
|
|
@@ -47,8 +51,8 @@ export const CategoriesListServiceDefinition = defineService('categories-list');
|
|
|
47
51
|
* }
|
|
48
52
|
* ```
|
|
49
53
|
*/
|
|
50
|
-
|
|
51
|
-
const signalsService = getService(SignalsServiceDefinition);
|
|
54
|
+
exports.CategoriesListService = services_definitions_1.implementService.withConfig()(exports.CategoriesListServiceDefinition, ({ getService, config }) => {
|
|
55
|
+
const signalsService = getService(signals_1.SignalsServiceDefinition);
|
|
52
56
|
const categoriesSignal = signalsService.signal(config.categories);
|
|
53
57
|
const isLoadingSignal = signalsService.signal(false);
|
|
54
58
|
const errorSignal = signalsService.signal(null);
|
|
@@ -125,8 +129,8 @@ export const CategoriesListService = implementService.withConfig()(CategoriesLis
|
|
|
125
129
|
* }
|
|
126
130
|
* ```
|
|
127
131
|
*/
|
|
128
|
-
|
|
129
|
-
const categoriesResponse = await categories
|
|
132
|
+
async function loadCategoriesListServiceConfig() {
|
|
133
|
+
const categoriesResponse = await categories_1.categories
|
|
130
134
|
.queryCategories({
|
|
131
135
|
treeReference: {
|
|
132
136
|
appNamespace: '@wix/stores',
|