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,218 @@
|
|
|
1
|
+
import { curveMonotoneX } from '@visx/curve'
|
|
2
|
+
import { GridRows } from '@visx/grid'
|
|
3
|
+
import { Group } from '@visx/group'
|
|
4
|
+
import { scaleLinear, scalePoint } from '@visx/scale'
|
|
5
|
+
import { AreaStack } from '@visx/shape'
|
|
6
|
+
import { memo, useMemo, useState } from 'react'
|
|
7
|
+
import { AxisBottomDate, AxisLeftNumeric } from '../primitives/Axes'
|
|
8
|
+
import {
|
|
9
|
+
ChartTooltip,
|
|
10
|
+
TooltipBody,
|
|
11
|
+
TooltipHeader,
|
|
12
|
+
TooltipRow,
|
|
13
|
+
useTooltipStyles,
|
|
14
|
+
} from '../primitives/ChartTooltip'
|
|
15
|
+
import { ChartFrame, resolveLegend } from '../primitives/ChartFrame'
|
|
16
|
+
import { Crosshair, SeriesDot } from '../primitives/Crosshair'
|
|
17
|
+
import { HoverOverlay } from '../primitives/HoverOverlay'
|
|
18
|
+
import { useHoverSync } from '../hooks/useHoverSync'
|
|
19
|
+
import { deriveTooltipRows } from '../series'
|
|
20
|
+
import type { ChartLegendConfig, ChartSeries } from '../series'
|
|
21
|
+
import { VX } from '../../tokens'
|
|
22
|
+
import { smartTicks, smartTicksEvery } from '../utils/ticks'
|
|
23
|
+
|
|
24
|
+
export type StackedAreaProps<T> = {
|
|
25
|
+
data: T[]
|
|
26
|
+
/** Fixed height in pixels, forwarded to the internal `ChartFrame`. Default 240. */
|
|
27
|
+
height?: number
|
|
28
|
+
chartId: string
|
|
29
|
+
getX: (d: T) => string
|
|
30
|
+
/** The stacked bands, bottom to top — the single source of truth for color, legend, and tooltip
|
|
31
|
+
* rows. Typically `mark: 'area'` (rendered as a `bar`-shaped legend/tooltip swatch). */
|
|
32
|
+
series: ChartSeries<T>[]
|
|
33
|
+
formatValue: (v: number) => string
|
|
34
|
+
yLabel?: string
|
|
35
|
+
numTicksY?: number
|
|
36
|
+
numTicksX?: number
|
|
37
|
+
yAutoMaxFloor?: number
|
|
38
|
+
/** Legend config forwarded to `ChartFrame`; `false` disables the legend (sparkline escape).
|
|
39
|
+
* Default `{ placement: 'bottom' }`. */
|
|
40
|
+
legend?: ChartLegendConfig | false
|
|
41
|
+
/** Accessible text alternative, forwarded to `ChartFrame` as `aria-label` (+ `role="img"`). */
|
|
42
|
+
ariaLabel?: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Multi-series stacked-area chart with an optional derived legend (default on) and legend-hover
|
|
47
|
+
* dimming. Each band's fillOpacity is dimmed when a different key is highlighted via the legend.
|
|
48
|
+
* The tooltip renders rows in reversed (top-to-bottom) stack order so it matches the visual stack.
|
|
49
|
+
*/
|
|
50
|
+
function StackedAreaInner<T>(props: StackedAreaProps<T>) {
|
|
51
|
+
const { series, chartId, height, legend, ariaLabel } = props
|
|
52
|
+
const [highlightedKey, setHighlightedKey] = useState<string | null>(null)
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<ChartFrame
|
|
56
|
+
series={series}
|
|
57
|
+
chartId={chartId}
|
|
58
|
+
{...(height !== undefined && { height })}
|
|
59
|
+
{...(ariaLabel !== undefined && { ariaLabel })}
|
|
60
|
+
legend={resolveLegend(legend, {
|
|
61
|
+
highlighted: highlightedKey,
|
|
62
|
+
onHighlight: setHighlightedKey,
|
|
63
|
+
})}
|
|
64
|
+
>
|
|
65
|
+
{(plot) => <StackedAreaPlot {...props} plot={plot} highlightedKey={highlightedKey} />}
|
|
66
|
+
</ChartFrame>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
type StackedAreaPlotProps<T> = StackedAreaProps<T> & {
|
|
71
|
+
plot: { width: number; height: number }
|
|
72
|
+
highlightedKey: string | null
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The measured plot — split from {@link StackedAreaInner} so its scale/hover-sync hooks only run
|
|
76
|
+
* once `ChartFrame` has resolved a non-empty plot rect. */
|
|
77
|
+
function StackedAreaPlot<T>(props: StackedAreaPlotProps<T>) {
|
|
78
|
+
const {
|
|
79
|
+
data,
|
|
80
|
+
chartId,
|
|
81
|
+
getX,
|
|
82
|
+
series,
|
|
83
|
+
formatValue,
|
|
84
|
+
numTicksY = 5,
|
|
85
|
+
numTicksX,
|
|
86
|
+
yAutoMaxFloor,
|
|
87
|
+
plot,
|
|
88
|
+
highlightedKey,
|
|
89
|
+
} = props
|
|
90
|
+
|
|
91
|
+
const MARGIN = VX.margin
|
|
92
|
+
const xMax = plot.width - MARGIN.left - MARGIN.right
|
|
93
|
+
const yMax = plot.height - MARGIN.top - MARGIN.bottom
|
|
94
|
+
|
|
95
|
+
const seriesByKey = useMemo(() => new Map(series.map((s) => [s.key, s])), [series])
|
|
96
|
+
const groups = useMemo(() => series.map((s) => s.key), [series])
|
|
97
|
+
|
|
98
|
+
const xScale = useMemo(
|
|
99
|
+
() =>
|
|
100
|
+
scalePoint<string>({
|
|
101
|
+
domain: data.map(getX),
|
|
102
|
+
range: [0, xMax],
|
|
103
|
+
padding: 0,
|
|
104
|
+
}),
|
|
105
|
+
[data, xMax, getX],
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
const yScale = useMemo(() => {
|
|
109
|
+
let maxTotal = 0
|
|
110
|
+
for (const d of data) {
|
|
111
|
+
let total = 0
|
|
112
|
+
for (const s of series) {
|
|
113
|
+
total += s.getValue(d) ?? 0
|
|
114
|
+
}
|
|
115
|
+
if (total > maxTotal) maxTotal = total
|
|
116
|
+
}
|
|
117
|
+
const upper = Math.max(maxTotal, yAutoMaxFloor ?? maxTotal) * 1.1
|
|
118
|
+
return scaleLinear<number>({ domain: [0, upper], range: [yMax, 0], nice: true })
|
|
119
|
+
}, [data, series, yMax, yAutoMaxFloor])
|
|
120
|
+
|
|
121
|
+
const tooltipStyles = useTooltipStyles()
|
|
122
|
+
const { tip, tooltipRef, syncedPoint, isDirectHover, handleMouse, handleLeave } = useHoverSync<T>(
|
|
123
|
+
{
|
|
124
|
+
data,
|
|
125
|
+
chartId,
|
|
126
|
+
getKey: getX,
|
|
127
|
+
xScale,
|
|
128
|
+
marginLeft: MARGIN.left,
|
|
129
|
+
},
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
const tickValues = useMemo(
|
|
133
|
+
() =>
|
|
134
|
+
numTicksX ? smartTicksEvery(data.map(getX), numTicksX) : smartTicks(data.map(getX), xMax),
|
|
135
|
+
[data, xMax, getX, numTicksX],
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<>
|
|
140
|
+
<svg width={plot.width} height={plot.height}>
|
|
141
|
+
<Group left={MARGIN.left} top={MARGIN.top}>
|
|
142
|
+
<GridRows scale={yScale} width={xMax} stroke={VX.grid} numTicks={numTicksY} />
|
|
143
|
+
|
|
144
|
+
<AreaStack<T, string>
|
|
145
|
+
data={data}
|
|
146
|
+
keys={groups}
|
|
147
|
+
x={(d) => xScale(getX(d.data)) ?? 0}
|
|
148
|
+
y0={(d) => yScale(d[0]) ?? 0}
|
|
149
|
+
y1={(d) => yScale(d[1]) ?? 0}
|
|
150
|
+
value={(d, key) => seriesByKey.get(key)?.getValue(d) ?? 0}
|
|
151
|
+
curve={curveMonotoneX}
|
|
152
|
+
>
|
|
153
|
+
{({ stacks, path }) =>
|
|
154
|
+
stacks.map((stack) => (
|
|
155
|
+
<path
|
|
156
|
+
key={`stack-${stack.key}`}
|
|
157
|
+
d={path(stack) || ''}
|
|
158
|
+
fill={seriesByKey.get(stack.key)?.color}
|
|
159
|
+
stroke="transparent"
|
|
160
|
+
fillOpacity={highlightedKey === null || highlightedKey === stack.key ? 1 : 0.25}
|
|
161
|
+
/>
|
|
162
|
+
))
|
|
163
|
+
}
|
|
164
|
+
</AreaStack>
|
|
165
|
+
|
|
166
|
+
{syncedPoint &&
|
|
167
|
+
(() => {
|
|
168
|
+
const sx = xScale(getX(syncedPoint)) ?? 0
|
|
169
|
+
// A dot on each band's TOP edge (its cumulative stacked value), so the tooltip's
|
|
170
|
+
// per-series rows visibly attach to the boundary between that series and the one above.
|
|
171
|
+
let cum = 0
|
|
172
|
+
return (
|
|
173
|
+
<>
|
|
174
|
+
<Crosshair x={sx} top={0} bottom={yMax} />
|
|
175
|
+
{series.map((s) => {
|
|
176
|
+
cum += s.getValue(syncedPoint) ?? 0
|
|
177
|
+
return (
|
|
178
|
+
<SeriesDot key={`dot-${s.key}`} cx={sx} cy={yScale(cum)} color={s.color} />
|
|
179
|
+
)
|
|
180
|
+
})}
|
|
181
|
+
</>
|
|
182
|
+
)
|
|
183
|
+
})()}
|
|
184
|
+
|
|
185
|
+
<AxisLeftNumeric scale={yScale} numTicks={numTicksY} tickFormat={formatValue} />
|
|
186
|
+
<AxisBottomDate top={yMax} scale={xScale} tickValues={tickValues} />
|
|
187
|
+
|
|
188
|
+
<HoverOverlay width={xMax} height={yMax} onMove={handleMouse} onLeave={handleLeave} />
|
|
189
|
+
</Group>
|
|
190
|
+
</svg>
|
|
191
|
+
<ChartTooltip tip={isDirectHover ? tip : null} tooltipRef={tooltipRef} styles={tooltipStyles}>
|
|
192
|
+
{tip && isDirectHover && (
|
|
193
|
+
<>
|
|
194
|
+
<TooltipHeader date={getX(tip.data)} />
|
|
195
|
+
<TooltipBody>
|
|
196
|
+
{deriveTooltipRows(series.toReversed(), tip.data, formatValue).map((row) => (
|
|
197
|
+
<TooltipRow
|
|
198
|
+
key={row.key}
|
|
199
|
+
color={row.color}
|
|
200
|
+
label={row.label}
|
|
201
|
+
value={row.value}
|
|
202
|
+
shape={row.shape}
|
|
203
|
+
/>
|
|
204
|
+
))}
|
|
205
|
+
</TooltipBody>
|
|
206
|
+
</>
|
|
207
|
+
)}
|
|
208
|
+
</ChartTooltip>
|
|
209
|
+
</>
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Hand-memoized: React Compiler does not process the shipped dist, so we wrap the
|
|
215
|
+
* hot stacked-area kind in `React.memo` to retain the auto-memoization it had as source
|
|
216
|
+
* (parity with ZonedLine / Bars / MultiLine).
|
|
217
|
+
*/
|
|
218
|
+
export const StackedArea = memo(StackedAreaInner) as typeof StackedAreaInner
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { curveMonotoneX } from '@visx/curve'
|
|
2
|
+
import { GridRows } from '@visx/grid'
|
|
3
|
+
import { Group } from '@visx/group'
|
|
4
|
+
import { scaleLinear, scalePoint } from '@visx/scale'
|
|
5
|
+
import { AreaClosed, LinePath } from '@visx/shape'
|
|
6
|
+
import { Threshold } from '@visx/threshold'
|
|
7
|
+
import { memo, useMemo } from 'react'
|
|
8
|
+
import type { ReactNode } from 'react'
|
|
9
|
+
import { AreaGradient, areaFillUrl } from '../primitives/AreaGradient'
|
|
10
|
+
import { AxisBottomDate, AxisLeftNumeric } from '../primitives/Axes'
|
|
11
|
+
import {
|
|
12
|
+
ChartTooltip,
|
|
13
|
+
TooltipBody,
|
|
14
|
+
TooltipHeader,
|
|
15
|
+
TooltipRow,
|
|
16
|
+
useTooltipStyles,
|
|
17
|
+
} from '../primitives/ChartTooltip'
|
|
18
|
+
import { ChartFrame, resolveLegend } from '../primitives/ChartFrame'
|
|
19
|
+
import { Crosshair, SeriesDot } from '../primitives/Crosshair'
|
|
20
|
+
import { HoverOverlay } from '../primitives/HoverOverlay'
|
|
21
|
+
import { ZoneRects } from '../primitives/ZoneRects'
|
|
22
|
+
import type { ZoneSpec } from '../primitives/ZoneRects'
|
|
23
|
+
import { useHoverSync } from '../hooks/useHoverSync'
|
|
24
|
+
import { deriveTooltipRows, LINE_OVERLAY_STROKE_WIDTH } from '../series'
|
|
25
|
+
import type { ChartLegendConfig, ChartSeries } from '../series'
|
|
26
|
+
import { VX } from '../../tokens'
|
|
27
|
+
import { padAutoLower } from '../utils/domain'
|
|
28
|
+
import { smartTicks, smartTicksEvery } from '../utils/ticks'
|
|
29
|
+
|
|
30
|
+
/** @deprecated Use ZoneSpec from primitives/ZoneRects. Kept as an alias for back-compat. */
|
|
31
|
+
export type ZonedLineZone = ZoneSpec
|
|
32
|
+
|
|
33
|
+
/** Semi-transparent fill above (or below) a threshold value, tracking the line. */
|
|
34
|
+
export type ZonedLineThreshold = {
|
|
35
|
+
value: number
|
|
36
|
+
side: 'above' | 'below'
|
|
37
|
+
fill: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Dashed horizontal reference line — visual annotation only, no fill. */
|
|
41
|
+
export type ZonedLineRefLine = {
|
|
42
|
+
value: number
|
|
43
|
+
color: string
|
|
44
|
+
/** Solid by default; set true for a dashed line. */
|
|
45
|
+
dashed?: boolean
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type ZonedLineTooltipLabel = {
|
|
49
|
+
text: string
|
|
50
|
+
color: string
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type ZonedLineProps<T> = {
|
|
54
|
+
data: T[]
|
|
55
|
+
/** Fixed height in pixels, forwarded to the internal `ChartFrame`. Default 240. */
|
|
56
|
+
height?: number
|
|
57
|
+
chartId: string
|
|
58
|
+
/** Extracts the x-axis category (date string) from a data point. */
|
|
59
|
+
getX: (d: T) => string
|
|
60
|
+
/** Single-series line — the sole source of truth for color, dash, legend, and tooltip row. Pass
|
|
61
|
+
* exactly one entry (kept as an array for parity with the other kinds and so `ChartFrame` /
|
|
62
|
+
* `deriveLegend` / `deriveTooltipRows` can consume it directly). */
|
|
63
|
+
series: ChartSeries<T>[]
|
|
64
|
+
/** Fixed y-domain (e.g. [0, 100]) or 'auto' to compute from data. */
|
|
65
|
+
yDomain: [number, number] | 'auto'
|
|
66
|
+
/**
|
|
67
|
+
* When yDomain is 'auto': the upper bound is at least this value (caps data max).
|
|
68
|
+
* e.g. yAutoMaxFloor=2 guarantees the y-axis always reaches 2 even if data is smaller.
|
|
69
|
+
*/
|
|
70
|
+
yAutoMaxFloor?: number
|
|
71
|
+
/**
|
|
72
|
+
* When yDomain is 'auto': the lower bound is at most this value.
|
|
73
|
+
* Default 0 — always includes zero when data is all positive. Pass a negative
|
|
74
|
+
* number (or Infinity to disable) for metrics that can legitimately swing both ways.
|
|
75
|
+
*/
|
|
76
|
+
yAutoMinCeil?: number
|
|
77
|
+
/** Padding multiplier applied to auto-computed bounds. Default 1.1. The lower bound always pads
|
|
78
|
+
* DOWN from `min(dataMin, yAutoMinCeil)` (never up, which would clip data) — see
|
|
79
|
+
* {@link padAutoLower}. */
|
|
80
|
+
yAutoPad?: number
|
|
81
|
+
zones?: ZonedLineZone[]
|
|
82
|
+
thresholds?: ZonedLineThreshold[]
|
|
83
|
+
refLines?: ZonedLineRefLine[]
|
|
84
|
+
numTicksY?: number
|
|
85
|
+
numTicksX?: number
|
|
86
|
+
/** Label shown at the right of the tooltip header (e.g. zone name with zone color). */
|
|
87
|
+
tooltipLabel?: (d: T) => ZonedLineTooltipLabel | null
|
|
88
|
+
/** Formatter for the tooltip value. */
|
|
89
|
+
formatValue: (v: number) => string
|
|
90
|
+
/** Optional extra tooltip rows (rendered after the main row). */
|
|
91
|
+
renderExtraTooltipRows?: (d: T) => ReactNode
|
|
92
|
+
/**
|
|
93
|
+
* Opt-in soft gradient fill under the line. Pass a color token to tint the area
|
|
94
|
+
* with that hue — the modern single-hue look. `true` falls back to the series color. Off by
|
|
95
|
+
* default (a neutral fill under the neutral line just reads as grey haze). Strength is global
|
|
96
|
+
* via `--vx-area-top` / `--vx-area-bottom` (tunable in the dev theme lab).
|
|
97
|
+
*/
|
|
98
|
+
areaFill?: string | boolean
|
|
99
|
+
/** Legend config forwarded to `ChartFrame`; `false` disables the legend (sparkline escape).
|
|
100
|
+
* Default `{ placement: 'bottom' }`. */
|
|
101
|
+
legend?: ChartLegendConfig | false
|
|
102
|
+
/** Accessible text alternative, forwarded to `ChartFrame` as `aria-label` (+ `role="img"`). */
|
|
103
|
+
ariaLabel?: string
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Line chart with zone backgrounds, threshold fills, reference lines, and a
|
|
108
|
+
* shared-cursor tooltip. Covers the line-with-zones pattern. Does NOT handle
|
|
109
|
+
* dual-panel charts (keep those bespoke).
|
|
110
|
+
*
|
|
111
|
+
* Composes `ChartFrame` for measuring + the derived legend — single-series, so the legend is
|
|
112
|
+
* optional in practice but present by default (gained relative to the pre-redesign kind).
|
|
113
|
+
*
|
|
114
|
+
* X-axis is built from the full `data` array so the calendar is preserved even
|
|
115
|
+
* when the series has nulls; the line itself skips null points (creating
|
|
116
|
+
* visual gaps).
|
|
117
|
+
*/
|
|
118
|
+
function ZonedLineInner<T>(props: ZonedLineProps<T>) {
|
|
119
|
+
const { series, chartId, height, legend, ariaLabel } = props
|
|
120
|
+
|
|
121
|
+
// Default the line overlay to the redesign's 1.9px stroke (docs/DESIGN-SPEC.md §5) — applied
|
|
122
|
+
// once here so the plotted line, the derived legend swatch, and the derived tooltip row agree.
|
|
123
|
+
const styledSeries = useMemo<ChartSeries<T>[]>(
|
|
124
|
+
() => series.map((s) => ({ ...s, strokeWidth: s.strokeWidth ?? LINE_OVERLAY_STROKE_WIDTH })),
|
|
125
|
+
[series],
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<ChartFrame
|
|
130
|
+
series={styledSeries}
|
|
131
|
+
chartId={chartId}
|
|
132
|
+
{...(height !== undefined && { height })}
|
|
133
|
+
{...(ariaLabel !== undefined && { ariaLabel })}
|
|
134
|
+
legend={resolveLegend(legend)}
|
|
135
|
+
>
|
|
136
|
+
{(plot) => <ZonedLinePlot {...props} series={styledSeries} plot={plot} />}
|
|
137
|
+
</ChartFrame>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
type ZonedLinePlotProps<T> = ZonedLineProps<T> & {
|
|
142
|
+
plot: { width: number; height: number }
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** The measured plot — split from {@link ZonedLineInner} so its scale/hover-sync hooks only run
|
|
146
|
+
* once `ChartFrame` has resolved a non-empty plot rect. */
|
|
147
|
+
function ZonedLinePlot<T>(props: ZonedLinePlotProps<T>) {
|
|
148
|
+
const {
|
|
149
|
+
data,
|
|
150
|
+
chartId,
|
|
151
|
+
getX,
|
|
152
|
+
series,
|
|
153
|
+
yDomain,
|
|
154
|
+
yAutoPad = 1.1,
|
|
155
|
+
yAutoMaxFloor,
|
|
156
|
+
yAutoMinCeil = 0,
|
|
157
|
+
zones = [],
|
|
158
|
+
thresholds = [],
|
|
159
|
+
refLines = [],
|
|
160
|
+
numTicksY = 5,
|
|
161
|
+
numTicksX,
|
|
162
|
+
tooltipLabel,
|
|
163
|
+
formatValue,
|
|
164
|
+
renderExtraTooltipRows,
|
|
165
|
+
areaFill,
|
|
166
|
+
plot,
|
|
167
|
+
} = props
|
|
168
|
+
|
|
169
|
+
const primary = series[0]
|
|
170
|
+
const MARGIN = VX.margin
|
|
171
|
+
const xMax = plot.width - MARGIN.left - MARGIN.right
|
|
172
|
+
const yMax = plot.height - MARGIN.top - MARGIN.bottom
|
|
173
|
+
|
|
174
|
+
// Area is opt-in: pass a color token to get a cohesive single-hue fill under the line.
|
|
175
|
+
// (A neutral fill under the neutral line just reads as grey haze, so there is no default-on.)
|
|
176
|
+
const showArea = areaFill !== undefined && areaFill !== false
|
|
177
|
+
const areaColor = typeof areaFill === 'string' ? areaFill : primary?.color
|
|
178
|
+
const areaId = `${chartId}-area`
|
|
179
|
+
|
|
180
|
+
type Valid = T & { __y: number }
|
|
181
|
+
const valid = useMemo<Valid[]>(() => {
|
|
182
|
+
const out: Valid[] = []
|
|
183
|
+
for (const d of data) {
|
|
184
|
+
const y = primary?.getValue(d) ?? null
|
|
185
|
+
if (y !== null && y !== undefined && !Number.isNaN(y)) {
|
|
186
|
+
out.push(Object.assign({}, d, { __y: y }) as Valid)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return out
|
|
190
|
+
}, [data, primary])
|
|
191
|
+
|
|
192
|
+
const xScale = useMemo(
|
|
193
|
+
() =>
|
|
194
|
+
scalePoint<string>({
|
|
195
|
+
// Full calendar — axis does not compress across nulls.
|
|
196
|
+
domain: data.map(getX),
|
|
197
|
+
range: [0, xMax],
|
|
198
|
+
padding: 0.3,
|
|
199
|
+
}),
|
|
200
|
+
[data, xMax, getX],
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
const yScale = useMemo(() => {
|
|
204
|
+
if (yDomain === 'auto') {
|
|
205
|
+
const ys = valid.map((d) => d.__y)
|
|
206
|
+
const dataMax = ys.length ? Math.max(...ys) : 0
|
|
207
|
+
const dataMin = ys.length ? Math.min(...ys) : 0
|
|
208
|
+
const upper = Math.max(dataMax, yAutoMaxFloor ?? dataMax) * yAutoPad
|
|
209
|
+
const lower = padAutoLower(Math.min(dataMin, yAutoMinCeil), yAutoPad)
|
|
210
|
+
return scaleLinear<number>({ domain: [lower, upper], range: [yMax, 0], nice: true })
|
|
211
|
+
}
|
|
212
|
+
return scaleLinear<number>({ domain: yDomain, range: [yMax, 0] })
|
|
213
|
+
}, [valid, yDomain, yMax, yAutoPad, yAutoMaxFloor, yAutoMinCeil])
|
|
214
|
+
|
|
215
|
+
const tooltipStyles = useTooltipStyles()
|
|
216
|
+
const { tip, tooltipRef, syncedPoint, isDirectHover, handleMouse, handleLeave } =
|
|
217
|
+
useHoverSync<Valid>({
|
|
218
|
+
data: valid,
|
|
219
|
+
chartId,
|
|
220
|
+
getKey: getX,
|
|
221
|
+
xScale,
|
|
222
|
+
marginLeft: MARGIN.left,
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
const tickValues = useMemo(
|
|
226
|
+
() =>
|
|
227
|
+
numTicksX ? smartTicksEvery(data.map(getX), numTicksX) : smartTicks(data.map(getX), xMax),
|
|
228
|
+
[data, xMax, getX, numTicksX],
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
const tooltipLbl = tip ? (tooltipLabel?.(tip.data) ?? null) : null
|
|
232
|
+
|
|
233
|
+
return (
|
|
234
|
+
<>
|
|
235
|
+
<svg width={plot.width} height={plot.height}>
|
|
236
|
+
<Group left={MARGIN.left} top={MARGIN.top}>
|
|
237
|
+
<GridRows scale={yScale} width={xMax} stroke={VX.grid} numTicks={numTicksY} />
|
|
238
|
+
|
|
239
|
+
<ZoneRects zones={zones} width={xMax} leftScale={yScale} />
|
|
240
|
+
|
|
241
|
+
{thresholds.map((t, i) => (
|
|
242
|
+
<Threshold<Valid>
|
|
243
|
+
key={`thr-${i}`}
|
|
244
|
+
id={`${chartId}-thr-${i}`}
|
|
245
|
+
data={valid}
|
|
246
|
+
x={(d) => xScale(getX(d)) ?? 0}
|
|
247
|
+
y0={() => yScale(t.value)}
|
|
248
|
+
y1={(d) => yScale(d.__y)}
|
|
249
|
+
clipAboveTo={0}
|
|
250
|
+
clipBelowTo={yMax}
|
|
251
|
+
curve={curveMonotoneX}
|
|
252
|
+
belowAreaProps={{ fill: t.side === 'above' ? t.fill : 'transparent' }}
|
|
253
|
+
aboveAreaProps={{ fill: t.side === 'below' ? t.fill : 'transparent' }}
|
|
254
|
+
/>
|
|
255
|
+
))}
|
|
256
|
+
|
|
257
|
+
{showArea && areaColor !== undefined && (
|
|
258
|
+
<>
|
|
259
|
+
<defs>
|
|
260
|
+
<AreaGradient id={areaId} color={areaColor} />
|
|
261
|
+
</defs>
|
|
262
|
+
<AreaClosed<Valid>
|
|
263
|
+
data={valid}
|
|
264
|
+
x={(d) => xScale(getX(d)) ?? 0}
|
|
265
|
+
y={(d) => yScale(d.__y)}
|
|
266
|
+
yScale={yScale}
|
|
267
|
+
curve={curveMonotoneX}
|
|
268
|
+
fill={areaFillUrl(areaId)}
|
|
269
|
+
/>
|
|
270
|
+
</>
|
|
271
|
+
)}
|
|
272
|
+
|
|
273
|
+
{refLines.map((r, i) => (
|
|
274
|
+
<line
|
|
275
|
+
key={`ref-${i}`}
|
|
276
|
+
x1={0}
|
|
277
|
+
x2={xMax}
|
|
278
|
+
y1={yScale(r.value)}
|
|
279
|
+
y2={yScale(r.value)}
|
|
280
|
+
stroke={r.color}
|
|
281
|
+
strokeDasharray={r.dashed ? VX.dashArray : undefined}
|
|
282
|
+
/>
|
|
283
|
+
))}
|
|
284
|
+
|
|
285
|
+
{primary && (
|
|
286
|
+
<LinePath<Valid>
|
|
287
|
+
data={valid}
|
|
288
|
+
x={(d) => xScale(getX(d)) ?? 0}
|
|
289
|
+
y={(d) => yScale(d.__y)}
|
|
290
|
+
stroke={primary.color}
|
|
291
|
+
strokeWidth={primary.strokeWidth ?? VX.lineWidth}
|
|
292
|
+
strokeDasharray={primary.dash === 'dashed' ? VX.dashArray : undefined}
|
|
293
|
+
curve={curveMonotoneX}
|
|
294
|
+
/>
|
|
295
|
+
)}
|
|
296
|
+
|
|
297
|
+
{syncedPoint && primary && (
|
|
298
|
+
<>
|
|
299
|
+
<Crosshair x={xScale(getX(syncedPoint)) ?? 0} top={0} bottom={yMax} />
|
|
300
|
+
<SeriesDot
|
|
301
|
+
cx={xScale(getX(syncedPoint)) ?? 0}
|
|
302
|
+
cy={yScale(syncedPoint.__y)}
|
|
303
|
+
color={primary.color}
|
|
304
|
+
/>
|
|
305
|
+
</>
|
|
306
|
+
)}
|
|
307
|
+
|
|
308
|
+
<AxisLeftNumeric scale={yScale} numTicks={numTicksY} />
|
|
309
|
+
<AxisBottomDate top={yMax} scale={xScale} tickValues={tickValues} />
|
|
310
|
+
|
|
311
|
+
<HoverOverlay width={xMax} height={yMax} onMove={handleMouse} onLeave={handleLeave} />
|
|
312
|
+
</Group>
|
|
313
|
+
</svg>
|
|
314
|
+
<ChartTooltip tip={isDirectHover ? tip : null} tooltipRef={tooltipRef} styles={tooltipStyles}>
|
|
315
|
+
{tip && isDirectHover && (
|
|
316
|
+
<>
|
|
317
|
+
<TooltipHeader
|
|
318
|
+
date={getX(tip.data)}
|
|
319
|
+
{...(tooltipLbl !== null && { label: tooltipLbl.text, labelColor: tooltipLbl.color })}
|
|
320
|
+
/>
|
|
321
|
+
<TooltipBody>
|
|
322
|
+
{deriveTooltipRows(series, tip.data, formatValue).map((row) => (
|
|
323
|
+
<TooltipRow
|
|
324
|
+
key={row.key}
|
|
325
|
+
color={row.color}
|
|
326
|
+
label={row.label}
|
|
327
|
+
value={row.value}
|
|
328
|
+
shape={row.shape}
|
|
329
|
+
dashed={row.dashed}
|
|
330
|
+
{...(row.strokeWidth !== undefined && { strokeWidth: row.strokeWidth })}
|
|
331
|
+
/>
|
|
332
|
+
))}
|
|
333
|
+
{renderExtraTooltipRows?.(tip.data)}
|
|
334
|
+
</TooltipBody>
|
|
335
|
+
</>
|
|
336
|
+
)}
|
|
337
|
+
</ChartTooltip>
|
|
338
|
+
</>
|
|
339
|
+
)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Hand-memoized: React Compiler does not process the shipped dist, so the hot ZonedLine kind is
|
|
344
|
+
* wrapped in `React.memo` to retain the auto-memoization it had as source (parity with Bars).
|
|
345
|
+
*/
|
|
346
|
+
export const ZonedLine = memo(ZonedLineInner) as typeof ZonedLineInner
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AreaGradient — the single source for the soft single-hue area fill under a line.
|
|
3
|
+
*
|
|
4
|
+
* Renders a vertical <linearGradient> that fades a series/line color from `--vx-area-top`
|
|
5
|
+
* opacity at the data peak to `--vx-area-bottom` at the baseline. Both stops are
|
|
6
|
+
* `color-mix` of a CSS-var color, so they stay theme-aware AND the dev theme lab can retune
|
|
7
|
+
* the whole app's gradient strength by overriding two vars on :root — no chart edits.
|
|
8
|
+
*
|
|
9
|
+
* Usage (inside an <svg>):
|
|
10
|
+
* <defs><AreaGradient id={`${chartId}-area`} color={VX.line} /></defs>
|
|
11
|
+
* <AreaClosed ... fill={areaFillUrl(`${chartId}-area`)} />
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const areaStop = (color: string, edge: 'top' | 'bottom'): string =>
|
|
15
|
+
`color-mix(in srgb, ${color} var(--vx-area-${edge}), transparent)`
|
|
16
|
+
|
|
17
|
+
export function AreaGradient({ id, color }: { id: string; color: string }) {
|
|
18
|
+
return (
|
|
19
|
+
<linearGradient id={id} x1="0" x2="0" y1="0" y2="1">
|
|
20
|
+
<stop offset="0%" stopColor={areaStop(color, 'top')} />
|
|
21
|
+
<stop offset="100%" stopColor={areaStop(color, 'bottom')} />
|
|
22
|
+
</linearGradient>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const areaFillUrl = (id: string): string => `url(#${id})`
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { AxisBottom, AxisLeft, AxisRight } from '@visx/axis'
|
|
2
|
+
import type { AxisScale, TickFormatter } from '@visx/axis'
|
|
3
|
+
import { VX } from '../../tokens'
|
|
4
|
+
import { fmtAxisDate } from '../utils/format'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Tick label font — mono, per `docs/DESIGN-SPEC.md` §5 ("ticks mono 10.5px faint"). Not a `VX.*`
|
|
8
|
+
* ref (the token layer is off-limits to font-family additions here) — a plain reference to the
|
|
9
|
+
* `--basalt-font-mono` var that `styles.css` already defines.
|
|
10
|
+
*/
|
|
11
|
+
const TICK_FONT_FAMILY = 'var(--basalt-font-mono)'
|
|
12
|
+
|
|
13
|
+
/** Themed left numeric axis — baked-in theme colors + font size. */
|
|
14
|
+
export function AxisLeftNumeric({
|
|
15
|
+
scale,
|
|
16
|
+
numTicks = 5,
|
|
17
|
+
tickFormat,
|
|
18
|
+
}: {
|
|
19
|
+
scale: AxisScale
|
|
20
|
+
numTicks?: number
|
|
21
|
+
tickFormat?: TickFormatter<number>
|
|
22
|
+
}) {
|
|
23
|
+
return (
|
|
24
|
+
<AxisLeft
|
|
25
|
+
scale={scale}
|
|
26
|
+
numTicks={numTicks}
|
|
27
|
+
{...(tickFormat !== undefined && { tickFormat })}
|
|
28
|
+
tickLabelProps={{
|
|
29
|
+
fill: VX.faint,
|
|
30
|
+
fontFamily: TICK_FONT_FAMILY,
|
|
31
|
+
fontSize: VX.axisFont,
|
|
32
|
+
dx: -4,
|
|
33
|
+
}}
|
|
34
|
+
stroke={VX.surface.border}
|
|
35
|
+
tickStroke={VX.surface.border}
|
|
36
|
+
/>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Themed right numeric axis — mirrors AxisLeftNumeric for dual-axis charts. */
|
|
41
|
+
export function AxisRightNumeric({
|
|
42
|
+
scale,
|
|
43
|
+
left,
|
|
44
|
+
numTicks = 5,
|
|
45
|
+
tickFormat,
|
|
46
|
+
}: {
|
|
47
|
+
scale: AxisScale
|
|
48
|
+
/** Left offset inside the Group (typically xMax). Required since AxisRight needs positioning. */
|
|
49
|
+
left: number
|
|
50
|
+
numTicks?: number
|
|
51
|
+
tickFormat?: TickFormatter<number>
|
|
52
|
+
}) {
|
|
53
|
+
return (
|
|
54
|
+
<AxisRight
|
|
55
|
+
left={left}
|
|
56
|
+
scale={scale}
|
|
57
|
+
numTicks={numTicks}
|
|
58
|
+
{...(tickFormat !== undefined && { tickFormat })}
|
|
59
|
+
tickLabelProps={{
|
|
60
|
+
fill: VX.faint,
|
|
61
|
+
fontFamily: TICK_FONT_FAMILY,
|
|
62
|
+
fontSize: VX.axisFont,
|
|
63
|
+
dx: 4,
|
|
64
|
+
}}
|
|
65
|
+
stroke={VX.surface.border}
|
|
66
|
+
tickStroke={VX.surface.border}
|
|
67
|
+
/>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Themed bottom date axis — baked-in smartTicks + DD.MM formatting. */
|
|
72
|
+
export function AxisBottomDate({
|
|
73
|
+
scale,
|
|
74
|
+
top,
|
|
75
|
+
tickValues,
|
|
76
|
+
}: {
|
|
77
|
+
scale: AxisScale
|
|
78
|
+
top: number
|
|
79
|
+
tickValues: string[]
|
|
80
|
+
}) {
|
|
81
|
+
return (
|
|
82
|
+
<AxisBottom
|
|
83
|
+
top={top}
|
|
84
|
+
scale={scale}
|
|
85
|
+
tickValues={tickValues}
|
|
86
|
+
tickFormat={fmtAxisDate}
|
|
87
|
+
tickLabelProps={{
|
|
88
|
+
fill: VX.faint,
|
|
89
|
+
fontFamily: TICK_FONT_FAMILY,
|
|
90
|
+
fontSize: VX.axisFont,
|
|
91
|
+
textAnchor: 'middle',
|
|
92
|
+
}}
|
|
93
|
+
stroke={VX.surface.border}
|
|
94
|
+
tickStroke={VX.surface.border}
|
|
95
|
+
/>
|
|
96
|
+
)
|
|
97
|
+
}
|