@trycourier/courier-ui-inbox 1.0.7-beta → 1.0.9-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/README.md +380 -0
- package/dist/components/courier-inbox-header-title.d.ts +12 -9
- package/dist/components/courier-inbox-header.d.ts +11 -8
- package/dist/components/courier-inbox-list-item-menu.d.ts +7 -6
- package/dist/components/courier-inbox-list-item.d.ts +11 -12
- package/dist/components/courier-inbox-list.d.ts +11 -6
- package/dist/components/courier-inbox-menu-button.d.ts +10 -5
- package/dist/components/courier-inbox-option-menu-item.d.ts +9 -9
- package/dist/components/courier-inbox-option-menu.d.ts +11 -9
- package/dist/components/courier-inbox-pagination-list-item.d.ts +12 -8
- package/dist/components/courier-inbox-popup-menu.d.ts +19 -16
- package/dist/components/courier-inbox-skeleton-list-item.d.ts +10 -5
- package/dist/components/courier-inbox-skeleton-list.d.ts +7 -3
- package/dist/components/courier-inbox.d.ts +10 -8
- package/dist/components/courier-unread-count-badge.d.ts +10 -6
- package/dist/datastore/datastore.d.ts +1 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1062 -852
- package/dist/index.mjs.map +1 -1
- package/dist/types/courier-inbox-theme.d.ts +52 -52
- package/dist/types/snapshots.d.ts +2 -2
- package/dist/utils/utils.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { Courier } from "@trycourier/courier-js";
|
|
4
|
+
import { Courier, InboxMessageEvent } from "@trycourier/courier-js";
|
|
5
|
+
import { Courier as Courier2 } from "@trycourier/courier-js";
|
|
5
6
|
var __defProp2 = Object.defineProperty;
|
|
7
|
+
var __typeError = (msg) => {
|
|
8
|
+
throw TypeError(msg);
|
|
9
|
+
};
|
|
6
10
|
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
11
|
var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
12
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
13
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), member.get(obj));
|
|
14
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
15
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
16
|
+
var _isInitialised;
|
|
8
17
|
const CourierColors = {
|
|
9
18
|
black: {
|
|
10
19
|
500: "#171717",
|
|
@@ -73,15 +82,52 @@ const addSystemThemeModeListener = (callback) => {
|
|
|
73
82
|
mediaQuery.removeEventListener("change", handler);
|
|
74
83
|
};
|
|
75
84
|
};
|
|
76
|
-
const
|
|
77
|
-
|
|
85
|
+
const HTMLElementBase = (() => {
|
|
86
|
+
try {
|
|
87
|
+
return typeof HTMLElement === "undefined" ? class {
|
|
88
|
+
} : HTMLElement;
|
|
89
|
+
} catch {
|
|
90
|
+
return class {
|
|
91
|
+
};
|
|
78
92
|
}
|
|
79
|
-
}
|
|
93
|
+
})();
|
|
94
|
+
class CourierBaseElement extends HTMLElementBase {
|
|
80
95
|
constructor() {
|
|
81
|
-
super();
|
|
96
|
+
super(...arguments);
|
|
97
|
+
__privateAdd(this, _isInitialised, false);
|
|
82
98
|
}
|
|
83
|
-
|
|
84
|
-
|
|
99
|
+
/** Tag-name you’ll use in `customElements.define()` */
|
|
100
|
+
static get id() {
|
|
101
|
+
return "courier-base-element";
|
|
102
|
+
}
|
|
103
|
+
/* ------------------------------------------------------------------ */
|
|
104
|
+
/* Custom-elements lifecycle hooks */
|
|
105
|
+
/* ------------------------------------------------------------------ */
|
|
106
|
+
connectedCallback() {
|
|
107
|
+
var _a;
|
|
108
|
+
if (__privateGet(this, _isInitialised)) return;
|
|
109
|
+
__privateSet(this, _isInitialised, true);
|
|
110
|
+
(_a = this.onComponentMounted) == null ? void 0 : _a.call(this);
|
|
111
|
+
}
|
|
112
|
+
disconnectedCallback() {
|
|
113
|
+
var _a;
|
|
114
|
+
__privateSet(this, _isInitialised, false);
|
|
115
|
+
(_a = this.onComponentUnmounted) == null ? void 0 : _a.call(this);
|
|
116
|
+
}
|
|
117
|
+
/* ------------------------------------------------------------------ */
|
|
118
|
+
/* Overridable hooks */
|
|
119
|
+
/* ------------------------------------------------------------------ */
|
|
120
|
+
/** Called **once** when the element first becomes part of the DOM. */
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
122
|
+
onComponentMounted() {
|
|
123
|
+
}
|
|
124
|
+
/** Called when the element is removed from the DOM. */
|
|
125
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
126
|
+
onComponentUnmounted() {
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
_isInitialised = /* @__PURE__ */ new WeakMap();
|
|
130
|
+
class CourierSystemThemeElement extends CourierBaseElement {
|
|
85
131
|
constructor() {
|
|
86
132
|
super();
|
|
87
133
|
__publicField2(this, "_currentSystemTheme");
|
|
@@ -92,13 +138,16 @@ class CourierSystemThemeElement extends BaseElement {
|
|
|
92
138
|
this.onSystemThemeChange(mode);
|
|
93
139
|
});
|
|
94
140
|
}
|
|
141
|
+
static get id() {
|
|
142
|
+
return "courier-system-theme-element";
|
|
143
|
+
}
|
|
95
144
|
get currentSystemTheme() {
|
|
96
145
|
return this._currentSystemTheme;
|
|
97
146
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
147
|
+
onComponentUnmounted() {
|
|
148
|
+
var _a;
|
|
149
|
+
(_a = this._systemThemeCleanup) == null ? void 0 : _a.call(this);
|
|
150
|
+
super.onComponentUnmounted();
|
|
102
151
|
}
|
|
103
152
|
onSystemThemeChange(_) {
|
|
104
153
|
}
|
|
@@ -153,6 +202,9 @@ class CourierButton extends CourierSystemThemeElement {
|
|
|
153
202
|
}
|
|
154
203
|
});
|
|
155
204
|
}
|
|
205
|
+
static get id() {
|
|
206
|
+
return "courier-button";
|
|
207
|
+
}
|
|
156
208
|
getStyles(props) {
|
|
157
209
|
const defaultTextColor = () => {
|
|
158
210
|
const secondary = CourierButtonVariants.secondary(this.currentSystemTheme);
|
|
@@ -254,7 +306,7 @@ const CourierIconSVGs = {
|
|
|
254
306
|
<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"/>
|
|
255
307
|
</svg>`
|
|
256
308
|
};
|
|
257
|
-
class CourierIcon extends
|
|
309
|
+
class CourierIcon extends CourierBaseElement {
|
|
258
310
|
constructor(color, svg) {
|
|
259
311
|
super();
|
|
260
312
|
__publicField2(this, "_color");
|
|
@@ -271,6 +323,9 @@ class CourierIcon extends BaseElement {
|
|
|
271
323
|
shadow.appendChild(this._style);
|
|
272
324
|
this.refresh();
|
|
273
325
|
}
|
|
326
|
+
static get id() {
|
|
327
|
+
return "courier-icon";
|
|
328
|
+
}
|
|
274
329
|
getStyles(color) {
|
|
275
330
|
return `
|
|
276
331
|
:host {
|
|
@@ -305,7 +360,7 @@ class CourierIcon extends BaseElement {
|
|
|
305
360
|
this.refresh();
|
|
306
361
|
}
|
|
307
362
|
}
|
|
308
|
-
class CourierLink extends
|
|
363
|
+
class CourierLink extends CourierBaseElement {
|
|
309
364
|
constructor() {
|
|
310
365
|
super();
|
|
311
366
|
__publicField2(this, "link");
|
|
@@ -369,6 +424,9 @@ class CourierLink extends BaseElement {
|
|
|
369
424
|
this.updateUnderline();
|
|
370
425
|
this.updateMode();
|
|
371
426
|
}
|
|
427
|
+
static get id() {
|
|
428
|
+
return "courier-link";
|
|
429
|
+
}
|
|
372
430
|
connectedCallback() {
|
|
373
431
|
const slot = document.createElement("slot");
|
|
374
432
|
this.link.appendChild(slot);
|
|
@@ -467,20 +525,18 @@ __publicField2(CourierLink, "observedAttributes", [
|
|
|
467
525
|
"font-family",
|
|
468
526
|
"font-size"
|
|
469
527
|
]);
|
|
470
|
-
class
|
|
528
|
+
class CourierFactoryElement extends CourierSystemThemeElement {
|
|
471
529
|
constructor() {
|
|
472
530
|
super();
|
|
473
|
-
__publicField2(this, "shadow");
|
|
474
|
-
this.shadow = this.attachShadow({ mode: "open" });
|
|
475
531
|
}
|
|
476
532
|
// Build the element with a factory function
|
|
477
533
|
build(newElement) {
|
|
478
534
|
if (newElement === null) {
|
|
479
|
-
this.
|
|
535
|
+
this.replaceChildren();
|
|
480
536
|
return;
|
|
481
537
|
}
|
|
482
538
|
const element = newElement ?? this.defaultElement();
|
|
483
|
-
this.
|
|
539
|
+
this.replaceChildren(element);
|
|
484
540
|
}
|
|
485
541
|
// Default element to be used if no factory is provided
|
|
486
542
|
defaultElement() {
|
|
@@ -494,18 +550,20 @@ class CourierElement extends CourierSystemThemeElement {
|
|
|
494
550
|
return element;
|
|
495
551
|
}
|
|
496
552
|
}
|
|
497
|
-
class CourierInfoState extends
|
|
553
|
+
class CourierInfoState extends CourierFactoryElement {
|
|
498
554
|
constructor(props) {
|
|
499
555
|
super();
|
|
500
556
|
__publicField2(this, "_props");
|
|
501
557
|
__publicField2(this, "_title");
|
|
502
558
|
__publicField2(this, "_button");
|
|
503
559
|
__publicField2(this, "_style");
|
|
504
|
-
__publicField2(this, "_buttonClickCallback", null);
|
|
505
560
|
this._props = props;
|
|
506
561
|
}
|
|
562
|
+
static get id() {
|
|
563
|
+
return "courier-info-state";
|
|
564
|
+
}
|
|
507
565
|
defaultElement() {
|
|
508
|
-
var _a
|
|
566
|
+
var _a;
|
|
509
567
|
const container = document.createElement("div");
|
|
510
568
|
this._title = document.createElement("h2");
|
|
511
569
|
if ((_a = this._props.title) == null ? void 0 : _a.text) {
|
|
@@ -518,12 +576,7 @@ class CourierInfoState extends CourierElement {
|
|
|
518
576
|
container.appendChild(this._style);
|
|
519
577
|
container.appendChild(this._title);
|
|
520
578
|
container.appendChild(this._button);
|
|
521
|
-
this.
|
|
522
|
-
(_b = this._button) == null ? void 0 : _b.addEventListener("click", () => {
|
|
523
|
-
if (this._buttonClickCallback) {
|
|
524
|
-
this._buttonClickCallback();
|
|
525
|
-
}
|
|
526
|
-
});
|
|
579
|
+
this.appendChild(container);
|
|
527
580
|
return container;
|
|
528
581
|
}
|
|
529
582
|
onSystemThemeChange(_) {
|
|
@@ -548,6 +601,8 @@ class CourierInfoState extends CourierElement {
|
|
|
548
601
|
gap: 16px;
|
|
549
602
|
text-align: center;
|
|
550
603
|
padding: 24px;
|
|
604
|
+
box-sizing: border-box;
|
|
605
|
+
height: 100%;
|
|
551
606
|
}
|
|
552
607
|
|
|
553
608
|
.container h2 {
|
|
@@ -568,11 +623,8 @@ class CourierInfoState extends CourierElement {
|
|
|
568
623
|
this._button.updateButton(props.button);
|
|
569
624
|
}
|
|
570
625
|
}
|
|
571
|
-
setButtonClickCallback(callback) {
|
|
572
|
-
this._buttonClickCallback = callback;
|
|
573
|
-
}
|
|
574
626
|
}
|
|
575
|
-
class CourierIconButton extends
|
|
627
|
+
class CourierIconButton extends CourierBaseElement {
|
|
576
628
|
constructor(svg, color, backgroundColor, hoverBackgroundColor, activeBackgroundColor, borderRadius, height, width) {
|
|
577
629
|
super();
|
|
578
630
|
__publicField2(this, "_backgroundColor");
|
|
@@ -600,6 +652,9 @@ class CourierIconButton extends BaseElement {
|
|
|
600
652
|
this._button.appendChild(this._icon);
|
|
601
653
|
shadow.appendChild(this._button);
|
|
602
654
|
}
|
|
655
|
+
static get id() {
|
|
656
|
+
return "courier-icon-button";
|
|
657
|
+
}
|
|
603
658
|
refresh() {
|
|
604
659
|
this._style.textContent = this.getStyles();
|
|
605
660
|
}
|
|
@@ -665,20 +720,29 @@ class CourierIconButton extends BaseElement {
|
|
|
665
720
|
this.refresh();
|
|
666
721
|
}
|
|
667
722
|
}
|
|
668
|
-
function registerElement(
|
|
669
|
-
if (typeof window !== "undefined" && !customElements.get(
|
|
670
|
-
customElements.define(
|
|
723
|
+
function registerElement(element) {
|
|
724
|
+
if (typeof window !== "undefined" && !customElements.get(element.id)) {
|
|
725
|
+
customElements.define(element.id, element);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
function injectGlobalStyle(styleId, styles) {
|
|
729
|
+
const selector = `style[data-${styleId}]`;
|
|
730
|
+
const existingStyle = document.querySelector(selector);
|
|
731
|
+
if (!existingStyle) {
|
|
732
|
+
const style = document.createElement("style");
|
|
733
|
+
style.setAttribute(`data-${styleId}`, "");
|
|
734
|
+
style.textContent = styles;
|
|
735
|
+
document.head.appendChild(style);
|
|
736
|
+
return style;
|
|
671
737
|
}
|
|
738
|
+
return existingStyle;
|
|
672
739
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
{ name: "courier-system-theme", class: CourierSystemThemeElement }
|
|
680
|
-
];
|
|
681
|
-
components.forEach(({ name, class: componentClass }) => registerElement(name, componentClass));
|
|
740
|
+
registerElement(CourierButton);
|
|
741
|
+
registerElement(CourierIcon);
|
|
742
|
+
registerElement(CourierLink);
|
|
743
|
+
registerElement(CourierInfoState);
|
|
744
|
+
registerElement(CourierIconButton);
|
|
745
|
+
registerElement(CourierSystemThemeElement);
|
|
682
746
|
function copyMessage(message) {
|
|
683
747
|
const copy = {
|
|
684
748
|
...message
|
|
@@ -707,6 +771,9 @@ function copyInboxAction(action) {
|
|
|
707
771
|
return copy;
|
|
708
772
|
}
|
|
709
773
|
function copyInboxDataSet(dataSet) {
|
|
774
|
+
if (!dataSet) {
|
|
775
|
+
return void 0;
|
|
776
|
+
}
|
|
710
777
|
return {
|
|
711
778
|
...dataSet,
|
|
712
779
|
messages: dataSet.messages.map((message) => copyMessage(message))
|
|
@@ -717,6 +784,7 @@ function getMessageTime(message) {
|
|
|
717
784
|
const now = /* @__PURE__ */ new Date();
|
|
718
785
|
const messageDate = new Date(message.created);
|
|
719
786
|
const diffInSeconds = Math.floor((now.getTime() - messageDate.getTime()) / 1e3);
|
|
787
|
+
if (diffInSeconds < 5) return "Now";
|
|
720
788
|
if (diffInSeconds < 60) return `${diffInSeconds}s`;
|
|
721
789
|
if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)}m`;
|
|
722
790
|
if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)}h`;
|
|
@@ -724,29 +792,28 @@ function getMessageTime(message) {
|
|
|
724
792
|
if (diffInSeconds < 31536e3) return `${Math.floor(diffInSeconds / 604800)}w`;
|
|
725
793
|
return `${Math.floor(diffInSeconds / 31536e3)}y`;
|
|
726
794
|
}
|
|
727
|
-
class CourierInboxListItemMenu extends
|
|
795
|
+
class CourierInboxListItemMenu extends CourierBaseElement {
|
|
728
796
|
constructor(theme2) {
|
|
729
797
|
super();
|
|
730
798
|
// State
|
|
731
799
|
__publicField(this, "_theme");
|
|
732
800
|
__publicField(this, "_options", []);
|
|
733
|
-
// Components
|
|
734
|
-
__publicField(this, "_style");
|
|
735
801
|
this._theme = theme2;
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
802
|
+
}
|
|
803
|
+
static get id() {
|
|
804
|
+
return "courier-inbox-list-item-menu";
|
|
805
|
+
}
|
|
806
|
+
onComponentMounted() {
|
|
740
807
|
const menu = document.createElement("ul");
|
|
741
808
|
menu.className = "menu";
|
|
742
|
-
|
|
809
|
+
this.appendChild(menu);
|
|
743
810
|
}
|
|
744
|
-
getStyles() {
|
|
811
|
+
static getStyles(theme2) {
|
|
745
812
|
var _a, _b, _c;
|
|
746
|
-
const menu = (_c = (_b = (_a =
|
|
813
|
+
const menu = (_c = (_b = (_a = theme2.inbox) == null ? void 0 : _a.list) == null ? void 0 : _b.item) == null ? void 0 : _c.menu;
|
|
747
814
|
return `
|
|
748
|
-
|
|
749
|
-
display:
|
|
815
|
+
${CourierInboxListItemMenu.id} {
|
|
816
|
+
display: none;
|
|
750
817
|
position: absolute;
|
|
751
818
|
background: ${(menu == null ? void 0 : menu.backgroundColor) ?? "red"};
|
|
752
819
|
border: ${(menu == null ? void 0 : menu.border) ?? "1px solid red"};
|
|
@@ -759,12 +826,13 @@ class CourierInboxListItemMenu extends BaseElement {
|
|
|
759
826
|
overflow: hidden;
|
|
760
827
|
}
|
|
761
828
|
|
|
762
|
-
|
|
829
|
+
${CourierInboxListItemMenu.id}.visible {
|
|
830
|
+
display: block;
|
|
763
831
|
opacity: 1;
|
|
764
832
|
pointer-events: auto;
|
|
765
833
|
}
|
|
766
834
|
|
|
767
|
-
ul.menu {
|
|
835
|
+
${CourierInboxListItemMenu.id} ul.menu {
|
|
768
836
|
list-style: none;
|
|
769
837
|
margin: 0;
|
|
770
838
|
padding: 0;
|
|
@@ -772,7 +840,7 @@ class CourierInboxListItemMenu extends BaseElement {
|
|
|
772
840
|
flex-direction: row;
|
|
773
841
|
}
|
|
774
842
|
|
|
775
|
-
li.menu-item {
|
|
843
|
+
${CourierInboxListItemMenu.id} li.menu-item {
|
|
776
844
|
display: flex;
|
|
777
845
|
align-items: center;
|
|
778
846
|
justify-content: center;
|
|
@@ -787,11 +855,11 @@ class CourierInboxListItemMenu extends BaseElement {
|
|
|
787
855
|
this.renderMenu();
|
|
788
856
|
}
|
|
789
857
|
renderMenu() {
|
|
790
|
-
var _a, _b, _c
|
|
791
|
-
const menu =
|
|
858
|
+
var _a, _b, _c;
|
|
859
|
+
const menu = this.querySelector("ul.menu");
|
|
792
860
|
if (!menu) return;
|
|
793
861
|
menu.innerHTML = "";
|
|
794
|
-
const menuTheme = (
|
|
862
|
+
const menuTheme = (_c = (_b = (_a = this._theme.inbox) == null ? void 0 : _a.list) == null ? void 0 : _b.item) == null ? void 0 : _c.menu;
|
|
795
863
|
const cancelEvent = (e) => {
|
|
796
864
|
e.stopPropagation();
|
|
797
865
|
e.preventDefault();
|
|
@@ -813,13 +881,15 @@ class CourierInboxListItemMenu extends BaseElement {
|
|
|
813
881
|
});
|
|
814
882
|
}
|
|
815
883
|
show() {
|
|
884
|
+
this.style.display = "block";
|
|
816
885
|
this.classList.add("visible");
|
|
817
886
|
}
|
|
818
887
|
hide() {
|
|
888
|
+
this.style.display = "none";
|
|
819
889
|
this.classList.remove("visible");
|
|
820
890
|
}
|
|
821
891
|
}
|
|
822
|
-
registerElement(
|
|
892
|
+
registerElement(CourierInboxListItemMenu);
|
|
823
893
|
const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
824
894
|
constructor() {
|
|
825
895
|
__publicField(this, "_inboxDataSet");
|
|
@@ -850,28 +920,22 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
|
850
920
|
removeDataStoreListener(listener) {
|
|
851
921
|
this._dataStoreListeners = this._dataStoreListeners.filter((l) => l !== listener);
|
|
852
922
|
}
|
|
853
|
-
async
|
|
854
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
923
|
+
async fetchCachableDataSet(props) {
|
|
924
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
855
925
|
if (props.canUseCache) {
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
break;
|
|
862
|
-
case "archive":
|
|
863
|
-
if (this._archiveDataSet) {
|
|
864
|
-
return this._archiveDataSet;
|
|
865
|
-
}
|
|
866
|
-
break;
|
|
926
|
+
if (props.feedType === "inbox" && this._inboxDataSet) {
|
|
927
|
+
return this._inboxDataSet;
|
|
928
|
+
}
|
|
929
|
+
if (props.feedType === "archive" && this._archiveDataSet) {
|
|
930
|
+
return this._archiveDataSet;
|
|
867
931
|
}
|
|
868
932
|
}
|
|
869
|
-
const response =
|
|
933
|
+
const response = await props.fetch;
|
|
870
934
|
return {
|
|
871
935
|
feedType: props.feedType,
|
|
872
|
-
messages: ((
|
|
873
|
-
canPaginate: ((
|
|
874
|
-
paginationCursor: ((
|
|
936
|
+
messages: ((_b = (_a = response.data) == null ? void 0 : _a.messages) == null ? void 0 : _b.nodes) ?? [],
|
|
937
|
+
canPaginate: ((_e = (_d = (_c = response.data) == null ? void 0 : _c.messages) == null ? void 0 : _d.pageInfo) == null ? void 0 : _e.hasNextPage) ?? false,
|
|
938
|
+
paginationCursor: ((_h = (_g = (_f = response.data) == null ? void 0 : _f.messages) == null ? void 0 : _g.pageInfo) == null ? void 0 : _h.startCursor) ?? null
|
|
875
939
|
};
|
|
876
940
|
}
|
|
877
941
|
async fetchUnreadCount(props) {
|
|
@@ -883,43 +947,43 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
|
883
947
|
return unreadCount ?? 0;
|
|
884
948
|
}
|
|
885
949
|
async load(props) {
|
|
886
|
-
var _a, _b
|
|
950
|
+
var _a, _b;
|
|
887
951
|
try {
|
|
888
|
-
|
|
952
|
+
const client = Courier.shared.client;
|
|
953
|
+
if (!(client == null ? void 0 : client.options.userId)) {
|
|
889
954
|
throw new Error("User is not signed in");
|
|
890
955
|
}
|
|
891
|
-
const properties = props ?? {
|
|
892
|
-
const [
|
|
893
|
-
this.
|
|
956
|
+
const properties = props ?? { canUseCache: true };
|
|
957
|
+
const [inboxDataSet, archiveDataSet, unreadCount] = await Promise.all([
|
|
958
|
+
this.fetchCachableDataSet({ fetch: client.inbox.getMessages(), feedType: "inbox", canUseCache: properties.canUseCache }),
|
|
959
|
+
this.fetchCachableDataSet({ fetch: client.inbox.getArchivedMessages(), feedType: "archive", canUseCache: properties.canUseCache }),
|
|
894
960
|
this.fetchUnreadCount(properties)
|
|
895
961
|
]);
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
this._inboxDataSet = dataSet;
|
|
899
|
-
break;
|
|
900
|
-
case "archive":
|
|
901
|
-
this._archiveDataSet = dataSet;
|
|
902
|
-
break;
|
|
903
|
-
}
|
|
962
|
+
this._inboxDataSet = inboxDataSet;
|
|
963
|
+
this._archiveDataSet = archiveDataSet;
|
|
904
964
|
this._unreadCount = unreadCount;
|
|
905
965
|
this._dataStoreListeners.forEach((listener) => {
|
|
906
|
-
var _a2, _b2,
|
|
907
|
-
|
|
908
|
-
|
|
966
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
967
|
+
if (this._inboxDataSet) {
|
|
968
|
+
(_b2 = (_a2 = listener.events).onDataSetChange) == null ? void 0 : _b2.call(_a2, this._inboxDataSet, "inbox");
|
|
969
|
+
}
|
|
970
|
+
if (this._archiveDataSet) {
|
|
971
|
+
(_d = (_c = listener.events).onDataSetChange) == null ? void 0 : _d.call(_c, this._archiveDataSet, "archive");
|
|
972
|
+
}
|
|
973
|
+
(_f = (_e = listener.events).onUnreadCountChange) == null ? void 0 : _f.call(_e, this._unreadCount ?? 0);
|
|
909
974
|
});
|
|
910
975
|
} catch (error) {
|
|
911
|
-
(
|
|
976
|
+
(_b = (_a = Courier.shared.client) == null ? void 0 : _a.options.logger) == null ? void 0 : _b.error("Error loading inbox:", error);
|
|
912
977
|
this._dataStoreListeners.forEach((listener) => {
|
|
913
978
|
var _a2, _b2;
|
|
914
979
|
(_b2 = (_a2 = listener.events).onError) == null ? void 0 : _b2.call(_a2, error);
|
|
915
980
|
});
|
|
916
981
|
}
|
|
917
982
|
}
|
|
918
|
-
|
|
983
|
+
// Connect the socket
|
|
919
984
|
async listenForUpdates() {
|
|
920
985
|
var _a, _b;
|
|
921
986
|
try {
|
|
922
|
-
await this.ensureDataSetsLoaded();
|
|
923
987
|
await this.connectSocket();
|
|
924
988
|
} catch (error) {
|
|
925
989
|
(_b = (_a = Courier.shared.client) == null ? void 0 : _a.options.logger) == null ? void 0 : _b.error("Error listening for updates:", error);
|
|
@@ -929,85 +993,73 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
|
929
993
|
});
|
|
930
994
|
}
|
|
931
995
|
}
|
|
932
|
-
/** Fetch either/both datasets if they aren't already loaded. */
|
|
933
|
-
async ensureDataSetsLoaded() {
|
|
934
|
-
let dataSetPromises = [];
|
|
935
|
-
if (!this._inboxDataSet) {
|
|
936
|
-
dataSetPromises.push(this.load({ feedType: "inbox", canUseCache: true }));
|
|
937
|
-
}
|
|
938
|
-
if (!this._archiveDataSet) {
|
|
939
|
-
dataSetPromises.push(this.load({ feedType: "archive", canUseCache: true }));
|
|
940
|
-
}
|
|
941
|
-
await Promise.all(dataSetPromises);
|
|
942
|
-
}
|
|
943
996
|
async connectSocket() {
|
|
944
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k
|
|
997
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
945
998
|
const socket = (_a = Courier.shared.client) == null ? void 0 : _a.inbox.socket;
|
|
946
999
|
try {
|
|
947
1000
|
if (!socket) {
|
|
948
1001
|
(_c = (_b = Courier.shared.client) == null ? void 0 : _b.options.logger) == null ? void 0 : _c.info("CourierInbox socket not available");
|
|
949
1002
|
return;
|
|
950
1003
|
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
(_h = (_g = Courier.shared.client) == null ? void 0 : _g.options.logger) == null ? void 0 : _h.info("CourierInbox socket already connected. Socket will not attempt reconnection.");
|
|
1004
|
+
if (socket.isConnecting || socket.isOpen) {
|
|
1005
|
+
(_f = (_d = Courier.shared.client) == null ? void 0 : _d.options.logger) == null ? void 0 : _f.info(`Inbox socket already connecting or open for client ID: [${(_e = Courier.shared.client) == null ? void 0 : _e.options.connectionId}]`);
|
|
954
1006
|
return;
|
|
955
1007
|
}
|
|
956
|
-
socket.
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
if (event.messageId) {
|
|
962
|
-
message = this.getMessage({ messageId: event.messageId });
|
|
1008
|
+
socket.addMessageEventListener((event) => {
|
|
1009
|
+
if (event.event === InboxMessageEvent.NewMessage) {
|
|
1010
|
+
const message2 = event.data;
|
|
1011
|
+
this.addMessage(message2, 0, "inbox");
|
|
1012
|
+
return;
|
|
963
1013
|
}
|
|
1014
|
+
const message = this.getMessage({ messageId: event.messageId });
|
|
964
1015
|
switch (event.event) {
|
|
965
|
-
case
|
|
1016
|
+
case InboxMessageEvent.MarkAllRead:
|
|
966
1017
|
this.readAllMessages({ canCallApi: false });
|
|
967
1018
|
break;
|
|
968
|
-
case
|
|
1019
|
+
case InboxMessageEvent.Read:
|
|
969
1020
|
if (message) {
|
|
970
1021
|
this.readMessage({ message, canCallApi: false });
|
|
971
1022
|
}
|
|
972
1023
|
break;
|
|
973
|
-
case
|
|
1024
|
+
case InboxMessageEvent.Unread:
|
|
974
1025
|
if (message) {
|
|
975
1026
|
this.unreadMessage({ message, canCallApi: false });
|
|
976
1027
|
}
|
|
977
1028
|
break;
|
|
978
|
-
case
|
|
1029
|
+
case InboxMessageEvent.Opened:
|
|
979
1030
|
if (message) {
|
|
980
1031
|
this.openMessage({ message, canCallApi: false });
|
|
981
1032
|
}
|
|
982
1033
|
break;
|
|
983
|
-
case
|
|
1034
|
+
case InboxMessageEvent.Archive:
|
|
984
1035
|
if (message) {
|
|
985
1036
|
this.archiveMessage({ message, canCallApi: false });
|
|
986
1037
|
}
|
|
987
1038
|
break;
|
|
988
|
-
case
|
|
1039
|
+
case InboxMessageEvent.ArchiveRead:
|
|
989
1040
|
this.archiveReadMessages({ canCallApi: false });
|
|
990
1041
|
break;
|
|
991
|
-
case
|
|
1042
|
+
case InboxMessageEvent.ArchiveAll:
|
|
1043
|
+
this.archiveAllMessages({ canCallApi: false });
|
|
1044
|
+
break;
|
|
1045
|
+
case InboxMessageEvent.Clicked:
|
|
992
1046
|
if (message) {
|
|
993
1047
|
this.clickMessage({ message, canCallApi: false });
|
|
994
1048
|
}
|
|
995
1049
|
break;
|
|
996
|
-
case
|
|
1050
|
+
case InboxMessageEvent.Unarchive:
|
|
997
1051
|
if (message) {
|
|
998
1052
|
this.unarchiveMessage({ message, canCallApi: false });
|
|
999
1053
|
}
|
|
1000
1054
|
break;
|
|
1001
|
-
case
|
|
1055
|
+
case InboxMessageEvent.Unopened:
|
|
1002
1056
|
break;
|
|
1003
1057
|
}
|
|
1004
|
-
};
|
|
1058
|
+
});
|
|
1005
1059
|
await socket.connect();
|
|
1006
|
-
|
|
1007
|
-
socket.keepAlive();
|
|
1008
|
-
(_j = (_i = Courier.shared.client) == null ? void 0 : _i.options.logger) == null ? void 0 : _j.info("CourierInbox socket connected");
|
|
1060
|
+
(_i = (_g = Courier.shared.client) == null ? void 0 : _g.options.logger) == null ? void 0 : _i.info(`Inbox socket connected for client ID: [${(_h = Courier.shared.client) == null ? void 0 : _h.options.connectionId}]`);
|
|
1009
1061
|
} catch (error) {
|
|
1010
|
-
(
|
|
1062
|
+
(_k = (_j = Courier.shared.client) == null ? void 0 : _j.options.logger) == null ? void 0 : _k.error("Failed to connect socket:", error);
|
|
1011
1063
|
}
|
|
1012
1064
|
}
|
|
1013
1065
|
/**
|
|
@@ -1017,6 +1069,9 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
|
1017
1069
|
*/
|
|
1018
1070
|
getMessage(props) {
|
|
1019
1071
|
var _a, _b;
|
|
1072
|
+
if (!props.messageId) {
|
|
1073
|
+
return void 0;
|
|
1074
|
+
}
|
|
1020
1075
|
return ((_a = this._inboxDataSet) == null ? void 0 : _a.messages.find((m) => m.messageId === props.messageId)) ?? ((_b = this._archiveDataSet) == null ? void 0 : _b.messages.find((m) => m.messageId === props.messageId));
|
|
1021
1076
|
}
|
|
1022
1077
|
/**
|
|
@@ -1444,8 +1499,12 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
|
1444
1499
|
this._archiveDataSet = archive;
|
|
1445
1500
|
this._dataStoreListeners.forEach((listener) => {
|
|
1446
1501
|
var _a, _b, _c, _d, _e, _f;
|
|
1447
|
-
|
|
1448
|
-
|
|
1502
|
+
if (this._inboxDataSet) {
|
|
1503
|
+
(_b = (_a = listener.events).onDataSetChange) == null ? void 0 : _b.call(_a, this._inboxDataSet, "inbox");
|
|
1504
|
+
}
|
|
1505
|
+
if (this._archiveDataSet) {
|
|
1506
|
+
(_d = (_c = listener.events).onDataSetChange) == null ? void 0 : _d.call(_c, this._archiveDataSet, "archive");
|
|
1507
|
+
}
|
|
1449
1508
|
(_f = (_e = listener.events).onUnreadCountChange) == null ? void 0 : _f.call(_e, unreadCount);
|
|
1450
1509
|
});
|
|
1451
1510
|
}
|
|
@@ -1511,7 +1570,7 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
|
1511
1570
|
};
|
|
1512
1571
|
__publicField(_CourierInboxDatastore, "instance");
|
|
1513
1572
|
let CourierInboxDatastore = _CourierInboxDatastore;
|
|
1514
|
-
class
|
|
1573
|
+
class CourierInboxListItem extends CourierBaseElement {
|
|
1515
1574
|
constructor(theme2) {
|
|
1516
1575
|
super();
|
|
1517
1576
|
// State
|
|
@@ -1523,7 +1582,6 @@ class CourierListItem extends BaseElement {
|
|
|
1523
1582
|
__publicField(this, "_titleElement");
|
|
1524
1583
|
__publicField(this, "_subtitleElement");
|
|
1525
1584
|
__publicField(this, "_timeElement");
|
|
1526
|
-
__publicField(this, "_style");
|
|
1527
1585
|
__publicField(this, "_menu");
|
|
1528
1586
|
__publicField(this, "_unreadIndicator");
|
|
1529
1587
|
__publicField(this, "_actionsContainer");
|
|
@@ -1536,27 +1594,30 @@ class CourierListItem extends BaseElement {
|
|
|
1536
1594
|
__publicField(this, "onItemActionClick", null);
|
|
1537
1595
|
this._theme = theme2;
|
|
1538
1596
|
this._isMobile = "ontouchstart" in window;
|
|
1539
|
-
|
|
1597
|
+
this.render();
|
|
1598
|
+
}
|
|
1599
|
+
static get id() {
|
|
1600
|
+
return "courier-inbox-list-item";
|
|
1601
|
+
}
|
|
1602
|
+
render() {
|
|
1540
1603
|
const contentContainer = document.createElement("div");
|
|
1541
1604
|
contentContainer.className = "content-container";
|
|
1542
1605
|
this._titleElement = document.createElement("p");
|
|
1543
|
-
this._titleElement.
|
|
1606
|
+
this._titleElement.className = "title";
|
|
1544
1607
|
this._subtitleElement = document.createElement("p");
|
|
1545
|
-
this._subtitleElement.
|
|
1608
|
+
this._subtitleElement.className = "subtitle";
|
|
1546
1609
|
this._actionsContainer = document.createElement("div");
|
|
1547
1610
|
this._actionsContainer.className = "actions-container";
|
|
1548
1611
|
contentContainer.appendChild(this._titleElement);
|
|
1549
1612
|
contentContainer.appendChild(this._subtitleElement);
|
|
1550
1613
|
contentContainer.appendChild(this._actionsContainer);
|
|
1551
1614
|
this._timeElement = document.createElement("p");
|
|
1552
|
-
this._timeElement.
|
|
1615
|
+
this._timeElement.className = "time";
|
|
1553
1616
|
this._unreadIndicator = document.createElement("div");
|
|
1554
1617
|
this._unreadIndicator.className = "unread-indicator";
|
|
1555
|
-
this._style = document.createElement("style");
|
|
1556
|
-
this._refreshStyles();
|
|
1557
1618
|
this._menu = new CourierInboxListItemMenu(this._theme);
|
|
1558
1619
|
this._menu.setOptions(this._getMenuOptions());
|
|
1559
|
-
|
|
1620
|
+
this.append(this._unreadIndicator, contentContainer, this._timeElement, this._menu);
|
|
1560
1621
|
const cancelPropagation = (e) => {
|
|
1561
1622
|
e.stopPropagation();
|
|
1562
1623
|
e.preventDefault();
|
|
@@ -1565,7 +1626,7 @@ class CourierListItem extends BaseElement {
|
|
|
1565
1626
|
this._menu.addEventListener("pointerdown", cancelPropagation);
|
|
1566
1627
|
this._menu.addEventListener("click", cancelPropagation);
|
|
1567
1628
|
this.addEventListener("click", (e) => {
|
|
1568
|
-
if (this._menu.contains(e.target) || e.composedPath().includes(this._menu)) {
|
|
1629
|
+
if (this._menu && (this._menu.contains(e.target) || e.composedPath().includes(this._menu))) {
|
|
1569
1630
|
return;
|
|
1570
1631
|
}
|
|
1571
1632
|
if (this._message && this.onItemClick && !(e.target instanceof CourierIcon) && !this._isLongPress) {
|
|
@@ -1575,6 +1636,133 @@ class CourierListItem extends BaseElement {
|
|
|
1575
1636
|
this._setupHoverBehavior();
|
|
1576
1637
|
this._setupLongPressBehavior();
|
|
1577
1638
|
}
|
|
1639
|
+
static getStyles(theme2) {
|
|
1640
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
1641
|
+
const list = (_a = theme2.inbox) == null ? void 0 : _a.list;
|
|
1642
|
+
return `
|
|
1643
|
+
${CourierInboxListItem.id} {
|
|
1644
|
+
display: flex;
|
|
1645
|
+
flex-direction: row;
|
|
1646
|
+
align-items: flex-start;
|
|
1647
|
+
justify-content: space-between;
|
|
1648
|
+
border-bottom: ${((_b = list == null ? void 0 : list.item) == null ? void 0 : _b.divider) ?? "1px solid red"};
|
|
1649
|
+
font-family: inherit;
|
|
1650
|
+
cursor: pointer;
|
|
1651
|
+
transition: background-color 0.2s ease;
|
|
1652
|
+
margin: 0;
|
|
1653
|
+
width: 100%;
|
|
1654
|
+
box-sizing: border-box;
|
|
1655
|
+
padding: 12px 20px;
|
|
1656
|
+
position: relative;
|
|
1657
|
+
background-color: ${((_c = list == null ? void 0 : list.item) == null ? void 0 : _c.backgroundColor) ?? "transparent"};
|
|
1658
|
+
user-select: none;
|
|
1659
|
+
-webkit-user-select: none;
|
|
1660
|
+
-moz-user-select: none;
|
|
1661
|
+
-ms-user-select: none;
|
|
1662
|
+
touch-action: manipulation;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
/* Base hover / active */
|
|
1666
|
+
@media (hover: hover) {
|
|
1667
|
+
${CourierInboxListItem.id}:hover {
|
|
1668
|
+
background-color: ${((_d = list == null ? void 0 : list.item) == null ? void 0 : _d.hoverBackgroundColor) ?? "red"};
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
${CourierInboxListItem.id}:active {
|
|
1673
|
+
background-color: ${((_e = list == null ? void 0 : list.item) == null ? void 0 : _e.activeBackgroundColor) ?? "red"};
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
/* Menu hover / active */
|
|
1677
|
+
@media (hover: hover) {
|
|
1678
|
+
${CourierInboxListItem.id}:hover:has(courier-inbox-list-item-menu:hover, courier-inbox-list-item-menu *:hover, courier-button:hover, courier-button *:hover) {
|
|
1679
|
+
background-color: ${((_f = list == null ? void 0 : list.item) == null ? void 0 : _f.backgroundColor) ?? "transparent"};
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
${CourierInboxListItem.id}:active:has(courier-inbox-list-item-menu:active, courier-inbox-list-item-menu *:active, courier-button:active, courier-button *:active) {
|
|
1684
|
+
background-color: ${((_g = list == null ? void 0 : list.item) == null ? void 0 : _g.backgroundColor) ?? "transparent"};
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
${CourierInboxListItem.id}:last-child {
|
|
1688
|
+
border-bottom: none;
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
${CourierInboxListItem.id} .unread-indicator {
|
|
1692
|
+
position: absolute;
|
|
1693
|
+
top: 28px;
|
|
1694
|
+
left: 6px;
|
|
1695
|
+
width: 8px;
|
|
1696
|
+
height: 8px;
|
|
1697
|
+
border-radius: 50%;
|
|
1698
|
+
background-color: ${((_h = list == null ? void 0 : list.item) == null ? void 0 : _h.unreadIndicatorColor) ?? "red"};
|
|
1699
|
+
display: none;
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
${CourierInboxListItem.id}.unread .unread-indicator {
|
|
1703
|
+
display: block;
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
${CourierInboxListItem.id} .content-container {
|
|
1707
|
+
flex: 1;
|
|
1708
|
+
display: flex;
|
|
1709
|
+
flex-direction: column;
|
|
1710
|
+
margin-right: 12px;
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
${CourierInboxListItem.id} p {
|
|
1714
|
+
margin: 0;
|
|
1715
|
+
overflow-wrap: break-word;
|
|
1716
|
+
word-break: break-word;
|
|
1717
|
+
hyphens: auto;
|
|
1718
|
+
line-height: 1.4;
|
|
1719
|
+
user-select: none;
|
|
1720
|
+
-webkit-user-select: none;
|
|
1721
|
+
-moz-user-select: none;
|
|
1722
|
+
-ms-user-select: none;
|
|
1723
|
+
text-align: left;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
${CourierInboxListItem.id} .title {
|
|
1727
|
+
font-family: ${((_j = (_i = list == null ? void 0 : list.item) == null ? void 0 : _i.title) == null ? void 0 : _j.family) ?? "inherit"};
|
|
1728
|
+
font-size: ${((_l = (_k = list == null ? void 0 : list.item) == null ? void 0 : _k.title) == null ? void 0 : _l.size) ?? "14px"};
|
|
1729
|
+
color: ${((_n = (_m = list == null ? void 0 : list.item) == null ? void 0 : _m.title) == null ? void 0 : _n.color) ?? "red"};
|
|
1730
|
+
margin-bottom: 4px;
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
${CourierInboxListItem.id} .subtitle {
|
|
1734
|
+
font-family: ${((_p = (_o = list == null ? void 0 : list.item) == null ? void 0 : _o.subtitle) == null ? void 0 : _p.family) ?? "inherit"};
|
|
1735
|
+
font-size: ${((_r = (_q = list == null ? void 0 : list.item) == null ? void 0 : _q.subtitle) == null ? void 0 : _r.size) ?? "14px"};
|
|
1736
|
+
color: ${((_t = (_s = list == null ? void 0 : list.item) == null ? void 0 : _s.subtitle) == null ? void 0 : _t.color) ?? "red"};
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
${CourierInboxListItem.id} .time {
|
|
1740
|
+
font-family: ${((_v = (_u = list == null ? void 0 : list.item) == null ? void 0 : _u.time) == null ? void 0 : _v.family) ?? "inherit"};
|
|
1741
|
+
font-size: ${((_x = (_w = list == null ? void 0 : list.item) == null ? void 0 : _w.time) == null ? void 0 : _x.size) ?? "14px"};
|
|
1742
|
+
color: ${((_z = (_y = list == null ? void 0 : list.item) == null ? void 0 : _y.time) == null ? void 0 : _z.color) ?? "red"};
|
|
1743
|
+
text-align: right;
|
|
1744
|
+
white-space: nowrap;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
${CourierInboxListItem.id} courier-inbox-list-item-menu {
|
|
1748
|
+
z-index: 1;
|
|
1749
|
+
position: absolute;
|
|
1750
|
+
top: 8px;
|
|
1751
|
+
right: 8px;
|
|
1752
|
+
display: none;
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
${CourierInboxListItem.id} .actions-container {
|
|
1756
|
+
display: flex;
|
|
1757
|
+
margin-top: 10px;
|
|
1758
|
+
flex-wrap: wrap;
|
|
1759
|
+
flex-direction: row;
|
|
1760
|
+
align-items: center;
|
|
1761
|
+
gap: 8px;
|
|
1762
|
+
display: none;
|
|
1763
|
+
}
|
|
1764
|
+
`;
|
|
1765
|
+
}
|
|
1578
1766
|
_setupHoverBehavior() {
|
|
1579
1767
|
if (!this._isMobile) {
|
|
1580
1768
|
this.addEventListener("mouseenter", () => {
|
|
@@ -1667,7 +1855,7 @@ class CourierListItem extends BaseElement {
|
|
|
1667
1855
|
_showMenu() {
|
|
1668
1856
|
var _a, _b, _c;
|
|
1669
1857
|
const menu = (_c = (_b = (_a = this._theme.inbox) == null ? void 0 : _a.list) == null ? void 0 : _b.item) == null ? void 0 : _c.menu;
|
|
1670
|
-
if (menu && menu.enabled) {
|
|
1858
|
+
if (menu && menu.enabled && this._menu && this._timeElement) {
|
|
1671
1859
|
this._menu.setOptions(this._getMenuOptions());
|
|
1672
1860
|
this._menu.style.display = "block";
|
|
1673
1861
|
this._menu.show();
|
|
@@ -1677,259 +1865,157 @@ class CourierListItem extends BaseElement {
|
|
|
1677
1865
|
_hideMenu() {
|
|
1678
1866
|
var _a, _b, _c;
|
|
1679
1867
|
const menu = (_c = (_b = (_a = this._theme.inbox) == null ? void 0 : _a.list) == null ? void 0 : _b.item) == null ? void 0 : _c.menu;
|
|
1680
|
-
if (menu && menu.enabled) {
|
|
1868
|
+
if (menu && menu.enabled && this._menu && this._timeElement) {
|
|
1681
1869
|
this._menu.hide();
|
|
1682
1870
|
this._menu.style.display = "none";
|
|
1683
1871
|
this._timeElement.style.opacity = "1";
|
|
1684
1872
|
}
|
|
1685
1873
|
}
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1874
|
+
// Public API
|
|
1875
|
+
setMessage(message, feedType) {
|
|
1876
|
+
this._message = message;
|
|
1877
|
+
this._feedType = feedType;
|
|
1878
|
+
this._updateContent();
|
|
1879
|
+
}
|
|
1880
|
+
setOnItemClick(cb) {
|
|
1881
|
+
this.onItemClick = cb;
|
|
1882
|
+
}
|
|
1883
|
+
setOnItemActionClick(cb) {
|
|
1884
|
+
this.onItemActionClick = cb;
|
|
1885
|
+
}
|
|
1886
|
+
setOnItemLongPress(cb) {
|
|
1887
|
+
this.onItemLongPress = cb;
|
|
1888
|
+
}
|
|
1889
|
+
// Content rendering
|
|
1890
|
+
_updateContent() {
|
|
1891
|
+
var _a, _b, _c;
|
|
1892
|
+
if (!this._message) {
|
|
1893
|
+
if (this._titleElement) this._titleElement.textContent = "";
|
|
1894
|
+
if (this._subtitleElement) this._subtitleElement.textContent = "";
|
|
1895
|
+
return;
|
|
1896
|
+
}
|
|
1897
|
+
this.classList.toggle("unread", !this._message.read && this._feedType !== "archive");
|
|
1898
|
+
if (this._titleElement) {
|
|
1899
|
+
this._titleElement.textContent = this._message.title || "Untitled Message";
|
|
1900
|
+
}
|
|
1901
|
+
if (this._subtitleElement) {
|
|
1902
|
+
this._subtitleElement.textContent = this._message.preview || this._message.body || "";
|
|
1903
|
+
}
|
|
1904
|
+
if (this._timeElement) {
|
|
1905
|
+
this._timeElement.textContent = getMessageTime(this._message);
|
|
1906
|
+
}
|
|
1907
|
+
if (this._menu) {
|
|
1908
|
+
this._menu.setOptions(this._getMenuOptions());
|
|
1909
|
+
}
|
|
1910
|
+
const hasActions = this._message.actions && this._message.actions.length > 0;
|
|
1911
|
+
if (this._actionsContainer) {
|
|
1912
|
+
this._actionsContainer.style.display = hasActions ? "flex" : "none";
|
|
1913
|
+
}
|
|
1914
|
+
const actionsTheme = (_c = (_b = (_a = this._theme.inbox) == null ? void 0 : _a.list) == null ? void 0 : _b.item) == null ? void 0 : _c.actions;
|
|
1915
|
+
if (this._actionsContainer && this._message.actions) {
|
|
1916
|
+
this._message.actions.forEach((action) => {
|
|
1917
|
+
var _a2, _b2, _c2, _d, _e;
|
|
1918
|
+
const actionButton = new CourierButton({
|
|
1919
|
+
text: action.content,
|
|
1920
|
+
variant: "secondary",
|
|
1921
|
+
backgroundColor: actionsTheme == null ? void 0 : actionsTheme.backgroundColor,
|
|
1922
|
+
hoverBackgroundColor: actionsTheme == null ? void 0 : actionsTheme.hoverBackgroundColor,
|
|
1923
|
+
activeBackgroundColor: actionsTheme == null ? void 0 : actionsTheme.activeBackgroundColor,
|
|
1924
|
+
border: actionsTheme == null ? void 0 : actionsTheme.border,
|
|
1925
|
+
borderRadius: actionsTheme == null ? void 0 : actionsTheme.borderRadius,
|
|
1926
|
+
shadow: actionsTheme == null ? void 0 : actionsTheme.shadow,
|
|
1927
|
+
fontFamily: (_a2 = actionsTheme == null ? void 0 : actionsTheme.font) == null ? void 0 : _a2.family,
|
|
1928
|
+
fontSize: (_b2 = actionsTheme == null ? void 0 : actionsTheme.font) == null ? void 0 : _b2.size,
|
|
1929
|
+
fontWeight: (_c2 = actionsTheme == null ? void 0 : actionsTheme.font) == null ? void 0 : _c2.weight,
|
|
1930
|
+
textColor: (_d = actionsTheme == null ? void 0 : actionsTheme.font) == null ? void 0 : _d.color,
|
|
1931
|
+
onClick: () => {
|
|
1932
|
+
if (this._message && this.onItemActionClick) {
|
|
1933
|
+
this.onItemActionClick(this._message, action);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
});
|
|
1937
|
+
(_e = this._actionsContainer) == null ? void 0 : _e.appendChild(actionButton);
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
registerElement(CourierInboxListItem);
|
|
1943
|
+
class CourierInboxSkeletonListItem extends CourierBaseElement {
|
|
1944
|
+
constructor(theme2) {
|
|
1945
|
+
super();
|
|
1946
|
+
__publicField(this, "_theme");
|
|
1947
|
+
__publicField(this, "_style");
|
|
1948
|
+
this._theme = theme2;
|
|
1949
|
+
}
|
|
1950
|
+
static get id() {
|
|
1951
|
+
return "courier-inbox-skeleton-list-item";
|
|
1952
|
+
}
|
|
1953
|
+
onComponentMounted() {
|
|
1954
|
+
this._style = injectGlobalStyle(CourierInboxSkeletonListItem.id, CourierInboxSkeletonListItem.getStyles(this._theme));
|
|
1955
|
+
this.render();
|
|
1956
|
+
}
|
|
1957
|
+
onComponentUnmounted() {
|
|
1958
|
+
var _a;
|
|
1959
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
1960
|
+
}
|
|
1961
|
+
render() {
|
|
1962
|
+
const firstRow = new CourierSkeletonAnimatedRow(this._theme);
|
|
1963
|
+
const secondRow = new CourierSkeletonAnimatedRow(this._theme);
|
|
1964
|
+
const thirdRow = new CourierSkeletonAnimatedRow(this._theme);
|
|
1965
|
+
this.appendChild(firstRow);
|
|
1966
|
+
this.appendChild(secondRow);
|
|
1967
|
+
this.appendChild(thirdRow);
|
|
1968
|
+
}
|
|
1969
|
+
static getStyles(_theme) {
|
|
1689
1970
|
return `
|
|
1690
|
-
|
|
1971
|
+
${CourierInboxSkeletonListItem.id} {
|
|
1691
1972
|
display: flex;
|
|
1692
|
-
flex-direction:
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
border-bottom: ${(listItem == null ? void 0 : listItem.divider) ?? "1px solid red"};
|
|
1696
|
-
font-family: inherit;
|
|
1697
|
-
cursor: pointer;
|
|
1698
|
-
transition: background-color 0.2s ease;
|
|
1699
|
-
margin: 0;
|
|
1973
|
+
flex-direction: column;
|
|
1974
|
+
gap: 12px;
|
|
1975
|
+
padding: 12px;
|
|
1700
1976
|
width: 100%;
|
|
1701
1977
|
box-sizing: border-box;
|
|
1702
|
-
padding: 12px 20px;
|
|
1703
|
-
position: relative;
|
|
1704
|
-
background-color: ${(listItem == null ? void 0 : listItem.backgroundColor) ?? "transparent"};
|
|
1705
|
-
user-select: none;
|
|
1706
|
-
-webkit-user-select: none;
|
|
1707
|
-
-moz-user-select: none;
|
|
1708
|
-
-ms-user-select: none;
|
|
1709
|
-
touch-action: manipulation;
|
|
1710
1978
|
}
|
|
1711
1979
|
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
:host(:hover) {
|
|
1715
|
-
background-color: ${(listItem == null ? void 0 : listItem.hoverBackgroundColor) ?? "red"};
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
:host(:active) {
|
|
1719
|
-
background-color: ${(listItem == null ? void 0 : listItem.activeBackgroundColor) ?? "red"};
|
|
1980
|
+
${CourierInboxSkeletonListItem.id} > *:first-child {
|
|
1981
|
+
width: 35%;
|
|
1720
1982
|
}
|
|
1721
1983
|
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
:host(:hover):has(courier-inbox-list-item-menu:hover, courier-inbox-list-item-menu *:hover, courier-button:hover, courier-button *:hover) {
|
|
1725
|
-
background-color: ${(listItem == null ? void 0 : listItem.backgroundColor) ?? "transparent"};
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
:host(:active):has(courier-inbox-list-item-menu:active, courier-inbox-list-item-menu *:active, courier-button:active, courier-button *:active) {
|
|
1729
|
-
background-color: ${(listItem == null ? void 0 : listItem.backgroundColor) ?? "transparent"};
|
|
1984
|
+
${CourierInboxSkeletonListItem.id} > *:nth-child(2) {
|
|
1985
|
+
width: 100%;
|
|
1730
1986
|
}
|
|
1731
1987
|
|
|
1732
|
-
|
|
1733
|
-
|
|
1988
|
+
${CourierInboxSkeletonListItem.id} > *:nth-child(3) {
|
|
1989
|
+
width: 82%;
|
|
1734
1990
|
}
|
|
1735
|
-
|
|
1736
|
-
.unread-indicator {
|
|
1737
|
-
position: absolute;
|
|
1738
|
-
top: 28px;
|
|
1739
|
-
left: 6px;
|
|
1740
|
-
width: 8px;
|
|
1741
|
-
height: 8px;
|
|
1742
|
-
border-radius: 50%;
|
|
1743
|
-
background-color: ${(listItem == null ? void 0 : listItem.unreadIndicatorColor) ?? "red"};
|
|
1744
|
-
display: none;
|
|
1745
|
-
}
|
|
1746
|
-
|
|
1747
|
-
:host(.unread) .unread-indicator {
|
|
1748
|
-
display: block;
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
|
-
.content-container {
|
|
1752
|
-
flex: 1;
|
|
1753
|
-
display: flex;
|
|
1754
|
-
flex-direction: column;
|
|
1755
|
-
margin-right: 12px;
|
|
1756
|
-
}
|
|
1757
|
-
|
|
1758
|
-
p {
|
|
1759
|
-
margin: 0;
|
|
1760
|
-
overflow-wrap: break-word;
|
|
1761
|
-
word-break: break-word;
|
|
1762
|
-
hyphens: auto;
|
|
1763
|
-
line-height: 1.4;
|
|
1764
|
-
user-select: none;
|
|
1765
|
-
-webkit-user-select: none;
|
|
1766
|
-
-moz-user-select: none;
|
|
1767
|
-
-ms-user-select: none;
|
|
1768
|
-
text-align: left;
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
|
-
p[part='title'] {
|
|
1772
|
-
font-family: ${((_c = listItem == null ? void 0 : listItem.title) == null ? void 0 : _c.family) ?? "inherit"};
|
|
1773
|
-
font-size: ${((_d = listItem == null ? void 0 : listItem.title) == null ? void 0 : _d.size) ?? "14px"};
|
|
1774
|
-
color: ${((_e = listItem == null ? void 0 : listItem.title) == null ? void 0 : _e.color) ?? "red"};
|
|
1775
|
-
margin-bottom: 4px;
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
|
-
p[part='subtitle'] {
|
|
1779
|
-
font-family: ${((_f = listItem == null ? void 0 : listItem.subtitle) == null ? void 0 : _f.family) ?? "inherit"};
|
|
1780
|
-
font-size: ${((_g = listItem == null ? void 0 : listItem.subtitle) == null ? void 0 : _g.size) ?? "14px"};
|
|
1781
|
-
color: ${((_h = listItem == null ? void 0 : listItem.subtitle) == null ? void 0 : _h.color) ?? "red"};
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
p[part='time'] {
|
|
1785
|
-
font-family: ${((_i = listItem == null ? void 0 : listItem.time) == null ? void 0 : _i.family) ?? "inherit"};
|
|
1786
|
-
font-size: ${((_j = listItem == null ? void 0 : listItem.time) == null ? void 0 : _j.size) ?? "14px"};
|
|
1787
|
-
color: ${((_k = listItem == null ? void 0 : listItem.time) == null ? void 0 : _k.color) ?? "red"};
|
|
1788
|
-
text-align: right;
|
|
1789
|
-
white-space: nowrap;
|
|
1790
|
-
}
|
|
1791
|
-
|
|
1792
|
-
courier-inbox-list-item-menu {
|
|
1793
|
-
z-index: 1;
|
|
1794
|
-
position: absolute;
|
|
1795
|
-
top: 8px;
|
|
1796
|
-
right: 8px;
|
|
1797
|
-
display: none; /* becomes block while visible */
|
|
1798
|
-
}
|
|
1799
|
-
|
|
1800
|
-
.actions-container {
|
|
1801
|
-
display: flex;
|
|
1802
|
-
margin-top: 10px;
|
|
1803
|
-
flex-wrap: wrap;
|
|
1804
|
-
flex-direction: row;
|
|
1805
|
-
align-items: center;
|
|
1806
|
-
gap: 8px;
|
|
1807
|
-
display: none;
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
1991
|
`;
|
|
1811
1992
|
}
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
if (feedTypeAttr) {
|
|
1821
|
-
this._feedType = feedTypeAttr;
|
|
1822
|
-
}
|
|
1823
|
-
if (messageAttr) {
|
|
1824
|
-
try {
|
|
1825
|
-
this._message = JSON.parse(messageAttr);
|
|
1826
|
-
this._updateContent();
|
|
1827
|
-
} catch (err) {
|
|
1828
|
-
(_b = (_a = Courier.shared.client) == null ? void 0 : _a.options.logger) == null ? void 0 : _b.error("CourierListItem – failed to parse message:", err);
|
|
1829
|
-
}
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
// Public API
|
|
1833
|
-
setMessage(message, feedType) {
|
|
1834
|
-
this._message = message;
|
|
1835
|
-
this._feedType = feedType;
|
|
1836
|
-
this._updateContent();
|
|
1837
|
-
}
|
|
1838
|
-
setOnItemClick(cb) {
|
|
1839
|
-
this.onItemClick = cb;
|
|
1993
|
+
}
|
|
1994
|
+
registerElement(CourierInboxSkeletonListItem);
|
|
1995
|
+
class CourierSkeletonAnimatedRow extends CourierBaseElement {
|
|
1996
|
+
constructor(theme2) {
|
|
1997
|
+
super();
|
|
1998
|
+
__publicField(this, "_theme");
|
|
1999
|
+
__publicField(this, "_style");
|
|
2000
|
+
this._theme = theme2;
|
|
1840
2001
|
}
|
|
1841
|
-
|
|
1842
|
-
|
|
2002
|
+
static get id() {
|
|
2003
|
+
return "courier-skeleton-animated-row";
|
|
1843
2004
|
}
|
|
1844
|
-
|
|
1845
|
-
this.
|
|
1846
|
-
|
|
1847
|
-
// Content rendering
|
|
1848
|
-
_updateContent() {
|
|
1849
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1850
|
-
if (!this._message) {
|
|
1851
|
-
this._titleElement.textContent = "";
|
|
1852
|
-
this._subtitleElement.textContent = "";
|
|
1853
|
-
return;
|
|
1854
|
-
}
|
|
1855
|
-
this.classList.toggle("unread", !this._message.read && this._feedType !== "archive");
|
|
1856
|
-
this._titleElement.textContent = this._message.title || "Untitled Message";
|
|
1857
|
-
this._subtitleElement.textContent = this._message.preview || this._message.body || "";
|
|
1858
|
-
this._timeElement.textContent = getMessageTime(this._message);
|
|
1859
|
-
this._menu.setOptions(this._getMenuOptions());
|
|
1860
|
-
const hasActions = ((_a = this._message) == null ? void 0 : _a.actions) && this._message.actions.length > 0;
|
|
1861
|
-
this._actionsContainer.style.display = hasActions ? "flex" : "none";
|
|
1862
|
-
const actionsTheme = (_d = (_c = (_b = this._theme.inbox) == null ? void 0 : _b.list) == null ? void 0 : _c.item) == null ? void 0 : _d.actions;
|
|
1863
|
-
(_f = (_e = this._message) == null ? void 0 : _e.actions) == null ? void 0 : _f.forEach((action) => {
|
|
1864
|
-
var _a2, _b2, _c2, _d2;
|
|
1865
|
-
const actionButton = new CourierButton({
|
|
1866
|
-
text: action.content,
|
|
1867
|
-
variant: "secondary",
|
|
1868
|
-
backgroundColor: actionsTheme == null ? void 0 : actionsTheme.backgroundColor,
|
|
1869
|
-
hoverBackgroundColor: actionsTheme == null ? void 0 : actionsTheme.hoverBackgroundColor,
|
|
1870
|
-
activeBackgroundColor: actionsTheme == null ? void 0 : actionsTheme.activeBackgroundColor,
|
|
1871
|
-
border: actionsTheme == null ? void 0 : actionsTheme.border,
|
|
1872
|
-
borderRadius: actionsTheme == null ? void 0 : actionsTheme.borderRadius,
|
|
1873
|
-
shadow: actionsTheme == null ? void 0 : actionsTheme.shadow,
|
|
1874
|
-
fontFamily: (_a2 = actionsTheme == null ? void 0 : actionsTheme.font) == null ? void 0 : _a2.family,
|
|
1875
|
-
fontSize: (_b2 = actionsTheme == null ? void 0 : actionsTheme.font) == null ? void 0 : _b2.size,
|
|
1876
|
-
fontWeight: (_c2 = actionsTheme == null ? void 0 : actionsTheme.font) == null ? void 0 : _c2.weight,
|
|
1877
|
-
textColor: (_d2 = actionsTheme == null ? void 0 : actionsTheme.font) == null ? void 0 : _d2.color,
|
|
1878
|
-
onClick: () => {
|
|
1879
|
-
if (this._message && this.onItemActionClick) {
|
|
1880
|
-
this.onItemActionClick(this._message, action);
|
|
1881
|
-
}
|
|
1882
|
-
}
|
|
1883
|
-
});
|
|
1884
|
-
this._actionsContainer.appendChild(actionButton);
|
|
1885
|
-
});
|
|
2005
|
+
onComponentMounted() {
|
|
2006
|
+
this._style = injectGlobalStyle(CourierSkeletonAnimatedRow.id, CourierSkeletonAnimatedRow.getStyles(this._theme));
|
|
2007
|
+
this.render();
|
|
1886
2008
|
}
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
constructor(theme2, opacity) {
|
|
1891
|
-
super();
|
|
1892
|
-
// Shadow root
|
|
1893
|
-
__publicField(this, "_shadow");
|
|
1894
|
-
this._shadow = this.attachShadow({ mode: "open" });
|
|
1895
|
-
const style = document.createElement("style");
|
|
1896
|
-
style.textContent = this.getStyles(opacity);
|
|
1897
|
-
this._shadow.appendChild(style);
|
|
1898
|
-
const firstRow = new CourierSkeletonAnimatedRow(theme2, 35);
|
|
1899
|
-
const secondRow = new CourierSkeletonAnimatedRow(theme2, 100);
|
|
1900
|
-
const thirdRow = new CourierSkeletonAnimatedRow(theme2, 82);
|
|
1901
|
-
this._shadow.appendChild(firstRow);
|
|
1902
|
-
this._shadow.appendChild(secondRow);
|
|
1903
|
-
this._shadow.appendChild(thirdRow);
|
|
1904
|
-
}
|
|
1905
|
-
getStyles(opacity) {
|
|
1906
|
-
return `
|
|
1907
|
-
:host {
|
|
1908
|
-
display: flex;
|
|
1909
|
-
flex-direction: column;
|
|
1910
|
-
gap: 12px;
|
|
1911
|
-
padding: 12px;
|
|
1912
|
-
width: 100%;
|
|
1913
|
-
box-sizing: border-box;
|
|
1914
|
-
opacity: ${opacity};
|
|
1915
|
-
}
|
|
1916
|
-
`;
|
|
2009
|
+
onComponentUnmounted() {
|
|
2010
|
+
var _a;
|
|
2011
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
1917
2012
|
}
|
|
1918
|
-
|
|
1919
|
-
registerElement("courier-inbox-skeleton-list-item", CourierInboxSkeletonListItem);
|
|
1920
|
-
class CourierSkeletonAnimatedRow extends BaseElement {
|
|
1921
|
-
constructor(theme2, widthPercent) {
|
|
1922
|
-
super();
|
|
1923
|
-
__publicField(this, "_shadow");
|
|
1924
|
-
this._shadow = this.attachShadow({ mode: "open" });
|
|
1925
|
-
const style = document.createElement("style");
|
|
1926
|
-
style.textContent = this.getStyles(theme2, widthPercent);
|
|
1927
|
-
this._shadow.appendChild(style);
|
|
2013
|
+
render() {
|
|
1928
2014
|
const skeletonItem = document.createElement("div");
|
|
1929
2015
|
skeletonItem.className = "skeleton-item";
|
|
1930
|
-
this.
|
|
2016
|
+
this.appendChild(skeletonItem);
|
|
1931
2017
|
}
|
|
1932
|
-
getStyles(theme2
|
|
2018
|
+
static getStyles(theme2) {
|
|
1933
2019
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1934
2020
|
const color = ((_c = (_b = (_a = theme2.inbox) == null ? void 0 : _a.loading) == null ? void 0 : _b.animation) == null ? void 0 : _c.barColor) ?? "#000";
|
|
1935
2021
|
const hexColor = color.length === 4 ? `#${color[1]}${color[1]}${color[2]}${color[2]}${color[3]}${color[3]}` : color;
|
|
@@ -1939,15 +2025,15 @@ class CourierSkeletonAnimatedRow extends BaseElement {
|
|
|
1939
2025
|
const colorWithAlpha80 = `rgba(${r}, ${g}, ${b}, 0.8)`;
|
|
1940
2026
|
const colorWithAlpha40 = `rgba(${r}, ${g}, ${b}, 0.4)`;
|
|
1941
2027
|
return `
|
|
1942
|
-
|
|
2028
|
+
${CourierSkeletonAnimatedRow.id} {
|
|
1943
2029
|
display: flex;
|
|
1944
2030
|
height: 100%;
|
|
1945
|
-
width:
|
|
2031
|
+
width: 100%;
|
|
1946
2032
|
align-items: flex-start;
|
|
1947
2033
|
justify-content: flex-start;
|
|
1948
2034
|
}
|
|
1949
2035
|
|
|
1950
|
-
.skeleton-item {
|
|
2036
|
+
${CourierSkeletonAnimatedRow.id} .skeleton-item {
|
|
1951
2037
|
height: ${((_f = (_e = (_d = theme2.inbox) == null ? void 0 : _d.loading) == null ? void 0 : _e.animation) == null ? void 0 : _f.barHeight) ?? "14px"};
|
|
1952
2038
|
width: 100%;
|
|
1953
2039
|
background: linear-gradient(
|
|
@@ -1957,11 +2043,11 @@ class CourierSkeletonAnimatedRow extends BaseElement {
|
|
|
1957
2043
|
${colorWithAlpha80} 75%
|
|
1958
2044
|
);
|
|
1959
2045
|
background-size: 200% 100%;
|
|
1960
|
-
animation: shimmer ${((_i = (_h = (_g = theme2.inbox) == null ? void 0 : _g.loading) == null ? void 0 : _h.animation) == null ? void 0 : _i.duration) ?? "2s"} ease-in-out infinite;
|
|
2046
|
+
animation: ${CourierSkeletonAnimatedRow.id}-shimmer ${((_i = (_h = (_g = theme2.inbox) == null ? void 0 : _g.loading) == null ? void 0 : _h.animation) == null ? void 0 : _i.duration) ?? "2s"} ease-in-out infinite;
|
|
1961
2047
|
border-radius: ${((_l = (_k = (_j = theme2.inbox) == null ? void 0 : _j.loading) == null ? void 0 : _k.animation) == null ? void 0 : _l.barBorderRadius) ?? "14px"};
|
|
1962
2048
|
}
|
|
1963
2049
|
|
|
1964
|
-
@keyframes shimmer {
|
|
2050
|
+
@keyframes ${CourierSkeletonAnimatedRow.id}-shimmer {
|
|
1965
2051
|
0% {
|
|
1966
2052
|
background-position: 200% 0;
|
|
1967
2053
|
}
|
|
@@ -1972,30 +2058,38 @@ class CourierSkeletonAnimatedRow extends BaseElement {
|
|
|
1972
2058
|
`;
|
|
1973
2059
|
}
|
|
1974
2060
|
}
|
|
1975
|
-
registerElement(
|
|
1976
|
-
class CourierInboxSkeletonList extends
|
|
2061
|
+
registerElement(CourierSkeletonAnimatedRow);
|
|
2062
|
+
class CourierInboxSkeletonList extends CourierFactoryElement {
|
|
1977
2063
|
constructor(theme2) {
|
|
1978
2064
|
super();
|
|
1979
2065
|
__publicField(this, "_theme");
|
|
2066
|
+
__publicField(this, "_style");
|
|
1980
2067
|
this._theme = theme2;
|
|
1981
2068
|
}
|
|
2069
|
+
static get id() {
|
|
2070
|
+
return "courier-inbox-skeleton-list";
|
|
2071
|
+
}
|
|
2072
|
+
onComponentMounted() {
|
|
2073
|
+
this._style = injectGlobalStyle(CourierInboxSkeletonList.id, CourierInboxSkeletonList.getStyles(this._theme));
|
|
2074
|
+
}
|
|
2075
|
+
onComponentUnmounted() {
|
|
2076
|
+
var _a;
|
|
2077
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
2078
|
+
}
|
|
1982
2079
|
defaultElement() {
|
|
1983
2080
|
const list = document.createElement("div");
|
|
1984
2081
|
list.className = "list";
|
|
1985
|
-
const style = document.createElement("style");
|
|
1986
|
-
style.textContent = this.getStyles();
|
|
1987
|
-
list.appendChild(style);
|
|
1988
2082
|
for (let i = 0; i < 3; i++) {
|
|
1989
|
-
const skeletonItem = new CourierInboxSkeletonListItem(this._theme
|
|
2083
|
+
const skeletonItem = new CourierInboxSkeletonListItem(this._theme);
|
|
1990
2084
|
list.appendChild(skeletonItem);
|
|
1991
2085
|
}
|
|
1992
|
-
this.
|
|
2086
|
+
this.appendChild(list);
|
|
1993
2087
|
return list;
|
|
1994
2088
|
}
|
|
1995
|
-
getStyles() {
|
|
1996
|
-
var _a, _b;
|
|
2089
|
+
static getStyles(theme2) {
|
|
2090
|
+
var _a, _b, _c, _d;
|
|
1997
2091
|
return `
|
|
1998
|
-
|
|
2092
|
+
${CourierInboxSkeletonList.id} {
|
|
1999
2093
|
display: flex;
|
|
2000
2094
|
height: 100%;
|
|
2001
2095
|
width: 100%;
|
|
@@ -2004,78 +2098,92 @@ class CourierInboxSkeletonList extends CourierElement {
|
|
|
2004
2098
|
overflow: hidden;
|
|
2005
2099
|
}
|
|
2006
2100
|
|
|
2007
|
-
.list {
|
|
2101
|
+
${CourierInboxSkeletonList.id} .list {
|
|
2008
2102
|
display: flex;
|
|
2009
2103
|
flex-direction: column;
|
|
2010
|
-
gap: 8px;
|
|
2011
2104
|
width: 100%;
|
|
2012
2105
|
overflow: hidden;
|
|
2013
2106
|
}
|
|
2014
2107
|
|
|
2015
|
-
.list > * {
|
|
2016
|
-
border-bottom: ${((_b = (_a =
|
|
2108
|
+
${CourierInboxSkeletonList.id} .list > * {
|
|
2109
|
+
border-bottom: ${((_b = (_a = theme2.inbox) == null ? void 0 : _a.loading) == null ? void 0 : _b.divider) ?? "1px solid red"};
|
|
2110
|
+
opacity: 100%;
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
${CourierInboxSkeletonList.id} .list > *:nth-child(2) {
|
|
2114
|
+
border-bottom: ${((_d = (_c = theme2.inbox) == null ? void 0 : _c.loading) == null ? void 0 : _d.divider) ?? "1px solid red"};
|
|
2115
|
+
opacity: 88%;
|
|
2017
2116
|
}
|
|
2018
2117
|
|
|
2019
|
-
.list > *:
|
|
2118
|
+
${CourierInboxSkeletonList.id} .list > *:nth-child(3) {
|
|
2020
2119
|
border-bottom: none;
|
|
2120
|
+
opacity: 50%;
|
|
2021
2121
|
}
|
|
2022
2122
|
`;
|
|
2023
2123
|
}
|
|
2024
2124
|
}
|
|
2025
|
-
registerElement(
|
|
2026
|
-
class CourierInboxPaginationListItem extends
|
|
2125
|
+
registerElement(CourierInboxSkeletonList);
|
|
2126
|
+
class CourierInboxPaginationListItem extends CourierBaseElement {
|
|
2027
2127
|
constructor(props) {
|
|
2028
2128
|
super();
|
|
2129
|
+
// State
|
|
2130
|
+
__publicField(this, "_theme");
|
|
2029
2131
|
// Components
|
|
2030
|
-
__publicField(this, "
|
|
2031
|
-
__publicField(this, "
|
|
2032
|
-
__publicField(this, "
|
|
2132
|
+
__publicField(this, "_style");
|
|
2133
|
+
__publicField(this, "_skeletonLoadingList");
|
|
2134
|
+
__publicField(this, "_observer");
|
|
2135
|
+
__publicField(this, "_customItem");
|
|
2033
2136
|
// Handlers
|
|
2034
|
-
__publicField(this, "
|
|
2035
|
-
this.
|
|
2036
|
-
this.
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2137
|
+
__publicField(this, "_onPaginationTrigger");
|
|
2138
|
+
this._theme = props.theme;
|
|
2139
|
+
this._customItem = props.customItem;
|
|
2140
|
+
this._onPaginationTrigger = props.onPaginationTrigger;
|
|
2141
|
+
}
|
|
2142
|
+
static get id() {
|
|
2143
|
+
return "courier-inbox-pagination-list-item";
|
|
2144
|
+
}
|
|
2145
|
+
onComponentMounted() {
|
|
2146
|
+
this._style = injectGlobalStyle(CourierInboxPaginationListItem.id, CourierInboxPaginationListItem.getStyles(this._theme));
|
|
2147
|
+
if (this._customItem) {
|
|
2148
|
+
this.appendChild(this._customItem);
|
|
2043
2149
|
} else {
|
|
2044
2150
|
const container = document.createElement("div");
|
|
2045
2151
|
container.className = "skeleton-container";
|
|
2046
|
-
this.
|
|
2047
|
-
this.
|
|
2048
|
-
container.appendChild(this.
|
|
2049
|
-
|
|
2152
|
+
this._skeletonLoadingList = new CourierInboxSkeletonList(this._theme);
|
|
2153
|
+
this._skeletonLoadingList.build(void 0);
|
|
2154
|
+
container.appendChild(this._skeletonLoadingList);
|
|
2155
|
+
this.appendChild(container);
|
|
2050
2156
|
}
|
|
2051
|
-
this.
|
|
2157
|
+
this._observer = new IntersectionObserver((entries) => {
|
|
2052
2158
|
entries.forEach((entry) => {
|
|
2053
2159
|
if (entry.isIntersecting) {
|
|
2054
|
-
this.
|
|
2160
|
+
this._onPaginationTrigger();
|
|
2055
2161
|
}
|
|
2056
2162
|
});
|
|
2057
2163
|
});
|
|
2058
|
-
this.
|
|
2164
|
+
this._observer.observe(this);
|
|
2059
2165
|
}
|
|
2060
|
-
|
|
2166
|
+
onComponentUnmounted() {
|
|
2167
|
+
var _a, _b;
|
|
2168
|
+
(_a = this._observer) == null ? void 0 : _a.disconnect();
|
|
2169
|
+
(_b = this._style) == null ? void 0 : _b.remove();
|
|
2170
|
+
}
|
|
2171
|
+
static getStyles(_theme) {
|
|
2061
2172
|
return `
|
|
2062
|
-
|
|
2173
|
+
${CourierInboxPaginationListItem.id} {
|
|
2063
2174
|
padding: 0;
|
|
2064
2175
|
margin: 0;
|
|
2065
2176
|
box-sizing: border-box;
|
|
2066
2177
|
}
|
|
2067
2178
|
|
|
2068
|
-
.skeleton-container {
|
|
2179
|
+
${CourierInboxPaginationListItem.id} .skeleton-container {
|
|
2069
2180
|
height: 150%;
|
|
2070
2181
|
}
|
|
2071
2182
|
`;
|
|
2072
2183
|
}
|
|
2073
|
-
disconnectedCallback() {
|
|
2074
|
-
this.observer.disconnect();
|
|
2075
|
-
}
|
|
2076
2184
|
}
|
|
2077
|
-
registerElement(
|
|
2078
|
-
class CourierInboxList extends
|
|
2185
|
+
registerElement(CourierInboxPaginationListItem);
|
|
2186
|
+
class CourierInboxList extends CourierBaseElement {
|
|
2079
2187
|
constructor(props) {
|
|
2080
2188
|
super();
|
|
2081
2189
|
// Theme
|
|
@@ -2098,34 +2206,53 @@ class CourierInboxList extends BaseElement {
|
|
|
2098
2206
|
__publicField(this, "_loadingStateFactory");
|
|
2099
2207
|
__publicField(this, "_emptyStateFactory");
|
|
2100
2208
|
__publicField(this, "_errorStateFactory");
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2209
|
+
// Components
|
|
2210
|
+
__publicField(this, "_listStyles");
|
|
2211
|
+
__publicField(this, "_listItemStyles");
|
|
2212
|
+
__publicField(this, "_listItemMenuStyles");
|
|
2104
2213
|
this._onRefresh = props.onRefresh;
|
|
2105
2214
|
this._onPaginationTrigger = props.onPaginationTrigger;
|
|
2106
2215
|
this._onMessageClick = props.onMessageClick;
|
|
2107
2216
|
this._onMessageActionClick = props.onMessageActionClick;
|
|
2108
2217
|
this._onMessageLongPress = props.onMessageLongPress;
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2218
|
+
this._themeSubscription = props.themeManager.subscribe((_) => {
|
|
2219
|
+
this.render();
|
|
2220
|
+
});
|
|
2221
|
+
}
|
|
2222
|
+
static get id() {
|
|
2223
|
+
return "courier-inbox-list";
|
|
2113
2224
|
}
|
|
2114
2225
|
// Getters
|
|
2115
2226
|
get messages() {
|
|
2116
2227
|
return this._messages;
|
|
2117
2228
|
}
|
|
2118
|
-
|
|
2229
|
+
get theme() {
|
|
2230
|
+
return this._themeSubscription.manager.getTheme();
|
|
2231
|
+
}
|
|
2232
|
+
onComponentMounted() {
|
|
2233
|
+
this._listStyles = injectGlobalStyle(CourierInboxList.id, CourierInboxList.getStyles(this.theme));
|
|
2234
|
+
this._listItemStyles = injectGlobalStyle(CourierInboxListItem.id, CourierInboxListItem.getStyles(this.theme));
|
|
2235
|
+
this._listItemMenuStyles = injectGlobalStyle(CourierInboxListItemMenu.id, CourierInboxListItemMenu.getStyles(this.theme));
|
|
2236
|
+
this.render();
|
|
2237
|
+
}
|
|
2238
|
+
onComponentUnmounted() {
|
|
2239
|
+
var _a, _b, _c;
|
|
2240
|
+
this._themeSubscription.unsubscribe();
|
|
2241
|
+
(_a = this._listStyles) == null ? void 0 : _a.remove();
|
|
2242
|
+
(_b = this._listItemStyles) == null ? void 0 : _b.remove();
|
|
2243
|
+
(_c = this._listItemMenuStyles) == null ? void 0 : _c.remove();
|
|
2244
|
+
}
|
|
2245
|
+
static getStyles(theme2) {
|
|
2119
2246
|
var _a;
|
|
2120
|
-
const list = (_a =
|
|
2247
|
+
const list = (_a = theme2.inbox) == null ? void 0 : _a.list;
|
|
2121
2248
|
return `
|
|
2122
|
-
|
|
2249
|
+
${CourierInboxList.id} {
|
|
2123
2250
|
flex: 1;
|
|
2124
2251
|
width: 100%;
|
|
2125
|
-
background-color: ${(list == null ? void 0 : list.backgroundColor) ??
|
|
2252
|
+
background-color: ${(list == null ? void 0 : list.backgroundColor) ?? "red"};
|
|
2126
2253
|
}
|
|
2127
2254
|
|
|
2128
|
-
ul {
|
|
2255
|
+
${CourierInboxList.id} ul {
|
|
2129
2256
|
list-style: none;
|
|
2130
2257
|
padding: 0;
|
|
2131
2258
|
margin: 0;
|
|
@@ -2133,15 +2260,6 @@ class CourierInboxList extends BaseElement {
|
|
|
2133
2260
|
}
|
|
2134
2261
|
`;
|
|
2135
2262
|
}
|
|
2136
|
-
reset() {
|
|
2137
|
-
var _a, _b;
|
|
2138
|
-
while ((_a = this.shadowRoot) == null ? void 0 : _a.firstChild) {
|
|
2139
|
-
this.shadowRoot.removeChild(this.shadowRoot.firstChild);
|
|
2140
|
-
}
|
|
2141
|
-
const style = document.createElement("style");
|
|
2142
|
-
style.textContent = this.getStyles();
|
|
2143
|
-
(_b = this.shadowRoot) == null ? void 0 : _b.appendChild(style);
|
|
2144
|
-
}
|
|
2145
2263
|
setDataSet(dataSet) {
|
|
2146
2264
|
this._messages = [...dataSet.messages];
|
|
2147
2265
|
this._canPaginate = Boolean(dataSet.canPaginate);
|
|
@@ -2195,11 +2313,21 @@ class CourierInboxList extends BaseElement {
|
|
|
2195
2313
|
this._onRefresh();
|
|
2196
2314
|
}
|
|
2197
2315
|
render() {
|
|
2198
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _
|
|
2199
|
-
this.
|
|
2200
|
-
|
|
2316
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$;
|
|
2317
|
+
while (this.firstChild) {
|
|
2318
|
+
this.removeChild(this.firstChild);
|
|
2319
|
+
}
|
|
2320
|
+
if (this._listStyles) {
|
|
2321
|
+
this._listStyles.textContent = CourierInboxList.getStyles(this.theme);
|
|
2322
|
+
}
|
|
2323
|
+
if (this._listItemStyles) {
|
|
2324
|
+
this._listItemStyles.textContent = CourierInboxListItem.getStyles(this.theme);
|
|
2325
|
+
}
|
|
2326
|
+
if (this._listItemMenuStyles) {
|
|
2327
|
+
this._listItemMenuStyles.textContent = CourierInboxListItemMenu.getStyles(this.theme);
|
|
2328
|
+
}
|
|
2201
2329
|
if (this._error) {
|
|
2202
|
-
const error = (_a =
|
|
2330
|
+
const error = (_a = this.theme.inbox) == null ? void 0 : _a.error;
|
|
2203
2331
|
const errorElement = new CourierInfoState({
|
|
2204
2332
|
title: {
|
|
2205
2333
|
text: ((_b = error == null ? void 0 : error.title) == null ? void 0 : _b.text) ?? this._error.message,
|
|
@@ -2219,57 +2347,57 @@ class CourierInboxList extends BaseElement {
|
|
|
2219
2347
|
fontWeight: (_v = (_u = error == null ? void 0 : error.button) == null ? void 0 : _u.font) == null ? void 0 : _v.weight,
|
|
2220
2348
|
shadow: (_w = error == null ? void 0 : error.button) == null ? void 0 : _w.shadow,
|
|
2221
2349
|
border: (_x = error == null ? void 0 : error.button) == null ? void 0 : _x.border,
|
|
2222
|
-
borderRadius: (_y = error == null ? void 0 : error.button) == null ? void 0 : _y.borderRadius
|
|
2350
|
+
borderRadius: (_y = error == null ? void 0 : error.button) == null ? void 0 : _y.borderRadius,
|
|
2351
|
+
onClick: () => this.handleRetry()
|
|
2223
2352
|
}
|
|
2224
2353
|
});
|
|
2225
2354
|
errorElement.build((_z = this._errorStateFactory) == null ? void 0 : _z.call(this, { feedType: this._feedType, error: this._error }));
|
|
2226
|
-
|
|
2227
|
-
(_A = this.shadowRoot) == null ? void 0 : _A.appendChild(errorElement);
|
|
2355
|
+
this.appendChild(errorElement);
|
|
2228
2356
|
return;
|
|
2229
2357
|
}
|
|
2230
2358
|
if (this._isLoading) {
|
|
2231
|
-
const loadingElement = new CourierInboxSkeletonList(
|
|
2232
|
-
loadingElement.build((
|
|
2233
|
-
|
|
2359
|
+
const loadingElement = new CourierInboxSkeletonList(this.theme);
|
|
2360
|
+
loadingElement.build((_A = this._loadingStateFactory) == null ? void 0 : _A.call(this, { feedType: this._feedType }));
|
|
2361
|
+
this.appendChild(loadingElement);
|
|
2234
2362
|
return;
|
|
2235
2363
|
}
|
|
2236
2364
|
if (this._messages.length === 0) {
|
|
2237
|
-
const empty = (
|
|
2365
|
+
const empty = (_B = this.theme.inbox) == null ? void 0 : _B.empty;
|
|
2238
2366
|
const emptyElement = new CourierInfoState({
|
|
2239
2367
|
title: {
|
|
2240
|
-
text: ((
|
|
2241
|
-
textColor: (
|
|
2242
|
-
fontFamily: (
|
|
2243
|
-
fontSize: (
|
|
2244
|
-
fontWeight: (
|
|
2368
|
+
text: ((_C = empty == null ? void 0 : empty.title) == null ? void 0 : _C.text) ?? `No ${this._feedType} messages yet`,
|
|
2369
|
+
textColor: (_E = (_D = empty == null ? void 0 : empty.title) == null ? void 0 : _D.font) == null ? void 0 : _E.color,
|
|
2370
|
+
fontFamily: (_G = (_F = empty == null ? void 0 : empty.title) == null ? void 0 : _F.font) == null ? void 0 : _G.family,
|
|
2371
|
+
fontSize: (_I = (_H = empty == null ? void 0 : empty.title) == null ? void 0 : _H.font) == null ? void 0 : _I.size,
|
|
2372
|
+
fontWeight: (_K = (_J = empty == null ? void 0 : empty.title) == null ? void 0 : _J.font) == null ? void 0 : _K.weight
|
|
2245
2373
|
},
|
|
2246
2374
|
button: {
|
|
2247
|
-
text: (
|
|
2248
|
-
backgroundColor: (
|
|
2249
|
-
hoverBackgroundColor: (
|
|
2250
|
-
activeBackgroundColor: (
|
|
2251
|
-
textColor: (
|
|
2252
|
-
fontFamily: (
|
|
2253
|
-
fontSize: (
|
|
2254
|
-
fontWeight: (
|
|
2255
|
-
shadow: (
|
|
2256
|
-
border: (
|
|
2257
|
-
borderRadius: (
|
|
2375
|
+
text: (_L = empty == null ? void 0 : empty.button) == null ? void 0 : _L.text,
|
|
2376
|
+
backgroundColor: (_M = empty == null ? void 0 : empty.button) == null ? void 0 : _M.backgroundColor,
|
|
2377
|
+
hoverBackgroundColor: (_N = empty == null ? void 0 : empty.button) == null ? void 0 : _N.hoverBackgroundColor,
|
|
2378
|
+
activeBackgroundColor: (_O = empty == null ? void 0 : empty.button) == null ? void 0 : _O.activeBackgroundColor,
|
|
2379
|
+
textColor: (_Q = (_P = empty == null ? void 0 : empty.button) == null ? void 0 : _P.font) == null ? void 0 : _Q.color,
|
|
2380
|
+
fontFamily: (_S = (_R = empty == null ? void 0 : empty.button) == null ? void 0 : _R.font) == null ? void 0 : _S.family,
|
|
2381
|
+
fontSize: (_U = (_T = empty == null ? void 0 : empty.button) == null ? void 0 : _T.font) == null ? void 0 : _U.size,
|
|
2382
|
+
fontWeight: (_W = (_V = empty == null ? void 0 : empty.button) == null ? void 0 : _V.font) == null ? void 0 : _W.weight,
|
|
2383
|
+
shadow: (_X = empty == null ? void 0 : empty.button) == null ? void 0 : _X.shadow,
|
|
2384
|
+
border: (_Y = empty == null ? void 0 : empty.button) == null ? void 0 : _Y.border,
|
|
2385
|
+
borderRadius: (_Z = empty == null ? void 0 : empty.button) == null ? void 0 : _Z.borderRadius,
|
|
2386
|
+
onClick: () => this.handleRefresh()
|
|
2258
2387
|
}
|
|
2259
2388
|
});
|
|
2260
|
-
emptyElement.build((
|
|
2261
|
-
|
|
2262
|
-
(_ba = this.shadowRoot) == null ? void 0 : _ba.appendChild(emptyElement);
|
|
2389
|
+
emptyElement.build((__ = this._emptyStateFactory) == null ? void 0 : __.call(this, { feedType: this._feedType }));
|
|
2390
|
+
this.appendChild(emptyElement);
|
|
2263
2391
|
return;
|
|
2264
2392
|
}
|
|
2265
2393
|
const list = document.createElement("ul");
|
|
2266
|
-
|
|
2394
|
+
this.appendChild(list);
|
|
2267
2395
|
this._messages.forEach((message, index) => {
|
|
2268
2396
|
if (this._listItemFactory) {
|
|
2269
2397
|
list.appendChild(this._listItemFactory({ message, index }));
|
|
2270
2398
|
return;
|
|
2271
2399
|
}
|
|
2272
|
-
const listItem = new
|
|
2400
|
+
const listItem = new CourierInboxListItem(this.theme);
|
|
2273
2401
|
listItem.setMessage(message, this._feedType);
|
|
2274
2402
|
listItem.setOnItemClick((message2) => {
|
|
2275
2403
|
var _a2;
|
|
@@ -2287,8 +2415,8 @@ class CourierInboxList extends BaseElement {
|
|
|
2287
2415
|
});
|
|
2288
2416
|
if (this._canPaginate) {
|
|
2289
2417
|
const paginationItem = new CourierInboxPaginationListItem({
|
|
2290
|
-
theme:
|
|
2291
|
-
customItem: (
|
|
2418
|
+
theme: this.theme,
|
|
2419
|
+
customItem: (_$ = this._paginationItemFactory) == null ? void 0 : _$.call(this, { feedType: this._feedType }),
|
|
2292
2420
|
onPaginationTrigger: () => {
|
|
2293
2421
|
var _a2;
|
|
2294
2422
|
return (_a2 = this._onPaginationTrigger) == null ? void 0 : _a2.call(this, this._feedType);
|
|
@@ -2318,34 +2446,28 @@ class CourierInboxList extends BaseElement {
|
|
|
2318
2446
|
this._paginationItemFactory = factory;
|
|
2319
2447
|
this.render();
|
|
2320
2448
|
}
|
|
2321
|
-
refreshTheme() {
|
|
2322
|
-
this.render();
|
|
2323
|
-
}
|
|
2324
|
-
// Disconnect the theme subscription
|
|
2325
|
-
disconnectedCallback() {
|
|
2326
|
-
this._themeSubscription.unsubscribe();
|
|
2327
|
-
}
|
|
2328
2449
|
}
|
|
2329
|
-
registerElement(
|
|
2330
|
-
class CourierInboxOptionMenuItem extends
|
|
2450
|
+
registerElement(CourierInboxList);
|
|
2451
|
+
class CourierInboxOptionMenuItem extends CourierBaseElement {
|
|
2331
2452
|
constructor(props) {
|
|
2332
2453
|
super();
|
|
2333
2454
|
// State
|
|
2334
2455
|
__publicField(this, "_option");
|
|
2456
|
+
__publicField(this, "_isSelectedable");
|
|
2335
2457
|
__publicField(this, "_isSelected");
|
|
2336
2458
|
// Components
|
|
2337
2459
|
__publicField(this, "_content");
|
|
2338
2460
|
__publicField(this, "_itemIcon");
|
|
2339
2461
|
__publicField(this, "_title");
|
|
2340
2462
|
__publicField(this, "_selectionIcon");
|
|
2341
|
-
__publicField(this, "_style");
|
|
2342
|
-
// Theme
|
|
2343
|
-
__publicField(this, "_themeManager");
|
|
2344
2463
|
this._option = props.option;
|
|
2345
2464
|
this._isSelected = props.isSelected;
|
|
2346
|
-
this.
|
|
2347
|
-
|
|
2348
|
-
|
|
2465
|
+
this._isSelectedable = props.selectable;
|
|
2466
|
+
}
|
|
2467
|
+
static get id() {
|
|
2468
|
+
return "courier-inbox-option-menu-item";
|
|
2469
|
+
}
|
|
2470
|
+
onComponentMounted() {
|
|
2349
2471
|
this._content = document.createElement("div");
|
|
2350
2472
|
this._content.className = "menu-item";
|
|
2351
2473
|
this._itemIcon = new CourierIcon(this._option.icon.svg ?? CourierIconSVGs.inbox);
|
|
@@ -2358,70 +2480,26 @@ class CourierInboxOptionMenuItem extends BaseElement {
|
|
|
2358
2480
|
this._content.appendChild(this._itemIcon);
|
|
2359
2481
|
this._content.appendChild(this._title);
|
|
2360
2482
|
this._content.appendChild(spacer);
|
|
2361
|
-
if (
|
|
2483
|
+
if (this._isSelectedable) {
|
|
2362
2484
|
this._content.appendChild(this._selectionIcon);
|
|
2363
2485
|
}
|
|
2364
|
-
|
|
2365
|
-
shadow.appendChild(this._content);
|
|
2486
|
+
this.appendChild(this._content);
|
|
2366
2487
|
this._selectionIcon.style.display = this._isSelected ? "block" : "none";
|
|
2367
2488
|
this.refreshTheme();
|
|
2368
2489
|
}
|
|
2369
|
-
getStyles() {
|
|
2370
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H;
|
|
2371
|
-
const theme2 = this._themeManager.getTheme();
|
|
2372
|
-
return `
|
|
2373
|
-
:host {
|
|
2374
|
-
display: flex;
|
|
2375
|
-
flex-direction: row;
|
|
2376
|
-
padding: 6px 12px;
|
|
2377
|
-
cursor: pointer;
|
|
2378
|
-
}
|
|
2379
|
-
|
|
2380
|
-
:host(:hover) {
|
|
2381
|
-
background-color: ${((_e = (_d = (_c = (_b = (_a = theme2.inbox) == null ? void 0 : _a.header) == null ? void 0 : _b.menus) == null ? void 0 : _c.popup) == null ? void 0 : _d.list) == null ? void 0 : _e.hoverBackgroundColor) ?? "red"};
|
|
2382
|
-
}
|
|
2383
|
-
|
|
2384
|
-
:host(:active) {
|
|
2385
|
-
background-color: ${((_j = (_i = (_h = (_g = (_f = theme2.inbox) == null ? void 0 : _f.header) == null ? void 0 : _g.menus) == null ? void 0 : _h.popup) == null ? void 0 : _i.list) == null ? void 0 : _j.activeBackgroundColor) ?? "red"};
|
|
2386
|
-
}
|
|
2387
|
-
|
|
2388
|
-
.menu-item {
|
|
2389
|
-
display: flex;
|
|
2390
|
-
align-items: center;
|
|
2391
|
-
width: 100%;
|
|
2392
|
-
gap: 12px;
|
|
2393
|
-
}
|
|
2394
|
-
|
|
2395
|
-
.spacer {
|
|
2396
|
-
flex: 1;
|
|
2397
|
-
}
|
|
2398
|
-
|
|
2399
|
-
p {
|
|
2400
|
-
margin: 0;
|
|
2401
|
-
font-family: ${((_p = (_o = (_n = (_m = (_l = (_k = theme2.inbox) == null ? void 0 : _k.header) == null ? void 0 : _l.menus) == null ? void 0 : _m.popup) == null ? void 0 : _n.list) == null ? void 0 : _o.font) == null ? void 0 : _p.family) ?? "inherit"};
|
|
2402
|
-
font-weight: ${((_v = (_u = (_t = (_s = (_r = (_q = theme2.inbox) == null ? void 0 : _q.header) == null ? void 0 : _r.menus) == null ? void 0 : _s.popup) == null ? void 0 : _t.list) == null ? void 0 : _u.font) == null ? void 0 : _v.weight) ?? "inherit"};
|
|
2403
|
-
font-size: ${((_B = (_A = (_z = (_y = (_x = (_w = theme2.inbox) == null ? void 0 : _w.header) == null ? void 0 : _x.menus) == null ? void 0 : _y.popup) == null ? void 0 : _z.list) == null ? void 0 : _A.font) == null ? void 0 : _B.size) ?? "14px"};
|
|
2404
|
-
color: ${((_H = (_G = (_F = (_E = (_D = (_C = theme2.inbox) == null ? void 0 : _C.header) == null ? void 0 : _D.menus) == null ? void 0 : _E.popup) == null ? void 0 : _F.list) == null ? void 0 : _G.font) == null ? void 0 : _H.color) ?? "red"};
|
|
2405
|
-
white-space: nowrap;
|
|
2406
|
-
}
|
|
2407
|
-
|
|
2408
|
-
.check-icon {
|
|
2409
|
-
display: none;
|
|
2410
|
-
}
|
|
2411
|
-
`;
|
|
2412
|
-
}
|
|
2413
2490
|
refreshTheme() {
|
|
2414
|
-
var _a, _b, _c, _d;
|
|
2415
|
-
this.
|
|
2416
|
-
this._selectionIcon.
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
this._itemIcon.
|
|
2491
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2492
|
+
(_b = this._selectionIcon) == null ? void 0 : _b.updateColor(((_a = this._option.selectionIcon) == null ? void 0 : _a.color) ?? "red");
|
|
2493
|
+
(_d = this._selectionIcon) == null ? void 0 : _d.updateSVG(((_c = this._option.selectionIcon) == null ? void 0 : _c.svg) ?? CourierIconSVGs.check);
|
|
2494
|
+
if (this._title) {
|
|
2495
|
+
this._title.textContent = this._option.text ?? "Missing Text";
|
|
2496
|
+
}
|
|
2497
|
+
(_f = this._itemIcon) == null ? void 0 : _f.updateColor(((_e = this._option.icon) == null ? void 0 : _e.color) ?? "red");
|
|
2498
|
+
(_h = this._itemIcon) == null ? void 0 : _h.updateSVG(((_g = this._option.icon) == null ? void 0 : _g.svg) ?? CourierIconSVGs.inbox);
|
|
2421
2499
|
}
|
|
2422
2500
|
}
|
|
2423
|
-
registerElement(
|
|
2424
|
-
class CourierInboxOptionMenu extends
|
|
2501
|
+
registerElement(CourierInboxOptionMenuItem);
|
|
2502
|
+
class CourierInboxOptionMenu extends CourierBaseElement {
|
|
2425
2503
|
constructor(themeManager, type, selectable, options, onMenuOpen) {
|
|
2426
2504
|
super();
|
|
2427
2505
|
// Theme
|
|
@@ -2441,31 +2519,39 @@ class CourierInboxOptionMenu extends BaseElement {
|
|
|
2441
2519
|
this._options = options;
|
|
2442
2520
|
this._selectedIndex = 0;
|
|
2443
2521
|
this._onMenuOpen = onMenuOpen;
|
|
2444
|
-
const shadow = this.attachShadow({ mode: "open" });
|
|
2445
|
-
this._menuButton = new CourierIconButton(type === "filters" ? CourierIconSVGs.filter : CourierIconSVGs.overflow);
|
|
2446
|
-
this._menu = document.createElement("div");
|
|
2447
|
-
this._menu.className = `menu ${type}`;
|
|
2448
|
-
this._style = document.createElement("style");
|
|
2449
|
-
shadow.appendChild(this._style);
|
|
2450
|
-
shadow.appendChild(this._menuButton);
|
|
2451
|
-
shadow.appendChild(this._menu);
|
|
2452
|
-
this._menuButton.addEventListener("click", this.toggleMenu.bind(this));
|
|
2453
|
-
document.addEventListener("click", this.handleOutsideClick.bind(this));
|
|
2454
2522
|
this._themeSubscription = themeManager.subscribe((_) => {
|
|
2455
2523
|
this.refreshTheme();
|
|
2456
2524
|
});
|
|
2525
|
+
}
|
|
2526
|
+
static get id() {
|
|
2527
|
+
return "courier-inbox-option-menu";
|
|
2528
|
+
}
|
|
2529
|
+
onComponentMounted() {
|
|
2530
|
+
this._style = injectGlobalStyle(CourierInboxOptionMenu.id, this.getStyles());
|
|
2531
|
+
this._menuButton = new CourierIconButton(this._type === "filters" ? CourierIconSVGs.filter : CourierIconSVGs.overflow);
|
|
2532
|
+
this._menu = document.createElement("div");
|
|
2533
|
+
this._menu.className = `menu ${this._type}`;
|
|
2534
|
+
this.appendChild(this._menuButton);
|
|
2535
|
+
this.appendChild(this._menu);
|
|
2536
|
+
this._menuButton.addEventListener("click", this.toggleMenu.bind(this));
|
|
2537
|
+
document.addEventListener("click", this.handleOutsideClick.bind(this));
|
|
2457
2538
|
this.refreshTheme();
|
|
2458
2539
|
}
|
|
2540
|
+
onComponentUnmounted() {
|
|
2541
|
+
var _a;
|
|
2542
|
+
this._themeSubscription.unsubscribe();
|
|
2543
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
2544
|
+
}
|
|
2459
2545
|
getStyles() {
|
|
2460
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
2546
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa;
|
|
2461
2547
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
2462
2548
|
return `
|
|
2463
|
-
|
|
2549
|
+
${CourierInboxOptionMenu.id} {
|
|
2464
2550
|
position: relative;
|
|
2465
2551
|
display: inline-block;
|
|
2466
2552
|
}
|
|
2467
2553
|
|
|
2468
|
-
.menu {
|
|
2554
|
+
${CourierInboxOptionMenu.id} .menu {
|
|
2469
2555
|
display: none;
|
|
2470
2556
|
position: absolute;
|
|
2471
2557
|
top: 42px;
|
|
@@ -2480,28 +2566,69 @@ class CourierInboxOptionMenu extends BaseElement {
|
|
|
2480
2566
|
padding: 4px 0;
|
|
2481
2567
|
}
|
|
2482
2568
|
|
|
2483
|
-
courier-inbox-filter-menu-item {
|
|
2569
|
+
${CourierInboxOptionMenu.id} courier-inbox-filter-menu-item {
|
|
2484
2570
|
border-bottom: ${((_u = (_t = (_s = (_r = (_q = theme2.inbox) == null ? void 0 : _q.header) == null ? void 0 : _r.menus) == null ? void 0 : _s.popup) == null ? void 0 : _t.list) == null ? void 0 : _u.divider) ?? "none"};
|
|
2485
2571
|
}
|
|
2486
2572
|
|
|
2487
|
-
courier-inbox-filter-menu-item:last-child {
|
|
2573
|
+
${CourierInboxOptionMenu.id} courier-inbox-filter-menu-item:last-child {
|
|
2488
2574
|
border-bottom: none;
|
|
2489
2575
|
}
|
|
2576
|
+
|
|
2577
|
+
${CourierInboxOptionMenuItem.id} {
|
|
2578
|
+
display: flex;
|
|
2579
|
+
flex-direction: row;
|
|
2580
|
+
padding: 6px 12px;
|
|
2581
|
+
cursor: pointer;
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
${CourierInboxOptionMenuItem.id}:hover {
|
|
2585
|
+
background-color: ${((_z = (_y = (_x = (_w = (_v = theme2.inbox) == null ? void 0 : _v.header) == null ? void 0 : _w.menus) == null ? void 0 : _x.popup) == null ? void 0 : _y.list) == null ? void 0 : _z.hoverBackgroundColor) ?? "red"};
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
${CourierInboxOptionMenuItem.id}:active {
|
|
2589
|
+
background-color: ${((_E = (_D = (_C = (_B = (_A = theme2.inbox) == null ? void 0 : _A.header) == null ? void 0 : _B.menus) == null ? void 0 : _C.popup) == null ? void 0 : _D.list) == null ? void 0 : _E.activeBackgroundColor) ?? "red"};
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
${CourierInboxOptionMenuItem.id} .menu-item {
|
|
2593
|
+
display: flex;
|
|
2594
|
+
align-items: center;
|
|
2595
|
+
width: 100%;
|
|
2596
|
+
gap: 12px;
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
${CourierInboxOptionMenuItem.id} .spacer {
|
|
2600
|
+
flex: 1;
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
${CourierInboxOptionMenuItem.id} p {
|
|
2604
|
+
margin: 0;
|
|
2605
|
+
font-family: ${((_K = (_J = (_I = (_H = (_G = (_F = theme2.inbox) == null ? void 0 : _F.header) == null ? void 0 : _G.menus) == null ? void 0 : _H.popup) == null ? void 0 : _I.list) == null ? void 0 : _J.font) == null ? void 0 : _K.family) ?? "inherit"};
|
|
2606
|
+
font-weight: ${((_Q = (_P = (_O = (_N = (_M = (_L = theme2.inbox) == null ? void 0 : _L.header) == null ? void 0 : _M.menus) == null ? void 0 : _N.popup) == null ? void 0 : _O.list) == null ? void 0 : _P.font) == null ? void 0 : _Q.weight) ?? "inherit"};
|
|
2607
|
+
font-size: ${((_W = (_V = (_U = (_T = (_S = (_R = theme2.inbox) == null ? void 0 : _R.header) == null ? void 0 : _S.menus) == null ? void 0 : _T.popup) == null ? void 0 : _U.list) == null ? void 0 : _V.font) == null ? void 0 : _W.size) ?? "14px"};
|
|
2608
|
+
color: ${((_aa = (_$ = (__ = (_Z = (_Y = (_X = theme2.inbox) == null ? void 0 : _X.header) == null ? void 0 : _Y.menus) == null ? void 0 : _Z.popup) == null ? void 0 : __.list) == null ? void 0 : _$.font) == null ? void 0 : _aa.color) ?? "red"};
|
|
2609
|
+
white-space: nowrap;
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
${CourierInboxOptionMenuItem.id} .check-icon {
|
|
2613
|
+
display: none;
|
|
2614
|
+
}
|
|
2490
2615
|
`;
|
|
2491
2616
|
}
|
|
2492
2617
|
refreshTheme() {
|
|
2493
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2494
|
-
this._style
|
|
2618
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2619
|
+
if (this._style) {
|
|
2620
|
+
this._style.textContent = this.getStyles();
|
|
2621
|
+
}
|
|
2495
2622
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
2496
2623
|
const menu = (_b = (_a = theme2.inbox) == null ? void 0 : _a.header) == null ? void 0 : _b.menus;
|
|
2497
2624
|
const isFilter = this._type === "filters";
|
|
2498
2625
|
const buttonConfig = isFilter ? (_c = menu == null ? void 0 : menu.filters) == null ? void 0 : _c.button : (_d = menu == null ? void 0 : menu.actions) == null ? void 0 : _d.button;
|
|
2499
2626
|
const defaultIcon = isFilter ? CourierIconSVGs.filter : CourierIconSVGs.overflow;
|
|
2500
|
-
this._menuButton.updateIconSVG(((_e = buttonConfig == null ? void 0 : buttonConfig.icon) == null ? void 0 : _e.svg) ?? defaultIcon);
|
|
2501
|
-
this._menuButton.updateIconColor(((
|
|
2502
|
-
this._menuButton.updateBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.backgroundColor) ?? "transparent");
|
|
2503
|
-
this._menuButton.updateHoverBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.hoverBackgroundColor) ?? "red");
|
|
2504
|
-
this._menuButton.updateActiveBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.activeBackgroundColor) ?? "red");
|
|
2627
|
+
(_f = this._menuButton) == null ? void 0 : _f.updateIconSVG(((_e = buttonConfig == null ? void 0 : buttonConfig.icon) == null ? void 0 : _e.svg) ?? defaultIcon);
|
|
2628
|
+
(_h = this._menuButton) == null ? void 0 : _h.updateIconColor(((_g = buttonConfig == null ? void 0 : buttonConfig.icon) == null ? void 0 : _g.color) ?? "red");
|
|
2629
|
+
(_i = this._menuButton) == null ? void 0 : _i.updateBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.backgroundColor) ?? "transparent");
|
|
2630
|
+
(_j = this._menuButton) == null ? void 0 : _j.updateHoverBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.hoverBackgroundColor) ?? "red");
|
|
2631
|
+
(_k = this._menuButton) == null ? void 0 : _k.updateActiveBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.activeBackgroundColor) ?? "red");
|
|
2505
2632
|
this.refreshMenuItems();
|
|
2506
2633
|
}
|
|
2507
2634
|
setOptions(options) {
|
|
@@ -2509,8 +2636,11 @@ class CourierInboxOptionMenu extends BaseElement {
|
|
|
2509
2636
|
this.refreshMenuItems();
|
|
2510
2637
|
}
|
|
2511
2638
|
refreshMenuItems() {
|
|
2512
|
-
this._menu
|
|
2639
|
+
if (this._menu) {
|
|
2640
|
+
this._menu.innerHTML = "";
|
|
2641
|
+
}
|
|
2513
2642
|
this._options.forEach((option, index) => {
|
|
2643
|
+
var _a;
|
|
2514
2644
|
const menuItem = new CourierInboxOptionMenuItem({
|
|
2515
2645
|
option,
|
|
2516
2646
|
selectable: this._selectable,
|
|
@@ -2523,13 +2653,16 @@ class CourierInboxOptionMenu extends BaseElement {
|
|
|
2523
2653
|
this.refreshMenuItems();
|
|
2524
2654
|
this.closeMenu();
|
|
2525
2655
|
});
|
|
2526
|
-
this._menu.appendChild(menuItem);
|
|
2656
|
+
(_a = this._menu) == null ? void 0 : _a.appendChild(menuItem);
|
|
2527
2657
|
});
|
|
2528
2658
|
}
|
|
2529
2659
|
toggleMenu(event) {
|
|
2660
|
+
var _a;
|
|
2530
2661
|
event.stopPropagation();
|
|
2531
|
-
const isOpening = this._menu.style.display !== "block";
|
|
2532
|
-
this._menu
|
|
2662
|
+
const isOpening = ((_a = this._menu) == null ? void 0 : _a.style.display) !== "block";
|
|
2663
|
+
if (this._menu) {
|
|
2664
|
+
this._menu.style.display = isOpening ? "block" : "none";
|
|
2665
|
+
}
|
|
2533
2666
|
if (isOpening) {
|
|
2534
2667
|
this._onMenuOpen();
|
|
2535
2668
|
}
|
|
@@ -2540,18 +2673,17 @@ class CourierInboxOptionMenu extends BaseElement {
|
|
|
2540
2673
|
}
|
|
2541
2674
|
}
|
|
2542
2675
|
closeMenu() {
|
|
2543
|
-
this._menu
|
|
2676
|
+
if (this._menu) {
|
|
2677
|
+
this._menu.style.display = "none";
|
|
2678
|
+
}
|
|
2544
2679
|
}
|
|
2545
2680
|
selectOption(option) {
|
|
2546
2681
|
this._selectedIndex = this._options.findIndex((o) => o.id === option.id);
|
|
2547
2682
|
this.refreshMenuItems();
|
|
2548
2683
|
}
|
|
2549
|
-
disconnectedCallback() {
|
|
2550
|
-
this._themeSubscription.unsubscribe();
|
|
2551
|
-
}
|
|
2552
2684
|
}
|
|
2553
|
-
registerElement(
|
|
2554
|
-
class CourierUnreadCountBadge extends
|
|
2685
|
+
registerElement(CourierInboxOptionMenu);
|
|
2686
|
+
class CourierUnreadCountBadge extends CourierBaseElement {
|
|
2555
2687
|
constructor(props) {
|
|
2556
2688
|
super();
|
|
2557
2689
|
// Theme
|
|
@@ -2566,37 +2698,51 @@ class CourierUnreadCountBadge extends BaseElement {
|
|
|
2566
2698
|
this._themeSubscription = props.themeBus.subscribe((_) => {
|
|
2567
2699
|
this.refreshTheme(this._location);
|
|
2568
2700
|
});
|
|
2569
|
-
|
|
2701
|
+
}
|
|
2702
|
+
static get id() {
|
|
2703
|
+
return "courier-unread-count-badge";
|
|
2704
|
+
}
|
|
2705
|
+
get theme() {
|
|
2706
|
+
return this._themeSubscription.manager.getTheme();
|
|
2707
|
+
}
|
|
2708
|
+
onComponentMounted() {
|
|
2570
2709
|
this._badge = document.createElement("span");
|
|
2571
|
-
this._badge.className =
|
|
2572
|
-
this.
|
|
2573
|
-
this.
|
|
2574
|
-
shadow.appendChild(this._style);
|
|
2575
|
-
shadow.appendChild(this._badge);
|
|
2710
|
+
this._badge.className = `unread-badge ${this._location}`;
|
|
2711
|
+
this.appendChild(this._badge);
|
|
2712
|
+
this.updateBadge();
|
|
2576
2713
|
}
|
|
2577
|
-
|
|
2578
|
-
var _a
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
const fontSize = (_g = indicator == null ? void 0 : indicator.font) == null ? void 0 : _g.size;
|
|
2714
|
+
onComponentUnmounted() {
|
|
2715
|
+
var _a;
|
|
2716
|
+
this._themeSubscription.unsubscribe();
|
|
2717
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
2718
|
+
}
|
|
2719
|
+
static getStyles(theme2) {
|
|
2720
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
|
|
2585
2721
|
return `
|
|
2586
|
-
|
|
2722
|
+
${CourierUnreadCountBadge.id} {
|
|
2587
2723
|
display: inline-block;
|
|
2588
2724
|
}
|
|
2589
2725
|
|
|
2590
|
-
.unread-badge {
|
|
2591
|
-
background-color: ${backgroundColor};
|
|
2592
|
-
color: ${color};
|
|
2593
|
-
border-radius: ${borderRadius};
|
|
2726
|
+
${CourierUnreadCountBadge.id} .unread-badge {
|
|
2594
2727
|
padding: 4px 8px;
|
|
2595
|
-
font-size: ${fontSize};
|
|
2596
2728
|
text-align: center;
|
|
2597
2729
|
display: none;
|
|
2598
2730
|
pointer-events: none;
|
|
2599
2731
|
}
|
|
2732
|
+
|
|
2733
|
+
${CourierUnreadCountBadge.id} .button {
|
|
2734
|
+
background-color: ${(_c = (_b = (_a = theme2.popup) == null ? void 0 : _a.button) == null ? void 0 : _b.unreadIndicator) == null ? void 0 : _c.backgroundColor};
|
|
2735
|
+
color: ${(_g = (_f = (_e = (_d = theme2.popup) == null ? void 0 : _d.button) == null ? void 0 : _e.unreadIndicator) == null ? void 0 : _f.font) == null ? void 0 : _g.color};
|
|
2736
|
+
border-radius: ${(_j = (_i = (_h = theme2.popup) == null ? void 0 : _h.button) == null ? void 0 : _i.unreadIndicator) == null ? void 0 : _j.borderRadius};
|
|
2737
|
+
font-size: ${(_n = (_m = (_l = (_k = theme2.popup) == null ? void 0 : _k.button) == null ? void 0 : _l.unreadIndicator) == null ? void 0 : _m.font) == null ? void 0 : _n.size};
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
${CourierUnreadCountBadge.id} .header {
|
|
2741
|
+
background-color: ${(_r = (_q = (_p = (_o = theme2.inbox) == null ? void 0 : _o.header) == null ? void 0 : _p.filters) == null ? void 0 : _q.unreadIndicator) == null ? void 0 : _r.backgroundColor};
|
|
2742
|
+
color: ${(_w = (_v = (_u = (_t = (_s = theme2.inbox) == null ? void 0 : _s.header) == null ? void 0 : _t.filters) == null ? void 0 : _u.unreadIndicator) == null ? void 0 : _v.font) == null ? void 0 : _w.color};
|
|
2743
|
+
border-radius: ${(_A = (_z = (_y = (_x = theme2.inbox) == null ? void 0 : _x.header) == null ? void 0 : _y.filters) == null ? void 0 : _z.unreadIndicator) == null ? void 0 : _A.borderRadius};
|
|
2744
|
+
font-size: ${(_F = (_E = (_D = (_C = (_B = theme2.inbox) == null ? void 0 : _B.header) == null ? void 0 : _C.filters) == null ? void 0 : _D.unreadIndicator) == null ? void 0 : _E.font) == null ? void 0 : _F.size};
|
|
2745
|
+
}
|
|
2600
2746
|
`;
|
|
2601
2747
|
}
|
|
2602
2748
|
setCount(count) {
|
|
@@ -2608,20 +2754,18 @@ class CourierUnreadCountBadge extends BaseElement {
|
|
|
2608
2754
|
this.updateBadge();
|
|
2609
2755
|
}
|
|
2610
2756
|
updateBadge() {
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2757
|
+
if (this._badge) {
|
|
2758
|
+
if (this._count > 0) {
|
|
2759
|
+
this._badge.textContent = this._count > 99 ? "99+" : this._count.toString();
|
|
2760
|
+
this._badge.style.display = "block";
|
|
2761
|
+
} else {
|
|
2762
|
+
this._badge.style.display = "none";
|
|
2763
|
+
}
|
|
2617
2764
|
}
|
|
2618
2765
|
}
|
|
2619
|
-
disconnectedCallback() {
|
|
2620
|
-
this._themeSubscription.unsubscribe();
|
|
2621
|
-
}
|
|
2622
2766
|
}
|
|
2623
|
-
registerElement(
|
|
2624
|
-
class CourierInboxHeaderTitle extends
|
|
2767
|
+
registerElement(CourierUnreadCountBadge);
|
|
2768
|
+
class CourierInboxHeaderTitle extends CourierBaseElement {
|
|
2625
2769
|
constructor(themeManager, option) {
|
|
2626
2770
|
super();
|
|
2627
2771
|
// Theme
|
|
@@ -2630,49 +2774,37 @@ class CourierInboxHeaderTitle extends BaseElement {
|
|
|
2630
2774
|
__publicField(this, "_option");
|
|
2631
2775
|
__publicField(this, "_feedType");
|
|
2632
2776
|
// Components
|
|
2777
|
+
__publicField(this, "_style");
|
|
2633
2778
|
__publicField(this, "_titleElement");
|
|
2634
2779
|
__publicField(this, "_iconElement");
|
|
2635
2780
|
__publicField(this, "_unreadBadge");
|
|
2636
|
-
__publicField(this, "_container");
|
|
2637
|
-
__publicField(this, "_style");
|
|
2638
2781
|
this._option = option;
|
|
2639
|
-
const shadow = this.attachShadow({ mode: "open" });
|
|
2640
|
-
this._style = document.createElement("style");
|
|
2641
|
-
this._container = document.createElement("div");
|
|
2642
|
-
this._container.className = "title-section";
|
|
2643
|
-
this._iconElement = new CourierIcon(void 0, this._option.icon.svg);
|
|
2644
|
-
this._titleElement = document.createElement("h2");
|
|
2645
|
-
this._unreadBadge = new CourierUnreadCountBadge({
|
|
2646
|
-
themeBus: themeManager,
|
|
2647
|
-
location: "header"
|
|
2648
|
-
});
|
|
2649
|
-
this._container.appendChild(this._iconElement);
|
|
2650
|
-
this._container.appendChild(this._titleElement);
|
|
2651
|
-
this._container.appendChild(this._unreadBadge);
|
|
2652
|
-
shadow.appendChild(this._style);
|
|
2653
|
-
shadow.appendChild(this._container);
|
|
2654
2782
|
this._themeSubscription = themeManager.subscribe((_) => {
|
|
2655
2783
|
this.refreshTheme(this._feedType ?? "inbox");
|
|
2656
2784
|
});
|
|
2657
|
-
this.refreshTheme(this._feedType ?? "inbox");
|
|
2658
2785
|
}
|
|
2659
|
-
|
|
2786
|
+
static get id() {
|
|
2787
|
+
return "courier-inbox-header-title";
|
|
2788
|
+
}
|
|
2789
|
+
get theme() {
|
|
2790
|
+
return this._themeSubscription.manager.getTheme();
|
|
2791
|
+
}
|
|
2792
|
+
static getStyles(theme2) {
|
|
2660
2793
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2661
|
-
const theme2 = this._themeSubscription.manager.getTheme();
|
|
2662
2794
|
return `
|
|
2663
|
-
.
|
|
2795
|
+
${CourierInboxHeaderTitle.id} {
|
|
2664
2796
|
display: flex;
|
|
2665
2797
|
align-items: center;
|
|
2666
2798
|
gap: 8px;
|
|
2667
2799
|
position: relative;
|
|
2668
2800
|
}
|
|
2669
2801
|
|
|
2670
|
-
courier-icon {
|
|
2802
|
+
${CourierInboxHeaderTitle.id} courier-icon {
|
|
2671
2803
|
display: flex;
|
|
2672
2804
|
align-items: center;
|
|
2673
2805
|
}
|
|
2674
2806
|
|
|
2675
|
-
h2 {
|
|
2807
|
+
${CourierInboxHeaderTitle.id} h2 {
|
|
2676
2808
|
margin: 0;
|
|
2677
2809
|
font-family: ${((_d = (_c = (_b = (_a = theme2.inbox) == null ? void 0 : _a.header) == null ? void 0 : _b.filters) == null ? void 0 : _c.font) == null ? void 0 : _d.family) ?? "inherit"};
|
|
2678
2810
|
font-size: ${((_h = (_g = (_f = (_e = theme2.inbox) == null ? void 0 : _e.header) == null ? void 0 : _f.filters) == null ? void 0 : _g.font) == null ? void 0 : _h.size) ?? "18px"};
|
|
@@ -2680,46 +2812,68 @@ class CourierInboxHeaderTitle extends BaseElement {
|
|
|
2680
2812
|
color: ${((_p = (_o = (_n = (_m = theme2.inbox) == null ? void 0 : _m.header) == null ? void 0 : _n.filters) == null ? void 0 : _o.font) == null ? void 0 : _p.color) ?? "red"};
|
|
2681
2813
|
}
|
|
2682
2814
|
|
|
2683
|
-
courier-unread-count-badge {
|
|
2815
|
+
${CourierInboxHeaderTitle.id} courier-unread-count-badge {
|
|
2684
2816
|
margin-left: 4px;
|
|
2685
2817
|
}
|
|
2686
2818
|
`;
|
|
2687
2819
|
}
|
|
2820
|
+
onComponentMounted() {
|
|
2821
|
+
this._style = injectGlobalStyle(CourierInboxHeaderTitle.id, CourierInboxHeaderTitle.getStyles(this.theme));
|
|
2822
|
+
this._iconElement = new CourierIcon(void 0, this._option.icon.svg);
|
|
2823
|
+
this._titleElement = document.createElement("h2");
|
|
2824
|
+
this._unreadBadge = new CourierUnreadCountBadge({
|
|
2825
|
+
themeBus: this._themeSubscription.manager,
|
|
2826
|
+
location: "header"
|
|
2827
|
+
});
|
|
2828
|
+
this.appendChild(this._iconElement);
|
|
2829
|
+
this.appendChild(this._titleElement);
|
|
2830
|
+
this.appendChild(this._unreadBadge);
|
|
2831
|
+
this.refreshTheme(this._feedType ?? "inbox");
|
|
2832
|
+
}
|
|
2833
|
+
onComponentUnmounted() {
|
|
2834
|
+
var _a;
|
|
2835
|
+
this._themeSubscription.unsubscribe();
|
|
2836
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
2837
|
+
}
|
|
2688
2838
|
refreshTheme(feedType) {
|
|
2839
|
+
var _a;
|
|
2689
2840
|
this._feedType = feedType;
|
|
2690
|
-
this._style
|
|
2691
|
-
|
|
2841
|
+
if (this._style) {
|
|
2842
|
+
this._style.textContent = CourierInboxHeaderTitle.getStyles(this.theme);
|
|
2843
|
+
}
|
|
2844
|
+
(_a = this._unreadBadge) == null ? void 0 : _a.refreshTheme("header");
|
|
2692
2845
|
this.updateFilter();
|
|
2693
2846
|
}
|
|
2694
2847
|
updateSelectedOption(option, feedType, unreadCount) {
|
|
2848
|
+
var _a;
|
|
2695
2849
|
this._option = option;
|
|
2696
2850
|
this._feedType = feedType;
|
|
2697
|
-
this._unreadBadge.setCount(unreadCount);
|
|
2851
|
+
(_a = this._unreadBadge) == null ? void 0 : _a.setCount(unreadCount);
|
|
2698
2852
|
this.updateFilter();
|
|
2699
2853
|
}
|
|
2700
2854
|
updateFilter() {
|
|
2701
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
|
|
2855
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
|
|
2702
2856
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
2703
2857
|
switch (this._feedType) {
|
|
2704
2858
|
case "inbox":
|
|
2705
|
-
this._titleElement
|
|
2706
|
-
|
|
2707
|
-
|
|
2859
|
+
if (this._titleElement) {
|
|
2860
|
+
this._titleElement.textContent = ((_d = (_c = (_b = (_a = theme2.inbox) == null ? void 0 : _a.header) == null ? void 0 : _b.filters) == null ? void 0 : _c.inbox) == null ? void 0 : _d.text) ?? "Inbox";
|
|
2861
|
+
}
|
|
2862
|
+
(_j = this._iconElement) == null ? void 0 : _j.updateSVG(((_i = (_h = (_g = (_f = (_e = theme2.inbox) == null ? void 0 : _e.header) == null ? void 0 : _f.filters) == null ? void 0 : _g.inbox) == null ? void 0 : _h.icon) == null ? void 0 : _i.svg) ?? CourierIconSVGs.inbox);
|
|
2863
|
+
(_p = this._iconElement) == null ? void 0 : _p.updateColor(((_o = (_n = (_m = (_l = (_k = theme2.inbox) == null ? void 0 : _k.header) == null ? void 0 : _l.filters) == null ? void 0 : _m.inbox) == null ? void 0 : _n.icon) == null ? void 0 : _o.color) ?? "red");
|
|
2708
2864
|
break;
|
|
2709
2865
|
case "archive":
|
|
2710
|
-
this._titleElement
|
|
2711
|
-
|
|
2712
|
-
|
|
2866
|
+
if (this._titleElement) {
|
|
2867
|
+
this._titleElement.textContent = ((_t = (_s = (_r = (_q = theme2.inbox) == null ? void 0 : _q.header) == null ? void 0 : _r.filters) == null ? void 0 : _s.archive) == null ? void 0 : _t.text) ?? "Archive";
|
|
2868
|
+
}
|
|
2869
|
+
(_z = this._iconElement) == null ? void 0 : _z.updateSVG(((_y = (_x = (_w = (_v = (_u = theme2.inbox) == null ? void 0 : _u.header) == null ? void 0 : _v.filters) == null ? void 0 : _w.archive) == null ? void 0 : _x.icon) == null ? void 0 : _y.svg) ?? CourierIconSVGs.archive);
|
|
2870
|
+
(_F = this._iconElement) == null ? void 0 : _F.updateColor(((_E = (_D = (_C = (_B = (_A = theme2.inbox) == null ? void 0 : _A.header) == null ? void 0 : _B.filters) == null ? void 0 : _C.archive) == null ? void 0 : _D.icon) == null ? void 0 : _E.color) ?? "red");
|
|
2713
2871
|
break;
|
|
2714
2872
|
}
|
|
2715
2873
|
}
|
|
2716
|
-
// Disconnect the theme subscription
|
|
2717
|
-
disconnectedCallback() {
|
|
2718
|
-
this._themeSubscription.unsubscribe();
|
|
2719
|
-
}
|
|
2720
2874
|
}
|
|
2721
|
-
registerElement(
|
|
2722
|
-
class CourierInboxHeader extends
|
|
2875
|
+
registerElement(CourierInboxHeaderTitle);
|
|
2876
|
+
class CourierInboxHeader extends CourierFactoryElement {
|
|
2723
2877
|
constructor(props) {
|
|
2724
2878
|
super();
|
|
2725
2879
|
// Theme
|
|
@@ -2739,7 +2893,23 @@ class CourierInboxHeader extends CourierElement {
|
|
|
2739
2893
|
});
|
|
2740
2894
|
this._onFeedTypeChange = props.onFeedTypeChange;
|
|
2741
2895
|
}
|
|
2742
|
-
|
|
2896
|
+
static get id() {
|
|
2897
|
+
return "courier-inbox-header";
|
|
2898
|
+
}
|
|
2899
|
+
static get observedAttributes() {
|
|
2900
|
+
return ["icon", "title", "feed-type"];
|
|
2901
|
+
}
|
|
2902
|
+
get theme() {
|
|
2903
|
+
return this._themeSubscription.manager.getTheme();
|
|
2904
|
+
}
|
|
2905
|
+
onComponentMounted() {
|
|
2906
|
+
this._style = injectGlobalStyle(CourierInboxHeader.id, CourierInboxHeader.getStyles(this.theme));
|
|
2907
|
+
}
|
|
2908
|
+
onComponentUmounted() {
|
|
2909
|
+
var _a;
|
|
2910
|
+
this._themeSubscription.unsubscribe();
|
|
2911
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
2912
|
+
}
|
|
2743
2913
|
getFilterOptions() {
|
|
2744
2914
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K;
|
|
2745
2915
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
@@ -2820,19 +2990,13 @@ class CourierInboxHeader extends CourierElement {
|
|
|
2820
2990
|
}
|
|
2821
2991
|
];
|
|
2822
2992
|
}
|
|
2823
|
-
static get observedAttributes() {
|
|
2824
|
-
return ["icon", "title", "feed-type"];
|
|
2825
|
-
}
|
|
2826
2993
|
refreshTheme() {
|
|
2827
|
-
var _a, _b
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
if (header) {
|
|
2831
|
-
header.style.backgroundColor = ((_c = (_b = theme2.inbox) == null ? void 0 : _b.header) == null ? void 0 : _c.backgroundColor) ?? CourierColors.white[500];
|
|
2832
|
-
header.style.boxShadow = ((_e = (_d = theme2.inbox) == null ? void 0 : _d.header) == null ? void 0 : _e.shadow) ?? `0px 1px 0px 0px ${CourierColors.gray[500]}`;
|
|
2994
|
+
var _a, _b;
|
|
2995
|
+
if (this._style) {
|
|
2996
|
+
this._style.textContent = CourierInboxHeader.getStyles(this.theme);
|
|
2833
2997
|
}
|
|
2834
|
-
(
|
|
2835
|
-
(
|
|
2998
|
+
(_a = this._filterMenu) == null ? void 0 : _a.setOptions(this.getFilterOptions());
|
|
2999
|
+
(_b = this._actionMenu) == null ? void 0 : _b.setOptions(this.getActionOptions());
|
|
2836
3000
|
}
|
|
2837
3001
|
handleOptionMenuItemClick(feedType, option) {
|
|
2838
3002
|
this._feedType = feedType;
|
|
@@ -2842,12 +3006,9 @@ class CourierInboxHeader extends CourierElement {
|
|
|
2842
3006
|
this._onFeedTypeChange(feedType);
|
|
2843
3007
|
}
|
|
2844
3008
|
render(props) {
|
|
3009
|
+
var _a, _b;
|
|
2845
3010
|
this._feedType = props.feedType;
|
|
2846
3011
|
this._unreadCount = props.unreadCount;
|
|
2847
|
-
this.refreshTitleSection();
|
|
2848
|
-
}
|
|
2849
|
-
refreshTitleSection() {
|
|
2850
|
-
var _a, _b;
|
|
2851
3012
|
const option = this.getFilterOptions().find((opt) => ["inbox", "archive"].includes(opt.id) && opt.id === this._feedType);
|
|
2852
3013
|
if (option) {
|
|
2853
3014
|
(_a = this._titleSection) == null ? void 0 : _a.updateSelectedOption(option, this._feedType, this._feedType === "inbox" ? this._unreadCount : 0);
|
|
@@ -2855,11 +3016,7 @@ class CourierInboxHeader extends CourierElement {
|
|
|
2855
3016
|
}
|
|
2856
3017
|
}
|
|
2857
3018
|
build(newElement) {
|
|
2858
|
-
var _a;
|
|
2859
3019
|
super.build(newElement);
|
|
2860
|
-
this._style = document.createElement("style");
|
|
2861
|
-
this._style.textContent = this.getStyles();
|
|
2862
|
-
(_a = this.shadow) == null ? void 0 : _a.appendChild(this._style);
|
|
2863
3020
|
this.refreshTheme();
|
|
2864
3021
|
}
|
|
2865
3022
|
defaultElement() {
|
|
@@ -2880,51 +3037,46 @@ class CourierInboxHeader extends CourierElement {
|
|
|
2880
3037
|
actions.className = "actions";
|
|
2881
3038
|
actions.appendChild(this._filterMenu);
|
|
2882
3039
|
actions.appendChild(this._actionMenu);
|
|
2883
|
-
const
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
return
|
|
2889
|
-
}
|
|
2890
|
-
getStyles() {
|
|
3040
|
+
const headerContent = document.createElement("div");
|
|
3041
|
+
headerContent.className = "header-content";
|
|
3042
|
+
headerContent.appendChild(this._titleSection);
|
|
3043
|
+
headerContent.appendChild(spacer);
|
|
3044
|
+
headerContent.appendChild(actions);
|
|
3045
|
+
return headerContent;
|
|
3046
|
+
}
|
|
3047
|
+
static getStyles(theme2) {
|
|
3048
|
+
var _a, _b, _c, _d;
|
|
2891
3049
|
return `
|
|
2892
|
-
|
|
2893
|
-
z-index: 100;
|
|
2894
|
-
}
|
|
2895
|
-
|
|
2896
|
-
.courier-inbox-header {
|
|
3050
|
+
${CourierInboxHeader.id} {
|
|
2897
3051
|
display: flex;
|
|
2898
3052
|
align-items: center;
|
|
2899
|
-
|
|
2900
|
-
padding: 10px 10px 10px 16px;
|
|
2901
|
-
background-color: ${CourierColors.white[500]};
|
|
2902
|
-
box-shadow: 0px 1px 0px 0px ${CourierColors.gray[500]};
|
|
3053
|
+
flex-shrink: 0;
|
|
2903
3054
|
}
|
|
2904
3055
|
|
|
2905
|
-
.header-content {
|
|
3056
|
+
${CourierInboxHeader.id} .header-content {
|
|
3057
|
+
padding: 10px 10px 10px 16px;
|
|
3058
|
+
background-color: ${((_b = (_a = theme2.inbox) == null ? void 0 : _a.header) == null ? void 0 : _b.backgroundColor) ?? CourierColors.white[500]};
|
|
3059
|
+
box-shadow: ${((_d = (_c = theme2.inbox) == null ? void 0 : _c.header) == null ? void 0 : _d.shadow) ?? `0px 1px 0px 0px red`};
|
|
2906
3060
|
display: flex;
|
|
2907
3061
|
align-items: center;
|
|
3062
|
+
justify-content: space-between;
|
|
2908
3063
|
flex: 1;
|
|
3064
|
+
z-index: 100;
|
|
2909
3065
|
}
|
|
2910
3066
|
|
|
2911
|
-
.spacer {
|
|
3067
|
+
${CourierInboxHeader.id} .spacer {
|
|
2912
3068
|
flex: 1;
|
|
2913
3069
|
}
|
|
2914
3070
|
|
|
2915
|
-
.actions {
|
|
3071
|
+
${CourierInboxHeader.id} .actions {
|
|
2916
3072
|
display: flex;
|
|
2917
3073
|
align-items: center;
|
|
2918
3074
|
gap: 4px;
|
|
2919
3075
|
}
|
|
2920
3076
|
`;
|
|
2921
3077
|
}
|
|
2922
|
-
// Disconnect the theme subscription
|
|
2923
|
-
disconnectedCallback() {
|
|
2924
|
-
this._themeSubscription.unsubscribe();
|
|
2925
|
-
}
|
|
2926
3078
|
}
|
|
2927
|
-
registerElement(
|
|
3079
|
+
registerElement(CourierInboxHeader);
|
|
2928
3080
|
class CourierInboxDataStoreListener {
|
|
2929
3081
|
constructor(events) {
|
|
2930
3082
|
__publicField(this, "events");
|
|
@@ -3395,7 +3547,7 @@ const defaultDarkTheme = {
|
|
|
3395
3547
|
},
|
|
3396
3548
|
loading: {
|
|
3397
3549
|
animation: {
|
|
3398
|
-
barColor: CourierColors.
|
|
3550
|
+
barColor: CourierColors.gray[400],
|
|
3399
3551
|
barHeight: "14px",
|
|
3400
3552
|
barBorderRadius: "14px",
|
|
3401
3553
|
duration: "2s"
|
|
@@ -3703,20 +3855,19 @@ class CourierInboxThemeManager {
|
|
|
3703
3855
|
this._subscriptions = [];
|
|
3704
3856
|
}
|
|
3705
3857
|
}
|
|
3706
|
-
class CourierInbox extends
|
|
3858
|
+
class CourierInbox extends CourierBaseElement {
|
|
3707
3859
|
constructor(themeManager) {
|
|
3708
|
-
var _a;
|
|
3709
3860
|
super();
|
|
3710
3861
|
// State
|
|
3711
3862
|
__publicField(this, "_currentFeed", "inbox");
|
|
3712
3863
|
// Theming
|
|
3713
3864
|
__publicField(this, "_themeManager");
|
|
3714
3865
|
// Components
|
|
3715
|
-
__publicField(this, "
|
|
3866
|
+
__publicField(this, "_inboxStyle");
|
|
3867
|
+
__publicField(this, "_unreadIndicatorStyle");
|
|
3716
3868
|
__publicField(this, "_list");
|
|
3717
3869
|
__publicField(this, "_datastoreListener");
|
|
3718
3870
|
__publicField(this, "_authListener");
|
|
3719
|
-
__publicField(this, "_style");
|
|
3720
3871
|
// Header
|
|
3721
3872
|
__publicField(this, "_header");
|
|
3722
3873
|
__publicField(this, "_headerFactory");
|
|
@@ -3729,10 +3880,32 @@ class CourierInbox extends BaseElement {
|
|
|
3729
3880
|
title: "Inbox",
|
|
3730
3881
|
icon: CourierIconSVGs.inbox,
|
|
3731
3882
|
feedType: this._currentFeed,
|
|
3732
|
-
height: "
|
|
3883
|
+
height: "auto"
|
|
3733
3884
|
});
|
|
3734
|
-
this._shadow = this.attachShadow({ mode: "open" });
|
|
3735
3885
|
this._themeManager = themeManager ?? new CourierInboxThemeManager(defaultLightTheme);
|
|
3886
|
+
}
|
|
3887
|
+
static get id() {
|
|
3888
|
+
return "courier-inbox";
|
|
3889
|
+
}
|
|
3890
|
+
get theme() {
|
|
3891
|
+
return this._themeManager.getTheme();
|
|
3892
|
+
}
|
|
3893
|
+
setLightTheme(theme2) {
|
|
3894
|
+
this._themeManager.setLightTheme(theme2);
|
|
3895
|
+
}
|
|
3896
|
+
setDarkTheme(theme2) {
|
|
3897
|
+
this._themeManager.setDarkTheme(theme2);
|
|
3898
|
+
}
|
|
3899
|
+
setMode(mode) {
|
|
3900
|
+
this._themeManager.setMode(mode);
|
|
3901
|
+
}
|
|
3902
|
+
static get observedAttributes() {
|
|
3903
|
+
return ["height", "light-theme", "dark-theme", "mode", "message-click", "message-action-click", "message-long-press"];
|
|
3904
|
+
}
|
|
3905
|
+
onComponentMounted() {
|
|
3906
|
+
var _a, _b;
|
|
3907
|
+
this._inboxStyle = injectGlobalStyle(CourierInbox.id, this.getStyles());
|
|
3908
|
+
this._unreadIndicatorStyle = injectGlobalStyle(CourierUnreadCountBadge.id, CourierUnreadCountBadge.getStyles(this.theme));
|
|
3736
3909
|
this._header = new CourierInboxHeader({
|
|
3737
3910
|
themeManager: this._themeManager,
|
|
3738
3911
|
onFeedTypeChange: (feedType) => {
|
|
@@ -3740,20 +3913,20 @@ class CourierInbox extends BaseElement {
|
|
|
3740
3913
|
}
|
|
3741
3914
|
});
|
|
3742
3915
|
this._header.build(void 0);
|
|
3743
|
-
this.
|
|
3916
|
+
this.appendChild(this._header);
|
|
3744
3917
|
this._list = new CourierInboxList({
|
|
3745
3918
|
themeManager: this._themeManager,
|
|
3746
3919
|
onRefresh: () => {
|
|
3747
3920
|
this.refresh();
|
|
3748
3921
|
},
|
|
3749
3922
|
onPaginationTrigger: async (feedType) => {
|
|
3750
|
-
var _a2,
|
|
3923
|
+
var _a2, _b2;
|
|
3751
3924
|
try {
|
|
3752
3925
|
await CourierInboxDatastore.shared.fetchNextPageOfMessages({
|
|
3753
3926
|
feedType
|
|
3754
3927
|
});
|
|
3755
3928
|
} catch (error) {
|
|
3756
|
-
(
|
|
3929
|
+
(_b2 = (_a2 = Courier.shared.client) == null ? void 0 : _a2.options.logger) == null ? void 0 : _b2.error("Failed to fetch next page of messages:", error);
|
|
3757
3930
|
}
|
|
3758
3931
|
},
|
|
3759
3932
|
onMessageClick: (message, index) => {
|
|
@@ -3785,41 +3958,45 @@ class CourierInbox extends BaseElement {
|
|
|
3785
3958
|
(_a2 = this._onMessageLongPress) == null ? void 0 : _a2.call(this, { message, index });
|
|
3786
3959
|
}
|
|
3787
3960
|
});
|
|
3788
|
-
this._style = document.createElement("style");
|
|
3789
3961
|
this.refreshTheme();
|
|
3790
|
-
this.
|
|
3791
|
-
this._shadow.appendChild(this._list);
|
|
3962
|
+
this.appendChild(this._list);
|
|
3792
3963
|
this._datastoreListener = new CourierInboxDataStoreListener({
|
|
3793
3964
|
onError: (error) => {
|
|
3794
|
-
|
|
3965
|
+
var _a2;
|
|
3966
|
+
(_a2 = this._list) == null ? void 0 : _a2.setError(error);
|
|
3795
3967
|
},
|
|
3796
3968
|
onDataSetChange: (dataSet, feedType) => {
|
|
3969
|
+
var _a2;
|
|
3797
3970
|
if (this._currentFeed === feedType) {
|
|
3798
|
-
this._list.setDataSet(dataSet);
|
|
3971
|
+
(_a2 = this._list) == null ? void 0 : _a2.setDataSet(dataSet);
|
|
3799
3972
|
this.updateHeader();
|
|
3800
3973
|
}
|
|
3801
3974
|
},
|
|
3802
3975
|
onPageAdded: (dataSet, feedType) => {
|
|
3976
|
+
var _a2;
|
|
3803
3977
|
if (this._currentFeed === feedType) {
|
|
3804
|
-
this._list.addPage(dataSet);
|
|
3978
|
+
(_a2 = this._list) == null ? void 0 : _a2.addPage(dataSet);
|
|
3805
3979
|
this.updateHeader();
|
|
3806
3980
|
}
|
|
3807
3981
|
},
|
|
3808
3982
|
onMessageAdd: (message, index, feedType) => {
|
|
3983
|
+
var _a2;
|
|
3809
3984
|
if (this._currentFeed === feedType) {
|
|
3810
|
-
this._list.addMessage(message, index);
|
|
3985
|
+
(_a2 = this._list) == null ? void 0 : _a2.addMessage(message, index);
|
|
3811
3986
|
this.updateHeader();
|
|
3812
3987
|
}
|
|
3813
3988
|
},
|
|
3814
3989
|
onMessageRemove: (_, index, feedType) => {
|
|
3990
|
+
var _a2;
|
|
3815
3991
|
if (this._currentFeed === feedType) {
|
|
3816
|
-
this._list.removeMessage(index);
|
|
3992
|
+
(_a2 = this._list) == null ? void 0 : _a2.removeMessage(index);
|
|
3817
3993
|
this.updateHeader();
|
|
3818
3994
|
}
|
|
3819
3995
|
},
|
|
3820
3996
|
onMessageUpdate: (message, index, feedType) => {
|
|
3997
|
+
var _a2;
|
|
3821
3998
|
if (this._currentFeed === feedType) {
|
|
3822
|
-
this._list.updateMessage(message, index);
|
|
3999
|
+
(_a2 = this._list) == null ? void 0 : _a2.updateMessage(message, index);
|
|
3823
4000
|
this.updateHeader();
|
|
3824
4001
|
}
|
|
3825
4002
|
},
|
|
@@ -3834,39 +4011,38 @@ class CourierInbox extends BaseElement {
|
|
|
3834
4011
|
this._authListener = Courier.shared.addAuthenticationListener((_) => {
|
|
3835
4012
|
this.refresh();
|
|
3836
4013
|
});
|
|
3837
|
-
if ((_a = Courier.shared.client) == null ? void 0 : _a.options.userId) {
|
|
3838
|
-
|
|
4014
|
+
if (!((_a = Courier.shared.client) == null ? void 0 : _a.options.userId)) {
|
|
4015
|
+
(_b = Courier.shared.client) == null ? void 0 : _b.options.logger.error("No user signed in. Please call Courier.shared.signIn(...) to load the inbox.");
|
|
4016
|
+
return;
|
|
3839
4017
|
}
|
|
4018
|
+
this.refresh();
|
|
3840
4019
|
}
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
this.
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
this._themeManager.setDarkTheme(theme2);
|
|
3849
|
-
}
|
|
3850
|
-
static get observedAttributes() {
|
|
3851
|
-
return ["height", "light-theme", "dark-theme", "mode", "message-click", "message-action-click", "message-long-press"];
|
|
4020
|
+
onComponentUnmounted() {
|
|
4021
|
+
var _a, _b, _c, _d;
|
|
4022
|
+
this._themeManager.cleanup();
|
|
4023
|
+
(_a = this._datastoreListener) == null ? void 0 : _a.remove();
|
|
4024
|
+
(_b = this._authListener) == null ? void 0 : _b.remove();
|
|
4025
|
+
(_c = this._inboxStyle) == null ? void 0 : _c.remove();
|
|
4026
|
+
(_d = this._unreadIndicatorStyle) == null ? void 0 : _d.remove();
|
|
3852
4027
|
}
|
|
3853
4028
|
refreshTheme() {
|
|
3854
|
-
|
|
4029
|
+
if (this._inboxStyle) {
|
|
4030
|
+
this._inboxStyle.textContent = this.getStyles();
|
|
4031
|
+
}
|
|
4032
|
+
if (this._unreadIndicatorStyle) {
|
|
4033
|
+
this._unreadIndicatorStyle.textContent = CourierUnreadCountBadge.getStyles(this.theme);
|
|
4034
|
+
}
|
|
3855
4035
|
}
|
|
3856
4036
|
getStyles() {
|
|
3857
4037
|
return `
|
|
3858
|
-
|
|
4038
|
+
${CourierInbox.id} {
|
|
3859
4039
|
display: flex;
|
|
3860
4040
|
flex-direction: column;
|
|
3861
4041
|
width: 100%;
|
|
3862
4042
|
height: ${this._defaultProps.height};
|
|
3863
4043
|
}
|
|
3864
4044
|
|
|
3865
|
-
courier-inbox-
|
|
3866
|
-
flex-shrink: 0;
|
|
3867
|
-
}
|
|
3868
|
-
|
|
3869
|
-
courier-inbox-list {
|
|
4045
|
+
${CourierInbox.id} courier-inbox-list {
|
|
3870
4046
|
flex: 1;
|
|
3871
4047
|
overflow-y: auto;
|
|
3872
4048
|
overflow-x: hidden;
|
|
@@ -3882,19 +4058,24 @@ class CourierInbox extends BaseElement {
|
|
|
3882
4058
|
this.updateHeader();
|
|
3883
4059
|
}
|
|
3884
4060
|
setLoadingState(factory) {
|
|
3885
|
-
|
|
4061
|
+
var _a;
|
|
4062
|
+
(_a = this._list) == null ? void 0 : _a.setLoadingStateFactory(factory);
|
|
3886
4063
|
}
|
|
3887
4064
|
setEmptyState(factory) {
|
|
3888
|
-
|
|
4065
|
+
var _a;
|
|
4066
|
+
(_a = this._list) == null ? void 0 : _a.setEmptyStateFactory(factory);
|
|
3889
4067
|
}
|
|
3890
4068
|
setErrorState(factory) {
|
|
3891
|
-
|
|
4069
|
+
var _a;
|
|
4070
|
+
(_a = this._list) == null ? void 0 : _a.setErrorStateFactory(factory);
|
|
3892
4071
|
}
|
|
3893
4072
|
setListItem(factory) {
|
|
3894
|
-
|
|
4073
|
+
var _a;
|
|
4074
|
+
(_a = this._list) == null ? void 0 : _a.setListItemFactory(factory);
|
|
3895
4075
|
}
|
|
3896
4076
|
setPaginationItem(factory) {
|
|
3897
|
-
|
|
4077
|
+
var _a;
|
|
4078
|
+
(_a = this._list) == null ? void 0 : _a.setPaginationItemFactory(factory);
|
|
3898
4079
|
}
|
|
3899
4080
|
onMessageClick(handler) {
|
|
3900
4081
|
this._onMessageClick = handler;
|
|
@@ -3906,30 +4087,31 @@ class CourierInbox extends BaseElement {
|
|
|
3906
4087
|
this._onMessageLongPress = handler;
|
|
3907
4088
|
}
|
|
3908
4089
|
setFeedType(feedType) {
|
|
4090
|
+
var _a;
|
|
3909
4091
|
this._currentFeed = feedType;
|
|
3910
|
-
this._list.setFeedType(feedType);
|
|
4092
|
+
(_a = this._list) == null ? void 0 : _a.setFeedType(feedType);
|
|
3911
4093
|
this.updateHeader();
|
|
3912
4094
|
this.load({
|
|
3913
|
-
feedType: this._currentFeed,
|
|
3914
4095
|
canUseCache: true
|
|
3915
4096
|
});
|
|
3916
4097
|
}
|
|
3917
4098
|
updateHeader() {
|
|
4099
|
+
var _a, _b, _c, _d;
|
|
3918
4100
|
const props = {
|
|
3919
4101
|
feedType: this._currentFeed,
|
|
3920
4102
|
unreadCount: CourierInboxDatastore.shared.unreadCount,
|
|
3921
|
-
messageCount: this._list.messages.length
|
|
4103
|
+
messageCount: ((_a = this._list) == null ? void 0 : _a.messages.length) ?? 0
|
|
3922
4104
|
};
|
|
3923
4105
|
switch (this._headerFactory) {
|
|
3924
4106
|
case void 0:
|
|
3925
|
-
this._header.render(props);
|
|
4107
|
+
(_b = this._header) == null ? void 0 : _b.render(props);
|
|
3926
4108
|
break;
|
|
3927
4109
|
case null:
|
|
3928
|
-
this._header.build(null);
|
|
4110
|
+
(_c = this._header) == null ? void 0 : _c.build(null);
|
|
3929
4111
|
break;
|
|
3930
4112
|
default:
|
|
3931
4113
|
const headerElement = this._headerFactory(props);
|
|
3932
|
-
this._header.build(headerElement);
|
|
4114
|
+
(_d = this._header) == null ? void 0 : _d.build(headerElement);
|
|
3933
4115
|
break;
|
|
3934
4116
|
}
|
|
3935
4117
|
}
|
|
@@ -3939,19 +4121,9 @@ class CourierInbox extends BaseElement {
|
|
|
3939
4121
|
}
|
|
3940
4122
|
refresh() {
|
|
3941
4123
|
this.load({
|
|
3942
|
-
feedType: this._currentFeed,
|
|
3943
4124
|
canUseCache: false
|
|
3944
4125
|
});
|
|
3945
4126
|
}
|
|
3946
|
-
connectedCallback() {
|
|
3947
|
-
this.refresh();
|
|
3948
|
-
}
|
|
3949
|
-
disconnectedCallback() {
|
|
3950
|
-
var _a, _b;
|
|
3951
|
-
this._themeManager.cleanup();
|
|
3952
|
-
(_a = this._datastoreListener) == null ? void 0 : _a.remove();
|
|
3953
|
-
(_b = this._authListener) == null ? void 0 : _b.remove();
|
|
3954
|
-
}
|
|
3955
4127
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
3956
4128
|
var _a, _b, _c, _d, _e, _f;
|
|
3957
4129
|
if (oldValue === newValue) return;
|
|
@@ -4009,20 +4181,35 @@ class CourierInbox extends BaseElement {
|
|
|
4009
4181
|
}
|
|
4010
4182
|
}
|
|
4011
4183
|
}
|
|
4012
|
-
registerElement(
|
|
4013
|
-
class CourierInboxMenuButton extends
|
|
4184
|
+
registerElement(CourierInbox);
|
|
4185
|
+
class CourierInboxMenuButton extends CourierFactoryElement {
|
|
4014
4186
|
constructor(themeBus) {
|
|
4015
4187
|
super();
|
|
4016
4188
|
// Theme
|
|
4017
4189
|
__publicField(this, "_themeSubscription");
|
|
4018
4190
|
// Components
|
|
4191
|
+
__publicField(this, "_style");
|
|
4019
4192
|
__publicField(this, "_container");
|
|
4020
4193
|
__publicField(this, "_triggerButton");
|
|
4021
4194
|
__publicField(this, "_unreadCountBadge");
|
|
4022
4195
|
this._themeSubscription = themeBus.subscribe((_) => {
|
|
4023
|
-
this.
|
|
4196
|
+
this.refreshTheme();
|
|
4024
4197
|
});
|
|
4025
4198
|
}
|
|
4199
|
+
static get id() {
|
|
4200
|
+
return "courier-inbox-menu-button";
|
|
4201
|
+
}
|
|
4202
|
+
get theme() {
|
|
4203
|
+
return this._themeSubscription.manager.getTheme();
|
|
4204
|
+
}
|
|
4205
|
+
onComponentMounted() {
|
|
4206
|
+
this._style = injectGlobalStyle(CourierInboxMenuButton.id, CourierInboxMenuButton.getStyles(this.theme));
|
|
4207
|
+
}
|
|
4208
|
+
onComponentUnmounted() {
|
|
4209
|
+
var _a;
|
|
4210
|
+
this._themeSubscription.unsubscribe();
|
|
4211
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
4212
|
+
}
|
|
4026
4213
|
defaultElement() {
|
|
4027
4214
|
this._container = document.createElement("div");
|
|
4028
4215
|
this._container.className = "menu-button-container";
|
|
@@ -4032,23 +4219,20 @@ class CourierInboxMenuButton extends CourierElement {
|
|
|
4032
4219
|
location: "button"
|
|
4033
4220
|
});
|
|
4034
4221
|
this._unreadCountBadge.id = "unread-badge";
|
|
4035
|
-
const style = document.createElement("style");
|
|
4036
|
-
style.textContent = this.getStyles();
|
|
4037
|
-
this._container.appendChild(style);
|
|
4038
4222
|
this._container.appendChild(this._triggerButton);
|
|
4039
4223
|
this._container.appendChild(this._unreadCountBadge);
|
|
4040
|
-
this.
|
|
4041
|
-
this.
|
|
4224
|
+
this.appendChild(this._container);
|
|
4225
|
+
this.refreshTheme();
|
|
4042
4226
|
return this._container;
|
|
4043
4227
|
}
|
|
4044
|
-
getStyles() {
|
|
4228
|
+
static getStyles(_theme) {
|
|
4045
4229
|
return `
|
|
4046
|
-
.menu-button-container {
|
|
4230
|
+
${CourierInboxMenuButton.id} .menu-button-container {
|
|
4047
4231
|
position: relative;
|
|
4048
4232
|
display: inline-block;
|
|
4049
4233
|
}
|
|
4050
4234
|
|
|
4051
|
-
#unread-badge {
|
|
4235
|
+
${CourierInboxMenuButton.id} #unread-badge {
|
|
4052
4236
|
position: absolute;
|
|
4053
4237
|
top: -8px;
|
|
4054
4238
|
left: 50%;
|
|
@@ -4059,30 +4243,26 @@ class CourierInboxMenuButton extends CourierElement {
|
|
|
4059
4243
|
onUnreadCountChange(unreadCount) {
|
|
4060
4244
|
var _a;
|
|
4061
4245
|
(_a = this._unreadCountBadge) == null ? void 0 : _a.setCount(unreadCount);
|
|
4062
|
-
this.
|
|
4063
|
-
}
|
|
4064
|
-
updateTheme() {
|
|
4065
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
4066
|
-
const theme2 = this._themeSubscription.manager.getTheme();
|
|
4067
|
-
(_d = this._triggerButton) == null ? void 0 : _d.updateIconColor(((_c = (_b = (_a = theme2 == null ? void 0 : theme2.popup) == null ? void 0 : _a.button) == null ? void 0 : _b.icon) == null ? void 0 : _c.color) ?? CourierColors.black[500]);
|
|
4068
|
-
(_h = this._triggerButton) == null ? void 0 : _h.updateIconSVG(((_g = (_f = (_e = theme2 == null ? void 0 : theme2.popup) == null ? void 0 : _e.button) == null ? void 0 : _f.icon) == null ? void 0 : _g.svg) ?? CourierIconSVGs.inbox);
|
|
4069
|
-
(_k = this._triggerButton) == null ? void 0 : _k.updateBackgroundColor(((_j = (_i = theme2 == null ? void 0 : theme2.popup) == null ? void 0 : _i.button) == null ? void 0 : _j.backgroundColor) ?? "transparent");
|
|
4070
|
-
(_n = this._triggerButton) == null ? void 0 : _n.updateHoverBackgroundColor(((_m = (_l = theme2 == null ? void 0 : theme2.popup) == null ? void 0 : _l.button) == null ? void 0 : _m.hoverBackgroundColor) ?? CourierColors.black[50010]);
|
|
4071
|
-
(_q = this._triggerButton) == null ? void 0 : _q.updateActiveBackgroundColor(((_p = (_o = theme2 == null ? void 0 : theme2.popup) == null ? void 0 : _o.button) == null ? void 0 : _p.activeBackgroundColor) ?? CourierColors.black[50020]);
|
|
4072
|
-
(_r = this._unreadCountBadge) == null ? void 0 : _r.refreshTheme("button");
|
|
4246
|
+
this.refreshTheme();
|
|
4073
4247
|
}
|
|
4074
|
-
|
|
4075
|
-
|
|
4248
|
+
refreshTheme() {
|
|
4249
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
4250
|
+
(_e = this._triggerButton) == null ? void 0 : _e.updateIconColor(((_d = (_c = (_b = (_a = this.theme) == null ? void 0 : _a.popup) == null ? void 0 : _b.button) == null ? void 0 : _c.icon) == null ? void 0 : _d.color) ?? CourierColors.black[500]);
|
|
4251
|
+
(_j = this._triggerButton) == null ? void 0 : _j.updateIconSVG(((_i = (_h = (_g = (_f = this.theme) == null ? void 0 : _f.popup) == null ? void 0 : _g.button) == null ? void 0 : _h.icon) == null ? void 0 : _i.svg) ?? CourierIconSVGs.inbox);
|
|
4252
|
+
(_n = this._triggerButton) == null ? void 0 : _n.updateBackgroundColor(((_m = (_l = (_k = this.theme) == null ? void 0 : _k.popup) == null ? void 0 : _l.button) == null ? void 0 : _m.backgroundColor) ?? "transparent");
|
|
4253
|
+
(_r = this._triggerButton) == null ? void 0 : _r.updateHoverBackgroundColor(((_q = (_p = (_o = this.theme) == null ? void 0 : _o.popup) == null ? void 0 : _p.button) == null ? void 0 : _q.hoverBackgroundColor) ?? CourierColors.black[50010]);
|
|
4254
|
+
(_v = this._triggerButton) == null ? void 0 : _v.updateActiveBackgroundColor(((_u = (_t = (_s = this.theme) == null ? void 0 : _s.popup) == null ? void 0 : _t.button) == null ? void 0 : _u.activeBackgroundColor) ?? CourierColors.black[50020]);
|
|
4255
|
+
(_w = this._unreadCountBadge) == null ? void 0 : _w.refreshTheme("button");
|
|
4076
4256
|
}
|
|
4077
4257
|
}
|
|
4078
|
-
registerElement(
|
|
4079
|
-
class CourierInboxPopupMenu extends
|
|
4258
|
+
registerElement(CourierInboxMenuButton);
|
|
4259
|
+
class CourierInboxPopupMenu extends CourierBaseElement {
|
|
4080
4260
|
constructor() {
|
|
4081
4261
|
super();
|
|
4082
4262
|
// State
|
|
4083
4263
|
__publicField(this, "_width", "440px");
|
|
4084
4264
|
__publicField(this, "_height", "440px");
|
|
4085
|
-
__publicField(this, "_popupAlignment", "top-
|
|
4265
|
+
__publicField(this, "_popupAlignment", "top-left");
|
|
4086
4266
|
__publicField(this, "_top", "40px");
|
|
4087
4267
|
__publicField(this, "_right", "0");
|
|
4088
4268
|
__publicField(this, "_bottom", "40px");
|
|
@@ -4098,28 +4278,26 @@ class CourierInboxPopupMenu extends BaseElement {
|
|
|
4098
4278
|
__publicField(this, "_datastoreListener");
|
|
4099
4279
|
// Factories
|
|
4100
4280
|
__publicField(this, "_popupMenuButtonFactory");
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
this._triggerButton.addEventListener("click", this.togglePopup.bind(this));
|
|
4115
|
-
document.addEventListener("click", this.handleOutsideClick.bind(this));
|
|
4116
|
-
this.updatePopupPosition();
|
|
4117
|
-
this._datastoreListener = new CourierInboxDataStoreListener(this);
|
|
4118
|
-
CourierInboxDatastore.shared.addDataStoreListener(this._datastoreListener);
|
|
4281
|
+
__publicField(this, "handleOutsideClick", (event) => {
|
|
4282
|
+
if (!this._popup) return;
|
|
4283
|
+
const SAFE_SELECTORS = [
|
|
4284
|
+
"courier-inbox-option-menu"
|
|
4285
|
+
];
|
|
4286
|
+
const clickIsInsideAllowedArea = event.composedPath().some((node) => {
|
|
4287
|
+
if (!(node instanceof HTMLElement)) return false;
|
|
4288
|
+
if (node === this._popup || this._popup.contains(node)) return true;
|
|
4289
|
+
return SAFE_SELECTORS.some((sel) => node.matches(sel));
|
|
4290
|
+
});
|
|
4291
|
+
if (clickIsInsideAllowedArea) return;
|
|
4292
|
+
this._popup.style.display = "none";
|
|
4293
|
+
});
|
|
4119
4294
|
this._themeManager.subscribe((_) => {
|
|
4120
4295
|
this.refreshTheme();
|
|
4121
4296
|
});
|
|
4122
4297
|
}
|
|
4298
|
+
static get id() {
|
|
4299
|
+
return "courier-inbox-popup-menu";
|
|
4300
|
+
}
|
|
4123
4301
|
get theme() {
|
|
4124
4302
|
return this._themeManager.getTheme();
|
|
4125
4303
|
}
|
|
@@ -4129,48 +4307,77 @@ class CourierInboxPopupMenu extends BaseElement {
|
|
|
4129
4307
|
setDarkTheme(theme2) {
|
|
4130
4308
|
this._themeManager.setDarkTheme(theme2);
|
|
4131
4309
|
}
|
|
4310
|
+
setMode(mode) {
|
|
4311
|
+
this._themeManager.setMode(mode);
|
|
4312
|
+
}
|
|
4132
4313
|
static get observedAttributes() {
|
|
4133
4314
|
return ["popup-alignment", "message-click", "message-action-click", "message-long-press", "popup-width", "popup-height", "top", "right", "bottom", "left", "light-theme", "dark-theme", "mode"];
|
|
4134
4315
|
}
|
|
4316
|
+
onComponentMounted() {
|
|
4317
|
+
this._style = injectGlobalStyle(CourierInboxPopupMenu.id, CourierInboxPopupMenu.getStyles(this.theme, this._width, this._height));
|
|
4318
|
+
this._triggerButton = new CourierInboxMenuButton(this._themeManager);
|
|
4319
|
+
this._triggerButton.build(void 0);
|
|
4320
|
+
this._popup = document.createElement("div");
|
|
4321
|
+
this._popup.className = "popup";
|
|
4322
|
+
this._inbox = new CourierInbox(this._themeManager);
|
|
4323
|
+
this._inbox.setAttribute("height", "100%");
|
|
4324
|
+
this.refreshTheme();
|
|
4325
|
+
this.appendChild(this._triggerButton);
|
|
4326
|
+
this.appendChild(this._popup);
|
|
4327
|
+
this._popup.appendChild(this._inbox);
|
|
4328
|
+
this._triggerButton.addEventListener("click", this.togglePopup.bind(this));
|
|
4329
|
+
document.addEventListener("click", this.handleOutsideClick.bind(this));
|
|
4330
|
+
this.updatePopupPosition();
|
|
4331
|
+
this._datastoreListener = new CourierInboxDataStoreListener(this);
|
|
4332
|
+
CourierInboxDatastore.shared.addDataStoreListener(this._datastoreListener);
|
|
4333
|
+
}
|
|
4334
|
+
onComponentUnmounted() {
|
|
4335
|
+
var _a, _b;
|
|
4336
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
4337
|
+
(_b = this._datastoreListener) == null ? void 0 : _b.remove();
|
|
4338
|
+
this._themeManager.cleanup();
|
|
4339
|
+
}
|
|
4135
4340
|
refreshTheme() {
|
|
4136
|
-
this._style
|
|
4341
|
+
if (this._style) {
|
|
4342
|
+
this._style.textContent = CourierInboxPopupMenu.getStyles(this.theme, this._width, this._height);
|
|
4343
|
+
}
|
|
4137
4344
|
}
|
|
4138
|
-
getStyles() {
|
|
4345
|
+
static getStyles(theme2, width, height) {
|
|
4139
4346
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4140
4347
|
return `
|
|
4141
|
-
|
|
4348
|
+
${CourierInboxPopupMenu.id} {
|
|
4142
4349
|
display: inline-block;
|
|
4143
4350
|
position: relative;
|
|
4144
4351
|
}
|
|
4145
4352
|
|
|
4146
|
-
.menu-button-container {
|
|
4353
|
+
${CourierInboxPopupMenu.id} .menu-button-container {
|
|
4147
4354
|
position: relative;
|
|
4148
4355
|
display: inline-block;
|
|
4149
4356
|
}
|
|
4150
4357
|
|
|
4151
|
-
.popup {
|
|
4358
|
+
${CourierInboxPopupMenu.id} .popup {
|
|
4152
4359
|
display: none;
|
|
4153
4360
|
position: absolute;
|
|
4154
|
-
background: ${((_b = (_a =
|
|
4155
|
-
border-radius: ${((_d = (_c =
|
|
4156
|
-
border: ${((_f = (_e =
|
|
4157
|
-
box-shadow: ${((_h = (_g =
|
|
4361
|
+
background: ${((_b = (_a = theme2.popup) == null ? void 0 : _a.window) == null ? void 0 : _b.backgroundColor) ?? "red"};
|
|
4362
|
+
border-radius: ${((_d = (_c = theme2.popup) == null ? void 0 : _c.window) == null ? void 0 : _d.borderRadius) ?? "8px"};
|
|
4363
|
+
border: ${((_f = (_e = theme2.popup) == null ? void 0 : _e.window) == null ? void 0 : _f.border) ?? `1px solid red`};
|
|
4364
|
+
box-shadow: ${((_h = (_g = theme2.popup) == null ? void 0 : _g.window) == null ? void 0 : _h.shadow) ?? `0px 8px 16px -4px red`};
|
|
4158
4365
|
z-index: 1000;
|
|
4159
|
-
width: ${
|
|
4160
|
-
height: ${
|
|
4366
|
+
width: ${width};
|
|
4367
|
+
height: ${height};
|
|
4161
4368
|
overflow: hidden;
|
|
4162
4369
|
transform: translateZ(0);
|
|
4163
4370
|
will-change: transform;
|
|
4164
4371
|
}
|
|
4165
4372
|
|
|
4166
|
-
#unread-badge {
|
|
4373
|
+
${CourierInboxPopupMenu.id} #unread-badge {
|
|
4167
4374
|
position: absolute;
|
|
4168
4375
|
top: -8px;
|
|
4169
4376
|
left: 50%;
|
|
4170
4377
|
pointer-events: none;
|
|
4171
4378
|
}
|
|
4172
4379
|
|
|
4173
|
-
courier-inbox {
|
|
4380
|
+
${CourierInboxPopupMenu.id} courier-inbox {
|
|
4174
4381
|
height: 100%;
|
|
4175
4382
|
}
|
|
4176
4383
|
`;
|
|
@@ -4226,13 +4433,16 @@ class CourierInboxPopupMenu extends BaseElement {
|
|
|
4226
4433
|
this.render();
|
|
4227
4434
|
}
|
|
4228
4435
|
onMessageClick(handler) {
|
|
4229
|
-
|
|
4436
|
+
var _a;
|
|
4437
|
+
(_a = this._inbox) == null ? void 0 : _a.onMessageClick(handler);
|
|
4230
4438
|
}
|
|
4231
4439
|
onMessageActionClick(handler) {
|
|
4232
|
-
|
|
4440
|
+
var _a;
|
|
4441
|
+
(_a = this._inbox) == null ? void 0 : _a.onMessageActionClick(handler);
|
|
4233
4442
|
}
|
|
4234
4443
|
onMessageLongPress(handler) {
|
|
4235
|
-
|
|
4444
|
+
var _a;
|
|
4445
|
+
(_a = this._inbox) == null ? void 0 : _a.onMessageLongPress(handler);
|
|
4236
4446
|
}
|
|
4237
4447
|
isValidPosition(value) {
|
|
4238
4448
|
const validPositions = [
|
|
@@ -4249,6 +4459,7 @@ class CourierInboxPopupMenu extends BaseElement {
|
|
|
4249
4459
|
return validPositions.includes(value);
|
|
4250
4460
|
}
|
|
4251
4461
|
updatePopupPosition() {
|
|
4462
|
+
if (!this._popup) return;
|
|
4252
4463
|
this._popup.style.top = "";
|
|
4253
4464
|
this._popup.style.bottom = "";
|
|
4254
4465
|
this._popup.style.left = "";
|
|
@@ -4301,25 +4512,19 @@ class CourierInboxPopupMenu extends BaseElement {
|
|
|
4301
4512
|
}
|
|
4302
4513
|
togglePopup(event) {
|
|
4303
4514
|
event.stopPropagation();
|
|
4515
|
+
if (!this._popup) return;
|
|
4304
4516
|
const isVisible = this._popup.style.display === "block";
|
|
4305
|
-
|
|
4306
|
-
this._popup.style.display = "block";
|
|
4307
|
-
} else {
|
|
4308
|
-
this._popup.style.display = "none";
|
|
4309
|
-
}
|
|
4310
|
-
}
|
|
4311
|
-
handleOutsideClick(event) {
|
|
4312
|
-
if (!this.contains(event.target)) {
|
|
4313
|
-
this._popup.style.display = "none";
|
|
4314
|
-
}
|
|
4517
|
+
this._popup.style.display = isVisible ? "none" : "block";
|
|
4315
4518
|
}
|
|
4316
4519
|
setContent(element) {
|
|
4520
|
+
if (!this._inbox) return;
|
|
4317
4521
|
this._inbox.innerHTML = "";
|
|
4318
4522
|
this._inbox.appendChild(element);
|
|
4319
4523
|
}
|
|
4320
4524
|
setSize(width, height) {
|
|
4321
4525
|
this._width = width;
|
|
4322
4526
|
this._height = height;
|
|
4527
|
+
if (!this._popup) return;
|
|
4323
4528
|
this._popup.style.width = width;
|
|
4324
4529
|
this._popup.style.height = height;
|
|
4325
4530
|
}
|
|
@@ -4333,36 +4538,45 @@ class CourierInboxPopupMenu extends BaseElement {
|
|
|
4333
4538
|
}
|
|
4334
4539
|
}
|
|
4335
4540
|
setFeedType(feedType) {
|
|
4336
|
-
|
|
4541
|
+
var _a;
|
|
4542
|
+
(_a = this._inbox) == null ? void 0 : _a.setFeedType(feedType);
|
|
4337
4543
|
}
|
|
4338
4544
|
// Factory methods
|
|
4339
|
-
|
|
4340
|
-
|
|
4545
|
+
setHeader(factory) {
|
|
4546
|
+
var _a;
|
|
4547
|
+
(_a = this._inbox) == null ? void 0 : _a.setHeader(factory);
|
|
4341
4548
|
}
|
|
4342
|
-
|
|
4343
|
-
|
|
4549
|
+
removeHeader() {
|
|
4550
|
+
var _a;
|
|
4551
|
+
(_a = this._inbox) == null ? void 0 : _a.removeHeader();
|
|
4344
4552
|
}
|
|
4345
|
-
|
|
4346
|
-
|
|
4553
|
+
setLoadingState(factory) {
|
|
4554
|
+
var _a;
|
|
4555
|
+
(_a = this._inbox) == null ? void 0 : _a.setLoadingState(factory);
|
|
4347
4556
|
}
|
|
4348
|
-
|
|
4349
|
-
|
|
4557
|
+
setEmptyState(factory) {
|
|
4558
|
+
var _a;
|
|
4559
|
+
(_a = this._inbox) == null ? void 0 : _a.setEmptyState(factory);
|
|
4350
4560
|
}
|
|
4351
|
-
|
|
4352
|
-
|
|
4561
|
+
setErrorState(factory) {
|
|
4562
|
+
var _a;
|
|
4563
|
+
(_a = this._inbox) == null ? void 0 : _a.setErrorState(factory);
|
|
4353
4564
|
}
|
|
4354
|
-
|
|
4355
|
-
|
|
4565
|
+
setListItem(factory) {
|
|
4566
|
+
var _a;
|
|
4567
|
+
(_a = this._inbox) == null ? void 0 : _a.setListItem(factory);
|
|
4356
4568
|
}
|
|
4357
|
-
|
|
4358
|
-
|
|
4569
|
+
setPaginationItem(factory) {
|
|
4570
|
+
var _a;
|
|
4571
|
+
(_a = this._inbox) == null ? void 0 : _a.setPaginationItem(factory);
|
|
4359
4572
|
}
|
|
4360
|
-
|
|
4573
|
+
setMenuButton(factory) {
|
|
4361
4574
|
this._popupMenuButtonFactory = factory;
|
|
4362
4575
|
this.render();
|
|
4363
4576
|
}
|
|
4364
4577
|
render() {
|
|
4365
4578
|
const unreadCount = CourierInboxDatastore.shared.unreadCount;
|
|
4579
|
+
if (!this._triggerButton) return;
|
|
4366
4580
|
switch (this._popupMenuButtonFactory) {
|
|
4367
4581
|
case void 0:
|
|
4368
4582
|
case null:
|
|
@@ -4375,13 +4589,8 @@ class CourierInboxPopupMenu extends BaseElement {
|
|
|
4375
4589
|
break;
|
|
4376
4590
|
}
|
|
4377
4591
|
}
|
|
4378
|
-
disconnectedCallback() {
|
|
4379
|
-
var _a;
|
|
4380
|
-
(_a = this._datastoreListener) == null ? void 0 : _a.remove();
|
|
4381
|
-
this._themeManager.cleanup();
|
|
4382
|
-
}
|
|
4383
4592
|
}
|
|
4384
|
-
registerElement(
|
|
4593
|
+
registerElement(CourierInboxPopupMenu);
|
|
4385
4594
|
function markAsRead(message) {
|
|
4386
4595
|
return CourierInboxDatastore.shared.readMessage({ message });
|
|
4387
4596
|
}
|
|
@@ -4414,14 +4623,15 @@ class CourierInboxDatastoreEvents {
|
|
|
4414
4623
|
}
|
|
4415
4624
|
}
|
|
4416
4625
|
export {
|
|
4626
|
+
Courier2 as Courier,
|
|
4417
4627
|
CourierInbox,
|
|
4418
4628
|
CourierInboxDataStoreListener,
|
|
4419
4629
|
CourierInboxDatastore,
|
|
4420
4630
|
CourierInboxDatastoreEvents,
|
|
4421
4631
|
CourierInboxHeader,
|
|
4632
|
+
CourierInboxListItem,
|
|
4422
4633
|
CourierInboxPopupMenu,
|
|
4423
4634
|
CourierInboxThemeManager,
|
|
4424
|
-
CourierListItem,
|
|
4425
4635
|
archiveMessage,
|
|
4426
4636
|
clickMessage,
|
|
4427
4637
|
defaultDarkTheme,
|