@poolse/react-ui 3.7.0 → 3.8.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/CHANGELOG.md +35 -0
- package/README.md +33 -0
- package/dist/index.cjs +497 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +194 -7
- package/dist/index.d.ts +194 -7
- package/dist/index.js +490 -83
- package/dist/index.js.map +1 -1
- package/dist/styles.css +136 -9
- package/package.json +5 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { CallParticipant, CallDevice, CallDeviceKind, Message, Uuid, LiveCall, Conversation, PresenceState, Presence, Membership, Attachment, LinkPreview, MessageCreateRequest } from '@poolse/sdk';
|
|
2
|
+
import { CallParticipant, CallDevice, CallDeviceKind, Message, Poolse, Uuid, LiveCall, Conversation, PresenceState, Presence, Membership, Attachment, LinkPreview, MessageCreateRequest } from '@poolse/sdk';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { SVGProps, ReactElement, ReactNode, CSSProperties } from 'react';
|
|
5
5
|
import { GroupPosition, UseRoom, UploadItem, ReactionMap } from '@poolse/react';
|
|
@@ -356,6 +356,95 @@ interface ConversationDraft {
|
|
|
356
356
|
}
|
|
357
357
|
/** `window.localStorage`, every call guarded (private mode, blocked storage, SSR). */
|
|
358
358
|
declare const localDraftStorage: DraftStorage;
|
|
359
|
+
/**
|
|
360
|
+
* One client's drafts: held in memory for the page (so switching
|
|
361
|
+
* conversations, or workspaces, and back finds them) and written to a
|
|
362
|
+
* storage under the client's namespace (server + user), so two
|
|
363
|
+
* workspaces never see each other's drafts. Cleared from storage by
|
|
364
|
+
* `chat.destroy({ clearStorage: true })`.
|
|
365
|
+
*/
|
|
366
|
+
declare class DraftScope {
|
|
367
|
+
private readonly namespace;
|
|
368
|
+
private readonly memory;
|
|
369
|
+
/** Storages written to, and the keys written to each. */
|
|
370
|
+
private readonly written;
|
|
371
|
+
constructor(namespace: () => string | null);
|
|
372
|
+
/** The storage key for a conversation's draft; null until the namespace is known. */
|
|
373
|
+
key(conversationId: string): string | null;
|
|
374
|
+
/** The draft for `key`: from memory, else from `storage` (else from `legacyKey`, moved over). */
|
|
375
|
+
read(storage: DraftStorage, key: string, legacyKey?: string): ConversationDraft | null | Promise<ConversationDraft | null>;
|
|
376
|
+
/** Save (or, when empty, drop) the draft for `key`. */
|
|
377
|
+
write(storage: DraftStorage, key: string, draft: ConversationDraft): void;
|
|
378
|
+
clear(storage: DraftStorage, key: string): void;
|
|
379
|
+
/** Called by `chat.destroy()`. @internal */
|
|
380
|
+
destroy(opts: {
|
|
381
|
+
clearStorage: boolean;
|
|
382
|
+
}): Promise<void>;
|
|
383
|
+
private track;
|
|
384
|
+
}
|
|
385
|
+
/** The drafts of one client (made on first use, dropped with it). */
|
|
386
|
+
declare function draftsOf(chat: Poolse): DraftScope;
|
|
387
|
+
|
|
388
|
+
/** One shortcut, e.g. `'Mod+Enter'`, `'Escape'`, `'j'`. */
|
|
389
|
+
type KeyBinding = string;
|
|
390
|
+
interface ComposerKeymap {
|
|
391
|
+
/** Send the message. Default `Enter` and `Mod+Enter`. */
|
|
392
|
+
send: KeyBinding[];
|
|
393
|
+
/** Insert a new line. Default `Shift+Enter`. */
|
|
394
|
+
newline: KeyBinding[];
|
|
395
|
+
/** In an empty composer: edit your last message. Default `ArrowUp`. */
|
|
396
|
+
editLast: KeyBinding[];
|
|
397
|
+
/** Cancel the reply being composed (or an edit). Default `Escape`. */
|
|
398
|
+
cancel: KeyBinding[];
|
|
399
|
+
}
|
|
400
|
+
interface MessageListKeymap {
|
|
401
|
+
/** Focus the next (newer) message. Default `j`, `ArrowDown`. */
|
|
402
|
+
next: KeyBinding[];
|
|
403
|
+
/** Focus the previous (older) message. Default `k`, `ArrowUp`. */
|
|
404
|
+
prev: KeyBinding[];
|
|
405
|
+
/** Focus the newest message. Default `End`. */
|
|
406
|
+
last: KeyBinding[];
|
|
407
|
+
/** Focus the oldest loaded message. Default `Home`. */
|
|
408
|
+
first: KeyBinding[];
|
|
409
|
+
/** Quote-reply to the focused message. Default `r`. */
|
|
410
|
+
reply: KeyBinding[];
|
|
411
|
+
/** Open the focused message's thread. Default `t`. */
|
|
412
|
+
thread: KeyBinding[];
|
|
413
|
+
/** Edit the focused message (yours). Default `e`. */
|
|
414
|
+
edit: KeyBinding[];
|
|
415
|
+
/** Delete the focused message (yours), after a confirmation. Default `Delete`, `Backspace`. */
|
|
416
|
+
delete: KeyBinding[];
|
|
417
|
+
/** Back to the composer. Default `Escape`. */
|
|
418
|
+
composer: KeyBinding[];
|
|
419
|
+
}
|
|
420
|
+
interface PoolseKeymap {
|
|
421
|
+
composer: ComposerKeymap;
|
|
422
|
+
messageList: MessageListKeymap;
|
|
423
|
+
}
|
|
424
|
+
/** Overrides: any binding list replaces the default one; `[]` turns a shortcut off. */
|
|
425
|
+
interface PoolseKeymapOverrides {
|
|
426
|
+
composer?: Partial<ComposerKeymap>;
|
|
427
|
+
messageList?: Partial<MessageListKeymap>;
|
|
428
|
+
}
|
|
429
|
+
declare const DEFAULT_KEYMAP: PoolseKeymap;
|
|
430
|
+
/**
|
|
431
|
+
* The keymap with `sendOn: 'mod+enter'`: Enter makes a new line and
|
|
432
|
+
* Cmd/Ctrl+Enter sends — for teams that write long messages.
|
|
433
|
+
*/
|
|
434
|
+
declare const MOD_ENTER_COMPOSER: Pick<ComposerKeymap, 'send' | 'newline'>;
|
|
435
|
+
/** The default keymap with `overrides` (and the send mode) applied. */
|
|
436
|
+
declare function resolveKeymap(overrides?: PoolseKeymapOverrides, sendOn?: 'enter' | 'mod+enter'): PoolseKeymap;
|
|
437
|
+
interface KeyLike {
|
|
438
|
+
key: string;
|
|
439
|
+
metaKey: boolean;
|
|
440
|
+
ctrlKey: boolean;
|
|
441
|
+
altKey: boolean;
|
|
442
|
+
shiftKey: boolean;
|
|
443
|
+
}
|
|
444
|
+
/** Whether a keyboard event is `binding`. */
|
|
445
|
+
declare function matchesKey(e: KeyLike, binding: KeyBinding): boolean;
|
|
446
|
+
/** Whether a keyboard event is any of `bindings`. */
|
|
447
|
+
declare function matchesAny(e: KeyLike, bindings: ReadonlyArray<KeyBinding>): boolean;
|
|
359
448
|
|
|
360
449
|
/**
|
|
361
450
|
* Position of this bubble within a same-sender, same-day, ≤5-min
|
|
@@ -527,8 +616,37 @@ interface RenderMessageContext {
|
|
|
527
616
|
|
|
528
617
|
interface ConversationViewProps {
|
|
529
618
|
conversationId: Uuid;
|
|
530
|
-
/**
|
|
531
|
-
|
|
619
|
+
/**
|
|
620
|
+
* What an empty conversation shows. Defaults to "No messages yet"
|
|
621
|
+
* with a hint to write the first one (or none, read-only). A
|
|
622
|
+
* function receives `{ readOnly }`.
|
|
623
|
+
*/
|
|
624
|
+
emptyState?: ReactNode | ((ctx: {
|
|
625
|
+
readOnly: boolean;
|
|
626
|
+
}) => ReactNode);
|
|
627
|
+
/**
|
|
628
|
+
* Keyboard shortcuts, scoped to this view (an app's own shortcuts
|
|
629
|
+
* never collide). Composer: Enter sends (see `sendOn`), Shift+Enter
|
|
630
|
+
* makes a new line, ↑ in an empty composer edits your last message,
|
|
631
|
+
* Esc cancels a reply. Message list (focus it with Tab or a click):
|
|
632
|
+
* j / k or ↓ / ↑ move between messages, Home / End jump, r replies,
|
|
633
|
+
* t opens the thread, e edits, Delete deletes (yours, after a
|
|
634
|
+
* confirm), Esc goes back to the composer. Override any binding;
|
|
635
|
+
* `[]` turns one off. See `DEFAULT_KEYMAP`.
|
|
636
|
+
*/
|
|
637
|
+
keymap?: PoolseKeymapOverrides;
|
|
638
|
+
/**
|
|
639
|
+
* `'enter'` (default): Enter sends, Shift+Enter is a new line.
|
|
640
|
+
* `'mod+enter'`: Enter is a new line, Cmd/Ctrl+Enter sends.
|
|
641
|
+
*/
|
|
642
|
+
sendOn?: 'enter' | 'mod+enter';
|
|
643
|
+
/** The message-list shortcuts (j / k / r / t / e / Delete). Defaults to `true`. */
|
|
644
|
+
keyboardShortcuts?: boolean;
|
|
645
|
+
/**
|
|
646
|
+
* Asked before the Delete shortcut deletes a message. Defaults to
|
|
647
|
+
* `window.confirm`. Return false to keep it.
|
|
648
|
+
*/
|
|
649
|
+
confirmDelete?: (message: Message) => boolean | Promise<boolean>;
|
|
532
650
|
/**
|
|
533
651
|
* Render-prop escape hatch for individual messages. When set,
|
|
534
652
|
* COMPLETELY overrides the default per-message rendering — you
|
|
@@ -727,7 +845,7 @@ interface ConversationViewProps {
|
|
|
727
845
|
*/
|
|
728
846
|
draftStorage?: DraftStorage;
|
|
729
847
|
}
|
|
730
|
-
declare function ConversationView({ conversationId, emptyState, renderMessage, labelFor, loadFonts, reactions, mentions, attachments, maxFileSize, acceptFileTypes, emojiPicker, actions, threads, quotations, readReceipts, linkPreviews, markdown, maxBodyLength, grouping, groupingWindowMs, groupWindowMinutes, layout, density, showAvatars, showPresence, timeFormat, slots, daySeparators, senderLabels, avatars, onMarkedRead, focusMessageId, onFocusMessageNotFound, onSenderPress, onAvatarPress, composer, readOnly, onCallBack, onJoinCall, currentCallId, persistDrafts, draftStorage, }: ConversationViewProps): react_jsx_runtime.JSX.Element;
|
|
848
|
+
declare function ConversationView({ conversationId, emptyState, renderMessage, labelFor, loadFonts, reactions, mentions, attachments, maxFileSize, acceptFileTypes, emojiPicker, actions, threads, quotations, readReceipts, linkPreviews, markdown, maxBodyLength, grouping, groupingWindowMs, groupWindowMinutes, layout, density, showAvatars, showPresence, timeFormat, slots, daySeparators, senderLabels, avatars, onMarkedRead, focusMessageId, onFocusMessageNotFound, onSenderPress, onAvatarPress, composer, readOnly, onCallBack, onJoinCall, currentCallId, persistDrafts, draftStorage, keymap: keymapOverrides, sendOn, keyboardShortcuts, confirmDelete, }: ConversationViewProps): react_jsx_runtime.JSX.Element;
|
|
731
849
|
|
|
732
850
|
interface ChatHeaderProps {
|
|
733
851
|
/** Conversation id — used to fetch the row + members for the title / presence dot. */
|
|
@@ -756,6 +874,40 @@ interface ChatHeaderProps {
|
|
|
756
874
|
}
|
|
757
875
|
declare function ChatHeader({ conversationId, labelFor, avatarFor, onBack, onPress, onMembersPress, rightSlot, showPresence, }: ChatHeaderProps): react_jsx_runtime.JSX.Element;
|
|
758
876
|
|
|
877
|
+
interface EmptyStateProps {
|
|
878
|
+
/** What's empty, in a few words: "No messages yet". */
|
|
879
|
+
title: ReactNode;
|
|
880
|
+
/** What to do next: "Say hello — your message starts the conversation." */
|
|
881
|
+
hint?: ReactNode;
|
|
882
|
+
/** A button or link for the next step. */
|
|
883
|
+
action?: ReactNode;
|
|
884
|
+
className?: string;
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* An empty screen that says what to do next. The components use it for
|
|
888
|
+
* their defaults (an empty conversation list, an empty channel, a search
|
|
889
|
+
* with no results); pass your own `emptyState` to any of them to
|
|
890
|
+
* replace it, or use this to keep the look.
|
|
891
|
+
*/
|
|
892
|
+
declare function EmptyState({ title, hint, action, className }: EmptyStateProps): react_jsx_runtime.JSX.Element;
|
|
893
|
+
|
|
894
|
+
interface SendStatusProps {
|
|
895
|
+
message: Message;
|
|
896
|
+
/** Send it again (failed or queued). */
|
|
897
|
+
onRetry?: () => void;
|
|
898
|
+
/** Drop the unsent message. */
|
|
899
|
+
onDiscard?: () => void;
|
|
900
|
+
/** Align with the bubble: right for your own messages. */
|
|
901
|
+
align?: 'left' | 'right';
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Under an unsent message: "Waiting for network…" while it's queued
|
|
905
|
+
* offline (it goes out by itself on reconnect), or "Not sent" with
|
|
906
|
+
* Retry and Delete when the server refused it. Nothing for a message
|
|
907
|
+
* that's on its way or sent.
|
|
908
|
+
*/
|
|
909
|
+
declare function SendStatus({ message, onRetry, onDiscard, align }: SendStatusProps): react_jsx_runtime.JSX.Element | null;
|
|
910
|
+
|
|
759
911
|
/** Minimal user shape the picker renders. Matches the RN InboxUser. */
|
|
760
912
|
interface InboxUser {
|
|
761
913
|
externalId: string;
|
|
@@ -969,6 +1121,18 @@ interface MessageComposerProps {
|
|
|
969
1121
|
* extensions (`'.pdf'`). Other files show an error chip instead.
|
|
970
1122
|
*/
|
|
971
1123
|
acceptFileTypes?: string[];
|
|
1124
|
+
/**
|
|
1125
|
+
* Composer shortcuts (send, new line, edit last, cancel) — see
|
|
1126
|
+
* `ComposerKeymap`. Defaults: Enter / Cmd+Enter send, Shift+Enter new
|
|
1127
|
+
* line, ↑ in an empty composer edits your last message, Esc cancels
|
|
1128
|
+
* the reply.
|
|
1129
|
+
*/
|
|
1130
|
+
keymap?: ComposerKeymap;
|
|
1131
|
+
/**
|
|
1132
|
+
* ↑ in an empty composer: edit your last message. Return `false`
|
|
1133
|
+
* when there's none to edit (the caret then moves as usual).
|
|
1134
|
+
*/
|
|
1135
|
+
onEditLast?: () => boolean | void;
|
|
972
1136
|
}
|
|
973
1137
|
/**
|
|
974
1138
|
* Imperative handle exposed via `ref` for parents that want to forward
|
|
@@ -1171,8 +1335,19 @@ interface ConversationListProps {
|
|
|
1171
1335
|
onSelect?: (conv: Conversation) => void;
|
|
1172
1336
|
/** Optional override for each row's rendering. */
|
|
1173
1337
|
renderItem?: (conv: Conversation, selected: boolean) => ReactNode;
|
|
1174
|
-
/**
|
|
1338
|
+
/**
|
|
1339
|
+
* What an empty list shows. Defaults to "No conversations yet" with a
|
|
1340
|
+
* hint at the next step.
|
|
1341
|
+
*/
|
|
1175
1342
|
emptyState?: ReactNode;
|
|
1343
|
+
/**
|
|
1344
|
+
* Show only conversations matching this text (name, the other
|
|
1345
|
+
* person in a direct chat via `labelFor`, the last message). For a
|
|
1346
|
+
* search field in `header`. Empty = everything.
|
|
1347
|
+
*/
|
|
1348
|
+
query?: string;
|
|
1349
|
+
/** What shows when `query` matches nothing. Receives the query. */
|
|
1350
|
+
noResultsState?: ReactNode | ((query: string) => ReactNode);
|
|
1176
1351
|
/**
|
|
1177
1352
|
* Controlled mode — when provided, render from these props instead
|
|
1178
1353
|
* of calling `useConversations()` internally. Lets parent components
|
|
@@ -1235,7 +1410,7 @@ interface ConversationListSection {
|
|
|
1235
1410
|
title: string;
|
|
1236
1411
|
filter: (conversation: Conversation) => boolean;
|
|
1237
1412
|
}
|
|
1238
|
-
declare function ConversationList({ selectedId, onSelect, renderItem, emptyState, conversations: controlledConversations, loading: controlledLoading, error: controlledError, unreadCounts, labelFor, avatarFor, showPresence, density, sections, groupBy, header, hasMore: controlledHasMore, loadingMore: controlledLoadingMore, onLoadMore, }: ConversationListProps): react_jsx_runtime.JSX.Element;
|
|
1413
|
+
declare function ConversationList({ selectedId, onSelect, renderItem, emptyState, query, noResultsState, conversations: controlledConversations, loading: controlledLoading, error: controlledError, unreadCounts, labelFor, avatarFor, showPresence, density, sections, groupBy, header, hasMore: controlledHasMore, loadingMore: controlledLoadingMore, onLoadMore, }: ConversationListProps): react_jsx_runtime.JSX.Element;
|
|
1239
1414
|
|
|
1240
1415
|
interface MemberListProps {
|
|
1241
1416
|
conversationId: Uuid;
|
|
@@ -1411,6 +1586,18 @@ interface MentionInputProps {
|
|
|
1411
1586
|
* extensions (`'.pdf'`). Other files show an error chip instead.
|
|
1412
1587
|
*/
|
|
1413
1588
|
acceptFileTypes?: string[];
|
|
1589
|
+
/**
|
|
1590
|
+
* Composer shortcuts (send, new line, edit last, cancel) — see
|
|
1591
|
+
* `ComposerKeymap`. Defaults: Enter / Cmd+Enter send, Shift+Enter new
|
|
1592
|
+
* line, ↑ in an empty composer edits your last message, Esc cancels
|
|
1593
|
+
* the reply.
|
|
1594
|
+
*/
|
|
1595
|
+
keymap?: ComposerKeymap;
|
|
1596
|
+
/**
|
|
1597
|
+
* ↑ in an empty composer: edit your last message. Return `false`
|
|
1598
|
+
* when there's none to edit (the caret then moves as usual).
|
|
1599
|
+
*/
|
|
1600
|
+
onEditLast?: () => boolean | void;
|
|
1414
1601
|
}
|
|
1415
1602
|
declare const MentionInput: react.ForwardRefExoticComponent<MentionInputProps & react.RefAttributes<MessageComposerHandle>>;
|
|
1416
1603
|
|
|
@@ -1464,4 +1651,4 @@ declare function usePoolseFonts(enabled?: boolean): void;
|
|
|
1464
1651
|
*/
|
|
1465
1652
|
declare function PoolseFonts(): null;
|
|
1466
1653
|
|
|
1467
|
-
export { AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, CallControlButton, type CallControlButtonProps, CallDeviceMenu, type CallDeviceMenuProps, CallLogRow, type CallLogRowProps, CallVideoGrid, type CallVideoGridProps, type ChatDensity, ChatHeader, type ChatHeaderProps, type ChatLayout, type ConversationDraft, ConversationList, type ConversationListProps, type ConversationListSection, ConversationView, type ConversationViewProps, type DraftStorage, EditableMessageBubble, type EditableMessageBubbleProps, EditedLabel, type EditedLabelProps, EmojiPicker, type EmojiPickerProps, GroupDetailsSheet, type GroupDetailsSheetProps, type IconName, type InboxUser, LinkPreviewCard, type LinkPreviewCardProps, LiveCallBanner, type LiveCallBannerProps, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, type MessageSlot, type MessageSlotProps, type MessageSlots, type MessageUser, PoolseFonts, PoolseIcon, type PoolseIconProps, PoolseInbox, type PoolseInboxHandle, type PoolseInboxProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, PoolseTheme, type PoolseThemeProps, type PoolseThemeValue, PresenceBadge, type PresenceBadgeProps, ReactionPicker, ReactionStrip, type ReactionStripProps, type RenderMessageContext, RoomJoinBar, type RoomJoinBarProps, RoomStage, type RoomStageProps, ThreadSummary, type ThreadSummaryProps, ThreadView, type ThreadViewProps, type TimeFormat, TypingIndicator, type TypingIndicatorProps, UploadQueueStrip, type UploadQueueStripProps, UserName, type UserNameProps, UserPickerSheet, type UserPickerSheetProps, formatRelativeTime, loadEmojiData, localDraftStorage, presenceStateLabel, presenceText, useDisplayName, useEditHistory, usePoolseFonts, useSystemColorScheme, useTheme };
|
|
1654
|
+
export { AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, CallControlButton, type CallControlButtonProps, CallDeviceMenu, type CallDeviceMenuProps, CallLogRow, type CallLogRowProps, CallVideoGrid, type CallVideoGridProps, type ChatDensity, ChatHeader, type ChatHeaderProps, type ChatLayout, type ComposerKeymap, type ConversationDraft, ConversationList, type ConversationListProps, type ConversationListSection, ConversationView, type ConversationViewProps, DEFAULT_KEYMAP, DraftScope, type DraftStorage, EditableMessageBubble, type EditableMessageBubbleProps, EditedLabel, type EditedLabelProps, EmojiPicker, type EmojiPickerProps, EmptyState, type EmptyStateProps, GroupDetailsSheet, type GroupDetailsSheetProps, type IconName, type InboxUser, type KeyBinding, LinkPreviewCard, type LinkPreviewCardProps, LiveCallBanner, type LiveCallBannerProps, MOD_ENTER_COMPOSER, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, type MessageListKeymap, type MessageSlot, type MessageSlotProps, type MessageSlots, type MessageUser, PoolseFonts, PoolseIcon, type PoolseIconProps, PoolseInbox, type PoolseInboxHandle, type PoolseInboxProps, type PoolseKeymap, type PoolseKeymapOverrides, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, PoolseTheme, type PoolseThemeProps, type PoolseThemeValue, PresenceBadge, type PresenceBadgeProps, ReactionPicker, ReactionStrip, type ReactionStripProps, type RenderMessageContext, RoomJoinBar, type RoomJoinBarProps, RoomStage, type RoomStageProps, SendStatus, type SendStatusProps, ThreadSummary, type ThreadSummaryProps, ThreadView, type ThreadViewProps, type TimeFormat, TypingIndicator, type TypingIndicatorProps, UploadQueueStrip, type UploadQueueStripProps, UserName, type UserNameProps, UserPickerSheet, type UserPickerSheetProps, draftsOf, formatRelativeTime, loadEmojiData, localDraftStorage, matchesAny, matchesKey, presenceStateLabel, presenceText, resolveKeymap, useDisplayName, useEditHistory, usePoolseFonts, useSystemColorScheme, useTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { CallParticipant, CallDevice, CallDeviceKind, Message, Uuid, LiveCall, Conversation, PresenceState, Presence, Membership, Attachment, LinkPreview, MessageCreateRequest } from '@poolse/sdk';
|
|
2
|
+
import { CallParticipant, CallDevice, CallDeviceKind, Message, Poolse, Uuid, LiveCall, Conversation, PresenceState, Presence, Membership, Attachment, LinkPreview, MessageCreateRequest } from '@poolse/sdk';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { SVGProps, ReactElement, ReactNode, CSSProperties } from 'react';
|
|
5
5
|
import { GroupPosition, UseRoom, UploadItem, ReactionMap } from '@poolse/react';
|
|
@@ -356,6 +356,95 @@ interface ConversationDraft {
|
|
|
356
356
|
}
|
|
357
357
|
/** `window.localStorage`, every call guarded (private mode, blocked storage, SSR). */
|
|
358
358
|
declare const localDraftStorage: DraftStorage;
|
|
359
|
+
/**
|
|
360
|
+
* One client's drafts: held in memory for the page (so switching
|
|
361
|
+
* conversations, or workspaces, and back finds them) and written to a
|
|
362
|
+
* storage under the client's namespace (server + user), so two
|
|
363
|
+
* workspaces never see each other's drafts. Cleared from storage by
|
|
364
|
+
* `chat.destroy({ clearStorage: true })`.
|
|
365
|
+
*/
|
|
366
|
+
declare class DraftScope {
|
|
367
|
+
private readonly namespace;
|
|
368
|
+
private readonly memory;
|
|
369
|
+
/** Storages written to, and the keys written to each. */
|
|
370
|
+
private readonly written;
|
|
371
|
+
constructor(namespace: () => string | null);
|
|
372
|
+
/** The storage key for a conversation's draft; null until the namespace is known. */
|
|
373
|
+
key(conversationId: string): string | null;
|
|
374
|
+
/** The draft for `key`: from memory, else from `storage` (else from `legacyKey`, moved over). */
|
|
375
|
+
read(storage: DraftStorage, key: string, legacyKey?: string): ConversationDraft | null | Promise<ConversationDraft | null>;
|
|
376
|
+
/** Save (or, when empty, drop) the draft for `key`. */
|
|
377
|
+
write(storage: DraftStorage, key: string, draft: ConversationDraft): void;
|
|
378
|
+
clear(storage: DraftStorage, key: string): void;
|
|
379
|
+
/** Called by `chat.destroy()`. @internal */
|
|
380
|
+
destroy(opts: {
|
|
381
|
+
clearStorage: boolean;
|
|
382
|
+
}): Promise<void>;
|
|
383
|
+
private track;
|
|
384
|
+
}
|
|
385
|
+
/** The drafts of one client (made on first use, dropped with it). */
|
|
386
|
+
declare function draftsOf(chat: Poolse): DraftScope;
|
|
387
|
+
|
|
388
|
+
/** One shortcut, e.g. `'Mod+Enter'`, `'Escape'`, `'j'`. */
|
|
389
|
+
type KeyBinding = string;
|
|
390
|
+
interface ComposerKeymap {
|
|
391
|
+
/** Send the message. Default `Enter` and `Mod+Enter`. */
|
|
392
|
+
send: KeyBinding[];
|
|
393
|
+
/** Insert a new line. Default `Shift+Enter`. */
|
|
394
|
+
newline: KeyBinding[];
|
|
395
|
+
/** In an empty composer: edit your last message. Default `ArrowUp`. */
|
|
396
|
+
editLast: KeyBinding[];
|
|
397
|
+
/** Cancel the reply being composed (or an edit). Default `Escape`. */
|
|
398
|
+
cancel: KeyBinding[];
|
|
399
|
+
}
|
|
400
|
+
interface MessageListKeymap {
|
|
401
|
+
/** Focus the next (newer) message. Default `j`, `ArrowDown`. */
|
|
402
|
+
next: KeyBinding[];
|
|
403
|
+
/** Focus the previous (older) message. Default `k`, `ArrowUp`. */
|
|
404
|
+
prev: KeyBinding[];
|
|
405
|
+
/** Focus the newest message. Default `End`. */
|
|
406
|
+
last: KeyBinding[];
|
|
407
|
+
/** Focus the oldest loaded message. Default `Home`. */
|
|
408
|
+
first: KeyBinding[];
|
|
409
|
+
/** Quote-reply to the focused message. Default `r`. */
|
|
410
|
+
reply: KeyBinding[];
|
|
411
|
+
/** Open the focused message's thread. Default `t`. */
|
|
412
|
+
thread: KeyBinding[];
|
|
413
|
+
/** Edit the focused message (yours). Default `e`. */
|
|
414
|
+
edit: KeyBinding[];
|
|
415
|
+
/** Delete the focused message (yours), after a confirmation. Default `Delete`, `Backspace`. */
|
|
416
|
+
delete: KeyBinding[];
|
|
417
|
+
/** Back to the composer. Default `Escape`. */
|
|
418
|
+
composer: KeyBinding[];
|
|
419
|
+
}
|
|
420
|
+
interface PoolseKeymap {
|
|
421
|
+
composer: ComposerKeymap;
|
|
422
|
+
messageList: MessageListKeymap;
|
|
423
|
+
}
|
|
424
|
+
/** Overrides: any binding list replaces the default one; `[]` turns a shortcut off. */
|
|
425
|
+
interface PoolseKeymapOverrides {
|
|
426
|
+
composer?: Partial<ComposerKeymap>;
|
|
427
|
+
messageList?: Partial<MessageListKeymap>;
|
|
428
|
+
}
|
|
429
|
+
declare const DEFAULT_KEYMAP: PoolseKeymap;
|
|
430
|
+
/**
|
|
431
|
+
* The keymap with `sendOn: 'mod+enter'`: Enter makes a new line and
|
|
432
|
+
* Cmd/Ctrl+Enter sends — for teams that write long messages.
|
|
433
|
+
*/
|
|
434
|
+
declare const MOD_ENTER_COMPOSER: Pick<ComposerKeymap, 'send' | 'newline'>;
|
|
435
|
+
/** The default keymap with `overrides` (and the send mode) applied. */
|
|
436
|
+
declare function resolveKeymap(overrides?: PoolseKeymapOverrides, sendOn?: 'enter' | 'mod+enter'): PoolseKeymap;
|
|
437
|
+
interface KeyLike {
|
|
438
|
+
key: string;
|
|
439
|
+
metaKey: boolean;
|
|
440
|
+
ctrlKey: boolean;
|
|
441
|
+
altKey: boolean;
|
|
442
|
+
shiftKey: boolean;
|
|
443
|
+
}
|
|
444
|
+
/** Whether a keyboard event is `binding`. */
|
|
445
|
+
declare function matchesKey(e: KeyLike, binding: KeyBinding): boolean;
|
|
446
|
+
/** Whether a keyboard event is any of `bindings`. */
|
|
447
|
+
declare function matchesAny(e: KeyLike, bindings: ReadonlyArray<KeyBinding>): boolean;
|
|
359
448
|
|
|
360
449
|
/**
|
|
361
450
|
* Position of this bubble within a same-sender, same-day, ≤5-min
|
|
@@ -527,8 +616,37 @@ interface RenderMessageContext {
|
|
|
527
616
|
|
|
528
617
|
interface ConversationViewProps {
|
|
529
618
|
conversationId: Uuid;
|
|
530
|
-
/**
|
|
531
|
-
|
|
619
|
+
/**
|
|
620
|
+
* What an empty conversation shows. Defaults to "No messages yet"
|
|
621
|
+
* with a hint to write the first one (or none, read-only). A
|
|
622
|
+
* function receives `{ readOnly }`.
|
|
623
|
+
*/
|
|
624
|
+
emptyState?: ReactNode | ((ctx: {
|
|
625
|
+
readOnly: boolean;
|
|
626
|
+
}) => ReactNode);
|
|
627
|
+
/**
|
|
628
|
+
* Keyboard shortcuts, scoped to this view (an app's own shortcuts
|
|
629
|
+
* never collide). Composer: Enter sends (see `sendOn`), Shift+Enter
|
|
630
|
+
* makes a new line, ↑ in an empty composer edits your last message,
|
|
631
|
+
* Esc cancels a reply. Message list (focus it with Tab or a click):
|
|
632
|
+
* j / k or ↓ / ↑ move between messages, Home / End jump, r replies,
|
|
633
|
+
* t opens the thread, e edits, Delete deletes (yours, after a
|
|
634
|
+
* confirm), Esc goes back to the composer. Override any binding;
|
|
635
|
+
* `[]` turns one off. See `DEFAULT_KEYMAP`.
|
|
636
|
+
*/
|
|
637
|
+
keymap?: PoolseKeymapOverrides;
|
|
638
|
+
/**
|
|
639
|
+
* `'enter'` (default): Enter sends, Shift+Enter is a new line.
|
|
640
|
+
* `'mod+enter'`: Enter is a new line, Cmd/Ctrl+Enter sends.
|
|
641
|
+
*/
|
|
642
|
+
sendOn?: 'enter' | 'mod+enter';
|
|
643
|
+
/** The message-list shortcuts (j / k / r / t / e / Delete). Defaults to `true`. */
|
|
644
|
+
keyboardShortcuts?: boolean;
|
|
645
|
+
/**
|
|
646
|
+
* Asked before the Delete shortcut deletes a message. Defaults to
|
|
647
|
+
* `window.confirm`. Return false to keep it.
|
|
648
|
+
*/
|
|
649
|
+
confirmDelete?: (message: Message) => boolean | Promise<boolean>;
|
|
532
650
|
/**
|
|
533
651
|
* Render-prop escape hatch for individual messages. When set,
|
|
534
652
|
* COMPLETELY overrides the default per-message rendering — you
|
|
@@ -727,7 +845,7 @@ interface ConversationViewProps {
|
|
|
727
845
|
*/
|
|
728
846
|
draftStorage?: DraftStorage;
|
|
729
847
|
}
|
|
730
|
-
declare function ConversationView({ conversationId, emptyState, renderMessage, labelFor, loadFonts, reactions, mentions, attachments, maxFileSize, acceptFileTypes, emojiPicker, actions, threads, quotations, readReceipts, linkPreviews, markdown, maxBodyLength, grouping, groupingWindowMs, groupWindowMinutes, layout, density, showAvatars, showPresence, timeFormat, slots, daySeparators, senderLabels, avatars, onMarkedRead, focusMessageId, onFocusMessageNotFound, onSenderPress, onAvatarPress, composer, readOnly, onCallBack, onJoinCall, currentCallId, persistDrafts, draftStorage, }: ConversationViewProps): react_jsx_runtime.JSX.Element;
|
|
848
|
+
declare function ConversationView({ conversationId, emptyState, renderMessage, labelFor, loadFonts, reactions, mentions, attachments, maxFileSize, acceptFileTypes, emojiPicker, actions, threads, quotations, readReceipts, linkPreviews, markdown, maxBodyLength, grouping, groupingWindowMs, groupWindowMinutes, layout, density, showAvatars, showPresence, timeFormat, slots, daySeparators, senderLabels, avatars, onMarkedRead, focusMessageId, onFocusMessageNotFound, onSenderPress, onAvatarPress, composer, readOnly, onCallBack, onJoinCall, currentCallId, persistDrafts, draftStorage, keymap: keymapOverrides, sendOn, keyboardShortcuts, confirmDelete, }: ConversationViewProps): react_jsx_runtime.JSX.Element;
|
|
731
849
|
|
|
732
850
|
interface ChatHeaderProps {
|
|
733
851
|
/** Conversation id — used to fetch the row + members for the title / presence dot. */
|
|
@@ -756,6 +874,40 @@ interface ChatHeaderProps {
|
|
|
756
874
|
}
|
|
757
875
|
declare function ChatHeader({ conversationId, labelFor, avatarFor, onBack, onPress, onMembersPress, rightSlot, showPresence, }: ChatHeaderProps): react_jsx_runtime.JSX.Element;
|
|
758
876
|
|
|
877
|
+
interface EmptyStateProps {
|
|
878
|
+
/** What's empty, in a few words: "No messages yet". */
|
|
879
|
+
title: ReactNode;
|
|
880
|
+
/** What to do next: "Say hello — your message starts the conversation." */
|
|
881
|
+
hint?: ReactNode;
|
|
882
|
+
/** A button or link for the next step. */
|
|
883
|
+
action?: ReactNode;
|
|
884
|
+
className?: string;
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* An empty screen that says what to do next. The components use it for
|
|
888
|
+
* their defaults (an empty conversation list, an empty channel, a search
|
|
889
|
+
* with no results); pass your own `emptyState` to any of them to
|
|
890
|
+
* replace it, or use this to keep the look.
|
|
891
|
+
*/
|
|
892
|
+
declare function EmptyState({ title, hint, action, className }: EmptyStateProps): react_jsx_runtime.JSX.Element;
|
|
893
|
+
|
|
894
|
+
interface SendStatusProps {
|
|
895
|
+
message: Message;
|
|
896
|
+
/** Send it again (failed or queued). */
|
|
897
|
+
onRetry?: () => void;
|
|
898
|
+
/** Drop the unsent message. */
|
|
899
|
+
onDiscard?: () => void;
|
|
900
|
+
/** Align with the bubble: right for your own messages. */
|
|
901
|
+
align?: 'left' | 'right';
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Under an unsent message: "Waiting for network…" while it's queued
|
|
905
|
+
* offline (it goes out by itself on reconnect), or "Not sent" with
|
|
906
|
+
* Retry and Delete when the server refused it. Nothing for a message
|
|
907
|
+
* that's on its way or sent.
|
|
908
|
+
*/
|
|
909
|
+
declare function SendStatus({ message, onRetry, onDiscard, align }: SendStatusProps): react_jsx_runtime.JSX.Element | null;
|
|
910
|
+
|
|
759
911
|
/** Minimal user shape the picker renders. Matches the RN InboxUser. */
|
|
760
912
|
interface InboxUser {
|
|
761
913
|
externalId: string;
|
|
@@ -969,6 +1121,18 @@ interface MessageComposerProps {
|
|
|
969
1121
|
* extensions (`'.pdf'`). Other files show an error chip instead.
|
|
970
1122
|
*/
|
|
971
1123
|
acceptFileTypes?: string[];
|
|
1124
|
+
/**
|
|
1125
|
+
* Composer shortcuts (send, new line, edit last, cancel) — see
|
|
1126
|
+
* `ComposerKeymap`. Defaults: Enter / Cmd+Enter send, Shift+Enter new
|
|
1127
|
+
* line, ↑ in an empty composer edits your last message, Esc cancels
|
|
1128
|
+
* the reply.
|
|
1129
|
+
*/
|
|
1130
|
+
keymap?: ComposerKeymap;
|
|
1131
|
+
/**
|
|
1132
|
+
* ↑ in an empty composer: edit your last message. Return `false`
|
|
1133
|
+
* when there's none to edit (the caret then moves as usual).
|
|
1134
|
+
*/
|
|
1135
|
+
onEditLast?: () => boolean | void;
|
|
972
1136
|
}
|
|
973
1137
|
/**
|
|
974
1138
|
* Imperative handle exposed via `ref` for parents that want to forward
|
|
@@ -1171,8 +1335,19 @@ interface ConversationListProps {
|
|
|
1171
1335
|
onSelect?: (conv: Conversation) => void;
|
|
1172
1336
|
/** Optional override for each row's rendering. */
|
|
1173
1337
|
renderItem?: (conv: Conversation, selected: boolean) => ReactNode;
|
|
1174
|
-
/**
|
|
1338
|
+
/**
|
|
1339
|
+
* What an empty list shows. Defaults to "No conversations yet" with a
|
|
1340
|
+
* hint at the next step.
|
|
1341
|
+
*/
|
|
1175
1342
|
emptyState?: ReactNode;
|
|
1343
|
+
/**
|
|
1344
|
+
* Show only conversations matching this text (name, the other
|
|
1345
|
+
* person in a direct chat via `labelFor`, the last message). For a
|
|
1346
|
+
* search field in `header`. Empty = everything.
|
|
1347
|
+
*/
|
|
1348
|
+
query?: string;
|
|
1349
|
+
/** What shows when `query` matches nothing. Receives the query. */
|
|
1350
|
+
noResultsState?: ReactNode | ((query: string) => ReactNode);
|
|
1176
1351
|
/**
|
|
1177
1352
|
* Controlled mode — when provided, render from these props instead
|
|
1178
1353
|
* of calling `useConversations()` internally. Lets parent components
|
|
@@ -1235,7 +1410,7 @@ interface ConversationListSection {
|
|
|
1235
1410
|
title: string;
|
|
1236
1411
|
filter: (conversation: Conversation) => boolean;
|
|
1237
1412
|
}
|
|
1238
|
-
declare function ConversationList({ selectedId, onSelect, renderItem, emptyState, conversations: controlledConversations, loading: controlledLoading, error: controlledError, unreadCounts, labelFor, avatarFor, showPresence, density, sections, groupBy, header, hasMore: controlledHasMore, loadingMore: controlledLoadingMore, onLoadMore, }: ConversationListProps): react_jsx_runtime.JSX.Element;
|
|
1413
|
+
declare function ConversationList({ selectedId, onSelect, renderItem, emptyState, query, noResultsState, conversations: controlledConversations, loading: controlledLoading, error: controlledError, unreadCounts, labelFor, avatarFor, showPresence, density, sections, groupBy, header, hasMore: controlledHasMore, loadingMore: controlledLoadingMore, onLoadMore, }: ConversationListProps): react_jsx_runtime.JSX.Element;
|
|
1239
1414
|
|
|
1240
1415
|
interface MemberListProps {
|
|
1241
1416
|
conversationId: Uuid;
|
|
@@ -1411,6 +1586,18 @@ interface MentionInputProps {
|
|
|
1411
1586
|
* extensions (`'.pdf'`). Other files show an error chip instead.
|
|
1412
1587
|
*/
|
|
1413
1588
|
acceptFileTypes?: string[];
|
|
1589
|
+
/**
|
|
1590
|
+
* Composer shortcuts (send, new line, edit last, cancel) — see
|
|
1591
|
+
* `ComposerKeymap`. Defaults: Enter / Cmd+Enter send, Shift+Enter new
|
|
1592
|
+
* line, ↑ in an empty composer edits your last message, Esc cancels
|
|
1593
|
+
* the reply.
|
|
1594
|
+
*/
|
|
1595
|
+
keymap?: ComposerKeymap;
|
|
1596
|
+
/**
|
|
1597
|
+
* ↑ in an empty composer: edit your last message. Return `false`
|
|
1598
|
+
* when there's none to edit (the caret then moves as usual).
|
|
1599
|
+
*/
|
|
1600
|
+
onEditLast?: () => boolean | void;
|
|
1414
1601
|
}
|
|
1415
1602
|
declare const MentionInput: react.ForwardRefExoticComponent<MentionInputProps & react.RefAttributes<MessageComposerHandle>>;
|
|
1416
1603
|
|
|
@@ -1464,4 +1651,4 @@ declare function usePoolseFonts(enabled?: boolean): void;
|
|
|
1464
1651
|
*/
|
|
1465
1652
|
declare function PoolseFonts(): null;
|
|
1466
1653
|
|
|
1467
|
-
export { AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, CallControlButton, type CallControlButtonProps, CallDeviceMenu, type CallDeviceMenuProps, CallLogRow, type CallLogRowProps, CallVideoGrid, type CallVideoGridProps, type ChatDensity, ChatHeader, type ChatHeaderProps, type ChatLayout, type ConversationDraft, ConversationList, type ConversationListProps, type ConversationListSection, ConversationView, type ConversationViewProps, type DraftStorage, EditableMessageBubble, type EditableMessageBubbleProps, EditedLabel, type EditedLabelProps, EmojiPicker, type EmojiPickerProps, GroupDetailsSheet, type GroupDetailsSheetProps, type IconName, type InboxUser, LinkPreviewCard, type LinkPreviewCardProps, LiveCallBanner, type LiveCallBannerProps, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, type MessageSlot, type MessageSlotProps, type MessageSlots, type MessageUser, PoolseFonts, PoolseIcon, type PoolseIconProps, PoolseInbox, type PoolseInboxHandle, type PoolseInboxProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, PoolseTheme, type PoolseThemeProps, type PoolseThemeValue, PresenceBadge, type PresenceBadgeProps, ReactionPicker, ReactionStrip, type ReactionStripProps, type RenderMessageContext, RoomJoinBar, type RoomJoinBarProps, RoomStage, type RoomStageProps, ThreadSummary, type ThreadSummaryProps, ThreadView, type ThreadViewProps, type TimeFormat, TypingIndicator, type TypingIndicatorProps, UploadQueueStrip, type UploadQueueStripProps, UserName, type UserNameProps, UserPickerSheet, type UserPickerSheetProps, formatRelativeTime, loadEmojiData, localDraftStorage, presenceStateLabel, presenceText, useDisplayName, useEditHistory, usePoolseFonts, useSystemColorScheme, useTheme };
|
|
1654
|
+
export { AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, CallControlButton, type CallControlButtonProps, CallDeviceMenu, type CallDeviceMenuProps, CallLogRow, type CallLogRowProps, CallVideoGrid, type CallVideoGridProps, type ChatDensity, ChatHeader, type ChatHeaderProps, type ChatLayout, type ComposerKeymap, type ConversationDraft, ConversationList, type ConversationListProps, type ConversationListSection, ConversationView, type ConversationViewProps, DEFAULT_KEYMAP, DraftScope, type DraftStorage, EditableMessageBubble, type EditableMessageBubbleProps, EditedLabel, type EditedLabelProps, EmojiPicker, type EmojiPickerProps, EmptyState, type EmptyStateProps, GroupDetailsSheet, type GroupDetailsSheetProps, type IconName, type InboxUser, type KeyBinding, LinkPreviewCard, type LinkPreviewCardProps, LiveCallBanner, type LiveCallBannerProps, MOD_ENTER_COMPOSER, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, type MessageListKeymap, type MessageSlot, type MessageSlotProps, type MessageSlots, type MessageUser, PoolseFonts, PoolseIcon, type PoolseIconProps, PoolseInbox, type PoolseInboxHandle, type PoolseInboxProps, type PoolseKeymap, type PoolseKeymapOverrides, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, PoolseTheme, type PoolseThemeProps, type PoolseThemeValue, PresenceBadge, type PresenceBadgeProps, ReactionPicker, ReactionStrip, type ReactionStripProps, type RenderMessageContext, RoomJoinBar, type RoomJoinBarProps, RoomStage, type RoomStageProps, SendStatus, type SendStatusProps, ThreadSummary, type ThreadSummaryProps, ThreadView, type ThreadViewProps, type TimeFormat, TypingIndicator, type TypingIndicatorProps, UploadQueueStrip, type UploadQueueStripProps, UserName, type UserNameProps, UserPickerSheet, type UserPickerSheetProps, draftsOf, formatRelativeTime, loadEmojiData, localDraftStorage, matchesAny, matchesKey, presenceStateLabel, presenceText, resolveKeymap, useDisplayName, useEditHistory, usePoolseFonts, useSystemColorScheme, useTheme };
|