@poolse/react-ui 1.0.3 → 1.0.5
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 +582 -430
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -8
- package/dist/index.d.ts +37 -8
- package/dist/index.js +585 -433
- package/dist/index.js.map +1 -1
- package/dist/styles.css +78 -12
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -324,6 +324,63 @@ function PoolseIcon({
|
|
|
324
324
|
}
|
|
325
325
|
);
|
|
326
326
|
}
|
|
327
|
+
function UploadQueueStrip({ items, onCancel, onDismiss }) {
|
|
328
|
+
if (items.length === 0) return null;
|
|
329
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-strip", role: "status", "aria-live": "polite", children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
330
|
+
UploadChip,
|
|
331
|
+
{
|
|
332
|
+
item,
|
|
333
|
+
onCancel: () => onCancel(item.localId),
|
|
334
|
+
onDismiss: () => onDismiss(item.localId)
|
|
335
|
+
},
|
|
336
|
+
item.localId
|
|
337
|
+
)) });
|
|
338
|
+
}
|
|
339
|
+
function UploadChip({
|
|
340
|
+
item,
|
|
341
|
+
onCancel,
|
|
342
|
+
onDismiss
|
|
343
|
+
}) {
|
|
344
|
+
const pct = item.byteSize > 0 ? Math.min(100, Math.round(item.loaded / item.byteSize * 100)) : 0;
|
|
345
|
+
const isError = item.status === "error";
|
|
346
|
+
const isInFlight = item.status === "pending" || item.status === "uploading";
|
|
347
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
348
|
+
"div",
|
|
349
|
+
{
|
|
350
|
+
className: `poolse-upload-chip poolse-upload-chip--${item.status}`,
|
|
351
|
+
"data-status": item.status,
|
|
352
|
+
children: [
|
|
353
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__icon", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: isError ? "attachment" : "attachment", size: 18, label: null }) }),
|
|
354
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-upload-chip__body", children: [
|
|
355
|
+
/* @__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" }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
357
|
+
"div",
|
|
358
|
+
{
|
|
359
|
+
className: "poolse-upload-chip__bar",
|
|
360
|
+
role: "progressbar",
|
|
361
|
+
"aria-valuemin": 0,
|
|
362
|
+
"aria-valuemax": 100,
|
|
363
|
+
"aria-valuenow": pct,
|
|
364
|
+
"aria-label": `Uploading ${item.filename}`,
|
|
365
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__bar-fill", style: { width: `${pct}%` } })
|
|
366
|
+
}
|
|
367
|
+
)
|
|
368
|
+
] }),
|
|
369
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
370
|
+
"button",
|
|
371
|
+
{
|
|
372
|
+
type: "button",
|
|
373
|
+
className: "poolse-upload-chip__action",
|
|
374
|
+
onClick: isInFlight ? onCancel : onDismiss,
|
|
375
|
+
"aria-label": isInFlight ? `Cancel upload of ${item.filename}` : `Dismiss ${item.filename}`,
|
|
376
|
+
title: isInFlight ? "Cancel" : "Dismiss",
|
|
377
|
+
children: "\xD7"
|
|
378
|
+
}
|
|
379
|
+
)
|
|
380
|
+
]
|
|
381
|
+
}
|
|
382
|
+
);
|
|
383
|
+
}
|
|
327
384
|
var MAX_NAME_CHARS = 24;
|
|
328
385
|
function UserName({
|
|
329
386
|
userId,
|
|
@@ -349,317 +406,467 @@ function truncate(s) {
|
|
|
349
406
|
if (s.length <= MAX_NAME_CHARS) return s;
|
|
350
407
|
return s.slice(0, MAX_NAME_CHARS - 1) + "\u2026";
|
|
351
408
|
}
|
|
352
|
-
function
|
|
353
|
-
conversationId,
|
|
354
|
-
onSend,
|
|
355
|
-
onTyping,
|
|
356
|
-
placeholder = "Type a message\u2026",
|
|
357
|
-
disabled = false,
|
|
358
|
-
labelFor,
|
|
359
|
-
replyingTo,
|
|
360
|
-
onCancelReply
|
|
361
|
-
}) {
|
|
362
|
-
const { members } = react$1.useMembers(conversationId);
|
|
363
|
-
const [value, setValue] = react.useState("");
|
|
364
|
-
const [sending, setSending] = react.useState(false);
|
|
365
|
-
const [mention, setMention] = react.useState(null);
|
|
366
|
-
const [activeIdx, setActiveIdx] = react.useState(0);
|
|
367
|
-
const selectedMentions = react.useRef(/* @__PURE__ */ new Set());
|
|
368
|
-
const taRef = react.useRef(null);
|
|
369
|
-
const label = labelFor ?? ((id) => id.slice(0, 8));
|
|
370
|
-
const filtered = mention ? members.filter((m) => label(m.user_id).toLowerCase().includes(mention.query.toLowerCase())) : [];
|
|
409
|
+
function useAutogrow(ref, value) {
|
|
371
410
|
react.useEffect(() => {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
411
|
+
const ta = ref.current;
|
|
412
|
+
if (!ta) return;
|
|
413
|
+
ta.style.height = "auto";
|
|
414
|
+
ta.style.height = `${ta.scrollHeight}px`;
|
|
415
|
+
}, [ref, value]);
|
|
416
|
+
}
|
|
417
|
+
var MentionInput = react.forwardRef(
|
|
418
|
+
function MentionInput2({
|
|
419
|
+
conversationId,
|
|
420
|
+
onSend,
|
|
421
|
+
onTyping,
|
|
422
|
+
placeholder = "Type a message\u2026",
|
|
423
|
+
disabled = false,
|
|
424
|
+
labelFor,
|
|
425
|
+
replyingTo,
|
|
426
|
+
onCancelReply,
|
|
427
|
+
attachments = true
|
|
428
|
+
}, ref) {
|
|
429
|
+
const { members } = react$1.useMembers(conversationId);
|
|
430
|
+
const [value, setValue] = react.useState("");
|
|
431
|
+
const [sending, setSending] = react.useState(false);
|
|
432
|
+
const [mention, setMention] = react.useState(null);
|
|
433
|
+
const [activeIdx, setActiveIdx] = react.useState(0);
|
|
434
|
+
const selectedMentions = react.useRef(/* @__PURE__ */ new Set());
|
|
435
|
+
const taRef = react.useRef(null);
|
|
436
|
+
const fileInputRef = react.useRef(null);
|
|
437
|
+
useAutogrow(taRef, value);
|
|
438
|
+
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
|
+
);
|
|
442
|
+
const readyCount = queue.filter((it) => it.status === "ready").length;
|
|
443
|
+
const uploading = queue.some((it) => it.status === "pending" || it.status === "uploading");
|
|
444
|
+
const addFiles = (files) => {
|
|
445
|
+
if (!attachments || files.length === 0) return;
|
|
446
|
+
void uploadAll(
|
|
447
|
+
files.map((f) => ({
|
|
448
|
+
body: f,
|
|
449
|
+
contentType: f.type || "application/octet-stream",
|
|
450
|
+
byteSize: f.size,
|
|
451
|
+
filename: f.name
|
|
452
|
+
}))
|
|
453
|
+
).catch(() => {
|
|
384
454
|
});
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
const query = head.slice(at + 1);
|
|
423
|
-
if (isAtBoundary && !/\s/.test(query)) {
|
|
424
|
-
setMention({ start: at, query });
|
|
425
|
-
} else {
|
|
455
|
+
};
|
|
456
|
+
react.useImperativeHandle(ref, () => ({ addFiles }), [addFiles, attachments]);
|
|
457
|
+
const label = labelFor ?? ((id) => id.slice(0, 8));
|
|
458
|
+
const filtered = mention ? members.filter((m) => label(m.user_id).toLowerCase().includes(mention.query.toLowerCase())) : [];
|
|
459
|
+
react.useEffect(() => {
|
|
460
|
+
setActiveIdx(0);
|
|
461
|
+
}, [filtered.length, mention?.query]);
|
|
462
|
+
const submit = async () => {
|
|
463
|
+
const trimmed = value.trim();
|
|
464
|
+
const ready = queue.filter((it) => it.status === "ready");
|
|
465
|
+
const hasReady = ready.length > 0;
|
|
466
|
+
if (!trimmed && !hasReady || sending || uploading) return;
|
|
467
|
+
setSending(true);
|
|
468
|
+
try {
|
|
469
|
+
const mentions = Array.from(selectedMentions.current);
|
|
470
|
+
await onSend({
|
|
471
|
+
body: trimmed,
|
|
472
|
+
...mentions.length > 0 ? { mentions } : {},
|
|
473
|
+
...replyingTo ? { quoted_message_id: replyingTo.id } : {},
|
|
474
|
+
...hasReady ? { attachment_ids: ready.map((it) => it.attachment.id) } : {}
|
|
475
|
+
});
|
|
476
|
+
setValue("");
|
|
477
|
+
selectedMentions.current = /* @__PURE__ */ new Set();
|
|
478
|
+
for (const it of ready) removeUpload(it.localId);
|
|
479
|
+
} finally {
|
|
480
|
+
setSending(false);
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
const insertMention = (m) => {
|
|
484
|
+
if (!mention) return;
|
|
485
|
+
const name = label(m.user_id);
|
|
486
|
+
const before = value.slice(0, mention.start);
|
|
487
|
+
const after = value.slice(mention.start + 1 + mention.query.length);
|
|
488
|
+
const inserted = `@${name} `;
|
|
489
|
+
const next = `${before}${inserted}${after}`;
|
|
490
|
+
selectedMentions.current.add(m.user_id);
|
|
491
|
+
setValue(next);
|
|
426
492
|
setMention(null);
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
493
|
+
requestAnimationFrame(() => {
|
|
494
|
+
const ta = taRef.current;
|
|
495
|
+
if (!ta) return;
|
|
496
|
+
const pos = before.length + inserted.length;
|
|
497
|
+
ta.focus();
|
|
498
|
+
ta.setSelectionRange(pos, pos);
|
|
499
|
+
});
|
|
500
|
+
};
|
|
501
|
+
const onChange = (e) => {
|
|
502
|
+
const next = e.target.value;
|
|
503
|
+
setValue(next);
|
|
504
|
+
onTyping?.();
|
|
505
|
+
const caret = e.target.selectionStart ?? next.length;
|
|
506
|
+
const head = next.slice(0, caret);
|
|
507
|
+
const at = head.lastIndexOf("@");
|
|
508
|
+
if (at === -1) {
|
|
509
|
+
setMention(null);
|
|
434
510
|
return;
|
|
435
511
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
512
|
+
const charBefore = at === 0 ? " " : head.charAt(at - 1);
|
|
513
|
+
const isAtBoundary = /\s/.test(charBefore);
|
|
514
|
+
const query = head.slice(at + 1);
|
|
515
|
+
if (isAtBoundary && !/\s/.test(query)) {
|
|
516
|
+
setMention({ start: at, query });
|
|
517
|
+
} else {
|
|
518
|
+
setMention(null);
|
|
440
519
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
520
|
+
};
|
|
521
|
+
const onKeyDown = (e) => {
|
|
522
|
+
if (mention && filtered.length > 0) {
|
|
523
|
+
if (e.key === "ArrowDown") {
|
|
524
|
+
e.preventDefault();
|
|
525
|
+
setActiveIdx((i) => (i + 1) % filtered.length);
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
if (e.key === "ArrowUp") {
|
|
529
|
+
e.preventDefault();
|
|
530
|
+
setActiveIdx((i) => (i - 1 + filtered.length) % filtered.length);
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
if (e.key === "Enter" || e.key === "Tab") {
|
|
534
|
+
const pick = filtered[activeIdx];
|
|
535
|
+
if (pick) {
|
|
536
|
+
e.preventDefault();
|
|
537
|
+
insertMention(pick);
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
if (e.key === "Escape") {
|
|
444
542
|
e.preventDefault();
|
|
445
|
-
|
|
543
|
+
setMention(null);
|
|
446
544
|
return;
|
|
447
545
|
}
|
|
448
546
|
}
|
|
449
|
-
if (e.key === "
|
|
547
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
548
|
+
const ta = e.currentTarget;
|
|
549
|
+
const caret = ta.selectionStart;
|
|
550
|
+
const result = handleListEnter(value, caret);
|
|
551
|
+
if (result) {
|
|
552
|
+
e.preventDefault();
|
|
553
|
+
setValue(result.value);
|
|
554
|
+
requestAnimationFrame(() => {
|
|
555
|
+
taRef.current?.setSelectionRange(result.caret, result.caret);
|
|
556
|
+
});
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
450
559
|
e.preventDefault();
|
|
451
|
-
|
|
452
|
-
return;
|
|
560
|
+
void submit();
|
|
453
561
|
}
|
|
454
|
-
|
|
455
|
-
if (e.key === "Enter" && !e.shiftKey) {
|
|
456
|
-
const ta = e.currentTarget;
|
|
457
|
-
const caret = ta.selectionStart;
|
|
458
|
-
const result = handleListEnter(value, caret);
|
|
459
|
-
if (result) {
|
|
562
|
+
if (e.key === "Escape" && replyingTo && onCancelReply && !mention) {
|
|
460
563
|
e.preventDefault();
|
|
461
|
-
|
|
462
|
-
requestAnimationFrame(() => {
|
|
463
|
-
taRef.current?.setSelectionRange(result.caret, result.caret);
|
|
464
|
-
});
|
|
465
|
-
return;
|
|
564
|
+
onCancelReply();
|
|
466
565
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__reply-body", children: [
|
|
488
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-composer__reply-label", children: [
|
|
489
|
-
"Replying to ",
|
|
490
|
-
replyLabel
|
|
566
|
+
};
|
|
567
|
+
const replyLabel = replyingTo?.sender_id ? labelFor?.(replyingTo.sender_id) ?? `User ${replyingTo.sender_id.slice(0, 6)}` : "Unknown";
|
|
568
|
+
const canSend = !disabled && !sending && !uploading && (value.trim() !== "" || readyCount > 0);
|
|
569
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
570
|
+
"form",
|
|
571
|
+
{
|
|
572
|
+
className: "poolse-composer",
|
|
573
|
+
onSubmit: (e) => {
|
|
574
|
+
e.preventDefault();
|
|
575
|
+
void submit();
|
|
576
|
+
},
|
|
577
|
+
style: { position: "relative" },
|
|
578
|
+
children: [
|
|
579
|
+
replyingTo && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__reply", role: "status", children: [
|
|
580
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__reply-body", children: [
|
|
581
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-composer__reply-label", children: [
|
|
582
|
+
"Replying to ",
|
|
583
|
+
replyLabel
|
|
584
|
+
] }),
|
|
585
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-composer__reply-preview", children: replyingTo.body ?? "" })
|
|
491
586
|
] }),
|
|
492
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
587
|
+
onCancelReply && /* @__PURE__ */ jsxRuntime.jsx(
|
|
588
|
+
"button",
|
|
589
|
+
{
|
|
590
|
+
type: "button",
|
|
591
|
+
className: "poolse-composer__reply-cancel",
|
|
592
|
+
onClick: onCancelReply,
|
|
593
|
+
"aria-label": "Cancel reply",
|
|
594
|
+
title: "Cancel reply",
|
|
595
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "close", size: 14, label: null })
|
|
596
|
+
}
|
|
597
|
+
)
|
|
493
598
|
] }),
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
{
|
|
497
|
-
type: "button",
|
|
498
|
-
className: "poolse-composer__reply-cancel",
|
|
499
|
-
onClick: onCancelReply,
|
|
500
|
-
"aria-label": "Cancel reply",
|
|
501
|
-
title: "Cancel reply",
|
|
502
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "close", size: 14, label: null })
|
|
503
|
-
}
|
|
504
|
-
)
|
|
505
|
-
] }),
|
|
506
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__row", children: [
|
|
507
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
508
|
-
"textarea",
|
|
599
|
+
attachments && visibleUploads.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
600
|
+
UploadQueueStrip,
|
|
509
601
|
{
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
value,
|
|
514
|
-
onChange,
|
|
515
|
-
onKeyDown,
|
|
516
|
-
placeholder,
|
|
517
|
-
disabled: disabled || sending,
|
|
518
|
-
"aria-label": placeholder,
|
|
519
|
-
role: "combobox",
|
|
520
|
-
"aria-expanded": Boolean(mention && filtered.length > 0),
|
|
521
|
-
"aria-controls": "poolse-mention-menu",
|
|
522
|
-
"aria-autocomplete": "list",
|
|
523
|
-
...mention && filtered.length > 0 ? { "aria-activedescendant": `poolse-mention-opt-${activeIdx}` } : {}
|
|
602
|
+
items: visibleUploads,
|
|
603
|
+
onCancel: cancelUpload,
|
|
604
|
+
onDismiss: removeUpload
|
|
524
605
|
}
|
|
525
606
|
),
|
|
526
|
-
/* @__PURE__ */ jsxRuntime.
|
|
527
|
-
|
|
607
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__row", children: [
|
|
608
|
+
attachments && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
609
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
610
|
+
"input",
|
|
611
|
+
{
|
|
612
|
+
ref: fileInputRef,
|
|
613
|
+
type: "file",
|
|
614
|
+
multiple: true,
|
|
615
|
+
className: "poolse-attach-input",
|
|
616
|
+
onChange: (e) => {
|
|
617
|
+
const files = Array.from(e.target.files ?? []);
|
|
618
|
+
if (files.length > 0) addFiles(files);
|
|
619
|
+
e.target.value = "";
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
),
|
|
623
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
624
|
+
"button",
|
|
625
|
+
{
|
|
626
|
+
type: "button",
|
|
627
|
+
className: "poolse-composer__attach",
|
|
628
|
+
onClick: () => fileInputRef.current?.click(),
|
|
629
|
+
disabled: disabled || sending,
|
|
630
|
+
"aria-label": "Attach files",
|
|
631
|
+
title: "Attach files",
|
|
632
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "attachment", size: 20, label: null })
|
|
633
|
+
}
|
|
634
|
+
)
|
|
635
|
+
] }),
|
|
636
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
637
|
+
"textarea",
|
|
638
|
+
{
|
|
639
|
+
ref: taRef,
|
|
640
|
+
className: "poolse-composer__input",
|
|
641
|
+
rows: 1,
|
|
642
|
+
value,
|
|
643
|
+
onChange,
|
|
644
|
+
onKeyDown,
|
|
645
|
+
placeholder,
|
|
646
|
+
disabled: disabled || sending,
|
|
647
|
+
"aria-label": placeholder,
|
|
648
|
+
role: "combobox",
|
|
649
|
+
"aria-expanded": Boolean(mention && filtered.length > 0),
|
|
650
|
+
"aria-controls": "poolse-mention-menu",
|
|
651
|
+
"aria-autocomplete": "list",
|
|
652
|
+
...mention && filtered.length > 0 ? { "aria-activedescendant": `poolse-mention-opt-${activeIdx}` } : {}
|
|
653
|
+
}
|
|
654
|
+
),
|
|
655
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
656
|
+
"button",
|
|
657
|
+
{
|
|
658
|
+
type: "submit",
|
|
659
|
+
className: "poolse-composer__send",
|
|
660
|
+
disabled: !canSend,
|
|
661
|
+
"aria-label": "Send message",
|
|
662
|
+
title: uploading ? "Waiting for uploads\u2026" : "Send message",
|
|
663
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "send-fill", label: null })
|
|
664
|
+
}
|
|
665
|
+
)
|
|
666
|
+
] }),
|
|
667
|
+
mention && filtered.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
668
|
+
"div",
|
|
528
669
|
{
|
|
529
|
-
|
|
530
|
-
className: "poolse-
|
|
531
|
-
|
|
532
|
-
"aria-label": "
|
|
533
|
-
children: /* @__PURE__ */ jsxRuntime.
|
|
670
|
+
id: "poolse-mention-menu",
|
|
671
|
+
className: "poolse-mention-menu",
|
|
672
|
+
role: "listbox",
|
|
673
|
+
"aria-label": "Members",
|
|
674
|
+
children: filtered.map((m, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
675
|
+
"div",
|
|
676
|
+
{
|
|
677
|
+
id: `poolse-mention-opt-${i}`,
|
|
678
|
+
role: "option",
|
|
679
|
+
"aria-selected": i === activeIdx,
|
|
680
|
+
className: `poolse-mention-menu__item${i === activeIdx ? " poolse-mention-menu__item--active" : ""}`,
|
|
681
|
+
onMouseDown: (e) => {
|
|
682
|
+
e.preventDefault();
|
|
683
|
+
insertMention(m);
|
|
684
|
+
},
|
|
685
|
+
children: [
|
|
686
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "@" }),
|
|
687
|
+
/* @__PURE__ */ jsxRuntime.jsx(UserName, { userId: m.user_id, ...labelFor ? { labelFor } : {} })
|
|
688
|
+
]
|
|
689
|
+
},
|
|
690
|
+
m.id
|
|
691
|
+
))
|
|
534
692
|
}
|
|
535
693
|
)
|
|
536
|
-
]
|
|
537
|
-
mention && filtered.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
538
|
-
"div",
|
|
539
|
-
{
|
|
540
|
-
id: "poolse-mention-menu",
|
|
541
|
-
className: "poolse-mention-menu",
|
|
542
|
-
role: "listbox",
|
|
543
|
-
"aria-label": "Members",
|
|
544
|
-
children: filtered.map((m, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
545
|
-
"div",
|
|
546
|
-
{
|
|
547
|
-
id: `poolse-mention-opt-${i}`,
|
|
548
|
-
role: "option",
|
|
549
|
-
"aria-selected": i === activeIdx,
|
|
550
|
-
className: `poolse-mention-menu__item${i === activeIdx ? " poolse-mention-menu__item--active" : ""}`,
|
|
551
|
-
onMouseDown: (e) => {
|
|
552
|
-
e.preventDefault();
|
|
553
|
-
insertMention(m);
|
|
554
|
-
},
|
|
555
|
-
children: [
|
|
556
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "@" }),
|
|
557
|
-
/* @__PURE__ */ jsxRuntime.jsx(UserName, { userId: m.user_id, ...labelFor ? { labelFor } : {} })
|
|
558
|
-
]
|
|
559
|
-
},
|
|
560
|
-
m.id
|
|
561
|
-
))
|
|
562
|
-
}
|
|
563
|
-
)
|
|
564
|
-
]
|
|
565
|
-
}
|
|
566
|
-
);
|
|
567
|
-
}
|
|
568
|
-
function MessageComposer({
|
|
569
|
-
onSend,
|
|
570
|
-
onTyping,
|
|
571
|
-
placeholder = "Type a message\u2026",
|
|
572
|
-
disabled = false,
|
|
573
|
-
replyingTo,
|
|
574
|
-
onCancelReply,
|
|
575
|
-
labelFor
|
|
576
|
-
}) {
|
|
577
|
-
const [value, setValue] = react.useState("");
|
|
578
|
-
const [sending, setSending] = react.useState(false);
|
|
579
|
-
const taRef = react.useRef(null);
|
|
580
|
-
const submit = async () => {
|
|
581
|
-
const trimmed = value.trim();
|
|
582
|
-
if (!trimmed || sending) return;
|
|
583
|
-
setSending(true);
|
|
584
|
-
try {
|
|
585
|
-
await onSend(trimmed, replyingTo ? { quoted_message_id: replyingTo.id } : void 0);
|
|
586
|
-
setValue("");
|
|
587
|
-
} finally {
|
|
588
|
-
setSending(false);
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
const onKeyDown = (e) => {
|
|
592
|
-
if (e.key === "Enter" && !e.shiftKey) {
|
|
593
|
-
const ta = e.currentTarget;
|
|
594
|
-
const caret = ta.selectionStart;
|
|
595
|
-
const result = handleListEnter(value, caret);
|
|
596
|
-
if (result) {
|
|
597
|
-
e.preventDefault();
|
|
598
|
-
setValue(result.value);
|
|
599
|
-
requestAnimationFrame(() => {
|
|
600
|
-
taRef.current?.setSelectionRange(result.caret, result.caret);
|
|
601
|
-
});
|
|
602
|
-
return;
|
|
694
|
+
]
|
|
603
695
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
696
|
+
);
|
|
697
|
+
}
|
|
698
|
+
);
|
|
699
|
+
var MessageComposer = react.forwardRef(
|
|
700
|
+
function MessageComposer2({
|
|
701
|
+
onSend,
|
|
702
|
+
onTyping,
|
|
703
|
+
placeholder = "Type a message\u2026",
|
|
704
|
+
disabled = false,
|
|
705
|
+
replyingTo,
|
|
706
|
+
onCancelReply,
|
|
707
|
+
labelFor,
|
|
708
|
+
attachments = true
|
|
709
|
+
}, ref) {
|
|
710
|
+
const [value, setValue] = react.useState("");
|
|
711
|
+
const [sending, setSending] = react.useState(false);
|
|
712
|
+
const taRef = react.useRef(null);
|
|
713
|
+
const fileInputRef = react.useRef(null);
|
|
714
|
+
useAutogrow(taRef, value);
|
|
715
|
+
const {
|
|
716
|
+
queue,
|
|
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
|
+
);
|
|
724
|
+
const readyCount = queue.filter((it) => it.status === "ready").length;
|
|
725
|
+
const uploading = queue.some(
|
|
726
|
+
(it) => it.status === "pending" || it.status === "uploading"
|
|
727
|
+
);
|
|
728
|
+
const addFiles = (files) => {
|
|
729
|
+
if (!attachments || files.length === 0) return;
|
|
730
|
+
void uploadAll(
|
|
731
|
+
files.map((f) => ({
|
|
732
|
+
body: f,
|
|
733
|
+
contentType: f.type || "application/octet-stream",
|
|
734
|
+
byteSize: f.size,
|
|
735
|
+
filename: f.name
|
|
736
|
+
}))
|
|
737
|
+
).catch(() => {
|
|
738
|
+
});
|
|
739
|
+
};
|
|
740
|
+
react.useImperativeHandle(ref, () => ({ addFiles }), [addFiles, attachments]);
|
|
741
|
+
const submit = async () => {
|
|
742
|
+
const trimmed = value.trim();
|
|
743
|
+
const ready = queue.filter((it) => it.status === "ready");
|
|
744
|
+
const hasReady = ready.length > 0;
|
|
745
|
+
if (!trimmed && !hasReady || sending || uploading) return;
|
|
746
|
+
setSending(true);
|
|
747
|
+
try {
|
|
748
|
+
const opts = {
|
|
749
|
+
...replyingTo ? { quoted_message_id: replyingTo.id } : {},
|
|
750
|
+
...hasReady ? { attachment_ids: ready.map((it) => it.attachment.id) } : {}
|
|
751
|
+
};
|
|
752
|
+
await onSend(trimmed, Object.keys(opts).length > 0 ? opts : void 0);
|
|
753
|
+
setValue("");
|
|
754
|
+
for (const it of ready) removeUpload(it.localId);
|
|
755
|
+
} finally {
|
|
756
|
+
setSending(false);
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
const onKeyDown = (e) => {
|
|
760
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
761
|
+
const ta = e.currentTarget;
|
|
762
|
+
const caret = ta.selectionStart;
|
|
763
|
+
const result = handleListEnter(value, caret);
|
|
764
|
+
if (result) {
|
|
765
|
+
e.preventDefault();
|
|
766
|
+
setValue(result.value);
|
|
767
|
+
requestAnimationFrame(() => {
|
|
768
|
+
taRef.current?.setSelectionRange(result.caret, result.caret);
|
|
769
|
+
});
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
621
772
|
e.preventDefault();
|
|
622
773
|
void submit();
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
774
|
+
}
|
|
775
|
+
if (e.key === "Escape" && replyingTo && onCancelReply) {
|
|
776
|
+
e.preventDefault();
|
|
777
|
+
onCancelReply();
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
const onChange = (e) => {
|
|
781
|
+
setValue(e.target.value);
|
|
782
|
+
onTyping?.();
|
|
783
|
+
};
|
|
784
|
+
const canSend = !disabled && !sending && !uploading && (value.trim() !== "" || readyCount > 0);
|
|
785
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
786
|
+
"form",
|
|
787
|
+
{
|
|
788
|
+
className: "poolse-composer",
|
|
789
|
+
onSubmit: (e) => {
|
|
790
|
+
e.preventDefault();
|
|
791
|
+
void submit();
|
|
792
|
+
},
|
|
793
|
+
children: [
|
|
794
|
+
replyingTo && /* @__PURE__ */ jsxRuntime.jsx(
|
|
795
|
+
ReplyChip,
|
|
636
796
|
{
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
value,
|
|
641
|
-
onChange,
|
|
642
|
-
onKeyDown,
|
|
643
|
-
placeholder,
|
|
644
|
-
disabled: disabled || sending,
|
|
645
|
-
"aria-label": placeholder
|
|
797
|
+
message: replyingTo,
|
|
798
|
+
...labelFor ? { labelFor } : {},
|
|
799
|
+
...onCancelReply ? { onCancel: onCancelReply } : {}
|
|
646
800
|
}
|
|
647
801
|
),
|
|
648
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
649
|
-
|
|
802
|
+
attachments && visibleUploads.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
803
|
+
UploadQueueStrip,
|
|
650
804
|
{
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
"aria-label": "Send message",
|
|
655
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "send-fill", label: null })
|
|
805
|
+
items: visibleUploads,
|
|
806
|
+
onCancel: cancelUpload,
|
|
807
|
+
onDismiss: removeUpload
|
|
656
808
|
}
|
|
657
|
-
)
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
809
|
+
),
|
|
810
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__row", children: [
|
|
811
|
+
attachments && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
812
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
813
|
+
"input",
|
|
814
|
+
{
|
|
815
|
+
ref: fileInputRef,
|
|
816
|
+
type: "file",
|
|
817
|
+
multiple: true,
|
|
818
|
+
className: "poolse-attach-input",
|
|
819
|
+
onChange: (e) => {
|
|
820
|
+
const files = Array.from(e.target.files ?? []);
|
|
821
|
+
if (files.length > 0) addFiles(files);
|
|
822
|
+
e.target.value = "";
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
),
|
|
826
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
827
|
+
"button",
|
|
828
|
+
{
|
|
829
|
+
type: "button",
|
|
830
|
+
className: "poolse-composer__attach",
|
|
831
|
+
onClick: () => fileInputRef.current?.click(),
|
|
832
|
+
disabled: disabled || sending,
|
|
833
|
+
"aria-label": "Attach files",
|
|
834
|
+
title: "Attach files",
|
|
835
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "attachment", size: 20, label: null })
|
|
836
|
+
}
|
|
837
|
+
)
|
|
838
|
+
] }),
|
|
839
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
840
|
+
"textarea",
|
|
841
|
+
{
|
|
842
|
+
ref: taRef,
|
|
843
|
+
className: "poolse-composer__input",
|
|
844
|
+
rows: 1,
|
|
845
|
+
value,
|
|
846
|
+
onChange,
|
|
847
|
+
onKeyDown,
|
|
848
|
+
placeholder,
|
|
849
|
+
disabled: disabled || sending,
|
|
850
|
+
"aria-label": placeholder
|
|
851
|
+
}
|
|
852
|
+
),
|
|
853
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
854
|
+
"button",
|
|
855
|
+
{
|
|
856
|
+
type: "submit",
|
|
857
|
+
className: "poolse-composer__send",
|
|
858
|
+
disabled: !canSend,
|
|
859
|
+
"aria-label": "Send message",
|
|
860
|
+
title: uploading ? "Waiting for uploads\u2026" : "Send message",
|
|
861
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "send-fill", label: null })
|
|
862
|
+
}
|
|
863
|
+
)
|
|
864
|
+
] })
|
|
865
|
+
]
|
|
866
|
+
}
|
|
867
|
+
);
|
|
868
|
+
}
|
|
869
|
+
);
|
|
663
870
|
function ReplyChip({
|
|
664
871
|
message,
|
|
665
872
|
labelFor,
|
|
@@ -1229,7 +1436,6 @@ function ReactionPicker({
|
|
|
1229
1436
|
className: "poolse-reaction-picker",
|
|
1230
1437
|
role: "menu",
|
|
1231
1438
|
"aria-label": "Pick a reaction",
|
|
1232
|
-
style: { position: "absolute", bottom: "100%", left: 0, marginBottom: 6 },
|
|
1233
1439
|
onKeyDown: onKey,
|
|
1234
1440
|
children: COMMON_EMOJIS.map((e) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1235
1441
|
"button",
|
|
@@ -1535,13 +1741,52 @@ function ThreadView({
|
|
|
1535
1741
|
renderMessage
|
|
1536
1742
|
}) {
|
|
1537
1743
|
const { me } = react$1.useMe();
|
|
1538
|
-
const {
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1744
|
+
const {
|
|
1745
|
+
replies,
|
|
1746
|
+
loading,
|
|
1747
|
+
error,
|
|
1748
|
+
hasMore,
|
|
1749
|
+
loadMore,
|
|
1750
|
+
sendReply,
|
|
1751
|
+
edit,
|
|
1752
|
+
delete: deleteReply
|
|
1753
|
+
} = react$1.useThread(conversationId, rootMessage.id);
|
|
1754
|
+
const [editingId, setEditingId] = react.useState(null);
|
|
1755
|
+
react.useEffect(() => {
|
|
1756
|
+
setEditingId(null);
|
|
1757
|
+
}, [rootMessage.id]);
|
|
1542
1758
|
const listRef = react.useRef(null);
|
|
1543
1759
|
const closeBtnRef = react.useRef(null);
|
|
1544
1760
|
const lastReplyIdRef = react.useRef(null);
|
|
1761
|
+
const composerRef = react.useRef(null);
|
|
1762
|
+
const [dragActive, setDragActive] = react.useState(false);
|
|
1763
|
+
const dragDepthRef = react.useRef(0);
|
|
1764
|
+
const isFileDrag = (e) => Array.from(e.dataTransfer?.types ?? []).includes("Files");
|
|
1765
|
+
const onDragEnter = (e) => {
|
|
1766
|
+
if (!isFileDrag(e)) return;
|
|
1767
|
+
e.preventDefault();
|
|
1768
|
+
dragDepthRef.current += 1;
|
|
1769
|
+
setDragActive(true);
|
|
1770
|
+
};
|
|
1771
|
+
const onDragOver = (e) => {
|
|
1772
|
+
if (!isFileDrag(e)) return;
|
|
1773
|
+
e.preventDefault();
|
|
1774
|
+
if (e.dataTransfer) e.dataTransfer.dropEffect = "copy";
|
|
1775
|
+
};
|
|
1776
|
+
const onDragLeave = (e) => {
|
|
1777
|
+
if (!isFileDrag(e)) return;
|
|
1778
|
+
e.preventDefault();
|
|
1779
|
+
dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);
|
|
1780
|
+
if (dragDepthRef.current === 0) setDragActive(false);
|
|
1781
|
+
};
|
|
1782
|
+
const onDrop = (e) => {
|
|
1783
|
+
if (!isFileDrag(e)) return;
|
|
1784
|
+
e.preventDefault();
|
|
1785
|
+
dragDepthRef.current = 0;
|
|
1786
|
+
setDragActive(false);
|
|
1787
|
+
const files = Array.from(e.dataTransfer?.files ?? []);
|
|
1788
|
+
if (files.length > 0) composerRef.current?.addFiles(files);
|
|
1789
|
+
};
|
|
1545
1790
|
react.useEffect(() => {
|
|
1546
1791
|
const tail = replies[replies.length - 1];
|
|
1547
1792
|
if (!tail) return;
|
|
@@ -1559,13 +1804,37 @@ function ThreadView({
|
|
|
1559
1804
|
document.addEventListener("keydown", onKey);
|
|
1560
1805
|
return () => document.removeEventListener("keydown", onKey);
|
|
1561
1806
|
}, [onClose]);
|
|
1562
|
-
const
|
|
1807
|
+
const renderDefault = (msg) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1808
|
+
MessageRow,
|
|
1809
|
+
{
|
|
1810
|
+
msg,
|
|
1811
|
+
meId: me?.id ?? null,
|
|
1812
|
+
reactions: true,
|
|
1813
|
+
attachments: true,
|
|
1814
|
+
actions: true,
|
|
1815
|
+
threads: false,
|
|
1816
|
+
quotations: false,
|
|
1817
|
+
editing: editingId === msg.id,
|
|
1818
|
+
onStartEdit: () => setEditingId(msg.id),
|
|
1819
|
+
onCancelEdit: () => setEditingId(null),
|
|
1820
|
+
onSaveEdit: async (body) => {
|
|
1821
|
+
await edit(msg.id, body);
|
|
1822
|
+
setEditingId(null);
|
|
1823
|
+
},
|
|
1824
|
+
onDelete: () => void deleteReply(msg.id)
|
|
1825
|
+
}
|
|
1826
|
+
);
|
|
1827
|
+
const renderOne = renderMessage ? (msg, currentUserId) => renderMessage(msg, currentUserId) : (msg) => renderDefault(msg);
|
|
1563
1828
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1564
1829
|
"aside",
|
|
1565
1830
|
{
|
|
1566
|
-
className:
|
|
1831
|
+
className: `poolse-thread${dragActive ? " is-drag-active" : ""}`,
|
|
1567
1832
|
role: "complementary",
|
|
1568
1833
|
"aria-label": "Message thread",
|
|
1834
|
+
onDragEnter,
|
|
1835
|
+
onDragOver,
|
|
1836
|
+
onDragLeave,
|
|
1837
|
+
onDrop,
|
|
1569
1838
|
children: [
|
|
1570
1839
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "poolse-thread__header", children: [
|
|
1571
1840
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-thread__title", children: "Thread" }),
|
|
@@ -1594,25 +1863,26 @@ function ThreadView({
|
|
|
1594
1863
|
error.message
|
|
1595
1864
|
] })
|
|
1596
1865
|
] }),
|
|
1597
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1866
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1867
|
+
MessageComposer,
|
|
1868
|
+
{
|
|
1869
|
+
ref: composerRef,
|
|
1870
|
+
onSend: (body, opts) => sendReply({
|
|
1871
|
+
body,
|
|
1872
|
+
...opts?.attachment_ids && opts.attachment_ids.length > 0 ? { attachment_ids: opts.attachment_ids } : {}
|
|
1873
|
+
}),
|
|
1874
|
+
placeholder: "Reply in thread\u2026"
|
|
1875
|
+
}
|
|
1876
|
+
),
|
|
1877
|
+
dragActive && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__drop-overlay", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__drop-overlay-inner", children: [
|
|
1878
|
+
/* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "attachment", size: 40, label: null }),
|
|
1879
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__drop-overlay-title", children: "Drop files to upload" }),
|
|
1880
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__drop-overlay-hint", children: "They'll be sent in one reply" })
|
|
1881
|
+
] }) })
|
|
1598
1882
|
]
|
|
1599
1883
|
}
|
|
1600
1884
|
);
|
|
1601
1885
|
}
|
|
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
1886
|
function TypingIndicator({ typing, labelFor }) {
|
|
1617
1887
|
const ids = Array.from(typing);
|
|
1618
1888
|
const isTyping = ids.length > 0;
|
|
@@ -1656,63 +1926,6 @@ function TypingLabel({ ids, labelFor }) {
|
|
|
1656
1926
|
" people are typing"
|
|
1657
1927
|
] });
|
|
1658
1928
|
}
|
|
1659
|
-
function UploadQueueStrip({ items, onCancel, onDismiss }) {
|
|
1660
|
-
if (items.length === 0) return null;
|
|
1661
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-strip", role: "status", "aria-live": "polite", children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1662
|
-
UploadChip,
|
|
1663
|
-
{
|
|
1664
|
-
item,
|
|
1665
|
-
onCancel: () => onCancel(item.localId),
|
|
1666
|
-
onDismiss: () => onDismiss(item.localId)
|
|
1667
|
-
},
|
|
1668
|
-
item.localId
|
|
1669
|
-
)) });
|
|
1670
|
-
}
|
|
1671
|
-
function UploadChip({
|
|
1672
|
-
item,
|
|
1673
|
-
onCancel,
|
|
1674
|
-
onDismiss
|
|
1675
|
-
}) {
|
|
1676
|
-
const pct = item.byteSize > 0 ? Math.min(100, Math.round(item.loaded / item.byteSize * 100)) : 0;
|
|
1677
|
-
const isError = item.status === "error";
|
|
1678
|
-
const isInFlight = item.status === "pending" || item.status === "uploading";
|
|
1679
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1680
|
-
"div",
|
|
1681
|
-
{
|
|
1682
|
-
className: `poolse-upload-chip poolse-upload-chip--${item.status}`,
|
|
1683
|
-
"data-status": item.status,
|
|
1684
|
-
children: [
|
|
1685
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__icon", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: isError ? "attachment" : "attachment", size: 18, label: null }) }),
|
|
1686
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-upload-chip__body", children: [
|
|
1687
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__filename", title: item.filename, children: item.filename }),
|
|
1688
|
-
isError ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__error", children: item.error?.message ?? "Upload failed" }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1689
|
-
"div",
|
|
1690
|
-
{
|
|
1691
|
-
className: "poolse-upload-chip__bar",
|
|
1692
|
-
role: "progressbar",
|
|
1693
|
-
"aria-valuemin": 0,
|
|
1694
|
-
"aria-valuemax": 100,
|
|
1695
|
-
"aria-valuenow": pct,
|
|
1696
|
-
"aria-label": `Uploading ${item.filename}`,
|
|
1697
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__bar-fill", style: { width: `${pct}%` } })
|
|
1698
|
-
}
|
|
1699
|
-
)
|
|
1700
|
-
] }),
|
|
1701
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1702
|
-
"button",
|
|
1703
|
-
{
|
|
1704
|
-
type: "button",
|
|
1705
|
-
className: "poolse-upload-chip__action",
|
|
1706
|
-
onClick: isInFlight ? onCancel : onDismiss,
|
|
1707
|
-
"aria-label": isInFlight ? `Cancel upload of ${item.filename}` : `Dismiss ${item.filename}`,
|
|
1708
|
-
title: isInFlight ? "Cancel" : "Dismiss",
|
|
1709
|
-
children: "\xD7"
|
|
1710
|
-
}
|
|
1711
|
-
)
|
|
1712
|
-
]
|
|
1713
|
-
}
|
|
1714
|
-
);
|
|
1715
|
-
}
|
|
1716
1929
|
var TRUE = true;
|
|
1717
1930
|
function ConversationView({
|
|
1718
1931
|
conversationId,
|
|
@@ -1875,28 +2088,7 @@ function ConversationView({
|
|
|
1875
2088
|
el.classList.add("poolse-message-row--highlight");
|
|
1876
2089
|
setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
|
|
1877
2090
|
};
|
|
1878
|
-
const
|
|
1879
|
-
const visibleUploads = uploadQueue.filter(
|
|
1880
|
-
(it) => it.status === "pending" || it.status === "uploading" || it.status === "error"
|
|
1881
|
-
);
|
|
1882
|
-
const onPickFiles = async (files) => {
|
|
1883
|
-
if (files.length === 0) return;
|
|
1884
|
-
try {
|
|
1885
|
-
const atts = await uploadAll(
|
|
1886
|
-
files.map((f) => ({
|
|
1887
|
-
body: f,
|
|
1888
|
-
contentType: f.type || "application/octet-stream",
|
|
1889
|
-
byteSize: f.size,
|
|
1890
|
-
filename: f.name
|
|
1891
|
-
}))
|
|
1892
|
-
);
|
|
1893
|
-
await send({ body: "", attachment_ids: atts.map((a) => a.id) });
|
|
1894
|
-
for (const it of uploadQueue) {
|
|
1895
|
-
if (it.status === "ready") removeUpload(it.localId);
|
|
1896
|
-
}
|
|
1897
|
-
} catch {
|
|
1898
|
-
}
|
|
1899
|
-
};
|
|
2091
|
+
const composerRef = react.useRef(null);
|
|
1900
2092
|
const [dragActive, setDragActive] = react.useState(false);
|
|
1901
2093
|
const dragDepthRef = react.useRef(0);
|
|
1902
2094
|
const isFileDrag = (e) => Array.from(e.dataTransfer?.types ?? []).includes("Files");
|
|
@@ -1923,12 +2115,13 @@ function ConversationView({
|
|
|
1923
2115
|
dragDepthRef.current = 0;
|
|
1924
2116
|
setDragActive(false);
|
|
1925
2117
|
const files = Array.from(e.dataTransfer?.files ?? []);
|
|
1926
|
-
if (files.length > 0)
|
|
2118
|
+
if (files.length > 0) composerRef.current?.addFiles(files);
|
|
1927
2119
|
};
|
|
1928
2120
|
const onSendBody = async (body, opts) => {
|
|
1929
2121
|
await send({
|
|
1930
2122
|
body,
|
|
1931
|
-
...opts?.quoted_message_id ? { quoted_message_id: opts.quoted_message_id } : {}
|
|
2123
|
+
...opts?.quoted_message_id ? { quoted_message_id: opts.quoted_message_id } : {},
|
|
2124
|
+
...opts?.attachment_ids && opts.attachment_ids.length > 0 ? { attachment_ids: opts.attachment_ids } : {}
|
|
1932
2125
|
});
|
|
1933
2126
|
setReplyingTo(null);
|
|
1934
2127
|
};
|
|
@@ -1939,17 +2132,21 @@ function ConversationView({
|
|
|
1939
2132
|
const Composer = mentions && members.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1940
2133
|
MentionInput,
|
|
1941
2134
|
{
|
|
2135
|
+
ref: composerRef,
|
|
1942
2136
|
conversationId,
|
|
1943
2137
|
onSend: onSendWithMentions,
|
|
1944
2138
|
onTyping: signalTyping,
|
|
2139
|
+
attachments,
|
|
1945
2140
|
...labelFor ? { labelFor } : {},
|
|
1946
2141
|
...quotations ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
1947
2142
|
}
|
|
1948
2143
|
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1949
2144
|
MessageComposer,
|
|
1950
2145
|
{
|
|
2146
|
+
ref: composerRef,
|
|
1951
2147
|
onSend: onSendBody,
|
|
1952
2148
|
onTyping: signalTyping,
|
|
2149
|
+
attachments,
|
|
1953
2150
|
...labelFor ? { labelFor } : {},
|
|
1954
2151
|
...quotations ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
1955
2152
|
}
|
|
@@ -2070,18 +2267,7 @@ function ConversationView({
|
|
|
2070
2267
|
}
|
|
2071
2268
|
),
|
|
2072
2269
|
/* @__PURE__ */ jsxRuntime.jsx(TypingIndicator, { typing, ...labelFor ? { labelFor } : {} }),
|
|
2073
|
-
|
|
2074
|
-
UploadQueueStrip,
|
|
2075
|
-
{
|
|
2076
|
-
items: visibleUploads,
|
|
2077
|
-
onCancel: cancelUpload,
|
|
2078
|
-
onDismiss: removeUpload
|
|
2079
|
-
}
|
|
2080
|
-
),
|
|
2081
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__composer-row", children: [
|
|
2082
|
-
attachments && /* @__PURE__ */ jsxRuntime.jsx(AttachmentPickerButton, { onPick: onPickFiles, disabled: uploading }),
|
|
2083
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__composer-flex", children: Composer })
|
|
2084
|
-
] }),
|
|
2270
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__composer-row", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__composer-flex", children: Composer }) }),
|
|
2085
2271
|
dragActive && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__drop-overlay", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__drop-overlay-inner", children: [
|
|
2086
2272
|
/* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "attachment", size: 40, label: null }),
|
|
2087
2273
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__drop-overlay-title", children: "Drop files to upload" }),
|
|
@@ -2100,40 +2286,6 @@ function ConversationView({
|
|
|
2100
2286
|
) })
|
|
2101
2287
|
] });
|
|
2102
2288
|
}
|
|
2103
|
-
function AttachmentPickerButton({
|
|
2104
|
-
onPick,
|
|
2105
|
-
disabled
|
|
2106
|
-
}) {
|
|
2107
|
-
const inputRef = react.useRef(null);
|
|
2108
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2109
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2110
|
-
"input",
|
|
2111
|
-
{
|
|
2112
|
-
ref: inputRef,
|
|
2113
|
-
type: "file",
|
|
2114
|
-
multiple: true,
|
|
2115
|
-
className: "poolse-attach-input",
|
|
2116
|
-
onChange: (e) => {
|
|
2117
|
-
const files = Array.from(e.target.files ?? []);
|
|
2118
|
-
if (files.length > 0) onPick(files);
|
|
2119
|
-
e.target.value = "";
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2122
|
-
),
|
|
2123
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2124
|
-
"button",
|
|
2125
|
-
{
|
|
2126
|
-
type: "button",
|
|
2127
|
-
className: "poolse-attach-btn",
|
|
2128
|
-
onClick: () => inputRef.current?.click(),
|
|
2129
|
-
disabled,
|
|
2130
|
-
"aria-label": "Attach files",
|
|
2131
|
-
title: "Attach files",
|
|
2132
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "attachment", size: 20, label: null })
|
|
2133
|
-
}
|
|
2134
|
-
)
|
|
2135
|
-
] });
|
|
2136
|
-
}
|
|
2137
2289
|
function ConversationList({
|
|
2138
2290
|
selectedId,
|
|
2139
2291
|
onSelect,
|