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,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BasaltProvider — wraps `MantineProvider` with the Basalt theme, injects the `--vx-*` palette
|
|
3
|
+
* stylesheet, and bridges Mantine's color scheme into the Vx chart theme context so chrome and
|
|
4
|
+
* charts share one scheme-reactive identity.
|
|
5
|
+
*
|
|
6
|
+
* Grounded in argo: argo split this into `main.tsx` (the `MantineProvider` + `cssVariablesResolver`
|
|
7
|
+
* wiring) and `charts-bridge.tsx` (the `VxBridge`: read the Mantine color scheme, provide the Vx
|
|
8
|
+
* context, inject the palette `<style>`). Basalt folds the GENERIC half of both into one provider.
|
|
9
|
+
* The DOMAIN half of argo's `main.tsx` — router, query client, app routes, auth gate, the concrete
|
|
10
|
+
* series/sections — stays in the consumer and does NOT extract.
|
|
11
|
+
*
|
|
12
|
+
* The palette injection is pure CSS: the `<style>` emitted by `buildPaletteCss` keys off Mantine's
|
|
13
|
+
* `[data-mantine-color-scheme]` attribute, so dark/light resolution needs no React re-render. The
|
|
14
|
+
* Vx context still carries the resolved `colorScheme` for any non-color branching a chart may need.
|
|
15
|
+
*
|
|
16
|
+
* Mantine usage is allowed in this `./` root layer (unlike `src/charts/**` and `src/tokens/**`).
|
|
17
|
+
*/
|
|
18
|
+
import { MantineProvider, useComputedColorScheme } from '@mantine/core'
|
|
19
|
+
import type { MantineProviderProps } from '@mantine/core'
|
|
20
|
+
import { Component, useEffect } from 'react'
|
|
21
|
+
import type { ErrorInfo, ReactNode } from 'react'
|
|
22
|
+
import { VxThemeProvider } from '../charts/theme'
|
|
23
|
+
import { ConnectivityProvider } from '../connectivity'
|
|
24
|
+
import { createBasaltTheme, cssVariablesResolver } from '../theme'
|
|
25
|
+
import { buildPaletteCss } from '../tokens'
|
|
26
|
+
import type { BuildPaletteOpts } from '../tokens'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Where an error surfaced — drives consumer routing (a render error vs a global rejection differ).
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* <BasaltProvider
|
|
33
|
+
* onError={(e, ctx) => {
|
|
34
|
+
* if (ctx.kind === 'render') Sentry.captureException(e, { extra: { info: ctx.info } })
|
|
35
|
+
* if (ctx.kind === 'unhandledrejection') Sentry.captureException(e)
|
|
36
|
+
* }}
|
|
37
|
+
* >
|
|
38
|
+
*/
|
|
39
|
+
export type BasaltErrorContext =
|
|
40
|
+
| { kind: 'render'; info: ErrorInfo }
|
|
41
|
+
| { kind: 'window'; event: ErrorEvent }
|
|
42
|
+
| { kind: 'unhandledrejection'; reason: unknown }
|
|
43
|
+
|
|
44
|
+
export type BasaltProviderProps = {
|
|
45
|
+
children: ReactNode
|
|
46
|
+
/** Theme override merged onto the Basalt base. Omit to use the base theme as-is. */
|
|
47
|
+
theme?: MantineProviderProps['theme']
|
|
48
|
+
/**
|
|
49
|
+
* Inject the `--vx-*` palette stylesheet once via an inline `<style>`. Default `true`. Set
|
|
50
|
+
* `false` to skip it (SSR / head injection — emit `buildPaletteCss(paletteOptions)` yourself).
|
|
51
|
+
*/
|
|
52
|
+
injectPalette?: boolean
|
|
53
|
+
/**
|
|
54
|
+
* Passed through to `buildPaletteCss` so a consumer can append its own series/groups/derived
|
|
55
|
+
* declarations on top of the framework primitives. Additive extension to the S0 stub shape.
|
|
56
|
+
*/
|
|
57
|
+
paletteOptions?: BuildPaletteOpts
|
|
58
|
+
/** Default color scheme. Defaults to dark. */
|
|
59
|
+
defaultColorScheme?: MantineProviderProps['defaultColorScheme']
|
|
60
|
+
/**
|
|
61
|
+
* Report errors caught by the in-provider boundary AND global window/unhandledrejection listeners.
|
|
62
|
+
* Unset → console.error in dev (process.env.NODE_ENV !== 'production'), no-op in prod.
|
|
63
|
+
* NEVER a no-op prop — the BasaltErrorBoundary + listeners that feed it ship in this same freeze.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* <BasaltProvider onError={(e, ctx) => Sentry.captureException(e, { tags: { kind: ctx.kind } })}>
|
|
67
|
+
*/
|
|
68
|
+
onError?: (error: unknown, ctx: BasaltErrorContext) => void
|
|
69
|
+
/**
|
|
70
|
+
* CSP nonce for the raw palette `<style>` at provider/index.tsx (the one element `...rest`
|
|
71
|
+
* cannot reach — it is basalt's own JSX, not a Mantine prop). For Mantine's own injected styles,
|
|
72
|
+
* also pass `getStyleNonce={() => nonce}` via `...rest` — Mantine v9 has no top-level `nonce`
|
|
73
|
+
* prop; its nonce mechanism is `getStyleNonce: () => string`, which flows through `...rest`.
|
|
74
|
+
*/
|
|
75
|
+
nonce?: string
|
|
76
|
+
/** Optional SSE endpoint for connectivity monitoring. When set, an EventSource is opened. */
|
|
77
|
+
sseUrl?: string
|
|
78
|
+
/** Optional health-check endpoint for connectivity monitoring. When set, periodic GET pings run. */
|
|
79
|
+
healthUrl?: string
|
|
80
|
+
/** Interval in ms for health pings. Default: 30_000 (30s). */
|
|
81
|
+
healthIntervalMs?: number
|
|
82
|
+
} & Omit<MantineProviderProps, 'children' | 'theme' | 'defaultColorScheme'>
|
|
83
|
+
|
|
84
|
+
// ── Default error handler ─────────────────────────────────────────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
function defaultOnError(error: unknown, ctx: BasaltErrorContext): void {
|
|
87
|
+
if (process.env['NODE_ENV'] !== 'production') {
|
|
88
|
+
// eslint-disable-next-line no-console -- intentional dev-only diagnostic when no onError is supplied
|
|
89
|
+
console.error('[BasaltProvider] unhandled error', ctx.kind, error)
|
|
90
|
+
}
|
|
91
|
+
// prod: no-op
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ── Error boundary ────────────────────────────────────────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
type BoundaryProps = {
|
|
97
|
+
children: ReactNode
|
|
98
|
+
onError: (error: unknown, ctx: BasaltErrorContext) => void
|
|
99
|
+
/** Optional UI to render when a render error is caught. If a function, called with the error. Defaults to null. */
|
|
100
|
+
fallback?: ReactNode | ((error: unknown) => ReactNode)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
type BoundaryState = { hasError: boolean; error: unknown }
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Error boundary that catches render-phase errors inside `BasaltProvider`. Wraps `BasaltBridge` +
|
|
107
|
+
* children INSIDE `MantineProvider` so a thrown render error still has theme context for a fallback.
|
|
108
|
+
* Also exported so consumers can mount nested boundaries with the same `onError` contract.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* <BasaltErrorBoundary onError={(e, ctx) => Sentry.captureException(e)} fallback={<p>Something went wrong.</p>}>
|
|
112
|
+
* <MyFeature />
|
|
113
|
+
* </BasaltErrorBoundary>
|
|
114
|
+
*/
|
|
115
|
+
export class BasaltErrorBoundary extends Component<BoundaryProps, BoundaryState> {
|
|
116
|
+
constructor(props: BoundaryProps) {
|
|
117
|
+
super(props)
|
|
118
|
+
this.state = { hasError: false, error: undefined }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static getDerivedStateFromError(error: unknown): BoundaryState {
|
|
122
|
+
return { hasError: true, error }
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
override componentDidCatch(error: unknown, info: ErrorInfo): void {
|
|
126
|
+
this.props.onError(error, { kind: 'render', info })
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
override render(): ReactNode {
|
|
130
|
+
if (this.state.hasError) {
|
|
131
|
+
const { fallback } = this.props
|
|
132
|
+
if (fallback === undefined) return null
|
|
133
|
+
return typeof fallback === 'function' ? fallback(this.state.error) : fallback
|
|
134
|
+
}
|
|
135
|
+
return this.props.children
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ── Inner bridge ──────────────────────────────────────────────────────────────────────────────────
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Inner bridge — must render INSIDE `MantineProvider` to read the active color scheme. Provides
|
|
143
|
+
* the Vx chart theme context and injects the palette `<style>`. Mirrors argo's `VxBridge`.
|
|
144
|
+
* Also registers global window error listeners for the `onError` contract.
|
|
145
|
+
*/
|
|
146
|
+
function BasaltBridge({
|
|
147
|
+
children,
|
|
148
|
+
injectPalette,
|
|
149
|
+
paletteOptions,
|
|
150
|
+
nonce,
|
|
151
|
+
onError,
|
|
152
|
+
}: {
|
|
153
|
+
children: ReactNode
|
|
154
|
+
injectPalette: boolean
|
|
155
|
+
paletteOptions: BuildPaletteOpts | undefined
|
|
156
|
+
nonce: string | undefined
|
|
157
|
+
onError: (error: unknown, ctx: BasaltErrorContext) => void
|
|
158
|
+
}) {
|
|
159
|
+
// Resolve via Mantine's computed scheme so 'auto' follows the OS prefers-color-scheme
|
|
160
|
+
// (fallback 'dark' before hydration, matching the provider's defaultColorScheme).
|
|
161
|
+
const resolved = useComputedColorScheme('dark')
|
|
162
|
+
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
// SSR guard — window is not available in server contexts
|
|
165
|
+
if (typeof window === 'undefined') return
|
|
166
|
+
|
|
167
|
+
const handleError = (e: ErrorEvent): void => {
|
|
168
|
+
onError(e.error ?? e, { kind: 'window', event: e })
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const handleUnhandledRejection = (e: PromiseRejectionEvent): void => {
|
|
172
|
+
onError(e.reason, { kind: 'unhandledrejection', reason: e.reason })
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
window.addEventListener('error', handleError)
|
|
176
|
+
window.addEventListener('unhandledrejection', handleUnhandledRejection)
|
|
177
|
+
|
|
178
|
+
return () => {
|
|
179
|
+
window.removeEventListener('error', handleError)
|
|
180
|
+
window.removeEventListener('unhandledrejection', handleUnhandledRejection)
|
|
181
|
+
}
|
|
182
|
+
}, [onError])
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<VxThemeProvider colorScheme={resolved}>
|
|
186
|
+
{injectPalette ? <style nonce={nonce}>{buildPaletteCss(paletteOptions)}</style> : null}
|
|
187
|
+
{children}
|
|
188
|
+
</VxThemeProvider>
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ── Public provider ───────────────────────────────────────────────────────────────────────────────
|
|
193
|
+
|
|
194
|
+
export function BasaltProvider({
|
|
195
|
+
children,
|
|
196
|
+
theme,
|
|
197
|
+
injectPalette = true,
|
|
198
|
+
paletteOptions,
|
|
199
|
+
defaultColorScheme = 'dark',
|
|
200
|
+
onError,
|
|
201
|
+
nonce,
|
|
202
|
+
sseUrl,
|
|
203
|
+
healthUrl,
|
|
204
|
+
healthIntervalMs,
|
|
205
|
+
...rest
|
|
206
|
+
}: BasaltProviderProps) {
|
|
207
|
+
const errorHandler = onError ?? defaultOnError
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<MantineProvider
|
|
211
|
+
theme={createBasaltTheme(theme)}
|
|
212
|
+
cssVariablesResolver={cssVariablesResolver}
|
|
213
|
+
defaultColorScheme={defaultColorScheme}
|
|
214
|
+
{...rest}
|
|
215
|
+
>
|
|
216
|
+
<BasaltErrorBoundary onError={errorHandler}>
|
|
217
|
+
<BasaltBridge
|
|
218
|
+
injectPalette={injectPalette}
|
|
219
|
+
paletteOptions={paletteOptions}
|
|
220
|
+
nonce={nonce}
|
|
221
|
+
onError={errorHandler}
|
|
222
|
+
>
|
|
223
|
+
<ConnectivityProvider
|
|
224
|
+
{...(sseUrl !== undefined ? { sseUrl } : {})}
|
|
225
|
+
{...(healthUrl !== undefined ? { healthUrl } : {})}
|
|
226
|
+
{...(healthIntervalMs !== undefined ? { healthIntervalMs } : {})}
|
|
227
|
+
>
|
|
228
|
+
{children}
|
|
229
|
+
</ConnectivityProvider>
|
|
230
|
+
</BasaltBridge>
|
|
231
|
+
</BasaltErrorBoundary>
|
|
232
|
+
</MantineProvider>
|
|
233
|
+
)
|
|
234
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ./query/devtools — prod-safe lazy wrapper for @tanstack/react-query-devtools.
|
|
3
|
+
* The devtools package is an OPTIONAL peer — never imported at module evaluation time.
|
|
4
|
+
* The dynamic import() resolves only when rendered in non-production.
|
|
5
|
+
*/
|
|
6
|
+
import { lazy, Suspense } from 'react'
|
|
7
|
+
import type { ComponentProps } from 'react'
|
|
8
|
+
import type { ReactQueryDevtools } from '@tanstack/react-query-devtools'
|
|
9
|
+
|
|
10
|
+
const LazyDevtools = lazy(() =>
|
|
11
|
+
import('@tanstack/react-query-devtools').then((m) => ({ default: m.ReactQueryDevtools })),
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Lazy, production-excluded wrapper for ReactQueryDevtools. Safe to import unconditionally —
|
|
16
|
+
* the devtools chunk is only resolved when rendered outside of production and the dynamic
|
|
17
|
+
* import fires. In production this returns null immediately.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* import { BasaltQueryDevtools } from 'basalt-ui/query'
|
|
21
|
+
*
|
|
22
|
+
* function Root() {
|
|
23
|
+
* return (
|
|
24
|
+
* <QueryClientProvider client={client}>
|
|
25
|
+
* {children}
|
|
26
|
+
* <BasaltQueryDevtools initialIsOpen={false} />
|
|
27
|
+
* </QueryClientProvider>
|
|
28
|
+
* )
|
|
29
|
+
* }
|
|
30
|
+
*/
|
|
31
|
+
export function BasaltQueryDevtools(props: ComponentProps<typeof ReactQueryDevtools>) {
|
|
32
|
+
if (process.env['NODE_ENV'] === 'production') return null
|
|
33
|
+
return (
|
|
34
|
+
<Suspense fallback={null}>
|
|
35
|
+
<LazyDevtools {...props} />
|
|
36
|
+
</Suspense>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ./query — thin TanStack Query adapter + transport-agnostic Eden unwrap.
|
|
3
|
+
* Optional peer: @tanstack/react-query.
|
|
4
|
+
*/
|
|
5
|
+
import { QueryClient } from '@tanstack/react-query'
|
|
6
|
+
import type { QueryClientConfig } from '@tanstack/react-query'
|
|
7
|
+
|
|
8
|
+
// ── createBasaltQueryClient ───────────────────────────────────────────────────────────────────────
|
|
9
|
+
|
|
10
|
+
const BASALT_QUERY_DEFAULTS = {
|
|
11
|
+
staleTime: 30_000,
|
|
12
|
+
gcTime: 5 * 60 * 1000,
|
|
13
|
+
retry: 2,
|
|
14
|
+
refetchOnWindowFocus: false,
|
|
15
|
+
} as const
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Wraps QueryClient with basalt dashboard defaults. All options are mergeable — consumer
|
|
19
|
+
* overrides win per-query, framework defaults are the fallback.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* import { createBasaltQueryClient, QueryClientProvider } from 'basalt-ui/query'
|
|
23
|
+
* import { useState } from 'react'
|
|
24
|
+
*
|
|
25
|
+
* function Root({ children }: { children: React.ReactNode }) {
|
|
26
|
+
* const [client] = useState(() => createBasaltQueryClient())
|
|
27
|
+
* return <QueryClientProvider client={client}>{children}</QueryClientProvider>
|
|
28
|
+
* }
|
|
29
|
+
*/
|
|
30
|
+
export function createBasaltQueryClient(config?: QueryClientConfig): QueryClient {
|
|
31
|
+
return new QueryClient({
|
|
32
|
+
...config,
|
|
33
|
+
defaultOptions: {
|
|
34
|
+
...config?.defaultOptions,
|
|
35
|
+
queries: { ...BASALT_QUERY_DEFAULTS, ...config?.defaultOptions?.queries },
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ── unwrap ────────────────────────────────────────────────────────────────────────────────────────
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Transport-agnostic unwrap for any `{ data, error }` envelope (Eden Treaty, raw fetch wrappers,
|
|
44
|
+
* etc.). TData is inferred from the data field. Throws on the error branch so failures surface
|
|
45
|
+
* to the nearest error boundary or TanStack Query's error state.
|
|
46
|
+
*
|
|
47
|
+
* Null guard: if `error` is falsy but `data` is `null`, unwrap throws with a descriptive message.
|
|
48
|
+
* This catches 204 No Content responses and silent transport failures that return `{ data: null,
|
|
49
|
+
* error: null }` — both signal an unexpected absence of data and should not silently resolve.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* import { unwrap } from 'basalt-ui/query'
|
|
53
|
+
*
|
|
54
|
+
* queryFn: () => unwrap(api.users.get({ query: params }))
|
|
55
|
+
* // mutation:
|
|
56
|
+
* mutationFn: (body) => unwrap(api.resource.post({ body }))
|
|
57
|
+
* // manual:
|
|
58
|
+
* const rows = await unwrap(api.users.get())
|
|
59
|
+
*/
|
|
60
|
+
export async function unwrap<TData>(
|
|
61
|
+
response: Promise<{ data: TData | null; error: unknown }>,
|
|
62
|
+
): Promise<TData> {
|
|
63
|
+
const { data, error } = await response
|
|
64
|
+
if (error) throw error
|
|
65
|
+
if (data === null)
|
|
66
|
+
throw new Error(
|
|
67
|
+
'unwrap: null data with no error — check for a 204 response or a transport failure',
|
|
68
|
+
)
|
|
69
|
+
return data as TData
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ── toErrorMessage ────────────────────────────────────────────────────────────────────────────────
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Extract a human-readable message from an unknown thrown value (e.g. the raw Eden envelope
|
|
76
|
+
* thrown by `unwrap`). Removes the 8-line three-branch boilerplate consumers duplicate.
|
|
77
|
+
*
|
|
78
|
+
* Resolution order:
|
|
79
|
+
* 1. `Error` instance → err.message
|
|
80
|
+
* 2. `{ message: string }` → message (Eden / Elysia error shape)
|
|
81
|
+
* 3. `{ value: ... }` → toErrorMessage(value) recursively (Eden nested value envelope)
|
|
82
|
+
* 4. plain string → itself
|
|
83
|
+
* 5. anything else → JSON.stringify with safe fallback to String()
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* try {
|
|
87
|
+
* await unwrap(api.resource.post({ body }))
|
|
88
|
+
* } catch (e) {
|
|
89
|
+
* toast(toErrorMessage(e))
|
|
90
|
+
* }
|
|
91
|
+
*/
|
|
92
|
+
export function toErrorMessage(err: unknown): string {
|
|
93
|
+
if (err instanceof Error) return err.message
|
|
94
|
+
if (typeof err === 'string') return err
|
|
95
|
+
if (typeof err === 'object' && err !== null) {
|
|
96
|
+
const obj = err as Record<string, unknown>
|
|
97
|
+
if (typeof obj['message'] === 'string') return obj['message']
|
|
98
|
+
// Eden-style { value: ... } or { status, value } envelopes — unwrap one level.
|
|
99
|
+
if ('value' in obj) return toErrorMessage(obj['value'])
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
return JSON.stringify(err)
|
|
103
|
+
} catch {
|
|
104
|
+
return String(err)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ── Re-exports from @tanstack/react-query ────────────────────────────────────────────────────────
|
|
109
|
+
|
|
110
|
+
// Provider + boundary helpers
|
|
111
|
+
export {
|
|
112
|
+
QueryClientProvider,
|
|
113
|
+
QueryErrorResetBoundary,
|
|
114
|
+
useQueryErrorResetBoundary,
|
|
115
|
+
} from '@tanstack/react-query'
|
|
116
|
+
|
|
117
|
+
// Primary fetch hooks — import from basalt-ui/query rather than dual-importing @tanstack/react-query
|
|
118
|
+
export {
|
|
119
|
+
useQuery,
|
|
120
|
+
useSuspenseQuery,
|
|
121
|
+
useMutation,
|
|
122
|
+
useQueryClient,
|
|
123
|
+
useInfiniteQuery,
|
|
124
|
+
queryOptions,
|
|
125
|
+
} from '@tanstack/react-query'
|
|
126
|
+
|
|
127
|
+
// ── Re-export devtools helper ─────────────────────────────────────────────────────────────────────
|
|
128
|
+
|
|
129
|
+
export { BasaltQueryDevtools } from './devtools'
|
package/src/register.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Design seam — the augmentable BasaltRegister interface, the single Slot extractor, house-style
|
|
3
|
+
* primitives (AsyncState, assertNever), and the vendored Standard Schema v1 contract.
|
|
4
|
+
*
|
|
5
|
+
* Re-exported from the root barrel '.' so `declare module 'basalt-ui'` augmentation works.
|
|
6
|
+
* Mantine-free. Imports only a type from ./tokens (erased at runtime).
|
|
7
|
+
*/
|
|
8
|
+
import type { SeriesMap } from './tokens'
|
|
9
|
+
|
|
10
|
+
// ── BasaltRegister + Slot ─────────────────────────────────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The one augmentable seam — TanStack Router/Query's `interface Register {}` applied to the whole
|
|
14
|
+
* app shape. Declaration-merge your truth ONCE per concern, in that concern's own file. Every slot
|
|
15
|
+
* is optional and defaults to a never-keyed empty type; a charts-only consumer augments only
|
|
16
|
+
* `series` (or nothing) and pays zero cost.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // src/theme/series.ts — augment ONE slot in its own file, 3 lines:
|
|
20
|
+
* declare module 'basalt-ui' {
|
|
21
|
+
* interface BasaltRegister { series: typeof DEMO_SERIES }
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
export interface BasaltRegister {}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Extract a slot or fall back to the NEVER-KEYED EMPTY OBJECT `{}`.
|
|
28
|
+
*
|
|
29
|
+
* WHY `{}` AND NOT `Record<string, never>`:
|
|
30
|
+
* `keyof {}` is `never` (correct — an un-augmented slot has no keys).
|
|
31
|
+
* `keyof Record<string, never>` is `string` — silent widening that would accept every string as a
|
|
32
|
+
* 'legal' key (the TS footgun). The `{}` default and the `Extract<keyof, string>` symbol guard in
|
|
33
|
+
* SeriesKey are baked into this one place and locked by fixture J.1 / J.2.
|
|
34
|
+
*
|
|
35
|
+
* `infer S extends Constraint` is a BOUND-CHECK, not a cast — an ill-typed augment falls through
|
|
36
|
+
* to `{}` rather than poisoning the union. This ONE generic is the frozen mechanism every battery
|
|
37
|
+
* slot instantiates against. At 1.0 the `series`, `commands`, `overlays`, and `notifications`
|
|
38
|
+
* slots ship and have concrete instantiations (define-commands.ts, define-overlays.ts,
|
|
39
|
+
* define-notifications.ts); `router`, `query`, and `state` remain advisory.
|
|
40
|
+
*/
|
|
41
|
+
export type Slot<K extends string, Constraint> = BasaltRegister extends {
|
|
42
|
+
[P in K]: infer S extends Constraint
|
|
43
|
+
}
|
|
44
|
+
? S
|
|
45
|
+
: {}
|
|
46
|
+
|
|
47
|
+
/** The consumer's registered series map, or `{}` when un-augmented. */
|
|
48
|
+
export type Series = Slot<'series', SeriesMap>
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The legal series keys — Extract<…, string> drops symbol/number members that `keyof` always
|
|
52
|
+
* includes (§B.2/§6.3), so the literal union never widens via a symbol key.
|
|
53
|
+
*
|
|
54
|
+
* Un-augmented: `never` (slot is `{}`, keyof is never).
|
|
55
|
+
* Augmented: the exact string literal union of the registered series map keys.
|
|
56
|
+
*/
|
|
57
|
+
export type SeriesKey = Extract<keyof Series, string>
|
|
58
|
+
|
|
59
|
+
// ── AsyncState + assertNever ──────────────────────────────────────────────────────────────────────
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The house discriminated-union shape — N valid states, not 2ⁿ. `data` is present ONLY in
|
|
63
|
+
* 'success', `error` ONLY in 'error'. The shape AgentPart / notification kinds / command results
|
|
64
|
+
* copy in later phases.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* function view<T>(s: AsyncState<T>) {
|
|
68
|
+
* switch (s.status) {
|
|
69
|
+
* case 'idle': return null
|
|
70
|
+
* case 'loading': return <Spinner/>
|
|
71
|
+
* case 'success': return <Data value={s.data}/>
|
|
72
|
+
* case 'error': return <Err e={s.error}/>
|
|
73
|
+
* default: return assertNever(s) // tsc errors here if a variant is unhandled
|
|
74
|
+
* }
|
|
75
|
+
* }
|
|
76
|
+
*/
|
|
77
|
+
export type AsyncState<T, E = Error> =
|
|
78
|
+
| { readonly status: 'idle' }
|
|
79
|
+
| { readonly status: 'loading' }
|
|
80
|
+
| { readonly status: 'success'; readonly data: T }
|
|
81
|
+
| { readonly status: 'error'; readonly error: E }
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Exhaustiveness sentinel. A bare `default: return null` is FORBIDDEN house-style. The `never`
|
|
85
|
+
* param turns an unhandled union member into a compile error.
|
|
86
|
+
*/
|
|
87
|
+
export function assertNever(value: never): never {
|
|
88
|
+
throw new Error(`Unhandled discriminated-union variant: ${JSON.stringify(value)}`)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// ── Standard Schema v1 (vendored spec — not a package dependency) ─────────────────────────────────
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The published Standard Schema v1 `~standard` contract, vendored verbatim. It is a SPEC, not a
|
|
95
|
+
* package; ~25 lines, zero deps. Zod 4 / Valibot / ArkType all implement `~standard` and are
|
|
96
|
+
* assignable. Every validation boundary (createPersistedState, future form resolver, route search,
|
|
97
|
+
* agent payloads) types against THIS — never `ZodSchema`. Basalt invents ZERO validation
|
|
98
|
+
* primitive.
|
|
99
|
+
*
|
|
100
|
+
* EDEN-TREATY SEAM (house-style DOCTRINE — basalt ships no treaty wiring; that lands in the
|
|
101
|
+
* Phase-4 ./query battery). The seam is a `typeof` seam, never codegen:
|
|
102
|
+
* export type App = typeof app // Elysia app
|
|
103
|
+
* const api = treaty<App>(url) // Eden infers the whole API from the type
|
|
104
|
+
*
|
|
105
|
+
* THREE silent-`any` footguns — each drops a type to `any` with NO error:
|
|
106
|
+
* 1. Elysia routes MUST be method-chained (`app.get(...).post(...)`) — a non-chained route
|
|
107
|
+
* silently drops App to `any`.
|
|
108
|
+
* 2. Client & server tsconfig path aliases MUST match — a mismatch erases the inferred types.
|
|
109
|
+
* 3. An `async function*` STREAM route MUST declare `: AsyncGenerator<AgentPart>` and carry NO
|
|
110
|
+
* t.Object/t.Union response schema (eden #231) — the inner union drops to `any`. Validate at
|
|
111
|
+
* yield-time.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* // createPersistedState with Standard Schema validation:
|
|
115
|
+
* createPersistedState({ key: 'draft', version: 1, initial: DEFAULT, schema: z.object({ title: z.string() }) })
|
|
116
|
+
*/
|
|
117
|
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
118
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export namespace StandardSchemaV1 {
|
|
122
|
+
export interface Props<Input = unknown, Output = Input> {
|
|
123
|
+
readonly version: 1
|
|
124
|
+
readonly vendor: string
|
|
125
|
+
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>
|
|
126
|
+
readonly types?: Types<Input, Output> | undefined
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type Result<Output> = SuccessResult<Output> | FailureResult
|
|
130
|
+
|
|
131
|
+
export interface SuccessResult<Output> {
|
|
132
|
+
readonly value: Output
|
|
133
|
+
readonly issues?: undefined
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface FailureResult {
|
|
137
|
+
readonly issues: ReadonlyArray<Issue>
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface Issue {
|
|
141
|
+
readonly message: string
|
|
142
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface PathSegment {
|
|
146
|
+
readonly key: PropertyKey
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface Types<Input = unknown, Output = Input> {
|
|
150
|
+
readonly input: Input
|
|
151
|
+
readonly output: Output
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export type InferInput<T extends StandardSchemaV1> = NonNullable<T['~standard']['types']>['input']
|
|
155
|
+
export type InferOutput<T extends StandardSchemaV1> = NonNullable<
|
|
156
|
+
T['~standard']['types']
|
|
157
|
+
>['output']
|
|
158
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ./router-tanstack — headless TanStack Router bridge for the app shell.
|
|
3
|
+
* Optional peer: @tanstack/react-router.
|
|
4
|
+
* Augments StaticDataRouteOption with title/icon/navSection for breadcrumb
|
|
5
|
+
* and nav-active wiring — no Mantine, no JSX, no navigate() helper.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
createSearchParamStore,
|
|
10
|
+
type SearchParamStore,
|
|
11
|
+
type SearchParamStoreOptions,
|
|
12
|
+
} from './search-param-store'
|
|
13
|
+
export {
|
|
14
|
+
createMultiSearchParamStore,
|
|
15
|
+
type MultiSearchParamStore,
|
|
16
|
+
type MultiSearchParamStoreOptions,
|
|
17
|
+
} from './multi-search-param-store'
|
|
18
|
+
import type { ReactNode } from 'react'
|
|
19
|
+
import { useLocation, useMatches } from '@tanstack/react-router'
|
|
20
|
+
|
|
21
|
+
// ── StaticDataRouteOption augmentation ───────────────────────────────────────────────────────────
|
|
22
|
+
|
|
23
|
+
declare module '@tanstack/react-router' {
|
|
24
|
+
interface StaticDataRouteOption {
|
|
25
|
+
/** Page/section title — drives breadcrumbs via useRouterBreadcrumbs(). */
|
|
26
|
+
title?: string
|
|
27
|
+
/** Nav icon — ReactNode passed through to the shell SidebarItem. */
|
|
28
|
+
icon?: ReactNode
|
|
29
|
+
/** Groups sidebar items under a named section label. */
|
|
30
|
+
navSection?: string
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ── useBasaltNav ──────────────────────────────────────────────────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
/** Reactive nav-active state derived from the current TanStack Router location. */
|
|
37
|
+
export type BasaltNav = {
|
|
38
|
+
/** Current pathname (reactive, updates on every navigation). */
|
|
39
|
+
currentPath: string
|
|
40
|
+
/**
|
|
41
|
+
* True when `href` matches the current route.
|
|
42
|
+
* Default: prefix match so a parent nav item stays active on child routes.
|
|
43
|
+
* Pass `{ exact: true }` for exact-only matching.
|
|
44
|
+
* The root `'/'` always matches exactly regardless of the option.
|
|
45
|
+
*/
|
|
46
|
+
isActive: (href: string, opts?: { exact?: boolean }) => boolean
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Returns the current path and an `isActive` predicate for nav highlighting.
|
|
51
|
+
* Reads only `useLocation` — no navigate, no typed-route `to` casts.
|
|
52
|
+
* Navigation stays with TanStack's own typed `<Link>` / `useNavigate`.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* import { useBasaltNav } from 'basalt-ui/router-tanstack'
|
|
56
|
+
*
|
|
57
|
+
* function NavItem({ href, label }: { href: string; label: string }) {
|
|
58
|
+
* const { isActive } = useBasaltNav()
|
|
59
|
+
* return <NavLink href={href} active={isActive(href)}>{label}</NavLink>
|
|
60
|
+
* }
|
|
61
|
+
*/
|
|
62
|
+
export function useBasaltNav(): BasaltNav {
|
|
63
|
+
const currentPath = useLocation({ select: (l) => l.pathname })
|
|
64
|
+
|
|
65
|
+
const isActive = (href: string, opts?: { exact?: boolean }): boolean => {
|
|
66
|
+
const exact = opts?.exact === true || href === '/'
|
|
67
|
+
if (exact) return currentPath === href
|
|
68
|
+
return currentPath === href || currentPath.startsWith(href + '/')
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return { currentPath, isActive }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ── useRouterBreadcrumbs ──────────────────────────────────────────────────────────────────────────
|
|
75
|
+
|
|
76
|
+
/** A single breadcrumb entry projected from route staticData. */
|
|
77
|
+
export type BasaltBreadcrumb = {
|
|
78
|
+
/** The route's `staticData.title`. */
|
|
79
|
+
title: string
|
|
80
|
+
/** The matched pathname for this ancestor (usable as `<Link to={href}>` target). */
|
|
81
|
+
href: string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Returns the ancestor→deepest breadcrumb trail derived from `staticData.title` on each match.
|
|
86
|
+
* Routes without a `staticData.title` are silently omitted.
|
|
87
|
+
* Uses the `select` form of `useMatches` for re-render gating — only re-renders when the
|
|
88
|
+
* projected breadcrumb array actually changes shape.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* import { useRouterBreadcrumbs } from 'basalt-ui/router-tanstack'
|
|
92
|
+
*
|
|
93
|
+
* function AppBreadcrumbs() {
|
|
94
|
+
* const crumbs = useRouterBreadcrumbs()
|
|
95
|
+
* return (
|
|
96
|
+
* <nav aria-label="breadcrumb">
|
|
97
|
+
* {crumbs.map((c) => <a key={c.href} href={c.href}>{c.title}</a>)}
|
|
98
|
+
* </nav>
|
|
99
|
+
* )
|
|
100
|
+
* }
|
|
101
|
+
*/
|
|
102
|
+
export function useRouterBreadcrumbs(): BasaltBreadcrumb[] {
|
|
103
|
+
return useMatches({
|
|
104
|
+
select: (matches) =>
|
|
105
|
+
matches.flatMap((m) =>
|
|
106
|
+
typeof m.staticData?.title === 'string'
|
|
107
|
+
? [{ title: m.staticData.title, href: m.pathname }]
|
|
108
|
+
: [],
|
|
109
|
+
),
|
|
110
|
+
})
|
|
111
|
+
}
|