@ash-cloud/ash-ui 0.2.0 → 0.2.1
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 +97 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -14
- package/dist/index.d.ts +43 -14
- package/dist/index.js +96 -15
- package/dist/index.js.map +1 -1
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +52 -1
- package/dist/types.d.ts +52 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -569,6 +569,61 @@ function LazyMarkdown({ children, fallback, components, className }) {
|
|
|
569
569
|
}
|
|
570
570
|
return /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx("span", { className, children: fallback ?? children }), children: /* @__PURE__ */ jsxRuntime.jsx(ReactMarkdown, { components: markdownComponents, children }) });
|
|
571
571
|
}
|
|
572
|
+
function Mention({ name, color, url }) {
|
|
573
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
574
|
+
"span",
|
|
575
|
+
{
|
|
576
|
+
className: cn(
|
|
577
|
+
"ash-mention",
|
|
578
|
+
"inline-flex items-center",
|
|
579
|
+
"px-1.5 py-0.5 rounded",
|
|
580
|
+
"text-[var(--ash-font-size-sm,12px)]",
|
|
581
|
+
"font-medium"
|
|
582
|
+
),
|
|
583
|
+
style: {
|
|
584
|
+
backgroundColor: color ? `${color}20` : "var(--ash-mention-bg,rgba(255,255,255,0.1))",
|
|
585
|
+
color: color || "var(--ash-mention-text,inherit)"
|
|
586
|
+
},
|
|
587
|
+
children: [
|
|
588
|
+
url && /* @__PURE__ */ jsxRuntime.jsx(
|
|
589
|
+
"img",
|
|
590
|
+
{
|
|
591
|
+
src: url,
|
|
592
|
+
alt: "",
|
|
593
|
+
className: "w-4 h-4 rounded mr-1 object-cover"
|
|
594
|
+
}
|
|
595
|
+
),
|
|
596
|
+
"@",
|
|
597
|
+
name
|
|
598
|
+
]
|
|
599
|
+
}
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
function RichContentRenderer({
|
|
603
|
+
content,
|
|
604
|
+
components,
|
|
605
|
+
className
|
|
606
|
+
}) {
|
|
607
|
+
const MentionComponent = components?.mention || Mention;
|
|
608
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("ash-rich-content", className), children: content.map((segment, index) => {
|
|
609
|
+
if (segment.type === "text") {
|
|
610
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LazyMarkdown, { components, children: segment.content }, index);
|
|
611
|
+
}
|
|
612
|
+
if (segment.type === "mention") {
|
|
613
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
614
|
+
MentionComponent,
|
|
615
|
+
{
|
|
616
|
+
name: segment.name,
|
|
617
|
+
color: segment.color,
|
|
618
|
+
url: segment.url,
|
|
619
|
+
data: segment.data
|
|
620
|
+
},
|
|
621
|
+
index
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
return null;
|
|
625
|
+
}) });
|
|
626
|
+
}
|
|
572
627
|
var MessageContext = react.createContext(null);
|
|
573
628
|
function useMessage() {
|
|
574
629
|
const context = react.useContext(MessageContext);
|
|
@@ -681,10 +736,26 @@ function MessageContent({ children, className }) {
|
|
|
681
736
|
}
|
|
682
737
|
function MessageResponse({
|
|
683
738
|
content,
|
|
739
|
+
richContent,
|
|
684
740
|
isStreaming,
|
|
685
741
|
className,
|
|
686
742
|
components
|
|
687
743
|
}) {
|
|
744
|
+
if (richContent && richContent.length > 0) {
|
|
745
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
746
|
+
"div",
|
|
747
|
+
{
|
|
748
|
+
className: cn(
|
|
749
|
+
"ash-message-response",
|
|
750
|
+
"font-[var(--ash-font-size-base,13px)]",
|
|
751
|
+
"leading-relaxed",
|
|
752
|
+
isStreaming && "animate-pulse",
|
|
753
|
+
className
|
|
754
|
+
),
|
|
755
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(RichContentRenderer, { content: richContent, components })
|
|
756
|
+
}
|
|
757
|
+
);
|
|
758
|
+
}
|
|
688
759
|
if (!content) return null;
|
|
689
760
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
690
761
|
"div",
|
|
@@ -760,6 +831,7 @@ function MessageTimestamp({ timestamp, className }) {
|
|
|
760
831
|
}
|
|
761
832
|
function StatusIndicator({ status, size = "sm", className }) {
|
|
762
833
|
const sizeClasses = {
|
|
834
|
+
xs: "w-1.5 h-1.5",
|
|
763
835
|
sm: "w-2 h-2",
|
|
764
836
|
md: "w-3 h-3",
|
|
765
837
|
lg: "w-4 h-4"
|
|
@@ -1138,14 +1210,16 @@ function Tool({
|
|
|
1138
1210
|
toolInvocation,
|
|
1139
1211
|
children,
|
|
1140
1212
|
className,
|
|
1141
|
-
defaultExpanded = false
|
|
1213
|
+
defaultExpanded = false,
|
|
1214
|
+
variant = "default"
|
|
1142
1215
|
}) {
|
|
1143
1216
|
const [isExpanded, setIsExpanded] = react.useState(defaultExpanded);
|
|
1144
1217
|
const toggleExpanded = () => setIsExpanded((prev) => !prev);
|
|
1145
1218
|
const contextValue = {
|
|
1146
1219
|
toolInvocation,
|
|
1147
1220
|
isExpanded,
|
|
1148
|
-
toggleExpanded
|
|
1221
|
+
toggleExpanded,
|
|
1222
|
+
variant
|
|
1149
1223
|
};
|
|
1150
1224
|
const status = toolInvocation.state === "result" ? "success" : "pending";
|
|
1151
1225
|
const isErrorResult = Boolean(
|
|
@@ -1181,25 +1255,28 @@ function ToolHeader({
|
|
|
1181
1255
|
icon,
|
|
1182
1256
|
showToggle = true
|
|
1183
1257
|
}) {
|
|
1184
|
-
const { toolInvocation, isExpanded, toggleExpanded } = useTool();
|
|
1258
|
+
const { toolInvocation, isExpanded, toggleExpanded, variant } = useTool();
|
|
1259
|
+
const isCompact = variant === "compact";
|
|
1185
1260
|
const status = toolInvocation.state === "result" ? "success" : "pending";
|
|
1186
1261
|
const formattedName = formatToolName(toolInvocation.toolName);
|
|
1187
1262
|
const toolIcon = icon;
|
|
1263
|
+
const canToggle = showToggle && !isCompact;
|
|
1188
1264
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1189
1265
|
"button",
|
|
1190
1266
|
{
|
|
1191
|
-
onClick:
|
|
1267
|
+
onClick: canToggle ? toggleExpanded : void 0,
|
|
1192
1268
|
className: cn(
|
|
1193
1269
|
"ash-tool-header",
|
|
1194
1270
|
"w-full flex items-center gap-2",
|
|
1195
|
-
"px-3 py-2",
|
|
1271
|
+
isCompact ? "px-2 py-1.5" : "px-3 py-2",
|
|
1196
1272
|
"text-left",
|
|
1197
|
-
|
|
1273
|
+
canToggle && "cursor-pointer hover:bg-white/[0.03] transition-colors",
|
|
1274
|
+
!canToggle && "cursor-default",
|
|
1198
1275
|
className
|
|
1199
1276
|
),
|
|
1200
1277
|
children: [
|
|
1201
|
-
/* @__PURE__ */ jsxRuntime.jsx(StatusIndicator, { status, size: "sm" }),
|
|
1202
|
-
toolIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[var(--ash-text-muted,rgba(255,255,255,0.5))]", children: toolIcon }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[var(--ash-text-muted,rgba(255,255,255,0.5))]", children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: [
|
|
1278
|
+
/* @__PURE__ */ jsxRuntime.jsx(StatusIndicator, { status, size: isCompact ? "xs" : "sm" }),
|
|
1279
|
+
toolIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[var(--ash-text-muted,rgba(255,255,255,0.5))]", children: toolIcon }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[var(--ash-text-muted,rgba(255,255,255,0.5))]", children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: isCompact ? "w-3 h-3" : "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: [
|
|
1203
1280
|
/* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" }),
|
|
1204
1281
|
/* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z" })
|
|
1205
1282
|
] }) }),
|
|
@@ -1208,7 +1285,7 @@ function ToolHeader({
|
|
|
1208
1285
|
{
|
|
1209
1286
|
className: cn(
|
|
1210
1287
|
"flex-1 font-medium",
|
|
1211
|
-
"text-[var(--ash-font-size-sm,12px)]",
|
|
1288
|
+
isCompact ? "text-[var(--ash-font-size-xs,10px)]" : "text-[var(--ash-font-size-sm,12px)]",
|
|
1212
1289
|
"text-[var(--ash-text-primary,rgba(255,255,255,0.9))]"
|
|
1213
1290
|
),
|
|
1214
1291
|
children: formattedName
|
|
@@ -1218,14 +1295,14 @@ function ToolHeader({
|
|
|
1218
1295
|
"span",
|
|
1219
1296
|
{
|
|
1220
1297
|
className: cn(
|
|
1221
|
-
"text-[var(--ash-font-size-xs,10px)]",
|
|
1298
|
+
isCompact ? "text-[9px]" : "text-[var(--ash-font-size-xs,10px)]",
|
|
1222
1299
|
"text-[var(--ash-text-muted,rgba(255,255,255,0.5))]",
|
|
1223
1300
|
"truncate max-w-[200px]"
|
|
1224
1301
|
),
|
|
1225
1302
|
children: Object.keys(toolInvocation.args).length > 0 && `(${Object.keys(toolInvocation.args).join(", ")})`
|
|
1226
1303
|
}
|
|
1227
1304
|
),
|
|
1228
|
-
|
|
1305
|
+
canToggle && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1229
1306
|
"svg",
|
|
1230
1307
|
{
|
|
1231
1308
|
className: cn(
|
|
@@ -1321,24 +1398,28 @@ function ToolOutput({ className, maxHeight = 300 }) {
|
|
|
1321
1398
|
function ToolList({
|
|
1322
1399
|
toolInvocations,
|
|
1323
1400
|
className,
|
|
1324
|
-
defaultExpanded = false
|
|
1401
|
+
defaultExpanded = false,
|
|
1402
|
+
variant = "default"
|
|
1325
1403
|
}) {
|
|
1326
1404
|
if (!toolInvocations || toolInvocations.length === 0) {
|
|
1327
1405
|
return null;
|
|
1328
1406
|
}
|
|
1407
|
+
const isCompact = variant === "compact";
|
|
1329
1408
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1330
1409
|
"div",
|
|
1331
1410
|
{
|
|
1332
1411
|
className: cn(
|
|
1333
1412
|
"ash-tool-list",
|
|
1334
|
-
"flex flex-col
|
|
1413
|
+
"flex flex-col",
|
|
1414
|
+
isCompact ? "gap-1" : "gap-2",
|
|
1335
1415
|
className
|
|
1336
1416
|
),
|
|
1337
1417
|
children: toolInvocations.map((inv) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1338
1418
|
Tool,
|
|
1339
1419
|
{
|
|
1340
1420
|
toolInvocation: inv,
|
|
1341
|
-
defaultExpanded
|
|
1421
|
+
defaultExpanded,
|
|
1422
|
+
variant
|
|
1342
1423
|
},
|
|
1343
1424
|
inv.toolCallId
|
|
1344
1425
|
))
|
|
@@ -4266,6 +4347,7 @@ exports.LoaderIcon = LoaderIcon;
|
|
|
4266
4347
|
exports.LoadingDots = LoadingDots;
|
|
4267
4348
|
exports.LoadingSpinner = LoadingSpinner;
|
|
4268
4349
|
exports.LogsPanel = LogsPanel;
|
|
4350
|
+
exports.Mention = Mention;
|
|
4269
4351
|
exports.Message = Message;
|
|
4270
4352
|
exports.MessageAction = MessageAction;
|
|
4271
4353
|
exports.MessageActions = MessageActions;
|
|
@@ -4283,6 +4365,7 @@ exports.PlugIcon = PlugIcon;
|
|
|
4283
4365
|
exports.Reasoning = Reasoning;
|
|
4284
4366
|
exports.ReasoningContent = ReasoningContent;
|
|
4285
4367
|
exports.ReasoningTrigger = ReasoningTrigger;
|
|
4368
|
+
exports.RichContentRenderer = RichContentRenderer;
|
|
4286
4369
|
exports.SearchIcon = SearchIcon;
|
|
4287
4370
|
exports.SendIcon = SendIcon;
|
|
4288
4371
|
exports.Shimmer = Shimmer;
|