@poolse/react-ui 3.8.0 → 3.9.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 +16 -0
- package/README.md +39 -1
- package/dist/index.cjs +593 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +133 -3
- package/dist/index.d.ts +133 -3
- package/dist/index.js +589 -7
- package/dist/index.js.map +1 -1
- package/dist/styles.css +464 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { forwardRef, useState, useId, useReducer, useRef, useEffect, useImperativeHandle, useCallback, useMemo, createContext, Fragment as Fragment$1, useLayoutEffect, useContext } from 'react';
|
|
3
3
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { safeUuid, MessageQueuedError } from '@poolse/sdk';
|
|
5
|
-
import { usePoolse, useMembers, useUser, useMe, useConversations, useAttachmentUpload, filterConversations, useConversation, usePresence, useUserPresence, useMessages, useTyping, useMessageStreams, useRealtimeStatus, isMessageVisibleTo, receiptsOf, computeGroupPosition, sameDay, formatDayLabel, canEditOwnMessage, useLiveCall, callLogDisplayFor, useThread, usePresenceMany, formatCallLogPreview, ApiError, useReactions, useAttachmentUrl } from '@poolse/react';
|
|
5
|
+
import { usePoolse, useMembers, useUser, useMe, useConversations, useAttachmentUpload, filterConversations, useConversation, usePresence, useUserPresence, useMessages, useTyping, useMessageStreams, useRealtimeStatus, isMessageVisibleTo, receiptsOf, computeGroupPosition, sameDay, formatDayLabel, canEditOwnMessage, useLiveCall, recordingNoticeDisplayFor, callLogDisplayFor, useThread, usePresenceMany, formatCallLogPreview, formatRecordingNoticePreview, ApiError, useReactions, useAttachmentUrl, captureLabel, useRecording, captureErrorMessage, useLiveTranscript, groupTranscript, formatCallDuration, useTranscript, findInText } from '@poolse/react';
|
|
6
6
|
import ReactMarkdown from 'react-markdown';
|
|
7
7
|
import remarkGfm from 'remark-gfm';
|
|
8
8
|
import { resolveTheme, tokensToCssVariables } from '@poolse/theme';
|
|
@@ -605,7 +605,7 @@ function CallControlButton({
|
|
|
605
605
|
label,
|
|
606
606
|
onClick,
|
|
607
607
|
active = false,
|
|
608
|
-
highlight = false,
|
|
608
|
+
highlight: highlight2 = false,
|
|
609
609
|
tone = "neutral",
|
|
610
610
|
large = false,
|
|
611
611
|
disabled = false,
|
|
@@ -616,7 +616,7 @@ function CallControlButton({
|
|
|
616
616
|
"callbtn",
|
|
617
617
|
tone !== "neutral" ? `callbtn--${tone}` : "",
|
|
618
618
|
active ? "callbtn--active" : "",
|
|
619
|
-
|
|
619
|
+
highlight2 ? "callbtn--highlight" : "",
|
|
620
620
|
large ? "callbtn--large" : ""
|
|
621
621
|
].filter(Boolean).join(" ");
|
|
622
622
|
return /* @__PURE__ */ jsxs("span", { className: "callbtn__slot", children: [
|
|
@@ -632,7 +632,7 @@ function CallControlButton({
|
|
|
632
632
|
className: classes,
|
|
633
633
|
onClick,
|
|
634
634
|
disabled,
|
|
635
|
-
"aria-pressed": tone === "neutral" ? active ||
|
|
635
|
+
"aria-pressed": tone === "neutral" ? active || highlight2 : void 0,
|
|
636
636
|
"aria-label": label,
|
|
637
637
|
title: label,
|
|
638
638
|
children: /* @__PURE__ */ jsx(PoolseIcon, { name: icon, size: large ? 26 : 22, label: null })
|
|
@@ -2282,6 +2282,189 @@ function formatTime(iso) {
|
|
|
2282
2282
|
if (Number.isNaN(d.getTime())) return "";
|
|
2283
2283
|
return d.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
|
|
2284
2284
|
}
|
|
2285
|
+
function RecordingBanner({
|
|
2286
|
+
recording,
|
|
2287
|
+
transcribing = false,
|
|
2288
|
+
mode,
|
|
2289
|
+
consentRequired = false,
|
|
2290
|
+
myConsent,
|
|
2291
|
+
onStop,
|
|
2292
|
+
onChangeConsent,
|
|
2293
|
+
pending = false,
|
|
2294
|
+
className
|
|
2295
|
+
}) {
|
|
2296
|
+
const label = captureLabel(recording, transcribing, mode);
|
|
2297
|
+
if (!label) return null;
|
|
2298
|
+
const listenOnly = consentRequired && myConsent === "declined";
|
|
2299
|
+
const meta = listenOnly ? "You declined \u2014 you are listen-only" : consentRequired ? "Only people who agreed are captured" : "Everyone in the call is told";
|
|
2300
|
+
return /* @__PURE__ */ jsxs(
|
|
2301
|
+
"div",
|
|
2302
|
+
{
|
|
2303
|
+
className: ["poolse-rec-banner", className].filter(Boolean).join(" "),
|
|
2304
|
+
role: "status",
|
|
2305
|
+
"aria-label": `${label}. ${meta}`,
|
|
2306
|
+
children: [
|
|
2307
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-rec-dot", "aria-hidden": "true" }),
|
|
2308
|
+
/* @__PURE__ */ jsxs("span", { className: "poolse-rec-banner__text", children: [
|
|
2309
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-rec-banner__title", children: label }),
|
|
2310
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-rec-banner__meta", children: meta })
|
|
2311
|
+
] }),
|
|
2312
|
+
listenOnly && onChangeConsent && /* @__PURE__ */ jsx(
|
|
2313
|
+
"button",
|
|
2314
|
+
{
|
|
2315
|
+
type: "button",
|
|
2316
|
+
className: "poolse-rec-banner__btn",
|
|
2317
|
+
onClick: onChangeConsent,
|
|
2318
|
+
disabled: pending,
|
|
2319
|
+
children: "Change"
|
|
2320
|
+
}
|
|
2321
|
+
),
|
|
2322
|
+
recording && onStop && /* @__PURE__ */ jsx(
|
|
2323
|
+
"button",
|
|
2324
|
+
{
|
|
2325
|
+
type: "button",
|
|
2326
|
+
className: "poolse-rec-banner__btn",
|
|
2327
|
+
onClick: onStop,
|
|
2328
|
+
disabled: pending,
|
|
2329
|
+
children: "Stop"
|
|
2330
|
+
}
|
|
2331
|
+
)
|
|
2332
|
+
]
|
|
2333
|
+
}
|
|
2334
|
+
);
|
|
2335
|
+
}
|
|
2336
|
+
function RecordingIndicator({
|
|
2337
|
+
recording,
|
|
2338
|
+
transcribing = false,
|
|
2339
|
+
mode,
|
|
2340
|
+
className
|
|
2341
|
+
}) {
|
|
2342
|
+
const label = captureLabel(recording, transcribing, mode);
|
|
2343
|
+
if (!label) return null;
|
|
2344
|
+
return /* @__PURE__ */ jsxs(
|
|
2345
|
+
"span",
|
|
2346
|
+
{
|
|
2347
|
+
className: ["poolse-rec-indicator", className].filter(Boolean).join(" "),
|
|
2348
|
+
role: "img",
|
|
2349
|
+
"aria-label": label,
|
|
2350
|
+
title: label,
|
|
2351
|
+
children: [
|
|
2352
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-rec-dot", "aria-hidden": "true" }),
|
|
2353
|
+
recording ? "REC" : "Transcript"
|
|
2354
|
+
]
|
|
2355
|
+
}
|
|
2356
|
+
);
|
|
2357
|
+
}
|
|
2358
|
+
function ConsentPrompt({
|
|
2359
|
+
recording,
|
|
2360
|
+
transcribing = false,
|
|
2361
|
+
mode,
|
|
2362
|
+
startedByName,
|
|
2363
|
+
onAnswer,
|
|
2364
|
+
onAccepted,
|
|
2365
|
+
onDeclined,
|
|
2366
|
+
pending = false,
|
|
2367
|
+
error,
|
|
2368
|
+
overlay = true,
|
|
2369
|
+
className
|
|
2370
|
+
}) {
|
|
2371
|
+
const [busy, setBusy] = useState(false);
|
|
2372
|
+
const [failed, setFailed] = useState(false);
|
|
2373
|
+
const agree = useRef(null);
|
|
2374
|
+
const id = useId();
|
|
2375
|
+
useEffect(() => agree.current?.focus(), []);
|
|
2376
|
+
const what = recording && transcribing ? "recorded and transcribed" : recording ? mode === "audio" ? "recorded (audio)" : "recorded" : "transcribed";
|
|
2377
|
+
const answer = async (decision) => {
|
|
2378
|
+
setBusy(true);
|
|
2379
|
+
setFailed(false);
|
|
2380
|
+
try {
|
|
2381
|
+
const ok = await onAnswer(decision);
|
|
2382
|
+
if (ok === false) {
|
|
2383
|
+
setFailed(true);
|
|
2384
|
+
return;
|
|
2385
|
+
}
|
|
2386
|
+
if (decision === "accepted") onAccepted?.();
|
|
2387
|
+
else onDeclined?.();
|
|
2388
|
+
} catch {
|
|
2389
|
+
setFailed(true);
|
|
2390
|
+
} finally {
|
|
2391
|
+
setBusy(false);
|
|
2392
|
+
}
|
|
2393
|
+
};
|
|
2394
|
+
const disabled = busy || pending;
|
|
2395
|
+
const shownError = error ?? (failed ? "That didn\u2019t go through. Try again." : null);
|
|
2396
|
+
const card = /* @__PURE__ */ jsxs(
|
|
2397
|
+
"div",
|
|
2398
|
+
{
|
|
2399
|
+
className: ["poolse-consent", className].filter(Boolean).join(" "),
|
|
2400
|
+
role: "alertdialog",
|
|
2401
|
+
"aria-modal": overlay ? true : void 0,
|
|
2402
|
+
"aria-labelledby": `${id}-title`,
|
|
2403
|
+
"aria-describedby": `${id}-body`,
|
|
2404
|
+
children: [
|
|
2405
|
+
/* @__PURE__ */ jsxs("div", { className: "poolse-consent__head", children: [
|
|
2406
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-rec-dot", "aria-hidden": "true" }),
|
|
2407
|
+
/* @__PURE__ */ jsxs("h2", { id: `${id}-title`, className: "poolse-consent__title", children: [
|
|
2408
|
+
"This call is being ",
|
|
2409
|
+
what
|
|
2410
|
+
] })
|
|
2411
|
+
] }),
|
|
2412
|
+
/* @__PURE__ */ jsxs("p", { id: `${id}-body`, className: "poolse-consent__body", children: [
|
|
2413
|
+
startedByName ? `${startedByName} started it. ` : "",
|
|
2414
|
+
"Your microphone and camera stay off until you agree. You can still hear and see everyone."
|
|
2415
|
+
] }),
|
|
2416
|
+
/* @__PURE__ */ jsxs("div", { className: "poolse-consent__actions", children: [
|
|
2417
|
+
/* @__PURE__ */ jsx(
|
|
2418
|
+
"button",
|
|
2419
|
+
{
|
|
2420
|
+
type: "button",
|
|
2421
|
+
className: "poolse-consent__btn",
|
|
2422
|
+
onClick: () => void answer("declined"),
|
|
2423
|
+
disabled,
|
|
2424
|
+
children: "Stay listen-only"
|
|
2425
|
+
}
|
|
2426
|
+
),
|
|
2427
|
+
/* @__PURE__ */ jsx(
|
|
2428
|
+
"button",
|
|
2429
|
+
{
|
|
2430
|
+
ref: agree,
|
|
2431
|
+
type: "button",
|
|
2432
|
+
className: "poolse-consent__btn poolse-consent__btn--primary",
|
|
2433
|
+
onClick: () => void answer("accepted"),
|
|
2434
|
+
disabled,
|
|
2435
|
+
children: "Agree"
|
|
2436
|
+
}
|
|
2437
|
+
)
|
|
2438
|
+
] }),
|
|
2439
|
+
shownError && /* @__PURE__ */ jsx("p", { className: "poolse-consent__error", role: "alert", children: shownError })
|
|
2440
|
+
]
|
|
2441
|
+
}
|
|
2442
|
+
);
|
|
2443
|
+
return overlay ? /* @__PURE__ */ jsx("div", { className: "poolse-consent-scrim", children: card }) : card;
|
|
2444
|
+
}
|
|
2445
|
+
function RecordingNoticeRow({ msg, meId, nameFor }) {
|
|
2446
|
+
const display = recordingNoticeDisplayFor(msg, meId, nameFor);
|
|
2447
|
+
if (!display) return null;
|
|
2448
|
+
const time = formatTime2(msg.inserted_at);
|
|
2449
|
+
const label = [display.title, display.detail, time].filter(Boolean).join(", ");
|
|
2450
|
+
return /* @__PURE__ */ jsx("div", { className: "poolse-call-log poolse-rec-notice", role: "note", "aria-label": label, children: /* @__PURE__ */ jsxs("span", { className: "poolse-call-log__chip", children: [
|
|
2451
|
+
/* @__PURE__ */ jsx(
|
|
2452
|
+
"span",
|
|
2453
|
+
{
|
|
2454
|
+
className: `poolse-rec-dot${display.event === "stopped" ? " poolse-rec-dot--off" : ""}`,
|
|
2455
|
+
"aria-hidden": "true"
|
|
2456
|
+
}
|
|
2457
|
+
),
|
|
2458
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-call-log__title", children: display.title }),
|
|
2459
|
+
display.detail && /* @__PURE__ */ jsx("span", { className: "poolse-call-log__detail", children: display.detail }),
|
|
2460
|
+
time && /* @__PURE__ */ jsx("span", { className: "poolse-call-log__time", children: time })
|
|
2461
|
+
] }) });
|
|
2462
|
+
}
|
|
2463
|
+
function formatTime2(iso) {
|
|
2464
|
+
const d = new Date(iso);
|
|
2465
|
+
if (Number.isNaN(d.getTime())) return "";
|
|
2466
|
+
return d.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
|
|
2467
|
+
}
|
|
2285
2468
|
function AttachmentPreview({ attachment, onClick }) {
|
|
2286
2469
|
const isFullRow = "content_type" in attachment;
|
|
2287
2470
|
const { url, loading, error } = useAttachmentUrl(attachment.id);
|
|
@@ -3705,6 +3888,16 @@ function FlatBody({
|
|
|
3705
3888
|
);
|
|
3706
3889
|
}
|
|
3707
3890
|
function MessageRow(props) {
|
|
3891
|
+
if (recordingNoticeDisplayFor(props.msg, props.meId)) {
|
|
3892
|
+
return /* @__PURE__ */ jsx(
|
|
3893
|
+
RecordingNoticeRow,
|
|
3894
|
+
{
|
|
3895
|
+
msg: props.msg,
|
|
3896
|
+
meId: props.meId,
|
|
3897
|
+
...props.nameForUserId ? { nameFor: props.nameForUserId } : {}
|
|
3898
|
+
}
|
|
3899
|
+
);
|
|
3900
|
+
}
|
|
3708
3901
|
const callLog = callLogDisplayFor(props.msg, props.meId);
|
|
3709
3902
|
if (callLog !== void 0) {
|
|
3710
3903
|
return callLog ? /* @__PURE__ */ jsx(
|
|
@@ -4276,6 +4469,14 @@ function ConversationView({
|
|
|
4276
4469
|
const membersOn = mentions || readReceipts || wantsMemberCount;
|
|
4277
4470
|
const { members, loading: membersLoading } = useMembers(membersOn ? conversationId : "");
|
|
4278
4471
|
const chat = usePoolse();
|
|
4472
|
+
const nameForUserId = useCallback(
|
|
4473
|
+
(userId) => {
|
|
4474
|
+
const ext = members.find((m) => m.user_id === userId)?.external_id;
|
|
4475
|
+
if (!ext) return null;
|
|
4476
|
+
return chat.users.peek(ext)?.displayName ?? labelFor?.(ext) ?? null;
|
|
4477
|
+
},
|
|
4478
|
+
[members, chat, labelFor]
|
|
4479
|
+
);
|
|
4279
4480
|
const isGroupChat = members.length > 2;
|
|
4280
4481
|
const showSenderLabelsResolved = senderLabels === "always" || senderLabels === "auto" && isGroupChat;
|
|
4281
4482
|
const showAvatarsResolved = showAvatars ?? (layout === "list" ? true : layout === "compact" ? false : avatars === "always" || avatars === "auto" && isGroupChat);
|
|
@@ -4945,6 +5146,7 @@ function ConversationView({
|
|
|
4945
5146
|
onDiscardSend: () => discardSend(msg.id)
|
|
4946
5147
|
} : {},
|
|
4947
5148
|
...onCallBack ? { onCallBack } : {},
|
|
5149
|
+
nameForUserId,
|
|
4948
5150
|
...layoutProps,
|
|
4949
5151
|
mentionsMe: mentionsViewer(msg, me?.id ?? null)
|
|
4950
5152
|
}
|
|
@@ -5344,7 +5546,7 @@ function DefaultRow({
|
|
|
5344
5546
|
const avatarUrl = isDirect ? otherExtId ? avatarFor?.(otherExtId) ?? other?.avatarUrl ?? null : conv.avatar_url ?? null : conv.avatar_url ?? null;
|
|
5345
5547
|
const time = conv.last_message_at ? formatRelative(conv.last_message_at) : "";
|
|
5346
5548
|
const hasUnread = unread > 0;
|
|
5347
|
-
const preview = formatCallLogPreview(conv.last_message_preview, meId) ?? conv.last_message_preview ?? (conv.last_sequence > 0 ? `${conv.last_sequence} message${conv.last_sequence === 1 ? "" : "s"}` : "No messages yet");
|
|
5549
|
+
const preview = formatCallLogPreview(conv.last_message_preview, meId) ?? formatRecordingNoticePreview(conv.last_message_preview, meId) ?? conv.last_message_preview ?? (conv.last_sequence > 0 ? `${conv.last_sequence} message${conv.last_sequence === 1 ? "" : "s"}` : "No messages yet");
|
|
5348
5550
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5349
5551
|
/* @__PURE__ */ jsx(
|
|
5350
5552
|
Avatar,
|
|
@@ -5910,8 +6112,24 @@ function RoomJoinBar({ room, allowStart = true }) {
|
|
|
5910
6112
|
] })
|
|
5911
6113
|
] });
|
|
5912
6114
|
}
|
|
5913
|
-
function RoomStage({
|
|
6115
|
+
function RoomStage({
|
|
6116
|
+
room,
|
|
6117
|
+
title,
|
|
6118
|
+
labelFor,
|
|
6119
|
+
className,
|
|
6120
|
+
capture = true,
|
|
6121
|
+
allowRecord = false
|
|
6122
|
+
}) {
|
|
5914
6123
|
const media = room.media;
|
|
6124
|
+
const live = room.live;
|
|
6125
|
+
const rec = useRecording(
|
|
6126
|
+
capture || allowRecord ? live?.id ?? null : null,
|
|
6127
|
+
live?.conversation_id ?? null,
|
|
6128
|
+
live
|
|
6129
|
+
);
|
|
6130
|
+
const [consentDismissed, setConsentDismissed] = useState(false);
|
|
6131
|
+
const transcribing = !!rec.transcription?.active;
|
|
6132
|
+
const starter = rec.recording?.started_by_user_id;
|
|
5915
6133
|
const stage = useRef(null);
|
|
5916
6134
|
const fullscreen = useFullscreen(stage);
|
|
5917
6135
|
const [menu, setMenu] = useState(null);
|
|
@@ -5940,6 +6158,15 @@ function RoomStage({ room, title, labelFor, className }) {
|
|
|
5940
6158
|
/* @__PURE__ */ jsx("span", { className: "poolse-room__dot", "aria-hidden": "true" }),
|
|
5941
6159
|
elapsed
|
|
5942
6160
|
] }),
|
|
6161
|
+
capture && /* @__PURE__ */ jsx(
|
|
6162
|
+
RecordingIndicator,
|
|
6163
|
+
{
|
|
6164
|
+
recording: rec.active,
|
|
6165
|
+
transcribing,
|
|
6166
|
+
mode: rec.recording?.mode ?? null,
|
|
6167
|
+
className: "poolse-room__chip"
|
|
6168
|
+
}
|
|
6169
|
+
),
|
|
5943
6170
|
/* @__PURE__ */ jsxs("span", { className: "poolse-room__chip", "aria-label": `${count} in the room`, children: [
|
|
5944
6171
|
/* @__PURE__ */ jsx(PoolseIcon, { name: "users", size: 14, label: null }),
|
|
5945
6172
|
count
|
|
@@ -5964,6 +6191,19 @@ function RoomStage({ room, title, labelFor, className }) {
|
|
|
5964
6191
|
}
|
|
5965
6192
|
)
|
|
5966
6193
|
] }),
|
|
6194
|
+
capture && /* @__PURE__ */ jsx(
|
|
6195
|
+
RecordingBanner,
|
|
6196
|
+
{
|
|
6197
|
+
className: "poolse-room__rec",
|
|
6198
|
+
recording: rec.active,
|
|
6199
|
+
transcribing,
|
|
6200
|
+
mode: rec.recording?.mode ?? null,
|
|
6201
|
+
consentRequired: rec.consentRequired,
|
|
6202
|
+
myConsent: rec.myConsent,
|
|
6203
|
+
onChangeConsent: () => setConsentDismissed(false),
|
|
6204
|
+
pending: rec.pending
|
|
6205
|
+
}
|
|
6206
|
+
),
|
|
5967
6207
|
/* @__PURE__ */ jsx("div", { className: "poolse-room__stage", children: count > 0 ? /* @__PURE__ */ jsx(
|
|
5968
6208
|
CallVideoGrid,
|
|
5969
6209
|
{
|
|
@@ -5978,6 +6218,20 @@ function RoomStage({ room, title, labelFor, className }) {
|
|
|
5978
6218
|
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => void media.setScreenShareEnabled(false), children: "Stop sharing" })
|
|
5979
6219
|
] }),
|
|
5980
6220
|
room.error && /* @__PURE__ */ jsx("p", { className: "poolse-room__error", children: room.error.message }),
|
|
6221
|
+
rec.error && /* @__PURE__ */ jsx("p", { className: "poolse-room__error", children: captureErrorMessage(rec.error) }),
|
|
6222
|
+
capture && rec.needsConsent && !(consentDismissed && rec.myConsent === "declined") && /* @__PURE__ */ jsx(
|
|
6223
|
+
ConsentPrompt,
|
|
6224
|
+
{
|
|
6225
|
+
recording: rec.active,
|
|
6226
|
+
transcribing,
|
|
6227
|
+
mode: rec.recording?.mode ?? null,
|
|
6228
|
+
startedByName: starter ? labelFor?.(starter) ?? null : null,
|
|
6229
|
+
onAnswer: rec.consent,
|
|
6230
|
+
onAccepted: () => void media.republish(),
|
|
6231
|
+
onDeclined: () => setConsentDismissed(true),
|
|
6232
|
+
pending: rec.pending
|
|
6233
|
+
}
|
|
6234
|
+
),
|
|
5981
6235
|
/* @__PURE__ */ jsxs("div", { className: "poolse-room__bar", children: [
|
|
5982
6236
|
/* @__PURE__ */ jsxs("span", { className: "callsheet__control", children: [
|
|
5983
6237
|
/* @__PURE__ */ jsx(
|
|
@@ -6055,6 +6309,16 @@ function RoomStage({ room, title, labelFor, className }) {
|
|
|
6055
6309
|
}
|
|
6056
6310
|
)
|
|
6057
6311
|
] }),
|
|
6312
|
+
allowRecord && rec.available && /* @__PURE__ */ jsx(
|
|
6313
|
+
CallControlButton,
|
|
6314
|
+
{
|
|
6315
|
+
icon: "presence",
|
|
6316
|
+
highlight: rec.active,
|
|
6317
|
+
label: rec.active ? "Stop recording" : "Record",
|
|
6318
|
+
onClick: () => void (rec.active ? rec.stop() : rec.start()),
|
|
6319
|
+
disabled: rec.pending || media.status !== "connected"
|
|
6320
|
+
}
|
|
6321
|
+
),
|
|
6058
6322
|
/* @__PURE__ */ jsx(
|
|
6059
6323
|
CallControlButton,
|
|
6060
6324
|
{
|
|
@@ -6086,6 +6350,324 @@ function useElapsed(startedAt, running) {
|
|
|
6086
6350
|
const s = String(total % 60).padStart(2, "0");
|
|
6087
6351
|
return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${s}` : `${m}:${s}`;
|
|
6088
6352
|
}
|
|
6353
|
+
function LiveTranscriptPanel({
|
|
6354
|
+
callId,
|
|
6355
|
+
enabled = true,
|
|
6356
|
+
showControls = true,
|
|
6357
|
+
onClose,
|
|
6358
|
+
title = "Live transcript",
|
|
6359
|
+
className
|
|
6360
|
+
}) {
|
|
6361
|
+
const live = useLiveTranscript(callId, { enabled });
|
|
6362
|
+
const blocks = useMemo(() => groupTranscript(live.segments), [live.segments]);
|
|
6363
|
+
const scroller = useRef(null);
|
|
6364
|
+
const pinned = useRef(true);
|
|
6365
|
+
useEffect(() => {
|
|
6366
|
+
const el = scroller.current;
|
|
6367
|
+
if (el && pinned.current) el.scrollTop = el.scrollHeight;
|
|
6368
|
+
}, [live.segments]);
|
|
6369
|
+
const error = live.error ? transcriptError(live.error) : null;
|
|
6370
|
+
return /* @__PURE__ */ jsxs(
|
|
6371
|
+
"section",
|
|
6372
|
+
{
|
|
6373
|
+
className: ["poolse-transcript", "poolse-transcript--live", className].filter(Boolean).join(" "),
|
|
6374
|
+
"aria-label": title,
|
|
6375
|
+
children: [
|
|
6376
|
+
/* @__PURE__ */ jsxs("header", { className: "poolse-transcript__head", children: [
|
|
6377
|
+
/* @__PURE__ */ jsxs("span", { className: "poolse-transcript__title", children: [
|
|
6378
|
+
live.live && /* @__PURE__ */ jsx("span", { className: "poolse-rec-dot", "aria-hidden": "true" }),
|
|
6379
|
+
title
|
|
6380
|
+
] }),
|
|
6381
|
+
showControls && callId && /* @__PURE__ */ jsx(
|
|
6382
|
+
"button",
|
|
6383
|
+
{
|
|
6384
|
+
type: "button",
|
|
6385
|
+
className: "poolse-transcript__btn",
|
|
6386
|
+
onClick: () => void (live.live ? live.stop() : live.start()),
|
|
6387
|
+
disabled: live.pending,
|
|
6388
|
+
children: live.live ? "Stop" : live.transcript ? "Resume" : "Start"
|
|
6389
|
+
}
|
|
6390
|
+
),
|
|
6391
|
+
onClose && /* @__PURE__ */ jsx(
|
|
6392
|
+
"button",
|
|
6393
|
+
{
|
|
6394
|
+
type: "button",
|
|
6395
|
+
className: "poolse-transcript__icon-btn",
|
|
6396
|
+
onClick: onClose,
|
|
6397
|
+
"aria-label": "Close transcript",
|
|
6398
|
+
children: /* @__PURE__ */ jsx(PoolseIcon, { name: "close", size: 16, label: null })
|
|
6399
|
+
}
|
|
6400
|
+
)
|
|
6401
|
+
] }),
|
|
6402
|
+
/* @__PURE__ */ jsx(
|
|
6403
|
+
"div",
|
|
6404
|
+
{
|
|
6405
|
+
ref: scroller,
|
|
6406
|
+
className: "poolse-transcript__body",
|
|
6407
|
+
role: "log",
|
|
6408
|
+
"aria-live": "polite",
|
|
6409
|
+
"aria-relevant": "additions",
|
|
6410
|
+
onScroll: (e) => {
|
|
6411
|
+
const el = e.currentTarget;
|
|
6412
|
+
pinned.current = el.scrollHeight - el.scrollTop - el.clientHeight < 24;
|
|
6413
|
+
},
|
|
6414
|
+
children: blocks.length === 0 ? /* @__PURE__ */ jsx("p", { className: "poolse-transcript__empty", children: error ?? (live.live ? "Listening\u2026" : live.joined ? "Transcription is off. Start it to see what is said." : "Opening the transcript\u2026") }) : blocks.map((b, i) => /* @__PURE__ */ jsxs("div", { className: "poolse-transcript__block", children: [
|
|
6415
|
+
/* @__PURE__ */ jsxs("div", { className: "poolse-transcript__who", children: [
|
|
6416
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-transcript__name", children: b.name }),
|
|
6417
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-transcript__time", children: formatCallDuration(b.startMs) })
|
|
6418
|
+
] }),
|
|
6419
|
+
/* @__PURE__ */ jsx("p", { className: "poolse-transcript__text", children: b.segments.map((s, k) => /* @__PURE__ */ jsxs("span", { className: s.final ? void 0 : "poolse-transcript__interim", children: [
|
|
6420
|
+
k > 0 ? " " : "",
|
|
6421
|
+
s.text
|
|
6422
|
+
] }, k)) })
|
|
6423
|
+
] }, `${b.speaker}-${b.startMs}-${i}`))
|
|
6424
|
+
}
|
|
6425
|
+
),
|
|
6426
|
+
error && blocks.length > 0 && /* @__PURE__ */ jsx("p", { className: "poolse-transcript__error", role: "alert", children: error })
|
|
6427
|
+
]
|
|
6428
|
+
}
|
|
6429
|
+
);
|
|
6430
|
+
}
|
|
6431
|
+
function TranscriptViewer({
|
|
6432
|
+
callId,
|
|
6433
|
+
canRename = true,
|
|
6434
|
+
onSeek,
|
|
6435
|
+
title = "Transcript",
|
|
6436
|
+
className
|
|
6437
|
+
}) {
|
|
6438
|
+
const { transcript, loading, missing, error, renameSpeakers } = useTranscript(callId);
|
|
6439
|
+
const [query, setQuery] = useState("");
|
|
6440
|
+
const [hit, setHit] = useState(0);
|
|
6441
|
+
const blocks = useMemo(() => groupTranscript(transcript?.segments ?? []), [transcript]);
|
|
6442
|
+
const hits = useMemo(() => {
|
|
6443
|
+
const out = [];
|
|
6444
|
+
if (!query.trim()) return out;
|
|
6445
|
+
blocks.forEach(
|
|
6446
|
+
(block, b) => block.segments.forEach((seg, s) => {
|
|
6447
|
+
for (const r of findInText(seg.text, query)) out.push({ b, s, r });
|
|
6448
|
+
})
|
|
6449
|
+
);
|
|
6450
|
+
return out;
|
|
6451
|
+
}, [blocks, query]);
|
|
6452
|
+
useEffect(() => setHit(0), [query]);
|
|
6453
|
+
const body = useRef(null);
|
|
6454
|
+
useEffect(() => {
|
|
6455
|
+
body.current?.querySelector(".poolse-transcript__hit--current")?.scrollIntoView({ block: "center" });
|
|
6456
|
+
}, [hit, hits]);
|
|
6457
|
+
const step = (d) => setHit((h) => hits.length ? (h + d + hits.length) % hits.length : 0);
|
|
6458
|
+
if (!callId) return null;
|
|
6459
|
+
const meta = transcript ? [
|
|
6460
|
+
transcript.started_at ? formatDate(transcript.started_at) : null,
|
|
6461
|
+
duration(transcript),
|
|
6462
|
+
transcript.speakers.length === 1 ? "1 speaker" : `${transcript.speakers.length} speakers`
|
|
6463
|
+
].filter(Boolean).join(" \xB7 ") : null;
|
|
6464
|
+
return /* @__PURE__ */ jsxs(
|
|
6465
|
+
"section",
|
|
6466
|
+
{
|
|
6467
|
+
className: ["poolse-transcript", "poolse-transcript--viewer", className].filter(Boolean).join(" "),
|
|
6468
|
+
"aria-label": title,
|
|
6469
|
+
children: [
|
|
6470
|
+
/* @__PURE__ */ jsx("header", { className: "poolse-transcript__head", children: /* @__PURE__ */ jsxs("span", { className: "poolse-transcript__heading", children: [
|
|
6471
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-transcript__title", children: title }),
|
|
6472
|
+
meta && /* @__PURE__ */ jsx("span", { className: "poolse-transcript__meta", children: meta })
|
|
6473
|
+
] }) }),
|
|
6474
|
+
transcript && transcript.segments.length > 0 && /* @__PURE__ */ jsxs("div", { className: "poolse-transcript__search", role: "search", children: [
|
|
6475
|
+
/* @__PURE__ */ jsx(PoolseIcon, { name: "search", size: 15, label: null }),
|
|
6476
|
+
/* @__PURE__ */ jsx(
|
|
6477
|
+
"input",
|
|
6478
|
+
{
|
|
6479
|
+
type: "search",
|
|
6480
|
+
value: query,
|
|
6481
|
+
onChange: (e) => setQuery(e.target.value),
|
|
6482
|
+
onKeyDown: (e) => {
|
|
6483
|
+
if (e.key === "Enter") {
|
|
6484
|
+
e.preventDefault();
|
|
6485
|
+
step(e.shiftKey ? -1 : 1);
|
|
6486
|
+
}
|
|
6487
|
+
},
|
|
6488
|
+
placeholder: "Search the transcript",
|
|
6489
|
+
"aria-label": "Search the transcript"
|
|
6490
|
+
}
|
|
6491
|
+
),
|
|
6492
|
+
query.trim() && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6493
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-transcript__count", "aria-live": "polite", children: hits.length ? `${hit + 1} of ${hits.length}` : "No matches" }),
|
|
6494
|
+
/* @__PURE__ */ jsx(
|
|
6495
|
+
"button",
|
|
6496
|
+
{
|
|
6497
|
+
type: "button",
|
|
6498
|
+
className: "poolse-transcript__icon-btn",
|
|
6499
|
+
onClick: () => step(-1),
|
|
6500
|
+
disabled: !hits.length,
|
|
6501
|
+
"aria-label": "Previous match",
|
|
6502
|
+
children: /* @__PURE__ */ jsx(PoolseIcon, { name: "chevron-up", size: 15, label: null })
|
|
6503
|
+
}
|
|
6504
|
+
),
|
|
6505
|
+
/* @__PURE__ */ jsx(
|
|
6506
|
+
"button",
|
|
6507
|
+
{
|
|
6508
|
+
type: "button",
|
|
6509
|
+
className: "poolse-transcript__icon-btn",
|
|
6510
|
+
onClick: () => step(1),
|
|
6511
|
+
disabled: !hits.length,
|
|
6512
|
+
"aria-label": "Next match",
|
|
6513
|
+
children: /* @__PURE__ */ jsx(PoolseIcon, { name: "chevron-down", size: 15, label: null })
|
|
6514
|
+
}
|
|
6515
|
+
)
|
|
6516
|
+
] })
|
|
6517
|
+
] }),
|
|
6518
|
+
transcript && transcript.speakers.length > 0 && /* @__PURE__ */ jsx(
|
|
6519
|
+
SpeakerList,
|
|
6520
|
+
{
|
|
6521
|
+
speakers: transcript.speakers,
|
|
6522
|
+
canRename,
|
|
6523
|
+
onRename: renameSpeakers
|
|
6524
|
+
}
|
|
6525
|
+
),
|
|
6526
|
+
/* @__PURE__ */ jsx("div", { ref: body, className: "poolse-transcript__body", children: loading && !transcript ? /* @__PURE__ */ jsx("p", { className: "poolse-transcript__empty", children: "Loading the transcript\u2026" }) : missing ? /* @__PURE__ */ jsx("p", { className: "poolse-transcript__empty", children: "This call has no transcript." }) : error && !transcript ? /* @__PURE__ */ jsx("p", { className: "poolse-transcript__empty", children: transcriptError(error) }) : transcript && transcript.segments.length === 0 ? /* @__PURE__ */ jsx("p", { className: "poolse-transcript__empty", children: "Nothing was said in this call." }) : blocks.map((block, b) => /* @__PURE__ */ jsxs(
|
|
6527
|
+
"div",
|
|
6528
|
+
{
|
|
6529
|
+
className: "poolse-transcript__block",
|
|
6530
|
+
children: [
|
|
6531
|
+
/* @__PURE__ */ jsxs("div", { className: "poolse-transcript__who", children: [
|
|
6532
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-transcript__name", children: block.name }),
|
|
6533
|
+
onSeek ? /* @__PURE__ */ jsx(
|
|
6534
|
+
"button",
|
|
6535
|
+
{
|
|
6536
|
+
type: "button",
|
|
6537
|
+
className: "poolse-transcript__time poolse-transcript__time--link",
|
|
6538
|
+
onClick: () => onSeek(block.startMs),
|
|
6539
|
+
"aria-label": `Play from ${formatCallDuration(block.startMs)}`,
|
|
6540
|
+
children: formatCallDuration(block.startMs)
|
|
6541
|
+
}
|
|
6542
|
+
) : /* @__PURE__ */ jsx("span", { className: "poolse-transcript__time", children: formatCallDuration(block.startMs) })
|
|
6543
|
+
] }),
|
|
6544
|
+
/* @__PURE__ */ jsx("p", { className: "poolse-transcript__text", children: block.segments.map((seg, s) => /* @__PURE__ */ jsxs("span", { children: [
|
|
6545
|
+
s > 0 ? " " : "",
|
|
6546
|
+
highlight(seg, hits, b, s, hit)
|
|
6547
|
+
] }, s)) })
|
|
6548
|
+
]
|
|
6549
|
+
},
|
|
6550
|
+
`${block.speaker}-${block.startMs}-${b}`
|
|
6551
|
+
)) })
|
|
6552
|
+
]
|
|
6553
|
+
}
|
|
6554
|
+
);
|
|
6555
|
+
}
|
|
6556
|
+
function SpeakerList({
|
|
6557
|
+
speakers,
|
|
6558
|
+
canRename,
|
|
6559
|
+
onRename
|
|
6560
|
+
}) {
|
|
6561
|
+
const [editing, setEditing] = useState(null);
|
|
6562
|
+
const [draft, setDraft] = useState("");
|
|
6563
|
+
const [busy, setBusy] = useState(false);
|
|
6564
|
+
const [error, setError] = useState(null);
|
|
6565
|
+
const save = async (key, name) => {
|
|
6566
|
+
setBusy(true);
|
|
6567
|
+
setError(null);
|
|
6568
|
+
try {
|
|
6569
|
+
await onRename({ [key]: name });
|
|
6570
|
+
setEditing(null);
|
|
6571
|
+
} catch (err) {
|
|
6572
|
+
setError(
|
|
6573
|
+
err instanceof ApiError && err.status === 403 ? "Only people who were in the call can rename speakers." : err instanceof ApiError && err.code === "validation_failed" ? "Names can be up to 100 characters." : "The name could not be saved. Try again."
|
|
6574
|
+
);
|
|
6575
|
+
} finally {
|
|
6576
|
+
setBusy(false);
|
|
6577
|
+
}
|
|
6578
|
+
};
|
|
6579
|
+
return /* @__PURE__ */ jsxs("div", { className: "poolse-transcript__speakers", children: [
|
|
6580
|
+
/* @__PURE__ */ jsx("ul", { "aria-label": "Speakers", children: speakers.map((sp) => /* @__PURE__ */ jsx("li", { className: "poolse-transcript__speaker", children: editing === sp.key ? /* @__PURE__ */ jsxs(
|
|
6581
|
+
"form",
|
|
6582
|
+
{
|
|
6583
|
+
className: "poolse-transcript__rename",
|
|
6584
|
+
onSubmit: (e) => {
|
|
6585
|
+
e.preventDefault();
|
|
6586
|
+
const name = draft.trim();
|
|
6587
|
+
if (name) void save(sp.key, name);
|
|
6588
|
+
},
|
|
6589
|
+
children: [
|
|
6590
|
+
/* @__PURE__ */ jsx(
|
|
6591
|
+
"input",
|
|
6592
|
+
{
|
|
6593
|
+
value: draft,
|
|
6594
|
+
onChange: (e) => setDraft(e.target.value),
|
|
6595
|
+
maxLength: 100,
|
|
6596
|
+
"aria-label": "Speaker name",
|
|
6597
|
+
autoFocus: true,
|
|
6598
|
+
onKeyDown: (e) => {
|
|
6599
|
+
if (e.key === "Escape") setEditing(null);
|
|
6600
|
+
}
|
|
6601
|
+
}
|
|
6602
|
+
),
|
|
6603
|
+
/* @__PURE__ */ jsx("button", { type: "submit", disabled: busy || !draft.trim(), children: "Save" }),
|
|
6604
|
+
sp.corrected && /* @__PURE__ */ jsx("button", { type: "button", disabled: busy, onClick: () => void save(sp.key, null), children: "Use their own name" }),
|
|
6605
|
+
/* @__PURE__ */ jsx("button", { type: "button", disabled: busy, onClick: () => setEditing(null), children: "Cancel" })
|
|
6606
|
+
]
|
|
6607
|
+
}
|
|
6608
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6609
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-transcript__speaker-name", title: sp.name ?? void 0, children: sp.name?.trim() || "Speaker" }),
|
|
6610
|
+
canRename && /* @__PURE__ */ jsx(
|
|
6611
|
+
"button",
|
|
6612
|
+
{
|
|
6613
|
+
type: "button",
|
|
6614
|
+
className: "poolse-transcript__icon-btn",
|
|
6615
|
+
onClick: () => {
|
|
6616
|
+
setDraft(sp.name ?? "");
|
|
6617
|
+
setError(null);
|
|
6618
|
+
setEditing(sp.key);
|
|
6619
|
+
},
|
|
6620
|
+
"aria-label": `Rename ${sp.name?.trim() || "speaker"}`,
|
|
6621
|
+
children: /* @__PURE__ */ jsx(PoolseIcon, { name: "edit", size: 13, label: null })
|
|
6622
|
+
}
|
|
6623
|
+
)
|
|
6624
|
+
] }) }, sp.key)) }),
|
|
6625
|
+
error && /* @__PURE__ */ jsx("p", { className: "poolse-transcript__error", role: "alert", children: error })
|
|
6626
|
+
] });
|
|
6627
|
+
}
|
|
6628
|
+
function highlight(seg, hits, b, s, current) {
|
|
6629
|
+
const mine = hits.map((h, i) => ({ ...h, i })).filter((h) => h.b === b && h.s === s);
|
|
6630
|
+
if (!mine.length) return seg.text;
|
|
6631
|
+
const out = [];
|
|
6632
|
+
let at = 0;
|
|
6633
|
+
for (const h of mine) {
|
|
6634
|
+
if (h.r[0] > at) out.push(seg.text.slice(at, h.r[0]));
|
|
6635
|
+
out.push(
|
|
6636
|
+
/* @__PURE__ */ jsx(
|
|
6637
|
+
"mark",
|
|
6638
|
+
{
|
|
6639
|
+
className: `poolse-transcript__hit${h.i === current ? " poolse-transcript__hit--current" : ""}`,
|
|
6640
|
+
children: seg.text.slice(h.r[0], h.r[1])
|
|
6641
|
+
},
|
|
6642
|
+
h.i
|
|
6643
|
+
)
|
|
6644
|
+
);
|
|
6645
|
+
at = h.r[1];
|
|
6646
|
+
}
|
|
6647
|
+
if (at < seg.text.length) out.push(seg.text.slice(at));
|
|
6648
|
+
return out;
|
|
6649
|
+
}
|
|
6650
|
+
function duration(t) {
|
|
6651
|
+
if (!t.started_at || !t.ended_at) return null;
|
|
6652
|
+
const ms = Date.parse(t.ended_at) - Date.parse(t.started_at);
|
|
6653
|
+
return Number.isFinite(ms) && ms > 0 ? formatCallDuration(ms) : null;
|
|
6654
|
+
}
|
|
6655
|
+
function formatDate(iso) {
|
|
6656
|
+
const d = new Date(iso);
|
|
6657
|
+
if (Number.isNaN(d.getTime())) return null;
|
|
6658
|
+
return d.toLocaleString(void 0, {
|
|
6659
|
+
month: "short",
|
|
6660
|
+
day: "numeric",
|
|
6661
|
+
hour: "2-digit",
|
|
6662
|
+
minute: "2-digit"
|
|
6663
|
+
});
|
|
6664
|
+
}
|
|
6665
|
+
function transcriptError(err) {
|
|
6666
|
+
const code = err instanceof ApiError ? err.code : err.message;
|
|
6667
|
+
if (code === "forbidden") return "You can\u2019t open this transcript.";
|
|
6668
|
+
if (code === "not_found") return "There is no transcript for this call.";
|
|
6669
|
+
return captureErrorMessage(err instanceof ApiError ? err : { code });
|
|
6670
|
+
}
|
|
6089
6671
|
var ThemeContext = createContext(null);
|
|
6090
6672
|
var DARK_QUERY = "(prefers-color-scheme: dark)";
|
|
6091
6673
|
function systemScheme() {
|
|
@@ -6249,6 +6831,6 @@ function PoolseLogo({
|
|
|
6249
6831
|
);
|
|
6250
6832
|
}
|
|
6251
6833
|
|
|
6252
|
-
export { AttachmentPreview, Avatar, CallControlButton, CallDeviceMenu, CallLogRow, CallVideoGrid, ChatHeader, ConversationList, ConversationView, DEFAULT_KEYMAP, DraftScope, EditableMessageBubble, EditedLabel, EmojiPicker, EmptyState, GroupDetailsSheet, LinkPreviewCard, LiveCallBanner, MOD_ENTER_COMPOSER, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, PoolseFonts, PoolseIcon, PoolseInbox, PoolseLogo, PoolseTheme, PresenceBadge, ReactionPicker, ReactionStrip, RoomJoinBar, RoomStage, SendStatus, ThreadSummary, ThreadView, TypingIndicator, UploadQueueStrip, UserName, UserPickerSheet, draftsOf, formatRelativeTime, loadEmojiData, localDraftStorage, matchesAny, matchesKey, presenceStateLabel, presenceText, resolveKeymap, useDisplayName, useEditHistory, usePoolseFonts, useSystemColorScheme, useTheme };
|
|
6834
|
+
export { AttachmentPreview, Avatar, CallControlButton, CallDeviceMenu, CallLogRow, CallVideoGrid, ChatHeader, ConsentPrompt, ConversationList, ConversationView, DEFAULT_KEYMAP, DraftScope, EditableMessageBubble, EditedLabel, EmojiPicker, EmptyState, GroupDetailsSheet, LinkPreviewCard, LiveCallBanner, LiveTranscriptPanel, MOD_ENTER_COMPOSER, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, PoolseFonts, PoolseIcon, PoolseInbox, PoolseLogo, PoolseTheme, PresenceBadge, ReactionPicker, ReactionStrip, RecordingBanner, RecordingIndicator, RecordingNoticeRow, RoomJoinBar, RoomStage, SendStatus, ThreadSummary, ThreadView, TranscriptViewer, TypingIndicator, UploadQueueStrip, UserName, UserPickerSheet, draftsOf, formatRelativeTime, loadEmojiData, localDraftStorage, matchesAny, matchesKey, presenceStateLabel, presenceText, resolveKeymap, useDisplayName, useEditHistory, usePoolseFonts, useSystemColorScheme, useTheme };
|
|
6253
6835
|
//# sourceMappingURL=index.js.map
|
|
6254
6836
|
//# sourceMappingURL=index.js.map
|