basalt-ui 0.4.2 → 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 +199 -41
- 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 +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 +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 -877
- package/src/starlight.css +0 -308
- package/tailwind.config.js +0 -78
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: basalt-ui
|
|
3
|
+
description: Notification conventions for basalt-ui apps — notify helpers, typed registry, persisted history store, bell/center, and BasaltNotifications overlay from the shipped ./notifications battery. @mantine/notifications is an optional peer.
|
|
4
|
+
paths:
|
|
5
|
+
- 'src/**'
|
|
6
|
+
- 'apps/**/src/**'
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Basalt Notifications
|
|
10
|
+
|
|
11
|
+
basalt-ui ships `./notifications` — a Mantine notification adapter battery providing `notify`,
|
|
12
|
+
`notifySuccess/Error/Warning/Info`, `notifyPromise`, `defineNotifications`, `emit`,
|
|
13
|
+
`useNotificationHistory`, `NotificationBell`, `NotificationCenter`, and `BasaltNotifications`
|
|
14
|
+
on top of `@mantine/notifications`. `@mantine/notifications` is an **optional peer** — install it
|
|
15
|
+
before using this battery:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bun add @mantine/notifications
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Mount BasaltNotifications
|
|
22
|
+
|
|
23
|
+
Render **one** `<BasaltNotifications />` inside `BasaltProvider`, before the router. The overlay is
|
|
24
|
+
opt-in — it is NOT auto-mounted from `BasaltProvider` to keep the peer out of the root barrel.
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { BasaltNotifications } from 'basalt-ui/notifications'
|
|
28
|
+
import { BasaltProvider } from 'basalt-ui'
|
|
29
|
+
|
|
30
|
+
createRoot(root).render(
|
|
31
|
+
<BasaltProvider>
|
|
32
|
+
<BasaltNotifications />
|
|
33
|
+
<App />
|
|
34
|
+
</BasaltProvider>,
|
|
35
|
+
)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`BasaltNotifications` wraps Mantine's `<Notifications />` with basalt defaults:
|
|
39
|
+
`position="bottom-right"`, `autoClose=4000`, `limit=5`. Pass props to override:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
<BasaltNotifications position="top-right" autoClose={3000} limit={3} />
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
NOTE: `BasaltOverlays` (from `basalt-ui/commands`) is the shipped composable mount that wires
|
|
46
|
+
notifications together with spotlight/modals in one place. A standalone `<BasaltNotifications />`
|
|
47
|
+
remains available for apps that don't use the overlays layer.
|
|
48
|
+
|
|
49
|
+
## notify
|
|
50
|
+
|
|
51
|
+
`notify(opts)` is the core helper. It maps intent → Mantine color name, sets the correct aria
|
|
52
|
+
`role` for screen reader announcement, applies per-intent `autoClose` defaults, and records the
|
|
53
|
+
toast to the persisted history store. Returns the notification id string.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { notify } from 'basalt-ui/notifications'
|
|
57
|
+
|
|
58
|
+
notify({ intent: 'success', message: 'Profile saved' })
|
|
59
|
+
notify({ intent: 'error', message: 'Upload failed', title: 'Error', autoClose: false })
|
|
60
|
+
notify({ intent: 'warning', message: 'Session expires soon', dedupKey: 'session-warn' })
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Intent → Mantine color + aria role + autoClose
|
|
64
|
+
|
|
65
|
+
| Intent | `color=` | `role=` | Default autoClose |
|
|
66
|
+
| ------- | ---------- | --------------------- | ------------------------- |
|
|
67
|
+
| success | `'green'` | `'status'` (polite) | 2000ms |
|
|
68
|
+
| info | `'blue'` | `'status'` (polite) | 3000ms |
|
|
69
|
+
| warning | `'yellow'` | `'alert'` (assertive) | 5000ms |
|
|
70
|
+
| error | `'red'` | `'alert'` (assertive) | `false` (until dismissed) |
|
|
71
|
+
|
|
72
|
+
**Never pass raw Mantine colors directly.** Always use `notify`'s `intent` field — the mapping is
|
|
73
|
+
the canonical source so screen-reader announcement and autoClose stay consistent.
|
|
74
|
+
|
|
75
|
+
### Two-layer dedup
|
|
76
|
+
|
|
77
|
+
1. **Mantine id-dedup**: passing the same `id` to `notifications.show` is a no-op on screen
|
|
78
|
+
(Mantine's built-in dedup). Pass `id` to prevent a toast from appearing twice.
|
|
79
|
+
2. **dedupKey window**: a module-level guard skips any `notify` call using the same `dedupKey`
|
|
80
|
+
within 1500ms — useful for event-driven triggers that may fire rapidly.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
// Fire rapidly — only the first call within 1500ms shows:
|
|
84
|
+
notify({ intent: 'warning', message: 'Rate limit', dedupKey: 'rate-limit-warn' })
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Convenience wrappers
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { notifySuccess, notifyError, notifyWarning, notifyInfo } from 'basalt-ui/notifications'
|
|
91
|
+
|
|
92
|
+
notifySuccess('Changes saved')
|
|
93
|
+
notifyError('Upload failed', { title: 'Storage error' })
|
|
94
|
+
notifyWarning('Session expires in 5 minutes')
|
|
95
|
+
notifyInfo('New version available', { autoClose: 10000 })
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Each wrapper calls `notify` with the matching intent. The second arg takes all `NotifyOptions`
|
|
99
|
+
fields except `intent` and `message`.
|
|
100
|
+
|
|
101
|
+
## notifyPromise
|
|
102
|
+
|
|
103
|
+
For async operations — shows a loading toast, then updates to success or error on settle.
|
|
104
|
+
Uses `notifications.show` for loading, then `notifications.update` for the final state (required
|
|
105
|
+
by Mantine to replace an existing id — `show` with the same id is a no-op).
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
import { notifyPromise } from 'basalt-ui/notifications'
|
|
109
|
+
|
|
110
|
+
await notifyPromise(uploadFile(file), {
|
|
111
|
+
loading: 'Uploading…',
|
|
112
|
+
success: 'Upload complete',
|
|
113
|
+
error: 'Upload failed',
|
|
114
|
+
})
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The promise is passed through — `await notifyPromise(...)` resolves/rejects as normal. The final
|
|
118
|
+
state is recorded to the notification history store (loading state is not recorded).
|
|
119
|
+
|
|
120
|
+
## defineNotifications + emit
|
|
121
|
+
|
|
122
|
+
`defineNotifications` is a const-generic factory (mirrors `defineSeries` from `./tokens`) for
|
|
123
|
+
typed notification kind registries. Augment `BasaltRegister.notifications` once with the spec map
|
|
124
|
+
type, then use `emit` — unknown kinds are tsc errors.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
// notifications.ts — define and augment (app-side, once):
|
|
128
|
+
import { defineNotifications } from 'basalt-ui/notifications'
|
|
129
|
+
|
|
130
|
+
export const NOTIFICATIONS = defineNotifications({
|
|
131
|
+
'upload:success': { intent: 'success', toMessage: (p: { name: string }) => `Uploaded ${p.name}` },
|
|
132
|
+
'upload:error': { intent: 'error', toMessage: (_: unknown) => 'Upload failed' },
|
|
133
|
+
'session:warn': { intent: 'warning', toMessage: () => 'Session expires soon' },
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
declare module 'basalt-ui' {
|
|
137
|
+
interface BasaltRegister {
|
|
138
|
+
notifications: typeof NOTIFICATIONS
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
// usage.ts — typed emit, unknown kinds fail tsc:
|
|
145
|
+
import { emit } from 'basalt-ui/notifications'
|
|
146
|
+
|
|
147
|
+
emit('upload:success', { name: 'photo.jpg' }) // ✓ typed payload
|
|
148
|
+
emit('upload:error', null) // ✓
|
|
149
|
+
emit('nonexistent', null) // ✗ tsc error
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`emit` resolves `intent` + calls `toMessage(payload)` from the registered spec, then calls
|
|
153
|
+
`notify()`. Pass extra `NotifyOptions` as a third argument to override spec defaults.
|
|
154
|
+
|
|
155
|
+
## defineNotification (single-spec helper)
|
|
156
|
+
|
|
157
|
+
Mirror of `defineOverlay` from `./commands` — types a single notification spec without registering
|
|
158
|
+
it. Use when splitting notification definitions across files before merging into `defineNotifications`.
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
import { defineNotification, defineNotifications } from 'basalt-ui/notifications'
|
|
162
|
+
|
|
163
|
+
// Type an isolated spec constant — useful when splitting across files:
|
|
164
|
+
const uploadSuccess = defineNotification({
|
|
165
|
+
intent: 'success',
|
|
166
|
+
toMessage: (p: { name: string }) => `Uploaded ${p.name}`,
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
// Merge into the full registry (defineNotifications does the actual registration):
|
|
170
|
+
export const NOTIFICATIONS = defineNotifications({ 'upload:success': uploadSuccess })
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
WARNING: `defineNotification` only TYPES — it does NOT register. Only `defineNotifications(map)`
|
|
174
|
+
registers. Calling `emit` without a prior `defineNotifications` is a no-op at runtime.
|
|
175
|
+
|
|
176
|
+
### `NotificationSpec` has no `title`/`icon` — by design
|
|
177
|
+
|
|
178
|
+
`NotificationSpec` is `{ intent, toMessage? }` — deliberately no `title`/`icon` field. Those stay
|
|
179
|
+
per-call `NotifyOptions` (`emit(kind, payload, { title: '…' })` or `notify({ ..., title: '…' })`),
|
|
180
|
+
so a title that varies per call site isn't forced into the registry. If every call to a given kind
|
|
181
|
+
repeats the same title, pass it at each call site — there's no registry-level default to fall back
|
|
182
|
+
on.
|
|
183
|
+
|
|
184
|
+
### Colors beyond the 4 intents live outside the registry
|
|
185
|
+
|
|
186
|
+
`notify`/`emit` only resolve `intent` to one of the four Mantine colors (§ Intent → Mantine color
|
|
187
|
+
above) — there's no `intent` override and no raw-color escape in `NotifyOptions`. A feature needing
|
|
188
|
+
per-category colored toasts beyond `success`/`info`/`warning`/`error` (e.g. achievement toasts keyed
|
|
189
|
+
by achievement type) cannot ride the typed registry. The documented stance: call Mantine's raw
|
|
190
|
+
`notifications.show({ color, ... })` directly, outside `notify`/`emit`. The cost is explicit — a
|
|
191
|
+
raw `notifications.show` toast is invisible to the persisted history store, the bell, and the
|
|
192
|
+
notification center, since only `notify`/`notifyPromise` record to history.
|
|
193
|
+
|
|
194
|
+
## Notification history store
|
|
195
|
+
|
|
196
|
+
Every `notify()` / `notifyPromise()` call records to a module-level persisted external store
|
|
197
|
+
(own `useSyncExternalStore` + versioned `{ v, value }` envelope under `basalt:notifications` in
|
|
198
|
+
localStorage). The store is **not** hook-scoped — `add`, `markRead`, `markAllRead`, `clear` are
|
|
199
|
+
module-level and callable outside React.
|
|
200
|
+
|
|
201
|
+
Ring-buffer cap: 50 items. Items store `{ id, intent, title?, message, createdAt, readAt? }` —
|
|
202
|
+
**message and title are strings** (ReactNode is not serializable). Cross-tab sync via the
|
|
203
|
+
`storage` event.
|
|
204
|
+
|
|
205
|
+
### useNotificationHistory
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
import { useNotificationHistory } from 'basalt-ui/notifications'
|
|
209
|
+
|
|
210
|
+
const { items, unreadCount, markRead, markAllRead, clear } = useNotificationHistory()
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
| Field | Type | Description |
|
|
214
|
+
| --------------- | --------------------------- | ------------------------------------------ |
|
|
215
|
+
| `items` | `NotificationHistoryItem[]` | All history (newest first, ring-buffer 50) |
|
|
216
|
+
| `unreadCount` | `number` | Items with no `readAt` |
|
|
217
|
+
| `markRead(id)` | `(id: string) => void` | Mark one item read |
|
|
218
|
+
| `markAllRead()` | `() => void` | Mark all items read |
|
|
219
|
+
| `clear()` | `() => void` | Clear all history |
|
|
220
|
+
|
|
221
|
+
## NotificationBell
|
|
222
|
+
|
|
223
|
+
A Mantine `ActionIcon` + `Indicator` showing unread count. Opens a `NotificationCenter` in a
|
|
224
|
+
`Popover`. Marks all items read when the center opens. Designed for the shell `globalActions` slot.
|
|
225
|
+
|
|
226
|
+
```tsx
|
|
227
|
+
import { NotificationBell } from 'basalt-ui/notifications'
|
|
228
|
+
import { BasaltShell } from 'basalt-ui'
|
|
229
|
+
;<BasaltShell globalActions={<NotificationBell />} {...rest} />
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
The bell renders a bell SVG icon (no `@tabler/icons` dependency — icons are ReactNode per house
|
|
233
|
+
rules). The unread indicator is capped at `9+` for counts above 9.
|
|
234
|
+
|
|
235
|
+
## NotificationCenter
|
|
236
|
+
|
|
237
|
+
Lists history items (title, message, relative time, unread dot) with "Mark all read" and "Clear"
|
|
238
|
+
actions. Consumes `useNotificationHistory`. Composable — mount it inside any Popover, Drawer, or
|
|
239
|
+
panel:
|
|
240
|
+
|
|
241
|
+
```tsx
|
|
242
|
+
import { NotificationCenter } from 'basalt-ui/notifications'
|
|
243
|
+
import { Drawer } from '@mantine/core'
|
|
244
|
+
;<Drawer opened={opened} onClose={close} title="Notifications">
|
|
245
|
+
<NotificationCenter maxHeight={500} />
|
|
246
|
+
</Drawer>
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
`NotificationBell` uses `NotificationCenter` internally. Mount `NotificationCenter` directly only
|
|
250
|
+
when you need a custom container (e.g. a full-page notifications view or a custom Drawer).
|
|
251
|
+
|
|
252
|
+
## Deferred (not yet shipped)
|
|
253
|
+
|
|
254
|
+
The following features are advisory notes for future work — they are NOT part of the current battery:
|
|
255
|
+
|
|
256
|
+
- **Web Push** (`usePushSubscription` + `sw.js` + Elysia push route): server-side push delivery
|
|
257
|
+
for background notifications. Requires a service worker, a push endpoint, and a vapid key.
|
|
258
|
+
- **Visibility-aware delivery buffering**: buffer toasts while the tab is hidden (`document.hidden`)
|
|
259
|
+
and flush on `visibilitychange` — prevents lost toasts when the tab is backgrounded.
|
|
260
|
+
- **IntersectionObserver per-item mark-seen**: replace the mark-read-on-open approach with
|
|
261
|
+
per-item IntersectionObserver so only viewed items are marked read (higher fidelity).
|
|
262
|
+
- **Cross-device read-sync**: propagate `readAt` via an Elysia endpoint so read state syncs
|
|
263
|
+
across browser sessions (requires auth and a backend store).
|
|
264
|
+
- **Quiet hours**: suppress non-error toasts during a configurable time window.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: basalt-ui
|
|
3
|
+
description: TanStack Query conventions for basalt-ui apps — query factories, Suspense reads, and mutation/invalidation. basalt-ui ships ./query (createBasaltQueryClient + unwrap + devtools); this rule covers the advisory consumer patterns on top.
|
|
4
|
+
paths:
|
|
5
|
+
- 'src/lib/queries/**'
|
|
6
|
+
- 'apps/**/src/lib/queries/**'
|
|
7
|
+
- 'src/routes/**'
|
|
8
|
+
- 'apps/**/src/routes/**'
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Basalt Query — TanStack Query Conventions
|
|
12
|
+
|
|
13
|
+
basalt-ui ships `./query` — a thin TanStack Query adapter providing `createBasaltQueryClient`,
|
|
14
|
+
`unwrap`, `BasaltQueryDevtools`, and convenience re-exports (`QueryClientProvider`,
|
|
15
|
+
`QueryErrorResetBoundary`, `useQueryErrorResetBoundary`). @tanstack/react-query is a **required**
|
|
16
|
+
peer — `BasaltProvider` hard-requires it at build time.
|
|
17
|
+
|
|
18
|
+
`./query` also re-exports the primary fetch hooks so consumers never need to dual-import from both
|
|
19
|
+
`basalt-ui/query` and `@tanstack/react-query`:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import {
|
|
23
|
+
useQuery,
|
|
24
|
+
useSuspenseQuery,
|
|
25
|
+
useMutation,
|
|
26
|
+
useQueryClient,
|
|
27
|
+
useInfiniteQuery,
|
|
28
|
+
queryOptions,
|
|
29
|
+
} from 'basalt-ui/query'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This rule covers the advisory consumer patterns on top of that adapter. Nothing in the framework
|
|
33
|
+
enforces these conventions beyond the `unwrap` seam.
|
|
34
|
+
|
|
35
|
+
## Query factories
|
|
36
|
+
|
|
37
|
+
Each resource has a factory in `src/lib/queries/<resource>.ts`:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { queryOptions, useSuspenseQuery } from 'basalt-ui/query'
|
|
41
|
+
import { unwrap } from 'basalt-ui/query'
|
|
42
|
+
import { api } from '../api-client'
|
|
43
|
+
|
|
44
|
+
export const resourceQueries = {
|
|
45
|
+
list: (params: ListParams) =>
|
|
46
|
+
queryOptions({
|
|
47
|
+
queryKey: ['resource', 'list', params],
|
|
48
|
+
queryFn: () => unwrap(api.resource.get({ query: params })),
|
|
49
|
+
}),
|
|
50
|
+
summary: () =>
|
|
51
|
+
queryOptions({
|
|
52
|
+
queryKey: ['resource', 'summary'],
|
|
53
|
+
queryFn: () => unwrap(api.resource.summary.get()),
|
|
54
|
+
}),
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- Key hierarchy: `[resource, action, ...params]`.
|
|
59
|
+
- `queryOptions` and all hooks import from `basalt-ui/query` — do not dual-import from
|
|
60
|
+
`@tanstack/react-query` directly.
|
|
61
|
+
- `queryFn` unwraps typed responses via `unwrap()` — throws on the error branch so failures surface
|
|
62
|
+
to the nearest error boundary or TanStack Query's error state. Also throws when `data` is `null`
|
|
63
|
+
with no error (e.g. a 204 No Content or a silent transport failure that returns
|
|
64
|
+
`{ data: null, error: null }`). Both cases are bugs the caller must address.
|
|
65
|
+
- Never use raw strings as query keys in components — always import from the factory.
|
|
66
|
+
|
|
67
|
+
## Reading data in components
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { useSuspenseQuery } from 'basalt-ui/query'
|
|
71
|
+
|
|
72
|
+
const { data } = useSuspenseQuery(resourceQueries.summary())
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- Always `useSuspenseQuery` inside loader-prefetched routes (never `useQuery`) — pairs with the
|
|
76
|
+
router's `ensureQueryData` (see basalt-router.md).
|
|
77
|
+
- Wrap pages or panels in `<Suspense fallback={…}>` at the route level.
|
|
78
|
+
|
|
79
|
+
## Mutations
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
const mutation = useMutation({
|
|
83
|
+
mutationFn: (body) => unwrap(api.resource.post({ body })),
|
|
84
|
+
onSuccess: () => {
|
|
85
|
+
queryClient.invalidateQueries({ queryKey: ['resource'] })
|
|
86
|
+
notifications.show({ message: 'Saved', color: 'green' })
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
- Invalidate by resource prefix (first key segment) — catches list + summary at once.
|
|
92
|
+
- Show a notification on success; let errors bubble to the global error boundary.
|
|
93
|
+
- For the in-button success flip (loading spinner → green `IconCheck`), drive it off `mutation.isPending`
|
|
94
|
+
/ `mutation.isSuccess` — see the interaction-feedback section in basalt-mantine.md.
|
|
95
|
+
|
|
96
|
+
## DevTools
|
|
97
|
+
|
|
98
|
+
Use `BasaltQueryDevtools` from `basalt-ui/query` — it is lazy, production-excluded, and safe to
|
|
99
|
+
import unconditionally:
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { BasaltQueryDevtools, QueryClientProvider } from 'basalt-ui/query'
|
|
103
|
+
|
|
104
|
+
function Root() {
|
|
105
|
+
return (
|
|
106
|
+
<QueryClientProvider client={client}>
|
|
107
|
+
{children}
|
|
108
|
+
<BasaltQueryDevtools initialIsOpen={false} />
|
|
109
|
+
</QueryClientProvider>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Never import `@tanstack/react-query-devtools` directly in app code — it is an optional peer and
|
|
115
|
+
the lazy wrapper handles the production guard for you.
|
|
116
|
+
|
|
117
|
+
## Eden footguns (hard authoring rules)
|
|
118
|
+
|
|
119
|
+
Two patterns silently degrade Eden Treaty inference to `any` — both must be avoided:
|
|
120
|
+
|
|
121
|
+
1. **Non-chained route definitions**: Elysia routes MUST be method-chained on the `app` instance.
|
|
122
|
+
A standalone `app.get(...)` (reassigned or called without chaining back to the root) drops the
|
|
123
|
+
`App` type to `any`, which propagates into the Treaty client and loses all type safety.
|
|
124
|
+
|
|
125
|
+
2. **Mismatched tsconfig path aliases**: The client package and the server package MUST share or
|
|
126
|
+
extend one root `tsconfig` so path aliases (`~/*`, `@/*`, etc.) resolve identically in both.
|
|
127
|
+
A mismatch causes Eden's type extraction to fail silently and degrade to `any`.
|
|
128
|
+
|
|
129
|
+
Both footguns produce no TypeScript error at the point of breakage — they only manifest as `any`
|
|
130
|
+
types on the Treaty client, making them hard to spot. Check these first when Eden types regress.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: basalt-ui
|
|
3
|
+
description: TanStack Router conventions for basalt-ui apps — file-based routes, typed search params, and loader/query coupling. Advisory (ships an optional ./router-tanstack adapter for active-state and breadcrumb wiring).
|
|
4
|
+
paths:
|
|
5
|
+
- 'src/routes/**'
|
|
6
|
+
- 'apps/**/src/routes/**'
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Basalt Router — TanStack Router Conventions
|
|
10
|
+
|
|
11
|
+
basalt-ui is **router-agnostic** — `BasaltShell` takes a `NavLinkRenderer` for nav rendering and
|
|
12
|
+
receives active state from the consumer. Nav active-state can now be resolved via
|
|
13
|
+
`useBasaltNav().isActive(item.href)` from `basalt-ui/router-tanstack`, and breadcrumbs via
|
|
14
|
+
`useRouterBreadcrumbs()`; navigation itself stays with TanStack's typed `<Link>` / `useNavigate`.
|
|
15
|
+
Badge counts and navigation wiring remain consumer-side. This rule is the recommended opinion layer
|
|
16
|
+
when you use TanStack Router (the basalt-ui default). It is **advisory** — adopt it for
|
|
17
|
+
consistency; nothing in the framework enforces it.
|
|
18
|
+
|
|
19
|
+
## Adding a page
|
|
20
|
+
|
|
21
|
+
1. Create `src/routes/<page-name>.tsx`.
|
|
22
|
+
2. Export `Route` via `createFileRoute('/<page-name>')`.
|
|
23
|
+
3. Add `validateSearch` with a Zod schema parsed via a function — not the schema passed directly.
|
|
24
|
+
4. Define `loaderDeps` to forward search params to the loader (required for search-param-driven queries).
|
|
25
|
+
5. Add a `loader` that calls `ensureQueryData` for each query the page needs.
|
|
26
|
+
6. Register the page in your `BasaltShell` sidebar sections (`SidebarSection[]`).
|
|
27
|
+
|
|
28
|
+
## Route structure
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { createFileRoute } from '@tanstack/react-router'
|
|
32
|
+
import { useSuspenseQuery } from 'basalt-ui/query'
|
|
33
|
+
import { z } from 'zod'
|
|
34
|
+
import { resourceQueries } from '../lib/queries/resource'
|
|
35
|
+
|
|
36
|
+
const SearchSchema = z.object({
|
|
37
|
+
window: z.enum(['7d', '30d', '90d', 'all']).default('30d'),
|
|
38
|
+
from: z.string().optional(),
|
|
39
|
+
to: z.string().optional(),
|
|
40
|
+
})
|
|
41
|
+
type SearchParams = z.infer<typeof SearchSchema>
|
|
42
|
+
|
|
43
|
+
export const Route = createFileRoute('/resource')({
|
|
44
|
+
validateSearch: (raw: Record<string, unknown>) => SearchSchema.parse(raw),
|
|
45
|
+
loaderDeps: ({ search }: { search: SearchParams }) => ({
|
|
46
|
+
window: search.window,
|
|
47
|
+
from: search.from,
|
|
48
|
+
to: search.to,
|
|
49
|
+
}),
|
|
50
|
+
loader: ({ context, deps }) =>
|
|
51
|
+
Promise.all([
|
|
52
|
+
context.queryClient.ensureQueryData(resourceQueries.summary(deps)),
|
|
53
|
+
context.queryClient.ensureQueryData(resourceQueries.series(deps)),
|
|
54
|
+
]),
|
|
55
|
+
component: ResourcePage,
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
function ResourcePage() {
|
|
59
|
+
const search = Route.useSearch()
|
|
60
|
+
const { data } = useSuspenseQuery(resourceQueries.summary(search))
|
|
61
|
+
// render — charts read VX.* tokens; chrome uses Mantine
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## validateSearch
|
|
66
|
+
|
|
67
|
+
- Always parse with the schema-function form: `(raw) => SearchSchema.parse(raw)`.
|
|
68
|
+
- Default values live in the schema (`.default()`), not in the component.
|
|
69
|
+
- Access via `const search = Route.useSearch()`.
|
|
70
|
+
- Update via `navigate({ search: { window: 'all', from: undefined, to: undefined } })` — prefer plain
|
|
71
|
+
objects over reducers to avoid `| undefined` assignability errors when the schema has defaults.
|
|
72
|
+
|
|
73
|
+
## loaderDeps
|
|
74
|
+
|
|
75
|
+
- Define `loaderDeps` whenever the loader depends on search params. Without it, search-param changes do
|
|
76
|
+
not re-trigger the loader.
|
|
77
|
+
- The `deps` object is forwarded to the loader and should be passed directly to the `ensureQueryData`
|
|
78
|
+
query factories.
|
|
79
|
+
|
|
80
|
+
## Loaders
|
|
81
|
+
|
|
82
|
+
- Use `ensureQueryData` (not `fetchQuery`) so cached data is reused.
|
|
83
|
+
- The loader receives `context: { queryClient }` — wire it in your router config.
|
|
84
|
+
- Loaders do not return data to the component — components read via `useSuspenseQuery`.
|
|
85
|
+
- When a redirect from another route points here, include the required `search` params or TypeScript
|
|
86
|
+
raises `MakeRequiredSearchParams`.
|
|
87
|
+
|
|
88
|
+
## Route tree
|
|
89
|
+
|
|
90
|
+
`src/routeTree.gen.ts` is auto-generated by the Vite plugin — never edit it. Regenerated by
|
|
91
|
+
`tsr generate` (also during `typecheck`). File names starting with `__` are reserved; only `__root.tsx`
|
|
92
|
+
is valid.
|
|
93
|
+
|
|
94
|
+
The shipped oxlint preset does **not** ban `react-router` or `react-router-dom` — basalt is
|
|
95
|
+
router-agnostic and imposes no mechanical guard. TanStack Router is the recommended/idiomatic
|
|
96
|
+
choice (this rule documents its conventions, and the `./router-tanstack` adapter targets it), but
|
|
97
|
+
using `react-router` is an advisory preference, not an enforced restriction.
|
|
98
|
+
|
|
99
|
+
## ./router-tanstack adapter
|
|
100
|
+
|
|
101
|
+
The optional `./router-tanstack` subpath ships a headless (Mantine-free) TanStack Router bridge.
|
|
102
|
+
Install `@tanstack/react-router` as a peer, then import from `basalt-ui/router-tanstack`.
|
|
103
|
+
|
|
104
|
+
**Prerequisites:**
|
|
105
|
+
|
|
106
|
+
- `@tanstack/router-plugin/vite` must be configured in your Vite config and `tsr generate` must
|
|
107
|
+
have run at least once — the `StaticDataRouteOption` augmentation only takes effect once the route
|
|
108
|
+
tree (`src/routeTree.gen.ts`) has been generated. In CI and after adding routes, run
|
|
109
|
+
`tsr generate` (or `bun run typecheck`, which triggers it) before relying on breadcrumb or nav data.
|
|
110
|
+
- The loader's `context.queryClient` requires `createRootRouteWithContext<{ queryClient: QueryClient }>()`.
|
|
111
|
+
Run `basalt init` to scaffold a `query-client.ts` + `__root.tsx` seed that wires the TanStack
|
|
112
|
+
Router + Query context correctly — the generated `__root.tsx` uses
|
|
113
|
+
`createRootRouteWithContext<{ queryClient }>()` and passes the client through `RouterProvider`.
|
|
114
|
+
|
|
115
|
+
**StaticDataRouteOption augmentation** — declare on any route to drive the adapter:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
export const Route = createFileRoute('/reports')({
|
|
119
|
+
staticData: { title: 'Reports', navSection: 'Insights' },
|
|
120
|
+
component: ReportsPage,
|
|
121
|
+
})
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Augmented fields: `title?: string`, `icon?: ReactNode`, `navSection?: string` (all optional — any
|
|
125
|
+
route remains valid without them).
|
|
126
|
+
|
|
127
|
+
**useBasaltNav** — reactive active-state resolution:
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
import { useBasaltNav } from 'basalt-ui/router-tanstack'
|
|
131
|
+
|
|
132
|
+
const { currentPath, isActive } = useBasaltNav()
|
|
133
|
+
isActive('/reports') // prefix match (active on /reports/42 too)
|
|
134
|
+
isActive('/reports', { exact: true }) // exact match only
|
|
135
|
+
isActive('/') // always exact (root is never a prefix match)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**useRouterBreadcrumbs** — ancestor→deepest breadcrumb trail from `staticData.title`:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import { useRouterBreadcrumbs } from 'basalt-ui/router-tanstack'
|
|
142
|
+
|
|
143
|
+
function AppBreadcrumbs() {
|
|
144
|
+
const crumbs = useRouterBreadcrumbs()
|
|
145
|
+
return <nav>{crumbs.map((c) => <a key={c.href} href={c.href}>{c.title}</a>)}</nav>
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**renderNavLink pattern** — wire the shell's `NavLinkRenderer` with typed TanStack routes.
|
|
150
|
+
basalt does NOT ship this renderer; typed-route `to` is the consumer's typed concern:
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
import { Link } from '@tanstack/react-router'
|
|
154
|
+
import { NavLink as MantineNavLink } from '@mantine/core'
|
|
155
|
+
import { useBasaltNav } from 'basalt-ui/router-tanstack'
|
|
156
|
+
import type { NavLinkRenderer } from 'basalt-ui'
|
|
157
|
+
|
|
158
|
+
const { isActive } = useBasaltNav()
|
|
159
|
+
|
|
160
|
+
const renderNavLink: NavLinkRenderer = (item, _flags) => (
|
|
161
|
+
<MantineNavLink
|
|
162
|
+
component={Link}
|
|
163
|
+
to={item.href ?? '/'}
|
|
164
|
+
label={item.label}
|
|
165
|
+
leftSection={item.icon}
|
|
166
|
+
rightSection={item.badge}
|
|
167
|
+
active={isActive(item.href ?? '/')}
|
|
168
|
+
/>
|
|
169
|
+
)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Navigation (`.navigate()`, `<Link to={…}>`) is always the consumer's typed concern — the adapter
|
|
173
|
+
exposes no `navigate()` helper so that TanStack's route-tree types remain authoritative.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: basalt-ui
|
|
3
|
+
description: Client state conventions for basalt-ui apps — where each kind of state lives and the theme-scheme rule (localStorage-theme read is guarded). Mostly advisory.
|
|
4
|
+
paths:
|
|
5
|
+
- 'src/**'
|
|
6
|
+
- 'apps/**/src/**'
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Basalt State
|
|
10
|
+
|
|
11
|
+
How to place state in a basalt-ui app. The **theme-scheme rule** below is
|
|
12
|
+
guard-enforced (`basalt check-theme` bans `localStorage.getItem('theme')`); the rest is **advisory**.
|
|
13
|
+
|
|
14
|
+
## State placement
|
|
15
|
+
|
|
16
|
+
Pick the right home for each kind of state — don't dump everything into one store:
|
|
17
|
+
|
|
18
|
+
- **Server state** (API data) → TanStack Query (see basalt-query.md).
|
|
19
|
+
- **URL state** (filters, active tab, pagination, time window) → `validateSearch` in TanStack Router
|
|
20
|
+
(see basalt-router.md). URL state is shareable and survives reload — prefer it for anything a user
|
|
21
|
+
might link to.
|
|
22
|
+
- **Theme / color scheme** → `useMantineColorScheme()` from Mantine — **never** a client store, and
|
|
23
|
+
**never** `localStorage.getItem('theme')`. The scheme persists to Mantine's own key and resolves the
|
|
24
|
+
`--vx-*` tokens via CSS; reading it any other way breaks scheme reactivity and trips `basalt check-theme`.
|
|
25
|
+
- **UI preferences that must survive navigation but aren't URL-worthy** (sidebar collapsed, panel
|
|
26
|
+
layout, draft filters) → `createPersistedState` from `basalt-ui/state` — the framework's own
|
|
27
|
+
versioned localStorage primitive (see below). `BasaltShell` already persists its own collapse state
|
|
28
|
+
internally; use `createPersistedState` for app-level preferences. Reach for a third-party store
|
|
29
|
+
only when complex cross-component state genuinely warrants it (see escape hatch below).
|
|
30
|
+
|
|
31
|
+
## useOnlineStatus — SSR-safe online/offline hook
|
|
32
|
+
|
|
33
|
+
`useOnlineStatus()` returns `true` when the browser reports an active network connection,
|
|
34
|
+
`false` when offline. Backed by `useSyncExternalStore` + `window.online`/`offline` events.
|
|
35
|
+
SSR-safe — server snapshot is `true` (optimistic). Exported from both `basalt-ui` (root) and
|
|
36
|
+
`basalt-ui/state`.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { useOnlineStatus } from 'basalt-ui/state'
|
|
40
|
+
|
|
41
|
+
const isOnline = useOnlineStatus()
|
|
42
|
+
if (!isOnline) return <OfflineBanner />
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
No props, no options. Use it in any component; no provider needed.
|
|
46
|
+
|
|
47
|
+
## createPersistedState — the default primitive
|
|
48
|
+
|
|
49
|
+
`createPersistedState` is a factory hook: call it once at module scope, use the returned hook in
|
|
50
|
+
components. SSR-safe, cross-tab via the `storage` event, versioned to handle shape migrations.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { createPersistedState } from 'basalt-ui/state'
|
|
54
|
+
|
|
55
|
+
// 1. Define the hook once (version: increment when the shape changes):
|
|
56
|
+
export const usePanelLayout = createPersistedState({
|
|
57
|
+
key: 'panel-layout',
|
|
58
|
+
version: 1,
|
|
59
|
+
initial: 'split' as 'split' | 'stacked',
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
// 2. Use in any component — no provider, no context:
|
|
63
|
+
const [layout, setLayout] = usePanelLayout()
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Keys are namespaced `basalt:<key>` automatically and never collide with the theme-scheme guard.
|
|
67
|
+
Pass a `schema` (Standard Schema) to validate persisted values and fall back to `initial` on mismatch.
|
|
68
|
+
|
|
69
|
+
## Zustand escape hatch (complex cross-component stores)
|
|
70
|
+
|
|
71
|
+
Reach for Zustand only when `createPersistedState` is insufficient — typically when multiple
|
|
72
|
+
unrelated components share mutable state that is **not** URL-worthy and has no single owning
|
|
73
|
+
component:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { create } from 'zustand'
|
|
77
|
+
import { persist } from 'zustand/middleware'
|
|
78
|
+
|
|
79
|
+
type UiState = {
|
|
80
|
+
panelLayout: 'split' | 'stacked'
|
|
81
|
+
setPanelLayout: (v: UiState['panelLayout']) => void
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const useUiStore = create<UiState>()(
|
|
85
|
+
persist(
|
|
86
|
+
(set) => ({
|
|
87
|
+
panelLayout: 'split',
|
|
88
|
+
setPanelLayout: (v) => set({ panelLayout: v }),
|
|
89
|
+
}),
|
|
90
|
+
{ name: 'app-ui' },
|
|
91
|
+
),
|
|
92
|
+
)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
basalt-ui does **not** ship or depend on Zustand — it is a consumer choice. Resist putting
|
|
96
|
+
query results, derived data, or theme scheme in any store.
|
|
97
|
+
|
|
98
|
+
> **Forms** are covered by `basalt-forms.md` — see `./forms` (useBasaltForm, field, FormErrorSummary,
|
|
99
|
+
> useFormDraft). `@mantine/form` is an optional peer; install it with `bun add @mantine/form`.
|