@wix/headless-stores 0.0.12 → 0.0.15
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 +4 -2
- package/cjs/dist/astro/actions/custom-checkout.js +4 -8
- package/cjs/dist/astro/actions/index.d.ts +1 -1
- package/cjs/dist/astro/actions/index.js +1 -17
- package/cjs/dist/enums/index.d.ts +2 -2
- package/cjs/dist/enums/index.js +2 -18
- package/cjs/dist/enums/social-platform-enums.js +4 -7
- package/cjs/dist/enums/sort-enums.js +3 -6
- package/cjs/dist/react/BuyNow.js +6 -11
- package/cjs/dist/react/Category.d.ts +2 -2
- package/cjs/dist/react/Category.js +6 -10
- package/cjs/dist/react/Collection.d.ts +1 -1
- package/cjs/dist/react/Collection.js +31 -39
- package/cjs/dist/react/FilteredCollection.d.ts +6 -20
- package/cjs/dist/react/FilteredCollection.js +29 -57
- package/cjs/dist/react/PayNow.js +4 -9
- package/cjs/dist/react/Product.d.ts +3 -3
- package/cjs/dist/react/Product.js +6 -11
- package/cjs/dist/react/ProductActions.js +12 -17
- package/cjs/dist/react/ProductModifiers.d.ts +3 -1
- package/cjs/dist/react/ProductModifiers.js +23 -29
- package/cjs/dist/react/ProductVariantSelector.d.ts +1 -1
- package/cjs/dist/react/ProductVariantSelector.js +18 -28
- package/cjs/dist/react/RelatedProducts.d.ts +2 -2
- package/cjs/dist/react/RelatedProducts.js +35 -33
- package/cjs/dist/react/SelectedVariant.js +8 -14
- package/cjs/dist/react/SocialSharing.d.ts +2 -3
- package/cjs/dist/react/SocialSharing.js +35 -33
- package/cjs/dist/react/Sort.d.ts +4 -3
- package/cjs/dist/react/Sort.js +6 -10
- package/cjs/dist/react/index.d.ts +13 -13
- package/cjs/dist/react/index.js +13 -52
- package/cjs/dist/server-actions/custom-checkout-action.js +8 -11
- package/cjs/dist/server-actions/index.d.ts +1 -1
- package/cjs/dist/server-actions/index.js +1 -17
- package/cjs/dist/services/buy-now-service.d.ts +44 -3
- package/cjs/dist/services/buy-now-service.js +20 -22
- package/cjs/dist/services/catalog-options-service.d.ts +3 -3
- package/cjs/dist/services/catalog-options-service.js +45 -46
- package/cjs/dist/services/catalog-price-range-service.d.ts +3 -3
- package/cjs/dist/services/catalog-price-range-service.js +21 -25
- package/cjs/dist/services/category-service.d.ts +7 -7
- package/cjs/dist/services/category-service.js +20 -22
- package/cjs/dist/services/collection-service.d.ts +8 -8
- package/cjs/dist/services/collection-service.js +102 -133
- package/cjs/dist/services/filter-service.d.ts +4 -4
- package/cjs/dist/services/filter-service.js +47 -61
- package/cjs/dist/services/index.d.ts +13 -2
- package/cjs/dist/services/index.js +13 -9
- package/cjs/dist/services/pay-now-service.d.ts +4 -3
- package/cjs/dist/services/pay-now-service.js +11 -16
- package/cjs/dist/services/product-modifiers-service.d.ts +6 -6
- package/cjs/dist/services/product-modifiers-service.js +17 -21
- package/cjs/dist/services/product-service.d.ts +8 -8
- package/cjs/dist/services/product-service.js +22 -26
- package/cjs/dist/services/related-products-service.d.ts +5 -5
- package/cjs/dist/services/related-products-service.js +9 -13
- package/cjs/dist/services/selected-variant-service.d.ts +11 -8
- package/cjs/dist/services/selected-variant-service.js +73 -90
- package/cjs/dist/services/social-sharing-service.d.ts +2 -9
- package/cjs/dist/services/social-sharing-service.js +48 -60
- package/cjs/dist/services/sort-service.d.ts +3 -3
- package/cjs/dist/services/sort-service.js +14 -19
- package/cjs/dist/utils/index.js +6 -9
- package/cjs/dist/utils/url-params.js +5 -9
- package/dist/astro/actions/custom-checkout.d.ts +1 -1
- package/dist/astro/actions/custom-checkout.js +1 -1
- package/dist/astro/actions/index.d.ts +1 -1
- package/dist/astro/actions/index.js +1 -1
- package/dist/enums/index.d.ts +2 -2
- package/dist/enums/index.js +2 -2
- package/dist/react/BuyNow.js +4 -6
- package/dist/react/Category.d.ts +2 -2
- package/dist/react/Category.js +2 -2
- package/dist/react/Collection.d.ts +1 -1
- package/dist/react/Collection.js +20 -20
- package/dist/react/FilteredCollection.d.ts +6 -20
- package/dist/react/FilteredCollection.js +17 -35
- package/dist/react/PayNow.js +2 -4
- package/dist/react/Product.d.ts +3 -3
- package/dist/react/Product.js +2 -2
- package/dist/react/ProductActions.js +9 -10
- package/dist/react/ProductModifiers.d.ts +3 -1
- package/dist/react/ProductModifiers.js +14 -12
- package/dist/react/ProductVariantSelector.d.ts +1 -1
- package/dist/react/ProductVariantSelector.js +6 -8
- package/dist/react/RelatedProducts.d.ts +2 -2
- package/dist/react/RelatedProducts.js +25 -15
- package/dist/react/SelectedVariant.js +2 -2
- package/dist/react/SocialSharing.d.ts +2 -3
- package/dist/react/SocialSharing.js +24 -13
- package/dist/react/Sort.d.ts +4 -3
- package/dist/react/Sort.js +3 -4
- package/dist/react/index.d.ts +13 -13
- package/dist/react/index.js +13 -13
- package/dist/server-actions/index.d.ts +1 -1
- package/dist/server-actions/index.js +1 -1
- package/dist/services/buy-now-service.d.ts +44 -3
- package/dist/services/buy-now-service.js +7 -4
- package/dist/services/catalog-options-service.d.ts +3 -3
- package/dist/services/catalog-options-service.js +33 -30
- package/dist/services/catalog-price-range-service.d.ts +3 -3
- package/dist/services/catalog-price-range-service.js +18 -18
- package/dist/services/category-service.d.ts +7 -7
- package/dist/services/category-service.js +17 -15
- package/dist/services/collection-service.d.ts +8 -8
- package/dist/services/collection-service.js +80 -74
- package/dist/services/filter-service.d.ts +4 -4
- package/dist/services/filter-service.js +37 -48
- package/dist/services/index.d.ts +13 -2
- package/dist/services/index.js +13 -2
- package/dist/services/pay-now-service.d.ts +4 -3
- package/dist/services/pay-now-service.js +1 -1
- package/dist/services/product-modifiers-service.d.ts +6 -6
- package/dist/services/product-modifiers-service.js +13 -13
- package/dist/services/product-service.d.ts +8 -8
- package/dist/services/product-service.js +19 -19
- package/dist/services/related-products-service.d.ts +5 -5
- package/dist/services/related-products-service.js +6 -6
- package/dist/services/selected-variant-service.d.ts +11 -8
- package/dist/services/selected-variant-service.js +71 -85
- package/dist/services/social-sharing-service.d.ts +2 -9
- package/dist/services/social-sharing-service.js +29 -37
- package/dist/services/sort-service.d.ts +3 -3
- package/dist/services/sort-service.js +8 -10
- package/dist/utils/url-params.js +4 -4
- package/package.json +6 -5
- package/cjs/dist/services/product-media-gallery-service.d.ts +0 -25
- package/cjs/dist/services/product-media-gallery-service.js +0 -105
- package/dist/services/product-media-gallery-service.d.ts +0 -25
- package/dist/services/product-media-gallery-service.js +0 -101
package/cjs/dist/utils/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getCheckoutUrlForProduct = getCheckoutUrlForProduct;
|
|
4
|
-
const ecom_1 = require("@wix/ecom");
|
|
5
|
-
const redirects_1 = require("@wix/redirects");
|
|
1
|
+
import { checkout } from "@wix/ecom";
|
|
2
|
+
import { redirects } from "@wix/redirects";
|
|
6
3
|
const CATLOG_APP_ID_V3 = "215238eb-22a5-4c36-9e7b-e7c08025e04e";
|
|
7
|
-
async function getCheckoutUrlForProduct(productId, variantId) {
|
|
8
|
-
const checkoutResult = await
|
|
4
|
+
export async function getCheckoutUrlForProduct(productId, variantId) {
|
|
5
|
+
const checkoutResult = await checkout.createCheckout({
|
|
9
6
|
lineItems: [
|
|
10
7
|
{
|
|
11
8
|
catalogReference: {
|
|
@@ -18,12 +15,12 @@ async function getCheckoutUrlForProduct(productId, variantId) {
|
|
|
18
15
|
quantity: 1,
|
|
19
16
|
},
|
|
20
17
|
],
|
|
21
|
-
channelType:
|
|
18
|
+
channelType: checkout.ChannelType.WEB,
|
|
22
19
|
});
|
|
23
20
|
if (!checkoutResult._id) {
|
|
24
21
|
throw new Error("Failed to create checkout");
|
|
25
22
|
}
|
|
26
|
-
const { redirectSession } = await
|
|
23
|
+
const { redirectSession } = await redirects.createRedirectSession({
|
|
27
24
|
ecomCheckout: { checkoutId: checkoutResult._id },
|
|
28
25
|
callbacks: {
|
|
29
26
|
postFlowUrl: window.location.href,
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.URLParamsUtils = void 0;
|
|
4
|
-
class URLParamsUtils {
|
|
1
|
+
export class URLParamsUtils {
|
|
5
2
|
static parseSearchParams(searchParams) {
|
|
6
3
|
const params = {};
|
|
7
4
|
// Parse all parameters
|
|
@@ -22,14 +19,14 @@ class URLParamsUtils {
|
|
|
22
19
|
return params;
|
|
23
20
|
}
|
|
24
21
|
static updateURL(params) {
|
|
25
|
-
if (typeof window ===
|
|
22
|
+
if (typeof window === 'undefined')
|
|
26
23
|
return;
|
|
27
24
|
const url = new URL(window.location.href);
|
|
28
25
|
const urlParams = new URLSearchParams();
|
|
29
26
|
// Add all parameters
|
|
30
27
|
Object.entries(params).forEach(([key, value]) => {
|
|
31
28
|
if (Array.isArray(value)) {
|
|
32
|
-
value.forEach(
|
|
29
|
+
value.forEach(v => urlParams.append(key, v));
|
|
33
30
|
}
|
|
34
31
|
else if (value) {
|
|
35
32
|
urlParams.set(key, value);
|
|
@@ -39,12 +36,11 @@ class URLParamsUtils {
|
|
|
39
36
|
const newURL = urlParams.toString()
|
|
40
37
|
? `${url.pathname}?${urlParams.toString()}`
|
|
41
38
|
: url.pathname;
|
|
42
|
-
window.history.replaceState({},
|
|
39
|
+
window.history.replaceState({}, '', newURL);
|
|
43
40
|
}
|
|
44
41
|
static getURLParams() {
|
|
45
|
-
if (typeof window ===
|
|
42
|
+
if (typeof window === 'undefined')
|
|
46
43
|
return {};
|
|
47
44
|
return this.parseSearchParams(new URLSearchParams(window.location.search));
|
|
48
45
|
}
|
|
49
46
|
}
|
|
50
|
-
exports.URLParamsUtils = URLParamsUtils;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CustomLineItemCheckoutOptions } from "
|
|
1
|
+
import { type CustomLineItemCheckoutOptions } from "../../server-actions/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Creates an Astro action factory for custom checkout functionality with line items.
|
|
4
4
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="astro/env" />
|
|
2
2
|
// @ts-ignore
|
|
3
3
|
import { defineAction } from "astro:actions";
|
|
4
|
-
import { getCustomLineItemCheckoutURLFactory, } from "
|
|
4
|
+
import { getCustomLineItemCheckoutURLFactory, } from "../../server-actions/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Creates an Astro action factory for custom checkout functionality with line items.
|
|
7
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./custom-checkout";
|
|
1
|
+
export * from "./custom-checkout.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./custom-checkout";
|
|
1
|
+
export * from "./custom-checkout.js";
|
package/dist/enums/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./sort-enums.js";
|
|
2
|
+
export * from "./social-platform-enums.js";
|
package/dist/enums/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./sort-enums.js";
|
|
2
|
+
export * from "./social-platform-enums.js";
|
package/dist/react/BuyNow.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { useService } from "@wix/services-manager-react";
|
|
2
|
-
import { BuyNowServiceDefinition } from "../services/buy-now-service";
|
|
3
|
-
;
|
|
4
|
-
;
|
|
2
|
+
import { BuyNowServiceDefinition } from "../services/buy-now-service.js";
|
|
5
3
|
/**
|
|
6
4
|
* A headless component that provides buy now functionality using the render props pattern.
|
|
7
5
|
*
|
|
@@ -30,7 +28,7 @@ import { BuyNowServiceDefinition } from "../services/buy-now-service";
|
|
|
30
28
|
* @component
|
|
31
29
|
*/
|
|
32
30
|
export function BuyNow(props) {
|
|
33
|
-
const { redirectToCheckout, loadingSignal, productName, errorSignal, price, currency,
|
|
31
|
+
const { redirectToCheckout, loadingSignal, productName, errorSignal, price, currency, inStockSignal, preOrderAvailableSignal, } = useService(BuyNowServiceDefinition);
|
|
34
32
|
return props.children({
|
|
35
33
|
isLoading: loadingSignal.get(),
|
|
36
34
|
error: errorSignal.get(),
|
|
@@ -38,7 +36,7 @@ export function BuyNow(props) {
|
|
|
38
36
|
redirectToCheckout,
|
|
39
37
|
price,
|
|
40
38
|
currency,
|
|
41
|
-
inStock,
|
|
42
|
-
preOrderAvailable,
|
|
39
|
+
inStock: inStockSignal.get(),
|
|
40
|
+
preOrderAvailable: preOrderAvailableSignal.get(),
|
|
43
41
|
});
|
|
44
42
|
}
|
package/dist/react/Category.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Category } from
|
|
2
|
-
import React, { type ReactNode } from
|
|
1
|
+
import { type Category } from "@wix/auto_sdk_categories_categories";
|
|
2
|
+
import React, { type ReactNode } from "react";
|
|
3
3
|
export interface CategoryListProps {
|
|
4
4
|
children: (data: {
|
|
5
5
|
categories: Category[];
|
package/dist/react/Category.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useService } from
|
|
3
|
-
import { CategoryServiceDefinition } from
|
|
2
|
+
import { useService } from "@wix/services-manager-react";
|
|
3
|
+
import { CategoryServiceDefinition } from "../services/category-service.js";
|
|
4
4
|
/**
|
|
5
5
|
* Headless component for displaying a list of categories
|
|
6
6
|
*
|
package/dist/react/Collection.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useService } from
|
|
2
|
-
import { CollectionServiceDefinition } from
|
|
3
|
-
import { InventoryAvailabilityStatus, } from
|
|
1
|
+
import { useService } from "@wix/services-manager-react";
|
|
2
|
+
import { CollectionServiceDefinition } from "../services/collection-service.js";
|
|
3
|
+
import { InventoryAvailabilityStatus, } from "@wix/auto_sdk_stores_products-v-3";
|
|
4
4
|
/**
|
|
5
5
|
* Headless component for product grid
|
|
6
6
|
*
|
|
@@ -10,11 +10,11 @@ export const Grid = (props) => {
|
|
|
10
10
|
const service = useService(CollectionServiceDefinition);
|
|
11
11
|
// Debug logging to help identify service issues
|
|
12
12
|
if (!service) {
|
|
13
|
-
console.error(
|
|
13
|
+
console.error("CollectionService is undefined");
|
|
14
14
|
return props.children({
|
|
15
15
|
products: [],
|
|
16
16
|
isLoading: false,
|
|
17
|
-
error:
|
|
17
|
+
error: "Service not available",
|
|
18
18
|
isEmpty: true,
|
|
19
19
|
totalProducts: 0,
|
|
20
20
|
hasProducts: false,
|
|
@@ -37,11 +37,11 @@ export const Grid = (props) => {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
catch (err) {
|
|
40
|
-
console.error(
|
|
40
|
+
console.error("Error accessing service properties:", err);
|
|
41
41
|
return props.children({
|
|
42
42
|
products: [],
|
|
43
43
|
isLoading: false,
|
|
44
|
-
error:
|
|
44
|
+
error: "Failed to load products",
|
|
45
45
|
isEmpty: true,
|
|
46
46
|
totalProducts: 0,
|
|
47
47
|
hasProducts: false,
|
|
@@ -60,18 +60,18 @@ export const Item = (props) => {
|
|
|
60
60
|
const image = product?.media?.main?.image || null;
|
|
61
61
|
// Create formatted price since formattedAmount is not available
|
|
62
62
|
const rawAmount = product.actualPriceRange?.minValue?.amount;
|
|
63
|
-
const price = rawAmount ? `$${rawAmount}` :
|
|
63
|
+
const price = rawAmount ? `$${rawAmount}` : "$0.00";
|
|
64
64
|
// Create formatted compare-at price
|
|
65
65
|
const rawCompareAmount = product.compareAtPriceRange?.minValue?.amount;
|
|
66
66
|
const compareAtPrice = rawCompareAmount ? `$${rawCompareAmount}` : null;
|
|
67
67
|
const availabilityStatus = product.inventory?.availabilityStatus;
|
|
68
68
|
const available = availabilityStatus === InventoryAvailabilityStatus.IN_STOCK ||
|
|
69
69
|
availabilityStatus === InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK;
|
|
70
|
-
const description = typeof product.description ===
|
|
70
|
+
const description = typeof product.description === "string" ? product.description : "";
|
|
71
71
|
return props.children({
|
|
72
|
-
id: product._id ||
|
|
73
|
-
title: product.name ||
|
|
74
|
-
slug: product.slug ||
|
|
72
|
+
id: product._id || "",
|
|
73
|
+
title: product.name || "",
|
|
74
|
+
slug: product.slug || "",
|
|
75
75
|
image,
|
|
76
76
|
price,
|
|
77
77
|
compareAtPrice,
|
|
@@ -90,7 +90,7 @@ export const LoadMore = (props) => {
|
|
|
90
90
|
const service = useService(CollectionServiceDefinition);
|
|
91
91
|
// Error handling for undefined service
|
|
92
92
|
if (!service) {
|
|
93
|
-
console.error(
|
|
93
|
+
console.error("CollectionService is undefined in LoadMore");
|
|
94
94
|
return props.children({
|
|
95
95
|
loadMore: async () => { },
|
|
96
96
|
refresh: async () => { },
|
|
@@ -115,7 +115,7 @@ export const LoadMore = (props) => {
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
catch (err) {
|
|
118
|
-
console.error(
|
|
118
|
+
console.error("Error in LoadMore:", err);
|
|
119
119
|
return props.children({
|
|
120
120
|
loadMore: async () => { },
|
|
121
121
|
refresh: async () => { },
|
|
@@ -135,7 +135,7 @@ export const Header = (props) => {
|
|
|
135
135
|
const service = useService(CollectionServiceDefinition);
|
|
136
136
|
// Error handling for undefined service
|
|
137
137
|
if (!service) {
|
|
138
|
-
console.error(
|
|
138
|
+
console.error("CollectionService is undefined in Header");
|
|
139
139
|
return props.children({
|
|
140
140
|
totalProducts: 0,
|
|
141
141
|
isLoading: false,
|
|
@@ -153,7 +153,7 @@ export const Header = (props) => {
|
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
155
|
catch (err) {
|
|
156
|
-
console.error(
|
|
156
|
+
console.error("Error in Header:", err);
|
|
157
157
|
return props.children({
|
|
158
158
|
totalProducts: 0,
|
|
159
159
|
isLoading: false,
|
|
@@ -171,12 +171,12 @@ export const Actions = (props) => {
|
|
|
171
171
|
const service = useService(CollectionServiceDefinition);
|
|
172
172
|
// Error handling for undefined service
|
|
173
173
|
if (!service) {
|
|
174
|
-
console.error(
|
|
174
|
+
console.error("CollectionService is undefined in Actions");
|
|
175
175
|
return props.children({
|
|
176
176
|
refresh: async () => { },
|
|
177
177
|
loadMore: async () => { },
|
|
178
178
|
isLoading: false,
|
|
179
|
-
error:
|
|
179
|
+
error: "Service not available",
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
182
|
try {
|
|
@@ -190,12 +190,12 @@ export const Actions = (props) => {
|
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
catch (err) {
|
|
193
|
-
console.error(
|
|
193
|
+
console.error("Error in Actions:", err);
|
|
194
194
|
return props.children({
|
|
195
195
|
refresh: async () => { },
|
|
196
196
|
loadMore: async () => { },
|
|
197
197
|
isLoading: false,
|
|
198
|
-
error:
|
|
198
|
+
error: "Failed to load actions",
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
201
|
};
|
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
import React, { type ReactNode } from
|
|
2
|
-
import { type AvailableOptions, type FilterServiceAPI, type Filter } from
|
|
3
|
-
import { type V3Product } from
|
|
4
|
-
import { type CollectionServiceAPI } from '../services/collection-service';
|
|
1
|
+
import React, { type ReactNode } from "react";
|
|
2
|
+
import { type AvailableOptions, type FilterServiceAPI, type Filter } from "../services/filter-service.js";
|
|
3
|
+
import { type V3Product } from "@wix/auto_sdk_stores_products-v-3";
|
|
5
4
|
export type { AvailableOptions, Filter, FilterServiceAPI };
|
|
6
|
-
export interface FilteredCollectionProviderProps {
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Headless component for providing a filtered collection
|
|
11
|
-
*
|
|
12
|
-
* @component
|
|
13
|
-
*/
|
|
14
|
-
export declare const Provider: React.FC<FilteredCollectionProviderProps>;
|
|
15
|
-
export declare const useFilteredCollection: () => {
|
|
16
|
-
filter: FilterServiceAPI | null;
|
|
17
|
-
collection: CollectionServiceAPI | null;
|
|
18
|
-
};
|
|
19
5
|
export interface FiltersLoadingProps {
|
|
20
6
|
children: (data: {
|
|
21
7
|
isFullyLoaded: boolean;
|
|
@@ -57,7 +43,7 @@ export interface FilteredItemProps {
|
|
|
57
43
|
}) => ReactNode;
|
|
58
44
|
}
|
|
59
45
|
/**
|
|
60
|
-
* Headless component for displaying
|
|
46
|
+
* Headless component for displaying a filtered product item
|
|
61
47
|
*
|
|
62
48
|
* @component
|
|
63
49
|
*/
|
|
@@ -73,7 +59,7 @@ export interface FilteredLoadMoreProps {
|
|
|
73
59
|
}) => ReactNode;
|
|
74
60
|
}
|
|
75
61
|
/**
|
|
76
|
-
* Headless component for
|
|
62
|
+
* Headless component for load more filtered products functionality
|
|
77
63
|
*
|
|
78
64
|
* @component
|
|
79
65
|
*/
|
|
@@ -89,7 +75,7 @@ export interface FilteredFiltersProps {
|
|
|
89
75
|
}) => ReactNode;
|
|
90
76
|
}
|
|
91
77
|
/**
|
|
92
|
-
* Headless component for
|
|
78
|
+
* Headless component for product filters with available options
|
|
93
79
|
*
|
|
94
80
|
* @component
|
|
95
81
|
*/
|
|
@@ -1,34 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { InventoryAvailabilityStatus, } from
|
|
6
|
-
import { CollectionServiceDefinition, } from '../services/collection-service';
|
|
7
|
-
const FilteredCollectionContext = createContext({ filter: null, collection: null });
|
|
8
|
-
/**
|
|
9
|
-
* Headless component for providing a filtered collection
|
|
10
|
-
*
|
|
11
|
-
* @component
|
|
12
|
-
*/
|
|
13
|
-
export const Provider = ({ children, }) => {
|
|
14
|
-
const filter = useService(FilterServiceDefinition);
|
|
15
|
-
const collection = useService(CollectionServiceDefinition);
|
|
16
|
-
return (_jsx(FilteredCollectionContext.Provider, { value: { filter, collection }, children: children }));
|
|
17
|
-
};
|
|
18
|
-
export const useFilteredCollection = () => {
|
|
19
|
-
const context = useContext(FilteredCollectionContext);
|
|
20
|
-
if (!context) {
|
|
21
|
-
throw new Error('useFilteredCollection must be used within a FilteredCollectionProvider');
|
|
22
|
-
}
|
|
23
|
-
return context;
|
|
24
|
-
};
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useService } from "@wix/services-manager-react";
|
|
3
|
+
import { CollectionServiceDefinition } from "../services/collection-service.js";
|
|
4
|
+
import { FilterServiceDefinition, } from "../services/filter-service.js";
|
|
5
|
+
import { InventoryAvailabilityStatus, } from "@wix/auto_sdk_stores_products-v-3";
|
|
25
6
|
/**
|
|
26
7
|
* Headless component for displaying a loading state for filters
|
|
27
8
|
*
|
|
28
9
|
* @component
|
|
29
10
|
*/
|
|
30
11
|
export const FiltersLoading = ({ children }) => {
|
|
31
|
-
const
|
|
12
|
+
const filter = useService(FilterServiceDefinition);
|
|
32
13
|
const isFullyLoaded = filter.isFullyLoaded.get();
|
|
33
14
|
return _jsx(_Fragment, { children: children({ isFullyLoaded }) });
|
|
34
15
|
};
|
|
@@ -38,7 +19,7 @@ export const FiltersLoading = ({ children }) => {
|
|
|
38
19
|
* @component
|
|
39
20
|
*/
|
|
40
21
|
export const Grid = ({ children }) => {
|
|
41
|
-
const
|
|
22
|
+
const collection = useService(CollectionServiceDefinition);
|
|
42
23
|
const products = collection.products.get() || [];
|
|
43
24
|
const totalProducts = collection.totalProducts.get();
|
|
44
25
|
const isLoading = collection.isLoading.get();
|
|
@@ -55,20 +36,20 @@ export const Grid = ({ children }) => {
|
|
|
55
36
|
}) }));
|
|
56
37
|
};
|
|
57
38
|
/**
|
|
58
|
-
* Headless component for displaying
|
|
39
|
+
* Headless component for displaying a filtered product item
|
|
59
40
|
*
|
|
60
41
|
* @component
|
|
61
42
|
*/
|
|
62
43
|
export const Item = ({ product, children }) => {
|
|
63
44
|
// Safe conversion of product data with type safety guards
|
|
64
|
-
const title = String(product.name ||
|
|
45
|
+
const title = String(product.name || "");
|
|
65
46
|
const image = product.media?.main?.image || null;
|
|
66
|
-
const imageAltText = product.media?.main?.altText ||
|
|
47
|
+
const imageAltText = product.media?.main?.altText || "";
|
|
67
48
|
const price = product.actualPriceRange?.minValue?.formattedAmount ||
|
|
68
49
|
product.actualPriceRange?.maxValue?.formattedAmount ||
|
|
69
50
|
(product.actualPriceRange?.minValue?.amount
|
|
70
51
|
? `$${product.actualPriceRange.minValue.amount}`
|
|
71
|
-
:
|
|
52
|
+
: "$0.00");
|
|
72
53
|
// Add compare at price
|
|
73
54
|
const compareAtPrice = product.compareAtPriceRange?.minValue?.formattedAmount ||
|
|
74
55
|
(product.compareAtPriceRange?.minValue?.amount
|
|
@@ -77,7 +58,7 @@ export const Item = ({ product, children }) => {
|
|
|
77
58
|
const availabilityStatus = product.inventory?.availabilityStatus;
|
|
78
59
|
const available = availabilityStatus === InventoryAvailabilityStatus.IN_STOCK ||
|
|
79
60
|
availabilityStatus === InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK;
|
|
80
|
-
const slug = String(product.slug || product._id ||
|
|
61
|
+
const slug = String(product.slug || product._id || "");
|
|
81
62
|
const description = product.plainDescription
|
|
82
63
|
? String(product.plainDescription)
|
|
83
64
|
: undefined;
|
|
@@ -93,12 +74,12 @@ export const Item = ({ product, children }) => {
|
|
|
93
74
|
}) }));
|
|
94
75
|
};
|
|
95
76
|
/**
|
|
96
|
-
* Headless component for
|
|
77
|
+
* Headless component for load more filtered products functionality
|
|
97
78
|
*
|
|
98
79
|
* @component
|
|
99
80
|
*/
|
|
100
81
|
export const LoadMore = ({ children }) => {
|
|
101
|
-
const
|
|
82
|
+
const collection = useService(CollectionServiceDefinition);
|
|
102
83
|
const loadMore = collection.loadMore;
|
|
103
84
|
const refresh = collection.refresh;
|
|
104
85
|
const isLoading = collection.isLoading.get();
|
|
@@ -115,12 +96,13 @@ export const LoadMore = ({ children }) => {
|
|
|
115
96
|
}) }));
|
|
116
97
|
};
|
|
117
98
|
/**
|
|
118
|
-
* Headless component for
|
|
99
|
+
* Headless component for product filters with available options
|
|
119
100
|
*
|
|
120
101
|
* @component
|
|
121
102
|
*/
|
|
122
103
|
export const Filters = ({ children }) => {
|
|
123
|
-
const
|
|
104
|
+
const collection = useService(CollectionServiceDefinition);
|
|
105
|
+
const filter = useService(FilterServiceDefinition);
|
|
124
106
|
const applyFilters = filter.applyFilters;
|
|
125
107
|
const clearFilters = filter.clearFilters;
|
|
126
108
|
const currentFilters = filter.currentFilters.get();
|
package/dist/react/PayNow.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { useService } from "@wix/services-manager-react";
|
|
2
|
-
import { PayNowServiceDefinition } from "../services/pay-now-service";
|
|
3
|
-
;
|
|
4
|
-
;
|
|
2
|
+
import { PayNowServiceDefinition } from "../services/pay-now-service.js";
|
|
5
3
|
/**
|
|
6
4
|
* A headless component that provides pay now functionality using the render props pattern.
|
|
7
5
|
*
|
|
@@ -26,7 +24,7 @@ import { PayNowServiceDefinition } from "../services/pay-now-service";
|
|
|
26
24
|
* @component
|
|
27
25
|
*/
|
|
28
26
|
export function PayNow(props) {
|
|
29
|
-
const { redirectToCheckout, loadingSignal, errorSignal
|
|
27
|
+
const { redirectToCheckout, loadingSignal, errorSignal } = useService(PayNowServiceDefinition);
|
|
30
28
|
return props.children({
|
|
31
29
|
isLoading: loadingSignal.get(),
|
|
32
30
|
error: errorSignal.get(),
|
package/dist/react/Product.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { V3Product } from
|
|
1
|
+
import type { V3Product } from "@wix/auto_sdk_stores_products-v-3";
|
|
2
2
|
/**
|
|
3
3
|
* Props for ProductName headless component
|
|
4
4
|
*/
|
|
@@ -31,9 +31,9 @@ export interface ProductDescriptionProps {
|
|
|
31
31
|
*/
|
|
32
32
|
export interface ProductDescriptionRenderProps {
|
|
33
33
|
/** Product description (may contain HTML) */
|
|
34
|
-
description: NonNullable<V3Product[
|
|
34
|
+
description: NonNullable<V3Product["description"]>;
|
|
35
35
|
/** Product plain description */
|
|
36
|
-
plainDescription: NonNullable<V3Product[
|
|
36
|
+
plainDescription: NonNullable<V3Product["plainDescription"]>;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Headless component for product description display
|
package/dist/react/Product.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useService } from
|
|
2
|
-
import { ProductServiceDefinition } from
|
|
1
|
+
import { useService } from "@wix/services-manager-react";
|
|
2
|
+
import { ProductServiceDefinition } from "../services/product-service.js";
|
|
3
3
|
/**
|
|
4
4
|
* Headless component for product name display
|
|
5
5
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { useService } from
|
|
2
|
-
import { SelectedVariantServiceDefinition } from
|
|
3
|
-
import { ProductModifiersServiceDefinition } from
|
|
1
|
+
import { useService } from "@wix/services-manager-react";
|
|
2
|
+
import { SelectedVariantServiceDefinition } from "../services/selected-variant-service.js";
|
|
3
|
+
import { ProductModifiersServiceDefinition } from "../services/product-modifiers-service.js";
|
|
4
|
+
import { CurrentCartServiceDefinition } from "@wix/headless-ecom/services";
|
|
4
5
|
/**
|
|
5
6
|
* Headless component for product actions (add to cart, buy now)
|
|
6
7
|
*
|
|
@@ -8,9 +9,7 @@ import { ProductModifiersServiceDefinition } from '../services/product-modifiers
|
|
|
8
9
|
*/
|
|
9
10
|
export const Actions = (props) => {
|
|
10
11
|
const variantService = useService(SelectedVariantServiceDefinition);
|
|
11
|
-
|
|
12
|
-
// typeof CurrentCartServiceDefinition
|
|
13
|
-
// >;
|
|
12
|
+
const cartService = useService(CurrentCartServiceDefinition);
|
|
14
13
|
// Try to get modifiers service - it may not exist for all products
|
|
15
14
|
let modifiersService = null;
|
|
16
15
|
try {
|
|
@@ -49,19 +48,19 @@ export const Actions = (props) => {
|
|
|
49
48
|
const onBuyNow = async () => {
|
|
50
49
|
try {
|
|
51
50
|
// Clear the cart first
|
|
52
|
-
|
|
51
|
+
await cartService.clearCart();
|
|
53
52
|
// Add the product to cart
|
|
54
53
|
await onAddToCart();
|
|
55
54
|
// Proceed to checkout
|
|
56
|
-
|
|
55
|
+
await cartService.proceedToCheckout();
|
|
57
56
|
}
|
|
58
57
|
catch (error) {
|
|
59
|
-
console.error(
|
|
58
|
+
console.error("Buy now failed:", error);
|
|
60
59
|
throw error;
|
|
61
60
|
}
|
|
62
61
|
};
|
|
63
62
|
const onOpenCart = () => {
|
|
64
|
-
|
|
63
|
+
cartService.openCart();
|
|
65
64
|
};
|
|
66
65
|
return props.children({
|
|
67
66
|
onAddToCart,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ConnectedModifier, type ConnectedModifierChoice } from
|
|
1
|
+
import { type ConnectedModifier, type ConnectedModifierChoice } from "@wix/auto_sdk_stores_products-v-3";
|
|
2
2
|
/**
|
|
3
3
|
* Props for Modifiers headless component
|
|
4
4
|
*/
|
|
@@ -21,6 +21,8 @@ export interface ModifiersRenderProps {
|
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Headless component for all product modifiers
|
|
24
|
+
*
|
|
25
|
+
* @component
|
|
24
26
|
*/
|
|
25
27
|
export declare const Modifiers: (props: ModifiersProps) => import("react").ReactNode;
|
|
26
28
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useState } from
|
|
2
|
-
import { useService } from
|
|
3
|
-
import { ProductModifiersServiceDefinition } from
|
|
4
|
-
import { ModifierRenderType, } from
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { useService } from "@wix/services-manager-react";
|
|
3
|
+
import { ProductModifiersServiceDefinition } from "../services/product-modifiers-service.js";
|
|
4
|
+
import { ModifierRenderType, } from "@wix/auto_sdk_stores_products-v-3";
|
|
5
5
|
/**
|
|
6
6
|
* Custom hook to safely get the modifiers service
|
|
7
7
|
*/
|
|
@@ -15,6 +15,8 @@ function useModifiersService() {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Headless component for all product modifiers
|
|
18
|
+
*
|
|
19
|
+
* @component
|
|
18
20
|
*/
|
|
19
21
|
export const Modifiers = (props) => {
|
|
20
22
|
const modifiersService = useModifiersService();
|
|
@@ -45,7 +47,7 @@ export const Modifiers = (props) => {
|
|
|
45
47
|
export const Modifier = (props) => {
|
|
46
48
|
const modifiersService = useModifiersService();
|
|
47
49
|
const { modifier } = props;
|
|
48
|
-
const name = modifier.name ||
|
|
50
|
+
const name = modifier.name || "";
|
|
49
51
|
const type = modifier.modifierRenderType;
|
|
50
52
|
const mandatory = modifier.mandatory || false;
|
|
51
53
|
const choices = modifier.choicesSettings?.choices || [];
|
|
@@ -75,13 +77,13 @@ export const Modifier = (props) => {
|
|
|
75
77
|
export const Choice = (props) => {
|
|
76
78
|
const modifiersService = useModifiersService();
|
|
77
79
|
const { modifier, choice } = props;
|
|
78
|
-
const modifierName = modifier.name ||
|
|
80
|
+
const modifierName = modifier.name || "";
|
|
79
81
|
const renderType = modifier.modifierRenderType;
|
|
80
82
|
// For TEXT_CHOICES, use choice.key; for SWATCH_CHOICES, use choice.name
|
|
81
83
|
const choiceValue = renderType === ModifierRenderType.TEXT_CHOICES
|
|
82
|
-
? choice.key || choice.name ||
|
|
83
|
-
: choice.name ||
|
|
84
|
-
const value = choice.name ||
|
|
84
|
+
? choice.key || choice.name || ""
|
|
85
|
+
: choice.name || "";
|
|
86
|
+
const value = choice.name || ""; // Display name is always choice.name
|
|
85
87
|
const description = choice.description;
|
|
86
88
|
const colorCode = choice.colorCode;
|
|
87
89
|
const selectedValue = modifiersService?.getModifierValue(modifierName);
|
|
@@ -107,13 +109,13 @@ export const Choice = (props) => {
|
|
|
107
109
|
export const FreeText = (props) => {
|
|
108
110
|
const modifiersService = useModifiersService();
|
|
109
111
|
const { modifier } = props;
|
|
110
|
-
const modifierName = modifier.name ||
|
|
112
|
+
const modifierName = modifier.name || "";
|
|
111
113
|
const mandatory = modifier.mandatory || false;
|
|
112
114
|
const freeTextSettings = modifier.freeTextSettings;
|
|
113
115
|
const maxChars = freeTextSettings?.maxLength;
|
|
114
116
|
const placeholder = freeTextSettings?.placeholder;
|
|
115
117
|
const selectedValue = modifiersService?.getModifierValue(modifierName);
|
|
116
|
-
const value = selectedValue?.freeTextValue ||
|
|
118
|
+
const value = selectedValue?.freeTextValue || "";
|
|
117
119
|
const charCount = value.length;
|
|
118
120
|
const isOverLimit = maxChars ? charCount > maxChars : false;
|
|
119
121
|
const onChange = (newValue) => {
|
|
@@ -141,7 +143,7 @@ export const FreeText = (props) => {
|
|
|
141
143
|
export const ToggleFreeText = (props) => {
|
|
142
144
|
const modifiersService = useModifiersService();
|
|
143
145
|
const { modifier } = props;
|
|
144
|
-
const modifierName = modifier.name ||
|
|
146
|
+
const modifierName = modifier.name || "";
|
|
145
147
|
const mandatory = modifier.mandatory || false;
|
|
146
148
|
const [isTextInputShown, setIsTextInputShown] = useState(mandatory);
|
|
147
149
|
const onToggle = () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ConnectedOption, type ConnectedOptionChoice, InventoryAvailabilityStatus } from
|
|
1
|
+
import { type ConnectedOption, type ConnectedOptionChoice, InventoryAvailabilityStatus } from "@wix/auto_sdk_stores_products-v-3";
|
|
2
2
|
/**
|
|
3
3
|
* Props for Options headless component
|
|
4
4
|
*/
|