@poolse/react-ui 0.2.0-alpha.6 → 1.0.0-beta.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 +22 -0
- package/dist/index.cjs +116 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +116 -79
- package/dist/index.js.map +1 -1
- package/dist/styles.css +35 -16
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -449,10 +449,7 @@ function MessageComposer({
|
|
|
449
449
|
if (!trimmed || sending) return;
|
|
450
450
|
setSending(true);
|
|
451
451
|
try {
|
|
452
|
-
await onSend(
|
|
453
|
-
trimmed,
|
|
454
|
-
replyingTo ? { quoted_message_id: replyingTo.id } : void 0
|
|
455
|
-
);
|
|
452
|
+
await onSend(trimmed, replyingTo ? { quoted_message_id: replyingTo.id } : void 0);
|
|
456
453
|
setValue("");
|
|
457
454
|
} finally {
|
|
458
455
|
setSending(false);
|
|
@@ -655,8 +652,9 @@ function MessageBubble({
|
|
|
655
652
|
hour: "2-digit",
|
|
656
653
|
minute: "2-digit"
|
|
657
654
|
}) : "";
|
|
655
|
+
const showQuoteCard = message.quoted_message !== void 0 && message.quoted_message !== null ? "full" : message.quoted_message_id ? "placeholder" : null;
|
|
658
656
|
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
659
|
-
|
|
657
|
+
showQuoteCard === "full" && /* @__PURE__ */ jsx(
|
|
660
658
|
QuotedCard,
|
|
661
659
|
{
|
|
662
660
|
quoted: message.quoted_message,
|
|
@@ -665,6 +663,7 @@ function MessageBubble({
|
|
|
665
663
|
...onQuotedClick ? { onClick: onQuotedClick } : {}
|
|
666
664
|
}
|
|
667
665
|
),
|
|
666
|
+
showQuoteCard === "placeholder" && /* @__PURE__ */ jsx(QuotedPlaceholder, { isSelf, quotedMessageId: message.quoted_message_id }),
|
|
668
667
|
message.deleted_at ? /* @__PURE__ */ jsx("span", { className: "poolse-message__body--deleted", children: "[deleted]" }) : /* @__PURE__ */ jsx("span", { children: message.body ?? "" }),
|
|
669
668
|
/* @__PURE__ */ jsxs("span", { className: "poolse-message__meta", children: [
|
|
670
669
|
/* @__PURE__ */ jsx("span", { children: time }),
|
|
@@ -680,6 +679,22 @@ function MessageBubble({
|
|
|
680
679
|
] })
|
|
681
680
|
] });
|
|
682
681
|
}
|
|
682
|
+
function QuotedPlaceholder({
|
|
683
|
+
isSelf,
|
|
684
|
+
quotedMessageId: _quotedMessageId
|
|
685
|
+
}) {
|
|
686
|
+
return /* @__PURE__ */ jsxs(
|
|
687
|
+
"div",
|
|
688
|
+
{
|
|
689
|
+
className: `poolse-quote poolse-quote--placeholder ${isSelf ? "poolse-quote--self" : "poolse-quote--other"}`,
|
|
690
|
+
"aria-label": "Quoted message",
|
|
691
|
+
children: [
|
|
692
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-quote__sender", children: "Replying to a message" }),
|
|
693
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-quote__body", children: "Loading preview\u2026" })
|
|
694
|
+
]
|
|
695
|
+
}
|
|
696
|
+
);
|
|
697
|
+
}
|
|
683
698
|
function QuotedCard({
|
|
684
699
|
quoted,
|
|
685
700
|
isSelf,
|
|
@@ -966,80 +981,87 @@ function MessageRow({
|
|
|
966
981
|
const showThreadPill = threads && !msg.deleted_at && !msg.thread_root_id && replyCount > 0;
|
|
967
982
|
const handleSave = onSaveEdit ?? (async () => void 0);
|
|
968
983
|
const handleCancel = onCancelEdit ?? (() => void 0);
|
|
969
|
-
return /* @__PURE__ */ jsxs(
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
{
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
onSave: handleSave,
|
|
978
|
-
onCancel: handleCancel
|
|
979
|
-
}
|
|
980
|
-
) : /* @__PURE__ */ jsx(
|
|
981
|
-
MessageBubble,
|
|
982
|
-
{
|
|
983
|
-
message: msg,
|
|
984
|
-
currentUserId: meId,
|
|
985
|
-
...readState ? { readState } : {},
|
|
986
|
-
...labelFor ? { labelFor } : {},
|
|
987
|
-
...onQuotedClick ? { onQuotedClick } : {}
|
|
988
|
-
}
|
|
989
|
-
),
|
|
990
|
-
showAttachments && /* @__PURE__ */ jsx("div", { className: `poolse-message-row__attachments ${isSelf ? "is-self" : ""}`, children: msg.attachments.map((att) => /* @__PURE__ */ jsx(AttachmentPreview, { attachment: att }, att.id)) }),
|
|
991
|
-
showReactions && /* @__PURE__ */ jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsx(
|
|
992
|
-
InlineReactions,
|
|
993
|
-
{
|
|
994
|
-
reactions: reactionsHook.reactions,
|
|
995
|
-
currentUserId: meId,
|
|
996
|
-
onAdd: (e) => void reactionsHook.addReaction(e),
|
|
997
|
-
onRemove: (e) => void reactionsHook.removeReaction(e)
|
|
998
|
-
}
|
|
999
|
-
) }),
|
|
1000
|
-
showThreadPill && /* @__PURE__ */ jsxs(
|
|
1001
|
-
"button",
|
|
1002
|
-
{
|
|
1003
|
-
type: "button",
|
|
1004
|
-
className: `poolse-thread-pill ${isSelf ? "poolse-thread-pill--right" : "poolse-thread-pill--left"}`,
|
|
1005
|
-
onClick: onOpenThread,
|
|
1006
|
-
"aria-label": `View ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`,
|
|
1007
|
-
children: [
|
|
1008
|
-
/* @__PURE__ */ jsx(PoolseIcon, { name: "messages", size: 12, label: null }),
|
|
1009
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
1010
|
-
replyCount,
|
|
1011
|
-
" ",
|
|
1012
|
-
replyCount === 1 ? "reply" : "replies"
|
|
1013
|
-
] })
|
|
1014
|
-
]
|
|
1015
|
-
}
|
|
1016
|
-
),
|
|
1017
|
-
showActions && /* @__PURE__ */ jsx(
|
|
1018
|
-
"div",
|
|
1019
|
-
{
|
|
1020
|
-
className: `poolse-message-row__actions ${isSelf ? "poolse-message-row__actions--right" : "poolse-message-row__actions--left"}`,
|
|
1021
|
-
children: /* @__PURE__ */ jsx(
|
|
1022
|
-
MessageActions,
|
|
984
|
+
return /* @__PURE__ */ jsxs(
|
|
985
|
+
"div",
|
|
986
|
+
{
|
|
987
|
+
className: `poolse-message-row ${isSelf ? "poolse-message-row--right" : ""}`,
|
|
988
|
+
"data-message-id": msg.id,
|
|
989
|
+
children: [
|
|
990
|
+
editing ? /* @__PURE__ */ jsx(
|
|
991
|
+
EditableMessageBubble,
|
|
1023
992
|
{
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
993
|
+
message: msg,
|
|
994
|
+
currentUserId: meId,
|
|
995
|
+
...readState ? { readState } : {},
|
|
996
|
+
editing: true,
|
|
997
|
+
onSave: handleSave,
|
|
998
|
+
onCancel: handleCancel
|
|
999
|
+
}
|
|
1000
|
+
) : /* @__PURE__ */ jsx(
|
|
1001
|
+
MessageBubble,
|
|
1002
|
+
{
|
|
1003
|
+
message: msg,
|
|
1004
|
+
currentUserId: meId,
|
|
1005
|
+
...readState ? { readState } : {},
|
|
1006
|
+
...labelFor ? { labelFor } : {},
|
|
1007
|
+
...onQuotedClick ? { onQuotedClick } : {}
|
|
1008
|
+
}
|
|
1009
|
+
),
|
|
1010
|
+
showAttachments && /* @__PURE__ */ jsx("div", { className: `poolse-message-row__attachments ${isSelf ? "is-self" : ""}`, children: msg.attachments.map((att) => /* @__PURE__ */ jsx(AttachmentPreview, { attachment: att }, att.id)) }),
|
|
1011
|
+
showReactions && /* @__PURE__ */ jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsx(
|
|
1012
|
+
InlineReactions,
|
|
1013
|
+
{
|
|
1014
|
+
reactions: reactionsHook.reactions,
|
|
1015
|
+
currentUserId: meId,
|
|
1016
|
+
onAdd: (e) => void reactionsHook.addReaction(e),
|
|
1017
|
+
onRemove: (e) => void reactionsHook.removeReaction(e)
|
|
1018
|
+
}
|
|
1019
|
+
) }),
|
|
1020
|
+
showThreadPill && /* @__PURE__ */ jsxs(
|
|
1021
|
+
"button",
|
|
1022
|
+
{
|
|
1023
|
+
type: "button",
|
|
1024
|
+
className: `poolse-thread-pill ${isSelf ? "poolse-thread-pill--right" : "poolse-thread-pill--left"}`,
|
|
1025
|
+
onClick: onOpenThread,
|
|
1026
|
+
"aria-label": `View ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`,
|
|
1027
|
+
children: [
|
|
1028
|
+
/* @__PURE__ */ jsx(PoolseIcon, { name: "messages", size: 12, label: null }),
|
|
1029
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
1030
|
+
replyCount,
|
|
1031
|
+
" ",
|
|
1032
|
+
replyCount === 1 ? "reply" : "replies"
|
|
1033
|
+
] })
|
|
1034
|
+
]
|
|
1035
|
+
}
|
|
1036
|
+
),
|
|
1037
|
+
showActions && /* @__PURE__ */ jsx(
|
|
1038
|
+
"div",
|
|
1039
|
+
{
|
|
1040
|
+
className: `poolse-message-row__actions ${isSelf ? "poolse-message-row__actions--right" : "poolse-message-row__actions--left"}`,
|
|
1041
|
+
children: /* @__PURE__ */ jsx(
|
|
1042
|
+
MessageActions,
|
|
1043
|
+
{
|
|
1044
|
+
...reactions ? {
|
|
1045
|
+
onReact: (emoji) => {
|
|
1046
|
+
void reactionsHook.addReaction(emoji);
|
|
1047
|
+
}
|
|
1048
|
+
} : {},
|
|
1049
|
+
...threads && onOpenThread ? { onReply: onOpenThread } : {},
|
|
1050
|
+
...quotations && onQuote ? { onQuote } : {},
|
|
1051
|
+
...msg.body ? {
|
|
1052
|
+
onCopy: () => {
|
|
1053
|
+
void navigator?.clipboard?.writeText(msg.body ?? "").catch(() => void 0);
|
|
1054
|
+
}
|
|
1055
|
+
} : {},
|
|
1056
|
+
...isSelf && onStartEdit ? { onEdit: onStartEdit } : {},
|
|
1057
|
+
...isSelf && onDelete ? { onDelete } : {}
|
|
1034
1058
|
}
|
|
1035
|
-
|
|
1036
|
-
...isSelf && onStartEdit ? { onEdit: onStartEdit } : {},
|
|
1037
|
-
...isSelf && onDelete ? { onDelete } : {}
|
|
1059
|
+
)
|
|
1038
1060
|
}
|
|
1039
1061
|
)
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1062
|
+
]
|
|
1063
|
+
}
|
|
1064
|
+
);
|
|
1043
1065
|
}
|
|
1044
1066
|
function InlineReactions({
|
|
1045
1067
|
reactions,
|
|
@@ -1329,12 +1351,26 @@ function ConversationView({
|
|
|
1329
1351
|
if (renderMessage) {
|
|
1330
1352
|
return /* @__PURE__ */ jsx(Fragment$1, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
|
|
1331
1353
|
}
|
|
1354
|
+
const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
|
|
1355
|
+
const original = messages.find((m) => m.id === msg.quoted_message_id);
|
|
1356
|
+
if (!original) return msg;
|
|
1357
|
+
return {
|
|
1358
|
+
...msg,
|
|
1359
|
+
quoted_message: {
|
|
1360
|
+
id: original.id,
|
|
1361
|
+
sender_id: original.sender_id,
|
|
1362
|
+
body: original.body,
|
|
1363
|
+
deleted_at: original.deleted_at,
|
|
1364
|
+
inserted_at: original.inserted_at
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
})() : msg;
|
|
1332
1368
|
const isSelf = me !== null && msg.sender_id === me.id;
|
|
1333
1369
|
const readState = readReceipts && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
|
|
1334
|
-
return /* @__PURE__ */ jsx(
|
|
1370
|
+
return /* @__PURE__ */ jsx(
|
|
1335
1371
|
MessageRow,
|
|
1336
1372
|
{
|
|
1337
|
-
msg,
|
|
1373
|
+
msg: enriched,
|
|
1338
1374
|
meId: me?.id ?? null,
|
|
1339
1375
|
reactions,
|
|
1340
1376
|
attachments,
|
|
@@ -1354,8 +1390,9 @@ function ConversationView({
|
|
|
1354
1390
|
onOpenThread: () => setThreadRootId(msg.id),
|
|
1355
1391
|
onQuote: () => setReplyingTo(msg),
|
|
1356
1392
|
onQuotedClick: scrollToOriginal
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1393
|
+
},
|
|
1394
|
+
msg.id
|
|
1395
|
+
);
|
|
1359
1396
|
}),
|
|
1360
1397
|
error && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__empty", children: [
|
|
1361
1398
|
"Failed to load: ",
|