@justanarthur/modo-ui 0.6.0-canary.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +197 -643
- package/blocks/sidebar-app/examples.mdx +2 -2
- package/blocks/sidebar-app/index.tsx +20 -7
- package/blocks/sidebar-app/inset-topbar.tsx +3 -8
- package/blocks/sidebar-app/menu-grid.ts +8 -18
- package/blocks/sidebar-app/nav-data.ts +1 -1
- package/blocks/sidebar-app/search-field.tsx +8 -15
- package/blocks/sidebar-app/thread-page.tsx +58 -0
- package/blocks/sidebar-app/user-footer.tsx +8 -15
- package/blocks/sidebar-app/workspace-header.tsx +9 -28
- package/components/AI/input-message/examples.mdx +37 -33
- package/components/AI/input-message/file-preview-tile.tsx +59 -0
- package/components/AI/input-message/file-thumbnail.tsx +26 -53
- package/components/AI/input-message/index.tsx +362 -1122
- package/components/AI/input-message/input-message.css +25 -0
- package/components/AI/input-message/queued-row.tsx +102 -0
- package/components/AI/input-message/shared.ts +38 -0
- package/components/AI/input-message/suggestion-row.tsx +64 -0
- package/components/AI/input-message/use-composer-files.ts +142 -0
- package/components/AI/input-message/use-history-nav.ts +60 -0
- package/components/AI/input-message/use-message-queue.ts +108 -0
- package/components/AI/input-message/use-region-height.ts +34 -0
- package/components/AI/thinking-indicator/index.tsx +9 -31
- package/components/accordion/accordion-content.tsx +217 -0
- package/components/accordion/accordion-context.tsx +118 -0
- package/components/accordion/accordion-group.tsx +215 -0
- package/components/accordion/examples.mdx +64 -132
- package/components/accordion/index.tsx +127 -891
- package/components/avatar/examples.mdx +2 -2
- package/components/avatar/index.tsx +40 -34
- package/components/badge/change-demo.tsx +2 -0
- package/components/badge/examples.mdx +16 -34
- package/components/badge/index.tsx +31 -69
- package/components/badge/variants.ts +5 -30
- package/components/button/examples.mdx +79 -94
- package/components/button/index.tsx +97 -188
- package/components/button/loading-demo.tsx +2 -0
- package/components/button/variants.ts +12 -117
- package/components/card/card-group.tsx +184 -0
- package/components/card/card-media.tsx +207 -0
- package/components/card/card-parts.tsx +179 -0
- package/components/card/examples.mdx +91 -143
- package/components/card/index.tsx +190 -881
- package/components/copy/examples.mdx +29 -67
- package/components/copy/index.tsx +58 -285
- package/components/inputs/checkbox/examples.mdx +22 -39
- package/components/inputs/checkbox/index.tsx +103 -255
- package/components/inputs/checkbox/select-all-demo.tsx +8 -6
- package/components/inputs/color-picker/channel-sliders.tsx +70 -0
- package/components/inputs/color-picker/color-input.tsx +387 -0
- package/components/inputs/color-picker/{variants.ts → color-math.ts} +22 -57
- package/components/inputs/color-picker/context.ts +11 -0
- package/components/inputs/color-picker/examples.mdx +20 -59
- package/components/inputs/color-picker/format-menu.tsx +212 -0
- package/components/inputs/color-picker/index.tsx +190 -1776
- package/components/inputs/color-picker/inputs-row.tsx +196 -0
- package/components/inputs/color-picker/popover.tsx +161 -0
- package/components/inputs/color-picker/saturation-square.tsx +167 -0
- package/components/inputs/color-picker/swatches.tsx +178 -0
- package/components/inputs/combobox/context.ts +90 -0
- package/components/inputs/combobox/examples.mdx +103 -206
- package/components/inputs/combobox/fields.tsx +328 -0
- package/components/inputs/combobox/index.tsx +155 -1310
- package/components/inputs/combobox/list.tsx +415 -0
- package/components/inputs/combobox/remote-demo.tsx +70 -74
- package/components/inputs/date-time/calendar/examples.mdx +0 -11
- package/components/inputs/date-time/calendar/index.tsx +32 -59
- package/components/inputs/date-time/calendar/use-month-window.ts +35 -32
- package/components/inputs/date-time/date-picker/examples.mdx +59 -155
- package/components/inputs/date-time/date-picker/index.tsx +186 -370
- package/components/inputs/date-time/date-picker/masked-date-input.tsx +105 -247
- package/components/inputs/date-time/date-range-picker/examples.mdx +6 -62
- package/components/inputs/date-time/date-range-picker/index.tsx +105 -404
- package/components/inputs/date-time/date-value.ts +37 -0
- package/components/inputs/date-time/day-rules.ts +22 -0
- package/components/inputs/date-time/duration-picker/examples.mdx +0 -24
- package/components/inputs/date-time/duration-picker/index.tsx +50 -140
- package/components/inputs/date-time/month-picker/examples.mdx +0 -29
- package/components/inputs/date-time/month-picker/index.tsx +48 -132
- package/components/inputs/date-time/picker-shell.tsx +226 -347
- package/components/inputs/date-time/time-columns.tsx +11 -15
- package/components/inputs/date-time/time-picker/examples.mdx +0 -31
- package/components/inputs/date-time/time-picker/index.tsx +37 -118
- package/components/inputs/field/examples.mdx +81 -39
- package/components/inputs/field/index.tsx +113 -103
- package/components/inputs/file-dropzone/examples.mdx +23 -24
- package/components/inputs/file-dropzone/file-row.tsx +20 -21
- package/components/inputs/file-dropzone/index.tsx +130 -129
- package/components/inputs/file-dropzone/upload-demo.tsx +22 -18
- package/components/inputs/file-dropzone/variants.ts +3 -1
- package/components/inputs/input/examples.mdx +19 -74
- package/components/inputs/input/index.tsx +86 -149
- package/components/inputs/input/password-demo.tsx +5 -5
- package/components/inputs/label/examples.mdx +19 -26
- package/components/inputs/label/index.tsx +21 -34
- package/components/inputs/number-input/examples.mdx +63 -36
- package/components/inputs/number-input/index.tsx +62 -57
- package/components/inputs/radio/examples.mdx +24 -39
- package/components/inputs/radio/index.tsx +125 -328
- package/components/inputs/search/examples.mdx +3 -3
- package/components/inputs/search/index.tsx +46 -39
- package/components/inputs/select/examples.mdx +76 -167
- package/components/inputs/select/index.tsx +252 -776
- package/components/inputs/slider/comfortable.tsx +524 -0
- package/components/inputs/slider/compact.tsx +690 -0
- package/components/inputs/slider/examples.mdx +9 -35
- package/components/inputs/slider/geometry.ts +88 -0
- package/components/inputs/slider/index.tsx +65 -1796
- package/components/inputs/slider/value-display.tsx +184 -0
- package/components/inputs/switch/examples.mdx +31 -33
- package/components/inputs/switch/index.tsx +55 -107
- package/components/inputs/textarea/examples.mdx +23 -61
- package/components/inputs/textarea/index.tsx +21 -99
- package/components/navigation/navigation-menu/content.tsx +76 -0
- package/components/navigation/navigation-menu/context.ts +34 -0
- package/components/navigation/navigation-menu/examples.mdx +21 -84
- package/components/navigation/navigation-menu/index.tsx +139 -639
- package/components/navigation/navigation-menu/item.tsx +47 -0
- package/components/navigation/navigation-menu/link.tsx +104 -0
- package/components/navigation/navigation-menu/list.tsx +86 -0
- package/components/navigation/navigation-menu/trigger.tsx +78 -0
- package/components/navigation/navigation-menu/use-dom-rows.ts +56 -0
- package/components/navigation/pagination/examples.mdx +25 -34
- package/components/navigation/pagination/index.tsx +75 -153
- package/components/navigation/sidebar/examples.mdx +17 -23
- package/components/navigation/sidebar/index.tsx +59 -119
- package/components/navigation/sidebar/menu-scope.tsx +439 -0
- package/components/navigation/sidebar/row-label.tsx +61 -0
- package/components/navigation/sidebar/sidebar-context.tsx +71 -0
- package/components/navigation/sidebar/sidebar-group.tsx +299 -0
- package/components/navigation/sidebar/sidebar-menu-actions.tsx +209 -0
- package/components/navigation/sidebar/sidebar-menu-button.tsx +214 -0
- package/components/navigation/sidebar/sidebar-menu-item.tsx +207 -0
- package/components/navigation/sidebar/sidebar-menu-sub.tsx +180 -0
- package/components/navigation/sidebar/sidebar-parts.tsx +94 -0
- package/components/navigation/sidebar/sidebar-provider.tsx +248 -0
- package/components/navigation/sidebar/sidebar-rail.tsx +206 -0
- package/components/navigation/sidebar/sidebar-shell.tsx +180 -0
- package/components/navigation/sidebar/sidebar-shortcut.tsx +101 -0
- package/components/navigation/sidebar/sidebar.css +7 -11
- package/components/navigation/sidebar/use-measured-collapse.ts +62 -0
- package/components/navigation/tabs/context.ts +45 -0
- package/components/navigation/tabs/examples.mdx +63 -17
- package/components/navigation/tabs/index.tsx +82 -434
- package/components/navigation/tabs/item.tsx +161 -0
- package/components/navigation/tabs/list.tsx +143 -0
- package/components/overlays/alert-dialog/examples.mdx +2 -36
- package/components/overlays/alert-dialog/index.tsx +76 -90
- package/components/overlays/alert-dialog/pending-demo.tsx +3 -1
- package/components/overlays/command/index.tsx +28 -59
- package/components/overlays/context-menu/examples.mdx +58 -4
- package/components/overlays/context-menu/index.tsx +77 -221
- package/components/overlays/dialog/examples.mdx +8 -31
- package/components/overlays/dialog/index.tsx +81 -261
- package/components/overlays/dropdown/dropdown-search.tsx +33 -98
- package/components/overlays/dropdown/examples.mdx +77 -363
- package/components/overlays/dropdown/index.tsx +114 -1010
- package/components/overlays/dropdown/menu-item.tsx +98 -382
- package/components/overlays/dropdown/menu-popup.tsx +294 -0
- package/components/overlays/dropdown/panel-state.ts +176 -0
- package/components/overlays/dropdown/submenu.tsx +170 -0
- package/components/overlays/popover/anchored-demo.tsx +22 -13
- package/components/overlays/popover/examples.mdx +16 -65
- package/components/overlays/popover/index.tsx +93 -137
- package/components/overlays/preview-card/examples.mdx +4 -4
- package/components/overlays/preview-card/index.tsx +48 -103
- package/components/overlays/sheet/examples.mdx +0 -12
- package/components/overlays/sheet/index.tsx +44 -129
- package/components/overlays/toast/examples.mdx +33 -25
- package/components/overlays/toast/index.tsx +56 -203
- package/components/overlays/toast/manager.ts +63 -119
- package/components/overlays/tooltip/examples.mdx +6 -12
- package/components/overlays/tooltip/index.tsx +124 -264
- package/components/progress/index.tsx +24 -30
- package/components/progress/progress.css +6 -28
- package/components/progress/step-demo.tsx +2 -0
- package/components/table/context.ts +49 -0
- package/components/table/examples.mdx +40 -72
- package/components/table/head.tsx +105 -0
- package/components/table/index.tsx +73 -458
- package/components/table/parts.tsx +188 -0
- package/components/table/sort-demo.tsx +21 -30
- package/dist/base.css +141 -122
- package/dist/blocks/sidebar-app/index.d.ts +10 -2
- package/dist/blocks/sidebar-app/index.js +49 -40
- package/dist/components/AI/input-message/index.d.ts +22 -19
- package/dist/components/AI/input-message/index.js +30 -23
- package/dist/components/AI/thinking-indicator/index.d.ts +2 -0
- package/dist/components/AI/thinking-indicator/index.js +10 -9
- package/dist/components/accordion/index.d.ts +52 -85
- package/dist/components/accordion/index.js +25 -19
- package/dist/components/avatar/index.d.ts +10 -10
- package/dist/components/avatar/index.js +9 -8
- package/dist/components/badge/index.d.ts +11 -18
- package/dist/components/badge/index.js +9 -9
- package/dist/components/badge/variants.d.ts +2 -9
- package/dist/components/badge/variants.js +3 -5
- package/dist/components/button/index.d.ts +36 -60
- package/dist/components/button/index.js +12 -9
- package/dist/components/button/variants.d.ts +3 -34
- package/dist/components/button/variants.js +2 -4
- package/dist/components/card/index.d.ts +163 -108
- package/dist/components/card/index.js +30 -21
- package/dist/components/copy/index.d.ts +10 -41
- package/dist/components/copy/index.js +18 -15
- package/dist/components/inputs/checkbox/index.d.ts +25 -25
- package/dist/components/inputs/checkbox/index.js +22 -18
- package/dist/components/inputs/color-picker/index.d.ts +65 -53
- package/dist/components/inputs/color-picker/index.js +35 -29
- package/dist/components/inputs/combobox/index.d.ts +147 -152
- package/dist/components/inputs/combobox/index.js +31 -29
- package/dist/components/inputs/date-time/calendar/index.d.ts +18 -24
- package/dist/components/inputs/date-time/calendar/index.js +17 -15
- package/dist/components/inputs/date-time/date-picker/index.d.ts +52 -96
- package/dist/components/inputs/date-time/date-picker/index.js +42 -35
- package/dist/components/inputs/date-time/date-range-picker/index.d.ts +48 -108
- package/dist/components/inputs/date-time/date-range-picker/index.js +40 -35
- package/dist/components/inputs/date-time/duration-picker/index.d.ts +21 -67
- package/dist/components/inputs/date-time/duration-picker/index.js +39 -33
- package/dist/components/inputs/date-time/month-picker/index.d.ts +18 -61
- package/dist/components/inputs/date-time/month-picker/index.js +38 -32
- package/dist/components/inputs/date-time/time-picker/index.d.ts +18 -59
- package/dist/components/inputs/date-time/time-picker/index.js +39 -33
- package/dist/components/inputs/field/index.d.ts +37 -41
- package/dist/components/inputs/field/index.js +13 -14
- package/dist/components/inputs/file-dropzone/index.d.ts +32 -25
- package/dist/components/inputs/file-dropzone/index.js +18 -15
- package/dist/components/inputs/file-dropzone/variants.js +1 -1
- package/dist/components/inputs/input/index.d.ts +48 -50
- package/dist/components/inputs/input/index.js +14 -12
- package/dist/components/inputs/label/index.d.ts +12 -10
- package/dist/components/inputs/label/index.js +5 -4
- package/dist/components/inputs/number-input/index.d.ts +31 -23
- package/dist/components/inputs/number-input/index.js +16 -14
- package/dist/components/inputs/radio/index.d.ts +20 -16
- package/dist/components/inputs/radio/index.js +20 -16
- package/dist/components/inputs/search/index.d.ts +12 -5
- package/dist/components/inputs/search/index.js +33 -26
- package/dist/components/inputs/select/index.d.ts +88 -99
- package/dist/components/inputs/select/index.js +32 -29
- package/dist/components/inputs/slider/index.d.ts +26 -48
- package/dist/components/inputs/slider/index.js +9 -10
- package/dist/components/inputs/switch/index.d.ts +12 -6
- package/dist/components/inputs/switch/index.js +17 -15
- package/dist/components/inputs/textarea/index.d.ts +12 -22
- package/dist/components/inputs/textarea/index.js +12 -9
- package/dist/components/navigation/navigation-menu/index.d.ts +112 -83
- package/dist/components/navigation/navigation-menu/index.js +31 -27
- package/dist/components/navigation/pagination/index.d.ts +25 -38
- package/dist/components/navigation/pagination/index.js +27 -34
- package/dist/components/navigation/sidebar/index.d.ts +236 -230
- package/dist/components/navigation/sidebar/index.js +59 -55
- package/dist/components/navigation/tabs/index.d.ts +62 -45
- package/dist/components/navigation/tabs/index.js +23 -17
- package/dist/components/overlays/alert-dialog/index.d.ts +71 -106
- package/dist/components/overlays/alert-dialog/index.js +24 -19
- package/dist/components/overlays/command/index.d.ts +40 -31
- package/dist/components/overlays/command/index.js +31 -25
- package/dist/components/overlays/context-menu/index.d.ts +70 -84
- package/dist/components/overlays/context-menu/index.js +35 -31
- package/dist/components/overlays/dialog/index.d.ts +82 -98
- package/dist/components/overlays/dialog/index.js +23 -20
- package/dist/components/overlays/dropdown/index.d.ts +191 -357
- package/dist/components/overlays/dropdown/index.js +35 -41
- package/dist/components/overlays/popover/index.d.ts +81 -52
- package/dist/components/overlays/popover/index.js +17 -13
- package/dist/components/overlays/preview-card/index.d.ts +52 -26
- package/dist/components/overlays/preview-card/index.js +16 -12
- package/dist/components/overlays/sheet/index.d.ts +41 -45
- package/dist/components/overlays/sheet/index.js +24 -19
- package/dist/components/overlays/toast/index.d.ts +73 -183
- package/dist/components/overlays/toast/index.js +20 -21
- package/dist/components/overlays/tooltip/index.d.ts +80 -118
- package/dist/components/overlays/tooltip/index.js +14 -12
- package/dist/components/progress/index.d.ts +10 -11
- package/dist/components/progress/index.js +7 -6
- package/dist/components/table/index.d.ts +72 -71
- package/dist/components/table/index.js +18 -16
- package/dist/index.d.ts +2575 -3149
- package/dist/index.js +186 -202
- package/dist/lib/date-locale.d.ts +6 -13
- package/dist/lib/date-locale.js +5 -11
- package/dist/lib/date-mask.d.ts +41 -0
- package/dist/lib/date-mask.js +20 -0
- package/dist/lib/field-box.d.ts +114 -0
- package/dist/lib/field-box.js +18 -0
- package/dist/lib/field-classes.d.ts +15 -119
- package/dist/lib/field-classes.js +4 -21
- package/dist/lib/fluid-hover-highlight.d.ts +3 -25
- package/dist/lib/fluid-hover-highlight.js +8 -13
- package/dist/lib/focus-ring.d.ts +16 -10
- package/dist/lib/focus-ring.js +6 -6
- package/dist/lib/goo-indicator.js +6 -5
- package/dist/lib/icon-context.d.ts +2 -8
- package/dist/lib/icon-context.js +2 -6
- package/dist/lib/merge-refs.d.ts +10 -0
- package/dist/lib/merge-refs.js +8 -0
- package/dist/lib/morph-layers.d.ts +12 -6
- package/dist/lib/morph-layers.js +7 -6
- package/dist/lib/morph-part.js +3 -3
- package/dist/lib/overlay.d.ts +113 -0
- package/dist/lib/overlay.js +21 -0
- package/dist/lib/popup-rows.d.ts +101 -0
- package/dist/lib/popup-rows.js +25 -0
- package/dist/lib/popup-surface.d.ts +92 -0
- package/dist/lib/popup-surface.js +17 -0
- package/dist/lib/popup.d.ts +17 -1
- package/dist/lib/popup.js +4 -1
- package/dist/lib/rect.d.ts +16 -0
- package/dist/lib/rect.js +12 -0
- package/dist/lib/reduced-motion.js +1 -1
- package/dist/lib/row-group.d.ts +100 -0
- package/dist/lib/row-group.js +12 -0
- package/dist/lib/row-index.d.ts +12 -7
- package/dist/lib/row-index.js +4 -2
- package/dist/lib/scroll-column.d.ts +1 -5
- package/dist/lib/scroll-column.js +13 -12
- package/dist/lib/shape-classes.d.ts +16 -0
- package/dist/lib/shape-classes.js +6 -0
- package/dist/lib/shape-context.d.ts +2 -9
- package/dist/lib/shape-context.js +3 -7
- package/dist/lib/size-context.d.ts +1 -2
- package/dist/lib/size-context.js +2 -7
- package/dist/lib/size-scale.js +1 -1
- package/dist/lib/slot.d.ts +31 -26
- package/dist/lib/slot.js +9 -9
- package/dist/lib/spinner-glyph.d.ts +7 -0
- package/dist/lib/spinner-glyph.js +7 -0
- package/dist/lib/springs.d.ts +5 -1
- package/dist/lib/springs.js +4 -2
- package/dist/lib/surface-classes.js +1 -1
- package/dist/lib/surface-context.d.ts +3 -1
- package/dist/lib/surface-context.js +3 -1
- package/dist/lib/use-autosize-textarea.d.ts +16 -0
- package/dist/lib/use-autosize-textarea.js +7 -0
- package/dist/lib/use-controllable-state.d.ts +15 -1
- package/dist/lib/use-controllable-state.js +1 -1
- package/dist/lib/use-fluid-hover.d.ts +1 -49
- package/dist/lib/use-fluid-hover.js +1 -7
- package/dist/lib/use-is-mobile.js +1 -1
- package/dist/lib/use-iso-layout-effect.d.ts +7 -0
- package/dist/lib/use-iso-layout-effect.js +6 -0
- package/dist/lib/use-keyboard-nav-gate.js +3 -2
- package/dist/lib/use-merge-split.js +7 -6
- package/dist/lib/use-morph.d.ts +13 -7
- package/dist/lib/use-morph.js +4 -3
- package/dist/lib/use-touch-primary.js +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/lib/weight-label.d.ts +26 -0
- package/dist/lib/weight-label.js +7 -0
- package/dist/preset.d.ts +4 -8
- package/dist/preset.js +8 -8
- package/dist/primitives/code/index.js +8 -8
- package/dist/primitives/craft/index.d.ts +1 -1
- package/dist/primitives/craft/index.js +13 -12
- package/dist/primitives/fluid-hover/index.d.ts +13 -14
- package/dist/primitives/fluid-hover/index.js +13 -10
- package/dist/primitives/morph/index.d.ts +1 -1
- package/dist/primitives/morph/index.js +20 -16
- package/dist/primitives/motion/index.d.ts +2 -0
- package/dist/primitives/motion/index.js +14 -11
- package/dist/primitives/scroll-area/index.d.ts +5 -4
- package/dist/primitives/scroll-area/index.js +5 -5
- package/dist/primitives/separator/index.d.ts +12 -11
- package/dist/primitives/separator/index.js +2 -2
- package/dist/primitives/sizes/index.d.ts +17 -4
- package/dist/primitives/sizes/index.js +7 -4
- package/dist/primitives/skeleton/index.d.ts +8 -8
- package/dist/primitives/skeleton/index.js +7 -6
- package/dist/primitives/surface/index.d.ts +12 -25
- package/dist/primitives/surface/index.js +8 -6
- package/dist/shared/{components-yxmxn2jp.js → components-07g2gbjy.js} +30 -75
- package/dist/shared/components-099sdasz.js +552 -0
- package/dist/shared/{components-bsqynhaj.js → components-0h3f5jae.js} +49 -51
- package/dist/shared/{components-wbbckbw8.js → components-0mrhj88d.js} +13 -12
- package/dist/shared/{components-0h78g3b5.js → components-0p2na0cp.js} +19 -47
- package/dist/shared/components-1a7cr7vh.js +40 -0
- package/dist/shared/components-1axxc3tk.js +334 -0
- package/dist/shared/components-1hc3xv0y.js +381 -0
- package/dist/shared/{components-gyt7my41.js → components-1jxw899c.js} +94 -84
- package/dist/shared/{components-jqpefjsn.js → components-1nv9q3s8.js} +24 -44
- package/dist/shared/components-1p3k62x2.js +137 -0
- package/dist/shared/{components-kz5q11pp.js → components-2xmke84n.js} +12 -4
- package/dist/shared/{components-c7rwx0ap.js → components-346ged8v.js} +24 -3
- package/dist/shared/{components-4j3t39dd.js → components-34brwmgp.js} +12 -11
- package/dist/shared/components-38wa9nx5.js +19 -0
- package/dist/shared/components-3hgk57s0.js +27 -0
- package/dist/shared/{components-px2zm7dc.js → components-3js2vgds.js} +13 -6
- package/dist/shared/{components-ctqmge8t.js → components-3m4rqrqm.js} +10 -3
- package/dist/shared/{components-3ey0hzpb.js → components-45r18egt.js} +11 -1
- package/dist/shared/components-50rh4ggz.js +54 -0
- package/dist/shared/components-5atrr490.js +99 -0
- package/dist/shared/components-5f3tq4qb.js +70 -0
- package/dist/shared/{components-dc5q749x.js → components-5vyaexsj.js} +16 -17
- package/dist/shared/{components-pwayrkw9.js → components-5ynncdpn.js} +5 -4
- package/dist/shared/{components-1e64t8aj.js → components-62mg6pab.js} +232 -93
- package/dist/shared/{components-drxrtnp2.js → components-6f5pyzb2.js} +8 -0
- package/dist/shared/{components-868v7scv.js → components-6xfhc5qm.js} +104 -169
- package/dist/shared/{components-yhgq0qxx.js → components-7c4a0egq.js} +20 -12
- package/dist/shared/components-7fqnqbh0.js +79 -0
- package/dist/shared/components-7fsy0jxg.js +443 -0
- package/dist/shared/{components-p0fm0bab.js → components-7t3pz7v7.js} +496 -526
- package/dist/shared/components-85epgxwf.js +620 -0
- package/dist/shared/{components-wknae3m4.js → components-86vvx0c8.js} +75 -121
- package/dist/shared/{components-wgtjt2af.js → components-88ktjdg0.js} +30 -27
- package/dist/shared/{components-ft3zdc79.js → components-88r046aa.js} +6 -6
- package/dist/shared/{components-xd3emmy4.js → components-8hfrd2fk.js} +1462 -1464
- package/dist/shared/components-8sazy704.js +146 -0
- package/dist/shared/{components-rrbpmfx4.js → components-8wp8d8q1.js} +8 -0
- package/dist/shared/{components-rtadhd9j.js → components-9ybenn5v.js} +16 -16
- package/dist/shared/components-amsc86fb.js +293 -0
- package/dist/shared/{components-9as3rf68.js → components-az04rmng.js} +12 -6
- package/dist/shared/components-bdkm2jzy.js +34 -0
- package/dist/shared/{components-xjkdvnbg.js → components-be3wggg1.js} +54 -48
- package/dist/shared/components-bkwjvvkh.js +18 -0
- package/dist/shared/{components-vf45j12c.js → components-ceyn28cf.js} +7 -0
- package/dist/shared/{components-3h92d94m.js → components-cy5z8zxy.js} +1 -2
- package/dist/shared/components-dm86y7b3.js +105 -0
- package/dist/shared/{components-c9yr4ed1.js → components-ejn6tvbw.js} +8 -6
- package/dist/shared/{components-34txk9rj.js → components-ew4wq7mj.js} +7 -0
- package/dist/shared/{components-svkt577j.js → components-f75y4gn8.js} +53 -70
- package/dist/shared/components-f9adtfq8.js +34 -0
- package/dist/shared/{components-2a7hcand.js → components-gbsdhmrv.js} +48 -83
- package/dist/shared/{components-9sttq78t.js → components-gc5zky2w.js} +54 -59
- package/dist/shared/{components-bae8sbjx.js → components-gkdx1787.js} +12 -6
- package/dist/shared/{components-124epb7f.js → components-grxgqa75.js} +3 -7
- package/dist/shared/components-gw0wd7gd.js +986 -0
- package/dist/shared/components-j4z3rtw2.js +179 -0
- package/dist/shared/{components-t5pk5nmc.js → components-j8tcbm8y.js} +927 -953
- package/dist/shared/components-jm91mjm1.js +297 -0
- package/dist/shared/{components-b94t6qtj.js → components-jtfptckj.js} +44 -39
- package/dist/shared/components-jx9qb4z8.js +63 -0
- package/dist/shared/components-k785rge6.js +336 -0
- package/dist/shared/{components-r8eqs7gz.js → components-k81x1aea.js} +10 -6
- package/dist/shared/{components-qx27excf.js → components-kn5c7652.js} +11 -13
- package/dist/shared/components-mse06t0x.js +31 -0
- package/dist/shared/{components-cet3jpa0.js → components-n7e31ct4.js} +71 -49
- package/dist/shared/components-nskr4hwg.js +1008 -0
- package/dist/shared/components-nv5m3gcv.js +37 -0
- package/dist/shared/components-nwa2a9tq.js +27 -0
- package/dist/shared/{components-f7h57m6t.js → components-p0x8ren6.js} +3 -1
- package/dist/shared/{components-2krsc300.js → components-p0z99d5b.js} +67 -92
- package/dist/shared/{components-b1e239g3.js → components-pa43g2r2.js} +15 -4
- package/dist/shared/{components-m06yq8wk.js → components-pedbt2dc.js} +35 -49
- package/dist/shared/components-pva1wj1r.js +27 -0
- package/dist/shared/components-q4wyd06h.js +382 -0
- package/dist/shared/{components-71nbt03m.js → components-qrpdtvxa.js} +12 -45
- package/dist/shared/components-r33dxr5j.js +91 -0
- package/dist/shared/{components-005jt2nz.js → components-re8p99fj.js} +53 -179
- package/dist/shared/components-s217vq1n.js +35 -0
- package/dist/shared/{components-vc864c51.js → components-sesrjvcc.js} +7 -6
- package/dist/shared/{components-qh1cvj6p.js → components-skn189mp.js} +29 -36
- package/dist/shared/{components-tz4gaf1v.js → components-tcyz2tdn.js} +9 -1
- package/dist/shared/components-tjxy84s9.js +53 -0
- package/dist/shared/components-tnj6mkhg.js +89 -0
- package/dist/shared/{components-de99ykt7.js → components-tz0axc0f.js} +1 -0
- package/dist/shared/components-v2j3jx89.js +7 -0
- package/dist/shared/components-vcte8p75.js +71 -0
- package/dist/shared/{components-c74gf16d.js → components-vgzerqt0.js} +34 -47
- package/dist/shared/components-vp6vzsee.js +30 -0
- package/dist/shared/components-vpkh6j83.js +42 -0
- package/dist/shared/{components-4nck8acq.js → components-wgd1nebp.js} +21 -14
- package/dist/shared/{components-pt5ftm4p.js → components-wrbw67f6.js} +10 -3
- package/dist/shared/{components-tz1fv35x.js → components-wwd093xg.js} +1 -0
- package/dist/shared/components-wyfmhtw9.js +61 -0
- package/dist/shared/{components-d3shbwqq.js → components-xpw8dzb0.js} +16 -23
- package/dist/shared/{components-mattt5jp.js → components-xzcgr3gy.js} +62 -60
- package/dist/shared/{components-jcnjay5g.js → components-ycx2kxeq.js} +9 -1
- package/dist/shared/components-zbzx62pg.js +1771 -0
- package/dist/shared/{components-dtca4s6b.js → components-zf0nnvvg.js} +67 -147
- package/dist/shared/{components-h83az0bz.js → components-znspksk0.js} +9 -1
- package/dist/shared/components-zpatc9x3.js +78 -0
- package/dist/styles.css +218 -235
- package/dist/tailwind.css +20 -8
- package/dist/tokens.css +53 -68
- package/index.ts +16 -2
- package/lib/date-locale.ts +12 -149
- package/lib/date-mask.ts +146 -0
- package/lib/field-box.ts +117 -0
- package/lib/field-classes.ts +85 -100
- package/lib/fluid-hover-highlight.tsx +12 -57
- package/lib/focus-ring.tsx +25 -22
- package/lib/goo-indicator.tsx +2 -0
- package/lib/icon-context.tsx +23 -75
- package/lib/merge-refs.ts +29 -0
- package/lib/morph-layers.tsx +3 -1
- package/lib/morph-part.tsx +5 -3
- package/lib/overlay.tsx +118 -0
- package/lib/popup-rows.tsx +149 -0
- package/lib/popup-surface.tsx +52 -0
- package/lib/popup.ts +10 -9
- package/lib/rect.ts +48 -0
- package/lib/reduced-motion.ts +2 -0
- package/lib/row-group.tsx +113 -0
- package/lib/row-index.tsx +27 -10
- package/lib/scroll-column.tsx +26 -53
- package/lib/shape-classes.ts +56 -0
- package/lib/shape-context.tsx +10 -79
- package/lib/size-context.tsx +8 -21
- package/lib/size-scale.ts +3 -9
- package/lib/slot.tsx +124 -0
- package/lib/spinner-glyph.tsx +27 -0
- package/lib/springs.ts +8 -9
- package/lib/surface-classes.ts +3 -8
- package/lib/surface-context.tsx +10 -5
- package/lib/use-autosize-textarea.ts +64 -0
- package/lib/use-controllable-state.ts +30 -15
- package/lib/use-fluid-hover.ts +9 -11
- package/lib/use-is-mobile.ts +5 -5
- package/lib/use-iso-layout-effect.ts +14 -0
- package/lib/use-keyboard-nav-gate.ts +5 -6
- package/lib/use-merge-split.tsx +5 -15
- package/lib/use-morph.ts +34 -76
- package/lib/use-touch-primary.tsx +5 -5
- package/lib/utils.ts +4 -11
- package/lib/weight-label.tsx +69 -0
- package/package.json +57 -194
- package/primitives/code/index.tsx +4 -2
- package/primitives/craft/demos.tsx +4 -2
- package/primitives/craft/examples.mdx +32 -34
- package/primitives/craft/index.tsx +3 -0
- package/primitives/fluid-hover/examples.mdx +1 -1
- package/primitives/fluid-hover/index.tsx +33 -68
- package/primitives/morph/examples.mdx +16 -19
- package/primitives/morph/index.tsx +5 -3
- package/primitives/motion/examples.mdx +3 -3
- package/primitives/motion/index.tsx +6 -22
- package/primitives/scroll-area/examples.mdx +4 -4
- package/primitives/scroll-area/index.tsx +16 -41
- package/primitives/separator/examples.mdx +2 -2
- package/primitives/separator/index.tsx +15 -14
- package/primitives/sizes/examples.mdx +1 -1
- package/primitives/sizes/index.tsx +28 -42
- package/primitives/skeleton/examples.mdx +6 -6
- package/primitives/skeleton/index.tsx +24 -10
- package/primitives/skeleton/skeleton.css +8 -3
- package/primitives/surface/examples.mdx +11 -11
- package/primitives/surface/index.tsx +15 -40
- package/primitives/surface/surface.css +1 -1
- package/DESIGN.md +0 -623
- package/components/inputs/select/variants.ts +0 -32
- package/components/navigation/sidebar/sidebar-core.tsx +0 -1408
- package/components/navigation/sidebar/sidebar-menu.tsx +0 -1495
- package/components/navigation/sidebar/variants.ts +0 -55
- package/components/navigation/tabs-subtle/examples.mdx +0 -49
- package/components/navigation/tabs-subtle/index.tsx +0 -512
- package/components/overlays/dropdown/menu-parts.tsx +0 -725
- package/components/overlays/toast/global-demo.tsx +0 -72
- package/dist/components/inputs/color-picker/variants.d.ts +0 -61
- package/dist/components/inputs/color-picker/variants.js +0 -28
- package/dist/components/inputs/select/variants.d.ts +0 -5
- package/dist/components/inputs/select/variants.js +0 -6
- package/dist/components/navigation/sidebar/variants.d.ts +0 -25
- package/dist/components/navigation/sidebar/variants.js +0 -28
- package/dist/components/navigation/tabs-subtle/index.d.ts +0 -73
- package/dist/components/navigation/tabs-subtle/index.js +0 -24
- package/dist/docs/index.d.ts +0 -83
- package/dist/docs/index.js +0 -288
- package/dist/docs/vite.d.ts +0 -31
- package/dist/docs/vite.js +0 -45
- package/dist/lib/field-variants.d.ts +0 -47
- package/dist/lib/field-variants.js +0 -26
- package/dist/lib/inert.d.ts +0 -9
- package/dist/lib/inert.js +0 -8
- package/dist/lib/row-order.d.ts +0 -28
- package/dist/lib/row-order.js +0 -10
- package/dist/lib/shape-radius.d.ts +0 -19
- package/dist/lib/shape-radius.js +0 -6
- package/dist/shared/components-01w9qcfa.js +0 -277
- package/dist/shared/components-26snnbs9.js +0 -322
- package/dist/shared/components-2qbqqpgq.js +0 -1545
- package/dist/shared/components-303jf96s.js +0 -1478
- package/dist/shared/components-4vfm04wq.js +0 -82
- package/dist/shared/components-54nq988h.js +0 -123
- package/dist/shared/components-7qx17na9.js +0 -300
- package/dist/shared/components-7s7pykk5.js +0 -281
- package/dist/shared/components-8jrk5eye.js +0 -448
- package/dist/shared/components-91zw3d9f.js +0 -136
- package/dist/shared/components-9jmjnkqd.js +0 -503
- package/dist/shared/components-adkarj8n.js +0 -35
- package/dist/shared/components-c5w5zk0s.js +0 -218
- package/dist/shared/components-cnead5qm.js +0 -185
- package/dist/shared/components-czdvj1a8.js +0 -266
- package/dist/shared/components-dcc02hs2.js +0 -31
- package/dist/shared/components-dhgk6mbt.js +0 -16
- package/dist/shared/components-g3eafs70.js +0 -337
- package/dist/shared/components-gx4h5rbb.js +0 -40
- package/dist/shared/components-h6p86be3.js +0 -19
- package/dist/shared/components-hdzrqqpx.js +0 -55
- package/dist/shared/components-hgv6tygd.js +0 -986
- package/dist/shared/components-krtx3m5b.js +0 -84
- package/dist/shared/components-kswxnm3h.js +0 -24
- package/dist/shared/components-mhza2wdn.js +0 -482
- package/dist/shared/components-mrbaxt8q.js +0 -62
- package/dist/shared/components-pv1dyrtn.js +0 -678
- package/dist/shared/components-s8yqk2dc.js +0 -124
- package/dist/shared/components-syynwm1r.js +0 -114
- package/dist/shared/components-tv7b8tet.js +0 -271
- package/dist/shared/components-w2jqa6hx.js +0 -404
- package/dist/shared/components-xdqmt6ed.js +0 -20
- package/dist/shared/components-y0kfy2g4.js +0 -578
- package/dist/shared/components-z3v0n0de.js +0 -11
- package/dist/shared/components-z8fedth5.js +0 -305
- package/dist/shared/components-zkk3fmw8.js +0 -150
- package/dist/tokens/colors.css +0 -230
- package/dist/tokens/motion.css +0 -40
- package/dist/tokens/radius.css +0 -10
- package/dist/tokens/spacing.css +0 -9
- package/dist/tokens/typography.css +0 -119
- package/docs/chrome.css +0 -120
- package/docs/chrome.tsx +0 -283
- package/docs/index.ts +0 -9
- package/docs/vite.ts +0 -85
- package/lib/field-variants.ts +0 -117
- package/lib/inert.ts +0 -22
- package/lib/row-order.tsx +0 -126
- package/lib/shape-radius.ts +0 -67
- package/lib/slot.ts +0 -115
- package/preset.ts +0 -199
|
@@ -1,161 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
/*
|
|
1
|
+
/*!
|
|
3
2
|
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
4
3
|
* `registry/default/input-message.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
5
|
-
* MIT License © 2026 Micka Touillaud
|
|
6
|
-
* Local modifications:
|
|
7
|
-
* - `"use client"` directive dropped (no RSC here).
|
|
8
|
-
* - `framer-motion` → `motion/react`; `@/lib/*` and `@/hooks/*` rewritten to
|
|
9
|
-
* `../../../lib/*` (`SizeProvider` → `../../../primitives/sizes`); `@/components/ui/fluid-hover-highlight` →
|
|
10
|
-
* `../../../lib/fluid-hover-highlight`; `@/registry/radix/{button,tooltip}` →
|
|
11
|
-
* `../../button` / `../../overlays/tooltip`; `@/registry/default/file-thumbnail` → `./file-thumbnail`
|
|
12
|
-
* (vendored beside this file).
|
|
13
|
-
* - Uncontrolled twins (Base UI shape, via `lib/use-controllable-state`), so the
|
|
14
|
-
* composer works with no state in the caller. The controlled API is unchanged — every
|
|
15
|
-
* `value` / `files` / `queue` / `status` prop still wins and still reports through its
|
|
16
|
-
* callback:
|
|
17
|
-
* · `value` / `onValueChange` are now optional and gain `defaultValue`;
|
|
18
|
-
* · `defaultFiles` seeds an internal file list — attachments are enabled by
|
|
19
|
-
* `onFilesChange` OR `defaultFiles` (upstream: `onFilesChange` alone);
|
|
20
|
-
* · `defaultQueue` seeds an internal queue — the queue is enabled by
|
|
21
|
-
* `onQueueChange` OR `defaultQueue`, still only alongside a status;
|
|
22
|
-
* · `defaultStatus` seeds an internal status (plus an optional `onStatusChange`);
|
|
23
|
-
* with the status uncontrolled the Stop control is offered even without
|
|
24
|
-
* `onStop` and flips the status to `"idle"` itself, which is the edge that
|
|
25
|
-
* auto-dispatches the head of the queue;
|
|
26
|
-
* · an uncontrolled draft / file list clears itself after `onSend`, which a
|
|
27
|
-
* controlled consumer does by hand.
|
|
28
|
-
* - React 18 / `noUncheckedIndexedAccess`: `useRef<HTMLDivElement | null>` where the ref is
|
|
29
|
-
* assigned, guards on `queue[0]`, `history[i]`, `suggestions[i]` and the swap in
|
|
30
|
-
* `moveQueued`, and `FilePreviewTile` turned into a `forwardRef` — it renders inside
|
|
31
|
-
* `<AnimatePresence mode="popLayout">`, which measures the exiting child through a ref
|
|
32
|
-
* (React 19 passes `ref` as a plain prop; React 18 warns and drops it).
|
|
33
|
-
* - modo item: TSDoc from the FF "InputMessage" docs page (its Playground section is
|
|
34
|
-
* skipped, and the transcript around the Attachments / Send Handler demos is dropped —
|
|
35
|
-
* `ChatMessage` is not part of this port).
|
|
36
|
-
* - Styling reads DS tokens (AGENTS.md styling): `text-[Npx]` →
|
|
37
|
-
* `text-<role>[-compact]`; `leading-[18px]` → `leading-4.5`; inline
|
|
38
|
-
* `fontVariationSettings` → `weight-*`; the hex focus-ring fallback →
|
|
39
|
-
* `ring-focus-ring` / `border-focus-ring`; literal colors → color tokens;
|
|
40
|
-
* `rounded-[Npx]` → radius tokens; `duration-80|120|160` and tier-length JS
|
|
41
|
-
* durations → `duration-<tier>` / `spring.*`.
|
|
4
|
+
* MIT License © 2026 Micka Touillaud (notice: LICENSE.fluid-functionalism). Local changes: see PORTING.md.
|
|
42
5
|
*/
|
|
43
6
|
|
|
44
|
-
|
|
7
|
+
'use client'
|
|
8
|
+
|
|
9
|
+
import { AnimatePresence, motion, Reorder } from 'motion/react'
|
|
45
10
|
import {
|
|
46
|
-
type ChangeEvent,
|
|
47
11
|
forwardRef,
|
|
48
12
|
type HTMLAttributes,
|
|
49
|
-
type DragEvent as ReactDragEvent,
|
|
50
13
|
type KeyboardEvent as ReactKeyboardEvent,
|
|
51
14
|
type MouseEvent as ReactMouseEvent,
|
|
52
|
-
type ReactNode,
|
|
53
15
|
type TextareaHTMLAttributes,
|
|
54
16
|
useCallback,
|
|
55
17
|
useEffect,
|
|
56
18
|
useId,
|
|
57
|
-
useLayoutEffect,
|
|
58
19
|
useMemo,
|
|
59
20
|
useRef,
|
|
60
|
-
useState,
|
|
61
21
|
} from 'react'
|
|
62
22
|
import { FluidHoverHighlight } from '../../../lib/fluid-hover-highlight'
|
|
63
23
|
import { useIcon } from '../../../lib/icon-context'
|
|
24
|
+
import { useReduceMotion } from '../../../lib/reduced-motion'
|
|
64
25
|
import { useShape } from '../../../lib/shape-context'
|
|
65
26
|
import { type SizeVariant, useSize } from '../../../lib/size-context'
|
|
66
27
|
import { spring } from '../../../lib/springs'
|
|
67
28
|
import { surfaceClasses } from '../../../lib/surface-classes'
|
|
68
29
|
import { SurfaceProvider } from '../../../lib/surface-context'
|
|
30
|
+
import { useAutosizeTextarea } from '../../../lib/use-autosize-textarea'
|
|
69
31
|
import { useControllableState } from '../../../lib/use-controllable-state'
|
|
70
|
-
import { useFluidHover
|
|
32
|
+
import { useFluidHover } from '../../../lib/use-fluid-hover'
|
|
33
|
+
import { useTouchPrimary } from '../../../lib/use-touch-primary'
|
|
71
34
|
import { cn } from '../../../lib/utils'
|
|
72
|
-
import {
|
|
35
|
+
import { SizeScope } from '../../../primitives/sizes'
|
|
73
36
|
import { Button } from '../../button'
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* height.
|
|
89
|
-
*
|
|
90
|
-
* Returns a ref for the region's CONTENT element. The height it reports is the
|
|
91
|
-
* clipping parent's scrollHeight, so inner margins count (the parent's
|
|
92
|
-
* overflow-hidden makes it a block formatting context, so they don't collapse
|
|
93
|
-
* out) and the value stays correct while the animated height is mid-flight.
|
|
94
|
-
* Observing the child rather than the parent keeps the ResizeObserver out of a
|
|
95
|
-
* feedback loop with that animation.
|
|
96
|
-
*/
|
|
97
|
-
function useRegionHeight() {
|
|
98
|
-
const roRef = useRef<ResizeObserver | null>(null)
|
|
99
|
-
const [height, setHeight] = useState<number | null>(null)
|
|
100
|
-
const ref = useCallback((el: HTMLElement | null) => {
|
|
101
|
-
roRef.current?.disconnect()
|
|
102
|
-
roRef.current = null
|
|
103
|
-
if (!el) return
|
|
104
|
-
const sync = () => {
|
|
105
|
-
const next = el.parentElement?.scrollHeight ?? el.offsetHeight
|
|
106
|
-
if (next > 0) setHeight(next)
|
|
107
|
-
}
|
|
108
|
-
sync()
|
|
109
|
-
const ro = new ResizeObserver(sync)
|
|
110
|
-
ro.observe(el)
|
|
111
|
-
roRef.current = ro
|
|
112
|
-
}, [])
|
|
113
|
-
return [ref, height] as const
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Touch devices have no hover, so hover-revealed affordances (like a queued
|
|
117
|
-
// row's × button) would never appear. `(hover: none)` flags those so they can
|
|
118
|
-
// be shown persistently instead. SSR-safe: starts false, resolves on mount.
|
|
119
|
-
function useIsTouch() {
|
|
120
|
-
const [isTouch, setIsTouch] = useState(false)
|
|
121
|
-
useEffect(() => {
|
|
122
|
-
const mq = window.matchMedia('(hover: none)')
|
|
123
|
-
const update = () => setIsTouch(mq.matches)
|
|
124
|
-
update()
|
|
125
|
-
mq.addEventListener('change', update)
|
|
126
|
-
return () => mq.removeEventListener('change', update)
|
|
127
|
-
}, [])
|
|
128
|
-
return isTouch
|
|
129
|
-
}
|
|
37
|
+
import { FilePreviewTile } from './file-preview-tile'
|
|
38
|
+
import { QueuedRow } from './queued-row'
|
|
39
|
+
import {
|
|
40
|
+
caretToEnd,
|
|
41
|
+
type InputMessageSlot,
|
|
42
|
+
type InputMessageSlotContext,
|
|
43
|
+
type InputMessageStatus,
|
|
44
|
+
type QueuedMessage,
|
|
45
|
+
} from './shared'
|
|
46
|
+
import { SuggestionRow } from './suggestion-row'
|
|
47
|
+
import { useComposerFiles } from './use-composer-files'
|
|
48
|
+
import { useHistoryNav } from './use-history-nav'
|
|
49
|
+
import { useMessageQueue } from './use-message-queue'
|
|
50
|
+
import { useRegionHeight } from './use-region-height'
|
|
130
51
|
|
|
131
52
|
const DEFAULT_ACCEPT = 'image/png,image/jpeg,application/pdf'
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
// fresh literal on every render would still churn the identity it stores.
|
|
135
|
-
const NO_FILES: File[] = []
|
|
136
|
-
const NO_QUEUE: QueuedMessage[] = []
|
|
137
|
-
|
|
138
|
-
type InputMessageStatus = 'idle' | 'streaming'
|
|
139
|
-
|
|
140
|
-
interface InputMessageSlotContext {
|
|
141
|
-
/** Opens the native file picker via the hidden `<input type="file">`.
|
|
142
|
-
* Pass `acceptOverride` (e.g. `"image/*"`) to scope the picker to a
|
|
143
|
-
* subset of the component's accept types just for this invocation. */
|
|
144
|
-
openFilePicker: (acceptOverride?: string) => void
|
|
145
|
-
/** Currently-attached files. */
|
|
146
|
-
files: File[]
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
type InputMessageSlot = ReactNode | ((ctx: InputMessageSlotContext) => ReactNode)
|
|
150
|
-
|
|
151
|
-
/** A message held in the queue while the assistant is responding. Carries the
|
|
152
|
-
* trimmed text plus a snapshot of the files attached when it was queued, so
|
|
153
|
-
* double-click-to-edit can restore both. `id` is a stable key minted on enqueue. */
|
|
154
|
-
interface QueuedMessage {
|
|
155
|
-
id: string
|
|
156
|
-
text: string
|
|
157
|
-
files: File[]
|
|
158
|
-
}
|
|
53
|
+
const NO_STRINGS: string[] = []
|
|
54
|
+
const REGION_SPRING = { ...spring.moderate, bounce: 0 }
|
|
159
55
|
|
|
160
56
|
interface InputMessageProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {
|
|
161
57
|
/** Step on the size ladder (see Sizes). Wins over the surrounding SizeProvider and propagates to the composer's rows, buttons and queued messages. */
|
|
@@ -194,7 +90,7 @@ interface InputMessageProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChan
|
|
|
194
90
|
accept?: string
|
|
195
91
|
/** Maximum number of attached files. Extra files beyond this limit are dropped. */
|
|
196
92
|
maxFiles?: number
|
|
197
|
-
/** Side length (in pixels) of each preview tile. Images use object-cover; PDFs render the first page via pdfjs; other types fall back to a centered icon. Defaults to 80. */
|
|
93
|
+
/** 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. */
|
|
198
94
|
filePreviewSize?: number
|
|
199
95
|
/** Extra props forwarded to the underlying textarea (value, onChange, onKeyDown, disabled and placeholder are controlled by the component). */
|
|
200
96
|
textareaProps?: Omit<
|
|
@@ -227,220 +123,7 @@ interface InputMessageProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChan
|
|
|
227
123
|
className?: string
|
|
228
124
|
}
|
|
229
125
|
|
|
230
|
-
|
|
231
|
-
// Composer-row tile: a FileThumbnail wrapped with enter/exit motion and a
|
|
232
|
-
// hover-revealed remove (×) button.
|
|
233
|
-
interface FilePreviewTileProps {
|
|
234
|
-
file: File
|
|
235
|
-
onRemove: () => void
|
|
236
|
-
size: number
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// React 18: the tile is rendered inside `<AnimatePresence mode="popLayout">`,
|
|
240
|
-
// which measures the exiting child through a ref. Upstream can be a plain
|
|
241
|
-
// function component (React 19 passes `ref` as a prop); here it has to be a
|
|
242
|
-
// forwardRef, or React logs "Function components cannot be given refs" and the
|
|
243
|
-
// pop-out measurement never lands.
|
|
244
|
-
const FilePreviewTile = forwardRef<HTMLDivElement, FilePreviewTileProps>(function FilePreviewTile(
|
|
245
|
-
{ file, onRemove, size },
|
|
246
|
-
ref,
|
|
247
|
-
) {
|
|
248
|
-
const XIcon = useIcon('x')
|
|
249
|
-
|
|
250
|
-
return (
|
|
251
|
-
<motion.div
|
|
252
|
-
ref={ref}
|
|
253
|
-
// `layout` animates sibling tiles into the gap when one is removed.
|
|
254
|
-
// Enter: spring.fast (0.08s) — the small-state-flip tier.
|
|
255
|
-
// Exit: 0.06s linear — exits should be slightly faster than enter.
|
|
256
|
-
layout
|
|
257
|
-
initial={{ opacity: 0, scale: 0.9 }}
|
|
258
|
-
animate={{ opacity: 1, scale: 1 }}
|
|
259
|
-
exit={{ opacity: 0, scale: 0.9, transition: spring.fast.exit }}
|
|
260
|
-
transition={spring.fast}
|
|
261
|
-
// `cursor-default` opts out of the parent's `cursor-text` so hovering
|
|
262
|
-
// a preview tile doesn't look like it'll land in the textarea.
|
|
263
|
-
className="relative shrink-0 cursor-default group/tile"
|
|
264
|
-
>
|
|
265
|
-
<FileThumbnail file={file} size={size} />
|
|
266
|
-
<Tooltip content="Remove" side="top">
|
|
267
|
-
<button
|
|
268
|
-
type="button"
|
|
269
|
-
onClick={e => {
|
|
270
|
-
e.stopPropagation()
|
|
271
|
-
onRemove()
|
|
272
|
-
}}
|
|
273
|
-
aria-label={`Remove ${file.name}`}
|
|
274
|
-
// Pinned to the light scheme (`light` class: dark circle + light X)
|
|
275
|
-
// regardless of theme — the close badge needs to read as a "delete
|
|
276
|
-
// affordance" over arbitrary image/PDF content, so it sits at a fixed
|
|
277
|
-
// contrast instead of flipping with the surrounding surface.
|
|
278
|
-
className="light absolute top-1 right-1 w-5 h-5 rounded-full bg-foreground text-background opacity-0 group-hover/tile:opacity-100 transition-opacity duration-fast flex items-center justify-center cursor-pointer outline-none focus-visible:opacity-100 focus-visible:ring-1 focus-visible:ring-focus-ring"
|
|
279
|
-
>
|
|
280
|
-
<XIcon size={12} strokeWidth={2.5} />
|
|
281
|
-
</button>
|
|
282
|
-
</Tooltip>
|
|
283
|
-
</motion.div>
|
|
284
|
-
)
|
|
285
|
-
})
|
|
286
|
-
|
|
287
|
-
// ─── Queued message row ───────────────────────────────────────────────────
|
|
288
|
-
// A pending message in the queue: a recessed, draggable row that reads as
|
|
289
|
-
// "staged, not live". Double-click (or Enter/F2) edits it back into the
|
|
290
|
-
// composer; the hover-revealed × (or Delete) removes it; drag — or Alt+↑/↓ —
|
|
291
|
-
// reorders. Top of the list is next to dispatch.
|
|
292
|
-
interface QueuedRowProps {
|
|
293
|
-
item: QueuedMessage
|
|
294
|
-
index: number
|
|
295
|
-
total: number
|
|
296
|
-
reduceMotion: boolean
|
|
297
|
-
isTouch: boolean
|
|
298
|
-
onEdit: (item: QueuedMessage) => void
|
|
299
|
-
onRemove: (item: QueuedMessage) => void
|
|
300
|
-
onMove: (item: QueuedMessage, dir: -1 | 1) => void
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
function QueuedRow({ item, index, total, reduceMotion, isTouch, onEdit, onRemove, onMove }: QueuedRowProps) {
|
|
304
|
-
const XIcon = useIcon('x')
|
|
305
|
-
const ImageIcon = useIcon('image')
|
|
306
|
-
const compactStep = useSize().variant === 'compact'
|
|
307
|
-
const fileCount = item.files.length
|
|
308
|
-
const label = item.text || `${fileCount} attachment${fileCount === 1 ? '' : 's'}`
|
|
309
|
-
|
|
310
|
-
return (
|
|
311
|
-
<Reorder.Item
|
|
312
|
-
value={item}
|
|
313
|
-
layout
|
|
314
|
-
// Enter: spring-fast chip category. Exit slightly faster (0.06s linear).
|
|
315
|
-
// Reduced-motion drops the scale.
|
|
316
|
-
initial={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.97 }}
|
|
317
|
-
animate={{ opacity: 1, scale: 1 }}
|
|
318
|
-
exit={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.97, transition: spring.fast.exit }}
|
|
319
|
-
transition={spring.fast}
|
|
320
|
-
aria-label={`Queued message ${index + 1} of ${total}: ${label}`}
|
|
321
|
-
tabIndex={0}
|
|
322
|
-
onDoubleClick={() => onEdit(item)}
|
|
323
|
-
onKeyDown={e => {
|
|
324
|
-
if (e.key === 'Enter' || e.key === 'F2') {
|
|
325
|
-
e.preventDefault()
|
|
326
|
-
onEdit(item)
|
|
327
|
-
} else if (e.key === 'Delete' || e.key === 'Backspace') {
|
|
328
|
-
e.preventDefault()
|
|
329
|
-
onRemove(item)
|
|
330
|
-
} else if (e.altKey && (e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
|
|
331
|
-
e.preventDefault()
|
|
332
|
-
onMove(item, e.key === 'ArrowUp' ? -1 : 1)
|
|
333
|
-
}
|
|
334
|
-
}}
|
|
335
|
-
className={cn(
|
|
336
|
-
// Fixed height (was py-1.5 around a 19.5px line box ≈ 31.5px) so the
|
|
337
|
-
// text-box trim on the label doesn't shrink the row.
|
|
338
|
-
'group/qrow flex items-center gap-2 rounded-lg bg-muted',
|
|
339
|
-
compactStep ? 'h-7 px-2 text-body-compact' : 'h-8 px-2.5 text-body',
|
|
340
|
-
'text-foreground/85 select-none outline-none',
|
|
341
|
-
'cursor-grab active:cursor-grabbing',
|
|
342
|
-
'focus-visible:ring-1 focus-visible:ring-focus-ring',
|
|
343
|
-
'weight-normal',
|
|
344
|
-
)}
|
|
345
|
-
>
|
|
346
|
-
{fileCount > 0 && (
|
|
347
|
-
<span className="flex shrink-0 items-center gap-0.5 text-muted-foreground">
|
|
348
|
-
<ImageIcon size={13} />
|
|
349
|
-
{item.text && <span className="tabular-nums">{fileCount}</span>}
|
|
350
|
-
</span>
|
|
351
|
-
)}
|
|
352
|
-
{/* py-1/-my-1 keeps truncate's overflow-hidden from clipping
|
|
353
|
-
ascenders and descenders outside the trimmed box. */}
|
|
354
|
-
<span className="min-w-0 flex-1 truncate [text-box:trim-both_cap_alphabetic] py-1 -my-1">{label}</span>
|
|
355
|
-
<Tooltip content="Remove" side="top">
|
|
356
|
-
<button
|
|
357
|
-
type="button"
|
|
358
|
-
// Stop the pointer-down from starting a Reorder drag, and the click
|
|
359
|
-
// from bubbling to the row's double-click/edit handler.
|
|
360
|
-
onPointerDown={e => e.stopPropagation()}
|
|
361
|
-
onClick={e => {
|
|
362
|
-
e.stopPropagation()
|
|
363
|
-
onRemove(item)
|
|
364
|
-
}}
|
|
365
|
-
aria-label={`Remove queued message: ${label}`}
|
|
366
|
-
className={cn(
|
|
367
|
-
'shrink-0 flex h-5 w-5 items-center justify-center rounded-full',
|
|
368
|
-
'text-muted-foreground hover:text-foreground hover:bg-hover',
|
|
369
|
-
// Hover devices reveal × on row-hover; touch has no hover, so keep
|
|
370
|
-
// it persistently visible there.
|
|
371
|
-
isTouch ? 'opacity-100' : 'opacity-0 group-hover/qrow:opacity-100 focus-visible:opacity-100',
|
|
372
|
-
'transition-opacity duration-fast cursor-pointer outline-none',
|
|
373
|
-
'focus-visible:ring-1 focus-visible:ring-focus-ring',
|
|
374
|
-
)}
|
|
375
|
-
>
|
|
376
|
-
<XIcon size={13} strokeWidth={2.5} />
|
|
377
|
-
</button>
|
|
378
|
-
</Tooltip>
|
|
379
|
-
</Reorder.Item>
|
|
380
|
-
)
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
// ─── Suggestion row ───────────────────────────────────────────────────────
|
|
384
|
-
// A suggested prompt in the listbox under the action bar. Registers itself
|
|
385
|
-
// with the fluid-hover system in an effect (MenuItem's pattern — an
|
|
386
|
-
// inline ref callback would re-register every render and keep the hook's
|
|
387
|
-
// measurement pass from ever settling). The highlight itself is the parent's
|
|
388
|
-
// sliding overlay, so the row only recolors its text when active.
|
|
389
|
-
interface SuggestionRowProps {
|
|
390
|
-
text: string
|
|
391
|
-
index: number
|
|
392
|
-
active: boolean
|
|
393
|
-
/** Show a ↓ keycap hint in the icon slot — the first row displays it while
|
|
394
|
-
* no row is highlighted, signposting that ArrowDown enters the list. */
|
|
395
|
-
keyHint: boolean
|
|
396
|
-
optionId: string
|
|
397
|
-
registerItem: (index: number, element: HTMLElement | null) => void
|
|
398
|
-
onSelect: () => void
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
function SuggestionRow({ text, index, active, keyHint, optionId, registerItem, onSelect }: SuggestionRowProps) {
|
|
402
|
-
const EnterIcon = useIcon('corner-down-left')
|
|
403
|
-
const ArrowDownIcon = useIcon('arrow-down')
|
|
404
|
-
const compactStep = useSize().variant === 'compact'
|
|
405
|
-
const ref = useRef<HTMLDivElement>(null)
|
|
406
|
-
|
|
407
|
-
useRegisterFluidHoverItem(registerItem, index, ref)
|
|
408
|
-
|
|
409
|
-
return (
|
|
410
|
-
<div
|
|
411
|
-
ref={ref}
|
|
412
|
-
id={optionId}
|
|
413
|
-
role="option"
|
|
414
|
-
aria-selected={active}
|
|
415
|
-
onClick={onSelect}
|
|
416
|
-
className={cn(
|
|
417
|
-
'relative flex cursor-pointer items-center gap-2',
|
|
418
|
-
// Text size mirrors the composer's textarea/placeholder (the rows
|
|
419
|
-
// read as prompt candidates, not metadata); heights follow the
|
|
420
|
-
// QueuedRow step ladder.
|
|
421
|
-
compactStep ? 'h-7 px-2 text-subtitle-compact' : 'h-8 px-2.5 text-subtitle',
|
|
422
|
-
'text-muted-foreground transition-colors duration-fast',
|
|
423
|
-
active && 'text-foreground',
|
|
424
|
-
'weight-normal',
|
|
425
|
-
)}
|
|
426
|
-
>
|
|
427
|
-
<span className="min-w-0 flex-1 truncate [text-box:trim-both_cap_alphabetic] py-1 -my-1">{text}</span>
|
|
428
|
-
{/* One icon slot: ↵ on the highlighted row; on the first row a muted ↓
|
|
429
|
-
takes the same slot while nothing is highlighted, signposting the
|
|
430
|
-
keyboard path into the list. */}
|
|
431
|
-
{!active && keyHint ? (
|
|
432
|
-
<ArrowDownIcon size={13} className="shrink-0 text-muted-foreground/70 transition-opacity duration-fast" />
|
|
433
|
-
) : (
|
|
434
|
-
<EnterIcon
|
|
435
|
-
size={13}
|
|
436
|
-
className={cn('shrink-0 transition-opacity duration-fast', active ? 'opacity-100' : 'opacity-0')}
|
|
437
|
-
/>
|
|
438
|
-
)}
|
|
439
|
-
</div>
|
|
440
|
-
)
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
// ─── InputMessage ─────────────────────────────────────────────────────────
|
|
126
|
+
const isPlain = (e: ReactKeyboardEvent) => !e.shiftKey && !e.altKey && !e.metaKey && !e.ctrlKey
|
|
444
127
|
|
|
445
128
|
/**
|
|
446
129
|
* Chat-style message composer with an auto-resizing textarea, flexible
|
|
@@ -464,7 +147,12 @@ function SuggestionRow({ text, index, active, keyHint, optionId, registerItem, o
|
|
|
464
147
|
* `defaultFiles`, `defaultQueue`, `defaultStatus` — so a composer can hold
|
|
465
148
|
* its own draft, attachments and queue with no state in the caller.
|
|
466
149
|
*
|
|
150
|
+
* Also exported from this item: `FileThumbnail`, the square preview the
|
|
151
|
+
* attachment tiles use, for showing sent attachments in a transcript.
|
|
152
|
+
*
|
|
467
153
|
* @example {@include ./examples.mdx}
|
|
154
|
+
* @source https://github.com/mickadesign/fluid-functionalism/blob/b3587bdbd83fc66c2a6aae3817ffb856cb09260b/registry/default/input-message.tsx Fluid Functionalism
|
|
155
|
+
* @license MIT © 2026 Micka Touillaud
|
|
468
156
|
*/
|
|
469
157
|
const InputMessage = forwardRef<HTMLDivElement, InputMessageProps>(
|
|
470
158
|
(
|
|
@@ -482,26 +170,25 @@ const InputMessage = forwardRef<HTMLDivElement, InputMessageProps>(
|
|
|
482
170
|
maxRows = 8,
|
|
483
171
|
clickToFocus = true,
|
|
484
172
|
sendLabel = 'Send',
|
|
485
|
-
files
|
|
173
|
+
files,
|
|
486
174
|
defaultFiles,
|
|
487
175
|
onFilesChange,
|
|
488
176
|
accept = DEFAULT_ACCEPT,
|
|
489
177
|
maxFiles,
|
|
490
178
|
filePreviewSize = 80,
|
|
491
179
|
textareaProps,
|
|
492
|
-
status
|
|
180
|
+
status,
|
|
493
181
|
defaultStatus,
|
|
494
182
|
onStatusChange,
|
|
495
183
|
onStop,
|
|
496
|
-
queue
|
|
184
|
+
queue,
|
|
497
185
|
defaultQueue,
|
|
498
186
|
onQueueChange,
|
|
499
187
|
showQueue = true,
|
|
500
|
-
history =
|
|
188
|
+
history = NO_STRINGS,
|
|
501
189
|
placeholderSuggestion,
|
|
502
190
|
suggestions,
|
|
503
191
|
className,
|
|
504
|
-
style,
|
|
505
192
|
...props
|
|
506
193
|
},
|
|
507
194
|
ref,
|
|
@@ -509,78 +196,37 @@ const InputMessage = forwardRef<HTMLDivElement, InputMessageProps>(
|
|
|
509
196
|
const shape = useShape()
|
|
510
197
|
const compactStep = useSize(size).variant === 'compact'
|
|
511
198
|
const ArrowUpIcon = useIcon('arrow-up')
|
|
512
|
-
const reduceMotion =
|
|
513
|
-
const isTouch =
|
|
514
|
-
|
|
199
|
+
const reduceMotion = useReduceMotion()
|
|
200
|
+
const isTouch = useTouchPrimary()
|
|
515
201
|
const textareaRef = useRef<HTMLTextAreaElement>(null)
|
|
516
|
-
const fileInputRef = useRef<HTMLInputElement>(null)
|
|
517
|
-
const [focusVisible, setFocusVisible] = useState(false)
|
|
518
|
-
const [dragOver, setDragOver] = useState(false)
|
|
519
|
-
const [hovered, setHovered] = useState(false)
|
|
520
|
-
|
|
521
|
-
// Split out onFocus/onBlur so the rest-spread onto the textarea can't
|
|
522
|
-
// clobber the composed handlers below.
|
|
523
202
|
const {
|
|
524
|
-
|
|
525
|
-
onBlur: _textareaOnBlur,
|
|
203
|
+
onBlur: textareaOnBlur,
|
|
526
204
|
'aria-describedby': textareaDescribedBy,
|
|
527
205
|
...restTextareaProps
|
|
528
206
|
} = textareaProps ?? {}
|
|
529
207
|
|
|
530
|
-
// ── Controlled / uncontrolled state ───────────────────────────────
|
|
531
|
-
// Each pair keeps upstream's controlled contract (the prop wins, the
|
|
532
|
-
// callback still fires) and gains an internal fallback, so the composer
|
|
533
|
-
// runs with no state in the caller.
|
|
534
208
|
const valueControlled = valueProp !== undefined
|
|
535
209
|
const [value, setValue] = useControllableState<string>(valueProp, defaultValue ?? '', onValueChange)
|
|
536
|
-
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
// Queue is active only when a status exists (controlled or seeded) and a
|
|
542
|
-
// queue is wired — same opt-in shape as `supportsFiles`.
|
|
543
|
-
const statusEnabled = statusProp !== undefined || defaultStatus !== undefined
|
|
544
|
-
const [statusValue, setStatus] = useControllableState<InputMessageStatus>(
|
|
545
|
-
statusProp,
|
|
546
|
-
defaultStatus ?? 'idle',
|
|
210
|
+
const attachments = useComposerFiles({ files, defaultFiles, onFilesChange, accept, maxFiles, disabled })
|
|
211
|
+
const messages = useMessageQueue({
|
|
212
|
+
status,
|
|
213
|
+
defaultStatus,
|
|
547
214
|
onStatusChange,
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
const [queueArr, setQueue] = useControllableState<QueuedMessage[]>(
|
|
553
|
-
queueProp,
|
|
554
|
-
defaultQueue ?? NO_QUEUE,
|
|
215
|
+
onStop,
|
|
216
|
+
queue,
|
|
217
|
+
defaultQueue,
|
|
555
218
|
onQueueChange,
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
// before the controlled `queue` prop round-trips back).
|
|
560
|
-
const queueRef = useRef(queueArr)
|
|
561
|
-
queueRef.current = queueArr
|
|
562
|
-
const supportsQueue = statusEnabled && (onQueueChange !== undefined || defaultQueue !== undefined)
|
|
563
|
-
const [liveMsg, setLiveMsg] = useState('')
|
|
219
|
+
onSend,
|
|
220
|
+
})
|
|
221
|
+
const recall = useHistoryNav(history, value, setValue, textareaRef)
|
|
564
222
|
|
|
565
|
-
|
|
566
|
-
// when not browsing; `draftBeforeHistory` stashes the in-progress text so
|
|
567
|
-
// ArrowDown past the newest entry restores it.
|
|
568
|
-
const [historyIndex, setHistoryIndex] = useState<number | null>(null)
|
|
569
|
-
const draftBeforeHistory = useRef('')
|
|
223
|
+
useAutosizeTextarea(textareaRef, { minRows, maxRows }, [value, compactStep])
|
|
570
224
|
|
|
571
|
-
//
|
|
572
|
-
//
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
// keyboard drive the same sliding bg-hover overlay (Dropdown's pattern):
|
|
576
|
-
// mouse movement resolves the nearest row, ↓/↑ set the index directly.
|
|
577
|
-
const suggestionsArr = useMemo(() => suggestions ?? [], [suggestions])
|
|
578
|
-
const suggestionsOpen = suggestionsArr.length > 0 && value === ''
|
|
225
|
+
// The list shows while the draft is empty; focus stays in the textarea
|
|
226
|
+
// (aria-activedescendant), and pointer and keyboard drive one fluid-hover highlight.
|
|
227
|
+
const suggestionList = suggestions ?? NO_STRINGS
|
|
228
|
+
const suggestionsOpen = suggestionList.length > 0 && value === ''
|
|
579
229
|
const suggestionListRef = useRef<HTMLDivElement | null>(null)
|
|
580
|
-
// Pixel heights for the three collapsible regions (see useRegionHeight).
|
|
581
|
-
const [filesRegionRef, filesRegionHeight] = useRegionHeight()
|
|
582
|
-
const [queueRegionRef, queueRegionHeight] = useRegionHeight()
|
|
583
|
-
const [suggestionsRegionRef, suggestionsRegionHeight] = useRegionHeight()
|
|
584
230
|
const suggestionHover = useFluidHover(suggestionListRef)
|
|
585
231
|
const {
|
|
586
232
|
activeIndex: activeSuggestion,
|
|
@@ -589,791 +235,385 @@ const InputMessage = forwardRef<HTMLDivElement, InputMessageProps>(
|
|
|
589
235
|
registerItem: registerSuggestion,
|
|
590
236
|
remeasure,
|
|
591
237
|
} = suggestionHover
|
|
592
|
-
|
|
593
|
-
// Rows stay registered while the list is closed, so their rects are from
|
|
594
|
-
// a hidden layout: re-measure on open. The highlight waits for it.
|
|
595
|
-
useEffect(() => {
|
|
596
|
-
if (suggestionsOpen) remeasure()
|
|
597
|
-
}, [suggestionsOpen, remeasure])
|
|
598
238
|
const suggestionListId = useId()
|
|
599
239
|
const ghostHintId = useId()
|
|
600
|
-
const showGhost = !!placeholderSuggestion && value === '' && !
|
|
240
|
+
const showGhost = !!placeholderSuggestion && value === '' && !attachments.dragging
|
|
601
241
|
|
|
242
|
+
const [filesRegionRef, filesRegionHeight] = useRegionHeight()
|
|
243
|
+
const [queueRegionRef, queueRegionHeight] = useRegionHeight()
|
|
244
|
+
const [suggestionsRegionRef, suggestionsRegionHeight] = useRegionHeight()
|
|
245
|
+
|
|
246
|
+
// Closed rows keep their registration with stale rects: remeasure on open.
|
|
602
247
|
useEffect(() => {
|
|
603
|
-
if (
|
|
604
|
-
|
|
248
|
+
if (suggestionsOpen) remeasure()
|
|
249
|
+
else setActiveSuggestion(null)
|
|
250
|
+
}, [suggestionsOpen, remeasure, setActiveSuggestion])
|
|
605
251
|
|
|
606
|
-
// Fill a suggested prompt into the composer (Tab / Enter / click). Fills
|
|
607
|
-
// only — the user still reviews and sends.
|
|
608
252
|
const acceptSuggestion = useCallback(
|
|
609
253
|
(text: string) => {
|
|
610
254
|
setActiveSuggestion(null)
|
|
611
|
-
|
|
255
|
+
recall.exit()
|
|
612
256
|
setValue(text)
|
|
613
|
-
|
|
614
|
-
const el = textareaRef.current
|
|
615
|
-
if (!el) return
|
|
616
|
-
el.focus()
|
|
617
|
-
el.setSelectionRange(el.value.length, el.value.length)
|
|
618
|
-
})
|
|
257
|
+
caretToEnd(textareaRef)
|
|
619
258
|
},
|
|
620
|
-
[setValue, setActiveSuggestion],
|
|
259
|
+
[setValue, setActiveSuggestion, recall.exit],
|
|
621
260
|
)
|
|
622
261
|
|
|
623
|
-
// Parsed line-height, cached per textarea element — getComputedStyle on
|
|
624
|
-
// every keystroke is needless work when the value only changes with font
|
|
625
|
-
// or zoom changes.
|
|
626
|
-
const lineHeightCache = useRef<{ el: HTMLTextAreaElement; value: number } | null>(null)
|
|
627
|
-
|
|
628
|
-
const resizeTextarea = useCallback(() => {
|
|
629
|
-
const el = textareaRef.current
|
|
630
|
-
if (!el) return
|
|
631
|
-
el.style.height = 'auto'
|
|
632
|
-
let cache = lineHeightCache.current
|
|
633
|
-
if (!cache || cache.el !== el) {
|
|
634
|
-
const lineHeight = parseFloat(getComputedStyle(el).lineHeight)
|
|
635
|
-
cache = { el, value: Number.isNaN(lineHeight) ? 20 : lineHeight }
|
|
636
|
-
lineHeightCache.current = cache
|
|
637
|
-
}
|
|
638
|
-
const min = cache.value * minRows
|
|
639
|
-
const max = cache.value * maxRows
|
|
640
|
-
const next = Math.min(Math.max(el.scrollHeight, min), max)
|
|
641
|
-
el.style.height = `${next}px`
|
|
642
|
-
el.style.overflowY = el.scrollHeight > max ? 'auto' : 'hidden'
|
|
643
|
-
}, [minRows, maxRows])
|
|
644
|
-
|
|
645
|
-
useIsoLayoutEffect(() => {
|
|
646
|
-
resizeTextarea()
|
|
647
|
-
}, [value, resizeTextarea])
|
|
648
|
-
|
|
649
|
-
// Re-measure when the textarea's width changes. The mount-time pass can
|
|
650
|
-
// run while an ancestor is still laid out at (near-)zero width — the
|
|
651
|
-
// wrapped placeholder then reads as many lines and pins the height at
|
|
652
|
-
// maxRows until the next value change. Width-gated so the observer
|
|
653
|
-
// doesn't loop on its own height writes.
|
|
654
|
-
useEffect(() => {
|
|
655
|
-
const el = textareaRef.current
|
|
656
|
-
if (!el || typeof ResizeObserver === 'undefined') return
|
|
657
|
-
let lastWidth = el.offsetWidth
|
|
658
|
-
const ro = new ResizeObserver(() => {
|
|
659
|
-
const width = el.offsetWidth
|
|
660
|
-
if (width === lastWidth) return
|
|
661
|
-
lastWidth = width
|
|
662
|
-
resizeTextarea()
|
|
663
|
-
})
|
|
664
|
-
ro.observe(el)
|
|
665
|
-
return () => ro.disconnect()
|
|
666
|
-
}, [resizeTextarea])
|
|
667
|
-
|
|
668
262
|
const trimmed = value.trim()
|
|
669
|
-
const canSend = !disabled && (trimmed.length > 0 ||
|
|
670
|
-
|
|
671
|
-
// Edge = the box-shadow's 1px ring, recoloured in place per state so the
|
|
672
|
-
// stroke gains contrast without ever appearing to thicken (no second
|
|
673
|
-
// border band layered beside it). The drop (`0 1px 1px`) is kept so the
|
|
674
|
-
// composer holds its lift across states. Applied inline (not via a
|
|
675
|
-
// `shadow-*` utility, which mangles multi-layer arbitrary values) with the
|
|
676
|
-
// precedence drag > focus > hover; when none are active, the className's
|
|
677
|
-
// `shadow-surface-2` supplies the resting edge.
|
|
678
|
-
const EDGE_DROP = '0 1px 1px -0.5px var(--shadow-color)'
|
|
679
|
-
const edgeShadow = dragOver
|
|
680
|
-
? `0 0 0 1px var(--brand), ${EDGE_DROP}`
|
|
681
|
-
: focusVisible
|
|
682
|
-
? `0 0 0 1px color-mix(in oklab, var(--foreground) 20%, transparent), ${EDGE_DROP}`
|
|
683
|
-
: hovered && clickToFocus && !disabled
|
|
684
|
-
? `0 0 0 1px var(--border), ${EDGE_DROP}`
|
|
685
|
-
: undefined
|
|
263
|
+
const canSend = !disabled && (trimmed.length > 0 || attachments.files.length > 0)
|
|
686
264
|
|
|
687
|
-
const handleSend =
|
|
265
|
+
const handleSend = () => {
|
|
688
266
|
if (!canSend) return
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
// then clear the composer and keep focus.
|
|
693
|
-
if (streaming && supportsQueue) {
|
|
694
|
-
const item: QueuedMessage = {
|
|
695
|
-
id: crypto.randomUUID(),
|
|
696
|
-
text: trimmed,
|
|
697
|
-
files: filesArr,
|
|
698
|
-
}
|
|
699
|
-
setQueue([...queueRef.current, item])
|
|
267
|
+
recall.exit()
|
|
268
|
+
if (messages.streaming && messages.supported) {
|
|
269
|
+
messages.enqueue(trimmed, attachments.files)
|
|
700
270
|
setValue('')
|
|
701
|
-
|
|
702
|
-
|
|
271
|
+
attachments.replace([])
|
|
272
|
+
caretToEnd(textareaRef)
|
|
703
273
|
return
|
|
704
274
|
}
|
|
705
|
-
onSend?.(trimmed,
|
|
706
|
-
// Local addition: an uncontrolled draft / file list clears itself, the
|
|
707
|
-
// way a controlled consumer clears its own state inside `onSend`.
|
|
275
|
+
onSend?.(trimmed, attachments.files)
|
|
708
276
|
if (!valueControlled) setValue('')
|
|
709
|
-
if (
|
|
710
|
-
}
|
|
711
|
-
canSend,
|
|
712
|
-
streaming,
|
|
713
|
-
supportsQueue,
|
|
714
|
-
onSend,
|
|
715
|
-
trimmed,
|
|
716
|
-
filesArr,
|
|
717
|
-
setQueue,
|
|
718
|
-
setValue,
|
|
719
|
-
supportsFiles,
|
|
720
|
-
setFiles,
|
|
721
|
-
valueControlled,
|
|
722
|
-
filesControlled,
|
|
723
|
-
])
|
|
724
|
-
|
|
725
|
-
// Stop halts the response. With the status uncontrolled the component owns
|
|
726
|
-
// that flag, so it flips itself to "idle" — the edge the auto-dispatch
|
|
727
|
-
// below watches for.
|
|
728
|
-
const statusControlled = statusProp !== undefined
|
|
729
|
-
const handleStop = useCallback(() => {
|
|
730
|
-
onStop?.()
|
|
731
|
-
if (!statusControlled) setStatus('idle')
|
|
732
|
-
}, [onStop, statusControlled, setStatus])
|
|
733
|
-
|
|
734
|
-
// Auto-dispatch: on the streaming → idle edge (whether the response
|
|
735
|
-
// finished on its own or the user pressed Stop), fire the head of the
|
|
736
|
-
// queue and drop it. The consumer is expected to set status back to
|
|
737
|
-
// "streaming" inside onSend, which re-arms this for the next item.
|
|
738
|
-
const prevStatusRef = useRef(status)
|
|
739
|
-
useEffect(() => {
|
|
740
|
-
const prev = prevStatusRef.current
|
|
741
|
-
prevStatusRef.current = status
|
|
742
|
-
if (!supportsQueue) return
|
|
743
|
-
if (prev === 'streaming' && status === 'idle' && queueArr.length > 0) {
|
|
744
|
-
const [next, ...rest] = queueArr
|
|
745
|
-
if (!next) return
|
|
746
|
-
setQueue(rest)
|
|
747
|
-
onSend?.(next.text, next.files, { queuedId: next.id })
|
|
748
|
-
setLiveMsg(`Message sent.${rest.length ? ` ${rest.length} still queued.` : ''}`)
|
|
749
|
-
}
|
|
750
|
-
}, [status, supportsQueue, queueArr, setQueue, onSend])
|
|
751
|
-
|
|
752
|
-
// ── Queue item actions ────────────────────────────────────────────
|
|
753
|
-
const editQueued = useCallback(
|
|
754
|
-
(item: QueuedMessage) => {
|
|
755
|
-
if (!supportsQueue) return
|
|
756
|
-
// Silent replace: pull the item out of the queue into the composer,
|
|
757
|
-
// overwriting any current draft. Re-sending re-queues it to the end.
|
|
758
|
-
setHistoryIndex(null)
|
|
759
|
-
setValue(item.text)
|
|
760
|
-
if (supportsFiles) {
|
|
761
|
-
setFiles(maxFiles != null ? item.files.slice(0, maxFiles) : item.files)
|
|
762
|
-
}
|
|
763
|
-
setQueue(queueRef.current.filter(q => q.id !== item.id))
|
|
764
|
-
requestAnimationFrame(() => {
|
|
765
|
-
const el = textareaRef.current
|
|
766
|
-
if (!el) return
|
|
767
|
-
el.focus()
|
|
768
|
-
el.setSelectionRange(el.value.length, el.value.length)
|
|
769
|
-
})
|
|
770
|
-
},
|
|
771
|
-
[supportsQueue, supportsFiles, setValue, setFiles, maxFiles, setQueue],
|
|
772
|
-
)
|
|
773
|
-
|
|
774
|
-
const removeQueued = useCallback(
|
|
775
|
-
(item: QueuedMessage) => setQueue(queueRef.current.filter(q => q.id !== item.id)),
|
|
776
|
-
[setQueue],
|
|
777
|
-
)
|
|
277
|
+
if (!attachments.controlled) attachments.replace([])
|
|
278
|
+
}
|
|
778
279
|
|
|
779
|
-
const
|
|
780
|
-
(
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
const a = next[i]
|
|
787
|
-
const b = next[j]
|
|
788
|
-
if (!a || !b) return
|
|
789
|
-
next[i] = b
|
|
790
|
-
next[j] = a
|
|
791
|
-
setQueue(next)
|
|
792
|
-
},
|
|
793
|
-
[setQueue],
|
|
794
|
-
)
|
|
280
|
+
const editQueued = (item: QueuedMessage) => {
|
|
281
|
+
recall.exit()
|
|
282
|
+
setValue(item.text)
|
|
283
|
+
attachments.replace(item.files)
|
|
284
|
+
messages.remove(item)
|
|
285
|
+
caretToEnd(textareaRef)
|
|
286
|
+
}
|
|
795
287
|
|
|
796
|
-
|
|
797
|
-
// draft) → Send (idle). Send and Queue share the arrow-up glyph; only the
|
|
798
|
-
// Stop⇄arrow swap animates. An uncontrolled status can always stop.
|
|
799
|
-
const canStop = onStop !== undefined || !statusControlled
|
|
800
|
-
const buttonMode: 'send' | 'queue' | 'stop' = !streaming
|
|
288
|
+
const buttonMode: 'send' | 'queue' | 'stop' = !messages.streaming
|
|
801
289
|
? 'send'
|
|
802
|
-
: canSend &&
|
|
290
|
+
: canSend && messages.supported
|
|
803
291
|
? 'queue'
|
|
804
|
-
: canStop
|
|
292
|
+
: messages.canStop
|
|
805
293
|
? 'stop'
|
|
806
294
|
: 'send'
|
|
807
295
|
const buttonLabel = buttonMode === 'stop' ? 'Stop' : buttonMode === 'queue' ? 'Queue message' : sendLabel
|
|
808
296
|
|
|
809
|
-
const
|
|
810
|
-
|
|
811
|
-
const el = textareaRef.current
|
|
812
|
-
if (el) el.setSelectionRange(el.value.length, el.value.length)
|
|
813
|
-
})
|
|
814
|
-
}, [])
|
|
815
|
-
|
|
816
|
-
const handleKeyDown = useCallback(
|
|
817
|
-
(e: ReactKeyboardEvent<HTMLTextAreaElement>) => {
|
|
818
|
-
if (e.nativeEvent.isComposing) return
|
|
819
|
-
|
|
820
|
-
// Suggested prompts: plain ArrowDown moves the highlight into / down
|
|
821
|
-
// the list, ArrowUp walks it back up (then out, returning to plain
|
|
822
|
-
// textarea behavior), Enter fills the highlighted prompt, Escape
|
|
823
|
-
// drops the highlight. With no highlight, ArrowUp still falls through
|
|
824
|
-
// to history recall below.
|
|
825
|
-
if (suggestionsOpen && !e.shiftKey && !e.altKey && !e.metaKey && !e.ctrlKey) {
|
|
826
|
-
if (e.key === 'ArrowDown') {
|
|
827
|
-
e.preventDefault()
|
|
828
|
-
setActiveSuggestion(prev => (prev == null ? 0 : Math.min(prev + 1, suggestionsArr.length - 1)))
|
|
829
|
-
return
|
|
830
|
-
}
|
|
831
|
-
if (activeSuggestion != null) {
|
|
832
|
-
if (e.key === 'ArrowUp') {
|
|
833
|
-
e.preventDefault()
|
|
834
|
-
setActiveSuggestion(activeSuggestion === 0 ? null : activeSuggestion - 1)
|
|
835
|
-
return
|
|
836
|
-
}
|
|
837
|
-
if (e.key === 'Enter') {
|
|
838
|
-
e.preventDefault()
|
|
839
|
-
const picked = suggestionsArr[activeSuggestion]
|
|
840
|
-
if (picked !== undefined) acceptSuggestion(picked)
|
|
841
|
-
return
|
|
842
|
-
}
|
|
843
|
-
if (e.key === 'Escape') {
|
|
844
|
-
e.preventDefault()
|
|
845
|
-
setActiveSuggestion(null)
|
|
846
|
-
return
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
}
|
|
297
|
+
const handleKeyDown = (e: ReactKeyboardEvent<HTMLTextAreaElement>) => {
|
|
298
|
+
if (e.nativeEvent.isComposing) return
|
|
850
299
|
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
// non-empty Tab resumes normal focus traversal).
|
|
854
|
-
if (e.key === 'Tab' && !e.shiftKey && placeholderSuggestion && value === '') {
|
|
300
|
+
if (suggestionsOpen && isPlain(e)) {
|
|
301
|
+
if (e.key === 'ArrowDown') {
|
|
855
302
|
e.preventDefault()
|
|
856
|
-
|
|
303
|
+
setActiveSuggestion(prev => (prev == null ? 0 : Math.min(prev + 1, suggestionList.length - 1)))
|
|
857
304
|
return
|
|
858
305
|
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
if (
|
|
864
|
-
history.length > 0 &&
|
|
865
|
-
(e.key === 'ArrowUp' || e.key === 'ArrowDown') &&
|
|
866
|
-
!e.shiftKey &&
|
|
867
|
-
!e.altKey &&
|
|
868
|
-
!e.metaKey &&
|
|
869
|
-
!e.ctrlKey
|
|
870
|
-
) {
|
|
871
|
-
const el = e.currentTarget
|
|
872
|
-
const caret = el.selectionStart ?? 0
|
|
873
|
-
const end = el.selectionEnd ?? caret
|
|
874
|
-
if (e.key === 'ArrowUp' && !value.slice(0, caret).includes('\n')) {
|
|
875
|
-
const start = historyIndex == null ? history.length : historyIndex
|
|
876
|
-
if (start > 0) {
|
|
877
|
-
e.preventDefault()
|
|
878
|
-
if (historyIndex == null) draftBeforeHistory.current = value
|
|
879
|
-
const ni = start - 1
|
|
880
|
-
setHistoryIndex(ni)
|
|
881
|
-
setValue(history[ni] ?? '')
|
|
882
|
-
setCaretEnd()
|
|
883
|
-
}
|
|
306
|
+
if (activeSuggestion != null) {
|
|
307
|
+
if (e.key === 'ArrowUp') {
|
|
308
|
+
e.preventDefault()
|
|
309
|
+
setActiveSuggestion(activeSuggestion === 0 ? null : activeSuggestion - 1)
|
|
884
310
|
return
|
|
885
311
|
}
|
|
886
|
-
if (e.key === '
|
|
312
|
+
if (e.key === 'Enter') {
|
|
887
313
|
e.preventDefault()
|
|
888
|
-
const
|
|
889
|
-
if (
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
}
|
|
896
|
-
setCaretEnd()
|
|
314
|
+
const picked = suggestionList[activeSuggestion]
|
|
315
|
+
if (picked !== undefined) acceptSuggestion(picked)
|
|
316
|
+
return
|
|
317
|
+
}
|
|
318
|
+
if (e.key === 'Escape') {
|
|
319
|
+
e.preventDefault()
|
|
320
|
+
setActiveSuggestion(null)
|
|
897
321
|
return
|
|
898
322
|
}
|
|
899
323
|
}
|
|
324
|
+
}
|
|
900
325
|
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
handleSend()
|
|
904
|
-
}
|
|
905
|
-
},
|
|
906
|
-
[
|
|
907
|
-
history,
|
|
908
|
-
value,
|
|
909
|
-
historyIndex,
|
|
910
|
-
setValue,
|
|
911
|
-
setCaretEnd,
|
|
912
|
-
handleSend,
|
|
913
|
-
suggestionsOpen,
|
|
914
|
-
suggestionsArr,
|
|
915
|
-
activeSuggestion,
|
|
916
|
-
setActiveSuggestion,
|
|
917
|
-
acceptSuggestion,
|
|
918
|
-
placeholderSuggestion,
|
|
919
|
-
],
|
|
920
|
-
)
|
|
921
|
-
|
|
922
|
-
const handleContainerMouseDown = useCallback(
|
|
923
|
-
(e: ReactMouseEvent<HTMLDivElement>) => {
|
|
924
|
-
if (!clickToFocus || disabled) return
|
|
925
|
-
const target = e.target as HTMLElement
|
|
926
|
-
if (target === textareaRef.current) return
|
|
927
|
-
// A press in a popup portalled out of the box reaches it through the React tree only.
|
|
928
|
-
if (!e.currentTarget.contains(target)) return
|
|
929
|
-
if (target.closest('button, a, input, select, textarea, [contenteditable], [role="button"], [data-im-queue]')) {
|
|
930
|
-
return
|
|
931
|
-
}
|
|
326
|
+
// Shift+Tab, and Tab once there is a draft, still move focus.
|
|
327
|
+
if (e.key === 'Tab' && !e.shiftKey && placeholderSuggestion && value === '') {
|
|
932
328
|
e.preventDefault()
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
)
|
|
937
|
-
|
|
938
|
-
// ── File helpers ──────────────────────────────────────────────────
|
|
939
|
-
const acceptTokens = useMemo(
|
|
940
|
-
() =>
|
|
941
|
-
accept
|
|
942
|
-
.split(',')
|
|
943
|
-
.map(s => s.trim())
|
|
944
|
-
.filter(Boolean),
|
|
945
|
-
[accept],
|
|
946
|
-
)
|
|
947
|
-
|
|
948
|
-
const matchesAccept = useCallback(
|
|
949
|
-
(file: File) =>
|
|
950
|
-
acceptTokens.some(token => {
|
|
951
|
-
if (token.endsWith('/*')) return file.type.startsWith(token.slice(0, -1))
|
|
952
|
-
if (token.startsWith('.')) return file.name.toLowerCase().endsWith(token.toLowerCase())
|
|
953
|
-
return file.type === token
|
|
954
|
-
}),
|
|
955
|
-
[acceptTokens],
|
|
956
|
-
)
|
|
329
|
+
acceptSuggestion(placeholderSuggestion)
|
|
330
|
+
return
|
|
331
|
+
}
|
|
957
332
|
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
// to catch "user dropped the same file twice" without false positives
|
|
963
|
-
// on legitimately distinct files (different bytes ⇒ different size).
|
|
964
|
-
const fingerprint = (f: File) => `${f.name}-${f.size}-${f.lastModified}`
|
|
965
|
-
const existing = new Set(filesArr.map(fingerprint))
|
|
966
|
-
const accepted: File[] = []
|
|
967
|
-
for (const f of incoming) {
|
|
968
|
-
if (!matchesAccept(f)) continue
|
|
969
|
-
const fp = fingerprint(f)
|
|
970
|
-
if (existing.has(fp)) continue
|
|
971
|
-
existing.add(fp)
|
|
972
|
-
accepted.push(f)
|
|
973
|
-
}
|
|
974
|
-
if (!accepted.length) return
|
|
975
|
-
const next = [...filesArr, ...accepted]
|
|
976
|
-
setFiles(maxFiles != null ? next.slice(0, maxFiles) : next)
|
|
977
|
-
},
|
|
978
|
-
[supportsFiles, setFiles, filesArr, matchesAccept, maxFiles],
|
|
979
|
-
)
|
|
333
|
+
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
334
|
+
recall.onKeyDown(e)
|
|
335
|
+
return
|
|
336
|
+
}
|
|
980
337
|
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
[supportsFiles, setFiles, filesArr],
|
|
987
|
-
)
|
|
338
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
339
|
+
e.preventDefault()
|
|
340
|
+
handleSend()
|
|
341
|
+
}
|
|
342
|
+
}
|
|
988
343
|
|
|
989
|
-
const
|
|
990
|
-
(
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
el.click()
|
|
999
|
-
// Restore on next tick — the picker dialog reads `accept` synchronously.
|
|
1000
|
-
queueMicrotask(() => {
|
|
1001
|
-
if (fileInputRef.current) fileInputRef.current.accept = accept
|
|
1002
|
-
})
|
|
1003
|
-
return
|
|
1004
|
-
}
|
|
1005
|
-
el.click()
|
|
1006
|
-
},
|
|
1007
|
-
[accept],
|
|
1008
|
-
)
|
|
344
|
+
const handleContainerMouseDown = (e: ReactMouseEvent<HTMLDivElement>) => {
|
|
345
|
+
if (!clickToFocus || disabled) return
|
|
346
|
+
const target = e.target as HTMLElement
|
|
347
|
+
if (target === textareaRef.current) return
|
|
348
|
+
if (target.closest('button, a, input, select, textarea, [contenteditable], [role="button"], [data-im-queue]'))
|
|
349
|
+
return
|
|
350
|
+
e.preventDefault()
|
|
351
|
+
textareaRef.current?.focus()
|
|
352
|
+
}
|
|
1009
353
|
|
|
1010
|
-
// ── Slot rendering ────────────────────────────────────────────────
|
|
1011
354
|
const slotCtx = useMemo<InputMessageSlotContext>(
|
|
1012
|
-
() => ({ openFilePicker, files:
|
|
1013
|
-
[
|
|
355
|
+
() => ({ openFilePicker: attachments.openPicker, files: attachments.files }),
|
|
356
|
+
[attachments.openPicker, attachments.files],
|
|
1014
357
|
)
|
|
1015
358
|
const leftContent = typeof leftSlot === 'function' ? leftSlot(slotCtx) : leftSlot
|
|
1016
359
|
const rightContent = typeof rightSlot === 'function' ? rightSlot(slotCtx) : rightSlot
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
const handleDrop = useCallback(
|
|
1039
|
-
(e: ReactDragEvent<HTMLDivElement>) => {
|
|
1040
|
-
e.preventDefault()
|
|
1041
|
-
setDragOver(false)
|
|
1042
|
-
if (!supportsFiles || disabled) return
|
|
1043
|
-
addFiles(Array.from(e.dataTransfer.files))
|
|
1044
|
-
},
|
|
1045
|
-
[supportsFiles, disabled, addFiles],
|
|
1046
|
-
)
|
|
1047
|
-
|
|
1048
|
-
const handleFileInputChange = useCallback(
|
|
1049
|
-
(e: ChangeEvent<HTMLInputElement>) => {
|
|
1050
|
-
if (!e.target.files) return
|
|
1051
|
-
addFiles(Array.from(e.target.files))
|
|
1052
|
-
e.target.value = '' // Allow re-selecting the same file.
|
|
1053
|
-
},
|
|
1054
|
-
[addFiles],
|
|
1055
|
-
)
|
|
1056
|
-
|
|
1057
|
-
const composer = (
|
|
1058
|
-
<div
|
|
1059
|
-
ref={ref}
|
|
1060
|
-
onMouseDown={handleContainerMouseDown}
|
|
1061
|
-
onDragOver={handleDragOver}
|
|
1062
|
-
onDragLeave={handleDragLeave}
|
|
1063
|
-
onDrop={handleDrop}
|
|
1064
|
-
className={cn(
|
|
1065
|
-
// The edge is the box-shadow's hairline ring (from surface-2), not a
|
|
1066
|
-
// border. State changes recolor that same 1px ring in place rather
|
|
1067
|
-
// than layering a second colored border beside it — so hover / focus
|
|
1068
|
-
// bump *contrast* without ever appearing to thicken the stroke.
|
|
1069
|
-
'flex flex-col gap-1 p-2 transition-[box-shadow,color] duration-fast',
|
|
1070
|
-
surfaceClasses(2, 2),
|
|
1071
|
-
shape.container,
|
|
1072
|
-
clickToFocus && !disabled && 'cursor-text',
|
|
1073
|
-
disabled && 'opacity-50 pointer-events-none',
|
|
1074
|
-
className,
|
|
1075
|
-
)}
|
|
1076
|
-
style={edgeShadow ? { boxShadow: edgeShadow, ...style } : style}
|
|
1077
|
-
onMouseEnter={() => setHovered(true)}
|
|
1078
|
-
onMouseLeave={() => setHovered(false)}
|
|
1079
|
-
{...props}
|
|
1080
|
-
>
|
|
1081
|
-
<SurfaceProvider value={2}>
|
|
1082
|
-
{supportsFiles && (
|
|
1083
|
-
<input
|
|
1084
|
-
ref={fileInputRef}
|
|
1085
|
-
type="file"
|
|
1086
|
-
accept={accept}
|
|
1087
|
-
multiple={maxFiles == null || maxFiles > 1}
|
|
1088
|
-
className="hidden"
|
|
1089
|
-
onChange={handleFileInputChange}
|
|
1090
|
-
aria-hidden="true"
|
|
1091
|
-
tabIndex={-1}
|
|
1092
|
-
/>
|
|
360
|
+
const textStep = compactStep
|
|
361
|
+
? 'text-subtitle-compact leading-4.5 px-1.5 py-1.5'
|
|
362
|
+
: 'text-subtitle leading-5 px-2 py-2'
|
|
363
|
+
|
|
364
|
+
return (
|
|
365
|
+
<SizeScope size={size}>
|
|
366
|
+
{/* biome-ignore lint/a11y/noStaticElementInteractions: the textarea is the control; the panel forwards pointer focus and takes drops. */}
|
|
367
|
+
<div
|
|
368
|
+
ref={ref}
|
|
369
|
+
data-input-message=""
|
|
370
|
+
data-click-to-focus={clickToFocus && !disabled ? '' : undefined}
|
|
371
|
+
data-drag-over={attachments.dragging ? '' : undefined}
|
|
372
|
+
onMouseDown={handleContainerMouseDown}
|
|
373
|
+
{...attachments.dropHandlers}
|
|
374
|
+
className={cn(
|
|
375
|
+
'flex flex-col gap-1 p-2 transition-[box-shadow,color] duration-fast',
|
|
376
|
+
surfaceClasses(2, 2),
|
|
377
|
+
shape.container,
|
|
378
|
+
clickToFocus && !disabled && 'cursor-text',
|
|
379
|
+
disabled && 'opacity-50 pointer-events-none',
|
|
380
|
+
className,
|
|
1093
381
|
)}
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
tile out of layout flow so siblings can slide into the gap
|
|
1100
|
-
without fighting its exit anim. Keys are purely file-identity
|
|
1101
|
-
(no index) so removing the first file doesn't re-key — and
|
|
1102
|
-
remount — every surviving sibling. */}
|
|
1103
|
-
<AnimatePresence initial={false}>
|
|
1104
|
-
{filesArr.length > 0 && (
|
|
1105
|
-
<motion.div
|
|
1106
|
-
key="preview-row"
|
|
1107
|
-
initial={{ height: 0, opacity: 0 }}
|
|
1108
|
-
animate={{ height: filesRegionHeight ?? 0, opacity: 1 }}
|
|
1109
|
-
exit={{ height: 0, opacity: 0 }}
|
|
1110
|
-
transition={{ ...spring.moderate, bounce: 0 }}
|
|
1111
|
-
className="overflow-hidden"
|
|
1112
|
-
>
|
|
1113
|
-
<div ref={filesRegionRef} className="flex flex-wrap gap-2 pb-1">
|
|
1114
|
-
<AnimatePresence initial={false} mode="popLayout">
|
|
1115
|
-
{filesArr.map((file, i) => (
|
|
1116
|
-
<FilePreviewTile
|
|
1117
|
-
key={`${file.name}-${file.size}-${file.lastModified}`}
|
|
1118
|
-
file={file}
|
|
1119
|
-
onRemove={() => removeFile(i)}
|
|
1120
|
-
size={filePreviewSize}
|
|
1121
|
-
/>
|
|
1122
|
-
))}
|
|
1123
|
-
</AnimatePresence>
|
|
1124
|
-
</div>
|
|
1125
|
-
</motion.div>
|
|
382
|
+
{...props}
|
|
383
|
+
>
|
|
384
|
+
<SurfaceProvider value={2}>
|
|
385
|
+
{attachments.supported && (
|
|
386
|
+
<input {...attachments.inputProps} className="hidden" aria-hidden="true" tabIndex={-1} />
|
|
1126
387
|
)}
|
|
1127
|
-
</AnimatePresence>
|
|
1128
388
|
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
the Reorder.Group handles drag-reorder (top = next to dispatch)
|
|
1132
|
-
and AnimatePresence handles per-row enter/exit. */}
|
|
1133
|
-
{supportsQueue && showQueue && (
|
|
389
|
+
{/* popLayout pulls a leaving tile out of flow so its siblings slide in;
|
|
390
|
+
keys are file identity, so removing one never remounts the rest. */}
|
|
1134
391
|
<AnimatePresence initial={false}>
|
|
1135
|
-
{
|
|
392
|
+
{attachments.files.length > 0 && (
|
|
1136
393
|
<motion.div
|
|
1137
|
-
key="
|
|
394
|
+
key="preview-row"
|
|
1138
395
|
initial={{ height: 0, opacity: 0 }}
|
|
1139
|
-
animate={{ height:
|
|
396
|
+
animate={{ height: filesRegionHeight ?? 0, opacity: 1 }}
|
|
1140
397
|
exit={{ height: 0, opacity: 0 }}
|
|
1141
|
-
transition={
|
|
398
|
+
transition={REGION_SPRING}
|
|
1142
399
|
className="overflow-hidden"
|
|
1143
400
|
>
|
|
1144
|
-
<
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
<AnimatePresence initial={false}>
|
|
1153
|
-
{queueArr.map((item, i) => (
|
|
1154
|
-
<QueuedRow
|
|
1155
|
-
key={item.id}
|
|
1156
|
-
item={item}
|
|
1157
|
-
index={i}
|
|
1158
|
-
total={queueArr.length}
|
|
1159
|
-
reduceMotion={reduceMotion}
|
|
1160
|
-
isTouch={isTouch}
|
|
1161
|
-
onEdit={editQueued}
|
|
1162
|
-
onRemove={removeQueued}
|
|
1163
|
-
onMove={moveQueued}
|
|
401
|
+
<div ref={filesRegionRef} className="flex flex-wrap gap-2 pb-1">
|
|
402
|
+
<AnimatePresence initial={false} mode="popLayout">
|
|
403
|
+
{attachments.files.map((file, i) => (
|
|
404
|
+
<FilePreviewTile
|
|
405
|
+
key={`${file.name}-${file.size}-${file.lastModified}`}
|
|
406
|
+
file={file}
|
|
407
|
+
onRemove={() => attachments.remove(i)}
|
|
408
|
+
size={filePreviewSize}
|
|
1164
409
|
/>
|
|
1165
410
|
))}
|
|
1166
411
|
</AnimatePresence>
|
|
1167
|
-
</
|
|
412
|
+
</div>
|
|
1168
413
|
</motion.div>
|
|
1169
414
|
)}
|
|
1170
415
|
</AnimatePresence>
|
|
1171
|
-
)}
|
|
1172
416
|
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
417
|
+
{messages.supported && showQueue && (
|
|
418
|
+
<AnimatePresence initial={false}>
|
|
419
|
+
{messages.queue.length > 0 && (
|
|
420
|
+
<motion.div
|
|
421
|
+
key="queue-row"
|
|
422
|
+
initial={{ height: 0, opacity: 0 }}
|
|
423
|
+
animate={{ height: queueRegionHeight ?? 0, opacity: 1 }}
|
|
424
|
+
exit={{ height: 0, opacity: 0 }}
|
|
425
|
+
transition={REGION_SPRING}
|
|
426
|
+
className="overflow-hidden"
|
|
427
|
+
>
|
|
428
|
+
<Reorder.Group
|
|
429
|
+
ref={queueRegionRef}
|
|
430
|
+
axis="y"
|
|
431
|
+
values={messages.queue}
|
|
432
|
+
onReorder={messages.setQueue}
|
|
433
|
+
data-im-queue
|
|
434
|
+
className="flex flex-col gap-1 pb-1"
|
|
435
|
+
>
|
|
436
|
+
<AnimatePresence initial={false}>
|
|
437
|
+
{messages.queue.map((item, i) => (
|
|
438
|
+
<QueuedRow
|
|
439
|
+
key={item.id}
|
|
440
|
+
item={item}
|
|
441
|
+
index={i}
|
|
442
|
+
total={messages.queue.length}
|
|
443
|
+
reduceMotion={reduceMotion}
|
|
444
|
+
isTouch={isTouch}
|
|
445
|
+
onEdit={editQueued}
|
|
446
|
+
onRemove={messages.remove}
|
|
447
|
+
onMove={messages.move}
|
|
448
|
+
/>
|
|
449
|
+
))}
|
|
450
|
+
</AnimatePresence>
|
|
451
|
+
</Reorder.Group>
|
|
452
|
+
</motion.div>
|
|
453
|
+
)}
|
|
454
|
+
</AnimatePresence>
|
|
455
|
+
)}
|
|
456
|
+
|
|
457
|
+
<div className="relative">
|
|
458
|
+
<textarea
|
|
459
|
+
ref={textareaRef}
|
|
460
|
+
value={value}
|
|
461
|
+
onChange={e => {
|
|
462
|
+
recall.exit()
|
|
463
|
+
setActiveSuggestion(null)
|
|
464
|
+
setValue(e.target.value)
|
|
465
|
+
}}
|
|
466
|
+
onKeyDown={handleKeyDown}
|
|
467
|
+
onBlur={e => {
|
|
468
|
+
setActiveSuggestion(null)
|
|
469
|
+
textareaOnBlur?.(e)
|
|
470
|
+
}}
|
|
471
|
+
placeholder={
|
|
472
|
+
attachments.dragging
|
|
473
|
+
? 'Drop files here to add to chat'
|
|
474
|
+
: placeholderSuggestion
|
|
475
|
+
? undefined // the ghost below renders it
|
|
476
|
+
: placeholder
|
|
477
|
+
}
|
|
478
|
+
disabled={disabled}
|
|
479
|
+
rows={minRows}
|
|
480
|
+
aria-label={textareaProps?.['aria-label'] ?? 'Message'}
|
|
481
|
+
aria-describedby={
|
|
482
|
+
[showGhost ? ghostHintId : null, textareaDescribedBy].filter(Boolean).join(' ') || undefined
|
|
483
|
+
}
|
|
484
|
+
aria-activedescendant={activeSuggestion != null ? `${suggestionListId}-${activeSuggestion}` : undefined}
|
|
1227
485
|
className={cn(
|
|
1228
|
-
'
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
compactStep ? 'text-subtitle-compact leading-4.5 px-1.5 py-1.5' : 'text-subtitle leading-5 px-2 py-2',
|
|
486
|
+
'w-full resize-none rounded-none bg-transparent outline-none',
|
|
487
|
+
'text-foreground placeholder:text-muted-foreground',
|
|
488
|
+
textStep,
|
|
1232
489
|
'weight-normal',
|
|
1233
490
|
)}
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
>
|
|
1247
|
-
|
|
1248
|
-
|
|
491
|
+
{...restTextareaProps}
|
|
492
|
+
/>
|
|
493
|
+
{/* An overlay rather than the native placeholder, so the Tab keycap can sit inline. */}
|
|
494
|
+
{showGhost && (
|
|
495
|
+
<div
|
|
496
|
+
aria-hidden="true"
|
|
497
|
+
className={cn(
|
|
498
|
+
'pointer-events-none absolute inset-0 overflow-hidden text-muted-foreground',
|
|
499
|
+
textStep,
|
|
500
|
+
'weight-normal',
|
|
501
|
+
)}
|
|
502
|
+
>
|
|
503
|
+
<span className="flex max-w-full items-center gap-1.5">
|
|
504
|
+
<span className="min-w-0 truncate">{placeholderSuggestion}</span>
|
|
505
|
+
<kbd
|
|
506
|
+
className={cn(
|
|
507
|
+
'inline-flex shrink-0 -translate-y-px items-center rounded-box border border-border bg-background px-1 font-sans text-muted-foreground',
|
|
508
|
+
compactStep ? 'h-4 text-micro-compact' : 'h-[18px] text-micro',
|
|
509
|
+
)}
|
|
510
|
+
>
|
|
511
|
+
Tab
|
|
512
|
+
</kbd>
|
|
513
|
+
</span>
|
|
514
|
+
</div>
|
|
515
|
+
)}
|
|
516
|
+
{showGhost && (
|
|
517
|
+
<span id={ghostHintId} className="sr-only">
|
|
518
|
+
Suggested prompt: {placeholderSuggestion}. Press Tab to fill the composer with it.
|
|
1249
519
|
</span>
|
|
520
|
+
)}
|
|
521
|
+
</div>
|
|
522
|
+
<div
|
|
523
|
+
className={cn(
|
|
524
|
+
'flex items-center justify-between',
|
|
525
|
+
// Slot buttons are the consumer's: the compact step scales every one, send included.
|
|
526
|
+
compactStep ? 'gap-1.5 [&_button]:h-6 [&_button.w-7]:w-6 [&_button]:text-caption-compact' : 'gap-2',
|
|
527
|
+
)}
|
|
528
|
+
>
|
|
529
|
+
<div className="flex items-center gap-1.5 min-w-0">{leftContent}</div>
|
|
530
|
+
<div className="flex items-center gap-1.5 shrink-0">
|
|
531
|
+
{rightContent}
|
|
532
|
+
<Button
|
|
533
|
+
type="button"
|
|
534
|
+
variant="primary"
|
|
535
|
+
size="icon-compact"
|
|
536
|
+
onClick={buttonMode === 'stop' ? messages.stop : handleSend}
|
|
537
|
+
disabled={buttonMode === 'stop' ? disabled : !canSend}
|
|
538
|
+
aria-label={buttonLabel}
|
|
539
|
+
>
|
|
540
|
+
<AnimatePresence mode="wait" initial={false}>
|
|
541
|
+
<motion.span
|
|
542
|
+
key={buttonMode === 'stop' ? 'stop' : 'arrow'}
|
|
543
|
+
initial={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.6 }}
|
|
544
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
545
|
+
exit={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.6, transition: spring.fast.exit }}
|
|
546
|
+
transition={spring.fast}
|
|
547
|
+
className="flex items-center justify-center leading-none"
|
|
548
|
+
>
|
|
549
|
+
{buttonMode === 'stop' ? (
|
|
550
|
+
<span className="h-3 w-3 rounded-glyph bg-current" />
|
|
551
|
+
) : (
|
|
552
|
+
// A touch larger than icon-compact's 14px svg.
|
|
553
|
+
<ArrowUpIcon
|
|
554
|
+
size={compactStep ? 15 : 19}
|
|
555
|
+
className={cn('block', compactStep ? '!h-[15px] !w-[15px]' : '!h-[19px] !w-[19px]')}
|
|
556
|
+
/>
|
|
557
|
+
)}
|
|
558
|
+
</motion.span>
|
|
559
|
+
</AnimatePresence>
|
|
560
|
+
</Button>
|
|
1250
561
|
</div>
|
|
1251
|
-
)}
|
|
1252
|
-
{showGhost && (
|
|
1253
|
-
<span id={ghostHintId} className="sr-only">
|
|
1254
|
-
Suggested prompt: {placeholderSuggestion}. Press Tab to fill the composer with it.
|
|
1255
|
-
</span>
|
|
1256
|
-
)}
|
|
1257
|
-
</div>
|
|
1258
|
-
<div
|
|
1259
|
-
className={cn(
|
|
1260
|
-
'flex items-center justify-between',
|
|
1261
|
-
// The footer's controls sit one notch below the composer's step:
|
|
1262
|
-
// slot content is consumer-authored (usually sm/icon-sm pinned
|
|
1263
|
-
// Buttons), so the compact step scales any button in the row —
|
|
1264
|
-
// send button included — down to 24px via a scoped override.
|
|
1265
|
-
compactStep ? 'gap-1.5 [&_button]:h-6 [&_button.w-7]:w-6 [&_button]:text-caption-compact' : 'gap-2',
|
|
1266
|
-
)}
|
|
1267
|
-
>
|
|
1268
|
-
<div className="flex items-center gap-1.5 min-w-0">{leftContent}</div>
|
|
1269
|
-
<div className="flex items-center gap-1.5 shrink-0">
|
|
1270
|
-
{rightContent}
|
|
1271
|
-
<Button
|
|
1272
|
-
type="button"
|
|
1273
|
-
variant="primary"
|
|
1274
|
-
size="icon-sm"
|
|
1275
|
-
onClick={buttonMode === 'stop' ? handleStop : handleSend}
|
|
1276
|
-
disabled={buttonMode === 'stop' ? disabled : !canSend}
|
|
1277
|
-
aria-label={buttonLabel}
|
|
1278
|
-
>
|
|
1279
|
-
<AnimatePresence mode="wait" initial={false}>
|
|
1280
|
-
<motion.span
|
|
1281
|
-
key={buttonMode === 'stop' ? 'stop' : 'arrow'}
|
|
1282
|
-
initial={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.6 }}
|
|
1283
|
-
animate={{ opacity: 1, scale: 1 }}
|
|
1284
|
-
exit={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.6, transition: spring.fast.exit }}
|
|
1285
|
-
transition={spring.fast}
|
|
1286
|
-
className="flex items-center justify-center leading-none"
|
|
1287
|
-
>
|
|
1288
|
-
{buttonMode === 'stop' ? (
|
|
1289
|
-
<span className="h-3 w-3 rounded-glyph bg-current" />
|
|
1290
|
-
) : (
|
|
1291
|
-
// Override icon-sm's small 14px svg — the send glyph reads
|
|
1292
|
-
// better a touch larger. `size` matches the attribute to
|
|
1293
|
-
// the CSS so the svg box stays centered.
|
|
1294
|
-
<ArrowUpIcon
|
|
1295
|
-
size={compactStep ? 15 : 19}
|
|
1296
|
-
className={cn('block', compactStep ? '!h-[15px] !w-[15px]' : '!h-[19px] !w-[19px]')}
|
|
1297
|
-
/>
|
|
1298
|
-
)}
|
|
1299
|
-
</motion.span>
|
|
1300
|
-
</AnimatePresence>
|
|
1301
|
-
</Button>
|
|
1302
562
|
</div>
|
|
1303
|
-
</div>
|
|
1304
563
|
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
key="suggestions"
|
|
1318
|
-
initial={{ height: 0, opacity: 0 }}
|
|
1319
|
-
animate={{ height: suggestionsRegionHeight ?? 0, opacity: 1 }}
|
|
1320
|
-
// Height-only exit: the region clips shut bottom-up under
|
|
1321
|
-
// overflow-hidden, so the divider holds its place until the
|
|
1322
|
-
// space actually closes (a simultaneous opacity fade made it
|
|
1323
|
-
// vanish mid-collapse, which read as a height glitch).
|
|
1324
|
-
exit={{ height: 0 }}
|
|
1325
|
-
transition={{ ...spring.moderate, bounce: 0 }}
|
|
1326
|
-
// -mt-1 cancels the container's gap-1 above this region and
|
|
1327
|
-
// the listbox's mt-2 restores it INSIDE the collapsible
|
|
1328
|
-
// area — otherwise that 4px gap sits outside the height
|
|
1329
|
-
// animation and snaps away only at unmount.
|
|
1330
|
-
className="-mx-2 -mt-1 overflow-hidden"
|
|
1331
|
-
>
|
|
1332
|
-
<div
|
|
1333
|
-
ref={el => {
|
|
1334
|
-
suggestionListRef.current = el
|
|
1335
|
-
suggestionsRegionRef(el)
|
|
1336
|
-
}}
|
|
1337
|
-
role="listbox"
|
|
1338
|
-
id={suggestionListId}
|
|
1339
|
-
aria-label="Suggested prompts"
|
|
1340
|
-
onMouseEnter={suggestionHandlers.onMouseEnter}
|
|
1341
|
-
onMouseMove={suggestionHandlers.onMouseMove}
|
|
1342
|
-
onMouseLeave={suggestionHandlers.onMouseLeave}
|
|
1343
|
-
onClick={suggestionHandlers.onClick}
|
|
1344
|
-
className="relative mt-2 flex flex-col border-t border-border/60 px-1.5 pt-1.5"
|
|
564
|
+
{suggestionList.length > 0 && (
|
|
565
|
+
<AnimatePresence initial={false}>
|
|
566
|
+
{suggestionsOpen && (
|
|
567
|
+
<motion.div
|
|
568
|
+
key="suggestions"
|
|
569
|
+
initial={{ height: 0, opacity: 0 }}
|
|
570
|
+
animate={{ height: suggestionsRegionHeight ?? 0, opacity: 1 }}
|
|
571
|
+
// Height only: a fade would drop the divider before the space closes.
|
|
572
|
+
exit={{ height: 0 }}
|
|
573
|
+
transition={REGION_SPRING}
|
|
574
|
+
// -mt-1 / mt-2 move the gap inside the collapsing region; -mx-2 runs the divider full width.
|
|
575
|
+
className="-mx-2 -mt-1 overflow-hidden"
|
|
1345
576
|
>
|
|
1346
|
-
{/*
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
577
|
+
{/* biome-ignore lint/a11y/useKeyWithClickEvents: the textarea drives the list by keyboard (aria-activedescendant). */}
|
|
578
|
+
<div
|
|
579
|
+
ref={el => {
|
|
580
|
+
suggestionListRef.current = el
|
|
581
|
+
suggestionsRegionRef(el)
|
|
582
|
+
}}
|
|
583
|
+
role="listbox"
|
|
584
|
+
id={suggestionListId}
|
|
585
|
+
aria-label="Suggested prompts"
|
|
586
|
+
onMouseEnter={suggestionHandlers.onMouseEnter}
|
|
587
|
+
onMouseMove={suggestionHandlers.onMouseMove}
|
|
588
|
+
onMouseLeave={suggestionHandlers.onMouseLeave}
|
|
589
|
+
onClick={suggestionHandlers.onClick}
|
|
590
|
+
className="relative mt-2 flex flex-col border-t border-border/60 px-1.5 pt-1.5"
|
|
591
|
+
>
|
|
592
|
+
<FluidHoverHighlight hover={suggestionHover} className={shape.bg} />
|
|
593
|
+
{suggestionList.map((s, i) => (
|
|
594
|
+
<SuggestionRow
|
|
595
|
+
key={`${s}-${i}`}
|
|
596
|
+
text={s}
|
|
597
|
+
index={i}
|
|
598
|
+
active={i === activeSuggestion}
|
|
599
|
+
keyHint={i === 0 && activeSuggestion == null}
|
|
600
|
+
optionId={`${suggestionListId}-${i}`}
|
|
601
|
+
registerItem={registerSuggestion}
|
|
602
|
+
onSelect={() => acceptSuggestion(s)}
|
|
603
|
+
/>
|
|
604
|
+
))}
|
|
605
|
+
</div>
|
|
606
|
+
</motion.div>
|
|
607
|
+
)}
|
|
608
|
+
</AnimatePresence>
|
|
609
|
+
)}
|
|
610
|
+
<span className="sr-only" role="status" aria-live="polite">
|
|
611
|
+
{messages.announcement}
|
|
612
|
+
</span>
|
|
613
|
+
</SurfaceProvider>
|
|
614
|
+
</div>
|
|
615
|
+
</SizeScope>
|
|
1372
616
|
)
|
|
1373
|
-
|
|
1374
|
-
// A size prop pins the whole composer — inner buttons, rows and queued
|
|
1375
|
-
// messages included — to one ladder step (matches InputGroup).
|
|
1376
|
-
return size ? <SizeProvider size={size}>{composer}</SizeProvider> : composer
|
|
1377
617
|
},
|
|
1378
618
|
)
|
|
1379
619
|
|