@vio-live/web-sdk 0.28.0 → 0.29.0
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/CHANGELOG.md +72 -2
- package/README.md +69 -0
- package/dist/{chunk-AFJ5M53F.js → chunk-AG4G2S2M.js} +219 -18
- package/dist/chunk-AG4G2S2M.js.map +1 -0
- package/dist/{chunk-Q2NALS7P.js → chunk-L6YYYKQK.js} +76 -12
- package/dist/chunk-L6YYYKQK.js.map +1 -0
- package/dist/core/index.d.ts +81 -5
- package/dist/core/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +3 -3
- package/dist/{tokens-y0KzN7bP.d.ts → tokens-Dok4d21V.d.ts} +28 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-AFJ5M53F.js.map +0 -1
- package/dist/chunk-Q2NALS7P.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vio, __decorateClass, primaryImageUrl, displayPrice, toCampaignId, getGlobalCurrency, ensureVippsButton, formatPrice, buyerRefOf, nexiReturnPaymentId, readNexiPending, kustomReturnOutcome, KUSTOM_RETURN_QUERY_KEYS, ADYEN_RETURN_METHOD, adyenReturnParams, ADYEN_RETURN_QUERY_KEYS, adyenReturnOutcome, gatewayHasBuyerRef, rememberedCheckoutSponsor, checkoutSponsorOf, AdyenOriginError, normalizeSlotId, autoSlotDisplayName, autoSlotId, sponsorIdentityFrom, Configuration, normalizeScope, campaignCandidates } from './chunk-
|
|
1
|
+
import { Vio, __decorateClass, primaryImageUrl, displayPrice, toCampaignId, getGlobalCurrency, ensureVippsButton, formatPrice, buyerRefOf, nexiReturnPaymentId, readNexiPending, kustomReturnOutcome, KUSTOM_RETURN_QUERY_KEYS, ADYEN_RETURN_METHOD, adyenReturnParams, ADYEN_RETURN_QUERY_KEYS, adyenReturnOutcome, gatewayHasBuyerRef, rememberedCheckoutSponsor, checkoutSponsorOf, AdyenOriginError, normalizeSlotId, autoSlotDisplayName, autoSlotId, sponsorIdentityFrom, Configuration, normalizeScope, campaignCandidates } from './chunk-AG4G2S2M.js';
|
|
2
2
|
import { LitElement, css, html, nothing } from 'lit';
|
|
3
3
|
import { property, state, query } from 'lit/decorators.js';
|
|
4
4
|
|
|
@@ -1828,6 +1828,10 @@ var VioProductDetail = class extends LitElement {
|
|
|
1828
1828
|
this.optMapCache = /* @__PURE__ */ new WeakMap();
|
|
1829
1829
|
/** Pre-prepared Apple Pay handle — show() fires synchronously on tap. */
|
|
1830
1830
|
this.applePayHandle = null;
|
|
1831
|
+
/** The amount `applePayHandle`'s sheet shows (product × quantity when it was prepared). */
|
|
1832
|
+
this.applePayAmount = null;
|
|
1833
|
+
/** The amount the latest preparation was asked for — a newer one supersedes it. */
|
|
1834
|
+
this.applePayAskedFor = null;
|
|
1831
1835
|
/** Keyboard and focus while open: Escape closes, Tab stays inside, focus returns to the opener. */
|
|
1832
1836
|
this.dialogFocus = new DialogFocus({
|
|
1833
1837
|
host: this,
|
|
@@ -2552,6 +2556,9 @@ var VioProductDetail = class extends LitElement {
|
|
|
2552
2556
|
this.bottomSheet.update(this.open);
|
|
2553
2557
|
}
|
|
2554
2558
|
if (changed.has("product") || changed.has("open")) this.measureThumbs();
|
|
2559
|
+
if ((changed.has("quantity") || changed.has("selectedOptions")) && this.product && this.applePayAskedFor !== null) {
|
|
2560
|
+
if (this.unitPrice * this.quantity !== this.applePayAskedFor) this.prepareApplePaySheet();
|
|
2561
|
+
}
|
|
2555
2562
|
if (changed.has("activeImageIndex")) this.revealActiveThumb();
|
|
2556
2563
|
this.measureLogo();
|
|
2557
2564
|
if (changed.has("vioSlot") || changed.has("vioSlotName") || changed.has("vioScope") || changed.has("vioScopeName") || changed.has("vioCampaign")) {
|
|
@@ -2681,13 +2688,7 @@ var VioProductDetail = class extends LitElement {
|
|
|
2681
2688
|
if (values.length > 0) initial[opt.name] = values[0];
|
|
2682
2689
|
}
|
|
2683
2690
|
this.selectedOptions = initial;
|
|
2684
|
-
|
|
2685
|
-
this.applePayHandle = handle;
|
|
2686
|
-
this.applePayOk = handle.available;
|
|
2687
|
-
}).catch(() => {
|
|
2688
|
-
this.applePayHandle = null;
|
|
2689
|
-
this.applePayOk = false;
|
|
2690
|
-
});
|
|
2691
|
+
this.prepareApplePaySheet();
|
|
2691
2692
|
void this.loadAvailablePaymentMethods();
|
|
2692
2693
|
}
|
|
2693
2694
|
this.isLoading = false;
|
|
@@ -3070,6 +3071,12 @@ var VioProductDetail = class extends LitElement {
|
|
|
3070
3071
|
}
|
|
3071
3072
|
buyWithVipps() {
|
|
3072
3073
|
if (!this.product || this.availableQuantity <= 0 || this.adding) return;
|
|
3074
|
+
if ((Vio.cart.getCart(this.sponsorId)?.items.length ?? 0) > 0) {
|
|
3075
|
+
this.addCurrentToCart();
|
|
3076
|
+
this.close();
|
|
3077
|
+
this.openCheckoutWithVipps();
|
|
3078
|
+
return;
|
|
3079
|
+
}
|
|
3073
3080
|
const redirect = beginPaymentRedirect({ method: "vipps", sponsorId: this.sponsorId, source: "detail" });
|
|
3074
3081
|
this.addCurrentToCart();
|
|
3075
3082
|
this.close();
|
|
@@ -3092,11 +3099,19 @@ var VioProductDetail = class extends LitElement {
|
|
|
3092
3099
|
redirect.fail(err instanceof Error ? err.message : String(err));
|
|
3093
3100
|
}
|
|
3094
3101
|
if (!fallback) return;
|
|
3102
|
+
this.openCheckoutWithVipps();
|
|
3103
|
+
}
|
|
3104
|
+
/** The ordinary way in, Vipps preselected: the host opens the checkout on `vio:checkout-open`. */
|
|
3105
|
+
openCheckoutWithVipps() {
|
|
3106
|
+
this.openCheckoutWith("vipps");
|
|
3107
|
+
}
|
|
3108
|
+
/** The ordinary way in with a method preselected: the host opens the checkout on `vio:checkout-open`. */
|
|
3109
|
+
openCheckoutWith(paymentMethod) {
|
|
3095
3110
|
this.dispatchEvent(
|
|
3096
3111
|
new CustomEvent("vio:checkout-open", {
|
|
3097
3112
|
bubbles: true,
|
|
3098
3113
|
composed: true,
|
|
3099
|
-
detail: { sponsorId: this.sponsorId, paymentMethod
|
|
3114
|
+
detail: { sponsorId: this.sponsorId, paymentMethod, express: false, ...this.attribution(), ...sponsorDetail(this.sponsorId) }
|
|
3100
3115
|
})
|
|
3101
3116
|
);
|
|
3102
3117
|
}
|
|
@@ -3113,14 +3128,47 @@ var VioProductDetail = class extends LitElement {
|
|
|
3113
3128
|
})
|
|
3114
3129
|
);
|
|
3115
3130
|
}
|
|
3131
|
+
/** Prepare the Apple Pay sheet for this product × quantity; the newest preparation wins. */
|
|
3132
|
+
prepareApplePaySheet() {
|
|
3133
|
+
const amount = this.unitPrice * this.quantity;
|
|
3134
|
+
this.applePayAskedFor = amount;
|
|
3135
|
+
void Vio.checkout.prepareApplePayFor(amount, this.currency).then((handle) => {
|
|
3136
|
+
if (this.applePayAskedFor !== amount) return;
|
|
3137
|
+
this.applePayHandle = handle;
|
|
3138
|
+
this.applePayAmount = amount;
|
|
3139
|
+
this.applePayOk = handle.available;
|
|
3140
|
+
}).catch(() => {
|
|
3141
|
+
if (this.applePayAskedFor !== amount) return;
|
|
3142
|
+
this.applePayHandle = null;
|
|
3143
|
+
this.applePayAmount = null;
|
|
3144
|
+
this.applePayOk = false;
|
|
3145
|
+
});
|
|
3146
|
+
}
|
|
3116
3147
|
/**
|
|
3117
3148
|
* Express buy with Apple Pay. Runs synchronously inside the click so the
|
|
3118
3149
|
* Apple Pay sheet keeps the user gesture: add to cart → open checkout (sets
|
|
3119
3150
|
* state) → launch the sheet. On authorize, `payment-complete` drives the
|
|
3120
3151
|
* confirmation drawer (same path as the in-checkout Apple Pay button).
|
|
3152
|
+
*
|
|
3153
|
+
* The sheet's amount is fixed before the tap (Apple blocks a sheet opened
|
|
3154
|
+
* after an await, so it cannot wait for the server's cart), while the
|
|
3155
|
+
* charge is the sponsor's WHOLE cart. So the sheet opens only when it shows
|
|
3156
|
+
* what will be charged: an empty cart, and a sheet prepared for this
|
|
3157
|
+
* product × quantity. Otherwise — lines already in the cart (as with Vipps,
|
|
3158
|
+
* see buyWithVipps), or a quantity whose sheet is still being prepared —
|
|
3159
|
+
* the product is added and the checkout opens with Apple Pay preselected:
|
|
3160
|
+
* every line and the total on screen, and its own Apple Pay button pays
|
|
3161
|
+
* that total.
|
|
3121
3162
|
*/
|
|
3122
3163
|
buyWithApplePay() {
|
|
3123
3164
|
if (!this.product || this.availableQuantity <= 0 || !this.applePayHandle) return;
|
|
3165
|
+
const cartHasLines = (Vio.cart.getCart(this.sponsorId)?.items.length ?? 0) > 0;
|
|
3166
|
+
if (cartHasLines || this.applePayAmount !== this.unitPrice * this.quantity) {
|
|
3167
|
+
this.addCurrentToCart();
|
|
3168
|
+
this.close();
|
|
3169
|
+
this.openCheckoutWith("apple-pay");
|
|
3170
|
+
return;
|
|
3171
|
+
}
|
|
3124
3172
|
this.addCurrentToCart();
|
|
3125
3173
|
try {
|
|
3126
3174
|
Vio.checkout.open(this.sponsorId);
|
|
@@ -4025,6 +4073,9 @@ var VioCart = class extends LitElement {
|
|
|
4025
4073
|
if (changed.has("open") && this.open) {
|
|
4026
4074
|
this.confirmedOrder = null;
|
|
4027
4075
|
this.preparedTotal = -1;
|
|
4076
|
+
for (const cart of this.carts.values()) {
|
|
4077
|
+
if (cart.cartId) void Vio.cart.refreshFromServer(cart.sponsorId);
|
|
4078
|
+
}
|
|
4028
4079
|
}
|
|
4029
4080
|
if (this.open && this.itemCount > 0) {
|
|
4030
4081
|
const total = this.totalAcrossSponsors;
|
|
@@ -4453,6 +4504,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
4453
4504
|
this.open = false;
|
|
4454
4505
|
this.heading = "Kasse";
|
|
4455
4506
|
this.shippingLabel = "Beregnes ved kasse";
|
|
4507
|
+
this.vippsShipsInApp = false;
|
|
4456
4508
|
this.express = false;
|
|
4457
4509
|
this.checkoutState = null;
|
|
4458
4510
|
this.items = [];
|
|
@@ -5766,6 +5818,9 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
5766
5818
|
if (changed.has("open") && this.open) {
|
|
5767
5819
|
this.autoSelectSoleMethod();
|
|
5768
5820
|
}
|
|
5821
|
+
if (changed.has("open") && this.open && this.checkoutState?.sponsorId && !this.orderConfirmed) {
|
|
5822
|
+
void Vio.cart.refreshFromServer(this.checkoutState.sponsorId);
|
|
5823
|
+
}
|
|
5769
5824
|
if ((changed.has("klarnaAvailable") && this.klarnaAvailable || changed.has("applePayAvailable") && this.applePayAvailable) && this.paymentMethodsResolved && !this.checkoutState?.paymentMethod) {
|
|
5770
5825
|
this.autoSelectAttempted = false;
|
|
5771
5826
|
this.autoSelectSoleMethod();
|
|
@@ -5892,6 +5947,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
5892
5947
|
if (Array.isArray(methods)) {
|
|
5893
5948
|
this.availableMethods = methods.map((m) => m.name);
|
|
5894
5949
|
this.stripeMode = await Vio.checkout.getStripeMode(spId);
|
|
5950
|
+
this.vippsShipsInApp = this.availableMethods.some((m) => String(m).toLowerCase() === "vipps") ? await Vio.checkout.getVippsExpressEnabled(spId) : false;
|
|
5895
5951
|
} else {
|
|
5896
5952
|
this.availableMethods = null;
|
|
5897
5953
|
}
|
|
@@ -6467,6 +6523,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
6467
6523
|
* express always has one; the normal flow has one once the backend
|
|
6468
6524
|
* shippings loaded (the choice IS persisted on the cart and charged). */
|
|
6469
6525
|
shippingMajor() {
|
|
6526
|
+
if (this.vippsChoosesShipping()) return 0;
|
|
6470
6527
|
if (this.checkoutState?.paymentMethod === "qliro" && typeof this.qliroShipping?.price === "number") {
|
|
6471
6528
|
return this.qliroShipping.price;
|
|
6472
6529
|
}
|
|
@@ -6481,6 +6538,10 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
6481
6538
|
if (!o) return 0;
|
|
6482
6539
|
return o.priceMajor ?? o.price / 100;
|
|
6483
6540
|
}
|
|
6541
|
+
/** Vipps is the method and it runs as Express: the delivery is chosen in Vipps. */
|
|
6542
|
+
vippsChoosesShipping() {
|
|
6543
|
+
return this.checkoutState?.paymentMethod === "vipps" && this.vippsShipsInApp;
|
|
6544
|
+
}
|
|
6484
6545
|
/** The rate the summary names — Qliro's own pick while Qliro is the method. */
|
|
6485
6546
|
summaryShippingName() {
|
|
6486
6547
|
if (this.checkoutState?.paymentMethod === "qliro" && this.qliroShipping) {
|
|
@@ -7903,7 +7964,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
7903
7964
|
</div>
|
|
7904
7965
|
<div class="order-row">
|
|
7905
7966
|
<span>Frakt${this.shippingMajor() > 0 && this.summaryShippingName() ? ` \u2013 ${this.summaryShippingName()}` : ""}</span>
|
|
7906
|
-
<span>${this.shippingMajor() > 0 ? formatPrice(this.shippingMajor(), this.checkoutState?.currency) : this.shippingLabel}</span>
|
|
7967
|
+
<span>${this.vippsChoosesShipping() ? "Velges i Vipps" : this.shippingMajor() > 0 ? formatPrice(this.shippingMajor(), this.checkoutState?.currency) : this.shippingLabel}</span>
|
|
7907
7968
|
</div>
|
|
7908
7969
|
<div class="order-row total">
|
|
7909
7970
|
<span>Totalt</span><span>${this.payTotalLabel()}</span>
|
|
@@ -7924,6 +7985,9 @@ __decorateClass([
|
|
|
7924
7985
|
__decorateClass([
|
|
7925
7986
|
property({ type: String, attribute: "shipping-label" })
|
|
7926
7987
|
], _VioCheckout.prototype, "shippingLabel", 2);
|
|
7988
|
+
__decorateClass([
|
|
7989
|
+
state()
|
|
7990
|
+
], _VioCheckout.prototype, "vippsShipsInApp", 2);
|
|
7927
7991
|
__decorateClass([
|
|
7928
7992
|
property({ type: Boolean, reflect: true })
|
|
7929
7993
|
], _VioCheckout.prototype, "express", 2);
|
|
@@ -8099,5 +8163,5 @@ function registerVioElements() {
|
|
|
8099
8163
|
}
|
|
8100
8164
|
|
|
8101
8165
|
export { VioCart, VioCheckout, VioProduct, VioProductCarousel, VioProductDetail, VioTokens, applyVioTheme, registerVioElements };
|
|
8102
|
-
//# sourceMappingURL=chunk-
|
|
8103
|
-
//# sourceMappingURL=chunk-
|
|
8166
|
+
//# sourceMappingURL=chunk-L6YYYKQK.js.map
|
|
8167
|
+
//# sourceMappingURL=chunk-L6YYYKQK.js.map
|