@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.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { forwardRef, useState, useId, useReducer, useRef, useEffect, useImperativeHandle, useCallback, useMemo, createContext, Fragment as Fragment$1, useLayoutEffect, useContext } from 'react';
|
|
3
3
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import {
|
|
4
|
+
import { safeUuid, MessageQueuedError } from '@poolse/sdk';
|
|
5
|
+
import { usePoolse, useMembers, useUser, useMe, useConversations, useAttachmentUpload, filterConversations, useConversation, usePresence, useUserPresence, useMessages, useTyping, useMessageStreams, useRealtimeStatus, isMessageVisibleTo, receiptsOf, computeGroupPosition, sameDay, formatDayLabel, canEditOwnMessage, useLiveCall, callLogDisplayFor, useThread, usePresenceMany, formatCallLogPreview, ApiError, useReactions, useAttachmentUrl } from '@poolse/react';
|
|
5
6
|
import ReactMarkdown from 'react-markdown';
|
|
6
7
|
import remarkGfm from 'remark-gfm';
|
|
7
8
|
import { resolveTheme, tokensToCssVariables } from '@poolse/theme';
|
|
@@ -769,47 +770,133 @@ var localDraftStorage = {
|
|
|
769
770
|
}
|
|
770
771
|
}
|
|
771
772
|
};
|
|
772
|
-
var memory = /* @__PURE__ */ new Map();
|
|
773
773
|
function draftKey(userId, conversationId) {
|
|
774
774
|
return `poolse:draft:${userId}:${conversationId}`;
|
|
775
775
|
}
|
|
776
776
|
var isEmpty = (d) => d.text.trim() === "" && !d.replyTo;
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
let raw;
|
|
781
|
-
try {
|
|
782
|
-
raw = storage.get(key);
|
|
783
|
-
} catch {
|
|
784
|
-
return null;
|
|
777
|
+
var DraftScope = class {
|
|
778
|
+
constructor(namespace) {
|
|
779
|
+
this.namespace = namespace;
|
|
785
780
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
781
|
+
namespace;
|
|
782
|
+
memory = /* @__PURE__ */ new Map();
|
|
783
|
+
/** Storages written to, and the keys written to each. */
|
|
784
|
+
written = /* @__PURE__ */ new Map();
|
|
785
|
+
/** The storage key for a conversation's draft; null until the namespace is known. */
|
|
786
|
+
key(conversationId) {
|
|
787
|
+
const ns = this.namespace();
|
|
788
|
+
return ns ? `${ns}:draft:${conversationId}` : null;
|
|
789
|
+
}
|
|
790
|
+
/** The draft for `key`: from memory, else from `storage` (else from `legacyKey`, moved over). */
|
|
791
|
+
read(storage, key, legacyKey) {
|
|
792
|
+
const held = this.memory.get(key);
|
|
793
|
+
if (held) return held;
|
|
794
|
+
const hold = (d) => {
|
|
795
|
+
if (d && !this.memory.has(key)) this.memory.set(key, d);
|
|
796
|
+
return this.memory.get(key) ?? d;
|
|
797
|
+
};
|
|
798
|
+
const fromLegacy = () => {
|
|
799
|
+
if (!legacyKey) return null;
|
|
800
|
+
const old = safeGet(storage, legacyKey);
|
|
801
|
+
const move = (raw2) => {
|
|
802
|
+
const d = parse(raw2);
|
|
803
|
+
if (!d) return null;
|
|
804
|
+
this.write(storage, key, d);
|
|
805
|
+
swallow(() => storage.remove(legacyKey));
|
|
806
|
+
return hold(d);
|
|
807
|
+
};
|
|
808
|
+
return old instanceof Promise ? old.then(move, () => null) : move(old);
|
|
809
|
+
};
|
|
810
|
+
const raw = safeGet(storage, key);
|
|
811
|
+
const take = (r) => {
|
|
812
|
+
const d = parse(r);
|
|
813
|
+
return d ? hold(d) : fromLegacy();
|
|
814
|
+
};
|
|
815
|
+
return raw instanceof Promise ? raw.then(take, () => null) : take(raw);
|
|
816
|
+
}
|
|
817
|
+
/** Save (or, when empty, drop) the draft for `key`. */
|
|
818
|
+
write(storage, key, draft) {
|
|
819
|
+
if (isEmpty(draft)) {
|
|
820
|
+
this.clear(storage, key);
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
this.memory.set(key, draft);
|
|
824
|
+
this.track(storage, key);
|
|
825
|
+
const value = JSON.stringify({ v: 1, text: draft.text, replyTo: draft.replyTo });
|
|
826
|
+
swallow(() => storage.set(key, value));
|
|
827
|
+
}
|
|
828
|
+
clear(storage, key) {
|
|
829
|
+
this.memory.delete(key);
|
|
830
|
+
swallow(() => storage.remove(key));
|
|
831
|
+
}
|
|
832
|
+
/** Called by `chat.destroy()`. @internal */
|
|
833
|
+
async destroy(opts) {
|
|
834
|
+
this.memory.clear();
|
|
835
|
+
if (!opts.clearStorage) return;
|
|
836
|
+
const ns = this.namespace();
|
|
837
|
+
const storages = /* @__PURE__ */ new Set([...this.written.keys(), localDraftStorage]);
|
|
838
|
+
for (const storage of storages) {
|
|
839
|
+
const keys = new Set(this.written.get(storage) ?? []);
|
|
840
|
+
if (ns) {
|
|
841
|
+
try {
|
|
842
|
+
const raw = await storage.get(indexKey(ns));
|
|
843
|
+
const listed = raw ? JSON.parse(raw) : [];
|
|
844
|
+
if (Array.isArray(listed)) {
|
|
845
|
+
for (const k of listed) if (typeof k === "string") keys.add(k);
|
|
846
|
+
}
|
|
847
|
+
} catch {
|
|
848
|
+
}
|
|
849
|
+
swallow(() => storage.remove(indexKey(ns)));
|
|
850
|
+
}
|
|
851
|
+
for (const k of keys) swallow(() => storage.remove(k));
|
|
852
|
+
}
|
|
853
|
+
this.written.clear();
|
|
801
854
|
}
|
|
802
|
-
|
|
803
|
-
|
|
855
|
+
// Remember the key in an index entry, so a sign-out finds drafts
|
|
856
|
+
// written in earlier sessions too.
|
|
857
|
+
track(storage, key) {
|
|
858
|
+
let keys = this.written.get(storage);
|
|
859
|
+
if (!keys) {
|
|
860
|
+
keys = /* @__PURE__ */ new Set();
|
|
861
|
+
this.written.set(storage, keys);
|
|
862
|
+
}
|
|
863
|
+
if (keys.has(key)) return;
|
|
864
|
+
keys.add(key);
|
|
865
|
+
const ns = this.namespace();
|
|
866
|
+
if (!ns) return;
|
|
867
|
+
const all = keys;
|
|
868
|
+
const merge = (raw2) => {
|
|
869
|
+
let listed = [];
|
|
870
|
+
try {
|
|
871
|
+
const v = raw2 ? JSON.parse(raw2) : [];
|
|
872
|
+
if (Array.isArray(v)) listed = v.filter((k) => typeof k === "string");
|
|
873
|
+
} catch {
|
|
874
|
+
}
|
|
875
|
+
const next = [.../* @__PURE__ */ new Set([...listed, ...all])];
|
|
876
|
+
swallow(() => storage.set(indexKey(ns), JSON.stringify(next)));
|
|
877
|
+
};
|
|
878
|
+
const raw = safeGet(storage, indexKey(ns));
|
|
879
|
+
if (raw instanceof Promise) void raw.then(merge, () => void 0);
|
|
880
|
+
else merge(raw);
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
function draftsOf(chat) {
|
|
884
|
+
return chat.scoped("react-ui:drafts", (c) => new DraftScope(() => c.namespace));
|
|
885
|
+
}
|
|
886
|
+
var indexKey = (ns) => `${ns}:draft-index`;
|
|
887
|
+
function safeGet(storage, key) {
|
|
804
888
|
try {
|
|
805
|
-
|
|
889
|
+
return storage.get(key);
|
|
806
890
|
} catch {
|
|
891
|
+
return null;
|
|
807
892
|
}
|
|
808
893
|
}
|
|
809
|
-
function
|
|
810
|
-
memory.delete(key);
|
|
894
|
+
function swallow(fn) {
|
|
811
895
|
try {
|
|
812
|
-
|
|
896
|
+
const r = fn();
|
|
897
|
+
if (r && typeof r.catch === "function") {
|
|
898
|
+
r.catch(() => void 0);
|
|
899
|
+
}
|
|
813
900
|
} catch {
|
|
814
901
|
}
|
|
815
902
|
}
|
|
@@ -825,8 +912,98 @@ function parse(raw) {
|
|
|
825
912
|
return null;
|
|
826
913
|
}
|
|
827
914
|
}
|
|
915
|
+
function EmptyState({ title, hint, action, className }) {
|
|
916
|
+
return /* @__PURE__ */ jsxs("div", { className: ["poolse-empty-state", className].filter(Boolean).join(" "), role: "status", children: [
|
|
917
|
+
/* @__PURE__ */ jsx("p", { className: "poolse-empty-state__title", children: title }),
|
|
918
|
+
hint ? /* @__PURE__ */ jsx("p", { className: "poolse-empty-state__hint", children: hint }) : null,
|
|
919
|
+
action ? /* @__PURE__ */ jsx("div", { className: "poolse-empty-state__action", children: action }) : null
|
|
920
|
+
] });
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
// src/keymap.ts
|
|
924
|
+
var DEFAULT_KEYMAP = {
|
|
925
|
+
composer: {
|
|
926
|
+
send: ["Enter", "Mod+Enter"],
|
|
927
|
+
newline: ["Shift+Enter"],
|
|
928
|
+
editLast: ["ArrowUp"],
|
|
929
|
+
cancel: ["Escape"]
|
|
930
|
+
},
|
|
931
|
+
messageList: {
|
|
932
|
+
next: ["j", "ArrowDown"],
|
|
933
|
+
prev: ["k", "ArrowUp"],
|
|
934
|
+
last: ["End"],
|
|
935
|
+
first: ["Home"],
|
|
936
|
+
reply: ["r"],
|
|
937
|
+
thread: ["t"],
|
|
938
|
+
edit: ["e"],
|
|
939
|
+
delete: ["Delete", "Backspace"],
|
|
940
|
+
composer: ["Escape"]
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
var MOD_ENTER_COMPOSER = {
|
|
944
|
+
send: ["Mod+Enter"],
|
|
945
|
+
newline: ["Enter", "Shift+Enter"]
|
|
946
|
+
};
|
|
947
|
+
function resolveKeymap(overrides, sendOn = "enter") {
|
|
948
|
+
return {
|
|
949
|
+
composer: {
|
|
950
|
+
...DEFAULT_KEYMAP.composer,
|
|
951
|
+
...sendOn === "mod+enter" ? MOD_ENTER_COMPOSER : {},
|
|
952
|
+
...overrides?.composer
|
|
953
|
+
},
|
|
954
|
+
messageList: { ...DEFAULT_KEYMAP.messageList, ...overrides?.messageList }
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
function matchesKey(e, binding) {
|
|
958
|
+
const parts = binding.split("+");
|
|
959
|
+
const key = parts.pop() ?? "";
|
|
960
|
+
const mods = new Set(parts.map((p) => p.toLowerCase()));
|
|
961
|
+
const wantMod = mods.has("mod");
|
|
962
|
+
const wantCtrl = mods.has("ctrl");
|
|
963
|
+
const wantMeta = mods.has("meta") || mods.has("cmd");
|
|
964
|
+
const wantAlt = mods.has("alt") || mods.has("option");
|
|
965
|
+
const wantShift = mods.has("shift");
|
|
966
|
+
if (wantMod ? !(e.metaKey || e.ctrlKey) : !wantCtrl && !wantMeta && (e.metaKey || e.ctrlKey)) {
|
|
967
|
+
return false;
|
|
968
|
+
}
|
|
969
|
+
if (wantCtrl && !e.ctrlKey) return false;
|
|
970
|
+
if (wantMeta && !e.metaKey) return false;
|
|
971
|
+
if (wantAlt !== e.altKey) return false;
|
|
972
|
+
const letter = key.length === 1;
|
|
973
|
+
if (!letter && wantShift !== e.shiftKey) return false;
|
|
974
|
+
if (letter && wantShift && !e.shiftKey) return false;
|
|
975
|
+
return letter ? e.key.toLowerCase() === key.toLowerCase() : e.key === key;
|
|
976
|
+
}
|
|
977
|
+
function matchesAny(e, bindings) {
|
|
978
|
+
return bindings.some((b) => matchesKey(e, b));
|
|
979
|
+
}
|
|
980
|
+
function isTypingTarget(target) {
|
|
981
|
+
if (!target || typeof target.closest !== "function") return false;
|
|
982
|
+
const el = target;
|
|
983
|
+
if (el.isContentEditable) return true;
|
|
984
|
+
return !!el.closest('input, textarea, select, [contenteditable="true"]');
|
|
985
|
+
}
|
|
986
|
+
function composerAction(e, keymap) {
|
|
987
|
+
if (matchesAny(e, keymap.newline)) return "newline";
|
|
988
|
+
if (matchesAny(e, keymap.send)) return "send";
|
|
989
|
+
if (matchesAny(e, keymap.editLast)) return "editLast";
|
|
990
|
+
if (matchesAny(e, keymap.cancel)) return "cancel";
|
|
991
|
+
return null;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
// src/motion.ts
|
|
995
|
+
function prefersReducedMotion() {
|
|
996
|
+
try {
|
|
997
|
+
return typeof globalThis.matchMedia === "function" && globalThis.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
998
|
+
} catch {
|
|
999
|
+
return false;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
828
1002
|
|
|
829
1003
|
// src/layout.ts
|
|
1004
|
+
function gutterTime(time) {
|
|
1005
|
+
return time.replace(/\s+(?=[AaPp]\.?[Mm]\.?$)/, "").replace(/\u202f/g, "");
|
|
1006
|
+
}
|
|
830
1007
|
function formatMessageTime(iso, format) {
|
|
831
1008
|
if (!iso) return "";
|
|
832
1009
|
const date = new Date(iso);
|
|
@@ -1479,7 +1656,9 @@ var MentionInput = forwardRef(
|
|
|
1479
1656
|
emojiPicker = true,
|
|
1480
1657
|
maxFileSize,
|
|
1481
1658
|
acceptFileTypes,
|
|
1482
|
-
onValueChange
|
|
1659
|
+
onValueChange,
|
|
1660
|
+
keymap = DEFAULT_KEYMAP.composer,
|
|
1661
|
+
onEditLast
|
|
1483
1662
|
}, ref) {
|
|
1484
1663
|
const chat = usePoolse();
|
|
1485
1664
|
const { members } = useMembers(conversationId);
|
|
@@ -1630,10 +1809,26 @@ var MentionInput = forwardRef(
|
|
|
1630
1809
|
return;
|
|
1631
1810
|
}
|
|
1632
1811
|
}
|
|
1633
|
-
|
|
1812
|
+
const action = composerAction(e, keymap);
|
|
1813
|
+
if (action === "editLast") {
|
|
1814
|
+
if (value === "" && onEditLast && onEditLast() !== false) e.preventDefault();
|
|
1815
|
+
return;
|
|
1816
|
+
}
|
|
1817
|
+
if (action === "newline" && e.key === "Enter" && !e.shiftKey) {
|
|
1818
|
+
const result = handleListEnter(value, e.currentTarget.selectionStart);
|
|
1819
|
+
if (result) {
|
|
1820
|
+
e.preventDefault();
|
|
1821
|
+
setValue(result.value);
|
|
1822
|
+
requestAnimationFrame(() => {
|
|
1823
|
+
taRef.current?.setSelectionRange(result.caret, result.caret);
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
return;
|
|
1827
|
+
}
|
|
1828
|
+
if (action === "send") {
|
|
1634
1829
|
const ta = e.currentTarget;
|
|
1635
1830
|
const caret = ta.selectionStart;
|
|
1636
|
-
const result = handleListEnter(value, caret);
|
|
1831
|
+
const result = e.key === "Enter" && !e.metaKey && !e.ctrlKey ? handleListEnter(value, caret) : null;
|
|
1637
1832
|
if (result) {
|
|
1638
1833
|
e.preventDefault();
|
|
1639
1834
|
setValue(result.value);
|
|
@@ -1645,7 +1840,7 @@ var MentionInput = forwardRef(
|
|
|
1645
1840
|
e.preventDefault();
|
|
1646
1841
|
void submit();
|
|
1647
1842
|
}
|
|
1648
|
-
if (
|
|
1843
|
+
if (action === "cancel" && replyingTo && onCancelReply && !mention) {
|
|
1649
1844
|
e.preventDefault();
|
|
1650
1845
|
onCancelReply();
|
|
1651
1846
|
}
|
|
@@ -1701,6 +1896,8 @@ var MentionInput = forwardRef(
|
|
|
1701
1896
|
multiple: true,
|
|
1702
1897
|
...uploads.accept ? { accept: uploads.accept } : {},
|
|
1703
1898
|
className: "poolse-attach-input",
|
|
1899
|
+
"aria-label": "Attach files",
|
|
1900
|
+
tabIndex: -1,
|
|
1704
1901
|
onChange: (e) => {
|
|
1705
1902
|
const files = Array.from(e.target.files ?? []);
|
|
1706
1903
|
if (files.length > 0) addFiles(files);
|
|
@@ -1734,11 +1931,11 @@ var MentionInput = forwardRef(
|
|
|
1734
1931
|
placeholder,
|
|
1735
1932
|
disabled: disabled || sending,
|
|
1736
1933
|
"aria-label": placeholder,
|
|
1737
|
-
role: "combobox",
|
|
1738
|
-
"aria-expanded": Boolean(mention && filtered.length > 0),
|
|
1739
|
-
"aria-controls": menuId,
|
|
1740
1934
|
"aria-autocomplete": "list",
|
|
1741
|
-
...mention && filtered.length > 0 ? {
|
|
1935
|
+
...mention && filtered.length > 0 ? {
|
|
1936
|
+
"aria-controls": menuId,
|
|
1937
|
+
"aria-activedescendant": `${menuId}-opt-${activeIdx}`
|
|
1938
|
+
} : {}
|
|
1742
1939
|
}
|
|
1743
1940
|
),
|
|
1744
1941
|
emojiPicker && /* @__PURE__ */ jsx(
|
|
@@ -1785,8 +1982,7 @@ function MentionOption({ member, name }) {
|
|
|
1785
1982
|
const { profile } = useUser(member.external_id);
|
|
1786
1983
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1787
1984
|
/* @__PURE__ */ jsx(Avatar, { src: profile?.avatarUrl ?? null, name, size: "xs" }),
|
|
1788
|
-
/* @__PURE__ */ jsx("span", { className: "poolse-mention-menu__name", children: name })
|
|
1789
|
-
name !== member.external_id ? /* @__PURE__ */ jsx("span", { className: "poolse-mention-menu__handle", children: member.external_id }) : null
|
|
1985
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-mention-menu__name", children: name })
|
|
1790
1986
|
] });
|
|
1791
1987
|
}
|
|
1792
1988
|
function rankMembers(members, query, label) {
|
|
@@ -1813,7 +2009,9 @@ var MessageComposer = forwardRef(
|
|
|
1813
2009
|
emojiPicker = true,
|
|
1814
2010
|
maxFileSize,
|
|
1815
2011
|
acceptFileTypes,
|
|
1816
|
-
onValueChange
|
|
2012
|
+
onValueChange,
|
|
2013
|
+
keymap = DEFAULT_KEYMAP.composer,
|
|
2014
|
+
onEditLast
|
|
1817
2015
|
}, ref) {
|
|
1818
2016
|
const [value, setValue] = useState("");
|
|
1819
2017
|
const [sending, setSending] = useState(false);
|
|
@@ -1867,10 +2065,26 @@ var MessageComposer = forwardRef(
|
|
|
1867
2065
|
}
|
|
1868
2066
|
};
|
|
1869
2067
|
const onKeyDown = (e) => {
|
|
1870
|
-
|
|
2068
|
+
const action = composerAction(e, keymap);
|
|
2069
|
+
if (action === "editLast") {
|
|
2070
|
+
if (value === "" && onEditLast && onEditLast() !== false) e.preventDefault();
|
|
2071
|
+
return;
|
|
2072
|
+
}
|
|
2073
|
+
if (action === "newline" && e.key === "Enter" && !e.shiftKey) {
|
|
2074
|
+
const result = handleListEnter(value, e.currentTarget.selectionStart);
|
|
2075
|
+
if (result) {
|
|
2076
|
+
e.preventDefault();
|
|
2077
|
+
setValue(result.value);
|
|
2078
|
+
requestAnimationFrame(() => {
|
|
2079
|
+
taRef.current?.setSelectionRange(result.caret, result.caret);
|
|
2080
|
+
});
|
|
2081
|
+
}
|
|
2082
|
+
return;
|
|
2083
|
+
}
|
|
2084
|
+
if (action === "send") {
|
|
1871
2085
|
const ta = e.currentTarget;
|
|
1872
2086
|
const caret = ta.selectionStart;
|
|
1873
|
-
const result = handleListEnter(value, caret);
|
|
2087
|
+
const result = e.key === "Enter" && !e.metaKey && !e.ctrlKey ? handleListEnter(value, caret) : null;
|
|
1874
2088
|
if (result) {
|
|
1875
2089
|
e.preventDefault();
|
|
1876
2090
|
setValue(result.value);
|
|
@@ -1882,7 +2096,7 @@ var MessageComposer = forwardRef(
|
|
|
1882
2096
|
e.preventDefault();
|
|
1883
2097
|
void submit();
|
|
1884
2098
|
}
|
|
1885
|
-
if (
|
|
2099
|
+
if (action === "cancel" && replyingTo && onCancelReply) {
|
|
1886
2100
|
e.preventDefault();
|
|
1887
2101
|
onCancelReply();
|
|
1888
2102
|
}
|
|
@@ -1928,6 +2142,8 @@ var MessageComposer = forwardRef(
|
|
|
1928
2142
|
multiple: true,
|
|
1929
2143
|
...uploads.accept ? { accept: uploads.accept } : {},
|
|
1930
2144
|
className: "poolse-attach-input",
|
|
2145
|
+
"aria-label": "Attach files",
|
|
2146
|
+
tabIndex: -1,
|
|
1931
2147
|
onChange: (e) => {
|
|
1932
2148
|
const files = Array.from(e.target.files ?? []);
|
|
1933
2149
|
if (files.length > 0) addFiles(files);
|
|
@@ -3141,6 +3357,35 @@ function InlineReactions({
|
|
|
3141
3357
|
);
|
|
3142
3358
|
}) });
|
|
3143
3359
|
}
|
|
3360
|
+
function SendStatus({ message, onRetry, onDiscard, align = "right" }) {
|
|
3361
|
+
const status = message.local_status;
|
|
3362
|
+
if (status !== "queued" && status !== "failed") return null;
|
|
3363
|
+
const failed = status === "failed";
|
|
3364
|
+
return /* @__PURE__ */ jsxs(
|
|
3365
|
+
"div",
|
|
3366
|
+
{
|
|
3367
|
+
className: [
|
|
3368
|
+
"poolse-send-status",
|
|
3369
|
+
`poolse-send-status--${status}`,
|
|
3370
|
+
`poolse-send-status--${align}`
|
|
3371
|
+
].join(" "),
|
|
3372
|
+
role: "status",
|
|
3373
|
+
children: [
|
|
3374
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-send-status__text", children: failed ? message.local_error ? `Not sent: ${message.local_error}` : "Not sent" : "Waiting for network\u2026" }),
|
|
3375
|
+
onRetry && /* @__PURE__ */ jsx("button", { type: "button", className: "poolse-send-status__button", onClick: onRetry, children: failed ? "Retry" : "Send now" }),
|
|
3376
|
+
failed && onDiscard && /* @__PURE__ */ jsx(
|
|
3377
|
+
"button",
|
|
3378
|
+
{
|
|
3379
|
+
type: "button",
|
|
3380
|
+
className: "poolse-send-status__button poolse-send-status__button--danger",
|
|
3381
|
+
onClick: onDiscard,
|
|
3382
|
+
children: "Delete"
|
|
3383
|
+
}
|
|
3384
|
+
)
|
|
3385
|
+
]
|
|
3386
|
+
}
|
|
3387
|
+
);
|
|
3388
|
+
}
|
|
3144
3389
|
function ThreadSummary({ message, onOpen, maxAvatars = 3, className }) {
|
|
3145
3390
|
const now = useNow();
|
|
3146
3391
|
const count = message.reply_count ?? 0;
|
|
@@ -3202,7 +3447,9 @@ function FlatMessageRow({
|
|
|
3202
3447
|
onAvatarPress,
|
|
3203
3448
|
timeFormat,
|
|
3204
3449
|
slots,
|
|
3205
|
-
mentionsMe = false
|
|
3450
|
+
mentionsMe = false,
|
|
3451
|
+
onRetrySend,
|
|
3452
|
+
onDiscardSend
|
|
3206
3453
|
}) {
|
|
3207
3454
|
const compact = layout === "compact";
|
|
3208
3455
|
const isSelf = meId !== null && msg.sender_id === meId;
|
|
@@ -3226,8 +3473,9 @@ function FlatMessageRow({
|
|
|
3226
3473
|
const time = formatMessageTime(msg.inserted_at, timeFormat);
|
|
3227
3474
|
const replyCount = msg.reply_count ?? 0;
|
|
3228
3475
|
const showThreadLink = threads && !msg.thread_root_id && replyCount > 0;
|
|
3229
|
-
const
|
|
3230
|
-
const
|
|
3476
|
+
const unsent = !!msg.local_status;
|
|
3477
|
+
const showActions = actions && !deleted && !editing && !unsent;
|
|
3478
|
+
const timeEl = (className) => /* @__PURE__ */ jsx("time", { className, dateTime: msg.inserted_at, children: className === "poolse-row__gutter-time" ? gutterTime(time) : time });
|
|
3231
3479
|
const avatarSize = compact ? "sm" : "md";
|
|
3232
3480
|
const avatarEl = /* @__PURE__ */ jsx(
|
|
3233
3481
|
Avatar,
|
|
@@ -3319,7 +3567,7 @@ function FlatMessageRow({
|
|
|
3319
3567
|
meta
|
|
3320
3568
|
}
|
|
3321
3569
|
);
|
|
3322
|
-
const reactionsEl = reactions && !deleted ? /* @__PURE__ */ jsx(
|
|
3570
|
+
const reactionsEl = reactions && !deleted && !unsent ? /* @__PURE__ */ jsx(
|
|
3323
3571
|
InlineReactions,
|
|
3324
3572
|
{
|
|
3325
3573
|
reactions: reactionsHook.reactions,
|
|
@@ -3360,7 +3608,16 @@ function FlatMessageRow({
|
|
|
3360
3608
|
renderSlot(slots?.body, ctx, body),
|
|
3361
3609
|
linkPreviews && !editing && hasLinkPreviews(msg) ? /* @__PURE__ */ jsx(MessageLinkPreviews, { message: msg, canRemove: isSelf }) : null,
|
|
3362
3610
|
renderSlot(slots?.reactions, ctx, reactionsEl),
|
|
3363
|
-
renderSlot(slots?.thread, ctx, threadEl)
|
|
3611
|
+
renderSlot(slots?.thread, ctx, threadEl),
|
|
3612
|
+
/* @__PURE__ */ jsx(
|
|
3613
|
+
SendStatus,
|
|
3614
|
+
{
|
|
3615
|
+
message: msg,
|
|
3616
|
+
align: "left",
|
|
3617
|
+
...onRetrySend ? { onRetry: onRetrySend } : {},
|
|
3618
|
+
...onDiscardSend ? { onDiscard: onDiscardSend } : {}
|
|
3619
|
+
}
|
|
3620
|
+
)
|
|
3364
3621
|
] });
|
|
3365
3622
|
return /* @__PURE__ */ jsxs(
|
|
3366
3623
|
"div",
|
|
@@ -3372,9 +3629,13 @@ function FlatMessageRow({
|
|
|
3372
3629
|
isRunStart ? "poolse-row--run-start" : "poolse-row--continued",
|
|
3373
3630
|
isSelf ? "poolse-row--self" : "",
|
|
3374
3631
|
mentionsMe ? "poolse-row--mention" : "",
|
|
3375
|
-
editing ? "poolse-row--editing" : ""
|
|
3632
|
+
editing ? "poolse-row--editing" : "",
|
|
3633
|
+
unsent ? "poolse-row--unsent" : ""
|
|
3376
3634
|
].filter(Boolean).join(" "),
|
|
3377
3635
|
"data-message-id": msg.id,
|
|
3636
|
+
role: "article",
|
|
3637
|
+
"aria-label": `Message from ${isSelf ? "you" : senderName}`,
|
|
3638
|
+
tabIndex: -1,
|
|
3378
3639
|
"data-actions-open": actionsOpen || void 0,
|
|
3379
3640
|
onClick: onRowClick,
|
|
3380
3641
|
children: [
|
|
@@ -3489,7 +3750,9 @@ function BubbleMessageRow({
|
|
|
3489
3750
|
onSenderPress,
|
|
3490
3751
|
onAvatarPress,
|
|
3491
3752
|
timeFormat,
|
|
3492
|
-
slots
|
|
3753
|
+
slots,
|
|
3754
|
+
onRetrySend,
|
|
3755
|
+
onDiscardSend
|
|
3493
3756
|
}) {
|
|
3494
3757
|
const { profile: senderProfile } = useUser(msg.sender_external_id);
|
|
3495
3758
|
const senderFallbackName = msg.sender_external_id ?? (msg.sender_id ? `User ${msg.sender_id.slice(0, 6)}` : "Unknown");
|
|
@@ -3506,8 +3769,9 @@ function BubbleMessageRow({
|
|
|
3506
3769
|
initialReactions: msg.reactions,
|
|
3507
3770
|
currentUserId: meId
|
|
3508
3771
|
});
|
|
3509
|
-
const
|
|
3510
|
-
const
|
|
3772
|
+
const unsent = !!msg.local_status;
|
|
3773
|
+
const showReactions = reactions && !msg.deleted_at && !unsent;
|
|
3774
|
+
const showActions = actions && !msg.deleted_at && !editing && !unsent;
|
|
3511
3775
|
const replyCount = msg.reply_count ?? 0;
|
|
3512
3776
|
const showThreadPill = threads && !msg.thread_root_id && replyCount > 0;
|
|
3513
3777
|
const handleSave = onSaveEdit ?? (async () => void 0);
|
|
@@ -3531,9 +3795,13 @@ function BubbleMessageRow({
|
|
|
3531
3795
|
// tighten the inter-bubble gap inside a cluster (first/middle/
|
|
3532
3796
|
// last) and widen it between clusters (standalone or the
|
|
3533
3797
|
// first of a new run).
|
|
3534
|
-
`poolse-message-row--${groupPosition}
|
|
3798
|
+
`poolse-message-row--${groupPosition}`,
|
|
3799
|
+
unsent ? "poolse-message-row--unsent" : ""
|
|
3535
3800
|
].filter(Boolean).join(" "),
|
|
3536
3801
|
"data-message-id": msg.id,
|
|
3802
|
+
role: "article",
|
|
3803
|
+
"aria-label": `Message from ${isSelf ? "you" : senderName}`,
|
|
3804
|
+
tabIndex: -1,
|
|
3537
3805
|
"data-actions-open": actionsOpen || void 0,
|
|
3538
3806
|
"data-avatar": showAvatar && !isSelf ? true : void 0,
|
|
3539
3807
|
onClick: onRowClick,
|
|
@@ -3595,6 +3863,15 @@ function BubbleMessageRow({
|
|
|
3595
3863
|
)
|
|
3596
3864
|
}
|
|
3597
3865
|
),
|
|
3866
|
+
/* @__PURE__ */ jsx(
|
|
3867
|
+
SendStatus,
|
|
3868
|
+
{
|
|
3869
|
+
message: msg,
|
|
3870
|
+
align: isSelf ? "right" : "left",
|
|
3871
|
+
...onRetrySend ? { onRetry: onRetrySend } : {},
|
|
3872
|
+
...onDiscardSend ? { onDiscard: onDiscardSend } : {}
|
|
3873
|
+
}
|
|
3874
|
+
),
|
|
3598
3875
|
renderSlot(
|
|
3599
3876
|
slots?.reactions,
|
|
3600
3877
|
slotContext,
|
|
@@ -3760,13 +4037,12 @@ function ThreadView({
|
|
|
3760
4037
|
}, [replies]);
|
|
3761
4038
|
useEffect(() => {
|
|
3762
4039
|
closeBtnRef.current?.focus();
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
}, [onClose]);
|
|
4040
|
+
}, []);
|
|
4041
|
+
const onPaneKeyDown = (e) => {
|
|
4042
|
+
if (e.key !== "Escape" || e.defaultPrevented || !onClose) return;
|
|
4043
|
+
e.preventDefault();
|
|
4044
|
+
onClose();
|
|
4045
|
+
};
|
|
3770
4046
|
const renderDefault = (msg) => /* @__PURE__ */ jsx(
|
|
3771
4047
|
MessageRow,
|
|
3772
4048
|
{
|
|
@@ -3799,6 +4075,7 @@ function ThreadView({
|
|
|
3799
4075
|
className: `poolse-thread${density ? ` poolse-conversation--density-${density}` : ""}${dragActive ? " is-drag-active" : ""}`,
|
|
3800
4076
|
role: "complementary",
|
|
3801
4077
|
"aria-label": "Message thread",
|
|
4078
|
+
onKeyDown: onPaneKeyDown,
|
|
3802
4079
|
onDragEnter,
|
|
3803
4080
|
onDragOver,
|
|
3804
4081
|
onDragLeave,
|
|
@@ -3819,9 +4096,9 @@ function ThreadView({
|
|
|
3819
4096
|
)
|
|
3820
4097
|
] }),
|
|
3821
4098
|
/* @__PURE__ */ jsx("div", { className: "poolse-thread__root", children: /* @__PURE__ */ jsx(MessageBubble, { message: rootMessage, currentUserId: me?.id ?? null }) }),
|
|
3822
|
-
/* @__PURE__ */ jsxs("div", { className: "poolse-thread__messages", ref: listRef, children: [
|
|
4099
|
+
/* @__PURE__ */ jsxs("div", { className: "poolse-thread__messages", ref: listRef, role: "log", "aria-label": "Replies", children: [
|
|
3823
4100
|
hasMore && !loading && replies.length > 0 && /* @__PURE__ */ jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older replies" }),
|
|
3824
|
-
loading && replies.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: "Loading replies\u2026" }) : replies.length === 0 ? /* @__PURE__ */ jsx(
|
|
4101
|
+
loading && replies.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: "Loading replies\u2026" }) : replies.length === 0 ? /* @__PURE__ */ jsx(EmptyState, { title: "No replies yet", hint: "Write a reply below to start the thread." }) : (
|
|
3825
4102
|
// Same Fragment trick as ConversationView so MessageBubble
|
|
3826
4103
|
// remains the direct flex child for align-self to work.
|
|
3827
4104
|
replies.map((msg) => /* @__PURE__ */ jsx(Fragment$1, { children: renderOne(msg, me?.id ?? null) }, msg.id))
|
|
@@ -3958,7 +4235,11 @@ function ConversationView({
|
|
|
3958
4235
|
onJoinCall,
|
|
3959
4236
|
currentCallId = null,
|
|
3960
4237
|
persistDrafts = TRUE,
|
|
3961
|
-
draftStorage
|
|
4238
|
+
draftStorage,
|
|
4239
|
+
keymap: keymapOverrides,
|
|
4240
|
+
sendOn = "enter",
|
|
4241
|
+
keyboardShortcuts = TRUE,
|
|
4242
|
+
confirmDelete
|
|
3962
4243
|
}) {
|
|
3963
4244
|
usePoolseFonts(loadFonts);
|
|
3964
4245
|
const showComposer = composer && !readOnly;
|
|
@@ -3973,10 +4254,13 @@ function ConversationView({
|
|
|
3973
4254
|
loadMore,
|
|
3974
4255
|
loadUntil,
|
|
3975
4256
|
send,
|
|
4257
|
+
retry: retrySend,
|
|
4258
|
+
discard: discardSend,
|
|
3976
4259
|
edit,
|
|
3977
4260
|
delete: deleteMsg,
|
|
3978
4261
|
markReadUpTo
|
|
3979
4262
|
} = useMessages(conversationId);
|
|
4263
|
+
const keymap = useMemo(() => resolveKeymap(keymapOverrides, sendOn), [keymapOverrides, sendOn]);
|
|
3980
4264
|
const { typing: typingPeople, signalTyping } = useTyping(conversationId);
|
|
3981
4265
|
const streams = useMessageStreams(conversationId);
|
|
3982
4266
|
const typing = useMemo(() => {
|
|
@@ -4269,18 +4553,19 @@ function ConversationView({
|
|
|
4269
4553
|
const meIdForDrafts = me?.id ?? null;
|
|
4270
4554
|
const draftsOn = persistDrafts && showComposer;
|
|
4271
4555
|
const storage = draftStorage ?? localDraftStorage;
|
|
4556
|
+
const drafts = draftsOf(chat);
|
|
4272
4557
|
const draftRef = useRef({ text: "", replyTo: null });
|
|
4273
4558
|
const draftKeyFor = useCallback(
|
|
4274
|
-
() => draftsOn && meIdForDrafts ?
|
|
4275
|
-
[draftsOn, meIdForDrafts]
|
|
4559
|
+
() => draftsOn && meIdForDrafts ? drafts.key(conversationIdRef.current) : null,
|
|
4560
|
+
[draftsOn, meIdForDrafts, drafts]
|
|
4276
4561
|
);
|
|
4277
4562
|
const saveDraft = useCallback(
|
|
4278
4563
|
(patch) => {
|
|
4279
4564
|
draftRef.current = { ...draftRef.current, ...patch };
|
|
4280
4565
|
const key = draftKeyFor();
|
|
4281
|
-
if (key)
|
|
4566
|
+
if (key) drafts.write(storage, key, draftRef.current);
|
|
4282
4567
|
},
|
|
4283
|
-
[draftKeyFor, storage]
|
|
4568
|
+
[draftKeyFor, storage, drafts]
|
|
4284
4569
|
);
|
|
4285
4570
|
const setReplyingTo = useCallback(
|
|
4286
4571
|
(m) => {
|
|
@@ -4301,13 +4586,14 @@ function ConversationView({
|
|
|
4301
4586
|
draftRef.current = { text: composer2?.getText() || d.text, replyTo: d.replyTo };
|
|
4302
4587
|
if (d.replyTo && canQuote) setReplyingToState((cur) => cur ?? d.replyTo);
|
|
4303
4588
|
};
|
|
4304
|
-
const
|
|
4589
|
+
const legacy = meIdForDrafts ? draftKey(meIdForDrafts, conversationIdRef.current) : void 0;
|
|
4590
|
+
const found = drafts.read(storage, key, legacy);
|
|
4305
4591
|
if (found instanceof Promise) void found.then(apply);
|
|
4306
4592
|
else apply(found);
|
|
4307
4593
|
return () => {
|
|
4308
4594
|
live = false;
|
|
4309
4595
|
};
|
|
4310
|
-
}, [conversationId, draftKeyFor, storage, canQuote, mentionComposer]);
|
|
4596
|
+
}, [conversationId, draftKeyFor, storage, canQuote, mentionComposer, drafts, meIdForDrafts]);
|
|
4311
4597
|
const onComposerChange = useCallback((text) => saveDraft({ text }), [saveDraft]);
|
|
4312
4598
|
useEffect(() => {
|
|
4313
4599
|
if (!replyingTo) return;
|
|
@@ -4356,11 +4642,13 @@ function ConversationView({
|
|
|
4356
4642
|
const files = Array.from(e.dataTransfer?.files ?? []);
|
|
4357
4643
|
if (files.length > 0) composerRef.current?.addFiles(files);
|
|
4358
4644
|
};
|
|
4359
|
-
const sendRequest = async (
|
|
4645
|
+
const sendRequest = async (input) => {
|
|
4646
|
+
const req = { ...input, id: input.id ?? safeUuid() };
|
|
4360
4647
|
try {
|
|
4361
4648
|
await send(req);
|
|
4362
4649
|
} catch (err) {
|
|
4363
4650
|
if (err instanceof ApiError && err.code === "quoted_message_deleted") {
|
|
4651
|
+
discardSend(req.id);
|
|
4364
4652
|
setReplyingTo(null);
|
|
4365
4653
|
setSendNotice("The message you replied to was deleted.");
|
|
4366
4654
|
const body = req.body;
|
|
@@ -4372,13 +4660,91 @@ function ConversationView({
|
|
|
4372
4660
|
}
|
|
4373
4661
|
return;
|
|
4374
4662
|
}
|
|
4375
|
-
throw err;
|
|
4663
|
+
if (!(err instanceof MessageQueuedError) && !chat.outboxEnabled) throw err;
|
|
4376
4664
|
}
|
|
4377
4665
|
setReplyingToState(null);
|
|
4378
4666
|
setUnreadMarker(null);
|
|
4379
4667
|
draftRef.current = { text: "", replyTo: null };
|
|
4380
4668
|
const key = draftKeyFor();
|
|
4381
|
-
if (key)
|
|
4669
|
+
if (key) drafts.clear(storage, key);
|
|
4670
|
+
};
|
|
4671
|
+
const editLast = () => {
|
|
4672
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
4673
|
+
const m = messages[i];
|
|
4674
|
+
if (!me || m.sender_id !== me.id || m.deleted_at || m.local_status) continue;
|
|
4675
|
+
if (m.thread_root_id) continue;
|
|
4676
|
+
const isRead = maxReadByOthers !== null && maxReadByOthers >= m.sequence;
|
|
4677
|
+
const editable = canEditOwnMessage({
|
|
4678
|
+
isSelf: true,
|
|
4679
|
+
deleted: false,
|
|
4680
|
+
receiptsVisible,
|
|
4681
|
+
readState: showReadState && maxReadByOthers !== null ? isRead ? "read" : "sent" : void 0,
|
|
4682
|
+
insertedAt: m.inserted_at
|
|
4683
|
+
});
|
|
4684
|
+
if (!editable) return false;
|
|
4685
|
+
setEditingId(m.id);
|
|
4686
|
+
return true;
|
|
4687
|
+
}
|
|
4688
|
+
return false;
|
|
4689
|
+
};
|
|
4690
|
+
const rowsInList = () => Array.from(listRef.current?.querySelectorAll("[data-message-id]") ?? []).filter(
|
|
4691
|
+
(el) => el.closest(".poolse-conversation__messages") === listRef.current
|
|
4692
|
+
);
|
|
4693
|
+
const focusRow = (el) => {
|
|
4694
|
+
if (!el) return;
|
|
4695
|
+
el.focus();
|
|
4696
|
+
if (typeof el.scrollIntoView === "function") {
|
|
4697
|
+
el.scrollIntoView({ block: "nearest", behavior: prefersReducedMotion() ? "auto" : "smooth" });
|
|
4698
|
+
}
|
|
4699
|
+
};
|
|
4700
|
+
const onListKeyDown = (e) => {
|
|
4701
|
+
if (!keyboardShortcuts || isTypingTarget(e.target)) return;
|
|
4702
|
+
const km = keymap.messageList;
|
|
4703
|
+
const rows = rowsInList();
|
|
4704
|
+
if (rows.length === 0) return;
|
|
4705
|
+
const focused = e.target.closest?.("[data-message-id]");
|
|
4706
|
+
const idx = focused ? rows.indexOf(focused) : -1;
|
|
4707
|
+
const focusedMsg = focused ? messages.find((m) => m.id === focused.dataset["messageId"]) ?? null : null;
|
|
4708
|
+
const handled = () => {
|
|
4709
|
+
e.preventDefault();
|
|
4710
|
+
e.stopPropagation();
|
|
4711
|
+
};
|
|
4712
|
+
if (matchesAny(e, km.next)) {
|
|
4713
|
+
handled();
|
|
4714
|
+
focusRow(rows[idx === -1 ? rows.length - 1 : Math.min(rows.length - 1, idx + 1)]);
|
|
4715
|
+
} else if (matchesAny(e, km.prev)) {
|
|
4716
|
+
handled();
|
|
4717
|
+
focusRow(rows[idx === -1 ? rows.length - 1 : Math.max(0, idx - 1)]);
|
|
4718
|
+
} else if (matchesAny(e, km.last)) {
|
|
4719
|
+
handled();
|
|
4720
|
+
focusRow(rows[rows.length - 1]);
|
|
4721
|
+
} else if (matchesAny(e, km.first)) {
|
|
4722
|
+
handled();
|
|
4723
|
+
focusRow(rows[0]);
|
|
4724
|
+
} else if (matchesAny(e, km.composer)) {
|
|
4725
|
+
if (!showComposer) return;
|
|
4726
|
+
handled();
|
|
4727
|
+
composerRef.current?.focus();
|
|
4728
|
+
} else if (focusedMsg && !focusedMsg.deleted_at && !focusedMsg.local_status) {
|
|
4729
|
+
const isSelf = me !== null && focusedMsg.sender_id === me.id;
|
|
4730
|
+
if (matchesAny(e, km.reply) && canQuote) {
|
|
4731
|
+
handled();
|
|
4732
|
+
setReplyingTo(focusedMsg);
|
|
4733
|
+
composerRef.current?.focus();
|
|
4734
|
+
} else if (matchesAny(e, km.thread) && threads) {
|
|
4735
|
+
handled();
|
|
4736
|
+
setThreadRootId(focusedMsg.id);
|
|
4737
|
+
} else if (matchesAny(e, km.edit) && isSelf && showComposer) {
|
|
4738
|
+
handled();
|
|
4739
|
+
setEditingId(focusedMsg.id);
|
|
4740
|
+
} else if (matchesAny(e, km.delete) && isSelf && actions) {
|
|
4741
|
+
handled();
|
|
4742
|
+
const ask = confirmDelete ?? (() => typeof globalThis.confirm === "function" ? globalThis.confirm("Delete this message?") : false);
|
|
4743
|
+
void Promise.resolve(ask(focusedMsg)).then((ok) => {
|
|
4744
|
+
if (ok) void deleteMsg(focusedMsg.id).catch(() => void 0);
|
|
4745
|
+
});
|
|
4746
|
+
}
|
|
4747
|
+
}
|
|
4382
4748
|
};
|
|
4383
4749
|
const onSendBody = (body, opts) => sendRequest({
|
|
4384
4750
|
body,
|
|
@@ -4398,6 +4764,8 @@ function ConversationView({
|
|
|
4398
4764
|
conversationId,
|
|
4399
4765
|
onSend: onSendWithMentions,
|
|
4400
4766
|
onTyping: signalTyping,
|
|
4767
|
+
keymap: keymap.composer,
|
|
4768
|
+
onEditLast: editLast,
|
|
4401
4769
|
attachments,
|
|
4402
4770
|
emojiPicker,
|
|
4403
4771
|
...attachmentRules,
|
|
@@ -4412,6 +4780,8 @@ function ConversationView({
|
|
|
4412
4780
|
onValueChange: onComposerChange,
|
|
4413
4781
|
onSend: onSendBody,
|
|
4414
4782
|
onTyping: signalTyping,
|
|
4783
|
+
keymap: keymap.composer,
|
|
4784
|
+
onEditLast: editLast,
|
|
4415
4785
|
attachments,
|
|
4416
4786
|
emojiPicker,
|
|
4417
4787
|
...attachmentRules,
|
|
@@ -4476,6 +4846,8 @@ function ConversationView({
|
|
|
4476
4846
|
"aria-label": "Conversation messages",
|
|
4477
4847
|
"aria-live": "polite",
|
|
4478
4848
|
"aria-relevant": "additions",
|
|
4849
|
+
tabIndex: 0,
|
|
4850
|
+
onKeyDown: onListKeyDown,
|
|
4479
4851
|
children: [
|
|
4480
4852
|
hasMore && /* @__PURE__ */ jsx("div", { ref: topSentinelRef, "aria-hidden": "true", style: { height: 1 } }),
|
|
4481
4853
|
showJump && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__jump-unread", children: [
|
|
@@ -4503,7 +4875,13 @@ function ConversationView({
|
|
|
4503
4875
|
}
|
|
4504
4876
|
)
|
|
4505
4877
|
] }),
|
|
4506
|
-
loading && messages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: "Loading\u2026" }) : messages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: emptyState
|
|
4878
|
+
loading && messages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: "Loading\u2026" }) : messages.length === 0 && !error ? typeof emptyState === "function" ? emptyState({ readOnly: !showComposer }) : emptyState !== void 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: emptyState }) : /* @__PURE__ */ jsx(
|
|
4879
|
+
EmptyState,
|
|
4880
|
+
{
|
|
4881
|
+
title: "No messages yet",
|
|
4882
|
+
...showComposer ? { hint: "Write the first message below \u2014 everyone here will see it." } : {}
|
|
4883
|
+
}
|
|
4884
|
+
) : visibleMessages.map((msg, idx) => {
|
|
4507
4885
|
const prev = idx > 0 ? visibleMessages[idx - 1] ?? null : null;
|
|
4508
4886
|
const next = idx < visibleMessages.length - 1 ? visibleMessages[idx + 1] ?? null : null;
|
|
4509
4887
|
const groupPosition = grouping ? computeGroupPosition(msg, prev, next, groupWindowMs) : "standalone";
|
|
@@ -4562,6 +4940,10 @@ function ConversationView({
|
|
|
4562
4940
|
onQuote: () => setReplyingTo(msg),
|
|
4563
4941
|
...!isSelf && msg.sequence !== Number.MAX_SAFE_INTEGER ? { onMarkUnread: () => void markUnreadFrom(msg) } : {},
|
|
4564
4942
|
onQuotedClick: scrollToOriginal,
|
|
4943
|
+
...msg.local_status ? {
|
|
4944
|
+
onRetrySend: () => void retrySend(msg.id).catch(() => void 0),
|
|
4945
|
+
onDiscardSend: () => discardSend(msg.id)
|
|
4946
|
+
} : {},
|
|
4565
4947
|
...onCallBack ? { onCallBack } : {},
|
|
4566
4948
|
...layoutProps,
|
|
4567
4949
|
mentionsMe: mentionsViewer(msg, me?.id ?? null)
|
|
@@ -4663,12 +5045,12 @@ function ConversationView({
|
|
|
4663
5045
|
var NO_MESSAGE = "00000000-0000-0000-0000-000000000000";
|
|
4664
5046
|
function scrollDividerIntoView(el) {
|
|
4665
5047
|
if (el && typeof el.scrollIntoView === "function") {
|
|
4666
|
-
el.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
5048
|
+
el.scrollIntoView({ behavior: prefersReducedMotion() ? "auto" : "smooth", block: "start" });
|
|
4667
5049
|
}
|
|
4668
5050
|
}
|
|
4669
5051
|
function highlightRow(el) {
|
|
4670
5052
|
if (typeof el.scrollIntoView === "function") {
|
|
4671
|
-
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
5053
|
+
el.scrollIntoView({ behavior: prefersReducedMotion() ? "auto" : "smooth", block: "center" });
|
|
4672
5054
|
}
|
|
4673
5055
|
el.classList.add("poolse-message-row--highlight");
|
|
4674
5056
|
setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
|
|
@@ -4777,6 +5159,8 @@ function ConversationList({
|
|
|
4777
5159
|
onSelect,
|
|
4778
5160
|
renderItem,
|
|
4779
5161
|
emptyState,
|
|
5162
|
+
query = "",
|
|
5163
|
+
noResultsState,
|
|
4780
5164
|
conversations: controlledConversations,
|
|
4781
5165
|
loading: controlledLoading,
|
|
4782
5166
|
error: controlledError,
|
|
@@ -4797,7 +5181,15 @@ function ConversationList({
|
|
|
4797
5181
|
const meExternalId = me?.external_id ?? null;
|
|
4798
5182
|
const meId = me?.id ?? null;
|
|
4799
5183
|
const isControlled = controlledConversations !== void 0;
|
|
4800
|
-
const
|
|
5184
|
+
const allConversations = isControlled ? controlledConversations : auto.conversations;
|
|
5185
|
+
const needle = query.trim().toLowerCase();
|
|
5186
|
+
const conversations = useMemo(
|
|
5187
|
+
() => needle ? filterConversations(allConversations, needle, {
|
|
5188
|
+
meExternalId,
|
|
5189
|
+
...labelFor ? { labelFor } : {}
|
|
5190
|
+
}) : allConversations,
|
|
5191
|
+
[allConversations, needle, meExternalId, labelFor]
|
|
5192
|
+
);
|
|
4801
5193
|
const loading = isControlled ? controlledLoading ?? false : auto.loading;
|
|
4802
5194
|
const error = isControlled ? controlledError ?? null : auto.error;
|
|
4803
5195
|
const counts = unreadCounts ?? (isControlled ? void 0 : auto.unreadCounts);
|
|
@@ -4845,8 +5237,23 @@ function ConversationList({
|
|
|
4845
5237
|
if (error && conversations.length === 0) {
|
|
4846
5238
|
return /* @__PURE__ */ jsx("div", { className: "poolse-list poolse-list--placeholder poolse-list--error", children: "Failed to load conversations." });
|
|
4847
5239
|
}
|
|
5240
|
+
if (conversations.length === 0 && needle && allConversations.length > 0) {
|
|
5241
|
+
return typeof noResultsState === "function" ? noResultsState(query.trim()) : noResultsState !== void 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-list poolse-list--placeholder", children: noResultsState }) : /* @__PURE__ */ jsx(
|
|
5242
|
+
EmptyState,
|
|
5243
|
+
{
|
|
5244
|
+
title: `Nothing matches \u201C${query.trim()}\u201D`,
|
|
5245
|
+
hint: "Check the spelling, or search by a person's or channel's name."
|
|
5246
|
+
}
|
|
5247
|
+
);
|
|
5248
|
+
}
|
|
4848
5249
|
if (conversations.length === 0) {
|
|
4849
|
-
return /* @__PURE__ */ jsx("div", { className: "poolse-list poolse-list--placeholder", children: emptyState
|
|
5250
|
+
return emptyState !== void 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-list poolse-list--placeholder", children: emptyState }) : /* @__PURE__ */ jsx(
|
|
5251
|
+
EmptyState,
|
|
5252
|
+
{
|
|
5253
|
+
title: "No conversations yet",
|
|
5254
|
+
hint: "Start a chat with someone, or join a channel \u2014 it shows up here."
|
|
5255
|
+
}
|
|
5256
|
+
);
|
|
4850
5257
|
}
|
|
4851
5258
|
const row = (conv) => {
|
|
4852
5259
|
const selected = selectedId === conv.id;
|
|
@@ -4885,10 +5292,10 @@ function ConversationList({
|
|
|
4885
5292
|
);
|
|
4886
5293
|
};
|
|
4887
5294
|
return /* @__PURE__ */ jsxs("ul", { ref: listRef, className: "poolse-list", role: "listbox", "aria-label": "Conversations", children: [
|
|
4888
|
-
groups === null ? conversations.map(row) : groups.map((g) => /* @__PURE__ */
|
|
5295
|
+
groups === null ? conversations.map(row) : groups.map((g) => /* @__PURE__ */ jsx("li", { role: "presentation", className: "poolse-list__section", children: /* @__PURE__ */ jsxs("div", { role: "group", "aria-label": g.title, children: [
|
|
4889
5296
|
/* @__PURE__ */ jsx("div", { className: "poolse-list__section-title", "aria-hidden": "true", children: g.title }),
|
|
4890
5297
|
/* @__PURE__ */ jsx("ul", { className: "poolse-list__section-items", role: "presentation", children: g.conversations.map(row) })
|
|
4891
|
-
] }, g.title)),
|
|
5298
|
+
] }) }, g.title)),
|
|
4892
5299
|
loadingMore && /* @__PURE__ */ jsx("li", { className: "poolse-list__loading-more", role: "presentation", children: "Loading\u2026" }),
|
|
4893
5300
|
hasMore && /* @__PURE__ */ jsx(
|
|
4894
5301
|
"li",
|
|
@@ -5206,7 +5613,7 @@ function UserPickerSheet({
|
|
|
5206
5613
|
}
|
|
5207
5614
|
)
|
|
5208
5615
|
] }),
|
|
5209
|
-
/* @__PURE__ */ jsx("ul", { className: "poolse-user-picker", role: "listbox", "aria-label": "Users", children: filtered.length === 0 ? /* @__PURE__ */ jsx("li", { className: "poolse-user-picker__empty", children: "No
|
|
5616
|
+
/* @__PURE__ */ jsx("ul", { className: "poolse-user-picker", role: "listbox", "aria-label": "Users", children: filtered.length === 0 ? /* @__PURE__ */ jsx("li", { className: "poolse-user-picker__empty", children: "No one matches that. Try part of a first or last name." }) : filtered.map((u) => {
|
|
5210
5617
|
const isSelected = selected.has(u.externalId);
|
|
5211
5618
|
return /* @__PURE__ */ jsxs(
|
|
5212
5619
|
"li",
|
|
@@ -5842,6 +6249,6 @@ function PoolseLogo({
|
|
|
5842
6249
|
);
|
|
5843
6250
|
}
|
|
5844
6251
|
|
|
5845
|
-
export { AttachmentPreview, Avatar, CallControlButton, CallDeviceMenu, CallLogRow, CallVideoGrid, ChatHeader, ConversationList, ConversationView, EditableMessageBubble, EditedLabel, EmojiPicker, GroupDetailsSheet, LinkPreviewCard, LiveCallBanner, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, PoolseFonts, PoolseIcon, PoolseInbox, PoolseLogo, PoolseTheme, PresenceBadge, ReactionPicker, ReactionStrip, RoomJoinBar, RoomStage, ThreadSummary, ThreadView, TypingIndicator, UploadQueueStrip, UserName, UserPickerSheet, formatRelativeTime, loadEmojiData, localDraftStorage, presenceStateLabel, presenceText, useDisplayName, useEditHistory, usePoolseFonts, useSystemColorScheme, useTheme };
|
|
6252
|
+
export { AttachmentPreview, Avatar, CallControlButton, CallDeviceMenu, CallLogRow, CallVideoGrid, ChatHeader, ConversationList, ConversationView, DEFAULT_KEYMAP, DraftScope, EditableMessageBubble, EditedLabel, EmojiPicker, EmptyState, GroupDetailsSheet, LinkPreviewCard, LiveCallBanner, MOD_ENTER_COMPOSER, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, PoolseFonts, PoolseIcon, PoolseInbox, PoolseLogo, PoolseTheme, PresenceBadge, ReactionPicker, ReactionStrip, RoomJoinBar, RoomStage, SendStatus, ThreadSummary, ThreadView, TypingIndicator, UploadQueueStrip, UserName, UserPickerSheet, draftsOf, formatRelativeTime, loadEmojiData, localDraftStorage, matchesAny, matchesKey, presenceStateLabel, presenceText, resolveKeymap, useDisplayName, useEditHistory, usePoolseFonts, useSystemColorScheme, useTheme };
|
|
5846
6253
|
//# sourceMappingURL=index.js.map
|
|
5847
6254
|
//# sourceMappingURL=index.js.map
|