@novu/react 3.11.0 → 3.11.2-nightly.20251224.eb609546a3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -18
- package/dist/cjs/components/Inbox.cjs +5 -1
- package/dist/cjs/components/Inbox.cjs.map +1 -1
- package/dist/cjs/components/NovuUI.cjs +3 -1
- package/dist/cjs/components/NovuUI.cjs.map +1 -1
- package/dist/cjs/components/NovuUI.d.cts +9 -9
- package/dist/cjs/components/index.cjs +7 -1
- package/dist/cjs/components/index.cjs.map +1 -1
- package/dist/cjs/components/index.d.cts +5 -0
- package/dist/cjs/components/subscription/DefaultSubscription.cjs +59 -0
- package/dist/cjs/components/subscription/DefaultSubscription.cjs.map +1 -0
- package/dist/cjs/components/subscription/DefaultSubscription.d.cts +11 -0
- package/dist/cjs/components/subscription/Subscription.cjs +80 -0
- package/dist/cjs/components/subscription/Subscription.cjs.map +1 -0
- package/dist/cjs/components/subscription/Subscription.d.cts +22 -0
- package/dist/cjs/components/subscription/SubscriptionButton.cjs +91 -0
- package/dist/cjs/components/subscription/SubscriptionButton.cjs.map +1 -0
- package/dist/cjs/components/subscription/SubscriptionButton.d.cts +8 -0
- package/dist/cjs/components/subscription/SubscriptionPreferences.cjs +91 -0
- package/dist/cjs/components/subscription/SubscriptionPreferences.cjs.map +1 -0
- package/dist/cjs/components/subscription/SubscriptionPreferences.d.cts +8 -0
- package/dist/cjs/hooks/NovuProvider.cjs +21 -18
- package/dist/cjs/hooks/NovuProvider.cjs.map +1 -1
- package/dist/cjs/hooks/index.cjs +11 -1
- package/dist/cjs/hooks/index.cjs.map +1 -1
- package/dist/cjs/hooks/index.d.cts +7 -1
- package/dist/cjs/hooks/useCounts.cjs +2 -2
- package/dist/cjs/hooks/useCounts.cjs.map +1 -1
- package/dist/cjs/hooks/useCreateSubscription.cjs +61 -0
- package/dist/cjs/hooks/useCreateSubscription.cjs.map +1 -0
- package/dist/cjs/hooks/useCreateSubscription.d.cts +17 -0
- package/dist/cjs/hooks/useNotifications.cjs +57 -60
- package/dist/cjs/hooks/useNotifications.cjs.map +1 -1
- package/dist/cjs/hooks/useRemoveSubscription.cjs +61 -0
- package/dist/cjs/hooks/useRemoveSubscription.cjs.map +1 -0
- package/dist/cjs/hooks/useRemoveSubscription.d.cts +17 -0
- package/dist/cjs/hooks/useSubscription.cjs +156 -0
- package/dist/cjs/hooks/useSubscription.cjs.map +1 -0
- package/dist/cjs/hooks/useSubscription.d.cts +21 -0
- package/dist/cjs/hooks/useSubscriptions.cjs +121 -0
- package/dist/cjs/hooks/useSubscriptions.cjs.map +1 -0
- package/dist/cjs/hooks/useSubscriptions.d.cts +36 -0
- package/dist/cjs/hooks/useUpdateSubscription.cjs +61 -0
- package/dist/cjs/hooks/useUpdateSubscription.cjs.map +1 -0
- package/dist/cjs/hooks/useUpdateSubscription.d.cts +18 -0
- package/dist/cjs/index.cjs +18 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +14 -3
- package/dist/cjs/server/index.cjs +61 -2
- package/dist/cjs/server/index.cjs.map +1 -1
- package/dist/cjs/server/index.d.cts +18 -4
- package/dist/cjs/utils/appearance.cjs.map +1 -1
- package/dist/cjs/utils/appearance.d.cts +3 -3
- package/dist/cjs/utils/types.cjs.map +1 -1
- package/dist/cjs/utils/types.d.cts +32 -11
- package/dist/esm/components/Inbox.js +5 -1
- package/dist/esm/components/Inbox.js.map +1 -1
- package/dist/esm/components/NovuUI.d.ts +9 -9
- package/dist/esm/components/NovuUI.js +3 -1
- package/dist/esm/components/NovuUI.js.map +1 -1
- package/dist/esm/components/index.d.ts +5 -0
- package/dist/esm/components/index.js +3 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/components/subscription/DefaultSubscription.d.ts +11 -0
- package/dist/esm/components/subscription/DefaultSubscription.js +34 -0
- package/dist/esm/components/subscription/DefaultSubscription.js.map +1 -0
- package/dist/esm/components/subscription/Subscription.d.ts +22 -0
- package/dist/esm/components/subscription/Subscription.js +45 -0
- package/dist/esm/components/subscription/Subscription.js.map +1 -0
- package/dist/esm/components/subscription/SubscriptionButton.d.ts +8 -0
- package/dist/esm/components/subscription/SubscriptionButton.js +56 -0
- package/dist/esm/components/subscription/SubscriptionButton.js.map +1 -0
- package/dist/esm/components/subscription/SubscriptionPreferences.d.ts +8 -0
- package/dist/esm/components/subscription/SubscriptionPreferences.js +56 -0
- package/dist/esm/components/subscription/SubscriptionPreferences.js.map +1 -0
- package/dist/esm/hooks/NovuProvider.js +22 -19
- package/dist/esm/hooks/NovuProvider.js.map +1 -1
- package/dist/esm/hooks/index.d.ts +7 -1
- package/dist/esm/hooks/index.js +5 -0
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/useCounts.js +3 -3
- package/dist/esm/hooks/useCounts.js.map +1 -1
- package/dist/esm/hooks/useCreateSubscription.d.ts +17 -0
- package/dist/esm/hooks/useCreateSubscription.js +36 -0
- package/dist/esm/hooks/useCreateSubscription.js.map +1 -0
- package/dist/esm/hooks/useNotifications.js +58 -61
- package/dist/esm/hooks/useNotifications.js.map +1 -1
- package/dist/esm/hooks/useRemoveSubscription.d.ts +17 -0
- package/dist/esm/hooks/useRemoveSubscription.js +36 -0
- package/dist/esm/hooks/useRemoveSubscription.js.map +1 -0
- package/dist/esm/hooks/useSubscription.d.ts +21 -0
- package/dist/esm/hooks/useSubscription.js +129 -0
- package/dist/esm/hooks/useSubscription.js.map +1 -0
- package/dist/esm/hooks/useSubscriptions.d.ts +36 -0
- package/dist/esm/hooks/useSubscriptions.js +96 -0
- package/dist/esm/hooks/useSubscriptions.js.map +1 -0
- package/dist/esm/hooks/useUpdateSubscription.d.ts +18 -0
- package/dist/esm/hooks/useUpdateSubscription.js +36 -0
- package/dist/esm/hooks/useUpdateSubscription.js.map +1 -0
- package/dist/esm/index.d.ts +14 -3
- package/dist/esm/index.js +32 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/server/index.d.ts +18 -4
- package/dist/esm/server/index.js +53 -2
- package/dist/esm/server/index.js.map +1 -1
- package/dist/esm/utils/appearance.d.ts +3 -3
- package/dist/esm/utils/appearance.js.map +1 -1
- package/dist/esm/utils/types.d.ts +32 -11
- package/package.json +11 -11
|
@@ -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 UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesProps,\n UsePreferencesResult,\n UseScheduleProps,\n UseScheduleResult,\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\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
|
|
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;AAuInC,gBAA4E;AA1GnE;AADF,SAAS,MAAM,OAAmB;AACvC,SAAO,4CAAC,gDAAmB;AAC7B;AAEO,SAAS,eAAe;AAAC;AAEzB,SAAS,gBAAgB;AAAC;AAE1B,SAAS,cAAc;AAAC;AAExB,SAAS,OAAO;AAAC;AAEjB,SAAS,aAAa,OAA0B;AACrD,SAAO,2EAAG,gBAAM,UAAS;AAC3B;AAEO,SAAS,eAAe;AAC7B,SAAO,4CAAC,gDAAmB;AAC7B;AAEO,SAAS,qBAAqB;AAAC;AAE/B,SAAS,0BAA0B;AAAC;AAEpC,SAAS,UAAU;AACxB,SAAO;AACT;AAEO,SAAS,UAAU,GAAoC;AAC5D,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,QAAQ;AAAA,EACjC;AACF;AAEO,SAAS,iBAAiB,GAAkD;AACjF,S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gC;AACrG,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,QAAQ,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,EACrE;AACF;AAEO,SAAS,iBAAiB,GAAkD;AACjF,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,QAAQ;AAAA,EACjC;AACF;","names":[]}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { InboxProps } from '../components/Inbox.cjs';
|
|
3
|
-
export
|
|
3
|
+
export * from '@novu/js';
|
|
4
|
+
export { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';
|
|
4
5
|
import { NovuProviderProps } from '../hooks/NovuProvider.cjs';
|
|
5
6
|
import { UseCountsProps, UseCountsResult } from '../hooks/useCounts.cjs';
|
|
7
|
+
import { UseCreateSubscriptionProps, UseCreateSubscriptionResult } from '../hooks/useCreateSubscription.cjs';
|
|
6
8
|
import { UseNotificationsProps, UseNotificationsResult } from '../hooks/useNotifications.cjs';
|
|
7
9
|
import { UsePreferencesProps, UsePreferencesResult } from '../hooks/usePreferences.cjs';
|
|
10
|
+
import { UseRemoveSubscriptionProps, UseRemoveSubscriptionResult } from '../hooks/useRemoveSubscription.cjs';
|
|
8
11
|
import { UseScheduleProps, UseScheduleResult } from '../hooks/useSchedule.cjs';
|
|
9
|
-
|
|
12
|
+
import { UseSubscriptionProps, UseSubscriptionResult } from '../hooks/useSubscription.cjs';
|
|
13
|
+
import { UseSubscriptionsProps, UseSubscriptionsResult } from '../hooks/useSubscriptions.cjs';
|
|
14
|
+
import { UseUpdateSubscriptionProps, UseUpdateSubscriptionResult } from '../hooks/useUpdateSubscription.cjs';
|
|
15
|
+
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';
|
|
10
16
|
export { BellProps } from '../components/Bell.cjs';
|
|
11
17
|
export { InboxContentProps } from '../components/InboxContent.cjs';
|
|
12
18
|
export { NotificationProps } from '../components/Notifications.cjs';
|
|
@@ -24,11 +30,19 @@ declare function InboxContent(): void;
|
|
|
24
30
|
declare function Notifications(): void;
|
|
25
31
|
declare function Preferences(): void;
|
|
26
32
|
declare function Bell(): void;
|
|
27
|
-
declare function NovuProvider(props: NovuProviderProps):
|
|
33
|
+
declare function NovuProvider(props: NovuProviderProps): react_jsx_runtime.JSX.Element;
|
|
34
|
+
declare function Subscription(): react_jsx_runtime.JSX.Element;
|
|
35
|
+
declare function SubscriptionButton(): void;
|
|
36
|
+
declare function SubscriptionPreferences(): void;
|
|
28
37
|
declare function useNovu(): null;
|
|
29
38
|
declare function useCounts(_: UseCountsProps): UseCountsResult;
|
|
30
39
|
declare function useNotifications(_: UseNotificationsProps): UseNotificationsResult;
|
|
31
40
|
declare function usePreferences(_: UsePreferencesProps): UsePreferencesResult;
|
|
32
41
|
declare function useSchedule(_: UseScheduleProps): UseScheduleResult;
|
|
42
|
+
declare function useSubscription(_: UseSubscriptionProps): UseSubscriptionResult;
|
|
43
|
+
declare function useCreateSubscription(_?: UseCreateSubscriptionProps): UseCreateSubscriptionResult;
|
|
44
|
+
declare function useUpdateSubscription(_?: UseUpdateSubscriptionProps): UseUpdateSubscriptionResult;
|
|
45
|
+
declare function useRemoveSubscription(_?: UseRemoveSubscriptionProps): UseRemoveSubscriptionResult;
|
|
46
|
+
declare function useSubscriptions(_: UseSubscriptionsProps): UseSubscriptionsResult;
|
|
33
47
|
|
|
34
|
-
export { Bell, Inbox, InboxContent, InboxProps, Notifications, NovuProvider, NovuProviderProps, Preferences, UseCountsProps, UseCountsResult, UseNotificationsProps, UseNotificationsResult, UseScheduleProps as UsePreferencesProps, UsePreferencesResult, useCounts, useNotifications, useNovu, usePreferences, useSchedule };
|
|
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 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/appearance.ts"],"sourcesContent":["import type {
|
|
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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AllAppearance } from '@novu/js/ui';
|
|
2
2
|
import { MountedElement } from '../context/RendererContext.cjs';
|
|
3
|
-
import {
|
|
3
|
+
import { ReactInboxAppearance, ReactSubscriptionAppearance } from './types.cjs';
|
|
4
4
|
import 'react/jsx-runtime';
|
|
5
5
|
import 'react';
|
|
6
6
|
import '@novu/js';
|
|
7
7
|
|
|
8
|
-
declare function adaptAppearanceForJs(appearance:
|
|
8
|
+
declare function adaptAppearanceForJs(appearance: ReactInboxAppearance | ReactSubscriptionAppearance, mountElement: (el: HTMLElement, mountedElement: MountedElement) => () => void): AllAppearance | undefined;
|
|
9
9
|
|
|
10
10
|
export { adaptAppearanceForJs };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/types.ts"],"sourcesContent":["import type { Context, DefaultSchedule, Subscriber, UnreadCount } from '@novu/js';\nimport type {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/types.ts"],"sourcesContent":["import type { Context, DefaultSchedule, Subscriber, UnreadCount } from '@novu/js';\nimport type {\n AllIconKey,\n AllTheme,\n InboxIconKey,\n InboxLocalization,\n InboxProps,\n InboxTheme,\n Notification,\n NotificationActionClickHandler,\n NotificationClickHandler,\n PreferenceGroups,\n PreferencesFilter,\n PreferencesSort,\n RouterPush,\n SubscriptionIconKey,\n SubscriptionTheme,\n Tab,\n} from '@novu/js/ui';\nimport type { ReactNode } from 'react';\n\nexport type NotificationsRenderer = (notification: Notification) => React.ReactNode;\nexport type AvatarRenderer = (notification: Notification) => React.ReactNode;\nexport type SubjectRenderer = (notification: Notification) => React.ReactNode;\nexport type BodyRenderer = (notification: Notification) => React.ReactNode;\nexport type DefaultActionsRenderer = (notification: Notification) => React.ReactNode;\nexport type CustomActionsRenderer = (notification: Notification) => React.ReactNode;\nexport type BellRenderer = (unreadCount: UnreadCount) => React.ReactNode;\n\nexport type ReactIconRendererProps = { class?: string };\nexport type ReactIconRenderer = (props: ReactIconRendererProps) => ReactNode;\n\nexport type ReactInboxIconOverrides = {\n [key in InboxIconKey]?: ReactIconRenderer;\n};\n\nexport type ReactInboxTheme = Omit<InboxTheme, 'icons'> & {\n icons?: ReactInboxIconOverrides;\n};\n\nexport type ReactSubscriptionIconOverrides = {\n [key in SubscriptionIconKey]?: ReactIconRenderer;\n};\n\nexport type ReactSubscriptionTheme = Omit<SubscriptionTheme, 'icons'> & {\n icons?: ReactSubscriptionIconOverrides;\n};\n\nexport type ReactAllIconOverrides = {\n [key in AllIconKey]?: ReactIconRenderer;\n};\n\nexport type ReactAllTheme = Omit<AllTheme, 'icons'> & {\n icons?: ReactAllIconOverrides;\n};\n\nexport type ReactInboxAppearance = ReactInboxTheme & {\n baseTheme?: InboxTheme | InboxTheme[];\n};\n\nexport type ReactSubscriptionAppearance = ReactSubscriptionTheme & {\n baseTheme?: SubscriptionTheme | SubscriptionTheme[];\n};\n\nexport type ReactAllAppearance = ReactAllTheme & {\n baseTheme?: ReactAllTheme | ReactAllTheme[];\n};\n\nexport type DefaultInboxProps = {\n open?: boolean;\n renderNotification?: NotificationsRenderer;\n renderAvatar?: AvatarRenderer;\n renderSubject?: SubjectRenderer;\n renderBody?: BodyRenderer;\n renderDefaultActions?: DefaultActionsRenderer;\n renderCustomActions?: CustomActionsRenderer;\n renderBell?: BellRenderer;\n onNotificationClick?: NotificationClickHandler;\n onPrimaryActionClick?: NotificationActionClickHandler;\n onSecondaryActionClick?: NotificationActionClickHandler;\n placement?: InboxProps['placement'];\n placementOffset?: InboxProps['placementOffset'];\n};\n\ntype StandardBaseProps = {\n subscriberHash?: string;\n contextHash?: string;\n backendUrl?: string;\n socketUrl?: string;\n appearance?: ReactInboxAppearance;\n localization?: InboxLocalization;\n tabs?: Array<Tab>;\n preferencesFilter?: PreferencesFilter;\n preferenceGroups?: PreferenceGroups;\n preferencesSort?: PreferencesSort;\n defaultSchedule?: DefaultSchedule;\n routerPush?: RouterPush;\n context?: Context;\n} & (\n | {\n // TODO: Backward compatibility support - remove in future versions (see NV-5801)\n /** @deprecated Use subscriber prop instead */\n subscriberId: string;\n subscriber?: never;\n applicationIdentifier: string;\n }\n | {\n subscriber: Subscriber | string;\n subscriberId?: never;\n applicationIdentifier: string;\n }\n | {\n // Keyless mode - no subscriber or subscriberId or applicationIdentifier\n subscriber?: never;\n subscriberId?: never;\n applicationIdentifier?: never;\n }\n);\n\ntype InboxBaseProps = Omit<StandardBaseProps, 'appearance'> & {\n appearance?: ReactInboxAppearance;\n};\n\nexport type BaseProps = InboxBaseProps;\n\nexport type NotificationRendererProps = {\n renderNotification: NotificationsRenderer;\n renderAvatar?: never;\n renderSubject?: never;\n renderBody?: never;\n renderDefaultActions?: never;\n renderCustomActions?: never;\n};\n\nexport type SubjectBodyRendererProps = {\n renderNotification?: never;\n renderAvatar?: AvatarRenderer;\n renderSubject?: SubjectRenderer;\n renderBody?: BodyRenderer;\n renderDefaultActions?: DefaultActionsRenderer;\n renderCustomActions?: CustomActionsRenderer;\n};\n\nexport type NoRendererProps = {\n renderNotification?: undefined;\n renderAvatar?: undefined;\n renderSubject?: undefined;\n renderBody?: undefined;\n renderDefaultActions?: undefined;\n renderCustomActions?: undefined;\n};\n\nexport type DefaultProps = BaseProps &\n DefaultInboxProps & {\n children?: never;\n } & (NotificationRendererProps | SubjectBodyRendererProps | NoRendererProps);\n\nexport type WithChildrenProps = BaseProps & {\n children: React.ReactNode;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UnreadCount, DefaultSchedule, Context, Subscriber } from '@novu/js';
|
|
2
|
-
import { Notification,
|
|
2
|
+
import { Notification, InboxIconKey, InboxTheme, SubscriptionIconKey, SubscriptionTheme, AllIconKey, AllTheme, NotificationClickHandler, NotificationActionClickHandler, InboxProps, InboxLocalization, Tab, PreferencesFilter, PreferenceGroups, PreferencesSort, RouterPush } from '@novu/js/ui';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
|
|
5
5
|
type NotificationsRenderer = (notification: Notification) => React.ReactNode;
|
|
@@ -13,14 +13,32 @@ type ReactIconRendererProps = {
|
|
|
13
13
|
class?: string;
|
|
14
14
|
};
|
|
15
15
|
type ReactIconRenderer = (props: ReactIconRendererProps) => ReactNode;
|
|
16
|
-
type
|
|
17
|
-
[key in
|
|
16
|
+
type ReactInboxIconOverrides = {
|
|
17
|
+
[key in InboxIconKey]?: ReactIconRenderer;
|
|
18
18
|
};
|
|
19
|
-
type
|
|
20
|
-
icons?:
|
|
19
|
+
type ReactInboxTheme = Omit<InboxTheme, 'icons'> & {
|
|
20
|
+
icons?: ReactInboxIconOverrides;
|
|
21
21
|
};
|
|
22
|
-
type
|
|
23
|
-
|
|
22
|
+
type ReactSubscriptionIconOverrides = {
|
|
23
|
+
[key in SubscriptionIconKey]?: ReactIconRenderer;
|
|
24
|
+
};
|
|
25
|
+
type ReactSubscriptionTheme = Omit<SubscriptionTheme, 'icons'> & {
|
|
26
|
+
icons?: ReactSubscriptionIconOverrides;
|
|
27
|
+
};
|
|
28
|
+
type ReactAllIconOverrides = {
|
|
29
|
+
[key in AllIconKey]?: ReactIconRenderer;
|
|
30
|
+
};
|
|
31
|
+
type ReactAllTheme = Omit<AllTheme, 'icons'> & {
|
|
32
|
+
icons?: ReactAllIconOverrides;
|
|
33
|
+
};
|
|
34
|
+
type ReactInboxAppearance = ReactInboxTheme & {
|
|
35
|
+
baseTheme?: InboxTheme | InboxTheme[];
|
|
36
|
+
};
|
|
37
|
+
type ReactSubscriptionAppearance = ReactSubscriptionTheme & {
|
|
38
|
+
baseTheme?: SubscriptionTheme | SubscriptionTheme[];
|
|
39
|
+
};
|
|
40
|
+
type ReactAllAppearance = ReactAllTheme & {
|
|
41
|
+
baseTheme?: ReactAllTheme | ReactAllTheme[];
|
|
24
42
|
};
|
|
25
43
|
type DefaultInboxProps = {
|
|
26
44
|
open?: boolean;
|
|
@@ -42,8 +60,8 @@ type StandardBaseProps = {
|
|
|
42
60
|
contextHash?: string;
|
|
43
61
|
backendUrl?: string;
|
|
44
62
|
socketUrl?: string;
|
|
45
|
-
appearance?:
|
|
46
|
-
localization?:
|
|
63
|
+
appearance?: ReactInboxAppearance;
|
|
64
|
+
localization?: InboxLocalization;
|
|
47
65
|
tabs?: Array<Tab>;
|
|
48
66
|
preferencesFilter?: PreferencesFilter;
|
|
49
67
|
preferenceGroups?: PreferenceGroups;
|
|
@@ -65,7 +83,10 @@ type StandardBaseProps = {
|
|
|
65
83
|
subscriberId?: never;
|
|
66
84
|
applicationIdentifier?: never;
|
|
67
85
|
});
|
|
68
|
-
type
|
|
86
|
+
type InboxBaseProps = Omit<StandardBaseProps, 'appearance'> & {
|
|
87
|
+
appearance?: ReactInboxAppearance;
|
|
88
|
+
};
|
|
89
|
+
type BaseProps = InboxBaseProps;
|
|
69
90
|
type NotificationRendererProps = {
|
|
70
91
|
renderNotification: NotificationsRenderer;
|
|
71
92
|
renderAvatar?: never;
|
|
@@ -97,4 +118,4 @@ type WithChildrenProps = BaseProps & {
|
|
|
97
118
|
children: React.ReactNode;
|
|
98
119
|
};
|
|
99
120
|
|
|
100
|
-
export type { AvatarRenderer, BaseProps, BellRenderer, BodyRenderer, CustomActionsRenderer, DefaultActionsRenderer, DefaultInboxProps, DefaultProps, NoRendererProps, NotificationRendererProps, NotificationsRenderer,
|
|
121
|
+
export type { AvatarRenderer, BaseProps, BellRenderer, BodyRenderer, CustomActionsRenderer, DefaultActionsRenderer, DefaultInboxProps, DefaultProps, NoRendererProps, NotificationRendererProps, NotificationsRenderer, ReactAllAppearance, ReactAllIconOverrides, ReactAllTheme, ReactIconRenderer, ReactIconRendererProps, ReactInboxAppearance, ReactInboxIconOverrides, ReactInboxTheme, ReactSubscriptionAppearance, ReactSubscriptionIconOverrides, ReactSubscriptionTheme, SubjectBodyRendererProps, SubjectRenderer, WithChildrenProps };
|
|
@@ -81,7 +81,10 @@ var DefaultInbox = (props) => {
|
|
|
81
81
|
};
|
|
82
82
|
var Inbox = React.memo((props) => {
|
|
83
83
|
const { subscriberId, ...propsWithoutSubscriberId } = props;
|
|
84
|
-
const subscriber =
|
|
84
|
+
const subscriber = useMemo(
|
|
85
|
+
() => buildSubscriber({ subscriberId: props.subscriberId, subscriber: props.subscriber }),
|
|
86
|
+
[props.subscriberId, props.subscriber]
|
|
87
|
+
);
|
|
85
88
|
const applicationIdentifier = props.applicationIdentifier ? props.applicationIdentifier : "";
|
|
86
89
|
const novu = useUnsafeNovu();
|
|
87
90
|
if (novu) {
|
|
@@ -195,6 +198,7 @@ var InboxChild = withRenderer(
|
|
|
195
198
|
) });
|
|
196
199
|
})
|
|
197
200
|
);
|
|
201
|
+
InboxChild.displayName = "InboxChild";
|
|
198
202
|
function isWithChildrenProps(props) {
|
|
199
203
|
return "children" in props;
|
|
200
204
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Inbox.tsx"],"sourcesContent":["import { StandardNovuOptions } from '@novu/js';\nimport { buildSubscriber } from '@novu/js/internal';\nimport React, { useMemo } from 'react';\nimport { useNovuUI } from '../context/NovuUIContext';\nimport { useRenderer } from '../context/RendererContext';\nimport { InternalNovuProvider, useNovu, useUnsafeNovu } from '../hooks/NovuProvider';\nimport { DefaultInboxProps, DefaultProps, WithChildrenProps } from '../utils/types';\nimport { Mounter } from './Mounter';\nimport { NovuUI } from './NovuUI';\nimport { withRenderer } from './Renderer';\n\nexport type InboxProps = DefaultProps | WithChildrenProps;\n\nconst DefaultInbox = (props: DefaultInboxProps) => {\n const {\n open,\n renderNotification,\n renderAvatar,\n renderSubject,\n renderBody,\n renderDefaultActions,\n renderCustomActions,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placement,\n placementOffset,\n } = props;\n const { novuUI } = useNovuUI();\n const { mountElement } = useRenderer();\n\n const mount = React.useCallback(\n (element: HTMLElement) => {\n if (renderNotification) {\n return novuUI.mountComponent({\n name: 'Inbox',\n props: {\n open,\n renderNotification: renderNotification\n ? (el, notification) => mountElement(el, renderNotification(notification))\n : undefined,\n renderBell: renderBell ? (el, unreadCount) => mountElement(el, renderBell(unreadCount)) : undefined,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n },\n element,\n });\n }\n\n return novuUI.mountComponent({\n name: 'Inbox',\n props: {\n open,\n renderAvatar: renderAvatar ? (el, notification) => mountElement(el, renderAvatar(notification)) : undefined,\n renderSubject: renderSubject\n ? (el, notification) => mountElement(el, renderSubject(notification))\n : undefined,\n renderBody: renderBody ? (el, notification) => mountElement(el, renderBody(notification)) : undefined,\n renderDefaultActions: renderDefaultActions\n ? (el, notification) => mountElement(el, renderDefaultActions(notification))\n : undefined,\n renderCustomActions: renderCustomActions\n ? (el, notification) => mountElement(el, renderCustomActions(notification))\n : undefined,\n renderBell: renderBell ? (el, unreadCount) => mountElement(el, renderBell(unreadCount)) : undefined,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n },\n element,\n });\n },\n [\n open,\n renderNotification,\n renderAvatar,\n renderSubject,\n renderBody,\n renderDefaultActions,\n renderCustomActions,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n ]\n );\n\n return <Mounter mount={mount} />;\n};\n\nexport const Inbox = React.memo((props: InboxProps) => {\n const { subscriberId, ...propsWithoutSubscriberId } = props;\n const subscriber = buildSubscriber({ subscriberId: props.subscriberId, subscriber: props.subscriber });\n const applicationIdentifier = props.applicationIdentifier ? props.applicationIdentifier : ''; // for keyless we provide an empty string, the api will generate a identifier\n const novu = useUnsafeNovu();\n\n if (novu) {\n return (\n <InboxChild {...propsWithoutSubscriberId} applicationIdentifier={applicationIdentifier} subscriber={subscriber} />\n );\n }\n\n const providerProps = {\n applicationIdentifier,\n subscriberHash: props.subscriberHash,\n contextHash: props.contextHash,\n backendUrl: props.backendUrl,\n socketUrl: props.socketUrl,\n subscriber,\n defaultSchedule: props.defaultSchedule,\n context: props.context,\n } satisfies StandardNovuOptions;\n\n return (\n <InternalNovuProvider {...providerProps} userAgentType=\"components\">\n <InboxChild {...propsWithoutSubscriberId} applicationIdentifier={applicationIdentifier} subscriber={subscriber} />\n </InternalNovuProvider>\n );\n});\n\nconst InboxChild = withRenderer(\n React.memo((props: InboxProps) => {\n const {\n localization,\n appearance,\n tabs,\n preferencesFilter,\n preferenceGroups,\n preferencesSort,\n routerPush,\n applicationIdentifier = '', // for keyless we provide an empty string, the api will generate a identifier\n subscriberId,\n subscriberHash,\n contextHash,\n backendUrl,\n socketUrl,\n subscriber,\n defaultSchedule,\n context,\n } = props;\n const novu = useNovu();\n\n const options = useMemo(() => {\n return {\n localization,\n appearance,\n tabs,\n preferencesFilter,\n preferenceGroups,\n preferencesSort,\n routerPush,\n options: {\n applicationIdentifier,\n subscriberHash,\n contextHash,\n backendUrl,\n socketUrl,\n subscriber: buildSubscriber({ subscriberId, subscriber }),\n defaultSchedule,\n context,\n },\n };\n }, [\n localization,\n appearance,\n tabs,\n preferencesFilter,\n preferenceGroups,\n preferencesSort,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n contextHash,\n backendUrl,\n socketUrl,\n subscriber,\n context,\n ]);\n\n if (isWithChildrenProps(props)) {\n return (\n <NovuUI options={options} novu={novu}>\n {props.children}\n </NovuUI>\n );\n }\n\n const {\n open,\n renderNotification,\n renderAvatar,\n renderSubject,\n renderBody,\n renderDefaultActions,\n renderCustomActions,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n } = props;\n\n return (\n <NovuUI options={options} novu={novu}>\n <DefaultInbox\n open={open}\n renderNotification={renderNotification}\n renderAvatar={renderAvatar}\n renderSubject={renderSubject}\n renderBody={renderBody}\n renderDefaultActions={renderDefaultActions}\n renderCustomActions={renderCustomActions}\n renderBell={renderBell}\n onNotificationClick={onNotificationClick}\n onPrimaryActionClick={onPrimaryActionClick}\n onSecondaryActionClick={onSecondaryActionClick}\n placement={placement}\n placementOffset={placementOffset}\n />\n </NovuUI>\n );\n })\n);\n\nfunction isWithChildrenProps(props: InboxProps): props is WithChildrenProps {\n return 'children' in props;\n}\n"],"mappings":";AACA,SAAS,uBAAuB;AAChC,OAAO,SAAS,eAAe;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB,SAAS,qBAAqB;AAE7D,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAoFpB;AAhFT,IAAM,eAAe,CAAC,UAA6B;AACjD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAC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A,QACA;AAAA,QACA,SAAS;AAAA,UACP;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,YAAY,gBAAgB,EAAE,cAAc,WAAW,CAAC;AAAA,UACxD;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF,GAAG;AAAA,MACD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,oBAAoB,KAAK,GAAG;AAC9B,aACE,oBAAC,UAAO,SAAkB,MACvB,gBAAM,UACT;AAAA,IAEJ;AAEA,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI;AAEJ,WACE,oBAAC,UAAO,SAAkB,MACxB;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF,GACF;AAAA,EAEJ,CAAC;AACH;AAEA,SAAS,oBAAoB,OAA+C;AAC1E,SAAO,cAAc;AACvB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Inbox.tsx"],"sourcesContent":["import { StandardNovuOptions } from '@novu/js';\nimport { buildSubscriber } from '@novu/js/internal';\nimport React, { useMemo } from 'react';\nimport { useNovuUI } from '../context/NovuUIContext';\nimport { useRenderer } from '../context/RendererContext';\nimport { InternalNovuProvider, useNovu, useUnsafeNovu } from '../hooks/NovuProvider';\nimport { DefaultInboxProps, DefaultProps, WithChildrenProps } from '../utils/types';\nimport { Mounter } from './Mounter';\nimport { NovuUI } from './NovuUI';\nimport { withRenderer } from './Renderer';\n\nexport type InboxProps = DefaultProps | WithChildrenProps;\n\nconst DefaultInbox = (props: DefaultInboxProps) => {\n const {\n open,\n renderNotification,\n renderAvatar,\n renderSubject,\n renderBody,\n renderDefaultActions,\n renderCustomActions,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placement,\n placementOffset,\n } = props;\n const { novuUI } = useNovuUI();\n const { mountElement } = useRenderer();\n\n const mount = React.useCallback(\n (element: HTMLElement) => {\n if (renderNotification) {\n return novuUI.mountComponent({\n name: 'Inbox',\n props: {\n open,\n renderNotification: renderNotification\n ? (el, notification) => mountElement(el, renderNotification(notification))\n : undefined,\n renderBell: renderBell ? (el, unreadCount) => mountElement(el, renderBell(unreadCount)) : undefined,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n },\n element,\n });\n }\n\n return novuUI.mountComponent({\n name: 'Inbox',\n props: {\n open,\n renderAvatar: renderAvatar ? (el, notification) => mountElement(el, renderAvatar(notification)) : undefined,\n renderSubject: renderSubject\n ? (el, notification) => mountElement(el, renderSubject(notification))\n : undefined,\n renderBody: renderBody ? (el, notification) => mountElement(el, renderBody(notification)) : undefined,\n renderDefaultActions: renderDefaultActions\n ? (el, notification) => mountElement(el, renderDefaultActions(notification))\n : undefined,\n renderCustomActions: renderCustomActions\n ? (el, notification) => mountElement(el, renderCustomActions(notification))\n : undefined,\n renderBell: renderBell ? (el, unreadCount) => mountElement(el, renderBell(unreadCount)) : undefined,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n },\n element,\n });\n },\n [\n open,\n renderNotification,\n renderAvatar,\n renderSubject,\n renderBody,\n renderDefaultActions,\n renderCustomActions,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n ]\n );\n\n return <Mounter mount={mount} />;\n};\n\nexport const Inbox = React.memo((props: InboxProps) => {\n const { subscriberId, ...propsWithoutSubscriberId } = props;\n const subscriber = useMemo(\n () => buildSubscriber({ subscriberId: props.subscriberId, subscriber: props.subscriber }),\n [props.subscriberId, props.subscriber]\n );\n const applicationIdentifier = props.applicationIdentifier ? props.applicationIdentifier : ''; // for keyless we provide an empty string, the api will generate a identifier\n const novu = useUnsafeNovu();\n\n if (novu) {\n return (\n <InboxChild {...propsWithoutSubscriberId} applicationIdentifier={applicationIdentifier} subscriber={subscriber} />\n );\n }\n\n const providerProps = {\n applicationIdentifier,\n subscriberHash: props.subscriberHash,\n contextHash: props.contextHash,\n backendUrl: props.backendUrl,\n socketUrl: props.socketUrl,\n subscriber,\n defaultSchedule: props.defaultSchedule,\n context: props.context,\n } satisfies StandardNovuOptions;\n\n return (\n <InternalNovuProvider {...providerProps} userAgentType=\"components\">\n <InboxChild {...propsWithoutSubscriberId} applicationIdentifier={applicationIdentifier} subscriber={subscriber} />\n </InternalNovuProvider>\n );\n});\n\nconst InboxChild = withRenderer(\n React.memo((props: InboxProps) => {\n const {\n localization,\n appearance,\n tabs,\n preferencesFilter,\n preferenceGroups,\n preferencesSort,\n routerPush,\n applicationIdentifier = '', // for keyless we provide an empty string, the api will generate a identifier\n subscriberId,\n subscriberHash,\n contextHash,\n backendUrl,\n socketUrl,\n subscriber,\n defaultSchedule,\n context,\n } = props;\n const novu = useNovu();\n\n const options = useMemo(() => {\n return {\n localization,\n appearance,\n tabs,\n preferencesFilter,\n preferenceGroups,\n preferencesSort,\n routerPush,\n options: {\n applicationIdentifier,\n subscriberHash,\n contextHash,\n backendUrl,\n socketUrl,\n subscriber: buildSubscriber({ subscriberId, subscriber }),\n defaultSchedule,\n context,\n },\n };\n }, [\n localization,\n appearance,\n tabs,\n preferencesFilter,\n preferenceGroups,\n preferencesSort,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n contextHash,\n backendUrl,\n socketUrl,\n subscriber,\n context,\n ]);\n\n if (isWithChildrenProps(props)) {\n return (\n <NovuUI options={options} novu={novu}>\n {props.children}\n </NovuUI>\n );\n }\n\n const {\n open,\n renderNotification,\n renderAvatar,\n renderSubject,\n renderBody,\n renderDefaultActions,\n renderCustomActions,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n } = props;\n\n return (\n <NovuUI options={options} novu={novu}>\n <DefaultInbox\n open={open}\n renderNotification={renderNotification}\n renderAvatar={renderAvatar}\n renderSubject={renderSubject}\n renderBody={renderBody}\n renderDefaultActions={renderDefaultActions}\n renderCustomActions={renderCustomActions}\n renderBell={renderBell}\n onNotificationClick={onNotificationClick}\n onPrimaryActionClick={onPrimaryActionClick}\n onSecondaryActionClick={onSecondaryActionClick}\n placement={placement}\n placementOffset={placementOffset}\n />\n </NovuUI>\n );\n })\n);\n\nInboxChild.displayName = 'InboxChild';\n\nfunction isWithChildrenProps(props: InboxProps): props is WithChildrenProps {\n return 'children' in props;\n}\n"],"mappings":";AACA,SAAS,uBAAuB;AAChC,OAAO,SAAS,eAAe;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB,SAAS,qBAAqB;AAE7D,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAoFpB;AAhFT,IAAM,eAAe,CAAC,UAA6B;AACjD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,EAAE,OAAO,IAAI,UAAU;AAC7B,QAAM,EAAE,aAAa,IAAI,YAAY;AAErC,QAAM,QAAQ,MAAM;AAAA,IAClB,CAAC,YAAyB;AACxB,UAAI,oBAAoB;AACtB,eAAO,OAAO,eAAe;AAAA,UAC3B,MAAM;AAAA,UACN,OAAO;AAAA,YACL;AAAA,YACA,oBAAoB,qBAChB,CA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A,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,oBAAoB,KAAK,GAAG;AAC9B,aACE,oBAAC,UAAO,SAAkB,MACvB,gBAAM,UACT;AAAA,IAEJ;AAEA,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI;AAEJ,WACE,oBAAC,UAAO,SAAkB,MACxB;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF,GACF;AAAA,EAEJ,CAAC;AACH;AAEA,WAAW,cAAc;AAEzB,SAAS,oBAAoB,OAA+C;AAC1E,SAAO,cAAc;AACvB;","names":[]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Novu } from '@novu/js';
|
|
3
|
-
import { NovuUIOptions } from '@novu/js/ui';
|
|
3
|
+
import { NovuUIOptions as NovuUIOptions$1 } from '@novu/js/ui';
|
|
4
4
|
import React__default from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { ReactInboxAppearance, ReactSubscriptionAppearance } from '../utils/types.js';
|
|
6
6
|
|
|
7
|
-
type
|
|
8
|
-
appearance?:
|
|
7
|
+
type NovuUIOptions = Omit<NovuUIOptions$1, 'appearance'> & {
|
|
8
|
+
appearance?: ReactInboxAppearance | ReactSubscriptionAppearance;
|
|
9
9
|
};
|
|
10
|
-
type
|
|
11
|
-
options:
|
|
12
|
-
novu
|
|
10
|
+
type NovuUIProps = React__default.PropsWithChildren<{
|
|
11
|
+
options: NovuUIOptions;
|
|
12
|
+
novu: Novu;
|
|
13
13
|
}>;
|
|
14
|
-
declare const NovuUI: ({ options, novu, children }:
|
|
14
|
+
declare const NovuUI: ({ options, novu, children }: NovuUIProps) => react_jsx_runtime.JSX.Element;
|
|
15
15
|
|
|
16
|
-
export { NovuUI };
|
|
16
|
+
export { NovuUI, type NovuUIOptions };
|
|
@@ -64,6 +64,7 @@ var NovuUI = ({ options, novu, children }) => {
|
|
|
64
64
|
novuUI.updateTabs(options.tabs);
|
|
65
65
|
novuUI.updateOptions(options.options);
|
|
66
66
|
novuUI.updateRouterPush(options.routerPush);
|
|
67
|
+
novuUI.updateNovu(novu);
|
|
67
68
|
}, [
|
|
68
69
|
shadowRootDetector,
|
|
69
70
|
novuUI,
|
|
@@ -71,7 +72,8 @@ var NovuUI = ({ options, novu, children }) => {
|
|
|
71
72
|
options.localization,
|
|
72
73
|
options.tabs,
|
|
73
74
|
options.options,
|
|
74
|
-
options.routerPush
|
|
75
|
+
options.routerPush,
|
|
76
|
+
novu
|
|
75
77
|
]);
|
|
76
78
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
77
79
|
/* @__PURE__ */ jsx(ShadowRootDetector, { ref: shadowRootDetector }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/NovuUI.tsx"],"sourcesContent":["import { Novu } from '@novu/js';\nimport type { NovuUIOptions as JsNovuUIOptions } from '@novu/js/ui';\nimport { NovuUI as NovuUIClass } from '@novu/js/ui';\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport { NovuUIProvider } from '../context/NovuUIContext';\nimport { useRenderer } from '../context/RendererContext';\nimport { useDataRef } from '../hooks/internal/useDataRef';\nimport { adaptAppearanceForJs } from '../utils/appearance';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/NovuUI.tsx"],"sourcesContent":["import { Novu } from '@novu/js';\nimport type { NovuUIOptions as JsNovuUIOptions } from '@novu/js/ui';\nimport { NovuUI as NovuUIClass } from '@novu/js/ui';\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport { NovuUIProvider } from '../context/NovuUIContext';\nimport { useRenderer } from '../context/RendererContext';\nimport { useDataRef } from '../hooks/internal/useDataRef';\nimport { adaptAppearanceForJs } from '../utils/appearance';\nimport type { ReactInboxAppearance, ReactSubscriptionAppearance } from '../utils/types';\nimport { ShadowRootDetector } from './ShadowRootDetector';\n\nexport type NovuUIOptions = Omit<JsNovuUIOptions, 'appearance'> & {\n appearance?: ReactInboxAppearance | ReactSubscriptionAppearance;\n};\n\ntype NovuUIProps = React.PropsWithChildren<{\n options: NovuUIOptions;\n novu: Novu;\n}>;\n\nconst findParentShadowRoot = (child?: HTMLDivElement | null): Node | null => {\n if (!child) {\n return null;\n }\n\n let node: Node | null = child;\n\n while (node) {\n if (node instanceof Element && node.shadowRoot) {\n return node.shadowRoot;\n }\n\n if (node instanceof ShadowRoot) {\n return node;\n }\n\n node = node.parentNode;\n\n if (!node || node === document) {\n break;\n }\n }\n\n return null;\n};\n\nexport const NovuUI = ({ options, novu, children }: NovuUIProps) => {\n const shadowRootDetector = useRef<HTMLDivElement>(null);\n const { mountElement } = useRenderer();\n\n const adaptedAppearanceForUpdate = useMemo(\n () => adaptAppearanceForJs(options.appearance || {}, mountElement),\n [options.appearance, mountElement]\n );\n\n const adaptedOptions = useMemo(() => {\n return {\n ...options,\n appearance: adaptedAppearanceForUpdate,\n novu,\n };\n }, [options, novu, adaptedAppearanceForUpdate]);\n\n const optionsRef = useDataRef(adaptedOptions);\n const [novuUI, setNovuUI] = useState<NovuUIClass | undefined>();\n\n useEffect(() => {\n const parentShadowRoot = findParentShadowRoot(shadowRootDetector.current);\n const instance = new NovuUIClass({\n ...optionsRef.current,\n container: optionsRef.current.container ?? parentShadowRoot,\n });\n setNovuUI(instance);\n\n return () => {\n instance.unmount();\n };\n }, []);\n\n useEffect(() => {\n if (!novuUI) {\n return;\n }\n\n const parentShadowRoot = findParentShadowRoot(shadowRootDetector.current);\n novuUI.updateContainer(options.container ?? parentShadowRoot);\n novuUI.updateAppearance(adaptedAppearanceForUpdate);\n novuUI.updateLocalization(options.localization);\n novuUI.updateTabs(options.tabs);\n novuUI.updateOptions(options.options);\n novuUI.updateRouterPush(options.routerPush);\n novuUI.updateNovu(novu);\n }, [\n shadowRootDetector,\n novuUI,\n adaptedAppearanceForUpdate,\n options.localization,\n options.tabs,\n options.options,\n options.routerPush,\n novu,\n ]);\n\n return (\n <>\n <ShadowRootDetector ref={shadowRootDetector} />\n {novuUI && <NovuUIProvider value={{ novuUI }}>{children}</NovuUIProvider>}\n </>\n );\n};\n"],"mappings":";AAEA,SAAS,UAAU,mBAAmB;AACtC,SAAgB,WAAW,SAAS,QAAQ,gBAAgB;AAC5D,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,4BAA4B;AAErC,SAAS,0BAA0B;AA+F/B,mBACE,KADF;AApFJ,IAAM,uBAAuB,CAAC,UAA+C;AAC3E,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,MAAI,OAAoB;AAExB,SAAO,MAAM;AACX,QAAI,gBAAgB,WAAW,KAAK,YAAY;AAC9C,aAAO,KAAK;AAAA,IACd;AAEA,QAAI,gBAAgB,YAAY;AAC9B,aAAO;AAAA,IACT;AAEA,WAAO,KAAK;AAEZ,QAAI,CAAC,QAAQ,SAAS,UAAU;AAC9B;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEO,IAAM,SAAS,CAAC,EAAE,SAAS,MAAM,SAAS,MAAmB;AAClE,QAAM,qBAAqB,OAAuB,IAAI;AACtD,QAAM,EAAE,aAAa,IAAI,YAAY;AAErC,QAAM,6BAA6B;AAAA,IACjC,MAAM,qBAAqB,QAAQ,cAAc,CAAC,GAAG,YAAY;AAAA,IACjE,CAAC,QAAQ,YAAY,YAAY;AAAA,EACnC;AAEA,QAAM,iBAAiB,QAAQ,MAAM;AACnC,WAAO;AAAA,MACL,GAAG;AAAA,MACH,YAAY;AAAA,MACZ;AAAA,IACF;AAAA,EACF,GAAG,CAAC,SAAS,MAAM,0BAA0B,CAAC;AAE9C,QAAM,aAAa,WAAW,cAAc;AAC5C,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAkC;AAE9D,YAAU,MAAM;AACd,UAAM,mBAAmB,qBAAqB,mBAAmB,OAAO;AACxE,UAAM,WAAW,IAAI,YAAY;AAAA,MAC/B,GAAG,WAAW;AAAA,MACd,WAAW,WAAW,QAAQ,aAAa;AAAA,IAC7C,CAAC;AACD,cAAU,QAAQ;AAElB,WAAO,MAAM;AACX,eAAS,QAAQ;AAAA,IACnB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACd,QAAI,CAAC,QAAQ;AACX;AAAA,IACF;AAEA,UAAM,mBAAmB,qBAAqB,mBAAmB,OAAO;AACxE,WAAO,gBAAgB,QAAQ,aAAa,gBAAgB;AAC5D,WAAO,iBAAiB,0BAA0B;AAClD,WAAO,mBAAmB,QAAQ,YAAY;AAC9C,WAAO,WAAW,QAAQ,IAAI;AAC9B,WAAO,cAAc,QAAQ,OAAO;AACpC,WAAO,iBAAiB,QAAQ,UAAU;AAC1C,WAAO,WAAW,IAAI;AAAA,EACxB,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR;AAAA,EACF,CAAC;AAED,SACE,iCACE;AAAA,wBAAC,sBAAmB,KAAK,oBAAoB;AAAA,IAC5C,UAAU,oBAAC,kBAAe,OAAO,EAAE,OAAO,GAAI,UAAS;AAAA,KAC1D;AAEJ;","names":[]}
|
|
@@ -4,8 +4,13 @@ export { Inbox, InboxProps } from './Inbox.js';
|
|
|
4
4
|
export { InboxContent, InboxContentProps } from './InboxContent.js';
|
|
5
5
|
export { NotificationProps, Notifications } from './Notifications.js';
|
|
6
6
|
export { Preferences } from './Preferences.js';
|
|
7
|
+
export { Subscription, SubscriptionProps } from './subscription/Subscription.js';
|
|
8
|
+
export { SubscriptionButton, SubscriptionButtonProps } from './subscription/SubscriptionButton.js';
|
|
9
|
+
export { SubscriptionPreferences, SubscriptionPreferencesProps } from './subscription/SubscriptionPreferences.js';
|
|
7
10
|
import 'react/jsx-runtime';
|
|
8
11
|
import '@novu/js';
|
|
9
12
|
import 'react';
|
|
10
13
|
import '../utils/types.js';
|
|
11
14
|
import '@novu/js/ui';
|
|
15
|
+
import './NovuUI.js';
|
|
16
|
+
import './subscription/DefaultSubscription.js';
|
|
@@ -5,4 +5,7 @@ export * from "./Inbox.js";
|
|
|
5
5
|
export * from "./InboxContent.js";
|
|
6
6
|
export * from "./Notifications.js";
|
|
7
7
|
export * from "./Preferences.js";
|
|
8
|
+
export * from "./subscription/Subscription.js";
|
|
9
|
+
export * from "./subscription/SubscriptionButton.js";
|
|
10
|
+
export * from "./subscription/SubscriptionPreferences.js";
|
|
8
11
|
//# 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 './Notifications';\nexport * from './Preferences';\n"],"mappings":";AAAA,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 './Notifications';\nexport * from './Preferences';\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;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { TopicSubscription } from '@novu/js';
|
|
3
|
+
import { SubscriptionProps } from '@novu/js/ui';
|
|
4
|
+
|
|
5
|
+
type PreferencesRenderer = (subscription?: TopicSubscription, loading?: boolean) => React.ReactNode;
|
|
6
|
+
type DefaultSubscriptionProps = {
|
|
7
|
+
renderPreferences?: PreferencesRenderer;
|
|
8
|
+
} & Pick<SubscriptionProps, 'open' | 'placement' | 'placementOffset' | 'topicKey' | 'identifier' | 'preferences'>;
|
|
9
|
+
declare const DefaultSubscription: (props: DefaultSubscriptionProps) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { DefaultSubscription, type DefaultSubscriptionProps, type PreferencesRenderer };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/components/subscription/DefaultSubscription.tsx
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { useNovuUI } from "../../context/NovuUIContext.js";
|
|
4
|
+
import { useRenderer } from "../../context/RendererContext.js";
|
|
5
|
+
import { Mounter } from "../Mounter.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var DefaultSubscription = (props) => {
|
|
8
|
+
const { topicKey, identifier, preferences, open, placement, placementOffset, renderPreferences } = props;
|
|
9
|
+
const { novuUI } = useNovuUI();
|
|
10
|
+
const { mountElement } = useRenderer();
|
|
11
|
+
const mount = useCallback(
|
|
12
|
+
(element) => {
|
|
13
|
+
return novuUI.mountComponent({
|
|
14
|
+
name: "Subscription",
|
|
15
|
+
props: {
|
|
16
|
+
topicKey,
|
|
17
|
+
identifier,
|
|
18
|
+
preferences,
|
|
19
|
+
open,
|
|
20
|
+
placementOffset,
|
|
21
|
+
placement,
|
|
22
|
+
renderPreferences: renderPreferences ? (el, subscription, loading) => mountElement(el, renderPreferences(subscription, loading)) : void 0
|
|
23
|
+
},
|
|
24
|
+
element
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
[topicKey, identifier, preferences, open, placementOffset, placement, renderPreferences, novuUI, mountElement]
|
|
28
|
+
);
|
|
29
|
+
return /* @__PURE__ */ jsx(Mounter, { mount });
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
DefaultSubscription
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=DefaultSubscription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/subscription/DefaultSubscription.tsx"],"sourcesContent":["import { TopicSubscription } from '@novu/js';\nimport { SubscriptionProps } from '@novu/js/ui';\nimport { useCallback } from 'react';\nimport { useNovuUI } from '../../context/NovuUIContext';\nimport { useRenderer } from '../../context/RendererContext';\nimport { Mounter } from '../Mounter';\n\nexport type PreferencesRenderer = (subscription?: TopicSubscription, loading?: boolean) => React.ReactNode;\n\nexport type DefaultSubscriptionProps = {\n renderPreferences?: PreferencesRenderer;\n} & Pick<SubscriptionProps, 'open' | 'placement' | 'placementOffset' | 'topicKey' | 'identifier' | 'preferences'>;\n\nexport const DefaultSubscription = (props: DefaultSubscriptionProps) => {\n const { topicKey, identifier, preferences, open, placement, placementOffset, renderPreferences } = props;\n const { novuUI } = useNovuUI();\n const { mountElement } = useRenderer();\n\n const mount = useCallback(\n (element: HTMLElement) => {\n return novuUI.mountComponent({\n name: 'Subscription',\n props: {\n topicKey,\n identifier,\n preferences,\n open,\n placementOffset,\n placement,\n renderPreferences: renderPreferences\n ? (el, subscription, loading) => mountElement(el, renderPreferences(subscription, loading))\n : undefined,\n },\n element,\n });\n },\n [topicKey, identifier, preferences, open, placementOffset, placement, renderPreferences, novuUI, mountElement]\n );\n\n return <Mounter mount={mount} />;\n};\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AAkCf;AA1BF,IAAM,sBAAsB,CAAC,UAAoC;AACtE,QAAM,EAAE,UAAU,YAAY,aAAa,MAAM,WAAW,iBAAiB,kBAAkB,IAAI;AACnG,QAAM,EAAE,OAAO,IAAI,UAAU;AAC7B,QAAM,EAAE,aAAa,IAAI,YAAY;AAErC,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,mBAAmB,oBACf,CAAC,IAAI,cAAc,YAAY,aAAa,IAAI,kBAAkB,cAAc,OAAO,CAAC,IACxF;AAAA,QACN;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,UAAU,YAAY,aAAa,MAAM,iBAAiB,WAAW,mBAAmB,QAAQ,YAAY;AAAA,EAC/G;AAEA,SAAO,oBAAC,WAAQ,OAAc;AAChC;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { SubscriptionLocalization } from '@novu/js/ui';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
import { ReactSubscriptionAppearance } from '../../utils/types.js';
|
|
5
|
+
import { NovuUIOptions } from '../NovuUI.js';
|
|
6
|
+
import { DefaultSubscriptionProps } from './DefaultSubscription.js';
|
|
7
|
+
import '@novu/js';
|
|
8
|
+
|
|
9
|
+
type BaseSubscriptionProps = {
|
|
10
|
+
localization?: SubscriptionLocalization;
|
|
11
|
+
appearance?: ReactSubscriptionAppearance;
|
|
12
|
+
} & Pick<NovuUIOptions, 'container'>;
|
|
13
|
+
type SubscriptionPropsWithChildren = {
|
|
14
|
+
children?: React__default.ReactNode;
|
|
15
|
+
} & Exclude<DefaultSubscriptionProps, 'renderPreferences'> & BaseSubscriptionProps;
|
|
16
|
+
type SubscriptionPropsWithoutChildren = {
|
|
17
|
+
children?: never;
|
|
18
|
+
} & DefaultSubscriptionProps & BaseSubscriptionProps;
|
|
19
|
+
type SubscriptionProps = SubscriptionPropsWithChildren | SubscriptionPropsWithoutChildren;
|
|
20
|
+
declare const Subscription: React__default.MemoExoticComponent<(props: SubscriptionProps) => react_jsx_runtime.JSX.Element>;
|
|
21
|
+
|
|
22
|
+
export { Subscription, type SubscriptionProps };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/components/subscription/Subscription.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 { DefaultSubscription } from "./DefaultSubscription.js";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var SubscriptionInternal = withRenderer((props) => {
|
|
9
|
+
const { container, localization, appearance, ...defaultSubscriptionProps } = props;
|
|
10
|
+
const novu = useNovu();
|
|
11
|
+
const options = useMemo(() => {
|
|
12
|
+
return {
|
|
13
|
+
container,
|
|
14
|
+
localization,
|
|
15
|
+
appearance,
|
|
16
|
+
options: novu.options
|
|
17
|
+
};
|
|
18
|
+
}, [localization, appearance, container, novu.options]);
|
|
19
|
+
if (isWithChildrenProps(props)) {
|
|
20
|
+
const clonedChildren = React.Children.map(props.children, (child) => {
|
|
21
|
+
if (React.isValidElement(child)) {
|
|
22
|
+
return React.cloneElement(child, {
|
|
23
|
+
...child.props,
|
|
24
|
+
topicKey: defaultSubscriptionProps.topicKey,
|
|
25
|
+
identifier: defaultSubscriptionProps.identifier,
|
|
26
|
+
preferences: defaultSubscriptionProps.preferences
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return child;
|
|
30
|
+
});
|
|
31
|
+
return /* @__PURE__ */ jsx(NovuUI, { options, novu, children: clonedChildren });
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ jsx(NovuUI, { options, novu, children: /* @__PURE__ */ jsx(DefaultSubscription, { ...defaultSubscriptionProps }) });
|
|
34
|
+
});
|
|
35
|
+
SubscriptionInternal.displayName = "SubscriptionInternal";
|
|
36
|
+
var Subscription = React.memo((props) => {
|
|
37
|
+
return /* @__PURE__ */ jsx(SubscriptionInternal, { ...props });
|
|
38
|
+
});
|
|
39
|
+
function isWithChildrenProps(props) {
|
|
40
|
+
return "children" in props;
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
Subscription
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=Subscription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/subscription/Subscription.tsx"],"sourcesContent":["import { SubscriptionLocalization } from '@novu/js/ui';\nimport React, { useMemo } from 'react';\nimport { useNovu } from '../../hooks/NovuProvider';\nimport { ReactSubscriptionAppearance } from '../../utils/types';\nimport { NovuUI, NovuUIOptions } from '../NovuUI';\nimport { withRenderer } from '../Renderer';\nimport { DefaultSubscription, DefaultSubscriptionProps } from './DefaultSubscription';\n\ntype BaseSubscriptionProps = {\n localization?: SubscriptionLocalization;\n appearance?: ReactSubscriptionAppearance;\n} & Pick<NovuUIOptions, 'container'>;\n\ntype SubscriptionPropsWithChildren = {\n children?: React.ReactNode;\n} & Exclude<DefaultSubscriptionProps, 'renderPreferences'> &\n BaseSubscriptionProps;\n\ntype SubscriptionPropsWithoutChildren = {\n children?: never;\n} & DefaultSubscriptionProps &\n BaseSubscriptionProps;\n\nexport type SubscriptionProps = SubscriptionPropsWithChildren | SubscriptionPropsWithoutChildren;\n\nconst SubscriptionInternal = withRenderer<SubscriptionProps>((props) => {\n const { container, localization, appearance, ...defaultSubscriptionProps } = props;\n const novu = useNovu();\n\n const options: NovuUIOptions = useMemo(() => {\n return {\n container,\n localization,\n appearance,\n options: novu.options,\n };\n }, [localization, appearance, container, novu.options]);\n\n if (isWithChildrenProps(props)) {\n const clonedChildren = React.Children.map(props.children, (child) => {\n if (React.isValidElement(child)) {\n return React.cloneElement(child, {\n ...child.props,\n topicKey: defaultSubscriptionProps.topicKey,\n identifier: defaultSubscriptionProps.identifier,\n preferences: defaultSubscriptionProps.preferences,\n });\n }\n\n return child;\n });\n\n return (\n <NovuUI options={options} novu={novu}>\n {clonedChildren}\n </NovuUI>\n );\n }\n\n return (\n <NovuUI options={options} novu={novu}>\n <DefaultSubscription {...defaultSubscriptionProps} />\n </NovuUI>\n );\n});\n\nSubscriptionInternal.displayName = 'SubscriptionInternal';\n\nexport const Subscription = React.memo((props: SubscriptionProps) => {\n return <SubscriptionInternal {...props} />;\n});\n\nfunction isWithChildrenProps(props: SubscriptionProps): props is SubscriptionPropsWithChildren {\n return 'children' in props;\n}\n"],"mappings":";AACA,OAAO,SAAS,eAAe;AAC/B,SAAS,eAAe;AAExB,SAAS,cAA6B;AACtC,SAAS,oBAAoB;AAC7B,SAAS,2BAAqD;AA+CxD;AA5BN,IAAM,uBAAuB,aAAgC,CAAC,UAAU;AACtE,QAAM,EAAE,WAAW,cAAc,YAAY,GAAG,yBAAyB,IAAI;AAC7E,QAAM,OAAO,QAAQ;AAErB,QAAM,UAAyB,QAAQ,MAAM;AAC3C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,KAAK;AAAA,IAChB;AAAA,EACF,GAAG,CAAC,cAAc,YAAY,WAAW,KAAK,OAAO,CAAC;AAEtD,MAAI,oBAAoB,KAAK,GAAG;AAC9B,UAAM,iBAAiB,MAAM,SAAS,IAAI,MAAM,UAAU,CAAC,UAAU;AACnE,UAAI,MAAM,eAAe,KAAK,GAAG;AAC/B,eAAO,MAAM,aAAa,OAAO;AAAA,UAC/B,GAAG,MAAM;AAAA,UACT,UAAU,yBAAyB;AAAA,UACnC,YAAY,yBAAyB;AAAA,UACrC,aAAa,yBAAyB;AAAA,QACxC,CAAC;AAAA,MACH;AAEA,aAAO;AAAA,IACT,CAAC;AAED,WACE,oBAAC,UAAO,SAAkB,MACvB,0BACH;AAAA,EAEJ;AAEA,SACE,oBAAC,UAAO,SAAkB,MACxB,8BAAC,uBAAqB,GAAG,0BAA0B,GACrD;AAEJ,CAAC;AAED,qBAAqB,cAAc;AAE5B,IAAM,eAAe,MAAM,KAAK,CAAC,UAA6B;AACnE,SAAO,oBAAC,wBAAsB,GAAG,OAAO;AAC1C,CAAC;AAED,SAAS,oBAAoB,OAAkE;AAC7F,SAAO,cAAc;AACvB;","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { SubscriptionButtonWrapperProps } from '@novu/js/ui';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
|
|
5
|
+
type SubscriptionButtonProps = Partial<SubscriptionButtonWrapperProps>;
|
|
6
|
+
declare const SubscriptionButton: React__default.MemoExoticComponent<({ topicKey, identifier, preferences, onClick, onDeleteError, onDeleteSuccess, onCreateError, onCreateSuccess, }: SubscriptionButtonProps) => react_jsx_runtime.JSX.Element>;
|
|
7
|
+
|
|
8
|
+
export { SubscriptionButton, type SubscriptionButtonProps };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// src/components/subscription/SubscriptionButton.tsx
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { useNovuUI } from "../../context/NovuUIContext.js";
|
|
4
|
+
import { Mounter } from "../Mounter.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
var SubscriptionButton = React.memo(
|
|
7
|
+
({
|
|
8
|
+
topicKey,
|
|
9
|
+
identifier,
|
|
10
|
+
preferences,
|
|
11
|
+
onClick,
|
|
12
|
+
onDeleteError,
|
|
13
|
+
onDeleteSuccess,
|
|
14
|
+
onCreateError,
|
|
15
|
+
onCreateSuccess
|
|
16
|
+
}) => {
|
|
17
|
+
const { novuUI } = useNovuUI();
|
|
18
|
+
const mount = React.useCallback(
|
|
19
|
+
(element) => {
|
|
20
|
+
if (!topicKey) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
return novuUI.mountComponent({
|
|
24
|
+
name: "SubscriptionButton",
|
|
25
|
+
element,
|
|
26
|
+
props: {
|
|
27
|
+
topicKey,
|
|
28
|
+
identifier,
|
|
29
|
+
preferences,
|
|
30
|
+
onClick,
|
|
31
|
+
onDeleteError,
|
|
32
|
+
onDeleteSuccess,
|
|
33
|
+
onCreateError,
|
|
34
|
+
onCreateSuccess
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
[
|
|
39
|
+
novuUI,
|
|
40
|
+
topicKey,
|
|
41
|
+
identifier,
|
|
42
|
+
preferences,
|
|
43
|
+
onClick,
|
|
44
|
+
onDeleteError,
|
|
45
|
+
onDeleteSuccess,
|
|
46
|
+
onCreateError,
|
|
47
|
+
onCreateSuccess
|
|
48
|
+
]
|
|
49
|
+
);
|
|
50
|
+
return /* @__PURE__ */ jsx(Mounter, { mount });
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
export {
|
|
54
|
+
SubscriptionButton
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=SubscriptionButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/subscription/SubscriptionButton.tsx"],"sourcesContent":["import type { SubscriptionButtonWrapperProps } from '@novu/js/ui';\nimport React from 'react';\nimport { useNovuUI } from '../../context/NovuUIContext';\nimport { Mounter } from '../Mounter';\n\nexport type SubscriptionButtonProps = Partial<SubscriptionButtonWrapperProps>;\n\nexport const SubscriptionButton = React.memo(\n ({\n topicKey,\n identifier,\n preferences,\n onClick,\n onDeleteError,\n onDeleteSuccess,\n onCreateError,\n onCreateSuccess,\n }: SubscriptionButtonProps) => {\n const { novuUI } = useNovuUI();\n\n const mount = React.useCallback(\n (element: HTMLElement) => {\n if (!topicKey) {\n return;\n }\n\n return novuUI.mountComponent({\n name: 'SubscriptionButton',\n element,\n props: {\n topicKey,\n identifier,\n preferences,\n onClick,\n onDeleteError,\n onDeleteSuccess,\n onCreateError,\n onCreateSuccess,\n },\n });\n },\n [\n novuUI,\n topicKey,\n identifier,\n preferences,\n onClick,\n onDeleteError,\n onDeleteSuccess,\n onCreateError,\n onCreateSuccess,\n ]\n );\n\n return <Mounter mount={mount} />;\n }\n);\n"],"mappings":";AACA,OAAO,WAAW;AAClB,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AAmDb;AA/CJ,IAAM,qBAAqB,MAAM;AAAA,EACtC,CAAC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,MAA+B;AAC7B,UAAM,EAAE,OAAO,IAAI,UAAU;AAE7B,UAAM,QAAQ,MAAM;AAAA,MAClB,CAAC,YAAyB;AACxB,YAAI,CAAC,UAAU;AACb;AAAA,QACF;AAEA,eAAO,OAAO,eAAe;AAAA,UAC3B,MAAM;AAAA,UACN;AAAA,UACA,OAAO;AAAA,YACL;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,oBAAC,WAAQ,OAAc;AAAA,EAChC;AACF;","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { SubscriptionPreferencesWrapperProps } from '@novu/js/ui';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
|
|
5
|
+
type SubscriptionPreferencesProps = Partial<SubscriptionPreferencesWrapperProps>;
|
|
6
|
+
declare const SubscriptionPreferences: React__default.MemoExoticComponent<({ topicKey, identifier, preferences, onClick, onDeleteError, onDeleteSuccess, onCreateError, onCreateSuccess, }: SubscriptionPreferencesProps) => react_jsx_runtime.JSX.Element>;
|
|
7
|
+
|
|
8
|
+
export { SubscriptionPreferences, type SubscriptionPreferencesProps };
|