@trycourier/courier-ui-inbox 1.0.6-beta → 1.0.8-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/courier-inbox-header-title.d.ts +12 -8
- package/dist/components/courier-inbox-header.d.ts +11 -8
- package/dist/components/courier-inbox-list-item-menu.d.ts +9 -7
- package/dist/components/courier-inbox-list-item.d.ts +11 -11
- package/dist/components/courier-inbox-list.d.ts +11 -5
- package/dist/components/courier-inbox-menu-button.d.ts +10 -5
- package/dist/components/courier-inbox-option-menu-item.d.ts +9 -8
- package/dist/components/courier-inbox-option-menu.d.ts +11 -8
- package/dist/components/courier-inbox-pagination-list-item.d.ts +12 -7
- package/dist/components/{courier-inbox-menu.d.ts → courier-inbox-popup-menu.d.ts} +10 -7
- package/dist/components/courier-inbox-skeleton-list-item.d.ts +10 -4
- package/dist/components/courier-inbox-skeleton-list.d.ts +7 -3
- package/dist/components/courier-inbox.d.ts +9 -7
- package/dist/components/courier-unread-count-badge.d.ts +10 -5
- package/dist/datastore/__tests__/datastore.test.d.ts +1 -0
- package/dist/datastore/datastore.d.ts +1 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1025 -849
- package/dist/index.mjs.map +1 -1
- package/dist/jest.setup.d.ts +0 -0
- 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 +8 -5
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
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
5
|
var __defProp2 = Object.defineProperty;
|
|
6
|
+
var __typeError = (msg) => {
|
|
7
|
+
throw TypeError(msg);
|
|
8
|
+
};
|
|
6
9
|
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
10
|
var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
11
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
12
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), member.get(obj));
|
|
13
|
+
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);
|
|
14
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
15
|
+
var _isInitialised;
|
|
8
16
|
const CourierColors = {
|
|
9
17
|
black: {
|
|
10
18
|
500: "#171717",
|
|
@@ -73,7 +81,52 @@ const addSystemThemeModeListener = (callback) => {
|
|
|
73
81
|
mediaQuery.removeEventListener("change", handler);
|
|
74
82
|
};
|
|
75
83
|
};
|
|
76
|
-
|
|
84
|
+
const HTMLElementBase = (() => {
|
|
85
|
+
try {
|
|
86
|
+
return typeof HTMLElement === "undefined" ? class {
|
|
87
|
+
} : HTMLElement;
|
|
88
|
+
} catch {
|
|
89
|
+
return class {
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
})();
|
|
93
|
+
class CourierBaseElement extends HTMLElementBase {
|
|
94
|
+
constructor() {
|
|
95
|
+
super(...arguments);
|
|
96
|
+
__privateAdd(this, _isInitialised, false);
|
|
97
|
+
}
|
|
98
|
+
/** Tag-name you’ll use in `customElements.define()` */
|
|
99
|
+
static get id() {
|
|
100
|
+
return "courier-base-element";
|
|
101
|
+
}
|
|
102
|
+
/* ------------------------------------------------------------------ */
|
|
103
|
+
/* Custom-elements lifecycle hooks */
|
|
104
|
+
/* ------------------------------------------------------------------ */
|
|
105
|
+
connectedCallback() {
|
|
106
|
+
var _a;
|
|
107
|
+
if (__privateGet(this, _isInitialised)) return;
|
|
108
|
+
__privateSet(this, _isInitialised, true);
|
|
109
|
+
(_a = this.onComponentMounted) == null ? void 0 : _a.call(this);
|
|
110
|
+
}
|
|
111
|
+
disconnectedCallback() {
|
|
112
|
+
var _a;
|
|
113
|
+
__privateSet(this, _isInitialised, false);
|
|
114
|
+
(_a = this.onComponentUnmounted) == null ? void 0 : _a.call(this);
|
|
115
|
+
}
|
|
116
|
+
/* ------------------------------------------------------------------ */
|
|
117
|
+
/* Overridable hooks */
|
|
118
|
+
/* ------------------------------------------------------------------ */
|
|
119
|
+
/** Called **once** when the element first becomes part of the DOM. */
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
121
|
+
onComponentMounted() {
|
|
122
|
+
}
|
|
123
|
+
/** Called when the element is removed from the DOM. */
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
125
|
+
onComponentUnmounted() {
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
_isInitialised = /* @__PURE__ */ new WeakMap();
|
|
129
|
+
class CourierSystemThemeElement extends CourierBaseElement {
|
|
77
130
|
constructor() {
|
|
78
131
|
super();
|
|
79
132
|
__publicField2(this, "_currentSystemTheme");
|
|
@@ -84,13 +137,16 @@ class CourierSystemThemeElement extends HTMLElement {
|
|
|
84
137
|
this.onSystemThemeChange(mode);
|
|
85
138
|
});
|
|
86
139
|
}
|
|
140
|
+
static get id() {
|
|
141
|
+
return "courier-system-theme-element";
|
|
142
|
+
}
|
|
87
143
|
get currentSystemTheme() {
|
|
88
144
|
return this._currentSystemTheme;
|
|
89
145
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
146
|
+
onComponentUnmounted() {
|
|
147
|
+
var _a;
|
|
148
|
+
(_a = this._systemThemeCleanup) == null ? void 0 : _a.call(this);
|
|
149
|
+
super.onComponentUnmounted();
|
|
94
150
|
}
|
|
95
151
|
onSystemThemeChange(_) {
|
|
96
152
|
}
|
|
@@ -145,6 +201,9 @@ class CourierButton extends CourierSystemThemeElement {
|
|
|
145
201
|
}
|
|
146
202
|
});
|
|
147
203
|
}
|
|
204
|
+
static get id() {
|
|
205
|
+
return "courier-button";
|
|
206
|
+
}
|
|
148
207
|
getStyles(props) {
|
|
149
208
|
const defaultTextColor = () => {
|
|
150
209
|
const secondary = CourierButtonVariants.secondary(this.currentSystemTheme);
|
|
@@ -217,9 +276,6 @@ class CourierButton extends CourierSystemThemeElement {
|
|
|
217
276
|
this._style.textContent = this.getStyles(props);
|
|
218
277
|
}
|
|
219
278
|
}
|
|
220
|
-
if (!customElements.get("courier-button")) {
|
|
221
|
-
customElements.define("courier-button", CourierButton);
|
|
222
|
-
}
|
|
223
279
|
const CourierIconSVGs = {
|
|
224
280
|
inbox: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
225
281
|
<path d="M5.5 14.5V17C5.5 17.2812 5.71875 17.5 6 17.5H18C18.25 17.5 18.5 17.2812 18.5 17V14.5H15.9375L15.2812 15.8125C15.0938 16.25 14.6562 16.5 14.1875 16.5H9.78125C9.3125 16.5 8.875 16.25 8.6875 15.8125L8.03125 14.5H5.5ZM18.1875 13L16.6562 6.90625C16.5938 6.65625 16.4062 6.5 16.1875 6.5H7.8125C7.5625 6.5 7.375 6.65625 7.3125 6.90625L5.78125 13H8.1875C8.65625 13 9.09375 13.2812 9.3125 13.7188L9.9375 15H14.0312L14.6875 13.7188C14.875 13.2812 15.3125 13 15.7812 13H18.1875ZM4 14.25C4 14.0938 4 13.9375 4.03125 13.7812L5.84375 6.53125C6.09375 5.625 6.875 5 7.8125 5H16.1875C17.0938 5 17.9062 5.625 18.125 6.53125L19.9375 13.7812C19.9688 13.9375 20 14.0938 20 14.25V17C20 18.125 19.0938 19 18 19H6C4.875 19 4 18.125 4 17V14.25Z" fill="currentColor"/>
|
|
@@ -249,7 +305,7 @@ const CourierIconSVGs = {
|
|
|
249
305
|
<path d="M5.5 11C5.0625 11 4.75 10.6875 4.75 10.25V5.75C4.75 5.34375 5.0625 5 5.5 5C5.90625 5 6.25 5.34375 6.25 5.75V8.28125L6.875 7.53125C8.15625 6 10.0625 5 12.25 5C16.0938 5 19.25 8.15625 19.25 12C19.25 15.875 16.0938 19 12.25 19C10.6562 19 9.21875 18.5 8.03125 17.625C7.71875 17.375 7.625 16.9062 7.875 16.5625C8.125 16.2188 8.59375 16.1562 8.9375 16.4062C9.84375 17.0938 11 17.5 12.25 17.5C15.2812 17.5 17.75 15.0625 17.75 12C17.75 8.96875 15.2812 6.5 12.25 6.5C10.5312 6.5 9.03125 7.28125 8 8.5L7.15625 9.5H10C10.4062 9.5 10.75 9.84375 10.75 10.25C10.75 10.6875 10.4062 11 10 11H5.5Z" fill="currentColor"/>
|
|
250
306
|
</svg>`
|
|
251
307
|
};
|
|
252
|
-
class CourierIcon extends
|
|
308
|
+
class CourierIcon extends CourierBaseElement {
|
|
253
309
|
constructor(color, svg) {
|
|
254
310
|
super();
|
|
255
311
|
__publicField2(this, "_color");
|
|
@@ -266,6 +322,9 @@ class CourierIcon extends HTMLElement {
|
|
|
266
322
|
shadow.appendChild(this._style);
|
|
267
323
|
this.refresh();
|
|
268
324
|
}
|
|
325
|
+
static get id() {
|
|
326
|
+
return "courier-icon";
|
|
327
|
+
}
|
|
269
328
|
getStyles(color) {
|
|
270
329
|
return `
|
|
271
330
|
:host {
|
|
@@ -300,10 +359,7 @@ class CourierIcon extends HTMLElement {
|
|
|
300
359
|
this.refresh();
|
|
301
360
|
}
|
|
302
361
|
}
|
|
303
|
-
|
|
304
|
-
customElements.define("courier-icon", CourierIcon);
|
|
305
|
-
}
|
|
306
|
-
class CourierLink extends HTMLElement {
|
|
362
|
+
class CourierLink extends CourierBaseElement {
|
|
307
363
|
constructor() {
|
|
308
364
|
super();
|
|
309
365
|
__publicField2(this, "link");
|
|
@@ -367,6 +423,9 @@ class CourierLink extends HTMLElement {
|
|
|
367
423
|
this.updateUnderline();
|
|
368
424
|
this.updateMode();
|
|
369
425
|
}
|
|
426
|
+
static get id() {
|
|
427
|
+
return "courier-link";
|
|
428
|
+
}
|
|
370
429
|
connectedCallback() {
|
|
371
430
|
const slot = document.createElement("slot");
|
|
372
431
|
this.link.appendChild(slot);
|
|
@@ -465,23 +524,18 @@ __publicField2(CourierLink, "observedAttributes", [
|
|
|
465
524
|
"font-family",
|
|
466
525
|
"font-size"
|
|
467
526
|
]);
|
|
468
|
-
|
|
469
|
-
customElements.define("courier-link", CourierLink);
|
|
470
|
-
}
|
|
471
|
-
class CourierElement extends CourierSystemThemeElement {
|
|
527
|
+
class CourierFactoryElement extends CourierSystemThemeElement {
|
|
472
528
|
constructor() {
|
|
473
529
|
super();
|
|
474
|
-
__publicField2(this, "shadow");
|
|
475
|
-
this.shadow = this.attachShadow({ mode: "open" });
|
|
476
530
|
}
|
|
477
531
|
// Build the element with a factory function
|
|
478
532
|
build(newElement) {
|
|
479
533
|
if (newElement === null) {
|
|
480
|
-
this.
|
|
534
|
+
this.replaceChildren();
|
|
481
535
|
return;
|
|
482
536
|
}
|
|
483
537
|
const element = newElement ?? this.defaultElement();
|
|
484
|
-
this.
|
|
538
|
+
this.replaceChildren(element);
|
|
485
539
|
}
|
|
486
540
|
// Default element to be used if no factory is provided
|
|
487
541
|
defaultElement() {
|
|
@@ -495,7 +549,7 @@ class CourierElement extends CourierSystemThemeElement {
|
|
|
495
549
|
return element;
|
|
496
550
|
}
|
|
497
551
|
}
|
|
498
|
-
class CourierInfoState extends
|
|
552
|
+
class CourierInfoState extends CourierFactoryElement {
|
|
499
553
|
constructor(props) {
|
|
500
554
|
super();
|
|
501
555
|
__publicField2(this, "_props");
|
|
@@ -505,6 +559,9 @@ class CourierInfoState extends CourierElement {
|
|
|
505
559
|
__publicField2(this, "_buttonClickCallback", null);
|
|
506
560
|
this._props = props;
|
|
507
561
|
}
|
|
562
|
+
static get id() {
|
|
563
|
+
return "courier-info-state";
|
|
564
|
+
}
|
|
508
565
|
defaultElement() {
|
|
509
566
|
var _a, _b;
|
|
510
567
|
const container = document.createElement("div");
|
|
@@ -519,7 +576,7 @@ class CourierInfoState extends CourierElement {
|
|
|
519
576
|
container.appendChild(this._style);
|
|
520
577
|
container.appendChild(this._title);
|
|
521
578
|
container.appendChild(this._button);
|
|
522
|
-
this.
|
|
579
|
+
this.appendChild(container);
|
|
523
580
|
(_b = this._button) == null ? void 0 : _b.addEventListener("click", () => {
|
|
524
581
|
if (this._buttonClickCallback) {
|
|
525
582
|
this._buttonClickCallback();
|
|
@@ -549,6 +606,8 @@ class CourierInfoState extends CourierElement {
|
|
|
549
606
|
gap: 16px;
|
|
550
607
|
text-align: center;
|
|
551
608
|
padding: 24px;
|
|
609
|
+
box-sizing: border-box;
|
|
610
|
+
height: 100%;
|
|
552
611
|
}
|
|
553
612
|
|
|
554
613
|
.container h2 {
|
|
@@ -573,10 +632,7 @@ class CourierInfoState extends CourierElement {
|
|
|
573
632
|
this._buttonClickCallback = callback;
|
|
574
633
|
}
|
|
575
634
|
}
|
|
576
|
-
|
|
577
|
-
customElements.define("courier-info-state", CourierInfoState);
|
|
578
|
-
}
|
|
579
|
-
class CourierIconButton extends HTMLElement {
|
|
635
|
+
class CourierIconButton extends CourierBaseElement {
|
|
580
636
|
constructor(svg, color, backgroundColor, hoverBackgroundColor, activeBackgroundColor, borderRadius, height, width) {
|
|
581
637
|
super();
|
|
582
638
|
__publicField2(this, "_backgroundColor");
|
|
@@ -604,6 +660,9 @@ class CourierIconButton extends HTMLElement {
|
|
|
604
660
|
this._button.appendChild(this._icon);
|
|
605
661
|
shadow.appendChild(this._button);
|
|
606
662
|
}
|
|
663
|
+
static get id() {
|
|
664
|
+
return "courier-icon-button";
|
|
665
|
+
}
|
|
607
666
|
refresh() {
|
|
608
667
|
this._style.textContent = this.getStyles();
|
|
609
668
|
}
|
|
@@ -669,21 +728,29 @@ class CourierIconButton extends HTMLElement {
|
|
|
669
728
|
this.refresh();
|
|
670
729
|
}
|
|
671
730
|
}
|
|
672
|
-
|
|
673
|
-
|
|
731
|
+
function registerElement(element) {
|
|
732
|
+
if (typeof window !== "undefined" && !customElements.get(element.id)) {
|
|
733
|
+
customElements.define(element.id, element);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
function injectGlobalStyle(styleId, styles) {
|
|
737
|
+
const selector = `style[data-${styleId}]`;
|
|
738
|
+
const existingStyle = document.querySelector(selector);
|
|
739
|
+
if (!existingStyle) {
|
|
740
|
+
const style = document.createElement("style");
|
|
741
|
+
style.setAttribute(`data-${styleId}`, "");
|
|
742
|
+
style.textContent = styles;
|
|
743
|
+
document.head.appendChild(style);
|
|
744
|
+
return style;
|
|
745
|
+
}
|
|
746
|
+
return existingStyle;
|
|
674
747
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
];
|
|
682
|
-
components.forEach(({ name, class: componentClass }) => {
|
|
683
|
-
if (!customElements.get(name)) {
|
|
684
|
-
customElements.define(name, componentClass);
|
|
685
|
-
}
|
|
686
|
-
});
|
|
748
|
+
registerElement(CourierButton);
|
|
749
|
+
registerElement(CourierIcon);
|
|
750
|
+
registerElement(CourierLink);
|
|
751
|
+
registerElement(CourierInfoState);
|
|
752
|
+
registerElement(CourierIconButton);
|
|
753
|
+
registerElement(CourierSystemThemeElement);
|
|
687
754
|
function copyMessage(message) {
|
|
688
755
|
const copy = {
|
|
689
756
|
...message
|
|
@@ -712,6 +779,9 @@ function copyInboxAction(action) {
|
|
|
712
779
|
return copy;
|
|
713
780
|
}
|
|
714
781
|
function copyInboxDataSet(dataSet) {
|
|
782
|
+
if (!dataSet) {
|
|
783
|
+
return void 0;
|
|
784
|
+
}
|
|
715
785
|
return {
|
|
716
786
|
...dataSet,
|
|
717
787
|
messages: dataSet.messages.map((message) => copyMessage(message))
|
|
@@ -722,6 +792,7 @@ function getMessageTime(message) {
|
|
|
722
792
|
const now = /* @__PURE__ */ new Date();
|
|
723
793
|
const messageDate = new Date(message.created);
|
|
724
794
|
const diffInSeconds = Math.floor((now.getTime() - messageDate.getTime()) / 1e3);
|
|
795
|
+
if (diffInSeconds < 5) return "Now";
|
|
725
796
|
if (diffInSeconds < 60) return `${diffInSeconds}s`;
|
|
726
797
|
if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)}m`;
|
|
727
798
|
if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)}h`;
|
|
@@ -729,29 +800,28 @@ function getMessageTime(message) {
|
|
|
729
800
|
if (diffInSeconds < 31536e3) return `${Math.floor(diffInSeconds / 604800)}w`;
|
|
730
801
|
return `${Math.floor(diffInSeconds / 31536e3)}y`;
|
|
731
802
|
}
|
|
732
|
-
class
|
|
803
|
+
class CourierInboxListItemMenu extends CourierBaseElement {
|
|
733
804
|
constructor(theme2) {
|
|
734
805
|
super();
|
|
735
806
|
// State
|
|
736
807
|
__publicField(this, "_theme");
|
|
737
808
|
__publicField(this, "_options", []);
|
|
738
|
-
// Components
|
|
739
|
-
__publicField(this, "_style");
|
|
740
809
|
this._theme = theme2;
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
810
|
+
}
|
|
811
|
+
static get id() {
|
|
812
|
+
return "courier-inbox-list-item-menu";
|
|
813
|
+
}
|
|
814
|
+
onComponentMounted() {
|
|
745
815
|
const menu = document.createElement("ul");
|
|
746
816
|
menu.className = "menu";
|
|
747
|
-
|
|
817
|
+
this.appendChild(menu);
|
|
748
818
|
}
|
|
749
|
-
getStyles() {
|
|
819
|
+
static getStyles(theme2) {
|
|
750
820
|
var _a, _b, _c;
|
|
751
|
-
const menu = (_c = (_b = (_a =
|
|
821
|
+
const menu = (_c = (_b = (_a = theme2.inbox) == null ? void 0 : _a.list) == null ? void 0 : _b.item) == null ? void 0 : _c.menu;
|
|
752
822
|
return `
|
|
753
|
-
|
|
754
|
-
display:
|
|
823
|
+
${CourierInboxListItemMenu.id} {
|
|
824
|
+
display: none;
|
|
755
825
|
position: absolute;
|
|
756
826
|
background: ${(menu == null ? void 0 : menu.backgroundColor) ?? "red"};
|
|
757
827
|
border: ${(menu == null ? void 0 : menu.border) ?? "1px solid red"};
|
|
@@ -764,12 +834,13 @@ class CourierListItemActionMenu extends HTMLElement {
|
|
|
764
834
|
overflow: hidden;
|
|
765
835
|
}
|
|
766
836
|
|
|
767
|
-
|
|
837
|
+
${CourierInboxListItemMenu.id}.visible {
|
|
838
|
+
display: block;
|
|
768
839
|
opacity: 1;
|
|
769
840
|
pointer-events: auto;
|
|
770
841
|
}
|
|
771
842
|
|
|
772
|
-
ul.menu {
|
|
843
|
+
${CourierInboxListItemMenu.id} ul.menu {
|
|
773
844
|
list-style: none;
|
|
774
845
|
margin: 0;
|
|
775
846
|
padding: 0;
|
|
@@ -777,7 +848,7 @@ class CourierListItemActionMenu extends HTMLElement {
|
|
|
777
848
|
flex-direction: row;
|
|
778
849
|
}
|
|
779
850
|
|
|
780
|
-
li.menu-item {
|
|
851
|
+
${CourierInboxListItemMenu.id} li.menu-item {
|
|
781
852
|
display: flex;
|
|
782
853
|
align-items: center;
|
|
783
854
|
justify-content: center;
|
|
@@ -792,11 +863,11 @@ class CourierListItemActionMenu extends HTMLElement {
|
|
|
792
863
|
this.renderMenu();
|
|
793
864
|
}
|
|
794
865
|
renderMenu() {
|
|
795
|
-
var _a, _b, _c
|
|
796
|
-
const menu =
|
|
866
|
+
var _a, _b, _c;
|
|
867
|
+
const menu = this.querySelector("ul.menu");
|
|
797
868
|
if (!menu) return;
|
|
798
869
|
menu.innerHTML = "";
|
|
799
|
-
const menuTheme = (
|
|
870
|
+
const menuTheme = (_c = (_b = (_a = this._theme.inbox) == null ? void 0 : _a.list) == null ? void 0 : _b.item) == null ? void 0 : _c.menu;
|
|
800
871
|
const cancelEvent = (e) => {
|
|
801
872
|
e.stopPropagation();
|
|
802
873
|
e.preventDefault();
|
|
@@ -818,15 +889,15 @@ class CourierListItemActionMenu extends HTMLElement {
|
|
|
818
889
|
});
|
|
819
890
|
}
|
|
820
891
|
show() {
|
|
892
|
+
this.style.display = "block";
|
|
821
893
|
this.classList.add("visible");
|
|
822
894
|
}
|
|
823
895
|
hide() {
|
|
896
|
+
this.style.display = "none";
|
|
824
897
|
this.classList.remove("visible");
|
|
825
898
|
}
|
|
826
899
|
}
|
|
827
|
-
|
|
828
|
-
customElements.define("courier-list-item-menu", CourierListItemActionMenu);
|
|
829
|
-
}
|
|
900
|
+
registerElement(CourierInboxListItemMenu);
|
|
830
901
|
const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
831
902
|
constructor() {
|
|
832
903
|
__publicField(this, "_inboxDataSet");
|
|
@@ -857,28 +928,22 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
|
857
928
|
removeDataStoreListener(listener) {
|
|
858
929
|
this._dataStoreListeners = this._dataStoreListeners.filter((l) => l !== listener);
|
|
859
930
|
}
|
|
860
|
-
async
|
|
861
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
931
|
+
async fetchCachableDataSet(props) {
|
|
932
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
862
933
|
if (props.canUseCache) {
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
break;
|
|
869
|
-
case "archive":
|
|
870
|
-
if (this._archiveDataSet) {
|
|
871
|
-
return this._archiveDataSet;
|
|
872
|
-
}
|
|
873
|
-
break;
|
|
934
|
+
if (props.feedType === "inbox" && this._inboxDataSet) {
|
|
935
|
+
return this._inboxDataSet;
|
|
936
|
+
}
|
|
937
|
+
if (props.feedType === "archive" && this._archiveDataSet) {
|
|
938
|
+
return this._archiveDataSet;
|
|
874
939
|
}
|
|
875
940
|
}
|
|
876
|
-
const response =
|
|
941
|
+
const response = await props.fetch;
|
|
877
942
|
return {
|
|
878
943
|
feedType: props.feedType,
|
|
879
|
-
messages: ((
|
|
880
|
-
canPaginate: ((
|
|
881
|
-
paginationCursor: ((
|
|
944
|
+
messages: ((_b = (_a = response.data) == null ? void 0 : _a.messages) == null ? void 0 : _b.nodes) ?? [],
|
|
945
|
+
canPaginate: ((_e = (_d = (_c = response.data) == null ? void 0 : _c.messages) == null ? void 0 : _d.pageInfo) == null ? void 0 : _e.hasNextPage) ?? false,
|
|
946
|
+
paginationCursor: ((_h = (_g = (_f = response.data) == null ? void 0 : _f.messages) == null ? void 0 : _g.pageInfo) == null ? void 0 : _h.startCursor) ?? null
|
|
882
947
|
};
|
|
883
948
|
}
|
|
884
949
|
async fetchUnreadCount(props) {
|
|
@@ -890,43 +955,43 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
|
890
955
|
return unreadCount ?? 0;
|
|
891
956
|
}
|
|
892
957
|
async load(props) {
|
|
893
|
-
var _a, _b
|
|
958
|
+
var _a, _b;
|
|
894
959
|
try {
|
|
895
|
-
|
|
960
|
+
const client = Courier.shared.client;
|
|
961
|
+
if (!(client == null ? void 0 : client.options.userId)) {
|
|
896
962
|
throw new Error("User is not signed in");
|
|
897
963
|
}
|
|
898
|
-
const properties = props ?? {
|
|
899
|
-
const [
|
|
900
|
-
this.
|
|
964
|
+
const properties = props ?? { canUseCache: true };
|
|
965
|
+
const [inboxDataSet, archiveDataSet, unreadCount] = await Promise.all([
|
|
966
|
+
this.fetchCachableDataSet({ fetch: client.inbox.getMessages(), feedType: "inbox", canUseCache: properties.canUseCache }),
|
|
967
|
+
this.fetchCachableDataSet({ fetch: client.inbox.getArchivedMessages(), feedType: "archive", canUseCache: properties.canUseCache }),
|
|
901
968
|
this.fetchUnreadCount(properties)
|
|
902
969
|
]);
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
this._inboxDataSet = dataSet;
|
|
906
|
-
break;
|
|
907
|
-
case "archive":
|
|
908
|
-
this._archiveDataSet = dataSet;
|
|
909
|
-
break;
|
|
910
|
-
}
|
|
970
|
+
this._inboxDataSet = inboxDataSet;
|
|
971
|
+
this._archiveDataSet = archiveDataSet;
|
|
911
972
|
this._unreadCount = unreadCount;
|
|
912
973
|
this._dataStoreListeners.forEach((listener) => {
|
|
913
|
-
var _a2, _b2,
|
|
914
|
-
|
|
915
|
-
|
|
974
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
975
|
+
if (this._inboxDataSet) {
|
|
976
|
+
(_b2 = (_a2 = listener.events).onDataSetChange) == null ? void 0 : _b2.call(_a2, this._inboxDataSet, "inbox");
|
|
977
|
+
}
|
|
978
|
+
if (this._archiveDataSet) {
|
|
979
|
+
(_d = (_c = listener.events).onDataSetChange) == null ? void 0 : _d.call(_c, this._archiveDataSet, "archive");
|
|
980
|
+
}
|
|
981
|
+
(_f = (_e = listener.events).onUnreadCountChange) == null ? void 0 : _f.call(_e, this._unreadCount ?? 0);
|
|
916
982
|
});
|
|
917
983
|
} catch (error) {
|
|
918
|
-
(
|
|
984
|
+
(_b = (_a = Courier.shared.client) == null ? void 0 : _a.options.logger) == null ? void 0 : _b.error("Error loading inbox:", error);
|
|
919
985
|
this._dataStoreListeners.forEach((listener) => {
|
|
920
986
|
var _a2, _b2;
|
|
921
987
|
(_b2 = (_a2 = listener.events).onError) == null ? void 0 : _b2.call(_a2, error);
|
|
922
988
|
});
|
|
923
989
|
}
|
|
924
990
|
}
|
|
925
|
-
|
|
991
|
+
// Connect the socket
|
|
926
992
|
async listenForUpdates() {
|
|
927
993
|
var _a, _b;
|
|
928
994
|
try {
|
|
929
|
-
await this.ensureDataSetsLoaded();
|
|
930
995
|
await this.connectSocket();
|
|
931
996
|
} catch (error) {
|
|
932
997
|
(_b = (_a = Courier.shared.client) == null ? void 0 : _a.options.logger) == null ? void 0 : _b.error("Error listening for updates:", error);
|
|
@@ -936,85 +1001,73 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
|
936
1001
|
});
|
|
937
1002
|
}
|
|
938
1003
|
}
|
|
939
|
-
/** Fetch either/both datasets if they aren't already loaded. */
|
|
940
|
-
async ensureDataSetsLoaded() {
|
|
941
|
-
let dataSetPromises = [];
|
|
942
|
-
if (!this._inboxDataSet) {
|
|
943
|
-
dataSetPromises.push(this.load({ feedType: "inbox", canUseCache: true }));
|
|
944
|
-
}
|
|
945
|
-
if (!this._archiveDataSet) {
|
|
946
|
-
dataSetPromises.push(this.load({ feedType: "archive", canUseCache: true }));
|
|
947
|
-
}
|
|
948
|
-
await Promise.all(dataSetPromises);
|
|
949
|
-
}
|
|
950
1004
|
async connectSocket() {
|
|
951
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k
|
|
1005
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
952
1006
|
const socket = (_a = Courier.shared.client) == null ? void 0 : _a.inbox.socket;
|
|
953
1007
|
try {
|
|
954
1008
|
if (!socket) {
|
|
955
1009
|
(_c = (_b = Courier.shared.client) == null ? void 0 : _b.options.logger) == null ? void 0 : _c.info("CourierInbox socket not available");
|
|
956
1010
|
return;
|
|
957
1011
|
}
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
(_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.");
|
|
1012
|
+
if (socket.isConnecting || socket.isOpen) {
|
|
1013
|
+
(_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}]`);
|
|
961
1014
|
return;
|
|
962
1015
|
}
|
|
963
|
-
socket.
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
if (event.messageId) {
|
|
969
|
-
message = this.getMessage({ messageId: event.messageId });
|
|
1016
|
+
socket.addMessageEventListener((event) => {
|
|
1017
|
+
if (event.event === InboxMessageEvent.NewMessage) {
|
|
1018
|
+
const message2 = event.data;
|
|
1019
|
+
this.addMessage(message2, 0, "inbox");
|
|
1020
|
+
return;
|
|
970
1021
|
}
|
|
1022
|
+
const message = this.getMessage({ messageId: event.messageId });
|
|
971
1023
|
switch (event.event) {
|
|
972
|
-
case
|
|
1024
|
+
case InboxMessageEvent.MarkAllRead:
|
|
973
1025
|
this.readAllMessages({ canCallApi: false });
|
|
974
1026
|
break;
|
|
975
|
-
case
|
|
1027
|
+
case InboxMessageEvent.Read:
|
|
976
1028
|
if (message) {
|
|
977
1029
|
this.readMessage({ message, canCallApi: false });
|
|
978
1030
|
}
|
|
979
1031
|
break;
|
|
980
|
-
case
|
|
1032
|
+
case InboxMessageEvent.Unread:
|
|
981
1033
|
if (message) {
|
|
982
1034
|
this.unreadMessage({ message, canCallApi: false });
|
|
983
1035
|
}
|
|
984
1036
|
break;
|
|
985
|
-
case
|
|
1037
|
+
case InboxMessageEvent.Opened:
|
|
986
1038
|
if (message) {
|
|
987
1039
|
this.openMessage({ message, canCallApi: false });
|
|
988
1040
|
}
|
|
989
1041
|
break;
|
|
990
|
-
case
|
|
1042
|
+
case InboxMessageEvent.Archive:
|
|
991
1043
|
if (message) {
|
|
992
1044
|
this.archiveMessage({ message, canCallApi: false });
|
|
993
1045
|
}
|
|
994
1046
|
break;
|
|
995
|
-
case
|
|
1047
|
+
case InboxMessageEvent.ArchiveRead:
|
|
996
1048
|
this.archiveReadMessages({ canCallApi: false });
|
|
997
1049
|
break;
|
|
998
|
-
case
|
|
1050
|
+
case InboxMessageEvent.ArchiveAll:
|
|
1051
|
+
this.archiveAllMessages({ canCallApi: false });
|
|
1052
|
+
break;
|
|
1053
|
+
case InboxMessageEvent.Clicked:
|
|
999
1054
|
if (message) {
|
|
1000
1055
|
this.clickMessage({ message, canCallApi: false });
|
|
1001
1056
|
}
|
|
1002
1057
|
break;
|
|
1003
|
-
case
|
|
1058
|
+
case InboxMessageEvent.Unarchive:
|
|
1004
1059
|
if (message) {
|
|
1005
1060
|
this.unarchiveMessage({ message, canCallApi: false });
|
|
1006
1061
|
}
|
|
1007
1062
|
break;
|
|
1008
|
-
case
|
|
1063
|
+
case InboxMessageEvent.Unopened:
|
|
1009
1064
|
break;
|
|
1010
1065
|
}
|
|
1011
|
-
};
|
|
1066
|
+
});
|
|
1012
1067
|
await socket.connect();
|
|
1013
|
-
|
|
1014
|
-
socket.keepAlive();
|
|
1015
|
-
(_j = (_i = Courier.shared.client) == null ? void 0 : _i.options.logger) == null ? void 0 : _j.info("CourierInbox socket connected");
|
|
1068
|
+
(_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}]`);
|
|
1016
1069
|
} catch (error) {
|
|
1017
|
-
(
|
|
1070
|
+
(_k = (_j = Courier.shared.client) == null ? void 0 : _j.options.logger) == null ? void 0 : _k.error("Failed to connect socket:", error);
|
|
1018
1071
|
}
|
|
1019
1072
|
}
|
|
1020
1073
|
/**
|
|
@@ -1024,6 +1077,9 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
|
1024
1077
|
*/
|
|
1025
1078
|
getMessage(props) {
|
|
1026
1079
|
var _a, _b;
|
|
1080
|
+
if (!props.messageId) {
|
|
1081
|
+
return void 0;
|
|
1082
|
+
}
|
|
1027
1083
|
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));
|
|
1028
1084
|
}
|
|
1029
1085
|
/**
|
|
@@ -1451,8 +1507,12 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
|
1451
1507
|
this._archiveDataSet = archive;
|
|
1452
1508
|
this._dataStoreListeners.forEach((listener) => {
|
|
1453
1509
|
var _a, _b, _c, _d, _e, _f;
|
|
1454
|
-
|
|
1455
|
-
|
|
1510
|
+
if (this._inboxDataSet) {
|
|
1511
|
+
(_b = (_a = listener.events).onDataSetChange) == null ? void 0 : _b.call(_a, this._inboxDataSet, "inbox");
|
|
1512
|
+
}
|
|
1513
|
+
if (this._archiveDataSet) {
|
|
1514
|
+
(_d = (_c = listener.events).onDataSetChange) == null ? void 0 : _d.call(_c, this._archiveDataSet, "archive");
|
|
1515
|
+
}
|
|
1456
1516
|
(_f = (_e = listener.events).onUnreadCountChange) == null ? void 0 : _f.call(_e, unreadCount);
|
|
1457
1517
|
});
|
|
1458
1518
|
}
|
|
@@ -1518,7 +1578,7 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
|
1518
1578
|
};
|
|
1519
1579
|
__publicField(_CourierInboxDatastore, "instance");
|
|
1520
1580
|
let CourierInboxDatastore = _CourierInboxDatastore;
|
|
1521
|
-
class
|
|
1581
|
+
class CourierInboxListItem extends CourierBaseElement {
|
|
1522
1582
|
constructor(theme2) {
|
|
1523
1583
|
super();
|
|
1524
1584
|
// State
|
|
@@ -1530,7 +1590,6 @@ class CourierListItem extends HTMLElement {
|
|
|
1530
1590
|
__publicField(this, "_titleElement");
|
|
1531
1591
|
__publicField(this, "_subtitleElement");
|
|
1532
1592
|
__publicField(this, "_timeElement");
|
|
1533
|
-
__publicField(this, "_style");
|
|
1534
1593
|
__publicField(this, "_menu");
|
|
1535
1594
|
__publicField(this, "_unreadIndicator");
|
|
1536
1595
|
__publicField(this, "_actionsContainer");
|
|
@@ -1543,27 +1602,30 @@ class CourierListItem extends HTMLElement {
|
|
|
1543
1602
|
__publicField(this, "onItemActionClick", null);
|
|
1544
1603
|
this._theme = theme2;
|
|
1545
1604
|
this._isMobile = "ontouchstart" in window;
|
|
1546
|
-
|
|
1605
|
+
this.render();
|
|
1606
|
+
}
|
|
1607
|
+
static get id() {
|
|
1608
|
+
return "courier-inbox-list-item";
|
|
1609
|
+
}
|
|
1610
|
+
render() {
|
|
1547
1611
|
const contentContainer = document.createElement("div");
|
|
1548
1612
|
contentContainer.className = "content-container";
|
|
1549
1613
|
this._titleElement = document.createElement("p");
|
|
1550
|
-
this._titleElement.
|
|
1614
|
+
this._titleElement.className = "title";
|
|
1551
1615
|
this._subtitleElement = document.createElement("p");
|
|
1552
|
-
this._subtitleElement.
|
|
1616
|
+
this._subtitleElement.className = "subtitle";
|
|
1553
1617
|
this._actionsContainer = document.createElement("div");
|
|
1554
1618
|
this._actionsContainer.className = "actions-container";
|
|
1555
1619
|
contentContainer.appendChild(this._titleElement);
|
|
1556
1620
|
contentContainer.appendChild(this._subtitleElement);
|
|
1557
1621
|
contentContainer.appendChild(this._actionsContainer);
|
|
1558
1622
|
this._timeElement = document.createElement("p");
|
|
1559
|
-
this._timeElement.
|
|
1623
|
+
this._timeElement.className = "time";
|
|
1560
1624
|
this._unreadIndicator = document.createElement("div");
|
|
1561
1625
|
this._unreadIndicator.className = "unread-indicator";
|
|
1562
|
-
this.
|
|
1563
|
-
this._refreshStyles();
|
|
1564
|
-
this._menu = new CourierListItemActionMenu(this._theme);
|
|
1626
|
+
this._menu = new CourierInboxListItemMenu(this._theme);
|
|
1565
1627
|
this._menu.setOptions(this._getMenuOptions());
|
|
1566
|
-
|
|
1628
|
+
this.append(this._unreadIndicator, contentContainer, this._timeElement, this._menu);
|
|
1567
1629
|
const cancelPropagation = (e) => {
|
|
1568
1630
|
e.stopPropagation();
|
|
1569
1631
|
e.preventDefault();
|
|
@@ -1572,7 +1634,7 @@ class CourierListItem extends HTMLElement {
|
|
|
1572
1634
|
this._menu.addEventListener("pointerdown", cancelPropagation);
|
|
1573
1635
|
this._menu.addEventListener("click", cancelPropagation);
|
|
1574
1636
|
this.addEventListener("click", (e) => {
|
|
1575
|
-
if (this._menu.contains(e.target) || e.composedPath().includes(this._menu)) {
|
|
1637
|
+
if (this._menu && (this._menu.contains(e.target) || e.composedPath().includes(this._menu))) {
|
|
1576
1638
|
return;
|
|
1577
1639
|
}
|
|
1578
1640
|
if (this._message && this.onItemClick && !(e.target instanceof CourierIcon) && !this._isLongPress) {
|
|
@@ -1582,6 +1644,133 @@ class CourierListItem extends HTMLElement {
|
|
|
1582
1644
|
this._setupHoverBehavior();
|
|
1583
1645
|
this._setupLongPressBehavior();
|
|
1584
1646
|
}
|
|
1647
|
+
static getStyles(theme2) {
|
|
1648
|
+
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;
|
|
1649
|
+
const list = (_a = theme2.inbox) == null ? void 0 : _a.list;
|
|
1650
|
+
return `
|
|
1651
|
+
${CourierInboxListItem.id} {
|
|
1652
|
+
display: flex;
|
|
1653
|
+
flex-direction: row;
|
|
1654
|
+
align-items: flex-start;
|
|
1655
|
+
justify-content: space-between;
|
|
1656
|
+
border-bottom: ${((_b = list == null ? void 0 : list.item) == null ? void 0 : _b.divider) ?? "1px solid red"};
|
|
1657
|
+
font-family: inherit;
|
|
1658
|
+
cursor: pointer;
|
|
1659
|
+
transition: background-color 0.2s ease;
|
|
1660
|
+
margin: 0;
|
|
1661
|
+
width: 100%;
|
|
1662
|
+
box-sizing: border-box;
|
|
1663
|
+
padding: 12px 20px;
|
|
1664
|
+
position: relative;
|
|
1665
|
+
background-color: ${((_c = list == null ? void 0 : list.item) == null ? void 0 : _c.backgroundColor) ?? "transparent"};
|
|
1666
|
+
user-select: none;
|
|
1667
|
+
-webkit-user-select: none;
|
|
1668
|
+
-moz-user-select: none;
|
|
1669
|
+
-ms-user-select: none;
|
|
1670
|
+
touch-action: manipulation;
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
/* Base hover / active */
|
|
1674
|
+
@media (hover: hover) {
|
|
1675
|
+
${CourierInboxListItem.id}:hover {
|
|
1676
|
+
background-color: ${((_d = list == null ? void 0 : list.item) == null ? void 0 : _d.hoverBackgroundColor) ?? "red"};
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
${CourierInboxListItem.id}:active {
|
|
1681
|
+
background-color: ${((_e = list == null ? void 0 : list.item) == null ? void 0 : _e.activeBackgroundColor) ?? "red"};
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
/* Menu hover / active */
|
|
1685
|
+
@media (hover: hover) {
|
|
1686
|
+
${CourierInboxListItem.id}:hover:has(courier-inbox-list-item-menu:hover, courier-inbox-list-item-menu *:hover, courier-button:hover, courier-button *:hover) {
|
|
1687
|
+
background-color: ${((_f = list == null ? void 0 : list.item) == null ? void 0 : _f.backgroundColor) ?? "transparent"};
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
${CourierInboxListItem.id}:active:has(courier-inbox-list-item-menu:active, courier-inbox-list-item-menu *:active, courier-button:active, courier-button *:active) {
|
|
1692
|
+
background-color: ${((_g = list == null ? void 0 : list.item) == null ? void 0 : _g.backgroundColor) ?? "transparent"};
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
${CourierInboxListItem.id}:last-child {
|
|
1696
|
+
border-bottom: none;
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
${CourierInboxListItem.id} .unread-indicator {
|
|
1700
|
+
position: absolute;
|
|
1701
|
+
top: 28px;
|
|
1702
|
+
left: 6px;
|
|
1703
|
+
width: 8px;
|
|
1704
|
+
height: 8px;
|
|
1705
|
+
border-radius: 50%;
|
|
1706
|
+
background-color: ${((_h = list == null ? void 0 : list.item) == null ? void 0 : _h.unreadIndicatorColor) ?? "red"};
|
|
1707
|
+
display: none;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
${CourierInboxListItem.id}.unread .unread-indicator {
|
|
1711
|
+
display: block;
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
${CourierInboxListItem.id} .content-container {
|
|
1715
|
+
flex: 1;
|
|
1716
|
+
display: flex;
|
|
1717
|
+
flex-direction: column;
|
|
1718
|
+
margin-right: 12px;
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
${CourierInboxListItem.id} p {
|
|
1722
|
+
margin: 0;
|
|
1723
|
+
overflow-wrap: break-word;
|
|
1724
|
+
word-break: break-word;
|
|
1725
|
+
hyphens: auto;
|
|
1726
|
+
line-height: 1.4;
|
|
1727
|
+
user-select: none;
|
|
1728
|
+
-webkit-user-select: none;
|
|
1729
|
+
-moz-user-select: none;
|
|
1730
|
+
-ms-user-select: none;
|
|
1731
|
+
text-align: left;
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
${CourierInboxListItem.id} .title {
|
|
1735
|
+
font-family: ${((_j = (_i = list == null ? void 0 : list.item) == null ? void 0 : _i.title) == null ? void 0 : _j.family) ?? "inherit"};
|
|
1736
|
+
font-size: ${((_l = (_k = list == null ? void 0 : list.item) == null ? void 0 : _k.title) == null ? void 0 : _l.size) ?? "14px"};
|
|
1737
|
+
color: ${((_n = (_m = list == null ? void 0 : list.item) == null ? void 0 : _m.title) == null ? void 0 : _n.color) ?? "red"};
|
|
1738
|
+
margin-bottom: 4px;
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
${CourierInboxListItem.id} .subtitle {
|
|
1742
|
+
font-family: ${((_p = (_o = list == null ? void 0 : list.item) == null ? void 0 : _o.subtitle) == null ? void 0 : _p.family) ?? "inherit"};
|
|
1743
|
+
font-size: ${((_r = (_q = list == null ? void 0 : list.item) == null ? void 0 : _q.subtitle) == null ? void 0 : _r.size) ?? "14px"};
|
|
1744
|
+
color: ${((_t = (_s = list == null ? void 0 : list.item) == null ? void 0 : _s.subtitle) == null ? void 0 : _t.color) ?? "red"};
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
${CourierInboxListItem.id} .time {
|
|
1748
|
+
font-family: ${((_v = (_u = list == null ? void 0 : list.item) == null ? void 0 : _u.time) == null ? void 0 : _v.family) ?? "inherit"};
|
|
1749
|
+
font-size: ${((_x = (_w = list == null ? void 0 : list.item) == null ? void 0 : _w.time) == null ? void 0 : _x.size) ?? "14px"};
|
|
1750
|
+
color: ${((_z = (_y = list == null ? void 0 : list.item) == null ? void 0 : _y.time) == null ? void 0 : _z.color) ?? "red"};
|
|
1751
|
+
text-align: right;
|
|
1752
|
+
white-space: nowrap;
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
${CourierInboxListItem.id} courier-inbox-list-item-menu {
|
|
1756
|
+
z-index: 1;
|
|
1757
|
+
position: absolute;
|
|
1758
|
+
top: 8px;
|
|
1759
|
+
right: 8px;
|
|
1760
|
+
display: none;
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
${CourierInboxListItem.id} .actions-container {
|
|
1764
|
+
display: flex;
|
|
1765
|
+
margin-top: 10px;
|
|
1766
|
+
flex-wrap: wrap;
|
|
1767
|
+
flex-direction: row;
|
|
1768
|
+
align-items: center;
|
|
1769
|
+
gap: 8px;
|
|
1770
|
+
display: none;
|
|
1771
|
+
}
|
|
1772
|
+
`;
|
|
1773
|
+
}
|
|
1585
1774
|
_setupHoverBehavior() {
|
|
1586
1775
|
if (!this._isMobile) {
|
|
1587
1776
|
this.addEventListener("mouseenter", () => {
|
|
@@ -1674,7 +1863,7 @@ class CourierListItem extends HTMLElement {
|
|
|
1674
1863
|
_showMenu() {
|
|
1675
1864
|
var _a, _b, _c;
|
|
1676
1865
|
const menu = (_c = (_b = (_a = this._theme.inbox) == null ? void 0 : _a.list) == null ? void 0 : _b.item) == null ? void 0 : _c.menu;
|
|
1677
|
-
if (menu && menu.enabled) {
|
|
1866
|
+
if (menu && menu.enabled && this._menu && this._timeElement) {
|
|
1678
1867
|
this._menu.setOptions(this._getMenuOptions());
|
|
1679
1868
|
this._menu.style.display = "block";
|
|
1680
1869
|
this._menu.show();
|
|
@@ -1684,158 +1873,12 @@ class CourierListItem extends HTMLElement {
|
|
|
1684
1873
|
_hideMenu() {
|
|
1685
1874
|
var _a, _b, _c;
|
|
1686
1875
|
const menu = (_c = (_b = (_a = this._theme.inbox) == null ? void 0 : _a.list) == null ? void 0 : _b.item) == null ? void 0 : _c.menu;
|
|
1687
|
-
if (menu && menu.enabled) {
|
|
1876
|
+
if (menu && menu.enabled && this._menu && this._timeElement) {
|
|
1688
1877
|
this._menu.hide();
|
|
1689
1878
|
this._menu.style.display = "none";
|
|
1690
1879
|
this._timeElement.style.opacity = "1";
|
|
1691
1880
|
}
|
|
1692
1881
|
}
|
|
1693
|
-
_getStyles() {
|
|
1694
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1695
|
-
const listItem = (_b = (_a = this._theme.inbox) == null ? void 0 : _a.list) == null ? void 0 : _b.item;
|
|
1696
|
-
return `
|
|
1697
|
-
:host {
|
|
1698
|
-
display: flex;
|
|
1699
|
-
flex-direction: row;
|
|
1700
|
-
align-items: flex-start;
|
|
1701
|
-
justify-content: space-between;
|
|
1702
|
-
border-bottom: ${(listItem == null ? void 0 : listItem.divider) ?? "1px solid red"};
|
|
1703
|
-
font-family: inherit;
|
|
1704
|
-
cursor: pointer;
|
|
1705
|
-
transition: background-color 0.2s ease;
|
|
1706
|
-
margin: 0;
|
|
1707
|
-
width: 100%;
|
|
1708
|
-
box-sizing: border-box;
|
|
1709
|
-
padding: 12px 20px;
|
|
1710
|
-
position: relative;
|
|
1711
|
-
background-color: ${(listItem == null ? void 0 : listItem.backgroundColor) ?? "transparent"};
|
|
1712
|
-
user-select: none;
|
|
1713
|
-
-webkit-user-select: none;
|
|
1714
|
-
-moz-user-select: none;
|
|
1715
|
-
-ms-user-select: none;
|
|
1716
|
-
touch-action: manipulation;
|
|
1717
|
-
}
|
|
1718
|
-
|
|
1719
|
-
/* ───────────────────────── Base hover / active ────────────────── */
|
|
1720
|
-
@media (hover: hover) {
|
|
1721
|
-
:host(:hover) {
|
|
1722
|
-
background-color: ${(listItem == null ? void 0 : listItem.hoverBackgroundColor) ?? "red"};
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
:host(:active) {
|
|
1726
|
-
background-color: ${(listItem == null ? void 0 : listItem.activeBackgroundColor) ?? "red"};
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
/* ───────────────────────── Menu hover / active ────────────────── */
|
|
1730
|
-
@media (hover: hover) {
|
|
1731
|
-
:host(:hover):has(courier-list-item-menu:hover, courier-list-item-menu *:hover, courier-button:hover, courier-button *:hover) {
|
|
1732
|
-
background-color: ${(listItem == null ? void 0 : listItem.backgroundColor) ?? "transparent"};
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
:host(:active):has(courier-list-item-menu:active, courier-list-item-menu *:active, courier-button:active, courier-button *:active) {
|
|
1736
|
-
background-color: ${(listItem == null ? void 0 : listItem.backgroundColor) ?? "transparent"};
|
|
1737
|
-
}
|
|
1738
|
-
|
|
1739
|
-
:host(:last-child) {
|
|
1740
|
-
border-bottom: none;
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
.unread-indicator {
|
|
1744
|
-
position: absolute;
|
|
1745
|
-
top: 28px;
|
|
1746
|
-
left: 6px;
|
|
1747
|
-
width: 8px;
|
|
1748
|
-
height: 8px;
|
|
1749
|
-
border-radius: 50%;
|
|
1750
|
-
background-color: ${(listItem == null ? void 0 : listItem.unreadIndicatorColor) ?? "red"};
|
|
1751
|
-
display: none;
|
|
1752
|
-
}
|
|
1753
|
-
|
|
1754
|
-
:host(.unread) .unread-indicator {
|
|
1755
|
-
display: block;
|
|
1756
|
-
}
|
|
1757
|
-
|
|
1758
|
-
.content-container {
|
|
1759
|
-
flex: 1;
|
|
1760
|
-
display: flex;
|
|
1761
|
-
flex-direction: column;
|
|
1762
|
-
margin-right: 12px;
|
|
1763
|
-
}
|
|
1764
|
-
|
|
1765
|
-
p {
|
|
1766
|
-
margin: 0;
|
|
1767
|
-
overflow-wrap: break-word;
|
|
1768
|
-
word-break: break-word;
|
|
1769
|
-
hyphens: auto;
|
|
1770
|
-
line-height: 1.4;
|
|
1771
|
-
user-select: none;
|
|
1772
|
-
-webkit-user-select: none;
|
|
1773
|
-
-moz-user-select: none;
|
|
1774
|
-
-ms-user-select: none;
|
|
1775
|
-
text-align: left;
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
|
-
p[part='title'] {
|
|
1779
|
-
font-family: ${((_c = listItem == null ? void 0 : listItem.title) == null ? void 0 : _c.family) ?? "inherit"};
|
|
1780
|
-
font-size: ${((_d = listItem == null ? void 0 : listItem.title) == null ? void 0 : _d.size) ?? "14px"};
|
|
1781
|
-
color: ${((_e = listItem == null ? void 0 : listItem.title) == null ? void 0 : _e.color) ?? "red"};
|
|
1782
|
-
margin-bottom: 4px;
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1785
|
-
p[part='subtitle'] {
|
|
1786
|
-
font-family: ${((_f = listItem == null ? void 0 : listItem.subtitle) == null ? void 0 : _f.family) ?? "inherit"};
|
|
1787
|
-
font-size: ${((_g = listItem == null ? void 0 : listItem.subtitle) == null ? void 0 : _g.size) ?? "14px"};
|
|
1788
|
-
color: ${((_h = listItem == null ? void 0 : listItem.subtitle) == null ? void 0 : _h.color) ?? "red"};
|
|
1789
|
-
}
|
|
1790
|
-
|
|
1791
|
-
p[part='time'] {
|
|
1792
|
-
font-family: ${((_i = listItem == null ? void 0 : listItem.time) == null ? void 0 : _i.family) ?? "inherit"};
|
|
1793
|
-
font-size: ${((_j = listItem == null ? void 0 : listItem.time) == null ? void 0 : _j.size) ?? "14px"};
|
|
1794
|
-
color: ${((_k = listItem == null ? void 0 : listItem.time) == null ? void 0 : _k.color) ?? "red"};
|
|
1795
|
-
text-align: right;
|
|
1796
|
-
white-space: nowrap;
|
|
1797
|
-
}
|
|
1798
|
-
|
|
1799
|
-
courier-list-item-menu {
|
|
1800
|
-
z-index: 1;
|
|
1801
|
-
position: absolute;
|
|
1802
|
-
top: 8px;
|
|
1803
|
-
right: 8px;
|
|
1804
|
-
display: none; /* becomes block while visible */
|
|
1805
|
-
}
|
|
1806
|
-
|
|
1807
|
-
.actions-container {
|
|
1808
|
-
display: flex;
|
|
1809
|
-
margin-top: 10px;
|
|
1810
|
-
flex-wrap: wrap;
|
|
1811
|
-
flex-direction: row;
|
|
1812
|
-
align-items: center;
|
|
1813
|
-
gap: 8px;
|
|
1814
|
-
display: none;
|
|
1815
|
-
}
|
|
1816
|
-
|
|
1817
|
-
`;
|
|
1818
|
-
}
|
|
1819
|
-
_refreshStyles() {
|
|
1820
|
-
this._style.textContent = this._getStyles();
|
|
1821
|
-
}
|
|
1822
|
-
// Lifecycle hooks
|
|
1823
|
-
connectedCallback() {
|
|
1824
|
-
var _a, _b;
|
|
1825
|
-
const messageAttr = this.getAttribute("message");
|
|
1826
|
-
const feedTypeAttr = this.getAttribute("feed-type");
|
|
1827
|
-
if (feedTypeAttr) {
|
|
1828
|
-
this._feedType = feedTypeAttr;
|
|
1829
|
-
}
|
|
1830
|
-
if (messageAttr) {
|
|
1831
|
-
try {
|
|
1832
|
-
this._message = JSON.parse(messageAttr);
|
|
1833
|
-
this._updateContent();
|
|
1834
|
-
} catch (err) {
|
|
1835
|
-
(_b = (_a = Courier.shared.client) == null ? void 0 : _a.options.logger) == null ? void 0 : _b.error("CourierListItem – failed to parse message:", err);
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1839
1882
|
// Public API
|
|
1840
1883
|
setMessage(message, feedType) {
|
|
1841
1884
|
this._message = message;
|
|
@@ -1853,94 +1896,134 @@ class CourierListItem extends HTMLElement {
|
|
|
1853
1896
|
}
|
|
1854
1897
|
// Content rendering
|
|
1855
1898
|
_updateContent() {
|
|
1856
|
-
var _a, _b, _c
|
|
1899
|
+
var _a, _b, _c;
|
|
1857
1900
|
if (!this._message) {
|
|
1858
|
-
this._titleElement.textContent = "";
|
|
1859
|
-
this._subtitleElement.textContent = "";
|
|
1901
|
+
if (this._titleElement) this._titleElement.textContent = "";
|
|
1902
|
+
if (this._subtitleElement) this._subtitleElement.textContent = "";
|
|
1860
1903
|
return;
|
|
1861
1904
|
}
|
|
1862
1905
|
this.classList.toggle("unread", !this._message.read && this._feedType !== "archive");
|
|
1863
|
-
this._titleElement
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1906
|
+
if (this._titleElement) {
|
|
1907
|
+
this._titleElement.textContent = this._message.title || "Untitled Message";
|
|
1908
|
+
}
|
|
1909
|
+
if (this._subtitleElement) {
|
|
1910
|
+
this._subtitleElement.textContent = this._message.preview || this._message.body || "";
|
|
1911
|
+
}
|
|
1912
|
+
if (this._timeElement) {
|
|
1913
|
+
this._timeElement.textContent = getMessageTime(this._message);
|
|
1914
|
+
}
|
|
1915
|
+
if (this._menu) {
|
|
1916
|
+
this._menu.setOptions(this._getMenuOptions());
|
|
1917
|
+
}
|
|
1918
|
+
const hasActions = this._message.actions && this._message.actions.length > 0;
|
|
1919
|
+
if (this._actionsContainer) {
|
|
1920
|
+
this._actionsContainer.style.display = hasActions ? "flex" : "none";
|
|
1921
|
+
}
|
|
1922
|
+
const actionsTheme = (_c = (_b = (_a = this._theme.inbox) == null ? void 0 : _a.list) == null ? void 0 : _b.item) == null ? void 0 : _c.actions;
|
|
1923
|
+
if (this._actionsContainer && this._message.actions) {
|
|
1924
|
+
this._message.actions.forEach((action) => {
|
|
1925
|
+
var _a2, _b2, _c2, _d, _e;
|
|
1926
|
+
const actionButton = new CourierButton({
|
|
1927
|
+
text: action.content,
|
|
1928
|
+
variant: "secondary",
|
|
1929
|
+
backgroundColor: actionsTheme == null ? void 0 : actionsTheme.backgroundColor,
|
|
1930
|
+
hoverBackgroundColor: actionsTheme == null ? void 0 : actionsTheme.hoverBackgroundColor,
|
|
1931
|
+
activeBackgroundColor: actionsTheme == null ? void 0 : actionsTheme.activeBackgroundColor,
|
|
1932
|
+
border: actionsTheme == null ? void 0 : actionsTheme.border,
|
|
1933
|
+
borderRadius: actionsTheme == null ? void 0 : actionsTheme.borderRadius,
|
|
1934
|
+
shadow: actionsTheme == null ? void 0 : actionsTheme.shadow,
|
|
1935
|
+
fontFamily: (_a2 = actionsTheme == null ? void 0 : actionsTheme.font) == null ? void 0 : _a2.family,
|
|
1936
|
+
fontSize: (_b2 = actionsTheme == null ? void 0 : actionsTheme.font) == null ? void 0 : _b2.size,
|
|
1937
|
+
fontWeight: (_c2 = actionsTheme == null ? void 0 : actionsTheme.font) == null ? void 0 : _c2.weight,
|
|
1938
|
+
textColor: (_d = actionsTheme == null ? void 0 : actionsTheme.font) == null ? void 0 : _d.color,
|
|
1939
|
+
onClick: () => {
|
|
1940
|
+
if (this._message && this.onItemActionClick) {
|
|
1941
|
+
this.onItemActionClick(this._message, action);
|
|
1942
|
+
}
|
|
1888
1943
|
}
|
|
1889
|
-
}
|
|
1944
|
+
});
|
|
1945
|
+
(_e = this._actionsContainer) == null ? void 0 : _e.appendChild(actionButton);
|
|
1890
1946
|
});
|
|
1891
|
-
|
|
1892
|
-
});
|
|
1947
|
+
}
|
|
1893
1948
|
}
|
|
1894
1949
|
}
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
class CourierInboxSkeletonListItem extends HTMLElement {
|
|
1899
|
-
constructor(theme2, opacity) {
|
|
1950
|
+
registerElement(CourierInboxListItem);
|
|
1951
|
+
class CourierInboxSkeletonListItem extends CourierBaseElement {
|
|
1952
|
+
constructor(theme2) {
|
|
1900
1953
|
super();
|
|
1901
|
-
|
|
1902
|
-
__publicField(this, "
|
|
1903
|
-
this.
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
this.
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1954
|
+
__publicField(this, "_theme");
|
|
1955
|
+
__publicField(this, "_style");
|
|
1956
|
+
this._theme = theme2;
|
|
1957
|
+
}
|
|
1958
|
+
static get id() {
|
|
1959
|
+
return "courier-inbox-skeleton-list-item";
|
|
1960
|
+
}
|
|
1961
|
+
onComponentMounted() {
|
|
1962
|
+
this._style = injectGlobalStyle(CourierInboxSkeletonListItem.id, CourierInboxSkeletonListItem.getStyles(this._theme));
|
|
1963
|
+
this.render();
|
|
1964
|
+
}
|
|
1965
|
+
onComponentUnmounted() {
|
|
1966
|
+
var _a;
|
|
1967
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
1968
|
+
}
|
|
1969
|
+
render() {
|
|
1970
|
+
const firstRow = new CourierSkeletonAnimatedRow(this._theme);
|
|
1971
|
+
const secondRow = new CourierSkeletonAnimatedRow(this._theme);
|
|
1972
|
+
const thirdRow = new CourierSkeletonAnimatedRow(this._theme);
|
|
1973
|
+
this.appendChild(firstRow);
|
|
1974
|
+
this.appendChild(secondRow);
|
|
1975
|
+
this.appendChild(thirdRow);
|
|
1976
|
+
}
|
|
1977
|
+
static getStyles(_theme) {
|
|
1915
1978
|
return `
|
|
1916
|
-
|
|
1979
|
+
${CourierInboxSkeletonListItem.id} {
|
|
1917
1980
|
display: flex;
|
|
1918
1981
|
flex-direction: column;
|
|
1919
1982
|
gap: 12px;
|
|
1920
1983
|
padding: 12px;
|
|
1921
1984
|
width: 100%;
|
|
1922
1985
|
box-sizing: border-box;
|
|
1923
|
-
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
${CourierInboxSkeletonListItem.id} > *:first-child {
|
|
1989
|
+
width: 35%;
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
${CourierInboxSkeletonListItem.id} > *:nth-child(2) {
|
|
1993
|
+
width: 100%;
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
${CourierInboxSkeletonListItem.id} > *:nth-child(3) {
|
|
1997
|
+
width: 82%;
|
|
1924
1998
|
}
|
|
1925
1999
|
`;
|
|
1926
2000
|
}
|
|
1927
2001
|
}
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
class CourierSkeletonAnimatedRow extends HTMLElement {
|
|
1932
|
-
constructor(theme2, widthPercent) {
|
|
2002
|
+
registerElement(CourierInboxSkeletonListItem);
|
|
2003
|
+
class CourierSkeletonAnimatedRow extends CourierBaseElement {
|
|
2004
|
+
constructor(theme2) {
|
|
1933
2005
|
super();
|
|
1934
|
-
__publicField(this, "
|
|
1935
|
-
this
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
2006
|
+
__publicField(this, "_theme");
|
|
2007
|
+
__publicField(this, "_style");
|
|
2008
|
+
this._theme = theme2;
|
|
2009
|
+
}
|
|
2010
|
+
static get id() {
|
|
2011
|
+
return "courier-skeleton-animated-row";
|
|
2012
|
+
}
|
|
2013
|
+
onComponentMounted() {
|
|
2014
|
+
this._style = injectGlobalStyle(CourierSkeletonAnimatedRow.id, CourierSkeletonAnimatedRow.getStyles(this._theme));
|
|
2015
|
+
this.render();
|
|
2016
|
+
}
|
|
2017
|
+
onComponentUnmounted() {
|
|
2018
|
+
var _a;
|
|
2019
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
2020
|
+
}
|
|
2021
|
+
render() {
|
|
1939
2022
|
const skeletonItem = document.createElement("div");
|
|
1940
2023
|
skeletonItem.className = "skeleton-item";
|
|
1941
|
-
this.
|
|
2024
|
+
this.appendChild(skeletonItem);
|
|
1942
2025
|
}
|
|
1943
|
-
getStyles(theme2
|
|
2026
|
+
static getStyles(theme2) {
|
|
1944
2027
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1945
2028
|
const color = ((_c = (_b = (_a = theme2.inbox) == null ? void 0 : _a.loading) == null ? void 0 : _b.animation) == null ? void 0 : _c.barColor) ?? "#000";
|
|
1946
2029
|
const hexColor = color.length === 4 ? `#${color[1]}${color[1]}${color[2]}${color[2]}${color[3]}${color[3]}` : color;
|
|
@@ -1950,15 +2033,15 @@ class CourierSkeletonAnimatedRow extends HTMLElement {
|
|
|
1950
2033
|
const colorWithAlpha80 = `rgba(${r}, ${g}, ${b}, 0.8)`;
|
|
1951
2034
|
const colorWithAlpha40 = `rgba(${r}, ${g}, ${b}, 0.4)`;
|
|
1952
2035
|
return `
|
|
1953
|
-
|
|
2036
|
+
${CourierSkeletonAnimatedRow.id} {
|
|
1954
2037
|
display: flex;
|
|
1955
2038
|
height: 100%;
|
|
1956
|
-
width:
|
|
2039
|
+
width: 100%;
|
|
1957
2040
|
align-items: flex-start;
|
|
1958
2041
|
justify-content: flex-start;
|
|
1959
2042
|
}
|
|
1960
2043
|
|
|
1961
|
-
.skeleton-item {
|
|
2044
|
+
${CourierSkeletonAnimatedRow.id} .skeleton-item {
|
|
1962
2045
|
height: ${((_f = (_e = (_d = theme2.inbox) == null ? void 0 : _d.loading) == null ? void 0 : _e.animation) == null ? void 0 : _f.barHeight) ?? "14px"};
|
|
1963
2046
|
width: 100%;
|
|
1964
2047
|
background: linear-gradient(
|
|
@@ -1968,11 +2051,11 @@ class CourierSkeletonAnimatedRow extends HTMLElement {
|
|
|
1968
2051
|
${colorWithAlpha80} 75%
|
|
1969
2052
|
);
|
|
1970
2053
|
background-size: 200% 100%;
|
|
1971
|
-
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;
|
|
2054
|
+
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;
|
|
1972
2055
|
border-radius: ${((_l = (_k = (_j = theme2.inbox) == null ? void 0 : _j.loading) == null ? void 0 : _k.animation) == null ? void 0 : _l.barBorderRadius) ?? "14px"};
|
|
1973
2056
|
}
|
|
1974
2057
|
|
|
1975
|
-
@keyframes shimmer {
|
|
2058
|
+
@keyframes ${CourierSkeletonAnimatedRow.id}-shimmer {
|
|
1976
2059
|
0% {
|
|
1977
2060
|
background-position: 200% 0;
|
|
1978
2061
|
}
|
|
@@ -1983,32 +2066,38 @@ class CourierSkeletonAnimatedRow extends HTMLElement {
|
|
|
1983
2066
|
`;
|
|
1984
2067
|
}
|
|
1985
2068
|
}
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
}
|
|
1989
|
-
class CourierInboxSkeletonList extends CourierElement {
|
|
2069
|
+
registerElement(CourierSkeletonAnimatedRow);
|
|
2070
|
+
class CourierInboxSkeletonList extends CourierFactoryElement {
|
|
1990
2071
|
constructor(theme2) {
|
|
1991
2072
|
super();
|
|
1992
2073
|
__publicField(this, "_theme");
|
|
2074
|
+
__publicField(this, "_style");
|
|
1993
2075
|
this._theme = theme2;
|
|
1994
2076
|
}
|
|
2077
|
+
static get id() {
|
|
2078
|
+
return "courier-inbox-skeleton-list";
|
|
2079
|
+
}
|
|
2080
|
+
onComponentMounted() {
|
|
2081
|
+
this._style = injectGlobalStyle(CourierInboxSkeletonList.id, CourierInboxSkeletonList.getStyles(this._theme));
|
|
2082
|
+
}
|
|
2083
|
+
onComponentUnmounted() {
|
|
2084
|
+
var _a;
|
|
2085
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
2086
|
+
}
|
|
1995
2087
|
defaultElement() {
|
|
1996
2088
|
const list = document.createElement("div");
|
|
1997
2089
|
list.className = "list";
|
|
1998
|
-
const style = document.createElement("style");
|
|
1999
|
-
style.textContent = this.getStyles();
|
|
2000
|
-
list.appendChild(style);
|
|
2001
2090
|
for (let i = 0; i < 3; i++) {
|
|
2002
|
-
const skeletonItem = new CourierInboxSkeletonListItem(this._theme
|
|
2091
|
+
const skeletonItem = new CourierInboxSkeletonListItem(this._theme);
|
|
2003
2092
|
list.appendChild(skeletonItem);
|
|
2004
2093
|
}
|
|
2005
|
-
this.
|
|
2094
|
+
this.appendChild(list);
|
|
2006
2095
|
return list;
|
|
2007
2096
|
}
|
|
2008
|
-
getStyles() {
|
|
2009
|
-
var _a, _b;
|
|
2097
|
+
static getStyles(theme2) {
|
|
2098
|
+
var _a, _b, _c, _d;
|
|
2010
2099
|
return `
|
|
2011
|
-
|
|
2100
|
+
${CourierInboxSkeletonList.id} {
|
|
2012
2101
|
display: flex;
|
|
2013
2102
|
height: 100%;
|
|
2014
2103
|
width: 100%;
|
|
@@ -2017,82 +2106,92 @@ class CourierInboxSkeletonList extends CourierElement {
|
|
|
2017
2106
|
overflow: hidden;
|
|
2018
2107
|
}
|
|
2019
2108
|
|
|
2020
|
-
.list {
|
|
2109
|
+
${CourierInboxSkeletonList.id} .list {
|
|
2021
2110
|
display: flex;
|
|
2022
2111
|
flex-direction: column;
|
|
2023
|
-
gap: 8px;
|
|
2024
2112
|
width: 100%;
|
|
2025
2113
|
overflow: hidden;
|
|
2026
2114
|
}
|
|
2027
2115
|
|
|
2028
|
-
.list > * {
|
|
2029
|
-
border-bottom: ${((_b = (_a =
|
|
2116
|
+
${CourierInboxSkeletonList.id} .list > * {
|
|
2117
|
+
border-bottom: ${((_b = (_a = theme2.inbox) == null ? void 0 : _a.loading) == null ? void 0 : _b.divider) ?? "1px solid red"};
|
|
2118
|
+
opacity: 100%;
|
|
2030
2119
|
}
|
|
2031
2120
|
|
|
2032
|
-
.list > *:
|
|
2121
|
+
${CourierInboxSkeletonList.id} .list > *:nth-child(2) {
|
|
2122
|
+
border-bottom: ${((_d = (_c = theme2.inbox) == null ? void 0 : _c.loading) == null ? void 0 : _d.divider) ?? "1px solid red"};
|
|
2123
|
+
opacity: 88%;
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
${CourierInboxSkeletonList.id} .list > *:nth-child(3) {
|
|
2033
2127
|
border-bottom: none;
|
|
2128
|
+
opacity: 50%;
|
|
2034
2129
|
}
|
|
2035
2130
|
`;
|
|
2036
2131
|
}
|
|
2037
2132
|
}
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
}
|
|
2041
|
-
class CourierInboxPaginationListItem extends HTMLElement {
|
|
2133
|
+
registerElement(CourierInboxSkeletonList);
|
|
2134
|
+
class CourierInboxPaginationListItem extends CourierBaseElement {
|
|
2042
2135
|
constructor(props) {
|
|
2043
2136
|
super();
|
|
2137
|
+
// State
|
|
2138
|
+
__publicField(this, "_theme");
|
|
2044
2139
|
// Components
|
|
2045
|
-
__publicField(this, "
|
|
2046
|
-
__publicField(this, "
|
|
2047
|
-
__publicField(this, "
|
|
2140
|
+
__publicField(this, "_style");
|
|
2141
|
+
__publicField(this, "_skeletonLoadingList");
|
|
2142
|
+
__publicField(this, "_observer");
|
|
2143
|
+
__publicField(this, "_customItem");
|
|
2048
2144
|
// Handlers
|
|
2049
|
-
__publicField(this, "
|
|
2050
|
-
this.
|
|
2051
|
-
this.
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2145
|
+
__publicField(this, "_onPaginationTrigger");
|
|
2146
|
+
this._theme = props.theme;
|
|
2147
|
+
this._customItem = props.customItem;
|
|
2148
|
+
this._onPaginationTrigger = props.onPaginationTrigger;
|
|
2149
|
+
}
|
|
2150
|
+
static get id() {
|
|
2151
|
+
return "courier-inbox-pagination-list-item";
|
|
2152
|
+
}
|
|
2153
|
+
onComponentMounted() {
|
|
2154
|
+
this._style = injectGlobalStyle(CourierInboxPaginationListItem.id, CourierInboxPaginationListItem.getStyles(this._theme));
|
|
2155
|
+
if (this._customItem) {
|
|
2156
|
+
this.appendChild(this._customItem);
|
|
2058
2157
|
} else {
|
|
2059
2158
|
const container = document.createElement("div");
|
|
2060
2159
|
container.className = "skeleton-container";
|
|
2061
|
-
this.
|
|
2062
|
-
this.
|
|
2063
|
-
container.appendChild(this.
|
|
2064
|
-
|
|
2160
|
+
this._skeletonLoadingList = new CourierInboxSkeletonList(this._theme);
|
|
2161
|
+
this._skeletonLoadingList.build(void 0);
|
|
2162
|
+
container.appendChild(this._skeletonLoadingList);
|
|
2163
|
+
this.appendChild(container);
|
|
2065
2164
|
}
|
|
2066
|
-
this.
|
|
2165
|
+
this._observer = new IntersectionObserver((entries) => {
|
|
2067
2166
|
entries.forEach((entry) => {
|
|
2068
2167
|
if (entry.isIntersecting) {
|
|
2069
|
-
this.
|
|
2168
|
+
this._onPaginationTrigger();
|
|
2070
2169
|
}
|
|
2071
2170
|
});
|
|
2072
2171
|
});
|
|
2073
|
-
this.
|
|
2172
|
+
this._observer.observe(this);
|
|
2074
2173
|
}
|
|
2075
|
-
|
|
2174
|
+
onComponentUnmounted() {
|
|
2175
|
+
var _a, _b;
|
|
2176
|
+
(_a = this._observer) == null ? void 0 : _a.disconnect();
|
|
2177
|
+
(_b = this._style) == null ? void 0 : _b.remove();
|
|
2178
|
+
}
|
|
2179
|
+
static getStyles(_theme) {
|
|
2076
2180
|
return `
|
|
2077
|
-
|
|
2181
|
+
${CourierInboxPaginationListItem.id} {
|
|
2078
2182
|
padding: 0;
|
|
2079
2183
|
margin: 0;
|
|
2080
2184
|
box-sizing: border-box;
|
|
2081
2185
|
}
|
|
2082
2186
|
|
|
2083
|
-
.skeleton-container {
|
|
2187
|
+
${CourierInboxPaginationListItem.id} .skeleton-container {
|
|
2084
2188
|
height: 150%;
|
|
2085
2189
|
}
|
|
2086
2190
|
`;
|
|
2087
2191
|
}
|
|
2088
|
-
disconnectedCallback() {
|
|
2089
|
-
this.observer.disconnect();
|
|
2090
|
-
}
|
|
2091
|
-
}
|
|
2092
|
-
if (!customElements.get("courier-inbox-pagination-list-item")) {
|
|
2093
|
-
customElements.define("courier-inbox-pagination-list-item", CourierInboxPaginationListItem);
|
|
2094
2192
|
}
|
|
2095
|
-
|
|
2193
|
+
registerElement(CourierInboxPaginationListItem);
|
|
2194
|
+
class CourierInboxList extends CourierBaseElement {
|
|
2096
2195
|
constructor(props) {
|
|
2097
2196
|
super();
|
|
2098
2197
|
// Theme
|
|
@@ -2115,34 +2214,53 @@ class CourierInboxList extends HTMLElement {
|
|
|
2115
2214
|
__publicField(this, "_loadingStateFactory");
|
|
2116
2215
|
__publicField(this, "_emptyStateFactory");
|
|
2117
2216
|
__publicField(this, "_errorStateFactory");
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2217
|
+
// Components
|
|
2218
|
+
__publicField(this, "_listStyles");
|
|
2219
|
+
__publicField(this, "_listItemStyles");
|
|
2220
|
+
__publicField(this, "_listItemMenuStyles");
|
|
2121
2221
|
this._onRefresh = props.onRefresh;
|
|
2122
2222
|
this._onPaginationTrigger = props.onPaginationTrigger;
|
|
2123
2223
|
this._onMessageClick = props.onMessageClick;
|
|
2124
2224
|
this._onMessageActionClick = props.onMessageActionClick;
|
|
2125
2225
|
this._onMessageLongPress = props.onMessageLongPress;
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2226
|
+
this._themeSubscription = props.themeManager.subscribe((_) => {
|
|
2227
|
+
this.render();
|
|
2228
|
+
});
|
|
2229
|
+
}
|
|
2230
|
+
static get id() {
|
|
2231
|
+
return "courier-inbox-list";
|
|
2130
2232
|
}
|
|
2131
2233
|
// Getters
|
|
2132
2234
|
get messages() {
|
|
2133
2235
|
return this._messages;
|
|
2134
2236
|
}
|
|
2135
|
-
|
|
2237
|
+
get theme() {
|
|
2238
|
+
return this._themeSubscription.manager.getTheme();
|
|
2239
|
+
}
|
|
2240
|
+
onComponentMounted() {
|
|
2241
|
+
this._listStyles = injectGlobalStyle(CourierInboxList.id, CourierInboxList.getStyles(this.theme));
|
|
2242
|
+
this._listItemStyles = injectGlobalStyle(CourierInboxListItem.id, CourierInboxListItem.getStyles(this.theme));
|
|
2243
|
+
this._listItemMenuStyles = injectGlobalStyle(CourierInboxListItemMenu.id, CourierInboxListItemMenu.getStyles(this.theme));
|
|
2244
|
+
this.render();
|
|
2245
|
+
}
|
|
2246
|
+
onComponentUnmounted() {
|
|
2247
|
+
var _a, _b, _c;
|
|
2248
|
+
this._themeSubscription.unsubscribe();
|
|
2249
|
+
(_a = this._listStyles) == null ? void 0 : _a.remove();
|
|
2250
|
+
(_b = this._listItemStyles) == null ? void 0 : _b.remove();
|
|
2251
|
+
(_c = this._listItemMenuStyles) == null ? void 0 : _c.remove();
|
|
2252
|
+
}
|
|
2253
|
+
static getStyles(theme2) {
|
|
2136
2254
|
var _a;
|
|
2137
|
-
const list = (_a =
|
|
2255
|
+
const list = (_a = theme2.inbox) == null ? void 0 : _a.list;
|
|
2138
2256
|
return `
|
|
2139
|
-
|
|
2257
|
+
${CourierInboxList.id} {
|
|
2140
2258
|
flex: 1;
|
|
2141
2259
|
width: 100%;
|
|
2142
|
-
background-color: ${(list == null ? void 0 : list.backgroundColor) ??
|
|
2260
|
+
background-color: ${(list == null ? void 0 : list.backgroundColor) ?? "red"};
|
|
2143
2261
|
}
|
|
2144
2262
|
|
|
2145
|
-
ul {
|
|
2263
|
+
${CourierInboxList.id} ul {
|
|
2146
2264
|
list-style: none;
|
|
2147
2265
|
padding: 0;
|
|
2148
2266
|
margin: 0;
|
|
@@ -2150,15 +2268,6 @@ class CourierInboxList extends HTMLElement {
|
|
|
2150
2268
|
}
|
|
2151
2269
|
`;
|
|
2152
2270
|
}
|
|
2153
|
-
reset() {
|
|
2154
|
-
var _a, _b;
|
|
2155
|
-
while ((_a = this.shadowRoot) == null ? void 0 : _a.firstChild) {
|
|
2156
|
-
this.shadowRoot.removeChild(this.shadowRoot.firstChild);
|
|
2157
|
-
}
|
|
2158
|
-
const style = document.createElement("style");
|
|
2159
|
-
style.textContent = this.getStyles();
|
|
2160
|
-
(_b = this.shadowRoot) == null ? void 0 : _b.appendChild(style);
|
|
2161
|
-
}
|
|
2162
2271
|
setDataSet(dataSet) {
|
|
2163
2272
|
this._messages = [...dataSet.messages];
|
|
2164
2273
|
this._canPaginate = Boolean(dataSet.canPaginate);
|
|
@@ -2212,11 +2321,21 @@ class CourierInboxList extends HTMLElement {
|
|
|
2212
2321
|
this._onRefresh();
|
|
2213
2322
|
}
|
|
2214
2323
|
render() {
|
|
2215
|
-
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, __, _
|
|
2216
|
-
this.
|
|
2217
|
-
|
|
2324
|
+
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, __, _$;
|
|
2325
|
+
while (this.firstChild) {
|
|
2326
|
+
this.removeChild(this.firstChild);
|
|
2327
|
+
}
|
|
2328
|
+
if (this._listStyles) {
|
|
2329
|
+
this._listStyles.textContent = CourierInboxList.getStyles(this.theme);
|
|
2330
|
+
}
|
|
2331
|
+
if (this._listItemStyles) {
|
|
2332
|
+
this._listItemStyles.textContent = CourierInboxListItem.getStyles(this.theme);
|
|
2333
|
+
}
|
|
2334
|
+
if (this._listItemMenuStyles) {
|
|
2335
|
+
this._listItemMenuStyles.textContent = CourierInboxListItemMenu.getStyles(this.theme);
|
|
2336
|
+
}
|
|
2218
2337
|
if (this._error) {
|
|
2219
|
-
const error = (_a =
|
|
2338
|
+
const error = (_a = this.theme.inbox) == null ? void 0 : _a.error;
|
|
2220
2339
|
const errorElement = new CourierInfoState({
|
|
2221
2340
|
title: {
|
|
2222
2341
|
text: ((_b = error == null ? void 0 : error.title) == null ? void 0 : _b.text) ?? this._error.message,
|
|
@@ -2241,52 +2360,52 @@ class CourierInboxList extends HTMLElement {
|
|
|
2241
2360
|
});
|
|
2242
2361
|
errorElement.build((_z = this._errorStateFactory) == null ? void 0 : _z.call(this, { feedType: this._feedType, error: this._error }));
|
|
2243
2362
|
errorElement.setButtonClickCallback(() => this.handleRetry());
|
|
2244
|
-
|
|
2363
|
+
this.appendChild(errorElement);
|
|
2245
2364
|
return;
|
|
2246
2365
|
}
|
|
2247
2366
|
if (this._isLoading) {
|
|
2248
|
-
const loadingElement = new CourierInboxSkeletonList(
|
|
2249
|
-
loadingElement.build((
|
|
2250
|
-
|
|
2367
|
+
const loadingElement = new CourierInboxSkeletonList(this.theme);
|
|
2368
|
+
loadingElement.build((_A = this._loadingStateFactory) == null ? void 0 : _A.call(this, { feedType: this._feedType }));
|
|
2369
|
+
this.appendChild(loadingElement);
|
|
2251
2370
|
return;
|
|
2252
2371
|
}
|
|
2253
2372
|
if (this._messages.length === 0) {
|
|
2254
|
-
const empty = (
|
|
2373
|
+
const empty = (_B = this.theme.inbox) == null ? void 0 : _B.empty;
|
|
2255
2374
|
const emptyElement = new CourierInfoState({
|
|
2256
2375
|
title: {
|
|
2257
|
-
text: ((
|
|
2258
|
-
textColor: (
|
|
2259
|
-
fontFamily: (
|
|
2260
|
-
fontSize: (
|
|
2261
|
-
fontWeight: (
|
|
2376
|
+
text: ((_C = empty == null ? void 0 : empty.title) == null ? void 0 : _C.text) ?? `No ${this._feedType} messages yet`,
|
|
2377
|
+
textColor: (_E = (_D = empty == null ? void 0 : empty.title) == null ? void 0 : _D.font) == null ? void 0 : _E.color,
|
|
2378
|
+
fontFamily: (_G = (_F = empty == null ? void 0 : empty.title) == null ? void 0 : _F.font) == null ? void 0 : _G.family,
|
|
2379
|
+
fontSize: (_I = (_H = empty == null ? void 0 : empty.title) == null ? void 0 : _H.font) == null ? void 0 : _I.size,
|
|
2380
|
+
fontWeight: (_K = (_J = empty == null ? void 0 : empty.title) == null ? void 0 : _J.font) == null ? void 0 : _K.weight
|
|
2262
2381
|
},
|
|
2263
2382
|
button: {
|
|
2264
|
-
text: (
|
|
2265
|
-
backgroundColor: (
|
|
2266
|
-
hoverBackgroundColor: (
|
|
2267
|
-
activeBackgroundColor: (
|
|
2268
|
-
textColor: (
|
|
2269
|
-
fontFamily: (
|
|
2270
|
-
fontSize: (
|
|
2271
|
-
fontWeight: (
|
|
2272
|
-
shadow: (
|
|
2273
|
-
border: (
|
|
2274
|
-
borderRadius: (
|
|
2383
|
+
text: (_L = empty == null ? void 0 : empty.button) == null ? void 0 : _L.text,
|
|
2384
|
+
backgroundColor: (_M = empty == null ? void 0 : empty.button) == null ? void 0 : _M.backgroundColor,
|
|
2385
|
+
hoverBackgroundColor: (_N = empty == null ? void 0 : empty.button) == null ? void 0 : _N.hoverBackgroundColor,
|
|
2386
|
+
activeBackgroundColor: (_O = empty == null ? void 0 : empty.button) == null ? void 0 : _O.activeBackgroundColor,
|
|
2387
|
+
textColor: (_Q = (_P = empty == null ? void 0 : empty.button) == null ? void 0 : _P.font) == null ? void 0 : _Q.color,
|
|
2388
|
+
fontFamily: (_S = (_R = empty == null ? void 0 : empty.button) == null ? void 0 : _R.font) == null ? void 0 : _S.family,
|
|
2389
|
+
fontSize: (_U = (_T = empty == null ? void 0 : empty.button) == null ? void 0 : _T.font) == null ? void 0 : _U.size,
|
|
2390
|
+
fontWeight: (_W = (_V = empty == null ? void 0 : empty.button) == null ? void 0 : _V.font) == null ? void 0 : _W.weight,
|
|
2391
|
+
shadow: (_X = empty == null ? void 0 : empty.button) == null ? void 0 : _X.shadow,
|
|
2392
|
+
border: (_Y = empty == null ? void 0 : empty.button) == null ? void 0 : _Y.border,
|
|
2393
|
+
borderRadius: (_Z = empty == null ? void 0 : empty.button) == null ? void 0 : _Z.borderRadius
|
|
2275
2394
|
}
|
|
2276
2395
|
});
|
|
2277
|
-
emptyElement.build((
|
|
2396
|
+
emptyElement.build((__ = this._emptyStateFactory) == null ? void 0 : __.call(this, { feedType: this._feedType }));
|
|
2278
2397
|
emptyElement.setButtonClickCallback(() => this.handleRefresh());
|
|
2279
|
-
|
|
2398
|
+
this.appendChild(emptyElement);
|
|
2280
2399
|
return;
|
|
2281
2400
|
}
|
|
2282
2401
|
const list = document.createElement("ul");
|
|
2283
|
-
|
|
2402
|
+
this.appendChild(list);
|
|
2284
2403
|
this._messages.forEach((message, index) => {
|
|
2285
2404
|
if (this._listItemFactory) {
|
|
2286
2405
|
list.appendChild(this._listItemFactory({ message, index }));
|
|
2287
2406
|
return;
|
|
2288
2407
|
}
|
|
2289
|
-
const listItem = new
|
|
2408
|
+
const listItem = new CourierInboxListItem(this.theme);
|
|
2290
2409
|
listItem.setMessage(message, this._feedType);
|
|
2291
2410
|
listItem.setOnItemClick((message2) => {
|
|
2292
2411
|
var _a2;
|
|
@@ -2304,8 +2423,8 @@ class CourierInboxList extends HTMLElement {
|
|
|
2304
2423
|
});
|
|
2305
2424
|
if (this._canPaginate) {
|
|
2306
2425
|
const paginationItem = new CourierInboxPaginationListItem({
|
|
2307
|
-
theme:
|
|
2308
|
-
customItem: (
|
|
2426
|
+
theme: this.theme,
|
|
2427
|
+
customItem: (_$ = this._paginationItemFactory) == null ? void 0 : _$.call(this, { feedType: this._feedType }),
|
|
2309
2428
|
onPaginationTrigger: () => {
|
|
2310
2429
|
var _a2;
|
|
2311
2430
|
return (_a2 = this._onPaginationTrigger) == null ? void 0 : _a2.call(this, this._feedType);
|
|
@@ -2335,36 +2454,28 @@ class CourierInboxList extends HTMLElement {
|
|
|
2335
2454
|
this._paginationItemFactory = factory;
|
|
2336
2455
|
this.render();
|
|
2337
2456
|
}
|
|
2338
|
-
refreshTheme() {
|
|
2339
|
-
this.render();
|
|
2340
|
-
}
|
|
2341
|
-
// Disconnect the theme subscription
|
|
2342
|
-
disconnectedCallback() {
|
|
2343
|
-
this._themeSubscription.unsubscribe();
|
|
2344
|
-
}
|
|
2345
|
-
}
|
|
2346
|
-
if (!customElements.get("courier-inbox-list")) {
|
|
2347
|
-
customElements.define("courier-inbox-list", CourierInboxList);
|
|
2348
2457
|
}
|
|
2349
|
-
|
|
2458
|
+
registerElement(CourierInboxList);
|
|
2459
|
+
class CourierInboxOptionMenuItem extends CourierBaseElement {
|
|
2350
2460
|
constructor(props) {
|
|
2351
2461
|
super();
|
|
2352
2462
|
// State
|
|
2353
2463
|
__publicField(this, "_option");
|
|
2464
|
+
__publicField(this, "_isSelectedable");
|
|
2354
2465
|
__publicField(this, "_isSelected");
|
|
2355
2466
|
// Components
|
|
2356
2467
|
__publicField(this, "_content");
|
|
2357
2468
|
__publicField(this, "_itemIcon");
|
|
2358
2469
|
__publicField(this, "_title");
|
|
2359
2470
|
__publicField(this, "_selectionIcon");
|
|
2360
|
-
__publicField(this, "_style");
|
|
2361
|
-
// Theme
|
|
2362
|
-
__publicField(this, "_themeManager");
|
|
2363
2471
|
this._option = props.option;
|
|
2364
2472
|
this._isSelected = props.isSelected;
|
|
2365
|
-
this.
|
|
2366
|
-
|
|
2367
|
-
|
|
2473
|
+
this._isSelectedable = props.selectable;
|
|
2474
|
+
}
|
|
2475
|
+
static get id() {
|
|
2476
|
+
return "courier-inbox-option-menu-item";
|
|
2477
|
+
}
|
|
2478
|
+
onComponentMounted() {
|
|
2368
2479
|
this._content = document.createElement("div");
|
|
2369
2480
|
this._content.className = "menu-item";
|
|
2370
2481
|
this._itemIcon = new CourierIcon(this._option.icon.svg ?? CourierIconSVGs.inbox);
|
|
@@ -2377,72 +2488,26 @@ class CourierInboxOptionMenuItem extends HTMLElement {
|
|
|
2377
2488
|
this._content.appendChild(this._itemIcon);
|
|
2378
2489
|
this._content.appendChild(this._title);
|
|
2379
2490
|
this._content.appendChild(spacer);
|
|
2380
|
-
if (
|
|
2491
|
+
if (this._isSelectedable) {
|
|
2381
2492
|
this._content.appendChild(this._selectionIcon);
|
|
2382
2493
|
}
|
|
2383
|
-
|
|
2384
|
-
shadow.appendChild(this._content);
|
|
2494
|
+
this.appendChild(this._content);
|
|
2385
2495
|
this._selectionIcon.style.display = this._isSelected ? "block" : "none";
|
|
2386
2496
|
this.refreshTheme();
|
|
2387
2497
|
}
|
|
2388
|
-
getStyles() {
|
|
2389
|
-
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;
|
|
2390
|
-
const theme2 = this._themeManager.getTheme();
|
|
2391
|
-
return `
|
|
2392
|
-
:host {
|
|
2393
|
-
display: flex;
|
|
2394
|
-
flex-direction: row;
|
|
2395
|
-
padding: 6px 12px;
|
|
2396
|
-
cursor: pointer;
|
|
2397
|
-
}
|
|
2398
|
-
|
|
2399
|
-
:host(:hover) {
|
|
2400
|
-
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"};
|
|
2401
|
-
}
|
|
2402
|
-
|
|
2403
|
-
:host(:active) {
|
|
2404
|
-
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"};
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
|
-
.menu-item {
|
|
2408
|
-
display: flex;
|
|
2409
|
-
align-items: center;
|
|
2410
|
-
width: 100%;
|
|
2411
|
-
gap: 12px;
|
|
2412
|
-
}
|
|
2413
|
-
|
|
2414
|
-
.spacer {
|
|
2415
|
-
flex: 1;
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2418
|
-
p {
|
|
2419
|
-
margin: 0;
|
|
2420
|
-
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"};
|
|
2421
|
-
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"};
|
|
2422
|
-
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"};
|
|
2423
|
-
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"};
|
|
2424
|
-
white-space: nowrap;
|
|
2425
|
-
}
|
|
2426
|
-
|
|
2427
|
-
.check-icon {
|
|
2428
|
-
display: none;
|
|
2429
|
-
}
|
|
2430
|
-
`;
|
|
2431
|
-
}
|
|
2432
2498
|
refreshTheme() {
|
|
2433
|
-
var _a, _b, _c, _d;
|
|
2434
|
-
this.
|
|
2435
|
-
this._selectionIcon.
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
this._itemIcon.
|
|
2499
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2500
|
+
(_b = this._selectionIcon) == null ? void 0 : _b.updateColor(((_a = this._option.selectionIcon) == null ? void 0 : _a.color) ?? "red");
|
|
2501
|
+
(_d = this._selectionIcon) == null ? void 0 : _d.updateSVG(((_c = this._option.selectionIcon) == null ? void 0 : _c.svg) ?? CourierIconSVGs.check);
|
|
2502
|
+
if (this._title) {
|
|
2503
|
+
this._title.textContent = this._option.text ?? "Missing Text";
|
|
2504
|
+
}
|
|
2505
|
+
(_f = this._itemIcon) == null ? void 0 : _f.updateColor(((_e = this._option.icon) == null ? void 0 : _e.color) ?? "red");
|
|
2506
|
+
(_h = this._itemIcon) == null ? void 0 : _h.updateSVG(((_g = this._option.icon) == null ? void 0 : _g.svg) ?? CourierIconSVGs.inbox);
|
|
2440
2507
|
}
|
|
2441
2508
|
}
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
}
|
|
2445
|
-
class CourierInboxOptionMenu extends HTMLElement {
|
|
2509
|
+
registerElement(CourierInboxOptionMenuItem);
|
|
2510
|
+
class CourierInboxOptionMenu extends CourierBaseElement {
|
|
2446
2511
|
constructor(themeManager, type, selectable, options, onMenuOpen) {
|
|
2447
2512
|
super();
|
|
2448
2513
|
// Theme
|
|
@@ -2462,31 +2527,39 @@ class CourierInboxOptionMenu extends HTMLElement {
|
|
|
2462
2527
|
this._options = options;
|
|
2463
2528
|
this._selectedIndex = 0;
|
|
2464
2529
|
this._onMenuOpen = onMenuOpen;
|
|
2465
|
-
const shadow = this.attachShadow({ mode: "open" });
|
|
2466
|
-
this._menuButton = new CourierIconButton(type === "filters" ? CourierIconSVGs.filter : CourierIconSVGs.overflow);
|
|
2467
|
-
this._menu = document.createElement("div");
|
|
2468
|
-
this._menu.className = `menu ${type}`;
|
|
2469
|
-
this._style = document.createElement("style");
|
|
2470
|
-
shadow.appendChild(this._style);
|
|
2471
|
-
shadow.appendChild(this._menuButton);
|
|
2472
|
-
shadow.appendChild(this._menu);
|
|
2473
|
-
this._menuButton.addEventListener("click", this.toggleMenu.bind(this));
|
|
2474
|
-
document.addEventListener("click", this.handleOutsideClick.bind(this));
|
|
2475
2530
|
this._themeSubscription = themeManager.subscribe((_) => {
|
|
2476
2531
|
this.refreshTheme();
|
|
2477
2532
|
});
|
|
2533
|
+
}
|
|
2534
|
+
static get id() {
|
|
2535
|
+
return "courier-inbox-option-menu";
|
|
2536
|
+
}
|
|
2537
|
+
onComponentMounted() {
|
|
2538
|
+
this._style = injectGlobalStyle(CourierInboxOptionMenu.id, this.getStyles());
|
|
2539
|
+
this._menuButton = new CourierIconButton(this._type === "filters" ? CourierIconSVGs.filter : CourierIconSVGs.overflow);
|
|
2540
|
+
this._menu = document.createElement("div");
|
|
2541
|
+
this._menu.className = `menu ${this._type}`;
|
|
2542
|
+
this.appendChild(this._menuButton);
|
|
2543
|
+
this.appendChild(this._menu);
|
|
2544
|
+
this._menuButton.addEventListener("click", this.toggleMenu.bind(this));
|
|
2545
|
+
document.addEventListener("click", this.handleOutsideClick.bind(this));
|
|
2478
2546
|
this.refreshTheme();
|
|
2479
2547
|
}
|
|
2548
|
+
onComponentUnmounted() {
|
|
2549
|
+
var _a;
|
|
2550
|
+
this._themeSubscription.unsubscribe();
|
|
2551
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
2552
|
+
}
|
|
2480
2553
|
getStyles() {
|
|
2481
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
2554
|
+
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;
|
|
2482
2555
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
2483
2556
|
return `
|
|
2484
|
-
|
|
2557
|
+
${CourierInboxOptionMenu.id} {
|
|
2485
2558
|
position: relative;
|
|
2486
2559
|
display: inline-block;
|
|
2487
2560
|
}
|
|
2488
2561
|
|
|
2489
|
-
.menu {
|
|
2562
|
+
${CourierInboxOptionMenu.id} .menu {
|
|
2490
2563
|
display: none;
|
|
2491
2564
|
position: absolute;
|
|
2492
2565
|
top: 42px;
|
|
@@ -2501,28 +2574,69 @@ class CourierInboxOptionMenu extends HTMLElement {
|
|
|
2501
2574
|
padding: 4px 0;
|
|
2502
2575
|
}
|
|
2503
2576
|
|
|
2504
|
-
courier-inbox-filter-menu-item {
|
|
2577
|
+
${CourierInboxOptionMenu.id} courier-inbox-filter-menu-item {
|
|
2505
2578
|
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"};
|
|
2506
2579
|
}
|
|
2507
2580
|
|
|
2508
|
-
courier-inbox-filter-menu-item:last-child {
|
|
2581
|
+
${CourierInboxOptionMenu.id} courier-inbox-filter-menu-item:last-child {
|
|
2509
2582
|
border-bottom: none;
|
|
2510
2583
|
}
|
|
2584
|
+
|
|
2585
|
+
${CourierInboxOptionMenuItem.id} {
|
|
2586
|
+
display: flex;
|
|
2587
|
+
flex-direction: row;
|
|
2588
|
+
padding: 6px 12px;
|
|
2589
|
+
cursor: pointer;
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
${CourierInboxOptionMenuItem.id}:hover {
|
|
2593
|
+
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"};
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
${CourierInboxOptionMenuItem.id}:active {
|
|
2597
|
+
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"};
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2600
|
+
${CourierInboxOptionMenuItem.id} .menu-item {
|
|
2601
|
+
display: flex;
|
|
2602
|
+
align-items: center;
|
|
2603
|
+
width: 100%;
|
|
2604
|
+
gap: 12px;
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
${CourierInboxOptionMenuItem.id} .spacer {
|
|
2608
|
+
flex: 1;
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2611
|
+
${CourierInboxOptionMenuItem.id} p {
|
|
2612
|
+
margin: 0;
|
|
2613
|
+
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"};
|
|
2614
|
+
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"};
|
|
2615
|
+
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"};
|
|
2616
|
+
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"};
|
|
2617
|
+
white-space: nowrap;
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
${CourierInboxOptionMenuItem.id} .check-icon {
|
|
2621
|
+
display: none;
|
|
2622
|
+
}
|
|
2511
2623
|
`;
|
|
2512
2624
|
}
|
|
2513
2625
|
refreshTheme() {
|
|
2514
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2515
|
-
this._style
|
|
2626
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2627
|
+
if (this._style) {
|
|
2628
|
+
this._style.textContent = this.getStyles();
|
|
2629
|
+
}
|
|
2516
2630
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
2517
2631
|
const menu = (_b = (_a = theme2.inbox) == null ? void 0 : _a.header) == null ? void 0 : _b.menus;
|
|
2518
2632
|
const isFilter = this._type === "filters";
|
|
2519
2633
|
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;
|
|
2520
2634
|
const defaultIcon = isFilter ? CourierIconSVGs.filter : CourierIconSVGs.overflow;
|
|
2521
|
-
this._menuButton.updateIconSVG(((_e = buttonConfig == null ? void 0 : buttonConfig.icon) == null ? void 0 : _e.svg) ?? defaultIcon);
|
|
2522
|
-
this._menuButton.updateIconColor(((
|
|
2523
|
-
this._menuButton.updateBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.backgroundColor) ?? "transparent");
|
|
2524
|
-
this._menuButton.updateHoverBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.hoverBackgroundColor) ?? "red");
|
|
2525
|
-
this._menuButton.updateActiveBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.activeBackgroundColor) ?? "red");
|
|
2635
|
+
(_f = this._menuButton) == null ? void 0 : _f.updateIconSVG(((_e = buttonConfig == null ? void 0 : buttonConfig.icon) == null ? void 0 : _e.svg) ?? defaultIcon);
|
|
2636
|
+
(_h = this._menuButton) == null ? void 0 : _h.updateIconColor(((_g = buttonConfig == null ? void 0 : buttonConfig.icon) == null ? void 0 : _g.color) ?? "red");
|
|
2637
|
+
(_i = this._menuButton) == null ? void 0 : _i.updateBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.backgroundColor) ?? "transparent");
|
|
2638
|
+
(_j = this._menuButton) == null ? void 0 : _j.updateHoverBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.hoverBackgroundColor) ?? "red");
|
|
2639
|
+
(_k = this._menuButton) == null ? void 0 : _k.updateActiveBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.activeBackgroundColor) ?? "red");
|
|
2526
2640
|
this.refreshMenuItems();
|
|
2527
2641
|
}
|
|
2528
2642
|
setOptions(options) {
|
|
@@ -2530,8 +2644,11 @@ class CourierInboxOptionMenu extends HTMLElement {
|
|
|
2530
2644
|
this.refreshMenuItems();
|
|
2531
2645
|
}
|
|
2532
2646
|
refreshMenuItems() {
|
|
2533
|
-
this._menu
|
|
2647
|
+
if (this._menu) {
|
|
2648
|
+
this._menu.innerHTML = "";
|
|
2649
|
+
}
|
|
2534
2650
|
this._options.forEach((option, index) => {
|
|
2651
|
+
var _a;
|
|
2535
2652
|
const menuItem = new CourierInboxOptionMenuItem({
|
|
2536
2653
|
option,
|
|
2537
2654
|
selectable: this._selectable,
|
|
@@ -2544,13 +2661,16 @@ class CourierInboxOptionMenu extends HTMLElement {
|
|
|
2544
2661
|
this.refreshMenuItems();
|
|
2545
2662
|
this.closeMenu();
|
|
2546
2663
|
});
|
|
2547
|
-
this._menu.appendChild(menuItem);
|
|
2664
|
+
(_a = this._menu) == null ? void 0 : _a.appendChild(menuItem);
|
|
2548
2665
|
});
|
|
2549
2666
|
}
|
|
2550
2667
|
toggleMenu(event) {
|
|
2668
|
+
var _a;
|
|
2551
2669
|
event.stopPropagation();
|
|
2552
|
-
const isOpening = this._menu.style.display !== "block";
|
|
2553
|
-
this._menu
|
|
2670
|
+
const isOpening = ((_a = this._menu) == null ? void 0 : _a.style.display) !== "block";
|
|
2671
|
+
if (this._menu) {
|
|
2672
|
+
this._menu.style.display = isOpening ? "block" : "none";
|
|
2673
|
+
}
|
|
2554
2674
|
if (isOpening) {
|
|
2555
2675
|
this._onMenuOpen();
|
|
2556
2676
|
}
|
|
@@ -2561,20 +2681,17 @@ class CourierInboxOptionMenu extends HTMLElement {
|
|
|
2561
2681
|
}
|
|
2562
2682
|
}
|
|
2563
2683
|
closeMenu() {
|
|
2564
|
-
this._menu
|
|
2684
|
+
if (this._menu) {
|
|
2685
|
+
this._menu.style.display = "none";
|
|
2686
|
+
}
|
|
2565
2687
|
}
|
|
2566
2688
|
selectOption(option) {
|
|
2567
2689
|
this._selectedIndex = this._options.findIndex((o) => o.id === option.id);
|
|
2568
2690
|
this.refreshMenuItems();
|
|
2569
2691
|
}
|
|
2570
|
-
disconnectedCallback() {
|
|
2571
|
-
this._themeSubscription.unsubscribe();
|
|
2572
|
-
}
|
|
2573
|
-
}
|
|
2574
|
-
if (!customElements.get("courier-inbox-option-menu")) {
|
|
2575
|
-
customElements.define("courier-inbox-option-menu", CourierInboxOptionMenu);
|
|
2576
2692
|
}
|
|
2577
|
-
|
|
2693
|
+
registerElement(CourierInboxOptionMenu);
|
|
2694
|
+
class CourierUnreadCountBadge extends CourierBaseElement {
|
|
2578
2695
|
constructor(props) {
|
|
2579
2696
|
super();
|
|
2580
2697
|
// Theme
|
|
@@ -2589,37 +2706,51 @@ class CourierUnreadCountBadge extends HTMLElement {
|
|
|
2589
2706
|
this._themeSubscription = props.themeBus.subscribe((_) => {
|
|
2590
2707
|
this.refreshTheme(this._location);
|
|
2591
2708
|
});
|
|
2592
|
-
|
|
2709
|
+
}
|
|
2710
|
+
static get id() {
|
|
2711
|
+
return "courier-unread-count-badge";
|
|
2712
|
+
}
|
|
2713
|
+
get theme() {
|
|
2714
|
+
return this._themeSubscription.manager.getTheme();
|
|
2715
|
+
}
|
|
2716
|
+
onComponentMounted() {
|
|
2593
2717
|
this._badge = document.createElement("span");
|
|
2594
|
-
this._badge.className =
|
|
2595
|
-
this.
|
|
2596
|
-
this.
|
|
2597
|
-
|
|
2598
|
-
|
|
2718
|
+
this._badge.className = `unread-badge ${this._location}`;
|
|
2719
|
+
this.appendChild(this._badge);
|
|
2720
|
+
this.updateBadge();
|
|
2721
|
+
}
|
|
2722
|
+
onComponentUnmounted() {
|
|
2723
|
+
var _a;
|
|
2724
|
+
this._themeSubscription.unsubscribe();
|
|
2725
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
2599
2726
|
}
|
|
2600
|
-
getStyles(
|
|
2601
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2602
|
-
const theme2 = this._themeSubscription.manager.getTheme();
|
|
2603
|
-
const indicator = location === "button" ? (_b = (_a = theme2.popup) == null ? void 0 : _a.button) == null ? void 0 : _b.unreadIndicator : (_e = (_d = (_c = theme2.inbox) == null ? void 0 : _c.header) == null ? void 0 : _d.filters) == null ? void 0 : _e.unreadIndicator;
|
|
2604
|
-
const backgroundColor = indicator == null ? void 0 : indicator.backgroundColor;
|
|
2605
|
-
const borderRadius = indicator == null ? void 0 : indicator.borderRadius;
|
|
2606
|
-
const color = (_f = indicator == null ? void 0 : indicator.font) == null ? void 0 : _f.color;
|
|
2607
|
-
const fontSize = (_g = indicator == null ? void 0 : indicator.font) == null ? void 0 : _g.size;
|
|
2727
|
+
static getStyles(theme2) {
|
|
2728
|
+
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;
|
|
2608
2729
|
return `
|
|
2609
|
-
|
|
2730
|
+
${CourierUnreadCountBadge.id} {
|
|
2610
2731
|
display: inline-block;
|
|
2611
2732
|
}
|
|
2612
2733
|
|
|
2613
|
-
.unread-badge {
|
|
2614
|
-
background-color: ${backgroundColor};
|
|
2615
|
-
color: ${color};
|
|
2616
|
-
border-radius: ${borderRadius};
|
|
2734
|
+
${CourierUnreadCountBadge.id} .unread-badge {
|
|
2617
2735
|
padding: 4px 8px;
|
|
2618
|
-
font-size: ${fontSize};
|
|
2619
2736
|
text-align: center;
|
|
2620
2737
|
display: none;
|
|
2621
2738
|
pointer-events: none;
|
|
2622
2739
|
}
|
|
2740
|
+
|
|
2741
|
+
${CourierUnreadCountBadge.id} .button {
|
|
2742
|
+
background-color: ${(_c = (_b = (_a = theme2.popup) == null ? void 0 : _a.button) == null ? void 0 : _b.unreadIndicator) == null ? void 0 : _c.backgroundColor};
|
|
2743
|
+
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};
|
|
2744
|
+
border-radius: ${(_j = (_i = (_h = theme2.popup) == null ? void 0 : _h.button) == null ? void 0 : _i.unreadIndicator) == null ? void 0 : _j.borderRadius};
|
|
2745
|
+
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};
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
${CourierUnreadCountBadge.id} .header {
|
|
2749
|
+
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};
|
|
2750
|
+
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};
|
|
2751
|
+
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};
|
|
2752
|
+
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};
|
|
2753
|
+
}
|
|
2623
2754
|
`;
|
|
2624
2755
|
}
|
|
2625
2756
|
setCount(count) {
|
|
@@ -2631,22 +2762,18 @@ class CourierUnreadCountBadge extends HTMLElement {
|
|
|
2631
2762
|
this.updateBadge();
|
|
2632
2763
|
}
|
|
2633
2764
|
updateBadge() {
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2765
|
+
if (this._badge) {
|
|
2766
|
+
if (this._count > 0) {
|
|
2767
|
+
this._badge.textContent = this._count.toString();
|
|
2768
|
+
this._badge.style.display = "block";
|
|
2769
|
+
} else {
|
|
2770
|
+
this._badge.style.display = "none";
|
|
2771
|
+
}
|
|
2640
2772
|
}
|
|
2641
2773
|
}
|
|
2642
|
-
disconnectedCallback() {
|
|
2643
|
-
this._themeSubscription.unsubscribe();
|
|
2644
|
-
}
|
|
2645
2774
|
}
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
}
|
|
2649
|
-
class CourierInboxHeaderTitle extends HTMLElement {
|
|
2775
|
+
registerElement(CourierUnreadCountBadge);
|
|
2776
|
+
class CourierInboxHeaderTitle extends CourierBaseElement {
|
|
2650
2777
|
constructor(themeManager, option) {
|
|
2651
2778
|
super();
|
|
2652
2779
|
// Theme
|
|
@@ -2655,49 +2782,37 @@ class CourierInboxHeaderTitle extends HTMLElement {
|
|
|
2655
2782
|
__publicField(this, "_option");
|
|
2656
2783
|
__publicField(this, "_feedType");
|
|
2657
2784
|
// Components
|
|
2785
|
+
__publicField(this, "_style");
|
|
2658
2786
|
__publicField(this, "_titleElement");
|
|
2659
2787
|
__publicField(this, "_iconElement");
|
|
2660
2788
|
__publicField(this, "_unreadBadge");
|
|
2661
|
-
__publicField(this, "_container");
|
|
2662
|
-
__publicField(this, "_style");
|
|
2663
2789
|
this._option = option;
|
|
2664
|
-
const shadow = this.attachShadow({ mode: "open" });
|
|
2665
|
-
this._style = document.createElement("style");
|
|
2666
|
-
this._container = document.createElement("div");
|
|
2667
|
-
this._container.className = "title-section";
|
|
2668
|
-
this._iconElement = new CourierIcon(void 0, this._option.icon.svg);
|
|
2669
|
-
this._titleElement = document.createElement("h2");
|
|
2670
|
-
this._unreadBadge = new CourierUnreadCountBadge({
|
|
2671
|
-
themeBus: themeManager,
|
|
2672
|
-
location: "header"
|
|
2673
|
-
});
|
|
2674
|
-
this._container.appendChild(this._iconElement);
|
|
2675
|
-
this._container.appendChild(this._titleElement);
|
|
2676
|
-
this._container.appendChild(this._unreadBadge);
|
|
2677
|
-
shadow.appendChild(this._style);
|
|
2678
|
-
shadow.appendChild(this._container);
|
|
2679
2790
|
this._themeSubscription = themeManager.subscribe((_) => {
|
|
2680
2791
|
this.refreshTheme(this._feedType ?? "inbox");
|
|
2681
2792
|
});
|
|
2682
|
-
this.refreshTheme(this._feedType ?? "inbox");
|
|
2683
2793
|
}
|
|
2684
|
-
|
|
2794
|
+
static get id() {
|
|
2795
|
+
return "courier-inbox-header-title";
|
|
2796
|
+
}
|
|
2797
|
+
get theme() {
|
|
2798
|
+
return this._themeSubscription.manager.getTheme();
|
|
2799
|
+
}
|
|
2800
|
+
static getStyles(theme2) {
|
|
2685
2801
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2686
|
-
const theme2 = this._themeSubscription.manager.getTheme();
|
|
2687
2802
|
return `
|
|
2688
|
-
.
|
|
2803
|
+
${CourierInboxHeaderTitle.id} {
|
|
2689
2804
|
display: flex;
|
|
2690
2805
|
align-items: center;
|
|
2691
2806
|
gap: 8px;
|
|
2692
2807
|
position: relative;
|
|
2693
2808
|
}
|
|
2694
2809
|
|
|
2695
|
-
courier-icon {
|
|
2810
|
+
${CourierInboxHeaderTitle.id} courier-icon {
|
|
2696
2811
|
display: flex;
|
|
2697
2812
|
align-items: center;
|
|
2698
2813
|
}
|
|
2699
2814
|
|
|
2700
|
-
h2 {
|
|
2815
|
+
${CourierInboxHeaderTitle.id} h2 {
|
|
2701
2816
|
margin: 0;
|
|
2702
2817
|
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"};
|
|
2703
2818
|
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"};
|
|
@@ -2705,48 +2820,68 @@ class CourierInboxHeaderTitle extends HTMLElement {
|
|
|
2705
2820
|
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"};
|
|
2706
2821
|
}
|
|
2707
2822
|
|
|
2708
|
-
courier-unread-count-badge {
|
|
2823
|
+
${CourierInboxHeaderTitle.id} courier-unread-count-badge {
|
|
2709
2824
|
margin-left: 4px;
|
|
2710
2825
|
}
|
|
2711
2826
|
`;
|
|
2712
2827
|
}
|
|
2828
|
+
onComponentMounted() {
|
|
2829
|
+
this._style = injectGlobalStyle(CourierInboxHeaderTitle.id, CourierInboxHeaderTitle.getStyles(this.theme));
|
|
2830
|
+
this._iconElement = new CourierIcon(void 0, this._option.icon.svg);
|
|
2831
|
+
this._titleElement = document.createElement("h2");
|
|
2832
|
+
this._unreadBadge = new CourierUnreadCountBadge({
|
|
2833
|
+
themeBus: this._themeSubscription.manager,
|
|
2834
|
+
location: "header"
|
|
2835
|
+
});
|
|
2836
|
+
this.appendChild(this._iconElement);
|
|
2837
|
+
this.appendChild(this._titleElement);
|
|
2838
|
+
this.appendChild(this._unreadBadge);
|
|
2839
|
+
this.refreshTheme(this._feedType ?? "inbox");
|
|
2840
|
+
}
|
|
2841
|
+
onComponentUnmounted() {
|
|
2842
|
+
var _a;
|
|
2843
|
+
this._themeSubscription.unsubscribe();
|
|
2844
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
2845
|
+
}
|
|
2713
2846
|
refreshTheme(feedType) {
|
|
2847
|
+
var _a;
|
|
2714
2848
|
this._feedType = feedType;
|
|
2715
|
-
this._style
|
|
2716
|
-
|
|
2849
|
+
if (this._style) {
|
|
2850
|
+
this._style.textContent = CourierInboxHeaderTitle.getStyles(this.theme);
|
|
2851
|
+
}
|
|
2852
|
+
(_a = this._unreadBadge) == null ? void 0 : _a.refreshTheme("header");
|
|
2717
2853
|
this.updateFilter();
|
|
2718
2854
|
}
|
|
2719
2855
|
updateSelectedOption(option, feedType, unreadCount) {
|
|
2856
|
+
var _a;
|
|
2720
2857
|
this._option = option;
|
|
2721
2858
|
this._feedType = feedType;
|
|
2722
|
-
this._unreadBadge.setCount(unreadCount);
|
|
2859
|
+
(_a = this._unreadBadge) == null ? void 0 : _a.setCount(unreadCount);
|
|
2723
2860
|
this.updateFilter();
|
|
2724
2861
|
}
|
|
2725
2862
|
updateFilter() {
|
|
2726
|
-
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;
|
|
2863
|
+
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;
|
|
2727
2864
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
2728
2865
|
switch (this._feedType) {
|
|
2729
2866
|
case "inbox":
|
|
2730
|
-
this._titleElement
|
|
2731
|
-
|
|
2732
|
-
|
|
2867
|
+
if (this._titleElement) {
|
|
2868
|
+
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";
|
|
2869
|
+
}
|
|
2870
|
+
(_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);
|
|
2871
|
+
(_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");
|
|
2733
2872
|
break;
|
|
2734
2873
|
case "archive":
|
|
2735
|
-
this._titleElement
|
|
2736
|
-
|
|
2737
|
-
|
|
2874
|
+
if (this._titleElement) {
|
|
2875
|
+
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";
|
|
2876
|
+
}
|
|
2877
|
+
(_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);
|
|
2878
|
+
(_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");
|
|
2738
2879
|
break;
|
|
2739
2880
|
}
|
|
2740
2881
|
}
|
|
2741
|
-
// Disconnect the theme subscription
|
|
2742
|
-
disconnectedCallback() {
|
|
2743
|
-
this._themeSubscription.unsubscribe();
|
|
2744
|
-
}
|
|
2745
2882
|
}
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
}
|
|
2749
|
-
class CourierInboxHeader extends CourierElement {
|
|
2883
|
+
registerElement(CourierInboxHeaderTitle);
|
|
2884
|
+
class CourierInboxHeader extends CourierFactoryElement {
|
|
2750
2885
|
constructor(props) {
|
|
2751
2886
|
super();
|
|
2752
2887
|
// Theme
|
|
@@ -2766,7 +2901,23 @@ class CourierInboxHeader extends CourierElement {
|
|
|
2766
2901
|
});
|
|
2767
2902
|
this._onFeedTypeChange = props.onFeedTypeChange;
|
|
2768
2903
|
}
|
|
2769
|
-
|
|
2904
|
+
static get id() {
|
|
2905
|
+
return "courier-inbox-header";
|
|
2906
|
+
}
|
|
2907
|
+
static get observedAttributes() {
|
|
2908
|
+
return ["icon", "title", "feed-type"];
|
|
2909
|
+
}
|
|
2910
|
+
get theme() {
|
|
2911
|
+
return this._themeSubscription.manager.getTheme();
|
|
2912
|
+
}
|
|
2913
|
+
onComponentMounted() {
|
|
2914
|
+
this._style = injectGlobalStyle(CourierInboxHeader.id, CourierInboxHeader.getStyles(this.theme));
|
|
2915
|
+
}
|
|
2916
|
+
onComponentUmounted() {
|
|
2917
|
+
var _a;
|
|
2918
|
+
this._themeSubscription.unsubscribe();
|
|
2919
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
2920
|
+
}
|
|
2770
2921
|
getFilterOptions() {
|
|
2771
2922
|
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;
|
|
2772
2923
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
@@ -2847,19 +2998,13 @@ class CourierInboxHeader extends CourierElement {
|
|
|
2847
2998
|
}
|
|
2848
2999
|
];
|
|
2849
3000
|
}
|
|
2850
|
-
static get observedAttributes() {
|
|
2851
|
-
return ["icon", "title", "feed-type"];
|
|
2852
|
-
}
|
|
2853
3001
|
refreshTheme() {
|
|
2854
|
-
var _a, _b
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
if (header) {
|
|
2858
|
-
header.style.backgroundColor = ((_c = (_b = theme2.inbox) == null ? void 0 : _b.header) == null ? void 0 : _c.backgroundColor) ?? CourierColors.white[500];
|
|
2859
|
-
header.style.boxShadow = ((_e = (_d = theme2.inbox) == null ? void 0 : _d.header) == null ? void 0 : _e.shadow) ?? `0px 1px 0px 0px ${CourierColors.gray[500]}`;
|
|
3002
|
+
var _a, _b;
|
|
3003
|
+
if (this._style) {
|
|
3004
|
+
this._style.textContent = CourierInboxHeader.getStyles(this.theme);
|
|
2860
3005
|
}
|
|
2861
|
-
(
|
|
2862
|
-
(
|
|
3006
|
+
(_a = this._filterMenu) == null ? void 0 : _a.setOptions(this.getFilterOptions());
|
|
3007
|
+
(_b = this._actionMenu) == null ? void 0 : _b.setOptions(this.getActionOptions());
|
|
2863
3008
|
}
|
|
2864
3009
|
handleOptionMenuItemClick(feedType, option) {
|
|
2865
3010
|
this._feedType = feedType;
|
|
@@ -2869,12 +3014,9 @@ class CourierInboxHeader extends CourierElement {
|
|
|
2869
3014
|
this._onFeedTypeChange(feedType);
|
|
2870
3015
|
}
|
|
2871
3016
|
render(props) {
|
|
3017
|
+
var _a, _b;
|
|
2872
3018
|
this._feedType = props.feedType;
|
|
2873
3019
|
this._unreadCount = props.unreadCount;
|
|
2874
|
-
this.refreshTitleSection();
|
|
2875
|
-
}
|
|
2876
|
-
refreshTitleSection() {
|
|
2877
|
-
var _a, _b;
|
|
2878
3020
|
const option = this.getFilterOptions().find((opt) => ["inbox", "archive"].includes(opt.id) && opt.id === this._feedType);
|
|
2879
3021
|
if (option) {
|
|
2880
3022
|
(_a = this._titleSection) == null ? void 0 : _a.updateSelectedOption(option, this._feedType, this._feedType === "inbox" ? this._unreadCount : 0);
|
|
@@ -2882,11 +3024,7 @@ class CourierInboxHeader extends CourierElement {
|
|
|
2882
3024
|
}
|
|
2883
3025
|
}
|
|
2884
3026
|
build(newElement) {
|
|
2885
|
-
var _a;
|
|
2886
3027
|
super.build(newElement);
|
|
2887
|
-
this._style = document.createElement("style");
|
|
2888
|
-
this._style.textContent = this.getStyles();
|
|
2889
|
-
(_a = this.shadow) == null ? void 0 : _a.appendChild(this._style);
|
|
2890
3028
|
this.refreshTheme();
|
|
2891
3029
|
}
|
|
2892
3030
|
defaultElement() {
|
|
@@ -2907,53 +3045,46 @@ class CourierInboxHeader extends CourierElement {
|
|
|
2907
3045
|
actions.className = "actions";
|
|
2908
3046
|
actions.appendChild(this._filterMenu);
|
|
2909
3047
|
actions.appendChild(this._actionMenu);
|
|
2910
|
-
const
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
return
|
|
2916
|
-
}
|
|
2917
|
-
getStyles() {
|
|
3048
|
+
const headerContent = document.createElement("div");
|
|
3049
|
+
headerContent.className = "header-content";
|
|
3050
|
+
headerContent.appendChild(this._titleSection);
|
|
3051
|
+
headerContent.appendChild(spacer);
|
|
3052
|
+
headerContent.appendChild(actions);
|
|
3053
|
+
return headerContent;
|
|
3054
|
+
}
|
|
3055
|
+
static getStyles(theme2) {
|
|
3056
|
+
var _a, _b, _c, _d;
|
|
2918
3057
|
return `
|
|
2919
|
-
|
|
2920
|
-
z-index: 100;
|
|
2921
|
-
}
|
|
2922
|
-
|
|
2923
|
-
.courier-inbox-header {
|
|
3058
|
+
${CourierInboxHeader.id} {
|
|
2924
3059
|
display: flex;
|
|
2925
3060
|
align-items: center;
|
|
2926
|
-
|
|
2927
|
-
padding: 10px 10px 10px 16px;
|
|
2928
|
-
background-color: ${CourierColors.white[500]};
|
|
2929
|
-
box-shadow: 0px 1px 0px 0px ${CourierColors.gray[500]};
|
|
3061
|
+
flex-shrink: 0;
|
|
2930
3062
|
}
|
|
2931
3063
|
|
|
2932
|
-
.header-content {
|
|
3064
|
+
${CourierInboxHeader.id} .header-content {
|
|
3065
|
+
padding: 10px 10px 10px 16px;
|
|
3066
|
+
background-color: ${((_b = (_a = theme2.inbox) == null ? void 0 : _a.header) == null ? void 0 : _b.backgroundColor) ?? CourierColors.white[500]};
|
|
3067
|
+
box-shadow: ${((_d = (_c = theme2.inbox) == null ? void 0 : _c.header) == null ? void 0 : _d.shadow) ?? `0px 1px 0px 0px red`};
|
|
2933
3068
|
display: flex;
|
|
2934
3069
|
align-items: center;
|
|
3070
|
+
justify-content: space-between;
|
|
2935
3071
|
flex: 1;
|
|
3072
|
+
z-index: 100;
|
|
2936
3073
|
}
|
|
2937
3074
|
|
|
2938
|
-
.spacer {
|
|
3075
|
+
${CourierInboxHeader.id} .spacer {
|
|
2939
3076
|
flex: 1;
|
|
2940
3077
|
}
|
|
2941
3078
|
|
|
2942
|
-
.actions {
|
|
3079
|
+
${CourierInboxHeader.id} .actions {
|
|
2943
3080
|
display: flex;
|
|
2944
3081
|
align-items: center;
|
|
2945
3082
|
gap: 4px;
|
|
2946
3083
|
}
|
|
2947
3084
|
`;
|
|
2948
3085
|
}
|
|
2949
|
-
// Disconnect the theme subscription
|
|
2950
|
-
disconnectedCallback() {
|
|
2951
|
-
this._themeSubscription.unsubscribe();
|
|
2952
|
-
}
|
|
2953
|
-
}
|
|
2954
|
-
if (!customElements.get("courier-inbox-header")) {
|
|
2955
|
-
customElements.define("courier-inbox-header", CourierInboxHeader);
|
|
2956
3086
|
}
|
|
3087
|
+
registerElement(CourierInboxHeader);
|
|
2957
3088
|
class CourierInboxDataStoreListener {
|
|
2958
3089
|
constructor(events) {
|
|
2959
3090
|
__publicField(this, "events");
|
|
@@ -3424,7 +3555,7 @@ const defaultDarkTheme = {
|
|
|
3424
3555
|
},
|
|
3425
3556
|
loading: {
|
|
3426
3557
|
animation: {
|
|
3427
|
-
barColor: CourierColors.
|
|
3558
|
+
barColor: CourierColors.gray[400],
|
|
3428
3559
|
barHeight: "14px",
|
|
3429
3560
|
barBorderRadius: "14px",
|
|
3430
3561
|
duration: "2s"
|
|
@@ -3732,20 +3863,19 @@ class CourierInboxThemeManager {
|
|
|
3732
3863
|
this._subscriptions = [];
|
|
3733
3864
|
}
|
|
3734
3865
|
}
|
|
3735
|
-
class CourierInbox extends
|
|
3866
|
+
class CourierInbox extends CourierBaseElement {
|
|
3736
3867
|
constructor(themeManager) {
|
|
3737
|
-
var _a;
|
|
3738
3868
|
super();
|
|
3739
3869
|
// State
|
|
3740
3870
|
__publicField(this, "_currentFeed", "inbox");
|
|
3741
3871
|
// Theming
|
|
3742
3872
|
__publicField(this, "_themeManager");
|
|
3743
3873
|
// Components
|
|
3744
|
-
__publicField(this, "
|
|
3874
|
+
__publicField(this, "_inboxStyle");
|
|
3875
|
+
__publicField(this, "_unreadIndicatorStyle");
|
|
3745
3876
|
__publicField(this, "_list");
|
|
3746
3877
|
__publicField(this, "_datastoreListener");
|
|
3747
3878
|
__publicField(this, "_authListener");
|
|
3748
|
-
__publicField(this, "_style");
|
|
3749
3879
|
// Header
|
|
3750
3880
|
__publicField(this, "_header");
|
|
3751
3881
|
__publicField(this, "_headerFactory");
|
|
@@ -3760,8 +3890,27 @@ class CourierInbox extends HTMLElement {
|
|
|
3760
3890
|
feedType: this._currentFeed,
|
|
3761
3891
|
height: "768px"
|
|
3762
3892
|
});
|
|
3763
|
-
this._shadow = this.attachShadow({ mode: "open" });
|
|
3764
3893
|
this._themeManager = themeManager ?? new CourierInboxThemeManager(defaultLightTheme);
|
|
3894
|
+
}
|
|
3895
|
+
static get id() {
|
|
3896
|
+
return "courier-inbox";
|
|
3897
|
+
}
|
|
3898
|
+
get theme() {
|
|
3899
|
+
return this._themeManager.getTheme();
|
|
3900
|
+
}
|
|
3901
|
+
setLightTheme(theme2) {
|
|
3902
|
+
this._themeManager.setLightTheme(theme2);
|
|
3903
|
+
}
|
|
3904
|
+
setDarkTheme(theme2) {
|
|
3905
|
+
this._themeManager.setDarkTheme(theme2);
|
|
3906
|
+
}
|
|
3907
|
+
static get observedAttributes() {
|
|
3908
|
+
return ["height", "light-theme", "dark-theme", "mode", "message-click", "message-action-click", "message-long-press"];
|
|
3909
|
+
}
|
|
3910
|
+
onComponentMounted() {
|
|
3911
|
+
var _a, _b;
|
|
3912
|
+
this._inboxStyle = injectGlobalStyle(CourierInbox.id, this.getStyles());
|
|
3913
|
+
this._unreadIndicatorStyle = injectGlobalStyle(CourierUnreadCountBadge.id, CourierUnreadCountBadge.getStyles(this.theme));
|
|
3765
3914
|
this._header = new CourierInboxHeader({
|
|
3766
3915
|
themeManager: this._themeManager,
|
|
3767
3916
|
onFeedTypeChange: (feedType) => {
|
|
@@ -3769,20 +3918,20 @@ class CourierInbox extends HTMLElement {
|
|
|
3769
3918
|
}
|
|
3770
3919
|
});
|
|
3771
3920
|
this._header.build(void 0);
|
|
3772
|
-
this.
|
|
3921
|
+
this.appendChild(this._header);
|
|
3773
3922
|
this._list = new CourierInboxList({
|
|
3774
3923
|
themeManager: this._themeManager,
|
|
3775
3924
|
onRefresh: () => {
|
|
3776
3925
|
this.refresh();
|
|
3777
3926
|
},
|
|
3778
3927
|
onPaginationTrigger: async (feedType) => {
|
|
3779
|
-
var _a2,
|
|
3928
|
+
var _a2, _b2;
|
|
3780
3929
|
try {
|
|
3781
3930
|
await CourierInboxDatastore.shared.fetchNextPageOfMessages({
|
|
3782
3931
|
feedType
|
|
3783
3932
|
});
|
|
3784
3933
|
} catch (error) {
|
|
3785
|
-
(
|
|
3934
|
+
(_b2 = (_a2 = Courier.shared.client) == null ? void 0 : _a2.options.logger) == null ? void 0 : _b2.error("Failed to fetch next page of messages:", error);
|
|
3786
3935
|
}
|
|
3787
3936
|
},
|
|
3788
3937
|
onMessageClick: (message, index) => {
|
|
@@ -3814,41 +3963,45 @@ class CourierInbox extends HTMLElement {
|
|
|
3814
3963
|
(_a2 = this._onMessageLongPress) == null ? void 0 : _a2.call(this, { message, index });
|
|
3815
3964
|
}
|
|
3816
3965
|
});
|
|
3817
|
-
this._style = document.createElement("style");
|
|
3818
3966
|
this.refreshTheme();
|
|
3819
|
-
this.
|
|
3820
|
-
this._shadow.appendChild(this._list);
|
|
3967
|
+
this.appendChild(this._list);
|
|
3821
3968
|
this._datastoreListener = new CourierInboxDataStoreListener({
|
|
3822
3969
|
onError: (error) => {
|
|
3823
|
-
|
|
3970
|
+
var _a2;
|
|
3971
|
+
(_a2 = this._list) == null ? void 0 : _a2.setError(error);
|
|
3824
3972
|
},
|
|
3825
3973
|
onDataSetChange: (dataSet, feedType) => {
|
|
3974
|
+
var _a2;
|
|
3826
3975
|
if (this._currentFeed === feedType) {
|
|
3827
|
-
this._list.setDataSet(dataSet);
|
|
3976
|
+
(_a2 = this._list) == null ? void 0 : _a2.setDataSet(dataSet);
|
|
3828
3977
|
this.updateHeader();
|
|
3829
3978
|
}
|
|
3830
3979
|
},
|
|
3831
3980
|
onPageAdded: (dataSet, feedType) => {
|
|
3981
|
+
var _a2;
|
|
3832
3982
|
if (this._currentFeed === feedType) {
|
|
3833
|
-
this._list.addPage(dataSet);
|
|
3983
|
+
(_a2 = this._list) == null ? void 0 : _a2.addPage(dataSet);
|
|
3834
3984
|
this.updateHeader();
|
|
3835
3985
|
}
|
|
3836
3986
|
},
|
|
3837
3987
|
onMessageAdd: (message, index, feedType) => {
|
|
3988
|
+
var _a2;
|
|
3838
3989
|
if (this._currentFeed === feedType) {
|
|
3839
|
-
this._list.addMessage(message, index);
|
|
3990
|
+
(_a2 = this._list) == null ? void 0 : _a2.addMessage(message, index);
|
|
3840
3991
|
this.updateHeader();
|
|
3841
3992
|
}
|
|
3842
3993
|
},
|
|
3843
3994
|
onMessageRemove: (_, index, feedType) => {
|
|
3995
|
+
var _a2;
|
|
3844
3996
|
if (this._currentFeed === feedType) {
|
|
3845
|
-
this._list.removeMessage(index);
|
|
3997
|
+
(_a2 = this._list) == null ? void 0 : _a2.removeMessage(index);
|
|
3846
3998
|
this.updateHeader();
|
|
3847
3999
|
}
|
|
3848
4000
|
},
|
|
3849
4001
|
onMessageUpdate: (message, index, feedType) => {
|
|
4002
|
+
var _a2;
|
|
3850
4003
|
if (this._currentFeed === feedType) {
|
|
3851
|
-
this._list.updateMessage(message, index);
|
|
4004
|
+
(_a2 = this._list) == null ? void 0 : _a2.updateMessage(message, index);
|
|
3852
4005
|
this.updateHeader();
|
|
3853
4006
|
}
|
|
3854
4007
|
},
|
|
@@ -3863,39 +4016,38 @@ class CourierInbox extends HTMLElement {
|
|
|
3863
4016
|
this._authListener = Courier.shared.addAuthenticationListener((_) => {
|
|
3864
4017
|
this.refresh();
|
|
3865
4018
|
});
|
|
3866
|
-
if ((_a = Courier.shared.client) == null ? void 0 : _a.options.userId) {
|
|
3867
|
-
|
|
4019
|
+
if (!((_a = Courier.shared.client) == null ? void 0 : _a.options.userId)) {
|
|
4020
|
+
(_b = Courier.shared.client) == null ? void 0 : _b.options.logger.error("No user signed in. Please call Courier.shared.signIn(...) to load the inbox.");
|
|
4021
|
+
return;
|
|
3868
4022
|
}
|
|
4023
|
+
this.refresh();
|
|
3869
4024
|
}
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
this.
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
this._themeManager.setDarkTheme(theme2);
|
|
3878
|
-
}
|
|
3879
|
-
static get observedAttributes() {
|
|
3880
|
-
return ["height", "light-theme", "dark-theme", "mode", "message-click", "message-action-click", "message-long-press"];
|
|
4025
|
+
onComponentUnmounted() {
|
|
4026
|
+
var _a, _b, _c, _d;
|
|
4027
|
+
this._themeManager.cleanup();
|
|
4028
|
+
(_a = this._datastoreListener) == null ? void 0 : _a.remove();
|
|
4029
|
+
(_b = this._authListener) == null ? void 0 : _b.remove();
|
|
4030
|
+
(_c = this._inboxStyle) == null ? void 0 : _c.remove();
|
|
4031
|
+
(_d = this._unreadIndicatorStyle) == null ? void 0 : _d.remove();
|
|
3881
4032
|
}
|
|
3882
4033
|
refreshTheme() {
|
|
3883
|
-
|
|
4034
|
+
if (this._inboxStyle) {
|
|
4035
|
+
this._inboxStyle.textContent = this.getStyles();
|
|
4036
|
+
}
|
|
4037
|
+
if (this._unreadIndicatorStyle) {
|
|
4038
|
+
this._unreadIndicatorStyle.textContent = CourierUnreadCountBadge.getStyles(this.theme);
|
|
4039
|
+
}
|
|
3884
4040
|
}
|
|
3885
4041
|
getStyles() {
|
|
3886
4042
|
return `
|
|
3887
|
-
|
|
4043
|
+
${CourierInbox.id} {
|
|
3888
4044
|
display: flex;
|
|
3889
4045
|
flex-direction: column;
|
|
3890
4046
|
width: 100%;
|
|
3891
4047
|
height: ${this._defaultProps.height};
|
|
3892
4048
|
}
|
|
3893
4049
|
|
|
3894
|
-
courier-inbox-
|
|
3895
|
-
flex-shrink: 0;
|
|
3896
|
-
}
|
|
3897
|
-
|
|
3898
|
-
courier-inbox-list {
|
|
4050
|
+
${CourierInbox.id} courier-inbox-list {
|
|
3899
4051
|
flex: 1;
|
|
3900
4052
|
overflow-y: auto;
|
|
3901
4053
|
overflow-x: hidden;
|
|
@@ -3911,19 +4063,24 @@ class CourierInbox extends HTMLElement {
|
|
|
3911
4063
|
this.updateHeader();
|
|
3912
4064
|
}
|
|
3913
4065
|
setLoadingState(factory) {
|
|
3914
|
-
|
|
4066
|
+
var _a;
|
|
4067
|
+
(_a = this._list) == null ? void 0 : _a.setLoadingStateFactory(factory);
|
|
3915
4068
|
}
|
|
3916
4069
|
setEmptyState(factory) {
|
|
3917
|
-
|
|
4070
|
+
var _a;
|
|
4071
|
+
(_a = this._list) == null ? void 0 : _a.setEmptyStateFactory(factory);
|
|
3918
4072
|
}
|
|
3919
4073
|
setErrorState(factory) {
|
|
3920
|
-
|
|
4074
|
+
var _a;
|
|
4075
|
+
(_a = this._list) == null ? void 0 : _a.setErrorStateFactory(factory);
|
|
3921
4076
|
}
|
|
3922
4077
|
setListItem(factory) {
|
|
3923
|
-
|
|
4078
|
+
var _a;
|
|
4079
|
+
(_a = this._list) == null ? void 0 : _a.setListItemFactory(factory);
|
|
3924
4080
|
}
|
|
3925
4081
|
setPaginationItem(factory) {
|
|
3926
|
-
|
|
4082
|
+
var _a;
|
|
4083
|
+
(_a = this._list) == null ? void 0 : _a.setPaginationItemFactory(factory);
|
|
3927
4084
|
}
|
|
3928
4085
|
onMessageClick(handler) {
|
|
3929
4086
|
this._onMessageClick = handler;
|
|
@@ -3935,30 +4092,31 @@ class CourierInbox extends HTMLElement {
|
|
|
3935
4092
|
this._onMessageLongPress = handler;
|
|
3936
4093
|
}
|
|
3937
4094
|
setFeedType(feedType) {
|
|
4095
|
+
var _a;
|
|
3938
4096
|
this._currentFeed = feedType;
|
|
3939
|
-
this._list.setFeedType(feedType);
|
|
4097
|
+
(_a = this._list) == null ? void 0 : _a.setFeedType(feedType);
|
|
3940
4098
|
this.updateHeader();
|
|
3941
4099
|
this.load({
|
|
3942
|
-
feedType: this._currentFeed,
|
|
3943
4100
|
canUseCache: true
|
|
3944
4101
|
});
|
|
3945
4102
|
}
|
|
3946
4103
|
updateHeader() {
|
|
4104
|
+
var _a, _b, _c, _d;
|
|
3947
4105
|
const props = {
|
|
3948
4106
|
feedType: this._currentFeed,
|
|
3949
4107
|
unreadCount: CourierInboxDatastore.shared.unreadCount,
|
|
3950
|
-
messageCount: this._list.messages.length
|
|
4108
|
+
messageCount: ((_a = this._list) == null ? void 0 : _a.messages.length) ?? 0
|
|
3951
4109
|
};
|
|
3952
4110
|
switch (this._headerFactory) {
|
|
3953
4111
|
case void 0:
|
|
3954
|
-
this._header.render(props);
|
|
4112
|
+
(_b = this._header) == null ? void 0 : _b.render(props);
|
|
3955
4113
|
break;
|
|
3956
4114
|
case null:
|
|
3957
|
-
this._header.build(null);
|
|
4115
|
+
(_c = this._header) == null ? void 0 : _c.build(null);
|
|
3958
4116
|
break;
|
|
3959
4117
|
default:
|
|
3960
4118
|
const headerElement = this._headerFactory(props);
|
|
3961
|
-
this._header.build(headerElement);
|
|
4119
|
+
(_d = this._header) == null ? void 0 : _d.build(headerElement);
|
|
3962
4120
|
break;
|
|
3963
4121
|
}
|
|
3964
4122
|
}
|
|
@@ -3968,19 +4126,9 @@ class CourierInbox extends HTMLElement {
|
|
|
3968
4126
|
}
|
|
3969
4127
|
refresh() {
|
|
3970
4128
|
this.load({
|
|
3971
|
-
feedType: this._currentFeed,
|
|
3972
4129
|
canUseCache: false
|
|
3973
4130
|
});
|
|
3974
4131
|
}
|
|
3975
|
-
connectedCallback() {
|
|
3976
|
-
this.refresh();
|
|
3977
|
-
}
|
|
3978
|
-
disconnectedCallback() {
|
|
3979
|
-
var _a, _b;
|
|
3980
|
-
this._themeManager.cleanup();
|
|
3981
|
-
(_a = this._datastoreListener) == null ? void 0 : _a.remove();
|
|
3982
|
-
(_b = this._authListener) == null ? void 0 : _b.remove();
|
|
3983
|
-
}
|
|
3984
4132
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
3985
4133
|
var _a, _b, _c, _d, _e, _f;
|
|
3986
4134
|
if (oldValue === newValue) return;
|
|
@@ -4038,22 +4186,35 @@ class CourierInbox extends HTMLElement {
|
|
|
4038
4186
|
}
|
|
4039
4187
|
}
|
|
4040
4188
|
}
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
}
|
|
4044
|
-
class CourierInboxMenuButton extends CourierElement {
|
|
4189
|
+
registerElement(CourierInbox);
|
|
4190
|
+
class CourierInboxMenuButton extends CourierFactoryElement {
|
|
4045
4191
|
constructor(themeBus) {
|
|
4046
4192
|
super();
|
|
4047
4193
|
// Theme
|
|
4048
4194
|
__publicField(this, "_themeSubscription");
|
|
4049
4195
|
// Components
|
|
4196
|
+
__publicField(this, "_style");
|
|
4050
4197
|
__publicField(this, "_container");
|
|
4051
4198
|
__publicField(this, "_triggerButton");
|
|
4052
4199
|
__publicField(this, "_unreadCountBadge");
|
|
4053
4200
|
this._themeSubscription = themeBus.subscribe((_) => {
|
|
4054
|
-
this.
|
|
4201
|
+
this.refreshTheme();
|
|
4055
4202
|
});
|
|
4056
4203
|
}
|
|
4204
|
+
static get id() {
|
|
4205
|
+
return "courier-inbox-menu-button";
|
|
4206
|
+
}
|
|
4207
|
+
get theme() {
|
|
4208
|
+
return this._themeSubscription.manager.getTheme();
|
|
4209
|
+
}
|
|
4210
|
+
onComponentMounted() {
|
|
4211
|
+
this._style = injectGlobalStyle(CourierInboxMenuButton.id, CourierInboxMenuButton.getStyles(this.theme));
|
|
4212
|
+
}
|
|
4213
|
+
onComponentUnmounted() {
|
|
4214
|
+
var _a;
|
|
4215
|
+
this._themeSubscription.unsubscribe();
|
|
4216
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
4217
|
+
}
|
|
4057
4218
|
defaultElement() {
|
|
4058
4219
|
this._container = document.createElement("div");
|
|
4059
4220
|
this._container.className = "menu-button-container";
|
|
@@ -4063,23 +4224,20 @@ class CourierInboxMenuButton extends CourierElement {
|
|
|
4063
4224
|
location: "button"
|
|
4064
4225
|
});
|
|
4065
4226
|
this._unreadCountBadge.id = "unread-badge";
|
|
4066
|
-
const style = document.createElement("style");
|
|
4067
|
-
style.textContent = this.getStyles();
|
|
4068
|
-
this._container.appendChild(style);
|
|
4069
4227
|
this._container.appendChild(this._triggerButton);
|
|
4070
4228
|
this._container.appendChild(this._unreadCountBadge);
|
|
4071
|
-
this.
|
|
4072
|
-
this.
|
|
4229
|
+
this.appendChild(this._container);
|
|
4230
|
+
this.refreshTheme();
|
|
4073
4231
|
return this._container;
|
|
4074
4232
|
}
|
|
4075
|
-
getStyles() {
|
|
4233
|
+
static getStyles(_theme) {
|
|
4076
4234
|
return `
|
|
4077
|
-
.menu-button-container {
|
|
4235
|
+
${CourierInboxMenuButton.id} .menu-button-container {
|
|
4078
4236
|
position: relative;
|
|
4079
4237
|
display: inline-block;
|
|
4080
4238
|
}
|
|
4081
4239
|
|
|
4082
|
-
#unread-badge {
|
|
4240
|
+
${CourierInboxMenuButton.id} #unread-badge {
|
|
4083
4241
|
position: absolute;
|
|
4084
4242
|
top: -8px;
|
|
4085
4243
|
left: 50%;
|
|
@@ -4090,26 +4248,20 @@ class CourierInboxMenuButton extends CourierElement {
|
|
|
4090
4248
|
onUnreadCountChange(unreadCount) {
|
|
4091
4249
|
var _a;
|
|
4092
4250
|
(_a = this._unreadCountBadge) == null ? void 0 : _a.setCount(unreadCount);
|
|
4093
|
-
this.
|
|
4094
|
-
}
|
|
4095
|
-
updateTheme() {
|
|
4096
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
4097
|
-
const theme2 = this._themeSubscription.manager.getTheme();
|
|
4098
|
-
(_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]);
|
|
4099
|
-
(_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);
|
|
4100
|
-
(_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");
|
|
4101
|
-
(_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]);
|
|
4102
|
-
(_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]);
|
|
4103
|
-
(_r = this._unreadCountBadge) == null ? void 0 : _r.refreshTheme("button");
|
|
4251
|
+
this.refreshTheme();
|
|
4104
4252
|
}
|
|
4105
|
-
|
|
4106
|
-
|
|
4253
|
+
refreshTheme() {
|
|
4254
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
4255
|
+
(_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]);
|
|
4256
|
+
(_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);
|
|
4257
|
+
(_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");
|
|
4258
|
+
(_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]);
|
|
4259
|
+
(_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]);
|
|
4260
|
+
(_w = this._unreadCountBadge) == null ? void 0 : _w.refreshTheme("button");
|
|
4107
4261
|
}
|
|
4108
4262
|
}
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
}
|
|
4112
|
-
class CourierInboxMenu extends HTMLElement {
|
|
4263
|
+
registerElement(CourierInboxMenuButton);
|
|
4264
|
+
class CourierInboxPopupMenu extends CourierBaseElement {
|
|
4113
4265
|
constructor() {
|
|
4114
4266
|
super();
|
|
4115
4267
|
// State
|
|
@@ -4131,28 +4283,26 @@ class CourierInboxMenu extends HTMLElement {
|
|
|
4131
4283
|
__publicField(this, "_datastoreListener");
|
|
4132
4284
|
// Factories
|
|
4133
4285
|
__publicField(this, "_popupMenuButtonFactory");
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
this._triggerButton.addEventListener("click", this.togglePopup.bind(this));
|
|
4148
|
-
document.addEventListener("click", this.handleOutsideClick.bind(this));
|
|
4149
|
-
this.updatePopupPosition();
|
|
4150
|
-
this._datastoreListener = new CourierInboxDataStoreListener(this);
|
|
4151
|
-
CourierInboxDatastore.shared.addDataStoreListener(this._datastoreListener);
|
|
4286
|
+
__publicField(this, "handleOutsideClick", (event) => {
|
|
4287
|
+
if (!this._popup) return;
|
|
4288
|
+
const SAFE_SELECTORS = [
|
|
4289
|
+
"courier-inbox-option-menu"
|
|
4290
|
+
];
|
|
4291
|
+
const clickIsInsideAllowedArea = event.composedPath().some((node) => {
|
|
4292
|
+
if (!(node instanceof HTMLElement)) return false;
|
|
4293
|
+
if (node === this._popup || this._popup.contains(node)) return true;
|
|
4294
|
+
return SAFE_SELECTORS.some((sel) => node.matches(sel));
|
|
4295
|
+
});
|
|
4296
|
+
if (clickIsInsideAllowedArea) return;
|
|
4297
|
+
this._popup.style.display = "none";
|
|
4298
|
+
});
|
|
4152
4299
|
this._themeManager.subscribe((_) => {
|
|
4153
4300
|
this.refreshTheme();
|
|
4154
4301
|
});
|
|
4155
4302
|
}
|
|
4303
|
+
static get id() {
|
|
4304
|
+
return "courier-inbox-popup-menu";
|
|
4305
|
+
}
|
|
4156
4306
|
get theme() {
|
|
4157
4307
|
return this._themeManager.getTheme();
|
|
4158
4308
|
}
|
|
@@ -4165,45 +4315,71 @@ class CourierInboxMenu extends HTMLElement {
|
|
|
4165
4315
|
static get observedAttributes() {
|
|
4166
4316
|
return ["popup-alignment", "message-click", "message-action-click", "message-long-press", "popup-width", "popup-height", "top", "right", "bottom", "left", "light-theme", "dark-theme", "mode"];
|
|
4167
4317
|
}
|
|
4318
|
+
onComponentMounted() {
|
|
4319
|
+
this._style = injectGlobalStyle(CourierInboxPopupMenu.id, CourierInboxPopupMenu.getStyles(this.theme, this._width, this._height));
|
|
4320
|
+
this._triggerButton = new CourierInboxMenuButton(this._themeManager);
|
|
4321
|
+
this._triggerButton.build(void 0);
|
|
4322
|
+
this._popup = document.createElement("div");
|
|
4323
|
+
this._popup.className = "popup";
|
|
4324
|
+
this._inbox = new CourierInbox(this._themeManager);
|
|
4325
|
+
this._inbox.setAttribute("height", "100%");
|
|
4326
|
+
this.refreshTheme();
|
|
4327
|
+
this.appendChild(this._triggerButton);
|
|
4328
|
+
this.appendChild(this._popup);
|
|
4329
|
+
this._popup.appendChild(this._inbox);
|
|
4330
|
+
this._triggerButton.addEventListener("click", this.togglePopup.bind(this));
|
|
4331
|
+
document.addEventListener("click", this.handleOutsideClick.bind(this));
|
|
4332
|
+
this.updatePopupPosition();
|
|
4333
|
+
this._datastoreListener = new CourierInboxDataStoreListener(this);
|
|
4334
|
+
CourierInboxDatastore.shared.addDataStoreListener(this._datastoreListener);
|
|
4335
|
+
}
|
|
4336
|
+
onComponentUnmounted() {
|
|
4337
|
+
var _a, _b;
|
|
4338
|
+
(_a = this._style) == null ? void 0 : _a.remove();
|
|
4339
|
+
(_b = this._datastoreListener) == null ? void 0 : _b.remove();
|
|
4340
|
+
this._themeManager.cleanup();
|
|
4341
|
+
}
|
|
4168
4342
|
refreshTheme() {
|
|
4169
|
-
this._style
|
|
4343
|
+
if (this._style) {
|
|
4344
|
+
this._style.textContent = CourierInboxPopupMenu.getStyles(this.theme, this._width, this._height);
|
|
4345
|
+
}
|
|
4170
4346
|
}
|
|
4171
|
-
getStyles() {
|
|
4347
|
+
static getStyles(theme2, width, height) {
|
|
4172
4348
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4173
4349
|
return `
|
|
4174
|
-
|
|
4350
|
+
${CourierInboxPopupMenu.id} {
|
|
4175
4351
|
display: inline-block;
|
|
4176
4352
|
position: relative;
|
|
4177
4353
|
}
|
|
4178
4354
|
|
|
4179
|
-
.menu-button-container {
|
|
4355
|
+
${CourierInboxPopupMenu.id} .menu-button-container {
|
|
4180
4356
|
position: relative;
|
|
4181
4357
|
display: inline-block;
|
|
4182
4358
|
}
|
|
4183
4359
|
|
|
4184
|
-
.popup {
|
|
4360
|
+
${CourierInboxPopupMenu.id} .popup {
|
|
4185
4361
|
display: none;
|
|
4186
4362
|
position: absolute;
|
|
4187
|
-
background: ${((_b = (_a =
|
|
4188
|
-
border-radius: ${((_d = (_c =
|
|
4189
|
-
border: ${((_f = (_e =
|
|
4190
|
-
box-shadow: ${((_h = (_g =
|
|
4363
|
+
background: ${((_b = (_a = theme2.popup) == null ? void 0 : _a.window) == null ? void 0 : _b.backgroundColor) ?? "red"};
|
|
4364
|
+
border-radius: ${((_d = (_c = theme2.popup) == null ? void 0 : _c.window) == null ? void 0 : _d.borderRadius) ?? "8px"};
|
|
4365
|
+
border: ${((_f = (_e = theme2.popup) == null ? void 0 : _e.window) == null ? void 0 : _f.border) ?? `1px solid red`};
|
|
4366
|
+
box-shadow: ${((_h = (_g = theme2.popup) == null ? void 0 : _g.window) == null ? void 0 : _h.shadow) ?? `0px 8px 16px -4px red`};
|
|
4191
4367
|
z-index: 1000;
|
|
4192
|
-
width: ${
|
|
4193
|
-
height: ${
|
|
4368
|
+
width: ${width};
|
|
4369
|
+
height: ${height};
|
|
4194
4370
|
overflow: hidden;
|
|
4195
4371
|
transform: translateZ(0);
|
|
4196
4372
|
will-change: transform;
|
|
4197
4373
|
}
|
|
4198
4374
|
|
|
4199
|
-
#unread-badge {
|
|
4375
|
+
${CourierInboxPopupMenu.id} #unread-badge {
|
|
4200
4376
|
position: absolute;
|
|
4201
4377
|
top: -8px;
|
|
4202
4378
|
left: 50%;
|
|
4203
4379
|
pointer-events: none;
|
|
4204
4380
|
}
|
|
4205
4381
|
|
|
4206
|
-
courier-inbox {
|
|
4382
|
+
${CourierInboxPopupMenu.id} courier-inbox {
|
|
4207
4383
|
height: 100%;
|
|
4208
4384
|
}
|
|
4209
4385
|
`;
|
|
@@ -4259,13 +4435,16 @@ class CourierInboxMenu extends HTMLElement {
|
|
|
4259
4435
|
this.render();
|
|
4260
4436
|
}
|
|
4261
4437
|
onMessageClick(handler) {
|
|
4262
|
-
|
|
4438
|
+
var _a;
|
|
4439
|
+
(_a = this._inbox) == null ? void 0 : _a.onMessageClick(handler);
|
|
4263
4440
|
}
|
|
4264
4441
|
onMessageActionClick(handler) {
|
|
4265
|
-
|
|
4442
|
+
var _a;
|
|
4443
|
+
(_a = this._inbox) == null ? void 0 : _a.onMessageActionClick(handler);
|
|
4266
4444
|
}
|
|
4267
4445
|
onMessageLongPress(handler) {
|
|
4268
|
-
|
|
4446
|
+
var _a;
|
|
4447
|
+
(_a = this._inbox) == null ? void 0 : _a.onMessageLongPress(handler);
|
|
4269
4448
|
}
|
|
4270
4449
|
isValidPosition(value) {
|
|
4271
4450
|
const validPositions = [
|
|
@@ -4282,6 +4461,7 @@ class CourierInboxMenu extends HTMLElement {
|
|
|
4282
4461
|
return validPositions.includes(value);
|
|
4283
4462
|
}
|
|
4284
4463
|
updatePopupPosition() {
|
|
4464
|
+
if (!this._popup) return;
|
|
4285
4465
|
this._popup.style.top = "";
|
|
4286
4466
|
this._popup.style.bottom = "";
|
|
4287
4467
|
this._popup.style.left = "";
|
|
@@ -4334,25 +4514,19 @@ class CourierInboxMenu extends HTMLElement {
|
|
|
4334
4514
|
}
|
|
4335
4515
|
togglePopup(event) {
|
|
4336
4516
|
event.stopPropagation();
|
|
4517
|
+
if (!this._popup) return;
|
|
4337
4518
|
const isVisible = this._popup.style.display === "block";
|
|
4338
|
-
|
|
4339
|
-
this._popup.style.display = "block";
|
|
4340
|
-
} else {
|
|
4341
|
-
this._popup.style.display = "none";
|
|
4342
|
-
}
|
|
4343
|
-
}
|
|
4344
|
-
handleOutsideClick(event) {
|
|
4345
|
-
if (!this.contains(event.target)) {
|
|
4346
|
-
this._popup.style.display = "none";
|
|
4347
|
-
}
|
|
4519
|
+
this._popup.style.display = isVisible ? "none" : "block";
|
|
4348
4520
|
}
|
|
4349
4521
|
setContent(element) {
|
|
4522
|
+
if (!this._inbox) return;
|
|
4350
4523
|
this._inbox.innerHTML = "";
|
|
4351
4524
|
this._inbox.appendChild(element);
|
|
4352
4525
|
}
|
|
4353
4526
|
setSize(width, height) {
|
|
4354
4527
|
this._width = width;
|
|
4355
4528
|
this._height = height;
|
|
4529
|
+
if (!this._popup) return;
|
|
4356
4530
|
this._popup.style.width = width;
|
|
4357
4531
|
this._popup.style.height = height;
|
|
4358
4532
|
}
|
|
@@ -4366,29 +4540,37 @@ class CourierInboxMenu extends HTMLElement {
|
|
|
4366
4540
|
}
|
|
4367
4541
|
}
|
|
4368
4542
|
setFeedType(feedType) {
|
|
4369
|
-
|
|
4543
|
+
var _a;
|
|
4544
|
+
(_a = this._inbox) == null ? void 0 : _a.setFeedType(feedType);
|
|
4370
4545
|
}
|
|
4371
4546
|
// Factory methods
|
|
4372
4547
|
setPopupHeader(factory) {
|
|
4373
|
-
|
|
4548
|
+
var _a;
|
|
4549
|
+
(_a = this._inbox) == null ? void 0 : _a.setHeader(factory);
|
|
4374
4550
|
}
|
|
4375
4551
|
removePopupHeader() {
|
|
4376
|
-
|
|
4552
|
+
var _a;
|
|
4553
|
+
(_a = this._inbox) == null ? void 0 : _a.removeHeader();
|
|
4377
4554
|
}
|
|
4378
4555
|
setPopupLoadingState(factory) {
|
|
4379
|
-
|
|
4556
|
+
var _a;
|
|
4557
|
+
(_a = this._inbox) == null ? void 0 : _a.setLoadingState(factory);
|
|
4380
4558
|
}
|
|
4381
4559
|
setPopupEmptyState(factory) {
|
|
4382
|
-
|
|
4560
|
+
var _a;
|
|
4561
|
+
(_a = this._inbox) == null ? void 0 : _a.setEmptyState(factory);
|
|
4383
4562
|
}
|
|
4384
4563
|
setPopupErrorState(factory) {
|
|
4385
|
-
|
|
4564
|
+
var _a;
|
|
4565
|
+
(_a = this._inbox) == null ? void 0 : _a.setErrorState(factory);
|
|
4386
4566
|
}
|
|
4387
4567
|
setPopupListItem(factory) {
|
|
4388
|
-
|
|
4568
|
+
var _a;
|
|
4569
|
+
(_a = this._inbox) == null ? void 0 : _a.setListItem(factory);
|
|
4389
4570
|
}
|
|
4390
4571
|
setPopupPaginationItem(factory) {
|
|
4391
|
-
|
|
4572
|
+
var _a;
|
|
4573
|
+
(_a = this._inbox) == null ? void 0 : _a.setPaginationItem(factory);
|
|
4392
4574
|
}
|
|
4393
4575
|
setPopupMenuButton(factory) {
|
|
4394
4576
|
this._popupMenuButtonFactory = factory;
|
|
@@ -4396,6 +4578,7 @@ class CourierInboxMenu extends HTMLElement {
|
|
|
4396
4578
|
}
|
|
4397
4579
|
render() {
|
|
4398
4580
|
const unreadCount = CourierInboxDatastore.shared.unreadCount;
|
|
4581
|
+
if (!this._triggerButton) return;
|
|
4399
4582
|
switch (this._popupMenuButtonFactory) {
|
|
4400
4583
|
case void 0:
|
|
4401
4584
|
case null:
|
|
@@ -4408,15 +4591,8 @@ class CourierInboxMenu extends HTMLElement {
|
|
|
4408
4591
|
break;
|
|
4409
4592
|
}
|
|
4410
4593
|
}
|
|
4411
|
-
disconnectedCallback() {
|
|
4412
|
-
var _a;
|
|
4413
|
-
(_a = this._datastoreListener) == null ? void 0 : _a.remove();
|
|
4414
|
-
this._themeManager.cleanup();
|
|
4415
|
-
}
|
|
4416
|
-
}
|
|
4417
|
-
if (!customElements.get("courier-inbox-menu")) {
|
|
4418
|
-
customElements.define("courier-inbox-menu", CourierInboxMenu);
|
|
4419
4594
|
}
|
|
4595
|
+
registerElement(CourierInboxPopupMenu);
|
|
4420
4596
|
function markAsRead(message) {
|
|
4421
4597
|
return CourierInboxDatastore.shared.readMessage({ message });
|
|
4422
4598
|
}
|
|
@@ -4454,9 +4630,9 @@ export {
|
|
|
4454
4630
|
CourierInboxDatastore,
|
|
4455
4631
|
CourierInboxDatastoreEvents,
|
|
4456
4632
|
CourierInboxHeader,
|
|
4457
|
-
|
|
4633
|
+
CourierInboxListItem,
|
|
4634
|
+
CourierInboxPopupMenu,
|
|
4458
4635
|
CourierInboxThemeManager,
|
|
4459
|
-
CourierListItem,
|
|
4460
4636
|
archiveMessage,
|
|
4461
4637
|
clickMessage,
|
|
4462
4638
|
defaultDarkTheme,
|