@novu/react 3.11.0 → 3.12.0-rc.2

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.
Files changed (101) hide show
  1. package/README.md +10 -18
  2. package/dist/cjs/components/Inbox.cjs +5 -1
  3. package/dist/cjs/components/Inbox.cjs.map +1 -1
  4. package/dist/cjs/components/NovuUI.cjs +3 -1
  5. package/dist/cjs/components/NovuUI.cjs.map +1 -1
  6. package/dist/cjs/components/NovuUI.d.cts +9 -9
  7. package/dist/cjs/components/index.cjs +7 -1
  8. package/dist/cjs/components/index.cjs.map +1 -1
  9. package/dist/cjs/components/index.d.cts +5 -0
  10. package/dist/cjs/components/subscription/DefaultSubscription.cjs +59 -0
  11. package/dist/cjs/components/subscription/DefaultSubscription.cjs.map +1 -0
  12. package/dist/cjs/components/subscription/DefaultSubscription.d.cts +11 -0
  13. package/dist/cjs/components/subscription/Subscription.cjs +80 -0
  14. package/dist/cjs/components/subscription/Subscription.cjs.map +1 -0
  15. package/dist/cjs/components/subscription/Subscription.d.cts +22 -0
  16. package/dist/cjs/components/subscription/SubscriptionButton.cjs +91 -0
  17. package/dist/cjs/components/subscription/SubscriptionButton.cjs.map +1 -0
  18. package/dist/cjs/components/subscription/SubscriptionButton.d.cts +8 -0
  19. package/dist/cjs/components/subscription/SubscriptionPreferences.cjs +91 -0
  20. package/dist/cjs/components/subscription/SubscriptionPreferences.cjs.map +1 -0
  21. package/dist/cjs/components/subscription/SubscriptionPreferences.d.cts +8 -0
  22. package/dist/cjs/hooks/NovuProvider.cjs +21 -18
  23. package/dist/cjs/hooks/NovuProvider.cjs.map +1 -1
  24. package/dist/cjs/hooks/index.cjs +11 -1
  25. package/dist/cjs/hooks/index.cjs.map +1 -1
  26. package/dist/cjs/hooks/index.d.cts +7 -1
  27. package/dist/cjs/hooks/useCreateSubscription.cjs +61 -0
  28. package/dist/cjs/hooks/useCreateSubscription.cjs.map +1 -0
  29. package/dist/cjs/hooks/useCreateSubscription.d.cts +17 -0
  30. package/dist/cjs/hooks/useDeleteSubscription.cjs +61 -0
  31. package/dist/cjs/hooks/useDeleteSubscription.cjs.map +1 -0
  32. package/dist/cjs/hooks/useDeleteSubscription.d.cts +17 -0
  33. package/dist/cjs/hooks/useSubscription.cjs +156 -0
  34. package/dist/cjs/hooks/useSubscription.cjs.map +1 -0
  35. package/dist/cjs/hooks/useSubscription.d.cts +21 -0
  36. package/dist/cjs/hooks/useSubscriptions.cjs +121 -0
  37. package/dist/cjs/hooks/useSubscriptions.cjs.map +1 -0
  38. package/dist/cjs/hooks/useSubscriptions.d.cts +36 -0
  39. package/dist/cjs/hooks/useUpdateSubscription.cjs +61 -0
  40. package/dist/cjs/hooks/useUpdateSubscription.cjs.map +1 -0
  41. package/dist/cjs/hooks/useUpdateSubscription.d.cts +18 -0
  42. package/dist/cjs/index.cjs +18 -2
  43. package/dist/cjs/index.cjs.map +1 -1
  44. package/dist/cjs/index.d.cts +14 -3
  45. package/dist/cjs/server/index.cjs +61 -2
  46. package/dist/cjs/server/index.cjs.map +1 -1
  47. package/dist/cjs/server/index.d.cts +18 -4
  48. package/dist/cjs/utils/appearance.cjs.map +1 -1
  49. package/dist/cjs/utils/appearance.d.cts +3 -3
  50. package/dist/cjs/utils/types.cjs.map +1 -1
  51. package/dist/cjs/utils/types.d.cts +32 -11
  52. package/dist/esm/components/Inbox.js +5 -1
  53. package/dist/esm/components/Inbox.js.map +1 -1
  54. package/dist/esm/components/NovuUI.d.ts +9 -9
  55. package/dist/esm/components/NovuUI.js +3 -1
  56. package/dist/esm/components/NovuUI.js.map +1 -1
  57. package/dist/esm/components/index.d.ts +5 -0
  58. package/dist/esm/components/index.js +3 -0
  59. package/dist/esm/components/index.js.map +1 -1
  60. package/dist/esm/components/subscription/DefaultSubscription.d.ts +11 -0
  61. package/dist/esm/components/subscription/DefaultSubscription.js +34 -0
  62. package/dist/esm/components/subscription/DefaultSubscription.js.map +1 -0
  63. package/dist/esm/components/subscription/Subscription.d.ts +22 -0
  64. package/dist/esm/components/subscription/Subscription.js +45 -0
  65. package/dist/esm/components/subscription/Subscription.js.map +1 -0
  66. package/dist/esm/components/subscription/SubscriptionButton.d.ts +8 -0
  67. package/dist/esm/components/subscription/SubscriptionButton.js +56 -0
  68. package/dist/esm/components/subscription/SubscriptionButton.js.map +1 -0
  69. package/dist/esm/components/subscription/SubscriptionPreferences.d.ts +8 -0
  70. package/dist/esm/components/subscription/SubscriptionPreferences.js +56 -0
  71. package/dist/esm/components/subscription/SubscriptionPreferences.js.map +1 -0
  72. package/dist/esm/hooks/NovuProvider.js +22 -19
  73. package/dist/esm/hooks/NovuProvider.js.map +1 -1
  74. package/dist/esm/hooks/index.d.ts +7 -1
  75. package/dist/esm/hooks/index.js +5 -0
  76. package/dist/esm/hooks/index.js.map +1 -1
  77. package/dist/esm/hooks/useCreateSubscription.d.ts +17 -0
  78. package/dist/esm/hooks/useCreateSubscription.js +36 -0
  79. package/dist/esm/hooks/useCreateSubscription.js.map +1 -0
  80. package/dist/esm/hooks/useDeleteSubscription.d.ts +17 -0
  81. package/dist/esm/hooks/useDeleteSubscription.js +36 -0
  82. package/dist/esm/hooks/useDeleteSubscription.js.map +1 -0
  83. package/dist/esm/hooks/useSubscription.d.ts +21 -0
  84. package/dist/esm/hooks/useSubscription.js +129 -0
  85. package/dist/esm/hooks/useSubscription.js.map +1 -0
  86. package/dist/esm/hooks/useSubscriptions.d.ts +36 -0
  87. package/dist/esm/hooks/useSubscriptions.js +96 -0
  88. package/dist/esm/hooks/useSubscriptions.js.map +1 -0
  89. package/dist/esm/hooks/useUpdateSubscription.d.ts +18 -0
  90. package/dist/esm/hooks/useUpdateSubscription.js +36 -0
  91. package/dist/esm/hooks/useUpdateSubscription.js.map +1 -0
  92. package/dist/esm/index.d.ts +14 -3
  93. package/dist/esm/index.js +32 -3
  94. package/dist/esm/index.js.map +1 -1
  95. package/dist/esm/server/index.d.ts +18 -4
  96. package/dist/esm/server/index.js +53 -2
  97. package/dist/esm/server/index.js.map +1 -1
  98. package/dist/esm/utils/appearance.d.ts +3 -3
  99. package/dist/esm/utils/appearance.js.map +1 -1
  100. package/dist/esm/utils/types.d.ts +32 -11
  101. package/package.json +11 -11
package/README.md CHANGED
@@ -34,10 +34,8 @@ import { Inbox } from '@novu/react';
34
34
  function Novu() {
35
35
  return (
36
36
  <Inbox
37
- options={{
38
- subscriber: 'SUBSCRIBER_ID',
39
- applicationIdentifier: 'APPLICATION_IDENTIFIER',
40
- }}
37
+ subscriber='SUBSCRIBER_ID'
38
+ applicationIdentifier='APPLICATION_IDENTIFIER'
41
39
  />
42
40
  );
43
41
  }
@@ -53,12 +51,10 @@ import { Inbox } from '@novu/react';
53
51
  function Novu() {
54
52
  return (
55
53
  <Inbox
56
- options={{
57
- backendUrl: 'YOUR_BACKEND_URL',
58
- socketUrl: 'YOUR_SOCKET_URL',
59
- subscriber: 'SUBSCRIBER_ID',
60
- applicationIdentifier: 'APPLICATION_IDENTIFIER',
61
- }}
54
+ backendUrl='YOUR_BACKEND_URL'
55
+ socketUrl='YOUR_SOCKET_URL'
56
+ subscriber='SUBSCRIBER_ID'
57
+ applicationIdentifier='APPLICATION_IDENTIFIER'
62
58
  />
63
59
  );
64
60
  }
@@ -77,10 +73,8 @@ function Novu() {
77
73
  return (
78
74
  <div>
79
75
  <Inbox
80
- options={{
81
- subscriber: 'SUBSCRIBER_ID',
82
- applicationIdentifier: 'APPLICATION_IDENTIFIER',
83
- }}
76
+ subscriber='SUBSCRIBER_ID'
77
+ applicationIdentifier='APPLICATION_IDENTIFIER'
84
78
  open={isOpen}
85
79
  />
86
80
  <button onClick={() => setOpen(true)}>Open Inbox</button>
@@ -100,10 +94,8 @@ import { Inbox } from '@novu/react';
100
94
  function Novu() {
101
95
  return (
102
96
  <Inbox
103
- options={{
104
- subscriber: 'SUBSCRIBER_ID',
105
- applicationIdentifier: 'APPLICATION_IDENTIFIER',
106
- }}
97
+ subscriber='SUBSCRIBER_ID'
98
+ applicationIdentifier='APPLICATION_IDENTIFIER'
107
99
  localization={{
108
100
  'inbox.status.archived': 'Archived',
109
101
  'inbox.status.unread': 'Unread',
@@ -115,7 +115,10 @@ var DefaultInbox = (props) => {
115
115
  };
116
116
  var Inbox = import_react.default.memo((props) => {
117
117
  const { subscriberId, ...propsWithoutSubscriberId } = props;
118
- const subscriber = (0, import_internal.buildSubscriber)({ subscriberId: props.subscriberId, subscriber: props.subscriber });
118
+ const subscriber = (0, import_react.useMemo)(
119
+ () => (0, import_internal.buildSubscriber)({ subscriberId: props.subscriberId, subscriber: props.subscriber }),
120
+ [props.subscriberId, props.subscriber]
121
+ );
119
122
  const applicationIdentifier = props.applicationIdentifier ? props.applicationIdentifier : "";
120
123
  const novu = (0, import_NovuProvider.useUnsafeNovu)();
121
124
  if (novu) {
@@ -229,6 +232,7 @@ var InboxChild = (0, import_Renderer.withRenderer)(
229
232
  ) });
230
233
  })
231
234
  );
235
+ InboxChild.displayName = "InboxChild";
232
236
  function isWithChildrenProps(props) {
233
237
  return "children" in props;
234
238
  }
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAgC;AAChC,mBAA+B;AAC/B,2BAA0B;AAC1B,6BAA4B;AAC5B,0BAA6D;AAE7D,qBAAwB;AACxB,oBAAuB;AACvB,sBAA6B;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,QAAI,gCAAU;AAC7B,QAAM,EAAE,aAAa,QAAI,oCAAY;AAErC,QAAM,QAAQ,aAAAA,QAAM;AAAA,IAClB,CAAC,YAAyB;AACxB,UAAI,oBAAoB;AACtB,eAAO,OAAO,eAAe;AAAA,UAC3B,MAAM;AAAA,UACN,OAAO;AAAA,YACL;AAAA,YACA,oBAAoB,qBAChB,CAAC,IAAI,iBAAiB,aAAa,IAAI,mBAAmB,YAAY,CAAC,IACvE;AAAA,YACJ,YAAY,aAAa,CAAC,IAAI,gBAAgB,aAAa,IAAI,WAAW,WAAW,CAAC,IAAI;AAAA,YAC1F;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAEA,aAAO,OAAO,eAAe;AAAA,QAC3B,MAAM;AAAA,QACN,OAAO;AAAA,UACL;AAAA,UACA,c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AA,IACF,IAAI;AAEJ,WACE,4CAAC,wBAAO,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":["React"]}
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":";;;;;;;;;;;;;;;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AAAA,QACA;AAAA;AAAA,IACF,GACF;AAAA,EAEJ,CAAC;AACH;AAEA,WAAW,cAAc;AAEzB,SAAS,oBAAoB,OAA+C;AAC1E,SAAO,cAAc;AACvB;","names":["React"]}
@@ -88,6 +88,7 @@ var NovuUI = ({ options, novu, children }) => {
88
88
  novuUI.updateTabs(options.tabs);
89
89
  novuUI.updateOptions(options.options);
90
90
  novuUI.updateRouterPush(options.routerPush);
91
+ novuUI.updateNovu(novu);
91
92
  }, [
92
93
  shadowRootDetector,
93
94
  novuUI,
@@ -95,7 +96,8 @@ var NovuUI = ({ options, novu, children }) => {
95
96
  options.localization,
96
97
  options.tabs,
97
98
  options.options,
98
- options.routerPush
99
+ options.routerPush,
100
+ novu
99
101
  ]);
100
102
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
101
103
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ShadowRootDetector.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 { ReactAppearance } from '../utils/types';\nimport { ShadowRootDetector } from './ShadowRootDetector';\n\ntype NovuUIProps = Omit<JsNovuUIOptions, 'appearance'> & {\n appearance?: ReactAppearance;\n};\n\ntype RendererProps = React.PropsWithChildren<{\n options: NovuUIProps;\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 }: RendererProps) => {\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 }, [\n shadowRootDetector,\n novuUI,\n adaptedAppearanceForUpdate,\n options.localization,\n options.tabs,\n options.options,\n options.routerPush,\n ]);\n\n return (\n <>\n <ShadowRootDetector ref={shadowRootDetector} />\n {novuUI && <NovuUIProvider value={{ novuUI }}>{children}</NovuUIProvider>}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gBAAsC;AACtC,mBAA4D;AAC5D,2BAA+B;AAC/B,6BAA4B;AAC5B,wBAA2B;AAC3B,wBAAqC;AAErC,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AO,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;AAAA,EAC5C,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,CAAC;AAED,SACE,4EACE;AAAA,gDAAC,gDAAmB,KAAK,oBAAoB;AAAA,IAC5C,UAAU,4CAAC,uCAAe,OAAO,EAAE,OAAO,GAAI,UAAS;AAAA,KAC1D;AAEJ;","names":["NovuUIClass"]}
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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gBAAsC;AACtC,mBAA4D;AAC5D,2BAA+B;AAC/B,6BAA4B;AAC5B,wBAA2B;AAC3B,wBAAqC;AAErC,gCAAmC;AA+F/B;AApFJ,IAAM,uBAAuB,CAAC,UAA+C;AAC3E,MAAI,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ClD,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,4EACE;AAAA,gDAAC,gDAAmB,KAAK,oBAAoB;AAAA,IAC5C,UAAU,4CAAC,uCAAe,OAAO,EAAE,OAAO,GAAI,UAAS;AAAA,KAC1D;AAEJ;","names":["NovuUIClass"]}
@@ -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 { ReactAppearance } from '../utils/types.cjs';
5
+ import { ReactInboxAppearance, ReactSubscriptionAppearance } from '../utils/types.cjs';
6
6
 
7
- type NovuUIProps = Omit<NovuUIOptions, 'appearance'> & {
8
- appearance?: ReactAppearance;
7
+ type NovuUIOptions = Omit<NovuUIOptions$1, 'appearance'> & {
8
+ appearance?: ReactInboxAppearance | ReactSubscriptionAppearance;
9
9
  };
10
- type RendererProps = React__default.PropsWithChildren<{
11
- options: NovuUIProps;
12
- novu?: Novu;
10
+ type NovuUIProps = React__default.PropsWithChildren<{
11
+ options: NovuUIOptions;
12
+ novu: Novu;
13
13
  }>;
14
- declare const NovuUI: ({ options, novu, children }: RendererProps) => react_jsx_runtime.JSX.Element;
14
+ declare const NovuUI: ({ options, novu, children }: NovuUIProps) => react_jsx_runtime.JSX.Element;
15
15
 
16
- export { NovuUI };
16
+ export { NovuUI, type NovuUIOptions };
@@ -23,6 +23,9 @@ __reExport(components_exports, require("./Inbox.cjs"), module.exports);
23
23
  __reExport(components_exports, require("./InboxContent.cjs"), module.exports);
24
24
  __reExport(components_exports, require("./Notifications.cjs"), module.exports);
25
25
  __reExport(components_exports, require("./Preferences.cjs"), module.exports);
26
+ __reExport(components_exports, require("./subscription/Subscription.cjs"), module.exports);
27
+ __reExport(components_exports, require("./subscription/SubscriptionButton.cjs"), module.exports);
28
+ __reExport(components_exports, require("./subscription/SubscriptionPreferences.cjs"), module.exports);
26
29
  // Annotate the CommonJS export names for ESM import in node:
27
30
  0 && (module.exports = {
28
31
  ...require("../hooks/NovuProvider.cjs"),
@@ -30,6 +33,9 @@ __reExport(components_exports, require("./Preferences.cjs"), module.exports);
30
33
  ...require("./Inbox.cjs"),
31
34
  ...require("./InboxContent.cjs"),
32
35
  ...require("./Notifications.cjs"),
33
- ...require("./Preferences.cjs")
36
+ ...require("./Preferences.cjs"),
37
+ ...require("./subscription/Subscription.cjs"),
38
+ ...require("./subscription/SubscriptionButton.cjs"),
39
+ ...require("./subscription/SubscriptionPreferences.cjs")
34
40
  });
35
41
  //# sourceMappingURL=index.cjs.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;AAAA;AAAA,+BAAc,sCAAd;AACA,+BAAc,uBADd;AAEA,+BAAc,wBAFd;AAGA,+BAAc,+BAHd;AAIA,+BAAc,gCAJd;AAKA,+BAAc,8BALd;","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;AAAA;AAAA,+BAAc,sCAAd;AACA,+BAAc,uBADd;AAEA,+BAAc,wBAFd;AAGA,+BAAc,+BAHd;AAIA,+BAAc,gCAJd;AAKA,+BAAc,8BALd;AAMA,+BAAc,4CANd;AAOA,+BAAc,kDAPd;AAQA,+BAAc,uDARd;","names":[]}
@@ -4,8 +4,13 @@ export { Inbox, InboxProps } from './Inbox.cjs';
4
4
  export { InboxContent, InboxContentProps } from './InboxContent.cjs';
5
5
  export { NotificationProps, Notifications } from './Notifications.cjs';
6
6
  export { Preferences } from './Preferences.cjs';
7
+ export { Subscription, SubscriptionProps } from './subscription/Subscription.cjs';
8
+ export { SubscriptionButton, SubscriptionButtonProps } from './subscription/SubscriptionButton.cjs';
9
+ export { SubscriptionPreferences, SubscriptionPreferencesProps } from './subscription/SubscriptionPreferences.cjs';
7
10
  import 'react/jsx-runtime';
8
11
  import '@novu/js';
9
12
  import 'react';
10
13
  import '../utils/types.cjs';
11
14
  import '@novu/js/ui';
15
+ import './NovuUI.cjs';
16
+ import './subscription/DefaultSubscription.cjs';
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/components/subscription/DefaultSubscription.tsx
21
+ var DefaultSubscription_exports = {};
22
+ __export(DefaultSubscription_exports, {
23
+ DefaultSubscription: () => DefaultSubscription
24
+ });
25
+ module.exports = __toCommonJS(DefaultSubscription_exports);
26
+ var import_react = require("react");
27
+ var import_NovuUIContext = require("../../context/NovuUIContext.cjs");
28
+ var import_RendererContext = require("../../context/RendererContext.cjs");
29
+ var import_Mounter = require("../Mounter.cjs");
30
+ var import_jsx_runtime = require("react/jsx-runtime");
31
+ var DefaultSubscription = (props) => {
32
+ const { topicKey, identifier, preferences, open, placement, placementOffset, renderPreferences } = props;
33
+ const { novuUI } = (0, import_NovuUIContext.useNovuUI)();
34
+ const { mountElement } = (0, import_RendererContext.useRenderer)();
35
+ const mount = (0, import_react.useCallback)(
36
+ (element) => {
37
+ return novuUI.mountComponent({
38
+ name: "Subscription",
39
+ props: {
40
+ topicKey,
41
+ identifier,
42
+ preferences,
43
+ open,
44
+ placementOffset,
45
+ placement,
46
+ renderPreferences: renderPreferences ? (el, subscription, loading) => mountElement(el, renderPreferences(subscription, loading)) : void 0
47
+ },
48
+ element
49
+ });
50
+ },
51
+ [topicKey, identifier, preferences, open, placementOffset, placement, renderPreferences, novuUI, mountElement]
52
+ );
53
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Mounter.Mounter, { mount });
54
+ };
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ DefaultSubscription
58
+ });
59
+ //# sourceMappingURL=DefaultSubscription.cjs.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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA4B;AAC5B,2BAA0B;AAC1B,6BAA4B;AAC5B,qBAAwB;AAkCf;AA1BF,IAAM,sBAAsB,CAAC,UAAoC;AACtE,QAAM,EAAE,UAAU,YAAY,aAAa,MAAM,WAAW,iBAAiB,kBAAkB,IAAI;AACnG,QAAM,EAAE,OAAO,QAAI,gCAAU;AAC7B,QAAM,EAAE,aAAa,QAAI,oCAAY;AAErC,QAAM,YAAQ;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,4CAAC,0BAAQ,OAAc;AAChC;","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,80 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/components/subscription/Subscription.tsx
31
+ var Subscription_exports = {};
32
+ __export(Subscription_exports, {
33
+ Subscription: () => Subscription
34
+ });
35
+ module.exports = __toCommonJS(Subscription_exports);
36
+ var import_react = __toESM(require("react"), 1);
37
+ var import_NovuProvider = require("../../hooks/NovuProvider.cjs");
38
+ var import_NovuUI = require("../NovuUI.cjs");
39
+ var import_Renderer = require("../Renderer.cjs");
40
+ var import_DefaultSubscription = require("./DefaultSubscription.cjs");
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ var SubscriptionInternal = (0, import_Renderer.withRenderer)((props) => {
43
+ const { container, localization, appearance, ...defaultSubscriptionProps } = props;
44
+ const novu = (0, import_NovuProvider.useNovu)();
45
+ const options = (0, import_react.useMemo)(() => {
46
+ return {
47
+ container,
48
+ localization,
49
+ appearance,
50
+ options: novu.options
51
+ };
52
+ }, [localization, appearance, container, novu.options]);
53
+ if (isWithChildrenProps(props)) {
54
+ const clonedChildren = import_react.default.Children.map(props.children, (child) => {
55
+ if (import_react.default.isValidElement(child)) {
56
+ return import_react.default.cloneElement(child, {
57
+ ...child.props,
58
+ topicKey: defaultSubscriptionProps.topicKey,
59
+ identifier: defaultSubscriptionProps.identifier,
60
+ preferences: defaultSubscriptionProps.preferences
61
+ });
62
+ }
63
+ return child;
64
+ });
65
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_NovuUI.NovuUI, { options, novu, children: clonedChildren });
66
+ }
67
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_NovuUI.NovuUI, { options, novu, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DefaultSubscription.DefaultSubscription, { ...defaultSubscriptionProps }) });
68
+ });
69
+ SubscriptionInternal.displayName = "SubscriptionInternal";
70
+ var Subscription = import_react.default.memo((props) => {
71
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubscriptionInternal, { ...props });
72
+ });
73
+ function isWithChildrenProps(props) {
74
+ return "children" in props;
75
+ }
76
+ // Annotate the CommonJS export names for ESM import in node:
77
+ 0 && (module.exports = {
78
+ Subscription
79
+ });
80
+ //# sourceMappingURL=Subscription.cjs.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA+B;AAC/B,0BAAwB;AAExB,oBAAsC;AACtC,sBAA6B;AAC7B,iCAA8D;AA+CxD;AA5BN,IAAM,2BAAuB,8BAAgC,CAAC,UAAU;AACtE,QAAM,EAAE,WAAW,cAAc,YAAY,GAAG,yBAAyB,IAAI;AAC7E,QAAM,WAAO,6BAAQ;AAErB,QAAM,cAAyB,sBAAQ,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,aAAAA,QAAM,SAAS,IAAI,MAAM,UAAU,CAAC,UAAU;AACnE,UAAI,aAAAA,QAAM,eAAe,KAAK,GAAG;AAC/B,eAAO,aAAAA,QAAM,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,4CAAC,wBAAO,SAAkB,MACvB,0BACH;AAAA,EAEJ;AAEA,SACE,4CAAC,wBAAO,SAAkB,MACxB,sDAAC,kDAAqB,GAAG,0BAA0B,GACrD;AAEJ,CAAC;AAED,qBAAqB,cAAc;AAE5B,IAAM,eAAe,aAAAA,QAAM,KAAK,CAAC,UAA6B;AACnE,SAAO,4CAAC,wBAAsB,GAAG,OAAO;AAC1C,CAAC;AAED,SAAS,oBAAoB,OAAkE;AAC7F,SAAO,cAAc;AACvB;","names":["React"]}
@@ -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.cjs';
5
+ import { NovuUIOptions } from '../NovuUI.cjs';
6
+ import { DefaultSubscriptionProps } from './DefaultSubscription.cjs';
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,91 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/components/subscription/SubscriptionButton.tsx
31
+ var SubscriptionButton_exports = {};
32
+ __export(SubscriptionButton_exports, {
33
+ SubscriptionButton: () => SubscriptionButton
34
+ });
35
+ module.exports = __toCommonJS(SubscriptionButton_exports);
36
+ var import_react = __toESM(require("react"), 1);
37
+ var import_NovuUIContext = require("../../context/NovuUIContext.cjs");
38
+ var import_Mounter = require("../Mounter.cjs");
39
+ var import_jsx_runtime = require("react/jsx-runtime");
40
+ var SubscriptionButton = import_react.default.memo(
41
+ ({
42
+ topicKey,
43
+ identifier,
44
+ preferences,
45
+ onClick,
46
+ onDeleteError,
47
+ onDeleteSuccess,
48
+ onCreateError,
49
+ onCreateSuccess
50
+ }) => {
51
+ const { novuUI } = (0, import_NovuUIContext.useNovuUI)();
52
+ const mount = import_react.default.useCallback(
53
+ (element) => {
54
+ if (!topicKey || !preferences) {
55
+ return;
56
+ }
57
+ return novuUI.mountComponent({
58
+ name: "SubscriptionButton",
59
+ element,
60
+ props: {
61
+ topicKey,
62
+ identifier,
63
+ preferences,
64
+ onClick,
65
+ onDeleteError,
66
+ onDeleteSuccess,
67
+ onCreateError,
68
+ onCreateSuccess
69
+ }
70
+ });
71
+ },
72
+ [
73
+ novuUI,
74
+ topicKey,
75
+ identifier,
76
+ preferences,
77
+ onClick,
78
+ onDeleteError,
79
+ onDeleteSuccess,
80
+ onCreateError,
81
+ onCreateSuccess
82
+ ]
83
+ );
84
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Mounter.Mounter, { mount });
85
+ }
86
+ );
87
+ // Annotate the CommonJS export names for ESM import in node:
88
+ 0 && (module.exports = {
89
+ SubscriptionButton
90
+ });
91
+ //# sourceMappingURL=SubscriptionButton.cjs.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 || !preferences) {\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,2BAA0B;AAC1B,qBAAwB;AAmDb;AA/CJ,IAAM,qBAAqB,aAAAA,QAAM;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,QAAI,gCAAU;AAE7B,UAAM,QAAQ,aAAAA,QAAM;AAAA,MAClB,CAAC,YAAyB;AACxB,YAAI,CAAC,YAAY,CAAC,aAAa;AAC7B;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,4CAAC,0BAAQ,OAAc;AAAA,EAChC;AACF;","names":["React"]}
@@ -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,91 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/components/subscription/SubscriptionPreferences.tsx
31
+ var SubscriptionPreferences_exports = {};
32
+ __export(SubscriptionPreferences_exports, {
33
+ SubscriptionPreferences: () => SubscriptionPreferences
34
+ });
35
+ module.exports = __toCommonJS(SubscriptionPreferences_exports);
36
+ var import_react = __toESM(require("react"), 1);
37
+ var import_NovuUIContext = require("../../context/NovuUIContext.cjs");
38
+ var import_Mounter = require("../Mounter.cjs");
39
+ var import_jsx_runtime = require("react/jsx-runtime");
40
+ var SubscriptionPreferences = import_react.default.memo(
41
+ ({
42
+ topicKey,
43
+ identifier,
44
+ preferences,
45
+ onClick,
46
+ onDeleteError,
47
+ onDeleteSuccess,
48
+ onCreateError,
49
+ onCreateSuccess
50
+ }) => {
51
+ const { novuUI } = (0, import_NovuUIContext.useNovuUI)();
52
+ const mount = import_react.default.useCallback(
53
+ (element) => {
54
+ if (!topicKey || !preferences) {
55
+ return;
56
+ }
57
+ return novuUI.mountComponent({
58
+ name: "SubscriptionPreferences",
59
+ element,
60
+ props: {
61
+ topicKey,
62
+ identifier,
63
+ preferences,
64
+ onClick,
65
+ onDeleteError,
66
+ onDeleteSuccess,
67
+ onCreateError,
68
+ onCreateSuccess
69
+ }
70
+ });
71
+ },
72
+ [
73
+ novuUI,
74
+ topicKey,
75
+ identifier,
76
+ preferences,
77
+ onClick,
78
+ onDeleteError,
79
+ onDeleteSuccess,
80
+ onCreateError,
81
+ onCreateSuccess
82
+ ]
83
+ );
84
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Mounter.Mounter, { mount });
85
+ }
86
+ );
87
+ // Annotate the CommonJS export names for ESM import in node:
88
+ 0 && (module.exports = {
89
+ SubscriptionPreferences
90
+ });
91
+ //# sourceMappingURL=SubscriptionPreferences.cjs.map