@ai-matrx/rich-content 0.2.4 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/code-block/CodeBlock.d.ts +44 -0
- package/dist/code-block/CodeBlock.js +449 -0
- package/dist/code-block/CodeBlockHeader.d.ts +63 -0
- package/dist/code-block/CodeBlockHeader.js +472 -0
- package/dist/code-block/CodeEditorLoading.d.ts +3 -0
- package/dist/code-block/CodeEditorLoading.js +34 -0
- package/dist/code-block/LanguageDisplay.d.ts +28 -0
- package/dist/code-block/LanguageDisplay.js +279 -0
- package/dist/code-block/SmallCodeEditor.d.ts +30 -0
- package/dist/code-block/SmallCodeEditor.js +22 -0
- package/dist/code-block/StickyButtons.d.ts +35 -0
- package/dist/code-block/StickyButtons.js +88 -0
- package/dist/code-block/highlight/ShikiCodeView.d.ts +26 -0
- package/dist/code-block/highlight/ShikiCodeView.js +134 -0
- package/dist/code-block/highlight/shiki-highlighter.d.ts +14 -0
- package/dist/code-block/highlight/shiki-highlighter.js +126 -0
- package/dist/code-block/highlight/useHighlightedLines.d.ts +18 -0
- package/dist/code-block/highlight/useHighlightedLines.js +142 -0
- package/dist/code-block/sticky-inset.d.ts +6 -0
- package/dist/code-block/sticky-inset.js +10 -0
- package/dist/display/block-interaction.d.ts +33 -0
- package/dist/display/block-interaction.js +13 -0
- package/dist/display/blocks/ChatCollapsibleWrapper.d.ts +13 -0
- package/dist/display/blocks/ChatCollapsibleWrapper.js +56 -0
- package/dist/display/blocks/buildMediaSource.d.ts +25 -0
- package/dist/display/blocks/buildMediaSource.js +43 -0
- package/dist/display/blocks/canvas-adaptive.d.ts +118 -0
- package/dist/display/blocks/canvas-adaptive.js +127 -0
- package/dist/display/blocks/canvas-fit.d.ts +24 -0
- package/dist/display/blocks/canvas-fit.js +19 -0
- package/dist/display/blocks/chart/ChartBlock.d.ts +8 -0
- package/dist/display/blocks/chart/ChartBlock.js +125 -0
- package/dist/display/blocks/chart/ChartCanvas.d.ts +18 -0
- package/dist/display/blocks/chart/ChartCanvas.js +159 -0
- package/dist/display/blocks/chart/TableChart.d.ts +25 -0
- package/dist/display/blocks/chart/TableChart.js +97 -0
- package/dist/display/blocks/chart/chart-spec.d.ts +39 -0
- package/dist/display/blocks/chart/chart-spec.js +128 -0
- package/dist/display/blocks/chart/labels.d.ts +20 -0
- package/dist/display/blocks/chart/labels.js +7 -0
- package/dist/display/blocks/chart/table-chart.d.ts +37 -0
- package/dist/display/blocks/chart/table-chart.js +231 -0
- package/dist/display/blocks/common/BlockHeaderWrapper.d.ts +56 -0
- package/dist/display/blocks/common/BlockHeaderWrapper.js +310 -0
- package/dist/display/blocks/common/ContentBlockWrapper.d.ts +40 -0
- package/dist/display/blocks/common/ContentBlockWrapper.js +214 -0
- package/dist/display/blocks/common/SandboxedHtml.d.ts +27 -0
- package/dist/display/blocks/common/SandboxedHtml.js +26 -0
- package/dist/display/blocks/diagram/DiagramLoadingVisualization.d.ts +6 -0
- package/dist/display/blocks/diagram/DiagramLoadingVisualization.js +190 -0
- package/dist/display/blocks/diagram/InteractiveDiagramBlock.d.ts +51 -0
- package/dist/display/blocks/diagram/InteractiveDiagramBlock.js +2415 -0
- package/dist/display/blocks/diagram/diagram-printer.d.ts +16 -0
- package/dist/display/blocks/diagram/diagram-printer.js +294 -0
- package/dist/display/blocks/diagram/diagram-visual-defaults.d.ts +116 -0
- package/dist/display/blocks/diagram/diagram-visual-defaults.js +400 -0
- package/dist/display/blocks/diagram/layout-utils.d.ts +90 -0
- package/dist/display/blocks/diagram/layout-utils.js +347 -0
- package/dist/display/blocks/diagram/parseDiagramJSON.d.ts +105 -0
- package/dist/display/blocks/diagram/parseDiagramJSON.js +296 -0
- package/dist/display/blocks/diagram/presentation-direction.d.ts +29 -0
- package/dist/display/blocks/diagram/presentation-direction.js +19 -0
- package/dist/display/blocks/diagram/ui-utils.d.ts +1 -0
- package/dist/display/blocks/diagram/ui-utils.js +18 -0
- package/dist/display/blocks/diff/DiffBlock.d.ts +10 -0
- package/dist/display/blocks/diff/DiffBlock.js +119 -0
- package/dist/display/blocks/diff/DiffCanvas.d.ts +15 -0
- package/dist/display/blocks/diff/DiffCanvas.js +20 -0
- package/dist/display/blocks/generic/GenericStructuredBlock.d.ts +24 -0
- package/dist/display/blocks/generic/GenericStructuredBlock.js +53 -0
- package/dist/display/blocks/generic/StructuredValueTabs.d.ts +21 -0
- package/dist/display/blocks/generic/StructuredValueTabs.js +124 -0
- package/dist/display/blocks/generic/tile-actions-slot.d.ts +39 -0
- package/dist/display/blocks/generic/tile-actions-slot.js +33 -0
- package/dist/display/blocks/images/ImageBlock.d.ts +8 -0
- package/dist/display/blocks/images/ImageBlock.js +265 -0
- package/dist/display/blocks/json/JsonBlock.d.ts +34 -0
- package/dist/display/blocks/json/JsonBlock.js +562 -0
- package/dist/display/blocks/json/JsonTableView.d.ts +10 -0
- package/dist/display/blocks/json/JsonTableView.js +173 -0
- package/dist/display/blocks/json/json-compact-stringify.d.ts +25 -0
- package/dist/display/blocks/json/json-compact-stringify.js +52 -0
- package/dist/display/blocks/json/json-tabular-utils.d.ts +65 -0
- package/dist/display/blocks/json/json-tabular-utils.js +121 -0
- package/dist/display/blocks/links/LinkComponent.d.ts +6 -0
- package/dist/display/blocks/links/LinkComponent.js +373 -0
- package/dist/display/blocks/links/LinkComponentWithFetch.d.ts +1 -0
- package/dist/display/blocks/links/LinkComponentWithFetch.js +0 -0
- package/dist/display/blocks/markdown/MarkdownKindBlock.d.ts +48 -0
- package/dist/display/blocks/markdown/MarkdownKindBlock.js +52 -0
- package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.d.ts +17 -0
- package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.js +70 -0
- package/dist/display/blocks/mermaid/MermaidBlock.d.ts +19 -0
- package/dist/display/blocks/mermaid/MermaidBlock.js +386 -0
- package/dist/display/blocks/search-replace/SearchReplaceBlock.d.ts +50 -0
- package/dist/display/blocks/search-replace/SearchReplaceBlock.js +71 -0
- package/dist/display/blocks/svg/SvgBlock.d.ts +8 -0
- package/dist/display/blocks/svg/SvgBlock.js +126 -0
- package/dist/display/blocks/table/StreamingTableRenderer.d.ts +53 -0
- package/dist/display/blocks/table/StreamingTableRenderer.js +907 -0
- package/dist/display/blocks/table/TableRenderPathDiagnostic.d.ts +21 -0
- package/dist/display/blocks/table/TableRenderPathDiagnostic.js +79 -0
- package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.d.ts +14 -0
- package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.js +15 -0
- package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.d.ts +13 -0
- package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.js +19 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTrace.d.ts +30 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTrace.js +75 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.d.ts +13 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.js +48 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.d.ts +12 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.js +19 -0
- package/dist/display/blocks/toml/TomlBlock.d.ts +7 -0
- package/dist/display/blocks/toml/TomlBlock.js +167 -0
- package/dist/display/blocks/tree/TreeBlock.d.ts +7 -0
- package/dist/display/blocks/tree/TreeBlock.js +163 -0
- package/dist/display/blocks/xml/XmlBlock.d.ts +23 -0
- package/dist/display/blocks/xml/XmlBlock.js +197 -0
- package/dist/display/blocks/xml/readXmlTag.d.ts +1 -0
- package/dist/display/blocks/xml/readXmlTag.js +1 -0
- package/dist/display/blocks/xml/xml-tokenize.d.ts +13 -0
- package/dist/display/blocks/xml/xml-tokenize.js +169 -0
- package/dist/display/blocks/yaml/YamlBlock.d.ts +7 -0
- package/dist/display/blocks/yaml/YamlBlock.js +191 -0
- package/dist/display/chat-markdown/BasicMarkdownContent.d.ts +29 -0
- package/dist/display/chat-markdown/BasicMarkdownContent.js +122 -0
- package/dist/display/chat-markdown/BlockRenderingContext.d.ts +23 -0
- package/dist/display/chat-markdown/BlockRenderingContext.js +17 -0
- package/dist/display/chat-markdown/ConfigurableMarkdownContent.d.ts +172 -0
- package/dist/display/chat-markdown/ConfigurableMarkdownContent.js +649 -0
- package/dist/display/chat-markdown/InlineCodeSnippet.d.ts +19 -0
- package/dist/display/chat-markdown/InlineCodeSnippet.js +146 -0
- package/dist/display/chat-markdown/InlineCodeSnippetKindGate.d.ts +11 -0
- package/dist/display/chat-markdown/InlineCodeSnippetKindGate.js +9 -0
- package/dist/display/chat-markdown/KindTextGate.d.ts +31 -0
- package/dist/display/chat-markdown/KindTextGate.js +60 -0
- package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.d.ts +6 -0
- package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.js +92 -0
- package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.d.ts +72 -0
- package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.js +94 -0
- package/dist/display/chat-markdown/block-registry/BlockRenderer.d.ts +126 -0
- package/dist/display/chat-markdown/block-registry/BlockRenderer.js +473 -0
- package/dist/display/chat-markdown/block-registry/block-dispatch.d.ts +410 -0
- package/dist/display/chat-markdown/block-registry/block-dispatch.js +495 -0
- package/dist/display/chat-markdown/block-registry/json-parse-utils.d.ts +13 -0
- package/dist/display/chat-markdown/block-registry/json-parse-utils.js +236 -0
- package/dist/display/chat-markdown/constants.d.ts +14 -0
- package/dist/display/chat-markdown/constants.js +317 -0
- package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.d.ts +31 -0
- package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.js +62 -0
- package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.d.ts +12 -0
- package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.js +18 -0
- package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.d.ts +22 -0
- package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.js +130 -0
- package/dist/display/chat-markdown/diff-blocks/diff-style-registry.d.ts +21 -0
- package/dist/display/chat-markdown/diff-blocks/diff-style-registry.js +91 -0
- package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.d.ts +26 -0
- package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.js +186 -0
- package/dist/display/chat-markdown/diff-blocks/types.d.ts +56 -0
- package/dist/display/chat-markdown/diff-blocks/types.js +0 -0
- package/dist/display/chat-markdown/internal-handlers/BlockFallback.d.ts +20 -0
- package/dist/display/chat-markdown/internal-handlers/BlockFallback.js +83 -0
- package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.d.ts +4 -0
- package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.js +16 -0
- package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.d.ts +17 -0
- package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.js +40 -0
- package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.d.ts +8 -0
- package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.js +91 -0
- package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.d.ts +20 -0
- package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.js +72 -0
- package/dist/display/chat-markdown/kind-source-view.d.ts +14 -0
- package/dist/display/chat-markdown/kind-source-view.js +14 -0
- package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.d.ts +28 -0
- package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.js +65 -0
- package/dist/display/chat-markdown/progressive-mount.d.ts +18 -0
- package/dist/display/chat-markdown/progressive-mount.js +90 -0
- package/dist/display/chat-markdown/render-block-to-content-block.d.ts +31 -0
- package/dist/display/chat-markdown/render-block-to-content-block.js +32 -0
- package/dist/display/chat-markdown/settle-stream-blocks.d.ts +50 -0
- package/dist/display/chat-markdown/settle-stream-blocks.js +26 -0
- package/dist/display/chat-markdown/stable-blocks.d.ts +15 -0
- package/dist/display/chat-markdown/stable-blocks.js +54 -0
- package/dist/display/chat-markdown/types.d.ts +11 -0
- package/dist/display/chat-markdown/types.js +26 -0
- package/dist/display/specimen/SpecimenContext.d.ts +26 -0
- package/dist/display/specimen/SpecimenContext.js +64 -0
- package/dist/display/tables/MarkdownTable.d.ts +23 -0
- package/dist/display/tables/MarkdownTable.js +769 -0
- package/dist/display/tables/MarkdownTableScrollArea.d.ts +12 -0
- package/dist/display/tables/MarkdownTableScrollArea.js +92 -0
- package/dist/display/tables/SendToGoogleSheetButton.d.ts +19 -0
- package/dist/display/tables/SendToGoogleSheetButton.js +93 -0
- package/dist/display/tables/SendToWorkbookButton.d.ts +24 -0
- package/dist/display/tables/SendToWorkbookButton.js +93 -0
- package/dist/display/tables/TableSaveToMenu.d.ts +16 -0
- package/dist/display/tables/TableSaveToMenu.js +98 -0
- package/dist/display/tables/TableWithSeparatedControls.d.ts +22 -0
- package/dist/display/tables/TableWithSeparatedControls.js +574 -0
- package/dist/display/tables/ViewTableModal.d.ts +14 -0
- package/dist/display/tables/ViewTableModal.js +67 -0
- package/dist/display/tables/editing/ColumnActionsMenu.d.ts +16 -0
- package/dist/display/tables/editing/ColumnActionsMenu.js +80 -0
- package/dist/display/tables/editing/RowActionsMenu.d.ts +16 -0
- package/dist/display/tables/editing/RowActionsMenu.js +80 -0
- package/dist/display/tables/editing/TableEditToolbar.d.ts +15 -0
- package/dist/display/tables/editing/TableEditToolbar.js +63 -0
- package/dist/display/tables/editing/tableMutations.d.ts +50 -0
- package/dist/display/tables/editing/tableMutations.js +148 -0
- package/dist/display/tables/editing/useDoubleClickEdit.d.ts +43 -0
- package/dist/display/tables/editing/useDoubleClickEdit.js +51 -0
- package/dist/display/tables/editing/useTableUndo.d.ts +25 -0
- package/dist/display/tables/editing/useTableUndo.js +17 -0
- package/dist/display/tables/table-action-row.d.ts +8 -0
- package/dist/display/tables/table-action-row.js +31 -0
- package/dist/display/tables/table-viewer.d.ts +13 -0
- package/dist/display/tables/table-viewer.js +18 -0
- package/dist/host/ErrorActions.d.ts +1 -1
- package/dist/host/ErrorNotice.d.ts +10 -0
- package/dist/host/ErrorNotice.js +19 -0
- package/dist/host/app-bindings.d.ts +155 -0
- package/dist/host/app-bindings.js +160 -0
- package/dist/host/diagnostics.d.ts +2 -2
- package/dist/host/diagnostics.js +2 -1
- package/dist/host/tables.d.ts +1 -6
- package/dist/host/types.d.ts +14 -7
- package/dist/levels/RichContent.d.ts +3 -0
- package/dist/levels/RichContent.js +102 -0
- package/dist/levels/RichContentInline.d.ts +28 -0
- package/dist/levels/RichContentInline.js +61 -0
- package/dist/levels/RichContentPreview.d.ts +12 -0
- package/dist/levels/RichContentPreview.js +39 -0
- package/dist/levels/RichContentStandardImpl.d.ts +12 -0
- package/dist/levels/RichContentStandardImpl.js +27 -0
- package/dist/levels/RichContentStaticProse.d.ts +46 -0
- package/dist/levels/RichContentStaticProse.js +100 -0
- package/dist/levels/depth.d.ts +18 -0
- package/dist/levels/depth.js +32 -0
- package/dist/levels/prose/inline-level-elements.d.ts +19 -0
- package/dist/levels/prose/inline-level-elements.js +103 -0
- package/dist/levels/prose/prose-block-elements.d.ts +25 -0
- package/dist/levels/prose/prose-block-elements.js +313 -0
- package/dist/levels/prose/prose-inline-elements.d.ts +13 -0
- package/dist/levels/prose/prose-inline-elements.js +143 -0
- package/dist/levels/prose/prose-prepare.d.ts +50 -0
- package/dist/levels/prose/prose-prepare.js +246 -0
- package/dist/levels/prose/remote-image-policy.d.ts +34 -0
- package/dist/levels/prose/remote-image-policy.js +153 -0
- package/dist/levels/prose/variant-root.d.ts +9 -0
- package/dist/levels/prose/variant-root.js +34 -0
- package/dist/levels/rich-content-types.d.ts +93 -0
- package/dist/levels/rich-content-types.js +4 -0
- package/dist/levels/server/DelimiterViolationReport.d.ts +7 -0
- package/dist/levels/server/DelimiterViolationReport.js +24 -0
- package/dist/levels/server/RichContentServer.d.ts +27 -0
- package/dist/levels/server/RichContentServer.js +97 -0
- package/dist/levels/standard/NestedRichContent.d.ts +7 -0
- package/dist/levels/standard/NestedRichContent.js +70 -0
- package/dist/levels/standard/StandardBlocks.d.ts +13 -0
- package/dist/levels/standard/StandardBlocks.js +239 -0
- package/dist/levels/standard/StandardKindRegion.d.ts +14 -0
- package/dist/levels/standard/StandardKindRegion.js +69 -0
- package/dist/levels/standard/standard-kind-region.d.ts +19 -0
- package/dist/levels/standard/standard-kind-region.js +21 -0
- package/dist/levels/standard/static-standard.d.ts +23 -0
- package/dist/levels/standard/static-standard.js +187 -0
- package/dist/levels/standard/stream-holdback.d.ts +2 -0
- package/dist/levels/standard/stream-holdback.js +77 -0
- package/dist/mermaid/MermaidFullscreen.d.ts +17 -0
- package/dist/mermaid/MermaidFullscreen.js +71 -0
- package/dist/mermaid/MermaidRenderer.d.ts +20 -0
- package/dist/mermaid/MermaidRenderer.js +267 -0
- package/dist/mermaid/MermaidView.d.ts +27 -0
- package/dist/mermaid/MermaidView.js +68 -0
- package/dist/mermaid/MermaidViewport.d.ts +75 -0
- package/dist/mermaid/MermaidViewport.js +286 -0
- package/dist/mermaid/adapters/er.d.ts +10 -0
- package/dist/mermaid/adapters/er.js +205 -0
- package/dist/mermaid/adapters/flowchart.d.ts +17 -0
- package/dist/mermaid/adapters/flowchart.js +634 -0
- package/dist/mermaid/adapters/journey.d.ts +9 -0
- package/dist/mermaid/adapters/journey.js +207 -0
- package/dist/mermaid/adapters/mindmap.d.ts +12 -0
- package/dist/mermaid/adapters/mindmap.js +252 -0
- package/dist/mermaid/adapters/pie.d.ts +7 -0
- package/dist/mermaid/adapters/pie.js +172 -0
- package/dist/mermaid/adapters/quadrant.d.ts +8 -0
- package/dist/mermaid/adapters/quadrant.js +231 -0
- package/dist/mermaid/adapters/register.d.ts +7 -0
- package/dist/mermaid/adapters/register.js +19 -0
- package/dist/mermaid/adapters/sequence.d.ts +8 -0
- package/dist/mermaid/adapters/sequence.js +251 -0
- package/dist/mermaid/adapters/state.d.ts +12 -0
- package/dist/mermaid/adapters/state.js +245 -0
- package/dist/mermaid/adapters/timeline.d.ts +8 -0
- package/dist/mermaid/adapters/timeline.js +245 -0
- package/dist/mermaid/catalog.d.ts +33 -0
- package/dist/mermaid/catalog.js +202 -0
- package/dist/mermaid/diagram-type.d.ts +39 -0
- package/dist/mermaid/diagram-type.js +89 -0
- package/dist/mermaid/export.d.ts +21 -0
- package/dist/mermaid/export.js +112 -0
- package/dist/mermaid/extract-fence.d.ts +15 -0
- package/dist/mermaid/extract-fence.js +22 -0
- package/dist/mermaid/lazy-draw.d.ts +40 -0
- package/dist/mermaid/lazy-draw.js +168 -0
- package/dist/mermaid/model/adapter.d.ts +28 -0
- package/dist/mermaid/model/adapter.js +16 -0
- package/dist/mermaid/model/ops.d.ts +282 -0
- package/dist/mermaid/model/ops.js +9 -0
- package/dist/mermaid/model/round-trip.d.ts +22 -0
- package/dist/mermaid/model/round-trip.js +45 -0
- package/dist/mermaid/model/types.d.ts +271 -0
- package/dist/mermaid/model/types.js +0 -0
- package/dist/mermaid/print-render.d.ts +9 -0
- package/dist/mermaid/print-render.js +39 -0
- package/dist/mermaid/runtime.d.ts +25 -0
- package/dist/mermaid/runtime.js +183 -0
- package/dist/mermaid/sanitize.d.ts +46 -0
- package/dist/mermaid/sanitize.js +234 -0
- package/dist/mermaid/types.d.ts +43 -0
- package/dist/mermaid/types.js +21 -0
- package/dist/mermaid/view/ViewModePane.d.ts +24 -0
- package/dist/mermaid/view/ViewModePane.js +9 -0
- package/dist/utils/client-lazy.d.ts +1 -1
- package/dist/utils/client-lazy.js +4 -1
- package/dist/utils/lifted/DiffView.d.ts +10 -0
- package/dist/utils/lifted/DiffView.js +26 -0
- package/dist/utils/lifted/IconButton.d.ts +24 -0
- package/dist/utils/lifted/IconButton.js +43 -0
- package/dist/utils/lifted/MatrxMiniLoader.d.ts +1 -0
- package/dist/utils/lifted/MatrxMiniLoader.js +8 -0
- package/dist/utils/lifted/ShimmerText.d.ts +5 -0
- package/dist/utils/lifted/ShimmerText.js +21 -0
- package/dist/utils/lifted/SuspenseLoader.d.ts +16 -0
- package/dist/utils/lifted/SuspenseLoader.js +42 -0
- package/dist/utils/lifted/Tooltip.d.ts +20 -0
- package/dist/utils/lifted/Tooltip.js +52 -0
- package/dist/utils/lifted/artifactId.d.ts +34 -0
- package/dist/utils/lifted/artifactId.js +15 -0
- package/dist/utils/lifted/canvasContent.d.ts +63 -0
- package/dist/utils/lifted/canvasContent.js +98 -0
- package/dist/utils/lifted/captureReactError.d.ts +24 -0
- package/dist/utils/lifted/captureReactError.js +28 -0
- package/dist/utils/lifted/chunk-load-recovery.d.ts +25 -0
- package/dist/utils/lifted/chunk-load-recovery.js +36 -0
- package/dist/utils/lifted/code-editor-agent-types.d.ts +6 -0
- package/dist/utils/lifted/code-editor-agent-types.js +0 -0
- package/dist/utils/lifted/code-editor-agents.d.ts +39 -0
- package/dist/utils/lifted/code-editor-agents.js +52 -0
- package/dist/utils/lifted/code-language-extension.d.ts +1 -0
- package/dist/utils/lifted/code-language-extension.js +60 -0
- package/dist/utils/lifted/custom-icons.d.ts +16 -0
- package/dist/utils/lifted/custom-icons.js +47 -0
- package/dist/utils/lifted/durability.d.ts +16 -0
- package/dist/utils/lifted/durability.js +45 -0
- package/dist/utils/lifted/errors.d.ts +30 -0
- package/dist/utils/lifted/errors.js +29 -0
- package/dist/utils/lifted/html-document.d.ts +1 -0
- package/dist/utils/lifted/html-document.js +12 -0
- package/dist/utils/lifted/languageOptions.d.ts +9 -0
- package/dist/utils/lifted/languageOptions.js +52 -0
- package/dist/utils/lifted/languages.d.ts +34 -0
- package/dist/utils/lifted/languages.js +175 -0
- package/dist/utils/lifted/loading-spinner.d.ts +18 -0
- package/dist/utils/lifted/loading-spinner.js +200 -0
- package/dist/utils/lifted/media-refs.d.ts +13 -0
- package/dist/utils/lifted/media-refs.js +27 -0
- package/dist/utils/lifted/scroll-root.d.ts +1 -0
- package/dist/utils/lifted/scroll-root.js +25 -0
- package/dist/utils/lifted/syntax-themes.d.ts +32 -0
- package/dist/utils/lifted/syntax-themes.js +100 -0
- package/dist/utils/lifted/url-utm.d.ts +24 -0
- package/dist/utils/lifted/url-utm.js +66 -0
- package/dist/utils/lifted/use-is-mounted.d.ts +24 -0
- package/dist/utils/lifted/use-is-mounted.js +21 -0
- package/dist/utils/lifted/useToastManager.d.ts +1 -0
- package/dist/utils/lifted/useToastManager.js +7 -0
- package/dist/utils/report-kind-at-raw-renderer.d.ts +19 -0
- package/dist/utils/report-kind-at-raw-renderer.js +32 -0
- package/package.json +48 -10
|
@@ -0,0 +1,907 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useClipboard } from "@ai-matrx/kit/clipboard";
|
|
4
|
+
import { toast as copyToast } from "../../../host/toast.js";
|
|
5
|
+
import { rewriteTableSource } from "../../../utils/table-source.js";
|
|
6
|
+
import {
|
|
7
|
+
useState,
|
|
8
|
+
useEffect,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef
|
|
11
|
+
} from "react";
|
|
12
|
+
import { useIsMobile } from "@ai-matrx/kit/media-query";
|
|
13
|
+
import { cn } from "@ai-matrx/design-system";
|
|
14
|
+
import { RegionSkeleton } from "@ai-matrx/design-system/controls";
|
|
15
|
+
import { RichContent } from "../../../levels/RichContent.js";
|
|
16
|
+
import { useMarkdownStreaming } from "../../../markdown-core/streaming-context.js";
|
|
17
|
+
import { Button } from "@ai-matrx/design-system";
|
|
18
|
+
import {
|
|
19
|
+
Download,
|
|
20
|
+
Eye,
|
|
21
|
+
Edit,
|
|
22
|
+
Save,
|
|
23
|
+
X,
|
|
24
|
+
FileJson,
|
|
25
|
+
FileText,
|
|
26
|
+
FileSpreadsheet,
|
|
27
|
+
FileDown,
|
|
28
|
+
ChevronDown,
|
|
29
|
+
Columns3,
|
|
30
|
+
Maximize2,
|
|
31
|
+
EyeOff
|
|
32
|
+
} from "lucide-react";
|
|
33
|
+
import {
|
|
34
|
+
DropdownMenu,
|
|
35
|
+
DropdownMenuContent,
|
|
36
|
+
DropdownMenuItem,
|
|
37
|
+
DropdownMenuTrigger,
|
|
38
|
+
DropdownMenuSeparator,
|
|
39
|
+
DropdownMenuCheckboxItem,
|
|
40
|
+
DropdownMenuLabel
|
|
41
|
+
} from "@ai-matrx/design-system";
|
|
42
|
+
import { useOpenTableViewerWindow } from "../../../host/app-bindings.js";
|
|
43
|
+
import { useToastManager } from "../../../utils/lifted/useToastManager.js";
|
|
44
|
+
import { THEMES } from "../../themes.js";
|
|
45
|
+
import { TableSaveToMenu } from "../../tables/TableSaveToMenu.js";
|
|
46
|
+
import {
|
|
47
|
+
phoneStackCellProps,
|
|
48
|
+
useTableViewer
|
|
49
|
+
} from "../../tables/table-viewer.js";
|
|
50
|
+
import { useCanvasFit } from "../canvas-fit.js";
|
|
51
|
+
import { ChartThisButton, TableChartPanel } from "../chart/TableChart.js";
|
|
52
|
+
import { tableActionRowClass, useTableActionTitles } from "../../tables/table-action-row.js";
|
|
53
|
+
import { TableEditToolbar } from "../../tables/editing/TableEditToolbar.js";
|
|
54
|
+
import { RowActionsMenu } from "../../tables/editing/RowActionsMenu.js";
|
|
55
|
+
import { ColumnActionsMenu } from "../../tables/editing/ColumnActionsMenu.js";
|
|
56
|
+
import { useTableUndo } from "../../tables/editing/useTableUndo.js";
|
|
57
|
+
import { useDoubleClickEdit } from "../../tables/editing/useDoubleClickEdit.js";
|
|
58
|
+
import { MarkdownTableScrollArea } from "../../tables/MarkdownTableScrollArea.js";
|
|
59
|
+
import {
|
|
60
|
+
appendRow,
|
|
61
|
+
appendColumn,
|
|
62
|
+
clearAllContents,
|
|
63
|
+
insertRowAbove,
|
|
64
|
+
insertRowBelow,
|
|
65
|
+
removeRow,
|
|
66
|
+
clearRow,
|
|
67
|
+
duplicateRow,
|
|
68
|
+
insertColumnBefore,
|
|
69
|
+
insertColumnAfter,
|
|
70
|
+
removeColumn,
|
|
71
|
+
clearColumn,
|
|
72
|
+
duplicateColumn
|
|
73
|
+
} from "../../tables/editing/tableMutations.js";
|
|
74
|
+
import { useSpecimenMode } from "../../specimen/SpecimenContext.js";
|
|
75
|
+
import {
|
|
76
|
+
parseMarkdownTable,
|
|
77
|
+
cleanTableHeaderKey
|
|
78
|
+
} from "./parseMarkdownTable.js";
|
|
79
|
+
const NO_HIDDEN_COLUMNS = /* @__PURE__ */ new Set();
|
|
80
|
+
const ExportDropdownMenu = ({
|
|
81
|
+
tableData,
|
|
82
|
+
content,
|
|
83
|
+
copyTableToClipboard,
|
|
84
|
+
copyMarkdownToClipboard,
|
|
85
|
+
copyJsonToClipboard,
|
|
86
|
+
downloadCSV,
|
|
87
|
+
downloadMarkdown,
|
|
88
|
+
isStreamActive = false
|
|
89
|
+
}) => {
|
|
90
|
+
const [isDataStable, setIsDataStable] = useState(false);
|
|
91
|
+
const stabilityTimerRef = useRef(null);
|
|
92
|
+
const stableTableData = useMemo(
|
|
93
|
+
() => ({
|
|
94
|
+
headers: tableData.headers,
|
|
95
|
+
rows: tableData.rows,
|
|
96
|
+
normalizedData: tableData.normalizedData
|
|
97
|
+
}),
|
|
98
|
+
[
|
|
99
|
+
JSON.stringify(tableData.headers),
|
|
100
|
+
JSON.stringify(tableData.rows),
|
|
101
|
+
JSON.stringify(tableData.normalizedData)
|
|
102
|
+
]
|
|
103
|
+
);
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (isStreamActive) {
|
|
106
|
+
setIsDataStable(false);
|
|
107
|
+
if (stabilityTimerRef.current) {
|
|
108
|
+
clearTimeout(stabilityTimerRef.current);
|
|
109
|
+
stabilityTimerRef.current = null;
|
|
110
|
+
}
|
|
111
|
+
return void 0;
|
|
112
|
+
}
|
|
113
|
+
if (stabilityTimerRef.current) {
|
|
114
|
+
clearTimeout(stabilityTimerRef.current);
|
|
115
|
+
}
|
|
116
|
+
setIsDataStable(false);
|
|
117
|
+
stabilityTimerRef.current = setTimeout(() => {
|
|
118
|
+
setIsDataStable(true);
|
|
119
|
+
}, 1e3);
|
|
120
|
+
return () => {
|
|
121
|
+
if (stabilityTimerRef.current) {
|
|
122
|
+
clearTimeout(stabilityTimerRef.current);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}, [stableTableData, content, isStreamActive]);
|
|
126
|
+
if (isStreamActive || !isDataStable) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
130
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
131
|
+
Button,
|
|
132
|
+
{
|
|
133
|
+
variant: "outline",
|
|
134
|
+
size: "sm",
|
|
135
|
+
className: "flex items-center gap-2 hover:bg-blue-100 dark:hover:bg-blue-800/30",
|
|
136
|
+
children: [
|
|
137
|
+
/* @__PURE__ */ jsx(Download, { className: "h-4 w-4" }),
|
|
138
|
+
"Export",
|
|
139
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 ml-1" })
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
) }),
|
|
143
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-64", children: [
|
|
144
|
+
/* @__PURE__ */ jsxs(
|
|
145
|
+
DropdownMenuItem,
|
|
146
|
+
{
|
|
147
|
+
onClick: copyTableToClipboard,
|
|
148
|
+
className: "flex items-center gap-2 cursor-pointer",
|
|
149
|
+
children: [
|
|
150
|
+
/* @__PURE__ */ jsx(FileText, { className: "h-4 w-4 text-green-500" }),
|
|
151
|
+
/* @__PURE__ */ jsx("span", { children: "Copy as Text" })
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
content && /* @__PURE__ */ jsxs(
|
|
156
|
+
DropdownMenuItem,
|
|
157
|
+
{
|
|
158
|
+
onClick: copyMarkdownToClipboard,
|
|
159
|
+
className: "flex items-center gap-2 cursor-pointer",
|
|
160
|
+
children: [
|
|
161
|
+
/* @__PURE__ */ jsx(FileDown, { className: "h-4 w-4 text-purple-500" }),
|
|
162
|
+
/* @__PURE__ */ jsx("span", { children: "Copy as Markdown" })
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
tableData.normalizedData && /* @__PURE__ */ jsxs(
|
|
167
|
+
DropdownMenuItem,
|
|
168
|
+
{
|
|
169
|
+
onClick: copyJsonToClipboard,
|
|
170
|
+
className: "flex items-center gap-2 cursor-pointer",
|
|
171
|
+
children: [
|
|
172
|
+
/* @__PURE__ */ jsx(FileJson, { className: "h-4 w-4 text-blue-500" }),
|
|
173
|
+
/* @__PURE__ */ jsx("span", { children: "Copy as JSON" })
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
178
|
+
/* @__PURE__ */ jsxs(
|
|
179
|
+
DropdownMenuItem,
|
|
180
|
+
{
|
|
181
|
+
onClick: downloadCSV,
|
|
182
|
+
className: "flex items-center gap-2 cursor-pointer",
|
|
183
|
+
children: [
|
|
184
|
+
/* @__PURE__ */ jsx(FileSpreadsheet, { className: "h-4 w-4 text-orange-500" }),
|
|
185
|
+
/* @__PURE__ */ jsx("span", { children: "Download as CSV" })
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
content && /* @__PURE__ */ jsxs(
|
|
190
|
+
DropdownMenuItem,
|
|
191
|
+
{
|
|
192
|
+
onClick: downloadMarkdown,
|
|
193
|
+
className: "flex items-center gap-2 cursor-pointer",
|
|
194
|
+
children: [
|
|
195
|
+
/* @__PURE__ */ jsx(FileDown, { className: "h-4 w-4 text-indigo-500" }),
|
|
196
|
+
/* @__PURE__ */ jsx("span", { children: "Download as Markdown" })
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
] })
|
|
201
|
+
] });
|
|
202
|
+
};
|
|
203
|
+
const StreamingTableRenderer = (props) => {
|
|
204
|
+
const parsedTable = useMemo(
|
|
205
|
+
() => parseMarkdownTable(props.content),
|
|
206
|
+
[props.content]
|
|
207
|
+
);
|
|
208
|
+
if (!parsedTable) {
|
|
209
|
+
return props.isStreamActive ? /* @__PURE__ */ jsx(RegionSkeleton, { shape: "rows", count: 3, "aria-label": "Table arriving" }) : null;
|
|
210
|
+
}
|
|
211
|
+
return /* @__PURE__ */ jsx(StreamingTableRendererCore, { ...props, parsedTable });
|
|
212
|
+
};
|
|
213
|
+
const StreamingTableRendererCore = ({
|
|
214
|
+
content,
|
|
215
|
+
metadata,
|
|
216
|
+
isStreamActive = false,
|
|
217
|
+
className,
|
|
218
|
+
fontSize = 13,
|
|
219
|
+
theme = "professional",
|
|
220
|
+
onSave = () => {
|
|
221
|
+
},
|
|
222
|
+
onContentChange,
|
|
223
|
+
saveAsTable,
|
|
224
|
+
expanded = false,
|
|
225
|
+
parsedTable
|
|
226
|
+
}) => {
|
|
227
|
+
const { copyText } = useClipboard({
|
|
228
|
+
notify: (message, kind) => kind === "error" ? copyToast.error(message) : copyToast.success(message)
|
|
229
|
+
});
|
|
230
|
+
const toast = useToastManager();
|
|
231
|
+
const isMobile = useIsMobile();
|
|
232
|
+
const canvasFit = useCanvasFit();
|
|
233
|
+
const { canWrite } = useTableViewer();
|
|
234
|
+
const openTableWindow = useOpenTableViewerWindow();
|
|
235
|
+
const inLiveStream = useMarkdownStreaming();
|
|
236
|
+
const trailingRowStreaming = isStreamActive || inLiveStream;
|
|
237
|
+
const specimenMode = useSpecimenMode();
|
|
238
|
+
const tableTheme = THEMES[theme]?.table || THEMES.professional.table;
|
|
239
|
+
const [editMode, setEditMode] = useState("none");
|
|
240
|
+
const [showNormalized, setShowNormalized] = useState(false);
|
|
241
|
+
const [showChart, setShowChart] = useState(false);
|
|
242
|
+
const actionRowRef = useTableActionTitles();
|
|
243
|
+
const [internalTableData, setInternalTableData] = useState(null);
|
|
244
|
+
const tableData = internalTableData ?? parsedTable;
|
|
245
|
+
const { headers, rows } = tableData;
|
|
246
|
+
const defaultHiddenCols = NO_HIDDEN_COLUMNS;
|
|
247
|
+
const [hiddenColsOverride, setHiddenColsOverride] = useState(null);
|
|
248
|
+
const hiddenCols = hiddenColsOverride ?? defaultHiddenCols;
|
|
249
|
+
const toggleColumn = (index) => {
|
|
250
|
+
setHiddenColsOverride((prev) => {
|
|
251
|
+
const base = prev ?? defaultHiddenCols;
|
|
252
|
+
const next = new Set(base);
|
|
253
|
+
if (next.has(index)) next.delete(index);
|
|
254
|
+
else next.add(index);
|
|
255
|
+
return next;
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
const showAllColumns = () => setHiddenColsOverride(/* @__PURE__ */ new Set());
|
|
259
|
+
const showStreamingIndicator = isStreamActive && metadata?.hasPartialContent;
|
|
260
|
+
const generateMarkdownTable = () => rewriteTableSource(content, { headers, rows });
|
|
261
|
+
const copyTableToClipboard = async () => {
|
|
262
|
+
try {
|
|
263
|
+
const formattedTable = generateMarkdownTable();
|
|
264
|
+
await copyText(formattedTable, "Table copied to clipboard");
|
|
265
|
+
} catch (err) {
|
|
266
|
+
toast.error(err instanceof Error ? err.message : "Failed to copy table");
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
const copyJsonToClipboard = async () => {
|
|
270
|
+
try {
|
|
271
|
+
await copyText(
|
|
272
|
+
JSON.stringify(tableData.normalizedData, null, 2)
|
|
273
|
+
);
|
|
274
|
+
toast.success("JSON copied to clipboard");
|
|
275
|
+
} catch (err) {
|
|
276
|
+
toast.error(err instanceof Error ? err.message : "Failed to copy JSON");
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
const copyMarkdownToClipboard = async () => {
|
|
280
|
+
try {
|
|
281
|
+
if (content) {
|
|
282
|
+
await copyText(content, "Markdown copied to clipboard");
|
|
283
|
+
} else {
|
|
284
|
+
copyTableToClipboard();
|
|
285
|
+
}
|
|
286
|
+
} catch (err) {
|
|
287
|
+
toast.error(
|
|
288
|
+
err instanceof Error ? err.message : "Failed to copy markdown"
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
const downloadCSV = () => {
|
|
293
|
+
try {
|
|
294
|
+
const csvContent = [
|
|
295
|
+
headers.map((h) => h.replace(/"/g, '""')).join(","),
|
|
296
|
+
...rows.map(
|
|
297
|
+
(row) => row.map((cell) => {
|
|
298
|
+
const escaped = cell.replace(/"/g, '""');
|
|
299
|
+
return cell.includes(",") ? `"${escaped}"` : escaped;
|
|
300
|
+
}).join(",")
|
|
301
|
+
)
|
|
302
|
+
].join("\n");
|
|
303
|
+
const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8;" });
|
|
304
|
+
const url = URL.createObjectURL(blob);
|
|
305
|
+
const link = document.createElement("a");
|
|
306
|
+
link.href = url;
|
|
307
|
+
link.download = "table_data.csv";
|
|
308
|
+
link.click();
|
|
309
|
+
URL.revokeObjectURL(url);
|
|
310
|
+
toast.success("Table exported to CSV", {
|
|
311
|
+
action: {
|
|
312
|
+
label: "Download Again",
|
|
313
|
+
onClick: () => link.click(),
|
|
314
|
+
className: "font-medium"
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
} catch (err) {
|
|
318
|
+
toast.error(
|
|
319
|
+
err instanceof Error ? err.message : "Failed to download CSV"
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
const downloadMarkdown = () => {
|
|
324
|
+
try {
|
|
325
|
+
const markdownContent = content || "";
|
|
326
|
+
const fileName = headers && headers[0] ? `${headers[0].replace(/[^a-z0-9]/gi, "_").toLowerCase()}.md` : "table_data.md";
|
|
327
|
+
const blob = new Blob([markdownContent], {
|
|
328
|
+
type: "text/markdown;charset=utf-8"
|
|
329
|
+
});
|
|
330
|
+
const url = URL.createObjectURL(blob);
|
|
331
|
+
const link = document.createElement("a");
|
|
332
|
+
link.href = url;
|
|
333
|
+
link.download = fileName;
|
|
334
|
+
document.body.appendChild(link);
|
|
335
|
+
link.click();
|
|
336
|
+
document.body.removeChild(link);
|
|
337
|
+
URL.revokeObjectURL(url);
|
|
338
|
+
toast.success("Markdown file downloaded", {
|
|
339
|
+
action: {
|
|
340
|
+
label: "Download Again",
|
|
341
|
+
onClick: () => {
|
|
342
|
+
const newLink = document.createElement("a");
|
|
343
|
+
newLink.href = url;
|
|
344
|
+
newLink.download = fileName;
|
|
345
|
+
document.body.appendChild(newLink);
|
|
346
|
+
newLink.click();
|
|
347
|
+
document.body.removeChild(newLink);
|
|
348
|
+
},
|
|
349
|
+
className: "font-medium"
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
} catch (err) {
|
|
353
|
+
toast.error(
|
|
354
|
+
err instanceof Error ? err.message : "Failed to download Markdown"
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
const toggleGlobalEditMode = () => {
|
|
359
|
+
if (editMode !== "none") {
|
|
360
|
+
if (!notifyContentChange()) return;
|
|
361
|
+
onSave(tableData);
|
|
362
|
+
setEditMode("none");
|
|
363
|
+
toast.info("Edit mode deactivated");
|
|
364
|
+
} else {
|
|
365
|
+
setInternalTableData(parsedTable);
|
|
366
|
+
setEditMode("header");
|
|
367
|
+
toast.info("Edit mode activated");
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
const handleHeaderChange = (index, value) => {
|
|
371
|
+
const newHeaders = [...headers];
|
|
372
|
+
newHeaders[index] = value;
|
|
373
|
+
setInternalTableData({ ...tableData, headers: newHeaders });
|
|
374
|
+
};
|
|
375
|
+
const handleCellChange = (rowIndex, colIndex, value) => {
|
|
376
|
+
const newRows = [...rows];
|
|
377
|
+
newRows[rowIndex][colIndex] = value;
|
|
378
|
+
setInternalTableData({ ...tableData, rows: newRows });
|
|
379
|
+
};
|
|
380
|
+
const handleRowClick = (rowIndex) => {
|
|
381
|
+
if (editMode === "none") return;
|
|
382
|
+
onSave(tableData);
|
|
383
|
+
setEditMode(rowIndex);
|
|
384
|
+
};
|
|
385
|
+
const handleHeaderClick = () => {
|
|
386
|
+
if (editMode === "none") return;
|
|
387
|
+
onSave(tableData);
|
|
388
|
+
setEditMode("header");
|
|
389
|
+
};
|
|
390
|
+
const handleSave = () => {
|
|
391
|
+
if (!notifyContentChange()) return;
|
|
392
|
+
onSave(tableData);
|
|
393
|
+
setEditMode("none");
|
|
394
|
+
toast.success("Table data saved");
|
|
395
|
+
};
|
|
396
|
+
const handleCancel = () => {
|
|
397
|
+
setInternalTableData(null);
|
|
398
|
+
setEditMode("none");
|
|
399
|
+
toast.info("Edits cancelled");
|
|
400
|
+
};
|
|
401
|
+
const notifyContentChange = () => {
|
|
402
|
+
if (onContentChange && content) {
|
|
403
|
+
try {
|
|
404
|
+
onContentChange(generateMarkdownTable());
|
|
405
|
+
} catch (error) {
|
|
406
|
+
toast.error(error instanceof Error ? error.message : String(error));
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return true;
|
|
411
|
+
};
|
|
412
|
+
const undo = useTableUndo();
|
|
413
|
+
const applyMutation = (mutator) => {
|
|
414
|
+
setInternalTableData(mutator(tableData));
|
|
415
|
+
};
|
|
416
|
+
const undoLast = () => {
|
|
417
|
+
const prev = undo.consume();
|
|
418
|
+
if (prev) {
|
|
419
|
+
setInternalTableData(prev);
|
|
420
|
+
toast.info("Undone");
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
const undoToastAction = {
|
|
424
|
+
label: "Undo",
|
|
425
|
+
onClick: undoLast,
|
|
426
|
+
className: "font-medium"
|
|
427
|
+
};
|
|
428
|
+
const handleAppendRow = () => {
|
|
429
|
+
applyMutation(appendRow);
|
|
430
|
+
toast.success("Row added");
|
|
431
|
+
};
|
|
432
|
+
const handleInsertRowAbove = (rowIndex) => {
|
|
433
|
+
applyMutation((t) => insertRowAbove(t, rowIndex));
|
|
434
|
+
toast.success("Row inserted above");
|
|
435
|
+
};
|
|
436
|
+
const handleInsertRowBelow = (rowIndex) => {
|
|
437
|
+
applyMutation((t) => insertRowBelow(t, rowIndex));
|
|
438
|
+
toast.success("Row inserted below");
|
|
439
|
+
};
|
|
440
|
+
const handleDuplicateRow = (rowIndex) => {
|
|
441
|
+
applyMutation((t) => duplicateRow(t, rowIndex));
|
|
442
|
+
toast.success("Row duplicated");
|
|
443
|
+
};
|
|
444
|
+
const handleClearRow = (rowIndex) => {
|
|
445
|
+
undo.snapshot(tableData);
|
|
446
|
+
applyMutation((t) => clearRow(t, rowIndex));
|
|
447
|
+
toast.success("Row cleared", { action: undoToastAction });
|
|
448
|
+
};
|
|
449
|
+
const handleDeleteRow = (rowIndex) => {
|
|
450
|
+
undo.snapshot(tableData);
|
|
451
|
+
applyMutation((t) => removeRow(t, rowIndex));
|
|
452
|
+
if (editMode === rowIndex) {
|
|
453
|
+
setEditMode("header");
|
|
454
|
+
}
|
|
455
|
+
toast.success("Row deleted", { action: undoToastAction });
|
|
456
|
+
};
|
|
457
|
+
const handleClearAllContents = () => {
|
|
458
|
+
if (rows.length === 0 || headers.length <= 1) return;
|
|
459
|
+
undo.snapshot(tableData);
|
|
460
|
+
applyMutation(clearAllContents);
|
|
461
|
+
toast.success("Cleared all contents (kept first column)", {
|
|
462
|
+
action: undoToastAction
|
|
463
|
+
});
|
|
464
|
+
};
|
|
465
|
+
const handleAppendColumn = () => {
|
|
466
|
+
applyMutation((t) => appendColumn(t));
|
|
467
|
+
toast.success("Column added");
|
|
468
|
+
};
|
|
469
|
+
const handleInsertColumnBefore = (colIndex) => {
|
|
470
|
+
applyMutation((t) => insertColumnBefore(t, colIndex));
|
|
471
|
+
toast.success("Column inserted before");
|
|
472
|
+
};
|
|
473
|
+
const handleInsertColumnAfter = (colIndex) => {
|
|
474
|
+
applyMutation((t) => insertColumnAfter(t, colIndex));
|
|
475
|
+
toast.success("Column inserted after");
|
|
476
|
+
};
|
|
477
|
+
const handleDuplicateColumn = (colIndex) => {
|
|
478
|
+
applyMutation((t) => duplicateColumn(t, colIndex));
|
|
479
|
+
toast.success("Column duplicated");
|
|
480
|
+
};
|
|
481
|
+
const handleClearColumn = (colIndex) => {
|
|
482
|
+
undo.snapshot(tableData);
|
|
483
|
+
applyMutation((t) => clearColumn(t, colIndex));
|
|
484
|
+
toast.success("Column cleared", { action: undoToastAction });
|
|
485
|
+
};
|
|
486
|
+
const handleDeleteColumn = (colIndex) => {
|
|
487
|
+
undo.snapshot(tableData);
|
|
488
|
+
applyMutation((t) => removeColumn(t, colIndex));
|
|
489
|
+
toast.success("Column deleted", { action: undoToastAction });
|
|
490
|
+
};
|
|
491
|
+
const isEditingEnabled = editMode !== "none";
|
|
492
|
+
const phoneStack = !isEditingEnabled;
|
|
493
|
+
const pinFirstColumn = canvasFit === "tight" && !isMobile && !isEditingEnabled;
|
|
494
|
+
const isEditingHeader = editMode === "header";
|
|
495
|
+
const editingBorderStyle = "overflow-x-auto rounded-xl border-3 border-dashed border-red-500";
|
|
496
|
+
const normalBorderStyle = `overflow-x-auto rounded-xl border-3 ${tableTheme.border}`;
|
|
497
|
+
const tableIsComplete = !isStreamActive || metadata?.isComplete === true;
|
|
498
|
+
const canEnterEditMode = tableIsComplete && !specimenMode;
|
|
499
|
+
const { handleTableDoubleClick, bindCellTextareaRef } = useDoubleClickEdit({
|
|
500
|
+
canEnterEditMode,
|
|
501
|
+
editMode,
|
|
502
|
+
setEditMode
|
|
503
|
+
});
|
|
504
|
+
const cellPaddingClass = expanded ? "px-3 py-2" : "px-2.5 py-1.5";
|
|
505
|
+
const isColumnHidden = (index) => !isEditingEnabled && hiddenCols.has(index);
|
|
506
|
+
const hasHiddenColumns = !isEditingEnabled && hiddenCols.size > 0;
|
|
507
|
+
const hiddenHeaderLabel = (index) => cleanTableHeaderKey(headers[index] ?? "") || `Column ${index + 1}`;
|
|
508
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("relative w-full my-3", className), children: [
|
|
509
|
+
showNormalized && tableData.normalizedData ? /* @__PURE__ */ jsxs("div", { className: "relative p-4 bg-gray-100 dark:bg-gray-800 rounded-lg", children: [
|
|
510
|
+
/* @__PURE__ */ jsx("pre", { className: "text-sm overflow-auto", children: JSON.stringify(tableData.normalizedData, null, 2) }),
|
|
511
|
+
/* @__PURE__ */ jsxs(
|
|
512
|
+
Button,
|
|
513
|
+
{
|
|
514
|
+
variant: "outline",
|
|
515
|
+
size: "sm",
|
|
516
|
+
onClick: () => setShowNormalized(false),
|
|
517
|
+
className: "absolute top-2 right-2 opacity-90 hover:opacity-100 flex items-center gap-1 shadow-md",
|
|
518
|
+
children: [
|
|
519
|
+
/* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" }),
|
|
520
|
+
"View Table"
|
|
521
|
+
]
|
|
522
|
+
}
|
|
523
|
+
)
|
|
524
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
525
|
+
/* @__PURE__ */ jsxs(
|
|
526
|
+
MarkdownTableScrollArea,
|
|
527
|
+
{
|
|
528
|
+
className: cn(
|
|
529
|
+
"border border-border rounded-lg shadow-sm",
|
|
530
|
+
isEditingEnabled && "border-dashed border-red-500 border-2",
|
|
531
|
+
isMobile && "-mx-1",
|
|
532
|
+
phoneStack && "phone-stack"
|
|
533
|
+
),
|
|
534
|
+
children: [
|
|
535
|
+
/* @__PURE__ */ jsxs(
|
|
536
|
+
"table",
|
|
537
|
+
{
|
|
538
|
+
className: cn(
|
|
539
|
+
"divide-y divide-border",
|
|
540
|
+
isMobile && !phoneStack ? "min-w-max w-full" : phoneStack ? "w-full" : "min-w-full"
|
|
541
|
+
),
|
|
542
|
+
style: { fontSize: `${fontSize}px` },
|
|
543
|
+
"data-canvas-fit": canvasFit === "outside" ? void 0 : canvasFit,
|
|
544
|
+
onDoubleClick: canWrite ? handleTableDoubleClick : void 0,
|
|
545
|
+
children: [
|
|
546
|
+
/* @__PURE__ */ jsx("thead", { className: tableTheme.header, onClick: handleHeaderClick, children: /* @__PURE__ */ jsxs("tr", { className: cn(pinFirstColumn && "[background-color:inherit]"), children: [
|
|
547
|
+
isEditingEnabled && /* @__PURE__ */ jsx("th", { className: "w-5 p-0", "aria-hidden": "true" }),
|
|
548
|
+
headers.map(
|
|
549
|
+
(header, index) => isColumnHidden(index) ? null : /* @__PURE__ */ jsx(
|
|
550
|
+
"th",
|
|
551
|
+
{
|
|
552
|
+
"data-cell": "header",
|
|
553
|
+
"data-cell-col": index,
|
|
554
|
+
className: cn(
|
|
555
|
+
cellPaddingClass,
|
|
556
|
+
"text-left font-semibold",
|
|
557
|
+
tableTheme.headerText,
|
|
558
|
+
isMobile && "whitespace-nowrap",
|
|
559
|
+
isEditingEnabled && "group/col",
|
|
560
|
+
pinFirstColumn && index === 0 && "sticky left-0 z-[1] [background-color:inherit] border-r border-border"
|
|
561
|
+
),
|
|
562
|
+
children: /* @__PURE__ */ jsxs(
|
|
563
|
+
"div",
|
|
564
|
+
{
|
|
565
|
+
className: cn(
|
|
566
|
+
"flex items-center gap-2",
|
|
567
|
+
isEditingEnabled && "justify-between"
|
|
568
|
+
),
|
|
569
|
+
children: [
|
|
570
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 min-w-0", children: isEditingHeader ? /* @__PURE__ */ jsx(
|
|
571
|
+
"input",
|
|
572
|
+
{
|
|
573
|
+
type: "text",
|
|
574
|
+
value: header,
|
|
575
|
+
onChange: (e) => handleHeaderChange(index, e.target.value),
|
|
576
|
+
className: cn(
|
|
577
|
+
"w-full bg-transparent outline-none border border-dashed border-blue-300 p-1",
|
|
578
|
+
tableTheme.headerText
|
|
579
|
+
),
|
|
580
|
+
onClick: (e) => e.stopPropagation()
|
|
581
|
+
}
|
|
582
|
+
) : (
|
|
583
|
+
// Every cell renders through the ONE core's inline
|
|
584
|
+
// level (math, links, code — healed while the row
|
|
585
|
+
// is still arriving).
|
|
586
|
+
/* @__PURE__ */ jsx(
|
|
587
|
+
RichContent,
|
|
588
|
+
{
|
|
589
|
+
level: "inline",
|
|
590
|
+
source: header,
|
|
591
|
+
gfmCell: true,
|
|
592
|
+
isStreaming: trailingRowStreaming && rows.length === 0
|
|
593
|
+
}
|
|
594
|
+
)
|
|
595
|
+
) }),
|
|
596
|
+
isEditingEnabled && /* @__PURE__ */ jsx(
|
|
597
|
+
ColumnActionsMenu,
|
|
598
|
+
{
|
|
599
|
+
onInsertBefore: () => handleInsertColumnBefore(index),
|
|
600
|
+
onInsertAfter: () => handleInsertColumnAfter(index),
|
|
601
|
+
onDuplicate: () => handleDuplicateColumn(index),
|
|
602
|
+
onClear: () => handleClearColumn(index),
|
|
603
|
+
onDelete: () => handleDeleteColumn(index)
|
|
604
|
+
}
|
|
605
|
+
)
|
|
606
|
+
]
|
|
607
|
+
}
|
|
608
|
+
)
|
|
609
|
+
},
|
|
610
|
+
index
|
|
611
|
+
)
|
|
612
|
+
),
|
|
613
|
+
hasHiddenColumns && /* @__PURE__ */ jsx(
|
|
614
|
+
"th",
|
|
615
|
+
{
|
|
616
|
+
className: "w-6 px-1 py-1.5 text-center align-middle cursor-pointer text-muted-foreground hover:text-foreground",
|
|
617
|
+
title: `${hiddenCols.size} hidden column${hiddenCols.size === 1 ? "" : "s"} \u2014 click to show all`,
|
|
618
|
+
onClick: (e) => {
|
|
619
|
+
e.stopPropagation();
|
|
620
|
+
showAllColumns();
|
|
621
|
+
},
|
|
622
|
+
children: /* @__PURE__ */ jsx(EyeOff, { className: "h-3.5 w-3.5 mx-auto" })
|
|
623
|
+
}
|
|
624
|
+
)
|
|
625
|
+
] }) }),
|
|
626
|
+
/* @__PURE__ */ jsx("tbody", { className: "bg-background divide-y divide-border", children: rows.map((row, rowIndex) => /* @__PURE__ */ jsxs(
|
|
627
|
+
"tr",
|
|
628
|
+
{
|
|
629
|
+
className: cn(
|
|
630
|
+
"transition-colors",
|
|
631
|
+
typeof tableTheme.row === "object" ? tableTheme.row.hover : "hover:bg-muted/30",
|
|
632
|
+
editMode === rowIndex && "bg-blue-50 dark:bg-blue-900/20",
|
|
633
|
+
isEditingEnabled && "group/row"
|
|
634
|
+
),
|
|
635
|
+
onClick: () => handleRowClick(rowIndex),
|
|
636
|
+
children: [
|
|
637
|
+
isEditingEnabled && /* @__PURE__ */ jsx("td", { className: "w-5 p-0 text-center align-middle", children: /* @__PURE__ */ jsx(
|
|
638
|
+
RowActionsMenu,
|
|
639
|
+
{
|
|
640
|
+
onInsertAbove: () => handleInsertRowAbove(rowIndex),
|
|
641
|
+
onInsertBelow: () => handleInsertRowBelow(rowIndex),
|
|
642
|
+
onDuplicate: () => handleDuplicateRow(rowIndex),
|
|
643
|
+
onClear: () => handleClearRow(rowIndex),
|
|
644
|
+
onDelete: () => handleDeleteRow(rowIndex)
|
|
645
|
+
}
|
|
646
|
+
) }),
|
|
647
|
+
headers.map(
|
|
648
|
+
(_, colIndex) => isColumnHidden(colIndex) ? null : /* @__PURE__ */ jsx(
|
|
649
|
+
"td",
|
|
650
|
+
{
|
|
651
|
+
"data-cell": "body",
|
|
652
|
+
"data-cell-row": rowIndex,
|
|
653
|
+
"data-cell-col": colIndex,
|
|
654
|
+
...phoneStack ? phoneStackCellProps(headers, colIndex) : {},
|
|
655
|
+
className: cn(
|
|
656
|
+
cellPaddingClass,
|
|
657
|
+
"text-foreground",
|
|
658
|
+
isMobile && !phoneStack ? "whitespace-nowrap max-w-[200px] overflow-hidden text-ellipsis" : "whitespace-normal",
|
|
659
|
+
pinFirstColumn && colIndex === 0 && "sticky left-0 z-[1] bg-background border-r border-border min-w-[7rem] max-w-[12rem]"
|
|
660
|
+
),
|
|
661
|
+
children: editMode === rowIndex ? /* @__PURE__ */ jsx(
|
|
662
|
+
"textarea",
|
|
663
|
+
{
|
|
664
|
+
ref: bindCellTextareaRef(rowIndex, colIndex),
|
|
665
|
+
value: row[colIndex] || "",
|
|
666
|
+
onChange: (e) => handleCellChange(
|
|
667
|
+
rowIndex,
|
|
668
|
+
colIndex,
|
|
669
|
+
e.target.value
|
|
670
|
+
),
|
|
671
|
+
className: cn(
|
|
672
|
+
"w-full bg-transparent outline-none border border-dashed border-blue-300 p-1",
|
|
673
|
+
"resize-y min-h-[8rem]"
|
|
674
|
+
),
|
|
675
|
+
onClick: (e) => e.stopPropagation(),
|
|
676
|
+
onFocus: (e) => e.target.select()
|
|
677
|
+
}
|
|
678
|
+
) : row[colIndex] ? /* @__PURE__ */ jsx(
|
|
679
|
+
RichContent,
|
|
680
|
+
{
|
|
681
|
+
level: "inline",
|
|
682
|
+
source: row[colIndex],
|
|
683
|
+
gfmCell: true,
|
|
684
|
+
isStreaming: trailingRowStreaming && rowIndex === rows.length - 1
|
|
685
|
+
}
|
|
686
|
+
) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", "data-empty-cell": "", "aria-label": "Empty cell", children: "\u2014" })
|
|
687
|
+
},
|
|
688
|
+
colIndex
|
|
689
|
+
)
|
|
690
|
+
),
|
|
691
|
+
hasHiddenColumns && /* @__PURE__ */ jsx("td", { className: "w-6 px-1 py-0 align-middle", "aria-hidden": true })
|
|
692
|
+
]
|
|
693
|
+
},
|
|
694
|
+
rowIndex
|
|
695
|
+
)) })
|
|
696
|
+
]
|
|
697
|
+
}
|
|
698
|
+
),
|
|
699
|
+
showStreamingIndicator && /* @__PURE__ */ jsx("div", { className: "px-4 py-2 bg-muted/30 border-t border-border", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
700
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
|
|
701
|
+
/* @__PURE__ */ jsx("span", { className: "w-1.5 h-1.5 bg-primary rounded-full animate-pulse" }),
|
|
702
|
+
/* @__PURE__ */ jsx("span", { className: "w-1.5 h-1.5 bg-primary rounded-full animate-pulse [animation-delay:200ms]" }),
|
|
703
|
+
/* @__PURE__ */ jsx("span", { className: "w-1.5 h-1.5 bg-primary rounded-full animate-pulse [animation-delay:400ms]" })
|
|
704
|
+
] }),
|
|
705
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
706
|
+
"Streaming data... (",
|
|
707
|
+
metadata?.completeRowCount,
|
|
708
|
+
" row",
|
|
709
|
+
metadata?.completeRowCount !== 1 ? "s" : "",
|
|
710
|
+
" complete",
|
|
711
|
+
metadata?.hasPartialContent ? ", 1 buffering" : "",
|
|
712
|
+
")"
|
|
713
|
+
] })
|
|
714
|
+
] }) })
|
|
715
|
+
]
|
|
716
|
+
}
|
|
717
|
+
),
|
|
718
|
+
tableIsComplete && !specimenMode && /* @__PURE__ */ jsxs(
|
|
719
|
+
"div",
|
|
720
|
+
{
|
|
721
|
+
ref: actionRowRef,
|
|
722
|
+
role: "toolbar",
|
|
723
|
+
"aria-label": "Table actions",
|
|
724
|
+
className: tableActionRowClass(isMobile),
|
|
725
|
+
children: [
|
|
726
|
+
isEditingEnabled && /* @__PURE__ */ jsx(
|
|
727
|
+
TableEditToolbar,
|
|
728
|
+
{
|
|
729
|
+
onAddRow: handleAppendRow,
|
|
730
|
+
onAddColumn: handleAppendColumn,
|
|
731
|
+
onClearAllContents: handleClearAllContents,
|
|
732
|
+
rowCount: rows.length,
|
|
733
|
+
colCount: headers.length,
|
|
734
|
+
className: "contents"
|
|
735
|
+
}
|
|
736
|
+
),
|
|
737
|
+
!isEditingEnabled && headers.length > 1 && /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
738
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
739
|
+
Button,
|
|
740
|
+
{
|
|
741
|
+
variant: "outline",
|
|
742
|
+
size: "sm",
|
|
743
|
+
"aria-label": "Choose visible columns",
|
|
744
|
+
title: "Choose visible columns",
|
|
745
|
+
className: "flex items-center gap-2 hover:bg-blue-100 dark:hover:bg-blue-800/30",
|
|
746
|
+
children: [
|
|
747
|
+
/* @__PURE__ */ jsx(Columns3, { className: "h-4 w-4" }),
|
|
748
|
+
hiddenCols.size > 0 && /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
|
|
749
|
+
"(",
|
|
750
|
+
headers.length - hiddenCols.size,
|
|
751
|
+
"/",
|
|
752
|
+
headers.length,
|
|
753
|
+
")"
|
|
754
|
+
] }),
|
|
755
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 ml-1" })
|
|
756
|
+
]
|
|
757
|
+
}
|
|
758
|
+
) }),
|
|
759
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-56", children: [
|
|
760
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Visible columns" }),
|
|
761
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
762
|
+
headers.map((_, index) => /* @__PURE__ */ jsx(
|
|
763
|
+
DropdownMenuCheckboxItem,
|
|
764
|
+
{
|
|
765
|
+
checked: !hiddenCols.has(index),
|
|
766
|
+
onCheckedChange: () => toggleColumn(index),
|
|
767
|
+
onSelect: (e) => e.preventDefault(),
|
|
768
|
+
children: /* @__PURE__ */ jsx("span", { className: "truncate", children: hiddenHeaderLabel(index) })
|
|
769
|
+
},
|
|
770
|
+
index
|
|
771
|
+
)),
|
|
772
|
+
hiddenCols.size > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
773
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
774
|
+
/* @__PURE__ */ jsxs(
|
|
775
|
+
DropdownMenuItem,
|
|
776
|
+
{
|
|
777
|
+
onClick: showAllColumns,
|
|
778
|
+
className: "cursor-pointer",
|
|
779
|
+
children: [
|
|
780
|
+
/* @__PURE__ */ jsx(Eye, { className: "h-4 w-4 mr-2" }),
|
|
781
|
+
"Show all"
|
|
782
|
+
]
|
|
783
|
+
}
|
|
784
|
+
)
|
|
785
|
+
] })
|
|
786
|
+
] })
|
|
787
|
+
] }),
|
|
788
|
+
!expanded && !isEditingEnabled && /* @__PURE__ */ jsxs(
|
|
789
|
+
Button,
|
|
790
|
+
{
|
|
791
|
+
variant: "outline",
|
|
792
|
+
size: "sm",
|
|
793
|
+
onClick: () => openTableWindow({
|
|
794
|
+
content,
|
|
795
|
+
title: cleanTableHeaderKey(headers[0] ?? "") || "Table"
|
|
796
|
+
}),
|
|
797
|
+
className: "flex items-center gap-2 hover:bg-blue-100 dark:hover:bg-blue-800/30",
|
|
798
|
+
children: [
|
|
799
|
+
/* @__PURE__ */ jsx(Maximize2, { className: "h-4 w-4" }),
|
|
800
|
+
"Window"
|
|
801
|
+
]
|
|
802
|
+
}
|
|
803
|
+
),
|
|
804
|
+
!isEditingEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
805
|
+
tableData.normalizedData && /* @__PURE__ */ jsxs(
|
|
806
|
+
Button,
|
|
807
|
+
{
|
|
808
|
+
variant: "outline",
|
|
809
|
+
size: "sm",
|
|
810
|
+
onClick: () => setShowNormalized(!showNormalized),
|
|
811
|
+
className: "flex items-center gap-2 hover:bg-blue-100 dark:hover:bg-blue-800/30",
|
|
812
|
+
children: [
|
|
813
|
+
/* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" }),
|
|
814
|
+
showNormalized ? "Table" : "Data"
|
|
815
|
+
]
|
|
816
|
+
}
|
|
817
|
+
),
|
|
818
|
+
/* @__PURE__ */ jsx(
|
|
819
|
+
ChartThisButton,
|
|
820
|
+
{
|
|
821
|
+
table: { headers, rows },
|
|
822
|
+
active: showChart,
|
|
823
|
+
onToggle: () => setShowChart((v) => !v)
|
|
824
|
+
}
|
|
825
|
+
),
|
|
826
|
+
canWrite && tableData.normalizedData && /* @__PURE__ */ jsx(
|
|
827
|
+
TableSaveToMenu,
|
|
828
|
+
{
|
|
829
|
+
headers,
|
|
830
|
+
rows,
|
|
831
|
+
title: saveAsTable?.title ?? null,
|
|
832
|
+
...saveAsTable?.resolveTitle ? { resolveTitle: saveAsTable.resolveTitle } : {},
|
|
833
|
+
...saveAsTable?.onSaved ? { onSaved: saveAsTable.onSaved } : {}
|
|
834
|
+
}
|
|
835
|
+
),
|
|
836
|
+
/* @__PURE__ */ jsx(
|
|
837
|
+
ExportDropdownMenu,
|
|
838
|
+
{
|
|
839
|
+
tableData,
|
|
840
|
+
content,
|
|
841
|
+
copyTableToClipboard,
|
|
842
|
+
copyMarkdownToClipboard,
|
|
843
|
+
copyJsonToClipboard,
|
|
844
|
+
downloadCSV,
|
|
845
|
+
downloadMarkdown,
|
|
846
|
+
isStreamActive
|
|
847
|
+
}
|
|
848
|
+
)
|
|
849
|
+
] }),
|
|
850
|
+
isEditingEnabled ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
851
|
+
/* @__PURE__ */ jsxs(
|
|
852
|
+
Button,
|
|
853
|
+
{
|
|
854
|
+
variant: "outline",
|
|
855
|
+
size: "sm",
|
|
856
|
+
onClick: handleSave,
|
|
857
|
+
"data-keep-label": "",
|
|
858
|
+
className: "flex items-center gap-2 border-1 border-dashed border-green-500 rounded-xl",
|
|
859
|
+
children: [
|
|
860
|
+
/* @__PURE__ */ jsx(Save, { className: "h-4 w-4" }),
|
|
861
|
+
"Save"
|
|
862
|
+
]
|
|
863
|
+
}
|
|
864
|
+
),
|
|
865
|
+
/* @__PURE__ */ jsxs(
|
|
866
|
+
Button,
|
|
867
|
+
{
|
|
868
|
+
variant: "outline",
|
|
869
|
+
size: "sm",
|
|
870
|
+
onClick: handleCancel,
|
|
871
|
+
"data-keep-label": "",
|
|
872
|
+
className: "flex items-center gap-2 border-1 border-dashed border-red-500 rounded-xl",
|
|
873
|
+
children: [
|
|
874
|
+
/* @__PURE__ */ jsx(X, { className: "h-4 w-4" }),
|
|
875
|
+
"Cancel"
|
|
876
|
+
]
|
|
877
|
+
}
|
|
878
|
+
)
|
|
879
|
+
] }) : canWrite ? /* @__PURE__ */ jsxs(
|
|
880
|
+
Button,
|
|
881
|
+
{
|
|
882
|
+
variant: "outline",
|
|
883
|
+
size: "sm",
|
|
884
|
+
onClick: toggleGlobalEditMode,
|
|
885
|
+
className: "flex items-center gap-2 hover:bg-blue-100 dark:hover:bg-blue-800/30",
|
|
886
|
+
children: [
|
|
887
|
+
/* @__PURE__ */ jsx(Edit, { className: "h-4 w-4" }),
|
|
888
|
+
"Edit"
|
|
889
|
+
]
|
|
890
|
+
}
|
|
891
|
+
) : null
|
|
892
|
+
]
|
|
893
|
+
}
|
|
894
|
+
)
|
|
895
|
+
] }),
|
|
896
|
+
showChart && !isStreamActive && /* @__PURE__ */ jsx(
|
|
897
|
+
TableChartPanel,
|
|
898
|
+
{
|
|
899
|
+
table: { headers, rows },
|
|
900
|
+
onClose: () => setShowChart(false)
|
|
901
|
+
}
|
|
902
|
+
)
|
|
903
|
+
] });
|
|
904
|
+
};
|
|
905
|
+
export {
|
|
906
|
+
StreamingTableRenderer
|
|
907
|
+
};
|