@timbal-ai/timbal-react 1.0.0 → 1.2.0
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/CHANGELOG.md +35 -0
- package/README.md +55 -8
- package/dist/app.cjs +2369 -1189
- package/dist/app.d.cts +8 -4
- package/dist/app.d.ts +8 -4
- package/dist/app.esm.js +32 -7
- package/dist/{chart-artifact-DOkwSTjQ.d.cts → chart-artifact-E58ve76I.d.cts} +279 -12
- package/dist/{chart-artifact-CBo9x8Ch.d.ts → chart-artifact-_PEJgCpQ.d.ts} +279 -12
- package/dist/{chat-Bed4FQSl.d.cts → chat-ClmzWzCX.d.cts} +33 -4
- package/dist/{chat-Bed4FQSl.d.ts → chat-ClmzWzCX.d.ts} +33 -4
- package/dist/chat.cjs +1446 -776
- package/dist/chat.d.cts +1 -1
- package/dist/chat.d.ts +1 -1
- package/dist/chat.esm.js +3 -3
- package/dist/{chunk-YEFBANNF.esm.js → chunk-4VULP3CJ.esm.js} +242 -288
- package/dist/{chunk-RZ6QC6RG.esm.js → chunk-AGJKK6R7.esm.js} +2 -2
- package/dist/{chunk-FOD67Z6G.esm.js → chunk-BMXFXLVV.esm.js} +341 -12
- package/dist/chunk-FEYZUVBM.esm.js +52 -0
- package/dist/{chunk-C6IXFM4T.esm.js → chunk-MTYXREHK.esm.js} +4 -4
- package/dist/{chunk-AYHOVAMI.esm.js → chunk-NAMKO2MU.esm.js} +1 -1
- package/dist/{chunk-SNLXVG7H.esm.js → chunk-UY7AKWJL.esm.js} +1108 -656
- package/dist/{chunk-GLPOVYEA.esm.js → chunk-XDIY2WSL.esm.js} +669 -279
- package/dist/index.cjs +2967 -1824
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.esm.js +41 -11
- package/dist/pill-segmented-tabs-BsIOW1Lo.d.cts +528 -0
- package/dist/pill-segmented-tabs-BsIOW1Lo.d.ts +528 -0
- package/dist/studio.cjs +1685 -1015
- package/dist/studio.d.cts +2 -2
- package/dist/studio.d.ts +2 -2
- package/dist/studio.esm.js +5 -5
- package/dist/styles.css +24 -0
- package/dist/ui.cjs +387 -49
- package/dist/ui.d.cts +71 -491
- package/dist/ui.d.ts +71 -491
- package/dist/ui.esm.js +26 -6
- package/dist/{welcome-COOb05a5.d.cts → welcome-BFGRoNfK.d.cts} +1 -1
- package/dist/{welcome-DE08m9ca.d.ts → welcome-DXqsGTwH.d.ts} +1 -1
- package/package.json +7 -3
- package/vite/local-dev.d.ts +5 -1
- package/vite/local-dev.mjs +17 -13
package/dist/chat.cjs
CHANGED
|
@@ -910,10 +910,10 @@ function findParentIdFromAuiParent(messages, auiParentId) {
|
|
|
910
910
|
}
|
|
911
911
|
|
|
912
912
|
// src/chat/thread.tsx
|
|
913
|
-
var
|
|
914
|
-
var
|
|
913
|
+
var import_react30 = require("react");
|
|
914
|
+
var import_react31 = require("@assistant-ui/react");
|
|
915
915
|
var import_lucide_react8 = require("lucide-react");
|
|
916
|
-
var
|
|
916
|
+
var import_react32 = require("motion/react");
|
|
917
917
|
|
|
918
918
|
// src/chat/attachment.tsx
|
|
919
919
|
var import_react5 = require("react");
|
|
@@ -1070,6 +1070,33 @@ var TIMBAL_V2_SHADOW = {
|
|
|
1070
1070
|
ghost: "",
|
|
1071
1071
|
link: ""
|
|
1072
1072
|
};
|
|
1073
|
+
var TIMBAL_V2_PRIMARY_SURFACE = cn(
|
|
1074
|
+
TIMBAL_V2_PRIMARY_GRADIENT,
|
|
1075
|
+
TIMBAL_V2_SHADOW.primary,
|
|
1076
|
+
TIMBAL_V2_BORDER.primary
|
|
1077
|
+
);
|
|
1078
|
+
var TIMBAL_V2_PRIMARY_PILL_ROOT = cn(
|
|
1079
|
+
"relative box-border inline-flex items-center justify-center overflow-hidden rounded-full border-0 bg-transparent p-0 font-normal shadow-none transition duration-200 ease-in-out",
|
|
1080
|
+
TIMBAL_V2_SHADOW.primary,
|
|
1081
|
+
TIMBAL_V2_BORDER.primary
|
|
1082
|
+
);
|
|
1083
|
+
var TIMBAL_V2_PRIMARY_PILL_FILL_LAYER = cn(
|
|
1084
|
+
"pointer-events-none absolute inset-0 transition duration-200 ease-in-out",
|
|
1085
|
+
"bg-gradient-to-b from-primary-fill-from to-primary-fill-to",
|
|
1086
|
+
"group-hover/avatar:from-primary-fill-hover-from group-hover/avatar:to-primary-fill-hover-to",
|
|
1087
|
+
"group-active/avatar:from-primary-fill-active-from group-active/avatar:to-primary-fill-active-to"
|
|
1088
|
+
);
|
|
1089
|
+
var TIMBAL_V2_SECONDARY_PILL_ROOT = cn(
|
|
1090
|
+
"relative box-border inline-flex items-center justify-center overflow-hidden rounded-full bg-transparent p-0 font-normal shadow-none transition duration-200 ease-in-out",
|
|
1091
|
+
TIMBAL_V2_SHADOW.secondary,
|
|
1092
|
+
TIMBAL_V2_BORDER.secondary
|
|
1093
|
+
);
|
|
1094
|
+
var TIMBAL_V2_SECONDARY_PILL_FILL_LAYER = cn(
|
|
1095
|
+
"pointer-events-none absolute inset-0 transition duration-200 ease-in-out",
|
|
1096
|
+
TIMBAL_V2_ELEVATED_GRADIENT,
|
|
1097
|
+
"group-hover/avatar:from-secondary-fill-hover-from group-hover/avatar:to-secondary-fill-hover-to",
|
|
1098
|
+
"group-active/avatar:from-secondary-fill-active-from group-active/avatar:to-secondary-fill-active-to"
|
|
1099
|
+
);
|
|
1073
1100
|
var TIMBAL_V2_SWITCH_TRACK_OFF = cn(
|
|
1074
1101
|
TIMBAL_V2_ELEVATED_GRADIENT,
|
|
1075
1102
|
"border border-border shadow-card"
|
|
@@ -1179,25 +1206,71 @@ function DialogTitle({
|
|
|
1179
1206
|
}
|
|
1180
1207
|
|
|
1181
1208
|
// src/ui/avatar.tsx
|
|
1209
|
+
var React = __toESM(require("react"), 1);
|
|
1182
1210
|
var import_radix_ui3 = require("radix-ui");
|
|
1183
1211
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1212
|
+
var AVATAR_PRIMARY_FALLBACK_CLASS = cn(
|
|
1213
|
+
TIMBAL_V2_SECONDARY_PILL_ROOT,
|
|
1214
|
+
TIMBAL_V2_LABEL.secondary,
|
|
1215
|
+
"font-medium"
|
|
1216
|
+
);
|
|
1217
|
+
var AVATAR_SECONDARY_FILL_STYLE = {
|
|
1218
|
+
backgroundImage: "linear-gradient(to bottom, var(--elevated-from), var(--elevated-to))"
|
|
1219
|
+
};
|
|
1220
|
+
var AvatarChromeContext = React.createContext(
|
|
1221
|
+
null
|
|
1222
|
+
);
|
|
1223
|
+
function useAvatarChrome() {
|
|
1224
|
+
return React.useContext(AvatarChromeContext);
|
|
1225
|
+
}
|
|
1226
|
+
function isBrandedVariant(variant) {
|
|
1227
|
+
return variant === "secondary" || variant === "primary" || variant === "chart";
|
|
1228
|
+
}
|
|
1229
|
+
var AVATAR_SIZE_CLASS = {
|
|
1230
|
+
default: "size-8",
|
|
1231
|
+
sm: "size-6",
|
|
1232
|
+
lg: "size-10"
|
|
1233
|
+
};
|
|
1184
1234
|
function Avatar({
|
|
1185
1235
|
className,
|
|
1186
1236
|
size = "default",
|
|
1237
|
+
variant: rootVariant,
|
|
1238
|
+
children,
|
|
1187
1239
|
...props
|
|
1188
1240
|
}) {
|
|
1189
|
-
|
|
1241
|
+
const [chrome, setChrome] = React.useState(rootVariant ?? "muted");
|
|
1242
|
+
React.useLayoutEffect(() => {
|
|
1243
|
+
if (rootVariant !== void 0) {
|
|
1244
|
+
setChrome(rootVariant);
|
|
1245
|
+
}
|
|
1246
|
+
}, [rootVariant]);
|
|
1247
|
+
const branded = isBrandedVariant(chrome);
|
|
1248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AvatarChromeContext.Provider, { value: { chrome, setChrome }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1190
1249
|
import_radix_ui3.Avatar.Root,
|
|
1191
1250
|
{
|
|
1192
1251
|
"data-slot": "avatar",
|
|
1193
1252
|
"data-size": size,
|
|
1253
|
+
"data-variant": branded ? "secondary" : chrome,
|
|
1194
1254
|
className: cn(
|
|
1195
|
-
"group/avatar relative
|
|
1255
|
+
"group/avatar relative shrink-0 select-none",
|
|
1256
|
+
AVATAR_SIZE_CLASS[size],
|
|
1257
|
+
branded ? TIMBAL_V2_SECONDARY_PILL_ROOT : "flex overflow-hidden rounded-full",
|
|
1196
1258
|
className
|
|
1197
1259
|
),
|
|
1198
|
-
...props
|
|
1260
|
+
...props,
|
|
1261
|
+
children: [
|
|
1262
|
+
branded ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1263
|
+
"span",
|
|
1264
|
+
{
|
|
1265
|
+
"aria-hidden": true,
|
|
1266
|
+
className: TIMBAL_V2_SECONDARY_PILL_FILL_LAYER,
|
|
1267
|
+
style: AVATAR_SECONDARY_FILL_STYLE
|
|
1268
|
+
}
|
|
1269
|
+
) : null,
|
|
1270
|
+
children
|
|
1271
|
+
]
|
|
1199
1272
|
}
|
|
1200
|
-
);
|
|
1273
|
+
) });
|
|
1201
1274
|
}
|
|
1202
1275
|
function AvatarImage({
|
|
1203
1276
|
className,
|
|
@@ -1207,24 +1280,44 @@ function AvatarImage({
|
|
|
1207
1280
|
import_radix_ui3.Avatar.Image,
|
|
1208
1281
|
{
|
|
1209
1282
|
"data-slot": "avatar-image",
|
|
1210
|
-
className: cn(
|
|
1283
|
+
className: cn(
|
|
1284
|
+
"relative z-10 aspect-square size-full rounded-full object-cover",
|
|
1285
|
+
className
|
|
1286
|
+
),
|
|
1211
1287
|
...props
|
|
1212
1288
|
}
|
|
1213
1289
|
);
|
|
1214
1290
|
}
|
|
1215
1291
|
function AvatarFallback({
|
|
1216
1292
|
className,
|
|
1293
|
+
variant = "muted",
|
|
1294
|
+
seed: _seed,
|
|
1295
|
+
children,
|
|
1296
|
+
style,
|
|
1217
1297
|
...props
|
|
1218
1298
|
}) {
|
|
1299
|
+
const chromeCtx = useAvatarChrome();
|
|
1300
|
+
React.useLayoutEffect(() => {
|
|
1301
|
+
chromeCtx?.setChrome(variant);
|
|
1302
|
+
}, [chromeCtx, variant]);
|
|
1303
|
+
const branded = isBrandedVariant(variant);
|
|
1219
1304
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1220
1305
|
import_radix_ui3.Avatar.Fallback,
|
|
1221
1306
|
{
|
|
1222
1307
|
"data-slot": "avatar-fallback",
|
|
1308
|
+
"data-variant": branded ? "secondary" : variant,
|
|
1223
1309
|
className: cn(
|
|
1224
|
-
"
|
|
1310
|
+
"relative z-10 flex size-full items-center justify-center rounded-full",
|
|
1311
|
+
branded ? cn(
|
|
1312
|
+
"bg-transparent font-medium",
|
|
1313
|
+
TIMBAL_V2_LABEL.secondary,
|
|
1314
|
+
"text-sm group-data-[size=sm]/avatar:text-xs"
|
|
1315
|
+
) : "bg-muted font-normal text-muted-foreground text-sm group-data-[size=sm]/avatar:text-xs",
|
|
1225
1316
|
className
|
|
1226
1317
|
),
|
|
1227
|
-
|
|
1318
|
+
style,
|
|
1319
|
+
...props,
|
|
1320
|
+
children
|
|
1228
1321
|
}
|
|
1229
1322
|
);
|
|
1230
1323
|
}
|
|
@@ -1233,7 +1326,7 @@ function AvatarFallback({
|
|
|
1233
1326
|
var import_react4 = require("react");
|
|
1234
1327
|
|
|
1235
1328
|
// src/ui/timbal-v2-button.tsx
|
|
1236
|
-
var
|
|
1329
|
+
var React2 = __toESM(require("react"), 1);
|
|
1237
1330
|
var import_radix_ui4 = require("radix-ui");
|
|
1238
1331
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1239
1332
|
var TIMBAL_V2_FILL_AS_CHILD = {
|
|
@@ -1269,7 +1362,7 @@ var TIMBAL_V2_LABEL_AS_CHILD = {
|
|
|
1269
1362
|
...TIMBAL_V2_LABEL,
|
|
1270
1363
|
link: "text-foreground underline decoration-foreground/25 underline-offset-2 hover:decoration-foreground/45"
|
|
1271
1364
|
};
|
|
1272
|
-
var TimbalV2Button =
|
|
1365
|
+
var TimbalV2Button = React2.forwardRef(function TimbalV2Button2({
|
|
1273
1366
|
variant = "secondary",
|
|
1274
1367
|
size = "sm",
|
|
1275
1368
|
isIconOnly = false,
|
|
@@ -1534,131 +1627,329 @@ var import_react_markdown = require("@assistant-ui/react-markdown");
|
|
|
1534
1627
|
var import_remark_gfm = __toESM(require("remark-gfm"), 1);
|
|
1535
1628
|
var import_remark_math = __toESM(require("remark-math"), 1);
|
|
1536
1629
|
var import_rehype_katex = __toESM(require("rehype-katex"), 1);
|
|
1537
|
-
var
|
|
1630
|
+
var import_react20 = require("react");
|
|
1538
1631
|
var import_lucide_react4 = require("lucide-react");
|
|
1539
1632
|
|
|
1540
1633
|
// src/chat/syntax-highlighter.tsx
|
|
1541
|
-
var
|
|
1634
|
+
var import_react19 = require("react");
|
|
1542
1635
|
var import_core = require("shiki/core");
|
|
1543
1636
|
var import_javascript = require("shiki/engine/javascript");
|
|
1544
1637
|
|
|
1545
1638
|
// src/artifacts/registry.tsx
|
|
1546
|
-
var
|
|
1639
|
+
var import_react18 = require("react");
|
|
1547
1640
|
|
|
1548
1641
|
// src/artifacts/chart-artifact.tsx
|
|
1549
|
-
var
|
|
1642
|
+
var import_react10 = require("react");
|
|
1550
1643
|
|
|
1551
1644
|
// src/charts/line-area-chart.tsx
|
|
1552
|
-
var import_react8 = require("react");
|
|
1553
|
-
|
|
1554
|
-
// src/charts/use-chart-width.ts
|
|
1555
1645
|
var import_react7 = require("react");
|
|
1556
|
-
|
|
1557
|
-
const ref = (0, import_react7.useRef)(null);
|
|
1558
|
-
const [width, setWidth] = (0, import_react7.useState)(initial);
|
|
1559
|
-
(0, import_react7.useEffect)(() => {
|
|
1560
|
-
const el = ref.current;
|
|
1561
|
-
if (!el || typeof ResizeObserver === "undefined") return;
|
|
1562
|
-
const ro = new ResizeObserver((entries) => {
|
|
1563
|
-
const w = entries[0]?.contentRect.width;
|
|
1564
|
-
if (w && w > 0) setWidth(w);
|
|
1565
|
-
});
|
|
1566
|
-
ro.observe(el);
|
|
1567
|
-
return () => ro.disconnect();
|
|
1568
|
-
}, []);
|
|
1569
|
-
return { ref, width };
|
|
1570
|
-
}
|
|
1646
|
+
var import_recharts = require("recharts");
|
|
1571
1647
|
|
|
1572
|
-
// src/
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
if (
|
|
1581
|
-
|
|
1582
|
-
return `M ${points[0].x},${points[0].y} L ${points[1].x},${points[1].y}`;
|
|
1583
|
-
}
|
|
1584
|
-
const tangents = monotoneTangents(points);
|
|
1585
|
-
let d = `M ${points[0].x},${points[0].y}`;
|
|
1586
|
-
for (let i = 0; i < n - 1; i++) {
|
|
1587
|
-
const p0 = points[i];
|
|
1588
|
-
const p1 = points[i + 1];
|
|
1589
|
-
const dx = (p1.x - p0.x) / 3;
|
|
1590
|
-
const c1x = p0.x + dx;
|
|
1591
|
-
const c1y = p0.y + dx * tangents[i];
|
|
1592
|
-
const c2x = p1.x - dx;
|
|
1593
|
-
const c2y = p1.y - dx * tangents[i + 1];
|
|
1594
|
-
d += ` C ${c1x},${c1y} ${c2x},${c2y} ${p1.x},${p1.y}`;
|
|
1648
|
+
// src/ui/chart.tsx
|
|
1649
|
+
var React3 = __toESM(require("react"), 1);
|
|
1650
|
+
var RechartsPrimitive = __toESM(require("recharts"), 1);
|
|
1651
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1652
|
+
var THEMES = { light: "", dark: ".dark" };
|
|
1653
|
+
var ChartContext = React3.createContext(null);
|
|
1654
|
+
function useChart() {
|
|
1655
|
+
const context = React3.useContext(ChartContext);
|
|
1656
|
+
if (!context) {
|
|
1657
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
1595
1658
|
}
|
|
1596
|
-
return
|
|
1659
|
+
return context;
|
|
1597
1660
|
}
|
|
1598
|
-
function
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1661
|
+
function ChartContainer({
|
|
1662
|
+
id,
|
|
1663
|
+
className,
|
|
1664
|
+
children,
|
|
1665
|
+
config,
|
|
1666
|
+
...props
|
|
1667
|
+
}) {
|
|
1668
|
+
const uniqueId = React3.useId();
|
|
1669
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
1670
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1671
|
+
"div",
|
|
1672
|
+
{
|
|
1673
|
+
"data-slot": "chart",
|
|
1674
|
+
"data-chart": chartId,
|
|
1675
|
+
className: cn(
|
|
1676
|
+
"[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
1677
|
+
className
|
|
1678
|
+
),
|
|
1679
|
+
...props,
|
|
1680
|
+
children: [
|
|
1681
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChartStyle, { id: chartId, config }),
|
|
1682
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RechartsPrimitive.ResponsiveContainer, { children })
|
|
1683
|
+
]
|
|
1684
|
+
}
|
|
1685
|
+
) });
|
|
1604
1686
|
}
|
|
1605
|
-
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1687
|
+
var ChartStyle = ({ id, config }) => {
|
|
1688
|
+
const colorConfig = Object.entries(config).filter(
|
|
1689
|
+
([, c]) => c.theme || c.color
|
|
1690
|
+
);
|
|
1691
|
+
if (!colorConfig.length) {
|
|
1692
|
+
return null;
|
|
1611
1693
|
}
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1694
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1695
|
+
"style",
|
|
1696
|
+
{
|
|
1697
|
+
dangerouslySetInnerHTML: {
|
|
1698
|
+
__html: Object.entries(THEMES).map(
|
|
1699
|
+
([theme, prefix]) => `
|
|
1700
|
+
${prefix} [data-chart=${id}] {
|
|
1701
|
+
${colorConfig.map(([key, itemConfig]) => {
|
|
1702
|
+
const color = itemConfig.theme?.[theme] || itemConfig.color;
|
|
1703
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
1704
|
+
}).join("\n")}
|
|
1705
|
+
}
|
|
1706
|
+
`
|
|
1707
|
+
).join("\n")
|
|
1708
|
+
}
|
|
1622
1709
|
}
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1710
|
+
);
|
|
1711
|
+
};
|
|
1712
|
+
var ChartTooltip = RechartsPrimitive.Tooltip;
|
|
1713
|
+
function ChartTooltipContent({
|
|
1714
|
+
active,
|
|
1715
|
+
payload,
|
|
1716
|
+
className,
|
|
1717
|
+
indicator = "dot",
|
|
1718
|
+
hideLabel = false,
|
|
1719
|
+
hideIndicator = false,
|
|
1720
|
+
label,
|
|
1721
|
+
labelFormatter,
|
|
1722
|
+
labelClassName,
|
|
1723
|
+
formatter,
|
|
1724
|
+
color,
|
|
1725
|
+
nameKey,
|
|
1726
|
+
labelKey
|
|
1727
|
+
}) {
|
|
1728
|
+
const { config } = useChart();
|
|
1729
|
+
const tooltipLabel = React3.useMemo(() => {
|
|
1730
|
+
if (hideLabel || !payload?.length) {
|
|
1731
|
+
return null;
|
|
1732
|
+
}
|
|
1733
|
+
const [item] = payload;
|
|
1734
|
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
|
|
1735
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
1736
|
+
const value = !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;
|
|
1737
|
+
if (labelFormatter) {
|
|
1738
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
|
|
1630
1739
|
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
const h = Math.hypot(a, b);
|
|
1634
|
-
if (h > 3) {
|
|
1635
|
-
const t = 3 / h;
|
|
1636
|
-
tangents[i] = t * a * s;
|
|
1637
|
-
tangents[i + 1] = t * b * s;
|
|
1740
|
+
if (!value) {
|
|
1741
|
+
return null;
|
|
1638
1742
|
}
|
|
1743
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: cn("font-medium", labelClassName), children: value });
|
|
1744
|
+
}, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
|
|
1745
|
+
if (!active || !payload?.length) {
|
|
1746
|
+
return null;
|
|
1639
1747
|
}
|
|
1640
|
-
|
|
1748
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
1749
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1750
|
+
"div",
|
|
1751
|
+
{
|
|
1752
|
+
className: cn(
|
|
1753
|
+
"border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",
|
|
1754
|
+
"animate-in fade-in-0 zoom-in-95 duration-150",
|
|
1755
|
+
className
|
|
1756
|
+
),
|
|
1757
|
+
children: [
|
|
1758
|
+
!nestLabel ? tooltipLabel : null,
|
|
1759
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "grid gap-1.5", children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
1760
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
1761
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
1762
|
+
const indicatorColor = color || item.payload?.fill || item.color;
|
|
1763
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1764
|
+
"div",
|
|
1765
|
+
{
|
|
1766
|
+
className: cn(
|
|
1767
|
+
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
|
|
1768
|
+
indicator === "dot" && "items-center"
|
|
1769
|
+
),
|
|
1770
|
+
children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
1771
|
+
itemConfig?.icon ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1772
|
+
"div",
|
|
1773
|
+
{
|
|
1774
|
+
className: cn(
|
|
1775
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
1776
|
+
{
|
|
1777
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
1778
|
+
"w-1": indicator === "line",
|
|
1779
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
1780
|
+
"my-0.5": nestLabel && indicator === "dashed"
|
|
1781
|
+
}
|
|
1782
|
+
),
|
|
1783
|
+
style: {
|
|
1784
|
+
"--color-bg": indicatorColor,
|
|
1785
|
+
"--color-border": indicatorColor
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
),
|
|
1789
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1790
|
+
"div",
|
|
1791
|
+
{
|
|
1792
|
+
className: cn(
|
|
1793
|
+
"flex flex-1 justify-between leading-none",
|
|
1794
|
+
nestLabel ? "items-end" : "items-center"
|
|
1795
|
+
),
|
|
1796
|
+
children: [
|
|
1797
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid gap-1.5", children: [
|
|
1798
|
+
nestLabel ? tooltipLabel : null,
|
|
1799
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-muted-foreground", children: itemConfig?.label || item.name })
|
|
1800
|
+
] }),
|
|
1801
|
+
item.value != null && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-foreground font-mono font-medium tabular-nums", children: typeof item.value === "number" ? item.value.toLocaleString() : String(item.value) })
|
|
1802
|
+
]
|
|
1803
|
+
}
|
|
1804
|
+
)
|
|
1805
|
+
] })
|
|
1806
|
+
},
|
|
1807
|
+
`${item.dataKey ?? index}`
|
|
1808
|
+
);
|
|
1809
|
+
}) })
|
|
1810
|
+
]
|
|
1811
|
+
}
|
|
1812
|
+
);
|
|
1641
1813
|
}
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1814
|
+
var ChartLegend = RechartsPrimitive.Legend;
|
|
1815
|
+
function ChartLegendContent({
|
|
1816
|
+
className,
|
|
1817
|
+
hideIcon = false,
|
|
1818
|
+
payload,
|
|
1819
|
+
verticalAlign = "bottom",
|
|
1820
|
+
nameKey
|
|
1821
|
+
}) {
|
|
1822
|
+
const { config } = useChart();
|
|
1823
|
+
if (!payload?.length) {
|
|
1824
|
+
return null;
|
|
1645
1825
|
}
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1826
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1827
|
+
"div",
|
|
1828
|
+
{
|
|
1829
|
+
className: cn(
|
|
1830
|
+
"flex items-center justify-center gap-4",
|
|
1831
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
1832
|
+
className
|
|
1833
|
+
),
|
|
1834
|
+
children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
1835
|
+
const key = `${nameKey || item.dataKey || "value"}`;
|
|
1836
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
1837
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1838
|
+
"div",
|
|
1839
|
+
{
|
|
1840
|
+
className: "[&>svg]:text-muted-foreground flex min-w-0 max-w-[8rem] items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3",
|
|
1841
|
+
children: [
|
|
1842
|
+
itemConfig?.icon && !hideIcon ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(itemConfig.icon, {}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1843
|
+
"div",
|
|
1844
|
+
{
|
|
1845
|
+
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
1846
|
+
style: { backgroundColor: item.color }
|
|
1847
|
+
}
|
|
1848
|
+
),
|
|
1849
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "min-w-0 truncate", children: itemConfig?.label ?? (item.value != null ? String(item.value) : null) })
|
|
1850
|
+
]
|
|
1851
|
+
},
|
|
1852
|
+
`${item.value ?? index}`
|
|
1853
|
+
);
|
|
1854
|
+
})
|
|
1855
|
+
}
|
|
1856
|
+
);
|
|
1857
|
+
}
|
|
1858
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
1859
|
+
if (typeof payload !== "object" || payload === null) {
|
|
1860
|
+
return void 0;
|
|
1651
1861
|
}
|
|
1652
|
-
|
|
1862
|
+
const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
|
|
1863
|
+
let configLabelKey = key;
|
|
1864
|
+
if (key in payload && typeof payload[key] === "string") {
|
|
1865
|
+
configLabelKey = payload[key];
|
|
1866
|
+
} else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
|
|
1867
|
+
configLabelKey = payloadPayload[key];
|
|
1868
|
+
}
|
|
1869
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
// src/charts/chart-gradient-utils.ts
|
|
1873
|
+
function barGradientId(scopeId, dataKey) {
|
|
1874
|
+
return `bar-${scopeId}-${sanitizeId(dataKey)}`;
|
|
1875
|
+
}
|
|
1876
|
+
function pieGradientId(scopeId, key) {
|
|
1877
|
+
return `pie-${scopeId}-${sanitizeId(key)}`;
|
|
1653
1878
|
}
|
|
1654
|
-
function
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
if (
|
|
1660
|
-
|
|
1661
|
-
return
|
|
1879
|
+
function sanitizeId(key) {
|
|
1880
|
+
return key.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1881
|
+
}
|
|
1882
|
+
function truncateLabel(text, maxChars = 14) {
|
|
1883
|
+
const s = String(text ?? "");
|
|
1884
|
+
if (s.length <= maxChars) return s;
|
|
1885
|
+
if (maxChars <= 1) return "\u2026";
|
|
1886
|
+
return `${s.slice(0, maxChars - 1)}\u2026`;
|
|
1887
|
+
}
|
|
1888
|
+
function estimateYAxisWidth(labels, { min = 48, max = 112, charWidth = 6.5 } = {}) {
|
|
1889
|
+
if (labels.length === 0) return min;
|
|
1890
|
+
const longest = labels.reduce((a, b) => a.length >= b.length ? a : b, "");
|
|
1891
|
+
return Math.min(max, Math.max(min, Math.ceil(longest.length * charWidth) + 12));
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
// src/charts/chart-axis-tick.tsx
|
|
1895
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1896
|
+
var ChartAxisTick = ({
|
|
1897
|
+
x = 0,
|
|
1898
|
+
y = 0,
|
|
1899
|
+
payload,
|
|
1900
|
+
textAnchor = "end",
|
|
1901
|
+
maxChars = 14,
|
|
1902
|
+
clipTicks = true
|
|
1903
|
+
}) => {
|
|
1904
|
+
const raw = String(payload?.value ?? "");
|
|
1905
|
+
const label = clipTicks ? truncateLabel(raw, maxChars) : raw;
|
|
1906
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("g", { transform: `translate(${x},${y})`, children: [
|
|
1907
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("title", { children: raw }),
|
|
1908
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1909
|
+
"text",
|
|
1910
|
+
{
|
|
1911
|
+
textAnchor,
|
|
1912
|
+
fill: "currentColor",
|
|
1913
|
+
className: "fill-muted-foreground",
|
|
1914
|
+
dominantBaseline: "middle",
|
|
1915
|
+
children: label
|
|
1916
|
+
}
|
|
1917
|
+
)
|
|
1918
|
+
] });
|
|
1919
|
+
};
|
|
1920
|
+
|
|
1921
|
+
// src/charts/chart-gradients.tsx
|
|
1922
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1923
|
+
var BarGradientDefs = ({
|
|
1924
|
+
scopeId,
|
|
1925
|
+
dataKeys,
|
|
1926
|
+
horizontal
|
|
1927
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("defs", { children: dataKeys.map((dataKey) => {
|
|
1928
|
+
const id = barGradientId(scopeId, dataKey);
|
|
1929
|
+
const color = `var(--color-${dataKey})`;
|
|
1930
|
+
if (horizontal) {
|
|
1931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "1", y2: "0", children: [
|
|
1932
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "0%", stopColor: color, stopOpacity: 1 }),
|
|
1933
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "100%", stopColor: color, stopOpacity: 0.55 })
|
|
1934
|
+
] }, dataKey);
|
|
1935
|
+
}
|
|
1936
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
1937
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "0%", stopColor: color, stopOpacity: 1 }),
|
|
1938
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "100%", stopColor: color, stopOpacity: 0.55 })
|
|
1939
|
+
] }, dataKey);
|
|
1940
|
+
}) });
|
|
1941
|
+
var PieGradientDefs = ({ scopeId, slices }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("defs", { children: slices.map(({ key, color }) => {
|
|
1942
|
+
const id = pieGradientId(scopeId, key);
|
|
1943
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "1", y2: "1", children: [
|
|
1944
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "0%", stopColor: color, stopOpacity: 1 }),
|
|
1945
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "100%", stopColor: color, stopOpacity: 0.65 })
|
|
1946
|
+
] }, key);
|
|
1947
|
+
}) });
|
|
1948
|
+
|
|
1949
|
+
// src/charts/geometry.ts
|
|
1950
|
+
function toNum(value) {
|
|
1951
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
1952
|
+
return Number.isFinite(n) ? n : 0;
|
|
1662
1953
|
}
|
|
1663
1954
|
function round(v) {
|
|
1664
1955
|
return Math.round(v * 1e6) / 1e6;
|
|
@@ -1672,18 +1963,53 @@ function formatCompact(value, unit) {
|
|
|
1672
1963
|
return unit ? `${s}${unit}` : s;
|
|
1673
1964
|
}
|
|
1674
1965
|
|
|
1966
|
+
// src/charts/line-area-chart-utils.ts
|
|
1967
|
+
function resolveChartMargin(options) {
|
|
1968
|
+
const { flush, showXAxis, showYAxis } = options;
|
|
1969
|
+
if (!flush) {
|
|
1970
|
+
return { top: 8, right: 12, bottom: 0, left: 0 };
|
|
1971
|
+
}
|
|
1972
|
+
const anyAxis = showXAxis || showYAxis;
|
|
1973
|
+
if (!anyAxis) {
|
|
1974
|
+
return { top: 8, right: 12, bottom: 8, left: 12 };
|
|
1975
|
+
}
|
|
1976
|
+
return {
|
|
1977
|
+
top: 8,
|
|
1978
|
+
right: 12,
|
|
1979
|
+
bottom: showXAxis ? 24 : 8,
|
|
1980
|
+
left: showYAxis ? 8 : 12
|
|
1981
|
+
};
|
|
1982
|
+
}
|
|
1983
|
+
function flushBarCategoryGap(flush, showCategoryAxis) {
|
|
1984
|
+
return flush && showCategoryAxis ? "0%" : void 0;
|
|
1985
|
+
}
|
|
1986
|
+
function flushLineAreaEdgeToEdge(flush, variant, showXAxis, showYAxis) {
|
|
1987
|
+
return flush && (variant === "line" || variant === "area") && showXAxis && !showYAxis;
|
|
1988
|
+
}
|
|
1989
|
+
function resolveTooltipCategory(label, payload, xKey, data, formatX) {
|
|
1990
|
+
const row = payload?.[0]?.payload;
|
|
1991
|
+
if (row && xKey in row) {
|
|
1992
|
+
const idx = data.indexOf(row);
|
|
1993
|
+
return formatX(row[xKey], idx >= 0 ? idx : 0);
|
|
1994
|
+
}
|
|
1995
|
+
if (label != null && label !== "") {
|
|
1996
|
+
const idx = typeof label === "number" ? label : data.findIndex((r) => r[xKey] === label || String(r[xKey]) === String(label));
|
|
1997
|
+
return formatX(label, idx >= 0 ? idx : 0);
|
|
1998
|
+
}
|
|
1999
|
+
return "";
|
|
2000
|
+
}
|
|
2001
|
+
|
|
1675
2002
|
// src/charts/line-area-chart.tsx
|
|
1676
|
-
var
|
|
2003
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2004
|
+
var INDEX_X_KEY = "__index";
|
|
1677
2005
|
var CHART_PALETTE = [
|
|
1678
|
-
"var(--
|
|
1679
|
-
"#
|
|
1680
|
-
"#
|
|
1681
|
-
"#
|
|
1682
|
-
"#
|
|
1683
|
-
"#
|
|
2006
|
+
"var(--chart-1, #4f46e5)",
|
|
2007
|
+
"var(--chart-2, #3b82f6)",
|
|
2008
|
+
"var(--chart-3, #0ea5e9)",
|
|
2009
|
+
"var(--chart-4, #6366f1)",
|
|
2010
|
+
"var(--chart-5, #60a5fa)",
|
|
2011
|
+
"var(--chart-6, #2563eb)"
|
|
1684
2012
|
];
|
|
1685
|
-
var PAD_DEFAULT = { top: 12, right: 16, bottom: 26, left: 44 };
|
|
1686
|
-
var PAD_FLUSH = { top: 20, right: 0, bottom: 8, left: 0 };
|
|
1687
2013
|
var LineAreaChart = ({
|
|
1688
2014
|
data = [],
|
|
1689
2015
|
xKey: xKeyProp,
|
|
@@ -1692,308 +2018,314 @@ var LineAreaChart = ({
|
|
|
1692
2018
|
height = 240,
|
|
1693
2019
|
unit,
|
|
1694
2020
|
yMax,
|
|
2021
|
+
curve = "monotone",
|
|
2022
|
+
stacked = false,
|
|
2023
|
+
dots = false,
|
|
2024
|
+
orientation = "vertical",
|
|
2025
|
+
barRadius = 4,
|
|
2026
|
+
gridLines,
|
|
1695
2027
|
layout = "default",
|
|
1696
2028
|
showGrid = true,
|
|
1697
2029
|
showXAxis: showXAxisProp,
|
|
1698
2030
|
showYAxis: showYAxisProp,
|
|
1699
2031
|
showLegend: showLegendProp,
|
|
1700
2032
|
showTooltip = true,
|
|
2033
|
+
tooltipIndicator = "dot",
|
|
1701
2034
|
formatValue,
|
|
1702
2035
|
formatX,
|
|
2036
|
+
clipTicks = true,
|
|
1703
2037
|
className,
|
|
1704
2038
|
ariaLabel = "Chart"
|
|
1705
2039
|
}) => {
|
|
1706
|
-
const
|
|
1707
|
-
const { ref, width } = useChartWidth();
|
|
1708
|
-
const [active, setActive] = (0, import_react8.useState)(null);
|
|
1709
|
-
const [grown, setGrown] = (0, import_react8.useState)(false);
|
|
2040
|
+
const gradientScopeId = (0, import_react7.useId)().replace(/:/g, "");
|
|
1710
2041
|
const xKey = xKeyProp ?? inferXKey(data);
|
|
1711
|
-
const series = (
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
const
|
|
1716
|
-
const
|
|
1717
|
-
const
|
|
1718
|
-
const showLegend = showLegendProp ?? (layout !== "flush" && series.length > 1);
|
|
1719
|
-
(0, import_react8.useEffect)(() => {
|
|
1720
|
-
const t = requestAnimationFrame(() => setGrown(true));
|
|
1721
|
-
return () => cancelAnimationFrame(t);
|
|
1722
|
-
}, []);
|
|
1723
|
-
const innerW = Math.max(0, width - pad.left - pad.right);
|
|
1724
|
-
const innerH = Math.max(0, height - pad.top - pad.bottom);
|
|
1725
|
-
const { minV, maxV } = (0, import_react8.useMemo)(() => {
|
|
1726
|
-
let lo = 0;
|
|
1727
|
-
let hi = yMax ?? 0;
|
|
1728
|
-
for (const s of series) {
|
|
1729
|
-
for (const d of data) {
|
|
1730
|
-
const v = toNum(d[s.dataKey]);
|
|
1731
|
-
if (v > hi && yMax == null) hi = v;
|
|
1732
|
-
if (v < lo) lo = v;
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
if (hi === lo) hi = lo + 1;
|
|
1736
|
-
return { minV: lo, maxV: yMax != null ? yMax : hi * 1.08 };
|
|
1737
|
-
}, [series, data, yMax]);
|
|
1738
|
-
const ticks = (0, import_react8.useMemo)(() => niceTicks(minV, maxV, 4), [minV, maxV]);
|
|
2042
|
+
const series = resolveSeries(seriesProp, data, xKey);
|
|
2043
|
+
const flush = layout === "flush";
|
|
2044
|
+
const horizontal = orientation === "horizontal" && variant === "bar";
|
|
2045
|
+
const showXAxis = showXAxisProp ?? !flush;
|
|
2046
|
+
const showYAxis = showYAxisProp ?? !flush;
|
|
2047
|
+
const showLegend = showLegendProp ?? (!flush && series.length > 1);
|
|
2048
|
+
const grid = gridLines ?? (horizontal ? "vertical" : "horizontal");
|
|
1739
2049
|
if (data.length === 0 || series.length === 0) {
|
|
1740
|
-
return /* @__PURE__ */ (0,
|
|
2050
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartEmpty, { className, height, ariaLabel });
|
|
1741
2051
|
}
|
|
1742
|
-
const
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
const
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
};
|
|
1755
|
-
const
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
2052
|
+
const config = {};
|
|
2053
|
+
series.forEach((s, i) => {
|
|
2054
|
+
config[s.dataKey] = {
|
|
2055
|
+
label: s.label ?? s.dataKey,
|
|
2056
|
+
color: s.color ?? CHART_PALETTE[i % CHART_PALETTE.length]
|
|
2057
|
+
};
|
|
2058
|
+
});
|
|
2059
|
+
const valueFmt = (v) => formatValue ? formatValue(toNum(v)) : formatCompact(toNum(v), unit);
|
|
2060
|
+
const xFmt = (v, i) => formatX ? formatX(v, i) : String(v ?? "");
|
|
2061
|
+
const margin = resolveChartMargin({ flush, showXAxis, showYAxis });
|
|
2062
|
+
const flushCategoryXAxisProps = flush && showXAxis && flushLineAreaEdgeToEdge(flush, variant, showXAxis, showYAxis) ? { scale: "point", padding: "no-gap", interval: 0 } : flush && showXAxis && variant === "bar" ? { interval: 0 } : {};
|
|
2063
|
+
const useIndexX = flushLineAreaEdgeToEdge(flush, variant, showXAxis, showYAxis);
|
|
2064
|
+
const chartData = useIndexX ? data.map((row, i) => ({ ...row, [INDEX_X_KEY]: i })) : data;
|
|
2065
|
+
const chartXKey = useIndexX ? INDEX_X_KEY : xKey;
|
|
2066
|
+
const categoryTick = (textAnchor) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartAxisTick, { textAnchor, clipTicks });
|
|
2067
|
+
const showVGrid = showGrid && (grid === "vertical" || grid === "both");
|
|
2068
|
+
const showHGrid = showGrid && (grid === "horizontal" || grid === "both");
|
|
2069
|
+
const tooltipEl = showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2070
|
+
ChartTooltip,
|
|
2071
|
+
{
|
|
2072
|
+
cursor: variant === "bar",
|
|
2073
|
+
content: ({ active, payload, label }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2074
|
+
ChartTooltipContent,
|
|
2075
|
+
{
|
|
2076
|
+
active,
|
|
2077
|
+
payload,
|
|
2078
|
+
label,
|
|
2079
|
+
indicator: tooltipIndicator,
|
|
2080
|
+
labelFormatter: (_value, items) => {
|
|
2081
|
+
const category = resolveTooltipCategory(label, items, xKey, data, xFmt);
|
|
2082
|
+
return category || null;
|
|
2083
|
+
},
|
|
2084
|
+
formatter: (value, name, item) => {
|
|
2085
|
+
const key = String(item.dataKey ?? name ?? "value");
|
|
2086
|
+
const seriesLabel = config[key]?.label ?? name;
|
|
2087
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-1 items-center justify-between leading-none", children: [
|
|
2088
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-muted-foreground", children: seriesLabel }),
|
|
2089
|
+
value != null ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-foreground font-mono font-medium tabular-nums", children: valueFmt(value) }) : null
|
|
2090
|
+
] });
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
)
|
|
2094
|
+
}
|
|
2095
|
+
) : null;
|
|
2096
|
+
const legendEl = showLegend ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartLegend, { content: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartLegendContent, {}) }) : null;
|
|
2097
|
+
const gridEl = showGrid && grid !== "none" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts.CartesianGrid, { vertical: showVGrid, horizontal: showHGrid, strokeDasharray: "4 4" }) : null;
|
|
2098
|
+
const yDomain = yMax != null ? [0, yMax] : void 0;
|
|
2099
|
+
if (variant === "bar") {
|
|
2100
|
+
const dataKeys = series.map((s) => s.dataKey);
|
|
2101
|
+
const barDefs = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(BarGradientDefs, { scopeId: gradientScopeId, dataKeys, horizontal });
|
|
2102
|
+
const bars = series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2103
|
+
import_recharts.Bar,
|
|
1759
2104
|
{
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
"
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
2105
|
+
dataKey: s.dataKey,
|
|
2106
|
+
fill: `url(#${barGradientId(gradientScopeId, s.dataKey)})`,
|
|
2107
|
+
radius: barCornerRadius(barRadius, horizontal, stacked),
|
|
2108
|
+
stackId: stacked ? "stack" : void 0,
|
|
2109
|
+
isAnimationActive: true
|
|
2110
|
+
},
|
|
2111
|
+
s.dataKey
|
|
2112
|
+
));
|
|
2113
|
+
if (horizontal) {
|
|
2114
|
+
const categoryLabels = data.map((row, i) => xFmt(row[xKey], i));
|
|
2115
|
+
const yAxisWidth = showYAxis ? estimateYAxisWidth(
|
|
2116
|
+
clipTicks ? categoryLabels.map((l) => l.slice(0, 14)) : categoryLabels
|
|
2117
|
+
) : 0;
|
|
2118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2119
|
+
import_recharts.BarChart,
|
|
2120
|
+
{
|
|
2121
|
+
accessibilityLayer: true,
|
|
2122
|
+
data,
|
|
2123
|
+
layout: "vertical",
|
|
2124
|
+
margin,
|
|
2125
|
+
barCategoryGap: flushBarCategoryGap(flush, showYAxis),
|
|
2126
|
+
children: [
|
|
2127
|
+
barDefs,
|
|
2128
|
+
gridEl,
|
|
2129
|
+
showXAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2130
|
+
import_recharts.XAxis,
|
|
1769
2131
|
{
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
2132
|
+
type: "number",
|
|
2133
|
+
tickLine: false,
|
|
2134
|
+
axisLine: false,
|
|
2135
|
+
tickMargin: 8,
|
|
2136
|
+
tickFormatter: (v) => valueFmt(v),
|
|
2137
|
+
domain: yDomain
|
|
1775
2138
|
}
|
|
1776
|
-
)
|
|
1777
|
-
/* @__PURE__ */ (0,
|
|
1778
|
-
|
|
1779
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "8%", stopColor: "white", stopOpacity: 1 }),
|
|
1780
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "92%", stopColor: "white", stopOpacity: 1 }),
|
|
1781
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "100%", stopColor: "white", stopOpacity: 0 })
|
|
1782
|
-
] }),
|
|
1783
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("mask", { id: `${uid}-gridmask`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1784
|
-
"rect",
|
|
2139
|
+
) : null,
|
|
2140
|
+
showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2141
|
+
import_recharts.YAxis,
|
|
1785
2142
|
{
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
2143
|
+
type: "category",
|
|
2144
|
+
dataKey: xKey,
|
|
2145
|
+
tickLine: false,
|
|
2146
|
+
axisLine: false,
|
|
2147
|
+
tickMargin: 8,
|
|
2148
|
+
width: yAxisWidth,
|
|
2149
|
+
minTickGap: 16,
|
|
2150
|
+
tick: categoryTick("end")
|
|
1791
2151
|
}
|
|
1792
|
-
) }),
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
showGrid && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("g", { mask: `url(#${uid}-gridmask)`, children: ticks.map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1813
|
-
"line",
|
|
1814
|
-
{
|
|
1815
|
-
x1: pad.left,
|
|
1816
|
-
x2: width - pad.right,
|
|
1817
|
-
y1: yScale(t),
|
|
1818
|
-
y2: yScale(t),
|
|
1819
|
-
stroke: "currentColor",
|
|
1820
|
-
strokeOpacity: 0.14,
|
|
1821
|
-
strokeDasharray: "4 4",
|
|
1822
|
-
className: "text-muted-foreground"
|
|
1823
|
-
},
|
|
1824
|
-
i
|
|
1825
|
-
)) }),
|
|
1826
|
-
showYAxis && ticks.map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1827
|
-
"text",
|
|
1828
|
-
{
|
|
1829
|
-
x: pad.left - 8,
|
|
1830
|
-
y: yScale(t),
|
|
1831
|
-
textAnchor: "end",
|
|
1832
|
-
dominantBaseline: "middle",
|
|
1833
|
-
className: "fill-muted-foreground text-[10px] tabular-nums",
|
|
1834
|
-
children: fmtV(t)
|
|
1835
|
-
},
|
|
1836
|
-
i
|
|
1837
|
-
)),
|
|
1838
|
-
showXAxis && labelIdx.map((i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1839
|
-
"text",
|
|
2152
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts.YAxis, { type: "category", dataKey: xKey, hide: true, width: 0 }),
|
|
2153
|
+
tooltipEl,
|
|
2154
|
+
legendEl,
|
|
2155
|
+
bars
|
|
2156
|
+
]
|
|
2157
|
+
}
|
|
2158
|
+
) });
|
|
2159
|
+
}
|
|
2160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2161
|
+
import_recharts.BarChart,
|
|
2162
|
+
{
|
|
2163
|
+
accessibilityLayer: true,
|
|
2164
|
+
data,
|
|
2165
|
+
margin,
|
|
2166
|
+
barCategoryGap: flushBarCategoryGap(flush, showXAxis),
|
|
2167
|
+
children: [
|
|
2168
|
+
barDefs,
|
|
2169
|
+
gridEl,
|
|
2170
|
+
showXAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2171
|
+
import_recharts.XAxis,
|
|
1840
2172
|
{
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
/* @__PURE__ */ (0,
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
x: xPos(i),
|
|
1853
|
-
y: yScale(toNum(d[s.dataKey]))
|
|
1854
|
-
}));
|
|
1855
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("g", { children: [
|
|
1856
|
-
variant === "area" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: monotoneAreaPath(pts, baseY), fill: `url(#${uid}-fill-${si})` }),
|
|
1857
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1858
|
-
"path",
|
|
1859
|
-
{
|
|
1860
|
-
d: monotoneLinePath(pts),
|
|
1861
|
-
fill: "none",
|
|
1862
|
-
stroke: color,
|
|
1863
|
-
strokeWidth: 2,
|
|
1864
|
-
strokeLinecap: "round",
|
|
1865
|
-
strokeLinejoin: "round"
|
|
1866
|
-
}
|
|
1867
|
-
)
|
|
1868
|
-
] }, s.dataKey);
|
|
1869
|
-
}) }),
|
|
1870
|
-
showTooltip && active != null && variant !== "bar" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("g", { pointerEvents: "none", children: [
|
|
1871
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1872
|
-
"line",
|
|
1873
|
-
{
|
|
1874
|
-
x1: xPos(active),
|
|
1875
|
-
x2: xPos(active),
|
|
1876
|
-
y1: pad.top,
|
|
1877
|
-
y2: pad.top + innerH,
|
|
1878
|
-
stroke: "currentColor",
|
|
1879
|
-
strokeOpacity: 0.25,
|
|
1880
|
-
className: "text-foreground"
|
|
1881
|
-
}
|
|
1882
|
-
),
|
|
1883
|
-
series.map((s, si) => {
|
|
1884
|
-
const color = s.color ?? CHART_PALETTE[si % CHART_PALETTE.length];
|
|
1885
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1886
|
-
"circle",
|
|
1887
|
-
{
|
|
1888
|
-
cx: xPos(active),
|
|
1889
|
-
cy: yScale(toNum(data[active]?.[s.dataKey])),
|
|
1890
|
-
r: 4,
|
|
1891
|
-
fill: color,
|
|
1892
|
-
stroke: "var(--background, #fff)",
|
|
1893
|
-
strokeWidth: 2
|
|
1894
|
-
},
|
|
1895
|
-
s.dataKey
|
|
1896
|
-
);
|
|
1897
|
-
})
|
|
1898
|
-
] }),
|
|
1899
|
-
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1900
|
-
"rect",
|
|
2173
|
+
dataKey: xKey,
|
|
2174
|
+
tickLine: false,
|
|
2175
|
+
axisLine: false,
|
|
2176
|
+
tickMargin: 8,
|
|
2177
|
+
minTickGap: 16,
|
|
2178
|
+
tick: categoryTick("middle"),
|
|
2179
|
+
...flushCategoryXAxisProps
|
|
2180
|
+
}
|
|
2181
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts.XAxis, { dataKey: xKey, hide: true }),
|
|
2182
|
+
showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2183
|
+
import_recharts.YAxis,
|
|
1901
2184
|
{
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
onMouseMove: onMove,
|
|
1909
|
-
onMouseLeave: () => setActive(null)
|
|
2185
|
+
tickLine: false,
|
|
2186
|
+
axisLine: false,
|
|
2187
|
+
tickMargin: 8,
|
|
2188
|
+
width: 44,
|
|
2189
|
+
tickFormatter: (v) => valueFmt(v),
|
|
2190
|
+
domain: yDomain
|
|
1910
2191
|
}
|
|
1911
|
-
)
|
|
2192
|
+
) : null,
|
|
2193
|
+
tooltipEl,
|
|
2194
|
+
legendEl,
|
|
2195
|
+
bars
|
|
1912
2196
|
]
|
|
1913
2197
|
}
|
|
1914
|
-
)
|
|
1915
|
-
|
|
1916
|
-
|
|
2198
|
+
) });
|
|
2199
|
+
}
|
|
2200
|
+
const lineAreaAxes = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
2201
|
+
showXAxis && useIndexX ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2202
|
+
import_recharts.XAxis,
|
|
1917
2203
|
{
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
2204
|
+
type: "number",
|
|
2205
|
+
dataKey: INDEX_X_KEY,
|
|
2206
|
+
domain: [0, Math.max(0, chartData.length - 1)],
|
|
2207
|
+
allowDecimals: false,
|
|
2208
|
+
ticks: chartData.map((_, i) => i),
|
|
2209
|
+
tickLine: false,
|
|
2210
|
+
axisLine: false,
|
|
2211
|
+
tickMargin: 8,
|
|
2212
|
+
tickFormatter: (i) => {
|
|
2213
|
+
const row = chartData[Number(i)];
|
|
2214
|
+
return row ? xFmt(row[xKey], Number(i)) : "";
|
|
2215
|
+
}
|
|
1926
2216
|
}
|
|
1927
|
-
),
|
|
1928
|
-
|
|
2217
|
+
) : showXAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2218
|
+
import_recharts.XAxis,
|
|
2219
|
+
{
|
|
2220
|
+
dataKey: xKey,
|
|
2221
|
+
tickLine: false,
|
|
2222
|
+
axisLine: false,
|
|
2223
|
+
tickMargin: 8,
|
|
2224
|
+
minTickGap: flush ? 8 : 24,
|
|
2225
|
+
tickFormatter: (v, i) => xFmt(v, i),
|
|
2226
|
+
...flushCategoryXAxisProps
|
|
2227
|
+
}
|
|
2228
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts.XAxis, { dataKey: chartXKey, hide: true }),
|
|
2229
|
+
showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2230
|
+
import_recharts.YAxis,
|
|
2231
|
+
{
|
|
2232
|
+
tickLine: false,
|
|
2233
|
+
axisLine: false,
|
|
2234
|
+
tickMargin: 8,
|
|
2235
|
+
width: 44,
|
|
2236
|
+
tickFormatter: (v) => valueFmt(v),
|
|
2237
|
+
domain: yDomain
|
|
2238
|
+
}
|
|
2239
|
+
) : null
|
|
1929
2240
|
] });
|
|
1930
|
-
};
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
2241
|
+
const chartA11y = flush ? {} : { accessibilityLayer: true };
|
|
2242
|
+
if (variant === "area") {
|
|
2243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2244
|
+
ChartShell,
|
|
2245
|
+
{
|
|
2246
|
+
config,
|
|
2247
|
+
height,
|
|
2248
|
+
className,
|
|
2249
|
+
ariaLabel,
|
|
2250
|
+
flush,
|
|
2251
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_recharts.AreaChart, { ...chartA11y, data: chartData, margin, children: [
|
|
2252
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("defs", { children: series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("linearGradient", { id: `fill-${s.dataKey}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
2253
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("stop", { offset: "5%", stopColor: `var(--color-${s.dataKey})`, stopOpacity: 0.3 }),
|
|
2254
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("stop", { offset: "95%", stopColor: `var(--color-${s.dataKey})`, stopOpacity: 0.04 })
|
|
2255
|
+
] }, s.dataKey)) }),
|
|
2256
|
+
gridEl,
|
|
2257
|
+
lineAreaAxes,
|
|
2258
|
+
tooltipEl,
|
|
2259
|
+
legendEl,
|
|
2260
|
+
series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2261
|
+
import_recharts.Area,
|
|
2262
|
+
{
|
|
2263
|
+
dataKey: s.dataKey,
|
|
2264
|
+
type: curve,
|
|
2265
|
+
stackId: stacked ? "stack" : void 0,
|
|
2266
|
+
stroke: `var(--color-${s.dataKey})`,
|
|
2267
|
+
strokeWidth: 2,
|
|
2268
|
+
fill: `url(#fill-${s.dataKey})`,
|
|
2269
|
+
dot: dots === true ? { r: 3 } : false,
|
|
2270
|
+
activeDot: { r: 4 },
|
|
2271
|
+
isAnimationActive: true
|
|
2272
|
+
},
|
|
2273
|
+
s.dataKey
|
|
2274
|
+
))
|
|
2275
|
+
] })
|
|
2276
|
+
}
|
|
2277
|
+
);
|
|
2278
|
+
}
|
|
2279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2280
|
+
ChartShell,
|
|
1961
2281
|
{
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
children: [
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
)
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
2282
|
+
config,
|
|
2283
|
+
height,
|
|
2284
|
+
className,
|
|
2285
|
+
ariaLabel,
|
|
2286
|
+
flush,
|
|
2287
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_recharts.LineChart, { ...chartA11y, data: chartData, margin, children: [
|
|
2288
|
+
gridEl,
|
|
2289
|
+
lineAreaAxes,
|
|
2290
|
+
tooltipEl,
|
|
2291
|
+
legendEl,
|
|
2292
|
+
series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2293
|
+
import_recharts.Line,
|
|
2294
|
+
{
|
|
2295
|
+
dataKey: s.dataKey,
|
|
2296
|
+
type: curve,
|
|
2297
|
+
stroke: `var(--color-${s.dataKey})`,
|
|
2298
|
+
strokeWidth: 2,
|
|
2299
|
+
dot: dots === true ? { r: 3 } : false,
|
|
2300
|
+
activeDot: { r: 4 },
|
|
2301
|
+
isAnimationActive: true
|
|
2302
|
+
},
|
|
2303
|
+
s.dataKey
|
|
2304
|
+
))
|
|
2305
|
+
] })
|
|
1983
2306
|
}
|
|
1984
2307
|
);
|
|
1985
2308
|
};
|
|
1986
|
-
var
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
2309
|
+
var ChartShell = ({ config, height, className, ariaLabel, flush = false, children }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2310
|
+
ChartContainer,
|
|
2311
|
+
{
|
|
2312
|
+
config,
|
|
2313
|
+
role: "img",
|
|
2314
|
+
"aria-label": ariaLabel,
|
|
2315
|
+
className: cn(
|
|
2316
|
+
"aspect-auto w-full",
|
|
2317
|
+
flush && "justify-start [&_.recharts-responsive-container]:!mx-0 [&_.recharts-responsive-container]:w-full",
|
|
2318
|
+
className
|
|
2319
|
+
),
|
|
2320
|
+
style: { height },
|
|
2321
|
+
children
|
|
2322
|
+
}
|
|
2323
|
+
);
|
|
2324
|
+
var ChartEmpty = ({
|
|
2325
|
+
className,
|
|
2326
|
+
height,
|
|
2327
|
+
ariaLabel
|
|
2328
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1997
2329
|
"div",
|
|
1998
2330
|
{
|
|
1999
2331
|
className: cn(
|
|
@@ -2001,9 +2333,15 @@ var ChartEmpty = ({ className, height }) => /* @__PURE__ */ (0, import_jsx_runti
|
|
|
2001
2333
|
className
|
|
2002
2334
|
),
|
|
2003
2335
|
style: { height },
|
|
2336
|
+
role: "img",
|
|
2337
|
+
"aria-label": ariaLabel,
|
|
2004
2338
|
children: "No data yet"
|
|
2005
2339
|
}
|
|
2006
2340
|
);
|
|
2341
|
+
function barCornerRadius(r, horizontal, stacked) {
|
|
2342
|
+
if (stacked) return r;
|
|
2343
|
+
return horizontal ? [0, r, r, 0] : [r, r, 0, 0];
|
|
2344
|
+
}
|
|
2007
2345
|
function inferXKey(data) {
|
|
2008
2346
|
if (data.length === 0) return "x";
|
|
2009
2347
|
for (const k of Object.keys(data[0])) {
|
|
@@ -2018,21 +2356,360 @@ function resolveSeries(seriesProp, data, xKey) {
|
|
|
2018
2356
|
if (data.length === 0) return [];
|
|
2019
2357
|
return Object.keys(data[0]).filter((k) => k !== xKey && typeof data[0][k] === "number").map((dataKey) => ({ dataKey }));
|
|
2020
2358
|
}
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2359
|
+
|
|
2360
|
+
// src/charts/pie-chart.tsx
|
|
2361
|
+
var import_react8 = require("react");
|
|
2362
|
+
var import_recharts2 = require("recharts");
|
|
2363
|
+
|
|
2364
|
+
// src/charts/chart-center-label.tsx
|
|
2365
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2366
|
+
var CENTER_BOX_W = 96;
|
|
2367
|
+
var CENTER_BOX_H = 52;
|
|
2368
|
+
var ChartCenterLabel = ({ cx, cy, value, label }) => {
|
|
2369
|
+
const hasValue = value != null && value !== "";
|
|
2370
|
+
const hasLabel = label != null && label !== "";
|
|
2371
|
+
if (!hasValue && !hasLabel) return null;
|
|
2372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2373
|
+
"foreignObject",
|
|
2374
|
+
{
|
|
2375
|
+
x: cx - CENTER_BOX_W / 2,
|
|
2376
|
+
y: cy - CENTER_BOX_H / 2,
|
|
2377
|
+
width: CENTER_BOX_W,
|
|
2378
|
+
height: CENTER_BOX_H,
|
|
2379
|
+
className: "overflow-visible",
|
|
2380
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "pointer-events-none flex h-full flex-col items-center justify-center gap-0.5 text-center", children: [
|
|
2381
|
+
hasValue ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-2xl font-normal leading-none tabular-nums text-foreground", children: value }) : null,
|
|
2382
|
+
hasLabel ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-[11px] leading-none text-muted-foreground", children: label }) : null
|
|
2383
|
+
] })
|
|
2384
|
+
}
|
|
2385
|
+
);
|
|
2386
|
+
};
|
|
2387
|
+
|
|
2388
|
+
// src/charts/pie-chart.tsx
|
|
2389
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2390
|
+
var PieChart = ({
|
|
2391
|
+
data,
|
|
2392
|
+
nameKey: nameKeyProp,
|
|
2393
|
+
dataKey = "value",
|
|
2394
|
+
innerRadius = 0,
|
|
2395
|
+
colors,
|
|
2396
|
+
height = 260,
|
|
2397
|
+
showLegend = true,
|
|
2398
|
+
showLabels = false,
|
|
2399
|
+
showTooltip = true,
|
|
2400
|
+
tooltipIndicator = "dot",
|
|
2401
|
+
centerValue,
|
|
2402
|
+
centerLabel,
|
|
2403
|
+
className,
|
|
2404
|
+
ariaLabel = "Pie chart"
|
|
2405
|
+
}) => {
|
|
2406
|
+
const gradientScopeId = (0, import_react8.useId)().replace(/:/g, "");
|
|
2407
|
+
const nameKey = nameKeyProp ?? inferNameKey(data, dataKey);
|
|
2408
|
+
const palette = colors ?? CHART_PALETTE;
|
|
2409
|
+
if (data.length === 0) {
|
|
2410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(PieEmpty, { className, height, ariaLabel });
|
|
2411
|
+
}
|
|
2412
|
+
const slices = data.map((d, i) => ({
|
|
2413
|
+
name: String(d[nameKey] ?? i),
|
|
2414
|
+
value: toNum(d[dataKey]),
|
|
2415
|
+
fill: palette[i % palette.length]
|
|
2416
|
+
}));
|
|
2417
|
+
const config = {};
|
|
2418
|
+
for (const s of slices) config[s.name] = { label: s.name };
|
|
2419
|
+
const innerPct = innerRadius > 0 ? `${Math.round(innerRadius * 75)}%` : 0;
|
|
2420
|
+
const hasCenter = innerRadius > 0 && (centerValue != null || centerLabel != null);
|
|
2421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2422
|
+
ChartContainer,
|
|
2423
|
+
{
|
|
2424
|
+
config,
|
|
2425
|
+
role: "img",
|
|
2426
|
+
"aria-label": ariaLabel,
|
|
2427
|
+
className: cn("aspect-auto w-full", className),
|
|
2428
|
+
style: { height },
|
|
2429
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_recharts2.PieChart, { children: [
|
|
2430
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2431
|
+
PieGradientDefs,
|
|
2432
|
+
{
|
|
2433
|
+
scopeId: gradientScopeId,
|
|
2434
|
+
slices: slices.map((s) => ({ key: s.name, color: s.fill }))
|
|
2435
|
+
}
|
|
2436
|
+
),
|
|
2437
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2438
|
+
ChartTooltip,
|
|
2439
|
+
{
|
|
2440
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChartTooltipContent, { nameKey: "name", indicator: tooltipIndicator, hideLabel: true })
|
|
2441
|
+
}
|
|
2442
|
+
),
|
|
2443
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2444
|
+
import_recharts2.Pie,
|
|
2445
|
+
{
|
|
2446
|
+
data: slices,
|
|
2447
|
+
dataKey: "value",
|
|
2448
|
+
nameKey: "name",
|
|
2449
|
+
innerRadius: innerPct,
|
|
2450
|
+
outerRadius: "75%",
|
|
2451
|
+
paddingAngle: innerRadius > 0 ? 2 : 0,
|
|
2452
|
+
strokeWidth: 2,
|
|
2453
|
+
label: showLabels,
|
|
2454
|
+
isAnimationActive: true,
|
|
2455
|
+
children: [
|
|
2456
|
+
slices.map((s) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_recharts2.Cell, { fill: `url(#${pieGradientId(gradientScopeId, s.name)})` }, s.name)),
|
|
2457
|
+
hasCenter && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2458
|
+
import_recharts2.Label,
|
|
2459
|
+
{
|
|
2460
|
+
position: "center",
|
|
2461
|
+
content: ({ viewBox }) => {
|
|
2462
|
+
if (!viewBox || !("cx" in viewBox)) return null;
|
|
2463
|
+
const { cx, cy } = viewBox;
|
|
2464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2465
|
+
ChartCenterLabel,
|
|
2466
|
+
{
|
|
2467
|
+
cx,
|
|
2468
|
+
cy,
|
|
2469
|
+
value: centerValue,
|
|
2470
|
+
label: centerLabel
|
|
2471
|
+
}
|
|
2472
|
+
);
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
)
|
|
2476
|
+
]
|
|
2477
|
+
}
|
|
2478
|
+
),
|
|
2479
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChartLegend, { content: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChartLegendContent, { nameKey: "name" }) })
|
|
2480
|
+
] })
|
|
2481
|
+
}
|
|
2482
|
+
);
|
|
2483
|
+
};
|
|
2484
|
+
var PieEmpty = ({
|
|
2485
|
+
className,
|
|
2486
|
+
height,
|
|
2487
|
+
ariaLabel
|
|
2488
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2489
|
+
"div",
|
|
2490
|
+
{
|
|
2491
|
+
className: cn("flex w-full items-center justify-center text-xs text-muted-foreground", className),
|
|
2492
|
+
style: { height },
|
|
2493
|
+
role: "img",
|
|
2494
|
+
"aria-label": ariaLabel,
|
|
2495
|
+
children: "No data yet"
|
|
2496
|
+
}
|
|
2497
|
+
);
|
|
2498
|
+
function inferNameKey(data, dataKey) {
|
|
2499
|
+
if (data.length === 0) return "name";
|
|
2500
|
+
for (const k of Object.keys(data[0])) {
|
|
2501
|
+
if (k !== dataKey && typeof data[0][k] !== "number") return k;
|
|
2502
|
+
}
|
|
2503
|
+
return Object.keys(data[0]).find((k) => k !== dataKey) ?? "name";
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
// src/charts/radial-chart.tsx
|
|
2507
|
+
var import_react9 = require("react");
|
|
2508
|
+
var import_recharts3 = require("recharts");
|
|
2509
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2510
|
+
var RadialChart = ({
|
|
2511
|
+
data,
|
|
2512
|
+
nameKey: nameKeyProp,
|
|
2513
|
+
dataKey = "value",
|
|
2514
|
+
maxValue,
|
|
2515
|
+
colors,
|
|
2516
|
+
height = 260,
|
|
2517
|
+
ringWidth = 16,
|
|
2518
|
+
ringGap = 4,
|
|
2519
|
+
showLegend = true,
|
|
2520
|
+
centerValue,
|
|
2521
|
+
centerLabel,
|
|
2522
|
+
className,
|
|
2523
|
+
ariaLabel = "Radial chart"
|
|
2524
|
+
}) => {
|
|
2525
|
+
const gradientScopeId = (0, import_react9.useId)().replace(/:/g, "");
|
|
2526
|
+
const nameKey = nameKeyProp ?? inferNameKey2(data, dataKey);
|
|
2527
|
+
const palette = colors ?? CHART_PALETTE;
|
|
2528
|
+
if (data.length === 0) {
|
|
2529
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(RadialEmpty, { className, height, ariaLabel });
|
|
2530
|
+
}
|
|
2531
|
+
const rows = data.map((d, i) => ({
|
|
2532
|
+
name: String(d[nameKey] ?? i),
|
|
2533
|
+
value: toNum(d[dataKey]),
|
|
2534
|
+
fill: palette[i % palette.length]
|
|
2535
|
+
}));
|
|
2536
|
+
const max = maxValue ?? Math.max(...rows.map((r) => r.value), 1);
|
|
2537
|
+
const config = {};
|
|
2538
|
+
for (const r of rows) config[r.name] = { label: r.name };
|
|
2539
|
+
const hasCenter = centerValue != null || centerLabel != null;
|
|
2540
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: cn("flex w-full flex-col items-center gap-3", className), children: [
|
|
2541
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2542
|
+
ChartContainer,
|
|
2543
|
+
{
|
|
2544
|
+
config,
|
|
2545
|
+
role: "img",
|
|
2546
|
+
"aria-label": ariaLabel,
|
|
2547
|
+
className: "aspect-auto w-full",
|
|
2548
|
+
style: { height: height - (showLegend ? 32 : 0) },
|
|
2549
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2550
|
+
import_recharts3.RadialBarChart,
|
|
2551
|
+
{
|
|
2552
|
+
data: rows,
|
|
2553
|
+
startAngle: 90,
|
|
2554
|
+
endAngle: -270,
|
|
2555
|
+
innerRadius: "30%",
|
|
2556
|
+
outerRadius: "100%",
|
|
2557
|
+
barSize: ringWidth,
|
|
2558
|
+
barGap: ringGap,
|
|
2559
|
+
children: [
|
|
2560
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2561
|
+
PieGradientDefs,
|
|
2562
|
+
{
|
|
2563
|
+
scopeId: gradientScopeId,
|
|
2564
|
+
slices: rows.map((r) => ({ key: r.name, color: r.fill }))
|
|
2565
|
+
}
|
|
2566
|
+
),
|
|
2567
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_recharts3.PolarAngleAxis, { type: "number", domain: [0, max], tick: false, axisLine: false }),
|
|
2568
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChartTooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChartTooltipContent, { nameKey: "name", hideLabel: true }) }),
|
|
2569
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_recharts3.RadialBar, { dataKey: "value", background: true, cornerRadius: ringWidth / 2, isAnimationActive: true, children: rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_recharts3.Cell, { fill: `url(#${pieGradientId(gradientScopeId, r.name)})` }, r.name)) }),
|
|
2570
|
+
hasCenter && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_recharts3.PolarRadiusAxis, { tick: false, tickLine: false, axisLine: false, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2571
|
+
import_recharts3.Label,
|
|
2572
|
+
{
|
|
2573
|
+
position: "center",
|
|
2574
|
+
content: ({ viewBox }) => {
|
|
2575
|
+
if (!viewBox || !("cx" in viewBox)) return null;
|
|
2576
|
+
const { cx, cy } = viewBox;
|
|
2577
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2578
|
+
ChartCenterLabel,
|
|
2579
|
+
{
|
|
2580
|
+
cx,
|
|
2581
|
+
cy,
|
|
2582
|
+
value: centerValue,
|
|
2583
|
+
label: centerLabel
|
|
2584
|
+
}
|
|
2585
|
+
);
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
) })
|
|
2589
|
+
]
|
|
2590
|
+
}
|
|
2591
|
+
)
|
|
2592
|
+
}
|
|
2593
|
+
),
|
|
2594
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
2595
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "inline-block size-2.5 rounded-[3px]", style: { background: r.fill } }),
|
|
2596
|
+
r.name
|
|
2597
|
+
] }, r.name)) })
|
|
2598
|
+
] });
|
|
2599
|
+
};
|
|
2600
|
+
var RadialEmpty = ({
|
|
2601
|
+
className,
|
|
2602
|
+
height,
|
|
2603
|
+
ariaLabel
|
|
2604
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2605
|
+
"div",
|
|
2606
|
+
{
|
|
2607
|
+
className: cn("flex w-full items-center justify-center text-xs text-muted-foreground", className),
|
|
2608
|
+
style: { height },
|
|
2609
|
+
role: "img",
|
|
2610
|
+
"aria-label": ariaLabel,
|
|
2611
|
+
children: "No data yet"
|
|
2612
|
+
}
|
|
2613
|
+
);
|
|
2614
|
+
function inferNameKey2(data, dataKey) {
|
|
2615
|
+
if (data.length === 0) return "name";
|
|
2616
|
+
for (const k of Object.keys(data[0])) {
|
|
2617
|
+
if (k !== dataKey && typeof data[0][k] !== "number") return k;
|
|
2618
|
+
}
|
|
2619
|
+
return Object.keys(data[0]).find((k) => k !== dataKey) ?? "name";
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
// src/charts/radar-chart.tsx
|
|
2623
|
+
var import_recharts4 = require("recharts");
|
|
2624
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2625
|
+
var RadarChart = ({
|
|
2626
|
+
data,
|
|
2627
|
+
nameKey: nameKeyProp,
|
|
2628
|
+
series: seriesProp,
|
|
2629
|
+
maxValue,
|
|
2630
|
+
height = 280,
|
|
2631
|
+
showLegend = true,
|
|
2632
|
+
fill = true,
|
|
2633
|
+
className,
|
|
2634
|
+
ariaLabel = "Radar chart"
|
|
2635
|
+
}) => {
|
|
2636
|
+
const nameKey = nameKeyProp ?? inferNameKey3(data);
|
|
2637
|
+
const series = resolveSeries2(seriesProp, data, nameKey);
|
|
2638
|
+
if (data.length < 3 || series.length === 0) {
|
|
2639
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2640
|
+
"div",
|
|
2641
|
+
{
|
|
2642
|
+
className: cn("flex items-center justify-center text-xs text-muted-foreground", className),
|
|
2643
|
+
style: { height },
|
|
2644
|
+
role: "img",
|
|
2645
|
+
"aria-label": ariaLabel,
|
|
2646
|
+
children: "Radar needs at least 3 axes"
|
|
2647
|
+
}
|
|
2648
|
+
);
|
|
2649
|
+
}
|
|
2650
|
+
const config = {};
|
|
2651
|
+
series.forEach((s, i) => {
|
|
2652
|
+
config[s.dataKey] = {
|
|
2653
|
+
label: s.label ?? s.dataKey,
|
|
2654
|
+
color: s.color ?? CHART_PALETTE[i % CHART_PALETTE.length]
|
|
2655
|
+
};
|
|
2656
|
+
});
|
|
2657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2658
|
+
ChartContainer,
|
|
2659
|
+
{
|
|
2660
|
+
config,
|
|
2661
|
+
role: "img",
|
|
2662
|
+
"aria-label": ariaLabel,
|
|
2663
|
+
className: cn("mx-auto aspect-square", className),
|
|
2664
|
+
style: { height },
|
|
2665
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_recharts4.RadarChart, { data, outerRadius: "70%", children: [
|
|
2666
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartTooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartTooltipContent, { indicator: "line" }) }),
|
|
2667
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_recharts4.PolarGrid, {}),
|
|
2668
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2669
|
+
import_recharts4.PolarAngleAxis,
|
|
2670
|
+
{
|
|
2671
|
+
dataKey: nameKey,
|
|
2672
|
+
tick: { fontSize: 10, fill: "var(--color-muted-foreground)" }
|
|
2673
|
+
}
|
|
2674
|
+
),
|
|
2675
|
+
series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2676
|
+
import_recharts4.Radar,
|
|
2677
|
+
{
|
|
2678
|
+
dataKey: s.dataKey,
|
|
2679
|
+
stroke: `var(--color-${s.dataKey})`,
|
|
2680
|
+
fill: `var(--color-${s.dataKey})`,
|
|
2681
|
+
fillOpacity: fill ? 0.18 : 0,
|
|
2682
|
+
strokeWidth: 2,
|
|
2683
|
+
dot: { r: 2.5, fillOpacity: 1 },
|
|
2684
|
+
isAnimationActive: true
|
|
2685
|
+
},
|
|
2686
|
+
s.dataKey
|
|
2687
|
+
)),
|
|
2688
|
+
showLegend && series.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartLegend, { content: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartLegendContent, {}) })
|
|
2689
|
+
] })
|
|
2690
|
+
}
|
|
2691
|
+
);
|
|
2692
|
+
};
|
|
2693
|
+
function inferNameKey3(data) {
|
|
2694
|
+
if (data.length === 0) return "name";
|
|
2695
|
+
for (const k of Object.keys(data[0])) {
|
|
2696
|
+
if (typeof data[0][k] !== "number") return k;
|
|
2697
|
+
}
|
|
2698
|
+
return Object.keys(data[0])[0] ?? "name";
|
|
2699
|
+
}
|
|
2700
|
+
function resolveSeries2(seriesProp, data, nameKey) {
|
|
2701
|
+
if (seriesProp && seriesProp.length > 0) {
|
|
2702
|
+
return seriesProp.map((s) => typeof s === "string" ? { dataKey: s } : s);
|
|
2703
|
+
}
|
|
2704
|
+
if (data.length === 0) return [];
|
|
2705
|
+
return Object.keys(data[0]).filter((k) => k !== nameKey && typeof data[0][k] === "number").map((dataKey) => ({ dataKey }));
|
|
2029
2706
|
}
|
|
2030
2707
|
|
|
2031
2708
|
// src/artifacts/artifact-card.tsx
|
|
2032
|
-
var
|
|
2709
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2033
2710
|
var ArtifactCard = ({ title, kind, className, bodyClassName, toolbar, children }) => {
|
|
2034
2711
|
const hasHeader = Boolean(title || toolbar);
|
|
2035
|
-
return /* @__PURE__ */ (0,
|
|
2712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2036
2713
|
"div",
|
|
2037
2714
|
{
|
|
2038
2715
|
className: cn(
|
|
@@ -2041,29 +2718,29 @@ var ArtifactCard = ({ title, kind, className, bodyClassName, toolbar, children }
|
|
|
2041
2718
|
),
|
|
2042
2719
|
"data-artifact-kind": kind,
|
|
2043
2720
|
children: [
|
|
2044
|
-
hasHeader && /* @__PURE__ */ (0,
|
|
2045
|
-
title && /* @__PURE__ */ (0,
|
|
2046
|
-
!title && /* @__PURE__ */ (0,
|
|
2721
|
+
hasHeader && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "aui-artifact-header flex items-center gap-2 border-b border-border/40 bg-muted/30 px-3 py-1.5", children: [
|
|
2722
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "aui-artifact-title flex-1 truncate text-xs font-semibold text-foreground/80", children: title }),
|
|
2723
|
+
!title && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "flex-1" }),
|
|
2047
2724
|
toolbar
|
|
2048
2725
|
] }),
|
|
2049
|
-
/* @__PURE__ */ (0,
|
|
2726
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: cn("aui-artifact-body", bodyClassName), children })
|
|
2050
2727
|
]
|
|
2051
2728
|
}
|
|
2052
2729
|
);
|
|
2053
2730
|
};
|
|
2054
2731
|
|
|
2055
2732
|
// src/artifacts/chart-artifact.tsx
|
|
2056
|
-
var
|
|
2733
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2057
2734
|
var ChartArtifactView = ({
|
|
2058
2735
|
artifact,
|
|
2059
2736
|
embedded = false,
|
|
2060
2737
|
height = 300
|
|
2061
2738
|
}) => {
|
|
2062
|
-
const plot = /* @__PURE__ */ (0,
|
|
2739
|
+
const plot = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChartArtifactPlot, { artifact, height });
|
|
2063
2740
|
if (embedded) {
|
|
2064
|
-
return /* @__PURE__ */ (0,
|
|
2741
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "aui-artifact-chart w-full", children: plot });
|
|
2065
2742
|
}
|
|
2066
|
-
return /* @__PURE__ */ (0,
|
|
2743
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ArtifactCard, { title: artifact.title, kind: "chart", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "aui-artifact-chart pt-2", children: plot }) });
|
|
2067
2744
|
};
|
|
2068
2745
|
function ChartArtifactPlot({
|
|
2069
2746
|
artifact,
|
|
@@ -2071,14 +2748,59 @@ function ChartArtifactPlot({
|
|
|
2071
2748
|
}) {
|
|
2072
2749
|
const { chartType = "bar", data = [] } = artifact;
|
|
2073
2750
|
const xKey = artifact.xKey ?? inferXKey2(data);
|
|
2074
|
-
const series = (0,
|
|
2751
|
+
const series = (0, import_react10.useMemo)(() => {
|
|
2752
|
+
if (artifact.series && artifact.series.length > 0) {
|
|
2753
|
+
return artifact.series.map((s) => ({
|
|
2754
|
+
dataKey: s.dataKey,
|
|
2755
|
+
label: s.label,
|
|
2756
|
+
color: s.color
|
|
2757
|
+
}));
|
|
2758
|
+
}
|
|
2075
2759
|
const keys = Array.isArray(artifact.dataKey) ? artifact.dataKey : typeof artifact.dataKey === "string" ? [artifact.dataKey] : inferDataKeys(data, xKey);
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2760
|
+
const colors = artifact.colors;
|
|
2761
|
+
return keys.map((dataKey, i) => ({
|
|
2762
|
+
dataKey,
|
|
2763
|
+
color: colors?.[i]
|
|
2764
|
+
}));
|
|
2765
|
+
}, [artifact.series, artifact.dataKey, artifact.colors, data, xKey]);
|
|
2766
|
+
const aria = typeof artifact.title === "string" ? artifact.title : "Chart";
|
|
2767
|
+
if (chartType === "pie" || chartType === "donut") {
|
|
2768
|
+
const total = data.reduce((sum, d) => sum + toNum(d[series[0]?.dataKey ?? "value"]), 0);
|
|
2769
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2770
|
+
PieChart,
|
|
2771
|
+
{
|
|
2772
|
+
data,
|
|
2773
|
+
nameKey: xKey,
|
|
2774
|
+
dataKey: series[0]?.dataKey ?? "value",
|
|
2775
|
+
innerRadius: chartType === "donut" ? 0.6 : 0,
|
|
2776
|
+
colors: artifact.colors,
|
|
2777
|
+
height,
|
|
2778
|
+
unit: artifact.unit,
|
|
2779
|
+
centerValue: chartType === "donut" ? formatCompact(total, artifact.unit) : void 0,
|
|
2780
|
+
centerLabel: chartType === "donut" ? "Total" : void 0,
|
|
2781
|
+
ariaLabel: aria
|
|
2782
|
+
}
|
|
2783
|
+
) });
|
|
2080
2784
|
}
|
|
2081
|
-
|
|
2785
|
+
if (chartType === "radial") {
|
|
2786
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2787
|
+
RadialChart,
|
|
2788
|
+
{
|
|
2789
|
+
data,
|
|
2790
|
+
nameKey: xKey,
|
|
2791
|
+
dataKey: series[0]?.dataKey ?? "value",
|
|
2792
|
+
colors: artifact.colors,
|
|
2793
|
+
height,
|
|
2794
|
+
ariaLabel: aria
|
|
2795
|
+
}
|
|
2796
|
+
) });
|
|
2797
|
+
}
|
|
2798
|
+
if (chartType === "radar") {
|
|
2799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RadarChart, { data, nameKey: xKey, series, height, ariaLabel: aria }) });
|
|
2800
|
+
}
|
|
2801
|
+
const horizontal = chartType === "horizontalBar";
|
|
2802
|
+
const showAxes = artifact.showAxes === true;
|
|
2803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2082
2804
|
LineAreaChart,
|
|
2083
2805
|
{
|
|
2084
2806
|
data,
|
|
@@ -2087,71 +2809,19 @@ function ChartArtifactPlot({
|
|
|
2087
2809
|
layout: "flush",
|
|
2088
2810
|
height,
|
|
2089
2811
|
variant: chartType === "line" ? "line" : chartType === "area" ? "area" : "bar",
|
|
2812
|
+
orientation: horizontal ? "horizontal" : "vertical",
|
|
2813
|
+
stacked: artifact.stacked,
|
|
2814
|
+
curve: artifact.curve,
|
|
2815
|
+
dots: artifact.dots,
|
|
2816
|
+
tooltipIndicator: artifact.tooltipIndicator,
|
|
2817
|
+
showXAxis: showAxes,
|
|
2818
|
+
showYAxis: showAxes && horizontal,
|
|
2819
|
+
showLegend: artifact.legend ?? series.length > 1,
|
|
2090
2820
|
unit: artifact.unit,
|
|
2091
|
-
ariaLabel:
|
|
2821
|
+
ariaLabel: aria
|
|
2092
2822
|
}
|
|
2093
2823
|
);
|
|
2094
2824
|
}
|
|
2095
|
-
var PIE_W = 320;
|
|
2096
|
-
var PIE_H = 220;
|
|
2097
|
-
var PieChart = ({ data, xKey, dataKey }) => {
|
|
2098
|
-
if (data.length === 0) {
|
|
2099
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex h-32 items-center justify-center text-xs text-muted-foreground", children: "No data" });
|
|
2100
|
-
}
|
|
2101
|
-
const cx = PIE_W / 2;
|
|
2102
|
-
const cy = PIE_H / 2;
|
|
2103
|
-
const r = Math.min(PIE_W, PIE_H) / 2 - 16;
|
|
2104
|
-
const total = data.reduce((sum, d) => sum + toNum(d[dataKey]), 0) || 1;
|
|
2105
|
-
let acc = 0;
|
|
2106
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-col items-center gap-3", children: [
|
|
2107
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2108
|
-
"svg",
|
|
2109
|
-
{
|
|
2110
|
-
viewBox: `0 0 ${PIE_W} ${PIE_H}`,
|
|
2111
|
-
className: "w-full max-w-[20rem]",
|
|
2112
|
-
role: "img",
|
|
2113
|
-
"aria-label": "Pie chart",
|
|
2114
|
-
children: data.map((d, i) => {
|
|
2115
|
-
const value = toNum(d[dataKey]);
|
|
2116
|
-
const start = acc / total * Math.PI * 2;
|
|
2117
|
-
acc += value;
|
|
2118
|
-
const end = acc / total * Math.PI * 2;
|
|
2119
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2120
|
-
PieSlice,
|
|
2121
|
-
{
|
|
2122
|
-
cx,
|
|
2123
|
-
cy,
|
|
2124
|
-
r,
|
|
2125
|
-
start,
|
|
2126
|
-
end,
|
|
2127
|
-
color: CHART_PALETTE[i % CHART_PALETTE.length]
|
|
2128
|
-
},
|
|
2129
|
-
i
|
|
2130
|
-
);
|
|
2131
|
-
})
|
|
2132
|
-
}
|
|
2133
|
-
),
|
|
2134
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex flex-wrap items-center justify-center gap-x-3 gap-y-1 text-xs text-muted-foreground", children: data.map((d, i) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
2135
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2136
|
-
"span",
|
|
2137
|
-
{
|
|
2138
|
-
className: "inline-block size-2 rounded-sm",
|
|
2139
|
-
style: { background: CHART_PALETTE[i % CHART_PALETTE.length] }
|
|
2140
|
-
}
|
|
2141
|
-
),
|
|
2142
|
-
String(d[xKey] ?? i)
|
|
2143
|
-
] }, i)) })
|
|
2144
|
-
] });
|
|
2145
|
-
};
|
|
2146
|
-
var PieSlice = ({ cx, cy, r, start, end, color }) => {
|
|
2147
|
-
const x1 = cx + Math.sin(start) * r;
|
|
2148
|
-
const y1 = cy - Math.cos(start) * r;
|
|
2149
|
-
const x2 = cx + Math.sin(end) * r;
|
|
2150
|
-
const y2 = cy - Math.cos(end) * r;
|
|
2151
|
-
const large = end - start > Math.PI ? 1 : 0;
|
|
2152
|
-
const path = `M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${large} 1 ${x2} ${y2} Z`;
|
|
2153
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: path, fill: color, stroke: "var(--background, #fff)", strokeWidth: 1.5 });
|
|
2154
|
-
};
|
|
2155
2825
|
function inferXKey2(data) {
|
|
2156
2826
|
if (data.length === 0) return "x";
|
|
2157
2827
|
for (const k of Object.keys(data[0])) {
|
|
@@ -2167,8 +2837,8 @@ function inferDataKeys(data, xKey) {
|
|
|
2167
2837
|
}
|
|
2168
2838
|
|
|
2169
2839
|
// src/artifacts/question-artifact.tsx
|
|
2170
|
-
var
|
|
2171
|
-
var
|
|
2840
|
+
var import_react11 = require("react");
|
|
2841
|
+
var import_react12 = require("@assistant-ui/react");
|
|
2172
2842
|
var import_lucide_react3 = require("lucide-react");
|
|
2173
2843
|
|
|
2174
2844
|
// src/design/classes.ts
|
|
@@ -2277,12 +2947,12 @@ var studioQuestionOptionSelectedClass = cn(
|
|
|
2277
2947
|
);
|
|
2278
2948
|
|
|
2279
2949
|
// src/artifacts/question-artifact.tsx
|
|
2280
|
-
var
|
|
2950
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2281
2951
|
function optionKey(option, index) {
|
|
2282
2952
|
const id = option.id?.trim();
|
|
2283
2953
|
return id ? id : `__option-${index}`;
|
|
2284
2954
|
}
|
|
2285
|
-
var OptionRadio = ({ selected }) => /* @__PURE__ */ (0,
|
|
2955
|
+
var OptionRadio = ({ selected }) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2286
2956
|
"span",
|
|
2287
2957
|
{
|
|
2288
2958
|
className: cn(
|
|
@@ -2290,18 +2960,18 @@ var OptionRadio = ({ selected }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx
|
|
|
2290
2960
|
selected ? "border-foreground bg-foreground text-background" : "border-border bg-background"
|
|
2291
2961
|
),
|
|
2292
2962
|
"aria-hidden": true,
|
|
2293
|
-
children: selected ? /* @__PURE__ */ (0,
|
|
2963
|
+
children: selected ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react3.CheckIcon, { className: "size-2.5 stroke-[3]" }) : null
|
|
2294
2964
|
}
|
|
2295
2965
|
);
|
|
2296
2966
|
var QuestionArtifactView = ({
|
|
2297
2967
|
artifact
|
|
2298
2968
|
}) => {
|
|
2299
|
-
const runtime = (0,
|
|
2300
|
-
const [selected, setSelected] = (0,
|
|
2301
|
-
const [submittedIds, setSubmittedIds] = (0,
|
|
2969
|
+
const runtime = (0, import_react12.useThreadRuntime)();
|
|
2970
|
+
const [selected, setSelected] = (0, import_react11.useState)([]);
|
|
2971
|
+
const [submittedIds, setSubmittedIds] = (0, import_react11.useState)(null);
|
|
2302
2972
|
const isMulti = artifact.multi === true;
|
|
2303
2973
|
const isDisabled = submittedIds !== null;
|
|
2304
|
-
const send = (0,
|
|
2974
|
+
const send = (0, import_react11.useCallback)(
|
|
2305
2975
|
(keys) => {
|
|
2306
2976
|
if (keys.length === 0) return;
|
|
2307
2977
|
const labels = artifact.options.map((option, index) => ({ option, key: optionKey(option, index) })).filter(({ key }) => keys.includes(key)).map(({ option }) => option.label);
|
|
@@ -2313,7 +2983,7 @@ var QuestionArtifactView = ({
|
|
|
2313
2983
|
},
|
|
2314
2984
|
[artifact.options, runtime]
|
|
2315
2985
|
);
|
|
2316
|
-
const onPick = (0,
|
|
2986
|
+
const onPick = (0, import_react11.useCallback)(
|
|
2317
2987
|
(key) => {
|
|
2318
2988
|
if (isDisabled) return;
|
|
2319
2989
|
if (!isMulti) {
|
|
@@ -2326,15 +2996,15 @@ var QuestionArtifactView = ({
|
|
|
2326
2996
|
},
|
|
2327
2997
|
[isDisabled, isMulti, send]
|
|
2328
2998
|
);
|
|
2329
|
-
const onConfirm = (0,
|
|
2999
|
+
const onConfirm = (0, import_react11.useCallback)(() => {
|
|
2330
3000
|
send(selected);
|
|
2331
3001
|
}, [selected, send]);
|
|
2332
|
-
return /* @__PURE__ */ (0,
|
|
2333
|
-
artifact.prompt ? /* @__PURE__ */ (0,
|
|
2334
|
-
/* @__PURE__ */ (0,
|
|
3002
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: studioArtifactShellClass, "data-artifact-kind": "question", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "px-2.5 py-2", children: [
|
|
3003
|
+
artifact.prompt ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "mb-2 text-sm font-normal leading-snug text-foreground", children: artifact.prompt }) : null,
|
|
3004
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "flex flex-col gap-0.5", role: "list", children: artifact.options.map((option, index) => {
|
|
2335
3005
|
const key = optionKey(option, index);
|
|
2336
3006
|
const isSelected = submittedIds ? submittedIds.includes(key) : isMulti && selected.includes(key);
|
|
2337
|
-
return /* @__PURE__ */ (0,
|
|
3007
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
2338
3008
|
"button",
|
|
2339
3009
|
{
|
|
2340
3010
|
type: "button",
|
|
@@ -2346,17 +3016,17 @@ var QuestionArtifactView = ({
|
|
|
2346
3016
|
isDisabled && (isSelected ? "cursor-default" : "cursor-not-allowed opacity-50")
|
|
2347
3017
|
),
|
|
2348
3018
|
children: [
|
|
2349
|
-
/* @__PURE__ */ (0,
|
|
2350
|
-
/* @__PURE__ */ (0,
|
|
2351
|
-
/* @__PURE__ */ (0,
|
|
2352
|
-
option.description ? /* @__PURE__ */ (0,
|
|
3019
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(OptionRadio, { selected: isSelected }),
|
|
3020
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "min-w-0 flex-1 text-left", children: [
|
|
3021
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "block font-normal text-foreground", children: option.label }),
|
|
3022
|
+
option.description ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: option.description }) : null
|
|
2353
3023
|
] })
|
|
2354
3024
|
]
|
|
2355
3025
|
},
|
|
2356
3026
|
key
|
|
2357
3027
|
);
|
|
2358
3028
|
}) }),
|
|
2359
|
-
isMulti && !submittedIds ? /* @__PURE__ */ (0,
|
|
3029
|
+
isMulti && !submittedIds ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "mt-2 flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2360
3030
|
TimbalV2Button,
|
|
2361
3031
|
{
|
|
2362
3032
|
type: "button",
|
|
@@ -2371,12 +3041,12 @@ var QuestionArtifactView = ({
|
|
|
2371
3041
|
};
|
|
2372
3042
|
|
|
2373
3043
|
// src/artifacts/html-artifact.tsx
|
|
2374
|
-
var
|
|
3044
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2375
3045
|
var HtmlArtifactView = ({ artifact }) => {
|
|
2376
3046
|
const sandboxed = artifact.sandboxed !== false;
|
|
2377
3047
|
const sandbox = sandboxed ? "allow-scripts allow-same-origin allow-forms allow-modals allow-popups allow-pointer-lock" : void 0;
|
|
2378
3048
|
const height = artifact.height ?? "320px";
|
|
2379
|
-
return /* @__PURE__ */ (0,
|
|
3049
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ArtifactCard, { title: artifact.title, kind: "html", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2380
3050
|
"iframe",
|
|
2381
3051
|
{
|
|
2382
3052
|
title: artifact.title ?? "HTML artifact",
|
|
@@ -2389,7 +3059,7 @@ var HtmlArtifactView = ({ artifact }) => {
|
|
|
2389
3059
|
};
|
|
2390
3060
|
|
|
2391
3061
|
// src/artifacts/json-artifact.tsx
|
|
2392
|
-
var
|
|
3062
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2393
3063
|
var JsonArtifactView = ({
|
|
2394
3064
|
artifact
|
|
2395
3065
|
}) => {
|
|
@@ -2401,16 +3071,16 @@ var JsonArtifactView = ({
|
|
|
2401
3071
|
} catch {
|
|
2402
3072
|
body = String(data);
|
|
2403
3073
|
}
|
|
2404
|
-
return /* @__PURE__ */ (0,
|
|
3074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ArtifactCard, { title, kind: "json", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("pre", { className: "aui-artifact-json m-0 max-h-[420px] overflow-auto p-3 font-mono text-[12px] leading-relaxed text-foreground/85", children: body }) });
|
|
2405
3075
|
};
|
|
2406
3076
|
|
|
2407
3077
|
// src/artifacts/table-artifact.tsx
|
|
2408
|
-
var
|
|
3078
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2409
3079
|
var TableArtifactView = ({ artifact }) => {
|
|
2410
3080
|
const rows = artifact.rows ?? [];
|
|
2411
3081
|
const columns = artifact.columns ?? deriveColumns(rows);
|
|
2412
|
-
return /* @__PURE__ */ (0,
|
|
2413
|
-
/* @__PURE__ */ (0,
|
|
3082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ArtifactCard, { title: artifact.title, kind: "table", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "aui-artifact-table-wrap overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("table", { className: "aui-artifact-table w-full border-collapse text-sm", children: [
|
|
3083
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("tr", { className: "border-b border-border/40 bg-muted/20", children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2414
3084
|
"th",
|
|
2415
3085
|
{
|
|
2416
3086
|
className: "px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",
|
|
@@ -2418,11 +3088,11 @@ var TableArtifactView = ({ artifact }) => {
|
|
|
2418
3088
|
},
|
|
2419
3089
|
col.key
|
|
2420
3090
|
)) }) }),
|
|
2421
|
-
/* @__PURE__ */ (0,
|
|
3091
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("tbody", { children: rows.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2422
3092
|
"tr",
|
|
2423
3093
|
{
|
|
2424
3094
|
className: "border-b border-border/30 transition-colors last:border-b-0 hover:bg-muted/20",
|
|
2425
|
-
children: columns.map((col) => /* @__PURE__ */ (0,
|
|
3095
|
+
children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2426
3096
|
"td",
|
|
2427
3097
|
{
|
|
2428
3098
|
className: "px-3 py-2 align-top text-foreground/85",
|
|
@@ -2455,7 +3125,7 @@ function formatCell(value) {
|
|
|
2455
3125
|
}
|
|
2456
3126
|
|
|
2457
3127
|
// src/artifacts/ui/ui-artifact.tsx
|
|
2458
|
-
var
|
|
3128
|
+
var import_react17 = require("react");
|
|
2459
3129
|
|
|
2460
3130
|
// src/artifacts/ui/types.ts
|
|
2461
3131
|
function isUiBinding(value) {
|
|
@@ -2508,38 +3178,38 @@ function resolveBindable(value, state) {
|
|
|
2508
3178
|
}
|
|
2509
3179
|
|
|
2510
3180
|
// src/artifacts/ui/registry.tsx
|
|
2511
|
-
var
|
|
2512
|
-
var
|
|
2513
|
-
var UiStateContext = (0,
|
|
2514
|
-
var UiDispatchContext = (0,
|
|
3181
|
+
var import_react13 = require("react");
|
|
3182
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3183
|
+
var UiStateContext = (0, import_react13.createContext)({});
|
|
3184
|
+
var UiDispatchContext = (0, import_react13.createContext)(() => {
|
|
2515
3185
|
});
|
|
2516
|
-
var UiStateProvider = ({ state, dispatch, children }) => /* @__PURE__ */ (0,
|
|
3186
|
+
var UiStateProvider = ({ state, dispatch, children }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(UiStateContext.Provider, { value: state, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(UiDispatchContext.Provider, { value: dispatch, children }) });
|
|
2517
3187
|
function useUiState() {
|
|
2518
|
-
return (0,
|
|
3188
|
+
return (0, import_react13.useContext)(UiStateContext);
|
|
2519
3189
|
}
|
|
2520
3190
|
function useUiDispatch() {
|
|
2521
|
-
return (0,
|
|
3191
|
+
return (0, import_react13.useContext)(UiDispatchContext);
|
|
2522
3192
|
}
|
|
2523
|
-
var UiEventContext = (0,
|
|
3193
|
+
var UiEventContext = (0, import_react13.createContext)(
|
|
2524
3194
|
null
|
|
2525
3195
|
);
|
|
2526
|
-
var UiEventProvider = ({ onEvent, children }) => /* @__PURE__ */ (0,
|
|
3196
|
+
var UiEventProvider = ({ onEvent, children }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(UiEventContext.Provider, { value: onEvent, children });
|
|
2527
3197
|
function useUiEventEmitter() {
|
|
2528
|
-
return (0,
|
|
3198
|
+
return (0, import_react13.useContext)(UiEventContext);
|
|
2529
3199
|
}
|
|
2530
|
-
var UiCustomNodeRegistryContext = (0,
|
|
3200
|
+
var UiCustomNodeRegistryContext = (0, import_react13.createContext)({});
|
|
2531
3201
|
function useUiCustomNodeRegistry() {
|
|
2532
|
-
return (0,
|
|
3202
|
+
return (0, import_react13.useContext)(UiCustomNodeRegistryContext);
|
|
2533
3203
|
}
|
|
2534
3204
|
|
|
2535
3205
|
// src/artifacts/ui/nodes.tsx
|
|
2536
|
-
var
|
|
2537
|
-
var
|
|
2538
|
-
var
|
|
3206
|
+
var import_react14 = require("react");
|
|
3207
|
+
var import_react15 = require("motion/react");
|
|
3208
|
+
var import_react16 = require("@assistant-ui/react");
|
|
2539
3209
|
|
|
2540
3210
|
// src/ui/button.tsx
|
|
2541
3211
|
var import_class_variance_authority = require("class-variance-authority");
|
|
2542
|
-
var
|
|
3212
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2543
3213
|
var LEGACY_SIZE_TO_V2 = {
|
|
2544
3214
|
default: "md",
|
|
2545
3215
|
xs: "xs",
|
|
@@ -2589,7 +3259,7 @@ function Button({
|
|
|
2589
3259
|
const v2Variant = TIMBAL_V2_FROM_LEGACY_BUTTON[variant ?? "default"];
|
|
2590
3260
|
const v2Size = LEGACY_SIZE_TO_V2[size ?? "default"];
|
|
2591
3261
|
const isIconOnly = typeof size === "string" && size.startsWith("icon");
|
|
2592
|
-
return /* @__PURE__ */ (0,
|
|
3262
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2593
3263
|
TimbalV2Button,
|
|
2594
3264
|
{
|
|
2595
3265
|
"data-slot": "button",
|
|
@@ -2607,29 +3277,29 @@ function Button({
|
|
|
2607
3277
|
}
|
|
2608
3278
|
|
|
2609
3279
|
// src/artifacts/ui/nodes.tsx
|
|
2610
|
-
var
|
|
3280
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2611
3281
|
var UiNodeView = ({ node }) => {
|
|
2612
3282
|
switch (node.kind) {
|
|
2613
3283
|
case "box":
|
|
2614
|
-
return /* @__PURE__ */ (0,
|
|
3284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(BoxNode, { node });
|
|
2615
3285
|
case "text":
|
|
2616
|
-
return /* @__PURE__ */ (0,
|
|
3286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TextNode, { node });
|
|
2617
3287
|
case "heading":
|
|
2618
|
-
return /* @__PURE__ */ (0,
|
|
3288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(HeadingNode, { node });
|
|
2619
3289
|
case "badge":
|
|
2620
|
-
return /* @__PURE__ */ (0,
|
|
3290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(BadgeNode, { node });
|
|
2621
3291
|
case "button":
|
|
2622
|
-
return /* @__PURE__ */ (0,
|
|
3292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ButtonNode, { node });
|
|
2623
3293
|
case "toggle":
|
|
2624
|
-
return /* @__PURE__ */ (0,
|
|
3294
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ToggleNode, { node });
|
|
2625
3295
|
case "slider":
|
|
2626
|
-
return /* @__PURE__ */ (0,
|
|
3296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SliderNode, { node });
|
|
2627
3297
|
case "tooltip":
|
|
2628
|
-
return /* @__PURE__ */ (0,
|
|
3298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipNode, { node });
|
|
2629
3299
|
case "draggable":
|
|
2630
|
-
return /* @__PURE__ */ (0,
|
|
3300
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DraggableNode, { node });
|
|
2631
3301
|
case "custom":
|
|
2632
|
-
return /* @__PURE__ */ (0,
|
|
3302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CustomNode, { node });
|
|
2633
3303
|
default:
|
|
2634
3304
|
return null;
|
|
2635
3305
|
}
|
|
@@ -2637,9 +3307,9 @@ var UiNodeView = ({ node }) => {
|
|
|
2637
3307
|
function useActionRunner() {
|
|
2638
3308
|
const state = useUiState();
|
|
2639
3309
|
const dispatch = useUiDispatch();
|
|
2640
|
-
const runtime = (0,
|
|
3310
|
+
const runtime = (0, import_react16.useThreadRuntime)();
|
|
2641
3311
|
const emit = useUiEventEmitter();
|
|
2642
|
-
return (0,
|
|
3312
|
+
return (0, import_react14.useCallback)(
|
|
2643
3313
|
(actions) => {
|
|
2644
3314
|
if (!actions) return;
|
|
2645
3315
|
const list = Array.isArray(actions) ? actions : [actions];
|
|
@@ -2689,7 +3359,7 @@ var JUSTIFY_CLS = {
|
|
|
2689
3359
|
};
|
|
2690
3360
|
var BoxNode = ({ node }) => {
|
|
2691
3361
|
const dir = node.direction ?? "col";
|
|
2692
|
-
return /* @__PURE__ */ (0,
|
|
3362
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2693
3363
|
"div",
|
|
2694
3364
|
{
|
|
2695
3365
|
className: cn(
|
|
@@ -2704,7 +3374,7 @@ var BoxNode = ({ node }) => {
|
|
|
2704
3374
|
gap: node.gap !== void 0 ? `${node.gap * 0.25}rem` : void 0,
|
|
2705
3375
|
padding: node.padding !== void 0 ? `${node.padding * 0.25}rem` : void 0
|
|
2706
3376
|
},
|
|
2707
|
-
children: node.children?.map((child, i) => /* @__PURE__ */ (0,
|
|
3377
|
+
children: node.children?.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UiNodeView, { node: child }, child.id ?? i))
|
|
2708
3378
|
}
|
|
2709
3379
|
);
|
|
2710
3380
|
};
|
|
@@ -2723,7 +3393,7 @@ var TEXT_WEIGHT = {
|
|
|
2723
3393
|
var TextNode = ({ node }) => {
|
|
2724
3394
|
const state = useUiState();
|
|
2725
3395
|
const value = resolveBindable(node.value, state);
|
|
2726
|
-
return /* @__PURE__ */ (0,
|
|
3396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2727
3397
|
"span",
|
|
2728
3398
|
{
|
|
2729
3399
|
className: cn(
|
|
@@ -2754,13 +3424,13 @@ var HeadingNode = ({ node }) => {
|
|
|
2754
3424
|
);
|
|
2755
3425
|
switch (level) {
|
|
2756
3426
|
case 1:
|
|
2757
|
-
return /* @__PURE__ */ (0,
|
|
3427
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h1", { className: cls, children: value });
|
|
2758
3428
|
case 2:
|
|
2759
|
-
return /* @__PURE__ */ (0,
|
|
3429
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h2", { className: cls, children: value });
|
|
2760
3430
|
case 3:
|
|
2761
|
-
return /* @__PURE__ */ (0,
|
|
3431
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h3", { className: cls, children: value });
|
|
2762
3432
|
case 4:
|
|
2763
|
-
return /* @__PURE__ */ (0,
|
|
3433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h4", { className: cls, children: value });
|
|
2764
3434
|
}
|
|
2765
3435
|
};
|
|
2766
3436
|
var BADGE_TONE = {
|
|
@@ -2773,7 +3443,7 @@ var BADGE_TONE = {
|
|
|
2773
3443
|
var BadgeNode = ({ node }) => {
|
|
2774
3444
|
const state = useUiState();
|
|
2775
3445
|
const value = String(resolveBindable(node.value, state) ?? "");
|
|
2776
|
-
return /* @__PURE__ */ (0,
|
|
3446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2777
3447
|
"span",
|
|
2778
3448
|
{
|
|
2779
3449
|
className: cn(
|
|
@@ -2790,7 +3460,7 @@ var ButtonNode = ({ node }) => {
|
|
|
2790
3460
|
const run = useActionRunner();
|
|
2791
3461
|
const label = String(resolveBindable(node.label, state) ?? "");
|
|
2792
3462
|
const disabled = node.disabled !== void 0 ? Boolean(resolveBindable(node.disabled, state)) : false;
|
|
2793
|
-
return /* @__PURE__ */ (0,
|
|
3463
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2794
3464
|
Button,
|
|
2795
3465
|
{
|
|
2796
3466
|
variant: node.variant ?? "default",
|
|
@@ -2812,7 +3482,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2812
3482
|
dispatch({ type: "toggle", path: node.binding });
|
|
2813
3483
|
run(node.onChange);
|
|
2814
3484
|
};
|
|
2815
|
-
return /* @__PURE__ */ (0,
|
|
3485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
2816
3486
|
"label",
|
|
2817
3487
|
{
|
|
2818
3488
|
className: cn(
|
|
@@ -2820,7 +3490,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2820
3490
|
node.className
|
|
2821
3491
|
),
|
|
2822
3492
|
children: [
|
|
2823
|
-
/* @__PURE__ */ (0,
|
|
3493
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2824
3494
|
"button",
|
|
2825
3495
|
{
|
|
2826
3496
|
type: "button",
|
|
@@ -2831,7 +3501,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2831
3501
|
"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-[background,box-shadow,border-color] duration-200",
|
|
2832
3502
|
value ? "border-foreground/15 bg-gradient-to-b from-primary-fill-from to-primary-fill-to shadow-card" : cn(TIMBAL_V2_SWITCH_TRACK_OFF, "hover:from-secondary-fill-hover-from hover:to-secondary-fill-hover-to")
|
|
2833
3503
|
),
|
|
2834
|
-
children: /* @__PURE__ */ (0,
|
|
3504
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2835
3505
|
"span",
|
|
2836
3506
|
{
|
|
2837
3507
|
className: cn(
|
|
@@ -2844,7 +3514,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2844
3514
|
)
|
|
2845
3515
|
}
|
|
2846
3516
|
),
|
|
2847
|
-
label && /* @__PURE__ */ (0,
|
|
3517
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-foreground/85", children: label })
|
|
2848
3518
|
]
|
|
2849
3519
|
}
|
|
2850
3520
|
);
|
|
@@ -2864,12 +3534,12 @@ var SliderNode = ({ node }) => {
|
|
|
2864
3534
|
const next = Number(e.target.value);
|
|
2865
3535
|
dispatch({ type: "set", path: node.binding, value: next });
|
|
2866
3536
|
};
|
|
2867
|
-
return /* @__PURE__ */ (0,
|
|
2868
|
-
(label || showValue) && /* @__PURE__ */ (0,
|
|
2869
|
-
label && /* @__PURE__ */ (0,
|
|
2870
|
-
showValue && /* @__PURE__ */ (0,
|
|
3537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: cn("aui-ui-slider flex flex-col gap-1", node.className), children: [
|
|
3538
|
+
(label || showValue) && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center justify-between text-xs text-muted-foreground", children: [
|
|
3539
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: label }),
|
|
3540
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-mono", children: value })
|
|
2871
3541
|
] }),
|
|
2872
|
-
/* @__PURE__ */ (0,
|
|
3542
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2873
3543
|
"input",
|
|
2874
3544
|
{
|
|
2875
3545
|
type: "range",
|
|
@@ -2891,9 +3561,9 @@ var SliderNode = ({ node }) => {
|
|
|
2891
3561
|
var TooltipNode = ({ node }) => {
|
|
2892
3562
|
const state = useUiState();
|
|
2893
3563
|
const content = String(resolveBindable(node.content, state) ?? "");
|
|
2894
|
-
return /* @__PURE__ */ (0,
|
|
2895
|
-
/* @__PURE__ */ (0,
|
|
2896
|
-
/* @__PURE__ */ (0,
|
|
3564
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Tooltip, { children: [
|
|
3565
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: cn("aui-ui-tooltip-trigger inline-flex", node.className), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UiNodeView, { node: node.child }) }) }),
|
|
3566
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipContent, { side: node.side ?? "top", children: content })
|
|
2897
3567
|
] }) });
|
|
2898
3568
|
};
|
|
2899
3569
|
var DraggableNode = ({ node }) => {
|
|
@@ -2901,8 +3571,8 @@ var DraggableNode = ({ node }) => {
|
|
|
2901
3571
|
const snapBack = node.snapBack ?? true;
|
|
2902
3572
|
const axis = node.axis ?? "both";
|
|
2903
3573
|
const dragProp = axis === "both" ? true : axis;
|
|
2904
|
-
return /* @__PURE__ */ (0,
|
|
2905
|
-
|
|
3574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3575
|
+
import_react15.motion.div,
|
|
2906
3576
|
{
|
|
2907
3577
|
drag: dragProp,
|
|
2908
3578
|
dragMomentum: false,
|
|
@@ -2913,7 +3583,7 @@ var DraggableNode = ({ node }) => {
|
|
|
2913
3583
|
"aui-ui-draggable inline-block cursor-grab touch-none",
|
|
2914
3584
|
node.className
|
|
2915
3585
|
),
|
|
2916
|
-
children: /* @__PURE__ */ (0,
|
|
3586
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UiNodeView, { node: node.child })
|
|
2917
3587
|
}
|
|
2918
3588
|
);
|
|
2919
3589
|
};
|
|
@@ -2923,8 +3593,8 @@ var CustomNode = ({ node }) => {
|
|
|
2923
3593
|
const Renderer = registry[node.name];
|
|
2924
3594
|
if (!Renderer) return null;
|
|
2925
3595
|
const resolvedProps = resolveProps(node.props ?? {}, state);
|
|
2926
|
-
const children = node.children?.map((child, i) => /* @__PURE__ */ (0,
|
|
2927
|
-
return /* @__PURE__ */ (0,
|
|
3596
|
+
const children = node.children?.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UiNodeView, { node: child }, child.id ?? i));
|
|
3597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Renderer, { props: resolvedProps, children });
|
|
2928
3598
|
};
|
|
2929
3599
|
function resolveProps(props, state) {
|
|
2930
3600
|
const out = {};
|
|
@@ -2935,17 +3605,17 @@ function resolveProps(props, state) {
|
|
|
2935
3605
|
}
|
|
2936
3606
|
|
|
2937
3607
|
// src/artifacts/ui/ui-artifact.tsx
|
|
2938
|
-
var
|
|
3608
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2939
3609
|
var UiArtifactView = ({ artifact }) => {
|
|
2940
|
-
const [state, dispatch] = (0,
|
|
3610
|
+
const [state, dispatch] = (0, import_react17.useReducer)(
|
|
2941
3611
|
uiStateReducer,
|
|
2942
3612
|
artifact.initialState ?? {}
|
|
2943
3613
|
);
|
|
2944
|
-
return /* @__PURE__ */ (0,
|
|
3614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ArtifactCard, { title: artifact.title, kind: "ui", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(UiStateProvider, { state, dispatch, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "aui-ui-root p-3", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(UiNodeView, { node: artifact.root }) }) }) });
|
|
2945
3615
|
};
|
|
2946
3616
|
|
|
2947
3617
|
// src/artifacts/registry.tsx
|
|
2948
|
-
var
|
|
3618
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2949
3619
|
var defaultArtifactRenderers = {
|
|
2950
3620
|
chart: ChartArtifactView,
|
|
2951
3621
|
question: QuestionArtifactView,
|
|
@@ -2954,25 +3624,25 @@ var defaultArtifactRenderers = {
|
|
|
2954
3624
|
table: TableArtifactView,
|
|
2955
3625
|
ui: UiArtifactView
|
|
2956
3626
|
};
|
|
2957
|
-
var ArtifactRegistryContext = (0,
|
|
3627
|
+
var ArtifactRegistryContext = (0, import_react18.createContext)(
|
|
2958
3628
|
defaultArtifactRenderers
|
|
2959
3629
|
);
|
|
2960
3630
|
var ArtifactRegistryProvider = ({ renderers, override, children }) => {
|
|
2961
|
-
const merged = (0,
|
|
3631
|
+
const merged = (0, import_react18.useMemo)(() => {
|
|
2962
3632
|
if (!renderers) return defaultArtifactRenderers;
|
|
2963
3633
|
if (override) return renderers;
|
|
2964
3634
|
return { ...defaultArtifactRenderers, ...renderers };
|
|
2965
3635
|
}, [renderers, override]);
|
|
2966
|
-
return /* @__PURE__ */ (0,
|
|
3636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ArtifactRegistryContext.Provider, { value: merged, children });
|
|
2967
3637
|
};
|
|
2968
3638
|
function useArtifactRegistry() {
|
|
2969
|
-
return (0,
|
|
3639
|
+
return (0, import_react18.useContext)(ArtifactRegistryContext);
|
|
2970
3640
|
}
|
|
2971
3641
|
var ArtifactView = ({ artifact }) => {
|
|
2972
3642
|
const registry = useArtifactRegistry();
|
|
2973
3643
|
const Renderer = registry[artifact.type] ?? registry.json;
|
|
2974
3644
|
if (!Renderer) return null;
|
|
2975
|
-
return /* @__PURE__ */ (0,
|
|
3645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Renderer, { artifact });
|
|
2976
3646
|
};
|
|
2977
3647
|
|
|
2978
3648
|
// src/artifacts/parse.ts
|
|
@@ -3048,7 +3718,7 @@ var import_c = __toESM(require("shiki/langs/c.mjs"), 1);
|
|
|
3048
3718
|
var import_cpp = __toESM(require("shiki/langs/cpp.mjs"), 1);
|
|
3049
3719
|
var import_vitesse_dark = __toESM(require("shiki/themes/vitesse-dark.mjs"), 1);
|
|
3050
3720
|
var import_vitesse_light = __toESM(require("shiki/themes/vitesse-light.mjs"), 1);
|
|
3051
|
-
var
|
|
3721
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3052
3722
|
var SHIKI_THEME_DARK = "vitesse-dark";
|
|
3053
3723
|
var SHIKI_THEME_LIGHT = "vitesse-light";
|
|
3054
3724
|
var highlighterPromise = null;
|
|
@@ -3086,8 +3756,8 @@ var ShikiSyntaxHighlighter = ({
|
|
|
3086
3756
|
language,
|
|
3087
3757
|
code
|
|
3088
3758
|
}) => {
|
|
3089
|
-
const [html, setHtml] = (0,
|
|
3090
|
-
(0,
|
|
3759
|
+
const [html, setHtml] = (0, import_react19.useState)(null);
|
|
3760
|
+
(0, import_react19.useEffect)(() => {
|
|
3091
3761
|
let cancelled = false;
|
|
3092
3762
|
(async () => {
|
|
3093
3763
|
try {
|
|
@@ -3117,13 +3787,13 @@ var ShikiSyntaxHighlighter = ({
|
|
|
3117
3787
|
try {
|
|
3118
3788
|
const parsed = JSON.parse(code);
|
|
3119
3789
|
if (isArtifact(parsed)) {
|
|
3120
|
-
return /* @__PURE__ */ (0,
|
|
3790
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ArtifactView, { artifact: parsed });
|
|
3121
3791
|
}
|
|
3122
3792
|
} catch {
|
|
3123
3793
|
}
|
|
3124
3794
|
}
|
|
3125
3795
|
if (html) {
|
|
3126
|
-
return /* @__PURE__ */ (0,
|
|
3796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3127
3797
|
"div",
|
|
3128
3798
|
{
|
|
3129
3799
|
className: "shiki-wrapper [&>pre]:!m-0 [&>pre]:!rounded-t-none [&>pre]:!rounded-b-lg [&>pre]:!border [&>pre]:!border-t-0 [&>pre]:!border-border/50 [&>pre]:!p-3 [&>pre]:!text-xs [&>pre]:!leading-relaxed [&>pre]:overflow-x-auto",
|
|
@@ -3131,14 +3801,14 @@ var ShikiSyntaxHighlighter = ({
|
|
|
3131
3801
|
}
|
|
3132
3802
|
);
|
|
3133
3803
|
}
|
|
3134
|
-
return /* @__PURE__ */ (0,
|
|
3804
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Pre, { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Code2, { children: code }) });
|
|
3135
3805
|
};
|
|
3136
3806
|
var syntax_highlighter_default = ShikiSyntaxHighlighter;
|
|
3137
3807
|
|
|
3138
3808
|
// src/chat/markdown-text.tsx
|
|
3139
|
-
var
|
|
3809
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3140
3810
|
var MarkdownTextImpl = () => {
|
|
3141
|
-
return /* @__PURE__ */ (0,
|
|
3811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3142
3812
|
import_react_markdown.MarkdownTextPrimitive,
|
|
3143
3813
|
{
|
|
3144
3814
|
remarkPlugins: [import_remark_gfm.default, import_remark_math.default],
|
|
@@ -3151,7 +3821,7 @@ var MarkdownTextImpl = () => {
|
|
|
3151
3821
|
}
|
|
3152
3822
|
);
|
|
3153
3823
|
};
|
|
3154
|
-
var MarkdownText = (0,
|
|
3824
|
+
var MarkdownText = (0, import_react20.memo)(MarkdownTextImpl);
|
|
3155
3825
|
var CodeHeader = ({ language, code }) => {
|
|
3156
3826
|
const { isCopied, copyToClipboard } = useCopyToClipboard();
|
|
3157
3827
|
if (isArtifactFenceLanguage(language)) return null;
|
|
@@ -3159,20 +3829,20 @@ var CodeHeader = ({ language, code }) => {
|
|
|
3159
3829
|
if (!code || isCopied) return;
|
|
3160
3830
|
copyToClipboard(code);
|
|
3161
3831
|
};
|
|
3162
|
-
return /* @__PURE__ */ (0,
|
|
3163
|
-
/* @__PURE__ */ (0,
|
|
3164
|
-
/* @__PURE__ */ (0,
|
|
3832
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "aui-code-header flex items-center justify-between rounded-t-lg border border-b-0 border-border/50 bg-code-header-bg px-4 py-2", children: [
|
|
3833
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { className: "flex items-center gap-2 text-xs font-semibold tracking-wide text-muted-foreground/80 uppercase", children: [
|
|
3834
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/40" }),
|
|
3165
3835
|
language
|
|
3166
3836
|
] }),
|
|
3167
|
-
/* @__PURE__ */ (0,
|
|
3837
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3168
3838
|
TooltipIconButton,
|
|
3169
3839
|
{
|
|
3170
3840
|
tooltip: isCopied ? "Copied!" : "Copy",
|
|
3171
3841
|
onClick: onCopy,
|
|
3172
3842
|
className: "transition-colors hover:text-foreground",
|
|
3173
3843
|
children: [
|
|
3174
|
-
!isCopied && /* @__PURE__ */ (0,
|
|
3175
|
-
isCopied && /* @__PURE__ */ (0,
|
|
3844
|
+
!isCopied && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react4.CopyIcon, { className: "h-3.5 w-3.5" }),
|
|
3845
|
+
isCopied && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react4.CheckIcon, { className: "h-3.5 w-3.5 text-emerald-500" })
|
|
3176
3846
|
]
|
|
3177
3847
|
}
|
|
3178
3848
|
)
|
|
@@ -3181,7 +3851,7 @@ var CodeHeader = ({ language, code }) => {
|
|
|
3181
3851
|
var useCopyToClipboard = ({
|
|
3182
3852
|
copiedDuration = 3e3
|
|
3183
3853
|
} = {}) => {
|
|
3184
|
-
const [isCopied, setIsCopied] = (0,
|
|
3854
|
+
const [isCopied, setIsCopied] = (0, import_react20.useState)(false);
|
|
3185
3855
|
const copyToClipboard = (value) => {
|
|
3186
3856
|
if (!value) return;
|
|
3187
3857
|
navigator.clipboard.writeText(value).then(() => {
|
|
@@ -3192,7 +3862,7 @@ var useCopyToClipboard = ({
|
|
|
3192
3862
|
return { isCopied, copyToClipboard };
|
|
3193
3863
|
};
|
|
3194
3864
|
var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownComponents)({
|
|
3195
|
-
h1: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3865
|
+
h1: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3196
3866
|
"h1",
|
|
3197
3867
|
{
|
|
3198
3868
|
className: cn(
|
|
@@ -3202,7 +3872,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3202
3872
|
...props
|
|
3203
3873
|
}
|
|
3204
3874
|
),
|
|
3205
|
-
h2: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3875
|
+
h2: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3206
3876
|
"h2",
|
|
3207
3877
|
{
|
|
3208
3878
|
className: cn(
|
|
@@ -3212,7 +3882,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3212
3882
|
...props
|
|
3213
3883
|
}
|
|
3214
3884
|
),
|
|
3215
|
-
h3: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3885
|
+
h3: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3216
3886
|
"h3",
|
|
3217
3887
|
{
|
|
3218
3888
|
className: cn(
|
|
@@ -3222,7 +3892,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3222
3892
|
...props
|
|
3223
3893
|
}
|
|
3224
3894
|
),
|
|
3225
|
-
h4: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3895
|
+
h4: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3226
3896
|
"h4",
|
|
3227
3897
|
{
|
|
3228
3898
|
className: cn(
|
|
@@ -3232,7 +3902,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3232
3902
|
...props
|
|
3233
3903
|
}
|
|
3234
3904
|
),
|
|
3235
|
-
h5: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3905
|
+
h5: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3236
3906
|
"h5",
|
|
3237
3907
|
{
|
|
3238
3908
|
className: cn(
|
|
@@ -3242,7 +3912,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3242
3912
|
...props
|
|
3243
3913
|
}
|
|
3244
3914
|
),
|
|
3245
|
-
h6: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3915
|
+
h6: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3246
3916
|
"h6",
|
|
3247
3917
|
{
|
|
3248
3918
|
className: cn(
|
|
@@ -3252,7 +3922,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3252
3922
|
...props
|
|
3253
3923
|
}
|
|
3254
3924
|
),
|
|
3255
|
-
p: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3925
|
+
p: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3256
3926
|
"p",
|
|
3257
3927
|
{
|
|
3258
3928
|
className: cn(
|
|
@@ -3262,7 +3932,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3262
3932
|
...props
|
|
3263
3933
|
}
|
|
3264
3934
|
),
|
|
3265
|
-
a: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3935
|
+
a: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3266
3936
|
"a",
|
|
3267
3937
|
{
|
|
3268
3938
|
className: cn(
|
|
@@ -3274,7 +3944,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3274
3944
|
...props
|
|
3275
3945
|
}
|
|
3276
3946
|
),
|
|
3277
|
-
blockquote: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3947
|
+
blockquote: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3278
3948
|
"blockquote",
|
|
3279
3949
|
{
|
|
3280
3950
|
className: cn(
|
|
@@ -3284,7 +3954,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3284
3954
|
...props
|
|
3285
3955
|
}
|
|
3286
3956
|
),
|
|
3287
|
-
ul: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3957
|
+
ul: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3288
3958
|
"ul",
|
|
3289
3959
|
{
|
|
3290
3960
|
className: cn(
|
|
@@ -3294,7 +3964,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3294
3964
|
...props
|
|
3295
3965
|
}
|
|
3296
3966
|
),
|
|
3297
|
-
ol: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3967
|
+
ol: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3298
3968
|
"ol",
|
|
3299
3969
|
{
|
|
3300
3970
|
className: cn(
|
|
@@ -3304,7 +3974,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3304
3974
|
...props
|
|
3305
3975
|
}
|
|
3306
3976
|
),
|
|
3307
|
-
hr: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3977
|
+
hr: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3308
3978
|
"hr",
|
|
3309
3979
|
{
|
|
3310
3980
|
className: cn(
|
|
@@ -3314,14 +3984,14 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3314
3984
|
...props
|
|
3315
3985
|
}
|
|
3316
3986
|
),
|
|
3317
|
-
table: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3987
|
+
table: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "my-4 w-full overflow-x-auto rounded-lg border border-border/50", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3318
3988
|
"table",
|
|
3319
3989
|
{
|
|
3320
3990
|
className: cn("aui-md-table w-full border-collapse text-sm", className),
|
|
3321
3991
|
...props
|
|
3322
3992
|
}
|
|
3323
3993
|
) }),
|
|
3324
|
-
th: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3994
|
+
th: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3325
3995
|
"th",
|
|
3326
3996
|
{
|
|
3327
3997
|
className: cn(
|
|
@@ -3331,7 +4001,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3331
4001
|
...props
|
|
3332
4002
|
}
|
|
3333
4003
|
),
|
|
3334
|
-
td: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
4004
|
+
td: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3335
4005
|
"td",
|
|
3336
4006
|
{
|
|
3337
4007
|
className: cn(
|
|
@@ -3341,7 +4011,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3341
4011
|
...props
|
|
3342
4012
|
}
|
|
3343
4013
|
),
|
|
3344
|
-
tr: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
4014
|
+
tr: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3345
4015
|
"tr",
|
|
3346
4016
|
{
|
|
3347
4017
|
className: cn(
|
|
@@ -3351,8 +4021,8 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3351
4021
|
...props
|
|
3352
4022
|
}
|
|
3353
4023
|
),
|
|
3354
|
-
li: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3355
|
-
sup: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
4024
|
+
li: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("li", { className: cn("aui-md-li leading-[1.7]", className), ...props }),
|
|
4025
|
+
sup: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3356
4026
|
"sup",
|
|
3357
4027
|
{
|
|
3358
4028
|
className: cn(
|
|
@@ -3362,7 +4032,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3362
4032
|
...props
|
|
3363
4033
|
}
|
|
3364
4034
|
),
|
|
3365
|
-
pre: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
4035
|
+
pre: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3366
4036
|
"pre",
|
|
3367
4037
|
{
|
|
3368
4038
|
className: cn(
|
|
@@ -3374,7 +4044,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3374
4044
|
),
|
|
3375
4045
|
code: function Code({ className, ...props }) {
|
|
3376
4046
|
const isCodeBlock = (0, import_react_markdown.useIsMarkdownCodeBlock)();
|
|
3377
|
-
return /* @__PURE__ */ (0,
|
|
4047
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3378
4048
|
"code",
|
|
3379
4049
|
{
|
|
3380
4050
|
className: cn(
|
|
@@ -3385,20 +4055,20 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3385
4055
|
}
|
|
3386
4056
|
);
|
|
3387
4057
|
},
|
|
3388
|
-
strong: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3389
|
-
em: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
4058
|
+
strong: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("strong", { className: cn("font-semibold text-foreground", className), ...props }),
|
|
4059
|
+
em: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("em", { className: cn("italic", className), ...props }),
|
|
3390
4060
|
CodeHeader
|
|
3391
4061
|
});
|
|
3392
4062
|
|
|
3393
4063
|
// src/chat/tool-fallback.tsx
|
|
3394
|
-
var
|
|
4064
|
+
var import_react24 = require("react");
|
|
3395
4065
|
var import_lucide_react5 = require("lucide-react");
|
|
3396
|
-
var
|
|
4066
|
+
var import_react25 = require("@assistant-ui/react");
|
|
3397
4067
|
|
|
3398
4068
|
// src/ui/shimmer.tsx
|
|
3399
|
-
var
|
|
3400
|
-
var
|
|
3401
|
-
var
|
|
4069
|
+
var import_react21 = require("motion/react");
|
|
4070
|
+
var import_react22 = require("react");
|
|
4071
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3402
4072
|
var ShimmerComponent = ({
|
|
3403
4073
|
children,
|
|
3404
4074
|
as: Component = "p",
|
|
@@ -3406,14 +4076,14 @@ var ShimmerComponent = ({
|
|
|
3406
4076
|
duration = 2,
|
|
3407
4077
|
spread = 2
|
|
3408
4078
|
}) => {
|
|
3409
|
-
const MotionComponent =
|
|
4079
|
+
const MotionComponent = import_react21.motion.create(
|
|
3410
4080
|
Component
|
|
3411
4081
|
);
|
|
3412
|
-
const dynamicSpread = (0,
|
|
4082
|
+
const dynamicSpread = (0, import_react22.useMemo)(
|
|
3413
4083
|
() => (children?.length ?? 0) * spread,
|
|
3414
4084
|
[children, spread]
|
|
3415
4085
|
);
|
|
3416
|
-
return /* @__PURE__ */ (0,
|
|
4086
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3417
4087
|
MotionComponent,
|
|
3418
4088
|
{
|
|
3419
4089
|
animate: { backgroundPosition: "0% center" },
|
|
@@ -3436,11 +4106,11 @@ var ShimmerComponent = ({
|
|
|
3436
4106
|
}
|
|
3437
4107
|
);
|
|
3438
4108
|
};
|
|
3439
|
-
var Shimmer = (0,
|
|
4109
|
+
var Shimmer = (0, import_react22.memo)(ShimmerComponent);
|
|
3440
4110
|
|
|
3441
4111
|
// src/chat/motion.tsx
|
|
3442
|
-
var
|
|
3443
|
-
var
|
|
4112
|
+
var import_react23 = require("motion/react");
|
|
4113
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3444
4114
|
var luxuryEase = [0.16, 1, 0.3, 1];
|
|
3445
4115
|
var TOOL_ENTER_MS = 0.78;
|
|
3446
4116
|
var TOOL_EXIT_MS = 0.28;
|
|
@@ -3466,10 +4136,10 @@ function toolMotionState(reduced, entering, variant) {
|
|
|
3466
4136
|
return entering ? { opacity: 0, y: 14, filter: "blur(10px)" } : { opacity: 1, y: 0, filter: "blur(0px)" };
|
|
3467
4137
|
}
|
|
3468
4138
|
function ToolMotion({ children, className, motionKey }) {
|
|
3469
|
-
const reduced = (0,
|
|
4139
|
+
const reduced = (0, import_react23.useReducedMotion)() ?? false;
|
|
3470
4140
|
const { enter, exit } = toolPresenceTransition(reduced);
|
|
3471
|
-
return /* @__PURE__ */ (0,
|
|
3472
|
-
|
|
4141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4142
|
+
import_react23.motion.div,
|
|
3473
4143
|
{
|
|
3474
4144
|
className: cn("aui-tool-motion w-full min-w-0", className),
|
|
3475
4145
|
initial: toolMotionState(reduced, true, "settled"),
|
|
@@ -3488,11 +4158,11 @@ function ToolPresence({
|
|
|
3488
4158
|
className,
|
|
3489
4159
|
variant = "settled"
|
|
3490
4160
|
}) {
|
|
3491
|
-
const reduced = (0,
|
|
4161
|
+
const reduced = (0, import_react23.useReducedMotion)() ?? false;
|
|
3492
4162
|
const { enter, exit } = toolPresenceTransition(reduced);
|
|
3493
4163
|
const enterTransition = variant === "executing" ? { duration: reduced ? 0.3 : 0.52, ease: luxuryEase } : enter;
|
|
3494
|
-
return /* @__PURE__ */ (0,
|
|
3495
|
-
|
|
4164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react23.AnimatePresence, { mode: "wait", initial: true, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4165
|
+
import_react23.motion.div,
|
|
3496
4166
|
{
|
|
3497
4167
|
className: cn("aui-tool-presence w-full min-w-0", className),
|
|
3498
4168
|
initial: toolMotionState(reduced, true, variant),
|
|
@@ -3512,8 +4182,8 @@ function ToolBodyPresence({
|
|
|
3512
4182
|
children,
|
|
3513
4183
|
className
|
|
3514
4184
|
}) {
|
|
3515
|
-
const reduced = (0,
|
|
3516
|
-
return /* @__PURE__ */ (0,
|
|
4185
|
+
const reduced = (0, import_react23.useReducedMotion)() ?? false;
|
|
4186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3517
4187
|
"div",
|
|
3518
4188
|
{
|
|
3519
4189
|
className: cn(
|
|
@@ -3521,7 +4191,7 @@ function ToolBodyPresence({
|
|
|
3521
4191
|
open ? reduced ? "duration-200 ease-out" : "duration-[340ms] ease-[cubic-bezier(0.16,1,0.3,1)]" : reduced ? "duration-150 ease-[cubic-bezier(0.4,0,0.2,1)]" : "duration-200 ease-[cubic-bezier(0.4,0,0.2,1)]"
|
|
3522
4192
|
),
|
|
3523
4193
|
style: { gridTemplateRows: open ? "1fr" : "0fr" },
|
|
3524
|
-
children: /* @__PURE__ */ (0,
|
|
4194
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3525
4195
|
"div",
|
|
3526
4196
|
{
|
|
3527
4197
|
className: cn(
|
|
@@ -3537,7 +4207,7 @@ function ToolBodyPresence({
|
|
|
3537
4207
|
}
|
|
3538
4208
|
|
|
3539
4209
|
// src/chat/tool-fallback.tsx
|
|
3540
|
-
var
|
|
4210
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3541
4211
|
function detectRunning({
|
|
3542
4212
|
status,
|
|
3543
4213
|
result,
|
|
@@ -3551,7 +4221,7 @@ function detectRunning({
|
|
|
3551
4221
|
}
|
|
3552
4222
|
function useToolRunning(props) {
|
|
3553
4223
|
const { isRunning: streamRunning } = useTimbalRuntime();
|
|
3554
|
-
const partStatus = (0,
|
|
4224
|
+
const partStatus = (0, import_react25.useAuiState)((s) => s.part.status);
|
|
3555
4225
|
return detectRunning({
|
|
3556
4226
|
status: partStatus ?? props.status,
|
|
3557
4227
|
result: props.result,
|
|
@@ -3569,8 +4239,8 @@ function formatToolResult(result) {
|
|
|
3569
4239
|
return String(result);
|
|
3570
4240
|
}
|
|
3571
4241
|
}
|
|
3572
|
-
var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__ */ (0,
|
|
3573
|
-
action ? shimmer ? /* @__PURE__ */ (0,
|
|
4242
|
+
var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("span", { className: "inline-flex min-w-0 max-w-full items-baseline gap-1", children: [
|
|
4243
|
+
action ? shimmer ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3574
4244
|
Shimmer,
|
|
3575
4245
|
{
|
|
3576
4246
|
as: "span",
|
|
@@ -3579,10 +4249,10 @@ var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__
|
|
|
3579
4249
|
spread: 2.5,
|
|
3580
4250
|
children: action
|
|
3581
4251
|
}
|
|
3582
|
-
) : /* @__PURE__ */ (0,
|
|
3583
|
-
detail ? /* @__PURE__ */ (0,
|
|
4252
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: studioTimelineActionClass, children: action }) : null,
|
|
4253
|
+
detail ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: studioTimelineDetailClass, children: detail }) : null
|
|
3584
4254
|
] });
|
|
3585
|
-
var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0,
|
|
4255
|
+
var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3586
4256
|
import_lucide_react5.ChevronRightIcon,
|
|
3587
4257
|
{
|
|
3588
4258
|
className: studioTimelineChevronClass(expanded),
|
|
@@ -3590,9 +4260,9 @@ var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0, import_jsx_runt
|
|
|
3590
4260
|
}
|
|
3591
4261
|
);
|
|
3592
4262
|
var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
3593
|
-
const [open, setOpen] = (0,
|
|
4263
|
+
const [open, setOpen] = (0, import_react24.useState)(false);
|
|
3594
4264
|
const detail = formatToolLabel(toolName);
|
|
3595
|
-
const formattedArgs = (0,
|
|
4265
|
+
const formattedArgs = (0, import_react24.useMemo)(() => {
|
|
3596
4266
|
if (!argsText || argsText === "{}") return null;
|
|
3597
4267
|
try {
|
|
3598
4268
|
return JSON.stringify(JSON.parse(argsText), null, 2);
|
|
@@ -3600,17 +4270,17 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3600
4270
|
return argsText;
|
|
3601
4271
|
}
|
|
3602
4272
|
}, [argsText]);
|
|
3603
|
-
const formattedResult = (0,
|
|
4273
|
+
const formattedResult = (0, import_react24.useMemo)(() => {
|
|
3604
4274
|
if (result === void 0 || result === null) return null;
|
|
3605
4275
|
return formatToolResult(result);
|
|
3606
4276
|
}, [result]);
|
|
3607
4277
|
const hasBody = Boolean(formattedArgs || formattedResult);
|
|
3608
4278
|
const action = isError ? "Failed" : "Used";
|
|
3609
4279
|
if (!hasBody) {
|
|
3610
|
-
return /* @__PURE__ */ (0,
|
|
4280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "aui-tool-row w-full min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TimelineActionLabel, { action, detail }) });
|
|
3611
4281
|
}
|
|
3612
|
-
return /* @__PURE__ */ (0,
|
|
3613
|
-
/* @__PURE__ */ (0,
|
|
4282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "aui-tool-row w-full min-w-0", children: [
|
|
4283
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3614
4284
|
"button",
|
|
3615
4285
|
{
|
|
3616
4286
|
type: "button",
|
|
@@ -3618,7 +4288,7 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3618
4288
|
"aria-expanded": open,
|
|
3619
4289
|
"aria-label": `${action} ${detail}`,
|
|
3620
4290
|
className: studioTimelineRowButtonClass,
|
|
3621
|
-
children: /* @__PURE__ */ (0,
|
|
4291
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
3622
4292
|
"span",
|
|
3623
4293
|
{
|
|
3624
4294
|
className: cn(
|
|
@@ -3627,37 +4297,37 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3627
4297
|
"text-foreground"
|
|
3628
4298
|
),
|
|
3629
4299
|
children: [
|
|
3630
|
-
/* @__PURE__ */ (0,
|
|
3631
|
-
/* @__PURE__ */ (0,
|
|
4300
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TimelineActionLabel, { action, detail }),
|
|
4301
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TimelineHoverChevron, { expanded: open })
|
|
3632
4302
|
]
|
|
3633
4303
|
}
|
|
3634
4304
|
)
|
|
3635
4305
|
}
|
|
3636
4306
|
),
|
|
3637
|
-
/* @__PURE__ */ (0,
|
|
4307
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
3638
4308
|
ToolBodyPresence,
|
|
3639
4309
|
{
|
|
3640
4310
|
open,
|
|
3641
4311
|
className: cn(studioTimelineBodyPadClass, "gap-2"),
|
|
3642
4312
|
children: [
|
|
3643
|
-
formattedArgs ? /* @__PURE__ */ (0,
|
|
4313
|
+
formattedArgs ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3644
4314
|
"div",
|
|
3645
4315
|
{
|
|
3646
4316
|
className: cn(
|
|
3647
4317
|
studioComposerIoWellClass,
|
|
3648
4318
|
"max-h-48 overflow-auto px-2.5 py-2"
|
|
3649
4319
|
),
|
|
3650
|
-
children: /* @__PURE__ */ (0,
|
|
4320
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("pre", { className: "whitespace-pre-wrap break-words font-mono text-[11px] font-normal leading-relaxed text-foreground", children: formattedArgs })
|
|
3651
4321
|
}
|
|
3652
4322
|
) : null,
|
|
3653
|
-
formattedResult ? /* @__PURE__ */ (0,
|
|
4323
|
+
formattedResult ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3654
4324
|
"div",
|
|
3655
4325
|
{
|
|
3656
4326
|
className: cn(
|
|
3657
4327
|
studioComposerIoWellClass,
|
|
3658
4328
|
"max-h-48 overflow-auto px-2.5 py-2"
|
|
3659
4329
|
),
|
|
3660
|
-
children: /* @__PURE__ */ (0,
|
|
4330
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("pre", { className: "whitespace-pre-wrap break-words font-mono text-[11px] font-normal leading-relaxed text-foreground", children: formattedResult })
|
|
3661
4331
|
}
|
|
3662
4332
|
) : null
|
|
3663
4333
|
]
|
|
@@ -3674,20 +4344,20 @@ var ToolFallbackImpl = ({
|
|
|
3674
4344
|
const isRunning = useToolRunning({ status, result });
|
|
3675
4345
|
const isError = status?.type === "incomplete" && status.reason !== "cancelled";
|
|
3676
4346
|
const presenceKey = isRunning ? "running" : isError ? "error" : "complete";
|
|
3677
|
-
return /* @__PURE__ */ (0,
|
|
4347
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3678
4348
|
ToolPresence,
|
|
3679
4349
|
{
|
|
3680
4350
|
presenceKey,
|
|
3681
4351
|
variant: isRunning ? "executing" : "settled",
|
|
3682
4352
|
className: "py-0.5",
|
|
3683
|
-
children: isRunning ? /* @__PURE__ */ (0,
|
|
4353
|
+
children: isRunning ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "aui-tool-running", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3684
4354
|
TimelineActionLabel,
|
|
3685
4355
|
{
|
|
3686
4356
|
action: "Using",
|
|
3687
4357
|
detail: formatToolLabel(toolName),
|
|
3688
4358
|
shimmer: true
|
|
3689
4359
|
}
|
|
3690
|
-
) }) : /* @__PURE__ */ (0,
|
|
4360
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3691
4361
|
ToolPanel,
|
|
3692
4362
|
{
|
|
3693
4363
|
toolName,
|
|
@@ -3699,13 +4369,13 @@ var ToolFallbackImpl = ({
|
|
|
3699
4369
|
}
|
|
3700
4370
|
);
|
|
3701
4371
|
};
|
|
3702
|
-
var ToolFallback = (0,
|
|
4372
|
+
var ToolFallback = (0, import_react24.memo)(
|
|
3703
4373
|
ToolFallbackImpl
|
|
3704
4374
|
);
|
|
3705
4375
|
ToolFallback.displayName = "ToolFallback";
|
|
3706
4376
|
|
|
3707
4377
|
// src/artifacts/tool-artifact.tsx
|
|
3708
|
-
var
|
|
4378
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
3709
4379
|
var ToolArtifactFallback = (props) => {
|
|
3710
4380
|
const registry = useArtifactRegistry();
|
|
3711
4381
|
const isRunning = useToolRunning({
|
|
@@ -3717,24 +4387,24 @@ var ToolArtifactFallback = (props) => {
|
|
|
3717
4387
|
if (artifact) {
|
|
3718
4388
|
const Renderer = registry[artifact.type];
|
|
3719
4389
|
if (Renderer) {
|
|
3720
|
-
return /* @__PURE__ */ (0,
|
|
4390
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3721
4391
|
ToolMotion,
|
|
3722
4392
|
{
|
|
3723
4393
|
motionKey: `artifact-${artifact.type}`,
|
|
3724
4394
|
className: "aui-tool-artifact",
|
|
3725
|
-
children: /* @__PURE__ */ (0,
|
|
4395
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Renderer, { artifact })
|
|
3726
4396
|
}
|
|
3727
4397
|
);
|
|
3728
4398
|
}
|
|
3729
4399
|
}
|
|
3730
4400
|
}
|
|
3731
|
-
return /* @__PURE__ */ (0,
|
|
4401
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ToolFallback, { ...props });
|
|
3732
4402
|
};
|
|
3733
4403
|
|
|
3734
4404
|
// src/chat/composer.tsx
|
|
3735
|
-
var
|
|
4405
|
+
var import_react26 = require("@assistant-ui/react");
|
|
3736
4406
|
var import_lucide_react6 = require("lucide-react");
|
|
3737
|
-
var
|
|
4407
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
3738
4408
|
var Composer = ({
|
|
3739
4409
|
placeholder = "Send a message...",
|
|
3740
4410
|
showAttachments,
|
|
@@ -3745,10 +4415,10 @@ var Composer = ({
|
|
|
3745
4415
|
}) => {
|
|
3746
4416
|
const attachmentsEnabled = useTimbalAttachmentsEnabled();
|
|
3747
4417
|
const attachUi = showAttachments !== false && attachmentsEnabled;
|
|
3748
|
-
const shell = /* @__PURE__ */ (0,
|
|
3749
|
-
attachUi && /* @__PURE__ */ (0,
|
|
3750
|
-
/* @__PURE__ */ (0,
|
|
3751
|
-
/* @__PURE__ */ (0,
|
|
4418
|
+
const shell = /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
4419
|
+
attachUi && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComposerAttachments, {}),
|
|
4420
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComposerInput, { placeholder, autoFocus: !noAutoFocus }),
|
|
4421
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3752
4422
|
ComposerToolbar,
|
|
3753
4423
|
{
|
|
3754
4424
|
showAttachments: attachUi,
|
|
@@ -3757,15 +4427,15 @@ var Composer = ({
|
|
|
3757
4427
|
}
|
|
3758
4428
|
)
|
|
3759
4429
|
] });
|
|
3760
|
-
return /* @__PURE__ */ (0,
|
|
3761
|
-
|
|
4430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4431
|
+
import_react26.ComposerPrimitive.Root,
|
|
3762
4432
|
{
|
|
3763
4433
|
className: cn(
|
|
3764
4434
|
"aui-composer-root relative flex w-full flex-col",
|
|
3765
4435
|
className
|
|
3766
4436
|
),
|
|
3767
|
-
children: attachUi ? /* @__PURE__ */ (0,
|
|
3768
|
-
|
|
4437
|
+
children: attachUi ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4438
|
+
import_react26.ComposerPrimitive.AttachmentDropzone,
|
|
3769
4439
|
{
|
|
3770
4440
|
className: cn(
|
|
3771
4441
|
studioComposeInputShellClass,
|
|
@@ -3773,7 +4443,7 @@ var Composer = ({
|
|
|
3773
4443
|
),
|
|
3774
4444
|
children: shell
|
|
3775
4445
|
}
|
|
3776
|
-
) : /* @__PURE__ */ (0,
|
|
4446
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: studioComposeInputShellClass, children: shell })
|
|
3777
4447
|
}
|
|
3778
4448
|
);
|
|
3779
4449
|
};
|
|
@@ -3781,7 +4451,7 @@ var ComposerInput = ({
|
|
|
3781
4451
|
placeholder,
|
|
3782
4452
|
autoFocus
|
|
3783
4453
|
}) => {
|
|
3784
|
-
const composer = (0,
|
|
4454
|
+
const composer = (0, import_react26.useComposerRuntime)();
|
|
3785
4455
|
const onKeyDown = (e) => {
|
|
3786
4456
|
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
|
|
3787
4457
|
e.preventDefault();
|
|
@@ -3793,8 +4463,8 @@ var ComposerInput = ({
|
|
|
3793
4463
|
el.style.height = "auto";
|
|
3794
4464
|
el.style.height = `${Math.min(el.scrollHeight, 240)}px`;
|
|
3795
4465
|
};
|
|
3796
|
-
return /* @__PURE__ */ (0,
|
|
3797
|
-
|
|
4466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4467
|
+
import_react26.ComposerPrimitive.Input,
|
|
3798
4468
|
{
|
|
3799
4469
|
placeholder,
|
|
3800
4470
|
className: "aui-composer-input max-h-60 min-h-14 w-full resize-none bg-composer-bg px-3 pt-3 pb-1 text-sm outline-none placeholder:text-muted-foreground/70 focus-visible:ring-0",
|
|
@@ -3807,17 +4477,17 @@ var ComposerInput = ({
|
|
|
3807
4477
|
);
|
|
3808
4478
|
};
|
|
3809
4479
|
var ComposerToolbar = ({ showAttachments, toolbar, sendTooltip }) => {
|
|
3810
|
-
return /* @__PURE__ */ (0,
|
|
3811
|
-
/* @__PURE__ */ (0,
|
|
3812
|
-
showAttachments && /* @__PURE__ */ (0,
|
|
4480
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "aui-composer-action-wrapper relative z-[1] flex items-center justify-between gap-1 bg-composer-bg px-2.5 pb-2.5", children: [
|
|
4481
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
4482
|
+
showAttachments && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComposerAddAttachment, {}),
|
|
3813
4483
|
toolbar
|
|
3814
4484
|
] }),
|
|
3815
|
-
/* @__PURE__ */ (0,
|
|
4485
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComposerSendOrCancel, { sendTooltip })
|
|
3816
4486
|
] });
|
|
3817
4487
|
};
|
|
3818
4488
|
var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
3819
|
-
return /* @__PURE__ */ (0,
|
|
3820
|
-
/* @__PURE__ */ (0,
|
|
4489
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
4490
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react26.AuiIf, { condition: (s) => !s.thread.isRunning, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react26.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3821
4491
|
TooltipIconButton,
|
|
3822
4492
|
{
|
|
3823
4493
|
tooltip: sendTooltip,
|
|
@@ -3825,34 +4495,34 @@ var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
|
3825
4495
|
type: "submit",
|
|
3826
4496
|
className: "aui-composer-send shrink-0 disabled:opacity-30",
|
|
3827
4497
|
"aria-label": "Send message",
|
|
3828
|
-
children: /* @__PURE__ */ (0,
|
|
4498
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_lucide_react6.ArrowUpIcon, { className: "aui-composer-send-icon size-4" })
|
|
3829
4499
|
}
|
|
3830
4500
|
) }) }),
|
|
3831
|
-
/* @__PURE__ */ (0,
|
|
4501
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react26.AuiIf, { condition: (s) => s.thread.isRunning, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react26.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3832
4502
|
TooltipIconButton,
|
|
3833
4503
|
{
|
|
3834
4504
|
tooltip: "Stop generating",
|
|
3835
4505
|
variant: "primary",
|
|
3836
4506
|
className: "aui-composer-cancel shrink-0",
|
|
3837
4507
|
"aria-label": "Stop generating",
|
|
3838
|
-
children: /* @__PURE__ */ (0,
|
|
4508
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_lucide_react6.SquareIcon, { className: "aui-composer-cancel-icon size-3 fill-current" })
|
|
3839
4509
|
}
|
|
3840
4510
|
) }) })
|
|
3841
4511
|
] });
|
|
3842
4512
|
};
|
|
3843
4513
|
|
|
3844
4514
|
// src/chat/suggestions.tsx
|
|
3845
|
-
var
|
|
3846
|
-
var
|
|
4515
|
+
var import_react27 = require("react");
|
|
4516
|
+
var import_react28 = require("@assistant-ui/react");
|
|
3847
4517
|
var import_lucide_react7 = require("lucide-react");
|
|
3848
|
-
var
|
|
4518
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
3849
4519
|
var Suggestions = ({
|
|
3850
4520
|
suggestions,
|
|
3851
4521
|
className
|
|
3852
4522
|
}) => {
|
|
3853
4523
|
const items = useResolvedSuggestions(suggestions);
|
|
3854
4524
|
if (!items || items.length === 0) return null;
|
|
3855
|
-
return /* @__PURE__ */ (0,
|
|
4525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3856
4526
|
"div",
|
|
3857
4527
|
{
|
|
3858
4528
|
className: cn(
|
|
@@ -3861,17 +4531,17 @@ var Suggestions = ({
|
|
|
3861
4531
|
),
|
|
3862
4532
|
role: "list",
|
|
3863
4533
|
"aria-label": "Suggested prompts",
|
|
3864
|
-
children: items.map((suggestion, i) => /* @__PURE__ */ (0,
|
|
4534
|
+
children: items.map((suggestion, i) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SuggestionRow, { suggestion }, (suggestion.prompt ?? suggestion.title) + i))
|
|
3865
4535
|
}
|
|
3866
4536
|
);
|
|
3867
4537
|
};
|
|
3868
4538
|
var SuggestionRow = ({ suggestion }) => {
|
|
3869
|
-
const runtime = (0,
|
|
4539
|
+
const runtime = (0, import_react28.useThreadRuntime)();
|
|
3870
4540
|
const onClick = () => {
|
|
3871
4541
|
const text = suggestion.prompt ?? suggestion.title;
|
|
3872
4542
|
runtime.append({ role: "user", content: [{ type: "text", text }] });
|
|
3873
4543
|
};
|
|
3874
|
-
return /* @__PURE__ */ (0,
|
|
4544
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
3875
4545
|
"button",
|
|
3876
4546
|
{
|
|
3877
4547
|
type: "button",
|
|
@@ -3879,20 +4549,20 @@ var SuggestionRow = ({ suggestion }) => {
|
|
|
3879
4549
|
onClick,
|
|
3880
4550
|
className: cn("aui-thread-suggestion", studioListRowButtonClass),
|
|
3881
4551
|
children: [
|
|
3882
|
-
/* @__PURE__ */ (0,
|
|
3883
|
-
/* @__PURE__ */ (0,
|
|
3884
|
-
/* @__PURE__ */ (0,
|
|
3885
|
-
suggestion.description && /* @__PURE__ */ (0,
|
|
4552
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "aui-thread-suggestion-icon shrink-0 text-muted-foreground", children: suggestion.icon ?? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react7.ArrowUpIcon, { className: "size-4", strokeWidth: 1.75, "aria-hidden": true }) }),
|
|
4553
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("span", { className: "aui-thread-suggestion-text min-w-0 flex-1 text-left", children: [
|
|
4554
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "aui-thread-suggestion-text-1 block truncate text-sm font-normal text-foreground", children: suggestion.title }),
|
|
4555
|
+
suggestion.description && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "aui-thread-suggestion-text-2 mt-0.5 block truncate text-xs text-muted-foreground", children: suggestion.description })
|
|
3886
4556
|
] })
|
|
3887
4557
|
]
|
|
3888
4558
|
}
|
|
3889
4559
|
);
|
|
3890
4560
|
};
|
|
3891
4561
|
function useResolvedSuggestions(source) {
|
|
3892
|
-
const [resolved, setResolved] = (0,
|
|
4562
|
+
const [resolved, setResolved] = (0, import_react27.useState)(
|
|
3893
4563
|
() => Array.isArray(source) ? source : void 0
|
|
3894
4564
|
);
|
|
3895
|
-
(0,
|
|
4565
|
+
(0, import_react27.useEffect)(() => {
|
|
3896
4566
|
if (!source) {
|
|
3897
4567
|
setResolved(void 0);
|
|
3898
4568
|
return;
|
|
@@ -3911,7 +4581,7 @@ function useResolvedSuggestions(source) {
|
|
|
3911
4581
|
cancelled = true;
|
|
3912
4582
|
};
|
|
3913
4583
|
}, [source]);
|
|
3914
|
-
return (0,
|
|
4584
|
+
return (0, import_react27.useMemo)(() => resolved, [resolved]);
|
|
3915
4585
|
}
|
|
3916
4586
|
|
|
3917
4587
|
// src/design/theme-sanity.ts
|
|
@@ -3984,15 +4654,15 @@ function scheduleThemeSanityCheck() {
|
|
|
3984
4654
|
}
|
|
3985
4655
|
|
|
3986
4656
|
// src/chat/thread-variant.tsx
|
|
3987
|
-
var
|
|
3988
|
-
var ThreadVariantContext = (0,
|
|
4657
|
+
var import_react29 = require("react");
|
|
4658
|
+
var ThreadVariantContext = (0, import_react29.createContext)("default");
|
|
3989
4659
|
var ThreadVariantProvider = ThreadVariantContext.Provider;
|
|
3990
4660
|
function useThreadVariant() {
|
|
3991
|
-
return (0,
|
|
4661
|
+
return (0, import_react29.useContext)(ThreadVariantContext);
|
|
3992
4662
|
}
|
|
3993
4663
|
|
|
3994
4664
|
// src/chat/thread.tsx
|
|
3995
|
-
var
|
|
4665
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
3996
4666
|
var Thread = ({
|
|
3997
4667
|
className,
|
|
3998
4668
|
variant = "default",
|
|
@@ -4015,17 +4685,17 @@ var Thread = ({
|
|
|
4015
4685
|
const EditComposerSlot = components?.EditComposer ?? EditComposer;
|
|
4016
4686
|
const ScrollToBottomSlot = components?.ScrollToBottom ?? ThreadScrollToBottom;
|
|
4017
4687
|
const SuggestionsSlot = components?.Suggestions ?? Suggestions;
|
|
4018
|
-
(0,
|
|
4688
|
+
(0, import_react30.useEffect)(() => {
|
|
4019
4689
|
scheduleThemeSanityCheck();
|
|
4020
4690
|
}, []);
|
|
4021
|
-
return /* @__PURE__ */ (0,
|
|
4691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ThreadVariantProvider, { value: variant, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4022
4692
|
ArtifactRegistryProvider,
|
|
4023
4693
|
{
|
|
4024
4694
|
renderers: artifacts?.renderers,
|
|
4025
4695
|
override: artifacts?.override,
|
|
4026
|
-
children: /* @__PURE__ */ (0,
|
|
4027
|
-
}), children: /* @__PURE__ */ (0,
|
|
4028
|
-
|
|
4696
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(UiEventProvider, { onEvent: onArtifactEvent ?? (() => {
|
|
4697
|
+
}), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4698
|
+
import_react31.ThreadPrimitive.Root,
|
|
4029
4699
|
{
|
|
4030
4700
|
className: cn(
|
|
4031
4701
|
"aui-root aui-thread-root @container flex h-full flex-col bg-transparent",
|
|
@@ -4034,8 +4704,8 @@ var Thread = ({
|
|
|
4034
4704
|
),
|
|
4035
4705
|
style: { ["--thread-max-width"]: maxWidth },
|
|
4036
4706
|
"data-thread-variant": variant,
|
|
4037
|
-
children: /* @__PURE__ */ (0,
|
|
4038
|
-
|
|
4707
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4708
|
+
import_react31.ThreadPrimitive.Viewport,
|
|
4039
4709
|
{
|
|
4040
4710
|
turnAnchor: "bottom",
|
|
4041
4711
|
className: cn(
|
|
@@ -4043,7 +4713,7 @@ var Thread = ({
|
|
|
4043
4713
|
isPanel ? "px-2 pt-2" : "px-4 pt-4"
|
|
4044
4714
|
),
|
|
4045
4715
|
children: [
|
|
4046
|
-
/* @__PURE__ */ (0,
|
|
4716
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4047
4717
|
WelcomeSlot,
|
|
4048
4718
|
{
|
|
4049
4719
|
config: welcome,
|
|
@@ -4052,8 +4722,8 @@ var Thread = ({
|
|
|
4052
4722
|
Suggestions: SuggestionsSlot
|
|
4053
4723
|
}
|
|
4054
4724
|
),
|
|
4055
|
-
/* @__PURE__ */ (0,
|
|
4056
|
-
|
|
4725
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4726
|
+
import_react31.ThreadPrimitive.Messages,
|
|
4057
4727
|
{
|
|
4058
4728
|
components: {
|
|
4059
4729
|
UserMessage: UserMessageSlot,
|
|
@@ -4062,14 +4732,14 @@ var Thread = ({
|
|
|
4062
4732
|
}
|
|
4063
4733
|
}
|
|
4064
4734
|
),
|
|
4065
|
-
/* @__PURE__ */ (0,
|
|
4066
|
-
|
|
4735
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4736
|
+
import_react31.ThreadPrimitive.ViewportFooter,
|
|
4067
4737
|
{
|
|
4068
4738
|
className: cn(
|
|
4069
4739
|
"aui-thread-viewport-footer sticky bottom-0 z-10 mt-auto w-full isolate pt-2",
|
|
4070
4740
|
isPanel ? "bg-card pb-2" : "bg-background pb-4 md:pb-6"
|
|
4071
4741
|
),
|
|
4072
|
-
children: /* @__PURE__ */ (0,
|
|
4742
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4073
4743
|
"div",
|
|
4074
4744
|
{
|
|
4075
4745
|
className: cn(
|
|
@@ -4077,8 +4747,8 @@ var Thread = ({
|
|
|
4077
4747
|
isPanel ? "gap-2" : "gap-4"
|
|
4078
4748
|
),
|
|
4079
4749
|
children: [
|
|
4080
|
-
/* @__PURE__ */ (0,
|
|
4081
|
-
/* @__PURE__ */ (0,
|
|
4750
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ScrollToBottomSlot, {}),
|
|
4751
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ComposerSlot, { placeholder })
|
|
4082
4752
|
]
|
|
4083
4753
|
}
|
|
4084
4754
|
)
|
|
@@ -4093,13 +4763,13 @@ var Thread = ({
|
|
|
4093
4763
|
) });
|
|
4094
4764
|
};
|
|
4095
4765
|
var ThreadScrollToBottom = () => {
|
|
4096
|
-
return /* @__PURE__ */ (0,
|
|
4766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ThreadPrimitive.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4097
4767
|
TooltipIconButton,
|
|
4098
4768
|
{
|
|
4099
4769
|
tooltip: "Scroll to bottom",
|
|
4100
4770
|
variant: "secondary",
|
|
4101
4771
|
className: "aui-thread-scroll-to-bottom absolute -top-12 z-10 self-center disabled:invisible",
|
|
4102
|
-
children: /* @__PURE__ */ (0,
|
|
4772
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.ArrowDownIcon, { className: "size-4" })
|
|
4103
4773
|
}
|
|
4104
4774
|
) });
|
|
4105
4775
|
};
|
|
@@ -4132,15 +4802,15 @@ var ThreadWelcome = ({
|
|
|
4132
4802
|
showWelcomeSuggestions: showWelcomeSuggestionsProp,
|
|
4133
4803
|
Suggestions: SuggestionsSlot = Suggestions
|
|
4134
4804
|
}) => {
|
|
4135
|
-
const isEmpty = (0,
|
|
4805
|
+
const isEmpty = (0, import_react31.useThread)((s) => s.messages.length === 0);
|
|
4136
4806
|
const isPanel = useThreadVariant() === "panel";
|
|
4137
4807
|
const showWelcomeSuggestions = showWelcomeSuggestionsProp ?? !isPanel;
|
|
4138
4808
|
if (!isEmpty) return null;
|
|
4139
4809
|
const defaultHeading = isPanel ? "Ask about this page" : "How can I help you today?";
|
|
4140
4810
|
const defaultSubheading = isPanel ? "The assistant can use dashboard context from your app." : "Send a message to start a conversation.";
|
|
4141
|
-
return /* @__PURE__ */ (0,
|
|
4142
|
-
/* @__PURE__ */ (0,
|
|
4143
|
-
|
|
4811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: [
|
|
4812
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4813
|
+
import_react32.motion.div,
|
|
4144
4814
|
{
|
|
4145
4815
|
className: cn(
|
|
4146
4816
|
"aui-thread-welcome-message flex flex-col items-center justify-center text-center",
|
|
@@ -4150,9 +4820,9 @@ var ThreadWelcome = ({
|
|
|
4150
4820
|
initial: "initial",
|
|
4151
4821
|
animate: "animate",
|
|
4152
4822
|
children: [
|
|
4153
|
-
config?.icon && /* @__PURE__ */ (0,
|
|
4154
|
-
/* @__PURE__ */ (0,
|
|
4155
|
-
|
|
4823
|
+
config?.icon && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react32.motion.div, { variants: welcomeIcon, className: isPanel ? "mb-3" : "mb-5", children: config.icon }),
|
|
4824
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4825
|
+
import_react32.motion.h1,
|
|
4156
4826
|
{
|
|
4157
4827
|
variants: welcomeItem,
|
|
4158
4828
|
className: cn(
|
|
@@ -4162,8 +4832,8 @@ var ThreadWelcome = ({
|
|
|
4162
4832
|
children: config?.heading ?? defaultHeading
|
|
4163
4833
|
}
|
|
4164
4834
|
),
|
|
4165
|
-
/* @__PURE__ */ (0,
|
|
4166
|
-
|
|
4835
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4836
|
+
import_react32.motion.p,
|
|
4167
4837
|
{
|
|
4168
4838
|
variants: welcomeItem,
|
|
4169
4839
|
className: "aui-thread-welcome-message-inner mt-1.5 text-muted-foreground text-sm",
|
|
@@ -4173,16 +4843,16 @@ var ThreadWelcome = ({
|
|
|
4173
4843
|
]
|
|
4174
4844
|
}
|
|
4175
4845
|
) }),
|
|
4176
|
-
showWelcomeSuggestions && suggestions ? /* @__PURE__ */ (0,
|
|
4846
|
+
showWelcomeSuggestions && suggestions ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "aui-thread-welcome-suggestions mx-auto w-full max-w-(--thread-max-width) px-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(SuggestionsSlot, { suggestions }) }) : null
|
|
4177
4847
|
] });
|
|
4178
4848
|
};
|
|
4179
4849
|
var MessageError = () => {
|
|
4180
|
-
return /* @__PURE__ */ (0,
|
|
4850
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.MessagePrimitive.Error, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ErrorPrimitive.Root, { className: "aui-message-error-root mt-2 rounded-md border border-destructive bg-destructive/10 p-3 text-destructive text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ErrorPrimitive.Message, { className: "aui-message-error-message line-clamp-2" }) }) });
|
|
4181
4851
|
};
|
|
4182
4852
|
var AssistantMessage = () => {
|
|
4183
4853
|
const isPanel = useThreadVariant() === "panel";
|
|
4184
|
-
return /* @__PURE__ */ (0,
|
|
4185
|
-
|
|
4854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4855
|
+
import_react31.MessagePrimitive.Root,
|
|
4186
4856
|
{
|
|
4187
4857
|
className: cn(
|
|
4188
4858
|
"aui-assistant-message-root fade-in slide-in-from-bottom-1 relative mx-auto w-full max-w-(--thread-max-width) animate-in duration-150",
|
|
@@ -4190,7 +4860,7 @@ var AssistantMessage = () => {
|
|
|
4190
4860
|
),
|
|
4191
4861
|
"data-role": "assistant",
|
|
4192
4862
|
children: [
|
|
4193
|
-
/* @__PURE__ */ (0,
|
|
4863
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4194
4864
|
"div",
|
|
4195
4865
|
{
|
|
4196
4866
|
className: cn(
|
|
@@ -4198,8 +4868,8 @@ var AssistantMessage = () => {
|
|
|
4198
4868
|
isPanel ? "px-1 text-sm" : "px-2"
|
|
4199
4869
|
),
|
|
4200
4870
|
children: [
|
|
4201
|
-
/* @__PURE__ */ (0,
|
|
4202
|
-
|
|
4871
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4872
|
+
import_react31.MessagePrimitive.Parts,
|
|
4203
4873
|
{
|
|
4204
4874
|
components: {
|
|
4205
4875
|
Text: MarkdownText,
|
|
@@ -4209,11 +4879,11 @@ var AssistantMessage = () => {
|
|
|
4209
4879
|
}
|
|
4210
4880
|
}
|
|
4211
4881
|
),
|
|
4212
|
-
/* @__PURE__ */ (0,
|
|
4882
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(MessageError, {})
|
|
4213
4883
|
]
|
|
4214
4884
|
}
|
|
4215
4885
|
),
|
|
4216
|
-
/* @__PURE__ */ (0,
|
|
4886
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "aui-assistant-message-footer mt-1 mb-3 ml-1 flex", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(AssistantActionBar, {}) })
|
|
4217
4887
|
]
|
|
4218
4888
|
}
|
|
4219
4889
|
);
|
|
@@ -4226,36 +4896,36 @@ var ASSISTANT_ACTION_ICON_CLASS = cn(
|
|
|
4226
4896
|
"[&>span:first-child]:group-hover/tbv2:bg-ghost-fill-hover"
|
|
4227
4897
|
);
|
|
4228
4898
|
var AssistantActionBar = () => {
|
|
4229
|
-
return /* @__PURE__ */ (0,
|
|
4230
|
-
|
|
4899
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4900
|
+
import_react31.ActionBarPrimitive.Root,
|
|
4231
4901
|
{
|
|
4232
4902
|
hideWhenRunning: true,
|
|
4233
4903
|
autohide: "never",
|
|
4234
4904
|
className: "aui-assistant-action-bar-root flex items-center gap-0 bg-transparent px-0 py-0.5 text-muted-foreground/60",
|
|
4235
4905
|
children: [
|
|
4236
|
-
/* @__PURE__ */ (0,
|
|
4906
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarPrimitive.Copy, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4237
4907
|
TooltipIconButton,
|
|
4238
4908
|
{
|
|
4239
4909
|
tooltip: "Copy",
|
|
4240
4910
|
variant: "ghost",
|
|
4241
4911
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
4242
4912
|
children: [
|
|
4243
|
-
/* @__PURE__ */ (0,
|
|
4244
|
-
/* @__PURE__ */ (0,
|
|
4913
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.AuiIf, { condition: (s) => s.message.isCopied, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.CheckIcon, { className: "size-3" }) }),
|
|
4914
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.AuiIf, { condition: (s) => !s.message.isCopied, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.CopyIcon, { className: "size-3" }) })
|
|
4245
4915
|
]
|
|
4246
4916
|
}
|
|
4247
4917
|
) }),
|
|
4248
|
-
/* @__PURE__ */ (0,
|
|
4918
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarPrimitive.Reload, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4249
4919
|
TooltipIconButton,
|
|
4250
4920
|
{
|
|
4251
4921
|
tooltip: "Regenerate",
|
|
4252
4922
|
variant: "ghost",
|
|
4253
4923
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
4254
|
-
children: /* @__PURE__ */ (0,
|
|
4924
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.RefreshCwIcon, { className: "size-3" })
|
|
4255
4925
|
}
|
|
4256
4926
|
) }),
|
|
4257
|
-
/* @__PURE__ */ (0,
|
|
4258
|
-
/* @__PURE__ */ (0,
|
|
4927
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_react31.ActionBarMorePrimitive.Root, { children: [
|
|
4928
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarMorePrimitive.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4259
4929
|
TooltipIconButton,
|
|
4260
4930
|
{
|
|
4261
4931
|
tooltip: "More",
|
|
@@ -4264,17 +4934,17 @@ var AssistantActionBar = () => {
|
|
|
4264
4934
|
ASSISTANT_ACTION_ICON_CLASS,
|
|
4265
4935
|
"data-[state=open]:text-muted-foreground/80"
|
|
4266
4936
|
),
|
|
4267
|
-
children: /* @__PURE__ */ (0,
|
|
4937
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.MoreHorizontalIcon, { className: "size-3" })
|
|
4268
4938
|
}
|
|
4269
4939
|
) }),
|
|
4270
|
-
/* @__PURE__ */ (0,
|
|
4271
|
-
|
|
4940
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4941
|
+
import_react31.ActionBarMorePrimitive.Content,
|
|
4272
4942
|
{
|
|
4273
4943
|
side: "bottom",
|
|
4274
4944
|
align: "start",
|
|
4275
4945
|
className: "aui-action-bar-more-content z-50 min-w-36 overflow-hidden rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-card-elevated",
|
|
4276
|
-
children: /* @__PURE__ */ (0,
|
|
4277
|
-
/* @__PURE__ */ (0,
|
|
4946
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarPrimitive.ExportMarkdown, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_react31.ActionBarMorePrimitive.Item, { className: "aui-action-bar-more-item flex cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-none hover:bg-muted focus:bg-muted", children: [
|
|
4947
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.DownloadIcon, { className: "size-4 shrink-0" }),
|
|
4278
4948
|
"Export as Markdown"
|
|
4279
4949
|
] }) })
|
|
4280
4950
|
}
|
|
@@ -4285,12 +4955,12 @@ var AssistantActionBar = () => {
|
|
|
4285
4955
|
);
|
|
4286
4956
|
};
|
|
4287
4957
|
var UserMessageText = () => {
|
|
4288
|
-
return /* @__PURE__ */ (0,
|
|
4958
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "whitespace-pre-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.MessagePartPrimitive.Text, { smooth: false }) });
|
|
4289
4959
|
};
|
|
4290
4960
|
var UserMessage = () => {
|
|
4291
4961
|
const isPanel = useThreadVariant() === "panel";
|
|
4292
|
-
return /* @__PURE__ */ (0,
|
|
4293
|
-
|
|
4962
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4963
|
+
import_react31.MessagePrimitive.Root,
|
|
4294
4964
|
{
|
|
4295
4965
|
className: cn(
|
|
4296
4966
|
"aui-user-message-root mx-auto flex w-full max-w-(--thread-max-width) flex-col items-end gap-2",
|
|
@@ -4298,9 +4968,9 @@ var UserMessage = () => {
|
|
|
4298
4968
|
),
|
|
4299
4969
|
"data-role": "user",
|
|
4300
4970
|
children: [
|
|
4301
|
-
/* @__PURE__ */ (0,
|
|
4302
|
-
/* @__PURE__ */ (0,
|
|
4303
|
-
|
|
4971
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(UserMessageAttachments, {}),
|
|
4972
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4973
|
+
import_react32.motion.div,
|
|
4304
4974
|
{
|
|
4305
4975
|
className: cn(
|
|
4306
4976
|
"aui-user-message-content relative inline-block max-w-[85%] rounded-2xl bg-bubble-user text-bubble-user-foreground",
|
|
@@ -4310,8 +4980,8 @@ var UserMessage = () => {
|
|
|
4310
4980
|
animate: { opacity: 1, y: 0, scale: 1 },
|
|
4311
4981
|
transition: { duration: 0.65, ease: luxuryEase },
|
|
4312
4982
|
children: [
|
|
4313
|
-
/* @__PURE__ */ (0,
|
|
4314
|
-
/* @__PURE__ */ (0,
|
|
4983
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.MessagePrimitive.Parts, { components: { Text: UserMessageText } }),
|
|
4984
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(UserActionBar, {}) })
|
|
4315
4985
|
]
|
|
4316
4986
|
}
|
|
4317
4987
|
)
|
|
@@ -4320,42 +4990,42 @@ var UserMessage = () => {
|
|
|
4320
4990
|
);
|
|
4321
4991
|
};
|
|
4322
4992
|
var UserActionBar = () => {
|
|
4323
|
-
return /* @__PURE__ */ (0,
|
|
4324
|
-
|
|
4993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4994
|
+
import_react31.ActionBarPrimitive.Root,
|
|
4325
4995
|
{
|
|
4326
4996
|
hideWhenRunning: true,
|
|
4327
4997
|
autohide: "always",
|
|
4328
4998
|
className: "aui-user-action-bar-root flex flex-col items-end",
|
|
4329
|
-
children: /* @__PURE__ */ (0,
|
|
4999
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarPrimitive.Edit, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4330
5000
|
TooltipIconButton,
|
|
4331
5001
|
{
|
|
4332
5002
|
tooltip: "Edit",
|
|
4333
5003
|
variant: "ghost",
|
|
4334
5004
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
4335
|
-
children: /* @__PURE__ */ (0,
|
|
5005
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.PencilIcon, { className: "size-3" })
|
|
4336
5006
|
}
|
|
4337
5007
|
) })
|
|
4338
5008
|
}
|
|
4339
5009
|
);
|
|
4340
5010
|
};
|
|
4341
5011
|
var EditComposer = () => {
|
|
4342
|
-
return /* @__PURE__ */ (0,
|
|
4343
|
-
/* @__PURE__ */ (0,
|
|
4344
|
-
|
|
5012
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.MessagePrimitive.Root, { className: "aui-edit-composer-wrapper mx-auto flex w-full max-w-(--thread-max-width) flex-col px-2 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_react31.ComposerPrimitive.Root, { className: "aui-edit-composer-root ml-auto flex w-full max-w-[85%] flex-col rounded-2xl bg-muted", children: [
|
|
5013
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
5014
|
+
import_react31.ComposerPrimitive.Input,
|
|
4345
5015
|
{
|
|
4346
5016
|
className: "aui-edit-composer-input min-h-14 w-full resize-none bg-transparent p-4 text-foreground text-sm outline-none",
|
|
4347
5017
|
autoFocus: true
|
|
4348
5018
|
}
|
|
4349
5019
|
),
|
|
4350
|
-
/* @__PURE__ */ (0,
|
|
4351
|
-
/* @__PURE__ */ (0,
|
|
4352
|
-
/* @__PURE__ */ (0,
|
|
5020
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "aui-edit-composer-footer mx-3 mb-3 flex items-center gap-2 self-end", children: [
|
|
5021
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(TimbalV2Button, { variant: "ghost", size: "sm", children: "Cancel" }) }),
|
|
5022
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(TimbalV2Button, { variant: "primary", size: "sm", children: "Update" }) })
|
|
4353
5023
|
] })
|
|
4354
5024
|
] }) });
|
|
4355
5025
|
};
|
|
4356
5026
|
|
|
4357
5027
|
// src/chat/chat.tsx
|
|
4358
|
-
var
|
|
5028
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
4359
5029
|
function TimbalChat({
|
|
4360
5030
|
workforceId,
|
|
4361
5031
|
baseUrl,
|
|
@@ -4366,7 +5036,7 @@ function TimbalChat({
|
|
|
4366
5036
|
debug,
|
|
4367
5037
|
...threadProps
|
|
4368
5038
|
}) {
|
|
4369
|
-
return /* @__PURE__ */ (0,
|
|
5039
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
4370
5040
|
TimbalRuntimeProvider,
|
|
4371
5041
|
{
|
|
4372
5042
|
workforceId,
|
|
@@ -4376,7 +5046,7 @@ function TimbalChat({
|
|
|
4376
5046
|
attachmentsUploadUrl,
|
|
4377
5047
|
attachmentsAccept,
|
|
4378
5048
|
debug,
|
|
4379
|
-
children: /* @__PURE__ */ (0,
|
|
5049
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Thread, { ...threadProps })
|
|
4380
5050
|
}
|
|
4381
5051
|
);
|
|
4382
5052
|
}
|
|
@@ -4405,7 +5075,7 @@ var overlayListPanelClass = cn(
|
|
|
4405
5075
|
);
|
|
4406
5076
|
|
|
4407
5077
|
// src/chat/workforce-selector.tsx
|
|
4408
|
-
var
|
|
5078
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
4409
5079
|
var WorkforceSelector = ({
|
|
4410
5080
|
workforces,
|
|
4411
5081
|
value,
|
|
@@ -4416,7 +5086,7 @@ var WorkforceSelector = ({
|
|
|
4416
5086
|
}) => {
|
|
4417
5087
|
if (workforces.length === 0) return null;
|
|
4418
5088
|
if (hideWhenSingle && workforces.length === 1) return null;
|
|
4419
|
-
return /* @__PURE__ */ (0,
|
|
5089
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
4420
5090
|
"div",
|
|
4421
5091
|
{
|
|
4422
5092
|
className: cn(
|
|
@@ -4427,7 +5097,7 @@ var WorkforceSelector = ({
|
|
|
4427
5097
|
className
|
|
4428
5098
|
),
|
|
4429
5099
|
children: [
|
|
4430
|
-
/* @__PURE__ */ (0,
|
|
5100
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
4431
5101
|
"select",
|
|
4432
5102
|
{
|
|
4433
5103
|
className: "aui-workforce-selector-input h-full cursor-pointer appearance-none rounded-full border-none bg-transparent pr-8 pl-3.5 text-sm font-medium text-foreground outline-none focus:outline-none",
|
|
@@ -4435,15 +5105,15 @@ var WorkforceSelector = ({
|
|
|
4435
5105
|
onChange: (e) => onChange(e.target.value),
|
|
4436
5106
|
"aria-label": placeholder,
|
|
4437
5107
|
children: [
|
|
4438
|
-
!value && /* @__PURE__ */ (0,
|
|
5108
|
+
!value && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("option", { value: "", children: placeholder }),
|
|
4439
5109
|
workforces.map((w) => {
|
|
4440
5110
|
const id = idOf(w);
|
|
4441
|
-
return /* @__PURE__ */ (0,
|
|
5111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("option", { value: id, children: w.name ?? id }, id);
|
|
4442
5112
|
})
|
|
4443
5113
|
]
|
|
4444
5114
|
}
|
|
4445
5115
|
),
|
|
4446
|
-
/* @__PURE__ */ (0,
|
|
5116
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
4447
5117
|
import_lucide_react9.ChevronDownIcon,
|
|
4448
5118
|
{
|
|
4449
5119
|
className: "aui-workforce-selector-icon pointer-events-none absolute right-3 size-3.5 text-muted-foreground/70",
|