@novu/react 3.9.2 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Inbox.cjs +9 -3
- package/dist/cjs/components/Inbox.cjs.map +1 -1
- package/dist/cjs/hooks/NovuProvider.cjs +14 -3
- package/dist/cjs/hooks/NovuProvider.cjs.map +1 -1
- package/dist/cjs/hooks/index.cjs +3 -1
- package/dist/cjs/hooks/index.cjs.map +1 -1
- package/dist/cjs/hooks/index.d.cts +1 -0
- package/dist/cjs/hooks/useSchedule.cjs +80 -0
- package/dist/cjs/hooks/useSchedule.cjs.map +1 -0
- package/dist/cjs/hooks/useSchedule.d.cts +16 -0
- package/dist/cjs/index.cjs +4 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -1
- package/dist/cjs/server/index.cjs +11 -2
- package/dist/cjs/server/index.cjs.map +1 -1
- package/dist/cjs/server/index.d.cts +3 -1
- package/dist/cjs/utils/types.cjs.map +1 -1
- package/dist/cjs/utils/types.d.cts +4 -2
- package/dist/esm/components/Inbox.js +9 -3
- package/dist/esm/components/Inbox.js.map +1 -1
- package/dist/esm/hooks/NovuProvider.js +14 -3
- package/dist/esm/hooks/NovuProvider.js.map +1 -1
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/useSchedule.d.ts +16 -0
- package/dist/esm/hooks/useSchedule.js +55 -0
- package/dist/esm/hooks/useSchedule.js.map +1 -0
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +3 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/server/index.d.ts +3 -1
- package/dist/esm/server/index.js +9 -1
- package/dist/esm/server/index.js.map +1 -1
- package/dist/esm/utils/types.d.ts +4 -2
- package/package.json +2 -2
|
@@ -126,7 +126,8 @@ var Inbox = import_react.default.memo((props) => {
|
|
|
126
126
|
subscriberHash: props.subscriberHash,
|
|
127
127
|
backendUrl: props.backendUrl,
|
|
128
128
|
socketUrl: props.socketUrl,
|
|
129
|
-
subscriber
|
|
129
|
+
subscriber,
|
|
130
|
+
defaultSchedule: props.defaultSchedule
|
|
130
131
|
};
|
|
131
132
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_NovuProvider.InternalNovuProvider, { ...providerProps, userAgentType: "components", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InboxChild, { ...propsWithoutSubscriberId, applicationIdentifier, subscriber }) });
|
|
132
133
|
});
|
|
@@ -138,6 +139,7 @@ var InboxChild = (0, import_Renderer.withRenderer)(
|
|
|
138
139
|
tabs,
|
|
139
140
|
preferencesFilter,
|
|
140
141
|
preferenceGroups,
|
|
142
|
+
preferencesSort,
|
|
141
143
|
routerPush,
|
|
142
144
|
applicationIdentifier = "",
|
|
143
145
|
// for keyless we provide an empty string, the api will generate a identifier
|
|
@@ -145,7 +147,8 @@ var InboxChild = (0, import_Renderer.withRenderer)(
|
|
|
145
147
|
subscriberHash,
|
|
146
148
|
backendUrl,
|
|
147
149
|
socketUrl,
|
|
148
|
-
subscriber
|
|
150
|
+
subscriber,
|
|
151
|
+
defaultSchedule
|
|
149
152
|
} = props;
|
|
150
153
|
const novu = (0, import_NovuProvider.useNovu)();
|
|
151
154
|
const options = (0, import_react.useMemo)(() => {
|
|
@@ -155,13 +158,15 @@ var InboxChild = (0, import_Renderer.withRenderer)(
|
|
|
155
158
|
tabs,
|
|
156
159
|
preferencesFilter,
|
|
157
160
|
preferenceGroups,
|
|
161
|
+
preferencesSort,
|
|
158
162
|
routerPush,
|
|
159
163
|
options: {
|
|
160
164
|
applicationIdentifier,
|
|
161
165
|
subscriberHash,
|
|
162
166
|
backendUrl,
|
|
163
167
|
socketUrl,
|
|
164
|
-
subscriber: (0, import_internal.buildSubscriber)({ subscriberId, subscriber })
|
|
168
|
+
subscriber: (0, import_internal.buildSubscriber)({ subscriberId, subscriber }),
|
|
169
|
+
defaultSchedule
|
|
165
170
|
}
|
|
166
171
|
};
|
|
167
172
|
}, [
|
|
@@ -170,6 +175,7 @@ var InboxChild = (0, import_Renderer.withRenderer)(
|
|
|
170
175
|
tabs,
|
|
171
176
|
preferencesFilter,
|
|
172
177
|
preferenceGroups,
|
|
178
|
+
preferencesSort,
|
|
173
179
|
applicationIdentifier,
|
|
174
180
|
subscriberId,
|
|
175
181
|
subscriberHash,
|
|
@@ -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 backendUrl: props.backendUrl,\n socketUrl: props.socketUrl,\n subscriber,\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 routerPush,\n applicationIdentifier = '', // for keyless we provide an empty string, the api will generate a identifier\n subscriberId,\n subscriberHash,\n backendUrl,\n socketUrl,\n subscriber,\n } = props;\n const novu = useNovu();\n\n const options = useMemo(() => {\n return {\n localization,\n appearance,\n tabs,\n preferencesFilter,\n preferenceGroups,\n routerPush,\n options: {\n applicationIdentifier,\n subscriberHash,\n backendUrl,\n socketUrl,\n subscriber: buildSubscriber({ subscriberId, subscriber }),\n },\n };\n }, [\n localization,\n appearance,\n tabs,\n preferencesFilter,\n preferenceGroups,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n socketUrl,\n subscriber,\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;AAA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A;AAAA,QACA,SAAS;AAAA,UACP;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,gBAAY,iCAAgB,EAAE,cAAc,WAAW,CAAC;AAAA,QAC1D;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,IACF,CAAC;AAED,QAAI,oBAAoB,KAAK,GAAG;AAC9B,aACE,4CAAC,wBAAO,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,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 = 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 backendUrl: props.backendUrl,\n socketUrl: props.socketUrl,\n subscriber,\n defaultSchedule: props.defaultSchedule,\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 backendUrl,\n socketUrl,\n subscriber,\n defaultSchedule,\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 backendUrl,\n socketUrl,\n subscriber: buildSubscriber({ subscriberId, subscriber }),\n defaultSchedule,\n },\n };\n }, [\n localization,\n appearance,\n tabs,\n preferencesFilter,\n preferenceGroups,\n preferencesSort,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n socketUrl,\n subscriber,\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,Y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AAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,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"]}
|
|
@@ -30,7 +30,7 @@ var import_js = require("@novu/js");
|
|
|
30
30
|
var import_internal = require("@novu/js/internal");
|
|
31
31
|
var import_react = require("react");
|
|
32
32
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
-
var version = "3.
|
|
33
|
+
var version = "3.10.0";
|
|
34
34
|
var name = "@novu/react";
|
|
35
35
|
var baseUserAgent = `${name}@${version}`;
|
|
36
36
|
var NovuContext = (0, import_react.createContext)(void 0);
|
|
@@ -48,7 +48,17 @@ var NovuProvider = (props) => {
|
|
|
48
48
|
var InternalNovuProvider = (props) => {
|
|
49
49
|
const applicationIdentifier = props.applicationIdentifier || "";
|
|
50
50
|
const subscriberObj = (0, import_internal.buildSubscriber)({ subscriberId: props.subscriberId, subscriber: props.subscriber });
|
|
51
|
-
const {
|
|
51
|
+
const {
|
|
52
|
+
children,
|
|
53
|
+
subscriberId,
|
|
54
|
+
subscriberHash,
|
|
55
|
+
backendUrl,
|
|
56
|
+
apiUrl,
|
|
57
|
+
socketUrl,
|
|
58
|
+
useCache,
|
|
59
|
+
userAgentType,
|
|
60
|
+
defaultSchedule
|
|
61
|
+
} = props;
|
|
52
62
|
const novu = (0, import_react.useMemo)(
|
|
53
63
|
() => new import_js.Novu({
|
|
54
64
|
applicationIdentifier,
|
|
@@ -58,7 +68,8 @@ var InternalNovuProvider = (props) => {
|
|
|
58
68
|
socketUrl,
|
|
59
69
|
useCache,
|
|
60
70
|
__userAgent: `${baseUserAgent} ${userAgentType}`,
|
|
61
|
-
subscriber: subscriberObj
|
|
71
|
+
subscriber: subscriberObj,
|
|
72
|
+
defaultSchedule
|
|
62
73
|
}),
|
|
63
74
|
[applicationIdentifier, subscriberHash, backendUrl, apiUrl, socketUrl, useCache, userAgentType]
|
|
64
75
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/NovuProvider.tsx"],"sourcesContent":["import { Novu, NovuOptions } from '@novu/js';\nimport { buildSubscriber } from '@novu/js/internal';\nimport { createContext, ReactNode, useContext, useEffect, useMemo } from 'react';\n\n// @ts-
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/NovuProvider.tsx"],"sourcesContent":["import { Novu, NovuOptions } from '@novu/js';\nimport { buildSubscriber } from '@novu/js/internal';\nimport { createContext, ReactNode, useContext, useEffect, useMemo } from 'react';\n\n// @ts-expect-error\nconst version = PACKAGE_VERSION;\n// @ts-expect-error\nconst name = PACKAGE_NAME;\nconst baseUserAgent = `${name}@${version}`;\n\nexport type NovuProviderProps = NovuOptions & {\n children: ReactNode;\n};\n\nconst NovuContext = createContext<Novu | undefined>(undefined);\n\nexport const NovuProvider = (props: NovuProviderProps) => {\n const { subscriberId, ...propsWithoutSubscriberId } = props;\n const subscriberObj = buildSubscriber({ subscriberId, subscriber: props.subscriber });\n const applicationIdentifier = propsWithoutSubscriberId.applicationIdentifier\n ? propsWithoutSubscriberId.applicationIdentifier\n : '';\n\n const providerProps: NovuProviderProps = {\n ...propsWithoutSubscriberId,\n applicationIdentifier,\n subscriber: subscriberObj,\n };\n\n return (\n <InternalNovuProvider {...providerProps} applicationIdentifier={applicationIdentifier} userAgentType=\"hooks\">\n {props.children}\n </InternalNovuProvider>\n );\n};\n\n/**\n * @internal Should be used internally not to be exposed outside of the library\n * This is needed to differentiate between the hooks and components user agents\n * Better to use this internally to avoid confusion.\n */\nexport const InternalNovuProvider = (props: NovuProviderProps & { userAgentType: 'components' | 'hooks' }) => {\n const applicationIdentifier = props.applicationIdentifier || '';\n const subscriberObj = buildSubscriber({ subscriberId: props.subscriberId, subscriber: props.subscriber });\n\n const {\n children,\n subscriberId,\n subscriberHash,\n backendUrl,\n apiUrl,\n socketUrl,\n useCache,\n userAgentType,\n defaultSchedule,\n } = props;\n\n const novu = useMemo(\n () =>\n new Novu({\n applicationIdentifier,\n subscriberHash,\n backendUrl,\n apiUrl,\n socketUrl,\n useCache,\n __userAgent: `${baseUserAgent} ${userAgentType}`,\n subscriber: subscriberObj,\n defaultSchedule,\n }),\n [applicationIdentifier, subscriberHash, backendUrl, apiUrl, socketUrl, useCache, userAgentType]\n );\n\n useEffect(() => {\n novu.changeSubscriber({\n subscriber: subscriberObj,\n subscriberHash: props.subscriberHash,\n });\n }, [subscriberObj.subscriberId, props.subscriberHash, novu]);\n\n return <NovuContext.Provider value={novu}>{children}</NovuContext.Provider>;\n};\n\nexport const useNovu = () => {\n const context = useContext(NovuContext);\n if (!context) {\n throw new Error('useNovu must be used within a <NovuProvider />');\n }\n\n return context;\n};\n\nexport const useUnsafeNovu = () => {\n const context = useContext(NovuContext);\n\n return context;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAkC;AAClC,sBAAgC;AAChC,mBAAyE;AA4BrE;AAzBJ,IAAM,UAAU;AAEhB,IAAM,OAAO;AACb,IAAM,gBAAgB,GAAG,IAAI,IAAI,OAAO;AAMxC,IAAM,kBAAc,4BAAgC,MAAS;AAEtD,IAAM,eAAe,CAAC,UAA6B;AACxD,QAAM,EAAE,cAAc,GAAG,yBAAyB,IAAI;AACtD,QAAM,oBAAgB,iCAAgB,EAAE,cAAc,YAAY,MAAM,WAAW,CAAC;AACpF,QAAM,wBAAwB,yBAAyB,wBACnD,yBAAyB,wBACzB;AAEJ,QAAM,gBAAmC;AAAA,IACvC,GAAG;AAAA,IACH;AAAA,IACA,YAAY;AAAA,EACd;AAEA,SACE,4CAAC,wBAAsB,GAAG,eAAe,uBAA8C,eAAc,SAClG,gBAAM,UACT;AAEJ;AAOO,IAAM,uBAAuB,CAAC,UAAyE;AAC5G,QAAM,wBAAwB,MAAM,yBAAyB;AAC7D,QAAM,oBAAgB,iCAAgB,EAAE,cAAc,MAAM,cAAc,YAAY,MAAM,WAAW,CAAC;AAExG,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,WAAO;AAAA,IACX,MACE,IAAI,eAAK;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa,GAAG,aAAa,IAAI,aAAa;AAAA,MAC9C,YAAY;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,IACH,CAAC,uBAAuB,gBAAgB,YAAY,QAAQ,WAAW,UAAU,aAAa;AAAA,EAChG;AAEA,8BAAU,MAAM;AACd,SAAK,iBAAiB;AAAA,MACpB,YAAY;AAAA,MACZ,gBAAgB,MAAM;AAAA,IACxB,CAAC;AAAA,EACH,GAAG,CAAC,cAAc,cAAc,MAAM,gBAAgB,IAAI,CAAC;AAE3D,SAAO,4CAAC,YAAY,UAAZ,EAAqB,OAAO,MAAO,UAAS;AACtD;AAEO,IAAM,UAAU,MAAM;AAC3B,QAAM,cAAU,yBAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AAEA,SAAO;AACT;AAEO,IAAM,gBAAgB,MAAM;AACjC,QAAM,cAAU,yBAAW,WAAW;AAEtC,SAAO;AACT;","names":[]}
|
package/dist/cjs/hooks/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ var import_NovuProvider = require("./NovuProvider.cjs");
|
|
|
33
33
|
__reExport(hooks_exports, require("./useCounts.cjs"), module.exports);
|
|
34
34
|
__reExport(hooks_exports, require("./useNotifications.cjs"), module.exports);
|
|
35
35
|
__reExport(hooks_exports, require("./usePreferences.cjs"), module.exports);
|
|
36
|
+
__reExport(hooks_exports, require("./useSchedule.cjs"), module.exports);
|
|
36
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
38
|
0 && (module.exports = {
|
|
38
39
|
NovuProvider,
|
|
@@ -42,6 +43,7 @@ __reExport(hooks_exports, require("./usePreferences.cjs"), module.exports);
|
|
|
42
43
|
useNovu,
|
|
43
44
|
...require("./useCounts.cjs"),
|
|
44
45
|
...require("./useNotifications.cjs"),
|
|
45
|
-
...require("./usePreferences.cjs")
|
|
46
|
+
...require("./usePreferences.cjs"),
|
|
47
|
+
...require("./useSchedule.cjs")
|
|
46
48
|
});
|
|
47
49
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export type {\n ChannelPreference,\n ChannelType,\n EventHandler,\n Events,\n FiltersCountResponse,\n InboxNotification,\n ListNotificationsResponse,\n Notification,\n NotificationFilter,\n NotificationStatus,\n NovuError,\n NovuOptions,\n Preference,\n PreferencesResponse,\n SocketEventNames,\n UnreadCount,\n WebSocketEvent,\n} from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\nexport { NovuProvider, useNovu } from './NovuProvider';\nexport * from './useCounts';\nexport * from './useNotifications';\nexport * from './usePreferences';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBA,gBAA4E;AAC5E,0BAAsC;AACtC,0BAAc,4BArBd;AAsBA,0BAAc,mCAtBd;AAuBA,0BAAc,iCAvBd;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export type {\n ChannelPreference,\n ChannelType,\n EventHandler,\n Events,\n FiltersCountResponse,\n InboxNotification,\n ListNotificationsResponse,\n Notification,\n NotificationFilter,\n NotificationStatus,\n NovuError,\n NovuOptions,\n Preference,\n PreferencesResponse,\n SocketEventNames,\n UnreadCount,\n WebSocketEvent,\n} from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\nexport { NovuProvider, useNovu } from './NovuProvider';\nexport * from './useCounts';\nexport * from './useNotifications';\nexport * from './usePreferences';\nexport * from './useSchedule';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBA,gBAA4E;AAC5E,0BAAsC;AACtC,0BAAc,4BArBd;AAsBA,0BAAc,mCAtBd;AAuBA,0BAAc,iCAvBd;AAwBA,0BAAc,8BAxBd;","names":[]}
|
|
@@ -3,5 +3,6 @@ export { NovuProvider, useNovu } from './NovuProvider.cjs';
|
|
|
3
3
|
export { UseCountsProps, UseCountsResult, useCounts } from './useCounts.cjs';
|
|
4
4
|
export { UseNotificationsProps, UseNotificationsResult, useNotifications } from './useNotifications.cjs';
|
|
5
5
|
export { UsePreferencesProps, UsePreferencesResult, usePreferences } from './usePreferences.cjs';
|
|
6
|
+
export { UseScheduleProps, UseScheduleResult, useSchedule } from './useSchedule.cjs';
|
|
6
7
|
import 'react/jsx-runtime';
|
|
7
8
|
import 'react';
|
|
@@ -0,0 +1,80 @@
|
|
|
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/hooks/useSchedule.ts
|
|
21
|
+
var useSchedule_exports = {};
|
|
22
|
+
__export(useSchedule_exports, {
|
|
23
|
+
useSchedule: () => useSchedule
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useSchedule_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_NovuProvider = require("./NovuProvider.cjs");
|
|
28
|
+
var useSchedule = (props) => {
|
|
29
|
+
const { onSuccess, onError } = props || {};
|
|
30
|
+
const [data, setData] = (0, import_react.useState)();
|
|
31
|
+
const { preferences, on } = (0, import_NovuProvider.useNovu)();
|
|
32
|
+
const [error, setError] = (0, import_react.useState)();
|
|
33
|
+
const [isLoading, setIsLoading] = (0, import_react.useState)(true);
|
|
34
|
+
const [isFetching, setIsFetching] = (0, import_react.useState)(false);
|
|
35
|
+
const sync = (event) => {
|
|
36
|
+
if (!event.data) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
setData(event.data);
|
|
40
|
+
};
|
|
41
|
+
(0, import_react.useEffect)(() => {
|
|
42
|
+
fetchSchedule();
|
|
43
|
+
const listUpdatedCleanup = on("preference.schedule.get.updated", sync);
|
|
44
|
+
const listPendingCleanup = on("preference.schedule.get.pending", sync);
|
|
45
|
+
const listResolvedCleanup = on("preference.schedule.get.resolved", sync);
|
|
46
|
+
return () => {
|
|
47
|
+
listUpdatedCleanup();
|
|
48
|
+
listPendingCleanup();
|
|
49
|
+
listResolvedCleanup();
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
52
|
+
const fetchSchedule = async () => {
|
|
53
|
+
setIsFetching(true);
|
|
54
|
+
const response = await preferences.schedule.get();
|
|
55
|
+
if (response.error) {
|
|
56
|
+
setError(response.error);
|
|
57
|
+
onError == null ? void 0 : onError(response.error);
|
|
58
|
+
} else {
|
|
59
|
+
onSuccess == null ? void 0 : onSuccess(response.data);
|
|
60
|
+
}
|
|
61
|
+
setIsLoading(false);
|
|
62
|
+
setIsFetching(false);
|
|
63
|
+
};
|
|
64
|
+
const refetch = () => {
|
|
65
|
+
preferences.schedule.cache.clearAll();
|
|
66
|
+
return fetchSchedule();
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
schedule: data,
|
|
70
|
+
error,
|
|
71
|
+
isLoading,
|
|
72
|
+
isFetching,
|
|
73
|
+
refetch
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
useSchedule
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=useSchedule.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useSchedule.ts"],"sourcesContent":["import { NovuError, Schedule } from '@novu/js';\nimport { useEffect, useState } from 'react';\nimport { useNovu } from './NovuProvider';\n\nexport type UseScheduleProps = {\n onSuccess?: (data: Schedule) => void;\n onError?: (error: NovuError) => void;\n};\n\nexport type UseScheduleResult = {\n schedule?: Schedule;\n error?: NovuError;\n isLoading: boolean; // initial loading\n isFetching: boolean; // the request is in flight\n refetch: () => Promise<void>;\n};\n\nexport const useSchedule = (props?: UseScheduleProps): UseScheduleResult => {\n const { onSuccess, onError } = props || {};\n const [data, setData] = useState<Schedule>();\n const { preferences, on } = useNovu();\n const [error, setError] = useState<NovuError>();\n const [isLoading, setIsLoading] = useState(true);\n const [isFetching, setIsFetching] = useState(false);\n\n const sync = (event: { data?: Schedule }) => {\n if (!event.data) {\n return;\n }\n setData(event.data);\n };\n\n useEffect(() => {\n fetchSchedule();\n\n const listUpdatedCleanup = on('preference.schedule.get.updated', sync);\n const listPendingCleanup = on('preference.schedule.get.pending', sync);\n const listResolvedCleanup = on('preference.schedule.get.resolved', sync);\n\n return () => {\n listUpdatedCleanup();\n listPendingCleanup();\n listResolvedCleanup();\n };\n }, []);\n\n const fetchSchedule = async () => {\n setIsFetching(true);\n const response = await preferences.schedule.get();\n if (response.error) {\n setError(response.error);\n onError?.(response.error);\n } else {\n onSuccess?.(response.data!);\n }\n setIsLoading(false);\n setIsFetching(false);\n };\n\n const refetch = () => {\n preferences.schedule.cache.clearAll();\n\n return fetchSchedule();\n };\n\n return {\n schedule: data,\n error,\n isLoading,\n isFetching,\n refetch,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAoC;AACpC,0BAAwB;AAejB,IAAM,cAAc,CAAC,UAAgD;AAC1E,QAAM,EAAE,WAAW,QAAQ,IAAI,SAAS,CAAC;AACzC,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAmB;AAC3C,QAAM,EAAE,aAAa,GAAG,QAAI,6BAAQ;AACpC,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAoB;AAC9C,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,IAAI;AAC/C,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,KAAK;AAElD,QAAM,OAAO,CAAC,UAA+B;AAC3C,QAAI,CAAC,MAAM,MAAM;AACf;AAAA,IACF;AACA,YAAQ,MAAM,IAAI;AAAA,EACpB;AAEA,8BAAU,MAAM;AACd,kBAAc;AAEd,UAAM,qBAAqB,GAAG,mCAAmC,IAAI;AACrE,UAAM,qBAAqB,GAAG,mCAAmC,IAAI;AACrE,UAAM,sBAAsB,GAAG,oCAAoC,IAAI;AAEvE,WAAO,MAAM;AACX,yBAAmB;AACnB,yBAAmB;AACnB,0BAAoB;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,gBAAgB,YAAY;AAChC,kBAAc,IAAI;AAClB,UAAM,WAAW,MAAM,YAAY,SAAS,IAAI;AAChD,QAAI,SAAS,OAAO;AAClB,eAAS,SAAS,KAAK;AACvB,yCAAU,SAAS;AAAA,IACrB,OAAO;AACL,6CAAY,SAAS;AAAA,IACvB;AACA,iBAAa,KAAK;AAClB,kBAAc,KAAK;AAAA,EACrB;AAEA,QAAM,UAAU,MAAM;AACpB,gBAAY,SAAS,MAAM,SAAS;AAEpC,WAAO,cAAc;AAAA,EACvB;AAEA,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Schedule, NovuError } from '@novu/js';
|
|
2
|
+
|
|
3
|
+
type UseScheduleProps = {
|
|
4
|
+
onSuccess?: (data: Schedule) => void;
|
|
5
|
+
onError?: (error: NovuError) => void;
|
|
6
|
+
};
|
|
7
|
+
type UseScheduleResult = {
|
|
8
|
+
schedule?: Schedule;
|
|
9
|
+
error?: NovuError;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
isFetching: boolean;
|
|
12
|
+
refetch: () => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
declare const useSchedule: (props?: UseScheduleProps) => UseScheduleResult;
|
|
15
|
+
|
|
16
|
+
export { type UseScheduleProps, type UseScheduleResult, useSchedule };
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -32,7 +32,8 @@ __export(src_exports, {
|
|
|
32
32
|
useCounts: () => import_hooks.useCounts,
|
|
33
33
|
useNotifications: () => import_hooks.useNotifications,
|
|
34
34
|
useNovu: () => import_hooks.useNovu,
|
|
35
|
-
usePreferences: () => import_hooks.usePreferences
|
|
35
|
+
usePreferences: () => import_hooks.usePreferences,
|
|
36
|
+
useSchedule: () => import_hooks.useSchedule
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(src_exports);
|
|
38
39
|
var import_js = require("@novu/js");
|
|
@@ -52,6 +53,7 @@ var import_hooks = require("./hooks/index.cjs");
|
|
|
52
53
|
useCounts,
|
|
53
54
|
useNotifications,
|
|
54
55
|
useNovu,
|
|
55
|
-
usePreferences
|
|
56
|
+
usePreferences,
|
|
57
|
+
useSchedule
|
|
56
58
|
});
|
|
57
59
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type {\n ChannelPreference,\n ChannelType,\n EventHandler,\n Events,\n FiltersCountResponse,\n InboxNotification,\n ListNotificationsResponse,\n Notification,\n NotificationFilter,\n NotificationStatus,\n NovuError,\n NovuOptions,\n Preference,\n PreferencesResponse,\n SocketEventNames,\n UnreadCount,\n WebSocketEvent,\n} from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n Appearance,\n AppearanceCallback,\n AppearanceCallbackFunction,\n AppearanceCallbackKeys,\n AppearanceKey,\n ElementStyles,\n Elements,\n Localization,\n LocalizationKey,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\n Tab,\n Variables,\n} from '@novu/js/ui';\nexport type { BellProps, InboxContentProps, InboxProps, NotificationProps, NovuProviderProps } from './components';\nexport { Bell, Inbox, InboxContent, Notifications, NovuProvider, Preferences } from './components';\nexport type {\n UseCountsProps,\n UseCountsResult,\n UseNotificationsProps,\n UseNotificationsResult,\n
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type {\n ChannelPreference,\n ChannelType,\n EventHandler,\n Events,\n FiltersCountResponse,\n InboxNotification,\n ListNotificationsResponse,\n Notification,\n NotificationFilter,\n NotificationStatus,\n NovuError,\n NovuOptions,\n Preference,\n PreferencesResponse,\n SocketEventNames,\n UnreadCount,\n WebSocketEvent,\n} from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n Appearance,\n AppearanceCallback,\n AppearanceCallbackFunction,\n AppearanceCallbackKeys,\n AppearanceKey,\n ElementStyles,\n Elements,\n Localization,\n LocalizationKey,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\n Tab,\n Variables,\n} from '@novu/js/ui';\nexport type { BellProps, InboxContentProps, InboxProps, NotificationProps, NovuProviderProps } from './components';\nexport { Bell, Inbox, InboxContent, Notifications, NovuProvider, Preferences } from './components';\nexport type {\n UseCountsProps,\n UseCountsResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesResult,\n UseScheduleProps as UsePreferencesProps,\n} from './hooks';\nexport { useCounts, useNotifications, useNovu, usePreferences, useSchedule } 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;AAmBA,gBAA4E;AAsB5E,wBAAoF;AASpF,mBAAkF;","names":[]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -8,7 +8,8 @@ export { NotificationProps, Notifications } from './components/Notifications.cjs
|
|
|
8
8
|
export { Preferences } from './components/Preferences.cjs';
|
|
9
9
|
export { UseCountsProps, UseCountsResult, useCounts } from './hooks/useCounts.cjs';
|
|
10
10
|
export { UseNotificationsProps, UseNotificationsResult, useNotifications } from './hooks/useNotifications.cjs';
|
|
11
|
-
export {
|
|
11
|
+
export { UsePreferencesResult, usePreferences } from './hooks/usePreferences.cjs';
|
|
12
|
+
export { UseScheduleProps as UsePreferencesProps, useSchedule } from './hooks/useSchedule.cjs';
|
|
12
13
|
export { BaseProps, BellRenderer, BodyRenderer, DefaultInboxProps, DefaultProps, NoRendererProps, NotificationRendererProps, NotificationsRenderer, SubjectBodyRendererProps, SubjectRenderer, WithChildrenProps } from './utils/types.cjs';
|
|
13
14
|
import 'react/jsx-runtime';
|
|
14
15
|
import 'react';
|
|
@@ -32,7 +32,8 @@ __export(server_exports, {
|
|
|
32
32
|
useCounts: () => useCounts,
|
|
33
33
|
useNotifications: () => useNotifications,
|
|
34
34
|
useNovu: () => useNovu,
|
|
35
|
-
usePreferences: () => usePreferences
|
|
35
|
+
usePreferences: () => usePreferences,
|
|
36
|
+
useSchedule: () => useSchedule
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(server_exports);
|
|
38
39
|
var import_ShadowRootDetector = require("../components/ShadowRootDetector.cjs");
|
|
@@ -81,6 +82,13 @@ function usePreferences(_) {
|
|
|
81
82
|
refetch: () => Promise.resolve()
|
|
82
83
|
};
|
|
83
84
|
}
|
|
85
|
+
function useSchedule(_) {
|
|
86
|
+
return {
|
|
87
|
+
isLoading: false,
|
|
88
|
+
isFetching: false,
|
|
89
|
+
refetch: () => Promise.resolve()
|
|
90
|
+
};
|
|
91
|
+
}
|
|
84
92
|
// Annotate the CommonJS export names for ESM import in node:
|
|
85
93
|
0 && (module.exports = {
|
|
86
94
|
Bell,
|
|
@@ -95,6 +103,7 @@ function usePreferences(_) {
|
|
|
95
103
|
useCounts,
|
|
96
104
|
useNotifications,
|
|
97
105
|
useNovu,
|
|
98
|
-
usePreferences
|
|
106
|
+
usePreferences,
|
|
107
|
+
useSchedule
|
|
99
108
|
});
|
|
100
109
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -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} 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 type {\n ChannelPreference,\n ChannelType,\n FiltersCountResponse,\n InboxNotification,\n ListNotificationsResponse,\n Notification,\n NotificationFilter,\n NotificationStatus,\n NovuError,\n NovuOptions,\n Preference,\n} from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n Appearance,\n AppearanceKey,\n ElementStyles,\n Elements,\n Localization,\n LocalizationKey,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\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
|
|
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 type {\n ChannelPreference,\n ChannelType,\n FiltersCountResponse,\n InboxNotification,\n ListNotificationsResponse,\n Notification,\n NotificationFilter,\n NotificationStatus,\n NovuError,\n NovuOptions,\n Preference,\n} from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n Appearance,\n AppearanceKey,\n ElementStyles,\n Elements,\n Localization,\n LocalizationKey,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\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;AACA,gCAAmC;AAuFnC,gBAA4E;AApEnE;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;AAAC;AAEjD,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,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,SAAS,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,IACpE,SAAS,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,IACpE,YAAY,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,IACvE,gBAAgB,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,IAC3E,SAAS,MAAM,QAAQ,QAAQ;AAAA,IAC/B,WAAW,MAAM,QAAQ,QAAQ;AAAA,EACnC;AACF;AAEO,SAAS,eAAe,GAA8C;AAC3E,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,QAAQ;AAAA,EACjC;AACF;AAEO,SAAS,YAAY,GAAwC;AAClE,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,QAAQ;AAAA,EACjC;AACF;","names":[]}
|
|
@@ -5,6 +5,7 @@ import { NovuProviderProps } from '../hooks/NovuProvider.cjs';
|
|
|
5
5
|
import { UseCountsProps, UseCountsResult } from '../hooks/useCounts.cjs';
|
|
6
6
|
import { UseNotificationsProps, UseNotificationsResult } from '../hooks/useNotifications.cjs';
|
|
7
7
|
import { UsePreferencesProps, UsePreferencesResult } from '../hooks/usePreferences.cjs';
|
|
8
|
+
import { UseScheduleProps, UseScheduleResult } from '../hooks/useSchedule.cjs';
|
|
8
9
|
export { Appearance, AppearanceKey, ElementStyles, Elements, Localization, LocalizationKey, NotificationActionClickHandler, NotificationClickHandler, NotificationRenderer, PreferenceGroups, PreferencesFilter, RouterPush, Tab, Variables } from '@novu/js/ui';
|
|
9
10
|
export { BellProps } from '../components/Bell.cjs';
|
|
10
11
|
export { InboxContentProps } from '../components/InboxContent.cjs';
|
|
@@ -28,5 +29,6 @@ declare function useNovu(): null;
|
|
|
28
29
|
declare function useCounts(_: UseCountsProps): UseCountsResult;
|
|
29
30
|
declare function useNotifications(_: UseNotificationsProps): UseNotificationsResult;
|
|
30
31
|
declare function usePreferences(_: UsePreferencesProps): UsePreferencesResult;
|
|
32
|
+
declare function useSchedule(_: UseScheduleProps): UseScheduleResult;
|
|
31
33
|
|
|
32
|
-
export { Bell, Inbox, InboxContent, InboxProps, Notifications, NovuProvider, NovuProviderProps, Preferences, UseCountsProps, UseCountsResult, UseNotificationsProps, UseNotificationsResult, UsePreferencesProps, UsePreferencesResult, useCounts, useNotifications, useNovu, usePreferences };
|
|
34
|
+
export { Bell, Inbox, InboxContent, InboxProps, Notifications, NovuProvider, NovuProviderProps, Preferences, UseCountsProps, UseCountsResult, UseNotificationsProps, UseNotificationsResult, UseScheduleProps as UsePreferencesProps, UsePreferencesResult, useCounts, useNotifications, useNovu, usePreferences, useSchedule };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/types.ts"],"sourcesContent":["import type { Subscriber, UnreadCount } from '@novu/js';\nimport type {\n IconKey,\n InboxProps,\n Theme as JsTheme,\n Localization,\n Notification,\n NotificationActionClickHandler,\n NotificationClickHandler,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\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 ReactIconOverrides = {\n [key in IconKey]?: ReactIconRenderer;\n};\n\nexport type ReactTheme = Omit<JsTheme, 'icons'> & {\n icons?: ReactIconOverrides;\n};\n\nexport type ReactAppearance = ReactTheme & {\n baseTheme?: JsTheme | JsTheme[];\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 backendUrl?: string;\n socketUrl?: string;\n appearance?: ReactAppearance;\n localization?: Localization;\n tabs?: Array<Tab>;\n preferencesFilter?: PreferencesFilter;\n preferenceGroups?: PreferenceGroups;\n routerPush?: RouterPush;\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\nexport type BaseProps = StandardBaseProps;\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
|
+
{"version":3,"sources":["../../../src/utils/types.ts"],"sourcesContent":["import type { DefaultSchedule, Subscriber, UnreadCount } from '@novu/js';\nimport type {\n IconKey,\n InboxProps,\n Theme as JsTheme,\n Localization,\n Notification,\n NotificationActionClickHandler,\n NotificationClickHandler,\n PreferenceGroups,\n PreferencesFilter,\n PreferencesSort,\n RouterPush,\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 ReactIconOverrides = {\n [key in IconKey]?: ReactIconRenderer;\n};\n\nexport type ReactTheme = Omit<JsTheme, 'icons'> & {\n icons?: ReactIconOverrides;\n};\n\nexport type ReactAppearance = ReactTheme & {\n baseTheme?: JsTheme | JsTheme[];\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 backendUrl?: string;\n socketUrl?: string;\n appearance?: ReactAppearance;\n localization?: Localization;\n tabs?: Array<Tab>;\n preferencesFilter?: PreferencesFilter;\n preferenceGroups?: PreferenceGroups;\n preferencesSort?: PreferencesSort;\n defaultSchedule?: DefaultSchedule;\n routerPush?: RouterPush;\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\nexport type BaseProps = StandardBaseProps;\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
|
-
import { UnreadCount, Subscriber } from '@novu/js';
|
|
2
|
-
import { Notification, IconKey, Theme, NotificationClickHandler, NotificationActionClickHandler, InboxProps, Localization, Tab, PreferencesFilter, PreferenceGroups, RouterPush } from '@novu/js/ui';
|
|
1
|
+
import { UnreadCount, DefaultSchedule, Subscriber } from '@novu/js';
|
|
2
|
+
import { Notification, IconKey, Theme, NotificationClickHandler, NotificationActionClickHandler, InboxProps, Localization, 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;
|
|
@@ -46,6 +46,8 @@ type StandardBaseProps = {
|
|
|
46
46
|
tabs?: Array<Tab>;
|
|
47
47
|
preferencesFilter?: PreferencesFilter;
|
|
48
48
|
preferenceGroups?: PreferenceGroups;
|
|
49
|
+
preferencesSort?: PreferencesSort;
|
|
50
|
+
defaultSchedule?: DefaultSchedule;
|
|
49
51
|
routerPush?: RouterPush;
|
|
50
52
|
} & ({
|
|
51
53
|
/** @deprecated Use subscriber prop instead */
|
|
@@ -92,7 +92,8 @@ var Inbox = React.memo((props) => {
|
|
|
92
92
|
subscriberHash: props.subscriberHash,
|
|
93
93
|
backendUrl: props.backendUrl,
|
|
94
94
|
socketUrl: props.socketUrl,
|
|
95
|
-
subscriber
|
|
95
|
+
subscriber,
|
|
96
|
+
defaultSchedule: props.defaultSchedule
|
|
96
97
|
};
|
|
97
98
|
return /* @__PURE__ */ jsx(InternalNovuProvider, { ...providerProps, userAgentType: "components", children: /* @__PURE__ */ jsx(InboxChild, { ...propsWithoutSubscriberId, applicationIdentifier, subscriber }) });
|
|
98
99
|
});
|
|
@@ -104,6 +105,7 @@ var InboxChild = withRenderer(
|
|
|
104
105
|
tabs,
|
|
105
106
|
preferencesFilter,
|
|
106
107
|
preferenceGroups,
|
|
108
|
+
preferencesSort,
|
|
107
109
|
routerPush,
|
|
108
110
|
applicationIdentifier = "",
|
|
109
111
|
// for keyless we provide an empty string, the api will generate a identifier
|
|
@@ -111,7 +113,8 @@ var InboxChild = withRenderer(
|
|
|
111
113
|
subscriberHash,
|
|
112
114
|
backendUrl,
|
|
113
115
|
socketUrl,
|
|
114
|
-
subscriber
|
|
116
|
+
subscriber,
|
|
117
|
+
defaultSchedule
|
|
115
118
|
} = props;
|
|
116
119
|
const novu = useNovu();
|
|
117
120
|
const options = useMemo(() => {
|
|
@@ -121,13 +124,15 @@ var InboxChild = withRenderer(
|
|
|
121
124
|
tabs,
|
|
122
125
|
preferencesFilter,
|
|
123
126
|
preferenceGroups,
|
|
127
|
+
preferencesSort,
|
|
124
128
|
routerPush,
|
|
125
129
|
options: {
|
|
126
130
|
applicationIdentifier,
|
|
127
131
|
subscriberHash,
|
|
128
132
|
backendUrl,
|
|
129
133
|
socketUrl,
|
|
130
|
-
subscriber: buildSubscriber({ subscriberId, subscriber })
|
|
134
|
+
subscriber: buildSubscriber({ subscriberId, subscriber }),
|
|
135
|
+
defaultSchedule
|
|
131
136
|
}
|
|
132
137
|
};
|
|
133
138
|
}, [
|
|
@@ -136,6 +141,7 @@ var InboxChild = withRenderer(
|
|
|
136
141
|
tabs,
|
|
137
142
|
preferencesFilter,
|
|
138
143
|
preferenceGroups,
|
|
144
|
+
preferencesSort,
|
|
139
145
|
applicationIdentifier,
|
|
140
146
|
subscriberId,
|
|
141
147
|
subscriberHash,
|
|
@@ -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 backendUrl: props.backendUrl,\n socketUrl: props.socketUrl,\n subscriber,\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 routerPush,\n applicationIdentifier = '', // for keyless we provide an empty string, the api will generate a identifier\n subscriberId,\n subscriberHash,\n backendUrl,\n socketUrl,\n subscriber,\n } = props;\n const novu = useNovu();\n\n const options = useMemo(() => {\n return {\n localization,\n appearance,\n tabs,\n preferencesFilter,\n preferenceGroups,\n routerPush,\n options: {\n applicationIdentifier,\n subscriberHash,\n backendUrl,\n socketUrl,\n subscriber: buildSubscriber({ subscriberId, subscriber }),\n },\n };\n }, [\n localization,\n appearance,\n tabs,\n preferencesFilter,\n preferenceGroups,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n socketUrl,\n subscriber,\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,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,C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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 = 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 backendUrl: props.backendUrl,\n socketUrl: props.socketUrl,\n subscriber,\n defaultSchedule: props.defaultSchedule,\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 backendUrl,\n socketUrl,\n subscriber,\n defaultSchedule,\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 backendUrl,\n socketUrl,\n subscriber: buildSubscriber({ subscriberId, subscriber }),\n defaultSchedule,\n },\n };\n }, [\n localization,\n appearance,\n tabs,\n preferencesFilter,\n preferenceGroups,\n preferencesSort,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n socketUrl,\n subscriber,\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,S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AAAA;AAAA,MACxB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI;AACJ,UAAM,OAAO,QAAQ;AAErB,UAAM,UAAU,QAAQ,MAAM;AAC5B,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAS;AAAA,UACP;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,YAAY,gBAAgB,EAAE,cAAc,WAAW,CAAC;AAAA,UACxD;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,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":[]}
|
|
@@ -3,7 +3,7 @@ import { Novu } from "@novu/js";
|
|
|
3
3
|
import { buildSubscriber } from "@novu/js/internal";
|
|
4
4
|
import { createContext, useContext, useEffect, useMemo } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
var version = "3.
|
|
6
|
+
var version = "3.10.0";
|
|
7
7
|
var name = "@novu/react";
|
|
8
8
|
var baseUserAgent = `${name}@${version}`;
|
|
9
9
|
var NovuContext = createContext(void 0);
|
|
@@ -21,7 +21,17 @@ var NovuProvider = (props) => {
|
|
|
21
21
|
var InternalNovuProvider = (props) => {
|
|
22
22
|
const applicationIdentifier = props.applicationIdentifier || "";
|
|
23
23
|
const subscriberObj = buildSubscriber({ subscriberId: props.subscriberId, subscriber: props.subscriber });
|
|
24
|
-
const {
|
|
24
|
+
const {
|
|
25
|
+
children,
|
|
26
|
+
subscriberId,
|
|
27
|
+
subscriberHash,
|
|
28
|
+
backendUrl,
|
|
29
|
+
apiUrl,
|
|
30
|
+
socketUrl,
|
|
31
|
+
useCache,
|
|
32
|
+
userAgentType,
|
|
33
|
+
defaultSchedule
|
|
34
|
+
} = props;
|
|
25
35
|
const novu = useMemo(
|
|
26
36
|
() => new Novu({
|
|
27
37
|
applicationIdentifier,
|
|
@@ -31,7 +41,8 @@ var InternalNovuProvider = (props) => {
|
|
|
31
41
|
socketUrl,
|
|
32
42
|
useCache,
|
|
33
43
|
__userAgent: `${baseUserAgent} ${userAgentType}`,
|
|
34
|
-
subscriber: subscriberObj
|
|
44
|
+
subscriber: subscriberObj,
|
|
45
|
+
defaultSchedule
|
|
35
46
|
}),
|
|
36
47
|
[applicationIdentifier, subscriberHash, backendUrl, apiUrl, socketUrl, useCache, userAgentType]
|
|
37
48
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/NovuProvider.tsx"],"sourcesContent":["import { Novu, NovuOptions } from '@novu/js';\nimport { buildSubscriber } from '@novu/js/internal';\nimport { createContext, ReactNode, useContext, useEffect, useMemo } from 'react';\n\n// @ts-
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/NovuProvider.tsx"],"sourcesContent":["import { Novu, NovuOptions } from '@novu/js';\nimport { buildSubscriber } from '@novu/js/internal';\nimport { createContext, ReactNode, useContext, useEffect, useMemo } from 'react';\n\n// @ts-expect-error\nconst version = PACKAGE_VERSION;\n// @ts-expect-error\nconst name = PACKAGE_NAME;\nconst baseUserAgent = `${name}@${version}`;\n\nexport type NovuProviderProps = NovuOptions & {\n children: ReactNode;\n};\n\nconst NovuContext = createContext<Novu | undefined>(undefined);\n\nexport const NovuProvider = (props: NovuProviderProps) => {\n const { subscriberId, ...propsWithoutSubscriberId } = props;\n const subscriberObj = buildSubscriber({ subscriberId, subscriber: props.subscriber });\n const applicationIdentifier = propsWithoutSubscriberId.applicationIdentifier\n ? propsWithoutSubscriberId.applicationIdentifier\n : '';\n\n const providerProps: NovuProviderProps = {\n ...propsWithoutSubscriberId,\n applicationIdentifier,\n subscriber: subscriberObj,\n };\n\n return (\n <InternalNovuProvider {...providerProps} applicationIdentifier={applicationIdentifier} userAgentType=\"hooks\">\n {props.children}\n </InternalNovuProvider>\n );\n};\n\n/**\n * @internal Should be used internally not to be exposed outside of the library\n * This is needed to differentiate between the hooks and components user agents\n * Better to use this internally to avoid confusion.\n */\nexport const InternalNovuProvider = (props: NovuProviderProps & { userAgentType: 'components' | 'hooks' }) => {\n const applicationIdentifier = props.applicationIdentifier || '';\n const subscriberObj = buildSubscriber({ subscriberId: props.subscriberId, subscriber: props.subscriber });\n\n const {\n children,\n subscriberId,\n subscriberHash,\n backendUrl,\n apiUrl,\n socketUrl,\n useCache,\n userAgentType,\n defaultSchedule,\n } = props;\n\n const novu = useMemo(\n () =>\n new Novu({\n applicationIdentifier,\n subscriberHash,\n backendUrl,\n apiUrl,\n socketUrl,\n useCache,\n __userAgent: `${baseUserAgent} ${userAgentType}`,\n subscriber: subscriberObj,\n defaultSchedule,\n }),\n [applicationIdentifier, subscriberHash, backendUrl, apiUrl, socketUrl, useCache, userAgentType]\n );\n\n useEffect(() => {\n novu.changeSubscriber({\n subscriber: subscriberObj,\n subscriberHash: props.subscriberHash,\n });\n }, [subscriberObj.subscriberId, props.subscriberHash, novu]);\n\n return <NovuContext.Provider value={novu}>{children}</NovuContext.Provider>;\n};\n\nexport const useNovu = () => {\n const context = useContext(NovuContext);\n if (!context) {\n throw new Error('useNovu must be used within a <NovuProvider />');\n }\n\n return context;\n};\n\nexport const useUnsafeNovu = () => {\n const context = useContext(NovuContext);\n\n return context;\n};\n"],"mappings":";AAAA,SAAS,YAAyB;AAClC,SAAS,uBAAuB;AAChC,SAAS,eAA0B,YAAY,WAAW,eAAe;AA4BrE;AAzBJ,IAAM,UAAU;AAEhB,IAAM,OAAO;AACb,IAAM,gBAAgB,GAAG,IAAI,IAAI,OAAO;AAMxC,IAAM,cAAc,cAAgC,MAAS;AAEtD,IAAM,eAAe,CAAC,UAA6B;AACxD,QAAM,EAAE,cAAc,GAAG,yBAAyB,IAAI;AACtD,QAAM,gBAAgB,gBAAgB,EAAE,cAAc,YAAY,MAAM,WAAW,CAAC;AACpF,QAAM,wBAAwB,yBAAyB,wBACnD,yBAAyB,wBACzB;AAEJ,QAAM,gBAAmC;AAAA,IACvC,GAAG;AAAA,IACH;AAAA,IACA,YAAY;AAAA,EACd;AAEA,SACE,oBAAC,wBAAsB,GAAG,eAAe,uBAA8C,eAAc,SAClG,gBAAM,UACT;AAEJ;AAOO,IAAM,uBAAuB,CAAC,UAAyE;AAC5G,QAAM,wBAAwB,MAAM,yBAAyB;AAC7D,QAAM,gBAAgB,gBAAgB,EAAE,cAAc,MAAM,cAAc,YAAY,MAAM,WAAW,CAAC;AAExG,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,OAAO;AAAA,IACX,MACE,IAAI,KAAK;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa,GAAG,aAAa,IAAI,aAAa;AAAA,MAC9C,YAAY;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,IACH,CAAC,uBAAuB,gBAAgB,YAAY,QAAQ,WAAW,UAAU,aAAa;AAAA,EAChG;AAEA,YAAU,MAAM;AACd,SAAK,iBAAiB;AAAA,MACpB,YAAY;AAAA,MACZ,gBAAgB,MAAM;AAAA,IACxB,CAAC;AAAA,EACH,GAAG,CAAC,cAAc,cAAc,MAAM,gBAAgB,IAAI,CAAC;AAE3D,SAAO,oBAAC,YAAY,UAAZ,EAAqB,OAAO,MAAO,UAAS;AACtD;AAEO,IAAM,UAAU,MAAM;AAC3B,QAAM,UAAU,WAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AAEA,SAAO;AACT;AAEO,IAAM,gBAAgB,MAAM;AACjC,QAAM,UAAU,WAAW,WAAW;AAEtC,SAAO;AACT;","names":[]}
|
|
@@ -3,5 +3,6 @@ export { NovuProvider, useNovu } from './NovuProvider.js';
|
|
|
3
3
|
export { UseCountsProps, UseCountsResult, useCounts } from './useCounts.js';
|
|
4
4
|
export { UseNotificationsProps, UseNotificationsResult, useNotifications } from './useNotifications.js';
|
|
5
5
|
export { UsePreferencesProps, UsePreferencesResult, usePreferences } from './usePreferences.js';
|
|
6
|
+
export { UseScheduleProps, UseScheduleResult, useSchedule } from './useSchedule.js';
|
|
6
7
|
import 'react/jsx-runtime';
|
|
7
8
|
import 'react';
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export type {\n ChannelPreference,\n ChannelType,\n EventHandler,\n Events,\n FiltersCountResponse,\n InboxNotification,\n ListNotificationsResponse,\n Notification,\n NotificationFilter,\n NotificationStatus,\n NovuError,\n NovuOptions,\n Preference,\n PreferencesResponse,\n SocketEventNames,\n UnreadCount,\n WebSocketEvent,\n} from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\nexport { NovuProvider, useNovu } from './NovuProvider';\nexport * from './useCounts';\nexport * from './useNotifications';\nexport * from './usePreferences';\n"],"mappings":";AAmBA,SAAS,iBAAiB,mBAAmB,+BAA+B;AAC5E,SAAS,cAAc,eAAe;AACtC,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export type {\n ChannelPreference,\n ChannelType,\n EventHandler,\n Events,\n FiltersCountResponse,\n InboxNotification,\n ListNotificationsResponse,\n Notification,\n NotificationFilter,\n NotificationStatus,\n NovuError,\n NovuOptions,\n Preference,\n PreferencesResponse,\n SocketEventNames,\n UnreadCount,\n WebSocketEvent,\n} from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\nexport { NovuProvider, useNovu } from './NovuProvider';\nexport * from './useCounts';\nexport * from './useNotifications';\nexport * from './usePreferences';\nexport * from './useSchedule';\n"],"mappings":";AAmBA,SAAS,iBAAiB,mBAAmB,+BAA+B;AAC5E,SAAS,cAAc,eAAe;AACtC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Schedule, NovuError } from '@novu/js';
|
|
2
|
+
|
|
3
|
+
type UseScheduleProps = {
|
|
4
|
+
onSuccess?: (data: Schedule) => void;
|
|
5
|
+
onError?: (error: NovuError) => void;
|
|
6
|
+
};
|
|
7
|
+
type UseScheduleResult = {
|
|
8
|
+
schedule?: Schedule;
|
|
9
|
+
error?: NovuError;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
isFetching: boolean;
|
|
12
|
+
refetch: () => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
declare const useSchedule: (props?: UseScheduleProps) => UseScheduleResult;
|
|
15
|
+
|
|
16
|
+
export { type UseScheduleProps, type UseScheduleResult, useSchedule };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// src/hooks/useSchedule.ts
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useNovu } from "./NovuProvider.js";
|
|
4
|
+
var useSchedule = (props) => {
|
|
5
|
+
const { onSuccess, onError } = props || {};
|
|
6
|
+
const [data, setData] = useState();
|
|
7
|
+
const { preferences, on } = useNovu();
|
|
8
|
+
const [error, setError] = useState();
|
|
9
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
10
|
+
const [isFetching, setIsFetching] = useState(false);
|
|
11
|
+
const sync = (event) => {
|
|
12
|
+
if (!event.data) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
setData(event.data);
|
|
16
|
+
};
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
fetchSchedule();
|
|
19
|
+
const listUpdatedCleanup = on("preference.schedule.get.updated", sync);
|
|
20
|
+
const listPendingCleanup = on("preference.schedule.get.pending", sync);
|
|
21
|
+
const listResolvedCleanup = on("preference.schedule.get.resolved", sync);
|
|
22
|
+
return () => {
|
|
23
|
+
listUpdatedCleanup();
|
|
24
|
+
listPendingCleanup();
|
|
25
|
+
listResolvedCleanup();
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
const fetchSchedule = async () => {
|
|
29
|
+
setIsFetching(true);
|
|
30
|
+
const response = await preferences.schedule.get();
|
|
31
|
+
if (response.error) {
|
|
32
|
+
setError(response.error);
|
|
33
|
+
onError?.(response.error);
|
|
34
|
+
} else {
|
|
35
|
+
onSuccess?.(response.data);
|
|
36
|
+
}
|
|
37
|
+
setIsLoading(false);
|
|
38
|
+
setIsFetching(false);
|
|
39
|
+
};
|
|
40
|
+
const refetch = () => {
|
|
41
|
+
preferences.schedule.cache.clearAll();
|
|
42
|
+
return fetchSchedule();
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
schedule: data,
|
|
46
|
+
error,
|
|
47
|
+
isLoading,
|
|
48
|
+
isFetching,
|
|
49
|
+
refetch
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
useSchedule
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=useSchedule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useSchedule.ts"],"sourcesContent":["import { NovuError, Schedule } from '@novu/js';\nimport { useEffect, useState } from 'react';\nimport { useNovu } from './NovuProvider';\n\nexport type UseScheduleProps = {\n onSuccess?: (data: Schedule) => void;\n onError?: (error: NovuError) => void;\n};\n\nexport type UseScheduleResult = {\n schedule?: Schedule;\n error?: NovuError;\n isLoading: boolean; // initial loading\n isFetching: boolean; // the request is in flight\n refetch: () => Promise<void>;\n};\n\nexport const useSchedule = (props?: UseScheduleProps): UseScheduleResult => {\n const { onSuccess, onError } = props || {};\n const [data, setData] = useState<Schedule>();\n const { preferences, on } = useNovu();\n const [error, setError] = useState<NovuError>();\n const [isLoading, setIsLoading] = useState(true);\n const [isFetching, setIsFetching] = useState(false);\n\n const sync = (event: { data?: Schedule }) => {\n if (!event.data) {\n return;\n }\n setData(event.data);\n };\n\n useEffect(() => {\n fetchSchedule();\n\n const listUpdatedCleanup = on('preference.schedule.get.updated', sync);\n const listPendingCleanup = on('preference.schedule.get.pending', sync);\n const listResolvedCleanup = on('preference.schedule.get.resolved', sync);\n\n return () => {\n listUpdatedCleanup();\n listPendingCleanup();\n listResolvedCleanup();\n };\n }, []);\n\n const fetchSchedule = async () => {\n setIsFetching(true);\n const response = await preferences.schedule.get();\n if (response.error) {\n setError(response.error);\n onError?.(response.error);\n } else {\n onSuccess?.(response.data!);\n }\n setIsLoading(false);\n setIsFetching(false);\n };\n\n const refetch = () => {\n preferences.schedule.cache.clearAll();\n\n return fetchSchedule();\n };\n\n return {\n schedule: data,\n error,\n isLoading,\n isFetching,\n refetch,\n };\n};\n"],"mappings":";AACA,SAAS,WAAW,gBAAgB;AACpC,SAAS,eAAe;AAejB,IAAM,cAAc,CAAC,UAAgD;AAC1E,QAAM,EAAE,WAAW,QAAQ,IAAI,SAAS,CAAC;AACzC,QAAM,CAAC,MAAM,OAAO,IAAI,SAAmB;AAC3C,QAAM,EAAE,aAAa,GAAG,IAAI,QAAQ;AACpC,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAoB;AAC9C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,IAAI;AAC/C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAElD,QAAM,OAAO,CAAC,UAA+B;AAC3C,QAAI,CAAC,MAAM,MAAM;AACf;AAAA,IACF;AACA,YAAQ,MAAM,IAAI;AAAA,EACpB;AAEA,YAAU,MAAM;AACd,kBAAc;AAEd,UAAM,qBAAqB,GAAG,mCAAmC,IAAI;AACrE,UAAM,qBAAqB,GAAG,mCAAmC,IAAI;AACrE,UAAM,sBAAsB,GAAG,oCAAoC,IAAI;AAEvE,WAAO,MAAM;AACX,yBAAmB;AACnB,yBAAmB;AACnB,0BAAoB;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,gBAAgB,YAAY;AAChC,kBAAc,IAAI;AAClB,UAAM,WAAW,MAAM,YAAY,SAAS,IAAI;AAChD,QAAI,SAAS,OAAO;AAClB,eAAS,SAAS,KAAK;AACvB,gBAAU,SAAS,KAAK;AAAA,IAC1B,OAAO;AACL,kBAAY,SAAS,IAAK;AAAA,IAC5B;AACA,iBAAa,KAAK;AAClB,kBAAc,KAAK;AAAA,EACrB;AAEA,QAAM,UAAU,MAAM;AACpB,gBAAY,SAAS,MAAM,SAAS;AAEpC,WAAO,cAAc;AAAA,EACvB;AAEA,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ export { NotificationProps, Notifications } from './components/Notifications.js'
|
|
|
8
8
|
export { Preferences } from './components/Preferences.js';
|
|
9
9
|
export { UseCountsProps, UseCountsResult, useCounts } from './hooks/useCounts.js';
|
|
10
10
|
export { UseNotificationsProps, UseNotificationsResult, useNotifications } from './hooks/useNotifications.js';
|
|
11
|
-
export {
|
|
11
|
+
export { UsePreferencesResult, usePreferences } from './hooks/usePreferences.js';
|
|
12
|
+
export { UseScheduleProps as UsePreferencesProps, useSchedule } from './hooks/useSchedule.js';
|
|
12
13
|
export { BaseProps, BellRenderer, BodyRenderer, DefaultInboxProps, DefaultProps, NoRendererProps, NotificationRendererProps, NotificationsRenderer, SubjectBodyRendererProps, SubjectRenderer, WithChildrenProps } from './utils/types.js';
|
|
13
14
|
import 'react/jsx-runtime';
|
|
14
15
|
import 'react';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from "@novu/js";
|
|
3
3
|
import { Bell, Inbox, InboxContent, Notifications, NovuProvider, Preferences } from "./components/index.js";
|
|
4
|
-
import { useCounts, useNotifications, useNovu, usePreferences } from "./hooks/index.js";
|
|
4
|
+
import { useCounts, useNotifications, useNovu, usePreferences, useSchedule } from "./hooks/index.js";
|
|
5
5
|
export {
|
|
6
6
|
Bell,
|
|
7
7
|
Inbox,
|
|
@@ -15,6 +15,7 @@ export {
|
|
|
15
15
|
useCounts,
|
|
16
16
|
useNotifications,
|
|
17
17
|
useNovu,
|
|
18
|
-
usePreferences
|
|
18
|
+
usePreferences,
|
|
19
|
+
useSchedule
|
|
19
20
|
};
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type {\n ChannelPreference,\n ChannelType,\n EventHandler,\n Events,\n FiltersCountResponse,\n InboxNotification,\n ListNotificationsResponse,\n Notification,\n NotificationFilter,\n NotificationStatus,\n NovuError,\n NovuOptions,\n Preference,\n PreferencesResponse,\n SocketEventNames,\n UnreadCount,\n WebSocketEvent,\n} from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n Appearance,\n AppearanceCallback,\n AppearanceCallbackFunction,\n AppearanceCallbackKeys,\n AppearanceKey,\n ElementStyles,\n Elements,\n Localization,\n LocalizationKey,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\n Tab,\n Variables,\n} from '@novu/js/ui';\nexport type { BellProps, InboxContentProps, InboxProps, NotificationProps, NovuProviderProps } from './components';\nexport { Bell, Inbox, InboxContent, Notifications, NovuProvider, Preferences } from './components';\nexport type {\n UseCountsProps,\n UseCountsResult,\n UseNotificationsProps,\n UseNotificationsResult,\n
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type {\n ChannelPreference,\n ChannelType,\n EventHandler,\n Events,\n FiltersCountResponse,\n InboxNotification,\n ListNotificationsResponse,\n Notification,\n NotificationFilter,\n NotificationStatus,\n NovuError,\n NovuOptions,\n Preference,\n PreferencesResponse,\n SocketEventNames,\n UnreadCount,\n WebSocketEvent,\n} from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n Appearance,\n AppearanceCallback,\n AppearanceCallbackFunction,\n AppearanceCallbackKeys,\n AppearanceKey,\n ElementStyles,\n Elements,\n Localization,\n LocalizationKey,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\n Tab,\n Variables,\n} from '@novu/js/ui';\nexport type { BellProps, InboxContentProps, InboxProps, NotificationProps, NovuProviderProps } from './components';\nexport { Bell, Inbox, InboxContent, Notifications, NovuProvider, Preferences } from './components';\nexport type {\n UseCountsProps,\n UseCountsResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesResult,\n UseScheduleProps as UsePreferencesProps,\n} from './hooks';\nexport { useCounts, useNotifications, useNovu, usePreferences, useSchedule } 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":";AAmBA,SAAS,iBAAiB,mBAAmB,+BAA+B;AAsB5E,SAAS,MAAM,OAAO,cAAc,eAAe,cAAc,mBAAmB;AASpF,SAAS,WAAW,kBAAkB,SAAS,gBAAgB,mBAAmB;","names":[]}
|
|
@@ -5,6 +5,7 @@ import { NovuProviderProps } from '../hooks/NovuProvider.js';
|
|
|
5
5
|
import { UseCountsProps, UseCountsResult } from '../hooks/useCounts.js';
|
|
6
6
|
import { UseNotificationsProps, UseNotificationsResult } from '../hooks/useNotifications.js';
|
|
7
7
|
import { UsePreferencesProps, UsePreferencesResult } from '../hooks/usePreferences.js';
|
|
8
|
+
import { UseScheduleProps, UseScheduleResult } from '../hooks/useSchedule.js';
|
|
8
9
|
export { Appearance, AppearanceKey, ElementStyles, Elements, Localization, LocalizationKey, NotificationActionClickHandler, NotificationClickHandler, NotificationRenderer, PreferenceGroups, PreferencesFilter, RouterPush, Tab, Variables } from '@novu/js/ui';
|
|
9
10
|
export { BellProps } from '../components/Bell.js';
|
|
10
11
|
export { InboxContentProps } from '../components/InboxContent.js';
|
|
@@ -28,5 +29,6 @@ declare function useNovu(): null;
|
|
|
28
29
|
declare function useCounts(_: UseCountsProps): UseCountsResult;
|
|
29
30
|
declare function useNotifications(_: UseNotificationsProps): UseNotificationsResult;
|
|
30
31
|
declare function usePreferences(_: UsePreferencesProps): UsePreferencesResult;
|
|
32
|
+
declare function useSchedule(_: UseScheduleProps): UseScheduleResult;
|
|
31
33
|
|
|
32
|
-
export { Bell, Inbox, InboxContent, InboxProps, Notifications, NovuProvider, NovuProviderProps, Preferences, UseCountsProps, UseCountsResult, UseNotificationsProps, UseNotificationsResult, UsePreferencesProps, UsePreferencesResult, useCounts, useNotifications, useNovu, usePreferences };
|
|
34
|
+
export { Bell, Inbox, InboxContent, InboxProps, Notifications, NovuProvider, NovuProviderProps, Preferences, UseCountsProps, UseCountsResult, UseNotificationsProps, UseNotificationsResult, UseScheduleProps as UsePreferencesProps, UsePreferencesResult, useCounts, useNotifications, useNovu, usePreferences, useSchedule };
|
package/dist/esm/server/index.js
CHANGED
|
@@ -45,6 +45,13 @@ function usePreferences(_) {
|
|
|
45
45
|
refetch: () => Promise.resolve()
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
+
function useSchedule(_) {
|
|
49
|
+
return {
|
|
50
|
+
isLoading: false,
|
|
51
|
+
isFetching: false,
|
|
52
|
+
refetch: () => Promise.resolve()
|
|
53
|
+
};
|
|
54
|
+
}
|
|
48
55
|
export {
|
|
49
56
|
Bell,
|
|
50
57
|
Inbox,
|
|
@@ -58,6 +65,7 @@ export {
|
|
|
58
65
|
useCounts,
|
|
59
66
|
useNotifications,
|
|
60
67
|
useNovu,
|
|
61
|
-
usePreferences
|
|
68
|
+
usePreferences,
|
|
69
|
+
useSchedule
|
|
62
70
|
};
|
|
63
71
|
//# sourceMappingURL=index.js.map
|
|
@@ -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} 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 type {\n ChannelPreference,\n ChannelType,\n FiltersCountResponse,\n InboxNotification,\n ListNotificationsResponse,\n Notification,\n NotificationFilter,\n NotificationStatus,\n NovuError,\n NovuOptions,\n Preference,\n} from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n Appearance,\n AppearanceKey,\n ElementStyles,\n Elements,\n Localization,\n LocalizationKey,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\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
|
|
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 type {\n ChannelPreference,\n ChannelType,\n FiltersCountResponse,\n InboxNotification,\n ListNotificationsResponse,\n Notification,\n NotificationFilter,\n NotificationStatus,\n NovuError,\n NovuOptions,\n Preference,\n} from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n Appearance,\n AppearanceKey,\n ElementStyles,\n Elements,\n Localization,\n LocalizationKey,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\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":";AACA,SAAS,0BAA0B;AAuFnC,SAAS,iBAAiB,mBAAmB,+BAA+B;AApEnE;AADF,SAAS,MAAM,OAAmB;AACvC,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,eAAe;AAAC;AAEzB,SAAS,gBAAgB;AAAC;AAE1B,SAAS,cAAc;AAAC;AAExB,SAAS,OAAO;AAAC;AAEjB,SAAS,aAAa,OAA0B;AAAC;AAEjD,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,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,SAAS,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,IACpE,SAAS,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,IACpE,YAAY,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,IACvE,gBAAgB,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,IAC3E,SAAS,MAAM,QAAQ,QAAQ;AAAA,IAC/B,WAAW,MAAM,QAAQ,QAAQ;AAAA,EACnC;AACF;AAEO,SAAS,eAAe,GAA8C;AAC3E,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,QAAQ;AAAA,EACjC;AACF;AAEO,SAAS,YAAY,GAAwC;AAClE,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,QAAQ;AAAA,EACjC;AACF;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UnreadCount, Subscriber } from '@novu/js';
|
|
2
|
-
import { Notification, IconKey, Theme, NotificationClickHandler, NotificationActionClickHandler, InboxProps, Localization, Tab, PreferencesFilter, PreferenceGroups, RouterPush } from '@novu/js/ui';
|
|
1
|
+
import { UnreadCount, DefaultSchedule, Subscriber } from '@novu/js';
|
|
2
|
+
import { Notification, IconKey, Theme, NotificationClickHandler, NotificationActionClickHandler, InboxProps, Localization, 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;
|
|
@@ -46,6 +46,8 @@ type StandardBaseProps = {
|
|
|
46
46
|
tabs?: Array<Tab>;
|
|
47
47
|
preferencesFilter?: PreferencesFilter;
|
|
48
48
|
preferenceGroups?: PreferenceGroups;
|
|
49
|
+
preferencesSort?: PreferencesSort;
|
|
50
|
+
defaultSchedule?: DefaultSchedule;
|
|
49
51
|
routerPush?: RouterPush;
|
|
50
52
|
} & ({
|
|
51
53
|
/** @deprecated Use subscriber prop instead */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novu/react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/novuhq/novu",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
"dependencies": {
|
|
124
|
-
"@novu/js": "3.
|
|
124
|
+
"@novu/js": "3.10.0"
|
|
125
125
|
},
|
|
126
126
|
"nx": {
|
|
127
127
|
"tags": [
|