@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.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,8 +1788,98 @@ 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
|
|
1880
|
+
function gutterTime(time) {
|
|
1881
|
+
return time.replace(/\s+(?=[AaPp]\.?[Mm]\.?$)/, "").replace(/\u202f/g, "");
|
|
1882
|
+
}
|
|
1706
1883
|
function formatMessageTime(iso, format) {
|
|
1707
1884
|
if (!iso) return "";
|
|
1708
1885
|
const date = new Date(iso);
|
|
@@ -2355,7 +2532,9 @@ var MentionInput = react.forwardRef(
|
|
|
2355
2532
|
emojiPicker = true,
|
|
2356
2533
|
maxFileSize,
|
|
2357
2534
|
acceptFileTypes,
|
|
2358
|
-
onValueChange
|
|
2535
|
+
onValueChange,
|
|
2536
|
+
keymap = DEFAULT_KEYMAP.composer,
|
|
2537
|
+
onEditLast
|
|
2359
2538
|
}, ref) {
|
|
2360
2539
|
const chat = react$1.usePoolse();
|
|
2361
2540
|
const { members } = react$1.useMembers(conversationId);
|
|
@@ -2506,10 +2685,26 @@ var MentionInput = react.forwardRef(
|
|
|
2506
2685
|
return;
|
|
2507
2686
|
}
|
|
2508
2687
|
}
|
|
2509
|
-
|
|
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") {
|
|
2510
2705
|
const ta = e.currentTarget;
|
|
2511
2706
|
const caret = ta.selectionStart;
|
|
2512
|
-
const result = handleListEnter(value, caret);
|
|
2707
|
+
const result = e.key === "Enter" && !e.metaKey && !e.ctrlKey ? handleListEnter(value, caret) : null;
|
|
2513
2708
|
if (result) {
|
|
2514
2709
|
e.preventDefault();
|
|
2515
2710
|
setValue(result.value);
|
|
@@ -2521,7 +2716,7 @@ var MentionInput = react.forwardRef(
|
|
|
2521
2716
|
e.preventDefault();
|
|
2522
2717
|
void submit();
|
|
2523
2718
|
}
|
|
2524
|
-
if (
|
|
2719
|
+
if (action === "cancel" && replyingTo && onCancelReply && !mention) {
|
|
2525
2720
|
e.preventDefault();
|
|
2526
2721
|
onCancelReply();
|
|
2527
2722
|
}
|
|
@@ -2577,6 +2772,8 @@ var MentionInput = react.forwardRef(
|
|
|
2577
2772
|
multiple: true,
|
|
2578
2773
|
...uploads.accept ? { accept: uploads.accept } : {},
|
|
2579
2774
|
className: "poolse-attach-input",
|
|
2775
|
+
"aria-label": "Attach files",
|
|
2776
|
+
tabIndex: -1,
|
|
2580
2777
|
onChange: (e) => {
|
|
2581
2778
|
const files = Array.from(e.target.files ?? []);
|
|
2582
2779
|
if (files.length > 0) addFiles(files);
|
|
@@ -2610,11 +2807,11 @@ var MentionInput = react.forwardRef(
|
|
|
2610
2807
|
placeholder,
|
|
2611
2808
|
disabled: disabled || sending,
|
|
2612
2809
|
"aria-label": placeholder,
|
|
2613
|
-
role: "combobox",
|
|
2614
|
-
"aria-expanded": Boolean(mention && filtered.length > 0),
|
|
2615
|
-
"aria-controls": menuId,
|
|
2616
2810
|
"aria-autocomplete": "list",
|
|
2617
|
-
...mention && filtered.length > 0 ? {
|
|
2811
|
+
...mention && filtered.length > 0 ? {
|
|
2812
|
+
"aria-controls": menuId,
|
|
2813
|
+
"aria-activedescendant": `${menuId}-opt-${activeIdx}`
|
|
2814
|
+
} : {}
|
|
2618
2815
|
}
|
|
2619
2816
|
),
|
|
2620
2817
|
emojiPicker && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2661,8 +2858,7 @@ function MentionOption({ member, name }) {
|
|
|
2661
2858
|
const { profile } = react$1.useUser(member.external_id);
|
|
2662
2859
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2663
2860
|
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: profile?.avatarUrl ?? null, name, size: "xs" }),
|
|
2664
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-mention-menu__name", children: name })
|
|
2665
|
-
name !== member.external_id ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-mention-menu__handle", children: member.external_id }) : null
|
|
2861
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-mention-menu__name", children: name })
|
|
2666
2862
|
] });
|
|
2667
2863
|
}
|
|
2668
2864
|
function rankMembers(members, query, label) {
|
|
@@ -2689,7 +2885,9 @@ var MessageComposer = react.forwardRef(
|
|
|
2689
2885
|
emojiPicker = true,
|
|
2690
2886
|
maxFileSize,
|
|
2691
2887
|
acceptFileTypes,
|
|
2692
|
-
onValueChange
|
|
2888
|
+
onValueChange,
|
|
2889
|
+
keymap = DEFAULT_KEYMAP.composer,
|
|
2890
|
+
onEditLast
|
|
2693
2891
|
}, ref) {
|
|
2694
2892
|
const [value, setValue] = react.useState("");
|
|
2695
2893
|
const [sending, setSending] = react.useState(false);
|
|
@@ -2743,10 +2941,26 @@ var MessageComposer = react.forwardRef(
|
|
|
2743
2941
|
}
|
|
2744
2942
|
};
|
|
2745
2943
|
const onKeyDown = (e) => {
|
|
2746
|
-
|
|
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") {
|
|
2747
2961
|
const ta = e.currentTarget;
|
|
2748
2962
|
const caret = ta.selectionStart;
|
|
2749
|
-
const result = handleListEnter(value, caret);
|
|
2963
|
+
const result = e.key === "Enter" && !e.metaKey && !e.ctrlKey ? handleListEnter(value, caret) : null;
|
|
2750
2964
|
if (result) {
|
|
2751
2965
|
e.preventDefault();
|
|
2752
2966
|
setValue(result.value);
|
|
@@ -2758,7 +2972,7 @@ var MessageComposer = react.forwardRef(
|
|
|
2758
2972
|
e.preventDefault();
|
|
2759
2973
|
void submit();
|
|
2760
2974
|
}
|
|
2761
|
-
if (
|
|
2975
|
+
if (action === "cancel" && replyingTo && onCancelReply) {
|
|
2762
2976
|
e.preventDefault();
|
|
2763
2977
|
onCancelReply();
|
|
2764
2978
|
}
|
|
@@ -2804,6 +3018,8 @@ var MessageComposer = react.forwardRef(
|
|
|
2804
3018
|
multiple: true,
|
|
2805
3019
|
...uploads.accept ? { accept: uploads.accept } : {},
|
|
2806
3020
|
className: "poolse-attach-input",
|
|
3021
|
+
"aria-label": "Attach files",
|
|
3022
|
+
tabIndex: -1,
|
|
2807
3023
|
onChange: (e) => {
|
|
2808
3024
|
const files = Array.from(e.target.files ?? []);
|
|
2809
3025
|
if (files.length > 0) addFiles(files);
|
|
@@ -4017,6 +4233,35 @@ function InlineReactions({
|
|
|
4017
4233
|
);
|
|
4018
4234
|
}) });
|
|
4019
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
|
+
}
|
|
4020
4265
|
function ThreadSummary({ message, onOpen, maxAvatars = 3, className }) {
|
|
4021
4266
|
const now = useNow();
|
|
4022
4267
|
const count = message.reply_count ?? 0;
|
|
@@ -4078,7 +4323,9 @@ function FlatMessageRow({
|
|
|
4078
4323
|
onAvatarPress,
|
|
4079
4324
|
timeFormat,
|
|
4080
4325
|
slots,
|
|
4081
|
-
mentionsMe = false
|
|
4326
|
+
mentionsMe = false,
|
|
4327
|
+
onRetrySend,
|
|
4328
|
+
onDiscardSend
|
|
4082
4329
|
}) {
|
|
4083
4330
|
const compact = layout === "compact";
|
|
4084
4331
|
const isSelf = meId !== null && msg.sender_id === meId;
|
|
@@ -4102,8 +4349,9 @@ function FlatMessageRow({
|
|
|
4102
4349
|
const time = formatMessageTime(msg.inserted_at, timeFormat);
|
|
4103
4350
|
const replyCount = msg.reply_count ?? 0;
|
|
4104
4351
|
const showThreadLink = threads && !msg.thread_root_id && replyCount > 0;
|
|
4105
|
-
const
|
|
4106
|
-
const
|
|
4352
|
+
const unsent = !!msg.local_status;
|
|
4353
|
+
const showActions = actions && !deleted && !editing && !unsent;
|
|
4354
|
+
const timeEl = (className) => /* @__PURE__ */ jsxRuntime.jsx("time", { className, dateTime: msg.inserted_at, children: className === "poolse-row__gutter-time" ? gutterTime(time) : time });
|
|
4107
4355
|
const avatarSize = compact ? "sm" : "md";
|
|
4108
4356
|
const avatarEl = /* @__PURE__ */ jsxRuntime.jsx(
|
|
4109
4357
|
Avatar,
|
|
@@ -4195,7 +4443,7 @@ function FlatMessageRow({
|
|
|
4195
4443
|
meta
|
|
4196
4444
|
}
|
|
4197
4445
|
);
|
|
4198
|
-
const reactionsEl = reactions && !deleted ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4446
|
+
const reactionsEl = reactions && !deleted && !unsent ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4199
4447
|
InlineReactions,
|
|
4200
4448
|
{
|
|
4201
4449
|
reactions: reactionsHook.reactions,
|
|
@@ -4236,7 +4484,16 @@ function FlatMessageRow({
|
|
|
4236
4484
|
renderSlot(slots?.body, ctx, body),
|
|
4237
4485
|
linkPreviews && !editing && hasLinkPreviews(msg) ? /* @__PURE__ */ jsxRuntime.jsx(MessageLinkPreviews, { message: msg, canRemove: isSelf }) : null,
|
|
4238
4486
|
renderSlot(slots?.reactions, ctx, reactionsEl),
|
|
4239
|
-
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
|
+
)
|
|
4240
4497
|
] });
|
|
4241
4498
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4242
4499
|
"div",
|
|
@@ -4248,9 +4505,13 @@ function FlatMessageRow({
|
|
|
4248
4505
|
isRunStart ? "poolse-row--run-start" : "poolse-row--continued",
|
|
4249
4506
|
isSelf ? "poolse-row--self" : "",
|
|
4250
4507
|
mentionsMe ? "poolse-row--mention" : "",
|
|
4251
|
-
editing ? "poolse-row--editing" : ""
|
|
4508
|
+
editing ? "poolse-row--editing" : "",
|
|
4509
|
+
unsent ? "poolse-row--unsent" : ""
|
|
4252
4510
|
].filter(Boolean).join(" "),
|
|
4253
4511
|
"data-message-id": msg.id,
|
|
4512
|
+
role: "article",
|
|
4513
|
+
"aria-label": `Message from ${isSelf ? "you" : senderName}`,
|
|
4514
|
+
tabIndex: -1,
|
|
4254
4515
|
"data-actions-open": actionsOpen || void 0,
|
|
4255
4516
|
onClick: onRowClick,
|
|
4256
4517
|
children: [
|
|
@@ -4365,7 +4626,9 @@ function BubbleMessageRow({
|
|
|
4365
4626
|
onSenderPress,
|
|
4366
4627
|
onAvatarPress,
|
|
4367
4628
|
timeFormat,
|
|
4368
|
-
slots
|
|
4629
|
+
slots,
|
|
4630
|
+
onRetrySend,
|
|
4631
|
+
onDiscardSend
|
|
4369
4632
|
}) {
|
|
4370
4633
|
const { profile: senderProfile } = react$1.useUser(msg.sender_external_id);
|
|
4371
4634
|
const senderFallbackName = msg.sender_external_id ?? (msg.sender_id ? `User ${msg.sender_id.slice(0, 6)}` : "Unknown");
|
|
@@ -4382,8 +4645,9 @@ function BubbleMessageRow({
|
|
|
4382
4645
|
initialReactions: msg.reactions,
|
|
4383
4646
|
currentUserId: meId
|
|
4384
4647
|
});
|
|
4385
|
-
const
|
|
4386
|
-
const
|
|
4648
|
+
const unsent = !!msg.local_status;
|
|
4649
|
+
const showReactions = reactions && !msg.deleted_at && !unsent;
|
|
4650
|
+
const showActions = actions && !msg.deleted_at && !editing && !unsent;
|
|
4387
4651
|
const replyCount = msg.reply_count ?? 0;
|
|
4388
4652
|
const showThreadPill = threads && !msg.thread_root_id && replyCount > 0;
|
|
4389
4653
|
const handleSave = onSaveEdit ?? (async () => void 0);
|
|
@@ -4407,9 +4671,13 @@ function BubbleMessageRow({
|
|
|
4407
4671
|
// tighten the inter-bubble gap inside a cluster (first/middle/
|
|
4408
4672
|
// last) and widen it between clusters (standalone or the
|
|
4409
4673
|
// first of a new run).
|
|
4410
|
-
`poolse-message-row--${groupPosition}
|
|
4674
|
+
`poolse-message-row--${groupPosition}`,
|
|
4675
|
+
unsent ? "poolse-message-row--unsent" : ""
|
|
4411
4676
|
].filter(Boolean).join(" "),
|
|
4412
4677
|
"data-message-id": msg.id,
|
|
4678
|
+
role: "article",
|
|
4679
|
+
"aria-label": `Message from ${isSelf ? "you" : senderName}`,
|
|
4680
|
+
tabIndex: -1,
|
|
4413
4681
|
"data-actions-open": actionsOpen || void 0,
|
|
4414
4682
|
"data-avatar": showAvatar && !isSelf ? true : void 0,
|
|
4415
4683
|
onClick: onRowClick,
|
|
@@ -4471,6 +4739,15 @@ function BubbleMessageRow({
|
|
|
4471
4739
|
)
|
|
4472
4740
|
}
|
|
4473
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
|
+
),
|
|
4474
4751
|
renderSlot(
|
|
4475
4752
|
slots?.reactions,
|
|
4476
4753
|
slotContext,
|
|
@@ -4636,13 +4913,12 @@ function ThreadView({
|
|
|
4636
4913
|
}, [replies]);
|
|
4637
4914
|
react.useEffect(() => {
|
|
4638
4915
|
closeBtnRef.current?.focus();
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
}, [onClose]);
|
|
4916
|
+
}, []);
|
|
4917
|
+
const onPaneKeyDown = (e) => {
|
|
4918
|
+
if (e.key !== "Escape" || e.defaultPrevented || !onClose) return;
|
|
4919
|
+
e.preventDefault();
|
|
4920
|
+
onClose();
|
|
4921
|
+
};
|
|
4646
4922
|
const renderDefault = (msg) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4647
4923
|
MessageRow,
|
|
4648
4924
|
{
|
|
@@ -4675,6 +4951,7 @@ function ThreadView({
|
|
|
4675
4951
|
className: `poolse-thread${density ? ` poolse-conversation--density-${density}` : ""}${dragActive ? " is-drag-active" : ""}`,
|
|
4676
4952
|
role: "complementary",
|
|
4677
4953
|
"aria-label": "Message thread",
|
|
4954
|
+
onKeyDown: onPaneKeyDown,
|
|
4678
4955
|
onDragEnter,
|
|
4679
4956
|
onDragOver,
|
|
4680
4957
|
onDragLeave,
|
|
@@ -4695,9 +4972,9 @@ function ThreadView({
|
|
|
4695
4972
|
)
|
|
4696
4973
|
] }),
|
|
4697
4974
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-thread__root", children: /* @__PURE__ */ jsxRuntime.jsx(MessageBubble, { message: rootMessage, currentUserId: me?.id ?? null }) }),
|
|
4698
|
-
/* @__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: [
|
|
4699
4976
|
hasMore && !loading && replies.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older replies" }),
|
|
4700
|
-
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." }) : (
|
|
4701
4978
|
// Same Fragment trick as ConversationView so MessageBubble
|
|
4702
4979
|
// remains the direct flex child for align-self to work.
|
|
4703
4980
|
replies.map((msg) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderOne(msg, me?.id ?? null) }, msg.id))
|
|
@@ -4834,7 +5111,11 @@ function ConversationView({
|
|
|
4834
5111
|
onJoinCall,
|
|
4835
5112
|
currentCallId = null,
|
|
4836
5113
|
persistDrafts = TRUE,
|
|
4837
|
-
draftStorage
|
|
5114
|
+
draftStorage,
|
|
5115
|
+
keymap: keymapOverrides,
|
|
5116
|
+
sendOn = "enter",
|
|
5117
|
+
keyboardShortcuts = TRUE,
|
|
5118
|
+
confirmDelete
|
|
4838
5119
|
}) {
|
|
4839
5120
|
usePoolseFonts(loadFonts);
|
|
4840
5121
|
const showComposer = composer && !readOnly;
|
|
@@ -4849,10 +5130,13 @@ function ConversationView({
|
|
|
4849
5130
|
loadMore,
|
|
4850
5131
|
loadUntil,
|
|
4851
5132
|
send,
|
|
5133
|
+
retry: retrySend,
|
|
5134
|
+
discard: discardSend,
|
|
4852
5135
|
edit,
|
|
4853
5136
|
delete: deleteMsg,
|
|
4854
5137
|
markReadUpTo
|
|
4855
5138
|
} = react$1.useMessages(conversationId);
|
|
5139
|
+
const keymap = react.useMemo(() => resolveKeymap(keymapOverrides, sendOn), [keymapOverrides, sendOn]);
|
|
4856
5140
|
const { typing: typingPeople, signalTyping } = react$1.useTyping(conversationId);
|
|
4857
5141
|
const streams = react$1.useMessageStreams(conversationId);
|
|
4858
5142
|
const typing = react.useMemo(() => {
|
|
@@ -5145,18 +5429,19 @@ function ConversationView({
|
|
|
5145
5429
|
const meIdForDrafts = me?.id ?? null;
|
|
5146
5430
|
const draftsOn = persistDrafts && showComposer;
|
|
5147
5431
|
const storage = draftStorage ?? localDraftStorage;
|
|
5432
|
+
const drafts = draftsOf(chat);
|
|
5148
5433
|
const draftRef = react.useRef({ text: "", replyTo: null });
|
|
5149
5434
|
const draftKeyFor = react.useCallback(
|
|
5150
|
-
() => draftsOn && meIdForDrafts ?
|
|
5151
|
-
[draftsOn, meIdForDrafts]
|
|
5435
|
+
() => draftsOn && meIdForDrafts ? drafts.key(conversationIdRef.current) : null,
|
|
5436
|
+
[draftsOn, meIdForDrafts, drafts]
|
|
5152
5437
|
);
|
|
5153
5438
|
const saveDraft = react.useCallback(
|
|
5154
5439
|
(patch) => {
|
|
5155
5440
|
draftRef.current = { ...draftRef.current, ...patch };
|
|
5156
5441
|
const key = draftKeyFor();
|
|
5157
|
-
if (key)
|
|
5442
|
+
if (key) drafts.write(storage, key, draftRef.current);
|
|
5158
5443
|
},
|
|
5159
|
-
[draftKeyFor, storage]
|
|
5444
|
+
[draftKeyFor, storage, drafts]
|
|
5160
5445
|
);
|
|
5161
5446
|
const setReplyingTo = react.useCallback(
|
|
5162
5447
|
(m) => {
|
|
@@ -5177,13 +5462,14 @@ function ConversationView({
|
|
|
5177
5462
|
draftRef.current = { text: composer2?.getText() || d.text, replyTo: d.replyTo };
|
|
5178
5463
|
if (d.replyTo && canQuote) setReplyingToState((cur) => cur ?? d.replyTo);
|
|
5179
5464
|
};
|
|
5180
|
-
const
|
|
5465
|
+
const legacy = meIdForDrafts ? draftKey(meIdForDrafts, conversationIdRef.current) : void 0;
|
|
5466
|
+
const found = drafts.read(storage, key, legacy);
|
|
5181
5467
|
if (found instanceof Promise) void found.then(apply);
|
|
5182
5468
|
else apply(found);
|
|
5183
5469
|
return () => {
|
|
5184
5470
|
live = false;
|
|
5185
5471
|
};
|
|
5186
|
-
}, [conversationId, draftKeyFor, storage, canQuote, mentionComposer]);
|
|
5472
|
+
}, [conversationId, draftKeyFor, storage, canQuote, mentionComposer, drafts, meIdForDrafts]);
|
|
5187
5473
|
const onComposerChange = react.useCallback((text) => saveDraft({ text }), [saveDraft]);
|
|
5188
5474
|
react.useEffect(() => {
|
|
5189
5475
|
if (!replyingTo) return;
|
|
@@ -5232,11 +5518,13 @@ function ConversationView({
|
|
|
5232
5518
|
const files = Array.from(e.dataTransfer?.files ?? []);
|
|
5233
5519
|
if (files.length > 0) composerRef.current?.addFiles(files);
|
|
5234
5520
|
};
|
|
5235
|
-
const sendRequest = async (
|
|
5521
|
+
const sendRequest = async (input) => {
|
|
5522
|
+
const req = { ...input, id: input.id ?? sdk.safeUuid() };
|
|
5236
5523
|
try {
|
|
5237
5524
|
await send(req);
|
|
5238
5525
|
} catch (err) {
|
|
5239
5526
|
if (err instanceof react$1.ApiError && err.code === "quoted_message_deleted") {
|
|
5527
|
+
discardSend(req.id);
|
|
5240
5528
|
setReplyingTo(null);
|
|
5241
5529
|
setSendNotice("The message you replied to was deleted.");
|
|
5242
5530
|
const body = req.body;
|
|
@@ -5248,13 +5536,91 @@ function ConversationView({
|
|
|
5248
5536
|
}
|
|
5249
5537
|
return;
|
|
5250
5538
|
}
|
|
5251
|
-
throw err;
|
|
5539
|
+
if (!(err instanceof sdk.MessageQueuedError) && !chat.outboxEnabled) throw err;
|
|
5252
5540
|
}
|
|
5253
5541
|
setReplyingToState(null);
|
|
5254
5542
|
setUnreadMarker(null);
|
|
5255
5543
|
draftRef.current = { text: "", replyTo: null };
|
|
5256
5544
|
const key = draftKeyFor();
|
|
5257
|
-
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
|
+
}
|
|
5258
5624
|
};
|
|
5259
5625
|
const onSendBody = (body, opts) => sendRequest({
|
|
5260
5626
|
body,
|
|
@@ -5274,6 +5640,8 @@ function ConversationView({
|
|
|
5274
5640
|
conversationId,
|
|
5275
5641
|
onSend: onSendWithMentions,
|
|
5276
5642
|
onTyping: signalTyping,
|
|
5643
|
+
keymap: keymap.composer,
|
|
5644
|
+
onEditLast: editLast,
|
|
5277
5645
|
attachments,
|
|
5278
5646
|
emojiPicker,
|
|
5279
5647
|
...attachmentRules,
|
|
@@ -5288,6 +5656,8 @@ function ConversationView({
|
|
|
5288
5656
|
onValueChange: onComposerChange,
|
|
5289
5657
|
onSend: onSendBody,
|
|
5290
5658
|
onTyping: signalTyping,
|
|
5659
|
+
keymap: keymap.composer,
|
|
5660
|
+
onEditLast: editLast,
|
|
5291
5661
|
attachments,
|
|
5292
5662
|
emojiPicker,
|
|
5293
5663
|
...attachmentRules,
|
|
@@ -5352,6 +5722,8 @@ function ConversationView({
|
|
|
5352
5722
|
"aria-label": "Conversation messages",
|
|
5353
5723
|
"aria-live": "polite",
|
|
5354
5724
|
"aria-relevant": "additions",
|
|
5725
|
+
tabIndex: 0,
|
|
5726
|
+
onKeyDown: onListKeyDown,
|
|
5355
5727
|
children: [
|
|
5356
5728
|
hasMore && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: topSentinelRef, "aria-hidden": "true", style: { height: 1 } }),
|
|
5357
5729
|
showJump && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__jump-unread", children: [
|
|
@@ -5379,7 +5751,13 @@ function ConversationView({
|
|
|
5379
5751
|
}
|
|
5380
5752
|
)
|
|
5381
5753
|
] }),
|
|
5382
|
-
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) => {
|
|
5383
5761
|
const prev = idx > 0 ? visibleMessages[idx - 1] ?? null : null;
|
|
5384
5762
|
const next = idx < visibleMessages.length - 1 ? visibleMessages[idx + 1] ?? null : null;
|
|
5385
5763
|
const groupPosition = grouping ? react$1.computeGroupPosition(msg, prev, next, groupWindowMs) : "standalone";
|
|
@@ -5438,6 +5816,10 @@ function ConversationView({
|
|
|
5438
5816
|
onQuote: () => setReplyingTo(msg),
|
|
5439
5817
|
...!isSelf && msg.sequence !== Number.MAX_SAFE_INTEGER ? { onMarkUnread: () => void markUnreadFrom(msg) } : {},
|
|
5440
5818
|
onQuotedClick: scrollToOriginal,
|
|
5819
|
+
...msg.local_status ? {
|
|
5820
|
+
onRetrySend: () => void retrySend(msg.id).catch(() => void 0),
|
|
5821
|
+
onDiscardSend: () => discardSend(msg.id)
|
|
5822
|
+
} : {},
|
|
5441
5823
|
...onCallBack ? { onCallBack } : {},
|
|
5442
5824
|
...layoutProps,
|
|
5443
5825
|
mentionsMe: mentionsViewer(msg, me?.id ?? null)
|
|
@@ -5539,12 +5921,12 @@ function ConversationView({
|
|
|
5539
5921
|
var NO_MESSAGE = "00000000-0000-0000-0000-000000000000";
|
|
5540
5922
|
function scrollDividerIntoView(el) {
|
|
5541
5923
|
if (el && typeof el.scrollIntoView === "function") {
|
|
5542
|
-
el.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
5924
|
+
el.scrollIntoView({ behavior: prefersReducedMotion() ? "auto" : "smooth", block: "start" });
|
|
5543
5925
|
}
|
|
5544
5926
|
}
|
|
5545
5927
|
function highlightRow(el) {
|
|
5546
5928
|
if (typeof el.scrollIntoView === "function") {
|
|
5547
|
-
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
5929
|
+
el.scrollIntoView({ behavior: prefersReducedMotion() ? "auto" : "smooth", block: "center" });
|
|
5548
5930
|
}
|
|
5549
5931
|
el.classList.add("poolse-message-row--highlight");
|
|
5550
5932
|
setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
|
|
@@ -5653,6 +6035,8 @@ function ConversationList({
|
|
|
5653
6035
|
onSelect,
|
|
5654
6036
|
renderItem,
|
|
5655
6037
|
emptyState,
|
|
6038
|
+
query = "",
|
|
6039
|
+
noResultsState,
|
|
5656
6040
|
conversations: controlledConversations,
|
|
5657
6041
|
loading: controlledLoading,
|
|
5658
6042
|
error: controlledError,
|
|
@@ -5673,7 +6057,15 @@ function ConversationList({
|
|
|
5673
6057
|
const meExternalId = me?.external_id ?? null;
|
|
5674
6058
|
const meId = me?.id ?? null;
|
|
5675
6059
|
const isControlled = controlledConversations !== void 0;
|
|
5676
|
-
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
|
+
);
|
|
5677
6069
|
const loading = isControlled ? controlledLoading ?? false : auto.loading;
|
|
5678
6070
|
const error = isControlled ? controlledError ?? null : auto.error;
|
|
5679
6071
|
const counts = unreadCounts ?? (isControlled ? void 0 : auto.unreadCounts);
|
|
@@ -5721,8 +6113,23 @@ function ConversationList({
|
|
|
5721
6113
|
if (error && conversations.length === 0) {
|
|
5722
6114
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder poolse-list--error", children: "Failed to load conversations." });
|
|
5723
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
|
+
}
|
|
5724
6125
|
if (conversations.length === 0) {
|
|
5725
|
-
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
|
+
);
|
|
5726
6133
|
}
|
|
5727
6134
|
const row = (conv) => {
|
|
5728
6135
|
const selected = selectedId === conv.id;
|
|
@@ -5761,10 +6168,10 @@ function ConversationList({
|
|
|
5761
6168
|
);
|
|
5762
6169
|
};
|
|
5763
6170
|
return /* @__PURE__ */ jsxRuntime.jsxs("ul", { ref: listRef, className: "poolse-list", role: "listbox", "aria-label": "Conversations", children: [
|
|
5764
|
-
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: [
|
|
5765
6172
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list__section-title", "aria-hidden": "true", children: g.title }),
|
|
5766
6173
|
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "poolse-list__section-items", role: "presentation", children: g.conversations.map(row) })
|
|
5767
|
-
] }, g.title)),
|
|
6174
|
+
] }) }, g.title)),
|
|
5768
6175
|
loadingMore && /* @__PURE__ */ jsxRuntime.jsx("li", { className: "poolse-list__loading-more", role: "presentation", children: "Loading\u2026" }),
|
|
5769
6176
|
hasMore && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5770
6177
|
"li",
|
|
@@ -6082,7 +6489,7 @@ function UserPickerSheet({
|
|
|
6082
6489
|
}
|
|
6083
6490
|
)
|
|
6084
6491
|
] }),
|
|
6085
|
-
/* @__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) => {
|
|
6086
6493
|
const isSelected = selected.has(u.externalId);
|
|
6087
6494
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6088
6495
|
"li",
|
|
@@ -6751,12 +7158,16 @@ exports.CallVideoGrid = CallVideoGrid;
|
|
|
6751
7158
|
exports.ChatHeader = ChatHeader;
|
|
6752
7159
|
exports.ConversationList = ConversationList;
|
|
6753
7160
|
exports.ConversationView = ConversationView;
|
|
7161
|
+
exports.DEFAULT_KEYMAP = DEFAULT_KEYMAP;
|
|
7162
|
+
exports.DraftScope = DraftScope;
|
|
6754
7163
|
exports.EditableMessageBubble = EditableMessageBubble;
|
|
6755
7164
|
exports.EditedLabel = EditedLabel;
|
|
6756
7165
|
exports.EmojiPicker = EmojiPicker;
|
|
7166
|
+
exports.EmptyState = EmptyState;
|
|
6757
7167
|
exports.GroupDetailsSheet = GroupDetailsSheet;
|
|
6758
7168
|
exports.LinkPreviewCard = LinkPreviewCard;
|
|
6759
7169
|
exports.LiveCallBanner = LiveCallBanner;
|
|
7170
|
+
exports.MOD_ENTER_COMPOSER = MOD_ENTER_COMPOSER;
|
|
6760
7171
|
exports.MemberList = MemberList;
|
|
6761
7172
|
exports.MentionInput = MentionInput;
|
|
6762
7173
|
exports.MessageActions = MessageActions;
|
|
@@ -6772,17 +7183,22 @@ exports.ReactionPicker = ReactionPicker;
|
|
|
6772
7183
|
exports.ReactionStrip = ReactionStrip;
|
|
6773
7184
|
exports.RoomJoinBar = RoomJoinBar;
|
|
6774
7185
|
exports.RoomStage = RoomStage;
|
|
7186
|
+
exports.SendStatus = SendStatus;
|
|
6775
7187
|
exports.ThreadSummary = ThreadSummary;
|
|
6776
7188
|
exports.ThreadView = ThreadView;
|
|
6777
7189
|
exports.TypingIndicator = TypingIndicator;
|
|
6778
7190
|
exports.UploadQueueStrip = UploadQueueStrip;
|
|
6779
7191
|
exports.UserName = UserName;
|
|
6780
7192
|
exports.UserPickerSheet = UserPickerSheet;
|
|
7193
|
+
exports.draftsOf = draftsOf;
|
|
6781
7194
|
exports.formatRelativeTime = formatRelativeTime;
|
|
6782
7195
|
exports.loadEmojiData = loadEmojiData;
|
|
6783
7196
|
exports.localDraftStorage = localDraftStorage;
|
|
7197
|
+
exports.matchesAny = matchesAny;
|
|
7198
|
+
exports.matchesKey = matchesKey;
|
|
6784
7199
|
exports.presenceStateLabel = presenceStateLabel;
|
|
6785
7200
|
exports.presenceText = presenceText;
|
|
7201
|
+
exports.resolveKeymap = resolveKeymap;
|
|
6786
7202
|
exports.useDisplayName = useDisplayName;
|
|
6787
7203
|
exports.useEditHistory = useEditHistory;
|
|
6788
7204
|
exports.usePoolseFonts = usePoolseFonts;
|