@realtimexsco/live-chat 1.3.4 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +980 -292
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +69 -1
- package/dist/index.d.ts +69 -1
- package/dist/index.mjs +955 -294
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +93 -59
- package/package.json +5 -3
package/dist/index.d.mts
CHANGED
|
@@ -4,6 +4,9 @@ import * as zustand_middleware from 'zustand/middleware';
|
|
|
4
4
|
import * as zustand from 'zustand';
|
|
5
5
|
import { ManagerOptions, SocketOptions, Socket } from 'socket.io-client';
|
|
6
6
|
import { Renderable } from 'react-hot-toast';
|
|
7
|
+
import { DayPicker, DayButton } from 'react-day-picker';
|
|
8
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
9
|
+
import { VariantProps } from 'class-variance-authority';
|
|
7
10
|
|
|
8
11
|
interface IChannel {
|
|
9
12
|
id: string;
|
|
@@ -31,6 +34,7 @@ interface IMessage {
|
|
|
31
34
|
content: string;
|
|
32
35
|
sender: string;
|
|
33
36
|
senderId?: string;
|
|
37
|
+
senderImage?: string;
|
|
34
38
|
receiver?: string;
|
|
35
39
|
timestamp: string;
|
|
36
40
|
isOwnMessage: boolean;
|
|
@@ -1222,6 +1226,56 @@ interface ActiveChannelMessagesProps {
|
|
|
1222
1226
|
|
|
1223
1227
|
declare const ActiveChannelMessagesView: (props: ActiveChannelMessagesProps) => React.JSX.Element;
|
|
1224
1228
|
|
|
1229
|
+
/** Presets matching Slack's "Jump to…" menu. */
|
|
1230
|
+
type JumpToPreset = "today" | "yesterday" | "lastWeek" | "lastMonth" | "beginning" | "specific";
|
|
1231
|
+
type PendingJump = {
|
|
1232
|
+
kind: "beginning";
|
|
1233
|
+
} | {
|
|
1234
|
+
kind: "date";
|
|
1235
|
+
at: number;
|
|
1236
|
+
};
|
|
1237
|
+
declare function startOfLocalDay(date: Date): number;
|
|
1238
|
+
/** `yyyy-mm-dd` for `<input type="date" min/max>`. */
|
|
1239
|
+
declare function toDateInputValue(date: Date): string;
|
|
1240
|
+
/**
|
|
1241
|
+
* Clamp a picked day into [minDay, maxDay] (inclusive local midnights).
|
|
1242
|
+
* Returns null if the range is invalid.
|
|
1243
|
+
*/
|
|
1244
|
+
declare function clampJumpDate(picked: Date, minDay: number, maxDay: number): Date | null;
|
|
1245
|
+
/** First selectable day = later of conversation created vs oldest known message. */
|
|
1246
|
+
declare function resolveJumpDateBounds(createdAt: string | undefined, oldestMessageTimestamp: string | undefined, now?: Date): {
|
|
1247
|
+
minDay: number;
|
|
1248
|
+
maxDay: number;
|
|
1249
|
+
};
|
|
1250
|
+
declare function resolveJumpPreset(preset: Exclude<JumpToPreset, "beginning" | "specific">, now?: Date): number;
|
|
1251
|
+
/**
|
|
1252
|
+
* Decide whether to keep loading older messages, or which message id to scroll to.
|
|
1253
|
+
* Messages must be sorted ascending by timestamp.
|
|
1254
|
+
*/
|
|
1255
|
+
declare function resolveJumpStep(messages: Array<{
|
|
1256
|
+
id: string;
|
|
1257
|
+
_id?: string;
|
|
1258
|
+
timestamp: string;
|
|
1259
|
+
}>, pending: PendingJump, hasMore: boolean): {
|
|
1260
|
+
action: "loadOlder";
|
|
1261
|
+
} | {
|
|
1262
|
+
action: "scroll";
|
|
1263
|
+
messageId: string;
|
|
1264
|
+
} | {
|
|
1265
|
+
action: "done";
|
|
1266
|
+
};
|
|
1267
|
+
/** Smoothly scroll a message into the upper-middle of the list container. */
|
|
1268
|
+
declare function smoothScrollToMessage(container: HTMLElement, messageEl: HTMLElement): void;
|
|
1269
|
+
|
|
1270
|
+
type ChatDateJumpMenuProps = {
|
|
1271
|
+
label: string;
|
|
1272
|
+
/** Inclusive local-day bounds for the specific-date picker (ms at local midnight). */
|
|
1273
|
+
minDay: number;
|
|
1274
|
+
maxDay: number;
|
|
1275
|
+
onJump: (preset: JumpToPreset, specificDate?: Date) => void;
|
|
1276
|
+
};
|
|
1277
|
+
declare function ChatDateJumpMenu({ label, minDay, maxDay, onJump }: ChatDateJumpMenuProps): React.JSX.Element;
|
|
1278
|
+
|
|
1225
1279
|
interface ChannelMessageBoxProps {
|
|
1226
1280
|
activeChannel: IChannel | null;
|
|
1227
1281
|
conversationId: string | null;
|
|
@@ -1425,6 +1479,7 @@ interface MessageItemProps {
|
|
|
1425
1479
|
conversationInfo?: any;
|
|
1426
1480
|
isHighlighted?: boolean;
|
|
1427
1481
|
senderName?: string;
|
|
1482
|
+
senderId?: string;
|
|
1428
1483
|
senderImage?: string;
|
|
1429
1484
|
showSenderName?: boolean;
|
|
1430
1485
|
showSenderLabel?: boolean;
|
|
@@ -1480,4 +1535,17 @@ declare function ChatAlertsProvider({ children, value, }: {
|
|
|
1480
1535
|
}): React.JSX.Element;
|
|
1481
1536
|
declare function useChatAlerts(): ChatAlertsContextValue;
|
|
1482
1537
|
|
|
1483
|
-
|
|
1538
|
+
declare const buttonVariants: (props?: ({
|
|
1539
|
+
variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
1540
|
+
size?: "xs" | "sm" | "lg" | "default" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
1541
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
1542
|
+
declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
1543
|
+
asChild?: boolean;
|
|
1544
|
+
}): React.JSX.Element;
|
|
1545
|
+
|
|
1546
|
+
declare function Calendar({ className, classNames, showOutsideDays, captionLayout, buttonVariant, formatters, components, ...props }: React.ComponentProps<typeof DayPicker> & {
|
|
1547
|
+
buttonVariant?: React.ComponentProps<typeof Button>["variant"];
|
|
1548
|
+
}): React.JSX.Element;
|
|
1549
|
+
declare function CalendarDayButton({ className, day, modifiers, ...props }: React.ComponentProps<typeof DayButton>): React.JSX.Element;
|
|
1550
|
+
|
|
1551
|
+
export { type ActiveChannelMessagesSlotProps, type AdminsDrawerSlotProps, type AttachmentsDrawerSlotProps, type AvatarSlotProps, CHAT_API_KEYS, CHAT_GET_API_KEYS, Calendar, CalendarDayButton, Channel, type ChannelDetailsDrawerSlotProps, ChannelHeaderView as ChannelHeader, type ChannelHeaderSlotProps, ChannelListView as ChannelList, ChannelListItem, type ChannelListItemSlotProps, type ChannelListSlotProps, type ChannelMessageBoxSlotProps, Chat, type ChatActionModalSlotProps, ChatAlertsProvider, type ChatApiKey, ChatAvatar, type ChatCallContext, type ChatClassNames, type ChatColorMode, type ChatComponents, type ChatCustomizationConfig, ChatCustomizationProvider, ChatDateJumpMenu, type ChatDateTimePreferences, type ChatFeatures, type ChatGetApiKey, ChatLayout, type ChatLayoutConfig, type ChatLayoutSlotProps, ChatLocaleProvider, ChatMain, type ChatPanelAlertsSlotProps, type ChatQueryParams, type ChatQueryParamsByApi, ChatThemeProvider, ChatViewport, type ChatViewportHeight, DefaultChannelListItem, DefaultChatAvatar, DefaultChatLayout, ForwardModalView as ForwardModal, type ForwardModalSlotProps, HeaderCallActions, type HeaderCallActionsSlotProps, type HeaderLeftSideSlotProps, type HeaderRightSideSlotProps, type HeaderSearchOverlaySlotProps, type IAttachment, type IChannel, type IDMDelete, type IDMEditMessage, type IDMForward, type IDMMessage, type IDMPin, type IDMReaction, type IDMRead, type IDMStar, type IDMTyping, type IDMUnstar, type IMessage, type ISocketConfig, type JumpToPreset, LoggedUserDetails, type LoggedUserDetailsSlotProps, type MembersDrawerSlotProps, type MessageAttachmentsSlotProps, ChannelMessageBoxView as MessageInput, MessageItemView as MessageItem, type MessageItemSlotProps, ActiveChannelMessagesView as MessageList, type MessageReactionsSlotProps, type MessageReplySnippetSlotProps, type MessageStatusSlotProps, type MessageToolbarSlotProps, type PendingJump, type PermissionDrawerSlotProps, type PhoneCallButtonSlotProps, type PinnedMessagesDrawerSlotProps, type StarredMessagesDrawerSlotProps, type UIConfig, type VideoCallButtonSlotProps, capitalizeFirst, clampJumpDate, ChatMain as default, defaultChatClassNames, defaultChatComponents, defaultChatFeatures, defaultChatLayoutConfig, downloadFile, getChatBaseUrl, getChatQueryParamApis, getChatQueryParams, getChatQueryParamsByApi, getChatSocketUrl, getFirstAndLastNameOneCharacter, getResponsiveWidth, getSocketConfig, isEmpty, mergeChatCustomization, mergeChatLayoutConfig, packageDefaultComponents, resolveApiUrl, resolveChatApiKey, resolveJumpDateBounds, resolveJumpPreset, resolveJumpStep, resolveSocketUrl, setChatAccessToken, setChatBaseURL, setChatClientId, setChatQueryParamApis, setChatQueryParams, setChatQueryParamsByApi, setChatSocketUrl, showNotification, smoothScrollToMessage, socketService, startOfLocalDay, toDateInputValue, uniqueList, useChatAlerts, useChatContext, useChatController, useChatCustomization, useChatCustomizationOptional, useChatFeatures, useChatFeaturesOptional, useChatLocale, useStore as useChatStore, useChatTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ import * as zustand_middleware from 'zustand/middleware';
|
|
|
4
4
|
import * as zustand from 'zustand';
|
|
5
5
|
import { ManagerOptions, SocketOptions, Socket } from 'socket.io-client';
|
|
6
6
|
import { Renderable } from 'react-hot-toast';
|
|
7
|
+
import { DayPicker, DayButton } from 'react-day-picker';
|
|
8
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
9
|
+
import { VariantProps } from 'class-variance-authority';
|
|
7
10
|
|
|
8
11
|
interface IChannel {
|
|
9
12
|
id: string;
|
|
@@ -31,6 +34,7 @@ interface IMessage {
|
|
|
31
34
|
content: string;
|
|
32
35
|
sender: string;
|
|
33
36
|
senderId?: string;
|
|
37
|
+
senderImage?: string;
|
|
34
38
|
receiver?: string;
|
|
35
39
|
timestamp: string;
|
|
36
40
|
isOwnMessage: boolean;
|
|
@@ -1222,6 +1226,56 @@ interface ActiveChannelMessagesProps {
|
|
|
1222
1226
|
|
|
1223
1227
|
declare const ActiveChannelMessagesView: (props: ActiveChannelMessagesProps) => React.JSX.Element;
|
|
1224
1228
|
|
|
1229
|
+
/** Presets matching Slack's "Jump to…" menu. */
|
|
1230
|
+
type JumpToPreset = "today" | "yesterday" | "lastWeek" | "lastMonth" | "beginning" | "specific";
|
|
1231
|
+
type PendingJump = {
|
|
1232
|
+
kind: "beginning";
|
|
1233
|
+
} | {
|
|
1234
|
+
kind: "date";
|
|
1235
|
+
at: number;
|
|
1236
|
+
};
|
|
1237
|
+
declare function startOfLocalDay(date: Date): number;
|
|
1238
|
+
/** `yyyy-mm-dd` for `<input type="date" min/max>`. */
|
|
1239
|
+
declare function toDateInputValue(date: Date): string;
|
|
1240
|
+
/**
|
|
1241
|
+
* Clamp a picked day into [minDay, maxDay] (inclusive local midnights).
|
|
1242
|
+
* Returns null if the range is invalid.
|
|
1243
|
+
*/
|
|
1244
|
+
declare function clampJumpDate(picked: Date, minDay: number, maxDay: number): Date | null;
|
|
1245
|
+
/** First selectable day = later of conversation created vs oldest known message. */
|
|
1246
|
+
declare function resolveJumpDateBounds(createdAt: string | undefined, oldestMessageTimestamp: string | undefined, now?: Date): {
|
|
1247
|
+
minDay: number;
|
|
1248
|
+
maxDay: number;
|
|
1249
|
+
};
|
|
1250
|
+
declare function resolveJumpPreset(preset: Exclude<JumpToPreset, "beginning" | "specific">, now?: Date): number;
|
|
1251
|
+
/**
|
|
1252
|
+
* Decide whether to keep loading older messages, or which message id to scroll to.
|
|
1253
|
+
* Messages must be sorted ascending by timestamp.
|
|
1254
|
+
*/
|
|
1255
|
+
declare function resolveJumpStep(messages: Array<{
|
|
1256
|
+
id: string;
|
|
1257
|
+
_id?: string;
|
|
1258
|
+
timestamp: string;
|
|
1259
|
+
}>, pending: PendingJump, hasMore: boolean): {
|
|
1260
|
+
action: "loadOlder";
|
|
1261
|
+
} | {
|
|
1262
|
+
action: "scroll";
|
|
1263
|
+
messageId: string;
|
|
1264
|
+
} | {
|
|
1265
|
+
action: "done";
|
|
1266
|
+
};
|
|
1267
|
+
/** Smoothly scroll a message into the upper-middle of the list container. */
|
|
1268
|
+
declare function smoothScrollToMessage(container: HTMLElement, messageEl: HTMLElement): void;
|
|
1269
|
+
|
|
1270
|
+
type ChatDateJumpMenuProps = {
|
|
1271
|
+
label: string;
|
|
1272
|
+
/** Inclusive local-day bounds for the specific-date picker (ms at local midnight). */
|
|
1273
|
+
minDay: number;
|
|
1274
|
+
maxDay: number;
|
|
1275
|
+
onJump: (preset: JumpToPreset, specificDate?: Date) => void;
|
|
1276
|
+
};
|
|
1277
|
+
declare function ChatDateJumpMenu({ label, minDay, maxDay, onJump }: ChatDateJumpMenuProps): React.JSX.Element;
|
|
1278
|
+
|
|
1225
1279
|
interface ChannelMessageBoxProps {
|
|
1226
1280
|
activeChannel: IChannel | null;
|
|
1227
1281
|
conversationId: string | null;
|
|
@@ -1425,6 +1479,7 @@ interface MessageItemProps {
|
|
|
1425
1479
|
conversationInfo?: any;
|
|
1426
1480
|
isHighlighted?: boolean;
|
|
1427
1481
|
senderName?: string;
|
|
1482
|
+
senderId?: string;
|
|
1428
1483
|
senderImage?: string;
|
|
1429
1484
|
showSenderName?: boolean;
|
|
1430
1485
|
showSenderLabel?: boolean;
|
|
@@ -1480,4 +1535,17 @@ declare function ChatAlertsProvider({ children, value, }: {
|
|
|
1480
1535
|
}): React.JSX.Element;
|
|
1481
1536
|
declare function useChatAlerts(): ChatAlertsContextValue;
|
|
1482
1537
|
|
|
1483
|
-
|
|
1538
|
+
declare const buttonVariants: (props?: ({
|
|
1539
|
+
variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
1540
|
+
size?: "xs" | "sm" | "lg" | "default" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
1541
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
1542
|
+
declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
1543
|
+
asChild?: boolean;
|
|
1544
|
+
}): React.JSX.Element;
|
|
1545
|
+
|
|
1546
|
+
declare function Calendar({ className, classNames, showOutsideDays, captionLayout, buttonVariant, formatters, components, ...props }: React.ComponentProps<typeof DayPicker> & {
|
|
1547
|
+
buttonVariant?: React.ComponentProps<typeof Button>["variant"];
|
|
1548
|
+
}): React.JSX.Element;
|
|
1549
|
+
declare function CalendarDayButton({ className, day, modifiers, ...props }: React.ComponentProps<typeof DayButton>): React.JSX.Element;
|
|
1550
|
+
|
|
1551
|
+
export { type ActiveChannelMessagesSlotProps, type AdminsDrawerSlotProps, type AttachmentsDrawerSlotProps, type AvatarSlotProps, CHAT_API_KEYS, CHAT_GET_API_KEYS, Calendar, CalendarDayButton, Channel, type ChannelDetailsDrawerSlotProps, ChannelHeaderView as ChannelHeader, type ChannelHeaderSlotProps, ChannelListView as ChannelList, ChannelListItem, type ChannelListItemSlotProps, type ChannelListSlotProps, type ChannelMessageBoxSlotProps, Chat, type ChatActionModalSlotProps, ChatAlertsProvider, type ChatApiKey, ChatAvatar, type ChatCallContext, type ChatClassNames, type ChatColorMode, type ChatComponents, type ChatCustomizationConfig, ChatCustomizationProvider, ChatDateJumpMenu, type ChatDateTimePreferences, type ChatFeatures, type ChatGetApiKey, ChatLayout, type ChatLayoutConfig, type ChatLayoutSlotProps, ChatLocaleProvider, ChatMain, type ChatPanelAlertsSlotProps, type ChatQueryParams, type ChatQueryParamsByApi, ChatThemeProvider, ChatViewport, type ChatViewportHeight, DefaultChannelListItem, DefaultChatAvatar, DefaultChatLayout, ForwardModalView as ForwardModal, type ForwardModalSlotProps, HeaderCallActions, type HeaderCallActionsSlotProps, type HeaderLeftSideSlotProps, type HeaderRightSideSlotProps, type HeaderSearchOverlaySlotProps, type IAttachment, type IChannel, type IDMDelete, type IDMEditMessage, type IDMForward, type IDMMessage, type IDMPin, type IDMReaction, type IDMRead, type IDMStar, type IDMTyping, type IDMUnstar, type IMessage, type ISocketConfig, type JumpToPreset, LoggedUserDetails, type LoggedUserDetailsSlotProps, type MembersDrawerSlotProps, type MessageAttachmentsSlotProps, ChannelMessageBoxView as MessageInput, MessageItemView as MessageItem, type MessageItemSlotProps, ActiveChannelMessagesView as MessageList, type MessageReactionsSlotProps, type MessageReplySnippetSlotProps, type MessageStatusSlotProps, type MessageToolbarSlotProps, type PendingJump, type PermissionDrawerSlotProps, type PhoneCallButtonSlotProps, type PinnedMessagesDrawerSlotProps, type StarredMessagesDrawerSlotProps, type UIConfig, type VideoCallButtonSlotProps, capitalizeFirst, clampJumpDate, ChatMain as default, defaultChatClassNames, defaultChatComponents, defaultChatFeatures, defaultChatLayoutConfig, downloadFile, getChatBaseUrl, getChatQueryParamApis, getChatQueryParams, getChatQueryParamsByApi, getChatSocketUrl, getFirstAndLastNameOneCharacter, getResponsiveWidth, getSocketConfig, isEmpty, mergeChatCustomization, mergeChatLayoutConfig, packageDefaultComponents, resolveApiUrl, resolveChatApiKey, resolveJumpDateBounds, resolveJumpPreset, resolveJumpStep, resolveSocketUrl, setChatAccessToken, setChatBaseURL, setChatClientId, setChatQueryParamApis, setChatQueryParams, setChatQueryParamsByApi, setChatSocketUrl, showNotification, smoothScrollToMessage, socketService, startOfLocalDay, toDateInputValue, uniqueList, useChatAlerts, useChatContext, useChatController, useChatCustomization, useChatCustomizationOptional, useChatFeatures, useChatFeaturesOptional, useChatLocale, useStore as useChatStore, useChatTheme };
|