@trycourier/courier-ui-inbox 1.0.6-beta → 1.0.7-beta

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/index.mjs CHANGED
@@ -73,7 +73,15 @@ const addSystemThemeModeListener = (callback) => {
73
73
  mediaQuery.removeEventListener("change", handler);
74
74
  };
75
75
  };
76
- class CourierSystemThemeElement extends HTMLElement {
76
+ const BaseElement = typeof window === "undefined" ? class {
77
+ constructor() {
78
+ }
79
+ } : class extends HTMLElement {
80
+ constructor() {
81
+ super();
82
+ }
83
+ };
84
+ class CourierSystemThemeElement extends BaseElement {
77
85
  constructor() {
78
86
  super();
79
87
  __publicField2(this, "_currentSystemTheme");
@@ -217,9 +225,6 @@ class CourierButton extends CourierSystemThemeElement {
217
225
  this._style.textContent = this.getStyles(props);
218
226
  }
219
227
  }
220
- if (!customElements.get("courier-button")) {
221
- customElements.define("courier-button", CourierButton);
222
- }
223
228
  const CourierIconSVGs = {
224
229
  inbox: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
225
230
  <path d="M5.5 14.5V17C5.5 17.2812 5.71875 17.5 6 17.5H18C18.25 17.5 18.5 17.2812 18.5 17V14.5H15.9375L15.2812 15.8125C15.0938 16.25 14.6562 16.5 14.1875 16.5H9.78125C9.3125 16.5 8.875 16.25 8.6875 15.8125L8.03125 14.5H5.5ZM18.1875 13L16.6562 6.90625C16.5938 6.65625 16.4062 6.5 16.1875 6.5H7.8125C7.5625 6.5 7.375 6.65625 7.3125 6.90625L5.78125 13H8.1875C8.65625 13 9.09375 13.2812 9.3125 13.7188L9.9375 15H14.0312L14.6875 13.7188C14.875 13.2812 15.3125 13 15.7812 13H18.1875ZM4 14.25C4 14.0938 4 13.9375 4.03125 13.7812L5.84375 6.53125C6.09375 5.625 6.875 5 7.8125 5H16.1875C17.0938 5 17.9062 5.625 18.125 6.53125L19.9375 13.7812C19.9688 13.9375 20 14.0938 20 14.25V17C20 18.125 19.0938 19 18 19H6C4.875 19 4 18.125 4 17V14.25Z" fill="currentColor"/>
@@ -249,7 +254,7 @@ const CourierIconSVGs = {
249
254
  <path d="M5.5 11C5.0625 11 4.75 10.6875 4.75 10.25V5.75C4.75 5.34375 5.0625 5 5.5 5C5.90625 5 6.25 5.34375 6.25 5.75V8.28125L6.875 7.53125C8.15625 6 10.0625 5 12.25 5C16.0938 5 19.25 8.15625 19.25 12C19.25 15.875 16.0938 19 12.25 19C10.6562 19 9.21875 18.5 8.03125 17.625C7.71875 17.375 7.625 16.9062 7.875 16.5625C8.125 16.2188 8.59375 16.1562 8.9375 16.4062C9.84375 17.0938 11 17.5 12.25 17.5C15.2812 17.5 17.75 15.0625 17.75 12C17.75 8.96875 15.2812 6.5 12.25 6.5C10.5312 6.5 9.03125 7.28125 8 8.5L7.15625 9.5H10C10.4062 9.5 10.75 9.84375 10.75 10.25C10.75 10.6875 10.4062 11 10 11H5.5Z" fill="currentColor"/>
250
255
  </svg>`
251
256
  };
252
- class CourierIcon extends HTMLElement {
257
+ class CourierIcon extends BaseElement {
253
258
  constructor(color, svg) {
254
259
  super();
255
260
  __publicField2(this, "_color");
@@ -300,10 +305,7 @@ class CourierIcon extends HTMLElement {
300
305
  this.refresh();
301
306
  }
302
307
  }
303
- if (!customElements.get("courier-icon")) {
304
- customElements.define("courier-icon", CourierIcon);
305
- }
306
- class CourierLink extends HTMLElement {
308
+ class CourierLink extends BaseElement {
307
309
  constructor() {
308
310
  super();
309
311
  __publicField2(this, "link");
@@ -465,9 +467,6 @@ __publicField2(CourierLink, "observedAttributes", [
465
467
  "font-family",
466
468
  "font-size"
467
469
  ]);
468
- if (!customElements.get("courier-link")) {
469
- customElements.define("courier-link", CourierLink);
470
- }
471
470
  class CourierElement extends CourierSystemThemeElement {
472
471
  constructor() {
473
472
  super();
@@ -573,10 +572,7 @@ class CourierInfoState extends CourierElement {
573
572
  this._buttonClickCallback = callback;
574
573
  }
575
574
  }
576
- if (!customElements.get("courier-info-state")) {
577
- customElements.define("courier-info-state", CourierInfoState);
578
- }
579
- class CourierIconButton extends HTMLElement {
575
+ class CourierIconButton extends BaseElement {
580
576
  constructor(svg, color, backgroundColor, hoverBackgroundColor, activeBackgroundColor, borderRadius, height, width) {
581
577
  super();
582
578
  __publicField2(this, "_backgroundColor");
@@ -669,21 +665,20 @@ class CourierIconButton extends HTMLElement {
669
665
  this.refresh();
670
666
  }
671
667
  }
672
- if (!customElements.get("courier-icon-button")) {
673
- customElements.define("courier-icon-button", CourierIconButton);
668
+ function registerElement(name, element) {
669
+ if (typeof window !== "undefined" && !customElements.get(name)) {
670
+ customElements.define(name, element);
671
+ }
674
672
  }
675
673
  const components = [
676
674
  { name: "courier-button", class: CourierButton },
677
675
  { name: "courier-icon", class: CourierIcon },
678
676
  { name: "courier-link", class: CourierLink },
679
677
  { name: "courier-info-state", class: CourierInfoState },
680
- { name: "courier-icon-button", class: CourierIconButton }
678
+ { name: "courier-icon-button", class: CourierIconButton },
679
+ { name: "courier-system-theme", class: CourierSystemThemeElement }
681
680
  ];
682
- components.forEach(({ name, class: componentClass }) => {
683
- if (!customElements.get(name)) {
684
- customElements.define(name, componentClass);
685
- }
686
- });
681
+ components.forEach(({ name, class: componentClass }) => registerElement(name, componentClass));
687
682
  function copyMessage(message) {
688
683
  const copy = {
689
684
  ...message
@@ -729,7 +724,7 @@ function getMessageTime(message) {
729
724
  if (diffInSeconds < 31536e3) return `${Math.floor(diffInSeconds / 604800)}w`;
730
725
  return `${Math.floor(diffInSeconds / 31536e3)}y`;
731
726
  }
732
- class CourierListItemActionMenu extends HTMLElement {
727
+ class CourierInboxListItemMenu extends BaseElement {
733
728
  constructor(theme2) {
734
729
  super();
735
730
  // State
@@ -824,9 +819,7 @@ class CourierListItemActionMenu extends HTMLElement {
824
819
  this.classList.remove("visible");
825
820
  }
826
821
  }
827
- if (!customElements.get("courier-list-item-menu")) {
828
- customElements.define("courier-list-item-menu", CourierListItemActionMenu);
829
- }
822
+ registerElement("courier-inbox-list-item-menu", CourierInboxListItemMenu);
830
823
  const _CourierInboxDatastore = class _CourierInboxDatastore {
831
824
  constructor() {
832
825
  __publicField(this, "_inboxDataSet");
@@ -1518,7 +1511,7 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
1518
1511
  };
1519
1512
  __publicField(_CourierInboxDatastore, "instance");
1520
1513
  let CourierInboxDatastore = _CourierInboxDatastore;
1521
- class CourierListItem extends HTMLElement {
1514
+ class CourierListItem extends BaseElement {
1522
1515
  constructor(theme2) {
1523
1516
  super();
1524
1517
  // State
@@ -1561,7 +1554,7 @@ class CourierListItem extends HTMLElement {
1561
1554
  this._unreadIndicator.className = "unread-indicator";
1562
1555
  this._style = document.createElement("style");
1563
1556
  this._refreshStyles();
1564
- this._menu = new CourierListItemActionMenu(this._theme);
1557
+ this._menu = new CourierInboxListItemMenu(this._theme);
1565
1558
  this._menu.setOptions(this._getMenuOptions());
1566
1559
  shadow.append(this._style, this._unreadIndicator, contentContainer, this._timeElement, this._menu);
1567
1560
  const cancelPropagation = (e) => {
@@ -1728,11 +1721,11 @@ class CourierListItem extends HTMLElement {
1728
1721
 
1729
1722
  /* ───────────────────────── Menu hover / active ────────────────── */
1730
1723
  @media (hover: hover) {
1731
- :host(:hover):has(courier-list-item-menu:hover, courier-list-item-menu *:hover, courier-button:hover, courier-button *:hover) {
1724
+ :host(:hover):has(courier-inbox-list-item-menu:hover, courier-inbox-list-item-menu *:hover, courier-button:hover, courier-button *:hover) {
1732
1725
  background-color: ${(listItem == null ? void 0 : listItem.backgroundColor) ?? "transparent"};
1733
1726
  }
1734
1727
  }
1735
- :host(:active):has(courier-list-item-menu:active, courier-list-item-menu *:active, courier-button:active, courier-button *:active) {
1728
+ :host(:active):has(courier-inbox-list-item-menu:active, courier-inbox-list-item-menu *:active, courier-button:active, courier-button *:active) {
1736
1729
  background-color: ${(listItem == null ? void 0 : listItem.backgroundColor) ?? "transparent"};
1737
1730
  }
1738
1731
 
@@ -1796,7 +1789,7 @@ class CourierListItem extends HTMLElement {
1796
1789
  white-space: nowrap;
1797
1790
  }
1798
1791
 
1799
- courier-list-item-menu {
1792
+ courier-inbox-list-item-menu {
1800
1793
  z-index: 1;
1801
1794
  position: absolute;
1802
1795
  top: 8px;
@@ -1892,10 +1885,8 @@ class CourierListItem extends HTMLElement {
1892
1885
  });
1893
1886
  }
1894
1887
  }
1895
- if (!customElements.get("courier-list-item")) {
1896
- customElements.define("courier-list-item", CourierListItem);
1897
- }
1898
- class CourierInboxSkeletonListItem extends HTMLElement {
1888
+ registerElement("courier-inbox-list-item", CourierListItem);
1889
+ class CourierInboxSkeletonListItem extends BaseElement {
1899
1890
  constructor(theme2, opacity) {
1900
1891
  super();
1901
1892
  // Shadow root
@@ -1925,10 +1916,8 @@ class CourierInboxSkeletonListItem extends HTMLElement {
1925
1916
  `;
1926
1917
  }
1927
1918
  }
1928
- if (!customElements.get("courier-inbox-skeleton-list-item")) {
1929
- customElements.define("courier-inbox-skeleton-list-item", CourierInboxSkeletonListItem);
1930
- }
1931
- class CourierSkeletonAnimatedRow extends HTMLElement {
1919
+ registerElement("courier-inbox-skeleton-list-item", CourierInboxSkeletonListItem);
1920
+ class CourierSkeletonAnimatedRow extends BaseElement {
1932
1921
  constructor(theme2, widthPercent) {
1933
1922
  super();
1934
1923
  __publicField(this, "_shadow");
@@ -1983,9 +1972,7 @@ class CourierSkeletonAnimatedRow extends HTMLElement {
1983
1972
  `;
1984
1973
  }
1985
1974
  }
1986
- if (!customElements.get("courier-skeleton-animated-row")) {
1987
- customElements.define("courier-skeleton-animated-row", CourierSkeletonAnimatedRow);
1988
- }
1975
+ registerElement("courier-skeleton-animated-row", CourierSkeletonAnimatedRow);
1989
1976
  class CourierInboxSkeletonList extends CourierElement {
1990
1977
  constructor(theme2) {
1991
1978
  super();
@@ -2035,10 +2022,8 @@ class CourierInboxSkeletonList extends CourierElement {
2035
2022
  `;
2036
2023
  }
2037
2024
  }
2038
- if (!customElements.get("courier-inbox-skeleton-list")) {
2039
- customElements.define("courier-inbox-skeleton-list", CourierInboxSkeletonList);
2040
- }
2041
- class CourierInboxPaginationListItem extends HTMLElement {
2025
+ registerElement("courier-inbox-skeleton-list", CourierInboxSkeletonList);
2026
+ class CourierInboxPaginationListItem extends BaseElement {
2042
2027
  constructor(props) {
2043
2028
  super();
2044
2029
  // Components
@@ -2089,10 +2074,8 @@ class CourierInboxPaginationListItem extends HTMLElement {
2089
2074
  this.observer.disconnect();
2090
2075
  }
2091
2076
  }
2092
- if (!customElements.get("courier-inbox-pagination-list-item")) {
2093
- customElements.define("courier-inbox-pagination-list-item", CourierInboxPaginationListItem);
2094
- }
2095
- class CourierInboxList extends HTMLElement {
2077
+ registerElement("courier-inbox-pagination-list-item", CourierInboxPaginationListItem);
2078
+ class CourierInboxList extends BaseElement {
2096
2079
  constructor(props) {
2097
2080
  super();
2098
2081
  // Theme
@@ -2343,10 +2326,8 @@ class CourierInboxList extends HTMLElement {
2343
2326
  this._themeSubscription.unsubscribe();
2344
2327
  }
2345
2328
  }
2346
- if (!customElements.get("courier-inbox-list")) {
2347
- customElements.define("courier-inbox-list", CourierInboxList);
2348
- }
2349
- class CourierInboxOptionMenuItem extends HTMLElement {
2329
+ registerElement("courier-inbox-list", CourierInboxList);
2330
+ class CourierInboxOptionMenuItem extends BaseElement {
2350
2331
  constructor(props) {
2351
2332
  super();
2352
2333
  // State
@@ -2439,10 +2420,8 @@ class CourierInboxOptionMenuItem extends HTMLElement {
2439
2420
  this._itemIcon.updateSVG(((_d = this._option.icon) == null ? void 0 : _d.svg) ?? CourierIconSVGs.inbox);
2440
2421
  }
2441
2422
  }
2442
- if (!customElements.get("courier-inbox-filter-menu-item")) {
2443
- customElements.define("courier-inbox-filter-menu-item", CourierInboxOptionMenuItem);
2444
- }
2445
- class CourierInboxOptionMenu extends HTMLElement {
2423
+ registerElement("courier-inbox-filter-menu-item", CourierInboxOptionMenuItem);
2424
+ class CourierInboxOptionMenu extends BaseElement {
2446
2425
  constructor(themeManager, type, selectable, options, onMenuOpen) {
2447
2426
  super();
2448
2427
  // Theme
@@ -2571,10 +2550,8 @@ class CourierInboxOptionMenu extends HTMLElement {
2571
2550
  this._themeSubscription.unsubscribe();
2572
2551
  }
2573
2552
  }
2574
- if (!customElements.get("courier-inbox-option-menu")) {
2575
- customElements.define("courier-inbox-option-menu", CourierInboxOptionMenu);
2576
- }
2577
- class CourierUnreadCountBadge extends HTMLElement {
2553
+ registerElement("courier-inbox-option-menu", CourierInboxOptionMenu);
2554
+ class CourierUnreadCountBadge extends BaseElement {
2578
2555
  constructor(props) {
2579
2556
  super();
2580
2557
  // Theme
@@ -2643,10 +2620,8 @@ class CourierUnreadCountBadge extends HTMLElement {
2643
2620
  this._themeSubscription.unsubscribe();
2644
2621
  }
2645
2622
  }
2646
- if (!customElements.get("courier-unread-count-badge")) {
2647
- customElements.define("courier-unread-count-badge", CourierUnreadCountBadge);
2648
- }
2649
- class CourierInboxHeaderTitle extends HTMLElement {
2623
+ registerElement("courier-unread-count-badge", CourierUnreadCountBadge);
2624
+ class CourierInboxHeaderTitle extends BaseElement {
2650
2625
  constructor(themeManager, option) {
2651
2626
  super();
2652
2627
  // Theme
@@ -2743,9 +2718,7 @@ class CourierInboxHeaderTitle extends HTMLElement {
2743
2718
  this._themeSubscription.unsubscribe();
2744
2719
  }
2745
2720
  }
2746
- if (!customElements.get("courier-inbox-header-title")) {
2747
- customElements.define("courier-inbox-header-title", CourierInboxHeaderTitle);
2748
- }
2721
+ registerElement("courier-inbox-header-title", CourierInboxHeaderTitle);
2749
2722
  class CourierInboxHeader extends CourierElement {
2750
2723
  constructor(props) {
2751
2724
  super();
@@ -2951,9 +2924,7 @@ class CourierInboxHeader extends CourierElement {
2951
2924
  this._themeSubscription.unsubscribe();
2952
2925
  }
2953
2926
  }
2954
- if (!customElements.get("courier-inbox-header")) {
2955
- customElements.define("courier-inbox-header", CourierInboxHeader);
2956
- }
2927
+ registerElement("courier-inbox-header", CourierInboxHeader);
2957
2928
  class CourierInboxDataStoreListener {
2958
2929
  constructor(events) {
2959
2930
  __publicField(this, "events");
@@ -3732,7 +3703,7 @@ class CourierInboxThemeManager {
3732
3703
  this._subscriptions = [];
3733
3704
  }
3734
3705
  }
3735
- class CourierInbox extends HTMLElement {
3706
+ class CourierInbox extends BaseElement {
3736
3707
  constructor(themeManager) {
3737
3708
  var _a;
3738
3709
  super();
@@ -4038,9 +4009,7 @@ class CourierInbox extends HTMLElement {
4038
4009
  }
4039
4010
  }
4040
4011
  }
4041
- if (!customElements.get("courier-inbox")) {
4042
- customElements.define("courier-inbox", CourierInbox);
4043
- }
4012
+ registerElement("courier-inbox", CourierInbox);
4044
4013
  class CourierInboxMenuButton extends CourierElement {
4045
4014
  constructor(themeBus) {
4046
4015
  super();
@@ -4106,10 +4075,8 @@ class CourierInboxMenuButton extends CourierElement {
4106
4075
  this._themeSubscription.unsubscribe();
4107
4076
  }
4108
4077
  }
4109
- if (!customElements.get("courier-inbox-menu-button")) {
4110
- customElements.define("courier-inbox-menu-button", CourierInboxMenuButton);
4111
- }
4112
- class CourierInboxMenu extends HTMLElement {
4078
+ registerElement("courier-inbox-menu-button", CourierInboxMenuButton);
4079
+ class CourierInboxPopupMenu extends BaseElement {
4113
4080
  constructor() {
4114
4081
  super();
4115
4082
  // State
@@ -4414,9 +4381,7 @@ class CourierInboxMenu extends HTMLElement {
4414
4381
  this._themeManager.cleanup();
4415
4382
  }
4416
4383
  }
4417
- if (!customElements.get("courier-inbox-menu")) {
4418
- customElements.define("courier-inbox-menu", CourierInboxMenu);
4419
- }
4384
+ registerElement("courier-inbox-popup-menu", CourierInboxPopupMenu);
4420
4385
  function markAsRead(message) {
4421
4386
  return CourierInboxDatastore.shared.readMessage({ message });
4422
4387
  }
@@ -4454,7 +4419,7 @@ export {
4454
4419
  CourierInboxDatastore,
4455
4420
  CourierInboxDatastoreEvents,
4456
4421
  CourierInboxHeader,
4457
- CourierInboxMenu,
4422
+ CourierInboxPopupMenu,
4458
4423
  CourierInboxThemeManager,
4459
4424
  CourierListItem,
4460
4425
  archiveMessage,