@poolse/react-ui 2.0.1 → 2.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 +457 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +112 -2
- package/dist/index.d.ts +112 -2
- package/dist/index.js +456 -9
- package/dist/index.js.map +1 -1
- package/dist/styles.css +405 -0
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -2323,6 +2323,62 @@ function ConversationView({
|
|
|
2323
2323
|
) })
|
|
2324
2324
|
] });
|
|
2325
2325
|
}
|
|
2326
|
+
function ChatHeader({
|
|
2327
|
+
conversationId,
|
|
2328
|
+
labelFor,
|
|
2329
|
+
avatarFor,
|
|
2330
|
+
onBack,
|
|
2331
|
+
onPress,
|
|
2332
|
+
onMembersPress,
|
|
2333
|
+
rightSlot
|
|
2334
|
+
}) {
|
|
2335
|
+
const { me } = react$1.useMe();
|
|
2336
|
+
const meId = me?.id ?? null;
|
|
2337
|
+
const { conversation: conv } = react$1.useConversation(conversationId);
|
|
2338
|
+
const { members } = react$1.useMembers(conversationId);
|
|
2339
|
+
const { online } = react$1.usePresence(conversationId);
|
|
2340
|
+
const isDirect = conv?.type === "direct";
|
|
2341
|
+
const otherMember = isDirect ? members.find((m) => m.user_id !== meId) : null;
|
|
2342
|
+
const otherExtId = otherMember?.external_id ?? null;
|
|
2343
|
+
const title = isDirect ? otherExtId ? labelFor?.(otherExtId) ?? otherExtId : conv?.name ?? "Direct chat" : conv?.name ?? "Untitled group";
|
|
2344
|
+
const avatarUrl = isDirect && otherExtId ? avatarFor?.(otherExtId) ?? null : null;
|
|
2345
|
+
const otherOnline = isDirect && otherExtId ? online.has(otherExtId) : false;
|
|
2346
|
+
const subtitle = isDirect ? otherOnline ? "Online" : null : `${members.length} member${members.length === 1 ? "" : "s"}`;
|
|
2347
|
+
const isPressable = typeof onPress === "function";
|
|
2348
|
+
const titleContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2349
|
+
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: avatarUrl, name: title, online: otherOnline, size: "md" }),
|
|
2350
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-chat-header__titles", children: [
|
|
2351
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-chat-header__title", children: title }),
|
|
2352
|
+
subtitle ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-chat-header__subtitle", children: subtitle }) : null
|
|
2353
|
+
] })
|
|
2354
|
+
] });
|
|
2355
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "poolse-chat-header", children: [
|
|
2356
|
+
onBack ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2357
|
+
"button",
|
|
2358
|
+
{
|
|
2359
|
+
type: "button",
|
|
2360
|
+
className: "poolse-icon-btn poolse-chat-header__back",
|
|
2361
|
+
onClick: onBack,
|
|
2362
|
+
"aria-label": "Back",
|
|
2363
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "reply", size: 20, label: null })
|
|
2364
|
+
}
|
|
2365
|
+
) : null,
|
|
2366
|
+
isPressable ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "poolse-chat-header__title-btn", onClick: onPress, children: titleContent }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-chat-header__title-row", children: titleContent }),
|
|
2367
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-chat-header__actions", children: [
|
|
2368
|
+
!isDirect && onMembersPress ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2369
|
+
"button",
|
|
2370
|
+
{
|
|
2371
|
+
type: "button",
|
|
2372
|
+
className: "poolse-icon-btn",
|
|
2373
|
+
onClick: onMembersPress,
|
|
2374
|
+
"aria-label": "View members",
|
|
2375
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "users", size: 20, label: null })
|
|
2376
|
+
}
|
|
2377
|
+
) : null,
|
|
2378
|
+
rightSlot
|
|
2379
|
+
] })
|
|
2380
|
+
] });
|
|
2381
|
+
}
|
|
2326
2382
|
function ConversationList({
|
|
2327
2383
|
selectedId,
|
|
2328
2384
|
onSelect,
|
|
@@ -2331,9 +2387,13 @@ function ConversationList({
|
|
|
2331
2387
|
conversations: controlledConversations,
|
|
2332
2388
|
loading: controlledLoading,
|
|
2333
2389
|
error: controlledError,
|
|
2334
|
-
unreadCounts
|
|
2390
|
+
unreadCounts,
|
|
2391
|
+
labelFor,
|
|
2392
|
+
avatarFor
|
|
2335
2393
|
}) {
|
|
2336
2394
|
const auto = react$1.useConversations();
|
|
2395
|
+
const { me } = react$1.useMe();
|
|
2396
|
+
const meExternalId = me?.external_id ?? null;
|
|
2337
2397
|
const isControlled = controlledConversations !== void 0;
|
|
2338
2398
|
const conversations = isControlled ? controlledConversations : auto.conversations;
|
|
2339
2399
|
const loading = isControlled ? controlledLoading ?? false : auto.loading;
|
|
@@ -2351,7 +2411,17 @@ function ConversationList({
|
|
|
2351
2411
|
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "poolse-list", role: "listbox", "aria-label": "Conversations", children: conversations.map((conv) => {
|
|
2352
2412
|
const selected = selectedId === conv.id;
|
|
2353
2413
|
const unread = counts?.[conv.id] ?? 0;
|
|
2354
|
-
const content = renderItem ? renderItem(conv, selected) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2414
|
+
const content = renderItem ? renderItem(conv, selected) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2415
|
+
DefaultRow,
|
|
2416
|
+
{
|
|
2417
|
+
conv,
|
|
2418
|
+
selected,
|
|
2419
|
+
unread,
|
|
2420
|
+
meExternalId,
|
|
2421
|
+
...labelFor ? { labelFor } : {},
|
|
2422
|
+
...avatarFor ? { avatarFor } : {}
|
|
2423
|
+
}
|
|
2424
|
+
);
|
|
2355
2425
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2356
2426
|
"li",
|
|
2357
2427
|
{
|
|
@@ -2375,19 +2445,26 @@ function ConversationList({
|
|
|
2375
2445
|
function DefaultRow({
|
|
2376
2446
|
conv,
|
|
2377
2447
|
selected: _selected,
|
|
2378
|
-
unread
|
|
2448
|
+
unread,
|
|
2449
|
+
meExternalId,
|
|
2450
|
+
labelFor,
|
|
2451
|
+
avatarFor
|
|
2379
2452
|
}) {
|
|
2380
|
-
const
|
|
2453
|
+
const isDirect = conv.type === "direct";
|
|
2454
|
+
const otherExtId = isDirect && meExternalId ? (conv.member_external_ids ?? []).find((x) => x !== meExternalId) : null;
|
|
2455
|
+
const title = isDirect ? otherExtId ? labelFor?.(otherExtId) ?? otherExtId : conv.name ?? "Direct chat" : conv.name ?? "Untitled group";
|
|
2456
|
+
const avatarUrl = isDirect ? otherExtId ? avatarFor?.(otherExtId) ?? null : conv.avatar_url ?? null : conv.avatar_url ?? null;
|
|
2381
2457
|
const time = conv.last_message_at ? formatRelative(conv.last_message_at) : "";
|
|
2382
2458
|
const hasUnread = unread > 0;
|
|
2459
|
+
const preview = conv.last_message_preview ?? (conv.last_sequence > 0 ? `${conv.last_sequence} message${conv.last_sequence === 1 ? "" : "s"}` : "No messages yet");
|
|
2383
2460
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2384
|
-
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { src:
|
|
2461
|
+
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: avatarUrl, name: title, size: "md" }),
|
|
2385
2462
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-list__body", children: [
|
|
2386
2463
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-list__head", children: [
|
|
2387
2464
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `poolse-list__title${hasUnread ? " poolse-list__title--unread" : ""}`, children: title }),
|
|
2388
2465
|
time && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-list__time", children: time })
|
|
2389
2466
|
] }),
|
|
2390
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list__preview", children:
|
|
2467
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list__preview", children: preview })
|
|
2391
2468
|
] }),
|
|
2392
2469
|
hasUnread && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2393
2470
|
"span",
|
|
@@ -2486,6 +2563,376 @@ function RoleBadge({ role }) {
|
|
|
2486
2563
|
const mod = role === "owner" ? "owner" : role === "admin" ? "admin" : null;
|
|
2487
2564
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: `poolse-badge${mod ? ` poolse-badge--${mod}` : ""}`, children: role });
|
|
2488
2565
|
}
|
|
2566
|
+
function GroupDetailsSheet({
|
|
2567
|
+
visible,
|
|
2568
|
+
onClose,
|
|
2569
|
+
conversationId,
|
|
2570
|
+
labelFor,
|
|
2571
|
+
avatarFor,
|
|
2572
|
+
footer
|
|
2573
|
+
}) {
|
|
2574
|
+
const { conversation: conv } = react$1.useConversation(visible ? conversationId : null);
|
|
2575
|
+
react.useEffect(() => {
|
|
2576
|
+
if (!visible) return void 0;
|
|
2577
|
+
const onKey = (e) => {
|
|
2578
|
+
if (e.key === "Escape") onClose();
|
|
2579
|
+
};
|
|
2580
|
+
document.addEventListener("keydown", onKey);
|
|
2581
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
2582
|
+
}, [visible, onClose]);
|
|
2583
|
+
if (!visible) return null;
|
|
2584
|
+
const title = conv?.name ?? "Group";
|
|
2585
|
+
const memberCount = conv?.member_external_ids?.length ?? 0;
|
|
2586
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2587
|
+
"div",
|
|
2588
|
+
{
|
|
2589
|
+
className: "poolse-modal",
|
|
2590
|
+
role: "dialog",
|
|
2591
|
+
"aria-modal": "true",
|
|
2592
|
+
"aria-label": "Group details",
|
|
2593
|
+
onClick: (e) => {
|
|
2594
|
+
if (e.target === e.currentTarget) onClose();
|
|
2595
|
+
},
|
|
2596
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-modal__sheet", children: [
|
|
2597
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "poolse-modal__header", children: [
|
|
2598
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-modal__title", children: "Group details" }),
|
|
2599
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "poolse-icon-btn", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "close", size: 18, label: null }) })
|
|
2600
|
+
] }),
|
|
2601
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-modal__body", children: [
|
|
2602
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-group-details__hero", children: [
|
|
2603
|
+
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: conv?.avatar_url ?? null, name: title, size: "lg" }),
|
|
2604
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-group-details__hero-text", children: [
|
|
2605
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-group-details__title", children: title }),
|
|
2606
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-group-details__subtitle", children: memberCount > 0 ? `${memberCount} member${memberCount === 1 ? "" : "s"}` : "" })
|
|
2607
|
+
] })
|
|
2608
|
+
] }),
|
|
2609
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-group-details__members", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2610
|
+
MemberList,
|
|
2611
|
+
{
|
|
2612
|
+
conversationId,
|
|
2613
|
+
...labelFor ? { labelFor } : {},
|
|
2614
|
+
...avatarFor ? { avatarFor } : {}
|
|
2615
|
+
}
|
|
2616
|
+
) })
|
|
2617
|
+
] }),
|
|
2618
|
+
footer ? /* @__PURE__ */ jsxRuntime.jsx("footer", { className: "poolse-modal__footer", children: footer }) : null
|
|
2619
|
+
] })
|
|
2620
|
+
}
|
|
2621
|
+
);
|
|
2622
|
+
}
|
|
2623
|
+
function UserPickerSheet({
|
|
2624
|
+
visible,
|
|
2625
|
+
onClose,
|
|
2626
|
+
users,
|
|
2627
|
+
excludeIds = [],
|
|
2628
|
+
mode,
|
|
2629
|
+
onPickDirect,
|
|
2630
|
+
onCreateGroup
|
|
2631
|
+
}) {
|
|
2632
|
+
const [query, setQuery] = react.useState("");
|
|
2633
|
+
const [selected, setSelected] = react.useState(/* @__PURE__ */ new Set());
|
|
2634
|
+
const [groupName, setGroupName] = react.useState("");
|
|
2635
|
+
const searchRef = react.useRef(null);
|
|
2636
|
+
react.useEffect(() => {
|
|
2637
|
+
if (visible) {
|
|
2638
|
+
setQuery("");
|
|
2639
|
+
setSelected(/* @__PURE__ */ new Set());
|
|
2640
|
+
setGroupName("");
|
|
2641
|
+
const id = setTimeout(() => searchRef.current?.focus(), 50);
|
|
2642
|
+
return () => clearTimeout(id);
|
|
2643
|
+
}
|
|
2644
|
+
return void 0;
|
|
2645
|
+
}, [visible]);
|
|
2646
|
+
react.useEffect(() => {
|
|
2647
|
+
if (!visible) return void 0;
|
|
2648
|
+
const onKey = (e) => {
|
|
2649
|
+
if (e.key === "Escape") onClose();
|
|
2650
|
+
};
|
|
2651
|
+
document.addEventListener("keydown", onKey);
|
|
2652
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
2653
|
+
}, [visible, onClose]);
|
|
2654
|
+
const filtered = react.useMemo(() => {
|
|
2655
|
+
const q = query.trim().toLowerCase();
|
|
2656
|
+
const excluded = new Set(excludeIds);
|
|
2657
|
+
return users.filter((u) => {
|
|
2658
|
+
if (excluded.has(u.externalId)) return false;
|
|
2659
|
+
if (!q) return true;
|
|
2660
|
+
return u.name.toLowerCase().includes(q) || u.externalId.toLowerCase().includes(q) || (u.subtitle ?? "").toLowerCase().includes(q);
|
|
2661
|
+
});
|
|
2662
|
+
}, [users, excludeIds, query]);
|
|
2663
|
+
if (!visible) return null;
|
|
2664
|
+
const toggle = (externalId) => {
|
|
2665
|
+
setSelected((prev) => {
|
|
2666
|
+
const next = new Set(prev);
|
|
2667
|
+
if (next.has(externalId)) next.delete(externalId);
|
|
2668
|
+
else next.add(externalId);
|
|
2669
|
+
return next;
|
|
2670
|
+
});
|
|
2671
|
+
};
|
|
2672
|
+
const canSubmitGroup = mode === "group" && selected.size >= 2 && groupName.trim().length > 0;
|
|
2673
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2674
|
+
"div",
|
|
2675
|
+
{
|
|
2676
|
+
className: "poolse-modal",
|
|
2677
|
+
role: "dialog",
|
|
2678
|
+
"aria-modal": "true",
|
|
2679
|
+
"aria-label": mode === "group" ? "Create group" : "New chat",
|
|
2680
|
+
onClick: (e) => {
|
|
2681
|
+
if (e.target === e.currentTarget) onClose();
|
|
2682
|
+
},
|
|
2683
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-modal__sheet", children: [
|
|
2684
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "poolse-modal__header", children: [
|
|
2685
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-modal__title", children: mode === "group" ? "New group" : "New chat" }),
|
|
2686
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "poolse-icon-btn", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "close", size: 18, label: null }) })
|
|
2687
|
+
] }),
|
|
2688
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-modal__body", children: [
|
|
2689
|
+
mode === "group" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2690
|
+
"input",
|
|
2691
|
+
{
|
|
2692
|
+
type: "text",
|
|
2693
|
+
value: groupName,
|
|
2694
|
+
onChange: (e) => setGroupName(e.target.value),
|
|
2695
|
+
placeholder: "Group name",
|
|
2696
|
+
className: "poolse-input",
|
|
2697
|
+
"aria-label": "Group name"
|
|
2698
|
+
}
|
|
2699
|
+
) : null,
|
|
2700
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-modal__search", children: [
|
|
2701
|
+
/* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "search", size: 16, label: null }),
|
|
2702
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2703
|
+
"input",
|
|
2704
|
+
{
|
|
2705
|
+
ref: searchRef,
|
|
2706
|
+
type: "text",
|
|
2707
|
+
value: query,
|
|
2708
|
+
onChange: (e) => setQuery(e.target.value),
|
|
2709
|
+
placeholder: "Search by name or id\u2026",
|
|
2710
|
+
className: "poolse-input poolse-input--bare",
|
|
2711
|
+
"aria-label": "Search users"
|
|
2712
|
+
}
|
|
2713
|
+
)
|
|
2714
|
+
] }),
|
|
2715
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "poolse-user-picker", role: "listbox", "aria-label": "Users", children: filtered.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("li", { className: "poolse-user-picker__empty", children: "No matching users." }) : filtered.map((u) => {
|
|
2716
|
+
const isSelected = selected.has(u.externalId);
|
|
2717
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2718
|
+
"li",
|
|
2719
|
+
{
|
|
2720
|
+
role: "option",
|
|
2721
|
+
"aria-selected": isSelected,
|
|
2722
|
+
className: `poolse-user-picker__row${isSelected ? " poolse-user-picker__row--selected" : ""}`,
|
|
2723
|
+
onClick: () => {
|
|
2724
|
+
if (mode === "single") {
|
|
2725
|
+
onPickDirect?.(u.externalId);
|
|
2726
|
+
onClose();
|
|
2727
|
+
} else {
|
|
2728
|
+
toggle(u.externalId);
|
|
2729
|
+
}
|
|
2730
|
+
},
|
|
2731
|
+
children: [
|
|
2732
|
+
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: u.avatarUrl ?? null, name: u.name, size: "md" }),
|
|
2733
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-user-picker__body", children: [
|
|
2734
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-user-picker__name", children: u.name }),
|
|
2735
|
+
u.subtitle ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-user-picker__subtitle", children: u.subtitle }) : null
|
|
2736
|
+
] }),
|
|
2737
|
+
mode === "group" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2738
|
+
"span",
|
|
2739
|
+
{
|
|
2740
|
+
className: `poolse-user-picker__check${isSelected ? " poolse-user-picker__check--on" : ""}`,
|
|
2741
|
+
"aria-hidden": "true",
|
|
2742
|
+
children: isSelected ? "\u2713" : ""
|
|
2743
|
+
}
|
|
2744
|
+
) : null
|
|
2745
|
+
]
|
|
2746
|
+
},
|
|
2747
|
+
u.externalId
|
|
2748
|
+
);
|
|
2749
|
+
}) })
|
|
2750
|
+
] }),
|
|
2751
|
+
mode === "group" ? /* @__PURE__ */ jsxRuntime.jsxs("footer", { className: "poolse-modal__footer", children: [
|
|
2752
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-modal__footer-hint", children: [
|
|
2753
|
+
selected.size,
|
|
2754
|
+
" selected",
|
|
2755
|
+
selected.size < 2 ? " (need 2+)" : ""
|
|
2756
|
+
] }),
|
|
2757
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2758
|
+
"button",
|
|
2759
|
+
{
|
|
2760
|
+
type: "button",
|
|
2761
|
+
className: "poolse-btn poolse-btn--brand",
|
|
2762
|
+
disabled: !canSubmitGroup,
|
|
2763
|
+
onClick: () => {
|
|
2764
|
+
if (!canSubmitGroup) return;
|
|
2765
|
+
onCreateGroup?.(groupName.trim(), Array.from(selected));
|
|
2766
|
+
onClose();
|
|
2767
|
+
},
|
|
2768
|
+
children: "Create group"
|
|
2769
|
+
}
|
|
2770
|
+
)
|
|
2771
|
+
] }) : null
|
|
2772
|
+
] })
|
|
2773
|
+
}
|
|
2774
|
+
);
|
|
2775
|
+
}
|
|
2776
|
+
var PoolseInbox = react.forwardRef(function PoolseInbox2({
|
|
2777
|
+
title = "Chats",
|
|
2778
|
+
users,
|
|
2779
|
+
labelFor,
|
|
2780
|
+
avatarFor,
|
|
2781
|
+
renderRightAction,
|
|
2782
|
+
renderConversationRow,
|
|
2783
|
+
emptyState
|
|
2784
|
+
}, ref) {
|
|
2785
|
+
const { me } = react$1.useMe();
|
|
2786
|
+
const meExternalId = me?.external_id ?? null;
|
|
2787
|
+
const { conversations, create, unreadCounts } = react$1.useConversations();
|
|
2788
|
+
const [activeId, setActiveId] = react.useState(null);
|
|
2789
|
+
const [userPickerOpen, setUserPickerOpen] = react.useState(false);
|
|
2790
|
+
const [groupPickerOpen, setGroupPickerOpen] = react.useState(false);
|
|
2791
|
+
const [groupDetailsOpen, setGroupDetailsOpen] = react.useState(false);
|
|
2792
|
+
const openDirect = react.useCallback(
|
|
2793
|
+
async (externalId) => {
|
|
2794
|
+
const conv = await create({
|
|
2795
|
+
type: "direct",
|
|
2796
|
+
member_external_ids: [externalId]
|
|
2797
|
+
});
|
|
2798
|
+
setActiveId(conv.id);
|
|
2799
|
+
},
|
|
2800
|
+
[create]
|
|
2801
|
+
);
|
|
2802
|
+
const openGroup = react.useCallback(
|
|
2803
|
+
async (name, memberExternalIds) => {
|
|
2804
|
+
const conv = await create({
|
|
2805
|
+
type: "group",
|
|
2806
|
+
name,
|
|
2807
|
+
member_external_ids: memberExternalIds
|
|
2808
|
+
});
|
|
2809
|
+
setActiveId(conv.id);
|
|
2810
|
+
},
|
|
2811
|
+
[create]
|
|
2812
|
+
);
|
|
2813
|
+
react.useImperativeHandle(
|
|
2814
|
+
ref,
|
|
2815
|
+
() => ({
|
|
2816
|
+
open: setActiveId,
|
|
2817
|
+
openDirect,
|
|
2818
|
+
openGroup,
|
|
2819
|
+
promptNewChat: () => setUserPickerOpen(true),
|
|
2820
|
+
promptNewGroup: () => setGroupPickerOpen(true),
|
|
2821
|
+
close: () => setActiveId(null)
|
|
2822
|
+
}),
|
|
2823
|
+
[openDirect, openGroup]
|
|
2824
|
+
);
|
|
2825
|
+
const renderRow = react.useMemo(() => {
|
|
2826
|
+
if (!renderConversationRow) return void 0;
|
|
2827
|
+
return (conv, selected) => renderConversationRow(conv, meExternalId, selected);
|
|
2828
|
+
}, [renderConversationRow, meExternalId]);
|
|
2829
|
+
const activeConv = activeId ? conversations.find((c) => c.id === activeId) ?? null : null;
|
|
2830
|
+
const isGroup = activeConv?.type === "group";
|
|
2831
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `poolse-inbox${activeId ? " poolse-inbox--detail-open" : ""}`, children: [
|
|
2832
|
+
/* @__PURE__ */ jsxRuntime.jsxs("aside", { className: "poolse-inbox__list-pane", children: [
|
|
2833
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "poolse-inbox__list-header", children: [
|
|
2834
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-inbox__list-title", children: title }),
|
|
2835
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-inbox__list-actions", children: [
|
|
2836
|
+
users ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2837
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2838
|
+
"button",
|
|
2839
|
+
{
|
|
2840
|
+
type: "button",
|
|
2841
|
+
className: "poolse-icon-btn",
|
|
2842
|
+
onClick: () => setUserPickerOpen(true),
|
|
2843
|
+
"aria-label": "New chat",
|
|
2844
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "compose", size: 18, label: null })
|
|
2845
|
+
}
|
|
2846
|
+
),
|
|
2847
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2848
|
+
"button",
|
|
2849
|
+
{
|
|
2850
|
+
type: "button",
|
|
2851
|
+
className: "poolse-icon-btn",
|
|
2852
|
+
onClick: () => setGroupPickerOpen(true),
|
|
2853
|
+
"aria-label": "New group",
|
|
2854
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "users", size: 18, label: null })
|
|
2855
|
+
}
|
|
2856
|
+
)
|
|
2857
|
+
] }) : null,
|
|
2858
|
+
renderRightAction?.()
|
|
2859
|
+
] })
|
|
2860
|
+
] }),
|
|
2861
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-inbox__list-scroll", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2862
|
+
ConversationList,
|
|
2863
|
+
{
|
|
2864
|
+
selectedId: activeId ?? null,
|
|
2865
|
+
onSelect: (c) => setActiveId(c.id),
|
|
2866
|
+
conversations,
|
|
2867
|
+
unreadCounts,
|
|
2868
|
+
...labelFor ? { labelFor } : {},
|
|
2869
|
+
...avatarFor ? { avatarFor } : {},
|
|
2870
|
+
...renderRow ? { renderItem: renderRow } : {},
|
|
2871
|
+
...emptyState !== void 0 ? { emptyState } : {}
|
|
2872
|
+
}
|
|
2873
|
+
) })
|
|
2874
|
+
] }),
|
|
2875
|
+
/* @__PURE__ */ jsxRuntime.jsx("section", { className: "poolse-inbox__detail-pane", children: activeId ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2876
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2877
|
+
ChatHeader,
|
|
2878
|
+
{
|
|
2879
|
+
conversationId: activeId,
|
|
2880
|
+
onBack: () => setActiveId(null),
|
|
2881
|
+
...labelFor ? { labelFor } : {},
|
|
2882
|
+
...avatarFor ? { avatarFor } : {},
|
|
2883
|
+
...isGroup ? { onMembersPress: () => setGroupDetailsOpen(true) } : {}
|
|
2884
|
+
}
|
|
2885
|
+
),
|
|
2886
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2887
|
+
ConversationView,
|
|
2888
|
+
{
|
|
2889
|
+
conversationId: activeId,
|
|
2890
|
+
...labelFor ? { labelFor } : {}
|
|
2891
|
+
},
|
|
2892
|
+
activeId
|
|
2893
|
+
)
|
|
2894
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-inbox__detail-empty", children: [
|
|
2895
|
+
/* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "messages", size: 32, label: null }),
|
|
2896
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-inbox__detail-empty-title", children: "Pick a conversation" })
|
|
2897
|
+
] }) }),
|
|
2898
|
+
users ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2899
|
+
UserPickerSheet,
|
|
2900
|
+
{
|
|
2901
|
+
visible: userPickerOpen,
|
|
2902
|
+
onClose: () => setUserPickerOpen(false),
|
|
2903
|
+
users,
|
|
2904
|
+
excludeIds: meExternalId ? [meExternalId] : [],
|
|
2905
|
+
mode: "single",
|
|
2906
|
+
onPickDirect: (externalId) => {
|
|
2907
|
+
void openDirect(externalId);
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
) : null,
|
|
2911
|
+
users ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2912
|
+
UserPickerSheet,
|
|
2913
|
+
{
|
|
2914
|
+
visible: groupPickerOpen,
|
|
2915
|
+
onClose: () => setGroupPickerOpen(false),
|
|
2916
|
+
users,
|
|
2917
|
+
excludeIds: meExternalId ? [meExternalId] : [],
|
|
2918
|
+
mode: "group",
|
|
2919
|
+
onCreateGroup: (name, ids) => {
|
|
2920
|
+
void openGroup(name, ids);
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
) : null,
|
|
2924
|
+
activeId && isGroup ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2925
|
+
GroupDetailsSheet,
|
|
2926
|
+
{
|
|
2927
|
+
visible: groupDetailsOpen,
|
|
2928
|
+
onClose: () => setGroupDetailsOpen(false),
|
|
2929
|
+
conversationId: activeId,
|
|
2930
|
+
...labelFor ? { labelFor } : {},
|
|
2931
|
+
...avatarFor ? { avatarFor } : {}
|
|
2932
|
+
}
|
|
2933
|
+
) : null
|
|
2934
|
+
] });
|
|
2935
|
+
});
|
|
2489
2936
|
var MARK_PATHS = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2490
2937
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2491
2938
|
"path",
|
|
@@ -2596,9 +3043,11 @@ function PoolseLogo({
|
|
|
2596
3043
|
|
|
2597
3044
|
exports.AttachmentPreview = AttachmentPreview;
|
|
2598
3045
|
exports.Avatar = Avatar;
|
|
3046
|
+
exports.ChatHeader = ChatHeader;
|
|
2599
3047
|
exports.ConversationList = ConversationList;
|
|
2600
3048
|
exports.ConversationView = ConversationView;
|
|
2601
3049
|
exports.EditableMessageBubble = EditableMessageBubble;
|
|
3050
|
+
exports.GroupDetailsSheet = GroupDetailsSheet;
|
|
2602
3051
|
exports.MemberList = MemberList;
|
|
2603
3052
|
exports.MentionInput = MentionInput;
|
|
2604
3053
|
exports.MessageActions = MessageActions;
|
|
@@ -2606,6 +3055,7 @@ exports.MessageBubble = MessageBubble;
|
|
|
2606
3055
|
exports.MessageComposer = MessageComposer;
|
|
2607
3056
|
exports.PoolseFonts = PoolseFonts;
|
|
2608
3057
|
exports.PoolseIcon = PoolseIcon;
|
|
3058
|
+
exports.PoolseInbox = PoolseInbox;
|
|
2609
3059
|
exports.PoolseLogo = PoolseLogo;
|
|
2610
3060
|
exports.ReactionPicker = ReactionPicker;
|
|
2611
3061
|
exports.ReactionStrip = ReactionStrip;
|
|
@@ -2613,6 +3063,7 @@ exports.ThreadView = ThreadView;
|
|
|
2613
3063
|
exports.TypingIndicator = TypingIndicator;
|
|
2614
3064
|
exports.UploadQueueStrip = UploadQueueStrip;
|
|
2615
3065
|
exports.UserName = UserName;
|
|
3066
|
+
exports.UserPickerSheet = UserPickerSheet;
|
|
2616
3067
|
exports.useDisplayName = useDisplayName;
|
|
2617
3068
|
exports.usePoolseFonts = usePoolseFonts;
|
|
2618
3069
|
//# sourceMappingURL=index.cjs.map
|