@trycourier/courier-react 8.0.12-beta → 8.0.15-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-client-component.d.ts +6 -0
- package/dist/components/{courier-inbox-menu.d.ts → courier-inbox-popup-menu.d.ts} +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +666 -419
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -8
package/dist/index.mjs
CHANGED
|
@@ -1,95 +1,262 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState, useEffect, useRef } from "react";
|
|
2
2
|
import { createRoot } from "react-dom/client";
|
|
3
3
|
import { flushSync } from "react-dom";
|
|
4
4
|
var __defProp$1 = Object.defineProperty;
|
|
5
5
|
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
6
|
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
const CLOSE_CODE_NORMAL_CLOSURE = 1e3;
|
|
8
|
+
const IPW_VERSION = "v1";
|
|
7
9
|
const _CourierSocket = class _CourierSocket2 {
|
|
8
|
-
constructor(
|
|
10
|
+
constructor(options) {
|
|
9
11
|
__publicField$1(this, "webSocket", null);
|
|
10
|
-
__publicField$1(this, "
|
|
11
|
-
__publicField$1(this, "
|
|
12
|
-
__publicField$1(this, "onMessageReceived");
|
|
13
|
-
__publicField$1(this, "onClose");
|
|
14
|
-
__publicField$1(this, "onError");
|
|
12
|
+
__publicField$1(this, "retryAttempt", 0);
|
|
13
|
+
__publicField$1(this, "retryTimeoutId", null);
|
|
15
14
|
__publicField$1(this, "url");
|
|
16
15
|
__publicField$1(this, "options");
|
|
17
|
-
this.url =
|
|
16
|
+
this.url = options.apiUrls.inbox.webSocket;
|
|
18
17
|
this.options = options;
|
|
19
18
|
}
|
|
20
19
|
/**
|
|
21
|
-
*
|
|
20
|
+
* Connects to the Courier WebSocket server.
|
|
21
|
+
*
|
|
22
|
+
* If the connection is already established, this is a no-op.
|
|
23
|
+
*
|
|
24
|
+
* @returns A promise that resolves when the connection is established or rejects if the connection could not be established.
|
|
22
25
|
*/
|
|
23
|
-
get isConnected() {
|
|
24
|
-
return this.webSocket !== null;
|
|
25
|
-
}
|
|
26
26
|
async connect() {
|
|
27
|
-
|
|
27
|
+
var _a;
|
|
28
|
+
this.clearRetryTimeout();
|
|
29
|
+
if (this.isConnecting || this.isOpen) {
|
|
30
|
+
(_a = this.options.logger) == null ? void 0 : _a.info("Attempted to open a WebSocket connection, but one already exists.");
|
|
31
|
+
return Promise.reject(new Error("WebSocket connection already exists"));
|
|
32
|
+
}
|
|
28
33
|
return new Promise((resolve, reject) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
34
|
+
this.webSocket = new WebSocket(this.getWebSocketUrl());
|
|
35
|
+
this.webSocket.addEventListener("open", (event) => {
|
|
36
|
+
this.retryAttempt = 0;
|
|
37
|
+
this.onOpen(event);
|
|
38
|
+
resolve();
|
|
39
|
+
});
|
|
40
|
+
this.webSocket.addEventListener("message", async (event) => {
|
|
41
|
+
var _a2;
|
|
42
|
+
try {
|
|
43
|
+
const json = JSON.parse(event.data);
|
|
44
|
+
if ("event" in json && json.event === "reconnect") {
|
|
45
|
+
this.close(CLOSE_CODE_NORMAL_CLOSURE);
|
|
46
|
+
await this.retryConnection(json.retryAfter * 1e3);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this.onMessageReceived(json);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
(_a2 = this.options.logger) == null ? void 0 : _a2.error("Error parsing socket message", error);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
this.webSocket.addEventListener("close", (event) => {
|
|
55
|
+
if (event.code !== CLOSE_CODE_NORMAL_CLOSURE) {
|
|
56
|
+
const courierCloseEvent = _CourierSocket2.parseCloseEvent(event);
|
|
57
|
+
if (courierCloseEvent.retryAfterSeconds) {
|
|
58
|
+
this.retryConnection(courierCloseEvent.retryAfterSeconds * 1e3);
|
|
59
|
+
} else {
|
|
60
|
+
this.retryConnection();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
this.onClose(event);
|
|
64
|
+
});
|
|
65
|
+
this.webSocket.addEventListener("error", (event) => {
|
|
66
|
+
this.retryConnection();
|
|
67
|
+
this.onError(event);
|
|
68
|
+
reject(event);
|
|
69
|
+
});
|
|
57
70
|
});
|
|
58
71
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Closes the WebSocket connection.
|
|
74
|
+
*
|
|
75
|
+
* See {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close} for more details.
|
|
76
|
+
*
|
|
77
|
+
* @param code The WebSocket close code. Defaults to {@link CLOSE_CODE_NORMAL_CLOSURE}.
|
|
78
|
+
* @param reason The WebSocket close reason.
|
|
79
|
+
*/
|
|
80
|
+
close(code = CLOSE_CODE_NORMAL_CLOSURE, reason) {
|
|
81
|
+
if (this.webSocket === null) {
|
|
82
|
+
return;
|
|
64
83
|
}
|
|
84
|
+
this.webSocket.close(code, reason);
|
|
85
|
+
this.webSocket = null;
|
|
65
86
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Sends a message to the Courier WebSocket server.
|
|
89
|
+
*
|
|
90
|
+
* @param message The message to send. The message will be serialized to a JSON string.
|
|
91
|
+
*/
|
|
92
|
+
send(message) {
|
|
93
|
+
var _a;
|
|
94
|
+
if (this.webSocket === null || this.isConnecting) {
|
|
95
|
+
(_a = this.options.logger) == null ? void 0 : _a.info("Attempted to send a message, but the WebSocket is not yet open.");
|
|
96
|
+
return;
|
|
69
97
|
}
|
|
70
98
|
const json = JSON.stringify(message);
|
|
71
|
-
|
|
99
|
+
this.webSocket.send(json);
|
|
72
100
|
}
|
|
73
|
-
|
|
74
|
-
this.
|
|
75
|
-
|
|
76
|
-
|
|
101
|
+
get userId() {
|
|
102
|
+
return this.options.userId;
|
|
103
|
+
}
|
|
104
|
+
get logger() {
|
|
105
|
+
return this.options.logger;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Whether the WebSocket connection is currently being established.
|
|
109
|
+
*/
|
|
110
|
+
get isConnecting() {
|
|
111
|
+
return this.webSocket !== null && this.webSocket.readyState === WebSocket.CONNECTING;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Whether the WebSocket connection is currently open.
|
|
115
|
+
*/
|
|
116
|
+
get isOpen() {
|
|
117
|
+
return this.webSocket !== null && this.webSocket.readyState === WebSocket.OPEN;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Constructs the WebSocket URL for the Courier WebSocket server using context
|
|
121
|
+
* from the {@link CourierClientOptions} passed to the constructor.
|
|
122
|
+
*
|
|
123
|
+
* @returns The WebSocket URL
|
|
124
|
+
*/
|
|
125
|
+
getWebSocketUrl() {
|
|
126
|
+
const accessToken = this.options.accessToken;
|
|
127
|
+
const connectionId = this.options.connectionId;
|
|
128
|
+
const userId = this.userId;
|
|
129
|
+
return `${this.url}?auth=${accessToken}&cid=${connectionId}&iwpv=${IPW_VERSION}&userId=${userId}`;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Parses the Retry-After time from the WebSocket close event reason,
|
|
133
|
+
* and returns a new {@link CourierCloseEvent} with the retry after time in seconds
|
|
134
|
+
* if present.
|
|
135
|
+
*
|
|
136
|
+
* The Courier WebSocket server may send the close event reason in the following format:
|
|
137
|
+
*
|
|
138
|
+
* ```json
|
|
139
|
+
* {
|
|
140
|
+
* "Retry-After": "10" // The retry after time in seconds
|
|
141
|
+
* }
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/reason
|
|
145
|
+
*
|
|
146
|
+
* @param closeEvent The WebSocket close event.
|
|
147
|
+
* @returns The WebSocket close event with the retry after time in seconds.
|
|
148
|
+
*/
|
|
149
|
+
static parseCloseEvent(closeEvent) {
|
|
150
|
+
if (closeEvent.reason === null || closeEvent.reason === "") {
|
|
151
|
+
return closeEvent;
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
const jsonReason = JSON.parse(closeEvent.reason);
|
|
155
|
+
if (!jsonReason[_CourierSocket2.RETRY_AFTER_KEY]) {
|
|
156
|
+
return closeEvent;
|
|
157
|
+
}
|
|
158
|
+
const retryAfterSeconds = parseInt(jsonReason[_CourierSocket2.RETRY_AFTER_KEY]);
|
|
159
|
+
if (Number.isNaN(retryAfterSeconds) || retryAfterSeconds < 0) {
|
|
160
|
+
return closeEvent;
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
...closeEvent,
|
|
164
|
+
retryAfterSeconds
|
|
165
|
+
};
|
|
166
|
+
} catch (error) {
|
|
167
|
+
return closeEvent;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Calculates the retry backoff time in milliseconds based on the current retry attempt.
|
|
172
|
+
*/
|
|
173
|
+
getBackoffTimeInMillis() {
|
|
174
|
+
const backoffIntervalInMillis = _CourierSocket2.BACKOFF_INTERVALS_IN_MILLIS[this.retryAttempt];
|
|
175
|
+
const lowerBound = backoffIntervalInMillis - backoffIntervalInMillis * _CourierSocket2.BACKOFF_JITTER_FACTOR;
|
|
176
|
+
const upperBound = backoffIntervalInMillis + backoffIntervalInMillis * _CourierSocket2.BACKOFF_JITTER_FACTOR;
|
|
177
|
+
return Math.floor(Math.random() * (upperBound - lowerBound) + lowerBound);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Retries the connection to the Courier WebSocket server after
|
|
181
|
+
* either {@param suggestedBackoffTimeInMillis} or a random backoff time
|
|
182
|
+
* calculated using {@link getBackoffTimeInMillis}.
|
|
183
|
+
*
|
|
184
|
+
* @param suggestedBackoffTimeInMillis The suggested backoff time in milliseconds.
|
|
185
|
+
* @returns A promise that resolves when the connection is established or rejects if the connection could not be established.
|
|
186
|
+
*/
|
|
187
|
+
async retryConnection(suggestedBackoffTimeInMillis) {
|
|
188
|
+
var _a, _b, _c;
|
|
189
|
+
if (this.retryTimeoutId !== null) {
|
|
190
|
+
(_a = this.logger) == null ? void 0 : _a.debug("Skipping retry attempt because a previous retry is already scheduled.");
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (this.retryAttempt >= _CourierSocket2.MAX_RETRY_ATTEMPTS) {
|
|
194
|
+
(_b = this.logger) == null ? void 0 : _b.error(`Max retry attempts (${_CourierSocket2.MAX_RETRY_ATTEMPTS}) reached.`);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const backoffTimeInMillis = suggestedBackoffTimeInMillis != null ? suggestedBackoffTimeInMillis : this.getBackoffTimeInMillis();
|
|
198
|
+
this.retryTimeoutId = window.setTimeout(async () => {
|
|
77
199
|
try {
|
|
78
|
-
await this.
|
|
200
|
+
await this.connect();
|
|
79
201
|
} catch (error) {
|
|
80
|
-
(_a = this.options.logger) == null ? void 0 : _a.error("Error occurred on Keep Alive:", error);
|
|
81
202
|
}
|
|
82
|
-
},
|
|
203
|
+
}, backoffTimeInMillis);
|
|
204
|
+
(_c = this.logger) == null ? void 0 : _c.debug(`Retrying connection in ${Math.floor(backoffTimeInMillis / 1e3)}s. Retry attempt ${this.retryAttempt + 1} of ${_CourierSocket2.MAX_RETRY_ATTEMPTS}.`);
|
|
205
|
+
this.retryAttempt++;
|
|
83
206
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Clears the retry timeout if it exists.
|
|
209
|
+
*/
|
|
210
|
+
clearRetryTimeout() {
|
|
211
|
+
if (this.retryTimeoutId !== null) {
|
|
212
|
+
window.clearTimeout(this.retryTimeoutId);
|
|
213
|
+
this.retryTimeoutId = null;
|
|
88
214
|
}
|
|
89
215
|
}
|
|
90
216
|
};
|
|
91
|
-
__publicField$1(_CourierSocket, "
|
|
217
|
+
__publicField$1(_CourierSocket, "BACKOFF_JITTER_FACTOR", 0.5);
|
|
218
|
+
__publicField$1(_CourierSocket, "MAX_RETRY_ATTEMPTS", 5);
|
|
219
|
+
__publicField$1(_CourierSocket, "BACKOFF_INTERVALS_IN_MILLIS", [
|
|
220
|
+
3e4,
|
|
221
|
+
// 30 seconds
|
|
222
|
+
6e4,
|
|
223
|
+
// 1 minute
|
|
224
|
+
12e4,
|
|
225
|
+
// 2 minutes
|
|
226
|
+
24e4,
|
|
227
|
+
// 4 minutes
|
|
228
|
+
48e4
|
|
229
|
+
// 8 minutes
|
|
230
|
+
]);
|
|
231
|
+
__publicField$1(_CourierSocket, "RETRY_AFTER_KEY", "Retry-After");
|
|
92
232
|
let CourierSocket = _CourierSocket;
|
|
233
|
+
var ClientAction = /* @__PURE__ */ ((ClientAction2) => {
|
|
234
|
+
ClientAction2["Subscribe"] = "subscribe";
|
|
235
|
+
ClientAction2["Unsubscribe"] = "unsubscribe";
|
|
236
|
+
ClientAction2["Pong"] = "pong";
|
|
237
|
+
ClientAction2["Ping"] = "ping";
|
|
238
|
+
return ClientAction2;
|
|
239
|
+
})(ClientAction || {});
|
|
240
|
+
var ServerAction = /* @__PURE__ */ ((ServerAction2) => {
|
|
241
|
+
ServerAction2["Ack"] = "ack";
|
|
242
|
+
ServerAction2["Ping"] = "ping";
|
|
243
|
+
ServerAction2["Pong"] = "pong";
|
|
244
|
+
return ServerAction2;
|
|
245
|
+
})(ServerAction || {});
|
|
246
|
+
var MessageEvent = /* @__PURE__ */ ((MessageEvent2) => {
|
|
247
|
+
MessageEvent2["NewMessage"] = "message";
|
|
248
|
+
MessageEvent2["Archive"] = "archive";
|
|
249
|
+
MessageEvent2["ArchiveAll"] = "archive-all";
|
|
250
|
+
MessageEvent2["ArchiveRead"] = "archive-read";
|
|
251
|
+
MessageEvent2["Clicked"] = "clicked";
|
|
252
|
+
MessageEvent2["MarkAllRead"] = "mark-all-read";
|
|
253
|
+
MessageEvent2["Opened"] = "opened";
|
|
254
|
+
MessageEvent2["Read"] = "read";
|
|
255
|
+
MessageEvent2["Unarchive"] = "unarchive";
|
|
256
|
+
MessageEvent2["Unopened"] = "unopened";
|
|
257
|
+
MessageEvent2["Unread"] = "unread";
|
|
258
|
+
return MessageEvent2;
|
|
259
|
+
})(MessageEvent || {});
|
|
93
260
|
const getCourierApiUrls = (urls) => ({
|
|
94
261
|
courier: {
|
|
95
262
|
rest: (urls == null ? void 0 : urls.courier.rest) || "https://api.courier.com",
|
|
@@ -131,12 +298,27 @@ class Logger {
|
|
|
131
298
|
}
|
|
132
299
|
}
|
|
133
300
|
}
|
|
134
|
-
class
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
301
|
+
const _UUID = class _UUID2 {
|
|
302
|
+
/**
|
|
303
|
+
* nanoid
|
|
304
|
+
* Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
|
|
305
|
+
*
|
|
306
|
+
* https://github.com/ai/nanoid/blob/main/LICENSE
|
|
307
|
+
*
|
|
308
|
+
* @param size - The size of the UUID to generate.
|
|
309
|
+
* @returns A string representing the UUID.
|
|
310
|
+
*/
|
|
311
|
+
static nanoid(size = 21) {
|
|
312
|
+
let id = "";
|
|
313
|
+
let bytes = crypto.getRandomValues(new Uint8Array(size |= 0));
|
|
314
|
+
while (size--) {
|
|
315
|
+
id += _UUID2.ALPHABET[bytes[size] & 63];
|
|
316
|
+
}
|
|
317
|
+
return id;
|
|
138
318
|
}
|
|
139
|
-
}
|
|
319
|
+
};
|
|
320
|
+
__publicField$1(_UUID, "ALPHABET", "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict");
|
|
321
|
+
let UUID = _UUID;
|
|
140
322
|
class CourierRequestError extends Error {
|
|
141
323
|
constructor(code, message, type) {
|
|
142
324
|
super(message);
|
|
@@ -164,8 +346,9 @@ Response JSON: ${JSON.stringify(data.response, null, 2)}
|
|
|
164
346
|
`);
|
|
165
347
|
}
|
|
166
348
|
async function http(props) {
|
|
167
|
-
|
|
168
|
-
const
|
|
349
|
+
var _a;
|
|
350
|
+
const validCodes = (_a = props.validCodes) != null ? _a : [200];
|
|
351
|
+
const uid = props.options.showLogs ? UUID.nanoid() : void 0;
|
|
169
352
|
const request = new Request(props.url, {
|
|
170
353
|
method: props.method,
|
|
171
354
|
headers: {
|
|
@@ -215,7 +398,7 @@ async function http(props) {
|
|
|
215
398
|
return data;
|
|
216
399
|
}
|
|
217
400
|
async function graphql(props) {
|
|
218
|
-
const uid = props.options.showLogs ? UUID.
|
|
401
|
+
const uid = props.options.showLogs ? UUID.nanoid() : void 0;
|
|
219
402
|
if (uid) {
|
|
220
403
|
logRequest(props.options.logger, uid, "GraphQL", {
|
|
221
404
|
url: props.url,
|
|
@@ -304,70 +487,120 @@ class BrandClient extends Client {
|
|
|
304
487
|
return json.data.brand;
|
|
305
488
|
}
|
|
306
489
|
}
|
|
307
|
-
class
|
|
490
|
+
const _CourierInboxSocket = class _CourierInboxSocket2 extends CourierSocket {
|
|
308
491
|
constructor(options) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
__publicField$1(this, "
|
|
312
|
-
__publicField$1(this, "receivedMessageEvent");
|
|
313
|
-
this.onMessageReceived = (data) => this.convertToType(data);
|
|
492
|
+
super(options);
|
|
493
|
+
__publicField$1(this, "pingIntervalId", null);
|
|
494
|
+
__publicField$1(this, "messageEventListeners", []);
|
|
314
495
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
} catch (error) {
|
|
330
|
-
(_c = this.options.logger) == null ? void 0 : _c.error("Error parsing socket message", error);
|
|
331
|
-
if (error instanceof Error) {
|
|
332
|
-
(_d = this.onError) == null ? void 0 : _d.call(this, error);
|
|
496
|
+
onOpen(_) {
|
|
497
|
+
this.restartPingInterval();
|
|
498
|
+
return Promise.resolve();
|
|
499
|
+
}
|
|
500
|
+
onMessageReceived(data) {
|
|
501
|
+
if ("action" in data && data.action === ServerAction.Ping) {
|
|
502
|
+
const envelope = data;
|
|
503
|
+
this.sendPong(envelope);
|
|
504
|
+
}
|
|
505
|
+
if ("event" in data) {
|
|
506
|
+
for (const listener of this.messageEventListeners) {
|
|
507
|
+
listener(data);
|
|
333
508
|
}
|
|
334
509
|
}
|
|
510
|
+
this.restartPingInterval();
|
|
511
|
+
return Promise.resolve();
|
|
335
512
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
513
|
+
onClose(_) {
|
|
514
|
+
return Promise.resolve();
|
|
515
|
+
}
|
|
516
|
+
onError(_) {
|
|
517
|
+
return Promise.resolve();
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Sends a subscribe message to the server.
|
|
521
|
+
*
|
|
522
|
+
* Subscribes to all events for the user.
|
|
523
|
+
*/
|
|
524
|
+
sendSubscribe() {
|
|
525
|
+
const envelope = {
|
|
526
|
+
tid: UUID.nanoid(),
|
|
527
|
+
action: ClientAction.Subscribe,
|
|
340
528
|
data: {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
channel: this.options.userId,
|
|
344
|
-
event: "*",
|
|
345
|
-
version: (props == null ? void 0 : props.version) ?? 5
|
|
529
|
+
channel: this.userId,
|
|
530
|
+
event: "*"
|
|
346
531
|
}
|
|
347
532
|
};
|
|
348
|
-
|
|
349
|
-
subscription.data.clientSourceId = this.options.connectionId;
|
|
350
|
-
}
|
|
351
|
-
if (this.options.tenantId) {
|
|
352
|
-
subscription.data.accountId = this.options.tenantId;
|
|
353
|
-
}
|
|
354
|
-
(_a = this.options.logger) == null ? void 0 : _a.debug("Sending subscribe request", subscription);
|
|
355
|
-
await this.send(subscription);
|
|
533
|
+
this.send(envelope);
|
|
356
534
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
535
|
+
/**
|
|
536
|
+
* Sends an unsubscribe message to the server.
|
|
537
|
+
*
|
|
538
|
+
* Unsubscribes from all events for the user.
|
|
539
|
+
*/
|
|
540
|
+
sendUnsubscribe() {
|
|
541
|
+
const envelope = {
|
|
542
|
+
tid: UUID.nanoid(),
|
|
543
|
+
action: ClientAction.Unsubscribe,
|
|
544
|
+
data: {
|
|
545
|
+
channel: this.userId
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
this.send(envelope);
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Adds a message event listener, called when a message event is received
|
|
552
|
+
* from the Courier WebSocket server.
|
|
553
|
+
*
|
|
554
|
+
* @param listener The listener function
|
|
555
|
+
*/
|
|
556
|
+
addMessageEventListener(listener) {
|
|
557
|
+
this.messageEventListeners.push(listener);
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Send a ping message to the server.
|
|
561
|
+
*
|
|
562
|
+
* ping/pong is implemented at the application layer since the browser's
|
|
563
|
+
* WebSocket implementation does not support control-level ping/pong.
|
|
564
|
+
*/
|
|
565
|
+
sendPing() {
|
|
566
|
+
const envelope = {
|
|
567
|
+
tid: UUID.nanoid(),
|
|
568
|
+
action: ClientAction.Ping
|
|
569
|
+
};
|
|
570
|
+
this.send(envelope);
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Send a pong response to the server.
|
|
574
|
+
*
|
|
575
|
+
* ping/pong is implemented at the application layer since the browser's
|
|
576
|
+
* WebSocket implementation does not support control-level ping/pong.
|
|
577
|
+
*/
|
|
578
|
+
sendPong(incomingMessage) {
|
|
579
|
+
const response = {
|
|
580
|
+
tid: incomingMessage.tid,
|
|
581
|
+
action: ClientAction.Pong
|
|
582
|
+
};
|
|
583
|
+
this.send(response);
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Restart the ping interval, clearing the previous interval if it exists.
|
|
587
|
+
*/
|
|
588
|
+
restartPingInterval() {
|
|
589
|
+
if (this.pingIntervalId) {
|
|
590
|
+
window.clearInterval(this.pingIntervalId);
|
|
362
591
|
}
|
|
363
|
-
|
|
592
|
+
this.pingIntervalId = window.setInterval(() => {
|
|
593
|
+
this.sendPing();
|
|
594
|
+
}, _CourierInboxSocket2.PING_INTERVAL_MILLIS);
|
|
364
595
|
}
|
|
365
|
-
}
|
|
596
|
+
};
|
|
597
|
+
__publicField$1(_CourierInboxSocket, "PING_INTERVAL_MILLIS", 6e4);
|
|
598
|
+
let CourierInboxSocket = _CourierInboxSocket;
|
|
366
599
|
class InboxClient extends Client {
|
|
367
600
|
constructor(options) {
|
|
368
601
|
super(options);
|
|
369
602
|
__publicField$1(this, "socket");
|
|
370
|
-
this.socket = new
|
|
603
|
+
this.socket = new CourierInboxSocket(options);
|
|
371
604
|
}
|
|
372
605
|
/**
|
|
373
606
|
* Get paginated messages
|
|
@@ -376,10 +609,11 @@ class InboxClient extends Client {
|
|
|
376
609
|
* @returns Promise resolving to paginated messages response
|
|
377
610
|
*/
|
|
378
611
|
async getMessages(props) {
|
|
612
|
+
var _a;
|
|
379
613
|
const query = `
|
|
380
614
|
query GetInboxMessages(
|
|
381
615
|
$params: FilterParamsInput = { ${this.options.tenantId ? `accountId: "${this.options.tenantId}"` : ""} }
|
|
382
|
-
$limit: Int = ${(props == null ? void 0 : props.paginationLimit)
|
|
616
|
+
$limit: Int = ${(_a = props == null ? void 0 : props.paginationLimit) != null ? _a : 24}
|
|
383
617
|
$after: String ${(props == null ? void 0 : props.startCursor) ? `= "${props.startCursor}"` : ""}
|
|
384
618
|
) {
|
|
385
619
|
count(params: $params)
|
|
@@ -428,10 +662,11 @@ class InboxClient extends Client {
|
|
|
428
662
|
* @returns Promise resolving to paginated archived messages response
|
|
429
663
|
*/
|
|
430
664
|
async getArchivedMessages(props) {
|
|
665
|
+
var _a;
|
|
431
666
|
const query = `
|
|
432
667
|
query GetInboxMessages(
|
|
433
668
|
$params: FilterParamsInput = { ${this.options.tenantId ? `accountId: "${this.options.tenantId}"` : ""}, archived: true }
|
|
434
|
-
$limit: Int = ${(props == null ? void 0 : props.paginationLimit)
|
|
669
|
+
$limit: Int = ${(_a = props == null ? void 0 : props.paginationLimit) != null ? _a : 24}
|
|
435
670
|
$after: String ${(props == null ? void 0 : props.startCursor) ? `= "${props.startCursor}"` : ""}
|
|
436
671
|
) {
|
|
437
672
|
count(params: $params)
|
|
@@ -478,6 +713,7 @@ class InboxClient extends Client {
|
|
|
478
713
|
* @returns Promise resolving to number of unread messages
|
|
479
714
|
*/
|
|
480
715
|
async getUnreadMessageCount() {
|
|
716
|
+
var _a2;
|
|
481
717
|
var _a;
|
|
482
718
|
const query = `
|
|
483
719
|
query GetMessages {
|
|
@@ -493,7 +729,7 @@ class InboxClient extends Client {
|
|
|
493
729
|
},
|
|
494
730
|
url: this.options.apiUrls.inbox.graphql
|
|
495
731
|
});
|
|
496
|
-
return ((_a = response.data) == null ? void 0 : _a.count)
|
|
732
|
+
return (_a2 = (_a = response.data) == null ? void 0 : _a.count) != null ? _a2 : 0;
|
|
497
733
|
}
|
|
498
734
|
/**
|
|
499
735
|
* Track a click event
|
|
@@ -976,13 +1212,14 @@ class TrackingClient extends Client {
|
|
|
976
1212
|
}
|
|
977
1213
|
class CourierClient extends Client {
|
|
978
1214
|
constructor(props) {
|
|
1215
|
+
var _a2;
|
|
979
1216
|
var _a, _b;
|
|
980
1217
|
const showLogs = props.showLogs !== void 0 ? props.showLogs : process.env.NODE_ENV === "development";
|
|
981
1218
|
const baseOptions = {
|
|
982
1219
|
...props,
|
|
983
1220
|
showLogs,
|
|
984
1221
|
apiUrls: props.apiUrls || getCourierApiUrls(),
|
|
985
|
-
accessToken: props.jwt
|
|
1222
|
+
accessToken: (_a2 = props.jwt) != null ? _a2 : props.publicApiKey
|
|
986
1223
|
};
|
|
987
1224
|
super({
|
|
988
1225
|
...baseOptions,
|
|
@@ -1027,7 +1264,7 @@ class AuthenticationListener {
|
|
|
1027
1264
|
}
|
|
1028
1265
|
const _Courier = class _Courier2 {
|
|
1029
1266
|
constructor() {
|
|
1030
|
-
__publicField$1(this, "id", UUID.
|
|
1267
|
+
__publicField$1(this, "id", UUID.nanoid());
|
|
1031
1268
|
__publicField$1(this, "instanceClient");
|
|
1032
1269
|
__publicField$1(this, "_paginationLimit", 24);
|
|
1033
1270
|
__publicField$1(this, "authenticationListeners", []);
|
|
@@ -1060,7 +1297,8 @@ const _Courier = class _Courier2 {
|
|
|
1060
1297
|
* @param options - The options for the Courier client
|
|
1061
1298
|
*/
|
|
1062
1299
|
signIn(props) {
|
|
1063
|
-
|
|
1300
|
+
var _a;
|
|
1301
|
+
const connectionId = (_a = props.connectionId) != null ? _a : UUID.nanoid();
|
|
1064
1302
|
this.instanceClient = new CourierClient({ ...props, connectionId });
|
|
1065
1303
|
this.notifyAuthenticationListeners({ userId: props.userId });
|
|
1066
1304
|
}
|
|
@@ -1176,7 +1414,15 @@ const addSystemThemeModeListener = (callback) => {
|
|
|
1176
1414
|
mediaQuery.removeEventListener("change", handler);
|
|
1177
1415
|
};
|
|
1178
1416
|
};
|
|
1179
|
-
|
|
1417
|
+
const BaseElement = typeof window === "undefined" ? class {
|
|
1418
|
+
constructor() {
|
|
1419
|
+
}
|
|
1420
|
+
} : class extends HTMLElement {
|
|
1421
|
+
constructor() {
|
|
1422
|
+
super();
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1425
|
+
class CourierSystemThemeElement extends BaseElement {
|
|
1180
1426
|
constructor() {
|
|
1181
1427
|
super();
|
|
1182
1428
|
__publicField2(this, "_currentSystemTheme");
|
|
@@ -1249,6 +1495,7 @@ class CourierButton extends CourierSystemThemeElement {
|
|
|
1249
1495
|
});
|
|
1250
1496
|
}
|
|
1251
1497
|
getStyles(props) {
|
|
1498
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1252
1499
|
const defaultTextColor = () => {
|
|
1253
1500
|
const secondary = CourierButtonVariants.secondary(this.currentSystemTheme);
|
|
1254
1501
|
return secondary.textColor;
|
|
@@ -1284,18 +1531,18 @@ class CourierButton extends CourierSystemThemeElement {
|
|
|
1284
1531
|
|
|
1285
1532
|
button {
|
|
1286
1533
|
border: none;
|
|
1287
|
-
border-radius: ${props.borderRadius
|
|
1288
|
-
font-weight: ${props.fontWeight
|
|
1289
|
-
font-family: ${props.fontFamily
|
|
1290
|
-
font-size: ${props.fontSize
|
|
1534
|
+
border-radius: ${(_a = props.borderRadius) != null ? _a : defaultBorderRadius()};
|
|
1535
|
+
font-weight: ${(_b = props.fontWeight) != null ? _b : defaultFontWeight()};
|
|
1536
|
+
font-family: ${(_c = props.fontFamily) != null ? _c : "inherit"};
|
|
1537
|
+
font-size: ${(_d = props.fontSize) != null ? _d : defaultFontSize()};
|
|
1291
1538
|
padding: 6px 10px;
|
|
1292
1539
|
cursor: pointer;
|
|
1293
1540
|
width: 100%;
|
|
1294
1541
|
height: 100%;
|
|
1295
|
-
background-color: ${props.backgroundColor
|
|
1296
|
-
color: ${props.textColor
|
|
1297
|
-
border: ${props.border
|
|
1298
|
-
box-shadow: ${props.shadow
|
|
1542
|
+
background-color: ${(_e = props.backgroundColor) != null ? _e : defaultBackgroundColor()};
|
|
1543
|
+
color: ${(_f = props.textColor) != null ? _f : defaultTextColor()};
|
|
1544
|
+
border: ${(_g = props.border) != null ? _g : defaultBorder()};
|
|
1545
|
+
box-shadow: ${(_h = props.shadow) != null ? _h : defaultShadow()};
|
|
1299
1546
|
touch-action: manipulation;
|
|
1300
1547
|
}
|
|
1301
1548
|
|
|
@@ -1320,9 +1567,6 @@ class CourierButton extends CourierSystemThemeElement {
|
|
|
1320
1567
|
this._style.textContent = this.getStyles(props);
|
|
1321
1568
|
}
|
|
1322
1569
|
}
|
|
1323
|
-
if (!customElements.get("courier-button")) {
|
|
1324
|
-
customElements.define("courier-button", CourierButton);
|
|
1325
|
-
}
|
|
1326
1570
|
const CourierIconSVGs = {
|
|
1327
1571
|
inbox: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1328
1572
|
<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"/>
|
|
@@ -1352,14 +1596,14 @@ const CourierIconSVGs = {
|
|
|
1352
1596
|
<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"/>
|
|
1353
1597
|
</svg>`
|
|
1354
1598
|
};
|
|
1355
|
-
class CourierIcon extends
|
|
1599
|
+
class CourierIcon extends BaseElement {
|
|
1356
1600
|
constructor(color, svg) {
|
|
1357
1601
|
super();
|
|
1358
1602
|
__publicField2(this, "_color");
|
|
1359
1603
|
__publicField2(this, "_svg");
|
|
1360
1604
|
__publicField2(this, "_iconContainer");
|
|
1361
1605
|
__publicField2(this, "_style");
|
|
1362
|
-
this._color = color
|
|
1606
|
+
this._color = color != null ? color : CourierColors.black[500];
|
|
1363
1607
|
this._svg = svg;
|
|
1364
1608
|
const shadow = this.attachShadow({ mode: "open" });
|
|
1365
1609
|
this._iconContainer = document.createElement("div");
|
|
@@ -1403,10 +1647,7 @@ class CourierIcon extends HTMLElement {
|
|
|
1403
1647
|
this.refresh();
|
|
1404
1648
|
}
|
|
1405
1649
|
}
|
|
1406
|
-
|
|
1407
|
-
customElements.define("courier-icon", CourierIcon);
|
|
1408
|
-
}
|
|
1409
|
-
class CourierLink extends HTMLElement {
|
|
1650
|
+
class CourierLink extends BaseElement {
|
|
1410
1651
|
constructor() {
|
|
1411
1652
|
super();
|
|
1412
1653
|
__publicField2(this, "link");
|
|
@@ -1568,9 +1809,6 @@ __publicField2(CourierLink, "observedAttributes", [
|
|
|
1568
1809
|
"font-family",
|
|
1569
1810
|
"font-size"
|
|
1570
1811
|
]);
|
|
1571
|
-
if (!customElements.get("courier-link")) {
|
|
1572
|
-
customElements.define("courier-link", CourierLink);
|
|
1573
|
-
}
|
|
1574
1812
|
class CourierElement extends CourierSystemThemeElement {
|
|
1575
1813
|
constructor() {
|
|
1576
1814
|
super();
|
|
@@ -1583,7 +1821,7 @@ class CourierElement extends CourierSystemThemeElement {
|
|
|
1583
1821
|
this.shadow.replaceChildren();
|
|
1584
1822
|
return;
|
|
1585
1823
|
}
|
|
1586
|
-
const element = newElement
|
|
1824
|
+
const element = newElement != null ? newElement : this.defaultElement();
|
|
1587
1825
|
this.shadow.replaceChildren(element);
|
|
1588
1826
|
}
|
|
1589
1827
|
// Default element to be used if no factory is provided
|
|
@@ -1609,13 +1847,14 @@ class CourierInfoState extends CourierElement {
|
|
|
1609
1847
|
this._props = props;
|
|
1610
1848
|
}
|
|
1611
1849
|
defaultElement() {
|
|
1850
|
+
var _a2;
|
|
1612
1851
|
var _a, _b;
|
|
1613
1852
|
const container = document.createElement("div");
|
|
1614
1853
|
this._title = document.createElement("h2");
|
|
1615
1854
|
if ((_a = this._props.title) == null ? void 0 : _a.text) {
|
|
1616
1855
|
this._title.textContent = this._props.title.text;
|
|
1617
1856
|
}
|
|
1618
|
-
this._button = new CourierButton(this._props.button
|
|
1857
|
+
this._button = new CourierButton((_a2 = this._props.button) != null ? _a2 : CourierButtonVariants.secondary(this.currentSystemTheme));
|
|
1619
1858
|
this._style = document.createElement("style");
|
|
1620
1859
|
this._style.textContent = this.getStyles(this._props);
|
|
1621
1860
|
container.className = "container";
|
|
@@ -1634,6 +1873,7 @@ class CourierInfoState extends CourierElement {
|
|
|
1634
1873
|
this.updateStyles(this._props);
|
|
1635
1874
|
}
|
|
1636
1875
|
getStyles(props) {
|
|
1876
|
+
var _a2, _b2, _c2, _d2;
|
|
1637
1877
|
var _a, _b, _c, _d;
|
|
1638
1878
|
return `
|
|
1639
1879
|
:host {
|
|
@@ -1656,10 +1896,10 @@ class CourierInfoState extends CourierElement {
|
|
|
1656
1896
|
|
|
1657
1897
|
.container h2 {
|
|
1658
1898
|
margin: 0;
|
|
1659
|
-
color: ${((_a = props.title) == null ? void 0 : _a.textColor)
|
|
1660
|
-
font-size: ${((_b = props.title) == null ? void 0 : _b.fontSize)
|
|
1661
|
-
font-weight: ${((_c = props.title) == null ? void 0 : _c.fontWeight)
|
|
1662
|
-
font-family: ${((_d = props.title) == null ? void 0 : _d.fontFamily)
|
|
1899
|
+
color: ${(_a2 = (_a = props.title) == null ? void 0 : _a.textColor) != null ? _a2 : "red"};
|
|
1900
|
+
font-size: ${(_b2 = (_b = props.title) == null ? void 0 : _b.fontSize) != null ? _b2 : "16px"};
|
|
1901
|
+
font-weight: ${(_c2 = (_c = props.title) == null ? void 0 : _c.fontWeight) != null ? _c2 : "500"};
|
|
1902
|
+
font-family: ${(_d2 = (_d = props.title) == null ? void 0 : _d.fontFamily) != null ? _d2 : "inherit"};
|
|
1663
1903
|
}
|
|
1664
1904
|
`;
|
|
1665
1905
|
}
|
|
@@ -1676,10 +1916,7 @@ class CourierInfoState extends CourierElement {
|
|
|
1676
1916
|
this._buttonClickCallback = callback;
|
|
1677
1917
|
}
|
|
1678
1918
|
}
|
|
1679
|
-
|
|
1680
|
-
customElements.define("courier-info-state", CourierInfoState);
|
|
1681
|
-
}
|
|
1682
|
-
class CourierIconButton extends HTMLElement {
|
|
1919
|
+
class CourierIconButton extends BaseElement {
|
|
1683
1920
|
constructor(svg, color, backgroundColor, hoverBackgroundColor, activeBackgroundColor, borderRadius, height, width) {
|
|
1684
1921
|
super();
|
|
1685
1922
|
__publicField2(this, "_backgroundColor");
|
|
@@ -1711,32 +1948,33 @@ class CourierIconButton extends HTMLElement {
|
|
|
1711
1948
|
this._style.textContent = this.getStyles();
|
|
1712
1949
|
}
|
|
1713
1950
|
getStyles() {
|
|
1951
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1714
1952
|
return `
|
|
1715
1953
|
:host {
|
|
1716
1954
|
display: inline-block;
|
|
1717
|
-
border-radius: ${this._borderRadius
|
|
1955
|
+
border-radius: ${(_a = this._borderRadius) != null ? _a : "50%"};
|
|
1718
1956
|
}
|
|
1719
1957
|
|
|
1720
1958
|
button {
|
|
1721
1959
|
border: none;
|
|
1722
|
-
border-radius: ${this._borderRadius
|
|
1960
|
+
border-radius: ${(_b = this._borderRadius) != null ? _b : "50%"};
|
|
1723
1961
|
cursor: pointer;
|
|
1724
|
-
width: ${this._width
|
|
1725
|
-
height: ${this._height
|
|
1962
|
+
width: ${(_c = this._width) != null ? _c : "36px"};
|
|
1963
|
+
height: ${(_d = this._height) != null ? _d : "36px"};
|
|
1726
1964
|
display: flex;
|
|
1727
1965
|
align-items: center;
|
|
1728
1966
|
justify-content: center;
|
|
1729
|
-
background: ${this._backgroundColor
|
|
1967
|
+
background: ${(_e = this._backgroundColor) != null ? _e : "transparent"};
|
|
1730
1968
|
transition: background-color 0.2s ease;
|
|
1731
1969
|
touch-action: manipulation;
|
|
1732
1970
|
}
|
|
1733
1971
|
|
|
1734
1972
|
button:hover {
|
|
1735
|
-
background-color: ${this._hoverBackgroundColor
|
|
1973
|
+
background-color: ${(_f = this._hoverBackgroundColor) != null ? _f : "red"};
|
|
1736
1974
|
}
|
|
1737
1975
|
|
|
1738
1976
|
button:active {
|
|
1739
|
-
background-color: ${this._activeBackgroundColor
|
|
1977
|
+
background-color: ${(_g = this._activeBackgroundColor) != null ? _g : "red"};
|
|
1740
1978
|
}
|
|
1741
1979
|
|
|
1742
1980
|
button:disabled {
|
|
@@ -1772,21 +2010,20 @@ class CourierIconButton extends HTMLElement {
|
|
|
1772
2010
|
this.refresh();
|
|
1773
2011
|
}
|
|
1774
2012
|
}
|
|
1775
|
-
|
|
1776
|
-
|
|
2013
|
+
function registerElement(name, element) {
|
|
2014
|
+
if (typeof window !== "undefined" && !customElements.get(name)) {
|
|
2015
|
+
customElements.define(name, element);
|
|
2016
|
+
}
|
|
1777
2017
|
}
|
|
1778
2018
|
const components = [
|
|
1779
2019
|
{ name: "courier-button", class: CourierButton },
|
|
1780
2020
|
{ name: "courier-icon", class: CourierIcon },
|
|
1781
2021
|
{ name: "courier-link", class: CourierLink },
|
|
1782
2022
|
{ name: "courier-info-state", class: CourierInfoState },
|
|
1783
|
-
{ name: "courier-icon-button", class: CourierIconButton }
|
|
2023
|
+
{ name: "courier-icon-button", class: CourierIconButton },
|
|
2024
|
+
{ name: "courier-system-theme", class: CourierSystemThemeElement }
|
|
1784
2025
|
];
|
|
1785
|
-
components.forEach(({ name, class: componentClass }) =>
|
|
1786
|
-
if (!customElements.get(name)) {
|
|
1787
|
-
customElements.define(name, componentClass);
|
|
1788
|
-
}
|
|
1789
|
-
});
|
|
2026
|
+
components.forEach(({ name, class: componentClass }) => registerElement(name, componentClass));
|
|
1790
2027
|
function copyMessage(message) {
|
|
1791
2028
|
const copy = {
|
|
1792
2029
|
...message
|
|
@@ -1832,7 +2069,7 @@ function getMessageTime(message) {
|
|
|
1832
2069
|
if (diffInSeconds < 31536e3) return `${Math.floor(diffInSeconds / 604800)}w`;
|
|
1833
2070
|
return `${Math.floor(diffInSeconds / 31536e3)}y`;
|
|
1834
2071
|
}
|
|
1835
|
-
class
|
|
2072
|
+
class CourierInboxListItemMenu extends BaseElement {
|
|
1836
2073
|
constructor(theme2) {
|
|
1837
2074
|
super();
|
|
1838
2075
|
__publicField(this, "_theme");
|
|
@@ -1848,16 +2085,17 @@ class CourierListItemActionMenu extends HTMLElement {
|
|
|
1848
2085
|
shadow.appendChild(menu);
|
|
1849
2086
|
}
|
|
1850
2087
|
getStyles() {
|
|
2088
|
+
var _a2, _b2, _c2, _d;
|
|
1851
2089
|
var _a, _b, _c;
|
|
1852
2090
|
const menu = (_c = (_b = (_a = this._theme.inbox) == null ? void 0 : _a.list) == null ? void 0 : _b.item) == null ? void 0 : _c.menu;
|
|
1853
2091
|
return `
|
|
1854
2092
|
:host {
|
|
1855
2093
|
display: block;
|
|
1856
2094
|
position: absolute;
|
|
1857
|
-
background: ${(menu == null ? void 0 : menu.backgroundColor)
|
|
1858
|
-
border: ${(menu == null ? void 0 : menu.border)
|
|
1859
|
-
border-radius: ${(menu == null ? void 0 : menu.borderRadius)
|
|
1860
|
-
box-shadow: ${(menu == null ? void 0 : menu.shadow)
|
|
2095
|
+
background: ${(_a2 = menu == null ? void 0 : menu.backgroundColor) != null ? _a2 : "red"};
|
|
2096
|
+
border: ${(_b2 = menu == null ? void 0 : menu.border) != null ? _b2 : "1px solid red"};
|
|
2097
|
+
border-radius: ${(_c2 = menu == null ? void 0 : menu.borderRadius) != null ? _c2 : "0px"};
|
|
2098
|
+
box-shadow: ${(_d = menu == null ? void 0 : menu.shadow) != null ? _d : "0 2px 8px red"};
|
|
1861
2099
|
user-select: none;
|
|
1862
2100
|
opacity: 0;
|
|
1863
2101
|
pointer-events: none;
|
|
@@ -1925,9 +2163,7 @@ class CourierListItemActionMenu extends HTMLElement {
|
|
|
1925
2163
|
this.classList.remove("visible");
|
|
1926
2164
|
}
|
|
1927
2165
|
}
|
|
1928
|
-
|
|
1929
|
-
customElements.define("courier-list-item-menu", CourierListItemActionMenu);
|
|
1930
|
-
}
|
|
2166
|
+
registerElement("courier-inbox-list-item-menu", CourierInboxListItemMenu);
|
|
1931
2167
|
const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
1932
2168
|
constructor() {
|
|
1933
2169
|
__publicField(this, "_inboxDataSet");
|
|
@@ -1944,13 +2180,16 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
1944
2180
|
return _CourierInboxDatastore2.instance;
|
|
1945
2181
|
}
|
|
1946
2182
|
get unreadCount() {
|
|
1947
|
-
|
|
2183
|
+
var _a;
|
|
2184
|
+
return (_a = this._unreadCount) != null ? _a : 0;
|
|
1948
2185
|
}
|
|
1949
2186
|
get inboxDataSet() {
|
|
1950
|
-
|
|
2187
|
+
var _a;
|
|
2188
|
+
return (_a = this._inboxDataSet) != null ? _a : { feedType: "inbox", messages: [], canPaginate: false, paginationCursor: null };
|
|
1951
2189
|
}
|
|
1952
2190
|
get archiveDataSet() {
|
|
1953
|
-
|
|
2191
|
+
var _a;
|
|
2192
|
+
return (_a = this._archiveDataSet) != null ? _a : { feedType: "archive", messages: [], canPaginate: false, paginationCursor: null };
|
|
1954
2193
|
}
|
|
1955
2194
|
addDataStoreListener(listener) {
|
|
1956
2195
|
this._dataStoreListeners.push(listener);
|
|
@@ -1959,6 +2198,7 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
1959
2198
|
this._dataStoreListeners = this._dataStoreListeners.filter((l) => l !== listener);
|
|
1960
2199
|
}
|
|
1961
2200
|
async fetchDataSet(props) {
|
|
2201
|
+
var _a2, _b2, _c2;
|
|
1962
2202
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1963
2203
|
if (props.canUseCache) {
|
|
1964
2204
|
switch (props.feedType) {
|
|
@@ -1977,9 +2217,9 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
1977
2217
|
const response = props.feedType === "inbox" ? await ((_a = Courier.shared.client) == null ? void 0 : _a.inbox.getMessages()) : await ((_b = Courier.shared.client) == null ? void 0 : _b.inbox.getArchivedMessages());
|
|
1978
2218
|
return {
|
|
1979
2219
|
feedType: props.feedType,
|
|
1980
|
-
messages: ((_d = (_c = response == null ? void 0 : response.data) == null ? void 0 : _c.messages) == null ? void 0 : _d.nodes)
|
|
1981
|
-
canPaginate: ((_g = (_f = (_e = response == null ? void 0 : response.data) == null ? void 0 : _e.messages) == null ? void 0 : _f.pageInfo) == null ? void 0 : _g.hasNextPage)
|
|
1982
|
-
paginationCursor: ((_j = (_i = (_h = response == null ? void 0 : response.data) == null ? void 0 : _h.messages) == null ? void 0 : _i.pageInfo) == null ? void 0 : _j.startCursor)
|
|
2220
|
+
messages: (_a2 = (_d = (_c = response == null ? void 0 : response.data) == null ? void 0 : _c.messages) == null ? void 0 : _d.nodes) != null ? _a2 : [],
|
|
2221
|
+
canPaginate: (_b2 = (_g = (_f = (_e = response == null ? void 0 : response.data) == null ? void 0 : _e.messages) == null ? void 0 : _f.pageInfo) == null ? void 0 : _g.hasNextPage) != null ? _b2 : false,
|
|
2222
|
+
paginationCursor: (_c2 = (_j = (_i = (_h = response == null ? void 0 : response.data) == null ? void 0 : _h.messages) == null ? void 0 : _i.pageInfo) == null ? void 0 : _j.startCursor) != null ? _c2 : null
|
|
1983
2223
|
};
|
|
1984
2224
|
}
|
|
1985
2225
|
async fetchUnreadCount(props) {
|
|
@@ -1988,7 +2228,7 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
1988
2228
|
return this._unreadCount;
|
|
1989
2229
|
}
|
|
1990
2230
|
const unreadCount = await ((_a = Courier.shared.client) == null ? void 0 : _a.inbox.getUnreadMessageCount());
|
|
1991
|
-
return unreadCount
|
|
2231
|
+
return unreadCount != null ? unreadCount : 0;
|
|
1992
2232
|
}
|
|
1993
2233
|
async load(props) {
|
|
1994
2234
|
var _a, _b, _c;
|
|
@@ -1996,7 +2236,7 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
1996
2236
|
if (!((_a = Courier.shared.client) == null ? void 0 : _a.options.userId)) {
|
|
1997
2237
|
throw new Error("User is not signed in");
|
|
1998
2238
|
}
|
|
1999
|
-
const properties = props
|
|
2239
|
+
const properties = props != null ? props : { feedType: "inbox", canUseCache: true };
|
|
2000
2240
|
const [dataSet, unreadCount] = await Promise.all([
|
|
2001
2241
|
this.fetchDataSet(properties),
|
|
2002
2242
|
this.fetchUnreadCount(properties)
|
|
@@ -2011,9 +2251,10 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
2011
2251
|
}
|
|
2012
2252
|
this._unreadCount = unreadCount;
|
|
2013
2253
|
this._dataStoreListeners.forEach((listener) => {
|
|
2254
|
+
var _a3;
|
|
2014
2255
|
var _a2, _b2, _c2, _d;
|
|
2015
2256
|
(_b2 = (_a2 = listener.events).onDataSetChange) == null ? void 0 : _b2.call(_a2, dataSet, properties.feedType);
|
|
2016
|
-
(_d = (_c2 = listener.events).onUnreadCountChange) == null ? void 0 : _d.call(_c2, this._unreadCount
|
|
2257
|
+
(_d = (_c2 = listener.events).onUnreadCountChange) == null ? void 0 : _d.call(_c2, (_a3 = this._unreadCount) != null ? _a3 : 0);
|
|
2017
2258
|
});
|
|
2018
2259
|
} catch (error) {
|
|
2019
2260
|
(_c = (_b = Courier.shared.client) == null ? void 0 : _b.options.logger) == null ? void 0 : _c.error("Error loading inbox:", error);
|
|
@@ -2049,73 +2290,70 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
2049
2290
|
await Promise.all(dataSetPromises);
|
|
2050
2291
|
}
|
|
2051
2292
|
async connectSocket() {
|
|
2052
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k
|
|
2293
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2053
2294
|
const socket = (_a = Courier.shared.client) == null ? void 0 : _a.inbox.socket;
|
|
2054
2295
|
try {
|
|
2055
2296
|
if (!socket) {
|
|
2056
2297
|
(_c = (_b = Courier.shared.client) == null ? void 0 : _b.options.logger) == null ? void 0 : _c.info("CourierInbox socket not available");
|
|
2057
2298
|
return;
|
|
2058
2299
|
}
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
(_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.");
|
|
2300
|
+
if (socket.isConnecting || socket.isOpen) {
|
|
2301
|
+
(_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}]`);
|
|
2062
2302
|
return;
|
|
2063
2303
|
}
|
|
2064
|
-
socket.
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
if (event.messageId) {
|
|
2070
|
-
message = this.getMessage({ messageId: event.messageId });
|
|
2304
|
+
socket.addMessageEventListener((event) => {
|
|
2305
|
+
if (event.event === MessageEvent.NewMessage) {
|
|
2306
|
+
const message2 = event.data;
|
|
2307
|
+
this.addMessage(message2, 0, "inbox");
|
|
2308
|
+
return;
|
|
2071
2309
|
}
|
|
2310
|
+
const message = this.getMessage({ messageId: event.messageId });
|
|
2072
2311
|
switch (event.event) {
|
|
2073
|
-
case
|
|
2312
|
+
case MessageEvent.MarkAllRead:
|
|
2074
2313
|
this.readAllMessages({ canCallApi: false });
|
|
2075
2314
|
break;
|
|
2076
|
-
case
|
|
2315
|
+
case MessageEvent.Read:
|
|
2077
2316
|
if (message) {
|
|
2078
2317
|
this.readMessage({ message, canCallApi: false });
|
|
2079
2318
|
}
|
|
2080
2319
|
break;
|
|
2081
|
-
case
|
|
2320
|
+
case MessageEvent.Unread:
|
|
2082
2321
|
if (message) {
|
|
2083
2322
|
this.unreadMessage({ message, canCallApi: false });
|
|
2084
2323
|
}
|
|
2085
2324
|
break;
|
|
2086
|
-
case
|
|
2325
|
+
case MessageEvent.Opened:
|
|
2087
2326
|
if (message) {
|
|
2088
2327
|
this.openMessage({ message, canCallApi: false });
|
|
2089
2328
|
}
|
|
2090
2329
|
break;
|
|
2091
|
-
case
|
|
2330
|
+
case MessageEvent.Archive:
|
|
2092
2331
|
if (message) {
|
|
2093
2332
|
this.archiveMessage({ message, canCallApi: false });
|
|
2094
2333
|
}
|
|
2095
2334
|
break;
|
|
2096
|
-
case
|
|
2335
|
+
case MessageEvent.ArchiveRead:
|
|
2097
2336
|
this.archiveReadMessages({ canCallApi: false });
|
|
2098
2337
|
break;
|
|
2099
|
-
case
|
|
2338
|
+
case MessageEvent.Clicked:
|
|
2100
2339
|
if (message) {
|
|
2101
2340
|
this.clickMessage({ message, canCallApi: false });
|
|
2102
2341
|
}
|
|
2103
2342
|
break;
|
|
2104
|
-
case
|
|
2343
|
+
case MessageEvent.Unarchive:
|
|
2105
2344
|
if (message) {
|
|
2106
2345
|
this.unarchiveMessage({ message, canCallApi: false });
|
|
2107
2346
|
}
|
|
2108
2347
|
break;
|
|
2109
|
-
case
|
|
2348
|
+
case MessageEvent.Unopened:
|
|
2110
2349
|
break;
|
|
2111
2350
|
}
|
|
2112
|
-
};
|
|
2351
|
+
});
|
|
2113
2352
|
await socket.connect();
|
|
2114
2353
|
await socket.sendSubscribe();
|
|
2115
|
-
socket.
|
|
2116
|
-
(_j = (_i = Courier.shared.client) == null ? void 0 : _i.options.logger) == null ? void 0 : _j.info("CourierInbox socket connected");
|
|
2354
|
+
(_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}]`);
|
|
2117
2355
|
} catch (error) {
|
|
2118
|
-
(
|
|
2356
|
+
(_k = (_j = Courier.shared.client) == null ? void 0 : _j.options.logger) == null ? void 0 : _k.error("Failed to connect socket:", error);
|
|
2119
2357
|
}
|
|
2120
2358
|
}
|
|
2121
2359
|
/**
|
|
@@ -2124,8 +2362,12 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
2124
2362
|
* @returns The message or undefined if it is not found
|
|
2125
2363
|
*/
|
|
2126
2364
|
getMessage(props) {
|
|
2365
|
+
var _a2;
|
|
2127
2366
|
var _a, _b;
|
|
2128
|
-
|
|
2367
|
+
if (!props.messageId) {
|
|
2368
|
+
return void 0;
|
|
2369
|
+
}
|
|
2370
|
+
return (_a2 = (_a = this._inboxDataSet) == null ? void 0 : _a.messages.find((m) => m.messageId === props.messageId)) != null ? _a2 : (_b = this._archiveDataSet) == null ? void 0 : _b.messages.find((m) => m.messageId === props.messageId);
|
|
2129
2371
|
}
|
|
2130
2372
|
/**
|
|
2131
2373
|
* Fetch the next page of messages
|
|
@@ -2133,6 +2375,7 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
2133
2375
|
* @returns The next page of messages or null if there is no next page
|
|
2134
2376
|
*/
|
|
2135
2377
|
async fetchNextPageOfMessages(props) {
|
|
2378
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
2136
2379
|
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;
|
|
2137
2380
|
switch (props.feedType) {
|
|
2138
2381
|
case "inbox":
|
|
@@ -2148,9 +2391,9 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
2148
2391
|
}));
|
|
2149
2392
|
const dataSet = {
|
|
2150
2393
|
feedType: "inbox",
|
|
2151
|
-
messages: ((_d = (_c = response == null ? void 0 : response.data) == null ? void 0 : _c.messages) == null ? void 0 : _d.nodes)
|
|
2152
|
-
canPaginate: ((_g = (_f = (_e = response == null ? void 0 : response.data) == null ? void 0 : _e.messages) == null ? void 0 : _f.pageInfo) == null ? void 0 : _g.hasNextPage)
|
|
2153
|
-
paginationCursor: ((_j = (_i = (_h = response == null ? void 0 : response.data) == null ? void 0 : _h.messages) == null ? void 0 : _i.pageInfo) == null ? void 0 : _j.startCursor)
|
|
2394
|
+
messages: (_a2 = (_d = (_c = response == null ? void 0 : response.data) == null ? void 0 : _c.messages) == null ? void 0 : _d.nodes) != null ? _a2 : [],
|
|
2395
|
+
canPaginate: (_b2 = (_g = (_f = (_e = response == null ? void 0 : response.data) == null ? void 0 : _e.messages) == null ? void 0 : _f.pageInfo) == null ? void 0 : _g.hasNextPage) != null ? _b2 : false,
|
|
2396
|
+
paginationCursor: (_c2 = (_j = (_i = (_h = response == null ? void 0 : response.data) == null ? void 0 : _h.messages) == null ? void 0 : _i.pageInfo) == null ? void 0 : _j.startCursor) != null ? _c2 : null
|
|
2154
2397
|
};
|
|
2155
2398
|
this.addPage(dataSet);
|
|
2156
2399
|
return dataSet;
|
|
@@ -2175,9 +2418,9 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
2175
2418
|
}));
|
|
2176
2419
|
const dataSet = {
|
|
2177
2420
|
feedType: "archive",
|
|
2178
|
-
messages: ((_p = (_o = response == null ? void 0 : response.data) == null ? void 0 : _o.messages) == null ? void 0 : _p.nodes)
|
|
2179
|
-
canPaginate: ((_s = (_r = (_q = response == null ? void 0 : response.data) == null ? void 0 : _q.messages) == null ? void 0 : _r.pageInfo) == null ? void 0 : _s.hasNextPage)
|
|
2180
|
-
paginationCursor: ((_v = (_u = (_t = response == null ? void 0 : response.data) == null ? void 0 : _t.messages) == null ? void 0 : _u.pageInfo) == null ? void 0 : _v.startCursor)
|
|
2421
|
+
messages: (_d2 = (_p = (_o = response == null ? void 0 : response.data) == null ? void 0 : _o.messages) == null ? void 0 : _p.nodes) != null ? _d2 : [],
|
|
2422
|
+
canPaginate: (_e2 = (_s = (_r = (_q = response == null ? void 0 : response.data) == null ? void 0 : _q.messages) == null ? void 0 : _r.pageInfo) == null ? void 0 : _s.hasNextPage) != null ? _e2 : false,
|
|
2423
|
+
paginationCursor: (_f2 = (_v = (_u = (_t = response == null ? void 0 : response.data) == null ? void 0 : _t.messages) == null ? void 0 : _u.pageInfo) == null ? void 0 : _v.startCursor) != null ? _f2 : null
|
|
2181
2424
|
};
|
|
2182
2425
|
this.addPage(dataSet);
|
|
2183
2426
|
return dataSet;
|
|
@@ -2341,6 +2584,7 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
2341
2584
|
}
|
|
2342
2585
|
}
|
|
2343
2586
|
async archiveReadMessages({ canCallApi = true } = {}) {
|
|
2587
|
+
var _a2;
|
|
2344
2588
|
var _a, _b, _c, _d;
|
|
2345
2589
|
if (!this.canMutate()) {
|
|
2346
2590
|
return;
|
|
@@ -2348,11 +2592,11 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
2348
2592
|
const datastoreSnapshot = this.getDatastoreSnapshot(this.unreadCount, this._inboxDataSet, this._archiveDataSet);
|
|
2349
2593
|
try {
|
|
2350
2594
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
2351
|
-
const messagesToArchive = ((_a = this._inboxDataSet) == null ? void 0 : _a.messages.filter((message) => message.read))
|
|
2595
|
+
const messagesToArchive = (_a2 = (_a = this._inboxDataSet) == null ? void 0 : _a.messages.filter((message) => message.read)) != null ? _a2 : [];
|
|
2352
2596
|
messagesToArchive.forEach((message) => {
|
|
2353
|
-
var
|
|
2597
|
+
var _a22, _b2, _c2;
|
|
2354
2598
|
message.archived = timestamp;
|
|
2355
|
-
const inboxIndex = (
|
|
2599
|
+
const inboxIndex = (_a22 = this._inboxDataSet) == null ? void 0 : _a22.messages.findIndex((m) => m.messageId === message.messageId);
|
|
2356
2600
|
if (inboxIndex !== void 0 && inboxIndex !== -1) {
|
|
2357
2601
|
(_b2 = this._inboxDataSet) == null ? void 0 : _b2.messages.splice(inboxIndex, 1);
|
|
2358
2602
|
}
|
|
@@ -2362,9 +2606,9 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
2362
2606
|
}
|
|
2363
2607
|
});
|
|
2364
2608
|
this._dataStoreListeners.forEach((listener) => {
|
|
2365
|
-
var
|
|
2609
|
+
var _a22, _b2, _c2, _d2;
|
|
2366
2610
|
if (this._inboxDataSet) {
|
|
2367
|
-
(_b2 = (
|
|
2611
|
+
(_b2 = (_a22 = listener.events).onDataSetChange) == null ? void 0 : _b2.call(_a22, this._inboxDataSet, "inbox");
|
|
2368
2612
|
}
|
|
2369
2613
|
if (this._archiveDataSet) {
|
|
2370
2614
|
(_d2 = (_c2 = listener.events).onDataSetChange) == null ? void 0 : _d2.call(_c2, this._archiveDataSet, "archive");
|
|
@@ -2510,9 +2754,10 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
2510
2754
|
break;
|
|
2511
2755
|
}
|
|
2512
2756
|
this._dataStoreListeners.forEach((listener) => {
|
|
2757
|
+
var _a3;
|
|
2513
2758
|
var _a2, _b2, _c, _d;
|
|
2514
2759
|
(_b2 = (_a2 = listener.events).onMessageAdd) == null ? void 0 : _b2.call(_a2, message, index, feedType);
|
|
2515
|
-
(_d = (_c = listener.events).onUnreadCountChange) == null ? void 0 : _d.call(_c, this._unreadCount
|
|
2760
|
+
(_d = (_c = listener.events).onUnreadCountChange) == null ? void 0 : _d.call(_c, (_a3 = this._unreadCount) != null ? _a3 : 0);
|
|
2516
2761
|
});
|
|
2517
2762
|
}
|
|
2518
2763
|
removeMessage(message, index, feedType) {
|
|
@@ -2529,9 +2774,10 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
2529
2774
|
break;
|
|
2530
2775
|
}
|
|
2531
2776
|
this._dataStoreListeners.forEach((listener) => {
|
|
2777
|
+
var _a3;
|
|
2532
2778
|
var _a2, _b2, _c, _d;
|
|
2533
2779
|
(_b2 = (_a2 = listener.events).onMessageRemove) == null ? void 0 : _b2.call(_a2, message, index, feedType);
|
|
2534
|
-
(_d = (_c = listener.events).onUnreadCountChange) == null ? void 0 : _d.call(_c, this._unreadCount
|
|
2780
|
+
(_d = (_c = listener.events).onUnreadCountChange) == null ? void 0 : _d.call(_c, (_a3 = this._unreadCount) != null ? _a3 : 0);
|
|
2535
2781
|
});
|
|
2536
2782
|
}
|
|
2537
2783
|
/**
|
|
@@ -2585,9 +2831,10 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
2585
2831
|
break;
|
|
2586
2832
|
}
|
|
2587
2833
|
this._dataStoreListeners.forEach((listener) => {
|
|
2834
|
+
var _a2;
|
|
2588
2835
|
var _a, _b, _c, _d;
|
|
2589
2836
|
(_b = (_a = listener.events).onMessageUpdate) == null ? void 0 : _b.call(_a, message, index, feedType);
|
|
2590
|
-
(_d = (_c = listener.events).onUnreadCountChange) == null ? void 0 : _d.call(_c, this._unreadCount
|
|
2837
|
+
(_d = (_c = listener.events).onUnreadCountChange) == null ? void 0 : _d.call(_c, (_a2 = this._unreadCount) != null ? _a2 : 0);
|
|
2591
2838
|
});
|
|
2592
2839
|
}
|
|
2593
2840
|
/**
|
|
@@ -2619,7 +2866,7 @@ const _CourierInboxDatastore = class _CourierInboxDatastore2 {
|
|
|
2619
2866
|
};
|
|
2620
2867
|
__publicField(_CourierInboxDatastore, "instance");
|
|
2621
2868
|
let CourierInboxDatastore = _CourierInboxDatastore;
|
|
2622
|
-
class CourierListItem extends
|
|
2869
|
+
class CourierListItem extends BaseElement {
|
|
2623
2870
|
constructor(theme2) {
|
|
2624
2871
|
super();
|
|
2625
2872
|
__publicField(this, "_theme");
|
|
@@ -2658,7 +2905,7 @@ class CourierListItem extends HTMLElement {
|
|
|
2658
2905
|
this._unreadIndicator.className = "unread-indicator";
|
|
2659
2906
|
this._style = document.createElement("style");
|
|
2660
2907
|
this._refreshStyles();
|
|
2661
|
-
this._menu = new
|
|
2908
|
+
this._menu = new CourierInboxListItemMenu(this._theme);
|
|
2662
2909
|
this._menu.setOptions(this._getMenuOptions());
|
|
2663
2910
|
shadow.append(this._style, this._unreadIndicator, contentContainer, this._timeElement, this._menu);
|
|
2664
2911
|
const cancelPropagation = (e) => {
|
|
@@ -2699,18 +2946,19 @@ class CourierListItem extends HTMLElement {
|
|
|
2699
2946
|
"touchstart",
|
|
2700
2947
|
() => {
|
|
2701
2948
|
this._longPressTimeout = window.setTimeout(() => {
|
|
2949
|
+
var _a2, _b2;
|
|
2702
2950
|
this._isLongPress = true;
|
|
2703
2951
|
this._showMenu();
|
|
2704
2952
|
if (this._message && this.onItemLongPress) {
|
|
2705
2953
|
this.onItemLongPress(this._message);
|
|
2706
2954
|
if (navigator.vibrate) {
|
|
2707
|
-
navigator.vibrate((longPress == null ? void 0 : longPress.vibrationDuration)
|
|
2955
|
+
navigator.vibrate((_a2 = longPress == null ? void 0 : longPress.vibrationDuration) != null ? _a2 : 50);
|
|
2708
2956
|
}
|
|
2709
2957
|
}
|
|
2710
2958
|
setTimeout(() => {
|
|
2711
2959
|
this._hideMenu();
|
|
2712
2960
|
this._isLongPress = false;
|
|
2713
|
-
}, (longPress == null ? void 0 : longPress.displayDuration)
|
|
2961
|
+
}, (_b2 = longPress == null ? void 0 : longPress.displayDuration) != null ? _b2 : 2e3);
|
|
2714
2962
|
}, 650);
|
|
2715
2963
|
},
|
|
2716
2964
|
{ passive: true }
|
|
@@ -2727,6 +2975,7 @@ class CourierListItem extends HTMLElement {
|
|
|
2727
2975
|
}
|
|
2728
2976
|
// Helpers
|
|
2729
2977
|
_getMenuOptions() {
|
|
2978
|
+
var _a2, _b2;
|
|
2730
2979
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
2731
2980
|
const menuTheme = (_d = (_c = (_b = (_a = this._theme.inbox) == null ? void 0 : _a.list) == null ? void 0 : _b.item) == null ? void 0 : _c.menu) == null ? void 0 : _d.item;
|
|
2732
2981
|
let options = [];
|
|
@@ -2736,7 +2985,7 @@ class CourierListItem extends HTMLElement {
|
|
|
2736
2985
|
id: ((_e = this._message) == null ? void 0 : _e.read) ? "unread" : "read",
|
|
2737
2986
|
icon: {
|
|
2738
2987
|
svg: ((_f = this._message) == null ? void 0 : _f.read) ? (_g = menuTheme == null ? void 0 : menuTheme.unread) == null ? void 0 : _g.svg : (_h = menuTheme == null ? void 0 : menuTheme.read) == null ? void 0 : _h.svg,
|
|
2739
|
-
color: ((_i = this._message) == null ? void 0 : _i.read) ? (_j = menuTheme == null ? void 0 : menuTheme.unread) == null ? void 0 : _j.color : ((_k = menuTheme == null ? void 0 : menuTheme.read) == null ? void 0 : _k.color)
|
|
2988
|
+
color: ((_i = this._message) == null ? void 0 : _i.read) ? (_j = menuTheme == null ? void 0 : menuTheme.unread) == null ? void 0 : _j.color : (_a2 = (_k = menuTheme == null ? void 0 : menuTheme.read) == null ? void 0 : _k.color) != null ? _a2 : "red"
|
|
2740
2989
|
},
|
|
2741
2990
|
onClick: () => {
|
|
2742
2991
|
if (this._message) {
|
|
@@ -2753,7 +3002,7 @@ class CourierListItem extends HTMLElement {
|
|
|
2753
3002
|
id: isArchiveFeed ? "unarchive" : "archive",
|
|
2754
3003
|
icon: {
|
|
2755
3004
|
svg: isArchiveFeed ? (_l = menuTheme == null ? void 0 : menuTheme.unarchive) == null ? void 0 : _l.svg : (_m = menuTheme == null ? void 0 : menuTheme.archive) == null ? void 0 : _m.svg,
|
|
2756
|
-
color: isArchiveFeed ? (_n = menuTheme == null ? void 0 : menuTheme.unarchive) == null ? void 0 : _n.color : ((_o = menuTheme == null ? void 0 : menuTheme.archive) == null ? void 0 : _o.color)
|
|
3005
|
+
color: isArchiveFeed ? (_n = menuTheme == null ? void 0 : menuTheme.unarchive) == null ? void 0 : _n.color : (_b2 = (_o = menuTheme == null ? void 0 : menuTheme.archive) == null ? void 0 : _o.color) != null ? _b2 : "red"
|
|
2757
3006
|
},
|
|
2758
3007
|
onClick: () => {
|
|
2759
3008
|
if (this._message) {
|
|
@@ -2788,6 +3037,7 @@ class CourierListItem extends HTMLElement {
|
|
|
2788
3037
|
}
|
|
2789
3038
|
}
|
|
2790
3039
|
_getStyles() {
|
|
3040
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l, _m, _n, _o, _p;
|
|
2791
3041
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2792
3042
|
const listItem = (_b = (_a = this._theme.inbox) == null ? void 0 : _a.list) == null ? void 0 : _b.item;
|
|
2793
3043
|
return `
|
|
@@ -2796,7 +3046,7 @@ class CourierListItem extends HTMLElement {
|
|
|
2796
3046
|
flex-direction: row;
|
|
2797
3047
|
align-items: flex-start;
|
|
2798
3048
|
justify-content: space-between;
|
|
2799
|
-
border-bottom: ${(listItem == null ? void 0 : listItem.divider)
|
|
3049
|
+
border-bottom: ${(_a2 = listItem == null ? void 0 : listItem.divider) != null ? _a2 : "1px solid red"};
|
|
2800
3050
|
font-family: inherit;
|
|
2801
3051
|
cursor: pointer;
|
|
2802
3052
|
transition: background-color 0.2s ease;
|
|
@@ -2805,7 +3055,7 @@ class CourierListItem extends HTMLElement {
|
|
|
2805
3055
|
box-sizing: border-box;
|
|
2806
3056
|
padding: 12px 20px;
|
|
2807
3057
|
position: relative;
|
|
2808
|
-
background-color: ${(listItem == null ? void 0 : listItem.backgroundColor)
|
|
3058
|
+
background-color: ${(_b2 = listItem == null ? void 0 : listItem.backgroundColor) != null ? _b2 : "transparent"};
|
|
2809
3059
|
user-select: none;
|
|
2810
3060
|
-webkit-user-select: none;
|
|
2811
3061
|
-moz-user-select: none;
|
|
@@ -2816,21 +3066,21 @@ class CourierListItem extends HTMLElement {
|
|
|
2816
3066
|
/* ───────────────────────── Base hover / active ────────────────── */
|
|
2817
3067
|
@media (hover: hover) {
|
|
2818
3068
|
:host(:hover) {
|
|
2819
|
-
background-color: ${(listItem == null ? void 0 : listItem.hoverBackgroundColor)
|
|
3069
|
+
background-color: ${(_c2 = listItem == null ? void 0 : listItem.hoverBackgroundColor) != null ? _c2 : "red"};
|
|
2820
3070
|
}
|
|
2821
3071
|
}
|
|
2822
3072
|
:host(:active) {
|
|
2823
|
-
background-color: ${(listItem == null ? void 0 : listItem.activeBackgroundColor)
|
|
3073
|
+
background-color: ${(_d2 = listItem == null ? void 0 : listItem.activeBackgroundColor) != null ? _d2 : "red"};
|
|
2824
3074
|
}
|
|
2825
3075
|
|
|
2826
3076
|
/* ───────────────────────── Menu hover / active ────────────────── */
|
|
2827
3077
|
@media (hover: hover) {
|
|
2828
|
-
:host(:hover):has(courier-list-item-menu:hover, courier-list-item-menu *:hover, courier-button:hover, courier-button *:hover) {
|
|
2829
|
-
background-color: ${(listItem == null ? void 0 : listItem.backgroundColor)
|
|
3078
|
+
:host(:hover):has(courier-inbox-list-item-menu:hover, courier-inbox-list-item-menu *:hover, courier-button:hover, courier-button *:hover) {
|
|
3079
|
+
background-color: ${(_e2 = listItem == null ? void 0 : listItem.backgroundColor) != null ? _e2 : "transparent"};
|
|
2830
3080
|
}
|
|
2831
3081
|
}
|
|
2832
|
-
:host(:active):has(courier-list-item-menu:active, courier-list-item-menu *:active, courier-button:active, courier-button *:active) {
|
|
2833
|
-
background-color: ${(listItem == null ? void 0 : listItem.backgroundColor)
|
|
3082
|
+
:host(:active):has(courier-inbox-list-item-menu:active, courier-inbox-list-item-menu *:active, courier-button:active, courier-button *:active) {
|
|
3083
|
+
background-color: ${(_f2 = listItem == null ? void 0 : listItem.backgroundColor) != null ? _f2 : "transparent"};
|
|
2834
3084
|
}
|
|
2835
3085
|
|
|
2836
3086
|
:host(:last-child) {
|
|
@@ -2844,7 +3094,7 @@ class CourierListItem extends HTMLElement {
|
|
|
2844
3094
|
width: 8px;
|
|
2845
3095
|
height: 8px;
|
|
2846
3096
|
border-radius: 50%;
|
|
2847
|
-
background-color: ${(listItem == null ? void 0 : listItem.unreadIndicatorColor)
|
|
3097
|
+
background-color: ${(_g2 = listItem == null ? void 0 : listItem.unreadIndicatorColor) != null ? _g2 : "red"};
|
|
2848
3098
|
display: none;
|
|
2849
3099
|
}
|
|
2850
3100
|
|
|
@@ -2873,27 +3123,27 @@ class CourierListItem extends HTMLElement {
|
|
|
2873
3123
|
}
|
|
2874
3124
|
|
|
2875
3125
|
p[part='title'] {
|
|
2876
|
-
font-family: ${((_c = listItem == null ? void 0 : listItem.title) == null ? void 0 : _c.family)
|
|
2877
|
-
font-size: ${((_d = listItem == null ? void 0 : listItem.title) == null ? void 0 : _d.size)
|
|
2878
|
-
color: ${((_e = listItem == null ? void 0 : listItem.title) == null ? void 0 : _e.color)
|
|
3126
|
+
font-family: ${(_h2 = (_c = listItem == null ? void 0 : listItem.title) == null ? void 0 : _c.family) != null ? _h2 : "inherit"};
|
|
3127
|
+
font-size: ${(_i2 = (_d = listItem == null ? void 0 : listItem.title) == null ? void 0 : _d.size) != null ? _i2 : "14px"};
|
|
3128
|
+
color: ${(_j2 = (_e = listItem == null ? void 0 : listItem.title) == null ? void 0 : _e.color) != null ? _j2 : "red"};
|
|
2879
3129
|
margin-bottom: 4px;
|
|
2880
3130
|
}
|
|
2881
3131
|
|
|
2882
3132
|
p[part='subtitle'] {
|
|
2883
|
-
font-family: ${((_f = listItem == null ? void 0 : listItem.subtitle) == null ? void 0 : _f.family)
|
|
2884
|
-
font-size: ${((_g = listItem == null ? void 0 : listItem.subtitle) == null ? void 0 : _g.size)
|
|
2885
|
-
color: ${((_h = listItem == null ? void 0 : listItem.subtitle) == null ? void 0 : _h.color)
|
|
3133
|
+
font-family: ${(_k2 = (_f = listItem == null ? void 0 : listItem.subtitle) == null ? void 0 : _f.family) != null ? _k2 : "inherit"};
|
|
3134
|
+
font-size: ${(_l = (_g = listItem == null ? void 0 : listItem.subtitle) == null ? void 0 : _g.size) != null ? _l : "14px"};
|
|
3135
|
+
color: ${(_m = (_h = listItem == null ? void 0 : listItem.subtitle) == null ? void 0 : _h.color) != null ? _m : "red"};
|
|
2886
3136
|
}
|
|
2887
3137
|
|
|
2888
3138
|
p[part='time'] {
|
|
2889
|
-
font-family: ${((_i = listItem == null ? void 0 : listItem.time) == null ? void 0 : _i.family)
|
|
2890
|
-
font-size: ${((_j = listItem == null ? void 0 : listItem.time) == null ? void 0 : _j.size)
|
|
2891
|
-
color: ${((_k = listItem == null ? void 0 : listItem.time) == null ? void 0 : _k.color)
|
|
3139
|
+
font-family: ${(_n = (_i = listItem == null ? void 0 : listItem.time) == null ? void 0 : _i.family) != null ? _n : "inherit"};
|
|
3140
|
+
font-size: ${(_o = (_j = listItem == null ? void 0 : listItem.time) == null ? void 0 : _j.size) != null ? _o : "14px"};
|
|
3141
|
+
color: ${(_p = (_k = listItem == null ? void 0 : listItem.time) == null ? void 0 : _k.color) != null ? _p : "red"};
|
|
2892
3142
|
text-align: right;
|
|
2893
3143
|
white-space: nowrap;
|
|
2894
3144
|
}
|
|
2895
3145
|
|
|
2896
|
-
courier-list-item-menu {
|
|
3146
|
+
courier-inbox-list-item-menu {
|
|
2897
3147
|
z-index: 1;
|
|
2898
3148
|
position: absolute;
|
|
2899
3149
|
top: 8px;
|
|
@@ -2989,10 +3239,8 @@ class CourierListItem extends HTMLElement {
|
|
|
2989
3239
|
});
|
|
2990
3240
|
}
|
|
2991
3241
|
}
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
}
|
|
2995
|
-
class CourierInboxSkeletonListItem extends HTMLElement {
|
|
3242
|
+
registerElement("courier-inbox-list-item", CourierListItem);
|
|
3243
|
+
class CourierInboxSkeletonListItem extends BaseElement {
|
|
2996
3244
|
constructor(theme2, opacity) {
|
|
2997
3245
|
super();
|
|
2998
3246
|
__publicField(this, "_shadow");
|
|
@@ -3021,10 +3269,8 @@ class CourierInboxSkeletonListItem extends HTMLElement {
|
|
|
3021
3269
|
`;
|
|
3022
3270
|
}
|
|
3023
3271
|
}
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
}
|
|
3027
|
-
class CourierSkeletonAnimatedRow extends HTMLElement {
|
|
3272
|
+
registerElement("courier-inbox-skeleton-list-item", CourierInboxSkeletonListItem);
|
|
3273
|
+
class CourierSkeletonAnimatedRow extends BaseElement {
|
|
3028
3274
|
constructor(theme2, widthPercent) {
|
|
3029
3275
|
super();
|
|
3030
3276
|
__publicField(this, "_shadow");
|
|
@@ -3037,8 +3283,9 @@ class CourierSkeletonAnimatedRow extends HTMLElement {
|
|
|
3037
3283
|
this._shadow.appendChild(skeletonItem);
|
|
3038
3284
|
}
|
|
3039
3285
|
getStyles(theme2, widthPercent) {
|
|
3286
|
+
var _a2, _b2, _c2, _d2;
|
|
3040
3287
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
3041
|
-
const color = ((_c = (_b = (_a = theme2.inbox) == null ? void 0 : _a.loading) == null ? void 0 : _b.animation) == null ? void 0 : _c.barColor)
|
|
3288
|
+
const color = (_a2 = (_c = (_b = (_a = theme2.inbox) == null ? void 0 : _a.loading) == null ? void 0 : _b.animation) == null ? void 0 : _c.barColor) != null ? _a2 : "#000";
|
|
3042
3289
|
const hexColor = color.length === 4 ? `#${color[1]}${color[1]}${color[2]}${color[2]}${color[3]}${color[3]}` : color;
|
|
3043
3290
|
const r = parseInt(hexColor.slice(1, 3), 16);
|
|
3044
3291
|
const g = parseInt(hexColor.slice(3, 5), 16);
|
|
@@ -3055,7 +3302,7 @@ class CourierSkeletonAnimatedRow extends HTMLElement {
|
|
|
3055
3302
|
}
|
|
3056
3303
|
|
|
3057
3304
|
.skeleton-item {
|
|
3058
|
-
height: ${((_f = (_e = (_d = theme2.inbox) == null ? void 0 : _d.loading) == null ? void 0 : _e.animation) == null ? void 0 : _f.barHeight)
|
|
3305
|
+
height: ${(_b2 = (_f = (_e = (_d = theme2.inbox) == null ? void 0 : _d.loading) == null ? void 0 : _e.animation) == null ? void 0 : _f.barHeight) != null ? _b2 : "14px"};
|
|
3059
3306
|
width: 100%;
|
|
3060
3307
|
background: linear-gradient(
|
|
3061
3308
|
90deg,
|
|
@@ -3064,8 +3311,8 @@ class CourierSkeletonAnimatedRow extends HTMLElement {
|
|
|
3064
3311
|
${colorWithAlpha80} 75%
|
|
3065
3312
|
);
|
|
3066
3313
|
background-size: 200% 100%;
|
|
3067
|
-
animation: shimmer ${((_i = (_h = (_g = theme2.inbox) == null ? void 0 : _g.loading) == null ? void 0 : _h.animation) == null ? void 0 : _i.duration)
|
|
3068
|
-
border-radius: ${((_l = (_k = (_j = theme2.inbox) == null ? void 0 : _j.loading) == null ? void 0 : _k.animation) == null ? void 0 : _l.barBorderRadius)
|
|
3314
|
+
animation: shimmer ${(_c2 = (_i = (_h = (_g = theme2.inbox) == null ? void 0 : _g.loading) == null ? void 0 : _h.animation) == null ? void 0 : _i.duration) != null ? _c2 : "2s"} ease-in-out infinite;
|
|
3315
|
+
border-radius: ${(_d2 = (_l = (_k = (_j = theme2.inbox) == null ? void 0 : _j.loading) == null ? void 0 : _k.animation) == null ? void 0 : _l.barBorderRadius) != null ? _d2 : "14px"};
|
|
3069
3316
|
}
|
|
3070
3317
|
|
|
3071
3318
|
@keyframes shimmer {
|
|
@@ -3079,9 +3326,7 @@ class CourierSkeletonAnimatedRow extends HTMLElement {
|
|
|
3079
3326
|
`;
|
|
3080
3327
|
}
|
|
3081
3328
|
}
|
|
3082
|
-
|
|
3083
|
-
customElements.define("courier-skeleton-animated-row", CourierSkeletonAnimatedRow);
|
|
3084
|
-
}
|
|
3329
|
+
registerElement("courier-skeleton-animated-row", CourierSkeletonAnimatedRow);
|
|
3085
3330
|
class CourierInboxSkeletonList extends CourierElement {
|
|
3086
3331
|
constructor(theme2) {
|
|
3087
3332
|
super();
|
|
@@ -3102,6 +3347,7 @@ class CourierInboxSkeletonList extends CourierElement {
|
|
|
3102
3347
|
return list;
|
|
3103
3348
|
}
|
|
3104
3349
|
getStyles() {
|
|
3350
|
+
var _a2;
|
|
3105
3351
|
var _a, _b;
|
|
3106
3352
|
return `
|
|
3107
3353
|
:host {
|
|
@@ -3122,7 +3368,7 @@ class CourierInboxSkeletonList extends CourierElement {
|
|
|
3122
3368
|
}
|
|
3123
3369
|
|
|
3124
3370
|
.list > * {
|
|
3125
|
-
border-bottom: ${((_b = (_a = this._theme.inbox) == null ? void 0 : _a.loading) == null ? void 0 : _b.divider)
|
|
3371
|
+
border-bottom: ${(_a2 = (_b = (_a = this._theme.inbox) == null ? void 0 : _a.loading) == null ? void 0 : _b.divider) != null ? _a2 : "1px solid red"};
|
|
3126
3372
|
}
|
|
3127
3373
|
|
|
3128
3374
|
.list > *:last-child {
|
|
@@ -3131,10 +3377,8 @@ class CourierInboxSkeletonList extends CourierElement {
|
|
|
3131
3377
|
`;
|
|
3132
3378
|
}
|
|
3133
3379
|
}
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
}
|
|
3137
|
-
class CourierInboxPaginationListItem extends HTMLElement {
|
|
3380
|
+
registerElement("courier-inbox-skeleton-list", CourierInboxSkeletonList);
|
|
3381
|
+
class CourierInboxPaginationListItem extends BaseElement {
|
|
3138
3382
|
constructor(props) {
|
|
3139
3383
|
super();
|
|
3140
3384
|
__publicField(this, "skeletonLoadingList");
|
|
@@ -3183,10 +3427,8 @@ class CourierInboxPaginationListItem extends HTMLElement {
|
|
|
3183
3427
|
this.observer.disconnect();
|
|
3184
3428
|
}
|
|
3185
3429
|
}
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
}
|
|
3189
|
-
class CourierInboxList extends HTMLElement {
|
|
3430
|
+
registerElement("courier-inbox-pagination-list-item", CourierInboxPaginationListItem);
|
|
3431
|
+
class CourierInboxList extends BaseElement {
|
|
3190
3432
|
constructor(props) {
|
|
3191
3433
|
super();
|
|
3192
3434
|
__publicField(this, "_themeSubscription");
|
|
@@ -3223,13 +3465,14 @@ class CourierInboxList extends HTMLElement {
|
|
|
3223
3465
|
return this._messages;
|
|
3224
3466
|
}
|
|
3225
3467
|
getStyles() {
|
|
3468
|
+
var _a2;
|
|
3226
3469
|
var _a;
|
|
3227
3470
|
const list = (_a = this._themeSubscription.manager.getTheme().inbox) == null ? void 0 : _a.list;
|
|
3228
3471
|
return `
|
|
3229
3472
|
:host {
|
|
3230
3473
|
flex: 1;
|
|
3231
3474
|
width: 100%;
|
|
3232
|
-
background-color: ${(list == null ? void 0 : list.backgroundColor)
|
|
3475
|
+
background-color: ${(_a2 = list == null ? void 0 : list.backgroundColor) != null ? _a2 : CourierColors.white[500]};
|
|
3233
3476
|
}
|
|
3234
3477
|
|
|
3235
3478
|
ul {
|
|
@@ -3302,6 +3545,7 @@ class CourierInboxList extends HTMLElement {
|
|
|
3302
3545
|
this._onRefresh();
|
|
3303
3546
|
}
|
|
3304
3547
|
render() {
|
|
3548
|
+
var _a2, _b2;
|
|
3305
3549
|
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, _ba, _ca, _da;
|
|
3306
3550
|
this.reset();
|
|
3307
3551
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
@@ -3309,7 +3553,7 @@ class CourierInboxList extends HTMLElement {
|
|
|
3309
3553
|
const error = (_a = theme2.inbox) == null ? void 0 : _a.error;
|
|
3310
3554
|
const errorElement = new CourierInfoState({
|
|
3311
3555
|
title: {
|
|
3312
|
-
text: ((_b = error == null ? void 0 : error.title) == null ? void 0 : _b.text)
|
|
3556
|
+
text: (_a2 = (_b = error == null ? void 0 : error.title) == null ? void 0 : _b.text) != null ? _a2 : this._error.message,
|
|
3313
3557
|
textColor: (_d = (_c = error == null ? void 0 : error.title) == null ? void 0 : _c.font) == null ? void 0 : _d.color,
|
|
3314
3558
|
fontFamily: (_f = (_e = error == null ? void 0 : error.title) == null ? void 0 : _e.font) == null ? void 0 : _f.family,
|
|
3315
3559
|
fontSize: (_h = (_g = error == null ? void 0 : error.title) == null ? void 0 : _g.font) == null ? void 0 : _h.size,
|
|
@@ -3344,7 +3588,7 @@ class CourierInboxList extends HTMLElement {
|
|
|
3344
3588
|
const empty = (_D = theme2.inbox) == null ? void 0 : _D.empty;
|
|
3345
3589
|
const emptyElement = new CourierInfoState({
|
|
3346
3590
|
title: {
|
|
3347
|
-
text: ((_E = empty == null ? void 0 : empty.title) == null ? void 0 : _E.text)
|
|
3591
|
+
text: (_b2 = (_E = empty == null ? void 0 : empty.title) == null ? void 0 : _E.text) != null ? _b2 : `No ${this._feedType} messages yet`,
|
|
3348
3592
|
textColor: (_G = (_F = empty == null ? void 0 : empty.title) == null ? void 0 : _F.font) == null ? void 0 : _G.color,
|
|
3349
3593
|
fontFamily: (_I = (_H = empty == null ? void 0 : empty.title) == null ? void 0 : _H.font) == null ? void 0 : _I.family,
|
|
3350
3594
|
fontSize: (_K = (_J = empty == null ? void 0 : empty.title) == null ? void 0 : _J.font) == null ? void 0 : _K.size,
|
|
@@ -3379,16 +3623,16 @@ class CourierInboxList extends HTMLElement {
|
|
|
3379
3623
|
const listItem = new CourierListItem(theme2);
|
|
3380
3624
|
listItem.setMessage(message, this._feedType);
|
|
3381
3625
|
listItem.setOnItemClick((message2) => {
|
|
3382
|
-
var
|
|
3383
|
-
return (
|
|
3626
|
+
var _a22;
|
|
3627
|
+
return (_a22 = this._onMessageClick) == null ? void 0 : _a22.call(this, message2, index);
|
|
3384
3628
|
});
|
|
3385
3629
|
listItem.setOnItemActionClick((message2, action) => {
|
|
3386
|
-
var
|
|
3387
|
-
return (
|
|
3630
|
+
var _a22;
|
|
3631
|
+
return (_a22 = this._onMessageActionClick) == null ? void 0 : _a22.call(this, message2, action, index);
|
|
3388
3632
|
});
|
|
3389
3633
|
listItem.setOnItemLongPress((message2) => {
|
|
3390
|
-
var
|
|
3391
|
-
return (
|
|
3634
|
+
var _a22;
|
|
3635
|
+
return (_a22 = this._onMessageLongPress) == null ? void 0 : _a22.call(this, message2, index);
|
|
3392
3636
|
});
|
|
3393
3637
|
list.appendChild(listItem);
|
|
3394
3638
|
});
|
|
@@ -3397,8 +3641,8 @@ class CourierInboxList extends HTMLElement {
|
|
|
3397
3641
|
theme: theme2,
|
|
3398
3642
|
customItem: (_da = this._paginationItemFactory) == null ? void 0 : _da.call(this, { feedType: this._feedType }),
|
|
3399
3643
|
onPaginationTrigger: () => {
|
|
3400
|
-
var
|
|
3401
|
-
return (
|
|
3644
|
+
var _a22;
|
|
3645
|
+
return (_a22 = this._onPaginationTrigger) == null ? void 0 : _a22.call(this, this._feedType);
|
|
3402
3646
|
}
|
|
3403
3647
|
});
|
|
3404
3648
|
list.appendChild(paginationItem);
|
|
@@ -3433,11 +3677,10 @@ class CourierInboxList extends HTMLElement {
|
|
|
3433
3677
|
this._themeSubscription.unsubscribe();
|
|
3434
3678
|
}
|
|
3435
3679
|
}
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
}
|
|
3439
|
-
class CourierInboxOptionMenuItem extends HTMLElement {
|
|
3680
|
+
registerElement("courier-inbox-list", CourierInboxList);
|
|
3681
|
+
class CourierInboxOptionMenuItem extends BaseElement {
|
|
3440
3682
|
constructor(props) {
|
|
3683
|
+
var _a;
|
|
3441
3684
|
super();
|
|
3442
3685
|
__publicField(this, "_option");
|
|
3443
3686
|
__publicField(this, "_isSelected");
|
|
@@ -3454,7 +3697,7 @@ class CourierInboxOptionMenuItem extends HTMLElement {
|
|
|
3454
3697
|
this._style = document.createElement("style");
|
|
3455
3698
|
this._content = document.createElement("div");
|
|
3456
3699
|
this._content.className = "menu-item";
|
|
3457
|
-
this._itemIcon = new CourierIcon(this._option.icon.svg
|
|
3700
|
+
this._itemIcon = new CourierIcon((_a = this._option.icon.svg) != null ? _a : CourierIconSVGs.inbox);
|
|
3458
3701
|
this._itemIcon.setAttribute("size", "16");
|
|
3459
3702
|
this._title = document.createElement("p");
|
|
3460
3703
|
this._title.textContent = this._option.text;
|
|
@@ -3473,6 +3716,7 @@ class CourierInboxOptionMenuItem extends HTMLElement {
|
|
|
3473
3716
|
this.refreshTheme();
|
|
3474
3717
|
}
|
|
3475
3718
|
getStyles() {
|
|
3719
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
3476
3720
|
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;
|
|
3477
3721
|
const theme2 = this._themeManager.getTheme();
|
|
3478
3722
|
return `
|
|
@@ -3484,11 +3728,11 @@ class CourierInboxOptionMenuItem extends HTMLElement {
|
|
|
3484
3728
|
}
|
|
3485
3729
|
|
|
3486
3730
|
:host(:hover) {
|
|
3487
|
-
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)
|
|
3731
|
+
background-color: ${(_a2 = (_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) != null ? _a2 : "red"};
|
|
3488
3732
|
}
|
|
3489
3733
|
|
|
3490
3734
|
:host(:active) {
|
|
3491
|
-
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)
|
|
3735
|
+
background-color: ${(_b2 = (_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) != null ? _b2 : "red"};
|
|
3492
3736
|
}
|
|
3493
3737
|
|
|
3494
3738
|
.menu-item {
|
|
@@ -3504,10 +3748,10 @@ class CourierInboxOptionMenuItem extends HTMLElement {
|
|
|
3504
3748
|
|
|
3505
3749
|
p {
|
|
3506
3750
|
margin: 0;
|
|
3507
|
-
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)
|
|
3508
|
-
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)
|
|
3509
|
-
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)
|
|
3510
|
-
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)
|
|
3751
|
+
font-family: ${(_c2 = (_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) != null ? _c2 : "inherit"};
|
|
3752
|
+
font-weight: ${(_d2 = (_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) != null ? _d2 : "inherit"};
|
|
3753
|
+
font-size: ${(_e2 = (_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) != null ? _e2 : "14px"};
|
|
3754
|
+
color: ${(_f2 = (_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) != null ? _f2 : "red"};
|
|
3511
3755
|
white-space: nowrap;
|
|
3512
3756
|
}
|
|
3513
3757
|
|
|
@@ -3517,19 +3761,18 @@ class CourierInboxOptionMenuItem extends HTMLElement {
|
|
|
3517
3761
|
`;
|
|
3518
3762
|
}
|
|
3519
3763
|
refreshTheme() {
|
|
3764
|
+
var _a2, _b2, _c2, _d2, _e;
|
|
3520
3765
|
var _a, _b, _c, _d;
|
|
3521
3766
|
this._style.textContent = this.getStyles();
|
|
3522
|
-
this._selectionIcon.updateColor(((_a = this._option.selectionIcon) == null ? void 0 : _a.color)
|
|
3523
|
-
this._selectionIcon.updateSVG(((_b = this._option.selectionIcon) == null ? void 0 : _b.svg)
|
|
3524
|
-
this._title.textContent = this._option.text
|
|
3525
|
-
this._itemIcon.updateColor(((_c = this._option.icon) == null ? void 0 : _c.color)
|
|
3526
|
-
this._itemIcon.updateSVG(((_d = this._option.icon) == null ? void 0 : _d.svg)
|
|
3767
|
+
this._selectionIcon.updateColor((_a2 = (_a = this._option.selectionIcon) == null ? void 0 : _a.color) != null ? _a2 : "red");
|
|
3768
|
+
this._selectionIcon.updateSVG((_b2 = (_b = this._option.selectionIcon) == null ? void 0 : _b.svg) != null ? _b2 : CourierIconSVGs.check);
|
|
3769
|
+
this._title.textContent = (_c2 = this._option.text) != null ? _c2 : "Missing Text";
|
|
3770
|
+
this._itemIcon.updateColor((_d2 = (_c = this._option.icon) == null ? void 0 : _c.color) != null ? _d2 : "red");
|
|
3771
|
+
this._itemIcon.updateSVG((_e = (_d = this._option.icon) == null ? void 0 : _d.svg) != null ? _e : CourierIconSVGs.inbox);
|
|
3527
3772
|
}
|
|
3528
3773
|
}
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
}
|
|
3532
|
-
class CourierInboxOptionMenu extends HTMLElement {
|
|
3774
|
+
registerElement("courier-inbox-filter-menu-item", CourierInboxOptionMenuItem);
|
|
3775
|
+
class CourierInboxOptionMenu extends BaseElement {
|
|
3533
3776
|
constructor(themeManager, type, selectable, options, onMenuOpen) {
|
|
3534
3777
|
super();
|
|
3535
3778
|
__publicField(this, "_themeSubscription");
|
|
@@ -3562,6 +3805,7 @@ class CourierInboxOptionMenu extends HTMLElement {
|
|
|
3562
3805
|
this.refreshTheme();
|
|
3563
3806
|
}
|
|
3564
3807
|
getStyles() {
|
|
3808
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
3565
3809
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
3566
3810
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
3567
3811
|
return `
|
|
@@ -3575,10 +3819,10 @@ class CourierInboxOptionMenu extends HTMLElement {
|
|
|
3575
3819
|
position: absolute;
|
|
3576
3820
|
top: 42px;
|
|
3577
3821
|
right: -6px;
|
|
3578
|
-
border-radius: ${((_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.borderRadius)
|
|
3579
|
-
border: ${((_h = (_g = (_f = (_e = theme2.inbox) == null ? void 0 : _e.header) == null ? void 0 : _f.menus) == null ? void 0 : _g.popup) == null ? void 0 : _h.border)
|
|
3580
|
-
background: ${((_l = (_k = (_j = (_i = theme2.inbox) == null ? void 0 : _i.header) == null ? void 0 : _j.menus) == null ? void 0 : _k.popup) == null ? void 0 : _l.backgroundColor)
|
|
3581
|
-
box-shadow: ${((_p = (_o = (_n = (_m = theme2.inbox) == null ? void 0 : _m.header) == null ? void 0 : _n.menus) == null ? void 0 : _o.popup) == null ? void 0 : _p.shadow)
|
|
3822
|
+
border-radius: ${(_a2 = (_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.borderRadius) != null ? _a2 : "6px"};
|
|
3823
|
+
border: ${(_b2 = (_h = (_g = (_f = (_e = theme2.inbox) == null ? void 0 : _e.header) == null ? void 0 : _f.menus) == null ? void 0 : _g.popup) == null ? void 0 : _h.border) != null ? _b2 : "1px solid red"};
|
|
3824
|
+
background: ${(_c2 = (_l = (_k = (_j = (_i = theme2.inbox) == null ? void 0 : _i.header) == null ? void 0 : _j.menus) == null ? void 0 : _k.popup) == null ? void 0 : _l.backgroundColor) != null ? _c2 : "red"};
|
|
3825
|
+
box-shadow: ${(_d2 = (_p = (_o = (_n = (_m = theme2.inbox) == null ? void 0 : _m.header) == null ? void 0 : _n.menus) == null ? void 0 : _o.popup) == null ? void 0 : _p.shadow) != null ? _d2 : "0 4px 12px 0 red"};
|
|
3582
3826
|
z-index: 1000;
|
|
3583
3827
|
min-width: 200px;
|
|
3584
3828
|
overflow: hidden;
|
|
@@ -3586,7 +3830,7 @@ class CourierInboxOptionMenu extends HTMLElement {
|
|
|
3586
3830
|
}
|
|
3587
3831
|
|
|
3588
3832
|
courier-inbox-filter-menu-item {
|
|
3589
|
-
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)
|
|
3833
|
+
border-bottom: ${(_e2 = (_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) != null ? _e2 : "none"};
|
|
3590
3834
|
}
|
|
3591
3835
|
|
|
3592
3836
|
courier-inbox-filter-menu-item:last-child {
|
|
@@ -3595,6 +3839,7 @@ class CourierInboxOptionMenu extends HTMLElement {
|
|
|
3595
3839
|
`;
|
|
3596
3840
|
}
|
|
3597
3841
|
refreshTheme() {
|
|
3842
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
3598
3843
|
var _a, _b, _c, _d, _e, _f;
|
|
3599
3844
|
this._style.textContent = this.getStyles();
|
|
3600
3845
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
@@ -3602,11 +3847,11 @@ class CourierInboxOptionMenu extends HTMLElement {
|
|
|
3602
3847
|
const isFilter = this._type === "filters";
|
|
3603
3848
|
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;
|
|
3604
3849
|
const defaultIcon = isFilter ? CourierIconSVGs.filter : CourierIconSVGs.overflow;
|
|
3605
|
-
this._menuButton.updateIconSVG(((_e = buttonConfig == null ? void 0 : buttonConfig.icon) == null ? void 0 : _e.svg)
|
|
3606
|
-
this._menuButton.updateIconColor(((_f = buttonConfig == null ? void 0 : buttonConfig.icon) == null ? void 0 : _f.color)
|
|
3607
|
-
this._menuButton.updateBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.backgroundColor)
|
|
3608
|
-
this._menuButton.updateHoverBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.hoverBackgroundColor)
|
|
3609
|
-
this._menuButton.updateActiveBackgroundColor((buttonConfig == null ? void 0 : buttonConfig.activeBackgroundColor)
|
|
3850
|
+
this._menuButton.updateIconSVG((_a2 = (_e = buttonConfig == null ? void 0 : buttonConfig.icon) == null ? void 0 : _e.svg) != null ? _a2 : defaultIcon);
|
|
3851
|
+
this._menuButton.updateIconColor((_b2 = (_f = buttonConfig == null ? void 0 : buttonConfig.icon) == null ? void 0 : _f.color) != null ? _b2 : "red");
|
|
3852
|
+
this._menuButton.updateBackgroundColor((_c2 = buttonConfig == null ? void 0 : buttonConfig.backgroundColor) != null ? _c2 : "transparent");
|
|
3853
|
+
this._menuButton.updateHoverBackgroundColor((_d2 = buttonConfig == null ? void 0 : buttonConfig.hoverBackgroundColor) != null ? _d2 : "red");
|
|
3854
|
+
this._menuButton.updateActiveBackgroundColor((_e2 = buttonConfig == null ? void 0 : buttonConfig.activeBackgroundColor) != null ? _e2 : "red");
|
|
3610
3855
|
this.refreshMenuItems();
|
|
3611
3856
|
}
|
|
3612
3857
|
setOptions(options) {
|
|
@@ -3655,10 +3900,8 @@ class CourierInboxOptionMenu extends HTMLElement {
|
|
|
3655
3900
|
this._themeSubscription.unsubscribe();
|
|
3656
3901
|
}
|
|
3657
3902
|
}
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
}
|
|
3661
|
-
class CourierUnreadCountBadge extends HTMLElement {
|
|
3903
|
+
registerElement("courier-inbox-option-menu", CourierInboxOptionMenu);
|
|
3904
|
+
class CourierUnreadCountBadge extends BaseElement {
|
|
3662
3905
|
constructor(props) {
|
|
3663
3906
|
super();
|
|
3664
3907
|
__publicField(this, "_themeSubscription");
|
|
@@ -3724,11 +3967,10 @@ class CourierUnreadCountBadge extends HTMLElement {
|
|
|
3724
3967
|
this._themeSubscription.unsubscribe();
|
|
3725
3968
|
}
|
|
3726
3969
|
}
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
}
|
|
3730
|
-
class CourierInboxHeaderTitle extends HTMLElement {
|
|
3970
|
+
registerElement("courier-unread-count-badge", CourierUnreadCountBadge);
|
|
3971
|
+
class CourierInboxHeaderTitle extends BaseElement {
|
|
3731
3972
|
constructor(themeManager, option) {
|
|
3973
|
+
var _a;
|
|
3732
3974
|
super();
|
|
3733
3975
|
__publicField(this, "_themeSubscription");
|
|
3734
3976
|
__publicField(this, "_option");
|
|
@@ -3755,11 +3997,13 @@ class CourierInboxHeaderTitle extends HTMLElement {
|
|
|
3755
3997
|
shadow.appendChild(this._style);
|
|
3756
3998
|
shadow.appendChild(this._container);
|
|
3757
3999
|
this._themeSubscription = themeManager.subscribe((_) => {
|
|
3758
|
-
|
|
4000
|
+
var _a2;
|
|
4001
|
+
this.refreshTheme((_a2 = this._feedType) != null ? _a2 : "inbox");
|
|
3759
4002
|
});
|
|
3760
|
-
this.refreshTheme(this._feedType
|
|
4003
|
+
this.refreshTheme((_a = this._feedType) != null ? _a : "inbox");
|
|
3761
4004
|
}
|
|
3762
4005
|
getStyles() {
|
|
4006
|
+
var _a2, _b2, _c2, _d2;
|
|
3763
4007
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
3764
4008
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
3765
4009
|
return `
|
|
@@ -3777,10 +4021,10 @@ class CourierInboxHeaderTitle extends HTMLElement {
|
|
|
3777
4021
|
|
|
3778
4022
|
h2 {
|
|
3779
4023
|
margin: 0;
|
|
3780
|
-
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)
|
|
3781
|
-
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)
|
|
3782
|
-
font-weight: ${((_l = (_k = (_j = (_i = theme2.inbox) == null ? void 0 : _i.header) == null ? void 0 : _j.filters) == null ? void 0 : _k.font) == null ? void 0 : _l.weight)
|
|
3783
|
-
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)
|
|
4024
|
+
font-family: ${(_a2 = (_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) != null ? _a2 : "inherit"};
|
|
4025
|
+
font-size: ${(_b2 = (_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) != null ? _b2 : "18px"};
|
|
4026
|
+
font-weight: ${(_c2 = (_l = (_k = (_j = (_i = theme2.inbox) == null ? void 0 : _i.header) == null ? void 0 : _j.filters) == null ? void 0 : _k.font) == null ? void 0 : _l.weight) != null ? _c2 : "500"};
|
|
4027
|
+
color: ${(_d2 = (_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) != null ? _d2 : "red"};
|
|
3784
4028
|
}
|
|
3785
4029
|
|
|
3786
4030
|
courier-unread-count-badge {
|
|
@@ -3801,18 +4045,19 @@ class CourierInboxHeaderTitle extends HTMLElement {
|
|
|
3801
4045
|
this.updateFilter();
|
|
3802
4046
|
}
|
|
3803
4047
|
updateFilter() {
|
|
4048
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
3804
4049
|
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;
|
|
3805
4050
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
3806
4051
|
switch (this._feedType) {
|
|
3807
4052
|
case "inbox":
|
|
3808
|
-
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)
|
|
3809
|
-
this._iconElement.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)
|
|
3810
|
-
this._iconElement.updateColor(((_n = (_m = (_l = (_k = (_j = theme2.inbox) == null ? void 0 : _j.header) == null ? void 0 : _k.filters) == null ? void 0 : _l.inbox) == null ? void 0 : _m.icon) == null ? void 0 : _n.color)
|
|
4053
|
+
this._titleElement.textContent = (_a2 = (_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) != null ? _a2 : "Inbox";
|
|
4054
|
+
this._iconElement.updateSVG((_b2 = (_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) != null ? _b2 : CourierIconSVGs.inbox);
|
|
4055
|
+
this._iconElement.updateColor((_c2 = (_n = (_m = (_l = (_k = (_j = theme2.inbox) == null ? void 0 : _j.header) == null ? void 0 : _k.filters) == null ? void 0 : _l.inbox) == null ? void 0 : _m.icon) == null ? void 0 : _n.color) != null ? _c2 : "red");
|
|
3811
4056
|
break;
|
|
3812
4057
|
case "archive":
|
|
3813
|
-
this._titleElement.textContent = ((_r = (_q = (_p = (_o = theme2.inbox) == null ? void 0 : _o.header) == null ? void 0 : _p.filters) == null ? void 0 : _q.archive) == null ? void 0 : _r.text)
|
|
3814
|
-
this._iconElement.updateSVG(((_w = (_v = (_u = (_t = (_s = theme2.inbox) == null ? void 0 : _s.header) == null ? void 0 : _t.filters) == null ? void 0 : _u.archive) == null ? void 0 : _v.icon) == null ? void 0 : _w.svg)
|
|
3815
|
-
this._iconElement.updateColor(((_B = (_A = (_z = (_y = (_x = theme2.inbox) == null ? void 0 : _x.header) == null ? void 0 : _y.filters) == null ? void 0 : _z.archive) == null ? void 0 : _A.icon) == null ? void 0 : _B.color)
|
|
4058
|
+
this._titleElement.textContent = (_d2 = (_r = (_q = (_p = (_o = theme2.inbox) == null ? void 0 : _o.header) == null ? void 0 : _p.filters) == null ? void 0 : _q.archive) == null ? void 0 : _r.text) != null ? _d2 : "Archive";
|
|
4059
|
+
this._iconElement.updateSVG((_e2 = (_w = (_v = (_u = (_t = (_s = theme2.inbox) == null ? void 0 : _s.header) == null ? void 0 : _t.filters) == null ? void 0 : _u.archive) == null ? void 0 : _v.icon) == null ? void 0 : _w.svg) != null ? _e2 : CourierIconSVGs.archive);
|
|
4060
|
+
this._iconElement.updateColor((_f2 = (_B = (_A = (_z = (_y = (_x = theme2.inbox) == null ? void 0 : _x.header) == null ? void 0 : _y.filters) == null ? void 0 : _z.archive) == null ? void 0 : _A.icon) == null ? void 0 : _B.color) != null ? _f2 : "red");
|
|
3816
4061
|
break;
|
|
3817
4062
|
}
|
|
3818
4063
|
}
|
|
@@ -3821,9 +4066,7 @@ class CourierInboxHeaderTitle extends HTMLElement {
|
|
|
3821
4066
|
this._themeSubscription.unsubscribe();
|
|
3822
4067
|
}
|
|
3823
4068
|
}
|
|
3824
|
-
|
|
3825
|
-
customElements.define("courier-inbox-header-title", CourierInboxHeaderTitle);
|
|
3826
|
-
}
|
|
4069
|
+
registerElement("courier-inbox-header-title", CourierInboxHeaderTitle);
|
|
3827
4070
|
class CourierInboxHeader extends CourierElement {
|
|
3828
4071
|
constructor(props) {
|
|
3829
4072
|
super();
|
|
@@ -3842,20 +4085,21 @@ class CourierInboxHeader extends CourierElement {
|
|
|
3842
4085
|
}
|
|
3843
4086
|
// Menu options
|
|
3844
4087
|
getFilterOptions() {
|
|
4088
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2;
|
|
3845
4089
|
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;
|
|
3846
4090
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
3847
4091
|
const filterMenu = (_c = (_b = (_a = theme2.inbox) == null ? void 0 : _a.header) == null ? void 0 : _b.menus) == null ? void 0 : _c.filters;
|
|
3848
4092
|
return [
|
|
3849
4093
|
{
|
|
3850
4094
|
id: "inbox",
|
|
3851
|
-
text: ((_d = filterMenu == null ? void 0 : filterMenu.inbox) == null ? void 0 : _d.text)
|
|
4095
|
+
text: (_a2 = (_d = filterMenu == null ? void 0 : filterMenu.inbox) == null ? void 0 : _d.text) != null ? _a2 : "Inbox",
|
|
3852
4096
|
icon: {
|
|
3853
|
-
color: ((_f = (_e = filterMenu == null ? void 0 : filterMenu.inbox) == null ? void 0 : _e.icon) == null ? void 0 : _f.color)
|
|
3854
|
-
svg: ((_h = (_g = filterMenu == null ? void 0 : filterMenu.inbox) == null ? void 0 : _g.icon) == null ? void 0 : _h.svg)
|
|
4097
|
+
color: (_b2 = (_f = (_e = filterMenu == null ? void 0 : filterMenu.inbox) == null ? void 0 : _e.icon) == null ? void 0 : _f.color) != null ? _b2 : "red",
|
|
4098
|
+
svg: (_c2 = (_h = (_g = filterMenu == null ? void 0 : filterMenu.inbox) == null ? void 0 : _g.icon) == null ? void 0 : _h.svg) != null ? _c2 : CourierIconSVGs.inbox
|
|
3855
4099
|
},
|
|
3856
4100
|
selectionIcon: {
|
|
3857
|
-
color: ((_n = (_m = (_l = (_k = (_j = (_i = theme2.inbox) == null ? void 0 : _i.header) == null ? void 0 : _j.menus) == null ? void 0 : _k.popup) == null ? void 0 : _l.list) == null ? void 0 : _m.selectionIcon) == null ? void 0 : _n.color)
|
|
3858
|
-
svg: ((_t = (_s = (_r = (_q = (_p = (_o = theme2.inbox) == null ? void 0 : _o.header) == null ? void 0 : _p.menus) == null ? void 0 : _q.popup) == null ? void 0 : _r.list) == null ? void 0 : _s.selectionIcon) == null ? void 0 : _t.svg)
|
|
4101
|
+
color: (_d2 = (_n = (_m = (_l = (_k = (_j = (_i = theme2.inbox) == null ? void 0 : _i.header) == null ? void 0 : _j.menus) == null ? void 0 : _k.popup) == null ? void 0 : _l.list) == null ? void 0 : _m.selectionIcon) == null ? void 0 : _n.color) != null ? _d2 : "red",
|
|
4102
|
+
svg: (_e2 = (_t = (_s = (_r = (_q = (_p = (_o = theme2.inbox) == null ? void 0 : _o.header) == null ? void 0 : _p.menus) == null ? void 0 : _q.popup) == null ? void 0 : _r.list) == null ? void 0 : _s.selectionIcon) == null ? void 0 : _t.svg) != null ? _e2 : CourierIconSVGs.check
|
|
3859
4103
|
},
|
|
3860
4104
|
onClick: (option) => {
|
|
3861
4105
|
this.handleOptionMenuItemClick("inbox", option);
|
|
@@ -3863,14 +4107,14 @@ class CourierInboxHeader extends CourierElement {
|
|
|
3863
4107
|
},
|
|
3864
4108
|
{
|
|
3865
4109
|
id: "archive",
|
|
3866
|
-
text: ((_u = filterMenu == null ? void 0 : filterMenu.archive) == null ? void 0 : _u.text)
|
|
4110
|
+
text: (_f2 = (_u = filterMenu == null ? void 0 : filterMenu.archive) == null ? void 0 : _u.text) != null ? _f2 : "Archive",
|
|
3867
4111
|
icon: {
|
|
3868
|
-
color: ((_w = (_v = filterMenu == null ? void 0 : filterMenu.archive) == null ? void 0 : _v.icon) == null ? void 0 : _w.color)
|
|
3869
|
-
svg: ((_y = (_x = filterMenu == null ? void 0 : filterMenu.archive) == null ? void 0 : _x.icon) == null ? void 0 : _y.svg)
|
|
4112
|
+
color: (_g2 = (_w = (_v = filterMenu == null ? void 0 : filterMenu.archive) == null ? void 0 : _v.icon) == null ? void 0 : _w.color) != null ? _g2 : "red",
|
|
4113
|
+
svg: (_h2 = (_y = (_x = filterMenu == null ? void 0 : filterMenu.archive) == null ? void 0 : _x.icon) == null ? void 0 : _y.svg) != null ? _h2 : CourierIconSVGs.archive
|
|
3870
4114
|
},
|
|
3871
4115
|
selectionIcon: {
|
|
3872
|
-
color: ((_E = (_D = (_C = (_B = (_A = (_z = theme2.inbox) == null ? void 0 : _z.header) == null ? void 0 : _A.menus) == null ? void 0 : _B.popup) == null ? void 0 : _C.list) == null ? void 0 : _D.selectionIcon) == null ? void 0 : _E.color)
|
|
3873
|
-
svg: ((_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.selectionIcon) == null ? void 0 : _K.svg)
|
|
4116
|
+
color: (_i2 = (_E = (_D = (_C = (_B = (_A = (_z = theme2.inbox) == null ? void 0 : _z.header) == null ? void 0 : _A.menus) == null ? void 0 : _B.popup) == null ? void 0 : _C.list) == null ? void 0 : _D.selectionIcon) == null ? void 0 : _E.color) != null ? _i2 : "red",
|
|
4117
|
+
svg: (_j2 = (_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.selectionIcon) == null ? void 0 : _K.svg) != null ? _j2 : CourierIconSVGs.check
|
|
3874
4118
|
},
|
|
3875
4119
|
onClick: (option) => {
|
|
3876
4120
|
this.handleOptionMenuItemClick("archive", option);
|
|
@@ -3879,16 +4123,17 @@ class CourierInboxHeader extends CourierElement {
|
|
|
3879
4123
|
];
|
|
3880
4124
|
}
|
|
3881
4125
|
getActionOptions() {
|
|
4126
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
|
|
3882
4127
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
3883
4128
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
3884
4129
|
const actionMenu = (_c = (_b = (_a = theme2.inbox) == null ? void 0 : _a.header) == null ? void 0 : _b.menus) == null ? void 0 : _c.actions;
|
|
3885
4130
|
return [
|
|
3886
4131
|
{
|
|
3887
4132
|
id: "markAllRead",
|
|
3888
|
-
text: ((_d = actionMenu == null ? void 0 : actionMenu.markAllRead) == null ? void 0 : _d.text)
|
|
4133
|
+
text: (_a2 = (_d = actionMenu == null ? void 0 : actionMenu.markAllRead) == null ? void 0 : _d.text) != null ? _a2 : "Mark All as Read",
|
|
3889
4134
|
icon: {
|
|
3890
|
-
color: ((_f = (_e = actionMenu == null ? void 0 : actionMenu.markAllRead) == null ? void 0 : _e.icon) == null ? void 0 : _f.color)
|
|
3891
|
-
svg: ((_h = (_g = actionMenu == null ? void 0 : actionMenu.markAllRead) == null ? void 0 : _g.icon) == null ? void 0 : _h.svg)
|
|
4135
|
+
color: (_b2 = (_f = (_e = actionMenu == null ? void 0 : actionMenu.markAllRead) == null ? void 0 : _e.icon) == null ? void 0 : _f.color) != null ? _b2 : "red",
|
|
4136
|
+
svg: (_c2 = (_h = (_g = actionMenu == null ? void 0 : actionMenu.markAllRead) == null ? void 0 : _g.icon) == null ? void 0 : _h.svg) != null ? _c2 : CourierIconSVGs.inbox
|
|
3892
4137
|
},
|
|
3893
4138
|
selectionIcon: null,
|
|
3894
4139
|
onClick: (_) => {
|
|
@@ -3897,10 +4142,10 @@ class CourierInboxHeader extends CourierElement {
|
|
|
3897
4142
|
},
|
|
3898
4143
|
{
|
|
3899
4144
|
id: "archiveAll",
|
|
3900
|
-
text: ((_i = actionMenu == null ? void 0 : actionMenu.archiveAll) == null ? void 0 : _i.text)
|
|
4145
|
+
text: (_d2 = (_i = actionMenu == null ? void 0 : actionMenu.archiveAll) == null ? void 0 : _i.text) != null ? _d2 : "Archive All",
|
|
3901
4146
|
icon: {
|
|
3902
|
-
color: ((_k = (_j = actionMenu == null ? void 0 : actionMenu.archiveAll) == null ? void 0 : _j.icon) == null ? void 0 : _k.color)
|
|
3903
|
-
svg: ((_m = (_l = actionMenu == null ? void 0 : actionMenu.archiveAll) == null ? void 0 : _l.icon) == null ? void 0 : _m.svg)
|
|
4147
|
+
color: (_e2 = (_k = (_j = actionMenu == null ? void 0 : actionMenu.archiveAll) == null ? void 0 : _j.icon) == null ? void 0 : _k.color) != null ? _e2 : "red",
|
|
4148
|
+
svg: (_f2 = (_m = (_l = actionMenu == null ? void 0 : actionMenu.archiveAll) == null ? void 0 : _l.icon) == null ? void 0 : _m.svg) != null ? _f2 : CourierIconSVGs.archive
|
|
3904
4149
|
},
|
|
3905
4150
|
selectionIcon: null,
|
|
3906
4151
|
onClick: (_) => {
|
|
@@ -3909,10 +4154,10 @@ class CourierInboxHeader extends CourierElement {
|
|
|
3909
4154
|
},
|
|
3910
4155
|
{
|
|
3911
4156
|
id: "archiveRead",
|
|
3912
|
-
text: ((_n = actionMenu == null ? void 0 : actionMenu.archiveRead) == null ? void 0 : _n.text)
|
|
4157
|
+
text: (_g2 = (_n = actionMenu == null ? void 0 : actionMenu.archiveRead) == null ? void 0 : _n.text) != null ? _g2 : "Archive Read",
|
|
3913
4158
|
icon: {
|
|
3914
|
-
color: ((_p = (_o = actionMenu == null ? void 0 : actionMenu.archiveRead) == null ? void 0 : _o.icon) == null ? void 0 : _p.color)
|
|
3915
|
-
svg: ((_r = (_q = actionMenu == null ? void 0 : actionMenu.archiveRead) == null ? void 0 : _q.icon) == null ? void 0 : _r.svg)
|
|
4159
|
+
color: (_h2 = (_p = (_o = actionMenu == null ? void 0 : actionMenu.archiveRead) == null ? void 0 : _o.icon) == null ? void 0 : _p.color) != null ? _h2 : "red",
|
|
4160
|
+
svg: (_i2 = (_r = (_q = actionMenu == null ? void 0 : actionMenu.archiveRead) == null ? void 0 : _q.icon) == null ? void 0 : _r.svg) != null ? _i2 : CourierIconSVGs.archive
|
|
3916
4161
|
},
|
|
3917
4162
|
selectionIcon: null,
|
|
3918
4163
|
onClick: (_) => {
|
|
@@ -3925,12 +4170,13 @@ class CourierInboxHeader extends CourierElement {
|
|
|
3925
4170
|
return ["icon", "title", "feed-type"];
|
|
3926
4171
|
}
|
|
3927
4172
|
refreshTheme() {
|
|
4173
|
+
var _a2, _b2;
|
|
3928
4174
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
3929
4175
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
3930
4176
|
const header = (_a = this.shadow) == null ? void 0 : _a.querySelector(".courier-inbox-header");
|
|
3931
4177
|
if (header) {
|
|
3932
|
-
header.style.backgroundColor = ((_c = (_b = theme2.inbox) == null ? void 0 : _b.header) == null ? void 0 : _c.backgroundColor)
|
|
3933
|
-
header.style.boxShadow = ((_e = (_d = theme2.inbox) == null ? void 0 : _d.header) == null ? void 0 : _e.shadow)
|
|
4178
|
+
header.style.backgroundColor = (_a2 = (_c = (_b = theme2.inbox) == null ? void 0 : _b.header) == null ? void 0 : _c.backgroundColor) != null ? _a2 : CourierColors.white[500];
|
|
4179
|
+
header.style.boxShadow = (_b2 = (_e = (_d = theme2.inbox) == null ? void 0 : _d.header) == null ? void 0 : _e.shadow) != null ? _b2 : `0px 1px 0px 0px ${CourierColors.gray[500]}`;
|
|
3934
4180
|
}
|
|
3935
4181
|
(_f = this._filterMenu) == null ? void 0 : _f.setOptions(this.getFilterOptions());
|
|
3936
4182
|
(_g = this._actionMenu) == null ? void 0 : _g.setOptions(this.getActionOptions());
|
|
@@ -4025,9 +4271,7 @@ class CourierInboxHeader extends CourierElement {
|
|
|
4025
4271
|
this._themeSubscription.unsubscribe();
|
|
4026
4272
|
}
|
|
4027
4273
|
}
|
|
4028
|
-
|
|
4029
|
-
customElements.define("courier-inbox-header", CourierInboxHeader);
|
|
4030
|
-
}
|
|
4274
|
+
registerElement("courier-inbox-header", CourierInboxHeader);
|
|
4031
4275
|
class CourierInboxDataStoreListener {
|
|
4032
4276
|
constructor(events) {
|
|
4033
4277
|
__publicField(this, "events");
|
|
@@ -4803,7 +5047,7 @@ class CourierInboxThemeManager {
|
|
|
4803
5047
|
this._subscriptions = [];
|
|
4804
5048
|
}
|
|
4805
5049
|
}
|
|
4806
|
-
let CourierInbox$1 = class CourierInbox extends
|
|
5050
|
+
let CourierInbox$1 = class CourierInbox extends BaseElement {
|
|
4807
5051
|
constructor(themeManager) {
|
|
4808
5052
|
var _a;
|
|
4809
5053
|
super();
|
|
@@ -4826,7 +5070,7 @@ let CourierInbox$1 = class CourierInbox extends HTMLElement {
|
|
|
4826
5070
|
height: "768px"
|
|
4827
5071
|
});
|
|
4828
5072
|
this._shadow = this.attachShadow({ mode: "open" });
|
|
4829
|
-
this._themeManager = themeManager
|
|
5073
|
+
this._themeManager = themeManager != null ? themeManager : new CourierInboxThemeManager(defaultLightTheme);
|
|
4830
5074
|
this._header = new CourierInboxHeader({
|
|
4831
5075
|
themeManager: this._themeManager,
|
|
4832
5076
|
onFeedTypeChange: (feedType) => {
|
|
@@ -5103,9 +5347,7 @@ let CourierInbox$1 = class CourierInbox extends HTMLElement {
|
|
|
5103
5347
|
}
|
|
5104
5348
|
}
|
|
5105
5349
|
};
|
|
5106
|
-
|
|
5107
|
-
customElements.define("courier-inbox", CourierInbox$1);
|
|
5108
|
-
}
|
|
5350
|
+
registerElement("courier-inbox", CourierInbox$1);
|
|
5109
5351
|
class CourierInboxMenuButton extends CourierElement {
|
|
5110
5352
|
constructor(themeBus) {
|
|
5111
5353
|
super();
|
|
@@ -5156,23 +5398,22 @@ class CourierInboxMenuButton extends CourierElement {
|
|
|
5156
5398
|
this.updateTheme();
|
|
5157
5399
|
}
|
|
5158
5400
|
updateTheme() {
|
|
5401
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
5159
5402
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
5160
5403
|
const theme2 = this._themeSubscription.manager.getTheme();
|
|
5161
|
-
(_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)
|
|
5162
|
-
(_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)
|
|
5163
|
-
(_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)
|
|
5164
|
-
(_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)
|
|
5165
|
-
(_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)
|
|
5404
|
+
(_d = this._triggerButton) == null ? void 0 : _d.updateIconColor((_a2 = (_c = (_b = (_a = theme2 == null ? void 0 : theme2.popup) == null ? void 0 : _a.button) == null ? void 0 : _b.icon) == null ? void 0 : _c.color) != null ? _a2 : CourierColors.black[500]);
|
|
5405
|
+
(_h = this._triggerButton) == null ? void 0 : _h.updateIconSVG((_b2 = (_g = (_f = (_e = theme2 == null ? void 0 : theme2.popup) == null ? void 0 : _e.button) == null ? void 0 : _f.icon) == null ? void 0 : _g.svg) != null ? _b2 : CourierIconSVGs.inbox);
|
|
5406
|
+
(_k = this._triggerButton) == null ? void 0 : _k.updateBackgroundColor((_c2 = (_j = (_i = theme2 == null ? void 0 : theme2.popup) == null ? void 0 : _i.button) == null ? void 0 : _j.backgroundColor) != null ? _c2 : "transparent");
|
|
5407
|
+
(_n = this._triggerButton) == null ? void 0 : _n.updateHoverBackgroundColor((_d2 = (_m = (_l = theme2 == null ? void 0 : theme2.popup) == null ? void 0 : _l.button) == null ? void 0 : _m.hoverBackgroundColor) != null ? _d2 : CourierColors.black[50010]);
|
|
5408
|
+
(_q = this._triggerButton) == null ? void 0 : _q.updateActiveBackgroundColor((_e2 = (_p = (_o = theme2 == null ? void 0 : theme2.popup) == null ? void 0 : _o.button) == null ? void 0 : _p.activeBackgroundColor) != null ? _e2 : CourierColors.black[50020]);
|
|
5166
5409
|
(_r = this._unreadCountBadge) == null ? void 0 : _r.refreshTheme("button");
|
|
5167
5410
|
}
|
|
5168
5411
|
disconnectedCallback() {
|
|
5169
5412
|
this._themeSubscription.unsubscribe();
|
|
5170
5413
|
}
|
|
5171
5414
|
}
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
}
|
|
5175
|
-
let CourierInboxMenu$1 = class CourierInboxMenu extends HTMLElement {
|
|
5415
|
+
registerElement("courier-inbox-menu-button", CourierInboxMenuButton);
|
|
5416
|
+
let CourierInboxPopupMenu$1 = class CourierInboxPopupMenu extends BaseElement {
|
|
5176
5417
|
constructor() {
|
|
5177
5418
|
super();
|
|
5178
5419
|
__publicField(this, "_width", "440px");
|
|
@@ -5227,6 +5468,7 @@ let CourierInboxMenu$1 = class CourierInboxMenu extends HTMLElement {
|
|
|
5227
5468
|
this._style.textContent = this.getStyles();
|
|
5228
5469
|
}
|
|
5229
5470
|
getStyles() {
|
|
5471
|
+
var _a2, _b2, _c2, _d2;
|
|
5230
5472
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5231
5473
|
return `
|
|
5232
5474
|
:host {
|
|
@@ -5242,10 +5484,10 @@ let CourierInboxMenu$1 = class CourierInboxMenu extends HTMLElement {
|
|
|
5242
5484
|
.popup {
|
|
5243
5485
|
display: none;
|
|
5244
5486
|
position: absolute;
|
|
5245
|
-
background: ${((_b = (_a = this.theme.popup) == null ? void 0 : _a.window) == null ? void 0 : _b.backgroundColor)
|
|
5246
|
-
border-radius: ${((_d = (_c = this.theme.popup) == null ? void 0 : _c.window) == null ? void 0 : _d.borderRadius)
|
|
5247
|
-
border: ${((_f = (_e = this.theme.popup) == null ? void 0 : _e.window) == null ? void 0 : _f.border)
|
|
5248
|
-
box-shadow: ${((_h = (_g = this.theme.popup) == null ? void 0 : _g.window) == null ? void 0 : _h.shadow)
|
|
5487
|
+
background: ${(_a2 = (_b = (_a = this.theme.popup) == null ? void 0 : _a.window) == null ? void 0 : _b.backgroundColor) != null ? _a2 : "red"};
|
|
5488
|
+
border-radius: ${(_b2 = (_d = (_c = this.theme.popup) == null ? void 0 : _c.window) == null ? void 0 : _d.borderRadius) != null ? _b2 : "8px"};
|
|
5489
|
+
border: ${(_c2 = (_f = (_e = this.theme.popup) == null ? void 0 : _e.window) == null ? void 0 : _f.border) != null ? _c2 : `1px solid red`};
|
|
5490
|
+
box-shadow: ${(_d2 = (_h = (_g = this.theme.popup) == null ? void 0 : _g.window) == null ? void 0 : _h.shadow) != null ? _d2 : `0px 8px 16px -4px red`};
|
|
5249
5491
|
z-index: 1000;
|
|
5250
5492
|
width: ${this._width};
|
|
5251
5493
|
height: ${this._height};
|
|
@@ -5472,9 +5714,7 @@ let CourierInboxMenu$1 = class CourierInboxMenu extends HTMLElement {
|
|
|
5472
5714
|
this._themeManager.cleanup();
|
|
5473
5715
|
}
|
|
5474
5716
|
};
|
|
5475
|
-
|
|
5476
|
-
customElements.define("courier-inbox-menu", CourierInboxMenu$1);
|
|
5477
|
-
}
|
|
5717
|
+
registerElement("courier-inbox-popup-menu", CourierInboxPopupMenu$1);
|
|
5478
5718
|
const useCourier = () => {
|
|
5479
5719
|
const signIn = (props) => Courier.shared.signIn(props);
|
|
5480
5720
|
const signOut = () => Courier.shared.signOut();
|
|
@@ -5890,6 +6130,19 @@ function render(node, container) {
|
|
|
5890
6130
|
const root = createRoot(container);
|
|
5891
6131
|
return root.render(node);
|
|
5892
6132
|
}
|
|
6133
|
+
const CourierClientComponent = ({ children }) => {
|
|
6134
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
6135
|
+
useEffect(() => {
|
|
6136
|
+
setIsMounted(true);
|
|
6137
|
+
}, []);
|
|
6138
|
+
if (typeof window === "undefined") {
|
|
6139
|
+
return null;
|
|
6140
|
+
}
|
|
6141
|
+
if (!isMounted) {
|
|
6142
|
+
return null;
|
|
6143
|
+
}
|
|
6144
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children });
|
|
6145
|
+
};
|
|
5893
6146
|
const CourierInbox2 = (props) => {
|
|
5894
6147
|
const inboxRef = useRef(null);
|
|
5895
6148
|
useEffect(() => {
|
|
@@ -5974,21 +6227,18 @@ const CourierInbox2 = (props) => {
|
|
|
5974
6227
|
inbox.setFeedType(props.feedType || "inbox");
|
|
5975
6228
|
});
|
|
5976
6229
|
}, [props.feedType, inboxRef]);
|
|
5977
|
-
return (
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
}
|
|
5988
|
-
)
|
|
5989
|
-
);
|
|
6230
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(CourierClientComponent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6231
|
+
"courier-inbox",
|
|
6232
|
+
{
|
|
6233
|
+
ref: inboxRef,
|
|
6234
|
+
height: props.height,
|
|
6235
|
+
"light-theme": props.lightTheme ? JSON.stringify(props.lightTheme) : void 0,
|
|
6236
|
+
"dark-theme": props.darkTheme ? JSON.stringify(props.darkTheme) : void 0,
|
|
6237
|
+
mode: props.mode
|
|
6238
|
+
}
|
|
6239
|
+
) });
|
|
5990
6240
|
};
|
|
5991
|
-
const
|
|
6241
|
+
const CourierInboxPopupMenu2 = (props) => {
|
|
5992
6242
|
const menuRef = useRef(null);
|
|
5993
6243
|
useEffect(() => {
|
|
5994
6244
|
const menu = menuRef.current;
|
|
@@ -6082,29 +6332,26 @@ const CourierInboxMenu2 = (props) => {
|
|
|
6082
6332
|
menu.setFeedType(props.feedType || "inbox");
|
|
6083
6333
|
});
|
|
6084
6334
|
}, [props.feedType, menuRef]);
|
|
6085
|
-
return (
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
}
|
|
6102
|
-
)
|
|
6103
|
-
);
|
|
6335
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(CourierClientComponent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6336
|
+
"courier-inbox-popup-menu",
|
|
6337
|
+
{
|
|
6338
|
+
ref: menuRef,
|
|
6339
|
+
"popup-alignment": props.popupAlignment,
|
|
6340
|
+
"popup-width": props.popupWidth,
|
|
6341
|
+
"popup-height": props.popupHeight,
|
|
6342
|
+
left: props.left,
|
|
6343
|
+
top: props.top,
|
|
6344
|
+
right: props.right,
|
|
6345
|
+
bottom: props.bottom,
|
|
6346
|
+
"light-theme": props.lightTheme ? JSON.stringify(props.lightTheme) : void 0,
|
|
6347
|
+
"dark-theme": props.darkTheme ? JSON.stringify(props.darkTheme) : void 0,
|
|
6348
|
+
mode: props.mode
|
|
6349
|
+
}
|
|
6350
|
+
) });
|
|
6104
6351
|
};
|
|
6105
6352
|
export {
|
|
6106
6353
|
CourierInbox2 as CourierInbox,
|
|
6107
|
-
|
|
6354
|
+
CourierInboxPopupMenu2 as CourierInboxPopupMenu,
|
|
6108
6355
|
useCourier
|
|
6109
6356
|
};
|
|
6110
6357
|
//# sourceMappingURL=index.mjs.map
|