@trycourier/courier-react 8.0.18-beta → 8.0.20-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 +366 -127
- package/dist/components/courier-inbox-popup-menu.d.ts +10 -9
- package/dist/components/courier-inbox.d.ts +9 -9
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +78 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,171 +1,410 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@trycourier/courier-react`
|
|
2
2
|
|
|
3
|
-
React
|
|
3
|
+
React components for Courier Inbox.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 1. Install
|
|
6
6
|
|
|
7
|
-
```
|
|
8
|
-
npm i @trycourier/courier-react@8.0.
|
|
7
|
+
```sh
|
|
8
|
+
npm i @trycourier/courier-react@8.0.20-beta
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
> **Not using React?** We suggest you use [@trycourier/courier-ui-inbox](../courier-ui-inbox/README.md) package instead.
|
|
12
|
+
|
|
13
|
+
## 2. Authenticate
|
|
14
|
+
|
|
15
|
+
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.**
|
|
16
|
+
|
|
17
|
+
**How it works:**
|
|
18
|
+
|
|
19
|
+
1. **Your frontend calls your backend:**
|
|
20
|
+
- When your app needs to authenticate a user, your frontend should make a request to your own backend (e.g., `/api/generate-courier-jwt`).
|
|
21
|
+
|
|
22
|
+
2. **Your backend calls Courier to issue a JWT:**
|
|
23
|
+
- In your backend endpoint, use your Courier API Key to call the [Courier JWT Token Endpoint](https://www.courier.com/docs/reference/auth/issue-token) and generate a JWT for the user.
|
|
24
|
+
- Your backend then returns the JWT to your frontend.
|
|
25
|
+
|
|
26
|
+
> **Where do I get my API Key?** Go to your [Courier API Keys](https://app.courier.com/settings/api-keys) page.
|
|
27
|
+
|
|
28
|
+
**Example: Quick Testing with cURL**
|
|
29
|
+
|
|
30
|
+
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.**
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
curl --request POST \
|
|
34
|
+
--url https://api.courier.com/auth/issue-token \
|
|
35
|
+
--header 'Accept: application/json' \
|
|
36
|
+
--header 'Authorization: Bearer $YOUR_API_KEY' \
|
|
37
|
+
--header 'Content-Type: application/json' \
|
|
38
|
+
--data \
|
|
39
|
+
'{
|
|
40
|
+
"scope": "user_id:$YOUR_USER_ID write:user-tokens inbox:read:messages inbox:write:events read:preferences write:preferences read:brands",
|
|
41
|
+
"expires_in": "$YOUR_NUMBER days"
|
|
42
|
+
}'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 3. Add Inbox Component
|
|
46
|
+
|
|
47
|
+
### `CourierInbox`
|
|
48
|
+
|
|
49
|
+
<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" />
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { useEffect } from 'react';
|
|
53
|
+
import { CourierInbox, useCourier } from '@trycourier/courier-react';
|
|
54
|
+
|
|
55
|
+
export default function App() {
|
|
56
|
+
|
|
57
|
+
const courier = useCourier();
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
// Generate a JWT for your user (do this on your backend server)
|
|
61
|
+
const jwt = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'; // Replace with actual JWT
|
|
62
|
+
|
|
63
|
+
// Authenticate the user with the inbox
|
|
64
|
+
courier.shared.signIn({
|
|
65
|
+
userId: $YOUR_USER_ID,
|
|
66
|
+
jwt: jwt,
|
|
67
|
+
});
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
return <CourierInbox />;
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `CourierInboxPopupMenu`
|
|
76
|
+
|
|
77
|
+
<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
78
|
|
|
13
79
|
```ts
|
|
14
80
|
import { useEffect } from 'react';
|
|
15
81
|
import { CourierInbox, useCourier } from '@trycourier/courier-react';
|
|
16
82
|
|
|
17
|
-
function App() {
|
|
83
|
+
export default function App() {
|
|
84
|
+
|
|
85
|
+
const courier = useCourier();
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
// Generate a JWT for your user (do this on your backend server)
|
|
89
|
+
const jwt = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'; // Replace with actual JWT
|
|
90
|
+
|
|
91
|
+
// Authenticate the user with the inbox
|
|
92
|
+
courier.shared.signIn({
|
|
93
|
+
userId: $YOUR_USER_ID,
|
|
94
|
+
jwt: jwt,
|
|
95
|
+
});
|
|
96
|
+
}, []);
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<div style={{ padding: '24px' }}>
|
|
100
|
+
<CourierInboxPopupMenu />
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## NextJS & Server Side Rendering Frameworks
|
|
108
|
+
|
|
109
|
+
`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`.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
'use client'
|
|
113
|
+
|
|
114
|
+
...
|
|
115
|
+
import { ..., CourierInboxPopupMenu } from '@trycourier/courier-react';
|
|
116
|
+
|
|
117
|
+
export default function Page() {
|
|
118
|
+
|
|
119
|
+
...
|
|
120
|
+
|
|
121
|
+
return <CourierInboxPopupMenu />;
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Handle Clicks and Presses
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
import { useEffect } from 'react';
|
|
130
|
+
import { CourierInbox, useCourier, type CourierInboxListItemFactoryProps, type CourierInboxListItemActionFactoryProps } from '@trycourier/courier-react';
|
|
131
|
+
|
|
132
|
+
export default function App() {
|
|
18
133
|
|
|
19
134
|
const courier = useCourier();
|
|
20
135
|
|
|
21
136
|
useEffect(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
137
|
+
// Generate a JWT for your user (do this on your backend server)
|
|
138
|
+
const jwt = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'; // Replace with actual JWT
|
|
139
|
+
|
|
140
|
+
// Authenticate the user with the inbox
|
|
141
|
+
courier.shared.signIn({
|
|
142
|
+
userId: $YOUR_USER_ID,
|
|
143
|
+
jwt: jwt,
|
|
25
144
|
});
|
|
26
145
|
}, []);
|
|
27
146
|
|
|
28
147
|
return (
|
|
29
148
|
<CourierInbox
|
|
30
|
-
onMessageClick={(
|
|
31
|
-
|
|
149
|
+
onMessageClick={({ message, index }: CourierInboxListItemFactoryProps) => {
|
|
150
|
+
alert("Message clicked at index " + index + ":\n" + JSON.stringify(message, null, 2));
|
|
32
151
|
}}
|
|
33
|
-
onMessageActionClick={(
|
|
34
|
-
|
|
152
|
+
onMessageActionClick={({ message, action, index }: CourierInboxListItemActionFactoryProps) => {
|
|
153
|
+
alert(
|
|
154
|
+
"Message action clicked at index " + index + ":\n" +
|
|
155
|
+
"Action: " + JSON.stringify(action, null, 2) + "\n" +
|
|
156
|
+
"Message: " + JSON.stringify(message, null, 2)
|
|
157
|
+
);
|
|
35
158
|
}}
|
|
36
|
-
onMessageLongPress={(
|
|
37
|
-
|
|
159
|
+
onMessageLongPress={({ message, index }: CourierInboxListItemFactoryProps) => {
|
|
160
|
+
alert("Message long pressed at index " + index + ":\n" + JSON.stringify(message, null, 2));
|
|
38
161
|
}}
|
|
39
|
-
|
|
162
|
+
/>
|
|
163
|
+
);
|
|
40
164
|
|
|
41
|
-
|
|
165
|
+
}
|
|
166
|
+
```
|
|
42
167
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
168
|
+
## Styles and Theming
|
|
169
|
+
|
|
170
|
+
### Light & Dark Themes
|
|
171
|
+
|
|
172
|
+
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.
|
|
173
|
+
|
|
174
|
+
> **🎨 Theme Reference:** [All available theme values](../courier-ui-inbox/docs/theme.md)
|
|
175
|
+
|
|
176
|
+
<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" />
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
import { CourierInbox, ..., type CourierInboxTheme } from '@trycourier/courier-react';
|
|
180
|
+
|
|
181
|
+
export default function App() {
|
|
182
|
+
...
|
|
183
|
+
|
|
184
|
+
const theme: CourierInboxTheme = {
|
|
185
|
+
inbox: {
|
|
186
|
+
header: {
|
|
187
|
+
filters: {
|
|
188
|
+
unreadIndicator: {
|
|
189
|
+
backgroundColor: '#8B5CF6',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
list: {
|
|
194
|
+
item: {
|
|
195
|
+
unreadIndicatorColor: '#8B5CF6',
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
return <CourierInbox lightTheme={theme} darkTheme={theme} mode="light" />;
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Popup Alignment, Positioning, and Dimensions
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
export default function App() {
|
|
209
|
+
|
|
210
|
+
...
|
|
211
|
+
|
|
212
|
+
return (
|
|
213
|
+
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', padding: '100px' }}>
|
|
214
|
+
<CourierInboxPopupMenu
|
|
215
|
+
popupAlignment="top-right" // 'top-right' | 'top-left' | 'top-center' | 'bottom-right' | 'bottom-left' | 'bottom-center' | 'center-right' | 'center-left' | 'center-center'
|
|
216
|
+
popupWidth="340px"
|
|
217
|
+
popupHeight="400px"
|
|
218
|
+
top="44px"
|
|
219
|
+
right="44px"
|
|
220
|
+
/>
|
|
221
|
+
</div>
|
|
54
222
|
);
|
|
55
223
|
|
|
56
224
|
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Custom height `CourierInbox`
|
|
57
228
|
|
|
58
|
-
|
|
229
|
+
> **Important:** The default `CourierInbox` height is auto. It will set it's height based on it's children.
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
<CourierInbox height='50vh' />
|
|
59
233
|
```
|
|
60
234
|
|
|
61
|
-
##
|
|
235
|
+
## Custom Elements
|
|
62
236
|
|
|
63
|
-
|
|
237
|
+
Customize the inbox UI with any element you want.
|
|
238
|
+
|
|
239
|
+
### List Items
|
|
240
|
+
|
|
241
|
+
<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
242
|
|
|
65
243
|
```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
|
-
};
|
|
244
|
+
import { CourierInbox, ..., type CourierInboxListItemFactoryProps } from '@trycourier/courier-react'
|
|
97
245
|
|
|
98
|
-
|
|
246
|
+
const CustomListItem = ({ message, index }: CourierInboxListItemFactoryProps) => (
|
|
247
|
+
<pre style={{
|
|
248
|
+
padding: '24px',
|
|
249
|
+
borderBottom: '1px solid #e0e0e0',
|
|
250
|
+
margin: '0'
|
|
251
|
+
}}>
|
|
252
|
+
{JSON.stringify({ message, index }, null, 2)}
|
|
253
|
+
</pre>
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
export default function App() {
|
|
257
|
+
|
|
258
|
+
...
|
|
259
|
+
|
|
260
|
+
return (
|
|
261
|
+
<CourierInbox
|
|
262
|
+
renderListItem={(props: CourierInboxListItemFactoryProps) => {
|
|
263
|
+
return <CustomListItem {...props} />
|
|
264
|
+
}}
|
|
265
|
+
/>
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Header
|
|
272
|
+
|
|
273
|
+
<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" />
|
|
274
|
+
|
|
275
|
+
```ts
|
|
276
|
+
import { CourierInbox, ..., type CourierInboxHeaderFactoryProps } from '@trycourier/courier-react'
|
|
99
277
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
278
|
+
const CustomHeader = (props: CourierInboxHeaderFactoryProps) => (
|
|
279
|
+
<div style={{
|
|
280
|
+
background: 'red',
|
|
281
|
+
fontSize: '24px',
|
|
282
|
+
padding: '24px',
|
|
283
|
+
width: '100%'
|
|
284
|
+
}}>
|
|
285
|
+
{props.feedType}
|
|
286
|
+
</div>
|
|
287
|
+
);
|
|
107
288
|
|
|
108
|
-
|
|
289
|
+
export default function App() {
|
|
109
290
|
|
|
110
|
-
|
|
111
|
-
popupAlignment='top-left'
|
|
112
|
-
popupWidth='456px'
|
|
113
|
-
popupHeight='456px'
|
|
114
|
-
mode='system'
|
|
115
|
-
feedType='archive'
|
|
116
|
-
/>
|
|
291
|
+
...
|
|
117
292
|
|
|
293
|
+
return (
|
|
294
|
+
<CourierInbox
|
|
295
|
+
renderHeader={(props: CourierInboxHeaderFactoryProps) => {
|
|
296
|
+
return <CustomHeader {...props} />
|
|
297
|
+
}}
|
|
298
|
+
/>
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
}
|
|
118
302
|
```
|
|
119
303
|
|
|
120
|
-
|
|
304
|
+
### Popup Menu Button
|
|
305
|
+
|
|
306
|
+
<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" />
|
|
307
|
+
|
|
308
|
+
```ts
|
|
309
|
+
import { CourierInboxPopupMenu, ..., type CourierInboxMenuButtonFactoryProps } from '@trycourier/courier-react'
|
|
310
|
+
|
|
311
|
+
const CustomMenuButton = ({ unreadCount }: CourierInboxMenuButtonFactoryProps) => (
|
|
312
|
+
<button>
|
|
313
|
+
Open the Inbox Popup. Unread message count: {unreadCount}
|
|
314
|
+
</button>
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
export default function App() {
|
|
318
|
+
|
|
319
|
+
...
|
|
320
|
+
|
|
321
|
+
return (
|
|
322
|
+
<div style={{ padding: '24px' }}>
|
|
323
|
+
<CourierInboxPopupMenu
|
|
324
|
+
renderMenuButton={(props: CourierInboxMenuButtonFactoryProps) => {
|
|
325
|
+
return <CustomMenuButton {...props} />
|
|
326
|
+
}}
|
|
327
|
+
/>
|
|
328
|
+
</div>
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
}
|
|
332
|
+
```
|
|
121
333
|
|
|
122
|
-
|
|
334
|
+
### Loading, Empty, Error & Pagination
|
|
123
335
|
|
|
124
336
|
```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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}}
|
|
170
|
-
|
|
337
|
+
import {
|
|
338
|
+
CourierInbox,
|
|
339
|
+
...,
|
|
340
|
+
type CourierInboxStateEmptyFactoryProps,
|
|
341
|
+
type CourierInboxStateLoadingFactoryProps,
|
|
342
|
+
type CourierInboxStateErrorFactoryProps,
|
|
343
|
+
type CourierInboxPaginationItemFactoryProps
|
|
344
|
+
} from '@trycourier/courier-react'
|
|
345
|
+
|
|
346
|
+
const CustomLoadingState = ({ feedType }: CourierInboxStateLoadingFactoryProps) => (
|
|
347
|
+
<div style={{
|
|
348
|
+
padding: '24px',
|
|
349
|
+
background: 'red',
|
|
350
|
+
textAlign: 'center'
|
|
351
|
+
}}>
|
|
352
|
+
Custom Loading State
|
|
353
|
+
</div>
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
const CustomEmptyState = ({ feedType }: CourierInboxStateEmptyFactoryProps) => (
|
|
357
|
+
<div style={{
|
|
358
|
+
padding: '24px',
|
|
359
|
+
background: 'green',
|
|
360
|
+
textAlign: 'center'
|
|
361
|
+
}}>
|
|
362
|
+
Custom Empty State
|
|
363
|
+
</div>
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
const CustomErrorState = ({ feedType, error }: CourierInboxStateErrorFactoryProps) => (
|
|
367
|
+
<div style={{
|
|
368
|
+
padding: '24px',
|
|
369
|
+
background: 'blue',
|
|
370
|
+
textAlign: 'center'
|
|
371
|
+
}}>
|
|
372
|
+
Custom Error State: {error.message}
|
|
373
|
+
</div>
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
const CustomPaginationItem = ({ feedType }: CourierInboxPaginationItemFactoryProps) => (
|
|
377
|
+
<div style={{
|
|
378
|
+
padding: '24px',
|
|
379
|
+
background: 'yellow',
|
|
380
|
+
textAlign: 'center'
|
|
381
|
+
}}>
|
|
382
|
+
Custom Pagination Item
|
|
383
|
+
</div>
|
|
384
|
+
);
|
|
385
|
+
|
|
386
|
+
export default function App() {
|
|
387
|
+
|
|
388
|
+
...
|
|
389
|
+
|
|
390
|
+
return (
|
|
391
|
+
<CourierInbox
|
|
392
|
+
renderLoadingState={(props: CourierInboxStateLoadingFactoryProps) => {
|
|
393
|
+
return <CustomLoadingState {...props} />
|
|
394
|
+
}}
|
|
395
|
+
renderEmptyState={(props: CourierInboxStateEmptyFactoryProps) => {
|
|
396
|
+
return <CustomEmptyState {...props} />
|
|
397
|
+
}}
|
|
398
|
+
renderErrorState={(props: CourierInboxStateErrorFactoryProps) => {
|
|
399
|
+
return <CustomErrorState {...props} />
|
|
400
|
+
}}
|
|
401
|
+
renderPaginationItem={(props: CourierInboxPaginationItemFactoryProps) => {
|
|
402
|
+
return <CustomPaginationItem {...props} />
|
|
403
|
+
}}
|
|
404
|
+
/>
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
}
|
|
171
408
|
```
|
|
409
|
+
|
|
410
|
+
> **Not using React?** We suggest you use [@trycourier/courier-ui-inbox](../courier-ui-inbox/README.md) package instead.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from '../../../../node_modules/react';
|
|
2
|
+
import { CourierInboxFeedType, CourierInboxHeaderFactoryProps, CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxMenuButtonFactoryProps, CourierInboxPopupMenu as CourierInboxPopupMenuElement, CourierInboxPaginationItemFactoryProps, CourierInboxPopupAlignment, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxTheme } from '@trycourier/courier-ui-inbox';
|
|
2
3
|
import { CourierComponentThemeMode } from '@trycourier/courier-ui-core';
|
|
3
4
|
export interface CourierInboxPopupMenuProps {
|
|
4
5
|
popupAlignment?: CourierInboxPopupAlignment;
|
|
@@ -15,12 +16,12 @@ export interface CourierInboxPopupMenuProps {
|
|
|
15
16
|
onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;
|
|
16
17
|
onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;
|
|
17
18
|
onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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;
|
|
25
26
|
}
|
|
26
|
-
export declare const CourierInboxPopupMenu: (
|
|
27
|
+
export declare const CourierInboxPopupMenu: import('../../../../node_modules/react').ForwardRefExoticComponent<CourierInboxPopupMenuProps & import('../../../../node_modules/react').RefAttributes<CourierInboxPopupMenuElement>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxTheme, CourierInboxHeaderFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxFeedType } from '@trycourier/courier-ui-inbox';
|
|
1
|
+
import { ReactNode } from '../../../../node_modules/react';
|
|
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 {
|
|
5
5
|
height?: string;
|
|
@@ -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
|
-
export declare const CourierInbox: (
|
|
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-
|
|
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 { createRoot } from \"react-dom/client\";\nimport { flushSync } from \"react-dom\";\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 flushSync to ensure the DOM is updated synchronously\n flushSync(() => {\n render(node, container);\n });\n\n return container;\n}\n\n/**\n * Render a React node using createRoot.\n * @param node - The React node to render.\n * @param container - The container to render the node into.\n * @returns The rendered node.\n */\nfunction render(node: ReactNode, container: HTMLElement) {\n const root = createRoot(container);\n return root.render(node);\n}","import React, { useState, useEffect } from 'react';\n\ninterface CourierClientProps {\n children: React.ReactNode;\n}\n\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 React, { useRef, useEffect } 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) => React.ReactNode;\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => React.ReactNode;\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => React.ReactNode;\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => React.ReactNode;\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => React.ReactNode;\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => React.ReactNode;\n}\n\nexport const CourierInbox = (props: CourierInboxProps) => {\n const inboxRef = useRef<CourierInboxElement>(null);\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};","import { useRef, useEffect } 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) => React.ReactNode;\n renderPopupListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => React.ReactNode;\n renderPopupEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => React.ReactNode;\n renderPopupLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => React.ReactNode;\n renderPopupErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => React.ReactNode;\n renderPopupPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => React.ReactNode;\n renderPopupMenuButton?: (props: CourierInboxMenuButtonFactoryProps | undefined | null) => React.ReactNode;\n}\n\nexport const CourierInboxPopupMenu = (props: CourierInboxPopupMenuProps) => {\n const menuRef = useRef<CourierInboxPopupMenuElement>(null);\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","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","flushSync","root","createRoot","render","CourierClientComponent","children","isMounted","setIsMounted","useState","useEffect","window","props","inboxRef","useRef","inbox","current","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","ref","height","lightTheme","JSON","stringify","darkTheme","mode","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,OAOlC,OAJPC,EAAAA,WAAU,MAaZ,SAAgBJ,EAAiBC,GACzB,MAAAI,EAAOC,aAAWL,GACjBI,EAAKE,OAAOP,EACrB,CAfIO,CAAOP,EAAMC,EAAS,IAGjBA,CACT,CCbO,MAAMO,EAAuD,EAAGC,eACrE,MAAOC,EAAWC,GAAgBC,EAAAA,UAAS,GAOvC,OALJC,EAAAA,WAAU,KACRF,GAAa,EAAI,GAChB,IAGmB,oBAAXG,OACF,KAGJJ,oBAIKD,aAHD,IAGU,uBCCQM,IACrB,MAAAC,EAAWC,SAA4B,MAwG7C,OArGAJ,EAAAA,WAAU,KACR,MAAMK,EAAQF,EAASG,QAClBD,GACCA,EAAAE,eAAeL,EAAMK,eAAc,GACxC,CAACL,EAAMK,eAAgBJ,IAG1BH,EAAAA,WAAU,KACR,MAAMK,EAAQF,EAASG,QAClBD,GACCA,EAAAG,qBAAqBN,EAAMM,qBAAoB,GACpD,CAACN,EAAMM,qBAAsBL,IAGhCH,EAAAA,WAAU,KACR,MAAMK,EAAQF,EAASG,QAClBD,GACCA,EAAAI,mBAAmBP,EAAMO,mBAAkB,GAChD,CAACP,EAAMO,mBAAoBN,IAG9BH,EAAAA,WAAU,KACR,MAAM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vBM,oBAAqB,IAAMN,MAS7B,+BAPsB7B,OAAOoC,qBAAqBX,GAGtCD,IACCK,IAGN,KACLP,EAASe,SACTZ,EAAcY,QAAO,CACvB,GACC,IAEH,MAAMb,EAAc,WACZ,MAAAc,EAAUvC,OAAAA,EAAAA,EAAAA,QAAQC,OAAOuC,aAAQ,EAAAC,EAAAF,QAC/BpB,EAAA,CACNE,OAAiB,MAATkB,OAAS,EAAAA,EAAAlB,OACjBtB,SACAG,WACD,EAGG4B,EAAgBD,IACd,MAAAa,EAAYtC,EAAAA,sBAAsBH,OAC/BqB,EAAA,CACPjB,KAAMF,EACNG,0BACAC,qBACAG,cACAE,gBACAC,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,QAAA,GAEzE,CAACH,IA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
2
|
export * from './components/courier-inbox';
|
|
3
3
|
export * from './components/courier-inbox-popup-menu';
|
|
4
|
+
export type { CourierProps, CourierClientOptions, CourierBrand, CourierApiUrls, CourierUserPreferences, CourierUserPreferencesStatus, CourierUserPreferencesChannel, CourierUserPreferencesPaging, CourierUserPreferencesTopic, CourierUserPreferencesTopicResponse, CourierDevice, CourierToken, CourierGetInboxMessageResponse, CourierGetInboxMessagesResponse, InboxMessage, InboxAction, InboxMessageEventEnvelope, } from '@trycourier/courier-js';
|
|
5
|
+
export { markAsRead, markAsUnread, clickMessage, archiveMessage, openMessage } from '@trycourier/courier-ui-inbox';
|
|
6
|
+
export type { CourierInboxHeaderFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxListItemFactoryProps, CourierInboxListItemActionFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxMenuButtonFactoryProps, CourierInboxFeedType } from '@trycourier/courier-ui-inbox';
|
|
7
|
+
export type { CourierInboxTheme, CourierInboxFontTheme, CourierInboxIconTheme, CourierInboxFilterItemTheme, CourierInboxUnreadIndicatorTheme, CourierInboxIconButtonTheme, CourierInboxButtonTheme, CourierInboxMenuButtonTheme, CourierInboxPopupTheme, CourierInboxListItemTheme, CourierInboxSkeletonLoadingStateTheme, CourierInboxInfoStateTheme, CourierMenuItemTheme, CourierFilterMenuTheme, CourierActionMenuTheme } from '@trycourier/courier-ui-inbox';
|
|
8
|
+
export { defaultLightTheme, defaultDarkTheme, mergeTheme } from '@trycourier/courier-ui-inbox';
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { CourierInboxDatastore, CourierInboxDataStoreListener } from "@trycourier/courier-ui-inbox";
|
|
2
|
-
import React, { useState, useEffect, useRef } from "react";
|
|
3
1
|
import { Courier } from "@trycourier/courier-js";
|
|
2
|
+
import { CourierInboxDatastore, CourierInboxDataStoreListener } from "@trycourier/courier-ui-inbox";
|
|
3
|
+
import { archiveMessage, clickMessage, defaultDarkTheme, defaultLightTheme, markAsRead, markAsUnread, mergeTheme, openMessage } from "@trycourier/courier-ui-inbox";
|
|
4
|
+
import React, { useState, useEffect, forwardRef, useRef } from "react";
|
|
4
5
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
5
|
-
import { createRoot } from "react-dom/client";
|
|
6
6
|
import { flushSync } from "react-dom";
|
|
7
|
+
import { createRoot } from "react-dom/client";
|
|
7
8
|
const useCourier = () => {
|
|
8
9
|
const signIn = (props) => Courier.shared.signIn(props);
|
|
9
10
|
const signOut = () => Courier.shared.signOut();
|
|
@@ -12,9 +13,9 @@ const useCourier = () => {
|
|
|
12
13
|
const setPaginationLimit = (limit) => Courier.shared.paginationLimit = limit;
|
|
13
14
|
const readMessage = (message) => CourierInboxDatastore.shared.readMessage({ message });
|
|
14
15
|
const unreadMessage = (message) => CourierInboxDatastore.shared.unreadMessage({ message });
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
16
|
+
const clickMessage2 = (message) => CourierInboxDatastore.shared.clickMessage({ message });
|
|
17
|
+
const archiveMessage2 = (message) => CourierInboxDatastore.shared.archiveMessage({ message });
|
|
18
|
+
const openMessage2 = (message) => CourierInboxDatastore.shared.openMessage({ message });
|
|
18
19
|
const unarchiveMessage = (message) => CourierInboxDatastore.shared.unarchiveMessage({ message });
|
|
19
20
|
const readAllMessages = () => CourierInboxDatastore.shared.readAllMessages();
|
|
20
21
|
const [auth, setAuth] = React.useState({
|
|
@@ -28,9 +29,9 @@ const useCourier = () => {
|
|
|
28
29
|
setPaginationLimit,
|
|
29
30
|
readMessage,
|
|
30
31
|
unreadMessage,
|
|
31
|
-
clickMessage,
|
|
32
|
-
archiveMessage,
|
|
33
|
-
openMessage,
|
|
32
|
+
clickMessage: clickMessage2,
|
|
33
|
+
archiveMessage: archiveMessage2,
|
|
34
|
+
openMessage: openMessage2,
|
|
34
35
|
unarchiveMessage,
|
|
35
36
|
readAllMessages
|
|
36
37
|
});
|
|
@@ -70,9 +71,9 @@ const useCourier = () => {
|
|
|
70
71
|
setPaginationLimit,
|
|
71
72
|
readMessage,
|
|
72
73
|
unreadMessage,
|
|
73
|
-
clickMessage,
|
|
74
|
-
archiveMessage,
|
|
75
|
-
openMessage,
|
|
74
|
+
clickMessage: clickMessage2,
|
|
75
|
+
archiveMessage: archiveMessage2,
|
|
76
|
+
openMessage: openMessage2,
|
|
76
77
|
unarchiveMessage,
|
|
77
78
|
readAllMessages,
|
|
78
79
|
inbox: datastore.inboxDataSet,
|
|
@@ -89,14 +90,17 @@ const useCourier = () => {
|
|
|
89
90
|
};
|
|
90
91
|
function reactNodeToHTMLElement(node) {
|
|
91
92
|
const container = document.createElement("div");
|
|
93
|
+
const root = createRoot(container);
|
|
92
94
|
flushSync(() => {
|
|
93
|
-
render(node
|
|
95
|
+
root.render(node);
|
|
94
96
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
const element = container.firstElementChild;
|
|
98
|
+
if (!(element instanceof HTMLElement)) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
"renderListItem must return a single JSX element that renders to an HTMLElement (e.g., <div>)"
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
return element;
|
|
100
104
|
}
|
|
101
105
|
const CourierClientComponent = ({ children }) => {
|
|
102
106
|
const [isMounted, setIsMounted] = useState(false);
|
|
@@ -111,8 +115,15 @@ const CourierClientComponent = ({ children }) => {
|
|
|
111
115
|
}
|
|
112
116
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
113
117
|
};
|
|
114
|
-
const CourierInbox = (props) => {
|
|
118
|
+
const CourierInbox = forwardRef((props, ref) => {
|
|
115
119
|
const inboxRef = useRef(null);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (typeof ref === "function") {
|
|
122
|
+
ref(inboxRef.current);
|
|
123
|
+
} else if (ref) {
|
|
124
|
+
ref.current = inboxRef.current;
|
|
125
|
+
}
|
|
126
|
+
}, [ref]);
|
|
116
127
|
useEffect(() => {
|
|
117
128
|
const inbox = inboxRef.current;
|
|
118
129
|
if (!inbox) return;
|
|
@@ -205,9 +216,17 @@ const CourierInbox = (props) => {
|
|
|
205
216
|
mode: props.mode
|
|
206
217
|
}
|
|
207
218
|
) });
|
|
208
|
-
};
|
|
209
|
-
|
|
219
|
+
});
|
|
220
|
+
CourierInbox.displayName = "CourierInbox";
|
|
221
|
+
const CourierInboxPopupMenu = forwardRef((props, ref) => {
|
|
210
222
|
const menuRef = useRef(null);
|
|
223
|
+
useEffect(() => {
|
|
224
|
+
if (typeof ref === "function") {
|
|
225
|
+
ref(menuRef.current);
|
|
226
|
+
} else if (ref) {
|
|
227
|
+
ref.current = menuRef.current;
|
|
228
|
+
}
|
|
229
|
+
}, [ref]);
|
|
211
230
|
useEffect(() => {
|
|
212
231
|
const menu = menuRef.current;
|
|
213
232
|
if (!menu) return;
|
|
@@ -225,74 +244,74 @@ const CourierInboxPopupMenu = (props) => {
|
|
|
225
244
|
}, [props.onMessageLongPress, menuRef]);
|
|
226
245
|
useEffect(() => {
|
|
227
246
|
const menu = menuRef.current;
|
|
228
|
-
if (!menu || !props.
|
|
247
|
+
if (!menu || !props.renderHeader) return;
|
|
229
248
|
queueMicrotask(() => {
|
|
230
|
-
menu.
|
|
231
|
-
const reactNode = props.
|
|
249
|
+
menu.setHeader((headerProps) => {
|
|
250
|
+
const reactNode = props.renderHeader(headerProps);
|
|
232
251
|
return reactNodeToHTMLElement(reactNode);
|
|
233
252
|
});
|
|
234
253
|
});
|
|
235
|
-
}, [props.
|
|
254
|
+
}, [props.renderHeader, menuRef]);
|
|
236
255
|
useEffect(() => {
|
|
237
256
|
const menu = menuRef.current;
|
|
238
|
-
if (!menu || !props.
|
|
257
|
+
if (!menu || !props.renderListItem) return;
|
|
239
258
|
queueMicrotask(() => {
|
|
240
|
-
menu.
|
|
241
|
-
const reactNode = props.
|
|
259
|
+
menu.setListItem((itemProps) => {
|
|
260
|
+
const reactNode = props.renderListItem(itemProps);
|
|
242
261
|
return reactNodeToHTMLElement(reactNode);
|
|
243
262
|
});
|
|
244
263
|
});
|
|
245
|
-
}, [props.
|
|
264
|
+
}, [props.renderListItem, menuRef]);
|
|
246
265
|
useEffect(() => {
|
|
247
266
|
const menu = menuRef.current;
|
|
248
|
-
if (!menu || !props.
|
|
267
|
+
if (!menu || !props.renderEmptyState) return;
|
|
249
268
|
queueMicrotask(() => {
|
|
250
|
-
menu.
|
|
251
|
-
const reactNode = props.
|
|
269
|
+
menu.setEmptyState((emptyStateProps) => {
|
|
270
|
+
const reactNode = props.renderEmptyState(emptyStateProps);
|
|
252
271
|
return reactNodeToHTMLElement(reactNode);
|
|
253
272
|
});
|
|
254
273
|
});
|
|
255
|
-
}, [props.
|
|
274
|
+
}, [props.renderEmptyState, menuRef]);
|
|
256
275
|
useEffect(() => {
|
|
257
276
|
const menu = menuRef.current;
|
|
258
|
-
if (!menu || !props.
|
|
277
|
+
if (!menu || !props.renderLoadingState) return;
|
|
259
278
|
queueMicrotask(() => {
|
|
260
|
-
menu.
|
|
261
|
-
const reactNode = props.
|
|
279
|
+
menu.setLoadingState((loadingStateProps) => {
|
|
280
|
+
const reactNode = props.renderLoadingState(loadingStateProps);
|
|
262
281
|
return reactNodeToHTMLElement(reactNode);
|
|
263
282
|
});
|
|
264
283
|
});
|
|
265
|
-
}, [props.
|
|
284
|
+
}, [props.renderLoadingState, menuRef]);
|
|
266
285
|
useEffect(() => {
|
|
267
286
|
const menu = menuRef.current;
|
|
268
|
-
if (!menu || !props.
|
|
287
|
+
if (!menu || !props.renderErrorState) return;
|
|
269
288
|
queueMicrotask(() => {
|
|
270
|
-
menu.
|
|
271
|
-
const reactNode = props.
|
|
289
|
+
menu.setErrorState((errorStateProps) => {
|
|
290
|
+
const reactNode = props.renderErrorState(errorStateProps);
|
|
272
291
|
return reactNodeToHTMLElement(reactNode);
|
|
273
292
|
});
|
|
274
293
|
});
|
|
275
|
-
}, [props.
|
|
294
|
+
}, [props.renderErrorState, menuRef]);
|
|
276
295
|
useEffect(() => {
|
|
277
296
|
const menu = menuRef.current;
|
|
278
|
-
if (!menu || !props.
|
|
297
|
+
if (!menu || !props.renderPaginationItem) return;
|
|
279
298
|
queueMicrotask(() => {
|
|
280
|
-
menu.
|
|
281
|
-
const reactNode = props.
|
|
299
|
+
menu.setPaginationItem((paginationProps) => {
|
|
300
|
+
const reactNode = props.renderPaginationItem(paginationProps);
|
|
282
301
|
return reactNodeToHTMLElement(reactNode);
|
|
283
302
|
});
|
|
284
303
|
});
|
|
285
|
-
}, [props.
|
|
304
|
+
}, [props.renderPaginationItem, menuRef]);
|
|
286
305
|
useEffect(() => {
|
|
287
306
|
const menu = menuRef.current;
|
|
288
|
-
if (!menu || !props.
|
|
307
|
+
if (!menu || !props.renderMenuButton) return;
|
|
289
308
|
queueMicrotask(() => {
|
|
290
|
-
menu.
|
|
291
|
-
const reactNode = props.
|
|
309
|
+
menu.setMenuButton((buttonProps) => {
|
|
310
|
+
const reactNode = props.renderMenuButton(buttonProps);
|
|
292
311
|
return reactNodeToHTMLElement(reactNode);
|
|
293
312
|
});
|
|
294
313
|
});
|
|
295
|
-
}, [props.
|
|
314
|
+
}, [props.renderMenuButton, menuRef]);
|
|
296
315
|
useEffect(() => {
|
|
297
316
|
const menu = menuRef.current;
|
|
298
317
|
if (!menu) return;
|
|
@@ -316,10 +335,19 @@ const CourierInboxPopupMenu = (props) => {
|
|
|
316
335
|
mode: props.mode
|
|
317
336
|
}
|
|
318
337
|
) });
|
|
319
|
-
};
|
|
338
|
+
});
|
|
339
|
+
CourierInboxPopupMenu.displayName = "CourierInboxPopupMenu";
|
|
320
340
|
export {
|
|
321
341
|
CourierInbox,
|
|
322
342
|
CourierInboxPopupMenu,
|
|
343
|
+
archiveMessage,
|
|
344
|
+
clickMessage,
|
|
345
|
+
defaultDarkTheme,
|
|
346
|
+
defaultLightTheme,
|
|
347
|
+
markAsRead,
|
|
348
|
+
markAsUnread,
|
|
349
|
+
mergeTheme,
|
|
350
|
+
openMessage,
|
|
323
351
|
useCourier
|
|
324
352
|
};
|
|
325
353
|
//# sourceMappingURL=index.mjs.map
|
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 { createRoot } from \"react-dom/client\";\nimport { flushSync } from \"react-dom\";\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 flushSync to ensure the DOM is updated synchronously\n flushSync(() => {\n render(node, container);\n });\n\n return container;\n}\n\n/**\n * Render a React node using createRoot.\n * @param node - The React node to render.\n * @param container - The container to render the node into.\n * @returns The rendered node.\n */\nfunction render(node: ReactNode, container: HTMLElement) {\n const root = createRoot(container);\n return root.render(node);\n}","import React, { useState, useEffect } from 'react';\n\ninterface CourierClientProps {\n children: React.ReactNode;\n}\n\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 React, { useRef, useEffect } 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) => React.ReactNode;\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => React.ReactNode;\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => React.ReactNode;\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => React.ReactNode;\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => React.ReactNode;\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => React.ReactNode;\n}\n\nexport const CourierInbox = (props: CourierInboxProps) => {\n const inboxRef = useRef<CourierInboxElement>(null);\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};","import { useRef, useEffect } 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) => React.ReactNode;\n renderPopupListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => React.ReactNode;\n renderPopupEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => React.ReactNode;\n renderPopupLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => React.ReactNode;\n renderPopupErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => React.ReactNode;\n renderPopupPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => React.ReactNode;\n renderPopupMenuButton?: (props: CourierInboxMenuButtonFactoryProps | undefined | null) => React.ReactNode;\n}\n\nexport const CourierInboxPopupMenu = (props: CourierInboxPopupMenuProps) => {\n const menuRef = useRef<CourierInboxPopupMenuElement>(null);\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"],"names":[],"mappings":";;;;;;AA8BO,MAAM,aAAa,MAAM;AAG9B,QAAM,SAAS,CAAC,UAAwB,QAAQ,OAAO,OAAO,KAAK;AACnE,QAAM,UAAU,MAAM,QAAQ,OAAO,QAAQ;AAG7C,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;AACzE,QAAA,cAAc,CAAC,YAA0B,sBAAsB,OAAO,YAAY,EAAE,SAAS;AAC7F,QAAA,gBAAgB,CAAC,YAA0B,sBAAsB,OAAO,cAAc,EAAE,SAAS;AACjG,QAAA,eAAe,CAAC,YAA0B,sBAAsB,OAAO,aAAa,EAAE,SAAS;AAC/F,QAAA,iBAAiB,CAAC,YAA0B,sBAAsB,OAAO,eAAe,EAAE,SAAS;AACnG,QAAA,cAAc,CAAC,YAA0B,sBAAsB,OAAO,YAAY,EAAE,SAAS;AAC7F,QAAA,mBAAmB,CAAC,YAA0B,sBAAsB,OAAO,iBAAiB,EAAE,SAAS;AAC7G,QAAM,kBAAkB,MAAM,sBAAsB,OAAO,gBAAgB;AAG3E,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAA8B;AAAA,IAC1D,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,EAAA,CACD;AAED,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAqB;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;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;"}
|
|
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,EAAE,SAAS;AACnG,QAAM,gBAAgB,CAAC,YAA0B,sBAAsB,OAAO,cAAc,EAAE,SAAS;AACvG,QAAMA,gBAAe,CAAC,YAA0B,sBAAsB,OAAO,aAAa,EAAE,SAAS;AACrG,QAAMC,kB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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.6-beta",
|
|
30
|
+
"@trycourier/courier-ui-core": "1.0.9-beta",
|
|
31
|
+
"@trycourier/courier-ui-inbox": "1.0.9-beta"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": ">=18.0.0",
|