@trycourier/courier-react 8.0.19-beta → 8.0.21-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 +361 -127
- package/dist/components/courier-inbox-popup-menu.d.ts +8 -8
- package/dist/components/courier-inbox.d.ts +7 -7
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +28 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,171 +1,405 @@
|
|
|
1
|
-
|
|
1
|
+
<img width="1040" alt="courier-react" src="https://github.com/user-attachments/assets/e886b445-d106-4dab-afca-82183e0fcbe7" />
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 1. Install
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```sh
|
|
6
|
+
npm i @trycourier/courier-react@8.0.21-beta
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
> **Not using React?** We suggest you use [@trycourier/courier-ui-inbox](../courier-ui-inbox/README.md) package instead.
|
|
10
|
+
|
|
11
|
+
## 2. Authenticate
|
|
12
|
+
|
|
13
|
+
To use the SDK, you need to generate a JWT (JSON Web Token) for your user. **This JWT should always be generated by your backend server, never in client-side code.**
|
|
14
|
+
|
|
15
|
+
**How it works:**
|
|
16
|
+
|
|
17
|
+
1. **Your frontend calls your backend:**
|
|
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
|
+
|
|
20
|
+
2. **Your backend calls Courier to issue a JWT:**
|
|
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
|
+
- Your backend then returns the JWT to your frontend.
|
|
23
|
+
|
|
24
|
+
To quickly test JWT generation (for development only), you can use the following cURL command to call Courier's API directly. **Do not use this in production or from client-side code.**
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
curl --request POST \
|
|
28
|
+
--url https://api.courier.com/auth/issue-token \
|
|
29
|
+
--header 'Accept: application/json' \
|
|
30
|
+
--header 'Authorization: Bearer $YOUR_API_KEY' \
|
|
31
|
+
--header 'Content-Type: application/json' \
|
|
32
|
+
--data \
|
|
33
|
+
'{
|
|
34
|
+
"scope": "user_id:$YOUR_USER_ID write:user-tokens inbox:read:messages inbox:write:events read:preferences write:preferences read:brands",
|
|
35
|
+
"expires_in": "$YOUR_NUMBER days"
|
|
36
|
+
}'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 3. Add Inbox Component
|
|
40
|
+
|
|
41
|
+
### `CourierInbox`
|
|
42
|
+
|
|
43
|
+
<img width="688" alt="Screenshot 2025-06-25 at 5 17 47 PM" src="https://github.com/user-attachments/assets/1655f43b-cc61-473f-9204-8dffeae21042" />
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { useEffect } from 'react';
|
|
47
|
+
import { CourierInbox, useCourier } from '@trycourier/courier-react';
|
|
48
|
+
|
|
49
|
+
export default function App() {
|
|
6
50
|
|
|
7
|
-
|
|
8
|
-
|
|
51
|
+
const courier = useCourier();
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
// Generate a JWT for your user (do this on your backend server)
|
|
55
|
+
const jwt = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'; // Replace with actual JWT
|
|
56
|
+
|
|
57
|
+
// Authenticate the user with the inbox
|
|
58
|
+
courier.shared.signIn({
|
|
59
|
+
userId: $YOUR_USER_ID,
|
|
60
|
+
jwt: jwt,
|
|
61
|
+
});
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
return <CourierInbox />;
|
|
65
|
+
|
|
66
|
+
}
|
|
9
67
|
```
|
|
10
68
|
|
|
11
|
-
|
|
69
|
+
### `CourierInboxPopupMenu`
|
|
70
|
+
|
|
71
|
+
<img width="605" alt="Screenshot 2025-06-25 at 5 21 53 PM" src="https://github.com/user-attachments/assets/1c5497ba-a860-4d7e-8cf7-5b56a65cea51" />
|
|
12
72
|
|
|
13
73
|
```ts
|
|
14
74
|
import { useEffect } from 'react';
|
|
15
75
|
import { CourierInbox, useCourier } from '@trycourier/courier-react';
|
|
16
76
|
|
|
17
|
-
function App() {
|
|
77
|
+
export default function App() {
|
|
18
78
|
|
|
19
79
|
const courier = useCourier();
|
|
20
80
|
|
|
21
81
|
useEffect(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
82
|
+
// Generate a JWT for your user (do this on your backend server)
|
|
83
|
+
const jwt = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'; // Replace with actual JWT
|
|
84
|
+
|
|
85
|
+
// Authenticate the user with the inbox
|
|
86
|
+
courier.shared.signIn({
|
|
87
|
+
userId: $YOUR_USER_ID,
|
|
88
|
+
jwt: jwt,
|
|
89
|
+
});
|
|
90
|
+
}, []);
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div style={{ padding: '24px' }}>
|
|
94
|
+
<CourierInboxPopupMenu />
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## NextJS & Server Side Rendering Frameworks
|
|
102
|
+
|
|
103
|
+
`courier-react` only supports client side rendering. You will need to add `'use client'` to the top of any file that will use `CourierInbox` or `CourierInboxPopupMenu`.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
'use client'
|
|
107
|
+
|
|
108
|
+
...
|
|
109
|
+
import { ..., CourierInboxPopupMenu } from '@trycourier/courier-react';
|
|
110
|
+
|
|
111
|
+
export default function Page() {
|
|
112
|
+
|
|
113
|
+
...
|
|
114
|
+
|
|
115
|
+
return <CourierInboxPopupMenu />;
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Handle Clicks and Presses
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { useEffect } from 'react';
|
|
124
|
+
import { CourierInbox, useCourier, type CourierInboxListItemFactoryProps, type CourierInboxListItemActionFactoryProps } from '@trycourier/courier-react';
|
|
125
|
+
|
|
126
|
+
export default function App() {
|
|
127
|
+
|
|
128
|
+
const courier = useCourier();
|
|
129
|
+
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
// Generate a JWT for your user (do this on your backend server)
|
|
132
|
+
const jwt = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'; // Replace with actual JWT
|
|
133
|
+
|
|
134
|
+
// Authenticate the user with the inbox
|
|
135
|
+
courier.shared.signIn({
|
|
136
|
+
userId: $YOUR_USER_ID,
|
|
137
|
+
jwt: jwt,
|
|
25
138
|
});
|
|
26
139
|
}, []);
|
|
27
140
|
|
|
28
141
|
return (
|
|
29
142
|
<CourierInbox
|
|
30
|
-
onMessageClick={(
|
|
31
|
-
|
|
143
|
+
onMessageClick={({ message, index }: CourierInboxListItemFactoryProps) => {
|
|
144
|
+
alert("Message clicked at index " + index + ":\n" + JSON.stringify(message, null, 2));
|
|
32
145
|
}}
|
|
33
|
-
onMessageActionClick={(
|
|
34
|
-
|
|
146
|
+
onMessageActionClick={({ message, action, index }: CourierInboxListItemActionFactoryProps) => {
|
|
147
|
+
alert(
|
|
148
|
+
"Message action clicked at index " + index + ":\n" +
|
|
149
|
+
"Action: " + JSON.stringify(action, null, 2) + "\n" +
|
|
150
|
+
"Message: " + JSON.stringify(message, null, 2)
|
|
151
|
+
);
|
|
35
152
|
}}
|
|
36
|
-
onMessageLongPress={(
|
|
37
|
-
|
|
153
|
+
onMessageLongPress={({ message, index }: CourierInboxListItemFactoryProps) => {
|
|
154
|
+
// Handle message long presses. **Only works on devices that support javascript's touch events. This will not work with a mouse cursor.**
|
|
155
|
+
alert("Message long pressed at index " + index + ":\n" + JSON.stringify(message, null, 2));
|
|
38
156
|
}}
|
|
39
|
-
|
|
157
|
+
/>
|
|
158
|
+
);
|
|
40
159
|
|
|
41
|
-
|
|
160
|
+
}
|
|
161
|
+
```
|
|
42
162
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
163
|
+
## Styles and Theming
|
|
164
|
+
|
|
165
|
+
### Light & Dark Themes
|
|
166
|
+
|
|
167
|
+
The fastest way to style the Inbox to match your app. This example shows unread indicator styling, but you can customize fonts, icons, text, and more.
|
|
168
|
+
|
|
169
|
+
> **🎨 Theme Reference:** [All available theme values](../courier-ui-inbox/docs/theme.md)
|
|
170
|
+
|
|
171
|
+
<img width="688" alt="Screenshot 2025-06-25 at 5 38 07 PM" src="https://github.com/user-attachments/assets/d1440494-ee66-4ff6-850b-c1a13691cf2f" />
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
import { CourierInbox, ..., type CourierInboxTheme } from '@trycourier/courier-react';
|
|
175
|
+
|
|
176
|
+
export default function App() {
|
|
177
|
+
...
|
|
178
|
+
|
|
179
|
+
const theme: CourierInboxTheme = {
|
|
180
|
+
inbox: {
|
|
181
|
+
header: {
|
|
182
|
+
filters: {
|
|
183
|
+
unreadIndicator: {
|
|
184
|
+
backgroundColor: '#8B5CF6',
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
list: {
|
|
189
|
+
item: {
|
|
190
|
+
unreadIndicatorColor: '#8B5CF6',
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
return <CourierInbox lightTheme={theme} darkTheme={theme} mode="light" />;
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Popup Alignment, Positioning, and Dimensions
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
export default function App() {
|
|
204
|
+
|
|
205
|
+
...
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', padding: '100px' }}>
|
|
209
|
+
<CourierInboxPopupMenu
|
|
210
|
+
popupAlignment="top-right" // 'top-right' | 'top-left' | 'top-center' | 'bottom-right' | 'bottom-left' | 'bottom-center' | 'center-right' | 'center-left' | 'center-center'
|
|
211
|
+
popupWidth="340px"
|
|
212
|
+
popupHeight="400px"
|
|
213
|
+
top="44px"
|
|
214
|
+
right="44px"
|
|
215
|
+
/>
|
|
216
|
+
</div>
|
|
54
217
|
);
|
|
55
218
|
|
|
56
219
|
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Custom height `CourierInbox`
|
|
57
223
|
|
|
58
|
-
|
|
224
|
+
> **Important:** The default `CourierInbox` height is auto. It will set it's height based on it's children.
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
<CourierInbox height='50vh' />
|
|
59
228
|
```
|
|
60
229
|
|
|
61
|
-
##
|
|
230
|
+
## Custom Elements
|
|
231
|
+
|
|
232
|
+
Customize the inbox UI with any element you want.
|
|
233
|
+
|
|
234
|
+
### List Items
|
|
62
235
|
|
|
63
|
-
|
|
236
|
+
<img width="688" alt="Screenshot 2025-06-25 at 6 25 17 PM" src="https://github.com/user-attachments/assets/075a568b-5538-4116-bb3d-752ecc5dea2c" />
|
|
64
237
|
|
|
65
238
|
```ts
|
|
66
|
-
import {
|
|
67
|
-
|
|
68
|
-
const theme: CourierInboxTheme = {
|
|
69
|
-
popup: {
|
|
70
|
-
button: {
|
|
71
|
-
unreadIndicator: {
|
|
72
|
-
backgroundColor: '#9b4dca',
|
|
73
|
-
...
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
window: {
|
|
77
|
-
...
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
inbox: {
|
|
81
|
-
header: {
|
|
82
|
-
filters: {
|
|
83
|
-
unreadIndicator: {
|
|
84
|
-
backgroundColor: '#9b4dca',
|
|
85
|
-
...
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
list: {
|
|
90
|
-
item: {
|
|
91
|
-
unreadIndicatorColor: '#9b4dca',
|
|
92
|
-
...
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
};
|
|
239
|
+
import { CourierInbox, ..., type CourierInboxListItemFactoryProps } from '@trycourier/courier-react'
|
|
97
240
|
|
|
98
|
-
|
|
241
|
+
const CustomListItem = ({ message, index }: CourierInboxListItemFactoryProps) => (
|
|
242
|
+
<pre style={{
|
|
243
|
+
padding: '24px',
|
|
244
|
+
borderBottom: '1px solid #e0e0e0',
|
|
245
|
+
margin: '0'
|
|
246
|
+
}}>
|
|
247
|
+
{JSON.stringify({ message, index }, null, 2)}
|
|
248
|
+
</pre>
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
export default function App() {
|
|
252
|
+
|
|
253
|
+
...
|
|
254
|
+
|
|
255
|
+
return (
|
|
256
|
+
<CourierInbox
|
|
257
|
+
renderListItem={(props: CourierInboxListItemFactoryProps) => {
|
|
258
|
+
return <CustomListItem {...props} />
|
|
259
|
+
}}
|
|
260
|
+
/>
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Header
|
|
267
|
+
|
|
268
|
+
<img width="688" alt="Screenshot 2025-06-25 at 6 35 59 PM" src="https://github.com/user-attachments/assets/25d45ac1-32e6-4e98-baf1-d0df34cef72a" />
|
|
269
|
+
|
|
270
|
+
```ts
|
|
271
|
+
import { CourierInbox, ..., type CourierInboxHeaderFactoryProps } from '@trycourier/courier-react'
|
|
99
272
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
273
|
+
const CustomHeader = (props: CourierInboxHeaderFactoryProps) => (
|
|
274
|
+
<div style={{
|
|
275
|
+
background: 'red',
|
|
276
|
+
fontSize: '24px',
|
|
277
|
+
padding: '24px',
|
|
278
|
+
width: '100%'
|
|
279
|
+
}}>
|
|
280
|
+
{props.feedType}
|
|
281
|
+
</div>
|
|
282
|
+
);
|
|
107
283
|
|
|
108
|
-
|
|
284
|
+
export default function App() {
|
|
109
285
|
|
|
110
|
-
|
|
111
|
-
popupAlignment='top-left'
|
|
112
|
-
popupWidth='456px'
|
|
113
|
-
popupHeight='456px'
|
|
114
|
-
mode='system'
|
|
115
|
-
feedType='archive'
|
|
116
|
-
/>
|
|
286
|
+
...
|
|
117
287
|
|
|
288
|
+
return (
|
|
289
|
+
<CourierInbox
|
|
290
|
+
renderHeader={(props: CourierInboxHeaderFactoryProps) => {
|
|
291
|
+
return <CustomHeader {...props} />
|
|
292
|
+
}}
|
|
293
|
+
/>
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
}
|
|
118
297
|
```
|
|
119
298
|
|
|
120
|
-
|
|
299
|
+
### Popup Menu Button
|
|
121
300
|
|
|
122
|
-
|
|
301
|
+
<img width="606" alt="Screenshot 2025-06-25 at 6 40 38 PM" src="https://github.com/user-attachments/assets/dfb0daca-f11d-420f-9dc7-0c14b49ab7db" />
|
|
123
302
|
|
|
124
303
|
```ts
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
<CourierInboxMenu
|
|
149
|
-
renderPopupMenuButton={(props) => {
|
|
150
|
-
return <div>...</div>
|
|
151
|
-
}}
|
|
152
|
-
renderPopupHeader={(props) => {
|
|
153
|
-
return <div>...</div>
|
|
154
|
-
}}
|
|
155
|
-
renderPopupListItem={(props) => {
|
|
156
|
-
return <div>...</div>
|
|
157
|
-
}}
|
|
158
|
-
renderPopupEmptyState={(props) => {
|
|
159
|
-
return <div>...</div>
|
|
160
|
-
}}
|
|
161
|
-
renderPopupLoadingState={(props) => {
|
|
162
|
-
return <div>...</div>
|
|
163
|
-
}}
|
|
164
|
-
renderPopupErrorState={(props) => {
|
|
165
|
-
return <div>...</div>
|
|
166
|
-
}}
|
|
167
|
-
renderPopupPaginationItem={(props) => {
|
|
168
|
-
return <div>...</div>
|
|
169
|
-
}}
|
|
170
|
-
/>
|
|
304
|
+
import { CourierInboxPopupMenu, ..., type CourierInboxMenuButtonFactoryProps } from '@trycourier/courier-react'
|
|
305
|
+
|
|
306
|
+
const CustomMenuButton = ({ unreadCount }: CourierInboxMenuButtonFactoryProps) => (
|
|
307
|
+
<button>
|
|
308
|
+
Open the Inbox Popup. Unread message count: {unreadCount}
|
|
309
|
+
</button>
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
export default function App() {
|
|
313
|
+
|
|
314
|
+
...
|
|
315
|
+
|
|
316
|
+
return (
|
|
317
|
+
<div style={{ padding: '24px' }}>
|
|
318
|
+
<CourierInboxPopupMenu
|
|
319
|
+
renderMenuButton={(props: CourierInboxMenuButtonFactoryProps) => {
|
|
320
|
+
return <CustomMenuButton {...props} />
|
|
321
|
+
}}
|
|
322
|
+
/>
|
|
323
|
+
</div>
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
}
|
|
171
327
|
```
|
|
328
|
+
|
|
329
|
+
### Loading, Empty, Error & Pagination
|
|
330
|
+
|
|
331
|
+
```ts
|
|
332
|
+
import {
|
|
333
|
+
CourierInbox,
|
|
334
|
+
...,
|
|
335
|
+
type CourierInboxStateEmptyFactoryProps,
|
|
336
|
+
type CourierInboxStateLoadingFactoryProps,
|
|
337
|
+
type CourierInboxStateErrorFactoryProps,
|
|
338
|
+
type CourierInboxPaginationItemFactoryProps
|
|
339
|
+
} from '@trycourier/courier-react'
|
|
340
|
+
|
|
341
|
+
const CustomLoadingState = ({ feedType }: CourierInboxStateLoadingFactoryProps) => (
|
|
342
|
+
<div style={{
|
|
343
|
+
padding: '24px',
|
|
344
|
+
background: 'red',
|
|
345
|
+
textAlign: 'center'
|
|
346
|
+
}}>
|
|
347
|
+
Custom Loading State
|
|
348
|
+
</div>
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
const CustomEmptyState = ({ feedType }: CourierInboxStateEmptyFactoryProps) => (
|
|
352
|
+
<div style={{
|
|
353
|
+
padding: '24px',
|
|
354
|
+
background: 'green',
|
|
355
|
+
textAlign: 'center'
|
|
356
|
+
}}>
|
|
357
|
+
Custom Empty State
|
|
358
|
+
</div>
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
const CustomErrorState = ({ feedType, error }: CourierInboxStateErrorFactoryProps) => (
|
|
362
|
+
<div style={{
|
|
363
|
+
padding: '24px',
|
|
364
|
+
background: 'blue',
|
|
365
|
+
textAlign: 'center'
|
|
366
|
+
}}>
|
|
367
|
+
Custom Error State: {error.message}
|
|
368
|
+
</div>
|
|
369
|
+
);
|
|
370
|
+
|
|
371
|
+
const CustomPaginationItem = ({ feedType }: CourierInboxPaginationItemFactoryProps) => (
|
|
372
|
+
<div style={{
|
|
373
|
+
padding: '24px',
|
|
374
|
+
background: 'yellow',
|
|
375
|
+
textAlign: 'center'
|
|
376
|
+
}}>
|
|
377
|
+
Custom Pagination Item
|
|
378
|
+
</div>
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
export default function App() {
|
|
382
|
+
|
|
383
|
+
...
|
|
384
|
+
|
|
385
|
+
return (
|
|
386
|
+
<CourierInbox
|
|
387
|
+
renderLoadingState={(props: CourierInboxStateLoadingFactoryProps) => {
|
|
388
|
+
return <CustomLoadingState {...props} />
|
|
389
|
+
}}
|
|
390
|
+
renderEmptyState={(props: CourierInboxStateEmptyFactoryProps) => {
|
|
391
|
+
return <CustomEmptyState {...props} />
|
|
392
|
+
}}
|
|
393
|
+
renderErrorState={(props: CourierInboxStateErrorFactoryProps) => {
|
|
394
|
+
return <CustomErrorState {...props} />
|
|
395
|
+
}}
|
|
396
|
+
renderPaginationItem={(props: CourierInboxPaginationItemFactoryProps) => {
|
|
397
|
+
return <CustomPaginationItem {...props} />
|
|
398
|
+
}}
|
|
399
|
+
/>
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
}
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
> **Not using React?** We suggest you use [@trycourier/courier-ui-inbox](../courier-ui-inbox/README.md) package instead.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from '../../../../node_modules/react';
|
|
2
2
|
import { CourierInboxFeedType, CourierInboxHeaderFactoryProps, CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxMenuButtonFactoryProps, CourierInboxPopupMenu as CourierInboxPopupMenuElement, CourierInboxPaginationItemFactoryProps, CourierInboxPopupAlignment, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxTheme } from '@trycourier/courier-ui-inbox';
|
|
3
3
|
import { CourierComponentThemeMode } from '@trycourier/courier-ui-core';
|
|
4
4
|
export interface CourierInboxPopupMenuProps {
|
|
@@ -16,12 +16,12 @@ export interface CourierInboxPopupMenuProps {
|
|
|
16
16
|
onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;
|
|
17
17
|
onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;
|
|
18
18
|
onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;
|
|
20
|
+
renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;
|
|
21
|
+
renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;
|
|
22
|
+
renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;
|
|
23
|
+
renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;
|
|
24
|
+
renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;
|
|
25
|
+
renderMenuButton?: (props: CourierInboxMenuButtonFactoryProps | undefined | null) => ReactNode;
|
|
26
26
|
}
|
|
27
27
|
export declare const CourierInboxPopupMenu: import('../../../../node_modules/react').ForwardRefExoticComponent<CourierInboxPopupMenuProps & import('../../../../node_modules/react').RefAttributes<CourierInboxPopupMenuElement>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from '../../../../node_modules/react';
|
|
2
2
|
import { CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxTheme, CourierInbox as CourierInboxElement, CourierInboxHeaderFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxFeedType } from '@trycourier/courier-ui-inbox';
|
|
3
3
|
import { CourierComponentThemeMode } from '@trycourier/courier-ui-core';
|
|
4
4
|
export interface CourierInboxProps {
|
|
@@ -10,11 +10,11 @@ export interface CourierInboxProps {
|
|
|
10
10
|
onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;
|
|
11
11
|
onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;
|
|
12
12
|
onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;
|
|
13
|
-
renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) =>
|
|
14
|
-
renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) =>
|
|
15
|
-
renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) =>
|
|
16
|
-
renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) =>
|
|
17
|
-
renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) =>
|
|
18
|
-
renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) =>
|
|
13
|
+
renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;
|
|
14
|
+
renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;
|
|
15
|
+
renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;
|
|
16
|
+
renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;
|
|
17
|
+
renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;
|
|
18
|
+
renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;
|
|
19
19
|
}
|
|
20
20
|
export declare const CourierInbox: import('../../../../node_modules/react').ForwardRefExoticComponent<CourierInboxProps & import('../../../../node_modules/react').RefAttributes<CourierInboxElement>>;
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@trycourier/courier-js"),r=require("@trycourier/courier-ui-inbox"),t=require("react"),s=require("react/jsx-runtime"),n=require("react-dom"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@trycourier/courier-js"),r=require("@trycourier/courier-ui-inbox"),t=require("react"),s=require("react/jsx-runtime"),n=require("react-dom"),a=require("react-dom/client");function o(e){const r=document.createElement("div"),t=a.createRoot(r);n.flushSync((()=>{t.render(e)}));const s=r.firstElementChild;if(!(s instanceof HTMLElement))throw new Error("renderListItem must return a single JSX element that renders to an HTMLElement (e.g., <div>)");return s}const i=({children:e})=>{const[r,n]=t.useState(!1);return t.useEffect((()=>{n(!0)}),[]),"undefined"==typeof window?null:r?s.jsx(s.Fragment,{children:e}):null},u=t.forwardRef(((e,r)=>{const n=t.useRef(null);return t.useEffect((()=>{"function"==typeof r?r(n.current):r&&(r.current=n.current)}),[r]),t.useEffect((()=>{const r=n.current;r&&r.onMessageClick(e.onMessageClick)}),[e.onMessageClick,n]),t.useEffect((()=>{const r=n.current;r&&r.onMessageActionClick(e.onMessageActionClick)}),[e.onMessageActionClick,n]),t.useEffect((()=>{const r=n.current;r&&r.onMessageLongPress(e.onMessageLongPress)}),[e.onMessageLongPress,n]),t.useEffect((()=>{const r=n.current;r&&e.renderHeader&&queueMicrotask((()=>{r.setHeader((r=>o(e.renderHeader(r))))}))}),[e.renderHeader,n]),t.useEffect((()=>{const r=n.current;r&&e.renderListItem&&queueMicrotask((()=>{r.setListItem((r=>o(e.renderListItem(r))))}))}),[e.renderListItem,n]),t.useEffect((()=>{const r=n.current;r&&e.renderEmptyState&&queueMicrotask((()=>{r.setEmptyState((r=>o(e.renderEmptyState(r))))}))}),[e.renderEmptyState,n]),t.useEffect((()=>{const r=n.current;r&&e.renderLoadingState&&queueMicrotask((()=>{r.setLoadingState((r=>o(e.renderLoadingState(r))))}))}),[e.renderLoadingState,n]),t.useEffect((()=>{const r=n.current;r&&e.renderErrorState&&queueMicrotask((()=>{r.setErrorState((r=>o(e.renderErrorState(r))))}))}),[e.renderErrorState,n]),t.useEffect((()=>{const r=n.current;r&&e.renderPaginationItem&&queueMicrotask((()=>{r.setPaginationItem((r=>o(e.renderPaginationItem(r))))}))}),[e.renderPaginationItem,n]),t.useEffect((()=>{const r=n.current;r&&queueMicrotask((()=>{r.setFeedType(e.feedType||"inbox")}))}),[e.feedType,n]),s.jsx(i,{children:s.jsx("courier-inbox",{ref:n,height:e.height,"light-theme":e.lightTheme?JSON.stringify(e.lightTheme):void 0,"dark-theme":e.darkTheme?JSON.stringify(e.darkTheme):void 0,mode:e.mode})})}));u.displayName="CourierInbox";const c=t.forwardRef(((e,r)=>{const n=t.useRef(null);return t.useEffect((()=>{"function"==typeof r?r(n.current):r&&(r.current=n.current)}),[r]),t.useEffect((()=>{const r=n.current;r&&r.onMessageClick(e.onMessageClick)}),[e.onMessageClick,n]),t.useEffect((()=>{const r=n.current;r&&r.onMessageActionClick(e.onMessageActionClick)}),[e.onMessageActionClick,n]),t.useEffect((()=>{const r=n.current;r&&r.onMessageLongPress(e.onMessageLongPress)}),[e.onMessageLongPress,n]),t.useEffect((()=>{const r=n.current;r&&e.renderHeader&&queueMicrotask((()=>{r.setHeader((r=>o(e.renderHeader(r))))}))}),[e.renderHeader,n]),t.useEffect((()=>{const r=n.current;r&&e.renderListItem&&queueMicrotask((()=>{r.setListItem((r=>o(e.renderListItem(r))))}))}),[e.renderListItem,n]),t.useEffect((()=>{const r=n.current;r&&e.renderEmptyState&&queueMicrotask((()=>{r.setEmptyState((r=>o(e.renderEmptyState(r))))}))}),[e.renderEmptyState,n]),t.useEffect((()=>{const r=n.current;r&&e.renderLoadingState&&queueMicrotask((()=>{r.setLoadingState((r=>o(e.renderLoadingState(r))))}))}),[e.renderLoadingState,n]),t.useEffect((()=>{const r=n.current;r&&e.renderErrorState&&queueMicrotask((()=>{r.setErrorState((r=>o(e.renderErrorState(r))))}))}),[e.renderErrorState,n]),t.useEffect((()=>{const r=n.current;r&&e.renderPaginationItem&&queueMicrotask((()=>{r.setPaginationItem((r=>o(e.renderPaginationItem(r))))}))}),[e.renderPaginationItem,n]),t.useEffect((()=>{const r=n.current;r&&e.renderMenuButton&&queueMicrotask((()=>{r.setMenuButton((r=>o(e.renderMenuButton(r))))}))}),[e.renderMenuButton,n]),t.useEffect((()=>{const r=n.current;r&&queueMicrotask((()=>{r.setFeedType(e.feedType||"inbox")}))}),[e.feedType,n]),s.jsx(i,{children:s.jsx("courier-inbox-popup-menu",{ref:n,"popup-alignment":e.popupAlignment,"popup-width":e.popupWidth,"popup-height":e.popupHeight,left:e.left,top:e.top,right:e.right,bottom:e.bottom,"light-theme":e.lightTheme?JSON.stringify(e.lightTheme):void 0,"dark-theme":e.darkTheme?JSON.stringify(e.darkTheme):void 0,mode:e.mode})})}));c.displayName="CourierInboxPopupMenu",Object.defineProperty(exports,"archiveMessage",{enumerable:!0,get:()=>r.archiveMessage}),Object.defineProperty(exports,"clickMessage",{enumerable:!0,get:()=>r.clickMessage}),Object.defineProperty(exports,"defaultDarkTheme",{enumerable:!0,get:()=>r.defaultDarkTheme}),Object.defineProperty(exports,"defaultLightTheme",{enumerable:!0,get:()=>r.defaultLightTheme}),Object.defineProperty(exports,"markAsRead",{enumerable:!0,get:()=>r.markAsRead}),Object.defineProperty(exports,"markAsUnread",{enumerable:!0,get:()=>r.markAsUnread}),Object.defineProperty(exports,"mergeTheme",{enumerable:!0,get:()=>r.mergeTheme}),Object.defineProperty(exports,"openMessage",{enumerable:!0,get:()=>r.openMessage}),exports.CourierInbox=u,exports.CourierInboxPopupMenu=c,exports.useCourier=()=>{const s=r=>e.Courier.shared.signIn(r),n=()=>e.Courier.shared.signOut(),a=e=>r.CourierInboxDatastore.shared.load(e),o=e=>r.CourierInboxDatastore.shared.fetchNextPageOfMessages(e),i=r=>e.Courier.shared.paginationLimit=r,u=e=>r.CourierInboxDatastore.shared.readMessage({message:e}),c=e=>r.CourierInboxDatastore.shared.unreadMessage({message:e}),d=e=>r.CourierInboxDatastore.shared.clickMessage({message:e}),g=e=>r.CourierInboxDatastore.shared.archiveMessage({message:e}),f=e=>r.CourierInboxDatastore.shared.openMessage({message:e}),m=e=>r.CourierInboxDatastore.shared.unarchiveMessage({message:e}),h=()=>r.CourierInboxDatastore.shared.readAllMessages(),[l,p]=t.useState({userId:void 0,signIn:s,signOut:n}),[M,E]=t.useState({load:a,fetchNextPageOfMessages:o,setPaginationLimit:i,readMessage:u,unreadMessage:c,clickMessage:d,archiveMessage:g,openMessage:f,unarchiveMessage:m,readAllMessages:h});t.useEffect((()=>{const t=e.Courier.shared.addAuthenticationListener((()=>x())),s=new r.CourierInboxDataStoreListener({onError:e=>b(e),onDataSetChange:()=>b(),onPageAdded:()=>b(),onMessageAdd:()=>b(),onMessageRemove:()=>b(),onMessageUpdate:()=>b(),onUnreadCountChange:()=>b()});return r.CourierInboxDatastore.shared.addDataStoreListener(s),x(),b(),()=>{t.remove(),s.remove()}}),[]);const x=()=>{var r;const t=null==(r=e.Courier.shared.client)?void 0:r.options;p({userId:null==t?void 0:t.userId,signIn:s,signOut:n})},b=e=>{const t=r.CourierInboxDatastore.shared;E({load:a,fetchNextPageOfMessages:o,setPaginationLimit:i,readMessage:u,unreadMessage:c,clickMessage:d,archiveMessage:g,openMessage:f,unarchiveMessage:m,readAllMessages:h,inbox:t.inboxDataSet,archive:t.archiveDataSet,unreadCount:t.unreadCount,error:e})};return{shared:e.Courier.shared,auth:l,inbox:M}};
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/utils/utils.tsx","../src/components/courier-client-component.tsx","../src/components/courier-inbox.tsx","../src/components/courier-inbox-popup-menu.tsx","../src/hooks/use-courier.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { createRoot } from \"react-dom/client\";\n\n/**\n * Converts a React node to an HTMLElement.\n * This function uses flushSync to ensure the DOM is updated synchronously.\n * @param node - The React node to convert.\n * @returns The converted HTMLElement.\n */\nexport function reactNodeToHTMLElement(node: ReactNode): HTMLElement {\n const container = document.createElement('div');\n\n // Use React 18 root\n const root = createRoot(container);\n flushSync(() => {\n root.render(node);\n });\n\n // Wait until React mounts the content synchronously\n const element = container.firstElementChild;\n if (!(element instanceof HTMLElement)) {\n throw new Error(\n 'renderListItem must return a single JSX element that renders to an HTMLElement (e.g., <div>)'\n );\n }\n\n return element;\n}","import React, { useState, useEffect } from 'react';\n\ninterface CourierClientProps {\n children: React.ReactNode;\n}\n\n// This class prevents issues with server side rendering react components\n// It will force the component to only render client side\n// A future update could support server side rendering if there is enough demand\nexport const CourierClientComponent: React.FC<CourierClientProps> = ({ children }) => {\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n // During SSR, render nothing or fallback\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (!isMounted) {\n return null;\n }\n\n return <>{children}</>;\n};","import { useRef, useEffect, JSX, forwardRef } from \"react\";\nimport { CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxTheme, CourierInbox as CourierInboxElement, CourierInboxHeaderFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxFeedType } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxProps {\n height?: string;\n lightTheme?: CourierInboxTheme;\n darkTheme?: CourierInboxTheme;\n mode?: CourierComponentThemeMode;\n feedType?: CourierInboxFeedType;\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => JSX.Element;\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => JSX.Element;\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => JSX.Element;\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => JSX.Element;\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => JSX.Element;\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => JSX.Element;\n}\n\nexport const CourierInbox = forwardRef<CourierInboxElement, CourierInboxProps>((props, ref) => {\n const inboxRef = useRef<CourierInboxElement | null>(null);\n\n // Expose the internal ref to the parent if a ref was passed in\n useEffect(() => {\n if (typeof ref === \"function\") {\n ref(inboxRef.current);\n } else if (ref) {\n (ref as React.RefObject<CourierInboxElement | null>).current = inboxRef.current;\n }\n }, [ref]);\n\n // Handle message click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, inboxRef]);\n\n // Handle message action click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, inboxRef]);\n\n // Handle message long press\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, inboxRef]);\n\n // Render header\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderHeader) return;\n queueMicrotask(() => {\n inbox.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader, inboxRef]);\n\n // Render list item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderListItem) return;\n queueMicrotask(() => {\n inbox.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem, inboxRef]);\n\n // Render empty state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderEmptyState) return;\n queueMicrotask(() => {\n inbox.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState, inboxRef]);\n\n // Render loading state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderLoadingState) return;\n queueMicrotask(() => {\n inbox.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState, inboxRef]);\n\n // Render error state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderErrorState) return;\n queueMicrotask(() => {\n inbox.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState, inboxRef]);\n\n // Render pagination item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n inbox.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem, inboxRef]);\n\n // Set feed type\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n queueMicrotask(() => {\n inbox.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, inboxRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox\n ref={inboxRef}\n height={props.height}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n});\n\nCourierInbox.displayName = 'CourierInbox';","import { useRef, useEffect, JSX, forwardRef } from \"react\";\nimport { CourierInboxFeedType, CourierInboxHeaderFactoryProps, CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxMenuButtonFactoryProps, CourierInboxPopupMenu as CourierInboxPopupMenuElement, CourierInboxPaginationItemFactoryProps, CourierInboxPopupAlignment, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxTheme } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxPopupMenuProps {\n popupAlignment?: CourierInboxPopupAlignment;\n popupWidth?: string;\n popupHeight?: string;\n left?: string;\n top?: string;\n right?: string;\n bottom?: string;\n lightTheme?: CourierInboxTheme;\n darkTheme?: CourierInboxTheme;\n mode?: CourierComponentThemeMode;\n feedType?: CourierInboxFeedType;\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n renderPopupHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => JSX.Element;\n renderPopupListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => JSX.Element;\n renderPopupEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => JSX.Element;\n renderPopupLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => JSX.Element;\n renderPopupErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => JSX.Element;\n renderPopupPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => JSX.Element;\n renderPopupMenuButton?: (props: CourierInboxMenuButtonFactoryProps | undefined | null) => JSX.Element;\n}\n\nexport const CourierInboxPopupMenu = forwardRef<CourierInboxPopupMenuElement, CourierInboxPopupMenuProps>((props, ref) => {\n const menuRef = useRef<CourierInboxPopupMenuElement>(null);\n\n // Expose the internal ref to the parent if a ref was passed in\n useEffect(() => {\n if (typeof ref === \"function\") {\n ref(menuRef.current);\n } else if (ref) {\n (ref as React.RefObject<CourierInboxPopupMenuElement | null>).current = menuRef.current;\n }\n }, [ref]);\n\n // Handle message click\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, menuRef]);\n\n // Handle message action click\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, menuRef]);\n\n // Handle message long press\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, menuRef]);\n\n // Render header\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupHeader) return;\n queueMicrotask(() => {\n menu.setPopupHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupHeader, menuRef]);\n\n // Render list item\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupListItem) return;\n queueMicrotask(() => {\n menu.setPopupListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupListItem, menuRef]);\n\n // Render empty state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupEmptyState) return;\n queueMicrotask(() => {\n menu.setPopupEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupEmptyState, menuRef]);\n\n // Render loading state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupLoadingState) return;\n queueMicrotask(() => {\n menu.setPopupLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupLoadingState, menuRef]);\n\n // Render error state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupErrorState) return;\n queueMicrotask(() => {\n menu.setPopupErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupErrorState, menuRef]);\n\n // Render pagination item\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupPaginationItem) return;\n queueMicrotask(() => {\n menu.setPopupPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupPaginationItem, menuRef]);\n\n // Render menu button\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupMenuButton) return;\n queueMicrotask(() => {\n menu.setPopupMenuButton((buttonProps?: CourierInboxMenuButtonFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupMenuButton!(buttonProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupMenuButton, menuRef]);\n\n // Set feed type\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n queueMicrotask(() => {\n menu.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, menuRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox-popup-menu\n ref={menuRef}\n popup-alignment={props.popupAlignment}\n popup-width={props.popupWidth}\n popup-height={props.popupHeight}\n left={props.left}\n top={props.top}\n right={props.right}\n bottom={props.bottom}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n});\n\nCourierInboxPopupMenu.displayName = 'CourierInboxPopupMenu';","import React from 'react';\nimport { Courier, CourierProps, InboxMessage } from '@trycourier/courier-js';\nimport { CourierInboxDatastore, CourierInboxDataStoreListener, CourierInboxFeedType, InboxDataSet } from '@trycourier/courier-ui-inbox';\n\ntype AuthenticationHooks = {\n userId?: string,\n signIn: (props: CourierProps) => void,\n signOut: () => void\n}\n\ntype InboxHooks = {\n load: (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => Promise<void>,\n fetchNextPageOfMessages: (props: { feedType: CourierInboxFeedType }) => Promise<InboxDataSet | null>,\n setPaginationLimit: (limit: number) => void,\n readMessage: (message: InboxMessage) => Promise<void>,\n unreadMessage: (message: InboxMessage) => Promise<void>,\n clickMessage: (message: InboxMessage) => Promise<void>,\n archiveMessage: (message: InboxMessage) => Promise<void>,\n openMessage: (message: InboxMessage) => Promise<void>,\n unarchiveMessage: (message: InboxMessage) => Promise<void>,\n readAllMessages: () => Promise<void>,\n inbox?: InboxDataSet,\n archive?: InboxDataSet,\n unreadCount?: number,\n error?: Error\n}\n\n// A hook for managing the shared state of Courier\n// If you want to use more functions, checkout the Courier JS SDK which\n// can be used directly by importing from '@trycourier/courier-js'\nexport const useCourier = () => {\n\n // Authentication Functions\n const signIn = (props: CourierProps) => Courier.shared.signIn(props);\n const signOut = () => Courier.shared.signOut();\n\n // Inbox Functions\n const loadInbox = (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => CourierInboxDatastore.shared.load(props);\n const fetchNextPageOfMessages = (props: { feedType: CourierInboxFeedType }) => CourierInboxDatastore.shared.fetchNextPageOfMessages(props);\n const setPaginationLimit = (limit: number) => Courier.shared.paginationLimit = limit;\n const readMessage = (message: InboxMessage) => CourierInboxDatastore.shared.readMessage({ message });\n const unreadMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unreadMessage({ message });\n const clickMessage = (message: InboxMessage) => CourierInboxDatastore.shared.clickMessage({ message });\n const archiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.archiveMessage({ message });\n const openMessage = (message: InboxMessage) => CourierInboxDatastore.shared.openMessage({ message });\n const unarchiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unarchiveMessage({ message });\n const readAllMessages = () => CourierInboxDatastore.shared.readAllMessages();\n\n // State\n const [auth, setAuth] = React.useState<AuthenticationHooks>({\n userId: undefined,\n signIn,\n signOut\n });\n\n const [inbox, setInbox] = React.useState<InboxHooks>({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages\n });\n\n React.useEffect(() => {\n\n // Add a listener to the Courier instance\n const listener = Courier.shared.addAuthenticationListener(() => refreshAuth());\n\n // Add inbox data store listener\n const inboxListener = new CourierInboxDataStoreListener({\n onError: (error: Error) => refreshInbox(error),\n onDataSetChange: () => refreshInbox(),\n onPageAdded: () => refreshInbox(),\n onMessageAdd: () => refreshInbox(),\n onMessageRemove: () => refreshInbox(),\n onMessageUpdate: () => refreshInbox(),\n onUnreadCountChange: () => refreshInbox()\n });\n CourierInboxDatastore.shared.addDataStoreListener(inboxListener);\n\n // Set initial values\n refreshAuth();\n refreshInbox();\n\n // Remove listeners when the component unmounts\n return () => {\n listener.remove();\n inboxListener.remove();\n };\n }, []);\n\n const refreshAuth = () => {\n const options = Courier.shared.client?.options;\n setAuth({\n userId: options?.userId,\n signIn,\n signOut\n });\n }\n\n const refreshInbox = (error?: Error) => {\n const datastore = CourierInboxDatastore.shared;\n setInbox({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages,\n inbox: datastore.inboxDataSet,\n archive: datastore.archiveDataSet,\n unreadCount: datastore.unreadCount,\n error: error,\n });\n }\n\n return {\n shared: Courier.shared,\n auth: auth,\n inbox: inbox,\n };\n};\n"],"names":["reactNodeToHTMLElement","node","container","document","createElement","root","createRoot","flushSync","render","element","firstElementChild","HTMLElement","Error","CourierClientComponent","children","isMounted","setIsMounted","useState","useEffect","window","CourierInbox","forwardRef","props","ref","inboxRef","useRef","current","inbox","onMessageClick","onMessageActionClick","onMessageLongPress","renderHeader","queueMicrotask","setHeader","headerProps","renderListItem","setListItem","itemProps","renderEmptyState","setEmptyState","emptyStateProps","renderLoadingState","setLoadingState","loadingStateProps","renderErrorState","setErrorState","errorStateProps","renderPaginationItem","setPaginationItem","paginationProps","setFeedType","feedType","jsxRuntime","jsx","height","lightTheme","JSON","stringify","darkTheme","mode","displayName","CourierInboxPopupMenu","menuRef","menu","renderPopupHeader","setPopupHeader","renderPopupListItem","setPopupListItem","renderPopupEmptyState","setPopupEmptyState","renderPopupLoadingState","setPopupLoadingState","renderPopupErrorState","setPopupErrorState","renderPopupPaginationItem","setPopupPaginationItem","renderPopupMenuButton","setPopupMenuButton","buttonProps","popupAlignment","popupWidth","popupHeight","left","top","right","bottom","signIn","Courier","shared","signOut","loadInbox","CourierInboxDatastore","load","fetchNextPageOfMessages","setPaginationLimit","limit","paginationLimit","readMessage","message","unreadMessage","clickMessage","archiveMessage","openMessage","unarchiveMessage","readAllMessages","auth","setAuth","React","userId","setInbox","listener","addAuthenticationListener","refreshAuth","inboxListener","CourierInboxDataStoreListener","onError","error","refreshInbox","onDataSetChange","onPageAdded","onMessageAdd","onMessageRemove","onMessageUpdate","onUnreadCountChange","addDataStoreListener","remove","options","client","_a","datastore","inboxDataSet","archive","archiveDataSet","unreadCount"],"mappings":"2QAUO,SAASA,EAAuBC,GAC/B,MAAAC,EAAYC,SAASC,cAAc,OAGnCC,EAAOC,aAAWJ,GACxBK,EAAAA,WAAU,KACRF,EAAKG,OAAOP,EAAI,IAIlB,MAAMQ,EAAUP,EAAUQ,kBACtB,KAAED,aAAmBE,aACvB,MAAM,IAAIC,MACR,gGAIG,OAAAH,CACT,CCnBO,MAAMI,EAAuD,EAAGC,eACrE,MAAOC,EAAWC,GAAgBC,EAAAA,UAAS,GAOvC,OALJC,EAAAA,WAAU,KACRF,GAAa,EAAI,GAChB,IA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BACAC,eACAC,iBACAC,cACAC,mBACAC,kBACA7E,MAAOsG,EAAUC,aACjBC,QAASF,EAAUG,eACnBC,YAAaJ,EAAUI,YACvBjB,SACD,EAGI,MAAA,CACL5B,OAAQD,EAAQA,QAAAC,OAChBiB,OACA9E,QACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/utils/utils.tsx","../src/components/courier-client-component.tsx","../src/components/courier-inbox.tsx","../src/components/courier-inbox-popup-menu.tsx","../src/hooks/use-courier.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { createRoot } from \"react-dom/client\";\n\n/**\n * Converts a React node to an HTMLElement.\n * This function uses flushSync to ensure the DOM is updated synchronously.\n * @param node - The React node to convert.\n * @returns The converted HTMLElement.\n */\nexport function reactNodeToHTMLElement(node: ReactNode): HTMLElement {\n const container = document.createElement('div');\n\n // Use React 18 root\n const root = createRoot(container);\n flushSync(() => {\n root.render(node);\n });\n\n // Wait until React mounts the content synchronously\n const element = container.firstElementChild;\n if (!(element instanceof HTMLElement)) {\n throw new Error(\n 'renderListItem must return a single JSX element that renders to an HTMLElement (e.g., <div>)'\n );\n }\n\n return element;\n}","import React, { useState, useEffect } from 'react';\n\ninterface CourierClientProps {\n children: React.ReactNode;\n}\n\n// This class prevents issues with server side rendering react components\n// It will force the component to only render client side\n// A future update could support server side rendering if there is enough demand\nexport const CourierClientComponent: React.FC<CourierClientProps> = ({ children }) => {\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n // During SSR, render nothing or fallback\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (!isMounted) {\n return null;\n }\n\n return <>{children}</>;\n};","import { useRef, useEffect, forwardRef, ReactNode } from \"react\";\nimport { CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxTheme, CourierInbox as CourierInboxElement, CourierInboxHeaderFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxFeedType } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxProps {\n height?: string;\n lightTheme?: CourierInboxTheme;\n darkTheme?: CourierInboxTheme;\n mode?: CourierComponentThemeMode;\n feedType?: CourierInboxFeedType;\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;\n}\n\nexport const CourierInbox = forwardRef<CourierInboxElement, CourierInboxProps>((props, ref) => {\n const inboxRef = useRef<CourierInboxElement | null>(null);\n\n // Expose the internal ref to the parent if a ref was passed in\n useEffect(() => {\n if (typeof ref === \"function\") {\n ref(inboxRef.current);\n } else if (ref) {\n (ref as React.RefObject<CourierInboxElement | null>).current = inboxRef.current;\n }\n }, [ref]);\n\n // Handle message click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, inboxRef]);\n\n // Handle message action click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, inboxRef]);\n\n // Handle message long press\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, inboxRef]);\n\n // Render header\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderHeader) return;\n queueMicrotask(() => {\n inbox.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader, inboxRef]);\n\n // Render list item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderListItem) return;\n queueMicrotask(() => {\n inbox.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem, inboxRef]);\n\n // Render empty state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderEmptyState) return;\n queueMicrotask(() => {\n inbox.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState, inboxRef]);\n\n // Render loading state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderLoadingState) return;\n queueMicrotask(() => {\n inbox.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState, inboxRef]);\n\n // Render error state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderErrorState) return;\n queueMicrotask(() => {\n inbox.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState, inboxRef]);\n\n // Render pagination item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n inbox.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem, inboxRef]);\n\n // Set feed type\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n queueMicrotask(() => {\n inbox.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, inboxRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox\n ref={inboxRef}\n height={props.height}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n});\n\nCourierInbox.displayName = 'CourierInbox';","import { useRef, useEffect, forwardRef, ReactNode } from \"react\";\nimport { CourierInboxFeedType, CourierInboxHeaderFactoryProps, CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxMenuButtonFactoryProps, CourierInboxPopupMenu as CourierInboxPopupMenuElement, CourierInboxPaginationItemFactoryProps, CourierInboxPopupAlignment, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxTheme } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxPopupMenuProps {\n popupAlignment?: CourierInboxPopupAlignment;\n popupWidth?: string;\n popupHeight?: string;\n left?: string;\n top?: string;\n right?: string;\n bottom?: string;\n lightTheme?: CourierInboxTheme;\n darkTheme?: CourierInboxTheme;\n mode?: CourierComponentThemeMode;\n feedType?: CourierInboxFeedType;\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;\n renderMenuButton?: (props: CourierInboxMenuButtonFactoryProps | undefined | null) => ReactNode;\n}\n\nexport const CourierInboxPopupMenu = forwardRef<CourierInboxPopupMenuElement, CourierInboxPopupMenuProps>((props, ref) => {\n const menuRef = useRef<CourierInboxPopupMenuElement>(null);\n\n // Expose the internal ref to the parent if a ref was passed in\n useEffect(() => {\n if (typeof ref === \"function\") {\n ref(menuRef.current);\n } else if (ref) {\n (ref as React.RefObject<CourierInboxPopupMenuElement | null>).current = menuRef.current;\n }\n }, [ref]);\n\n // Handle message click\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, menuRef]);\n\n // Handle message action click\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, menuRef]);\n\n // Handle message long press\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, menuRef]);\n\n // Render header\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderHeader) return;\n queueMicrotask(() => {\n menu.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader, menuRef]);\n\n // Render list item\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderListItem) return;\n queueMicrotask(() => {\n menu.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem, menuRef]);\n\n // Render empty state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderEmptyState) return;\n queueMicrotask(() => {\n menu.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState, menuRef]);\n\n // Render loading state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderLoadingState) return;\n queueMicrotask(() => {\n menu.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState, menuRef]);\n\n // Render error state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderErrorState) return;\n queueMicrotask(() => {\n menu.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState, menuRef]);\n\n // Render pagination item\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n menu.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem, menuRef]);\n\n // Render menu button\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderMenuButton) return;\n queueMicrotask(() => {\n menu.setMenuButton((buttonProps?: CourierInboxMenuButtonFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderMenuButton!(buttonProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderMenuButton, menuRef]);\n\n // Set feed type\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n queueMicrotask(() => {\n menu.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, menuRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox-popup-menu\n ref={menuRef}\n popup-alignment={props.popupAlignment}\n popup-width={props.popupWidth}\n popup-height={props.popupHeight}\n left={props.left}\n top={props.top}\n right={props.right}\n bottom={props.bottom}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n});\n\nCourierInboxPopupMenu.displayName = 'CourierInboxPopupMenu';","import React from 'react';\nimport { Courier, CourierProps, InboxMessage } from '@trycourier/courier-js';\nimport { CourierInboxDatastore, CourierInboxDataStoreListener, CourierInboxFeedType, InboxDataSet } from '@trycourier/courier-ui-inbox';\n\ntype AuthenticationHooks = {\n userId?: string,\n signIn: (props: CourierProps) => void,\n signOut: () => void\n}\n\ntype InboxHooks = {\n load: (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => Promise<void>,\n fetchNextPageOfMessages: (props: { feedType: CourierInboxFeedType }) => Promise<InboxDataSet | null>,\n setPaginationLimit: (limit: number) => void,\n readMessage: (message: InboxMessage) => Promise<void>,\n unreadMessage: (message: InboxMessage) => Promise<void>,\n clickMessage: (message: InboxMessage) => Promise<void>,\n archiveMessage: (message: InboxMessage) => Promise<void>,\n openMessage: (message: InboxMessage) => Promise<void>,\n unarchiveMessage: (message: InboxMessage) => Promise<void>,\n readAllMessages: () => Promise<void>,\n inbox?: InboxDataSet,\n archive?: InboxDataSet,\n unreadCount?: number,\n error?: Error\n}\n\n// A hook for managing the shared state of Courier\n// If you want to use more functions, checkout the Courier JS SDK which\n// can be used directly by importing from '@trycourier/courier-js'\nexport const useCourier = () => {\n\n // Authentication Functions\n const signIn = (props: CourierProps) => Courier.shared.signIn(props);\n const signOut = () => Courier.shared.signOut();\n\n // Inbox Functions\n const loadInbox = (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => CourierInboxDatastore.shared.load(props);\n const fetchNextPageOfMessages = (props: { feedType: CourierInboxFeedType }) => CourierInboxDatastore.shared.fetchNextPageOfMessages(props);\n const setPaginationLimit = (limit: number) => Courier.shared.paginationLimit = limit;\n const readMessage = (message: InboxMessage) => CourierInboxDatastore.shared.readMessage({ message });\n const unreadMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unreadMessage({ message });\n const clickMessage = (message: InboxMessage) => CourierInboxDatastore.shared.clickMessage({ message });\n const archiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.archiveMessage({ message });\n const openMessage = (message: InboxMessage) => CourierInboxDatastore.shared.openMessage({ message });\n const unarchiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unarchiveMessage({ message });\n const readAllMessages = () => CourierInboxDatastore.shared.readAllMessages();\n\n // State\n const [auth, setAuth] = React.useState<AuthenticationHooks>({\n userId: undefined,\n signIn,\n signOut\n });\n\n const [inbox, setInbox] = React.useState<InboxHooks>({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages\n });\n\n React.useEffect(() => {\n\n // Add a listener to the Courier instance\n const listener = Courier.shared.addAuthenticationListener(() => refreshAuth());\n\n // Add inbox data store listener\n const inboxListener = new CourierInboxDataStoreListener({\n onError: (error: Error) => refreshInbox(error),\n onDataSetChange: () => refreshInbox(),\n onPageAdded: () => refreshInbox(),\n onMessageAdd: () => refreshInbox(),\n onMessageRemove: () => refreshInbox(),\n onMessageUpdate: () => refreshInbox(),\n onUnreadCountChange: () => refreshInbox()\n });\n CourierInboxDatastore.shared.addDataStoreListener(inboxListener);\n\n // Set initial values\n refreshAuth();\n refreshInbox();\n\n // Remove listeners when the component unmounts\n return () => {\n listener.remove();\n inboxListener.remove();\n };\n }, []);\n\n const refreshAuth = () => {\n const options = Courier.shared.client?.options;\n setAuth({\n userId: options?.userId,\n signIn,\n signOut\n });\n }\n\n const refreshInbox = (error?: Error) => {\n const datastore = CourierInboxDatastore.shared;\n setInbox({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages,\n inbox: datastore.inboxDataSet,\n archive: datastore.archiveDataSet,\n unreadCount: datastore.unreadCount,\n error: error,\n });\n }\n\n return {\n shared: Courier.shared,\n auth: auth,\n inbox: inbox,\n };\n};\n"],"names":["reactNodeToHTMLElement","node","container","document","createElement","root","createRoot","flushSync","render","element","firstElementChild","HTMLElement","Error","CourierClientComponent","children","isMounted","setIsMounted","useState","useEffect","window","CourierInbox","forwardRef","props","ref","inboxRef","useRef","current","inbox","onMessageClick","onMessageActionClick","onMessageLongPress","renderHeader","queueMicrotask","setHeader","headerProps","renderListItem","setListItem","itemProps","renderEmptyState","setEmptyState","emptyStateProps","renderLoadingState","setLoadingState","loadingStateProps","renderErrorState","setErrorState","errorStateProps","renderPaginationItem","setPaginationItem","paginationProps","setFeedType","feedType","jsx","height","lightTheme","JSON","stringify","darkTheme","mode","displayName","CourierInboxPopupMenu","menuRef","menu","renderMenuButton","setMenuButton","buttonProps","popupAlignment","popupWidth","popupHeight","left","top","right","bottom","signIn","Courier","shared","signOut","loadInbox","CourierInboxDatastore","load","fetchNextPageOfMessages","setPaginationLimit","limit","paginationLimit","readMessage","message","unreadMessage","clickMessage","archiveMessage","openMessage","unarchiveMessage","readAllMessages","auth","setAuth","React","userId","setInbox","listener","addAuthenticationListener","refreshAuth","inboxListener","CourierInboxDataStoreListener","onError","error","refreshInbox","onDataSetChange","onPageAdded","onMessageAdd","onMessageRemove","onMessageUpdate","onUnreadCountChange","addDataStoreListener","remove","options","client","datastore","inboxDataSet","archive","archiveDataSet","unreadCount"],"mappings":"2QAUO,SAASA,EAAuBC,GACrC,MAAMC,EAAYC,SAASC,cAAc,OAGnCC,EAAOC,EAAAA,WAAWJ,GACxBK,EAAAA,WAAU,KACRF,EAAKG,OAAOP,EAAI,IAIlB,MAAMQ,EAAUP,EAAUQ,kBAC1B,KAAMD,aAAmBE,aACvB,MAAM,IAAIC,MACR,gGAIJ,OAAOH,CACT,CCnBO,MAAMI,EAAuD,EAAGC,eACrE,MAAOC,EAAWC,GAAgBC,EAAAA,UAAS,GAO3C,OALAC,EAAAA,WAAU,KACRF,GAAa,EAAI,GAChB,IAGmB,oBAAXG,OACF,KAGJJ,oBAIKD,aAHD,IAGU,ECFRM,EAAeC,EAAAA,YAAmD,CAACC,EAAOC,KACrF,MAAMC,EAAWC,EAAAA,OAAmC,MAiHpD,OA9GAP,EAAAA,WAAU,KACW,mBAARK,EACTA,EAAIC,EAASE,SACJH,IACRA,EAAoDG,QAAUF,EAASE,QAC1E,GACC,CAACH,IAGJL,EAAAA,WAAU,KACR,MAAMS,EAAQH,EAASE,QAClBC,GACLA,EAAMC,eAAeN,EAAMM,eAAc,GACxC,CAACN,EAAMM,eAAgBJ,IAG1BN,EAAAA,WAAU,KACR,MAAMS,EAAQH,EAASE,QAClBC,GACLA,EAAME,qBAAqBP,EAAMO,qBAAoB,GACpD,CAACP,EAAMO,qBAAsBL,IAGhCN,EAAAA,WAAU,KACR,MAAMS,EAAQH,EAASE,QAClBC,GACLA,EAAMG,mBAAmBR,EAAMQ,mBAAkB,GAChD,CAACR,EAAMQ,mBAAoBN,IAG9BN,EAAAA,WAAU,KACR,MAAMS,EAAQH,EAASE,QAClBC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,QAAUC,GAAiBC,EAAaD,GACxCE,gBAAiB,IAAMD,IACvBE,YAAa,IAAMF,IACnBG,aAAc,IAAMH,IACpBI,gBAAiB,IAAMJ,IACvBK,gBAAiB,IAAML,IACvBM,oBAAqB,IAAMN,MAS7B,OAPA1B,wBAAsBH,OAAOoC,qBAAqBX,GAGlDD,IACAK,IAGO,KACLP,EAASe,SACTZ,EAAcY,QAAA,CAChB,GACC,IAEH,MAAMb,EAAc,WAClB,MAAMc,EAAUvC,OAAAA,EAAAA,EAAAA,QAAQC,OAAOuC,aAAfxC,EAAAA,EAAuBuC,QACvCpB,EAAQ,CACNE,OAAQ,MAAAkB,OAAA,EAAAA,EAASlB,OACjBtB,SACAG,WACD,EAGG4B,EAAgBD,IACpB,MAAMY,EAAYrC,EAAAA,sBAAsBH,OACxCqB,EAAS,CACPjB,KAAMF,EACNG,0BACAC,qBACAG,cACAE,gBACAC,eACAC,iBACAC,cACAC,mBACAC,kBACAhE,MAAOwF,EAAUC,aACjBC,QAASF,EAAUG,eACnBC,YAAaJ,EAAUI,YACvBhB,SACD,EAGH,MAAO,CACL5B,OAAQD,EAAAA,QAAQC,OAChBiB,OACAjE,QAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export { markAsRead, markAsUnread, clickMessage, archiveMessage, openMessage } f
|
|
|
6
6
|
export type { CourierInboxHeaderFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxListItemFactoryProps, CourierInboxListItemActionFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxMenuButtonFactoryProps, CourierInboxFeedType } from '@trycourier/courier-ui-inbox';
|
|
7
7
|
export type { CourierInboxTheme, CourierInboxFontTheme, CourierInboxIconTheme, CourierInboxFilterItemTheme, CourierInboxUnreadIndicatorTheme, CourierInboxIconButtonTheme, CourierInboxButtonTheme, CourierInboxMenuButtonTheme, CourierInboxPopupTheme, CourierInboxListItemTheme, CourierInboxSkeletonLoadingStateTheme, CourierInboxInfoStateTheme, CourierMenuItemTheme, CourierFilterMenuTheme, CourierActionMenuTheme } from '@trycourier/courier-ui-inbox';
|
|
8
8
|
export { defaultLightTheme, defaultDarkTheme, mergeTheme } from '@trycourier/courier-ui-inbox';
|
|
9
|
+
export type { CourierComponentThemeMode } from '@trycourier/courier-ui-core';
|
package/dist/index.mjs
CHANGED
|
@@ -244,74 +244,74 @@ const CourierInboxPopupMenu = forwardRef((props, ref) => {
|
|
|
244
244
|
}, [props.onMessageLongPress, menuRef]);
|
|
245
245
|
useEffect(() => {
|
|
246
246
|
const menu = menuRef.current;
|
|
247
|
-
if (!menu || !props.
|
|
247
|
+
if (!menu || !props.renderHeader) return;
|
|
248
248
|
queueMicrotask(() => {
|
|
249
|
-
menu.
|
|
250
|
-
const reactNode = props.
|
|
249
|
+
menu.setHeader((headerProps) => {
|
|
250
|
+
const reactNode = props.renderHeader(headerProps);
|
|
251
251
|
return reactNodeToHTMLElement(reactNode);
|
|
252
252
|
});
|
|
253
253
|
});
|
|
254
|
-
}, [props.
|
|
254
|
+
}, [props.renderHeader, menuRef]);
|
|
255
255
|
useEffect(() => {
|
|
256
256
|
const menu = menuRef.current;
|
|
257
|
-
if (!menu || !props.
|
|
257
|
+
if (!menu || !props.renderListItem) return;
|
|
258
258
|
queueMicrotask(() => {
|
|
259
|
-
menu.
|
|
260
|
-
const reactNode = props.
|
|
259
|
+
menu.setListItem((itemProps) => {
|
|
260
|
+
const reactNode = props.renderListItem(itemProps);
|
|
261
261
|
return reactNodeToHTMLElement(reactNode);
|
|
262
262
|
});
|
|
263
263
|
});
|
|
264
|
-
}, [props.
|
|
264
|
+
}, [props.renderListItem, menuRef]);
|
|
265
265
|
useEffect(() => {
|
|
266
266
|
const menu = menuRef.current;
|
|
267
|
-
if (!menu || !props.
|
|
267
|
+
if (!menu || !props.renderEmptyState) return;
|
|
268
268
|
queueMicrotask(() => {
|
|
269
|
-
menu.
|
|
270
|
-
const reactNode = props.
|
|
269
|
+
menu.setEmptyState((emptyStateProps) => {
|
|
270
|
+
const reactNode = props.renderEmptyState(emptyStateProps);
|
|
271
271
|
return reactNodeToHTMLElement(reactNode);
|
|
272
272
|
});
|
|
273
273
|
});
|
|
274
|
-
}, [props.
|
|
274
|
+
}, [props.renderEmptyState, menuRef]);
|
|
275
275
|
useEffect(() => {
|
|
276
276
|
const menu = menuRef.current;
|
|
277
|
-
if (!menu || !props.
|
|
277
|
+
if (!menu || !props.renderLoadingState) return;
|
|
278
278
|
queueMicrotask(() => {
|
|
279
|
-
menu.
|
|
280
|
-
const reactNode = props.
|
|
279
|
+
menu.setLoadingState((loadingStateProps) => {
|
|
280
|
+
const reactNode = props.renderLoadingState(loadingStateProps);
|
|
281
281
|
return reactNodeToHTMLElement(reactNode);
|
|
282
282
|
});
|
|
283
283
|
});
|
|
284
|
-
}, [props.
|
|
284
|
+
}, [props.renderLoadingState, menuRef]);
|
|
285
285
|
useEffect(() => {
|
|
286
286
|
const menu = menuRef.current;
|
|
287
|
-
if (!menu || !props.
|
|
287
|
+
if (!menu || !props.renderErrorState) return;
|
|
288
288
|
queueMicrotask(() => {
|
|
289
|
-
menu.
|
|
290
|
-
const reactNode = props.
|
|
289
|
+
menu.setErrorState((errorStateProps) => {
|
|
290
|
+
const reactNode = props.renderErrorState(errorStateProps);
|
|
291
291
|
return reactNodeToHTMLElement(reactNode);
|
|
292
292
|
});
|
|
293
293
|
});
|
|
294
|
-
}, [props.
|
|
294
|
+
}, [props.renderErrorState, menuRef]);
|
|
295
295
|
useEffect(() => {
|
|
296
296
|
const menu = menuRef.current;
|
|
297
|
-
if (!menu || !props.
|
|
297
|
+
if (!menu || !props.renderPaginationItem) return;
|
|
298
298
|
queueMicrotask(() => {
|
|
299
|
-
menu.
|
|
300
|
-
const reactNode = props.
|
|
299
|
+
menu.setPaginationItem((paginationProps) => {
|
|
300
|
+
const reactNode = props.renderPaginationItem(paginationProps);
|
|
301
301
|
return reactNodeToHTMLElement(reactNode);
|
|
302
302
|
});
|
|
303
303
|
});
|
|
304
|
-
}, [props.
|
|
304
|
+
}, [props.renderPaginationItem, menuRef]);
|
|
305
305
|
useEffect(() => {
|
|
306
306
|
const menu = menuRef.current;
|
|
307
|
-
if (!menu || !props.
|
|
307
|
+
if (!menu || !props.renderMenuButton) return;
|
|
308
308
|
queueMicrotask(() => {
|
|
309
|
-
menu.
|
|
310
|
-
const reactNode = props.
|
|
309
|
+
menu.setMenuButton((buttonProps) => {
|
|
310
|
+
const reactNode = props.renderMenuButton(buttonProps);
|
|
311
311
|
return reactNodeToHTMLElement(reactNode);
|
|
312
312
|
});
|
|
313
313
|
});
|
|
314
|
-
}, [props.
|
|
314
|
+
}, [props.renderMenuButton, menuRef]);
|
|
315
315
|
useEffect(() => {
|
|
316
316
|
const menu = menuRef.current;
|
|
317
317
|
if (!menu) return;
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/hooks/use-courier.tsx","../src/utils/utils.tsx","../src/components/courier-client-component.tsx","../src/components/courier-inbox.tsx","../src/components/courier-inbox-popup-menu.tsx"],"sourcesContent":["import React from 'react';\nimport { Courier, CourierProps, InboxMessage } from '@trycourier/courier-js';\nimport { CourierInboxDatastore, CourierInboxDataStoreListener, CourierInboxFeedType, InboxDataSet } from '@trycourier/courier-ui-inbox';\n\ntype AuthenticationHooks = {\n userId?: string,\n signIn: (props: CourierProps) => void,\n signOut: () => void\n}\n\ntype InboxHooks = {\n load: (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => Promise<void>,\n fetchNextPageOfMessages: (props: { feedType: CourierInboxFeedType }) => Promise<InboxDataSet | null>,\n setPaginationLimit: (limit: number) => void,\n readMessage: (message: InboxMessage) => Promise<void>,\n unreadMessage: (message: InboxMessage) => Promise<void>,\n clickMessage: (message: InboxMessage) => Promise<void>,\n archiveMessage: (message: InboxMessage) => Promise<void>,\n openMessage: (message: InboxMessage) => Promise<void>,\n unarchiveMessage: (message: InboxMessage) => Promise<void>,\n readAllMessages: () => Promise<void>,\n inbox?: InboxDataSet,\n archive?: InboxDataSet,\n unreadCount?: number,\n error?: Error\n}\n\n// A hook for managing the shared state of Courier\n// If you want to use more functions, checkout the Courier JS SDK which\n// can be used directly by importing from '@trycourier/courier-js'\nexport const useCourier = () => {\n\n // Authentication Functions\n const signIn = (props: CourierProps) => Courier.shared.signIn(props);\n const signOut = () => Courier.shared.signOut();\n\n // Inbox Functions\n const loadInbox = (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => CourierInboxDatastore.shared.load(props);\n const fetchNextPageOfMessages = (props: { feedType: CourierInboxFeedType }) => CourierInboxDatastore.shared.fetchNextPageOfMessages(props);\n const setPaginationLimit = (limit: number) => Courier.shared.paginationLimit = limit;\n const readMessage = (message: InboxMessage) => CourierInboxDatastore.shared.readMessage({ message });\n const unreadMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unreadMessage({ message });\n const clickMessage = (message: InboxMessage) => CourierInboxDatastore.shared.clickMessage({ message });\n const archiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.archiveMessage({ message });\n const openMessage = (message: InboxMessage) => CourierInboxDatastore.shared.openMessage({ message });\n const unarchiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unarchiveMessage({ message });\n const readAllMessages = () => CourierInboxDatastore.shared.readAllMessages();\n\n // State\n const [auth, setAuth] = React.useState<AuthenticationHooks>({\n userId: undefined,\n signIn,\n signOut\n });\n\n const [inbox, setInbox] = React.useState<InboxHooks>({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages\n });\n\n React.useEffect(() => {\n\n // Add a listener to the Courier instance\n const listener = Courier.shared.addAuthenticationListener(() => refreshAuth());\n\n // Add inbox data store listener\n const inboxListener = new CourierInboxDataStoreListener({\n onError: (error: Error) => refreshInbox(error),\n onDataSetChange: () => refreshInbox(),\n onPageAdded: () => refreshInbox(),\n onMessageAdd: () => refreshInbox(),\n onMessageRemove: () => refreshInbox(),\n onMessageUpdate: () => refreshInbox(),\n onUnreadCountChange: () => refreshInbox()\n });\n CourierInboxDatastore.shared.addDataStoreListener(inboxListener);\n\n // Set initial values\n refreshAuth();\n refreshInbox();\n\n // Remove listeners when the component unmounts\n return () => {\n listener.remove();\n inboxListener.remove();\n };\n }, []);\n\n const refreshAuth = () => {\n const options = Courier.shared.client?.options;\n setAuth({\n userId: options?.userId,\n signIn,\n signOut\n });\n }\n\n const refreshInbox = (error?: Error) => {\n const datastore = CourierInboxDatastore.shared;\n setInbox({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages,\n inbox: datastore.inboxDataSet,\n archive: datastore.archiveDataSet,\n unreadCount: datastore.unreadCount,\n error: error,\n });\n }\n\n return {\n shared: Courier.shared,\n auth: auth,\n inbox: inbox,\n };\n};\n","import { ReactNode } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { createRoot } from \"react-dom/client\";\n\n/**\n * Converts a React node to an HTMLElement.\n * This function uses flushSync to ensure the DOM is updated synchronously.\n * @param node - The React node to convert.\n * @returns The converted HTMLElement.\n */\nexport function reactNodeToHTMLElement(node: ReactNode): HTMLElement {\n const container = document.createElement('div');\n\n // Use React 18 root\n const root = createRoot(container);\n flushSync(() => {\n root.render(node);\n });\n\n // Wait until React mounts the content synchronously\n const element = container.firstElementChild;\n if (!(element instanceof HTMLElement)) {\n throw new Error(\n 'renderListItem must return a single JSX element that renders to an HTMLElement (e.g., <div>)'\n );\n }\n\n return element;\n}","import React, { useState, useEffect } from 'react';\n\ninterface CourierClientProps {\n children: React.ReactNode;\n}\n\n// This class prevents issues with server side rendering react components\n// It will force the component to only render client side\n// A future update could support server side rendering if there is enough demand\nexport const CourierClientComponent: React.FC<CourierClientProps> = ({ children }) => {\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n // During SSR, render nothing or fallback\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (!isMounted) {\n return null;\n }\n\n return <>{children}</>;\n};","import { useRef, useEffect, JSX, forwardRef } from \"react\";\nimport { CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxTheme, CourierInbox as CourierInboxElement, CourierInboxHeaderFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxFeedType } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxProps {\n height?: string;\n lightTheme?: CourierInboxTheme;\n darkTheme?: CourierInboxTheme;\n mode?: CourierComponentThemeMode;\n feedType?: CourierInboxFeedType;\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => JSX.Element;\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => JSX.Element;\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => JSX.Element;\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => JSX.Element;\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => JSX.Element;\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => JSX.Element;\n}\n\nexport const CourierInbox = forwardRef<CourierInboxElement, CourierInboxProps>((props, ref) => {\n const inboxRef = useRef<CourierInboxElement | null>(null);\n\n // Expose the internal ref to the parent if a ref was passed in\n useEffect(() => {\n if (typeof ref === \"function\") {\n ref(inboxRef.current);\n } else if (ref) {\n (ref as React.RefObject<CourierInboxElement | null>).current = inboxRef.current;\n }\n }, [ref]);\n\n // Handle message click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, inboxRef]);\n\n // Handle message action click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, inboxRef]);\n\n // Handle message long press\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, inboxRef]);\n\n // Render header\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderHeader) return;\n queueMicrotask(() => {\n inbox.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader, inboxRef]);\n\n // Render list item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderListItem) return;\n queueMicrotask(() => {\n inbox.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem, inboxRef]);\n\n // Render empty state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderEmptyState) return;\n queueMicrotask(() => {\n inbox.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState, inboxRef]);\n\n // Render loading state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderLoadingState) return;\n queueMicrotask(() => {\n inbox.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState, inboxRef]);\n\n // Render error state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderErrorState) return;\n queueMicrotask(() => {\n inbox.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState, inboxRef]);\n\n // Render pagination item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n inbox.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem, inboxRef]);\n\n // Set feed type\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n queueMicrotask(() => {\n inbox.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, inboxRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox\n ref={inboxRef}\n height={props.height}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n});\n\nCourierInbox.displayName = 'CourierInbox';","import { useRef, useEffect, JSX, forwardRef } from \"react\";\nimport { CourierInboxFeedType, CourierInboxHeaderFactoryProps, CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxMenuButtonFactoryProps, CourierInboxPopupMenu as CourierInboxPopupMenuElement, CourierInboxPaginationItemFactoryProps, CourierInboxPopupAlignment, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxTheme } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxPopupMenuProps {\n popupAlignment?: CourierInboxPopupAlignment;\n popupWidth?: string;\n popupHeight?: string;\n left?: string;\n top?: string;\n right?: string;\n bottom?: string;\n lightTheme?: CourierInboxTheme;\n darkTheme?: CourierInboxTheme;\n mode?: CourierComponentThemeMode;\n feedType?: CourierInboxFeedType;\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n renderPopupHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => JSX.Element;\n renderPopupListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => JSX.Element;\n renderPopupEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => JSX.Element;\n renderPopupLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => JSX.Element;\n renderPopupErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => JSX.Element;\n renderPopupPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => JSX.Element;\n renderPopupMenuButton?: (props: CourierInboxMenuButtonFactoryProps | undefined | null) => JSX.Element;\n}\n\nexport const CourierInboxPopupMenu = forwardRef<CourierInboxPopupMenuElement, CourierInboxPopupMenuProps>((props, ref) => {\n const menuRef = useRef<CourierInboxPopupMenuElement>(null);\n\n // Expose the internal ref to the parent if a ref was passed in\n useEffect(() => {\n if (typeof ref === \"function\") {\n ref(menuRef.current);\n } else if (ref) {\n (ref as React.RefObject<CourierInboxPopupMenuElement | null>).current = menuRef.current;\n }\n }, [ref]);\n\n // Handle message click\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, menuRef]);\n\n // Handle message action click\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, menuRef]);\n\n // Handle message long press\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, menuRef]);\n\n // Render header\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupHeader) return;\n queueMicrotask(() => {\n menu.setPopupHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupHeader, menuRef]);\n\n // Render list item\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupListItem) return;\n queueMicrotask(() => {\n menu.setPopupListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupListItem, menuRef]);\n\n // Render empty state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupEmptyState) return;\n queueMicrotask(() => {\n menu.setPopupEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupEmptyState, menuRef]);\n\n // Render loading state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupLoadingState) return;\n queueMicrotask(() => {\n menu.setPopupLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupLoadingState, menuRef]);\n\n // Render error state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupErrorState) return;\n queueMicrotask(() => {\n menu.setPopupErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupErrorState, menuRef]);\n\n // Render pagination item\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupPaginationItem) return;\n queueMicrotask(() => {\n menu.setPopupPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupPaginationItem, menuRef]);\n\n // Render menu button\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPopupMenuButton) return;\n queueMicrotask(() => {\n menu.setPopupMenuButton((buttonProps?: CourierInboxMenuButtonFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPopupMenuButton!(buttonProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPopupMenuButton, menuRef]);\n\n // Set feed type\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n queueMicrotask(() => {\n menu.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, menuRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox-popup-menu\n ref={menuRef}\n popup-alignment={props.popupAlignment}\n popup-width={props.popupWidth}\n popup-height={props.popupHeight}\n left={props.left}\n top={props.top}\n right={props.right}\n bottom={props.bottom}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n});\n\nCourierInboxPopupMenu.displayName = 'CourierInboxPopupMenu';"],"names":["clickMessage","archiveMessage","openMessage"],"mappings":";;;;;;;AA8BO,M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,mBAAiB,MAAM;AAAA,MACvB,eAAa,MAAM;AAAA,MACnB,gBAAc,MAAM;AAAA,MACpB,MAAM,MAAM;AAAA,MACZ,KAAK,MAAM;AAAA,MACX,OAAO,MAAM;AAAA,MACb,QAAQ,MAAM;AAAA,MACd,eAAa,MAAM,aAAa,KAAK,UAAU,MAAM,UAAU,IAAI;AAAA,MACnE,cAAY,MAAM,YAAY,KAAK,UAAU,MAAM,SAAS,IAAI;AAAA,MAChE,MAAM,MAAM;AAAA,IAAA;AAAA,EAAA,GAEhB;AAEJ,CAAC;AAED,sBAAsB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/hooks/use-courier.tsx","../src/utils/utils.tsx","../src/components/courier-client-component.tsx","../src/components/courier-inbox.tsx","../src/components/courier-inbox-popup-menu.tsx"],"sourcesContent":["import React from 'react';\nimport { Courier, CourierProps, InboxMessage } from '@trycourier/courier-js';\nimport { CourierInboxDatastore, CourierInboxDataStoreListener, CourierInboxFeedType, InboxDataSet } from '@trycourier/courier-ui-inbox';\n\ntype AuthenticationHooks = {\n userId?: string,\n signIn: (props: CourierProps) => void,\n signOut: () => void\n}\n\ntype InboxHooks = {\n load: (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => Promise<void>,\n fetchNextPageOfMessages: (props: { feedType: CourierInboxFeedType }) => Promise<InboxDataSet | null>,\n setPaginationLimit: (limit: number) => void,\n readMessage: (message: InboxMessage) => Promise<void>,\n unreadMessage: (message: InboxMessage) => Promise<void>,\n clickMessage: (message: InboxMessage) => Promise<void>,\n archiveMessage: (message: InboxMessage) => Promise<void>,\n openMessage: (message: InboxMessage) => Promise<void>,\n unarchiveMessage: (message: InboxMessage) => Promise<void>,\n readAllMessages: () => Promise<void>,\n inbox?: InboxDataSet,\n archive?: InboxDataSet,\n unreadCount?: number,\n error?: Error\n}\n\n// A hook for managing the shared state of Courier\n// If you want to use more functions, checkout the Courier JS SDK which\n// can be used directly by importing from '@trycourier/courier-js'\nexport const useCourier = () => {\n\n // Authentication Functions\n const signIn = (props: CourierProps) => Courier.shared.signIn(props);\n const signOut = () => Courier.shared.signOut();\n\n // Inbox Functions\n const loadInbox = (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => CourierInboxDatastore.shared.load(props);\n const fetchNextPageOfMessages = (props: { feedType: CourierInboxFeedType }) => CourierInboxDatastore.shared.fetchNextPageOfMessages(props);\n const setPaginationLimit = (limit: number) => Courier.shared.paginationLimit = limit;\n const readMessage = (message: InboxMessage) => CourierInboxDatastore.shared.readMessage({ message });\n const unreadMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unreadMessage({ message });\n const clickMessage = (message: InboxMessage) => CourierInboxDatastore.shared.clickMessage({ message });\n const archiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.archiveMessage({ message });\n const openMessage = (message: InboxMessage) => CourierInboxDatastore.shared.openMessage({ message });\n const unarchiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unarchiveMessage({ message });\n const readAllMessages = () => CourierInboxDatastore.shared.readAllMessages();\n\n // State\n const [auth, setAuth] = React.useState<AuthenticationHooks>({\n userId: undefined,\n signIn,\n signOut\n });\n\n const [inbox, setInbox] = React.useState<InboxHooks>({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages\n });\n\n React.useEffect(() => {\n\n // Add a listener to the Courier instance\n const listener = Courier.shared.addAuthenticationListener(() => refreshAuth());\n\n // Add inbox data store listener\n const inboxListener = new CourierInboxDataStoreListener({\n onError: (error: Error) => refreshInbox(error),\n onDataSetChange: () => refreshInbox(),\n onPageAdded: () => refreshInbox(),\n onMessageAdd: () => refreshInbox(),\n onMessageRemove: () => refreshInbox(),\n onMessageUpdate: () => refreshInbox(),\n onUnreadCountChange: () => refreshInbox()\n });\n CourierInboxDatastore.shared.addDataStoreListener(inboxListener);\n\n // Set initial values\n refreshAuth();\n refreshInbox();\n\n // Remove listeners when the component unmounts\n return () => {\n listener.remove();\n inboxListener.remove();\n };\n }, []);\n\n const refreshAuth = () => {\n const options = Courier.shared.client?.options;\n setAuth({\n userId: options?.userId,\n signIn,\n signOut\n });\n }\n\n const refreshInbox = (error?: Error) => {\n const datastore = CourierInboxDatastore.shared;\n setInbox({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages,\n inbox: datastore.inboxDataSet,\n archive: datastore.archiveDataSet,\n unreadCount: datastore.unreadCount,\n error: error,\n });\n }\n\n return {\n shared: Courier.shared,\n auth: auth,\n inbox: inbox,\n };\n};\n","import { ReactNode } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { createRoot } from \"react-dom/client\";\n\n/**\n * Converts a React node to an HTMLElement.\n * This function uses flushSync to ensure the DOM is updated synchronously.\n * @param node - The React node to convert.\n * @returns The converted HTMLElement.\n */\nexport function reactNodeToHTMLElement(node: ReactNode): HTMLElement {\n const container = document.createElement('div');\n\n // Use React 18 root\n const root = createRoot(container);\n flushSync(() => {\n root.render(node);\n });\n\n // Wait until React mounts the content synchronously\n const element = container.firstElementChild;\n if (!(element instanceof HTMLElement)) {\n throw new Error(\n 'renderListItem must return a single JSX element that renders to an HTMLElement (e.g., <div>)'\n );\n }\n\n return element;\n}","import React, { useState, useEffect } from 'react';\n\ninterface CourierClientProps {\n children: React.ReactNode;\n}\n\n// This class prevents issues with server side rendering react components\n// It will force the component to only render client side\n// A future update could support server side rendering if there is enough demand\nexport const CourierClientComponent: React.FC<CourierClientProps> = ({ children }) => {\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n // During SSR, render nothing or fallback\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (!isMounted) {\n return null;\n }\n\n return <>{children}</>;\n};","import { useRef, useEffect, forwardRef, ReactNode } from \"react\";\nimport { CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxTheme, CourierInbox as CourierInboxElement, CourierInboxHeaderFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxFeedType } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxProps {\n height?: string;\n lightTheme?: CourierInboxTheme;\n darkTheme?: CourierInboxTheme;\n mode?: CourierComponentThemeMode;\n feedType?: CourierInboxFeedType;\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;\n}\n\nexport const CourierInbox = forwardRef<CourierInboxElement, CourierInboxProps>((props, ref) => {\n const inboxRef = useRef<CourierInboxElement | null>(null);\n\n // Expose the internal ref to the parent if a ref was passed in\n useEffect(() => {\n if (typeof ref === \"function\") {\n ref(inboxRef.current);\n } else if (ref) {\n (ref as React.RefObject<CourierInboxElement | null>).current = inboxRef.current;\n }\n }, [ref]);\n\n // Handle message click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, inboxRef]);\n\n // Handle message action click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, inboxRef]);\n\n // Handle message long press\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, inboxRef]);\n\n // Render header\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderHeader) return;\n queueMicrotask(() => {\n inbox.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader, inboxRef]);\n\n // Render list item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderListItem) return;\n queueMicrotask(() => {\n inbox.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem, inboxRef]);\n\n // Render empty state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderEmptyState) return;\n queueMicrotask(() => {\n inbox.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState, inboxRef]);\n\n // Render loading state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderLoadingState) return;\n queueMicrotask(() => {\n inbox.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState, inboxRef]);\n\n // Render error state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderErrorState) return;\n queueMicrotask(() => {\n inbox.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState, inboxRef]);\n\n // Render pagination item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n inbox.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem, inboxRef]);\n\n // Set feed type\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n queueMicrotask(() => {\n inbox.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, inboxRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox\n ref={inboxRef}\n height={props.height}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n});\n\nCourierInbox.displayName = 'CourierInbox';","import { useRef, useEffect, forwardRef, ReactNode } from \"react\";\nimport { CourierInboxFeedType, CourierInboxHeaderFactoryProps, CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxMenuButtonFactoryProps, CourierInboxPopupMenu as CourierInboxPopupMenuElement, CourierInboxPaginationItemFactoryProps, CourierInboxPopupAlignment, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxTheme } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxPopupMenuProps {\n popupAlignment?: CourierInboxPopupAlignment;\n popupWidth?: string;\n popupHeight?: string;\n left?: string;\n top?: string;\n right?: string;\n bottom?: string;\n lightTheme?: CourierInboxTheme;\n darkTheme?: CourierInboxTheme;\n mode?: CourierComponentThemeMode;\n feedType?: CourierInboxFeedType;\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;\n renderMenuButton?: (props: CourierInboxMenuButtonFactoryProps | undefined | null) => ReactNode;\n}\n\nexport const CourierInboxPopupMenu = forwardRef<CourierInboxPopupMenuElement, CourierInboxPopupMenuProps>((props, ref) => {\n const menuRef = useRef<CourierInboxPopupMenuElement>(null);\n\n // Expose the internal ref to the parent if a ref was passed in\n useEffect(() => {\n if (typeof ref === \"function\") {\n ref(menuRef.current);\n } else if (ref) {\n (ref as React.RefObject<CourierInboxPopupMenuElement | null>).current = menuRef.current;\n }\n }, [ref]);\n\n // Handle message click\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, menuRef]);\n\n // Handle message action click\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, menuRef]);\n\n // Handle message long press\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, menuRef]);\n\n // Render header\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderHeader) return;\n queueMicrotask(() => {\n menu.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader, menuRef]);\n\n // Render list item\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderListItem) return;\n queueMicrotask(() => {\n menu.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem, menuRef]);\n\n // Render empty state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderEmptyState) return;\n queueMicrotask(() => {\n menu.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState, menuRef]);\n\n // Render loading state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderLoadingState) return;\n queueMicrotask(() => {\n menu.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState, menuRef]);\n\n // Render error state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderErrorState) return;\n queueMicrotask(() => {\n menu.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState, menuRef]);\n\n // Render pagination item\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n menu.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem, menuRef]);\n\n // Render menu button\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderMenuButton) return;\n queueMicrotask(() => {\n menu.setMenuButton((buttonProps?: CourierInboxMenuButtonFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderMenuButton!(buttonProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderMenuButton, menuRef]);\n\n // Set feed type\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n queueMicrotask(() => {\n menu.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, menuRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox-popup-menu\n ref={menuRef}\n popup-alignment={props.popupAlignment}\n popup-width={props.popupWidth}\n popup-height={props.popupHeight}\n left={props.left}\n top={props.top}\n right={props.right}\n bottom={props.bottom}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n});\n\nCourierInboxPopupMenu.displayName = 'CourierInboxPopupMenu';"],"names":["clickMessage","archiveMessage","openMessage"],"mappings":";;;;;;;AA8BO,MAAM,aAAa,MAAM;AAG9B,QAAM,SAAS,CAAC,UAAwB,QAAQ,OAAO,OAAO,KAAK;AACnE,QAAM,UAAU,MAAM,QAAQ,OAAO,QAAA;AAGrC,QAAM,YAAY,CAAC,UAAqE,sBAAsB,OAAO,KAAK,KAAK;AAC/H,QAAM,0BAA0B,CAAC,UAA8C,sBAAsB,OAAO,wBAAwB,KAAK;AACzI,QAAM,qBAAqB,CAAC,UAAkB,QAAQ,OAAO,kBAAkB;AAC/E,QAAM,cAAc,CAAC,YAA0B,sBAAsB,OAAO,YAAY,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hB;AAEJ,CAAC;AAED,sBAAsB,cAAc;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trycourier/courier-react",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.21-beta",
|
|
4
4
|
"description": "The React components for the Courier web UI",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"author": "Courier",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@trycourier/courier-js": "2.0.
|
|
30
|
-
"@trycourier/courier-ui-core": "1.0.
|
|
31
|
-
"@trycourier/courier-ui-inbox": "1.0.
|
|
29
|
+
"@trycourier/courier-js": "2.0.8-beta",
|
|
30
|
+
"@trycourier/courier-ui-core": "1.0.11-beta",
|
|
31
|
+
"@trycourier/courier-ui-inbox": "1.0.11-beta"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": ">=18.0.0",
|