@justanarthur/modo-ui-ai 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSE.fluid-functionalism +21 -0
- package/README.md +105 -2
- package/blocks/conversation/agent-prompt/examples.mdx +44 -0
- package/blocks/conversation/agent-prompt/index.tsx +114 -0
- package/blocks/conversation/composer/draft.css +25 -0
- package/blocks/conversation/composer/draft.tsx +589 -0
- package/blocks/conversation/composer/examples.mdx +164 -0
- package/blocks/conversation/composer/file-preview-tile.tsx +59 -0
- package/blocks/conversation/composer/file-thumbnail.tsx +146 -0
- package/blocks/conversation/composer/index.tsx +651 -0
- package/blocks/conversation/composer/queued-row.tsx +102 -0
- package/blocks/conversation/composer/shared.ts +38 -0
- package/blocks/conversation/composer/suggestion-row.tsx +64 -0
- package/blocks/conversation/composer/use-composer-files.ts +142 -0
- package/blocks/conversation/composer/use-history-nav.ts +60 -0
- package/blocks/conversation/composer/use-message-queue.ts +108 -0
- package/blocks/conversation/composer/use-region-height.ts +34 -0
- package/blocks/conversation/failure-states/examples.mdx +58 -0
- package/blocks/conversation/failure-states/index.tsx +274 -0
- package/blocks/conversation/transcript/examples.mdx +43 -0
- package/blocks/conversation/transcript/index.tsx +206 -0
- package/blocks/conversation/transcript-search/examples.mdx +50 -0
- package/blocks/conversation/transcript-search/index.tsx +469 -0
- package/blocks/dialogs/command-palette/examples.mdx +50 -0
- package/blocks/dialogs/command-palette/index.tsx +239 -0
- package/blocks/dialogs/hook-dialog/examples.mdx +44 -0
- package/blocks/dialogs/hook-dialog/index.tsx +286 -0
- package/blocks/dialogs/mcp-server-dialog/examples.mdx +57 -0
- package/blocks/dialogs/mcp-server-dialog/index.tsx +415 -0
- package/blocks/dialogs/shortcuts-sheet/examples.mdx +36 -0
- package/blocks/dialogs/shortcuts-sheet/index.tsx +186 -0
- package/blocks/panes/artifacts-pane/examples.mdx +23 -0
- package/blocks/panes/artifacts-pane/index.tsx +82 -0
- package/blocks/panes/changes-pane/examples.mdx +23 -0
- package/blocks/panes/changes-pane/index.tsx +248 -0
- package/blocks/panes/file-pane/examples.mdx +13 -0
- package/blocks/panes/file-pane/index.tsx +102 -0
- package/blocks/panes/pr-pane/examples.mdx +13 -0
- package/blocks/panes/pr-pane/index.tsx +191 -0
- package/blocks/panes/side-pane/examples.mdx +58 -0
- package/blocks/panes/side-pane/index.tsx +187 -0
- package/blocks/panes/tasks-pane/examples.mdx +23 -0
- package/blocks/panes/tasks-pane/index.tsx +127 -0
- package/blocks/panes/terminal-pane/examples.mdx +13 -0
- package/blocks/panes/terminal-pane/index.tsx +99 -0
- package/blocks/panes/usage-pane/examples.mdx +23 -0
- package/blocks/panes/usage-pane/index.tsx +78 -0
- package/blocks/profiles/profile-onboarding/examples.mdx +80 -0
- package/blocks/profiles/profile-onboarding/index.tsx +580 -0
- package/blocks/profiles/profile-switcher/examples.mdx +29 -0
- package/blocks/profiles/profile-switcher/index.tsx +212 -0
- package/blocks/profiles/profile-usage/examples.mdx +41 -0
- package/blocks/profiles/profile-usage/index.tsx +141 -0
- package/blocks/sessions/inbox/examples.mdx +35 -0
- package/blocks/sessions/inbox/index.tsx +372 -0
- package/blocks/sessions/session-board/examples.mdx +34 -0
- package/blocks/sessions/session-board/index.tsx +570 -0
- package/blocks/sessions/session-sidebar/examples.mdx +93 -0
- package/blocks/sessions/session-sidebar/index.tsx +497 -0
- package/blocks/settings/extensions/examples.mdx +10 -0
- package/blocks/settings/extensions/index.tsx +72 -0
- package/blocks/settings/hooks/examples.mdx +16 -0
- package/blocks/settings/hooks/index.tsx +127 -0
- package/blocks/settings/mcp-servers/examples.mdx +26 -0
- package/blocks/settings/mcp-servers/index.tsx +204 -0
- package/blocks/settings/memory/examples.mdx +22 -0
- package/blocks/settings/memory/index.tsx +113 -0
- package/blocks/settings/notifications/examples.mdx +8 -0
- package/blocks/settings/notifications/index.tsx +63 -0
- package/blocks/settings/permission-rules/examples.mdx +37 -0
- package/blocks/settings/permission-rules/index.tsx +317 -0
- package/blocks/settings/plugin-catalog/examples.mdx +52 -0
- package/blocks/settings/plugin-catalog/index.tsx +407 -0
- package/blocks/settings/plugins/examples.mdx +10 -0
- package/blocks/settings/plugins/index.tsx +72 -0
- package/blocks/settings/settings-window/examples.mdx +40 -0
- package/blocks/settings/settings-window/index.tsx +188 -0
- package/blocks/settings/worktrees/examples.mdx +17 -0
- package/blocks/settings/worktrees/index.tsx +145 -0
- package/components/conversation/agent-run/examples.mdx +38 -0
- package/components/conversation/agent-run/index.tsx +83 -0
- package/components/conversation/chapter-nav/examples.mdx +30 -0
- package/components/conversation/chapter-nav/index.tsx +123 -0
- package/components/conversation/message/examples.mdx +53 -0
- package/components/conversation/message/index.tsx +130 -0
- package/components/conversation/message/working.tsx +102 -0
- package/components/conversation/reasoning/examples.mdx +32 -0
- package/components/conversation/reasoning/index.tsx +55 -0
- package/components/conversation/recap/examples.mdx +21 -0
- package/components/conversation/recap/index.tsx +67 -0
- package/components/conversation/todo-list/examples.mdx +32 -0
- package/components/conversation/todo-list/index.tsx +106 -0
- package/components/conversation/tool-call/examples.mdx +48 -0
- package/components/conversation/tool-call/index.tsx +142 -0
- package/components/conversation/work-summary/examples.mdx +50 -0
- package/components/conversation/work-summary/index.tsx +87 -0
- package/components/prompts/permission-request/examples.mdx +32 -0
- package/components/prompts/permission-request/index.tsx +74 -0
- package/components/prompts/plan-approval/examples.mdx +37 -0
- package/components/prompts/plan-approval/index.tsx +76 -0
- package/components/prompts/prompt-card/examples.mdx +31 -0
- package/components/prompts/prompt-card/index.tsx +82 -0
- package/components/prompts/question-prompt/examples.mdx +46 -0
- package/components/prompts/question-prompt/index.tsx +118 -0
- package/dist/blocks/conversation/agent-prompt/index.d.ts +7 -0
- package/dist/blocks/conversation/agent-prompt/index.js +13 -0
- package/dist/blocks/conversation/composer/index.d.ts +4 -0
- package/dist/blocks/conversation/composer/index.js +16 -0
- package/dist/blocks/conversation/failure-states/index.d.ts +4 -0
- package/dist/blocks/conversation/failure-states/index.js +8 -0
- package/dist/blocks/conversation/transcript/index.d.ts +50 -0
- package/dist/blocks/conversation/transcript/index.js +17 -0
- package/dist/blocks/conversation/transcript-search/index.d.ts +4 -0
- package/dist/blocks/conversation/transcript-search/index.js +11 -0
- package/dist/blocks/dialogs/command-palette/index.d.ts +5 -0
- package/dist/blocks/dialogs/command-palette/index.js +20 -0
- package/dist/blocks/dialogs/hook-dialog/index.d.ts +3 -0
- package/dist/blocks/dialogs/hook-dialog/index.js +12 -0
- package/dist/blocks/dialogs/mcp-server-dialog/index.d.ts +5 -0
- package/dist/blocks/dialogs/mcp-server-dialog/index.js +12 -0
- package/dist/blocks/dialogs/shortcuts-sheet/index.d.ts +2 -0
- package/dist/blocks/dialogs/shortcuts-sheet/index.js +11 -0
- package/dist/blocks/panes/artifacts-pane/index.d.ts +3 -0
- package/dist/blocks/panes/artifacts-pane/index.js +9 -0
- package/dist/blocks/panes/changes-pane/index.d.ts +3 -0
- package/dist/blocks/panes/changes-pane/index.js +9 -0
- package/dist/blocks/panes/file-pane/index.d.ts +3 -0
- package/dist/blocks/panes/file-pane/index.js +9 -0
- package/dist/blocks/panes/pr-pane/index.d.ts +3 -0
- package/dist/blocks/panes/pr-pane/index.js +10 -0
- package/dist/blocks/panes/side-pane/index.d.ts +5 -0
- package/dist/blocks/panes/side-pane/index.js +21 -0
- package/dist/blocks/panes/tasks-pane/index.d.ts +3 -0
- package/dist/blocks/panes/tasks-pane/index.js +10 -0
- package/dist/blocks/panes/terminal-pane/index.d.ts +3 -0
- package/dist/blocks/panes/terminal-pane/index.js +9 -0
- package/dist/blocks/panes/usage-pane/index.d.ts +4 -0
- package/dist/blocks/panes/usage-pane/index.js +11 -0
- package/dist/blocks/profiles/profile-onboarding/index.d.ts +4 -0
- package/dist/blocks/profiles/profile-onboarding/index.js +11 -0
- package/dist/blocks/profiles/profile-switcher/index.d.ts +4 -0
- package/dist/blocks/profiles/profile-switcher/index.js +12 -0
- package/dist/blocks/profiles/profile-usage/index.d.ts +4 -0
- package/dist/blocks/profiles/profile-usage/index.js +10 -0
- package/dist/blocks/sessions/inbox/index.d.ts +2 -0
- package/dist/blocks/sessions/inbox/index.js +11 -0
- package/dist/blocks/sessions/session-board/index.d.ts +4 -0
- package/dist/blocks/sessions/session-board/index.js +27 -0
- package/dist/blocks/sessions/session-sidebar/index.d.ts +5 -0
- package/dist/blocks/sessions/session-sidebar/index.js +15 -0
- package/dist/blocks/settings/extensions/index.d.ts +2 -0
- package/dist/blocks/settings/extensions/index.js +9 -0
- package/dist/blocks/settings/hooks/index.d.ts +4 -0
- package/dist/blocks/settings/hooks/index.js +9 -0
- package/dist/blocks/settings/mcp-servers/index.d.ts +4 -0
- package/dist/blocks/settings/mcp-servers/index.js +9 -0
- package/dist/blocks/settings/memory/index.d.ts +4 -0
- package/dist/blocks/settings/memory/index.js +8 -0
- package/dist/blocks/settings/notifications/index.d.ts +2 -0
- package/dist/blocks/settings/notifications/index.js +8 -0
- package/dist/blocks/settings/permission-rules/index.d.ts +3 -0
- package/dist/blocks/settings/permission-rules/index.js +10 -0
- package/dist/blocks/settings/plugin-catalog/index.d.ts +2 -0
- package/dist/blocks/settings/plugin-catalog/index.js +11 -0
- package/dist/blocks/settings/plugins/index.d.ts +4 -0
- package/dist/blocks/settings/plugins/index.js +9 -0
- package/dist/blocks/settings/settings-window/index.d.ts +4 -0
- package/dist/blocks/settings/settings-window/index.js +8 -0
- package/dist/blocks/settings/worktrees/index.d.ts +4 -0
- package/dist/blocks/settings/worktrees/index.js +9 -0
- package/dist/components/conversation/agent-run/index.d.ts +3 -0
- package/dist/components/conversation/agent-run/index.js +10 -0
- package/dist/components/conversation/chapter-nav/index.d.ts +2 -0
- package/dist/components/conversation/chapter-nav/index.js +11 -0
- package/dist/components/conversation/message/index.d.ts +2 -0
- package/dist/components/conversation/message/index.js +15 -0
- package/dist/components/conversation/reasoning/index.d.ts +2 -0
- package/dist/components/conversation/reasoning/index.js +8 -0
- package/dist/components/conversation/recap/index.d.ts +2 -0
- package/dist/components/conversation/recap/index.js +9 -0
- package/dist/components/conversation/todo-list/index.d.ts +2 -0
- package/dist/components/conversation/todo-list/index.js +9 -0
- package/dist/components/conversation/tool-call/index.d.ts +3 -0
- package/dist/components/conversation/tool-call/index.js +13 -0
- package/dist/components/conversation/work-summary/index.d.ts +2 -0
- package/dist/components/conversation/work-summary/index.js +10 -0
- package/dist/components/prompts/permission-request/index.d.ts +2 -0
- package/dist/components/prompts/permission-request/index.js +9 -0
- package/dist/components/prompts/plan-approval/index.d.ts +2 -0
- package/dist/components/prompts/plan-approval/index.js +9 -0
- package/dist/components/prompts/prompt-card/index.d.ts +3 -0
- package/dist/components/prompts/prompt-card/index.js +8 -0
- package/dist/components/prompts/question-prompt/index.d.ts +2 -0
- package/dist/components/prompts/question-prompt/index.js +9 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +231 -0
- package/dist/lib/config-parts.d.ts +2 -0
- package/dist/lib/config-parts.js +16 -0
- package/dist/lib/icons.d.ts +2 -0
- package/dist/lib/icons.js +10 -0
- package/dist/lib/pace-bar.d.ts +11 -0
- package/dist/lib/pace-bar.js +6 -0
- package/dist/lib/pace.d.ts +4 -0
- package/dist/lib/pace.js +14 -0
- package/dist/lib/pane-parts.d.ts +25 -0
- package/dist/lib/pane-parts.js +11 -0
- package/dist/lib/row-trigger.d.ts +5 -0
- package/dist/lib/row-trigger.js +7 -0
- package/dist/lib/settings-parts.d.ts +70 -0
- package/dist/lib/settings-parts.js +24 -0
- package/dist/lib/side-pane-types.d.ts +2 -0
- package/dist/lib/side-pane-types.js +1 -0
- package/dist/lib/status-glyph.d.ts +8 -0
- package/dist/lib/status-glyph.js +12 -0
- package/dist/lib/types.d.ts +3 -0
- package/dist/lib/types.js +1 -0
- package/dist/shared/chunk-04a497rr.js +21 -0
- package/dist/shared/chunk-13yf0mza.d.ts +70 -0
- package/dist/shared/chunk-1hzrm8r5.d.ts +51 -0
- package/dist/shared/chunk-1qdwg7w5.d.ts +81 -0
- package/dist/shared/chunk-1yt061np.d.ts +64 -0
- package/dist/shared/chunk-218qabm5.js +250 -0
- package/dist/shared/chunk-2fk5aq60.js +313 -0
- package/dist/shared/chunk-3ps5h55t.d.ts +30 -0
- package/dist/shared/chunk-3yaftgh0.d.ts +28 -0
- package/dist/shared/chunk-4zvhpf2x.js +55 -0
- package/dist/shared/chunk-57hzzmjd.d.ts +67 -0
- package/dist/shared/chunk-58jh3mje.js +46 -0
- package/dist/shared/chunk-58qvny6a.d.ts +29 -0
- package/dist/shared/chunk-5fhkkn39.js +130 -0
- package/dist/shared/chunk-5hw0525a.d.ts +33 -0
- package/dist/shared/chunk-5meda998.js +238 -0
- package/dist/shared/chunk-5pqksw7z.js +91 -0
- package/dist/shared/chunk-6220dy5n.js +70 -0
- package/dist/shared/chunk-64bnh22t.d.ts +59 -0
- package/dist/shared/chunk-66sh633m.d.ts +60 -0
- package/dist/shared/chunk-6cmf27g3.d.ts +81 -0
- package/dist/shared/chunk-6kwk9vag.js +558 -0
- package/dist/shared/chunk-6rdwkymk.js +177 -0
- package/dist/shared/chunk-71j8qzvb.d.ts +57 -0
- package/dist/shared/chunk-74bvf3tw.d.ts +21 -0
- package/dist/shared/chunk-75zwypyr.d.ts +43 -0
- package/dist/shared/chunk-7mfer3tp.js +176 -0
- package/dist/shared/chunk-7rzjmcnh.d.ts +30 -0
- package/dist/shared/chunk-7zvb39cf.d.ts +26 -0
- package/dist/shared/chunk-8mecznyr.js +357 -0
- package/dist/shared/chunk-8pag6vmd.js +255 -0
- package/dist/shared/chunk-94grzz9f.js +187 -0
- package/dist/shared/chunk-9kw6m047.d.ts +32 -0
- package/dist/shared/chunk-at0jje23.d.ts +110 -0
- package/dist/shared/chunk-awd573h9.js +34 -0
- package/dist/shared/chunk-b171wjge.d.ts +25 -0
- package/dist/shared/chunk-b4dz15em.d.ts +36 -0
- package/dist/shared/chunk-b5ccp5de.js +35 -0
- package/dist/shared/chunk-bh2b5d1z.js +98 -0
- package/dist/shared/chunk-c36qvrwq.d.ts +30 -0
- package/dist/shared/chunk-c8wp058j.js +153 -0
- package/dist/shared/chunk-d2t72h4x.d.ts +35 -0
- package/dist/shared/chunk-dh3qy5fj.js +49 -0
- package/dist/shared/chunk-dxzrtvt9.d.ts +283 -0
- package/dist/shared/chunk-e46apgve.d.ts +40 -0
- package/dist/shared/chunk-ejtknc0w.js +21 -0
- package/dist/shared/chunk-eqajdxn8.js +82 -0
- package/dist/shared/chunk-fapc805j.js +130 -0
- package/dist/shared/chunk-fm1qyrae.d.ts +68 -0
- package/dist/shared/chunk-fqhcz6ss.d.ts +29 -0
- package/dist/shared/chunk-g88hweqh.d.ts +70 -0
- package/dist/shared/chunk-gb5ee5dw.d.ts +88 -0
- package/dist/shared/chunk-gewnsgza.js +61 -0
- package/dist/shared/chunk-hxjgey30.d.ts +36 -0
- package/dist/shared/chunk-jkkdq1mh.d.ts +213 -0
- package/dist/shared/chunk-jpq101w3.js +91 -0
- package/dist/shared/chunk-k3bv9k1v.d.ts +56 -0
- package/dist/shared/chunk-kreypnzp.d.ts +34 -0
- package/dist/shared/chunk-mnzw0bav.js +80 -0
- package/dist/shared/chunk-mrb3fp2f.d.ts +30 -0
- package/dist/shared/chunk-n1qq2wp9.js +6 -0
- package/dist/shared/chunk-n31qwnj2.js +1544 -0
- package/dist/shared/chunk-n4742y54.js +39 -0
- package/dist/shared/chunk-ndjvdkv7.d.ts +29 -0
- package/dist/shared/chunk-njf851p1.js +245 -0
- package/dist/shared/chunk-nk4578dr.js +73 -0
- package/dist/shared/chunk-nkbgg7bw.d.ts +24 -0
- package/dist/shared/chunk-nvh33x9x.js +488 -0
- package/dist/shared/chunk-paezqfg1.js +106 -0
- package/dist/shared/chunk-qemm9e3r.d.ts +21 -0
- package/dist/shared/chunk-qhxz1etk.js +96 -0
- package/dist/shared/chunk-qj5ev9ak.js +531 -0
- package/dist/shared/chunk-qnwggvjy.js +150 -0
- package/dist/shared/chunk-qt31n444.js +178 -0
- package/dist/shared/chunk-r5hz78pb.js +129 -0
- package/dist/shared/chunk-r6nb21kz.d.ts +102 -0
- package/dist/shared/chunk-rqrpvvz4.d.ts +107 -0
- package/dist/shared/chunk-s3r759ec.js +80 -0
- package/dist/shared/chunk-sdtjrw9w.d.ts +98 -0
- package/dist/shared/chunk-skg3m9m0.js +56 -0
- package/dist/shared/chunk-t21t9x7e.js +188 -0
- package/dist/shared/chunk-tc75ng2c.js +235 -0
- package/dist/shared/chunk-tkx1krwc.js +88 -0
- package/dist/shared/chunk-tprdqtb1.d.ts +30 -0
- package/dist/shared/chunk-tv9a1sek.js +137 -0
- package/dist/shared/chunk-tvbd27hg.d.ts +43 -0
- package/dist/shared/chunk-ty2ccknv.d.ts +54 -0
- package/dist/shared/chunk-v6yevw62.d.ts +28 -0
- package/dist/shared/chunk-v9q38p0x.js +258 -0
- package/dist/shared/chunk-vgh4f3sv.js +118 -0
- package/dist/shared/chunk-vjht1zn1.js +391 -0
- package/dist/shared/chunk-vsrkb0sp.d.ts +21 -0
- package/dist/shared/chunk-whsx7yp9.d.ts +37 -0
- package/dist/shared/chunk-wq9h37gy.js +86 -0
- package/dist/shared/chunk-x7az5x1y.d.ts +57 -0
- package/dist/shared/chunk-x9jf26yb.js +318 -0
- package/dist/shared/chunk-xbrrt07s.d.ts +23 -0
- package/dist/shared/chunk-xkchhs2z.js +129 -0
- package/dist/shared/chunk-xzfrskd7.js +202 -0
- package/dist/shared/chunk-y4cj4y54.js +423 -0
- package/dist/shared/chunk-y934at6m.js +7 -0
- package/dist/shared/chunk-zbpwhpjy.d.ts +75 -0
- package/dist/shared/chunk-zfhmbb7n.js +63 -0
- package/dist/shared/chunk-zk0t4vq5.js +71 -0
- package/dist/shared/chunk-znp9gna7.d.ts +23 -0
- package/dist/styles.css +467 -0
- package/index.ts +49 -0
- package/lib/config-parts.tsx +97 -0
- package/lib/icons.tsx +149 -0
- package/lib/pace-bar.tsx +24 -0
- package/lib/pace.ts +78 -0
- package/lib/pane-parts.tsx +76 -0
- package/lib/row-trigger.tsx +44 -0
- package/lib/settings-parts.tsx +232 -0
- package/lib/side-pane-types.ts +75 -0
- package/lib/status-glyph.tsx +25 -0
- package/lib/types.ts +204 -0
- package/mock/demo-reply.tsx +33 -0
- package/mock/demo-session.tsx +150 -0
- package/mock/mock-config.ts +173 -0
- package/mock/mock-extras.ts +288 -0
- package/mock/mock-panes.ts +190 -0
- package/mock/mock-settings.ts +92 -0
- package/mock/mock.ts +548 -0
- package/mock/screen-frame.tsx +49 -0
- package/package.json +114 -4
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
3
|
+
* `registry/default/input-message.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
4
|
+
* MIT License © 2026 Micka Touillaud (notice: LICENSE.fluid-functionalism). Local changes: see ui/PORTING.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use client'
|
|
8
|
+
|
|
9
|
+
import { SurfaceProvider, useAutosizeTextarea, useReduceMotion, useTouchPrimary } from '@justanarthur/modo-ui'
|
|
10
|
+
import { Button } from '@justanarthur/modo-ui/components/actions/button'
|
|
11
|
+
import { useIcon } from '@justanarthur/modo-ui/lib/icon-context'
|
|
12
|
+
import { useShape } from '@justanarthur/modo-ui/lib/shape-context'
|
|
13
|
+
import { type SizeVariant, useSize } from '@justanarthur/modo-ui/lib/size-context'
|
|
14
|
+
import { spring } from '@justanarthur/modo-ui/lib/springs'
|
|
15
|
+
import { surfaceClasses } from '@justanarthur/modo-ui/lib/surface-classes'
|
|
16
|
+
import { useControllableState } from '@justanarthur/modo-ui/lib/use-controllable-state'
|
|
17
|
+
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
18
|
+
import { FluidHoverHighlight, useFluidHover } from '@justanarthur/modo-ui/primitives/systems/fluid-hover'
|
|
19
|
+
import { SizeScope } from '@justanarthur/modo-ui/primitives/systems/sizes'
|
|
20
|
+
import { AnimatePresence, motion, Reorder } from 'motion/react'
|
|
21
|
+
import {
|
|
22
|
+
forwardRef,
|
|
23
|
+
type HTMLAttributes,
|
|
24
|
+
type KeyboardEvent as ReactKeyboardEvent,
|
|
25
|
+
type MouseEvent as ReactMouseEvent,
|
|
26
|
+
type TextareaHTMLAttributes,
|
|
27
|
+
useCallback,
|
|
28
|
+
useEffect,
|
|
29
|
+
useId,
|
|
30
|
+
useMemo,
|
|
31
|
+
useRef,
|
|
32
|
+
} from 'react'
|
|
33
|
+
import { FilePreviewTile } from './file-preview-tile'
|
|
34
|
+
import { QueuedRow } from './queued-row'
|
|
35
|
+
import { caretToEnd, type DraftSlot, type DraftSlotContext, type DraftStatus, type QueuedMessage } from './shared'
|
|
36
|
+
import { SuggestionRow } from './suggestion-row'
|
|
37
|
+
import { useComposerFiles } from './use-composer-files'
|
|
38
|
+
import { useHistoryNav } from './use-history-nav'
|
|
39
|
+
import { useMessageQueue } from './use-message-queue'
|
|
40
|
+
import { useRegionHeight } from './use-region-height'
|
|
41
|
+
|
|
42
|
+
const DEFAULT_ACCEPT = 'image/png,image/jpeg,application/pdf'
|
|
43
|
+
const NO_STRINGS: string[] = []
|
|
44
|
+
const REGION_SPRING = { ...spring.moderate, bounce: 0 }
|
|
45
|
+
|
|
46
|
+
interface ComposerDraftProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {
|
|
47
|
+
/** Step on the size ladder (see Sizes). Wins over the surrounding SizeProvider and propagates to the composer's rows, buttons and queued messages. */
|
|
48
|
+
size?: SizeVariant
|
|
49
|
+
/** Controlled textarea value. Pair with `onValueChange`; omit both for an uncontrolled composer. */
|
|
50
|
+
value?: string
|
|
51
|
+
/** Initial textarea value for an uncontrolled composer. Defaults to `""`. */
|
|
52
|
+
defaultValue?: string
|
|
53
|
+
/** Called with the new value on every textarea change. */
|
|
54
|
+
onValueChange?: (value: string) => void
|
|
55
|
+
/** Fires on Enter (without Shift) or send-button click, and when a queued message auto-dispatches. Receives the trimmed value, the attached files, and — for auto-dispatched queue items — `meta.queuedId`. Skipped when the value is empty and no files are attached. */
|
|
56
|
+
onSend?: (value: string, files: File[], meta?: { queuedId?: string }) => void
|
|
57
|
+
/** Placeholder shown when the value is empty. While a file is dragged over the component (and attachments are enabled) it swaps to "Drop files here to add to chat". Defaults to `"Ask me anything…"`. */
|
|
58
|
+
placeholder?: string
|
|
59
|
+
/** Content rendered in the bottom-left action area. May be a render-fn that receives `{ openFilePicker, files }` — `openFilePicker(acceptOverride?)` opens the native file picker. */
|
|
60
|
+
leftSlot?: DraftSlot
|
|
61
|
+
/** Content rendered in the bottom-right action area, before the built-in send button. Same render-fn shape as `leftSlot`. */
|
|
62
|
+
rightSlot?: DraftSlot
|
|
63
|
+
/** Disables the textarea, send button, and drag-and-drop. Defaults to `false`. */
|
|
64
|
+
disabled?: boolean
|
|
65
|
+
/** Minimum visible rows before the textarea grows. Defaults to 1. */
|
|
66
|
+
minRows?: number
|
|
67
|
+
/** Maximum visible rows before the textarea starts to scroll. Defaults to 8. */
|
|
68
|
+
maxRows?: number
|
|
69
|
+
/** When true, clicking anywhere on the surrounding container (outside of buttons / links / inputs) focuses the textarea. Defaults to `true`. */
|
|
70
|
+
clickToFocus?: boolean
|
|
71
|
+
/** Accessible label for the send button. Defaults to `"Send"`. */
|
|
72
|
+
sendLabel?: string
|
|
73
|
+
/** Controlled list of attached files. Pair with `onFilesChange` to enable drag-and-drop and the file-picker slot helper. */
|
|
74
|
+
files?: File[]
|
|
75
|
+
/** Initial attachments for an uncontrolled composer. Providing it (even as `[]`) enables attachment behavior on its own. */
|
|
76
|
+
defaultFiles?: File[]
|
|
77
|
+
/** Called when files are added (drag-drop or picker) or removed via the preview tile's × button. Duplicate drops of the same file (same name + size + lastModified) are silently de-duplicated. */
|
|
78
|
+
onFilesChange?: (files: File[]) => void
|
|
79
|
+
/** Accepted MIME types as a comma-separated string. Used by both the file picker and the drag-and-drop filter. Defaults to `"image/png,image/jpeg,application/pdf"`. */
|
|
80
|
+
accept?: string
|
|
81
|
+
/** Maximum number of attached files. Extra files beyond this limit are dropped. */
|
|
82
|
+
maxFiles?: number
|
|
83
|
+
/** Side length (in pixels) of each preview tile. Images use object-cover; PDFs render the first page via pdfjs (an optional peer: without `pdfjs-dist` they show the file icon); other types fall back to a centered icon. Defaults to 80. */
|
|
84
|
+
filePreviewSize?: number
|
|
85
|
+
/** Extra props forwarded to the underlying textarea (value, onChange, onKeyDown, disabled and placeholder are controlled by the component). */
|
|
86
|
+
textareaProps?: Omit<
|
|
87
|
+
TextareaHTMLAttributes<HTMLTextAreaElement>,
|
|
88
|
+
'value' | 'onChange' | 'onKeyDown' | 'disabled' | 'placeholder'
|
|
89
|
+
>
|
|
90
|
+
/** Assistant response state. When `"streaming"`, the send button becomes a Stop control (empty draft) or a Queue action (non-empty draft). On the streaming→idle edge the next queued message auto-dispatches via `onSend`. Leave it and `defaultStatus` undefined for the send-immediately behavior. */
|
|
91
|
+
status?: DraftStatus
|
|
92
|
+
/** Initial status for an uncontrolled composer — the component then owns the streaming flag, and Stop flips it to `"idle"` itself. */
|
|
93
|
+
defaultStatus?: DraftStatus
|
|
94
|
+
/** Called whenever the status changes while it is uncontrolled (currently: the Stop control). */
|
|
95
|
+
onStatusChange?: (status: DraftStatus) => void
|
|
96
|
+
/** Fires when the Stop control is pressed (streaming + empty draft). Halt the current response and set status to `"idle"` — that edge immediately dispatches the next queued message. */
|
|
97
|
+
onStop?: () => void
|
|
98
|
+
/** Controlled queue of pending messages, rendered as reorderable rows above the textarea. Double-click (or Enter/F2) edits a row back into the composer; the × (or Delete) removes it; drag — or Alt+↑/↓ — reorders. Requires a status. */
|
|
99
|
+
queue?: QueuedMessage[]
|
|
100
|
+
/** Initial queue for an uncontrolled composer. Providing it (even as `[]`) enables the queue on its own, alongside `status` or `defaultStatus`. */
|
|
101
|
+
defaultQueue?: QueuedMessage[]
|
|
102
|
+
/** Called whenever the queue changes — enqueue, edit, delete, reorder, or auto-dispatch. Each QueuedMessage is `{ id, text, files }`. */
|
|
103
|
+
onQueueChange?: (queue: QueuedMessage[]) => void
|
|
104
|
+
/** Render the built-in reorderable queue rows above the textarea. Set to false to suppress them and render the queue yourself — enqueue and auto-dispatch still run. Defaults to `true`. */
|
|
105
|
+
showQueue?: boolean
|
|
106
|
+
/** Previously-sent messages, oldest first. With the textarea focused, ArrowUp (caret on the first line) recalls the previous message and walks backward; ArrowDown (caret on the last line) walks forward toward the in-progress draft. Editing or sending exits history mode. Defaults to `[]`. */
|
|
107
|
+
history?: string[]
|
|
108
|
+
/** Suggested prompt rendered as the placeholder (with a Tab keycap) while the draft is empty. Pressing Tab fills it into the composer — it doesn't send. Takes precedence over `placeholder`. */
|
|
109
|
+
placeholderSuggestion?: string
|
|
110
|
+
/** Suggested prompts listed under the action bar while the draft is empty. ArrowDown moves a highlight into the list (focus stays in the textarea), ArrowUp walks back up and out, Enter or click fills the highlighted prompt. Escape drops the highlight; typing collapses the list. */
|
|
111
|
+
suggestions?: string[]
|
|
112
|
+
/** Extra classes for the composer surface. */
|
|
113
|
+
className?: string
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const isPlain = (e: ReactKeyboardEvent) => !e.shiftKey && !e.altKey && !e.metaKey && !e.ctrlKey
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The composer's draft on its own (Fluid Functionalism's InputMessage): the
|
|
120
|
+
* textarea, its attachments, queue, history and suggestions, and the send /
|
|
121
|
+
* queue / stop button, on a Surface-2 substrate. `Composer` documents it.
|
|
122
|
+
*/
|
|
123
|
+
const ComposerDraft = forwardRef<HTMLDivElement, ComposerDraftProps>(
|
|
124
|
+
(
|
|
125
|
+
{
|
|
126
|
+
size,
|
|
127
|
+
value: valueProp,
|
|
128
|
+
defaultValue,
|
|
129
|
+
onValueChange,
|
|
130
|
+
onSend,
|
|
131
|
+
placeholder = 'Ask me anything…',
|
|
132
|
+
leftSlot,
|
|
133
|
+
rightSlot,
|
|
134
|
+
disabled,
|
|
135
|
+
minRows = 1,
|
|
136
|
+
maxRows = 8,
|
|
137
|
+
clickToFocus = true,
|
|
138
|
+
sendLabel = 'Send',
|
|
139
|
+
files,
|
|
140
|
+
defaultFiles,
|
|
141
|
+
onFilesChange,
|
|
142
|
+
accept = DEFAULT_ACCEPT,
|
|
143
|
+
maxFiles,
|
|
144
|
+
filePreviewSize = 80,
|
|
145
|
+
textareaProps,
|
|
146
|
+
status,
|
|
147
|
+
defaultStatus,
|
|
148
|
+
onStatusChange,
|
|
149
|
+
onStop,
|
|
150
|
+
queue,
|
|
151
|
+
defaultQueue,
|
|
152
|
+
onQueueChange,
|
|
153
|
+
showQueue = true,
|
|
154
|
+
history = NO_STRINGS,
|
|
155
|
+
placeholderSuggestion,
|
|
156
|
+
suggestions,
|
|
157
|
+
className,
|
|
158
|
+
...props
|
|
159
|
+
},
|
|
160
|
+
ref,
|
|
161
|
+
) => {
|
|
162
|
+
const shape = useShape()
|
|
163
|
+
const compactStep = useSize(size).variant === 'compact'
|
|
164
|
+
const ArrowUpIcon = useIcon('arrow-up')
|
|
165
|
+
const reduceMotion = useReduceMotion()
|
|
166
|
+
const isTouch = useTouchPrimary()
|
|
167
|
+
const textareaRef = useRef<HTMLTextAreaElement>(null)
|
|
168
|
+
const {
|
|
169
|
+
onBlur: textareaOnBlur,
|
|
170
|
+
'aria-describedby': textareaDescribedBy,
|
|
171
|
+
...restTextareaProps
|
|
172
|
+
} = textareaProps ?? {}
|
|
173
|
+
|
|
174
|
+
const valueControlled = valueProp !== undefined
|
|
175
|
+
const [value, setValue] = useControllableState<string>(valueProp, defaultValue ?? '', onValueChange)
|
|
176
|
+
const attachments = useComposerFiles({ files, defaultFiles, onFilesChange, accept, maxFiles, disabled })
|
|
177
|
+
const messages = useMessageQueue({
|
|
178
|
+
status,
|
|
179
|
+
defaultStatus,
|
|
180
|
+
onStatusChange,
|
|
181
|
+
onStop,
|
|
182
|
+
queue,
|
|
183
|
+
defaultQueue,
|
|
184
|
+
onQueueChange,
|
|
185
|
+
onSend,
|
|
186
|
+
})
|
|
187
|
+
const recall = useHistoryNav(history, value, setValue, textareaRef)
|
|
188
|
+
|
|
189
|
+
useAutosizeTextarea(textareaRef, { minRows, maxRows }, [value, compactStep])
|
|
190
|
+
|
|
191
|
+
// The list shows while the draft is empty; focus stays in the textarea
|
|
192
|
+
// (aria-activedescendant), and pointer and keyboard drive one fluid-hover highlight.
|
|
193
|
+
const suggestionList = suggestions ?? NO_STRINGS
|
|
194
|
+
const suggestionsOpen = suggestionList.length > 0 && value === ''
|
|
195
|
+
const suggestionListRef = useRef<HTMLDivElement | null>(null)
|
|
196
|
+
const suggestionHover = useFluidHover(suggestionListRef)
|
|
197
|
+
const {
|
|
198
|
+
activeIndex: activeSuggestion,
|
|
199
|
+
setActiveIndex: setActiveSuggestion,
|
|
200
|
+
handlers: suggestionHandlers,
|
|
201
|
+
registerItem: registerSuggestion,
|
|
202
|
+
remeasure,
|
|
203
|
+
} = suggestionHover
|
|
204
|
+
const suggestionListId = useId()
|
|
205
|
+
const ghostHintId = useId()
|
|
206
|
+
const showGhost = !!placeholderSuggestion && value === '' && !attachments.dragging
|
|
207
|
+
|
|
208
|
+
const [filesRegionRef, filesRegionHeight] = useRegionHeight()
|
|
209
|
+
const [queueRegionRef, queueRegionHeight] = useRegionHeight()
|
|
210
|
+
const [suggestionsRegionRef, suggestionsRegionHeight] = useRegionHeight()
|
|
211
|
+
|
|
212
|
+
// Closed rows keep their registration with stale rects: remeasure on open.
|
|
213
|
+
useEffect(() => {
|
|
214
|
+
if (suggestionsOpen) remeasure()
|
|
215
|
+
else setActiveSuggestion(null)
|
|
216
|
+
}, [suggestionsOpen, remeasure, setActiveSuggestion])
|
|
217
|
+
|
|
218
|
+
const acceptSuggestion = useCallback(
|
|
219
|
+
(text: string) => {
|
|
220
|
+
setActiveSuggestion(null)
|
|
221
|
+
recall.exit()
|
|
222
|
+
setValue(text)
|
|
223
|
+
caretToEnd(textareaRef)
|
|
224
|
+
},
|
|
225
|
+
[setValue, setActiveSuggestion, recall.exit],
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
const trimmed = value.trim()
|
|
229
|
+
const canSend = !disabled && (trimmed.length > 0 || attachments.files.length > 0)
|
|
230
|
+
|
|
231
|
+
const handleSend = () => {
|
|
232
|
+
if (!canSend) return
|
|
233
|
+
recall.exit()
|
|
234
|
+
if (messages.streaming && messages.supported) {
|
|
235
|
+
messages.enqueue(trimmed, attachments.files)
|
|
236
|
+
setValue('')
|
|
237
|
+
attachments.replace([])
|
|
238
|
+
caretToEnd(textareaRef)
|
|
239
|
+
return
|
|
240
|
+
}
|
|
241
|
+
onSend?.(trimmed, attachments.files)
|
|
242
|
+
if (!valueControlled) setValue('')
|
|
243
|
+
if (!attachments.controlled) attachments.replace([])
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const editQueued = (item: QueuedMessage) => {
|
|
247
|
+
recall.exit()
|
|
248
|
+
setValue(item.text)
|
|
249
|
+
attachments.replace(item.files)
|
|
250
|
+
messages.remove(item)
|
|
251
|
+
caretToEnd(textareaRef)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const buttonMode: 'send' | 'queue' | 'stop' = !messages.streaming
|
|
255
|
+
? 'send'
|
|
256
|
+
: canSend && messages.supported
|
|
257
|
+
? 'queue'
|
|
258
|
+
: messages.canStop
|
|
259
|
+
? 'stop'
|
|
260
|
+
: 'send'
|
|
261
|
+
const buttonLabel = buttonMode === 'stop' ? 'Stop' : buttonMode === 'queue' ? 'Queue message' : sendLabel
|
|
262
|
+
|
|
263
|
+
const handleKeyDown = (e: ReactKeyboardEvent<HTMLTextAreaElement>) => {
|
|
264
|
+
if (e.nativeEvent.isComposing) return
|
|
265
|
+
|
|
266
|
+
if (suggestionsOpen && isPlain(e)) {
|
|
267
|
+
if (e.key === 'ArrowDown') {
|
|
268
|
+
e.preventDefault()
|
|
269
|
+
setActiveSuggestion(prev => (prev == null ? 0 : Math.min(prev + 1, suggestionList.length - 1)))
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
if (activeSuggestion != null) {
|
|
273
|
+
if (e.key === 'ArrowUp') {
|
|
274
|
+
e.preventDefault()
|
|
275
|
+
setActiveSuggestion(activeSuggestion === 0 ? null : activeSuggestion - 1)
|
|
276
|
+
return
|
|
277
|
+
}
|
|
278
|
+
if (e.key === 'Enter') {
|
|
279
|
+
e.preventDefault()
|
|
280
|
+
const picked = suggestionList[activeSuggestion]
|
|
281
|
+
if (picked !== undefined) acceptSuggestion(picked)
|
|
282
|
+
return
|
|
283
|
+
}
|
|
284
|
+
if (e.key === 'Escape') {
|
|
285
|
+
e.preventDefault()
|
|
286
|
+
setActiveSuggestion(null)
|
|
287
|
+
return
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Shift+Tab, and Tab once there is a draft, still move focus.
|
|
293
|
+
if (e.key === 'Tab' && !e.shiftKey && placeholderSuggestion && value === '') {
|
|
294
|
+
e.preventDefault()
|
|
295
|
+
acceptSuggestion(placeholderSuggestion)
|
|
296
|
+
return
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
300
|
+
recall.onKeyDown(e)
|
|
301
|
+
return
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
305
|
+
e.preventDefault()
|
|
306
|
+
handleSend()
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const handleContainerMouseDown = (e: ReactMouseEvent<HTMLDivElement>) => {
|
|
311
|
+
if (!clickToFocus || disabled) return
|
|
312
|
+
const target = e.target as HTMLElement
|
|
313
|
+
if (target === textareaRef.current) return
|
|
314
|
+
if (target.closest('button, a, input, select, textarea, [contenteditable], [role="button"], [data-draft-queue]'))
|
|
315
|
+
return
|
|
316
|
+
e.preventDefault()
|
|
317
|
+
textareaRef.current?.focus()
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const slotCtx = useMemo<DraftSlotContext>(
|
|
321
|
+
() => ({ openFilePicker: attachments.openPicker, files: attachments.files }),
|
|
322
|
+
[attachments.openPicker, attachments.files],
|
|
323
|
+
)
|
|
324
|
+
const leftContent = typeof leftSlot === 'function' ? leftSlot(slotCtx) : leftSlot
|
|
325
|
+
const rightContent = typeof rightSlot === 'function' ? rightSlot(slotCtx) : rightSlot
|
|
326
|
+
const textStep = compactStep
|
|
327
|
+
? 'text-subtitle-compact leading-4.5 px-1.5 py-1.5'
|
|
328
|
+
: 'text-subtitle leading-5 px-2 py-2'
|
|
329
|
+
|
|
330
|
+
return (
|
|
331
|
+
<SizeScope size={size}>
|
|
332
|
+
{/* biome-ignore lint/a11y/noStaticElementInteractions: the textarea is the control; the panel forwards pointer focus and takes drops. */}
|
|
333
|
+
<div
|
|
334
|
+
ref={ref}
|
|
335
|
+
data-composer-draft=""
|
|
336
|
+
data-click-to-focus={clickToFocus && !disabled ? '' : undefined}
|
|
337
|
+
data-drag-over={attachments.dragging ? '' : undefined}
|
|
338
|
+
onMouseDown={handleContainerMouseDown}
|
|
339
|
+
{...attachments.dropHandlers}
|
|
340
|
+
className={cn(
|
|
341
|
+
'flex flex-col gap-1 p-2 transition-[box-shadow,color] duration-fast',
|
|
342
|
+
surfaceClasses(2, 2),
|
|
343
|
+
shape.container,
|
|
344
|
+
clickToFocus && !disabled && 'cursor-text',
|
|
345
|
+
disabled && 'opacity-50 pointer-events-none',
|
|
346
|
+
className,
|
|
347
|
+
)}
|
|
348
|
+
{...props}
|
|
349
|
+
>
|
|
350
|
+
<SurfaceProvider value={2}>
|
|
351
|
+
{attachments.supported && (
|
|
352
|
+
<input {...attachments.inputProps} className="hidden" aria-hidden="true" tabIndex={-1} />
|
|
353
|
+
)}
|
|
354
|
+
|
|
355
|
+
{/* popLayout pulls a leaving tile out of flow so its siblings slide in;
|
|
356
|
+
keys are file identity, so removing one never remounts the rest. */}
|
|
357
|
+
<AnimatePresence initial={false}>
|
|
358
|
+
{attachments.files.length > 0 && (
|
|
359
|
+
<motion.div
|
|
360
|
+
key="preview-row"
|
|
361
|
+
initial={{ height: 0, opacity: 0 }}
|
|
362
|
+
animate={{ height: filesRegionHeight ?? 0, opacity: 1 }}
|
|
363
|
+
exit={{ height: 0, opacity: 0 }}
|
|
364
|
+
transition={REGION_SPRING}
|
|
365
|
+
className="overflow-hidden"
|
|
366
|
+
>
|
|
367
|
+
<div ref={filesRegionRef} className="flex flex-wrap gap-2 pb-1">
|
|
368
|
+
<AnimatePresence initial={false} mode="popLayout">
|
|
369
|
+
{attachments.files.map((file, i) => (
|
|
370
|
+
<FilePreviewTile
|
|
371
|
+
key={`${file.name}-${file.size}-${file.lastModified}`}
|
|
372
|
+
file={file}
|
|
373
|
+
onRemove={() => attachments.remove(i)}
|
|
374
|
+
size={filePreviewSize}
|
|
375
|
+
/>
|
|
376
|
+
))}
|
|
377
|
+
</AnimatePresence>
|
|
378
|
+
</div>
|
|
379
|
+
</motion.div>
|
|
380
|
+
)}
|
|
381
|
+
</AnimatePresence>
|
|
382
|
+
|
|
383
|
+
{messages.supported && showQueue && (
|
|
384
|
+
<AnimatePresence initial={false}>
|
|
385
|
+
{messages.queue.length > 0 && (
|
|
386
|
+
<motion.div
|
|
387
|
+
key="queue-row"
|
|
388
|
+
initial={{ height: 0, opacity: 0 }}
|
|
389
|
+
animate={{ height: queueRegionHeight ?? 0, opacity: 1 }}
|
|
390
|
+
exit={{ height: 0, opacity: 0 }}
|
|
391
|
+
transition={REGION_SPRING}
|
|
392
|
+
className="overflow-hidden"
|
|
393
|
+
>
|
|
394
|
+
<Reorder.Group
|
|
395
|
+
ref={queueRegionRef}
|
|
396
|
+
axis="y"
|
|
397
|
+
values={messages.queue}
|
|
398
|
+
onReorder={messages.setQueue}
|
|
399
|
+
data-draft-queue
|
|
400
|
+
className="flex flex-col gap-1 pb-1"
|
|
401
|
+
>
|
|
402
|
+
<AnimatePresence initial={false}>
|
|
403
|
+
{messages.queue.map((item, i) => (
|
|
404
|
+
<QueuedRow
|
|
405
|
+
key={item.id}
|
|
406
|
+
item={item}
|
|
407
|
+
index={i}
|
|
408
|
+
total={messages.queue.length}
|
|
409
|
+
reduceMotion={reduceMotion}
|
|
410
|
+
isTouch={isTouch}
|
|
411
|
+
onEdit={editQueued}
|
|
412
|
+
onRemove={messages.remove}
|
|
413
|
+
onMove={messages.move}
|
|
414
|
+
/>
|
|
415
|
+
))}
|
|
416
|
+
</AnimatePresence>
|
|
417
|
+
</Reorder.Group>
|
|
418
|
+
</motion.div>
|
|
419
|
+
)}
|
|
420
|
+
</AnimatePresence>
|
|
421
|
+
)}
|
|
422
|
+
|
|
423
|
+
<div className="relative">
|
|
424
|
+
<textarea
|
|
425
|
+
ref={textareaRef}
|
|
426
|
+
value={value}
|
|
427
|
+
onChange={e => {
|
|
428
|
+
recall.exit()
|
|
429
|
+
setActiveSuggestion(null)
|
|
430
|
+
setValue(e.target.value)
|
|
431
|
+
}}
|
|
432
|
+
onKeyDown={handleKeyDown}
|
|
433
|
+
onBlur={e => {
|
|
434
|
+
setActiveSuggestion(null)
|
|
435
|
+
textareaOnBlur?.(e)
|
|
436
|
+
}}
|
|
437
|
+
placeholder={
|
|
438
|
+
attachments.dragging
|
|
439
|
+
? 'Drop files here to add to chat'
|
|
440
|
+
: placeholderSuggestion
|
|
441
|
+
? undefined // the ghost below renders it
|
|
442
|
+
: placeholder
|
|
443
|
+
}
|
|
444
|
+
disabled={disabled}
|
|
445
|
+
rows={minRows}
|
|
446
|
+
aria-label={textareaProps?.['aria-label'] ?? 'Message'}
|
|
447
|
+
aria-describedby={
|
|
448
|
+
[showGhost ? ghostHintId : null, textareaDescribedBy].filter(Boolean).join(' ') || undefined
|
|
449
|
+
}
|
|
450
|
+
aria-activedescendant={activeSuggestion != null ? `${suggestionListId}-${activeSuggestion}` : undefined}
|
|
451
|
+
className={cn(
|
|
452
|
+
'w-full resize-none rounded-none bg-transparent outline-none',
|
|
453
|
+
'text-foreground placeholder:text-muted-foreground',
|
|
454
|
+
textStep,
|
|
455
|
+
'weight-normal',
|
|
456
|
+
)}
|
|
457
|
+
{...restTextareaProps}
|
|
458
|
+
/>
|
|
459
|
+
{/* An overlay rather than the native placeholder, so the Tab keycap can sit inline. */}
|
|
460
|
+
{showGhost && (
|
|
461
|
+
<div
|
|
462
|
+
aria-hidden="true"
|
|
463
|
+
className={cn(
|
|
464
|
+
'pointer-events-none absolute inset-0 overflow-hidden text-muted-foreground',
|
|
465
|
+
textStep,
|
|
466
|
+
'weight-normal',
|
|
467
|
+
)}
|
|
468
|
+
>
|
|
469
|
+
<span className="flex max-w-full items-center gap-1.5">
|
|
470
|
+
<span className="min-w-0 truncate">{placeholderSuggestion}</span>
|
|
471
|
+
<kbd
|
|
472
|
+
className={cn(
|
|
473
|
+
'inline-flex shrink-0 -translate-y-px items-center rounded-box border border-border bg-background px-1 font-sans text-muted-foreground',
|
|
474
|
+
compactStep ? 'h-4 text-micro-compact' : 'h-[18px] text-micro',
|
|
475
|
+
)}
|
|
476
|
+
>
|
|
477
|
+
Tab
|
|
478
|
+
</kbd>
|
|
479
|
+
</span>
|
|
480
|
+
</div>
|
|
481
|
+
)}
|
|
482
|
+
{showGhost && (
|
|
483
|
+
<span id={ghostHintId} className="sr-only">
|
|
484
|
+
Suggested prompt: {placeholderSuggestion}. Press Tab to fill the composer with it.
|
|
485
|
+
</span>
|
|
486
|
+
)}
|
|
487
|
+
</div>
|
|
488
|
+
<div
|
|
489
|
+
className={cn(
|
|
490
|
+
'flex items-center justify-between',
|
|
491
|
+
// Slot buttons are the consumer's: the compact step scales every one, send included.
|
|
492
|
+
compactStep ? 'gap-1.5 [&_button]:h-6 [&_button.w-7]:w-6 [&_button]:text-caption-compact' : 'gap-2',
|
|
493
|
+
)}
|
|
494
|
+
>
|
|
495
|
+
<div className="flex items-center gap-1.5 min-w-0">{leftContent}</div>
|
|
496
|
+
<div className="flex items-center gap-1.5 shrink-0">
|
|
497
|
+
{rightContent}
|
|
498
|
+
<Button
|
|
499
|
+
type="button"
|
|
500
|
+
variant="primary"
|
|
501
|
+
size="icon-compact"
|
|
502
|
+
onClick={buttonMode === 'stop' ? messages.stop : handleSend}
|
|
503
|
+
disabled={buttonMode === 'stop' ? disabled : !canSend}
|
|
504
|
+
aria-label={buttonLabel}
|
|
505
|
+
>
|
|
506
|
+
<AnimatePresence mode="wait" initial={false}>
|
|
507
|
+
<motion.span
|
|
508
|
+
key={buttonMode === 'stop' ? 'stop' : 'arrow'}
|
|
509
|
+
initial={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.6 }}
|
|
510
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
511
|
+
exit={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.6, transition: spring.fast.exit }}
|
|
512
|
+
transition={spring.fast}
|
|
513
|
+
className="flex items-center justify-center leading-none"
|
|
514
|
+
>
|
|
515
|
+
{buttonMode === 'stop' ? (
|
|
516
|
+
<span className="h-3 w-3 rounded-glyph bg-current" />
|
|
517
|
+
) : (
|
|
518
|
+
// A touch larger than icon-compact's 14px svg.
|
|
519
|
+
<ArrowUpIcon
|
|
520
|
+
size={compactStep ? 15 : 19}
|
|
521
|
+
className={cn('block', compactStep ? '!h-[15px] !w-[15px]' : '!h-[19px] !w-[19px]')}
|
|
522
|
+
/>
|
|
523
|
+
)}
|
|
524
|
+
</motion.span>
|
|
525
|
+
</AnimatePresence>
|
|
526
|
+
</Button>
|
|
527
|
+
</div>
|
|
528
|
+
</div>
|
|
529
|
+
|
|
530
|
+
{suggestionList.length > 0 && (
|
|
531
|
+
<AnimatePresence initial={false}>
|
|
532
|
+
{suggestionsOpen && (
|
|
533
|
+
<motion.div
|
|
534
|
+
key="suggestions"
|
|
535
|
+
initial={{ height: 0, opacity: 0 }}
|
|
536
|
+
animate={{ height: suggestionsRegionHeight ?? 0, opacity: 1 }}
|
|
537
|
+
// Height only: a fade would drop the divider before the space closes.
|
|
538
|
+
exit={{ height: 0 }}
|
|
539
|
+
transition={REGION_SPRING}
|
|
540
|
+
// -mt-1 / mt-2 move the gap inside the collapsing region; -mx-2 runs the divider full width.
|
|
541
|
+
className="-mx-2 -mt-1 overflow-hidden"
|
|
542
|
+
>
|
|
543
|
+
{/* biome-ignore lint/a11y/useKeyWithClickEvents: the textarea drives the list by keyboard (aria-activedescendant). */}
|
|
544
|
+
<div
|
|
545
|
+
ref={el => {
|
|
546
|
+
suggestionListRef.current = el
|
|
547
|
+
suggestionsRegionRef(el)
|
|
548
|
+
}}
|
|
549
|
+
role="listbox"
|
|
550
|
+
id={suggestionListId}
|
|
551
|
+
aria-label="Suggested prompts"
|
|
552
|
+
onMouseEnter={suggestionHandlers.onMouseEnter}
|
|
553
|
+
onMouseMove={suggestionHandlers.onMouseMove}
|
|
554
|
+
onMouseLeave={suggestionHandlers.onMouseLeave}
|
|
555
|
+
onClick={suggestionHandlers.onClick}
|
|
556
|
+
className="relative mt-2 flex flex-col border-t border-border/60 px-1.5 pt-1.5"
|
|
557
|
+
>
|
|
558
|
+
<FluidHoverHighlight hover={suggestionHover} className={shape.bg} />
|
|
559
|
+
{suggestionList.map((s, i) => (
|
|
560
|
+
<SuggestionRow
|
|
561
|
+
key={`${s}-${i}`}
|
|
562
|
+
text={s}
|
|
563
|
+
index={i}
|
|
564
|
+
active={i === activeSuggestion}
|
|
565
|
+
keyHint={i === 0 && activeSuggestion == null}
|
|
566
|
+
optionId={`${suggestionListId}-${i}`}
|
|
567
|
+
registerItem={registerSuggestion}
|
|
568
|
+
onSelect={() => acceptSuggestion(s)}
|
|
569
|
+
/>
|
|
570
|
+
))}
|
|
571
|
+
</div>
|
|
572
|
+
</motion.div>
|
|
573
|
+
)}
|
|
574
|
+
</AnimatePresence>
|
|
575
|
+
)}
|
|
576
|
+
<span className="sr-only" role="status" aria-live="polite">
|
|
577
|
+
{messages.announcement}
|
|
578
|
+
</span>
|
|
579
|
+
</SurfaceProvider>
|
|
580
|
+
</div>
|
|
581
|
+
</SizeScope>
|
|
582
|
+
)
|
|
583
|
+
},
|
|
584
|
+
)
|
|
585
|
+
|
|
586
|
+
ComposerDraft.displayName = 'Composer.Draft'
|
|
587
|
+
|
|
588
|
+
export type { ComposerDraftProps, DraftSlot, DraftSlotContext, DraftStatus, QueuedMessage }
|
|
589
|
+
export { ComposerDraft }
|