@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,156 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { InputGroupAddon, type InputGroupButtonProps, type InputGroupTextareaProps } from "./input-group.js";
|
|
3
|
+
export interface PromptInputMessages {
|
|
4
|
+
/** The textarea's placeholder. */
|
|
5
|
+
placeholder: string;
|
|
6
|
+
/** PromptInputSubmit, ready to send. */
|
|
7
|
+
send: string;
|
|
8
|
+
/** PromptInputSubmit while a reply streams in and it can be stopped. */
|
|
9
|
+
stop: string;
|
|
10
|
+
/** PromptInputSubmit after sending, before the reply. */
|
|
11
|
+
waiting: string;
|
|
12
|
+
/** PromptInputAttachButton's name. */
|
|
13
|
+
attach: string;
|
|
14
|
+
/** An attachment with no name of its own. */
|
|
15
|
+
attachment: string;
|
|
16
|
+
/** An attachment's remove button. */
|
|
17
|
+
removeAttachment: (name: string) => string;
|
|
18
|
+
/** An image attachment's thumbnail, which opens the preview. */
|
|
19
|
+
previewAttachment: (name: string) => string;
|
|
20
|
+
}
|
|
21
|
+
declare module "./locale" {
|
|
22
|
+
interface Messages {
|
|
23
|
+
promptInput: PromptInputMessages;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Where the reply is: `ready` (nothing running), `submitted` (sent, nothing back yet),
|
|
28
|
+
* `streaming` (the reply is coming in) or `error` (the last one failed; the prompt can be sent again).
|
|
29
|
+
*/
|
|
30
|
+
export type PromptInputStatus = "ready" | "submitted" | "streaming" | "error";
|
|
31
|
+
/** `inline`: one line, tools and send beside the text. `stacked`: the text above, the toolbar below. */
|
|
32
|
+
export type PromptInputLayout = "inline" | "stacked";
|
|
33
|
+
export interface PromptInputProps extends Omit<React.ComponentProps<"form">, "onSubmit" | "defaultValue" | "children"> {
|
|
34
|
+
/** The prompt text, when controlled. */
|
|
35
|
+
value?: string;
|
|
36
|
+
/** The starting text, when uncontrolled. */
|
|
37
|
+
defaultValue?: string;
|
|
38
|
+
onValueChange?: (value: string) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Called with the trimmed prompt when it is sent (the submit button, or Enter in the textarea).
|
|
41
|
+
* Uncontrolled, the field clears itself afterwards; controlled, clear it yourself.
|
|
42
|
+
*/
|
|
43
|
+
onSubmit?: (value: string, event: React.FormEvent<HTMLFormElement>) => void;
|
|
44
|
+
/**
|
|
45
|
+
* The reply's state. `submitted` shows a spinner and `streaming` a stop square; with `onStop`
|
|
46
|
+
* both are the Stop button, without it the button waits, disabled. Default `ready`.
|
|
47
|
+
*/
|
|
48
|
+
status?: PromptInputStatus;
|
|
49
|
+
/** Called by the stop button while `status` is `submitted` or `streaming`. */
|
|
50
|
+
onStop?: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Files pasted into the prompt or dropped on the bar. Set it to accept them; screenshots pasted
|
|
53
|
+
* with ⌘V / Ctrl+V arrive here as image files.
|
|
54
|
+
*/
|
|
55
|
+
onFiles?: (files: File[]) => void;
|
|
56
|
+
/** Allow sending with no text, e.g. when files are attached. */
|
|
57
|
+
allowEmpty?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Always stacked: the text on its own row, the tools and send under it. For a bar with more
|
|
60
|
+
* tools than one line has room for (a model picker, modes). Without it the bar is one line
|
|
61
|
+
* until the text needs more — or until there is too little room for the text beside the tools.
|
|
62
|
+
*/
|
|
63
|
+
stacked?: boolean;
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
children?: React.ReactNode;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* PromptInput — the prompt bar of an AI chat. It starts as one 38px line: tools on the left, the
|
|
69
|
+
* text, and the round send button on the right. The moment the text would run into the send
|
|
70
|
+
* button, or gets a second line, the bar morphs: it grows, the text takes the full width, and
|
|
71
|
+
* the tools and send button glide down into a toolbar. Empty, or short enough again, it morphs
|
|
72
|
+
* back. Enter sends; Shift+Enter adds a line.
|
|
73
|
+
*
|
|
74
|
+
* Compose: `PromptInput` → `PromptInputHeader` (`PromptInputAttachment`s) · `PromptInputTextarea` ·
|
|
75
|
+
* `PromptInputToolbar` → `PromptInputTools` (`PromptInputButton`s, `PromptInputAttachButton`) +
|
|
76
|
+
* `PromptInputSubmit`. With `onFiles` it also takes pasted screenshots and dropped files.
|
|
77
|
+
* The rule people break: a second primary button in the bar. Send is the one action; tools are ghost.
|
|
78
|
+
*/
|
|
79
|
+
export declare function PromptInput({ value: valueProp, defaultValue, onValueChange, onSubmit, status, onStop, onFiles, allowEmpty, stacked, disabled, className, children, ref, onDragOver, onDragLeave, onDrop, ...props }: PromptInputProps): React.JSX.Element;
|
|
80
|
+
/** A row above the text, for `PromptInputAttachment`s. */
|
|
81
|
+
export declare function PromptInputHeader({ className, ...props }: React.ComponentProps<typeof InputGroupAddon>): React.JSX.Element;
|
|
82
|
+
export interface PromptInputAttachmentProps extends Omit<React.ComponentProps<"div">, "children"> {
|
|
83
|
+
/** The attached file. Images show a preview; anything else a mono chip with the name. */
|
|
84
|
+
file?: File;
|
|
85
|
+
/** The file's name. Defaults to `file.name`. */
|
|
86
|
+
name?: string;
|
|
87
|
+
/** An image to preview instead of reading `file`, e.g. a URL the upload returned. */
|
|
88
|
+
src?: string;
|
|
89
|
+
/** The MIME type, when there is no `file`. Images (`image/…`) show a preview. */
|
|
90
|
+
type?: string;
|
|
91
|
+
/** Shows a remove button. */
|
|
92
|
+
onRemove?: () => void;
|
|
93
|
+
/**
|
|
94
|
+
* Accessible names. Defaults: `Remove <name>`, `Preview <name>` — `messages.promptInput`
|
|
95
|
+
* `removeAttachment` and `previewAttachment` from a LocaleProvider.
|
|
96
|
+
*/
|
|
97
|
+
labels?: {
|
|
98
|
+
remove?: string;
|
|
99
|
+
preview?: string;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* A file attached to the prompt. An image — a pasted screenshot, a PNG — shows as a 56px
|
|
104
|
+
* thumbnail that opens a larger preview; anything else, a PDF or a spreadsheet, as a raised mono
|
|
105
|
+
* key with its name. Both have a remove button.
|
|
106
|
+
*/
|
|
107
|
+
export declare function PromptInputAttachment({ file, name: nameProp, src, type, onRemove, labels, className, ...props }: PromptInputAttachmentProps): React.JSX.Element;
|
|
108
|
+
export interface PromptInputAttachButtonProps extends Omit<InputGroupButtonProps, "onClick" | "children" | "type"> {
|
|
109
|
+
/** Called with the files picked. */
|
|
110
|
+
onFiles: (files: File[]) => void;
|
|
111
|
+
/** File types to offer, as for `<input type="file">`: `"image/*,.pdf"`. */
|
|
112
|
+
accept?: string;
|
|
113
|
+
/** Allow picking several files. Default `true`. */
|
|
114
|
+
multiple?: boolean;
|
|
115
|
+
/** Accessible name. Default `Attach files` (`messages.promptInput.attach`). */
|
|
116
|
+
label?: string;
|
|
117
|
+
}
|
|
118
|
+
/** A ghost paperclip that opens the file picker. */
|
|
119
|
+
export declare function PromptInputAttachButton({ onFiles, accept, multiple, label, disabled, ...props }: PromptInputAttachButtonProps): React.JSX.Element;
|
|
120
|
+
export interface PromptInputTextareaProps extends Omit<InputGroupTextareaProps, "value" | "defaultValue" | "ref"> {
|
|
121
|
+
ref?: React.Ref<HTMLTextAreaElement>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The prompt itself: one line while it fits, then a borderless textarea that grows with its
|
|
125
|
+
* content up to 240px and scrolls. Enter sends; Shift+Enter adds a line, and the Enter that
|
|
126
|
+
* confirms an input method's text does not send. Pasted files go to the bar's `onFiles`.
|
|
127
|
+
*/
|
|
128
|
+
export declare function PromptInputTextarea({ className, ref, onChange, onKeyDown, onPaste, placeholder: placeholderProp, ...props }: PromptInputTextareaProps): React.JSX.Element;
|
|
129
|
+
/**
|
|
130
|
+
* The tools and the send button. On one line they sit either side of the text; stacked, they
|
|
131
|
+
* form the row under it.
|
|
132
|
+
*/
|
|
133
|
+
export declare function PromptInputToolbar({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
134
|
+
/** A group of tool buttons and selects at the start of the toolbar. */
|
|
135
|
+
export interface PromptInputToolsProps extends React.ComponentProps<"div"> {
|
|
136
|
+
/**
|
|
137
|
+
* `start` (default): the tools at the start of the toolbar. `end`: beside the send button — for
|
|
138
|
+
* a model picker or a mode, under the text when the bar is stacked.
|
|
139
|
+
*/
|
|
140
|
+
side?: "start" | "end";
|
|
141
|
+
}
|
|
142
|
+
export declare function PromptInputTools({ side, className, ...props }: PromptInputToolsProps): React.JSX.Element;
|
|
143
|
+
/** A tool in the toolbar (attach, search, a mode): ghost and 30px. Icon-only ones need `aria-label`. */
|
|
144
|
+
export declare function PromptInputButton({ variant, size, children, ...props }: InputGroupButtonProps): React.JSX.Element;
|
|
145
|
+
export interface PromptInputSubmitProps extends Omit<InputGroupButtonProps, "children"> {
|
|
146
|
+
/**
|
|
147
|
+
* Accessible names. Defaults: `Send`, `Stop`, `Waiting for the reply`; a LocaleProvider sets
|
|
148
|
+
* them for every PromptInputSubmit (`messages.promptInput`).
|
|
149
|
+
*/
|
|
150
|
+
labels?: Partial<Pick<PromptInputMessages, "send" | "stop" | "waiting">>;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The send button: round, primary, an arrow. While the reply is on its way it shows a spinner,
|
|
154
|
+
* then a stop square that calls `onStop`; it is disabled while the prompt is empty.
|
|
155
|
+
*/
|
|
156
|
+
export declare function PromptInputSubmit({ labels, className, onClick, ...props }: PromptInputSubmitProps): React.JSX.Element;
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ArrowUpIcon, FileTextIcon, PaperclipIcon, SquareIcon, XIcon } from "lucide-react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { cssDuration } from "../lib/motion.js";
|
|
7
|
+
import { mergeRefs } from "../lib/merge-refs.js";
|
|
8
|
+
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "./dialog.js";
|
|
9
|
+
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupTextarea, } from "./input-group.js";
|
|
10
|
+
import { useMessages } from "./locale.js";
|
|
11
|
+
import { Spinner } from "./spinner.js";
|
|
12
|
+
const defaultMessages = {
|
|
13
|
+
placeholder: "Ask anything",
|
|
14
|
+
send: "Send",
|
|
15
|
+
stop: "Stop",
|
|
16
|
+
waiting: "Waiting for the reply",
|
|
17
|
+
attach: "Attach files",
|
|
18
|
+
attachment: "Attachment",
|
|
19
|
+
removeAttachment: (name) => `Remove ${name}`,
|
|
20
|
+
previewAttachment: (name) => `Preview ${name}`,
|
|
21
|
+
};
|
|
22
|
+
const PromptInputContext = React.createContext(null);
|
|
23
|
+
function usePromptInput(part) {
|
|
24
|
+
const context = React.useContext(PromptInputContext);
|
|
25
|
+
if (!context)
|
|
26
|
+
throw new Error(`${part} must be used inside <PromptInput>.`);
|
|
27
|
+
return context;
|
|
28
|
+
}
|
|
29
|
+
/* ── Motion helpers ────────────────────────────────────────────────────────── */
|
|
30
|
+
const reducedMotion = () => typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
31
|
+
/**
|
|
32
|
+
* The morph's timing: twice `--duration` (300ms) on an ease-out milder than the brand's, which would
|
|
33
|
+
* front-load a glide this size into one frame, so the bar is seen to grow and settle; none under
|
|
34
|
+
* reduced motion.
|
|
35
|
+
*/
|
|
36
|
+
function morphTiming() {
|
|
37
|
+
if (typeof document === "undefined" || reducedMotion())
|
|
38
|
+
return null;
|
|
39
|
+
const duration = cssDuration() * 2;
|
|
40
|
+
if (!duration)
|
|
41
|
+
return null;
|
|
42
|
+
return { duration, easing: "cubic-bezier(0.33, 1, 0.68, 1)" };
|
|
43
|
+
}
|
|
44
|
+
let measureContext;
|
|
45
|
+
/** The width of `text` on one line in the textarea's own font. */
|
|
46
|
+
function lineWidth(text, el) {
|
|
47
|
+
measureContext ??= document.createElement("canvas").getContext("2d");
|
|
48
|
+
if (!measureContext)
|
|
49
|
+
return 0;
|
|
50
|
+
const cs = getComputedStyle(el);
|
|
51
|
+
measureContext.font = `${cs.fontStyle} ${cs.fontWeight} ${cs.fontSize} ${cs.fontFamily}`;
|
|
52
|
+
const spacing = parseFloat(cs.letterSpacing) || 0;
|
|
53
|
+
return measureContext.measureText(text).width + spacing * text.length;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Where a part's content starts — its box plus its padding. The layouts pad the text and the
|
|
57
|
+
* toolbar differently, so the morph moves what is seen from where it was seen, not the box.
|
|
58
|
+
*/
|
|
59
|
+
function contentOrigin(el) {
|
|
60
|
+
const rect = el.getBoundingClientRect();
|
|
61
|
+
const cs = getComputedStyle(el);
|
|
62
|
+
return { left: rect.left + parseFloat(cs.paddingLeft), top: rect.top + parseFloat(cs.paddingTop) };
|
|
63
|
+
}
|
|
64
|
+
/** Text no wider than the room by this much more goes back to one line, so it never flickers at the edge. */
|
|
65
|
+
const RETURN_PX = 16;
|
|
66
|
+
/** Less room than this for the text on one line (a phone, a bar full of tools) and the bar stays stacked. */
|
|
67
|
+
const MIN_ROOM = 160;
|
|
68
|
+
const imageName = (name) => /\.(png|jpe?g|gif|webp|avif|svg)$/i.test(name);
|
|
69
|
+
/** An event that reached the bar through a React portal (the dialog an attachment opened). */
|
|
70
|
+
const fromPortal = (event) => !event.currentTarget.contains(event.target);
|
|
71
|
+
/**
|
|
72
|
+
* PromptInput — the prompt bar of an AI chat. It starts as one 38px line: tools on the left, the
|
|
73
|
+
* text, and the round send button on the right. The moment the text would run into the send
|
|
74
|
+
* button, or gets a second line, the bar morphs: it grows, the text takes the full width, and
|
|
75
|
+
* the tools and send button glide down into a toolbar. Empty, or short enough again, it morphs
|
|
76
|
+
* back. Enter sends; Shift+Enter adds a line.
|
|
77
|
+
*
|
|
78
|
+
* Compose: `PromptInput` → `PromptInputHeader` (`PromptInputAttachment`s) · `PromptInputTextarea` ·
|
|
79
|
+
* `PromptInputToolbar` → `PromptInputTools` (`PromptInputButton`s, `PromptInputAttachButton`) +
|
|
80
|
+
* `PromptInputSubmit`. With `onFiles` it also takes pasted screenshots and dropped files.
|
|
81
|
+
* The rule people break: a second primary button in the bar. Send is the one action; tools are ghost.
|
|
82
|
+
*/
|
|
83
|
+
export function PromptInput({ value: valueProp, defaultValue = "", onValueChange, onSubmit, status = "ready", onStop, onFiles, allowEmpty = false, stacked = false, disabled = false, className, children, ref, onDragOver, onDragLeave, onDrop, ...props }) {
|
|
84
|
+
const [own, setOwn] = React.useState(defaultValue);
|
|
85
|
+
// `null` (a draft not loaded yet) counts as no value, as it does on React's own fields.
|
|
86
|
+
const controlled = valueProp != null;
|
|
87
|
+
const value = controlled ? valueProp : own;
|
|
88
|
+
const formRef = React.useRef(null);
|
|
89
|
+
const formRefs = React.useMemo(() => mergeRefs(formRef, ref), [ref]);
|
|
90
|
+
const groupRef = React.useRef(null);
|
|
91
|
+
const textareaRef = React.useRef(null);
|
|
92
|
+
const [dragging, setDragging] = React.useState(false);
|
|
93
|
+
const setValue = React.useCallback((next) => {
|
|
94
|
+
if (!controlled)
|
|
95
|
+
setOwn(next);
|
|
96
|
+
onValueChange?.(next);
|
|
97
|
+
}, [controlled, onValueChange]);
|
|
98
|
+
/* ── The morph between one line and the stacked bar (FLIP) ── */
|
|
99
|
+
const [layout, setLayout] = React.useState(stacked ? "stacked" : "inline");
|
|
100
|
+
const layoutRef = React.useRef(layout);
|
|
101
|
+
layoutRef.current = layout;
|
|
102
|
+
/** Group width minus the text's room, read while inline: gives the inline room at any width. */
|
|
103
|
+
const chrome = React.useRef(null);
|
|
104
|
+
const first = React.useRef(null);
|
|
105
|
+
const running = React.useRef([]);
|
|
106
|
+
/** The morph now playing: an older one that ends late must not undo this one's settings. */
|
|
107
|
+
const morphing = React.useRef(0);
|
|
108
|
+
const mounted = React.useRef(false);
|
|
109
|
+
const morph = React.useCallback((next, animate) => {
|
|
110
|
+
if (next === layoutRef.current)
|
|
111
|
+
return;
|
|
112
|
+
const group = groupRef.current;
|
|
113
|
+
if (group && animate) {
|
|
114
|
+
// Read where everything is drawn now (mid-morph included), before the layout changes.
|
|
115
|
+
first.current = {
|
|
116
|
+
box: group.getBoundingClientRect(),
|
|
117
|
+
parts: new Map([...group.querySelectorAll("[data-morph]")].map((el) => [el, contentOrigin(el)])),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
layoutRef.current = next;
|
|
121
|
+
setLayout(next);
|
|
122
|
+
}, []);
|
|
123
|
+
/** One line or stacked, for the text as it is now. */
|
|
124
|
+
const decide = React.useCallback((animate) => {
|
|
125
|
+
const group = groupRef.current;
|
|
126
|
+
const textarea = textareaRef.current;
|
|
127
|
+
if (!group || !textarea)
|
|
128
|
+
return;
|
|
129
|
+
if (layoutRef.current === "inline") {
|
|
130
|
+
const cs = getComputedStyle(textarea);
|
|
131
|
+
const room = textarea.clientWidth - parseFloat(cs.paddingLeft) - parseFloat(cs.paddingRight);
|
|
132
|
+
chrome.current = group.clientWidth - room;
|
|
133
|
+
}
|
|
134
|
+
if (stacked)
|
|
135
|
+
return morph("stacked", animate);
|
|
136
|
+
// Too little room beside the tools: stacked, even empty.
|
|
137
|
+
if (chrome.current != null && group.clientWidth - chrome.current < MIN_ROOM)
|
|
138
|
+
return morph("stacked", animate);
|
|
139
|
+
const text = textarea.value;
|
|
140
|
+
if (!text)
|
|
141
|
+
return morph("inline", animate);
|
|
142
|
+
if (text.includes("\n"))
|
|
143
|
+
return morph("stacked", animate);
|
|
144
|
+
if (chrome.current == null)
|
|
145
|
+
return;
|
|
146
|
+
const room = group.clientWidth - chrome.current;
|
|
147
|
+
// A long paste is wider than any bar long before its end: measuring all of it (a megabyte
|
|
148
|
+
// of log) would hold up every keystroke after it.
|
|
149
|
+
const width = lineWidth(text.slice(0, 2000), textarea);
|
|
150
|
+
if (layoutRef.current === "inline" && width > room)
|
|
151
|
+
morph("stacked", animate);
|
|
152
|
+
else if (layoutRef.current === "stacked" && width < room - RETURN_PX)
|
|
153
|
+
morph("inline", animate);
|
|
154
|
+
}, [morph, stacked]);
|
|
155
|
+
// Every change of the text: decide before the frame paints. The first decision does not animate.
|
|
156
|
+
React.useLayoutEffect(() => {
|
|
157
|
+
decide(mounted.current);
|
|
158
|
+
mounted.current = true;
|
|
159
|
+
}, [value, decide]);
|
|
160
|
+
// The width changes the room: decide again, without the morph.
|
|
161
|
+
React.useEffect(() => {
|
|
162
|
+
const group = groupRef.current;
|
|
163
|
+
if (!group)
|
|
164
|
+
return;
|
|
165
|
+
const resize = new ResizeObserver(() => decide(false));
|
|
166
|
+
resize.observe(group);
|
|
167
|
+
return () => resize.disconnect();
|
|
168
|
+
}, [decide]);
|
|
169
|
+
// Play the morph: the bar's height, and each part from where it was to where it is now.
|
|
170
|
+
React.useLayoutEffect(() => {
|
|
171
|
+
const from = first.current;
|
|
172
|
+
first.current = null;
|
|
173
|
+
const group = groupRef.current;
|
|
174
|
+
const timing = morphTiming();
|
|
175
|
+
if (!from || !group || !timing)
|
|
176
|
+
return;
|
|
177
|
+
for (const a of running.current)
|
|
178
|
+
a.cancel();
|
|
179
|
+
running.current = [];
|
|
180
|
+
// The text wraps as the new layout does before anything is measured: its final height sets the bar's.
|
|
181
|
+
const control = group.querySelector("[data-slot=input-group-control]");
|
|
182
|
+
if (control)
|
|
183
|
+
control.wrap = layout === "inline" ? "off" : "soft";
|
|
184
|
+
// Every part's new place, read before the bar's height starts playing: that resizes the bar
|
|
185
|
+
// at once, and on a page that centres it, moves it.
|
|
186
|
+
const box = group.getBoundingClientRect();
|
|
187
|
+
const moves = [];
|
|
188
|
+
for (const [el, was] of from.parts) {
|
|
189
|
+
if (!el.isConnected)
|
|
190
|
+
continue;
|
|
191
|
+
const now = contentOrigin(el);
|
|
192
|
+
const dx = was.left - from.box.left - (now.left - box.left);
|
|
193
|
+
const dy = was.top - from.box.top - (now.top - box.top);
|
|
194
|
+
if (Math.abs(dx) >= 0.5 || Math.abs(dy) >= 0.5)
|
|
195
|
+
moves.push([el, dx, dy]);
|
|
196
|
+
}
|
|
197
|
+
// While the bar's height plays, its contents keep their final layout: rows packed at the top
|
|
198
|
+
// (data-morphing) and the text at its final height, so nothing is squeezed, scrolled or
|
|
199
|
+
// floated — the bar opens and closes around them, clipped.
|
|
200
|
+
const id = ++morphing.current;
|
|
201
|
+
group.style.overflow = "clip";
|
|
202
|
+
group.dataset.morphing = "";
|
|
203
|
+
if (control)
|
|
204
|
+
control.style.minHeight = `${control.offsetHeight}px`;
|
|
205
|
+
const settle = () => {
|
|
206
|
+
if (id !== morphing.current)
|
|
207
|
+
return;
|
|
208
|
+
group.style.overflow = "";
|
|
209
|
+
delete group.dataset.morphing;
|
|
210
|
+
if (control)
|
|
211
|
+
control.style.minHeight = "";
|
|
212
|
+
};
|
|
213
|
+
const grow = group.animate([{ height: `${from.box.height}px` }, { height: `${box.height}px` }], timing);
|
|
214
|
+
running.current.push(grow);
|
|
215
|
+
grow.finished.then(settle, settle);
|
|
216
|
+
for (const [el, dx, dy] of moves)
|
|
217
|
+
running.current.push(el.animate([{ translate: `${dx}px ${dy}px` }, { translate: "0px 0px" }], timing));
|
|
218
|
+
}, [layout]);
|
|
219
|
+
React.useEffect(() => () => running.current.forEach((a) => a.cancel()), []);
|
|
220
|
+
const busy = status === "submitted" || status === "streaming";
|
|
221
|
+
const context = React.useMemo(() => ({
|
|
222
|
+
value,
|
|
223
|
+
setValue,
|
|
224
|
+
status,
|
|
225
|
+
disabled,
|
|
226
|
+
allowEmpty,
|
|
227
|
+
layout,
|
|
228
|
+
onStop,
|
|
229
|
+
onFiles,
|
|
230
|
+
submit: () => formRef.current?.requestSubmit(),
|
|
231
|
+
textareaRef,
|
|
232
|
+
}), [value, setValue, status, disabled, allowEmpty, layout, onStop, onFiles]);
|
|
233
|
+
const takesFiles = onFiles != null && !disabled;
|
|
234
|
+
const hasFiles = (event) => event.dataTransfer.types.includes("Files");
|
|
235
|
+
return (_jsx(PromptInputContext.Provider, { value: context, children: _jsx("form", { ref: formRefs, "data-slot": "prompt-input", "data-status": status, "data-layout": layout, className: cn("w-full", className), onSubmit: (event) => {
|
|
236
|
+
event.preventDefault();
|
|
237
|
+
const text = value.trim();
|
|
238
|
+
if ((!text && !allowEmpty) || busy || disabled)
|
|
239
|
+
return;
|
|
240
|
+
onSubmit?.(text, event);
|
|
241
|
+
if (!controlled)
|
|
242
|
+
setValue("");
|
|
243
|
+
}, onDragOver: (event) => {
|
|
244
|
+
onDragOver?.(event);
|
|
245
|
+
if (!takesFiles || !hasFiles(event))
|
|
246
|
+
return;
|
|
247
|
+
event.preventDefault();
|
|
248
|
+
event.dataTransfer.dropEffect = "copy";
|
|
249
|
+
setDragging(true);
|
|
250
|
+
}, onDragLeave: (event) => {
|
|
251
|
+
onDragLeave?.(event);
|
|
252
|
+
if (!event.currentTarget.contains(event.relatedTarget))
|
|
253
|
+
setDragging(false);
|
|
254
|
+
}, onDrop: (event) => {
|
|
255
|
+
onDrop?.(event);
|
|
256
|
+
setDragging(false);
|
|
257
|
+
if (!takesFiles || !hasFiles(event))
|
|
258
|
+
return;
|
|
259
|
+
event.preventDefault();
|
|
260
|
+
const files = [...event.dataTransfer.files];
|
|
261
|
+
if (files.length)
|
|
262
|
+
onFiles(files);
|
|
263
|
+
}, ...props, children: _jsx(InputGroup, { ref: groupRef, "data-layout": layout, "data-dragging": dragging ? "" : undefined, className: "has-[>textarea]:min-h-0 data-dragging:border-control-focus", onMouseDown: (event) => {
|
|
264
|
+
// Empty space in the bar focuses the text, as on a native field — not a click in the
|
|
265
|
+
// preview dialog an attachment opened, which reaches here through React's portal.
|
|
266
|
+
if (fromPortal(event) ||
|
|
267
|
+
event.target.closest("button, a, input, textarea, select"))
|
|
268
|
+
return;
|
|
269
|
+
event.preventDefault();
|
|
270
|
+
textareaRef.current?.focus();
|
|
271
|
+
}, children: children }) }) }));
|
|
272
|
+
}
|
|
273
|
+
/* ── Attachments ───────────────────────────────────────────────────────────── */
|
|
274
|
+
/** A row above the text, for `PromptInputAttachment`s. */
|
|
275
|
+
export function PromptInputHeader({ className, ...props }) {
|
|
276
|
+
return (_jsx(InputGroupAddon, { "data-slot": "prompt-input-header", align: "block-start", className: cn("flex-wrap items-center gap-2 pb-0", className), ...props }));
|
|
277
|
+
}
|
|
278
|
+
/** The image a file or URL points to, as an object URL that is released when it is no longer shown. */
|
|
279
|
+
function usePreview(file, src, image) {
|
|
280
|
+
const [url, setUrl] = React.useState(src);
|
|
281
|
+
React.useEffect(() => {
|
|
282
|
+
if (src || !file || !image) {
|
|
283
|
+
setUrl(src);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const objectUrl = URL.createObjectURL(file);
|
|
287
|
+
setUrl(objectUrl);
|
|
288
|
+
return () => URL.revokeObjectURL(objectUrl);
|
|
289
|
+
}, [file, src, image]);
|
|
290
|
+
return url;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* A file attached to the prompt. An image — a pasted screenshot, a PNG — shows as a 56px
|
|
294
|
+
* thumbnail that opens a larger preview; anything else, a PDF or a spreadsheet, as a raised mono
|
|
295
|
+
* key with its name. Both have a remove button.
|
|
296
|
+
*/
|
|
297
|
+
export function PromptInputAttachment({ file, name: nameProp, src, type, onRemove, labels, className, ...props }) {
|
|
298
|
+
const text = useMessages("promptInput", defaultMessages);
|
|
299
|
+
const name = nameProp ?? file?.name ?? text.attachment;
|
|
300
|
+
const mime = type ?? file?.type;
|
|
301
|
+
// A picture with something to show: an image without its file or URL yet is a chip.
|
|
302
|
+
const image = (mime ? mime.startsWith("image/") : src != null || imageName(name)) && (src != null || file != null);
|
|
303
|
+
const url = usePreview(file, src, image);
|
|
304
|
+
// A 24px target, the inset size of a chip's remover. On a thumbnail it is a 20px raised disc on
|
|
305
|
+
// the corner, the target reaching a little past the disc.
|
|
306
|
+
const remove = onRemove && (_jsx("button", { type: "button", "data-slot": "prompt-input-attachment-remove", "aria-label": labels?.remove ?? text.removeAttachment(name), onClick: onRemove, className: cn("inline-flex size-(--control-inset-sm) shrink-0 cursor-pointer items-center justify-center rounded-full text-muted-foreground focus-ring transition-[background-color,color] duration-(--duration) ease-(--ease) hover:text-foreground", image ? "absolute -end-2 -top-2 z-10" : "hover:bg-control-hover"), children: image ? (_jsx("span", { className: "inline-flex size-5 items-center justify-center rounded-full material-raised", children: _jsx(XIcon, { "aria-hidden": true, className: "size-3" }) })) : (_jsx(XIcon, { "aria-hidden": true, className: "size-3.5" })) }));
|
|
307
|
+
if (image)
|
|
308
|
+
return (_jsxs("div", { "data-slot": "prompt-input-attachment", "data-kind": "image", className: cn("relative size-14 shrink-0", className), ...props, children: [_jsxs(Dialog, { children: [_jsx(DialogTrigger, { "aria-label": labels?.preview ?? text.previewAttachment(name), className: "block size-full cursor-zoom-in overflow-hidden rounded-item border border-field-edge bg-control-surface focus-ring", children: url && _jsx("img", { src: url, alt: "", draggable: false, className: "size-full object-cover" }) }), _jsxs(DialogContent, { size: "xl", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { className: "truncate font-mono text-sm", children: name }) }), url && (_jsx("img", { src: url, alt: name, className: "mx-auto block h-auto max-h-[min(70vh,calc(100dvh-12rem))] min-h-0 w-auto max-w-full rounded-item" }))] })] }), remove] }));
|
|
309
|
+
const Icon = mime === "application/pdf" || /\.pdf$/i.test(name) ? FileTextIcon : PaperclipIcon;
|
|
310
|
+
return (_jsxs("div", { "data-slot": "prompt-input-attachment", "data-kind": "file", className: cn("inline-flex min-h-(--control-inset-sm) max-w-56 items-center gap-1.5 rounded-item bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent ps-2 font-mono text-[11px] text-foreground shadow-key", onRemove ? "pe-0" : "pe-2", className), ...props, children: [_jsx(Icon, { "aria-hidden": true, className: "size-3 shrink-0 text-muted-foreground" }), _jsx("span", { className: "truncate", children: name }), remove] }));
|
|
311
|
+
}
|
|
312
|
+
/** A ghost paperclip that opens the file picker. */
|
|
313
|
+
export function PromptInputAttachButton({ onFiles, accept, multiple = true, label, disabled, ...props }) {
|
|
314
|
+
const text = useMessages("promptInput", defaultMessages);
|
|
315
|
+
const input = React.useRef(null);
|
|
316
|
+
const context = React.useContext(PromptInputContext);
|
|
317
|
+
return (_jsxs(_Fragment, { children: [_jsx(PromptInputButton, { "aria-label": label ?? text.attach, disabled: disabled ?? context?.disabled, onClick: () => input.current?.click(), ...props, children: _jsx(PaperclipIcon, {}) }), _jsx("input", { ref: input, type: "file", tabIndex: -1, "aria-hidden": true, hidden: true, accept: accept, multiple: multiple, onChange: (event) => {
|
|
318
|
+
const files = [...(event.currentTarget.files ?? [])];
|
|
319
|
+
event.currentTarget.value = "";
|
|
320
|
+
if (files.length)
|
|
321
|
+
onFiles(files);
|
|
322
|
+
} })] }));
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* The prompt itself: one line while it fits, then a borderless textarea that grows with its
|
|
326
|
+
* content up to 240px and scrolls. Enter sends; Shift+Enter adds a line, and the Enter that
|
|
327
|
+
* confirms an input method's text does not send. Pasted files go to the bar's `onFiles`.
|
|
328
|
+
*/
|
|
329
|
+
export function PromptInputTextarea({ className, ref, onChange, onKeyDown, onPaste, placeholder: placeholderProp, ...props }) {
|
|
330
|
+
const { value, setValue, submit, disabled, layout, onFiles, textareaRef } = usePromptInput("PromptInputTextarea");
|
|
331
|
+
const text = useMessages("promptInput", defaultMessages);
|
|
332
|
+
const placeholder = placeholderProp === undefined ? text.placeholder : placeholderProp;
|
|
333
|
+
const refs = React.useMemo(() => mergeRefs(textareaRef, ref), [textareaRef, ref]);
|
|
334
|
+
// One row, and no wrapping while the bar is one line (Base UI's control does not type these).
|
|
335
|
+
React.useLayoutEffect(() => {
|
|
336
|
+
const textarea = textareaRef.current;
|
|
337
|
+
if (!textarea)
|
|
338
|
+
return;
|
|
339
|
+
textarea.rows = 1;
|
|
340
|
+
textarea.wrap = layout === "inline" ? "off" : "soft";
|
|
341
|
+
}, [layout, textareaRef]);
|
|
342
|
+
// Where `field-sizing: content` is missing, grow with the text by hand; the max height still caps it.
|
|
343
|
+
React.useLayoutEffect(() => {
|
|
344
|
+
const textarea = textareaRef.current;
|
|
345
|
+
if (!textarea || typeof CSS === "undefined" || CSS.supports("field-sizing", "content"))
|
|
346
|
+
return;
|
|
347
|
+
textarea.style.height = "auto";
|
|
348
|
+
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
349
|
+
}, [value, layout, textareaRef]);
|
|
350
|
+
return (_jsxs(_Fragment, { children: [placeholder ? (_jsx("span", { "data-slot": "prompt-input-placeholder", "data-morph": "", "aria-hidden": "true", dir: props.dir, className: "font-body text-base sm:text-[15px]", children: placeholder })) : null, _jsx(InputGroupTextarea
|
|
351
|
+
// Base UI types the control's ref as an input; it renders the textarea here.
|
|
352
|
+
, {
|
|
353
|
+
// Base UI types the control's ref as an input; it renders the textarea here.
|
|
354
|
+
ref: refs, "data-morph": "", name: "prompt", value: value, placeholder: placeholder, disabled: disabled, onChange: (event) => {
|
|
355
|
+
onChange?.(event);
|
|
356
|
+
setValue(event.currentTarget.value);
|
|
357
|
+
}, onPaste: (event) => {
|
|
358
|
+
onPaste?.(event);
|
|
359
|
+
const data = event.clipboardData;
|
|
360
|
+
if (event.defaultPrevented || !onFiles || !data.files.length)
|
|
361
|
+
return;
|
|
362
|
+
// Copied text — plain and rich together — pastes as text, though spreadsheets and word
|
|
363
|
+
// processors add a picture of it. Anything else with files (a screenshot, a copied image) attaches.
|
|
364
|
+
if (data.types.includes("text/plain") && data.types.includes("text/html"))
|
|
365
|
+
return;
|
|
366
|
+
event.preventDefault();
|
|
367
|
+
onFiles([...data.files]);
|
|
368
|
+
}, onKeyDown: (event) => {
|
|
369
|
+
onKeyDown?.(event);
|
|
370
|
+
if (event.defaultPrevented)
|
|
371
|
+
return;
|
|
372
|
+
// Not the Enter that confirms an input method's text: Safari ends the composition before
|
|
373
|
+
// that keydown, which then shows only as key code 229.
|
|
374
|
+
const composing = event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229;
|
|
375
|
+
if (event.key === "Enter" && !event.shiftKey && !composing) {
|
|
376
|
+
event.preventDefault();
|
|
377
|
+
submit();
|
|
378
|
+
}
|
|
379
|
+
}, className: className, ...props })] }));
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* The tools and the send button. On one line they sit either side of the text; stacked, they
|
|
383
|
+
* form the row under it.
|
|
384
|
+
*/
|
|
385
|
+
export function PromptInputToolbar({ className, ...props }) {
|
|
386
|
+
return _jsx("div", { "data-slot": "prompt-input-toolbar", className: cn("contents", className), ...props });
|
|
387
|
+
}
|
|
388
|
+
export function PromptInputTools({ side = "start", className, ...props }) {
|
|
389
|
+
return (_jsx("div", { "data-slot": "prompt-input-tools", "data-side": side, "data-morph": "", className: cn("flex min-w-0 items-center gap-1", className), ...props }));
|
|
390
|
+
}
|
|
391
|
+
/** A tool in the toolbar (attach, search, a mode): ghost and 30px. Icon-only ones need `aria-label`. */
|
|
392
|
+
export function PromptInputButton({ variant = "ghost", size, children, ...props }) {
|
|
393
|
+
const icon = React.Children.count(children) === 1 && React.isValidElement(children);
|
|
394
|
+
return (_jsx(InputGroupButton, { type: "button", variant: variant, size: size ?? (icon ? "icon" : "default"), ...props, children: children }));
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* The send button: round, primary, an arrow. While the reply is on its way it shows a spinner,
|
|
398
|
+
* then a stop square that calls `onStop`; it is disabled while the prompt is empty.
|
|
399
|
+
*/
|
|
400
|
+
export function PromptInputSubmit({ labels, className, onClick, ...props }) {
|
|
401
|
+
const { value, status, disabled, allowEmpty, onStop } = usePromptInput("PromptInputSubmit");
|
|
402
|
+
const busy = status === "submitted" || status === "streaming";
|
|
403
|
+
const stop = busy && onStop != null;
|
|
404
|
+
const text = useMessages("promptInput", defaultMessages, labels);
|
|
405
|
+
const label = stop ? text.stop : busy ? text.waiting : text.send;
|
|
406
|
+
return (_jsx("span", { "data-slot": "prompt-input-submit", "data-morph": "", className: "flex", children: _jsx(InputGroupButton, { "data-status": status, variant: "primary", size: "icon", type: stop ? "button" : "submit", "aria-label": label, disabled: disabled || (busy ? !stop : !allowEmpty && value.trim() === ""), onClick: (event) => {
|
|
407
|
+
onClick?.(event);
|
|
408
|
+
if (!stop || event.defaultPrevented)
|
|
409
|
+
return;
|
|
410
|
+
// Stopping re-renders this button as Send before the click's default action runs:
|
|
411
|
+
// cancel it, or the form would send whatever is in the prompt.
|
|
412
|
+
event.preventDefault();
|
|
413
|
+
onStop();
|
|
414
|
+
}, className: className, ...props, children: status === "streaming" && stop ? (_jsx(SquareIcon, { "aria-hidden": true, className: "size-3 fill-current" })) : busy ? (_jsx(Spinner, { size: "sm", "aria-hidden": true })) : (_jsx(ArrowUpIcon, { "aria-hidden": true })) }) }));
|
|
415
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
export interface QuoteProps extends Omit<ComponentProps<"figure">, "children"> {
|
|
3
|
+
/** The quote itself, set in Licht. Real words from a real person only. */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** Who said it. */
|
|
6
|
+
author?: ReactNode;
|
|
7
|
+
/** Their role and organisation, e.g. `Editor, Organisation`. */
|
|
8
|
+
byline?: ReactNode;
|
|
9
|
+
/** A small single-colour logo or mark, in the current ink, beside the attribution. */
|
|
10
|
+
logo?: ReactNode;
|
|
11
|
+
/** `cite` URL of the source, if the quote is published elsewhere. */
|
|
12
|
+
cite?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Quote — a quote card: an object on the page (the card material at 20px) holding a Licht
|
|
16
|
+
* quote, a mono attribution and an optional logo.
|
|
17
|
+
*
|
|
18
|
+
* The rule people break: inventing it. Never write a quote, a name or a logo that
|
|
19
|
+
* does not exist and is not approved for use. In drafts, use plain placeholder text
|
|
20
|
+
* ("Quote from a real customer goes here.") so nothing fictional can ship by accident.
|
|
21
|
+
*/
|
|
22
|
+
export declare function Quote({ author, byline, logo, cite, className, children, ...props }: QuoteProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
/**
|
|
5
|
+
* Quote — a quote card: an object on the page (the card material at 20px) holding a Licht
|
|
6
|
+
* quote, a mono attribution and an optional logo.
|
|
7
|
+
*
|
|
8
|
+
* The rule people break: inventing it. Never write a quote, a name or a logo that
|
|
9
|
+
* does not exist and is not approved for use. In drafts, use plain placeholder text
|
|
10
|
+
* ("Quote from a real customer goes here.") so nothing fictional can ship by accident.
|
|
11
|
+
*/
|
|
12
|
+
export function Quote({ author, byline, logo, cite, className, children, ...props }) {
|
|
13
|
+
const hasAttribution = author != null || byline != null || logo != null;
|
|
14
|
+
return (_jsxs("figure", { "data-slot": "quote", className: cn("m-0 flex w-full flex-col gap-8 surface-card break-words sm:gap-10", className), ...props, children: [_jsxs("blockquote", { cite: cite, className: "m-0 flex flex-col gap-4", children: [_jsx("span", { "aria-hidden": true, className: "font-heading text-[48px] leading-[0.6] font-light text-muted-foreground select-none", children: "\u201C" }), _jsx("div", { "data-slot": "quote-text", className: "font-heading text-[24px] leading-[1.25] font-light tracking-[-0.015em] text-pretty text-foreground sm:text-[28px] [&>p]:m-0 [&>p+p]:mt-4", children: children })] }), hasAttribution ? (_jsxs("figcaption", { "data-slot": "quote-attribution", className: "flex items-center justify-between gap-6 border-t border-border pt-5 font-mono text-xs leading-snug", children: [_jsxs("span", { className: "flex min-w-0 flex-col gap-1", children: [author != null ? _jsx("span", { className: "text-foreground", children: author }) : null, byline != null ? _jsx("span", { className: "text-muted-foreground", children: byline }) : null] }), logo != null ? (_jsx("span", { "data-slot": "quote-logo", className: "flex shrink-0 items-center text-foreground-soft [&_img]:h-6 [&_svg]:h-6 [&_svg]:w-auto", children: logo })) : null] })) : null] }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Radio as BaseRadio } from "@base-ui/react/radio";
|
|
2
|
+
import { RadioGroup as BaseRadioGroup } from "@base-ui/react/radio-group";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
/**
|
|
5
|
+
* RadioGroup — one choice from a short list where every option should stay visible.
|
|
6
|
+
*
|
|
7
|
+
* Render it through `<Fieldset render={<RadioGroup />}>` inside a `<Field name>` so the options
|
|
8
|
+
* share a legend and validation. For 2–5 short, comparable options consider `ToggleGroup`; past
|
|
9
|
+
* about seven options use `Select`. The rule people break: a radio group with nothing selected
|
|
10
|
+
* and no `required` — give it a sensible `defaultValue` or make the choice mandatory.
|
|
11
|
+
*/
|
|
12
|
+
export declare function RadioGroup<Value>({ className, ref, ...props }: BaseRadioGroup.Props<Value>): React.JSX.Element;
|
|
13
|
+
/**
|
|
14
|
+
* Radio — an 18px round control in the field material. Selected, it takes the primary fill
|
|
15
|
+
* with an inner dot. Always place it inside `<RadioGroup>` and next to a visible label
|
|
16
|
+
* (`<FieldLabel><Radio value="…" />Label</FieldLabel>`).
|
|
17
|
+
*/
|
|
18
|
+
export declare function Radio<Value>({ className, ...props }: BaseRadio.Root.Props<Value>): React.JSX.Element;
|