@poolse/react-ui 1.0.5 → 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 +101 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.js +101 -73
- package/dist/index.js.map +1 -1
- package/dist/styles.css +233 -12
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -343,6 +343,7 @@ function UploadChip({
|
|
|
343
343
|
}) {
|
|
344
344
|
const pct = item.byteSize > 0 ? Math.min(100, Math.round(item.loaded / item.byteSize * 100)) : 0;
|
|
345
345
|
const isError = item.status === "error";
|
|
346
|
+
const isReady = item.status === "ready";
|
|
346
347
|
const isInFlight = item.status === "pending" || item.status === "uploading";
|
|
347
348
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
348
349
|
"div",
|
|
@@ -350,10 +351,15 @@ function UploadChip({
|
|
|
350
351
|
className: `poolse-upload-chip poolse-upload-chip--${item.status}`,
|
|
351
352
|
"data-status": item.status,
|
|
352
353
|
children: [
|
|
353
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__icon", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name:
|
|
354
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__icon", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: isReady ? "check" : "attachment", size: 18, label: null }) }),
|
|
354
355
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-upload-chip__body", children: [
|
|
355
356
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__filename", title: item.filename, children: item.filename }),
|
|
356
|
-
isError ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__error", children: item.error?.message ?? "Upload failed" }) :
|
|
357
|
+
isError ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__error", children: item.error?.message ?? "Upload failed" }) : isReady ? (
|
|
358
|
+
// No progress bar once the upload is done — the chip itself
|
|
359
|
+
// is the "staged, waiting on send" signal. A short caption
|
|
360
|
+
// makes that explicit for screen-readers + glance-readers.
|
|
361
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__ready-label", children: "Ready to send" })
|
|
362
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
357
363
|
"div",
|
|
358
364
|
{
|
|
359
365
|
className: "poolse-upload-chip__bar",
|
|
@@ -372,8 +378,8 @@ function UploadChip({
|
|
|
372
378
|
type: "button",
|
|
373
379
|
className: "poolse-upload-chip__action",
|
|
374
380
|
onClick: isInFlight ? onCancel : onDismiss,
|
|
375
|
-
"aria-label": isInFlight ? `Cancel upload of ${item.filename}` : `Dismiss ${item.filename}`,
|
|
376
|
-
title: isInFlight ? "Cancel" : "Dismiss",
|
|
381
|
+
"aria-label": isInFlight ? `Cancel upload of ${item.filename}` : isReady ? `Remove ${item.filename}` : `Dismiss ${item.filename}`,
|
|
382
|
+
title: isInFlight ? "Cancel" : isReady ? "Remove" : "Dismiss",
|
|
377
383
|
children: "\xD7"
|
|
378
384
|
}
|
|
379
385
|
)
|
|
@@ -436,9 +442,7 @@ var MentionInput = react.forwardRef(
|
|
|
436
442
|
const fileInputRef = react.useRef(null);
|
|
437
443
|
useAutogrow(taRef, value);
|
|
438
444
|
const { queue, uploadAll, cancel: cancelUpload, remove: removeUpload } = react$1.useAttachmentUpload();
|
|
439
|
-
const visibleUploads = queue.filter(
|
|
440
|
-
(it) => it.status === "pending" || it.status === "uploading" || it.status === "error"
|
|
441
|
-
);
|
|
445
|
+
const visibleUploads = queue.filter((it) => it.status !== "cancelled");
|
|
442
446
|
const readyCount = queue.filter((it) => it.status === "ready").length;
|
|
443
447
|
const uploading = queue.some((it) => it.status === "pending" || it.status === "uploading");
|
|
444
448
|
const addFiles = (files) => {
|
|
@@ -712,19 +716,10 @@ var MessageComposer = react.forwardRef(
|
|
|
712
716
|
const taRef = react.useRef(null);
|
|
713
717
|
const fileInputRef = react.useRef(null);
|
|
714
718
|
useAutogrow(taRef, value);
|
|
715
|
-
const {
|
|
716
|
-
|
|
717
|
-
uploadAll,
|
|
718
|
-
cancel: cancelUpload,
|
|
719
|
-
remove: removeUpload
|
|
720
|
-
} = react$1.useAttachmentUpload();
|
|
721
|
-
const visibleUploads = queue.filter(
|
|
722
|
-
(it) => it.status === "pending" || it.status === "uploading" || it.status === "error"
|
|
723
|
-
);
|
|
719
|
+
const { queue, uploadAll, cancel: cancelUpload, remove: removeUpload } = react$1.useAttachmentUpload();
|
|
720
|
+
const visibleUploads = queue.filter((it) => it.status !== "cancelled");
|
|
724
721
|
const readyCount = queue.filter((it) => it.status === "ready").length;
|
|
725
|
-
const uploading = queue.some(
|
|
726
|
-
(it) => it.status === "pending" || it.status === "uploading"
|
|
727
|
-
);
|
|
722
|
+
const uploading = queue.some((it) => it.status === "pending" || it.status === "uploading");
|
|
728
723
|
const addFiles = (files) => {
|
|
729
724
|
if (!attachments || files.length === 0) return;
|
|
730
725
|
void uploadAll(
|
|
@@ -895,6 +890,24 @@ function ReplyChip({
|
|
|
895
890
|
)
|
|
896
891
|
] });
|
|
897
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
|
+
}
|
|
898
911
|
function AttachmentPreview({ attachment, onClick }) {
|
|
899
912
|
const isFullRow = "content_type" in attachment;
|
|
900
913
|
const { url, loading, error } = react$1.useAttachmentUrl(attachment.id);
|
|
@@ -1058,24 +1071,6 @@ function formatBytes(n) {
|
|
|
1058
1071
|
if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
|
1059
1072
|
return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
1060
1073
|
}
|
|
1061
|
-
function Avatar({ src, name, online, size = "md", className }) {
|
|
1062
|
-
const initials = computeInitials(name);
|
|
1063
|
-
const classes = [
|
|
1064
|
-
"poolse-avatar",
|
|
1065
|
-
size === "sm" ? "poolse-avatar--sm" : null,
|
|
1066
|
-
size === "lg" ? "poolse-avatar--lg" : null,
|
|
1067
|
-
className
|
|
1068
|
-
].filter(Boolean).join(" ");
|
|
1069
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: classes, "aria-label": name ?? "avatar", role: "img", children: [
|
|
1070
|
-
src ? /* @__PURE__ */ jsxRuntime.jsx("img", { src, alt: name ?? "" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: initials }),
|
|
1071
|
-
online ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-avatar__presence", "aria-hidden": "true" }) : null
|
|
1072
|
-
] });
|
|
1073
|
-
}
|
|
1074
|
-
function computeInitials(name) {
|
|
1075
|
-
if (!name) return "?";
|
|
1076
|
-
const parts = name.trim().split(/\s+/).slice(0, 2);
|
|
1077
|
-
return parts.map((p) => p.charAt(0).toUpperCase()).join("").slice(0, 2) || "?";
|
|
1078
|
-
}
|
|
1079
1074
|
|
|
1080
1075
|
// src/userColor.ts
|
|
1081
1076
|
var PALETTE = [
|
|
@@ -1113,7 +1108,8 @@ function MessageBubble({
|
|
|
1113
1108
|
maxBodyLength = 0,
|
|
1114
1109
|
markdown = false,
|
|
1115
1110
|
showSenderName = false,
|
|
1116
|
-
actionsTrigger
|
|
1111
|
+
actionsTrigger,
|
|
1112
|
+
showAttachments = true
|
|
1117
1113
|
}) {
|
|
1118
1114
|
const isSelf = currentUserId !== null && message.sender_id === currentUserId;
|
|
1119
1115
|
const [expanded, setExpanded] = react.useState(false);
|
|
@@ -1122,17 +1118,27 @@ function MessageBubble({
|
|
|
1122
1118
|
const senderName = sender?.displayName ?? senderFallbackName;
|
|
1123
1119
|
const senderColorHex = message.sender_id ? userColor(message.sender_id) : "currentColor";
|
|
1124
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;
|
|
1125
1131
|
const className = [
|
|
1126
1132
|
"poolse-message",
|
|
1127
1133
|
isSelf ? "poolse-message--self" : "poolse-message--other",
|
|
1128
1134
|
// Group-position modifier — CSS uses it to toggle which corners
|
|
1129
1135
|
// get the asymmetric tail vs. fully-rounded treatment.
|
|
1130
|
-
`poolse-message--${groupPosition}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
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(" ");
|
|
1136
1142
|
const time = message.inserted_at ? new Date(message.inserted_at).toLocaleTimeString(void 0, {
|
|
1137
1143
|
hour: "2-digit",
|
|
1138
1144
|
minute: "2-digit"
|
|
@@ -1151,7 +1157,9 @@ function MessageBubble({
|
|
|
1151
1157
|
}
|
|
1152
1158
|
),
|
|
1153
1159
|
showQuoteCard === "placeholder" && /* @__PURE__ */ jsxRuntime.jsx(QuotedPlaceholder, { isSelf, quotedMessageId: message.quoted_message_id }),
|
|
1154
|
-
|
|
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: [
|
|
1155
1163
|
markdown ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1156
1164
|
ReactMarkdown__default.default,
|
|
1157
1165
|
{
|
|
@@ -1188,21 +1196,53 @@ function MessageBubble({
|
|
|
1188
1196
|
children: "Show less"
|
|
1189
1197
|
}
|
|
1190
1198
|
)
|
|
1191
|
-
] }),
|
|
1192
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
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
|
+
)
|
|
1204
1218
|
] });
|
|
1205
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
|
+
}
|
|
1206
1246
|
function QuotedPlaceholder({
|
|
1207
1247
|
isSelf,
|
|
1208
1248
|
quotedMessageId: _quotedMessageId
|
|
@@ -1540,7 +1580,6 @@ function MessageRow({
|
|
|
1540
1580
|
currentUserId: meId
|
|
1541
1581
|
});
|
|
1542
1582
|
const showReactions = reactions && !msg.deleted_at;
|
|
1543
|
-
const showAttachments = attachments && Array.isArray(msg.attachments) && msg.attachments.length > 0;
|
|
1544
1583
|
const showActions = actions && !msg.deleted_at && !editing;
|
|
1545
1584
|
const replyCount = msg.reply_count ?? 0;
|
|
1546
1585
|
const showThreadPill = threads && !msg.deleted_at && !msg.thread_root_id && replyCount > 0;
|
|
@@ -1610,6 +1649,7 @@ function MessageRow({
|
|
|
1610
1649
|
maxBodyLength,
|
|
1611
1650
|
markdown,
|
|
1612
1651
|
showSenderName,
|
|
1652
|
+
showAttachments: attachments,
|
|
1613
1653
|
...readState ? { readState } : {},
|
|
1614
1654
|
...labelFor ? { labelFor } : {},
|
|
1615
1655
|
...onQuotedClick ? { onQuotedClick } : {},
|
|
@@ -1633,7 +1673,6 @@ function MessageRow({
|
|
|
1633
1673
|
)
|
|
1634
1674
|
}
|
|
1635
1675
|
),
|
|
1636
|
-
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)) }),
|
|
1637
1676
|
showReactions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1638
1677
|
InlineReactions,
|
|
1639
1678
|
{
|
|
@@ -1892,16 +1931,7 @@ function TypingIndicator({ typing, labelFor }) {
|
|
|
1892
1931
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-typing__dot" }),
|
|
1893
1932
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-typing__dot" })
|
|
1894
1933
|
] }),
|
|
1895
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1896
|
-
"span",
|
|
1897
|
-
{
|
|
1898
|
-
className: "poolse-typing__label",
|
|
1899
|
-
role: "status",
|
|
1900
|
-
"aria-live": "polite",
|
|
1901
|
-
"aria-atomic": "true",
|
|
1902
|
-
children: isTyping ? /* @__PURE__ */ jsxRuntime.jsx(TypingLabel, { ids, ...labelFor ? { labelFor } : {} }) : ""
|
|
1903
|
-
}
|
|
1904
|
-
)
|
|
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 } : {} }) : "" })
|
|
1905
1935
|
] });
|
|
1906
1936
|
}
|
|
1907
1937
|
function TypingLabel({ ids, labelFor }) {
|
|
@@ -2381,9 +2411,7 @@ function MemberList({
|
|
|
2381
2411
|
emptyState
|
|
2382
2412
|
}) {
|
|
2383
2413
|
const { members, loading, error, removeMember } = react$1.useMembers(conversationId);
|
|
2384
|
-
const { online: presenceOnline } = react$1.usePresence(
|
|
2385
|
-
onlineUserIds === void 0 ? conversationId : ""
|
|
2386
|
-
);
|
|
2414
|
+
const { online: presenceOnline } = react$1.usePresence(onlineUserIds === void 0 ? conversationId : "");
|
|
2387
2415
|
const effectiveOnline = onlineUserIds ?? presenceOnline;
|
|
2388
2416
|
if (loading && members.length === 0) {
|
|
2389
2417
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: "Loading members\u2026" });
|