@zonsh/ui 0.0.0 → 0.4.1
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/LICENSE +43 -0
- package/README.md +81 -1
- package/assets/illustrations/drawing/bracket-construction-dark.svg +77 -0
- package/assets/illustrations/drawing/bracket-construction-filled-dark.svg +50 -0
- package/assets/illustrations/drawing/bracket-construction-filled.svg +50 -0
- package/assets/illustrations/drawing/bracket-construction.svg +77 -0
- package/assets/illustrations/drawing/crescent-dark.svg +28 -0
- package/assets/illustrations/drawing/crescent-guides-dark.svg +33 -0
- package/assets/illustrations/drawing/crescent-guides.svg +33 -0
- package/assets/illustrations/drawing/crescent.svg +28 -0
- package/assets/illustrations/drawing/eclipse-dark.svg +187 -0
- package/assets/illustrations/drawing/eclipse-guides-dark.svg +191 -0
- package/assets/illustrations/drawing/eclipse-guides.svg +191 -0
- package/assets/illustrations/drawing/eclipse.svg +187 -0
- package/assets/illustrations/drawing/elevation-guides-dark.svg +31 -0
- package/assets/illustrations/drawing/elevation-guides-plain-dark.svg +9 -0
- package/assets/illustrations/drawing/elevation-guides-plain.svg +9 -0
- package/assets/illustrations/drawing/elevation-guides.svg +31 -0
- package/assets/illustrations/drawing/horizon-dark.svg +30 -0
- package/assets/illustrations/drawing/horizon.svg +30 -0
- package/assets/illustrations/drawing/nib-study-dark.svg +107 -0
- package/assets/illustrations/drawing/nib-study-plain-dark.svg +93 -0
- package/assets/illustrations/drawing/nib-study-plain.svg +93 -0
- package/assets/illustrations/drawing/nib-study.svg +107 -0
- package/assets/illustrations/editorial/assistant-640.webp +0 -0
- package/assets/illustrations/editorial/assistant.webp +0 -0
- package/assets/illustrations/editorial/automation-640.webp +0 -0
- package/assets/illustrations/editorial/automation.webp +0 -0
- package/assets/illustrations/editorial/bracket-left-640.webp +0 -0
- package/assets/illustrations/editorial/bracket-left.webp +0 -0
- package/assets/illustrations/editorial/bracket-right-640.webp +0 -0
- package/assets/illustrations/editorial/bracket-right.webp +0 -0
- package/assets/illustrations/editorial/custom-software-640.webp +0 -0
- package/assets/illustrations/editorial/custom-software.webp +0 -0
- package/assets/illustrations/editorial/digitalization-640.webp +0 -0
- package/assets/illustrations/editorial/digitalization.webp +0 -0
- package/assets/illustrations/editorial/integration-640.webp +0 -0
- package/assets/illustrations/editorial/integration.webp +0 -0
- package/assets/illustrations/editorial/problem-640.webp +0 -0
- package/assets/illustrations/editorial/problem.webp +0 -0
- package/assets/illustrations/editorial/process-analysis-640.webp +0 -0
- package/assets/illustrations/editorial/process-analysis.webp +0 -0
- package/assets/illustrations/editorial/process-concept-640.webp +0 -0
- package/assets/illustrations/editorial/process-concept.webp +0 -0
- package/assets/illustrations/editorial/process-development-640.webp +0 -0
- package/assets/illustrations/editorial/process-development.webp +0 -0
- package/assets/illustrations/editorial/process-discovery-640.webp +0 -0
- package/assets/illustrations/editorial/process-discovery.webp +0 -0
- package/assets/illustrations/editorial/process-maintenance-640.webp +0 -0
- package/assets/illustrations/editorial/process-maintenance.webp +0 -0
- package/assets/illustrations/editorial/process-prototype-640.webp +0 -0
- package/assets/illustrations/editorial/process-prototype.webp +0 -0
- package/assets/illustrations/editorial/process-testing-640.webp +0 -0
- package/assets/illustrations/editorial/process-testing.webp +0 -0
- package/assets/illustrations/iso/automation-dark.svg +6 -0
- package/assets/illustrations/iso/automation.svg +6 -0
- package/assets/illustrations/iso/bar-chart-dark.svg +6 -0
- package/assets/illustrations/iso/bar-chart.svg +6 -0
- package/assets/illustrations/iso/brackets-classic-dark.svg +6 -0
- package/assets/illustrations/iso/brackets-classic.svg +6 -0
- package/assets/illustrations/iso/brackets-dark.svg +6 -0
- package/assets/illustrations/iso/brackets.svg +6 -0
- package/assets/illustrations/iso/city-dark.svg +6 -0
- package/assets/illustrations/iso/city.svg +6 -0
- package/assets/illustrations/iso/conveyor-dark.svg +6 -0
- package/assets/illustrations/iso/conveyor.svg +6 -0
- package/assets/illustrations/iso/database-dark.svg +6 -0
- package/assets/illustrations/iso/database.svg +6 -0
- package/assets/illustrations/iso/documents-dark.svg +6 -0
- package/assets/illustrations/iso/documents.svg +6 -0
- package/assets/illustrations/iso/inbox-dark.svg +6 -0
- package/assets/illustrations/iso/inbox.svg +6 -0
- package/assets/illustrations/iso/laptop-dark.svg +6 -0
- package/assets/illustrations/iso/laptop.svg +6 -0
- package/assets/illustrations/iso/monitor-dark.svg +6 -0
- package/assets/illustrations/iso/monitor.svg +6 -0
- package/assets/illustrations/iso/pipeline-dark.svg +6 -0
- package/assets/illustrations/iso/pipeline.svg +6 -0
- package/assets/illustrations/iso/platform-dark.svg +6 -0
- package/assets/illustrations/iso/platform.svg +6 -0
- package/assets/illustrations/iso/server-dark.svg +6 -0
- package/assets/illustrations/iso/server.svg +6 -0
- package/assets/illustrations/iso/spreadsheet-dark.svg +6 -0
- package/assets/illustrations/iso/spreadsheet.svg +6 -0
- package/assets/illustrations/iso/timeline-dark.svg +6 -0
- package/assets/illustrations/iso/timeline.svg +6 -0
- package/assets/illustrations/sheet/construction.svg +115 -0
- package/assets/illustrations/sheet/crescent.svg +40 -0
- package/assets/illustrations/sheet/limb.svg +42 -0
- package/assets/illustrations/sheet/stress-axis.svg +119 -0
- package/assets/illustrations/sheet/totality.svg +215 -0
- package/assets/illustrations/sheet/vertical-metrics.svg +43 -0
- package/assets/logo-left.svg +1 -0
- package/assets/logo-right.svg +1 -0
- package/assets/logo.svg +1 -0
- package/dist/components/_overlay.d.ts +47 -0
- package/dist/components/_overlay.js +59 -0
- package/dist/components/accordion.d.ts +32 -0
- package/dist/components/accordion.js +39 -0
- package/dist/components/alert-dialog.d.ts +45 -0
- package/dist/components/alert-dialog.js +56 -0
- package/dist/components/alert.d.ts +35 -0
- package/dist/components/alert.js +42 -0
- package/dist/components/ascii-field.d.ts +34 -0
- package/dist/components/ascii-field.js +410 -0
- package/dist/components/aspect-ratio.d.ts +14 -0
- package/dist/components/aspect-ratio.js +17 -0
- package/dist/components/avatar.d.ts +42 -0
- package/dist/components/avatar.js +55 -0
- package/dist/components/badge.d.ts +70 -0
- package/dist/components/badge.js +62 -0
- package/dist/components/bottom-nav.d.ts +86 -0
- package/dist/components/bottom-nav.js +175 -0
- package/dist/components/breadcrumb.d.ts +31 -0
- package/dist/components/breadcrumb.js +37 -0
- package/dist/components/button-group.d.ts +30 -0
- package/dist/components/button-group.js +47 -0
- package/dist/components/button.d.ts +53 -0
- package/dist/components/button.js +130 -0
- package/dist/components/calendar.d.ts +26 -0
- package/dist/components/calendar.js +179 -0
- package/dist/components/card.d.ts +42 -0
- package/dist/components/card.js +76 -0
- package/dist/components/carousel.d.ts +109 -0
- package/dist/components/carousel.js +231 -0
- package/dist/components/chart.d.ts +189 -0
- package/dist/components/chart.js +323 -0
- package/dist/components/checkbox.d.ts +23 -0
- package/dist/components/checkbox.js +43 -0
- package/dist/components/code-block.d.ts +55 -0
- package/dist/components/code-block.js +100 -0
- package/dist/components/collapsible.d.ts +20 -0
- package/dist/components/collapsible.js +32 -0
- package/dist/components/color-picker.d.ts +107 -0
- package/dist/components/color-picker.js +428 -0
- package/dist/components/combobox.d.ts +99 -0
- package/dist/components/combobox.js +172 -0
- package/dist/components/command.d.ts +132 -0
- package/dist/components/command.js +257 -0
- package/dist/components/context-menu.d.ts +29 -0
- package/dist/components/context-menu.js +35 -0
- package/dist/components/conversation.d.ts +36 -0
- package/dist/components/conversation.js +303 -0
- package/dist/components/copy-button.d.ts +55 -0
- package/dist/components/copy-button.js +133 -0
- package/dist/components/data-table.d.ts +235 -0
- package/dist/components/data-table.js +655 -0
- package/dist/components/date-picker.d.ts +160 -0
- package/dist/components/date-picker.js +338 -0
- package/dist/components/dialog.d.ts +57 -0
- package/dist/components/dialog.js +95 -0
- package/dist/components/direction.d.ts +16 -0
- package/dist/components/direction.js +18 -0
- package/dist/components/drawer.d.ts +69 -0
- package/dist/components/drawer.js +79 -0
- package/dist/components/empty.d.ts +31 -0
- package/dist/components/empty.js +50 -0
- package/dist/components/feature-list.d.ts +54 -0
- package/dist/components/feature-list.js +43 -0
- package/dist/components/field.d.ts +34 -0
- package/dist/components/field.js +81 -0
- package/dist/components/file-drop.d.ts +77 -0
- package/dist/components/file-drop.js +258 -0
- package/dist/components/filter-bar.d.ts +153 -0
- package/dist/components/filter-bar.js +334 -0
- package/dist/components/form.d.ts +35 -0
- package/dist/components/form.js +56 -0
- package/dist/components/graph.d.ts +146 -0
- package/dist/components/graph.js +825 -0
- package/dist/components/illustration.d.ts +85 -0
- package/dist/components/illustration.js +165 -0
- package/dist/components/input-group.d.ts +138 -0
- package/dist/components/input-group.js +312 -0
- package/dist/components/input.d.ts +16 -0
- package/dist/components/input.js +25 -0
- package/dist/components/item.d.ts +64 -0
- package/dist/components/item.js +116 -0
- package/dist/components/kbd.d.ts +50 -0
- package/dist/components/kbd.js +45 -0
- package/dist/components/label.d.ts +12 -0
- package/dist/components/label.js +24 -0
- package/dist/components/layout.d.ts +136 -0
- package/dist/components/layout.js +162 -0
- package/dist/components/lightbox.d.ts +100 -0
- package/dist/components/lightbox.js +439 -0
- package/dist/components/locale.d.ts +44 -0
- package/dist/components/locale.js +37 -0
- package/dist/components/logo.d.ts +54 -0
- package/dist/components/logo.js +96 -0
- package/dist/components/menu.d.ts +60 -0
- package/dist/components/menu.js +140 -0
- package/dist/components/menubar.d.ts +62 -0
- package/dist/components/menubar.js +223 -0
- package/dist/components/message.d.ts +42 -0
- package/dist/components/message.js +59 -0
- package/dist/components/meter.d.ts +31 -0
- package/dist/components/meter.js +27 -0
- package/dist/components/money-input.d.ts +80 -0
- package/dist/components/money-input.js +253 -0
- package/dist/components/native-select.d.ts +26 -0
- package/dist/components/native-select.js +35 -0
- package/dist/components/navigation-menu.d.ts +42 -0
- package/dist/components/navigation-menu.js +97 -0
- package/dist/components/number-field.d.ts +55 -0
- package/dist/components/number-field.js +164 -0
- package/dist/components/otp-field.d.ts +48 -0
- package/dist/components/otp-field.js +102 -0
- package/dist/components/pagination.d.ts +37 -0
- package/dist/components/pagination.js +81 -0
- package/dist/components/pdf-viewer.d.ts +134 -0
- package/dist/components/pdf-viewer.js +996 -0
- package/dist/components/phone-input.d.ts +79 -0
- package/dist/components/phone-input.js +282 -0
- package/dist/components/popover.d.ts +33 -0
- package/dist/components/popover.js +48 -0
- package/dist/components/preview-card.d.ts +25 -0
- package/dist/components/preview-card.js +22 -0
- package/dist/components/progress.d.ts +27 -0
- package/dist/components/progress.js +25 -0
- package/dist/components/prompt-input.d.ts +156 -0
- package/dist/components/prompt-input.js +415 -0
- package/dist/components/quote.d.ts +22 -0
- package/dist/components/quote.js +15 -0
- package/dist/components/radio-group.d.ts +18 -0
- package/dist/components/radio-group.js +34 -0
- package/dist/components/rating.d.ts +73 -0
- package/dist/components/rating.js +124 -0
- package/dist/components/reasoning.d.ts +46 -0
- package/dist/components/reasoning.js +73 -0
- package/dist/components/resizable.d.ts +47 -0
- package/dist/components/resizable.js +44 -0
- package/dist/components/response.d.ts +41 -0
- package/dist/components/response.js +566 -0
- package/dist/components/scroll-area.d.ts +33 -0
- package/dist/components/scroll-area.js +31 -0
- package/dist/components/select.d.ts +35 -0
- package/dist/components/select.js +71 -0
- package/dist/components/separator.d.ts +14 -0
- package/dist/components/separator.js +17 -0
- package/dist/components/sidebar.d.ts +163 -0
- package/dist/components/sidebar.js +505 -0
- package/dist/components/site-header.d.ts +93 -0
- package/dist/components/site-header.js +121 -0
- package/dist/components/skeleton.d.ts +31 -0
- package/dist/components/skeleton.js +29 -0
- package/dist/components/slider.d.ts +24 -0
- package/dist/components/slider.js +131 -0
- package/dist/components/sortable.d.ts +178 -0
- package/dist/components/sortable.js +1258 -0
- package/dist/components/sources.d.ts +40 -0
- package/dist/components/sources.js +42 -0
- package/dist/components/spinner.d.ts +48 -0
- package/dist/components/spinner.js +75 -0
- package/dist/components/stat.d.ts +91 -0
- package/dist/components/stat.js +141 -0
- package/dist/components/stepper.d.ts +71 -0
- package/dist/components/stepper.js +101 -0
- package/dist/components/suggestions.d.ts +20 -0
- package/dist/components/suggestions.js +18 -0
- package/dist/components/switch.d.ts +14 -0
- package/dist/components/switch.js +26 -0
- package/dist/components/table.d.ts +172 -0
- package/dist/components/table.js +895 -0
- package/dist/components/tabs.d.ts +25 -0
- package/dist/components/tabs.js +162 -0
- package/dist/components/tag.d.ts +41 -0
- package/dist/components/tag.js +88 -0
- package/dist/components/tags-input.d.ts +56 -0
- package/dist/components/tags-input.js +271 -0
- package/dist/components/textarea.d.ts +13 -0
- package/dist/components/textarea.js +16 -0
- package/dist/components/theme.d.ts +55 -0
- package/dist/components/theme.js +120 -0
- package/dist/components/time-field.d.ts +70 -0
- package/dist/components/time-field.js +450 -0
- package/dist/components/timeline.d.ts +92 -0
- package/dist/components/timeline.js +108 -0
- package/dist/components/tippy.d.ts +48 -0
- package/dist/components/tippy.js +648 -0
- package/dist/components/toast.d.ts +88 -0
- package/dist/components/toast.js +205 -0
- package/dist/components/toggle-group.d.ts +41 -0
- package/dist/components/toggle-group.js +140 -0
- package/dist/components/toggle.d.ts +23 -0
- package/dist/components/toggle.js +35 -0
- package/dist/components/tool-call.d.ts +63 -0
- package/dist/components/tool-call.js +68 -0
- package/dist/components/toolbar.d.ts +17 -0
- package/dist/components/toolbar.js +39 -0
- package/dist/components/tooltip.d.ts +42 -0
- package/dist/components/tooltip.js +47 -0
- package/dist/components/tour.d.ts +127 -0
- package/dist/components/tour.js +648 -0
- package/dist/components/tree.d.ts +75 -0
- package/dist/components/tree.js +649 -0
- package/dist/components/typography.d.ts +134 -0
- package/dist/components/typography.js +176 -0
- package/dist/components/video-player.d.ts +284 -0
- package/dist/components/video-player.js +1392 -0
- package/dist/illustration.d.ts +2 -0
- package/dist/illustration.js +7 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +94 -0
- package/dist/lib/cn.d.ts +20 -0
- package/dist/lib/cn.js +38 -0
- package/dist/lib/code-highlight.d.ts +18 -0
- package/dist/lib/code-highlight.js +174 -0
- package/dist/lib/code-theme.d.ts +19 -0
- package/dist/lib/code-theme.js +140 -0
- package/dist/lib/collapse-row.d.ts +9 -0
- package/dist/lib/collapse-row.js +129 -0
- package/dist/lib/digit-roll.d.ts +21 -0
- package/dist/lib/digit-roll.js +31 -0
- package/dist/lib/editorial-assets.d.ts +16 -0
- package/dist/lib/editorial-assets.js +56 -0
- package/dist/lib/field-errors.d.ts +28 -0
- package/dist/lib/field-errors.js +24 -0
- package/dist/lib/field-value.d.ts +13 -0
- package/dist/lib/field-value.js +44 -0
- package/dist/lib/figure/catalog.d.ts +127 -0
- package/dist/lib/figure/catalog.js +130 -0
- package/dist/lib/figure/figures/automation.d.ts +7 -0
- package/dist/lib/figure/figures/automation.js +143 -0
- package/dist/lib/figure/figures/bar-chart.d.ts +7 -0
- package/dist/lib/figure/figures/bar-chart.js +99 -0
- package/dist/lib/figure/figures/brackets-classic.d.ts +11 -0
- package/dist/lib/figure/figures/brackets-classic.js +170 -0
- package/dist/lib/figure/figures/brackets.d.ts +8 -0
- package/dist/lib/figure/figures/brackets.js +84 -0
- package/dist/lib/figure/figures/city.d.ts +7 -0
- package/dist/lib/figure/figures/city.js +93 -0
- package/dist/lib/figure/figures/conveyor.d.ts +7 -0
- package/dist/lib/figure/figures/conveyor.js +97 -0
- package/dist/lib/figure/figures/database.d.ts +7 -0
- package/dist/lib/figure/figures/database.js +65 -0
- package/dist/lib/figure/figures/documents.d.ts +7 -0
- package/dist/lib/figure/figures/documents.js +83 -0
- package/dist/lib/figure/figures/inbox.d.ts +7 -0
- package/dist/lib/figure/figures/inbox.js +92 -0
- package/dist/lib/figure/figures/laptop.d.ts +7 -0
- package/dist/lib/figure/figures/laptop.js +67 -0
- package/dist/lib/figure/figures/monitor.d.ts +7 -0
- package/dist/lib/figure/figures/monitor.js +59 -0
- package/dist/lib/figure/figures/pipeline.d.ts +8 -0
- package/dist/lib/figure/figures/pipeline.js +117 -0
- package/dist/lib/figure/figures/platform.d.ts +7 -0
- package/dist/lib/figure/figures/platform.js +117 -0
- package/dist/lib/figure/figures/server.d.ts +7 -0
- package/dist/lib/figure/figures/server.js +115 -0
- package/dist/lib/figure/figures/spreadsheet.d.ts +7 -0
- package/dist/lib/figure/figures/spreadsheet.js +87 -0
- package/dist/lib/figure/figures/timeline.d.ts +7 -0
- package/dist/lib/figure/figures/timeline.js +65 -0
- package/dist/lib/figure/kernel.d.ts +152 -0
- package/dist/lib/figure/kernel.js +576 -0
- package/dist/lib/figure/parts.d.ts +42 -0
- package/dist/lib/figure/parts.js +126 -0
- package/dist/lib/form-reset.d.ts +11 -0
- package/dist/lib/form-reset.js +22 -0
- package/dist/lib/glide.d.ts +53 -0
- package/dist/lib/glide.js +138 -0
- package/dist/lib/graph-layout.d.ts +58 -0
- package/dist/lib/graph-layout.js +209 -0
- package/dist/lib/illustration-drawings.d.ts +89 -0
- package/dist/lib/illustration-drawings.js +539 -0
- package/dist/lib/illustration-info.d.ts +37 -0
- package/dist/lib/illustration-info.js +22 -0
- package/dist/lib/illustration-library.d.ts +87 -0
- package/dist/lib/illustration-library.js +352 -0
- package/dist/lib/logo-geometry.d.ts +29 -0
- package/dist/lib/logo-geometry.js +67 -0
- package/dist/lib/markdown-guard.d.ts +16 -0
- package/dist/lib/markdown-guard.js +123 -0
- package/dist/lib/merge-refs.d.ts +10 -0
- package/dist/lib/merge-refs.js +26 -0
- package/dist/lib/money.d.ts +73 -0
- package/dist/lib/money.js +343 -0
- package/dist/lib/motion.d.ts +6 -0
- package/dist/lib/motion.js +12 -0
- package/dist/lib/pdf-worker.d.ts +1 -0
- package/dist/lib/pdf-worker.js +6 -0
- package/dist/lib/pdf.d.ts +19 -0
- package/dist/lib/pdf.js +58 -0
- package/dist/lib/phone-countries.d.ts +1 -0
- package/dist/lib/phone-countries.js +281 -0
- package/dist/lib/phone.d.ts +90 -0
- package/dist/lib/phone.js +286 -0
- package/dist/lib/platform.d.ts +38 -0
- package/dist/lib/platform.js +75 -0
- package/dist/lib/room.d.ts +25 -0
- package/dist/lib/room.js +46 -0
- package/dist/lib/row-index.d.ts +15 -0
- package/dist/lib/row-index.js +136 -0
- package/dist/lib/table-fit.d.ts +143 -0
- package/dist/lib/table-fit.js +596 -0
- package/dist/lib/theme-script.d.ts +31 -0
- package/dist/lib/theme-script.js +49 -0
- package/dist/lib/tippy/pixels.d.ts +47 -0
- package/dist/lib/tippy/pixels.js +187 -0
- package/dist/lib/tippy/sprite.d.ts +86 -0
- package/dist/lib/tippy/sprite.js +753 -0
- package/dist/messages/de.d.ts +12 -0
- package/dist/messages/de.js +326 -0
- package/dist/styles/expressive.css +203 -0
- package/dist/styles/fonts.css +145 -0
- package/dist/styles/index.css +207 -0
- package/dist/styles/material.css +317 -0
- package/dist/styles/parts/ai.css +361 -0
- package/dist/styles/parts/brand.css +75 -0
- package/dist/styles/parts/controls.css +774 -0
- package/dist/styles/parts/data.css +222 -0
- package/dist/styles/parts/editorial.css +120 -0
- package/dist/styles/parts/feedback.css +340 -0
- package/dist/styles/parts/foundations.css +166 -0
- package/dist/styles/parts/graph.css +214 -0
- package/dist/styles/parts/inputs.css +261 -0
- package/dist/styles/parts/isometric.css +124 -0
- package/dist/styles/parts/navigation.css +424 -0
- package/dist/styles/parts/overlays.css +250 -0
- package/dist/styles/parts/pdf.css +154 -0
- package/dist/styles/parts/react-flow.css +519 -0
- package/dist/styles/tokens.css +299 -0
- package/dist/vite.d.ts +66 -0
- package/dist/vite.js +29 -0
- package/package.json +183 -5
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Toast as BaseToast, type ToastManager, type ToastManagerAddOptions, type ToastManagerPromiseOptions, type ToastManagerUpdateOptions, type ToastObject } from "@base-ui/react/toast";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export interface ToastMessages {
|
|
4
|
+
/** Each toast's close button. */
|
|
5
|
+
close: string;
|
|
6
|
+
/** The name of the stack's landmark, which F6 jumps to. */
|
|
7
|
+
region: string;
|
|
8
|
+
}
|
|
9
|
+
declare module "./locale" {
|
|
10
|
+
interface Messages {
|
|
11
|
+
toast: ToastMessages;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export type ToastType = "default" | "success" | "warning" | "info" | "error" | "loading";
|
|
15
|
+
/** A button inside the toast: "Undo", "View". */
|
|
16
|
+
export interface ToastActionOptions {
|
|
17
|
+
label: React.ReactNode;
|
|
18
|
+
onClick: () => void;
|
|
19
|
+
}
|
|
20
|
+
export interface ToastOptions extends Omit<ToastManagerAddOptions<object>, "type" | "title"> {
|
|
21
|
+
type?: ToastType;
|
|
22
|
+
/** Shorthand for `actionProps: { children: label, onClick }`. */
|
|
23
|
+
action?: ToastActionOptions;
|
|
24
|
+
}
|
|
25
|
+
/** The `toast` API: call it for a default toast, or use a typed shortcut. */
|
|
26
|
+
export interface ToastApi {
|
|
27
|
+
(title: React.ReactNode, options?: ToastOptions): string;
|
|
28
|
+
/** A green check. The surface stays the menu material. */
|
|
29
|
+
success: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
30
|
+
/** An amber triangle: done, but something needs a look ("Saved, 2 images were too large"). */
|
|
31
|
+
warning: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
32
|
+
/** A blue info mark: neutral news ("A new version is available"). */
|
|
33
|
+
info: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
34
|
+
/** The same treatment in `--destructive`, announced urgently. */
|
|
35
|
+
error: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
36
|
+
/** Spinner, no auto-dismiss. Update it with `toast.update(id, { type: "success", … })`. */
|
|
37
|
+
loading: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
38
|
+
/** loading → success / error, following a promise. */
|
|
39
|
+
promise: <Value>(promise: Promise<Value>, options: ToastManagerPromiseOptions<Value, object>) => Promise<Value>;
|
|
40
|
+
update: (id: string, options: Omit<ToastManagerUpdateOptions<object>, "type"> & {
|
|
41
|
+
type?: ToastType;
|
|
42
|
+
}) => void;
|
|
43
|
+
/** Close one toast, or all of them when called without an id. */
|
|
44
|
+
dismiss: (id?: string) => void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* toast — queue a toast from anywhere, including outside React (an API client, a store).
|
|
48
|
+
* Requires one `<Toaster />` mounted in the app; toasts sent before it mounts (from a page's
|
|
49
|
+
* mount effect, say) wait for it.
|
|
50
|
+
*
|
|
51
|
+
* toast.success("Your changes are saved.")
|
|
52
|
+
* toast.error("We couldn't send your message.", { description: "Check your connection and try again." })
|
|
53
|
+
* toast("Integration removed", { action: { label: "Undo", onClick: restore } })
|
|
54
|
+
*/
|
|
55
|
+
export declare const toast: ToastApi;
|
|
56
|
+
/**
|
|
57
|
+
* useToast — the same API as `toast`, bound to the nearest `<Toaster>` (render your tree as its
|
|
58
|
+
* children to use it), plus the live `toasts` array. Outside a Toaster it is the global `toast`,
|
|
59
|
+
* and `toasts` are those the global manager's Toaster shows.
|
|
60
|
+
*/
|
|
61
|
+
export declare function useToast(): ToastApi & {
|
|
62
|
+
toasts: ToastObject<object>[];
|
|
63
|
+
};
|
|
64
|
+
export interface ToasterProps extends Omit<BaseToast.Provider.Props, "toastManager"> {
|
|
65
|
+
/** Defaults to the library-wide manager behind `toast()`. */
|
|
66
|
+
toastManager?: ToastManager<object>;
|
|
67
|
+
/** Classes for the viewport (the fixed stack in the bottom-right corner). */
|
|
68
|
+
className?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Accessible name of each toast's close button.
|
|
71
|
+
* @deprecated Use `labels.close`.
|
|
72
|
+
*/
|
|
73
|
+
closeLabel?: string;
|
|
74
|
+
/** Accessible names: each close button and the stack's region. A LocaleProvider sets them for every Toaster. */
|
|
75
|
+
labels?: Partial<ToastMessages>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Toaster — Toast.Provider + Viewport: toasts stack in the bottom-right corner (bottom, full
|
|
79
|
+
* width on mobile), expand on hover or focus, and swipe away down or right. F6 jumps into the stack.
|
|
80
|
+
* Inside a right-to-left `DirectionProvider` they read right to left and the corner mirrors: they
|
|
81
|
+
* stack bottom-left and swipe away down or left.
|
|
82
|
+
*
|
|
83
|
+
* Mount it once near the root (extra Toasters on the same manager render nothing). Render the app
|
|
84
|
+
* as its children if you want `useToast()`.
|
|
85
|
+
* The rule people break: toasting what needs a decision. A toast disappears; anything the person
|
|
86
|
+
* must act on belongs in the page or an `AlertDialog`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function Toaster({ toastManager, limit, className, closeLabel, labels, children, ...props }: ToasterProps): React.JSX.Element;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useDirection } from "@base-ui/react/direction-provider";
|
|
4
|
+
import { Toast as BaseToast, } from "@base-ui/react/toast";
|
|
5
|
+
import { CircleAlertIcon, CircleCheckIcon, InfoIcon, LoaderCircleIcon, TriangleAlertIcon, XIcon, } from "lucide-react";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { cn } from "../lib/cn.js";
|
|
8
|
+
import { useMessages } from "./locale.js";
|
|
9
|
+
const defaultMessages = { close: "Dismiss", region: "Notifications" };
|
|
10
|
+
function toAddOptions(title, { action, ...options } = {}) {
|
|
11
|
+
const add = { title, ...options };
|
|
12
|
+
if (action)
|
|
13
|
+
add.actionProps = { ...options.actionProps, children: action.label, onClick: action.onClick };
|
|
14
|
+
return add;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The toast API over a manager. With `listener` — the manager a `<Toaster>` subscribes to — calls
|
|
18
|
+
* made before any such Toaster has mounted wait for one (see `whenListening`).
|
|
19
|
+
*/
|
|
20
|
+
function createToastApi(manager, listener) {
|
|
21
|
+
let waiting = 0;
|
|
22
|
+
const later = (call) => (listener ? whenListening(listener, call) : call());
|
|
23
|
+
const add = (options) => {
|
|
24
|
+
if (!listener || isListening(listener))
|
|
25
|
+
return manager.add(options);
|
|
26
|
+
// The id is ours, so `update` and `dismiss` can name the toast before it shows.
|
|
27
|
+
const id = options.id ?? `toast-waiting-${++waiting}`;
|
|
28
|
+
later(() => manager.add({ ...options, id }));
|
|
29
|
+
return id;
|
|
30
|
+
};
|
|
31
|
+
const show = (title, options) => add(toAddOptions(title, options));
|
|
32
|
+
return Object.assign(show, {
|
|
33
|
+
success: (title, options) => show(title, { ...options, type: "success" }),
|
|
34
|
+
warning: (title, options) => show(title, { ...options, type: "warning" }),
|
|
35
|
+
info: (title, options) => show(title, { ...options, type: "info" }),
|
|
36
|
+
error: (title, options) => show(title, { priority: "high", ...options, type: "error" }),
|
|
37
|
+
loading: (title, options) =>
|
|
38
|
+
// Base UI keeps a loading toast up by itself; a timeout of 0 here would outlive it, and the
|
|
39
|
+
// success or error it is updated to would never close.
|
|
40
|
+
show(title, { ...options, type: "loading" }),
|
|
41
|
+
promise: (promise, options) => {
|
|
42
|
+
if (!listener || isListening(listener))
|
|
43
|
+
return manager.promise(promise, options);
|
|
44
|
+
// The caller holds the promise itself; the copy the Toaster follows must not reject unheard.
|
|
45
|
+
later(() => void manager.promise(promise, options).catch(() => { }));
|
|
46
|
+
return promise;
|
|
47
|
+
},
|
|
48
|
+
update: (id, options) => later(() => manager.update(id, options)),
|
|
49
|
+
dismiss: (id) => later(() => manager.close(id)),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** The library-wide manager. `<Toaster />` renders it unless you pass your own `toastManager`. */
|
|
53
|
+
const globalToastManager = BaseToast.createToastManager();
|
|
54
|
+
/**
|
|
55
|
+
* toast — queue a toast from anywhere, including outside React (an API client, a store).
|
|
56
|
+
* Requires one `<Toaster />` mounted in the app; toasts sent before it mounts (from a page's
|
|
57
|
+
* mount effect, say) wait for it.
|
|
58
|
+
*
|
|
59
|
+
* toast.success("Your changes are saved.")
|
|
60
|
+
* toast.error("We couldn't send your message.", { description: "Check your connection and try again." })
|
|
61
|
+
* toast("Integration removed", { action: { label: "Undo", onClick: restore } })
|
|
62
|
+
*/
|
|
63
|
+
export const toast = createToastApi(globalToastManager, globalToastManager);
|
|
64
|
+
/** The manager of the nearest `<Toaster>`, so `useToast` adds through it rather than a local store. */
|
|
65
|
+
const ToasterManagerContext = React.createContext(null);
|
|
66
|
+
/**
|
|
67
|
+
* The nearest Toast.Provider's manager, or null outside one, where Base UI's hook throws. A
|
|
68
|
+
* component is inside a provider or not for as long as it is mounted, so its hooks keep their order.
|
|
69
|
+
*/
|
|
70
|
+
function useNearestToastManager() {
|
|
71
|
+
try {
|
|
72
|
+
return BaseToast.useToastManager();
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const NO_TOASTS = [];
|
|
79
|
+
/**
|
|
80
|
+
* useToast — the same API as `toast`, bound to the nearest `<Toaster>` (render your tree as its
|
|
81
|
+
* children to use it), plus the live `toasts` array. Outside a Toaster it is the global `toast`,
|
|
82
|
+
* and `toasts` are those the global manager's Toaster shows.
|
|
83
|
+
*/
|
|
84
|
+
export function useToast() {
|
|
85
|
+
const shared = React.useContext(ToasterManagerContext);
|
|
86
|
+
const nearest = useNearestToastManager();
|
|
87
|
+
const shown = React.useSyncExternalStore(subscribeRegistry, () => shownToasts.get(globalToastManager) ?? NO_TOASTS, () => NO_TOASTS);
|
|
88
|
+
const { add, close, update, promise } = nearest ?? {};
|
|
89
|
+
const api = React.useMemo(() => shared
|
|
90
|
+
? createToastApi(shared, shared)
|
|
91
|
+
: add && close && update && promise
|
|
92
|
+
? createToastApi({ add, close, update, promise })
|
|
93
|
+
: createToastApi(globalToastManager, globalToastManager), [shared, add, close, update, promise]);
|
|
94
|
+
return Object.assign(api, { toasts: nearest?.toasts ?? shown });
|
|
95
|
+
}
|
|
96
|
+
/*
|
|
97
|
+
* Several <Toaster>s can share one manager (two demos on a page, a layout and a nested route).
|
|
98
|
+
* Only the first one mounted renders the stack, so a toast never appears twice.
|
|
99
|
+
*/
|
|
100
|
+
const toasterRegistry = new WeakMap();
|
|
101
|
+
/** The toasts each manager's primary Toaster shows: `useToast` outside a Toaster reads them. */
|
|
102
|
+
const shownToasts = new WeakMap();
|
|
103
|
+
const registryListeners = new Set();
|
|
104
|
+
const notifyRegistry = () => registryListeners.forEach((listener) => listener());
|
|
105
|
+
const subscribeRegistry = (listener) => {
|
|
106
|
+
registryListeners.add(listener);
|
|
107
|
+
return () => {
|
|
108
|
+
registryListeners.delete(listener);
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
/*
|
|
112
|
+
* A manager hands a toast only to the Toasters subscribed at that moment, so one sent from a page's
|
|
113
|
+
* mount effect — which runs before the effects of a Toaster placed after the page, or around it —
|
|
114
|
+
* would be dropped. Until a Toaster for the manager has mounted, calls wait here (the last 50) and
|
|
115
|
+
* play in order once one has. On the server nothing mounts: there they are dropped, as before.
|
|
116
|
+
*/
|
|
117
|
+
const waitingCalls = new WeakMap();
|
|
118
|
+
/** A Toaster for the manager has mounted and nothing sent earlier is still waiting. */
|
|
119
|
+
function isListening(manager) {
|
|
120
|
+
return (toasterRegistry.get(manager)?.length ?? 0) > 0 && !waitingCalls.has(manager);
|
|
121
|
+
}
|
|
122
|
+
function whenListening(manager, call) {
|
|
123
|
+
if (isListening(manager))
|
|
124
|
+
return call();
|
|
125
|
+
if (typeof window === "undefined")
|
|
126
|
+
return;
|
|
127
|
+
const queue = waitingCalls.get(manager) ?? [];
|
|
128
|
+
queue.push(call);
|
|
129
|
+
if (queue.length > 50)
|
|
130
|
+
queue.shift();
|
|
131
|
+
waitingCalls.set(manager, queue);
|
|
132
|
+
}
|
|
133
|
+
function playWaiting(manager) {
|
|
134
|
+
const queue = waitingCalls.get(manager);
|
|
135
|
+
if (!queue || !toasterRegistry.get(manager)?.length)
|
|
136
|
+
return;
|
|
137
|
+
waitingCalls.delete(manager);
|
|
138
|
+
queue.forEach((call) => call());
|
|
139
|
+
}
|
|
140
|
+
function useIsPrimaryToaster(manager) {
|
|
141
|
+
const [id] = React.useState(() => Symbol("toaster"));
|
|
142
|
+
React.useEffect(() => {
|
|
143
|
+
const list = toasterRegistry.get(manager) ?? [];
|
|
144
|
+
toasterRegistry.set(manager, [...list, id]);
|
|
145
|
+
notifyRegistry();
|
|
146
|
+
// The Provider below has subscribed by now (a child's effects run first). Play what waited a
|
|
147
|
+
// tick later, after StrictMode's check has re-run the effects: its unmount stops the timers.
|
|
148
|
+
queueMicrotask(() => playWaiting(manager));
|
|
149
|
+
return () => {
|
|
150
|
+
toasterRegistry.set(manager, (toasterRegistry.get(manager) ?? []).filter((entry) => entry !== id));
|
|
151
|
+
notifyRegistry();
|
|
152
|
+
};
|
|
153
|
+
}, [manager, id]);
|
|
154
|
+
return React.useSyncExternalStore(subscribeRegistry, () => toasterRegistry.get(manager)?.[0] === id, () => false);
|
|
155
|
+
}
|
|
156
|
+
/* ── Rendering ─────────────────────────────────────────────────────────────── */
|
|
157
|
+
const icons = {
|
|
158
|
+
default: null,
|
|
159
|
+
/* Status colour shows on the icon only: the title says what happened. */
|
|
160
|
+
success: _jsx(CircleCheckIcon, { "aria-hidden": true, className: "size-4 text-success" }),
|
|
161
|
+
warning: _jsx(TriangleAlertIcon, { "aria-hidden": true, className: "size-4 text-warning" }),
|
|
162
|
+
info: _jsx(InfoIcon, { "aria-hidden": true, className: "size-4 text-info" }),
|
|
163
|
+
error: _jsx(CircleAlertIcon, { "aria-hidden": true, className: "size-4 text-destructive" }),
|
|
164
|
+
loading: _jsx(LoaderCircleIcon, { "aria-hidden": true, className: "size-4 text-muted-foreground motion-safe:animate-spin" }),
|
|
165
|
+
};
|
|
166
|
+
function ToastItem({ toast: item, closeLabel, rtl }) {
|
|
167
|
+
const type = (item.type ?? "default");
|
|
168
|
+
const icon = icons[type] ?? null;
|
|
169
|
+
return (_jsx(BaseToast.Root, { toast: item, "data-slot": "toast", "data-type": type,
|
|
170
|
+
// Away from the page, toward the corner's edge: the left one in a right-to-left page.
|
|
171
|
+
swipeDirection: rtl ? ["down", "left"] : ["down", "right"], className: "rounded-button material-menu font-body outline-none", children: _jsxs(BaseToast.Content, { "data-slot": "toast-content", className: "flex items-start gap-3 overflow-hidden p-4 pe-11", children: [icon && _jsx("span", { className: "flex h-5 shrink-0 items-center", children: icon }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5 break-words", children: [_jsx(BaseToast.Title, { "data-slot": "toast-title", className: "font-body text-sm leading-5 font-medium tracking-normal text-foreground" }), _jsx(BaseToast.Description, { "data-slot": "toast-description", className: "text-[13px] leading-normal text-muted-foreground first:text-sm first:leading-5 first:text-foreground" }), _jsx(BaseToast.Action, { "data-slot": "toast-action", className: "mt-2.5 inline-flex min-h-(--control-h-sm) cursor-pointer items-center self-start rounded-button material-raised px-3 text-[13px] font-medium focus-ring" })] }), _jsx(BaseToast.Close, { "data-slot": "toast-close", "aria-label": closeLabel, className: "absolute end-3 top-3 inline-flex size-6 cursor-pointer items-center justify-center rounded-full material-row text-muted-foreground focus-ring", children: _jsx(XIcon, { "aria-hidden": true, className: "size-3.5" }) })] }) }));
|
|
172
|
+
}
|
|
173
|
+
function ToastList({ manager, closeLabel, rtl }) {
|
|
174
|
+
const { toasts } = BaseToast.useToastManager();
|
|
175
|
+
React.useLayoutEffect(() => {
|
|
176
|
+
shownToasts.set(manager, toasts);
|
|
177
|
+
notifyRegistry();
|
|
178
|
+
}, [manager, toasts]);
|
|
179
|
+
React.useLayoutEffect(() => () => {
|
|
180
|
+
shownToasts.delete(manager);
|
|
181
|
+
notifyRegistry();
|
|
182
|
+
}, [manager]);
|
|
183
|
+
return toasts.map((item) => _jsx(ToastItem, { toast: item, closeLabel: closeLabel, rtl: rtl }, item.id));
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Toaster — Toast.Provider + Viewport: toasts stack in the bottom-right corner (bottom, full
|
|
187
|
+
* width on mobile), expand on hover or focus, and swipe away down or right. F6 jumps into the stack.
|
|
188
|
+
* Inside a right-to-left `DirectionProvider` they read right to left and the corner mirrors: they
|
|
189
|
+
* stack bottom-left and swipe away down or left.
|
|
190
|
+
*
|
|
191
|
+
* Mount it once near the root (extra Toasters on the same manager render nothing). Render the app
|
|
192
|
+
* as its children if you want `useToast()`.
|
|
193
|
+
* The rule people break: toasting what needs a decision. A toast disappears; anything the person
|
|
194
|
+
* must act on belongs in the page or an `AlertDialog`.
|
|
195
|
+
*/
|
|
196
|
+
export function Toaster({ toastManager = globalToastManager, limit = 3, className, closeLabel, labels, children, ...props }) {
|
|
197
|
+
const primary = useIsPrimaryToaster(toastManager);
|
|
198
|
+
const text = useMessages("toast", defaultMessages, labels);
|
|
199
|
+
// The stack is portalled out of any `dir` element: it takes the direction from the provider.
|
|
200
|
+
const rtl = useDirection() === "rtl";
|
|
201
|
+
return (_jsxs(BaseToast.Provider, { toastManager: toastManager, limit: limit, ...props, children: [_jsx(ToasterManagerContext.Provider, { value: toastManager, children: children }), primary && (_jsx(BaseToast.Portal, { children: _jsx(BaseToast.Viewport, { "data-slot": "toast-viewport", dir: rtl ? "rtl" : undefined, "aria-label": text.region, className: cn(
|
|
202
|
+
// Above the home indicator on a page that draws under it (viewport-fit=cover), and
|
|
203
|
+
// above a BottomNav, whose --bottom-nav-h already counts the safe area.
|
|
204
|
+
"fixed bottom-[calc(1rem+max(env(safe-area-inset-bottom,0px),var(--bottom-nav-h,0px)))] z-[60] mx-auto w-[calc(100vw-2rem)] outline-none sm:bottom-[calc(1.5rem+max(env(safe-area-inset-bottom,0px),var(--bottom-nav-h,0px)))] sm:w-90", rtl ? "left-4 sm:left-6" : "right-4 sm:right-6", className), children: _jsx(ToastList, { manager: toastManager, closeLabel: closeLabel ?? text.close, rtl: rtl }) }) }))] }));
|
|
205
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Toggle as BaseToggle } from "@base-ui/react/toggle";
|
|
2
|
+
import { ToggleGroup as BaseToggleGroup } from "@base-ui/react/toggle-group";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export interface ToggleGroupProps<Value extends string = string> extends BaseToggleGroup.Props<Value> {
|
|
5
|
+
/**
|
|
6
|
+
* In single mode (the default) one segment always stays pressed: clicking the current
|
|
7
|
+
* segment again does nothing. Set `allowEmpty` to let it be cleared.
|
|
8
|
+
*/
|
|
9
|
+
allowEmpty?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Segments with an `icon` and a label show only one of them until pressed: `label` keeps the
|
|
12
|
+
* icons and reveals the pressed segment's label; `icon` keeps the labels and reveals its icon.
|
|
13
|
+
* The segment widens as the hidden part slides in, and the raised surface widens with it.
|
|
14
|
+
*/
|
|
15
|
+
reveal?: "label" | "icon";
|
|
16
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* ToggleGroup — the segmented control. A recessed 38px track holding 30px segments; the current
|
|
20
|
+
* segment is raised like a secondary button. In single mode one raised indicator glides to the
|
|
21
|
+
* segment you pick; until it has measured (and in `multiple` mode) each pressed segment raises
|
|
22
|
+
* itself.
|
|
23
|
+
*
|
|
24
|
+
* Use it for 2–5 short, mutually exclusive options where seeing them side by side is the point
|
|
25
|
+
* (billing period, view mode, a units switch). Past five options, or with long labels, use
|
|
26
|
+
* `Select`. The rule people break: using it as a row of independent actions — that is a
|
|
27
|
+
* toolbar of `Button`s or `Toggle`s. Give the group an `aria-label` or a visible label.
|
|
28
|
+
*/
|
|
29
|
+
export declare function ToggleGroup<Value extends string = string>({ allowEmpty, reveal, multiple, onValueChange, className, children, ref, ...props }: ToggleGroupProps<Value>): React.JSX.Element;
|
|
30
|
+
export interface ToggleGroupItemProps<Value extends string = string> extends BaseToggle.Props<Value> {
|
|
31
|
+
/**
|
|
32
|
+
* A 16px lucide icon before the label. With the group's `reveal`, one of the two stays hidden
|
|
33
|
+
* until the segment is pressed; the hidden label still names the segment for assistive tech.
|
|
34
|
+
*/
|
|
35
|
+
icon?: React.ReactNode;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* ToggleGroupItem — one segment. Needs a `value`; icon-only segments need an `aria-label`.
|
|
39
|
+
* Keep labels to a word or two so the segments stay comparable.
|
|
40
|
+
*/
|
|
41
|
+
export declare function ToggleGroupItem<Value extends string = string>({ icon, className, children, ...props }: ToggleGroupItemProps<Value>): React.JSX.Element;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Toggle as BaseToggle } from "@base-ui/react/toggle";
|
|
4
|
+
import { ToggleGroup as BaseToggleGroup } from "@base-ui/react/toggle-group";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { cn, sx } from "../lib/cn.js";
|
|
7
|
+
import { glideMotion, glideStyle, useGlide, useMergedRef } from "../lib/glide.js";
|
|
8
|
+
const ITEM = '[data-slot="toggle-group-item"]';
|
|
9
|
+
const findPressed = (root) => root.querySelector(`${ITEM}[data-pressed]`);
|
|
10
|
+
/**
|
|
11
|
+
* Keeps the chosen item in view in a row that scrolls sideways (a narrow screen): when it mounts,
|
|
12
|
+
* when the choice changes, and when the row or an item resizes — web fonts arriving, a hidden row
|
|
13
|
+
* shown — until someone scrolls the row themselves. Only the row scrolls, never the page, and its
|
|
14
|
+
* scroll-padding stays clear. It works from the boxes on screen, so LTR and RTL alike. (TabsList
|
|
15
|
+
* has the same.)
|
|
16
|
+
*/
|
|
17
|
+
function useRevealChosen(list, item, attribute) {
|
|
18
|
+
React.useLayoutEffect(() => {
|
|
19
|
+
const row = list.current;
|
|
20
|
+
if (!row)
|
|
21
|
+
return;
|
|
22
|
+
let held = false;
|
|
23
|
+
// The item chosen last (in `multiple` mode, the one just pressed), else the first chosen one.
|
|
24
|
+
let last = null;
|
|
25
|
+
const reveal = () => {
|
|
26
|
+
if (last && !last.hasAttribute(attribute))
|
|
27
|
+
last = null;
|
|
28
|
+
const chosen = row.scrollWidth > row.clientWidth && (last ?? row.querySelector(`${item}[${attribute}]`));
|
|
29
|
+
if (!chosen)
|
|
30
|
+
return;
|
|
31
|
+
const style = getComputedStyle(row);
|
|
32
|
+
const left = row.getBoundingClientRect().left + row.clientLeft;
|
|
33
|
+
const start = left + (Number.parseFloat(style.scrollPaddingLeft) || 0);
|
|
34
|
+
const end = left + row.clientWidth - (Number.parseFloat(style.scrollPaddingRight) || 0);
|
|
35
|
+
const box = chosen.getBoundingClientRect();
|
|
36
|
+
// Wider than the room: its start shows (its right edge in RTL).
|
|
37
|
+
const delta = box.left < start && box.right > end
|
|
38
|
+
? style.direction === "rtl"
|
|
39
|
+
? box.right - end
|
|
40
|
+
: box.left - start
|
|
41
|
+
: box.left < start
|
|
42
|
+
? box.left - start
|
|
43
|
+
: Math.max(0, box.right - end);
|
|
44
|
+
if (delta)
|
|
45
|
+
row.scrollLeft += delta;
|
|
46
|
+
};
|
|
47
|
+
const resize = new ResizeObserver(() => !held && reveal());
|
|
48
|
+
const observe = () => {
|
|
49
|
+
resize.disconnect();
|
|
50
|
+
resize.observe(row);
|
|
51
|
+
row.querySelectorAll(item).forEach((node) => resize.observe(node));
|
|
52
|
+
};
|
|
53
|
+
const mutations = new MutationObserver((records) => {
|
|
54
|
+
if (records.some((r) => r.type === "childList"))
|
|
55
|
+
observe();
|
|
56
|
+
const chosen = records
|
|
57
|
+
.filter((r) => r.type === "attributes" && r.target.hasAttribute(attribute))
|
|
58
|
+
.at(-1);
|
|
59
|
+
if (chosen) {
|
|
60
|
+
last = chosen.target;
|
|
61
|
+
held = false;
|
|
62
|
+
reveal();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
mutations.observe(row, {
|
|
66
|
+
subtree: true,
|
|
67
|
+
childList: true,
|
|
68
|
+
attributes: true,
|
|
69
|
+
attributeFilter: [attribute],
|
|
70
|
+
});
|
|
71
|
+
// Scrolling the row by hand, or moving through it by keyboard, leaves it where it is.
|
|
72
|
+
const hold = () => {
|
|
73
|
+
held = true;
|
|
74
|
+
};
|
|
75
|
+
const events = ["wheel", "touchstart", "keydown"];
|
|
76
|
+
for (const type of events)
|
|
77
|
+
row.addEventListener(type, hold, { passive: true });
|
|
78
|
+
observe();
|
|
79
|
+
reveal();
|
|
80
|
+
return () => {
|
|
81
|
+
resize.disconnect();
|
|
82
|
+
mutations.disconnect();
|
|
83
|
+
for (const type of events)
|
|
84
|
+
row.removeEventListener(type, hold);
|
|
85
|
+
};
|
|
86
|
+
}, [list, item, attribute]);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* ToggleGroup — the segmented control. A recessed 38px track holding 30px segments; the current
|
|
90
|
+
* segment is raised like a secondary button. In single mode one raised indicator glides to the
|
|
91
|
+
* segment you pick; until it has measured (and in `multiple` mode) each pressed segment raises
|
|
92
|
+
* itself.
|
|
93
|
+
*
|
|
94
|
+
* Use it for 2–5 short, mutually exclusive options where seeing them side by side is the point
|
|
95
|
+
* (billing period, view mode, a units switch). Past five options, or with long labels, use
|
|
96
|
+
* `Select`. The rule people break: using it as a row of independent actions — that is a
|
|
97
|
+
* toolbar of `Button`s or `Toggle`s. Give the group an `aria-label` or a visible label.
|
|
98
|
+
*/
|
|
99
|
+
export function ToggleGroup({ allowEmpty = false, reveal, multiple, onValueChange, className, children, ref, ...props }) {
|
|
100
|
+
const [rootRef, setRef] = useMergedRef(ref);
|
|
101
|
+
const glide = useGlide(rootRef, findPressed, {
|
|
102
|
+
enabled: !multiple,
|
|
103
|
+
attributes: ["data-pressed"],
|
|
104
|
+
items: ITEM,
|
|
105
|
+
});
|
|
106
|
+
// Too many segments for a narrow screen scroll inside the track; the pressed one starts in view.
|
|
107
|
+
useRevealChosen(rootRef, ITEM, "data-pressed");
|
|
108
|
+
return (_jsxs(BaseToggleGroup, { ref: setRef, "data-slot": "toggle-group", "data-indicator": glide.visible ? "" : undefined, "data-reveal": reveal, multiple: multiple, onValueChange: (value, eventDetails) => {
|
|
109
|
+
if (!multiple && !allowEmpty && value.length === 0) {
|
|
110
|
+
eventDetails.cancel();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
onValueChange?.(value, eventDetails);
|
|
114
|
+
}, className: sx([
|
|
115
|
+
"group/toggle-group relative inline-flex min-h-(--control-h) w-fit max-w-full material-field items-stretch gap-0.5 rounded-control p-[3px]",
|
|
116
|
+
// Segments that outgrow the row scroll inside the track (its 3px inset keeps their focus
|
|
117
|
+
// outlines whole) instead of pushing the page wider.
|
|
118
|
+
"scroll-px-[3px] [scrollbar-width:none] data-[orientation=horizontal]:overflow-x-auto data-[orientation=horizontal]:overflow-y-hidden [&::-webkit-scrollbar]:hidden",
|
|
119
|
+
"data-[orientation=vertical]:flex-col",
|
|
120
|
+
"data-disabled:**:data-[slot=toggle-group-item]:opacity-100",
|
|
121
|
+
], className), ...props, children: [!multiple && (_jsx("span", { "aria-hidden": true, "data-slot": "toggle-group-indicator", "data-visible": glide.visible ? "" : undefined, "data-instant": glide.instant ? "" : undefined, className: cn(glideMotion, "rounded-item border border-transparent bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent shadow-raised"), style: glideStyle(glide) })), children] }));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* ToggleGroupItem — one segment. Needs a `value`; icon-only segments need an `aria-label`.
|
|
125
|
+
* Keep labels to a word or two so the segments stay comparable.
|
|
126
|
+
*/
|
|
127
|
+
export function ToggleGroupItem({ icon, className, children, ...props }) {
|
|
128
|
+
return (_jsx(BaseToggle, { "data-slot": "toggle-group-item", className: sx([
|
|
129
|
+
"relative inline-flex min-h-(--control-h-sm) flex-1 cursor-pointer items-center justify-center gap-1.5 rounded-item border border-transparent px-3 font-body text-[13px] leading-none font-medium whitespace-nowrap text-control-muted select-none",
|
|
130
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
131
|
+
// Hover only brightens the label; the raised material means "selected".
|
|
132
|
+
"hover:not-data-disabled:text-foreground",
|
|
133
|
+
"data-pressed:bg-control-surface data-pressed:bg-linear-to-b data-pressed:from-control-inner-edge data-pressed:to-transparent data-pressed:text-foreground data-pressed:shadow-raised",
|
|
134
|
+
// Once the gliding indicator is placed it carries the raised surface instead.
|
|
135
|
+
"group-data-indicator/toggle-group:data-pressed:bg-transparent group-data-indicator/toggle-group:data-pressed:bg-none group-data-indicator/toggle-group:data-pressed:shadow-none",
|
|
136
|
+
"disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
137
|
+
// Revealing segments size to their content; the icon–label gap sits inside the part that slides.
|
|
138
|
+
"group-data-[reveal]/toggle-group:flex-none group-data-[reveal]/toggle-group:gap-0",
|
|
139
|
+
], className), ...props, children: icon == null ? (children) : (_jsxs(_Fragment, { children: [_jsx("span", { "data-slot": "toggle-group-icon", children: _jsx("span", { children: icon }) }), children != null && (_jsx("span", { "data-slot": "toggle-group-label", children: _jsx("span", { children: children }) }))] })) }));
|
|
140
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Toggle as BaseToggle } from "@base-ui/react/toggle";
|
|
2
|
+
declare const sizes: {
|
|
3
|
+
readonly sm: "min-h-(--control-h-sm) gap-1.5 px-3 text-[13px]";
|
|
4
|
+
readonly default: "min-h-(--control-h) gap-2 px-4 text-sm";
|
|
5
|
+
readonly icon: "size-(--icon-button) rounded-full p-0";
|
|
6
|
+
readonly "icon-sm": "size-(--control-h-sm) rounded-full p-0";
|
|
7
|
+
};
|
|
8
|
+
export type ToggleSize = keyof typeof sizes;
|
|
9
|
+
export interface ToggleProps<Value extends string = string> extends BaseToggle.Props<Value> {
|
|
10
|
+
size?: ToggleSize;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Toggle — a raised button that stays pressed. Off, it is the quiet raised surface with soft
|
|
14
|
+
* ink, and hover only brightens the ink. On, it sinks into the surface: the hover fill, a deeper inset shadow, the
|
|
15
|
+
* `--control-focus` edge of a current item and full foreground ink. Never a colour fill or
|
|
16
|
+
* layout movement.
|
|
17
|
+
*
|
|
18
|
+
* Use it for a single on/off tool ("Show grid", bold, pin). For a choice between options use
|
|
19
|
+
* `ToggleGroup`; for a form value use `Checkbox` or `Switch`. Icon sizes are circular and need
|
|
20
|
+
* an `aria-label` — and keep that label constant; the pressed state is announced separately.
|
|
21
|
+
*/
|
|
22
|
+
export declare function Toggle<Value extends string = string>({ size, className, ...props }: ToggleProps<Value>): import("react").JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Toggle as BaseToggle } from "@base-ui/react/toggle";
|
|
4
|
+
import { sx } from "../lib/cn.js";
|
|
5
|
+
const sizes = {
|
|
6
|
+
sm: "min-h-(--control-h-sm) gap-1.5 px-3 text-[13px]",
|
|
7
|
+
default: "min-h-(--control-h) gap-2 px-4 text-sm",
|
|
8
|
+
icon: "size-(--icon-button) rounded-full p-0",
|
|
9
|
+
"icon-sm": "size-(--control-h-sm) rounded-full p-0",
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Toggle — a raised button that stays pressed. Off, it is the quiet raised surface with soft
|
|
13
|
+
* ink, and hover only brightens the ink. On, it sinks into the surface: the hover fill, a deeper inset shadow, the
|
|
14
|
+
* `--control-focus` edge of a current item and full foreground ink. Never a colour fill or
|
|
15
|
+
* layout movement.
|
|
16
|
+
*
|
|
17
|
+
* Use it for a single on/off tool ("Show grid", bold, pin). For a choice between options use
|
|
18
|
+
* `ToggleGroup`; for a form value use `Checkbox` or `Switch`. Icon sizes are circular and need
|
|
19
|
+
* an `aria-label` — and keep that label constant; the pressed state is announced separately.
|
|
20
|
+
*/
|
|
21
|
+
export function Toggle({ size = "default", className, ...props }) {
|
|
22
|
+
return (_jsx(BaseToggle, { "data-slot": "toggle", "data-size": size, className: sx([
|
|
23
|
+
// The raised material, written out: the shared utility fills on hover, which would
|
|
24
|
+
// read as "on". Hover here only brightens the ink; the pressed inset lives in controls.css.
|
|
25
|
+
"inline-flex shrink-0 cursor-pointer items-center justify-center rounded-button border border-transparent bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent font-body leading-none font-medium whitespace-nowrap shadow-raised focus-ring select-none",
|
|
26
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
27
|
+
// Off is the quiet raised surface with soft ink; on sinks in behind the focus-grey edge.
|
|
28
|
+
"text-foreground-soft hover:not-data-disabled:text-foreground",
|
|
29
|
+
"data-pressed:bg-control-hover data-pressed:text-foreground data-pressed:shadow-(--toggle-shadow-pressed)",
|
|
30
|
+
// Only a natively disabled toggle ignores the pointer; drawn by a ToolbarButton it stays
|
|
31
|
+
// focusable while disabled and still takes hover, so a tooltip can say why.
|
|
32
|
+
"disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
33
|
+
sizes[size],
|
|
34
|
+
], className), ...props }));
|
|
35
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Collapsible as BaseCollapsible } from "@base-ui/react/collapsible";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
/** Where a tool call is: queued, running, finished, or failed. */
|
|
4
|
+
export type ToolCallStatus = "pending" | "running" | "completed" | "error";
|
|
5
|
+
/** The status labels by status, and the headings of ToolCallInput and ToolCallOutput. */
|
|
6
|
+
export interface ToolCallMessages extends Record<ToolCallStatus, string> {
|
|
7
|
+
/** ToolCallInput's heading. */
|
|
8
|
+
parameters: string;
|
|
9
|
+
/** ToolCallOutput's heading. */
|
|
10
|
+
result: string;
|
|
11
|
+
/** ToolCallOutput's heading when the call failed. */
|
|
12
|
+
failure: string;
|
|
13
|
+
}
|
|
14
|
+
declare module "./locale" {
|
|
15
|
+
interface Messages {
|
|
16
|
+
toolCall: ToolCallMessages;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export interface ToolCallProps extends Omit<BaseCollapsible.Root.Props, "children"> {
|
|
20
|
+
/** The tool's name as the model called it, shown in mono: `search_orders`. */
|
|
21
|
+
name: string;
|
|
22
|
+
status: ToolCallStatus;
|
|
23
|
+
/** A 14px icon before the name. Default: a wrench. */
|
|
24
|
+
icon?: React.ReactNode;
|
|
25
|
+
/** Status labels, e.g. for another language. A LocaleProvider sets them for every ToolCall. */
|
|
26
|
+
labels?: Partial<ToolCallMessages>;
|
|
27
|
+
/** Colour the parameters and the result as code — JSON for objects — in the zon theme. Default `true`. */
|
|
28
|
+
highlight?: boolean;
|
|
29
|
+
/** `ToolCallInput` and `ToolCallOutput`. */
|
|
30
|
+
children?: React.ReactNode;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* ToolCall — a tool the model used, as a 20px card: the tool's name in mono, its status as a
|
|
34
|
+
* tag (a spinner while it runs, a green check when done, red on error), and, folded under it,
|
|
35
|
+
* what it was called with and what it returned.
|
|
36
|
+
*
|
|
37
|
+
* The rule people break: opening every tool call by default. Most readers want the answer;
|
|
38
|
+
* the calls are there to check it.
|
|
39
|
+
*/
|
|
40
|
+
export declare function ToolCall({ name, status, icon, labels, highlight, className, children, ...props }: ToolCallProps): React.JSX.Element;
|
|
41
|
+
export interface ToolCallInputProps {
|
|
42
|
+
/** What the tool was called with; objects show as JSON. */
|
|
43
|
+
input: unknown;
|
|
44
|
+
/** The heading. Default `Parameters`, or `messages.toolCall.parameters`. */
|
|
45
|
+
label?: React.ReactNode;
|
|
46
|
+
/** The language of a string `input`, e.g. `"bash"` for a command; objects are always JSON. */
|
|
47
|
+
language?: string;
|
|
48
|
+
}
|
|
49
|
+
/** What the model called the tool with, as a code block. */
|
|
50
|
+
export declare function ToolCallInput({ input, label, language }: ToolCallInputProps): React.JSX.Element;
|
|
51
|
+
export interface ToolCallOutputProps {
|
|
52
|
+
/** What the tool returned; objects show as JSON. Children replace it, e.g. a table. */
|
|
53
|
+
output?: unknown;
|
|
54
|
+
/** The error, when the call failed: shown in red with an icon instead of the output. */
|
|
55
|
+
errorText?: string;
|
|
56
|
+
/** The heading. Default `Result`, or `Error` (`messages.toolCall.result` and `failure`). */
|
|
57
|
+
label?: React.ReactNode;
|
|
58
|
+
/** The language of a string `output`, e.g. `"html"`; objects are always JSON. */
|
|
59
|
+
language?: string;
|
|
60
|
+
children?: React.ReactNode;
|
|
61
|
+
}
|
|
62
|
+
/** What the tool returned: a code block, your own rendering as children, or the error. */
|
|
63
|
+
export declare function ToolCallOutput({ output, errorText, label, language, children }: ToolCallOutputProps): React.JSX.Element;
|