@realtimexsco/live-chat 1.3.4 → 1.4.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.
- package/dist/firebase-messaging-sw.js +68 -0
- package/dist/index.cjs +1268 -292
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +155 -1
- package/dist/index.d.ts +155 -1
- package/dist/index.mjs +1231 -294
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +93 -59
- package/package.json +9 -2
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,103 @@ 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
|
+
interface PushConfig {
|
|
1552
|
+
/** Firebase credentials present on the backend deployment. */
|
|
1553
|
+
configured: boolean;
|
|
1554
|
+
/** Super-admin ceiling AND client admin toggle, resolved. */
|
|
1555
|
+
enabled: boolean;
|
|
1556
|
+
firebaseConfig: Record<string, string> | null;
|
|
1557
|
+
vapidKey: string | null;
|
|
1558
|
+
}
|
|
1559
|
+
interface PushPreference {
|
|
1560
|
+
enabled: boolean;
|
|
1561
|
+
allowedByWorkspace: boolean;
|
|
1562
|
+
deviceCount: number;
|
|
1563
|
+
}
|
|
1564
|
+
declare const apiGetPushConfig: () => Promise<PushConfig>;
|
|
1565
|
+
declare const apiRegisterPushToken: (token: string, deviceLabel?: string) => Promise<any>;
|
|
1566
|
+
declare const apiRemovePushToken: (token: string) => Promise<any>;
|
|
1567
|
+
declare const apiGetPushPreference: () => Promise<PushPreference>;
|
|
1568
|
+
declare const apiUpdatePushPreference: (enabled: boolean) => Promise<any>;
|
|
1569
|
+
declare const isPushSupported: () => boolean;
|
|
1570
|
+
declare const getStoredPushToken: () => string | null;
|
|
1571
|
+
/**
|
|
1572
|
+
* Full device opt-in: browser permission prompt → FCM token → backend
|
|
1573
|
+
* registration. Returns the registered token.
|
|
1574
|
+
*/
|
|
1575
|
+
declare const enablePushOnThisDevice: () => Promise<string>;
|
|
1576
|
+
/** Device opt-out: invalidates the FCM token and removes it server-side. */
|
|
1577
|
+
declare const disablePushOnThisDevice: () => Promise<void>;
|
|
1578
|
+
/**
|
|
1579
|
+
* Foreground messages (tab focused) — FCM does not display these itself.
|
|
1580
|
+
* Returns an unsubscribe function. Typical use: show the in-app toast.
|
|
1581
|
+
*/
|
|
1582
|
+
declare const onForegroundPush: (callback: (payload: {
|
|
1583
|
+
title?: string;
|
|
1584
|
+
body?: string;
|
|
1585
|
+
data?: Record<string, string>;
|
|
1586
|
+
}) => void) => Promise<() => void>;
|
|
1587
|
+
|
|
1588
|
+
interface PushNotificationsState {
|
|
1589
|
+
/** Browser supports service workers + the Push API. */
|
|
1590
|
+
supported: boolean;
|
|
1591
|
+
/** Super-admin ceiling AND client admin toggle allow push. */
|
|
1592
|
+
allowedByWorkspace: boolean;
|
|
1593
|
+
/** Firebase credentials are configured on the backend. */
|
|
1594
|
+
configured: boolean;
|
|
1595
|
+
/** Current browser notification permission. */
|
|
1596
|
+
permission: NotificationPermission | "unsupported";
|
|
1597
|
+
/** The user's account-level preference (mute switch). */
|
|
1598
|
+
userEnabled: boolean;
|
|
1599
|
+
/** This browser has a registered push token. */
|
|
1600
|
+
deviceEnabled: boolean;
|
|
1601
|
+
loading: boolean;
|
|
1602
|
+
error: string | null;
|
|
1603
|
+
}
|
|
1604
|
+
interface UsePushNotifications extends PushNotificationsState {
|
|
1605
|
+
/** Prompt for permission and register this device. */
|
|
1606
|
+
enable: () => Promise<boolean>;
|
|
1607
|
+
/** Unregister this device. */
|
|
1608
|
+
disable: () => Promise<void>;
|
|
1609
|
+
/** Account-level mute switch across all of the user's devices. */
|
|
1610
|
+
setUserEnabled: (enabled: boolean) => Promise<void>;
|
|
1611
|
+
refresh: () => Promise<void>;
|
|
1612
|
+
}
|
|
1613
|
+
/**
|
|
1614
|
+
* Per-user push notification opt-in for the embedded chat.
|
|
1615
|
+
*
|
|
1616
|
+
* Renders no UI itself — pair with PushNotificationToggle or your own
|
|
1617
|
+
* control. Requires setChatBaseURL/setChatClientId/setChatAccessToken to be
|
|
1618
|
+
* configured (same as the rest of the chat).
|
|
1619
|
+
*/
|
|
1620
|
+
declare const usePushNotifications: () => UsePushNotifications;
|
|
1621
|
+
|
|
1622
|
+
interface PushNotificationToggleProps {
|
|
1623
|
+
className?: string;
|
|
1624
|
+
label?: string;
|
|
1625
|
+
description?: string;
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* Drop-in per-user push notification switch. Renders nothing while push is
|
|
1629
|
+
* unsupported by the browser, disabled by the workspace admins, or not yet
|
|
1630
|
+
* configured on the backend — users only ever see a switch they can use.
|
|
1631
|
+
*
|
|
1632
|
+
* On: prompts for browser permission and registers this device.
|
|
1633
|
+
* Off: unregisters this device.
|
|
1634
|
+
*/
|
|
1635
|
+
declare const PushNotificationToggle: ({ className, label, description, }: PushNotificationToggleProps) => React.JSX.Element | null;
|
|
1636
|
+
|
|
1637
|
+
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 PushConfig, PushNotificationToggle, type PushNotificationToggleProps, type PushNotificationsState, type PushPreference, type StarredMessagesDrawerSlotProps, type UIConfig, type UsePushNotifications, type VideoCallButtonSlotProps, apiGetPushConfig, apiGetPushPreference, apiRegisterPushToken, apiRemovePushToken, apiUpdatePushPreference, capitalizeFirst, clampJumpDate, ChatMain as default, defaultChatClassNames, defaultChatComponents, defaultChatFeatures, defaultChatLayoutConfig, disablePushOnThisDevice, downloadFile, enablePushOnThisDevice, getChatBaseUrl, getChatQueryParamApis, getChatQueryParams, getChatQueryParamsByApi, getChatSocketUrl, getFirstAndLastNameOneCharacter, getResponsiveWidth, getSocketConfig, getStoredPushToken, isEmpty, isPushSupported, mergeChatCustomization, mergeChatLayoutConfig, onForegroundPush, 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, usePushNotifications };
|
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,103 @@ 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
|
+
interface PushConfig {
|
|
1552
|
+
/** Firebase credentials present on the backend deployment. */
|
|
1553
|
+
configured: boolean;
|
|
1554
|
+
/** Super-admin ceiling AND client admin toggle, resolved. */
|
|
1555
|
+
enabled: boolean;
|
|
1556
|
+
firebaseConfig: Record<string, string> | null;
|
|
1557
|
+
vapidKey: string | null;
|
|
1558
|
+
}
|
|
1559
|
+
interface PushPreference {
|
|
1560
|
+
enabled: boolean;
|
|
1561
|
+
allowedByWorkspace: boolean;
|
|
1562
|
+
deviceCount: number;
|
|
1563
|
+
}
|
|
1564
|
+
declare const apiGetPushConfig: () => Promise<PushConfig>;
|
|
1565
|
+
declare const apiRegisterPushToken: (token: string, deviceLabel?: string) => Promise<any>;
|
|
1566
|
+
declare const apiRemovePushToken: (token: string) => Promise<any>;
|
|
1567
|
+
declare const apiGetPushPreference: () => Promise<PushPreference>;
|
|
1568
|
+
declare const apiUpdatePushPreference: (enabled: boolean) => Promise<any>;
|
|
1569
|
+
declare const isPushSupported: () => boolean;
|
|
1570
|
+
declare const getStoredPushToken: () => string | null;
|
|
1571
|
+
/**
|
|
1572
|
+
* Full device opt-in: browser permission prompt → FCM token → backend
|
|
1573
|
+
* registration. Returns the registered token.
|
|
1574
|
+
*/
|
|
1575
|
+
declare const enablePushOnThisDevice: () => Promise<string>;
|
|
1576
|
+
/** Device opt-out: invalidates the FCM token and removes it server-side. */
|
|
1577
|
+
declare const disablePushOnThisDevice: () => Promise<void>;
|
|
1578
|
+
/**
|
|
1579
|
+
* Foreground messages (tab focused) — FCM does not display these itself.
|
|
1580
|
+
* Returns an unsubscribe function. Typical use: show the in-app toast.
|
|
1581
|
+
*/
|
|
1582
|
+
declare const onForegroundPush: (callback: (payload: {
|
|
1583
|
+
title?: string;
|
|
1584
|
+
body?: string;
|
|
1585
|
+
data?: Record<string, string>;
|
|
1586
|
+
}) => void) => Promise<() => void>;
|
|
1587
|
+
|
|
1588
|
+
interface PushNotificationsState {
|
|
1589
|
+
/** Browser supports service workers + the Push API. */
|
|
1590
|
+
supported: boolean;
|
|
1591
|
+
/** Super-admin ceiling AND client admin toggle allow push. */
|
|
1592
|
+
allowedByWorkspace: boolean;
|
|
1593
|
+
/** Firebase credentials are configured on the backend. */
|
|
1594
|
+
configured: boolean;
|
|
1595
|
+
/** Current browser notification permission. */
|
|
1596
|
+
permission: NotificationPermission | "unsupported";
|
|
1597
|
+
/** The user's account-level preference (mute switch). */
|
|
1598
|
+
userEnabled: boolean;
|
|
1599
|
+
/** This browser has a registered push token. */
|
|
1600
|
+
deviceEnabled: boolean;
|
|
1601
|
+
loading: boolean;
|
|
1602
|
+
error: string | null;
|
|
1603
|
+
}
|
|
1604
|
+
interface UsePushNotifications extends PushNotificationsState {
|
|
1605
|
+
/** Prompt for permission and register this device. */
|
|
1606
|
+
enable: () => Promise<boolean>;
|
|
1607
|
+
/** Unregister this device. */
|
|
1608
|
+
disable: () => Promise<void>;
|
|
1609
|
+
/** Account-level mute switch across all of the user's devices. */
|
|
1610
|
+
setUserEnabled: (enabled: boolean) => Promise<void>;
|
|
1611
|
+
refresh: () => Promise<void>;
|
|
1612
|
+
}
|
|
1613
|
+
/**
|
|
1614
|
+
* Per-user push notification opt-in for the embedded chat.
|
|
1615
|
+
*
|
|
1616
|
+
* Renders no UI itself — pair with PushNotificationToggle or your own
|
|
1617
|
+
* control. Requires setChatBaseURL/setChatClientId/setChatAccessToken to be
|
|
1618
|
+
* configured (same as the rest of the chat).
|
|
1619
|
+
*/
|
|
1620
|
+
declare const usePushNotifications: () => UsePushNotifications;
|
|
1621
|
+
|
|
1622
|
+
interface PushNotificationToggleProps {
|
|
1623
|
+
className?: string;
|
|
1624
|
+
label?: string;
|
|
1625
|
+
description?: string;
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* Drop-in per-user push notification switch. Renders nothing while push is
|
|
1629
|
+
* unsupported by the browser, disabled by the workspace admins, or not yet
|
|
1630
|
+
* configured on the backend — users only ever see a switch they can use.
|
|
1631
|
+
*
|
|
1632
|
+
* On: prompts for browser permission and registers this device.
|
|
1633
|
+
* Off: unregisters this device.
|
|
1634
|
+
*/
|
|
1635
|
+
declare const PushNotificationToggle: ({ className, label, description, }: PushNotificationToggleProps) => React.JSX.Element | null;
|
|
1636
|
+
|
|
1637
|
+
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 PushConfig, PushNotificationToggle, type PushNotificationToggleProps, type PushNotificationsState, type PushPreference, type StarredMessagesDrawerSlotProps, type UIConfig, type UsePushNotifications, type VideoCallButtonSlotProps, apiGetPushConfig, apiGetPushPreference, apiRegisterPushToken, apiRemovePushToken, apiUpdatePushPreference, capitalizeFirst, clampJumpDate, ChatMain as default, defaultChatClassNames, defaultChatComponents, defaultChatFeatures, defaultChatLayoutConfig, disablePushOnThisDevice, downloadFile, enablePushOnThisDevice, getChatBaseUrl, getChatQueryParamApis, getChatQueryParams, getChatQueryParamsByApi, getChatSocketUrl, getFirstAndLastNameOneCharacter, getResponsiveWidth, getSocketConfig, getStoredPushToken, isEmpty, isPushSupported, mergeChatCustomization, mergeChatLayoutConfig, onForegroundPush, 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, usePushNotifications };
|