basalt-ui 0.3.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +70 -0
- package/CHANGELOG.md +216 -26
- package/LICENSE +201 -0
- package/README.md +434 -160
- package/agent/rules/basalt-agent.md +395 -0
- package/agent/rules/basalt-charts.md +170 -0
- package/agent/rules/basalt-commands.md +320 -0
- package/agent/rules/basalt-content.md +390 -0
- package/agent/rules/basalt-data.md +237 -0
- package/agent/rules/basalt-forms.md +186 -0
- package/agent/rules/basalt-mantine.md +327 -0
- package/agent/rules/basalt-notifications.md +264 -0
- package/agent/rules/basalt-query.md +130 -0
- package/agent/rules/basalt-router.md +173 -0
- package/agent/rules/basalt-state.md +99 -0
- package/agent/rules/basalt-tokens.md +148 -0
- package/agent/templates/CLAUDE-block.md.tpl +35 -0
- package/agent/templates/DESIGN.md.tpl +71 -0
- package/agent/templates/__root.tpl +31 -0
- package/agent/templates/query-client.ts.tpl +12 -0
- package/bin/basalt.mjs +14 -0
- package/configs/check.yml +29 -0
- package/configs/lefthook.yml +21 -0
- package/configs/oxfmt.json +8 -0
- package/configs/oxlint-plugin.js +269 -0
- package/configs/oxlint-plugin.test.ts +107 -0
- package/configs/oxlint.json +116 -0
- package/configs/tsconfig.base.json +20 -0
- package/configs/tsconfig.node.json +8 -0
- package/configs/tsconfig.react-app.json +8 -0
- package/dist/agent/ai-sdk-transport.d.ts +85 -0
- package/dist/agent/ai-sdk-transport.d.ts.map +1 -0
- package/dist/agent/ai-sdk-transport.js +109 -0
- package/dist/agent/history.d.ts +55 -0
- package/dist/agent/history.d.ts.map +1 -0
- package/dist/agent/history.js +32 -0
- package/dist/agent/index.d.ts +53 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +23 -0
- package/dist/agent/outcome.d.ts +71 -0
- package/dist/agent/outcome.d.ts.map +1 -0
- package/dist/agent/outcome.js +30 -0
- package/dist/agent/part-list.d.ts +75 -0
- package/dist/agent/part-list.d.ts.map +1 -0
- package/dist/agent/part-list.js +127 -0
- package/dist/agent/parts.d.ts +91 -0
- package/dist/agent/parts.d.ts.map +1 -0
- package/dist/agent/parts.js +49 -0
- package/dist/agent/stick-to-bottom.d.ts +23 -0
- package/dist/agent/stick-to-bottom.d.ts.map +1 -0
- package/dist/agent/stick-to-bottom.js +73 -0
- package/dist/agent/thread.d.ts +124 -0
- package/dist/agent/thread.d.ts.map +1 -0
- package/dist/agent/thread.js +131 -0
- package/dist/agent/transport.d.ts +87 -0
- package/dist/agent/transport.d.ts.map +1 -0
- package/dist/agent/transport.js +21 -0
- package/dist/agent/use-agent-stream.d.ts +34 -0
- package/dist/agent/use-agent-stream.d.ts.map +1 -0
- package/dist/agent/use-agent-stream.js +56 -0
- package/dist/agent/use-agent-thread-runs.d.ts +72 -0
- package/dist/agent/use-agent-thread-runs.d.ts.map +1 -0
- package/dist/agent/use-agent-thread-runs.js +217 -0
- package/dist/agent-chat/composer.d.ts +18 -0
- package/dist/agent-chat/composer.d.ts.map +1 -0
- package/dist/agent-chat/composer.js +86 -0
- package/dist/agent-chat/index.d.ts +24 -0
- package/dist/agent-chat/index.d.ts.map +1 -0
- package/dist/agent-chat/index.js +15 -0
- package/dist/agent-chat/thread-detail-panel.d.ts +27 -0
- package/dist/agent-chat/thread-detail-panel.d.ts.map +1 -0
- package/dist/agent-chat/thread-detail-panel.js +108 -0
- package/dist/agent-chat/thread-feed.d.ts +18 -0
- package/dist/agent-chat/thread-feed.d.ts.map +1 -0
- package/dist/agent-chat/thread-feed.js +42 -0
- package/dist/agent-chat/thread-message.d.ts +31 -0
- package/dist/agent-chat/thread-message.d.ts.map +1 -0
- package/dist/agent-chat/thread-message.js +128 -0
- package/dist/agent-chat/thread-outcome-card.d.ts +19 -0
- package/dist/agent-chat/thread-outcome-card.d.ts.map +1 -0
- package/dist/agent-chat/thread-outcome-card.js +120 -0
- package/dist/agent-chat/thread-workspace.d.ts +27 -0
- package/dist/agent-chat/thread-workspace.d.ts.map +1 -0
- package/dist/agent-chat/thread-workspace.js +95 -0
- package/dist/charts/hooks/useChartSize.d.ts +25 -0
- package/dist/charts/hooks/useChartSize.d.ts.map +1 -0
- package/dist/charts/hooks/useChartSize.js +8 -0
- package/dist/charts/hooks/useChartTooltip.d.ts +13 -0
- package/dist/charts/hooks/useChartTooltip.d.ts.map +1 -0
- package/dist/charts/hooks/useChartTooltip.js +26 -0
- package/dist/charts/hooks/useHoverSync.d.ts +30 -0
- package/dist/charts/hooks/useHoverSync.d.ts.map +1 -0
- package/dist/charts/hooks/useHoverSync.js +70 -0
- package/dist/charts/hover-context.d.ts +21 -0
- package/dist/charts/hover-context.d.ts.map +1 -0
- package/dist/charts/hover-context.js +12 -0
- package/dist/charts/hover-sync.d.ts +14 -0
- package/dist/charts/hover-sync.d.ts.map +1 -0
- package/dist/charts/hover-sync.js +17 -0
- package/dist/charts/index.d.ts +47 -0
- package/dist/charts/index.d.ts.map +1 -0
- package/dist/charts/index.js +129 -0
- package/dist/charts/kinds/Bars.d.ts +129 -0
- package/dist/charts/kinds/Bars.d.ts.map +1 -0
- package/dist/charts/kinds/Bars.js +467 -0
- package/dist/charts/kinds/Donut.d.ts +65 -0
- package/dist/charts/kinds/Donut.d.ts.map +1 -0
- package/dist/charts/kinds/Donut.js +158 -0
- package/dist/charts/kinds/DualPanel.d.ts +67 -0
- package/dist/charts/kinds/DualPanel.d.ts.map +1 -0
- package/dist/charts/kinds/DualPanel.js +326 -0
- package/dist/charts/kinds/Heatmap.d.ts +59 -0
- package/dist/charts/kinds/Heatmap.d.ts.map +1 -0
- package/dist/charts/kinds/Heatmap.js +175 -0
- package/dist/charts/kinds/MultiLine.d.ts +73 -0
- package/dist/charts/kinds/MultiLine.d.ts.map +1 -0
- package/dist/charts/kinds/MultiLine.js +275 -0
- package/dist/charts/kinds/StackedArea.d.ts +35 -0
- package/dist/charts/kinds/StackedArea.d.ts.map +1 -0
- package/dist/charts/kinds/StackedArea.js +151 -0
- package/dist/charts/kinds/ZonedLine.d.ts +94 -0
- package/dist/charts/kinds/ZonedLine.d.ts.map +1 -0
- package/dist/charts/kinds/ZonedLine.js +218 -0
- package/dist/charts/primitives/AreaGradient.d.ts +18 -0
- package/dist/charts/primitives/AreaGradient.d.ts.map +1 -0
- package/dist/charts/primitives/AreaGradient.js +13 -0
- package/dist/charts/primitives/Axes.d.ts +22 -0
- package/dist/charts/primitives/Axes.d.ts.map +1 -0
- package/dist/charts/primitives/Axes.js +79 -0
- package/dist/charts/primitives/ChartCard.d.ts +14 -0
- package/dist/charts/primitives/ChartCard.d.ts.map +1 -0
- package/dist/charts/primitives/ChartCard.js +144 -0
- package/dist/charts/primitives/ChartFrame.d.ts +70 -0
- package/dist/charts/primitives/ChartFrame.d.ts.map +1 -0
- package/dist/charts/primitives/ChartFrame.js +77 -0
- package/dist/charts/primitives/ChartLegend.d.ts +36 -0
- package/dist/charts/primitives/ChartLegend.d.ts.map +1 -0
- package/dist/charts/primitives/ChartLegend.js +234 -0
- package/dist/charts/primitives/ChartTooltip.d.ts +34 -0
- package/dist/charts/primitives/ChartTooltip.d.ts.map +1 -0
- package/dist/charts/primitives/ChartTooltip.js +134 -0
- package/dist/charts/primitives/Crosshair.d.ts +23 -0
- package/dist/charts/primitives/Crosshair.d.ts.map +1 -0
- package/dist/charts/primitives/Crosshair.js +21 -0
- package/dist/charts/primitives/HoverOverlay.d.ts +9 -0
- package/dist/charts/primitives/HoverOverlay.d.ts.map +1 -0
- package/dist/charts/primitives/HoverOverlay.js +21 -0
- package/dist/charts/primitives/ResponsiveChart.d.ts +45 -0
- package/dist/charts/primitives/ResponsiveChart.d.ts.map +1 -0
- package/dist/charts/primitives/ResponsiveChart.js +24 -0
- package/dist/charts/primitives/ZoneRects.d.ts +38 -0
- package/dist/charts/primitives/ZoneRects.d.ts.map +1 -0
- package/dist/charts/primitives/ZoneRects.js +30 -0
- package/dist/charts/series.d.ts +99 -0
- package/dist/charts/series.d.ts.map +1 -0
- package/dist/charts/series.js +55 -0
- package/dist/charts/sparklines/BarSparkline.d.ts +13 -0
- package/dist/charts/sparklines/BarSparkline.d.ts.map +1 -0
- package/dist/charts/sparklines/BarSparkline.js +33 -0
- package/dist/charts/sparklines/LineSparkline.d.ts +15 -0
- package/dist/charts/sparklines/LineSparkline.d.ts.map +1 -0
- package/dist/charts/sparklines/LineSparkline.js +39 -0
- package/dist/charts/sparklines/index.d.ts +3 -0
- package/dist/charts/sparklines/index.d.ts.map +1 -0
- package/dist/charts/sparklines/index.js +6 -0
- package/dist/charts/theme.d.ts +21 -0
- package/dist/charts/theme.d.ts.map +1 -0
- package/dist/charts/theme.js +30 -0
- package/dist/charts/utils/domain.d.ts +20 -0
- package/dist/charts/utils/domain.d.ts.map +1 -0
- package/dist/charts/utils/domain.js +7 -0
- package/dist/charts/utils/format.d.ts +5 -0
- package/dist/charts/utils/format.d.ts.map +1 -0
- package/dist/charts/utils/format.js +27 -0
- package/dist/charts/utils/ticks.d.ts +5 -0
- package/dist/charts/utils/ticks.d.ts.map +1 -0
- package/dist/charts/utils/ticks.js +18 -0
- package/dist/cli/index.d.ts +273 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +907 -0
- package/dist/commands/ShortcutsHelp.d.ts +17 -0
- package/dist/commands/ShortcutsHelp.d.ts.map +1 -0
- package/dist/commands/ShortcutsHelp.js +64 -0
- package/dist/commands/define-commands.d.ts +140 -0
- package/dist/commands/define-commands.d.ts.map +1 -0
- package/dist/commands/define-commands.js +26 -0
- package/dist/commands/define-overlays.d.ts +134 -0
- package/dist/commands/define-overlays.d.ts.map +1 -0
- package/dist/commands/define-overlays.js +53 -0
- package/dist/commands/index.d.ts +42 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +46 -0
- package/dist/commands/overlays-mount.d.ts +117 -0
- package/dist/commands/overlays-mount.d.ts.map +1 -0
- package/dist/commands/overlays-mount.js +116 -0
- package/dist/commands/projectors.d.ts +152 -0
- package/dist/commands/projectors.d.ts.map +1 -0
- package/dist/commands/projectors.js +87 -0
- package/dist/commands/shortcut-format.d.ts +48 -0
- package/dist/commands/shortcut-format.d.ts.map +1 -0
- package/dist/commands/shortcut-format.js +33 -0
- package/dist/commands/useCommandHotkeys.d.ts +14 -0
- package/dist/commands/useCommandHotkeys.d.ts.map +1 -0
- package/dist/commands/useCommandHotkeys.js +45 -0
- package/dist/connectivity/connectivity-indicator.d.ts +8 -0
- package/dist/connectivity/connectivity-indicator.d.ts.map +1 -0
- package/dist/connectivity/connectivity-indicator.js +203 -0
- package/dist/connectivity/connectivity-provider.d.ts +7 -0
- package/dist/connectivity/connectivity-provider.d.ts.map +1 -0
- package/dist/connectivity/connectivity-provider.js +125 -0
- package/dist/connectivity/index.d.ts +13 -0
- package/dist/connectivity/index.d.ts.map +1 -0
- package/dist/connectivity/index.js +8 -0
- package/dist/connectivity/types.d.ts +36 -0
- package/dist/connectivity/types.d.ts.map +1 -0
- package/dist/connectivity/types.js +0 -0
- package/dist/connectivity/use-connectivity.d.ts +3 -0
- package/dist/connectivity/use-connectivity.d.ts.map +1 -0
- package/dist/connectivity/use-connectivity.js +14 -0
- package/dist/content/article-actions.d.ts +39 -0
- package/dist/content/article-actions.d.ts.map +1 -0
- package/dist/content/article-actions.js +28 -0
- package/dist/content/article-card.d.ts +58 -0
- package/dist/content/article-card.d.ts.map +1 -0
- package/dist/content/article-card.js +76 -0
- package/dist/content/article-card.module.css +109 -0
- package/dist/content/article-card.module.css.d.ts +16 -0
- package/dist/content/article-filter-bar.d.ts +40 -0
- package/dist/content/article-filter-bar.d.ts.map +1 -0
- package/dist/content/article-filter-bar.js +56 -0
- package/dist/content/article-layout.d.ts +61 -0
- package/dist/content/article-layout.d.ts.map +1 -0
- package/dist/content/article-layout.js +71 -0
- package/dist/content/article-layout.module.css +131 -0
- package/dist/content/article-layout.module.css.d.ts +20 -0
- package/dist/content/article-model.d.ts +62 -0
- package/dist/content/article-model.d.ts.map +1 -0
- package/dist/content/article-model.js +41 -0
- package/dist/content/block-split.d.ts +24 -0
- package/dist/content/block-split.d.ts.map +1 -0
- package/dist/content/block-split.js +63 -0
- package/dist/content/callout-alert.d.ts +27 -0
- package/dist/content/callout-alert.d.ts.map +1 -0
- package/dist/content/callout-alert.js +59 -0
- package/dist/content/callout.d.ts +24 -0
- package/dist/content/callout.d.ts.map +1 -0
- package/dist/content/callout.js +59 -0
- package/dist/content/callout.module.css +77 -0
- package/dist/content/callout.module.css.d.ts +16 -0
- package/dist/content/code-block.d.ts +26 -0
- package/dist/content/code-block.d.ts.map +1 -0
- package/dist/content/code-block.js +41 -0
- package/dist/content/code-block.module.css +86 -0
- package/dist/content/code-block.module.css.d.ts +14 -0
- package/dist/content/copy-action.d.ts +29 -0
- package/dist/content/copy-action.d.ts.map +1 -0
- package/dist/content/copy-action.js +46 -0
- package/dist/content/fence-block.d.ts +19 -0
- package/dist/content/fence-block.d.ts.map +1 -0
- package/dist/content/fence-block.js +23 -0
- package/dist/content/glyphs.d.ts +18 -0
- package/dist/content/glyphs.d.ts.map +1 -0
- package/dist/content/glyphs.js +43 -0
- package/dist/content/guide.d.ts +47 -0
- package/dist/content/guide.d.ts.map +1 -0
- package/dist/content/guide.js +110 -0
- package/dist/content/guide.module.css +62 -0
- package/dist/content/guide.module.css.d.ts +13 -0
- package/dist/content/heading-anchor.d.ts +8 -0
- package/dist/content/heading-anchor.d.ts.map +1 -0
- package/dist/content/heading-anchor.js +23 -0
- package/dist/content/heading-components.d.ts +5 -0
- package/dist/content/heading-components.d.ts.map +1 -0
- package/dist/content/heading-components.js +41 -0
- package/dist/content/highlighter.d.ts +8 -0
- package/dist/content/highlighter.d.ts.map +1 -0
- package/dist/content/highlighter.js +85 -0
- package/dist/content/index.d.ts +45 -0
- package/dist/content/index.d.ts.map +1 -0
- package/dist/content/index.js +43 -0
- package/dist/content/markdown-hast.d.ts +23 -0
- package/dist/content/markdown-hast.d.ts.map +1 -0
- package/dist/content/markdown-hast.js +48 -0
- package/dist/content/markdown.d.ts +68 -0
- package/dist/content/markdown.d.ts.map +1 -0
- package/dist/content/markdown.js +180 -0
- package/dist/content/mdx.d.ts +20 -0
- package/dist/content/mdx.d.ts.map +1 -0
- package/dist/content/mdx.js +64 -0
- package/dist/content/mermaid.d.ts +32 -0
- package/dist/content/mermaid.d.ts.map +1 -0
- package/dist/content/mermaid.js +70 -0
- package/dist/content/mermaid.module.css +20 -0
- package/dist/content/mermaid.module.css.d.ts +8 -0
- package/dist/content/prose.d.ts +29 -0
- package/dist/content/prose.d.ts.map +1 -0
- package/dist/content/prose.js +24 -0
- package/dist/content/prose.module.css +330 -0
- package/dist/content/prose.module.css.d.ts +12 -0
- package/dist/content/reading-progress.d.ts +20 -0
- package/dist/content/reading-progress.d.ts.map +1 -0
- package/dist/content/reading-progress.js +38 -0
- package/dist/content/reading-progress.module.css +22 -0
- package/dist/content/reading-progress.module.css.d.ts +9 -0
- package/dist/content/slug.d.ts +28 -0
- package/dist/content/slug.d.ts.map +1 -0
- package/dist/content/slug.js +28 -0
- package/dist/content/toc.d.ts +37 -0
- package/dist/content/toc.d.ts.map +1 -0
- package/dist/content/toc.js +134 -0
- package/dist/content/toc.module.css +51 -0
- package/dist/content/toc.module.css.d.ts +13 -0
- package/dist/content/url-hardening.d.ts +23 -0
- package/dist/content/url-hardening.d.ts.map +1 -0
- package/dist/content/url-hardening.js +23 -0
- package/dist/dashboard/delta-badge.d.ts +13 -0
- package/dist/dashboard/delta-badge.d.ts.map +1 -0
- package/dist/dashboard/delta-badge.js +45 -0
- package/dist/dashboard/empty-state.d.ts +15 -0
- package/dist/dashboard/empty-state.d.ts.map +1 -0
- package/dist/dashboard/empty-state.js +56 -0
- package/dist/dashboard/index.d.ts +5 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +16 -0
- package/dist/dashboard/settings-section.d.ts +24 -0
- package/dist/dashboard/settings-section.d.ts.map +1 -0
- package/dist/dashboard/settings-section.js +61 -0
- package/dist/dashboard/settings-section.module.css +23 -0
- package/dist/dashboard/settings-section.module.css.d.ts +10 -0
- package/dist/dashboard/stat-card.d.ts +18 -0
- package/dist/dashboard/stat-card.d.ts.map +1 -0
- package/dist/dashboard/stat-card.js +74 -0
- package/dist/data/data-table.d.ts +198 -0
- package/dist/data/data-table.d.ts.map +1 -0
- package/dist/data/data-table.js +342 -0
- package/dist/data/index.d.ts +34 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +2 -0
- package/dist/data/table.d.ts +24 -0
- package/dist/data/table.d.ts.map +1 -0
- package/dist/data/table.js +20 -0
- package/dist/data/virtual-list.d.ts +74 -0
- package/dist/data/virtual-list.d.ts.map +1 -0
- package/dist/data/virtual-list.js +86 -0
- package/dist/data/virtual.d.ts +20 -0
- package/dist/data/virtual.d.ts.map +1 -0
- package/dist/data/virtual.js +4 -0
- package/dist/forms/FormErrorSummary.d.ts +29 -0
- package/dist/forms/FormErrorSummary.d.ts.map +1 -0
- package/dist/forms/FormErrorSummary.js +28 -0
- package/dist/forms/create-form.d.ts +31 -0
- package/dist/forms/create-form.d.ts.map +1 -0
- package/dist/forms/create-form.js +18 -0
- package/dist/forms/field.d.ts +22 -0
- package/dist/forms/field.d.ts.map +1 -0
- package/dist/forms/field.js +9 -0
- package/dist/forms/index.d.ts +17 -0
- package/dist/forms/index.d.ts.map +1 -0
- package/dist/forms/index.js +13 -0
- package/dist/forms/use-form-draft.d.ts +61 -0
- package/dist/forms/use-form-draft.d.ts.map +1 -0
- package/dist/forms/use-form-draft.js +55 -0
- package/dist/guard/guard-hook.d.ts +40 -0
- package/dist/guard/guard-hook.d.ts.map +1 -0
- package/dist/guard/guard-hook.js +55 -0
- package/dist/guard/index.d.ts +144 -0
- package/dist/guard/index.d.ts.map +1 -0
- package/dist/guard/index.js +315 -0
- package/dist/guard/types.d.ts +97 -0
- package/dist/guard/types.d.ts.map +1 -0
- package/dist/guard/types.js +0 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +90 -0
- package/dist/motion/index.d.ts +29 -0
- package/dist/motion/index.d.ts.map +1 -0
- package/dist/motion/index.js +12 -0
- package/dist/notifications/bell.d.ts +12 -0
- package/dist/notifications/bell.d.ts.map +1 -0
- package/dist/notifications/bell.js +84 -0
- package/dist/notifications/center.d.ts +20 -0
- package/dist/notifications/center.d.ts.map +1 -0
- package/dist/notifications/center.js +144 -0
- package/dist/notifications/define-notifications.d.ts +97 -0
- package/dist/notifications/define-notifications.d.ts.map +1 -0
- package/dist/notifications/define-notifications.js +27 -0
- package/dist/notifications/index.d.ts +36 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +52 -0
- package/dist/notifications/notify.d.ts +92 -0
- package/dist/notifications/notify.d.ts.map +1 -0
- package/dist/notifications/notify.js +127 -0
- package/dist/notifications/overlay.d.ts +20 -0
- package/dist/notifications/overlay.d.ts.map +1 -0
- package/dist/notifications/overlay.js +12 -0
- package/dist/notifications/store.d.ts +120 -0
- package/dist/notifications/store.d.ts.map +1 -0
- package/dist/notifications/store.js +113 -0
- package/dist/provider/index.d.ts +93 -0
- package/dist/provider/index.d.ts.map +1 -0
- package/dist/provider/index.js +106 -0
- package/dist/query/devtools.d.ts +21 -0
- package/dist/query/devtools.d.ts.map +1 -0
- package/dist/query/devtools.js +12 -0
- package/dist/query/index.d.ts +65 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +68 -0
- package/dist/register.d.ts +139 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +6 -0
- package/dist/router-tanstack/index.d.ts +74 -0
- package/dist/router-tanstack/index.d.ts.map +1 -0
- package/dist/router-tanstack/index.js +29 -0
- package/dist/router-tanstack/multi-search-param-store.d.ts +78 -0
- package/dist/router-tanstack/multi-search-param-store.d.ts.map +1 -0
- package/dist/router-tanstack/multi-search-param-store.js +35 -0
- package/dist/router-tanstack/search-param-store.d.ts +92 -0
- package/dist/router-tanstack/search-param-store.d.ts.map +1 -0
- package/dist/router-tanstack/search-param-store.js +26 -0
- package/dist/shell/account-types.d.ts +118 -0
- package/dist/shell/account-types.d.ts.map +1 -0
- package/dist/shell/account-types.js +0 -0
- package/dist/shell/app-breadcrumbs.d.ts +17 -0
- package/dist/shell/app-breadcrumbs.d.ts.map +1 -0
- package/dist/shell/app-breadcrumbs.js +39 -0
- package/dist/shell/app-header.module.css +73 -0
- package/dist/shell/app-header.module.css.d.ts +11 -0
- package/dist/shell/app-mobile-nav.d.ts +26 -0
- package/dist/shell/app-mobile-nav.d.ts.map +1 -0
- package/dist/shell/app-mobile-nav.js +106 -0
- package/dist/shell/app-mobile-nav.module.css +100 -0
- package/dist/shell/app-mobile-nav.module.css.d.ts +14 -0
- package/dist/shell/app-sidebar-account.d.ts +3 -0
- package/dist/shell/app-sidebar-account.d.ts.map +1 -0
- package/dist/shell/app-sidebar-account.js +84 -0
- package/dist/shell/app-sidebar.d.ts +56 -0
- package/dist/shell/app-sidebar.d.ts.map +1 -0
- package/dist/shell/app-sidebar.js +455 -0
- package/dist/shell/app-sidebar.module.css +414 -0
- package/dist/shell/app-sidebar.module.css.d.ts +34 -0
- package/dist/shell/index.d.ts +123 -0
- package/dist/shell/index.d.ts.map +1 -0
- package/dist/shell/index.js +179 -0
- package/dist/shell/page-header.d.ts +13 -0
- package/dist/shell/page-header.d.ts.map +1 -0
- package/dist/shell/page-header.js +23 -0
- package/dist/shell/sidebar-search.d.ts +12 -0
- package/dist/shell/sidebar-search.d.ts.map +1 -0
- package/dist/shell/sidebar-search.js +62 -0
- package/dist/shell/sidebar-search.module.css +62 -0
- package/dist/shell/sidebar-search.module.css.d.ts +11 -0
- package/dist/state.d.ts +62 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +124 -0
- package/dist/styles.css +166 -0
- package/dist/surfaces.d.ts +376 -0
- package/dist/surfaces.d.ts.map +1 -0
- package/dist/surfaces.js +306 -0
- package/dist/theme/controls.module.css +143 -0
- package/dist/theme/controls.module.css.d.ts +17 -0
- package/dist/theme/floating.module.css +35 -0
- package/dist/theme/floating.module.css.d.ts +9 -0
- package/dist/theme/index.d.ts +22 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +733 -0
- package/dist/theme/nav-link.module.css +67 -0
- package/dist/theme/nav-link.module.css.d.ts +8 -0
- package/dist/theme/segmented-control.module.css +14 -0
- package/dist/theme/segmented-control.module.css.d.ts +8 -0
- package/dist/theme/timeline.module.css +29 -0
- package/dist/theme/timeline.module.css.d.ts +9 -0
- package/dist/theme-lab/index.d.ts +59 -0
- package/dist/theme-lab/index.d.ts.map +1 -0
- package/dist/theme-lab/index.js +263 -0
- package/dist/theme-toggle/index.d.ts +8 -0
- package/dist/theme-toggle/index.d.ts.map +1 -0
- package/dist/theme-toggle/index.js +155 -0
- package/dist/tokens/index.d.ts +151 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +246 -0
- package/dist/tokens/palette.d.ts +304 -0
- package/dist/tokens/palette.d.ts.map +1 -0
- package/dist/tokens/palette.js +186 -0
- package/dist/vite.d.ts +30 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +68 -0
- package/llms.txt +149 -0
- package/package.json +246 -37
- package/src/agent/ai-sdk-transport.ts +280 -0
- package/src/agent/history.ts +128 -0
- package/src/agent/index.ts +92 -0
- package/src/agent/outcome.ts +120 -0
- package/src/agent/part-list.tsx +292 -0
- package/src/agent/parts.ts +136 -0
- package/src/agent/stick-to-bottom.tsx +154 -0
- package/src/agent/thread.ts +312 -0
- package/src/agent/transport.ts +114 -0
- package/src/agent/use-agent-stream.ts +141 -0
- package/src/agent/use-agent-thread-runs.ts +440 -0
- package/src/agent-chat/composer.tsx +131 -0
- package/src/agent-chat/index.ts +35 -0
- package/src/agent-chat/thread-detail-panel.tsx +192 -0
- package/src/agent-chat/thread-feed.tsx +81 -0
- package/src/agent-chat/thread-message.tsx +251 -0
- package/src/agent-chat/thread-outcome-card.tsx +196 -0
- package/src/agent-chat/thread-workspace.tsx +179 -0
- package/src/charts/hooks/useChartSize.ts +31 -0
- package/src/charts/hooks/useChartTooltip.ts +31 -0
- package/src/charts/hooks/useHoverSync.ts +116 -0
- package/src/charts/hover-context.ts +28 -0
- package/src/charts/hover-sync.tsx +37 -0
- package/src/charts/index.ts +118 -0
- package/src/charts/kinds/Bars.tsx +634 -0
- package/src/charts/kinds/Donut.tsx +233 -0
- package/src/charts/kinds/DualPanel.tsx +432 -0
- package/src/charts/kinds/Heatmap.tsx +255 -0
- package/src/charts/kinds/MultiLine.tsx +376 -0
- package/src/charts/kinds/StackedArea.tsx +218 -0
- package/src/charts/kinds/ZonedLine.tsx +346 -0
- package/src/charts/primitives/AreaGradient.tsx +26 -0
- package/src/charts/primitives/Axes.tsx +97 -0
- package/src/charts/primitives/ChartCard.tsx +180 -0
- package/src/charts/primitives/ChartFrame.tsx +157 -0
- package/src/charts/primitives/ChartLegend.tsx +302 -0
- package/src/charts/primitives/ChartTooltip.tsx +158 -0
- package/src/charts/primitives/Crosshair.tsx +40 -0
- package/src/charts/primitives/HoverOverlay.tsx +24 -0
- package/src/charts/primitives/ResponsiveChart.tsx +64 -0
- package/src/charts/primitives/ZoneRects.tsx +67 -0
- package/src/charts/series.ts +163 -0
- package/src/charts/sparklines/BarSparkline.tsx +48 -0
- package/src/charts/sparklines/LineSparkline.tsx +57 -0
- package/src/charts/sparklines/index.ts +2 -0
- package/src/charts/theme.tsx +53 -0
- package/src/charts/utils/domain.test.ts +24 -0
- package/src/charts/utils/domain.ts +22 -0
- package/src/charts/utils/format.ts +27 -0
- package/src/charts/utils/ticks.ts +18 -0
- package/src/cli/check-theme.test.ts +658 -0
- package/src/cli/index.ts +1497 -0
- package/src/cli/init-sync.test.ts +160 -0
- package/src/commands/ShortcutsHelp.tsx +129 -0
- package/src/commands/define-commands.ts +184 -0
- package/src/commands/define-overlays.ts +197 -0
- package/src/commands/index.ts +86 -0
- package/src/commands/overlays-mount.tsx +301 -0
- package/src/commands/projectors.ts +267 -0
- package/src/commands/shortcut-format.ts +83 -0
- package/src/commands/useCommandHotkeys.ts +114 -0
- package/src/connectivity/connectivity-indicator.tsx +249 -0
- package/src/connectivity/connectivity-provider.tsx +186 -0
- package/src/connectivity/index.ts +18 -0
- package/src/connectivity/types.ts +39 -0
- package/src/connectivity/use-connectivity.ts +25 -0
- package/src/content/article-actions.test.ts +78 -0
- package/src/content/article-actions.ts +72 -0
- package/src/content/article-card.module.css +109 -0
- package/src/content/article-card.module.css.d.ts +16 -0
- package/src/content/article-card.tsx +173 -0
- package/src/content/article-filter-bar.tsx +88 -0
- package/src/content/article-layout.module.css +131 -0
- package/src/content/article-layout.module.css.d.ts +20 -0
- package/src/content/article-layout.tsx +167 -0
- package/src/content/article-model.test.ts +119 -0
- package/src/content/article-model.ts +110 -0
- package/src/content/block-split.test.ts +75 -0
- package/src/content/block-split.ts +102 -0
- package/src/content/callout-alert.ts +88 -0
- package/src/content/callout.module.css +77 -0
- package/src/content/callout.module.css.d.ts +16 -0
- package/src/content/callout.tsx +96 -0
- package/src/content/code-block.module.css +86 -0
- package/src/content/code-block.module.css.d.ts +14 -0
- package/src/content/code-block.tsx +82 -0
- package/src/content/copy-action.tsx +79 -0
- package/src/content/fence-block.tsx +39 -0
- package/src/content/glyphs.tsx +53 -0
- package/src/content/guide.module.css +62 -0
- package/src/content/guide.module.css.d.ts +13 -0
- package/src/content/guide.tsx +174 -0
- package/src/content/heading-anchor.tsx +54 -0
- package/src/content/heading-components.tsx +62 -0
- package/src/content/highlighter.ts +123 -0
- package/src/content/index.ts +60 -0
- package/src/content/markdown-hast.ts +80 -0
- package/src/content/markdown.tsx +346 -0
- package/src/content/mdx.tsx +127 -0
- package/src/content/mermaid.module.css +20 -0
- package/src/content/mermaid.module.css.d.ts +8 -0
- package/src/content/mermaid.tsx +124 -0
- package/src/content/prose.module.css +330 -0
- package/src/content/prose.module.css.d.ts +12 -0
- package/src/content/prose.tsx +53 -0
- package/src/content/reading-progress.module.css +22 -0
- package/src/content/reading-progress.module.css.d.ts +9 -0
- package/src/content/reading-progress.tsx +67 -0
- package/src/content/slug.test.ts +62 -0
- package/src/content/slug.ts +57 -0
- package/src/content/toc.module.css +51 -0
- package/src/content/toc.module.css.d.ts +13 -0
- package/src/content/toc.tsx +226 -0
- package/src/content/url-hardening.ts +46 -0
- package/src/dashboard/delta-badge.tsx +70 -0
- package/src/dashboard/empty-state.tsx +80 -0
- package/src/dashboard/index.ts +11 -0
- package/src/dashboard/settings-section.module.css +23 -0
- package/src/dashboard/settings-section.module.css.d.ts +10 -0
- package/src/dashboard/settings-section.tsx +118 -0
- package/src/dashboard/stat-card.tsx +105 -0
- package/src/data/data-table.tsx +695 -0
- package/src/data/index.ts +37 -0
- package/src/data/table.ts +46 -0
- package/src/data/virtual-list.tsx +180 -0
- package/src/data/virtual.ts +21 -0
- package/src/forms/FormErrorSummary.tsx +64 -0
- package/src/forms/create-form.ts +57 -0
- package/src/forms/field.ts +30 -0
- package/src/forms/index.ts +26 -0
- package/src/forms/use-form-draft.ts +170 -0
- package/src/guard/check-source.test.ts +834 -0
- package/src/guard/guard-hook.test.ts +173 -0
- package/src/guard/guard-hook.ts +122 -0
- package/src/guard/index.ts +510 -0
- package/src/guard/types.ts +117 -0
- package/src/index.ts +139 -0
- package/src/motion/index.ts +26 -0
- package/src/notifications/bell.tsx +108 -0
- package/src/notifications/center.tsx +245 -0
- package/src/notifications/define-notifications.ts +162 -0
- package/src/notifications/index.ts +79 -0
- package/src/notifications/notify.tsx +260 -0
- package/src/notifications/overlay.tsx +64 -0
- package/src/notifications/store.ts +287 -0
- package/src/provider/index.tsx +234 -0
- package/src/query/devtools.tsx +38 -0
- package/src/query/index.ts +129 -0
- package/src/register.ts +158 -0
- package/src/router-tanstack/index.ts +111 -0
- package/src/router-tanstack/multi-search-param-store.test.ts +56 -0
- package/src/router-tanstack/multi-search-param-store.ts +122 -0
- package/src/router-tanstack/search-param-store.ts +125 -0
- package/src/shell/account-types.ts +119 -0
- package/src/shell/app-breadcrumbs.tsx +90 -0
- package/src/shell/app-header.module.css +73 -0
- package/src/shell/app-header.module.css.d.ts +11 -0
- package/src/shell/app-mobile-nav.module.css +100 -0
- package/src/shell/app-mobile-nav.module.css.d.ts +14 -0
- package/src/shell/app-mobile-nav.tsx +146 -0
- package/src/shell/app-sidebar-account.tsx +142 -0
- package/src/shell/app-sidebar.module.css +414 -0
- package/src/shell/app-sidebar.module.css.d.ts +34 -0
- package/src/shell/app-sidebar.tsx +632 -0
- package/src/shell/index.tsx +343 -0
- package/src/shell/page-header.tsx +35 -0
- package/src/shell/sidebar-search.module.css +62 -0
- package/src/shell/sidebar-search.module.css.d.ts +11 -0
- package/src/shell/sidebar-search.tsx +80 -0
- package/src/state.ts +246 -0
- package/src/styles.css +166 -0
- package/src/styles.floor.test.ts +36 -0
- package/src/surfaces.ts +489 -0
- package/src/theme/border-coverage.test.ts +272 -0
- package/src/theme/contrast.test.ts +306 -0
- package/src/theme/controls.module.css +143 -0
- package/src/theme/controls.module.css.d.ts +17 -0
- package/src/theme/floating.module.css +35 -0
- package/src/theme/floating.module.css.d.ts +9 -0
- package/src/theme/index.ts +933 -0
- package/src/theme/nav-link.module.css +67 -0
- package/src/theme/nav-link.module.css.d.ts +8 -0
- package/src/theme/segmented-control.module.css +14 -0
- package/src/theme/segmented-control.module.css.d.ts +8 -0
- package/src/theme/shadow-surfaces.test.ts +421 -0
- package/src/theme/timeline.module.css +29 -0
- package/src/theme/timeline.module.css.d.ts +9 -0
- package/src/theme-lab/index.tsx +359 -0
- package/src/theme-lab/theme-lab.test.ts +60 -0
- package/src/theme-toggle/index.tsx +180 -0
- package/src/tokens/index.ts +363 -0
- package/src/tokens/palette.ts +288 -0
- package/src/vite.ts +122 -0
- package/src/index.css +0 -986
- package/src/starlight.css +0 -308
- package/tailwind.config.js +0 -78
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ThreadOutcomeCard — one inbox-row projection of an `AgentThread` for a multi-thread feed.
|
|
3
|
+
*
|
|
4
|
+
* Never renders the raw transcript or the live streaming text — only the distilled `AgentOutcome`
|
|
5
|
+
* (title + summary), a relative timestamp, and a status badge. While a thread has no outcome yet
|
|
6
|
+
* and is still `pending`/`streaming`, it renders a skeleton preview instead of any prompt/partial
|
|
7
|
+
* text, so a feed never leaks in-progress content.
|
|
8
|
+
*
|
|
9
|
+
* Presentational only — the enclosing `ThreadFeed` owns the enter/exit + reorder animation, so
|
|
10
|
+
* this row stays a plain button with no motion wrapper of its own.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { ThreadOutcomeCard } from 'basalt-ui'
|
|
14
|
+
*
|
|
15
|
+
* <ThreadOutcomeCard
|
|
16
|
+
* thread={thread}
|
|
17
|
+
* selected={thread.id === activeId}
|
|
18
|
+
* onSelect={() => select(thread.id)}
|
|
19
|
+
* />
|
|
20
|
+
*/
|
|
21
|
+
import { Badge, Group, Skeleton, Stack, Text, UnstyledButton } from '@mantine/core'
|
|
22
|
+
import { useHover } from '@mantine/hooks'
|
|
23
|
+
import type { JSX } from 'react'
|
|
24
|
+
import type { AgentThread, ThreadStatus } from '../agent'
|
|
25
|
+
import { alpha, VX } from '../tokens'
|
|
26
|
+
|
|
27
|
+
// ── Status badge — shown ONLY for states that need a glance (attention/error). ────
|
|
28
|
+
// done/pending/streaming stay badge-free: a settled feed shouldn't be a wall of green chips —
|
|
29
|
+
// read/unread title weight + the timestamp already carry the rest.
|
|
30
|
+
|
|
31
|
+
const STATUS_BADGE: Partial<
|
|
32
|
+
Record<ThreadStatus, { readonly label: string; readonly statusToken: string }>
|
|
33
|
+
> = {
|
|
34
|
+
attention: { label: 'Needs review', statusToken: VX.status.warn },
|
|
35
|
+
error: { label: 'Failed', statusToken: VX.status.bad },
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ── Dependency-free relative-time helper (no date-fns) ────────────────────────
|
|
39
|
+
|
|
40
|
+
const RELATIVE_TIME_FORMAT = new Intl.RelativeTimeFormat('en', { numeric: 'auto' })
|
|
41
|
+
|
|
42
|
+
const RELATIVE_TIME_UNITS: readonly {
|
|
43
|
+
readonly unit: Intl.RelativeTimeFormatUnit
|
|
44
|
+
readonly ms: number
|
|
45
|
+
}[] = [
|
|
46
|
+
{ unit: 'year', ms: 31_536_000_000 },
|
|
47
|
+
{ unit: 'month', ms: 2_628_000_000 },
|
|
48
|
+
{ unit: 'week', ms: 604_800_000 },
|
|
49
|
+
{ unit: 'day', ms: 86_400_000 },
|
|
50
|
+
{ unit: 'hour', ms: 3_600_000 },
|
|
51
|
+
{ unit: 'minute', ms: 60_000 },
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
/** Formats an epoch-ms timestamp as a short relative string ("3 hours ago", "just now"). */
|
|
55
|
+
function formatRelativeTime(timestamp: number): string {
|
|
56
|
+
const diffMs = timestamp - Date.now()
|
|
57
|
+
const absMs = Math.abs(diffMs)
|
|
58
|
+
if (absMs < 60_000) return 'just now'
|
|
59
|
+
const unit = RELATIVE_TIME_UNITS.find(({ ms }) => absMs >= ms) ?? RELATIVE_TIME_UNITS.at(-1)!
|
|
60
|
+
return RELATIVE_TIME_FORMAT.format(Math.round(diffMs / unit.ms), unit.unit)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ── Row bodies ─────────────────────────────────────────────────────────────────
|
|
64
|
+
|
|
65
|
+
/** Preview skeleton shown while a thread has no resolved outcome yet (never raw prompt/live text). */
|
|
66
|
+
function OutcomeSkeleton(): JSX.Element {
|
|
67
|
+
return (
|
|
68
|
+
<Stack gap={6}>
|
|
69
|
+
<Skeleton height={14} width="60%" radius="sm" />
|
|
70
|
+
<Skeleton height={11} width="90%" radius="sm" />
|
|
71
|
+
</Stack>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The thread's opening user prompt — the fallback title for a thread with no resolved outcome. */
|
|
76
|
+
function promptOf(thread: AgentThread): string | undefined {
|
|
77
|
+
const firstUser = thread.messages.find((message) => message.role === 'user')
|
|
78
|
+
if (firstUser === undefined) return undefined
|
|
79
|
+
const text = firstUser.parts
|
|
80
|
+
.map((part) => (part.type === 'text' ? part.text : ''))
|
|
81
|
+
.join('')
|
|
82
|
+
.trim()
|
|
83
|
+
return text.length > 0 ? text : undefined
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function OutcomeBody({ thread }: { thread: AgentThread }): JSX.Element {
|
|
87
|
+
const badge = STATUS_BADGE[thread.status]
|
|
88
|
+
const title = thread.outcome?.title ?? promptOf(thread) ?? 'Untitled'
|
|
89
|
+
const summary =
|
|
90
|
+
thread.outcome?.summary ?? (thread.status === 'error' ? 'This run didn’t finish.' : '')
|
|
91
|
+
return (
|
|
92
|
+
<Stack gap={4}>
|
|
93
|
+
<Group justify="space-between" gap="xs" wrap="nowrap" align="flex-start">
|
|
94
|
+
<Text
|
|
95
|
+
fw={550}
|
|
96
|
+
{...(thread.read ? { c: 'dimmed' } : {})}
|
|
97
|
+
lineClamp={1}
|
|
98
|
+
style={{
|
|
99
|
+
flex: 1,
|
|
100
|
+
fontFamily: 'var(--basalt-font-head)',
|
|
101
|
+
fontSize: VX.text.md,
|
|
102
|
+
fontStretch: '88%',
|
|
103
|
+
}}
|
|
104
|
+
>
|
|
105
|
+
{title}
|
|
106
|
+
</Text>
|
|
107
|
+
{badge !== undefined && (
|
|
108
|
+
<Badge
|
|
109
|
+
size="xs"
|
|
110
|
+
radius={6}
|
|
111
|
+
styles={{
|
|
112
|
+
root: {
|
|
113
|
+
backgroundColor: alpha(badge.statusToken, 0.13),
|
|
114
|
+
padding: '2px 7px',
|
|
115
|
+
height: 'auto',
|
|
116
|
+
},
|
|
117
|
+
label: {
|
|
118
|
+
fontFamily: 'var(--basalt-font-mono)',
|
|
119
|
+
fontSize: VX.text.xs,
|
|
120
|
+
fontWeight: 600,
|
|
121
|
+
textTransform: 'none',
|
|
122
|
+
letterSpacing: 'normal',
|
|
123
|
+
color: badge.statusToken,
|
|
124
|
+
},
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
{badge.label}
|
|
128
|
+
</Badge>
|
|
129
|
+
)}
|
|
130
|
+
</Group>
|
|
131
|
+
<Text size="xs" c="dimmed" lineClamp={1}>
|
|
132
|
+
{summary}
|
|
133
|
+
</Text>
|
|
134
|
+
<Text
|
|
135
|
+
style={{ fontFamily: 'var(--basalt-font-mono)', fontSize: VX.text.micro, color: VX.faint }}
|
|
136
|
+
>
|
|
137
|
+
{formatRelativeTime(thread.updatedAt)}
|
|
138
|
+
</Text>
|
|
139
|
+
</Stack>
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// ── ThreadOutcomeCard ─────────────────────────────────────────────────────────
|
|
144
|
+
|
|
145
|
+
export type ThreadOutcomeCardProps = {
|
|
146
|
+
readonly thread: AgentThread
|
|
147
|
+
/** Whether this row is the active/open thread — applies a subtle highlight. */
|
|
148
|
+
readonly selected: boolean
|
|
149
|
+
/** Called when the row is clicked/activated. */
|
|
150
|
+
readonly onSelect: () => void
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* One inbox row: title + summary + relative timestamp + status badge, or a skeleton preview
|
|
155
|
+
* while the outcome hasn't resolved. Shared-element `layoutId` (thread.id) drives the FLIP into
|
|
156
|
+
* `ThreadDetailPanel`'s header when reduced motion is not requested.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* <ThreadOutcomeCard thread={thread} selected={false} onSelect={() => select(thread.id)} />
|
|
160
|
+
*/
|
|
161
|
+
export function ThreadOutcomeCard({
|
|
162
|
+
thread,
|
|
163
|
+
selected,
|
|
164
|
+
onSelect,
|
|
165
|
+
}: ThreadOutcomeCardProps): JSX.Element {
|
|
166
|
+
const { hovered, ref } = useHover<HTMLButtonElement>()
|
|
167
|
+
const isPreviewing =
|
|
168
|
+
thread.outcome === null && (thread.status === 'pending' || thread.status === 'streaming')
|
|
169
|
+
|
|
170
|
+
// Card idiom (docs/DESIGN-SPEC.md §5): panel + shadow-card, radius 7 (VX.radiusCard), xs/sm
|
|
171
|
+
// inset — each outcome row reads as its own card lifted off the feed pane, not a flat
|
|
172
|
+
// highlighted list row.
|
|
173
|
+
const background = selected
|
|
174
|
+
? VX.surface.elevated
|
|
175
|
+
: hovered
|
|
176
|
+
? VX.surface.panelHover
|
|
177
|
+
: VX.surface.panel
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<UnstyledButton
|
|
181
|
+
ref={ref}
|
|
182
|
+
onClick={onSelect}
|
|
183
|
+
w="100%"
|
|
184
|
+
style={{
|
|
185
|
+
display: 'block',
|
|
186
|
+
padding: 'var(--mantine-spacing-xs) var(--mantine-spacing-sm)',
|
|
187
|
+
borderRadius: VX.radiusCard,
|
|
188
|
+
boxShadow: VX.shadowCard,
|
|
189
|
+
backgroundColor: background,
|
|
190
|
+
transition: 'background-color 120ms ease',
|
|
191
|
+
}}
|
|
192
|
+
>
|
|
193
|
+
{isPreviewing ? <OutcomeSkeleton /> : <OutcomeBody thread={thread} />}
|
|
194
|
+
</UnstyledButton>
|
|
195
|
+
)
|
|
196
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ThreadWorkspace — the flagship, ready-to-use two-pane thread-chat composite.
|
|
3
|
+
*
|
|
4
|
+
* Composes `ThreadFeed` + a new-thread `Composer` (left/main pane) with `ThreadDetailPanel`
|
|
5
|
+
* (right pane) over `useAgentThreadRuns`, so a consumer wires one component instead of hand-
|
|
6
|
+
* assembling the pieces. Responsive: wide viewports show both panes side by side; narrow
|
|
7
|
+
* viewports (`<= 768px`) show exactly one — the feed when no thread is open, a full-screen
|
|
8
|
+
* detail panel once one is.
|
|
9
|
+
*
|
|
10
|
+
* `useThreads` is a prop, not called internally, because `createThreadsStore` must be invoked
|
|
11
|
+
* ONCE at module scope (see the doctrine on `createThreadsStore` in `../agent`) — the consumer
|
|
12
|
+
* owns that module-scope call and passes the resulting hook in here.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { ThreadWorkspace } from 'basalt-ui'
|
|
16
|
+
* import { createThreadsStore, edenTransport, heuristicOutcome } from 'basalt-ui/agent'
|
|
17
|
+
*
|
|
18
|
+
* // Module scope — called ONCE:
|
|
19
|
+
* const useThreads = createThreadsStore({ key: 'main-threads', version: 1 })
|
|
20
|
+
* const transport = edenTransport((input, signal) =>
|
|
21
|
+
* api.chat.post({ body: { message: input }, fetch: { signal } }),
|
|
22
|
+
* )
|
|
23
|
+
*
|
|
24
|
+
* function Inbox() {
|
|
25
|
+
* return (
|
|
26
|
+
* <ThreadWorkspace
|
|
27
|
+
* useThreads={useThreads}
|
|
28
|
+
* transport={transport}
|
|
29
|
+
* resolveOutcome={heuristicOutcome}
|
|
30
|
+
* newThreadPlaceholder="Start a new conversation…"
|
|
31
|
+
* />
|
|
32
|
+
* )
|
|
33
|
+
* }
|
|
34
|
+
*/
|
|
35
|
+
import { Box, Divider, Flex, Stack, Text } from '@mantine/core'
|
|
36
|
+
import { useMediaQuery } from '@mantine/hooks'
|
|
37
|
+
import type { JSX, ReactNode } from 'react'
|
|
38
|
+
import type { AgentPart, AgentTransport, OutcomeResolver, ThreadsStore } from '../agent'
|
|
39
|
+
import { useAgentThreadRuns } from '../agent'
|
|
40
|
+
import { Composer } from './composer'
|
|
41
|
+
import { ThreadDetailPanel } from './thread-detail-panel'
|
|
42
|
+
import { ThreadFeed } from './thread-feed'
|
|
43
|
+
|
|
44
|
+
const NARROW_BREAKPOINT = '(max-width: 768px)'
|
|
45
|
+
const DETAIL_PANEL_WIDTH = 'clamp(440px, 40%, 520px)'
|
|
46
|
+
|
|
47
|
+
export type ThreadWorkspaceProps = {
|
|
48
|
+
/**
|
|
49
|
+
* The thread-store hook, created ONCE at module scope via `createThreadsStore` and passed in —
|
|
50
|
+
* ThreadWorkspace must not call `createThreadsStore` itself.
|
|
51
|
+
*/
|
|
52
|
+
readonly useThreads: () => ThreadsStore
|
|
53
|
+
/** The injected transport seam — one stream per `start()` call. */
|
|
54
|
+
readonly transport: AgentTransport<AgentPart, string>
|
|
55
|
+
/** Distills a finished thread into a feed-ready `AgentOutcome`. */
|
|
56
|
+
readonly resolveOutcome: OutcomeResolver<AgentPart>
|
|
57
|
+
/** Placeholder for the new-thread composer pinned under the feed. */
|
|
58
|
+
readonly newThreadPlaceholder?: string
|
|
59
|
+
/** Rendered in place of the feed while there are no threads yet. */
|
|
60
|
+
readonly emptyState?: ReactNode
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Default hint shown in the feed pane before any thread exists (overridable via `emptyState`). */
|
|
64
|
+
function FeedEmptyState(): JSX.Element {
|
|
65
|
+
return (
|
|
66
|
+
<Stack align="center" justify="center" gap={4} h="100%" p="xl">
|
|
67
|
+
<Text fw={600} size="sm">
|
|
68
|
+
No threads yet
|
|
69
|
+
</Text>
|
|
70
|
+
<Text size="xs" c="dimmed" ta="center">
|
|
71
|
+
Send a message below to start your first thread.
|
|
72
|
+
</Text>
|
|
73
|
+
</Stack>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* A two-pane master-detail thread workspace: a scrollable feed of threads with an anchored
|
|
79
|
+
* new-thread composer, and a detail panel for the open thread's live transcript. Collapses to a
|
|
80
|
+
* single pane below 768px.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* <ThreadWorkspace useThreads={useThreads} transport={transport} resolveOutcome={heuristicOutcome} />
|
|
84
|
+
*/
|
|
85
|
+
export function ThreadWorkspace({
|
|
86
|
+
useThreads,
|
|
87
|
+
transport,
|
|
88
|
+
resolveOutcome,
|
|
89
|
+
newThreadPlaceholder,
|
|
90
|
+
emptyState,
|
|
91
|
+
}: ThreadWorkspaceProps): JSX.Element {
|
|
92
|
+
const store = useThreads()
|
|
93
|
+
const runs = useAgentThreadRuns({ transport, store, resolveOutcome })
|
|
94
|
+
const narrow = useMediaQuery(NARROW_BREAKPOINT)
|
|
95
|
+
|
|
96
|
+
const threads = store.threads
|
|
97
|
+
const activeThread = threads.find((thread) => thread.id === store.activeId) ?? null
|
|
98
|
+
const activeRun = store.activeId !== null ? runs.runs.get(store.activeId) : undefined
|
|
99
|
+
const liveParts = activeRun?.parts
|
|
100
|
+
|
|
101
|
+
const handleSelect = (id: string): void => {
|
|
102
|
+
store.select(id)
|
|
103
|
+
store.markRead(id)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const handleNewThread = (text: string): void => {
|
|
107
|
+
const id = store.create()
|
|
108
|
+
store.select(id)
|
|
109
|
+
store.markRead(id)
|
|
110
|
+
runs.start(id, text)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const handleSend = (text: string): void => {
|
|
114
|
+
if (store.activeId === null) return
|
|
115
|
+
runs.start(store.activeId, text)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const handleStop = (): void => {
|
|
119
|
+
if (store.activeId === null) return
|
|
120
|
+
runs.stop(store.activeId)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const handleRetry = (): void => {
|
|
124
|
+
if (store.activeId === null) return
|
|
125
|
+
runs.retry(store.activeId)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// A plain pane, NOT a card — the feed's own rows carry the card idiom (docs/DESIGN-SPEC.md §5),
|
|
129
|
+
// so this pane stays flush with the page and the feed/detail split reads via the divider token.
|
|
130
|
+
const feed = (
|
|
131
|
+
<Box style={{ display: 'flex', flexDirection: 'column', height: '100%', overflow: 'hidden' }}>
|
|
132
|
+
<Box style={{ flex: 1, minHeight: 0 }}>
|
|
133
|
+
{store.threads.length === 0 ? (
|
|
134
|
+
(emptyState ?? <FeedEmptyState />)
|
|
135
|
+
) : (
|
|
136
|
+
<ThreadFeed threads={threads} activeId={store.activeId} onSelect={handleSelect} />
|
|
137
|
+
)}
|
|
138
|
+
</Box>
|
|
139
|
+
<Divider color="var(--vx-divider)" />
|
|
140
|
+
<Box p="sm">
|
|
141
|
+
<Composer
|
|
142
|
+
onSubmit={handleNewThread}
|
|
143
|
+
{...(newThreadPlaceholder !== undefined ? { placeholder: newThreadPlaceholder } : {})}
|
|
144
|
+
/>
|
|
145
|
+
</Box>
|
|
146
|
+
</Box>
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
const detail = (
|
|
150
|
+
<ThreadDetailPanel
|
|
151
|
+
thread={activeThread}
|
|
152
|
+
{...(liveParts !== undefined ? { liveParts } : {})}
|
|
153
|
+
{...(activeRun !== undefined ? { runStatus: activeRun.status } : {})}
|
|
154
|
+
onSend={handleSend}
|
|
155
|
+
onStop={handleStop}
|
|
156
|
+
onRetry={handleRetry}
|
|
157
|
+
onClose={() => store.select(null)}
|
|
158
|
+
/>
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
if (narrow) {
|
|
162
|
+
return <Box style={{ height: '100%' }}>{store.activeId !== null ? detail : feed}</Box>
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<Flex style={{ height: '100%' }} gap="md">
|
|
167
|
+
<Box
|
|
168
|
+
style={{
|
|
169
|
+
flex: 1,
|
|
170
|
+
minWidth: 0,
|
|
171
|
+
borderRight: '1px solid var(--vx-divider)',
|
|
172
|
+
}}
|
|
173
|
+
>
|
|
174
|
+
{feed}
|
|
175
|
+
</Box>
|
|
176
|
+
<Box style={{ width: DETAIL_PANEL_WIDTH, flexShrink: 0 }}>{detail}</Box>
|
|
177
|
+
</Flex>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useParentSize } from '@visx/responsive'
|
|
2
|
+
|
|
3
|
+
export type ChartSize = {
|
|
4
|
+
width: number
|
|
5
|
+
height: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type UseChartSizeResult = ChartSize & {
|
|
9
|
+
/** Attach to the container element to measure its dimensions. */
|
|
10
|
+
ref: (node: HTMLDivElement | null) => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Measures the width and height of a container element via a ResizeObserver.
|
|
15
|
+
* A thin basalt wrapper over `@visx/responsive`'s `useParentSize` — keeps the
|
|
16
|
+
* `@visx/*` import inside `src/charts/**` per the Mantine-free boundary rule.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* function MyChart() {
|
|
20
|
+
* const { ref, width, height } = useChartSize()
|
|
21
|
+
* return (
|
|
22
|
+
* <div ref={ref} style={{ width: '100%', height: 240 }}>
|
|
23
|
+
* {width > 0 && <Bars width={width} height={height} ... />}
|
|
24
|
+
* </div>
|
|
25
|
+
* )
|
|
26
|
+
* }
|
|
27
|
+
*/
|
|
28
|
+
export function useChartSize(debounceMs = 0): UseChartSizeResult {
|
|
29
|
+
const { parentRef, width, height } = useParentSize({ debounceTime: debounceMs })
|
|
30
|
+
return { ref: parentRef, width, height }
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
export type TooltipState<T> = { data: T; x: number; y: number } | null
|
|
4
|
+
|
|
5
|
+
export function useChartTooltip<T>() {
|
|
6
|
+
const [tip, setTip] = useState<TooltipState<T>>(null)
|
|
7
|
+
const tooltipRef = useRef<HTMLDivElement>(null)
|
|
8
|
+
const lastDateRef = useRef<string | null>(null)
|
|
9
|
+
|
|
10
|
+
const show = useCallback((data: T, event: React.MouseEvent) => {
|
|
11
|
+
const el = tooltipRef.current
|
|
12
|
+
const width = el?.offsetWidth ?? 0
|
|
13
|
+
const height = el?.offsetHeight ?? 0
|
|
14
|
+
const margin = 8
|
|
15
|
+
const vw = window.innerWidth
|
|
16
|
+
const vh = window.innerHeight
|
|
17
|
+
const overflowsRight = event.clientX + 12 + width + margin > vw
|
|
18
|
+
const x = overflowsRight ? Math.max(margin, event.clientX - 12 - width) : event.clientX + 12
|
|
19
|
+
const y = Math.min(Math.max(margin, event.clientY - 12), vh - height - margin)
|
|
20
|
+
// State-driven positioning: the tooltip element reads x/y from `tip`. (A prior direct
|
|
21
|
+
// el.style.left/top write here was dead — the React render overwrote it the same frame.)
|
|
22
|
+
setTip({ data, x, y })
|
|
23
|
+
}, [])
|
|
24
|
+
|
|
25
|
+
const hide = useCallback(() => {
|
|
26
|
+
setTip(null)
|
|
27
|
+
lastDateRef.current = null
|
|
28
|
+
}, [])
|
|
29
|
+
|
|
30
|
+
return { tip, show, hide, tooltipRef, lastDateRef }
|
|
31
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { localPoint } from '@visx/event'
|
|
2
|
+
import { useCallback, useContext, useMemo, useRef } from 'react'
|
|
3
|
+
import { DEFAULT_NO_OP_SET_HOVER, HoverContext } from '../hover-context'
|
|
4
|
+
import { useChartTooltip } from './useChartTooltip'
|
|
5
|
+
|
|
6
|
+
type XScale = (x: string) => number | undefined
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Wires a chart into the shared-cursor HoverContext plus the local tooltip state.
|
|
10
|
+
*
|
|
11
|
+
* Returns everything a chart needs to:
|
|
12
|
+
* - snap mouse position to the nearest data point (by x-category)
|
|
13
|
+
* - broadcast that hover to other charts via HoverContext
|
|
14
|
+
* - read back hover from other charts (for ghost crosshair + dot)
|
|
15
|
+
* - drive its local tooltip
|
|
16
|
+
*
|
|
17
|
+
* Every non-sparkline chart kind MUST use this hook. Do not reimplement the
|
|
18
|
+
* closest-point loop inline — drift across 15+ charts is the exact problem
|
|
19
|
+
* this hook prevents.
|
|
20
|
+
*/
|
|
21
|
+
export function useHoverSync<T>({
|
|
22
|
+
data,
|
|
23
|
+
chartId,
|
|
24
|
+
getKey,
|
|
25
|
+
xScale,
|
|
26
|
+
marginLeft,
|
|
27
|
+
}: {
|
|
28
|
+
data: T[]
|
|
29
|
+
chartId: string
|
|
30
|
+
getKey: (d: T) => string
|
|
31
|
+
xScale: XScale
|
|
32
|
+
marginLeft: number
|
|
33
|
+
}) {
|
|
34
|
+
const ctx = useContext(HoverContext)
|
|
35
|
+
// Latest context in a ref so the mouse callbacks stay referentially stable: the provider's value
|
|
36
|
+
// is a NEW object on every hover broadcast, and depending on `ctx` would re-create both callbacks
|
|
37
|
+
// (and re-bind HoverOverlay's listeners) in every sibling chart on every cursor move.
|
|
38
|
+
const ctxRef = useRef(ctx)
|
|
39
|
+
ctxRef.current = ctx
|
|
40
|
+
const warnedRef = useRef(false)
|
|
41
|
+
|
|
42
|
+
if (
|
|
43
|
+
process.env['NODE_ENV'] !== 'production' &&
|
|
44
|
+
ctx.setHover === DEFAULT_NO_OP_SET_HOVER &&
|
|
45
|
+
!warnedRef.current
|
|
46
|
+
) {
|
|
47
|
+
warnedRef.current = true
|
|
48
|
+
// eslint-disable-next-line no-console
|
|
49
|
+
console.warn(
|
|
50
|
+
'[charts] useHoverSync used outside <HoverContext.Provider>. Cross-chart cursor sync will not work.',
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const { tip, show, hide, tooltipRef, lastDateRef } = useChartTooltip<T>()
|
|
55
|
+
|
|
56
|
+
// O(1) lookup of a point by its key. Under a provider every sibling resolves the broadcast
|
|
57
|
+
// key each frame; an O(n) `data.find` per sibling per move is N×O(M). This makes it N×O(1).
|
|
58
|
+
const pointByKey = useMemo(() => {
|
|
59
|
+
const m = new Map<string, T>()
|
|
60
|
+
for (const d of data) m.set(getKey(d), d)
|
|
61
|
+
return m
|
|
62
|
+
}, [data, getKey])
|
|
63
|
+
|
|
64
|
+
const handleMouse = useCallback(
|
|
65
|
+
(event: React.MouseEvent<SVGRectElement>) => {
|
|
66
|
+
const point = localPoint(event)
|
|
67
|
+
if (!point || data.length === 0) return
|
|
68
|
+
const px = point.x - marginLeft
|
|
69
|
+
let closest: T = data[0] as T
|
|
70
|
+
let minDist = Infinity
|
|
71
|
+
for (const d of data) {
|
|
72
|
+
const sx = xScale(getKey(d)) ?? 0
|
|
73
|
+
const dist = Math.abs(sx - px)
|
|
74
|
+
if (dist < minDist) {
|
|
75
|
+
minDist = dist
|
|
76
|
+
closest = d
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
show(closest, event)
|
|
80
|
+
const key = getKey(closest)
|
|
81
|
+
if (lastDateRef.current !== key) {
|
|
82
|
+
lastDateRef.current = key
|
|
83
|
+
ctxRef.current.setHover(key, chartId)
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
[data, xScale, getKey, chartId, marginLeft, show, lastDateRef],
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
const handleLeave = useCallback(() => {
|
|
90
|
+
hide()
|
|
91
|
+
// Only clear the SHARED hover if this chart currently owns it. When the cursor moves quickly from
|
|
92
|
+
// chart A to chart B, A's `mouseleave` can fire AFTER B's `mousemove` has already claimed the
|
|
93
|
+
// hover — an unconditional clear would then wipe B's cursor and flicker every sibling crosshair.
|
|
94
|
+
if (ctxRef.current.source === chartId) ctxRef.current.setHover(null, null)
|
|
95
|
+
}, [hide, chartId])
|
|
96
|
+
|
|
97
|
+
// The point the crosshair + synced dots track. Inside a <ChartHoverSync> this follows the
|
|
98
|
+
// broadcast key (so every sibling paints a ghost crosshair at the same x). WITHOUT a provider the
|
|
99
|
+
// chart is standalone, so it falls back to THIS chart's own hovered point (`tip.data`) — otherwise
|
|
100
|
+
// a chart outside a provider would never draw a crosshair/dots at all.
|
|
101
|
+
const syncedPoint = ctx.key ? (pointByKey.get(ctx.key) ?? null) : (tip?.data ?? null)
|
|
102
|
+
// Which chart owns the floating tooltip. Inside a provider the hovered chart is the one whose id
|
|
103
|
+
// matches the broadcast source (siblings show a ghost crosshair only). Standalone, its own local
|
|
104
|
+
// hover (`tip`) drives the tooltip.
|
|
105
|
+
const hasProvider = ctx.setHover !== DEFAULT_NO_OP_SET_HOVER
|
|
106
|
+
const isDirectHover = hasProvider ? ctx.source === chartId : tip !== null
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
tip,
|
|
110
|
+
tooltipRef,
|
|
111
|
+
syncedPoint,
|
|
112
|
+
isDirectHover,
|
|
113
|
+
handleMouse,
|
|
114
|
+
handleLeave,
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createContext } from 'react'
|
|
2
|
+
|
|
3
|
+
export type HoverCtx = {
|
|
4
|
+
key: string | null
|
|
5
|
+
source: string | null
|
|
6
|
+
setHover: (key: string | null, source: string | null) => void
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Sentinel identity used as the default context's `setHover`. `useHoverSync` compares against it
|
|
11
|
+
* (`ctx.setHover !== DEFAULT_NO_OP_SET_HOVER`) to decide whether a `ChartHoverSync` provider is
|
|
12
|
+
* mounted — which is load-bearing, not just a dev warning: standalone charts (no provider) drive
|
|
13
|
+
* their tooltip + crosshair from local hover, while inside a provider only the broadcast source
|
|
14
|
+
* owns the tooltip. CONTRACT: a real provider MUST supply its own `setHover`, never re-use this
|
|
15
|
+
* no-op (a provider that passes this sentinel would be (mis)read as "no provider").
|
|
16
|
+
* Exported only for that identity check — do NOT call directly.
|
|
17
|
+
*/
|
|
18
|
+
export const DEFAULT_NO_OP_SET_HOVER: HoverCtx['setHover'] = () => {}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Shared-cursor context — charts write the hovered key (an opaque category/date string) + their
|
|
22
|
+
* own chartId; other charts read and show a ghost crosshair + dot on the same key.
|
|
23
|
+
*/
|
|
24
|
+
export const HoverContext = createContext<HoverCtx>({
|
|
25
|
+
key: null,
|
|
26
|
+
source: null,
|
|
27
|
+
setHover: DEFAULT_NO_OP_SET_HOVER,
|
|
28
|
+
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import type { HoverCtx } from './hover-context'
|
|
3
|
+
import { useCallback, useMemo, useState } from 'react'
|
|
4
|
+
import { HoverContext } from './hover-context'
|
|
5
|
+
|
|
6
|
+
export type ChartHoverSyncProps = {
|
|
7
|
+
children: ReactNode
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type HoverState = {
|
|
11
|
+
key: string | null
|
|
12
|
+
source: string | null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Activates the shared-cursor HoverContext: holds the hovered key (an opaque
|
|
17
|
+
* category/date string) + source chartId in one place so every descendant
|
|
18
|
+
* chart's `useHoverSync` reads and writes the same cursor. Hovering one chart
|
|
19
|
+
* shows a ghost crosshair + dot on all sibling charts under this provider.
|
|
20
|
+
*
|
|
21
|
+
* Wrap a group of charts that should share a cursor in `<ChartHoverSync>`.
|
|
22
|
+
*/
|
|
23
|
+
export function ChartHoverSync({ children }: ChartHoverSyncProps) {
|
|
24
|
+
// oxlint-disable-next-line react/hook-use-state -- raw setter; renaming shadows setHover (the context callback)
|
|
25
|
+
const [hover, setHoverState] = useState<HoverState>({ key: null, source: null })
|
|
26
|
+
|
|
27
|
+
const setHover = useCallback<HoverCtx['setHover']>((key, source) => {
|
|
28
|
+
setHoverState({ key, source })
|
|
29
|
+
}, [])
|
|
30
|
+
|
|
31
|
+
const value = useMemo<HoverCtx>(
|
|
32
|
+
() => ({ key: hover.key, source: hover.source, setHover }),
|
|
33
|
+
[hover.key, hover.source, setHover],
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
return <HoverContext.Provider value={value}>{children}</HoverContext.Provider>
|
|
37
|
+
}
|