ui.shipaid.com 0.3.147 → 0.3.148
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/widget.es.js
CHANGED
|
@@ -3506,6 +3506,21 @@ const openCarousel = (from) => {
|
|
|
3506
3506
|
} catch {
|
|
3507
3507
|
}
|
|
3508
3508
|
};
|
|
3509
|
+
const ensureLearnMoreCarousel = (store) => {
|
|
3510
|
+
var _a, _b;
|
|
3511
|
+
try {
|
|
3512
|
+
const existing = document.querySelector("shipaid-learn-more-carousel");
|
|
3513
|
+
if (existing) return;
|
|
3514
|
+
const el = document.createElement("shipaid-learn-more-carousel");
|
|
3515
|
+
const isGreenEnabled = Boolean((_a = store == null ? void 0 : store.greenProtection) == null ? void 0 : _a.enabled);
|
|
3516
|
+
const isFreeGiftEnabled = Boolean((_b = store == null ? void 0 : store.freeGifts) == null ? void 0 : _b.enabled);
|
|
3517
|
+
if (isGreenEnabled) el.setAttribute("green-protection", "true");
|
|
3518
|
+
if (isFreeGiftEnabled) el.setAttribute("free-gift", "true");
|
|
3519
|
+
el.setAttribute("carousel-state", "close");
|
|
3520
|
+
document.body.appendChild(el);
|
|
3521
|
+
} catch {
|
|
3522
|
+
}
|
|
3523
|
+
};
|
|
3509
3524
|
const refreshShopifyCartUI = async () => {
|
|
3510
3525
|
try {
|
|
3511
3526
|
const sectionIds = ["cart-drawer", "cart-icon-bubble", "main-cart-items"];
|
|
@@ -3659,7 +3674,6 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
3659
3674
|
} catch {
|
|
3660
3675
|
}
|
|
3661
3676
|
};
|
|
3662
|
-
this._pendingLearnMoreSource = null;
|
|
3663
3677
|
this._handleHelpClick = (event) => {
|
|
3664
3678
|
if (event) event.preventDefault();
|
|
3665
3679
|
this._toggleBenefits();
|
|
@@ -3746,8 +3760,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
3746
3760
|
}
|
|
3747
3761
|
}
|
|
3748
3762
|
_openLearnMore(source) {
|
|
3749
|
-
|
|
3750
|
-
this._pendingLearnMoreSource = source;
|
|
3763
|
+
openCarousel(source);
|
|
3751
3764
|
if (this.persistPopup) {
|
|
3752
3765
|
this.setPopupKey();
|
|
3753
3766
|
}
|
|
@@ -4427,19 +4440,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
4427
4440
|
}
|
|
4428
4441
|
/** Templates */
|
|
4429
4442
|
learnMorePopupTemplate() {
|
|
4430
|
-
|
|
4431
|
-
const carousel = document.querySelector("shipaid-learn-more-carousel");
|
|
4432
|
-
const isGreenEnabled = Boolean((_b = (_a = this._store) == null ? void 0 : _a.greenProtection) == null ? void 0 : _b.enabled);
|
|
4433
|
-
const isFreeGiftEnabled = Boolean((_d = (_c = this._store) == null ? void 0 : _c.freeGifts) == null ? void 0 : _d.enabled);
|
|
4434
|
-
if (carousel) return;
|
|
4435
|
-
return x`
|
|
4436
|
-
<shipaid-learn-more-carousel
|
|
4437
|
-
carousel-state=${this._popup === "learn-more" ? "open" : "close"}
|
|
4438
|
-
free-gift=${isFreeGiftEnabled}
|
|
4439
|
-
green-protection=${isGreenEnabled}
|
|
4440
|
-
>
|
|
4441
|
-
</shipaid-learn-more-carousel>
|
|
4442
|
-
`;
|
|
4443
|
+
return null;
|
|
4443
4444
|
}
|
|
4444
4445
|
confirmationPopupTemplate() {
|
|
4445
4446
|
return x`
|
|
@@ -5019,15 +5020,14 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
5019
5020
|
renderPopups() {
|
|
5020
5021
|
if (this.persistPopup) {
|
|
5021
5022
|
this._popup = this.shouldPersistPopup();
|
|
5022
|
-
if (this._popup === "learn-more"
|
|
5023
|
-
|
|
5023
|
+
if (this._popup === "learn-more") {
|
|
5024
|
+
openCarousel("shipaid-widget");
|
|
5025
|
+
this._popup = null;
|
|
5024
5026
|
}
|
|
5025
5027
|
}
|
|
5026
5028
|
switch (this._popup) {
|
|
5027
5029
|
case "confirmation":
|
|
5028
5030
|
return this.confirmationPopupTemplate();
|
|
5029
|
-
case "learn-more":
|
|
5030
|
-
return this.learnMorePopupTemplate();
|
|
5031
5031
|
default:
|
|
5032
5032
|
return null;
|
|
5033
5033
|
}
|
|
@@ -5420,6 +5420,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
5420
5420
|
return;
|
|
5421
5421
|
}
|
|
5422
5422
|
this._hasFinishedSetup = true;
|
|
5423
|
+
ensureLearnMoreCarousel(this._store);
|
|
5423
5424
|
this._dispatchEvent(SHIPAID_EVENTS.LOADED, this._store);
|
|
5424
5425
|
setTimeout(async () => {
|
|
5425
5426
|
var _a2, _b2, _c2, _d2;
|
|
@@ -5481,24 +5482,6 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
5481
5482
|
this,
|
|
5482
5483
|
() => {
|
|
5483
5484
|
D(this.renderPopups(), document.body);
|
|
5484
|
-
if (this._popup === "learn-more") {
|
|
5485
|
-
const source = this._pendingLearnMoreSource ?? "shipaid-widget";
|
|
5486
|
-
this._pendingLearnMoreSource = null;
|
|
5487
|
-
requestAnimationFrame(() => {
|
|
5488
|
-
try {
|
|
5489
|
-
window.dispatchEvent(
|
|
5490
|
-
new CustomEvent(SHIPAID_EVENTS.LEARN_MORE_OPENED, {
|
|
5491
|
-
detail: { source }
|
|
5492
|
-
})
|
|
5493
|
-
);
|
|
5494
|
-
} catch (error) {
|
|
5495
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
5496
|
-
logger.error(`Failed to open ShipAid learn more carousel: ${message}`);
|
|
5497
|
-
}
|
|
5498
|
-
});
|
|
5499
|
-
} else {
|
|
5500
|
-
this._pendingLearnMoreSource = null;
|
|
5501
|
-
}
|
|
5502
5485
|
},
|
|
5503
5486
|
[this._popup]
|
|
5504
5487
|
);
|
|
@@ -6198,19 +6181,7 @@ class ShipAidCheckoutPlus extends s$1 {
|
|
|
6198
6181
|
}
|
|
6199
6182
|
}
|
|
6200
6183
|
_ensureLearnMoreCarousel() {
|
|
6201
|
-
|
|
6202
|
-
try {
|
|
6203
|
-
const existing = document.querySelector("shipaid-learn-more-carousel");
|
|
6204
|
-
if (existing) return;
|
|
6205
|
-
const el = document.createElement("shipaid-learn-more-carousel");
|
|
6206
|
-
const isGreenEnabled = Boolean((_b = (_a = this._store) == null ? void 0 : _a.greenProtection) == null ? void 0 : _b.enabled);
|
|
6207
|
-
const isFreeGiftEnabled = Boolean((_d = (_c = this._store) == null ? void 0 : _c.freeGifts) == null ? void 0 : _d.enabled);
|
|
6208
|
-
if (isGreenEnabled) el.setAttribute("green-protection", "true");
|
|
6209
|
-
if (isFreeGiftEnabled) el.setAttribute("free-gift", "true");
|
|
6210
|
-
el.setAttribute("carousel-state", "close");
|
|
6211
|
-
document.body.appendChild(el);
|
|
6212
|
-
} catch {
|
|
6213
|
-
}
|
|
6184
|
+
ensureLearnMoreCarousel(this._store);
|
|
6214
6185
|
}
|
|
6215
6186
|
_shouldShowWidget() {
|
|
6216
6187
|
var _a;
|