@copilotz/chat-ui 0.9.3 → 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.cjs +165 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +165 -95
- package/dist/index.js.map +1 -1
- package/dist/styles.css +0 -33
- package/package.json +1 -1
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__ */
|
|
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(
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
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
|
);
|
|
@@ -2461,14 +2458,6 @@ var ThreadInitialsIcon = ({ title }) => {
|
|
|
2461
2458
|
const initials = title?.split(" ").map((n) => n[0]).slice(0, 2).join("").toUpperCase() || "?";
|
|
2462
2459
|
return /* @__PURE__ */ jsx18("div", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded bg-muted text-[10px] font-medium text-muted-foreground", children: initials });
|
|
2463
2460
|
};
|
|
2464
|
-
var TAG_COLOR_CLASSES = [
|
|
2465
|
-
"bg-sky-500",
|
|
2466
|
-
"bg-emerald-500",
|
|
2467
|
-
"bg-violet-500",
|
|
2468
|
-
"bg-amber-500",
|
|
2469
|
-
"bg-rose-500",
|
|
2470
|
-
"bg-cyan-500"
|
|
2471
|
-
];
|
|
2472
2461
|
function slugTagName(name) {
|
|
2473
2462
|
const slug = name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48);
|
|
2474
2463
|
return slug || "tag";
|
|
@@ -2500,31 +2489,125 @@ function collectThreadTags(threads) {
|
|
|
2500
2489
|
}
|
|
2501
2490
|
return tags.sort((a, b) => a.name.localeCompare(b.name));
|
|
2502
2491
|
}
|
|
2503
|
-
function
|
|
2492
|
+
function normalizeTagColorKey(tag) {
|
|
2493
|
+
return (tag.name || tag.id || "tag").trim().toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g, "");
|
|
2494
|
+
}
|
|
2495
|
+
function hashTagColorKey(value) {
|
|
2504
2496
|
let hash = 0;
|
|
2505
|
-
for (const char of
|
|
2497
|
+
for (const char of value) {
|
|
2506
2498
|
hash = hash * 31 + char.charCodeAt(0) >>> 0;
|
|
2507
2499
|
}
|
|
2508
|
-
return hash
|
|
2500
|
+
return hash;
|
|
2509
2501
|
}
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2502
|
+
function hslToRgb(hue, saturation, lightness) {
|
|
2503
|
+
const chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
|
|
2504
|
+
const x = chroma * (1 - Math.abs(hue / 60 % 2 - 1));
|
|
2505
|
+
const match = lightness - chroma / 2;
|
|
2506
|
+
let red = 0;
|
|
2507
|
+
let green = 0;
|
|
2508
|
+
let blue = 0;
|
|
2509
|
+
if (hue < 60) {
|
|
2510
|
+
red = chroma;
|
|
2511
|
+
green = x;
|
|
2512
|
+
} else if (hue < 120) {
|
|
2513
|
+
red = x;
|
|
2514
|
+
green = chroma;
|
|
2515
|
+
} else if (hue < 180) {
|
|
2516
|
+
green = chroma;
|
|
2517
|
+
blue = x;
|
|
2518
|
+
} else if (hue < 240) {
|
|
2519
|
+
green = x;
|
|
2520
|
+
blue = chroma;
|
|
2521
|
+
} else if (hue < 300) {
|
|
2522
|
+
red = x;
|
|
2523
|
+
blue = chroma;
|
|
2524
|
+
} else {
|
|
2525
|
+
red = chroma;
|
|
2526
|
+
blue = x;
|
|
2515
2527
|
}
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2528
|
+
return {
|
|
2529
|
+
red: Math.round((red + match) * 255),
|
|
2530
|
+
green: Math.round((green + match) * 255),
|
|
2531
|
+
blue: Math.round((blue + match) * 255)
|
|
2532
|
+
};
|
|
2533
|
+
}
|
|
2534
|
+
function tagColor(tag) {
|
|
2535
|
+
if (tag.color) {
|
|
2536
|
+
return {
|
|
2537
|
+
accent: tag.color,
|
|
2538
|
+
background: `color-mix(in srgb, ${tag.color} 12%, transparent)`,
|
|
2539
|
+
border: `color-mix(in srgb, ${tag.color} 24%, transparent)`
|
|
2540
|
+
};
|
|
2526
2541
|
}
|
|
2527
|
-
);
|
|
2542
|
+
const hue = hashTagColorKey(normalizeTagColorKey(tag)) % 360;
|
|
2543
|
+
const { red, green, blue } = hslToRgb(hue, 0.68, 0.48);
|
|
2544
|
+
return {
|
|
2545
|
+
accent: `rgb(${red} ${green} ${blue})`,
|
|
2546
|
+
background: `rgb(${red} ${green} ${blue} / 0.12)`,
|
|
2547
|
+
border: `rgb(${red} ${green} ${blue} / 0.24)`
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2550
|
+
var TagDot = ({ tag }) => {
|
|
2551
|
+
const color = tagColor(tag);
|
|
2552
|
+
return /* @__PURE__ */ jsx18(
|
|
2553
|
+
"span",
|
|
2554
|
+
{
|
|
2555
|
+
"aria-hidden": "true",
|
|
2556
|
+
className: "h-2 w-2 shrink-0 rounded-full",
|
|
2557
|
+
style: { backgroundColor: color.accent }
|
|
2558
|
+
}
|
|
2559
|
+
);
|
|
2560
|
+
};
|
|
2561
|
+
var ThreadTagBadge = ({ tag }) => {
|
|
2562
|
+
const color = tagColor(tag);
|
|
2563
|
+
return /* @__PURE__ */ jsxs11(
|
|
2564
|
+
Badge,
|
|
2565
|
+
{
|
|
2566
|
+
variant: "secondary",
|
|
2567
|
+
className: "h-4 max-w-24 gap-1 rounded border px-1.5 py-0 text-[10px] font-normal text-muted-foreground",
|
|
2568
|
+
style: {
|
|
2569
|
+
backgroundColor: color.background,
|
|
2570
|
+
borderColor: color.border
|
|
2571
|
+
},
|
|
2572
|
+
children: [
|
|
2573
|
+
/* @__PURE__ */ jsx18(TagDot, { tag }),
|
|
2574
|
+
/* @__PURE__ */ jsx18("span", { className: "truncate", children: tag.name })
|
|
2575
|
+
]
|
|
2576
|
+
}
|
|
2577
|
+
);
|
|
2578
|
+
};
|
|
2579
|
+
var ThreadTagEditorBadge = ({
|
|
2580
|
+
tag,
|
|
2581
|
+
removeLabel,
|
|
2582
|
+
onRemove
|
|
2583
|
+
}) => {
|
|
2584
|
+
const color = tagColor(tag);
|
|
2585
|
+
return /* @__PURE__ */ jsxs11(
|
|
2586
|
+
Badge,
|
|
2587
|
+
{
|
|
2588
|
+
variant: "secondary",
|
|
2589
|
+
className: "gap-1 rounded-md border py-1 text-sm font-normal",
|
|
2590
|
+
style: {
|
|
2591
|
+
backgroundColor: color.background,
|
|
2592
|
+
borderColor: color.border
|
|
2593
|
+
},
|
|
2594
|
+
children: [
|
|
2595
|
+
/* @__PURE__ */ jsx18(TagDot, { tag }),
|
|
2596
|
+
tag.name,
|
|
2597
|
+
/* @__PURE__ */ jsx18(
|
|
2598
|
+
"button",
|
|
2599
|
+
{
|
|
2600
|
+
type: "button",
|
|
2601
|
+
className: "rounded-sm hover:bg-background/80",
|
|
2602
|
+
onClick: onRemove,
|
|
2603
|
+
"aria-label": removeLabel,
|
|
2604
|
+
children: /* @__PURE__ */ jsx18(X2, { className: "h-3 w-3" })
|
|
2605
|
+
}
|
|
2606
|
+
)
|
|
2607
|
+
]
|
|
2608
|
+
}
|
|
2609
|
+
);
|
|
2610
|
+
};
|
|
2528
2611
|
var Sidebar2 = ({
|
|
2529
2612
|
threads,
|
|
2530
2613
|
currentThreadId,
|
|
@@ -2991,25 +3074,12 @@ var Sidebar2 = ({
|
|
|
2991
3074
|
/* @__PURE__ */ jsxs11("div", { className: "space-y-4", children: [
|
|
2992
3075
|
/* @__PURE__ */ jsxs11("div", { className: "space-y-2", children: [
|
|
2993
3076
|
/* @__PURE__ */ jsx18("div", { className: "text-sm font-medium", children: config.labels?.tags || "Tags" }),
|
|
2994
|
-
(tagDialogThread.tags ?? []).length === 0 ? /* @__PURE__ */ jsx18("p", { className: "text-sm text-muted-foreground", children: config.labels?.untagged || "Untagged" }) : /* @__PURE__ */ jsx18("div", { className: "flex flex-wrap gap-2", children: (tagDialogThread.tags ?? []).map((tag) => /* @__PURE__ */
|
|
2995
|
-
|
|
3077
|
+
(tagDialogThread.tags ?? []).length === 0 ? /* @__PURE__ */ jsx18("p", { className: "text-sm text-muted-foreground", children: config.labels?.untagged || "Untagged" }) : /* @__PURE__ */ jsx18("div", { className: "flex flex-wrap gap-2", children: (tagDialogThread.tags ?? []).map((tag) => /* @__PURE__ */ jsx18(
|
|
3078
|
+
ThreadTagEditorBadge,
|
|
2996
3079
|
{
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
/* @__PURE__ */ jsx18(TagDot, { tag }),
|
|
3001
|
-
tag.name,
|
|
3002
|
-
/* @__PURE__ */ jsx18(
|
|
3003
|
-
"button",
|
|
3004
|
-
{
|
|
3005
|
-
type: "button",
|
|
3006
|
-
className: "rounded-sm hover:bg-background/80",
|
|
3007
|
-
onClick: () => removeTagFromThread(tagDialogThread, tag.id),
|
|
3008
|
-
"aria-label": config.labels?.removeTag || "Remove tag",
|
|
3009
|
-
children: /* @__PURE__ */ jsx18(X2, { className: "h-3 w-3" })
|
|
3010
|
-
}
|
|
3011
|
-
)
|
|
3012
|
-
]
|
|
3080
|
+
tag,
|
|
3081
|
+
removeLabel: config.labels?.removeTag || "Remove tag",
|
|
3082
|
+
onRemove: () => removeTagFromThread(tagDialogThread, tag.id)
|
|
3013
3083
|
},
|
|
3014
3084
|
tag.id
|
|
3015
3085
|
)) })
|