@timbal-ai/timbal-react 1.0.0 → 1.1.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 +28 -0
- package/README.md +45 -4
- package/dist/app.cjs +1996 -1183
- package/dist/app.d.cts +8 -4
- package/dist/app.d.ts +8 -4
- package/dist/app.esm.js +23 -6
- package/dist/{chart-artifact-CBo9x8Ch.d.ts → chart-artifact-BZp7nmaf.d.ts} +253 -12
- package/dist/{chart-artifact-DOkwSTjQ.d.cts → chart-artifact-CX-rh9nq.d.cts} +253 -12
- package/dist/{chat-Bed4FQSl.d.cts → chat-DCms8pJ_.d.cts} +31 -4
- package/dist/{chat-Bed4FQSl.d.ts → chat-DCms8pJ_.d.ts} +31 -4
- package/dist/chat.cjs +1088 -775
- package/dist/chat.d.cts +1 -1
- package/dist/chat.d.ts +1 -1
- package/dist/chat.esm.js +3 -3
- package/dist/{chunk-FOD67Z6G.esm.js → chunk-4AKJ6FKE.esm.js} +235 -4
- package/dist/{chunk-YEFBANNF.esm.js → chunk-6HWMJNZT.esm.js} +242 -288
- package/dist/{chunk-C6IXFM4T.esm.js → chunk-FRZOEYBO.esm.js} +4 -4
- package/dist/chunk-JEAUF54A.esm.js +52 -0
- package/dist/{chunk-AYHOVAMI.esm.js → chunk-P3KDAYX6.esm.js} +1 -1
- package/dist/{chunk-GLPOVYEA.esm.js → chunk-TK2AGIME.esm.js} +662 -274
- package/dist/{chunk-RZ6QC6RG.esm.js → chunk-XCM3V6RK.esm.js} +2 -2
- package/dist/{chunk-SNLXVG7H.esm.js → chunk-YXZ22OJN.esm.js} +849 -665
- package/dist/index.cjs +2558 -1789
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.esm.js +29 -11
- package/dist/pill-segmented-tabs-Ba5q0feL.d.cts +500 -0
- package/dist/pill-segmented-tabs-Ba5q0feL.d.ts +500 -0
- package/dist/studio.cjs +1310 -997
- 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 +26 -0
- package/dist/ui.cjs +275 -37
- package/dist/ui.d.cts +71 -491
- package/dist/ui.d.ts +71 -491
- package/dist/ui.esm.js +22 -6
- package/dist/{welcome-COOb05a5.d.cts → welcome-CRqOPKMp.d.cts} +1 -1
- package/dist/{welcome-DE08m9ca.d.ts → welcome-DlHUa3OL.d.ts} +1 -1
- package/package.json +7 -3
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_react27 = require("react");
|
|
914
|
+
var import_react28 = require("@assistant-ui/react");
|
|
915
915
|
var import_lucide_react8 = require("lucide-react");
|
|
916
|
-
var
|
|
916
|
+
var import_react29 = require("motion/react");
|
|
917
917
|
|
|
918
918
|
// src/chat/attachment.tsx
|
|
919
919
|
var import_react5 = require("react");
|
|
@@ -1534,131 +1534,251 @@ var import_react_markdown = require("@assistant-ui/react-markdown");
|
|
|
1534
1534
|
var import_remark_gfm = __toESM(require("remark-gfm"), 1);
|
|
1535
1535
|
var import_remark_math = __toESM(require("remark-math"), 1);
|
|
1536
1536
|
var import_rehype_katex = __toESM(require("rehype-katex"), 1);
|
|
1537
|
-
var
|
|
1537
|
+
var import_react17 = require("react");
|
|
1538
1538
|
var import_lucide_react4 = require("lucide-react");
|
|
1539
1539
|
|
|
1540
1540
|
// src/chat/syntax-highlighter.tsx
|
|
1541
|
-
var
|
|
1541
|
+
var import_react16 = require("react");
|
|
1542
1542
|
var import_core = require("shiki/core");
|
|
1543
1543
|
var import_javascript = require("shiki/engine/javascript");
|
|
1544
1544
|
|
|
1545
1545
|
// src/artifacts/registry.tsx
|
|
1546
|
-
var
|
|
1546
|
+
var import_react15 = require("react");
|
|
1547
1547
|
|
|
1548
1548
|
// src/artifacts/chart-artifact.tsx
|
|
1549
|
-
var
|
|
1549
|
+
var import_react7 = require("react");
|
|
1550
1550
|
|
|
1551
1551
|
// src/charts/line-area-chart.tsx
|
|
1552
|
-
var
|
|
1552
|
+
var import_recharts = require("recharts");
|
|
1553
1553
|
|
|
1554
|
-
// src/
|
|
1555
|
-
var
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
if (w && w > 0) setWidth(w);
|
|
1565
|
-
});
|
|
1566
|
-
ro.observe(el);
|
|
1567
|
-
return () => ro.disconnect();
|
|
1568
|
-
}, []);
|
|
1569
|
-
return { ref, width };
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
|
-
// src/charts/geometry.ts
|
|
1573
|
-
function toNum(value) {
|
|
1574
|
-
const n = typeof value === "number" ? value : Number(value);
|
|
1575
|
-
return Number.isFinite(n) ? n : 0;
|
|
1576
|
-
}
|
|
1577
|
-
function monotoneLinePath(points) {
|
|
1578
|
-
const n = points.length;
|
|
1579
|
-
if (n === 0) return "";
|
|
1580
|
-
if (n === 1) return `M ${points[0].x},${points[0].y}`;
|
|
1581
|
-
if (n === 2) {
|
|
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}`;
|
|
1554
|
+
// src/ui/chart.tsx
|
|
1555
|
+
var React2 = __toESM(require("react"), 1);
|
|
1556
|
+
var RechartsPrimitive = __toESM(require("recharts"), 1);
|
|
1557
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1558
|
+
var THEMES = { light: "", dark: ".dark" };
|
|
1559
|
+
var ChartContext = React2.createContext(null);
|
|
1560
|
+
function useChart() {
|
|
1561
|
+
const context = React2.useContext(ChartContext);
|
|
1562
|
+
if (!context) {
|
|
1563
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
1595
1564
|
}
|
|
1596
|
-
return
|
|
1565
|
+
return context;
|
|
1597
1566
|
}
|
|
1598
|
-
function
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1567
|
+
function ChartContainer({
|
|
1568
|
+
id,
|
|
1569
|
+
className,
|
|
1570
|
+
children,
|
|
1571
|
+
config,
|
|
1572
|
+
...props
|
|
1573
|
+
}) {
|
|
1574
|
+
const uniqueId = React2.useId();
|
|
1575
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
1576
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1577
|
+
"div",
|
|
1578
|
+
{
|
|
1579
|
+
"data-slot": "chart",
|
|
1580
|
+
"data-chart": chartId,
|
|
1581
|
+
className: cn(
|
|
1582
|
+
"[&_.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",
|
|
1583
|
+
className
|
|
1584
|
+
),
|
|
1585
|
+
...props,
|
|
1586
|
+
children: [
|
|
1587
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChartStyle, { id: chartId, config }),
|
|
1588
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RechartsPrimitive.ResponsiveContainer, { children })
|
|
1589
|
+
]
|
|
1590
|
+
}
|
|
1591
|
+
) });
|
|
1604
1592
|
}
|
|
1605
|
-
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1593
|
+
var ChartStyle = ({ id, config }) => {
|
|
1594
|
+
const colorConfig = Object.entries(config).filter(
|
|
1595
|
+
([, c]) => c.theme || c.color
|
|
1596
|
+
);
|
|
1597
|
+
if (!colorConfig.length) {
|
|
1598
|
+
return null;
|
|
1611
1599
|
}
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1600
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1601
|
+
"style",
|
|
1602
|
+
{
|
|
1603
|
+
dangerouslySetInnerHTML: {
|
|
1604
|
+
__html: Object.entries(THEMES).map(
|
|
1605
|
+
([theme, prefix]) => `
|
|
1606
|
+
${prefix} [data-chart=${id}] {
|
|
1607
|
+
${colorConfig.map(([key, itemConfig]) => {
|
|
1608
|
+
const color = itemConfig.theme?.[theme] || itemConfig.color;
|
|
1609
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
1610
|
+
}).join("\n")}
|
|
1611
|
+
}
|
|
1612
|
+
`
|
|
1613
|
+
).join("\n")
|
|
1614
|
+
}
|
|
1622
1615
|
}
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1616
|
+
);
|
|
1617
|
+
};
|
|
1618
|
+
var ChartTooltip = RechartsPrimitive.Tooltip;
|
|
1619
|
+
function ChartTooltipContent({
|
|
1620
|
+
active,
|
|
1621
|
+
payload,
|
|
1622
|
+
className,
|
|
1623
|
+
indicator = "dot",
|
|
1624
|
+
hideLabel = false,
|
|
1625
|
+
hideIndicator = false,
|
|
1626
|
+
label,
|
|
1627
|
+
labelFormatter,
|
|
1628
|
+
labelClassName,
|
|
1629
|
+
formatter,
|
|
1630
|
+
color,
|
|
1631
|
+
nameKey,
|
|
1632
|
+
labelKey
|
|
1633
|
+
}) {
|
|
1634
|
+
const { config } = useChart();
|
|
1635
|
+
const tooltipLabel = React2.useMemo(() => {
|
|
1636
|
+
if (hideLabel || !payload?.length) {
|
|
1637
|
+
return null;
|
|
1638
|
+
}
|
|
1639
|
+
const [item] = payload;
|
|
1640
|
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
|
|
1641
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
1642
|
+
const value = !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;
|
|
1643
|
+
if (labelFormatter) {
|
|
1644
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
|
|
1630
1645
|
}
|
|
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;
|
|
1646
|
+
if (!value) {
|
|
1647
|
+
return null;
|
|
1638
1648
|
}
|
|
1649
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: cn("font-medium", labelClassName), children: value });
|
|
1650
|
+
}, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
|
|
1651
|
+
if (!active || !payload?.length) {
|
|
1652
|
+
return null;
|
|
1639
1653
|
}
|
|
1640
|
-
|
|
1654
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
1655
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1656
|
+
"div",
|
|
1657
|
+
{
|
|
1658
|
+
className: cn(
|
|
1659
|
+
"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",
|
|
1660
|
+
"animate-in fade-in-0 zoom-in-95 duration-150",
|
|
1661
|
+
className
|
|
1662
|
+
),
|
|
1663
|
+
children: [
|
|
1664
|
+
!nestLabel ? tooltipLabel : null,
|
|
1665
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "grid gap-1.5", children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
1666
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
1667
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
1668
|
+
const indicatorColor = color || item.payload?.fill || item.color;
|
|
1669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1670
|
+
"div",
|
|
1671
|
+
{
|
|
1672
|
+
className: cn(
|
|
1673
|
+
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
|
|
1674
|
+
indicator === "dot" && "items-center"
|
|
1675
|
+
),
|
|
1676
|
+
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: [
|
|
1677
|
+
itemConfig?.icon ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1678
|
+
"div",
|
|
1679
|
+
{
|
|
1680
|
+
className: cn(
|
|
1681
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
1682
|
+
{
|
|
1683
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
1684
|
+
"w-1": indicator === "line",
|
|
1685
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
1686
|
+
"my-0.5": nestLabel && indicator === "dashed"
|
|
1687
|
+
}
|
|
1688
|
+
),
|
|
1689
|
+
style: {
|
|
1690
|
+
"--color-bg": indicatorColor,
|
|
1691
|
+
"--color-border": indicatorColor
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
),
|
|
1695
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1696
|
+
"div",
|
|
1697
|
+
{
|
|
1698
|
+
className: cn(
|
|
1699
|
+
"flex flex-1 justify-between leading-none",
|
|
1700
|
+
nestLabel ? "items-end" : "items-center"
|
|
1701
|
+
),
|
|
1702
|
+
children: [
|
|
1703
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid gap-1.5", children: [
|
|
1704
|
+
nestLabel ? tooltipLabel : null,
|
|
1705
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-muted-foreground", children: itemConfig?.label || item.name })
|
|
1706
|
+
] }),
|
|
1707
|
+
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) })
|
|
1708
|
+
]
|
|
1709
|
+
}
|
|
1710
|
+
)
|
|
1711
|
+
] })
|
|
1712
|
+
},
|
|
1713
|
+
`${item.dataKey ?? index}`
|
|
1714
|
+
);
|
|
1715
|
+
}) })
|
|
1716
|
+
]
|
|
1717
|
+
}
|
|
1718
|
+
);
|
|
1641
1719
|
}
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1720
|
+
var ChartLegend = RechartsPrimitive.Legend;
|
|
1721
|
+
function ChartLegendContent({
|
|
1722
|
+
className,
|
|
1723
|
+
hideIcon = false,
|
|
1724
|
+
payload,
|
|
1725
|
+
verticalAlign = "bottom",
|
|
1726
|
+
nameKey
|
|
1727
|
+
}) {
|
|
1728
|
+
const { config } = useChart();
|
|
1729
|
+
if (!payload?.length) {
|
|
1730
|
+
return null;
|
|
1645
1731
|
}
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1733
|
+
"div",
|
|
1734
|
+
{
|
|
1735
|
+
className: cn(
|
|
1736
|
+
"flex items-center justify-center gap-4",
|
|
1737
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
1738
|
+
className
|
|
1739
|
+
),
|
|
1740
|
+
children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
1741
|
+
const key = `${nameKey || item.dataKey || "value"}`;
|
|
1742
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
1743
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1744
|
+
"div",
|
|
1745
|
+
{
|
|
1746
|
+
className: "[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3",
|
|
1747
|
+
children: [
|
|
1748
|
+
itemConfig?.icon && !hideIcon ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(itemConfig.icon, {}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1749
|
+
"div",
|
|
1750
|
+
{
|
|
1751
|
+
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
1752
|
+
style: { backgroundColor: item.color }
|
|
1753
|
+
}
|
|
1754
|
+
),
|
|
1755
|
+
itemConfig?.label
|
|
1756
|
+
]
|
|
1757
|
+
},
|
|
1758
|
+
`${item.value ?? index}`
|
|
1759
|
+
);
|
|
1760
|
+
})
|
|
1761
|
+
}
|
|
1762
|
+
);
|
|
1763
|
+
}
|
|
1764
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
1765
|
+
if (typeof payload !== "object" || payload === null) {
|
|
1766
|
+
return void 0;
|
|
1651
1767
|
}
|
|
1652
|
-
|
|
1768
|
+
const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
|
|
1769
|
+
let configLabelKey = key;
|
|
1770
|
+
if (key in payload && typeof payload[key] === "string") {
|
|
1771
|
+
configLabelKey = payload[key];
|
|
1772
|
+
} else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
|
|
1773
|
+
configLabelKey = payloadPayload[key];
|
|
1774
|
+
}
|
|
1775
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
1653
1776
|
}
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
const
|
|
1658
|
-
|
|
1659
|
-
if (norm >= 5) nice = 5;
|
|
1660
|
-
else if (norm >= 2) nice = 2;
|
|
1661
|
-
return nice * base;
|
|
1777
|
+
|
|
1778
|
+
// src/charts/geometry.ts
|
|
1779
|
+
function toNum(value) {
|
|
1780
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
1781
|
+
return Number.isFinite(n) ? n : 0;
|
|
1662
1782
|
}
|
|
1663
1783
|
function round(v) {
|
|
1664
1784
|
return Math.round(v * 1e6) / 1e6;
|
|
@@ -1673,17 +1793,15 @@ function formatCompact(value, unit) {
|
|
|
1673
1793
|
}
|
|
1674
1794
|
|
|
1675
1795
|
// src/charts/line-area-chart.tsx
|
|
1676
|
-
var
|
|
1796
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1677
1797
|
var CHART_PALETTE = [
|
|
1678
|
-
"var(--
|
|
1679
|
-
"#10b981",
|
|
1680
|
-
"#f59e0b",
|
|
1681
|
-
"#
|
|
1682
|
-
"#
|
|
1683
|
-
"#
|
|
1798
|
+
"var(--chart-1, #6366f1)",
|
|
1799
|
+
"var(--chart-2, #10b981)",
|
|
1800
|
+
"var(--chart-3, #f59e0b)",
|
|
1801
|
+
"var(--chart-4, #a855f7)",
|
|
1802
|
+
"var(--chart-5, #ef4444)",
|
|
1803
|
+
"var(--chart-6, #06b6d4)"
|
|
1684
1804
|
];
|
|
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
1805
|
var LineAreaChart = ({
|
|
1688
1806
|
data = [],
|
|
1689
1807
|
xKey: xKeyProp,
|
|
@@ -1692,308 +1810,222 @@ var LineAreaChart = ({
|
|
|
1692
1810
|
height = 240,
|
|
1693
1811
|
unit,
|
|
1694
1812
|
yMax,
|
|
1813
|
+
curve = "monotone",
|
|
1814
|
+
stacked = false,
|
|
1815
|
+
dots = false,
|
|
1816
|
+
orientation = "vertical",
|
|
1817
|
+
barRadius = 4,
|
|
1818
|
+
gridLines,
|
|
1695
1819
|
layout = "default",
|
|
1696
1820
|
showGrid = true,
|
|
1697
1821
|
showXAxis: showXAxisProp,
|
|
1698
1822
|
showYAxis: showYAxisProp,
|
|
1699
1823
|
showLegend: showLegendProp,
|
|
1700
1824
|
showTooltip = true,
|
|
1825
|
+
tooltipIndicator = "dot",
|
|
1701
1826
|
formatValue,
|
|
1702
1827
|
formatX,
|
|
1703
1828
|
className,
|
|
1704
1829
|
ariaLabel = "Chart"
|
|
1705
1830
|
}) => {
|
|
1706
|
-
const uid = (0, import_react8.useId)();
|
|
1707
|
-
const { ref, width } = useChartWidth();
|
|
1708
|
-
const [active, setActive] = (0, import_react8.useState)(null);
|
|
1709
|
-
const [grown, setGrown] = (0, import_react8.useState)(false);
|
|
1710
1831
|
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]);
|
|
1832
|
+
const series = resolveSeries(seriesProp, data, xKey);
|
|
1833
|
+
const flush = layout === "flush";
|
|
1834
|
+
const horizontal = orientation === "horizontal" && variant === "bar";
|
|
1835
|
+
const showXAxis = showXAxisProp ?? !flush;
|
|
1836
|
+
const showYAxis = showYAxisProp ?? !flush;
|
|
1837
|
+
const showLegend = showLegendProp ?? (!flush && series.length > 1);
|
|
1838
|
+
const grid = gridLines ?? (horizontal ? "vertical" : "horizontal");
|
|
1739
1839
|
if (data.length === 0 || series.length === 0) {
|
|
1740
|
-
return /* @__PURE__ */ (0,
|
|
1840
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ChartEmpty, { className, height, ariaLabel });
|
|
1741
1841
|
}
|
|
1742
|
-
const
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
const
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1842
|
+
const config = {};
|
|
1843
|
+
series.forEach((s, i) => {
|
|
1844
|
+
config[s.dataKey] = {
|
|
1845
|
+
label: s.label ?? s.dataKey,
|
|
1846
|
+
color: s.color ?? CHART_PALETTE[i % CHART_PALETTE.length]
|
|
1847
|
+
};
|
|
1848
|
+
});
|
|
1849
|
+
const valueFmt = (v) => formatValue ? formatValue(toNum(v)) : formatCompact(toNum(v), unit);
|
|
1850
|
+
const xFmt = (v, i) => formatX ? formatX(v, i) : String(v ?? "");
|
|
1851
|
+
const margin = flush ? { top: 8, right: 4, bottom: 0, left: 0 } : { top: 8, right: 12, bottom: 0, left: 0 };
|
|
1852
|
+
const showVGrid = showGrid && (grid === "vertical" || grid === "both");
|
|
1853
|
+
const showHGrid = showGrid && (grid === "horizontal" || grid === "both");
|
|
1854
|
+
const tooltipEl = showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1855
|
+
ChartTooltip,
|
|
1856
|
+
{
|
|
1857
|
+
cursor: variant === "bar",
|
|
1858
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ChartTooltipContent, { indicator: tooltipIndicator })
|
|
1859
|
+
}
|
|
1860
|
+
) : null;
|
|
1861
|
+
const legendEl = showLegend ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ChartLegend, { content: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ChartLegendContent, {}) }) : null;
|
|
1862
|
+
const gridEl = showGrid && grid !== "none" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_recharts.CartesianGrid, { vertical: showVGrid, horizontal: showHGrid, strokeDasharray: "4 4" }) : null;
|
|
1863
|
+
const yDomain = yMax != null ? [0, yMax] : void 0;
|
|
1864
|
+
if (variant === "bar") {
|
|
1865
|
+
const bars = series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1866
|
+
import_recharts.Bar,
|
|
1759
1867
|
{
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
"
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
textAnchor: i === 0 ? "start" : i === xCount - 1 ? "end" : "middle",
|
|
1844
|
-
className: "fill-muted-foreground text-[10px] tabular-nums",
|
|
1845
|
-
children: fmtX(i)
|
|
1846
|
-
},
|
|
1847
|
-
i
|
|
1848
|
-
)),
|
|
1849
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("g", { clipPath: `url(#${uid}-grow)`, children: variant === "bar" ? renderBars({ data, series, xCount, xPos, yScale, baseY, innerW, uid }) : series.map((s, si) => {
|
|
1850
|
-
const color = s.color ?? CHART_PALETTE[si % CHART_PALETTE.length];
|
|
1851
|
-
const pts = data.map((d, i) => ({
|
|
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",
|
|
1901
|
-
{
|
|
1902
|
-
x: pad.left,
|
|
1903
|
-
y: pad.top,
|
|
1904
|
-
width: innerW,
|
|
1905
|
-
height: innerH,
|
|
1906
|
-
fill: "transparent",
|
|
1907
|
-
style: { cursor: "crosshair" },
|
|
1908
|
-
onMouseMove: onMove,
|
|
1909
|
-
onMouseLeave: () => setActive(null)
|
|
1910
|
-
}
|
|
1911
|
-
)
|
|
1912
|
-
]
|
|
1868
|
+
dataKey: s.dataKey,
|
|
1869
|
+
fill: `var(--color-${s.dataKey})`,
|
|
1870
|
+
radius: barCornerRadius(barRadius, horizontal, stacked),
|
|
1871
|
+
stackId: stacked ? "stack" : void 0,
|
|
1872
|
+
isAnimationActive: true
|
|
1873
|
+
},
|
|
1874
|
+
s.dataKey
|
|
1875
|
+
));
|
|
1876
|
+
if (horizontal) {
|
|
1877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_recharts.BarChart, { accessibilityLayer: true, data, layout: "vertical", margin, children: [
|
|
1878
|
+
gridEl,
|
|
1879
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1880
|
+
import_recharts.XAxis,
|
|
1881
|
+
{
|
|
1882
|
+
type: "number",
|
|
1883
|
+
hide: !showXAxis,
|
|
1884
|
+
tickLine: false,
|
|
1885
|
+
axisLine: false,
|
|
1886
|
+
tickMargin: 8,
|
|
1887
|
+
tickFormatter: (v) => valueFmt(v),
|
|
1888
|
+
domain: yDomain
|
|
1889
|
+
}
|
|
1890
|
+
),
|
|
1891
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1892
|
+
import_recharts.YAxis,
|
|
1893
|
+
{
|
|
1894
|
+
type: "category",
|
|
1895
|
+
dataKey: xKey,
|
|
1896
|
+
hide: !showYAxis,
|
|
1897
|
+
tickLine: false,
|
|
1898
|
+
axisLine: false,
|
|
1899
|
+
tickMargin: 8,
|
|
1900
|
+
width: showYAxis ? void 0 : 0,
|
|
1901
|
+
tickFormatter: (v, i) => xFmt(v, i)
|
|
1902
|
+
}
|
|
1903
|
+
),
|
|
1904
|
+
tooltipEl,
|
|
1905
|
+
legendEl,
|
|
1906
|
+
bars
|
|
1907
|
+
] }) });
|
|
1908
|
+
}
|
|
1909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_recharts.BarChart, { accessibilityLayer: true, data, margin, children: [
|
|
1910
|
+
gridEl,
|
|
1911
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1912
|
+
import_recharts.XAxis,
|
|
1913
|
+
{
|
|
1914
|
+
dataKey: xKey,
|
|
1915
|
+
hide: !showXAxis,
|
|
1916
|
+
tickLine: false,
|
|
1917
|
+
axisLine: false,
|
|
1918
|
+
tickMargin: 8,
|
|
1919
|
+
minTickGap: 16,
|
|
1920
|
+
tickFormatter: (v, i) => xFmt(v, i)
|
|
1921
|
+
}
|
|
1922
|
+
),
|
|
1923
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1924
|
+
import_recharts.YAxis,
|
|
1925
|
+
{
|
|
1926
|
+
hide: !showYAxis,
|
|
1927
|
+
tickLine: false,
|
|
1928
|
+
axisLine: false,
|
|
1929
|
+
tickMargin: 8,
|
|
1930
|
+
width: showYAxis ? 44 : 0,
|
|
1931
|
+
tickFormatter: (v) => valueFmt(v),
|
|
1932
|
+
domain: yDomain
|
|
1933
|
+
}
|
|
1934
|
+
),
|
|
1935
|
+
tooltipEl,
|
|
1936
|
+
legendEl,
|
|
1937
|
+
bars
|
|
1938
|
+
] }) });
|
|
1939
|
+
}
|
|
1940
|
+
const axes = /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
1941
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1942
|
+
import_recharts.XAxis,
|
|
1943
|
+
{
|
|
1944
|
+
dataKey: xKey,
|
|
1945
|
+
hide: !showXAxis,
|
|
1946
|
+
tickLine: false,
|
|
1947
|
+
axisLine: false,
|
|
1948
|
+
tickMargin: 8,
|
|
1949
|
+
minTickGap: 24,
|
|
1950
|
+
tickFormatter: (v, i) => xFmt(v, i)
|
|
1913
1951
|
}
|
|
1914
1952
|
),
|
|
1915
|
-
|
|
1916
|
-
|
|
1953
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1954
|
+
import_recharts.YAxis,
|
|
1917
1955
|
{
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
}))
|
|
1956
|
+
hide: !showYAxis,
|
|
1957
|
+
tickLine: false,
|
|
1958
|
+
axisLine: false,
|
|
1959
|
+
tickMargin: 8,
|
|
1960
|
+
width: showYAxis ? 44 : 0,
|
|
1961
|
+
tickFormatter: (v) => valueFmt(v),
|
|
1962
|
+
domain: yDomain
|
|
1926
1963
|
}
|
|
1927
|
-
)
|
|
1928
|
-
showLegend ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChartLegend, { series }) : null
|
|
1964
|
+
)
|
|
1929
1965
|
] });
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1943
|
-
"rect",
|
|
1966
|
+
if (variant === "area") {
|
|
1967
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_recharts.AreaChart, { accessibilityLayer: true, data, margin, children: [
|
|
1968
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("defs", { children: series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("linearGradient", { id: `fill-${s.dataKey}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
1969
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("stop", { offset: "5%", stopColor: `var(--color-${s.dataKey})`, stopOpacity: 0.3 }),
|
|
1970
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("stop", { offset: "95%", stopColor: `var(--color-${s.dataKey})`, stopOpacity: 0.04 })
|
|
1971
|
+
] }, s.dataKey)) }),
|
|
1972
|
+
gridEl,
|
|
1973
|
+
axes,
|
|
1974
|
+
tooltipEl,
|
|
1975
|
+
legendEl,
|
|
1976
|
+
series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1977
|
+
import_recharts.Area,
|
|
1944
1978
|
{
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
fill:
|
|
1979
|
+
dataKey: s.dataKey,
|
|
1980
|
+
type: curve,
|
|
1981
|
+
stackId: stacked ? "stack" : void 0,
|
|
1982
|
+
stroke: `var(--color-${s.dataKey})`,
|
|
1983
|
+
strokeWidth: 2,
|
|
1984
|
+
fill: `url(#fill-${s.dataKey})`,
|
|
1985
|
+
dot: dots === true ? { r: 3 } : false,
|
|
1986
|
+
activeDot: { r: 4 },
|
|
1987
|
+
isAnimationActive: true
|
|
1951
1988
|
},
|
|
1952
|
-
|
|
1953
|
-
)
|
|
1954
|
-
})
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1989
|
+
s.dataKey
|
|
1990
|
+
))
|
|
1991
|
+
] }) });
|
|
1992
|
+
}
|
|
1993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_recharts.LineChart, { accessibilityLayer: true, data, margin, children: [
|
|
1994
|
+
gridEl,
|
|
1995
|
+
axes,
|
|
1996
|
+
tooltipEl,
|
|
1997
|
+
legendEl,
|
|
1998
|
+
series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1999
|
+
import_recharts.Line,
|
|
2000
|
+
{
|
|
2001
|
+
dataKey: s.dataKey,
|
|
2002
|
+
type: curve,
|
|
2003
|
+
stroke: `var(--color-${s.dataKey})`,
|
|
2004
|
+
strokeWidth: 2,
|
|
2005
|
+
dot: dots === true ? { r: 3 } : false,
|
|
2006
|
+
activeDot: { r: 4 },
|
|
2007
|
+
isAnimationActive: true
|
|
1966
2008
|
},
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground", children: [
|
|
1971
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1972
|
-
"span",
|
|
1973
|
-
{
|
|
1974
|
-
className: "inline-block size-2 rounded-full",
|
|
1975
|
-
style: { background: r.color }
|
|
1976
|
-
}
|
|
1977
|
-
),
|
|
1978
|
-
r.label
|
|
1979
|
-
] }),
|
|
1980
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium tabular-nums text-foreground", children: r.value })
|
|
1981
|
-
] }, r.label)) })
|
|
1982
|
-
]
|
|
1983
|
-
}
|
|
1984
|
-
);
|
|
2009
|
+
s.dataKey
|
|
2010
|
+
))
|
|
2011
|
+
] }) });
|
|
1985
2012
|
};
|
|
1986
|
-
var
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
2013
|
+
var ChartShell = ({ config, height, className, ariaLabel, children }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2014
|
+
ChartContainer,
|
|
2015
|
+
{
|
|
2016
|
+
config,
|
|
2017
|
+
role: "img",
|
|
2018
|
+
"aria-label": ariaLabel,
|
|
2019
|
+
className: cn("aspect-auto w-full", className),
|
|
2020
|
+
style: { height },
|
|
2021
|
+
children
|
|
2022
|
+
}
|
|
2023
|
+
);
|
|
2024
|
+
var ChartEmpty = ({
|
|
2025
|
+
className,
|
|
2026
|
+
height,
|
|
2027
|
+
ariaLabel
|
|
2028
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1997
2029
|
"div",
|
|
1998
2030
|
{
|
|
1999
2031
|
className: cn(
|
|
@@ -2001,9 +2033,15 @@ var ChartEmpty = ({ className, height }) => /* @__PURE__ */ (0, import_jsx_runti
|
|
|
2001
2033
|
className
|
|
2002
2034
|
),
|
|
2003
2035
|
style: { height },
|
|
2036
|
+
role: "img",
|
|
2037
|
+
"aria-label": ariaLabel,
|
|
2004
2038
|
children: "No data yet"
|
|
2005
2039
|
}
|
|
2006
2040
|
);
|
|
2041
|
+
function barCornerRadius(r, horizontal, stacked) {
|
|
2042
|
+
if (stacked) return r;
|
|
2043
|
+
return horizontal ? [0, r, r, 0] : [r, r, 0, 0];
|
|
2044
|
+
}
|
|
2007
2045
|
function inferXKey(data) {
|
|
2008
2046
|
if (data.length === 0) return "x";
|
|
2009
2047
|
for (const k of Object.keys(data[0])) {
|
|
@@ -2018,21 +2056,304 @@ function resolveSeries(seriesProp, data, xKey) {
|
|
|
2018
2056
|
if (data.length === 0) return [];
|
|
2019
2057
|
return Object.keys(data[0]).filter((k) => k !== xKey && typeof data[0][k] === "number").map((dataKey) => ({ dataKey }));
|
|
2020
2058
|
}
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2059
|
+
|
|
2060
|
+
// src/charts/pie-chart.tsx
|
|
2061
|
+
var import_recharts2 = require("recharts");
|
|
2062
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2063
|
+
var PieChart = ({
|
|
2064
|
+
data,
|
|
2065
|
+
nameKey: nameKeyProp,
|
|
2066
|
+
dataKey = "value",
|
|
2067
|
+
innerRadius = 0,
|
|
2068
|
+
colors,
|
|
2069
|
+
height = 260,
|
|
2070
|
+
showLegend = true,
|
|
2071
|
+
showLabels = false,
|
|
2072
|
+
showTooltip = true,
|
|
2073
|
+
tooltipIndicator = "dot",
|
|
2074
|
+
centerValue,
|
|
2075
|
+
centerLabel,
|
|
2076
|
+
className,
|
|
2077
|
+
ariaLabel = "Pie chart"
|
|
2078
|
+
}) => {
|
|
2079
|
+
const nameKey = nameKeyProp ?? inferNameKey(data, dataKey);
|
|
2080
|
+
const palette = colors ?? CHART_PALETTE;
|
|
2081
|
+
if (data.length === 0) {
|
|
2082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PieEmpty, { className, height, ariaLabel });
|
|
2083
|
+
}
|
|
2084
|
+
const slices = data.map((d, i) => ({
|
|
2085
|
+
name: String(d[nameKey] ?? i),
|
|
2086
|
+
value: toNum(d[dataKey]),
|
|
2087
|
+
fill: palette[i % palette.length]
|
|
2088
|
+
}));
|
|
2089
|
+
const config = {};
|
|
2090
|
+
for (const s of slices) config[s.name] = { label: s.name };
|
|
2091
|
+
const innerPct = innerRadius > 0 ? `${Math.round(innerRadius * 75)}%` : 0;
|
|
2092
|
+
const hasCenter = innerRadius > 0 && (centerValue != null || centerLabel != null);
|
|
2093
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2094
|
+
ChartContainer,
|
|
2095
|
+
{
|
|
2096
|
+
config,
|
|
2097
|
+
role: "img",
|
|
2098
|
+
"aria-label": ariaLabel,
|
|
2099
|
+
className: cn("aspect-auto w-full", className),
|
|
2100
|
+
style: { height },
|
|
2101
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_recharts2.PieChart, { children: [
|
|
2102
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2103
|
+
ChartTooltip,
|
|
2104
|
+
{
|
|
2105
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ChartTooltipContent, { nameKey: "name", indicator: tooltipIndicator, hideLabel: true })
|
|
2106
|
+
}
|
|
2107
|
+
),
|
|
2108
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2109
|
+
import_recharts2.Pie,
|
|
2110
|
+
{
|
|
2111
|
+
data: slices,
|
|
2112
|
+
dataKey: "value",
|
|
2113
|
+
nameKey: "name",
|
|
2114
|
+
innerRadius: innerPct,
|
|
2115
|
+
outerRadius: "75%",
|
|
2116
|
+
paddingAngle: innerRadius > 0 ? 2 : 0,
|
|
2117
|
+
strokeWidth: 2,
|
|
2118
|
+
label: showLabels,
|
|
2119
|
+
isAnimationActive: true,
|
|
2120
|
+
children: [
|
|
2121
|
+
slices.map((s) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_recharts2.Cell, { fill: s.fill }, s.name)),
|
|
2122
|
+
hasCenter && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2123
|
+
import_recharts2.Label,
|
|
2124
|
+
{
|
|
2125
|
+
content: ({ viewBox }) => {
|
|
2126
|
+
if (!viewBox || !("cx" in viewBox)) return null;
|
|
2127
|
+
const { cx, cy } = viewBox;
|
|
2128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("text", { x: cx, y: cy, textAnchor: "middle", dominantBaseline: "middle", children: [
|
|
2129
|
+
centerValue != null && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("tspan", { x: cx, y: cy - 2, className: "fill-foreground text-2xl tabular-nums", children: centerValue }),
|
|
2130
|
+
centerLabel != null && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("tspan", { x: cx, y: cy + 18, className: "fill-muted-foreground text-[11px]", children: centerLabel })
|
|
2131
|
+
] });
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
)
|
|
2135
|
+
]
|
|
2136
|
+
}
|
|
2137
|
+
),
|
|
2138
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ChartLegend, { content: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ChartLegendContent, { nameKey: "name" }) })
|
|
2139
|
+
] })
|
|
2140
|
+
}
|
|
2141
|
+
);
|
|
2142
|
+
};
|
|
2143
|
+
var PieEmpty = ({
|
|
2144
|
+
className,
|
|
2145
|
+
height,
|
|
2146
|
+
ariaLabel
|
|
2147
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2148
|
+
"div",
|
|
2149
|
+
{
|
|
2150
|
+
className: cn("flex w-full items-center justify-center text-xs text-muted-foreground", className),
|
|
2151
|
+
style: { height },
|
|
2152
|
+
role: "img",
|
|
2153
|
+
"aria-label": ariaLabel,
|
|
2154
|
+
children: "No data yet"
|
|
2155
|
+
}
|
|
2156
|
+
);
|
|
2157
|
+
function inferNameKey(data, dataKey) {
|
|
2158
|
+
if (data.length === 0) return "name";
|
|
2159
|
+
for (const k of Object.keys(data[0])) {
|
|
2160
|
+
if (k !== dataKey && typeof data[0][k] !== "number") return k;
|
|
2161
|
+
}
|
|
2162
|
+
return Object.keys(data[0]).find((k) => k !== dataKey) ?? "name";
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
// src/charts/radial-chart.tsx
|
|
2166
|
+
var import_recharts3 = require("recharts");
|
|
2167
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2168
|
+
var RadialChart = ({
|
|
2169
|
+
data,
|
|
2170
|
+
nameKey: nameKeyProp,
|
|
2171
|
+
dataKey = "value",
|
|
2172
|
+
maxValue,
|
|
2173
|
+
colors,
|
|
2174
|
+
height = 260,
|
|
2175
|
+
ringWidth = 16,
|
|
2176
|
+
ringGap = 4,
|
|
2177
|
+
showLegend = true,
|
|
2178
|
+
centerValue,
|
|
2179
|
+
centerLabel,
|
|
2180
|
+
className,
|
|
2181
|
+
ariaLabel = "Radial chart"
|
|
2182
|
+
}) => {
|
|
2183
|
+
const nameKey = nameKeyProp ?? inferNameKey2(data, dataKey);
|
|
2184
|
+
const palette = colors ?? CHART_PALETTE;
|
|
2185
|
+
if (data.length === 0) {
|
|
2186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RadialEmpty, { className, height, ariaLabel });
|
|
2187
|
+
}
|
|
2188
|
+
const rows = data.map((d, i) => ({
|
|
2189
|
+
name: String(d[nameKey] ?? i),
|
|
2190
|
+
value: toNum(d[dataKey]),
|
|
2191
|
+
fill: palette[i % palette.length]
|
|
2192
|
+
}));
|
|
2193
|
+
const max = maxValue ?? Math.max(...rows.map((r) => r.value), 1);
|
|
2194
|
+
const config = {};
|
|
2195
|
+
for (const r of rows) config[r.name] = { label: r.name };
|
|
2196
|
+
const hasCenter = centerValue != null || centerLabel != null;
|
|
2197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: cn("flex w-full flex-col items-center gap-3", className), children: [
|
|
2198
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2199
|
+
ChartContainer,
|
|
2200
|
+
{
|
|
2201
|
+
config,
|
|
2202
|
+
role: "img",
|
|
2203
|
+
"aria-label": ariaLabel,
|
|
2204
|
+
className: "aspect-auto w-full",
|
|
2205
|
+
style: { height: height - (showLegend ? 32 : 0) },
|
|
2206
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2207
|
+
import_recharts3.RadialBarChart,
|
|
2208
|
+
{
|
|
2209
|
+
data: rows,
|
|
2210
|
+
startAngle: 90,
|
|
2211
|
+
endAngle: -270,
|
|
2212
|
+
innerRadius: "30%",
|
|
2213
|
+
outerRadius: "100%",
|
|
2214
|
+
barSize: ringWidth,
|
|
2215
|
+
barGap: ringGap,
|
|
2216
|
+
children: [
|
|
2217
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts3.PolarAngleAxis, { type: "number", domain: [0, max], tick: false, axisLine: false }),
|
|
2218
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartTooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartTooltipContent, { nameKey: "name", hideLabel: true }) }),
|
|
2219
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts3.RadialBar, { dataKey: "value", background: true, cornerRadius: ringWidth / 2, isAnimationActive: true, children: rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts3.Cell, { fill: r.fill }, r.name)) }),
|
|
2220
|
+
hasCenter && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts3.PolarRadiusAxis, { tick: false, tickLine: false, axisLine: false, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2221
|
+
import_recharts3.Label,
|
|
2222
|
+
{
|
|
2223
|
+
content: ({ viewBox }) => {
|
|
2224
|
+
if (!viewBox || !("cx" in viewBox)) return null;
|
|
2225
|
+
const { cx, cy } = viewBox;
|
|
2226
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("text", { x: cx, y: cy, textAnchor: "middle", dominantBaseline: "middle", children: [
|
|
2227
|
+
centerValue != null && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tspan", { x: cx, y: cy - 2, className: "fill-foreground text-2xl tabular-nums", children: centerValue }),
|
|
2228
|
+
centerLabel != null && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tspan", { x: cx, y: cy + 18, className: "fill-muted-foreground text-[11px]", children: centerLabel })
|
|
2229
|
+
] });
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
) })
|
|
2233
|
+
]
|
|
2234
|
+
}
|
|
2235
|
+
)
|
|
2236
|
+
}
|
|
2237
|
+
),
|
|
2238
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime12.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_runtime12.jsxs)("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
2239
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "inline-block size-2.5 rounded-[3px]", style: { background: r.fill } }),
|
|
2240
|
+
r.name
|
|
2241
|
+
] }, r.name)) })
|
|
2242
|
+
] });
|
|
2243
|
+
};
|
|
2244
|
+
var RadialEmpty = ({
|
|
2245
|
+
className,
|
|
2246
|
+
height,
|
|
2247
|
+
ariaLabel
|
|
2248
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2249
|
+
"div",
|
|
2250
|
+
{
|
|
2251
|
+
className: cn("flex w-full items-center justify-center text-xs text-muted-foreground", className),
|
|
2252
|
+
style: { height },
|
|
2253
|
+
role: "img",
|
|
2254
|
+
"aria-label": ariaLabel,
|
|
2255
|
+
children: "No data yet"
|
|
2256
|
+
}
|
|
2257
|
+
);
|
|
2258
|
+
function inferNameKey2(data, dataKey) {
|
|
2259
|
+
if (data.length === 0) return "name";
|
|
2260
|
+
for (const k of Object.keys(data[0])) {
|
|
2261
|
+
if (k !== dataKey && typeof data[0][k] !== "number") return k;
|
|
2262
|
+
}
|
|
2263
|
+
return Object.keys(data[0]).find((k) => k !== dataKey) ?? "name";
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
// src/charts/radar-chart.tsx
|
|
2267
|
+
var import_recharts4 = require("recharts");
|
|
2268
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2269
|
+
var RadarChart = ({
|
|
2270
|
+
data,
|
|
2271
|
+
nameKey: nameKeyProp,
|
|
2272
|
+
series: seriesProp,
|
|
2273
|
+
maxValue,
|
|
2274
|
+
height = 280,
|
|
2275
|
+
showLegend = true,
|
|
2276
|
+
fill = true,
|
|
2277
|
+
className,
|
|
2278
|
+
ariaLabel = "Radar chart"
|
|
2279
|
+
}) => {
|
|
2280
|
+
const nameKey = nameKeyProp ?? inferNameKey3(data);
|
|
2281
|
+
const series = resolveSeries2(seriesProp, data, nameKey);
|
|
2282
|
+
if (data.length < 3 || series.length === 0) {
|
|
2283
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2284
|
+
"div",
|
|
2285
|
+
{
|
|
2286
|
+
className: cn("flex items-center justify-center text-xs text-muted-foreground", className),
|
|
2287
|
+
style: { height },
|
|
2288
|
+
role: "img",
|
|
2289
|
+
"aria-label": ariaLabel,
|
|
2290
|
+
children: "Radar needs at least 3 axes"
|
|
2291
|
+
}
|
|
2292
|
+
);
|
|
2293
|
+
}
|
|
2294
|
+
const config = {};
|
|
2295
|
+
series.forEach((s, i) => {
|
|
2296
|
+
config[s.dataKey] = {
|
|
2297
|
+
label: s.label ?? s.dataKey,
|
|
2298
|
+
color: s.color ?? CHART_PALETTE[i % CHART_PALETTE.length]
|
|
2299
|
+
};
|
|
2300
|
+
});
|
|
2301
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2302
|
+
ChartContainer,
|
|
2303
|
+
{
|
|
2304
|
+
config,
|
|
2305
|
+
role: "img",
|
|
2306
|
+
"aria-label": ariaLabel,
|
|
2307
|
+
className: cn("mx-auto aspect-square", className),
|
|
2308
|
+
style: { height },
|
|
2309
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_recharts4.RadarChart, { data, outerRadius: "70%", children: [
|
|
2310
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ChartTooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ChartTooltipContent, { indicator: "line" }) }),
|
|
2311
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_recharts4.PolarGrid, {}),
|
|
2312
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2313
|
+
import_recharts4.PolarAngleAxis,
|
|
2314
|
+
{
|
|
2315
|
+
dataKey: nameKey,
|
|
2316
|
+
tick: { fontSize: 10, fill: "var(--color-muted-foreground)" }
|
|
2317
|
+
}
|
|
2318
|
+
),
|
|
2319
|
+
series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2320
|
+
import_recharts4.Radar,
|
|
2321
|
+
{
|
|
2322
|
+
dataKey: s.dataKey,
|
|
2323
|
+
stroke: `var(--color-${s.dataKey})`,
|
|
2324
|
+
fill: `var(--color-${s.dataKey})`,
|
|
2325
|
+
fillOpacity: fill ? 0.18 : 0,
|
|
2326
|
+
strokeWidth: 2,
|
|
2327
|
+
dot: { r: 2.5, fillOpacity: 1 },
|
|
2328
|
+
isAnimationActive: true
|
|
2329
|
+
},
|
|
2330
|
+
s.dataKey
|
|
2331
|
+
)),
|
|
2332
|
+
showLegend && series.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ChartLegend, { content: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ChartLegendContent, {}) })
|
|
2333
|
+
] })
|
|
2334
|
+
}
|
|
2335
|
+
);
|
|
2336
|
+
};
|
|
2337
|
+
function inferNameKey3(data) {
|
|
2338
|
+
if (data.length === 0) return "name";
|
|
2339
|
+
for (const k of Object.keys(data[0])) {
|
|
2340
|
+
if (typeof data[0][k] !== "number") return k;
|
|
2341
|
+
}
|
|
2342
|
+
return Object.keys(data[0])[0] ?? "name";
|
|
2343
|
+
}
|
|
2344
|
+
function resolveSeries2(seriesProp, data, nameKey) {
|
|
2345
|
+
if (seriesProp && seriesProp.length > 0) {
|
|
2346
|
+
return seriesProp.map((s) => typeof s === "string" ? { dataKey: s } : s);
|
|
2347
|
+
}
|
|
2348
|
+
if (data.length === 0) return [];
|
|
2349
|
+
return Object.keys(data[0]).filter((k) => k !== nameKey && typeof data[0][k] === "number").map((dataKey) => ({ dataKey }));
|
|
2029
2350
|
}
|
|
2030
2351
|
|
|
2031
2352
|
// src/artifacts/artifact-card.tsx
|
|
2032
|
-
var
|
|
2353
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2033
2354
|
var ArtifactCard = ({ title, kind, className, bodyClassName, toolbar, children }) => {
|
|
2034
2355
|
const hasHeader = Boolean(title || toolbar);
|
|
2035
|
-
return /* @__PURE__ */ (0,
|
|
2356
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2036
2357
|
"div",
|
|
2037
2358
|
{
|
|
2038
2359
|
className: cn(
|
|
@@ -2041,29 +2362,29 @@ var ArtifactCard = ({ title, kind, className, bodyClassName, toolbar, children }
|
|
|
2041
2362
|
),
|
|
2042
2363
|
"data-artifact-kind": kind,
|
|
2043
2364
|
children: [
|
|
2044
|
-
hasHeader && /* @__PURE__ */ (0,
|
|
2045
|
-
title && /* @__PURE__ */ (0,
|
|
2046
|
-
!title && /* @__PURE__ */ (0,
|
|
2365
|
+
hasHeader && /* @__PURE__ */ (0, import_jsx_runtime14.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: [
|
|
2366
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "aui-artifact-title flex-1 truncate text-xs font-semibold text-foreground/80", children: title }),
|
|
2367
|
+
!title && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "flex-1" }),
|
|
2047
2368
|
toolbar
|
|
2048
2369
|
] }),
|
|
2049
|
-
/* @__PURE__ */ (0,
|
|
2370
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: cn("aui-artifact-body", bodyClassName), children })
|
|
2050
2371
|
]
|
|
2051
2372
|
}
|
|
2052
2373
|
);
|
|
2053
2374
|
};
|
|
2054
2375
|
|
|
2055
2376
|
// src/artifacts/chart-artifact.tsx
|
|
2056
|
-
var
|
|
2377
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2057
2378
|
var ChartArtifactView = ({
|
|
2058
2379
|
artifact,
|
|
2059
2380
|
embedded = false,
|
|
2060
2381
|
height = 300
|
|
2061
2382
|
}) => {
|
|
2062
|
-
const plot = /* @__PURE__ */ (0,
|
|
2383
|
+
const plot = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChartArtifactPlot, { artifact, height });
|
|
2063
2384
|
if (embedded) {
|
|
2064
|
-
return /* @__PURE__ */ (0,
|
|
2385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "aui-artifact-chart w-full", children: plot });
|
|
2065
2386
|
}
|
|
2066
|
-
return /* @__PURE__ */ (0,
|
|
2387
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ArtifactCard, { title: artifact.title, kind: "chart", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "aui-artifact-chart pt-2", children: plot }) });
|
|
2067
2388
|
};
|
|
2068
2389
|
function ChartArtifactPlot({
|
|
2069
2390
|
artifact,
|
|
@@ -2071,14 +2392,58 @@ function ChartArtifactPlot({
|
|
|
2071
2392
|
}) {
|
|
2072
2393
|
const { chartType = "bar", data = [] } = artifact;
|
|
2073
2394
|
const xKey = artifact.xKey ?? inferXKey2(data);
|
|
2074
|
-
const series = (0,
|
|
2395
|
+
const series = (0, import_react7.useMemo)(() => {
|
|
2396
|
+
if (artifact.series && artifact.series.length > 0) {
|
|
2397
|
+
return artifact.series.map((s) => ({
|
|
2398
|
+
dataKey: s.dataKey,
|
|
2399
|
+
label: s.label,
|
|
2400
|
+
color: s.color
|
|
2401
|
+
}));
|
|
2402
|
+
}
|
|
2075
2403
|
const keys = Array.isArray(artifact.dataKey) ? artifact.dataKey : typeof artifact.dataKey === "string" ? [artifact.dataKey] : inferDataKeys(data, xKey);
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2404
|
+
const colors = artifact.colors;
|
|
2405
|
+
return keys.map((dataKey, i) => ({
|
|
2406
|
+
dataKey,
|
|
2407
|
+
color: colors?.[i]
|
|
2408
|
+
}));
|
|
2409
|
+
}, [artifact.series, artifact.dataKey, artifact.colors, data, xKey]);
|
|
2410
|
+
const aria = typeof artifact.title === "string" ? artifact.title : "Chart";
|
|
2411
|
+
if (chartType === "pie" || chartType === "donut") {
|
|
2412
|
+
const total = data.reduce((sum, d) => sum + toNum(d[series[0]?.dataKey ?? "value"]), 0);
|
|
2413
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2414
|
+
PieChart,
|
|
2415
|
+
{
|
|
2416
|
+
data,
|
|
2417
|
+
nameKey: xKey,
|
|
2418
|
+
dataKey: series[0]?.dataKey ?? "value",
|
|
2419
|
+
innerRadius: chartType === "donut" ? 0.6 : 0,
|
|
2420
|
+
colors: artifact.colors,
|
|
2421
|
+
height,
|
|
2422
|
+
unit: artifact.unit,
|
|
2423
|
+
centerValue: chartType === "donut" ? formatCompact(total, artifact.unit) : void 0,
|
|
2424
|
+
centerLabel: chartType === "donut" ? "Total" : void 0,
|
|
2425
|
+
ariaLabel: aria
|
|
2426
|
+
}
|
|
2427
|
+
) });
|
|
2080
2428
|
}
|
|
2081
|
-
|
|
2429
|
+
if (chartType === "radial") {
|
|
2430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2431
|
+
RadialChart,
|
|
2432
|
+
{
|
|
2433
|
+
data,
|
|
2434
|
+
nameKey: xKey,
|
|
2435
|
+
dataKey: series[0]?.dataKey ?? "value",
|
|
2436
|
+
colors: artifact.colors,
|
|
2437
|
+
height,
|
|
2438
|
+
ariaLabel: aria
|
|
2439
|
+
}
|
|
2440
|
+
) });
|
|
2441
|
+
}
|
|
2442
|
+
if (chartType === "radar") {
|
|
2443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(RadarChart, { data, nameKey: xKey, series, height, ariaLabel: aria }) });
|
|
2444
|
+
}
|
|
2445
|
+
const horizontal = chartType === "horizontalBar";
|
|
2446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2082
2447
|
LineAreaChart,
|
|
2083
2448
|
{
|
|
2084
2449
|
data,
|
|
@@ -2087,71 +2452,19 @@ function ChartArtifactPlot({
|
|
|
2087
2452
|
layout: "flush",
|
|
2088
2453
|
height,
|
|
2089
2454
|
variant: chartType === "line" ? "line" : chartType === "area" ? "area" : "bar",
|
|
2455
|
+
orientation: horizontal ? "horizontal" : "vertical",
|
|
2456
|
+
stacked: artifact.stacked,
|
|
2457
|
+
curve: artifact.curve,
|
|
2458
|
+
dots: artifact.dots,
|
|
2459
|
+
tooltipIndicator: artifact.tooltipIndicator,
|
|
2460
|
+
showXAxis: true,
|
|
2461
|
+
showYAxis: horizontal,
|
|
2462
|
+
showLegend: artifact.legend ?? series.length > 1,
|
|
2090
2463
|
unit: artifact.unit,
|
|
2091
|
-
ariaLabel:
|
|
2464
|
+
ariaLabel: aria
|
|
2092
2465
|
}
|
|
2093
2466
|
);
|
|
2094
2467
|
}
|
|
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
2468
|
function inferXKey2(data) {
|
|
2156
2469
|
if (data.length === 0) return "x";
|
|
2157
2470
|
for (const k of Object.keys(data[0])) {
|
|
@@ -2167,8 +2480,8 @@ function inferDataKeys(data, xKey) {
|
|
|
2167
2480
|
}
|
|
2168
2481
|
|
|
2169
2482
|
// src/artifacts/question-artifact.tsx
|
|
2170
|
-
var
|
|
2171
|
-
var
|
|
2483
|
+
var import_react8 = require("react");
|
|
2484
|
+
var import_react9 = require("@assistant-ui/react");
|
|
2172
2485
|
var import_lucide_react3 = require("lucide-react");
|
|
2173
2486
|
|
|
2174
2487
|
// src/design/classes.ts
|
|
@@ -2277,12 +2590,12 @@ var studioQuestionOptionSelectedClass = cn(
|
|
|
2277
2590
|
);
|
|
2278
2591
|
|
|
2279
2592
|
// src/artifacts/question-artifact.tsx
|
|
2280
|
-
var
|
|
2593
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2281
2594
|
function optionKey(option, index) {
|
|
2282
2595
|
const id = option.id?.trim();
|
|
2283
2596
|
return id ? id : `__option-${index}`;
|
|
2284
2597
|
}
|
|
2285
|
-
var OptionRadio = ({ selected }) => /* @__PURE__ */ (0,
|
|
2598
|
+
var OptionRadio = ({ selected }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2286
2599
|
"span",
|
|
2287
2600
|
{
|
|
2288
2601
|
className: cn(
|
|
@@ -2290,18 +2603,18 @@ var OptionRadio = ({ selected }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx
|
|
|
2290
2603
|
selected ? "border-foreground bg-foreground text-background" : "border-border bg-background"
|
|
2291
2604
|
),
|
|
2292
2605
|
"aria-hidden": true,
|
|
2293
|
-
children: selected ? /* @__PURE__ */ (0,
|
|
2606
|
+
children: selected ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react3.CheckIcon, { className: "size-2.5 stroke-[3]" }) : null
|
|
2294
2607
|
}
|
|
2295
2608
|
);
|
|
2296
2609
|
var QuestionArtifactView = ({
|
|
2297
2610
|
artifact
|
|
2298
2611
|
}) => {
|
|
2299
|
-
const runtime = (0,
|
|
2300
|
-
const [selected, setSelected] = (0,
|
|
2301
|
-
const [submittedIds, setSubmittedIds] = (0,
|
|
2612
|
+
const runtime = (0, import_react9.useThreadRuntime)();
|
|
2613
|
+
const [selected, setSelected] = (0, import_react8.useState)([]);
|
|
2614
|
+
const [submittedIds, setSubmittedIds] = (0, import_react8.useState)(null);
|
|
2302
2615
|
const isMulti = artifact.multi === true;
|
|
2303
2616
|
const isDisabled = submittedIds !== null;
|
|
2304
|
-
const send = (0,
|
|
2617
|
+
const send = (0, import_react8.useCallback)(
|
|
2305
2618
|
(keys) => {
|
|
2306
2619
|
if (keys.length === 0) return;
|
|
2307
2620
|
const labels = artifact.options.map((option, index) => ({ option, key: optionKey(option, index) })).filter(({ key }) => keys.includes(key)).map(({ option }) => option.label);
|
|
@@ -2313,7 +2626,7 @@ var QuestionArtifactView = ({
|
|
|
2313
2626
|
},
|
|
2314
2627
|
[artifact.options, runtime]
|
|
2315
2628
|
);
|
|
2316
|
-
const onPick = (0,
|
|
2629
|
+
const onPick = (0, import_react8.useCallback)(
|
|
2317
2630
|
(key) => {
|
|
2318
2631
|
if (isDisabled) return;
|
|
2319
2632
|
if (!isMulti) {
|
|
@@ -2326,15 +2639,15 @@ var QuestionArtifactView = ({
|
|
|
2326
2639
|
},
|
|
2327
2640
|
[isDisabled, isMulti, send]
|
|
2328
2641
|
);
|
|
2329
|
-
const onConfirm = (0,
|
|
2642
|
+
const onConfirm = (0, import_react8.useCallback)(() => {
|
|
2330
2643
|
send(selected);
|
|
2331
2644
|
}, [selected, send]);
|
|
2332
|
-
return /* @__PURE__ */ (0,
|
|
2333
|
-
artifact.prompt ? /* @__PURE__ */ (0,
|
|
2334
|
-
/* @__PURE__ */ (0,
|
|
2645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: studioArtifactShellClass, "data-artifact-kind": "question", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "px-2.5 py-2", children: [
|
|
2646
|
+
artifact.prompt ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "mb-2 text-sm font-normal leading-snug text-foreground", children: artifact.prompt }) : null,
|
|
2647
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex flex-col gap-0.5", role: "list", children: artifact.options.map((option, index) => {
|
|
2335
2648
|
const key = optionKey(option, index);
|
|
2336
2649
|
const isSelected = submittedIds ? submittedIds.includes(key) : isMulti && selected.includes(key);
|
|
2337
|
-
return /* @__PURE__ */ (0,
|
|
2650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
2338
2651
|
"button",
|
|
2339
2652
|
{
|
|
2340
2653
|
type: "button",
|
|
@@ -2346,17 +2659,17 @@ var QuestionArtifactView = ({
|
|
|
2346
2659
|
isDisabled && (isSelected ? "cursor-default" : "cursor-not-allowed opacity-50")
|
|
2347
2660
|
),
|
|
2348
2661
|
children: [
|
|
2349
|
-
/* @__PURE__ */ (0,
|
|
2350
|
-
/* @__PURE__ */ (0,
|
|
2351
|
-
/* @__PURE__ */ (0,
|
|
2352
|
-
option.description ? /* @__PURE__ */ (0,
|
|
2662
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(OptionRadio, { selected: isSelected }),
|
|
2663
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "min-w-0 flex-1 text-left", children: [
|
|
2664
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "block font-normal text-foreground", children: option.label }),
|
|
2665
|
+
option.description ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: option.description }) : null
|
|
2353
2666
|
] })
|
|
2354
2667
|
]
|
|
2355
2668
|
},
|
|
2356
2669
|
key
|
|
2357
2670
|
);
|
|
2358
2671
|
}) }),
|
|
2359
|
-
isMulti && !submittedIds ? /* @__PURE__ */ (0,
|
|
2672
|
+
isMulti && !submittedIds ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "mt-2 flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2360
2673
|
TimbalV2Button,
|
|
2361
2674
|
{
|
|
2362
2675
|
type: "button",
|
|
@@ -2371,12 +2684,12 @@ var QuestionArtifactView = ({
|
|
|
2371
2684
|
};
|
|
2372
2685
|
|
|
2373
2686
|
// src/artifacts/html-artifact.tsx
|
|
2374
|
-
var
|
|
2687
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2375
2688
|
var HtmlArtifactView = ({ artifact }) => {
|
|
2376
2689
|
const sandboxed = artifact.sandboxed !== false;
|
|
2377
2690
|
const sandbox = sandboxed ? "allow-scripts allow-same-origin allow-forms allow-modals allow-popups allow-pointer-lock" : void 0;
|
|
2378
2691
|
const height = artifact.height ?? "320px";
|
|
2379
|
-
return /* @__PURE__ */ (0,
|
|
2692
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ArtifactCard, { title: artifact.title, kind: "html", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2380
2693
|
"iframe",
|
|
2381
2694
|
{
|
|
2382
2695
|
title: artifact.title ?? "HTML artifact",
|
|
@@ -2389,7 +2702,7 @@ var HtmlArtifactView = ({ artifact }) => {
|
|
|
2389
2702
|
};
|
|
2390
2703
|
|
|
2391
2704
|
// src/artifacts/json-artifact.tsx
|
|
2392
|
-
var
|
|
2705
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2393
2706
|
var JsonArtifactView = ({
|
|
2394
2707
|
artifact
|
|
2395
2708
|
}) => {
|
|
@@ -2401,16 +2714,16 @@ var JsonArtifactView = ({
|
|
|
2401
2714
|
} catch {
|
|
2402
2715
|
body = String(data);
|
|
2403
2716
|
}
|
|
2404
|
-
return /* @__PURE__ */ (0,
|
|
2717
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ArtifactCard, { title, kind: "json", children: /* @__PURE__ */ (0, import_jsx_runtime18.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
2718
|
};
|
|
2406
2719
|
|
|
2407
2720
|
// src/artifacts/table-artifact.tsx
|
|
2408
|
-
var
|
|
2721
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2409
2722
|
var TableArtifactView = ({ artifact }) => {
|
|
2410
2723
|
const rows = artifact.rows ?? [];
|
|
2411
2724
|
const columns = artifact.columns ?? deriveColumns(rows);
|
|
2412
|
-
return /* @__PURE__ */ (0,
|
|
2413
|
-
/* @__PURE__ */ (0,
|
|
2725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ArtifactCard, { title: artifact.title, kind: "table", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "aui-artifact-table-wrap overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("table", { className: "aui-artifact-table w-full border-collapse text-sm", children: [
|
|
2726
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("tr", { className: "border-b border-border/40 bg-muted/20", children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2414
2727
|
"th",
|
|
2415
2728
|
{
|
|
2416
2729
|
className: "px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",
|
|
@@ -2418,11 +2731,11 @@ var TableArtifactView = ({ artifact }) => {
|
|
|
2418
2731
|
},
|
|
2419
2732
|
col.key
|
|
2420
2733
|
)) }) }),
|
|
2421
|
-
/* @__PURE__ */ (0,
|
|
2734
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("tbody", { children: rows.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2422
2735
|
"tr",
|
|
2423
2736
|
{
|
|
2424
2737
|
className: "border-b border-border/30 transition-colors last:border-b-0 hover:bg-muted/20",
|
|
2425
|
-
children: columns.map((col) => /* @__PURE__ */ (0,
|
|
2738
|
+
children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2426
2739
|
"td",
|
|
2427
2740
|
{
|
|
2428
2741
|
className: "px-3 py-2 align-top text-foreground/85",
|
|
@@ -2455,7 +2768,7 @@ function formatCell(value) {
|
|
|
2455
2768
|
}
|
|
2456
2769
|
|
|
2457
2770
|
// src/artifacts/ui/ui-artifact.tsx
|
|
2458
|
-
var
|
|
2771
|
+
var import_react14 = require("react");
|
|
2459
2772
|
|
|
2460
2773
|
// src/artifacts/ui/types.ts
|
|
2461
2774
|
function isUiBinding(value) {
|
|
@@ -2508,38 +2821,38 @@ function resolveBindable(value, state) {
|
|
|
2508
2821
|
}
|
|
2509
2822
|
|
|
2510
2823
|
// src/artifacts/ui/registry.tsx
|
|
2511
|
-
var
|
|
2512
|
-
var
|
|
2513
|
-
var UiStateContext = (0,
|
|
2514
|
-
var UiDispatchContext = (0,
|
|
2824
|
+
var import_react10 = require("react");
|
|
2825
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2826
|
+
var UiStateContext = (0, import_react10.createContext)({});
|
|
2827
|
+
var UiDispatchContext = (0, import_react10.createContext)(() => {
|
|
2515
2828
|
});
|
|
2516
|
-
var UiStateProvider = ({ state, dispatch, children }) => /* @__PURE__ */ (0,
|
|
2829
|
+
var UiStateProvider = ({ state, dispatch, children }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(UiStateContext.Provider, { value: state, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(UiDispatchContext.Provider, { value: dispatch, children }) });
|
|
2517
2830
|
function useUiState() {
|
|
2518
|
-
return (0,
|
|
2831
|
+
return (0, import_react10.useContext)(UiStateContext);
|
|
2519
2832
|
}
|
|
2520
2833
|
function useUiDispatch() {
|
|
2521
|
-
return (0,
|
|
2834
|
+
return (0, import_react10.useContext)(UiDispatchContext);
|
|
2522
2835
|
}
|
|
2523
|
-
var UiEventContext = (0,
|
|
2836
|
+
var UiEventContext = (0, import_react10.createContext)(
|
|
2524
2837
|
null
|
|
2525
2838
|
);
|
|
2526
|
-
var UiEventProvider = ({ onEvent, children }) => /* @__PURE__ */ (0,
|
|
2839
|
+
var UiEventProvider = ({ onEvent, children }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(UiEventContext.Provider, { value: onEvent, children });
|
|
2527
2840
|
function useUiEventEmitter() {
|
|
2528
|
-
return (0,
|
|
2841
|
+
return (0, import_react10.useContext)(UiEventContext);
|
|
2529
2842
|
}
|
|
2530
|
-
var UiCustomNodeRegistryContext = (0,
|
|
2843
|
+
var UiCustomNodeRegistryContext = (0, import_react10.createContext)({});
|
|
2531
2844
|
function useUiCustomNodeRegistry() {
|
|
2532
|
-
return (0,
|
|
2845
|
+
return (0, import_react10.useContext)(UiCustomNodeRegistryContext);
|
|
2533
2846
|
}
|
|
2534
2847
|
|
|
2535
2848
|
// src/artifacts/ui/nodes.tsx
|
|
2536
|
-
var
|
|
2537
|
-
var
|
|
2538
|
-
var
|
|
2849
|
+
var import_react11 = require("react");
|
|
2850
|
+
var import_react12 = require("motion/react");
|
|
2851
|
+
var import_react13 = require("@assistant-ui/react");
|
|
2539
2852
|
|
|
2540
2853
|
// src/ui/button.tsx
|
|
2541
2854
|
var import_class_variance_authority = require("class-variance-authority");
|
|
2542
|
-
var
|
|
2855
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2543
2856
|
var LEGACY_SIZE_TO_V2 = {
|
|
2544
2857
|
default: "md",
|
|
2545
2858
|
xs: "xs",
|
|
@@ -2589,7 +2902,7 @@ function Button({
|
|
|
2589
2902
|
const v2Variant = TIMBAL_V2_FROM_LEGACY_BUTTON[variant ?? "default"];
|
|
2590
2903
|
const v2Size = LEGACY_SIZE_TO_V2[size ?? "default"];
|
|
2591
2904
|
const isIconOnly = typeof size === "string" && size.startsWith("icon");
|
|
2592
|
-
return /* @__PURE__ */ (0,
|
|
2905
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2593
2906
|
TimbalV2Button,
|
|
2594
2907
|
{
|
|
2595
2908
|
"data-slot": "button",
|
|
@@ -2607,29 +2920,29 @@ function Button({
|
|
|
2607
2920
|
}
|
|
2608
2921
|
|
|
2609
2922
|
// src/artifacts/ui/nodes.tsx
|
|
2610
|
-
var
|
|
2923
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2611
2924
|
var UiNodeView = ({ node }) => {
|
|
2612
2925
|
switch (node.kind) {
|
|
2613
2926
|
case "box":
|
|
2614
|
-
return /* @__PURE__ */ (0,
|
|
2927
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(BoxNode, { node });
|
|
2615
2928
|
case "text":
|
|
2616
|
-
return /* @__PURE__ */ (0,
|
|
2929
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(TextNode, { node });
|
|
2617
2930
|
case "heading":
|
|
2618
|
-
return /* @__PURE__ */ (0,
|
|
2931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(HeadingNode, { node });
|
|
2619
2932
|
case "badge":
|
|
2620
|
-
return /* @__PURE__ */ (0,
|
|
2933
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(BadgeNode, { node });
|
|
2621
2934
|
case "button":
|
|
2622
|
-
return /* @__PURE__ */ (0,
|
|
2935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ButtonNode, { node });
|
|
2623
2936
|
case "toggle":
|
|
2624
|
-
return /* @__PURE__ */ (0,
|
|
2937
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ToggleNode, { node });
|
|
2625
2938
|
case "slider":
|
|
2626
|
-
return /* @__PURE__ */ (0,
|
|
2939
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SliderNode, { node });
|
|
2627
2940
|
case "tooltip":
|
|
2628
|
-
return /* @__PURE__ */ (0,
|
|
2941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(TooltipNode, { node });
|
|
2629
2942
|
case "draggable":
|
|
2630
|
-
return /* @__PURE__ */ (0,
|
|
2943
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DraggableNode, { node });
|
|
2631
2944
|
case "custom":
|
|
2632
|
-
return /* @__PURE__ */ (0,
|
|
2945
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CustomNode, { node });
|
|
2633
2946
|
default:
|
|
2634
2947
|
return null;
|
|
2635
2948
|
}
|
|
@@ -2637,9 +2950,9 @@ var UiNodeView = ({ node }) => {
|
|
|
2637
2950
|
function useActionRunner() {
|
|
2638
2951
|
const state = useUiState();
|
|
2639
2952
|
const dispatch = useUiDispatch();
|
|
2640
|
-
const runtime = (0,
|
|
2953
|
+
const runtime = (0, import_react13.useThreadRuntime)();
|
|
2641
2954
|
const emit = useUiEventEmitter();
|
|
2642
|
-
return (0,
|
|
2955
|
+
return (0, import_react11.useCallback)(
|
|
2643
2956
|
(actions) => {
|
|
2644
2957
|
if (!actions) return;
|
|
2645
2958
|
const list = Array.isArray(actions) ? actions : [actions];
|
|
@@ -2689,7 +3002,7 @@ var JUSTIFY_CLS = {
|
|
|
2689
3002
|
};
|
|
2690
3003
|
var BoxNode = ({ node }) => {
|
|
2691
3004
|
const dir = node.direction ?? "col";
|
|
2692
|
-
return /* @__PURE__ */ (0,
|
|
3005
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2693
3006
|
"div",
|
|
2694
3007
|
{
|
|
2695
3008
|
className: cn(
|
|
@@ -2704,7 +3017,7 @@ var BoxNode = ({ node }) => {
|
|
|
2704
3017
|
gap: node.gap !== void 0 ? `${node.gap * 0.25}rem` : void 0,
|
|
2705
3018
|
padding: node.padding !== void 0 ? `${node.padding * 0.25}rem` : void 0
|
|
2706
3019
|
},
|
|
2707
|
-
children: node.children?.map((child, i) => /* @__PURE__ */ (0,
|
|
3020
|
+
children: node.children?.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(UiNodeView, { node: child }, child.id ?? i))
|
|
2708
3021
|
}
|
|
2709
3022
|
);
|
|
2710
3023
|
};
|
|
@@ -2723,7 +3036,7 @@ var TEXT_WEIGHT = {
|
|
|
2723
3036
|
var TextNode = ({ node }) => {
|
|
2724
3037
|
const state = useUiState();
|
|
2725
3038
|
const value = resolveBindable(node.value, state);
|
|
2726
|
-
return /* @__PURE__ */ (0,
|
|
3039
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2727
3040
|
"span",
|
|
2728
3041
|
{
|
|
2729
3042
|
className: cn(
|
|
@@ -2754,13 +3067,13 @@ var HeadingNode = ({ node }) => {
|
|
|
2754
3067
|
);
|
|
2755
3068
|
switch (level) {
|
|
2756
3069
|
case 1:
|
|
2757
|
-
return /* @__PURE__ */ (0,
|
|
3070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h1", { className: cls, children: value });
|
|
2758
3071
|
case 2:
|
|
2759
|
-
return /* @__PURE__ */ (0,
|
|
3072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h2", { className: cls, children: value });
|
|
2760
3073
|
case 3:
|
|
2761
|
-
return /* @__PURE__ */ (0,
|
|
3074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h3", { className: cls, children: value });
|
|
2762
3075
|
case 4:
|
|
2763
|
-
return /* @__PURE__ */ (0,
|
|
3076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h4", { className: cls, children: value });
|
|
2764
3077
|
}
|
|
2765
3078
|
};
|
|
2766
3079
|
var BADGE_TONE = {
|
|
@@ -2773,7 +3086,7 @@ var BADGE_TONE = {
|
|
|
2773
3086
|
var BadgeNode = ({ node }) => {
|
|
2774
3087
|
const state = useUiState();
|
|
2775
3088
|
const value = String(resolveBindable(node.value, state) ?? "");
|
|
2776
|
-
return /* @__PURE__ */ (0,
|
|
3089
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2777
3090
|
"span",
|
|
2778
3091
|
{
|
|
2779
3092
|
className: cn(
|
|
@@ -2790,7 +3103,7 @@ var ButtonNode = ({ node }) => {
|
|
|
2790
3103
|
const run = useActionRunner();
|
|
2791
3104
|
const label = String(resolveBindable(node.label, state) ?? "");
|
|
2792
3105
|
const disabled = node.disabled !== void 0 ? Boolean(resolveBindable(node.disabled, state)) : false;
|
|
2793
|
-
return /* @__PURE__ */ (0,
|
|
3106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2794
3107
|
Button,
|
|
2795
3108
|
{
|
|
2796
3109
|
variant: node.variant ?? "default",
|
|
@@ -2812,7 +3125,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2812
3125
|
dispatch({ type: "toggle", path: node.binding });
|
|
2813
3126
|
run(node.onChange);
|
|
2814
3127
|
};
|
|
2815
|
-
return /* @__PURE__ */ (0,
|
|
3128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2816
3129
|
"label",
|
|
2817
3130
|
{
|
|
2818
3131
|
className: cn(
|
|
@@ -2820,7 +3133,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2820
3133
|
node.className
|
|
2821
3134
|
),
|
|
2822
3135
|
children: [
|
|
2823
|
-
/* @__PURE__ */ (0,
|
|
3136
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2824
3137
|
"button",
|
|
2825
3138
|
{
|
|
2826
3139
|
type: "button",
|
|
@@ -2831,7 +3144,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2831
3144
|
"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-[background,box-shadow,border-color] duration-200",
|
|
2832
3145
|
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
3146
|
),
|
|
2834
|
-
children: /* @__PURE__ */ (0,
|
|
3147
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2835
3148
|
"span",
|
|
2836
3149
|
{
|
|
2837
3150
|
className: cn(
|
|
@@ -2844,7 +3157,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2844
3157
|
)
|
|
2845
3158
|
}
|
|
2846
3159
|
),
|
|
2847
|
-
label && /* @__PURE__ */ (0,
|
|
3160
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-foreground/85", children: label })
|
|
2848
3161
|
]
|
|
2849
3162
|
}
|
|
2850
3163
|
);
|
|
@@ -2864,12 +3177,12 @@ var SliderNode = ({ node }) => {
|
|
|
2864
3177
|
const next = Number(e.target.value);
|
|
2865
3178
|
dispatch({ type: "set", path: node.binding, value: next });
|
|
2866
3179
|
};
|
|
2867
|
-
return /* @__PURE__ */ (0,
|
|
2868
|
-
(label || showValue) && /* @__PURE__ */ (0,
|
|
2869
|
-
label && /* @__PURE__ */ (0,
|
|
2870
|
-
showValue && /* @__PURE__ */ (0,
|
|
3180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cn("aui-ui-slider flex flex-col gap-1", node.className), children: [
|
|
3181
|
+
(label || showValue) && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center justify-between text-xs text-muted-foreground", children: [
|
|
3182
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: label }),
|
|
3183
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "font-mono", children: value })
|
|
2871
3184
|
] }),
|
|
2872
|
-
/* @__PURE__ */ (0,
|
|
3185
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2873
3186
|
"input",
|
|
2874
3187
|
{
|
|
2875
3188
|
type: "range",
|
|
@@ -2891,9 +3204,9 @@ var SliderNode = ({ node }) => {
|
|
|
2891
3204
|
var TooltipNode = ({ node }) => {
|
|
2892
3205
|
const state = useUiState();
|
|
2893
3206
|
const content = String(resolveBindable(node.content, state) ?? "");
|
|
2894
|
-
return /* @__PURE__ */ (0,
|
|
2895
|
-
/* @__PURE__ */ (0,
|
|
2896
|
-
/* @__PURE__ */ (0,
|
|
3207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Tooltip, { children: [
|
|
3208
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: cn("aui-ui-tooltip-trigger inline-flex", node.className), children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(UiNodeView, { node: node.child }) }) }),
|
|
3209
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(TooltipContent, { side: node.side ?? "top", children: content })
|
|
2897
3210
|
] }) });
|
|
2898
3211
|
};
|
|
2899
3212
|
var DraggableNode = ({ node }) => {
|
|
@@ -2901,8 +3214,8 @@ var DraggableNode = ({ node }) => {
|
|
|
2901
3214
|
const snapBack = node.snapBack ?? true;
|
|
2902
3215
|
const axis = node.axis ?? "both";
|
|
2903
3216
|
const dragProp = axis === "both" ? true : axis;
|
|
2904
|
-
return /* @__PURE__ */ (0,
|
|
2905
|
-
|
|
3217
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3218
|
+
import_react12.motion.div,
|
|
2906
3219
|
{
|
|
2907
3220
|
drag: dragProp,
|
|
2908
3221
|
dragMomentum: false,
|
|
@@ -2913,7 +3226,7 @@ var DraggableNode = ({ node }) => {
|
|
|
2913
3226
|
"aui-ui-draggable inline-block cursor-grab touch-none",
|
|
2914
3227
|
node.className
|
|
2915
3228
|
),
|
|
2916
|
-
children: /* @__PURE__ */ (0,
|
|
3229
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(UiNodeView, { node: node.child })
|
|
2917
3230
|
}
|
|
2918
3231
|
);
|
|
2919
3232
|
};
|
|
@@ -2923,8 +3236,8 @@ var CustomNode = ({ node }) => {
|
|
|
2923
3236
|
const Renderer = registry[node.name];
|
|
2924
3237
|
if (!Renderer) return null;
|
|
2925
3238
|
const resolvedProps = resolveProps(node.props ?? {}, state);
|
|
2926
|
-
const children = node.children?.map((child, i) => /* @__PURE__ */ (0,
|
|
2927
|
-
return /* @__PURE__ */ (0,
|
|
3239
|
+
const children = node.children?.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(UiNodeView, { node: child }, child.id ?? i));
|
|
3240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Renderer, { props: resolvedProps, children });
|
|
2928
3241
|
};
|
|
2929
3242
|
function resolveProps(props, state) {
|
|
2930
3243
|
const out = {};
|
|
@@ -2935,17 +3248,17 @@ function resolveProps(props, state) {
|
|
|
2935
3248
|
}
|
|
2936
3249
|
|
|
2937
3250
|
// src/artifacts/ui/ui-artifact.tsx
|
|
2938
|
-
var
|
|
3251
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2939
3252
|
var UiArtifactView = ({ artifact }) => {
|
|
2940
|
-
const [state, dispatch] = (0,
|
|
3253
|
+
const [state, dispatch] = (0, import_react14.useReducer)(
|
|
2941
3254
|
uiStateReducer,
|
|
2942
3255
|
artifact.initialState ?? {}
|
|
2943
3256
|
);
|
|
2944
|
-
return /* @__PURE__ */ (0,
|
|
3257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ArtifactCard, { title: artifact.title, kind: "ui", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(UiStateProvider, { state, dispatch, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "aui-ui-root p-3", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(UiNodeView, { node: artifact.root }) }) }) });
|
|
2945
3258
|
};
|
|
2946
3259
|
|
|
2947
3260
|
// src/artifacts/registry.tsx
|
|
2948
|
-
var
|
|
3261
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2949
3262
|
var defaultArtifactRenderers = {
|
|
2950
3263
|
chart: ChartArtifactView,
|
|
2951
3264
|
question: QuestionArtifactView,
|
|
@@ -2954,25 +3267,25 @@ var defaultArtifactRenderers = {
|
|
|
2954
3267
|
table: TableArtifactView,
|
|
2955
3268
|
ui: UiArtifactView
|
|
2956
3269
|
};
|
|
2957
|
-
var ArtifactRegistryContext = (0,
|
|
3270
|
+
var ArtifactRegistryContext = (0, import_react15.createContext)(
|
|
2958
3271
|
defaultArtifactRenderers
|
|
2959
3272
|
);
|
|
2960
3273
|
var ArtifactRegistryProvider = ({ renderers, override, children }) => {
|
|
2961
|
-
const merged = (0,
|
|
3274
|
+
const merged = (0, import_react15.useMemo)(() => {
|
|
2962
3275
|
if (!renderers) return defaultArtifactRenderers;
|
|
2963
3276
|
if (override) return renderers;
|
|
2964
3277
|
return { ...defaultArtifactRenderers, ...renderers };
|
|
2965
3278
|
}, [renderers, override]);
|
|
2966
|
-
return /* @__PURE__ */ (0,
|
|
3279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ArtifactRegistryContext.Provider, { value: merged, children });
|
|
2967
3280
|
};
|
|
2968
3281
|
function useArtifactRegistry() {
|
|
2969
|
-
return (0,
|
|
3282
|
+
return (0, import_react15.useContext)(ArtifactRegistryContext);
|
|
2970
3283
|
}
|
|
2971
3284
|
var ArtifactView = ({ artifact }) => {
|
|
2972
3285
|
const registry = useArtifactRegistry();
|
|
2973
3286
|
const Renderer = registry[artifact.type] ?? registry.json;
|
|
2974
3287
|
if (!Renderer) return null;
|
|
2975
|
-
return /* @__PURE__ */ (0,
|
|
3288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Renderer, { artifact });
|
|
2976
3289
|
};
|
|
2977
3290
|
|
|
2978
3291
|
// src/artifacts/parse.ts
|
|
@@ -3048,7 +3361,7 @@ var import_c = __toESM(require("shiki/langs/c.mjs"), 1);
|
|
|
3048
3361
|
var import_cpp = __toESM(require("shiki/langs/cpp.mjs"), 1);
|
|
3049
3362
|
var import_vitesse_dark = __toESM(require("shiki/themes/vitesse-dark.mjs"), 1);
|
|
3050
3363
|
var import_vitesse_light = __toESM(require("shiki/themes/vitesse-light.mjs"), 1);
|
|
3051
|
-
var
|
|
3364
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3052
3365
|
var SHIKI_THEME_DARK = "vitesse-dark";
|
|
3053
3366
|
var SHIKI_THEME_LIGHT = "vitesse-light";
|
|
3054
3367
|
var highlighterPromise = null;
|
|
@@ -3086,8 +3399,8 @@ var ShikiSyntaxHighlighter = ({
|
|
|
3086
3399
|
language,
|
|
3087
3400
|
code
|
|
3088
3401
|
}) => {
|
|
3089
|
-
const [html, setHtml] = (0,
|
|
3090
|
-
(0,
|
|
3402
|
+
const [html, setHtml] = (0, import_react16.useState)(null);
|
|
3403
|
+
(0, import_react16.useEffect)(() => {
|
|
3091
3404
|
let cancelled = false;
|
|
3092
3405
|
(async () => {
|
|
3093
3406
|
try {
|
|
@@ -3117,13 +3430,13 @@ var ShikiSyntaxHighlighter = ({
|
|
|
3117
3430
|
try {
|
|
3118
3431
|
const parsed = JSON.parse(code);
|
|
3119
3432
|
if (isArtifact(parsed)) {
|
|
3120
|
-
return /* @__PURE__ */ (0,
|
|
3433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ArtifactView, { artifact: parsed });
|
|
3121
3434
|
}
|
|
3122
3435
|
} catch {
|
|
3123
3436
|
}
|
|
3124
3437
|
}
|
|
3125
3438
|
if (html) {
|
|
3126
|
-
return /* @__PURE__ */ (0,
|
|
3439
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3127
3440
|
"div",
|
|
3128
3441
|
{
|
|
3129
3442
|
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 +3444,14 @@ var ShikiSyntaxHighlighter = ({
|
|
|
3131
3444
|
}
|
|
3132
3445
|
);
|
|
3133
3446
|
}
|
|
3134
|
-
return /* @__PURE__ */ (0,
|
|
3447
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Pre, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Code2, { children: code }) });
|
|
3135
3448
|
};
|
|
3136
3449
|
var syntax_highlighter_default = ShikiSyntaxHighlighter;
|
|
3137
3450
|
|
|
3138
3451
|
// src/chat/markdown-text.tsx
|
|
3139
|
-
var
|
|
3452
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3140
3453
|
var MarkdownTextImpl = () => {
|
|
3141
|
-
return /* @__PURE__ */ (0,
|
|
3454
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3142
3455
|
import_react_markdown.MarkdownTextPrimitive,
|
|
3143
3456
|
{
|
|
3144
3457
|
remarkPlugins: [import_remark_gfm.default, import_remark_math.default],
|
|
@@ -3151,7 +3464,7 @@ var MarkdownTextImpl = () => {
|
|
|
3151
3464
|
}
|
|
3152
3465
|
);
|
|
3153
3466
|
};
|
|
3154
|
-
var MarkdownText = (0,
|
|
3467
|
+
var MarkdownText = (0, import_react17.memo)(MarkdownTextImpl);
|
|
3155
3468
|
var CodeHeader = ({ language, code }) => {
|
|
3156
3469
|
const { isCopied, copyToClipboard } = useCopyToClipboard();
|
|
3157
3470
|
if (isArtifactFenceLanguage(language)) return null;
|
|
@@ -3159,20 +3472,20 @@ var CodeHeader = ({ language, code }) => {
|
|
|
3159
3472
|
if (!code || isCopied) return;
|
|
3160
3473
|
copyToClipboard(code);
|
|
3161
3474
|
};
|
|
3162
|
-
return /* @__PURE__ */ (0,
|
|
3163
|
-
/* @__PURE__ */ (0,
|
|
3164
|
-
/* @__PURE__ */ (0,
|
|
3475
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.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: [
|
|
3476
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { className: "flex items-center gap-2 text-xs font-semibold tracking-wide text-muted-foreground/80 uppercase", children: [
|
|
3477
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/40" }),
|
|
3165
3478
|
language
|
|
3166
3479
|
] }),
|
|
3167
|
-
/* @__PURE__ */ (0,
|
|
3480
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3168
3481
|
TooltipIconButton,
|
|
3169
3482
|
{
|
|
3170
3483
|
tooltip: isCopied ? "Copied!" : "Copy",
|
|
3171
3484
|
onClick: onCopy,
|
|
3172
3485
|
className: "transition-colors hover:text-foreground",
|
|
3173
3486
|
children: [
|
|
3174
|
-
!isCopied && /* @__PURE__ */ (0,
|
|
3175
|
-
isCopied && /* @__PURE__ */ (0,
|
|
3487
|
+
!isCopied && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react4.CopyIcon, { className: "h-3.5 w-3.5" }),
|
|
3488
|
+
isCopied && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react4.CheckIcon, { className: "h-3.5 w-3.5 text-emerald-500" })
|
|
3176
3489
|
]
|
|
3177
3490
|
}
|
|
3178
3491
|
)
|
|
@@ -3181,7 +3494,7 @@ var CodeHeader = ({ language, code }) => {
|
|
|
3181
3494
|
var useCopyToClipboard = ({
|
|
3182
3495
|
copiedDuration = 3e3
|
|
3183
3496
|
} = {}) => {
|
|
3184
|
-
const [isCopied, setIsCopied] = (0,
|
|
3497
|
+
const [isCopied, setIsCopied] = (0, import_react17.useState)(false);
|
|
3185
3498
|
const copyToClipboard = (value) => {
|
|
3186
3499
|
if (!value) return;
|
|
3187
3500
|
navigator.clipboard.writeText(value).then(() => {
|
|
@@ -3192,7 +3505,7 @@ var useCopyToClipboard = ({
|
|
|
3192
3505
|
return { isCopied, copyToClipboard };
|
|
3193
3506
|
};
|
|
3194
3507
|
var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownComponents)({
|
|
3195
|
-
h1: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3508
|
+
h1: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3196
3509
|
"h1",
|
|
3197
3510
|
{
|
|
3198
3511
|
className: cn(
|
|
@@ -3202,7 +3515,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3202
3515
|
...props
|
|
3203
3516
|
}
|
|
3204
3517
|
),
|
|
3205
|
-
h2: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3518
|
+
h2: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3206
3519
|
"h2",
|
|
3207
3520
|
{
|
|
3208
3521
|
className: cn(
|
|
@@ -3212,7 +3525,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3212
3525
|
...props
|
|
3213
3526
|
}
|
|
3214
3527
|
),
|
|
3215
|
-
h3: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3528
|
+
h3: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3216
3529
|
"h3",
|
|
3217
3530
|
{
|
|
3218
3531
|
className: cn(
|
|
@@ -3222,7 +3535,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3222
3535
|
...props
|
|
3223
3536
|
}
|
|
3224
3537
|
),
|
|
3225
|
-
h4: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3538
|
+
h4: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3226
3539
|
"h4",
|
|
3227
3540
|
{
|
|
3228
3541
|
className: cn(
|
|
@@ -3232,7 +3545,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3232
3545
|
...props
|
|
3233
3546
|
}
|
|
3234
3547
|
),
|
|
3235
|
-
h5: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3548
|
+
h5: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3236
3549
|
"h5",
|
|
3237
3550
|
{
|
|
3238
3551
|
className: cn(
|
|
@@ -3242,7 +3555,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3242
3555
|
...props
|
|
3243
3556
|
}
|
|
3244
3557
|
),
|
|
3245
|
-
h6: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3558
|
+
h6: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3246
3559
|
"h6",
|
|
3247
3560
|
{
|
|
3248
3561
|
className: cn(
|
|
@@ -3252,7 +3565,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3252
3565
|
...props
|
|
3253
3566
|
}
|
|
3254
3567
|
),
|
|
3255
|
-
p: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3568
|
+
p: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3256
3569
|
"p",
|
|
3257
3570
|
{
|
|
3258
3571
|
className: cn(
|
|
@@ -3262,7 +3575,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3262
3575
|
...props
|
|
3263
3576
|
}
|
|
3264
3577
|
),
|
|
3265
|
-
a: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3578
|
+
a: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3266
3579
|
"a",
|
|
3267
3580
|
{
|
|
3268
3581
|
className: cn(
|
|
@@ -3274,7 +3587,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3274
3587
|
...props
|
|
3275
3588
|
}
|
|
3276
3589
|
),
|
|
3277
|
-
blockquote: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3590
|
+
blockquote: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3278
3591
|
"blockquote",
|
|
3279
3592
|
{
|
|
3280
3593
|
className: cn(
|
|
@@ -3284,7 +3597,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3284
3597
|
...props
|
|
3285
3598
|
}
|
|
3286
3599
|
),
|
|
3287
|
-
ul: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3600
|
+
ul: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3288
3601
|
"ul",
|
|
3289
3602
|
{
|
|
3290
3603
|
className: cn(
|
|
@@ -3294,7 +3607,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3294
3607
|
...props
|
|
3295
3608
|
}
|
|
3296
3609
|
),
|
|
3297
|
-
ol: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3610
|
+
ol: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3298
3611
|
"ol",
|
|
3299
3612
|
{
|
|
3300
3613
|
className: cn(
|
|
@@ -3304,7 +3617,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3304
3617
|
...props
|
|
3305
3618
|
}
|
|
3306
3619
|
),
|
|
3307
|
-
hr: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3620
|
+
hr: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3308
3621
|
"hr",
|
|
3309
3622
|
{
|
|
3310
3623
|
className: cn(
|
|
@@ -3314,14 +3627,14 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3314
3627
|
...props
|
|
3315
3628
|
}
|
|
3316
3629
|
),
|
|
3317
|
-
table: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3630
|
+
table: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "my-4 w-full overflow-x-auto rounded-lg border border-border/50", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3318
3631
|
"table",
|
|
3319
3632
|
{
|
|
3320
3633
|
className: cn("aui-md-table w-full border-collapse text-sm", className),
|
|
3321
3634
|
...props
|
|
3322
3635
|
}
|
|
3323
3636
|
) }),
|
|
3324
|
-
th: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3637
|
+
th: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3325
3638
|
"th",
|
|
3326
3639
|
{
|
|
3327
3640
|
className: cn(
|
|
@@ -3331,7 +3644,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3331
3644
|
...props
|
|
3332
3645
|
}
|
|
3333
3646
|
),
|
|
3334
|
-
td: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3647
|
+
td: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3335
3648
|
"td",
|
|
3336
3649
|
{
|
|
3337
3650
|
className: cn(
|
|
@@ -3341,7 +3654,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3341
3654
|
...props
|
|
3342
3655
|
}
|
|
3343
3656
|
),
|
|
3344
|
-
tr: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3657
|
+
tr: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3345
3658
|
"tr",
|
|
3346
3659
|
{
|
|
3347
3660
|
className: cn(
|
|
@@ -3351,8 +3664,8 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3351
3664
|
...props
|
|
3352
3665
|
}
|
|
3353
3666
|
),
|
|
3354
|
-
li: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3355
|
-
sup: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3667
|
+
li: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("li", { className: cn("aui-md-li leading-[1.7]", className), ...props }),
|
|
3668
|
+
sup: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3356
3669
|
"sup",
|
|
3357
3670
|
{
|
|
3358
3671
|
className: cn(
|
|
@@ -3362,7 +3675,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3362
3675
|
...props
|
|
3363
3676
|
}
|
|
3364
3677
|
),
|
|
3365
|
-
pre: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3678
|
+
pre: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3366
3679
|
"pre",
|
|
3367
3680
|
{
|
|
3368
3681
|
className: cn(
|
|
@@ -3374,7 +3687,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3374
3687
|
),
|
|
3375
3688
|
code: function Code({ className, ...props }) {
|
|
3376
3689
|
const isCodeBlock = (0, import_react_markdown.useIsMarkdownCodeBlock)();
|
|
3377
|
-
return /* @__PURE__ */ (0,
|
|
3690
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3378
3691
|
"code",
|
|
3379
3692
|
{
|
|
3380
3693
|
className: cn(
|
|
@@ -3385,20 +3698,20 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3385
3698
|
}
|
|
3386
3699
|
);
|
|
3387
3700
|
},
|
|
3388
|
-
strong: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3389
|
-
em: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3701
|
+
strong: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("strong", { className: cn("font-semibold text-foreground", className), ...props }),
|
|
3702
|
+
em: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("em", { className: cn("italic", className), ...props }),
|
|
3390
3703
|
CodeHeader
|
|
3391
3704
|
});
|
|
3392
3705
|
|
|
3393
3706
|
// src/chat/tool-fallback.tsx
|
|
3394
|
-
var
|
|
3707
|
+
var import_react21 = require("react");
|
|
3395
3708
|
var import_lucide_react5 = require("lucide-react");
|
|
3396
|
-
var
|
|
3709
|
+
var import_react22 = require("@assistant-ui/react");
|
|
3397
3710
|
|
|
3398
3711
|
// src/ui/shimmer.tsx
|
|
3399
|
-
var
|
|
3400
|
-
var
|
|
3401
|
-
var
|
|
3712
|
+
var import_react18 = require("motion/react");
|
|
3713
|
+
var import_react19 = require("react");
|
|
3714
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3402
3715
|
var ShimmerComponent = ({
|
|
3403
3716
|
children,
|
|
3404
3717
|
as: Component = "p",
|
|
@@ -3406,14 +3719,14 @@ var ShimmerComponent = ({
|
|
|
3406
3719
|
duration = 2,
|
|
3407
3720
|
spread = 2
|
|
3408
3721
|
}) => {
|
|
3409
|
-
const MotionComponent =
|
|
3722
|
+
const MotionComponent = import_react18.motion.create(
|
|
3410
3723
|
Component
|
|
3411
3724
|
);
|
|
3412
|
-
const dynamicSpread = (0,
|
|
3725
|
+
const dynamicSpread = (0, import_react19.useMemo)(
|
|
3413
3726
|
() => (children?.length ?? 0) * spread,
|
|
3414
3727
|
[children, spread]
|
|
3415
3728
|
);
|
|
3416
|
-
return /* @__PURE__ */ (0,
|
|
3729
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3417
3730
|
MotionComponent,
|
|
3418
3731
|
{
|
|
3419
3732
|
animate: { backgroundPosition: "0% center" },
|
|
@@ -3436,11 +3749,11 @@ var ShimmerComponent = ({
|
|
|
3436
3749
|
}
|
|
3437
3750
|
);
|
|
3438
3751
|
};
|
|
3439
|
-
var Shimmer = (0,
|
|
3752
|
+
var Shimmer = (0, import_react19.memo)(ShimmerComponent);
|
|
3440
3753
|
|
|
3441
3754
|
// src/chat/motion.tsx
|
|
3442
|
-
var
|
|
3443
|
-
var
|
|
3755
|
+
var import_react20 = require("motion/react");
|
|
3756
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3444
3757
|
var luxuryEase = [0.16, 1, 0.3, 1];
|
|
3445
3758
|
var TOOL_ENTER_MS = 0.78;
|
|
3446
3759
|
var TOOL_EXIT_MS = 0.28;
|
|
@@ -3466,10 +3779,10 @@ function toolMotionState(reduced, entering, variant) {
|
|
|
3466
3779
|
return entering ? { opacity: 0, y: 14, filter: "blur(10px)" } : { opacity: 1, y: 0, filter: "blur(0px)" };
|
|
3467
3780
|
}
|
|
3468
3781
|
function ToolMotion({ children, className, motionKey }) {
|
|
3469
|
-
const reduced = (0,
|
|
3782
|
+
const reduced = (0, import_react20.useReducedMotion)() ?? false;
|
|
3470
3783
|
const { enter, exit } = toolPresenceTransition(reduced);
|
|
3471
|
-
return /* @__PURE__ */ (0,
|
|
3472
|
-
|
|
3784
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3785
|
+
import_react20.motion.div,
|
|
3473
3786
|
{
|
|
3474
3787
|
className: cn("aui-tool-motion w-full min-w-0", className),
|
|
3475
3788
|
initial: toolMotionState(reduced, true, "settled"),
|
|
@@ -3488,11 +3801,11 @@ function ToolPresence({
|
|
|
3488
3801
|
className,
|
|
3489
3802
|
variant = "settled"
|
|
3490
3803
|
}) {
|
|
3491
|
-
const reduced = (0,
|
|
3804
|
+
const reduced = (0, import_react20.useReducedMotion)() ?? false;
|
|
3492
3805
|
const { enter, exit } = toolPresenceTransition(reduced);
|
|
3493
3806
|
const enterTransition = variant === "executing" ? { duration: reduced ? 0.3 : 0.52, ease: luxuryEase } : enter;
|
|
3494
|
-
return /* @__PURE__ */ (0,
|
|
3495
|
-
|
|
3807
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_react20.AnimatePresence, { mode: "wait", initial: true, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3808
|
+
import_react20.motion.div,
|
|
3496
3809
|
{
|
|
3497
3810
|
className: cn("aui-tool-presence w-full min-w-0", className),
|
|
3498
3811
|
initial: toolMotionState(reduced, true, variant),
|
|
@@ -3512,8 +3825,8 @@ function ToolBodyPresence({
|
|
|
3512
3825
|
children,
|
|
3513
3826
|
className
|
|
3514
3827
|
}) {
|
|
3515
|
-
const reduced = (0,
|
|
3516
|
-
return /* @__PURE__ */ (0,
|
|
3828
|
+
const reduced = (0, import_react20.useReducedMotion)() ?? false;
|
|
3829
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3517
3830
|
"div",
|
|
3518
3831
|
{
|
|
3519
3832
|
className: cn(
|
|
@@ -3521,7 +3834,7 @@ function ToolBodyPresence({
|
|
|
3521
3834
|
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
3835
|
),
|
|
3523
3836
|
style: { gridTemplateRows: open ? "1fr" : "0fr" },
|
|
3524
|
-
children: /* @__PURE__ */ (0,
|
|
3837
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3525
3838
|
"div",
|
|
3526
3839
|
{
|
|
3527
3840
|
className: cn(
|
|
@@ -3537,7 +3850,7 @@ function ToolBodyPresence({
|
|
|
3537
3850
|
}
|
|
3538
3851
|
|
|
3539
3852
|
// src/chat/tool-fallback.tsx
|
|
3540
|
-
var
|
|
3853
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3541
3854
|
function detectRunning({
|
|
3542
3855
|
status,
|
|
3543
3856
|
result,
|
|
@@ -3551,7 +3864,7 @@ function detectRunning({
|
|
|
3551
3864
|
}
|
|
3552
3865
|
function useToolRunning(props) {
|
|
3553
3866
|
const { isRunning: streamRunning } = useTimbalRuntime();
|
|
3554
|
-
const partStatus = (0,
|
|
3867
|
+
const partStatus = (0, import_react22.useAuiState)((s) => s.part.status);
|
|
3555
3868
|
return detectRunning({
|
|
3556
3869
|
status: partStatus ?? props.status,
|
|
3557
3870
|
result: props.result,
|
|
@@ -3569,8 +3882,8 @@ function formatToolResult(result) {
|
|
|
3569
3882
|
return String(result);
|
|
3570
3883
|
}
|
|
3571
3884
|
}
|
|
3572
|
-
var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__ */ (0,
|
|
3573
|
-
action ? shimmer ? /* @__PURE__ */ (0,
|
|
3885
|
+
var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { className: "inline-flex min-w-0 max-w-full items-baseline gap-1", children: [
|
|
3886
|
+
action ? shimmer ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3574
3887
|
Shimmer,
|
|
3575
3888
|
{
|
|
3576
3889
|
as: "span",
|
|
@@ -3579,10 +3892,10 @@ var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__
|
|
|
3579
3892
|
spread: 2.5,
|
|
3580
3893
|
children: action
|
|
3581
3894
|
}
|
|
3582
|
-
) : /* @__PURE__ */ (0,
|
|
3583
|
-
detail ? /* @__PURE__ */ (0,
|
|
3895
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: studioTimelineActionClass, children: action }) : null,
|
|
3896
|
+
detail ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: studioTimelineDetailClass, children: detail }) : null
|
|
3584
3897
|
] });
|
|
3585
|
-
var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0,
|
|
3898
|
+
var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3586
3899
|
import_lucide_react5.ChevronRightIcon,
|
|
3587
3900
|
{
|
|
3588
3901
|
className: studioTimelineChevronClass(expanded),
|
|
@@ -3590,9 +3903,9 @@ var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0, import_jsx_runt
|
|
|
3590
3903
|
}
|
|
3591
3904
|
);
|
|
3592
3905
|
var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
3593
|
-
const [open, setOpen] = (0,
|
|
3906
|
+
const [open, setOpen] = (0, import_react21.useState)(false);
|
|
3594
3907
|
const detail = formatToolLabel(toolName);
|
|
3595
|
-
const formattedArgs = (0,
|
|
3908
|
+
const formattedArgs = (0, import_react21.useMemo)(() => {
|
|
3596
3909
|
if (!argsText || argsText === "{}") return null;
|
|
3597
3910
|
try {
|
|
3598
3911
|
return JSON.stringify(JSON.parse(argsText), null, 2);
|
|
@@ -3600,17 +3913,17 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3600
3913
|
return argsText;
|
|
3601
3914
|
}
|
|
3602
3915
|
}, [argsText]);
|
|
3603
|
-
const formattedResult = (0,
|
|
3916
|
+
const formattedResult = (0, import_react21.useMemo)(() => {
|
|
3604
3917
|
if (result === void 0 || result === null) return null;
|
|
3605
3918
|
return formatToolResult(result);
|
|
3606
3919
|
}, [result]);
|
|
3607
3920
|
const hasBody = Boolean(formattedArgs || formattedResult);
|
|
3608
3921
|
const action = isError ? "Failed" : "Used";
|
|
3609
3922
|
if (!hasBody) {
|
|
3610
|
-
return /* @__PURE__ */ (0,
|
|
3923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "aui-tool-row w-full min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TimelineActionLabel, { action, detail }) });
|
|
3611
3924
|
}
|
|
3612
|
-
return /* @__PURE__ */ (0,
|
|
3613
|
-
/* @__PURE__ */ (0,
|
|
3925
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "aui-tool-row w-full min-w-0", children: [
|
|
3926
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3614
3927
|
"button",
|
|
3615
3928
|
{
|
|
3616
3929
|
type: "button",
|
|
@@ -3618,7 +3931,7 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3618
3931
|
"aria-expanded": open,
|
|
3619
3932
|
"aria-label": `${action} ${detail}`,
|
|
3620
3933
|
className: studioTimelineRowButtonClass,
|
|
3621
|
-
children: /* @__PURE__ */ (0,
|
|
3934
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3622
3935
|
"span",
|
|
3623
3936
|
{
|
|
3624
3937
|
className: cn(
|
|
@@ -3627,37 +3940,37 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3627
3940
|
"text-foreground"
|
|
3628
3941
|
),
|
|
3629
3942
|
children: [
|
|
3630
|
-
/* @__PURE__ */ (0,
|
|
3631
|
-
/* @__PURE__ */ (0,
|
|
3943
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TimelineActionLabel, { action, detail }),
|
|
3944
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TimelineHoverChevron, { expanded: open })
|
|
3632
3945
|
]
|
|
3633
3946
|
}
|
|
3634
3947
|
)
|
|
3635
3948
|
}
|
|
3636
3949
|
),
|
|
3637
|
-
/* @__PURE__ */ (0,
|
|
3950
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3638
3951
|
ToolBodyPresence,
|
|
3639
3952
|
{
|
|
3640
3953
|
open,
|
|
3641
3954
|
className: cn(studioTimelineBodyPadClass, "gap-2"),
|
|
3642
3955
|
children: [
|
|
3643
|
-
formattedArgs ? /* @__PURE__ */ (0,
|
|
3956
|
+
formattedArgs ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3644
3957
|
"div",
|
|
3645
3958
|
{
|
|
3646
3959
|
className: cn(
|
|
3647
3960
|
studioComposerIoWellClass,
|
|
3648
3961
|
"max-h-48 overflow-auto px-2.5 py-2"
|
|
3649
3962
|
),
|
|
3650
|
-
children: /* @__PURE__ */ (0,
|
|
3963
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("pre", { className: "whitespace-pre-wrap break-words font-mono text-[11px] font-normal leading-relaxed text-foreground", children: formattedArgs })
|
|
3651
3964
|
}
|
|
3652
3965
|
) : null,
|
|
3653
|
-
formattedResult ? /* @__PURE__ */ (0,
|
|
3966
|
+
formattedResult ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3654
3967
|
"div",
|
|
3655
3968
|
{
|
|
3656
3969
|
className: cn(
|
|
3657
3970
|
studioComposerIoWellClass,
|
|
3658
3971
|
"max-h-48 overflow-auto px-2.5 py-2"
|
|
3659
3972
|
),
|
|
3660
|
-
children: /* @__PURE__ */ (0,
|
|
3973
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("pre", { className: "whitespace-pre-wrap break-words font-mono text-[11px] font-normal leading-relaxed text-foreground", children: formattedResult })
|
|
3661
3974
|
}
|
|
3662
3975
|
) : null
|
|
3663
3976
|
]
|
|
@@ -3674,20 +3987,20 @@ var ToolFallbackImpl = ({
|
|
|
3674
3987
|
const isRunning = useToolRunning({ status, result });
|
|
3675
3988
|
const isError = status?.type === "incomplete" && status.reason !== "cancelled";
|
|
3676
3989
|
const presenceKey = isRunning ? "running" : isError ? "error" : "complete";
|
|
3677
|
-
return /* @__PURE__ */ (0,
|
|
3990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3678
3991
|
ToolPresence,
|
|
3679
3992
|
{
|
|
3680
3993
|
presenceKey,
|
|
3681
3994
|
variant: isRunning ? "executing" : "settled",
|
|
3682
3995
|
className: "py-0.5",
|
|
3683
|
-
children: isRunning ? /* @__PURE__ */ (0,
|
|
3996
|
+
children: isRunning ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "aui-tool-running", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3684
3997
|
TimelineActionLabel,
|
|
3685
3998
|
{
|
|
3686
3999
|
action: "Using",
|
|
3687
4000
|
detail: formatToolLabel(toolName),
|
|
3688
4001
|
shimmer: true
|
|
3689
4002
|
}
|
|
3690
|
-
) }) : /* @__PURE__ */ (0,
|
|
4003
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3691
4004
|
ToolPanel,
|
|
3692
4005
|
{
|
|
3693
4006
|
toolName,
|
|
@@ -3699,13 +4012,13 @@ var ToolFallbackImpl = ({
|
|
|
3699
4012
|
}
|
|
3700
4013
|
);
|
|
3701
4014
|
};
|
|
3702
|
-
var ToolFallback = (0,
|
|
4015
|
+
var ToolFallback = (0, import_react21.memo)(
|
|
3703
4016
|
ToolFallbackImpl
|
|
3704
4017
|
);
|
|
3705
4018
|
ToolFallback.displayName = "ToolFallback";
|
|
3706
4019
|
|
|
3707
4020
|
// src/artifacts/tool-artifact.tsx
|
|
3708
|
-
var
|
|
4021
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3709
4022
|
var ToolArtifactFallback = (props) => {
|
|
3710
4023
|
const registry = useArtifactRegistry();
|
|
3711
4024
|
const isRunning = useToolRunning({
|
|
@@ -3717,24 +4030,24 @@ var ToolArtifactFallback = (props) => {
|
|
|
3717
4030
|
if (artifact) {
|
|
3718
4031
|
const Renderer = registry[artifact.type];
|
|
3719
4032
|
if (Renderer) {
|
|
3720
|
-
return /* @__PURE__ */ (0,
|
|
4033
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3721
4034
|
ToolMotion,
|
|
3722
4035
|
{
|
|
3723
4036
|
motionKey: `artifact-${artifact.type}`,
|
|
3724
4037
|
className: "aui-tool-artifact",
|
|
3725
|
-
children: /* @__PURE__ */ (0,
|
|
4038
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Renderer, { artifact })
|
|
3726
4039
|
}
|
|
3727
4040
|
);
|
|
3728
4041
|
}
|
|
3729
4042
|
}
|
|
3730
4043
|
}
|
|
3731
|
-
return /* @__PURE__ */ (0,
|
|
4044
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ToolFallback, { ...props });
|
|
3732
4045
|
};
|
|
3733
4046
|
|
|
3734
4047
|
// src/chat/composer.tsx
|
|
3735
|
-
var
|
|
4048
|
+
var import_react23 = require("@assistant-ui/react");
|
|
3736
4049
|
var import_lucide_react6 = require("lucide-react");
|
|
3737
|
-
var
|
|
4050
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3738
4051
|
var Composer = ({
|
|
3739
4052
|
placeholder = "Send a message...",
|
|
3740
4053
|
showAttachments,
|
|
@@ -3745,10 +4058,10 @@ var Composer = ({
|
|
|
3745
4058
|
}) => {
|
|
3746
4059
|
const attachmentsEnabled = useTimbalAttachmentsEnabled();
|
|
3747
4060
|
const attachUi = showAttachments !== false && attachmentsEnabled;
|
|
3748
|
-
const shell = /* @__PURE__ */ (0,
|
|
3749
|
-
attachUi && /* @__PURE__ */ (0,
|
|
3750
|
-
/* @__PURE__ */ (0,
|
|
3751
|
-
/* @__PURE__ */ (0,
|
|
4061
|
+
const shell = /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
|
|
4062
|
+
attachUi && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ComposerAttachments, {}),
|
|
4063
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ComposerInput, { placeholder, autoFocus: !noAutoFocus }),
|
|
4064
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3752
4065
|
ComposerToolbar,
|
|
3753
4066
|
{
|
|
3754
4067
|
showAttachments: attachUi,
|
|
@@ -3757,15 +4070,15 @@ var Composer = ({
|
|
|
3757
4070
|
}
|
|
3758
4071
|
)
|
|
3759
4072
|
] });
|
|
3760
|
-
return /* @__PURE__ */ (0,
|
|
3761
|
-
|
|
4073
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4074
|
+
import_react23.ComposerPrimitive.Root,
|
|
3762
4075
|
{
|
|
3763
4076
|
className: cn(
|
|
3764
4077
|
"aui-composer-root relative flex w-full flex-col",
|
|
3765
4078
|
className
|
|
3766
4079
|
),
|
|
3767
|
-
children: attachUi ? /* @__PURE__ */ (0,
|
|
3768
|
-
|
|
4080
|
+
children: attachUi ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4081
|
+
import_react23.ComposerPrimitive.AttachmentDropzone,
|
|
3769
4082
|
{
|
|
3770
4083
|
className: cn(
|
|
3771
4084
|
studioComposeInputShellClass,
|
|
@@ -3773,7 +4086,7 @@ var Composer = ({
|
|
|
3773
4086
|
),
|
|
3774
4087
|
children: shell
|
|
3775
4088
|
}
|
|
3776
|
-
) : /* @__PURE__ */ (0,
|
|
4089
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: studioComposeInputShellClass, children: shell })
|
|
3777
4090
|
}
|
|
3778
4091
|
);
|
|
3779
4092
|
};
|
|
@@ -3781,7 +4094,7 @@ var ComposerInput = ({
|
|
|
3781
4094
|
placeholder,
|
|
3782
4095
|
autoFocus
|
|
3783
4096
|
}) => {
|
|
3784
|
-
const composer = (0,
|
|
4097
|
+
const composer = (0, import_react23.useComposerRuntime)();
|
|
3785
4098
|
const onKeyDown = (e) => {
|
|
3786
4099
|
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
|
|
3787
4100
|
e.preventDefault();
|
|
@@ -3793,8 +4106,8 @@ var ComposerInput = ({
|
|
|
3793
4106
|
el.style.height = "auto";
|
|
3794
4107
|
el.style.height = `${Math.min(el.scrollHeight, 240)}px`;
|
|
3795
4108
|
};
|
|
3796
|
-
return /* @__PURE__ */ (0,
|
|
3797
|
-
|
|
4109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4110
|
+
import_react23.ComposerPrimitive.Input,
|
|
3798
4111
|
{
|
|
3799
4112
|
placeholder,
|
|
3800
4113
|
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 +4120,17 @@ var ComposerInput = ({
|
|
|
3807
4120
|
);
|
|
3808
4121
|
};
|
|
3809
4122
|
var ComposerToolbar = ({ showAttachments, toolbar, sendTooltip }) => {
|
|
3810
|
-
return /* @__PURE__ */ (0,
|
|
3811
|
-
/* @__PURE__ */ (0,
|
|
3812
|
-
showAttachments && /* @__PURE__ */ (0,
|
|
4123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.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: [
|
|
4124
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
4125
|
+
showAttachments && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ComposerAddAttachment, {}),
|
|
3813
4126
|
toolbar
|
|
3814
4127
|
] }),
|
|
3815
|
-
/* @__PURE__ */ (0,
|
|
4128
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ComposerSendOrCancel, { sendTooltip })
|
|
3816
4129
|
] });
|
|
3817
4130
|
};
|
|
3818
4131
|
var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
3819
|
-
return /* @__PURE__ */ (0,
|
|
3820
|
-
/* @__PURE__ */ (0,
|
|
4132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
|
|
4133
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react23.AuiIf, { condition: (s) => !s.thread.isRunning, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react23.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3821
4134
|
TooltipIconButton,
|
|
3822
4135
|
{
|
|
3823
4136
|
tooltip: sendTooltip,
|
|
@@ -3825,34 +4138,34 @@ var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
|
3825
4138
|
type: "submit",
|
|
3826
4139
|
className: "aui-composer-send shrink-0 disabled:opacity-30",
|
|
3827
4140
|
"aria-label": "Send message",
|
|
3828
|
-
children: /* @__PURE__ */ (0,
|
|
4141
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react6.ArrowUpIcon, { className: "aui-composer-send-icon size-4" })
|
|
3829
4142
|
}
|
|
3830
4143
|
) }) }),
|
|
3831
|
-
/* @__PURE__ */ (0,
|
|
4144
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react23.AuiIf, { condition: (s) => s.thread.isRunning, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react23.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3832
4145
|
TooltipIconButton,
|
|
3833
4146
|
{
|
|
3834
4147
|
tooltip: "Stop generating",
|
|
3835
4148
|
variant: "primary",
|
|
3836
4149
|
className: "aui-composer-cancel shrink-0",
|
|
3837
4150
|
"aria-label": "Stop generating",
|
|
3838
|
-
children: /* @__PURE__ */ (0,
|
|
4151
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react6.SquareIcon, { className: "aui-composer-cancel-icon size-3 fill-current" })
|
|
3839
4152
|
}
|
|
3840
4153
|
) }) })
|
|
3841
4154
|
] });
|
|
3842
4155
|
};
|
|
3843
4156
|
|
|
3844
4157
|
// src/chat/suggestions.tsx
|
|
3845
|
-
var
|
|
3846
|
-
var
|
|
4158
|
+
var import_react24 = require("react");
|
|
4159
|
+
var import_react25 = require("@assistant-ui/react");
|
|
3847
4160
|
var import_lucide_react7 = require("lucide-react");
|
|
3848
|
-
var
|
|
4161
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3849
4162
|
var Suggestions = ({
|
|
3850
4163
|
suggestions,
|
|
3851
4164
|
className
|
|
3852
4165
|
}) => {
|
|
3853
4166
|
const items = useResolvedSuggestions(suggestions);
|
|
3854
4167
|
if (!items || items.length === 0) return null;
|
|
3855
|
-
return /* @__PURE__ */ (0,
|
|
4168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3856
4169
|
"div",
|
|
3857
4170
|
{
|
|
3858
4171
|
className: cn(
|
|
@@ -3861,17 +4174,17 @@ var Suggestions = ({
|
|
|
3861
4174
|
),
|
|
3862
4175
|
role: "list",
|
|
3863
4176
|
"aria-label": "Suggested prompts",
|
|
3864
|
-
children: items.map((suggestion, i) => /* @__PURE__ */ (0,
|
|
4177
|
+
children: items.map((suggestion, i) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(SuggestionRow, { suggestion }, (suggestion.prompt ?? suggestion.title) + i))
|
|
3865
4178
|
}
|
|
3866
4179
|
);
|
|
3867
4180
|
};
|
|
3868
4181
|
var SuggestionRow = ({ suggestion }) => {
|
|
3869
|
-
const runtime = (0,
|
|
4182
|
+
const runtime = (0, import_react25.useThreadRuntime)();
|
|
3870
4183
|
const onClick = () => {
|
|
3871
4184
|
const text = suggestion.prompt ?? suggestion.title;
|
|
3872
4185
|
runtime.append({ role: "user", content: [{ type: "text", text }] });
|
|
3873
4186
|
};
|
|
3874
|
-
return /* @__PURE__ */ (0,
|
|
4187
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
3875
4188
|
"button",
|
|
3876
4189
|
{
|
|
3877
4190
|
type: "button",
|
|
@@ -3879,20 +4192,20 @@ var SuggestionRow = ({ suggestion }) => {
|
|
|
3879
4192
|
onClick,
|
|
3880
4193
|
className: cn("aui-thread-suggestion", studioListRowButtonClass),
|
|
3881
4194
|
children: [
|
|
3882
|
-
/* @__PURE__ */ (0,
|
|
3883
|
-
/* @__PURE__ */ (0,
|
|
3884
|
-
/* @__PURE__ */ (0,
|
|
3885
|
-
suggestion.description && /* @__PURE__ */ (0,
|
|
4195
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "aui-thread-suggestion-icon shrink-0 text-muted-foreground", children: suggestion.icon ?? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react7.ArrowUpIcon, { className: "size-4", strokeWidth: 1.75, "aria-hidden": true }) }),
|
|
4196
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("span", { className: "aui-thread-suggestion-text min-w-0 flex-1 text-left", children: [
|
|
4197
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "aui-thread-suggestion-text-1 block truncate text-sm font-normal text-foreground", children: suggestion.title }),
|
|
4198
|
+
suggestion.description && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "aui-thread-suggestion-text-2 mt-0.5 block truncate text-xs text-muted-foreground", children: suggestion.description })
|
|
3886
4199
|
] })
|
|
3887
4200
|
]
|
|
3888
4201
|
}
|
|
3889
4202
|
);
|
|
3890
4203
|
};
|
|
3891
4204
|
function useResolvedSuggestions(source) {
|
|
3892
|
-
const [resolved, setResolved] = (0,
|
|
4205
|
+
const [resolved, setResolved] = (0, import_react24.useState)(
|
|
3893
4206
|
() => Array.isArray(source) ? source : void 0
|
|
3894
4207
|
);
|
|
3895
|
-
(0,
|
|
4208
|
+
(0, import_react24.useEffect)(() => {
|
|
3896
4209
|
if (!source) {
|
|
3897
4210
|
setResolved(void 0);
|
|
3898
4211
|
return;
|
|
@@ -3911,7 +4224,7 @@ function useResolvedSuggestions(source) {
|
|
|
3911
4224
|
cancelled = true;
|
|
3912
4225
|
};
|
|
3913
4226
|
}, [source]);
|
|
3914
|
-
return (0,
|
|
4227
|
+
return (0, import_react24.useMemo)(() => resolved, [resolved]);
|
|
3915
4228
|
}
|
|
3916
4229
|
|
|
3917
4230
|
// src/design/theme-sanity.ts
|
|
@@ -3984,15 +4297,15 @@ function scheduleThemeSanityCheck() {
|
|
|
3984
4297
|
}
|
|
3985
4298
|
|
|
3986
4299
|
// src/chat/thread-variant.tsx
|
|
3987
|
-
var
|
|
3988
|
-
var ThreadVariantContext = (0,
|
|
4300
|
+
var import_react26 = require("react");
|
|
4301
|
+
var ThreadVariantContext = (0, import_react26.createContext)("default");
|
|
3989
4302
|
var ThreadVariantProvider = ThreadVariantContext.Provider;
|
|
3990
4303
|
function useThreadVariant() {
|
|
3991
|
-
return (0,
|
|
4304
|
+
return (0, import_react26.useContext)(ThreadVariantContext);
|
|
3992
4305
|
}
|
|
3993
4306
|
|
|
3994
4307
|
// src/chat/thread.tsx
|
|
3995
|
-
var
|
|
4308
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
3996
4309
|
var Thread = ({
|
|
3997
4310
|
className,
|
|
3998
4311
|
variant = "default",
|
|
@@ -4015,17 +4328,17 @@ var Thread = ({
|
|
|
4015
4328
|
const EditComposerSlot = components?.EditComposer ?? EditComposer;
|
|
4016
4329
|
const ScrollToBottomSlot = components?.ScrollToBottom ?? ThreadScrollToBottom;
|
|
4017
4330
|
const SuggestionsSlot = components?.Suggestions ?? Suggestions;
|
|
4018
|
-
(0,
|
|
4331
|
+
(0, import_react27.useEffect)(() => {
|
|
4019
4332
|
scheduleThemeSanityCheck();
|
|
4020
4333
|
}, []);
|
|
4021
|
-
return /* @__PURE__ */ (0,
|
|
4334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ThreadVariantProvider, { value: variant, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4022
4335
|
ArtifactRegistryProvider,
|
|
4023
4336
|
{
|
|
4024
4337
|
renderers: artifacts?.renderers,
|
|
4025
4338
|
override: artifacts?.override,
|
|
4026
|
-
children: /* @__PURE__ */ (0,
|
|
4027
|
-
}), children: /* @__PURE__ */ (0,
|
|
4028
|
-
|
|
4339
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(UiEventProvider, { onEvent: onArtifactEvent ?? (() => {
|
|
4340
|
+
}), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4341
|
+
import_react28.ThreadPrimitive.Root,
|
|
4029
4342
|
{
|
|
4030
4343
|
className: cn(
|
|
4031
4344
|
"aui-root aui-thread-root @container flex h-full flex-col bg-transparent",
|
|
@@ -4034,8 +4347,8 @@ var Thread = ({
|
|
|
4034
4347
|
),
|
|
4035
4348
|
style: { ["--thread-max-width"]: maxWidth },
|
|
4036
4349
|
"data-thread-variant": variant,
|
|
4037
|
-
children: /* @__PURE__ */ (0,
|
|
4038
|
-
|
|
4350
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
4351
|
+
import_react28.ThreadPrimitive.Viewport,
|
|
4039
4352
|
{
|
|
4040
4353
|
turnAnchor: "bottom",
|
|
4041
4354
|
className: cn(
|
|
@@ -4043,7 +4356,7 @@ var Thread = ({
|
|
|
4043
4356
|
isPanel ? "px-2 pt-2" : "px-4 pt-4"
|
|
4044
4357
|
),
|
|
4045
4358
|
children: [
|
|
4046
|
-
/* @__PURE__ */ (0,
|
|
4359
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4047
4360
|
WelcomeSlot,
|
|
4048
4361
|
{
|
|
4049
4362
|
config: welcome,
|
|
@@ -4052,8 +4365,8 @@ var Thread = ({
|
|
|
4052
4365
|
Suggestions: SuggestionsSlot
|
|
4053
4366
|
}
|
|
4054
4367
|
),
|
|
4055
|
-
/* @__PURE__ */ (0,
|
|
4056
|
-
|
|
4368
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4369
|
+
import_react28.ThreadPrimitive.Messages,
|
|
4057
4370
|
{
|
|
4058
4371
|
components: {
|
|
4059
4372
|
UserMessage: UserMessageSlot,
|
|
@@ -4062,14 +4375,14 @@ var Thread = ({
|
|
|
4062
4375
|
}
|
|
4063
4376
|
}
|
|
4064
4377
|
),
|
|
4065
|
-
/* @__PURE__ */ (0,
|
|
4066
|
-
|
|
4378
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4379
|
+
import_react28.ThreadPrimitive.ViewportFooter,
|
|
4067
4380
|
{
|
|
4068
4381
|
className: cn(
|
|
4069
4382
|
"aui-thread-viewport-footer sticky bottom-0 z-10 mt-auto w-full isolate pt-2",
|
|
4070
4383
|
isPanel ? "bg-card pb-2" : "bg-background pb-4 md:pb-6"
|
|
4071
4384
|
),
|
|
4072
|
-
children: /* @__PURE__ */ (0,
|
|
4385
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
4073
4386
|
"div",
|
|
4074
4387
|
{
|
|
4075
4388
|
className: cn(
|
|
@@ -4077,8 +4390,8 @@ var Thread = ({
|
|
|
4077
4390
|
isPanel ? "gap-2" : "gap-4"
|
|
4078
4391
|
),
|
|
4079
4392
|
children: [
|
|
4080
|
-
/* @__PURE__ */ (0,
|
|
4081
|
-
/* @__PURE__ */ (0,
|
|
4393
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ScrollToBottomSlot, {}),
|
|
4394
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ComposerSlot, { placeholder })
|
|
4082
4395
|
]
|
|
4083
4396
|
}
|
|
4084
4397
|
)
|
|
@@ -4093,13 +4406,13 @@ var Thread = ({
|
|
|
4093
4406
|
) });
|
|
4094
4407
|
};
|
|
4095
4408
|
var ThreadScrollToBottom = () => {
|
|
4096
|
-
return /* @__PURE__ */ (0,
|
|
4409
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.ThreadPrimitive.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4097
4410
|
TooltipIconButton,
|
|
4098
4411
|
{
|
|
4099
4412
|
tooltip: "Scroll to bottom",
|
|
4100
4413
|
variant: "secondary",
|
|
4101
4414
|
className: "aui-thread-scroll-to-bottom absolute -top-12 z-10 self-center disabled:invisible",
|
|
4102
|
-
children: /* @__PURE__ */ (0,
|
|
4415
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react8.ArrowDownIcon, { className: "size-4" })
|
|
4103
4416
|
}
|
|
4104
4417
|
) });
|
|
4105
4418
|
};
|
|
@@ -4132,15 +4445,15 @@ var ThreadWelcome = ({
|
|
|
4132
4445
|
showWelcomeSuggestions: showWelcomeSuggestionsProp,
|
|
4133
4446
|
Suggestions: SuggestionsSlot = Suggestions
|
|
4134
4447
|
}) => {
|
|
4135
|
-
const isEmpty = (0,
|
|
4448
|
+
const isEmpty = (0, import_react28.useThread)((s) => s.messages.length === 0);
|
|
4136
4449
|
const isPanel = useThreadVariant() === "panel";
|
|
4137
4450
|
const showWelcomeSuggestions = showWelcomeSuggestionsProp ?? !isPanel;
|
|
4138
4451
|
if (!isEmpty) return null;
|
|
4139
4452
|
const defaultHeading = isPanel ? "Ask about this page" : "How can I help you today?";
|
|
4140
4453
|
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
|
-
|
|
4454
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: [
|
|
4455
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
4456
|
+
import_react29.motion.div,
|
|
4144
4457
|
{
|
|
4145
4458
|
className: cn(
|
|
4146
4459
|
"aui-thread-welcome-message flex flex-col items-center justify-center text-center",
|
|
@@ -4150,9 +4463,9 @@ var ThreadWelcome = ({
|
|
|
4150
4463
|
initial: "initial",
|
|
4151
4464
|
animate: "animate",
|
|
4152
4465
|
children: [
|
|
4153
|
-
config?.icon && /* @__PURE__ */ (0,
|
|
4154
|
-
/* @__PURE__ */ (0,
|
|
4155
|
-
|
|
4466
|
+
config?.icon && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react29.motion.div, { variants: welcomeIcon, className: isPanel ? "mb-3" : "mb-5", children: config.icon }),
|
|
4467
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4468
|
+
import_react29.motion.h1,
|
|
4156
4469
|
{
|
|
4157
4470
|
variants: welcomeItem,
|
|
4158
4471
|
className: cn(
|
|
@@ -4162,8 +4475,8 @@ var ThreadWelcome = ({
|
|
|
4162
4475
|
children: config?.heading ?? defaultHeading
|
|
4163
4476
|
}
|
|
4164
4477
|
),
|
|
4165
|
-
/* @__PURE__ */ (0,
|
|
4166
|
-
|
|
4478
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4479
|
+
import_react29.motion.p,
|
|
4167
4480
|
{
|
|
4168
4481
|
variants: welcomeItem,
|
|
4169
4482
|
className: "aui-thread-welcome-message-inner mt-1.5 text-muted-foreground text-sm",
|
|
@@ -4173,16 +4486,16 @@ var ThreadWelcome = ({
|
|
|
4173
4486
|
]
|
|
4174
4487
|
}
|
|
4175
4488
|
) }),
|
|
4176
|
-
showWelcomeSuggestions && suggestions ? /* @__PURE__ */ (0,
|
|
4489
|
+
showWelcomeSuggestions && suggestions ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "aui-thread-welcome-suggestions mx-auto w-full max-w-(--thread-max-width) px-2", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(SuggestionsSlot, { suggestions }) }) : null
|
|
4177
4490
|
] });
|
|
4178
4491
|
};
|
|
4179
4492
|
var MessageError = () => {
|
|
4180
|
-
return /* @__PURE__ */ (0,
|
|
4493
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.MessagePrimitive.Error, { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.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_runtime33.jsx)(import_react28.ErrorPrimitive.Message, { className: "aui-message-error-message line-clamp-2" }) }) });
|
|
4181
4494
|
};
|
|
4182
4495
|
var AssistantMessage = () => {
|
|
4183
4496
|
const isPanel = useThreadVariant() === "panel";
|
|
4184
|
-
return /* @__PURE__ */ (0,
|
|
4185
|
-
|
|
4497
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
4498
|
+
import_react28.MessagePrimitive.Root,
|
|
4186
4499
|
{
|
|
4187
4500
|
className: cn(
|
|
4188
4501
|
"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 +4503,7 @@ var AssistantMessage = () => {
|
|
|
4190
4503
|
),
|
|
4191
4504
|
"data-role": "assistant",
|
|
4192
4505
|
children: [
|
|
4193
|
-
/* @__PURE__ */ (0,
|
|
4506
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
4194
4507
|
"div",
|
|
4195
4508
|
{
|
|
4196
4509
|
className: cn(
|
|
@@ -4198,8 +4511,8 @@ var AssistantMessage = () => {
|
|
|
4198
4511
|
isPanel ? "px-1 text-sm" : "px-2"
|
|
4199
4512
|
),
|
|
4200
4513
|
children: [
|
|
4201
|
-
/* @__PURE__ */ (0,
|
|
4202
|
-
|
|
4514
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4515
|
+
import_react28.MessagePrimitive.Parts,
|
|
4203
4516
|
{
|
|
4204
4517
|
components: {
|
|
4205
4518
|
Text: MarkdownText,
|
|
@@ -4209,11 +4522,11 @@ var AssistantMessage = () => {
|
|
|
4209
4522
|
}
|
|
4210
4523
|
}
|
|
4211
4524
|
),
|
|
4212
|
-
/* @__PURE__ */ (0,
|
|
4525
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(MessageError, {})
|
|
4213
4526
|
]
|
|
4214
4527
|
}
|
|
4215
4528
|
),
|
|
4216
|
-
/* @__PURE__ */ (0,
|
|
4529
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "aui-assistant-message-footer mt-1 mb-3 ml-1 flex", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(AssistantActionBar, {}) })
|
|
4217
4530
|
]
|
|
4218
4531
|
}
|
|
4219
4532
|
);
|
|
@@ -4226,36 +4539,36 @@ var ASSISTANT_ACTION_ICON_CLASS = cn(
|
|
|
4226
4539
|
"[&>span:first-child]:group-hover/tbv2:bg-ghost-fill-hover"
|
|
4227
4540
|
);
|
|
4228
4541
|
var AssistantActionBar = () => {
|
|
4229
|
-
return /* @__PURE__ */ (0,
|
|
4230
|
-
|
|
4542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
4543
|
+
import_react28.ActionBarPrimitive.Root,
|
|
4231
4544
|
{
|
|
4232
4545
|
hideWhenRunning: true,
|
|
4233
4546
|
autohide: "never",
|
|
4234
4547
|
className: "aui-assistant-action-bar-root flex items-center gap-0 bg-transparent px-0 py-0.5 text-muted-foreground/60",
|
|
4235
4548
|
children: [
|
|
4236
|
-
/* @__PURE__ */ (0,
|
|
4549
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.ActionBarPrimitive.Copy, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
4237
4550
|
TooltipIconButton,
|
|
4238
4551
|
{
|
|
4239
4552
|
tooltip: "Copy",
|
|
4240
4553
|
variant: "ghost",
|
|
4241
4554
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
4242
4555
|
children: [
|
|
4243
|
-
/* @__PURE__ */ (0,
|
|
4244
|
-
/* @__PURE__ */ (0,
|
|
4556
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.AuiIf, { condition: (s) => s.message.isCopied, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react8.CheckIcon, { className: "size-3" }) }),
|
|
4557
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.AuiIf, { condition: (s) => !s.message.isCopied, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react8.CopyIcon, { className: "size-3" }) })
|
|
4245
4558
|
]
|
|
4246
4559
|
}
|
|
4247
4560
|
) }),
|
|
4248
|
-
/* @__PURE__ */ (0,
|
|
4561
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.ActionBarPrimitive.Reload, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4249
4562
|
TooltipIconButton,
|
|
4250
4563
|
{
|
|
4251
4564
|
tooltip: "Regenerate",
|
|
4252
4565
|
variant: "ghost",
|
|
4253
4566
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
4254
|
-
children: /* @__PURE__ */ (0,
|
|
4567
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react8.RefreshCwIcon, { className: "size-3" })
|
|
4255
4568
|
}
|
|
4256
4569
|
) }),
|
|
4257
|
-
/* @__PURE__ */ (0,
|
|
4258
|
-
/* @__PURE__ */ (0,
|
|
4570
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_react28.ActionBarMorePrimitive.Root, { children: [
|
|
4571
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.ActionBarMorePrimitive.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4259
4572
|
TooltipIconButton,
|
|
4260
4573
|
{
|
|
4261
4574
|
tooltip: "More",
|
|
@@ -4264,17 +4577,17 @@ var AssistantActionBar = () => {
|
|
|
4264
4577
|
ASSISTANT_ACTION_ICON_CLASS,
|
|
4265
4578
|
"data-[state=open]:text-muted-foreground/80"
|
|
4266
4579
|
),
|
|
4267
|
-
children: /* @__PURE__ */ (0,
|
|
4580
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react8.MoreHorizontalIcon, { className: "size-3" })
|
|
4268
4581
|
}
|
|
4269
4582
|
) }),
|
|
4270
|
-
/* @__PURE__ */ (0,
|
|
4271
|
-
|
|
4583
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4584
|
+
import_react28.ActionBarMorePrimitive.Content,
|
|
4272
4585
|
{
|
|
4273
4586
|
side: "bottom",
|
|
4274
4587
|
align: "start",
|
|
4275
4588
|
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,
|
|
4589
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.ActionBarPrimitive.ExportMarkdown, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_react28.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: [
|
|
4590
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react8.DownloadIcon, { className: "size-4 shrink-0" }),
|
|
4278
4591
|
"Export as Markdown"
|
|
4279
4592
|
] }) })
|
|
4280
4593
|
}
|
|
@@ -4285,12 +4598,12 @@ var AssistantActionBar = () => {
|
|
|
4285
4598
|
);
|
|
4286
4599
|
};
|
|
4287
4600
|
var UserMessageText = () => {
|
|
4288
|
-
return /* @__PURE__ */ (0,
|
|
4601
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "whitespace-pre-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.MessagePartPrimitive.Text, { smooth: false }) });
|
|
4289
4602
|
};
|
|
4290
4603
|
var UserMessage = () => {
|
|
4291
4604
|
const isPanel = useThreadVariant() === "panel";
|
|
4292
|
-
return /* @__PURE__ */ (0,
|
|
4293
|
-
|
|
4605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
4606
|
+
import_react28.MessagePrimitive.Root,
|
|
4294
4607
|
{
|
|
4295
4608
|
className: cn(
|
|
4296
4609
|
"aui-user-message-root mx-auto flex w-full max-w-(--thread-max-width) flex-col items-end gap-2",
|
|
@@ -4298,9 +4611,9 @@ var UserMessage = () => {
|
|
|
4298
4611
|
),
|
|
4299
4612
|
"data-role": "user",
|
|
4300
4613
|
children: [
|
|
4301
|
-
/* @__PURE__ */ (0,
|
|
4302
|
-
/* @__PURE__ */ (0,
|
|
4303
|
-
|
|
4614
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(UserMessageAttachments, {}),
|
|
4615
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
4616
|
+
import_react29.motion.div,
|
|
4304
4617
|
{
|
|
4305
4618
|
className: cn(
|
|
4306
4619
|
"aui-user-message-content relative inline-block max-w-[85%] rounded-2xl bg-bubble-user text-bubble-user-foreground",
|
|
@@ -4310,8 +4623,8 @@ var UserMessage = () => {
|
|
|
4310
4623
|
animate: { opacity: 1, y: 0, scale: 1 },
|
|
4311
4624
|
transition: { duration: 0.65, ease: luxuryEase },
|
|
4312
4625
|
children: [
|
|
4313
|
-
/* @__PURE__ */ (0,
|
|
4314
|
-
/* @__PURE__ */ (0,
|
|
4626
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.MessagePrimitive.Parts, { components: { Text: UserMessageText } }),
|
|
4627
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.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_runtime33.jsx)(UserActionBar, {}) })
|
|
4315
4628
|
]
|
|
4316
4629
|
}
|
|
4317
4630
|
)
|
|
@@ -4320,42 +4633,42 @@ var UserMessage = () => {
|
|
|
4320
4633
|
);
|
|
4321
4634
|
};
|
|
4322
4635
|
var UserActionBar = () => {
|
|
4323
|
-
return /* @__PURE__ */ (0,
|
|
4324
|
-
|
|
4636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4637
|
+
import_react28.ActionBarPrimitive.Root,
|
|
4325
4638
|
{
|
|
4326
4639
|
hideWhenRunning: true,
|
|
4327
4640
|
autohide: "always",
|
|
4328
4641
|
className: "aui-user-action-bar-root flex flex-col items-end",
|
|
4329
|
-
children: /* @__PURE__ */ (0,
|
|
4642
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.ActionBarPrimitive.Edit, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4330
4643
|
TooltipIconButton,
|
|
4331
4644
|
{
|
|
4332
4645
|
tooltip: "Edit",
|
|
4333
4646
|
variant: "ghost",
|
|
4334
4647
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
4335
|
-
children: /* @__PURE__ */ (0,
|
|
4648
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react8.PencilIcon, { className: "size-3" })
|
|
4336
4649
|
}
|
|
4337
4650
|
) })
|
|
4338
4651
|
}
|
|
4339
4652
|
);
|
|
4340
4653
|
};
|
|
4341
4654
|
var EditComposer = () => {
|
|
4342
|
-
return /* @__PURE__ */ (0,
|
|
4343
|
-
/* @__PURE__ */ (0,
|
|
4344
|
-
|
|
4655
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.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_runtime33.jsxs)(import_react28.ComposerPrimitive.Root, { className: "aui-edit-composer-root ml-auto flex w-full max-w-[85%] flex-col rounded-2xl bg-muted", children: [
|
|
4656
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4657
|
+
import_react28.ComposerPrimitive.Input,
|
|
4345
4658
|
{
|
|
4346
4659
|
className: "aui-edit-composer-input min-h-14 w-full resize-none bg-transparent p-4 text-foreground text-sm outline-none",
|
|
4347
4660
|
autoFocus: true
|
|
4348
4661
|
}
|
|
4349
4662
|
),
|
|
4350
|
-
/* @__PURE__ */ (0,
|
|
4351
|
-
/* @__PURE__ */ (0,
|
|
4352
|
-
/* @__PURE__ */ (0,
|
|
4663
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "aui-edit-composer-footer mx-3 mb-3 flex items-center gap-2 self-end", children: [
|
|
4664
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(TimbalV2Button, { variant: "ghost", size: "sm", children: "Cancel" }) }),
|
|
4665
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react28.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(TimbalV2Button, { variant: "primary", size: "sm", children: "Update" }) })
|
|
4353
4666
|
] })
|
|
4354
4667
|
] }) });
|
|
4355
4668
|
};
|
|
4356
4669
|
|
|
4357
4670
|
// src/chat/chat.tsx
|
|
4358
|
-
var
|
|
4671
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
4359
4672
|
function TimbalChat({
|
|
4360
4673
|
workforceId,
|
|
4361
4674
|
baseUrl,
|
|
@@ -4366,7 +4679,7 @@ function TimbalChat({
|
|
|
4366
4679
|
debug,
|
|
4367
4680
|
...threadProps
|
|
4368
4681
|
}) {
|
|
4369
|
-
return /* @__PURE__ */ (0,
|
|
4682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4370
4683
|
TimbalRuntimeProvider,
|
|
4371
4684
|
{
|
|
4372
4685
|
workforceId,
|
|
@@ -4376,7 +4689,7 @@ function TimbalChat({
|
|
|
4376
4689
|
attachmentsUploadUrl,
|
|
4377
4690
|
attachmentsAccept,
|
|
4378
4691
|
debug,
|
|
4379
|
-
children: /* @__PURE__ */ (0,
|
|
4692
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Thread, { ...threadProps })
|
|
4380
4693
|
}
|
|
4381
4694
|
);
|
|
4382
4695
|
}
|
|
@@ -4405,7 +4718,7 @@ var overlayListPanelClass = cn(
|
|
|
4405
4718
|
);
|
|
4406
4719
|
|
|
4407
4720
|
// src/chat/workforce-selector.tsx
|
|
4408
|
-
var
|
|
4721
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
4409
4722
|
var WorkforceSelector = ({
|
|
4410
4723
|
workforces,
|
|
4411
4724
|
value,
|
|
@@ -4416,7 +4729,7 @@ var WorkforceSelector = ({
|
|
|
4416
4729
|
}) => {
|
|
4417
4730
|
if (workforces.length === 0) return null;
|
|
4418
4731
|
if (hideWhenSingle && workforces.length === 1) return null;
|
|
4419
|
-
return /* @__PURE__ */ (0,
|
|
4732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
4420
4733
|
"div",
|
|
4421
4734
|
{
|
|
4422
4735
|
className: cn(
|
|
@@ -4427,7 +4740,7 @@ var WorkforceSelector = ({
|
|
|
4427
4740
|
className
|
|
4428
4741
|
),
|
|
4429
4742
|
children: [
|
|
4430
|
-
/* @__PURE__ */ (0,
|
|
4743
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
4431
4744
|
"select",
|
|
4432
4745
|
{
|
|
4433
4746
|
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 +4748,15 @@ var WorkforceSelector = ({
|
|
|
4435
4748
|
onChange: (e) => onChange(e.target.value),
|
|
4436
4749
|
"aria-label": placeholder,
|
|
4437
4750
|
children: [
|
|
4438
|
-
!value && /* @__PURE__ */ (0,
|
|
4751
|
+
!value && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("option", { value: "", children: placeholder }),
|
|
4439
4752
|
workforces.map((w) => {
|
|
4440
4753
|
const id = idOf(w);
|
|
4441
|
-
return /* @__PURE__ */ (0,
|
|
4754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("option", { value: id, children: w.name ?? id }, id);
|
|
4442
4755
|
})
|
|
4443
4756
|
]
|
|
4444
4757
|
}
|
|
4445
4758
|
),
|
|
4446
|
-
/* @__PURE__ */ (0,
|
|
4759
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
4447
4760
|
import_lucide_react9.ChevronDownIcon,
|
|
4448
4761
|
{
|
|
4449
4762
|
className: "aui-workforce-selector-icon pointer-events-none absolute right-3 size-3.5 text-muted-foreground/70",
|