basalt-ui 0.4.2 → 1.0.1
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 +210 -40
- package/LICENSE +201 -0
- package/README.md +421 -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/skills/basalt-app/SKILL.md +137 -0
- package/agent/skills/basalt-charts/SKILL.md +179 -0
- package/agent/skills/basalt-design/SKILL.md +249 -0
- package/agent/templates/CLAUDE-block.md.tpl +38 -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-ui.mjs +14 -0
- package/configs/check.yml +29 -0
- package/configs/lefthook.yml +25 -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 +292 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +889 -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 +386 -0
- package/dist/surfaces.d.ts.map +1 -0
- package/dist/surfaces.js +312 -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 +152 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +249 -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 +243 -46
- 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 +668 -0
- package/src/cli/help.test.ts +93 -0
- package/src/cli/index.ts +1535 -0
- package/src/cli/init-sync.test.ts +160 -0
- package/src/cli/placement-engine.test.ts +194 -0
- package/src/cli/tarball-parity.test.ts +44 -0
- package/src/cli/template-format.test.ts +64 -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 +508 -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 +369 -0
- package/src/tokens/palette.ts +288 -0
- package/src/vite.ts +122 -0
- package/src/index.css +0 -877
- package/src/starlight.css +0 -308
- package/tailwind.config.js +0 -78
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: basalt-ui
|
|
3
|
+
description: Streaming-agent layer for basalt-ui apps — Eden-native transport, AgentPart exhaustive handling, StickToBottom, chat history, AND the multi-thread ThreadWorkspace (concurrent runs + a distilled-outcome feed + detail panel). Headless layer in ./agent; the Mantine chrome and markdown rendering (basalt-ui/content's Markdown) ship from the root entry. Covers authoring doctrine and the Eden #231 footgun.
|
|
4
|
+
paths:
|
|
5
|
+
- 'src/**/*agent*'
|
|
6
|
+
- 'src/**/chat*'
|
|
7
|
+
- 'src/**/transport*'
|
|
8
|
+
- 'apps/**/src/**/*agent*'
|
|
9
|
+
- 'apps/**/src/**/chat*'
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Basalt Agent — Streaming Chat Layer
|
|
13
|
+
|
|
14
|
+
basalt-ui ships `./agent` — a headless, Mantine-free streaming-chat layer with an injected
|
|
15
|
+
transport seam, exhaustive part rendering, auto-scroll, and persisted history. `./agent` ships no
|
|
16
|
+
markdown renderer of its own — `agent/** -> content` is lint-blocked by design, so `PartList` takes
|
|
17
|
+
a consumer-supplied `components.text`; basalt's own renderer is `basalt-ui/content`'s `Markdown`.
|
|
18
|
+
|
|
19
|
+
## AgentPart discriminated union
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import type { AgentPart } from 'basalt-ui/agent'
|
|
23
|
+
// StartPart | TextPart | ReasoningPart | ToolCallPart | SourcePart | ErrorPart
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`StartPart` is a no-op resumption signal, not renderable content — see "Stream resumption" below.
|
|
27
|
+
|
|
28
|
+
Every switch over `AgentPart` MUST end with `default: return assertNever(part)`. This is
|
|
29
|
+
enforced by tsc — adding a new variant without a case is a compile error.
|
|
30
|
+
|
|
31
|
+
## AgentTransport — the injected seam
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { useAgentStream, edenTransport, type AgentPart } from 'basalt-ui/agent'
|
|
35
|
+
|
|
36
|
+
// Wrap your Eden call:
|
|
37
|
+
const transport = edenTransport<AgentPart>((input, signal) =>
|
|
38
|
+
api.chat.post({ body: { message: input }, fetch: { signal } }),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
// Wire into the hook:
|
|
42
|
+
const { parts, status, send, stop, regenerate } = useAgentStream({ transport })
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`edenTransport` is zero-dep: it awaits the Eden `{data, error}` envelope, throws on error,
|
|
46
|
+
and yields from the `AsyncGenerator<TPart>` data value.
|
|
47
|
+
|
|
48
|
+
The transport seam is generic (`AgentTransport<TPart, TInput>`) — consumers can extend AgentPart
|
|
49
|
+
with domain variants and pass a custom input type. For a mock (tests/playground), implement the
|
|
50
|
+
interface directly without `edenTransport`:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
const mockTransport: AgentTransport = {
|
|
54
|
+
async *stream(input) {
|
|
55
|
+
yield { type: 'text', text: `Echo: ${input}` }
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Eden #231 — the critical stream footgun
|
|
61
|
+
|
|
62
|
+
**Issue (STILL OPEN):** applying a `t.Object` or `t.Union` response schema to an Elysia
|
|
63
|
+
`async function*` stream route collapses the streamed union to `any` in Eden Treaty.
|
|
64
|
+
|
|
65
|
+
**Mitigation (required doctrine):**
|
|
66
|
+
|
|
67
|
+
1. **NO response schema on the stream route.** Leave the `.post(handler)` call schema-free for
|
|
68
|
+
the streaming generator.
|
|
69
|
+
2. **Validate at yield-time.** Check part shape before yielding, not in the Elysia schema layer.
|
|
70
|
+
Use `parseAgentPart` from `basalt-ui/agent` to narrow untrusted values arriving over the wire:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { parseAgentPart } from 'basalt-ui/agent'
|
|
74
|
+
|
|
75
|
+
// On the client — e.g. parsing raw NDJSON lines from a custom transport:
|
|
76
|
+
const raw: unknown = JSON.parse(line)
|
|
77
|
+
const part = parseAgentPart(raw) // AgentPart | null
|
|
78
|
+
if (part !== null) handlePart(part)
|
|
79
|
+
|
|
80
|
+
// On the server — guard before yielding from external tool output:
|
|
81
|
+
const candidate = buildPartFromTool(toolResult)
|
|
82
|
+
const part = parseAgentPart(candidate)
|
|
83
|
+
if (part !== null) yield part
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`parseAgentPart` performs structural narrowing against every variant in the discriminated union
|
|
87
|
+
and returns `null` for unknown types or malformed shapes — no exceptions thrown.
|
|
88
|
+
|
|
89
|
+
3. **Explicit return type annotation.** The handler MUST declare `: AsyncGenerator<AgentPart>`.
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
// ✓ Correct — explicit return type, no response schema:
|
|
93
|
+
app.post('/chat', async function* ({ body }): AsyncGenerator<AgentPart> {
|
|
94
|
+
// validate body.message here, not via t.Object schema
|
|
95
|
+
yield { type: 'text', text: 'Hello' }
|
|
96
|
+
yield { type: 'text', text: ' world' }
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
// ✗ Wrong — response schema collapses the union to `any`:
|
|
100
|
+
app.post(
|
|
101
|
+
'/chat',
|
|
102
|
+
async function* ({ body }): AsyncGenerator<AgentPart> {
|
|
103
|
+
yield { type: 'text', text: 'Hello' }
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
response: t.Object({ type: t.Literal('text'), text: t.String() }), // drops to any
|
|
107
|
+
},
|
|
108
|
+
)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Two additional Eden silent-`any` footguns
|
|
112
|
+
|
|
113
|
+
These apply to ALL Eden Treaty usage (not just streams):
|
|
114
|
+
|
|
115
|
+
1. **Non-chained routes.** Elysia routes MUST be method-chained (`app.get(...).post(...)`). A
|
|
116
|
+
standalone `app.get(...)` that is not chained back drops the `App` type to `any`, losing all
|
|
117
|
+
Treaty type safety.
|
|
118
|
+
|
|
119
|
+
2. **Mismatched tsconfig path aliases.** Client and server packages MUST share or extend one root
|
|
120
|
+
`tsconfig` so path aliases (`~/*`, `@/*`) resolve identically. A mismatch causes Eden's type
|
|
121
|
+
extraction to fail silently and degrade to `any`.
|
|
122
|
+
|
|
123
|
+
Both footguns produce no TypeScript error at the point of breakage — they only manifest as `any`
|
|
124
|
+
types on the Treaty client.
|
|
125
|
+
|
|
126
|
+
## useAgentStream
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
const { parts, status, send, stop, regenerate } = useAgentStream({ transport })
|
|
130
|
+
// status: 'idle' | 'streaming' | 'done' | 'error'
|
|
131
|
+
// send(input): starts a new stream, resets parts
|
|
132
|
+
// stop(): aborts the in-flight stream via AbortController
|
|
133
|
+
// regenerate(): re-runs the last input
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## PartList — exhaustive rendering
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import { PartList } from 'basalt-ui/agent'
|
|
140
|
+
import { Markdown } from 'basalt-ui/content'
|
|
141
|
+
|
|
142
|
+
// Default headless renderers (plain HTML elements):
|
|
143
|
+
<PartList parts={parts} />
|
|
144
|
+
|
|
145
|
+
// With basalt's own Markdown for the text renderer:
|
|
146
|
+
<PartList
|
|
147
|
+
parts={parts}
|
|
148
|
+
components={{
|
|
149
|
+
text: ({ part }) => <Markdown streaming density="chat">{part.text}</Markdown>,
|
|
150
|
+
}}
|
|
151
|
+
/>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
`PartList` ships five headless default renderers (zero Mantine):
|
|
155
|
+
|
|
156
|
+
- `text` → `<div className="basalt-agent-text">`
|
|
157
|
+
- `reasoning` → `<details className="basalt-agent-reasoning">`
|
|
158
|
+
- `tool` → `<div className="basalt-agent-tool">` with labelled input/output `<pre>`
|
|
159
|
+
- `source` → `<a className="basalt-agent-source">`
|
|
160
|
+
- `error` → `<div className="basalt-agent-error" role="alert">`
|
|
161
|
+
|
|
162
|
+
`./agent` deliberately ships no markdown renderer of its own — `agent/** -> content` is
|
|
163
|
+
lint-blocked by design (the Mantine-free boundary). The package's only markdown renderer is
|
|
164
|
+
`basalt-ui/content`'s `Markdown`; `threadPartRenderers` (re-exported from the root `basalt-ui`
|
|
165
|
+
entry) already wires it in as the `text` renderer for `ThreadTranscript`/`ThreadWorkspace`.
|
|
166
|
+
|
|
167
|
+
## BasaltStickToBottom (optional peer)
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
import { BasaltStickToBottom } from 'basalt-ui/agent'
|
|
171
|
+
;<BasaltStickToBottom style={{ height: '400px', overflow: 'auto' }}>
|
|
172
|
+
<PartList parts={parts} />
|
|
173
|
+
</BasaltStickToBottom>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Install:** `bun add use-stick-to-bottom`
|
|
177
|
+
|
|
178
|
+
Lazily loaded — `use-stick-to-bottom` is an optional peer. Falls back to a plain scrollable div
|
|
179
|
+
while loading. Surfaces a scroll-to-bottom button (`.basalt-agent-scroll-to-bottom`) when the user
|
|
180
|
+
scrolls up.
|
|
181
|
+
|
|
182
|
+
## createChatHistoryStore
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
import { createChatHistoryStore } from 'basalt-ui/agent'
|
|
186
|
+
|
|
187
|
+
// Call once at module scope with a stable key:
|
|
188
|
+
const useChatHistory = createChatHistoryStore({ key: 'main-chat', version: 1, max: 100 })
|
|
189
|
+
|
|
190
|
+
// In a component:
|
|
191
|
+
const { messages, append, clear } = useChatHistory()
|
|
192
|
+
append({ id: crypto.randomUUID(), role: 'user', parts: [...], createdAt: Date.now() })
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Built on `createPersistedState` — SSR-safe, cross-tab via the `storage` event. Ring-buffered to
|
|
196
|
+
`max` (default 100). Increment `version` when the `ChatMessage` shape changes to clear stale data.
|
|
197
|
+
|
|
198
|
+
## Multi-thread workspace (shipped)
|
|
199
|
+
|
|
200
|
+
For the "many short chats" pattern — each prompt a short-lived thread, the feed showing only a
|
|
201
|
+
distilled outcome (title + summary), a right-hand detail panel to open and continue — basalt-ui
|
|
202
|
+
ships a full workspace. The headless multi-thread layer lives in `./agent` (Mantine-free); the
|
|
203
|
+
ready-built Mantine chrome ships from the root `basalt-ui` entry.
|
|
204
|
+
|
|
205
|
+
### Headless (`basalt-ui/agent`)
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
import { createThreadsStore, useAgentThreadRuns, heuristicOutcome } from 'basalt-ui/agent'
|
|
209
|
+
import type { AgentThread, AgentOutcome, OutcomeResolver, ThreadStatus } from 'basalt-ui/agent'
|
|
210
|
+
|
|
211
|
+
// Call ONCE at module scope — same doctrine as createChatHistoryStore:
|
|
212
|
+
const useThreads = createThreadsStore({ key: 'main-threads', version: 1 })
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
- `createThreadsStore({ key, version, maxThreads?, maxMessagesPerThread? })` — the multi-thread
|
|
216
|
+
analog of `createChatHistoryStore`: a persisted, ring-buffered registry of `AgentThread`s (each
|
|
217
|
+
carrying its own `ChatMessage[]`, a distilled `AgentOutcome | null`, a `ThreadStatus`, and a read
|
|
218
|
+
flag). Threads are newest-first; `create()` returns the new id and never touches `activeId`.
|
|
219
|
+
- `useAgentThreadRuns({ transport, store, resolveOutcome })` — the CONCURRENT run manager. Unlike
|
|
220
|
+
`useAgentStream` (one in-flight turn), it runs N streams keyed by thread id, so many short chats
|
|
221
|
+
stream and resolve in the background independently. `start(threadId, input)` / `stop(threadId)` /
|
|
222
|
+
`stopAll()`; `runs` is the live per-thread `{ status, parts }` map for the detail view.
|
|
223
|
+
- `AgentOutcome = { title; summary; status: 'done' | 'attention' | 'error' }` — the distilled feed
|
|
224
|
+
projection, deliberately a DIFFERENT shape from the transcript so raw prompt/thinking can never
|
|
225
|
+
leak into the feed (the enforced boundary).
|
|
226
|
+
|
|
227
|
+
### Outcome resolver — the summarize-to-outcome seam
|
|
228
|
+
|
|
229
|
+
basalt ships ONLY the seam, never an LLM call. `OutcomeResolver = (thread) => AgentOutcome |
|
|
230
|
+
Promise<AgentOutcome>` — the app supplies it. In production derive `{ title, summary }` from the
|
|
231
|
+
finished run (e.g. a structured final step of your own model) and return it. `heuristicOutcome` is
|
|
232
|
+
a demo-only fallback that truncates the last assistant text — never the production path.
|
|
233
|
+
|
|
234
|
+
### Ready-built UI (`basalt-ui`, Mantine)
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
import { ThreadWorkspace } from 'basalt-ui'
|
|
238
|
+
;<ThreadWorkspace
|
|
239
|
+
useThreads={useThreads}
|
|
240
|
+
transport={transport}
|
|
241
|
+
resolveOutcome={resolveOutcome}
|
|
242
|
+
newThreadPlaceholder="Ask anything…"
|
|
243
|
+
/>
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
`ThreadWorkspace` is the flagship composite: a `ThreadFeed` of distilled `ThreadOutcomeCard`s + an
|
|
247
|
+
anchored new-thread `Composer` on the left, a `ThreadDetailPanel` (full transcript + a continue
|
|
248
|
+
composer) on the right, collapsing to a single pane below 768px. The lower-level pieces
|
|
249
|
+
(`ThreadFeed`, `ThreadOutcomeCard`, `ThreadDetailPanel`, `Composer`, `ThreadTranscript`,
|
|
250
|
+
`threadPartRenderers`) are exported too for bespoke layouts. Motion (feed insert, panel slide) runs
|
|
251
|
+
on the shared `MOTION_*` tokens and honours `useReducedMotion`.
|
|
252
|
+
|
|
253
|
+
**Boundary:** the headless layer (`createThreadsStore`, `useAgentThreadRuns`, the outcome types)
|
|
254
|
+
stays Mantine-free in `./agent`; the components are Mantine-coupled and ship from the root entry.
|
|
255
|
+
Never add `@mantine/*` under `src/agent/**` — it is oxlint-enforced Mantine-free.
|
|
256
|
+
|
|
257
|
+
**No custom part types at the workspace level.** `ThreadWorkspace`, `ThreadDetailPanel`, and
|
|
258
|
+
`ThreadTranscript` render the framework's `AgentPart` union only — they are not generic over a
|
|
259
|
+
consumer-extended part type. If you need custom rendering for the existing part shapes, drop to
|
|
260
|
+
the headless layer instead: compose your own transcript from `PartList` (`basalt-ui/agent`) with a
|
|
261
|
+
custom `components` renderer map, rather than passing a wider type through `ThreadWorkspace`.
|
|
262
|
+
|
|
263
|
+
## Stream resumption — the reconnect seam
|
|
264
|
+
|
|
265
|
+
basalt-ui ships the CLIENT-SIDE contract for resuming a run after a disconnect (reload, network
|
|
266
|
+
drop) — NOT a concrete backend. A real resumable transport (e.g. Redis-backed run state) is the
|
|
267
|
+
consumer's responsibility; this section documents the seam a consumer transport plugs into.
|
|
268
|
+
|
|
269
|
+
### StartPart
|
|
270
|
+
|
|
271
|
+
A sixth `AgentPart` variant, emitted once at the top of a run:
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
export type StartPart = {
|
|
275
|
+
readonly type: 'start'
|
|
276
|
+
readonly runId: string
|
|
277
|
+
readonly resumeToken?: string
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Not renderable content — `PartList`'s exhaustive switch returns `null` for it, and it's stripped
|
|
282
|
+
before the consumer ever sees it: `useAgentStream` skips it in its accumulation loop; `useAgentThreadRuns`
|
|
283
|
+
skips it too but additionally reads `resumeToken` off it and stashes it on the persisted
|
|
284
|
+
`AgentThread` via `store.setResumeToken`. `parseAgentPart` validates it like every other variant
|
|
285
|
+
(`runId` required string, `resumeToken` optional string).
|
|
286
|
+
|
|
287
|
+
### AgentTransport.resume
|
|
288
|
+
|
|
289
|
+
```ts
|
|
290
|
+
export type AgentTransport<TPart = AgentPart, TInput = string> = {
|
|
291
|
+
stream: (input: TInput, signal?: AbortSignal) => AsyncGenerator<TPart>
|
|
292
|
+
resume?: (resumeToken: string, signal?: AbortSignal) => AsyncGenerator<TPart>
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Optional — a transport that doesn't support resumption simply omits `resume`. `edenTransport`
|
|
297
|
+
takes an optional second `resumeCall` parameter (same shape as `call`, but keyed on `resumeToken`
|
|
298
|
+
instead of the original input) and only adds a `resume` method to the returned transport object
|
|
299
|
+
when `resumeCall` is provided (no `resume: undefined` key otherwise):
|
|
300
|
+
|
|
301
|
+
```ts
|
|
302
|
+
const transport = edenTransport<AgentPart>(
|
|
303
|
+
(input, signal) => api.chat.post({ body: { message: input }, fetch: { signal } }),
|
|
304
|
+
(resumeToken, signal) => api.chat.resume.post({ body: { resumeToken }, fetch: { signal } }),
|
|
305
|
+
)
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### ThreadsStore.resumeToken / setResumeToken
|
|
309
|
+
|
|
310
|
+
`AgentThread` carries an optional `resumeToken?: string`, set from the run's most recent
|
|
311
|
+
`StartPart` and cleared once the run finalizes. `ThreadsStore.setResumeToken(id, token)` is the
|
|
312
|
+
setter — same shape/pattern as `setStatus`/`setOutcome`.
|
|
313
|
+
|
|
314
|
+
### Mount-time resume-before-interrupted
|
|
315
|
+
|
|
316
|
+
`useAgentThreadRuns`'s mount-reconciliation effect previously marked every orphaned thread
|
|
317
|
+
(`'pending'`/`'streaming'` with no live controller — e.g. after a reload mid-stream) straight to
|
|
318
|
+
`'interrupted'`. It now attempts a resume first:
|
|
319
|
+
|
|
320
|
+
1. Find the thread's last `role === 'user'` message (no new user message is created on resume — it
|
|
321
|
+
was already appended before the disconnect).
|
|
322
|
+
2. If `transport.resume` is defined AND the thread has a `resumeToken` AND that last user message
|
|
323
|
+
exists, call `transport.resume(resumeToken, signal)` and feed the resulting generator through
|
|
324
|
+
the SAME accumulate/finalize logic as a fresh `start()` call (both share one internal
|
|
325
|
+
`consumeAndFinalize` helper). The resumed run occupies the `runs` map exactly like a live turn —
|
|
326
|
+
reusing the existing `'streaming'` status; there is no separate `'resuming'` ThreadStatus.
|
|
327
|
+
3. Any failure — no `resume()`, no `resumeToken`, no user message, or the resume itself throwing —
|
|
328
|
+
falls back to `'interrupted'`, exactly as before.
|
|
329
|
+
|
|
330
|
+
Resumption is strictly additive: a transport that never emits `StartPart` and never implements
|
|
331
|
+
`resume` behaves identically to today (every orphaned thread still lands on `'interrupted'`).
|
|
332
|
+
|
|
333
|
+
## aiSdkTransport — the RECOMMENDED DEFAULT transport
|
|
334
|
+
|
|
335
|
+
For LLM chat use cases, `aiSdkTransport` (backed by the `ai` npm package, an OPTIONAL peer) is the
|
|
336
|
+
recommended default — `edenTransport` remains fully supported as the zero-extra-dependency
|
|
337
|
+
alternative (see above); neither is deprecated.
|
|
338
|
+
|
|
339
|
+
```ts
|
|
340
|
+
import { useAgentStream, aiSdkTransport } from 'basalt-ui/agent'
|
|
341
|
+
|
|
342
|
+
const transport = aiSdkTransport({ api: '/api/chat' })
|
|
343
|
+
const { parts, status, send } = useAgentStream({ transport })
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
**Install:** `bun add ai`. Like `BasaltStickToBottom`, `ai` is lazily resolved via a memoized
|
|
347
|
+
dynamic `import()` on first `stream()`/`resume()` — importing `basalt-ui/agent` (or calling
|
|
348
|
+
`aiSdkTransport(...)`) never eagerly resolves it. Unlike that, there is no "plain text" degrade
|
|
349
|
+
path if `ai` is missing: the rejected import propagates through the async generator
|
|
350
|
+
into the consumer's existing error handling (`useAgentStream` → `status: 'error'`;
|
|
351
|
+
`useAgentThreadRuns` → its `onFailureStatus`).
|
|
352
|
+
|
|
353
|
+
**Why diffing is needed.** AI SDK's `readUIMessageStream` yields the FULL accumulated `UIMessage`
|
|
354
|
+
snapshot on every update (a growing `parts` array; existing parts' content grows in place) — it is
|
|
355
|
+
not itself a delta stream. basalt-ui's whole part-accumulation model is delta-based, so
|
|
356
|
+
`aiSdkTransport` diffs consecutive snapshots internally and yields only the new `AgentPart` deltas.
|
|
357
|
+
One consequence: `ToolCallPart` gained an optional `toolCallId` field, since AI SDK's tool parts
|
|
358
|
+
carry one and re-emit on every state transition (`input-available` → `output-available`) at the
|
|
359
|
+
SAME array index — a consumer's own coalescing can key on `toolCallId` to update a tool block in
|
|
360
|
+
place instead of rendering a near-duplicate second block.
|
|
361
|
+
|
|
362
|
+
**Chat id binding.** `aiSdkTransport(options)` mints one stable chat id at construction — the
|
|
363
|
+
returned object is immediately usable with `useAgentStream`. Call `.forThread(threadId)` to bind a
|
|
364
|
+
transport to a caller-supplied id instead — the form `useAgentThreadRuns` expects when `transport`
|
|
365
|
+
is a per-thread factory (see "Multi-thread workspace" above):
|
|
366
|
+
|
|
367
|
+
```ts
|
|
368
|
+
const transport = aiSdkTransport({ api: '/api/chat' })
|
|
369
|
+
useAgentThreadRuns({
|
|
370
|
+
transport: (threadId) => transport.forThread(threadId),
|
|
371
|
+
store,
|
|
372
|
+
resolveOutcome,
|
|
373
|
+
})
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
**Scope gaps (v1):** `source-document`, `file`, `reasoning-file`, `data-*`, `step-start`, `custom`,
|
|
377
|
+
and `dynamic-tool` UIMessage parts have no `AgentPart` equivalent yet and are silently skipped by
|
|
378
|
+
the diff — not an oversight, a deliberate v1 boundary (see the code comment in
|
|
379
|
+
`ai-sdk-transport.ts`). Tool parts in the `'input-streaming'` state (partial/`DeepPartial` input)
|
|
380
|
+
are also skipped — only `'input-available'` and later states emit, to avoid flooding the consumer
|
|
381
|
+
with incomplete fragments.
|
|
382
|
+
|
|
383
|
+
## Deferred (advisory — not shipped)
|
|
384
|
+
|
|
385
|
+
The following are explicitly deferred and MUST NOT be scaffolded:
|
|
386
|
+
|
|
387
|
+
- Voice/audio streaming
|
|
388
|
+
- `streamdown` integration (Tailwind-only)
|
|
389
|
+
- Elysia stream route scaffold in app code (consumer's responsibility)
|
|
390
|
+
- `agent-parts.ts` helper files beyond the basalt surface
|
|
391
|
+
|
|
392
|
+
> The full thread-chat composite (`ThreadWorkspace`) is now **shipped** — see "Multi-thread
|
|
393
|
+
> workspace" above. It was previously on this list; a real consumer drove it, so it graduated per
|
|
394
|
+
> the "build-when-driven" rule rather than being scaffolded speculatively. `aiSdkTransport` graduated
|
|
395
|
+
> the same way — see the section above; it is no longer deferred.
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: basalt-ui
|
|
3
|
+
description: visx chart conventions — compose basalt-ui primitives/kinds, stay Mantine-free, and keep all color in `--vx-*` tokens. Enforced by the oxlint `@visx` ban.
|
|
4
|
+
paths:
|
|
5
|
+
- 'src/**/charts/**'
|
|
6
|
+
- 'apps/**/charts/**'
|
|
7
|
+
- 'packages/**/charts/**'
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Basalt Charts — visx Conventions
|
|
11
|
+
|
|
12
|
+
basalt-ui owns the chart doctrine. Charts are built from low-level [visx](https://airbnb.io/visx)
|
|
13
|
+
primitives so we can build exactly the chart we want; the trade-off is that every chart duplicates
|
|
14
|
+
structure unless we compose shared building blocks. **The primitives + a small kind set are the
|
|
15
|
+
contract, not optional polish.**
|
|
16
|
+
|
|
17
|
+
## The boundary (lint-enforced)
|
|
18
|
+
|
|
19
|
+
The shipped oxlint preset (`basalt-ui/configs/oxlint.json`) enforces two hard rules — they hold in
|
|
20
|
+
downstream apps too:
|
|
21
|
+
|
|
22
|
+
- **`@visx/*` may only be imported inside a `**/charts/**` directory.** Everywhere else, compose
|
|
23
|
+
basalt-ui chart primitives/kinds. If you need a raw visx primitive for a bespoke chart, import it
|
|
24
|
+
from `basalt-ui/charts` (it re-exports `Group`, `LinePath`, `Bar`, `AreaClosed`, `scaleLinear`,
|
|
25
|
+
`curveMonotoneX`, …) — keep the dependency declared in one place.
|
|
26
|
+
- **`@visx/tooltip` is banned everywhere.** Use `ChartTooltip` + `TooltipHeader`/`TooltipRow`/
|
|
27
|
+
`TooltipBody` from `basalt-ui/charts`.
|
|
28
|
+
- **The `src/charts/` tree must be Mantine-free** — no `@mantine/*` imports. Bridge the Mantine
|
|
29
|
+
color scheme to charts in exactly one file (see basalt-mantine.md, the VxBridge pattern); route
|
|
30
|
+
components import chart primitives directly from `basalt-ui/charts`, never from the bridge file.
|
|
31
|
+
|
|
32
|
+
## Every chart has
|
|
33
|
+
|
|
34
|
+
1. **ChartCard** wrapper — gives title + info-tooltip + extra slot, consistent margin.
|
|
35
|
+
2. **ChartLegend** — never hand-rolled legend markup. Supports `line | bar | split | splitLine`
|
|
36
|
+
shapes and optional highlight state.
|
|
37
|
+
3. **ChartTooltip** + `TooltipHeader` + `TooltipRow` + `TooltipBody` — never `@visx/tooltip` directly.
|
|
38
|
+
4. **AxisLeftNumeric** / **AxisRightNumeric** + **AxisBottomDate** — never raw `<AxisLeft>`/`<AxisBottom>`/`<AxisRight>`
|
|
39
|
+
(they miss theme tokens + smart ticks). Enforced by `basalt check-theme` (`raw-visx-axis` guard
|
|
40
|
+
fails the build on a raw axis in a `/charts/` file; escape via `theme-allow`), not just convention.
|
|
41
|
+
5. **HoverOverlay** for mouse capture, **HoverContext** for cross-chart crosshair sync,
|
|
42
|
+
**useChartTooltip** for tip state, **useHoverSync** for the shared cursor. Wrap a group of
|
|
43
|
+
date-aligned charts in **ChartHoverSync** (from `basalt-ui/charts`) to activate cross-chart sync —
|
|
44
|
+
hovering one chart casts a ghost crosshair on all siblings; without it `useHoverSync` runs
|
|
45
|
+
per-chart only and logs a dev warning:
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
<ChartHoverSync>
|
|
49
|
+
<ChartCard>…</ChartCard>
|
|
50
|
+
<ChartCard>…</ChartCard>
|
|
51
|
+
</ChartHoverSync>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
6. **Theme-aware colors** via `VX.*` tokens + `alpha()`. **Never** a raw hex literal in a chart file.
|
|
55
|
+
**Never** `localStorage.getItem('theme')` — the scheme resolves via CSS vars (see Dark/light below).
|
|
56
|
+
|
|
57
|
+
**Exemption:** sparklines (`LineSparkline`, `BarSparkline` — tiny inline charts with no legend/tooltip)
|
|
58
|
+
don't have to compose ChartCard/ChartLegend/ChartTooltip — but still use `VX.*` tokens.
|
|
59
|
+
|
|
60
|
+
## Kinds — the recurring shapes
|
|
61
|
+
|
|
62
|
+
basalt-ui ships these kinds (declarative props, generic over your point type via `getX`/`getY`):
|
|
63
|
+
|
|
64
|
+
- **`ZonedLine`** — a line with zone bands, thresholds, and reference lines.
|
|
65
|
+
- **`Bars`** — bars with optional overlaid line, zones, ref lines, dual-axis config.
|
|
66
|
+
- **`StackedArea`** — opaque stacked bands.
|
|
67
|
+
- **`Donut`** — proportional donut.
|
|
68
|
+
- **`MultiLine`** — N series on a shared y-axis: legend-hover dimming, per-series synced dots,
|
|
69
|
+
dashed companion (MA) lines, per-point markers (PR stars / status dots), zones + refLines, fixed
|
|
70
|
+
or auto domain (covers z-score/σ via a fixed symmetric domain + zero refLine).
|
|
71
|
+
- **`DualPanel`** — top line-pane + bottom signed-histogram pane sharing one x-scale and one cursor;
|
|
72
|
+
optional fill-between two top lines, zones, refLines.
|
|
73
|
+
- **`Heatmap`** — category×category intensity grid (`color-mix` alpha), per-cell tooltip, optional
|
|
74
|
+
gradient legend strip.
|
|
75
|
+
|
|
76
|
+
How to add a chart:
|
|
77
|
+
|
|
78
|
+
1. **Fits an existing kind?** Use it. Pass `data`, `width`, `height`, `chartId`, accessors, and the
|
|
79
|
+
declarative zones/thresholds/refLines arrays.
|
|
80
|
+
2. **Second instance of a new recurring shape?** Extract a kind and migrate both call sites
|
|
81
|
+
(Rule of Three: don't extract on the first, don't wait past the third). Bespoke escape hatches
|
|
82
|
+
(`renderExtraTooltipRows`, etc.) are fine but must not grow into god-object configs.
|
|
83
|
+
3. **Genuinely unique (e.g. a dual-panel MACD)?** Stay bespoke — compose the primitives + the raw
|
|
84
|
+
visx re-exports directly. Keep it in the page's chart file, not in a shared kind.
|
|
85
|
+
|
|
86
|
+
**Anti-pattern:** a single `<Chart type="..." config={...} />` that switches by kind. Prefer N small kinds.
|
|
87
|
+
|
|
88
|
+
## Series color
|
|
89
|
+
|
|
90
|
+
App-specific series colors are _your_ domain data, not framework data. Declare them once:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { defineSeries, groupTokens } from 'basalt-ui/tokens'
|
|
94
|
+
|
|
95
|
+
const SERIES = defineSeries({
|
|
96
|
+
load: { light: '#…', dark: '#…' },
|
|
97
|
+
recovery: { light: '#…', dark: '#…' },
|
|
98
|
+
})
|
|
99
|
+
const tokens = groupTokens('series', SERIES) // → { load: 'var(--vx-series-load)', ... }
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Emit the CSS via `buildPaletteCss({ groups: { 'series-': SERIES } })`. A hue keeps its identity but
|
|
103
|
+
shifts shade across schemes — that's why each entry is a `{ light, dark }` pair, not a single value.
|
|
104
|
+
**Adding a new color** means adding a pair to your series map and rebuilding the palette CSS — never
|
|
105
|
+
inline a hex in a chart.
|
|
106
|
+
|
|
107
|
+
## Dark/light mode
|
|
108
|
+
|
|
109
|
+
Theme reactivity is **pure CSS**: the `--vx-*` variables are redeclared under the light/dark color
|
|
110
|
+
scheme, so toggling the scheme restyles every chart with no React re-render. Charts read `VX.*` (var
|
|
111
|
+
refs) directly. Don't branch on color scheme in JS; never read `localStorage.getItem('theme')`.
|
|
112
|
+
|
|
113
|
+
## Area gradients
|
|
114
|
+
|
|
115
|
+
Use the `AreaGradient` primitive (a vertical `<linearGradient>` of `color-mix` stops over a `--vx-*`
|
|
116
|
+
color) with the global strength knobs (`--vx-area-top` / `--vx-area-bottom`). Default the fill **on**
|
|
117
|
+
for plain metric lines, **off** when the chart already carries zone/threshold fills (avoid double-fill
|
|
118
|
+
clutter). Keep stacked-area bands opaque — fading them leaks lower bands.
|
|
119
|
+
|
|
120
|
+
## Responsive sizing
|
|
121
|
+
|
|
122
|
+
Use `ResponsiveChart` (render-prop container) or `useChartSize` (hook) from `basalt-ui/charts` —
|
|
123
|
+
both are backed by `@visx/responsive`'s `useParentSize` and keep the `@visx/*` import inside
|
|
124
|
+
`src/charts/**` per the boundary rule. Never reach for `@visx/responsive` directly or
|
|
125
|
+
`useElementSize` from `@mantine/hooks` in a chart file.
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import { ResponsiveChart, Bars } from 'basalt-ui/charts'
|
|
129
|
+
|
|
130
|
+
// Preferred: render prop, renders nothing until the first measurement
|
|
131
|
+
<ResponsiveChart height={320}>
|
|
132
|
+
{({ width, height }) => (
|
|
133
|
+
<Bars width={width} height={height} data={data} chartId="load" getX={…} getY={…} />
|
|
134
|
+
)}
|
|
135
|
+
</ResponsiveChart>
|
|
136
|
+
|
|
137
|
+
// aspectRatio variant: height = width / ratio
|
|
138
|
+
<ResponsiveChart aspectRatio={16 / 9}>
|
|
139
|
+
{({ width, height }) => <MyChart width={width} height={height} />}
|
|
140
|
+
</ResponsiveChart>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Use `useChartSize` directly when you need the `ref` on a custom container:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
import { useChartSize } from 'basalt-ui/charts'
|
|
147
|
+
|
|
148
|
+
const { ref, width, height } = useChartSize()
|
|
149
|
+
// attach ref to your container div; width/height update via ResizeObserver
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`ResponsiveChartProps`: `height` (default 240), `aspectRatio`, `debounceMs` (default 0), `children`.
|
|
153
|
+
`UseChartSizeResult`: `{ ref, width, height }`.
|
|
154
|
+
|
|
155
|
+
## Migrating from pre-1.0 (`@argo/charts` era)
|
|
156
|
+
|
|
157
|
+
Three silent renames/behavior changes trip up a consumer migrating off the pre-1.0 in-house charts
|
|
158
|
+
package — all typecheck-clean only in a strict setup, so they're easy to miss in a quick port:
|
|
159
|
+
|
|
160
|
+
- **`HoverCtx.date` → `HoverCtx.key`.** The hover context's cross-chart cursor field is generic
|
|
161
|
+
now (not date-only) — rename the field, not just the type.
|
|
162
|
+
- **`useHoverSync({ getX })` → `useHoverSync({ getKey })`.** Same generalization — pass an accessor
|
|
163
|
+
returning the series key, not an x/date value.
|
|
164
|
+
- **`legend.maxRows` renders a `+N more` chip** instead of silently truncating. A consumer that
|
|
165
|
+
previously hand-rolled `.slice(0, N)` on its legend items gets a visible UX diff (a real overflow
|
|
166
|
+
indicator) — drop the manual slice and let `maxRows` own it.
|
|
167
|
+
|
|
168
|
+
## Rule of thumb
|
|
169
|
+
|
|
170
|
+
> If the new chart doesn't fit the primitives, add a kind — don't loosen the primitives.
|