basalt-ui 0.3.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +70 -0
- package/CHANGELOG.md +216 -26
- package/LICENSE +201 -0
- package/README.md +434 -160
- package/agent/rules/basalt-agent.md +395 -0
- package/agent/rules/basalt-charts.md +170 -0
- package/agent/rules/basalt-commands.md +320 -0
- package/agent/rules/basalt-content.md +390 -0
- package/agent/rules/basalt-data.md +237 -0
- package/agent/rules/basalt-forms.md +186 -0
- package/agent/rules/basalt-mantine.md +327 -0
- package/agent/rules/basalt-notifications.md +264 -0
- package/agent/rules/basalt-query.md +130 -0
- package/agent/rules/basalt-router.md +173 -0
- package/agent/rules/basalt-state.md +99 -0
- package/agent/rules/basalt-tokens.md +148 -0
- package/agent/templates/CLAUDE-block.md.tpl +35 -0
- package/agent/templates/DESIGN.md.tpl +71 -0
- package/agent/templates/__root.tpl +31 -0
- package/agent/templates/query-client.ts.tpl +12 -0
- package/bin/basalt.mjs +14 -0
- package/configs/check.yml +29 -0
- package/configs/lefthook.yml +21 -0
- package/configs/oxfmt.json +8 -0
- package/configs/oxlint-plugin.js +269 -0
- package/configs/oxlint-plugin.test.ts +107 -0
- package/configs/oxlint.json +116 -0
- package/configs/tsconfig.base.json +20 -0
- package/configs/tsconfig.node.json +8 -0
- package/configs/tsconfig.react-app.json +8 -0
- package/dist/agent/ai-sdk-transport.d.ts +85 -0
- package/dist/agent/ai-sdk-transport.d.ts.map +1 -0
- package/dist/agent/ai-sdk-transport.js +109 -0
- package/dist/agent/history.d.ts +55 -0
- package/dist/agent/history.d.ts.map +1 -0
- package/dist/agent/history.js +32 -0
- package/dist/agent/index.d.ts +53 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +23 -0
- package/dist/agent/outcome.d.ts +71 -0
- package/dist/agent/outcome.d.ts.map +1 -0
- package/dist/agent/outcome.js +30 -0
- package/dist/agent/part-list.d.ts +75 -0
- package/dist/agent/part-list.d.ts.map +1 -0
- package/dist/agent/part-list.js +127 -0
- package/dist/agent/parts.d.ts +91 -0
- package/dist/agent/parts.d.ts.map +1 -0
- package/dist/agent/parts.js +49 -0
- package/dist/agent/stick-to-bottom.d.ts +23 -0
- package/dist/agent/stick-to-bottom.d.ts.map +1 -0
- package/dist/agent/stick-to-bottom.js +73 -0
- package/dist/agent/thread.d.ts +124 -0
- package/dist/agent/thread.d.ts.map +1 -0
- package/dist/agent/thread.js +131 -0
- package/dist/agent/transport.d.ts +87 -0
- package/dist/agent/transport.d.ts.map +1 -0
- package/dist/agent/transport.js +21 -0
- package/dist/agent/use-agent-stream.d.ts +34 -0
- package/dist/agent/use-agent-stream.d.ts.map +1 -0
- package/dist/agent/use-agent-stream.js +56 -0
- package/dist/agent/use-agent-thread-runs.d.ts +72 -0
- package/dist/agent/use-agent-thread-runs.d.ts.map +1 -0
- package/dist/agent/use-agent-thread-runs.js +217 -0
- package/dist/agent-chat/composer.d.ts +18 -0
- package/dist/agent-chat/composer.d.ts.map +1 -0
- package/dist/agent-chat/composer.js +86 -0
- package/dist/agent-chat/index.d.ts +24 -0
- package/dist/agent-chat/index.d.ts.map +1 -0
- package/dist/agent-chat/index.js +15 -0
- package/dist/agent-chat/thread-detail-panel.d.ts +27 -0
- package/dist/agent-chat/thread-detail-panel.d.ts.map +1 -0
- package/dist/agent-chat/thread-detail-panel.js +108 -0
- package/dist/agent-chat/thread-feed.d.ts +18 -0
- package/dist/agent-chat/thread-feed.d.ts.map +1 -0
- package/dist/agent-chat/thread-feed.js +42 -0
- package/dist/agent-chat/thread-message.d.ts +31 -0
- package/dist/agent-chat/thread-message.d.ts.map +1 -0
- package/dist/agent-chat/thread-message.js +128 -0
- package/dist/agent-chat/thread-outcome-card.d.ts +19 -0
- package/dist/agent-chat/thread-outcome-card.d.ts.map +1 -0
- package/dist/agent-chat/thread-outcome-card.js +120 -0
- package/dist/agent-chat/thread-workspace.d.ts +27 -0
- package/dist/agent-chat/thread-workspace.d.ts.map +1 -0
- package/dist/agent-chat/thread-workspace.js +95 -0
- package/dist/charts/hooks/useChartSize.d.ts +25 -0
- package/dist/charts/hooks/useChartSize.d.ts.map +1 -0
- package/dist/charts/hooks/useChartSize.js +8 -0
- package/dist/charts/hooks/useChartTooltip.d.ts +13 -0
- package/dist/charts/hooks/useChartTooltip.d.ts.map +1 -0
- package/dist/charts/hooks/useChartTooltip.js +26 -0
- package/dist/charts/hooks/useHoverSync.d.ts +30 -0
- package/dist/charts/hooks/useHoverSync.d.ts.map +1 -0
- package/dist/charts/hooks/useHoverSync.js +70 -0
- package/dist/charts/hover-context.d.ts +21 -0
- package/dist/charts/hover-context.d.ts.map +1 -0
- package/dist/charts/hover-context.js +12 -0
- package/dist/charts/hover-sync.d.ts +14 -0
- package/dist/charts/hover-sync.d.ts.map +1 -0
- package/dist/charts/hover-sync.js +17 -0
- package/dist/charts/index.d.ts +47 -0
- package/dist/charts/index.d.ts.map +1 -0
- package/dist/charts/index.js +129 -0
- package/dist/charts/kinds/Bars.d.ts +129 -0
- package/dist/charts/kinds/Bars.d.ts.map +1 -0
- package/dist/charts/kinds/Bars.js +467 -0
- package/dist/charts/kinds/Donut.d.ts +65 -0
- package/dist/charts/kinds/Donut.d.ts.map +1 -0
- package/dist/charts/kinds/Donut.js +158 -0
- package/dist/charts/kinds/DualPanel.d.ts +67 -0
- package/dist/charts/kinds/DualPanel.d.ts.map +1 -0
- package/dist/charts/kinds/DualPanel.js +326 -0
- package/dist/charts/kinds/Heatmap.d.ts +59 -0
- package/dist/charts/kinds/Heatmap.d.ts.map +1 -0
- package/dist/charts/kinds/Heatmap.js +175 -0
- package/dist/charts/kinds/MultiLine.d.ts +73 -0
- package/dist/charts/kinds/MultiLine.d.ts.map +1 -0
- package/dist/charts/kinds/MultiLine.js +275 -0
- package/dist/charts/kinds/StackedArea.d.ts +35 -0
- package/dist/charts/kinds/StackedArea.d.ts.map +1 -0
- package/dist/charts/kinds/StackedArea.js +151 -0
- package/dist/charts/kinds/ZonedLine.d.ts +94 -0
- package/dist/charts/kinds/ZonedLine.d.ts.map +1 -0
- package/dist/charts/kinds/ZonedLine.js +218 -0
- package/dist/charts/primitives/AreaGradient.d.ts +18 -0
- package/dist/charts/primitives/AreaGradient.d.ts.map +1 -0
- package/dist/charts/primitives/AreaGradient.js +13 -0
- package/dist/charts/primitives/Axes.d.ts +22 -0
- package/dist/charts/primitives/Axes.d.ts.map +1 -0
- package/dist/charts/primitives/Axes.js +79 -0
- package/dist/charts/primitives/ChartCard.d.ts +14 -0
- package/dist/charts/primitives/ChartCard.d.ts.map +1 -0
- package/dist/charts/primitives/ChartCard.js +144 -0
- package/dist/charts/primitives/ChartFrame.d.ts +70 -0
- package/dist/charts/primitives/ChartFrame.d.ts.map +1 -0
- package/dist/charts/primitives/ChartFrame.js +77 -0
- package/dist/charts/primitives/ChartLegend.d.ts +36 -0
- package/dist/charts/primitives/ChartLegend.d.ts.map +1 -0
- package/dist/charts/primitives/ChartLegend.js +234 -0
- package/dist/charts/primitives/ChartTooltip.d.ts +34 -0
- package/dist/charts/primitives/ChartTooltip.d.ts.map +1 -0
- package/dist/charts/primitives/ChartTooltip.js +134 -0
- package/dist/charts/primitives/Crosshair.d.ts +23 -0
- package/dist/charts/primitives/Crosshair.d.ts.map +1 -0
- package/dist/charts/primitives/Crosshair.js +21 -0
- package/dist/charts/primitives/HoverOverlay.d.ts +9 -0
- package/dist/charts/primitives/HoverOverlay.d.ts.map +1 -0
- package/dist/charts/primitives/HoverOverlay.js +21 -0
- package/dist/charts/primitives/ResponsiveChart.d.ts +45 -0
- package/dist/charts/primitives/ResponsiveChart.d.ts.map +1 -0
- package/dist/charts/primitives/ResponsiveChart.js +24 -0
- package/dist/charts/primitives/ZoneRects.d.ts +38 -0
- package/dist/charts/primitives/ZoneRects.d.ts.map +1 -0
- package/dist/charts/primitives/ZoneRects.js +30 -0
- package/dist/charts/series.d.ts +99 -0
- package/dist/charts/series.d.ts.map +1 -0
- package/dist/charts/series.js +55 -0
- package/dist/charts/sparklines/BarSparkline.d.ts +13 -0
- package/dist/charts/sparklines/BarSparkline.d.ts.map +1 -0
- package/dist/charts/sparklines/BarSparkline.js +33 -0
- package/dist/charts/sparklines/LineSparkline.d.ts +15 -0
- package/dist/charts/sparklines/LineSparkline.d.ts.map +1 -0
- package/dist/charts/sparklines/LineSparkline.js +39 -0
- package/dist/charts/sparklines/index.d.ts +3 -0
- package/dist/charts/sparklines/index.d.ts.map +1 -0
- package/dist/charts/sparklines/index.js +6 -0
- package/dist/charts/theme.d.ts +21 -0
- package/dist/charts/theme.d.ts.map +1 -0
- package/dist/charts/theme.js +30 -0
- package/dist/charts/utils/domain.d.ts +20 -0
- package/dist/charts/utils/domain.d.ts.map +1 -0
- package/dist/charts/utils/domain.js +7 -0
- package/dist/charts/utils/format.d.ts +5 -0
- package/dist/charts/utils/format.d.ts.map +1 -0
- package/dist/charts/utils/format.js +27 -0
- package/dist/charts/utils/ticks.d.ts +5 -0
- package/dist/charts/utils/ticks.d.ts.map +1 -0
- package/dist/charts/utils/ticks.js +18 -0
- package/dist/cli/index.d.ts +273 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +907 -0
- package/dist/commands/ShortcutsHelp.d.ts +17 -0
- package/dist/commands/ShortcutsHelp.d.ts.map +1 -0
- package/dist/commands/ShortcutsHelp.js +64 -0
- package/dist/commands/define-commands.d.ts +140 -0
- package/dist/commands/define-commands.d.ts.map +1 -0
- package/dist/commands/define-commands.js +26 -0
- package/dist/commands/define-overlays.d.ts +134 -0
- package/dist/commands/define-overlays.d.ts.map +1 -0
- package/dist/commands/define-overlays.js +53 -0
- package/dist/commands/index.d.ts +42 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +46 -0
- package/dist/commands/overlays-mount.d.ts +117 -0
- package/dist/commands/overlays-mount.d.ts.map +1 -0
- package/dist/commands/overlays-mount.js +116 -0
- package/dist/commands/projectors.d.ts +152 -0
- package/dist/commands/projectors.d.ts.map +1 -0
- package/dist/commands/projectors.js +87 -0
- package/dist/commands/shortcut-format.d.ts +48 -0
- package/dist/commands/shortcut-format.d.ts.map +1 -0
- package/dist/commands/shortcut-format.js +33 -0
- package/dist/commands/useCommandHotkeys.d.ts +14 -0
- package/dist/commands/useCommandHotkeys.d.ts.map +1 -0
- package/dist/commands/useCommandHotkeys.js +45 -0
- package/dist/connectivity/connectivity-indicator.d.ts +8 -0
- package/dist/connectivity/connectivity-indicator.d.ts.map +1 -0
- package/dist/connectivity/connectivity-indicator.js +203 -0
- package/dist/connectivity/connectivity-provider.d.ts +7 -0
- package/dist/connectivity/connectivity-provider.d.ts.map +1 -0
- package/dist/connectivity/connectivity-provider.js +125 -0
- package/dist/connectivity/index.d.ts +13 -0
- package/dist/connectivity/index.d.ts.map +1 -0
- package/dist/connectivity/index.js +8 -0
- package/dist/connectivity/types.d.ts +36 -0
- package/dist/connectivity/types.d.ts.map +1 -0
- package/dist/connectivity/types.js +0 -0
- package/dist/connectivity/use-connectivity.d.ts +3 -0
- package/dist/connectivity/use-connectivity.d.ts.map +1 -0
- package/dist/connectivity/use-connectivity.js +14 -0
- package/dist/content/article-actions.d.ts +39 -0
- package/dist/content/article-actions.d.ts.map +1 -0
- package/dist/content/article-actions.js +28 -0
- package/dist/content/article-card.d.ts +58 -0
- package/dist/content/article-card.d.ts.map +1 -0
- package/dist/content/article-card.js +76 -0
- package/dist/content/article-card.module.css +109 -0
- package/dist/content/article-card.module.css.d.ts +16 -0
- package/dist/content/article-filter-bar.d.ts +40 -0
- package/dist/content/article-filter-bar.d.ts.map +1 -0
- package/dist/content/article-filter-bar.js +56 -0
- package/dist/content/article-layout.d.ts +61 -0
- package/dist/content/article-layout.d.ts.map +1 -0
- package/dist/content/article-layout.js +71 -0
- package/dist/content/article-layout.module.css +131 -0
- package/dist/content/article-layout.module.css.d.ts +20 -0
- package/dist/content/article-model.d.ts +62 -0
- package/dist/content/article-model.d.ts.map +1 -0
- package/dist/content/article-model.js +41 -0
- package/dist/content/block-split.d.ts +24 -0
- package/dist/content/block-split.d.ts.map +1 -0
- package/dist/content/block-split.js +63 -0
- package/dist/content/callout-alert.d.ts +27 -0
- package/dist/content/callout-alert.d.ts.map +1 -0
- package/dist/content/callout-alert.js +59 -0
- package/dist/content/callout.d.ts +24 -0
- package/dist/content/callout.d.ts.map +1 -0
- package/dist/content/callout.js +59 -0
- package/dist/content/callout.module.css +77 -0
- package/dist/content/callout.module.css.d.ts +16 -0
- package/dist/content/code-block.d.ts +26 -0
- package/dist/content/code-block.d.ts.map +1 -0
- package/dist/content/code-block.js +41 -0
- package/dist/content/code-block.module.css +86 -0
- package/dist/content/code-block.module.css.d.ts +14 -0
- package/dist/content/copy-action.d.ts +29 -0
- package/dist/content/copy-action.d.ts.map +1 -0
- package/dist/content/copy-action.js +46 -0
- package/dist/content/fence-block.d.ts +19 -0
- package/dist/content/fence-block.d.ts.map +1 -0
- package/dist/content/fence-block.js +23 -0
- package/dist/content/glyphs.d.ts +18 -0
- package/dist/content/glyphs.d.ts.map +1 -0
- package/dist/content/glyphs.js +43 -0
- package/dist/content/guide.d.ts +47 -0
- package/dist/content/guide.d.ts.map +1 -0
- package/dist/content/guide.js +110 -0
- package/dist/content/guide.module.css +62 -0
- package/dist/content/guide.module.css.d.ts +13 -0
- package/dist/content/heading-anchor.d.ts +8 -0
- package/dist/content/heading-anchor.d.ts.map +1 -0
- package/dist/content/heading-anchor.js +23 -0
- package/dist/content/heading-components.d.ts +5 -0
- package/dist/content/heading-components.d.ts.map +1 -0
- package/dist/content/heading-components.js +41 -0
- package/dist/content/highlighter.d.ts +8 -0
- package/dist/content/highlighter.d.ts.map +1 -0
- package/dist/content/highlighter.js +85 -0
- package/dist/content/index.d.ts +45 -0
- package/dist/content/index.d.ts.map +1 -0
- package/dist/content/index.js +43 -0
- package/dist/content/markdown-hast.d.ts +23 -0
- package/dist/content/markdown-hast.d.ts.map +1 -0
- package/dist/content/markdown-hast.js +48 -0
- package/dist/content/markdown.d.ts +68 -0
- package/dist/content/markdown.d.ts.map +1 -0
- package/dist/content/markdown.js +180 -0
- package/dist/content/mdx.d.ts +20 -0
- package/dist/content/mdx.d.ts.map +1 -0
- package/dist/content/mdx.js +64 -0
- package/dist/content/mermaid.d.ts +32 -0
- package/dist/content/mermaid.d.ts.map +1 -0
- package/dist/content/mermaid.js +70 -0
- package/dist/content/mermaid.module.css +20 -0
- package/dist/content/mermaid.module.css.d.ts +8 -0
- package/dist/content/prose.d.ts +29 -0
- package/dist/content/prose.d.ts.map +1 -0
- package/dist/content/prose.js +24 -0
- package/dist/content/prose.module.css +330 -0
- package/dist/content/prose.module.css.d.ts +12 -0
- package/dist/content/reading-progress.d.ts +20 -0
- package/dist/content/reading-progress.d.ts.map +1 -0
- package/dist/content/reading-progress.js +38 -0
- package/dist/content/reading-progress.module.css +22 -0
- package/dist/content/reading-progress.module.css.d.ts +9 -0
- package/dist/content/slug.d.ts +28 -0
- package/dist/content/slug.d.ts.map +1 -0
- package/dist/content/slug.js +28 -0
- package/dist/content/toc.d.ts +37 -0
- package/dist/content/toc.d.ts.map +1 -0
- package/dist/content/toc.js +134 -0
- package/dist/content/toc.module.css +51 -0
- package/dist/content/toc.module.css.d.ts +13 -0
- package/dist/content/url-hardening.d.ts +23 -0
- package/dist/content/url-hardening.d.ts.map +1 -0
- package/dist/content/url-hardening.js +23 -0
- package/dist/dashboard/delta-badge.d.ts +13 -0
- package/dist/dashboard/delta-badge.d.ts.map +1 -0
- package/dist/dashboard/delta-badge.js +45 -0
- package/dist/dashboard/empty-state.d.ts +15 -0
- package/dist/dashboard/empty-state.d.ts.map +1 -0
- package/dist/dashboard/empty-state.js +56 -0
- package/dist/dashboard/index.d.ts +5 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +16 -0
- package/dist/dashboard/settings-section.d.ts +24 -0
- package/dist/dashboard/settings-section.d.ts.map +1 -0
- package/dist/dashboard/settings-section.js +61 -0
- package/dist/dashboard/settings-section.module.css +23 -0
- package/dist/dashboard/settings-section.module.css.d.ts +10 -0
- package/dist/dashboard/stat-card.d.ts +18 -0
- package/dist/dashboard/stat-card.d.ts.map +1 -0
- package/dist/dashboard/stat-card.js +74 -0
- package/dist/data/data-table.d.ts +198 -0
- package/dist/data/data-table.d.ts.map +1 -0
- package/dist/data/data-table.js +342 -0
- package/dist/data/index.d.ts +34 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +2 -0
- package/dist/data/table.d.ts +24 -0
- package/dist/data/table.d.ts.map +1 -0
- package/dist/data/table.js +20 -0
- package/dist/data/virtual-list.d.ts +74 -0
- package/dist/data/virtual-list.d.ts.map +1 -0
- package/dist/data/virtual-list.js +86 -0
- package/dist/data/virtual.d.ts +20 -0
- package/dist/data/virtual.d.ts.map +1 -0
- package/dist/data/virtual.js +4 -0
- package/dist/forms/FormErrorSummary.d.ts +29 -0
- package/dist/forms/FormErrorSummary.d.ts.map +1 -0
- package/dist/forms/FormErrorSummary.js +28 -0
- package/dist/forms/create-form.d.ts +31 -0
- package/dist/forms/create-form.d.ts.map +1 -0
- package/dist/forms/create-form.js +18 -0
- package/dist/forms/field.d.ts +22 -0
- package/dist/forms/field.d.ts.map +1 -0
- package/dist/forms/field.js +9 -0
- package/dist/forms/index.d.ts +17 -0
- package/dist/forms/index.d.ts.map +1 -0
- package/dist/forms/index.js +13 -0
- package/dist/forms/use-form-draft.d.ts +61 -0
- package/dist/forms/use-form-draft.d.ts.map +1 -0
- package/dist/forms/use-form-draft.js +55 -0
- package/dist/guard/guard-hook.d.ts +40 -0
- package/dist/guard/guard-hook.d.ts.map +1 -0
- package/dist/guard/guard-hook.js +55 -0
- package/dist/guard/index.d.ts +144 -0
- package/dist/guard/index.d.ts.map +1 -0
- package/dist/guard/index.js +315 -0
- package/dist/guard/types.d.ts +97 -0
- package/dist/guard/types.d.ts.map +1 -0
- package/dist/guard/types.js +0 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +90 -0
- package/dist/motion/index.d.ts +29 -0
- package/dist/motion/index.d.ts.map +1 -0
- package/dist/motion/index.js +12 -0
- package/dist/notifications/bell.d.ts +12 -0
- package/dist/notifications/bell.d.ts.map +1 -0
- package/dist/notifications/bell.js +84 -0
- package/dist/notifications/center.d.ts +20 -0
- package/dist/notifications/center.d.ts.map +1 -0
- package/dist/notifications/center.js +144 -0
- package/dist/notifications/define-notifications.d.ts +97 -0
- package/dist/notifications/define-notifications.d.ts.map +1 -0
- package/dist/notifications/define-notifications.js +27 -0
- package/dist/notifications/index.d.ts +36 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +52 -0
- package/dist/notifications/notify.d.ts +92 -0
- package/dist/notifications/notify.d.ts.map +1 -0
- package/dist/notifications/notify.js +127 -0
- package/dist/notifications/overlay.d.ts +20 -0
- package/dist/notifications/overlay.d.ts.map +1 -0
- package/dist/notifications/overlay.js +12 -0
- package/dist/notifications/store.d.ts +120 -0
- package/dist/notifications/store.d.ts.map +1 -0
- package/dist/notifications/store.js +113 -0
- package/dist/provider/index.d.ts +93 -0
- package/dist/provider/index.d.ts.map +1 -0
- package/dist/provider/index.js +106 -0
- package/dist/query/devtools.d.ts +21 -0
- package/dist/query/devtools.d.ts.map +1 -0
- package/dist/query/devtools.js +12 -0
- package/dist/query/index.d.ts +65 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +68 -0
- package/dist/register.d.ts +139 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +6 -0
- package/dist/router-tanstack/index.d.ts +74 -0
- package/dist/router-tanstack/index.d.ts.map +1 -0
- package/dist/router-tanstack/index.js +29 -0
- package/dist/router-tanstack/multi-search-param-store.d.ts +78 -0
- package/dist/router-tanstack/multi-search-param-store.d.ts.map +1 -0
- package/dist/router-tanstack/multi-search-param-store.js +35 -0
- package/dist/router-tanstack/search-param-store.d.ts +92 -0
- package/dist/router-tanstack/search-param-store.d.ts.map +1 -0
- package/dist/router-tanstack/search-param-store.js +26 -0
- package/dist/shell/account-types.d.ts +118 -0
- package/dist/shell/account-types.d.ts.map +1 -0
- package/dist/shell/account-types.js +0 -0
- package/dist/shell/app-breadcrumbs.d.ts +17 -0
- package/dist/shell/app-breadcrumbs.d.ts.map +1 -0
- package/dist/shell/app-breadcrumbs.js +39 -0
- package/dist/shell/app-header.module.css +73 -0
- package/dist/shell/app-header.module.css.d.ts +11 -0
- package/dist/shell/app-mobile-nav.d.ts +26 -0
- package/dist/shell/app-mobile-nav.d.ts.map +1 -0
- package/dist/shell/app-mobile-nav.js +106 -0
- package/dist/shell/app-mobile-nav.module.css +100 -0
- package/dist/shell/app-mobile-nav.module.css.d.ts +14 -0
- package/dist/shell/app-sidebar-account.d.ts +3 -0
- package/dist/shell/app-sidebar-account.d.ts.map +1 -0
- package/dist/shell/app-sidebar-account.js +84 -0
- package/dist/shell/app-sidebar.d.ts +56 -0
- package/dist/shell/app-sidebar.d.ts.map +1 -0
- package/dist/shell/app-sidebar.js +455 -0
- package/dist/shell/app-sidebar.module.css +414 -0
- package/dist/shell/app-sidebar.module.css.d.ts +34 -0
- package/dist/shell/index.d.ts +123 -0
- package/dist/shell/index.d.ts.map +1 -0
- package/dist/shell/index.js +179 -0
- package/dist/shell/page-header.d.ts +13 -0
- package/dist/shell/page-header.d.ts.map +1 -0
- package/dist/shell/page-header.js +23 -0
- package/dist/shell/sidebar-search.d.ts +12 -0
- package/dist/shell/sidebar-search.d.ts.map +1 -0
- package/dist/shell/sidebar-search.js +62 -0
- package/dist/shell/sidebar-search.module.css +62 -0
- package/dist/shell/sidebar-search.module.css.d.ts +11 -0
- package/dist/state.d.ts +62 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +124 -0
- package/dist/styles.css +166 -0
- package/dist/surfaces.d.ts +376 -0
- package/dist/surfaces.d.ts.map +1 -0
- package/dist/surfaces.js +306 -0
- package/dist/theme/controls.module.css +143 -0
- package/dist/theme/controls.module.css.d.ts +17 -0
- package/dist/theme/floating.module.css +35 -0
- package/dist/theme/floating.module.css.d.ts +9 -0
- package/dist/theme/index.d.ts +22 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +733 -0
- package/dist/theme/nav-link.module.css +67 -0
- package/dist/theme/nav-link.module.css.d.ts +8 -0
- package/dist/theme/segmented-control.module.css +14 -0
- package/dist/theme/segmented-control.module.css.d.ts +8 -0
- package/dist/theme/timeline.module.css +29 -0
- package/dist/theme/timeline.module.css.d.ts +9 -0
- package/dist/theme-lab/index.d.ts +59 -0
- package/dist/theme-lab/index.d.ts.map +1 -0
- package/dist/theme-lab/index.js +263 -0
- package/dist/theme-toggle/index.d.ts +8 -0
- package/dist/theme-toggle/index.d.ts.map +1 -0
- package/dist/theme-toggle/index.js +155 -0
- package/dist/tokens/index.d.ts +151 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +246 -0
- package/dist/tokens/palette.d.ts +304 -0
- package/dist/tokens/palette.d.ts.map +1 -0
- package/dist/tokens/palette.js +186 -0
- package/dist/vite.d.ts +30 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +68 -0
- package/llms.txt +149 -0
- package/package.json +246 -37
- package/src/agent/ai-sdk-transport.ts +280 -0
- package/src/agent/history.ts +128 -0
- package/src/agent/index.ts +92 -0
- package/src/agent/outcome.ts +120 -0
- package/src/agent/part-list.tsx +292 -0
- package/src/agent/parts.ts +136 -0
- package/src/agent/stick-to-bottom.tsx +154 -0
- package/src/agent/thread.ts +312 -0
- package/src/agent/transport.ts +114 -0
- package/src/agent/use-agent-stream.ts +141 -0
- package/src/agent/use-agent-thread-runs.ts +440 -0
- package/src/agent-chat/composer.tsx +131 -0
- package/src/agent-chat/index.ts +35 -0
- package/src/agent-chat/thread-detail-panel.tsx +192 -0
- package/src/agent-chat/thread-feed.tsx +81 -0
- package/src/agent-chat/thread-message.tsx +251 -0
- package/src/agent-chat/thread-outcome-card.tsx +196 -0
- package/src/agent-chat/thread-workspace.tsx +179 -0
- package/src/charts/hooks/useChartSize.ts +31 -0
- package/src/charts/hooks/useChartTooltip.ts +31 -0
- package/src/charts/hooks/useHoverSync.ts +116 -0
- package/src/charts/hover-context.ts +28 -0
- package/src/charts/hover-sync.tsx +37 -0
- package/src/charts/index.ts +118 -0
- package/src/charts/kinds/Bars.tsx +634 -0
- package/src/charts/kinds/Donut.tsx +233 -0
- package/src/charts/kinds/DualPanel.tsx +432 -0
- package/src/charts/kinds/Heatmap.tsx +255 -0
- package/src/charts/kinds/MultiLine.tsx +376 -0
- package/src/charts/kinds/StackedArea.tsx +218 -0
- package/src/charts/kinds/ZonedLine.tsx +346 -0
- package/src/charts/primitives/AreaGradient.tsx +26 -0
- package/src/charts/primitives/Axes.tsx +97 -0
- package/src/charts/primitives/ChartCard.tsx +180 -0
- package/src/charts/primitives/ChartFrame.tsx +157 -0
- package/src/charts/primitives/ChartLegend.tsx +302 -0
- package/src/charts/primitives/ChartTooltip.tsx +158 -0
- package/src/charts/primitives/Crosshair.tsx +40 -0
- package/src/charts/primitives/HoverOverlay.tsx +24 -0
- package/src/charts/primitives/ResponsiveChart.tsx +64 -0
- package/src/charts/primitives/ZoneRects.tsx +67 -0
- package/src/charts/series.ts +163 -0
- package/src/charts/sparklines/BarSparkline.tsx +48 -0
- package/src/charts/sparklines/LineSparkline.tsx +57 -0
- package/src/charts/sparklines/index.ts +2 -0
- package/src/charts/theme.tsx +53 -0
- package/src/charts/utils/domain.test.ts +24 -0
- package/src/charts/utils/domain.ts +22 -0
- package/src/charts/utils/format.ts +27 -0
- package/src/charts/utils/ticks.ts +18 -0
- package/src/cli/check-theme.test.ts +658 -0
- package/src/cli/index.ts +1497 -0
- package/src/cli/init-sync.test.ts +160 -0
- package/src/commands/ShortcutsHelp.tsx +129 -0
- package/src/commands/define-commands.ts +184 -0
- package/src/commands/define-overlays.ts +197 -0
- package/src/commands/index.ts +86 -0
- package/src/commands/overlays-mount.tsx +301 -0
- package/src/commands/projectors.ts +267 -0
- package/src/commands/shortcut-format.ts +83 -0
- package/src/commands/useCommandHotkeys.ts +114 -0
- package/src/connectivity/connectivity-indicator.tsx +249 -0
- package/src/connectivity/connectivity-provider.tsx +186 -0
- package/src/connectivity/index.ts +18 -0
- package/src/connectivity/types.ts +39 -0
- package/src/connectivity/use-connectivity.ts +25 -0
- package/src/content/article-actions.test.ts +78 -0
- package/src/content/article-actions.ts +72 -0
- package/src/content/article-card.module.css +109 -0
- package/src/content/article-card.module.css.d.ts +16 -0
- package/src/content/article-card.tsx +173 -0
- package/src/content/article-filter-bar.tsx +88 -0
- package/src/content/article-layout.module.css +131 -0
- package/src/content/article-layout.module.css.d.ts +20 -0
- package/src/content/article-layout.tsx +167 -0
- package/src/content/article-model.test.ts +119 -0
- package/src/content/article-model.ts +110 -0
- package/src/content/block-split.test.ts +75 -0
- package/src/content/block-split.ts +102 -0
- package/src/content/callout-alert.ts +88 -0
- package/src/content/callout.module.css +77 -0
- package/src/content/callout.module.css.d.ts +16 -0
- package/src/content/callout.tsx +96 -0
- package/src/content/code-block.module.css +86 -0
- package/src/content/code-block.module.css.d.ts +14 -0
- package/src/content/code-block.tsx +82 -0
- package/src/content/copy-action.tsx +79 -0
- package/src/content/fence-block.tsx +39 -0
- package/src/content/glyphs.tsx +53 -0
- package/src/content/guide.module.css +62 -0
- package/src/content/guide.module.css.d.ts +13 -0
- package/src/content/guide.tsx +174 -0
- package/src/content/heading-anchor.tsx +54 -0
- package/src/content/heading-components.tsx +62 -0
- package/src/content/highlighter.ts +123 -0
- package/src/content/index.ts +60 -0
- package/src/content/markdown-hast.ts +80 -0
- package/src/content/markdown.tsx +346 -0
- package/src/content/mdx.tsx +127 -0
- package/src/content/mermaid.module.css +20 -0
- package/src/content/mermaid.module.css.d.ts +8 -0
- package/src/content/mermaid.tsx +124 -0
- package/src/content/prose.module.css +330 -0
- package/src/content/prose.module.css.d.ts +12 -0
- package/src/content/prose.tsx +53 -0
- package/src/content/reading-progress.module.css +22 -0
- package/src/content/reading-progress.module.css.d.ts +9 -0
- package/src/content/reading-progress.tsx +67 -0
- package/src/content/slug.test.ts +62 -0
- package/src/content/slug.ts +57 -0
- package/src/content/toc.module.css +51 -0
- package/src/content/toc.module.css.d.ts +13 -0
- package/src/content/toc.tsx +226 -0
- package/src/content/url-hardening.ts +46 -0
- package/src/dashboard/delta-badge.tsx +70 -0
- package/src/dashboard/empty-state.tsx +80 -0
- package/src/dashboard/index.ts +11 -0
- package/src/dashboard/settings-section.module.css +23 -0
- package/src/dashboard/settings-section.module.css.d.ts +10 -0
- package/src/dashboard/settings-section.tsx +118 -0
- package/src/dashboard/stat-card.tsx +105 -0
- package/src/data/data-table.tsx +695 -0
- package/src/data/index.ts +37 -0
- package/src/data/table.ts +46 -0
- package/src/data/virtual-list.tsx +180 -0
- package/src/data/virtual.ts +21 -0
- package/src/forms/FormErrorSummary.tsx +64 -0
- package/src/forms/create-form.ts +57 -0
- package/src/forms/field.ts +30 -0
- package/src/forms/index.ts +26 -0
- package/src/forms/use-form-draft.ts +170 -0
- package/src/guard/check-source.test.ts +834 -0
- package/src/guard/guard-hook.test.ts +173 -0
- package/src/guard/guard-hook.ts +122 -0
- package/src/guard/index.ts +510 -0
- package/src/guard/types.ts +117 -0
- package/src/index.ts +139 -0
- package/src/motion/index.ts +26 -0
- package/src/notifications/bell.tsx +108 -0
- package/src/notifications/center.tsx +245 -0
- package/src/notifications/define-notifications.ts +162 -0
- package/src/notifications/index.ts +79 -0
- package/src/notifications/notify.tsx +260 -0
- package/src/notifications/overlay.tsx +64 -0
- package/src/notifications/store.ts +287 -0
- package/src/provider/index.tsx +234 -0
- package/src/query/devtools.tsx +38 -0
- package/src/query/index.ts +129 -0
- package/src/register.ts +158 -0
- package/src/router-tanstack/index.ts +111 -0
- package/src/router-tanstack/multi-search-param-store.test.ts +56 -0
- package/src/router-tanstack/multi-search-param-store.ts +122 -0
- package/src/router-tanstack/search-param-store.ts +125 -0
- package/src/shell/account-types.ts +119 -0
- package/src/shell/app-breadcrumbs.tsx +90 -0
- package/src/shell/app-header.module.css +73 -0
- package/src/shell/app-header.module.css.d.ts +11 -0
- package/src/shell/app-mobile-nav.module.css +100 -0
- package/src/shell/app-mobile-nav.module.css.d.ts +14 -0
- package/src/shell/app-mobile-nav.tsx +146 -0
- package/src/shell/app-sidebar-account.tsx +142 -0
- package/src/shell/app-sidebar.module.css +414 -0
- package/src/shell/app-sidebar.module.css.d.ts +34 -0
- package/src/shell/app-sidebar.tsx +632 -0
- package/src/shell/index.tsx +343 -0
- package/src/shell/page-header.tsx +35 -0
- package/src/shell/sidebar-search.module.css +62 -0
- package/src/shell/sidebar-search.module.css.d.ts +11 -0
- package/src/shell/sidebar-search.tsx +80 -0
- package/src/state.ts +246 -0
- package/src/styles.css +166 -0
- package/src/styles.floor.test.ts +36 -0
- package/src/surfaces.ts +489 -0
- package/src/theme/border-coverage.test.ts +272 -0
- package/src/theme/contrast.test.ts +306 -0
- package/src/theme/controls.module.css +143 -0
- package/src/theme/controls.module.css.d.ts +17 -0
- package/src/theme/floating.module.css +35 -0
- package/src/theme/floating.module.css.d.ts +9 -0
- package/src/theme/index.ts +933 -0
- package/src/theme/nav-link.module.css +67 -0
- package/src/theme/nav-link.module.css.d.ts +8 -0
- package/src/theme/segmented-control.module.css +14 -0
- package/src/theme/segmented-control.module.css.d.ts +8 -0
- package/src/theme/shadow-surfaces.test.ts +421 -0
- package/src/theme/timeline.module.css +29 -0
- package/src/theme/timeline.module.css.d.ts +9 -0
- package/src/theme-lab/index.tsx +359 -0
- package/src/theme-lab/theme-lab.test.ts +60 -0
- package/src/theme-toggle/index.tsx +180 -0
- package/src/tokens/index.ts +363 -0
- package/src/tokens/palette.ts +288 -0
- package/src/vite.ts +122 -0
- package/src/index.css +0 -986
- package/src/starlight.css +0 -308
- package/tailwind.config.js +0 -78
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ZoneSpec } from '../primitives/ZoneRects.js';
|
|
2
|
+
import type { ChartLegendConfig, ChartSeries } from '../series.js';
|
|
3
|
+
export type DualPanelProps<T> = {
|
|
4
|
+
data: T[];
|
|
5
|
+
/** Fixed height in pixels, forwarded to the internal `ChartFrame`. Default 240. */
|
|
6
|
+
height?: number;
|
|
7
|
+
chartId: string;
|
|
8
|
+
getX: (d: T) => string;
|
|
9
|
+
/** 1+ line series in the top pane — the single source of truth for color, dash, legend, and
|
|
10
|
+
* tooltip rows. E.g. acute (solid) / chronic (dashed). */
|
|
11
|
+
series: ChartSeries<T>[];
|
|
12
|
+
/** Top-pane y-domain. Default 'auto' (computed from all top lines, padded). */
|
|
13
|
+
topYDomain?: [number, number] | 'auto';
|
|
14
|
+
/** Shade the band between two top lines (by key), filled on both sides. */
|
|
15
|
+
fillBetween?: {
|
|
16
|
+
from: string;
|
|
17
|
+
to: string;
|
|
18
|
+
fill: string;
|
|
19
|
+
};
|
|
20
|
+
/** Horizontal reference lines on the top pane. Solid by default; set dashed: true for a dashed line. */
|
|
21
|
+
topRefLines?: {
|
|
22
|
+
value: number;
|
|
23
|
+
color: string;
|
|
24
|
+
dashed?: boolean;
|
|
25
|
+
}[];
|
|
26
|
+
/** Horizontal value-range bands on the top pane. */
|
|
27
|
+
topZones?: ZoneSpec[];
|
|
28
|
+
/** Bottom-pane signed value — return null to skip the bar. */
|
|
29
|
+
getBar: (d: T) => number | null;
|
|
30
|
+
barLabel: string;
|
|
31
|
+
barColorPositive: string;
|
|
32
|
+
barColorNegative: string;
|
|
33
|
+
/** Top pane share of the inner plot height. Default 0.62. */
|
|
34
|
+
topFraction?: number;
|
|
35
|
+
formatTop: (v: number) => string;
|
|
36
|
+
formatBottom: (v: number) => string;
|
|
37
|
+
/** Tooltip badge — appears at the right of the tooltip header. */
|
|
38
|
+
tooltipLabel?: (d: T) => {
|
|
39
|
+
text: string;
|
|
40
|
+
color: string;
|
|
41
|
+
} | null;
|
|
42
|
+
/** Legend config forwarded to `ChartFrame`; `false` disables the legend (sparkline escape).
|
|
43
|
+
* Default `{ placement: 'bottom' }`. */
|
|
44
|
+
legend?: ChartLegendConfig | false;
|
|
45
|
+
/** Accessible text alternative, forwarded to `ChartFrame` as `aria-label` (+ `role="img"`). */
|
|
46
|
+
ariaLabel?: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Dual-pane chart: a top line pane and a bottom signed-histogram pane sharing
|
|
50
|
+
* ONE x-scale and ONE cursor. Generalizes argo's divergence (acute/chronic +
|
|
51
|
+
* divergence) and momentum (e1RM + velocity) charts.
|
|
52
|
+
*
|
|
53
|
+
* Composes `ChartFrame` for measuring + the derived legend — `series` (the top lines) plus a
|
|
54
|
+
* synthesized divergence entry drive the legend, so acute/chronic/divergence are all legible
|
|
55
|
+
* without hovering (previously legend-less).
|
|
56
|
+
*
|
|
57
|
+
* X-axis is built from the full `data` array so the calendar is preserved even
|
|
58
|
+
* when a series has nulls; lines/bars skip null points (visual gaps).
|
|
59
|
+
*/
|
|
60
|
+
declare function DualPanelInner<T>(props: DualPanelProps<T>): import("react").JSX.Element;
|
|
61
|
+
/**
|
|
62
|
+
* Hand-memoized: React Compiler does not process the shipped dist, so the hot DualPanel kind is
|
|
63
|
+
* wrapped in `React.memo` to retain the auto-memoization it had as source (parity with ZonedLine).
|
|
64
|
+
*/
|
|
65
|
+
export declare const DualPanel: typeof DualPanelInner;
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=DualPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DualPanel.d.ts","sourceRoot":"","sources":["../../../src/charts/kinds/DualPanel.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAGvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAe,MAAM,WAAW,CAAA;AAI5E,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,IAAI,EAAE,CAAC,EAAE,CAAA;IACT,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAA;IACtB;8DAC0D;IAC1D,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAA;IACxB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;IACtC,2EAA2E;IAC3E,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACxD,wGAAwG;IACxG,WAAW,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAA;IAClE,oDAAoD;IACpD,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAA;IACrB,8DAA8D;IAC9D,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAA;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,MAAM,CAAA;IACxB,gBAAgB,EAAE,MAAM,CAAA;IACxB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;IAChC,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;IACnC,kEAAkE;IAClE,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAC/D;4CACwC;IACxC,MAAM,CAAC,EAAE,iBAAiB,GAAG,KAAK,CAAA;IAClC,+FAA+F;IAC/F,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAID;;;;;;;;;;;GAWG;AACH,iBAAS,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,+BAiClD;AA+TD;;;GAGG;AACH,eAAO,MAAM,SAAS,EAA2B,OAAO,cAAc,CAAA"}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { curveMonotoneX } from "@visx/curve";
|
|
3
|
+
import { GridRows } from "@visx/grid";
|
|
4
|
+
import { Group } from "@visx/group";
|
|
5
|
+
import { scaleLinear, scalePoint } from "@visx/scale";
|
|
6
|
+
import { Bar, LinePath } from "@visx/shape";
|
|
7
|
+
import { Threshold } from "@visx/threshold";
|
|
8
|
+
import { memo, useMemo } from "react";
|
|
9
|
+
import { AxisBottomDate, AxisLeftNumeric } from "../primitives/Axes.js";
|
|
10
|
+
import {
|
|
11
|
+
ChartTooltip,
|
|
12
|
+
TooltipBody,
|
|
13
|
+
TooltipHeader,
|
|
14
|
+
TooltipRow,
|
|
15
|
+
useTooltipStyles
|
|
16
|
+
} from "../primitives/ChartTooltip.js";
|
|
17
|
+
import { ChartFrame, resolveLegend } from "../primitives/ChartFrame.js";
|
|
18
|
+
import { Crosshair, SeriesDot } from "../primitives/Crosshair.js";
|
|
19
|
+
import { HoverOverlay } from "../primitives/HoverOverlay.js";
|
|
20
|
+
import { ZoneRects } from "../primitives/ZoneRects.js";
|
|
21
|
+
import { useHoverSync } from "../hooks/useHoverSync.js";
|
|
22
|
+
import { deriveTooltipRows, LINE_OVERLAY_STROKE_WIDTH } from "../series.js";
|
|
23
|
+
import { VX } from "../../tokens/index.js";
|
|
24
|
+
import { smartTicks } from "../utils/ticks.js";
|
|
25
|
+
const PANE_GAP = 12;
|
|
26
|
+
function DualPanelInner(props) {
|
|
27
|
+
const { series, chartId, height, barLabel, barColorPositive, legend, ariaLabel } = props;
|
|
28
|
+
const styledSeries = useMemo(
|
|
29
|
+
() => series.map((s) => ({ ...s, strokeWidth: s.strokeWidth ?? LINE_OVERLAY_STROKE_WIDTH })),
|
|
30
|
+
[series]
|
|
31
|
+
);
|
|
32
|
+
const legendSeries = useMemo(
|
|
33
|
+
() => [
|
|
34
|
+
...styledSeries,
|
|
35
|
+
{ key: "__divergence", label: barLabel, color: barColorPositive, mark: "bar" }
|
|
36
|
+
],
|
|
37
|
+
[styledSeries, barLabel, barColorPositive]
|
|
38
|
+
);
|
|
39
|
+
return /* @__PURE__ */ jsx(
|
|
40
|
+
ChartFrame,
|
|
41
|
+
{
|
|
42
|
+
series: legendSeries,
|
|
43
|
+
chartId,
|
|
44
|
+
...height !== void 0 && { height },
|
|
45
|
+
...ariaLabel !== void 0 && { ariaLabel },
|
|
46
|
+
legend: resolveLegend(legend),
|
|
47
|
+
children: (plot) => /* @__PURE__ */ jsx(DualPanelPlot, { ...props, series: styledSeries, plot })
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
function DualPanelPlot(props) {
|
|
52
|
+
const {
|
|
53
|
+
data,
|
|
54
|
+
chartId,
|
|
55
|
+
getX,
|
|
56
|
+
series,
|
|
57
|
+
topYDomain = "auto",
|
|
58
|
+
fillBetween,
|
|
59
|
+
topRefLines = [],
|
|
60
|
+
topZones = [],
|
|
61
|
+
getBar,
|
|
62
|
+
barLabel,
|
|
63
|
+
barColorPositive,
|
|
64
|
+
barColorNegative,
|
|
65
|
+
topFraction = 0.62,
|
|
66
|
+
formatTop,
|
|
67
|
+
formatBottom,
|
|
68
|
+
tooltipLabel,
|
|
69
|
+
plot
|
|
70
|
+
} = props;
|
|
71
|
+
const MARGIN = VX.margin;
|
|
72
|
+
const xMax = plot.width - MARGIN.left - MARGIN.right;
|
|
73
|
+
const plotH = plot.height - MARGIN.top - MARGIN.bottom - PANE_GAP;
|
|
74
|
+
const topH = Math.max(Math.round(plotH * topFraction), 1);
|
|
75
|
+
const bottomH = Math.max(plotH - topH, 1);
|
|
76
|
+
const bottomTop = topH + PANE_GAP;
|
|
77
|
+
const innerH = topH + PANE_GAP + bottomH;
|
|
78
|
+
const xScale = useMemo(
|
|
79
|
+
() => scalePoint({ domain: data.map(getX), range: [0, xMax], padding: 0.3 }),
|
|
80
|
+
[data, xMax, getX]
|
|
81
|
+
);
|
|
82
|
+
const topYScale = useMemo(() => {
|
|
83
|
+
if (topYDomain !== "auto") {
|
|
84
|
+
return scaleLinear({ domain: topYDomain, range: [topH, 0] });
|
|
85
|
+
}
|
|
86
|
+
let lo = Infinity;
|
|
87
|
+
let hi = -Infinity;
|
|
88
|
+
for (const s of series) {
|
|
89
|
+
for (const d of data) {
|
|
90
|
+
const v = s.getValue(d);
|
|
91
|
+
if (v === null || v === void 0 || Number.isNaN(v)) continue;
|
|
92
|
+
if (v < lo) lo = v;
|
|
93
|
+
if (v > hi) hi = v;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (!Number.isFinite(lo) || !Number.isFinite(hi)) {
|
|
97
|
+
lo = 0;
|
|
98
|
+
hi = 1;
|
|
99
|
+
}
|
|
100
|
+
const span = hi - lo || Math.abs(hi) || 1;
|
|
101
|
+
return scaleLinear({
|
|
102
|
+
domain: [lo - span * 0.08, hi + span * 0.08],
|
|
103
|
+
range: [topH, 0],
|
|
104
|
+
nice: true
|
|
105
|
+
});
|
|
106
|
+
}, [data, series, topYDomain, topH]);
|
|
107
|
+
const bottomYScale = useMemo(() => {
|
|
108
|
+
let maxAbs = 0;
|
|
109
|
+
for (const d of data) {
|
|
110
|
+
const v = getBar(d);
|
|
111
|
+
if (v === null || v === void 0 || Number.isNaN(v)) continue;
|
|
112
|
+
const a = Math.abs(v);
|
|
113
|
+
if (a > maxAbs) maxAbs = a;
|
|
114
|
+
}
|
|
115
|
+
if (maxAbs === 0) maxAbs = 1;
|
|
116
|
+
return scaleLinear({
|
|
117
|
+
domain: [-maxAbs, maxAbs],
|
|
118
|
+
range: [bottomH, 0],
|
|
119
|
+
nice: true
|
|
120
|
+
});
|
|
121
|
+
}, [data, getBar, bottomH]);
|
|
122
|
+
const tooltipStyles = useTooltipStyles();
|
|
123
|
+
const { tip, tooltipRef, syncedPoint, isDirectHover, handleMouse, handleLeave } = useHoverSync(
|
|
124
|
+
{
|
|
125
|
+
data,
|
|
126
|
+
chartId,
|
|
127
|
+
getKey: getX,
|
|
128
|
+
xScale,
|
|
129
|
+
marginLeft: MARGIN.left
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
const tickValues = useMemo(() => smartTicks(data.map(getX), xMax), [data, xMax, getX]);
|
|
133
|
+
const barWidth = data.length > 0 ? Math.max(xMax / data.length * 0.6, 2) : 2;
|
|
134
|
+
const fillPts = useMemo(() => {
|
|
135
|
+
if (!fillBetween) return [];
|
|
136
|
+
const fromLine = series.find((s) => s.key === fillBetween.from);
|
|
137
|
+
const toLine = series.find((s) => s.key === fillBetween.to);
|
|
138
|
+
if (!fromLine || !toLine) return [];
|
|
139
|
+
const out = [];
|
|
140
|
+
for (const d of data) {
|
|
141
|
+
const f = fromLine.getValue(d);
|
|
142
|
+
const t = toLine.getValue(d);
|
|
143
|
+
if (f === null || f === void 0 || Number.isNaN(f)) continue;
|
|
144
|
+
if (t === null || t === void 0 || Number.isNaN(t)) continue;
|
|
145
|
+
out.push({ __d: d, __from: f, __to: t });
|
|
146
|
+
}
|
|
147
|
+
return out;
|
|
148
|
+
}, [data, fillBetween, series]);
|
|
149
|
+
const lineValid = useMemo(() => {
|
|
150
|
+
const out = /* @__PURE__ */ new Map();
|
|
151
|
+
for (const s of series) {
|
|
152
|
+
const pts = [];
|
|
153
|
+
for (const d of data) {
|
|
154
|
+
const v = s.getValue(d);
|
|
155
|
+
if (v !== null && v !== void 0 && !Number.isNaN(v)) pts.push({ __d: d, __y: v });
|
|
156
|
+
}
|
|
157
|
+
out.set(s.key, pts);
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}, [data, series]);
|
|
161
|
+
const sx = syncedPoint ? xScale(getX(syncedPoint)) ?? 0 : 0;
|
|
162
|
+
const syncedBar = syncedPoint ? getBar(syncedPoint) : null;
|
|
163
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
164
|
+
/* @__PURE__ */ jsxs("svg", { width: plot.width, height: plot.height, children: [
|
|
165
|
+
/* @__PURE__ */ jsxs(Group, { left: MARGIN.left, top: MARGIN.top, children: [
|
|
166
|
+
/* @__PURE__ */ jsx(GridRows, { scale: topYScale, width: xMax, stroke: VX.grid, numTicks: 4 }),
|
|
167
|
+
/* @__PURE__ */ jsx(ZoneRects, { zones: topZones, width: xMax, leftScale: topYScale }),
|
|
168
|
+
fillBetween && fillPts.length > 0 && /* @__PURE__ */ jsx(
|
|
169
|
+
Threshold,
|
|
170
|
+
{
|
|
171
|
+
id: `${chartId}-fill`,
|
|
172
|
+
data: fillPts,
|
|
173
|
+
x: (p) => xScale(getX(p.__d)) ?? 0,
|
|
174
|
+
y0: (p) => topYScale(p.__from),
|
|
175
|
+
y1: (p) => topYScale(p.__to),
|
|
176
|
+
clipAboveTo: 0,
|
|
177
|
+
clipBelowTo: topH,
|
|
178
|
+
curve: curveMonotoneX,
|
|
179
|
+
belowAreaProps: { fill: fillBetween.fill },
|
|
180
|
+
aboveAreaProps: { fill: fillBetween.fill }
|
|
181
|
+
}
|
|
182
|
+
),
|
|
183
|
+
topRefLines.map((r, i) => /* @__PURE__ */ jsx(
|
|
184
|
+
"line",
|
|
185
|
+
{
|
|
186
|
+
x1: 0,
|
|
187
|
+
x2: xMax,
|
|
188
|
+
y1: topYScale(r.value),
|
|
189
|
+
y2: topYScale(r.value),
|
|
190
|
+
stroke: r.color,
|
|
191
|
+
strokeDasharray: r.dashed ? VX.dashArray : void 0
|
|
192
|
+
},
|
|
193
|
+
`top-ref-${i}`
|
|
194
|
+
)),
|
|
195
|
+
series.map((s) => {
|
|
196
|
+
const valid = lineValid.get(s.key) ?? [];
|
|
197
|
+
if (valid.length === 0) return null;
|
|
198
|
+
return /* @__PURE__ */ jsx(
|
|
199
|
+
LinePath,
|
|
200
|
+
{
|
|
201
|
+
data: valid,
|
|
202
|
+
x: (p) => xScale(getX(p.__d)) ?? 0,
|
|
203
|
+
y: (p) => topYScale(p.__y),
|
|
204
|
+
stroke: s.color,
|
|
205
|
+
strokeWidth: s.strokeWidth ?? VX.lineWidth,
|
|
206
|
+
strokeDasharray: s.dash === "dashed" ? VX.dashArray : void 0,
|
|
207
|
+
curve: curveMonotoneX
|
|
208
|
+
},
|
|
209
|
+
`top-line-${s.key}`
|
|
210
|
+
);
|
|
211
|
+
}),
|
|
212
|
+
syncedPoint && /* @__PURE__ */ jsx(Fragment, { children: series.map((s) => {
|
|
213
|
+
const v = s.getValue(syncedPoint);
|
|
214
|
+
if (v === null || v === void 0 || Number.isNaN(v)) return null;
|
|
215
|
+
return /* @__PURE__ */ jsx(SeriesDot, { cx: sx, cy: topYScale(v), color: s.color }, `top-dot-${s.key}`);
|
|
216
|
+
}) }),
|
|
217
|
+
/* @__PURE__ */ jsx(AxisLeftNumeric, { scale: topYScale, numTicks: 4, tickFormat: formatTop }),
|
|
218
|
+
/* @__PURE__ */ jsx(
|
|
219
|
+
HoverOverlay,
|
|
220
|
+
{
|
|
221
|
+
width: xMax,
|
|
222
|
+
height: topH + PANE_GAP,
|
|
223
|
+
onMove: handleMouse,
|
|
224
|
+
onLeave: handleLeave
|
|
225
|
+
}
|
|
226
|
+
)
|
|
227
|
+
] }),
|
|
228
|
+
/* @__PURE__ */ jsxs(Group, { left: MARGIN.left, top: MARGIN.top + bottomTop, children: [
|
|
229
|
+
/* @__PURE__ */ jsx(
|
|
230
|
+
"line",
|
|
231
|
+
{
|
|
232
|
+
x1: 0,
|
|
233
|
+
x2: xMax,
|
|
234
|
+
y1: bottomYScale(0),
|
|
235
|
+
y2: bottomYScale(0),
|
|
236
|
+
stroke: VX.grid,
|
|
237
|
+
strokeWidth: 1
|
|
238
|
+
}
|
|
239
|
+
),
|
|
240
|
+
data.map((d) => {
|
|
241
|
+
const v = getBar(d);
|
|
242
|
+
if (v === null || v === void 0 || Number.isNaN(v)) return null;
|
|
243
|
+
const cx = xScale(getX(d)) ?? 0;
|
|
244
|
+
const y0 = bottomYScale(0);
|
|
245
|
+
const yVal = bottomYScale(v);
|
|
246
|
+
return /* @__PURE__ */ jsx(
|
|
247
|
+
Bar,
|
|
248
|
+
{
|
|
249
|
+
x: cx - barWidth / 2,
|
|
250
|
+
y: Math.min(y0, yVal),
|
|
251
|
+
width: barWidth,
|
|
252
|
+
height: Math.max(Math.abs(yVal - y0), 1),
|
|
253
|
+
fill: v >= 0 ? barColorPositive : barColorNegative,
|
|
254
|
+
fillOpacity: 0.7,
|
|
255
|
+
rx: 1.4
|
|
256
|
+
},
|
|
257
|
+
`bar-${getX(d)}`
|
|
258
|
+
);
|
|
259
|
+
}),
|
|
260
|
+
syncedPoint && /* @__PURE__ */ jsx(Fragment, { children: syncedBar !== null && syncedBar !== void 0 && !Number.isNaN(syncedBar) && /* @__PURE__ */ jsx(
|
|
261
|
+
SeriesDot,
|
|
262
|
+
{
|
|
263
|
+
cx: sx,
|
|
264
|
+
cy: bottomYScale(syncedBar),
|
|
265
|
+
color: syncedBar >= 0 ? barColorPositive : barColorNegative
|
|
266
|
+
}
|
|
267
|
+
) }),
|
|
268
|
+
/* @__PURE__ */ jsx(AxisLeftNumeric, { scale: bottomYScale, numTicks: 3, tickFormat: formatBottom }),
|
|
269
|
+
/* @__PURE__ */ jsx(AxisBottomDate, { top: bottomH, scale: xScale, tickValues }),
|
|
270
|
+
/* @__PURE__ */ jsx(
|
|
271
|
+
HoverOverlay,
|
|
272
|
+
{
|
|
273
|
+
width: xMax,
|
|
274
|
+
height: bottomH + MARGIN.bottom,
|
|
275
|
+
onMove: handleMouse,
|
|
276
|
+
onLeave: handleLeave
|
|
277
|
+
}
|
|
278
|
+
)
|
|
279
|
+
] }),
|
|
280
|
+
syncedPoint && /* @__PURE__ */ jsx(Group, { left: MARGIN.left, top: MARGIN.top, children: /* @__PURE__ */ jsx(Crosshair, { x: sx, top: 0, bottom: innerH }) })
|
|
281
|
+
] }),
|
|
282
|
+
/* @__PURE__ */ jsx(ChartTooltip, { tip: isDirectHover ? tip : null, tooltipRef, styles: tooltipStyles, children: tip && isDirectHover && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
283
|
+
/* @__PURE__ */ jsx(
|
|
284
|
+
TooltipHeader,
|
|
285
|
+
{
|
|
286
|
+
date: getX(tip.data),
|
|
287
|
+
...(() => {
|
|
288
|
+
const lbl = tooltipLabel?.(tip.data) ?? null;
|
|
289
|
+
return lbl !== null ? { label: lbl.text, labelColor: lbl.color } : {};
|
|
290
|
+
})()
|
|
291
|
+
}
|
|
292
|
+
),
|
|
293
|
+
/* @__PURE__ */ jsxs(TooltipBody, { children: [
|
|
294
|
+
deriveTooltipRows(series, tip.data, formatTop).map((row) => /* @__PURE__ */ jsx(
|
|
295
|
+
TooltipRow,
|
|
296
|
+
{
|
|
297
|
+
color: row.color,
|
|
298
|
+
label: row.label,
|
|
299
|
+
value: row.value,
|
|
300
|
+
shape: row.shape,
|
|
301
|
+
dashed: row.dashed,
|
|
302
|
+
...row.strokeWidth !== void 0 && { strokeWidth: row.strokeWidth }
|
|
303
|
+
},
|
|
304
|
+
row.key
|
|
305
|
+
)),
|
|
306
|
+
(() => {
|
|
307
|
+
const v = getBar(tip.data);
|
|
308
|
+
if (v === null || v === void 0 || Number.isNaN(v)) return null;
|
|
309
|
+
return /* @__PURE__ */ jsx(
|
|
310
|
+
TooltipRow,
|
|
311
|
+
{
|
|
312
|
+
color: v >= 0 ? barColorPositive : barColorNegative,
|
|
313
|
+
label: barLabel,
|
|
314
|
+
value: formatBottom(v),
|
|
315
|
+
shape: "bar"
|
|
316
|
+
}
|
|
317
|
+
);
|
|
318
|
+
})()
|
|
319
|
+
] })
|
|
320
|
+
] }) })
|
|
321
|
+
] });
|
|
322
|
+
}
|
|
323
|
+
const DualPanel = memo(DualPanelInner);
|
|
324
|
+
export {
|
|
325
|
+
DualPanel
|
|
326
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/** A single resolved heatmap cell — the unit the tooltip and hover operate on. */
|
|
3
|
+
type HeatmapCell = {
|
|
4
|
+
row: string;
|
|
5
|
+
col: string;
|
|
6
|
+
value: number;
|
|
7
|
+
};
|
|
8
|
+
export type HeatmapProps<T> = {
|
|
9
|
+
data: T[];
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
chartId: string;
|
|
13
|
+
/** Extracts the y-axis category (row) from a data point. */
|
|
14
|
+
getRow: (d: T) => string;
|
|
15
|
+
/** Extracts the x-axis category (column) from a data point. */
|
|
16
|
+
getCol: (d: T) => string;
|
|
17
|
+
/** Extracts the cell intensity value. */
|
|
18
|
+
getValue: (d: T) => number;
|
|
19
|
+
/** Explicit y order; defaults to first-seen rows from data. */
|
|
20
|
+
rows?: string[];
|
|
21
|
+
/** Explicit x order; defaults to first-seen columns from data. */
|
|
22
|
+
cols?: string[];
|
|
23
|
+
/** Base hue token for the heat fill. Default VX.line. */
|
|
24
|
+
color?: string;
|
|
25
|
+
/** Maps a value to a 0..1 intensity. Default value/max. */
|
|
26
|
+
intensity?: (value: number, max: number) => number;
|
|
27
|
+
/** Gap (px) between cells. Default 2. */
|
|
28
|
+
cellGap?: number;
|
|
29
|
+
/** Corner radius (px) of each cell. Default 2. */
|
|
30
|
+
cellRadius?: number;
|
|
31
|
+
/** Formatter for the tooltip value. */
|
|
32
|
+
formatValue?: (v: number) => string;
|
|
33
|
+
/** Label transform for a row category (axis + tooltip). */
|
|
34
|
+
rowLabel?: (row: string) => string;
|
|
35
|
+
/** Label transform for a column category (axis + tooltip). */
|
|
36
|
+
colLabel?: (col: string) => string;
|
|
37
|
+
/** Optional extra tooltip rows (rendered after the main row). */
|
|
38
|
+
renderTooltip?: (cell: HeatmapCell) => ReactNode;
|
|
39
|
+
/** Optional gradient legend strip below the grid (faint → solid color). */
|
|
40
|
+
legend?: {
|
|
41
|
+
min: string;
|
|
42
|
+
max: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Category × category intensity grid. Each cell is a rounded rect filled with the base
|
|
47
|
+
* color at an opacity derived from its value; empty cells stay a faint neutral track.
|
|
48
|
+
* Generalizes argo's day-of-week × hour-of-day heatmap. Categorical axes are rendered as
|
|
49
|
+
* plain themed `<text>` (cells are not date-categorical, so no useHoverSync / shared
|
|
50
|
+
* cursor) — per-cell hover drives the local tooltip directly.
|
|
51
|
+
*/
|
|
52
|
+
declare function HeatmapInner<T>(props: HeatmapProps<T>): import("react").JSX.Element;
|
|
53
|
+
/**
|
|
54
|
+
* Hand-memoized: React Compiler does not process the shipped dist, so the hot Heatmap kind is
|
|
55
|
+
* wrapped in `React.memo` to retain auto-memoization (parity with ZonedLine / Bars).
|
|
56
|
+
*/
|
|
57
|
+
export declare const Heatmap: typeof HeatmapInner;
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=Heatmap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Heatmap.d.ts","sourceRoot":"","sources":["../../../src/charts/kinds/Heatmap.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAYtC,kFAAkF;AAClF,KAAK,WAAW,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9D,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,IAAI,EAAE,CAAC,EAAE,CAAA;IACT,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,4DAA4D;IAC5D,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAA;IACxB,+DAA+D;IAC/D,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAA;IACxB,yCAAyC;IACzC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAA;IAC1B,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2DAA2D;IAC3D,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;IAClD,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,uCAAuC;IACvC,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;IACnC,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;IAClC,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;IAClC,iEAAiE;IACjE,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,SAAS,CAAA;IAChD,2EAA2E;IAC3E,MAAM,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CACtC,CAAA;AAgCD;;;;;;GAMG;AACH,iBAAS,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,+BAgK9C;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAyB,OAAO,YAAY,CAAA"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Group } from "@visx/group";
|
|
3
|
+
import { memo, useMemo } from "react";
|
|
4
|
+
import {
|
|
5
|
+
ChartTooltip,
|
|
6
|
+
TooltipBody,
|
|
7
|
+
TooltipHeader,
|
|
8
|
+
TooltipRow,
|
|
9
|
+
useTooltipStyles
|
|
10
|
+
} from "../primitives/ChartTooltip.js";
|
|
11
|
+
import { useChartTooltip } from "../hooks/useChartTooltip.js";
|
|
12
|
+
import { VX, alpha } from "../../tokens/index.js";
|
|
13
|
+
function firstSeen(data, get) {
|
|
14
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const d of data) {
|
|
17
|
+
const k = get(d);
|
|
18
|
+
if (!seen.has(k)) {
|
|
19
|
+
seen.add(k);
|
|
20
|
+
out.push(k);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
const cellKey = (row, col) => `${row}\0${col}`;
|
|
26
|
+
const LABEL_FONT_FAMILY = "var(--basalt-font-mono)";
|
|
27
|
+
const PAD_LEFT = 44;
|
|
28
|
+
const PAD_BOTTOM = 24;
|
|
29
|
+
const PAD_TOP = 8;
|
|
30
|
+
const LEGEND_H = 8;
|
|
31
|
+
const LEGEND_LABEL_H = 16;
|
|
32
|
+
function HeatmapInner(props) {
|
|
33
|
+
const {
|
|
34
|
+
data,
|
|
35
|
+
width,
|
|
36
|
+
height,
|
|
37
|
+
chartId,
|
|
38
|
+
getRow,
|
|
39
|
+
getCol,
|
|
40
|
+
getValue,
|
|
41
|
+
rows: rowsProp,
|
|
42
|
+
cols: colsProp,
|
|
43
|
+
color = VX.line,
|
|
44
|
+
intensity = (value, max2) => max2 > 0 ? value / max2 : 0,
|
|
45
|
+
cellGap = 2,
|
|
46
|
+
cellRadius = 2,
|
|
47
|
+
formatValue = (v) => `${v}`,
|
|
48
|
+
rowLabel = (r) => r,
|
|
49
|
+
colLabel = (c) => c,
|
|
50
|
+
renderTooltip,
|
|
51
|
+
legend
|
|
52
|
+
} = props;
|
|
53
|
+
const tooltipStyles = useTooltipStyles();
|
|
54
|
+
const { tip, show, hide, tooltipRef } = useChartTooltip();
|
|
55
|
+
const rows = useMemo(() => rowsProp ?? firstSeen(data, getRow), [rowsProp, data, getRow]);
|
|
56
|
+
const cols = useMemo(() => colsProp ?? firstSeen(data, getCol), [colsProp, data, getCol]);
|
|
57
|
+
const { lookup, max } = useMemo(() => {
|
|
58
|
+
const map = /* @__PURE__ */ new Map();
|
|
59
|
+
let m = 0;
|
|
60
|
+
for (const d of data) {
|
|
61
|
+
const v = getValue(d);
|
|
62
|
+
map.set(cellKey(getRow(d), getCol(d)), v);
|
|
63
|
+
if (v > m) m = v;
|
|
64
|
+
}
|
|
65
|
+
return { lookup: map, max: m };
|
|
66
|
+
}, [data, getRow, getCol, getValue]);
|
|
67
|
+
const legendH = legend ? LEGEND_H + LEGEND_LABEL_H : 0;
|
|
68
|
+
const gridW = Math.max(0, width - PAD_LEFT);
|
|
69
|
+
const gridH = Math.max(0, height - PAD_TOP - PAD_BOTTOM - legendH);
|
|
70
|
+
const cellW = cols.length > 0 ? gridW / cols.length : 0;
|
|
71
|
+
const cellH = rows.length > 0 ? gridH / rows.length : 0;
|
|
72
|
+
const legendGradientId = `${chartId}-heat-legend`;
|
|
73
|
+
return /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
|
|
74
|
+
/* @__PURE__ */ jsxs("svg", { width, height, children: [
|
|
75
|
+
/* @__PURE__ */ jsx(Group, { left: PAD_LEFT, top: PAD_TOP, children: rows.flatMap(
|
|
76
|
+
(row, ri) => cols.map((col, ci) => {
|
|
77
|
+
const value = lookup.get(cellKey(row, col));
|
|
78
|
+
const has = value !== void 0;
|
|
79
|
+
const fill = has ? alpha(color, intensity(value, max)) : alpha(VX.neutral, 0.04);
|
|
80
|
+
return /* @__PURE__ */ jsx(
|
|
81
|
+
"rect",
|
|
82
|
+
{
|
|
83
|
+
x: ci * cellW + cellGap / 2,
|
|
84
|
+
y: ri * cellH + cellGap / 2,
|
|
85
|
+
width: Math.max(0, cellW - cellGap),
|
|
86
|
+
height: Math.max(0, cellH - cellGap),
|
|
87
|
+
rx: cellRadius,
|
|
88
|
+
fill,
|
|
89
|
+
style: { cursor: has ? "pointer" : "default" },
|
|
90
|
+
onMouseMove: (e) => has && show({ row, col, value }, e),
|
|
91
|
+
onMouseLeave: hide
|
|
92
|
+
},
|
|
93
|
+
cellKey(row, col)
|
|
94
|
+
);
|
|
95
|
+
})
|
|
96
|
+
) }),
|
|
97
|
+
/* @__PURE__ */ jsx(Group, { left: 0, top: PAD_TOP, children: rows.map((row, ri) => /* @__PURE__ */ jsx(
|
|
98
|
+
"text",
|
|
99
|
+
{
|
|
100
|
+
x: PAD_LEFT - 6,
|
|
101
|
+
y: ri * cellH + cellH / 2 + 4,
|
|
102
|
+
textAnchor: "end",
|
|
103
|
+
fontSize: VX.axisFont,
|
|
104
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
105
|
+
fill: VX.faint,
|
|
106
|
+
children: rowLabel(row)
|
|
107
|
+
},
|
|
108
|
+
row
|
|
109
|
+
)) }),
|
|
110
|
+
/* @__PURE__ */ jsx(Group, { left: PAD_LEFT, top: PAD_TOP + gridH, children: cols.map((col, ci) => /* @__PURE__ */ jsx(
|
|
111
|
+
"text",
|
|
112
|
+
{
|
|
113
|
+
x: ci * cellW + cellW / 2,
|
|
114
|
+
y: 16,
|
|
115
|
+
textAnchor: "middle",
|
|
116
|
+
fontSize: VX.axisFont,
|
|
117
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
118
|
+
fill: VX.faint,
|
|
119
|
+
children: colLabel(col)
|
|
120
|
+
},
|
|
121
|
+
col
|
|
122
|
+
)) }),
|
|
123
|
+
legend && /* @__PURE__ */ jsxs(Group, { left: PAD_LEFT, top: PAD_TOP + gridH + PAD_BOTTOM, children: [
|
|
124
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: legendGradientId, x1: "0", x2: "1", y1: "0", y2: "0", children: [
|
|
125
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: alpha(color, 0.08) }),
|
|
126
|
+
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: color })
|
|
127
|
+
] }) }),
|
|
128
|
+
/* @__PURE__ */ jsx("rect", { width: gridW, height: LEGEND_H, rx: 2, fill: `url(#${legendGradientId})` }),
|
|
129
|
+
/* @__PURE__ */ jsx(
|
|
130
|
+
"text",
|
|
131
|
+
{
|
|
132
|
+
x: 0,
|
|
133
|
+
y: LEGEND_H + 12,
|
|
134
|
+
textAnchor: "start",
|
|
135
|
+
fontSize: VX.axisFont,
|
|
136
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
137
|
+
fill: VX.faint,
|
|
138
|
+
children: legend.min
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
/* @__PURE__ */ jsx(
|
|
142
|
+
"text",
|
|
143
|
+
{
|
|
144
|
+
x: gridW,
|
|
145
|
+
y: LEGEND_H + 12,
|
|
146
|
+
textAnchor: "end",
|
|
147
|
+
fontSize: VX.axisFont,
|
|
148
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
149
|
+
fill: VX.faint,
|
|
150
|
+
children: legend.max
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
] })
|
|
154
|
+
] }),
|
|
155
|
+
/* @__PURE__ */ jsx(ChartTooltip, { tip, tooltipRef, styles: tooltipStyles, children: tip !== null && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
156
|
+
/* @__PURE__ */ jsx(TooltipHeader, { date: rowLabel(tip.data.row), label: colLabel(tip.data.col) }),
|
|
157
|
+
/* @__PURE__ */ jsxs(TooltipBody, { children: [
|
|
158
|
+
/* @__PURE__ */ jsx(
|
|
159
|
+
TooltipRow,
|
|
160
|
+
{
|
|
161
|
+
color: alpha(color, 0.9),
|
|
162
|
+
shape: "bar",
|
|
163
|
+
label: "Value",
|
|
164
|
+
value: formatValue(tip.data.value)
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
renderTooltip?.(tip.data)
|
|
168
|
+
] })
|
|
169
|
+
] }) })
|
|
170
|
+
] });
|
|
171
|
+
}
|
|
172
|
+
const Heatmap = memo(HeatmapInner);
|
|
173
|
+
export {
|
|
174
|
+
Heatmap
|
|
175
|
+
};
|