ui.shipaid.com 0.3.39 → 0.3.41

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
@@ -965,7 +965,7 @@ const useOnce = (element, on) => useEffect(element, on, []);
965
965
  function n(n2, o3, r2) {
966
966
  return n2 ? o3() : null == r2 ? void 0 : r2();
967
967
  }
968
- const styles$1 = i$2`
968
+ const styles$2 = i$2`
969
969
  :host {
970
970
  --shipaid-primary: #0056d6;
971
971
  --shipaid-secondary: #0076ff;
@@ -1483,15 +1483,15 @@ const BellIcon = x`
1483
1483
  </g>
1484
1484
  </svg>
1485
1485
  `;
1486
- var __defProp$1 = Object.defineProperty;
1487
- var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
1488
- var __decorateClass$1 = (decorators, target, key, kind) => {
1489
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
1486
+ var __defProp$2 = Object.defineProperty;
1487
+ var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
1488
+ var __decorateClass$2 = (decorators, target, key, kind) => {
1489
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
1490
1490
  for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
1491
1491
  if (decorator = decorators[i2])
1492
1492
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1493
1493
  if (kind && result)
1494
- __defProp$1(target, key, result);
1494
+ __defProp$2(target, key, result);
1495
1495
  return result;
1496
1496
  };
1497
1497
  class LearnMorePopup extends s$1 {
@@ -1567,13 +1567,217 @@ class LearnMorePopup extends s$1 {
1567
1567
  `;
1568
1568
  }
1569
1569
  }
1570
- LearnMorePopup.styles = styles$1;
1571
- __decorateClass$1([
1570
+ LearnMorePopup.styles = styles$2;
1571
+ __decorateClass$2([
1572
1572
  n$7({ type: Boolean, attribute: true })
1573
1573
  ], LearnMorePopup.prototype, "active", 2);
1574
1574
  if (!customElements.get("shipaid-popup-learn-more")) {
1575
1575
  customElements.define("shipaid-popup-learn-more", LearnMorePopup);
1576
1576
  }
1577
+ const styles$1 = i$2`
1578
+ :host {
1579
+ --shipaid-primary: #0056d6;
1580
+ --shipaid-secondary: #0076ff;
1581
+ --shipaid-danger: #f44336;
1582
+ --shipaid-text: #000000;
1583
+ --shipaid-text-muted: #cccccc;
1584
+ --shipaid-text-grey: #aaaaaa;
1585
+ --shipaid-light-grey: #ebecf0;
1586
+ --shipaid-light-blue: #bacef4;
1587
+ --shipaid-font: "Lato", sans-serif;
1588
+ --shipaid-font-xs: 12px;
1589
+ --shipaid-font-sm: 14px;
1590
+ --shipaid-font-base: 16px;
1591
+ --shipaid-font-lg: 18px;
1592
+ --shipaid-font-display: 36px;
1593
+ --shipaid-font-regular: 400;
1594
+ --shipaid-font-heavy: 700;
1595
+ }
1596
+
1597
+ p,
1598
+ a {
1599
+ font-family: var(--shipaid-font);
1600
+ font-weight: var(--shipaid-font-regular);
1601
+ font-size: var(--shipaid-font-base);
1602
+ color: var(--shipaid-text);
1603
+ }
1604
+
1605
+ .shipaid-confirmation-popup {
1606
+ position: fixed;
1607
+ top: 0;
1608
+ bottom: 0;
1609
+ left: 0;
1610
+ right: 0;
1611
+ margin: 13rem auto;
1612
+ max-width: 30%;
1613
+ max-height: 70vh;
1614
+ height: fit-content;
1615
+ border: var(--shipaid-popup-border, var(--shipaid-primary)) .2rem solid;
1616
+ background-color: var(--shipaid-popup-background, #fff);
1617
+ border-radius: 45px;
1618
+ z-index: 1000000000;
1619
+ overflow: auto;
1620
+ visibility: hidden;
1621
+ opacity: 0;
1622
+ transition: all 250ms ease-in-out;
1623
+ display: inline-flex;
1624
+ flex-direction: column;
1625
+ gap: 1rem;
1626
+ padding: 2rem
1627
+ }
1628
+
1629
+ .shipaid-confirmation-popup.active {
1630
+ visibility: visible;
1631
+ opacity: 1;
1632
+ }
1633
+
1634
+ .shipaid-confirmation-popup.active + .blocker {
1635
+ z-index: 50;
1636
+ }
1637
+
1638
+ .popup-actions {
1639
+ display: flex;
1640
+ flex-direction: row;
1641
+ justify-content: space-around;
1642
+ margin-top: 2rem;
1643
+ margin-bottom: 1rem;
1644
+ }
1645
+
1646
+ .popup-subtitle {
1647
+ text-align: center;
1648
+ }
1649
+
1650
+ @media (max-width: 600px) {
1651
+ .shipaid-confirmation-popup {
1652
+ width: auto;
1653
+ height: 100vh;
1654
+ padding: 3rem;
1655
+ margin-left: 20px;
1656
+ margin-right: 20px;
1657
+ }
1658
+ }
1659
+
1660
+ .btn-primary {
1661
+ background-color: #0073e6;
1662
+ color: white;
1663
+ border: none;
1664
+ padding: 10px 20px;
1665
+ border-radius: 4px;
1666
+ cursor: pointer;
1667
+ }
1668
+
1669
+ .btn-primary:hover {
1670
+ background-color: #005bb5;
1671
+ }
1672
+
1673
+ .btn-secondary {
1674
+ background-color: transparent;
1675
+ color: #666;
1676
+ border: 1px solid #ccc;
1677
+ padding: 10px 20px;
1678
+ border-radius: 4px;
1679
+ cursor: pointer;
1680
+ }
1681
+
1682
+ .btn-secondary:hover {
1683
+ background-color: #f5f5f5;
1684
+ }
1685
+
1686
+
1687
+ .shipaid-confirmation-popup .popup-title {
1688
+ font-size: var(--shipaid-font-display);
1689
+ font-weight: var(--shipaid-font-regular);
1690
+ letter-spacing: 1px;
1691
+ text-align: center;
1692
+ }
1693
+
1694
+ @media (max-width: 600px) {
1695
+ .shipaid-confirmation-popup .popup-title {
1696
+ font-size: 2rem;
1697
+ }
1698
+ }
1699
+
1700
+ .shipaid-confirmation-popup p {
1701
+ font-size: var(--shipaid-font-base);
1702
+ margin: 0;
1703
+ }
1704
+
1705
+ @media (max-width: 600px) {
1706
+ .shipaid-confirmation-popup p {
1707
+ font-size: 10px;
1708
+ }
1709
+ }
1710
+
1711
+ .blocker {
1712
+ position: fixed;
1713
+ top: 0;
1714
+ left: 0;
1715
+ bottom: 0;
1716
+ right: 0;
1717
+ content: " ";
1718
+ background: transparent;
1719
+ z-index: -1;
1720
+ }
1721
+ `;
1722
+ var __defProp$1 = Object.defineProperty;
1723
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
1724
+ var __decorateClass$1 = (decorators, target, key, kind) => {
1725
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
1726
+ for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
1727
+ if (decorator = decorators[i2])
1728
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1729
+ if (kind && result)
1730
+ __defProp$1(target, key, result);
1731
+ return result;
1732
+ };
1733
+ class ConfirmationPopup extends s$1 {
1734
+ constructor() {
1735
+ super(...arguments);
1736
+ this.active = false;
1737
+ }
1738
+ handleClosePopup() {
1739
+ const event = new Event("close");
1740
+ this.dispatchEvent(event);
1741
+ }
1742
+ handleRemoveProtection() {
1743
+ const event = new Event("remove-protection");
1744
+ this.dispatchEvent(event);
1745
+ }
1746
+ render() {
1747
+ return x`
1748
+ <div class=${`shipaid-confirmation-popup ${this.active && "active"}`}>
1749
+ <p class="popup-title">Are you sure?</p>
1750
+ <div class="popup-subtitle">
1751
+ <p>Thousands of customers choose to protect their orders to ensure a seamless resolution process in the event of damage or loss in transit.</p>
1752
+ </div>
1753
+ <div class="popup-actions">
1754
+ <button
1755
+ type="button"
1756
+ class="btn-primary"
1757
+ @click=${this.handleClosePopup}
1758
+ >
1759
+ Keep the Delivery Guarantee
1760
+ </button>
1761
+ <button
1762
+ type="button"
1763
+ class="btn-secondary"
1764
+ @click=${this.handleRemoveProtection}
1765
+ >
1766
+ No, I'd like to ship my order unprotected
1767
+ </button>
1768
+ </div>
1769
+ </div>
1770
+ <div class="blocker" @click=${this.handleClosePopup}></div>
1771
+ `;
1772
+ }
1773
+ }
1774
+ ConfirmationPopup.styles = styles$1;
1775
+ __decorateClass$1([
1776
+ n$7({ type: Boolean, attribute: true })
1777
+ ], ConfirmationPopup.prototype, "active", 2);
1778
+ if (!customElements.get("shipaid-popup-confirmation")) {
1779
+ customElements.define("shipaid-popup-confirmation", ConfirmationPopup);
1780
+ }
1577
1781
  const loading = "Loading ShipAid Widget...";
1578
1782
  const title = "Delivery Guarantee";
1579
1783
  const description = "in case of Loss, Damage or Theft";
@@ -1989,9 +2193,23 @@ class ShipAidWidget extends s$1 {
1989
2193
  error: state2 === "error" ? message || true : false
1990
2194
  };
1991
2195
  }
2196
+ /** Trigger confirmation popup */
2197
+ _handleConfirmationPopup() {
2198
+ if (this._popup === "confirmation")
2199
+ return;
2200
+ this._popup = "confirmation";
2201
+ }
1992
2202
  /** Updates the current protection status, calling the relevant add/remove function. */
1993
- async _updateProtection() {
1994
- return this._hasProtectionInCart ? this.removeProtection() : this.addProtection();
2203
+ _updateProtection() {
2204
+ var _a, _b, _c;
2205
+ const removeWithConfirmation = (_c = (_b = (_a = this._store) == null ? void 0 : _a.widgetConfigurations) == null ? void 0 : _b.widget) == null ? void 0 : _c.removeWithConfirmation;
2206
+ if (!this._hasProtectionInCart) {
2207
+ return this.addProtection();
2208
+ }
2209
+ if (!removeWithConfirmation) {
2210
+ return this.removeProtection();
2211
+ }
2212
+ return this._handleConfirmationPopup();
1995
2213
  }
1996
2214
  /** Fetches store info from the ShipAid public API. */
1997
2215
  async _fetchShipAidData() {
@@ -2191,10 +2409,6 @@ class ShipAidWidget extends s$1 {
2191
2409
  const hasSessionPayload = !!sessionStorage.getItem(LOCAL_STORAGE_KEY);
2192
2410
  if (hasSessionPayload)
2193
2411
  return;
2194
- sessionStorage.setItem(
2195
- LOCAL_STORAGE_KEY,
2196
- JSON.stringify({ loaded: true })
2197
- );
2198
2412
  if (
2199
2413
  // If we first check that no protection items are in the cart
2200
2414
  !this._hasProtectionInCart && // Then check we have some items in the cart
@@ -2202,6 +2416,10 @@ class ShipAidWidget extends s$1 {
2202
2416
  this._store.widgetShowCart
2203
2417
  ) {
2204
2418
  await this.addProtection();
2419
+ sessionStorage.setItem(
2420
+ LOCAL_STORAGE_KEY,
2421
+ JSON.stringify({ loaded: true })
2422
+ );
2205
2423
  }
2206
2424
  }
2207
2425
  async handleMultipleProtectionVariants() {
@@ -2236,9 +2454,6 @@ class ShipAidWidget extends s$1 {
2236
2454
  }
2237
2455
  /** Templates */
2238
2456
  learnMorePopupTemplate() {
2239
- if (this.persistPopup) {
2240
- this._popup = this.shouldPersistPopup();
2241
- }
2242
2457
  return x`
2243
2458
  <shipaid-popup-learn-more
2244
2459
  ?active=${this._popup === "learn-more"}
@@ -2251,6 +2466,39 @@ class ShipAidWidget extends s$1 {
2251
2466
  ></shipaid-popup-learn-more>
2252
2467
  `;
2253
2468
  }
2469
+ confirmationPopupTemplate() {
2470
+ return x`
2471
+ <shipaid-popup-confirmation
2472
+ ?active=${this._popup === "confirmation"}
2473
+ @close=${() => {
2474
+ if (this.persistPopup) {
2475
+ localStorage.removeItem(`${LOCAL_STORAGE_SHIPAID_POPUP_KEY}`);
2476
+ }
2477
+ this._popup = null;
2478
+ }}
2479
+ @remove-protection=${() => {
2480
+ this.removeProtection();
2481
+ if (this.persistPopup) {
2482
+ localStorage.removeItem(`${LOCAL_STORAGE_SHIPAID_POPUP_KEY}`);
2483
+ }
2484
+ this._popup = null;
2485
+ }}
2486
+ ></shipaid-popup-confirmation>
2487
+ `;
2488
+ }
2489
+ renderPopups() {
2490
+ if (this.persistPopup) {
2491
+ this._popup = this.shouldPersistPopup();
2492
+ }
2493
+ switch (this._popup) {
2494
+ case "confirmation":
2495
+ return this.confirmationPopupTemplate();
2496
+ case "learn-more":
2497
+ return this.learnMorePopupTemplate();
2498
+ default:
2499
+ return null;
2500
+ }
2501
+ }
2254
2502
  promptTemplate() {
2255
2503
  var _a, _b, _c;
2256
2504
  const { useToggle, useCheckbox, leftCheckbox } = ((_b = (_a = this._store) == null ? void 0 : _a.widgetConfigurations) == null ? void 0 : _b.widget) || { useToggle: false, useCheckbox: false, leftCheckbox: false };
@@ -2544,7 +2792,7 @@ class ShipAidWidget extends s$1 {
2544
2792
  },
2545
2793
  [this._store, this._cart]
2546
2794
  );
2547
- D(this.learnMorePopupTemplate(), document.body);
2795
+ D(this.renderPopups(), document.body);
2548
2796
  return x`
2549
2797
  <style>
2550
2798
  :host {