@poolse/react-ui 1.0.6 → 1.1.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 +78 -0
- package/README.md +266 -50
- package/dist/index.cjs +89 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +89 -63
- package/dist/index.js.map +1 -1
- package/dist/styles.css +216 -12
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -716,17 +716,10 @@ var MessageComposer = react.forwardRef(
|
|
|
716
716
|
const taRef = react.useRef(null);
|
|
717
717
|
const fileInputRef = react.useRef(null);
|
|
718
718
|
useAutogrow(taRef, value);
|
|
719
|
-
const {
|
|
720
|
-
queue,
|
|
721
|
-
uploadAll,
|
|
722
|
-
cancel: cancelUpload,
|
|
723
|
-
remove: removeUpload
|
|
724
|
-
} = react$1.useAttachmentUpload();
|
|
719
|
+
const { queue, uploadAll, cancel: cancelUpload, remove: removeUpload } = react$1.useAttachmentUpload();
|
|
725
720
|
const visibleUploads = queue.filter((it) => it.status !== "cancelled");
|
|
726
721
|
const readyCount = queue.filter((it) => it.status === "ready").length;
|
|
727
|
-
const uploading = queue.some(
|
|
728
|
-
(it) => it.status === "pending" || it.status === "uploading"
|
|
729
|
-
);
|
|
722
|
+
const uploading = queue.some((it) => it.status === "pending" || it.status === "uploading");
|
|
730
723
|
const addFiles = (files) => {
|
|
731
724
|
if (!attachments || files.length === 0) return;
|
|
732
725
|
void uploadAll(
|
|
@@ -897,6 +890,24 @@ function ReplyChip({
|
|
|
897
890
|
)
|
|
898
891
|
] });
|
|
899
892
|
}
|
|
893
|
+
function Avatar({ src, name, online, size = "md", className }) {
|
|
894
|
+
const initials = computeInitials(name);
|
|
895
|
+
const classes = [
|
|
896
|
+
"poolse-avatar",
|
|
897
|
+
size === "sm" ? "poolse-avatar--sm" : null,
|
|
898
|
+
size === "lg" ? "poolse-avatar--lg" : null,
|
|
899
|
+
className
|
|
900
|
+
].filter(Boolean).join(" ");
|
|
901
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: classes, "aria-label": name ?? "avatar", role: "img", children: [
|
|
902
|
+
src ? /* @__PURE__ */ jsxRuntime.jsx("img", { src, alt: name ?? "" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: initials }),
|
|
903
|
+
online ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-avatar__presence", "aria-hidden": "true" }) : null
|
|
904
|
+
] });
|
|
905
|
+
}
|
|
906
|
+
function computeInitials(name) {
|
|
907
|
+
if (!name) return "?";
|
|
908
|
+
const parts = name.trim().split(/\s+/).slice(0, 2);
|
|
909
|
+
return parts.map((p) => p.charAt(0).toUpperCase()).join("").slice(0, 2) || "?";
|
|
910
|
+
}
|
|
900
911
|
function AttachmentPreview({ attachment, onClick }) {
|
|
901
912
|
const isFullRow = "content_type" in attachment;
|
|
902
913
|
const { url, loading, error } = react$1.useAttachmentUrl(attachment.id);
|
|
@@ -1060,24 +1071,6 @@ function formatBytes(n) {
|
|
|
1060
1071
|
if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
|
1061
1072
|
return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
1062
1073
|
}
|
|
1063
|
-
function Avatar({ src, name, online, size = "md", className }) {
|
|
1064
|
-
const initials = computeInitials(name);
|
|
1065
|
-
const classes = [
|
|
1066
|
-
"poolse-avatar",
|
|
1067
|
-
size === "sm" ? "poolse-avatar--sm" : null,
|
|
1068
|
-
size === "lg" ? "poolse-avatar--lg" : null,
|
|
1069
|
-
className
|
|
1070
|
-
].filter(Boolean).join(" ");
|
|
1071
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: classes, "aria-label": name ?? "avatar", role: "img", children: [
|
|
1072
|
-
src ? /* @__PURE__ */ jsxRuntime.jsx("img", { src, alt: name ?? "" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: initials }),
|
|
1073
|
-
online ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-avatar__presence", "aria-hidden": "true" }) : null
|
|
1074
|
-
] });
|
|
1075
|
-
}
|
|
1076
|
-
function computeInitials(name) {
|
|
1077
|
-
if (!name) return "?";
|
|
1078
|
-
const parts = name.trim().split(/\s+/).slice(0, 2);
|
|
1079
|
-
return parts.map((p) => p.charAt(0).toUpperCase()).join("").slice(0, 2) || "?";
|
|
1080
|
-
}
|
|
1081
1074
|
|
|
1082
1075
|
// src/userColor.ts
|
|
1083
1076
|
var PALETTE = [
|
|
@@ -1115,7 +1108,8 @@ function MessageBubble({
|
|
|
1115
1108
|
maxBodyLength = 0,
|
|
1116
1109
|
markdown = false,
|
|
1117
1110
|
showSenderName = false,
|
|
1118
|
-
actionsTrigger
|
|
1111
|
+
actionsTrigger,
|
|
1112
|
+
showAttachments = true
|
|
1119
1113
|
}) {
|
|
1120
1114
|
const isSelf = currentUserId !== null && message.sender_id === currentUserId;
|
|
1121
1115
|
const [expanded, setExpanded] = react.useState(false);
|
|
@@ -1124,17 +1118,27 @@ function MessageBubble({
|
|
|
1124
1118
|
const senderName = sender?.displayName ?? senderFallbackName;
|
|
1125
1119
|
const senderColorHex = message.sender_id ? userColor(message.sender_id) : "currentColor";
|
|
1126
1120
|
const renderSenderName = showSenderName && !isSelf && (groupPosition === "first" || groupPosition === "standalone");
|
|
1121
|
+
const rawBody = message.body ?? "";
|
|
1122
|
+
const TRIM_BUFFER = 40;
|
|
1123
|
+
const shouldTrim = !expanded && maxBodyLength > 0 && rawBody.length > maxBodyLength + TRIM_BUFFER;
|
|
1124
|
+
const displayBody = shouldTrim ? rawBody.slice(0, maxBodyLength).trimEnd() + "\u2026" : rawBody;
|
|
1125
|
+
const attachmentList = showAttachments && !message.deleted_at && Array.isArray(message.attachments) ? message.attachments : [];
|
|
1126
|
+
const imageAttachments = attachmentList.filter((a) => isImageContentType(a.content_type));
|
|
1127
|
+
const fileAttachments = attachmentList.filter((a) => !isImageContentType(a.content_type));
|
|
1128
|
+
const hasAnyAttachment = imageAttachments.length > 0 || fileAttachments.length > 0;
|
|
1129
|
+
const hasVisibleBody = !message.deleted_at && rawBody.length > 0;
|
|
1130
|
+
const metaOverlay = hasAnyAttachment && imageAttachments.length > 0 && !hasVisibleBody && fileAttachments.length === 0;
|
|
1127
1131
|
const className = [
|
|
1128
1132
|
"poolse-message",
|
|
1129
1133
|
isSelf ? "poolse-message--self" : "poolse-message--other",
|
|
1130
1134
|
// Group-position modifier — CSS uses it to toggle which corners
|
|
1131
1135
|
// get the asymmetric tail vs. fully-rounded treatment.
|
|
1132
|
-
`poolse-message--${groupPosition}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1136
|
+
`poolse-message--${groupPosition}`,
|
|
1137
|
+
// Tells the CSS to round the image mosaic's bottom corners to
|
|
1138
|
+
// match the bubble's outer corner when nothing follows the media.
|
|
1139
|
+
hasAnyAttachment ? "poolse-message--has-media" : "",
|
|
1140
|
+
metaOverlay ? "poolse-message--media-only" : ""
|
|
1141
|
+
].filter(Boolean).join(" ");
|
|
1138
1142
|
const time = message.inserted_at ? new Date(message.inserted_at).toLocaleTimeString(void 0, {
|
|
1139
1143
|
hour: "2-digit",
|
|
1140
1144
|
minute: "2-digit"
|
|
@@ -1153,7 +1157,9 @@ function MessageBubble({
|
|
|
1153
1157
|
}
|
|
1154
1158
|
),
|
|
1155
1159
|
showQuoteCard === "placeholder" && /* @__PURE__ */ jsxRuntime.jsx(QuotedPlaceholder, { isSelf, quotedMessageId: message.quoted_message_id }),
|
|
1156
|
-
|
|
1160
|
+
imageAttachments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(ImageMosaic, { images: imageAttachments }),
|
|
1161
|
+
fileAttachments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-message__files", children: fileAttachments.map((att) => /* @__PURE__ */ jsxRuntime.jsx(AttachmentPreview, { attachment: att }, att.id)) }),
|
|
1162
|
+
message.deleted_at ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-message__body--deleted", children: "[deleted]" }) : hasVisibleBody ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-message__body", children: [
|
|
1157
1163
|
markdown ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1158
1164
|
ReactMarkdown__default.default,
|
|
1159
1165
|
{
|
|
@@ -1190,21 +1196,53 @@ function MessageBubble({
|
|
|
1190
1196
|
children: "Show less"
|
|
1191
1197
|
}
|
|
1192
1198
|
)
|
|
1193
|
-
] }),
|
|
1194
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1199
|
+
] }) : null,
|
|
1200
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1201
|
+
"span",
|
|
1202
|
+
{
|
|
1203
|
+
className: metaOverlay ? "poolse-message__meta poolse-message__meta--overlay" : "poolse-message__meta",
|
|
1204
|
+
children: [
|
|
1205
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: time }),
|
|
1206
|
+
message.edited_at ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: " \xB7 edited" }) : null,
|
|
1207
|
+
isSelf && readState ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1208
|
+
PoolseIcon,
|
|
1209
|
+
{
|
|
1210
|
+
name: readState === "read" ? "check-double" : "check",
|
|
1211
|
+
size: 14,
|
|
1212
|
+
label: readState === "read" ? "Read" : "Sent"
|
|
1213
|
+
}
|
|
1214
|
+
) : null
|
|
1215
|
+
]
|
|
1216
|
+
}
|
|
1217
|
+
)
|
|
1206
1218
|
] });
|
|
1207
1219
|
}
|
|
1220
|
+
function isImageContentType(ct) {
|
|
1221
|
+
return typeof ct === "string" && ct.toLowerCase().startsWith("image/");
|
|
1222
|
+
}
|
|
1223
|
+
function ImageMosaic({ images }) {
|
|
1224
|
+
const total = images.length;
|
|
1225
|
+
const visible = images.slice(0, 4);
|
|
1226
|
+
const layout = Math.min(total, 4);
|
|
1227
|
+
const overflow = Math.max(0, total - 4);
|
|
1228
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1229
|
+
"div",
|
|
1230
|
+
{
|
|
1231
|
+
className: `poolse-message__media poolse-message__media--n${layout}`,
|
|
1232
|
+
"aria-label": total === 1 ? "Image" : `${total} images`,
|
|
1233
|
+
children: visible.map((att, i) => {
|
|
1234
|
+
const isOverflowTile = i === visible.length - 1 && overflow > 0;
|
|
1235
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-message__media-tile", children: [
|
|
1236
|
+
/* @__PURE__ */ jsxRuntime.jsx(AttachmentPreview, { attachment: att }),
|
|
1237
|
+
isOverflowTile && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-message__media-overflow", "aria-hidden": "true", children: [
|
|
1238
|
+
"+",
|
|
1239
|
+
overflow
|
|
1240
|
+
] })
|
|
1241
|
+
] }, att.id);
|
|
1242
|
+
})
|
|
1243
|
+
}
|
|
1244
|
+
);
|
|
1245
|
+
}
|
|
1208
1246
|
function QuotedPlaceholder({
|
|
1209
1247
|
isSelf,
|
|
1210
1248
|
quotedMessageId: _quotedMessageId
|
|
@@ -1542,7 +1580,6 @@ function MessageRow({
|
|
|
1542
1580
|
currentUserId: meId
|
|
1543
1581
|
});
|
|
1544
1582
|
const showReactions = reactions && !msg.deleted_at;
|
|
1545
|
-
const showAttachments = attachments && Array.isArray(msg.attachments) && msg.attachments.length > 0;
|
|
1546
1583
|
const showActions = actions && !msg.deleted_at && !editing;
|
|
1547
1584
|
const replyCount = msg.reply_count ?? 0;
|
|
1548
1585
|
const showThreadPill = threads && !msg.deleted_at && !msg.thread_root_id && replyCount > 0;
|
|
@@ -1612,6 +1649,7 @@ function MessageRow({
|
|
|
1612
1649
|
maxBodyLength,
|
|
1613
1650
|
markdown,
|
|
1614
1651
|
showSenderName,
|
|
1652
|
+
showAttachments: attachments,
|
|
1615
1653
|
...readState ? { readState } : {},
|
|
1616
1654
|
...labelFor ? { labelFor } : {},
|
|
1617
1655
|
...onQuotedClick ? { onQuotedClick } : {},
|
|
@@ -1635,7 +1673,6 @@ function MessageRow({
|
|
|
1635
1673
|
)
|
|
1636
1674
|
}
|
|
1637
1675
|
),
|
|
1638
|
-
showAttachments && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `poolse-message-row__attachments ${isSelf ? "is-self" : ""}`, children: msg.attachments.map((att) => /* @__PURE__ */ jsxRuntime.jsx(AttachmentPreview, { attachment: att }, att.id)) }),
|
|
1639
1676
|
showReactions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1640
1677
|
InlineReactions,
|
|
1641
1678
|
{
|
|
@@ -1894,16 +1931,7 @@ function TypingIndicator({ typing, labelFor }) {
|
|
|
1894
1931
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-typing__dot" }),
|
|
1895
1932
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-typing__dot" })
|
|
1896
1933
|
] }),
|
|
1897
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1898
|
-
"span",
|
|
1899
|
-
{
|
|
1900
|
-
className: "poolse-typing__label",
|
|
1901
|
-
role: "status",
|
|
1902
|
-
"aria-live": "polite",
|
|
1903
|
-
"aria-atomic": "true",
|
|
1904
|
-
children: isTyping ? /* @__PURE__ */ jsxRuntime.jsx(TypingLabel, { ids, ...labelFor ? { labelFor } : {} }) : ""
|
|
1905
|
-
}
|
|
1906
|
-
)
|
|
1934
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-typing__label", role: "status", "aria-live": "polite", "aria-atomic": "true", children: isTyping ? /* @__PURE__ */ jsxRuntime.jsx(TypingLabel, { ids, ...labelFor ? { labelFor } : {} }) : "" })
|
|
1907
1935
|
] });
|
|
1908
1936
|
}
|
|
1909
1937
|
function TypingLabel({ ids, labelFor }) {
|
|
@@ -2383,9 +2411,7 @@ function MemberList({
|
|
|
2383
2411
|
emptyState
|
|
2384
2412
|
}) {
|
|
2385
2413
|
const { members, loading, error, removeMember } = react$1.useMembers(conversationId);
|
|
2386
|
-
const { online: presenceOnline } = react$1.usePresence(
|
|
2387
|
-
onlineUserIds === void 0 ? conversationId : ""
|
|
2388
|
-
);
|
|
2414
|
+
const { online: presenceOnline } = react$1.usePresence(onlineUserIds === void 0 ? conversationId : "");
|
|
2389
2415
|
const effectiveOnline = onlineUserIds ?? presenceOnline;
|
|
2390
2416
|
if (loading && members.length === 0) {
|
|
2391
2417
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: "Loading members\u2026" });
|