@nextclaw/agent-chat-ui 0.2.4 → 0.2.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 +45 -39
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1255,30 +1255,9 @@ var ChatComposerSurfaceRenderer = class {
|
|
|
1255
1255
|
element.className = this.buildTokenClassName(node.tokenKind, isSelected);
|
|
1256
1256
|
element.append(this.createTokenIcon(node.tokenKind));
|
|
1257
1257
|
const label = document.createElement("span");
|
|
1258
|
-
label.className = node.tokenKind === "file" ? "min-w-0 flex-1 truncate text-[12px] font-medium text-slate-
|
|
1258
|
+
label.className = node.tokenKind === "file" ? "min-w-0 flex-1 truncate text-[12px] font-medium text-slate-700" : "truncate";
|
|
1259
1259
|
label.textContent = node.label;
|
|
1260
1260
|
element.append(label);
|
|
1261
|
-
if (node.tokenKind === "file") {
|
|
1262
|
-
const badge = document.createElement("span");
|
|
1263
|
-
badge.className = [
|
|
1264
|
-
"hidden",
|
|
1265
|
-
"shrink-0",
|
|
1266
|
-
"rounded-md",
|
|
1267
|
-
"border",
|
|
1268
|
-
"border-sky-100",
|
|
1269
|
-
"bg-sky-50",
|
|
1270
|
-
"px-1.5",
|
|
1271
|
-
"py-0.5",
|
|
1272
|
-
"text-[9px]",
|
|
1273
|
-
"font-semibold",
|
|
1274
|
-
"uppercase",
|
|
1275
|
-
"tracking-[0.12em]",
|
|
1276
|
-
"text-sky-700",
|
|
1277
|
-
"sm:inline-flex"
|
|
1278
|
-
].join(" ");
|
|
1279
|
-
badge.textContent = this.resolveFileBadgeLabel(node.label);
|
|
1280
|
-
element.append(badge);
|
|
1281
|
-
}
|
|
1282
1261
|
return element;
|
|
1283
1262
|
};
|
|
1284
1263
|
this.buildTokenClassName = (tokenKind, isSelected) => {
|
|
@@ -1286,19 +1265,17 @@ var ChatComposerSurfaceRenderer = class {
|
|
|
1286
1265
|
return [
|
|
1287
1266
|
"mx-[2px]",
|
|
1288
1267
|
"inline-flex",
|
|
1289
|
-
"h-
|
|
1290
|
-
"max-w-[min(100%,
|
|
1268
|
+
"h-7",
|
|
1269
|
+
"max-w-[min(100%,17rem)]",
|
|
1291
1270
|
"items-center",
|
|
1292
|
-
"gap-
|
|
1293
|
-
"rounded-
|
|
1271
|
+
"gap-1.5",
|
|
1272
|
+
"rounded-lg",
|
|
1294
1273
|
"border",
|
|
1295
1274
|
"px-2",
|
|
1296
|
-
"pr-2.5",
|
|
1297
1275
|
"align-baseline",
|
|
1298
|
-
"shadow-[0_1px_2px_rgba(15,23,42,0.06)]",
|
|
1299
1276
|
"transition-[border-color,background-color,box-shadow,color]",
|
|
1300
1277
|
"duration-150",
|
|
1301
|
-
isSelected ? "border-
|
|
1278
|
+
isSelected ? "border-slate-300 bg-slate-100 text-slate-800 shadow-[0_0_0_2px_rgba(148,163,184,0.14)]" : "border-slate-200/80 bg-slate-50 text-slate-700"
|
|
1302
1279
|
].join(" ");
|
|
1303
1280
|
}
|
|
1304
1281
|
return [
|
|
@@ -1320,7 +1297,7 @@ var ChatComposerSurfaceRenderer = class {
|
|
|
1320
1297
|
};
|
|
1321
1298
|
this.createTokenIcon = (tokenKind) => {
|
|
1322
1299
|
const wrapper = document.createElement("span");
|
|
1323
|
-
wrapper.className = tokenKind === "file" ? "inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-
|
|
1300
|
+
wrapper.className = tokenKind === "file" ? "inline-flex h-4.5 w-4.5 shrink-0 items-center justify-center rounded-md bg-white text-slate-500 ring-1 ring-black/5" : "inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-primary/70";
|
|
1324
1301
|
wrapper.append(tokenKind === "file" ? this.createFileIcon() : this.createSkillIcon());
|
|
1325
1302
|
return wrapper;
|
|
1326
1303
|
};
|
|
@@ -1339,10 +1316,6 @@ var ChatComposerSurfaceRenderer = class {
|
|
|
1339
1316
|
{ tag: "path", attrs: { d: "M9.75 6.25h.01" } }
|
|
1340
1317
|
]);
|
|
1341
1318
|
};
|
|
1342
|
-
this.resolveFileBadgeLabel = (label) => {
|
|
1343
|
-
const match = /\.([a-z0-9]+)$/i.exec(label.trim());
|
|
1344
|
-
return match?.[1]?.slice(0, 4).toUpperCase() || "IMG";
|
|
1345
|
-
};
|
|
1346
1319
|
this.createSvgIcon = (children) => {
|
|
1347
1320
|
const svg = document.createElementNS(SVG_NAMESPACE, "svg");
|
|
1348
1321
|
svg.setAttribute("viewBox", "0 0 16 16");
|
|
@@ -1709,8 +1682,21 @@ var ChatComposerRuntime = class {
|
|
|
1709
1682
|
if (!this.rootElement) {
|
|
1710
1683
|
return;
|
|
1711
1684
|
}
|
|
1685
|
+
const targetSelection = this.selection;
|
|
1712
1686
|
this.rootElement.focus();
|
|
1713
|
-
|
|
1687
|
+
const restoreSelection2 = () => {
|
|
1688
|
+
if (!this.rootElement) {
|
|
1689
|
+
return;
|
|
1690
|
+
}
|
|
1691
|
+
this.selection = targetSelection;
|
|
1692
|
+
this.selectedRange = targetSelection;
|
|
1693
|
+
this.viewController.restoreSelectionIfFocused(this.rootElement, targetSelection);
|
|
1694
|
+
};
|
|
1695
|
+
if (typeof requestAnimationFrame === "function") {
|
|
1696
|
+
requestAnimationFrame(restoreSelection2);
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
restoreSelection2();
|
|
1714
1700
|
};
|
|
1715
1701
|
this.requireConfig = () => {
|
|
1716
1702
|
if (!this.config) {
|
|
@@ -2204,10 +2190,30 @@ function ChatMessageMarkdown(props) {
|
|
|
2204
2190
|
import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2205
2191
|
function ChatMessageFile({ file }) {
|
|
2206
2192
|
if (file.isImage && file.dataUrl) {
|
|
2207
|
-
return /* @__PURE__ */
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2193
|
+
return /* @__PURE__ */ jsx15(
|
|
2194
|
+
"img",
|
|
2195
|
+
{
|
|
2196
|
+
src: file.dataUrl,
|
|
2197
|
+
alt: file.label,
|
|
2198
|
+
className: "block max-h-80 max-w-full rounded-2xl object-contain"
|
|
2199
|
+
}
|
|
2200
|
+
);
|
|
2201
|
+
}
|
|
2202
|
+
if (file.dataUrl) {
|
|
2203
|
+
return /* @__PURE__ */ jsxs8(
|
|
2204
|
+
"a",
|
|
2205
|
+
{
|
|
2206
|
+
href: file.dataUrl,
|
|
2207
|
+
download: file.label,
|
|
2208
|
+
target: "_blank",
|
|
2209
|
+
rel: "noreferrer",
|
|
2210
|
+
className: "block rounded-2xl border border-black/8 bg-black/6 px-3 py-2 text-sm transition hover:bg-black/8",
|
|
2211
|
+
children: [
|
|
2212
|
+
/* @__PURE__ */ jsx15("div", { className: "font-medium", children: file.label }),
|
|
2213
|
+
/* @__PURE__ */ jsx15("div", { className: "text-xs opacity-75", children: file.mimeType })
|
|
2214
|
+
]
|
|
2215
|
+
}
|
|
2216
|
+
);
|
|
2211
2217
|
}
|
|
2212
2218
|
return /* @__PURE__ */ jsxs8("div", { className: "rounded-2xl border border-black/8 bg-black/6 px-3 py-2 text-sm", children: [
|
|
2213
2219
|
/* @__PURE__ */ jsx15("div", { className: "font-medium", children: file.label }),
|