@ai-matrx/rich-content 0.2.3 → 0.2.6

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.
Files changed (382) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/code-block/CodeBlock.d.ts +44 -0
  3. package/dist/code-block/CodeBlock.js +449 -0
  4. package/dist/code-block/CodeBlockHeader.d.ts +63 -0
  5. package/dist/code-block/CodeBlockHeader.js +472 -0
  6. package/dist/code-block/CodeEditorLoading.d.ts +3 -0
  7. package/dist/code-block/CodeEditorLoading.js +34 -0
  8. package/dist/code-block/LanguageDisplay.d.ts +28 -0
  9. package/dist/code-block/LanguageDisplay.js +279 -0
  10. package/dist/code-block/SmallCodeEditor.d.ts +30 -0
  11. package/dist/code-block/SmallCodeEditor.js +22 -0
  12. package/dist/code-block/StickyButtons.d.ts +35 -0
  13. package/dist/code-block/StickyButtons.js +88 -0
  14. package/dist/code-block/highlight/ShikiCodeView.d.ts +26 -0
  15. package/dist/code-block/highlight/ShikiCodeView.js +134 -0
  16. package/dist/code-block/highlight/shiki-highlighter.d.ts +14 -0
  17. package/dist/code-block/highlight/shiki-highlighter.js +126 -0
  18. package/dist/code-block/highlight/useHighlightedLines.d.ts +18 -0
  19. package/dist/code-block/highlight/useHighlightedLines.js +142 -0
  20. package/dist/code-block/sticky-inset.d.ts +6 -0
  21. package/dist/code-block/sticky-inset.js +10 -0
  22. package/dist/display/block-interaction.d.ts +33 -0
  23. package/dist/display/block-interaction.js +13 -0
  24. package/dist/display/blocks/ChatCollapsibleWrapper.d.ts +13 -0
  25. package/dist/display/blocks/ChatCollapsibleWrapper.js +56 -0
  26. package/dist/display/blocks/buildMediaSource.d.ts +25 -0
  27. package/dist/display/blocks/buildMediaSource.js +43 -0
  28. package/dist/display/blocks/canvas-adaptive.d.ts +118 -0
  29. package/dist/display/blocks/canvas-adaptive.js +127 -0
  30. package/dist/display/blocks/canvas-fit.d.ts +24 -0
  31. package/dist/display/blocks/canvas-fit.js +19 -0
  32. package/dist/display/blocks/chart/ChartBlock.d.ts +8 -0
  33. package/dist/display/blocks/chart/ChartBlock.js +125 -0
  34. package/dist/display/blocks/chart/ChartCanvas.d.ts +18 -0
  35. package/dist/display/blocks/chart/ChartCanvas.js +159 -0
  36. package/dist/display/blocks/chart/TableChart.d.ts +25 -0
  37. package/dist/display/blocks/chart/TableChart.js +97 -0
  38. package/dist/display/blocks/chart/chart-spec.d.ts +39 -0
  39. package/dist/display/blocks/chart/chart-spec.js +128 -0
  40. package/dist/display/blocks/chart/labels.d.ts +20 -0
  41. package/dist/display/blocks/chart/labels.js +7 -0
  42. package/dist/display/blocks/chart/table-chart.d.ts +37 -0
  43. package/dist/display/blocks/chart/table-chart.js +231 -0
  44. package/dist/display/blocks/common/BlockHeaderWrapper.d.ts +56 -0
  45. package/dist/display/blocks/common/BlockHeaderWrapper.js +310 -0
  46. package/dist/display/blocks/common/ContentBlockWrapper.d.ts +40 -0
  47. package/dist/display/blocks/common/ContentBlockWrapper.js +214 -0
  48. package/dist/display/blocks/common/SandboxedHtml.d.ts +27 -0
  49. package/dist/display/blocks/common/SandboxedHtml.js +26 -0
  50. package/dist/display/blocks/csv/CsvBlock.js +5 -1
  51. package/dist/display/blocks/diagram/DiagramLoadingVisualization.d.ts +6 -0
  52. package/dist/display/blocks/diagram/DiagramLoadingVisualization.js +190 -0
  53. package/dist/display/blocks/diagram/InteractiveDiagramBlock.d.ts +51 -0
  54. package/dist/display/blocks/diagram/InteractiveDiagramBlock.js +2415 -0
  55. package/dist/display/blocks/diagram/diagram-printer.d.ts +16 -0
  56. package/dist/display/blocks/diagram/diagram-printer.js +294 -0
  57. package/dist/display/blocks/diagram/diagram-visual-defaults.d.ts +116 -0
  58. package/dist/display/blocks/diagram/diagram-visual-defaults.js +400 -0
  59. package/dist/display/blocks/diagram/layout-utils.d.ts +90 -0
  60. package/dist/display/blocks/diagram/layout-utils.js +347 -0
  61. package/dist/display/blocks/diagram/parseDiagramJSON.d.ts +105 -0
  62. package/dist/display/blocks/diagram/parseDiagramJSON.js +296 -0
  63. package/dist/display/blocks/diagram/presentation-direction.d.ts +29 -0
  64. package/dist/display/blocks/diagram/presentation-direction.js +19 -0
  65. package/dist/display/blocks/diagram/ui-utils.d.ts +1 -0
  66. package/dist/display/blocks/diagram/ui-utils.js +18 -0
  67. package/dist/display/blocks/diff/DiffBlock.d.ts +10 -0
  68. package/dist/display/blocks/diff/DiffBlock.js +119 -0
  69. package/dist/display/blocks/diff/DiffCanvas.d.ts +15 -0
  70. package/dist/display/blocks/diff/DiffCanvas.js +20 -0
  71. package/dist/display/blocks/generic/GenericStructuredBlock.d.ts +24 -0
  72. package/dist/display/blocks/generic/GenericStructuredBlock.js +53 -0
  73. package/dist/display/blocks/generic/StructuredValueTabs.d.ts +21 -0
  74. package/dist/display/blocks/generic/StructuredValueTabs.js +124 -0
  75. package/dist/display/blocks/generic/tile-actions-slot.d.ts +39 -0
  76. package/dist/display/blocks/generic/tile-actions-slot.js +33 -0
  77. package/dist/display/blocks/images/ImageBlock.d.ts +8 -0
  78. package/dist/display/blocks/images/ImageBlock.js +265 -0
  79. package/dist/display/blocks/json/JsonBlock.d.ts +34 -0
  80. package/dist/display/blocks/json/JsonBlock.js +562 -0
  81. package/dist/display/blocks/json/JsonTableView.d.ts +10 -0
  82. package/dist/display/blocks/json/JsonTableView.js +173 -0
  83. package/dist/display/blocks/json/json-compact-stringify.d.ts +25 -0
  84. package/dist/display/blocks/json/json-compact-stringify.js +52 -0
  85. package/dist/display/blocks/json/json-tabular-utils.d.ts +65 -0
  86. package/dist/display/blocks/json/json-tabular-utils.js +121 -0
  87. package/dist/display/blocks/links/LinkComponent.d.ts +6 -0
  88. package/dist/display/blocks/links/LinkComponent.js +373 -0
  89. package/dist/display/blocks/links/LinkComponentWithFetch.d.ts +1 -0
  90. package/dist/display/blocks/links/LinkComponentWithFetch.js +0 -0
  91. package/dist/display/blocks/markdown/MarkdownKindBlock.d.ts +48 -0
  92. package/dist/display/blocks/markdown/MarkdownKindBlock.js +52 -0
  93. package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.d.ts +17 -0
  94. package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.js +70 -0
  95. package/dist/display/blocks/mermaid/MermaidBlock.d.ts +19 -0
  96. package/dist/display/blocks/mermaid/MermaidBlock.js +386 -0
  97. package/dist/display/blocks/search-replace/SearchReplaceBlock.d.ts +50 -0
  98. package/dist/display/blocks/search-replace/SearchReplaceBlock.js +71 -0
  99. package/dist/display/blocks/svg/SvgBlock.d.ts +8 -0
  100. package/dist/display/blocks/svg/SvgBlock.js +126 -0
  101. package/dist/display/blocks/table/StreamingTableRenderer.d.ts +53 -0
  102. package/dist/display/blocks/table/StreamingTableRenderer.js +907 -0
  103. package/dist/display/blocks/table/TableRenderPathDiagnostic.d.ts +21 -0
  104. package/dist/display/blocks/table/TableRenderPathDiagnostic.js +79 -0
  105. package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.d.ts +14 -0
  106. package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.js +15 -0
  107. package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.d.ts +13 -0
  108. package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.js +19 -0
  109. package/dist/display/blocks/thinking-reasoning/ThinkingTrace.d.ts +30 -0
  110. package/dist/display/blocks/thinking-reasoning/ThinkingTrace.js +75 -0
  111. package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.d.ts +13 -0
  112. package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.js +48 -0
  113. package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.d.ts +12 -0
  114. package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.js +19 -0
  115. package/dist/display/blocks/toml/TomlBlock.d.ts +7 -0
  116. package/dist/display/blocks/toml/TomlBlock.js +167 -0
  117. package/dist/display/blocks/tree/TreeBlock.d.ts +7 -0
  118. package/dist/display/blocks/tree/TreeBlock.js +163 -0
  119. package/dist/display/blocks/xml/XmlBlock.d.ts +23 -0
  120. package/dist/display/blocks/xml/XmlBlock.js +197 -0
  121. package/dist/display/blocks/xml/readXmlTag.d.ts +1 -0
  122. package/dist/display/blocks/xml/readXmlTag.js +1 -0
  123. package/dist/display/blocks/xml/xml-tokenize.d.ts +13 -0
  124. package/dist/display/blocks/xml/xml-tokenize.js +169 -0
  125. package/dist/display/blocks/yaml/YamlBlock.d.ts +7 -0
  126. package/dist/display/blocks/yaml/YamlBlock.js +191 -0
  127. package/dist/display/chat-markdown/BasicMarkdownContent.d.ts +29 -0
  128. package/dist/display/chat-markdown/BasicMarkdownContent.js +122 -0
  129. package/dist/display/chat-markdown/BlockRenderingContext.d.ts +23 -0
  130. package/dist/display/chat-markdown/BlockRenderingContext.js +17 -0
  131. package/dist/display/chat-markdown/ConfigurableMarkdownContent.d.ts +172 -0
  132. package/dist/display/chat-markdown/ConfigurableMarkdownContent.js +649 -0
  133. package/dist/display/chat-markdown/InlineCodeSnippet.d.ts +19 -0
  134. package/dist/display/chat-markdown/InlineCodeSnippet.js +146 -0
  135. package/dist/display/chat-markdown/InlineCodeSnippetKindGate.d.ts +11 -0
  136. package/dist/display/chat-markdown/InlineCodeSnippetKindGate.js +9 -0
  137. package/dist/display/chat-markdown/KindTextGate.d.ts +31 -0
  138. package/dist/display/chat-markdown/KindTextGate.js +60 -0
  139. package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.d.ts +6 -0
  140. package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.js +92 -0
  141. package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.d.ts +72 -0
  142. package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.js +94 -0
  143. package/dist/display/chat-markdown/block-registry/BlockRenderer.d.ts +126 -0
  144. package/dist/display/chat-markdown/block-registry/BlockRenderer.js +473 -0
  145. package/dist/display/chat-markdown/block-registry/block-dispatch.d.ts +410 -0
  146. package/dist/display/chat-markdown/block-registry/block-dispatch.js +495 -0
  147. package/dist/display/chat-markdown/block-registry/json-parse-utils.d.ts +13 -0
  148. package/dist/display/chat-markdown/block-registry/json-parse-utils.js +236 -0
  149. package/dist/display/chat-markdown/constants.d.ts +14 -0
  150. package/dist/display/chat-markdown/constants.js +317 -0
  151. package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.d.ts +31 -0
  152. package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.js +62 -0
  153. package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.d.ts +12 -0
  154. package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.js +18 -0
  155. package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.d.ts +22 -0
  156. package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.js +130 -0
  157. package/dist/display/chat-markdown/diff-blocks/diff-style-registry.d.ts +21 -0
  158. package/dist/display/chat-markdown/diff-blocks/diff-style-registry.js +91 -0
  159. package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.d.ts +26 -0
  160. package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.js +186 -0
  161. package/dist/display/chat-markdown/diff-blocks/types.d.ts +56 -0
  162. package/dist/display/chat-markdown/diff-blocks/types.js +0 -0
  163. package/dist/display/chat-markdown/internal-handlers/BlockFallback.d.ts +20 -0
  164. package/dist/display/chat-markdown/internal-handlers/BlockFallback.js +83 -0
  165. package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.d.ts +4 -0
  166. package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.js +16 -0
  167. package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.d.ts +17 -0
  168. package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.js +40 -0
  169. package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.d.ts +8 -0
  170. package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.js +91 -0
  171. package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.d.ts +20 -0
  172. package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.js +72 -0
  173. package/dist/display/chat-markdown/kind-source-view.d.ts +14 -0
  174. package/dist/display/chat-markdown/kind-source-view.js +14 -0
  175. package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.d.ts +28 -0
  176. package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.js +65 -0
  177. package/dist/display/chat-markdown/progressive-mount.d.ts +18 -0
  178. package/dist/display/chat-markdown/progressive-mount.js +90 -0
  179. package/dist/display/chat-markdown/render-block-to-content-block.d.ts +31 -0
  180. package/dist/display/chat-markdown/render-block-to-content-block.js +32 -0
  181. package/dist/display/chat-markdown/settle-stream-blocks.d.ts +50 -0
  182. package/dist/display/chat-markdown/settle-stream-blocks.js +26 -0
  183. package/dist/display/chat-markdown/stable-blocks.d.ts +15 -0
  184. package/dist/display/chat-markdown/stable-blocks.js +54 -0
  185. package/dist/display/chat-markdown/types.d.ts +11 -0
  186. package/dist/display/chat-markdown/types.js +26 -0
  187. package/dist/display/specimen/SpecimenContext.d.ts +26 -0
  188. package/dist/display/specimen/SpecimenContext.js +64 -0
  189. package/dist/display/tables/MarkdownTable.d.ts +23 -0
  190. package/dist/display/tables/MarkdownTable.js +769 -0
  191. package/dist/display/tables/MarkdownTableScrollArea.d.ts +12 -0
  192. package/dist/display/tables/MarkdownTableScrollArea.js +92 -0
  193. package/dist/display/tables/SendToGoogleSheetButton.d.ts +19 -0
  194. package/dist/display/tables/SendToGoogleSheetButton.js +93 -0
  195. package/dist/display/tables/SendToWorkbookButton.d.ts +24 -0
  196. package/dist/display/tables/SendToWorkbookButton.js +93 -0
  197. package/dist/display/tables/TableSaveToMenu.d.ts +16 -0
  198. package/dist/display/tables/TableSaveToMenu.js +98 -0
  199. package/dist/display/tables/TableWithSeparatedControls.d.ts +22 -0
  200. package/dist/display/tables/TableWithSeparatedControls.js +574 -0
  201. package/dist/display/tables/ViewTableModal.d.ts +14 -0
  202. package/dist/display/tables/ViewTableModal.js +67 -0
  203. package/dist/display/tables/editing/ColumnActionsMenu.d.ts +16 -0
  204. package/dist/display/tables/editing/ColumnActionsMenu.js +80 -0
  205. package/dist/display/tables/editing/RowActionsMenu.d.ts +16 -0
  206. package/dist/display/tables/editing/RowActionsMenu.js +80 -0
  207. package/dist/display/tables/editing/TableEditToolbar.d.ts +15 -0
  208. package/dist/display/tables/editing/TableEditToolbar.js +63 -0
  209. package/dist/display/tables/editing/tableMutations.d.ts +50 -0
  210. package/dist/display/tables/editing/tableMutations.js +148 -0
  211. package/dist/display/tables/editing/useDoubleClickEdit.d.ts +43 -0
  212. package/dist/display/tables/editing/useDoubleClickEdit.js +51 -0
  213. package/dist/display/tables/editing/useTableUndo.d.ts +25 -0
  214. package/dist/display/tables/editing/useTableUndo.js +17 -0
  215. package/dist/display/tables/table-action-row.d.ts +8 -0
  216. package/dist/display/tables/table-action-row.js +31 -0
  217. package/dist/display/tables/table-viewer.d.ts +13 -0
  218. package/dist/display/tables/table-viewer.js +18 -0
  219. package/dist/host/ErrorActions.d.ts +1 -1
  220. package/dist/host/ErrorNotice.d.ts +10 -0
  221. package/dist/host/ErrorNotice.js +19 -0
  222. package/dist/host/app-bindings.d.ts +155 -0
  223. package/dist/host/app-bindings.js +160 -0
  224. package/dist/host/diagnostics.d.ts +2 -2
  225. package/dist/host/diagnostics.js +2 -1
  226. package/dist/host/tables.d.ts +1 -6
  227. package/dist/host/types.d.ts +14 -7
  228. package/dist/levels/RichContent.d.ts +3 -0
  229. package/dist/levels/RichContent.js +102 -0
  230. package/dist/levels/RichContentInline.d.ts +28 -0
  231. package/dist/levels/RichContentInline.js +61 -0
  232. package/dist/levels/RichContentPreview.d.ts +12 -0
  233. package/dist/levels/RichContentPreview.js +39 -0
  234. package/dist/levels/RichContentStandardImpl.d.ts +12 -0
  235. package/dist/levels/RichContentStandardImpl.js +27 -0
  236. package/dist/levels/RichContentStaticProse.d.ts +46 -0
  237. package/dist/levels/RichContentStaticProse.js +100 -0
  238. package/dist/levels/depth.d.ts +18 -0
  239. package/dist/levels/depth.js +32 -0
  240. package/dist/levels/prose/inline-level-elements.d.ts +19 -0
  241. package/dist/levels/prose/inline-level-elements.js +103 -0
  242. package/dist/levels/prose/prose-block-elements.d.ts +25 -0
  243. package/dist/levels/prose/prose-block-elements.js +313 -0
  244. package/dist/levels/prose/prose-inline-elements.d.ts +13 -0
  245. package/dist/levels/prose/prose-inline-elements.js +143 -0
  246. package/dist/levels/prose/prose-prepare.d.ts +50 -0
  247. package/dist/levels/prose/prose-prepare.js +246 -0
  248. package/dist/levels/prose/remote-image-policy.d.ts +34 -0
  249. package/dist/levels/prose/remote-image-policy.js +153 -0
  250. package/dist/levels/prose/variant-root.d.ts +9 -0
  251. package/dist/levels/prose/variant-root.js +34 -0
  252. package/dist/levels/rich-content-types.d.ts +93 -0
  253. package/dist/levels/rich-content-types.js +4 -0
  254. package/dist/levels/server/DelimiterViolationReport.d.ts +7 -0
  255. package/dist/levels/server/DelimiterViolationReport.js +24 -0
  256. package/dist/levels/server/RichContentServer.d.ts +27 -0
  257. package/dist/levels/server/RichContentServer.js +97 -0
  258. package/dist/levels/standard/NestedRichContent.d.ts +7 -0
  259. package/dist/levels/standard/NestedRichContent.js +70 -0
  260. package/dist/levels/standard/StandardBlocks.d.ts +13 -0
  261. package/dist/levels/standard/StandardBlocks.js +239 -0
  262. package/dist/levels/standard/StandardKindRegion.d.ts +14 -0
  263. package/dist/levels/standard/StandardKindRegion.js +69 -0
  264. package/dist/levels/standard/standard-kind-region.d.ts +19 -0
  265. package/dist/levels/standard/standard-kind-region.js +21 -0
  266. package/dist/levels/standard/static-standard.d.ts +23 -0
  267. package/dist/levels/standard/static-standard.js +187 -0
  268. package/dist/levels/standard/stream-holdback.d.ts +2 -0
  269. package/dist/levels/standard/stream-holdback.js +77 -0
  270. package/dist/mermaid/MermaidFullscreen.d.ts +17 -0
  271. package/dist/mermaid/MermaidFullscreen.js +71 -0
  272. package/dist/mermaid/MermaidRenderer.d.ts +20 -0
  273. package/dist/mermaid/MermaidRenderer.js +267 -0
  274. package/dist/mermaid/MermaidView.d.ts +27 -0
  275. package/dist/mermaid/MermaidView.js +68 -0
  276. package/dist/mermaid/MermaidViewport.d.ts +75 -0
  277. package/dist/mermaid/MermaidViewport.js +286 -0
  278. package/dist/mermaid/adapters/er.d.ts +10 -0
  279. package/dist/mermaid/adapters/er.js +205 -0
  280. package/dist/mermaid/adapters/flowchart.d.ts +17 -0
  281. package/dist/mermaid/adapters/flowchart.js +634 -0
  282. package/dist/mermaid/adapters/journey.d.ts +9 -0
  283. package/dist/mermaid/adapters/journey.js +207 -0
  284. package/dist/mermaid/adapters/mindmap.d.ts +12 -0
  285. package/dist/mermaid/adapters/mindmap.js +252 -0
  286. package/dist/mermaid/adapters/pie.d.ts +7 -0
  287. package/dist/mermaid/adapters/pie.js +172 -0
  288. package/dist/mermaid/adapters/quadrant.d.ts +8 -0
  289. package/dist/mermaid/adapters/quadrant.js +231 -0
  290. package/dist/mermaid/adapters/register.d.ts +7 -0
  291. package/dist/mermaid/adapters/register.js +19 -0
  292. package/dist/mermaid/adapters/sequence.d.ts +8 -0
  293. package/dist/mermaid/adapters/sequence.js +251 -0
  294. package/dist/mermaid/adapters/state.d.ts +12 -0
  295. package/dist/mermaid/adapters/state.js +245 -0
  296. package/dist/mermaid/adapters/timeline.d.ts +8 -0
  297. package/dist/mermaid/adapters/timeline.js +245 -0
  298. package/dist/mermaid/catalog.d.ts +33 -0
  299. package/dist/mermaid/catalog.js +202 -0
  300. package/dist/mermaid/diagram-type.d.ts +39 -0
  301. package/dist/mermaid/diagram-type.js +89 -0
  302. package/dist/mermaid/export.d.ts +21 -0
  303. package/dist/mermaid/export.js +112 -0
  304. package/dist/mermaid/extract-fence.d.ts +15 -0
  305. package/dist/mermaid/extract-fence.js +22 -0
  306. package/dist/mermaid/lazy-draw.d.ts +40 -0
  307. package/dist/mermaid/lazy-draw.js +168 -0
  308. package/dist/mermaid/model/adapter.d.ts +28 -0
  309. package/dist/mermaid/model/adapter.js +16 -0
  310. package/dist/mermaid/model/ops.d.ts +282 -0
  311. package/dist/mermaid/model/ops.js +9 -0
  312. package/dist/mermaid/model/round-trip.d.ts +22 -0
  313. package/dist/mermaid/model/round-trip.js +45 -0
  314. package/dist/mermaid/model/types.d.ts +271 -0
  315. package/dist/mermaid/model/types.js +0 -0
  316. package/dist/mermaid/print-render.d.ts +9 -0
  317. package/dist/mermaid/print-render.js +39 -0
  318. package/dist/mermaid/runtime.d.ts +25 -0
  319. package/dist/mermaid/runtime.js +183 -0
  320. package/dist/mermaid/sanitize.d.ts +46 -0
  321. package/dist/mermaid/sanitize.js +234 -0
  322. package/dist/mermaid/types.d.ts +43 -0
  323. package/dist/mermaid/types.js +21 -0
  324. package/dist/mermaid/view/ViewModePane.d.ts +24 -0
  325. package/dist/mermaid/view/ViewModePane.js +9 -0
  326. package/dist/utils/client-lazy.d.ts +1 -1
  327. package/dist/utils/client-lazy.js +4 -1
  328. package/dist/utils/lifted/DiffView.d.ts +10 -0
  329. package/dist/utils/lifted/DiffView.js +26 -0
  330. package/dist/utils/lifted/IconButton.d.ts +24 -0
  331. package/dist/utils/lifted/IconButton.js +43 -0
  332. package/dist/utils/lifted/MatrxMiniLoader.d.ts +1 -0
  333. package/dist/utils/lifted/MatrxMiniLoader.js +8 -0
  334. package/dist/utils/lifted/ShimmerText.d.ts +5 -0
  335. package/dist/utils/lifted/ShimmerText.js +21 -0
  336. package/dist/utils/lifted/SuspenseLoader.d.ts +16 -0
  337. package/dist/utils/lifted/SuspenseLoader.js +42 -0
  338. package/dist/utils/lifted/Tooltip.d.ts +20 -0
  339. package/dist/utils/lifted/Tooltip.js +52 -0
  340. package/dist/utils/lifted/artifactId.d.ts +34 -0
  341. package/dist/utils/lifted/artifactId.js +15 -0
  342. package/dist/utils/lifted/canvasContent.d.ts +63 -0
  343. package/dist/utils/lifted/canvasContent.js +98 -0
  344. package/dist/utils/lifted/captureReactError.d.ts +24 -0
  345. package/dist/utils/lifted/captureReactError.js +28 -0
  346. package/dist/utils/lifted/chunk-load-recovery.d.ts +25 -0
  347. package/dist/utils/lifted/chunk-load-recovery.js +36 -0
  348. package/dist/utils/lifted/code-editor-agent-types.d.ts +6 -0
  349. package/dist/utils/lifted/code-editor-agent-types.js +0 -0
  350. package/dist/utils/lifted/code-editor-agents.d.ts +39 -0
  351. package/dist/utils/lifted/code-editor-agents.js +52 -0
  352. package/dist/utils/lifted/code-language-extension.d.ts +1 -0
  353. package/dist/utils/lifted/code-language-extension.js +60 -0
  354. package/dist/utils/lifted/custom-icons.d.ts +16 -0
  355. package/dist/utils/lifted/custom-icons.js +47 -0
  356. package/dist/utils/lifted/durability.d.ts +16 -0
  357. package/dist/utils/lifted/durability.js +45 -0
  358. package/dist/utils/lifted/errors.d.ts +30 -0
  359. package/dist/utils/lifted/errors.js +29 -0
  360. package/dist/utils/lifted/html-document.d.ts +1 -0
  361. package/dist/utils/lifted/html-document.js +12 -0
  362. package/dist/utils/lifted/languageOptions.d.ts +9 -0
  363. package/dist/utils/lifted/languageOptions.js +52 -0
  364. package/dist/utils/lifted/languages.d.ts +34 -0
  365. package/dist/utils/lifted/languages.js +175 -0
  366. package/dist/utils/lifted/loading-spinner.d.ts +18 -0
  367. package/dist/utils/lifted/loading-spinner.js +200 -0
  368. package/dist/utils/lifted/media-refs.d.ts +13 -0
  369. package/dist/utils/lifted/media-refs.js +27 -0
  370. package/dist/utils/lifted/scroll-root.d.ts +1 -0
  371. package/dist/utils/lifted/scroll-root.js +25 -0
  372. package/dist/utils/lifted/syntax-themes.d.ts +32 -0
  373. package/dist/utils/lifted/syntax-themes.js +100 -0
  374. package/dist/utils/lifted/url-utm.d.ts +24 -0
  375. package/dist/utils/lifted/url-utm.js +66 -0
  376. package/dist/utils/lifted/use-is-mounted.d.ts +24 -0
  377. package/dist/utils/lifted/use-is-mounted.js +21 -0
  378. package/dist/utils/lifted/useToastManager.d.ts +1 -0
  379. package/dist/utils/lifted/useToastManager.js +7 -0
  380. package/dist/utils/report-kind-at-raw-renderer.d.ts +19 -0
  381. package/dist/utils/report-kind-at-raw-renderer.js +32 -0
  382. package/package.json +32 -3
@@ -0,0 +1,562 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useClipboard } from "@ai-matrx/kit/clipboard";
4
+ import { humanizeIdentifier } from "@ai-matrx/kit/text-case";
5
+ import {
6
+ Suspense,
7
+ createContext,
8
+ lazy,
9
+ useContext,
10
+ useMemo,
11
+ useRef,
12
+ useState
13
+ } from "react";
14
+ import {
15
+ Copy,
16
+ FileSpreadsheet,
17
+ FileText,
18
+ ListTree,
19
+ Code2,
20
+ Compass,
21
+ FileJson,
22
+ StretchHorizontal,
23
+ TableProperties,
24
+ MoreHorizontal,
25
+ AlignJustify,
26
+ Shapes
27
+ } from "lucide-react";
28
+ import { useOpenSaveToTable } from "../../../host/tables.js";
29
+ import { toast } from "../../../host/toast.js";
30
+ import { cn } from "@ai-matrx/design-system";
31
+ import {
32
+ Tooltip,
33
+ TooltipContent,
34
+ TooltipProvider,
35
+ TooltipTrigger
36
+ } from "@ai-matrx/design-system";
37
+ import IconButton from "../../../utils/lifted/IconButton.js";
38
+ import { AdvancedMenu } from "../../../host/app-bindings.js";
39
+ import { useAdvancedMenu } from "../../../host/app-bindings.js";
40
+ import {
41
+ parseJsonSafe,
42
+ detectTabular,
43
+ rowsToCsv,
44
+ rowsToNdjson,
45
+ rowsToXlsx,
46
+ downloadText,
47
+ defaultJsonFilename
48
+ } from "./json-tabular-utils.js";
49
+ import { stringifyCompact } from "./json-compact-stringify.js";
50
+ import { CodeBlockWithContextAttach } from "../../../host/app-bindings.js";
51
+ import { useOpenConvertToShapeWindow } from "../../../host/app-bindings.js";
52
+ import { findEscapedKindMarkers } from "../../../kinds/react/kind-problems.js";
53
+ import KindEscapedNotice from "../../../kinds/react/KindEscapedNotice.js";
54
+ import { KindValueFrontDoor } from "../../../host/app-bindings.js";
55
+ import { textCarriesKind, valueCarriesKind } from "@ai-matrx/content-ir/surfaces";
56
+ import { Button } from "@ai-matrx/design-system/controls";
57
+ const JsonTableView = lazy(
58
+ () => import("./JsonTableView.js")
59
+ );
60
+ import { JsonTreeViewer, RawJsonExplorer } from "../../../host/app-bindings.js";
61
+ function PaneFallback({ label = "Loading\u2026" }) {
62
+ return /* @__PURE__ */ jsx("div", { className: "p-4 text-xs text-muted-foreground italic", children: label });
63
+ }
64
+ const JsonKindRouteContext = createContext([]);
65
+ function canonicalJson(value) {
66
+ try {
67
+ return JSON.stringify(value) ?? "";
68
+ } catch {
69
+ return "";
70
+ }
71
+ }
72
+ const JsonBlock = ({
73
+ content,
74
+ className,
75
+ isStreamActive = false,
76
+ allowEdit = true,
77
+ customBuiltinKeys = [],
78
+ onCodeChange,
79
+ conversationId,
80
+ messageId,
81
+ allowConvertToShape = true,
82
+ irEnvelope = null,
83
+ meta
84
+ }) => {
85
+ const openConvertToShape = useOpenConvertToShapeWindow();
86
+ const routedAbove = useContext(JsonKindRouteContext);
87
+ const [mode, setMode] = useState("code");
88
+ const openSaveToTable = useOpenSaveToTable();
89
+ const [formatOverride, setFormatOverride] = useState(null);
90
+ const effectiveContent = formatOverride ?? content;
91
+ const [previousContent, setPreviousContent] = useState(content);
92
+ if (previousContent !== content) {
93
+ setPreviousContent(content);
94
+ setFormatOverride(null);
95
+ }
96
+ const parsed = useMemo(() => {
97
+ return parseJsonSafe(effectiveContent);
98
+ }, [effectiveContent]);
99
+ const cardShowsSource = !allowConvertToShape || !textCarriesKind(effectiveContent) && !(parsed.ok && valueCarriesKind(parsed.value));
100
+ const kindMarkers = useMemo(() => {
101
+ if (!parsed.ok || isStreamActive || !allowConvertToShape) return [];
102
+ return findEscapedKindMarkers(parsed.value, irEnvelope);
103
+ }, [parsed, isStreamActive, allowConvertToShape, irEnvelope]);
104
+ const tabular = useMemo(() => {
105
+ if (!parsed.ok) {
106
+ return {
107
+ isTabular: false,
108
+ rows: [],
109
+ columns: [],
110
+ source: "none"
111
+ };
112
+ }
113
+ return detectTabular(parsed.value);
114
+ }, [parsed]);
115
+ const jsonMenuItems = useMemo(() => {
116
+ if (!parsed.ok) return [];
117
+ const data2 = parsed.value;
118
+ const items = [];
119
+ const base = defaultJsonFilename();
120
+ if (allowConvertToShape) {
121
+ items.push({
122
+ key: "convert-to-shape",
123
+ icon: Shapes,
124
+ iconColor: "text-amber-600 dark:text-amber-400",
125
+ label: "Convert to Shape\u2026",
126
+ description: "Create or improve a reusable Shape from this JSON",
127
+ category: "Create",
128
+ showToast: false,
129
+ action: () => {
130
+ openConvertToShape({ initialJsonContent: effectiveContent });
131
+ }
132
+ });
133
+ }
134
+ if (tabular.isTabular && openSaveToTable) {
135
+ items.push({
136
+ key: "save-to-table",
137
+ icon: TableProperties,
138
+ iconColor: "text-emerald-600 dark:text-emerald-400",
139
+ label: "Save to a table\u2026",
140
+ description: "A new table, or add these rows to one you have",
141
+ category: "Data",
142
+ showToast: false,
143
+ action: () => {
144
+ openSaveToTable({
145
+ value: data2,
146
+ title: tabular.source === "wrapped-array" && tabular.wrapperKey ? humanizeIdentifier(tabular.wrapperKey) || tabular.wrapperKey : null
147
+ });
148
+ }
149
+ });
150
+ }
151
+ if (Array.isArray(data2)) {
152
+ items.push({
153
+ key: "download-ndjson",
154
+ icon: FileText,
155
+ label: "Download as NDJSON",
156
+ description: "One object per line",
157
+ category: "Download",
158
+ showToast: false,
159
+ action: () => downloadText(
160
+ `${base}.ndjson`,
161
+ rowsToNdjson(data2),
162
+ "application/x-ndjson"
163
+ )
164
+ });
165
+ }
166
+ if (tabular.isTabular) {
167
+ items.push({
168
+ key: "download-csv",
169
+ icon: FileSpreadsheet,
170
+ label: "Download as CSV",
171
+ description: `${tabular.rows.length} rows \xD7 ${tabular.columns.length} cols`,
172
+ category: "Download",
173
+ showToast: false,
174
+ action: () => downloadText(
175
+ `${base}.csv`,
176
+ rowsToCsv(tabular.rows, tabular.columns),
177
+ "text/csv"
178
+ )
179
+ });
180
+ items.push({
181
+ key: "download-xlsx",
182
+ icon: FileSpreadsheet,
183
+ label: "Download as Excel (.xlsx)",
184
+ description: "Best for spreadsheets",
185
+ category: "Download",
186
+ showToast: false,
187
+ action: () => {
188
+ void rowsToXlsx(tabular.rows, tabular.columns, `${base}.xlsx`);
189
+ }
190
+ });
191
+ }
192
+ return items;
193
+ }, [
194
+ allowConvertToShape,
195
+ effectiveContent,
196
+ openConvertToShape,
197
+ openSaveToTable,
198
+ parsed,
199
+ tabular
200
+ ]);
201
+ const compactForm = useMemo(() => {
202
+ if (!parsed.ok) return null;
203
+ try {
204
+ return stringifyCompact(parsed.value, { maxWidth: 100, indent: 2 });
205
+ } catch {
206
+ return null;
207
+ }
208
+ }, [parsed]);
209
+ const expandedForm = useMemo(() => {
210
+ if (!parsed.ok) return null;
211
+ try {
212
+ return JSON.stringify(parsed.value, null, 2);
213
+ } catch {
214
+ return null;
215
+ }
216
+ }, [parsed]);
217
+ const isCompactFormatted = compactForm !== null && effectiveContent.trim() === compactForm.trim();
218
+ const applyFormat = (next) => {
219
+ if (next === effectiveContent) return;
220
+ if (onCodeChange) {
221
+ if (formatOverride !== null) setFormatOverride(null);
222
+ onCodeChange(next);
223
+ } else {
224
+ setFormatOverride(next);
225
+ }
226
+ };
227
+ const formatMenuItems = useMemo(() => {
228
+ const items = [];
229
+ if (compactForm) {
230
+ items.push({
231
+ key: "format-compact",
232
+ icon: AlignJustify,
233
+ iconColor: "text-sky-600 dark:text-sky-400",
234
+ label: "Compact formatting",
235
+ description: "Inline leaf objects and arrays that fit on one line. Updates the JSON text.",
236
+ category: "Format",
237
+ showToast: false,
238
+ disabled: isCompactFormatted,
239
+ action: () => applyFormat(compactForm)
240
+ });
241
+ }
242
+ if (expandedForm) {
243
+ items.push({
244
+ key: "format-expanded",
245
+ icon: Code2,
246
+ iconColor: "text-sky-600 dark:text-sky-400",
247
+ label: "Standard formatting",
248
+ description: "Two-space pretty-print. Updates the JSON text.",
249
+ category: "Format",
250
+ showToast: false,
251
+ disabled: !isCompactFormatted && effectiveContent.trim() === expandedForm.trim(),
252
+ action: () => applyFormat(expandedForm)
253
+ });
254
+ }
255
+ return items;
256
+ }, [compactForm, expandedForm, isCompactFormatted, effectiveContent]);
257
+ const fullMenuItems = useMemo(
258
+ () => [...formatMenuItems, ...jsonMenuItems],
259
+ [formatMenuItems, jsonMenuItems]
260
+ );
261
+ const canInspect = parsed.ok;
262
+ const activeMode = canInspect ? mode : "code";
263
+ const toggleFormat = () => {
264
+ if (isCompactFormatted) {
265
+ if (expandedForm) applyFormat(expandedForm);
266
+ } else {
267
+ if (compactForm) applyFormat(compactForm);
268
+ }
269
+ };
270
+ const viewToggle = /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
271
+ /* @__PURE__ */ jsx(
272
+ ViewToggle,
273
+ {
274
+ mode: activeMode,
275
+ onChange: setMode,
276
+ inspectAvailable: canInspect,
277
+ tabularAvailable: tabular.isTabular
278
+ }
279
+ ),
280
+ activeMode === "code" && /* @__PURE__ */ jsx(
281
+ FormatToggleButton,
282
+ {
283
+ isCompact: isCompactFormatted,
284
+ disabled: !compactForm || !expandedForm,
285
+ onToggle: toggleFormat
286
+ }
287
+ )
288
+ ] });
289
+ if (!parsed.ok) {
290
+ return /* @__PURE__ */ jsx(
291
+ "div",
292
+ {
293
+ "data-content-renderer": "JsonBlock",
294
+ onClick: (e) => e.stopPropagation(),
295
+ onMouseDown: (e) => e.stopPropagation(),
296
+ children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(PaneFallback, { label: "Loading code\u2026" }), children: /* @__PURE__ */ jsx(
297
+ CodeBlockWithContextAttach,
298
+ {
299
+ showSource: cardShowsSource,
300
+ code: content,
301
+ language: "json",
302
+ meta,
303
+ className,
304
+ isStreamActive,
305
+ allowEdit,
306
+ customBuiltinKeys,
307
+ onCodeChange,
308
+ headerLeftSlot: viewToggle,
309
+ extraMenuItems: fullMenuItems,
310
+ conversationId,
311
+ messageId
312
+ }
313
+ ) })
314
+ }
315
+ );
316
+ }
317
+ const data = parsed.value;
318
+ const tabularCaption = tabular.isTabular && `${tabular.rows.length} row${tabular.rows.length === 1 ? "" : "s"} \xD7 ${tabular.columns.length} col${tabular.columns.length === 1 ? "" : "s"}`;
319
+ const stopBubble = (e) => e.stopPropagation();
320
+ const routedKey = !isStreamActive && allowConvertToShape && valueCarriesKind(data) ? canonicalJson(data) : null;
321
+ if (routedKey !== null && !routedAbove.includes(routedKey)) {
322
+ return /* @__PURE__ */ jsx(JsonKindRouteContext.Provider, { value: [...routedAbove, routedKey], children: /* @__PURE__ */ jsxs(
323
+ "div",
324
+ {
325
+ "data-content-renderer": "JsonBlock",
326
+ "data-kind-route": "answer-value",
327
+ onClick: stopBubble,
328
+ onMouseDown: stopBubble,
329
+ onMouseUp: stopBubble,
330
+ onDoubleClick: stopBubble,
331
+ children: [
332
+ kindMarkers.length > 0 ? /* @__PURE__ */ jsx(KindEscapedNotice, { markers: kindMarkers, rendered: true }) : null,
333
+ /* @__PURE__ */ jsx(KindValueFrontDoor, { value: data })
334
+ ]
335
+ }
336
+ ) });
337
+ }
338
+ return /* @__PURE__ */ jsxs(
339
+ "div",
340
+ {
341
+ "data-content-renderer": "JsonBlock",
342
+ onClick: stopBubble,
343
+ onMouseDown: stopBubble,
344
+ onMouseUp: stopBubble,
345
+ onDoubleClick: stopBubble,
346
+ children: [
347
+ kindMarkers.length > 0 ? /* @__PURE__ */ jsx(KindEscapedNotice, { markers: kindMarkers }) : null,
348
+ mode === "code" ? /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(PaneFallback, { label: "Loading code\u2026" }), children: /* @__PURE__ */ jsx(
349
+ CodeBlockWithContextAttach,
350
+ {
351
+ showSource: cardShowsSource,
352
+ code: effectiveContent,
353
+ language: "json",
354
+ meta,
355
+ className,
356
+ isStreamActive,
357
+ allowEdit,
358
+ customBuiltinKeys,
359
+ onCodeChange: onCodeChange ? (next) => {
360
+ if (formatOverride !== null) setFormatOverride(null);
361
+ onCodeChange(next);
362
+ } : (next) => setFormatOverride(next),
363
+ headerLeftSlot: viewToggle,
364
+ extraMenuItems: fullMenuItems,
365
+ conversationId,
366
+ messageId
367
+ }
368
+ ) }) : /* @__PURE__ */ jsxs(
369
+ "div",
370
+ {
371
+ className: cn(
372
+ "w-full my-4 rounded-xl overflow-hidden border border-neutral-200 dark:border-neutral-700 bg-background",
373
+ className
374
+ ),
375
+ children: [
376
+ /* @__PURE__ */ jsx(
377
+ JsonViewHeader,
378
+ {
379
+ toggle: viewToggle,
380
+ menuItems: fullMenuItems,
381
+ caption: mode === "table" ? tabularCaption || "" : "",
382
+ content: effectiveContent
383
+ }
384
+ ),
385
+ /* @__PURE__ */ jsxs("div", { className: "bg-card", children: [
386
+ mode === "tree" && /* @__PURE__ */ jsx("div", { className: "max-h-[600px] overflow-auto", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(PaneFallback, { label: "Loading tree\u2026" }), children: /* @__PURE__ */ jsx(JsonTreeViewer, { data }) }) }),
387
+ mode === "table" && tabular.isTabular && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(PaneFallback, { label: "Loading table\u2026" }), children: /* @__PURE__ */ jsx(
388
+ JsonTableView,
389
+ {
390
+ rows: tabular.rows,
391
+ columns: tabular.columns,
392
+ caption: tabularCaption
393
+ }
394
+ ) }),
395
+ mode === "explorer" && /* @__PURE__ */ jsx("div", { className: "max-h-[600px] overflow-auto", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(PaneFallback, { label: "Loading explorer\u2026" }), children: /* @__PURE__ */ jsx(RawJsonExplorer, { pageData: data }) }) })
396
+ ] })
397
+ ]
398
+ }
399
+ )
400
+ ]
401
+ }
402
+ );
403
+ };
404
+ const FormatToggleButton = ({
405
+ isCompact,
406
+ disabled,
407
+ onToggle
408
+ }) => {
409
+ return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
410
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "outline", icon: /* @__PURE__ */ jsx(AlignJustify, {}), onMouseDown: (e) => e.stopPropagation(), onClick: (e) => {
411
+ e.stopPropagation();
412
+ if (!disabled) onToggle();
413
+ }, disabled, title: disabled ? "Available when the JSON is valid" : isCompact ? "Expand JSON" : "Compact JSON", "aria-label": isCompact ? "Expand JSON" : "Compact JSON" }) }),
414
+ /* @__PURE__ */ jsx(TooltipContent, { side: "bottom", className: "text-xs", children: disabled ? "Available when the JSON is valid" : isCompact ? "Reformat to standard pretty-print (updates the text)" : "Reformat to compact (inlines leaf objects, updates the text)" })
415
+ ] }) });
416
+ };
417
+ const VIEW_BUTTON = "h-5 w-5 flex items-center justify-center rounded transition-colors";
418
+ const ViewToggle = ({
419
+ mode,
420
+ onChange,
421
+ inspectAvailable,
422
+ tabularAvailable
423
+ }) => {
424
+ const items = [
425
+ { id: "code", label: "Code", icon: Code2, tooltip: "Code" },
426
+ {
427
+ id: "tree",
428
+ label: "Tree",
429
+ icon: ListTree,
430
+ disabled: !inspectAvailable,
431
+ tooltip: inspectAvailable ? "Tree" : "Available when the JSON is valid"
432
+ },
433
+ {
434
+ id: "table",
435
+ label: "Table",
436
+ icon: StretchHorizontal,
437
+ disabled: !inspectAvailable || !tabularAvailable,
438
+ tooltip: tabularAvailable ? "Table" : inspectAvailable ? "Table view available when JSON is an array of objects" : "Available when the JSON is valid"
439
+ },
440
+ {
441
+ id: "explorer",
442
+ label: "Path",
443
+ icon: Compass,
444
+ disabled: !inspectAvailable,
445
+ tooltip: inspectAvailable ? "Path explorer" : "Available when the JSON is valid"
446
+ }
447
+ ];
448
+ return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-0.5 rounded-md border border-border/50 bg-background/50 p-0.5", children: items.map((item) => {
449
+ const Icon = item.icon;
450
+ const active = mode === item.id;
451
+ const button = /* @__PURE__ */ jsx(
452
+ "button",
453
+ {
454
+ type: "button",
455
+ onClick: (e) => {
456
+ e.stopPropagation();
457
+ if (!item.disabled) onChange(item.id);
458
+ },
459
+ disabled: item.disabled,
460
+ title: item.tooltip ?? item.label,
461
+ "aria-label": `${item.label} view`,
462
+ "aria-pressed": active,
463
+ className: cn(
464
+ VIEW_BUTTON,
465
+ active ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:text-foreground hover:bg-muted",
466
+ item.disabled && "opacity-40 cursor-not-allowed"
467
+ ),
468
+ children: /* @__PURE__ */ jsx(Icon, { className: "h-3 w-3" })
469
+ },
470
+ item.id
471
+ );
472
+ return /* @__PURE__ */ jsxs(Tooltip, { children: [
473
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: button }),
474
+ /* @__PURE__ */ jsx(TooltipContent, { side: "bottom", className: "text-xs", children: item.tooltip })
475
+ ] }, item.id);
476
+ }) }) });
477
+ };
478
+ const JsonViewHeader = ({
479
+ toggle,
480
+ menuItems,
481
+ caption,
482
+ content
483
+ }) => {
484
+ const { copyText } = useClipboard({
485
+ notify: (message, kind) => kind === "error" ? toast.error(message) : toast.success(message)
486
+ });
487
+ const menu = useAdvancedMenu();
488
+ const kebabRef = useRef(null);
489
+ const [copied, setCopied] = useState(false);
490
+ const handleCopy = async () => {
491
+ try {
492
+ await copyText(content);
493
+ setCopied(true);
494
+ toast.success("Copied JSON to clipboard");
495
+ setTimeout(() => setCopied(false), 1500);
496
+ } catch {
497
+ toast.error("Failed to copy");
498
+ }
499
+ };
500
+ const fullMenuItems = [
501
+ {
502
+ key: "copy-json",
503
+ icon: Copy,
504
+ label: "Copy JSON",
505
+ category: "Copy",
506
+ showToast: false,
507
+ action: handleCopy
508
+ },
509
+ ...menuItems
510
+ ];
511
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 px-3 py-1.5 bg-zinc-300 dark:bg-zinc-700 text-xs text-gray-700 dark:text-gray-300", children: [
512
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 min-w-0", children: [
513
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 shrink-0", children: [
514
+ /* @__PURE__ */ jsx(FileJson, { className: "h-3.5 w-3.5 text-amber-600 dark:text-amber-400" }),
515
+ /* @__PURE__ */ jsx("span", { className: "font-mono text-[11px] font-semibold uppercase tracking-wide", children: "JSON" })
516
+ ] }),
517
+ toggle,
518
+ caption && /* @__PURE__ */ jsx("span", { className: "text-[11px] text-muted-foreground truncate", children: caption })
519
+ ] }),
520
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-0.5", children: [
521
+ /* @__PURE__ */ jsx(
522
+ IconButton,
523
+ {
524
+ icon: Copy,
525
+ tooltip: copied ? "Copied!" : "Copy JSON",
526
+ variant: "ghost",
527
+ onClick: handleCopy,
528
+ tooltipSide: "bottom"
529
+ }
530
+ ),
531
+ /* @__PURE__ */ jsx("div", { ref: kebabRef, onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx(
532
+ IconButton,
533
+ {
534
+ icon: MoreHorizontal,
535
+ tooltip: "More actions",
536
+ variant: "ghost",
537
+ tooltipSide: "bottom",
538
+ onClick: () => {
539
+ if (kebabRef.current) menu.open(kebabRef.current);
540
+ }
541
+ }
542
+ ) }),
543
+ /* @__PURE__ */ jsx(
544
+ AdvancedMenu,
545
+ {
546
+ ...menu.menuProps,
547
+ anchorElement: menu.anchorElement,
548
+ items: fullMenuItems,
549
+ title: "JSON actions",
550
+ position: "bottom-right",
551
+ width: "260px",
552
+ maxWidth: "300px"
553
+ }
554
+ )
555
+ ] })
556
+ ] });
557
+ };
558
+ var JsonBlock_default = JsonBlock;
559
+ export {
560
+ JsonBlock,
561
+ JsonBlock_default as default
562
+ };
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ interface JsonTableViewProps {
3
+ rows: Record<string, unknown>[];
4
+ columns: string[];
5
+ /** Optional preamble shown above the table — e.g. "12 rows × 5 cols". */
6
+ caption?: React.ReactNode;
7
+ className?: string;
8
+ }
9
+ export declare const JsonTableView: React.FC<JsonTableViewProps>;
10
+ export default JsonTableView;