@poolse/react-ui 1.0.2 → 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 +56 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +56 -11
- package/dist/index.js.map +1 -1
- package/dist/styles.css +100 -3
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -149,6 +149,14 @@ interface MessageBubbleProps {
|
|
|
149
149
|
* `userResolver` config.
|
|
150
150
|
*/
|
|
151
151
|
showSenderName?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Slot for a "show actions" affordance — typically a chevron
|
|
154
|
+
* rendered by `<MessageRow>` that toggles the actions popover on
|
|
155
|
+
* desktop click. Positioned absolutely at the top-trailing corner
|
|
156
|
+
* inside the bubble so it overlays the message border; hidden by
|
|
157
|
+
* CSS until the row is hovered.
|
|
158
|
+
*/
|
|
159
|
+
actionsTrigger?: ReactNode;
|
|
152
160
|
}
|
|
153
161
|
/**
|
|
154
162
|
* One message bubble. The default renderer for `<ConversationView>` —
|
|
@@ -159,7 +167,7 @@ interface MessageBubbleProps {
|
|
|
159
167
|
* (coral for self, surface-with-border for others), matching the
|
|
160
168
|
* brand-kit chat showcase.
|
|
161
169
|
*/
|
|
162
|
-
declare function MessageBubble({ message, currentUserId, readState, labelFor, onQuotedClick, groupPosition, maxBodyLength, markdown, showSenderName, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
|
|
170
|
+
declare function MessageBubble({ message, currentUserId, readState, labelFor, onQuotedClick, groupPosition, maxBodyLength, markdown, showSenderName, actionsTrigger, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
|
|
163
171
|
|
|
164
172
|
interface EditableMessageBubbleProps {
|
|
165
173
|
message: Message;
|
package/dist/index.d.ts
CHANGED
|
@@ -149,6 +149,14 @@ interface MessageBubbleProps {
|
|
|
149
149
|
* `userResolver` config.
|
|
150
150
|
*/
|
|
151
151
|
showSenderName?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Slot for a "show actions" affordance — typically a chevron
|
|
154
|
+
* rendered by `<MessageRow>` that toggles the actions popover on
|
|
155
|
+
* desktop click. Positioned absolutely at the top-trailing corner
|
|
156
|
+
* inside the bubble so it overlays the message border; hidden by
|
|
157
|
+
* CSS until the row is hovered.
|
|
158
|
+
*/
|
|
159
|
+
actionsTrigger?: ReactNode;
|
|
152
160
|
}
|
|
153
161
|
/**
|
|
154
162
|
* One message bubble. The default renderer for `<ConversationView>` —
|
|
@@ -159,7 +167,7 @@ interface MessageBubbleProps {
|
|
|
159
167
|
* (coral for self, surface-with-border for others), matching the
|
|
160
168
|
* brand-kit chat showcase.
|
|
161
169
|
*/
|
|
162
|
-
declare function MessageBubble({ message, currentUserId, readState, labelFor, onQuotedClick, groupPosition, maxBodyLength, markdown, showSenderName, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
|
|
170
|
+
declare function MessageBubble({ message, currentUserId, readState, labelFor, onQuotedClick, groupPosition, maxBodyLength, markdown, showSenderName, actionsTrigger, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
|
|
163
171
|
|
|
164
172
|
interface EditableMessageBubbleProps {
|
|
165
173
|
message: Message;
|
package/dist/index.js
CHANGED
|
@@ -898,7 +898,8 @@ function MessageBubble({
|
|
|
898
898
|
groupPosition = "standalone",
|
|
899
899
|
maxBodyLength = 0,
|
|
900
900
|
markdown = false,
|
|
901
|
-
showSenderName = false
|
|
901
|
+
showSenderName = false,
|
|
902
|
+
actionsTrigger
|
|
902
903
|
}) {
|
|
903
904
|
const isSelf = currentUserId !== null && message.sender_id === currentUserId;
|
|
904
905
|
const [expanded, setExpanded] = useState(false);
|
|
@@ -924,6 +925,7 @@ function MessageBubble({
|
|
|
924
925
|
}) : "";
|
|
925
926
|
const showQuoteCard = message.quoted_message !== void 0 && message.quoted_message !== null ? "full" : message.quoted_message_id ? "placeholder" : null;
|
|
926
927
|
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
928
|
+
actionsTrigger,
|
|
927
929
|
renderSenderName && /* @__PURE__ */ jsx("div", { className: "poolse-message__sender", style: { color: senderColorHex }, children: senderName }),
|
|
928
930
|
showQuoteCard === "full" && /* @__PURE__ */ jsx(
|
|
929
931
|
QuotedCard,
|
|
@@ -1220,7 +1222,6 @@ function ReactionPicker({
|
|
|
1220
1222
|
className: "poolse-reaction-picker",
|
|
1221
1223
|
role: "menu",
|
|
1222
1224
|
"aria-label": "Pick a reaction",
|
|
1223
|
-
style: { position: "absolute", bottom: "100%", left: 0, marginBottom: 6 },
|
|
1224
1225
|
onKeyDown: onKey,
|
|
1225
1226
|
children: COMMON_EMOJIS.map((e) => /* @__PURE__ */ jsx(
|
|
1226
1227
|
"button",
|
|
@@ -1365,6 +1366,7 @@ function MessageRow({
|
|
|
1365
1366
|
].filter(Boolean).join(" "),
|
|
1366
1367
|
"data-message-id": msg.id,
|
|
1367
1368
|
"data-actions-open": actionsOpen || void 0,
|
|
1369
|
+
"data-avatar": showAvatar && !isSelf ? true : void 0,
|
|
1368
1370
|
onClick: onRowClick,
|
|
1369
1371
|
children: [
|
|
1370
1372
|
editing ? /* @__PURE__ */ jsx(
|
|
@@ -1396,7 +1398,23 @@ function MessageRow({
|
|
|
1396
1398
|
showSenderName,
|
|
1397
1399
|
...readState ? { readState } : {},
|
|
1398
1400
|
...labelFor ? { labelFor } : {},
|
|
1399
|
-
...onQuotedClick ? { onQuotedClick } : {}
|
|
1401
|
+
...onQuotedClick ? { onQuotedClick } : {},
|
|
1402
|
+
...showActions ? {
|
|
1403
|
+
actionsTrigger: /* @__PURE__ */ jsx(
|
|
1404
|
+
"button",
|
|
1405
|
+
{
|
|
1406
|
+
type: "button",
|
|
1407
|
+
className: "poolse-message__chevron",
|
|
1408
|
+
"aria-label": "Show message actions",
|
|
1409
|
+
"aria-expanded": actionsOpen,
|
|
1410
|
+
onClick: (e) => {
|
|
1411
|
+
e.stopPropagation();
|
|
1412
|
+
setActionsOpen((o) => !o);
|
|
1413
|
+
},
|
|
1414
|
+
children: /* @__PURE__ */ jsx(PoolseIcon, { name: "chevron-down", size: 14, label: null })
|
|
1415
|
+
}
|
|
1416
|
+
)
|
|
1417
|
+
} : {}
|
|
1400
1418
|
}
|
|
1401
1419
|
)
|
|
1402
1420
|
}
|
|
@@ -1509,10 +1527,20 @@ function ThreadView({
|
|
|
1509
1527
|
renderMessage
|
|
1510
1528
|
}) {
|
|
1511
1529
|
const { me } = useMe();
|
|
1512
|
-
const {
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
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]);
|
|
1516
1544
|
const listRef = useRef(null);
|
|
1517
1545
|
const closeBtnRef = useRef(null);
|
|
1518
1546
|
const lastReplyIdRef = useRef(null);
|
|
@@ -1533,7 +1561,27 @@ function ThreadView({
|
|
|
1533
1561
|
document.addEventListener("keydown", onKey);
|
|
1534
1562
|
return () => document.removeEventListener("keydown", onKey);
|
|
1535
1563
|
}, [onClose]);
|
|
1536
|
-
const
|
|
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);
|
|
1537
1585
|
return /* @__PURE__ */ jsxs(
|
|
1538
1586
|
"aside",
|
|
1539
1587
|
{
|
|
@@ -1573,9 +1621,6 @@ function ThreadView({
|
|
|
1573
1621
|
}
|
|
1574
1622
|
);
|
|
1575
1623
|
}
|
|
1576
|
-
function defaultRenderReply(msg, currentUserId) {
|
|
1577
|
-
return /* @__PURE__ */ jsx(MessageBubble, { message: msg, currentUserId });
|
|
1578
|
-
}
|
|
1579
1624
|
function TypingIndicator({ typing, labelFor }) {
|
|
1580
1625
|
const ids = Array.from(typing);
|
|
1581
1626
|
const isTyping = ids.length > 0;
|