@vio-live/web-sdk 0.4.0 → 0.4.2
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/README.md +37 -0
- package/dist/{chunk-V5ZQG2H5.js → chunk-D6IA4ZWL.js} +27 -13
- package/dist/chunk-D6IA4ZWL.js.map +1 -0
- package/dist/{chunk-NP2KCM7X.js → chunk-KMIARP6X.js} +135 -34
- package/dist/chunk-KMIARP6X.js.map +1 -0
- package/dist/core/index.d.ts +21 -4
- package/dist/core/index.js +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-CvqQYURw.d.ts → tokens-DjVcB-RL.d.ts} +2 -2
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-NP2KCM7X.js.map +0 -1
- package/dist/chunk-V5ZQG2H5.js.map +0 -1
package/README.md
CHANGED
|
@@ -97,6 +97,43 @@ function Shop() {
|
|
|
97
97
|
|
|
98
98
|
Wrappers: `VioProduct`, `VioProductCarousel`, `VioProductDetail`, `VioCart`, `VioCheckout`.
|
|
99
99
|
|
|
100
|
+
## Theming
|
|
101
|
+
|
|
102
|
+
Every component reads its colors and fonts from `--vio-*` CSS custom properties
|
|
103
|
+
(shadow DOM inherits these from the light DOM, so this reaches every component,
|
|
104
|
+
including the Apple Pay/Klarna/Vipps panels). `applyVioTheme` is the one
|
|
105
|
+
supported way to override them — don't set `--vio-*` properties by hand, and
|
|
106
|
+
don't rely on the internal variable names staying stable across versions:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import { applyVioTheme } from '@vio-live/web-sdk/ui' // or '/react'
|
|
110
|
+
|
|
111
|
+
applyVioTheme({
|
|
112
|
+
colorAccent: '#0044ff',
|
|
113
|
+
colorText: '#111111',
|
|
114
|
+
fontSerif: '"Playfair Display", Georgia, serif',
|
|
115
|
+
fontSans: '"Inter", sans-serif',
|
|
116
|
+
})
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
A curated set on purpose — colors + fonts, not the full internal token list
|
|
120
|
+
(spacing/radius/sizes stay implementation detail). Call it again any time
|
|
121
|
+
(e.g. after a user picks a different brand color in a settings UI) — pass
|
|
122
|
+
`null`/`undefined` for a key to revert it to the SDK default instead of
|
|
123
|
+
leaving a stale override behind:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
applyVioTheme({ colorAccent: null }) // back to the default #c14a3b
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
By default it sets the override on `document.documentElement` (`:root`, the
|
|
130
|
+
whole page). Pass a second argument to scope it to one element instead —
|
|
131
|
+
useful if you show multiple differently-branded sponsors on the same page:
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
applyVioTheme({ colorAccent: '#ff6600' }, document.getElementById('sponsor-2'))
|
|
135
|
+
```
|
|
136
|
+
|
|
100
137
|
## Headless / SSR
|
|
101
138
|
|
|
102
139
|
The root and `/core` entries export the framework-agnostic core with **no DOM side-effects** — SSR-safe and **tree-shakeable** (importing one helper pulls only that helper, ~0.5 kB):
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vio, __decorateClass, primaryImageUrl, displayPrice, getGlobalCurrency, formatPrice
|
|
1
|
+
import { Vio, __decorateClass, primaryImageUrl, displayPrice, getGlobalCurrency, formatPrice } from './chunk-KMIARP6X.js';
|
|
2
2
|
import { LitElement, css, html } from 'lit';
|
|
3
3
|
import { property, state, query } from 'lit/decorators.js';
|
|
4
4
|
|
|
@@ -2730,7 +2730,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
2730
2730
|
this.klarnaCategories = [];
|
|
2731
2731
|
this.klarnaSelectedCat = "";
|
|
2732
2732
|
this.klarnaAuthorizing = false;
|
|
2733
|
-
this.selectedShipping =
|
|
2733
|
+
this.selectedShipping = "";
|
|
2734
2734
|
this.availableShippingsList = [];
|
|
2735
2735
|
this.availableMethods = null;
|
|
2736
2736
|
this.stripeLoading = false;
|
|
@@ -3080,10 +3080,13 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
3080
3080
|
gap: 12px;
|
|
3081
3081
|
margin-top: 4px;
|
|
3082
3082
|
}
|
|
3083
|
+
/* Klarna remembers the customer's preferred payment_method_category
|
|
3084
|
+
* server-side across sessions/browsers — exposing a category-switcher
|
|
3085
|
+
* chip UI on top of that just confuses users. Hidden per Alan's
|
|
3086
|
+
* 2026-08-18 cross-browser investigation; the switching logic (onKlarnaCategory)
|
|
3087
|
+
* stays wired for when/if this becomes configurable again. */
|
|
3083
3088
|
.klarna-cats {
|
|
3084
|
-
display:
|
|
3085
|
-
flex-wrap: wrap;
|
|
3086
|
-
gap: 8px;
|
|
3089
|
+
display: none !important;
|
|
3087
3090
|
}
|
|
3088
3091
|
.klarna-cat {
|
|
3089
3092
|
flex: 1 1 auto;
|
|
@@ -3496,7 +3499,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
3496
3499
|
super.disconnectedCallback();
|
|
3497
3500
|
}
|
|
3498
3501
|
updated(changed) {
|
|
3499
|
-
if (changed.has("open") && this.open && this.availableShippingsList.length === 0) {
|
|
3502
|
+
if (changed.has("open") && this.open && this.items.length > 0 && this.availableShippingsList.length === 0) {
|
|
3500
3503
|
void this.loadAvailableShippings();
|
|
3501
3504
|
}
|
|
3502
3505
|
void this.mountKlarnaIfNeeded();
|
|
@@ -3508,7 +3511,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
3508
3511
|
}
|
|
3509
3512
|
show() {
|
|
3510
3513
|
this.open = true;
|
|
3511
|
-
if (this.availableShippingsList.length === 0) {
|
|
3514
|
+
if (this.items.length > 0 && this.availableShippingsList.length === 0) {
|
|
3512
3515
|
void this.loadAvailableShippings();
|
|
3513
3516
|
}
|
|
3514
3517
|
}
|
|
@@ -3516,6 +3519,7 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
3516
3519
|
async loadAvailableShippings() {
|
|
3517
3520
|
const spId = this.checkoutState?.sponsorId;
|
|
3518
3521
|
if (!spId) return;
|
|
3522
|
+
if (this.items.length === 0) return;
|
|
3519
3523
|
if (this.loadingShippings) return;
|
|
3520
3524
|
this.loadingShippings = true;
|
|
3521
3525
|
this.shippingsAttempted = true;
|
|
@@ -3602,6 +3606,9 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
3602
3606
|
if (!this.klarnaAvailable || !this.open || !this.checkoutState) return;
|
|
3603
3607
|
if (this.checkoutState.paymentMethod !== "klarna" && !this.express) return;
|
|
3604
3608
|
if (this.klarnaMounting) return;
|
|
3609
|
+
if (this.items.length > 0 && this.availableShippingsList.length === 0 && !this.shippingsAttempted) {
|
|
3610
|
+
await this.loadAvailableShippings();
|
|
3611
|
+
}
|
|
3605
3612
|
const amount = this.checkoutState.subtotal;
|
|
3606
3613
|
if (this.klarnaHandle && this.klarnaMountedAmount === amount && this.klarnaMountedShipping === this.selectedShipping) {
|
|
3607
3614
|
return;
|
|
@@ -3649,9 +3656,9 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
3649
3656
|
this.klarnaSelectedCat = "";
|
|
3650
3657
|
this.klarnaAuthorizing = false;
|
|
3651
3658
|
}
|
|
3652
|
-
/** Shippings in effect: backend per-supplier when loaded
|
|
3659
|
+
/** Shippings in effect: backend per-supplier when loaded. */
|
|
3653
3660
|
get shippingList() {
|
|
3654
|
-
return this.availableShippingsList
|
|
3661
|
+
return this.availableShippingsList;
|
|
3655
3662
|
}
|
|
3656
3663
|
/** Selected shipping option (express flow). */
|
|
3657
3664
|
get shippingOption() {
|
|
@@ -3679,8 +3686,11 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
3679
3686
|
}
|
|
3680
3687
|
/** Switch the Klarna widget to a different payment_method_category. */
|
|
3681
3688
|
async onKlarnaCategory(identifier) {
|
|
3682
|
-
if (!this.klarnaHandle
|
|
3689
|
+
if (!this.klarnaHandle) return;
|
|
3683
3690
|
this.klarnaSelectedCat = identifier;
|
|
3691
|
+
if (typeof console !== "undefined") {
|
|
3692
|
+
console.log("[VioCheckout] User selected payment_method_category:", identifier);
|
|
3693
|
+
}
|
|
3684
3694
|
try {
|
|
3685
3695
|
await this.klarnaHandle.load(identifier);
|
|
3686
3696
|
} catch (err) {
|
|
@@ -3695,8 +3705,12 @@ var _VioCheckout = class _VioCheckout extends LitElement {
|
|
|
3695
3705
|
this.paymentError = null;
|
|
3696
3706
|
this.paymentNotice = null;
|
|
3697
3707
|
this.klarnaAuthorizing = true;
|
|
3708
|
+
const cat = this.klarnaSelectedCat || this.klarnaHandle.selected || "pay_now";
|
|
3709
|
+
if (typeof console !== "undefined") {
|
|
3710
|
+
console.log("[VioCheckout] Authorizing Klarna with payment_method_category:", cat);
|
|
3711
|
+
}
|
|
3698
3712
|
try {
|
|
3699
|
-
await this.klarnaHandle.authorize();
|
|
3713
|
+
await this.klarnaHandle.authorize(cat);
|
|
3700
3714
|
} finally {
|
|
3701
3715
|
this.klarnaAuthorizing = false;
|
|
3702
3716
|
}
|
|
@@ -4370,5 +4384,5 @@ function registerVioElements() {
|
|
|
4370
4384
|
}
|
|
4371
4385
|
|
|
4372
4386
|
export { VioCart, VioCheckout, VioProduct, VioProductCarousel, VioProductDetail, VioTokens, applyVioTheme, registerVioElements };
|
|
4373
|
-
//# sourceMappingURL=chunk-
|
|
4374
|
-
//# sourceMappingURL=chunk-
|
|
4387
|
+
//# sourceMappingURL=chunk-D6IA4ZWL.js.map
|
|
4388
|
+
//# sourceMappingURL=chunk-D6IA4ZWL.js.map
|