@trycourier/courier-react 8.0.23-beta → 8.0.24-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/courier-inbox-popup-menu.d.ts +21 -0
- package/dist/components/courier-inbox.d.ts +14 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +122 -110
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,26 +2,47 @@ import { ReactNode } from '../../../../node_modules/react';
|
|
|
2
2
|
import { CourierInboxFeedType, CourierInboxHeaderFactoryProps, CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxMenuButtonFactoryProps, CourierInboxPopupMenu as CourierInboxPopupMenuElement, CourierInboxPaginationItemFactoryProps, CourierInboxPopupAlignment, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxTheme } from '@trycourier/courier-ui-inbox';
|
|
3
3
|
import { CourierComponentThemeMode } from '@trycourier/courier-ui-core';
|
|
4
4
|
export interface CourierInboxPopupMenuProps {
|
|
5
|
+
/** Alignment of the popup menu: 'top-right', 'top-left', 'top-center', 'bottom-right', 'bottom-left', 'bottom-center', 'center-right', 'center-left', 'center-center'. */
|
|
5
6
|
popupAlignment?: CourierInboxPopupAlignment;
|
|
7
|
+
/** Width of the popup menu container. */
|
|
6
8
|
popupWidth?: string;
|
|
9
|
+
/** Height of the popup menu container. */
|
|
7
10
|
popupHeight?: string;
|
|
11
|
+
/** CSS left position for the popup menu. */
|
|
8
12
|
left?: string;
|
|
13
|
+
/** CSS top position for the popup menu. */
|
|
9
14
|
top?: string;
|
|
15
|
+
/** CSS right position for the popup menu. */
|
|
10
16
|
right?: string;
|
|
17
|
+
/** CSS bottom position for the popup menu. */
|
|
11
18
|
bottom?: string;
|
|
19
|
+
/** Theme object for light mode. */
|
|
12
20
|
lightTheme?: CourierInboxTheme;
|
|
21
|
+
/** Theme object for dark mode. */
|
|
13
22
|
darkTheme?: CourierInboxTheme;
|
|
23
|
+
/** Theme mode: 'light', 'dark', or 'system'. */
|
|
14
24
|
mode?: CourierComponentThemeMode;
|
|
25
|
+
/** Type of feed to display in the popup menu ('inbox' or 'archive'). */
|
|
15
26
|
feedType?: CourierInboxFeedType;
|
|
27
|
+
/** Callback fired when a message is clicked. */
|
|
16
28
|
onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;
|
|
29
|
+
/** Callback fired when a message action (e.g., button) is clicked. */
|
|
17
30
|
onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;
|
|
31
|
+
/** Callback fired when a message is long-pressed (for mobile/gesture support). */
|
|
18
32
|
onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;
|
|
33
|
+
/** Allows you to pass a custom component as the header. */
|
|
19
34
|
renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;
|
|
35
|
+
/** Allows you to pass a custom component as the list item. */
|
|
20
36
|
renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;
|
|
37
|
+
/** Allows you to pass a custom component as the empty state. */
|
|
21
38
|
renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;
|
|
39
|
+
/** Allows you to pass a custom component as the loading state. */
|
|
22
40
|
renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;
|
|
41
|
+
/** Allows you to pass a custom component as the error state. */
|
|
23
42
|
renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;
|
|
43
|
+
/** Allows you to pass a custom component as the pagination list item. */
|
|
24
44
|
renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;
|
|
45
|
+
/** Allows you to pass a custom component as the menu button. */
|
|
25
46
|
renderMenuButton?: (props: CourierInboxMenuButtonFactoryProps | undefined | null) => ReactNode;
|
|
26
47
|
}
|
|
27
48
|
export declare const CourierInboxPopupMenu: import('../../../../node_modules/react').ForwardRefExoticComponent<CourierInboxPopupMenuProps & import('../../../../node_modules/react').RefAttributes<CourierInboxPopupMenuElement>>;
|
|
@@ -2,19 +2,33 @@ import { ReactNode } from '../../../../node_modules/react';
|
|
|
2
2
|
import { CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxTheme, CourierInbox as CourierInboxElement, CourierInboxHeaderFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxFeedType } from '@trycourier/courier-ui-inbox';
|
|
3
3
|
import { CourierComponentThemeMode } from '@trycourier/courier-ui-core';
|
|
4
4
|
export interface CourierInboxProps {
|
|
5
|
+
/** Height of the inbox container. Defaults to "auto" and will resize itself based on it's children. */
|
|
5
6
|
height?: string;
|
|
7
|
+
/** Theme object for light mode */
|
|
6
8
|
lightTheme?: CourierInboxTheme;
|
|
9
|
+
/** Theme object for dark mode */
|
|
7
10
|
darkTheme?: CourierInboxTheme;
|
|
11
|
+
/** Theme mode: "light", "dark", or "system". Defaults to "system" */
|
|
8
12
|
mode?: CourierComponentThemeMode;
|
|
13
|
+
/** Type of feed to display in the inbox ("inbox" or "archive"). Defaults to "inbox" */
|
|
9
14
|
feedType?: CourierInboxFeedType;
|
|
15
|
+
/** Callback fired when a message is clicked. */
|
|
10
16
|
onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;
|
|
17
|
+
/** Callback fired when a message action (e.g., button) is clicked. */
|
|
11
18
|
onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;
|
|
19
|
+
/** Callback fired when a message is long-pressed (for mobile/gesture support). Only works on devices that support touch. */
|
|
12
20
|
onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;
|
|
21
|
+
/** Allows you to pass a custom component as the header. */
|
|
13
22
|
renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;
|
|
23
|
+
/** Allows you to pass a custom component as the list item. */
|
|
14
24
|
renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;
|
|
25
|
+
/** Allows you to pass a custom component as the empty state. */
|
|
15
26
|
renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;
|
|
27
|
+
/** Allows you to pass a custom component as the loading state. */
|
|
16
28
|
renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;
|
|
29
|
+
/** Allows you to pass a custom component as the error state. */
|
|
17
30
|
renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;
|
|
31
|
+
/** Allows you to pass a custom component as the pagination list item. */
|
|
18
32
|
renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;
|
|
19
33
|
}
|
|
20
34
|
export declare const CourierInbox: import('../../../../node_modules/react').ForwardRefExoticComponent<CourierInboxProps & import('../../../../node_modules/react').RefAttributes<CourierInboxElement>>;
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@trycourier/courier-js"),r=require("@trycourier/courier-ui-inbox"),t=require("react"),s=require("react/jsx-runtime"),n=require("react-dom"),a=require("react-dom/client");function o(e){const r=document.createElement("div"),t=a.createRoot(r);n.flushSync((()=>{t.render(e)}));const s=r.firstElementChild;if(!(s instanceof HTMLElement))throw new Error("renderListItem must return a single JSX element that renders to an HTMLElement (e.g., <div>)");return s}const i=({children:e})=>{const[r,n]=t.useState(!1);return t.useEffect((()=>{n(!0)}),[]),"undefined"==typeof window?null:r?s.jsx(s.Fragment,{children:e}):null},u=t.forwardRef(((e,r)=>{const n=t.useRef(null);return t.useEffect((()=>{"function"==typeof r?r(n.current):r&&(r.current=n.current)}),[r]),t.useEffect((()=>{const r=n.current;r&&r.onMessageClick(e.onMessageClick)}),[e.onMessageClick,n]),t.useEffect((()=>{const r=n.current;r&&r.onMessageActionClick(e.onMessageActionClick)}),[e.onMessageActionClick,n]),t.useEffect((()=>{const r=n.current;r&&r.onMessageLongPress(e.onMessageLongPress)}),[e.onMessageLongPress,n]),t.useEffect((()=>{const r=n.current;r&&e.renderHeader&&queueMicrotask((()=>{r.setHeader((r=>o(e.renderHeader(r))))}))}),[e.renderHeader,n]),t.useEffect((()=>{const r=n.current;r&&e.renderListItem&&queueMicrotask((()=>{r.setListItem((r=>o(e.renderListItem(r))))}))}),[e.renderListItem,n]),t.useEffect((()=>{const r=n.current;r&&e.renderEmptyState&&queueMicrotask((()=>{r.setEmptyState((r=>o(e.renderEmptyState(r))))}))}),[e.renderEmptyState,n]),t.useEffect((()=>{const r=n.current;r&&e.renderLoadingState&&queueMicrotask((()=>{r.setLoadingState((r=>o(e.renderLoadingState(r))))}))}),[e.renderLoadingState,n]),t.useEffect((()=>{const r=n.current;r&&e.renderErrorState&&queueMicrotask((()=>{r.setErrorState((r=>o(e.renderErrorState(r))))}))}),[e.renderErrorState,n]),t.useEffect((()=>{const r=n.current;r&&e.renderPaginationItem&&queueMicrotask((()=>{r.setPaginationItem((r=>o(e.renderPaginationItem(r))))}))}),[e.renderPaginationItem,n]),t.useEffect((()=>{const r=n.current;r&&queueMicrotask((()=>{r.setFeedType(e.feedType||"inbox")}))}),[e.feedType,n]),s.jsx(i,{children:s.jsx("courier-inbox",{ref:n,height:e.height,"light-theme":e.lightTheme?JSON.stringify(e.lightTheme):void 0,"dark-theme":e.darkTheme?JSON.stringify(e.darkTheme):void 0,mode:e.mode})})}));u.displayName="CourierInbox";const c=t.forwardRef(((e,r)=>{
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@trycourier/courier-js"),r=require("@trycourier/courier-ui-inbox"),t=require("react"),s=require("react/jsx-runtime"),n=require("react-dom"),a=require("react-dom/client");function o(e){const r=document.createElement("div"),t=a.createRoot(r);n.flushSync((()=>{t.render(e)}));const s=r.firstElementChild;if(!(s instanceof HTMLElement))throw new Error("renderListItem must return a single JSX element that renders to an HTMLElement (e.g., <div>)");return s}const i=({children:e})=>{const[r,n]=t.useState(!1);return t.useEffect((()=>{n(!0)}),[]),"undefined"==typeof window?null:r?s.jsx(s.Fragment,{children:e}):null},u=t.forwardRef(((e,r)=>{const n=t.useRef(null);return t.useEffect((()=>{"function"==typeof r?r(n.current):r&&(r.current=n.current)}),[r]),t.useEffect((()=>{const r=n.current;r&&r.onMessageClick(e.onMessageClick)}),[e.onMessageClick,n]),t.useEffect((()=>{const r=n.current;r&&r.onMessageActionClick(e.onMessageActionClick)}),[e.onMessageActionClick,n]),t.useEffect((()=>{const r=n.current;r&&r.onMessageLongPress(e.onMessageLongPress)}),[e.onMessageLongPress,n]),t.useEffect((()=>{const r=n.current;r&&e.renderHeader&&queueMicrotask((()=>{r.setHeader((r=>o(e.renderHeader(r))))}))}),[e.renderHeader,n]),t.useEffect((()=>{const r=n.current;r&&e.renderListItem&&queueMicrotask((()=>{r.setListItem((r=>o(e.renderListItem(r))))}))}),[e.renderListItem,n]),t.useEffect((()=>{const r=n.current;r&&e.renderEmptyState&&queueMicrotask((()=>{r.setEmptyState((r=>o(e.renderEmptyState(r))))}))}),[e.renderEmptyState,n]),t.useEffect((()=>{const r=n.current;r&&e.renderLoadingState&&queueMicrotask((()=>{r.setLoadingState((r=>o(e.renderLoadingState(r))))}))}),[e.renderLoadingState,n]),t.useEffect((()=>{const r=n.current;r&&e.renderErrorState&&queueMicrotask((()=>{r.setErrorState((r=>o(e.renderErrorState(r))))}))}),[e.renderErrorState,n]),t.useEffect((()=>{const r=n.current;r&&e.renderPaginationItem&&queueMicrotask((()=>{r.setPaginationItem((r=>o(e.renderPaginationItem(r))))}))}),[e.renderPaginationItem,n]),t.useEffect((()=>{const r=n.current;r&&queueMicrotask((()=>{r.setFeedType(e.feedType||"inbox")}))}),[e.feedType,n]),s.jsx(i,{children:s.jsx("courier-inbox",{ref:n,height:e.height,"light-theme":e.lightTheme?JSON.stringify(e.lightTheme):void 0,"dark-theme":e.darkTheme?JSON.stringify(e.darkTheme):void 0,mode:e.mode})})}));u.displayName="CourierInbox";const c=t.forwardRef(((e,r)=>{function n(e){r&&("function"==typeof r?r(e):r.current=e),n._el=e}function a(){return n._el??null}const u=t.useRef(void 0);return t.useEffect((()=>{const r=a();r&&e.feedType!==u.current&&(u.current=e.feedType,queueMicrotask((()=>{var t;null==(t=r.setFeedType)||t.call(r,e.feedType??"inbox")})))}),[e.feedType]),t.useEffect((()=>{const r=a();r&&r.onMessageClick(e.onMessageClick)}),[e.onMessageClick]),t.useEffect((()=>{const r=a();r&&r.onMessageActionClick(e.onMessageActionClick)}),[e.onMessageActionClick]),t.useEffect((()=>{const r=a();r&&r.onMessageLongPress(e.onMessageLongPress)}),[e.onMessageLongPress]),t.useEffect((()=>{const r=a();r&&e.renderHeader&&queueMicrotask((()=>{r.setHeader((r=>o(e.renderHeader(r))))}))}),[e.renderHeader]),t.useEffect((()=>{const r=a();r&&e.renderListItem&&queueMicrotask((()=>{r.setListItem((r=>o(e.renderListItem(r))))}))}),[e.renderListItem]),t.useEffect((()=>{const r=a();r&&e.renderEmptyState&&queueMicrotask((()=>{r.setEmptyState((r=>o(e.renderEmptyState(r))))}))}),[e.renderEmptyState]),t.useEffect((()=>{const r=a();r&&e.renderLoadingState&&queueMicrotask((()=>{r.setLoadingState((r=>o(e.renderLoadingState(r))))}))}),[e.renderLoadingState]),t.useEffect((()=>{const r=a();r&&e.renderErrorState&&queueMicrotask((()=>{r.setErrorState((r=>o(e.renderErrorState(r))))}))}),[e.renderErrorState]),t.useEffect((()=>{const r=a();r&&e.renderPaginationItem&&queueMicrotask((()=>{r.setPaginationItem((r=>o(e.renderPaginationItem(r))))}))}),[e.renderPaginationItem]),t.useEffect((()=>{const r=a();r&&e.renderMenuButton&&queueMicrotask((()=>{r.setMenuButton((r=>o(e.renderMenuButton(r))))}))}),[e.renderMenuButton]),s.jsx(i,{children:s.jsx("courier-inbox-popup-menu",{ref:n,"popup-alignment":e.popupAlignment,"popup-width":e.popupWidth,"popup-height":e.popupHeight,left:e.left,top:e.top,right:e.right,bottom:e.bottom,"light-theme":e.lightTheme?JSON.stringify(e.lightTheme):void 0,"dark-theme":e.darkTheme?JSON.stringify(e.darkTheme):void 0,mode:e.mode})})}));c.displayName="CourierInboxPopupMenu",Object.defineProperty(exports,"archiveMessage",{enumerable:!0,get:()=>r.archiveMessage}),Object.defineProperty(exports,"clickMessage",{enumerable:!0,get:()=>r.clickMessage}),Object.defineProperty(exports,"defaultDarkTheme",{enumerable:!0,get:()=>r.defaultDarkTheme}),Object.defineProperty(exports,"defaultLightTheme",{enumerable:!0,get:()=>r.defaultLightTheme}),Object.defineProperty(exports,"markAsRead",{enumerable:!0,get:()=>r.markAsRead}),Object.defineProperty(exports,"markAsUnread",{enumerable:!0,get:()=>r.markAsUnread}),Object.defineProperty(exports,"mergeTheme",{enumerable:!0,get:()=>r.mergeTheme}),Object.defineProperty(exports,"openMessage",{enumerable:!0,get:()=>r.openMessage}),exports.CourierInbox=u,exports.CourierInboxPopupMenu=c,exports.useCourier=()=>{const s=r=>e.Courier.shared.signIn(r),n=()=>e.Courier.shared.signOut(),a=e=>r.CourierInboxDatastore.shared.load(e),o=e=>r.CourierInboxDatastore.shared.fetchNextPageOfMessages(e),i=r=>e.Courier.shared.paginationLimit=r,u=e=>r.CourierInboxDatastore.shared.readMessage({message:e}),c=e=>r.CourierInboxDatastore.shared.unreadMessage({message:e}),d=e=>r.CourierInboxDatastore.shared.clickMessage({message:e}),g=e=>r.CourierInboxDatastore.shared.archiveMessage({message:e}),f=e=>r.CourierInboxDatastore.shared.openMessage({message:e}),m=e=>r.CourierInboxDatastore.shared.unarchiveMessage({message:e}),l=()=>r.CourierInboxDatastore.shared.readAllMessages(),[h,p]=t.useState({userId:void 0,signIn:s,signOut:n}),[M,E]=t.useState({load:a,fetchNextPageOfMessages:o,setPaginationLimit:i,readMessage:u,unreadMessage:c,clickMessage:d,archiveMessage:g,openMessage:f,unarchiveMessage:m,readAllMessages:l});t.useEffect((()=>{const t=e.Courier.shared.addAuthenticationListener((()=>x())),s=new r.CourierInboxDataStoreListener({onError:e=>b(e),onDataSetChange:()=>b(),onPageAdded:()=>b(),onMessageAdd:()=>b(),onMessageRemove:()=>b(),onMessageUpdate:()=>b(),onUnreadCountChange:()=>b()});return r.CourierInboxDatastore.shared.addDataStoreListener(s),x(),b(),()=>{t.remove(),s.remove()}}),[]);const x=()=>{var r;const t=null==(r=e.Courier.shared.client)?void 0:r.options;p({userId:null==t?void 0:t.userId,signIn:s,signOut:n})},b=e=>{const t=r.CourierInboxDatastore.shared;E({load:a,fetchNextPageOfMessages:o,setPaginationLimit:i,readMessage:u,unreadMessage:c,clickMessage:d,archiveMessage:g,openMessage:f,unarchiveMessage:m,readAllMessages:l,inbox:t.inboxDataSet,archive:t.archiveDataSet,unreadCount:t.unreadCount,error:e})};return{shared:e.Courier.shared,auth:h,inbox:M}};
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/utils/utils.tsx","../src/components/courier-client-component.tsx","../src/components/courier-inbox.tsx","../src/components/courier-inbox-popup-menu.tsx","../src/hooks/use-courier.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { createRoot } from \"react-dom/client\";\n\n/**\n * Converts a React node to an HTMLElement.\n * This function uses flushSync to ensure the DOM is updated synchronously.\n * @param node - The React node to convert.\n * @returns The converted HTMLElement.\n */\nexport function reactNodeToHTMLElement(node: ReactNode): HTMLElement {\n const container = document.createElement('div');\n\n // Use React 18 root\n const root = createRoot(container);\n flushSync(() => {\n root.render(node);\n });\n\n // Wait until React mounts the content synchronously\n const element = container.firstElementChild;\n if (!(element instanceof HTMLElement)) {\n throw new Error(\n 'renderListItem must return a single JSX element that renders to an HTMLElement (e.g., <div>)'\n );\n }\n\n return element;\n}","import React, { useState, useEffect } from 'react';\n\ninterface CourierClientProps {\n children: React.ReactNode;\n}\n\n// This class prevents issues with server side rendering react components\n// It will force the component to only render client side\n// A future update could support server side rendering if there is enough demand\nexport const CourierClientComponent: React.FC<CourierClientProps> = ({ children }) => {\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n // During SSR, render nothing or fallback\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (!isMounted) {\n return null;\n }\n\n return <>{children}</>;\n};","import { useRef, useEffect, forwardRef, ReactNode } from \"react\";\nimport { CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxTheme, CourierInbox as CourierInboxElement, CourierInboxHeaderFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxFeedType } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxProps {\n height?: string;\n lightTheme?: CourierInboxTheme;\n darkTheme?: CourierInboxTheme;\n mode?: CourierComponentThemeMode;\n feedType?: CourierInboxFeedType;\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;\n}\n\nexport const CourierInbox = forwardRef<CourierInboxElement, CourierInboxProps>((props, ref) => {\n const inboxRef = useRef<CourierInboxElement | null>(null);\n\n // Expose the internal ref to the parent if a ref was passed in\n useEffect(() => {\n if (typeof ref === \"function\") {\n ref(inboxRef.current);\n } else if (ref) {\n (ref as React.RefObject<CourierInboxElement | null>).current = inboxRef.current;\n }\n }, [ref]);\n\n // Handle message click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, inboxRef]);\n\n // Handle message action click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, inboxRef]);\n\n // Handle message long press\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, inboxRef]);\n\n // Render header\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderHeader) return;\n queueMicrotask(() => {\n inbox.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader, inboxRef]);\n\n // Render list item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderListItem) return;\n queueMicrotask(() => {\n inbox.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem, inboxRef]);\n\n // Render empty state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderEmptyState) return;\n queueMicrotask(() => {\n inbox.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState, inboxRef]);\n\n // Render loading state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderLoadingState) return;\n queueMicrotask(() => {\n inbox.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState, inboxRef]);\n\n // Render error state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderErrorState) return;\n queueMicrotask(() => {\n inbox.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState, inboxRef]);\n\n // Render pagination item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n inbox.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem, inboxRef]);\n\n // Set feed type\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n queueMicrotask(() => {\n inbox.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, inboxRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox\n ref={inboxRef}\n height={props.height}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n});\n\nCourierInbox.displayName = 'CourierInbox';","import { useRef, useEffect, forwardRef, ReactNode } from \"react\";\nimport { CourierInboxFeedType, CourierInboxHeaderFactoryProps, CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxMenuButtonFactoryProps, CourierInboxPopupMenu as CourierInboxPopupMenuElement, CourierInboxPaginationItemFactoryProps, CourierInboxPopupAlignment, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxTheme } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxPopupMenuProps {\n popupAlignment?: CourierInboxPopupAlignment;\n popupWidth?: string;\n popupHeight?: string;\n left?: string;\n top?: string;\n right?: string;\n bottom?: string;\n lightTheme?: CourierInboxTheme;\n darkTheme?: CourierInboxTheme;\n mode?: CourierComponentThemeMode;\n feedType?: CourierInboxFeedType;\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;\n renderMenuButton?: (props: CourierInboxMenuButtonFactoryProps | undefined | null) => ReactNode;\n}\n\nexport const CourierInboxPopupMenu = forwardRef<CourierInboxPopupMenuElement, CourierInboxPopupMenuProps>((props, ref) => {\n const menuRef = useRef<CourierInboxPopupMenuElement>(null);\n\n // Expose the internal ref to the parent if a ref was passed in\n useEffect(() => {\n if (typeof ref === \"function\") {\n ref(menuRef.current);\n } else if (ref) {\n (ref as React.RefObject<CourierInboxPopupMenuElement | null>).current = menuRef.current;\n }\n }, [ref]);\n\n // Handle message click\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, menuRef]);\n\n // Handle message action click\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, menuRef]);\n\n // Handle message long press\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, menuRef]);\n\n // Render header\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderHeader) return;\n queueMicrotask(() => {\n menu.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader, menuRef]);\n\n // Render list item\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderListItem) return;\n queueMicrotask(() => {\n menu.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem, menuRef]);\n\n // Render empty state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderEmptyState) return;\n queueMicrotask(() => {\n menu.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState, menuRef]);\n\n // Render loading state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderLoadingState) return;\n queueMicrotask(() => {\n menu.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState, menuRef]);\n\n // Render error state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderErrorState) return;\n queueMicrotask(() => {\n menu.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState, menuRef]);\n\n // Render pagination item\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n menu.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem, menuRef]);\n\n // Render menu button\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderMenuButton) return;\n queueMicrotask(() => {\n menu.setMenuButton((buttonProps?: CourierInboxMenuButtonFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderMenuButton!(buttonProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderMenuButton, menuRef]);\n\n // Set feed type\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n queueMicrotask(() => {\n menu.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, menuRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox-popup-menu\n ref={menuRef}\n popup-alignment={props.popupAlignment}\n popup-width={props.popupWidth}\n popup-height={props.popupHeight}\n left={props.left}\n top={props.top}\n right={props.right}\n bottom={props.bottom}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n});\n\nCourierInboxPopupMenu.displayName = 'CourierInboxPopupMenu';","import React from 'react';\nimport { Courier, CourierProps, InboxMessage } from '@trycourier/courier-js';\nimport { CourierInboxDatastore, CourierInboxDataStoreListener, CourierInboxFeedType, InboxDataSet } from '@trycourier/courier-ui-inbox';\n\ntype AuthenticationHooks = {\n userId?: string,\n signIn: (props: CourierProps) => void,\n signOut: () => void\n}\n\ntype InboxHooks = {\n load: (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => Promise<void>,\n fetchNextPageOfMessages: (props: { feedType: CourierInboxFeedType }) => Promise<InboxDataSet | null>,\n setPaginationLimit: (limit: number) => void,\n readMessage: (message: InboxMessage) => Promise<void>,\n unreadMessage: (message: InboxMessage) => Promise<void>,\n clickMessage: (message: InboxMessage) => Promise<void>,\n archiveMessage: (message: InboxMessage) => Promise<void>,\n openMessage: (message: InboxMessage) => Promise<void>,\n unarchiveMessage: (message: InboxMessage) => Promise<void>,\n readAllMessages: () => Promise<void>,\n inbox?: InboxDataSet,\n archive?: InboxDataSet,\n unreadCount?: number,\n error?: Error\n}\n\n// A hook for managing the shared state of Courier\n// If you want to use more functions, checkout the Courier JS SDK which\n// can be used directly by importing from '@trycourier/courier-js'\nexport const useCourier = () => {\n\n // Authentication Functions\n const signIn = (props: CourierProps) => Courier.shared.signIn(props);\n const signOut = () => Courier.shared.signOut();\n\n // Inbox Functions\n const loadInbox = (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => CourierInboxDatastore.shared.load(props);\n const fetchNextPageOfMessages = (props: { feedType: CourierInboxFeedType }) => CourierInboxDatastore.shared.fetchNextPageOfMessages(props);\n const setPaginationLimit = (limit: number) => Courier.shared.paginationLimit = limit;\n const readMessage = (message: InboxMessage) => CourierInboxDatastore.shared.readMessage({ message });\n const unreadMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unreadMessage({ message });\n const clickMessage = (message: InboxMessage) => CourierInboxDatastore.shared.clickMessage({ message });\n const archiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.archiveMessage({ message });\n const openMessage = (message: InboxMessage) => CourierInboxDatastore.shared.openMessage({ message });\n const unarchiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unarchiveMessage({ message });\n const readAllMessages = () => CourierInboxDatastore.shared.readAllMessages();\n\n // State\n const [auth, setAuth] = React.useState<AuthenticationHooks>({\n userId: undefined,\n signIn,\n signOut\n });\n\n const [inbox, setInbox] = React.useState<InboxHooks>({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages\n });\n\n React.useEffect(() => {\n\n // Add a listener to the Courier instance\n const listener = Courier.shared.addAuthenticationListener(() => refreshAuth());\n\n // Add inbox data store listener\n const inboxListener = new CourierInboxDataStoreListener({\n onError: (error: Error) => refreshInbox(error),\n onDataSetChange: () => refreshInbox(),\n onPageAdded: () => refreshInbox(),\n onMessageAdd: () => refreshInbox(),\n onMessageRemove: () => refreshInbox(),\n onMessageUpdate: () => refreshInbox(),\n onUnreadCountChange: () => refreshInbox()\n });\n CourierInboxDatastore.shared.addDataStoreListener(inboxListener);\n\n // Set initial values\n refreshAuth();\n refreshInbox();\n\n // Remove listeners when the component unmounts\n return () => {\n listener.remove();\n inboxListener.remove();\n };\n }, []);\n\n const refreshAuth = () => {\n const options = Courier.shared.client?.options;\n setAuth({\n userId: options?.userId,\n signIn,\n signOut\n });\n }\n\n const refreshInbox = (error?: Error) => {\n const datastore = CourierInboxDatastore.shared;\n setInbox({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages,\n inbox: datastore.inboxDataSet,\n archive: datastore.archiveDataSet,\n unreadCount: datastore.unreadCount,\n error: error,\n });\n }\n\n return {\n shared: Courier.shared,\n auth: auth,\n inbox: inbox,\n };\n};\n"],"names":["reactNodeToHTMLElement","node","container","document","createElement","root","createRoot","flushSync","render","element","firstElementChild","HTMLElement","Error","CourierClientComponent","children","isMounted","setIsMounted","useState","useEffect","window","CourierInbox","forwardRef","props","ref","inboxRef","useRef","current","inbox","onMessageClick","onMessageActionClick","onMessageLongPress","renderHeader","queueMicrotask","setHeader","headerProps","renderListItem","setListItem","itemProps","renderEmptyState","setEmptyState","emptyStateProps","renderLoadingState","setLoadingState","loadingStateProps","renderErrorState","setErrorState","errorStateProps","renderPaginationItem","setPaginationItem","paginationProps","setFeedType","feedType","jsx","height","lightTheme","JSON","stringify","darkTheme","mode","displayName","CourierInboxPopupMenu","menuRef","menu","renderMenuButton","setMenuButton","buttonProps","popupAlignment","popupWidth","popupHeight","left","top","right","bottom","signIn","Courier","shared","signOut","loadInbox","CourierInboxDatastore","load","fetchNextPageOfMessages","setPaginationLimit","limit","paginationLimit","readMessage","message","unreadMessage","clickMessage","archiveMessage","openMessage","unarchiveMessage","readAllMessages","auth","setAuth","React","userId","setInbox","listener","addAuthenticationListener","refreshAuth","inboxListener","CourierInboxDataStoreListener","onError","error","refreshInbox","onDataSetChange","onPageAdded","onMessageAdd","onMessageRemove","onMessageUpdate","onUnreadCountChange","addDataStoreListener","remove","options","client","datastore","inboxDataSet","archive","archiveDataSet","unreadCount"],"mappings":"2QAUO,SAASA,EAAuBC,GACrC,MAAMC,EAAYC,SAASC,cAAc,OAGnCC,EAAOC,EAAAA,WAAWJ,GACxBK,EAAAA,WAAU,KACRF,EAAKG,OAAOP,EAAI,IAIlB,MAAMQ,EAAUP,EAAUQ,kBAC1B,KAAMD,aAAmBE,aACvB,MAAM,IAAIC,MACR,gGAIJ,OAAOH,CACT,CCnBO,MAAMI,EAAuD,EAAGC,eACrE,MAAOC,EAAWC,GAAgBC,EAAAA,UAAS,GAO3C,OALAC,EAAAA,WAAU,KACRF,GAAa,EAAI,GAChB,IAGmB,oBAAXG,OACF,KAGJJ,oBAIKD,aAHD,IAGU,ECFRM,EAAeC,EAAAA,YAAmD,CAACC,EAAOC,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GH,MAAO,CACL5B,OAAQD,EAAAA,QAAQC,OAChBiB,OACAjE,QAAA"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/utils/utils.tsx","../src/components/courier-client-component.tsx","../src/components/courier-inbox.tsx","../src/components/courier-inbox-popup-menu.tsx","../src/hooks/use-courier.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { createRoot } from \"react-dom/client\";\n\n/**\n * Converts a React node to an HTMLElement.\n * This function uses flushSync to ensure the DOM is updated synchronously.\n * @param node - The React node to convert.\n * @returns The converted HTMLElement.\n */\nexport function reactNodeToHTMLElement(node: ReactNode): HTMLElement {\n const container = document.createElement('div');\n\n // Use React 18 root\n const root = createRoot(container);\n flushSync(() => {\n root.render(node);\n });\n\n // Wait until React mounts the content synchronously\n const element = container.firstElementChild;\n if (!(element instanceof HTMLElement)) {\n throw new Error(\n 'renderListItem must return a single JSX element that renders to an HTMLElement (e.g., <div>)'\n );\n }\n\n return element;\n}","import React, { useState, useEffect } from 'react';\n\ninterface CourierClientProps {\n children: React.ReactNode;\n}\n\n// This class prevents issues with server side rendering react components\n// It will force the component to only render client side\n// A future update could support server side rendering if there is enough demand\nexport const CourierClientComponent: React.FC<CourierClientProps> = ({ children }) => {\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n // During SSR, render nothing or fallback\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (!isMounted) {\n return null;\n }\n\n return <>{children}</>;\n};","import { useRef, useEffect, forwardRef, ReactNode } from \"react\";\nimport { CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxTheme, CourierInbox as CourierInboxElement, CourierInboxHeaderFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxFeedType } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxProps {\n /** Height of the inbox container. Defaults to \"auto\" and will resize itself based on it's children. */\n height?: string;\n\n /** Theme object for light mode */\n lightTheme?: CourierInboxTheme;\n\n /** Theme object for dark mode */\n darkTheme?: CourierInboxTheme;\n\n /** Theme mode: \"light\", \"dark\", or \"system\". Defaults to \"system\" */\n mode?: CourierComponentThemeMode;\n\n /** Type of feed to display in the inbox (\"inbox\" or \"archive\"). Defaults to \"inbox\" */\n feedType?: CourierInboxFeedType;\n\n /** Callback fired when a message is clicked. */\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n\n /** Callback fired when a message action (e.g., button) is clicked. */\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n\n /** Callback fired when a message is long-pressed (for mobile/gesture support). Only works on devices that support touch. */\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n\n /** Allows you to pass a custom component as the header. */\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the list item. */\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the empty state. */\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the loading state. */\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the error state. */\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the pagination list item. */\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;\n}\n\nexport const CourierInbox = forwardRef<CourierInboxElement, CourierInboxProps>((props, ref) => {\n const inboxRef = useRef<CourierInboxElement | null>(null);\n\n // Expose the internal ref to the parent if a ref was passed in\n useEffect(() => {\n if (typeof ref === \"function\") {\n ref(inboxRef.current);\n } else if (ref) {\n (ref as React.RefObject<CourierInboxElement | null>).current = inboxRef.current;\n }\n }, [ref]);\n\n // Handle message click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, inboxRef]);\n\n // Handle message action click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, inboxRef]);\n\n // Handle message long press\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, inboxRef]);\n\n // Render header\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderHeader) return;\n queueMicrotask(() => {\n inbox.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader, inboxRef]);\n\n // Render list item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderListItem) return;\n queueMicrotask(() => {\n inbox.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem, inboxRef]);\n\n // Render empty state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderEmptyState) return;\n queueMicrotask(() => {\n inbox.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState, inboxRef]);\n\n // Render loading state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderLoadingState) return;\n queueMicrotask(() => {\n inbox.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState, inboxRef]);\n\n // Render error state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderErrorState) return;\n queueMicrotask(() => {\n inbox.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState, inboxRef]);\n\n // Render pagination item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n inbox.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem, inboxRef]);\n\n // Set feed type\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n queueMicrotask(() => {\n inbox.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, inboxRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox\n ref={inboxRef}\n height={props.height}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n});\n\nCourierInbox.displayName = 'CourierInbox';","import { useEffect, useRef, forwardRef, ReactNode } from 'react';\nimport {\n CourierInboxFeedType,\n CourierInboxHeaderFactoryProps,\n CourierInboxListItemActionFactoryProps,\n CourierInboxListItemFactoryProps,\n CourierInboxMenuButtonFactoryProps,\n CourierInboxPopupMenu as CourierInboxPopupMenuElement,\n CourierInboxPaginationItemFactoryProps,\n CourierInboxPopupAlignment,\n CourierInboxStateEmptyFactoryProps,\n CourierInboxStateErrorFactoryProps,\n CourierInboxStateLoadingFactoryProps,\n CourierInboxTheme,\n} from '@trycourier/courier-ui-inbox';\nimport { reactNodeToHTMLElement } from '../utils/utils';\nimport { CourierComponentThemeMode } from '@trycourier/courier-ui-core';\nimport { CourierClientComponent } from './courier-client-component';\n\nexport interface CourierInboxPopupMenuProps {\n /** Alignment of the popup menu: 'top-right', 'top-left', 'top-center', 'bottom-right', 'bottom-left', 'bottom-center', 'center-right', 'center-left', 'center-center'. */\n popupAlignment?: CourierInboxPopupAlignment;\n\n /** Width of the popup menu container. */\n popupWidth?: string;\n\n /** Height of the popup menu container. */\n popupHeight?: string;\n\n /** CSS left position for the popup menu. */\n left?: string;\n\n /** CSS top position for the popup menu. */\n top?: string;\n\n /** CSS right position for the popup menu. */\n right?: string;\n\n /** CSS bottom position for the popup menu. */\n bottom?: string;\n\n /** Theme object for light mode. */\n lightTheme?: CourierInboxTheme;\n\n /** Theme object for dark mode. */\n darkTheme?: CourierInboxTheme;\n\n /** Theme mode: 'light', 'dark', or 'system'. */\n mode?: CourierComponentThemeMode;\n\n /** Type of feed to display in the popup menu ('inbox' or 'archive'). */\n feedType?: CourierInboxFeedType;\n\n /** Callback fired when a message is clicked. */\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n\n /** Callback fired when a message action (e.g., button) is clicked. */\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n\n /** Callback fired when a message is long-pressed (for mobile/gesture support). */\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n\n /** Allows you to pass a custom component as the header. */\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the list item. */\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the empty state. */\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the loading state. */\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the error state. */\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the pagination list item. */\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the menu button. */\n renderMenuButton?: (props: CourierInboxMenuButtonFactoryProps | undefined | null) => ReactNode;\n}\n\nexport const CourierInboxPopupMenu = forwardRef<CourierInboxPopupMenuElement, CourierInboxPopupMenuProps>(\n (props, ref) => {\n // Instead of using useRef and assigning to the custom element,\n // we use a callback ref to ensure the ref is set as soon as the element is mounted.\n function handleRef(el: CourierInboxPopupMenuElement | null) {\n if (ref) {\n if (typeof ref === 'function') {\n ref(el);\n } else {\n (ref as React.RefObject<CourierInboxPopupMenuElement | null>).current = el;\n }\n }\n // Store the element for use in effects\n (handleRef as any)._el = el;\n }\n\n // Helper to get the current element\n function getEl(): CourierInboxPopupMenuElement | null {\n return (handleRef as any)._el ?? null;\n }\n\n // Use a ref to track the last set feedType to prevent duplicate state changes\n const lastFeedTypeRef = useRef<CourierInboxFeedType | undefined>(undefined);\n\n useEffect(() => {\n const menu = getEl();\n if (!menu) return;\n // Only set feedType if it has changed from the last set value\n if (props.feedType !== lastFeedTypeRef.current) {\n lastFeedTypeRef.current = props.feedType;\n queueMicrotask(() => {\n menu.setFeedType?.(props.feedType ?? 'inbox');\n });\n }\n }, [props.feedType]);\n\n // Handle message click\n useEffect(() => {\n const menu = getEl();\n if (!menu) return;\n menu.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick]);\n\n // Handle message action click\n useEffect(() => {\n const menu = getEl();\n if (!menu) return;\n menu.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick]);\n\n // Handle message long press\n useEffect(() => {\n const menu = getEl();\n if (!menu) return;\n menu.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress]);\n\n // Render header\n useEffect(() => {\n const menu = getEl();\n if (!menu || !props.renderHeader) return;\n queueMicrotask(() => {\n menu.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader]);\n\n // Render list item\n useEffect(() => {\n const menu = getEl();\n if (!menu || !props.renderListItem) return;\n queueMicrotask(() => {\n menu.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem]);\n\n // Render empty state\n useEffect(() => {\n const menu = getEl();\n if (!menu || !props.renderEmptyState) return;\n queueMicrotask(() => {\n menu.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState]);\n\n // Render loading state\n useEffect(() => {\n const menu = getEl();\n if (!menu || !props.renderLoadingState) return;\n queueMicrotask(() => {\n menu.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState]);\n\n // Render error state\n useEffect(() => {\n const menu = getEl();\n if (!menu || !props.renderErrorState) return;\n queueMicrotask(() => {\n menu.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState]);\n\n // Render pagination item\n useEffect(() => {\n const menu = getEl();\n if (!menu || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n menu.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem]);\n\n // Render menu button\n useEffect(() => {\n const menu = getEl();\n if (!menu || !props.renderMenuButton) return;\n queueMicrotask(() => {\n menu.setMenuButton((buttonProps?: CourierInboxMenuButtonFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderMenuButton!(buttonProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderMenuButton]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox-popup-menu\n ref={handleRef}\n popup-alignment={props.popupAlignment}\n popup-width={props.popupWidth}\n popup-height={props.popupHeight}\n left={props.left}\n top={props.top}\n right={props.right}\n bottom={props.bottom}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n }\n);\n\nCourierInboxPopupMenu.displayName = 'CourierInboxPopupMenu';","import React from 'react';\nimport { Courier, CourierProps, InboxMessage } from '@trycourier/courier-js';\nimport { CourierInboxDatastore, CourierInboxDataStoreListener, CourierInboxFeedType, InboxDataSet } from '@trycourier/courier-ui-inbox';\n\ntype AuthenticationHooks = {\n userId?: string,\n signIn: (props: CourierProps) => void,\n signOut: () => void\n}\n\ntype InboxHooks = {\n load: (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => Promise<void>,\n fetchNextPageOfMessages: (props: { feedType: CourierInboxFeedType }) => Promise<InboxDataSet | null>,\n setPaginationLimit: (limit: number) => void,\n readMessage: (message: InboxMessage) => Promise<void>,\n unreadMessage: (message: InboxMessage) => Promise<void>,\n clickMessage: (message: InboxMessage) => Promise<void>,\n archiveMessage: (message: InboxMessage) => Promise<void>,\n openMessage: (message: InboxMessage) => Promise<void>,\n unarchiveMessage: (message: InboxMessage) => Promise<void>,\n readAllMessages: () => Promise<void>,\n inbox?: InboxDataSet,\n archive?: InboxDataSet,\n unreadCount?: number,\n error?: Error\n}\n\n// A hook for managing the shared state of Courier\n// If you want to use more functions, checkout the Courier JS SDK which\n// can be used directly by importing from '@trycourier/courier-js'\nexport const useCourier = () => {\n\n // Authentication Functions\n const signIn = (props: CourierProps) => Courier.shared.signIn(props);\n const signOut = () => Courier.shared.signOut();\n\n // Inbox Functions\n const loadInbox = (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => CourierInboxDatastore.shared.load(props);\n const fetchNextPageOfMessages = (props: { feedType: CourierInboxFeedType }) => CourierInboxDatastore.shared.fetchNextPageOfMessages(props);\n const setPaginationLimit = (limit: number) => Courier.shared.paginationLimit = limit;\n const readMessage = (message: InboxMessage) => CourierInboxDatastore.shared.readMessage({ message });\n const unreadMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unreadMessage({ message });\n const clickMessage = (message: InboxMessage) => CourierInboxDatastore.shared.clickMessage({ message });\n const archiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.archiveMessage({ message });\n const openMessage = (message: InboxMessage) => CourierInboxDatastore.shared.openMessage({ message });\n const unarchiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unarchiveMessage({ message });\n const readAllMessages = () => CourierInboxDatastore.shared.readAllMessages();\n\n // State\n const [auth, setAuth] = React.useState<AuthenticationHooks>({\n userId: undefined,\n signIn,\n signOut\n });\n\n const [inbox, setInbox] = React.useState<InboxHooks>({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages\n });\n\n React.useEffect(() => {\n\n // Add a listener to the Courier instance\n const listener = Courier.shared.addAuthenticationListener(() => refreshAuth());\n\n // Add inbox data store listener\n const inboxListener = new CourierInboxDataStoreListener({\n onError: (error: Error) => refreshInbox(error),\n onDataSetChange: () => refreshInbox(),\n onPageAdded: () => refreshInbox(),\n onMessageAdd: () => refreshInbox(),\n onMessageRemove: () => refreshInbox(),\n onMessageUpdate: () => refreshInbox(),\n onUnreadCountChange: () => refreshInbox()\n });\n CourierInboxDatastore.shared.addDataStoreListener(inboxListener);\n\n // Set initial values\n refreshAuth();\n refreshInbox();\n\n // Remove listeners when the component unmounts\n return () => {\n listener.remove();\n inboxListener.remove();\n };\n }, []);\n\n const refreshAuth = () => {\n const options = Courier.shared.client?.options;\n setAuth({\n userId: options?.userId,\n signIn,\n signOut\n });\n }\n\n const refreshInbox = (error?: Error) => {\n const datastore = CourierInboxDatastore.shared;\n setInbox({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages,\n inbox: datastore.inboxDataSet,\n archive: datastore.archiveDataSet,\n unreadCount: datastore.unreadCount,\n error: error,\n });\n }\n\n return {\n shared: Courier.shared,\n auth: auth,\n inbox: inbox,\n };\n};\n"],"names":["reactNodeToHTMLElement","node","container","document","createElement","root","createRoot","flushSync","render","element","firstElementChild","HTMLElement","Error","CourierClientComponent","children","isMounted","setIsMounted","useState","useEffect","window","CourierInbox","forwardRef","props","ref","inboxRef","useRef","current","inbox","onMessageClick","onMessageActionClick","onMessageLongPress","renderHeader","queueMicrotask","setHeader","headerProps","renderListItem","setListItem","itemProps","renderEmptyState","setEmptyState","emptyStateProps","renderLoadingState","setLoadingState","loadingStateProps","renderErrorState","setErrorState","errorStateProps","renderPaginationItem","setPaginationItem","paginationProps","setFeedType","feedType","jsx","height","lightTheme","JSON","stringify","darkTheme","mode","displayName","CourierInboxPopupMenu","handleRef","el","_el","getEl","lastFeedTypeRef","menu","_a","call","renderMenuButton","setMenuButton","buttonProps","popupAlignment","popupWidth","popupHeight","left","top","right","bottom","signIn","Courier","shared","signOut","loadInbox","CourierInboxDatastore","load","fetchNextPageOfMessages","setPaginationLimit","limit","paginationLimit","readMessage","message","unreadMessage","clickMessage","archiveMessage","openMessage","unarchiveMessage","readAllMessages","auth","setAuth","React","userId","setInbox","listener","addAuthenticationListener","refreshAuth","inboxListener","CourierInboxDataStoreListener","onError","error","refreshInbox","onDataSetChange","onPageAdded","onMessageAdd","onMessageRemove","onMessageUpdate","onUnreadCountChange","addDataStoreListener","remove","options","client","datastore","inboxDataSet","archive","archiveDataSet","unreadCount"],"mappings":"2QAUO,SAASA,EAAuBC,GACrC,MAAMC,EAAYC,SAASC,cAAc,OAGnCC,EAAOC,EAAAA,WAAWJ,GACxBK,EAAAA,WAAU,KACRF,EAAKG,OAAOP,EAAI,IAIlB,MAAMQ,EAAUP,EAAUQ,kBAC1B,KAAMD,aAAmBE,aACvB,MAAM,IAAIC,MACR,gGAIJ,OAAOH,CACT,CCnBO,MAAMI,EAAuD,EAAGC,eACrE,MAAOC,EAAWC,GAAgBC,EAAAA,UAAS,GAO3C,OALAC,EAAAA,WAAU,KACRF,GAAa,EAAI,GAChB,IAGmB,oBAAXG,OACF,KAGJJ,oBAIKD,aAHD,IAGU,ECyBRM,EAAeC,EAAAA,YAAmD,CAACC,EAAOC,KACrF,MAAMC,EAAWC,EAAAA,OAAmC,MAiHpD,OA9GAP,EAAAA,WAAU,KACW,mBAARK,EACTA,EAAIC,EAASE,SACJH,IACRA,EAAoDG,QAAUF,EAASE,QAC1E,GACC,CAACH,IAGJL,EAAAA,WAAU,KACR,MAAMS,EAAQH,EAASE,QAClBC,GACLA,EAAMC,eAAeN,EAAMM,eAAc,GACxC,CAACN,EAAMM,eAAgBJ,IAG1BN,EAAAA,WAAU,KACR,MAAMS,EAAQH,EAASE,QAClBC,GACLA,EAAME,qBAAqBP,EAAMO,qBAAoB,GACpD,CAACP,EAAMO,qBAAsBL,IAGhCN,EAAAA,WAAU,KACR,MAAMS,EAAQH,EAASE,QAClBC,GACLA,EAAMG,mBAAmBR,EAAMQ,mBAAkB,GAChD,CAACR,EAAMQ,mBAAoBN,IAG9BN,EAAAA,WAAU,KACR,MAAMS,EAAQH,EAASE,QAClBC,GAAUL,EAAMS,cACrBC,gB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iB,IAAMJ,IACvBK,gBAAiB,IAAML,IACvBM,oBAAqB,IAAMN,MAS7B,OAPA1B,wBAAsBH,OAAOoC,qBAAqBX,GAGlDD,IACAK,IAGO,KACLP,EAASe,SACTZ,EAAcY,QAAA,CAChB,GACC,IAEH,MAAMb,EAAc,WAClB,MAAMc,EAAUvC,OAAAA,EAAAA,EAAAA,QAAQC,OAAOuC,aAAfxC,EAAAA,EAAuBuC,QACvCpB,EAAQ,CACNE,OAAQ,MAAAkB,OAAA,EAAAA,EAASlB,OACjBtB,SACAG,WACD,EAGG4B,EAAgBD,IACpB,MAAMY,EAAYrC,EAAAA,sBAAsBH,OACxCqB,EAAS,CACPjB,KAAMF,EACNG,0BACAC,qBACAG,cACAE,gBACAC,eACAC,iBACAC,cACAC,mBACAC,kBACAtE,MAAO8F,EAAUC,aACjBC,QAASF,EAAUG,eACnBC,YAAaJ,EAAUI,YACvBhB,SACD,EAGH,MAAO,CACL5B,OAAQD,EAAAA,QAAQC,OAChBiB,OACAvE,QAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,4 +6,6 @@ export { markAsRead, markAsUnread, clickMessage, archiveMessage, openMessage } f
|
|
|
6
6
|
export type { CourierInboxHeaderFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxListItemFactoryProps, CourierInboxListItemActionFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxMenuButtonFactoryProps, CourierInboxFeedType } from '@trycourier/courier-ui-inbox';
|
|
7
7
|
export type { CourierInboxTheme, CourierInboxFontTheme, CourierInboxIconTheme, CourierInboxFilterItemTheme, CourierInboxUnreadCountIndicatorTheme, CourierInboxUnreadDotIndicatorTheme, CourierInboxIconButtonTheme, CourierInboxButtonTheme, CourierInboxMenuButtonTheme, CourierInboxPopupTheme, CourierInboxListItemTheme, CourierInboxSkeletonLoadingStateTheme, CourierInboxInfoStateTheme, CourierMenuItemTheme, CourierFilterMenuTheme, CourierActionMenuTheme } from '@trycourier/courier-ui-inbox';
|
|
8
8
|
export { defaultLightTheme, defaultDarkTheme, mergeTheme } from '@trycourier/courier-ui-inbox';
|
|
9
|
+
export type { CourierInbox as CourierInboxElement } from '@trycourier/courier-ui-inbox';
|
|
10
|
+
export type { CourierInboxPopupMenu as CourierInboxPopupMenuElement } from '@trycourier/courier-ui-inbox';
|
|
9
11
|
export type { CourierComponentThemeMode } from '@trycourier/courier-ui-core';
|
package/dist/index.mjs
CHANGED
|
@@ -218,124 +218,136 @@ const CourierInbox = forwardRef((props, ref) => {
|
|
|
218
218
|
) });
|
|
219
219
|
});
|
|
220
220
|
CourierInbox.displayName = "CourierInbox";
|
|
221
|
-
const CourierInboxPopupMenu = forwardRef(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
221
|
+
const CourierInboxPopupMenu = forwardRef(
|
|
222
|
+
(props, ref) => {
|
|
223
|
+
function handleRef(el) {
|
|
224
|
+
if (ref) {
|
|
225
|
+
if (typeof ref === "function") {
|
|
226
|
+
ref(el);
|
|
227
|
+
} else {
|
|
228
|
+
ref.current = el;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
handleRef._el = el;
|
|
228
232
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
233
|
+
function getEl() {
|
|
234
|
+
return handleRef._el ?? null;
|
|
235
|
+
}
|
|
236
|
+
const lastFeedTypeRef = useRef(void 0);
|
|
237
|
+
useEffect(() => {
|
|
238
|
+
const menu = getEl();
|
|
239
|
+
if (!menu) return;
|
|
240
|
+
if (props.feedType !== lastFeedTypeRef.current) {
|
|
241
|
+
lastFeedTypeRef.current = props.feedType;
|
|
242
|
+
queueMicrotask(() => {
|
|
243
|
+
var _a;
|
|
244
|
+
(_a = menu.setFeedType) == null ? void 0 : _a.call(menu, props.feedType ?? "inbox");
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}, [props.feedType]);
|
|
248
|
+
useEffect(() => {
|
|
249
|
+
const menu = getEl();
|
|
250
|
+
if (!menu) return;
|
|
251
|
+
menu.onMessageClick(props.onMessageClick);
|
|
252
|
+
}, [props.onMessageClick]);
|
|
253
|
+
useEffect(() => {
|
|
254
|
+
const menu = getEl();
|
|
255
|
+
if (!menu) return;
|
|
256
|
+
menu.onMessageActionClick(props.onMessageActionClick);
|
|
257
|
+
}, [props.onMessageActionClick]);
|
|
258
|
+
useEffect(() => {
|
|
259
|
+
const menu = getEl();
|
|
260
|
+
if (!menu) return;
|
|
261
|
+
menu.onMessageLongPress(props.onMessageLongPress);
|
|
262
|
+
}, [props.onMessageLongPress]);
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
const menu = getEl();
|
|
265
|
+
if (!menu || !props.renderHeader) return;
|
|
266
|
+
queueMicrotask(() => {
|
|
267
|
+
menu.setHeader((headerProps) => {
|
|
268
|
+
const reactNode = props.renderHeader(headerProps);
|
|
269
|
+
return reactNodeToHTMLElement(reactNode);
|
|
270
|
+
});
|
|
252
271
|
});
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
272
|
+
}, [props.renderHeader]);
|
|
273
|
+
useEffect(() => {
|
|
274
|
+
const menu = getEl();
|
|
275
|
+
if (!menu || !props.renderListItem) return;
|
|
276
|
+
queueMicrotask(() => {
|
|
277
|
+
menu.setListItem((itemProps) => {
|
|
278
|
+
const reactNode = props.renderListItem(itemProps);
|
|
279
|
+
return reactNodeToHTMLElement(reactNode);
|
|
280
|
+
});
|
|
262
281
|
});
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
282
|
+
}, [props.renderListItem]);
|
|
283
|
+
useEffect(() => {
|
|
284
|
+
const menu = getEl();
|
|
285
|
+
if (!menu || !props.renderEmptyState) return;
|
|
286
|
+
queueMicrotask(() => {
|
|
287
|
+
menu.setEmptyState((emptyStateProps) => {
|
|
288
|
+
const reactNode = props.renderEmptyState(emptyStateProps);
|
|
289
|
+
return reactNodeToHTMLElement(reactNode);
|
|
290
|
+
});
|
|
272
291
|
});
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
292
|
+
}, [props.renderEmptyState]);
|
|
293
|
+
useEffect(() => {
|
|
294
|
+
const menu = getEl();
|
|
295
|
+
if (!menu || !props.renderLoadingState) return;
|
|
296
|
+
queueMicrotask(() => {
|
|
297
|
+
menu.setLoadingState((loadingStateProps) => {
|
|
298
|
+
const reactNode = props.renderLoadingState(loadingStateProps);
|
|
299
|
+
return reactNodeToHTMLElement(reactNode);
|
|
300
|
+
});
|
|
282
301
|
});
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
302
|
+
}, [props.renderLoadingState]);
|
|
303
|
+
useEffect(() => {
|
|
304
|
+
const menu = getEl();
|
|
305
|
+
if (!menu || !props.renderErrorState) return;
|
|
306
|
+
queueMicrotask(() => {
|
|
307
|
+
menu.setErrorState((errorStateProps) => {
|
|
308
|
+
const reactNode = props.renderErrorState(errorStateProps);
|
|
309
|
+
return reactNodeToHTMLElement(reactNode);
|
|
310
|
+
});
|
|
292
311
|
});
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
312
|
+
}, [props.renderErrorState]);
|
|
313
|
+
useEffect(() => {
|
|
314
|
+
const menu = getEl();
|
|
315
|
+
if (!menu || !props.renderPaginationItem) return;
|
|
316
|
+
queueMicrotask(() => {
|
|
317
|
+
menu.setPaginationItem((paginationProps) => {
|
|
318
|
+
const reactNode = props.renderPaginationItem(paginationProps);
|
|
319
|
+
return reactNodeToHTMLElement(reactNode);
|
|
320
|
+
});
|
|
302
321
|
});
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
322
|
+
}, [props.renderPaginationItem]);
|
|
323
|
+
useEffect(() => {
|
|
324
|
+
const menu = getEl();
|
|
325
|
+
if (!menu || !props.renderMenuButton) return;
|
|
326
|
+
queueMicrotask(() => {
|
|
327
|
+
menu.setMenuButton((buttonProps) => {
|
|
328
|
+
const reactNode = props.renderMenuButton(buttonProps);
|
|
329
|
+
return reactNodeToHTMLElement(reactNode);
|
|
330
|
+
});
|
|
312
331
|
});
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
bottom: props.bottom,
|
|
333
|
-
"light-theme": props.lightTheme ? JSON.stringify(props.lightTheme) : void 0,
|
|
334
|
-
"dark-theme": props.darkTheme ? JSON.stringify(props.darkTheme) : void 0,
|
|
335
|
-
mode: props.mode
|
|
336
|
-
}
|
|
337
|
-
) });
|
|
338
|
-
});
|
|
332
|
+
}, [props.renderMenuButton]);
|
|
333
|
+
return /* @__PURE__ */ jsx(CourierClientComponent, { children: /* @__PURE__ */ jsx(
|
|
334
|
+
"courier-inbox-popup-menu",
|
|
335
|
+
{
|
|
336
|
+
ref: handleRef,
|
|
337
|
+
"popup-alignment": props.popupAlignment,
|
|
338
|
+
"popup-width": props.popupWidth,
|
|
339
|
+
"popup-height": props.popupHeight,
|
|
340
|
+
left: props.left,
|
|
341
|
+
top: props.top,
|
|
342
|
+
right: props.right,
|
|
343
|
+
bottom: props.bottom,
|
|
344
|
+
"light-theme": props.lightTheme ? JSON.stringify(props.lightTheme) : void 0,
|
|
345
|
+
"dark-theme": props.darkTheme ? JSON.stringify(props.darkTheme) : void 0,
|
|
346
|
+
mode: props.mode
|
|
347
|
+
}
|
|
348
|
+
) });
|
|
349
|
+
}
|
|
350
|
+
);
|
|
339
351
|
CourierInboxPopupMenu.displayName = "CourierInboxPopupMenu";
|
|
340
352
|
export {
|
|
341
353
|
CourierInbox,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/hooks/use-courier.tsx","../src/utils/utils.tsx","../src/components/courier-client-component.tsx","../src/components/courier-inbox.tsx","../src/components/courier-inbox-popup-menu.tsx"],"sourcesContent":["import React from 'react';\nimport { Courier, CourierProps, InboxMessage } from '@trycourier/courier-js';\nimport { CourierInboxDatastore, CourierInboxDataStoreListener, CourierInboxFeedType, InboxDataSet } from '@trycourier/courier-ui-inbox';\n\ntype AuthenticationHooks = {\n userId?: string,\n signIn: (props: CourierProps) => void,\n signOut: () => void\n}\n\ntype InboxHooks = {\n load: (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => Promise<void>,\n fetchNextPageOfMessages: (props: { feedType: CourierInboxFeedType }) => Promise<InboxDataSet | null>,\n setPaginationLimit: (limit: number) => void,\n readMessage: (message: InboxMessage) => Promise<void>,\n unreadMessage: (message: InboxMessage) => Promise<void>,\n clickMessage: (message: InboxMessage) => Promise<void>,\n archiveMessage: (message: InboxMessage) => Promise<void>,\n openMessage: (message: InboxMessage) => Promise<void>,\n unarchiveMessage: (message: InboxMessage) => Promise<void>,\n readAllMessages: () => Promise<void>,\n inbox?: InboxDataSet,\n archive?: InboxDataSet,\n unreadCount?: number,\n error?: Error\n}\n\n// A hook for managing the shared state of Courier\n// If you want to use more functions, checkout the Courier JS SDK which\n// can be used directly by importing from '@trycourier/courier-js'\nexport const useCourier = () => {\n\n // Authentication Functions\n const signIn = (props: CourierProps) => Courier.shared.signIn(props);\n const signOut = () => Courier.shared.signOut();\n\n // Inbox Functions\n const loadInbox = (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => CourierInboxDatastore.shared.load(props);\n const fetchNextPageOfMessages = (props: { feedType: CourierInboxFeedType }) => CourierInboxDatastore.shared.fetchNextPageOfMessages(props);\n const setPaginationLimit = (limit: number) => Courier.shared.paginationLimit = limit;\n const readMessage = (message: InboxMessage) => CourierInboxDatastore.shared.readMessage({ message });\n const unreadMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unreadMessage({ message });\n const clickMessage = (message: InboxMessage) => CourierInboxDatastore.shared.clickMessage({ message });\n const archiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.archiveMessage({ message });\n const openMessage = (message: InboxMessage) => CourierInboxDatastore.shared.openMessage({ message });\n const unarchiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unarchiveMessage({ message });\n const readAllMessages = () => CourierInboxDatastore.shared.readAllMessages();\n\n // State\n const [auth, setAuth] = React.useState<AuthenticationHooks>({\n userId: undefined,\n signIn,\n signOut\n });\n\n const [inbox, setInbox] = React.useState<InboxHooks>({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages\n });\n\n React.useEffect(() => {\n\n // Add a listener to the Courier instance\n const listener = Courier.shared.addAuthenticationListener(() => refreshAuth());\n\n // Add inbox data store listener\n const inboxListener = new CourierInboxDataStoreListener({\n onError: (error: Error) => refreshInbox(error),\n onDataSetChange: () => refreshInbox(),\n onPageAdded: () => refreshInbox(),\n onMessageAdd: () => refreshInbox(),\n onMessageRemove: () => refreshInbox(),\n onMessageUpdate: () => refreshInbox(),\n onUnreadCountChange: () => refreshInbox()\n });\n CourierInboxDatastore.shared.addDataStoreListener(inboxListener);\n\n // Set initial values\n refreshAuth();\n refreshInbox();\n\n // Remove listeners when the component unmounts\n return () => {\n listener.remove();\n inboxListener.remove();\n };\n }, []);\n\n const refreshAuth = () => {\n const options = Courier.shared.client?.options;\n setAuth({\n userId: options?.userId,\n signIn,\n signOut\n });\n }\n\n const refreshInbox = (error?: Error) => {\n const datastore = CourierInboxDatastore.shared;\n setInbox({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages,\n inbox: datastore.inboxDataSet,\n archive: datastore.archiveDataSet,\n unreadCount: datastore.unreadCount,\n error: error,\n });\n }\n\n return {\n shared: Courier.shared,\n auth: auth,\n inbox: inbox,\n };\n};\n","import { ReactNode } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { createRoot } from \"react-dom/client\";\n\n/**\n * Converts a React node to an HTMLElement.\n * This function uses flushSync to ensure the DOM is updated synchronously.\n * @param node - The React node to convert.\n * @returns The converted HTMLElement.\n */\nexport function reactNodeToHTMLElement(node: ReactNode): HTMLElement {\n const container = document.createElement('div');\n\n // Use React 18 root\n const root = createRoot(container);\n flushSync(() => {\n root.render(node);\n });\n\n // Wait until React mounts the content synchronously\n const element = container.firstElementChild;\n if (!(element instanceof HTMLElement)) {\n throw new Error(\n 'renderListItem must return a single JSX element that renders to an HTMLElement (e.g., <div>)'\n );\n }\n\n return element;\n}","import React, { useState, useEffect } from 'react';\n\ninterface CourierClientProps {\n children: React.ReactNode;\n}\n\n// This class prevents issues with server side rendering react components\n// It will force the component to only render client side\n// A future update could support server side rendering if there is enough demand\nexport const CourierClientComponent: React.FC<CourierClientProps> = ({ children }) => {\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n // During SSR, render nothing or fallback\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (!isMounted) {\n return null;\n }\n\n return <>{children}</>;\n};","import { useRef, useEffect, forwardRef, ReactNode } from \"react\";\nimport { CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxTheme, CourierInbox as CourierInboxElement, CourierInboxHeaderFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxFeedType } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxProps {\n height?: string;\n lightTheme?: CourierInboxTheme;\n darkTheme?: CourierInboxTheme;\n mode?: CourierComponentThemeMode;\n feedType?: CourierInboxFeedType;\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;\n}\n\nexport const CourierInbox = forwardRef<CourierInboxElement, CourierInboxProps>((props, ref) => {\n const inboxRef = useRef<CourierInboxElement | null>(null);\n\n // Expose the internal ref to the parent if a ref was passed in\n useEffect(() => {\n if (typeof ref === \"function\") {\n ref(inboxRef.current);\n } else if (ref) {\n (ref as React.RefObject<CourierInboxElement | null>).current = inboxRef.current;\n }\n }, [ref]);\n\n // Handle message click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, inboxRef]);\n\n // Handle message action click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, inboxRef]);\n\n // Handle message long press\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, inboxRef]);\n\n // Render header\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderHeader) return;\n queueMicrotask(() => {\n inbox.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader, inboxRef]);\n\n // Render list item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderListItem) return;\n queueMicrotask(() => {\n inbox.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem, inboxRef]);\n\n // Render empty state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderEmptyState) return;\n queueMicrotask(() => {\n inbox.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState, inboxRef]);\n\n // Render loading state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderLoadingState) return;\n queueMicrotask(() => {\n inbox.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState, inboxRef]);\n\n // Render error state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderErrorState) return;\n queueMicrotask(() => {\n inbox.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState, inboxRef]);\n\n // Render pagination item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n inbox.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem, inboxRef]);\n\n // Set feed type\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n queueMicrotask(() => {\n inbox.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, inboxRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox\n ref={inboxRef}\n height={props.height}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n});\n\nCourierInbox.displayName = 'CourierInbox';","import { useRef, useEffect, forwardRef, ReactNode } from \"react\";\nimport { CourierInboxFeedType, CourierInboxHeaderFactoryProps, CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxMenuButtonFactoryProps, CourierInboxPopupMenu as CourierInboxPopupMenuElement, CourierInboxPaginationItemFactoryProps, CourierInboxPopupAlignment, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxTheme } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxPopupMenuProps {\n popupAlignment?: CourierInboxPopupAlignment;\n popupWidth?: string;\n popupHeight?: string;\n left?: string;\n top?: string;\n right?: string;\n bottom?: string;\n lightTheme?: CourierInboxTheme;\n darkTheme?: CourierInboxTheme;\n mode?: CourierComponentThemeMode;\n feedType?: CourierInboxFeedType;\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;\n renderMenuButton?: (props: CourierInboxMenuButtonFactoryProps | undefined | null) => ReactNode;\n}\n\nexport const CourierInboxPopupMenu = forwardRef<CourierInboxPopupMenuElement, CourierInboxPopupMenuProps>((props, ref) => {\n const menuRef = useRef<CourierInboxPopupMenuElement>(null);\n\n // Expose the internal ref to the parent if a ref was passed in\n useEffect(() => {\n if (typeof ref === \"function\") {\n ref(menuRef.current);\n } else if (ref) {\n (ref as React.RefObject<CourierInboxPopupMenuElement | null>).current = menuRef.current;\n }\n }, [ref]);\n\n // Handle message click\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, menuRef]);\n\n // Handle message action click\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, menuRef]);\n\n // Handle message long press\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n menu.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, menuRef]);\n\n // Render header\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderHeader) return;\n queueMicrotask(() => {\n menu.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader, menuRef]);\n\n // Render list item\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderListItem) return;\n queueMicrotask(() => {\n menu.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem, menuRef]);\n\n // Render empty state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderEmptyState) return;\n queueMicrotask(() => {\n menu.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState, menuRef]);\n\n // Render loading state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderLoadingState) return;\n queueMicrotask(() => {\n menu.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState, menuRef]);\n\n // Render error state\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderErrorState) return;\n queueMicrotask(() => {\n menu.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState, menuRef]);\n\n // Render pagination item\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n menu.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem, menuRef]);\n\n // Render menu button\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu || !props.renderMenuButton) return;\n queueMicrotask(() => {\n menu.setMenuButton((buttonProps?: CourierInboxMenuButtonFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderMenuButton!(buttonProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderMenuButton, menuRef]);\n\n // Set feed type\n useEffect(() => {\n const menu = menuRef.current;\n if (!menu) return;\n queueMicrotask(() => {\n menu.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, menuRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox-popup-menu\n ref={menuRef}\n popup-alignment={props.popupAlignment}\n popup-width={props.popupWidth}\n popup-height={props.popupHeight}\n left={props.left}\n top={props.top}\n right={props.right}\n bottom={props.bottom}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n});\n\nCourierInboxPopupMenu.displayName = 'CourierInboxPopupMenu';"],"names":["clickMessage","archiveMessage","openMessage"],"mappings":";;;;;;;AA8BO,MAAM,aAAa,MAAM;AAG9B,QAAM,SAAS,CAAC,UAAwB,QAAQ,OAAO,OAAO,KAAK;AACn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AAM;AAAA,MACpB,MAAM,MAAM;AAAA,MACZ,KAAK,MAAM;AAAA,MACX,OAAO,MAAM;AAAA,MACb,QAAQ,MAAM;AAAA,MACd,eAAa,MAAM,aAAa,KAAK,UAAU,MAAM,UAAU,IAAI;AAAA,MACnE,cAAY,MAAM,YAAY,KAAK,UAAU,MAAM,SAAS,IAAI;AAAA,MAChE,MAAM,MAAM;AAAA,IAAA;AAAA,EAAA,GAEhB;AAEJ,CAAC;AAED,sBAAsB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/hooks/use-courier.tsx","../src/utils/utils.tsx","../src/components/courier-client-component.tsx","../src/components/courier-inbox.tsx","../src/components/courier-inbox-popup-menu.tsx"],"sourcesContent":["import React from 'react';\nimport { Courier, CourierProps, InboxMessage } from '@trycourier/courier-js';\nimport { CourierInboxDatastore, CourierInboxDataStoreListener, CourierInboxFeedType, InboxDataSet } from '@trycourier/courier-ui-inbox';\n\ntype AuthenticationHooks = {\n userId?: string,\n signIn: (props: CourierProps) => void,\n signOut: () => void\n}\n\ntype InboxHooks = {\n load: (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => Promise<void>,\n fetchNextPageOfMessages: (props: { feedType: CourierInboxFeedType }) => Promise<InboxDataSet | null>,\n setPaginationLimit: (limit: number) => void,\n readMessage: (message: InboxMessage) => Promise<void>,\n unreadMessage: (message: InboxMessage) => Promise<void>,\n clickMessage: (message: InboxMessage) => Promise<void>,\n archiveMessage: (message: InboxMessage) => Promise<void>,\n openMessage: (message: InboxMessage) => Promise<void>,\n unarchiveMessage: (message: InboxMessage) => Promise<void>,\n readAllMessages: () => Promise<void>,\n inbox?: InboxDataSet,\n archive?: InboxDataSet,\n unreadCount?: number,\n error?: Error\n}\n\n// A hook for managing the shared state of Courier\n// If you want to use more functions, checkout the Courier JS SDK which\n// can be used directly by importing from '@trycourier/courier-js'\nexport const useCourier = () => {\n\n // Authentication Functions\n const signIn = (props: CourierProps) => Courier.shared.signIn(props);\n const signOut = () => Courier.shared.signOut();\n\n // Inbox Functions\n const loadInbox = (props?: { feedType: CourierInboxFeedType, canUseCache: boolean }) => CourierInboxDatastore.shared.load(props);\n const fetchNextPageOfMessages = (props: { feedType: CourierInboxFeedType }) => CourierInboxDatastore.shared.fetchNextPageOfMessages(props);\n const setPaginationLimit = (limit: number) => Courier.shared.paginationLimit = limit;\n const readMessage = (message: InboxMessage) => CourierInboxDatastore.shared.readMessage({ message });\n const unreadMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unreadMessage({ message });\n const clickMessage = (message: InboxMessage) => CourierInboxDatastore.shared.clickMessage({ message });\n const archiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.archiveMessage({ message });\n const openMessage = (message: InboxMessage) => CourierInboxDatastore.shared.openMessage({ message });\n const unarchiveMessage = (message: InboxMessage) => CourierInboxDatastore.shared.unarchiveMessage({ message });\n const readAllMessages = () => CourierInboxDatastore.shared.readAllMessages();\n\n // State\n const [auth, setAuth] = React.useState<AuthenticationHooks>({\n userId: undefined,\n signIn,\n signOut\n });\n\n const [inbox, setInbox] = React.useState<InboxHooks>({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages\n });\n\n React.useEffect(() => {\n\n // Add a listener to the Courier instance\n const listener = Courier.shared.addAuthenticationListener(() => refreshAuth());\n\n // Add inbox data store listener\n const inboxListener = new CourierInboxDataStoreListener({\n onError: (error: Error) => refreshInbox(error),\n onDataSetChange: () => refreshInbox(),\n onPageAdded: () => refreshInbox(),\n onMessageAdd: () => refreshInbox(),\n onMessageRemove: () => refreshInbox(),\n onMessageUpdate: () => refreshInbox(),\n onUnreadCountChange: () => refreshInbox()\n });\n CourierInboxDatastore.shared.addDataStoreListener(inboxListener);\n\n // Set initial values\n refreshAuth();\n refreshInbox();\n\n // Remove listeners when the component unmounts\n return () => {\n listener.remove();\n inboxListener.remove();\n };\n }, []);\n\n const refreshAuth = () => {\n const options = Courier.shared.client?.options;\n setAuth({\n userId: options?.userId,\n signIn,\n signOut\n });\n }\n\n const refreshInbox = (error?: Error) => {\n const datastore = CourierInboxDatastore.shared;\n setInbox({\n load: loadInbox,\n fetchNextPageOfMessages,\n setPaginationLimit,\n readMessage,\n unreadMessage,\n clickMessage,\n archiveMessage,\n openMessage,\n unarchiveMessage,\n readAllMessages,\n inbox: datastore.inboxDataSet,\n archive: datastore.archiveDataSet,\n unreadCount: datastore.unreadCount,\n error: error,\n });\n }\n\n return {\n shared: Courier.shared,\n auth: auth,\n inbox: inbox,\n };\n};\n","import { ReactNode } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { createRoot } from \"react-dom/client\";\n\n/**\n * Converts a React node to an HTMLElement.\n * This function uses flushSync to ensure the DOM is updated synchronously.\n * @param node - The React node to convert.\n * @returns The converted HTMLElement.\n */\nexport function reactNodeToHTMLElement(node: ReactNode): HTMLElement {\n const container = document.createElement('div');\n\n // Use React 18 root\n const root = createRoot(container);\n flushSync(() => {\n root.render(node);\n });\n\n // Wait until React mounts the content synchronously\n const element = container.firstElementChild;\n if (!(element instanceof HTMLElement)) {\n throw new Error(\n 'renderListItem must return a single JSX element that renders to an HTMLElement (e.g., <div>)'\n );\n }\n\n return element;\n}","import React, { useState, useEffect } from 'react';\n\ninterface CourierClientProps {\n children: React.ReactNode;\n}\n\n// This class prevents issues with server side rendering react components\n// It will force the component to only render client side\n// A future update could support server side rendering if there is enough demand\nexport const CourierClientComponent: React.FC<CourierClientProps> = ({ children }) => {\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n // During SSR, render nothing or fallback\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (!isMounted) {\n return null;\n }\n\n return <>{children}</>;\n};","import { useRef, useEffect, forwardRef, ReactNode } from \"react\";\nimport { CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxTheme, CourierInbox as CourierInboxElement, CourierInboxHeaderFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateLoadingFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxFeedType } from \"@trycourier/courier-ui-inbox\";\nimport { reactNodeToHTMLElement } from \"../utils/utils\";\nimport { CourierComponentThemeMode } from \"@trycourier/courier-ui-core\";\nimport { CourierClientComponent } from \"./courier-client-component\";\n\nexport interface CourierInboxProps {\n /** Height of the inbox container. Defaults to \"auto\" and will resize itself based on it's children. */\n height?: string;\n\n /** Theme object for light mode */\n lightTheme?: CourierInboxTheme;\n\n /** Theme object for dark mode */\n darkTheme?: CourierInboxTheme;\n\n /** Theme mode: \"light\", \"dark\", or \"system\". Defaults to \"system\" */\n mode?: CourierComponentThemeMode;\n\n /** Type of feed to display in the inbox (\"inbox\" or \"archive\"). Defaults to \"inbox\" */\n feedType?: CourierInboxFeedType;\n\n /** Callback fired when a message is clicked. */\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n\n /** Callback fired when a message action (e.g., button) is clicked. */\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n\n /** Callback fired when a message is long-pressed (for mobile/gesture support). Only works on devices that support touch. */\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n\n /** Allows you to pass a custom component as the header. */\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the list item. */\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the empty state. */\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the loading state. */\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the error state. */\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the pagination list item. */\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;\n}\n\nexport const CourierInbox = forwardRef<CourierInboxElement, CourierInboxProps>((props, ref) => {\n const inboxRef = useRef<CourierInboxElement | null>(null);\n\n // Expose the internal ref to the parent if a ref was passed in\n useEffect(() => {\n if (typeof ref === \"function\") {\n ref(inboxRef.current);\n } else if (ref) {\n (ref as React.RefObject<CourierInboxElement | null>).current = inboxRef.current;\n }\n }, [ref]);\n\n // Handle message click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick, inboxRef]);\n\n // Handle message action click\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick, inboxRef]);\n\n // Handle message long press\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n inbox.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress, inboxRef]);\n\n // Render header\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderHeader) return;\n queueMicrotask(() => {\n inbox.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader, inboxRef]);\n\n // Render list item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderListItem) return;\n queueMicrotask(() => {\n inbox.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem, inboxRef]);\n\n // Render empty state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderEmptyState) return;\n queueMicrotask(() => {\n inbox.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState, inboxRef]);\n\n // Render loading state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderLoadingState) return;\n queueMicrotask(() => {\n inbox.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState, inboxRef]);\n\n // Render error state\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderErrorState) return;\n queueMicrotask(() => {\n inbox.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState, inboxRef]);\n\n // Render pagination item\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n inbox.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem, inboxRef]);\n\n // Set feed type\n useEffect(() => {\n const inbox = inboxRef.current;\n if (!inbox) return;\n queueMicrotask(() => {\n inbox.setFeedType(props.feedType || 'inbox');\n });\n }, [props.feedType, inboxRef]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox\n ref={inboxRef}\n height={props.height}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n});\n\nCourierInbox.displayName = 'CourierInbox';","import { useEffect, useRef, forwardRef, ReactNode } from 'react';\nimport {\n CourierInboxFeedType,\n CourierInboxHeaderFactoryProps,\n CourierInboxListItemActionFactoryProps,\n CourierInboxListItemFactoryProps,\n CourierInboxMenuButtonFactoryProps,\n CourierInboxPopupMenu as CourierInboxPopupMenuElement,\n CourierInboxPaginationItemFactoryProps,\n CourierInboxPopupAlignment,\n CourierInboxStateEmptyFactoryProps,\n CourierInboxStateErrorFactoryProps,\n CourierInboxStateLoadingFactoryProps,\n CourierInboxTheme,\n} from '@trycourier/courier-ui-inbox';\nimport { reactNodeToHTMLElement } from '../utils/utils';\nimport { CourierComponentThemeMode } from '@trycourier/courier-ui-core';\nimport { CourierClientComponent } from './courier-client-component';\n\nexport interface CourierInboxPopupMenuProps {\n /** Alignment of the popup menu: 'top-right', 'top-left', 'top-center', 'bottom-right', 'bottom-left', 'bottom-center', 'center-right', 'center-left', 'center-center'. */\n popupAlignment?: CourierInboxPopupAlignment;\n\n /** Width of the popup menu container. */\n popupWidth?: string;\n\n /** Height of the popup menu container. */\n popupHeight?: string;\n\n /** CSS left position for the popup menu. */\n left?: string;\n\n /** CSS top position for the popup menu. */\n top?: string;\n\n /** CSS right position for the popup menu. */\n right?: string;\n\n /** CSS bottom position for the popup menu. */\n bottom?: string;\n\n /** Theme object for light mode. */\n lightTheme?: CourierInboxTheme;\n\n /** Theme object for dark mode. */\n darkTheme?: CourierInboxTheme;\n\n /** Theme mode: 'light', 'dark', or 'system'. */\n mode?: CourierComponentThemeMode;\n\n /** Type of feed to display in the popup menu ('inbox' or 'archive'). */\n feedType?: CourierInboxFeedType;\n\n /** Callback fired when a message is clicked. */\n onMessageClick?: (props: CourierInboxListItemFactoryProps) => void;\n\n /** Callback fired when a message action (e.g., button) is clicked. */\n onMessageActionClick?: (props: CourierInboxListItemActionFactoryProps) => void;\n\n /** Callback fired when a message is long-pressed (for mobile/gesture support). */\n onMessageLongPress?: (props: CourierInboxListItemFactoryProps) => void;\n\n /** Allows you to pass a custom component as the header. */\n renderHeader?: (props: CourierInboxHeaderFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the list item. */\n renderListItem?: (props: CourierInboxListItemFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the empty state. */\n renderEmptyState?: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the loading state. */\n renderLoadingState?: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the error state. */\n renderErrorState?: (props: CourierInboxStateErrorFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the pagination list item. */\n renderPaginationItem?: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => ReactNode;\n\n /** Allows you to pass a custom component as the menu button. */\n renderMenuButton?: (props: CourierInboxMenuButtonFactoryProps | undefined | null) => ReactNode;\n}\n\nexport const CourierInboxPopupMenu = forwardRef<CourierInboxPopupMenuElement, CourierInboxPopupMenuProps>(\n (props, ref) => {\n // Instead of using useRef and assigning to the custom element,\n // we use a callback ref to ensure the ref is set as soon as the element is mounted.\n function handleRef(el: CourierInboxPopupMenuElement | null) {\n if (ref) {\n if (typeof ref === 'function') {\n ref(el);\n } else {\n (ref as React.RefObject<CourierInboxPopupMenuElement | null>).current = el;\n }\n }\n // Store the element for use in effects\n (handleRef as any)._el = el;\n }\n\n // Helper to get the current element\n function getEl(): CourierInboxPopupMenuElement | null {\n return (handleRef as any)._el ?? null;\n }\n\n // Use a ref to track the last set feedType to prevent duplicate state changes\n const lastFeedTypeRef = useRef<CourierInboxFeedType | undefined>(undefined);\n\n useEffect(() => {\n const menu = getEl();\n if (!menu) return;\n // Only set feedType if it has changed from the last set value\n if (props.feedType !== lastFeedTypeRef.current) {\n lastFeedTypeRef.current = props.feedType;\n queueMicrotask(() => {\n menu.setFeedType?.(props.feedType ?? 'inbox');\n });\n }\n }, [props.feedType]);\n\n // Handle message click\n useEffect(() => {\n const menu = getEl();\n if (!menu) return;\n menu.onMessageClick(props.onMessageClick);\n }, [props.onMessageClick]);\n\n // Handle message action click\n useEffect(() => {\n const menu = getEl();\n if (!menu) return;\n menu.onMessageActionClick(props.onMessageActionClick);\n }, [props.onMessageActionClick]);\n\n // Handle message long press\n useEffect(() => {\n const menu = getEl();\n if (!menu) return;\n menu.onMessageLongPress(props.onMessageLongPress);\n }, [props.onMessageLongPress]);\n\n // Render header\n useEffect(() => {\n const menu = getEl();\n if (!menu || !props.renderHeader) return;\n queueMicrotask(() => {\n menu.setHeader((headerProps?: CourierInboxHeaderFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderHeader!(headerProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderHeader]);\n\n // Render list item\n useEffect(() => {\n const menu = getEl();\n if (!menu || !props.renderListItem) return;\n queueMicrotask(() => {\n menu.setListItem((itemProps?: CourierInboxListItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderListItem!(itemProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderListItem]);\n\n // Render empty state\n useEffect(() => {\n const menu = getEl();\n if (!menu || !props.renderEmptyState) return;\n queueMicrotask(() => {\n menu.setEmptyState((emptyStateProps?: CourierInboxStateEmptyFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderEmptyState!(emptyStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderEmptyState]);\n\n // Render loading state\n useEffect(() => {\n const menu = getEl();\n if (!menu || !props.renderLoadingState) return;\n queueMicrotask(() => {\n menu.setLoadingState((loadingStateProps?: CourierInboxStateLoadingFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderLoadingState!(loadingStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderLoadingState]);\n\n // Render error state\n useEffect(() => {\n const menu = getEl();\n if (!menu || !props.renderErrorState) return;\n queueMicrotask(() => {\n menu.setErrorState((errorStateProps?: CourierInboxStateErrorFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderErrorState!(errorStateProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderErrorState]);\n\n // Render pagination item\n useEffect(() => {\n const menu = getEl();\n if (!menu || !props.renderPaginationItem) return;\n queueMicrotask(() => {\n menu.setPaginationItem((paginationProps?: CourierInboxPaginationItemFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderPaginationItem!(paginationProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderPaginationItem]);\n\n // Render menu button\n useEffect(() => {\n const menu = getEl();\n if (!menu || !props.renderMenuButton) return;\n queueMicrotask(() => {\n menu.setMenuButton((buttonProps?: CourierInboxMenuButtonFactoryProps | undefined | null): HTMLElement => {\n const reactNode = props.renderMenuButton!(buttonProps);\n return reactNodeToHTMLElement(reactNode);\n });\n });\n }, [props.renderMenuButton]);\n\n return (\n <CourierClientComponent>\n {/* @ts-ignore */}\n <courier-inbox-popup-menu\n ref={handleRef}\n popup-alignment={props.popupAlignment}\n popup-width={props.popupWidth}\n popup-height={props.popupHeight}\n left={props.left}\n top={props.top}\n right={props.right}\n bottom={props.bottom}\n light-theme={props.lightTheme ? JSON.stringify(props.lightTheme) : undefined}\n dark-theme={props.darkTheme ? JSON.stringify(props.darkTheme) : undefined}\n mode={props.mode}\n />\n </CourierClientComponent>\n );\n }\n);\n\nCourierInboxPopupMenu.displayName = 'CourierInboxPopupMenu';"],"names":["clickMessage","archiveMessage","openMessage"],"mappings":";;;;;;;AA8BO,MAAM,aAAa,MAAM;AAG9B,QAAM,SAAS,CAAC,UAAwB,QAAQ,OAAO,OAAO,KAAK;AACnE,QAAM,UAAU,MAAM,QAAQ,OAAO,QAAA;AAGrC,QAAM,YAAY,CAAC,UAAqE,sBAAsB,OAAO,KAAK,KAAK;AAC/H,QAAM,0BAA0B,CAAC,UAA8C,sBAAsB,OAAO,wBAAwB,KAAK;AACzI,QAAM,qBAAqB,CAAC,UAAkB,QAAQ,OAAO,kBAAkB;AAC/E,QAAM,cAAc,CAAC,YAA0B,sBAAsB,OAAO,YAAY,EA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Y,KAAK,UAAU,MAAM,SAAS,IAAI;AAAA,QAChE,MAAM,MAAM;AAAA,MAAA;AAAA,IAAA,GAEhB;AAAA,EAEJ;AACF;AAEA,sBAAsB,cAAc;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trycourier/courier-react",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.24-beta",
|
|
4
4
|
"description": "The React components for the Courier web UI",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"author": "Courier",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@trycourier/courier-js": "2.0.
|
|
29
|
+
"@trycourier/courier-js": "2.0.9-beta",
|
|
30
30
|
"@trycourier/courier-ui-core": "1.0.11-beta",
|
|
31
|
-
"@trycourier/courier-ui-inbox": "1.0.
|
|
31
|
+
"@trycourier/courier-ui-inbox": "1.0.14-beta"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": ">=18.0.0",
|