@arbidocs/react 0.3.149 → 0.3.151

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkZMTLGO3K_cjs = require('./chunk-ZMTLGO3K.cjs');
4
3
  var chunkZBZKHBDS_cjs = require('./chunk-ZBZKHBDS.cjs');
4
+ var chunkZMTLGO3K_cjs = require('./chunk-ZMTLGO3K.cjs');
5
5
  var React2 = require('react');
6
6
  var reactQuery = require('@tanstack/react-query');
7
7
  var jsxRuntime = require('react/jsx-runtime');
@@ -4400,6 +4400,13 @@ var presencePositionClasses = {
4400
4400
  md: "-right-1.5 -bottom-0.5",
4401
4401
  lg: "-right-1.5 -bottom-0.5"
4402
4402
  };
4403
+ var PRESENCE_LABELS = {
4404
+ connected: "Online",
4405
+ connecting: "Connecting",
4406
+ disconnected: "Offline",
4407
+ error: "Connection problem",
4408
+ hidden: "Status hidden"
4409
+ };
4403
4410
  var presenceColorClasses = {
4404
4411
  connected: "bg-status-online",
4405
4412
  connecting: "bg-status-connecting",
@@ -4420,6 +4427,7 @@ var UserEntity = React2.memo(function UserEntity2({
4420
4427
  colorClass = "",
4421
4428
  isAgent = false,
4422
4429
  agentStyle,
4430
+ avatarStyle,
4423
4431
  isMe = false,
4424
4432
  displayStatus,
4425
4433
  onClick,
@@ -4439,6 +4447,7 @@ var UserEntity = React2.memo(function UserEntity2({
4439
4447
  const agentBadge = isAgent ? /* @__PURE__ */ jsxRuntime.jsx(ArbiBotHeadIcon, { className: "w-3.5 h-3.5 text-muted-foreground" }) : void 0;
4440
4448
  const canMessage = interactive && !isMe && !isAgent;
4441
4449
  const showUnread = hasUnreadMessages && !isMe && !isAgent;
4450
+ const surfaceStyle = avatarStyle ?? agentStyle;
4442
4451
  const avatarCore = /* @__PURE__ */ jsxRuntime.jsxs(
4443
4452
  chunkZBZKHBDS_cjs.Avatar,
4444
4453
  {
@@ -4446,7 +4455,7 @@ var UserEntity = React2.memo(function UserEntity2({
4446
4455
  sizeClasses[size],
4447
4456
  isAgent ? "rounded-full border-2 border-dashed" : "border border-white"
4448
4457
  ),
4449
- style: agentStyle,
4458
+ style: surfaceStyle,
4450
4459
  "data-testid": "user-entity",
4451
4460
  children: [
4452
4461
  picture && /* @__PURE__ */ jsxRuntime.jsx(chunkZBZKHBDS_cjs.AvatarImage, { src: picture, alt: initials }),
@@ -4458,7 +4467,7 @@ var UserEntity = React2.memo(function UserEntity2({
4458
4467
  "font-semibold leading-none",
4459
4468
  isAgent ? "rounded-full bg-transparent" : `text-white ${colorClass}`
4460
4469
  ),
4461
- style: agentStyle,
4470
+ style: surfaceStyle,
4462
4471
  children: initials
4463
4472
  }
4464
4473
  )
@@ -4475,7 +4484,10 @@ var UserEntity = React2.memo(function UserEntity2({
4475
4484
  !showUnread && displayStatus ? presenceColorClasses[displayStatus] : ""
4476
4485
  ),
4477
4486
  style: showUnread ? { backgroundColor: "#00adef" } : void 0,
4478
- "data-testid": "user-entity-presence"
4487
+ "data-testid": "user-entity-presence",
4488
+ role: "img",
4489
+ "aria-label": showUnread ? "Unread messages" : PRESENCE_LABELS[displayStatus],
4490
+ title: showUnread ? "Unread messages" : PRESENCE_LABELS[displayStatus]
4479
4491
  }
4480
4492
  ) : null;
4481
4493
  const avatarElement = statusDot ? /* @__PURE__ */ jsxRuntime.jsxs(
@@ -4552,6 +4564,59 @@ var UserEntity = React2.memo(function UserEntity2({
4552
4564
  }
4553
4565
  return avatarElement;
4554
4566
  });
4567
+ function AgentBadge({ className }) {
4568
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4569
+ "span",
4570
+ {
4571
+ "data-testid": "agent-badge",
4572
+ className: chunkZBZKHBDS_cjs.cn(
4573
+ "inline-flex shrink-0 items-center gap-1 rounded-full border border-ai-accent/50",
4574
+ "bg-ai-accent-soft px-2 py-0.5 text-[11px] font-bold uppercase tracking-wider text-ai-accent",
4575
+ className
4576
+ ),
4577
+ children: [
4578
+ /* @__PURE__ */ jsxRuntime.jsx(ArbiBotHeadIcon, { size: 14, className: "text-ai-accent" }),
4579
+ "Agent"
4580
+ ]
4581
+ }
4582
+ );
4583
+ }
4584
+ var PRESENCE_WORDS = {
4585
+ connected: "Online",
4586
+ connecting: "Connecting",
4587
+ disconnected: "Offline",
4588
+ error: "Connection problem",
4589
+ hidden: null
4590
+ };
4591
+ function PresenceLabel({
4592
+ status,
4593
+ className
4594
+ }) {
4595
+ if (!status) return null;
4596
+ const word = PRESENCE_WORDS[status];
4597
+ if (!word) return null;
4598
+ const online = status === "connected";
4599
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4600
+ "span",
4601
+ {
4602
+ "data-testid": "presence-label",
4603
+ className: chunkZBZKHBDS_cjs.cn("inline-flex shrink-0 items-center gap-1 text-xs", className),
4604
+ children: [
4605
+ /* @__PURE__ */ jsxRuntime.jsx(
4606
+ "span",
4607
+ {
4608
+ className: chunkZBZKHBDS_cjs.cn(
4609
+ "size-1.5 rounded-full",
4610
+ online ? "bg-status-online" : "bg-muted-foreground/50"
4611
+ ),
4612
+ "aria-hidden": "true"
4613
+ }
4614
+ ),
4615
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: online ? "font-medium text-status-online" : "text-muted-foreground", children: word })
4616
+ ]
4617
+ }
4618
+ );
4619
+ }
4555
4620
  var PACKAGE_BADGE_VARIANTS = [
4556
4621
  "default",
4557
4622
  "accent",
@@ -5171,6 +5236,9 @@ function userDisplayName(user) {
5171
5236
  const name = [user.given_name, user.family_name].filter(Boolean).join(" ").trim();
5172
5237
  return name || user.email?.split("@")[0] || "Unknown";
5173
5238
  }
5239
+ function isAgentUser(user) {
5240
+ return user.external_id.startsWith("agt-");
5241
+ }
5174
5242
  var RELATIVE = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" });
5175
5243
  var DIVISIONS = [
5176
5244
  { amount: 60, unit: "seconds" },
@@ -5419,13 +5487,25 @@ function useDirectMessages(options) {
5419
5487
  markRead: (messageIds) => markReadMutation.mutateAsync(messageIds)
5420
5488
  };
5421
5489
  }
5422
- function DmAvatar({ user, className }) {
5423
- const name = userDisplayName(user);
5424
- const tint = getEntityColorStyles(user.external_id);
5425
- return /* @__PURE__ */ jsxRuntime.jsxs(chunkZBZKHBDS_cjs.Avatar, { className: chunkZBZKHBDS_cjs.cn("size-10", className), children: [
5426
- user.picture ? /* @__PURE__ */ jsxRuntime.jsx(chunkZBZKHBDS_cjs.AvatarImage, { src: user.picture, alt: name }) : null,
5427
- /* @__PURE__ */ jsxRuntime.jsx(chunkZBZKHBDS_cjs.AvatarFallback, { style: tint, className: "text-xs font-semibold", children: userInitials(user) })
5428
- ] });
5490
+ function DmAvatar({ user, className, size = "lg" }) {
5491
+ const presence = useArbiWsStore((s) => s.presence[user.external_id]);
5492
+ const displayStatus = presence === void 0 ? void 0 : presence === "online" ? "connected" : "disconnected";
5493
+ return /* @__PURE__ */ jsxRuntime.jsx(
5494
+ UserEntity,
5495
+ {
5496
+ variant: "icon",
5497
+ size,
5498
+ className,
5499
+ interactive: false,
5500
+ showTooltip: false,
5501
+ initials: userInitials(user),
5502
+ displayName: userDisplayName(user),
5503
+ picture: user.picture,
5504
+ avatarStyle: getEntityColorStyles(user.external_id),
5505
+ isAgent: isAgentUser(user),
5506
+ displayStatus
5507
+ }
5508
+ );
5429
5509
  }
5430
5510
  function ConversationList({
5431
5511
  conversations,
@@ -5463,16 +5543,19 @@ function ConversationList({
5463
5543
  c.leading ?? /* @__PURE__ */ jsxRuntime.jsx(DmAvatar, { user: peer }),
5464
5544
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
5465
5545
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
5466
- /* @__PURE__ */ jsxRuntime.jsx(
5467
- "span",
5468
- {
5469
- className: chunkZBZKHBDS_cjs.cn(
5470
- "truncate text-sm text-foreground",
5471
- unread ? "font-bold" : "font-semibold"
5472
- ),
5473
- children: userDisplayName(peer)
5474
- }
5475
- ),
5546
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 items-center gap-1.5", children: [
5547
+ /* @__PURE__ */ jsxRuntime.jsx(
5548
+ "span",
5549
+ {
5550
+ className: chunkZBZKHBDS_cjs.cn(
5551
+ "truncate text-sm text-foreground",
5552
+ unread ? "font-bold" : "font-semibold"
5553
+ ),
5554
+ children: userDisplayName(peer)
5555
+ }
5556
+ ),
5557
+ c.badge ?? (isAgentUser(peer) ? /* @__PURE__ */ jsxRuntime.jsx(AgentBadge, {}) : null)
5558
+ ] }),
5476
5559
  c.statusLabel ? /* @__PURE__ */ jsxRuntime.jsx(
5477
5560
  chunkZBZKHBDS_cjs.Badge,
5478
5561
  {
@@ -6931,14 +7014,6 @@ function DocumentGallery({
6931
7014
  );
6932
7015
  }
6933
7016
 
6934
- Object.defineProperty(exports, "ArbiProvider", {
6935
- enumerable: true,
6936
- get: function () { return chunkZMTLGO3K_cjs.ArbiProvider; }
6937
- });
6938
- Object.defineProperty(exports, "useArbi", {
6939
- enumerable: true,
6940
- get: function () { return chunkZMTLGO3K_cjs.useArbi; }
6941
- });
6942
7017
  Object.defineProperty(exports, "AiMarkdown", {
6943
7018
  enumerable: true,
6944
7019
  get: function () { return chunkZBZKHBDS_cjs.AiMarkdown; }
@@ -7363,6 +7438,14 @@ Object.defineProperty(exports, "toggleVariants", {
7363
7438
  enumerable: true,
7364
7439
  get: function () { return chunkZBZKHBDS_cjs.toggleVariants; }
7365
7440
  });
7441
+ Object.defineProperty(exports, "ArbiProvider", {
7442
+ enumerable: true,
7443
+ get: function () { return chunkZMTLGO3K_cjs.ArbiProvider; }
7444
+ });
7445
+ Object.defineProperty(exports, "useArbi", {
7446
+ enumerable: true,
7447
+ get: function () { return chunkZMTLGO3K_cjs.useArbi; }
7448
+ });
7366
7449
  Object.defineProperty(exports, "Arbi", {
7367
7450
  enumerable: true,
7368
7451
  get: function () { return browser.Arbi; }
@@ -7380,6 +7463,7 @@ Object.defineProperty(exports, "toast", {
7380
7463
  get: function () { return sonner.toast; }
7381
7464
  });
7382
7465
  exports.ActivityFeed = ActivityFeed;
7466
+ exports.AgentBadge = AgentBadge;
7383
7467
  exports.AiActionCard = AiActionCard;
7384
7468
  exports.AiAnswer = AiAnswer;
7385
7469
  exports.AppleIcon = AppleIcon;
@@ -7437,6 +7521,7 @@ exports.OpenAIIcon = OpenAIIcon;
7437
7521
  exports.PLACEHOLDER_COLOR = PLACEHOLDER_COLOR;
7438
7522
  exports.PassageCard = PassageCard;
7439
7523
  exports.PdfIcon = PdfIcon;
7524
+ exports.PresenceLabel = PresenceLabel;
7440
7525
  exports.ProjectEntity = ProjectEntity;
7441
7526
  exports.ProviderIcon = ProviderIcon;
7442
7527
  exports.RUN_WINDOW_MS = RUN_WINDOW_MS;