@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.cjs CHANGED
@@ -1229,7 +1229,6 @@ function ReactionPicker({
1229
1229
  className: "poolse-reaction-picker",
1230
1230
  role: "menu",
1231
1231
  "aria-label": "Pick a reaction",
1232
- style: { position: "absolute", bottom: "100%", left: 0, marginBottom: 6 },
1233
1232
  onKeyDown: onKey,
1234
1233
  children: COMMON_EMOJIS.map((e) => /* @__PURE__ */ jsxRuntime.jsx(
1235
1234
  "button",
@@ -1535,10 +1534,20 @@ function ThreadView({
1535
1534
  renderMessage
1536
1535
  }) {
1537
1536
  const { me } = react$1.useMe();
1538
- const { replies, loading, error, hasMore, loadMore, sendReply } = react$1.useThread(
1539
- conversationId,
1540
- rootMessage.id
1541
- );
1537
+ const {
1538
+ replies,
1539
+ loading,
1540
+ error,
1541
+ hasMore,
1542
+ loadMore,
1543
+ sendReply,
1544
+ edit,
1545
+ delete: deleteReply
1546
+ } = react$1.useThread(conversationId, rootMessage.id);
1547
+ const [editingId, setEditingId] = react.useState(null);
1548
+ react.useEffect(() => {
1549
+ setEditingId(null);
1550
+ }, [rootMessage.id]);
1542
1551
  const listRef = react.useRef(null);
1543
1552
  const closeBtnRef = react.useRef(null);
1544
1553
  const lastReplyIdRef = react.useRef(null);
@@ -1559,7 +1568,27 @@ function ThreadView({
1559
1568
  document.addEventListener("keydown", onKey);
1560
1569
  return () => document.removeEventListener("keydown", onKey);
1561
1570
  }, [onClose]);
1562
- const renderOne = renderMessage ?? defaultRenderReply;
1571
+ const renderDefault = (msg) => /* @__PURE__ */ jsxRuntime.jsx(
1572
+ MessageRow,
1573
+ {
1574
+ msg,
1575
+ meId: me?.id ?? null,
1576
+ reactions: true,
1577
+ attachments: true,
1578
+ actions: true,
1579
+ threads: false,
1580
+ quotations: false,
1581
+ editing: editingId === msg.id,
1582
+ onStartEdit: () => setEditingId(msg.id),
1583
+ onCancelEdit: () => setEditingId(null),
1584
+ onSaveEdit: async (body) => {
1585
+ await edit(msg.id, body);
1586
+ setEditingId(null);
1587
+ },
1588
+ onDelete: () => void deleteReply(msg.id)
1589
+ }
1590
+ );
1591
+ const renderOne = renderMessage ? (msg, currentUserId) => renderMessage(msg, currentUserId) : (msg) => renderDefault(msg);
1563
1592
  return /* @__PURE__ */ jsxRuntime.jsxs(
1564
1593
  "aside",
1565
1594
  {
@@ -1599,20 +1628,6 @@ function ThreadView({
1599
1628
  }
1600
1629
  );
1601
1630
  }
1602
- function defaultRenderReply(msg, currentUserId) {
1603
- return /* @__PURE__ */ jsxRuntime.jsx(
1604
- MessageRow,
1605
- {
1606
- msg,
1607
- meId: currentUserId,
1608
- reactions: true,
1609
- attachments: true,
1610
- actions: true,
1611
- threads: false,
1612
- quotations: false
1613
- }
1614
- );
1615
- }
1616
1631
  function TypingIndicator({ typing, labelFor }) {
1617
1632
  const ids = Array.from(typing);
1618
1633
  const isTyping = ids.length > 0;