@novu/react 3.15.0 → 3.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/NovuUI.cjs.map +1 -1
- package/dist/cjs/components/NovuUI.d.cts +2 -2
- package/dist/cjs/components/connect-chat/ConnectChat.cjs +63 -0
- package/dist/cjs/components/connect-chat/ConnectChat.cjs.map +1 -0
- package/dist/cjs/components/connect-chat/ConnectChat.d.cts +12 -0
- package/dist/cjs/components/connect-chat/DefaultConnectChat.cjs +83 -0
- package/dist/cjs/components/connect-chat/DefaultConnectChat.cjs.map +1 -0
- package/dist/cjs/components/connect-chat/DefaultConnectChat.d.cts +7 -0
- package/dist/cjs/components/index.cjs +4 -0
- package/dist/cjs/components/index.cjs.map +1 -1
- package/dist/cjs/components/index.d.cts +5 -1
- package/dist/cjs/components/slack-connect-button/DefaultSlackConnectButton.cjs +89 -0
- package/dist/cjs/components/slack-connect-button/DefaultSlackConnectButton.cjs.map +1 -0
- package/dist/cjs/components/slack-connect-button/DefaultSlackConnectButton.d.cts +7 -0
- package/dist/cjs/components/slack-connect-button/SlackConnectButton.cjs +63 -0
- package/dist/cjs/components/slack-connect-button/SlackConnectButton.cjs.map +1 -0
- package/dist/cjs/components/slack-connect-button/SlackConnectButton.d.cts +12 -0
- package/dist/cjs/components/slack-link-user/DefaultSlackLinkUser.cjs +80 -0
- package/dist/cjs/components/slack-link-user/DefaultSlackLinkUser.cjs.map +1 -0
- package/dist/cjs/components/slack-link-user/DefaultSlackLinkUser.d.cts +7 -0
- package/dist/cjs/components/slack-link-user/SlackLinkUser.cjs +63 -0
- package/dist/cjs/components/slack-link-user/SlackLinkUser.cjs.map +1 -0
- package/dist/cjs/components/slack-link-user/SlackLinkUser.d.cts +12 -0
- package/dist/cjs/hooks/NovuProvider.cjs +34 -22
- package/dist/cjs/hooks/NovuProvider.cjs.map +1 -1
- package/dist/cjs/hooks/NovuProvider.d.cts +13 -2
- package/dist/cjs/hooks/index.cjs +10 -0
- package/dist/cjs/hooks/index.cjs.map +1 -1
- package/dist/cjs/hooks/index.d.cts +5 -0
- package/dist/cjs/hooks/internal/useBrowserTabsChannel.cjs +5 -2
- package/dist/cjs/hooks/internal/useBrowserTabsChannel.cjs.map +1 -1
- package/dist/cjs/hooks/internal/useBrowserTabsChannel.d.cts +2 -1
- package/dist/cjs/hooks/internal/useWebsocketEvent.cjs +6 -3
- package/dist/cjs/hooks/internal/useWebsocketEvent.cjs.map +1 -1
- package/dist/cjs/hooks/internal/useWebsocketEvent.d.cts +2 -1
- package/dist/cjs/hooks/useChannelConnection.cjs +107 -0
- package/dist/cjs/hooks/useChannelConnection.cjs.map +1 -0
- package/dist/cjs/hooks/useChannelConnection.d.cts +20 -0
- package/dist/cjs/hooks/useChannelConnections.cjs +85 -0
- package/dist/cjs/hooks/useChannelConnections.cjs.map +1 -0
- package/dist/cjs/hooks/useChannelConnections.d.cts +24 -0
- package/dist/cjs/hooks/useChannelEndpoint.cjs +110 -0
- package/dist/cjs/hooks/useChannelEndpoint.cjs.map +1 -0
- package/dist/cjs/hooks/useChannelEndpoint.d.cts +20 -0
- package/dist/cjs/hooks/useCounts.cjs +5 -1
- package/dist/cjs/hooks/useCounts.cjs.map +1 -1
- package/dist/cjs/hooks/useCounts.d.cts +18 -0
- package/dist/cjs/hooks/useCreateChannelEndpoint.cjs +61 -0
- package/dist/cjs/hooks/useCreateChannelEndpoint.cjs.map +1 -0
- package/dist/cjs/hooks/useCreateChannelEndpoint.d.cts +17 -0
- package/dist/cjs/hooks/useDeleteChannelEndpoint.cjs +69 -0
- package/dist/cjs/hooks/useDeleteChannelEndpoint.cjs.map +1 -0
- package/dist/cjs/hooks/useDeleteChannelEndpoint.d.cts +17 -0
- package/dist/cjs/hooks/useNotifications.cjs +4 -0
- package/dist/cjs/hooks/useNotifications.cjs.map +1 -1
- package/dist/cjs/hooks/useNotifications.d.cts +18 -0
- package/dist/cjs/index.cjs +14 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +11 -2
- package/dist/cjs/internal/index.d.cts +1 -0
- package/dist/cjs/themes/index.d.cts +0 -1
- package/dist/cjs/utils/appearance.cjs.map +1 -1
- package/dist/cjs/utils/appearance.d.cts +2 -2
- package/dist/cjs/utils/types.d.cts +1 -1
- package/dist/esm/components/NovuUI.d.ts +2 -2
- package/dist/esm/components/NovuUI.js.map +1 -1
- package/dist/esm/components/connect-chat/ConnectChat.d.ts +12 -0
- package/dist/esm/components/connect-chat/ConnectChat.js +28 -0
- package/dist/esm/components/connect-chat/ConnectChat.js.map +1 -0
- package/dist/esm/components/connect-chat/DefaultConnectChat.d.ts +7 -0
- package/dist/esm/components/connect-chat/DefaultConnectChat.js +58 -0
- package/dist/esm/components/connect-chat/DefaultConnectChat.js.map +1 -0
- package/dist/esm/components/index.d.ts +5 -1
- package/dist/esm/components/index.js +2 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/components/slack-connect-button/DefaultSlackConnectButton.d.ts +7 -0
- package/dist/esm/components/slack-connect-button/DefaultSlackConnectButton.js +64 -0
- package/dist/esm/components/slack-connect-button/DefaultSlackConnectButton.js.map +1 -0
- package/dist/esm/components/slack-connect-button/SlackConnectButton.d.ts +12 -0
- package/dist/esm/components/slack-connect-button/SlackConnectButton.js +28 -0
- package/dist/esm/components/slack-connect-button/SlackConnectButton.js.map +1 -0
- package/dist/esm/components/slack-link-user/DefaultSlackLinkUser.d.ts +7 -0
- package/dist/esm/components/slack-link-user/DefaultSlackLinkUser.js +55 -0
- package/dist/esm/components/slack-link-user/DefaultSlackLinkUser.js.map +1 -0
- package/dist/esm/components/slack-link-user/SlackLinkUser.d.ts +12 -0
- package/dist/esm/components/slack-link-user/SlackLinkUser.js +28 -0
- package/dist/esm/components/slack-link-user/SlackLinkUser.js.map +1 -0
- package/dist/esm/hooks/NovuProvider.d.ts +13 -2
- package/dist/esm/hooks/NovuProvider.js +33 -22
- package/dist/esm/hooks/NovuProvider.js.map +1 -1
- package/dist/esm/hooks/index.d.ts +5 -0
- package/dist/esm/hooks/index.js +5 -0
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/internal/useBrowserTabsChannel.d.ts +2 -1
- package/dist/esm/hooks/internal/useBrowserTabsChannel.js +5 -2
- package/dist/esm/hooks/internal/useBrowserTabsChannel.js.map +1 -1
- package/dist/esm/hooks/internal/useWebsocketEvent.d.ts +2 -1
- package/dist/esm/hooks/internal/useWebsocketEvent.js +6 -3
- package/dist/esm/hooks/internal/useWebsocketEvent.js.map +1 -1
- package/dist/esm/hooks/useChannelConnection.d.ts +20 -0
- package/dist/esm/hooks/useChannelConnection.js +81 -0
- package/dist/esm/hooks/useChannelConnection.js.map +1 -0
- package/dist/esm/hooks/useChannelConnections.d.ts +24 -0
- package/dist/esm/hooks/useChannelConnections.js +60 -0
- package/dist/esm/hooks/useChannelConnections.js.map +1 -0
- package/dist/esm/hooks/useChannelEndpoint.d.ts +20 -0
- package/dist/esm/hooks/useChannelEndpoint.js +83 -0
- package/dist/esm/hooks/useChannelEndpoint.js.map +1 -0
- package/dist/esm/hooks/useCounts.d.ts +18 -0
- package/dist/esm/hooks/useCounts.js +6 -2
- package/dist/esm/hooks/useCounts.js.map +1 -1
- package/dist/esm/hooks/useCreateChannelEndpoint.d.ts +17 -0
- package/dist/esm/hooks/useCreateChannelEndpoint.js +36 -0
- package/dist/esm/hooks/useCreateChannelEndpoint.js.map +1 -0
- package/dist/esm/hooks/useDeleteChannelEndpoint.d.ts +17 -0
- package/dist/esm/hooks/useDeleteChannelEndpoint.js +43 -0
- package/dist/esm/hooks/useDeleteChannelEndpoint.js.map +1 -0
- package/dist/esm/hooks/useNotifications.d.ts +18 -0
- package/dist/esm/hooks/useNotifications.js +5 -1
- package/dist/esm/hooks/useNotifications.js.map +1 -1
- package/dist/esm/index.d.ts +11 -2
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/appearance.d.ts +2 -2
- package/dist/esm/utils/appearance.js.map +1 -1
- package/dist/esm/utils/types.d.ts +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/hooks/useCreateChannelEndpoint.ts
|
|
2
|
+
import { useCallback, useRef, useState } from "react";
|
|
3
|
+
import { useNovu } from "./NovuProvider.js";
|
|
4
|
+
var useCreateChannelEndpoint = (props = {}) => {
|
|
5
|
+
const propsRef = useRef(props);
|
|
6
|
+
propsRef.current = props;
|
|
7
|
+
const novu = useNovu();
|
|
8
|
+
const [isCreating, setIsCreating] = useState(false);
|
|
9
|
+
const [error, setError] = useState();
|
|
10
|
+
const create = useCallback(
|
|
11
|
+
async (args) => {
|
|
12
|
+
const { onSuccess, onError } = propsRef.current;
|
|
13
|
+
setError(void 0);
|
|
14
|
+
setIsCreating(true);
|
|
15
|
+
const response = await novu.channelEndpoints.create(args);
|
|
16
|
+
setIsCreating(false);
|
|
17
|
+
if (response.error) {
|
|
18
|
+
setError(response.error);
|
|
19
|
+
onError?.(response.error);
|
|
20
|
+
} else if (response.data) {
|
|
21
|
+
onSuccess?.(response.data);
|
|
22
|
+
}
|
|
23
|
+
return response;
|
|
24
|
+
},
|
|
25
|
+
[novu]
|
|
26
|
+
);
|
|
27
|
+
return {
|
|
28
|
+
create,
|
|
29
|
+
isCreating,
|
|
30
|
+
error
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
useCreateChannelEndpoint
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=useCreateChannelEndpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useCreateChannelEndpoint.ts"],"sourcesContent":["import type { ChannelEndpointResponse, CreateChannelEndpointArgs, NovuError } from '@novu/js';\nimport { useCallback, useRef, useState } from 'react';\nimport { useNovu } from './NovuProvider';\n\nexport type UseCreateChannelEndpointProps = {\n onSuccess?: (data: ChannelEndpointResponse) => void;\n onError?: (error: NovuError) => void;\n};\n\nexport type UseCreateChannelEndpointResult = {\n isCreating: boolean;\n error?: NovuError;\n create: (args: CreateChannelEndpointArgs) => Promise<{\n data?: ChannelEndpointResponse | undefined;\n error?: NovuError | undefined;\n }>;\n};\n\nexport const useCreateChannelEndpoint = (props: UseCreateChannelEndpointProps = {}): UseCreateChannelEndpointResult => {\n const propsRef = useRef<UseCreateChannelEndpointProps>(props);\n propsRef.current = props;\n const novu = useNovu();\n const [isCreating, setIsCreating] = useState(false);\n const [error, setError] = useState<NovuError>();\n\n const create = useCallback(\n async (args: CreateChannelEndpointArgs) => {\n const { onSuccess, onError } = propsRef.current;\n setError(undefined);\n setIsCreating(true);\n\n const response = await novu.channelEndpoints.create(args);\n\n setIsCreating(false);\n\n if (response.error) {\n setError(response.error as NovuError);\n onError?.(response.error as NovuError);\n } else if (response.data) {\n onSuccess?.(response.data as ChannelEndpointResponse);\n }\n\n return response as { data?: ChannelEndpointResponse; error?: NovuError };\n },\n [novu]\n );\n\n return {\n create,\n isCreating,\n error,\n };\n};\n"],"mappings":";AACA,SAAS,aAAa,QAAQ,gBAAgB;AAC9C,SAAS,eAAe;AAgBjB,IAAM,2BAA2B,CAAC,QAAuC,CAAC,MAAsC;AACrH,QAAM,WAAW,OAAsC,KAAK;AAC5D,WAAS,UAAU;AACnB,QAAM,OAAO,QAAQ;AACrB,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAClD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAoB;AAE9C,QAAM,SAAS;AAAA,IACb,OAAO,SAAoC;AACzC,YAAM,EAAE,WAAW,QAAQ,IAAI,SAAS;AACxC,eAAS,MAAS;AAClB,oBAAc,IAAI;AAElB,YAAM,WAAW,MAAM,KAAK,iBAAiB,OAAO,IAAI;AAExD,oBAAc,KAAK;AAEnB,UAAI,SAAS,OAAO;AAClB,iBAAS,SAAS,KAAkB;AACpC,kBAAU,SAAS,KAAkB;AAAA,MACvC,WAAW,SAAS,MAAM;AACxB,oBAAY,SAAS,IAA+B;AAAA,MACtD;AAEA,aAAO;AAAA,IACT;AAAA,IACA,CAAC,IAAI;AAAA,EACP;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NovuError } from '@novu/js';
|
|
2
|
+
|
|
3
|
+
type UseDeleteChannelEndpointProps = {
|
|
4
|
+
onSuccess?: () => void;
|
|
5
|
+
onError?: (error: NovuError) => void;
|
|
6
|
+
};
|
|
7
|
+
type UseDeleteChannelEndpointResult = {
|
|
8
|
+
isDeleting: boolean;
|
|
9
|
+
error?: NovuError;
|
|
10
|
+
remove: (identifier: string) => Promise<{
|
|
11
|
+
data?: undefined;
|
|
12
|
+
error?: NovuError | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
declare const useDeleteChannelEndpoint: (props?: UseDeleteChannelEndpointProps) => UseDeleteChannelEndpointResult;
|
|
16
|
+
|
|
17
|
+
export { type UseDeleteChannelEndpointProps, type UseDeleteChannelEndpointResult, useDeleteChannelEndpoint };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// src/hooks/useDeleteChannelEndpoint.ts
|
|
2
|
+
import { useCallback, useRef, useState } from "react";
|
|
3
|
+
import { useNovu } from "./NovuProvider.js";
|
|
4
|
+
var useDeleteChannelEndpoint = (props = {}) => {
|
|
5
|
+
const propsRef = useRef(props);
|
|
6
|
+
propsRef.current = props;
|
|
7
|
+
const novu = useNovu();
|
|
8
|
+
const [isDeleting, setIsDeleting] = useState(false);
|
|
9
|
+
const [error, setError] = useState();
|
|
10
|
+
const remove = useCallback(
|
|
11
|
+
async (identifier) => {
|
|
12
|
+
setError(void 0);
|
|
13
|
+
setIsDeleting(true);
|
|
14
|
+
try {
|
|
15
|
+
const response = await novu.channelEndpoints.delete({ identifier });
|
|
16
|
+
if (response.error) {
|
|
17
|
+
setError(response.error);
|
|
18
|
+
propsRef.current.onError?.(response.error);
|
|
19
|
+
} else {
|
|
20
|
+
propsRef.current.onSuccess?.();
|
|
21
|
+
}
|
|
22
|
+
return response;
|
|
23
|
+
} catch (err) {
|
|
24
|
+
const novuError = err;
|
|
25
|
+
setError(novuError);
|
|
26
|
+
propsRef.current.onError?.(novuError);
|
|
27
|
+
return { error: novuError };
|
|
28
|
+
} finally {
|
|
29
|
+
setIsDeleting(false);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
[novu]
|
|
33
|
+
);
|
|
34
|
+
return {
|
|
35
|
+
remove,
|
|
36
|
+
isDeleting,
|
|
37
|
+
error
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
useDeleteChannelEndpoint
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=useDeleteChannelEndpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useDeleteChannelEndpoint.ts"],"sourcesContent":["import type { NovuError } from '@novu/js';\nimport { useCallback, useRef, useState } from 'react';\nimport { useNovu } from './NovuProvider';\n\nexport type UseDeleteChannelEndpointProps = {\n onSuccess?: () => void;\n onError?: (error: NovuError) => void;\n};\n\nexport type UseDeleteChannelEndpointResult = {\n isDeleting: boolean;\n error?: NovuError;\n remove: (identifier: string) => Promise<{\n data?: undefined;\n error?: NovuError | undefined;\n }>;\n};\n\nexport const useDeleteChannelEndpoint = (props: UseDeleteChannelEndpointProps = {}): UseDeleteChannelEndpointResult => {\n const propsRef = useRef<UseDeleteChannelEndpointProps>(props);\n propsRef.current = props;\n const novu = useNovu();\n const [isDeleting, setIsDeleting] = useState(false);\n const [error, setError] = useState<NovuError>();\n\n const remove = useCallback(\n async (identifier: string) => {\n setError(undefined);\n setIsDeleting(true);\n\n try {\n const response = await novu.channelEndpoints.delete({ identifier });\n\n if (response.error) {\n setError(response.error as NovuError);\n propsRef.current.onError?.(response.error as NovuError);\n } else {\n propsRef.current.onSuccess?.();\n }\n\n return response as { data?: undefined; error?: NovuError };\n } catch (err) {\n const novuError = err as NovuError;\n setError(novuError);\n propsRef.current.onError?.(novuError);\n\n return { error: novuError };\n } finally {\n setIsDeleting(false);\n }\n },\n [novu]\n );\n\n return {\n remove,\n isDeleting,\n error,\n };\n};\n"],"mappings":";AACA,SAAS,aAAa,QAAQ,gBAAgB;AAC9C,SAAS,eAAe;AAgBjB,IAAM,2BAA2B,CAAC,QAAuC,CAAC,MAAsC;AACrH,QAAM,WAAW,OAAsC,KAAK;AAC5D,WAAS,UAAU;AACnB,QAAM,OAAO,QAAQ;AACrB,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAClD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAoB;AAE9C,QAAM,SAAS;AAAA,IACb,OAAO,eAAuB;AAC5B,eAAS,MAAS;AAClB,oBAAc,IAAI;AAElB,UAAI;AACF,cAAM,WAAW,MAAM,KAAK,iBAAiB,OAAO,EAAE,WAAW,CAAC;AAElE,YAAI,SAAS,OAAO;AAClB,mBAAS,SAAS,KAAkB;AACpC,mBAAS,QAAQ,UAAU,SAAS,KAAkB;AAAA,QACxD,OAAO;AACL,mBAAS,QAAQ,YAAY;AAAA,QAC/B;AAEA,eAAO;AAAA,MACT,SAAS,KAAK;AACZ,cAAM,YAAY;AAClB,iBAAS,SAAS;AAClB,iBAAS,QAAQ,UAAU,SAAS;AAEpC,eAAO,EAAE,OAAO,UAAU;AAAA,MAC5B,UAAE;AACA,sBAAc,KAAK;AAAA,MACrB;AAAA,IACF;AAAA,IACA,CAAC,IAAI;AAAA,EACP;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -26,6 +26,12 @@ import { NotificationFilter, Notification, NovuError } from '@novu/js';
|
|
|
26
26
|
* createdGte: 1704067200000,
|
|
27
27
|
* createdLte: 1735689599999
|
|
28
28
|
* });
|
|
29
|
+
*
|
|
30
|
+
* // Opt out of the built-in realtime updates and drive them yourself
|
|
31
|
+
* const { notifications, refetch } = useNotifications({
|
|
32
|
+
* read: false,
|
|
33
|
+
* realtime: false,
|
|
34
|
+
* });
|
|
29
35
|
* ```
|
|
30
36
|
*/
|
|
31
37
|
type UseNotificationsProps = {
|
|
@@ -39,6 +45,18 @@ type UseNotificationsProps = {
|
|
|
39
45
|
createdGte?: NotificationFilter['createdGte'];
|
|
40
46
|
createdLte?: NotificationFilter['createdLte'];
|
|
41
47
|
limit?: number;
|
|
48
|
+
/**
|
|
49
|
+
* When `false`, disables the WebSocket subscription that auto-injects
|
|
50
|
+
* newly received notifications into the list. Built-in mutations like
|
|
51
|
+
* `readAll`, `seenAll`, `archiveAll`, and `archiveAllRead` continue to
|
|
52
|
+
* update local state. Use this when you want to drive new-notification updates yourself (e.g.
|
|
53
|
+
* via your own `novu.on('notifications.notification_received', ...)`
|
|
54
|
+
* handler combined with `refetch()`).
|
|
55
|
+
*
|
|
56
|
+
* When set, this prop takes precedence over the `realtime` config on
|
|
57
|
+
* `<NovuProvider />`. When omitted, the provider value (default `true`) is used.
|
|
58
|
+
*/
|
|
59
|
+
realtime?: boolean;
|
|
42
60
|
onSuccess?: (data: Notification[]) => void;
|
|
43
61
|
onError?: (error: NovuError) => void;
|
|
44
62
|
};
|
|
@@ -3,7 +3,7 @@ import { checkNotificationMatchesFilter, isSameFilter } from "@novu/js";
|
|
|
3
3
|
import { useCallback, useEffect, useState } from "react";
|
|
4
4
|
import { useDataRef } from "./internal/useDataRef.js";
|
|
5
5
|
import { useWebSocketEvent } from "./internal/useWebsocketEvent.js";
|
|
6
|
-
import { useNovu } from "./NovuProvider.js";
|
|
6
|
+
import { useNovu, useRealtime } from "./NovuProvider.js";
|
|
7
7
|
var useNotifications = (props) => {
|
|
8
8
|
const {
|
|
9
9
|
tags,
|
|
@@ -16,6 +16,7 @@ var useNotifications = (props) => {
|
|
|
16
16
|
createdGte,
|
|
17
17
|
createdLte,
|
|
18
18
|
limit = 10,
|
|
19
|
+
realtime: propsRealtime,
|
|
19
20
|
onSuccess,
|
|
20
21
|
onError
|
|
21
22
|
} = props || {};
|
|
@@ -32,6 +33,8 @@ var useNotifications = (props) => {
|
|
|
32
33
|
createdLte
|
|
33
34
|
});
|
|
34
35
|
const novu = useNovu();
|
|
36
|
+
const providerRealtime = useRealtime();
|
|
37
|
+
const realtime = propsRealtime ?? providerRealtime;
|
|
35
38
|
const [data, setData] = useState();
|
|
36
39
|
const [error, setError] = useState();
|
|
37
40
|
const [isLoading, setIsLoading] = useState(true);
|
|
@@ -57,6 +60,7 @@ var useNotifications = (props) => {
|
|
|
57
60
|
}, [filterRef, novu]);
|
|
58
61
|
useWebSocketEvent({
|
|
59
62
|
event: "notifications.notification_received",
|
|
63
|
+
enabled: realtime,
|
|
60
64
|
eventHandler: ({ result: notification }) => {
|
|
61
65
|
const currentFilter = filterRef.current;
|
|
62
66
|
const matches = checkNotificationMatchesFilter(notification, currentFilter);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useNotifications.ts"],"sourcesContent":["import { checkNotificationMatchesFilter, isSameFilter, Notification, NotificationFilter, NovuError } from '@novu/js';\nimport { useCallback, useEffect, useState } from 'react';\nimport { useDataRef } from './internal/useDataRef';\nimport { useWebSocketEvent } from './internal/useWebsocketEvent';\nimport { useNovu } from './NovuProvider';\n\n/**\n * Props for the useNotifications hook.\n *\n * @example\n * ```tsx\n * // Get unread notifications\n * const { notifications } = useNotifications({\n * read: false\n * });\n *\n * // Get unseen notifications with specific tags\n * const { notifications } = useNotifications({\n * seen: false,\n * tags: ['important']\n * });\n *\n * // Get notifications (auto-updates in real time when new notifications arrive)\n * const { notifications } = useNotifications({\n * read: false\n * });\n *\n * // Get notifications from a specific time period\n * const { notifications } = useNotifications({\n * createdGte: 1704067200000,\n * createdLte: 1735689599999\n * });\n * ```\n */\nexport type UseNotificationsProps = {\n tags?: NotificationFilter['tags'];\n data?: NotificationFilter['data'];\n read?: NotificationFilter['read'];\n archived?: NotificationFilter['archived'];\n snoozed?: NotificationFilter['snoozed'];\n seen?: NotificationFilter['seen'];\n severity?: NotificationFilter['severity'];\n createdGte?: NotificationFilter['createdGte'];\n createdLte?: NotificationFilter['createdLte'];\n limit?: number;\n onSuccess?: (data: Notification[]) => void;\n onError?: (error: NovuError) => void;\n};\n\nexport type UseNotificationsResult = {\n notifications?: Notification[];\n error?: NovuError;\n isLoading: boolean;\n isFetching: boolean;\n hasMore: boolean;\n readAll: () => Promise<{\n data?: void | undefined;\n error?: NovuError | undefined;\n }>;\n seenAll: () => Promise<{\n data?: void | undefined;\n error?: NovuError | undefined;\n }>;\n archiveAll: () => Promise<{\n data?: void | undefined;\n error?: NovuError | undefined;\n }>;\n archiveAllRead: () => Promise<{\n data?: void | undefined;\n error?: NovuError | undefined;\n }>;\n refetch: () => Promise<void>;\n fetchMore: () => Promise<void>;\n};\n\nexport const useNotifications = (props?: UseNotificationsProps): UseNotificationsResult => {\n const {\n tags,\n data: dataFilter,\n read,\n archived = false,\n snoozed = false,\n seen,\n severity,\n createdGte,\n createdLte,\n limit = 10,\n onSuccess,\n onError,\n } = props || {};\n const limitRef = useDataRef<number | undefined>(limit);\n const filterRef = useDataRef<NotificationFilter>({\n tags,\n data: dataFilter,\n read,\n archived,\n snoozed,\n seen,\n severity,\n createdGte,\n createdLte,\n });\n const novu = useNovu();\n const [data, setData] = useState<Array<Notification>>();\n const [error, setError] = useState<NovuError>();\n const [isLoading, setIsLoading] = useState(true);\n const [isFetching, setIsFetching] = useState(false);\n const [hasMore, setHasMore] = useState(false);\n const length = data?.length;\n const after = length ? data[length - 1].id : undefined;\n const afterRef = useDataRef<string | undefined>(after);\n\n useEffect(() => {\n const listener = ({\n data,\n }: {\n data: { notifications: Notification[]; hasMore: boolean; filter: NotificationFilter };\n }) => {\n if (!data || !isSameFilter(filterRef.current, data.filter)) {\n return;\n }\n\n // the event is called with the list of all notifications cached matching the current filter\n setData(data.notifications);\n setHasMore(data.hasMore);\n };\n\n const cleanup = novu.on('notifications.list.updated', listener);\n\n return () => {\n cleanup();\n };\n }, [filterRef, novu]);\n\n useWebSocketEvent({\n event: 'notifications.notification_received',\n eventHandler: ({ result: notification }) => {\n const currentFilter = filterRef.current;\n const matches = checkNotificationMatchesFilter(notification, currentFilter);\n if (matches) {\n // the limit and after props are used to create a cache key\n // the first batch of notifications in the cache doesn't include the after prop and we want to push to the first batch\n const cacheKey = { ...currentFilter, limit: limitRef.current };\n novu.notifications.cache.unshift(cacheKey, notification);\n }\n },\n });\n\n const fetchNotifications = useCallback(\n async (options?: { refetch: boolean }) => {\n if (options?.refetch) {\n setError(undefined);\n setIsLoading(true);\n setIsFetching(false);\n }\n setIsFetching(true);\n\n const response = await novu.notifications.list({\n ...filterRef.current,\n limit,\n after: options?.refetch ? undefined : afterRef.current,\n });\n\n if (response.error) {\n setError(response.error);\n onError?.(response.error);\n setIsLoading(false);\n setIsFetching(false);\n } else if (response.data) {\n const responseData = response.data;\n onSuccess?.(responseData.notifications);\n setData(responseData.notifications);\n setHasMore(responseData.hasMore);\n setIsLoading(false);\n setIsFetching(false);\n }\n },\n [novu, filterRef, afterRef, limit, onError, onSuccess]\n );\n\n useEffect(() => {\n novu.notifications.clearCache({ filter: filterRef.current });\n fetchNotifications({ refetch: true });\n }, [filterRef, novu, JSON.stringify(filterRef.current), fetchNotifications]);\n\n const refetch = useCallback(() => {\n novu.notifications.clearCache({ filter: filterRef.current });\n return fetchNotifications({ refetch: true });\n }, [filterRef, novu, fetchNotifications]);\n\n const fetchMore = useCallback(async () => {\n if (!hasMore || isFetching) return;\n\n return fetchNotifications();\n }, [hasMore, isFetching, fetchNotifications]);\n\n const readAll = useCallback(async () => {\n return await novu.notifications.readAll({ tags: filterRef.current.tags, data: filterRef.current.data });\n }, [filterRef, novu]);\n\n const seenAll = useCallback(async () => {\n return await novu.notifications.seenAll({ tags: filterRef.current.tags, data: filterRef.current.data });\n }, [filterRef, novu]);\n\n const archiveAll = useCallback(async () => {\n return await novu.notifications.archiveAll({ tags: filterRef.current.tags, data: filterRef.current.data });\n }, [filterRef, novu]);\n\n const archiveAllRead = useCallback(async () => {\n return await novu.notifications.archiveAllRead({ tags: filterRef.current.tags, data: filterRef.current.data });\n }, [filterRef, novu]);\n\n return {\n readAll,\n seenAll,\n archiveAll,\n archiveAllRead,\n notifications: data,\n error,\n isLoading,\n isFetching,\n refetch,\n fetchMore,\n hasMore,\n };\n};\n"],"mappings":";AAAA,SAAS,gCAAgC,oBAAiE;AAC1G,SAAS,aAAa,WAAW,gBAAgB;AACjD,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAClC,SAAS,eAAe;AAuEjB,IAAM,mBAAmB,CAAC,UAA0D;AACzF,QAAM;AAAA,IACJ;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA,WAAW;AAAA,IACX,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,EACF,IAAI,SAAS,CAAC;AACd,QAAM,WAAW,WAA+B,KAAK;AACrD,QAAM,YAAY,WAA+B;AAAA,IAC/C;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,OAAO,QAAQ;AACrB,QAAM,CAAC,MAAM,OAAO,IAAI,SAA8B;AACtD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAoB;AAC9C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,IAAI;AAC/C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAClD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,SAAS,MAAM;AACrB,QAAM,QAAQ,SAAS,KAAK,SAAS,CAAC,EAAE,KAAK;AAC7C,QAAM,WAAW,WAA+B,KAAK;AAErD,YAAU,MAAM;AACd,UAAM,WAAW,CAAC;AAAA,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G,CAAC,WAAW,IAAI,CAAC;AAEpB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["data"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useNotifications.ts"],"sourcesContent":["import { checkNotificationMatchesFilter, isSameFilter, Notification, NotificationFilter, NovuError } from '@novu/js';\nimport { useCallback, useEffect, useState } from 'react';\nimport { useDataRef } from './internal/useDataRef';\nimport { useWebSocketEvent } from './internal/useWebsocketEvent';\nimport { useNovu, useRealtime } from './NovuProvider';\n\n/**\n * Props for the useNotifications hook.\n *\n * @example\n * ```tsx\n * // Get unread notifications\n * const { notifications } = useNotifications({\n * read: false\n * });\n *\n * // Get unseen notifications with specific tags\n * const { notifications } = useNotifications({\n * seen: false,\n * tags: ['important']\n * });\n *\n * // Get notifications (auto-updates in real time when new notifications arrive)\n * const { notifications } = useNotifications({\n * read: false\n * });\n *\n * // Get notifications from a specific time period\n * const { notifications } = useNotifications({\n * createdGte: 1704067200000,\n * createdLte: 1735689599999\n * });\n *\n * // Opt out of the built-in realtime updates and drive them yourself\n * const { notifications, refetch } = useNotifications({\n * read: false,\n * realtime: false,\n * });\n * ```\n */\nexport type UseNotificationsProps = {\n tags?: NotificationFilter['tags'];\n data?: NotificationFilter['data'];\n read?: NotificationFilter['read'];\n archived?: NotificationFilter['archived'];\n snoozed?: NotificationFilter['snoozed'];\n seen?: NotificationFilter['seen'];\n severity?: NotificationFilter['severity'];\n createdGte?: NotificationFilter['createdGte'];\n createdLte?: NotificationFilter['createdLte'];\n limit?: number;\n /**\n * When `false`, disables the WebSocket subscription that auto-injects\n * newly received notifications into the list. Built-in mutations like\n * `readAll`, `seenAll`, `archiveAll`, and `archiveAllRead` continue to\n * update local state. Use this when you want to drive new-notification updates yourself (e.g.\n * via your own `novu.on('notifications.notification_received', ...)`\n * handler combined with `refetch()`).\n *\n * When set, this prop takes precedence over the `realtime` config on\n * `<NovuProvider />`. When omitted, the provider value (default `true`) is used.\n */\n realtime?: boolean;\n onSuccess?: (data: Notification[]) => void;\n onError?: (error: NovuError) => void;\n};\n\nexport type UseNotificationsResult = {\n notifications?: Notification[];\n error?: NovuError;\n isLoading: boolean;\n isFetching: boolean;\n hasMore: boolean;\n readAll: () => Promise<{\n data?: void | undefined;\n error?: NovuError | undefined;\n }>;\n seenAll: () => Promise<{\n data?: void | undefined;\n error?: NovuError | undefined;\n }>;\n archiveAll: () => Promise<{\n data?: void | undefined;\n error?: NovuError | undefined;\n }>;\n archiveAllRead: () => Promise<{\n data?: void | undefined;\n error?: NovuError | undefined;\n }>;\n refetch: () => Promise<void>;\n fetchMore: () => Promise<void>;\n};\n\nexport const useNotifications = (props?: UseNotificationsProps): UseNotificationsResult => {\n const {\n tags,\n data: dataFilter,\n read,\n archived = false,\n snoozed = false,\n seen,\n severity,\n createdGte,\n createdLte,\n limit = 10,\n realtime: propsRealtime,\n onSuccess,\n onError,\n } = props || {};\n const limitRef = useDataRef<number | undefined>(limit);\n const filterRef = useDataRef<NotificationFilter>({\n tags,\n data: dataFilter,\n read,\n archived,\n snoozed,\n seen,\n severity,\n createdGte,\n createdLte,\n });\n const novu = useNovu();\n const providerRealtime = useRealtime();\n const realtime = propsRealtime ?? providerRealtime;\n const [data, setData] = useState<Array<Notification>>();\n const [error, setError] = useState<NovuError>();\n const [isLoading, setIsLoading] = useState(true);\n const [isFetching, setIsFetching] = useState(false);\n const [hasMore, setHasMore] = useState(false);\n const length = data?.length;\n const after = length ? data[length - 1].id : undefined;\n const afterRef = useDataRef<string | undefined>(after);\n\n useEffect(() => {\n const listener = ({\n data,\n }: {\n data: { notifications: Notification[]; hasMore: boolean; filter: NotificationFilter };\n }) => {\n if (!data || !isSameFilter(filterRef.current, data.filter)) {\n return;\n }\n\n // the event is called with the list of all notifications cached matching the current filter\n setData(data.notifications);\n setHasMore(data.hasMore);\n };\n\n const cleanup = novu.on('notifications.list.updated', listener);\n\n return () => {\n cleanup();\n };\n }, [filterRef, novu]);\n\n useWebSocketEvent({\n event: 'notifications.notification_received',\n enabled: realtime,\n eventHandler: ({ result: notification }) => {\n const currentFilter = filterRef.current;\n const matches = checkNotificationMatchesFilter(notification, currentFilter);\n if (matches) {\n // the limit and after props are used to create a cache key\n // the first batch of notifications in the cache doesn't include the after prop and we want to push to the first batch\n const cacheKey = { ...currentFilter, limit: limitRef.current };\n novu.notifications.cache.unshift(cacheKey, notification);\n }\n },\n });\n\n const fetchNotifications = useCallback(\n async (options?: { refetch: boolean }) => {\n if (options?.refetch) {\n setError(undefined);\n setIsLoading(true);\n setIsFetching(false);\n }\n setIsFetching(true);\n\n const response = await novu.notifications.list({\n ...filterRef.current,\n limit,\n after: options?.refetch ? undefined : afterRef.current,\n });\n\n if (response.error) {\n setError(response.error);\n onError?.(response.error);\n setIsLoading(false);\n setIsFetching(false);\n } else if (response.data) {\n const responseData = response.data;\n onSuccess?.(responseData.notifications);\n setData(responseData.notifications);\n setHasMore(responseData.hasMore);\n setIsLoading(false);\n setIsFetching(false);\n }\n },\n [novu, filterRef, afterRef, limit, onError, onSuccess]\n );\n\n useEffect(() => {\n novu.notifications.clearCache({ filter: filterRef.current });\n fetchNotifications({ refetch: true });\n }, [filterRef, novu, JSON.stringify(filterRef.current), fetchNotifications]);\n\n const refetch = useCallback(() => {\n novu.notifications.clearCache({ filter: filterRef.current });\n return fetchNotifications({ refetch: true });\n }, [filterRef, novu, fetchNotifications]);\n\n const fetchMore = useCallback(async () => {\n if (!hasMore || isFetching) return;\n\n return fetchNotifications();\n }, [hasMore, isFetching, fetchNotifications]);\n\n const readAll = useCallback(async () => {\n return await novu.notifications.readAll({ tags: filterRef.current.tags, data: filterRef.current.data });\n }, [filterRef, novu]);\n\n const seenAll = useCallback(async () => {\n return await novu.notifications.seenAll({ tags: filterRef.current.tags, data: filterRef.current.data });\n }, [filterRef, novu]);\n\n const archiveAll = useCallback(async () => {\n return await novu.notifications.archiveAll({ tags: filterRef.current.tags, data: filterRef.current.data });\n }, [filterRef, novu]);\n\n const archiveAllRead = useCallback(async () => {\n return await novu.notifications.archiveAllRead({ tags: filterRef.current.tags, data: filterRef.current.data });\n }, [filterRef, novu]);\n\n return {\n readAll,\n seenAll,\n archiveAll,\n archiveAllRead,\n notifications: data,\n error,\n isLoading,\n isFetching,\n refetch,\n fetchMore,\n hasMore,\n };\n};\n"],"mappings":";AAAA,SAAS,gCAAgC,oBAAiE;AAC1G,SAAS,aAAa,WAAW,gBAAgB;AACjD,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAClC,SAAS,SAAS,mBAAmB;AAyF9B,IAAM,mBAAmB,CAAC,UAA0D;AACzF,QAAM;AAAA,IACJ;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA,WAAW;AAAA,IACX,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,UAAU;AAAA,IACV;AAAA,IACA;AAAA,EACF,IAAI,SAAS,CAAC;AACd,QAAM,WAAW,WAA+B,KAAK;AACrD,QAAM,YAAY,WAA+B;AAAA,IAC/C;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,OAAO,QAAQ;AACrB,QAAM,mBAAmB,YAAY;AACrC,QAAM,WAAW,iBAAiB;AAClC,QAAM,CAAC,MAAM,OAAO,IAAI,SAA8B;AACtD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAoB;AAC9C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,IAAI;AAC/C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAClD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,SAAS,MAAM;AACrB,QAAM,QAAQ,SAAS,KAAK,SA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;AAC7C,WAAO,MAAM,KAAK,cAAc,eAAe,EAAE,MAAM,UAAU,QAAQ,MAAM,MAAM,UAAU,QAAQ,KAAK,CAAC;AAAA,EAC/G,GAAG,CAAC,WAAW,IAAI,CAAC;AAEpB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["data"]}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
export * from '@novu/js';
|
|
2
2
|
export { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';
|
|
3
|
-
export { AllLocalization, AllLocalizationKey, ElementStyles, InboxAppearance, InboxAppearanceCallback, InboxAppearanceCallbackFunction, InboxAppearanceCallbackKeys, InboxAppearanceKey, InboxElements, InboxLocalization, InboxLocalizationKey, InboxTheme, NotificationActionClickHandler, NotificationClickHandler, NotificationRenderer, PreferenceGroups, PreferencesFilter, RouterPush, SubscriptionAppearance, SubscriptionAppearanceCallback, SubscriptionAppearanceCallbackFunction, SubscriptionAppearanceCallbackKeys, SubscriptionAppearanceKey, SubscriptionElements, SubscriptionLocalization, SubscriptionLocalizationKey, SubscriptionTheme, Tab, Variables } from '@novu/js/ui';
|
|
3
|
+
export { AllLocalization, AllLocalizationKey, ChannelConnectButtonIconKey, ElementStyles, InboxAppearance, InboxAppearanceCallback, InboxAppearanceCallbackFunction, InboxAppearanceCallbackKeys, InboxAppearanceKey, InboxElements, InboxLocalization, InboxLocalizationKey, InboxTheme, NotificationActionClickHandler, NotificationClickHandler, NotificationRenderer, PreferenceGroups, PreferencesFilter, RouterPush, SubscriptionAppearance, SubscriptionAppearanceCallback, SubscriptionAppearanceCallbackFunction, SubscriptionAppearanceCallbackKeys, SubscriptionAppearanceKey, SubscriptionElements, SubscriptionLocalization, SubscriptionLocalizationKey, SubscriptionTheme, Tab, Variables } from '@novu/js/ui';
|
|
4
4
|
export { NovuProvider, NovuProviderProps, useNovu } from './hooks/NovuProvider.js';
|
|
5
5
|
export { Bell, BellProps } from './components/Bell.js';
|
|
6
6
|
export { Inbox, InboxProps } from './components/Inbox.js';
|
|
7
7
|
export { InboxContent, InboxContentProps } from './components/InboxContent.js';
|
|
8
8
|
export { NotificationProps, Notifications } from './components/Notifications.js';
|
|
9
9
|
export { Preferences } from './components/Preferences.js';
|
|
10
|
+
export { SlackConnectButton, SlackConnectButtonProps } from './components/slack-connect-button/SlackConnectButton.js';
|
|
11
|
+
export { SlackLinkUser, SlackLinkUserProps } from './components/slack-link-user/SlackLinkUser.js';
|
|
10
12
|
export { Subscription, SubscriptionProps } from './components/subscription/Subscription.js';
|
|
11
13
|
export { SubscriptionButton, SubscriptionButtonProps } from './components/subscription/SubscriptionButton.js';
|
|
12
14
|
export { SubscriptionPreferences, SubscriptionPreferencesProps } from './components/subscription/SubscriptionPreferences.js';
|
|
15
|
+
export { UseChannelConnectionProps, UseChannelConnectionResult, useChannelConnection } from './hooks/useChannelConnection.js';
|
|
16
|
+
export { UseChannelConnectionsProps, UseChannelConnectionsResult, useChannelConnections } from './hooks/useChannelConnections.js';
|
|
17
|
+
export { UseChannelEndpointProps, UseChannelEndpointResult, useChannelEndpoint } from './hooks/useChannelEndpoint.js';
|
|
13
18
|
export { UseCountsProps, UseCountsResult, useCounts } from './hooks/useCounts.js';
|
|
19
|
+
export { UseCreateChannelEndpointProps, UseCreateChannelEndpointResult, useCreateChannelEndpoint } from './hooks/useCreateChannelEndpoint.js';
|
|
14
20
|
export { useCreateSubscription } from './hooks/useCreateSubscription.js';
|
|
21
|
+
export { UseDeleteChannelEndpointProps, UseDeleteChannelEndpointResult, useDeleteChannelEndpoint } from './hooks/useDeleteChannelEndpoint.js';
|
|
15
22
|
export { UseNotificationsProps, UseNotificationsResult, useNotifications } from './hooks/useNotifications.js';
|
|
16
23
|
export { UsePreferencesResult, usePreferences } from './hooks/usePreferences.js';
|
|
17
24
|
export { useRemoveSubscription } from './hooks/useRemoveSubscription.js';
|
|
@@ -19,8 +26,10 @@ export { UseScheduleProps as UsePreferencesProps, useSchedule } from './hooks/us
|
|
|
19
26
|
export { useSubscription } from './hooks/useSubscription.js';
|
|
20
27
|
export { useSubscriptions } from './hooks/useSubscriptions.js';
|
|
21
28
|
export { useUpdateSubscription } from './hooks/useUpdateSubscription.js';
|
|
22
|
-
export { BaseProps, BellRenderer, BodyRenderer, DefaultInboxProps, DefaultProps, NoRendererProps, NotificationRendererProps, NotificationsRenderer, ReactInboxAppearance, ReactInboxTheme, ReactSubscriptionAppearance, ReactSubscriptionTheme, SubjectBodyRendererProps, SubjectRenderer, WithChildrenProps } from './utils/types.js';
|
|
29
|
+
export { BaseProps, BellRenderer, BodyRenderer, DefaultInboxProps, DefaultProps, NoRendererProps, NotificationRendererProps, NotificationsRenderer, ReactAllAppearance, ReactInboxAppearance, ReactInboxTheme, ReactSubscriptionAppearance, ReactSubscriptionTheme, SubjectBodyRendererProps, SubjectRenderer, WithChildrenProps } from './utils/types.js';
|
|
23
30
|
import 'react/jsx-runtime';
|
|
24
31
|
import 'react';
|
|
25
32
|
import './components/NovuUI.js';
|
|
33
|
+
import './components/slack-connect-button/DefaultSlackConnectButton.js';
|
|
34
|
+
import './components/slack-link-user/DefaultSlackLinkUser.js';
|
|
26
35
|
import './components/subscription/DefaultSubscription.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -7,13 +7,20 @@ import {
|
|
|
7
7
|
Notifications,
|
|
8
8
|
NovuProvider,
|
|
9
9
|
Preferences,
|
|
10
|
+
SlackConnectButton,
|
|
11
|
+
SlackLinkUser,
|
|
10
12
|
Subscription,
|
|
11
13
|
SubscriptionButton,
|
|
12
14
|
SubscriptionPreferences
|
|
13
15
|
} from "./components/index.js";
|
|
14
16
|
import {
|
|
17
|
+
useChannelConnection,
|
|
18
|
+
useChannelConnections,
|
|
19
|
+
useChannelEndpoint,
|
|
15
20
|
useCounts,
|
|
21
|
+
useCreateChannelEndpoint,
|
|
16
22
|
useCreateSubscription,
|
|
23
|
+
useDeleteChannelEndpoint,
|
|
17
24
|
useNotifications,
|
|
18
25
|
useNovu,
|
|
19
26
|
usePreferences,
|
|
@@ -32,12 +39,19 @@ export {
|
|
|
32
39
|
PreferenceLevel,
|
|
33
40
|
Preferences,
|
|
34
41
|
SeverityLevelEnum,
|
|
42
|
+
SlackConnectButton,
|
|
43
|
+
SlackLinkUser,
|
|
35
44
|
Subscription,
|
|
36
45
|
SubscriptionButton,
|
|
37
46
|
SubscriptionPreferences,
|
|
38
47
|
WorkflowCriticalityEnum,
|
|
48
|
+
useChannelConnection,
|
|
49
|
+
useChannelConnections,
|
|
50
|
+
useChannelEndpoint,
|
|
39
51
|
useCounts,
|
|
52
|
+
useCreateChannelEndpoint,
|
|
40
53
|
useCreateSubscription,
|
|
54
|
+
useDeleteChannelEndpoint,
|
|
41
55
|
useNotifications,
|
|
42
56
|
useNovu,
|
|
43
57
|
usePreferences,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type * from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n AllLocalization,\n AllLocalizationKey,\n ElementStyles,\n InboxAppearance,\n InboxAppearanceCallback,\n InboxAppearanceCallbackFunction,\n InboxAppearanceCallbackKeys,\n InboxAppearanceKey,\n InboxElements,\n InboxLocalization,\n InboxLocalizationKey,\n InboxTheme,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\n SubscriptionAppearance,\n SubscriptionAppearanceCallback,\n SubscriptionAppearanceCallbackFunction,\n SubscriptionAppearanceCallbackKeys,\n SubscriptionAppearanceKey,\n SubscriptionElements,\n SubscriptionLocalization,\n SubscriptionLocalizationKey,\n SubscriptionTheme,\n Tab,\n Variables,\n} from '@novu/js/ui';\nexport type {\n BellProps,\n InboxContentProps,\n InboxProps,\n NotificationProps,\n NovuProviderProps,\n SubscriptionButtonProps,\n SubscriptionPreferencesProps,\n SubscriptionProps,\n} from './components';\nexport {\n Bell,\n Inbox,\n InboxContent,\n Notifications,\n NovuProvider,\n Preferences,\n Subscription,\n SubscriptionButton,\n SubscriptionPreferences,\n} from './components';\nexport type {\n UseCountsProps,\n UseCountsResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesResult,\n UseScheduleProps as UsePreferencesProps,\n} from './hooks';\nexport {\n useCounts,\n useCreateSubscription,\n useNotifications,\n useNovu,\n usePreferences,\n useRemoveSubscription,\n useSchedule,\n useSubscription,\n useSubscriptions,\n useUpdateSubscription,\n} from './hooks';\n\nexport type {\n BaseProps,\n BellRenderer,\n BodyRenderer,\n DefaultInboxProps,\n DefaultProps,\n NoRendererProps,\n NotificationRendererProps,\n NotificationsRenderer,\n ReactInboxAppearance,\n ReactInboxTheme,\n ReactSubscriptionAppearance,\n ReactSubscriptionTheme,\n SubjectBodyRendererProps,\n SubjectRenderer,\n WithChildrenProps,\n} from './utils/types';\n"],"mappings":";AACA,SAAS,iBAAiB,mBAAmB,+BAA+B;
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type * from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n AllLocalization,\n AllLocalizationKey,\n ChannelConnectButtonIconKey,\n ElementStyles,\n InboxAppearance,\n InboxAppearanceCallback,\n InboxAppearanceCallbackFunction,\n InboxAppearanceCallbackKeys,\n InboxAppearanceKey,\n InboxElements,\n InboxLocalization,\n InboxLocalizationKey,\n InboxTheme,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\n SubscriptionAppearance,\n SubscriptionAppearanceCallback,\n SubscriptionAppearanceCallbackFunction,\n SubscriptionAppearanceCallbackKeys,\n SubscriptionAppearanceKey,\n SubscriptionElements,\n SubscriptionLocalization,\n SubscriptionLocalizationKey,\n SubscriptionTheme,\n Tab,\n Variables,\n} from '@novu/js/ui';\nexport type {\n BellProps,\n InboxContentProps,\n InboxProps,\n NotificationProps,\n NovuProviderProps,\n SlackConnectButtonProps,\n SlackLinkUserProps,\n SubscriptionButtonProps,\n SubscriptionPreferencesProps,\n SubscriptionProps,\n} from './components';\nexport {\n Bell,\n Inbox,\n InboxContent,\n Notifications,\n NovuProvider,\n Preferences,\n SlackConnectButton,\n SlackLinkUser,\n Subscription,\n SubscriptionButton,\n SubscriptionPreferences,\n} from './components';\nexport type {\n UseChannelConnectionProps,\n UseChannelConnectionResult,\n UseChannelConnectionsProps,\n UseChannelConnectionsResult,\n UseChannelEndpointProps,\n UseChannelEndpointResult,\n UseCountsProps,\n UseCountsResult,\n UseCreateChannelEndpointProps,\n UseCreateChannelEndpointResult,\n UseDeleteChannelEndpointProps,\n UseDeleteChannelEndpointResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesResult,\n UseScheduleProps as UsePreferencesProps,\n} from './hooks';\nexport {\n useChannelConnection,\n useChannelConnections,\n useChannelEndpoint,\n useCounts,\n useCreateChannelEndpoint,\n useCreateSubscription,\n useDeleteChannelEndpoint,\n useNotifications,\n useNovu,\n usePreferences,\n useRemoveSubscription,\n useSchedule,\n useSubscription,\n useSubscriptions,\n useUpdateSubscription,\n} from './hooks';\n\nexport type {\n BaseProps,\n BellRenderer,\n BodyRenderer,\n DefaultInboxProps,\n DefaultProps,\n NoRendererProps,\n NotificationRendererProps,\n NotificationsRenderer,\n ReactAllAppearance,\n ReactInboxAppearance,\n ReactInboxTheme,\n ReactSubscriptionAppearance,\n ReactSubscriptionTheme,\n SubjectBodyRendererProps,\n SubjectRenderer,\n WithChildrenProps,\n} from './utils/types';\n"],"mappings":";AACA,SAAS,iBAAiB,mBAAmB,+BAA+B;AA8C5E;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAmBP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AllAppearance } from '@novu/js/ui';
|
|
2
2
|
import { MountedElement } from '../context/RendererContext.js';
|
|
3
|
-
import { ReactInboxAppearance, ReactSubscriptionAppearance } from './types.js';
|
|
3
|
+
import { ReactInboxAppearance, ReactSubscriptionAppearance, ReactAllAppearance } from './types.js';
|
|
4
4
|
import 'react/jsx-runtime';
|
|
5
5
|
import 'react';
|
|
6
6
|
import '@novu/js';
|
|
7
7
|
|
|
8
|
-
declare function adaptAppearanceForJs(appearance: ReactInboxAppearance | ReactSubscriptionAppearance, mountElement: (el: HTMLElement, mountedElement: MountedElement) => () => void): AllAppearance | undefined;
|
|
8
|
+
declare function adaptAppearanceForJs(appearance: ReactInboxAppearance | ReactSubscriptionAppearance | ReactAllAppearance, mountElement: (el: HTMLElement, mountedElement: MountedElement) => () => void): AllAppearance | undefined;
|
|
9
9
|
|
|
10
10
|
export { adaptAppearanceForJs };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/appearance.ts"],"sourcesContent":["import type { AllAppearance, AllIconKey, AllIconOverrides } from '@novu/js/ui';\nimport { MountedElement } from '../context/RendererContext';\nimport type { ReactIconRenderer, ReactInboxAppearance, ReactSubscriptionAppearance } from './types';\n\nexport function adaptAppearanceForJs(\n appearance: ReactInboxAppearance | ReactSubscriptionAppearance,\n mountElement: (el: HTMLElement, mountedElement: MountedElement) => () => void\n): AllAppearance | undefined {\n if (!appearance) {\n return undefined;\n }\n const { icons, ...restAppearance } = appearance;\n const jsAppearance = { ...restAppearance } as AllAppearance;\n\n if (icons) {\n const jsIcons: AllIconOverrides = {};\n const iconKeys = Object.keys(icons) as Array<AllIconKey>;\n\n for (const iconKey of iconKeys) {\n // @ts-expect-error: cant easily fix this type error\n const reactRenderer = icons[iconKey] as ReactIconRenderer;\n\n if (reactRenderer) {\n jsIcons[iconKey] = (el: HTMLDivElement, props: { class?: string }) => {\n return mountElement(el, reactRenderer(props));\n };\n }\n }\n\n // JsAppearance also has .icons directly (from JsTheme part of JsAppearance)\n jsAppearance.icons = jsIcons;\n } else {\n // If original didn't have icons, ensure the clone doesn't either\n delete jsAppearance.icons;\n }\n\n return jsAppearance;\n}\n"],"mappings":";AAIO,SAAS,qBACd,YACA,cAC2B;AAC3B,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,EACT;AACA,QAAM,EAAE,OAAO,GAAG,eAAe,IAAI;AACrC,QAAM,eAAe,EAAE,GAAG,eAAe;AAEzC,MAAI,OAAO;AACT,UAAM,UAA4B,CAAC;AACnC,UAAM,WAAW,OAAO,KAAK,KAAK;AAElC,eAAW,WAAW,UAAU;AAE9B,YAAM,gBAAgB,MAAM,OAAO;AAEnC,UAAI,eAAe;AACjB,gBAAQ,OAAO,IAAI,CAAC,IAAoB,UAA8B;AACpE,iBAAO,aAAa,IAAI,cAAc,KAAK,CAAC;AAAA,QAC9C;AAAA,MACF;AAAA,IACF;AAGA,iBAAa,QAAQ;AAAA,EACvB,OAAO;AAEL,WAAO,aAAa;AAAA,EACtB;AAEA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/appearance.ts"],"sourcesContent":["import type { AllAppearance, AllIconKey, AllIconOverrides } from '@novu/js/ui';\nimport { MountedElement } from '../context/RendererContext';\nimport type { ReactAllAppearance, ReactIconRenderer, ReactInboxAppearance, ReactSubscriptionAppearance } from './types';\n\nexport function adaptAppearanceForJs(\n appearance: ReactInboxAppearance | ReactSubscriptionAppearance | ReactAllAppearance,\n mountElement: (el: HTMLElement, mountedElement: MountedElement) => () => void\n): AllAppearance | undefined {\n if (!appearance) {\n return undefined;\n }\n const { icons, ...restAppearance } = appearance;\n const jsAppearance = { ...restAppearance } as AllAppearance;\n\n if (icons) {\n const jsIcons: AllIconOverrides = {};\n const iconKeys = Object.keys(icons) as Array<AllIconKey>;\n\n for (const iconKey of iconKeys) {\n // @ts-expect-error: cant easily fix this type error\n const reactRenderer = icons[iconKey] as ReactIconRenderer;\n\n if (reactRenderer) {\n jsIcons[iconKey] = (el: HTMLDivElement, props: { class?: string }) => {\n return mountElement(el, reactRenderer(props));\n };\n }\n }\n\n // JsAppearance also has .icons directly (from JsTheme part of JsAppearance)\n jsAppearance.icons = jsIcons;\n } else {\n // If original didn't have icons, ensure the clone doesn't either\n delete jsAppearance.icons;\n }\n\n return jsAppearance;\n}\n"],"mappings":";AAIO,SAAS,qBACd,YACA,cAC2B;AAC3B,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,EACT;AACA,QAAM,EAAE,OAAO,GAAG,eAAe,IAAI;AACrC,QAAM,eAAe,EAAE,GAAG,eAAe;AAEzC,MAAI,OAAO;AACT,UAAM,UAA4B,CAAC;AACnC,UAAM,WAAW,OAAO,KAAK,KAAK;AAElC,eAAW,WAAW,UAAU;AAE9B,YAAM,gBAAgB,MAAM,OAAO;AAEnC,UAAI,eAAe;AACjB,gBAAQ,OAAO,IAAI,CAAC,IAAoB,UAA8B;AACpE,iBAAO,aAAa,IAAI,cAAc,KAAK,CAAC;AAAA,QAC9C;AAAA,MACF;AAAA,IACF;AAGA,iBAAa,QAAQ;AAAA,EACvB,OAAO;AAEL,WAAO,aAAa;AAAA,EACtB;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NovuSocketOptions, DefaultSchedule, Context, Subscriber, UnreadCount } from '@novu/js';
|
|
2
|
-
import { InboxTheme, InboxIconKey, InboxLocalization, Tab, PreferencesFilter, PreferenceGroups, PreferencesSort, RouterPush, Notification, NotificationClickHandler, NotificationActionClickHandler, InboxProps,
|
|
2
|
+
import { InboxTheme, InboxIconKey, InboxLocalization, Tab, PreferencesFilter, PreferenceGroups, PreferencesSort, RouterPush, Notification, NotificationClickHandler, NotificationActionClickHandler, InboxProps, AllTheme, AllIconKey, SubscriptionTheme, SubscriptionIconKey } from '@novu/js/ui';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
|
|
5
5
|
type NotificationsRenderer = (notification: Notification) => React.ReactNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novu/react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/novuhq/novu",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
"dependencies": {
|
|
124
|
-
"@novu/js": "3.
|
|
124
|
+
"@novu/js": "3.16.0"
|
|
125
125
|
},
|
|
126
126
|
"nx": {
|
|
127
127
|
"tags": [
|