@novu/react 3.17.0 → 3.18.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/index.cjs +3 -1
- package/dist/cjs/components/index.cjs.map +1 -1
- package/dist/cjs/components/index.d.cts +2 -0
- package/dist/cjs/components/telegram-connect-button/DefaultTelegramConnectButton.cjs +77 -0
- package/dist/cjs/components/telegram-connect-button/DefaultTelegramConnectButton.cjs.map +1 -0
- package/dist/cjs/components/telegram-connect-button/DefaultTelegramConnectButton.d.cts +7 -0
- package/dist/cjs/components/telegram-connect-button/TelegramConnectButton.cjs +63 -0
- package/dist/cjs/components/telegram-connect-button/TelegramConnectButton.cjs.map +1 -0
- package/dist/cjs/components/telegram-connect-button/TelegramConnectButton.d.cts +12 -0
- package/dist/cjs/hooks/index.cjs +2 -0
- package/dist/cjs/hooks/index.cjs.map +1 -1
- package/dist/cjs/hooks/index.d.cts +1 -0
- package/dist/cjs/hooks/useCounts.cjs +64 -45
- package/dist/cjs/hooks/useCounts.cjs.map +1 -1
- package/dist/cjs/hooks/usePreferences.cjs +2 -1
- package/dist/cjs/hooks/usePreferences.cjs.map +1 -1
- package/dist/cjs/hooks/useSchedule.cjs +2 -1
- package/dist/cjs/hooks/useSchedule.cjs.map +1 -1
- package/dist/cjs/hooks/useTelegramSubscriberLink.cjs +82 -0
- package/dist/cjs/hooks/useTelegramSubscriberLink.cjs.map +1 -0
- package/dist/cjs/hooks/useTelegramSubscriberLink.d.cts +51 -0
- package/dist/cjs/index.cjs +4 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +3 -0
- package/dist/cjs/server/index.cjs +25 -0
- package/dist/cjs/server/index.cjs.map +1 -1
- package/dist/cjs/server/index.d.cts +6 -1
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/components/telegram-connect-button/DefaultTelegramConnectButton.d.ts +7 -0
- package/dist/esm/components/telegram-connect-button/DefaultTelegramConnectButton.js +52 -0
- package/dist/esm/components/telegram-connect-button/DefaultTelegramConnectButton.js.map +1 -0
- package/dist/esm/components/telegram-connect-button/TelegramConnectButton.d.ts +12 -0
- package/dist/esm/components/telegram-connect-button/TelegramConnectButton.js +28 -0
- package/dist/esm/components/telegram-connect-button/TelegramConnectButton.js.map +1 -0
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/useCounts.js +65 -47
- package/dist/esm/hooks/useCounts.js.map +1 -1
- package/dist/esm/hooks/usePreferences.js +2 -1
- package/dist/esm/hooks/usePreferences.js.map +1 -1
- package/dist/esm/hooks/useSchedule.js +2 -1
- package/dist/esm/hooks/useSchedule.js.map +1 -1
- package/dist/esm/hooks/useTelegramSubscriberLink.d.ts +51 -0
- package/dist/esm/hooks/useTelegramSubscriberLink.js +57 -0
- package/dist/esm/hooks/useTelegramSubscriberLink.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/server/index.d.ts +6 -1
- package/dist/esm/server/index.js +20 -0
- package/dist/esm/server/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { TelegramSubscriberLinkOptions, TelegramSubscriberLinkStatus } from '@novu/js';
|
|
2
|
+
|
|
3
|
+
type UseTelegramSubscriberLinkProps = TelegramSubscriberLinkOptions;
|
|
4
|
+
type UseTelegramSubscriberLinkResult = {
|
|
5
|
+
/** Current deep-link URL (`t.me/<bot>?start=<code>`), or `null` before the first issue. */
|
|
6
|
+
deepLinkUrl: string | null;
|
|
7
|
+
/** Telegram bot username (no `@`), or `null` before the first issue. */
|
|
8
|
+
botUsername: string | null;
|
|
9
|
+
/** Lifecycle status: `loading` while resolving initial state, `pending` while waiting for Start, `connected` once linked, `expired` briefly before auto-reissue. */
|
|
10
|
+
status: TelegramSubscriberLinkStatus;
|
|
11
|
+
/** Last error, if any. */
|
|
12
|
+
error: Error | null;
|
|
13
|
+
/** Re-issue a fresh deep link and restart polling. */
|
|
14
|
+
refresh: () => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* React hook wrapping {@link TelegramSubscriberLink} from `@novu/js`.
|
|
18
|
+
*
|
|
19
|
+
* Issues a Telegram subscriber-link deep link, polls for connection, and
|
|
20
|
+
* re-issues automatically on code expiry. Returns reactive state that
|
|
21
|
+
* updates as the lifecycle progresses.
|
|
22
|
+
*
|
|
23
|
+
* **Important:** The underlying API endpoint requires `INTEGRATION_WRITE` permission.
|
|
24
|
+
* Either pass `secretKey` for direct server-side usage, or provide a custom
|
|
25
|
+
* `fetchFn` / `apiUrl` that routes through your backend proxy.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* import { useTelegramSubscriberLink } from '@novu/react';
|
|
30
|
+
*
|
|
31
|
+
* function TelegramConnect() {
|
|
32
|
+
* const { deepLinkUrl, botUsername, status, refresh } = useTelegramSubscriberLink({
|
|
33
|
+
* apiUrl: '/api/novu-proxy',
|
|
34
|
+
* integrationIdentifier: '<telegram-integration-identifier>',
|
|
35
|
+
* subscriberId: 'user-42',
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* if (status === 'connected') return <p>Connected!</p>;
|
|
39
|
+
*
|
|
40
|
+
* return (
|
|
41
|
+
* <div>
|
|
42
|
+
* {deepLinkUrl && <a href={deepLinkUrl}>Open @{botUsername} in Telegram</a>}
|
|
43
|
+
* <button onClick={refresh}>Refresh link</button>
|
|
44
|
+
* </div>
|
|
45
|
+
* );
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
declare function useTelegramSubscriberLink(props: UseTelegramSubscriberLinkProps): UseTelegramSubscriberLinkResult;
|
|
50
|
+
|
|
51
|
+
export { type UseTelegramSubscriberLinkProps, type UseTelegramSubscriberLinkResult, useTelegramSubscriberLink };
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
Subscription: () => import_components.Subscription,
|
|
36
36
|
SubscriptionButton: () => import_components.SubscriptionButton,
|
|
37
37
|
SubscriptionPreferences: () => import_components.SubscriptionPreferences,
|
|
38
|
+
TelegramConnectButton: () => import_components.TelegramConnectButton,
|
|
38
39
|
WorkflowCriticalityEnum: () => import_js.WorkflowCriticalityEnum,
|
|
39
40
|
useChannelConnection: () => import_hooks.useChannelConnection,
|
|
40
41
|
useChannelConnections: () => import_hooks.useChannelConnections,
|
|
@@ -50,6 +51,7 @@ __export(index_exports, {
|
|
|
50
51
|
useSchedule: () => import_hooks.useSchedule,
|
|
51
52
|
useSubscription: () => import_hooks.useSubscription,
|
|
52
53
|
useSubscriptions: () => import_hooks.useSubscriptions,
|
|
54
|
+
useTelegramSubscriberLink: () => import_hooks.useTelegramSubscriberLink,
|
|
53
55
|
useUpdateSubscription: () => import_hooks.useUpdateSubscription
|
|
54
56
|
});
|
|
55
57
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -73,6 +75,7 @@ var import_hooks = require("./hooks/index.cjs");
|
|
|
73
75
|
Subscription,
|
|
74
76
|
SubscriptionButton,
|
|
75
77
|
SubscriptionPreferences,
|
|
78
|
+
TelegramConnectButton,
|
|
76
79
|
WorkflowCriticalityEnum,
|
|
77
80
|
useChannelConnection,
|
|
78
81
|
useChannelConnections,
|
|
@@ -88,6 +91,7 @@ var import_hooks = require("./hooks/index.cjs");
|
|
|
88
91
|
useSchedule,
|
|
89
92
|
useSubscription,
|
|
90
93
|
useSubscriptions,
|
|
94
|
+
useTelegramSubscriberLink,
|
|
91
95
|
useUpdateSubscription
|
|
92
96
|
});
|
|
93
97
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.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 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 MsTeamsConnectButtonProps,\n MsTeamsLinkUserProps,\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 MsTeamsConnectButton,\n MsTeamsLinkUser,\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gBAA4E;
|
|
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 MsTeamsConnectButtonProps,\n MsTeamsLinkUserProps,\n NotificationProps,\n NovuProviderProps,\n SlackConnectButtonProps,\n SlackLinkUserProps,\n SubscriptionButtonProps,\n SubscriptionPreferencesProps,\n SubscriptionProps,\n TelegramConnectButtonProps,\n} from './components';\nexport {\n Bell,\n Inbox,\n InboxContent,\n MsTeamsConnectButton,\n MsTeamsLinkUser,\n Notifications,\n NovuProvider,\n Preferences,\n SlackConnectButton,\n SlackLinkUser,\n Subscription,\n SubscriptionButton,\n SubscriptionPreferences,\n TelegramConnectButton,\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 UseTelegramSubscriberLinkProps,\n UseTelegramSubscriberLinkResult,\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 useTelegramSubscriberLink,\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gBAA4E;AAiD5E,wBAeO;AAqBP,mBAiBO;","names":[]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -14,6 +14,7 @@ export { SlackLinkUser, SlackLinkUserProps } from './components/slack-link-user/
|
|
|
14
14
|
export { Subscription, SubscriptionProps } from './components/subscription/Subscription.cjs';
|
|
15
15
|
export { SubscriptionButton, SubscriptionButtonProps } from './components/subscription/SubscriptionButton.cjs';
|
|
16
16
|
export { SubscriptionPreferences, SubscriptionPreferencesProps } from './components/subscription/SubscriptionPreferences.cjs';
|
|
17
|
+
export { TelegramConnectButton, TelegramConnectButtonProps } from './components/telegram-connect-button/TelegramConnectButton.cjs';
|
|
17
18
|
export { UseChannelConnectionProps, UseChannelConnectionResult, useChannelConnection } from './hooks/useChannelConnection.cjs';
|
|
18
19
|
export { UseChannelConnectionsProps, UseChannelConnectionsResult, useChannelConnections } from './hooks/useChannelConnections.cjs';
|
|
19
20
|
export { UseChannelEndpointProps, UseChannelEndpointResult, useChannelEndpoint } from './hooks/useChannelEndpoint.cjs';
|
|
@@ -27,6 +28,7 @@ export { useRemoveSubscription } from './hooks/useRemoveSubscription.cjs';
|
|
|
27
28
|
export { UseScheduleProps as UsePreferencesProps, useSchedule } from './hooks/useSchedule.cjs';
|
|
28
29
|
export { useSubscription } from './hooks/useSubscription.cjs';
|
|
29
30
|
export { useSubscriptions } from './hooks/useSubscriptions.cjs';
|
|
31
|
+
export { UseTelegramSubscriberLinkProps, UseTelegramSubscriberLinkResult, useTelegramSubscriberLink } from './hooks/useTelegramSubscriberLink.cjs';
|
|
30
32
|
export { useUpdateSubscription } from './hooks/useUpdateSubscription.cjs';
|
|
31
33
|
export { BaseProps, BellRenderer, BodyRenderer, DefaultInboxProps, DefaultProps, NoRendererProps, NotificationRendererProps, NotificationsRenderer, ReactAllAppearance, ReactInboxAppearance, ReactInboxTheme, ReactSubscriptionAppearance, ReactSubscriptionTheme, SubjectBodyRendererProps, SubjectRenderer, WithChildrenProps } from './utils/types.cjs';
|
|
32
34
|
import 'react/jsx-runtime';
|
|
@@ -37,3 +39,4 @@ import './components/msteams-link-user/DefaultMsTeamsLinkUser.cjs';
|
|
|
37
39
|
import './components/slack-connect-button/DefaultSlackConnectButton.cjs';
|
|
38
40
|
import './components/slack-link-user/DefaultSlackLinkUser.cjs';
|
|
39
41
|
import './components/subscription/DefaultSubscription.cjs';
|
|
42
|
+
import './components/telegram-connect-button/DefaultTelegramConnectButton.cjs';
|
|
@@ -23,14 +23,19 @@ __export(server_exports, {
|
|
|
23
23
|
Bell: () => Bell,
|
|
24
24
|
Inbox: () => Inbox,
|
|
25
25
|
InboxContent: () => InboxContent,
|
|
26
|
+
MsTeamsConnectButton: () => MsTeamsConnectButton,
|
|
27
|
+
MsTeamsLinkUser: () => MsTeamsLinkUser,
|
|
26
28
|
Notifications: () => Notifications,
|
|
27
29
|
NovuProvider: () => NovuProvider,
|
|
28
30
|
PreferenceLevel: () => import_js.PreferenceLevel,
|
|
29
31
|
Preferences: () => Preferences,
|
|
30
32
|
SeverityLevelEnum: () => import_js.SeverityLevelEnum,
|
|
33
|
+
SlackConnectButton: () => SlackConnectButton,
|
|
34
|
+
SlackLinkUser: () => SlackLinkUser,
|
|
31
35
|
Subscription: () => Subscription,
|
|
32
36
|
SubscriptionButton: () => SubscriptionButton,
|
|
33
37
|
SubscriptionPreferences: () => SubscriptionPreferences,
|
|
38
|
+
TelegramConnectButton: () => TelegramConnectButton,
|
|
34
39
|
WorkflowCriticalityEnum: () => import_js.WorkflowCriticalityEnum,
|
|
35
40
|
useCounts: () => useCounts,
|
|
36
41
|
useCreateSubscription: () => useCreateSubscription,
|
|
@@ -68,6 +73,21 @@ function SubscriptionButton() {
|
|
|
68
73
|
}
|
|
69
74
|
function SubscriptionPreferences() {
|
|
70
75
|
}
|
|
76
|
+
function SlackConnectButton() {
|
|
77
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ShadowRootDetector.ShadowRootDetector, {});
|
|
78
|
+
}
|
|
79
|
+
function SlackLinkUser() {
|
|
80
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ShadowRootDetector.ShadowRootDetector, {});
|
|
81
|
+
}
|
|
82
|
+
function MsTeamsConnectButton() {
|
|
83
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ShadowRootDetector.ShadowRootDetector, {});
|
|
84
|
+
}
|
|
85
|
+
function MsTeamsLinkUser() {
|
|
86
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ShadowRootDetector.ShadowRootDetector, {});
|
|
87
|
+
}
|
|
88
|
+
function TelegramConnectButton() {
|
|
89
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ShadowRootDetector.ShadowRootDetector, {});
|
|
90
|
+
}
|
|
71
91
|
function useNovu() {
|
|
72
92
|
return null;
|
|
73
93
|
}
|
|
@@ -145,14 +165,19 @@ function useSubscriptions(_) {
|
|
|
145
165
|
Bell,
|
|
146
166
|
Inbox,
|
|
147
167
|
InboxContent,
|
|
168
|
+
MsTeamsConnectButton,
|
|
169
|
+
MsTeamsLinkUser,
|
|
148
170
|
Notifications,
|
|
149
171
|
NovuProvider,
|
|
150
172
|
PreferenceLevel,
|
|
151
173
|
Preferences,
|
|
152
174
|
SeverityLevelEnum,
|
|
175
|
+
SlackConnectButton,
|
|
176
|
+
SlackLinkUser,
|
|
153
177
|
Subscription,
|
|
154
178
|
SubscriptionButton,
|
|
155
179
|
SubscriptionPreferences,
|
|
180
|
+
TelegramConnectButton,
|
|
156
181
|
WorkflowCriticalityEnum,
|
|
157
182
|
useCounts,
|
|
158
183
|
useCreateSubscription,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/index.tsx"],"sourcesContent":["import type { InboxProps } from '../components/Inbox';\nimport { ShadowRootDetector } from '../components/ShadowRootDetector';\nimport type {\n UseCreateSubscriptionProps,\n UseCreateSubscriptionResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesProps,\n UsePreferencesResult,\n UseRemoveSubscriptionProps,\n UseRemoveSubscriptionResult,\n UseScheduleProps,\n UseScheduleResult,\n UseSubscriptionProps,\n UseSubscriptionResult,\n UseSubscriptionsProps,\n UseSubscriptionsResult,\n UseUpdateSubscriptionProps,\n UseUpdateSubscriptionResult,\n} from '../hooks';\nimport type { NovuProviderProps } from '../hooks/NovuProvider';\nimport type { UseCountsProps, UseCountsResult } from '../hooks/useCounts';\n\n/**\n * Exporting all components from the components folder\n * as empty functions to fix build errors in SSR\n * This will be replaced with actual components\n * when we implement the SSR components in @novu/js/ui\n */\nexport function Inbox(props: InboxProps) {\n return <ShadowRootDetector />;\n}\n\nexport function InboxContent() {}\n\nexport function Notifications() {}\n\nexport function Preferences() {}\n\nexport function Bell() {}\n\nexport function NovuProvider(props: NovuProviderProps) {\n return <>{props.children}</>;\n}\n\nexport function Subscription() {\n return <ShadowRootDetector />;\n}\n\nexport function SubscriptionButton() {}\n\nexport function SubscriptionPreferences() {}\n\nexport function useNovu() {\n return null;\n}\n\nexport function useCounts(_: UseCountsProps): UseCountsResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useNotifications(_: UseNotificationsProps): UseNotificationsResult {\n return {\n isLoading: false,\n isFetching: false,\n hasMore: false,\n readAll: () => Promise.resolve({ data: undefined, error: undefined }),\n seenAll: () => Promise.resolve({ data: undefined, error: undefined }),\n archiveAll: () => Promise.resolve({ data: undefined, error: undefined }),\n archiveAllRead: () => Promise.resolve({ data: undefined, error: undefined }),\n refetch: () => Promise.resolve(),\n fetchMore: () => Promise.resolve(),\n };\n}\n\nexport function usePreferences(_: UsePreferencesProps): UsePreferencesResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useSchedule(_: UseScheduleProps): UseScheduleResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useSubscription(_: UseSubscriptionProps): UseSubscriptionResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useCreateSubscription(_: UseCreateSubscriptionProps = {}): UseCreateSubscriptionResult {\n return {\n isCreating: false,\n error: undefined,\n create: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useUpdateSubscription(_: UseUpdateSubscriptionProps = {}): UseUpdateSubscriptionResult {\n return {\n isUpdating: false,\n error: undefined,\n update: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useRemoveSubscription(_: UseRemoveSubscriptionProps = {}): UseRemoveSubscriptionResult {\n return {\n isRemoving: false,\n error: undefined,\n remove: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useSubscriptions(_: UseSubscriptionsProps): UseSubscriptionsResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport 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';\n\nexport type { BellProps, InboxContentProps, InboxProps, NotificationProps, NovuProviderProps } from '../components';\n\nexport type {\n UseCountsProps,\n UseCountsResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesResult,\n UseScheduleProps as UsePreferencesProps,\n} from '../hooks';\n\nexport type {\n BaseProps,\n BellRenderer,\n BodyRenderer,\n DefaultInboxProps,\n DefaultProps,\n NoRendererProps,\n NotificationRendererProps,\n NotificationsRenderer,\n SubjectBodyRendererProps,\n SubjectRenderer,\n WithChildrenProps,\n} from '../utils/types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gCAAmC;
|
|
1
|
+
{"version":3,"sources":["../../../src/server/index.tsx"],"sourcesContent":["import type { InboxProps } from '../components/Inbox';\nimport { ShadowRootDetector } from '../components/ShadowRootDetector';\nimport type {\n UseCreateSubscriptionProps,\n UseCreateSubscriptionResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesProps,\n UsePreferencesResult,\n UseRemoveSubscriptionProps,\n UseRemoveSubscriptionResult,\n UseScheduleProps,\n UseScheduleResult,\n UseSubscriptionProps,\n UseSubscriptionResult,\n UseSubscriptionsProps,\n UseSubscriptionsResult,\n UseUpdateSubscriptionProps,\n UseUpdateSubscriptionResult,\n} from '../hooks';\nimport type { NovuProviderProps } from '../hooks/NovuProvider';\nimport type { UseCountsProps, UseCountsResult } from '../hooks/useCounts';\n\n/**\n * Exporting all components from the components folder\n * as empty functions to fix build errors in SSR\n * This will be replaced with actual components\n * when we implement the SSR components in @novu/js/ui\n */\nexport function Inbox(props: InboxProps) {\n return <ShadowRootDetector />;\n}\n\nexport function InboxContent() {}\n\nexport function Notifications() {}\n\nexport function Preferences() {}\n\nexport function Bell() {}\n\nexport function NovuProvider(props: NovuProviderProps) {\n return <>{props.children}</>;\n}\n\nexport function Subscription() {\n return <ShadowRootDetector />;\n}\n\nexport function SubscriptionButton() {}\n\nexport function SubscriptionPreferences() {}\n\nexport function SlackConnectButton() {\n return <ShadowRootDetector />;\n}\n\nexport function SlackLinkUser() {\n return <ShadowRootDetector />;\n}\n\nexport function MsTeamsConnectButton() {\n return <ShadowRootDetector />;\n}\n\nexport function MsTeamsLinkUser() {\n return <ShadowRootDetector />;\n}\n\nexport function TelegramConnectButton() {\n return <ShadowRootDetector />;\n}\n\nexport function useNovu() {\n return null;\n}\n\nexport function useCounts(_: UseCountsProps): UseCountsResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useNotifications(_: UseNotificationsProps): UseNotificationsResult {\n return {\n isLoading: false,\n isFetching: false,\n hasMore: false,\n readAll: () => Promise.resolve({ data: undefined, error: undefined }),\n seenAll: () => Promise.resolve({ data: undefined, error: undefined }),\n archiveAll: () => Promise.resolve({ data: undefined, error: undefined }),\n archiveAllRead: () => Promise.resolve({ data: undefined, error: undefined }),\n refetch: () => Promise.resolve(),\n fetchMore: () => Promise.resolve(),\n };\n}\n\nexport function usePreferences(_: UsePreferencesProps): UsePreferencesResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useSchedule(_: UseScheduleProps): UseScheduleResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useSubscription(_: UseSubscriptionProps): UseSubscriptionResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useCreateSubscription(_: UseCreateSubscriptionProps = {}): UseCreateSubscriptionResult {\n return {\n isCreating: false,\n error: undefined,\n create: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useUpdateSubscription(_: UseUpdateSubscriptionProps = {}): UseUpdateSubscriptionResult {\n return {\n isUpdating: false,\n error: undefined,\n update: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useRemoveSubscription(_: UseRemoveSubscriptionProps = {}): UseRemoveSubscriptionResult {\n return {\n isRemoving: false,\n error: undefined,\n remove: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useSubscriptions(_: UseSubscriptionsProps): UseSubscriptionsResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport 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';\n\nexport type { BellProps, InboxContentProps, InboxProps, NotificationProps, NovuProviderProps } from '../components';\n\nexport type {\n UseCountsProps,\n UseCountsResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesResult,\n UseScheduleProps as UsePreferencesProps,\n} from '../hooks';\n\nexport type {\n BaseProps,\n BellRenderer,\n BodyRenderer,\n DefaultInboxProps,\n DefaultProps,\n NoRendererProps,\n NotificationRendererProps,\n NotificationsRenderer,\n SubjectBodyRendererProps,\n SubjectRenderer,\n WithChildrenProps,\n} from '../utils/types';\n"],"mappings":"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","names":[]}
|
|
@@ -34,6 +34,11 @@ declare function NovuProvider(props: NovuProviderProps): react_jsx_runtime.JSX.E
|
|
|
34
34
|
declare function Subscription(): react_jsx_runtime.JSX.Element;
|
|
35
35
|
declare function SubscriptionButton(): void;
|
|
36
36
|
declare function SubscriptionPreferences(): void;
|
|
37
|
+
declare function SlackConnectButton(): react_jsx_runtime.JSX.Element;
|
|
38
|
+
declare function SlackLinkUser(): react_jsx_runtime.JSX.Element;
|
|
39
|
+
declare function MsTeamsConnectButton(): react_jsx_runtime.JSX.Element;
|
|
40
|
+
declare function MsTeamsLinkUser(): react_jsx_runtime.JSX.Element;
|
|
41
|
+
declare function TelegramConnectButton(): react_jsx_runtime.JSX.Element;
|
|
37
42
|
declare function useNovu(): null;
|
|
38
43
|
declare function useCounts(_: UseCountsProps): UseCountsResult;
|
|
39
44
|
declare function useNotifications(_: UseNotificationsProps): UseNotificationsResult;
|
|
@@ -45,4 +50,4 @@ declare function useUpdateSubscription(_?: UseUpdateSubscriptionProps): UseUpdat
|
|
|
45
50
|
declare function useRemoveSubscription(_?: UseRemoveSubscriptionProps): UseRemoveSubscriptionResult;
|
|
46
51
|
declare function useSubscriptions(_: UseSubscriptionsProps): UseSubscriptionsResult;
|
|
47
52
|
|
|
48
|
-
export { Bell, Inbox, InboxContent, InboxProps, Notifications, NovuProvider, NovuProviderProps, Preferences, Subscription, SubscriptionButton, SubscriptionPreferences, UseCountsProps, UseCountsResult, UseNotificationsProps, UseNotificationsResult, UseScheduleProps as UsePreferencesProps, UsePreferencesResult, useCounts, useCreateSubscription, useNotifications, useNovu, usePreferences, useRemoveSubscription, useSchedule, useSubscription, useSubscriptions, useUpdateSubscription };
|
|
53
|
+
export { Bell, Inbox, InboxContent, InboxProps, MsTeamsConnectButton, MsTeamsLinkUser, Notifications, NovuProvider, NovuProviderProps, Preferences, SlackConnectButton, SlackLinkUser, Subscription, SubscriptionButton, SubscriptionPreferences, TelegramConnectButton, UseCountsProps, UseCountsResult, UseNotificationsProps, UseNotificationsResult, UseScheduleProps as UsePreferencesProps, UsePreferencesResult, useCounts, useCreateSubscription, useNotifications, useNovu, usePreferences, useRemoveSubscription, useSchedule, useSubscription, useSubscriptions, useUpdateSubscription };
|
|
@@ -11,6 +11,7 @@ export { SlackLinkUser, SlackLinkUserProps } from './slack-link-user/SlackLinkUs
|
|
|
11
11
|
export { Subscription, SubscriptionProps } from './subscription/Subscription.js';
|
|
12
12
|
export { SubscriptionButton, SubscriptionButtonProps } from './subscription/SubscriptionButton.js';
|
|
13
13
|
export { SubscriptionPreferences, SubscriptionPreferencesProps } from './subscription/SubscriptionPreferences.js';
|
|
14
|
+
export { TelegramConnectButton, TelegramConnectButtonProps } from './telegram-connect-button/TelegramConnectButton.js';
|
|
14
15
|
import 'react/jsx-runtime';
|
|
15
16
|
import '@novu/js';
|
|
16
17
|
import 'react';
|
|
@@ -22,3 +23,4 @@ import './msteams-link-user/DefaultMsTeamsLinkUser.js';
|
|
|
22
23
|
import './slack-connect-button/DefaultSlackConnectButton.js';
|
|
23
24
|
import './slack-link-user/DefaultSlackLinkUser.js';
|
|
24
25
|
import './subscription/DefaultSubscription.js';
|
|
26
|
+
import './telegram-connect-button/DefaultTelegramConnectButton.js';
|
|
@@ -12,4 +12,5 @@ export * from "./slack-link-user/SlackLinkUser.js";
|
|
|
12
12
|
export * from "./subscription/Subscription.js";
|
|
13
13
|
export * from "./subscription/SubscriptionButton.js";
|
|
14
14
|
export * from "./subscription/SubscriptionPreferences.js";
|
|
15
|
+
export * from "./telegram-connect-button/TelegramConnectButton.js";
|
|
15
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/index.ts"],"sourcesContent":["export * from '../hooks/NovuProvider';\nexport * from './Bell';\nexport * from './Inbox';\nexport * from './InboxContent';\nexport * from './msteams-connect-button/MsTeamsConnectButton';\nexport * from './msteams-link-user/MsTeamsLinkUser';\nexport * from './Notifications';\nexport * from './Preferences';\nexport * from './slack-connect-button/SlackConnectButton';\nexport * from './slack-link-user/SlackLinkUser';\nexport * from './subscription/Subscription';\nexport * from './subscription/SubscriptionButton';\nexport * from './subscription/SubscriptionPreferences';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/index.ts"],"sourcesContent":["export * from '../hooks/NovuProvider';\nexport * from './Bell';\nexport * from './Inbox';\nexport * from './InboxContent';\nexport * from './msteams-connect-button/MsTeamsConnectButton';\nexport * from './msteams-link-user/MsTeamsLinkUser';\nexport * from './Notifications';\nexport * from './Preferences';\nexport * from './slack-connect-button/SlackConnectButton';\nexport * from './slack-link-user/SlackLinkUser';\nexport * from './subscription/Subscription';\nexport * from './subscription/SubscriptionButton';\nexport * from './subscription/SubscriptionPreferences';\nexport * from './telegram-connect-button/TelegramConnectButton';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { TelegramConnectButtonProps } from '@novu/js/ui';
|
|
3
|
+
|
|
4
|
+
type DefaultTelegramConnectButtonProps = Pick<TelegramConnectButtonProps, 'integrationIdentifier' | 'subscriberId' | 'onConnectSuccess' | 'onConnectError' | 'onDisconnectSuccess' | 'onDisconnectError' | 'connectLabel' | 'connectedLabel'>;
|
|
5
|
+
declare const DefaultTelegramConnectButton: (props: DefaultTelegramConnectButtonProps) => react_jsx_runtime.JSX.Element;
|
|
6
|
+
|
|
7
|
+
export { DefaultTelegramConnectButton, type DefaultTelegramConnectButtonProps };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/components/telegram-connect-button/DefaultTelegramConnectButton.tsx
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { useNovuUI } from "../../context/NovuUIContext.js";
|
|
4
|
+
import { Mounter } from "../Mounter.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
var DefaultTelegramConnectButton = (props) => {
|
|
7
|
+
const {
|
|
8
|
+
integrationIdentifier,
|
|
9
|
+
subscriberId,
|
|
10
|
+
onConnectSuccess,
|
|
11
|
+
onConnectError,
|
|
12
|
+
onDisconnectSuccess,
|
|
13
|
+
onDisconnectError,
|
|
14
|
+
connectLabel,
|
|
15
|
+
connectedLabel
|
|
16
|
+
} = props;
|
|
17
|
+
const { novuUI } = useNovuUI();
|
|
18
|
+
const mount = useCallback(
|
|
19
|
+
(element) => {
|
|
20
|
+
return novuUI.mountComponent({
|
|
21
|
+
name: "TelegramConnectButton",
|
|
22
|
+
props: {
|
|
23
|
+
integrationIdentifier,
|
|
24
|
+
subscriberId,
|
|
25
|
+
onConnectSuccess,
|
|
26
|
+
onConnectError,
|
|
27
|
+
onDisconnectSuccess,
|
|
28
|
+
onDisconnectError,
|
|
29
|
+
connectLabel,
|
|
30
|
+
connectedLabel
|
|
31
|
+
},
|
|
32
|
+
element
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
[
|
|
36
|
+
novuUI,
|
|
37
|
+
integrationIdentifier,
|
|
38
|
+
subscriberId,
|
|
39
|
+
onConnectSuccess,
|
|
40
|
+
onConnectError,
|
|
41
|
+
onDisconnectSuccess,
|
|
42
|
+
onDisconnectError,
|
|
43
|
+
connectLabel,
|
|
44
|
+
connectedLabel
|
|
45
|
+
]
|
|
46
|
+
);
|
|
47
|
+
return /* @__PURE__ */ jsx(Mounter, { mount });
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
DefaultTelegramConnectButton
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=DefaultTelegramConnectButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/telegram-connect-button/DefaultTelegramConnectButton.tsx"],"sourcesContent":["import { TelegramConnectButtonProps } from '@novu/js/ui';\nimport { useCallback } from 'react';\nimport { useNovuUI } from '../../context/NovuUIContext';\nimport { Mounter } from '../Mounter';\n\nexport type DefaultTelegramConnectButtonProps = Pick<\n TelegramConnectButtonProps,\n | 'integrationIdentifier'\n | 'subscriberId'\n | 'onConnectSuccess'\n | 'onConnectError'\n | 'onDisconnectSuccess'\n | 'onDisconnectError'\n | 'connectLabel'\n | 'connectedLabel'\n>;\n\nexport const DefaultTelegramConnectButton = (props: DefaultTelegramConnectButtonProps) => {\n const {\n integrationIdentifier,\n subscriberId,\n onConnectSuccess,\n onConnectError,\n onDisconnectSuccess,\n onDisconnectError,\n connectLabel,\n connectedLabel,\n } = props;\n const { novuUI } = useNovuUI();\n\n const mount = useCallback(\n (element: HTMLElement) => {\n return novuUI.mountComponent({\n name: 'TelegramConnectButton',\n props: {\n integrationIdentifier,\n subscriberId,\n onConnectSuccess,\n onConnectError,\n onDisconnectSuccess,\n onDisconnectError,\n connectLabel,\n connectedLabel,\n },\n element,\n });\n },\n [\n novuUI,\n integrationIdentifier,\n subscriberId,\n onConnectSuccess,\n onConnectError,\n onDisconnectSuccess,\n onDisconnectError,\n connectLabel,\n connectedLabel,\n ]\n );\n\n return <Mounter mount={mount} />;\n};\n"],"mappings":";AACA,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AAyDf;AA3CF,IAAM,+BAA+B,CAAC,UAA6C;AACxF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,EAAE,OAAO,IAAI,UAAU;AAE7B,QAAM,QAAQ;AAAA,IACZ,CAAC,YAAyB;AACxB,aAAO,OAAO,eAAe;AAAA,QAC3B,MAAM;AAAA,QACN,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,oBAAC,WAAQ,OAAc;AAChC;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { NovuUIOptions } from '../NovuUI.js';
|
|
4
|
+
import { DefaultTelegramConnectButtonProps } from './DefaultTelegramConnectButton.js';
|
|
5
|
+
import '@novu/js';
|
|
6
|
+
import '@novu/js/ui';
|
|
7
|
+
import '../../utils/types.js';
|
|
8
|
+
|
|
9
|
+
type TelegramConnectButtonProps = DefaultTelegramConnectButtonProps & Pick<NovuUIOptions, 'container' | 'appearance'>;
|
|
10
|
+
declare const TelegramConnectButton: React__default.MemoExoticComponent<(props: TelegramConnectButtonProps) => react_jsx_runtime.JSX.Element>;
|
|
11
|
+
|
|
12
|
+
export { TelegramConnectButton, type TelegramConnectButtonProps };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/components/telegram-connect-button/TelegramConnectButton.tsx
|
|
2
|
+
import React, { useMemo } from "react";
|
|
3
|
+
import { useNovu } from "../../hooks/NovuProvider.js";
|
|
4
|
+
import { NovuUI } from "../NovuUI.js";
|
|
5
|
+
import { withRenderer } from "../Renderer.js";
|
|
6
|
+
import { DefaultTelegramConnectButton } from "./DefaultTelegramConnectButton.js";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var TelegramConnectButtonInternal = withRenderer((props) => {
|
|
9
|
+
const { container, appearance, ...defaultProps } = props;
|
|
10
|
+
const novu = useNovu();
|
|
11
|
+
const options = useMemo(() => {
|
|
12
|
+
return {
|
|
13
|
+
container,
|
|
14
|
+
appearance,
|
|
15
|
+
options: novu.options
|
|
16
|
+
};
|
|
17
|
+
}, [container, appearance, novu.options]);
|
|
18
|
+
return /* @__PURE__ */ jsx(NovuUI, { options, novu, children: /* @__PURE__ */ jsx(DefaultTelegramConnectButton, { ...defaultProps }) });
|
|
19
|
+
});
|
|
20
|
+
TelegramConnectButtonInternal.displayName = "TelegramConnectButtonInternal";
|
|
21
|
+
var TelegramConnectButton = React.memo((props) => {
|
|
22
|
+
return /* @__PURE__ */ jsx(TelegramConnectButtonInternal, { ...props });
|
|
23
|
+
});
|
|
24
|
+
TelegramConnectButton.displayName = "TelegramConnectButton";
|
|
25
|
+
export {
|
|
26
|
+
TelegramConnectButton
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=TelegramConnectButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/telegram-connect-button/TelegramConnectButton.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { useNovu } from '../../hooks/NovuProvider';\nimport { NovuUI, NovuUIOptions } from '../NovuUI';\nimport { withRenderer } from '../Renderer';\nimport { DefaultTelegramConnectButton, DefaultTelegramConnectButtonProps } from './DefaultTelegramConnectButton';\n\nexport type TelegramConnectButtonProps = DefaultTelegramConnectButtonProps &\n Pick<NovuUIOptions, 'container' | 'appearance'>;\n\nconst TelegramConnectButtonInternal = withRenderer<TelegramConnectButtonProps>((props) => {\n const { container, appearance, ...defaultProps } = props;\n const novu = useNovu();\n\n const options: NovuUIOptions = useMemo(() => {\n return {\n container,\n appearance,\n options: novu.options,\n };\n }, [container, appearance, novu.options]);\n\n return (\n <NovuUI options={options} novu={novu}>\n <DefaultTelegramConnectButton {...defaultProps} />\n </NovuUI>\n );\n});\n\nTelegramConnectButtonInternal.displayName = 'TelegramConnectButtonInternal';\n\nexport const TelegramConnectButton = React.memo((props: TelegramConnectButtonProps) => {\n return <TelegramConnectButtonInternal {...props} />;\n});\n\nTelegramConnectButton.displayName = 'TelegramConnectButton';\n"],"mappings":";AAAA,OAAO,SAAS,eAAe;AAC/B,SAAS,eAAe;AACxB,SAAS,cAA6B;AACtC,SAAS,oBAAoB;AAC7B,SAAS,oCAAuE;AAmB1E;AAdN,IAAM,gCAAgC,aAAyC,CAAC,UAAU;AACxF,QAAM,EAAE,WAAW,YAAY,GAAG,aAAa,IAAI;AACnD,QAAM,OAAO,QAAQ;AAErB,QAAM,UAAyB,QAAQ,MAAM;AAC3C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,SAAS,KAAK;AAAA,IAChB;AAAA,EACF,GAAG,CAAC,WAAW,YAAY,KAAK,OAAO,CAAC;AAExC,SACE,oBAAC,UAAO,SAAkB,MACxB,8BAAC,gCAA8B,GAAG,cAAc,GAClD;AAEJ,CAAC;AAED,8BAA8B,cAAc;AAErC,IAAM,wBAAwB,MAAM,KAAK,CAAC,UAAsC;AACrF,SAAO,oBAAC,iCAA+B,GAAG,OAAO;AACnD,CAAC;AAED,sBAAsB,cAAc;","names":[]}
|
|
@@ -14,6 +14,7 @@ export { UseRemoveSubscriptionProps, UseRemoveSubscriptionResult, useRemoveSubsc
|
|
|
14
14
|
export { UseScheduleProps, UseScheduleResult, useSchedule } from './useSchedule.js';
|
|
15
15
|
export { UseSubscriptionProps, UseSubscriptionResult, useSubscription } from './useSubscription.js';
|
|
16
16
|
export { UseSubscriptionsProps, UseSubscriptionsResult, useSubscriptions } from './useSubscriptions.js';
|
|
17
|
+
export { UseTelegramSubscriberLinkProps, UseTelegramSubscriberLinkResult, useTelegramSubscriberLink } from './useTelegramSubscriberLink.js';
|
|
17
18
|
export { UseUpdateSubscriptionProps, UseUpdateSubscriptionResult, useUpdateSubscription } from './useUpdateSubscription.js';
|
|
18
19
|
import 'react/jsx-runtime';
|
|
19
20
|
import 'react';
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./useRemoveSubscription.js";
|
|
|
14
14
|
export * from "./useSchedule.js";
|
|
15
15
|
export * from "./useSubscription.js";
|
|
16
16
|
export * from "./useSubscriptions.js";
|
|
17
|
+
export * from "./useTelegramSubscriberLink.js";
|
|
17
18
|
export * from "./useUpdateSubscription.js";
|
|
18
19
|
export {
|
|
19
20
|
NovuProvider,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export type * from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\nexport { NovuProvider, useNovu } from './NovuProvider';\nexport * from './useChannelConnection';\nexport * from './useChannelConnections';\nexport * from './useChannelEndpoint';\nexport * from './useCounts';\nexport * from './useCreateChannelEndpoint';\nexport * from './useCreateSubscription';\nexport * from './useDeleteChannelEndpoint';\nexport * from './useNotifications';\nexport * from './usePreferences';\nexport * from './useRemoveSubscription';\nexport * from './useSchedule';\nexport * from './useSubscription';\nexport * from './useSubscriptions';\nexport * from './useUpdateSubscription';\n"],"mappings":";AACA,SAAS,iBAAiB,mBAAmB,+BAA+B;AAC5E,SAAS,cAAc,eAAe;AACtC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export type * from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\nexport { NovuProvider, useNovu } from './NovuProvider';\nexport * from './useChannelConnection';\nexport * from './useChannelConnections';\nexport * from './useChannelEndpoint';\nexport * from './useCounts';\nexport * from './useCreateChannelEndpoint';\nexport * from './useCreateSubscription';\nexport * from './useDeleteChannelEndpoint';\nexport * from './useNotifications';\nexport * from './usePreferences';\nexport * from './useRemoveSubscription';\nexport * from './useSchedule';\nexport * from './useSubscription';\nexport * from './useSubscriptions';\nexport * from './useTelegramSubscriberLink';\nexport * from './useUpdateSubscription';\n"],"mappings":";AACA,SAAS,iBAAiB,mBAAmB,+BAA+B;AAC5E,SAAS,cAAc,eAAe;AACtC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -1,62 +1,69 @@
|
|
|
1
1
|
// src/hooks/useCounts.ts
|
|
2
|
-
import {
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
2
|
+
import { NOTIFICATION_COUNT_SYNC_EVENTS, checkNotificationMatchesFilter, isSameFilter } from "@novu/js";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { useDataRef } from "./internal/useDataRef.js";
|
|
5
5
|
import { useWebSocketEvent } from "./internal/useWebsocketEvent.js";
|
|
6
6
|
import { useNovu, useRealtime } from "./NovuProvider.js";
|
|
7
7
|
var useCounts = (props) => {
|
|
8
8
|
const { filters, realtime: propsRealtime, onSuccess, onError } = props;
|
|
9
|
-
const
|
|
9
|
+
const novu = useNovu();
|
|
10
|
+
const { notifications } = novu;
|
|
10
11
|
const providerRealtime = useRealtime();
|
|
11
12
|
const realtime = propsRealtime ?? providerRealtime;
|
|
12
13
|
const filtersRef = useDataRef(filters);
|
|
14
|
+
const onSuccessRef = useDataRef(onSuccess);
|
|
15
|
+
const onErrorRef = useDataRef(onError);
|
|
16
|
+
const syncGenerationRef = useRef(0);
|
|
13
17
|
const [error, setError] = useState();
|
|
14
18
|
const [counts, setCounts] = useState();
|
|
15
19
|
const [isLoading, setIsLoading] = useState(true);
|
|
16
20
|
const [isFetching, setIsFetching] = useState(false);
|
|
17
|
-
const sync =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const sync = useCallback(
|
|
22
|
+
async (notification, overrideFilters) => {
|
|
23
|
+
const currentFilters = overrideFilters || filtersRef.current;
|
|
24
|
+
const existingCounts = currentFilters.map((filter) => ({ count: 0, filter }));
|
|
25
|
+
let countFiltersToFetch = [];
|
|
26
|
+
if (notification) {
|
|
27
|
+
countFiltersToFetch = currentFilters.filter(
|
|
28
|
+
(filter) => checkNotificationMatchesFilter(notification, filter)
|
|
29
|
+
);
|
|
30
|
+
} else {
|
|
31
|
+
countFiltersToFetch = currentFilters;
|
|
28
32
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
if (countFiltersToFetch.length === 0) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
setIsFetching(true);
|
|
36
|
-
const countsRes = await notifications.count({ filters: countFiltersToFetch });
|
|
37
|
-
setIsFetching(false);
|
|
38
|
-
setIsLoading(false);
|
|
39
|
-
if (countsRes.error) {
|
|
40
|
-
setError(countsRes.error);
|
|
41
|
-
onError?.(countsRes.error);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const data = countsRes.data;
|
|
45
|
-
onSuccess?.(data.counts);
|
|
46
|
-
setCounts((oldCounts) => {
|
|
47
|
-
const newCounts = [];
|
|
48
|
-
const countsReceived = data.counts;
|
|
49
|
-
for (let i = 0; i < existingCounts.length; i++) {
|
|
50
|
-
const existingFilter = existingCounts[i].filter;
|
|
51
|
-
const countReceived = countsReceived.find((c) => isSameFilter(c.filter, existingFilter));
|
|
52
|
-
const count = countReceived || oldCounts?.[i];
|
|
53
|
-
if (count) {
|
|
54
|
-
newCounts.push(count);
|
|
55
|
-
}
|
|
33
|
+
if (countFiltersToFetch.length === 0) {
|
|
34
|
+
return;
|
|
56
35
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
36
|
+
const generation = ++syncGenerationRef.current;
|
|
37
|
+
setIsFetching(true);
|
|
38
|
+
const countsRes = await notifications.count({ filters: countFiltersToFetch });
|
|
39
|
+
if (generation !== syncGenerationRef.current) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setIsFetching(false);
|
|
43
|
+
setIsLoading(false);
|
|
44
|
+
if (countsRes.error) {
|
|
45
|
+
setError(countsRes.error);
|
|
46
|
+
onErrorRef.current?.(countsRes.error);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const data = countsRes.data;
|
|
50
|
+
onSuccessRef.current?.(data.counts);
|
|
51
|
+
setCounts((oldCounts) => {
|
|
52
|
+
const newCounts = [];
|
|
53
|
+
const countsReceived = data.counts;
|
|
54
|
+
for (let i = 0; i < existingCounts.length; i++) {
|
|
55
|
+
const existingFilter = existingCounts[i].filter;
|
|
56
|
+
const countReceived = countsReceived.find((c) => isSameFilter(c.filter, existingFilter));
|
|
57
|
+
const count = countReceived || oldCounts?.[i];
|
|
58
|
+
if (count) {
|
|
59
|
+
newCounts.push(count);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return newCounts;
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
[notifications, filtersRef, onErrorRef, onSuccessRef]
|
|
66
|
+
);
|
|
60
67
|
useWebSocketEvent({
|
|
61
68
|
event: "notifications.notification_received",
|
|
62
69
|
enabled: realtime,
|
|
@@ -71,15 +78,26 @@ var useCounts = (props) => {
|
|
|
71
78
|
sync();
|
|
72
79
|
}
|
|
73
80
|
});
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
const cleanups = NOTIFICATION_COUNT_SYNC_EVENTS.map(
|
|
83
|
+
(event) => novu.on(event, (payload) => {
|
|
84
|
+
if ("error" in payload && payload.error) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
sync();
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
return () => cleanups.forEach((cleanup) => cleanup());
|
|
91
|
+
}, [novu, sync]);
|
|
74
92
|
useEffect(() => {
|
|
75
93
|
setError(void 0);
|
|
76
94
|
setIsLoading(true);
|
|
77
95
|
setIsFetching(false);
|
|
78
96
|
sync(void 0, filters);
|
|
79
|
-
}, [JSON.stringify(filters)]);
|
|
80
|
-
const refetch = async () => {
|
|
97
|
+
}, [JSON.stringify(filters), sync]);
|
|
98
|
+
const refetch = useCallback(async () => {
|
|
81
99
|
await sync();
|
|
82
|
-
};
|
|
100
|
+
}, [sync]);
|
|
83
101
|
return { counts, error, refetch, isLoading, isFetching };
|
|
84
102
|
};
|
|
85
103
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useCounts.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useCounts.ts"],"sourcesContent":["import { NOTIFICATION_COUNT_SYNC_EVENTS, checkNotificationMatchesFilter, isSameFilter, Notification, NotificationFilter, NovuError } from '@novu/js';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { useDataRef } from './internal/useDataRef';\nimport { useWebSocketEvent } from './internal/useWebsocketEvent';\nimport { useNovu, useRealtime } from './NovuProvider';\n\ntype Count = {\n count: number;\n filter: NotificationFilter;\n};\n\n/**\n * Props for the useCounts hook.\n *\n * @example\n * ```tsx\n * // Count unread notifications\n * const { counts } = useCounts({\n * filters: [{ read: false }]\n * });\n *\n * // Count unseen notifications with specific tags\n * const { counts } = useCounts({\n * filters: [{ seen: false, tags: ['important'] }]\n * });\n *\n * // Count seen but unread notifications\n * const { counts } = useCounts({\n * filters: [{ seen: true, read: false }]\n * });\n *\n * // Opt out of the built-in realtime count updates and drive them yourself\n * const { counts, refetch } = useCounts({\n * filters: [{ read: false }],\n * realtime: false,\n * });\n * ```\n */\nexport type UseCountsProps = {\n filters: NotificationFilter[];\n /**\n * When `false`, disables the WebSocket subscriptions that auto-resync\n * counts on `notifications.notification_received` and\n * `notifications.unread_count_changed`. The filter-driven fetch and\n * `refetch()` keep working. Use alongside\n * `useNotifications({ realtime: false })` when you drive live updates\n * yourself.\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: Count[]) => void;\n onError?: (error: NovuError) => void;\n};\n\nexport type UseCountsResult = {\n counts?: Count[];\n error?: NovuError;\n isLoading: boolean; // initial loading\n isFetching: boolean; // the request is in flight\n refetch: () => Promise<void>;\n};\n\nexport const useCounts = (props: UseCountsProps): UseCountsResult => {\n const { filters, realtime: propsRealtime, onSuccess, onError } = props;\n const novu = useNovu();\n const { notifications } = novu;\n const providerRealtime = useRealtime();\n const realtime = propsRealtime ?? providerRealtime;\n const filtersRef = useDataRef<NotificationFilter[]>(filters);\n const onSuccessRef = useDataRef(onSuccess);\n const onErrorRef = useDataRef(onError);\n const syncGenerationRef = useRef(0);\n const [error, setError] = useState<NovuError>();\n const [counts, setCounts] = useState<Count[]>();\n const [isLoading, setIsLoading] = useState(true);\n const [isFetching, setIsFetching] = useState(false);\n\n const sync = useCallback(\n async (notification?: Notification, overrideFilters?: NotificationFilter[]) => {\n const currentFilters = overrideFilters || filtersRef.current;\n const existingCounts = currentFilters.map((filter) => ({ count: 0, filter }));\n let countFiltersToFetch: NotificationFilter[] = [];\n\n if (notification) {\n countFiltersToFetch = currentFilters.filter((filter) =>\n checkNotificationMatchesFilter(notification, filter)\n );\n } else {\n countFiltersToFetch = currentFilters;\n }\n\n if (countFiltersToFetch.length === 0) {\n return;\n }\n\n const generation = ++syncGenerationRef.current;\n setIsFetching(true);\n\n const countsRes = await notifications.count({ filters: countFiltersToFetch });\n\n if (generation !== syncGenerationRef.current) {\n return;\n }\n\n setIsFetching(false);\n setIsLoading(false);\n\n if (countsRes.error) {\n setError(countsRes.error);\n onErrorRef.current?.(countsRes.error);\n\n return;\n }\n\n const data = countsRes.data!;\n onSuccessRef.current?.(data.counts);\n\n setCounts((oldCounts) => {\n const newCounts: Count[] = [];\n const countsReceived = data.counts;\n\n for (let i = 0; i < existingCounts.length; i++) {\n const existingFilter = existingCounts[i].filter;\n const countReceived = countsReceived.find((c) => isSameFilter(c.filter, existingFilter));\n const count = countReceived || oldCounts?.[i];\n if (count) {\n newCounts.push(count);\n }\n }\n\n return newCounts;\n });\n },\n [notifications, filtersRef, onErrorRef, onSuccessRef]\n );\n\n useWebSocketEvent({\n event: 'notifications.notification_received',\n enabled: realtime,\n eventHandler: (data) => {\n sync(data.result);\n },\n });\n\n useWebSocketEvent({\n event: 'notifications.unread_count_changed',\n enabled: realtime,\n eventHandler: () => {\n sync();\n },\n });\n\n useEffect(() => {\n const cleanups = NOTIFICATION_COUNT_SYNC_EVENTS.map((event) =>\n novu.on(event, (payload) => {\n if ('error' in payload && payload.error) {\n return;\n }\n\n sync();\n })\n );\n\n return () => cleanups.forEach((cleanup) => cleanup());\n }, [novu, sync]);\n\n useEffect(() => {\n setError(undefined);\n setIsLoading(true);\n setIsFetching(false);\n sync(undefined, filters);\n }, [JSON.stringify(filters), sync]);\n\n const refetch = useCallback(async () => {\n await sync();\n }, [sync]);\n\n return { counts, error, refetch, isLoading, isFetching };\n};\n"],"mappings":"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","names":[]}
|