@poolse/react-ui 1.0.4 → 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 +547 -410
- 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 +550 -413
- package/dist/index.js.map +1 -1
- package/dist/styles.css +44 -3
- 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,
|
|
@@ -1551,6 +1758,35 @@ function ThreadView({
|
|
|
1551
1758
|
const listRef = react.useRef(null);
|
|
1552
1759
|
const closeBtnRef = react.useRef(null);
|
|
1553
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
|
+
};
|
|
1554
1790
|
react.useEffect(() => {
|
|
1555
1791
|
const tail = replies[replies.length - 1];
|
|
1556
1792
|
if (!tail) return;
|
|
@@ -1592,9 +1828,13 @@ function ThreadView({
|
|
|
1592
1828
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1593
1829
|
"aside",
|
|
1594
1830
|
{
|
|
1595
|
-
className:
|
|
1831
|
+
className: `poolse-thread${dragActive ? " is-drag-active" : ""}`,
|
|
1596
1832
|
role: "complementary",
|
|
1597
1833
|
"aria-label": "Message thread",
|
|
1834
|
+
onDragEnter,
|
|
1835
|
+
onDragOver,
|
|
1836
|
+
onDragLeave,
|
|
1837
|
+
onDrop,
|
|
1598
1838
|
children: [
|
|
1599
1839
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "poolse-thread__header", children: [
|
|
1600
1840
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-thread__title", children: "Thread" }),
|
|
@@ -1623,7 +1863,22 @@ function ThreadView({
|
|
|
1623
1863
|
error.message
|
|
1624
1864
|
] })
|
|
1625
1865
|
] }),
|
|
1626
|
-
/* @__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
|
+
] }) })
|
|
1627
1882
|
]
|
|
1628
1883
|
}
|
|
1629
1884
|
);
|
|
@@ -1671,63 +1926,6 @@ function TypingLabel({ ids, labelFor }) {
|
|
|
1671
1926
|
" people are typing"
|
|
1672
1927
|
] });
|
|
1673
1928
|
}
|
|
1674
|
-
function UploadQueueStrip({ items, onCancel, onDismiss }) {
|
|
1675
|
-
if (items.length === 0) return null;
|
|
1676
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-strip", role: "status", "aria-live": "polite", children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1677
|
-
UploadChip,
|
|
1678
|
-
{
|
|
1679
|
-
item,
|
|
1680
|
-
onCancel: () => onCancel(item.localId),
|
|
1681
|
-
onDismiss: () => onDismiss(item.localId)
|
|
1682
|
-
},
|
|
1683
|
-
item.localId
|
|
1684
|
-
)) });
|
|
1685
|
-
}
|
|
1686
|
-
function UploadChip({
|
|
1687
|
-
item,
|
|
1688
|
-
onCancel,
|
|
1689
|
-
onDismiss
|
|
1690
|
-
}) {
|
|
1691
|
-
const pct = item.byteSize > 0 ? Math.min(100, Math.round(item.loaded / item.byteSize * 100)) : 0;
|
|
1692
|
-
const isError = item.status === "error";
|
|
1693
|
-
const isInFlight = item.status === "pending" || item.status === "uploading";
|
|
1694
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1695
|
-
"div",
|
|
1696
|
-
{
|
|
1697
|
-
className: `poolse-upload-chip poolse-upload-chip--${item.status}`,
|
|
1698
|
-
"data-status": item.status,
|
|
1699
|
-
children: [
|
|
1700
|
-
/* @__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 }) }),
|
|
1701
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-upload-chip__body", children: [
|
|
1702
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__filename", title: item.filename, children: item.filename }),
|
|
1703
|
-
isError ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__error", children: item.error?.message ?? "Upload failed" }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1704
|
-
"div",
|
|
1705
|
-
{
|
|
1706
|
-
className: "poolse-upload-chip__bar",
|
|
1707
|
-
role: "progressbar",
|
|
1708
|
-
"aria-valuemin": 0,
|
|
1709
|
-
"aria-valuemax": 100,
|
|
1710
|
-
"aria-valuenow": pct,
|
|
1711
|
-
"aria-label": `Uploading ${item.filename}`,
|
|
1712
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__bar-fill", style: { width: `${pct}%` } })
|
|
1713
|
-
}
|
|
1714
|
-
)
|
|
1715
|
-
] }),
|
|
1716
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1717
|
-
"button",
|
|
1718
|
-
{
|
|
1719
|
-
type: "button",
|
|
1720
|
-
className: "poolse-upload-chip__action",
|
|
1721
|
-
onClick: isInFlight ? onCancel : onDismiss,
|
|
1722
|
-
"aria-label": isInFlight ? `Cancel upload of ${item.filename}` : `Dismiss ${item.filename}`,
|
|
1723
|
-
title: isInFlight ? "Cancel" : "Dismiss",
|
|
1724
|
-
children: "\xD7"
|
|
1725
|
-
}
|
|
1726
|
-
)
|
|
1727
|
-
]
|
|
1728
|
-
}
|
|
1729
|
-
);
|
|
1730
|
-
}
|
|
1731
1929
|
var TRUE = true;
|
|
1732
1930
|
function ConversationView({
|
|
1733
1931
|
conversationId,
|
|
@@ -1890,28 +2088,7 @@ function ConversationView({
|
|
|
1890
2088
|
el.classList.add("poolse-message-row--highlight");
|
|
1891
2089
|
setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
|
|
1892
2090
|
};
|
|
1893
|
-
const
|
|
1894
|
-
const visibleUploads = uploadQueue.filter(
|
|
1895
|
-
(it) => it.status === "pending" || it.status === "uploading" || it.status === "error"
|
|
1896
|
-
);
|
|
1897
|
-
const onPickFiles = async (files) => {
|
|
1898
|
-
if (files.length === 0) return;
|
|
1899
|
-
try {
|
|
1900
|
-
const atts = await uploadAll(
|
|
1901
|
-
files.map((f) => ({
|
|
1902
|
-
body: f,
|
|
1903
|
-
contentType: f.type || "application/octet-stream",
|
|
1904
|
-
byteSize: f.size,
|
|
1905
|
-
filename: f.name
|
|
1906
|
-
}))
|
|
1907
|
-
);
|
|
1908
|
-
await send({ body: "", attachment_ids: atts.map((a) => a.id) });
|
|
1909
|
-
for (const it of uploadQueue) {
|
|
1910
|
-
if (it.status === "ready") removeUpload(it.localId);
|
|
1911
|
-
}
|
|
1912
|
-
} catch {
|
|
1913
|
-
}
|
|
1914
|
-
};
|
|
2091
|
+
const composerRef = react.useRef(null);
|
|
1915
2092
|
const [dragActive, setDragActive] = react.useState(false);
|
|
1916
2093
|
const dragDepthRef = react.useRef(0);
|
|
1917
2094
|
const isFileDrag = (e) => Array.from(e.dataTransfer?.types ?? []).includes("Files");
|
|
@@ -1938,12 +2115,13 @@ function ConversationView({
|
|
|
1938
2115
|
dragDepthRef.current = 0;
|
|
1939
2116
|
setDragActive(false);
|
|
1940
2117
|
const files = Array.from(e.dataTransfer?.files ?? []);
|
|
1941
|
-
if (files.length > 0)
|
|
2118
|
+
if (files.length > 0) composerRef.current?.addFiles(files);
|
|
1942
2119
|
};
|
|
1943
2120
|
const onSendBody = async (body, opts) => {
|
|
1944
2121
|
await send({
|
|
1945
2122
|
body,
|
|
1946
|
-
...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 } : {}
|
|
1947
2125
|
});
|
|
1948
2126
|
setReplyingTo(null);
|
|
1949
2127
|
};
|
|
@@ -1954,17 +2132,21 @@ function ConversationView({
|
|
|
1954
2132
|
const Composer = mentions && members.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1955
2133
|
MentionInput,
|
|
1956
2134
|
{
|
|
2135
|
+
ref: composerRef,
|
|
1957
2136
|
conversationId,
|
|
1958
2137
|
onSend: onSendWithMentions,
|
|
1959
2138
|
onTyping: signalTyping,
|
|
2139
|
+
attachments,
|
|
1960
2140
|
...labelFor ? { labelFor } : {},
|
|
1961
2141
|
...quotations ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
1962
2142
|
}
|
|
1963
2143
|
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1964
2144
|
MessageComposer,
|
|
1965
2145
|
{
|
|
2146
|
+
ref: composerRef,
|
|
1966
2147
|
onSend: onSendBody,
|
|
1967
2148
|
onTyping: signalTyping,
|
|
2149
|
+
attachments,
|
|
1968
2150
|
...labelFor ? { labelFor } : {},
|
|
1969
2151
|
...quotations ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
1970
2152
|
}
|
|
@@ -2085,18 +2267,7 @@ function ConversationView({
|
|
|
2085
2267
|
}
|
|
2086
2268
|
),
|
|
2087
2269
|
/* @__PURE__ */ jsxRuntime.jsx(TypingIndicator, { typing, ...labelFor ? { labelFor } : {} }),
|
|
2088
|
-
|
|
2089
|
-
UploadQueueStrip,
|
|
2090
|
-
{
|
|
2091
|
-
items: visibleUploads,
|
|
2092
|
-
onCancel: cancelUpload,
|
|
2093
|
-
onDismiss: removeUpload
|
|
2094
|
-
}
|
|
2095
|
-
),
|
|
2096
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__composer-row", children: [
|
|
2097
|
-
attachments && /* @__PURE__ */ jsxRuntime.jsx(AttachmentPickerButton, { onPick: onPickFiles, disabled: uploading }),
|
|
2098
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__composer-flex", children: Composer })
|
|
2099
|
-
] }),
|
|
2270
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__composer-row", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__composer-flex", children: Composer }) }),
|
|
2100
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: [
|
|
2101
2272
|
/* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "attachment", size: 40, label: null }),
|
|
2102
2273
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__drop-overlay-title", children: "Drop files to upload" }),
|
|
@@ -2115,40 +2286,6 @@ function ConversationView({
|
|
|
2115
2286
|
) })
|
|
2116
2287
|
] });
|
|
2117
2288
|
}
|
|
2118
|
-
function AttachmentPickerButton({
|
|
2119
|
-
onPick,
|
|
2120
|
-
disabled
|
|
2121
|
-
}) {
|
|
2122
|
-
const inputRef = react.useRef(null);
|
|
2123
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2124
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2125
|
-
"input",
|
|
2126
|
-
{
|
|
2127
|
-
ref: inputRef,
|
|
2128
|
-
type: "file",
|
|
2129
|
-
multiple: true,
|
|
2130
|
-
className: "poolse-attach-input",
|
|
2131
|
-
onChange: (e) => {
|
|
2132
|
-
const files = Array.from(e.target.files ?? []);
|
|
2133
|
-
if (files.length > 0) onPick(files);
|
|
2134
|
-
e.target.value = "";
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
),
|
|
2138
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2139
|
-
"button",
|
|
2140
|
-
{
|
|
2141
|
-
type: "button",
|
|
2142
|
-
className: "poolse-attach-btn",
|
|
2143
|
-
onClick: () => inputRef.current?.click(),
|
|
2144
|
-
disabled,
|
|
2145
|
-
"aria-label": "Attach files",
|
|
2146
|
-
title: "Attach files",
|
|
2147
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "attachment", size: 20, label: null })
|
|
2148
|
-
}
|
|
2149
|
-
)
|
|
2150
|
-
] });
|
|
2151
|
-
}
|
|
2152
2289
|
function ConversationList({
|
|
2153
2290
|
selectedId,
|
|
2154
2291
|
onSelect,
|