@trycourier/courier-ui-inbox 1.0.8-beta → 1.0.11-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +374 -0
- package/dist/components/courier-inbox-list-item.d.ts +3 -1
- package/dist/components/courier-inbox-list.d.ts +5 -0
- package/dist/components/courier-inbox-popup-menu.d.ts +14 -9
- package/dist/components/courier-inbox.d.ts +2 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +175 -115
- package/dist/index.mjs.map +1 -1
- package/dist/types/courier-inbox-theme-manager.d.ts +1 -0
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { Courier, InboxMessageEvent } from "@trycourier/courier-js";
|
|
5
|
+
import { Courier as Courier2 } from "@trycourier/courier-js";
|
|
5
6
|
var __defProp2 = Object.defineProperty;
|
|
6
7
|
var __typeError = (msg) => {
|
|
7
8
|
throw TypeError(msg);
|
|
@@ -156,29 +157,35 @@ const baseButtonStyles = {
|
|
|
156
157
|
fontSize: "14px"
|
|
157
158
|
};
|
|
158
159
|
const CourierButtonVariants = {
|
|
159
|
-
primary: (mode) =>
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
160
|
+
primary: (mode) => {
|
|
161
|
+
return {
|
|
162
|
+
...baseButtonStyles,
|
|
163
|
+
backgroundColor: theme[mode].colors.primary,
|
|
164
|
+
textColor: theme[mode].colors.secondary,
|
|
165
|
+
fontWeight: "500",
|
|
166
|
+
shadow: "none"
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
secondary: (mode) => {
|
|
170
|
+
return {
|
|
171
|
+
...baseButtonStyles,
|
|
172
|
+
backgroundColor: theme[mode].colors.secondary,
|
|
173
|
+
textColor: theme[mode].colors.primary,
|
|
174
|
+
fontWeight: "500",
|
|
175
|
+
border: `1px solid ${theme[mode].colors.border}`,
|
|
176
|
+
shadow: mode === "light" ? "0px 1px 2px 0px rgba(0, 0, 0, 0.06)" : "0px 1px 2px 0px rgba(255, 255, 255, 0.1)"
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
tertiary: (mode) => {
|
|
180
|
+
return {
|
|
181
|
+
...baseButtonStyles,
|
|
182
|
+
backgroundColor: theme[mode].colors.border,
|
|
183
|
+
textColor: theme[mode].colors.primary,
|
|
184
|
+
fontWeight: "500",
|
|
185
|
+
border: "none",
|
|
186
|
+
shadow: "none"
|
|
187
|
+
};
|
|
188
|
+
}
|
|
182
189
|
};
|
|
183
190
|
class CourierButton extends CourierSystemThemeElement {
|
|
184
191
|
constructor(props) {
|
|
@@ -205,32 +212,33 @@ class CourierButton extends CourierSystemThemeElement {
|
|
|
205
212
|
return "courier-button";
|
|
206
213
|
}
|
|
207
214
|
getStyles(props) {
|
|
215
|
+
const mode = props.mode === "system" ? this.currentSystemTheme : props.mode;
|
|
208
216
|
const defaultTextColor = () => {
|
|
209
|
-
const secondary = CourierButtonVariants.secondary(
|
|
217
|
+
const secondary = CourierButtonVariants.secondary(mode);
|
|
210
218
|
return secondary.textColor;
|
|
211
219
|
};
|
|
212
220
|
const defaultBackgroundColor = () => {
|
|
213
|
-
const secondary = CourierButtonVariants.secondary(
|
|
221
|
+
const secondary = CourierButtonVariants.secondary(mode);
|
|
214
222
|
return secondary.backgroundColor;
|
|
215
223
|
};
|
|
216
224
|
const defaultBorder = () => {
|
|
217
|
-
const secondary = CourierButtonVariants.secondary(
|
|
225
|
+
const secondary = CourierButtonVariants.secondary(mode);
|
|
218
226
|
return secondary.border;
|
|
219
227
|
};
|
|
220
228
|
const defaultShadow = () => {
|
|
221
|
-
const secondary = CourierButtonVariants.secondary(
|
|
229
|
+
const secondary = CourierButtonVariants.secondary(mode);
|
|
222
230
|
return secondary.shadow;
|
|
223
231
|
};
|
|
224
232
|
const defaultBorderRadius = () => {
|
|
225
|
-
const secondary = CourierButtonVariants.secondary(
|
|
233
|
+
const secondary = CourierButtonVariants.secondary(mode);
|
|
226
234
|
return secondary.borderRadius;
|
|
227
235
|
};
|
|
228
236
|
const defaultFontSize = () => {
|
|
229
|
-
const secondary = CourierButtonVariants.secondary(
|
|
237
|
+
const secondary = CourierButtonVariants.secondary(mode);
|
|
230
238
|
return secondary.fontSize;
|
|
231
239
|
};
|
|
232
240
|
const defaultFontWeight = () => {
|
|
233
|
-
const secondary = CourierButtonVariants.secondary(
|
|
241
|
+
const secondary = CourierButtonVariants.secondary(mode);
|
|
234
242
|
return secondary.fontWeight;
|
|
235
243
|
};
|
|
236
244
|
return `
|
|
@@ -556,14 +564,13 @@ class CourierInfoState extends CourierFactoryElement {
|
|
|
556
564
|
__publicField2(this, "_title");
|
|
557
565
|
__publicField2(this, "_button");
|
|
558
566
|
__publicField2(this, "_style");
|
|
559
|
-
__publicField2(this, "_buttonClickCallback", null);
|
|
560
567
|
this._props = props;
|
|
561
568
|
}
|
|
562
569
|
static get id() {
|
|
563
570
|
return "courier-info-state";
|
|
564
571
|
}
|
|
565
572
|
defaultElement() {
|
|
566
|
-
var _a
|
|
573
|
+
var _a;
|
|
567
574
|
const container = document.createElement("div");
|
|
568
575
|
this._title = document.createElement("h2");
|
|
569
576
|
if ((_a = this._props.title) == null ? void 0 : _a.text) {
|
|
@@ -577,11 +584,6 @@ class CourierInfoState extends CourierFactoryElement {
|
|
|
577
584
|
container.appendChild(this._title);
|
|
578
585
|
container.appendChild(this._button);
|
|
579
586
|
this.appendChild(container);
|
|
580
|
-
(_b = this._button) == null ? void 0 : _b.addEventListener("click", () => {
|
|
581
|
-
if (this._buttonClickCallback) {
|
|
582
|
-
this._buttonClickCallback();
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
587
|
return container;
|
|
586
588
|
}
|
|
587
589
|
onSystemThemeChange(_) {
|
|
@@ -628,9 +630,6 @@ class CourierInfoState extends CourierFactoryElement {
|
|
|
628
630
|
this._button.updateButton(props.button);
|
|
629
631
|
}
|
|
630
632
|
}
|
|
631
|
-
setButtonClickCallback(callback) {
|
|
632
|
-
this._buttonClickCallback = callback;
|
|
633
|
-
}
|
|
634
633
|
}
|
|
635
634
|
class CourierIconButton extends CourierBaseElement {
|
|
636
635
|
constructor(svg, color, backgroundColor, hoverBackgroundColor, activeBackgroundColor, borderRadius, height, width) {
|
|
@@ -1579,9 +1578,10 @@ const _CourierInboxDatastore = class _CourierInboxDatastore {
|
|
|
1579
1578
|
__publicField(_CourierInboxDatastore, "instance");
|
|
1580
1579
|
let CourierInboxDatastore = _CourierInboxDatastore;
|
|
1581
1580
|
class CourierInboxListItem extends CourierBaseElement {
|
|
1582
|
-
constructor(
|
|
1581
|
+
constructor(themeManager) {
|
|
1583
1582
|
super();
|
|
1584
1583
|
// State
|
|
1584
|
+
__publicField(this, "_themeManager");
|
|
1585
1585
|
__publicField(this, "_theme");
|
|
1586
1586
|
__publicField(this, "_message", null);
|
|
1587
1587
|
__publicField(this, "_feedType", "inbox");
|
|
@@ -1600,7 +1600,8 @@ class CourierInboxListItem extends CourierBaseElement {
|
|
|
1600
1600
|
__publicField(this, "onItemClick", null);
|
|
1601
1601
|
__publicField(this, "onItemLongPress", null);
|
|
1602
1602
|
__publicField(this, "onItemActionClick", null);
|
|
1603
|
-
this.
|
|
1603
|
+
this._themeManager = themeManager;
|
|
1604
|
+
this._theme = themeManager.getTheme();
|
|
1604
1605
|
this._isMobile = "ontouchstart" in window;
|
|
1605
1606
|
this.render();
|
|
1606
1607
|
}
|
|
@@ -1924,6 +1925,7 @@ class CourierInboxListItem extends CourierBaseElement {
|
|
|
1924
1925
|
this._message.actions.forEach((action) => {
|
|
1925
1926
|
var _a2, _b2, _c2, _d, _e;
|
|
1926
1927
|
const actionButton = new CourierButton({
|
|
1928
|
+
mode: this._themeManager.mode,
|
|
1927
1929
|
text: action.content,
|
|
1928
1930
|
variant: "secondary",
|
|
1929
1931
|
backgroundColor: actionsTheme == null ? void 0 : actionsTheme.backgroundColor,
|
|
@@ -2218,6 +2220,8 @@ class CourierInboxList extends CourierBaseElement {
|
|
|
2218
2220
|
__publicField(this, "_listStyles");
|
|
2219
2221
|
__publicField(this, "_listItemStyles");
|
|
2220
2222
|
__publicField(this, "_listItemMenuStyles");
|
|
2223
|
+
__publicField(this, "_errorContainer");
|
|
2224
|
+
__publicField(this, "_emptyContainer");
|
|
2221
2225
|
this._onRefresh = props.onRefresh;
|
|
2222
2226
|
this._onPaginationTrigger = props.onPaginationTrigger;
|
|
2223
2227
|
this._onMessageClick = props.onMessageClick;
|
|
@@ -2320,10 +2324,75 @@ class CourierInboxList extends CourierBaseElement {
|
|
|
2320
2324
|
handleRefresh() {
|
|
2321
2325
|
this._onRefresh();
|
|
2322
2326
|
}
|
|
2327
|
+
refreshInfoStateThemes() {
|
|
2328
|
+
var _a, _b;
|
|
2329
|
+
(_a = this._emptyContainer) == null ? void 0 : _a.updateStyles(this.errorProps);
|
|
2330
|
+
(_b = this._emptyContainer) == null ? void 0 : _b.updateStyles(this.emptyProps);
|
|
2331
|
+
}
|
|
2332
|
+
get errorProps() {
|
|
2333
|
+
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;
|
|
2334
|
+
const error = (_a = this.theme.inbox) == null ? void 0 : _a.error;
|
|
2335
|
+
const themeMode = this._themeSubscription.manager.mode;
|
|
2336
|
+
return {
|
|
2337
|
+
title: {
|
|
2338
|
+
text: ((_b = error == null ? void 0 : error.title) == null ? void 0 : _b.text) ?? ((_c = this._error) == null ? void 0 : _c.message),
|
|
2339
|
+
textColor: (_e = (_d = error == null ? void 0 : error.title) == null ? void 0 : _d.font) == null ? void 0 : _e.color,
|
|
2340
|
+
fontFamily: (_g = (_f = error == null ? void 0 : error.title) == null ? void 0 : _f.font) == null ? void 0 : _g.family,
|
|
2341
|
+
fontSize: (_i = (_h = error == null ? void 0 : error.title) == null ? void 0 : _h.font) == null ? void 0 : _i.size,
|
|
2342
|
+
fontWeight: (_k = (_j = error == null ? void 0 : error.title) == null ? void 0 : _j.font) == null ? void 0 : _k.weight
|
|
2343
|
+
},
|
|
2344
|
+
button: {
|
|
2345
|
+
mode: themeMode,
|
|
2346
|
+
text: (_l = error == null ? void 0 : error.button) == null ? void 0 : _l.text,
|
|
2347
|
+
backgroundColor: (_m = error == null ? void 0 : error.button) == null ? void 0 : _m.backgroundColor,
|
|
2348
|
+
hoverBackgroundColor: (_n = error == null ? void 0 : error.button) == null ? void 0 : _n.hoverBackgroundColor,
|
|
2349
|
+
activeBackgroundColor: (_o = error == null ? void 0 : error.button) == null ? void 0 : _o.activeBackgroundColor,
|
|
2350
|
+
textColor: (_q = (_p = error == null ? void 0 : error.button) == null ? void 0 : _p.font) == null ? void 0 : _q.color,
|
|
2351
|
+
fontFamily: (_s = (_r = error == null ? void 0 : error.button) == null ? void 0 : _r.font) == null ? void 0 : _s.family,
|
|
2352
|
+
fontSize: (_u = (_t = error == null ? void 0 : error.button) == null ? void 0 : _t.font) == null ? void 0 : _u.size,
|
|
2353
|
+
fontWeight: (_w = (_v = error == null ? void 0 : error.button) == null ? void 0 : _v.font) == null ? void 0 : _w.weight,
|
|
2354
|
+
shadow: (_x = error == null ? void 0 : error.button) == null ? void 0 : _x.shadow,
|
|
2355
|
+
border: (_y = error == null ? void 0 : error.button) == null ? void 0 : _y.border,
|
|
2356
|
+
borderRadius: (_z = error == null ? void 0 : error.button) == null ? void 0 : _z.borderRadius,
|
|
2357
|
+
onClick: () => this.handleRetry()
|
|
2358
|
+
}
|
|
2359
|
+
};
|
|
2360
|
+
}
|
|
2361
|
+
get emptyProps() {
|
|
2362
|
+
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;
|
|
2363
|
+
const empty = (_a = this.theme.inbox) == null ? void 0 : _a.empty;
|
|
2364
|
+
const themeMode = this._themeSubscription.manager.mode;
|
|
2365
|
+
return {
|
|
2366
|
+
title: {
|
|
2367
|
+
text: ((_b = empty == null ? void 0 : empty.title) == null ? void 0 : _b.text) ?? `No ${this._feedType} messages yet`,
|
|
2368
|
+
textColor: (_d = (_c = empty == null ? void 0 : empty.title) == null ? void 0 : _c.font) == null ? void 0 : _d.color,
|
|
2369
|
+
fontFamily: (_f = (_e = empty == null ? void 0 : empty.title) == null ? void 0 : _e.font) == null ? void 0 : _f.family,
|
|
2370
|
+
fontSize: (_h = (_g = empty == null ? void 0 : empty.title) == null ? void 0 : _g.font) == null ? void 0 : _h.size,
|
|
2371
|
+
fontWeight: (_j = (_i = empty == null ? void 0 : empty.title) == null ? void 0 : _i.font) == null ? void 0 : _j.weight
|
|
2372
|
+
},
|
|
2373
|
+
button: {
|
|
2374
|
+
mode: themeMode,
|
|
2375
|
+
text: (_k = empty == null ? void 0 : empty.button) == null ? void 0 : _k.text,
|
|
2376
|
+
backgroundColor: (_l = empty == null ? void 0 : empty.button) == null ? void 0 : _l.backgroundColor,
|
|
2377
|
+
hoverBackgroundColor: (_m = empty == null ? void 0 : empty.button) == null ? void 0 : _m.hoverBackgroundColor,
|
|
2378
|
+
activeBackgroundColor: (_n = empty == null ? void 0 : empty.button) == null ? void 0 : _n.activeBackgroundColor,
|
|
2379
|
+
textColor: (_p = (_o = empty == null ? void 0 : empty.button) == null ? void 0 : _o.font) == null ? void 0 : _p.color,
|
|
2380
|
+
fontFamily: (_r = (_q = empty == null ? void 0 : empty.button) == null ? void 0 : _q.font) == null ? void 0 : _r.family,
|
|
2381
|
+
fontSize: (_t = (_s = empty == null ? void 0 : empty.button) == null ? void 0 : _s.font) == null ? void 0 : _t.size,
|
|
2382
|
+
fontWeight: (_v = (_u = empty == null ? void 0 : empty.button) == null ? void 0 : _u.font) == null ? void 0 : _v.weight,
|
|
2383
|
+
shadow: (_w = empty == null ? void 0 : empty.button) == null ? void 0 : _w.shadow,
|
|
2384
|
+
border: (_x = empty == null ? void 0 : empty.button) == null ? void 0 : _x.border,
|
|
2385
|
+
borderRadius: (_y = empty == null ? void 0 : empty.button) == null ? void 0 : _y.borderRadius,
|
|
2386
|
+
onClick: () => this.handleRefresh()
|
|
2387
|
+
}
|
|
2388
|
+
};
|
|
2389
|
+
}
|
|
2323
2390
|
render() {
|
|
2324
|
-
var _a, _b, _c, _d
|
|
2391
|
+
var _a, _b, _c, _d;
|
|
2325
2392
|
while (this.firstChild) {
|
|
2326
2393
|
this.removeChild(this.firstChild);
|
|
2394
|
+
this._errorContainer = void 0;
|
|
2395
|
+
this._emptyContainer = void 0;
|
|
2327
2396
|
}
|
|
2328
2397
|
if (this._listStyles) {
|
|
2329
2398
|
this._listStyles.textContent = CourierInboxList.getStyles(this.theme);
|
|
@@ -2335,67 +2404,21 @@ class CourierInboxList extends CourierBaseElement {
|
|
|
2335
2404
|
this._listItemMenuStyles.textContent = CourierInboxListItemMenu.getStyles(this.theme);
|
|
2336
2405
|
}
|
|
2337
2406
|
if (this._error) {
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
text: ((_b = error == null ? void 0 : error.title) == null ? void 0 : _b.text) ?? this._error.message,
|
|
2342
|
-
textColor: (_d = (_c = error == null ? void 0 : error.title) == null ? void 0 : _c.font) == null ? void 0 : _d.color,
|
|
2343
|
-
fontFamily: (_f = (_e = error == null ? void 0 : error.title) == null ? void 0 : _e.font) == null ? void 0 : _f.family,
|
|
2344
|
-
fontSize: (_h = (_g = error == null ? void 0 : error.title) == null ? void 0 : _g.font) == null ? void 0 : _h.size,
|
|
2345
|
-
fontWeight: (_j = (_i = error == null ? void 0 : error.title) == null ? void 0 : _i.font) == null ? void 0 : _j.weight
|
|
2346
|
-
},
|
|
2347
|
-
button: {
|
|
2348
|
-
text: (_k = error == null ? void 0 : error.button) == null ? void 0 : _k.text,
|
|
2349
|
-
backgroundColor: (_l = error == null ? void 0 : error.button) == null ? void 0 : _l.backgroundColor,
|
|
2350
|
-
hoverBackgroundColor: (_m = error == null ? void 0 : error.button) == null ? void 0 : _m.hoverBackgroundColor,
|
|
2351
|
-
activeBackgroundColor: (_n = error == null ? void 0 : error.button) == null ? void 0 : _n.activeBackgroundColor,
|
|
2352
|
-
textColor: (_p = (_o = error == null ? void 0 : error.button) == null ? void 0 : _o.font) == null ? void 0 : _p.color,
|
|
2353
|
-
fontFamily: (_r = (_q = error == null ? void 0 : error.button) == null ? void 0 : _q.font) == null ? void 0 : _r.family,
|
|
2354
|
-
fontSize: (_t = (_s = error == null ? void 0 : error.button) == null ? void 0 : _s.font) == null ? void 0 : _t.size,
|
|
2355
|
-
fontWeight: (_v = (_u = error == null ? void 0 : error.button) == null ? void 0 : _u.font) == null ? void 0 : _v.weight,
|
|
2356
|
-
shadow: (_w = error == null ? void 0 : error.button) == null ? void 0 : _w.shadow,
|
|
2357
|
-
border: (_x = error == null ? void 0 : error.button) == null ? void 0 : _x.border,
|
|
2358
|
-
borderRadius: (_y = error == null ? void 0 : error.button) == null ? void 0 : _y.borderRadius
|
|
2359
|
-
}
|
|
2360
|
-
});
|
|
2361
|
-
errorElement.build((_z = this._errorStateFactory) == null ? void 0 : _z.call(this, { feedType: this._feedType, error: this._error }));
|
|
2362
|
-
errorElement.setButtonClickCallback(() => this.handleRetry());
|
|
2363
|
-
this.appendChild(errorElement);
|
|
2407
|
+
this._errorContainer = new CourierInfoState(this.errorProps);
|
|
2408
|
+
this._errorContainer.build((_a = this._errorStateFactory) == null ? void 0 : _a.call(this, { feedType: this._feedType, error: this._error }));
|
|
2409
|
+
this.appendChild(this._errorContainer);
|
|
2364
2410
|
return;
|
|
2365
2411
|
}
|
|
2366
2412
|
if (this._isLoading) {
|
|
2367
2413
|
const loadingElement = new CourierInboxSkeletonList(this.theme);
|
|
2368
|
-
loadingElement.build((
|
|
2414
|
+
loadingElement.build((_b = this._loadingStateFactory) == null ? void 0 : _b.call(this, { feedType: this._feedType }));
|
|
2369
2415
|
this.appendChild(loadingElement);
|
|
2370
2416
|
return;
|
|
2371
2417
|
}
|
|
2372
2418
|
if (this._messages.length === 0) {
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
text: ((_C = empty == null ? void 0 : empty.title) == null ? void 0 : _C.text) ?? `No ${this._feedType} messages yet`,
|
|
2377
|
-
textColor: (_E = (_D = empty == null ? void 0 : empty.title) == null ? void 0 : _D.font) == null ? void 0 : _E.color,
|
|
2378
|
-
fontFamily: (_G = (_F = empty == null ? void 0 : empty.title) == null ? void 0 : _F.font) == null ? void 0 : _G.family,
|
|
2379
|
-
fontSize: (_I = (_H = empty == null ? void 0 : empty.title) == null ? void 0 : _H.font) == null ? void 0 : _I.size,
|
|
2380
|
-
fontWeight: (_K = (_J = empty == null ? void 0 : empty.title) == null ? void 0 : _J.font) == null ? void 0 : _K.weight
|
|
2381
|
-
},
|
|
2382
|
-
button: {
|
|
2383
|
-
text: (_L = empty == null ? void 0 : empty.button) == null ? void 0 : _L.text,
|
|
2384
|
-
backgroundColor: (_M = empty == null ? void 0 : empty.button) == null ? void 0 : _M.backgroundColor,
|
|
2385
|
-
hoverBackgroundColor: (_N = empty == null ? void 0 : empty.button) == null ? void 0 : _N.hoverBackgroundColor,
|
|
2386
|
-
activeBackgroundColor: (_O = empty == null ? void 0 : empty.button) == null ? void 0 : _O.activeBackgroundColor,
|
|
2387
|
-
textColor: (_Q = (_P = empty == null ? void 0 : empty.button) == null ? void 0 : _P.font) == null ? void 0 : _Q.color,
|
|
2388
|
-
fontFamily: (_S = (_R = empty == null ? void 0 : empty.button) == null ? void 0 : _R.font) == null ? void 0 : _S.family,
|
|
2389
|
-
fontSize: (_U = (_T = empty == null ? void 0 : empty.button) == null ? void 0 : _T.font) == null ? void 0 : _U.size,
|
|
2390
|
-
fontWeight: (_W = (_V = empty == null ? void 0 : empty.button) == null ? void 0 : _V.font) == null ? void 0 : _W.weight,
|
|
2391
|
-
shadow: (_X = empty == null ? void 0 : empty.button) == null ? void 0 : _X.shadow,
|
|
2392
|
-
border: (_Y = empty == null ? void 0 : empty.button) == null ? void 0 : _Y.border,
|
|
2393
|
-
borderRadius: (_Z = empty == null ? void 0 : empty.button) == null ? void 0 : _Z.borderRadius
|
|
2394
|
-
}
|
|
2395
|
-
});
|
|
2396
|
-
emptyElement.build((__ = this._emptyStateFactory) == null ? void 0 : __.call(this, { feedType: this._feedType }));
|
|
2397
|
-
emptyElement.setButtonClickCallback(() => this.handleRefresh());
|
|
2398
|
-
this.appendChild(emptyElement);
|
|
2419
|
+
this._emptyContainer = new CourierInfoState(this.emptyProps);
|
|
2420
|
+
this._emptyContainer.build((_c = this._emptyStateFactory) == null ? void 0 : _c.call(this, { feedType: this._feedType }));
|
|
2421
|
+
this.appendChild(this._emptyContainer);
|
|
2399
2422
|
return;
|
|
2400
2423
|
}
|
|
2401
2424
|
const list = document.createElement("ul");
|
|
@@ -2405,7 +2428,7 @@ class CourierInboxList extends CourierBaseElement {
|
|
|
2405
2428
|
list.appendChild(this._listItemFactory({ message, index }));
|
|
2406
2429
|
return;
|
|
2407
2430
|
}
|
|
2408
|
-
const listItem = new CourierInboxListItem(this.
|
|
2431
|
+
const listItem = new CourierInboxListItem(this._themeSubscription.manager);
|
|
2409
2432
|
listItem.setMessage(message, this._feedType);
|
|
2410
2433
|
listItem.setOnItemClick((message2) => {
|
|
2411
2434
|
var _a2;
|
|
@@ -2424,7 +2447,7 @@ class CourierInboxList extends CourierBaseElement {
|
|
|
2424
2447
|
if (this._canPaginate) {
|
|
2425
2448
|
const paginationItem = new CourierInboxPaginationListItem({
|
|
2426
2449
|
theme: this.theme,
|
|
2427
|
-
customItem: (
|
|
2450
|
+
customItem: (_d = this._paginationItemFactory) == null ? void 0 : _d.call(this, { feedType: this._feedType }),
|
|
2428
2451
|
onPaginationTrigger: () => {
|
|
2429
2452
|
var _a2;
|
|
2430
2453
|
return (_a2 = this._onPaginationTrigger) == null ? void 0 : _a2.call(this, this._feedType);
|
|
@@ -2764,7 +2787,7 @@ class CourierUnreadCountBadge extends CourierBaseElement {
|
|
|
2764
2787
|
updateBadge() {
|
|
2765
2788
|
if (this._badge) {
|
|
2766
2789
|
if (this._count > 0) {
|
|
2767
|
-
this._badge.textContent = this._count.toString();
|
|
2790
|
+
this._badge.textContent = this._count > 99 ? "99+" : this._count.toString();
|
|
2768
2791
|
this._badge.style.display = "block";
|
|
2769
2792
|
} else {
|
|
2770
2793
|
this._badge.style.display = "none";
|
|
@@ -3829,6 +3852,9 @@ class CourierInboxThemeManager {
|
|
|
3829
3852
|
this._userMode = mode;
|
|
3830
3853
|
this.updateTheme();
|
|
3831
3854
|
}
|
|
3855
|
+
get mode() {
|
|
3856
|
+
return this._userMode;
|
|
3857
|
+
}
|
|
3832
3858
|
/**
|
|
3833
3859
|
* Subscribe to theme changes
|
|
3834
3860
|
* @param {Function} callback - Function to run when the theme changes
|
|
@@ -3888,7 +3914,7 @@ class CourierInbox extends CourierBaseElement {
|
|
|
3888
3914
|
title: "Inbox",
|
|
3889
3915
|
icon: CourierIconSVGs.inbox,
|
|
3890
3916
|
feedType: this._currentFeed,
|
|
3891
|
-
height: "
|
|
3917
|
+
height: "auto"
|
|
3892
3918
|
});
|
|
3893
3919
|
this._themeManager = themeManager ?? new CourierInboxThemeManager(defaultLightTheme);
|
|
3894
3920
|
}
|
|
@@ -3904,6 +3930,9 @@ class CourierInbox extends CourierBaseElement {
|
|
|
3904
3930
|
setDarkTheme(theme2) {
|
|
3905
3931
|
this._themeManager.setDarkTheme(theme2);
|
|
3906
3932
|
}
|
|
3933
|
+
setMode(mode) {
|
|
3934
|
+
this._themeManager.setMode(mode);
|
|
3935
|
+
}
|
|
3907
3936
|
static get observedAttributes() {
|
|
3908
3937
|
return ["height", "light-theme", "dark-theme", "mode", "message-click", "message-action-click", "message-long-press"];
|
|
3909
3938
|
}
|
|
@@ -4031,6 +4060,8 @@ class CourierInbox extends CourierBaseElement {
|
|
|
4031
4060
|
(_d = this._unreadIndicatorStyle) == null ? void 0 : _d.remove();
|
|
4032
4061
|
}
|
|
4033
4062
|
refreshTheme() {
|
|
4063
|
+
var _a;
|
|
4064
|
+
(_a = this._list) == null ? void 0 : _a.refreshInfoStateThemes();
|
|
4034
4065
|
if (this._inboxStyle) {
|
|
4035
4066
|
this._inboxStyle.textContent = this.getStyles();
|
|
4036
4067
|
}
|
|
@@ -4267,7 +4298,7 @@ class CourierInboxPopupMenu extends CourierBaseElement {
|
|
|
4267
4298
|
// State
|
|
4268
4299
|
__publicField(this, "_width", "440px");
|
|
4269
4300
|
__publicField(this, "_height", "440px");
|
|
4270
|
-
__publicField(this, "_popupAlignment", "top-
|
|
4301
|
+
__publicField(this, "_popupAlignment", "top-left");
|
|
4271
4302
|
__publicField(this, "_top", "40px");
|
|
4272
4303
|
__publicField(this, "_right", "0");
|
|
4273
4304
|
__publicField(this, "_bottom", "40px");
|
|
@@ -4279,6 +4310,10 @@ class CourierInboxPopupMenu extends CourierBaseElement {
|
|
|
4279
4310
|
__publicField(this, "_popup");
|
|
4280
4311
|
__publicField(this, "_inbox");
|
|
4281
4312
|
__publicField(this, "_style");
|
|
4313
|
+
// Inbox Handlers
|
|
4314
|
+
__publicField(this, "_onMessageClick");
|
|
4315
|
+
__publicField(this, "_onMessageActionClick");
|
|
4316
|
+
__publicField(this, "_onMessageLongPress");
|
|
4282
4317
|
// Listeners
|
|
4283
4318
|
__publicField(this, "_datastoreListener");
|
|
4284
4319
|
// Factories
|
|
@@ -4312,6 +4347,9 @@ class CourierInboxPopupMenu extends CourierBaseElement {
|
|
|
4312
4347
|
setDarkTheme(theme2) {
|
|
4313
4348
|
this._themeManager.setDarkTheme(theme2);
|
|
4314
4349
|
}
|
|
4350
|
+
setMode(mode) {
|
|
4351
|
+
this._themeManager.setMode(mode);
|
|
4352
|
+
}
|
|
4315
4353
|
static get observedAttributes() {
|
|
4316
4354
|
return ["popup-alignment", "message-click", "message-action-click", "message-long-press", "popup-width", "popup-height", "top", "right", "bottom", "left", "light-theme", "dark-theme", "mode"];
|
|
4317
4355
|
}
|
|
@@ -4323,6 +4361,26 @@ class CourierInboxPopupMenu extends CourierBaseElement {
|
|
|
4323
4361
|
this._popup.className = "popup";
|
|
4324
4362
|
this._inbox = new CourierInbox(this._themeManager);
|
|
4325
4363
|
this._inbox.setAttribute("height", "100%");
|
|
4364
|
+
if (this._inbox) {
|
|
4365
|
+
this._inbox.onMessageClick((props) => {
|
|
4366
|
+
if (this._onMessageClick) {
|
|
4367
|
+
this._onMessageClick(props);
|
|
4368
|
+
}
|
|
4369
|
+
this.closePopup();
|
|
4370
|
+
});
|
|
4371
|
+
this._inbox.onMessageActionClick((props) => {
|
|
4372
|
+
if (this._onMessageActionClick) {
|
|
4373
|
+
this._onMessageActionClick(props);
|
|
4374
|
+
}
|
|
4375
|
+
this.closePopup();
|
|
4376
|
+
});
|
|
4377
|
+
this._inbox.onMessageLongPress((props) => {
|
|
4378
|
+
if (this._onMessageLongPress) {
|
|
4379
|
+
this._onMessageLongPress(props);
|
|
4380
|
+
}
|
|
4381
|
+
this.closePopup();
|
|
4382
|
+
});
|
|
4383
|
+
}
|
|
4326
4384
|
this.refreshTheme();
|
|
4327
4385
|
this.appendChild(this._triggerButton);
|
|
4328
4386
|
this.appendChild(this._popup);
|
|
@@ -4435,16 +4493,13 @@ class CourierInboxPopupMenu extends CourierBaseElement {
|
|
|
4435
4493
|
this.render();
|
|
4436
4494
|
}
|
|
4437
4495
|
onMessageClick(handler) {
|
|
4438
|
-
|
|
4439
|
-
(_a = this._inbox) == null ? void 0 : _a.onMessageClick(handler);
|
|
4496
|
+
this._onMessageClick = handler;
|
|
4440
4497
|
}
|
|
4441
4498
|
onMessageActionClick(handler) {
|
|
4442
|
-
|
|
4443
|
-
(_a = this._inbox) == null ? void 0 : _a.onMessageActionClick(handler);
|
|
4499
|
+
this._onMessageActionClick = handler;
|
|
4444
4500
|
}
|
|
4445
4501
|
onMessageLongPress(handler) {
|
|
4446
|
-
|
|
4447
|
-
(_a = this._inbox) == null ? void 0 : _a.onMessageLongPress(handler);
|
|
4502
|
+
this._onMessageLongPress = handler;
|
|
4448
4503
|
}
|
|
4449
4504
|
isValidPosition(value) {
|
|
4450
4505
|
const validPositions = [
|
|
@@ -4518,6 +4573,10 @@ class CourierInboxPopupMenu extends CourierBaseElement {
|
|
|
4518
4573
|
const isVisible = this._popup.style.display === "block";
|
|
4519
4574
|
this._popup.style.display = isVisible ? "none" : "block";
|
|
4520
4575
|
}
|
|
4576
|
+
closePopup() {
|
|
4577
|
+
if (!this._popup) return;
|
|
4578
|
+
this._popup.style.display = "none";
|
|
4579
|
+
}
|
|
4521
4580
|
setContent(element) {
|
|
4522
4581
|
if (!this._inbox) return;
|
|
4523
4582
|
this._inbox.innerHTML = "";
|
|
@@ -4544,35 +4603,35 @@ class CourierInboxPopupMenu extends CourierBaseElement {
|
|
|
4544
4603
|
(_a = this._inbox) == null ? void 0 : _a.setFeedType(feedType);
|
|
4545
4604
|
}
|
|
4546
4605
|
// Factory methods
|
|
4547
|
-
|
|
4606
|
+
setHeader(factory) {
|
|
4548
4607
|
var _a;
|
|
4549
4608
|
(_a = this._inbox) == null ? void 0 : _a.setHeader(factory);
|
|
4550
4609
|
}
|
|
4551
|
-
|
|
4610
|
+
removeHeader() {
|
|
4552
4611
|
var _a;
|
|
4553
4612
|
(_a = this._inbox) == null ? void 0 : _a.removeHeader();
|
|
4554
4613
|
}
|
|
4555
|
-
|
|
4614
|
+
setLoadingState(factory) {
|
|
4556
4615
|
var _a;
|
|
4557
4616
|
(_a = this._inbox) == null ? void 0 : _a.setLoadingState(factory);
|
|
4558
4617
|
}
|
|
4559
|
-
|
|
4618
|
+
setEmptyState(factory) {
|
|
4560
4619
|
var _a;
|
|
4561
4620
|
(_a = this._inbox) == null ? void 0 : _a.setEmptyState(factory);
|
|
4562
4621
|
}
|
|
4563
|
-
|
|
4622
|
+
setErrorState(factory) {
|
|
4564
4623
|
var _a;
|
|
4565
4624
|
(_a = this._inbox) == null ? void 0 : _a.setErrorState(factory);
|
|
4566
4625
|
}
|
|
4567
|
-
|
|
4626
|
+
setListItem(factory) {
|
|
4568
4627
|
var _a;
|
|
4569
4628
|
(_a = this._inbox) == null ? void 0 : _a.setListItem(factory);
|
|
4570
4629
|
}
|
|
4571
|
-
|
|
4630
|
+
setPaginationItem(factory) {
|
|
4572
4631
|
var _a;
|
|
4573
4632
|
(_a = this._inbox) == null ? void 0 : _a.setPaginationItem(factory);
|
|
4574
4633
|
}
|
|
4575
|
-
|
|
4634
|
+
setMenuButton(factory) {
|
|
4576
4635
|
this._popupMenuButtonFactory = factory;
|
|
4577
4636
|
this.render();
|
|
4578
4637
|
}
|
|
@@ -4625,6 +4684,7 @@ class CourierInboxDatastoreEvents {
|
|
|
4625
4684
|
}
|
|
4626
4685
|
}
|
|
4627
4686
|
export {
|
|
4687
|
+
Courier2 as Courier,
|
|
4628
4688
|
CourierInbox,
|
|
4629
4689
|
CourierInboxDataStoreListener,
|
|
4630
4690
|
CourierInboxDatastore,
|