@trycourier/courier-ui-inbox 1.0.13-beta → 1.0.15
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 +12 -6
- package/dist/components/courier-inbox-list-item.d.ts +5 -1
- package/dist/components/courier-inbox-list.d.ts +1 -0
- package/dist/components/courier-inbox-popup-menu.d.ts +90 -4
- package/dist/components/courier-inbox.d.ts +61 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +222 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
## 1. Install
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
npm
|
|
6
|
+
npm install @trycourier/courier-ui-inbox@beta
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
> **Using React?** We suggest you use [@trycourier/courier-react](../courier-react/README.md) package instead.
|
|
@@ -14,10 +14,10 @@ To use the SDK, you need to generate a JWT (JSON Web Token) for your user. **Thi
|
|
|
14
14
|
|
|
15
15
|
**How it works:**
|
|
16
16
|
|
|
17
|
-
1. **Your frontend calls your backend:**
|
|
17
|
+
1. **Your frontend calls your backend:**
|
|
18
18
|
- When your app needs to authenticate a user, your frontend should make a request to your own backend (e.g., `/api/generate-courier-jwt`).
|
|
19
19
|
|
|
20
|
-
2. **Your backend calls Courier to issue a JWT:**
|
|
20
|
+
2. **Your backend calls Courier to issue a JWT:**
|
|
21
21
|
- In your backend endpoint, use your [Courier API Key](https://app.courier.com/settings/api-keys) to call the [Courier JWT Token Endpoint](https://www.courier.com/docs/reference/auth/issue-token) and generate a JWT for the user.
|
|
22
22
|
- Your backend then returns the JWT to your frontend.
|
|
23
23
|
|
|
@@ -193,10 +193,10 @@ The fastest way to style the Inbox to match your app. This example shows unread
|
|
|
193
193
|
|
|
194
194
|
<div style="display: flex; justify-content: center; align-items: center; padding: 100px;">
|
|
195
195
|
<!-- Available alignments: 'top-right' | 'top-left' | 'top-center' | 'bottom-right' | 'bottom-left' | 'bottom-center' | 'center-right' | 'center-left' | 'center-center' -->
|
|
196
|
-
<courier-inbox-popup-menu
|
|
196
|
+
<courier-inbox-popup-menu
|
|
197
197
|
popup-alignment="top-right"
|
|
198
|
-
top="44px"
|
|
199
|
-
right="44px"
|
|
198
|
+
top="44px"
|
|
199
|
+
right="44px"
|
|
200
200
|
popup-width="340px"
|
|
201
201
|
popup-height="400px">
|
|
202
202
|
</courier-inbox-popup-menu>
|
|
@@ -372,3 +372,9 @@ Customize the inbox UI with any element you want.
|
|
|
372
372
|
```
|
|
373
373
|
|
|
374
374
|
> **Using React?** We suggest you use [@trycourier/courier-react](../courier-react/README.md) package instead.
|
|
375
|
+
|
|
376
|
+
# **Share feedback with Courier**
|
|
377
|
+
|
|
378
|
+
We want to make this the best SDK for managing notifications! Have an idea or feedback about our SDKs? Let us know!
|
|
379
|
+
|
|
380
|
+
[Courier Web Issues](https://github.com/trycourier/courier-web/issues)
|
|
@@ -19,15 +19,18 @@ export declare class CourierInboxListItem extends CourierBaseElement {
|
|
|
19
19
|
private _actionsContainer?;
|
|
20
20
|
private _longPressTimeout;
|
|
21
21
|
private _isLongPress;
|
|
22
|
+
private _observer?;
|
|
22
23
|
private onItemClick;
|
|
23
24
|
private onItemLongPress;
|
|
24
25
|
private onItemActionClick;
|
|
26
|
+
private onItemVisible;
|
|
25
27
|
constructor(themeManager: CourierInboxThemeManager, canClick: boolean, _canLongPress: boolean);
|
|
26
28
|
private render;
|
|
29
|
+
private _setupIntersectionObserver;
|
|
30
|
+
onComponentUnmounted(): void;
|
|
27
31
|
static getStyles(theme: CourierInboxTheme): string;
|
|
28
32
|
private _setupHoverBehavior;
|
|
29
33
|
private _setupLongPressBehavior;
|
|
30
|
-
setOnLongPress(cb: (message: InboxMessage) => void): void;
|
|
31
34
|
private _getMenuOptions;
|
|
32
35
|
private _showMenu;
|
|
33
36
|
private _hideMenu;
|
|
@@ -35,5 +38,6 @@ export declare class CourierInboxListItem extends CourierBaseElement {
|
|
|
35
38
|
setOnItemClick(cb: (message: InboxMessage) => void): void;
|
|
36
39
|
setOnItemActionClick(cb: (message: InboxMessage, action: InboxAction) => void): void;
|
|
37
40
|
setOnItemLongPress(cb: (message: InboxMessage) => void): void;
|
|
41
|
+
setOnItemVisible(cb: (message: InboxMessage) => void): void;
|
|
38
42
|
private _updateContent;
|
|
39
43
|
}
|
|
@@ -62,6 +62,7 @@ export declare class CourierInboxList extends CourierBaseElement {
|
|
|
62
62
|
get errorProps(): any;
|
|
63
63
|
get emptyProps(): any;
|
|
64
64
|
private render;
|
|
65
|
+
private openVisibleMessage;
|
|
65
66
|
setLoadingStateFactory(factory: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => HTMLElement): void;
|
|
66
67
|
setEmptyStateFactory(factory: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => HTMLElement): void;
|
|
67
68
|
setErrorStateFactory(factory: (props: CourierInboxStateErrorFactoryProps | undefined | null) => HTMLElement): void;
|
|
@@ -9,14 +9,29 @@ export declare class CourierInboxPopupMenu extends CourierBaseElement implements
|
|
|
9
9
|
private _width;
|
|
10
10
|
private _height;
|
|
11
11
|
private _popupAlignment;
|
|
12
|
-
private _top
|
|
13
|
-
private _right
|
|
14
|
-
private _bottom
|
|
15
|
-
private _left
|
|
12
|
+
private _top?;
|
|
13
|
+
private _right?;
|
|
14
|
+
private _bottom?;
|
|
15
|
+
private _left?;
|
|
16
16
|
private _themeManager;
|
|
17
|
+
/** Returns the current theme object. */
|
|
17
18
|
get theme(): CourierInboxTheme;
|
|
19
|
+
/** Returns the current feed type. */
|
|
20
|
+
get currentFeed(): CourierInboxFeedType;
|
|
21
|
+
/**
|
|
22
|
+
* Set the light theme for the popup menu.
|
|
23
|
+
* @param theme The light theme object to set.
|
|
24
|
+
*/
|
|
18
25
|
setLightTheme(theme: CourierInboxTheme): void;
|
|
26
|
+
/**
|
|
27
|
+
* Set the dark theme for the popup menu.
|
|
28
|
+
* @param theme The dark theme object to set.
|
|
29
|
+
*/
|
|
19
30
|
setDarkTheme(theme: CourierInboxTheme): void;
|
|
31
|
+
/**
|
|
32
|
+
* Set the theme mode (light/dark/system).
|
|
33
|
+
* @param mode The theme mode to set.
|
|
34
|
+
*/
|
|
20
35
|
setMode(mode: CourierComponentThemeMode): void;
|
|
21
36
|
private _triggerButton?;
|
|
22
37
|
private _popup?;
|
|
@@ -31,26 +46,97 @@ export declare class CourierInboxPopupMenu extends CourierBaseElement implements
|
|
|
31
46
|
private refreshTheme;
|
|
32
47
|
static getStyles(theme: CourierInboxTheme, width: string, height: string): string;
|
|
33
48
|
attributeChangedCallback(name: string, _: string, newValue: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Called when the unread count changes.
|
|
51
|
+
* @param _ The new unread count (unused).
|
|
52
|
+
*/
|
|
34
53
|
onUnreadCountChange(_: number): void;
|
|
54
|
+
/**
|
|
55
|
+
* Set a handler for message click events.
|
|
56
|
+
* @param handler The function to call when a message is clicked.
|
|
57
|
+
*/
|
|
35
58
|
onMessageClick(handler?: (props: CourierInboxListItemFactoryProps) => void): void;
|
|
59
|
+
/**
|
|
60
|
+
* Set a handler for message action click events.
|
|
61
|
+
* @param handler The function to call when a message action is clicked.
|
|
62
|
+
*/
|
|
36
63
|
onMessageActionClick(handler?: (props: CourierInboxListItemActionFactoryProps) => void): void;
|
|
64
|
+
/**
|
|
65
|
+
* Set a handler for message long press events.
|
|
66
|
+
* @param handler The function to call when a message is long pressed.
|
|
67
|
+
*/
|
|
37
68
|
onMessageLongPress(handler?: (props: CourierInboxListItemFactoryProps) => void): void;
|
|
38
69
|
private isValidPosition;
|
|
39
70
|
private updatePopupPosition;
|
|
71
|
+
/**
|
|
72
|
+
* Toggle the popup menu open/closed.
|
|
73
|
+
* @param event The click event that triggered the toggle.
|
|
74
|
+
*/
|
|
40
75
|
private togglePopup;
|
|
76
|
+
/**
|
|
77
|
+
* Close the popup menu.
|
|
78
|
+
*/
|
|
41
79
|
closePopup(): void;
|
|
42
80
|
private handleOutsideClick;
|
|
81
|
+
/**
|
|
82
|
+
* Set the content of the popup inbox.
|
|
83
|
+
* @param element The HTMLElement to set as the content.
|
|
84
|
+
*/
|
|
43
85
|
setContent(element: HTMLElement): void;
|
|
86
|
+
/**
|
|
87
|
+
* Set the size of the popup menu.
|
|
88
|
+
* @param width The width to set.
|
|
89
|
+
* @param height The height to set.
|
|
90
|
+
*/
|
|
44
91
|
setSize(width: string, height: string): void;
|
|
92
|
+
/**
|
|
93
|
+
* Set the popup alignment/position.
|
|
94
|
+
* @param position The alignment/position to set.
|
|
95
|
+
*/
|
|
45
96
|
setPosition(position: CourierInboxPopupAlignment): void;
|
|
97
|
+
/**
|
|
98
|
+
* Set the feed type for the inbox.
|
|
99
|
+
* @param feedType The feed type to set.
|
|
100
|
+
*/
|
|
46
101
|
setFeedType(feedType: CourierInboxFeedType): void;
|
|
102
|
+
/**
|
|
103
|
+
* Set a custom header factory for the inbox.
|
|
104
|
+
* @param factory The factory function for the header.
|
|
105
|
+
*/
|
|
47
106
|
setHeader(factory: (props: CourierInboxHeaderFactoryProps | undefined | null) => HTMLElement): void;
|
|
107
|
+
/**
|
|
108
|
+
* Remove the custom header from the inbox.
|
|
109
|
+
*/
|
|
48
110
|
removeHeader(): void;
|
|
111
|
+
/**
|
|
112
|
+
* Set a custom loading state factory for the inbox.
|
|
113
|
+
* @param factory The factory function for the loading state.
|
|
114
|
+
*/
|
|
49
115
|
setLoadingState(factory: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => HTMLElement): void;
|
|
116
|
+
/**
|
|
117
|
+
* Set a custom empty state factory for the inbox.
|
|
118
|
+
* @param factory The factory function for the empty state.
|
|
119
|
+
*/
|
|
50
120
|
setEmptyState(factory: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => HTMLElement): void;
|
|
121
|
+
/**
|
|
122
|
+
* Set a custom error state factory for the inbox.
|
|
123
|
+
* @param factory The factory function for the error state.
|
|
124
|
+
*/
|
|
51
125
|
setErrorState(factory: (props: CourierInboxStateErrorFactoryProps | undefined | null) => HTMLElement): void;
|
|
126
|
+
/**
|
|
127
|
+
* Set a custom list item factory for the inbox.
|
|
128
|
+
* @param factory The factory function for the list item.
|
|
129
|
+
*/
|
|
52
130
|
setListItem(factory: (props: CourierInboxListItemFactoryProps | undefined | null) => HTMLElement): void;
|
|
131
|
+
/**
|
|
132
|
+
* Set a custom pagination item factory for the inbox.
|
|
133
|
+
* @param factory The factory function for the pagination item.
|
|
134
|
+
*/
|
|
53
135
|
setPaginationItem(factory: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => HTMLElement): void;
|
|
136
|
+
/**
|
|
137
|
+
* Set a custom menu button factory for the popup trigger.
|
|
138
|
+
* @param factory The factory function for the menu button.
|
|
139
|
+
*/
|
|
54
140
|
setMenuButton(factory: (props: CourierInboxMenuButtonFactoryProps | undefined | null) => HTMLElement): void;
|
|
55
141
|
private render;
|
|
56
142
|
}
|
|
@@ -6,10 +6,25 @@ import { CourierInboxThemeManager } from '../types/courier-inbox-theme-manager';
|
|
|
6
6
|
export declare class CourierInbox extends CourierBaseElement {
|
|
7
7
|
static get id(): string;
|
|
8
8
|
private _currentFeed;
|
|
9
|
+
/** Returns the current feed type. */
|
|
10
|
+
get currentFeed(): CourierInboxFeedType;
|
|
9
11
|
private _themeManager;
|
|
12
|
+
/** Returns the current theme object. */
|
|
10
13
|
get theme(): CourierInboxTheme;
|
|
14
|
+
/**
|
|
15
|
+
* Set the light theme for the inbox.
|
|
16
|
+
* @param theme The light theme object to set.
|
|
17
|
+
*/
|
|
11
18
|
setLightTheme(theme: CourierInboxTheme): void;
|
|
19
|
+
/**
|
|
20
|
+
* Set the dark theme for the inbox.
|
|
21
|
+
* @param theme The dark theme object to set.
|
|
22
|
+
*/
|
|
12
23
|
setDarkTheme(theme: CourierInboxTheme): void;
|
|
24
|
+
/**
|
|
25
|
+
* Set the theme mode (light/dark/system).
|
|
26
|
+
* @param mode The theme mode to set.
|
|
27
|
+
*/
|
|
13
28
|
setMode(mode: CourierComponentThemeMode): void;
|
|
14
29
|
private _inboxStyle?;
|
|
15
30
|
private _unreadIndicatorStyle?;
|
|
@@ -28,19 +43,65 @@ export declare class CourierInbox extends CourierBaseElement {
|
|
|
28
43
|
onComponentUnmounted(): void;
|
|
29
44
|
private refreshTheme;
|
|
30
45
|
private getStyles;
|
|
46
|
+
/**
|
|
47
|
+
* Sets a custom header factory for the inbox.
|
|
48
|
+
* @param factory - A function that returns an HTMLElement to render as the header.
|
|
49
|
+
*/
|
|
31
50
|
setHeader(factory: (props: CourierInboxHeaderFactoryProps | undefined | null) => HTMLElement): void;
|
|
51
|
+
/**
|
|
52
|
+
* Removes the custom header factory from the inbox, reverting to the default header.
|
|
53
|
+
*/
|
|
32
54
|
removeHeader(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Sets a custom loading state factory for the inbox list.
|
|
57
|
+
* @param factory - A function that returns an HTMLElement to render as the loading state.
|
|
58
|
+
*/
|
|
33
59
|
setLoadingState(factory: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => HTMLElement): void;
|
|
60
|
+
/**
|
|
61
|
+
* Sets a custom empty state factory for the inbox list.
|
|
62
|
+
* @param factory - A function that returns an HTMLElement to render as the empty state.
|
|
63
|
+
*/
|
|
34
64
|
setEmptyState(factory: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => HTMLElement): void;
|
|
65
|
+
/**
|
|
66
|
+
* Sets a custom error state factory for the inbox list.
|
|
67
|
+
* @param factory - A function that returns an HTMLElement to render as the error state.
|
|
68
|
+
*/
|
|
35
69
|
setErrorState(factory: (props: CourierInboxStateErrorFactoryProps | undefined | null) => HTMLElement): void;
|
|
70
|
+
/**
|
|
71
|
+
* Sets a custom list item factory for the inbox list.
|
|
72
|
+
* @param factory - A function that returns an HTMLElement to render as a list item.
|
|
73
|
+
*/
|
|
36
74
|
setListItem(factory: (props: CourierInboxListItemFactoryProps | undefined | null) => HTMLElement): void;
|
|
75
|
+
/**
|
|
76
|
+
* Sets a custom pagination item factory for the inbox list.
|
|
77
|
+
* @param factory - A function that returns an HTMLElement to render as a pagination item.
|
|
78
|
+
*/
|
|
37
79
|
setPaginationItem(factory: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => HTMLElement): void;
|
|
80
|
+
/**
|
|
81
|
+
* Registers a handler for message click events.
|
|
82
|
+
* @param handler - A function to be called when a message is clicked.
|
|
83
|
+
*/
|
|
38
84
|
onMessageClick(handler?: (props: CourierInboxListItemFactoryProps) => void): void;
|
|
85
|
+
/**
|
|
86
|
+
* Registers a handler for message action click events.
|
|
87
|
+
* @param handler - A function to be called when a message action is clicked.
|
|
88
|
+
*/
|
|
39
89
|
onMessageActionClick(handler?: (props: CourierInboxListItemActionFactoryProps) => void): void;
|
|
90
|
+
/**
|
|
91
|
+
* Registers a handler for message long press events.
|
|
92
|
+
* @param handler - A function to be called when a message is long-pressed.
|
|
93
|
+
*/
|
|
40
94
|
onMessageLongPress(handler?: (props: CourierInboxListItemFactoryProps) => void): void;
|
|
95
|
+
/**
|
|
96
|
+
* Sets the feed type for the inbox (e.g., "inbox" or "archive").
|
|
97
|
+
* @param feedType - The feed type to display.
|
|
98
|
+
*/
|
|
41
99
|
setFeedType(feedType: CourierInboxFeedType): void;
|
|
42
100
|
private updateHeader;
|
|
43
101
|
private load;
|
|
102
|
+
/**
|
|
103
|
+
* Forces a reload of the inbox data, bypassing the cache.
|
|
104
|
+
*/
|
|
44
105
|
refresh(): void;
|
|
45
106
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
46
107
|
}
|