@miragon/mcp-toolkit-ui 2.7.0 → 2.8.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/README.md +7 -4
- package/dist/app/adapt-data-widget.d.ts +1 -22
- package/dist/app/adapt-data-widget.d.ts.map +1 -1
- package/dist/app/adapt-data-widget.js +1 -35
- package/dist/app/adapt-data-widget.js.map +1 -1
- package/dist/app/builder/BuilderBanners.js +1 -1
- package/dist/app/builder/BuilderBanners.js.map +1 -1
- package/dist/app/builder/CanvasRow.d.ts +4 -2
- package/dist/app/builder/CanvasRow.d.ts.map +1 -1
- package/dist/app/builder/CanvasRow.js +21 -7
- package/dist/app/builder/CanvasRow.js.map +1 -1
- package/dist/app/builder/CatalogueSheet.d.ts.map +1 -1
- package/dist/app/builder/CatalogueSheet.js +11 -4
- package/dist/app/builder/CatalogueSheet.js.map +1 -1
- package/dist/app/builder/CellPropsSheet.d.ts +7 -3
- package/dist/app/builder/CellPropsSheet.d.ts.map +1 -1
- package/dist/app/builder/CellPropsSheet.js +10 -3
- package/dist/app/builder/CellPropsSheet.js.map +1 -1
- package/dist/app/builder/DiscardDialog.d.ts +18 -0
- package/dist/app/builder/DiscardDialog.d.ts.map +1 -0
- package/dist/app/builder/DiscardDialog.js +18 -0
- package/dist/app/builder/DiscardDialog.js.map +1 -0
- package/dist/app/builder/LayoutSurface.d.ts +33 -9
- package/dist/app/builder/LayoutSurface.d.ts.map +1 -1
- package/dist/app/builder/LayoutSurface.js +74 -23
- package/dist/app/builder/LayoutSurface.js.map +1 -1
- package/dist/app/builder/PipelineStrip.d.ts +2 -1
- package/dist/app/builder/PipelineStrip.d.ts.map +1 -1
- package/dist/app/builder/PipelineStrip.js +26 -13
- package/dist/app/builder/PipelineStrip.js.map +1 -1
- package/dist/app/builder/SaveDialog.d.ts +9 -1
- package/dist/app/builder/SaveDialog.d.ts.map +1 -1
- package/dist/app/builder/SaveDialog.js +8 -2
- package/dist/app/builder/SaveDialog.js.map +1 -1
- package/dist/app/builder/Toolbar.d.ts +12 -4
- package/dist/app/builder/Toolbar.d.ts.map +1 -1
- package/dist/app/builder/Toolbar.js +18 -7
- package/dist/app/builder/Toolbar.js.map +1 -1
- package/dist/app/builder/Workspace.d.ts +23 -3
- package/dist/app/builder/Workspace.d.ts.map +1 -1
- package/dist/app/builder/Workspace.js +58 -8
- package/dist/app/builder/Workspace.js.map +1 -1
- package/dist/app/builder/builder-model.d.ts +143 -1
- package/dist/app/builder/builder-model.d.ts.map +1 -1
- package/dist/app/builder/builder-model.js +191 -1
- package/dist/app/builder/builder-model.js.map +1 -1
- package/dist/app/builder/reveal.d.ts +10 -0
- package/dist/app/builder/reveal.d.ts.map +1 -0
- package/dist/app/builder/reveal.js +10 -0
- package/dist/app/builder/reveal.js.map +1 -0
- package/dist/app/builder/use-builder-catalogue.d.ts +4 -1
- package/dist/app/builder/use-builder-catalogue.d.ts.map +1 -1
- package/dist/app/builder/use-builder-catalogue.js +44 -17
- package/dist/app/builder/use-builder-catalogue.js.map +1 -1
- package/dist/app/builder/use-builder-session.d.ts +30 -0
- package/dist/app/builder/use-builder-session.d.ts.map +1 -0
- package/dist/app/builder/use-builder-session.js +58 -0
- package/dist/app/builder/use-builder-session.js.map +1 -0
- package/dist/app/builder/use-display-resolver.d.ts +17 -0
- package/dist/app/builder/use-display-resolver.d.ts.map +1 -0
- package/dist/app/builder/use-display-resolver.js +16 -0
- package/dist/app/builder/use-display-resolver.js.map +1 -0
- package/dist/app/index.d.ts +8 -3
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js +8 -2
- package/dist/app/index.js.map +1 -1
- package/dist/app/layout-builder.d.ts +13 -25
- package/dist/app/layout-builder.d.ts.map +1 -1
- package/dist/app/layout-builder.js +75 -81
- package/dist/app/layout-builder.js.map +1 -1
- package/dist/app/mcp-app-view-chrome.d.ts +12 -3
- package/dist/app/mcp-app-view-chrome.d.ts.map +1 -1
- package/dist/app/mcp-app-view-chrome.js +21 -5
- package/dist/app/mcp-app-view-chrome.js.map +1 -1
- package/dist/app/mcp-app-view-states.d.ts +11 -3
- package/dist/app/mcp-app-view-states.d.ts.map +1 -1
- package/dist/app/mcp-app-view-states.js +29 -8
- package/dist/app/mcp-app-view-states.js.map +1 -1
- package/dist/app/mcp-app-view.d.ts +33 -1
- package/dist/app/mcp-app-view.d.ts.map +1 -1
- package/dist/app/mcp-app-view.js +181 -127
- package/dist/app/mcp-app-view.js.map +1 -1
- package/dist/app/mcp-toolkit-app.d.ts +6 -1
- package/dist/app/mcp-toolkit-app.d.ts.map +1 -1
- package/dist/app/mcp-toolkit-app.js +8 -1
- package/dist/app/mcp-toolkit-app.js.map +1 -1
- package/dist/app/mcp-use-host-bridge.d.ts +15 -6
- package/dist/app/mcp-use-host-bridge.d.ts.map +1 -1
- package/dist/app/mcp-use-host-bridge.js +51 -22
- package/dist/app/mcp-use-host-bridge.js.map +1 -1
- package/dist/app/model-context.d.ts +71 -0
- package/dist/app/model-context.d.ts.map +1 -0
- package/dist/app/model-context.js +101 -0
- package/dist/app/model-context.js.map +1 -0
- package/dist/app/use-build-mode-focus.d.ts +33 -0
- package/dist/app/use-build-mode-focus.d.ts.map +1 -0
- package/dist/app/use-build-mode-focus.js +59 -0
- package/dist/app/use-build-mode-focus.js.map +1 -0
- package/dist/app/use-view-actions.d.ts +31 -0
- package/dist/app/use-view-actions.d.ts.map +1 -0
- package/dist/app/use-view-actions.js +81 -0
- package/dist/app/use-view-actions.js.map +1 -0
- package/dist/app/use-view-lifecycle.d.ts +4 -0
- package/dist/app/use-view-lifecycle.d.ts.map +1 -1
- package/dist/app/use-view-lifecycle.js +2 -0
- package/dist/app/use-view-lifecycle.js.map +1 -1
- package/dist/app/view-lifecycle.d.ts +80 -4
- package/dist/app/view-lifecycle.d.ts.map +1 -1
- package/dist/app/view-lifecycle.js +90 -3
- package/dist/app/view-lifecycle.js.map +1 -1
- package/dist/app/widget-fixture.d.ts +10 -3
- package/dist/app/widget-fixture.d.ts.map +1 -1
- package/dist/app/widget-fixture.js +21 -8
- package/dist/app/widget-fixture.js.map +1 -1
- package/dist/app/widget-props-sheet.d.ts +3 -1
- package/dist/app/widget-props-sheet.d.ts.map +1 -1
- package/dist/app/widget-props-sheet.js +22 -10
- package/dist/app/widget-props-sheet.js.map +1 -1
- package/dist/app/widget-renderer.js +1 -1
- package/dist/app/widget-renderer.js.map +1 -1
- package/dist/components/DrillButton.d.ts +9 -6
- package/dist/components/DrillButton.d.ts.map +1 -1
- package/dist/components/DrillButton.js +8 -6
- package/dist/components/DrillButton.js.map +1 -1
- package/dist/components/EmptyState.d.ts.map +1 -1
- package/dist/components/EmptyState.js +4 -2
- package/dist/components/EmptyState.js.map +1 -1
- package/dist/components/ErrorState.d.ts +5 -2
- package/dist/components/ErrorState.d.ts.map +1 -1
- package/dist/components/ErrorState.js +25 -8
- package/dist/components/ErrorState.js.map +1 -1
- package/dist/components/FilterBar.d.ts +15 -4
- package/dist/components/FilterBar.d.ts.map +1 -1
- package/dist/components/FilterBar.js +11 -6
- package/dist/components/FilterBar.js.map +1 -1
- package/dist/components/KpiGrid.d.ts +66 -21
- package/dist/components/KpiGrid.d.ts.map +1 -1
- package/dist/components/KpiGrid.js +101 -34
- package/dist/components/KpiGrid.js.map +1 -1
- package/dist/components/ListFooter.d.ts +31 -4
- package/dist/components/ListFooter.d.ts.map +1 -1
- package/dist/components/ListFooter.js +30 -11
- package/dist/components/ListFooter.js.map +1 -1
- package/dist/components/PagedListFooter.d.ts +57 -0
- package/dist/components/PagedListFooter.d.ts.map +1 -0
- package/dist/components/PagedListFooter.js +27 -0
- package/dist/components/PagedListFooter.js.map +1 -0
- package/dist/components/Pills.d.ts +27 -7
- package/dist/components/Pills.d.ts.map +1 -1
- package/dist/components/Pills.js +21 -6
- package/dist/components/Pills.js.map +1 -1
- package/dist/components/SectionHeading.d.ts +3 -1
- package/dist/components/SectionHeading.d.ts.map +1 -1
- package/dist/components/SectionHeading.js +6 -2
- package/dist/components/SectionHeading.js.map +1 -1
- package/dist/components/Toast.d.ts +9 -3
- package/dist/components/Toast.d.ts.map +1 -1
- package/dist/components/Toast.js +31 -16
- package/dist/components/Toast.js.map +1 -1
- package/dist/components/WidgetHeader.d.ts +34 -10
- package/dist/components/WidgetHeader.d.ts.map +1 -1
- package/dist/components/WidgetHeader.js +11 -6
- package/dist/components/WidgetHeader.js.map +1 -1
- package/dist/hooks/index.d.ts +4 -4
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/tool-result-recovery-model.d.ts +155 -0
- package/dist/hooks/tool-result-recovery-model.d.ts.map +1 -0
- package/dist/hooks/tool-result-recovery-model.js +273 -0
- package/dist/hooks/tool-result-recovery-model.js.map +1 -0
- package/dist/hooks/use-tool-query.d.ts +56 -14
- package/dist/hooks/use-tool-query.d.ts.map +1 -1
- package/dist/hooks/use-tool-query.js +102 -25
- package/dist/hooks/use-tool-query.js.map +1 -1
- package/dist/hooks/use-tool-result-recovery.d.ts +47 -52
- package/dist/hooks/use-tool-result-recovery.d.ts.map +1 -1
- package/dist/hooks/use-tool-result-recovery.js +58 -120
- package/dist/hooks/use-tool-result-recovery.js.map +1 -1
- package/dist/hooks/use-view-data.d.ts +52 -10
- package/dist/hooks/use-view-data.d.ts.map +1 -1
- package/dist/hooks/use-view-data.js +81 -16
- package/dist/hooks/use-view-data.js.map +1 -1
- package/dist/hooks/use-view-tool-query.d.ts +12 -7
- package/dist/hooks/use-view-tool-query.d.ts.map +1 -1
- package/dist/hooks/use-view-tool-query.js +15 -14
- package/dist/hooks/use-view-tool-query.js.map +1 -1
- package/dist/index.d.ts +17 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/focus-return.d.ts +61 -0
- package/dist/lib/focus-return.d.ts.map +1 -0
- package/dist/lib/focus-return.js +46 -0
- package/dist/lib/focus-return.js.map +1 -0
- package/dist/lib/parse-tool-result.d.ts +23 -1
- package/dist/lib/parse-tool-result.d.ts.map +1 -1
- package/dist/lib/parse-tool-result.js +38 -2
- package/dist/lib/parse-tool-result.js.map +1 -1
- package/dist/lib/toast-model.d.ts +41 -1
- package/dist/lib/toast-model.d.ts.map +1 -1
- package/dist/lib/toast-model.js +67 -1
- package/dist/lib/toast-model.js.map +1 -1
- package/dist/lib/tone-utils.d.ts +58 -6
- package/dist/lib/tone-utils.d.ts.map +1 -1
- package/dist/lib/tone-utils.js +66 -4
- package/dist/lib/tone-utils.js.map +1 -1
- package/dist/lib/tool-query.d.ts +107 -0
- package/dist/lib/tool-query.d.ts.map +1 -0
- package/dist/lib/tool-query.js +182 -0
- package/dist/lib/tool-query.js.map +1 -0
- package/dist/lib/tool-result-observer.d.ts +108 -0
- package/dist/lib/tool-result-observer.d.ts.map +1 -0
- package/dist/lib/tool-result-observer.js +158 -0
- package/dist/lib/tool-result-observer.js.map +1 -0
- package/dist/lib/typography.d.ts +37 -0
- package/dist/lib/typography.d.ts.map +1 -0
- package/dist/lib/typography.js +41 -0
- package/dist/lib/typography.js.map +1 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +11 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.d.ts.map +1 -1
- package/dist/locale/message-types.d.ts +117 -4
- package/dist/locale/message-types.d.ts.map +1 -1
- package/dist/locale/messages-de.d.ts.map +1 -1
- package/dist/locale/messages-de.js +44 -10
- package/dist/locale/messages-de.js.map +1 -1
- package/dist/locale/messages-en.d.ts.map +1 -1
- package/dist/locale/messages-en.js +44 -10
- package/dist/locale/messages-en.js.map +1 -1
- package/dist/locale/toolkit-messages.d.ts +19 -1
- package/dist/locale/toolkit-messages.d.ts.map +1 -1
- package/dist/locale/toolkit-messages.js +54 -1
- package/dist/locale/toolkit-messages.js.map +1 -1
- package/dist/primitives/alert.d.ts +1 -1
- package/dist/primitives/alert.d.ts.map +1 -1
- package/dist/primitives/alert.js +2 -0
- package/dist/primitives/alert.js.map +1 -1
- package/dist/primitives/badge.d.ts +1 -1
- package/dist/primitives/badge.d.ts.map +1 -1
- package/dist/primitives/badge.js +9 -4
- package/dist/primitives/badge.js.map +1 -1
- package/dist/primitives/button.d.ts +1 -1
- package/dist/primitives/button.js +1 -1
- package/dist/primitives/button.js.map +1 -1
- package/dist/primitives/dialog.d.ts +1 -1
- package/dist/primitives/dialog.d.ts.map +1 -1
- package/dist/primitives/dialog.js +10 -3
- package/dist/primitives/dialog.js.map +1 -1
- package/dist/primitives/select.js +1 -1
- package/dist/primitives/select.js.map +1 -1
- package/dist/primitives/sheet.d.ts +1 -1
- package/dist/primitives/sheet.d.ts.map +1 -1
- package/dist/primitives/sheet.js +6 -2
- package/dist/primitives/sheet.js.map +1 -1
- package/dist/providers/query-provider.d.ts +32 -1
- package/dist/providers/query-provider.d.ts.map +1 -1
- package/dist/providers/query-provider.js +53 -4
- package/dist/providers/query-provider.js.map +1 -1
- package/dist/render-cases-primitives.js +1 -1
- package/dist/render-cases-primitives.js.map +1 -1
- package/dist/render-cases.d.ts.map +1 -1
- package/dist/render-cases.js +30 -6
- package/dist/render-cases.js.map +1 -1
- package/dist/render-effects.d.ts +42 -0
- package/dist/render-effects.d.ts.map +1 -0
- package/dist/render-effects.js +81 -0
- package/dist/render-effects.js.map +1 -0
- package/dist/theme/create-theme.d.ts +19 -1
- package/dist/theme/create-theme.d.ts.map +1 -1
- package/dist/theme/create-theme.js +15 -0
- package/dist/theme/create-theme.js.map +1 -1
- package/package.json +5 -4
- package/src/app/adapt-data-widget.tsx +2 -42
- package/src/app/builder/BuilderBanners.tsx +1 -1
- package/src/app/builder/CanvasRow.tsx +63 -17
- package/src/app/builder/CatalogueSheet.tsx +50 -29
- package/src/app/builder/CellPropsSheet.tsx +17 -2
- package/src/app/builder/DiscardDialog.tsx +59 -0
- package/src/app/builder/LayoutSurface.tsx +206 -66
- package/src/app/builder/PipelineStrip.tsx +253 -153
- package/src/app/builder/SaveDialog.tsx +14 -2
- package/src/app/builder/Toolbar.tsx +144 -59
- package/src/app/builder/Workspace.tsx +226 -58
- package/src/app/builder/builder-model.ts +341 -2
- package/src/app/builder/builder-model.ux.test.ts +456 -0
- package/src/app/builder/builder-ux.test.tsx +844 -0
- package/src/app/builder/reveal.ts +10 -0
- package/src/app/builder/use-builder-catalogue.ts +56 -19
- package/src/app/builder/use-builder-session.ts +68 -0
- package/src/app/builder/use-display-resolver.ts +24 -0
- package/src/app/index.ts +12 -2
- package/src/app/layout-builder.tsx +178 -191
- package/src/app/mcp-app-view-chrome.test.tsx +141 -1
- package/src/app/mcp-app-view-chrome.tsx +56 -6
- package/src/app/mcp-app-view-states.tsx +51 -11
- package/src/app/mcp-app-view.effects.test.tsx +292 -0
- package/src/app/mcp-app-view.test.tsx +222 -2
- package/src/app/mcp-app-view.tsx +267 -117
- package/src/app/mcp-toolkit-app.test.tsx +40 -0
- package/src/app/mcp-toolkit-app.tsx +8 -1
- package/src/app/mcp-use-host-bridge.test.tsx +180 -0
- package/src/app/mcp-use-host-bridge.tsx +67 -24
- package/src/app/model-context.test.tsx +116 -0
- package/src/app/model-context.tsx +125 -0
- package/src/app/use-build-mode-focus.ts +62 -0
- package/src/app/use-view-actions.ts +89 -0
- package/src/app/use-view-lifecycle.ts +6 -0
- package/src/app/view-lifecycle.test.ts +216 -0
- package/src/app/view-lifecycle.ts +165 -5
- package/src/app/widget-fixture.effects.test.tsx +51 -0
- package/src/app/widget-fixture.render.test.tsx +81 -0
- package/src/app/widget-fixture.tsx +34 -11
- package/src/app/widget-props-sheet.tsx +57 -16
- package/src/app/widget-renderer.tsx +1 -1
- package/src/components/DrillButton.tsx +23 -10
- package/src/components/EmptyState.tsx +6 -4
- package/src/components/ErrorState.tsx +31 -9
- package/src/components/FilterBar.test.tsx +82 -0
- package/src/components/FilterBar.tsx +52 -26
- package/src/components/KpiGrid.test.tsx +279 -0
- package/src/components/KpiGrid.tsx +297 -90
- package/src/components/ListFooter.test.tsx +116 -0
- package/src/components/ListFooter.tsx +102 -15
- package/src/components/PagedListFooter.test.tsx +140 -0
- package/src/components/PagedListFooter.tsx +107 -0
- package/src/components/Pills.test.tsx +77 -0
- package/src/components/Pills.tsx +63 -10
- package/src/components/SectionHeading.tsx +9 -3
- package/src/components/Toast.tsx +37 -19
- package/src/components/WidgetHeader.test.tsx +78 -0
- package/src/components/WidgetHeader.tsx +63 -16
- package/src/components/feedback-states.test.tsx +98 -9
- package/src/components/tone-figures.test.tsx +8 -4
- package/src/hooks/index.ts +6 -3
- package/src/hooks/tool-result-recovery-model.test.ts +744 -0
- package/src/hooks/tool-result-recovery-model.ts +418 -0
- package/src/hooks/use-tool-query.effects.test.tsx +205 -0
- package/src/hooks/use-tool-query.ts +156 -33
- package/src/hooks/use-tool-result-recovery.effects.test.tsx +141 -0
- package/src/hooks/use-tool-result-recovery.test.ts +3 -4
- package/src/hooks/use-tool-result-recovery.ts +84 -142
- package/src/hooks/use-view-data.test.tsx +118 -9
- package/src/hooks/use-view-data.ts +128 -18
- package/src/hooks/use-view-tool-query.ts +25 -19
- package/src/i18n-coverage.test.tsx +104 -2
- package/src/index.ts +48 -11
- package/src/lib/focus-return.test.ts +288 -0
- package/src/lib/focus-return.ts +96 -0
- package/src/lib/parse-tool-result.test.ts +46 -1
- package/src/lib/parse-tool-result.ts +40 -2
- package/src/lib/toast-model.test.ts +166 -1
- package/src/lib/toast-model.ts +104 -2
- package/src/lib/tone-utils.test.ts +86 -10
- package/src/lib/tone-utils.ts +89 -8
- package/src/lib/tool-query.test.ts +569 -0
- package/src/lib/tool-query.ts +253 -0
- package/src/lib/tool-result-observer.test.ts +296 -0
- package/src/lib/tool-result-observer.ts +211 -0
- package/src/lib/typography.test.ts +45 -0
- package/src/lib/typography.ts +47 -0
- package/src/lib/utils.ts +12 -1
- package/src/locale/index.ts +1 -0
- package/src/locale/message-types.ts +118 -2
- package/src/locale/messages-de.ts +49 -10
- package/src/locale/messages-en.ts +49 -10
- package/src/locale/toolkit-messages.test.ts +133 -0
- package/src/locale/toolkit-messages.ts +63 -2
- package/src/primitives/alert.tsx +3 -0
- package/src/primitives/badge.tsx +9 -4
- package/src/primitives/button.tsx +1 -1
- package/src/primitives/dialog.tsx +10 -1
- package/src/primitives/select.tsx +1 -1
- package/src/primitives/sheet.tsx +7 -0
- package/src/providers/query-provider.test.tsx +154 -0
- package/src/providers/query-provider.tsx +66 -5
- package/src/render-cases-primitives.tsx +1 -1
- package/src/render-cases.tsx +38 -6
- package/src/render-effects.tsx +96 -0
- package/src/theme/cd-tokens.test.ts +3 -1
- package/src/theme/create-theme.test.ts +10 -0
- package/src/theme/create-theme.ts +28 -0
- package/src/theme/theme-css.test.ts +51 -0
- package/src/theme.css +31 -1
- package/ui-catalog.json +448 -41
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
2
|
+
import { type UseToolQueryOptions } from "../lib/tool-query.js";
|
|
3
|
+
/**
|
|
4
|
+
* Options of {@link useViewToolQuery}: TanStack's query options, passed
|
|
5
|
+
* through like `useToolQuery`'s (`enabled`, `retry`, `staleTime`,
|
|
6
|
+
* `placeholderData`, `initialData`, …).
|
|
7
|
+
*/
|
|
8
|
+
export type UseViewToolQueryOptions<T = unknown> = UseToolQueryOptions<T>;
|
|
5
9
|
/**
|
|
6
10
|
* Self-fetch hook for `*_show_*` widget tools — the envelope-unwrapping sibling
|
|
7
11
|
* of {@link useToolQuery}. A widget tool's text channel carries only a model
|
|
@@ -10,9 +14,10 @@ export interface UseViewToolQueryOptions {
|
|
|
10
14
|
* envelope; this hook decodes via {@link parseViewToolResult} (single-step →
|
|
11
15
|
* flat data, multi-step → keyed by step id) instead.
|
|
12
16
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
17
|
+
* Same key and options contract as {@link useToolQuery}: the effective key is
|
|
18
|
+
* `[...queryKey, args]` (`[...queryKey, toolName, args]` under an
|
|
19
|
+
* `AppQueryProvider` with `toolNameInQueryKey`), so sibling widgets sharing a
|
|
20
|
+
* query key and args collapse to a single deduped tool call.
|
|
16
21
|
*/
|
|
17
|
-
export declare function useViewToolQuery<T = unknown>(queryKey: unknown[], toolName: string, args: object, opts?: UseViewToolQueryOptions): UseQueryResult<T, Error>;
|
|
22
|
+
export declare function useViewToolQuery<T = unknown>(queryKey: readonly unknown[], toolName: string, args: object, opts?: UseViewToolQueryOptions<T>): UseQueryResult<T, Error>;
|
|
18
23
|
//# sourceMappingURL=use-view-tool-query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-view-tool-query.d.ts","sourceRoot":"","sources":["../../src/hooks/use-view-tool-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"use-view-tool-query.d.ts","sourceRoot":"","sources":["../../src/hooks/use-view-tool-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAGrE,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAGjF;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,GAAG,OAAO,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAA;AAEzE;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAC1C,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAChC,cAAc,CAAC,CAAC,EAAE,KAAK,CAAC,CAY1B"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useQuery } from "@tanstack/react-query";
|
|
2
|
-
import { useCallTool } from "../providers/query-provider.js";
|
|
2
|
+
import { useCallTool, useToolNameInQueryKey } from "../providers/query-provider.js";
|
|
3
3
|
import { parseViewToolResult } from "../lib/parse-tool-result.js";
|
|
4
|
+
import { toolQueryOptions } from "../lib/tool-query.js";
|
|
5
|
+
import { useRefetchOnTransport, useToolKeyGuard } from "./use-tool-query.js";
|
|
4
6
|
/**
|
|
5
7
|
* Self-fetch hook for `*_show_*` widget tools — the envelope-unwrapping sibling
|
|
6
8
|
* of {@link useToolQuery}. A widget tool's text channel carries only a model
|
|
@@ -9,21 +11,20 @@ import { parseViewToolResult } from "../lib/parse-tool-result.js";
|
|
|
9
11
|
* envelope; this hook decodes via {@link parseViewToolResult} (single-step →
|
|
10
12
|
* flat data, multi-step → keyed by step id) instead.
|
|
11
13
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
14
|
+
* Same key and options contract as {@link useToolQuery}: the effective key is
|
|
15
|
+
* `[...queryKey, args]` (`[...queryKey, toolName, args]` under an
|
|
16
|
+
* `AppQueryProvider` with `toolNameInQueryKey`), so sibling widgets sharing a
|
|
17
|
+
* query key and args collapse to a single deduped tool call.
|
|
15
18
|
*/
|
|
16
19
|
export function useViewToolQuery(queryKey, toolName, args, opts) {
|
|
17
20
|
const callTool = useCallTool();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
enabled: !!callTool && (opts?.enabled ?? true),
|
|
27
|
-
});
|
|
21
|
+
const toolNameInKey = useToolNameInQueryKey();
|
|
22
|
+
useToolKeyGuard(queryKey, toolName, args);
|
|
23
|
+
const query = useQuery(toolQueryOptions(queryKey, toolName, args, callTool, opts, {
|
|
24
|
+
decode: parseViewToolResult,
|
|
25
|
+
toolNameInKey,
|
|
26
|
+
}));
|
|
27
|
+
useRefetchOnTransport(callTool, query);
|
|
28
|
+
return query;
|
|
28
29
|
}
|
|
29
30
|
//# sourceMappingURL=use-view-tool-query.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-view-tool-query.js","sourceRoot":"","sources":["../../src/hooks/use-view-tool-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuB,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"use-view-tool-query.js","sourceRoot":"","sources":["../../src/hooks/use-view-tool-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuB,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAE,gBAAgB,EAA4B,MAAM,sBAAsB,CAAA;AACjF,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAS5E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAA4B,EAC5B,QAAgB,EAChB,IAAY,EACZ,IAAiC;IAEjC,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAC9B,MAAM,aAAa,GAAG,qBAAqB,EAAE,CAAA;IAC7C,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;IACzC,MAAM,KAAK,GAAG,QAAQ,CACpB,gBAAgB,CAAI,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC5D,MAAM,EAAE,mBAAmB;QAC3B,aAAa;KACd,CAAC,CACH,CAAA;IACD,qBAAqB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;IACtC,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,22 +13,27 @@ export { Switch } from "./primitives/switch.js";
|
|
|
13
13
|
export { ScrollArea, ScrollBar } from "./primitives/scroll-area.js";
|
|
14
14
|
export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, } from "./primitives/sheet.js";
|
|
15
15
|
export { useIsMobile } from "./hooks/use-mobile.js";
|
|
16
|
-
export { useToolQuery, useToolMutation } from "./hooks/use-tool-query.js";
|
|
17
|
-
export type { UseToolQueryOptions } from "./hooks/use-tool-query.js";
|
|
16
|
+
export { useToolQuery, useToolQueryKey, useToolMutation } from "./hooks/use-tool-query.js";
|
|
17
|
+
export type { UseToolQueryOptions, UseToolMutationOptions } from "./hooks/use-tool-query.js";
|
|
18
|
+
export { toolQueryKey, shouldRetryToolCall } from "./lib/tool-query.js";
|
|
19
|
+
export { ToolResultError, isToolError } from "./lib/parse-tool-result.js";
|
|
20
|
+
export { keepPreviousData } from "@tanstack/react-query";
|
|
18
21
|
export { useDebouncedValue } from "./hooks/use-debounced-value.js";
|
|
19
|
-
export { TONE_SOFT, TONE_DOT, TONE_TEXT, TONE_BORDER, TONE_ICON } from "./lib/tone-utils.js";
|
|
20
|
-
export type { ToneVariant } from "./lib/tone-utils.js";
|
|
22
|
+
export { TONE_VARIANTS, TONE_ALIASES, resolveTone, isToneVariant, TONE_SOFT, TONE_TINT, TONE_DOT, TONE_INK, TONE_TEXT, TONE_BORDER, TONE_ICON, } from "./lib/tone-utils.js";
|
|
23
|
+
export type { ToneVariant, ToneAlias, ToneName } from "./lib/tone-utils.js";
|
|
24
|
+
export { TYPE_SCALE, TYPE_STEPS, TYPE_FLOOR_PX, MICRO_LABEL } from "./lib/typography.js";
|
|
25
|
+
export type { TypeStep } from "./lib/typography.js";
|
|
21
26
|
export { FOCUS_RING, FOCUS_RING_INSET } from "./lib/focus-ring.js";
|
|
22
27
|
export { GridLayout, GridItem } from "./components/GridLayout.js";
|
|
23
28
|
export type { GridLayoutProps, GridItemProps } from "./components/GridLayout.js";
|
|
24
|
-
export { KpiGrid } from "./components/KpiGrid.js";
|
|
25
|
-
export type { KpiGridProps, KpiGridHeader, KpiCell } from "./components/KpiGrid.js";
|
|
26
|
-
export { LivePill, CountPill } from "./components/Pills.js";
|
|
27
|
-
export type { LivePillProps, CountPillProps } from "./components/Pills.js";
|
|
29
|
+
export { KpiGrid, KpiGridSkeleton } from "./components/KpiGrid.js";
|
|
30
|
+
export type { KpiGridProps, KpiGridHeader, KpiCell, KpiGridSkeletonProps, } from "./components/KpiGrid.js";
|
|
31
|
+
export { LivePill, CountPill, StatusBadge } from "./components/Pills.js";
|
|
32
|
+
export type { LivePillProps, CountPillProps, StatusBadgeProps, StatusBadgeText, } from "./components/Pills.js";
|
|
28
33
|
export { SectionHeading } from "./components/SectionHeading.js";
|
|
29
34
|
export type { SectionHeadingProps } from "./components/SectionHeading.js";
|
|
30
35
|
export { WidgetHeader } from "./components/WidgetHeader.js";
|
|
31
|
-
export type { WidgetHeaderProps } from "./components/WidgetHeader.js";
|
|
36
|
+
export type { WidgetHeaderProps, WidgetHeadingLevel } from "./components/WidgetHeader.js";
|
|
32
37
|
export { GroupCard } from "./components/GroupCard.js";
|
|
33
38
|
export type { GroupCardProps } from "./components/GroupCard.js";
|
|
34
39
|
export { FilterBar } from "./components/FilterBar.js";
|
|
@@ -37,6 +42,8 @@ export { DrillButton } from "./components/DrillButton.js";
|
|
|
37
42
|
export type { DrillButtonProps } from "./components/DrillButton.js";
|
|
38
43
|
export { ListFooter } from "./components/ListFooter.js";
|
|
39
44
|
export type { ListFooterProps } from "./components/ListFooter.js";
|
|
45
|
+
export { PagedListFooter } from "./components/PagedListFooter.js";
|
|
46
|
+
export type { PagedListFooterProps, PagedListState } from "./components/PagedListFooter.js";
|
|
40
47
|
export { ToastProvider, useToast } from "./components/Toast.js";
|
|
41
48
|
export type { ToastApi, ToastOptions, ToastTone } from "./components/Toast.js";
|
|
42
49
|
export { EmptyState } from "./components/EmptyState.js";
|
|
@@ -47,7 +54,7 @@ export { AppQueryProvider, useCallTool, queryClient } from "./providers/query-pr
|
|
|
47
54
|
export { createTheme, resolveThemeVars, ROLE_TOKENS, ThemeProvider, useTheme, usePortalContainer, themePresets, CD_TOKENS, CD_TOKENS_VERSION, fontFaces, GEIST_FONT_FILES, adoptHostFontVariables, HOST_FONT_VARIABLES, } from "./theme/index.js";
|
|
48
55
|
export type { ThemeTokens, ThemeDefinition, ThemeVars, CreateThemeOptions, ThemeMode, ThemeContextValue, ThemeProviderProps, ThemePresetId, CdTokenName, FontFacesOptions, InlineStyleTarget, } from "./theme/index.js";
|
|
49
56
|
export { LocaleProvider, useLocale, useTranslate, useToolkitMessages, TOOLKIT_MESSAGES, formatCount, resolveToolkitMessages, } from "./locale/index.js";
|
|
50
|
-
export type { LocaleContextValue, LocaleProviderProps, BoundTranslate, BuilderMessages, CommonMessages, ListFooterMessages, PropsSheetMessages, RendererMessages, ToolkitLocale, ToolkitMessages, ToolkitMessagesOverride, ViewMessages, } from "./locale/index.js";
|
|
57
|
+
export type { LocaleContextValue, LocaleProviderProps, BoundTranslate, BuilderMessages, CommonMessages, FilterBarMessages, ListFooterMessages, PropsSheetMessages, RendererMessages, ToolkitLocale, ToolkitMessages, ToolkitMessagesOverride, ViewMessages, } from "./locale/index.js";
|
|
51
58
|
export { cn } from "./lib/utils.js";
|
|
52
59
|
export { parseToolResult, parseViewToolResult } from "./lib/parse-tool-result.js";
|
|
53
60
|
export type { ParseToolResultOptions } from "./lib/parse-tool-result.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,IAAI,EACJ,UAAU,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,eAAe,EACf,WAAW,GACZ,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EACL,KAAK,EACL,WAAW,EACX,SA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E,WAAW,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAQ1F,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EACV,WAAW,EACX,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,kBAAkB,CAAA;AAOzB,OAAO,EACL,cAAc,EACd,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,sBAAsB,GACvB,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EACV,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,YAAY,GACb,MAAM,mBAAmB,CAAA;AAQ1B,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AACjF,YAAY,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -17,26 +17,38 @@ export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHe
|
|
|
17
17
|
// NOTE: the view-tool hooks (`useViewToolQuery`, `useViewData`) are exported
|
|
18
18
|
// from the `./hooks` subpath only — see `packages/ui/src/hooks/index.ts`.
|
|
19
19
|
export { useIsMobile } from "./hooks/use-mobile.js";
|
|
20
|
-
export { useToolQuery, useToolMutation } from "./hooks/use-tool-query.js";
|
|
20
|
+
export { useToolQuery, useToolQueryKey, useToolMutation } from "./hooks/use-tool-query.js";
|
|
21
|
+
// The query layer's contract: the effective cache key, the opt-in retry
|
|
22
|
+
// policy (no retry of a tool's own isError answer), and TanStack's
|
|
23
|
+
// keepPreviousData for `placeholderData`, so a consumer needs no direct
|
|
24
|
+
// @tanstack/react-query import for the common options.
|
|
25
|
+
export { toolQueryKey, shouldRetryToolCall } from "./lib/tool-query.js";
|
|
26
|
+
export { ToolResultError, isToolError } from "./lib/parse-tool-result.js";
|
|
27
|
+
export { keepPreviousData } from "@tanstack/react-query";
|
|
21
28
|
export { useDebouncedValue } from "./hooks/use-debounced-value.js";
|
|
22
29
|
// Tone token system — the semantic status tones (ToneVariant + TONE_* maps)
|
|
23
|
-
// behind the tone-aware components below. Pure data + class strings.
|
|
30
|
+
// behind the tone-aware components below. Pure data + class strings. ONE
|
|
31
|
+
// vocabulary (TONE_VARIANTS; retired names map through resolveTone). Three
|
|
24
32
|
// roles per tone: colour (TONE_DOT/TONE_BORDER/TONE_ICON), tint (TONE_SOFT,
|
|
25
|
-
// foreground text on it), text on a plain surface (
|
|
26
|
-
|
|
33
|
+
// foreground text on it; TONE_TINT alone), text on a plain surface (TONE_INK,
|
|
34
|
+
// the -ink role; TONE_TEXT is its deprecated name).
|
|
35
|
+
export { TONE_VARIANTS, TONE_ALIASES, resolveTone, isToneVariant, TONE_SOFT, TONE_TINT, TONE_DOT, TONE_INK, TONE_TEXT, TONE_BORDER, TONE_ICON, } from "./lib/tone-utils.js";
|
|
36
|
+
// The type scale (CI §4): text-title/section/body/dense/small utilities, 13 px floor.
|
|
37
|
+
export { TYPE_SCALE, TYPE_STEPS, TYPE_FLOOR_PX, MICRO_LABEL } from "./lib/typography.js";
|
|
27
38
|
// The kit's opaque focus ring as class strings, for custom controls.
|
|
28
39
|
export { FOCUS_RING, FOCUS_RING_INSET } from "./lib/focus-ring.js";
|
|
29
40
|
// Composed components — focused widget building blocks assembled from the
|
|
30
41
|
// primitives. Pure (React + primitives + cn), so they live in the root barrel.
|
|
31
42
|
export { GridLayout, GridItem } from "./components/GridLayout.js";
|
|
32
|
-
export { KpiGrid } from "./components/KpiGrid.js";
|
|
33
|
-
export { LivePill, CountPill } from "./components/Pills.js";
|
|
43
|
+
export { KpiGrid, KpiGridSkeleton } from "./components/KpiGrid.js";
|
|
44
|
+
export { LivePill, CountPill, StatusBadge } from "./components/Pills.js";
|
|
34
45
|
export { SectionHeading } from "./components/SectionHeading.js";
|
|
35
46
|
export { WidgetHeader } from "./components/WidgetHeader.js";
|
|
36
47
|
export { GroupCard } from "./components/GroupCard.js";
|
|
37
48
|
export { FilterBar } from "./components/FilterBar.js";
|
|
38
49
|
export { DrillButton } from "./components/DrillButton.js";
|
|
39
50
|
export { ListFooter } from "./components/ListFooter.js";
|
|
51
|
+
export { PagedListFooter } from "./components/PagedListFooter.js";
|
|
40
52
|
// Feedback and states — one pattern each for toasts, empty and error states.
|
|
41
53
|
export { ToastProvider, useToast } from "./components/Toast.js";
|
|
42
54
|
export { EmptyState } from "./components/EmptyState.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,OAAO,EACL,IAAI,EACJ,UAAU,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,eAAe,EACf,WAAW,GACZ,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EACL,KAAK,EACL,WAAW,EACX,SAAS,EACT,WAAW,EACX,QAAQ,EACR,SAAS,EACT,SAAS,EACT,YAAY,GACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,QAAQ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,EAAE,MAAM,4BAA4B,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAGjE,6EAA6E;AAC7E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAGvD,YAAY;AACZ,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAE1F,yEAAyE;AACzE,8EAA8E;AAC9E,4EAA4E;AAC5E,yEAAyE;AACzE,yEAAyE;AACzE,oEAAoE;AACpE,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,kBAAkB,CAAA;AAezB,4EAA4E;AAC5E,mEAAmE;AACnE,0EAA0E;AAC1E,6DAA6D;AAC7D,4DAA4D;AAC5D,OAAO,EACL,cAAc,EACd,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,sBAAsB,GACvB,MAAM,mBAAmB,CAAA;AAiB1B,wEAAwE;AACxE,6EAA6E;AAC7E,gFAAgF;AAChF,+EAA+E;AAE/E,QAAQ;AACR,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Focus return for the kit's dialogs and sheets (CI §12: focus goes back to
|
|
3
|
+
* where it came from).
|
|
4
|
+
*
|
|
5
|
+
* A Radix dialog returns the focus only to its `Trigger`. The kit's overlays
|
|
6
|
+
* mostly open from React state, without one (the builder's Save, Discard and
|
|
7
|
+
* Catalogue, a cell's props sheet), and Radix then cancels its focus scope's
|
|
8
|
+
* own restore and focuses nothing: closing them by keyboard left the focus on
|
|
9
|
+
* the document body. `DialogContent` and `SheetContent` therefore note the
|
|
10
|
+
* element that has the focus as they open and hand the focus back to it when
|
|
11
|
+
* they close and the focus went with them, while that element is still in the
|
|
12
|
+
* document. A consumer's own `onCloseAutoFocus` that calls `preventDefault()`
|
|
13
|
+
* keeps full control.
|
|
14
|
+
*/
|
|
15
|
+
/** The part of an element the hand-back needs (structural, so it tests without a DOM). */
|
|
16
|
+
export interface FocusReturnTarget {
|
|
17
|
+
readonly isConnected: boolean;
|
|
18
|
+
focus: () => void;
|
|
19
|
+
}
|
|
20
|
+
/** The part of Radix's auto-focus events the hand-back reads. */
|
|
21
|
+
export interface AutoFocusEventLike {
|
|
22
|
+
readonly defaultPrevented: boolean;
|
|
23
|
+
preventDefault: () => void;
|
|
24
|
+
}
|
|
25
|
+
/** One overlay's hand-back, from {@link createFocusReturn}. */
|
|
26
|
+
export interface FocusReturn {
|
|
27
|
+
/**
|
|
28
|
+
* Notes the element that has the focus as the overlay opens. The document
|
|
29
|
+
* body is no target: a pointer that opened it without focusing anything
|
|
30
|
+
* (Safari does not focus a clicked button) leaves Radix's default in place.
|
|
31
|
+
*/
|
|
32
|
+
capture: (active: FocusReturnTarget | null, body: unknown) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Hands the focus back to the noted element when the overlay closes and the
|
|
35
|
+
* focus went with it (`focusLost`: it sits on the body). It leaves the focus
|
|
36
|
+
* where it is when a handler before it prevented that, when the focus
|
|
37
|
+
* already sits elsewhere (a click outside a non-modal overlay, a hand-off
|
|
38
|
+
* that moved it) or when the element left the document (an Apply or
|
|
39
|
+
* Discard that unmounted the builder). Forgets the element either way.
|
|
40
|
+
*/
|
|
41
|
+
restore: (event: AutoFocusEventLike, focusLost: boolean) => void;
|
|
42
|
+
}
|
|
43
|
+
/** A {@link FocusReturn} with nothing noted yet. */
|
|
44
|
+
export declare function createFocusReturn(): FocusReturn;
|
|
45
|
+
/**
|
|
46
|
+
* The `onOpenAutoFocus` / `onCloseAutoFocus` pair of a Radix dialog content
|
|
47
|
+
* with the focus hand-back of {@link createFocusReturn} composed in: it notes
|
|
48
|
+
* the opener BEFORE the consumer's open handler runs (that one may move the
|
|
49
|
+
* focus) and hands it back AFTER the consumer's close handler (whose
|
|
50
|
+
* `preventDefault()` keeps it out). Radix fires the open event only when the
|
|
51
|
+
* focus is outside the content as it mounts, so an element inside it must not
|
|
52
|
+
* take the focus itself (`autoFocus`): Radix focuses the first one anyway.
|
|
53
|
+
*/
|
|
54
|
+
export declare function useFocusReturn<E extends AutoFocusEventLike>(handlers: {
|
|
55
|
+
onOpenAutoFocus?: (event: E) => void;
|
|
56
|
+
onCloseAutoFocus?: (event: E) => void;
|
|
57
|
+
}): {
|
|
58
|
+
onOpenAutoFocus: (event: E) => void;
|
|
59
|
+
onCloseAutoFocus: (event: E) => void;
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=focus-return.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-return.d.ts","sourceRoot":"","sources":["../../src/lib/focus-return.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,0FAA0F;AAC1F,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;IAC7B,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB;AAED,iEAAiE;AACjE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;IAClC,cAAc,EAAE,MAAM,IAAI,CAAA;CAC3B;AAED,+DAA+D;AAC/D,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IAClE;;;;;;;OAOG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAA;CACjE;AAED,oDAAoD;AACpD,wBAAgB,iBAAiB,IAAI,WAAW,CAc/C;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,kBAAkB,EAAE,QAAQ,EAAE;IACrE,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;IACpC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;CACtC,GAAG;IAAE,eAAe,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;CAAE,CAahF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
/** A {@link FocusReturn} with nothing noted yet. */
|
|
3
|
+
export function createFocusReturn() {
|
|
4
|
+
let opener = null;
|
|
5
|
+
return {
|
|
6
|
+
capture: (active, body) => {
|
|
7
|
+
opener = active === body ? null : active;
|
|
8
|
+
},
|
|
9
|
+
restore: (event, focusLost) => {
|
|
10
|
+
const target = opener;
|
|
11
|
+
opener = null;
|
|
12
|
+
if (event.defaultPrevented || !focusLost || target === null || !target.isConnected)
|
|
13
|
+
return;
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
target.focus();
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The `onOpenAutoFocus` / `onCloseAutoFocus` pair of a Radix dialog content
|
|
21
|
+
* with the focus hand-back of {@link createFocusReturn} composed in: it notes
|
|
22
|
+
* the opener BEFORE the consumer's open handler runs (that one may move the
|
|
23
|
+
* focus) and hands it back AFTER the consumer's close handler (whose
|
|
24
|
+
* `preventDefault()` keeps it out). Radix fires the open event only when the
|
|
25
|
+
* focus is outside the content as it mounts, so an element inside it must not
|
|
26
|
+
* take the focus itself (`autoFocus`): Radix focuses the first one anyway.
|
|
27
|
+
*/
|
|
28
|
+
export function useFocusReturn(handlers) {
|
|
29
|
+
const [focusReturn] = useState(createFocusReturn);
|
|
30
|
+
return {
|
|
31
|
+
onOpenAutoFocus: (event) => {
|
|
32
|
+
focusReturn.capture(activeElementOf(document), document.body);
|
|
33
|
+
handlers.onOpenAutoFocus?.(event);
|
|
34
|
+
},
|
|
35
|
+
onCloseAutoFocus: (event) => {
|
|
36
|
+
handlers.onCloseAutoFocus?.(event);
|
|
37
|
+
const active = document.activeElement;
|
|
38
|
+
focusReturn.restore(event, active === null || active === document.body);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function activeElementOf(doc) {
|
|
43
|
+
const active = doc.activeElement;
|
|
44
|
+
return active && "focus" in active ? active : null;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=focus-return.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-return.js","sourceRoot":"","sources":["../../src/lib/focus-return.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAgDhC,oDAAoD;AACpD,MAAM,UAAU,iBAAiB;IAC/B,IAAI,MAAM,GAA6B,IAAI,CAAA;IAC3C,OAAO;QACL,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;YACxB,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAA;QAC1C,CAAC;QACD,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;YAC5B,MAAM,MAAM,GAAG,MAAM,CAAA;YACrB,MAAM,GAAG,IAAI,CAAA;YACb,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,SAAS,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW;gBAAE,OAAM;YAC1F,KAAK,CAAC,cAAc,EAAE,CAAA;YACtB,MAAM,CAAC,KAAK,EAAE,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAA+B,QAG5D;IACC,MAAM,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAA;IACjD,OAAO;QACL,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE;YACzB,WAAW,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;YAC7D,QAAQ,CAAC,eAAe,EAAE,CAAC,KAAK,CAAC,CAAA;QACnC,CAAC;QACD,gBAAgB,EAAE,CAAC,KAAK,EAAE,EAAE;YAC1B,QAAQ,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,CAAA;YAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAA;YACrC,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAA;QACzE,CAAC;KACF,CAAA;AACH,CAAC;AAED,SAAS,eAAe,CAAC,GAAa;IACpC,MAAM,MAAM,GAAG,GAAG,CAAC,aAAa,CAAA;IAChC,OAAO,MAAM,IAAI,OAAO,IAAI,MAAM,CAAC,CAAC,CAAE,MAAsB,CAAC,CAAC,CAAC,IAAI,CAAA;AACrE,CAAC"}
|
|
@@ -13,10 +13,32 @@ export interface ParseToolResultOptions {
|
|
|
13
13
|
*/
|
|
14
14
|
prefer?: "structured" | "text";
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* A tool answered with an `isError` result: a deterministic failure of the
|
|
18
|
+
* call itself (a validation error, an engine 404), not of the transport.
|
|
19
|
+
* Thrown by {@link parseToolResult}. The query hooks retry it like any
|
|
20
|
+
* failure by default (the client's `retry`); pass `retry: shouldRetryToolCall`
|
|
21
|
+
* to stop that, since repeating the call repeats the answer. Still an `Error`
|
|
22
|
+
* with the tool's first text block as its message.
|
|
23
|
+
*/
|
|
24
|
+
export declare class ToolResultError extends Error {
|
|
25
|
+
/** The `isError` result as the tool returned it. */
|
|
26
|
+
readonly result: unknown;
|
|
27
|
+
constructor(message: string, result: unknown);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Whether `error` is a tool's own `isError` answer: a {@link ToolResultError},
|
|
31
|
+
* or mcp-use's `ToolError` (how `useDynamicTool` rejects an `isError` result
|
|
32
|
+
* inside a view), recognised by its name and result so the root barrel never
|
|
33
|
+
* imports `mcp-use/react`. Transport failures (a lost connection, a JSON-RPC
|
|
34
|
+
* error such as an unknown tool) are not tool errors.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isToolError(error: unknown): boolean;
|
|
16
37
|
/**
|
|
17
38
|
* Decodes an MCP tool result down to its data payload.
|
|
18
39
|
*
|
|
19
|
-
* Default (`prefer: "structured"`): `isError` → throw
|
|
40
|
+
* Default (`prefer: "structured"`): `isError` → throw a
|
|
41
|
+
* {@link ToolResultError} with the first text block,
|
|
20
42
|
* then `structuredContent` (if non-null), then JSON-decode the first text
|
|
21
43
|
* block (verbatim string if it isn't JSON), then the raw result.
|
|
22
44
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-tool-result.d.ts","sourceRoot":"","sources":["../../src/lib/parse-tool-result.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAAA;CAC/B;AAED
|
|
1
|
+
{"version":3,"file":"parse-tool-result.d.ts","sourceRoot":"","sources":["../../src/lib/parse-tool-result.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAAA;CAC/B;AAED;;;;;;;GAOG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;gBAEZ,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;CAK7C;AAMD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKnD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,sBAAsB,GAAG,CAAC,CAmC9F;AAKD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,CAAC,CASnE"}
|
|
@@ -1,7 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tool answered with an `isError` result: a deterministic failure of the
|
|
3
|
+
* call itself (a validation error, an engine 404), not of the transport.
|
|
4
|
+
* Thrown by {@link parseToolResult}. The query hooks retry it like any
|
|
5
|
+
* failure by default (the client's `retry`); pass `retry: shouldRetryToolCall`
|
|
6
|
+
* to stop that, since repeating the call repeats the answer. Still an `Error`
|
|
7
|
+
* with the tool's first text block as its message.
|
|
8
|
+
*/
|
|
9
|
+
export class ToolResultError extends Error {
|
|
10
|
+
/** The `isError` result as the tool returned it. */
|
|
11
|
+
result;
|
|
12
|
+
constructor(message, result) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "ToolResultError";
|
|
15
|
+
this.result = result;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function isRecord(value) {
|
|
19
|
+
return typeof value === "object" && value !== null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Whether `error` is a tool's own `isError` answer: a {@link ToolResultError},
|
|
23
|
+
* or mcp-use's `ToolError` (how `useDynamicTool` rejects an `isError` result
|
|
24
|
+
* inside a view), recognised by its name and result so the root barrel never
|
|
25
|
+
* imports `mcp-use/react`. Transport failures (a lost connection, a JSON-RPC
|
|
26
|
+
* error such as an unknown tool) are not tool errors.
|
|
27
|
+
*/
|
|
28
|
+
export function isToolError(error) {
|
|
29
|
+
if (error instanceof ToolResultError)
|
|
30
|
+
return true;
|
|
31
|
+
if (!(error instanceof Error) || error.name !== "ToolError")
|
|
32
|
+
return false;
|
|
33
|
+
const result = error.result;
|
|
34
|
+
return isRecord(result) && result.isError === true;
|
|
35
|
+
}
|
|
1
36
|
/**
|
|
2
37
|
* Decodes an MCP tool result down to its data payload.
|
|
3
38
|
*
|
|
4
|
-
* Default (`prefer: "structured"`): `isError` → throw
|
|
39
|
+
* Default (`prefer: "structured"`): `isError` → throw a
|
|
40
|
+
* {@link ToolResultError} with the first text block,
|
|
5
41
|
* then `structuredContent` (if non-null), then JSON-decode the first text
|
|
6
42
|
* block (verbatim string if it isn't JSON), then the raw result.
|
|
7
43
|
*
|
|
@@ -14,7 +50,7 @@
|
|
|
14
50
|
export function parseToolResult(result, opts) {
|
|
15
51
|
const r = result;
|
|
16
52
|
if (r?.isError)
|
|
17
|
-
throw new
|
|
53
|
+
throw new ToolResultError(r.content?.[0]?.text ?? "Tool call failed", result);
|
|
18
54
|
const fromStructured = () => r?.structuredContent != null ? r.structuredContent : undefined;
|
|
19
55
|
const fromText = () => {
|
|
20
56
|
const text = r?.content?.[0]?.text;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-tool-result.js","sourceRoot":"","sources":["../../src/lib/parse-tool-result.ts"],"names":[],"mappings":"AAkBA
|
|
1
|
+
{"version":3,"file":"parse-tool-result.js","sourceRoot":"","sources":["../../src/lib/parse-tool-result.ts"],"names":[],"mappings":"AAkBA;;;;;;;GAOG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,oDAAoD;IAC3C,MAAM,CAAS;IAExB,YAAY,OAAe,EAAE,MAAe;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAA;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AAM,CAAA;IACnF,CAAC;IACD,OAAO,MAAW,CAAA;AACpB,CAAC"}
|
|
@@ -5,9 +5,19 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/** Status tone of a toast — the four status roles (`--success` … `--info`). */
|
|
7
7
|
export type ToastTone = "success" | "warning" | "danger" | "info";
|
|
8
|
+
/**
|
|
9
|
+
* The toast tone of any tone name: the four status tones as is, a retired
|
|
10
|
+
* name through `resolveTone` (`error` → `danger`), and `neutral` or anything
|
|
11
|
+
* unknown as `info`. Keeps a toast whose tone arrives untyped (plain JS, wire
|
|
12
|
+
* data) on the screen instead of crashing the view on a missing icon.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveToastTone(name: unknown): ToastTone;
|
|
8
15
|
/** What a caller passes to `useToast().show(...)`. */
|
|
9
16
|
export interface ToastOptions {
|
|
10
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Status tone; drives the edge, the icon and the default duration. Default
|
|
19
|
+
* `"info"`. An untyped retired name still resolves ({@link resolveToastTone}).
|
|
20
|
+
*/
|
|
11
21
|
tone?: ToastTone;
|
|
12
22
|
/** The message. Say what happened, in one short sentence ("Job retried."). */
|
|
13
23
|
title: string;
|
|
@@ -43,4 +53,34 @@ export type ToastAction = {
|
|
|
43
53
|
};
|
|
44
54
|
/** Add appends (dropping the oldest beyond {@link MAX_VISIBLE_TOASTS}); dismiss removes by id. */
|
|
45
55
|
export declare function toastReducer(state: readonly ToastItem[], action: ToastAction): ToastItem[];
|
|
56
|
+
/**
|
|
57
|
+
* The clock a {@link createToastTimer} runs on. The default reads the global
|
|
58
|
+
* timers at call time, so fake timers installed in a test take effect.
|
|
59
|
+
*/
|
|
60
|
+
export interface ToastClock {
|
|
61
|
+
now: () => number;
|
|
62
|
+
setTimeout: (callback: () => void, ms: number) => unknown;
|
|
63
|
+
clearTimeout: (handle: unknown) => void;
|
|
64
|
+
}
|
|
65
|
+
/** The countdown of one toast (see {@link createToastTimer}). */
|
|
66
|
+
export interface ToastTimer {
|
|
67
|
+
/**
|
|
68
|
+
* Hold the toast for `reason` (`"pointer"`, `"focus"`): the countdown
|
|
69
|
+
* pauses and keeps the time that was left.
|
|
70
|
+
*/
|
|
71
|
+
hold: (reason: string) => void;
|
|
72
|
+
/** Release `reason`; once nothing holds the toast, it resumes with the time that was left. */
|
|
73
|
+
release: (reason: string) => void;
|
|
74
|
+
/** The time left in ms — frozen while held. */
|
|
75
|
+
remaining: () => number;
|
|
76
|
+
/** Stop for good (the toast left early or unmounted); `onExpire` never fires afterwards. */
|
|
77
|
+
cancel: () => void;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A pausable countdown: starts at once, pauses while anything holds it
|
|
81
|
+
* (hover, keyboard focus — so a reader can finish), and on release RESUMES
|
|
82
|
+
* WITH THE REMAINING TIME instead of restarting the full duration. Fires
|
|
83
|
+
* `onExpire` once.
|
|
84
|
+
*/
|
|
85
|
+
export declare function createToastTimer(duration: number, onExpire: () => void, clock?: ToastClock): ToastTimer;
|
|
46
86
|
//# sourceMappingURL=toast-model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-model.d.ts","sourceRoot":"","sources":["../../src/lib/toast-model.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"toast-model.d.ts","sourceRoot":"","sources":["../../src/lib/toast-model.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,+EAA+E;AAC/E,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAA;AAEjE;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,CAGzD;AAED,sDAAsD;AACtD,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAA;IACb,2EAA2E;IAC3E,WAAW,CAAC,EA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AAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,8FAA8F;IAC9F,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,+CAA+C;IAC/C,SAAS,EAAE,MAAM,MAAM,CAAA;IACvB,4FAA4F;IAC5F,MAAM,EAAE,MAAM,IAAI,CAAA;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,IAAI,EACpB,KAAK,GAAE,UAAyB,GAC/B,UAAU,CA2CZ"}
|
package/dist/lib/toast-model.js
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
* plus the timing rules, so both are testable without a DOM (the house path,
|
|
4
4
|
* FITNESS.md) and the component stays a thin view over them.
|
|
5
5
|
*/
|
|
6
|
+
import { resolveTone } from "./tone-utils.js";
|
|
7
|
+
/**
|
|
8
|
+
* The toast tone of any tone name: the four status tones as is, a retired
|
|
9
|
+
* name through `resolveTone` (`error` → `danger`), and `neutral` or anything
|
|
10
|
+
* unknown as `info`. Keeps a toast whose tone arrives untyped (plain JS, wire
|
|
11
|
+
* data) on the screen instead of crashing the view on a missing icon.
|
|
12
|
+
*/
|
|
13
|
+
export function resolveToastTone(name) {
|
|
14
|
+
const tone = resolveTone(name, "info");
|
|
15
|
+
return tone === "neutral" ? "info" : tone;
|
|
16
|
+
}
|
|
6
17
|
/** Default lifetime of a toast (CI §8: about 2.8 s). */
|
|
7
18
|
export const TOAST_DURATION_MS = 2800;
|
|
8
19
|
/** Lifetime of an error toast (CI §8: about 5 s) — long enough to read the reason. */
|
|
@@ -17,7 +28,7 @@ export function toastDuration(tone, explicit) {
|
|
|
17
28
|
}
|
|
18
29
|
/** Normalise caller options into a list item. */
|
|
19
30
|
export function createToast(id, options) {
|
|
20
|
-
const tone = options.tone
|
|
31
|
+
const tone = resolveToastTone(options.tone);
|
|
21
32
|
return {
|
|
22
33
|
id,
|
|
23
34
|
tone,
|
|
@@ -33,4 +44,59 @@ export function toastReducer(state, action) {
|
|
|
33
44
|
const next = state.filter((t) => t.id !== action.id);
|
|
34
45
|
return next.length === state.length ? state : next;
|
|
35
46
|
}
|
|
47
|
+
const SYSTEM_CLOCK = {
|
|
48
|
+
now: () => Date.now(),
|
|
49
|
+
setTimeout: (callback, ms) => globalThis.setTimeout(callback, ms),
|
|
50
|
+
clearTimeout: (handle) => globalThis.clearTimeout(handle),
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* A pausable countdown: starts at once, pauses while anything holds it
|
|
54
|
+
* (hover, keyboard focus — so a reader can finish), and on release RESUMES
|
|
55
|
+
* WITH THE REMAINING TIME instead of restarting the full duration. Fires
|
|
56
|
+
* `onExpire` once.
|
|
57
|
+
*/
|
|
58
|
+
export function createToastTimer(duration, onExpire, clock = SYSTEM_CLOCK) {
|
|
59
|
+
let left = Math.max(duration, 0);
|
|
60
|
+
let startedAt = 0;
|
|
61
|
+
let handle;
|
|
62
|
+
let running = false;
|
|
63
|
+
let finished = false;
|
|
64
|
+
const holds = new Set();
|
|
65
|
+
const elapsed = () => (running ? clock.now() - startedAt : 0);
|
|
66
|
+
const start = () => {
|
|
67
|
+
if (finished || running || holds.size > 0)
|
|
68
|
+
return;
|
|
69
|
+
running = true;
|
|
70
|
+
startedAt = clock.now();
|
|
71
|
+
handle = clock.setTimeout(() => {
|
|
72
|
+
running = false;
|
|
73
|
+
finished = true;
|
|
74
|
+
left = 0;
|
|
75
|
+
onExpire();
|
|
76
|
+
}, left);
|
|
77
|
+
};
|
|
78
|
+
const pause = () => {
|
|
79
|
+
if (!running)
|
|
80
|
+
return;
|
|
81
|
+
left = Math.max(left - elapsed(), 0);
|
|
82
|
+
running = false;
|
|
83
|
+
clock.clearTimeout(handle);
|
|
84
|
+
};
|
|
85
|
+
start();
|
|
86
|
+
return {
|
|
87
|
+
hold: (reason) => {
|
|
88
|
+
holds.add(reason);
|
|
89
|
+
pause();
|
|
90
|
+
},
|
|
91
|
+
release: (reason) => {
|
|
92
|
+
holds.delete(reason);
|
|
93
|
+
start();
|
|
94
|
+
},
|
|
95
|
+
remaining: () => Math.max(left - elapsed(), 0),
|
|
96
|
+
cancel: () => {
|
|
97
|
+
pause();
|
|
98
|
+
finished = true;
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
36
102
|
//# sourceMappingURL=toast-model.js.map
|