@jay-framework/wix-cart 0.16.2 → 0.16.4
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _jay_framework_runtime from '@jay-framework/runtime';
|
|
2
|
-
import { HTMLElementProxy, HTMLElementCollectionProxy } from '@jay-framework/runtime';
|
|
2
|
+
import { EventEmitter, HTMLElementProxy, HTMLElementCollectionProxy } from '@jay-framework/runtime';
|
|
3
3
|
import { Getter } from '@jay-framework/reactive';
|
|
4
4
|
import { currentCart } from '@wix/ecom';
|
|
5
5
|
import { LineItem, Cart } from '@wix/auto_sdk_ecom_current-cart';
|
|
@@ -239,6 +239,7 @@ interface WixCartContext {
|
|
|
239
239
|
* @returns Updated cart state
|
|
240
240
|
*/
|
|
241
241
|
removeCoupon(): Promise<CartOperationResult>;
|
|
242
|
+
onItemAddedToCart: EventEmitter<void, any>;
|
|
242
243
|
}
|
|
243
244
|
/**
|
|
244
245
|
* Context marker for client-side Wix Cart operations.
|
package/dist/index.client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AddToCartOptions, q as CartIndicatorState, n as CartLineItem, C as CartOperationResult, l as CartState, o as CartSummary, R as ReactiveCartIndicator, b as WIX_CART_CONTEXT, c as WixCartContext, r as cartIndicator, s as cartPage, u as init, t as miniCart } from './index.client-
|
|
1
|
+
export { A as AddToCartOptions, q as CartIndicatorState, n as CartLineItem, C as CartOperationResult, l as CartState, o as CartSummary, R as ReactiveCartIndicator, b as WIX_CART_CONTEXT, c as WixCartContext, r as cartIndicator, s as cartPage, u as init, t as miniCart } from './index.client-DWB0MOQ0.js';
|
|
2
2
|
import '@jay-framework/runtime';
|
|
3
3
|
import '@jay-framework/reactive';
|
|
4
4
|
import '@wix/ecom';
|
package/dist/index.client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createJayContext, useGlobalContext } from "@jay-framework/runtime";
|
|
2
|
-
import { registerReactiveGlobalContext, createSignal, useReactive,
|
|
2
|
+
import { registerReactiveGlobalContext, createSignal, useReactive, createEvent } from "@jay-framework/component";
|
|
3
3
|
import { WIX_CLIENT_CONTEXT } from "@jay-framework/wix-server-client/client";
|
|
4
4
|
import { currentCart } from "@wix/ecom";
|
|
5
5
|
import { makeJayStackComponent, makeJayInit } from "@jay-framework/fullstack-component";
|
|
@@ -251,7 +251,7 @@ function mapEstimateTotalsToState(estimate) {
|
|
|
251
251
|
};
|
|
252
252
|
}
|
|
253
253
|
const WIX_STORES_APP_ID = "215238eb-22a5-4c36-9e7b-e7c08025e04e";
|
|
254
|
-
const WIX_CART_CONTEXT = createJayContext();
|
|
254
|
+
const WIX_CART_CONTEXT = createJayContext("wix:cart");
|
|
255
255
|
function provideWixCartContext() {
|
|
256
256
|
const wixClientContext = useGlobalContext(WIX_CLIENT_CONTEXT);
|
|
257
257
|
const wixClient = wixClientContext.client;
|
|
@@ -260,6 +260,7 @@ function provideWixCartContext() {
|
|
|
260
260
|
const [itemCount, setItemCount] = createSignal(0);
|
|
261
261
|
const [hasItems, setHasItems] = createSignal(false);
|
|
262
262
|
const reactive = useReactive();
|
|
263
|
+
const onItemAddedToCart = createEvent();
|
|
263
264
|
function updateIndicatorFromCart(cart) {
|
|
264
265
|
const indicator = mapCartToIndicator(cart);
|
|
265
266
|
reactive.batchReactions(() => {
|
|
@@ -293,6 +294,7 @@ function provideWixCartContext() {
|
|
|
293
294
|
lineItems: [lineItem]
|
|
294
295
|
});
|
|
295
296
|
updateIndicatorFromCart(result.cart ?? null);
|
|
297
|
+
onItemAddedToCart.emit();
|
|
296
298
|
return { cartState: mapCartToState(result.cart ?? null) };
|
|
297
299
|
}
|
|
298
300
|
async function removeLineItems(lineItemIds) {
|
|
@@ -345,7 +347,8 @@ function provideWixCartContext() {
|
|
|
345
347
|
updateLineItemQuantity,
|
|
346
348
|
clearCart,
|
|
347
349
|
applyCoupon,
|
|
348
|
-
removeCoupon
|
|
350
|
+
removeCoupon,
|
|
351
|
+
onItemAddedToCart
|
|
349
352
|
};
|
|
350
353
|
});
|
|
351
354
|
console.log("[wix-cart] Client cart context initialized (reactive)");
|
|
@@ -353,14 +356,9 @@ function provideWixCartContext() {
|
|
|
353
356
|
}
|
|
354
357
|
function CartIndicatorInteractive(_props, refs, viewStateSignals, _carryForward, cartContext) {
|
|
355
358
|
const { isLoading: [isLoading, setIsLoading], justAdded: [justAdded, setJustAdded] } = viewStateSignals;
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
if (currentCount > prevItemCount()) {
|
|
360
|
-
setJustAdded(true);
|
|
361
|
-
setTimeout(() => setJustAdded(false), 1500);
|
|
362
|
-
}
|
|
363
|
-
setPrevItemCount(currentCount);
|
|
359
|
+
cartContext.onItemAddedToCart(() => {
|
|
360
|
+
setJustAdded(true);
|
|
361
|
+
setTimeout(() => setJustAdded(false), 1500);
|
|
364
362
|
});
|
|
365
363
|
refs.cartLink?.onclick(() => {
|
|
366
364
|
});
|
|
@@ -550,13 +548,8 @@ function CartPageInteractive(_props, refs, viewStateSignals, _carryForward, cart
|
|
|
550
548
|
const cartPage = makeJayStackComponent().withProps().withContexts(WIX_CART_CONTEXT).withInteractive(CartPageInteractive);
|
|
551
549
|
function MiniCartInteractive(_props, refs, viewStateSignals, _carryForward, cartContext) {
|
|
552
550
|
const { isOpen: [isOpen, setIsOpen] } = viewStateSignals;
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
const currentCount = cartContext.cartIndicator.itemCount();
|
|
556
|
-
if (currentCount > prevItemCount) {
|
|
557
|
-
setIsOpen(true);
|
|
558
|
-
}
|
|
559
|
-
prevItemCount = currentCount;
|
|
551
|
+
cartContext.onItemAddedToCart(() => {
|
|
552
|
+
setIsOpen(true);
|
|
560
553
|
});
|
|
561
554
|
refs.openButton.onclick(() => {
|
|
562
555
|
setIsOpen(true);
|
|
@@ -576,7 +569,7 @@ const init = makeJayInit().withClient(async (data) => {
|
|
|
576
569
|
const { enableClientCart } = data;
|
|
577
570
|
const cartContext = provideWixCartContext();
|
|
578
571
|
if (enableClientCart) {
|
|
579
|
-
|
|
572
|
+
cartContext.refreshCartIndicator();
|
|
580
573
|
}
|
|
581
574
|
console.log("[wix-cart] Client initialization complete");
|
|
582
575
|
console.log(`[wix-cart] Cart enabled: ${enableClientCart}`);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WixClient } from '@wix/sdk';
|
|
2
|
-
import { W as WixCartService } from './index.client-
|
|
3
|
-
export { A as AddToCartOptions, q as CartIndicatorState, n as CartLineItem, C as CartOperationResult, l as CartState, o as CartSummary, R as ReactiveCartIndicator, b as WIX_CART_CONTEXT, a as WIX_CART_SERVICE, c as WixCartContext, d as WixCartInitData, r as cartIndicator, s as cartPage, j as estimateCurrentCartTotalsOrNull, i as getCurrentCartOrNull, h as getEmptyCartState, u as init, e as mapCartSummary, g as mapCartToIndicator, f as mapCartToState, k as mapEstimateTotalsToState, m as mapLineItem, t as miniCart, p as provideWixCartContext } from './index.client-
|
|
2
|
+
import { W as WixCartService } from './index.client-DWB0MOQ0.js';
|
|
3
|
+
export { A as AddToCartOptions, q as CartIndicatorState, n as CartLineItem, C as CartOperationResult, l as CartState, o as CartSummary, R as ReactiveCartIndicator, b as WIX_CART_CONTEXT, a as WIX_CART_SERVICE, c as WixCartContext, d as WixCartInitData, r as cartIndicator, s as cartPage, j as estimateCurrentCartTotalsOrNull, i as getCurrentCartOrNull, h as getEmptyCartState, u as init, e as mapCartSummary, g as mapCartToIndicator, f as mapCartToState, k as mapEstimateTotalsToState, m as mapLineItem, t as miniCart, p as provideWixCartContext } from './index.client-DWB0MOQ0.js';
|
|
4
4
|
import { currentCart } from '@wix/ecom';
|
|
5
5
|
import { BuildDescriptors } from '@wix/sdk-types';
|
|
6
6
|
import '@jay-framework/runtime';
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { registerService, getService } from "@jay-framework/stack-server-runtime
|
|
|
2
2
|
import { currentCart } from "@wix/ecom";
|
|
3
3
|
import { createJayService, makeJayStackComponent, RenderPipeline, makeJayInit } from "@jay-framework/fullstack-component";
|
|
4
4
|
import { createJayContext, useGlobalContext } from "@jay-framework/runtime";
|
|
5
|
-
import { registerReactiveGlobalContext, createSignal, useReactive } from "@jay-framework/component";
|
|
5
|
+
import { registerReactiveGlobalContext, createSignal, useReactive, createEvent } from "@jay-framework/component";
|
|
6
6
|
import { WIX_CLIENT_CONTEXT, WIX_CLIENT_SERVICE } from "@jay-framework/wix-server-client";
|
|
7
7
|
let currentCartInstance;
|
|
8
8
|
function getCurrentCartClient(wixClient) {
|
|
@@ -259,7 +259,7 @@ function mapEstimateTotalsToState(estimate) {
|
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
261
|
const WIX_STORES_APP_ID = "215238eb-22a5-4c36-9e7b-e7c08025e04e";
|
|
262
|
-
const WIX_CART_CONTEXT = createJayContext();
|
|
262
|
+
const WIX_CART_CONTEXT = createJayContext("wix:cart");
|
|
263
263
|
function provideWixCartContext() {
|
|
264
264
|
const wixClientContext = useGlobalContext(WIX_CLIENT_CONTEXT);
|
|
265
265
|
const wixClient = wixClientContext.client;
|
|
@@ -268,6 +268,7 @@ function provideWixCartContext() {
|
|
|
268
268
|
const [itemCount, setItemCount] = createSignal(0);
|
|
269
269
|
const [hasItems, setHasItems] = createSignal(false);
|
|
270
270
|
const reactive = useReactive();
|
|
271
|
+
const onItemAddedToCart = createEvent();
|
|
271
272
|
function updateIndicatorFromCart(cart) {
|
|
272
273
|
const indicator = mapCartToIndicator(cart);
|
|
273
274
|
reactive.batchReactions(() => {
|
|
@@ -301,6 +302,7 @@ function provideWixCartContext() {
|
|
|
301
302
|
lineItems: [lineItem]
|
|
302
303
|
});
|
|
303
304
|
updateIndicatorFromCart(result.cart ?? null);
|
|
305
|
+
onItemAddedToCart.emit();
|
|
304
306
|
return { cartState: mapCartToState(result.cart ?? null) };
|
|
305
307
|
}
|
|
306
308
|
async function removeLineItems(lineItemIds) {
|
|
@@ -353,7 +355,8 @@ function provideWixCartContext() {
|
|
|
353
355
|
updateLineItemQuantity,
|
|
354
356
|
clearCart,
|
|
355
357
|
applyCoupon,
|
|
356
|
-
removeCoupon
|
|
358
|
+
removeCoupon,
|
|
359
|
+
onItemAddedToCart
|
|
357
360
|
};
|
|
358
361
|
});
|
|
359
362
|
console.log("[wix-cart] Client cart context initialized (reactive)");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/wix-cart",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Wix Cart/Ecom shared package for Jay Framework",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
"test": ":"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@jay-framework/component": "^0.16.
|
|
41
|
-
"@jay-framework/fullstack-component": "^0.16.
|
|
42
|
-
"@jay-framework/reactive": "^0.16.
|
|
43
|
-
"@jay-framework/runtime": "^0.16.
|
|
44
|
-
"@jay-framework/secure": "^0.16.
|
|
45
|
-
"@jay-framework/stack-client-runtime": "^0.16.
|
|
46
|
-
"@jay-framework/stack-server-runtime": "^0.16.
|
|
47
|
-
"@jay-framework/wix-server-client": "^0.16.
|
|
48
|
-
"@jay-framework/wix-utils": "^0.16.
|
|
40
|
+
"@jay-framework/component": "^0.16.4",
|
|
41
|
+
"@jay-framework/fullstack-component": "^0.16.4",
|
|
42
|
+
"@jay-framework/reactive": "^0.16.4",
|
|
43
|
+
"@jay-framework/runtime": "^0.16.4",
|
|
44
|
+
"@jay-framework/secure": "^0.16.4",
|
|
45
|
+
"@jay-framework/stack-client-runtime": "^0.16.4",
|
|
46
|
+
"@jay-framework/stack-server-runtime": "^0.16.4",
|
|
47
|
+
"@jay-framework/wix-server-client": "^0.16.4",
|
|
48
|
+
"@jay-framework/wix-utils": "^0.16.4",
|
|
49
49
|
"@wix/ecom": "^1.0.1996",
|
|
50
50
|
"@wix/sdk": "^1.21.5",
|
|
51
51
|
"@wix/sdk-runtime": "^1.0.11"
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"@babel/core": "^7.23.7",
|
|
55
55
|
"@babel/preset-env": "^7.23.8",
|
|
56
56
|
"@babel/preset-typescript": "^7.23.3",
|
|
57
|
-
"@jay-framework/compiler-jay-stack": "^0.16.
|
|
58
|
-
"@jay-framework/jay-cli": "^0.16.
|
|
59
|
-
"@jay-framework/vite-plugin": "^0.16.
|
|
60
|
-
"@jay-framework/wix-dev-environment": "^0.6.
|
|
57
|
+
"@jay-framework/compiler-jay-stack": "^0.16.4",
|
|
58
|
+
"@jay-framework/jay-cli": "^0.16.4",
|
|
59
|
+
"@jay-framework/vite-plugin": "^0.16.4",
|
|
60
|
+
"@jay-framework/wix-dev-environment": "^0.6.12",
|
|
61
61
|
"nodemon": "^3.0.3",
|
|
62
62
|
"rimraf": "^5.0.5",
|
|
63
63
|
"tslib": "^2.6.2",
|