@jay-framework/wix-cart 0.15.4 → 0.15.6
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/dist/contracts/mini-cart.jay-contract +19 -0
- package/dist/contracts/mini-cart.jay-contract.d.ts +26 -0
- package/dist/{index.client-VoD54p4E.d.ts → index.client-BgJIzp09.d.ts} +27 -1
- package/dist/index.client.d.ts +1 -1
- package/dist/index.client.js +26 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -4
- package/package.json +20 -17
- package/plugin.yaml +14 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: mini-cart
|
|
2
|
+
description: Drawer that auto-opens when a product is added to cart. Place cart content inside.
|
|
3
|
+
|
|
4
|
+
tags:
|
|
5
|
+
- tag: isOpen
|
|
6
|
+
type: variant
|
|
7
|
+
dataType: boolean
|
|
8
|
+
phase: fast+interactive
|
|
9
|
+
description: Whether the mini-cart drawer is currently open
|
|
10
|
+
|
|
11
|
+
- tag: openButton
|
|
12
|
+
type: interactive
|
|
13
|
+
elementType: HTMLButtonElement
|
|
14
|
+
description: Button to manually open the mini-cart drawer
|
|
15
|
+
|
|
16
|
+
- tag: closeButton
|
|
17
|
+
type: interactive
|
|
18
|
+
elementType: HTMLButtonElement
|
|
19
|
+
description: Button to close the mini-cart drawer
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {HTMLElementCollectionProxy, HTMLElementProxy, JayContract} from "@jay-framework/runtime";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export interface MiniCartViewState {
|
|
5
|
+
isOpen: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type MiniCartSlowViewState = {};
|
|
9
|
+
|
|
10
|
+
export type MiniCartFastViewState = Pick<MiniCartViewState, 'isOpen'>;
|
|
11
|
+
|
|
12
|
+
export type MiniCartInteractiveViewState = Pick<MiniCartViewState, 'isOpen'>;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export interface MiniCartRefs {
|
|
16
|
+
openButton: HTMLElementProxy<MiniCartViewState, HTMLButtonElement>,
|
|
17
|
+
closeButton: HTMLElementProxy<MiniCartViewState, HTMLButtonElement>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export interface MiniCartRepeatedRefs {
|
|
22
|
+
openButton: HTMLElementCollectionProxy<MiniCartViewState, HTMLButtonElement>,
|
|
23
|
+
closeButton: HTMLElementCollectionProxy<MiniCartViewState, HTMLButtonElement>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type MiniCartContract = JayContract<MiniCartViewState, MiniCartRefs, MiniCartSlowViewState, MiniCartFastViewState, MiniCartInteractiveViewState>
|
|
@@ -431,6 +431,32 @@ interface CartPageFastCarryForward {
|
|
|
431
431
|
*/
|
|
432
432
|
declare const cartPage: _jay_framework_fullstack_component.JayStackComponentDefinition<CartPageRefs, CartPageSlowViewState, CartPageFastViewState, CartPageInteractiveViewState, [CartPageSlowCarryForward, WixCartService], [Signals<CartPageFastViewState>, CartPageFastCarryForward, WixCartContext], PageProps, {}, _jay_framework_component.JayComponentCore<PageProps, CartPageInteractiveViewState>>;
|
|
433
433
|
|
|
434
|
+
interface MiniCartViewState {
|
|
435
|
+
isOpen: boolean
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
type MiniCartSlowViewState = {};
|
|
439
|
+
|
|
440
|
+
type MiniCartFastViewState = Pick<MiniCartViewState, 'isOpen'>;
|
|
441
|
+
|
|
442
|
+
type MiniCartInteractiveViewState = Pick<MiniCartViewState, 'isOpen'>;
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
interface MiniCartRefs {
|
|
446
|
+
openButton: HTMLElementProxy<MiniCartViewState, HTMLButtonElement>,
|
|
447
|
+
closeButton: HTMLElementProxy<MiniCartViewState, HTMLButtonElement>
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
interface MiniCartFastCarryForward {
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Mini Cart Drawer Component
|
|
454
|
+
*
|
|
455
|
+
* Auto-opens when a product is added to cart.
|
|
456
|
+
* Place cart content (e.g., cart-page component) inside in your template.
|
|
457
|
+
*/
|
|
458
|
+
declare const miniCart: _jay_framework_fullstack_component.JayStackComponentDefinition<MiniCartRefs, MiniCartSlowViewState, MiniCartFastViewState, MiniCartInteractiveViewState, [WixCartService], [Signals<MiniCartFastViewState>, MiniCartFastCarryForward, WixCartContext], PageProps, {}, _jay_framework_component.JayComponentCore<PageProps, MiniCartInteractiveViewState>>;
|
|
459
|
+
|
|
434
460
|
declare const init: _jay_framework_fullstack_component.JayInit<WixCartInitData>;
|
|
435
461
|
|
|
436
|
-
export { type AddToCartOptions as A, type CartOperationResult as C, type ReactiveCartIndicator as R, type WixCartService as W, WIX_CART_SERVICE as a, WIX_CART_CONTEXT as b, type WixCartContext as c, type WixCartInitData as d, mapCartSummary as e, mapCartToState as f, mapCartToIndicator as g, getEmptyCartState as h, getCurrentCartOrNull as i, estimateCurrentCartTotalsOrNull as j, mapEstimateTotalsToState as k, type CartState as l, mapLineItem as m, type CartLineItem as n, type CartSummary as o, provideWixCartContext as p, type CartIndicatorState as q, cartIndicator as r, cartPage as s,
|
|
462
|
+
export { type AddToCartOptions as A, type CartOperationResult as C, type ReactiveCartIndicator as R, type WixCartService as W, WIX_CART_SERVICE as a, WIX_CART_CONTEXT as b, type WixCartContext as c, type WixCartInitData as d, mapCartSummary as e, mapCartToState as f, mapCartToIndicator as g, getEmptyCartState as h, getCurrentCartOrNull as i, estimateCurrentCartTotalsOrNull as j, mapEstimateTotalsToState as k, type CartState as l, mapLineItem as m, type CartLineItem as n, type CartSummary as o, provideWixCartContext as p, type CartIndicatorState as q, cartIndicator as r, cartPage as s, miniCart as t, init as u };
|
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,
|
|
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-BgJIzp09.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, createEffect } from "@jay-framework/component";
|
|
2
|
+
import { registerReactiveGlobalContext, createSignal, useReactive, createEffect, createMemo } 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";
|
|
@@ -548,6 +548,29 @@ function CartPageInteractive(_props, refs, viewStateSignals, _carryForward, cart
|
|
|
548
548
|
};
|
|
549
549
|
}
|
|
550
550
|
const cartPage = makeJayStackComponent().withProps().withContexts(WIX_CART_CONTEXT).withInteractive(CartPageInteractive);
|
|
551
|
+
function MiniCartInteractive(_props, refs, viewStateSignals, _carryForward, cartContext) {
|
|
552
|
+
const { isOpen: [isOpen, setIsOpen] } = viewStateSignals;
|
|
553
|
+
let prevItemCount = cartContext.cartIndicator.itemCount();
|
|
554
|
+
createMemo(() => {
|
|
555
|
+
const currentCount = cartContext.cartIndicator.itemCount();
|
|
556
|
+
if (currentCount > prevItemCount) {
|
|
557
|
+
setIsOpen(true);
|
|
558
|
+
}
|
|
559
|
+
prevItemCount = currentCount;
|
|
560
|
+
});
|
|
561
|
+
refs.openButton.onclick(() => {
|
|
562
|
+
setIsOpen(true);
|
|
563
|
+
});
|
|
564
|
+
refs.closeButton.onclick(() => {
|
|
565
|
+
setIsOpen(false);
|
|
566
|
+
});
|
|
567
|
+
return {
|
|
568
|
+
render: () => ({
|
|
569
|
+
isOpen: isOpen()
|
|
570
|
+
})
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
const miniCart = makeJayStackComponent().withProps().withContexts(WIX_CART_CONTEXT).withInteractive(MiniCartInteractive);
|
|
551
574
|
const init = makeJayInit().withClient(async (data) => {
|
|
552
575
|
console.log("[wix-cart] Initializing client-side cart context...");
|
|
553
576
|
const { enableClientCart } = data;
|
|
@@ -562,5 +585,6 @@ export {
|
|
|
562
585
|
WIX_CART_CONTEXT,
|
|
563
586
|
cartIndicator,
|
|
564
587
|
cartPage,
|
|
565
|
-
init
|
|
588
|
+
init,
|
|
589
|
+
miniCart
|
|
566
590
|
};
|
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,
|
|
2
|
+
import { W as WixCartService } from './index.client-BgJIzp09.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-BgJIzp09.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
|
@@ -359,7 +359,7 @@ function provideWixCartContext() {
|
|
|
359
359
|
console.log("[wix-cart] Client cart context initialized (reactive)");
|
|
360
360
|
return cartContext;
|
|
361
361
|
}
|
|
362
|
-
async function renderFastChanging$
|
|
362
|
+
async function renderFastChanging$2(_props, _wixCart) {
|
|
363
363
|
const Pipeline = RenderPipeline.for();
|
|
364
364
|
return Pipeline.ok(null).toPhaseOutput(() => ({
|
|
365
365
|
viewState: {
|
|
@@ -371,7 +371,7 @@ async function renderFastChanging$1(_props, _wixCart) {
|
|
|
371
371
|
carryForward: {}
|
|
372
372
|
}));
|
|
373
373
|
}
|
|
374
|
-
const cartIndicator = makeJayStackComponent().withProps().withServices(WIX_CART_SERVICE).withFastRender(renderFastChanging$
|
|
374
|
+
const cartIndicator = makeJayStackComponent().withProps().withServices(WIX_CART_SERVICE).withFastRender(renderFastChanging$2);
|
|
375
375
|
function createEmptyCartViewState() {
|
|
376
376
|
return {
|
|
377
377
|
isEmpty: true,
|
|
@@ -408,14 +408,24 @@ async function renderSlowlyChanging(_props, _wixCart) {
|
|
|
408
408
|
carryForward: {}
|
|
409
409
|
}));
|
|
410
410
|
}
|
|
411
|
-
async function renderFastChanging(_props, _slowCarryForward, _wixCart) {
|
|
411
|
+
async function renderFastChanging$1(_props, _slowCarryForward, _wixCart) {
|
|
412
412
|
const Pipeline = RenderPipeline.for();
|
|
413
413
|
return Pipeline.ok(null).toPhaseOutput(() => ({
|
|
414
414
|
viewState: createEmptyCartViewState(),
|
|
415
415
|
carryForward: {}
|
|
416
416
|
}));
|
|
417
417
|
}
|
|
418
|
-
const cartPage = makeJayStackComponent().withProps().withServices(WIX_CART_SERVICE).withSlowlyRender(renderSlowlyChanging).withFastRender(renderFastChanging);
|
|
418
|
+
const cartPage = makeJayStackComponent().withProps().withServices(WIX_CART_SERVICE).withSlowlyRender(renderSlowlyChanging).withFastRender(renderFastChanging$1);
|
|
419
|
+
async function renderFastChanging(_props, _wixCart) {
|
|
420
|
+
const Pipeline = RenderPipeline.for();
|
|
421
|
+
return Pipeline.ok(null).toPhaseOutput(() => ({
|
|
422
|
+
viewState: {
|
|
423
|
+
isOpen: false
|
|
424
|
+
},
|
|
425
|
+
carryForward: {}
|
|
426
|
+
}));
|
|
427
|
+
}
|
|
428
|
+
const miniCart = makeJayStackComponent().withProps().withServices(WIX_CART_SERVICE).withFastRender(renderFastChanging);
|
|
419
429
|
const init = makeJayInit().withServer(async () => {
|
|
420
430
|
console.log("[wix-cart] Initializing Wix Cart service...");
|
|
421
431
|
const wixClient = getService(WIX_CLIENT_SERVICE);
|
|
@@ -440,6 +450,7 @@ export {
|
|
|
440
450
|
mapCartToState,
|
|
441
451
|
mapEstimateTotalsToState,
|
|
442
452
|
mapLineItem,
|
|
453
|
+
miniCart,
|
|
443
454
|
provideWixCartContext,
|
|
444
455
|
provideWixCartService
|
|
445
456
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/wix-cart",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Wix Cart/Ecom shared package for Jay Framework",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
},
|
|
21
21
|
"./plugin.yaml": "./plugin.yaml",
|
|
22
22
|
"./cart-indicator.jay-contract": "./dist/contracts/cart-indicator.jay-contract",
|
|
23
|
-
"./cart-page.jay-contract": "./dist/contracts/cart-page.jay-contract"
|
|
23
|
+
"./cart-page.jay-contract": "./dist/contracts/cart-page.jay-contract",
|
|
24
|
+
"./mini-cart.jay-contract": "./dist/contracts/mini-cart.jay-contract"
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
26
|
-
"build": "npm run clean && npm run definitions && npm run build:client && npm run build:server && npm run build:copy-contract && npm run build:types",
|
|
27
|
+
"build": "npm run clean && npm run definitions && npm run build:client && npm run build:server && npm run build:copy-contract && npm run build:types && npm run validate",
|
|
27
28
|
"definitions": "jay-cli definitions lib",
|
|
29
|
+
"validate": "jay-stack-cli validate-plugin",
|
|
28
30
|
"build:client": "vite build",
|
|
29
31
|
"build:server": "vite build --ssr",
|
|
30
32
|
"build:copy-contract": "mkdir -p dist/contracts && cp lib/contracts/*.jay-contract* dist/contracts/",
|
|
@@ -35,25 +37,26 @@
|
|
|
35
37
|
"test": ":"
|
|
36
38
|
},
|
|
37
39
|
"dependencies": {
|
|
38
|
-
"@jay-framework/component": "^0.15.
|
|
39
|
-
"@jay-framework/fullstack-component": "^0.15.
|
|
40
|
-
"@jay-framework/reactive": "^0.15.
|
|
41
|
-
"@jay-framework/runtime": "^0.15.
|
|
42
|
-
"@jay-framework/secure": "^0.15.
|
|
43
|
-
"@jay-framework/stack-client-runtime": "^0.15.
|
|
44
|
-
"@jay-framework/stack-server-runtime": "^0.15.
|
|
45
|
-
"@jay-framework/wix-server-client": "^0.15.
|
|
46
|
-
"@jay-framework/wix-utils": "^0.15.
|
|
47
|
-
"@wix/ecom": "^1.0.
|
|
48
|
-
"@wix/sdk": "^1.21.5"
|
|
40
|
+
"@jay-framework/component": "^0.15.6",
|
|
41
|
+
"@jay-framework/fullstack-component": "^0.15.6",
|
|
42
|
+
"@jay-framework/reactive": "^0.15.6",
|
|
43
|
+
"@jay-framework/runtime": "^0.15.6",
|
|
44
|
+
"@jay-framework/secure": "^0.15.6",
|
|
45
|
+
"@jay-framework/stack-client-runtime": "^0.15.6",
|
|
46
|
+
"@jay-framework/stack-server-runtime": "^0.15.6",
|
|
47
|
+
"@jay-framework/wix-server-client": "^0.15.6",
|
|
48
|
+
"@jay-framework/wix-utils": "^0.15.6",
|
|
49
|
+
"@wix/ecom": "^1.0.1996",
|
|
50
|
+
"@wix/sdk": "^1.21.5",
|
|
51
|
+
"@wix/sdk-runtime": "^1.0.11"
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
51
54
|
"@babel/core": "^7.23.7",
|
|
52
55
|
"@babel/preset-env": "^7.23.8",
|
|
53
56
|
"@babel/preset-typescript": "^7.23.3",
|
|
54
|
-
"@jay-framework/compiler-jay-stack": "^0.15.
|
|
55
|
-
"@jay-framework/jay-cli": "^0.15.
|
|
56
|
-
"@jay-framework/vite-plugin": "^0.15.
|
|
57
|
+
"@jay-framework/compiler-jay-stack": "^0.15.6",
|
|
58
|
+
"@jay-framework/jay-cli": "^0.15.6",
|
|
59
|
+
"@jay-framework/vite-plugin": "^0.15.6",
|
|
57
60
|
"@jay-framework/wix-dev-environment": "^0.6.11",
|
|
58
61
|
"nodemon": "^3.0.3",
|
|
59
62
|
"rimraf": "^5.0.5",
|
package/plugin.yaml
CHANGED
|
@@ -10,5 +10,19 @@ contracts:
|
|
|
10
10
|
contract: cart-page.jay-contract
|
|
11
11
|
component: cartPage
|
|
12
12
|
description: Full cart page with line item management and checkout
|
|
13
|
+
- name: mini-cart
|
|
14
|
+
contract: mini-cart.jay-contract
|
|
15
|
+
component: miniCart
|
|
16
|
+
description: Drawer that auto-opens when a product is added to cart
|
|
17
|
+
|
|
18
|
+
services:
|
|
19
|
+
- name: wix-cart
|
|
20
|
+
marker: WIX_CART_SERVICE
|
|
21
|
+
description: Wix eCommerce cart API for server-side cart operations
|
|
22
|
+
|
|
23
|
+
contexts:
|
|
24
|
+
- name: wix-cart
|
|
25
|
+
marker: WIX_CART_CONTEXT
|
|
26
|
+
description: Client-side reactive cart state with add-to-cart, remove, quantity, coupon, and checkout operations
|
|
13
27
|
|
|
14
28
|
# Plugin initialization uses makeJayInit pattern in lib/init.ts
|