@copilotz/chat-ui 0.9.4 → 0.9.6

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,26 +1245,46 @@ 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 ? isEditing ? "ml-auto flex w-full max-w-[min(42rem,85%)] flex-col rounded-xl border bg-background p-2 text-foreground shadow-sm" : "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
  {
1251
1253
  value: editContent,
1252
1254
  onChange: (e) => setEditContent(e.target.value),
1253
- className: "min-h-[100px] resize-none",
1255
+ className: "min-h-28 resize-y bg-muted/30 text-sm leading-6",
1254
1256
  autoFocus: true
1255
1257
  }
1256
1258
  ),
1257
- /* @__PURE__ */ jsxs5("div", { className: "flex gap-2 justify-end", children: [
1258
- /* @__PURE__ */ jsxs5(Button, { variant: "outline", size: "sm", onClick: handleCancelEdit, children: [
1259
- /* @__PURE__ */ jsx9(X, { className: "h-4 w-4 mr-1" }),
1260
- "Cancelar"
1261
- ] }),
1262
- /* @__PURE__ */ jsxs5(Button, { size: "sm", onClick: handleEdit, children: [
1263
- /* @__PURE__ */ jsx9(Check, { className: "h-4 w-4 mr-1" }),
1264
- "Salvar"
1265
- ] })
1259
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-end gap-2", children: [
1260
+ /* @__PURE__ */ jsxs5(
1261
+ Button,
1262
+ {
1263
+ type: "button",
1264
+ variant: "ghost",
1265
+ size: "sm",
1266
+ className: "h-8",
1267
+ onClick: handleCancelEdit,
1268
+ children: [
1269
+ /* @__PURE__ */ jsx9(X, { className: "h-4 w-4 mr-1" }),
1270
+ labels?.cancel || "Cancel"
1271
+ ]
1272
+ }
1273
+ ),
1274
+ /* @__PURE__ */ jsxs5(
1275
+ Button,
1276
+ {
1277
+ type: "button",
1278
+ size: "sm",
1279
+ className: "h-8",
1280
+ onClick: handleEdit,
1281
+ disabled: !editContent.trim() || editContent.trim() === message.content,
1282
+ children: [
1283
+ /* @__PURE__ */ jsx9(Check, { className: "h-4 w-4 mr-1" }),
1284
+ "Save"
1285
+ ]
1286
+ }
1287
+ )
1266
1288
  ] })
1267
1289
  ] }) : /* @__PURE__ */ jsxs5(Fragment2, { children: [
1268
1290
  !messageIsUser && /* @__PURE__ */ jsx9(
@@ -1297,49 +1319,44 @@ var Message = memo2(({
1297
1319
  }
1298
1320
  ) }),
1299
1321
  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
- ] }) })
1322
+ ] }) }),
1323
+ !isEditing && (enableCopy || canEdit) && /* @__PURE__ */ jsxs5(
1324
+ "div",
1325
+ {
1326
+ className: `mt-1 flex h-7 items-center gap-1 text-muted-foreground transition-opacity duration-150 ${messageIsUser ? "justify-end" : "justify-start"} ${showActions || actionsFocused || copied ? "opacity-100" : "pointer-events-none opacity-0"}`,
1327
+ children: [
1328
+ canEdit && /* @__PURE__ */ jsxs5(Tooltip, { children: [
1329
+ /* @__PURE__ */ jsx9(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx9(
1330
+ Button,
1331
+ {
1332
+ type: "button",
1333
+ variant: "ghost",
1334
+ size: "icon",
1335
+ className: "h-7 w-7",
1336
+ onClick: handleEdit,
1337
+ children: /* @__PURE__ */ jsx9(Edit, { className: "h-3.5 w-3.5" })
1338
+ }
1339
+ ) }),
1340
+ /* @__PURE__ */ jsx9(TooltipContent, { children: labels?.editMessage || "Edit" })
1341
+ ] }),
1342
+ enableCopy && /* @__PURE__ */ jsxs5(Tooltip, { children: [
1343
+ /* @__PURE__ */ jsx9(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx9(
1344
+ Button,
1345
+ {
1346
+ type: "button",
1347
+ variant: "ghost",
1348
+ size: "icon",
1349
+ className: "h-7 w-7",
1350
+ onClick: handleCopy,
1351
+ 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" })
1352
+ }
1353
+ ) }),
1354
+ /* @__PURE__ */ jsx9(TooltipContent, { children: copied ? "Copied" : labels?.copyMessage || "Copy" })
1355
+ ] })
1356
+ ]
1357
+ }
1358
+ )
1359
+ ] })
1343
1360
  ]
1344
1361
  }
1345
1362
  );
@@ -2611,6 +2628,33 @@ var ThreadTagEditorBadge = ({
2611
2628
  }
2612
2629
  );
2613
2630
  };
2631
+ var ThreadTagOptionButton = ({
2632
+ tag,
2633
+ assigned,
2634
+ onClick
2635
+ }) => {
2636
+ const color = tagColor(tag);
2637
+ return /* @__PURE__ */ jsxs11(
2638
+ Button,
2639
+ {
2640
+ type: "button",
2641
+ variant: "outline",
2642
+ size: "sm",
2643
+ disabled: assigned,
2644
+ className: "gap-1.5 border font-medium disabled:opacity-70",
2645
+ style: {
2646
+ backgroundColor: color.background,
2647
+ borderColor: color.border,
2648
+ color: color.accent
2649
+ },
2650
+ onClick,
2651
+ children: [
2652
+ /* @__PURE__ */ jsx18(TagDot, { tag }),
2653
+ tag.name
2654
+ ]
2655
+ }
2656
+ );
2657
+ };
2614
2658
  var Sidebar2 = ({
2615
2659
  threads,
2616
2660
  currentThreadId,
@@ -3094,14 +3138,11 @@ var Sidebar2 = ({
3094
3138
  (threadTag) => threadTag.id === tag.id
3095
3139
  );
3096
3140
  return /* @__PURE__ */ jsx18(
3097
- Button,
3141
+ ThreadTagOptionButton,
3098
3142
  {
3099
- type: "button",
3100
- variant: assigned ? "secondary" : "outline",
3101
- size: "sm",
3102
- disabled: assigned,
3103
- onClick: () => addTagToThread(tagDialogThread, tag),
3104
- children: tag.name
3143
+ tag,
3144
+ assigned,
3145
+ onClick: () => addTagToThread(tagDialogThread, tag)
3105
3146
  },
3106
3147
  tag.id
3107
3148
  );