@poolse/react-ui 3.7.1 → 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 +27 -0
- package/README.md +33 -0
- package/dist/index.cjs +492 -78
- 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 +485 -80
- package/dist/index.js.map +1 -1
- package/dist/styles.css +131 -0
- 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,6 +912,93 @@ 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
|
|
830
1004
|
function gutterTime(time) {
|
|
@@ -1482,7 +1656,9 @@ var MentionInput = forwardRef(
|
|
|
1482
1656
|
emojiPicker = true,
|
|
1483
1657
|
maxFileSize,
|
|
1484
1658
|
acceptFileTypes,
|
|
1485
|
-
onValueChange
|
|
1659
|
+
onValueChange,
|
|
1660
|
+
keymap = DEFAULT_KEYMAP.composer,
|
|
1661
|
+
onEditLast
|
|
1486
1662
|
}, ref) {
|
|
1487
1663
|
const chat = usePoolse();
|
|
1488
1664
|
const { members } = useMembers(conversationId);
|
|
@@ -1633,10 +1809,26 @@ var MentionInput = forwardRef(
|
|
|
1633
1809
|
return;
|
|
1634
1810
|
}
|
|
1635
1811
|
}
|
|
1636
|
-
|
|
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") {
|
|
1637
1829
|
const ta = e.currentTarget;
|
|
1638
1830
|
const caret = ta.selectionStart;
|
|
1639
|
-
const result = handleListEnter(value, caret);
|
|
1831
|
+
const result = e.key === "Enter" && !e.metaKey && !e.ctrlKey ? handleListEnter(value, caret) : null;
|
|
1640
1832
|
if (result) {
|
|
1641
1833
|
e.preventDefault();
|
|
1642
1834
|
setValue(result.value);
|
|
@@ -1648,7 +1840,7 @@ var MentionInput = forwardRef(
|
|
|
1648
1840
|
e.preventDefault();
|
|
1649
1841
|
void submit();
|
|
1650
1842
|
}
|
|
1651
|
-
if (
|
|
1843
|
+
if (action === "cancel" && replyingTo && onCancelReply && !mention) {
|
|
1652
1844
|
e.preventDefault();
|
|
1653
1845
|
onCancelReply();
|
|
1654
1846
|
}
|
|
@@ -1704,6 +1896,8 @@ var MentionInput = forwardRef(
|
|
|
1704
1896
|
multiple: true,
|
|
1705
1897
|
...uploads.accept ? { accept: uploads.accept } : {},
|
|
1706
1898
|
className: "poolse-attach-input",
|
|
1899
|
+
"aria-label": "Attach files",
|
|
1900
|
+
tabIndex: -1,
|
|
1707
1901
|
onChange: (e) => {
|
|
1708
1902
|
const files = Array.from(e.target.files ?? []);
|
|
1709
1903
|
if (files.length > 0) addFiles(files);
|
|
@@ -1737,11 +1931,11 @@ var MentionInput = forwardRef(
|
|
|
1737
1931
|
placeholder,
|
|
1738
1932
|
disabled: disabled || sending,
|
|
1739
1933
|
"aria-label": placeholder,
|
|
1740
|
-
role: "combobox",
|
|
1741
|
-
"aria-expanded": Boolean(mention && filtered.length > 0),
|
|
1742
|
-
"aria-controls": menuId,
|
|
1743
1934
|
"aria-autocomplete": "list",
|
|
1744
|
-
...mention && filtered.length > 0 ? {
|
|
1935
|
+
...mention && filtered.length > 0 ? {
|
|
1936
|
+
"aria-controls": menuId,
|
|
1937
|
+
"aria-activedescendant": `${menuId}-opt-${activeIdx}`
|
|
1938
|
+
} : {}
|
|
1745
1939
|
}
|
|
1746
1940
|
),
|
|
1747
1941
|
emojiPicker && /* @__PURE__ */ jsx(
|
|
@@ -1815,7 +2009,9 @@ var MessageComposer = forwardRef(
|
|
|
1815
2009
|
emojiPicker = true,
|
|
1816
2010
|
maxFileSize,
|
|
1817
2011
|
acceptFileTypes,
|
|
1818
|
-
onValueChange
|
|
2012
|
+
onValueChange,
|
|
2013
|
+
keymap = DEFAULT_KEYMAP.composer,
|
|
2014
|
+
onEditLast
|
|
1819
2015
|
}, ref) {
|
|
1820
2016
|
const [value, setValue] = useState("");
|
|
1821
2017
|
const [sending, setSending] = useState(false);
|
|
@@ -1869,10 +2065,26 @@ var MessageComposer = forwardRef(
|
|
|
1869
2065
|
}
|
|
1870
2066
|
};
|
|
1871
2067
|
const onKeyDown = (e) => {
|
|
1872
|
-
|
|
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") {
|
|
1873
2085
|
const ta = e.currentTarget;
|
|
1874
2086
|
const caret = ta.selectionStart;
|
|
1875
|
-
const result = handleListEnter(value, caret);
|
|
2087
|
+
const result = e.key === "Enter" && !e.metaKey && !e.ctrlKey ? handleListEnter(value, caret) : null;
|
|
1876
2088
|
if (result) {
|
|
1877
2089
|
e.preventDefault();
|
|
1878
2090
|
setValue(result.value);
|
|
@@ -1884,7 +2096,7 @@ var MessageComposer = forwardRef(
|
|
|
1884
2096
|
e.preventDefault();
|
|
1885
2097
|
void submit();
|
|
1886
2098
|
}
|
|
1887
|
-
if (
|
|
2099
|
+
if (action === "cancel" && replyingTo && onCancelReply) {
|
|
1888
2100
|
e.preventDefault();
|
|
1889
2101
|
onCancelReply();
|
|
1890
2102
|
}
|
|
@@ -1930,6 +2142,8 @@ var MessageComposer = forwardRef(
|
|
|
1930
2142
|
multiple: true,
|
|
1931
2143
|
...uploads.accept ? { accept: uploads.accept } : {},
|
|
1932
2144
|
className: "poolse-attach-input",
|
|
2145
|
+
"aria-label": "Attach files",
|
|
2146
|
+
tabIndex: -1,
|
|
1933
2147
|
onChange: (e) => {
|
|
1934
2148
|
const files = Array.from(e.target.files ?? []);
|
|
1935
2149
|
if (files.length > 0) addFiles(files);
|
|
@@ -3143,6 +3357,35 @@ function InlineReactions({
|
|
|
3143
3357
|
);
|
|
3144
3358
|
}) });
|
|
3145
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
|
+
}
|
|
3146
3389
|
function ThreadSummary({ message, onOpen, maxAvatars = 3, className }) {
|
|
3147
3390
|
const now = useNow();
|
|
3148
3391
|
const count = message.reply_count ?? 0;
|
|
@@ -3204,7 +3447,9 @@ function FlatMessageRow({
|
|
|
3204
3447
|
onAvatarPress,
|
|
3205
3448
|
timeFormat,
|
|
3206
3449
|
slots,
|
|
3207
|
-
mentionsMe = false
|
|
3450
|
+
mentionsMe = false,
|
|
3451
|
+
onRetrySend,
|
|
3452
|
+
onDiscardSend
|
|
3208
3453
|
}) {
|
|
3209
3454
|
const compact = layout === "compact";
|
|
3210
3455
|
const isSelf = meId !== null && msg.sender_id === meId;
|
|
@@ -3228,7 +3473,8 @@ function FlatMessageRow({
|
|
|
3228
3473
|
const time = formatMessageTime(msg.inserted_at, timeFormat);
|
|
3229
3474
|
const replyCount = msg.reply_count ?? 0;
|
|
3230
3475
|
const showThreadLink = threads && !msg.thread_root_id && replyCount > 0;
|
|
3231
|
-
const
|
|
3476
|
+
const unsent = !!msg.local_status;
|
|
3477
|
+
const showActions = actions && !deleted && !editing && !unsent;
|
|
3232
3478
|
const timeEl = (className) => /* @__PURE__ */ jsx("time", { className, dateTime: msg.inserted_at, children: className === "poolse-row__gutter-time" ? gutterTime(time) : time });
|
|
3233
3479
|
const avatarSize = compact ? "sm" : "md";
|
|
3234
3480
|
const avatarEl = /* @__PURE__ */ jsx(
|
|
@@ -3321,7 +3567,7 @@ function FlatMessageRow({
|
|
|
3321
3567
|
meta
|
|
3322
3568
|
}
|
|
3323
3569
|
);
|
|
3324
|
-
const reactionsEl = reactions && !deleted ? /* @__PURE__ */ jsx(
|
|
3570
|
+
const reactionsEl = reactions && !deleted && !unsent ? /* @__PURE__ */ jsx(
|
|
3325
3571
|
InlineReactions,
|
|
3326
3572
|
{
|
|
3327
3573
|
reactions: reactionsHook.reactions,
|
|
@@ -3362,7 +3608,16 @@ function FlatMessageRow({
|
|
|
3362
3608
|
renderSlot(slots?.body, ctx, body),
|
|
3363
3609
|
linkPreviews && !editing && hasLinkPreviews(msg) ? /* @__PURE__ */ jsx(MessageLinkPreviews, { message: msg, canRemove: isSelf }) : null,
|
|
3364
3610
|
renderSlot(slots?.reactions, ctx, reactionsEl),
|
|
3365
|
-
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
|
+
)
|
|
3366
3621
|
] });
|
|
3367
3622
|
return /* @__PURE__ */ jsxs(
|
|
3368
3623
|
"div",
|
|
@@ -3374,9 +3629,13 @@ function FlatMessageRow({
|
|
|
3374
3629
|
isRunStart ? "poolse-row--run-start" : "poolse-row--continued",
|
|
3375
3630
|
isSelf ? "poolse-row--self" : "",
|
|
3376
3631
|
mentionsMe ? "poolse-row--mention" : "",
|
|
3377
|
-
editing ? "poolse-row--editing" : ""
|
|
3632
|
+
editing ? "poolse-row--editing" : "",
|
|
3633
|
+
unsent ? "poolse-row--unsent" : ""
|
|
3378
3634
|
].filter(Boolean).join(" "),
|
|
3379
3635
|
"data-message-id": msg.id,
|
|
3636
|
+
role: "article",
|
|
3637
|
+
"aria-label": `Message from ${isSelf ? "you" : senderName}`,
|
|
3638
|
+
tabIndex: -1,
|
|
3380
3639
|
"data-actions-open": actionsOpen || void 0,
|
|
3381
3640
|
onClick: onRowClick,
|
|
3382
3641
|
children: [
|
|
@@ -3491,7 +3750,9 @@ function BubbleMessageRow({
|
|
|
3491
3750
|
onSenderPress,
|
|
3492
3751
|
onAvatarPress,
|
|
3493
3752
|
timeFormat,
|
|
3494
|
-
slots
|
|
3753
|
+
slots,
|
|
3754
|
+
onRetrySend,
|
|
3755
|
+
onDiscardSend
|
|
3495
3756
|
}) {
|
|
3496
3757
|
const { profile: senderProfile } = useUser(msg.sender_external_id);
|
|
3497
3758
|
const senderFallbackName = msg.sender_external_id ?? (msg.sender_id ? `User ${msg.sender_id.slice(0, 6)}` : "Unknown");
|
|
@@ -3508,8 +3769,9 @@ function BubbleMessageRow({
|
|
|
3508
3769
|
initialReactions: msg.reactions,
|
|
3509
3770
|
currentUserId: meId
|
|
3510
3771
|
});
|
|
3511
|
-
const
|
|
3512
|
-
const
|
|
3772
|
+
const unsent = !!msg.local_status;
|
|
3773
|
+
const showReactions = reactions && !msg.deleted_at && !unsent;
|
|
3774
|
+
const showActions = actions && !msg.deleted_at && !editing && !unsent;
|
|
3513
3775
|
const replyCount = msg.reply_count ?? 0;
|
|
3514
3776
|
const showThreadPill = threads && !msg.thread_root_id && replyCount > 0;
|
|
3515
3777
|
const handleSave = onSaveEdit ?? (async () => void 0);
|
|
@@ -3533,9 +3795,13 @@ function BubbleMessageRow({
|
|
|
3533
3795
|
// tighten the inter-bubble gap inside a cluster (first/middle/
|
|
3534
3796
|
// last) and widen it between clusters (standalone or the
|
|
3535
3797
|
// first of a new run).
|
|
3536
|
-
`poolse-message-row--${groupPosition}
|
|
3798
|
+
`poolse-message-row--${groupPosition}`,
|
|
3799
|
+
unsent ? "poolse-message-row--unsent" : ""
|
|
3537
3800
|
].filter(Boolean).join(" "),
|
|
3538
3801
|
"data-message-id": msg.id,
|
|
3802
|
+
role: "article",
|
|
3803
|
+
"aria-label": `Message from ${isSelf ? "you" : senderName}`,
|
|
3804
|
+
tabIndex: -1,
|
|
3539
3805
|
"data-actions-open": actionsOpen || void 0,
|
|
3540
3806
|
"data-avatar": showAvatar && !isSelf ? true : void 0,
|
|
3541
3807
|
onClick: onRowClick,
|
|
@@ -3597,6 +3863,15 @@ function BubbleMessageRow({
|
|
|
3597
3863
|
)
|
|
3598
3864
|
}
|
|
3599
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
|
+
),
|
|
3600
3875
|
renderSlot(
|
|
3601
3876
|
slots?.reactions,
|
|
3602
3877
|
slotContext,
|
|
@@ -3762,13 +4037,12 @@ function ThreadView({
|
|
|
3762
4037
|
}, [replies]);
|
|
3763
4038
|
useEffect(() => {
|
|
3764
4039
|
closeBtnRef.current?.focus();
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
}, [onClose]);
|
|
4040
|
+
}, []);
|
|
4041
|
+
const onPaneKeyDown = (e) => {
|
|
4042
|
+
if (e.key !== "Escape" || e.defaultPrevented || !onClose) return;
|
|
4043
|
+
e.preventDefault();
|
|
4044
|
+
onClose();
|
|
4045
|
+
};
|
|
3772
4046
|
const renderDefault = (msg) => /* @__PURE__ */ jsx(
|
|
3773
4047
|
MessageRow,
|
|
3774
4048
|
{
|
|
@@ -3801,6 +4075,7 @@ function ThreadView({
|
|
|
3801
4075
|
className: `poolse-thread${density ? ` poolse-conversation--density-${density}` : ""}${dragActive ? " is-drag-active" : ""}`,
|
|
3802
4076
|
role: "complementary",
|
|
3803
4077
|
"aria-label": "Message thread",
|
|
4078
|
+
onKeyDown: onPaneKeyDown,
|
|
3804
4079
|
onDragEnter,
|
|
3805
4080
|
onDragOver,
|
|
3806
4081
|
onDragLeave,
|
|
@@ -3821,9 +4096,9 @@ function ThreadView({
|
|
|
3821
4096
|
)
|
|
3822
4097
|
] }),
|
|
3823
4098
|
/* @__PURE__ */ jsx("div", { className: "poolse-thread__root", children: /* @__PURE__ */ jsx(MessageBubble, { message: rootMessage, currentUserId: me?.id ?? null }) }),
|
|
3824
|
-
/* @__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: [
|
|
3825
4100
|
hasMore && !loading && replies.length > 0 && /* @__PURE__ */ jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older replies" }),
|
|
3826
|
-
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." }) : (
|
|
3827
4102
|
// Same Fragment trick as ConversationView so MessageBubble
|
|
3828
4103
|
// remains the direct flex child for align-self to work.
|
|
3829
4104
|
replies.map((msg) => /* @__PURE__ */ jsx(Fragment$1, { children: renderOne(msg, me?.id ?? null) }, msg.id))
|
|
@@ -3960,7 +4235,11 @@ function ConversationView({
|
|
|
3960
4235
|
onJoinCall,
|
|
3961
4236
|
currentCallId = null,
|
|
3962
4237
|
persistDrafts = TRUE,
|
|
3963
|
-
draftStorage
|
|
4238
|
+
draftStorage,
|
|
4239
|
+
keymap: keymapOverrides,
|
|
4240
|
+
sendOn = "enter",
|
|
4241
|
+
keyboardShortcuts = TRUE,
|
|
4242
|
+
confirmDelete
|
|
3964
4243
|
}) {
|
|
3965
4244
|
usePoolseFonts(loadFonts);
|
|
3966
4245
|
const showComposer = composer && !readOnly;
|
|
@@ -3975,10 +4254,13 @@ function ConversationView({
|
|
|
3975
4254
|
loadMore,
|
|
3976
4255
|
loadUntil,
|
|
3977
4256
|
send,
|
|
4257
|
+
retry: retrySend,
|
|
4258
|
+
discard: discardSend,
|
|
3978
4259
|
edit,
|
|
3979
4260
|
delete: deleteMsg,
|
|
3980
4261
|
markReadUpTo
|
|
3981
4262
|
} = useMessages(conversationId);
|
|
4263
|
+
const keymap = useMemo(() => resolveKeymap(keymapOverrides, sendOn), [keymapOverrides, sendOn]);
|
|
3982
4264
|
const { typing: typingPeople, signalTyping } = useTyping(conversationId);
|
|
3983
4265
|
const streams = useMessageStreams(conversationId);
|
|
3984
4266
|
const typing = useMemo(() => {
|
|
@@ -4271,18 +4553,19 @@ function ConversationView({
|
|
|
4271
4553
|
const meIdForDrafts = me?.id ?? null;
|
|
4272
4554
|
const draftsOn = persistDrafts && showComposer;
|
|
4273
4555
|
const storage = draftStorage ?? localDraftStorage;
|
|
4556
|
+
const drafts = draftsOf(chat);
|
|
4274
4557
|
const draftRef = useRef({ text: "", replyTo: null });
|
|
4275
4558
|
const draftKeyFor = useCallback(
|
|
4276
|
-
() => draftsOn && meIdForDrafts ?
|
|
4277
|
-
[draftsOn, meIdForDrafts]
|
|
4559
|
+
() => draftsOn && meIdForDrafts ? drafts.key(conversationIdRef.current) : null,
|
|
4560
|
+
[draftsOn, meIdForDrafts, drafts]
|
|
4278
4561
|
);
|
|
4279
4562
|
const saveDraft = useCallback(
|
|
4280
4563
|
(patch) => {
|
|
4281
4564
|
draftRef.current = { ...draftRef.current, ...patch };
|
|
4282
4565
|
const key = draftKeyFor();
|
|
4283
|
-
if (key)
|
|
4566
|
+
if (key) drafts.write(storage, key, draftRef.current);
|
|
4284
4567
|
},
|
|
4285
|
-
[draftKeyFor, storage]
|
|
4568
|
+
[draftKeyFor, storage, drafts]
|
|
4286
4569
|
);
|
|
4287
4570
|
const setReplyingTo = useCallback(
|
|
4288
4571
|
(m) => {
|
|
@@ -4303,13 +4586,14 @@ function ConversationView({
|
|
|
4303
4586
|
draftRef.current = { text: composer2?.getText() || d.text, replyTo: d.replyTo };
|
|
4304
4587
|
if (d.replyTo && canQuote) setReplyingToState((cur) => cur ?? d.replyTo);
|
|
4305
4588
|
};
|
|
4306
|
-
const
|
|
4589
|
+
const legacy = meIdForDrafts ? draftKey(meIdForDrafts, conversationIdRef.current) : void 0;
|
|
4590
|
+
const found = drafts.read(storage, key, legacy);
|
|
4307
4591
|
if (found instanceof Promise) void found.then(apply);
|
|
4308
4592
|
else apply(found);
|
|
4309
4593
|
return () => {
|
|
4310
4594
|
live = false;
|
|
4311
4595
|
};
|
|
4312
|
-
}, [conversationId, draftKeyFor, storage, canQuote, mentionComposer]);
|
|
4596
|
+
}, [conversationId, draftKeyFor, storage, canQuote, mentionComposer, drafts, meIdForDrafts]);
|
|
4313
4597
|
const onComposerChange = useCallback((text) => saveDraft({ text }), [saveDraft]);
|
|
4314
4598
|
useEffect(() => {
|
|
4315
4599
|
if (!replyingTo) return;
|
|
@@ -4358,11 +4642,13 @@ function ConversationView({
|
|
|
4358
4642
|
const files = Array.from(e.dataTransfer?.files ?? []);
|
|
4359
4643
|
if (files.length > 0) composerRef.current?.addFiles(files);
|
|
4360
4644
|
};
|
|
4361
|
-
const sendRequest = async (
|
|
4645
|
+
const sendRequest = async (input) => {
|
|
4646
|
+
const req = { ...input, id: input.id ?? safeUuid() };
|
|
4362
4647
|
try {
|
|
4363
4648
|
await send(req);
|
|
4364
4649
|
} catch (err) {
|
|
4365
4650
|
if (err instanceof ApiError && err.code === "quoted_message_deleted") {
|
|
4651
|
+
discardSend(req.id);
|
|
4366
4652
|
setReplyingTo(null);
|
|
4367
4653
|
setSendNotice("The message you replied to was deleted.");
|
|
4368
4654
|
const body = req.body;
|
|
@@ -4374,13 +4660,91 @@ function ConversationView({
|
|
|
4374
4660
|
}
|
|
4375
4661
|
return;
|
|
4376
4662
|
}
|
|
4377
|
-
throw err;
|
|
4663
|
+
if (!(err instanceof MessageQueuedError) && !chat.outboxEnabled) throw err;
|
|
4378
4664
|
}
|
|
4379
4665
|
setReplyingToState(null);
|
|
4380
4666
|
setUnreadMarker(null);
|
|
4381
4667
|
draftRef.current = { text: "", replyTo: null };
|
|
4382
4668
|
const key = draftKeyFor();
|
|
4383
|
-
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
|
+
}
|
|
4384
4748
|
};
|
|
4385
4749
|
const onSendBody = (body, opts) => sendRequest({
|
|
4386
4750
|
body,
|
|
@@ -4400,6 +4764,8 @@ function ConversationView({
|
|
|
4400
4764
|
conversationId,
|
|
4401
4765
|
onSend: onSendWithMentions,
|
|
4402
4766
|
onTyping: signalTyping,
|
|
4767
|
+
keymap: keymap.composer,
|
|
4768
|
+
onEditLast: editLast,
|
|
4403
4769
|
attachments,
|
|
4404
4770
|
emojiPicker,
|
|
4405
4771
|
...attachmentRules,
|
|
@@ -4414,6 +4780,8 @@ function ConversationView({
|
|
|
4414
4780
|
onValueChange: onComposerChange,
|
|
4415
4781
|
onSend: onSendBody,
|
|
4416
4782
|
onTyping: signalTyping,
|
|
4783
|
+
keymap: keymap.composer,
|
|
4784
|
+
onEditLast: editLast,
|
|
4417
4785
|
attachments,
|
|
4418
4786
|
emojiPicker,
|
|
4419
4787
|
...attachmentRules,
|
|
@@ -4478,6 +4846,8 @@ function ConversationView({
|
|
|
4478
4846
|
"aria-label": "Conversation messages",
|
|
4479
4847
|
"aria-live": "polite",
|
|
4480
4848
|
"aria-relevant": "additions",
|
|
4849
|
+
tabIndex: 0,
|
|
4850
|
+
onKeyDown: onListKeyDown,
|
|
4481
4851
|
children: [
|
|
4482
4852
|
hasMore && /* @__PURE__ */ jsx("div", { ref: topSentinelRef, "aria-hidden": "true", style: { height: 1 } }),
|
|
4483
4853
|
showJump && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__jump-unread", children: [
|
|
@@ -4505,7 +4875,13 @@ function ConversationView({
|
|
|
4505
4875
|
}
|
|
4506
4876
|
)
|
|
4507
4877
|
] }),
|
|
4508
|
-
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) => {
|
|
4509
4885
|
const prev = idx > 0 ? visibleMessages[idx - 1] ?? null : null;
|
|
4510
4886
|
const next = idx < visibleMessages.length - 1 ? visibleMessages[idx + 1] ?? null : null;
|
|
4511
4887
|
const groupPosition = grouping ? computeGroupPosition(msg, prev, next, groupWindowMs) : "standalone";
|
|
@@ -4564,6 +4940,10 @@ function ConversationView({
|
|
|
4564
4940
|
onQuote: () => setReplyingTo(msg),
|
|
4565
4941
|
...!isSelf && msg.sequence !== Number.MAX_SAFE_INTEGER ? { onMarkUnread: () => void markUnreadFrom(msg) } : {},
|
|
4566
4942
|
onQuotedClick: scrollToOriginal,
|
|
4943
|
+
...msg.local_status ? {
|
|
4944
|
+
onRetrySend: () => void retrySend(msg.id).catch(() => void 0),
|
|
4945
|
+
onDiscardSend: () => discardSend(msg.id)
|
|
4946
|
+
} : {},
|
|
4567
4947
|
...onCallBack ? { onCallBack } : {},
|
|
4568
4948
|
...layoutProps,
|
|
4569
4949
|
mentionsMe: mentionsViewer(msg, me?.id ?? null)
|
|
@@ -4665,12 +5045,12 @@ function ConversationView({
|
|
|
4665
5045
|
var NO_MESSAGE = "00000000-0000-0000-0000-000000000000";
|
|
4666
5046
|
function scrollDividerIntoView(el) {
|
|
4667
5047
|
if (el && typeof el.scrollIntoView === "function") {
|
|
4668
|
-
el.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
5048
|
+
el.scrollIntoView({ behavior: prefersReducedMotion() ? "auto" : "smooth", block: "start" });
|
|
4669
5049
|
}
|
|
4670
5050
|
}
|
|
4671
5051
|
function highlightRow(el) {
|
|
4672
5052
|
if (typeof el.scrollIntoView === "function") {
|
|
4673
|
-
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
5053
|
+
el.scrollIntoView({ behavior: prefersReducedMotion() ? "auto" : "smooth", block: "center" });
|
|
4674
5054
|
}
|
|
4675
5055
|
el.classList.add("poolse-message-row--highlight");
|
|
4676
5056
|
setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
|
|
@@ -4779,6 +5159,8 @@ function ConversationList({
|
|
|
4779
5159
|
onSelect,
|
|
4780
5160
|
renderItem,
|
|
4781
5161
|
emptyState,
|
|
5162
|
+
query = "",
|
|
5163
|
+
noResultsState,
|
|
4782
5164
|
conversations: controlledConversations,
|
|
4783
5165
|
loading: controlledLoading,
|
|
4784
5166
|
error: controlledError,
|
|
@@ -4799,7 +5181,15 @@ function ConversationList({
|
|
|
4799
5181
|
const meExternalId = me?.external_id ?? null;
|
|
4800
5182
|
const meId = me?.id ?? null;
|
|
4801
5183
|
const isControlled = controlledConversations !== void 0;
|
|
4802
|
-
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
|
+
);
|
|
4803
5193
|
const loading = isControlled ? controlledLoading ?? false : auto.loading;
|
|
4804
5194
|
const error = isControlled ? controlledError ?? null : auto.error;
|
|
4805
5195
|
const counts = unreadCounts ?? (isControlled ? void 0 : auto.unreadCounts);
|
|
@@ -4847,8 +5237,23 @@ function ConversationList({
|
|
|
4847
5237
|
if (error && conversations.length === 0) {
|
|
4848
5238
|
return /* @__PURE__ */ jsx("div", { className: "poolse-list poolse-list--placeholder poolse-list--error", children: "Failed to load conversations." });
|
|
4849
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
|
+
}
|
|
4850
5249
|
if (conversations.length === 0) {
|
|
4851
|
-
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
|
+
);
|
|
4852
5257
|
}
|
|
4853
5258
|
const row = (conv) => {
|
|
4854
5259
|
const selected = selectedId === conv.id;
|
|
@@ -4887,10 +5292,10 @@ function ConversationList({
|
|
|
4887
5292
|
);
|
|
4888
5293
|
};
|
|
4889
5294
|
return /* @__PURE__ */ jsxs("ul", { ref: listRef, className: "poolse-list", role: "listbox", "aria-label": "Conversations", children: [
|
|
4890
|
-
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: [
|
|
4891
5296
|
/* @__PURE__ */ jsx("div", { className: "poolse-list__section-title", "aria-hidden": "true", children: g.title }),
|
|
4892
5297
|
/* @__PURE__ */ jsx("ul", { className: "poolse-list__section-items", role: "presentation", children: g.conversations.map(row) })
|
|
4893
|
-
] }, g.title)),
|
|
5298
|
+
] }) }, g.title)),
|
|
4894
5299
|
loadingMore && /* @__PURE__ */ jsx("li", { className: "poolse-list__loading-more", role: "presentation", children: "Loading\u2026" }),
|
|
4895
5300
|
hasMore && /* @__PURE__ */ jsx(
|
|
4896
5301
|
"li",
|
|
@@ -5208,7 +5613,7 @@ function UserPickerSheet({
|
|
|
5208
5613
|
}
|
|
5209
5614
|
)
|
|
5210
5615
|
] }),
|
|
5211
|
-
/* @__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) => {
|
|
5212
5617
|
const isSelected = selected.has(u.externalId);
|
|
5213
5618
|
return /* @__PURE__ */ jsxs(
|
|
5214
5619
|
"li",
|
|
@@ -5844,6 +6249,6 @@ function PoolseLogo({
|
|
|
5844
6249
|
);
|
|
5845
6250
|
}
|
|
5846
6251
|
|
|
5847
|
-
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 };
|
|
5848
6253
|
//# sourceMappingURL=index.js.map
|
|
5849
6254
|
//# sourceMappingURL=index.js.map
|