@nextclaw/agent-chat-ui 0.3.8 → 0.3.10
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 +39 -37
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -360,7 +360,7 @@ function ChatInputBarActions({ sendError, sendErrorDetailsLabel, isSending, canS
|
|
|
360
360
|
const sendErrorPreview = normalizedSendError ? buildSendErrorPreview(normalizedSendError) : "";
|
|
361
361
|
const resolvedSendErrorDetailsLabel = sendErrorDetailsLabel?.trim() || "Details";
|
|
362
362
|
return /* @__PURE__ */ jsxs("div", {
|
|
363
|
-
className: "flex flex-col items-end gap-1",
|
|
363
|
+
className: "flex shrink-0 flex-col items-end gap-1",
|
|
364
364
|
children: [normalizedSendError ? /* @__PURE__ */ jsxs("div", {
|
|
365
365
|
className: "flex max-w-[420px] items-start justify-end gap-2 text-right",
|
|
366
366
|
children: [/* @__PURE__ */ jsx("div", {
|
|
@@ -507,12 +507,16 @@ function ChatInputBarSkillPicker(props) {
|
|
|
507
507
|
children: /* @__PURE__ */ jsxs("button", {
|
|
508
508
|
type: "button",
|
|
509
509
|
"aria-haspopup": "listbox",
|
|
510
|
-
|
|
510
|
+
"aria-label": picker.title,
|
|
511
|
+
className: "relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg px-0 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 sm:w-auto sm:gap-1.5 sm:px-3",
|
|
511
512
|
children: [
|
|
512
513
|
/* @__PURE__ */ jsx(BrainCircuit, { className: "h-4 w-4" }),
|
|
513
|
-
/* @__PURE__ */ jsx("span", {
|
|
514
|
+
/* @__PURE__ */ jsx("span", {
|
|
515
|
+
className: "hidden sm:inline",
|
|
516
|
+
children: picker.title
|
|
517
|
+
}),
|
|
514
518
|
selectedCount > 0 ? /* @__PURE__ */ jsx("span", {
|
|
515
|
-
className: "
|
|
519
|
+
className: "absolute -right-1 -top-1 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold leading-none text-white shadow-sm sm:static sm:ml-0.5 sm:bg-primary/10 sm:text-primary sm:shadow-none",
|
|
516
520
|
children: selectedCount
|
|
517
521
|
}) : null
|
|
518
522
|
]
|
|
@@ -637,9 +641,8 @@ function AccessoryIcon({ icon }) {
|
|
|
637
641
|
return /* @__PURE__ */ jsx(ToolbarIcon, { icon });
|
|
638
642
|
}
|
|
639
643
|
function resolveTriggerWidth(key) {
|
|
640
|
-
if (key === "model") return "min-w-
|
|
641
|
-
if (key === "session-type") return "
|
|
642
|
-
if (key === "thinking") return "min-w-[150px]";
|
|
644
|
+
if (key === "model") return "min-w-0 flex-1";
|
|
645
|
+
if (key === "session-type" || key === "thinking") return "shrink-0";
|
|
643
646
|
return "";
|
|
644
647
|
}
|
|
645
648
|
function resolveContentWidth(key) {
|
|
@@ -660,7 +663,7 @@ function ToolbarSelect({ item }) {
|
|
|
660
663
|
onValueChange: item.onValueChange,
|
|
661
664
|
disabled: item.disabled,
|
|
662
665
|
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
663
|
-
className: `h-8 w-auto rounded-lg border-0 bg-transparent px-
|
|
666
|
+
className: `h-8 w-auto rounded-lg border-0 bg-transparent px-2 text-xs font-medium text-gray-600 shadow-none hover:bg-gray-100 focus:ring-0 sm:px-3 ${resolveTriggerWidth(item.key)}`,
|
|
664
667
|
children: item.selectedLabel ? /* @__PURE__ */ jsxs("div", {
|
|
665
668
|
className: "flex min-w-0 items-center gap-2 text-left",
|
|
666
669
|
children: [/* @__PURE__ */ jsx(ToolbarIcon, { icon: item.icon }), /* @__PURE__ */ jsx("span", {
|
|
@@ -700,16 +703,16 @@ function ToolbarSelect({ item }) {
|
|
|
700
703
|
})]
|
|
701
704
|
});
|
|
702
705
|
}
|
|
703
|
-
function ChatInputBarToolbar(
|
|
706
|
+
function ChatInputBarToolbar({ actions, accessories, selects, skillPicker }) {
|
|
704
707
|
const { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } = ChatUiPrimitives;
|
|
705
708
|
return /* @__PURE__ */ jsxs("div", {
|
|
706
|
-
className: "flex items-center justify-between px-3 pb-3",
|
|
709
|
+
className: "flex items-center justify-between gap-2 px-3 pb-3",
|
|
707
710
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
708
|
-
className: "flex items-center gap-1",
|
|
711
|
+
className: "flex min-w-0 flex-1 items-center gap-1 overflow-hidden",
|
|
709
712
|
children: [
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
+
skillPicker ? /* @__PURE__ */ jsx(ChatInputBarSkillPicker, { picker: skillPicker }) : null,
|
|
714
|
+
selects.map((item) => /* @__PURE__ */ jsx(ToolbarSelect, { item }, item.key)),
|
|
715
|
+
accessories?.map((item) => {
|
|
713
716
|
const button = /* @__PURE__ */ jsxs("button", {
|
|
714
717
|
type: "button",
|
|
715
718
|
className: `inline-flex items-center rounded-lg py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:text-gray-400 ${item.iconOnly ? "h-8 w-8 justify-center px-0" : "gap-1.5 px-3"}`,
|
|
@@ -734,7 +737,7 @@ function ChatInputBarToolbar(props) {
|
|
|
734
737
|
})] }) }, item.key);
|
|
735
738
|
})
|
|
736
739
|
]
|
|
737
|
-
}), /* @__PURE__ */ jsx(ChatInputBarActions, { ...
|
|
740
|
+
}), /* @__PURE__ */ jsx(ChatInputBarActions, { ...actions })]
|
|
738
741
|
});
|
|
739
742
|
}
|
|
740
743
|
function createComposerNodeId() {
|
|
@@ -1216,8 +1219,8 @@ function readChatComposerSnapshotFromEditorState(editorState) {
|
|
|
1216
1219
|
return {
|
|
1217
1220
|
nodes,
|
|
1218
1221
|
selection: {
|
|
1219
|
-
start: getOffsetFromPoint(selection.anchor),
|
|
1220
|
-
end: getOffsetFromPoint(selection.focus)
|
|
1222
|
+
start: Math.min(getOffsetFromPoint(selection.anchor), getOffsetFromPoint(selection.focus)),
|
|
1223
|
+
end: Math.max(getOffsetFromPoint(selection.anchor), getOffsetFromPoint(selection.focus))
|
|
1221
1224
|
}
|
|
1222
1225
|
};
|
|
1223
1226
|
});
|
|
@@ -1275,9 +1278,10 @@ function getDocumentLength(nodes) {
|
|
|
1275
1278
|
function insertToken(params) {
|
|
1276
1279
|
const { label, nodes, selection, tokenKey, tokenKind, trigger } = params;
|
|
1277
1280
|
const documentLength = getDocumentLength(nodes);
|
|
1278
|
-
const
|
|
1281
|
+
const [selectionStart, selectionEnd] = selection ? [Math.min(selection.start, selection.end), Math.max(selection.start, selection.end)] : [documentLength, documentLength];
|
|
1282
|
+
const replaceStart = trigger?.start ?? selectionStart;
|
|
1279
1283
|
return {
|
|
1280
|
-
nodes: replaceChatComposerRange(nodes, replaceStart, trigger?.end ??
|
|
1284
|
+
nodes: replaceChatComposerRange(nodes, replaceStart, trigger?.end ?? selectionEnd, [createChatComposerTokenNode({
|
|
1281
1285
|
label,
|
|
1282
1286
|
tokenKey,
|
|
1283
1287
|
tokenKind
|
|
@@ -1293,13 +1297,11 @@ function getChatComposerNodesSignature(nodes) {
|
|
|
1293
1297
|
}
|
|
1294
1298
|
function replaceChatComposerSelectionWithText(params) {
|
|
1295
1299
|
const { nodes, selection, text } = params;
|
|
1296
|
-
const
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
};
|
|
1300
|
-
const nextOffset = currentSelection.start + text.length;
|
|
1300
|
+
const documentLength = getDocumentLength(nodes);
|
|
1301
|
+
const [selectionStart, selectionEnd] = selection ? [Math.min(selection.start, selection.end), Math.max(selection.start, selection.end)] : [documentLength, documentLength];
|
|
1302
|
+
const nextOffset = selectionStart + text.length;
|
|
1301
1303
|
return {
|
|
1302
|
-
nodes: replaceChatComposerRange(nodes,
|
|
1304
|
+
nodes: replaceChatComposerRange(nodes, selectionStart, selectionEnd, [createChatComposerTextNode(text)]),
|
|
1303
1305
|
selection: {
|
|
1304
1306
|
start: nextOffset,
|
|
1305
1307
|
end: nextOffset
|
|
@@ -1355,17 +1357,17 @@ function syncSelectedSkillsIntoChatComposer(params) {
|
|
|
1355
1357
|
function deleteChatComposerContent(params) {
|
|
1356
1358
|
const { direction, nodes, selection: currentSelection } = params;
|
|
1357
1359
|
const documentLength = getDocumentLength(nodes);
|
|
1358
|
-
const
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
let rangeEnd = selection.end;
|
|
1364
|
-
if (selection.start === selection.end) if (direction === "backward" && selection.start > 0) rangeStart = selection.start - 1;
|
|
1365
|
-
else if (direction === "forward" && selection.end < documentLength) rangeEnd = selection.end + 1;
|
|
1360
|
+
const [selectionStart, selectionEnd] = currentSelection ? [Math.min(currentSelection.start, currentSelection.end), Math.max(currentSelection.start, currentSelection.end)] : [documentLength, documentLength];
|
|
1361
|
+
let rangeStart = selectionStart;
|
|
1362
|
+
let rangeEnd = selectionEnd;
|
|
1363
|
+
if (rangeStart === rangeEnd) if (direction === "backward" && rangeStart > 0) rangeStart -= 1;
|
|
1364
|
+
else if (direction === "forward" && rangeEnd < documentLength) rangeEnd += 1;
|
|
1366
1365
|
else return {
|
|
1367
1366
|
nodes: normalizeChatComposerNodes(nodes),
|
|
1368
|
-
selection
|
|
1367
|
+
selection: {
|
|
1368
|
+
start: rangeStart,
|
|
1369
|
+
end: rangeEnd
|
|
1370
|
+
}
|
|
1369
1371
|
};
|
|
1370
1372
|
return {
|
|
1371
1373
|
nodes: replaceChatComposerRange(nodes, rangeStart, rangeEnd, []),
|
|
@@ -1701,9 +1703,9 @@ const ChatInputBarTokenizedComposer = forwardRef(function ChatInputBarTokenizedC
|
|
|
1701
1703
|
}), [props.disabled, props.nodes]),
|
|
1702
1704
|
children: [
|
|
1703
1705
|
/* @__PURE__ */ jsx("div", {
|
|
1704
|
-
className: "px-4 py-2.5",
|
|
1706
|
+
className: "px-3 py-2 sm:px-4 sm:py-2.5",
|
|
1705
1707
|
children: /* @__PURE__ */ jsx("div", {
|
|
1706
|
-
className: "min-h-[60px]",
|
|
1708
|
+
className: "min-h-11 sm:min-h-[60px]",
|
|
1707
1709
|
children: /* @__PURE__ */ jsx(PlainTextPlugin, {
|
|
1708
1710
|
contentEditable: /* @__PURE__ */ jsx(ContentEditable, {
|
|
1709
1711
|
className: "min-h-7 max-h-[188px] w-full overflow-y-auto whitespace-pre-wrap break-words bg-transparent py-0.5 text-sm leading-6 text-gray-800 outline-none",
|
|
@@ -1741,7 +1743,7 @@ const ChatInputBarTokenizedComposer = forwardRef(function ChatInputBarTokenizedC
|
|
|
1741
1743
|
}
|
|
1742
1744
|
}),
|
|
1743
1745
|
placeholder: /* @__PURE__ */ jsx("div", {
|
|
1744
|
-
className: "pointer-events-none absolute left-
|
|
1746
|
+
className: "pointer-events-none absolute left-3 top-2 select-none text-sm leading-6 text-gray-400 sm:left-4 sm:top-2.5",
|
|
1745
1747
|
children: props.placeholder
|
|
1746
1748
|
}),
|
|
1747
1749
|
ErrorBoundary: LexicalErrorBoundary
|