@college-africa/chat-ui 1.1.1 → 1.2.1

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.
@@ -1,12 +1,8 @@
1
1
  import { default as React } from 'react';
2
- import { ChatClientConfig } from 'sdk';
2
+ import { ChatClientConfig } from '@college-africa/chat-sdk';
3
3
  export interface ChatAppProps {
4
4
  /** SDK configuration */
5
5
  config: ChatClientConfig;
6
- /** Authentication token (optional, can be set later via SDK) */
7
- token?: string;
8
- /** Token fetcher function (alternative to token prop) */
9
- getToken?: () => Promise<string>;
10
6
  /** Child components to render when SDK is ready */
11
7
  children: React.ReactNode;
12
8
  /** Custom loading component */
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { ConversationSummary } from 'sdk';
2
+ import { ConversationSummary } from '@college-africa/chat-sdk';
3
3
  export interface ConversationItemProps {
4
4
  /** Conversation summary data */
5
5
  conversation: ConversationSummary;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { Message } from 'sdk';
2
+ import { Message } from '@college-africa/chat-sdk';
3
3
  export interface MessageBubbleProps {
4
4
  /** The message to display */
5
5
  message: Message;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { Message } from 'sdk';
2
+ import { Message } from '@college-africa/chat-sdk';
3
3
  export interface MessageListProps {
4
4
  /** List of messages to display */
5
5
  messages: Message[];
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { User } from 'sdk';
2
+ import { User } from '@college-africa/chat-sdk';
3
3
  interface UserAutocompleteProps {
4
4
  multiple?: boolean;
5
5
  formik?: any;
@@ -1,3 +1,3 @@
1
- import { Message } from 'sdk';
1
+ import { Message } from '@college-africa/chat-sdk';
2
2
  /** Get a map of <userid, username> for message senders */
3
3
  export declare function useSenderNames(messages: Message[]): Map<number, string>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Hook to reactively compute total unread message count
3
+ *
4
+ * Uses IndexedDB via Dexie as the single source of truth
5
+ */
6
+ /**
7
+ * useUnreadCount - Hook for tracking total unread messages across all conversations
8
+ *
9
+ * Returns the total unread message count from the summaries table
10
+ * Updates automatically when unread counts change
11
+ */
12
+ export declare function useUnreadCount(): number | undefined;
@@ -0,0 +1,19 @@
1
+ import { WSMessage } from '@college-africa/chat-sdk';
2
+ export interface UseWebSocketParams {
3
+ /** Callback when a message is received */
4
+ onMessage?: (message: WSMessage) => void;
5
+ /** Callback when WebSocket connection opens */
6
+ onConnect?: () => void;
7
+ /** Callback when WebSocket connection closes */
8
+ onDisconnect?: () => void;
9
+ /** Callback when WebSocket error occurs */
10
+ onError?: (error: Error) => void;
11
+ }
12
+ /**
13
+ * Hook for tracking WebSocket connection status
14
+ * and for adding events to websocket connection changes
15
+ * Returns connection status for UI indicators
16
+ */
17
+ export declare function useWebSocket({ onMessage, onConnect, onDisconnect, onError }?: UseWebSocketParams): {
18
+ isConnected: boolean;
19
+ };
package/dist/index.d.ts CHANGED
@@ -30,14 +30,15 @@ export { ConversationItemSkeleton } from './components/ConversationItemSkeleton'
30
30
  export { MessageSkeleton } from './components/MessageSkeleton';
31
31
  export type { MessageSkeletonProps } from './components/MessageSkeleton';
32
32
  export { initSDK, getSDK, disconnectSDK, isSDKInitialized } from './utils/sdk';
33
- export { groupMessages, shouldGroupMessages } from './utils/messages';
33
+ export { fetchSummaries } from './utils/summaries';
34
34
  export { db } from './utils/db';
35
35
  export type { MessageGroup } from './utils/messages';
36
36
  export { useMessages } from './hooks/useMessages';
37
37
  export type { UseMessagesParams } from './hooks/useMessages';
38
- export { useWebSocketMessages } from './hooks/useWebSocketMessages';
39
- export type { UseWebSocketMessagesParams } from './hooks/useWebSocketMessages';
38
+ export { useWebSocket } from './hooks/useWebSocket';
39
+ export type { UseWebSocketParams } from './hooks/useWebSocket';
40
40
  export { useSenderNames } from './hooks/useSenderNames';
41
+ export { useUnreadCount } from './hooks/useUnreadCount';
41
42
  export { CACHE_TTL } from './hooks/constants';
42
43
  export type { User, Message, Group, ConversationSummary, ChatRole, Cursor, MessagePage, ConnectionState, Conversation } from './types';
43
44
  export { theme, getTheme } from './utils/theme';