@cognite/aura 1.48322.0 → 1.48344.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/dist/components/ui/core/message/message-response-table-labels.d.ts +6 -0
- package/dist/components/ui/core/message/message-response-table-labels.js +4 -1
- package/dist/components/ui/core/message/message-response-table-labels.js.map +1 -1
- package/dist/components/ui/core/message/message-response-table.js +120 -32
- package/dist/components/ui/core/message/message-response-table.js.map +1 -1
- package/dist/components/ui/core/message/message.js +17 -3
- package/dist/components/ui/core/message/message.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -7,5 +7,11 @@ export type MessageResponseTableLabels = {
|
|
|
7
7
|
currentPage: string;
|
|
8
8
|
/** Status line in the pagination footer, e.g. "Showing 1–50 of 120". */
|
|
9
9
|
paginationStatus: FormatPaginationStatus;
|
|
10
|
+
/** Button and tooltip that open the expanded view. */
|
|
11
|
+
expandView: string;
|
|
12
|
+
/** Accessible name of the expanded view dialog. */
|
|
13
|
+
expandedView: string;
|
|
14
|
+
/** Button that closes the expanded view. */
|
|
15
|
+
minimize: string;
|
|
10
16
|
};
|
|
11
17
|
export declare const DEFAULT_MESSAGE_RESPONSE_TABLE_LABELS: MessageResponseTableLabels;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export const DEFAULT_MESSAGE_RESPONSE_TABLE_LABELS = {
|
|
2
2
|
currentPage: 'Current page',
|
|
3
|
-
paginationStatus: (pageStart, pageEnd, totalRows)=>`Showing ${pageStart}–${pageEnd} of ${totalRows}
|
|
3
|
+
paginationStatus: (pageStart, pageEnd, totalRows)=>`Showing ${pageStart}–${pageEnd} of ${totalRows}`,
|
|
4
|
+
expandView: 'Expand view',
|
|
5
|
+
expandedView: 'Expanded table view',
|
|
6
|
+
minimize: 'Minimize table'
|
|
4
7
|
};
|
|
5
8
|
|
|
6
9
|
//# sourceMappingURL=message-response-table-labels.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/ui/core/message/message-response-table-labels.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\n/** Formats the pagination status line for the rows on the current page (1-based, inclusive). */\nexport type FormatPaginationStatus = (\n pageStart: number,\n pageEnd: number,\n totalRows: number\n) => ReactNode;\n\n/** User-facing text in `MessageResponseTable`. Aura has no translations, so consumers pass translated labels. */\nexport type MessageResponseTableLabels = {\n /** Accessible name of the page number input that long tables show instead of page links. */\n currentPage: string;\n /** Status line in the pagination footer, e.g. \"Showing 1–50 of 120\". */\n paginationStatus: FormatPaginationStatus;\n};\n\nexport const DEFAULT_MESSAGE_RESPONSE_TABLE_LABELS: MessageResponseTableLabels =\n {\n currentPage: 'Current page',\n paginationStatus: (pageStart, pageEnd, totalRows) =>\n `Showing ${pageStart}–${pageEnd} of ${totalRows}`,\n };\n"],"names":["DEFAULT_MESSAGE_RESPONSE_TABLE_LABELS","currentPage","paginationStatus","pageStart","pageEnd","totalRows"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/message/message-response-table-labels.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\n/** Formats the pagination status line for the rows on the current page (1-based, inclusive). */\nexport type FormatPaginationStatus = (\n pageStart: number,\n pageEnd: number,\n totalRows: number\n) => ReactNode;\n\n/** User-facing text in `MessageResponseTable`. Aura has no translations, so consumers pass translated labels. */\nexport type MessageResponseTableLabels = {\n /** Accessible name of the page number input that long tables show instead of page links. */\n currentPage: string;\n /** Status line in the pagination footer, e.g. \"Showing 1–50 of 120\". */\n paginationStatus: FormatPaginationStatus;\n /** Button and tooltip that open the expanded view. */\n expandView: string;\n /** Accessible name of the expanded view dialog. */\n expandedView: string;\n /** Button that closes the expanded view. */\n minimize: string;\n};\n\nexport const DEFAULT_MESSAGE_RESPONSE_TABLE_LABELS: MessageResponseTableLabels =\n {\n currentPage: 'Current page',\n paginationStatus: (pageStart, pageEnd, totalRows) =>\n `Showing ${pageStart}–${pageEnd} of ${totalRows}`,\n expandView: 'Expand view',\n expandedView: 'Expanded table view',\n minimize: 'Minimize table',\n };\n"],"names":["DEFAULT_MESSAGE_RESPONSE_TABLE_LABELS","currentPage","paginationStatus","pageStart","pageEnd","totalRows","expandView","expandedView","minimize"],"mappings":"AAuBA,OAAO,MAAMA,wCACX;IACEC,aAAa;IACbC,kBAAkB,CAACC,WAAWC,SAASC,YACrC,CAAC,QAAQ,EAAEF,UAAU,CAAC,EAAEC,QAAQ,IAAI,EAAEC,WAAW;IACnDC,YAAY;IACZC,cAAc;IACdC,UAAU;AACZ,EAAE"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Children, isValidElement, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { IconArrowsDiagonal, IconX } from "@tabler/icons-react";
|
|
4
|
+
import { cn } from "../../../../lib/utils.js";
|
|
5
|
+
import { Button } from "../button/button.js";
|
|
3
6
|
import { Card } from "../card/card.js";
|
|
4
|
-
import { DataGrid } from "../data-grid/data-grid.js";
|
|
7
|
+
import { DataGrid, DataGridHeader, DataGridHeaderEnd } from "../data-grid/data-grid.js";
|
|
8
|
+
import { Dialog, DialogClose, DialogContent } from "../dialog/dialog.js";
|
|
9
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../tooltip/tooltip.js";
|
|
5
10
|
import { MessageTableFooter } from "./message-response-table-footer.js";
|
|
6
11
|
import { DEFAULT_MESSAGE_RESPONSE_TABLE_LABELS } from "./message-response-table-labels.js";
|
|
7
12
|
const DEFAULT_TABLE_LABEL = 'Atlas AI Chat Table';
|
|
8
13
|
export const MESSAGE_TABLE_PAGE_SIZE = 50;
|
|
14
|
+
const COMPACT_VIEWPORT_BREAKPOINT_PX = 1024;
|
|
15
|
+
const isBelowDesktopBreakpoint = ()=>typeof window !== 'undefined' && window.innerWidth < COMPACT_VIEWPORT_BREAKPOINT_PX;
|
|
9
16
|
const clamp = (value, min, max)=>Math.min(Math.max(value, min), max);
|
|
10
17
|
const getTagName = (element)=>element.props.node?.tagName ?? (typeof element.type === 'string' ? element.type : undefined);
|
|
11
18
|
const getChildren = (element)=>element.props.children;
|
|
@@ -92,7 +99,10 @@ const buildColumns = (headers)=>headers.map((header, index)=>({
|
|
|
92
99
|
const totalRows = allRows.length;
|
|
93
100
|
const totalPages = Math.max(1, Math.ceil(totalRows / MESSAGE_TABLE_PAGE_SIZE));
|
|
94
101
|
const [pageIndex, setPageIndex] = useState(0);
|
|
95
|
-
const
|
|
102
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
103
|
+
const [isCompactViewport, setIsCompactViewport] = useState(isBelowDesktopBreakpoint);
|
|
104
|
+
const inlineGridRef = useRef(null);
|
|
105
|
+
const expandedGridRef = useRef(null);
|
|
96
106
|
// Clamp the page while rows stream in or shrink.
|
|
97
107
|
const currentPageIndex = clamp(pageIndex, 0, totalPages - 1);
|
|
98
108
|
// Pages are sliced here rather than by the grid: its client pagination resets
|
|
@@ -101,13 +111,30 @@ const buildColumns = (headers)=>headers.map((header, index)=>({
|
|
|
101
111
|
const pageRows = allRows.slice(currentPageIndex * MESSAGE_TABLE_PAGE_SIZE, (currentPageIndex + 1) * MESSAGE_TABLE_PAGE_SIZE);
|
|
102
112
|
// Show the top of each new page.
|
|
103
113
|
useEffect(()=>{
|
|
104
|
-
|
|
114
|
+
inlineGridRef.current?.scrollToRow(0);
|
|
115
|
+
expandedGridRef.current?.scrollToRow(0);
|
|
105
116
|
}, [
|
|
106
117
|
currentPageIndex
|
|
107
118
|
]);
|
|
119
|
+
const handleOpen = ()=>{
|
|
120
|
+
setIsCompactViewport(isBelowDesktopBreakpoint());
|
|
121
|
+
setIsExpanded(true);
|
|
122
|
+
};
|
|
108
123
|
const handlePageIndexChange = (nextPageIndex)=>{
|
|
109
124
|
setPageIndex(clamp(nextPageIndex, 0, totalPages - 1));
|
|
110
125
|
};
|
|
126
|
+
useEffect(()=>{
|
|
127
|
+
if (!isExpanded) return;
|
|
128
|
+
const handleResize = ()=>{
|
|
129
|
+
setIsCompactViewport(isBelowDesktopBreakpoint());
|
|
130
|
+
};
|
|
131
|
+
window.addEventListener('resize', handleResize, {
|
|
132
|
+
passive: true
|
|
133
|
+
});
|
|
134
|
+
return ()=>window.removeEventListener('resize', handleResize);
|
|
135
|
+
}, [
|
|
136
|
+
isExpanded
|
|
137
|
+
]);
|
|
111
138
|
if (!parsed.isParsed) {
|
|
112
139
|
return /*#__PURE__*/ _jsx("div", {
|
|
113
140
|
"data-slot": "message-table",
|
|
@@ -121,33 +148,30 @@ const buildColumns = (headers)=>headers.map((header, index)=>({
|
|
|
121
148
|
})
|
|
122
149
|
});
|
|
123
150
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
// max-h-131 (524px) fits the column header plus 10 single-line rows (36px each) and the footer; the rest scrolls. `w-full` lets the table fill the card's full width.
|
|
149
|
-
className: "max-h-131 w-full",
|
|
150
|
-
children: totalRows > 0 && /*#__PURE__*/ _jsx(MessageTableFooter, {
|
|
151
|
+
const columns = buildColumns(parsed.headers);
|
|
152
|
+
const renderGrid = ({ gridRef, className, header })=>/*#__PURE__*/ _jsxs(DataGrid, {
|
|
153
|
+
data: pageRows,
|
|
154
|
+
columns: columns,
|
|
155
|
+
getRowId: (row)=>row.id,
|
|
156
|
+
rowCount: totalRows,
|
|
157
|
+
manualPagination: true,
|
|
158
|
+
pagination: {
|
|
159
|
+
pageIndex: currentPageIndex,
|
|
160
|
+
pageSize: MESSAGE_TABLE_PAGE_SIZE
|
|
161
|
+
},
|
|
162
|
+
onPaginationChange: (next)=>handlePageIndexChange(next.pageIndex),
|
|
163
|
+
// Read-only tables are scanned rather than edited, so stripe rows instead of drawing column dividers.
|
|
164
|
+
striped: true,
|
|
165
|
+
// Header and rows share one background, so the titles carry the distinction.
|
|
166
|
+
emphasizeHeader: true,
|
|
167
|
+
// Chat answers often put sentences in cells; show them in full rather than truncated.
|
|
168
|
+
wrapCells: true,
|
|
169
|
+
gridRef: gridRef,
|
|
170
|
+
"aria-label": ariaLabel,
|
|
171
|
+
className: className,
|
|
172
|
+
children: [
|
|
173
|
+
header,
|
|
174
|
+
totalRows > 0 && /*#__PURE__*/ _jsx(MessageTableFooter, {
|
|
151
175
|
pageIndex: currentPageIndex,
|
|
152
176
|
pageSize: MESSAGE_TABLE_PAGE_SIZE,
|
|
153
177
|
labels: resolvedLabels,
|
|
@@ -155,8 +179,72 @@ const buildColumns = (headers)=>headers.map((header, index)=>({
|
|
|
155
179
|
totalRows: totalRows,
|
|
156
180
|
onPageIndexChange: handlePageIndexChange
|
|
157
181
|
})
|
|
182
|
+
]
|
|
183
|
+
});
|
|
184
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
185
|
+
"data-slot": "message-table",
|
|
186
|
+
className: "my-4",
|
|
187
|
+
children: [
|
|
188
|
+
/*#__PURE__*/ _jsx(Card, {
|
|
189
|
+
className: "w-full bg-transparent",
|
|
190
|
+
children: renderGrid({
|
|
191
|
+
gridRef: inlineGridRef,
|
|
192
|
+
// max-h-131 (524px) fits the expand button, the column header plus 10 single-line rows (36px each) and the footer; the rest scrolls. `w-full` lets the table fill the card's full width.
|
|
193
|
+
className: 'max-h-131 w-full',
|
|
194
|
+
header: /*#__PURE__*/ _jsx(DataGridHeader, {
|
|
195
|
+
children: /*#__PURE__*/ _jsx(DataGridHeaderEnd, {
|
|
196
|
+
children: /*#__PURE__*/ _jsxs(Tooltip, {
|
|
197
|
+
children: [
|
|
198
|
+
/*#__PURE__*/ _jsx(TooltipTrigger, {
|
|
199
|
+
render: /*#__PURE__*/ _jsx(Button, {
|
|
200
|
+
variant: "ghost",
|
|
201
|
+
size: "icon-sm",
|
|
202
|
+
type: "button",
|
|
203
|
+
"aria-label": resolvedLabels.expandView,
|
|
204
|
+
onClick: handleOpen,
|
|
205
|
+
children: /*#__PURE__*/ _jsx(IconArrowsDiagonal, {})
|
|
206
|
+
})
|
|
207
|
+
}),
|
|
208
|
+
/*#__PURE__*/ _jsx(TooltipContent, {
|
|
209
|
+
children: /*#__PURE__*/ _jsx("p", {
|
|
210
|
+
children: resolvedLabels.expandView
|
|
211
|
+
})
|
|
212
|
+
})
|
|
213
|
+
]
|
|
214
|
+
})
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
})
|
|
218
|
+
}),
|
|
219
|
+
/*#__PURE__*/ _jsx(Dialog, {
|
|
220
|
+
open: isExpanded,
|
|
221
|
+
onOpenChange: setIsExpanded,
|
|
222
|
+
children: /*#__PURE__*/ _jsxs(DialogContent, {
|
|
223
|
+
showCloseButton: false,
|
|
224
|
+
"aria-label": resolvedLabels.expandedView,
|
|
225
|
+
"data-slot": "message-table-expanded-dialog",
|
|
226
|
+
className: cn('text-base-foreground mb-0 flex flex-col gap-0 overflow-hidden p-0', isCompactViewport ? 'inset-0 size-full translate-y-0 rounded-none border-0 sm:left-0 sm:max-w-none sm:translate-x-0' : 'max-h-4/5 border-default sm:w-4/5 sm:max-w-none'),
|
|
227
|
+
children: [
|
|
228
|
+
/*#__PURE__*/ _jsx("div", {
|
|
229
|
+
className: "flex shrink-0 items-center justify-end gap-4 border-b border-default px-4 py-2",
|
|
230
|
+
children: /*#__PURE__*/ _jsx(DialogClose, {
|
|
231
|
+
render: /*#__PURE__*/ _jsx(Button, {
|
|
232
|
+
variant: "ghost",
|
|
233
|
+
size: "icon-sm",
|
|
234
|
+
type: "button",
|
|
235
|
+
"aria-label": resolvedLabels.minimize,
|
|
236
|
+
children: /*#__PURE__*/ _jsx(IconX, {})
|
|
237
|
+
})
|
|
238
|
+
})
|
|
239
|
+
}),
|
|
240
|
+
renderGrid({
|
|
241
|
+
gridRef: expandedGridRef,
|
|
242
|
+
className: 'flex-1 rounded-none'
|
|
243
|
+
})
|
|
244
|
+
]
|
|
245
|
+
})
|
|
158
246
|
})
|
|
159
|
-
|
|
247
|
+
]
|
|
160
248
|
});
|
|
161
249
|
};
|
|
162
250
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/ui/core/message/message-response-table.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react';\nimport { Children, isValidElement, useEffect, useRef, useState } from 'react';\n\nimport type { ColumnDef } from '@tanstack/react-table';\nimport type { JSX } from 'react/jsx-runtime';\nimport type { ExtraProps } from 'streamdown';\n\nimport { Card } from '../card/card';\nimport { DataGrid, type DataGridHandle } from '../data-grid/data-grid';\n\nimport { MessageTableFooter } from './message-response-table-footer';\nimport {\n DEFAULT_MESSAGE_RESPONSE_TABLE_LABELS,\n type MessageResponseTableLabels,\n} from './message-response-table-labels';\n\ntype MessageResponseTableProps = JSX.IntrinsicElements['table'] &\n ExtraProps & {\n /** Translated text for the table's controls; any label left out falls back to English. */\n labels?: Partial<MessageResponseTableLabels>;\n };\n\nconst DEFAULT_TABLE_LABEL = 'Atlas AI Chat Table';\n\ntype MessageTableRow = {\n id: string;\n /** Rendered Markdown content of each cell, so links and formatting survive. */\n cells: ReactNode[];\n /** Plain text of each cell. */\n text: string[];\n};\n\ntype ParsedTable =\n | { isParsed: true; headers: string[]; rows: MessageTableRow[] }\n | { isParsed: false };\n\nexport const MESSAGE_TABLE_PAGE_SIZE = 50;\n\nconst clamp = (value: number, min: number, max: number): number =>\n Math.min(Math.max(value, min), max);\n\nconst getTagName = (element: ReactElement): string | undefined =>\n (element.props as ExtraProps).node?.tagName ??\n (typeof element.type === 'string' ? element.type : undefined);\n\nconst getChildren = (element: ReactElement): ReactNode =>\n (element.props as { children?: ReactNode }).children;\n\n/**\n * Flattens rendered Markdown children into an indexable element array.\n * Streamdown hands us an opaque `ReactNode` tree, so there is no alternative API for this.\n */\nconst toElementArray = (node: ReactNode): ReactElement[] =>\n // eslint-disable-next-line @eslint-react/no-children-to-array -- The grid needs Streamdown's rendered table sections, rows and cells as indexable arrays\n Children.toArray(node).filter((child): child is ReactElement =>\n isValidElement(child)\n );\n\nconst extractText = (node: ReactNode): string => {\n if (node === null || node === undefined || typeof node === 'boolean') {\n return '';\n }\n if (typeof node === 'string' || typeof node === 'number') {\n return String(node);\n }\n if (Array.isArray(node)) {\n return node.map(extractText).join('');\n }\n if (isValidElement(node)) {\n return extractText(getChildren(node));\n }\n return '';\n};\n\nconst getCellContents = (row: ReactElement): ReactNode[] =>\n toElementArray(getChildren(row)).map(getChildren);\n\nconst parseTableChildren = (children: ReactNode): ParsedTable => {\n const sections = toElementArray(children);\n\n let header: ReactElement | null = null;\n let body: ReactElement | null = null;\n\n for (const section of sections) {\n const tagName = getTagName(section);\n if (tagName === 'thead' && !header) {\n header = section;\n } else if (tagName === 'tbody' && !body) {\n body = section;\n }\n }\n\n // Fallback for renderers that do not forward hast `node` metadata:\n // a table is conventionally [thead, tbody].\n if (!header && !body && sections.length <= 2) {\n [header = null, body = null] = sections;\n }\n\n const headerRow = header ? toElementArray(getChildren(header))[0] : undefined;\n if (!headerRow) return { isParsed: false };\n\n const headers = getCellContents(headerRow).map((cell) =>\n extractText(cell).trim()\n );\n if (headers.length === 0) return { isParsed: false };\n\n // While the response streams, the header arrives before any body rows.\n const rows = body\n ? toElementArray(getChildren(body)).map((row, index) => {\n const cells = getCellContents(row);\n return {\n id: String(index),\n cells,\n text: cells.map((cell) => extractText(cell).trim()),\n };\n })\n : [];\n\n return { isParsed: true, headers, rows };\n};\n\nconst getColumnId = (index: number): string => `column-${index}`;\n\nconst buildColumns = (headers: string[]): ColumnDef<MessageTableRow>[] =>\n headers.map((header, index) => ({\n id: getColumnId(index),\n header,\n accessorFn: (row) => row.text[index] ?? '',\n cell: ({ row }) => row.original.cells[index] ?? null,\n }));\n\n/**\n * Renders a Markdown table from a chat response as a DataGrid.\n * Not the default `table` renderer yet; opt in with `<MessageResponse components={{ table: MessageResponseTable }}>`.\n * Aura has no translations, so pass a translated `aria-label` to name the table (it defaults to \"Atlas AI Chat Table\")\n * and `labels` to translate its controls.\n */\nexport const MessageResponseTable = ({\n children,\n 'aria-label': ariaLabel = DEFAULT_TABLE_LABEL,\n labels,\n}: MessageResponseTableProps): ReactNode => {\n const resolvedLabels = {\n ...DEFAULT_MESSAGE_RESPONSE_TABLE_LABELS,\n ...labels,\n };\n const parsed = parseTableChildren(children);\n const allRows = parsed.isParsed ? parsed.rows : [];\n const totalRows = allRows.length;\n const totalPages = Math.max(\n 1,\n Math.ceil(totalRows / MESSAGE_TABLE_PAGE_SIZE)\n );\n\n const [pageIndex, setPageIndex] = useState(0);\n const gridRef = useRef<DataGridHandle>(null);\n\n // Clamp the page while rows stream in or shrink.\n const currentPageIndex = clamp(pageIndex, 0, totalPages - 1);\n // Pages are sliced here rather than by the grid: its client pagination resets\n // to the first page whenever `data` changes identity, which happens on every\n // re-render of the streamed Markdown.\n const pageRows = allRows.slice(\n currentPageIndex * MESSAGE_TABLE_PAGE_SIZE,\n (currentPageIndex + 1) * MESSAGE_TABLE_PAGE_SIZE\n );\n\n // Show the top of each new page.\n useEffect(() => {\n gridRef.current?.scrollToRow(0);\n }, [currentPageIndex]);\n\n const handlePageIndexChange = (nextPageIndex: number): void => {\n setPageIndex(clamp(nextPageIndex, 0, totalPages - 1));\n };\n\n if (!parsed.isParsed) {\n return (\n <div\n data-slot=\"message-table\"\n className=\"my-4 overflow-x-auto\"\n tabIndex={0}\n role=\"group\"\n aria-label={ariaLabel}\n >\n <table className=\"w-full\">{children}</table>\n </div>\n );\n }\n\n return (\n <div data-slot=\"message-table\" className=\"my-4\">\n {/* The Card keeps its shape and padding but drops its grey surface, so the grid sits on its default base background and muted stripes. */}\n <Card className=\"w-full bg-transparent\">\n <DataGrid<MessageTableRow>\n data={pageRows}\n columns={buildColumns(parsed.headers)}\n getRowId={(row) => row.id}\n rowCount={totalRows}\n manualPagination\n pagination={{\n pageIndex: currentPageIndex,\n pageSize: MESSAGE_TABLE_PAGE_SIZE,\n }}\n onPaginationChange={(next) => handlePageIndexChange(next.pageIndex)}\n // Read-only tables are scanned rather than edited, so stripe rows instead of drawing column dividers.\n striped\n // Header and rows share one background, so the titles carry the distinction.\n emphasizeHeader\n // Chat answers often put sentences in cells; show them in full rather than truncated.\n wrapCells\n gridRef={gridRef}\n aria-label={ariaLabel}\n // max-h-131 (524px) fits the column header plus 10 single-line rows (36px each) and the footer; the rest scrolls. `w-full` lets the table fill the card's full width.\n className=\"max-h-131 w-full\"\n >\n {totalRows > 0 && (\n <MessageTableFooter\n pageIndex={currentPageIndex}\n pageSize={MESSAGE_TABLE_PAGE_SIZE}\n labels={resolvedLabels}\n totalPages={totalPages}\n totalRows={totalRows}\n onPageIndexChange={handlePageIndexChange}\n />\n )}\n </DataGrid>\n </Card>\n </div>\n );\n};\n"],"names":["Children","isValidElement","useEffect","useRef","useState","Card","DataGrid","MessageTableFooter","DEFAULT_MESSAGE_RESPONSE_TABLE_LABELS","DEFAULT_TABLE_LABEL","MESSAGE_TABLE_PAGE_SIZE","clamp","value","min","max","Math","getTagName","element","props","node","tagName","type","undefined","getChildren","children","toElementArray","toArray","filter","child","extractText","String","Array","isArray","map","join","getCellContents","row","parseTableChildren","sections","header","body","section","length","headerRow","isParsed","headers","cell","trim","rows","index","cells","id","text","getColumnId","buildColumns","accessorFn","original","MessageResponseTable","ariaLabel","labels","resolvedLabels","parsed","allRows","totalRows","totalPages","ceil","pageIndex","setPageIndex","gridRef","currentPageIndex","pageRows","slice","current","scrollToRow","handlePageIndexChange","nextPageIndex","div","data-slot","className","tabIndex","role","aria-label","table","data","columns","getRowId","rowCount","manualPagination","pagination","pageSize","onPaginationChange","next","striped","emphasizeHeader","w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ACNc,SAAS9B,aAAaO,OAAOhB,OAAO;gBACpCwC,UAAU,CAACjD,MAAQA,IAAIe,EAAE;gBACzBmC,UAAUvB;gBACVwB,gBAAgB;gBAChBC,YAAY;oBACVtB,WAAWG;oBACXoB,UAAU/E;gBACZ;gBACAgF,oBAAoB,CAACC,OAASjB,sBAAsBiB,KAAKzB,SAAS;gBAClE,sGAAsG;gBACtG0B,OAAO;gBACP,6EAA6E;gBAC7EC,eAAe;gBACf,sFAAsF;gBACtFC,SAAS;gBACT1B,SAASA;gBACTa,cAAYvB;gBACZ,sKAAsK;gBACtKoB,WAAU;0BAETf,YAAY,mBACX,KAACxD;oBACC2D,WAAWG;oBACXoB,UAAU/E;oBACViD,QAAQC;oBACRI,YAAYA;oBACZD,WAAWA;oBACXgC,mBAAmBrB;;;;;AAOjC,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/message/message-response-table.tsx"],"sourcesContent":["import type { ReactElement, ReactNode, RefObject } from 'react';\nimport { Children, isValidElement, useEffect, useRef, useState } from 'react';\n\nimport { IconArrowsDiagonal, IconX } from '@tabler/icons-react';\nimport type { ColumnDef } from '@tanstack/react-table';\nimport type { JSX } from 'react/jsx-runtime';\nimport type { ExtraProps } from 'streamdown';\n\nimport { cn } from '../../../../lib/utils';\nimport { Button } from '../button/button';\nimport { Card } from '../card/card';\nimport {\n DataGrid,\n DataGridHeader,\n DataGridHeaderEnd,\n type DataGridHandle,\n} from '../data-grid/data-grid';\nimport { Dialog, DialogClose, DialogContent } from '../dialog/dialog';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '../tooltip/tooltip';\n\nimport { MessageTableFooter } from './message-response-table-footer';\nimport {\n DEFAULT_MESSAGE_RESPONSE_TABLE_LABELS,\n type MessageResponseTableLabels,\n} from './message-response-table-labels';\n\ntype MessageResponseTableProps = JSX.IntrinsicElements['table'] &\n ExtraProps & {\n /** Translated text for the table's controls; any label left out falls back to English. */\n labels?: Partial<MessageResponseTableLabels>;\n };\n\nconst DEFAULT_TABLE_LABEL = 'Atlas AI Chat Table';\n\ntype MessageTableRow = {\n id: string;\n /** Rendered Markdown content of each cell, so links and formatting survive. */\n cells: ReactNode[];\n /** Plain text of each cell. */\n text: string[];\n};\n\ntype ParsedTable =\n | { isParsed: true; headers: string[]; rows: MessageTableRow[] }\n | { isParsed: false };\n\nexport const MESSAGE_TABLE_PAGE_SIZE = 50;\n\nconst COMPACT_VIEWPORT_BREAKPOINT_PX = 1024;\n\nconst isBelowDesktopBreakpoint = (): boolean =>\n typeof window !== 'undefined' &&\n window.innerWidth < COMPACT_VIEWPORT_BREAKPOINT_PX;\n\nconst clamp = (value: number, min: number, max: number): number =>\n Math.min(Math.max(value, min), max);\n\nconst getTagName = (element: ReactElement): string | undefined =>\n (element.props as ExtraProps).node?.tagName ??\n (typeof element.type === 'string' ? element.type : undefined);\n\nconst getChildren = (element: ReactElement): ReactNode =>\n (element.props as { children?: ReactNode }).children;\n\n/**\n * Flattens rendered Markdown children into an indexable element array.\n * Streamdown hands us an opaque `ReactNode` tree, so there is no alternative API for this.\n */\nconst toElementArray = (node: ReactNode): ReactElement[] =>\n // eslint-disable-next-line @eslint-react/no-children-to-array -- The grid needs Streamdown's rendered table sections, rows and cells as indexable arrays\n Children.toArray(node).filter((child): child is ReactElement =>\n isValidElement(child)\n );\n\nconst extractText = (node: ReactNode): string => {\n if (node === null || node === undefined || typeof node === 'boolean') {\n return '';\n }\n if (typeof node === 'string' || typeof node === 'number') {\n return String(node);\n }\n if (Array.isArray(node)) {\n return node.map(extractText).join('');\n }\n if (isValidElement(node)) {\n return extractText(getChildren(node));\n }\n return '';\n};\n\nconst getCellContents = (row: ReactElement): ReactNode[] =>\n toElementArray(getChildren(row)).map(getChildren);\n\nconst parseTableChildren = (children: ReactNode): ParsedTable => {\n const sections = toElementArray(children);\n\n let header: ReactElement | null = null;\n let body: ReactElement | null = null;\n\n for (const section of sections) {\n const tagName = getTagName(section);\n if (tagName === 'thead' && !header) {\n header = section;\n } else if (tagName === 'tbody' && !body) {\n body = section;\n }\n }\n\n // Fallback for renderers that do not forward hast `node` metadata:\n // a table is conventionally [thead, tbody].\n if (!header && !body && sections.length <= 2) {\n [header = null, body = null] = sections;\n }\n\n const headerRow = header ? toElementArray(getChildren(header))[0] : undefined;\n if (!headerRow) return { isParsed: false };\n\n const headers = getCellContents(headerRow).map((cell) =>\n extractText(cell).trim()\n );\n if (headers.length === 0) return { isParsed: false };\n\n // While the response streams, the header arrives before any body rows.\n const rows = body\n ? toElementArray(getChildren(body)).map((row, index) => {\n const cells = getCellContents(row);\n return {\n id: String(index),\n cells,\n text: cells.map((cell) => extractText(cell).trim()),\n };\n })\n : [];\n\n return { isParsed: true, headers, rows };\n};\n\nconst getColumnId = (index: number): string => `column-${index}`;\n\nconst buildColumns = (headers: string[]): ColumnDef<MessageTableRow>[] =>\n headers.map((header, index) => ({\n id: getColumnId(index),\n header,\n accessorFn: (row) => row.text[index] ?? '',\n cell: ({ row }) => row.original.cells[index] ?? null,\n }));\n\n/**\n * Renders a Markdown table from a chat response as a DataGrid.\n * Not the default `table` renderer yet; opt in with `<MessageResponse components={{ table: MessageResponseTable }}>`.\n * Aura has no translations, so pass a translated `aria-label` to name the table (it defaults to \"Atlas AI Chat Table\")\n * and `labels` to translate its controls.\n */\nexport const MessageResponseTable = ({\n children,\n 'aria-label': ariaLabel = DEFAULT_TABLE_LABEL,\n labels,\n}: MessageResponseTableProps): ReactNode => {\n const resolvedLabels = {\n ...DEFAULT_MESSAGE_RESPONSE_TABLE_LABELS,\n ...labels,\n };\n const parsed = parseTableChildren(children);\n const allRows = parsed.isParsed ? parsed.rows : [];\n const totalRows = allRows.length;\n const totalPages = Math.max(\n 1,\n Math.ceil(totalRows / MESSAGE_TABLE_PAGE_SIZE)\n );\n\n const [pageIndex, setPageIndex] = useState(0);\n const [isExpanded, setIsExpanded] = useState(false);\n const [isCompactViewport, setIsCompactViewport] = useState(\n isBelowDesktopBreakpoint\n );\n\n const inlineGridRef = useRef<DataGridHandle>(null);\n const expandedGridRef = useRef<DataGridHandle>(null);\n\n // Clamp the page while rows stream in or shrink.\n const currentPageIndex = clamp(pageIndex, 0, totalPages - 1);\n // Pages are sliced here rather than by the grid: its client pagination resets\n // to the first page whenever `data` changes identity, which happens on every\n // re-render of the streamed Markdown.\n const pageRows = allRows.slice(\n currentPageIndex * MESSAGE_TABLE_PAGE_SIZE,\n (currentPageIndex + 1) * MESSAGE_TABLE_PAGE_SIZE\n );\n\n // Show the top of each new page.\n useEffect(() => {\n inlineGridRef.current?.scrollToRow(0);\n expandedGridRef.current?.scrollToRow(0);\n }, [currentPageIndex]);\n\n const handleOpen = (): void => {\n setIsCompactViewport(isBelowDesktopBreakpoint());\n setIsExpanded(true);\n };\n\n const handlePageIndexChange = (nextPageIndex: number): void => {\n setPageIndex(clamp(nextPageIndex, 0, totalPages - 1));\n };\n\n useEffect(() => {\n if (!isExpanded) return;\n\n const handleResize = (): void => {\n setIsCompactViewport(isBelowDesktopBreakpoint());\n };\n\n window.addEventListener('resize', handleResize, { passive: true });\n return () => window.removeEventListener('resize', handleResize);\n }, [isExpanded]);\n\n if (!parsed.isParsed) {\n return (\n <div\n data-slot=\"message-table\"\n className=\"my-4 overflow-x-auto\"\n tabIndex={0}\n role=\"group\"\n aria-label={ariaLabel}\n >\n <table className=\"w-full\">{children}</table>\n </div>\n );\n }\n\n const columns = buildColumns(parsed.headers);\n\n const renderGrid = ({\n gridRef,\n className,\n header,\n }: {\n gridRef: RefObject<DataGridHandle | null>;\n className: string;\n header?: ReactNode;\n }): ReactNode => (\n <DataGrid<MessageTableRow>\n data={pageRows}\n columns={columns}\n getRowId={(row) => row.id}\n rowCount={totalRows}\n manualPagination\n pagination={{\n pageIndex: currentPageIndex,\n pageSize: MESSAGE_TABLE_PAGE_SIZE,\n }}\n onPaginationChange={(next) => handlePageIndexChange(next.pageIndex)}\n // Read-only tables are scanned rather than edited, so stripe rows instead of drawing column dividers.\n striped\n // Header and rows share one background, so the titles carry the distinction.\n emphasizeHeader\n // Chat answers often put sentences in cells; show them in full rather than truncated.\n wrapCells\n gridRef={gridRef}\n aria-label={ariaLabel}\n className={className}\n >\n {header}\n {totalRows > 0 && (\n <MessageTableFooter\n pageIndex={currentPageIndex}\n pageSize={MESSAGE_TABLE_PAGE_SIZE}\n labels={resolvedLabels}\n totalPages={totalPages}\n totalRows={totalRows}\n onPageIndexChange={handlePageIndexChange}\n />\n )}\n </DataGrid>\n );\n\n return (\n <div data-slot=\"message-table\" className=\"my-4\">\n {/* The Card keeps its shape and padding but drops its grey surface, so the grid sits on its default base background and muted stripes. */}\n <Card className=\"w-full bg-transparent\">\n {renderGrid({\n gridRef: inlineGridRef,\n // max-h-131 (524px) fits the expand button, the column header plus 10 single-line rows (36px each) and the footer; the rest scrolls. `w-full` lets the table fill the card's full width.\n className: 'max-h-131 w-full',\n header: (\n <DataGridHeader>\n <DataGridHeaderEnd>\n <Tooltip>\n <TooltipTrigger\n render={\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n type=\"button\"\n aria-label={resolvedLabels.expandView}\n onClick={handleOpen}\n >\n <IconArrowsDiagonal />\n </Button>\n }\n />\n <TooltipContent>\n <p>{resolvedLabels.expandView}</p>\n </TooltipContent>\n </Tooltip>\n </DataGridHeaderEnd>\n </DataGridHeader>\n ),\n })}\n </Card>\n {/* Dialog portals into the configured portal container and handles Escape, backdrop presses, focus and scroll locking. */}\n <Dialog open={isExpanded} onOpenChange={setIsExpanded}>\n <DialogContent\n showCloseButton={false}\n aria-label={resolvedLabels.expandedView}\n data-slot=\"message-table-expanded-dialog\"\n className={cn(\n 'text-base-foreground mb-0 flex flex-col gap-0 overflow-hidden p-0',\n isCompactViewport\n ? // Full screen: undo the dialog's centring and width cap.\n 'inset-0 size-full translate-y-0 rounded-none border-0 sm:left-0 sm:max-w-none sm:translate-x-0'\n : 'max-h-4/5 border-default sm:w-4/5 sm:max-w-none'\n )}\n >\n <div className=\"flex shrink-0 items-center justify-end gap-4 border-b border-default px-4 py-2\">\n <DialogClose\n render={\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n type=\"button\"\n aria-label={resolvedLabels.minimize}\n >\n <IconX />\n </Button>\n }\n />\n </div>\n\n {renderGrid({\n gridRef: expandedGridRef,\n className: 'flex-1 rounded-none',\n })}\n </DialogContent>\n </Dialog>\n </div>\n );\n};\n"],"names":["Children","isValidElement","useEffect","useRef","useState","IconArrowsDiagonal","IconX","cn","Button","Card","DataGrid","DataGridHeader","DataGridHeaderEnd","Dialog","DialogClose","DialogContent","Tooltip","TooltipContent","TooltipTrigger","MessageTableFooter","DEFAULT_MESSAGE_RESPONSE_TABLE_LABELS","DEFAULT_TABLE_LABEL","MESSAGE_TABLE_PAGE_SIZE","COMPACT_VIEWPORT_BREAKPOINT_PX","isBelowDesktopBreakpoint","window","innerWidth","clamp","value","min","max","Math","getTagName","element","props","node","tagName","type","undefined","getChildren","children","toElementArray","toArray","filter","child","extractText","String","Array","isArray","map","join","getCellContents","row","parseTableChildren","sections","header","body","section","length","headerRow","isParsed","headers","cell","trim","rows","index","cells","id","text","getColumnId","buildColumns","accessorFn","original","MessageResponseTable","ariaLabel","labels","resolvedLabels","parsed","allRows","totalRows","totalPages","ceil","pageIndex","setPageIndex","isExpanded","setIsExpanded","isCompactViewport","setIsCompactViewport","inlineGridRef","expandedGridRef","currentPageIndex","pageRows","slice","current","scrollToRow","handleOpen","handlePageIndexChange","nextPageIndex","handleResize","addEventListener","passive","removeEventListener","div","data-slot","className","tabIndex","role","aria-label","table","columns","renderGrid","gridRef","data","getRowId","rowCount","manualPagination","pagination","pageSize","onPaginationChange","next","striped","emphasizeHeader","wrapCells","onPageIndexChange","render","variant","size","expandView","onClick","p","open","onOpenChange","showCloseButton","expandedView","minimize"],"mappings":";AACA,SAASA,QAAQ,EAAEC,cAAc,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAE9E,SAASC,kBAAkB,EAAEC,KAAK,QAAQ,s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ACbM,WAAW;oBACVC,SAASvB;oBACT,yLAAyL;oBACzLgB,WAAW;oBACXjD,sBACE,KAAC5C;kCACC,cAAA,KAACC;sCACC,cAAA,MAACI;;kDACC,KAACE;wCACC0G,sBACE,KAACpH;4CACCqH,SAAQ;4CACRC,MAAK;4CACLzF,MAAK;4CACLsE,cAAY/B,eAAemD,UAAU;4CACrCC,SAASjC;sDAET,cAAA,KAAC1F;;;kDAIP,KAACY;kDACC,cAAA,KAACgH;sDAAGrD,eAAemD,UAAU;;;;;;;gBAMzC;;0BAGF,KAAClH;gBAAOqH,MAAM9C;gBAAY+C,cAAc9C;0BACtC,cAAA,MAACtE;oBACCqH,iBAAiB;oBACjBzB,cAAY/B,eAAeyD,YAAY;oBACvC9B,aAAU;oBACVC,WAAWjG,GACT,qEACA+E,oBAEI,mGACA;;sCAGN,KAACgB;4BAAIE,WAAU;sCACb,cAAA,KAAC1F;gCACC8G,sBACE,KAACpH;oCACCqH,SAAQ;oCACRC,MAAK;oCACLzF,MAAK;oCACLsE,cAAY/B,eAAe0D,QAAQ;8CAEnC,cAAA,KAAChI;;;;wBAMRwG,WAAW;4BACVC,SAAStB;4BACTe,WAAW;wBACb;;;;;;AAKV,EAAE"}
|
|
@@ -3,7 +3,7 @@ import { createContext, useCallback, useContext, useEffect, useMemo, useState }
|
|
|
3
3
|
import { mermaid as mermaidPlugin } from "@streamdown/mermaid";
|
|
4
4
|
import { IconChevronLeft, IconChevronRight, IconPaperclip, IconX } from "@tabler/icons-react";
|
|
5
5
|
import { Streamdown } from "streamdown";
|
|
6
|
-
import { usePortalContainer } from "../../../../lib/portal-container-context.js";
|
|
6
|
+
import { PortalContainerContext, usePortalContainer } from "../../../../lib/portal-container-context.js";
|
|
7
7
|
import { cn, getInitials } from "../../../../lib/utils.js";
|
|
8
8
|
import { Avatar, AvatarFallback, AvatarIcon, AvatarImage } from "../avatar/avatar.js";
|
|
9
9
|
import { Button } from "../button/button.js";
|
|
@@ -351,6 +351,17 @@ const MessageResponseMarkdown = ({ className, components, plugins, controls, por
|
|
|
351
351
|
...props
|
|
352
352
|
});
|
|
353
353
|
};
|
|
354
|
+
/**
|
|
355
|
+
* Shares an explicit `portal` prop with components rendered inside the Markdown,
|
|
356
|
+
* such as the expanded table view, so they portal into the same container as Streamdown.
|
|
357
|
+
*/ const MessageResponsePortalProvider = ({ portal, children })=>{
|
|
358
|
+
const portalContainer = usePortalContainer();
|
|
359
|
+
const explicitPortalElement = typeof portal === 'function' ? portal() ?? undefined : portal;
|
|
360
|
+
return /*#__PURE__*/ _jsx(PortalContainerContext.Provider, {
|
|
361
|
+
value: explicitPortalElement ?? portalContainer,
|
|
362
|
+
children: children
|
|
363
|
+
});
|
|
364
|
+
};
|
|
354
365
|
const MessageResponse = ({ id, role, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'data-testid': dataTestId, ...props })=>/*#__PURE__*/ _jsx("div", {
|
|
355
366
|
"data-slot": "message-response",
|
|
356
367
|
id: id,
|
|
@@ -359,8 +370,11 @@ const MessageResponse = ({ id, role, 'aria-label': ariaLabel, 'aria-labelledby':
|
|
|
359
370
|
"aria-labelledby": ariaLabelledBy,
|
|
360
371
|
"aria-describedby": ariaDescribedBy,
|
|
361
372
|
"data-testid": dataTestId,
|
|
362
|
-
children: /*#__PURE__*/ _jsx(
|
|
363
|
-
|
|
373
|
+
children: /*#__PURE__*/ _jsx(MessageResponsePortalProvider, {
|
|
374
|
+
portal: props.portal,
|
|
375
|
+
children: /*#__PURE__*/ _jsx(MessageResponseMarkdown, {
|
|
376
|
+
...props
|
|
377
|
+
})
|
|
364
378
|
})
|
|
365
379
|
});
|
|
366
380
|
function MessageAttachment({ data, className, onRemove, ...props }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/ui/core/message/message.tsx"],"sourcesContent":["import type {\n ComponentProps,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n} from 'react';\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport { mermaid as mermaidPlugin } from '@streamdown/mermaid';\nimport {\n IconChevronLeft,\n IconChevronRight,\n IconPaperclip,\n IconX,\n} from '@tabler/icons-react';\nimport type { JSX } from 'react/jsx-runtime';\nimport type { Components, ExtraProps } from 'streamdown';\nimport { Streamdown } from 'streamdown';\n\nimport type { FileUIPart, UIMessage } from '../../../../lib/ai/types';\nimport { usePortalContainer } from '../../../../lib/portal-container-context';\nimport { cn, getInitials } from '../../../../lib/utils';\nimport {\n Avatar,\n AvatarFallback,\n AvatarIcon,\n AvatarImage,\n} from '../avatar/avatar';\nimport { Button } from '../button/button';\nimport { ButtonGroup, ButtonGroupText } from '../button-group/button-group';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '../tooltip/tooltip';\n\nimport { MESSAGE_RESPONSE_DEFAULT_STREAMDOWN_CONTROLS } from './message-response-default-streamdown-controls';\n\ntype MessageProps = HTMLAttributes<HTMLDivElement> & {\n isResponse?: boolean;\n};\n\nconst Message = ({\n className,\n isResponse = false,\n ...props\n}: MessageProps): ReactNode => (\n <div\n data-slot=\"message\"\n className={cn(\n 'group flex w-full items-start justify-start gap-3 mb-0 py-3',\n isResponse ? 'is-assistant items-start' : 'is-user flex-row-reverse',\n className\n )}\n {...props}\n />\n);\n\ntype MessageContentProps = HTMLAttributes<HTMLDivElement>;\n\nconst MessageContent = ({\n children,\n className,\n ...props\n}: MessageContentProps): ReactNode => (\n <div\n data-slot=\"message-content\"\n className={cn(\n 'is-user:dark flex flex-col gap-4 rounded-md text-base leading-tight tracking-tightest',\n 'max-w-4/5',\n // The table grid's rows are absolutely positioned, so they don't widen the content; give tables the full width rather than wrapping cells to fit the headers.\n 'has-data-[slot=message-table]:w-full',\n 'group-[.is-user]:overflow-hidden group-[.is-user]:bg-medium-background group-[.is-user]:p-2 group-[.is-user]:text-base-foreground',\n 'group-[.is-assistant]:text-base-foreground group-[.is-assistant]:pt-1',\n className\n )}\n {...props}\n >\n {children}\n </div>\n);\n\ntype MessageAvatarProps = ComponentProps<typeof Avatar> & {\n avatarUrl?: string;\n name?: string;\n};\n\nconst MessageAvatar = ({\n avatarUrl,\n name,\n className,\n children,\n variant,\n sizes,\n ...props\n}: MessageAvatarProps): ReactNode => {\n const fallbackText = name ? getInitials(name) : 'ME';\n\n return (\n <Avatar\n data-slot=\"message-avatar\"\n className={cn('size-7 group-[.is-user]:mt-1', className)}\n variant={variant}\n sizes={sizes}\n {...props}\n >\n {children || (\n <>\n {avatarUrl && (\n <AvatarImage\n alt={name || ''}\n className=\"mt-0 mb-0\"\n src={avatarUrl}\n />\n )}\n <AvatarFallback>{fallbackText}</AvatarFallback>\n </>\n )}\n </Avatar>\n );\n};\n\ntype MessageAvatarIconProps = ComponentProps<typeof AvatarIcon>;\n\nconst MessageAvatarIcon = (props: MessageAvatarIconProps): ReactNode => (\n <AvatarIcon data-slot=\"message-avatar-icon\" {...props} />\n);\n\ntype MessageActionsProps = ComponentProps<'div'>;\n\nconst MessageActions = ({\n className,\n children,\n ...props\n}: MessageActionsProps): ReactNode => (\n <div\n data-slot=\"message-actions\"\n className={cn('flex items-center gap-2 pt-2', className)}\n {...props}\n >\n {children}\n </div>\n);\n\ntype MessageActionProps = ComponentProps<typeof Button> & {\n tooltip?: string;\n label?: string;\n};\n\nconst MessageAction = ({\n tooltip,\n children,\n label,\n className,\n variant = 'ghost',\n size = 'sm',\n ...props\n}: MessageActionProps): ReactNode => {\n const button = (\n <Button\n data-slot=\"message-action\"\n className={cn(\n 'relative icon-sm text-muted-foreground hover:text-base-foreground',\n className\n )}\n size={size}\n type=\"button\"\n variant={variant}\n {...props}\n >\n {children}\n <span className=\"sr-only\">{label || tooltip}</span>\n </Button>\n );\n\n if (tooltip) {\n return (\n <Tooltip>\n <TooltipTrigger render={button} />\n <TooltipContent>\n <p>{tooltip}</p>\n </TooltipContent>\n </Tooltip>\n );\n }\n\n return button;\n};\n\ntype MessageBranchContextType = {\n currentBranch: number;\n totalBranches: number;\n goToPrevious: () => void;\n goToNext: () => void;\n branches: ReactElement[];\n setBranches: (branches: ReactElement[]) => void;\n};\n\nconst MessageBranchContext = createContext<MessageBranchContextType | null>(\n null\n);\n\nconst useMessageBranch = () => {\n const context = useContext(MessageBranchContext);\n\n if (!context) {\n throw new Error(\n 'MessageBranch components must be used within MessageBranch'\n );\n }\n\n return context;\n};\n\ntype MessageBranchProps = HTMLAttributes<HTMLDivElement> & {\n defaultBranch?: number;\n onBranchChange?: (branchIndex: number) => void;\n};\n\nconst MessageBranch = ({\n defaultBranch = 0,\n onBranchChange,\n className,\n ...props\n}: MessageBranchProps): ReactNode => {\n const [currentBranch, setCurrentBranch] = useState(defaultBranch);\n const [branches, setBranches] = useState<ReactElement[]>([]);\n\n const goToPrevious = useCallback(() => {\n setCurrentBranch((prev) => {\n const newBranch = prev > 0 ? prev - 1 : branches.length - 1;\n onBranchChange?.(newBranch);\n return newBranch;\n });\n }, [branches.length, onBranchChange]);\n\n const goToNext = useCallback(() => {\n setCurrentBranch((prev) => {\n const newBranch = prev < branches.length - 1 ? prev + 1 : 0;\n onBranchChange?.(newBranch);\n return newBranch;\n });\n }, [branches.length, onBranchChange]);\n\n const contextValue = useMemo<MessageBranchContextType>(\n () => ({\n currentBranch,\n totalBranches: branches.length,\n goToPrevious,\n goToNext,\n branches,\n setBranches,\n }),\n [currentBranch, branches, goToPrevious, goToNext, setBranches]\n );\n\n return (\n <MessageBranchContext.Provider value={contextValue}>\n <div\n data-slot=\"message-branch\"\n className={cn('grid w-full gap-2 [&>div]:pb-0', className)}\n {...props}\n />\n </MessageBranchContext.Provider>\n );\n};\n\ntype MessageBranchContentProps = HTMLAttributes<HTMLDivElement>;\n\nconst MessageBranchContent = ({\n children,\n ...props\n}: MessageBranchContentProps): ReactNode[] => {\n const { currentBranch, setBranches, branches } = useMessageBranch();\n const childrenArray = useMemo(\n () => (Array.isArray(children) ? children : [children]),\n [children]\n );\n\n useEffect(() => {\n if (branches.length !== childrenArray.length) {\n setBranches(childrenArray);\n }\n }, [childrenArray, branches, setBranches]);\n\n return childrenArray.map((branch, index) => (\n <div\n data-slot=\"message-branch-content\"\n className={cn(\n 'grid gap-2 overflow-hidden [&>div]:pb-0',\n index === currentBranch ? 'block' : 'hidden'\n )}\n key={branch.key}\n {...props}\n >\n {branch}\n </div>\n ));\n};\n\ntype MessageBranchSelectorProps = HTMLAttributes<HTMLDivElement> & {\n from: UIMessage['role'];\n};\n\nconst MessageBranchSelector = ({\n ...props\n}: MessageBranchSelectorProps): ReactNode => {\n const { totalBranches } = useMessageBranch();\n\n if (totalBranches <= 1) {\n return null;\n }\n\n return (\n <ButtonGroup\n data-slot=\"message-branch-selector\"\n className=\"[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md\"\n orientation=\"horizontal\"\n {...props}\n />\n );\n};\n\ntype MessageBranchPreviousProps = ComponentProps<typeof Button>;\n\nconst MessageBranchPrevious = ({\n children,\n ...props\n}: MessageBranchPreviousProps): ReactNode => {\n const { goToPrevious, totalBranches } = useMessageBranch();\n\n return (\n <Button\n data-slot=\"message-branch-previous\"\n aria-label=\"Previous branch\"\n disabled={totalBranches <= 1}\n onClick={goToPrevious}\n size=\"icon-sm\"\n type=\"button\"\n variant=\"ghost\"\n {...props}\n >\n {children ?? <IconChevronLeft size={14} />}\n </Button>\n );\n};\n\ntype MessageBranchNextProps = ComponentProps<typeof Button>;\n\nconst MessageBranchNext = ({\n children,\n ...props\n}: MessageBranchNextProps): ReactNode => {\n const { goToNext, totalBranches } = useMessageBranch();\n\n return (\n <Button\n data-slot=\"message-branch-next\"\n aria-label=\"Next branch\"\n disabled={totalBranches <= 1}\n onClick={goToNext}\n size=\"icon-sm\"\n type=\"button\"\n variant=\"ghost\"\n {...props}\n >\n {children ?? <IconChevronRight size={14} />}\n </Button>\n );\n};\n\ntype MessageBranchPageProps = HTMLAttributes<HTMLSpanElement>;\n\nconst MessageBranchPage = ({\n className,\n ...props\n}: MessageBranchPageProps): ReactNode => {\n const { currentBranch, totalBranches } = useMessageBranch();\n\n return (\n <ButtonGroupText\n data-slot=\"message-branch-page\"\n className={cn(\n 'border-none bg-transparent text-muted-foreground shadow-none px-2',\n className\n )}\n {...props}\n >\n {currentBranch + 1}/{totalBranches}\n </ButtonGroupText>\n );\n};\n\n/** Streamdown discards unrecognised props, so these go on a wrapper instead. */\ntype MessageResponseHostProps = Pick<\n HTMLAttributes<HTMLDivElement>,\n 'id' | 'role' | 'aria-label' | 'aria-labelledby' | 'aria-describedby'\n> & {\n 'data-testid'?: string;\n};\n\ntype MessageResponseProps = ComponentProps<typeof Streamdown> &\n MessageResponseHostProps;\n\ntype MarkdownComponentProps<T extends keyof JSX.IntrinsicElements> =\n JSX.IntrinsicElements[T] & ExtraProps;\n\nconst messageResponseComponents: Components = {\n h1: ({ children }: MarkdownComponentProps<'h1'>) => (\n <h1 className=\"mt-0 mb-2 scroll-m-20 text-xl font-medium tracking-tightest\">\n {children}\n </h1>\n ),\n h2: ({ children }: MarkdownComponentProps<'h2'>) => (\n <h2 className=\"mt-4 mb-1 scroll-m-20 text-lg font-medium tracking-tightest\">\n {children}\n </h2>\n ),\n h3: ({ children }: MarkdownComponentProps<'h3'>) => (\n <h3 className=\"mt-4 mb-1 scroll-m-20 text-base font-medium tracking-tighter\">\n {children}\n </h3>\n ),\n h4: ({ children }: MarkdownComponentProps<'h4'>) => (\n <h4 className=\"mt-2 mb-0 scroll-m-20 text-sm font-medium tracking-normal\">\n {children}\n </h4>\n ),\n h5: ({ children }: MarkdownComponentProps<'h5'>) => (\n <h5 className=\"mt-0 mb-0 scroll-m-20 text-xs font-medium tracking-tighter\">\n {children}\n </h5>\n ),\n h6: ({ children }: MarkdownComponentProps<'h6'>) => (\n <h6 className=\"mt-0 mb-0 scroll-m-20 text-2xs font-medium tracking-tighter\">\n {children}\n </h6>\n ),\n p: ({ children }: MarkdownComponentProps<'p'>) => (\n <p className=\"mt-2 mb-3 text-base font-normal leading-5 tracking-tightest\">\n {children}\n </p>\n ),\n strong: ({ children }: MarkdownComponentProps<'strong'>) => (\n <strong className=\"font-medium\">{children}</strong>\n ),\n em: ({ children }: MarkdownComponentProps<'em'>) => (\n <em className=\"italic\">{children}</em>\n ),\n b: ({ children }: MarkdownComponentProps<'b'>) => (\n <b className=\"font-medium\">{children}</b>\n ),\n i: ({ children }: MarkdownComponentProps<'i'>) => (\n <i className=\"italic\">{children}</i>\n ),\n ul: ({ children }: MarkdownComponentProps<'ul'>) => (\n <ul className=\"ml-8.25 mb-3 pt-2 pl-0 pb-0 list-disc text-base font-normal tracking-tightest\">\n {children}\n </ul>\n ),\n ol: ({ children }: MarkdownComponentProps<'ol'>) => (\n <ol className=\"ml-8.25 mb-3 pt-2 pl-0 pb-0 list-decimal text-base font-normal tracking-tightest\">\n {children}\n </ol>\n ),\n li: ({ children }: MarkdownComponentProps<'li'>) => (\n <li className=\"py-0\">{children}</li>\n ),\n blockquote: ({ children }: MarkdownComponentProps<'blockquote'>) => (\n <blockquote className=\"my-3 pr-2 pl-2 border-l border-l-default text-sm text-muted-foreground font-normal tracking-tight not-italic\">\n {children}\n </blockquote>\n ),\n hr: () => <hr className=\"my-4 border-default\" />,\n a: ({ children, href, ...props }: MarkdownComponentProps<'a'>) => (\n <a\n className=\"text-link-foreground no-underline hover:underline underline-offset-4\"\n href={href}\n {...props}\n >\n {children}\n </a>\n ),\n table: ({ children }: MarkdownComponentProps<'table'>) => (\n <div\n className=\"my-6 overflow-x-auto\"\n tabIndex={0}\n role=\"group\"\n aria-label=\"Atlas AI Chat Table\"\n >\n <table className=\"w-full\">{children}</table>\n </div>\n ),\n thead: ({ children }: MarkdownComponentProps<'thead'>) => (\n <thead>{children}</thead>\n ),\n tbody: ({ children }: MarkdownComponentProps<'tbody'>) => (\n <tbody>{children}</tbody>\n ),\n tr: ({ children }: MarkdownComponentProps<'tr'>) => (\n <tr className=\"m-0 border-t p-0 even:bg-muted-background\">{children}</tr>\n ),\n th: ({ children }: MarkdownComponentProps<'th'>) => (\n <th className=\"border px-4 py-2 text-left font-bold\">{children}</th>\n ),\n td: ({ children }: MarkdownComponentProps<'td'>) => (\n <td className=\"border px-4 py-2 text-left\">{children}</td>\n ),\n};\n\nconst MessageResponseMarkdown = ({\n className,\n components,\n plugins,\n controls,\n portal,\n ...props\n}: ComponentProps<typeof Streamdown>): JSX.Element => {\n const portalContainer = usePortalContainer();\n\n return (\n <Streamdown\n className={cn(\n 'size-full',\n // Blockquote paragraph overrides\n '[&_blockquote_p]:text-sm',\n '[&_blockquote_p]:tracking-tight',\n // Inline code\n '[&_code]:relative',\n '[&_code]:rounded',\n '[&_code]:bg-muted-background',\n '[&_code]:px-[0.3rem]',\n '[&_code]:py-[0.2rem]',\n '[&_code]:font-mono',\n '[&_code]:text-sm',\n '[&_code]:font-semibold',\n // Code blocks (Streamdown container)\n '[&_div[data-streamdown=\"code-block\"]]:my-4',\n '[&_div[data-streamdown=\"code-block\"]]:w-full',\n '[&_div[data-streamdown=\"code-block\"]]:overflow-hidden',\n '[&_div[data-streamdown=\"code-block\"]]:rounded-xl',\n '[&_div[data-streamdown=\"code-block\"]]:border',\n '[&_div[data-streamdown=\"code-block\"]]:border-default',\n // Code block header\n '[&_div[data-streamdown=\"code-block-header\"]]:flex',\n '[&_div[data-streamdown=\"code-block-header\"]]:items-center',\n '[&_div[data-streamdown=\"code-block-header\"]]:justify-between',\n '[&_div[data-streamdown=\"code-block-header\"]]:bg-muted-background/80',\n '[&_div[data-streamdown=\"code-block-header\"]]:px-4',\n '[&_div[data-streamdown=\"code-block-header\"]]:py-3',\n '[&_div[data-streamdown=\"code-block-header\"]]:text-xs',\n '[&_div[data-streamdown=\"code-block-header\"]]:text-muted-foreground',\n // Pre element inside code block\n '[&_div[data-streamdown=\"code-block\"]_pre]:m-0',\n '[&_div[data-streamdown=\"code-block\"]_pre]:overflow-x-auto',\n '[&_div[data-streamdown=\"code-block\"]_pre]:border-t',\n '[&_div[data-streamdown=\"code-block\"]_pre]:border-default',\n '[&_div[data-streamdown=\"code-block\"]_pre]:bg-card-background!',\n '[&_div[data-streamdown=\"code-block\"]_pre]:p-4',\n '[&_div[data-streamdown=\"code-block\"]_pre]:text-sm',\n '[&_div[data-streamdown=\"code-block\"]_pre]:text-medium-foreground!',\n // Code element inside pre\n '[&_div[data-streamdown=\"code-block\"]_pre_code]:static',\n '[&_div[data-streamdown=\"code-block\"]_pre_code]:rounded-none',\n '[&_div[data-streamdown=\"code-block\"]_pre_code]:bg-transparent',\n '[&_div[data-streamdown=\"code-block\"]_pre_code]:p-0',\n '[&_div[data-streamdown=\"code-block\"]_pre_code]:font-mono',\n '[&_div[data-streamdown=\"code-block\"]_pre_code]:text-sm',\n '[&_div[data-streamdown=\"code-block\"]_pre_code]:font-normal',\n // Code block buttons\n '[&_button[data-streamdown=\"code-block-copy-button\"]]:cursor-pointer',\n '[&_button[data-streamdown=\"code-block-copy-button\"]]:p-1',\n '[&_button[data-streamdown=\"code-block-copy-button\"]]:text-muted-foreground',\n '[&_button[data-streamdown=\"code-block-copy-button\"]]:transition-all',\n '[&_button[data-streamdown=\"code-block-copy-button\"]]:hover:text-base-foreground',\n '[&_button[data-streamdown=\"code-block-download-button\"]]:cursor-pointer',\n '[&_button[data-streamdown=\"code-block-download-button\"]]:p-1',\n '[&_button[data-streamdown=\"code-block-download-button\"]]:text-muted-foreground',\n '[&_button[data-streamdown=\"code-block-download-button\"]]:transition-all',\n '[&_button[data-streamdown=\"code-block-download-button\"]]:hover:text-base-foreground',\n // Regular pre blocks (not in Streamdown code blocks)\n '[&_pre:not([data-streamdown])]:my-3',\n '[&_pre:not([data-streamdown])]:mx-0',\n '[&_pre:not([data-streamdown])]:overflow-x-auto',\n '[&_pre:not([data-streamdown])]:rounded-md',\n '[&_pre:not([data-streamdown])]:border',\n '[&_pre:not([data-streamdown])]:bg-card-background',\n '[&_pre:not([data-streamdown])]:p-4',\n '[&_pre:not([data-streamdown])]:text-medium-foreground',\n '[&_pre:not([data-streamdown])]:text-sm',\n '[&_pre:not([data-streamdown])_code]:static',\n '[&_pre:not([data-streamdown])_code]:rounded-none',\n '[&_pre:not([data-streamdown])_code]:bg-transparent',\n '[&_pre:not([data-streamdown])_code]:px-0',\n '[&_pre:not([data-streamdown])_code]:py-0',\n '[&_pre:not([data-streamdown])_code]:font-mono',\n '[&_pre:not([data-streamdown])_code]:text-sm',\n '[&_pre:not([data-streamdown])_code]:font-normal',\n // Mermaid diagram blocks\n '[&_div[data-streamdown=\"mermaid-block\"]]:bg-card-background',\n '[&_div[data-streamdown=\"mermaid-block\"]]:text-base-foreground',\n '[&_div[data-streamdown=\"mermaid-block\"]]:flex',\n '[&_div[data-streamdown=\"mermaid-block\"]]:flex-col',\n '[&_div[data-streamdown=\"mermaid-block\"]]:rounded-lg',\n '[&_div[data-streamdown=\"mermaid-block\"]]:hover:bg-base-background-hover',\n '[&_div[data-streamdown=\"mermaid-block\"]]:border-0',\n // Positioning context for the action strip (see below)\n '[&_div[data-streamdown=\"mermaid-block\"]]:relative',\n // Nested scroll + sticky + pointer-events breaks hit-testing on Mermaid Copy/Download\n // (same class of issue as github.com/vercel/streamdown/issues/494). Force absolute strip.\n '[&_div[data-streamdown=\"mermaid-block\"]>div:has([data-streamdown=\"mermaid-block-actions\"])]:!absolute',\n '[&_div[data-streamdown=\"mermaid-block\"]>div:has([data-streamdown=\"mermaid-block-actions\"])]:!top-2',\n '[&_div[data-streamdown=\"mermaid-block\"]>div:has([data-streamdown=\"mermaid-block-actions\"])]:!right-2',\n '[&_div[data-streamdown=\"mermaid-block\"]>div:has([data-streamdown=\"mermaid-block-actions\"])]:!z-10',\n '[&_div[data-streamdown=\"mermaid-block\"]>div:has([data-streamdown=\"mermaid-block-actions\"])]:!mt-0',\n '[&_div[data-streamdown=\"mermaid-block\"]>div:has([data-streamdown=\"mermaid-block-actions\"])]:!pointer-events-auto',\n // Ensure mermaid container is tall enough for the toolbar (pan/zoom + actions)\n '[&_div[data-streamdown=\"mermaid-block\"]_.relative.w-full]:!min-h-28',\n // KaTeX sizing (overflow rules live in styles.source.css)\n '[&_.katex-display]:my-3',\n '[&_.katex]:text-[1em]',\n // First and last child margin resets\n '[&>*:first-child]:mt-0',\n '[&>*:last-child]:mb-0',\n className\n )}\n components={{ ...messageResponseComponents, ...components }}\n controls={controls ?? MESSAGE_RESPONSE_DEFAULT_STREAMDOWN_CONTROLS}\n plugins={{ ...plugins, mermaid: mermaidPlugin }}\n portal={portal ?? portalContainer}\n {...props}\n />\n );\n};\n\nconst MessageResponse = ({\n id,\n role,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'data-testid': dataTestId,\n ...props\n}: MessageResponseProps): JSX.Element => (\n <div\n data-slot=\"message-response\"\n id={id}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n data-testid={dataTestId}\n >\n <MessageResponseMarkdown {...props} />\n </div>\n);\n\ntype MessageAttachmentProps = HTMLAttributes<HTMLDivElement> & {\n data: FileUIPart;\n className?: string;\n onRemove?: () => void;\n};\n\nfunction MessageAttachment({\n data,\n className,\n onRemove,\n ...props\n}: MessageAttachmentProps): ReactNode {\n const filename = data.filename || '';\n const mediaType =\n data.mediaType?.startsWith('image/') && data.url ? 'image' : 'file';\n const isImage = mediaType === 'image';\n const attachmentLabel = filename || (isImage ? 'Image' : 'Attachment');\n\n return (\n <div\n data-slot=\"message-attachment\"\n className={cn(\n 'group relative size-24 overflow-hidden rounded-lg',\n className\n )}\n {...props}\n >\n {isImage ? (\n <>\n <img\n alt={filename || 'attachment'}\n className=\"size-full object-cover\"\n height={100}\n src={data.url}\n width={100}\n />\n {onRemove && (\n <Button\n aria-label=\"Remove attachment\"\n className=\"absolute top-2 right-2 size-6 rounded-full bg-card-background/80 p-0 opacity-0 backdrop-blur-sm transition-opacity hover:bg-card-background group-hover:opacity-100 [&>svg]:size-3\"\n onClick={(e) => {\n e.stopPropagation();\n onRemove();\n }}\n type=\"button\"\n variant=\"ghost\"\n >\n <IconX />\n <span className=\"sr-only\">Remove</span>\n </Button>\n )}\n </>\n ) : (\n <>\n <Tooltip>\n <TooltipTrigger\n render={\n <div className=\"flex size-full shrink-0 items-center justify-center rounded-lg bg-muted-background text-muted-foreground\">\n <IconPaperclip className=\"size-4\" />\n </div>\n }\n />\n <TooltipContent>\n <p>{attachmentLabel}</p>\n </TooltipContent>\n </Tooltip>\n {onRemove && (\n <Button\n aria-label=\"Remove attachment\"\n className=\"size-6 shrink-0 rounded-full p-0 opacity-0 transition-opacity hover:bg-base-background-hover group-hover:opacity-100 [&>svg]:size-3\"\n onClick={(e) => {\n e.stopPropagation();\n onRemove();\n }}\n type=\"button\"\n variant=\"ghost\"\n >\n <IconX />\n <span className=\"sr-only\">Remove</span>\n </Button>\n )}\n </>\n )}\n </div>\n );\n}\n\ntype MessageAttachmentsProps = ComponentProps<'div'>;\n\nfunction MessageAttachments({\n children,\n className,\n ...props\n}: MessageAttachmentsProps): ReactNode {\n if (!children) {\n return null;\n }\n\n return (\n <div\n data-slot=\"message-attachments\"\n className={cn(\n 'ml-auto flex w-fit flex-wrap items-start gap-2',\n className\n )}\n {...props}\n >\n {children}\n </div>\n );\n}\n\ntype MessageToolbarProps = ComponentProps<'div'>;\n\nconst MessageToolbar = ({\n className,\n children,\n ...props\n}: MessageToolbarProps): ReactNode => (\n <div\n data-slot=\"message-toolbar\"\n className={cn(\n 'mt-4 flex w-full items-center justify-between gap-4',\n className\n )}\n {...props}\n >\n {children}\n </div>\n);\n\nexport {\n Message,\n MessageAction,\n MessageActions,\n MessageAttachment,\n MessageAttachments,\n MessageAvatar,\n MessageAvatarIcon,\n MessageBranch,\n MessageBranchContent,\n MessageBranchNext,\n MessageBranchPage,\n MessageBranchPrevious,\n MessageBranchSelector,\n MessageContent,\n MessageResponse,\n MessageToolbar,\n};\n"],"names":["createContext","useCallback","useContext","useEffect","useMemo","useState","mermaid","mermaidPlugin","IconChevronLeft","IconChevronRight","IconPaperclip","IconX","Streamdown","usePortalContainer","cn","getInitials","Avatar","AvatarFallback","AvatarIcon","AvatarImage","Button","ButtonGroup","ButtonGroupText","Tooltip","TooltipContent","TooltipTrigger","MESSAGE_RESPONSE_DEFAULT_STREAMDOWN_CONTROLS","Message","className","isResponse","props","div","data-slot","MessageContent","children","MessageAvatar","avatarUrl","name","variant","sizes","fallbackText","alt","src","MessageAvatarIcon","MessageActions","MessageAction","tooltip","label","size","button","type","span","render","p","MessageBranchContext","useMessageBranch","context","Error","MessageBranch","defaultBranch","onBranchChange","currentBranch","setCurrentBranch","branches","setBranches","goToPrevious","prev","newBranch","length","goToNext","contextValue","totalBranches","Provider","value","MessageBranchContent","childrenArray","Array","isArray","map","branch","index","key","MessageBranchSelector","orientation","MessageBranchPrevious","aria-label","disabled","onClick","MessageBranchNext","MessageBranchPage","messageResponseComponents","h1","h2","h3","h4","h5","h6","strong","em","b","i","ul","ol","li","blockquote","hr","a","href","table","tabIndex","role","thead","tbody","tr","th","td","MessageResponseMarkdown","components","plugins","controls","portal","portalContainer","MessageResponse","id","ariaLabel","ariaLabelledBy","ariaDescribedBy","dataTestId","aria-labelledby","aria-describedby","data-testid","MessageAttachment","data","onRemove","filename","mediaType","startsWith","url","isImage","attachmentLabel","img","height","width","e","stopPropagation","MessageAttachments","MessageToolbar"],"mappings":";AAMA,SACEA,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACH,QAAQ;AAEf,SAASC,WAAWC,aAAa,QAAQ,sBAAsB;AAC/D,SACEC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,EACbC,KAAK,QACA,sBAAsB;AAG7B,SAASC,UAAU,QAAQ,aAAa;AAGxC,SAASC,kBAAkB,QAAQ,8CAA2C;AAC9E,SAASC,EAAE,EAAEC,WAAW,QAAQ,2BAAwB;AACxD,SACEC,MAAM,EACNC,cAAc,EACdC,UAAU,EACVC,WAA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AAI,CAAC,EAAEhF,QAAQ,EAAgC,iBAC7C,KAACgF;YAAGtF,WAAU;sBAAwCM;;IAExDiF,IAAI,CAAC,EAAEjF,QAAQ,EAAgC,iBAC7C,KAACiF;YAAGvF,WAAU;sBAA8BM;;AAEhD;AAEA,MAAMkF,0BAA0B,CAAC,EAC/BxF,SAAS,EACTyF,UAAU,EACVC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACN,GAAG1F,OAC+B;IAClC,MAAM2F,kBAAkB5G;IAExB,qBACE,KAACD;QACCgB,WAAWd,GACT,aACA,iCAAiC;QACjC,4BACA,mCACA,cAAc;QACd,qBACA,oBACA,gCACA,wBACA,wBACA,sBACA,oBACA,0BACA,qCAAqC;QACrC,8CACA,gDACA,yDACA,oDACA,gDACA,wDACA,oBAAoB;QACpB,qDACA,6DACA,gEACA,uEACA,qDACA,qDACA,wDACA,sEACA,gCAAgC;QAChC,iDACA,6DACA,sDACA,4DACA,iEACA,iDACA,qDACA,qEACA,0BAA0B;QAC1B,yDACA,+DACA,iEACA,sDACA,4DACA,0DACA,8DACA,qBAAqB;QACrB,uEACA,4DACA,8EACA,uEACA,mFACA,2EACA,gEACA,kFACA,2EACA,uFACA,qDAAqD;QACrD,uCACA,uCACA,kDACA,6CACA,yCACA,qDACA,sCACA,yDACA,0CACA,8CACA,oDACA,sDACA,4CACA,4CACA,iDACA,+CACA,mDACA,yBAAyB;QACzB,+DACA,iEACA,iDACA,qDACA,uDACA,2EACA,qDACA,uDAAuD;QACvD,qDACA,sFAAsF;QACtF,0FAA0F;QAC1F,yGACA,sGACA,wGACA,qGACA,qGACA,oHACA,+EAA+E;QAC/E,uEACA,0DAA0D;QAC1D,2BACA,yBACA,qCAAqC;QACrC,0BACA,yBACAc;QAEFyF,YAAY;YAAE,GAAG3B,yBAAyB;YAAE,GAAG2B,UAAU;QAAC;QAC1DE,UAAUA,YAAY7F;QACtB4F,SAAS;YAAE,GAAGA,OAAO;YAAEhH,SAASC;QAAc;QAC9CiH,Q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AW;oBACXzD,WAAU;oBACV2D,SAAS,CAACwD;wBACRA,EAAEC,eAAe;wBACjBX;oBACF;oBACAnF,MAAK;oBACLZ,SAAQ;;sCAER,KAAC3B;sCACD,KAACwC;4BAAKvB,WAAU;sCAAU;;;;;;;AAOxC;AAIA,SAASqH,mBAAmB,EAC1B/G,QAAQ,EACRN,SAAS,EACT,GAAGE,OACqB;IACxB,IAAI,CAACI,UAAU;QACb,OAAO;IACT;IAEA,qBACE,KAACH;QACCC,aAAU;QACVJ,WAAWd,GACT,kDACAc;QAED,GAAGE,KAAK;kBAERI;;AAGP;AAIA,MAAMgH,iBAAiB,CAAC,EACtBtH,SAAS,EACTM,QAAQ,EACR,GAAGJ,OACiB,iBACpB,KAACC;QACCC,aAAU;QACVJ,WAAWd,GACT,uDACAc;QAED,GAAGE,KAAK;kBAERI;;AAIL,SACEP,OAAO,EACPkB,aAAa,EACbD,cAAc,EACduF,iBAAiB,EACjBc,kBAAkB,EAClB9G,aAAa,EACbQ,iBAAiB,EACjBe,aAAa,EACbgB,oBAAoB,EACpBc,iBAAiB,EACjBC,iBAAiB,EACjBL,qBAAqB,EACrBF,qBAAqB,EACrBjD,cAAc,EACdyF,eAAe,EACfwB,cAAc,GACd"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/message/message.tsx"],"sourcesContent":["import type {\n ComponentProps,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n} from 'react';\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport { mermaid as mermaidPlugin } from '@streamdown/mermaid';\nimport {\n IconChevronLeft,\n IconChevronRight,\n IconPaperclip,\n IconX,\n} from '@tabler/icons-react';\nimport type { JSX } from 'react/jsx-runtime';\nimport type { Components, ExtraProps } from 'streamdown';\nimport { Streamdown } from 'streamdown';\n\nimport type { FileUIPart, UIMessage } from '../../../../lib/ai/types';\nimport {\n PortalContainerContext,\n usePortalContainer,\n} from '../../../../lib/portal-container-context';\nimport { cn, getInitials } from '../../../../lib/utils';\nimport {\n Avatar,\n AvatarFallback,\n AvatarIcon,\n AvatarImage,\n} from '../avatar/avatar';\nimport { Button } from '../button/button';\nimport { ButtonGroup, ButtonGroupText } from '../button-group/button-group';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '../tooltip/tooltip';\n\nimport { MESSAGE_RESPONSE_DEFAULT_STREAMDOWN_CONTROLS } from './message-response-default-streamdown-controls';\n\ntype MessageProps = HTMLAttributes<HTMLDivElement> & {\n isResponse?: boolean;\n};\n\nconst Message = ({\n className,\n isResponse = false,\n ...props\n}: MessageProps): ReactNode => (\n <div\n data-slot=\"message\"\n className={cn(\n 'group flex w-full items-start justify-start gap-3 mb-0 py-3',\n isResponse ? 'is-assistant items-start' : 'is-user flex-row-reverse',\n className\n )}\n {...props}\n />\n);\n\ntype MessageContentProps = HTMLAttributes<HTMLDivElement>;\n\nconst MessageContent = ({\n children,\n className,\n ...props\n}: MessageContentProps): ReactNode => (\n <div\n data-slot=\"message-content\"\n className={cn(\n 'is-user:dark flex flex-col gap-4 rounded-md text-base leading-tight tracking-tightest',\n 'max-w-4/5',\n // The table grid's rows are absolutely positioned, so they don't widen the content; give tables the full width rather than wrapping cells to fit the headers.\n 'has-data-[slot=message-table]:w-full',\n 'group-[.is-user]:overflow-hidden group-[.is-user]:bg-medium-background group-[.is-user]:p-2 group-[.is-user]:text-base-foreground',\n 'group-[.is-assistant]:text-base-foreground group-[.is-assistant]:pt-1',\n className\n )}\n {...props}\n >\n {children}\n </div>\n);\n\ntype MessageAvatarProps = ComponentProps<typeof Avatar> & {\n avatarUrl?: string;\n name?: string;\n};\n\nconst MessageAvatar = ({\n avatarUrl,\n name,\n className,\n children,\n variant,\n sizes,\n ...props\n}: MessageAvatarProps): ReactNode => {\n const fallbackText = name ? getInitials(name) : 'ME';\n\n return (\n <Avatar\n data-slot=\"message-avatar\"\n className={cn('size-7 group-[.is-user]:mt-1', className)}\n variant={variant}\n sizes={sizes}\n {...props}\n >\n {children || (\n <>\n {avatarUrl && (\n <AvatarImage\n alt={name || ''}\n className=\"mt-0 mb-0\"\n src={avatarUrl}\n />\n )}\n <AvatarFallback>{fallbackText}</AvatarFallback>\n </>\n )}\n </Avatar>\n );\n};\n\ntype MessageAvatarIconProps = ComponentProps<typeof AvatarIcon>;\n\nconst MessageAvatarIcon = (props: MessageAvatarIconProps): ReactNode => (\n <AvatarIcon data-slot=\"message-avatar-icon\" {...props} />\n);\n\ntype MessageActionsProps = ComponentProps<'div'>;\n\nconst MessageActions = ({\n className,\n children,\n ...props\n}: MessageActionsProps): ReactNode => (\n <div\n data-slot=\"message-actions\"\n className={cn('flex items-center gap-2 pt-2', className)}\n {...props}\n >\n {children}\n </div>\n);\n\ntype MessageActionProps = ComponentProps<typeof Button> & {\n tooltip?: string;\n label?: string;\n};\n\nconst MessageAction = ({\n tooltip,\n children,\n label,\n className,\n variant = 'ghost',\n size = 'sm',\n ...props\n}: MessageActionProps): ReactNode => {\n const button = (\n <Button\n data-slot=\"message-action\"\n className={cn(\n 'relative icon-sm text-muted-foreground hover:text-base-foreground',\n className\n )}\n size={size}\n type=\"button\"\n variant={variant}\n {...props}\n >\n {children}\n <span className=\"sr-only\">{label || tooltip}</span>\n </Button>\n );\n\n if (tooltip) {\n return (\n <Tooltip>\n <TooltipTrigger render={button} />\n <TooltipContent>\n <p>{tooltip}</p>\n </TooltipContent>\n </Tooltip>\n );\n }\n\n return button;\n};\n\ntype MessageBranchContextType = {\n currentBranch: number;\n totalBranches: number;\n goToPrevious: () => void;\n goToNext: () => void;\n branches: ReactElement[];\n setBranches: (branches: ReactElement[]) => void;\n};\n\nconst MessageBranchContext = createContext<MessageBranchContextType | null>(\n null\n);\n\nconst useMessageBranch = () => {\n const context = useContext(MessageBranchContext);\n\n if (!context) {\n throw new Error(\n 'MessageBranch components must be used within MessageBranch'\n );\n }\n\n return context;\n};\n\ntype MessageBranchProps = HTMLAttributes<HTMLDivElement> & {\n defaultBranch?: number;\n onBranchChange?: (branchIndex: number) => void;\n};\n\nconst MessageBranch = ({\n defaultBranch = 0,\n onBranchChange,\n className,\n ...props\n}: MessageBranchProps): ReactNode => {\n const [currentBranch, setCurrentBranch] = useState(defaultBranch);\n const [branches, setBranches] = useState<ReactElement[]>([]);\n\n const goToPrevious = useCallback(() => {\n setCurrentBranch((prev) => {\n const newBranch = prev > 0 ? prev - 1 : branches.length - 1;\n onBranchChange?.(newBranch);\n return newBranch;\n });\n }, [branches.length, onBranchChange]);\n\n const goToNext = useCallback(() => {\n setCurrentBranch((prev) => {\n const newBranch = prev < branches.length - 1 ? prev + 1 : 0;\n onBranchChange?.(newBranch);\n return newBranch;\n });\n }, [branches.length, onBranchChange]);\n\n const contextValue = useMemo<MessageBranchContextType>(\n () => ({\n currentBranch,\n totalBranches: branches.length,\n goToPrevious,\n goToNext,\n branches,\n setBranches,\n }),\n [currentBranch, branches, goToPrevious, goToNext, setBranches]\n );\n\n return (\n <MessageBranchContext.Provider value={contextValue}>\n <div\n data-slot=\"message-branch\"\n className={cn('grid w-full gap-2 [&>div]:pb-0', className)}\n {...props}\n />\n </MessageBranchContext.Provider>\n );\n};\n\ntype MessageBranchContentProps = HTMLAttributes<HTMLDivElement>;\n\nconst MessageBranchContent = ({\n children,\n ...props\n}: MessageBranchContentProps): ReactNode[] => {\n const { currentBranch, setBranches, branches } = useMessageBranch();\n const childrenArray = useMemo(\n () => (Array.isArray(children) ? children : [children]),\n [children]\n );\n\n useEffect(() => {\n if (branches.length !== childrenArray.length) {\n setBranches(childrenArray);\n }\n }, [childrenArray, branches, setBranches]);\n\n return childrenArray.map((branch, index) => (\n <div\n data-slot=\"message-branch-content\"\n className={cn(\n 'grid gap-2 overflow-hidden [&>div]:pb-0',\n index === currentBranch ? 'block' : 'hidden'\n )}\n key={branch.key}\n {...props}\n >\n {branch}\n </div>\n ));\n};\n\ntype MessageBranchSelectorProps = HTMLAttributes<HTMLDivElement> & {\n from: UIMessage['role'];\n};\n\nconst MessageBranchSelector = ({\n ...props\n}: MessageBranchSelectorProps): ReactNode => {\n const { totalBranches } = useMessageBranch();\n\n if (totalBranches <= 1) {\n return null;\n }\n\n return (\n <ButtonGroup\n data-slot=\"message-branch-selector\"\n className=\"[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md\"\n orientation=\"horizontal\"\n {...props}\n />\n );\n};\n\ntype MessageBranchPreviousProps = ComponentProps<typeof Button>;\n\nconst MessageBranchPrevious = ({\n children,\n ...props\n}: MessageBranchPreviousProps): ReactNode => {\n const { goToPrevious, totalBranches } = useMessageBranch();\n\n return (\n <Button\n data-slot=\"message-branch-previous\"\n aria-label=\"Previous branch\"\n disabled={totalBranches <= 1}\n onClick={goToPrevious}\n size=\"icon-sm\"\n type=\"button\"\n variant=\"ghost\"\n {...props}\n >\n {children ?? <IconChevronLeft size={14} />}\n </Button>\n );\n};\n\ntype MessageBranchNextProps = ComponentProps<typeof Button>;\n\nconst MessageBranchNext = ({\n children,\n ...props\n}: MessageBranchNextProps): ReactNode => {\n const { goToNext, totalBranches } = useMessageBranch();\n\n return (\n <Button\n data-slot=\"message-branch-next\"\n aria-label=\"Next branch\"\n disabled={totalBranches <= 1}\n onClick={goToNext}\n size=\"icon-sm\"\n type=\"button\"\n variant=\"ghost\"\n {...props}\n >\n {children ?? <IconChevronRight size={14} />}\n </Button>\n );\n};\n\ntype MessageBranchPageProps = HTMLAttributes<HTMLSpanElement>;\n\nconst MessageBranchPage = ({\n className,\n ...props\n}: MessageBranchPageProps): ReactNode => {\n const { currentBranch, totalBranches } = useMessageBranch();\n\n return (\n <ButtonGroupText\n data-slot=\"message-branch-page\"\n className={cn(\n 'border-none bg-transparent text-muted-foreground shadow-none px-2',\n className\n )}\n {...props}\n >\n {currentBranch + 1}/{totalBranches}\n </ButtonGroupText>\n );\n};\n\n/** Streamdown discards unrecognised props, so these go on a wrapper instead. */\ntype MessageResponseHostProps = Pick<\n HTMLAttributes<HTMLDivElement>,\n 'id' | 'role' | 'aria-label' | 'aria-labelledby' | 'aria-describedby'\n> & {\n 'data-testid'?: string;\n};\n\ntype MessageResponseProps = ComponentProps<typeof Streamdown> &\n MessageResponseHostProps;\n\ntype MarkdownComponentProps<T extends keyof JSX.IntrinsicElements> =\n JSX.IntrinsicElements[T] & ExtraProps;\n\nconst messageResponseComponents: Components = {\n h1: ({ children }: MarkdownComponentProps<'h1'>) => (\n <h1 className=\"mt-0 mb-2 scroll-m-20 text-xl font-medium tracking-tightest\">\n {children}\n </h1>\n ),\n h2: ({ children }: MarkdownComponentProps<'h2'>) => (\n <h2 className=\"mt-4 mb-1 scroll-m-20 text-lg font-medium tracking-tightest\">\n {children}\n </h2>\n ),\n h3: ({ children }: MarkdownComponentProps<'h3'>) => (\n <h3 className=\"mt-4 mb-1 scroll-m-20 text-base font-medium tracking-tighter\">\n {children}\n </h3>\n ),\n h4: ({ children }: MarkdownComponentProps<'h4'>) => (\n <h4 className=\"mt-2 mb-0 scroll-m-20 text-sm font-medium tracking-normal\">\n {children}\n </h4>\n ),\n h5: ({ children }: MarkdownComponentProps<'h5'>) => (\n <h5 className=\"mt-0 mb-0 scroll-m-20 text-xs font-medium tracking-tighter\">\n {children}\n </h5>\n ),\n h6: ({ children }: MarkdownComponentProps<'h6'>) => (\n <h6 className=\"mt-0 mb-0 scroll-m-20 text-2xs font-medium tracking-tighter\">\n {children}\n </h6>\n ),\n p: ({ children }: MarkdownComponentProps<'p'>) => (\n <p className=\"mt-2 mb-3 text-base font-normal leading-5 tracking-tightest\">\n {children}\n </p>\n ),\n strong: ({ children }: MarkdownComponentProps<'strong'>) => (\n <strong className=\"font-medium\">{children}</strong>\n ),\n em: ({ children }: MarkdownComponentProps<'em'>) => (\n <em className=\"italic\">{children}</em>\n ),\n b: ({ children }: MarkdownComponentProps<'b'>) => (\n <b className=\"font-medium\">{children}</b>\n ),\n i: ({ children }: MarkdownComponentProps<'i'>) => (\n <i className=\"italic\">{children}</i>\n ),\n ul: ({ children }: MarkdownComponentProps<'ul'>) => (\n <ul className=\"ml-8.25 mb-3 pt-2 pl-0 pb-0 list-disc text-base font-normal tracking-tightest\">\n {children}\n </ul>\n ),\n ol: ({ children }: MarkdownComponentProps<'ol'>) => (\n <ol className=\"ml-8.25 mb-3 pt-2 pl-0 pb-0 list-decimal text-base font-normal tracking-tightest\">\n {children}\n </ol>\n ),\n li: ({ children }: MarkdownComponentProps<'li'>) => (\n <li className=\"py-0\">{children}</li>\n ),\n blockquote: ({ children }: MarkdownComponentProps<'blockquote'>) => (\n <blockquote className=\"my-3 pr-2 pl-2 border-l border-l-default text-sm text-muted-foreground font-normal tracking-tight not-italic\">\n {children}\n </blockquote>\n ),\n hr: () => <hr className=\"my-4 border-default\" />,\n a: ({ children, href, ...props }: MarkdownComponentProps<'a'>) => (\n <a\n className=\"text-link-foreground no-underline hover:underline underline-offset-4\"\n href={href}\n {...props}\n >\n {children}\n </a>\n ),\n table: ({ children }: MarkdownComponentProps<'table'>) => (\n <div\n className=\"my-6 overflow-x-auto\"\n tabIndex={0}\n role=\"group\"\n aria-label=\"Atlas AI Chat Table\"\n >\n <table className=\"w-full\">{children}</table>\n </div>\n ),\n thead: ({ children }: MarkdownComponentProps<'thead'>) => (\n <thead>{children}</thead>\n ),\n tbody: ({ children }: MarkdownComponentProps<'tbody'>) => (\n <tbody>{children}</tbody>\n ),\n tr: ({ children }: MarkdownComponentProps<'tr'>) => (\n <tr className=\"m-0 border-t p-0 even:bg-muted-background\">{children}</tr>\n ),\n th: ({ children }: MarkdownComponentProps<'th'>) => (\n <th className=\"border px-4 py-2 text-left font-bold\">{children}</th>\n ),\n td: ({ children }: MarkdownComponentProps<'td'>) => (\n <td className=\"border px-4 py-2 text-left\">{children}</td>\n ),\n};\n\nconst MessageResponseMarkdown = ({\n className,\n components,\n plugins,\n controls,\n portal,\n ...props\n}: ComponentProps<typeof Streamdown>): JSX.Element => {\n const portalContainer = usePortalContainer();\n\n return (\n <Streamdown\n className={cn(\n 'size-full',\n // Blockquote paragraph overrides\n '[&_blockquote_p]:text-sm',\n '[&_blockquote_p]:tracking-tight',\n // Inline code\n '[&_code]:relative',\n '[&_code]:rounded',\n '[&_code]:bg-muted-background',\n '[&_code]:px-[0.3rem]',\n '[&_code]:py-[0.2rem]',\n '[&_code]:font-mono',\n '[&_code]:text-sm',\n '[&_code]:font-semibold',\n // Code blocks (Streamdown container)\n '[&_div[data-streamdown=\"code-block\"]]:my-4',\n '[&_div[data-streamdown=\"code-block\"]]:w-full',\n '[&_div[data-streamdown=\"code-block\"]]:overflow-hidden',\n '[&_div[data-streamdown=\"code-block\"]]:rounded-xl',\n '[&_div[data-streamdown=\"code-block\"]]:border',\n '[&_div[data-streamdown=\"code-block\"]]:border-default',\n // Code block header\n '[&_div[data-streamdown=\"code-block-header\"]]:flex',\n '[&_div[data-streamdown=\"code-block-header\"]]:items-center',\n '[&_div[data-streamdown=\"code-block-header\"]]:justify-between',\n '[&_div[data-streamdown=\"code-block-header\"]]:bg-muted-background/80',\n '[&_div[data-streamdown=\"code-block-header\"]]:px-4',\n '[&_div[data-streamdown=\"code-block-header\"]]:py-3',\n '[&_div[data-streamdown=\"code-block-header\"]]:text-xs',\n '[&_div[data-streamdown=\"code-block-header\"]]:text-muted-foreground',\n // Pre element inside code block\n '[&_div[data-streamdown=\"code-block\"]_pre]:m-0',\n '[&_div[data-streamdown=\"code-block\"]_pre]:overflow-x-auto',\n '[&_div[data-streamdown=\"code-block\"]_pre]:border-t',\n '[&_div[data-streamdown=\"code-block\"]_pre]:border-default',\n '[&_div[data-streamdown=\"code-block\"]_pre]:bg-card-background!',\n '[&_div[data-streamdown=\"code-block\"]_pre]:p-4',\n '[&_div[data-streamdown=\"code-block\"]_pre]:text-sm',\n '[&_div[data-streamdown=\"code-block\"]_pre]:text-medium-foreground!',\n // Code element inside pre\n '[&_div[data-streamdown=\"code-block\"]_pre_code]:static',\n '[&_div[data-streamdown=\"code-block\"]_pre_code]:rounded-none',\n '[&_div[data-streamdown=\"code-block\"]_pre_code]:bg-transparent',\n '[&_div[data-streamdown=\"code-block\"]_pre_code]:p-0',\n '[&_div[data-streamdown=\"code-block\"]_pre_code]:font-mono',\n '[&_div[data-streamdown=\"code-block\"]_pre_code]:text-sm',\n '[&_div[data-streamdown=\"code-block\"]_pre_code]:font-normal',\n // Code block buttons\n '[&_button[data-streamdown=\"code-block-copy-button\"]]:cursor-pointer',\n '[&_button[data-streamdown=\"code-block-copy-button\"]]:p-1',\n '[&_button[data-streamdown=\"code-block-copy-button\"]]:text-muted-foreground',\n '[&_button[data-streamdown=\"code-block-copy-button\"]]:transition-all',\n '[&_button[data-streamdown=\"code-block-copy-button\"]]:hover:text-base-foreground',\n '[&_button[data-streamdown=\"code-block-download-button\"]]:cursor-pointer',\n '[&_button[data-streamdown=\"code-block-download-button\"]]:p-1',\n '[&_button[data-streamdown=\"code-block-download-button\"]]:text-muted-foreground',\n '[&_button[data-streamdown=\"code-block-download-button\"]]:transition-all',\n '[&_button[data-streamdown=\"code-block-download-button\"]]:hover:text-base-foreground',\n // Regular pre blocks (not in Streamdown code blocks)\n '[&_pre:not([data-streamdown])]:my-3',\n '[&_pre:not([data-streamdown])]:mx-0',\n '[&_pre:not([data-streamdown])]:overflow-x-auto',\n '[&_pre:not([data-streamdown])]:rounded-md',\n '[&_pre:not([data-streamdown])]:border',\n '[&_pre:not([data-streamdown])]:bg-card-background',\n '[&_pre:not([data-streamdown])]:p-4',\n '[&_pre:not([data-streamdown])]:text-medium-foreground',\n '[&_pre:not([data-streamdown])]:text-sm',\n '[&_pre:not([data-streamdown])_code]:static',\n '[&_pre:not([data-streamdown])_code]:rounded-none',\n '[&_pre:not([data-streamdown])_code]:bg-transparent',\n '[&_pre:not([data-streamdown])_code]:px-0',\n '[&_pre:not([data-streamdown])_code]:py-0',\n '[&_pre:not([data-streamdown])_code]:font-mono',\n '[&_pre:not([data-streamdown])_code]:text-sm',\n '[&_pre:not([data-streamdown])_code]:font-normal',\n // Mermaid diagram blocks\n '[&_div[data-streamdown=\"mermaid-block\"]]:bg-card-background',\n '[&_div[data-streamdown=\"mermaid-block\"]]:text-base-foreground',\n '[&_div[data-streamdown=\"mermaid-block\"]]:flex',\n '[&_div[data-streamdown=\"mermaid-block\"]]:flex-col',\n '[&_div[data-streamdown=\"mermaid-block\"]]:rounded-lg',\n '[&_div[data-streamdown=\"mermaid-block\"]]:hover:bg-base-background-hover',\n '[&_div[data-streamdown=\"mermaid-block\"]]:border-0',\n // Positioning context for the action strip (see below)\n '[&_div[data-streamdown=\"mermaid-block\"]]:relative',\n // Nested scroll + sticky + pointer-events breaks hit-testing on Mermaid Copy/Download\n // (same class of issue as github.com/vercel/streamdown/issues/494). Force absolute strip.\n '[&_div[data-streamdown=\"mermaid-block\"]>div:has([data-streamdown=\"mermaid-block-actions\"])]:!absolute',\n '[&_div[data-streamdown=\"mermaid-block\"]>div:has([data-streamdown=\"mermaid-block-actions\"])]:!top-2',\n '[&_div[data-streamdown=\"mermaid-block\"]>div:has([data-streamdown=\"mermaid-block-actions\"])]:!right-2',\n '[&_div[data-streamdown=\"mermaid-block\"]>div:has([data-streamdown=\"mermaid-block-actions\"])]:!z-10',\n '[&_div[data-streamdown=\"mermaid-block\"]>div:has([data-streamdown=\"mermaid-block-actions\"])]:!mt-0',\n '[&_div[data-streamdown=\"mermaid-block\"]>div:has([data-streamdown=\"mermaid-block-actions\"])]:!pointer-events-auto',\n // Ensure mermaid container is tall enough for the toolbar (pan/zoom + actions)\n '[&_div[data-streamdown=\"mermaid-block\"]_.relative.w-full]:!min-h-28',\n // KaTeX sizing (overflow rules live in styles.source.css)\n '[&_.katex-display]:my-3',\n '[&_.katex]:text-[1em]',\n // First and last child margin resets\n '[&>*:first-child]:mt-0',\n '[&>*:last-child]:mb-0',\n className\n )}\n components={{ ...messageResponseComponents, ...components }}\n controls={controls ?? MESSAGE_RESPONSE_DEFAULT_STREAMDOWN_CONTROLS}\n plugins={{ ...plugins, mermaid: mermaidPlugin }}\n portal={portal ?? portalContainer}\n {...props}\n />\n );\n};\n\n/**\n * Shares an explicit `portal` prop with components rendered inside the Markdown,\n * such as the expanded table view, so they portal into the same container as Streamdown.\n */\nconst MessageResponsePortalProvider = ({\n portal,\n children,\n}: Pick<MessageResponseProps, 'portal'> & {\n children: ReactNode;\n}): JSX.Element => {\n const portalContainer = usePortalContainer();\n const explicitPortalElement =\n typeof portal === 'function' ? (portal() ?? undefined) : portal;\n\n return (\n <PortalContainerContext.Provider\n value={explicitPortalElement ?? portalContainer}\n >\n {children}\n </PortalContainerContext.Provider>\n );\n};\n\nconst MessageResponse = ({\n id,\n role,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'data-testid': dataTestId,\n ...props\n}: MessageResponseProps): JSX.Element => (\n <div\n data-slot=\"message-response\"\n id={id}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n data-testid={dataTestId}\n >\n <MessageResponsePortalProvider portal={props.portal}>\n <MessageResponseMarkdown {...props} />\n </MessageResponsePortalProvider>\n </div>\n);\n\ntype MessageAttachmentProps = HTMLAttributes<HTMLDivElement> & {\n data: FileUIPart;\n className?: string;\n onRemove?: () => void;\n};\n\nfunction MessageAttachment({\n data,\n className,\n onRemove,\n ...props\n}: MessageAttachmentProps): ReactNode {\n const filename = data.filename || '';\n const mediaType =\n data.mediaType?.startsWith('image/') && data.url ? 'image' : 'file';\n const isImage = mediaType === 'image';\n const attachmentLabel = filename || (isImage ? 'Image' : 'Attachment');\n\n return (\n <div\n data-slot=\"message-attachment\"\n className={cn(\n 'group relative size-24 overflow-hidden rounded-lg',\n className\n )}\n {...props}\n >\n {isImage ? (\n <>\n <img\n alt={filename || 'attachment'}\n className=\"size-full object-cover\"\n height={100}\n src={data.url}\n width={100}\n />\n {onRemove && (\n <Button\n aria-label=\"Remove attachment\"\n className=\"absolute top-2 right-2 size-6 rounded-full bg-card-background/80 p-0 opacity-0 backdrop-blur-sm transition-opacity hover:bg-card-background group-hover:opacity-100 [&>svg]:size-3\"\n onClick={(e) => {\n e.stopPropagation();\n onRemove();\n }}\n type=\"button\"\n variant=\"ghost\"\n >\n <IconX />\n <span className=\"sr-only\">Remove</span>\n </Button>\n )}\n </>\n ) : (\n <>\n <Tooltip>\n <TooltipTrigger\n render={\n <div className=\"flex size-full shrink-0 items-center justify-center rounded-lg bg-muted-background text-muted-foreground\">\n <IconPaperclip className=\"size-4\" />\n </div>\n }\n />\n <TooltipContent>\n <p>{attachmentLabel}</p>\n </TooltipContent>\n </Tooltip>\n {onRemove && (\n <Button\n aria-label=\"Remove attachment\"\n className=\"size-6 shrink-0 rounded-full p-0 opacity-0 transition-opacity hover:bg-base-background-hover group-hover:opacity-100 [&>svg]:size-3\"\n onClick={(e) => {\n e.stopPropagation();\n onRemove();\n }}\n type=\"button\"\n variant=\"ghost\"\n >\n <IconX />\n <span className=\"sr-only\">Remove</span>\n </Button>\n )}\n </>\n )}\n </div>\n );\n}\n\ntype MessageAttachmentsProps = ComponentProps<'div'>;\n\nfunction MessageAttachments({\n children,\n className,\n ...props\n}: MessageAttachmentsProps): ReactNode {\n if (!children) {\n return null;\n }\n\n return (\n <div\n data-slot=\"message-attachments\"\n className={cn(\n 'ml-auto flex w-fit flex-wrap items-start gap-2',\n className\n )}\n {...props}\n >\n {children}\n </div>\n );\n}\n\ntype MessageToolbarProps = ComponentProps<'div'>;\n\nconst MessageToolbar = ({\n className,\n children,\n ...props\n}: MessageToolbarProps): ReactNode => (\n <div\n data-slot=\"message-toolbar\"\n className={cn(\n 'mt-4 flex w-full items-center justify-between gap-4',\n className\n )}\n {...props}\n >\n {children}\n </div>\n);\n\nexport {\n Message,\n MessageAction,\n MessageActions,\n MessageAttachment,\n MessageAttachments,\n MessageAvatar,\n MessageAvatarIcon,\n MessageBranch,\n MessageBranchContent,\n MessageBranchNext,\n MessageBranchPage,\n MessageBranchPrevious,\n MessageBranchSelector,\n MessageContent,\n MessageResponse,\n MessageToolbar,\n};\n"],"names":["createContext","useCallback","useContext","useEffect","useMemo","useState","mermaid","mermaidPlugin","IconChevronLeft","IconChevronRight","IconPaperclip","IconX","Streamdown","PortalContainerContext","usePortalContainer","cn","getInitials","Avatar","AvatarFallback","AvatarIcon","AvatarImage","Button","ButtonGroup","ButtonGroupText","Tooltip","TooltipContent","TooltipTrigger","MESSAGE_RESPONSE_DEFAULT_STREAMDOWN_CONTROLS","Message","className","isResponse","props","div","data-slot","MessageContent","children","MessageAvatar","avatarUrl","name","variant","sizes","fallbackText","alt","src","MessageAvatarIcon","MessageActions","MessageAction","tooltip","label","size","button","type","span","render","p","MessageBranchContext","useMessageBranch","context","Error","MessageBranch","defaultBranch","onBranchChange","currentBranch","setCurrentBranch","branches","setBranches","goToPrevious","prev","newBranch","length","goToNext","contextValue","totalBranches","Provider","value","MessageBranchContent","childrenArray","Array","isArray","map","branch","index","key","MessageBranchSelector","orientation","MessageBranchPrevious","aria-label","disabled","onClick","MessageBranchNext","MessageBranchPage","messageResponseComponents","h1","h2","h3","h4","h5","h6","strong","em","b","i","ul","ol","li","blockquote","hr","a","href","table","tabIndex","role","thead","tbody","tr","th","td","MessageResponseMarkdown","components","plugins","controls","portal","portalContainer","MessageResponsePortalProvider","explicitPortalElement","undefined","MessageResponse","id","ariaLabel","ariaLabelledBy","ariaDescribedBy","dataTestId","aria-labelledby","aria-describedby","data-testid","MessageAttachment","data","onRemove","filename","mediaType","startsWith","url","isImage","attachmentLabel","img","height","width","e","stopPropagation","MessageAttachments","MessageToolbar"],"mappings":";AAMA,SACEA,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACH,QAAQ;AAEf,SAASC,WAAWC,aAAa,QAAQ,sBAAsB;AAC/D,SACEC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,EACbC,KAAK,QACA,sBAAsB;AAG7B,SAASC,UAAU,QAAQ,aAAa;AAGxC,SACEC,sBAAsB,EACtBC,kBAAkB,Q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E;sBAAO9E;;IAEV+E,IAAI,CAAC,EAAE/E,QAAQ,EAAgC,iBAC7C,KAAC+E;YAAGrF,WAAU;sBAA6CM;;IAE7DgF,IAAI,CAAC,EAAEhF,QAAQ,EAAgC,iBAC7C,KAACgF;YAAGtF,WAAU;sBAAwCM;;IAExDiF,IAAI,CAAC,EAAEjF,QAAQ,EAAgC,iBAC7C,KAACiF;YAAGvF,WAAU;sBAA8BM;;AAEhD;AAEA,MAAMkF,0BAA0B,CAAC,EAC/BxF,SAAS,EACTyF,UAAU,EACVC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACN,GAAG1F,OAC+B;IAClC,MAAM2F,kBAAkB5G;IAExB,qBACE,KAACF;QACCiB,WAAWd,GACT,aACA,iCAAiC;QACjC,4BACA,mCACA,cAAc;QACd,qBACA,oBACA,gCACA,wBACA,wBACA,sBACA,oBACA,0BACA,qCAAqC;QACrC,8CACA,gDACA,yDACA,oDACA,gDACA,wDACA,oBAAoB;QACpB,qDACA,6DACA,gEACA,uEACA,qDACA,qDACA,wDACA,sEACA,gCAAgC;QAChC,iDACA,6DACA,sDACA,4DACA,iEACA,iDACA,qDACA,qEACA,0BAA0B;QAC1B,yDACA,+DACA,iEACA,sDACA,4DACA,0DACA,8DACA,qBAAqB;QACrB,uEACA,4DACA,8EACA,uEACA,mFACA,2EACA,gEACA,kFACA,2EACA,uFACA,qDAAqD;QACrD,uCACA,uCACA,kDACA,6CACA,yCACA,qDACA,sCACA,yDACA,0CACA,8CACA,oDACA,sDACA,4CACA,4CACA,iDACA,+CACA,mDACA,yBAAyB;QACzB,+DACA,iEACA,iDACA,qDACA,uDACA,2EACA,qDACA,uDAAuD;QACvD,qDACA,sFAAsF;QACtF,0FAA0F;QAC1F,yGACA,sGACA,wGACA,qGACA,qGACA,oHACA,+EAA+E;QAC/E,uEACA,0DAA0D;QAC1D,2BACA,yBACA,qCAAqC;QACrC,0BACA,yBACAc;QAEFyF,YAAY;YAAE,GAAG3B,yBAAyB;YAAE,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