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,180 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from 'react'
|
|
2
|
+
import { useEffect, useId, useRef, useState } from 'react'
|
|
3
|
+
import { VX } from '../../tokens'
|
|
4
|
+
|
|
5
|
+
const infoWrapStyle: CSSProperties = {
|
|
6
|
+
position: 'relative',
|
|
7
|
+
display: 'inline-flex',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
marginLeft: 5,
|
|
10
|
+
}
|
|
11
|
+
const infoTriggerStyle: CSSProperties = {
|
|
12
|
+
appearance: 'none',
|
|
13
|
+
background: 'none',
|
|
14
|
+
border: 'none',
|
|
15
|
+
padding: 0,
|
|
16
|
+
margin: 0,
|
|
17
|
+
cursor: 'help',
|
|
18
|
+
display: 'inline-flex',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
}
|
|
21
|
+
// The tooltip bubble reads like every floating surface — panel bg + shadow-card + card radius
|
|
22
|
+
// (docs/DESIGN-SPEC.md section 5). It opens DOWNWARD (top: 100%) by convention, into/over the
|
|
23
|
+
// chart body. The header is intentionally outside the body's clip box (see `cardStyle` /
|
|
24
|
+
// `bodyClipStyle` below), so the bubble can overhang the card edge without ever being clipped.
|
|
25
|
+
// Mantine-free by design (the charts boundary), so this is a plain hover/focus-state bubble, not
|
|
26
|
+
// a Mantine Tooltip.
|
|
27
|
+
const bubbleStyle: CSSProperties = {
|
|
28
|
+
position: 'absolute',
|
|
29
|
+
top: 'calc(100% + 7px)',
|
|
30
|
+
left: 0,
|
|
31
|
+
zIndex: 10,
|
|
32
|
+
maxWidth: 260,
|
|
33
|
+
width: 'max-content',
|
|
34
|
+
padding: '7px 10px',
|
|
35
|
+
borderRadius: VX.radiusCard,
|
|
36
|
+
backgroundColor: VX.surface.panel,
|
|
37
|
+
boxShadow: VX.shadowCard,
|
|
38
|
+
color: VX.muted,
|
|
39
|
+
fontSize: VX.text.sm,
|
|
40
|
+
fontWeight: 400,
|
|
41
|
+
lineHeight: 1.4,
|
|
42
|
+
whiteSpace: 'normal',
|
|
43
|
+
pointerEvents: 'none',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function InfoIcon({ title }: { title: string }) {
|
|
47
|
+
const [open, setOpen] = useState(false)
|
|
48
|
+
const tipId = useId()
|
|
49
|
+
const triggerRef = useRef<HTMLButtonElement>(null)
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!open) return
|
|
53
|
+
const handlePointerDown = (event: PointerEvent) => {
|
|
54
|
+
if (triggerRef.current?.contains(event.target as Node)) return
|
|
55
|
+
setOpen(false)
|
|
56
|
+
}
|
|
57
|
+
document.addEventListener('pointerdown', handlePointerDown)
|
|
58
|
+
return () => document.removeEventListener('pointerdown', handlePointerDown)
|
|
59
|
+
}, [open])
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<span style={infoWrapStyle}>
|
|
63
|
+
<button
|
|
64
|
+
ref={triggerRef}
|
|
65
|
+
type="button"
|
|
66
|
+
aria-label="More information"
|
|
67
|
+
aria-describedby={open ? tipId : undefined}
|
|
68
|
+
onMouseEnter={() => setOpen(true)}
|
|
69
|
+
onMouseLeave={() => setOpen(false)}
|
|
70
|
+
onFocus={() => setOpen(true)}
|
|
71
|
+
onBlur={() => setOpen(false)}
|
|
72
|
+
onClick={() => setOpen(true)}
|
|
73
|
+
onKeyDown={(event) => {
|
|
74
|
+
if (event.key === 'Escape') setOpen(false)
|
|
75
|
+
}}
|
|
76
|
+
style={{ ...infoTriggerStyle, color: open ? VX.muted : VX.faint }}
|
|
77
|
+
>
|
|
78
|
+
<svg width={11} height={11} viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
|
79
|
+
<path d="M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0zm0 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3zm0 5a1 1 0 0 1 1 1v7a1 1 0 1 1-2 0v-7a1 1 0 0 1 1-1z" />
|
|
80
|
+
</svg>
|
|
81
|
+
</button>
|
|
82
|
+
{open && (
|
|
83
|
+
<span id={tipId} role="tooltip" style={bubbleStyle}>
|
|
84
|
+
{title}
|
|
85
|
+
</span>
|
|
86
|
+
)}
|
|
87
|
+
</span>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Surfaces resolve per theme via CSS vars, so the styles are static (no useMemo/isDark).
|
|
92
|
+
// Depth = `shadow-card` (a whisper shadow + a 1px ring baked into the same value), never a
|
|
93
|
+
// `border` property (docs/DESIGN-SPEC.md §5) — so a ChartCard reads IDENTICALLY to a Mantine
|
|
94
|
+
// Card/Paper (same shadow token, same radius token, no intrinsic margin; outer spacing comes
|
|
95
|
+
// from the parent Stack/SimpleGrid gap). Shadow + panel background + card radius all live on
|
|
96
|
+
// this OUTER box, which is never clipped — only the chart body below clips its own bottom
|
|
97
|
+
// corners (`bodyClipStyle`). The header is a direct, unclipped child of this box on purpose: its
|
|
98
|
+
// info-tooltip bubble must be able to overflow the card bounds without being invisibly cut off.
|
|
99
|
+
const cardStyle = {
|
|
100
|
+
borderRadius: VX.radiusCard,
|
|
101
|
+
boxShadow: VX.shadowCard,
|
|
102
|
+
backgroundColor: VX.surface.panel,
|
|
103
|
+
}
|
|
104
|
+
const bodyClipStyle = {
|
|
105
|
+
// Clip the chart body to the card's bottom corners — a chart with its own square edges would
|
|
106
|
+
// otherwise poke past the card's border-radius. Only the bottom corners: the body's top edge is
|
|
107
|
+
// interior, sitting under the (unclipped) header. Trade-off: a chart tooltip that overflows the
|
|
108
|
+
// card bounds is clipped too; the kinds keep tooltips inside the plot area, so this is fine in
|
|
109
|
+
// practice — a consumer rendering an oversized/edge tooltip should portal it out of the card.
|
|
110
|
+
borderBottomLeftRadius: VX.radiusCard,
|
|
111
|
+
borderBottomRightRadius: VX.radiusCard,
|
|
112
|
+
overflow: 'hidden' as const,
|
|
113
|
+
padding: '2px var(--mantine-spacing-sm, 0.75rem) var(--mantine-spacing-xs, 0.625rem)',
|
|
114
|
+
}
|
|
115
|
+
const headerStyle = {
|
|
116
|
+
display: 'flex',
|
|
117
|
+
justifyContent: 'space-between',
|
|
118
|
+
alignItems: 'center',
|
|
119
|
+
// Card inset = spacing xs (vertical) / sm (horizontal). The `--mantine-spacing-*` vars carry
|
|
120
|
+
// basalt's OWNED scale (theme.spacing.xs 0.625rem / sm 0.75rem); the rem fallbacks keep a
|
|
121
|
+
// Mantine-free `./charts`-only consumer (no MantineProvider vars) padded identically. No
|
|
122
|
+
// header/body divider — the title block and the plot read as one continuous surface; a rule here
|
|
123
|
+
// only doubled the card's shadow-embedded ring and made the header feel heavier.
|
|
124
|
+
padding: 'var(--mantine-spacing-xs, 0.625rem) var(--mantine-spacing-sm, 0.75rem) 4px',
|
|
125
|
+
}
|
|
126
|
+
const titleColumnStyle = {
|
|
127
|
+
display: 'inline-flex',
|
|
128
|
+
flexDirection: 'column' as const,
|
|
129
|
+
lineHeight: 1.15,
|
|
130
|
+
}
|
|
131
|
+
const titleStyle = {
|
|
132
|
+
display: 'inline-flex',
|
|
133
|
+
alignItems: 'center',
|
|
134
|
+
fontFamily: 'var(--basalt-font-head)',
|
|
135
|
+
fontStretch: '88%',
|
|
136
|
+
fontWeight: 550,
|
|
137
|
+
fontSize: VX.text.md,
|
|
138
|
+
color: VX.ink,
|
|
139
|
+
}
|
|
140
|
+
const subtitleStyle = {
|
|
141
|
+
fontSize: VX.text.sm,
|
|
142
|
+
fontWeight: 400,
|
|
143
|
+
color: VX.muted,
|
|
144
|
+
marginTop: 1,
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Standard wrapper for every visx chart — card with info-tooltip title + optional
|
|
149
|
+
* subtitle (the question the chart answers) + optional extra slot (current value
|
|
150
|
+
* badge etc.). Do not wrap visx charts in bare divs.
|
|
151
|
+
*/
|
|
152
|
+
export function ChartCard({
|
|
153
|
+
title,
|
|
154
|
+
subtitle,
|
|
155
|
+
tooltip,
|
|
156
|
+
extra,
|
|
157
|
+
children,
|
|
158
|
+
}: {
|
|
159
|
+
title: string
|
|
160
|
+
subtitle?: string
|
|
161
|
+
tooltip: string
|
|
162
|
+
extra?: ReactNode
|
|
163
|
+
children: ReactNode
|
|
164
|
+
}) {
|
|
165
|
+
return (
|
|
166
|
+
<div style={cardStyle}>
|
|
167
|
+
<div style={headerStyle}>
|
|
168
|
+
<span style={titleColumnStyle}>
|
|
169
|
+
<span style={titleStyle}>
|
|
170
|
+
{title}
|
|
171
|
+
<InfoIcon title={tooltip} />
|
|
172
|
+
</span>
|
|
173
|
+
{subtitle !== undefined && <span style={subtitleStyle}>{subtitle}</span>}
|
|
174
|
+
</span>
|
|
175
|
+
{extra !== undefined && <span>{extra}</span>}
|
|
176
|
+
</div>
|
|
177
|
+
<div style={bodyClipStyle}>{children}</div>
|
|
178
|
+
</div>
|
|
179
|
+
)
|
|
180
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from 'react'
|
|
2
|
+
import { useChartSize } from '../hooks/useChartSize'
|
|
3
|
+
import { deriveLegend } from '../series'
|
|
4
|
+
import type { ChartLegendConfig, LegendPlacement, SeriesStyle } from '../series'
|
|
5
|
+
import { ChartLegend } from './ChartLegend'
|
|
6
|
+
|
|
7
|
+
const DEFAULT_HEIGHT = 240
|
|
8
|
+
const DEFAULT_MIN_WIDTH = 200
|
|
9
|
+
|
|
10
|
+
/** Legend configuration for {@link ChartFrame}. Omit entirely (or pass `{}`) for the default
|
|
11
|
+
* bottom-placed legend; pass `false` only for the sparkline exemption. */
|
|
12
|
+
export type ChartFrameLegend = {
|
|
13
|
+
/** Default 'bottom'. */
|
|
14
|
+
placement?: LegendPlacement
|
|
15
|
+
/** Wrap cap → "+N more" rollup at high cardinality. */
|
|
16
|
+
maxRows?: number
|
|
17
|
+
/** Visually separate role: series | overlay | reference. */
|
|
18
|
+
groups?: boolean
|
|
19
|
+
/** Hover-dim wiring lifted from the kind — optional. */
|
|
20
|
+
highlighted?: string | null
|
|
21
|
+
onHighlight?: (key: string | null) => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type ChartFrameProps = {
|
|
25
|
+
/** Series identity — drives the derived legend. Pass the SAME array the kind draws + tooltips from. */
|
|
26
|
+
series: readonly SeriesStyle[]
|
|
27
|
+
/** Fixed height in pixels. Used when neither `aspectRatio` nor `fill` is set. Default 240. */
|
|
28
|
+
height?: number
|
|
29
|
+
/** height = Math.round(containerWidth / aspectRatio). Ignored when `fill` is set. */
|
|
30
|
+
aspectRatio?: number
|
|
31
|
+
/** Fill the parent flex/grid cell's measured height instead of a fixed/derived one. */
|
|
32
|
+
fill?: boolean
|
|
33
|
+
/** First-frame width floor before the container is measured. Default 200. */
|
|
34
|
+
minWidth?: number
|
|
35
|
+
/** Namespaces `ChartLegend`'s `split` swatch clipPath ids across multiple charts on one page. */
|
|
36
|
+
chartId?: string
|
|
37
|
+
/** `false` only for the sparkline exemption — every other chart gets a legend by default. */
|
|
38
|
+
legend?: ChartFrameLegend | false
|
|
39
|
+
/**
|
|
40
|
+
* Accessible text alternative for the chart, applied as `aria-label` (+ `role="img"`) on the
|
|
41
|
+
* outer container so screen readers announce something other than an unlabeled graphic. Every
|
|
42
|
+
* kind composing `ChartFrame` should accept and forward this from its own props.
|
|
43
|
+
*/
|
|
44
|
+
ariaLabel?: string
|
|
45
|
+
/** Draw the SVG marks given the plot rect that already excludes the legend band. */
|
|
46
|
+
children: (plot: { width: number; height: number }) => ReactNode
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const outerStyle = (fill: boolean, vertical: boolean): CSSProperties => ({
|
|
50
|
+
width: '100%',
|
|
51
|
+
height: fill ? '100%' : undefined,
|
|
52
|
+
display: 'flex',
|
|
53
|
+
flexDirection: vertical ? 'row' : 'column',
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const legendWrapperStyle = (vertical: boolean): CSSProperties => ({
|
|
57
|
+
flexShrink: 0,
|
|
58
|
+
width: vertical ? undefined : '100%',
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
/** A kind's own hover-dim wiring, merged into the resolved `ChartFrameLegend`. Kinds without
|
|
62
|
+
* per-series highlight state (single-series `ZonedLine`, `DualPanel`) omit this. */
|
|
63
|
+
export type ChartFrameLegendHover = {
|
|
64
|
+
highlighted: string | null
|
|
65
|
+
onHighlight: (key: string | null) => void
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Merges a kind's consumer-facing {@link ChartLegendConfig} (the `legend` prop every kind exposes)
|
|
70
|
+
* with the kind's own hover-dim wiring into the `ChartFrame`-facing {@link ChartFrameLegend}. This
|
|
71
|
+
* is the one merge every kind performs: consumer `placement`/`groups`/`maxRows` (or the defaults)
|
|
72
|
+
* plus the kind's `highlighted`/`onHighlight`, which a consumer may not set directly.
|
|
73
|
+
* `config === false` disables the legend regardless of `hover` (the sparkline escape).
|
|
74
|
+
*/
|
|
75
|
+
export function resolveLegend(
|
|
76
|
+
config: ChartLegendConfig | false | undefined,
|
|
77
|
+
hover?: ChartFrameLegendHover,
|
|
78
|
+
): ChartFrameLegend | false {
|
|
79
|
+
if (config === false) return false
|
|
80
|
+
return {
|
|
81
|
+
placement: config?.placement ?? 'bottom',
|
|
82
|
+
...(config?.groups !== undefined && { groups: config.groups }),
|
|
83
|
+
...(config?.maxRows !== undefined && { maxRows: config.maxRows }),
|
|
84
|
+
...(hover !== undefined && { highlighted: hover.highlighted, onHighlight: hover.onHighlight }),
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The measuring, legend-owning shell every non-sparkline chart composes. Supersedes
|
|
90
|
+
* `ResponsiveChart`'s job and adds the two things it lacked: it observes height (via
|
|
91
|
+
* `useChartSize`, which already measures it) and it reserves the legend band out of the plot
|
|
92
|
+
* rect via a second, independent `useChartSize` on the legend's own wrapper div. The legend
|
|
93
|
+
* `<div>` wraps (`ChartLegend`'s `flexWrap`), so its measured band grows as entries wrap and the
|
|
94
|
+
* plot shrinks accordingly — the plot can never overlap the legend because the legend's measured
|
|
95
|
+
* band is always subtracted first.
|
|
96
|
+
*
|
|
97
|
+
* Layout-only: it does not know lines from bars (that stays in the kind), so it is not a
|
|
98
|
+
* Recharts god-component. Render the child only when the resolved plot rect is non-empty.
|
|
99
|
+
*/
|
|
100
|
+
export function ChartFrame({
|
|
101
|
+
series,
|
|
102
|
+
height,
|
|
103
|
+
aspectRatio,
|
|
104
|
+
fill = false,
|
|
105
|
+
minWidth = DEFAULT_MIN_WIDTH,
|
|
106
|
+
chartId,
|
|
107
|
+
legend = {},
|
|
108
|
+
ariaLabel,
|
|
109
|
+
children,
|
|
110
|
+
}: ChartFrameProps): ReactNode {
|
|
111
|
+
const { ref: containerRef, width: containerW, height: containerH } = useChartSize()
|
|
112
|
+
const { ref: legendRef, width: legendW, height: legendH } = useChartSize()
|
|
113
|
+
|
|
114
|
+
const placement = legend === false ? 'bottom' : (legend.placement ?? 'bottom')
|
|
115
|
+
const vertical = placement === 'left' || placement === 'right'
|
|
116
|
+
|
|
117
|
+
const resolvedHeight = fill
|
|
118
|
+
? containerH
|
|
119
|
+
: aspectRatio !== undefined
|
|
120
|
+
? Math.round(containerW / aspectRatio)
|
|
121
|
+
: (height ?? DEFAULT_HEIGHT)
|
|
122
|
+
|
|
123
|
+
const sideLegendWidth = legend !== false && vertical ? legendW : 0
|
|
124
|
+
const topBottomLegendHeight = legend !== false && !vertical ? legendH : 0
|
|
125
|
+
|
|
126
|
+
const plot = {
|
|
127
|
+
width: Math.max(containerW - sideLegendWidth, minWidth),
|
|
128
|
+
height: resolvedHeight - topBottomLegendHeight,
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const legendNode =
|
|
132
|
+
legend === false ? null : (
|
|
133
|
+
<div ref={legendRef} style={legendWrapperStyle(vertical)}>
|
|
134
|
+
<ChartLegend
|
|
135
|
+
items={deriveLegend(series)}
|
|
136
|
+
placement={placement}
|
|
137
|
+
{...(chartId !== undefined && { chartId })}
|
|
138
|
+
{...(legend.groups !== undefined && { groups: legend.groups })}
|
|
139
|
+
{...(legend.maxRows !== undefined && { maxRows: legend.maxRows })}
|
|
140
|
+
{...(legend.highlighted !== undefined && { highlighted: legend.highlighted })}
|
|
141
|
+
{...(legend.onHighlight !== undefined && { onHighlight: legend.onHighlight })}
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<div
|
|
148
|
+
ref={containerRef}
|
|
149
|
+
style={outerStyle(fill, vertical)}
|
|
150
|
+
{...(ariaLabel !== undefined && { role: 'img', 'aria-label': ariaLabel })}
|
|
151
|
+
>
|
|
152
|
+
{legendNode !== null && (placement === 'top' || placement === 'left') && legendNode}
|
|
153
|
+
{plot.width > 0 && plot.height > 0 ? children(plot) : null}
|
|
154
|
+
{legendNode !== null && (placement === 'bottom' || placement === 'right') && legendNode}
|
|
155
|
+
</div>
|
|
156
|
+
)
|
|
157
|
+
}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import type { CSSProperties, FocusEvent, MouseEvent, ReactNode } from 'react'
|
|
2
|
+
import { VX, alpha } from '../../tokens'
|
|
3
|
+
import type { SeriesRole, LegendPlacement } from '../series'
|
|
4
|
+
|
|
5
|
+
export type LegendEntry = {
|
|
6
|
+
key: string
|
|
7
|
+
label: string
|
|
8
|
+
color: string
|
|
9
|
+
secondColor?: string
|
|
10
|
+
strokeWidth?: number
|
|
11
|
+
shape?: 'line' | 'bar' | 'split' | 'splitLine'
|
|
12
|
+
/** Render line-style swatches as dashed (only applies to 'line' / 'splitLine'). */
|
|
13
|
+
dashed?: boolean
|
|
14
|
+
/** bar swatch opacity — honored instead of a hardcoded value, so it cannot lie about the fill. */
|
|
15
|
+
fillOpacity?: number
|
|
16
|
+
/** Drives `groups` rendering (series → hairline divider → overlay → reference). */
|
|
17
|
+
role?: SeriesRole
|
|
18
|
+
/** Companions folded under this entry via `parent` (`deriveLegend`) — rendered as compact,
|
|
19
|
+
* subordinate sub-entries beside the parent's label instead of vanishing. */
|
|
20
|
+
children?: LegendEntry[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const LEGEND_ITEM_BASE: CSSProperties = {
|
|
24
|
+
display: 'flex',
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
gap: 6,
|
|
27
|
+
cursor: 'default',
|
|
28
|
+
transition: 'opacity 0.15s',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// An interactive legend entry is a native <button> (keyboard-focusable, no jsx-a11y role hack) —
|
|
32
|
+
// this strips the browser's default button chrome so it renders identically to the static entry.
|
|
33
|
+
const LEGEND_ITEM_BUTTON: CSSProperties = {
|
|
34
|
+
...LEGEND_ITEM_BASE,
|
|
35
|
+
appearance: 'none',
|
|
36
|
+
background: 'none',
|
|
37
|
+
border: 'none',
|
|
38
|
+
padding: 0,
|
|
39
|
+
margin: 0,
|
|
40
|
+
font: 'inherit',
|
|
41
|
+
color: 'inherit',
|
|
42
|
+
textAlign: 'inherit',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const GROUP_ORDER: SeriesRole[] = ['series', 'overlay', 'reference']
|
|
46
|
+
|
|
47
|
+
const roleOf = (item: LegendEntry): SeriesRole => item.role ?? 'series'
|
|
48
|
+
|
|
49
|
+
/** Order entries series → overlay → reference and record where a divider belongs. */
|
|
50
|
+
function orderEntries(
|
|
51
|
+
items: LegendEntry[],
|
|
52
|
+
groups: boolean,
|
|
53
|
+
): { entries: LegendEntry[]; dividerAfter: Set<number> } {
|
|
54
|
+
if (!groups) return { entries: items, dividerAfter: new Set() }
|
|
55
|
+
|
|
56
|
+
const dividerAfter = new Set<number>()
|
|
57
|
+
const entries: LegendEntry[] = []
|
|
58
|
+
const nonEmptyGroups = GROUP_ORDER.map((role) =>
|
|
59
|
+
items.filter((item) => roleOf(item) === role),
|
|
60
|
+
).filter((group) => group.length > 0)
|
|
61
|
+
nonEmptyGroups.forEach((group, i) => {
|
|
62
|
+
entries.push(...group)
|
|
63
|
+
if (i < nonEmptyGroups.length - 1) dividerAfter.add(entries.length - 1)
|
|
64
|
+
})
|
|
65
|
+
return { entries, dividerAfter }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function wrapperStyle(placement: LegendPlacement): CSSProperties {
|
|
69
|
+
const vertical = placement === 'left' || placement === 'right'
|
|
70
|
+
return {
|
|
71
|
+
display: 'flex',
|
|
72
|
+
flexDirection: vertical ? 'column' : 'row',
|
|
73
|
+
flexWrap: vertical ? 'nowrap' : 'wrap',
|
|
74
|
+
alignItems: vertical ? 'flex-start' : 'center',
|
|
75
|
+
justifyContent: vertical ? 'flex-start' : 'center',
|
|
76
|
+
columnGap: VX.legendGap,
|
|
77
|
+
rowGap: VX.legendGap,
|
|
78
|
+
padding: '8px 0 2px',
|
|
79
|
+
fontSize: VX.legendFontSize,
|
|
80
|
+
color: VX.muted,
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** `columnLayout` = the legend itself stacks entries in a column (left/right placement), so the
|
|
85
|
+
* divider between role groups must be a horizontal hairline rather than a vertical bar. */
|
|
86
|
+
function LegendDivider({ columnLayout }: { columnLayout: boolean }) {
|
|
87
|
+
return (
|
|
88
|
+
<span
|
|
89
|
+
aria-hidden
|
|
90
|
+
style={
|
|
91
|
+
columnLayout
|
|
92
|
+
? { width: '100%', height: 1, backgroundColor: alpha(VX.neutral, 0.25), margin: '2px 0' }
|
|
93
|
+
: { width: 1, alignSelf: 'stretch', backgroundColor: alpha(VX.neutral, 0.25) }
|
|
94
|
+
}
|
|
95
|
+
/>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function LegendSwatch({ item, idPrefix }: { item: LegendEntry; idPrefix: string }) {
|
|
100
|
+
if (item.shape === 'splitLine') {
|
|
101
|
+
return (
|
|
102
|
+
<svg width={20} height={14} style={{ flexShrink: 0 }}>
|
|
103
|
+
<line
|
|
104
|
+
x1={0}
|
|
105
|
+
y1={7}
|
|
106
|
+
x2={10}
|
|
107
|
+
y2={7}
|
|
108
|
+
stroke={item.color}
|
|
109
|
+
strokeWidth={item.strokeWidth ?? 2.5}
|
|
110
|
+
strokeDasharray={item.dashed ? VX.dashArray : undefined}
|
|
111
|
+
/>
|
|
112
|
+
<line
|
|
113
|
+
x1={10}
|
|
114
|
+
y1={7}
|
|
115
|
+
x2={20}
|
|
116
|
+
y2={7}
|
|
117
|
+
stroke={item.secondColor}
|
|
118
|
+
strokeWidth={item.strokeWidth ?? 2.5}
|
|
119
|
+
strokeDasharray={item.dashed ? VX.dashArray : undefined}
|
|
120
|
+
/>
|
|
121
|
+
</svg>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (item.shape === 'split') {
|
|
126
|
+
const topId = `split-top-${idPrefix}${item.key}`
|
|
127
|
+
const botId = `split-bot-${idPrefix}${item.key}`
|
|
128
|
+
return (
|
|
129
|
+
<svg width={14} height={14} style={{ flexShrink: 0 }}>
|
|
130
|
+
<defs>
|
|
131
|
+
<clipPath id={topId}>
|
|
132
|
+
<polygon points="0,0 14,0 0,14" />
|
|
133
|
+
</clipPath>
|
|
134
|
+
<clipPath id={botId}>
|
|
135
|
+
<polygon points="14,0 14,14 0,14" />
|
|
136
|
+
</clipPath>
|
|
137
|
+
</defs>
|
|
138
|
+
<rect width={14} height={14} rx={2} fill={item.color} clipPath={`url(#${topId})`} />
|
|
139
|
+
<rect width={14} height={14} rx={2} fill={item.secondColor} clipPath={`url(#${botId})`} />
|
|
140
|
+
</svg>
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (item.shape === 'bar') {
|
|
145
|
+
return (
|
|
146
|
+
<span
|
|
147
|
+
style={{
|
|
148
|
+
width: 11,
|
|
149
|
+
height: 11,
|
|
150
|
+
borderRadius: 3,
|
|
151
|
+
backgroundColor: item.color,
|
|
152
|
+
opacity: item.fillOpacity ?? 0.7,
|
|
153
|
+
flexShrink: 0,
|
|
154
|
+
}}
|
|
155
|
+
/>
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Line series — a 16×3px radius-2 pill (docs/DESIGN-SPEC.md §5). A thick, round-capped stroke
|
|
160
|
+
// reads as a filled pill when solid while still supporting the dashed variant.
|
|
161
|
+
return (
|
|
162
|
+
<svg width={16} height={6} style={{ flexShrink: 0 }}>
|
|
163
|
+
<line
|
|
164
|
+
x1={0}
|
|
165
|
+
y1={3}
|
|
166
|
+
x2={16}
|
|
167
|
+
y2={3}
|
|
168
|
+
stroke={item.color}
|
|
169
|
+
strokeWidth={item.strokeWidth ?? 3}
|
|
170
|
+
strokeLinecap="round"
|
|
171
|
+
strokeDasharray={item.dashed ? VX.dashArray : undefined}
|
|
172
|
+
/>
|
|
173
|
+
</svg>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const LEGEND_CHILD_STYLE: CSSProperties = {
|
|
178
|
+
display: 'flex',
|
|
179
|
+
alignItems: 'center',
|
|
180
|
+
gap: 4,
|
|
181
|
+
marginLeft: 4,
|
|
182
|
+
fontSize: '0.85em',
|
|
183
|
+
opacity: 0.75,
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Compact swatch for a folded child entry — smaller than {@link LegendSwatch}, line/bar only
|
|
187
|
+
* (folded companions are simple line or bar series; `split`/`splitLine` never fold). */
|
|
188
|
+
function LegendChildSwatch({ item }: { item: LegendEntry }) {
|
|
189
|
+
if (item.shape === 'bar') {
|
|
190
|
+
return (
|
|
191
|
+
<span
|
|
192
|
+
style={{
|
|
193
|
+
width: 10,
|
|
194
|
+
height: 10,
|
|
195
|
+
borderRadius: 2,
|
|
196
|
+
backgroundColor: item.color,
|
|
197
|
+
opacity: item.fillOpacity ?? 0.7,
|
|
198
|
+
flexShrink: 0,
|
|
199
|
+
}}
|
|
200
|
+
/>
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
return (
|
|
204
|
+
<svg width={14} height={10} style={{ flexShrink: 0 }}>
|
|
205
|
+
<line
|
|
206
|
+
x1={0}
|
|
207
|
+
y1={5}
|
|
208
|
+
x2={14}
|
|
209
|
+
y2={5}
|
|
210
|
+
stroke={item.color}
|
|
211
|
+
strokeWidth={item.strokeWidth ?? 2}
|
|
212
|
+
strokeDasharray={item.dashed ? VX.dashArray : undefined}
|
|
213
|
+
/>
|
|
214
|
+
</svg>
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** A folded companion, rendered subordinate to (and inside) its parent's legend entry. */
|
|
219
|
+
function LegendChild({ item }: { item: LegendEntry }) {
|
|
220
|
+
return (
|
|
221
|
+
<span style={LEGEND_CHILD_STYLE}>
|
|
222
|
+
<LegendChildSwatch item={item} />
|
|
223
|
+
<span>{item.label}</span>
|
|
224
|
+
</span>
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Shared legend for all non-sparkline charts. `highlighted`/`onHighlight` are optional — omit for
|
|
230
|
+
* static legends without hover interactivity. `chartId` namespaces `split` clipPath ids so two
|
|
231
|
+
* legends on the same page never collide. `groups` renders series → hairline divider → overlay →
|
|
232
|
+
* reference bands instead of one flat smear. `maxRows` caps the number of rendered entries and
|
|
233
|
+
* rolls the remainder into a `+N more` chip (row-accurate wrap measurement is `ChartFrame`'s job —
|
|
234
|
+
* this is an entry-count cap, a deliberate simplification until that primitive lands).
|
|
235
|
+
*/
|
|
236
|
+
export function ChartLegend({
|
|
237
|
+
items,
|
|
238
|
+
highlighted = null,
|
|
239
|
+
onHighlight,
|
|
240
|
+
chartId = '',
|
|
241
|
+
placement = 'bottom',
|
|
242
|
+
groups = false,
|
|
243
|
+
maxRows,
|
|
244
|
+
}: {
|
|
245
|
+
items: LegendEntry[]
|
|
246
|
+
highlighted?: string | null
|
|
247
|
+
onHighlight?: (key: string | null) => void
|
|
248
|
+
chartId?: string
|
|
249
|
+
placement?: LegendPlacement
|
|
250
|
+
groups?: boolean
|
|
251
|
+
maxRows?: number
|
|
252
|
+
}) {
|
|
253
|
+
const handleEnter = (e: MouseEvent<HTMLButtonElement> | FocusEvent<HTMLButtonElement>) => {
|
|
254
|
+
const key = e.currentTarget.dataset['legendKey']
|
|
255
|
+
if (key !== undefined) onHighlight?.(key)
|
|
256
|
+
}
|
|
257
|
+
const handleLeave = () => onHighlight?.(null)
|
|
258
|
+
|
|
259
|
+
const idPrefix = chartId ? `${chartId}-` : ''
|
|
260
|
+
const vertical = placement === 'left' || placement === 'right'
|
|
261
|
+
const { entries, dividerAfter } = orderEntries(items, groups)
|
|
262
|
+
const visible =
|
|
263
|
+
maxRows !== undefined && maxRows < entries.length ? entries.slice(0, maxRows) : entries
|
|
264
|
+
const hiddenCount = entries.length - visible.length
|
|
265
|
+
|
|
266
|
+
const nodes: ReactNode[] = []
|
|
267
|
+
visible.forEach((item, i) => {
|
|
268
|
+
nodes.push(
|
|
269
|
+
<button
|
|
270
|
+
key={item.key}
|
|
271
|
+
type="button"
|
|
272
|
+
data-legend-key={item.key}
|
|
273
|
+
aria-label={item.label}
|
|
274
|
+
style={{
|
|
275
|
+
...LEGEND_ITEM_BUTTON,
|
|
276
|
+
opacity: highlighted === null || highlighted === item.key ? 1 : 0.3,
|
|
277
|
+
}}
|
|
278
|
+
onMouseEnter={handleEnter}
|
|
279
|
+
onMouseLeave={handleLeave}
|
|
280
|
+
onFocus={handleEnter}
|
|
281
|
+
onBlur={handleLeave}
|
|
282
|
+
>
|
|
283
|
+
<LegendSwatch item={item} idPrefix={idPrefix} />
|
|
284
|
+
<span>{item.label}</span>
|
|
285
|
+
{item.children?.map((child) => (
|
|
286
|
+
<LegendChild key={child.key} item={child} />
|
|
287
|
+
))}
|
|
288
|
+
</button>,
|
|
289
|
+
)
|
|
290
|
+
if (dividerAfter.has(i))
|
|
291
|
+
nodes.push(<LegendDivider key={`divider-${item.key}`} columnLayout={vertical} />)
|
|
292
|
+
})
|
|
293
|
+
if (hiddenCount > 0) {
|
|
294
|
+
nodes.push(
|
|
295
|
+
<span key="legend-more" style={LEGEND_ITEM_BASE}>
|
|
296
|
+
+{hiddenCount} more
|
|
297
|
+
</span>,
|
|
298
|
+
)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return <div style={wrapperStyle(placement)}>{nodes}</div>
|
|
302
|
+
}
|