@ai-matrx/rich-content 0.2.3 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -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/csv/CsvBlock.js +5 -1
- 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 +32 -3
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
MoreVertical,
|
|
5
|
+
ArrowLeft,
|
|
6
|
+
ArrowRight,
|
|
7
|
+
Copy,
|
|
8
|
+
Eraser,
|
|
9
|
+
Trash2
|
|
10
|
+
} from "lucide-react";
|
|
11
|
+
import { Button } from "@ai-matrx/design-system";
|
|
12
|
+
import {
|
|
13
|
+
DropdownMenu,
|
|
14
|
+
DropdownMenuContent,
|
|
15
|
+
DropdownMenuItem,
|
|
16
|
+
DropdownMenuSeparator,
|
|
17
|
+
DropdownMenuTrigger
|
|
18
|
+
} from "@ai-matrx/design-system";
|
|
19
|
+
const ColumnActionsMenu = ({
|
|
20
|
+
onInsertBefore,
|
|
21
|
+
onInsertAfter,
|
|
22
|
+
onDuplicate,
|
|
23
|
+
onClear,
|
|
24
|
+
onDelete
|
|
25
|
+
}) => {
|
|
26
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
27
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
28
|
+
Button,
|
|
29
|
+
{
|
|
30
|
+
variant: "ghost",
|
|
31
|
+
size: "icon",
|
|
32
|
+
onClick: (e) => e.stopPropagation(),
|
|
33
|
+
className: "h-5 w-5 p-0 [&_svg]:size-3 opacity-0 group-hover/col:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100 transition-opacity text-muted-foreground hover:text-foreground",
|
|
34
|
+
"aria-label": "Column actions",
|
|
35
|
+
children: /* @__PURE__ */ jsx(MoreVertical, {})
|
|
36
|
+
}
|
|
37
|
+
) }),
|
|
38
|
+
/* @__PURE__ */ jsxs(
|
|
39
|
+
DropdownMenuContent,
|
|
40
|
+
{
|
|
41
|
+
align: "start",
|
|
42
|
+
className: "w-44",
|
|
43
|
+
onClick: (e) => e.stopPropagation(),
|
|
44
|
+
children: [
|
|
45
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: onInsertBefore, className: "cursor-pointer", children: [
|
|
46
|
+
/* @__PURE__ */ jsx(ArrowLeft, { className: "h-4 w-4 mr-2 text-blue-500" }),
|
|
47
|
+
"Insert before"
|
|
48
|
+
] }),
|
|
49
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: onInsertAfter, className: "cursor-pointer", children: [
|
|
50
|
+
/* @__PURE__ */ jsx(ArrowRight, { className: "h-4 w-4 mr-2 text-blue-500" }),
|
|
51
|
+
"Insert after"
|
|
52
|
+
] }),
|
|
53
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: onDuplicate, className: "cursor-pointer", children: [
|
|
54
|
+
/* @__PURE__ */ jsx(Copy, { className: "h-4 w-4 mr-2 text-purple-500" }),
|
|
55
|
+
"Duplicate column"
|
|
56
|
+
] }),
|
|
57
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
58
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: onClear, className: "cursor-pointer", children: [
|
|
59
|
+
/* @__PURE__ */ jsx(Eraser, { className: "h-4 w-4 mr-2 text-amber-500" }),
|
|
60
|
+
"Clear Column"
|
|
61
|
+
] }),
|
|
62
|
+
/* @__PURE__ */ jsxs(
|
|
63
|
+
DropdownMenuItem,
|
|
64
|
+
{
|
|
65
|
+
onClick: onDelete,
|
|
66
|
+
className: "cursor-pointer text-red-600 dark:text-red-400 focus:text-red-600 dark:focus:text-red-400",
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4 mr-2" }),
|
|
69
|
+
"Delete column"
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
] });
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
ColumnActionsMenu
|
|
80
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface RowActionsMenuProps {
|
|
3
|
+
onInsertAbove: () => void;
|
|
4
|
+
onInsertBelow: () => void;
|
|
5
|
+
onDuplicate: () => void;
|
|
6
|
+
onClear: () => void;
|
|
7
|
+
onDelete: () => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Tiny per-row action menu. Stays invisible until the parent row is hovered
|
|
11
|
+
* (relies on a `group/row` class on the <tr>). The trigger and items all
|
|
12
|
+
* stop event propagation so they don't trigger the row's onClick handler
|
|
13
|
+
* (which would otherwise enter cell-edit mode for that row).
|
|
14
|
+
*/
|
|
15
|
+
export declare const RowActionsMenu: React.FC<RowActionsMenuProps>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
MoreVertical,
|
|
5
|
+
ArrowUp,
|
|
6
|
+
ArrowDown,
|
|
7
|
+
Copy,
|
|
8
|
+
Eraser,
|
|
9
|
+
Trash2
|
|
10
|
+
} from "lucide-react";
|
|
11
|
+
import { Button } from "@ai-matrx/design-system";
|
|
12
|
+
import {
|
|
13
|
+
DropdownMenu,
|
|
14
|
+
DropdownMenuContent,
|
|
15
|
+
DropdownMenuItem,
|
|
16
|
+
DropdownMenuSeparator,
|
|
17
|
+
DropdownMenuTrigger
|
|
18
|
+
} from "@ai-matrx/design-system";
|
|
19
|
+
const RowActionsMenu = ({
|
|
20
|
+
onInsertAbove,
|
|
21
|
+
onInsertBelow,
|
|
22
|
+
onDuplicate,
|
|
23
|
+
onClear,
|
|
24
|
+
onDelete
|
|
25
|
+
}) => {
|
|
26
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
27
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
28
|
+
Button,
|
|
29
|
+
{
|
|
30
|
+
variant: "ghost",
|
|
31
|
+
size: "icon",
|
|
32
|
+
onClick: (e) => e.stopPropagation(),
|
|
33
|
+
className: "h-5 w-5 p-0 [&_svg]:size-3 opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100 transition-opacity text-muted-foreground hover:text-foreground",
|
|
34
|
+
"aria-label": "Row actions",
|
|
35
|
+
children: /* @__PURE__ */ jsx(MoreVertical, {})
|
|
36
|
+
}
|
|
37
|
+
) }),
|
|
38
|
+
/* @__PURE__ */ jsxs(
|
|
39
|
+
DropdownMenuContent,
|
|
40
|
+
{
|
|
41
|
+
align: "start",
|
|
42
|
+
className: "w-44",
|
|
43
|
+
onClick: (e) => e.stopPropagation(),
|
|
44
|
+
children: [
|
|
45
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: onInsertAbove, className: "cursor-pointer", children: [
|
|
46
|
+
/* @__PURE__ */ jsx(ArrowUp, { className: "h-4 w-4 mr-2 text-blue-500" }),
|
|
47
|
+
"Insert above"
|
|
48
|
+
] }),
|
|
49
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: onInsertBelow, className: "cursor-pointer", children: [
|
|
50
|
+
/* @__PURE__ */ jsx(ArrowDown, { className: "h-4 w-4 mr-2 text-blue-500" }),
|
|
51
|
+
"Insert below"
|
|
52
|
+
] }),
|
|
53
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: onDuplicate, className: "cursor-pointer", children: [
|
|
54
|
+
/* @__PURE__ */ jsx(Copy, { className: "h-4 w-4 mr-2 text-purple-500" }),
|
|
55
|
+
"Duplicate row"
|
|
56
|
+
] }),
|
|
57
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
58
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: onClear, className: "cursor-pointer", children: [
|
|
59
|
+
/* @__PURE__ */ jsx(Eraser, { className: "h-4 w-4 mr-2 text-amber-500" }),
|
|
60
|
+
"Clear Row"
|
|
61
|
+
] }),
|
|
62
|
+
/* @__PURE__ */ jsxs(
|
|
63
|
+
DropdownMenuItem,
|
|
64
|
+
{
|
|
65
|
+
onClick: onDelete,
|
|
66
|
+
className: "cursor-pointer text-red-600 dark:text-red-400 focus:text-red-600 dark:focus:text-red-400",
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4 mr-2" }),
|
|
69
|
+
"Delete row"
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
] });
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
RowActionsMenu
|
|
80
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface TableEditToolbarProps {
|
|
3
|
+
onAddRow: () => void;
|
|
4
|
+
onAddColumn: () => void;
|
|
5
|
+
/**
|
|
6
|
+
* Empties all data cells except the first column. Headers and first-column
|
|
7
|
+
* values are preserved. Disabled when there are no rows or only one column.
|
|
8
|
+
*/
|
|
9
|
+
onClearAllContents: () => void;
|
|
10
|
+
rowCount: number;
|
|
11
|
+
colCount: number;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const TableEditToolbar: React.FC<TableEditToolbarProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Plus, Eraser, Columns3, Rows3 } from "lucide-react";
|
|
4
|
+
import { Button } from "@ai-matrx/design-system";
|
|
5
|
+
import { cn } from "@ai-matrx/design-system";
|
|
6
|
+
const TableEditToolbar = ({
|
|
7
|
+
onAddRow,
|
|
8
|
+
onAddColumn,
|
|
9
|
+
onClearAllContents,
|
|
10
|
+
rowCount,
|
|
11
|
+
colCount,
|
|
12
|
+
className
|
|
13
|
+
}) => {
|
|
14
|
+
const clearDisabled = rowCount === 0 || colCount <= 1;
|
|
15
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-wrap items-center gap-2", className), children: [
|
|
16
|
+
/* @__PURE__ */ jsxs(
|
|
17
|
+
Button,
|
|
18
|
+
{
|
|
19
|
+
variant: "outline",
|
|
20
|
+
size: "sm",
|
|
21
|
+
onClick: onAddRow,
|
|
22
|
+
className: "flex items-center gap-1.5 hover:bg-blue-100 dark:hover:bg-blue-800/30",
|
|
23
|
+
children: [
|
|
24
|
+
/* @__PURE__ */ jsx(Plus, { className: "h-3.5 w-3.5" }),
|
|
25
|
+
/* @__PURE__ */ jsx(Rows3, { className: "h-3.5 w-3.5" }),
|
|
26
|
+
"Add Row"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
/* @__PURE__ */ jsxs(
|
|
31
|
+
Button,
|
|
32
|
+
{
|
|
33
|
+
variant: "outline",
|
|
34
|
+
size: "sm",
|
|
35
|
+
onClick: onAddColumn,
|
|
36
|
+
className: "flex items-center gap-1.5 hover:bg-blue-100 dark:hover:bg-blue-800/30",
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ jsx(Plus, { className: "h-3.5 w-3.5" }),
|
|
39
|
+
/* @__PURE__ */ jsx(Columns3, { className: "h-3.5 w-3.5" }),
|
|
40
|
+
"Add Column"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ jsxs(
|
|
45
|
+
Button,
|
|
46
|
+
{
|
|
47
|
+
variant: "outline",
|
|
48
|
+
size: "sm",
|
|
49
|
+
onClick: onClearAllContents,
|
|
50
|
+
disabled: clearDisabled,
|
|
51
|
+
title: "Clears all data cells. Preserves headers and the first column.",
|
|
52
|
+
className: "flex items-center gap-1.5 text-red-600 dark:text-red-400 border-red-200 dark:border-red-900/40 hover:bg-red-50 dark:hover:bg-red-900/20 disabled:opacity-50",
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsx(Eraser, { className: "h-3.5 w-3.5" }),
|
|
55
|
+
"Clear All Contents"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
] });
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
TableEditToolbar
|
|
63
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure mutation utilities for markdown table data.
|
|
3
|
+
*
|
|
4
|
+
* Every function takes a TableShape and returns a new TableShape. Inputs are
|
|
5
|
+
* never mutated. normalizedData is regenerated whenever it was present and
|
|
6
|
+
* the shape (rows or headers) changes.
|
|
7
|
+
*
|
|
8
|
+
* These run inside React event handlers, so they must be cheap enough for
|
|
9
|
+
* tables in the low-thousands-of-cells range. They are intentionally NOT
|
|
10
|
+
* called during streaming — the consuming components gate every call on
|
|
11
|
+
* `editMode !== "none"`, which is itself only reachable when the stream
|
|
12
|
+
* has completed.
|
|
13
|
+
*/
|
|
14
|
+
export type TableShape = {
|
|
15
|
+
headers: string[];
|
|
16
|
+
rows: string[][];
|
|
17
|
+
normalizedData?: Array<{
|
|
18
|
+
[key: string]: string;
|
|
19
|
+
}>;
|
|
20
|
+
};
|
|
21
|
+
/** Insert an empty row at a specific index. Out-of-range indices append. */
|
|
22
|
+
export declare const insertRow: (table: TableShape, atIndex?: number) => TableShape;
|
|
23
|
+
export declare const insertRowAbove: (table: TableShape, atIndex: number) => TableShape;
|
|
24
|
+
export declare const insertRowBelow: (table: TableShape, atIndex: number) => TableShape;
|
|
25
|
+
export declare const appendRow: (table: TableShape) => TableShape;
|
|
26
|
+
export declare const removeRow: (table: TableShape, atIndex: number) => TableShape;
|
|
27
|
+
/** Empty the cells of a row but keep the row (preserves row count). */
|
|
28
|
+
export declare const clearRow: (table: TableShape, atIndex: number) => TableShape;
|
|
29
|
+
/** Duplicate a row (copy is placed immediately below the original). */
|
|
30
|
+
export declare const duplicateRow: (table: TableShape, atIndex: number) => TableShape;
|
|
31
|
+
/** Remove all data rows (headers preserved). */
|
|
32
|
+
export declare const clearAllRows: (table: TableShape) => TableShape;
|
|
33
|
+
/**
|
|
34
|
+
* Empty all data cells EXCEPT the first column (headers and first-column
|
|
35
|
+
* values are preserved). Useful when the first column is a row label or
|
|
36
|
+
* key the user wants to keep while wiping the rest.
|
|
37
|
+
*
|
|
38
|
+
* No-op when there is at most one column (nothing to clear).
|
|
39
|
+
*/
|
|
40
|
+
export declare const clearAllContents: (table: TableShape) => TableShape;
|
|
41
|
+
/** Insert a new column. Out-of-range indices append. New header is uniquified. */
|
|
42
|
+
export declare const insertColumn: (table: TableShape, atIndex?: number, headerLabel?: string) => TableShape;
|
|
43
|
+
export declare const insertColumnBefore: (table: TableShape, atIndex: number, headerLabel?: string) => TableShape;
|
|
44
|
+
export declare const insertColumnAfter: (table: TableShape, atIndex: number, headerLabel?: string) => TableShape;
|
|
45
|
+
export declare const appendColumn: (table: TableShape, headerLabel?: string) => TableShape;
|
|
46
|
+
export declare const removeColumn: (table: TableShape, atIndex: number) => TableShape;
|
|
47
|
+
/** Empty all data cells in a column but keep the header. */
|
|
48
|
+
export declare const clearColumn: (table: TableShape, atIndex: number) => TableShape;
|
|
49
|
+
/** Duplicate a column (copy header gets " (copy)" suffix; placed immediately to the right). */
|
|
50
|
+
export declare const duplicateColumn: (table: TableShape, atIndex: number) => TableShape;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { unwrapCodeSpans } from "@ai-matrx/content-ir/source";
|
|
2
|
+
const cleanHeaderForKey = (header) => unwrapCodeSpans(header).replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1").replace(/(?<![A-Za-z0-9])_([^_\n]+?)_(?![A-Za-z0-9])/g, "$1").replace(/\[([^\]]+)\]\(([^)]+)\)/g, "$1|$2").trim();
|
|
3
|
+
const buildNormalizedRow = (headers, row) => {
|
|
4
|
+
const obj = {};
|
|
5
|
+
headers.forEach((header, i) => {
|
|
6
|
+
obj[cleanHeaderForKey(header)] = i < row.length ? row[i] : "";
|
|
7
|
+
});
|
|
8
|
+
return obj;
|
|
9
|
+
};
|
|
10
|
+
const rebuildNormalizedData = (table) => {
|
|
11
|
+
if (!table.normalizedData) return table;
|
|
12
|
+
return {
|
|
13
|
+
...table,
|
|
14
|
+
normalizedData: table.rows.map(
|
|
15
|
+
(row) => buildNormalizedRow(table.headers, row)
|
|
16
|
+
)
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const emptyRow = (colCount) => Array.from({ length: colCount }, () => "");
|
|
20
|
+
const ensureUniqueHeader = (label, existing) => {
|
|
21
|
+
if (!existing.includes(label)) return label;
|
|
22
|
+
let counter = 2;
|
|
23
|
+
while (existing.includes(`${label} ${counter}`)) {
|
|
24
|
+
counter++;
|
|
25
|
+
}
|
|
26
|
+
return `${label} ${counter}`;
|
|
27
|
+
};
|
|
28
|
+
const insertRow = (table, atIndex) => {
|
|
29
|
+
const colCount = table.headers.length;
|
|
30
|
+
const newRow = emptyRow(colCount);
|
|
31
|
+
const insertAt = atIndex === void 0 || atIndex < 0 || atIndex > table.rows.length ? table.rows.length : atIndex;
|
|
32
|
+
const newRows = [
|
|
33
|
+
...table.rows.slice(0, insertAt),
|
|
34
|
+
newRow,
|
|
35
|
+
...table.rows.slice(insertAt)
|
|
36
|
+
];
|
|
37
|
+
return rebuildNormalizedData({ ...table, rows: newRows });
|
|
38
|
+
};
|
|
39
|
+
const insertRowAbove = (table, atIndex) => insertRow(table, atIndex);
|
|
40
|
+
const insertRowBelow = (table, atIndex) => insertRow(table, atIndex + 1);
|
|
41
|
+
const appendRow = (table) => insertRow(table, table.rows.length);
|
|
42
|
+
const removeRow = (table, atIndex) => {
|
|
43
|
+
if (atIndex < 0 || atIndex >= table.rows.length) return table;
|
|
44
|
+
const newRows = table.rows.filter((_, i) => i !== atIndex);
|
|
45
|
+
return rebuildNormalizedData({ ...table, rows: newRows });
|
|
46
|
+
};
|
|
47
|
+
const clearRow = (table, atIndex) => {
|
|
48
|
+
if (atIndex < 0 || atIndex >= table.rows.length) return table;
|
|
49
|
+
const colCount = table.headers.length;
|
|
50
|
+
const cleared = emptyRow(colCount);
|
|
51
|
+
const newRows = table.rows.map((row, i) => i === atIndex ? cleared : row);
|
|
52
|
+
return rebuildNormalizedData({ ...table, rows: newRows });
|
|
53
|
+
};
|
|
54
|
+
const duplicateRow = (table, atIndex) => {
|
|
55
|
+
if (atIndex < 0 || atIndex >= table.rows.length) return table;
|
|
56
|
+
const copy = [...table.rows[atIndex]];
|
|
57
|
+
const newRows = [
|
|
58
|
+
...table.rows.slice(0, atIndex + 1),
|
|
59
|
+
copy,
|
|
60
|
+
...table.rows.slice(atIndex + 1)
|
|
61
|
+
];
|
|
62
|
+
return rebuildNormalizedData({ ...table, rows: newRows });
|
|
63
|
+
};
|
|
64
|
+
const clearAllRows = (table) => rebuildNormalizedData({ ...table, rows: [] });
|
|
65
|
+
const clearAllContents = (table) => {
|
|
66
|
+
if (table.headers.length <= 1) return table;
|
|
67
|
+
const newRows = table.rows.map(
|
|
68
|
+
(row) => row.map((cell, i) => i === 0 ? cell : "")
|
|
69
|
+
);
|
|
70
|
+
return rebuildNormalizedData({ ...table, rows: newRows });
|
|
71
|
+
};
|
|
72
|
+
const insertColumn = (table, atIndex, headerLabel = "New Column") => {
|
|
73
|
+
const insertAt = atIndex === void 0 || atIndex < 0 || atIndex > table.headers.length ? table.headers.length : atIndex;
|
|
74
|
+
const finalHeader = ensureUniqueHeader(headerLabel, table.headers);
|
|
75
|
+
const newHeaders = [
|
|
76
|
+
...table.headers.slice(0, insertAt),
|
|
77
|
+
finalHeader,
|
|
78
|
+
...table.headers.slice(insertAt)
|
|
79
|
+
];
|
|
80
|
+
const newRows = table.rows.map((row) => [
|
|
81
|
+
...row.slice(0, insertAt),
|
|
82
|
+
"",
|
|
83
|
+
...row.slice(insertAt)
|
|
84
|
+
]);
|
|
85
|
+
return rebuildNormalizedData({
|
|
86
|
+
...table,
|
|
87
|
+
headers: newHeaders,
|
|
88
|
+
rows: newRows
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
const insertColumnBefore = (table, atIndex, headerLabel) => insertColumn(table, atIndex, headerLabel);
|
|
92
|
+
const insertColumnAfter = (table, atIndex, headerLabel) => insertColumn(table, atIndex + 1, headerLabel);
|
|
93
|
+
const appendColumn = (table, headerLabel) => insertColumn(table, table.headers.length, headerLabel);
|
|
94
|
+
const removeColumn = (table, atIndex) => {
|
|
95
|
+
if (atIndex < 0 || atIndex >= table.headers.length) return table;
|
|
96
|
+
const newHeaders = table.headers.filter((_, i) => i !== atIndex);
|
|
97
|
+
const newRows = table.rows.map((row) => row.filter((_, i) => i !== atIndex));
|
|
98
|
+
return rebuildNormalizedData({
|
|
99
|
+
...table,
|
|
100
|
+
headers: newHeaders,
|
|
101
|
+
rows: newRows
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
const clearColumn = (table, atIndex) => {
|
|
105
|
+
if (atIndex < 0 || atIndex >= table.headers.length) return table;
|
|
106
|
+
const newRows = table.rows.map(
|
|
107
|
+
(row) => row.map((cell, i) => i === atIndex ? "" : cell)
|
|
108
|
+
);
|
|
109
|
+
return rebuildNormalizedData({ ...table, rows: newRows });
|
|
110
|
+
};
|
|
111
|
+
const duplicateColumn = (table, atIndex) => {
|
|
112
|
+
if (atIndex < 0 || atIndex >= table.headers.length) return table;
|
|
113
|
+
const baseHeader = table.headers[atIndex];
|
|
114
|
+
const copyHeader = ensureUniqueHeader(`${baseHeader} (copy)`, table.headers);
|
|
115
|
+
const newHeaders = [
|
|
116
|
+
...table.headers.slice(0, atIndex + 1),
|
|
117
|
+
copyHeader,
|
|
118
|
+
...table.headers.slice(atIndex + 1)
|
|
119
|
+
];
|
|
120
|
+
const newRows = table.rows.map((row) => [
|
|
121
|
+
...row.slice(0, atIndex + 1),
|
|
122
|
+
row[atIndex] ?? "",
|
|
123
|
+
...row.slice(atIndex + 1)
|
|
124
|
+
]);
|
|
125
|
+
return rebuildNormalizedData({
|
|
126
|
+
...table,
|
|
127
|
+
headers: newHeaders,
|
|
128
|
+
rows: newRows
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
export {
|
|
132
|
+
appendColumn,
|
|
133
|
+
appendRow,
|
|
134
|
+
clearAllContents,
|
|
135
|
+
clearAllRows,
|
|
136
|
+
clearColumn,
|
|
137
|
+
clearRow,
|
|
138
|
+
duplicateColumn,
|
|
139
|
+
duplicateRow,
|
|
140
|
+
insertColumn,
|
|
141
|
+
insertColumnAfter,
|
|
142
|
+
insertColumnBefore,
|
|
143
|
+
insertRow,
|
|
144
|
+
insertRowAbove,
|
|
145
|
+
insertRowBelow,
|
|
146
|
+
removeColumn,
|
|
147
|
+
removeRow
|
|
148
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mode controlled by the host component:
|
|
3
|
+
* - "none" → not editing
|
|
4
|
+
* - "header" → editing the header row
|
|
5
|
+
* - rowIndex N → editing body row N (cells are textareas)
|
|
6
|
+
*/
|
|
7
|
+
export type TableEditMode = "none" | "header" | number;
|
|
8
|
+
interface UseDoubleClickEditArgs {
|
|
9
|
+
/**
|
|
10
|
+
* Same gate as the visible "Edit" button. When false the hook is a no-op
|
|
11
|
+
* (e.g. while the table is streaming or otherwise locked).
|
|
12
|
+
*/
|
|
13
|
+
canEnterEditMode: boolean;
|
|
14
|
+
editMode: TableEditMode;
|
|
15
|
+
setEditMode: (mode: TableEditMode) => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Double-click anywhere on the table → enters edit mode (when allowed) and
|
|
19
|
+
* focuses the specific cell that was double-clicked. Implementation notes:
|
|
20
|
+
*
|
|
21
|
+
* 1. We attach `onDoubleClick` at the `<table>` level and identify the target
|
|
22
|
+
* cell via `data-cell-*` attributes on `<td>` / `<th>`. This avoids per-cell
|
|
23
|
+
* handlers and plays nicely with cell content that uses
|
|
24
|
+
* `dangerouslySetInnerHTML` (the inner span is the event target — closest()
|
|
25
|
+
* finds the cell ancestor cleanly).
|
|
26
|
+
*
|
|
27
|
+
* 2. We skip targets inside `input, textarea, button` so:
|
|
28
|
+
* - already-rendered textareas still get native double-click word selection,
|
|
29
|
+
* - row/column action menu triggers keep their normal click behavior.
|
|
30
|
+
*
|
|
31
|
+
* 3. Focus pipeline:
|
|
32
|
+
* - If the row is already in edit mode, the matching `<textarea>` is
|
|
33
|
+
* already mounted — we focus it directly.
|
|
34
|
+
* - Otherwise we stash `{row, col}` in `pendingFocusRef`, flip edit mode,
|
|
35
|
+
* and rely on the textarea ref callback (registered via
|
|
36
|
+
* `bindCellTextareaRef`) to consume the pending target on its first
|
|
37
|
+
* render and focus + select itself.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useDoubleClickEdit({ canEnterEditMode, editMode, setEditMode, }: UseDoubleClickEditArgs): {
|
|
40
|
+
handleTableDoubleClick: (e: React.MouseEvent<HTMLTableElement>) => void;
|
|
41
|
+
bindCellTextareaRef: (rowIndex: number, colIndex: number) => (el: HTMLTextAreaElement | null) => void;
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
function useDoubleClickEdit({
|
|
3
|
+
canEnterEditMode,
|
|
4
|
+
editMode,
|
|
5
|
+
setEditMode
|
|
6
|
+
}) {
|
|
7
|
+
const pendingFocusRef = useRef(null);
|
|
8
|
+
const handleTableDoubleClick = (e) => {
|
|
9
|
+
if (!canEnterEditMode) return;
|
|
10
|
+
const target = e.target;
|
|
11
|
+
if (!target) return;
|
|
12
|
+
if (target.closest("input, textarea, button")) return;
|
|
13
|
+
const cell = target.closest("[data-cell]");
|
|
14
|
+
if (!cell) return;
|
|
15
|
+
const kind = cell.dataset.cell;
|
|
16
|
+
if (kind === "header") {
|
|
17
|
+
if (editMode !== "header") setEditMode("header");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (kind === "body") {
|
|
21
|
+
const row = Number(cell.dataset.cellRow);
|
|
22
|
+
const col = Number(cell.dataset.cellCol);
|
|
23
|
+
if (Number.isNaN(row) || Number.isNaN(col)) return;
|
|
24
|
+
if (editMode === row) {
|
|
25
|
+
const textarea = cell.querySelector("textarea");
|
|
26
|
+
if (textarea) {
|
|
27
|
+
textarea.focus();
|
|
28
|
+
textarea.select();
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
pendingFocusRef.current = { row, col };
|
|
33
|
+
setEditMode(row);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const bindCellTextareaRef = (rowIndex, colIndex) => (el) => {
|
|
37
|
+
if (!el) return;
|
|
38
|
+
const pending = pendingFocusRef.current;
|
|
39
|
+
if (!pending) return;
|
|
40
|
+
if (pending.row !== rowIndex || pending.col !== colIndex) return;
|
|
41
|
+
pendingFocusRef.current = null;
|
|
42
|
+
requestAnimationFrame(() => {
|
|
43
|
+
el.focus();
|
|
44
|
+
el.select();
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
return { handleTableDoubleClick, bindCellTextareaRef };
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
useDoubleClickEdit
|
|
51
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-level undo helper for table edits.
|
|
3
|
+
*
|
|
4
|
+
* Snapshot the current state immediately before a destructive mutation,
|
|
5
|
+
* then pass `consume()` to a toast undo action. `consume()` returns the
|
|
6
|
+
* snapshot once and clears it (so a stale undo button can't restore an
|
|
7
|
+
* outdated snapshot after another mutation has happened).
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* const undo = useTableUndo<TableShape>();
|
|
11
|
+
* const handleDelete = () => {
|
|
12
|
+
* undo.snapshot(currentTable);
|
|
13
|
+
* setTable(removeRow(currentTable, idx));
|
|
14
|
+
* toast.success("Row deleted", {
|
|
15
|
+
* action: { label: "Undo", onClick: () => {
|
|
16
|
+
* const prev = undo.consume();
|
|
17
|
+
* if (prev) setTable(prev);
|
|
18
|
+
* }}
|
|
19
|
+
* });
|
|
20
|
+
* };
|
|
21
|
+
*/
|
|
22
|
+
export declare function useTableUndo<T>(): {
|
|
23
|
+
snapshot: (current: T) => void;
|
|
24
|
+
consume: () => T | null;
|
|
25
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useRef } from "react";
|
|
3
|
+
function useTableUndo() {
|
|
4
|
+
const snapshotRef = useRef(null);
|
|
5
|
+
const snapshot = useCallback((current) => {
|
|
6
|
+
snapshotRef.current = current;
|
|
7
|
+
}, []);
|
|
8
|
+
const consume = useCallback(() => {
|
|
9
|
+
const value = snapshotRef.current;
|
|
10
|
+
snapshotRef.current = null;
|
|
11
|
+
return value;
|
|
12
|
+
}, []);
|
|
13
|
+
return { snapshot, consume };
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
useTableUndo
|
|
17
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function tableActionRowClass(isMobile: boolean): string;
|
|
2
|
+
/**
|
|
3
|
+
* Gives every icon-only button in the row a tooltip from its own name
|
|
4
|
+
* (aria-label, else its label text), and keeps it current as labels flip
|
|
5
|
+
* ("Data" ↔ "Table", "Chart this" ↔ "Hide chart"). A title set by the button
|
|
6
|
+
* itself is never overwritten.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useTableActionTitles<T extends HTMLElement>(): import("react").RefObject<T | null>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
const ICON_ONLY = "[&_button:not([data-keep-label])]:h-7 [&_button:not([data-keep-label])]:min-w-7 [&_button:not([data-keep-label])]:gap-0.5 [&_button:not([data-keep-label])]:px-1.5 [&_button:not([data-keep-label])]:text-[0px] [&_button:not([data-keep-label])]:border-transparent [&_button:not([data-keep-label])]:bg-transparent [&_button:not([data-keep-label])]:shadow-none [&_button:not([data-keep-label])]:text-muted-foreground [&_button:not([data-keep-label]):hover]:bg-accent [&_button:not([data-keep-label]):hover]:text-foreground [&_button[aria-pressed=true]]:text-primary";
|
|
3
|
+
function tableActionRowClass(isMobile) {
|
|
4
|
+
return isMobile ? `mt-1 flex min-w-0 max-w-full flex-wrap items-center justify-start gap-0.5 ${ICON_ONLY}` : `mt-1 flex min-w-0 max-w-full flex-wrap items-center justify-end gap-0.5 ${ICON_ONLY}`;
|
|
5
|
+
}
|
|
6
|
+
function useTableActionTitles() {
|
|
7
|
+
const ref = useRef(null);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const row = ref.current;
|
|
10
|
+
if (!row) return;
|
|
11
|
+
const apply = () => {
|
|
12
|
+
row.querySelectorAll("button").forEach((button) => {
|
|
13
|
+
if (button.title && button.dataset.autoTitle === void 0) return;
|
|
14
|
+
const name = (button.getAttribute("aria-label") || button.textContent || "").replace(/\s+/g, " ").trim();
|
|
15
|
+
if (name && button.title !== name) {
|
|
16
|
+
button.title = name;
|
|
17
|
+
button.dataset.autoTitle = "";
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
apply();
|
|
22
|
+
const observer = new MutationObserver(apply);
|
|
23
|
+
observer.observe(row, { subtree: true, childList: true, characterData: true });
|
|
24
|
+
return () => observer.disconnect();
|
|
25
|
+
}, []);
|
|
26
|
+
return ref;
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
tableActionRowClass,
|
|
30
|
+
useTableActionTitles
|
|
31
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function useTableViewer(): {
|
|
2
|
+
canWrite: boolean;
|
|
3
|
+
};
|
|
4
|
+
/** A header cell's markdown as the plain words a phone-card label shows. */
|
|
5
|
+
export declare function plainHeaderLabel(header: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* The PHONE-STACK attributes for one body cell. The first column is the card's
|
|
8
|
+
* headline (no label); every other cell is labelled with its column.
|
|
9
|
+
*/
|
|
10
|
+
export declare function phoneStackCellProps(headers: readonly string[], colIndex: number): {
|
|
11
|
+
"data-phone"?: "lead";
|
|
12
|
+
"data-label"?: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useIsAuthenticated } from "../../host/app-bindings.js";
|
|
2
|
+
function useTableViewer() {
|
|
3
|
+
const signedIn = Boolean(useIsAuthenticated());
|
|
4
|
+
return { canWrite: signedIn };
|
|
5
|
+
}
|
|
6
|
+
function plainHeaderLabel(header) {
|
|
7
|
+
return header.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/<[^>]+>/g, "").replace(/[*_`~]/g, "").replace(/\s+/g, " ").trim();
|
|
8
|
+
}
|
|
9
|
+
function phoneStackCellProps(headers, colIndex) {
|
|
10
|
+
if (colIndex === 0) return { "data-phone": "lead" };
|
|
11
|
+
const label = plainHeaderLabel(headers[colIndex] ?? "");
|
|
12
|
+
return label ? { "data-label": label } : {};
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
phoneStackCellProps,
|
|
16
|
+
plainHeaderLabel,
|
|
17
|
+
useTableViewer
|
|
18
|
+
};
|