@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.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var sdk = require('@poolse/sdk');
|
|
6
7
|
var react$1 = require('@poolse/react');
|
|
7
8
|
var ReactMarkdown = require('react-markdown');
|
|
8
9
|
var remarkGfm = require('remark-gfm');
|
|
@@ -1645,47 +1646,133 @@ var localDraftStorage = {
|
|
|
1645
1646
|
}
|
|
1646
1647
|
}
|
|
1647
1648
|
};
|
|
1648
|
-
var memory = /* @__PURE__ */ new Map();
|
|
1649
1649
|
function draftKey(userId, conversationId) {
|
|
1650
1650
|
return `poolse:draft:${userId}:${conversationId}`;
|
|
1651
1651
|
}
|
|
1652
1652
|
var isEmpty = (d) => d.text.trim() === "" && !d.replyTo;
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
let raw;
|
|
1657
|
-
try {
|
|
1658
|
-
raw = storage.get(key);
|
|
1659
|
-
} catch {
|
|
1660
|
-
return null;
|
|
1653
|
+
var DraftScope = class {
|
|
1654
|
+
constructor(namespace) {
|
|
1655
|
+
this.namespace = namespace;
|
|
1661
1656
|
}
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1657
|
+
namespace;
|
|
1658
|
+
memory = /* @__PURE__ */ new Map();
|
|
1659
|
+
/** Storages written to, and the keys written to each. */
|
|
1660
|
+
written = /* @__PURE__ */ new Map();
|
|
1661
|
+
/** The storage key for a conversation's draft; null until the namespace is known. */
|
|
1662
|
+
key(conversationId) {
|
|
1663
|
+
const ns = this.namespace();
|
|
1664
|
+
return ns ? `${ns}:draft:${conversationId}` : null;
|
|
1665
|
+
}
|
|
1666
|
+
/** The draft for `key`: from memory, else from `storage` (else from `legacyKey`, moved over). */
|
|
1667
|
+
read(storage, key, legacyKey) {
|
|
1668
|
+
const held = this.memory.get(key);
|
|
1669
|
+
if (held) return held;
|
|
1670
|
+
const hold = (d) => {
|
|
1671
|
+
if (d && !this.memory.has(key)) this.memory.set(key, d);
|
|
1672
|
+
return this.memory.get(key) ?? d;
|
|
1673
|
+
};
|
|
1674
|
+
const fromLegacy = () => {
|
|
1675
|
+
if (!legacyKey) return null;
|
|
1676
|
+
const old = safeGet(storage, legacyKey);
|
|
1677
|
+
const move = (raw2) => {
|
|
1678
|
+
const d = parse(raw2);
|
|
1679
|
+
if (!d) return null;
|
|
1680
|
+
this.write(storage, key, d);
|
|
1681
|
+
swallow(() => storage.remove(legacyKey));
|
|
1682
|
+
return hold(d);
|
|
1683
|
+
};
|
|
1684
|
+
return old instanceof Promise ? old.then(move, () => null) : move(old);
|
|
1685
|
+
};
|
|
1686
|
+
const raw = safeGet(storage, key);
|
|
1687
|
+
const take = (r) => {
|
|
1688
|
+
const d = parse(r);
|
|
1689
|
+
return d ? hold(d) : fromLegacy();
|
|
1690
|
+
};
|
|
1691
|
+
return raw instanceof Promise ? raw.then(take, () => null) : take(raw);
|
|
1692
|
+
}
|
|
1693
|
+
/** Save (or, when empty, drop) the draft for `key`. */
|
|
1694
|
+
write(storage, key, draft) {
|
|
1695
|
+
if (isEmpty(draft)) {
|
|
1696
|
+
this.clear(storage, key);
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
this.memory.set(key, draft);
|
|
1700
|
+
this.track(storage, key);
|
|
1701
|
+
const value = JSON.stringify({ v: 1, text: draft.text, replyTo: draft.replyTo });
|
|
1702
|
+
swallow(() => storage.set(key, value));
|
|
1703
|
+
}
|
|
1704
|
+
clear(storage, key) {
|
|
1705
|
+
this.memory.delete(key);
|
|
1706
|
+
swallow(() => storage.remove(key));
|
|
1707
|
+
}
|
|
1708
|
+
/** Called by `chat.destroy()`. @internal */
|
|
1709
|
+
async destroy(opts) {
|
|
1710
|
+
this.memory.clear();
|
|
1711
|
+
if (!opts.clearStorage) return;
|
|
1712
|
+
const ns = this.namespace();
|
|
1713
|
+
const storages = /* @__PURE__ */ new Set([...this.written.keys(), localDraftStorage]);
|
|
1714
|
+
for (const storage of storages) {
|
|
1715
|
+
const keys = new Set(this.written.get(storage) ?? []);
|
|
1716
|
+
if (ns) {
|
|
1717
|
+
try {
|
|
1718
|
+
const raw = await storage.get(indexKey(ns));
|
|
1719
|
+
const listed = raw ? JSON.parse(raw) : [];
|
|
1720
|
+
if (Array.isArray(listed)) {
|
|
1721
|
+
for (const k of listed) if (typeof k === "string") keys.add(k);
|
|
1722
|
+
}
|
|
1723
|
+
} catch {
|
|
1724
|
+
}
|
|
1725
|
+
swallow(() => storage.remove(indexKey(ns)));
|
|
1726
|
+
}
|
|
1727
|
+
for (const k of keys) swallow(() => storage.remove(k));
|
|
1728
|
+
}
|
|
1729
|
+
this.written.clear();
|
|
1677
1730
|
}
|
|
1678
|
-
|
|
1679
|
-
|
|
1731
|
+
// Remember the key in an index entry, so a sign-out finds drafts
|
|
1732
|
+
// written in earlier sessions too.
|
|
1733
|
+
track(storage, key) {
|
|
1734
|
+
let keys = this.written.get(storage);
|
|
1735
|
+
if (!keys) {
|
|
1736
|
+
keys = /* @__PURE__ */ new Set();
|
|
1737
|
+
this.written.set(storage, keys);
|
|
1738
|
+
}
|
|
1739
|
+
if (keys.has(key)) return;
|
|
1740
|
+
keys.add(key);
|
|
1741
|
+
const ns = this.namespace();
|
|
1742
|
+
if (!ns) return;
|
|
1743
|
+
const all = keys;
|
|
1744
|
+
const merge = (raw2) => {
|
|
1745
|
+
let listed = [];
|
|
1746
|
+
try {
|
|
1747
|
+
const v = raw2 ? JSON.parse(raw2) : [];
|
|
1748
|
+
if (Array.isArray(v)) listed = v.filter((k) => typeof k === "string");
|
|
1749
|
+
} catch {
|
|
1750
|
+
}
|
|
1751
|
+
const next = [.../* @__PURE__ */ new Set([...listed, ...all])];
|
|
1752
|
+
swallow(() => storage.set(indexKey(ns), JSON.stringify(next)));
|
|
1753
|
+
};
|
|
1754
|
+
const raw = safeGet(storage, indexKey(ns));
|
|
1755
|
+
if (raw instanceof Promise) void raw.then(merge, () => void 0);
|
|
1756
|
+
else merge(raw);
|
|
1757
|
+
}
|
|
1758
|
+
};
|
|
1759
|
+
function draftsOf(chat) {
|
|
1760
|
+
return chat.scoped("react-ui:drafts", (c) => new DraftScope(() => c.namespace));
|
|
1761
|
+
}
|
|
1762
|
+
var indexKey = (ns) => `${ns}:draft-index`;
|
|
1763
|
+
function safeGet(storage, key) {
|
|
1680
1764
|
try {
|
|
1681
|
-
|
|
1765
|
+
return storage.get(key);
|
|
1682
1766
|
} catch {
|
|
1767
|
+
return null;
|
|
1683
1768
|
}
|
|
1684
1769
|
}
|
|
1685
|
-
function
|
|
1686
|
-
memory.delete(key);
|
|
1770
|
+
function swallow(fn) {
|
|
1687
1771
|
try {
|
|
1688
|
-
|
|
1772
|
+
const r = fn();
|
|
1773
|
+
if (r && typeof r.catch === "function") {
|
|
1774
|
+
r.catch(() => void 0);
|
|
1775
|
+
}
|
|
1689
1776
|
} catch {
|
|
1690
1777
|
}
|
|
1691
1778
|
}
|
|
@@ -1701,6 +1788,93 @@ function parse(raw) {
|
|
|
1701
1788
|
return null;
|
|
1702
1789
|
}
|
|
1703
1790
|
}
|
|
1791
|
+
function EmptyState({ title, hint, action, className }) {
|
|
1792
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ["poolse-empty-state", className].filter(Boolean).join(" "), role: "status", children: [
|
|
1793
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-empty-state__title", children: title }),
|
|
1794
|
+
hint ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "poolse-empty-state__hint", children: hint }) : null,
|
|
1795
|
+
action ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-empty-state__action", children: action }) : null
|
|
1796
|
+
] });
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
// src/keymap.ts
|
|
1800
|
+
var DEFAULT_KEYMAP = {
|
|
1801
|
+
composer: {
|
|
1802
|
+
send: ["Enter", "Mod+Enter"],
|
|
1803
|
+
newline: ["Shift+Enter"],
|
|
1804
|
+
editLast: ["ArrowUp"],
|
|
1805
|
+
cancel: ["Escape"]
|
|
1806
|
+
},
|
|
1807
|
+
messageList: {
|
|
1808
|
+
next: ["j", "ArrowDown"],
|
|
1809
|
+
prev: ["k", "ArrowUp"],
|
|
1810
|
+
last: ["End"],
|
|
1811
|
+
first: ["Home"],
|
|
1812
|
+
reply: ["r"],
|
|
1813
|
+
thread: ["t"],
|
|
1814
|
+
edit: ["e"],
|
|
1815
|
+
delete: ["Delete", "Backspace"],
|
|
1816
|
+
composer: ["Escape"]
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1819
|
+
var MOD_ENTER_COMPOSER = {
|
|
1820
|
+
send: ["Mod+Enter"],
|
|
1821
|
+
newline: ["Enter", "Shift+Enter"]
|
|
1822
|
+
};
|
|
1823
|
+
function resolveKeymap(overrides, sendOn = "enter") {
|
|
1824
|
+
return {
|
|
1825
|
+
composer: {
|
|
1826
|
+
...DEFAULT_KEYMAP.composer,
|
|
1827
|
+
...sendOn === "mod+enter" ? MOD_ENTER_COMPOSER : {},
|
|
1828
|
+
...overrides?.composer
|
|
1829
|
+
},
|
|
1830
|
+
messageList: { ...DEFAULT_KEYMAP.messageList, ...overrides?.messageList }
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
function matchesKey(e, binding) {
|
|
1834
|
+
const parts = binding.split("+");
|
|
1835
|
+
const key = parts.pop() ?? "";
|
|
1836
|
+
const mods = new Set(parts.map((p) => p.toLowerCase()));
|
|
1837
|
+
const wantMod = mods.has("mod");
|
|
1838
|
+
const wantCtrl = mods.has("ctrl");
|
|
1839
|
+
const wantMeta = mods.has("meta") || mods.has("cmd");
|
|
1840
|
+
const wantAlt = mods.has("alt") || mods.has("option");
|
|
1841
|
+
const wantShift = mods.has("shift");
|
|
1842
|
+
if (wantMod ? !(e.metaKey || e.ctrlKey) : !wantCtrl && !wantMeta && (e.metaKey || e.ctrlKey)) {
|
|
1843
|
+
return false;
|
|
1844
|
+
}
|
|
1845
|
+
if (wantCtrl && !e.ctrlKey) return false;
|
|
1846
|
+
if (wantMeta && !e.metaKey) return false;
|
|
1847
|
+
if (wantAlt !== e.altKey) return false;
|
|
1848
|
+
const letter = key.length === 1;
|
|
1849
|
+
if (!letter && wantShift !== e.shiftKey) return false;
|
|
1850
|
+
if (letter && wantShift && !e.shiftKey) return false;
|
|
1851
|
+
return letter ? e.key.toLowerCase() === key.toLowerCase() : e.key === key;
|
|
1852
|
+
}
|
|
1853
|
+
function matchesAny(e, bindings) {
|
|
1854
|
+
return bindings.some((b) => matchesKey(e, b));
|
|
1855
|
+
}
|
|
1856
|
+
function isTypingTarget(target) {
|
|
1857
|
+
if (!target || typeof target.closest !== "function") return false;
|
|
1858
|
+
const el = target;
|
|
1859
|
+
if (el.isContentEditable) return true;
|
|
1860
|
+
return !!el.closest('input, textarea, select, [contenteditable="true"]');
|
|
1861
|
+
}
|
|
1862
|
+
function composerAction(e, keymap) {
|
|
1863
|
+
if (matchesAny(e, keymap.newline)) return "newline";
|
|
1864
|
+
if (matchesAny(e, keymap.send)) return "send";
|
|
1865
|
+
if (matchesAny(e, keymap.editLast)) return "editLast";
|
|
1866
|
+
if (matchesAny(e, keymap.cancel)) return "cancel";
|
|
1867
|
+
return null;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
// src/motion.ts
|
|
1871
|
+
function prefersReducedMotion() {
|
|
1872
|
+
try {
|
|
1873
|
+
return typeof globalThis.matchMedia === "function" && globalThis.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1874
|
+
} catch {
|
|
1875
|
+
return false;
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1704
1878
|
|
|
1705
1879
|
// src/layout.ts
|
|
1706
1880
|
function gutterTime(time) {
|
|
@@ -2358,7 +2532,9 @@ var MentionInput = react.forwardRef(
|
|
|
2358
2532
|
emojiPicker = true,
|
|
2359
2533
|
maxFileSize,
|
|
2360
2534
|
acceptFileTypes,
|
|
2361
|
-
onValueChange
|
|
2535
|
+
onValueChange,
|
|
2536
|
+
keymap = DEFAULT_KEYMAP.composer,
|
|
2537
|
+
onEditLast
|
|
2362
2538
|
}, ref) {
|
|
2363
2539
|
const chat = react$1.usePoolse();
|
|
2364
2540
|
const { members } = react$1.useMembers(conversationId);
|
|
@@ -2509,10 +2685,26 @@ var MentionInput = react.forwardRef(
|
|
|
2509
2685
|
return;
|
|
2510
2686
|
}
|
|
2511
2687
|
}
|
|
2512
|
-
|
|
2688
|
+
const action = composerAction(e, keymap);
|
|
2689
|
+
if (action === "editLast") {
|
|
2690
|
+
if (value === "" && onEditLast && onEditLast() !== false) e.preventDefault();
|
|
2691
|
+
return;
|
|
2692
|
+
}
|
|
2693
|
+
if (action === "newline" && e.key === "Enter" && !e.shiftKey) {
|
|
2694
|
+
const result = handleListEnter(value, e.currentTarget.selectionStart);
|
|
2695
|
+
if (result) {
|
|
2696
|
+
e.preventDefault();
|
|
2697
|
+
setValue(result.value);
|
|
2698
|
+
requestAnimationFrame(() => {
|
|
2699
|
+
taRef.current?.setSelectionRange(result.caret, result.caret);
|
|
2700
|
+
});
|
|
2701
|
+
}
|
|
2702
|
+
return;
|
|
2703
|
+
}
|
|
2704
|
+
if (action === "send") {
|
|
2513
2705
|
const ta = e.currentTarget;
|
|
2514
2706
|
const caret = ta.selectionStart;
|
|
2515
|
-
const result = handleListEnter(value, caret);
|
|
2707
|
+
const result = e.key === "Enter" && !e.metaKey && !e.ctrlKey ? handleListEnter(value, caret) : null;
|
|
2516
2708
|
if (result) {
|
|
2517
2709
|
e.preventDefault();
|
|
2518
2710
|
setValue(result.value);
|
|
@@ -2524,7 +2716,7 @@ var MentionInput = react.forwardRef(
|
|
|
2524
2716
|
e.preventDefault();
|
|
2525
2717
|
void submit();
|
|
2526
2718
|
}
|
|
2527
|
-
if (
|
|
2719
|
+
if (action === "cancel" && replyingTo && onCancelReply && !mention) {
|
|
2528
2720
|
e.preventDefault();
|
|
2529
2721
|
onCancelReply();
|
|
2530
2722
|
}
|
|
@@ -2580,6 +2772,8 @@ var MentionInput = react.forwardRef(
|
|
|
2580
2772
|
multiple: true,
|
|
2581
2773
|
...uploads.accept ? { accept: uploads.accept } : {},
|
|
2582
2774
|
className: "poolse-attach-input",
|
|
2775
|
+
"aria-label": "Attach files",
|
|
2776
|
+
tabIndex: -1,
|
|
2583
2777
|
onChange: (e) => {
|
|
2584
2778
|
const files = Array.from(e.target.files ?? []);
|
|
2585
2779
|
if (files.length > 0) addFiles(files);
|
|
@@ -2613,11 +2807,11 @@ var MentionInput = react.forwardRef(
|
|
|
2613
2807
|
placeholder,
|
|
2614
2808
|
disabled: disabled || sending,
|
|
2615
2809
|
"aria-label": placeholder,
|
|
2616
|
-
role: "combobox",
|
|
2617
|
-
"aria-expanded": Boolean(mention && filtered.length > 0),
|
|
2618
|
-
"aria-controls": menuId,
|
|
2619
2810
|
"aria-autocomplete": "list",
|
|
2620
|
-
...mention && filtered.length > 0 ? {
|
|
2811
|
+
...mention && filtered.length > 0 ? {
|
|
2812
|
+
"aria-controls": menuId,
|
|
2813
|
+
"aria-activedescendant": `${menuId}-opt-${activeIdx}`
|
|
2814
|
+
} : {}
|
|
2621
2815
|
}
|
|
2622
2816
|
),
|
|
2623
2817
|
emojiPicker && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2691,7 +2885,9 @@ var MessageComposer = react.forwardRef(
|
|
|
2691
2885
|
emojiPicker = true,
|
|
2692
2886
|
maxFileSize,
|
|
2693
2887
|
acceptFileTypes,
|
|
2694
|
-
onValueChange
|
|
2888
|
+
onValueChange,
|
|
2889
|
+
keymap = DEFAULT_KEYMAP.composer,
|
|
2890
|
+
onEditLast
|
|
2695
2891
|
}, ref) {
|
|
2696
2892
|
const [value, setValue] = react.useState("");
|
|
2697
2893
|
const [sending, setSending] = react.useState(false);
|
|
@@ -2745,10 +2941,26 @@ var MessageComposer = react.forwardRef(
|
|
|
2745
2941
|
}
|
|
2746
2942
|
};
|
|
2747
2943
|
const onKeyDown = (e) => {
|
|
2748
|
-
|
|
2944
|
+
const action = composerAction(e, keymap);
|
|
2945
|
+
if (action === "editLast") {
|
|
2946
|
+
if (value === "" && onEditLast && onEditLast() !== false) e.preventDefault();
|
|
2947
|
+
return;
|
|
2948
|
+
}
|
|
2949
|
+
if (action === "newline" && e.key === "Enter" && !e.shiftKey) {
|
|
2950
|
+
const result = handleListEnter(value, e.currentTarget.selectionStart);
|
|
2951
|
+
if (result) {
|
|
2952
|
+
e.preventDefault();
|
|
2953
|
+
setValue(result.value);
|
|
2954
|
+
requestAnimationFrame(() => {
|
|
2955
|
+
taRef.current?.setSelectionRange(result.caret, result.caret);
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
return;
|
|
2959
|
+
}
|
|
2960
|
+
if (action === "send") {
|
|
2749
2961
|
const ta = e.currentTarget;
|
|
2750
2962
|
const caret = ta.selectionStart;
|
|
2751
|
-
const result = handleListEnter(value, caret);
|
|
2963
|
+
const result = e.key === "Enter" && !e.metaKey && !e.ctrlKey ? handleListEnter(value, caret) : null;
|
|
2752
2964
|
if (result) {
|
|
2753
2965
|
e.preventDefault();
|
|
2754
2966
|
setValue(result.value);
|
|
@@ -2760,7 +2972,7 @@ var MessageComposer = react.forwardRef(
|
|
|
2760
2972
|
e.preventDefault();
|
|
2761
2973
|
void submit();
|
|
2762
2974
|
}
|
|
2763
|
-
if (
|
|
2975
|
+
if (action === "cancel" && replyingTo && onCancelReply) {
|
|
2764
2976
|
e.preventDefault();
|
|
2765
2977
|
onCancelReply();
|
|
2766
2978
|
}
|
|
@@ -2806,6 +3018,8 @@ var MessageComposer = react.forwardRef(
|
|
|
2806
3018
|
multiple: true,
|
|
2807
3019
|
...uploads.accept ? { accept: uploads.accept } : {},
|
|
2808
3020
|
className: "poolse-attach-input",
|
|
3021
|
+
"aria-label": "Attach files",
|
|
3022
|
+
tabIndex: -1,
|
|
2809
3023
|
onChange: (e) => {
|
|
2810
3024
|
const files = Array.from(e.target.files ?? []);
|
|
2811
3025
|
if (files.length > 0) addFiles(files);
|
|
@@ -4019,6 +4233,35 @@ function InlineReactions({
|
|
|
4019
4233
|
);
|
|
4020
4234
|
}) });
|
|
4021
4235
|
}
|
|
4236
|
+
function SendStatus({ message, onRetry, onDiscard, align = "right" }) {
|
|
4237
|
+
const status = message.local_status;
|
|
4238
|
+
if (status !== "queued" && status !== "failed") return null;
|
|
4239
|
+
const failed = status === "failed";
|
|
4240
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4241
|
+
"div",
|
|
4242
|
+
{
|
|
4243
|
+
className: [
|
|
4244
|
+
"poolse-send-status",
|
|
4245
|
+
`poolse-send-status--${status}`,
|
|
4246
|
+
`poolse-send-status--${align}`
|
|
4247
|
+
].join(" "),
|
|
4248
|
+
role: "status",
|
|
4249
|
+
children: [
|
|
4250
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-send-status__text", children: failed ? message.local_error ? `Not sent: ${message.local_error}` : "Not sent" : "Waiting for network\u2026" }),
|
|
4251
|
+
onRetry && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "poolse-send-status__button", onClick: onRetry, children: failed ? "Retry" : "Send now" }),
|
|
4252
|
+
failed && onDiscard && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4253
|
+
"button",
|
|
4254
|
+
{
|
|
4255
|
+
type: "button",
|
|
4256
|
+
className: "poolse-send-status__button poolse-send-status__button--danger",
|
|
4257
|
+
onClick: onDiscard,
|
|
4258
|
+
children: "Delete"
|
|
4259
|
+
}
|
|
4260
|
+
)
|
|
4261
|
+
]
|
|
4262
|
+
}
|
|
4263
|
+
);
|
|
4264
|
+
}
|
|
4022
4265
|
function ThreadSummary({ message, onOpen, maxAvatars = 3, className }) {
|
|
4023
4266
|
const now = useNow();
|
|
4024
4267
|
const count = message.reply_count ?? 0;
|
|
@@ -4080,7 +4323,9 @@ function FlatMessageRow({
|
|
|
4080
4323
|
onAvatarPress,
|
|
4081
4324
|
timeFormat,
|
|
4082
4325
|
slots,
|
|
4083
|
-
mentionsMe = false
|
|
4326
|
+
mentionsMe = false,
|
|
4327
|
+
onRetrySend,
|
|
4328
|
+
onDiscardSend
|
|
4084
4329
|
}) {
|
|
4085
4330
|
const compact = layout === "compact";
|
|
4086
4331
|
const isSelf = meId !== null && msg.sender_id === meId;
|
|
@@ -4104,7 +4349,8 @@ function FlatMessageRow({
|
|
|
4104
4349
|
const time = formatMessageTime(msg.inserted_at, timeFormat);
|
|
4105
4350
|
const replyCount = msg.reply_count ?? 0;
|
|
4106
4351
|
const showThreadLink = threads && !msg.thread_root_id && replyCount > 0;
|
|
4107
|
-
const
|
|
4352
|
+
const unsent = !!msg.local_status;
|
|
4353
|
+
const showActions = actions && !deleted && !editing && !unsent;
|
|
4108
4354
|
const timeEl = (className) => /* @__PURE__ */ jsxRuntime.jsx("time", { className, dateTime: msg.inserted_at, children: className === "poolse-row__gutter-time" ? gutterTime(time) : time });
|
|
4109
4355
|
const avatarSize = compact ? "sm" : "md";
|
|
4110
4356
|
const avatarEl = /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4197,7 +4443,7 @@ function FlatMessageRow({
|
|
|
4197
4443
|
meta
|
|
4198
4444
|
}
|
|
4199
4445
|
);
|
|
4200
|
-
const reactionsEl = reactions && !deleted ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4446
|
+
const reactionsEl = reactions && !deleted && !unsent ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4201
4447
|
InlineReactions,
|
|
4202
4448
|
{
|
|
4203
4449
|
reactions: reactionsHook.reactions,
|
|
@@ -4238,7 +4484,16 @@ function FlatMessageRow({
|
|
|
4238
4484
|
renderSlot(slots?.body, ctx, body),
|
|
4239
4485
|
linkPreviews && !editing && hasLinkPreviews(msg) ? /* @__PURE__ */ jsxRuntime.jsx(MessageLinkPreviews, { message: msg, canRemove: isSelf }) : null,
|
|
4240
4486
|
renderSlot(slots?.reactions, ctx, reactionsEl),
|
|
4241
|
-
renderSlot(slots?.thread, ctx, threadEl)
|
|
4487
|
+
renderSlot(slots?.thread, ctx, threadEl),
|
|
4488
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4489
|
+
SendStatus,
|
|
4490
|
+
{
|
|
4491
|
+
message: msg,
|
|
4492
|
+
align: "left",
|
|
4493
|
+
...onRetrySend ? { onRetry: onRetrySend } : {},
|
|
4494
|
+
...onDiscardSend ? { onDiscard: onDiscardSend } : {}
|
|
4495
|
+
}
|
|
4496
|
+
)
|
|
4242
4497
|
] });
|
|
4243
4498
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4244
4499
|
"div",
|
|
@@ -4250,9 +4505,13 @@ function FlatMessageRow({
|
|
|
4250
4505
|
isRunStart ? "poolse-row--run-start" : "poolse-row--continued",
|
|
4251
4506
|
isSelf ? "poolse-row--self" : "",
|
|
4252
4507
|
mentionsMe ? "poolse-row--mention" : "",
|
|
4253
|
-
editing ? "poolse-row--editing" : ""
|
|
4508
|
+
editing ? "poolse-row--editing" : "",
|
|
4509
|
+
unsent ? "poolse-row--unsent" : ""
|
|
4254
4510
|
].filter(Boolean).join(" "),
|
|
4255
4511
|
"data-message-id": msg.id,
|
|
4512
|
+
role: "article",
|
|
4513
|
+
"aria-label": `Message from ${isSelf ? "you" : senderName}`,
|
|
4514
|
+
tabIndex: -1,
|
|
4256
4515
|
"data-actions-open": actionsOpen || void 0,
|
|
4257
4516
|
onClick: onRowClick,
|
|
4258
4517
|
children: [
|
|
@@ -4367,7 +4626,9 @@ function BubbleMessageRow({
|
|
|
4367
4626
|
onSenderPress,
|
|
4368
4627
|
onAvatarPress,
|
|
4369
4628
|
timeFormat,
|
|
4370
|
-
slots
|
|
4629
|
+
slots,
|
|
4630
|
+
onRetrySend,
|
|
4631
|
+
onDiscardSend
|
|
4371
4632
|
}) {
|
|
4372
4633
|
const { profile: senderProfile } = react$1.useUser(msg.sender_external_id);
|
|
4373
4634
|
const senderFallbackName = msg.sender_external_id ?? (msg.sender_id ? `User ${msg.sender_id.slice(0, 6)}` : "Unknown");
|
|
@@ -4384,8 +4645,9 @@ function BubbleMessageRow({
|
|
|
4384
4645
|
initialReactions: msg.reactions,
|
|
4385
4646
|
currentUserId: meId
|
|
4386
4647
|
});
|
|
4387
|
-
const
|
|
4388
|
-
const
|
|
4648
|
+
const unsent = !!msg.local_status;
|
|
4649
|
+
const showReactions = reactions && !msg.deleted_at && !unsent;
|
|
4650
|
+
const showActions = actions && !msg.deleted_at && !editing && !unsent;
|
|
4389
4651
|
const replyCount = msg.reply_count ?? 0;
|
|
4390
4652
|
const showThreadPill = threads && !msg.thread_root_id && replyCount > 0;
|
|
4391
4653
|
const handleSave = onSaveEdit ?? (async () => void 0);
|
|
@@ -4409,9 +4671,13 @@ function BubbleMessageRow({
|
|
|
4409
4671
|
// tighten the inter-bubble gap inside a cluster (first/middle/
|
|
4410
4672
|
// last) and widen it between clusters (standalone or the
|
|
4411
4673
|
// first of a new run).
|
|
4412
|
-
`poolse-message-row--${groupPosition}
|
|
4674
|
+
`poolse-message-row--${groupPosition}`,
|
|
4675
|
+
unsent ? "poolse-message-row--unsent" : ""
|
|
4413
4676
|
].filter(Boolean).join(" "),
|
|
4414
4677
|
"data-message-id": msg.id,
|
|
4678
|
+
role: "article",
|
|
4679
|
+
"aria-label": `Message from ${isSelf ? "you" : senderName}`,
|
|
4680
|
+
tabIndex: -1,
|
|
4415
4681
|
"data-actions-open": actionsOpen || void 0,
|
|
4416
4682
|
"data-avatar": showAvatar && !isSelf ? true : void 0,
|
|
4417
4683
|
onClick: onRowClick,
|
|
@@ -4473,6 +4739,15 @@ function BubbleMessageRow({
|
|
|
4473
4739
|
)
|
|
4474
4740
|
}
|
|
4475
4741
|
),
|
|
4742
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4743
|
+
SendStatus,
|
|
4744
|
+
{
|
|
4745
|
+
message: msg,
|
|
4746
|
+
align: isSelf ? "right" : "left",
|
|
4747
|
+
...onRetrySend ? { onRetry: onRetrySend } : {},
|
|
4748
|
+
...onDiscardSend ? { onDiscard: onDiscardSend } : {}
|
|
4749
|
+
}
|
|
4750
|
+
),
|
|
4476
4751
|
renderSlot(
|
|
4477
4752
|
slots?.reactions,
|
|
4478
4753
|
slotContext,
|
|
@@ -4638,13 +4913,12 @@ function ThreadView({
|
|
|
4638
4913
|
}, [replies]);
|
|
4639
4914
|
react.useEffect(() => {
|
|
4640
4915
|
closeBtnRef.current?.focus();
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
}, [onClose]);
|
|
4916
|
+
}, []);
|
|
4917
|
+
const onPaneKeyDown = (e) => {
|
|
4918
|
+
if (e.key !== "Escape" || e.defaultPrevented || !onClose) return;
|
|
4919
|
+
e.preventDefault();
|
|
4920
|
+
onClose();
|
|
4921
|
+
};
|
|
4648
4922
|
const renderDefault = (msg) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4649
4923
|
MessageRow,
|
|
4650
4924
|
{
|
|
@@ -4677,6 +4951,7 @@ function ThreadView({
|
|
|
4677
4951
|
className: `poolse-thread${density ? ` poolse-conversation--density-${density}` : ""}${dragActive ? " is-drag-active" : ""}`,
|
|
4678
4952
|
role: "complementary",
|
|
4679
4953
|
"aria-label": "Message thread",
|
|
4954
|
+
onKeyDown: onPaneKeyDown,
|
|
4680
4955
|
onDragEnter,
|
|
4681
4956
|
onDragOver,
|
|
4682
4957
|
onDragLeave,
|
|
@@ -4697,9 +4972,9 @@ function ThreadView({
|
|
|
4697
4972
|
)
|
|
4698
4973
|
] }),
|
|
4699
4974
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-thread__root", children: /* @__PURE__ */ jsxRuntime.jsx(MessageBubble, { message: rootMessage, currentUserId: me?.id ?? null }) }),
|
|
4700
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-thread__messages", ref: listRef, children: [
|
|
4975
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-thread__messages", ref: listRef, role: "log", "aria-label": "Replies", children: [
|
|
4701
4976
|
hasMore && !loading && replies.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older replies" }),
|
|
4702
|
-
loading && replies.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: "Loading replies\u2026" }) : replies.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4977
|
+
loading && replies.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: "Loading replies\u2026" }) : replies.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(EmptyState, { title: "No replies yet", hint: "Write a reply below to start the thread." }) : (
|
|
4703
4978
|
// Same Fragment trick as ConversationView so MessageBubble
|
|
4704
4979
|
// remains the direct flex child for align-self to work.
|
|
4705
4980
|
replies.map((msg) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderOne(msg, me?.id ?? null) }, msg.id))
|
|
@@ -4836,7 +5111,11 @@ function ConversationView({
|
|
|
4836
5111
|
onJoinCall,
|
|
4837
5112
|
currentCallId = null,
|
|
4838
5113
|
persistDrafts = TRUE,
|
|
4839
|
-
draftStorage
|
|
5114
|
+
draftStorage,
|
|
5115
|
+
keymap: keymapOverrides,
|
|
5116
|
+
sendOn = "enter",
|
|
5117
|
+
keyboardShortcuts = TRUE,
|
|
5118
|
+
confirmDelete
|
|
4840
5119
|
}) {
|
|
4841
5120
|
usePoolseFonts(loadFonts);
|
|
4842
5121
|
const showComposer = composer && !readOnly;
|
|
@@ -4851,10 +5130,13 @@ function ConversationView({
|
|
|
4851
5130
|
loadMore,
|
|
4852
5131
|
loadUntil,
|
|
4853
5132
|
send,
|
|
5133
|
+
retry: retrySend,
|
|
5134
|
+
discard: discardSend,
|
|
4854
5135
|
edit,
|
|
4855
5136
|
delete: deleteMsg,
|
|
4856
5137
|
markReadUpTo
|
|
4857
5138
|
} = react$1.useMessages(conversationId);
|
|
5139
|
+
const keymap = react.useMemo(() => resolveKeymap(keymapOverrides, sendOn), [keymapOverrides, sendOn]);
|
|
4858
5140
|
const { typing: typingPeople, signalTyping } = react$1.useTyping(conversationId);
|
|
4859
5141
|
const streams = react$1.useMessageStreams(conversationId);
|
|
4860
5142
|
const typing = react.useMemo(() => {
|
|
@@ -5147,18 +5429,19 @@ function ConversationView({
|
|
|
5147
5429
|
const meIdForDrafts = me?.id ?? null;
|
|
5148
5430
|
const draftsOn = persistDrafts && showComposer;
|
|
5149
5431
|
const storage = draftStorage ?? localDraftStorage;
|
|
5432
|
+
const drafts = draftsOf(chat);
|
|
5150
5433
|
const draftRef = react.useRef({ text: "", replyTo: null });
|
|
5151
5434
|
const draftKeyFor = react.useCallback(
|
|
5152
|
-
() => draftsOn && meIdForDrafts ?
|
|
5153
|
-
[draftsOn, meIdForDrafts]
|
|
5435
|
+
() => draftsOn && meIdForDrafts ? drafts.key(conversationIdRef.current) : null,
|
|
5436
|
+
[draftsOn, meIdForDrafts, drafts]
|
|
5154
5437
|
);
|
|
5155
5438
|
const saveDraft = react.useCallback(
|
|
5156
5439
|
(patch) => {
|
|
5157
5440
|
draftRef.current = { ...draftRef.current, ...patch };
|
|
5158
5441
|
const key = draftKeyFor();
|
|
5159
|
-
if (key)
|
|
5442
|
+
if (key) drafts.write(storage, key, draftRef.current);
|
|
5160
5443
|
},
|
|
5161
|
-
[draftKeyFor, storage]
|
|
5444
|
+
[draftKeyFor, storage, drafts]
|
|
5162
5445
|
);
|
|
5163
5446
|
const setReplyingTo = react.useCallback(
|
|
5164
5447
|
(m) => {
|
|
@@ -5179,13 +5462,14 @@ function ConversationView({
|
|
|
5179
5462
|
draftRef.current = { text: composer2?.getText() || d.text, replyTo: d.replyTo };
|
|
5180
5463
|
if (d.replyTo && canQuote) setReplyingToState((cur) => cur ?? d.replyTo);
|
|
5181
5464
|
};
|
|
5182
|
-
const
|
|
5465
|
+
const legacy = meIdForDrafts ? draftKey(meIdForDrafts, conversationIdRef.current) : void 0;
|
|
5466
|
+
const found = drafts.read(storage, key, legacy);
|
|
5183
5467
|
if (found instanceof Promise) void found.then(apply);
|
|
5184
5468
|
else apply(found);
|
|
5185
5469
|
return () => {
|
|
5186
5470
|
live = false;
|
|
5187
5471
|
};
|
|
5188
|
-
}, [conversationId, draftKeyFor, storage, canQuote, mentionComposer]);
|
|
5472
|
+
}, [conversationId, draftKeyFor, storage, canQuote, mentionComposer, drafts, meIdForDrafts]);
|
|
5189
5473
|
const onComposerChange = react.useCallback((text) => saveDraft({ text }), [saveDraft]);
|
|
5190
5474
|
react.useEffect(() => {
|
|
5191
5475
|
if (!replyingTo) return;
|
|
@@ -5234,11 +5518,13 @@ function ConversationView({
|
|
|
5234
5518
|
const files = Array.from(e.dataTransfer?.files ?? []);
|
|
5235
5519
|
if (files.length > 0) composerRef.current?.addFiles(files);
|
|
5236
5520
|
};
|
|
5237
|
-
const sendRequest = async (
|
|
5521
|
+
const sendRequest = async (input) => {
|
|
5522
|
+
const req = { ...input, id: input.id ?? sdk.safeUuid() };
|
|
5238
5523
|
try {
|
|
5239
5524
|
await send(req);
|
|
5240
5525
|
} catch (err) {
|
|
5241
5526
|
if (err instanceof react$1.ApiError && err.code === "quoted_message_deleted") {
|
|
5527
|
+
discardSend(req.id);
|
|
5242
5528
|
setReplyingTo(null);
|
|
5243
5529
|
setSendNotice("The message you replied to was deleted.");
|
|
5244
5530
|
const body = req.body;
|
|
@@ -5250,13 +5536,91 @@ function ConversationView({
|
|
|
5250
5536
|
}
|
|
5251
5537
|
return;
|
|
5252
5538
|
}
|
|
5253
|
-
throw err;
|
|
5539
|
+
if (!(err instanceof sdk.MessageQueuedError) && !chat.outboxEnabled) throw err;
|
|
5254
5540
|
}
|
|
5255
5541
|
setReplyingToState(null);
|
|
5256
5542
|
setUnreadMarker(null);
|
|
5257
5543
|
draftRef.current = { text: "", replyTo: null };
|
|
5258
5544
|
const key = draftKeyFor();
|
|
5259
|
-
if (key)
|
|
5545
|
+
if (key) drafts.clear(storage, key);
|
|
5546
|
+
};
|
|
5547
|
+
const editLast = () => {
|
|
5548
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
5549
|
+
const m = messages[i];
|
|
5550
|
+
if (!me || m.sender_id !== me.id || m.deleted_at || m.local_status) continue;
|
|
5551
|
+
if (m.thread_root_id) continue;
|
|
5552
|
+
const isRead = maxReadByOthers !== null && maxReadByOthers >= m.sequence;
|
|
5553
|
+
const editable = react$1.canEditOwnMessage({
|
|
5554
|
+
isSelf: true,
|
|
5555
|
+
deleted: false,
|
|
5556
|
+
receiptsVisible,
|
|
5557
|
+
readState: showReadState && maxReadByOthers !== null ? isRead ? "read" : "sent" : void 0,
|
|
5558
|
+
insertedAt: m.inserted_at
|
|
5559
|
+
});
|
|
5560
|
+
if (!editable) return false;
|
|
5561
|
+
setEditingId(m.id);
|
|
5562
|
+
return true;
|
|
5563
|
+
}
|
|
5564
|
+
return false;
|
|
5565
|
+
};
|
|
5566
|
+
const rowsInList = () => Array.from(listRef.current?.querySelectorAll("[data-message-id]") ?? []).filter(
|
|
5567
|
+
(el) => el.closest(".poolse-conversation__messages") === listRef.current
|
|
5568
|
+
);
|
|
5569
|
+
const focusRow = (el) => {
|
|
5570
|
+
if (!el) return;
|
|
5571
|
+
el.focus();
|
|
5572
|
+
if (typeof el.scrollIntoView === "function") {
|
|
5573
|
+
el.scrollIntoView({ block: "nearest", behavior: prefersReducedMotion() ? "auto" : "smooth" });
|
|
5574
|
+
}
|
|
5575
|
+
};
|
|
5576
|
+
const onListKeyDown = (e) => {
|
|
5577
|
+
if (!keyboardShortcuts || isTypingTarget(e.target)) return;
|
|
5578
|
+
const km = keymap.messageList;
|
|
5579
|
+
const rows = rowsInList();
|
|
5580
|
+
if (rows.length === 0) return;
|
|
5581
|
+
const focused = e.target.closest?.("[data-message-id]");
|
|
5582
|
+
const idx = focused ? rows.indexOf(focused) : -1;
|
|
5583
|
+
const focusedMsg = focused ? messages.find((m) => m.id === focused.dataset["messageId"]) ?? null : null;
|
|
5584
|
+
const handled = () => {
|
|
5585
|
+
e.preventDefault();
|
|
5586
|
+
e.stopPropagation();
|
|
5587
|
+
};
|
|
5588
|
+
if (matchesAny(e, km.next)) {
|
|
5589
|
+
handled();
|
|
5590
|
+
focusRow(rows[idx === -1 ? rows.length - 1 : Math.min(rows.length - 1, idx + 1)]);
|
|
5591
|
+
} else if (matchesAny(e, km.prev)) {
|
|
5592
|
+
handled();
|
|
5593
|
+
focusRow(rows[idx === -1 ? rows.length - 1 : Math.max(0, idx - 1)]);
|
|
5594
|
+
} else if (matchesAny(e, km.last)) {
|
|
5595
|
+
handled();
|
|
5596
|
+
focusRow(rows[rows.length - 1]);
|
|
5597
|
+
} else if (matchesAny(e, km.first)) {
|
|
5598
|
+
handled();
|
|
5599
|
+
focusRow(rows[0]);
|
|
5600
|
+
} else if (matchesAny(e, km.composer)) {
|
|
5601
|
+
if (!showComposer) return;
|
|
5602
|
+
handled();
|
|
5603
|
+
composerRef.current?.focus();
|
|
5604
|
+
} else if (focusedMsg && !focusedMsg.deleted_at && !focusedMsg.local_status) {
|
|
5605
|
+
const isSelf = me !== null && focusedMsg.sender_id === me.id;
|
|
5606
|
+
if (matchesAny(e, km.reply) && canQuote) {
|
|
5607
|
+
handled();
|
|
5608
|
+
setReplyingTo(focusedMsg);
|
|
5609
|
+
composerRef.current?.focus();
|
|
5610
|
+
} else if (matchesAny(e, km.thread) && threads) {
|
|
5611
|
+
handled();
|
|
5612
|
+
setThreadRootId(focusedMsg.id);
|
|
5613
|
+
} else if (matchesAny(e, km.edit) && isSelf && showComposer) {
|
|
5614
|
+
handled();
|
|
5615
|
+
setEditingId(focusedMsg.id);
|
|
5616
|
+
} else if (matchesAny(e, km.delete) && isSelf && actions) {
|
|
5617
|
+
handled();
|
|
5618
|
+
const ask = confirmDelete ?? (() => typeof globalThis.confirm === "function" ? globalThis.confirm("Delete this message?") : false);
|
|
5619
|
+
void Promise.resolve(ask(focusedMsg)).then((ok) => {
|
|
5620
|
+
if (ok) void deleteMsg(focusedMsg.id).catch(() => void 0);
|
|
5621
|
+
});
|
|
5622
|
+
}
|
|
5623
|
+
}
|
|
5260
5624
|
};
|
|
5261
5625
|
const onSendBody = (body, opts) => sendRequest({
|
|
5262
5626
|
body,
|
|
@@ -5276,6 +5640,8 @@ function ConversationView({
|
|
|
5276
5640
|
conversationId,
|
|
5277
5641
|
onSend: onSendWithMentions,
|
|
5278
5642
|
onTyping: signalTyping,
|
|
5643
|
+
keymap: keymap.composer,
|
|
5644
|
+
onEditLast: editLast,
|
|
5279
5645
|
attachments,
|
|
5280
5646
|
emojiPicker,
|
|
5281
5647
|
...attachmentRules,
|
|
@@ -5290,6 +5656,8 @@ function ConversationView({
|
|
|
5290
5656
|
onValueChange: onComposerChange,
|
|
5291
5657
|
onSend: onSendBody,
|
|
5292
5658
|
onTyping: signalTyping,
|
|
5659
|
+
keymap: keymap.composer,
|
|
5660
|
+
onEditLast: editLast,
|
|
5293
5661
|
attachments,
|
|
5294
5662
|
emojiPicker,
|
|
5295
5663
|
...attachmentRules,
|
|
@@ -5354,6 +5722,8 @@ function ConversationView({
|
|
|
5354
5722
|
"aria-label": "Conversation messages",
|
|
5355
5723
|
"aria-live": "polite",
|
|
5356
5724
|
"aria-relevant": "additions",
|
|
5725
|
+
tabIndex: 0,
|
|
5726
|
+
onKeyDown: onListKeyDown,
|
|
5357
5727
|
children: [
|
|
5358
5728
|
hasMore && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: topSentinelRef, "aria-hidden": "true", style: { height: 1 } }),
|
|
5359
5729
|
showJump && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__jump-unread", children: [
|
|
@@ -5381,7 +5751,13 @@ function ConversationView({
|
|
|
5381
5751
|
}
|
|
5382
5752
|
)
|
|
5383
5753
|
] }),
|
|
5384
|
-
loading && messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: "Loading\u2026" }) : messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: emptyState
|
|
5754
|
+
loading && messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: "Loading\u2026" }) : messages.length === 0 && !error ? typeof emptyState === "function" ? emptyState({ readOnly: !showComposer }) : emptyState !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: emptyState }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
5755
|
+
EmptyState,
|
|
5756
|
+
{
|
|
5757
|
+
title: "No messages yet",
|
|
5758
|
+
...showComposer ? { hint: "Write the first message below \u2014 everyone here will see it." } : {}
|
|
5759
|
+
}
|
|
5760
|
+
) : visibleMessages.map((msg, idx) => {
|
|
5385
5761
|
const prev = idx > 0 ? visibleMessages[idx - 1] ?? null : null;
|
|
5386
5762
|
const next = idx < visibleMessages.length - 1 ? visibleMessages[idx + 1] ?? null : null;
|
|
5387
5763
|
const groupPosition = grouping ? react$1.computeGroupPosition(msg, prev, next, groupWindowMs) : "standalone";
|
|
@@ -5440,6 +5816,10 @@ function ConversationView({
|
|
|
5440
5816
|
onQuote: () => setReplyingTo(msg),
|
|
5441
5817
|
...!isSelf && msg.sequence !== Number.MAX_SAFE_INTEGER ? { onMarkUnread: () => void markUnreadFrom(msg) } : {},
|
|
5442
5818
|
onQuotedClick: scrollToOriginal,
|
|
5819
|
+
...msg.local_status ? {
|
|
5820
|
+
onRetrySend: () => void retrySend(msg.id).catch(() => void 0),
|
|
5821
|
+
onDiscardSend: () => discardSend(msg.id)
|
|
5822
|
+
} : {},
|
|
5443
5823
|
...onCallBack ? { onCallBack } : {},
|
|
5444
5824
|
...layoutProps,
|
|
5445
5825
|
mentionsMe: mentionsViewer(msg, me?.id ?? null)
|
|
@@ -5541,12 +5921,12 @@ function ConversationView({
|
|
|
5541
5921
|
var NO_MESSAGE = "00000000-0000-0000-0000-000000000000";
|
|
5542
5922
|
function scrollDividerIntoView(el) {
|
|
5543
5923
|
if (el && typeof el.scrollIntoView === "function") {
|
|
5544
|
-
el.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
5924
|
+
el.scrollIntoView({ behavior: prefersReducedMotion() ? "auto" : "smooth", block: "start" });
|
|
5545
5925
|
}
|
|
5546
5926
|
}
|
|
5547
5927
|
function highlightRow(el) {
|
|
5548
5928
|
if (typeof el.scrollIntoView === "function") {
|
|
5549
|
-
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
5929
|
+
el.scrollIntoView({ behavior: prefersReducedMotion() ? "auto" : "smooth", block: "center" });
|
|
5550
5930
|
}
|
|
5551
5931
|
el.classList.add("poolse-message-row--highlight");
|
|
5552
5932
|
setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
|
|
@@ -5655,6 +6035,8 @@ function ConversationList({
|
|
|
5655
6035
|
onSelect,
|
|
5656
6036
|
renderItem,
|
|
5657
6037
|
emptyState,
|
|
6038
|
+
query = "",
|
|
6039
|
+
noResultsState,
|
|
5658
6040
|
conversations: controlledConversations,
|
|
5659
6041
|
loading: controlledLoading,
|
|
5660
6042
|
error: controlledError,
|
|
@@ -5675,7 +6057,15 @@ function ConversationList({
|
|
|
5675
6057
|
const meExternalId = me?.external_id ?? null;
|
|
5676
6058
|
const meId = me?.id ?? null;
|
|
5677
6059
|
const isControlled = controlledConversations !== void 0;
|
|
5678
|
-
const
|
|
6060
|
+
const allConversations = isControlled ? controlledConversations : auto.conversations;
|
|
6061
|
+
const needle = query.trim().toLowerCase();
|
|
6062
|
+
const conversations = react.useMemo(
|
|
6063
|
+
() => needle ? react$1.filterConversations(allConversations, needle, {
|
|
6064
|
+
meExternalId,
|
|
6065
|
+
...labelFor ? { labelFor } : {}
|
|
6066
|
+
}) : allConversations,
|
|
6067
|
+
[allConversations, needle, meExternalId, labelFor]
|
|
6068
|
+
);
|
|
5679
6069
|
const loading = isControlled ? controlledLoading ?? false : auto.loading;
|
|
5680
6070
|
const error = isControlled ? controlledError ?? null : auto.error;
|
|
5681
6071
|
const counts = unreadCounts ?? (isControlled ? void 0 : auto.unreadCounts);
|
|
@@ -5723,8 +6113,23 @@ function ConversationList({
|
|
|
5723
6113
|
if (error && conversations.length === 0) {
|
|
5724
6114
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder poolse-list--error", children: "Failed to load conversations." });
|
|
5725
6115
|
}
|
|
6116
|
+
if (conversations.length === 0 && needle && allConversations.length > 0) {
|
|
6117
|
+
return typeof noResultsState === "function" ? noResultsState(query.trim()) : noResultsState !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: noResultsState }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
6118
|
+
EmptyState,
|
|
6119
|
+
{
|
|
6120
|
+
title: `Nothing matches \u201C${query.trim()}\u201D`,
|
|
6121
|
+
hint: "Check the spelling, or search by a person's or channel's name."
|
|
6122
|
+
}
|
|
6123
|
+
);
|
|
6124
|
+
}
|
|
5726
6125
|
if (conversations.length === 0) {
|
|
5727
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: emptyState
|
|
6126
|
+
return emptyState !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: emptyState }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
6127
|
+
EmptyState,
|
|
6128
|
+
{
|
|
6129
|
+
title: "No conversations yet",
|
|
6130
|
+
hint: "Start a chat with someone, or join a channel \u2014 it shows up here."
|
|
6131
|
+
}
|
|
6132
|
+
);
|
|
5728
6133
|
}
|
|
5729
6134
|
const row = (conv) => {
|
|
5730
6135
|
const selected = selectedId === conv.id;
|
|
@@ -5763,10 +6168,10 @@ function ConversationList({
|
|
|
5763
6168
|
);
|
|
5764
6169
|
};
|
|
5765
6170
|
return /* @__PURE__ */ jsxRuntime.jsxs("ul", { ref: listRef, className: "poolse-list", role: "listbox", "aria-label": "Conversations", children: [
|
|
5766
|
-
groups === null ? conversations.map(row) : groups.map((g) => /* @__PURE__ */ jsxRuntime.
|
|
6171
|
+
groups === null ? conversations.map(row) : groups.map((g) => /* @__PURE__ */ jsxRuntime.jsx("li", { role: "presentation", className: "poolse-list__section", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "group", "aria-label": g.title, children: [
|
|
5767
6172
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list__section-title", "aria-hidden": "true", children: g.title }),
|
|
5768
6173
|
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "poolse-list__section-items", role: "presentation", children: g.conversations.map(row) })
|
|
5769
|
-
] }, g.title)),
|
|
6174
|
+
] }) }, g.title)),
|
|
5770
6175
|
loadingMore && /* @__PURE__ */ jsxRuntime.jsx("li", { className: "poolse-list__loading-more", role: "presentation", children: "Loading\u2026" }),
|
|
5771
6176
|
hasMore && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5772
6177
|
"li",
|
|
@@ -6084,7 +6489,7 @@ function UserPickerSheet({
|
|
|
6084
6489
|
}
|
|
6085
6490
|
)
|
|
6086
6491
|
] }),
|
|
6087
|
-
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "poolse-user-picker", role: "listbox", "aria-label": "Users", children: filtered.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("li", { className: "poolse-user-picker__empty", children: "No
|
|
6492
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "poolse-user-picker", role: "listbox", "aria-label": "Users", children: filtered.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("li", { className: "poolse-user-picker__empty", children: "No one matches that. Try part of a first or last name." }) : filtered.map((u) => {
|
|
6088
6493
|
const isSelected = selected.has(u.externalId);
|
|
6089
6494
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6090
6495
|
"li",
|
|
@@ -6753,12 +7158,16 @@ exports.CallVideoGrid = CallVideoGrid;
|
|
|
6753
7158
|
exports.ChatHeader = ChatHeader;
|
|
6754
7159
|
exports.ConversationList = ConversationList;
|
|
6755
7160
|
exports.ConversationView = ConversationView;
|
|
7161
|
+
exports.DEFAULT_KEYMAP = DEFAULT_KEYMAP;
|
|
7162
|
+
exports.DraftScope = DraftScope;
|
|
6756
7163
|
exports.EditableMessageBubble = EditableMessageBubble;
|
|
6757
7164
|
exports.EditedLabel = EditedLabel;
|
|
6758
7165
|
exports.EmojiPicker = EmojiPicker;
|
|
7166
|
+
exports.EmptyState = EmptyState;
|
|
6759
7167
|
exports.GroupDetailsSheet = GroupDetailsSheet;
|
|
6760
7168
|
exports.LinkPreviewCard = LinkPreviewCard;
|
|
6761
7169
|
exports.LiveCallBanner = LiveCallBanner;
|
|
7170
|
+
exports.MOD_ENTER_COMPOSER = MOD_ENTER_COMPOSER;
|
|
6762
7171
|
exports.MemberList = MemberList;
|
|
6763
7172
|
exports.MentionInput = MentionInput;
|
|
6764
7173
|
exports.MessageActions = MessageActions;
|
|
@@ -6774,17 +7183,22 @@ exports.ReactionPicker = ReactionPicker;
|
|
|
6774
7183
|
exports.ReactionStrip = ReactionStrip;
|
|
6775
7184
|
exports.RoomJoinBar = RoomJoinBar;
|
|
6776
7185
|
exports.RoomStage = RoomStage;
|
|
7186
|
+
exports.SendStatus = SendStatus;
|
|
6777
7187
|
exports.ThreadSummary = ThreadSummary;
|
|
6778
7188
|
exports.ThreadView = ThreadView;
|
|
6779
7189
|
exports.TypingIndicator = TypingIndicator;
|
|
6780
7190
|
exports.UploadQueueStrip = UploadQueueStrip;
|
|
6781
7191
|
exports.UserName = UserName;
|
|
6782
7192
|
exports.UserPickerSheet = UserPickerSheet;
|
|
7193
|
+
exports.draftsOf = draftsOf;
|
|
6783
7194
|
exports.formatRelativeTime = formatRelativeTime;
|
|
6784
7195
|
exports.loadEmojiData = loadEmojiData;
|
|
6785
7196
|
exports.localDraftStorage = localDraftStorage;
|
|
7197
|
+
exports.matchesAny = matchesAny;
|
|
7198
|
+
exports.matchesKey = matchesKey;
|
|
6786
7199
|
exports.presenceStateLabel = presenceStateLabel;
|
|
6787
7200
|
exports.presenceText = presenceText;
|
|
7201
|
+
exports.resolveKeymap = resolveKeymap;
|
|
6788
7202
|
exports.useDisplayName = useDisplayName;
|
|
6789
7203
|
exports.useEditHistory = useEditHistory;
|
|
6790
7204
|
exports.usePoolseFonts = usePoolseFonts;
|