@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,574 @@
|
|
|
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 { useState, useEffect, useCallback } from "react";
|
|
7
|
+
import { cn } from "@ai-matrx/design-system";
|
|
8
|
+
import { RichContent } from "../../levels/RichContent.js";
|
|
9
|
+
import { Button } from "@ai-matrx/design-system/controls";
|
|
10
|
+
import {
|
|
11
|
+
Download,
|
|
12
|
+
Eye,
|
|
13
|
+
Edit,
|
|
14
|
+
Save,
|
|
15
|
+
X,
|
|
16
|
+
FileJson,
|
|
17
|
+
FileText,
|
|
18
|
+
FileSpreadsheet,
|
|
19
|
+
FileDown,
|
|
20
|
+
ChevronDown,
|
|
21
|
+
Database
|
|
22
|
+
} from "lucide-react";
|
|
23
|
+
import {
|
|
24
|
+
DropdownMenu,
|
|
25
|
+
DropdownMenuContent,
|
|
26
|
+
DropdownMenuItem,
|
|
27
|
+
DropdownMenuTrigger,
|
|
28
|
+
DropdownMenuSeparator
|
|
29
|
+
} from "@ai-matrx/design-system";
|
|
30
|
+
import { useToastManager } from "../../utils/lifted/useToastManager.js";
|
|
31
|
+
import { THEMES } from "../themes.js";
|
|
32
|
+
import { useOpenSaveToTable } from "../../host/tables.js";
|
|
33
|
+
function useDebounce(value, delay) {
|
|
34
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const handler = setTimeout(() => {
|
|
37
|
+
setDebouncedValue(value);
|
|
38
|
+
}, delay);
|
|
39
|
+
return () => {
|
|
40
|
+
clearTimeout(handler);
|
|
41
|
+
};
|
|
42
|
+
}, [value, delay]);
|
|
43
|
+
return debouncedValue;
|
|
44
|
+
}
|
|
45
|
+
const TableControls = ({
|
|
46
|
+
tableData,
|
|
47
|
+
content,
|
|
48
|
+
showNormalized,
|
|
49
|
+
setShowNormalized,
|
|
50
|
+
editMode,
|
|
51
|
+
onSaveAsTable,
|
|
52
|
+
onSave,
|
|
53
|
+
onContentChange,
|
|
54
|
+
toggleGlobalEditMode,
|
|
55
|
+
handleSave,
|
|
56
|
+
handleCancel
|
|
57
|
+
}) => {
|
|
58
|
+
const { copyText } = useClipboard({
|
|
59
|
+
notify: (message, kind) => kind === "error" ? copyToast.error(message) : copyToast.success(message)
|
|
60
|
+
});
|
|
61
|
+
const toast = useToastManager();
|
|
62
|
+
const debouncedTableData = useDebounce(tableData, 500);
|
|
63
|
+
const isUpdating = tableData !== debouncedTableData;
|
|
64
|
+
const generateMarkdownTable = useCallback(
|
|
65
|
+
() => rewriteTableSource(content, { headers: tableData.headers, rows: tableData.rows }),
|
|
66
|
+
[content, tableData.headers, tableData.rows]
|
|
67
|
+
);
|
|
68
|
+
const notifyContentChange = useCallback(() => {
|
|
69
|
+
if (onContentChange && content) {
|
|
70
|
+
try {
|
|
71
|
+
onContentChange(generateMarkdownTable());
|
|
72
|
+
} catch (error) {
|
|
73
|
+
toast.error(error instanceof Error ? error.message : String(error));
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
}, [onContentChange, content, generateMarkdownTable, toast]);
|
|
79
|
+
const copyTableToClipboard = useCallback(async () => {
|
|
80
|
+
try {
|
|
81
|
+
const formattedTable = generateMarkdownTable();
|
|
82
|
+
await copyText(formattedTable, "Table copied to clipboard");
|
|
83
|
+
} catch (err) {
|
|
84
|
+
toast.error(err instanceof Error ? err.message : "Failed to copy table");
|
|
85
|
+
}
|
|
86
|
+
}, [generateMarkdownTable, toast]);
|
|
87
|
+
const copyJsonToClipboard = useCallback(async () => {
|
|
88
|
+
try {
|
|
89
|
+
await copyText(
|
|
90
|
+
JSON.stringify(debouncedTableData.normalizedData, null, 2)
|
|
91
|
+
);
|
|
92
|
+
toast.success("JSON copied to clipboard");
|
|
93
|
+
} catch (err) {
|
|
94
|
+
toast.error(err instanceof Error ? err.message : "Failed to copy JSON");
|
|
95
|
+
}
|
|
96
|
+
}, [debouncedTableData.normalizedData, toast]);
|
|
97
|
+
const copyMarkdownToClipboard = useCallback(async () => {
|
|
98
|
+
try {
|
|
99
|
+
if (content) {
|
|
100
|
+
await copyText(content, "Markdown copied to clipboard");
|
|
101
|
+
} else {
|
|
102
|
+
copyTableToClipboard();
|
|
103
|
+
}
|
|
104
|
+
} catch (err) {
|
|
105
|
+
toast.error(err instanceof Error ? err.message : "Failed to copy markdown");
|
|
106
|
+
}
|
|
107
|
+
}, [content, copyTableToClipboard, toast]);
|
|
108
|
+
const downloadCSV = useCallback(() => {
|
|
109
|
+
try {
|
|
110
|
+
const csvContent = [
|
|
111
|
+
tableData.headers.map((h) => h.replace(/"/g, '""')).join(","),
|
|
112
|
+
...tableData.rows.map(
|
|
113
|
+
(row) => row.map((cell) => {
|
|
114
|
+
const escaped = cell.replace(/"/g, '""');
|
|
115
|
+
return cell.includes(",") ? `"${escaped}"` : escaped;
|
|
116
|
+
}).join(",")
|
|
117
|
+
)
|
|
118
|
+
].join("\n");
|
|
119
|
+
const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8;" });
|
|
120
|
+
const url = URL.createObjectURL(blob);
|
|
121
|
+
const link = document.createElement("a");
|
|
122
|
+
link.href = url;
|
|
123
|
+
link.download = "table_data.csv";
|
|
124
|
+
link.click();
|
|
125
|
+
URL.revokeObjectURL(url);
|
|
126
|
+
toast.success("Table exported to CSV", {
|
|
127
|
+
action: {
|
|
128
|
+
label: "Download Again",
|
|
129
|
+
onClick: () => link.click(),
|
|
130
|
+
className: "font-medium"
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
} catch (err) {
|
|
134
|
+
toast.error(err instanceof Error ? err.message : "Failed to download CSV");
|
|
135
|
+
}
|
|
136
|
+
}, [tableData.headers, tableData.rows, toast]);
|
|
137
|
+
const downloadMarkdown = useCallback(() => {
|
|
138
|
+
try {
|
|
139
|
+
const markdownContent = content || "";
|
|
140
|
+
const fileName = tableData.headers && tableData.headers[0] ? `${tableData.headers[0].replace(/[^a-z0-9]/gi, "_").toLowerCase()}.md` : "table_data.md";
|
|
141
|
+
const blob = new Blob([markdownContent], {
|
|
142
|
+
type: "text/markdown;charset=utf-8"
|
|
143
|
+
});
|
|
144
|
+
const url = URL.createObjectURL(blob);
|
|
145
|
+
const link = document.createElement("a");
|
|
146
|
+
link.href = url;
|
|
147
|
+
link.download = fileName;
|
|
148
|
+
document.body.appendChild(link);
|
|
149
|
+
link.click();
|
|
150
|
+
document.body.removeChild(link);
|
|
151
|
+
URL.revokeObjectURL(url);
|
|
152
|
+
toast.success("Markdown file downloaded", {
|
|
153
|
+
action: {
|
|
154
|
+
label: "Download Again",
|
|
155
|
+
onClick: () => {
|
|
156
|
+
const newLink = document.createElement("a");
|
|
157
|
+
newLink.href = url;
|
|
158
|
+
newLink.download = fileName;
|
|
159
|
+
document.body.appendChild(newLink);
|
|
160
|
+
newLink.click();
|
|
161
|
+
document.body.removeChild(newLink);
|
|
162
|
+
},
|
|
163
|
+
className: "font-medium"
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
} catch (err) {
|
|
167
|
+
toast.error(err instanceof Error ? err.message : "Failed to download Markdown");
|
|
168
|
+
}
|
|
169
|
+
}, [content, tableData.headers, toast]);
|
|
170
|
+
const renderTableActionButton = useCallback(() => {
|
|
171
|
+
if (!debouncedTableData.normalizedData || !onSaveAsTable) return null;
|
|
172
|
+
return /* @__PURE__ */ jsx(
|
|
173
|
+
Button,
|
|
174
|
+
{
|
|
175
|
+
icon: /* @__PURE__ */ jsx(Database, {}),
|
|
176
|
+
variant: "outline",
|
|
177
|
+
onClick: onSaveAsTable,
|
|
178
|
+
className: "flex",
|
|
179
|
+
disabled: isUpdating,
|
|
180
|
+
children: "Save to a table"
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
}, [debouncedTableData.normalizedData, onSaveAsTable, isUpdating]);
|
|
184
|
+
if (isUpdating) {
|
|
185
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2 mt-2 opacity-50", children: [
|
|
186
|
+
debouncedTableData.normalizedData && /* @__PURE__ */ jsx(
|
|
187
|
+
Button,
|
|
188
|
+
{
|
|
189
|
+
icon: /* @__PURE__ */ jsx(Eye, {}),
|
|
190
|
+
type: "submit",
|
|
191
|
+
variant: "outline",
|
|
192
|
+
className: "flex",
|
|
193
|
+
disabled: true,
|
|
194
|
+
children: showNormalized ? "Table" : "Data"
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
debouncedTableData.normalizedData && onSaveAsTable && /* @__PURE__ */ jsx(
|
|
198
|
+
Button,
|
|
199
|
+
{
|
|
200
|
+
icon: /* @__PURE__ */ jsx(Database, {}),
|
|
201
|
+
type: "submit",
|
|
202
|
+
variant: "outline",
|
|
203
|
+
className: "flex",
|
|
204
|
+
disabled: true,
|
|
205
|
+
children: "Save to a table"
|
|
206
|
+
}
|
|
207
|
+
),
|
|
208
|
+
/* @__PURE__ */ jsx(
|
|
209
|
+
Button,
|
|
210
|
+
{
|
|
211
|
+
icon: /* @__PURE__ */ jsx(Download, {}),
|
|
212
|
+
iconEnd: /* @__PURE__ */ jsx(ChevronDown, {}),
|
|
213
|
+
type: "submit",
|
|
214
|
+
variant: "outline",
|
|
215
|
+
className: "flex",
|
|
216
|
+
disabled: true,
|
|
217
|
+
children: "Export"
|
|
218
|
+
}
|
|
219
|
+
),
|
|
220
|
+
editMode !== "none" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
221
|
+
/* @__PURE__ */ jsx(
|
|
222
|
+
Button,
|
|
223
|
+
{
|
|
224
|
+
icon: /* @__PURE__ */ jsx(Save, {}),
|
|
225
|
+
type: "submit",
|
|
226
|
+
variant: "outline",
|
|
227
|
+
className: "flex",
|
|
228
|
+
disabled: true,
|
|
229
|
+
children: "Save"
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
/* @__PURE__ */ jsx(
|
|
233
|
+
Button,
|
|
234
|
+
{
|
|
235
|
+
icon: /* @__PURE__ */ jsx(X, {}),
|
|
236
|
+
type: "submit",
|
|
237
|
+
variant: "outline",
|
|
238
|
+
className: "flex",
|
|
239
|
+
disabled: true,
|
|
240
|
+
children: "Cancel"
|
|
241
|
+
}
|
|
242
|
+
)
|
|
243
|
+
] }) : /* @__PURE__ */ jsx(
|
|
244
|
+
Button,
|
|
245
|
+
{
|
|
246
|
+
icon: /* @__PURE__ */ jsx(Edit, {}),
|
|
247
|
+
type: "submit",
|
|
248
|
+
variant: "outline",
|
|
249
|
+
className: "flex",
|
|
250
|
+
disabled: true,
|
|
251
|
+
children: "Edit"
|
|
252
|
+
}
|
|
253
|
+
)
|
|
254
|
+
] });
|
|
255
|
+
}
|
|
256
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2 mt-2", children: [
|
|
257
|
+
debouncedTableData.normalizedData && /* @__PURE__ */ jsx(
|
|
258
|
+
Button,
|
|
259
|
+
{
|
|
260
|
+
icon: /* @__PURE__ */ jsx(Eye, {}),
|
|
261
|
+
variant: "outline",
|
|
262
|
+
onClick: () => setShowNormalized(!showNormalized),
|
|
263
|
+
className: "flex",
|
|
264
|
+
children: showNormalized ? "Table" : "Data"
|
|
265
|
+
}
|
|
266
|
+
),
|
|
267
|
+
renderTableActionButton(),
|
|
268
|
+
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
269
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
270
|
+
Button,
|
|
271
|
+
{
|
|
272
|
+
icon: /* @__PURE__ */ jsx(Download, {}),
|
|
273
|
+
iconEnd: /* @__PURE__ */ jsx(ChevronDown, {}),
|
|
274
|
+
variant: "outline",
|
|
275
|
+
className: "flex",
|
|
276
|
+
children: "Export"
|
|
277
|
+
}
|
|
278
|
+
) }),
|
|
279
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-64", children: [
|
|
280
|
+
/* @__PURE__ */ jsxs(
|
|
281
|
+
DropdownMenuItem,
|
|
282
|
+
{
|
|
283
|
+
onClick: copyTableToClipboard,
|
|
284
|
+
className: "flex items-center gap-2 cursor-pointer",
|
|
285
|
+
children: [
|
|
286
|
+
/* @__PURE__ */ jsx(FileText, { className: "h-4 w-4 text-green-500" }),
|
|
287
|
+
/* @__PURE__ */ jsx("span", { children: "Copy as Text" })
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
),
|
|
291
|
+
content && /* @__PURE__ */ jsxs(
|
|
292
|
+
DropdownMenuItem,
|
|
293
|
+
{
|
|
294
|
+
onClick: copyMarkdownToClipboard,
|
|
295
|
+
className: "flex items-center gap-2 cursor-pointer",
|
|
296
|
+
children: [
|
|
297
|
+
/* @__PURE__ */ jsx(FileDown, { className: "h-4 w-4 text-purple-500" }),
|
|
298
|
+
/* @__PURE__ */ jsx("span", { children: "Copy as Markdown" })
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
),
|
|
302
|
+
debouncedTableData.normalizedData && /* @__PURE__ */ jsxs(
|
|
303
|
+
DropdownMenuItem,
|
|
304
|
+
{
|
|
305
|
+
onClick: copyJsonToClipboard,
|
|
306
|
+
className: "flex items-center gap-2 cursor-pointer",
|
|
307
|
+
children: [
|
|
308
|
+
/* @__PURE__ */ jsx(FileJson, { className: "h-4 w-4 text-blue-500" }),
|
|
309
|
+
/* @__PURE__ */ jsx("span", { children: "Copy as JSON" })
|
|
310
|
+
]
|
|
311
|
+
}
|
|
312
|
+
),
|
|
313
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
314
|
+
/* @__PURE__ */ jsxs(
|
|
315
|
+
DropdownMenuItem,
|
|
316
|
+
{
|
|
317
|
+
onClick: downloadCSV,
|
|
318
|
+
className: "flex items-center gap-2 cursor-pointer",
|
|
319
|
+
children: [
|
|
320
|
+
/* @__PURE__ */ jsx(FileSpreadsheet, { className: "h-4 w-4 text-orange-500" }),
|
|
321
|
+
/* @__PURE__ */ jsx("span", { children: "Download as CSV" })
|
|
322
|
+
]
|
|
323
|
+
}
|
|
324
|
+
),
|
|
325
|
+
content && /* @__PURE__ */ jsxs(
|
|
326
|
+
DropdownMenuItem,
|
|
327
|
+
{
|
|
328
|
+
onClick: downloadMarkdown,
|
|
329
|
+
className: "flex items-center gap-2 cursor-pointer",
|
|
330
|
+
children: [
|
|
331
|
+
/* @__PURE__ */ jsx(FileDown, { className: "h-4 w-4 text-indigo-500" }),
|
|
332
|
+
/* @__PURE__ */ jsx("span", { children: "Download as Markdown" })
|
|
333
|
+
]
|
|
334
|
+
}
|
|
335
|
+
)
|
|
336
|
+
] })
|
|
337
|
+
] }),
|
|
338
|
+
editMode !== "none" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
339
|
+
/* @__PURE__ */ jsx(
|
|
340
|
+
Button,
|
|
341
|
+
{
|
|
342
|
+
icon: /* @__PURE__ */ jsx(Save, {}),
|
|
343
|
+
variant: "outline",
|
|
344
|
+
onClick: () => handleSave(notifyContentChange),
|
|
345
|
+
className: "flex",
|
|
346
|
+
children: "Save"
|
|
347
|
+
}
|
|
348
|
+
),
|
|
349
|
+
/* @__PURE__ */ jsx(
|
|
350
|
+
Button,
|
|
351
|
+
{
|
|
352
|
+
icon: /* @__PURE__ */ jsx(X, {}),
|
|
353
|
+
variant: "outline",
|
|
354
|
+
onClick: handleCancel,
|
|
355
|
+
className: "flex",
|
|
356
|
+
children: "Cancel"
|
|
357
|
+
}
|
|
358
|
+
)
|
|
359
|
+
] }) : /* @__PURE__ */ jsx(
|
|
360
|
+
Button,
|
|
361
|
+
{
|
|
362
|
+
icon: /* @__PURE__ */ jsx(Edit, {}),
|
|
363
|
+
variant: "outline",
|
|
364
|
+
onClick: () => toggleGlobalEditMode(notifyContentChange),
|
|
365
|
+
className: "flex",
|
|
366
|
+
children: "Edit"
|
|
367
|
+
}
|
|
368
|
+
)
|
|
369
|
+
] });
|
|
370
|
+
};
|
|
371
|
+
const MarkdownTable = ({
|
|
372
|
+
data,
|
|
373
|
+
className = "",
|
|
374
|
+
fontSize = 16,
|
|
375
|
+
theme = "professional",
|
|
376
|
+
onSave = () => {
|
|
377
|
+
},
|
|
378
|
+
content = "",
|
|
379
|
+
onContentChange
|
|
380
|
+
}) => {
|
|
381
|
+
const [tableData, setTableData] = useState({
|
|
382
|
+
headers: [],
|
|
383
|
+
rows: [],
|
|
384
|
+
normalizedData: data?.normalizedData
|
|
385
|
+
});
|
|
386
|
+
const [showNormalized, setShowNormalized] = useState(false);
|
|
387
|
+
const [editMode, setEditMode] = useState("none");
|
|
388
|
+
const tableFontsize = fontSize;
|
|
389
|
+
const toast = useToastManager();
|
|
390
|
+
const tableTheme = THEMES[theme]?.table || THEMES.professional.table;
|
|
391
|
+
useEffect(() => {
|
|
392
|
+
if (data) {
|
|
393
|
+
setTableData({
|
|
394
|
+
headers: data.headers,
|
|
395
|
+
rows: data.rows,
|
|
396
|
+
normalizedData: data.normalizedData
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
}, [data]);
|
|
400
|
+
const renderMarkdown = (text) => /* @__PURE__ */ jsx(RichContent, { level: "inline", source: text, isStreaming: false, gfmCell: true });
|
|
401
|
+
const toggleGlobalEditMode = useCallback(
|
|
402
|
+
(notifyContentChange) => {
|
|
403
|
+
if (editMode !== "none") {
|
|
404
|
+
if (!notifyContentChange()) return;
|
|
405
|
+
onSave(tableData);
|
|
406
|
+
setEditMode("none");
|
|
407
|
+
toast.info("Edit mode deactivated");
|
|
408
|
+
} else {
|
|
409
|
+
setEditMode("header");
|
|
410
|
+
toast.info("Edit mode activated");
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
[editMode, onSave, tableData, toast]
|
|
414
|
+
);
|
|
415
|
+
const handleHeaderChange = useCallback(
|
|
416
|
+
(index, value) => {
|
|
417
|
+
const newHeaders = [...tableData.headers];
|
|
418
|
+
newHeaders[index] = value;
|
|
419
|
+
setTableData({ ...tableData, headers: newHeaders });
|
|
420
|
+
},
|
|
421
|
+
[tableData]
|
|
422
|
+
);
|
|
423
|
+
const handleCellChange = useCallback(
|
|
424
|
+
(rowIndex, colIndex, value) => {
|
|
425
|
+
const newRows = [...tableData.rows];
|
|
426
|
+
newRows[rowIndex][colIndex] = value;
|
|
427
|
+
setTableData({ ...tableData, rows: newRows });
|
|
428
|
+
},
|
|
429
|
+
[tableData]
|
|
430
|
+
);
|
|
431
|
+
const handleRowClick = useCallback(
|
|
432
|
+
(rowIndex) => {
|
|
433
|
+
if (editMode === "none") return;
|
|
434
|
+
onSave(tableData);
|
|
435
|
+
setEditMode(rowIndex);
|
|
436
|
+
},
|
|
437
|
+
[editMode, onSave, tableData]
|
|
438
|
+
);
|
|
439
|
+
const handleHeaderClick = useCallback(() => {
|
|
440
|
+
if (editMode === "none") return;
|
|
441
|
+
onSave(tableData);
|
|
442
|
+
setEditMode("header");
|
|
443
|
+
}, [editMode, onSave, tableData]);
|
|
444
|
+
const handleSave = useCallback(
|
|
445
|
+
(notifyContentChange) => {
|
|
446
|
+
if (!notifyContentChange()) return;
|
|
447
|
+
onSave(tableData);
|
|
448
|
+
setEditMode("none");
|
|
449
|
+
toast.success("Table data saved");
|
|
450
|
+
},
|
|
451
|
+
[onSave, tableData, toast]
|
|
452
|
+
);
|
|
453
|
+
const handleCancel = useCallback(() => {
|
|
454
|
+
if (data) {
|
|
455
|
+
setTableData({
|
|
456
|
+
headers: data.headers,
|
|
457
|
+
rows: data.rows,
|
|
458
|
+
normalizedData: data.normalizedData
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
setEditMode("none");
|
|
462
|
+
toast.info("Edits cancelled");
|
|
463
|
+
}, [data, toast]);
|
|
464
|
+
const openSaveToTable = useOpenSaveToTable();
|
|
465
|
+
const onSaveAsTable = useCallback(() => {
|
|
466
|
+
openSaveToTable?.({ grid: { headers: tableData.headers, rows: tableData.rows } });
|
|
467
|
+
}, [openSaveToTable, tableData.headers, tableData.rows]);
|
|
468
|
+
const isEditingEnabled = editMode !== "none";
|
|
469
|
+
const isEditingHeader = editMode === "header";
|
|
470
|
+
const editingBorderStyle = "overflow-x-auto rounded-xl border-3 border-dashed border-red-500 rounded-xl";
|
|
471
|
+
const normalBorderStyle = `overflow-x-auto rounded-xl border-3 ${tableTheme.border}`;
|
|
472
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("relative", className), children: [
|
|
473
|
+
showNormalized && tableData.normalizedData ? /* @__PURE__ */ jsxs("div", { className: "relative p-4 bg-gray-100 dark:bg-gray-800 rounded-lg", children: [
|
|
474
|
+
/* @__PURE__ */ jsx("pre", { className: "text-sm overflow-auto", children: JSON.stringify(tableData.normalizedData, null, 2) }),
|
|
475
|
+
/* @__PURE__ */ jsx(
|
|
476
|
+
Button,
|
|
477
|
+
{
|
|
478
|
+
icon: /* @__PURE__ */ jsx(Eye, {}),
|
|
479
|
+
variant: "outline",
|
|
480
|
+
onClick: () => setShowNormalized(false),
|
|
481
|
+
className: "absolute top-2 right-2 flex",
|
|
482
|
+
children: "View Table"
|
|
483
|
+
}
|
|
484
|
+
)
|
|
485
|
+
] }) : /* @__PURE__ */ jsx(
|
|
486
|
+
"div",
|
|
487
|
+
{
|
|
488
|
+
className: isEditingEnabled ? editingBorderStyle : normalBorderStyle,
|
|
489
|
+
children: /* @__PURE__ */ jsxs(
|
|
490
|
+
"table",
|
|
491
|
+
{
|
|
492
|
+
className: "w-full border-collapse",
|
|
493
|
+
style: { fontSize: `${tableFontsize}px` },
|
|
494
|
+
children: [
|
|
495
|
+
/* @__PURE__ */ jsx("thead", { className: tableTheme.header, children: /* @__PURE__ */ jsx("tr", { onClick: handleHeaderClick, children: tableData.headers.map((header, i) => /* @__PURE__ */ jsx(
|
|
496
|
+
"th",
|
|
497
|
+
{
|
|
498
|
+
className: cn("p-2 text-left", tableTheme.headerText),
|
|
499
|
+
children: isEditingHeader ? /* @__PURE__ */ jsx(
|
|
500
|
+
"input",
|
|
501
|
+
{
|
|
502
|
+
type: "text",
|
|
503
|
+
value: header,
|
|
504
|
+
onChange: (e) => handleHeaderChange(i, e.target.value),
|
|
505
|
+
className: cn(
|
|
506
|
+
"w-full bg-transparent outline-none border border-dashed border-blue-300 p-1",
|
|
507
|
+
tableTheme.headerText
|
|
508
|
+
),
|
|
509
|
+
onClick: (e) => e.stopPropagation()
|
|
510
|
+
}
|
|
511
|
+
) : renderMarkdown(header)
|
|
512
|
+
},
|
|
513
|
+
i
|
|
514
|
+
)) }) }),
|
|
515
|
+
/* @__PURE__ */ jsx("tbody", { children: tableData.rows.map((row, rowIndex) => /* @__PURE__ */ jsx(
|
|
516
|
+
"tr",
|
|
517
|
+
{
|
|
518
|
+
className: cn(
|
|
519
|
+
"border-t",
|
|
520
|
+
tableTheme.row,
|
|
521
|
+
editMode === rowIndex && "bg-blue-50 dark:bg-blue-900/20"
|
|
522
|
+
),
|
|
523
|
+
onClick: () => handleRowClick(rowIndex),
|
|
524
|
+
children: row.map((cell, colIndex) => /* @__PURE__ */ jsx(
|
|
525
|
+
"td",
|
|
526
|
+
{
|
|
527
|
+
className: cn("p-2", colIndex === 0 && "font-semibold"),
|
|
528
|
+
children: editMode === rowIndex ? /* @__PURE__ */ jsx(
|
|
529
|
+
"textarea",
|
|
530
|
+
{
|
|
531
|
+
value: cell,
|
|
532
|
+
onChange: (e) => handleCellChange(rowIndex, colIndex, e.target.value),
|
|
533
|
+
className: cn(
|
|
534
|
+
"w-full bg-transparent outline-none border border-dashed border-blue-300 p-1",
|
|
535
|
+
"resize-y min-h-[8rem]",
|
|
536
|
+
colIndex === 0 && "font-semibold"
|
|
537
|
+
),
|
|
538
|
+
onClick: (e) => e.stopPropagation(),
|
|
539
|
+
onFocus: (e) => e.target.select()
|
|
540
|
+
}
|
|
541
|
+
) : renderMarkdown(cell)
|
|
542
|
+
},
|
|
543
|
+
colIndex
|
|
544
|
+
))
|
|
545
|
+
},
|
|
546
|
+
rowIndex
|
|
547
|
+
)) })
|
|
548
|
+
]
|
|
549
|
+
}
|
|
550
|
+
)
|
|
551
|
+
}
|
|
552
|
+
),
|
|
553
|
+
/* @__PURE__ */ jsx(
|
|
554
|
+
TableControls,
|
|
555
|
+
{
|
|
556
|
+
tableData,
|
|
557
|
+
content,
|
|
558
|
+
showNormalized,
|
|
559
|
+
setShowNormalized,
|
|
560
|
+
editMode,
|
|
561
|
+
onSaveAsTable: openSaveToTable ? onSaveAsTable : null,
|
|
562
|
+
onSave,
|
|
563
|
+
onContentChange,
|
|
564
|
+
toggleGlobalEditMode,
|
|
565
|
+
handleSave,
|
|
566
|
+
handleCancel
|
|
567
|
+
}
|
|
568
|
+
)
|
|
569
|
+
] });
|
|
570
|
+
};
|
|
571
|
+
var TableWithSeparatedControls_default = MarkdownTable;
|
|
572
|
+
export {
|
|
573
|
+
TableWithSeparatedControls_default as default
|
|
574
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface TableInfo {
|
|
3
|
+
table_id: string;
|
|
4
|
+
table_name: string;
|
|
5
|
+
row_count: string;
|
|
6
|
+
field_count: string;
|
|
7
|
+
}
|
|
8
|
+
interface ViewTableModalProps {
|
|
9
|
+
isOpen: boolean;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
tableInfo: TableInfo;
|
|
12
|
+
}
|
|
13
|
+
declare const ViewTableModal: React.FC<ViewTableModalProps>;
|
|
14
|
+
export default ViewTableModal;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@ai-matrx/design-system";
|
|
4
|
+
import { Button } from "@ai-matrx/design-system/controls";
|
|
5
|
+
import { ExternalLink } from "lucide-react";
|
|
6
|
+
import { cn } from "@ai-matrx/design-system";
|
|
7
|
+
import { LocatedTableViewer } from "../../host/app-bindings.js";
|
|
8
|
+
const ViewTableModal = ({
|
|
9
|
+
isOpen,
|
|
10
|
+
onClose,
|
|
11
|
+
tableInfo
|
|
12
|
+
}) => {
|
|
13
|
+
const handleOpenInNewTab = () => {
|
|
14
|
+
if (tableInfo?.table_id) {
|
|
15
|
+
window.open(`/data/${tableInfo.table_id}`, "_blank");
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
19
|
+
Dialog,
|
|
20
|
+
{
|
|
21
|
+
open: isOpen,
|
|
22
|
+
onOpenChange: (open) => {
|
|
23
|
+
if (!open) {
|
|
24
|
+
onClose();
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
children: /* @__PURE__ */ jsxs(DialogContent, { className: cn(
|
|
28
|
+
"bg-textured text-gray-900 dark:text-gray-100 overflow-hidden",
|
|
29
|
+
"max-w-[95vw] w-[95vw] h-[90dvh] p-3 border-3 border-gray-200 dark:border-gray-700 rounded-3xl"
|
|
30
|
+
), children: [
|
|
31
|
+
/* @__PURE__ */ jsx(DialogHeader, { className: "flex flex-row items-center justify-between mb-1", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "text-xl font-semibold", children: [
|
|
32
|
+
"This table has ",
|
|
33
|
+
tableInfo.row_count,
|
|
34
|
+
" rows and ",
|
|
35
|
+
tableInfo.field_count,
|
|
36
|
+
" fields per row."
|
|
37
|
+
] }) }),
|
|
38
|
+
/* @__PURE__ */ jsx("div", { className: "py-0", children: /* @__PURE__ */ jsx("div", { className: "h-[calc(85dvh-140px)] overflow-auto border-border rounded-lg bg-textured", children: /* @__PURE__ */ jsx(LocatedTableViewer, { tableId: tableInfo.table_id }) }) }),
|
|
39
|
+
/* @__PURE__ */ jsx(DialogFooter, { className: "flex items-center gap-2 mt-2 pt-2", children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end w-full gap-2", children: [
|
|
40
|
+
/* @__PURE__ */ jsxs(
|
|
41
|
+
Button,
|
|
42
|
+
{
|
|
43
|
+
variant: "outline",
|
|
44
|
+
onClick: handleOpenInNewTab,
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ jsx(ExternalLink, { className: "h-4 w-4 mr-2" }),
|
|
47
|
+
"Open in New Tab"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
/* @__PURE__ */ jsx(
|
|
52
|
+
Button,
|
|
53
|
+
{
|
|
54
|
+
variant: "primary",
|
|
55
|
+
onClick: onClose,
|
|
56
|
+
children: "Done"
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
] }) })
|
|
60
|
+
] })
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
var ViewTableModal_default = ViewTableModal;
|
|
65
|
+
export {
|
|
66
|
+
ViewTableModal_default as default
|
|
67
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface ColumnActionsMenuProps {
|
|
3
|
+
onInsertBefore: () => void;
|
|
4
|
+
onInsertAfter: () => void;
|
|
5
|
+
onDuplicate: () => void;
|
|
6
|
+
onClear: () => void;
|
|
7
|
+
onDelete: () => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Tiny per-column action menu. Stays invisible until the parent header cell
|
|
11
|
+
* is hovered (relies on a `group/col` class on the <th>). The trigger and
|
|
12
|
+
* items all stop event propagation so they don't trigger the header row's
|
|
13
|
+
* onClick handler (which would otherwise switch to header-edit mode).
|
|
14
|
+
*/
|
|
15
|
+
export declare const ColumnActionsMenu: React.FC<ColumnActionsMenuProps>;
|
|
16
|
+
export {};
|