@kumix/ui 0.3.13 → 0.3.15
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 +12 -12
- package/dist/components/agents/agent-activity/activity-row.js +1 -1
- package/dist/components/agents/agent-activity/activity-row.js.map +1 -1
- package/dist/components/agents/agent-activity/index.js +1 -1
- package/dist/components/agents/agent-activity/index.js.map +1 -1
- package/dist/components/agents/agent-code.d.ts.map +1 -1
- package/dist/components/agents/agent-code.js +1 -1
- package/dist/components/agents/agent-code.js.map +1 -1
- package/dist/components/agents/agent-disclosure.js +1 -1
- package/dist/components/agents/agent-disclosure.js.map +1 -1
- package/dist/components/agents/ai-sidebar.js +1 -1
- package/dist/components/agents/ai-sidebar.js.map +1 -1
- package/dist/components/agents/approval-card/index.js +1 -1
- package/dist/components/agents/approval-card/index.js.map +1 -1
- package/dist/components/agents/chat-app.js +1 -1
- package/dist/components/agents/chat-app.js.map +1 -1
- package/dist/components/agents/citations.js +1 -1
- package/dist/components/agents/citations.js.map +1 -1
- package/dist/components/agents/code-block.js +1 -1
- package/dist/components/agents/code-block.js.map +1 -1
- package/dist/components/agents/file-diff.js +1 -1
- package/dist/components/agents/file-diff.js.map +1 -1
- package/dist/components/agents/image-generation.js +1 -1
- package/dist/components/agents/image-generation.js.map +1 -1
- package/dist/components/agents/loading-states/agent-progress.js +1 -1
- package/dist/components/agents/loading-states/agent-progress.js.map +1 -1
- package/dist/components/agents/loading-states/reasoning-text.js +1 -1
- package/dist/components/agents/loading-states/reasoning-text.js.map +1 -1
- package/dist/components/agents/loading-states/thinking-shimmer.js +1 -1
- package/dist/components/agents/loading-states/thinking-shimmer.js.map +1 -1
- package/dist/components/agents/message-bubble.js +1 -1
- package/dist/components/agents/message-bubble.js.map +1 -1
- package/dist/components/agents/message-scroller.js +1 -1
- package/dist/components/agents/message-scroller.js.map +1 -1
- package/dist/components/agents/message.js +1 -1
- package/dist/components/agents/message.js.map +1 -1
- package/dist/components/agents/prompt-input.js +1 -1
- package/dist/components/agents/prompt-input.js.map +1 -1
- package/dist/components/agents/streaming-response.js +1 -1
- package/dist/components/agents/streaming-response.js.map +1 -1
- package/dist/components/agents/todo-list.js +1 -1
- package/dist/components/agents/todo-list.js.map +1 -1
- package/dist/components/agents/tool-approval.js +1 -1
- package/dist/components/agents/tool-approval.js.map +1 -1
- package/dist/components/agents/tool-result.js +1 -1
- package/dist/components/agents/tool-result.js.map +1 -1
- package/dist/components/motion/action-swap.js +1 -1
- package/dist/components/motion/action-swap.js.map +1 -1
- package/dist/components/motion/adaptive-stepper.js +1 -1
- package/dist/components/motion/adaptive-stepper.js.map +1 -1
- package/dist/components/motion/animated-badge.js +1 -1
- package/dist/components/motion/animated-badge.js.map +1 -1
- package/dist/components/motion/animated-number.js +1 -1
- package/dist/components/motion/animated-number.js.map +1 -1
- package/dist/components/motion/animated-sidebar.js +1 -1
- package/dist/components/motion/animated-sidebar.js.map +1 -1
- package/dist/components/motion/animated-toast-stack.js +5 -4
- package/dist/components/motion/animated-toast-stack.js.map +1 -1
- package/dist/components/motion/attachment-upload.js +1 -1
- package/dist/components/motion/attachment-upload.js.map +1 -1
- package/dist/components/motion/availability-scheduler/icon-button.js +1 -1
- package/dist/components/motion/availability-scheduler/icon-button.js.map +1 -1
- package/dist/components/motion/availability-scheduler/index.js +1 -1
- package/dist/components/motion/availability-scheduler/index.js.map +1 -1
- package/dist/components/motion/bloom-menu.js +1 -1
- package/dist/components/motion/bloom-menu.js.map +1 -1
- package/dist/components/motion/bottom-sheet.js +1 -1
- package/dist/components/motion/bottom-sheet.js.map +1 -1
- package/dist/components/motion/bounce-sidebar.d.ts.map +1 -1
- package/dist/components/motion/bounce-sidebar.js +1 -1
- package/dist/components/motion/bounce-sidebar.js.map +1 -1
- package/dist/components/motion/bouncy-accordion.js +1 -1
- package/dist/components/motion/bouncy-accordion.js.map +1 -1
- package/dist/components/motion/button/base.js +1 -1
- package/dist/components/motion/button/base.js.map +1 -1
- package/dist/components/motion/button/metallic.js +1 -1
- package/dist/components/motion/button/metallic.js.map +1 -1
- package/dist/components/motion/card-folder.js +1 -1
- package/dist/components/motion/card-folder.js.map +1 -1
- package/dist/components/motion/center-morph-modal.js +1 -1
- package/dist/components/motion/center-morph-modal.js.map +1 -1
- package/dist/components/motion/checkbox.js +1 -1
- package/dist/components/motion/checkbox.js.map +1 -1
- package/dist/components/motion/chromatic-text-reveal.js +1 -1
- package/dist/components/motion/chromatic-text-reveal.js.map +1 -1
- package/dist/components/motion/combobox/content.js +1 -1
- package/dist/components/motion/combobox/content.js.map +1 -1
- package/dist/components/motion/combobox/context.js +1 -1
- package/dist/components/motion/combobox/context.js.map +1 -1
- package/dist/components/motion/combobox/list.js +1 -1
- package/dist/components/motion/combobox/list.js.map +1 -1
- package/dist/components/motion/combobox/trigger.js +1 -1
- package/dist/components/motion/combobox/trigger.js.map +1 -1
- package/dist/components/motion/command-palette.d.ts.map +1 -1
- package/dist/components/motion/command-palette.js +3 -22
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/context-menu.js +1 -1
- package/dist/components/motion/context-menu.js.map +1 -1
- package/dist/components/motion/cylinder-carousel.js +1 -1
- package/dist/components/motion/cylinder-carousel.js.map +1 -1
- package/dist/components/motion/digit-swap.js +1 -1
- package/dist/components/motion/digit-swap.js.map +1 -1
- package/dist/components/motion/dock.js +1 -1
- package/dist/components/motion/dock.js.map +1 -1
- package/dist/components/motion/drawer.js +1 -1
- package/dist/components/motion/drawer.js.map +1 -1
- package/dist/components/motion/dynamic-island.js +1 -1
- package/dist/components/motion/dynamic-island.js.map +1 -1
- package/dist/components/motion/expandable-action-bar.js +1 -1
- package/dist/components/motion/expandable-action-bar.js.map +1 -1
- package/dist/components/motion/expandable-control.d.ts.map +1 -1
- package/dist/components/motion/expandable-control.js +1 -1
- package/dist/components/motion/expandable-control.js.map +1 -1
- package/dist/components/motion/expandable-tabs.js +1 -1
- package/dist/components/motion/expandable-tabs.js.map +1 -1
- package/dist/components/motion/expanding-arrow-button.js +1 -1
- package/dist/components/motion/expanding-arrow-button.js.map +1 -1
- package/dist/components/motion/feedback-widget.js +1 -1
- package/dist/components/motion/feedback-widget.js.map +1 -1
- package/dist/components/motion/file-tree.js +1 -1
- package/dist/components/motion/file-tree.js.map +1 -1
- package/dist/components/motion/file-upload.js +1 -1
- package/dist/components/motion/file-upload.js.map +1 -1
- package/dist/components/motion/hold-action-button.js +1 -1
- package/dist/components/motion/hold-action-button.js.map +1 -1
- package/dist/components/motion/infinite-masonry.js +1 -1
- package/dist/components/motion/infinite-masonry.js.map +1 -1
- package/dist/components/motion/input.d.ts.map +1 -1
- package/dist/components/motion/input.js +1 -1
- package/dist/components/motion/input.js.map +1 -1
- package/dist/components/motion/liquid.js +1 -1
- package/dist/components/motion/liquid.js.map +1 -1
- package/dist/components/motion/loader.js +1 -1
- package/dist/components/motion/loader.js.map +1 -1
- package/dist/components/motion/magnetic.js +1 -1
- package/dist/components/motion/magnetic.js.map +1 -1
- package/dist/components/motion/marquee.d.ts.map +1 -1
- package/dist/components/motion/marquee.js +1 -1
- package/dist/components/motion/marquee.js.map +1 -1
- package/dist/components/motion/morphing-modal.js +1 -1
- package/dist/components/motion/morphing-modal.js.map +1 -1
- package/dist/components/motion/morphing-search.js +1 -1
- package/dist/components/motion/morphing-search.js.map +1 -1
- package/dist/components/motion/morphing-tabs.js +1 -1
- package/dist/components/motion/morphing-tabs.js.map +1 -1
- package/dist/components/motion/multi-select/content.js +1 -1
- package/dist/components/motion/multi-select/content.js.map +1 -1
- package/dist/components/motion/multi-select/context.js +1 -1
- package/dist/components/motion/multi-select/context.js.map +1 -1
- package/dist/components/motion/multi-select/list.js +1 -1
- package/dist/components/motion/multi-select/list.js.map +1 -1
- package/dist/components/motion/multi-select/trigger.js +1 -1
- package/dist/components/motion/multi-select/trigger.js.map +1 -1
- package/dist/components/motion/not-found/magnetic.d.ts.map +1 -1
- package/dist/components/motion/not-found/magnetic.js +1 -1
- package/dist/components/motion/not-found/magnetic.js.map +1 -1
- package/dist/components/motion/not-found/shared.js +1 -1
- package/dist/components/motion/not-found/shared.js.map +1 -1
- package/dist/components/motion/not-found/spotlight.js +1 -1
- package/dist/components/motion/not-found/spotlight.js.map +1 -1
- package/dist/components/motion/notification-stack.js +1 -1
- package/dist/components/motion/notification-stack.js.map +1 -1
- package/dist/components/motion/number-ticker.js +1 -1
- package/dist/components/motion/number-ticker.js.map +1 -1
- package/dist/components/motion/otp-input.js +1 -1
- package/dist/components/motion/otp-input.js.map +1 -1
- package/dist/components/motion/overflow-actions.js +1 -1
- package/dist/components/motion/overflow-actions.js.map +1 -1
- package/dist/components/motion/parallax.d.ts.map +1 -1
- package/dist/components/motion/parallax.js +1 -1
- package/dist/components/motion/parallax.js.map +1 -1
- package/dist/components/motion/popover-morph.js +1 -1
- package/dist/components/motion/popover-morph.js.map +1 -1
- package/dist/components/motion/popover.js +1 -1
- package/dist/components/motion/popover.js.map +1 -1
- package/dist/components/motion/preview-rail.js +1 -1
- package/dist/components/motion/preview-rail.js.map +1 -1
- package/dist/components/motion/project-folder.js +1 -1
- package/dist/components/motion/project-folder.js.map +1 -1
- package/dist/components/motion/pull-to-refresh.js +1 -1
- package/dist/components/motion/pull-to-refresh.js.map +1 -1
- package/dist/components/motion/radio.js +1 -1
- package/dist/components/motion/radio.js.map +1 -1
- package/dist/components/motion/range-slider-bubble.js +1 -1
- package/dist/components/motion/range-slider-bubble.js.map +1 -1
- package/dist/components/motion/range-slider-fluid.js +1 -1
- package/dist/components/motion/range-slider-fluid.js.map +1 -1
- package/dist/components/motion/range-slider-inline.d.ts +18 -0
- package/dist/components/motion/range-slider-inline.d.ts.map +1 -0
- package/dist/components/motion/range-slider-inline.js +267 -0
- package/dist/components/motion/range-slider-inline.js.map +1 -0
- package/dist/components/motion/range-slider-ruler.js +1 -1
- package/dist/components/motion/range-slider-ruler.js.map +1 -1
- package/dist/components/motion/range-slider-wave.js +1 -1
- package/dist/components/motion/range-slider-wave.js.map +1 -1
- package/dist/components/motion/range-slider.d.ts.map +1 -1
- package/dist/components/motion/range-slider.js +27 -11
- package/dist/components/motion/range-slider.js.map +1 -1
- package/dist/components/motion/scroll-progress.js +1 -1
- package/dist/components/motion/scroll-progress.js.map +1 -1
- package/dist/components/motion/scroll-reveal.js +1 -1
- package/dist/components/motion/scroll-reveal.js.map +1 -1
- package/dist/components/motion/scroll-to.js +1 -1
- package/dist/components/motion/scroll-to.js.map +1 -1
- package/dist/components/motion/select-morph.d.ts.map +1 -1
- package/dist/components/motion/select-morph.js +1 -1
- package/dist/components/motion/select-morph.js.map +1 -1
- package/dist/components/motion/select.js +1 -1
- package/dist/components/motion/select.js.map +1 -1
- package/dist/components/motion/shader-background.d.ts.map +1 -1
- package/dist/components/motion/shader-background.js +1 -1
- package/dist/components/motion/shader-background.js.map +1 -1
- package/dist/components/motion/shared-layout-bg.js +1 -1
- package/dist/components/motion/shared-layout-bg.js.map +1 -1
- package/dist/components/motion/signup-form.js +1 -1
- package/dist/components/motion/signup-form.js.map +1 -1
- package/dist/components/motion/slide-action-button.js +1 -1
- package/dist/components/motion/slide-action-button.js.map +1 -1
- package/dist/components/motion/swipeable-list.js +1 -1
- package/dist/components/motion/swipeable-list.js.map +1 -1
- package/dist/components/motion/switch.d.ts.map +1 -1
- package/dist/components/motion/switch.js +1 -1
- package/dist/components/motion/switch.js.map +1 -1
- package/dist/components/motion/table/index.js +1 -1
- package/dist/components/motion/table/index.js.map +1 -1
- package/dist/components/motion/table/skeleton-rows.d.ts.map +1 -1
- package/dist/components/motion/table/skeleton-rows.js +1 -1
- package/dist/components/motion/table/skeleton-rows.js.map +1 -1
- package/dist/components/motion/table/table-header.js +1 -1
- package/dist/components/motion/table/table-header.js.map +1 -1
- package/dist/components/motion/table/table-menu.js +1 -1
- package/dist/components/motion/table/table-menu.js.map +1 -1
- package/dist/components/motion/tabs.js +2 -2
- package/dist/components/motion/tabs.js.map +1 -1
- package/dist/components/motion/text-reveal.js +1 -1
- package/dist/components/motion/text-reveal.js.map +1 -1
- package/dist/components/motion/text-scramble.d.ts.map +1 -1
- package/dist/components/motion/text-scramble.js +1 -1
- package/dist/components/motion/text-scramble.js.map +1 -1
- package/dist/components/motion/text-shimmer.js +1 -1
- package/dist/components/motion/text-shimmer.js.map +1 -1
- package/dist/components/motion/theme-toggle.js +1 -1
- package/dist/components/motion/theme-toggle.js.map +1 -1
- package/dist/components/motion/tilt-card.js +1 -1
- package/dist/components/motion/tilt-card.js.map +1 -1
- package/dist/components/motion/tooltip-surface.d.ts +12 -0
- package/dist/components/motion/tooltip-surface.d.ts.map +1 -0
- package/dist/components/motion/tooltip-surface.js +97 -0
- package/dist/components/motion/tooltip-surface.js.map +1 -0
- package/dist/components/motion/tooltip.d.ts +13 -3
- package/dist/components/motion/tooltip.d.ts.map +1 -1
- package/dist/components/motion/tooltip.js +75 -104
- package/dist/components/motion/tooltip.js.map +1 -1
- package/dist/components/motion/wheel-picker.js +1 -1
- package/dist/components/motion/wheel-picker.js.map +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/alert.d.ts.map +1 -1
- package/dist/components/reui/alert.js +1 -1
- package/dist/components/reui/alert.js.map +1 -1
- package/dist/components/reui/autocomplete.d.ts +1 -1
- package/dist/components/reui/autocomplete.d.ts.map +1 -1
- package/dist/components/reui/autocomplete.js +2 -2
- package/dist/components/reui/autocomplete.js.map +1 -1
- package/dist/components/reui/badge.d.ts +2 -2
- package/dist/components/reui/badge.d.ts.map +1 -1
- package/dist/components/reui/badge.js +1 -1
- package/dist/components/reui/badge.js.map +1 -1
- package/dist/components/reui/cascader/cascader-columns.js +1 -1
- package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
- package/dist/components/reui/cascader/cascader-footer.js +1 -1
- package/dist/components/reui/cascader/cascader-footer.js.map +1 -1
- package/dist/components/reui/cascader/cascader-item.js +1 -1
- package/dist/components/reui/cascader/cascader-item.js.map +1 -1
- package/dist/components/reui/cascader/cascader-nav.js +1 -1
- package/dist/components/reui/cascader/cascader-nav.js.map +1 -1
- package/dist/components/reui/cascader/cascader.js +1 -1
- package/dist/components/reui/cascader/cascader.js.map +1 -1
- package/dist/components/reui/code-block/code-block.js +1 -1
- package/dist/components/reui/code-block/code-block.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-cell-selection.js +1 -1
- package/dist/components/reui/data-grid/data-grid-cell-selection.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +1 -1
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.js +1 -1
- package/dist/components/reui/date-selector.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-content.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-content.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
- package/dist/components/reui/filters/filters-advanced.js +1 -1
- package/dist/components/reui/filters/filters-advanced.js.map +1 -1
- package/dist/components/reui/filters/filters-builder.js +1 -1
- package/dist/components/reui/filters/filters-builder.js.map +1 -1
- package/dist/components/reui/filters/filters-chip.js +1 -1
- package/dist/components/reui/filters/filters-chip.js.map +1 -1
- package/dist/components/reui/filters/filters-editors.js +1 -1
- package/dist/components/reui/filters/filters-editors.js.map +1 -1
- package/dist/components/reui/filters/filters.js +1 -1
- package/dist/components/reui/filters/filters.js.map +1 -1
- package/dist/components/reui/frame.d.ts +6 -12
- package/dist/components/reui/frame.d.ts.map +1 -1
- package/dist/components/reui/frame.js +10 -17
- package/dist/components/reui/frame.js.map +1 -1
- package/dist/components/reui/gantt/gantt-bar.js +1 -1
- package/dist/components/reui/gantt/gantt-bar.js.map +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +1 -1
- package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
- package/dist/components/reui/gantt/gantt-view.js +1 -1
- package/dist/components/reui/gantt/gantt-view.js.map +1 -1
- package/dist/components/reui/gantt/gantt.js +1 -1
- package/dist/components/reui/gantt/gantt.js.map +1 -1
- package/dist/components/reui/icon-stack.js +1 -1
- package/dist/components/reui/icon-stack.js.map +1 -1
- package/dist/components/reui/icon-tile.d.ts +2 -2
- package/dist/components/reui/icon-tile.d.ts.map +1 -1
- package/dist/components/reui/icon-tile.js +1 -1
- package/dist/components/reui/icon-tile.js.map +1 -1
- package/dist/components/reui/kanban.d.ts.map +1 -1
- package/dist/components/reui/kanban.js +1 -1
- package/dist/components/reui/kanban.js.map +1 -1
- package/dist/components/reui/number-field.d.ts +3 -3
- package/dist/components/reui/number-field.d.ts.map +1 -1
- package/dist/components/reui/number-field.js +4 -4
- package/dist/components/reui/number-field.js.map +1 -1
- package/dist/components/reui/phone-input.js +1 -1
- package/dist/components/reui/phone-input.js.map +1 -1
- package/dist/components/reui/rating.d.ts +1 -1
- package/dist/components/reui/rating.d.ts.map +1 -1
- package/dist/components/reui/rating.js +1 -1
- package/dist/components/reui/rating.js.map +1 -1
- package/dist/components/reui/sortable.d.ts.map +1 -1
- package/dist/components/reui/sortable.js +1 -1
- package/dist/components/reui/sortable.js.map +1 -1
- package/dist/components/reui/stepper.d.ts.map +1 -1
- package/dist/components/reui/stepper.js +1 -1
- package/dist/components/reui/stepper.js.map +1 -1
- package/dist/components/reui/timeline.d.ts.map +1 -1
- package/dist/components/reui/timeline.js +1 -1
- package/dist/components/reui/timeline.js.map +1 -1
- package/dist/components/reui/tree.d.ts.map +1 -1
- package/dist/components/reui/tree.js +1 -1
- package/dist/components/reui/tree.js.map +1 -1
- package/dist/components/ui/accordion.d.ts.map +1 -1
- package/dist/components/ui/accordion.js +1 -1
- package/dist/components/ui/accordion.js.map +1 -1
- package/dist/components/ui/alert-dialog.js +1 -1
- package/dist/components/ui/alert-dialog.js.map +1 -1
- package/dist/components/ui/alert.d.ts.map +1 -1
- package/dist/components/ui/alert.js +1 -1
- package/dist/components/ui/alert.js.map +1 -1
- package/dist/components/ui/aspect-ratio.js +1 -1
- package/dist/components/ui/aspect-ratio.js.map +1 -1
- package/dist/components/ui/attachment.d.ts +1 -1
- package/dist/components/ui/attachment.js +1 -1
- package/dist/components/ui/attachment.js.map +1 -1
- package/dist/components/ui/avatar.d.ts.map +1 -1
- package/dist/components/ui/avatar.js +1 -1
- package/dist/components/ui/avatar.js.map +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/badge.d.ts.map +1 -1
- package/dist/components/ui/badge.js +1 -1
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/breadcrumb.d.ts.map +1 -1
- package/dist/components/ui/breadcrumb.js +1 -1
- package/dist/components/ui/breadcrumb.js.map +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts.map +1 -1
- package/dist/components/ui/bubble.js +1 -1
- package/dist/components/ui/bubble.js.map +1 -1
- package/dist/components/ui/button-group.js +1 -1
- package/dist/components/ui/button-group.js.map +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/calendar.js +1 -1
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/card.d.ts.map +1 -1
- package/dist/components/ui/card.js +1 -1
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/carousel.js +1 -1
- package/dist/components/ui/carousel.js.map +1 -1
- package/dist/components/ui/chart.d.ts.map +1 -1
- package/dist/components/ui/chart.js +1 -1
- package/dist/components/ui/chart.js.map +1 -1
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/checkbox.js.map +1 -1
- package/dist/components/ui/combobox.js +1 -1
- package/dist/components/ui/combobox.js.map +1 -1
- package/dist/components/ui/command.js +1 -1
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/context-menu.d.ts.map +1 -1
- package/dist/components/ui/context-menu.js +1 -1
- package/dist/components/ui/context-menu.js.map +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer.js +1 -1
- package/dist/components/ui/drawer.js.map +1 -1
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/empty.d.ts.map +1 -1
- package/dist/components/ui/empty.js +1 -1
- package/dist/components/ui/empty.js.map +1 -1
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/field.js.map +1 -1
- package/dist/components/ui/hover-card.d.ts.map +1 -1
- package/dist/components/ui/hover-card.js +1 -1
- package/dist/components/ui/hover-card.js.map +1 -1
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/input-group.js +1 -1
- package/dist/components/ui/input-group.js.map +1 -1
- package/dist/components/ui/input-otp.d.ts.map +1 -1
- package/dist/components/ui/input-otp.js +1 -1
- package/dist/components/ui/input-otp.js.map +1 -1
- package/dist/components/ui/input.d.ts.map +1 -1
- package/dist/components/ui/input.js +1 -1
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/item.js +1 -1
- package/dist/components/ui/item.js.map +1 -1
- package/dist/components/ui/kbd.js +1 -1
- package/dist/components/ui/kbd.js.map +1 -1
- package/dist/components/ui/label.d.ts.map +1 -1
- package/dist/components/ui/label.js +1 -1
- package/dist/components/ui/label.js.map +1 -1
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/marker.d.ts.map +1 -1
- package/dist/components/ui/marker.js +1 -1
- package/dist/components/ui/marker.js.map +1 -1
- package/dist/components/ui/menubar.js +1 -1
- package/dist/components/ui/menubar.js.map +1 -1
- package/dist/components/ui/message-scroller.js +1 -1
- package/dist/components/ui/message-scroller.js.map +1 -1
- package/dist/components/ui/message.d.ts.map +1 -1
- package/dist/components/ui/message.js +1 -1
- package/dist/components/ui/message.js.map +1 -1
- package/dist/components/ui/native-select.d.ts.map +1 -1
- package/dist/components/ui/native-select.js +1 -1
- package/dist/components/ui/native-select.js.map +1 -1
- package/dist/components/ui/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu.js +1 -1
- package/dist/components/ui/navigation-menu.js.map +1 -1
- package/dist/components/ui/pagination.js +1 -1
- package/dist/components/ui/pagination.js.map +1 -1
- package/dist/components/ui/popover.d.ts.map +1 -1
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/components/ui/progress.js +1 -1
- package/dist/components/ui/progress.js.map +1 -1
- package/dist/components/ui/questionnaire.js +1 -1
- package/dist/components/ui/questionnaire.js.map +1 -1
- package/dist/components/ui/radio-group.d.ts.map +1 -1
- package/dist/components/ui/radio-group.js +1 -1
- package/dist/components/ui/radio-group.js.map +1 -1
- package/dist/components/ui/resizable.d.ts.map +1 -1
- package/dist/components/ui/resizable.js +1 -1
- package/dist/components/ui/resizable.js.map +1 -1
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.js +1 -1
- package/dist/components/ui/scroll-area.js.map +1 -1
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/separator.d.ts.map +1 -1
- package/dist/components/ui/separator.js +1 -1
- package/dist/components/ui/separator.js.map +1 -1
- package/dist/components/ui/sheet.js +1 -1
- package/dist/components/ui/sheet.js.map +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/skeleton.js.map +1 -1
- package/dist/components/ui/slider.d.ts.map +1 -1
- package/dist/components/ui/slider.js +1 -1
- package/dist/components/ui/slider.js.map +1 -1
- package/dist/components/ui/spinner.d.ts.map +1 -1
- package/dist/components/ui/spinner.js +1 -1
- package/dist/components/ui/spinner.js.map +1 -1
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/switch.js.map +1 -1
- package/dist/components/ui/table.d.ts.map +1 -1
- package/dist/components/ui/table.js +1 -1
- package/dist/components/ui/table.js.map +1 -1
- package/dist/components/ui/tabs.d.ts +1 -1
- package/dist/components/ui/tabs.d.ts.map +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/tabs.js.map +1 -1
- package/dist/components/ui/textarea.d.ts.map +1 -1
- package/dist/components/ui/textarea.js +1 -1
- package/dist/components/ui/textarea.js.map +1 -1
- package/dist/components/ui/toast.js +1 -1
- package/dist/components/ui/toast.js.map +1 -1
- package/dist/components/ui/toggle-group.js +1 -1
- package/dist/components/ui/toggle-group.js.map +1 -1
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/components/ui/toggle.d.ts.map +1 -1
- package/dist/components/ui/toggle.js +1 -1
- package/dist/components/ui/toggle.js.map +1 -1
- package/dist/components/ui/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip.js +1 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/hooks/use-dismiss.d.ts +1 -1
- package/dist/hooks/use-dismiss.d.ts.map +1 -1
- package/dist/hooks/use-dismiss.js.map +1 -1
- package/dist/lib/command-search.d.ts +10 -0
- package/dist/lib/command-search.d.ts.map +1 -0
- package/dist/lib/command-search.js +52 -0
- package/dist/lib/command-search.js.map +1 -0
- package/package.json +10 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-bubble.js","names":[],"sources":["../../../src/components/agents/message-bubble.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentPropsWithRef,\n cloneElement,\n createContext,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useContext,\n useId,\n useState,\n} from \"react\";\nimport { cn } from \"cn\";\nimport { ChevronDown } from \"lucide-react\";\nimport { type HTMLMotionProps, motion, useReducedMotion } from \"motion/react\";\n\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from \"../../lib/ease\";\nimport { MessageSideContext } from \"./message-context\";\n\nexport type MessageBubbleVariant = \"solid\" | \"soft\" | \"tint\" | \"outline\" | \"ghost\" | \"danger\";\nexport type MessageBubbleAlign = \"start\" | \"end\";\n\ninterface MessageBubbleContextValue {\n align?: MessageBubbleAlign;\n animateIn: boolean;\n variant: MessageBubbleVariant;\n}\n\nconst MessageBubbleContext = createContext<MessageBubbleContextValue>({\n animateIn: true,\n variant: \"soft\",\n});\nconst MessageBubbleLayoutContext = createContext<() => void>(() => {});\n\nexport interface MessageBubbleProps extends Omit<HTMLMotionProps<\"div\">, \"children\"> {\n variant?: MessageBubbleVariant;\n /** Defaults to the surrounding Message alignment when omitted. */\n align?: MessageBubbleAlign;\n /** Plays the bubble entrance once when this component mounts. */\n animateIn?: boolean;\n children?: ReactNode;\n}\n\nexport interface MessageBubbleContentProps extends ComponentPropsWithRef<\"div\"> {\n /** Replaces the content element while preserving bubble styling. */\n render?: ReactElement;\n}\n\nexport interface MessageBubbleGroupProps extends ComponentPropsWithRef<\"div\"> {\n spacing?: \"compact\" | \"default\";\n}\n\nexport interface MessageBubbleCollapsibleProps extends ComponentPropsWithRef<\"div\"> {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n collapsedLines?: 2 | 3 | 4 | 5 | 6;\n moreLabel?: ReactNode;\n lessLabel?: ReactNode;\n contentClassName?: string;\n triggerClassName?: string;\n children?: ReactNode;\n}\n\nfunction mergeRefs<T>(...refs: Array<Ref<T> | undefined>) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }\n };\n}\n\nconst BUBBLE_CONTENT_REVEAL = {\n duration: 0.12,\n ease: EASE_OUT,\n delay: 0.04,\n} as const;\n\n// Sent bubbles should pop into place quickly with one restrained overshoot.\nconst BUBBLE_POP = {\n type: \"spring\",\n stiffness: 520,\n damping: 27,\n mass: 0.52,\n} as const;\n\nexport function MessageBubble({\n variant = \"soft\",\n align,\n animateIn = false,\n className,\n children,\n initial,\n animate,\n exit,\n transition,\n layout,\n ...props\n}: MessageBubbleProps) {\n const reduce = useReducedMotion() ?? false;\n const messageSide = useContext(MessageSideContext);\n const resolvedAlign = align ?? messageSide ?? \"start\";\n\n return (\n <MessageBubbleContext.Provider value={{ align: resolvedAlign, animateIn, variant }}>\n <motion.div\n data-slot=\"message-bubble\"\n data-align={resolvedAlign}\n data-variant={variant}\n layout={layout}\n initial={initial ?? false}\n animate={animate}\n exit={exit ?? (reduce ? { opacity: 0 } : { opacity: 0, y: -3, scale: 0.99 })}\n transition={transition ?? (reduce ? { duration: 0.12 } : SPRING_LAYOUT)}\n className={cn(\n \"group/bubble flex w-full flex-col\",\n resolvedAlign === \"end\" ? \"items-end\" : \"items-start\",\n className,\n )}\n {...props}\n >\n {children}\n </motion.div>\n </MessageBubbleContext.Provider>\n );\n}\n\nfunction bubbleContentClass(variant: MessageBubbleVariant, interactive: boolean) {\n return cn(\n \"relative z-0 min-w-9 max-w-[82%] rounded-2xl px-3.5 py-2.5 text-foreground text-sm leading-6\",\n \"[&_a]:font-medium [&_a]:underline [&_a]:underline-offset-4 [&_code]:rounded [&_code]:bg-background/60 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em] [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p+p]:mt-2 [&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-xl [&_pre]:bg-background/60 [&_pre]:p-3 [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5\",\n variant === \"solid\" && \"text-background\",\n variant === \"ghost\" && \"w-full max-w-none rounded-none px-0 py-0\",\n variant === \"danger\" && \"text-destructive\",\n interactive &&\n \"cursor-pointer text-left outline-none transition-[background-color,color,transform] duration-150 hover:brightness-[0.98] focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.99]\",\n );\n}\n\nfunction bubbleSurfaceClass(variant: MessageBubbleVariant, align: MessageBubbleAlign) {\n return cn(\n \"pointer-events-none absolute inset-0 -z-10 rounded-[inherit]\",\n align === \"end\" ? \"origin-bottom-right\" : \"origin-bottom-left\",\n variant === \"solid\" && \"bg-foreground\",\n variant === \"soft\" && \"bg-muted\",\n variant === \"tint\" && \"bg-primary/10\",\n variant === \"outline\" && \"border border-border/70 bg-background\",\n variant === \"danger\" && \"bg-destructive/10\",\n );\n}\n\nexport function MessageBubbleContent({\n render,\n className,\n children,\n ref,\n ...props\n}: MessageBubbleContentProps) {\n const reduce = useReducedMotion() ?? false;\n const { align = \"start\", animateIn, variant } = useContext(MessageBubbleContext);\n const [layoutVersion, setLayoutVersion] = useState(0);\n const notifyLayout = useCallback(() => setLayoutVersion((version) => version + 1), []);\n const interactive = render?.type === \"button\" || render?.type === \"a\";\n const classes = cn(bubbleContentClass(variant, interactive), className);\n const composedChildren = (\n <>\n {variant !== \"ghost\" ? (\n <motion.span\n aria-hidden=\"true\"\n layout={reduce ? false : \"size\"}\n layoutDependency={layoutVersion}\n initial={\n animateIn && !reduce\n ? {\n opacity: 0,\n scale: 0.92,\n }\n : false\n }\n animate={{ opacity: 1, scale: 1 }}\n transition={\n reduce\n ? { duration: 0 }\n : {\n opacity: { duration: 0.12, ease: EASE_OUT },\n scale: BUBBLE_POP,\n layout: SPRING_LAYOUT,\n }\n }\n className={bubbleSurfaceClass(variant, align)}\n />\n ) : null}\n <MessageBubbleLayoutContext.Provider value={notifyLayout}>\n <motion.div\n initial={animateIn ? (reduce ? { opacity: 0 } : { opacity: 0 }) : false}\n animate={{ opacity: 1 }}\n transition={reduce ? { duration: 0.12, ease: EASE_OUT } : BUBBLE_CONTENT_REVEAL}\n className=\"relative\"\n >\n {children}\n </motion.div>\n </MessageBubbleLayoutContext.Provider>\n </>\n );\n\n if (render) {\n const child = render as ReactElement<\n Record<string, unknown> & { className?: string; ref?: Ref<HTMLElement> }\n >;\n\n return cloneElement(child, {\n ...props,\n ref: mergeRefs(child.props.ref, ref as Ref<HTMLElement> | undefined),\n className: cn(classes, child.props.className),\n children: composedChildren,\n \"data-slot\": \"message-bubble-content\",\n });\n }\n\n return (\n <div ref={ref} data-slot=\"message-bubble-content\" className={classes} {...props}>\n {composedChildren}\n </div>\n );\n}\n\nexport function MessageBubbleGroup({\n spacing = \"compact\",\n className,\n ...props\n}: MessageBubbleGroupProps) {\n return (\n <div\n data-slot=\"message-bubble-group\"\n className={cn(\"flex w-full flex-col\", spacing === \"compact\" ? \"gap-1.5\" : \"gap-3\", className)}\n {...props}\n />\n );\n}\n\nconst LINE_CLAMP_CLASS = {\n 2: \"line-clamp-2\",\n 3: \"line-clamp-3\",\n 4: \"line-clamp-4\",\n 5: \"line-clamp-5\",\n 6: \"line-clamp-6\",\n} as const;\n\nexport function MessageBubbleCollapsible({\n open,\n defaultOpen = false,\n onOpenChange,\n collapsedLines = 4,\n moreLabel = \"Show more\",\n lessLabel = \"Show less\",\n contentClassName,\n triggerClassName,\n className,\n children,\n ...props\n}: MessageBubbleCollapsibleProps) {\n const reduce = useReducedMotion() ?? false;\n const contentId = useId();\n const notifyLayout = useContext(MessageBubbleLayoutContext);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const currentOpen = open ?? internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n notifyLayout();\n if (open === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [notifyLayout, onOpenChange, open],\n );\n\n return (\n <div\n data-slot=\"message-bubble-collapsible\"\n data-state={currentOpen ? \"open\" : \"closed\"}\n className={cn(\"w-full\", className)}\n {...props}\n >\n <div\n id={contentId}\n className={cn(\n \"transition-[mask-image] duration-200\",\n !currentOpen && LINE_CLAMP_CLASS[collapsedLines],\n !currentOpen && \"mask-[linear-gradient(to_bottom,#000_68%,transparent_100%)]\",\n contentClassName,\n )}\n >\n {children}\n </div>\n <button\n type=\"button\"\n aria-expanded={currentOpen}\n aria-controls={contentId}\n onClick={() => setOpen(!currentOpen)}\n className={cn(\n \"mt-2 inline-flex h-7 items-center gap-1 rounded-full px-2 font-medium text-muted-foreground text-xs outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\",\n triggerClassName,\n )}\n >\n <span>{currentOpen ? lessLabel : moreLabel}</span>\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotate: currentOpen ? 180 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n >\n <ChevronDown className=\"size-3.5\" />\n </motion.span>\n </button>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AA8BA,MAAM,uBAAuB,cAAyC;CACpE,WAAW;CACX,SAAS;AACX,CAAC;AACD,MAAM,6BAA6B,oBAAgC,CAAC,CAAC;AAgCrE,SAAS,UAAa,GAAG,MAAiC;CACxD,QAAQ,SAAmB;EACzB,KAAK,MAAM,OAAO,MAChB,IAAI,OAAO,QAAQ,YAAY,IAAI,IAAI;OAClC,IAAI,KAAK,IAAI,UAAU;CAEhC;AACF;AAEA,MAAM,wBAAwB;CAC5B,UAAU;CACV,MAAM;CACN,OAAO;AACT;AAGA,MAAM,aAAa;CACjB,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,SAAgB,cAAc,EAC5B,UAAU,QACV,OACA,YAAY,OACZ,WACA,UACA,SACA,SACA,MACA,YACA,QACA,GAAG,SACkB;CACrB,MAAM,SAAS,iBAAiB,KAAK;CACrC,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,gBAAgB,SAAS,eAAe;CAE9C,OACE,oBAAC,qBAAqB,UAAtB;EAA+B,OAAO;GAAE,OAAO;GAAe;GAAW;EAAQ;EAC/E,UAAA,oBAAC,OAAO,KAAR;GACE,aAAU;GACV,cAAY;GACZ,gBAAc;GACN;GACR,SAAS,WAAW;GACX;GACT,MAAM,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;IAAE,SAAS;IAAG,GAAG;IAAI,OAAO;GAAK;GAC1E,YAAY,eAAe,SAAS,EAAE,UAAU,IAAK,IAAI;GACzD,WAAW,GACT,qCACA,kBAAkB,QAAQ,cAAc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AY,cAAc,SAAS;EACnC,WAAW,GAAG,UAAU,SAAS;EACjC,GAAI;EAJN,UAAA,CAME,oBAAC,OAAD;GACE,IAAI;GACJ,WAAW,GACT,wCACA,CAAC,eAAe,iBAAiB,iBACjC,CAAC,eAAe,+DAChB,gBACF;GAEC;EACE,CAAA,GACL,qBAAC,UAAD;GACE,MAAK;GACL,iBAAe;GACf,iBAAe;GACf,eAAe,QAAQ,CAAC,WAAW;GACnC,WAAW,GACT,wNACA,gBACF;GARF,UAAA,CAUE,oBAAC,QAAD,EAAA,UAAO,cAAc,YAAY,UAAgB,CAAA,GACjD,oBAAC,OAAO,MAAR;IACE,eAAY;IACZ,SAAS,EAAE,QAAQ,cAAc,MAAM,EAAE;IACzC,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;IAEvC,UAAA,oBAAC,aAAD,EAAa,WAAU,WAAY,CAAA;GACxB,CAAA,CACP;EACL,CAAA,CAAA;;AAET"}
|
|
1
|
+
{"version":3,"file":"message-bubble.js","names":[],"sources":["../../../src/components/agents/message-bubble.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentPropsWithRef,\n cloneElement,\n createContext,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useContext,\n useId,\n useState,\n} from \"react\";\nimport { ChevronDown } from \"lucide-react\";\nimport { type HTMLMotionProps, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from \"../../lib/ease\";\nimport { MessageSideContext } from \"./message-context\";\n\nexport type MessageBubbleVariant = \"solid\" | \"soft\" | \"tint\" | \"outline\" | \"ghost\" | \"danger\";\nexport type MessageBubbleAlign = \"start\" | \"end\";\n\ninterface MessageBubbleContextValue {\n align?: MessageBubbleAlign;\n animateIn: boolean;\n variant: MessageBubbleVariant;\n}\n\nconst MessageBubbleContext = createContext<MessageBubbleContextValue>({\n animateIn: true,\n variant: \"soft\",\n});\nconst MessageBubbleLayoutContext = createContext<() => void>(() => {});\n\nexport interface MessageBubbleProps extends Omit<HTMLMotionProps<\"div\">, \"children\"> {\n variant?: MessageBubbleVariant;\n /** Defaults to the surrounding Message alignment when omitted. */\n align?: MessageBubbleAlign;\n /** Plays the bubble entrance once when this component mounts. */\n animateIn?: boolean;\n children?: ReactNode;\n}\n\nexport interface MessageBubbleContentProps extends ComponentPropsWithRef<\"div\"> {\n /** Replaces the content element while preserving bubble styling. */\n render?: ReactElement;\n}\n\nexport interface MessageBubbleGroupProps extends ComponentPropsWithRef<\"div\"> {\n spacing?: \"compact\" | \"default\";\n}\n\nexport interface MessageBubbleCollapsibleProps extends ComponentPropsWithRef<\"div\"> {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n collapsedLines?: 2 | 3 | 4 | 5 | 6;\n moreLabel?: ReactNode;\n lessLabel?: ReactNode;\n contentClassName?: string;\n triggerClassName?: string;\n children?: ReactNode;\n}\n\nfunction mergeRefs<T>(...refs: Array<Ref<T> | undefined>) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }\n };\n}\n\nconst BUBBLE_CONTENT_REVEAL = {\n duration: 0.12,\n ease: EASE_OUT,\n delay: 0.04,\n} as const;\n\n// Sent bubbles should pop into place quickly with one restrained overshoot.\nconst BUBBLE_POP = {\n type: \"spring\",\n stiffness: 520,\n damping: 27,\n mass: 0.52,\n} as const;\n\nexport function MessageBubble({\n variant = \"soft\",\n align,\n animateIn = false,\n className,\n children,\n initial,\n animate,\n exit,\n transition,\n layout,\n ...props\n}: MessageBubbleProps) {\n const reduce = useReducedMotion() ?? false;\n const messageSide = useContext(MessageSideContext);\n const resolvedAlign = align ?? messageSide ?? \"start\";\n\n return (\n <MessageBubbleContext.Provider value={{ align: resolvedAlign, animateIn, variant }}>\n <motion.div\n data-slot=\"message-bubble\"\n data-align={resolvedAlign}\n data-variant={variant}\n layout={layout}\n initial={initial ?? false}\n animate={animate}\n exit={exit ?? (reduce ? { opacity: 0 } : { opacity: 0, y: -3, scale: 0.99 })}\n transition={transition ?? (reduce ? { duration: 0.12 } : SPRING_LAYOUT)}\n className={cn(\n \"group/bubble flex w-full flex-col\",\n resolvedAlign === \"end\" ? \"items-end\" : \"items-start\",\n className,\n )}\n {...props}\n >\n {children}\n </motion.div>\n </MessageBubbleContext.Provider>\n );\n}\n\nfunction bubbleContentClass(variant: MessageBubbleVariant, interactive: boolean) {\n return cn(\n \"relative z-0 min-w-9 max-w-[82%] rounded-2xl px-3.5 py-2.5 text-foreground text-sm leading-6\",\n \"[&_a]:font-medium [&_a]:underline [&_a]:underline-offset-4 [&_code]:rounded [&_code]:bg-background/60 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em] [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p+p]:mt-2 [&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-xl [&_pre]:bg-background/60 [&_pre]:p-3 [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5\",\n variant === \"solid\" && \"text-background\",\n variant === \"ghost\" && \"w-full max-w-none rounded-none px-0 py-0\",\n variant === \"danger\" && \"text-destructive\",\n interactive &&\n \"cursor-pointer text-left outline-none transition-[background-color,color,transform] duration-150 hover:brightness-[0.98] focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.99]\",\n );\n}\n\nfunction bubbleSurfaceClass(variant: MessageBubbleVariant, align: MessageBubbleAlign) {\n return cn(\n \"pointer-events-none absolute inset-0 -z-10 rounded-[inherit]\",\n align === \"end\" ? \"origin-bottom-right\" : \"origin-bottom-left\",\n variant === \"solid\" && \"bg-foreground\",\n variant === \"soft\" && \"bg-muted\",\n variant === \"tint\" && \"bg-primary/10\",\n variant === \"outline\" && \"border border-border/70 bg-background\",\n variant === \"danger\" && \"bg-destructive/10\",\n );\n}\n\nexport function MessageBubbleContent({\n render,\n className,\n children,\n ref,\n ...props\n}: MessageBubbleContentProps) {\n const reduce = useReducedMotion() ?? false;\n const { align = \"start\", animateIn, variant } = useContext(MessageBubbleContext);\n const [layoutVersion, setLayoutVersion] = useState(0);\n const notifyLayout = useCallback(() => setLayoutVersion((version) => version + 1), []);\n const interactive = render?.type === \"button\" || render?.type === \"a\";\n const classes = cn(bubbleContentClass(variant, interactive), className);\n const composedChildren = (\n <>\n {variant !== \"ghost\" ? (\n <motion.span\n aria-hidden=\"true\"\n layout={reduce ? false : \"size\"}\n layoutDependency={layoutVersion}\n initial={\n animateIn && !reduce\n ? {\n opacity: 0,\n scale: 0.92,\n }\n : false\n }\n animate={{ opacity: 1, scale: 1 }}\n transition={\n reduce\n ? { duration: 0 }\n : {\n opacity: { duration: 0.12, ease: EASE_OUT },\n scale: BUBBLE_POP,\n layout: SPRING_LAYOUT,\n }\n }\n className={bubbleSurfaceClass(variant, align)}\n />\n ) : null}\n <MessageBubbleLayoutContext.Provider value={notifyLayout}>\n <motion.div\n initial={animateIn ? (reduce ? { opacity: 0 } : { opacity: 0 }) : false}\n animate={{ opacity: 1 }}\n transition={reduce ? { duration: 0.12, ease: EASE_OUT } : BUBBLE_CONTENT_REVEAL}\n className=\"relative\"\n >\n {children}\n </motion.div>\n </MessageBubbleLayoutContext.Provider>\n </>\n );\n\n if (render) {\n const child = render as ReactElement<\n Record<string, unknown> & { className?: string; ref?: Ref<HTMLElement> }\n >;\n\n return cloneElement(child, {\n ...props,\n ref: mergeRefs(child.props.ref, ref as Ref<HTMLElement> | undefined),\n className: cn(classes, child.props.className),\n children: composedChildren,\n \"data-slot\": \"message-bubble-content\",\n });\n }\n\n return (\n <div ref={ref} data-slot=\"message-bubble-content\" className={classes} {...props}>\n {composedChildren}\n </div>\n );\n}\n\nexport function MessageBubbleGroup({\n spacing = \"compact\",\n className,\n ...props\n}: MessageBubbleGroupProps) {\n return (\n <div\n data-slot=\"message-bubble-group\"\n className={cn(\"flex w-full flex-col\", spacing === \"compact\" ? \"gap-1.5\" : \"gap-3\", className)}\n {...props}\n />\n );\n}\n\nconst LINE_CLAMP_CLASS = {\n 2: \"line-clamp-2\",\n 3: \"line-clamp-3\",\n 4: \"line-clamp-4\",\n 5: \"line-clamp-5\",\n 6: \"line-clamp-6\",\n} as const;\n\nexport function MessageBubbleCollapsible({\n open,\n defaultOpen = false,\n onOpenChange,\n collapsedLines = 4,\n moreLabel = \"Show more\",\n lessLabel = \"Show less\",\n contentClassName,\n triggerClassName,\n className,\n children,\n ...props\n}: MessageBubbleCollapsibleProps) {\n const reduce = useReducedMotion() ?? false;\n const contentId = useId();\n const notifyLayout = useContext(MessageBubbleLayoutContext);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const currentOpen = open ?? internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n notifyLayout();\n if (open === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [notifyLayout, onOpenChange, open],\n );\n\n return (\n <div\n data-slot=\"message-bubble-collapsible\"\n data-state={currentOpen ? \"open\" : \"closed\"}\n className={cn(\"w-full\", className)}\n {...props}\n >\n <div\n id={contentId}\n className={cn(\n \"transition-[mask-image] duration-200\",\n !currentOpen && LINE_CLAMP_CLASS[collapsedLines],\n !currentOpen && \"mask-[linear-gradient(to_bottom,#000_68%,transparent_100%)]\",\n contentClassName,\n )}\n >\n {children}\n </div>\n <button\n type=\"button\"\n aria-expanded={currentOpen}\n aria-controls={contentId}\n onClick={() => setOpen(!currentOpen)}\n className={cn(\n \"mt-2 inline-flex h-7 items-center gap-1 rounded-full px-2 font-medium text-muted-foreground text-xs outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\",\n triggerClassName,\n )}\n >\n <span>{currentOpen ? lessLabel : moreLabel}</span>\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotate: currentOpen ? 180 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n >\n <ChevronDown className=\"size-3.5\" />\n </motion.span>\n </button>\n </div>\n );\n}\n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,WAAW;GACnC,WAAW,GACT,wNACA,gBACF;GARF,UAAA,CAUE,oBAAC,QAAD,EAAA,UAAO,cAAc,YAAY,UAAgB,CAAA,GACjD,oBAAC,OAAO,MAAR;IACE,eAAY;IACZ,SAAS,EAAE,QAAQ,cAAc,MAAM,EAAE;IACzC,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;IAEvC,UAAA,oBAAC,aAAD,EAAa,WAAU,WAAY,CAAA;GACxB,CAAA,CACP;EACL,CAAA,CAAA;;AAET"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { PreviewRail } from "../motion/preview-rail.js";
|
|
3
3
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
4
|
-
import { cn } from "
|
|
4
|
+
import { cn } from "@kumix/utils";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { useReducedMotion } from "motion/react";
|
|
7
7
|
//#region src/components/agents/message-scroller.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-scroller.js","names":[],"sources":["../../../src/components/agents/message-scroller.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentPropsWithRef,\n type Ref,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { cn } from \"cn\";\nimport { useReducedMotion } from \"motion/react\";\n\nimport { PreviewRail, type PreviewRailItem } from \"../motion/preview-rail\";\n\nconst PREVIEW_TITLE_LENGTH = 56;\nconst PREVIEW_DESCRIPTION_LENGTH = 88;\n\nfunction truncateMessageText(text: string, limit: number) {\n if (text.length <= limit) return text;\n const excerpt = text.slice(0, limit);\n const boundary = excerpt.lastIndexOf(\" \");\n return `${excerpt.slice(0, boundary > limit * 0.65 ? boundary : limit).trim()}…`;\n}\n\nfunction getMessageText(message: HTMLElement) {\n const surface =\n message.querySelector<HTMLElement>('[data-slot=\"message-bubble-content\"]') ??\n message.querySelector<HTMLElement>('[data-slot=\"message-content\"]') ??\n message;\n return (surface.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\n}\n\nfunction getMessagePreview(message: HTMLElement, assistantResponse?: HTMLElement) {\n const text = getMessageText(message);\n if (!text) {\n return { label: \"Message\", description: undefined };\n }\n\n if (text.length <= PREVIEW_TITLE_LENGTH) {\n const responseText = assistantResponse ? getMessageText(assistantResponse) : \"\";\n return {\n label: text,\n description: responseText\n ? truncateMessageText(responseText, PREVIEW_DESCRIPTION_LENGTH)\n : undefined,\n };\n }\n\n const titleExcerpt = text.slice(0, PREVIEW_TITLE_LENGTH);\n const titleBoundary = titleExcerpt.lastIndexOf(\" \");\n const titleEnd =\n titleBoundary > PREVIEW_TITLE_LENGTH * 0.65 ? titleBoundary : PREVIEW_TITLE_LENGTH;\n const label = `${text.slice(0, titleEnd).trim()}…`;\n const responseText = assistantResponse\n ? getMessageText(assistantResponse)\n : text.slice(titleEnd).trim();\n return {\n label,\n description: responseText\n ? truncateMessageText(responseText, PREVIEW_DESCRIPTION_LENGTH)\n : undefined,\n };\n}\n\nexport interface MessageScrollerProps extends ComponentPropsWithRef<\"div\"> {\n /** Keep streamed output pinned while the reader remains near the end. */\n followOutput?: boolean;\n /** Distance from the end that still counts as following the output. */\n followThreshold?: number;\n /** Smoothly follow growing content. */\n smooth?: boolean;\n /** Reports when the reader leaves or returns to the live edge. */\n onFollowChange?: (following: boolean) => void;\n /** Accessible label for the scrollable transcript. */\n label?: string;\n /** Marks the transcript as waiting for more streamed content. */\n busy?: boolean;\n /** Adds a compact rail for navigating between rendered Message rows. */\n navigation?: \"rail\";\n /** Accessible label for the optional message navigation rail. */\n navigationLabel?: string;\n viewportClassName?: string;\n contentClassName?: string;\n railClassName?: string;\n viewportRef?: Ref<HTMLElement>;\n viewportProps?: Omit<ComponentPropsWithRef<\"section\">, \"children\" | \"className\" | \"ref\">;\n contentProps?: Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"className\" | \"ref\">;\n}\n\nexport function MessageScroller({\n followOutput = true,\n followThreshold = 56,\n smooth = true,\n onFollowChange,\n label = \"Conversation\",\n busy,\n navigation,\n navigationLabel = \"Message navigation\",\n viewportClassName,\n contentClassName,\n railClassName,\n viewportRef: externalViewportRef,\n viewportProps,\n contentProps,\n className,\n children,\n ...props\n}: MessageScrollerProps) {\n const reduce = useReducedMotion() ?? false;\n const viewportRef = useRef<HTMLElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const followingRef = useRef(followOutput);\n const programmaticScrollRef = useRef(false);\n const scrollTimerRef = useRef<number | undefined>(undefined);\n const frameRef = useRef<number | undefined>(undefined);\n const railFrameRef = useRef<number | undefined>(undefined);\n const railIdRef = useRef(new WeakMap<HTMLElement, string>());\n const railIdCounterRef = useRef(0);\n const railTargetsRef = useRef(new Map<string, HTMLElement>());\n const [railItems, setRailItems] = useState<PreviewRailItem[]>([]);\n const [activeRailId, setActiveRailId] = useState(\"\");\n const [railOverflowing, setRailOverflowing] = useState(false);\n const {\n onScroll: onViewportScroll,\n onWheel: onViewportWheel,\n onTouchStart: onViewportTouchStart,\n onKeyDown: onViewportKeyDown,\n ...restViewportProps\n } = viewportProps ?? {};\n\n const setViewportRef = useCallback(\n (node: HTMLElement | null) => {\n viewportRef.current = node;\n if (typeof externalViewportRef === \"function\") {\n externalViewportRef(node);\n } else if (externalViewportRef) {\n externalViewportRef.current = node;\n }\n },\n [externalViewportRef],\n );\n\n const setFollowing = useCallback(\n (next: boolean) => {\n if (followingRef.current === next) return;\n followingRef.current = next;\n onFollowChange?.(next);\n },\n [onFollowChange],\n );\n\n const updateActiveRailItem = useCallback(() => {\n if (navigation !== \"rail\") return;\n const viewport = viewportRef.current;\n const targets = [...railTargetsRef.current.entries()];\n if (!viewport || targets.length === 0) return;\n\n const viewportRect = viewport.getBoundingClientRect();\n if (viewport.scrollTop <= followThreshold) {\n const firstId = targets[0]?.[0] ?? \"\";\n setActiveRailId((current) => (current === firstId ? current : firstId));\n return;\n }\n\n const distanceFromEnd = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight;\n if (distanceFromEnd <= followThreshold) {\n const lastId = targets.at(-1)?.[0] ?? \"\";\n setActiveRailId((current) => (current === lastId ? current : lastId));\n return;\n }\n\n const viewportCenter = viewportRect.top + viewportRect.height / 2;\n let nearestId = targets[0]?.[0] ?? \"\";\n let nearestDistance = Number.POSITIVE_INFINITY;\n\n for (const [id, element] of targets) {\n const rect = element.getBoundingClientRect();\n const messageCenter = rect.top + rect.height / 2;\n const distance = Math.abs(messageCenter - viewportCenter);\n if (distance < nearestDistance) {\n nearestDistance = distance;\n nearestId = id;\n }\n }\n\n setActiveRailId((current) => (current === nearestId ? current : nearestId));\n }, [followThreshold, navigation]);\n\n const syncRailItems = useCallback(() => {\n if (navigation !== \"rail\") return;\n const content = contentRef.current;\n const viewport = viewportRef.current;\n if (!content || !viewport) return;\n\n const messages = Array.from(content.querySelectorAll<HTMLElement>('[data-slot=\"message\"]'));\n const targets = new Map<string, HTMLElement>();\n const nextItems = messages.map((message, index) => {\n let id = railIdRef.current.get(message);\n if (!id) {\n railIdCounterRef.current += 1;\n id = `message-rail-${railIdCounterRef.current}`;\n railIdRef.current.set(message, id);\n }\n targets.set(id, message);\n const sender = message.dataset.from ?? \"conversation\";\n const assistantResponse =\n sender === \"user\"\n ? messages.slice(index + 1).find((candidate) => candidate.dataset.from === \"assistant\")\n : undefined;\n const preview = getMessagePreview(message, assistantResponse);\n\n return {\n id,\n label: preview.label,\n description: preview.description,\n ariaLabel: `Go to ${sender} message ${index + 1} of ${messages.length}`,\n };\n });\n\n railTargetsRef.current = targets;\n setRailItems((current) => {\n const unchanged =\n current.length === nextItems.length &&\n current.every(\n (item, index) =>\n item.id === nextItems[index]?.id &&\n item.label === nextItems[index]?.label &&\n item.description === nextItems[index]?.description &&\n item.ariaLabel === nextItems[index]?.ariaLabel,\n );\n return unchanged ? current : nextItems;\n });\n setRailOverflowing(viewport.scrollHeight > viewport.clientHeight + 1 && messages.length > 1);\n }, [navigation]);\n\n const scheduleRailSync = useCallback(() => {\n if (navigation !== \"rail\") return;\n if (railFrameRef.current) cancelAnimationFrame(railFrameRef.current);\n railFrameRef.current = requestAnimationFrame(() => {\n syncRailItems();\n updateActiveRailItem();\n });\n }, [navigation, syncRailItems, updateActiveRailItem]);\n\n const scrollToEnd = useCallback((behavior: ScrollBehavior) => {\n const viewport = viewportRef.current;\n if (!viewport) return;\n\n programmaticScrollRef.current = true;\n if (typeof viewport.scrollTo === \"function\") {\n viewport.scrollTo({ top: viewport.scrollHeight, behavior });\n } else {\n viewport.scrollTop = viewport.scrollHeight;\n }\n if (scrollTimerRef.current) window.clearTimeout(scrollTimerRef.current);\n scrollTimerRef.current = window.setTimeout(\n () => {\n programmaticScrollRef.current = false;\n },\n behavior === \"smooth\" ? 320 : 0,\n );\n }, []);\n\n const handleScroll = useCallback(() => {\n const viewport = viewportRef.current;\n if (!viewport || programmaticScrollRef.current) return;\n\n const distance = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight;\n setFollowing(distance <= followThreshold);\n updateActiveRailItem();\n }, [followThreshold, setFollowing, updateActiveRailItem]);\n\n const leaveLiveEdge = useCallback(() => {\n programmaticScrollRef.current = false;\n }, []);\n\n useLayoutEffect(() => {\n followingRef.current = followOutput;\n if (!followOutput) return;\n\n frameRef.current = requestAnimationFrame(() => scrollToEnd(\"auto\"));\n return () => {\n if (frameRef.current) cancelAnimationFrame(frameRef.current);\n };\n }, [followOutput, scrollToEnd]);\n\n useEffect(() => {\n const content = contentRef.current;\n if (!content || typeof ResizeObserver === \"undefined\") return;\n\n const observer = new ResizeObserver(() => {\n scheduleRailSync();\n if (!followOutput || !followingRef.current) return;\n scrollToEnd(reduce || !smooth ? \"auto\" : \"smooth\");\n });\n observer.observe(content);\n\n return () => observer.disconnect();\n }, [followOutput, reduce, scheduleRailSync, scrollToEnd, smooth]);\n\n useEffect(() => {\n if (navigation !== \"rail\") {\n railTargetsRef.current.clear();\n setRailItems([]);\n setRailOverflowing(false);\n return;\n }\n\n const content = contentRef.current;\n const viewport = viewportRef.current;\n if (!content || !viewport) return;\n\n scheduleRailSync();\n const mutationObserver =\n typeof MutationObserver === \"undefined\" ? null : new MutationObserver(scheduleRailSync);\n mutationObserver?.observe(content, {\n childList: true,\n characterData: true,\n subtree: true,\n });\n\n const resizeObserver =\n typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(scheduleRailSync);\n resizeObserver?.observe(content);\n resizeObserver?.observe(viewport);\n\n return () => {\n mutationObserver?.disconnect();\n resizeObserver?.disconnect();\n };\n }, [navigation, scheduleRailSync]);\n\n useEffect(\n () => () => {\n if (scrollTimerRef.current) window.clearTimeout(scrollTimerRef.current);\n if (frameRef.current) cancelAnimationFrame(frameRef.current);\n if (railFrameRef.current) cancelAnimationFrame(railFrameRef.current);\n },\n [],\n );\n\n const scrollToRailItem = useCallback(\n (item: PreviewRailItem) => {\n const viewport = viewportRef.current;\n const target = railTargetsRef.current.get(item.id);\n if (!viewport || !target) return;\n\n const lastItem = railItems.at(-1)?.id === item.id;\n setActiveRailId(item.id);\n if (lastItem) {\n setFollowing(true);\n scrollToEnd(reduce || !smooth ? \"auto\" : \"smooth\");\n return;\n }\n\n setFollowing(false);\n programmaticScrollRef.current = true;\n const viewportRect = viewport.getBoundingClientRect();\n const targetRect = target.getBoundingClientRect();\n const top =\n viewport.scrollTop +\n targetRect.top -\n viewportRect.top -\n (viewport.clientHeight - targetRect.height) / 2;\n const behavior = reduce || !smooth ? \"auto\" : \"smooth\";\n\n if (typeof viewport.scrollTo === \"function\") {\n viewport.scrollTo({ top, behavior });\n } else {\n viewport.scrollTop = top;\n }\n if (scrollTimerRef.current) window.clearTimeout(scrollTimerRef.current);\n scrollTimerRef.current = window.setTimeout(\n () => {\n programmaticScrollRef.current = false;\n },\n behavior === \"smooth\" ? 320 : 0,\n );\n },\n [railItems, reduce, scrollToEnd, setFollowing, smooth],\n );\n\n const viewport = (\n <section\n ref={setViewportRef}\n aria-label={label}\n {...restViewportProps}\n onScroll={(event) => {\n handleScroll();\n onViewportScroll?.(event);\n }}\n onWheel={(event) => {\n leaveLiveEdge();\n onViewportWheel?.(event);\n }}\n onTouchStart={(event) => {\n leaveLiveEdge();\n onViewportTouchStart?.(event);\n }}\n onKeyDown={(event) => {\n if ([\"ArrowUp\", \"PageUp\", \"Home\"].includes(event.key)) {\n leaveLiveEdge();\n }\n onViewportKeyDown?.(event);\n }}\n className={cn(\n \"h-full overflow-y-auto overscroll-contain outline-none [overflow-anchor:none] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset\",\n navigation === \"rail\"\n ? \"[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\"\n : \"[scrollbar-gutter:stable]\",\n viewportClassName,\n navigation === \"rail\" && railOverflowing && \"pr-10\",\n )}\n >\n <div\n ref={contentRef}\n role=\"log\"\n aria-live=\"polite\"\n aria-relevant=\"additions text\"\n aria-busy={busy}\n className={contentClassName}\n {...contentProps}\n >\n {children}\n </div>\n </section>\n );\n\n return (\n <div data-slot=\"message-scroller\" className={cn(\"min-h-0\", className)} {...props}>\n {navigation === \"rail\" ? (\n <PreviewRail\n items={railOverflowing ? railItems : []}\n label={navigationLabel}\n activeId={activeRailId}\n onItemSelect={scrollToRailItem}\n previewSide=\"before\"\n highlightActive\n itemSize={14}\n className=\"h-full min-h-0 overflow-hidden\"\n previewContainerClassName=\"right-8 left-3\"\n previewClassName=\"mr-1 w-64 max-w-full [&_[data-slot=preview-rail-card]]:h-20 [&_[data-slot=preview-rail-card]]:overflow-hidden [&_[data-slot=preview-rail-card]]:p-3 [&_[data-slot=preview-rail-title]]:line-clamp-1 [&_[data-slot=preview-rail-title]]:text-xs [&_[data-slot=preview-rail-title]]:leading-4 [&_[data-slot=preview-rail-description]]:line-clamp-2 [&_[data-slot=preview-rail-description]]:text-xs [&_[data-slot=preview-rail-description]]:leading-4\"\n railClassName={cn(\n \"absolute inset-y-3 right-1 w-7 content-center py-1 [&_[data-slot=preview-rail-item]]:w-7 [&_[data-slot=preview-rail-item]]:justify-end [&_[data-slot=preview-rail-tick]]:h-px [&_[data-slot=preview-rail-tick]]:w-4 [&_[data-slot=preview-rail-tick]]:origin-right\",\n railOverflowing ? \"pointer-events-auto opacity-100\" : \"pointer-events-none opacity-0\",\n railClassName,\n )}\n >\n {viewport}\n </PreviewRail>\n ) : (\n viewport\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAgBA,MAAM,uBAAuB;AAC7B,MAAM,6BAA6B;AAEnC,SAAS,oBAAoB,MAAc,OAAe;CACxD,IAAI,KAAK,UAAU,OAAO,OAAO;CACjC,MAAM,UAAU,KAAK,MAAM,GAAG,KAAK;CACnC,MAAM,WAAW,QAAQ,YAAY,GAAG;CACxC,OAAO,GAAG,QAAQ,MAAM,GAAG,WAAW,QAAQ,MAAO,WAAW,KAAK,CAAC,CAAC,KAAK,EAAE;AAChF;AAEA,SAAS,eAAe,SAAsB;CAK5C,SAHE,QAAQ,cAA2B,wCAAsC,KACzE,QAAQ,cAA2B,iCAA+B,KAClE,QAAA,CACc,eAAe,GAAA,CAAI,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAK;AAC/D;AAEA,SAAS,kBAAkB,SAAsB,mBAAiC;CAChF,MAAM,OAAO,eAAe,OAAO;CACnC,IAAI,CAAC,MACH,OAAO;EAAE,OAAO;EAAW,aAAa,KAAA;CAAU;CAGpD,IAAI,KAAK,UAAU,sBAAsB;EACvC,MAAM,eAAe,oBAAoB,eAAe,iBAAiB,IAAI;EAC7E,OAAO;GACL,OAAO;GACP,aAAa,eACT,oBAAoB,cAAc,0BAA0B,IAC5D,KAAA;EACN;CACF;CAGA,MAAM,gBADe,KAAK,MAAM,GAAG,oBACF,CAAC,CAAC,YAAY,GAAG;CAClD,MAAM,WACJ,gBAAgB,uBAAuB,MAAO,gBAAgB;CAChE,MAAM,QAAQ,GAAG,KAAK,MAAM,GAAG,QAAQ,CAAC,CAAC,KAAK,EAAE;CAChD,MAAM,eAAe,oBAC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AAS,OAAO,aAAa,eAAe,OAAO;EACtE,eAAe,UAAU,OAAO,iBACxB;GACJ,sBAAsB,UAAU;EAClC,GACA,aAAa,WAAW,MAAM,CAChC;CACF,GACA;EAAC;EAAW;EAAQ;EAAa;EAAc;CAAM,CACvD;CAEA,MAAM,WACJ,oBAAC,WAAD;EACE,KAAK;EACL,cAAY;EACZ,GAAI;EACJ,WAAW,UAAU;GACnB,aAAa;GACb,mBAAmB,KAAK;EAC1B;EACA,UAAU,UAAU;GAClB,cAAc;GACd,kBAAkB,KAAK;EACzB;EACA,eAAe,UAAU;GACvB,cAAc;GACd,uBAAuB,KAAK;EAC9B;EACA,YAAY,UAAU;GACpB,IAAI;IAAC;IAAW;IAAU;GAAM,CAAC,CAAC,SAAS,MAAM,GAAG,GAClD,cAAc;GAEhB,oBAAoB,KAAK;EAC3B;EACA,WAAW,GACT,uJACA,eAAe,SACX,mFACA,6BACJ,mBACA,eAAe,UAAU,mBAAmB,OAC9C;EAEA,UAAA,oBAAC,OAAD;GACE,KAAK;GACL,MAAK;GACL,aAAU;GACV,iBAAc;GACd,aAAW;GACX,WAAW;GACX,GAAI;GAEH;EACE,CAAA;CACE,CAAA;CAGX,OACE,oBAAC,OAAD;EAAK,aAAU;EAAmB,WAAW,GAAG,WAAW,SAAS;EAAG,GAAI;EACxE,UAAA,eAAe,SACd,oBAAC,aAAD;GACE,OAAO,kBAAkB,YAAY,CAAC;GACtC,OAAO;GACP,UAAU;GACV,cAAc;GACd,aAAY;GACZ,iBAAA;GACA,UAAU;GACV,WAAU;GACV,2BAA0B;GAC1B,kBAAiB;GACjB,eAAe,GACb,sQACA,kBAAkB,oCAAoC,iCACtD,aACF;GAEC,UAAA;EACU,CAAA,IAEb;CAEC,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"message-scroller.js","names":[],"sources":["../../../src/components/agents/message-scroller.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentPropsWithRef,\n type Ref,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { PreviewRail, type PreviewRailItem } from \"../motion/preview-rail\";\n\nconst PREVIEW_TITLE_LENGTH = 56;\nconst PREVIEW_DESCRIPTION_LENGTH = 88;\n\nfunction truncateMessageText(text: string, limit: number) {\n if (text.length <= limit) return text;\n const excerpt = text.slice(0, limit);\n const boundary = excerpt.lastIndexOf(\" \");\n return `${excerpt.slice(0, boundary > limit * 0.65 ? boundary : limit).trim()}…`;\n}\n\nfunction getMessageText(message: HTMLElement) {\n const surface =\n message.querySelector<HTMLElement>('[data-slot=\"message-bubble-content\"]') ??\n message.querySelector<HTMLElement>('[data-slot=\"message-content\"]') ??\n message;\n return (surface.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\n}\n\nfunction getMessagePreview(message: HTMLElement, assistantResponse?: HTMLElement) {\n const text = getMessageText(message);\n if (!text) {\n return { label: \"Message\", description: undefined };\n }\n\n if (text.length <= PREVIEW_TITLE_LENGTH) {\n const responseText = assistantResponse ? getMessageText(assistantResponse) : \"\";\n return {\n label: text,\n description: responseText\n ? truncateMessageText(responseText, PREVIEW_DESCRIPTION_LENGTH)\n : undefined,\n };\n }\n\n const titleExcerpt = text.slice(0, PREVIEW_TITLE_LENGTH);\n const titleBoundary = titleExcerpt.lastIndexOf(\" \");\n const titleEnd =\n titleBoundary > PREVIEW_TITLE_LENGTH * 0.65 ? titleBoundary : PREVIEW_TITLE_LENGTH;\n const label = `${text.slice(0, titleEnd).trim()}…`;\n const responseText = assistantResponse\n ? getMessageText(assistantResponse)\n : text.slice(titleEnd).trim();\n return {\n label,\n description: responseText\n ? truncateMessageText(responseText, PREVIEW_DESCRIPTION_LENGTH)\n : undefined,\n };\n}\n\nexport interface MessageScrollerProps extends ComponentPropsWithRef<\"div\"> {\n /** Keep streamed output pinned while the reader remains near the end. */\n followOutput?: boolean;\n /** Distance from the end that still counts as following the output. */\n followThreshold?: number;\n /** Smoothly follow growing content. */\n smooth?: boolean;\n /** Reports when the reader leaves or returns to the live edge. */\n onFollowChange?: (following: boolean) => void;\n /** Accessible label for the scrollable transcript. */\n label?: string;\n /** Marks the transcript as waiting for more streamed content. */\n busy?: boolean;\n /** Adds a compact rail for navigating between rendered Message rows. */\n navigation?: \"rail\";\n /** Accessible label for the optional message navigation rail. */\n navigationLabel?: string;\n viewportClassName?: string;\n contentClassName?: string;\n railClassName?: string;\n viewportRef?: Ref<HTMLElement>;\n viewportProps?: Omit<ComponentPropsWithRef<\"section\">, \"children\" | \"className\" | \"ref\">;\n contentProps?: Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"className\" | \"ref\">;\n}\n\nexport function MessageScroller({\n followOutput = true,\n followThreshold = 56,\n smooth = true,\n onFollowChange,\n label = \"Conversation\",\n busy,\n navigation,\n navigationLabel = \"Message navigation\",\n viewportClassName,\n contentClassName,\n railClassName,\n viewportRef: externalViewportRef,\n viewportProps,\n contentProps,\n className,\n children,\n ...props\n}: MessageScrollerProps) {\n const reduce = useReducedMotion() ?? false;\n const viewportRef = useRef<HTMLElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const followingRef = useRef(followOutput);\n const programmaticScrollRef = useRef(false);\n const scrollTimerRef = useRef<number | undefined>(undefined);\n const frameRef = useRef<number | undefined>(undefined);\n const railFrameRef = useRef<number | undefined>(undefined);\n const railIdRef = useRef(new WeakMap<HTMLElement, string>());\n const railIdCounterRef = useRef(0);\n const railTargetsRef = useRef(new Map<string, HTMLElement>());\n const [railItems, setRailItems] = useState<PreviewRailItem[]>([]);\n const [activeRailId, setActiveRailId] = useState(\"\");\n const [railOverflowing, setRailOverflowing] = useState(false);\n const {\n onScroll: onViewportScroll,\n onWheel: onViewportWheel,\n onTouchStart: onViewportTouchStart,\n onKeyDown: onViewportKeyDown,\n ...restViewportProps\n } = viewportProps ?? {};\n\n const setViewportRef = useCallback(\n (node: HTMLElement | null) => {\n viewportRef.current = node;\n if (typeof externalViewportRef === \"function\") {\n externalViewportRef(node);\n } else if (externalViewportRef) {\n externalViewportRef.current = node;\n }\n },\n [externalViewportRef],\n );\n\n const setFollowing = useCallback(\n (next: boolean) => {\n if (followingRef.current === next) return;\n followingRef.current = next;\n onFollowChange?.(next);\n },\n [onFollowChange],\n );\n\n const updateActiveRailItem = useCallback(() => {\n if (navigation !== \"rail\") return;\n const viewport = viewportRef.current;\n const targets = [...railTargetsRef.current.entries()];\n if (!viewport || targets.length === 0) return;\n\n const viewportRect = viewport.getBoundingClientRect();\n if (viewport.scrollTop <= followThreshold) {\n const firstId = targets[0]?.[0] ?? \"\";\n setActiveRailId((current) => (current === firstId ? current : firstId));\n return;\n }\n\n const distanceFromEnd = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight;\n if (distanceFromEnd <= followThreshold) {\n const lastId = targets.at(-1)?.[0] ?? \"\";\n setActiveRailId((current) => (current === lastId ? current : lastId));\n return;\n }\n\n const viewportCenter = viewportRect.top + viewportRect.height / 2;\n let nearestId = targets[0]?.[0] ?? \"\";\n let nearestDistance = Number.POSITIVE_INFINITY;\n\n for (const [id, element] of targets) {\n const rect = element.getBoundingClientRect();\n const messageCenter = rect.top + rect.height / 2;\n const distance = Math.abs(messageCenter - viewportCenter);\n if (distance < nearestDistance) {\n nearestDistance = distance;\n nearestId = id;\n }\n }\n\n setActiveRailId((current) => (current === nearestId ? current : nearestId));\n }, [followThreshold, navigation]);\n\n const syncRailItems = useCallback(() => {\n if (navigation !== \"rail\") return;\n const content = contentRef.current;\n const viewport = viewportRef.current;\n if (!content || !viewport) return;\n\n const messages = Array.from(content.querySelectorAll<HTMLElement>('[data-slot=\"message\"]'));\n const targets = new Map<string, HTMLElement>();\n const nextItems = messages.map((message, index) => {\n let id = railIdRef.current.get(message);\n if (!id) {\n railIdCounterRef.current += 1;\n id = `message-rail-${railIdCounterRef.current}`;\n railIdRef.current.set(message, id);\n }\n targets.set(id, message);\n const sender = message.dataset.from ?? \"conversation\";\n const assistantResponse =\n sender === \"user\"\n ? messages.slice(index + 1).find((candidate) => candidate.dataset.from === \"assistant\")\n : undefined;\n const preview = getMessagePreview(message, assistantResponse);\n\n return {\n id,\n label: preview.label,\n description: preview.description,\n ariaLabel: `Go to ${sender} message ${index + 1} of ${messages.length}`,\n };\n });\n\n railTargetsRef.current = targets;\n setRailItems((current) => {\n const unchanged =\n current.length === nextItems.length &&\n current.every(\n (item, index) =>\n item.id === nextItems[index]?.id &&\n item.label === nextItems[index]?.label &&\n item.description === nextItems[index]?.description &&\n item.ariaLabel === nextItems[index]?.ariaLabel,\n );\n return unchanged ? current : nextItems;\n });\n setRailOverflowing(viewport.scrollHeight > viewport.clientHeight + 1 && messages.length > 1);\n }, [navigation]);\n\n const scheduleRailSync = useCallback(() => {\n if (navigation !== \"rail\") return;\n if (railFrameRef.current) cancelAnimationFrame(railFrameRef.current);\n railFrameRef.current = requestAnimationFrame(() => {\n syncRailItems();\n updateActiveRailItem();\n });\n }, [navigation, syncRailItems, updateActiveRailItem]);\n\n const scrollToEnd = useCallback((behavior: ScrollBehavior) => {\n const viewport = viewportRef.current;\n if (!viewport) return;\n\n programmaticScrollRef.current = true;\n if (typeof viewport.scrollTo === \"function\") {\n viewport.scrollTo({ top: viewport.scrollHeight, behavior });\n } else {\n viewport.scrollTop = viewport.scrollHeight;\n }\n if (scrollTimerRef.current) window.clearTimeout(scrollTimerRef.current);\n scrollTimerRef.current = window.setTimeout(\n () => {\n programmaticScrollRef.current = false;\n },\n behavior === \"smooth\" ? 320 : 0,\n );\n }, []);\n\n const handleScroll = useCallback(() => {\n const viewport = viewportRef.current;\n if (!viewport || programmaticScrollRef.current) return;\n\n const distance = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight;\n setFollowing(distance <= followThreshold);\n updateActiveRailItem();\n }, [followThreshold, setFollowing, updateActiveRailItem]);\n\n const leaveLiveEdge = useCallback(() => {\n programmaticScrollRef.current = false;\n }, []);\n\n useLayoutEffect(() => {\n followingRef.current = followOutput;\n if (!followOutput) return;\n\n frameRef.current = requestAnimationFrame(() => scrollToEnd(\"auto\"));\n return () => {\n if (frameRef.current) cancelAnimationFrame(frameRef.current);\n };\n }, [followOutput, scrollToEnd]);\n\n useEffect(() => {\n const content = contentRef.current;\n if (!content || typeof ResizeObserver === \"undefined\") return;\n\n const observer = new ResizeObserver(() => {\n scheduleRailSync();\n if (!followOutput || !followingRef.current) return;\n scrollToEnd(reduce || !smooth ? \"auto\" : \"smooth\");\n });\n observer.observe(content);\n\n return () => observer.disconnect();\n }, [followOutput, reduce, scheduleRailSync, scrollToEnd, smooth]);\n\n useEffect(() => {\n if (navigation !== \"rail\") {\n railTargetsRef.current.clear();\n setRailItems([]);\n setRailOverflowing(false);\n return;\n }\n\n const content = contentRef.current;\n const viewport = viewportRef.current;\n if (!content || !viewport) return;\n\n scheduleRailSync();\n const mutationObserver =\n typeof MutationObserver === \"undefined\" ? null : new MutationObserver(scheduleRailSync);\n mutationObserver?.observe(content, {\n childList: true,\n characterData: true,\n subtree: true,\n });\n\n const resizeObserver =\n typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(scheduleRailSync);\n resizeObserver?.observe(content);\n resizeObserver?.observe(viewport);\n\n return () => {\n mutationObserver?.disconnect();\n resizeObserver?.disconnect();\n };\n }, [navigation, scheduleRailSync]);\n\n useEffect(\n () => () => {\n if (scrollTimerRef.current) window.clearTimeout(scrollTimerRef.current);\n if (frameRef.current) cancelAnimationFrame(frameRef.current);\n if (railFrameRef.current) cancelAnimationFrame(railFrameRef.current);\n },\n [],\n );\n\n const scrollToRailItem = useCallback(\n (item: PreviewRailItem) => {\n const viewport = viewportRef.current;\n const target = railTargetsRef.current.get(item.id);\n if (!viewport || !target) return;\n\n const lastItem = railItems.at(-1)?.id === item.id;\n setActiveRailId(item.id);\n if (lastItem) {\n setFollowing(true);\n scrollToEnd(reduce || !smooth ? \"auto\" : \"smooth\");\n return;\n }\n\n setFollowing(false);\n programmaticScrollRef.current = true;\n const viewportRect = viewport.getBoundingClientRect();\n const targetRect = target.getBoundingClientRect();\n const top =\n viewport.scrollTop +\n targetRect.top -\n viewportRect.top -\n (viewport.clientHeight - targetRect.height) / 2;\n const behavior = reduce || !smooth ? \"auto\" : \"smooth\";\n\n if (typeof viewport.scrollTo === \"function\") {\n viewport.scrollTo({ top, behavior });\n } else {\n viewport.scrollTop = top;\n }\n if (scrollTimerRef.current) window.clearTimeout(scrollTimerRef.current);\n scrollTimerRef.current = window.setTimeout(\n () => {\n programmaticScrollRef.current = false;\n },\n behavior === \"smooth\" ? 320 : 0,\n );\n },\n [railItems, reduce, scrollToEnd, setFollowing, smooth],\n );\n\n const viewport = (\n <section\n ref={setViewportRef}\n aria-label={label}\n {...restViewportProps}\n onScroll={(event) => {\n handleScroll();\n onViewportScroll?.(event);\n }}\n onWheel={(event) => {\n leaveLiveEdge();\n onViewportWheel?.(event);\n }}\n onTouchStart={(event) => {\n leaveLiveEdge();\n onViewportTouchStart?.(event);\n }}\n onKeyDown={(event) => {\n if ([\"ArrowUp\", \"PageUp\", \"Home\"].includes(event.key)) {\n leaveLiveEdge();\n }\n onViewportKeyDown?.(event);\n }}\n className={cn(\n \"h-full overflow-y-auto overscroll-contain outline-none [overflow-anchor:none] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset\",\n navigation === \"rail\"\n ? \"[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\"\n : \"[scrollbar-gutter:stable]\",\n viewportClassName,\n navigation === \"rail\" && railOverflowing && \"pr-10\",\n )}\n >\n <div\n ref={contentRef}\n role=\"log\"\n aria-live=\"polite\"\n aria-relevant=\"additions text\"\n aria-busy={busy}\n className={contentClassName}\n {...contentProps}\n >\n {children}\n </div>\n </section>\n );\n\n return (\n <div data-slot=\"message-scroller\" className={cn(\"min-h-0\", className)} {...props}>\n {navigation === \"rail\" ? (\n <PreviewRail\n items={railOverflowing ? railItems : []}\n label={navigationLabel}\n activeId={activeRailId}\n onItemSelect={scrollToRailItem}\n previewSide=\"before\"\n highlightActive\n itemSize={14}\n className=\"h-full min-h-0 overflow-hidden\"\n previewContainerClassName=\"right-8 left-3\"\n previewClassName=\"mr-1 w-64 max-w-full [&_[data-slot=preview-rail-card]]:h-20 [&_[data-slot=preview-rail-card]]:overflow-hidden [&_[data-slot=preview-rail-card]]:p-3 [&_[data-slot=preview-rail-title]]:line-clamp-1 [&_[data-slot=preview-rail-title]]:text-xs [&_[data-slot=preview-rail-title]]:leading-4 [&_[data-slot=preview-rail-description]]:line-clamp-2 [&_[data-slot=preview-rail-description]]:text-xs [&_[data-slot=preview-rail-description]]:leading-4\"\n railClassName={cn(\n \"absolute inset-y-3 right-1 w-7 content-center py-1 [&_[data-slot=preview-rail-item]]:w-7 [&_[data-slot=preview-rail-item]]:justify-end [&_[data-slot=preview-rail-tick]]:h-px [&_[data-slot=preview-rail-tick]]:w-4 [&_[data-slot=preview-rail-tick]]:origin-right\",\n railOverflowing ? \"pointer-events-auto opacity-100\" : \"pointer-events-none opacity-0\",\n railClassName,\n )}\n >\n {viewport}\n </PreviewRail>\n ) : (\n viewport\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAgBA,MAAM,uBAAuB;AAC7B,MAAM,6BAA6B;AAEnC,SAAS,oBAAoB,MAAc,OAAe;CACxD,IAAI,KAAK,UAAU,OAAO,OAAO;CACjC,MAAM,UAAU,KAAK,MAAM,GAAG,KAAK;CACnC,MAAM,WAAW,QAAQ,YAAY,GAAG;CACxC,OAAO,GAAG,QAAQ,MAAM,GAAG,WAAW,QAAQ,MAAO,WAAW,KAAK,CAAC,CAAC,KAAK,EAAE;AAChF;AAEA,SAAS,eAAe,SAAsB;CAK5C,SAHE,QAAQ,cAA2B,wCAAsC,KACzE,QAAQ,cAA2B,iCAA+B,KAClE,QAAA,CACc,eAAe,GAAA,CAAI,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAK;AAC/D;AAEA,SAAS,kBAAkB,SAAsB,mBAAiC;CAChF,MAAM,O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mB,WAAW,GAAG,WAAW,SAAS;EAAG,GAAI;EACxE,UAAA,eAAe,SACd,oBAAC,aAAD;GACE,OAAO,kBAAkB,YAAY,CAAC;GACtC,OAAO;GACP,UAAU;GACV,cAAc;GACd,aAAY;GACZ,iBAAA;GACA,UAAU;GACV,WAAU;GACV,2BAA0B;GAC1B,kBAAiB;GACjB,eAAe,GACb,sQACA,kBAAkB,oCAAoC,iCACtD,aACF;GAEC,UAAA;EACU,CAAA,IAEb;CAEC,CAAA;AAET"}
|
|
@@ -4,7 +4,7 @@ import { MessageSideContext } from "./message-context.js";
|
|
|
4
4
|
import { MessageBubble, MessageBubbleCollapsible, MessageBubbleContent, MessageBubbleGroup } from "./message-bubble.js";
|
|
5
5
|
import { MessageScroller } from "./message-scroller.js";
|
|
6
6
|
import { createContext, useContext } from "react";
|
|
7
|
-
import { cn } from "
|
|
7
|
+
import { cn } from "@kumix/utils";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { motion, useReducedMotion } from "motion/react";
|
|
10
10
|
//#region src/components/agents/message.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","names":[],"sources":["../../../src/components/agents/message.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentPropsWithRef, createContext, type ReactNode, useContext } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"message.js","names":[],"sources":["../../../src/components/agents/message.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentPropsWithRef, createContext, type ReactNode, useContext } from \"react\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\nimport { MessageSideContext } from \"./message-context\";\n\nexport {\n MessageBubble,\n MessageBubbleCollapsible,\n MessageBubbleContent,\n MessageBubbleGroup,\n} from \"./message-bubble\";\nexport type { MessageScrollerProps } from \"./message-scroller\";\nexport { MessageScroller } from \"./message-scroller\";\n\nexport type MessageFrom = \"user\" | \"assistant\";\n\ninterface MessageContextValue {\n from: MessageFrom;\n}\n\nconst MessageContext = createContext<MessageContextValue>({\n from: \"assistant\",\n});\n\nexport interface MessageProps\n extends Omit<ComponentPropsWithRef<typeof motion.article>, \"children\"> {\n from: MessageFrom;\n /** Plays a trailing-edge pop-up once when this message row mounts. */\n animateIn?: boolean;\n children: ReactNode;\n}\n\nexport interface MessageGroupProps extends ComponentPropsWithRef<\"div\"> {\n spacing?: \"compact\" | \"default\";\n}\n\nexport interface MessageAvatarProps extends ComponentPropsWithRef<\"div\"> {\n /** Keep an empty avatar slot so grouped messages remain aligned. */\n placeholder?: boolean;\n}\n\nexport type MessageContentProps = ComponentPropsWithRef<\"div\">;\nexport type MessageHeaderProps = ComponentPropsWithRef<\"div\">;\nexport type MessageFooterProps = ComponentPropsWithRef<\"div\">;\n\nexport type MessageMarkerProps = ComponentPropsWithRef<\"div\">;\n\nexport interface MessageTypingProps extends ComponentPropsWithRef<\"span\"> {\n label?: string;\n}\n\n// A sent row should rise from the live edge without changing measured layout.\nconst MESSAGE_POP_UP = {\n type: \"spring\",\n stiffness: 480,\n damping: 32,\n mass: 0.62,\n} as const;\n\nexport function Message({\n from,\n animateIn = false,\n children,\n className,\n initial,\n animate,\n transition,\n exit,\n style,\n ...props\n}: MessageProps) {\n const reduce = useReducedMotion() ?? false;\n\n return (\n <MessageSideContext.Provider value={from === \"user\" ? \"end\" : \"start\"}>\n <MessageContext.Provider value={{ from }}>\n <motion.article\n data-slot=\"message\"\n data-from={from}\n aria-label={props[\"aria-label\"] ?? `${from} message`}\n initial={\n initial ??\n (animateIn && !reduce\n ? {\n opacity: 0,\n transform: \"translateY(8px) scale(0.95)\",\n }\n : false)\n }\n animate={\n animate ??\n (animateIn && !reduce\n ? {\n opacity: 1,\n transform: \"translateY(0px) scale(1)\",\n }\n : { opacity: 1 })\n }\n exit={\n exit ??\n (reduce\n ? { opacity: 0 }\n : {\n opacity: 0,\n transform: \"translateY(-3px) scale(0.99)\",\n })\n }\n transition={transition ?? (reduce ? { duration: 0.12 } : MESSAGE_POP_UP)}\n style={{\n transformOrigin: from === \"user\" ? \"100% 100%\" : \"0% 100%\",\n ...style,\n }}\n className={cn(\n \"group/message flex w-full items-start gap-2\",\n from === \"user\" ? \"flex-row-reverse\" : \"flex-row\",\n className,\n )}\n {...props}\n >\n {children}\n </motion.article>\n </MessageContext.Provider>\n </MessageSideContext.Provider>\n );\n}\n\nexport function MessageGroup({ spacing = \"compact\", className, ...props }: MessageGroupProps) {\n return (\n <div\n data-slot=\"message-group\"\n className={cn(\"flex w-full flex-col\", spacing === \"compact\" ? \"gap-1.5\" : \"gap-4\", className)}\n {...props}\n />\n );\n}\n\nexport function MessageAvatar({\n placeholder = false,\n children,\n className,\n ...props\n}: MessageAvatarProps) {\n return (\n <div\n data-slot=\"message-avatar\"\n aria-hidden={placeholder || undefined}\n className={cn(\n \"grid size-7 shrink-0 place-items-center overflow-hidden rounded-full bg-muted font-medium text-muted-foreground text-xs [&_img]:size-full [&_img]:object-cover [&_svg]:size-3.5\",\n placeholder && \"invisible\",\n className,\n )}\n {...props}\n >\n {children}\n </div>\n );\n}\n\nexport function MessageContent({ className, ...props }: MessageContentProps) {\n const { from } = useContext(MessageContext);\n\n return (\n <div\n data-slot=\"message-content\"\n className={cn(\n \"flex min-w-0 flex-1 flex-col gap-1.5\",\n from === \"user\" ? \"items-end\" : \"items-start\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport function MessageHeader({ className, ...props }: MessageHeaderProps) {\n const { from } = useContext(MessageContext);\n\n return (\n <div\n data-slot=\"message-header\"\n className={cn(\n \"flex items-center gap-1.5 px-1 text-[11px] text-muted-foreground leading-none\",\n from === \"user\" ? \"justify-end\" : \"justify-start\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport function MessageFooter({ className, ...props }: MessageFooterProps) {\n const { from } = useContext(MessageContext);\n\n return (\n <div\n data-slot=\"message-footer\"\n className={cn(\n \"flex min-h-5 items-center gap-1 px-1 text-[11px] text-muted-foreground\",\n from === \"user\" ? \"justify-end\" : \"justify-start\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport function MessageMarker({ className, ...props }: MessageMarkerProps) {\n return (\n <div\n data-slot=\"message-marker\"\n className={cn(\n \"mx-auto flex w-fit max-w-[88%] items-center gap-1.5 rounded-full bg-muted/70 px-2.5 py-1 text-center text-muted-foreground text-xs\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport function MessageTyping({ label = \"Responding\", className, ...props }: MessageTypingProps) {\n const reduce = useReducedMotion() ?? false;\n\n return (\n <span\n data-slot=\"message-typing\"\n className={cn(\"inline-flex h-5 items-center gap-1\", className)}\n {...props}\n >\n <span className=\"sr-only\">{label}</span>\n {[0, 1, 2].map((index) => (\n <motion.span\n key={index}\n aria-hidden=\"true\"\n className=\"size-1 rounded-full bg-current\"\n animate={reduce ? { opacity: 0.45 } : { opacity: [0.28, 0.85, 0.28], y: [0, -2, 0] }}\n transition={{\n duration: 1.05,\n ease: EASE_OUT,\n repeat: Number.POSITIVE_INFINITY,\n delay: index * 0.14,\n }}\n />\n ))}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;AAwBA,MAAM,iBAAiB,cAAmC,EACxD,MAAM,YACR,CAAC;AA8BD,MAAM,iBAAiB;CACrB,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,SAAgB,QAAQ,EACtB,MACA,YAAY,OACZ,UACA,WACA,SACA,SACA,YACA,MACA,OACA,GAAG,SACY;CACf,MAAM,SAAS,iBAAiB,KAAK;CAErC,OACE,oBAAC,mBAAmB,UAApB;EAA6B,OAAO,SAAS,SAAS,QAAQ;EAC5D,UAAA,oBAAC,eAAe,UAAhB;GAAyB,OAAO,EAAE,KAAK;GACrC,UAAA,oBAAC,OAAO,SAAR;IACE,aAAU;IACV,aAAW;IACX,cAAY,MAAM,iBAAiB,GAAG,KAAK;IAC3C,SACE,YACC,aAAa,CAAC,SACX;KACE,SAAS;KACT,WAAW;I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,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GACT,0EACA,SAAS,SAAS,gBAAgB,iBAClC,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAgB,cAAc,EAAE,WAAW,GAAG,SAA6B;CACzE,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GACT,sIACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAgB,cAAc,EAAE,QAAQ,cAAc,WAAW,GAAG,SAA6B;CAC/F,MAAM,SAAS,iBAAiB,KAAK;CAErC,OACE,qBAAC,QAAD;EACE,aAAU;EACV,WAAW,GAAG,sCAAsC,SAAS;EAC7D,GAAI;EAHN,UAAA,CAKE,oBAAC,QAAD;GAAM,WAAU;GAAW,UAAA;EAAY,CAAA,GACtC;GAAC;GAAG;GAAG;EAAC,CAAC,CAAC,KAAK,UACd,oBAAC,OAAO,MAAR;GAEE,eAAY;GACZ,WAAU;GACV,SAAS,SAAS,EAAE,SAAS,IAAK,IAAI;IAAE,SAAS;KAAC;KAAM;KAAM;IAAI;IAAG,GAAG;KAAC;KAAG;KAAI;IAAC;GAAE;GACnF,YAAY;IACV,UAAU;IACV,MAAM;IACN,QAAQ,OAAO;IACf,OAAO,QAAQ;GACjB;EACD,GAVM,KAUN,CACF,CACG;;AAEV"}
|
|
@@ -5,7 +5,7 @@ import { Button } from "../motion/button/base.js";
|
|
|
5
5
|
import "../motion/button/index.js";
|
|
6
6
|
import { Select, SelectContent, SelectItem, SelectTrigger } from "../motion/select.js";
|
|
7
7
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
8
|
-
import { cn } from "
|
|
8
|
+
import { cn } from "@kumix/utils";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
11
11
|
import { ArrowUp, Plus, Square } from "lucide-react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-input.js","names":[],"sources":["../../../src/components/agents/prompt-input.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type FormEvent,\n type KeyboardEvent,\n type ReactNode,\n type TextareaHTMLAttributes,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { cn } from \"cn\";\nimport { ArrowUp, Plus, Square } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { SPRING_SWAP } from \"../../lib/ease\";\nimport { Button } from \"../motion/button\";\nimport { MorphPopover, MorphPopoverContent, MorphPopoverTrigger } from \"../motion/popover-morph\";\nimport { Select, SelectContent, SelectItem, SelectTrigger } from \"../motion/select\";\n\nexport interface PromptModel {\n value: string;\n label: ReactNode;\n icon?: ReactNode;\n disabled?: boolean;\n}\n\nexport interface PromptAction {\n value: string;\n label: ReactNode;\n description?: ReactNode;\n icon?: ReactNode;\n disabled?: boolean;\n}\n\nexport interface PromptInputProps\n extends Omit<\n TextareaHTMLAttributes<HTMLTextAreaElement>,\n \"value\" | \"defaultValue\" | \"onChange\" | \"onSubmit\" | \"children\"\n > {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n models?: PromptModel[];\n model?: string;\n defaultModel?: string;\n onModelChange?: (model: string) => void;\n actions?: PromptAction[];\n onAction?: (action: string) => void;\n onSubmit?: (value: string, model?: string) => void | Promise<void>;\n loading?: boolean;\n onStop?: () => void;\n minRows?: number;\n maxRows?: number;\n leadingAction?: ReactNode;\n className?: string;\n}\n\nexport function PromptInput({\n value,\n defaultValue = \"\",\n onValueChange,\n models = [],\n model,\n defaultModel,\n onModelChange,\n actions = [],\n onAction,\n onSubmit,\n loading = false,\n onStop,\n minRows = 2,\n maxRows = 8,\n leadingAction,\n className,\n disabled,\n placeholder = \"Ask the agent to do something…\",\n \"aria-label\": ariaLabel = \"Prompt\",\n onKeyDown,\n ...textareaProps\n}: PromptInputProps) {\n const reduce = useReducedMotion() ?? false;\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const measurementRef = useRef<HTMLDivElement>(null);\n const [internalValue, setInternalValue] = useState(defaultValue);\n const [internalModel, setInternalModel] = useState(defaultModel ?? models[0]?.value);\n const [actionsOpen, setActionsOpen] = useState(false);\n const currentValue = value ?? internalValue;\n const currentModelValue = model ?? internalModel;\n const currentModel = models.find((option) => option.value === currentModelValue);\n const canSubmit = Boolean(currentValue.trim()) && !disabled && !loading;\n\n const resizeTextarea = useCallback(() => {\n const textarea = textareaRef.current;\n const measurement = measurementRef.current;\n if (!textarea || !measurement || textarea.value !== currentValue) return;\n\n const lineHeight = 24;\n const nextHeight = Math.min(\n Math.max(measurement.scrollHeight, minRows * lineHeight),\n maxRows * lineHeight,\n );\n const height = `${nextHeight}px`;\n if (textarea.style.height !== height) textarea.style.height = height;\n }, [currentValue, maxRows, minRows]);\n\n useLayoutEffect(() => {\n resizeTextarea();\n }, [resizeTextarea]);\n\n useEffect(() => {\n const textarea = textareaRef.current;\n if (!textarea || typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(resizeTextarea);\n observer.observe(textarea);\n return () => observer.disconnect();\n }, [resizeTextarea]);\n\n const setValue = (next: string) => {\n if (value === undefined) setInternalValue(next);\n onValueChange?.(next);\n };\n\n const setModel = (next: string) => {\n if (model === undefined) setInternalModel(next);\n onModelChange?.(next);\n };\n\n const submit = (event?: FormEvent) => {\n event?.preventDefault();\n const prompt = currentValue.trim();\n if (!prompt || disabled || loading) return;\n\n onSubmit?.(prompt, currentModelValue);\n if (value === undefined) setInternalValue(\"\");\n textareaRef.current?.focus({ preventScroll: true });\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {\n onKeyDown?.(event);\n if (\n event.defaultPrevented ||\n event.key !== \"Enter\" ||\n event.shiftKey ||\n event.nativeEvent.isComposing\n ) {\n return;\n }\n event.preventDefault();\n submit();\n };\n\n return (\n <form\n onSubmit={submit}\n className={cn(\n \"relative w-full rounded-2xl border border-border/80 bg-background p-2 transition-colors focus-within:border-foreground/25\",\n disabled && \"opacity-60\",\n className,\n )}\n >\n <div\n ref={measurementRef}\n aria-hidden=\"true\"\n className=\"wrap-break-word pointer-events-none invisible absolute inset-x-2 top-0 whitespace-pre-wrap px-2 text-sm leading-6\"\n >\n {`${currentValue}\\u200b`}\n </div>\n <textarea\n ref={textareaRef}\n value={currentValue}\n disabled={disabled}\n placeholder={placeholder}\n aria-label={ariaLabel}\n rows={minRows}\n {...textareaProps}\n onChange={(event) => setValue(event.target.value)}\n onKeyDown={handleKeyDown}\n className=\"scrollbar-hide block w-full resize-none overflow-y-auto bg-transparent px-2 pt-1.5 text-foreground text-sm leading-6 outline-none placeholder:text-muted-foreground/55\"\n />\n\n <div className=\"mt-1 flex min-h-8 items-center gap-1\">\n {actions.length ? (\n <MorphPopover open={actionsOpen} onOpenChange={setActionsOpen}>\n <MorphPopoverTrigger>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n disabled={disabled || loading}\n aria-label=\"Add to prompt\"\n className=\"size-8 rounded-full\"\n >\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotate: actionsOpen ? 45 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n >\n <Plus className=\"size-4\" />\n </motion.span>\n </Button>\n </MorphPopoverTrigger>\n\n <MorphPopoverContent\n side=\"top\"\n align=\"start\"\n sideOffset={8}\n radius={12}\n className=\"w-56 p-1.5\"\n >\n {actions.map((action) => (\n <button\n key={action.value}\n type=\"button\"\n disabled={action.disabled}\n onClick={() => {\n onAction?.(action.value);\n setActionsOpen(false);\n }}\n className=\"flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left outline-none transition-colors hover:bg-muted focus-visible:bg-muted disabled:pointer-events-none disabled:opacity-50\"\n >\n {action.icon ? (\n <span className=\"mt-0.5 grid size-5 shrink-0 place-items-center text-muted-foreground [&_svg]:size-4\">\n {action.icon}\n </span>\n ) : null}\n <span className=\"min-w-0\">\n <span className=\"block text-foreground text-sm\">{action.label}</span>\n {action.description ? (\n <span className=\"mt-0.5 block text-muted-foreground text-xs leading-4\">\n {action.description}\n </span>\n ) : null}\n </span>\n </button>\n ))}\n </MorphPopoverContent>\n </MorphPopover>\n ) : null}\n {leadingAction}\n {models.length ? (\n <Select\n value={currentModelValue}\n onValueChange={setModel}\n disabled={disabled || loading}\n className=\"min-w-0\"\n >\n <SelectTrigger className=\"h-8 w-auto max-w-52 rounded-xl border-0 bg-transparent px-2 py-0 text-xs hover:bg-muted focus-visible:ring-2\">\n <span className=\"flex min-w-0 items-center gap-1.5\">\n {currentModel?.icon ? (\n <span className=\"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5\">\n {currentModel.icon}\n </span>\n ) : null}\n <span className=\"truncate text-muted-foreground\">\n {currentModel?.label ?? \"Choose model\"}\n </span>\n </span>\n </SelectTrigger>\n <SelectContent className=\"right-auto w-52 shadow-none\">\n {models.map((option) => (\n <SelectItem\n key={option.value}\n value={option.value}\n disabled={option.disabled}\n className=\"py-2\"\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n {option.icon ? (\n <span className=\"grid size-5 shrink-0 place-items-center text-muted-foreground [&_svg]:size-4\">\n {option.icon}\n </span>\n ) : null}\n <span className=\"min-w-0 truncate text-foreground text-sm\">{option.label}</span>\n </span>\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n ) : null}\n\n <Button\n type={loading ? \"button\" : \"submit\"}\n size=\"icon\"\n disabled={loading ? !onStop : !canSubmit}\n aria-label={loading ? \"Stop generating\" : \"Send prompt\"}\n onClick={loading ? onStop : undefined}\n className=\"ml-auto size-8 rounded-full\"\n >\n <AnimatePresence initial={false} mode=\"popLayout\">\n <motion.span\n key={loading ? \"stop\" : \"send\"}\n initial={reduce ? { opacity: 1 } : { opacity: 0, y: 3, scale: 0.8 }}\n animate={{ opacity: 1, y: 0, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -3, scale: 0.8 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n className=\"grid place-items-center\"\n >\n {loading ? (\n <Square className=\"size-3 fill-current\" />\n ) : (\n <ArrowUp className=\"size-4\" />\n )}\n </motion.span>\n </AnimatePresence>\n </Button>\n </div>\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA4DA,SAAgB,YAAY,EAC1B,OACA,eAAe,IACf,eACA,SAAS,CAAC,GACV,OACA,cACA,eACA,UAAU,CAAC,GACX,UACA,UACA,UAAU,OACV,QACA,UAAU,GACV,UAAU,GACV,eACA,WACA,UACA,cAAc,kCACd,cAAc,YAAY,UAC1B,WACA,GAAG,iBACgB;CACnB,MAAM,SAAS,iBAAiB,KAAK;CACrC,MAAM,cAAc,OAA4B,IAAI;CACpD,MAAM,iBAAiB,OAAuB,IAAI;CAClD,MAAM,CAAC,eAAe,oBAAoB,SAAS,YAAY;CAC/D,MAAM,CAAC,eAAe,oBAAoB,SAAS,gBAAgB,OAAO,EAAE,EAAE,KAAK;CACnF,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CACpD,MAAM,eAAe,SAAS;CAC9B,MAAM,oBAAoB,SAAS;CACnC,MAAM,eAAe,OAAO,MAAM,WAAW,OAAO,UAAU,iBAAiB;CAC/E,MAAM,YAAY,QAAQ,aAAa,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC;CAEhE,MAAM,iBAAiB,kBAAkB;EACvC,MAAM,WAAW,YAAY;EAC7B,MAAM,cAAc,eAAe;EACnC,IAAI,CAAC,YAAY,CAAC,eAAe,SAAS,UAAU,cAAc;EAElE,MAAM,aAAa;EAKnB,MAAM,SAAS,GAJI,KAAK,IACtB,KAAK,IAAI,YAAY,cAAc,UAAU,UAAU,GACvD,UAAU,UAEe,EAAE;EAC7B,IAAI,SAAS,MAAM,WAAW,QAAQ,SAAS,MAAM,SAAS;CAChE,GAAG;EAAC;EAAc;EAAS;CAAO,CAAC;CAEnC,sBAAsB;EACpB,eAAe;CACjB,GAAG,CAAC,cAAc,CAAC;CAEn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f,oBAAC,eAAD;OAAe,WAAU;OACtB,UAAA,OAAO,KAAK,WACX,oBAAC,YAAD;QAEE,OAAO,OAAO;QACd,UAAU,OAAO;QACjB,WAAU;QAEV,UAAA,qBAAC,QAAD;SAAM,WAAU;SAAhB,UAAA,CACG,OAAO,OACN,oBAAC,QAAD;UAAM,WAAU;UACb,UAAA,OAAO;SACJ,CAAA,IACJ,MACJ,oBAAC,QAAD;UAAM,WAAU;UAA4C,UAAA,OAAO;SAAY,CAAA,CAC3E;;OACI,GAbL,OAAO,KAaF,CACb;MACY,CAAA,CACT;KACN,CAAA,IAAA;KAEJ,oBAAC,QAAD;MACE,MAAM,UAAU,WAAW;MAC3B,MAAK;MACL,UAAU,UAAU,CAAC,SAAS,CAAC;MAC/B,cAAY,UAAU,oBAAoB;MAC1C,SAAS,UAAU,SAAS,KAAA;MAC5B,WAAU;MAEV,UAAA,oBAAC,iBAAD;OAAiB,SAAS;OAAO,MAAK;OACpC,UAAA,oBAAC,OAAO,MAAR;QAEE,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;SAAE,SAAS;SAAG,GAAG;SAAG,OAAO;QAAI;QAClE,SAAS;SAAE,SAAS;SAAG,GAAG;SAAG,OAAO;QAAE;QACtC,MAAM,SAAS,EAAE,SAAS,EAAE,IAAI;SAAE,SAAS;SAAG,GAAG;SAAI,OAAO;QAAI;QAChE,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;QACvC,WAAU;QAET,UAAA,UACC,oBAAC,QAAD,EAAQ,WAAU,sBAAuB,CAAA,IAEzC,oBAAC,SAAD,EAAS,WAAU,SAAU,CAAA;OAEpB,GAZN,UAAU,SAAS,MAYb;MACE,CAAA;KACX,CAAA;IACL;;EACD;;AAEV"}
|
|
1
|
+
{"version":3,"file":"prompt-input.js","names":[],"sources":["../../../src/components/agents/prompt-input.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type FormEvent,\n type KeyboardEvent,\n type ReactNode,\n type TextareaHTMLAttributes,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { ArrowUp, Plus, Square } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_SWAP } from \"../../lib/ease\";\nimport { Button } from \"../motion/button\";\nimport { MorphPopover, MorphPopoverContent, MorphPopoverTrigger } from \"../motion/popover-morph\";\nimport { Select, SelectContent, SelectItem, SelectTrigger } from \"../motion/select\";\n\nexport interface PromptModel {\n value: string;\n label: ReactNode;\n icon?: ReactNode;\n disabled?: boolean;\n}\n\nexport interface PromptAction {\n value: string;\n label: ReactNode;\n description?: ReactNode;\n icon?: ReactNode;\n disabled?: boolean;\n}\n\nexport interface PromptInputProps\n extends Omit<\n TextareaHTMLAttributes<HTMLTextAreaElement>,\n \"value\" | \"defaultValue\" | \"onChange\" | \"onSubmit\" | \"children\"\n > {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n models?: PromptModel[];\n model?: string;\n defaultModel?: string;\n onModelChange?: (model: string) => void;\n actions?: PromptAction[];\n onAction?: (action: string) => void;\n onSubmit?: (value: string, model?: string) => void | Promise<void>;\n loading?: boolean;\n onStop?: () => void;\n minRows?: number;\n maxRows?: number;\n leadingAction?: ReactNode;\n className?: string;\n}\n\nexport function PromptInput({\n value,\n defaultValue = \"\",\n onValueChange,\n models = [],\n model,\n defaultModel,\n onModelChange,\n actions = [],\n onAction,\n onSubmit,\n loading = false,\n onStop,\n minRows = 2,\n maxRows = 8,\n leadingAction,\n className,\n disabled,\n placeholder = \"Ask the agent to do something…\",\n \"aria-label\": ariaLabel = \"Prompt\",\n onKeyDown,\n ...textareaProps\n}: PromptInputProps) {\n const reduce = useReducedMotion() ?? false;\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const measurementRef = useRef<HTMLDivElement>(null);\n const [internalValue, setInternalValue] = useState(defaultValue);\n const [internalModel, setInternalModel] = useState(defaultModel ?? models[0]?.value);\n const [actionsOpen, setActionsOpen] = useState(false);\n const currentValue = value ?? internalValue;\n const currentModelValue = model ?? internalModel;\n const currentModel = models.find((option) => option.value === currentModelValue);\n const canSubmit = Boolean(currentValue.trim()) && !disabled && !loading;\n\n const resizeTextarea = useCallback(() => {\n const textarea = textareaRef.current;\n const measurement = measurementRef.current;\n if (!textarea || !measurement || textarea.value !== currentValue) return;\n\n const lineHeight = 24;\n const nextHeight = Math.min(\n Math.max(measurement.scrollHeight, minRows * lineHeight),\n maxRows * lineHeight,\n );\n const height = `${nextHeight}px`;\n if (textarea.style.height !== height) textarea.style.height = height;\n }, [currentValue, maxRows, minRows]);\n\n useLayoutEffect(() => {\n resizeTextarea();\n }, [resizeTextarea]);\n\n useEffect(() => {\n const textarea = textareaRef.current;\n if (!textarea || typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(resizeTextarea);\n observer.observe(textarea);\n return () => observer.disconnect();\n }, [resizeTextarea]);\n\n const setValue = (next: string) => {\n if (value === undefined) setInternalValue(next);\n onValueChange?.(next);\n };\n\n const setModel = (next: string) => {\n if (model === undefined) setInternalModel(next);\n onModelChange?.(next);\n };\n\n const submit = (event?: FormEvent) => {\n event?.preventDefault();\n const prompt = currentValue.trim();\n if (!prompt || disabled || loading) return;\n\n onSubmit?.(prompt, currentModelValue);\n if (value === undefined) setInternalValue(\"\");\n textareaRef.current?.focus({ preventScroll: true });\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {\n onKeyDown?.(event);\n if (\n event.defaultPrevented ||\n event.key !== \"Enter\" ||\n event.shiftKey ||\n event.nativeEvent.isComposing\n ) {\n return;\n }\n event.preventDefault();\n submit();\n };\n\n return (\n <form\n onSubmit={submit}\n className={cn(\n \"relative w-full rounded-2xl border border-border/80 bg-background p-2 transition-colors focus-within:border-foreground/25\",\n disabled && \"opacity-60\",\n className,\n )}\n >\n <div\n ref={measurementRef}\n aria-hidden=\"true\"\n className=\"wrap-break-word pointer-events-none invisible absolute inset-x-2 top-0 whitespace-pre-wrap px-2 text-sm leading-6\"\n >\n {`${currentValue}\\u200b`}\n </div>\n <textarea\n ref={textareaRef}\n value={currentValue}\n disabled={disabled}\n placeholder={placeholder}\n aria-label={ariaLabel}\n rows={minRows}\n {...textareaProps}\n onChange={(event) => setValue(event.target.value)}\n onKeyDown={handleKeyDown}\n className=\"scrollbar-hide block w-full resize-none overflow-y-auto bg-transparent px-2 pt-1.5 text-foreground text-sm leading-6 outline-none placeholder:text-muted-foreground/55\"\n />\n\n <div className=\"mt-1 flex min-h-8 items-center gap-1\">\n {actions.length ? (\n <MorphPopover open={actionsOpen} onOpenChange={setActionsOpen}>\n <MorphPopoverTrigger>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n disabled={disabled || loading}\n aria-label=\"Add to prompt\"\n className=\"size-8 rounded-full\"\n >\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotate: actionsOpen ? 45 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n >\n <Plus className=\"size-4\" />\n </motion.span>\n </Button>\n </MorphPopoverTrigger>\n\n <MorphPopoverContent\n side=\"top\"\n align=\"start\"\n sideOffset={8}\n radius={12}\n className=\"w-56 p-1.5\"\n >\n {actions.map((action) => (\n <button\n key={action.value}\n type=\"button\"\n disabled={action.disabled}\n onClick={() => {\n onAction?.(action.value);\n setActionsOpen(false);\n }}\n className=\"flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left outline-none transition-colors hover:bg-muted focus-visible:bg-muted disabled:pointer-events-none disabled:opacity-50\"\n >\n {action.icon ? (\n <span className=\"mt-0.5 grid size-5 shrink-0 place-items-center text-muted-foreground [&_svg]:size-4\">\n {action.icon}\n </span>\n ) : null}\n <span className=\"min-w-0\">\n <span className=\"block text-foreground text-sm\">{action.label}</span>\n {action.description ? (\n <span className=\"mt-0.5 block text-muted-foreground text-xs leading-4\">\n {action.description}\n </span>\n ) : null}\n </span>\n </button>\n ))}\n </MorphPopoverContent>\n </MorphPopover>\n ) : null}\n {leadingAction}\n {models.length ? (\n <Select\n value={currentModelValue}\n onValueChange={setModel}\n disabled={disabled || loading}\n className=\"min-w-0\"\n >\n <SelectTrigger className=\"h-8 w-auto max-w-52 rounded-xl border-0 bg-transparent px-2 py-0 text-xs hover:bg-muted focus-visible:ring-2\">\n <span className=\"flex min-w-0 items-center gap-1.5\">\n {currentModel?.icon ? (\n <span className=\"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5\">\n {currentModel.icon}\n </span>\n ) : null}\n <span className=\"truncate text-muted-foreground\">\n {currentModel?.label ?? \"Choose model\"}\n </span>\n </span>\n </SelectTrigger>\n <SelectContent className=\"right-auto w-52 shadow-none\">\n {models.map((option) => (\n <SelectItem\n key={option.value}\n value={option.value}\n disabled={option.disabled}\n className=\"py-2\"\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n {option.icon ? (\n <span className=\"grid size-5 shrink-0 place-items-center text-muted-foreground [&_svg]:size-4\">\n {option.icon}\n </span>\n ) : null}\n <span className=\"min-w-0 truncate text-foreground text-sm\">{option.label}</span>\n </span>\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n ) : null}\n\n <Button\n type={loading ? \"button\" : \"submit\"}\n size=\"icon\"\n disabled={loading ? !onStop : !canSubmit}\n aria-label={loading ? \"Stop generating\" : \"Send prompt\"}\n onClick={loading ? onStop : undefined}\n className=\"ml-auto size-8 rounded-full\"\n >\n <AnimatePresence initial={false} mode=\"popLayout\">\n <motion.span\n key={loading ? \"stop\" : \"send\"}\n initial={reduce ? { opacity: 1 } : { opacity: 0, y: 3, scale: 0.8 }}\n animate={{ opacity: 1, y: 0, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -3, scale: 0.8 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n className=\"grid place-items-center\"\n >\n {loading ? (\n <Square className=\"size-3 fill-current\" />\n ) : (\n <ArrowUp className=\"size-4\" />\n )}\n </motion.span>\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;QAEV,UAAA,qBAAC,QAAD;SAAM,WAAU;SAAhB,UAAA,CACG,OAAO,OACN,oBAAC,QAAD;UAAM,WAAU;UACb,UAAA,OAAO;SACJ,CAAA,IACJ,MACJ,oBAAC,QAAD;UAAM,WAAU;UAA4C,UAAA,OAAO;SAAY,CAAA,CAC3E;;OACI,GAbL,OAAO,KAaF,CACb;MACY,CAAA,CACT;KACN,CAAA,IAAA;KAEJ,oBAAC,QAAD;MACE,MAAM,UAAU,WAAW;MAC3B,MAAK;MACL,UAAU,UAAU,CAAC,SAAS,CAAC;MAC/B,cAAY,UAAU,oBAAoB;MAC1C,SAAS,UAAU,SAAS,KAAA;MAC5B,WAAU;MAEV,UAAA,oBAAC,iBAAD;OAAiB,SAAS;OAAO,MAAK;OACpC,UAAA,oBAAC,OAAO,MAAR;QAEE,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;SAAE,SAAS;SAAG,GAAG;SAAG,OAAO;QAAI;QAClE,SAAS;SAAE,SAAS;SAAG,GAAG;SAAG,OAAO;QAAE;QACtC,MAAM,SAAS,EAAE,SAAS,EAAE,IAAI;SAAE,SAAS;SAAG,GAAG;SAAI,OAAO;QAAI;QAChE,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;QACvC,WAAU;QAET,UAAA,UACC,oBAAC,QAAD,EAAQ,WAAU,sBAAuB,CAAA,IAEzC,oBAAC,SAAD,EAAS,WAAU,SAAU,CAAA;OAEpB,GAZN,UAAU,SAAS,MAYb;MACE,CAAA;KACX,CAAA;IACL;;EACD;;AAEV"}
|
|
@@ -3,7 +3,7 @@ import { EASE_OUT, SPRING_PRESS, SPRING_SWAP } from "../../lib/ease.js";
|
|
|
3
3
|
import { AgentDisclosure } from "./agent-disclosure.js";
|
|
4
4
|
import { CitationList, CitationStack } from "./citations.js";
|
|
5
5
|
import { useCallback, useEffect, useId, useRef, useState } from "react";
|
|
6
|
-
import { cn } from "
|
|
6
|
+
import { cn } from "@kumix/utils";
|
|
7
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
9
9
|
import { Check, ChevronDown, Copy, RotateCcw, ThumbsDown, ThumbsUp } from "lucide-react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streaming-response.js","names":[],"sources":["../../../src/components/agents/streaming-response.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useEffect, useId, useRef, useState } from \"react\";\nimport { cn } from \"cn\";\nimport { Check, ChevronDown, Copy, RotateCcw, ThumbsDown, ThumbsUp } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { EASE_OUT, SPRING_PRESS, SPRING_SWAP } from \"../../lib/ease\";\nimport { AgentDisclosure } from \"./agent-disclosure\";\nimport { type CitationItem, CitationList, CitationStack } from \"./citations\";\n\nexport type StreamingResponseStatus = \"streaming\" | \"complete\" | \"error\";\nexport type StreamingResponseFeedback = \"up\" | \"down\" | null;\n\nexport interface StreamingResponseProps {\n /** Rendered response content. Pass plain text or the output of a Markdown renderer. */\n children: ReactNode;\n status?: StreamingResponseStatus;\n /** Plain-text value copied by the built-in copy action. */\n copyText?: string;\n /** Overrides the built-in clipboard action. */\n onCopy?: () => void | Promise<void>;\n onRetry?: () => void;\n /** Optional sources shown as a compact footer disclosure after streaming. */\n sources?: CitationItem[];\n sourcesOpen?: boolean;\n defaultSourcesOpen?: boolean;\n onSourcesOpenChange?: (open: boolean) => void;\n sourceIdPrefix?: string;\n feedback?: StreamingResponseFeedback;\n defaultFeedback?: StreamingResponseFeedback;\n onFeedbackChange?: (feedback: StreamingResponseFeedback) => void;\n /** Set false when a surrounding conversation log announces streamed text. */\n announce?: boolean;\n /** Hides the built-in completion actions without changing response status. */\n showActions?: boolean;\n className?: string;\n contentClassName?: string;\n actionsClassName?: string;\n}\n\nfunction ResponseAction({\n label,\n active = false,\n onClick,\n children,\n}: {\n label: string;\n active?: boolean;\n onClick: () => void;\n children: ReactNode;\n}) {\n const reduce = useReducedMotion() ?? false;\n\n return (\n <motion.button\n type=\"button\"\n aria-label={label}\n title={label}\n aria-pressed={label === \"Helpful\" || label === \"Not helpful\" ? active : undefined}\n onClick={onClick}\n whileTap={reduce ? undefined : { scale: 0.9 }}\n transition={SPRING_PRESS}\n className={cn(\n \"grid size-7 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\",\n active && \"bg-muted text-foreground\",\n )}\n >\n {children}\n </motion.button>\n );\n}\n\nexport function StreamingResponse({\n children,\n status = \"streaming\",\n copyText,\n onCopy,\n onRetry,\n sources = [],\n sourcesOpen,\n defaultSourcesOpen = false,\n onSourcesOpenChange,\n sourceIdPrefix,\n feedback,\n defaultFeedback = null,\n onFeedbackChange,\n announce = true,\n showActions = true,\n className,\n contentClassName,\n actionsClassName,\n}: StreamingResponseProps) {\n const reduce = useReducedMotion() ?? false;\n const baseId = useId();\n const [copied, setCopied] = useState(false);\n const [internalFeedback, setInternalFeedback] =\n useState<StreamingResponseFeedback>(defaultFeedback);\n const [internalSourcesOpen, setInternalSourcesOpen] = useState(defaultSourcesOpen);\n const copyTimer = useRef<number | undefined>(undefined);\n const currentFeedback = feedback ?? internalFeedback;\n const currentSourcesOpen = sourcesOpen ?? internalSourcesOpen;\n const streaming = status === \"streaming\";\n const complete = status === \"complete\";\n const canCopy = Boolean(copyText || onCopy);\n const hasSources = sources.length > 0;\n const shouldShowActions =\n showActions && !streaming && (canCopy || onRetry || complete || hasSources);\n const sourcesContentId = `${baseId}-sources`;\n const resolvedSourcePrefix = sourceIdPrefix ?? `response-source-${baseId.replace(/:/g, \"\")}`;\n\n useEffect(\n () => () => {\n if (copyTimer.current) window.clearTimeout(copyTimer.current);\n },\n [],\n );\n\n const handleCopy = useCallback(async () => {\n if (onCopy) await onCopy();\n else if (copyText) await navigator.clipboard?.writeText(copyText);\n\n setCopied(true);\n if (copyTimer.current) window.clearTimeout(copyTimer.current);\n copyTimer.current = window.setTimeout(() => setCopied(false), 1600);\n }, [copyText, onCopy]);\n\n const setFeedback = (next: Exclude<StreamingResponseFeedback, null>) => {\n const value = currentFeedback === next ? null : next;\n if (feedback === undefined) setInternalFeedback(value);\n onFeedbackChange?.(value);\n };\n\n const setSourcesOpen = useCallback(\n (next: boolean) => {\n if (sourcesOpen === undefined) setInternalSourcesOpen(next);\n onSourcesOpenChange?.(next);\n },\n [onSourcesOpenChange, sourcesOpen],\n );\n\n return (\n <div data-state={status} aria-busy={streaming} className={cn(\"w-full\", className)}>\n <div\n aria-live={announce ? \"polite\" : \"off\"}\n className={cn(\n \"text-foreground/90 text-sm leading-6 [&_a]:font-medium [&_a]:underline [&_a]:underline-offset-4 [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em] [&_ol]:my-3 [&_ol]:list-decimal [&_ol]:space-y-1 [&_ol]:pl-5 [&_p+p]:mt-3 [&_pre]:my-3 [&_pre]:overflow-x-auto [&_pre]:rounded-xl [&_pre]:border [&_pre]:border-border [&_pre]:bg-muted/45 [&_pre]:p-3 [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_ul]:my-3 [&_ul]:list-disc [&_ul]:space-y-1 [&_ul]:pl-5\",\n contentClassName,\n )}\n >\n {children}\n </div>\n\n <AnimatePresence initial={false}>\n {shouldShowActions ? (\n <motion.div\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 4 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0 }}\n transition={{ duration: reduce ? 0.12 : 0.22, ease: EASE_OUT }}\n className=\"mt-3\"\n >\n <div className={cn(\"flex items-center gap-0.5\", actionsClassName)}>\n {canCopy ? (\n <ResponseAction label={copied ? \"Copied\" : \"Copy response\"} onClick={handleCopy}>\n {copied ? <Check className=\"size-3.5\" /> : <Copy className=\"size-3.5\" />}\n </ResponseAction>\n ) : null}\n {onRetry ? (\n <ResponseAction label=\"Retry response\" onClick={onRetry}>\n <RotateCcw className=\"size-3.5\" />\n </ResponseAction>\n ) : null}\n {complete ? (\n <>\n <ResponseAction\n label=\"Helpful\"\n active={currentFeedback === \"up\"}\n onClick={() => setFeedback(\"up\")}\n >\n <ThumbsUp className=\"size-3.5\" />\n </ResponseAction>\n <ResponseAction\n label=\"Not helpful\"\n active={currentFeedback === \"down\"}\n onClick={() => setFeedback(\"down\")}\n >\n <ThumbsDown className=\"size-3.5\" />\n </ResponseAction>\n </>\n ) : null}\n {hasSources ? (\n <button\n type=\"button\"\n aria-expanded={currentSourcesOpen}\n aria-controls={sourcesContentId}\n onClick={() => setSourcesOpen(!currentSourcesOpen)}\n className=\"group ml-1 inline-flex min-h-7 items-center gap-2 rounded-md px-1.5 text-muted-foreground text-xs outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <CitationStack citations={sources} />\n <span className=\"tabular-nums\">\n {sources.length} {sources.length === 1 ? \"source\" : \"sources\"}\n </span>\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotate: currentSourcesOpen ? 180 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n className=\"text-muted-foreground/50 group-hover:text-muted-foreground\"\n >\n <ChevronDown className=\"size-3\" />\n </motion.span>\n </button>\n ) : null}\n </div>\n\n {hasSources ? (\n <AgentDisclosure id={sourcesContentId} open={currentSourcesOpen}>\n <CitationList\n citations={sources}\n idPrefix={resolvedSourcePrefix}\n className=\"mt-2 rounded-xl bg-muted p-2\"\n />\n </AgentDisclosure>\n ) : null}\n </motion.div>\n ) : null}\n </AnimatePresence>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAyCA,SAAS,eAAe,EACtB,OACA,SAAS,OACT,SACA,YAMC;CACD,MAAM,SAAS,iBAAiB,KAAK;CAErC,OACE,oBAAC,OAAO,QAAR;EACE,MAAK;EACL,cAAY;EACZ,OAAO;EACP,gBAAc,UAAU,aAAa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;OAE/B,UAAA,oBAAC,UAAD,EAAU,WAAU,WAAY,CAAA;MAClB,CAAA,GAChB,oBAAC,gBAAD;OACE,OAAM;OACN,QAAQ,oBAAoB;OAC5B,eAAe,YAAY,MAAM;OAEjC,UAAA,oBAAC,YAAD,EAAY,WAAU,WAAY,CAAA;MACpB,CAAA,CAChB,EAAA,CAAA,IACA;MACH,aACC,qBAAC,UAAD;OACE,MAAK;OACL,iBAAe;OACf,iBAAe;OACf,eAAe,eAAe,CAAC,kBAAkB;OACjD,WAAU;OALZ,UAAA;QAOE,oBAAC,eAAD,EAAe,WAAW,QAAU,CAAA;QACpC,qBAAC,QAAD;SAAM,WAAU;SAAhB,UAAA;UACG,QAAQ;UAAO;UAAE,QAAQ,WAAW,IAAI,WAAW;SAChD;;QACN,oBAAC,OAAO,MAAR;SACE,eAAY;SACZ,SAAS,EAAE,QAAQ,qBAAqB,MAAM,EAAE;SAChD,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;SACvC,WAAU;SAEV,UAAA,oBAAC,aAAD,EAAa,WAAU,SAAU,CAAA;QACtB,CAAA;OACP;MACN,CAAA,IAAA;KACD;IAEJ,CAAA,GAAA,aACC,oBAAC,iBAAD;KAAiB,IAAI;KAAkB,MAAM;KAC3C,UAAA,oBAAC,cAAD;MACE,WAAW;MACX,UAAU;MACV,WAAU;KACX,CAAA;IACc,CAAA,IACf,IACM;GACV,CAAA,IAAA;EACW,CAAA,CACd;;AAET"}
|
|
1
|
+
{"version":3,"file":"streaming-response.js","names":[],"sources":["../../../src/components/agents/streaming-response.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useEffect, useId, useRef, useState } from \"react\";\nimport { Check, ChevronDown, Copy, RotateCcw, ThumbsDown, ThumbsUp } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_PRESS, SPRING_SWAP } from \"../../lib/ease\";\nimport { AgentDisclosure } from \"./agent-disclosure\";\nimport { type CitationItem, CitationList, CitationStack } from \"./citations\";\n\nexport type StreamingResponseStatus = \"streaming\" | \"complete\" | \"error\";\nexport type StreamingResponseFeedback = \"up\" | \"down\" | null;\n\nexport interface StreamingResponseProps {\n /** Rendered response content. Pass plain text or the output of a Markdown renderer. */\n children: ReactNode;\n status?: StreamingResponseStatus;\n /** Plain-text value copied by the built-in copy action. */\n copyText?: string;\n /** Overrides the built-in clipboard action. */\n onCopy?: () => void | Promise<void>;\n onRetry?: () => void;\n /** Optional sources shown as a compact footer disclosure after streaming. */\n sources?: CitationItem[];\n sourcesOpen?: boolean;\n defaultSourcesOpen?: boolean;\n onSourcesOpenChange?: (open: boolean) => void;\n sourceIdPrefix?: string;\n feedback?: StreamingResponseFeedback;\n defaultFeedback?: StreamingResponseFeedback;\n onFeedbackChange?: (feedback: StreamingResponseFeedback) => void;\n /** Set false when a surrounding conversation log announces streamed text. */\n announce?: boolean;\n /** Hides the built-in completion actions without changing response status. */\n showActions?: boolean;\n className?: string;\n contentClassName?: string;\n actionsClassName?: string;\n}\n\nfunction ResponseAction({\n label,\n active = false,\n onClick,\n children,\n}: {\n label: string;\n active?: boolean;\n onClick: () => void;\n children: ReactNode;\n}) {\n const reduce = useReducedMotion() ?? false;\n\n return (\n <motion.button\n type=\"button\"\n aria-label={label}\n title={label}\n aria-pressed={label === \"Helpful\" || label === \"Not helpful\" ? active : undefined}\n onClick={onClick}\n whileTap={reduce ? undefined : { scale: 0.9 }}\n transition={SPRING_PRESS}\n className={cn(\n \"grid size-7 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\",\n active && \"bg-muted text-foreground\",\n )}\n >\n {children}\n </motion.button>\n );\n}\n\nexport function StreamingResponse({\n children,\n status = \"streaming\",\n copyText,\n onCopy,\n onRetry,\n sources = [],\n sourcesOpen,\n defaultSourcesOpen = false,\n onSourcesOpenChange,\n sourceIdPrefix,\n feedback,\n defaultFeedback = null,\n onFeedbackChange,\n announce = true,\n showActions = true,\n className,\n contentClassName,\n actionsClassName,\n}: StreamingResponseProps) {\n const reduce = useReducedMotion() ?? false;\n const baseId = useId();\n const [copied, setCopied] = useState(false);\n const [internalFeedback, setInternalFeedback] =\n useState<StreamingResponseFeedback>(defaultFeedback);\n const [internalSourcesOpen, setInternalSourcesOpen] = useState(defaultSourcesOpen);\n const copyTimer = useRef<number | undefined>(undefined);\n const currentFeedback = feedback ?? internalFeedback;\n const currentSourcesOpen = sourcesOpen ?? internalSourcesOpen;\n const streaming = status === \"streaming\";\n const complete = status === \"complete\";\n const canCopy = Boolean(copyText || onCopy);\n const hasSources = sources.length > 0;\n const shouldShowActions =\n showActions && !streaming && (canCopy || onRetry || complete || hasSources);\n const sourcesContentId = `${baseId}-sources`;\n const resolvedSourcePrefix = sourceIdPrefix ?? `response-source-${baseId.replace(/:/g, \"\")}`;\n\n useEffect(\n () => () => {\n if (copyTimer.current) window.clearTimeout(copyTimer.current);\n },\n [],\n );\n\n const handleCopy = useCallback(async () => {\n if (onCopy) await onCopy();\n else if (copyText) await navigator.clipboard?.writeText(copyText);\n\n setCopied(true);\n if (copyTimer.current) window.clearTimeout(copyTimer.current);\n copyTimer.current = window.setTimeout(() => setCopied(false), 1600);\n }, [copyText, onCopy]);\n\n const setFeedback = (next: Exclude<StreamingResponseFeedback, null>) => {\n const value = currentFeedback === next ? null : next;\n if (feedback === undefined) setInternalFeedback(value);\n onFeedbackChange?.(value);\n };\n\n const setSourcesOpen = useCallback(\n (next: boolean) => {\n if (sourcesOpen === undefined) setInternalSourcesOpen(next);\n onSourcesOpenChange?.(next);\n },\n [onSourcesOpenChange, sourcesOpen],\n );\n\n return (\n <div data-state={status} aria-busy={streaming} className={cn(\"w-full\", className)}>\n <div\n aria-live={announce ? \"polite\" : \"off\"}\n className={cn(\n \"text-foreground/90 text-sm leading-6 [&_a]:font-medium [&_a]:underline [&_a]:underline-offset-4 [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em] [&_ol]:my-3 [&_ol]:list-decimal [&_ol]:space-y-1 [&_ol]:pl-5 [&_p+p]:mt-3 [&_pre]:my-3 [&_pre]:overflow-x-auto [&_pre]:rounded-xl [&_pre]:border [&_pre]:border-border [&_pre]:bg-muted/45 [&_pre]:p-3 [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_ul]:my-3 [&_ul]:list-disc [&_ul]:space-y-1 [&_ul]:pl-5\",\n contentClassName,\n )}\n >\n {children}\n </div>\n\n <AnimatePresence initial={false}>\n {shouldShowActions ? (\n <motion.div\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 4 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0 }}\n transition={{ duration: reduce ? 0.12 : 0.22, ease: EASE_OUT }}\n className=\"mt-3\"\n >\n <div className={cn(\"flex items-center gap-0.5\", actionsClassName)}>\n {canCopy ? (\n <ResponseAction label={copied ? \"Copied\" : \"Copy response\"} onClick={handleCopy}>\n {copied ? <Check className=\"size-3.5\" /> : <Copy className=\"size-3.5\" />}\n </ResponseAction>\n ) : null}\n {onRetry ? (\n <ResponseAction label=\"Retry response\" onClick={onRetry}>\n <RotateCcw className=\"size-3.5\" />\n </ResponseAction>\n ) : null}\n {complete ? (\n <>\n <ResponseAction\n label=\"Helpful\"\n active={currentFeedback === \"up\"}\n onClick={() => setFeedback(\"up\")}\n >\n <ThumbsUp className=\"size-3.5\" />\n </ResponseAction>\n <ResponseAction\n label=\"Not helpful\"\n active={currentFeedback === \"down\"}\n onClick={() => setFeedback(\"down\")}\n >\n <ThumbsDown className=\"size-3.5\" />\n </ResponseAction>\n </>\n ) : null}\n {hasSources ? (\n <button\n type=\"button\"\n aria-expanded={currentSourcesOpen}\n aria-controls={sourcesContentId}\n onClick={() => setSourcesOpen(!currentSourcesOpen)}\n className=\"group ml-1 inline-flex min-h-7 items-center gap-2 rounded-md px-1.5 text-muted-foreground text-xs outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <CitationStack citations={sources} />\n <span className=\"tabular-nums\">\n {sources.length} {sources.length === 1 ? \"source\" : \"sources\"}\n </span>\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotate: currentSourcesOpen ? 180 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n className=\"text-muted-foreground/50 group-hover:text-muted-foreground\"\n >\n <ChevronDown className=\"size-3\" />\n </motion.span>\n </button>\n ) : null}\n </div>\n\n {hasSources ? (\n <AgentDisclosure id={sourcesContentId} open={currentSourcesOpen}>\n <CitationList\n citations={sources}\n idPrefix={resolvedSourcePrefix}\n className=\"mt-2 rounded-xl bg-muted p-2\"\n />\n </AgentDisclosure>\n ) : null}\n </motion.div>\n ) : null}\n </AnimatePresence>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAyCA,SAAS,eAAe,EACtB,OACA,SAAS,OACT,SACA,YAMC;CACD,MAAM,SAAS,iBAAiB,KAAK;CAErC,OACE,oBAAC,OAAO,QAAR;EACE,MAAK;EACL,cAAY;EACZ,OAAO;EACP,gBAAc,UAAU,aAAa,UAAU,gBAAgB,SAAS,KAAA;EAC/D;EACT,UAAU,SAAS,KAAA,IAAY,EAAE,OAAO,GAAI;EAC5C,YAAY;EACZ,WAAW,GACT,oLACA,UAAU,0BACZ;EAEC;CACY,CAAA;AAEnB;AAEA,SAAgB,kBAAkB,EAChC,UACA,SAAS,aACT,UACA,QACA,SACA,UAAU,CAAC,GACX,aACA,qBAAqB,OACrB,qBACA,gBACA,UACA,kBAAkB,MAClB,kBACA,WAAW,MACX,cAAc,MACd,WACA,kBACA,oBACyB;CACzB,MAAM,SAAS,iBAAiB,KAAK;CACrC,MAAM,SAAS,MAAM;CACrB,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAC1C,MAAM,CAAC,kBAAkB,uBACvB,SAAoC,eAAe;CACrD,MAAM,CAAC,qBAAq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AO,MAAR;SACE,eAAY;SACZ,SAAS,EAAE,QAAQ,qBAAqB,MAAM,EAAE;SAChD,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;SACvC,WAAU;SAEV,UAAA,oBAAC,aAAD,EAAa,WAAU,SAAU,CAAA;QACtB,CAAA;OACP;MACN,CAAA,IAAA;KACD;IAEJ,CAAA,GAAA,aACC,oBAAC,iBAAD;KAAiB,IAAI;KAAkB,MAAM;KAC3C,UAAA,oBAAC,cAAD;MACE,WAAW;MACX,UAAU;MACV,WAAU;KACX,CAAA;IACc,CAAA,IACf,IACM;GACV,CAAA,IAAA;EACW,CAAA,CACd;;AAET"}
|
|
@@ -3,7 +3,7 @@ import { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from "../../lib/ease.js";
|
|
|
3
3
|
import { AgentDisclosure } from "./agent-disclosure.js";
|
|
4
4
|
import { ActionSwapRollText } from "../motion/action-swap-roll.js";
|
|
5
5
|
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
6
|
-
import { cn } from "
|
|
6
|
+
import { cn } from "@kumix/utils";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
9
9
|
import { ChevronDown, ListTodo } from "lucide-react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"todo-list.js","names":[],"sources":["../../../src/components/agents/todo-list.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { cn } from \"cn\";\nimport { ChevronDown, ListTodo } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from \"../../lib/ease\";\nimport { ActionSwapRollText } from \"../motion/action-swap-roll\";\nimport { AgentDisclosure } from \"./agent-disclosure\";\n\nexport type TodoItemStatus = \"pending\" | \"in-progress\" | \"completed\" | \"cancelled\";\n\nexport interface TodoItem {\n id: string;\n title: ReactNode;\n status?: TodoItemStatus;\n progress?: number;\n detail?: ReactNode;\n}\n\nexport interface TodoListProps {\n items: TodoItem[];\n title?: ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n collapseOnComplete?: boolean;\n maxHeight?: number;\n className?: string;\n}\n\nfunction statusLabel(status: TodoItemStatus) {\n if (status === \"in-progress\") return \"In progress\";\n if (status === \"completed\") return \"Completed\";\n if (status === \"cancelled\") return \"Cancelled\";\n return \"Pending\";\n}\n\nfunction TodoHeaderIcon({ complete }: { complete: boolean }) {\n const reduce = useReducedMotion() ?? false;\n\n return (\n <span aria-hidden=\"true\" className=\"relative grid size-6 shrink-0 place-items-center\">\n <AnimatePresence initial={false} mode=\"popLayout\">\n {complete ? (\n <motion.svg\n key=\"complete\"\n viewBox=\"0 0 24 24\"\n initial={reduce ? { opacity: 1 } : { opacity: 0, scale: 0.72 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n className=\"absolute size-5.5 overflow-visible text-emerald-500\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"9\" fill=\"currentColor\" />\n <motion.path\n d=\"M7.5 12.25 10.5 15.25 16.75 8.75\"\n fill=\"none\"\n stroke=\"white\"\n strokeWidth=\"2.25\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n initial={reduce ? { pathLength: 1 } : { pathLength: 0 }}\n animate={{ pathLength: 1 }}\n transition={reduce ? { duration: 0 } : { duration: 0.24, ease: EASE_OUT }}\n />\n </motion.svg>\n ) : (\n <motion.span\n key=\"todo\"\n initial={reduce ? { opacity: 1 } : { opacity: 0, scale: 0.8 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.72 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n className=\"absolute grid place-items-center text-muted-foreground\"\n >\n <ListTodo className=\"size-4\" />\n </motion.span>\n )}\n </AnimatePresence>\n </span>\n );\n}\n\nfunction TodoStatusIcon({ status, progress }: { status: TodoItemStatus; progress?: number }) {\n const reduce = useReducedMotion() ?? false;\n const normalizedProgress =\n progress === undefined ? 0.68 : Math.min(100, Math.max(0, progress)) / 100;\n\n return (\n <motion.svg\n aria-hidden=\"true\"\n viewBox=\"0 0 24 24\"\n initial={false}\n className={cn(\n \"mx-0.5 size-5 shrink-0 overflow-visible text-muted-foreground\",\n status === \"in-progress\" && \"text-foreground\",\n status === \"cancelled\" && \"text-rose-600 dark:text-rose-400\",\n )}\n >\n <motion.circle\n cx=\"12\"\n cy=\"12\"\n r=\"9\"\n fill=\"currentColor\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeDasharray={status === \"pending\" ? \"2 3\" : undefined}\n strokeLinecap=\"round\"\n initial={false}\n animate={{ fillOpacity: status === \"completed\" ? 0.06 : 0 }}\n transition={reduce ? { duration: 0 } : { duration: 0.18, ease: EASE_OUT }}\n className={cn(status === \"in-progress\" && \"opacity-20\")}\n />\n <motion.circle\n cx=\"12\"\n cy=\"12\"\n r=\"9\"\n pathLength=\"1\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n initial={false}\n animate={{\n pathLength: status === \"in-progress\" ? normalizedProgress : 0,\n opacity: status === \"in-progress\" ? 1 : 0,\n rotate: status === \"in-progress\" && progress === undefined && !reduce ? 360 : -90,\n }}\n transition={\n status === \"in-progress\" && progress === undefined && !reduce\n ? { rotate: { duration: 1.1, repeat: Infinity, ease: \"linear\" } }\n : reduce\n ? { duration: 0 }\n : SPRING_LAYOUT\n }\n style={{ transformOrigin: \"12px 12px\" }}\n />\n <motion.path\n d=\"M7.5 12.25 10.5 15.25 16.75 8.75\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n initial={false}\n animate={{\n pathLength: status === \"completed\" ? 1 : 0,\n opacity: status === \"completed\" ? 1 : 0,\n }}\n transition={reduce ? { duration: 0 } : { duration: 0.24, ease: EASE_OUT }}\n />\n <motion.path\n d=\"M8.5 8.5 15.5 15.5M15.5 8.5 8.5 15.5\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n initial={false}\n animate={{\n pathLength: status === \"cancelled\" ? 1 : 0,\n opacity: status === \"cancelled\" ? 1 : 0,\n }}\n transition={reduce ? { duration: 0 } : { duration: 0.2, ease: EASE_OUT }}\n />\n </motion.svg>\n );\n}\n\nexport function TodoList({\n items,\n title = \"To-dos\",\n open,\n defaultOpen = true,\n onOpenChange,\n collapseOnComplete = true,\n maxHeight = 248,\n className,\n}: TodoListProps) {\n const reduce = useReducedMotion() ?? false;\n const baseId = useId();\n const triggerId = `${baseId}-trigger`;\n const contentId = `${baseId}-content`;\n const viewportRef = useRef<HTMLDivElement>(null);\n const previousComplete = useRef(false);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const currentOpen = open ?? internalOpen;\n const completed = items.filter((item) => item.status === \"completed\").length;\n const allComplete = items.length > 0 && completed === items.length;\n const itemCount = items.length;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (open === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [onOpenChange, open],\n );\n\n useEffect(() => {\n if (previousComplete.current && !allComplete) {\n setOpen(true);\n }\n if (!previousComplete.current && allComplete && collapseOnComplete) {\n setOpen(false);\n }\n previousComplete.current = allComplete;\n }, [allComplete, collapseOnComplete, setOpen]);\n\n useLayoutEffect(() => {\n const viewport = viewportRef.current;\n if (!viewport || itemCount === 0) return;\n\n const frame = requestAnimationFrame(() => {\n if (viewport.scrollHeight <= viewport.clientHeight) return;\n if (typeof viewport.scrollTo === \"function\") {\n viewport.scrollTo({\n top: viewport.scrollHeight,\n behavior: reduce ? \"auto\" : \"smooth\",\n });\n } else {\n viewport.scrollTop = viewport.scrollHeight;\n }\n });\n return () => cancelAnimationFrame(frame);\n }, [itemCount, reduce]);\n\n return (\n <section\n aria-label=\"Agent task list\"\n className={cn(\"w-full overflow-hidden rounded-2xl border border-border/70\", className)}\n >\n <button\n id={triggerId}\n type=\"button\"\n aria-expanded={currentOpen}\n aria-controls={contentId}\n onClick={() => setOpen(!currentOpen)}\n className=\"group flex h-11 w-full items-center gap-2.5 rounded-2xl px-3.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <TodoHeaderIcon complete={allComplete} />\n <h3 className=\"min-w-0 flex-1 truncate font-medium text-foreground/90 text-sm\">{title}</h3>\n <span\n className={cn(\n \"shrink-0 font-medium text-muted-foreground text-xs tabular-nums\",\n allComplete && \"text-emerald-600 dark:text-emerald-400\",\n )}\n >\n <span className=\"sr-only\">\n {completed} of {items.length} tasks completed\n </span>\n <span aria-hidden=\"true\" className=\"inline-flex\">\n <ActionSwapRollText value={String(completed)}>{completed}</ActionSwapRollText>\n <span>/</span>\n <span>{items.length}</span>\n </span>\n </span>\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotate: currentOpen ? 180 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n className=\"text-muted-foreground/50 transition-colors group-hover:text-muted-foreground\"\n >\n <ChevronDown className=\"size-3.5\" />\n </motion.span>\n </button>\n\n <AgentDisclosure id={contentId} role=\"region\" aria-labelledby={triggerId} open={currentOpen}>\n <div\n ref={viewportRef}\n className=\"scrollbar-hide overflow-y-auto px-2 pb-2\"\n style={{ maxHeight }}\n >\n {items.length ? (\n <ol aria-live=\"polite\" className=\"space-y-0\">\n <AnimatePresence initial={false} mode=\"popLayout\">\n {items.map((item) => {\n const status = item.status ?? \"pending\";\n return (\n <motion.li\n layout=\"position\"\n key={item.id}\n initial={reduce ? { opacity: 1 } : { opacity: 0, y: 6 }}\n animate={{ opacity: 1, y: 0 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -3 }}\n transition={\n reduce\n ? { duration: 0 }\n : {\n opacity: { duration: 0.18, ease: EASE_OUT },\n y: SPRING_LAYOUT,\n layout: SPRING_LAYOUT,\n }\n }\n className=\"flex min-h-9 items-center gap-2.5 rounded-xl px-1.5 py-1\"\n >\n <TodoStatusIcon status={status} progress={item.progress} />\n <span className=\"sr-only\">{statusLabel(status)}: </span>\n <span\n className={cn(\n \"min-w-0 flex-1 truncate text-sm leading-5\",\n status === \"pending\" && \"text-muted-foreground/65\",\n status === \"in-progress\" && \"text-foreground\",\n status === \"completed\" && \"text-muted-foreground/60\",\n status === \"cancelled\" && \"text-muted-foreground/55\",\n )}\n >\n <span className=\"relative inline-block max-w-full\">\n {item.title}\n <motion.span\n aria-hidden=\"true\"\n initial={false}\n animate={{\n scaleX: status === \"completed\" ? 1 : 0,\n opacity: status === \"completed\" ? 1 : 0,\n }}\n transition={\n reduce\n ? { duration: 0 }\n : { duration: 0.28, ease: EASE_OUT, delay: 0.06 }\n }\n className=\"absolute inset-x-0 top-1/2 h-px origin-left bg-current\"\n />\n </span>\n </span>\n {item.detail ? (\n <span className=\"shrink-0 text-muted-foreground/55 text-sm\">\n {item.detail}\n </span>\n ) : null}\n </motion.li>\n );\n })}\n </AnimatePresence>\n </ol>\n ) : (\n <p className=\"px-1.5 py-2 text-muted-foreground text-sm\">No tasks yet</p>\n )}\n </div>\n </AgentDisclosure>\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;AAwCA,SAAS,YAAY,QAAwB;CAC3C,IAAI,WAAW,eAAe,OAAO;CACrC,IAAI,WAAW,aAAa,OAAO;CACnC,IAAI,WAAW,aAAa,OAAO;CACnC,OAAO;AACT;AAEA,SAAS,eAAe,EAAE,YAAmC;CAC3D,MAAM,SAAS,iBAAiB,KAAK;CAErC,OACE,oBAAC,QAAD;EAAM,eAAY;EAAO,WAAU;EACjC,UAAA,oBAAC,iBAAD;GAAiB,SAAS;GAAO,MAAK;GACnC,UAAA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Eb"}
|
|
1
|
+
{"version":3,"file":"todo-list.js","names":[],"sources":["../../../src/components/agents/todo-list.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { ChevronDown, ListTodo } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from \"../../lib/ease\";\nimport { ActionSwapRollText } from \"../motion/action-swap-roll\";\nimport { AgentDisclosure } from \"./agent-disclosure\";\n\nexport type TodoItemStatus = \"pending\" | \"in-progress\" | \"completed\" | \"cancelled\";\n\nexport interface TodoItem {\n id: string;\n title: ReactNode;\n status?: TodoItemStatus;\n progress?: number;\n detail?: ReactNode;\n}\n\nexport interface TodoListProps {\n items: TodoItem[];\n title?: ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n collapseOnComplete?: boolean;\n maxHeight?: number;\n className?: string;\n}\n\nfunction statusLabel(status: TodoItemStatus) {\n if (status === \"in-progress\") return \"In progress\";\n if (status === \"completed\") return \"Completed\";\n if (status === \"cancelled\") return \"Cancelled\";\n return \"Pending\";\n}\n\nfunction TodoHeaderIcon({ complete }: { complete: boolean }) {\n const reduce = useReducedMotion() ?? false;\n\n return (\n <span aria-hidden=\"true\" className=\"relative grid size-6 shrink-0 place-items-center\">\n <AnimatePresence initial={false} mode=\"popLayout\">\n {complete ? (\n <motion.svg\n key=\"complete\"\n viewBox=\"0 0 24 24\"\n initial={reduce ? { opacity: 1 } : { opacity: 0, scale: 0.72 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n className=\"absolute size-5.5 overflow-visible text-emerald-500\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"9\" fill=\"currentColor\" />\n <motion.path\n d=\"M7.5 12.25 10.5 15.25 16.75 8.75\"\n fill=\"none\"\n stroke=\"white\"\n strokeWidth=\"2.25\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n initial={reduce ? { pathLength: 1 } : { pathLength: 0 }}\n animate={{ pathLength: 1 }}\n transition={reduce ? { duration: 0 } : { duration: 0.24, ease: EASE_OUT }}\n />\n </motion.svg>\n ) : (\n <motion.span\n key=\"todo\"\n initial={reduce ? { opacity: 1 } : { opacity: 0, scale: 0.8 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.72 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n className=\"absolute grid place-items-center text-muted-foreground\"\n >\n <ListTodo className=\"size-4\" />\n </motion.span>\n )}\n </AnimatePresence>\n </span>\n );\n}\n\nfunction TodoStatusIcon({ status, progress }: { status: TodoItemStatus; progress?: number }) {\n const reduce = useReducedMotion() ?? false;\n const normalizedProgress =\n progress === undefined ? 0.68 : Math.min(100, Math.max(0, progress)) / 100;\n\n return (\n <motion.svg\n aria-hidden=\"true\"\n viewBox=\"0 0 24 24\"\n initial={false}\n className={cn(\n \"mx-0.5 size-5 shrink-0 overflow-visible text-muted-foreground\",\n status === \"in-progress\" && \"text-foreground\",\n status === \"cancelled\" && \"text-rose-600 dark:text-rose-400\",\n )}\n >\n <motion.circle\n cx=\"12\"\n cy=\"12\"\n r=\"9\"\n fill=\"currentColor\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeDasharray={status === \"pending\" ? \"2 3\" : undefined}\n strokeLinecap=\"round\"\n initial={false}\n animate={{ fillOpacity: status === \"completed\" ? 0.06 : 0 }}\n transition={reduce ? { duration: 0 } : { duration: 0.18, ease: EASE_OUT }}\n className={cn(status === \"in-progress\" && \"opacity-20\")}\n />\n <motion.circle\n cx=\"12\"\n cy=\"12\"\n r=\"9\"\n pathLength=\"1\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n initial={false}\n animate={{\n pathLength: status === \"in-progress\" ? normalizedProgress : 0,\n opacity: status === \"in-progress\" ? 1 : 0,\n rotate: status === \"in-progress\" && progress === undefined && !reduce ? 360 : -90,\n }}\n transition={\n status === \"in-progress\" && progress === undefined && !reduce\n ? { rotate: { duration: 1.1, repeat: Infinity, ease: \"linear\" } }\n : reduce\n ? { duration: 0 }\n : SPRING_LAYOUT\n }\n style={{ transformOrigin: \"12px 12px\" }}\n />\n <motion.path\n d=\"M7.5 12.25 10.5 15.25 16.75 8.75\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n initial={false}\n animate={{\n pathLength: status === \"completed\" ? 1 : 0,\n opacity: status === \"completed\" ? 1 : 0,\n }}\n transition={reduce ? { duration: 0 } : { duration: 0.24, ease: EASE_OUT }}\n />\n <motion.path\n d=\"M8.5 8.5 15.5 15.5M15.5 8.5 8.5 15.5\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n initial={false}\n animate={{\n pathLength: status === \"cancelled\" ? 1 : 0,\n opacity: status === \"cancelled\" ? 1 : 0,\n }}\n transition={reduce ? { duration: 0 } : { duration: 0.2, ease: EASE_OUT }}\n />\n </motion.svg>\n );\n}\n\nexport function TodoList({\n items,\n title = \"To-dos\",\n open,\n defaultOpen = true,\n onOpenChange,\n collapseOnComplete = true,\n maxHeight = 248,\n className,\n}: TodoListProps) {\n const reduce = useReducedMotion() ?? false;\n const baseId = useId();\n const triggerId = `${baseId}-trigger`;\n const contentId = `${baseId}-content`;\n const viewportRef = useRef<HTMLDivElement>(null);\n const previousComplete = useRef(false);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const currentOpen = open ?? internalOpen;\n const completed = items.filter((item) => item.status === \"completed\").length;\n const allComplete = items.length > 0 && completed === items.length;\n const itemCount = items.length;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (open === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [onOpenChange, open],\n );\n\n useEffect(() => {\n if (previousComplete.current && !allComplete) {\n setOpen(true);\n }\n if (!previousComplete.current && allComplete && collapseOnComplete) {\n setOpen(false);\n }\n previousComplete.current = allComplete;\n }, [allComplete, collapseOnComplete, setOpen]);\n\n useLayoutEffect(() => {\n const viewport = viewportRef.current;\n if (!viewport || itemCount === 0) return;\n\n const frame = requestAnimationFrame(() => {\n if (viewport.scrollHeight <= viewport.clientHeight) return;\n if (typeof viewport.scrollTo === \"function\") {\n viewport.scrollTo({\n top: viewport.scrollHeight,\n behavior: reduce ? \"auto\" : \"smooth\",\n });\n } else {\n viewport.scrollTop = viewport.scrollHeight;\n }\n });\n return () => cancelAnimationFrame(frame);\n }, [itemCount, reduce]);\n\n return (\n <section\n aria-label=\"Agent task list\"\n className={cn(\"w-full overflow-hidden rounded-2xl border border-border/70\", className)}\n >\n <button\n id={triggerId}\n type=\"button\"\n aria-expanded={currentOpen}\n aria-controls={contentId}\n onClick={() => setOpen(!currentOpen)}\n className=\"group flex h-11 w-full items-center gap-2.5 rounded-2xl px-3.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <TodoHeaderIcon complete={allComplete} />\n <h3 className=\"min-w-0 flex-1 truncate font-medium text-foreground/90 text-sm\">{title}</h3>\n <span\n className={cn(\n \"shrink-0 font-medium text-muted-foreground text-xs tabular-nums\",\n allComplete && \"text-emerald-600 dark:text-emerald-400\",\n )}\n >\n <span className=\"sr-only\">\n {completed} of {items.length} tasks completed\n </span>\n <span aria-hidden=\"true\" className=\"inline-flex\">\n <ActionSwapRollText value={String(completed)}>{completed}</ActionSwapRollText>\n <span>/</span>\n <span>{items.length}</span>\n </span>\n </span>\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotate: currentOpen ? 180 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n className=\"text-muted-foreground/50 transition-colors group-hover:text-muted-foreground\"\n >\n <ChevronDown className=\"size-3.5\" />\n </motion.span>\n </button>\n\n <AgentDisclosure id={contentId} role=\"region\" aria-labelledby={triggerId} open={currentOpen}>\n <div\n ref={viewportRef}\n className=\"scrollbar-hide overflow-y-auto px-2 pb-2\"\n style={{ maxHeight }}\n >\n {items.length ? (\n <ol aria-live=\"polite\" className=\"space-y-0\">\n <AnimatePresence initial={false} mode=\"popLayout\">\n {items.map((item) => {\n const status = item.status ?? \"pending\";\n return (\n <motion.li\n layout=\"position\"\n key={item.id}\n initial={reduce ? { opacity: 1 } : { opacity: 0, y: 6 }}\n animate={{ opacity: 1, y: 0 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -3 }}\n transition={\n reduce\n ? { duration: 0 }\n : {\n opacity: { duration: 0.18, ease: EASE_OUT },\n y: SPRING_LAYOUT,\n layout: SPRING_LAYOUT,\n }\n }\n className=\"flex min-h-9 items-center gap-2.5 rounded-xl px-1.5 py-1\"\n >\n <TodoStatusIcon status={status} progress={item.progress} />\n <span className=\"sr-only\">{statusLabel(status)}: </span>\n <span\n className={cn(\n \"min-w-0 flex-1 truncate text-sm leading-5\",\n status === \"pending\" && \"text-muted-foreground/65\",\n status === \"in-progress\" && \"text-foreground\",\n status === \"completed\" && \"text-muted-foreground/60\",\n status === \"cancelled\" && \"text-muted-foreground/55\",\n )}\n >\n <span className=\"relative inline-block max-w-full\">\n {item.title}\n <motion.span\n aria-hidden=\"true\"\n initial={false}\n animate={{\n scaleX: status === \"completed\" ? 1 : 0,\n opacity: status === \"completed\" ? 1 : 0,\n }}\n transition={\n reduce\n ? { duration: 0 }\n : { duration: 0.28, ease: EASE_OUT, delay: 0.06 }\n }\n className=\"absolute inset-x-0 top-1/2 h-px origin-left bg-current\"\n />\n </span>\n </span>\n {item.detail ? (\n <span className=\"shrink-0 text-muted-foreground/55 text-sm\">\n {item.detail}\n </span>\n ) : null}\n </motion.li>\n );\n })}\n </AnimatePresence>\n </ol>\n ) : (\n <p className=\"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AQ,WAAW,cAAc,IAAI;aACrC,SAAS,WAAW,cAAc,IAAI;YACxC;YACA,YACE,SACI,EAAE,UAAU,EAAE,IACd;aAAE,UAAU;aAAM,MAAM;aAAU,OAAO;YAAK;YAEpD,WAAU;WACX,CAAA,CACG;;SACF,CAAA;SACL,KAAK,SACJ,oBAAC,QAAD;UAAM,WAAU;UACb,UAAA,KAAK;SACF,CAAA,IACJ;QACK;OAjDJ,GAAA,KAAK,EAiDD;MAEf,CAAC;KACc,CAAA;IACf,CAAA,IAEJ,oBAAC,KAAD;KAAG,WAAU;KAA4C,UAAA;IAAe,CAAA;GAEvE,CAAA;EACU,CAAA,CACV;;AAEb"}
|
|
@@ -3,7 +3,7 @@ import { EASE_OUT, SPRING_PRESS, SPRING_SWAP } from "../../lib/ease.js";
|
|
|
3
3
|
import { AgentCode } from "./agent-code.js";
|
|
4
4
|
import { AgentDisclosure } from "./agent-disclosure.js";
|
|
5
5
|
import { useCallback, useEffect, useId, useRef, useState } from "react";
|
|
6
|
-
import { cn } from "
|
|
6
|
+
import { cn } from "@kumix/utils";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
9
9
|
import { Check, ChevronDown, CircleAlert, LoaderCircle, ShieldCheck, X } from "lucide-react";
|