@poolse/react-ui 1.0.3 → 1.0.4

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/dist/index.js CHANGED
@@ -1222,7 +1222,6 @@ function ReactionPicker({
1222
1222
  className: "poolse-reaction-picker",
1223
1223
  role: "menu",
1224
1224
  "aria-label": "Pick a reaction",
1225
- style: { position: "absolute", bottom: "100%", left: 0, marginBottom: 6 },
1226
1225
  onKeyDown: onKey,
1227
1226
  children: COMMON_EMOJIS.map((e) => /* @__PURE__ */ jsx(
1228
1227
  "button",
@@ -1528,10 +1527,20 @@ function ThreadView({
1528
1527
  renderMessage
1529
1528
  }) {
1530
1529
  const { me } = useMe();
1531
- const { replies, loading, error, hasMore, loadMore, sendReply } = useThread(
1532
- conversationId,
1533
- rootMessage.id
1534
- );
1530
+ const {
1531
+ replies,
1532
+ loading,
1533
+ error,
1534
+ hasMore,
1535
+ loadMore,
1536
+ sendReply,
1537
+ edit,
1538
+ delete: deleteReply
1539
+ } = useThread(conversationId, rootMessage.id);
1540
+ const [editingId, setEditingId] = useState(null);
1541
+ useEffect(() => {
1542
+ setEditingId(null);
1543
+ }, [rootMessage.id]);
1535
1544
  const listRef = useRef(null);
1536
1545
  const closeBtnRef = useRef(null);
1537
1546
  const lastReplyIdRef = useRef(null);
@@ -1552,7 +1561,27 @@ function ThreadView({
1552
1561
  document.addEventListener("keydown", onKey);
1553
1562
  return () => document.removeEventListener("keydown", onKey);
1554
1563
  }, [onClose]);
1555
- const renderOne = renderMessage ?? defaultRenderReply;
1564
+ const renderDefault = (msg) => /* @__PURE__ */ jsx(
1565
+ MessageRow,
1566
+ {
1567
+ msg,
1568
+ meId: me?.id ?? null,
1569
+ reactions: true,
1570
+ attachments: true,
1571
+ actions: true,
1572
+ threads: false,
1573
+ quotations: false,
1574
+ editing: editingId === msg.id,
1575
+ onStartEdit: () => setEditingId(msg.id),
1576
+ onCancelEdit: () => setEditingId(null),
1577
+ onSaveEdit: async (body) => {
1578
+ await edit(msg.id, body);
1579
+ setEditingId(null);
1580
+ },
1581
+ onDelete: () => void deleteReply(msg.id)
1582
+ }
1583
+ );
1584
+ const renderOne = renderMessage ? (msg, currentUserId) => renderMessage(msg, currentUserId) : (msg) => renderDefault(msg);
1556
1585
  return /* @__PURE__ */ jsxs(
1557
1586
  "aside",
1558
1587
  {
@@ -1592,20 +1621,6 @@ function ThreadView({
1592
1621
  }
1593
1622
  );
1594
1623
  }
1595
- function defaultRenderReply(msg, currentUserId) {
1596
- return /* @__PURE__ */ jsx(
1597
- MessageRow,
1598
- {
1599
- msg,
1600
- meId: currentUserId,
1601
- reactions: true,
1602
- attachments: true,
1603
- actions: true,
1604
- threads: false,
1605
- quotations: false
1606
- }
1607
- );
1608
- }
1609
1624
  function TypingIndicator({ typing, labelFor }) {
1610
1625
  const ids = Array.from(typing);
1611
1626
  const isTyping = ids.length > 0;