@miragon/mcp-toolkit-ui 2.5.0 → 2.7.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 +8 -2
- package/dist/app/builder/BuilderBanners.d.ts +7 -2
- package/dist/app/builder/BuilderBanners.d.ts.map +1 -1
- package/dist/app/builder/BuilderBanners.js +8 -3
- package/dist/app/builder/BuilderBanners.js.map +1 -1
- package/dist/app/builder/CanvasRow.d.ts.map +1 -1
- package/dist/app/builder/CanvasRow.js +12 -14
- 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 +6 -5
- package/dist/app/builder/CatalogueSheet.js.map +1 -1
- package/dist/app/builder/EmptyHint.d.ts +4 -0
- package/dist/app/builder/EmptyHint.d.ts.map +1 -1
- package/dist/app/builder/EmptyHint.js +6 -1
- package/dist/app/builder/EmptyHint.js.map +1 -1
- package/dist/app/builder/LayoutSurface.js +3 -3
- package/dist/app/builder/LayoutSurface.js.map +1 -1
- package/dist/app/builder/PipelineStrip.d.ts +3 -1
- package/dist/app/builder/PipelineStrip.d.ts.map +1 -1
- package/dist/app/builder/PipelineStrip.js +11 -6
- package/dist/app/builder/PipelineStrip.js.map +1 -1
- package/dist/app/builder/SaveDialog.d.ts.map +1 -1
- package/dist/app/builder/SaveDialog.js +2 -2
- package/dist/app/builder/SaveDialog.js.map +1 -1
- package/dist/app/builder/Toolbar.d.ts +3 -1
- package/dist/app/builder/Toolbar.d.ts.map +1 -1
- package/dist/app/builder/Toolbar.js +9 -3
- package/dist/app/builder/Toolbar.js.map +1 -1
- package/dist/app/builder/Workspace.js +2 -2
- package/dist/app/builder/Workspace.js.map +1 -1
- package/dist/app/builder/builder-model.d.ts +3 -2
- package/dist/app/builder/builder-model.d.ts.map +1 -1
- package/dist/app/builder/builder-model.js +5 -4
- package/dist/app/builder/builder-model.js.map +1 -1
- package/dist/app/builder/labels.d.ts +13 -62
- package/dist/app/builder/labels.d.ts.map +1 -1
- package/dist/app/builder/labels.js +9 -58
- package/dist/app/builder/labels.js.map +1 -1
- package/dist/app/builder/status-chip.d.ts.map +1 -1
- package/dist/app/builder/status-chip.js +3 -2
- package/dist/app/builder/status-chip.js.map +1 -1
- package/dist/app/builder/use-builder-catalogue.d.ts +1 -0
- package/dist/app/builder/use-builder-catalogue.d.ts.map +1 -1
- package/dist/app/builder/use-builder-catalogue.js +6 -0
- package/dist/app/builder/use-builder-catalogue.js.map +1 -1
- package/dist/app/builder/use-save-dashboard.d.ts +3 -1
- package/dist/app/builder/use-save-dashboard.d.ts.map +1 -1
- package/dist/app/builder/use-save-dashboard.js +3 -1
- package/dist/app/builder/use-save-dashboard.js.map +1 -1
- package/dist/app/index.d.ts +1 -1
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js.map +1 -1
- package/dist/app/layout-builder.d.ts +7 -2
- package/dist/app/layout-builder.d.ts.map +1 -1
- package/dist/app/layout-builder.js +17 -5
- package/dist/app/layout-builder.js.map +1 -1
- package/dist/app/mcp-app-view-chrome.d.ts +94 -20
- package/dist/app/mcp-app-view-chrome.d.ts.map +1 -1
- package/dist/app/mcp-app-view-chrome.js +109 -40
- package/dist/app/mcp-app-view-chrome.js.map +1 -1
- package/dist/app/mcp-app-view-states.d.ts +15 -0
- package/dist/app/mcp-app-view-states.d.ts.map +1 -0
- package/dist/app/mcp-app-view-states.js +34 -0
- package/dist/app/mcp-app-view-states.js.map +1 -0
- package/dist/app/mcp-app-view.d.ts +40 -5
- package/dist/app/mcp-app-view.d.ts.map +1 -1
- package/dist/app/mcp-app-view.js +174 -128
- package/dist/app/mcp-app-view.js.map +1 -1
- package/dist/app/mcp-toolkit-app.d.ts +2 -1
- package/dist/app/mcp-toolkit-app.d.ts.map +1 -1
- package/dist/app/mcp-toolkit-app.js +25 -3
- package/dist/app/mcp-toolkit-app.js.map +1 -1
- package/dist/app/use-view-lifecycle.d.ts +38 -0
- package/dist/app/use-view-lifecycle.d.ts.map +1 -0
- package/dist/app/use-view-lifecycle.js +79 -0
- package/dist/app/use-view-lifecycle.js.map +1 -0
- package/dist/app/view-lifecycle.d.ts +109 -0
- package/dist/app/view-lifecycle.d.ts.map +1 -0
- package/dist/app/view-lifecycle.js +120 -0
- package/dist/app/view-lifecycle.js.map +1 -0
- package/dist/app/widget-props-sheet.d.ts +3 -9
- package/dist/app/widget-props-sheet.d.ts.map +1 -1
- package/dist/app/widget-props-sheet.js +6 -13
- package/dist/app/widget-props-sheet.js.map +1 -1
- package/dist/app/widget-renderer.d.ts +41 -1
- package/dist/app/widget-renderer.d.ts.map +1 -1
- package/dist/app/widget-renderer.js +82 -31
- package/dist/app/widget-renderer.js.map +1 -1
- package/dist/components/DrillButton.d.ts.map +1 -1
- package/dist/components/DrillButton.js +2 -1
- package/dist/components/DrillButton.js.map +1 -1
- package/dist/components/EmptyState.d.ts +33 -0
- package/dist/components/EmptyState.d.ts.map +1 -0
- package/dist/components/EmptyState.js +17 -0
- package/dist/components/EmptyState.js.map +1 -0
- package/dist/components/ErrorState.d.ts +50 -0
- package/dist/components/ErrorState.d.ts.map +1 -0
- package/dist/components/ErrorState.js +60 -0
- package/dist/components/ErrorState.js.map +1 -0
- package/dist/components/FilterBar.d.ts +1 -1
- package/dist/components/FilterBar.d.ts.map +1 -1
- package/dist/components/FilterBar.js +7 -4
- package/dist/components/FilterBar.js.map +1 -1
- package/dist/components/GroupCard.d.ts.map +1 -1
- package/dist/components/GroupCard.js +2 -1
- package/dist/components/GroupCard.js.map +1 -1
- package/dist/components/KpiGrid.d.ts +10 -3
- package/dist/components/KpiGrid.d.ts.map +1 -1
- package/dist/components/KpiGrid.js +31 -9
- package/dist/components/KpiGrid.js.map +1 -1
- package/dist/components/ListFooter.d.ts +3 -2
- package/dist/components/ListFooter.d.ts.map +1 -1
- package/dist/components/ListFooter.js +14 -4
- package/dist/components/ListFooter.js.map +1 -1
- package/dist/components/Pills.d.ts +10 -6
- package/dist/components/Pills.d.ts.map +1 -1
- package/dist/components/Pills.js +12 -6
- package/dist/components/Pills.js.map +1 -1
- package/dist/components/Toast.d.ts +37 -0
- package/dist/components/Toast.d.ts.map +1 -0
- package/dist/components/Toast.js +91 -0
- package/dist/components/Toast.js.map +1 -0
- package/dist/components/WidgetHeader.js +1 -1
- package/dist/hooks/use-tool-result-recovery.d.ts +23 -1
- package/dist/hooks/use-tool-result-recovery.d.ts.map +1 -1
- package/dist/hooks/use-tool-result-recovery.js +21 -7
- package/dist/hooks/use-tool-result-recovery.js.map +1 -1
- package/dist/hooks/use-view-data.d.ts +6 -0
- package/dist/hooks/use-view-data.d.ts.map +1 -1
- package/dist/hooks/use-view-data.js +6 -1
- package/dist/hooks/use-view-data.js.map +1 -1
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/focus-ring.d.ts +18 -0
- package/dist/lib/focus-ring.d.ts.map +1 -0
- package/dist/lib/focus-ring.js +18 -0
- package/dist/lib/focus-ring.js.map +1 -0
- package/dist/lib/icon-stroke.d.ts +12 -0
- package/dist/lib/icon-stroke.d.ts.map +1 -0
- package/dist/lib/icon-stroke.js +12 -0
- package/dist/lib/icon-stroke.js.map +1 -0
- package/dist/lib/toast-model.d.ts +46 -0
- package/dist/lib/toast-model.d.ts.map +1 -0
- package/dist/lib/toast-model.js +36 -0
- package/dist/lib/toast-model.js.map +1 -0
- package/dist/lib/tone-utils.d.ts +43 -9
- package/dist/lib/tone-utils.d.ts.map +1 -1
- package/dist/lib/tone-utils.js +36 -7
- package/dist/lib/tone-utils.js.map +1 -1
- package/dist/locale/index.d.ts +3 -1
- package/dist/locale/index.d.ts.map +1 -1
- package/dist/locale/index.js +2 -1
- package/dist/locale/index.js.map +1 -1
- package/dist/locale/locale-provider.d.ts +42 -1
- package/dist/locale/locale-provider.d.ts.map +1 -1
- package/dist/locale/locale-provider.js +44 -3
- package/dist/locale/locale-provider.js.map +1 -1
- package/dist/locale/message-types.d.ts +223 -0
- package/dist/locale/message-types.d.ts.map +1 -0
- package/dist/locale/message-types.js +7 -0
- package/dist/locale/message-types.js.map +1 -0
- package/dist/locale/messages-de.d.ts +9 -0
- package/dist/locale/messages-de.d.ts.map +1 -0
- package/dist/locale/messages-de.js +151 -0
- package/dist/locale/messages-de.js.map +1 -0
- package/dist/locale/messages-en.d.ts +8 -0
- package/dist/locale/messages-en.d.ts.map +1 -0
- package/dist/locale/messages-en.js +150 -0
- package/dist/locale/messages-en.js.map +1 -0
- package/dist/locale/toolkit-messages.d.ts +39 -0
- package/dist/locale/toolkit-messages.d.ts.map +1 -0
- package/dist/locale/toolkit-messages.js +50 -0
- package/dist/locale/toolkit-messages.js.map +1 -0
- package/dist/primitives/alert.d.ts.map +1 -1
- package/dist/primitives/alert.js +4 -2
- 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 +14 -6
- package/dist/primitives/badge.js.map +1 -1
- package/dist/primitives/button.d.ts.map +1 -1
- package/dist/primitives/button.js +12 -8
- package/dist/primitives/button.js.map +1 -1
- package/dist/primitives/card.js +4 -4
- package/dist/primitives/card.js.map +1 -1
- package/dist/primitives/dialog.d.ts +7 -3
- package/dist/primitives/dialog.d.ts.map +1 -1
- package/dist/primitives/dialog.js +14 -7
- package/dist/primitives/dialog.js.map +1 -1
- package/dist/primitives/input.d.ts.map +1 -1
- package/dist/primitives/input.js +4 -1
- package/dist/primitives/input.js.map +1 -1
- package/dist/primitives/scroll-area.js +1 -1
- package/dist/primitives/scroll-area.js.map +1 -1
- package/dist/primitives/select.d.ts.map +1 -1
- package/dist/primitives/select.js +5 -2
- package/dist/primitives/select.js.map +1 -1
- package/dist/primitives/sheet.d.ts +3 -1
- package/dist/primitives/sheet.d.ts.map +1 -1
- package/dist/primitives/sheet.js +12 -6
- package/dist/primitives/sheet.js.map +1 -1
- package/dist/primitives/skeleton.js +1 -1
- package/dist/primitives/skeleton.js.map +1 -1
- package/dist/primitives/switch.d.ts.map +1 -1
- package/dist/primitives/switch.js +2 -1
- package/dist/primitives/switch.js.map +1 -1
- package/dist/primitives/tabs.d.ts.map +1 -1
- package/dist/primitives/tabs.js +5 -3
- package/dist/primitives/tabs.js.map +1 -1
- package/dist/render-cases.d.ts.map +1 -1
- package/dist/render-cases.js +20 -2
- package/dist/render-cases.js.map +1 -1
- package/dist/render-scan.d.ts +25 -0
- package/dist/render-scan.d.ts.map +1 -0
- package/dist/render-scan.js +66 -0
- package/dist/render-scan.js.map +1 -0
- package/dist/theme/cd-tokens.d.ts +66 -0
- package/dist/theme/cd-tokens.d.ts.map +1 -0
- package/dist/theme/cd-tokens.js +64 -0
- package/dist/theme/cd-tokens.js.map +1 -0
- package/dist/theme/create-theme.d.ts +196 -39
- package/dist/theme/create-theme.d.ts.map +1 -1
- package/dist/theme/create-theme.js +189 -13
- package/dist/theme/create-theme.js.map +1 -1
- package/dist/theme/fonts.d.ts +38 -0
- package/dist/theme/fonts.d.ts.map +1 -0
- package/dist/theme/fonts.js +56 -0
- package/dist/theme/fonts.js.map +1 -0
- package/dist/theme/host-fonts.d.ts +39 -0
- package/dist/theme/host-fonts.d.ts.map +1 -0
- package/dist/theme/host-fonts.js +44 -0
- package/dist/theme/host-fonts.js.map +1 -0
- package/dist/theme/index.d.ts +8 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +5 -1
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/portal-container.d.ts +16 -0
- package/dist/theme/portal-container.d.ts.map +1 -0
- package/dist/theme/portal-container.js +19 -0
- package/dist/theme/portal-container.js.map +1 -0
- package/dist/theme/presets.d.ts +24 -9
- package/dist/theme/presets.d.ts.map +1 -1
- package/dist/theme/presets.js +44 -11
- package/dist/theme/presets.js.map +1 -1
- package/dist/theme/theme-provider.d.ts +27 -9
- package/dist/theme/theme-provider.d.ts.map +1 -1
- package/dist/theme/theme-provider.js +42 -20
- package/dist/theme/theme-provider.js.map +1 -1
- package/package.json +13 -8
- package/src/app/builder/BuilderBanners.tsx +26 -13
- package/src/app/builder/CanvasRow.tsx +22 -21
- package/src/app/builder/CatalogueSheet.tsx +16 -14
- package/src/app/builder/EmptyHint.tsx +16 -11
- package/src/app/builder/LayoutSurface.tsx +7 -7
- package/src/app/builder/PipelineStrip.tsx +26 -17
- package/src/app/builder/SaveDialog.tsx +11 -12
- package/src/app/builder/Toolbar.tsx +19 -7
- package/src/app/builder/Workspace.tsx +5 -3
- package/src/app/builder/builder-feedback.test.tsx +75 -0
- package/src/app/builder/builder-model.test.ts +5 -0
- package/src/app/builder/builder-model.ts +5 -4
- package/src/app/builder/labels.ts +15 -121
- package/src/app/builder/status-chip.tsx +8 -4
- package/src/app/builder/use-builder-catalogue.ts +6 -0
- package/src/app/builder/use-save-dashboard.ts +5 -0
- package/src/app/index.ts +8 -1
- package/src/app/layout-builder.tsx +23 -3
- package/src/app/mcp-app-view-chrome.test.tsx +347 -14
- package/src/app/mcp-app-view-chrome.tsx +278 -100
- package/src/app/mcp-app-view-states.tsx +100 -0
- package/src/app/mcp-app-view.test.tsx +258 -0
- package/src/app/mcp-app-view.tsx +292 -185
- package/src/app/mcp-toolkit-app.tsx +31 -7
- package/src/app/use-view-lifecycle.ts +116 -0
- package/src/app/view-lifecycle.test.ts +227 -0
- package/src/app/view-lifecycle.ts +174 -0
- package/src/app/widget-props-sheet.tsx +13 -26
- package/src/app/widget-renderer.render.test.tsx +131 -0
- package/src/app/widget-renderer.tsx +136 -38
- package/src/components/DrillButton.tsx +2 -1
- package/src/components/EmptyState.tsx +81 -0
- package/src/components/ErrorState.tsx +182 -0
- package/src/components/FilterBar.tsx +9 -6
- package/src/components/GroupCard.tsx +3 -2
- package/src/components/KpiGrid.tsx +75 -44
- package/src/components/ListFooter.tsx +17 -6
- package/src/components/Pills.tsx +20 -11
- package/src/components/Toast.tsx +188 -0
- package/src/components/WidgetHeader.tsx +1 -1
- package/src/components/feedback-states.test.tsx +225 -0
- package/src/components/tone-figures.test.tsx +54 -0
- package/src/fonts.css +19 -0
- package/src/globals.css +9 -165
- package/src/hooks/use-tool-result-recovery.test.ts +25 -1
- package/src/hooks/use-tool-result-recovery.ts +34 -6
- package/src/hooks/use-view-data.test.tsx +60 -0
- package/src/hooks/use-view-data.ts +12 -1
- package/src/i18n-coverage.test.tsx +323 -0
- package/src/index.ts +57 -5
- package/src/lib/focus-ring.ts +20 -0
- package/src/lib/icon-stroke.test.ts +59 -0
- package/src/lib/icon-stroke.ts +13 -0
- package/src/lib/toast-model.test.ts +68 -0
- package/src/lib/toast-model.ts +63 -0
- package/src/lib/tone-utils.test.ts +47 -14
- package/src/lib/tone-utils.ts +61 -13
- package/src/locale/index.ts +13 -1
- package/src/locale/locale-provider.test.tsx +87 -0
- package/src/locale/locale-provider.tsx +90 -3
- package/src/locale/message-types.ts +221 -0
- package/src/locale/messages-de.ts +159 -0
- package/src/locale/messages-en.ts +157 -0
- package/src/locale/toolkit-messages.test.ts +216 -0
- package/src/locale/toolkit-messages.ts +82 -0
- package/src/no-hardcoded-copy.test.ts +432 -0
- package/src/primitives/alert.tsx +4 -2
- package/src/primitives/badge.tsx +14 -7
- package/src/primitives/button.tsx +13 -8
- package/src/primitives/card.tsx +4 -4
- package/src/primitives/dialog.tsx +32 -7
- package/src/primitives/input.tsx +5 -3
- package/src/primitives/scroll-area.tsx +1 -1
- package/src/primitives/select.tsx +6 -3
- package/src/primitives/sheet.tsx +26 -6
- package/src/primitives/skeleton.tsx +1 -1
- package/src/primitives/switch.tsx +4 -2
- package/src/primitives/tabs.tsx +9 -6
- package/src/render-cases.tsx +45 -1
- package/src/render-scan.ts +75 -0
- package/src/theme/cd-tokens.generated.css +48 -0
- package/src/theme/cd-tokens.test.ts +107 -0
- package/src/theme/cd-tokens.ts +67 -0
- package/src/theme/create-theme.test.ts +243 -5
- package/src/theme/create-theme.ts +313 -41
- package/src/theme/fonts.test.ts +85 -0
- package/src/theme/fonts.ts +72 -0
- package/src/theme/host-fonts.test.ts +135 -0
- package/src/theme/host-fonts.ts +52 -0
- package/src/theme/index.ts +15 -1
- package/src/theme/portal-container.ts +20 -0
- package/src/theme/presets.ts +44 -11
- package/src/theme/theme-css.test.ts +568 -0
- package/src/theme/theme-provider.test.tsx +82 -0
- package/src/theme/theme-provider.tsx +60 -24
- package/src/theme.css +314 -0
- package/ui-catalog.json +344 -17
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,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC/E,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EACL,MAAM,EACN,aAAa,EACb,WAAW,EACX,UAAU,EACV,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,WAAW,GACZ,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,iBAA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sB,GACvB,MAAM,mBAAmB,CAAA;AAgB1B,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,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The toolkit's focus indicator as Tailwind classes: an opaque 2px ring in the
|
|
3
|
+
* `--focus` role (blau-link on light, blau-hell on dark — 3:1 or more against
|
|
4
|
+
* every surface, see `theme/theme-css.test.ts`), offset from the control so it
|
|
5
|
+
* reads on any fill. Every interactive kit control uses it; spread it into a
|
|
6
|
+
* custom control's `className` so keyboard focus looks the same everywhere.
|
|
7
|
+
* (`theme.css` also gives every element without its own ring an opaque
|
|
8
|
+
* `:focus-visible` outline in the same colour.)
|
|
9
|
+
*
|
|
10
|
+
* The ring is a box-shadow, which forced-colors mode (Windows High Contrast)
|
|
11
|
+
* drops. `outline-hidden` — never `outline-none` — hides the outline only
|
|
12
|
+
* outside that mode and keeps a transparent 2px outline in it, which the
|
|
13
|
+
* browser paints in the system colour, so focus stays visible there too.
|
|
14
|
+
*/
|
|
15
|
+
export declare const FOCUS_RING = "outline-hidden focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-background";
|
|
16
|
+
/** {@link FOCUS_RING} drawn inside the element — for cells and rows flush with a container edge. */
|
|
17
|
+
export declare const FOCUS_RING_INSET = "outline-hidden focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-inset";
|
|
18
|
+
//# sourceMappingURL=focus-ring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-ring.d.ts","sourceRoot":"","sources":["../../src/lib/focus-ring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,kIAC0G,CAAA;AAEjI,oGAAoG;AACpG,eAAO,MAAM,gBAAgB,0FAC4D,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The toolkit's focus indicator as Tailwind classes: an opaque 2px ring in the
|
|
3
|
+
* `--focus` role (blau-link on light, blau-hell on dark — 3:1 or more against
|
|
4
|
+
* every surface, see `theme/theme-css.test.ts`), offset from the control so it
|
|
5
|
+
* reads on any fill. Every interactive kit control uses it; spread it into a
|
|
6
|
+
* custom control's `className` so keyboard focus looks the same everywhere.
|
|
7
|
+
* (`theme.css` also gives every element without its own ring an opaque
|
|
8
|
+
* `:focus-visible` outline in the same colour.)
|
|
9
|
+
*
|
|
10
|
+
* The ring is a box-shadow, which forced-colors mode (Windows High Contrast)
|
|
11
|
+
* drops. `outline-hidden` — never `outline-none` — hides the outline only
|
|
12
|
+
* outside that mode and keeps a transparent 2px outline in it, which the
|
|
13
|
+
* browser paints in the system colour, so focus stays visible there too.
|
|
14
|
+
*/
|
|
15
|
+
export const FOCUS_RING = "outline-hidden focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-background";
|
|
16
|
+
/** {@link FOCUS_RING} drawn inside the element — for cells and rows flush with a container edge. */
|
|
17
|
+
export const FOCUS_RING_INSET = "outline-hidden focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-inset";
|
|
18
|
+
//# sourceMappingURL=focus-ring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-ring.js","sourceRoot":"","sources":["../../src/lib/focus-ring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,UAAU,GACrB,+HAA+H,CAAA;AAEjI,oGAAoG;AACpG,MAAM,CAAC,MAAM,gBAAgB,GAC3B,uFAAuF,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lucide stroke widths of the toolkit's chrome (CI §11, on the 24 px grid).
|
|
3
|
+
* Set once through `LucideProvider`: `McpAppView` applies {@link ICON_STROKE}
|
|
4
|
+
* to everything it renders (its toast stack included), dense bars narrow it
|
|
5
|
+
* to {@link DENSE_ICON_STROKE}. Icons of a consumer's own `lucide-react` follow
|
|
6
|
+
* the provider only when they resolve to the same module instance (dedupe it).
|
|
7
|
+
*/
|
|
8
|
+
/** Default stroke of the toolkit's icons. */
|
|
9
|
+
export declare const ICON_STROKE = 2.5;
|
|
10
|
+
/** Stroke in dense chrome bars (the view toolbar, the builder's bars). */
|
|
11
|
+
export declare const DENSE_ICON_STROKE = 2;
|
|
12
|
+
//# sourceMappingURL=icon-stroke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-stroke.d.ts","sourceRoot":"","sources":["../../src/lib/icon-stroke.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,6CAA6C;AAC7C,eAAO,MAAM,WAAW,MAAM,CAAA;AAE9B,0EAA0E;AAC1E,eAAO,MAAM,iBAAiB,IAAI,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lucide stroke widths of the toolkit's chrome (CI §11, on the 24 px grid).
|
|
3
|
+
* Set once through `LucideProvider`: `McpAppView` applies {@link ICON_STROKE}
|
|
4
|
+
* to everything it renders (its toast stack included), dense bars narrow it
|
|
5
|
+
* to {@link DENSE_ICON_STROKE}. Icons of a consumer's own `lucide-react` follow
|
|
6
|
+
* the provider only when they resolve to the same module instance (dedupe it).
|
|
7
|
+
*/
|
|
8
|
+
/** Default stroke of the toolkit's icons. */
|
|
9
|
+
export const ICON_STROKE = 2.5;
|
|
10
|
+
/** Stroke in dense chrome bars (the view toolbar, the builder's bars). */
|
|
11
|
+
export const DENSE_ICON_STROKE = 2;
|
|
12
|
+
//# sourceMappingURL=icon-stroke.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-stroke.js","sourceRoot":"","sources":["../../src/lib/icon-stroke.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,6CAA6C;AAC7C,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAA;AAE9B,0EAA0E;AAC1E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure model behind `ToastProvider` / `useToast`: the toast list as a reducer
|
|
3
|
+
* plus the timing rules, so both are testable without a DOM (the house path,
|
|
4
|
+
* FITNESS.md) and the component stays a thin view over them.
|
|
5
|
+
*/
|
|
6
|
+
/** Status tone of a toast — the four status roles (`--success` … `--info`). */
|
|
7
|
+
export type ToastTone = "success" | "warning" | "danger" | "info";
|
|
8
|
+
/** What a caller passes to `useToast().show(...)`. */
|
|
9
|
+
export interface ToastOptions {
|
|
10
|
+
/** Status tone; drives the edge, the icon and the default duration. Default `"info"`. */
|
|
11
|
+
tone?: ToastTone;
|
|
12
|
+
/** The message. Say what happened, in one short sentence ("Job retried."). */
|
|
13
|
+
title: string;
|
|
14
|
+
/** Optional second line (what you can do next, or the affected object). */
|
|
15
|
+
description?: string;
|
|
16
|
+
/** Auto-dismiss after this many ms. Defaults per {@link toastDuration}. */
|
|
17
|
+
duration?: number;
|
|
18
|
+
}
|
|
19
|
+
/** A toast as it sits in the list. */
|
|
20
|
+
export interface ToastItem {
|
|
21
|
+
id: number;
|
|
22
|
+
tone: ToastTone;
|
|
23
|
+
title: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
duration: number;
|
|
26
|
+
}
|
|
27
|
+
/** Default lifetime of a toast (CI §8: about 2.8 s). */
|
|
28
|
+
export declare const TOAST_DURATION_MS = 2800;
|
|
29
|
+
/** Lifetime of an error toast (CI §8: about 5 s) — long enough to read the reason. */
|
|
30
|
+
export declare const TOAST_ERROR_DURATION_MS = 5000;
|
|
31
|
+
/** At most this many toasts stack; the oldest leaves first. */
|
|
32
|
+
export declare const MAX_VISIBLE_TOASTS = 3;
|
|
33
|
+
/** The lifetime of a toast: an explicit positive duration, else the tone's default. */
|
|
34
|
+
export declare function toastDuration(tone: ToastTone, explicit?: number): number;
|
|
35
|
+
/** Normalise caller options into a list item. */
|
|
36
|
+
export declare function createToast(id: number, options: ToastOptions): ToastItem;
|
|
37
|
+
export type ToastAction = {
|
|
38
|
+
type: "add";
|
|
39
|
+
toast: ToastItem;
|
|
40
|
+
} | {
|
|
41
|
+
type: "dismiss";
|
|
42
|
+
id: number;
|
|
43
|
+
};
|
|
44
|
+
/** Add appends (dropping the oldest beyond {@link MAX_VISIBLE_TOASTS}); dismiss removes by id. */
|
|
45
|
+
export declare function toastReducer(state: readonly ToastItem[], action: ToastAction): ToastItem[];
|
|
46
|
+
//# sourceMappingURL=toast-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast-model.d.ts","sourceRoot":"","sources":["../../src/lib/toast-model.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+EAA+E;AAC/E,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAA;AAEjE,sDAAsD;AACtD,MAAM,WAAW,YAAY;IAC3B,yFAAyF;IACzF,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAA;IACb,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,sCAAsC;AACtC,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,SAAS,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,wDAAwD;AACxD,eAAO,MAAM,iBAAiB,OAAO,CAAA;AACrC,sFAAsF;AACtF,eAAO,MAAM,uBAAuB,OAAO,CAAA;AAC3C,+DAA+D;AAC/D,eAAO,MAAM,kBAAkB,IAAI,CAAA;AAEnC,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAGxE;AAED,iDAAiD;AACjD,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,SAAS,CASxE;AAED,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAE7F,kGAAkG;AAClG,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,EAAE,CAI1F"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure model behind `ToastProvider` / `useToast`: the toast list as a reducer
|
|
3
|
+
* plus the timing rules, so both are testable without a DOM (the house path,
|
|
4
|
+
* FITNESS.md) and the component stays a thin view over them.
|
|
5
|
+
*/
|
|
6
|
+
/** Default lifetime of a toast (CI §8: about 2.8 s). */
|
|
7
|
+
export const TOAST_DURATION_MS = 2800;
|
|
8
|
+
/** Lifetime of an error toast (CI §8: about 5 s) — long enough to read the reason. */
|
|
9
|
+
export const TOAST_ERROR_DURATION_MS = 5000;
|
|
10
|
+
/** At most this many toasts stack; the oldest leaves first. */
|
|
11
|
+
export const MAX_VISIBLE_TOASTS = 3;
|
|
12
|
+
/** The lifetime of a toast: an explicit positive duration, else the tone's default. */
|
|
13
|
+
export function toastDuration(tone, explicit) {
|
|
14
|
+
if (explicit !== undefined && Number.isFinite(explicit) && explicit > 0)
|
|
15
|
+
return explicit;
|
|
16
|
+
return tone === "danger" ? TOAST_ERROR_DURATION_MS : TOAST_DURATION_MS;
|
|
17
|
+
}
|
|
18
|
+
/** Normalise caller options into a list item. */
|
|
19
|
+
export function createToast(id, options) {
|
|
20
|
+
const tone = options.tone ?? "info";
|
|
21
|
+
return {
|
|
22
|
+
id,
|
|
23
|
+
tone,
|
|
24
|
+
title: options.title,
|
|
25
|
+
...(options.description ? { description: options.description } : {}),
|
|
26
|
+
duration: toastDuration(tone, options.duration),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** Add appends (dropping the oldest beyond {@link MAX_VISIBLE_TOASTS}); dismiss removes by id. */
|
|
30
|
+
export function toastReducer(state, action) {
|
|
31
|
+
if (action.type === "add")
|
|
32
|
+
return [...state, action.toast].slice(-MAX_VISIBLE_TOASTS);
|
|
33
|
+
const next = state.filter((t) => t.id !== action.id);
|
|
34
|
+
return next.length === state.length ? state : next;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=toast-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast-model.js","sourceRoot":"","sources":["../../src/lib/toast-model.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA0BH,wDAAwD;AACxD,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAA;AACrC,sFAAsF;AACtF,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAA;AAC3C,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAEnC,uFAAuF;AACvF,MAAM,UAAU,aAAa,CAAC,IAAe,EAAE,QAAiB;IAC9D,IAAI,QAAQ,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAA;IACxF,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,iBAAiB,CAAA;AACxE,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,WAAW,CAAC,EAAU,EAAE,OAAqB;IAC3D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAAA;IACnC,OAAO;QACL,EAAE;QACF,IAAI;QACJ,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,QAAQ,EAAE,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC;KAChD,CAAA;AACH,CAAC;AAID,kGAAkG;AAClG,MAAM,UAAU,YAAY,CAAC,KAA2B,EAAE,MAAmB;IAC3E,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK;QAAE,OAAO,CAAC,GAAG,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC,CAAA;IACrF,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,CAAA;IACpD,OAAO,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC,CAAE,KAAqB,CAAC,CAAC,CAAC,IAAI,CAAA;AACrE,CAAC"}
|
package/dist/lib/tone-utils.d.ts
CHANGED
|
@@ -1,18 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Single source of truth for the semantic "tones" used across the tone-aware
|
|
3
|
-
* components (`Pills`, `KpiGrid`, `WidgetHeader`, …).
|
|
3
|
+
* components (`Pills`, `KpiGrid`, `WidgetHeader`, `Badge`, …).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* Every status tone has THREE roles (Miragon CI §3.3), each its own token in
|
|
6
|
+
* `theme.css` with light and dark values:
|
|
7
|
+
*
|
|
8
|
+
* | Role | Token | Map |
|
|
9
|
+
* | ---------------------------- | --------------- | -------------- |
|
|
10
|
+
* | fill, dot, border, icon | `--<tone>` | `TONE_DOT`, `TONE_BORDER`, `TONE_ICON` |
|
|
11
|
+
* | tint (badge/banner surface) | `--<tone>-soft` | `TONE_SOFT` (text on it: the foreground) |
|
|
12
|
+
* | text on a plain surface | `--<tone>-ink` | `TONE_TEXT` |
|
|
13
|
+
*
|
|
14
|
+
* Status is never text in its own colour: success and warning reach only
|
|
15
|
+
* 1.67:1 / 1.83:1 on white, so their ink is the foreground and the tone shows
|
|
16
|
+
* as a dot, icon or border NEXT to the text. On a tint the text is always the
|
|
17
|
+
* foreground (CI §3.3: "-soft: Text darauf --cd-schwarz, Rand in der
|
|
18
|
+
* Statusfarbe"), so pair `TONE_SOFT` with `TONE_BORDER`. `TONE_TEXT` is for
|
|
19
|
+
* a tone's words on a plain surface (a field error); figures — counts, KPI
|
|
20
|
+
* values, trends — never take it: they stay in the foreground next to a
|
|
21
|
+
* `TONE_DOT`. In dark mode the colours are the `-hell` values and the tints
|
|
22
|
+
* are transparent (no tinted fills on dark). The `neutral` tone reuses the
|
|
23
|
+
* muted ramp.
|
|
24
|
+
*
|
|
25
|
+
* Change a tone here, in one place, instead of hand-rolling
|
|
26
|
+
* `tone === "x" ? "…" : "…"` ternaries at every call site.
|
|
10
27
|
*/
|
|
11
28
|
export type ToneVariant = "neutral" | "info" | "success" | "warning" | "danger";
|
|
12
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Tinted surface + its text (the foreground: CI §3.3) — badges, pills,
|
|
31
|
+
* banners. Pair it with {@link TONE_BORDER}: the rim carries the tone, and in
|
|
32
|
+
* dark mode (no tints) it is all that does.
|
|
33
|
+
*/
|
|
13
34
|
export declare const TONE_SOFT: Record<ToneVariant, string>;
|
|
14
|
-
/** Solid dot
|
|
35
|
+
/** Solid dot colour — a status dot next to a label. */
|
|
15
36
|
export declare const TONE_DOT: Record<ToneVariant, string>;
|
|
16
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* The tone's TEXT colour (its `-ink` role) for words on a plain surface — a
|
|
39
|
+
* field error, a "missing" label. Success and warning resolve to the
|
|
40
|
+
* foreground on light: pair the text with a {@link TONE_DOT} or
|
|
41
|
+
* {@link TONE_ICON} to show the tone. Never on a tint (use {@link TONE_SOFT})
|
|
42
|
+
* and never for figures (they stay in the foreground next to a dot).
|
|
43
|
+
*/
|
|
17
44
|
export declare const TONE_TEXT: Record<ToneVariant, string>;
|
|
45
|
+
/** Border colour in the tone — the rim of a tinted badge, banner or toast. */
|
|
46
|
+
export declare const TONE_BORDER: Record<ToneVariant, string>;
|
|
47
|
+
/**
|
|
48
|
+
* Icon colour in the tone (SVG `currentColor`). For icons only — never for
|
|
49
|
+
* text: an icon next to its label carries the tone, the label stays readable.
|
|
50
|
+
*/
|
|
51
|
+
export declare const TONE_ICON: Record<ToneVariant, string>;
|
|
18
52
|
//# sourceMappingURL=tone-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tone-utils.d.ts","sourceRoot":"","sources":["../../src/lib/tone-utils.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tone-utils.d.ts","sourceRoot":"","sources":["../../src/lib/tone-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAA;AAE/E;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAMjD,CAAA;AAED,uDAAuD;AACvD,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAMhD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAMjD,CAAA;AAED,8EAA8E;AAC9E,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAMnD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAMjD,CAAA"}
|
package/dist/lib/tone-utils.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Tinted surface + its text (the foreground: CI §3.3) — badges, pills,
|
|
3
|
+
* banners. Pair it with {@link TONE_BORDER}: the rim carries the tone, and in
|
|
4
|
+
* dark mode (no tints) it is all that does.
|
|
5
|
+
*/
|
|
2
6
|
export const TONE_SOFT = {
|
|
3
7
|
neutral: "bg-muted text-muted-foreground",
|
|
4
|
-
info: "bg-info-soft text-
|
|
5
|
-
success: "bg-success-soft text-
|
|
6
|
-
warning: "bg-warning-soft text-
|
|
7
|
-
danger: "bg-danger-soft text-
|
|
8
|
+
info: "bg-info-soft text-foreground",
|
|
9
|
+
success: "bg-success-soft text-foreground",
|
|
10
|
+
warning: "bg-warning-soft text-foreground",
|
|
11
|
+
danger: "bg-danger-soft text-foreground",
|
|
8
12
|
};
|
|
9
|
-
/** Solid dot
|
|
13
|
+
/** Solid dot colour — a status dot next to a label. */
|
|
10
14
|
export const TONE_DOT = {
|
|
11
15
|
neutral: "bg-muted-foreground",
|
|
12
16
|
info: "bg-info",
|
|
@@ -14,9 +18,34 @@ export const TONE_DOT = {
|
|
|
14
18
|
warning: "bg-warning",
|
|
15
19
|
danger: "bg-danger",
|
|
16
20
|
};
|
|
17
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* The tone's TEXT colour (its `-ink` role) for words on a plain surface — a
|
|
23
|
+
* field error, a "missing" label. Success and warning resolve to the
|
|
24
|
+
* foreground on light: pair the text with a {@link TONE_DOT} or
|
|
25
|
+
* {@link TONE_ICON} to show the tone. Never on a tint (use {@link TONE_SOFT})
|
|
26
|
+
* and never for figures (they stay in the foreground next to a dot).
|
|
27
|
+
*/
|
|
18
28
|
export const TONE_TEXT = {
|
|
19
29
|
neutral: "text-foreground",
|
|
30
|
+
info: "text-info-ink",
|
|
31
|
+
success: "text-success-ink",
|
|
32
|
+
warning: "text-warning-ink",
|
|
33
|
+
danger: "text-danger-ink",
|
|
34
|
+
};
|
|
35
|
+
/** Border colour in the tone — the rim of a tinted badge, banner or toast. */
|
|
36
|
+
export const TONE_BORDER = {
|
|
37
|
+
neutral: "border-border",
|
|
38
|
+
info: "border-info",
|
|
39
|
+
success: "border-success",
|
|
40
|
+
warning: "border-warning",
|
|
41
|
+
danger: "border-danger",
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Icon colour in the tone (SVG `currentColor`). For icons only — never for
|
|
45
|
+
* text: an icon next to its label carries the tone, the label stays readable.
|
|
46
|
+
*/
|
|
47
|
+
export const TONE_ICON = {
|
|
48
|
+
neutral: "text-muted-foreground",
|
|
20
49
|
info: "text-info",
|
|
21
50
|
success: "text-success",
|
|
22
51
|
warning: "text-warning",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tone-utils.js","sourceRoot":"","sources":["../../src/lib/tone-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tone-utils.js","sourceRoot":"","sources":["../../src/lib/tone-utils.ts"],"names":[],"mappings":"AA6BA;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAgC;IACpD,OAAO,EAAE,gCAAgC;IACzC,IAAI,EAAE,8BAA8B;IACpC,OAAO,EAAE,iCAAiC;IAC1C,OAAO,EAAE,iCAAiC;IAC1C,MAAM,EAAE,gCAAgC;CACzC,CAAA;AAED,uDAAuD;AACvD,MAAM,CAAC,MAAM,QAAQ,GAAgC;IACnD,OAAO,EAAE,qBAAqB;IAC9B,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,WAAW;CACpB,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAgC;IACpD,OAAO,EAAE,iBAAiB;IAC1B,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,kBAAkB;IAC3B,MAAM,EAAE,iBAAiB;CAC1B,CAAA;AAED,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAgC;IACtD,OAAO,EAAE,eAAe;IACxB,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,gBAAgB;IACzB,OAAO,EAAE,gBAAgB;IACzB,MAAM,EAAE,eAAe;CACxB,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAgC;IACpD,OAAO,EAAE,uBAAuB;IAChC,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;CACtB,CAAA"}
|
package/dist/locale/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export { LocaleProvider, useLocale, useTranslate } from "./locale-provider.js";
|
|
1
|
+
export { LocaleProvider, useLocale, useTranslate, useToolkitMessages } from "./locale-provider.js";
|
|
2
2
|
export type { LocaleContextValue, LocaleProviderProps, BoundTranslate } from "./locale-provider.js";
|
|
3
|
+
export { TOOLKIT_MESSAGES, formatCount, resolveToolkitMessages } from "./toolkit-messages.js";
|
|
4
|
+
export type { BuilderMessages, CommonMessages, ListFooterMessages, PropsSheetMessages, RendererMessages, ToolkitLocale, ToolkitMessages, ToolkitMessagesOverride, ViewMessages, } from "./toolkit-messages.js";
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/locale/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/locale/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAClG,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACnG,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC7F,YAAY,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,YAAY,GACb,MAAM,uBAAuB,CAAA"}
|
package/dist/locale/index.js
CHANGED
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
// <LocaleProvider> and reads the active locale with useLocale/useTranslate,
|
|
4
4
|
// without pulling in the host runtime. Pairs with `createTranslator` from
|
|
5
5
|
// `@miragon/mcp-toolkit-core`.
|
|
6
|
-
export { LocaleProvider, useLocale, useTranslate } from "./locale-provider.js";
|
|
6
|
+
export { LocaleProvider, useLocale, useTranslate, useToolkitMessages } from "./locale-provider.js";
|
|
7
|
+
export { TOOLKIT_MESSAGES, formatCount, resolveToolkitMessages } from "./toolkit-messages.js";
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/dist/locale/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/locale/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,yEAAyE;AACzE,4EAA4E;AAC5E,0EAA0E;AAC1E,+BAA+B;AAC/B,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/locale/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,yEAAyE;AACzE,4EAA4E;AAC5E,0EAA0E;AAC1E,+BAA+B;AAC/B,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAElG,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { Translate } from "@miragon/mcp-toolkit-core";
|
|
3
|
+
import { type ToolkitMessages, type ToolkitMessagesOverride } from "./toolkit-messages.js";
|
|
3
4
|
/**
|
|
4
5
|
* A locale-bound translate: the active locale is already applied, so call sites
|
|
5
6
|
* only pass a key (+ params). Obtained from {@link useTranslate}.
|
|
@@ -11,6 +12,14 @@ export interface LocaleContextValue {
|
|
|
11
12
|
locale: string;
|
|
12
13
|
/** Translate a key in the active locale. */
|
|
13
14
|
t: BoundTranslate;
|
|
15
|
+
/**
|
|
16
|
+
* The toolkit's own strings for the active locale (its shipped `en`/`de`
|
|
17
|
+
* catalog, English for any other locale) with the provider's
|
|
18
|
+
* `toolkitMessages` override applied. Read it with {@link useToolkitMessages}.
|
|
19
|
+
* Optional on the type (a hand-built value may omit it); `LocaleProvider`
|
|
20
|
+
* always sets it.
|
|
21
|
+
*/
|
|
22
|
+
messages?: ToolkitMessages;
|
|
14
23
|
}
|
|
15
24
|
/** Read the active locale tag from the nearest {@link LocaleProvider}. */
|
|
16
25
|
export declare function useLocale(): string;
|
|
@@ -20,6 +29,32 @@ export declare function useLocale(): string;
|
|
|
20
29
|
* render their keys instead of throwing.
|
|
21
30
|
*/
|
|
22
31
|
export declare function useTranslate(): BoundTranslate;
|
|
32
|
+
/**
|
|
33
|
+
* The toolkit's own UI strings for the nearest {@link LocaleProvider}'s locale
|
|
34
|
+
* (English outside a provider). Every toolkit component reads its captions,
|
|
35
|
+
* labels and accessible names here, so a German locale renders no English
|
|
36
|
+
* toolkit chrome.
|
|
37
|
+
*/
|
|
38
|
+
export declare function useToolkitMessages(): ToolkitMessages;
|
|
39
|
+
/**
|
|
40
|
+
* The locale the toolkit's own text is in: the nearest {@link LocaleProvider}'s,
|
|
41
|
+
* else a {@link ToolkitLocaleFallback}'s (the host's, inside `McpAppView`),
|
|
42
|
+
* else `"en"`. Toolkit components format their numbers with it, so a count
|
|
43
|
+
* always matches the language of the sentence around it. Internal: consumer
|
|
44
|
+
* widgets read {@link useLocale}.
|
|
45
|
+
*/
|
|
46
|
+
export declare function useToolkitLocale(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Binds ONLY the toolkit's own strings and number format to `locale` for a
|
|
49
|
+
* subtree — the fallback `McpAppView` mounts with the host's locale. It is not
|
|
50
|
+
* a {@link LocaleProvider}: {@link useLocale} and {@link useTranslate} keep
|
|
51
|
+
* their outside-a-provider behaviour (`"en"`, echoed keys) for consumer
|
|
52
|
+
* widgets, and any `LocaleProvider` above or below wins over it.
|
|
53
|
+
*/
|
|
54
|
+
export declare function ToolkitLocaleFallback({ locale, children, }: {
|
|
55
|
+
locale: string;
|
|
56
|
+
children: ReactNode;
|
|
57
|
+
}): ReactNode;
|
|
23
58
|
export interface LocaleProviderProps {
|
|
24
59
|
/** The active locale tag (e.g. `"en"`, `"de"`). */
|
|
25
60
|
locale: string;
|
|
@@ -29,6 +64,12 @@ export interface LocaleProviderProps {
|
|
|
29
64
|
* consumer wires the locale before any catalog exists.
|
|
30
65
|
*/
|
|
31
66
|
translator?: Translate;
|
|
67
|
+
/**
|
|
68
|
+
* Override individual toolkit strings for this subtree, per catalog section
|
|
69
|
+
* (e.g. `{ listFooter: { loadMore: "Show more" } }`). Omitted entries keep the
|
|
70
|
+
* shipped `en`/`de` catalog of `locale`.
|
|
71
|
+
*/
|
|
72
|
+
toolkitMessages?: ToolkitMessagesOverride;
|
|
32
73
|
children: ReactNode;
|
|
33
74
|
}
|
|
34
75
|
/**
|
|
@@ -46,5 +87,5 @@ export interface LocaleProviderProps {
|
|
|
46
87
|
* <YourWidget />
|
|
47
88
|
* </LocaleProvider>
|
|
48
89
|
*/
|
|
49
|
-
export declare function LocaleProvider({ locale, translator, children }: LocaleProviderProps): ReactNode;
|
|
90
|
+
export declare function LocaleProvider({ locale, translator, toolkitMessages, children, }: LocaleProviderProps): ReactNode;
|
|
50
91
|
//# sourceMappingURL=locale-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale-provider.d.ts","sourceRoot":"","sources":["../../src/locale/locale-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"locale-provider.d.ts","sourceRoot":"","sources":["../../src/locale/locale-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAA;AAE9B;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAA;AAEtF,qEAAqE;AACrE,MAAM,WAAW,kBAAkB;IACjC,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAA;IACd,4CAA4C;IAC5C,CAAC,EAAE,cAAc,CAAA;IACjB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAA;CAC3B;AA2BD,0EAA0E;AAC1E,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,cAAc,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CAIpD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAIzC;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,MAAM,EACN,QAAQ,GACT,EAAE;IACD,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,SAAS,CAAA;CACpB,GAAG,SAAS,CAUZ;AAED,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB;;;;OAIG;IACH,eAAe,CAAC,EAAE,uBAAuB,CAAA;IACzC,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,UAAU,EACV,eAAe,EACf,QAAQ,GACT,EAAE,mBAAmB,GAAG,SAAS,CAUjC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useContext, useMemo } from "react";
|
|
3
|
+
import { resolveToolkitMessages, } from "./toolkit-messages.js";
|
|
3
4
|
const DEFAULT_LOCALE = "en";
|
|
4
5
|
/**
|
|
5
6
|
* Default used when a widget renders *outside* a {@link LocaleProvider} (e.g. a
|
|
@@ -8,8 +9,13 @@ const DEFAULT_LOCALE = "en";
|
|
|
8
9
|
* missing wrapper echoes the key (visible + greppable) instead of crashing a
|
|
9
10
|
* widget that is perfectly renderable in English.
|
|
10
11
|
*/
|
|
11
|
-
const DEFAULT_VALUE = {
|
|
12
|
+
const DEFAULT_VALUE = {
|
|
13
|
+
locale: DEFAULT_LOCALE,
|
|
14
|
+
t: (key) => key,
|
|
15
|
+
messages: resolveToolkitMessages(DEFAULT_LOCALE),
|
|
16
|
+
};
|
|
12
17
|
const LocaleContext = createContext(null);
|
|
18
|
+
const ToolkitLocaleFallbackContext = createContext(null);
|
|
13
19
|
/** Read the active locale tag from the nearest {@link LocaleProvider}. */
|
|
14
20
|
export function useLocale() {
|
|
15
21
|
return useContext(LocaleContext)?.locale ?? DEFAULT_VALUE.locale;
|
|
@@ -22,6 +28,40 @@ export function useLocale() {
|
|
|
22
28
|
export function useTranslate() {
|
|
23
29
|
return useContext(LocaleContext)?.t ?? DEFAULT_VALUE.t;
|
|
24
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* The toolkit's own UI strings for the nearest {@link LocaleProvider}'s locale
|
|
33
|
+
* (English outside a provider). Every toolkit component reads its captions,
|
|
34
|
+
* labels and accessible names here, so a German locale renders no English
|
|
35
|
+
* toolkit chrome.
|
|
36
|
+
*/
|
|
37
|
+
export function useToolkitMessages() {
|
|
38
|
+
const provided = useContext(LocaleContext);
|
|
39
|
+
const fallback = useContext(ToolkitLocaleFallbackContext);
|
|
40
|
+
return provided?.messages ?? fallback?.messages ?? DEFAULT_VALUE.messages;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The locale the toolkit's own text is in: the nearest {@link LocaleProvider}'s,
|
|
44
|
+
* else a {@link ToolkitLocaleFallback}'s (the host's, inside `McpAppView`),
|
|
45
|
+
* else `"en"`. Toolkit components format their numbers with it, so a count
|
|
46
|
+
* always matches the language of the sentence around it. Internal: consumer
|
|
47
|
+
* widgets read {@link useLocale}.
|
|
48
|
+
*/
|
|
49
|
+
export function useToolkitLocale() {
|
|
50
|
+
const provided = useContext(LocaleContext);
|
|
51
|
+
const fallback = useContext(ToolkitLocaleFallbackContext);
|
|
52
|
+
return provided?.locale ?? fallback?.locale ?? DEFAULT_VALUE.locale;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Binds ONLY the toolkit's own strings and number format to `locale` for a
|
|
56
|
+
* subtree — the fallback `McpAppView` mounts with the host's locale. It is not
|
|
57
|
+
* a {@link LocaleProvider}: {@link useLocale} and {@link useTranslate} keep
|
|
58
|
+
* their outside-a-provider behaviour (`"en"`, echoed keys) for consumer
|
|
59
|
+
* widgets, and any `LocaleProvider` above or below wins over it.
|
|
60
|
+
*/
|
|
61
|
+
export function ToolkitLocaleFallback({ locale, children, }) {
|
|
62
|
+
const value = useMemo(() => ({ locale, messages: resolveToolkitMessages(locale) }), [locale]);
|
|
63
|
+
return (_jsx(ToolkitLocaleFallbackContext.Provider, { value: value, children: children }));
|
|
64
|
+
}
|
|
25
65
|
/**
|
|
26
66
|
* Provide the active locale (and an optional translator) to a subtree. Widgets
|
|
27
67
|
* read it with {@link useLocale} / {@link useTranslate}. Pure React (no
|
|
@@ -37,11 +77,12 @@ export function useTranslate() {
|
|
|
37
77
|
* <YourWidget />
|
|
38
78
|
* </LocaleProvider>
|
|
39
79
|
*/
|
|
40
|
-
export function LocaleProvider({ locale, translator, children }) {
|
|
80
|
+
export function LocaleProvider({ locale, translator, toolkitMessages, children, }) {
|
|
41
81
|
const value = useMemo(() => ({
|
|
42
82
|
locale,
|
|
43
83
|
t: translator ? (key, params) => translator(locale, key, params) : (key) => key,
|
|
44
|
-
|
|
84
|
+
messages: resolveToolkitMessages(locale, toolkitMessages),
|
|
85
|
+
}), [locale, translator, toolkitMessages]);
|
|
45
86
|
return _jsx(LocaleContext.Provider, { value: value, children: children });
|
|
46
87
|
}
|
|
47
88
|
//# sourceMappingURL=locale-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale-provider.js","sourceRoot":"","sources":["../../src/locale/locale-provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"locale-provider.js","sourceRoot":"","sources":["../../src/locale/locale-provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,OAAO,CAAA;AAE1E,OAAO,EACL,sBAAsB,GAGvB,MAAM,uBAAuB,CAAA;AAwB9B,MAAM,cAAc,GAAG,IAAI,CAAA;AAE3B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