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,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ./notifications — Mantine notification adapter battery.
|
|
3
|
+
*
|
|
4
|
+
* Provides notify helpers, a typed registry, a persisted history store, and a bell/center
|
|
5
|
+
* overlay component on top of @mantine/notifications.
|
|
6
|
+
*
|
|
7
|
+
* Optional peer: @mantine/notifications ^9.3.0.
|
|
8
|
+
*
|
|
9
|
+
* Install with: bun add @mantine/notifications
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // main.tsx — mount the overlay:
|
|
13
|
+
* import { BasaltNotifications } from 'basalt-ui/notifications'
|
|
14
|
+
* <BasaltProvider><BasaltNotifications /><App /></BasaltProvider>
|
|
15
|
+
*
|
|
16
|
+
* // Usage:
|
|
17
|
+
* import { notifySuccess, notifyError, notifyPromise, NotificationBell } from 'basalt-ui/notifications'
|
|
18
|
+
* notifySuccess('Saved')
|
|
19
|
+
* notifyError('Failed', { title: 'Upload error' })
|
|
20
|
+
* notifyPromise(save(), { loading: 'Saving…', success: 'Saved', error: 'Failed' })
|
|
21
|
+
*
|
|
22
|
+
* // Shell bell (globalActions slot):
|
|
23
|
+
* <BasaltShell globalActions={<NotificationBell />} ... />
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
// ── notify core ───────────────────────────────────────────────────────────────
|
|
27
|
+
export {
|
|
28
|
+
notify,
|
|
29
|
+
notifySuccess,
|
|
30
|
+
notifyError,
|
|
31
|
+
notifyWarning,
|
|
32
|
+
notifyInfo,
|
|
33
|
+
notifyPromise,
|
|
34
|
+
} from './notify'
|
|
35
|
+
export type { NotifyOptions, NotifyPromiseMessages } from './notify'
|
|
36
|
+
|
|
37
|
+
// ── defineNotification + defineNotifications + typed emit ─────────────────────
|
|
38
|
+
export {
|
|
39
|
+
defineNotification,
|
|
40
|
+
defineNotifications,
|
|
41
|
+
emit,
|
|
42
|
+
resolveAction,
|
|
43
|
+
type NotificationAction,
|
|
44
|
+
type NotificationKind,
|
|
45
|
+
type NotificationSpec,
|
|
46
|
+
type NotificationSpecMap,
|
|
47
|
+
type NotificationIntent,
|
|
48
|
+
} from './define-notifications'
|
|
49
|
+
|
|
50
|
+
// ── history store ─────────────────────────────────────────────────────────────
|
|
51
|
+
export {
|
|
52
|
+
add,
|
|
53
|
+
markRead,
|
|
54
|
+
markAllRead,
|
|
55
|
+
dismiss,
|
|
56
|
+
dismissAll,
|
|
57
|
+
remove,
|
|
58
|
+
clear,
|
|
59
|
+
needsAttention,
|
|
60
|
+
useNotificationHistory,
|
|
61
|
+
} from './store'
|
|
62
|
+
export type {
|
|
63
|
+
NotificationActionRef,
|
|
64
|
+
NotificationHistoryItem,
|
|
65
|
+
NotificationHistoryState,
|
|
66
|
+
UseNotificationHistoryReturn,
|
|
67
|
+
} from './store'
|
|
68
|
+
|
|
69
|
+
// ── NotificationBell ──────────────────────────────────────────────────────────
|
|
70
|
+
export { NotificationBell } from './bell'
|
|
71
|
+
export type { NotificationBellProps } from './bell'
|
|
72
|
+
|
|
73
|
+
// ── NotificationCenter ────────────────────────────────────────────────────────
|
|
74
|
+
export { NotificationCenter } from './center'
|
|
75
|
+
export type { NotificationCenterProps } from './center'
|
|
76
|
+
|
|
77
|
+
// ── BasaltNotifications overlay ───────────────────────────────────────────────
|
|
78
|
+
export { BasaltNotifications } from './overlay'
|
|
79
|
+
export type { BasaltNotificationsProps } from './overlay'
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* notify — core toast helper wrapping @mantine/notifications.
|
|
3
|
+
*
|
|
4
|
+
* Maps intent → Mantine color name, sets per-intent aria role and autoClose defaults,
|
|
5
|
+
* records every toast into the module-level history store, and applies two-layer dedup:
|
|
6
|
+
* 1. Mantine id-dedup (passing the same id to notifications.show is a no-op on screen)
|
|
7
|
+
* 2. dedupKey window — module-level Map prevents duplicate keys within 1500ms
|
|
8
|
+
*
|
|
9
|
+
* For loading→success/error transitions use notifyPromise — it calls notifications.update
|
|
10
|
+
* (never show()) so the loading state is replaced correctly.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* notify({ intent: 'success', message: 'Saved' })
|
|
14
|
+
* notify({ intent: 'error', message: 'Failed', title: 'Upload error', autoClose: false })
|
|
15
|
+
* notifyPromise(apiCall(), { loading: 'Saving…', success: 'Saved', error: 'Failed' })
|
|
16
|
+
*/
|
|
17
|
+
import type { ReactNode } from 'react'
|
|
18
|
+
import { notifications } from '@mantine/notifications'
|
|
19
|
+
import { add } from './store'
|
|
20
|
+
import type { NotificationIntent, NotificationActionRef } from './store'
|
|
21
|
+
|
|
22
|
+
export type { NotificationIntent }
|
|
23
|
+
|
|
24
|
+
// ── Intent → Mantine color + defaults ────────────────────────────────────────
|
|
25
|
+
|
|
26
|
+
const INTENT_COLOR: Record<NotificationIntent, string> = {
|
|
27
|
+
success: 'green',
|
|
28
|
+
error: 'red',
|
|
29
|
+
warning: 'yellow',
|
|
30
|
+
info: 'blue',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Aria role per intent.
|
|
35
|
+
* 'alert' = assertive (error/warning: must be announced immediately)
|
|
36
|
+
* 'status' = polite (success/info: waits for a natural pause)
|
|
37
|
+
*/
|
|
38
|
+
const INTENT_ROLE: Record<NotificationIntent, 'alert' | 'status'> = {
|
|
39
|
+
error: 'alert',
|
|
40
|
+
warning: 'alert',
|
|
41
|
+
success: 'status',
|
|
42
|
+
info: 'status',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Per-intent default autoClose (ms). false = until-dismissed. */
|
|
46
|
+
const INTENT_AUTO_CLOSE: Record<NotificationIntent, number | false> = {
|
|
47
|
+
success: 2000,
|
|
48
|
+
info: 3000,
|
|
49
|
+
warning: 5000,
|
|
50
|
+
error: false,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ── Two-layer dedup — dedupKey window ────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
const DEDUP_WINDOW_MS = 1500
|
|
56
|
+
const dedupKeyTimestamps = new Map<string, number>()
|
|
57
|
+
|
|
58
|
+
function isDuplicateKey(dedupKey: string): boolean {
|
|
59
|
+
const last = dedupKeyTimestamps.get(dedupKey)
|
|
60
|
+
if (last !== undefined && Date.now() - last < DEDUP_WINDOW_MS) return true
|
|
61
|
+
dedupKeyTimestamps.set(dedupKey, Date.now())
|
|
62
|
+
return false
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ── ID generation ─────────────────────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
let seq = 0
|
|
68
|
+
function nextId(): string {
|
|
69
|
+
return `basalt-${Date.now()}-${++seq}`
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ── NotifyOptions ─────────────────────────────────────────────────────────────
|
|
73
|
+
|
|
74
|
+
export type NotifyOptions = {
|
|
75
|
+
intent?: NotificationIntent
|
|
76
|
+
message: ReactNode
|
|
77
|
+
title?: ReactNode
|
|
78
|
+
icon?: ReactNode
|
|
79
|
+
autoClose?: number | false
|
|
80
|
+
id?: string
|
|
81
|
+
dedupKey?: string
|
|
82
|
+
/**
|
|
83
|
+
* A serializable action ref — gives the recorded item an action button in the notification
|
|
84
|
+
* center. Usually attached automatically by `emit()` from the kind's spec; pass it directly
|
|
85
|
+
* only when calling `notify()` for an action registered in the notifications registry.
|
|
86
|
+
*/
|
|
87
|
+
action?: NotificationActionRef
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ── notify ────────────────────────────────────────────────────────────────────
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Show a toast and record it to the notification history.
|
|
94
|
+
* Returns the notification id (string).
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* const id = notify({ intent: 'success', message: 'Profile saved', title: 'Success' })
|
|
98
|
+
* const id = notify({ intent: 'error', message: <b>Failed</b>, autoClose: false })
|
|
99
|
+
*/
|
|
100
|
+
export function notify(opts: NotifyOptions): string {
|
|
101
|
+
const { intent = 'info', message, title, icon, autoClose, id, dedupKey, action } = opts
|
|
102
|
+
|
|
103
|
+
// Two-layer dedup: dedupKey window guard
|
|
104
|
+
if (dedupKey !== undefined && isDuplicateKey(dedupKey)) return id ?? nextId()
|
|
105
|
+
|
|
106
|
+
const resolvedId = id ?? nextId()
|
|
107
|
+
const color = INTENT_COLOR[intent]
|
|
108
|
+
const role = INTENT_ROLE[intent]
|
|
109
|
+
const resolvedAutoClose = autoClose !== undefined ? autoClose : INTENT_AUTO_CLOSE[intent]
|
|
110
|
+
|
|
111
|
+
notifications.show({
|
|
112
|
+
id: resolvedId,
|
|
113
|
+
message,
|
|
114
|
+
title: title ?? undefined,
|
|
115
|
+
color,
|
|
116
|
+
icon: icon ?? undefined,
|
|
117
|
+
autoClose: resolvedAutoClose,
|
|
118
|
+
role,
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
// Record to history store (stringify ReactNode — store only serializable text)
|
|
122
|
+
add({
|
|
123
|
+
id: resolvedId,
|
|
124
|
+
intent,
|
|
125
|
+
...(title !== undefined && { title: String(title) }),
|
|
126
|
+
message: String(message),
|
|
127
|
+
createdAt: Date.now(),
|
|
128
|
+
...(action !== undefined && { action }),
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
return resolvedId
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ── Convenience wrappers ──────────────────────────────────────────────────────
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Show a success toast.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* notifySuccess('Profile saved')
|
|
141
|
+
* notifySuccess('Done', { title: 'Upload complete', icon: <IconCheck /> })
|
|
142
|
+
*/
|
|
143
|
+
export function notifySuccess(
|
|
144
|
+
message: ReactNode,
|
|
145
|
+
opts?: Omit<NotifyOptions, 'intent' | 'message'>,
|
|
146
|
+
): string {
|
|
147
|
+
return notify({ ...opts, intent: 'success', message })
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Show an error toast (auto-close off by default).
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* notifyError('Upload failed', { title: 'Error' })
|
|
155
|
+
*/
|
|
156
|
+
export function notifyError(
|
|
157
|
+
message: ReactNode,
|
|
158
|
+
opts?: Omit<NotifyOptions, 'intent' | 'message'>,
|
|
159
|
+
): string {
|
|
160
|
+
return notify({ ...opts, intent: 'error', message })
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Show a warning toast.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* notifyWarning('Session expires in 5 minutes')
|
|
168
|
+
*/
|
|
169
|
+
export function notifyWarning(
|
|
170
|
+
message: ReactNode,
|
|
171
|
+
opts?: Omit<NotifyOptions, 'intent' | 'message'>,
|
|
172
|
+
): string {
|
|
173
|
+
return notify({ ...opts, intent: 'warning', message })
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Show an info toast.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* notifyInfo('New version available')
|
|
181
|
+
*/
|
|
182
|
+
export function notifyInfo(
|
|
183
|
+
message: ReactNode,
|
|
184
|
+
opts?: Omit<NotifyOptions, 'intent' | 'message'>,
|
|
185
|
+
): string {
|
|
186
|
+
return notify({ ...opts, intent: 'info', message })
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ── notifyPromise ─────────────────────────────────────────────────────────────
|
|
190
|
+
|
|
191
|
+
export type NotifyPromiseMessages = {
|
|
192
|
+
loading: ReactNode
|
|
193
|
+
success: ReactNode
|
|
194
|
+
error: ReactNode
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Show a loading toast while a promise is pending, then update to success or error on settle.
|
|
199
|
+
* Uses notifications.show for loading → notifications.update for the final state (Mantine dedup
|
|
200
|
+
* requires update, not show, to replace an existing id).
|
|
201
|
+
* Records the final state (success/error) to history.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* await notifyPromise(uploadFile(file), {
|
|
205
|
+
* loading: 'Uploading…',
|
|
206
|
+
* success: 'Upload complete',
|
|
207
|
+
* error: 'Upload failed',
|
|
208
|
+
* })
|
|
209
|
+
*/
|
|
210
|
+
export function notifyPromise<T>(promise: Promise<T>, messages: NotifyPromiseMessages): Promise<T> {
|
|
211
|
+
const id = nextId()
|
|
212
|
+
|
|
213
|
+
notifications.show({
|
|
214
|
+
id,
|
|
215
|
+
message: messages.loading,
|
|
216
|
+
loading: true,
|
|
217
|
+
autoClose: false,
|
|
218
|
+
withCloseButton: false,
|
|
219
|
+
role: 'status',
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
return promise.then(
|
|
223
|
+
(result) => {
|
|
224
|
+
notifications.update({
|
|
225
|
+
id,
|
|
226
|
+
message: messages.success,
|
|
227
|
+
color: INTENT_COLOR['success'],
|
|
228
|
+
loading: false,
|
|
229
|
+
autoClose: INTENT_AUTO_CLOSE['success'],
|
|
230
|
+
withCloseButton: true,
|
|
231
|
+
role: 'status',
|
|
232
|
+
})
|
|
233
|
+
add({
|
|
234
|
+
id,
|
|
235
|
+
intent: 'success',
|
|
236
|
+
message: String(messages.success),
|
|
237
|
+
createdAt: Date.now(),
|
|
238
|
+
})
|
|
239
|
+
return result
|
|
240
|
+
},
|
|
241
|
+
(err: unknown) => {
|
|
242
|
+
notifications.update({
|
|
243
|
+
id,
|
|
244
|
+
message: messages.error,
|
|
245
|
+
color: INTENT_COLOR['error'],
|
|
246
|
+
loading: false,
|
|
247
|
+
autoClose: INTENT_AUTO_CLOSE['error'],
|
|
248
|
+
withCloseButton: true,
|
|
249
|
+
role: 'alert',
|
|
250
|
+
})
|
|
251
|
+
add({
|
|
252
|
+
id,
|
|
253
|
+
intent: 'error',
|
|
254
|
+
message: String(messages.error),
|
|
255
|
+
createdAt: Date.now(),
|
|
256
|
+
})
|
|
257
|
+
throw err
|
|
258
|
+
},
|
|
259
|
+
)
|
|
260
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BasaltNotifications — thin wrapper around Mantine `<Notifications />` with basalt defaults.
|
|
3
|
+
*
|
|
4
|
+
* Mount this inside BasaltProvider (typically in main.tsx, after BasaltProvider):
|
|
5
|
+
*
|
|
6
|
+
* ```tsx
|
|
7
|
+
* <BasaltProvider ...>
|
|
8
|
+
* <BasaltNotifications />
|
|
9
|
+
* <App />
|
|
10
|
+
* </BasaltProvider>
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* It is NOT auto-mounted from BasaltProvider to keep @mantine/notifications out of the root barrel.
|
|
14
|
+
* This is an opt-in component — only add it when the app uses the notifications battery.
|
|
15
|
+
*
|
|
16
|
+
* NOTE: The composable `<BasaltOverlays>` (which will bundle notifications + modals + commands
|
|
17
|
+
* into a single mount point) arrives with the ./commands battery. For now, mount
|
|
18
|
+
* `<BasaltNotifications />` directly.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* import { BasaltNotifications } from 'basalt-ui/notifications'
|
|
22
|
+
* import { BasaltProvider } from 'basalt-ui'
|
|
23
|
+
*
|
|
24
|
+
* createRoot(root).render(
|
|
25
|
+
* <BasaltProvider>
|
|
26
|
+
* <BasaltNotifications />
|
|
27
|
+
* <App />
|
|
28
|
+
* </BasaltProvider>
|
|
29
|
+
* )
|
|
30
|
+
*/
|
|
31
|
+
import { Notifications } from '@mantine/notifications'
|
|
32
|
+
|
|
33
|
+
export type BasaltNotificationsProps = {
|
|
34
|
+
/** Toast position. Default: 'bottom-right'. */
|
|
35
|
+
position?:
|
|
36
|
+
| 'top-left'
|
|
37
|
+
| 'top-right'
|
|
38
|
+
| 'top-center'
|
|
39
|
+
| 'bottom-left'
|
|
40
|
+
| 'bottom-right'
|
|
41
|
+
| 'bottom-center'
|
|
42
|
+
/** Auto-close delay (ms). Default: 4000. */
|
|
43
|
+
autoClose?: number | false
|
|
44
|
+
/** Max visible toasts. Default: 5. */
|
|
45
|
+
limit?: number
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Mounts the Mantine Notifications overlay with basalt defaults.
|
|
50
|
+
* Render ONE instance per app — typically inside BasaltProvider, before the router.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* <BasaltProvider>
|
|
54
|
+
* <BasaltNotifications position="bottom-right" limit={5} />
|
|
55
|
+
* <RouterProvider router={router} />
|
|
56
|
+
* </BasaltProvider>
|
|
57
|
+
*/
|
|
58
|
+
export function BasaltNotifications({
|
|
59
|
+
position = 'bottom-right',
|
|
60
|
+
autoClose = 4000,
|
|
61
|
+
limit = 5,
|
|
62
|
+
}: BasaltNotificationsProps) {
|
|
63
|
+
return <Notifications position={position} autoClose={autoClose} limit={limit} />
|
|
64
|
+
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification history store — module-level persisted external store.
|
|
3
|
+
*
|
|
4
|
+
* Ring-buffer cap of 50 items. Keys are namespaced `basalt:notifications` mirroring
|
|
5
|
+
* createPersistedState's `basalt:*` pattern. Reads/writes use the same versioned `{ v, value }`
|
|
6
|
+
* envelope. Cross-tab sync via the `storage` event.
|
|
7
|
+
*
|
|
8
|
+
* Module-level add/markRead/markAllRead/clear are callable from notify() (not hook-scoped), and
|
|
9
|
+
* useNotificationHistory() exposes the reactive slice to components.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Module-level (non-React):
|
|
13
|
+
* import { add, markRead, markAllRead, clear } from 'basalt-ui/notifications'
|
|
14
|
+
* add({ id: 'x', intent: 'success', message: 'Done', createdAt: Date.now() })
|
|
15
|
+
*
|
|
16
|
+
* // React:
|
|
17
|
+
* import { useNotificationHistory } from 'basalt-ui/notifications'
|
|
18
|
+
* const { items, unreadCount, markRead, markAllRead, clear } = useNotificationHistory()
|
|
19
|
+
*/
|
|
20
|
+
import { useSyncExternalStore } from 'react'
|
|
21
|
+
|
|
22
|
+
// ── Types ─────────────────────────────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
export type NotificationIntent = 'success' | 'error' | 'warning' | 'info'
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A serializable reference to a registered action. Resolved at render time against the
|
|
28
|
+
* notifications registry (see resolveAction in ./define-notifications). The handler itself is NOT
|
|
29
|
+
* stored — only the kind + payload — so an actionable notification survives a reload.
|
|
30
|
+
*/
|
|
31
|
+
export type NotificationActionRef = {
|
|
32
|
+
kind: string
|
|
33
|
+
/** Must be JSON-serializable — it is persisted to localStorage alongside the item. */
|
|
34
|
+
payload?: unknown
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** A persisted history item — message/title stored as strings (ReactNode is not serializable). */
|
|
38
|
+
export type NotificationHistoryItem = {
|
|
39
|
+
id: string
|
|
40
|
+
intent: NotificationIntent
|
|
41
|
+
title?: string
|
|
42
|
+
message: string
|
|
43
|
+
createdAt: number
|
|
44
|
+
/** Set when the user has seen the item (markRead). undefined = unread. */
|
|
45
|
+
readAt?: number
|
|
46
|
+
/** Set when the user has dealt with the item (dismiss) — removes it from the Inbox view. */
|
|
47
|
+
dismissedAt?: number
|
|
48
|
+
/** A registry-resolved action — gives the item an actionable button in the center. */
|
|
49
|
+
action?: NotificationActionRef
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type NotificationHistoryState = NotificationHistoryItem[]
|
|
53
|
+
|
|
54
|
+
export type UseNotificationHistoryReturn = {
|
|
55
|
+
/** All history items, newest first (the "All" view). */
|
|
56
|
+
items: NotificationHistoryItem[]
|
|
57
|
+
/** Items that need attention and are not yet dismissed (the "Inbox" view). */
|
|
58
|
+
inbox: NotificationHistoryItem[]
|
|
59
|
+
/** Unread Inbox items — the bell badge count ("N things need your attention"). */
|
|
60
|
+
unreadCount: number
|
|
61
|
+
markRead: (id: string) => void
|
|
62
|
+
markAllRead: () => void
|
|
63
|
+
dismiss: (id: string) => void
|
|
64
|
+
dismissAll: () => void
|
|
65
|
+
remove: (id: string) => void
|
|
66
|
+
clear: () => void
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Whether an item belongs in the Inbox: it has an action, or it is an error/warning. Plain
|
|
71
|
+
* success/info confirmations are disposable — they live only in the full history, never the Inbox.
|
|
72
|
+
*/
|
|
73
|
+
export function needsAttention(item: NotificationHistoryItem): boolean {
|
|
74
|
+
return item.action !== undefined || item.intent === 'error' || item.intent === 'warning'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ── Constants ─────────────────────────────────────────────────────────────────
|
|
78
|
+
|
|
79
|
+
const STORAGE_KEY = 'basalt:notifications'
|
|
80
|
+
// v2: added dismissedAt + action (inbox/all split). v1 payloads are dropped on read (no consumers).
|
|
81
|
+
const VERSION = 2
|
|
82
|
+
const RING_CAP = 50
|
|
83
|
+
|
|
84
|
+
// ── Persistence helpers ───────────────────────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
type Envelope = { v: number; value: unknown }
|
|
87
|
+
|
|
88
|
+
function isEnvelope(raw: unknown): raw is Envelope {
|
|
89
|
+
return (
|
|
90
|
+
typeof raw === 'object' &&
|
|
91
|
+
raw !== null &&
|
|
92
|
+
'v' in raw &&
|
|
93
|
+
typeof (raw as Record<string, unknown>)['v'] === 'number' &&
|
|
94
|
+
'value' in raw
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function readStorage(): NotificationHistoryState {
|
|
99
|
+
if (typeof window === 'undefined') return []
|
|
100
|
+
try {
|
|
101
|
+
const raw = window.localStorage.getItem(STORAGE_KEY)
|
|
102
|
+
if (raw === null) return []
|
|
103
|
+
const parsed: unknown = JSON.parse(raw)
|
|
104
|
+
if (!isEnvelope(parsed) || parsed.v !== VERSION) return []
|
|
105
|
+
return Array.isArray(parsed.value) ? (parsed.value as NotificationHistoryState) : []
|
|
106
|
+
} catch {
|
|
107
|
+
return []
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function writeStorage(next: NotificationHistoryState): void {
|
|
112
|
+
if (typeof window === 'undefined') return
|
|
113
|
+
try {
|
|
114
|
+
const envelope: Envelope = { v: VERSION, value: next }
|
|
115
|
+
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(envelope))
|
|
116
|
+
} catch {
|
|
117
|
+
// Silently fail (storage full, private browsing, etc.)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ── Module-level state + listeners ───────────────────────────────────────────
|
|
122
|
+
|
|
123
|
+
let state: NotificationHistoryState = readStorage()
|
|
124
|
+
const listeners = new Set<() => void>()
|
|
125
|
+
|
|
126
|
+
function notifyListeners(): void {
|
|
127
|
+
for (const cb of listeners) cb()
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function setState(next: NotificationHistoryState): void {
|
|
131
|
+
state = next
|
|
132
|
+
writeStorage(next)
|
|
133
|
+
notifyListeners()
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ── Cross-tab sync ────────────────────────────────────────────────────────────
|
|
137
|
+
|
|
138
|
+
if (typeof window !== 'undefined') {
|
|
139
|
+
window.addEventListener('storage', (e: StorageEvent) => {
|
|
140
|
+
if (e.key === STORAGE_KEY) {
|
|
141
|
+
state = readStorage()
|
|
142
|
+
notifyListeners()
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ── Module-level public API ───────────────────────────────────────────────────
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Add a notification to the history store (ring-buffer capped at 50).
|
|
151
|
+
* Called by notify() — safe to call outside React.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* add({ id: 'x', intent: 'success', message: 'Saved', createdAt: Date.now() })
|
|
155
|
+
*/
|
|
156
|
+
export function add(item: NotificationHistoryItem): void {
|
|
157
|
+
const next = [item, ...state].slice(0, RING_CAP)
|
|
158
|
+
setState(next)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Mark a single notification as read by id.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* markRead('notification-id')
|
|
166
|
+
*/
|
|
167
|
+
export function markRead(id: string): void {
|
|
168
|
+
setState(state.map((item) => (item.id === id ? { ...item, readAt: Date.now() } : item)))
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Mark all notifications as read.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* markAllRead()
|
|
176
|
+
*/
|
|
177
|
+
export function markAllRead(): void {
|
|
178
|
+
const now = Date.now()
|
|
179
|
+
setState(state.map((item) => (item.readAt === undefined ? { ...item, readAt: now } : item)))
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Dismiss a single item — marks it dealt-with so it leaves the Inbox view. The item stays in the
|
|
184
|
+
* full history ("All" view). Use remove() to delete it outright.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* dismiss('notification-id')
|
|
188
|
+
*/
|
|
189
|
+
export function dismiss(id: string): void {
|
|
190
|
+
setState(state.map((item) => (item.id === id ? { ...item, dismissedAt: Date.now() } : item)))
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Dismiss every Inbox item at once — archives the whole attention set (they stay in the full
|
|
195
|
+
* history). The bulk counterpart to dismiss(); does not touch already-dismissed or non-attention
|
|
196
|
+
* items.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* dismissAll()
|
|
200
|
+
*/
|
|
201
|
+
export function dismissAll(): void {
|
|
202
|
+
const now = Date.now()
|
|
203
|
+
setState(
|
|
204
|
+
state.map((item) =>
|
|
205
|
+
item.dismissedAt === undefined && needsAttention(item) ? { ...item, dismissedAt: now } : item,
|
|
206
|
+
),
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Remove a single item from history entirely (per-item clear).
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* remove('notification-id')
|
|
215
|
+
*/
|
|
216
|
+
export function remove(id: string): void {
|
|
217
|
+
setState(state.filter((item) => item.id !== id))
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Clear all notification history.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* clear()
|
|
225
|
+
*/
|
|
226
|
+
export function clear(): void {
|
|
227
|
+
setState([])
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// ── useSyncExternalStore plumbing ─────────────────────────────────────────────
|
|
231
|
+
|
|
232
|
+
const noopSubscribe =
|
|
233
|
+
(_cb: () => void): (() => void) =>
|
|
234
|
+
() => {}
|
|
235
|
+
|
|
236
|
+
function subscribe(cb: () => void): () => void {
|
|
237
|
+
listeners.add(cb)
|
|
238
|
+
return () => {
|
|
239
|
+
listeners.delete(cb)
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function getSnapshot(): NotificationHistoryState {
|
|
244
|
+
return state
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const serverState: NotificationHistoryState = []
|
|
248
|
+
function getServerSnapshot(): NotificationHistoryState {
|
|
249
|
+
return serverState
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// ── Hook ──────────────────────────────────────────────────────────────────────
|
|
253
|
+
|
|
254
|
+
const isServer = typeof window === 'undefined'
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Reactive notification history — consumes the module-level persisted store.
|
|
258
|
+
* Exposes both the full history (`items`) and the attention Inbox (`inbox`); `unreadCount` is the
|
|
259
|
+
* unread Inbox count (the bell badge). Items are marked read on interaction, not on open.
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* function NotificationCenter() {
|
|
263
|
+
* const { inbox, unreadCount, markRead, dismiss } = useNotificationHistory()
|
|
264
|
+
* return (
|
|
265
|
+
* <div>
|
|
266
|
+
* {inbox.map(item => (
|
|
267
|
+
* <div key={item.id} onClick={() => markRead(item.id)}>
|
|
268
|
+
* {item.message}
|
|
269
|
+
* <button onClick={() => dismiss(item.id)}>Dismiss</button>
|
|
270
|
+
* </div>
|
|
271
|
+
* ))}
|
|
272
|
+
* </div>
|
|
273
|
+
* )
|
|
274
|
+
* }
|
|
275
|
+
*/
|
|
276
|
+
export function useNotificationHistory(): UseNotificationHistoryReturn {
|
|
277
|
+
const items = useSyncExternalStore<NotificationHistoryState>(
|
|
278
|
+
isServer ? noopSubscribe : subscribe,
|
|
279
|
+
isServer ? getServerSnapshot : getSnapshot,
|
|
280
|
+
getServerSnapshot,
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
const inbox = items.filter((item) => item.dismissedAt === undefined && needsAttention(item))
|
|
284
|
+
const unreadCount = inbox.filter((item) => item.readAt === undefined).length
|
|
285
|
+
|
|
286
|
+
return { items, inbox, unreadCount, markRead, markAllRead, dismiss, dismissAll, remove, clear }
|
|
287
|
+
}
|