@copilotz/chat-ui 0.9.4 → 0.9.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.js CHANGED
@@ -810,7 +810,6 @@ var MessageSenderAvatar = ({
810
810
  import {
811
811
  Copy,
812
812
  Edit,
813
- RotateCcw,
814
813
  Check,
815
814
  X,
816
815
  Download,
@@ -1153,6 +1152,7 @@ var Message = memo2(({
1153
1152
  const [isEditing, setIsEditing] = useState2(false);
1154
1153
  const [editContent, setEditContent] = useState2(message.content);
1155
1154
  const [showActions, setShowActions] = useState2(false);
1155
+ const [actionsFocused, setActionsFocused] = useState2(false);
1156
1156
  const [copied, setCopied] = useState2(false);
1157
1157
  const messageIsUser = isUser ?? message.role === "user";
1158
1158
  if (!hasRenderableAssistantBody(message)) {
@@ -1166,7 +1166,6 @@ var Message = memo2(({
1166
1166
  compactMode
1167
1167
  });
1168
1168
  const canEdit = enableEdit && messageIsUser;
1169
- const canRegenerate = enableRegenerate && !messageIsUser;
1170
1169
  const normalizedPreviewChars = Math.max(longMessagePreviewChars, 1);
1171
1170
  const normalizedChunkChars = Math.max(longMessageChunkChars, 1);
1172
1171
  const previewOverride = typeof message.metadata?.previewContent === "string" ? message.metadata.previewContent : void 0;
@@ -1200,9 +1199,6 @@ var Message = memo2(({
1200
1199
  setEditContent(message.content);
1201
1200
  setIsEditing(false);
1202
1201
  };
1203
- const handleRegenerate = () => {
1204
- onAction?.({ action: "regenerate", messageId: message.id });
1205
- };
1206
1202
  const handleToggleExpanded = () => {
1207
1203
  onToggleExpanded?.(message.id);
1208
1204
  };
@@ -1218,6 +1214,12 @@ var Message = memo2(({
1218
1214
  className: `flex w-full flex-col ${className} max-w-[800px] mx-auto`,
1219
1215
  onMouseEnter: () => setShowActions(true),
1220
1216
  onMouseLeave: () => setShowActions(false),
1217
+ onFocusCapture: () => setActionsFocused(true),
1218
+ onBlurCapture: (event) => {
1219
+ if (!event.currentTarget.contains(event.relatedTarget)) {
1220
+ setActionsFocused(false);
1221
+ }
1222
+ },
1221
1223
  children: [
1222
1224
  /* @__PURE__ */ jsxs5("div", { className: `flex gap-3 ${messageIsUser ? "flex-row-reverse" : "flex-row"} w-full mb-1`, children: [
1223
1225
  showAvatar && /* @__PURE__ */ jsx9("div", { className: `flex-shrink-0 ${compactMode ? "mt-1" : "mt-0"}`, children: /* @__PURE__ */ jsx9(
@@ -1243,8 +1245,8 @@ var Message = memo2(({
1243
1245
  message.isEdited && /* @__PURE__ */ jsx9(Badge, { variant: "outline", className: "text-xs", children: "editado" })
1244
1246
  ] })
1245
1247
  ] }),
1246
- /* @__PURE__ */ jsx9("div", { className: `flex-1 min-w-0 ${messageIsUser ? "text-right" : "text-left"} ${horizontalOffsetClass}`, children: /* @__PURE__ */ jsxs5("div", { className: `relative overflow-hidden text-left ${messageIsUser ? "ml-auto inline-flex max-w-[85%] flex-col rounded-lg bg-primary p-3 text-primary-foreground" : "flex w-full max-w-full flex-col"}`, children: [
1247
- isEditing ? /* @__PURE__ */ jsxs5("div", { className: "space-y-2", children: [
1248
+ /* @__PURE__ */ jsxs5("div", { className: `flex-1 min-w-0 ${messageIsUser ? "text-right" : "text-left"} ${horizontalOffsetClass}`, children: [
1249
+ /* @__PURE__ */ jsx9("div", { className: `relative overflow-hidden text-left ${messageIsUser ? "ml-auto inline-flex max-w-[85%] flex-col rounded-lg bg-primary p-3 text-primary-foreground" : "flex w-full max-w-full flex-col"}`, children: isEditing ? /* @__PURE__ */ jsxs5("div", { className: "space-y-2", children: [
1248
1250
  /* @__PURE__ */ jsx9(
1249
1251
  Textarea,
1250
1252
  {
@@ -1297,49 +1299,44 @@ var Message = memo2(({
1297
1299
  }
1298
1300
  ) }),
1299
1301
  message.attachments && message.attachments.length > 0 && /* @__PURE__ */ jsx9("div", { className: "mt-3 space-y-2", children: message.attachments.map((attachment, index) => /* @__PURE__ */ jsx9(MediaRenderer, { attachment }, index)) })
1300
- ] }),
1301
- !isEditing && (showActions || copied) && /* @__PURE__ */ jsxs5("div", { className: `absolute -top-2 flex gap-1 ${messageIsUser ? "-left-2" : "-right-2"}`, children: [
1302
- enableCopy && /* @__PURE__ */ jsxs5(Tooltip, { children: [
1303
- /* @__PURE__ */ jsx9(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx9(
1304
- Button,
1305
- {
1306
- variant: "secondary",
1307
- size: "icon",
1308
- className: "h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity",
1309
- onClick: handleCopy,
1310
- children: copied ? /* @__PURE__ */ jsx9(Check, { className: "h-3 w-3 text-green-500" }) : /* @__PURE__ */ jsx9(Copy, { className: "h-3 w-3" })
1311
- }
1312
- ) }),
1313
- /* @__PURE__ */ jsx9(TooltipContent, { children: copied ? "Copiado!" : "Copiar" })
1314
- ] }),
1315
- canEdit && /* @__PURE__ */ jsxs5(Tooltip, { children: [
1316
- /* @__PURE__ */ jsx9(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx9(
1317
- Button,
1318
- {
1319
- variant: "secondary",
1320
- size: "icon",
1321
- className: "h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity",
1322
- onClick: handleEdit,
1323
- children: /* @__PURE__ */ jsx9(Edit, { className: "h-3 w-3" })
1324
- }
1325
- ) }),
1326
- /* @__PURE__ */ jsx9(TooltipContent, { children: "Editar" })
1327
- ] }),
1328
- canRegenerate && /* @__PURE__ */ jsxs5(Tooltip, { children: [
1329
- /* @__PURE__ */ jsx9(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx9(
1330
- Button,
1331
- {
1332
- variant: "secondary",
1333
- size: "icon",
1334
- className: "h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity",
1335
- onClick: handleRegenerate,
1336
- children: /* @__PURE__ */ jsx9(RotateCcw, { className: "h-3 w-3" })
1337
- }
1338
- ) }),
1339
- /* @__PURE__ */ jsx9(TooltipContent, { children: "Regenerar" })
1340
- ] })
1341
- ] })
1342
- ] }) })
1302
+ ] }) }),
1303
+ !isEditing && (showActions || actionsFocused || copied) && (enableCopy || canEdit) && /* @__PURE__ */ jsxs5(
1304
+ "div",
1305
+ {
1306
+ className: `mt-1 flex items-center gap-1 text-muted-foreground transition-opacity ${messageIsUser ? "justify-end" : "justify-start"}`,
1307
+ children: [
1308
+ canEdit && /* @__PURE__ */ jsxs5(Tooltip, { children: [
1309
+ /* @__PURE__ */ jsx9(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx9(
1310
+ Button,
1311
+ {
1312
+ type: "button",
1313
+ variant: "ghost",
1314
+ size: "icon",
1315
+ className: "h-7 w-7",
1316
+ onClick: handleEdit,
1317
+ children: /* @__PURE__ */ jsx9(Edit, { className: "h-3.5 w-3.5" })
1318
+ }
1319
+ ) }),
1320
+ /* @__PURE__ */ jsx9(TooltipContent, { children: labels?.editMessage || "Edit" })
1321
+ ] }),
1322
+ enableCopy && /* @__PURE__ */ jsxs5(Tooltip, { children: [
1323
+ /* @__PURE__ */ jsx9(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx9(
1324
+ Button,
1325
+ {
1326
+ type: "button",
1327
+ variant: "ghost",
1328
+ size: "icon",
1329
+ className: "h-7 w-7",
1330
+ onClick: handleCopy,
1331
+ children: copied ? /* @__PURE__ */ jsx9(Check, { className: "h-3.5 w-3.5 text-green-500" }) : /* @__PURE__ */ jsx9(Copy, { className: "h-3.5 w-3.5" })
1332
+ }
1333
+ ) }),
1334
+ /* @__PURE__ */ jsx9(TooltipContent, { children: copied ? "Copied" : labels?.copyMessage || "Copy" })
1335
+ ] })
1336
+ ]
1337
+ }
1338
+ )
1339
+ ] })
1343
1340
  ]
1344
1341
  }
1345
1342
  );