@kumix/ui 0.3.13 → 0.3.14
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 +2 -2
- 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 +1 -1
- 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.js +1 -1
- 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 +1 -1
- 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.js +1 -1
- 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.js +1 -1
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/components/reui/frame.d.ts.map +1 -1
- package/dist/components/reui/frame.js +1 -1
- 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.js +1 -1
- 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.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.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 +2 -2
- 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.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 +2 -2
- 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/package.json +8 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/agents/approval-card/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { cn } from \"cn\";\nimport {\n ArrowLeft,\n ArrowRight,\n Check,\n CircleHelp,\n LoaderCircle,\n MessageSquareText,\n X,\n} from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { EASE_OUT, SPRING_SWAP } from \"../../../lib/ease\";\nimport { ActionSwapRollText } from \"../../motion/action-swap-roll\";\nimport { Button } from \"../../motion/button\";\nimport { Checkbox } from \"../../motion/checkbox\";\nimport { Input } from \"../../motion/input\";\nimport { RadioGroup, RadioGroupItem } from \"../../motion/radio\";\nimport { AgentDisclosure } from \"../agent-disclosure\";\nimport type {\n ApprovalCardAnswer,\n ApprovalCardAnswers,\n ApprovalCardProps,\n ApprovalCardQuestion,\n ApprovalCardStatus,\n} from \"./types\";\n\nexport type {\n ApprovalCardAnswer,\n ApprovalCardAnswers,\n ApprovalCardOption,\n ApprovalCardProps,\n ApprovalCardQuestion,\n ApprovalCardStatus,\n} from \"./types\";\n\nconst EMPTY_ANSWER: ApprovalCardAnswer = { selected: [], custom: \"\" };\n\nfunction getStatusLabel(status: ApprovalCardStatus) {\n if (status === \"submitting\") return \"Submitting\";\n if (status === \"approved\") return \"Approved\";\n if (status === \"rejected\") return \"Rejected\";\n if (status === \"changes-requested\") return \"Changes requested\";\n if (status === \"answered\") return \"Response submitted\";\n return \"Input required\";\n}\n\nfunction getStatusClass(status: ApprovalCardStatus) {\n if (status === \"approved\" || status === \"answered\") {\n return \"text-emerald-600 dark:text-emerald-400\";\n }\n if (status === \"rejected\") return \"text-rose-600 dark:text-rose-400\";\n if (status === \"changes-requested\") {\n return \"text-amber-600 dark:text-amber-400\";\n }\n return \"text-muted-foreground\";\n}\n\nfunction getStatusBadgeClass(status: ApprovalCardStatus) {\n if (status === \"pending\" || status === \"changes-requested\") {\n return \"border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400\";\n }\n if (status === \"submitting\") {\n return \"border-blue-500/30 bg-blue-500/10 text-blue-600 dark:text-blue-400\";\n }\n if (status === \"approved\" || status === \"answered\") {\n return \"border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400\";\n }\n return \"border-rose-500/30 bg-rose-500/10 text-rose-600 dark:text-rose-400\";\n}\n\nfunction isAnswered(answer: ApprovalCardAnswer) {\n return answer.selected.length > 0 || Boolean(answer.custom?.trim());\n}\n\nfunction QuestionOptions({\n question,\n answer,\n disabled,\n onChange,\n onSingleSelect,\n}: {\n question: ApprovalCardQuestion;\n answer: ApprovalCardAnswer;\n disabled: boolean;\n onChange: (answer: ApprovalCardAnswer) => void;\n onSingleSelect?: () => void;\n}) {\n const custom = answer.custom ?? \"\";\n\n return (\n <div className=\"mt-3\">\n {question.options?.length ? (\n question.multiple ? (\n <div className=\"grid gap-0.5\">\n {question.options.map((option) => (\n <Checkbox\n key={option.value}\n checked={answer.selected.includes(option.value)}\n disabled={disabled || option.disabled}\n label={option.label}\n onCheckedChange={(checked) =>\n onChange({\n ...answer,\n selected: checked\n ? [...answer.selected, option.value]\n : answer.selected.filter((value) => value !== option.value),\n })\n }\n className=\"min-h-9 rounded-lg px-1.5 py-1\"\n />\n ))}\n </div>\n ) : (\n <RadioGroup\n value={answer.selected[0] ?? \"\"}\n onValueChange={(value) => {\n onChange({ selected: [value], custom: \"\" });\n onSingleSelect?.();\n }}\n className=\"gap-0.5\"\n >\n {question.options.map((option) => (\n <RadioGroupItem\n key={option.value}\n value={option.value}\n label={option.label}\n disabled={disabled || option.disabled}\n className=\"min-h-9 rounded-lg px-1.5 py-1\"\n />\n ))}\n </RadioGroup>\n )\n ) : null}\n\n {question.allowCustom ? (\n <Input\n value={custom}\n disabled={disabled}\n placeholder={question.customPlaceholder ?? \"Add another response…\"}\n onChange={(value) =>\n onChange({\n selected: question.multiple ? answer.selected : [],\n custom: value,\n })\n }\n className={cn(\"p-0.5\", question.options?.length && \"mt-1.5\")}\n classNames={{\n field: \"h-10 rounded-xl border-0 bg-background/70 focus-within:bg-background\",\n input: \"px-3 text-sm\",\n }}\n />\n ) : null}\n </div>\n );\n}\n\nfunction ProgressDots({ current, ids }: { current: number; ids: string[] }) {\n return (\n <span className=\"flex gap-1.5\">\n <span className=\"sr-only\">\n Question {current + 1} of {ids.length}\n </span>\n {ids.map((id, index) => (\n <motion.span\n key={id}\n aria-hidden=\"true\"\n initial={{\n scale: index === current ? 1 : 0.75,\n opacity: index <= current ? 1 : 0.35,\n }}\n animate={{\n scale: index === current ? 1 : 0.75,\n opacity: index <= current ? 1 : 0.35,\n }}\n transition={SPRING_SWAP}\n className=\"size-1.5 rounded-full bg-foreground\"\n />\n ))}\n </span>\n );\n}\n\nexport function ApprovalCard({\n title = \"Approval required\",\n description,\n children,\n questions = [],\n status = \"pending\",\n answers,\n defaultAnswers = {},\n onAnswersChange,\n step,\n defaultStep = 0,\n onStepChange,\n onSubmit,\n onApprove,\n onReject,\n onRequestChanges,\n onDismiss,\n approveLabel = \"Approve\",\n submitLabel = \"Submit response\",\n result,\n className,\n}: ApprovalCardProps) {\n const reduce = useReducedMotion() ?? false;\n const [internalAnswers, setInternalAnswers] = useState<ApprovalCardAnswers>(defaultAnswers);\n const [internalStep, setInternalStep] = useState(defaultStep);\n const autoAdvanceTimer = useRef<number | undefined>(undefined);\n const currentAnswers = answers ?? internalAnswers;\n const currentStep = Math.min(\n Math.max(0, step ?? internalStep),\n Math.max(0, questions.length - 1),\n );\n const question = questions[currentStep];\n const questionMode = questions.length > 0;\n const pending = status === \"pending\";\n const busy = status === \"submitting\";\n const interactive = pending || busy;\n const currentAnswer = question ? (currentAnswers[question.id] ?? EMPTY_ANSWER) : EMPTY_ANSWER;\n const displayTitle = question?.title ?? title;\n const titleKey = question?.id ?? String(status);\n const statusLabel = getStatusLabel(status);\n\n const clearAutoAdvance = useCallback(() => {\n if (autoAdvanceTimer.current === undefined) return;\n window.clearTimeout(autoAdvanceTimer.current);\n autoAdvanceTimer.current = undefined;\n }, []);\n\n useEffect(() => clearAutoAdvance, [clearAutoAdvance]);\n\n const setAnswers = useCallback(\n (next: ApprovalCardAnswers) => {\n if (answers === undefined) setInternalAnswers(next);\n onAnswersChange?.(next);\n },\n [answers, onAnswersChange],\n );\n\n const setStep = (next: number) => {\n clearAutoAdvance();\n if (step === undefined) setInternalStep(next);\n onStepChange?.(next);\n };\n\n const updateCurrentAnswer = (next: ApprovalCardAnswer) => {\n if (!question) return;\n setAnswers({ ...currentAnswers, [question.id]: next });\n };\n\n const continueQuestion = () => {\n if (currentStep < questions.length - 1) {\n setStep(currentStep + 1);\n return;\n }\n onSubmit?.(currentAnswers);\n };\n\n const queueAutoAdvance = () => {\n if (\n !question ||\n question.multiple ||\n question.autoAdvance === false ||\n currentStep >= questions.length - 1 ||\n busy\n ) {\n return;\n }\n\n clearAutoAdvance();\n autoAdvanceTimer.current = window.setTimeout(() => {\n setStep(currentStep + 1);\n }, 240);\n };\n\n return (\n <div\n data-state={status}\n aria-busy={busy}\n className={cn(\"w-full overflow-hidden rounded-2xl bg-muted p-4 text-sm\", className)}\n >\n <div className=\"flex items-start gap-3\">\n <span\n aria-hidden=\"true\"\n className={cn(\n \"grid size-5 shrink-0 place-items-center text-muted-foreground\",\n getStatusClass(status),\n )}\n >\n {busy ? (\n <LoaderCircle className={cn(\"size-4\", !reduce && \"animate-spin\")} />\n ) : interactive ? (\n questionMode ? (\n <CircleHelp className=\"size-4\" />\n ) : (\n <MessageSquareText className=\"size-4\" />\n )\n ) : status === \"rejected\" ? (\n <X className=\"size-4\" />\n ) : (\n <Check className=\"size-4\" />\n )}\n </span>\n\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex min-w-0 items-start gap-3\">\n <h3 className=\"min-w-0 flex-1 font-medium text-base text-foreground leading-5\">\n <ActionSwapRollText value={titleKey}>{displayTitle}</ActionSwapRollText>\n </h3>\n {questionMode && interactive ? (\n <span className=\"shrink-0 text-muted-foreground/65 text-xs tabular-nums\">\n {currentStep + 1}/{questions.length}\n </span>\n ) : (\n <span\n className={cn(\n \"shrink-0 rounded-full border px-2 py-0.5 font-medium text-[11px] transition-colors\",\n getStatusBadgeClass(status),\n )}\n >\n {statusLabel}\n </span>\n )}\n {onDismiss ? (\n <button\n type=\"button\"\n aria-label=\"Dismiss\"\n onClick={onDismiss}\n className=\"grid size-5 shrink-0 place-items-center rounded-full text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <X className=\"size-4\" />\n </button>\n ) : null}\n </div>\n\n <AgentDisclosure open={interactive}>\n {questionMode && question ? (\n <AnimatePresence initial={false} mode=\"wait\">\n <motion.div\n key={question.id}\n initial={reduce ? { opacity: 1 } : { opacity: 0, x: 8 }}\n animate={{ opacity: 1, x: 0 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, x: -6 }}\n transition={{ duration: reduce ? 0 : 0.2, ease: EASE_OUT }}\n >\n {question.description ? (\n <p className=\"mt-1 text-muted-foreground leading-5\">{question.description}</p>\n ) : null}\n <QuestionOptions\n question={question}\n answer={currentAnswer}\n disabled={busy}\n onChange={updateCurrentAnswer}\n onSingleSelect={queueAutoAdvance}\n />\n </motion.div>\n </AnimatePresence>\n ) : (\n <div>\n {description ? (\n <p className=\"mt-1 text-muted-foreground leading-5\">{description}</p>\n ) : null}\n {children ? <div className=\"mt-3\">{children}</div> : null}\n </div>\n )}\n\n {questionMode ? (\n <div className=\"mt-4 flex items-center gap-3\">\n <Button\n variant=\"ghost\"\n size=\"icon\"\n aria-label=\"Previous question\"\n disabled={busy || currentStep === 0}\n onClick={() => setStep(currentStep - 1)}\n className=\"rounded-full\"\n >\n <ArrowLeft className=\"size-4\" />\n </Button>\n <ProgressDots current={currentStep} ids={questions.map((item) => item.id)} />\n <Button\n size={currentStep === questions.length - 1 ? \"sm\" : \"icon\"}\n aria-label={\n currentStep === questions.length - 1 ? \"Submit response\" : \"Next question\"\n }\n disabled={busy || !isAnswered(currentAnswer)}\n onClick={continueQuestion}\n className=\"ml-auto rounded-full\"\n >\n {busy ? (\n <LoaderCircle className={cn(\"size-4\", !reduce && \"animate-spin\")} />\n ) : currentStep === questions.length - 1 ? (\n <>\n {submitLabel}\n <ArrowRight className=\"size-3.5\" />\n </>\n ) : (\n <ArrowRight className=\"size-4\" />\n )}\n </Button>\n </div>\n ) : (\n <div className=\"mt-4 flex flex-wrap items-center gap-2\">\n <Button size=\"sm\" disabled={busy} onClick={onApprove} className=\"rounded-full\">\n {approveLabel}\n </Button>\n {onRequestChanges ? (\n <Button\n variant=\"secondary\"\n size=\"sm\"\n disabled={busy}\n onClick={onRequestChanges}\n className=\"rounded-full\"\n >\n Request changes\n </Button>\n ) : null}\n {onReject ? (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n disabled={busy}\n onClick={onReject}\n className=\"rounded-full text-muted-foreground hover:text-rose-600 dark:hover:text-rose-400\"\n >\n Reject\n </Button>\n ) : null}\n </div>\n )}\n </AgentDisclosure>\n\n {!interactive ? (\n <p className=\"mt-1 text-muted-foreground text-sm\">{result ?? statusLabel}</p>\n ) : null}\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,MAAM,eAAmC;CAAE,UAAU,CAAC;CAAG,QAAQ;AAAG;AAEpE,SAAS,eAAe,QAA4B;CAClD,IAAI,WAAW,cAAc,OAAO;CACpC,IAAI,WAAW,YAAY,OAAO;CAClC,IAAI,WAAW,YAAY,OAAO;CAClC,IAAI,W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U,WAAY,CAAA,CAClC,EAAA,CAAA,IAEF,oBAAC,YAAD,EAAY,WAAU,SAAU,CAAA;QAE5B,CAAA;OACL;MAEL,CAAA,IAAA,qBAAC,OAAD;OAAK,WAAU;OAAf,UAAA;QACE,oBAAC,QAAD;SAAQ,MAAK;SAAK,UAAU;SAAM,SAAS;SAAW,WAAU;SAC7D,UAAA;QACK,CAAA;QACP,mBACC,oBAAC,QAAD;SACE,SAAQ;SACR,MAAK;SACL,UAAU;SACV,SAAS;SACT,WAAU;SACX,UAAA;QAEO,CAAA,IACN;QACH,WACC,oBAAC,QAAD;SACE,SAAQ;SACR,MAAK;SACL,UAAU;SACV,SAAS;SACT,WAAU;SACX,UAAA;QAEO,CAAA,IACN;OACD;MAEQ,CAAA,CAAA;;KAEhB,CAAC,cACA,oBAAC,KAAD;MAAG,WAAU;MAAsC,UAAA,UAAU;KAAe,CAAA,IAC1E;IACD;GACF,CAAA,CAAA;;CACF,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/agents/approval-card/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport {\n ArrowLeft,\n ArrowRight,\n Check,\n CircleHelp,\n LoaderCircle,\n MessageSquareText,\n X,\n} from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_SWAP } from \"../../../lib/ease\";\nimport { ActionSwapRollText } from \"../../motion/action-swap-roll\";\nimport { Button } from \"../../motion/button\";\nimport { Checkbox } from \"../../motion/checkbox\";\nimport { Input } from \"../../motion/input\";\nimport { RadioGroup, RadioGroupItem } from \"../../motion/radio\";\nimport { AgentDisclosure } from \"../agent-disclosure\";\nimport type {\n ApprovalCardAnswer,\n ApprovalCardAnswers,\n ApprovalCardProps,\n ApprovalCardQuestion,\n ApprovalCardStatus,\n} from \"./types\";\n\nexport type {\n ApprovalCardAnswer,\n ApprovalCardAnswers,\n ApprovalCardOption,\n ApprovalCardProps,\n ApprovalCardQuestion,\n ApprovalCardStatus,\n} from \"./types\";\n\nconst EMPTY_ANSWER: ApprovalCardAnswer = { selected: [], custom: \"\" };\n\nfunction getStatusLabel(status: ApprovalCardStatus) {\n if (status === \"submitting\") return \"Submitting\";\n if (status === \"approved\") return \"Approved\";\n if (status === \"rejected\") return \"Rejected\";\n if (status === \"changes-requested\") return \"Changes requested\";\n if (status === \"answered\") return \"Response submitted\";\n return \"Input required\";\n}\n\nfunction getStatusClass(status: ApprovalCardStatus) {\n if (status === \"approved\" || status === \"answered\") {\n return \"text-emerald-600 dark:text-emerald-400\";\n }\n if (status === \"rejected\") return \"text-rose-600 dark:text-rose-400\";\n if (status === \"changes-requested\") {\n return \"text-amber-600 dark:text-amber-400\";\n }\n return \"text-muted-foreground\";\n}\n\nfunction getStatusBadgeClass(status: ApprovalCardStatus) {\n if (status === \"pending\" || status === \"changes-requested\") {\n return \"border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400\";\n }\n if (status === \"submitting\") {\n return \"border-blue-500/30 bg-blue-500/10 text-blue-600 dark:text-blue-400\";\n }\n if (status === \"approved\" || status === \"answered\") {\n return \"border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400\";\n }\n return \"border-rose-500/30 bg-rose-500/10 text-rose-600 dark:text-rose-400\";\n}\n\nfunction isAnswered(answer: ApprovalCardAnswer) {\n return answer.selected.length > 0 || Boolean(answer.custom?.trim());\n}\n\nfunction QuestionOptions({\n question,\n answer,\n disabled,\n onChange,\n onSingleSelect,\n}: {\n question: ApprovalCardQuestion;\n answer: ApprovalCardAnswer;\n disabled: boolean;\n onChange: (answer: ApprovalCardAnswer) => void;\n onSingleSelect?: () => void;\n}) {\n const custom = answer.custom ?? \"\";\n\n return (\n <div className=\"mt-3\">\n {question.options?.length ? (\n question.multiple ? (\n <div className=\"grid gap-0.5\">\n {question.options.map((option) => (\n <Checkbox\n key={option.value}\n checked={answer.selected.includes(option.value)}\n disabled={disabled || option.disabled}\n label={option.label}\n onCheckedChange={(checked) =>\n onChange({\n ...answer,\n selected: checked\n ? [...answer.selected, option.value]\n : answer.selected.filter((value) => value !== option.value),\n })\n }\n className=\"min-h-9 rounded-lg px-1.5 py-1\"\n />\n ))}\n </div>\n ) : (\n <RadioGroup\n value={answer.selected[0] ?? \"\"}\n onValueChange={(value) => {\n onChange({ selected: [value], custom: \"\" });\n onSingleSelect?.();\n }}\n className=\"gap-0.5\"\n >\n {question.options.map((option) => (\n <RadioGroupItem\n key={option.value}\n value={option.value}\n label={option.label}\n disabled={disabled || option.disabled}\n className=\"min-h-9 rounded-lg px-1.5 py-1\"\n />\n ))}\n </RadioGroup>\n )\n ) : null}\n\n {question.allowCustom ? (\n <Input\n value={custom}\n disabled={disabled}\n placeholder={question.customPlaceholder ?? \"Add another response…\"}\n onChange={(value) =>\n onChange({\n selected: question.multiple ? answer.selected : [],\n custom: value,\n })\n }\n className={cn(\"p-0.5\", question.options?.length && \"mt-1.5\")}\n classNames={{\n field: \"h-10 rounded-xl border-0 bg-background/70 focus-within:bg-background\",\n input: \"px-3 text-sm\",\n }}\n />\n ) : null}\n </div>\n );\n}\n\nfunction ProgressDots({ current, ids }: { current: number; ids: string[] }) {\n return (\n <span className=\"flex gap-1.5\">\n <span className=\"sr-only\">\n Question {current + 1} of {ids.length}\n </span>\n {ids.map((id, index) => (\n <motion.span\n key={id}\n aria-hidden=\"true\"\n initial={{\n scale: index === current ? 1 : 0.75,\n opacity: index <= current ? 1 : 0.35,\n }}\n animate={{\n scale: index === current ? 1 : 0.75,\n opacity: index <= current ? 1 : 0.35,\n }}\n transition={SPRING_SWAP}\n className=\"size-1.5 rounded-full bg-foreground\"\n />\n ))}\n </span>\n );\n}\n\nexport function ApprovalCard({\n title = \"Approval required\",\n description,\n children,\n questions = [],\n status = \"pending\",\n answers,\n defaultAnswers = {},\n onAnswersChange,\n step,\n defaultStep = 0,\n onStepChange,\n onSubmit,\n onApprove,\n onReject,\n onRequestChanges,\n onDismiss,\n approveLabel = \"Approve\",\n submitLabel = \"Submit response\",\n result,\n className,\n}: ApprovalCardProps) {\n const reduce = useReducedMotion() ?? false;\n const [internalAnswers, setInternalAnswers] = useState<ApprovalCardAnswers>(defaultAnswers);\n const [internalStep, setInternalStep] = useState(defaultStep);\n const autoAdvanceTimer = useRef<number | undefined>(undefined);\n const currentAnswers = answers ?? internalAnswers;\n const currentStep = Math.min(\n Math.max(0, step ?? internalStep),\n Math.max(0, questions.length - 1),\n );\n const question = questions[currentStep];\n const questionMode = questions.length > 0;\n const pending = status === \"pending\";\n const busy = status === \"submitting\";\n const interactive = pending || busy;\n const currentAnswer = question ? (currentAnswers[question.id] ?? EMPTY_ANSWER) : EMPTY_ANSWER;\n const displayTitle = question?.title ?? title;\n const titleKey = question?.id ?? String(status);\n const statusLabel = getStatusLabel(status);\n\n const clearAutoAdvance = useCallback(() => {\n if (autoAdvanceTimer.current === undefined) return;\n window.clearTimeout(autoAdvanceTimer.current);\n autoAdvanceTimer.current = undefined;\n }, []);\n\n useEffect(() => clearAutoAdvance, [clearAutoAdvance]);\n\n const setAnswers = useCallback(\n (next: ApprovalCardAnswers) => {\n if (answers === undefined) setInternalAnswers(next);\n onAnswersChange?.(next);\n },\n [answers, onAnswersChange],\n );\n\n const setStep = (next: number) => {\n clearAutoAdvance();\n if (step === undefined) setInternalStep(next);\n onStepChange?.(next);\n };\n\n const updateCurrentAnswer = (next: ApprovalCardAnswer) => {\n if (!question) return;\n setAnswers({ ...currentAnswers, [question.id]: next });\n };\n\n const continueQuestion = () => {\n if (currentStep < questions.length - 1) {\n setStep(currentStep + 1);\n return;\n }\n onSubmit?.(currentAnswers);\n };\n\n const queueAutoAdvance = () => {\n if (\n !question ||\n question.multiple ||\n question.autoAdvance === false ||\n currentStep >= questions.length - 1 ||\n busy\n ) {\n return;\n }\n\n clearAutoAdvance();\n autoAdvanceTimer.current = window.setTimeout(() => {\n setStep(currentStep + 1);\n }, 240);\n };\n\n return (\n <div\n data-state={status}\n aria-busy={busy}\n className={cn(\"w-full overflow-hidden rounded-2xl bg-muted p-4 text-sm\", className)}\n >\n <div className=\"flex items-start gap-3\">\n <span\n aria-hidden=\"true\"\n className={cn(\n \"grid size-5 shrink-0 place-items-center text-muted-foreground\",\n getStatusClass(status),\n )}\n >\n {busy ? (\n <LoaderCircle className={cn(\"size-4\", !reduce && \"animate-spin\")} />\n ) : interactive ? (\n questionMode ? (\n <CircleHelp className=\"size-4\" />\n ) : (\n <MessageSquareText className=\"size-4\" />\n )\n ) : status === \"rejected\" ? (\n <X className=\"size-4\" />\n ) : (\n <Check className=\"size-4\" />\n )}\n </span>\n\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex min-w-0 items-start gap-3\">\n <h3 className=\"min-w-0 flex-1 font-medium text-base text-foreground leading-5\">\n <ActionSwapRollText value={titleKey}>{displayTitle}</ActionSwapRollText>\n </h3>\n {questionMode && interactive ? (\n <span className=\"shrink-0 text-muted-foreground/65 text-xs tabular-nums\">\n {currentStep + 1}/{questions.length}\n </span>\n ) : (\n <span\n className={cn(\n \"shrink-0 rounded-full border px-2 py-0.5 font-medium text-[11px] transition-colors\",\n getStatusBadgeClass(status),\n )}\n >\n {statusLabel}\n </span>\n )}\n {onDismiss ? (\n <button\n type=\"button\"\n aria-label=\"Dismiss\"\n onClick={onDismiss}\n className=\"grid size-5 shrink-0 place-items-center rounded-full text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <X className=\"size-4\" />\n </button>\n ) : null}\n </div>\n\n <AgentDisclosure open={interactive}>\n {questionMode && question ? (\n <AnimatePresence initial={false} mode=\"wait\">\n <motion.div\n key={question.id}\n initial={reduce ? { opacity: 1 } : { opacity: 0, x: 8 }}\n animate={{ opacity: 1, x: 0 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, x: -6 }}\n transition={{ duration: reduce ? 0 : 0.2, ease: EASE_OUT }}\n >\n {question.description ? (\n <p className=\"mt-1 text-muted-foreground leading-5\">{question.description}</p>\n ) : null}\n <QuestionOptions\n question={question}\n answer={currentAnswer}\n disabled={busy}\n onChange={updateCurrentAnswer}\n onSingleSelect={queueAutoAdvance}\n />\n </motion.div>\n </AnimatePresence>\n ) : (\n <div>\n {description ? (\n <p className=\"mt-1 text-muted-foreground leading-5\">{description}</p>\n ) : null}\n {children ? <div className=\"mt-3\">{children}</div> : null}\n </div>\n )}\n\n {questionMode ? (\n <div className=\"mt-4 flex items-center gap-3\">\n <Button\n variant=\"ghost\"\n size=\"icon\"\n aria-label=\"Previous question\"\n disabled={busy || currentStep === 0}\n onClick={() => setStep(currentStep - 1)}\n className=\"rounded-full\"\n >\n <ArrowLeft className=\"size-4\" />\n </Button>\n <ProgressDots current={currentStep} ids={questions.map((item) => item.id)} />\n <Button\n size={currentStep === questions.length - 1 ? \"sm\" : \"icon\"}\n aria-label={\n currentStep === questions.length - 1 ? \"Submit response\" : \"Next question\"\n }\n disabled={busy || !isAnswered(currentAnswer)}\n onClick={continueQuestion}\n className=\"ml-auto rounded-full\"\n >\n {busy ? (\n <LoaderCircle className={cn(\"size-4\", !reduce && \"animate-spin\")} />\n ) : currentStep === questions.length - 1 ? (\n <>\n {submitLabel}\n <ArrowRight className=\"size-3.5\" />\n </>\n ) : (\n <ArrowRight className=\"size-4\" />\n )}\n </Button>\n </div>\n ) : (\n <div className=\"mt-4 flex flex-wrap items-center gap-2\">\n <Button size=\"sm\" disabled={busy} onClick={onApprove} className=\"rounded-full\">\n {approveLabel}\n </Button>\n {onRequestChanges ? (\n <Button\n variant=\"secondary\"\n size=\"sm\"\n disabled={busy}\n onClick={onRequestChanges}\n className=\"rounded-full\"\n >\n Request changes\n </Button>\n ) : null}\n {onReject ? (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n disabled={busy}\n onClick={onReject}\n className=\"rounded-full text-muted-foreground hover:text-rose-600 dark:hover:text-rose-400\"\n >\n Reject\n </Button>\n ) : null}\n </div>\n )}\n </AgentDisclosure>\n\n {!interactive ? (\n <p className=\"mt-1 text-muted-foreground text-sm\">{result ?? statusLabel}</p>\n ) : null}\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,MAAM,eAAmC;CAAE,UAAU,CAAC;CAAG,QAAQ;AAAG;AAEpE,SAAS,eAAe,QAA4B;CAClD,IAAI,WAAW,cAAc,OAAO;CACpC,IAAI,WAAW,YAAY,OAAO;CAClC,IAAI,WAAW,YAAY,OAAO;CAClC,IAAI,WAAW,qBAAqB,OAAO;CAC3C,IAAI,WAAW,YAAY,OAAO;CAClC,OAAO;AACT;AAEA,SAAS,eAAe,QAA4B;CAClD,IAAI,WAAW,cAAc,WAAW,YACtC,OAAO;CAET,IAAI,WAAW,YAAY,OAAO;CAClC,IAAI,WAAW,qBACb,OAAO;CAET,OAAO;AACT;AAEA,SAAS,oBAAoB,QAA4B;CACvD,IAAI,WAAW,aAAa,WAAW,qBACrC,OAAO;CAET,IAAI,WAAW,cACb,OAAO;CAET,IAAI,WAAW,cAAc,WAAW,YACtC,OAAO;CAET,OAAO;AACT;AAEA,SAAS,WAAW,QAA4B;CAC9C,OAAO,OAAO,SAAS,SAAS,KAAK,QAAQ,OAAO,QAAQ,KAAK,CAAC;AACpE;AAEA,SAAS,gBAAgB,EACvB,UACA,QACA,UACA,UACA,kBAOC;CACD,MAAM,SAAS,OAAO,UAAU;CAEhC,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACG,SAAS,SAAS,SACjB,SAAS,WACP,oBAAC,OAAD;GAAK,WAAU;GACZ,UAAA,SAAS,QAAQ,KAAK,WACrB,oBAAC,UAAD;IAEE,SAAS,OAAO,SAAS,SAAS,OAAO,KAAK;IAC9C,UAAU,YAAY,OAAO;IAC7B,OAAO,OAAO;IACd,kBAAkB,YAChB,SAAS;KACP,GAAG;KACH,UAAU,UACN,CAAC,GAAG,OAAO,UAAU,OAAO,KAAK,IAC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AA;QAC5E,oBAAC,QAAD;SACE,MAAM,gBAAgB,UAAU,SAAS,IAAI,OAAO;SACpD,cACE,gBAAgB,UAAU,SAAS,IAAI,oBAAoB;SAE7D,UAAU,QAAQ,CAAC,WAAW,aAAa;SAC3C,SAAS;SACT,WAAU;SAET,UAAA,OACC,oBAAC,cAAD,EAAc,WAAW,GAAG,UAAU,CAAC,UAAU,cAAc,EAAI,CAAA,IACjE,gBAAgB,UAAU,SAAS,IACrC,qBAAA,YAAA,EAAA,UAAA,CACG,aACD,oBAAC,YAAD,EAAY,WAAU,WAAY,CAAA,CAClC,EAAA,CAAA,IAEF,oBAAC,YAAD,EAAY,WAAU,SAAU,CAAA;QAE5B,CAAA;OACL;MAEL,CAAA,IAAA,qBAAC,OAAD;OAAK,WAAU;OAAf,UAAA;QACE,oBAAC,QAAD;SAAQ,MAAK;SAAK,UAAU;SAAM,SAAS;SAAW,WAAU;SAC7D,UAAA;QACK,CAAA;QACP,mBACC,oBAAC,QAAD;SACE,SAAQ;SACR,MAAK;SACL,UAAU;SACV,SAAS;SACT,WAAU;SACX,UAAA;QAEO,CAAA,IACN;QACH,WACC,oBAAC,QAAD;SACE,SAAQ;SACR,MAAK;SACL,UAAU;SACV,SAAS;SACT,WAAU;SACX,UAAA;QAEO,CAAA,IACN;OACD;MAEQ,CAAA,CAAA;;KAEhB,CAAC,cACA,oBAAC,KAAD;MAAG,WAAU;MAAsC,UAAA,UAAU;KAAe,CAAA,IAC1E;IACD;GACF,CAAA,CAAA;;CACF,CAAA;AAET"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { AnimatedSidebarProvider, useAnimatedSidebar } from "../motion/animated-sidebar.js";
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
|
-
import { cn } from "
|
|
4
|
+
import { cn } from "@kumix/utils";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/agents/chat-app.tsx
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-app.js","names":[],"sources":["../../../src/components/agents/chat-app.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef } from \"react\";\nimport { cn } from \"
|
|
1
|
+
{"version":3,"file":"chat-app.js","names":[],"sources":["../../../src/components/agents/chat-app.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef } from \"react\";\n\nimport { cn } from \"@kumix/utils\";\nimport {\n AnimatedSidebarProvider,\n type AnimatedSidebarProviderProps,\n useAnimatedSidebar,\n} from \"../motion/animated-sidebar\";\n\n/**\n * Shell width below which a docked sidebar leaves too little room for the\n * conversation: the default sidebar is 17rem, so under 600px the conversation\n * pane is left with barely 330px — narrower than a phone.\n *\n * Deliberately not AnimatedSidebar's own 767px mobile query: that one asks\n * whether the *viewport* is a phone (and swaps the sidebar for an off-canvas\n * sheet), this one asks whether the *shell's own box* — which may be a column,\n * a split view or a panel inside a much wider page — still fits both panes.\n */\nconst MIN_DOCKED_WIDTH = 600;\n\nexport interface ChatAppProps extends AnimatedSidebarProviderProps {\n /** Docked sidebar width as a CSS length. Default `17rem`. */\n sidebarWidth?: string;\n /**\n * Shell width in px under which the sidebar folds off-canvas. Ignored while\n * `open` is controlled — the consumer owns the state then.\n */\n collapseSidebarBelow?: number;\n}\n\n/**\n * Folds the sidebar away while the shell is too narrow to carry both panes,\n * and brings it back when it isn't. Only crossings are acted on, so a manual\n * toggle at either size stays put until the shell actually changes shape.\n *\n * Mount is not a crossing in the opening direction: a shell that merely has\n * room says nothing about whether the caller wanted the sidebar open, so the\n * first measurement leaves `defaultOpen` alone. Too narrow at mount *is* the\n * fold condition itself, so that half applies immediately.\n */\nfunction ShellFit({ minWidth }: { minWidth: number }) {\n const { open, setOpen } = useAnimatedSidebar();\n const markerRef = useRef<HTMLDivElement>(null);\n const narrowRef = useRef<boolean | null>(null);\n const openRef = useRef(open);\n openRef.current = open;\n\n useEffect(() => {\n const shell = markerRef.current?.parentElement;\n if (!shell) return;\n const observer = new ResizeObserver(([entry]) => {\n const narrow = entry.contentRect.width < minWidth;\n if (narrowRef.current === narrow) return;\n const first = narrowRef.current === null;\n narrowRef.current = narrow;\n if (first && !narrow) return;\n const wanted = !narrow;\n // Already where the shell wants it — saying so again would only be an\n // onOpenChange the caller never asked for.\n if (openRef.current === wanted) return;\n setOpen(wanted);\n });\n observer.observe(shell);\n return () => observer.disconnect();\n }, [minWidth, setOpen]);\n\n return <div ref={markerRef} className=\"hidden\" />;\n}\n\nexport function ChatApp({\n children,\n className,\n sidebarWidth = \"17rem\",\n collapseSidebarBelow = MIN_DOCKED_WIDTH,\n style,\n ...props\n}: ChatAppProps) {\n return (\n <AnimatedSidebarProvider\n {...props}\n style={{ ...style, \"--sidebar-width\": sidebarWidth }}\n className={cn(\n \"min-h-0 w-full overflow-hidden rounded-2xl border border-border bg-background\",\n className,\n )}\n >\n {/* A controlled `open` is the consumer's to change; fitting the shell\n would fire an onOpenChange they never asked for. */}\n {props.open === undefined ? <ShellFit minWidth={collapseSidebarBelow} /> : null}\n {children}\n </AnimatedSidebarProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,MAAM,mBAAmB;;;;;;;;;;;AAsBzB,SAAS,SAAS,EAAE,YAAkC;CACpD,MAAM,EAAE,MAAM,YAAY,mBAAmB;CAC7C,MAAM,YAAY,OAAuB,IAAI;CAC7C,MAAM,YAAY,OAAuB,IAAI;CAC7C,MAAM,UAAU,OAAO,IAAI;CAC3B,QAAQ,UAAU;CAElB,gBAAgB;EACd,MAAM,QAAQ,UAAU,SAAS;EACjC,IAAI,CAAC,OAAO;EACZ,MAAM,WAAW,IAAI,gBAAgB,CAAC,WAAW;GAC/C,MAAM,SAAS,MAAM,YAAY,QAAQ;GACzC,IAAI,UAAU,YAAY,QAAQ;GAClC,MAAM,QAAQ,UAAU,YAAY;GACpC,UAAU,UAAU;GACpB,IAAI,SAAS,CAAC,QAAQ;GACtB,MAAM,SAAS,CAAC;GAGhB,IAAI,QAAQ,YAAY,QAAQ;GAChC,QAAQ,MAAM;EAChB,CAAC;EACD,SAAS,QAAQ,KAAK;EACtB,aAAa,SAAS,WAAW;CACnC,GAAG,CAAC,UAAU,OAAO,CAAC;CAEtB,OAAO,oBAAC,OAAD;EAAK,KAAK;EAAW,WAAU;CAAU,CAAA;AAClD;AAEA,SAAgB,QAAQ,EACtB,UACA,WACA,eAAe,SACf,uBAAuB,kBACvB,OACA,GAAG,SACY;CACf,OACE,qBAAC,yBAAD;EACE,GAAI;EACJ,OAAO;GAAE,GAAG;GAAO,mBAAmB;EAAa;EACnD,WAAW,GACT,iFACA,SACF;EANF,UAAA,CAUG,MAAM,SAAS,KAAA,IAAY,oBAAC,UAAD,EAAU,UAAU,qBAAuB,CAAA,IAAI,MAC1E,QACsB;;AAE7B"}
|
|
@@ -3,7 +3,7 @@ import { useFavicon } from "../../hooks/use-favicon.js";
|
|
|
3
3
|
import { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from "../../lib/ease.js";
|
|
4
4
|
import { AgentDisclosure } from "./agent-disclosure.js";
|
|
5
5
|
import { useCallback, useId, 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 { BookOpenText, ChevronDown, ExternalLink, Globe2 } from "lucide-react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"citations.js","names":[],"sources":["../../../src/components/agents/citations.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useId, useState } from \"react\";\nimport { cn } from \"cn\";\nimport { BookOpenText, ChevronDown, ExternalLink, Globe2 } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { useFavicon } from \"../../hooks/use-favicon\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from \"../../lib/ease\";\nimport { AgentDisclosure } from \"./agent-disclosure\";\n\nexport interface CitationItem {\n id: string;\n title: ReactNode;\n domain?: ReactNode;\n url?: string;\n}\n\nexport interface CitationsProps {\n citations: CitationItem[];\n title?: ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n idPrefix?: string;\n className?: string;\n}\n\nexport interface CitationProps {\n citationId: string;\n index: number;\n /** Must match the related Citations idPrefix. */\n idPrefix: string;\n className?: string;\n}\n\nexport interface CitationListProps {\n citations: CitationItem[];\n idPrefix?: string;\n className?: string;\n}\n\nexport interface CitationStackProps {\n citations: CitationItem[];\n limit?: number;\n className?: string;\n}\n\nfunction citationTargetId(prefix: string, citationId: string) {\n return `${prefix}-${citationId.replace(/[^a-zA-Z0-9_-]/g, \"-\")}`;\n}\n\nexport function Citation({ citationId, index, idPrefix, className }: CitationProps) {\n return (\n <a\n href={`#${citationTargetId(idPrefix, citationId)}`}\n aria-label={`View citation ${index}`}\n className={cn(\n \"mx-0.5 inline-flex min-w-4 -translate-y-0.5 items-center justify-center rounded-md bg-muted/60 px-1 py-0.5 font-semibold text-[10px] text-muted-foreground leading-none no-underline outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\",\n className,\n )}\n >\n {index}\n </a>\n );\n}\n\nexport function CitationFavicon({ url, className }: { url?: string; className?: string }) {\n const favicon = useFavicon(url);\n\n return (\n <span\n aria-hidden=\"true\"\n className={cn(\"grid size-5 shrink-0 place-items-center text-muted-foreground\", className)}\n >\n {favicon.src ? (\n <img\n ref={favicon.ref}\n src={favicon.src}\n alt=\"\"\n width={16}\n height={16}\n referrerPolicy=\"no-referrer\"\n className=\"size-4 rounded-sm object-contain\"\n />\n ) : (\n <Globe2 className=\"size-3.5\" />\n )}\n </span>\n );\n}\n\nexport function CitationStack({ citations, limit = 3, className }: CitationStackProps) {\n return (\n <span aria-hidden=\"true\" className={cn(\"flex -space-x-1.5\", className)}>\n {citations.slice(0, limit).map((citation) => (\n <CitationFavicon\n key={citation.id}\n url={citation.url}\n className=\"size-6 rounded-full bg-background ring-2 ring-background\"\n />\n ))}\n </span>\n );\n}\n\nfunction CitationRow({\n citation,\n index,\n idPrefix,\n}: {\n citation: CitationItem;\n index: number;\n idPrefix: string;\n}) {\n const content = (\n <>\n <CitationFavicon url={citation.url} />\n <span className=\"flex min-w-0 flex-1 flex-wrap items-baseline gap-x-2 gap-y-0.5\">\n <span className=\"truncate font-medium text-foreground/80 text-sm transition-colors group-hover/citation:text-foreground\">\n {citation.title}\n </span>\n {citation.domain ? (\n <span className=\"min-w-0 truncate text-muted-foreground/60 text-xs\">\n {citation.domain}\n </span>\n ) : null}\n </span>\n <span className=\"flex shrink-0 items-center gap-1.5\">\n <span className=\"grid size-5 place-items-center rounded-md bg-foreground/5 font-semibold text-[10px] text-muted-foreground tabular-nums\">\n {index}\n </span>\n {citation.url ? (\n <ExternalLink className=\"size-3.5 text-muted-foreground/40 transition-colors group-hover/citation:text-muted-foreground\" />\n ) : null}\n </span>\n </>\n );\n const className =\n \"group/citation flex items-center gap-2 rounded-md px-1.5 py-1 outline-none focus-visible:ring-2 focus-visible:ring-ring\";\n const id = citationTargetId(idPrefix, citation.id);\n\n return citation.url ? (\n <a id={id} href={citation.url} target=\"_blank\" rel=\"noreferrer noopener\" className={className}>\n {content}\n </a>\n ) : (\n <div id={id} className={className}>\n {content}\n </div>\n );\n}\n\nexport function CitationList({ citations, idPrefix, className }: CitationListProps) {\n const reduce = useReducedMotion() ?? false;\n const baseId = useId();\n const resolvedPrefix = idPrefix ?? `citation-list-${baseId.replace(/:/g, \"\")}`;\n\n return (\n <div className={cn(\"grid gap-0.5\", className)}>\n <AnimatePresence mode=\"popLayout\">\n {citations.map((citation, index) => (\n <motion.div\n layout=\"position\"\n key={citation.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 >\n <CitationRow citation={citation} index={index + 1} idPrefix={resolvedPrefix} />\n </motion.div>\n ))}\n </AnimatePresence>\n </div>\n );\n}\n\nexport function Citations({\n citations,\n title = \"Sources\",\n open,\n defaultOpen = false,\n onOpenChange,\n idPrefix,\n className,\n}: CitationsProps) {\n const reduce = useReducedMotion() ?? false;\n const baseId = useId();\n const contentId = `${baseId}-content`;\n const resolvedPrefix = idPrefix ?? `citation-${baseId.replace(/:/g, \"\")}`;\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const currentOpen = open ?? internalOpen;\n const setOpen = useCallback(\n (next: boolean) => {\n if (open === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [onOpenChange, open],\n );\n\n return (\n <div className={cn(\"w-full text-sm\", className)}>\n <button\n type=\"button\"\n aria-expanded={currentOpen}\n aria-controls={contentId}\n onClick={() => setOpen(!currentOpen)}\n className=\"group -ml-1 flex min-h-8 items-center gap-2 rounded-lg px-1 text-left text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <BookOpenText className=\"size-4\" />\n <span className=\"font-medium\">{title}</span>\n <span className=\"rounded-full bg-muted px-1.5 py-0.5 font-semibold text-[10px] tabular-nums\">\n {citations.length}\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/60\"\n >\n <ChevronDown className=\"size-3.5\" />\n </motion.span>\n </button>\n\n <AgentDisclosure id={contentId} open={currentOpen}>\n <CitationList citations={citations} idPrefix={resolvedPrefix} className=\"mt-1\" />\n </AgentDisclosure>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAgDA,SAAS,iBAAiB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AS,iBAAiB,KAAK;CACrC,MAAM,SAAS,MAAM;CACrB,MAAM,YAAY,GAAG,OAAO;CAC5B,MAAM,iBAAiB,YAAY,YAAY,OAAO,QAAQ,MAAM,EAAE;CACtE,MAAM,CAAC,cAAc,mBAAmB,SAAS,WAAW;CAC5D,MAAM,cAAc,QAAQ;CAC5B,MAAM,UAAU,aACb,SAAkB;EACjB,IAAI,SAAS,KAAA,GAAW,gBAAgB,IAAI;EAC5C,eAAe,IAAI;CACrB,GACA,CAAC,cAAc,IAAI,CACrB;CAEA,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,kBAAkB,SAAS;EAA9C,UAAA,CACE,qBAAC,UAAD;GACE,MAAK;GACL,iBAAe;GACf,iBAAe;GACf,eAAe,QAAQ,CAAC,WAAW;GACnC,WAAU;GALZ,UAAA;IAOE,oBAAC,cAAD,EAAc,WAAU,SAAU,CAAA;IAClC,oBAAC,QAAD;KAAM,WAAU;KAAe,UAAA;IAAY,CAAA;IAC3C,oBAAC,QAAD;KAAM,WAAU;KACb,UAAA,UAAU;IACP,CAAA;IACN,oBAAC,OAAO,MAAR;KACE,eAAY;KACZ,SAAS,EAAE,QAAQ,cAAc,MAAM,EAAE;KACzC,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;KACvC,WAAU;KAEV,UAAA,oBAAC,aAAD,EAAa,WAAU,WAAY,CAAA;IACxB,CAAA;GACP;EAER,CAAA,GAAA,oBAAC,iBAAD;GAAiB,IAAI;GAAW,MAAM;GACpC,UAAA,oBAAC,cAAD;IAAyB;IAAW,UAAU;IAAgB,WAAU;GAAQ,CAAA;EACjE,CAAA,CACd;;AAET"}
|
|
1
|
+
{"version":3,"file":"citations.js","names":[],"sources":["../../../src/components/agents/citations.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useId, useState } from \"react\";\nimport { BookOpenText, ChevronDown, ExternalLink, Globe2 } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useFavicon } from \"../../hooks/use-favicon\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from \"../../lib/ease\";\nimport { AgentDisclosure } from \"./agent-disclosure\";\n\nexport interface CitationItem {\n id: string;\n title: ReactNode;\n domain?: ReactNode;\n url?: string;\n}\n\nexport interface CitationsProps {\n citations: CitationItem[];\n title?: ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n idPrefix?: string;\n className?: string;\n}\n\nexport interface CitationProps {\n citationId: string;\n index: number;\n /** Must match the related Citations idPrefix. */\n idPrefix: string;\n className?: string;\n}\n\nexport interface CitationListProps {\n citations: CitationItem[];\n idPrefix?: string;\n className?: string;\n}\n\nexport interface CitationStackProps {\n citations: CitationItem[];\n limit?: number;\n className?: string;\n}\n\nfunction citationTargetId(prefix: string, citationId: string) {\n return `${prefix}-${citationId.replace(/[^a-zA-Z0-9_-]/g, \"-\")}`;\n}\n\nexport function Citation({ citationId, index, idPrefix, className }: CitationProps) {\n return (\n <a\n href={`#${citationTargetId(idPrefix, citationId)}`}\n aria-label={`View citation ${index}`}\n className={cn(\n \"mx-0.5 inline-flex min-w-4 -translate-y-0.5 items-center justify-center rounded-md bg-muted/60 px-1 py-0.5 font-semibold text-[10px] text-muted-foreground leading-none no-underline outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\",\n className,\n )}\n >\n {index}\n </a>\n );\n}\n\nexport function CitationFavicon({ url, className }: { url?: string; className?: string }) {\n const favicon = useFavicon(url);\n\n return (\n <span\n aria-hidden=\"true\"\n className={cn(\"grid size-5 shrink-0 place-items-center text-muted-foreground\", className)}\n >\n {favicon.src ? (\n <img\n ref={favicon.ref}\n src={favicon.src}\n alt=\"\"\n width={16}\n height={16}\n referrerPolicy=\"no-referrer\"\n className=\"size-4 rounded-sm object-contain\"\n />\n ) : (\n <Globe2 className=\"size-3.5\" />\n )}\n </span>\n );\n}\n\nexport function CitationStack({ citations, limit = 3, className }: CitationStackProps) {\n return (\n <span aria-hidden=\"true\" className={cn(\"flex -space-x-1.5\", className)}>\n {citations.slice(0, limit).map((citation) => (\n <CitationFavicon\n key={citation.id}\n url={citation.url}\n className=\"size-6 rounded-full bg-background ring-2 ring-background\"\n />\n ))}\n </span>\n );\n}\n\nfunction CitationRow({\n citation,\n index,\n idPrefix,\n}: {\n citation: CitationItem;\n index: number;\n idPrefix: string;\n}) {\n const content = (\n <>\n <CitationFavicon url={citation.url} />\n <span className=\"flex min-w-0 flex-1 flex-wrap items-baseline gap-x-2 gap-y-0.5\">\n <span className=\"truncate font-medium text-foreground/80 text-sm transition-colors group-hover/citation:text-foreground\">\n {citation.title}\n </span>\n {citation.domain ? (\n <span className=\"min-w-0 truncate text-muted-foreground/60 text-xs\">\n {citation.domain}\n </span>\n ) : null}\n </span>\n <span className=\"flex shrink-0 items-center gap-1.5\">\n <span className=\"grid size-5 place-items-center rounded-md bg-foreground/5 font-semibold text-[10px] text-muted-foreground tabular-nums\">\n {index}\n </span>\n {citation.url ? (\n <ExternalLink className=\"size-3.5 text-muted-foreground/40 transition-colors group-hover/citation:text-muted-foreground\" />\n ) : null}\n </span>\n </>\n );\n const className =\n \"group/citation flex items-center gap-2 rounded-md px-1.5 py-1 outline-none focus-visible:ring-2 focus-visible:ring-ring\";\n const id = citationTargetId(idPrefix, citation.id);\n\n return citation.url ? (\n <a id={id} href={citation.url} target=\"_blank\" rel=\"noreferrer noopener\" className={className}>\n {content}\n </a>\n ) : (\n <div id={id} className={className}>\n {content}\n </div>\n );\n}\n\nexport function CitationList({ citations, idPrefix, className }: CitationListProps) {\n const reduce = useReducedMotion() ?? false;\n const baseId = useId();\n const resolvedPrefix = idPrefix ?? `citation-list-${baseId.replace(/:/g, \"\")}`;\n\n return (\n <div className={cn(\"grid gap-0.5\", className)}>\n <AnimatePresence mode=\"popLayout\">\n {citations.map((citation, index) => (\n <motion.div\n layout=\"position\"\n key={citation.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 >\n <CitationRow citation={citation} index={index + 1} idPrefix={resolvedPrefix} />\n </motion.div>\n ))}\n </AnimatePresence>\n </div>\n );\n}\n\nexport function Citations({\n citations,\n title = \"Sources\",\n open,\n defaultOpen = false,\n onOpenChange,\n idPrefix,\n className,\n}: CitationsProps) {\n const reduce = useReducedMotion() ?? false;\n const baseId = useId();\n const contentId = `${baseId}-content`;\n const resolvedPrefix = idPrefix ?? `citation-${baseId.replace(/:/g, \"\")}`;\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const currentOpen = open ?? internalOpen;\n const setOpen = useCallback(\n (next: boolean) => {\n if (open === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [onOpenChange, open],\n );\n\n return (\n <div className={cn(\"w-full text-sm\", className)}>\n <button\n type=\"button\"\n aria-expanded={currentOpen}\n aria-controls={contentId}\n onClick={() => setOpen(!currentOpen)}\n className=\"group -ml-1 flex min-h-8 items-center gap-2 rounded-lg px-1 text-left text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <BookOpenText className=\"size-4\" />\n <span className=\"font-medium\">{title}</span>\n <span className=\"rounded-full bg-muted px-1.5 py-0.5 font-semibold text-[10px] tabular-nums\">\n {citations.length}\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/60\"\n >\n <ChevronDown className=\"size-3.5\" />\n </motion.span>\n </button>\n\n <AgentDisclosure id={contentId} open={currentOpen}>\n <CitationList citations={citations} idPrefix={resolvedPrefix} className=\"mt-1\" />\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,EACxB,WACA,QAAQ,WACR,MACA,cAAc,OACd,cACA,UACA,aACiB;CACjB,MAAM,SAAS,iBAAiB,KAAK;CACrC,MAAM,SAAS,MAAM;CACrB,MAAM,YAAY,GAAG,OAAO;CAC5B,MAAM,iBAAiB,YAAY,YAAY,OAAO,QAAQ,MAAM,EAAE;CACtE,MAAM,CAAC,cAAc,mBAAmB,SAAS,WAAW;CAC5D,MAAM,cAAc,QAAQ;CAC5B,MAAM,UAAU,aACb,SAAkB;EACjB,IAAI,SAAS,KAAA,GAAW,gBAAgB,IAAI;EAC5C,eAAe,IAAI;CACrB,GACA,CAAC,cAAc,IAAI,CACrB;CAEA,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,kBAAkB,SAAS;EAA9C,UAAA,CACE,qBAAC,UAAD;GACE,MAAK;GACL,iBAAe;GACf,iBAAe;GACf,eAAe,QAAQ,CAAC,WAAW;GACnC,WAAU;GALZ,UAAA;IAOE,oBAAC,cAAD,EAAc,WAAU,SAAU,CAAA;IAClC,oBAAC,QAAD;KAAM,WAAU;KAAe,UAAA;IAAY,CAAA;IAC3C,oBAAC,QAAD;KAAM,WAAU;KACb,UAAA,UAAU;IACP,CAAA;IACN,oBAAC,OAAO,MAAR;KACE,eAAY;KACZ,SAAS,EAAE,QAAQ,cAAc,MAAM,EAAE;KACzC,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;KACvC,WAAU;KAEV,UAAA,oBAAC,aAAD,EAAa,WAAU,WAAY,CAAA;IACxB,CAAA;GACP;EAER,CAAA,GAAA,oBAAC,iBAAD;GAAiB,IAAI;GAAW,MAAM;GACpC,UAAA,oBAAC,cAAD;IAAyB;IAAW,UAAU;IAAgB,WAAU;GAAQ,CAAA;EACjE,CAAA,CACd;;AAET"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { SPRING_PRESS } from "../../lib/ease.js";
|
|
3
3
|
import { AgentCodeLine, useAgentCodeTokens } from "./agent-code.js";
|
|
4
4
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
|
-
import { cn } from "
|
|
5
|
+
import { cn } from "@kumix/utils";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { motion, useReducedMotion } from "motion/react";
|
|
8
8
|
import { Check, Copy, FileCode2, LoaderCircle } from "lucide-react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-block.js","names":[],"sources":["../../../src/components/agents/code-block.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactNode,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"code-block.js","names":[],"sources":["../../../src/components/agents/code-block.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactNode,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Check, Copy, FileCode2, LoaderCircle } from \"lucide-react\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_PRESS } from \"../../lib/ease\";\nimport { type AgentCodeLanguage, AgentCodeLine, useAgentCodeTokens } from \"./agent-code\";\n\nexport type CodeBlockStatus = \"streaming\" | \"complete\";\n\nexport interface CodeBlockProps {\n code: string;\n language?: AgentCodeLanguage;\n filename?: ReactNode;\n status?: CodeBlockStatus;\n showLineNumbers?: boolean;\n highlightLines?: number[];\n maxHeight?: number;\n wrap?: boolean;\n copyable?: boolean;\n onCopy?: () => void | Promise<void>;\n className?: string;\n}\n\nexport function CodeBlock({\n code,\n language = \"typescript\",\n filename,\n status = \"complete\",\n showLineNumbers = true,\n highlightLines = [],\n maxHeight = 280,\n wrap = false,\n copyable = true,\n onCopy,\n className,\n}: CodeBlockProps) {\n const reduce = useReducedMotion() ?? false;\n const viewportRef = useRef<HTMLDivElement>(null);\n const copyTimer = useRef<number | undefined>(undefined);\n const [copied, setCopied] = useState(false);\n const streaming = status === \"streaming\";\n const tokens = useAgentCodeTokens(code, language);\n const highlighted = useMemo(() => new Set(highlightLines), [highlightLines]);\n let offset = 0;\n const lines = code.split(\"\\n\").map((content) => {\n const line = { content, offset };\n offset += content.length + 1;\n return line;\n });\n\n useEffect(\n () => () => {\n if (copyTimer.current) window.clearTimeout(copyTimer.current);\n },\n [],\n );\n\n useLayoutEffect(() => {\n const viewport = viewportRef.current;\n if (!viewport || !streaming) 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 });\n\n const handleCopy = useCallback(async () => {\n if (onCopy) await onCopy();\n else await navigator.clipboard?.writeText(code);\n\n setCopied(true);\n if (copyTimer.current) window.clearTimeout(copyTimer.current);\n copyTimer.current = window.setTimeout(() => setCopied(false), 1600);\n }, [code, onCopy]);\n\n return (\n <div\n data-state={status}\n aria-busy={streaming}\n className={cn(\"w-full overflow-hidden rounded-2xl bg-muted/80 text-sm\", className)}\n >\n <div className=\"flex h-10 items-center gap-2.5 px-3\">\n <FileCode2 aria-hidden=\"true\" className=\"size-3.5 shrink-0 text-muted-foreground/70\" />\n {filename ? (\n <span className=\"min-w-0 truncate font-mono text-foreground/80 text-xs\">{filename}</span>\n ) : null}\n <span className=\"font-medium text-[10px] text-muted-foreground/55 uppercase tracking-wide\">\n {language}\n </span>\n <span\n className={cn(\n \"ml-auto inline-flex shrink-0 items-center gap-1 font-medium text-[10px]\",\n streaming\n ? \"text-blue-600 dark:text-blue-400\"\n : \"text-emerald-600 dark:text-emerald-400\",\n )}\n >\n {streaming ? (\n <LoaderCircle className={cn(\"size-3\", !reduce && \"animate-spin\")} />\n ) : (\n <Check className=\"size-3\" />\n )}\n {streaming ? \"Writing\" : \"Ready\"}\n </span>\n {copyable || onCopy ? (\n <motion.button\n type=\"button\"\n aria-label={copied ? \"Copied\" : \"Copy code\"}\n title={copied ? \"Copied\" : \"Copy code\"}\n onClick={handleCopy}\n whileTap={reduce ? undefined : { scale: 0.9 }}\n transition={SPRING_PRESS}\n className=\"grid size-7 shrink-0 place-items-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-background/70 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {copied ? <Check className=\"size-3.5\" /> : <Copy className=\"size-3.5\" />}\n </motion.button>\n ) : null}\n </div>\n\n <div\n ref={viewportRef}\n role={streaming ? \"log\" : undefined}\n aria-live={streaming ? \"polite\" : undefined}\n className=\"scrollbar-hide overflow-auto border-foreground/6 border-t py-2\"\n style={{ maxHeight }}\n >\n <pre className=\"m-0 min-w-max font-mono text-foreground/85 text-xs leading-5\">\n <code>\n {lines.map((line, index) => {\n const lineNumber = index + 1;\n return (\n <span\n key={line.offset}\n className={cn(\n \"grid min-h-5\",\n showLineNumbers ? \"grid-cols-[2.75rem_minmax(0,1fr)]\" : \"grid-cols-1\",\n highlighted.has(lineNumber) && \"bg-blue-500/[0.07]\",\n )}\n >\n {showLineNumbers ? (\n <span className=\"select-none pr-3 text-right text-muted-foreground/35 tabular-nums\">\n {lineNumber}\n </span>\n ) : null}\n <AgentCodeLine\n code={line.content}\n tokens={tokens?.[index]}\n className={cn(\n \"pr-4\",\n showLineNumbers ? \"pl-1\" : \"pl-4\",\n wrap ? \"wrap-break-word whitespace-pre-wrap\" : \"whitespace-pre\",\n )}\n />\n </span>\n );\n })}\n </code>\n </pre>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAkCA,SAAgB,UAAU,EACxB,MACA,WAAW,cACX,UACA,SAAS,YACT,kBAAkB,MAClB,iBAAiB,CAAC,GAClB,YAAY,KACZ,OAAO,OACP,WAAW,MACX,QACA,aACiB;CACjB,MAAM,SAAS,iBAAiB,KAAK;CACrC,MAAM,cAAc,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KAAK,MAqBN;IAEV,CAAC,EACG,CAAA;GACH,CAAA;EACF,CAAA,CACF;;AAET"}
|
|
@@ -3,7 +3,7 @@ import { SPRING_PRESS, SPRING_SWAP } from "../../lib/ease.js";
|
|
|
3
3
|
import { AgentCodeLine, useAgentCodeTokens } from "./agent-code.js";
|
|
4
4
|
import { AgentDisclosure } from "./agent-disclosure.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 { motion, useReducedMotion } from "motion/react";
|
|
9
9
|
import { Check, ChevronDown, Copy, FileCode2, LoaderCircle } from "lucide-react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-diff.js","names":[],"sources":["../../../src/components/agents/file-diff.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 { Check, ChevronDown, Copy, FileCode2, LoaderCircle } from \"lucide-react\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { SPRING_PRESS, SPRING_SWAP } from \"../../lib/ease\";\nimport { type AgentCodeLanguage, AgentCodeLine, useAgentCodeTokens } from \"./agent-code\";\nimport { AgentDisclosure } from \"./agent-disclosure\";\n\nexport type FileDiffStatus = \"streaming\" | \"complete\";\nexport type FileDiffLineType = \"added\" | \"removed\" | \"context\";\n\nexport interface FileDiffLine {\n id: string;\n type?: FileDiffLineType;\n oldLine?: number;\n newLine?: number;\n content: string;\n}\n\nexport interface FileDiffProps {\n file: ReactNode;\n lines: FileDiffLine[];\n status?: FileDiffStatus;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n collapseOnComplete?: boolean;\n maxHeight?: number;\n language?: AgentCodeLanguage;\n copyText?: string;\n onCopy?: () => void | Promise<void>;\n className?: string;\n}\n\nfunction ChangeCount({ value, type }: { value: number; type: \"added\" | \"removed\" }) {\n if (!value) return null;\n return (\n <span\n className={cn(\n \"font-mono text-xs tabular-nums\",\n type === \"added\"\n ? \"text-emerald-600 dark:text-emerald-400\"\n : \"text-rose-600 dark:text-rose-400\",\n )}\n >\n {type === \"added\" ? \"+\" : \"−\"}\n {value}\n </span>\n );\n}\n\nexport function FileDiff({\n file,\n lines,\n status = \"streaming\",\n open,\n defaultOpen = true,\n onOpenChange,\n collapseOnComplete = true,\n maxHeight = 220,\n language = \"typescript\",\n copyText,\n onCopy,\n className,\n}: FileDiffProps) {\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 previousStatus = useRef(status);\n const copyTimer = useRef<number | undefined>(undefined);\n const [copied, setCopied] = useState(false);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const currentOpen = open ?? internalOpen;\n const streaming = status === \"streaming\";\n const additions = lines.filter((line) => line.type === \"added\").length;\n const deletions = lines.filter((line) => line.type === \"removed\").length;\n const canCopy = Boolean(copyText || onCopy);\n const code = lines.map((line) => line.content).join(\"\\n\");\n const tokens = useAgentCodeTokens(code, language);\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 (previousStatus.current !== \"streaming\" && status === \"streaming\") {\n setOpen(true);\n }\n if (previousStatus.current === \"streaming\" && status === \"complete\" && collapseOnComplete) {\n setOpen(false);\n }\n previousStatus.current = status;\n }, [collapseOnComplete, setOpen, status]);\n\n useEffect(\n () => () => {\n if (copyTimer.current) window.clearTimeout(copyTimer.current);\n },\n [],\n );\n\n useLayoutEffect(() => {\n const viewport = viewportRef.current;\n if (!viewport || !currentOpen || !streaming) 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 });\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 return (\n <div data-state={status} aria-busy={streaming} className={cn(\"w-full text-sm\", className)}>\n <button\n id={triggerId}\n type=\"button\"\n aria-expanded={currentOpen}\n aria-controls={contentId}\n onClick={() => setOpen(!currentOpen)}\n className=\"group flex min-h-9 w-full items-center gap-2 rounded-md py-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\"\n >\n <FileCode2 aria-hidden=\"true\" className=\"size-4 shrink-0 text-muted-foreground\" />\n <span className=\"min-w-0 flex-1 truncate font-mono text-foreground/80 text-xs\">{file}</span>\n <span className=\"flex shrink-0 items-center gap-2\">\n <ChangeCount value={additions} type=\"added\" />\n <ChangeCount value={deletions} type=\"removed\" />\n </span>\n <span className=\"grid size-4 shrink-0 place-items-center text-muted-foreground/60\">\n {streaming ? (\n <LoaderCircle\n aria-label=\"Applying changes\"\n className={cn(\"size-3.5\", !reduce && \"animate-spin\")}\n />\n ) : (\n <Check aria-label=\"Changes applied\" className=\"size-3.5\" />\n )}\n </span>\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotate: currentOpen ? 180 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n className=\"shrink-0 text-muted-foreground/45 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 className=\"pt-1.5 pl-6\">\n <div className=\"overflow-hidden rounded-xl bg-muted/80\">\n <div\n ref={viewportRef}\n data-slot=\"file-diff-viewport\"\n aria-live=\"polite\"\n className=\"scrollbar-hide overflow-auto\"\n style={{ maxHeight }}\n >\n <div className=\"font-mono text-xs leading-5\">\n <span className=\"sr-only\">File changes</span>\n {lines.map((line, index) => {\n const type = line.type ?? \"context\";\n return (\n <div\n key={line.id}\n className={cn(\n \"grid grid-cols-[2.25rem_2.25rem_1rem_minmax(0,1fr)]\",\n type === \"added\" && \"bg-emerald-500/[0.07]\",\n type === \"removed\" && \"bg-rose-500/[0.07]\",\n )}\n >\n <span className=\"select-none pr-2 text-right text-muted-foreground/40 tabular-nums\">\n {line.oldLine}\n </span>\n <span className=\"select-none pr-2 text-right text-muted-foreground/40 tabular-nums\">\n {line.newLine}\n </span>\n <span\n className={cn(\n \"select-none text-center text-muted-foreground/45\",\n type === \"added\" && \"text-emerald-600 dark:text-emerald-400\",\n type === \"removed\" && \"text-rose-600 dark:text-rose-400\",\n )}\n >\n {type === \"added\" ? \"+\" : type === \"removed\" ? \"−\" : \"\"}\n </span>\n <AgentCodeLine\n code={line.content}\n tokens={tokens?.[index]}\n className=\"min-w-0 whitespace-pre px-1.5\"\n />\n </div>\n );\n })}\n </div>\n </div>\n\n {canCopy ? (\n <div className=\"flex justify-end px-2 pt-1 pb-1.5\">\n <motion.button\n type=\"button\"\n aria-label={copied ? \"Copied\" : \"Copy diff\"}\n title={copied ? \"Copied\" : \"Copy diff\"}\n onClick={handleCopy}\n whileTap={reduce ? undefined : { scale: 0.9 }}\n transition={SPRING_PRESS}\n className=\"grid size-7 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-background/70 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {copied ? <Check className=\"size-3.5\" /> : <Copy className=\"size-3.5\" />}\n </motion.button>\n </div>\n ) : null}\n </div>\n </div>\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M,KAAK;WACX,QAAQ,SAAS;WACjB,WAAU;UACX,CAAA;SACE;QA3BE,GAAA,KAAK,EA2BP;OAET,CAAC,CACE;;KACF,CAAA,GAEJ,UACC,oBAAC,OAAD;MAAK,WAAU;MACb,UAAA,oBAAC,OAAO,QAAR;OACE,MAAK;OACL,cAAY,SAAS,WAAW;OAChC,OAAO,SAAS,WAAW;OAC3B,SAAS;OACT,UAAU,SAAS,KAAA,IAAY,EAAE,OAAO,GAAI;OAC5C,YAAY;OACZ,WAAU;OAET,UAAA,SAAS,oBAAC,OAAD,EAAO,WAAU,WAAY,CAAA,IAAI,oBAAC,MAAD,EAAM,WAAU,WAAY,CAAA;MAC1D,CAAA;KACZ,CAAA,IACH,IACD;;GACF,CAAA;EACU,CAAA,CACd;;AAET"}
|
|
1
|
+
{"version":3,"file":"file-diff.js","names":[],"sources":["../../../src/components/agents/file-diff.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 { Check, ChevronDown, Copy, FileCode2, LoaderCircle } from \"lucide-react\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_PRESS, SPRING_SWAP } from \"../../lib/ease\";\nimport { type AgentCodeLanguage, AgentCodeLine, useAgentCodeTokens } from \"./agent-code\";\nimport { AgentDisclosure } from \"./agent-disclosure\";\n\nexport type FileDiffStatus = \"streaming\" | \"complete\";\nexport type FileDiffLineType = \"added\" | \"removed\" | \"context\";\n\nexport interface FileDiffLine {\n id: string;\n type?: FileDiffLineType;\n oldLine?: number;\n newLine?: number;\n content: string;\n}\n\nexport interface FileDiffProps {\n file: ReactNode;\n lines: FileDiffLine[];\n status?: FileDiffStatus;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n collapseOnComplete?: boolean;\n maxHeight?: number;\n language?: AgentCodeLanguage;\n copyText?: string;\n onCopy?: () => void | Promise<void>;\n className?: string;\n}\n\nfunction ChangeCount({ value, type }: { value: number; type: \"added\" | \"removed\" }) {\n if (!value) return null;\n return (\n <span\n className={cn(\n \"font-mono text-xs tabular-nums\",\n type === \"added\"\n ? \"text-emerald-600 dark:text-emerald-400\"\n : \"text-rose-600 dark:text-rose-400\",\n )}\n >\n {type === \"added\" ? \"+\" : \"−\"}\n {value}\n </span>\n );\n}\n\nexport function FileDiff({\n file,\n lines,\n status = \"streaming\",\n open,\n defaultOpen = true,\n onOpenChange,\n collapseOnComplete = true,\n maxHeight = 220,\n language = \"typescript\",\n copyText,\n onCopy,\n className,\n}: FileDiffProps) {\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 previousStatus = useRef(status);\n const copyTimer = useRef<number | undefined>(undefined);\n const [copied, setCopied] = useState(false);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const currentOpen = open ?? internalOpen;\n const streaming = status === \"streaming\";\n const additions = lines.filter((line) => line.type === \"added\").length;\n const deletions = lines.filter((line) => line.type === \"removed\").length;\n const canCopy = Boolean(copyText || onCopy);\n const code = lines.map((line) => line.content).join(\"\\n\");\n const tokens = useAgentCodeTokens(code, language);\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 (previousStatus.current !== \"streaming\" && status === \"streaming\") {\n setOpen(true);\n }\n if (previousStatus.current === \"streaming\" && status === \"complete\" && collapseOnComplete) {\n setOpen(false);\n }\n previousStatus.current = status;\n }, [collapseOnComplete, setOpen, status]);\n\n useEffect(\n () => () => {\n if (copyTimer.current) window.clearTimeout(copyTimer.current);\n },\n [],\n );\n\n useLayoutEffect(() => {\n const viewport = viewportRef.current;\n if (!viewport || !currentOpen || !streaming) 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 });\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 return (\n <div data-state={status} aria-busy={streaming} className={cn(\"w-full text-sm\", className)}>\n <button\n id={triggerId}\n type=\"button\"\n aria-expanded={currentOpen}\n aria-controls={contentId}\n onClick={() => setOpen(!currentOpen)}\n className=\"group flex min-h-9 w-full items-center gap-2 rounded-md py-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\"\n >\n <FileCode2 aria-hidden=\"true\" className=\"size-4 shrink-0 text-muted-foreground\" />\n <span className=\"min-w-0 flex-1 truncate font-mono text-foreground/80 text-xs\">{file}</span>\n <span className=\"flex shrink-0 items-center gap-2\">\n <ChangeCount value={additions} type=\"added\" />\n <ChangeCount value={deletions} type=\"removed\" />\n </span>\n <span className=\"grid size-4 shrink-0 place-items-center text-muted-foreground/60\">\n {streaming ? (\n <LoaderCircle\n aria-label=\"Applying changes\"\n className={cn(\"size-3.5\", !reduce && \"animate-spin\")}\n />\n ) : (\n <Check aria-label=\"Changes applied\" className=\"size-3.5\" />\n )}\n </span>\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotate: currentOpen ? 180 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n className=\"shrink-0 text-muted-foreground/45 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 className=\"pt-1.5 pl-6\">\n <div className=\"overflow-hidden rounded-xl bg-muted/80\">\n <div\n ref={viewportRef}\n data-slot=\"file-diff-viewport\"\n aria-live=\"polite\"\n className=\"scrollbar-hide overflow-auto\"\n style={{ maxHeight }}\n >\n <div className=\"font-mono text-xs leading-5\">\n <span className=\"sr-only\">File changes</span>\n {lines.map((line, index) => {\n const type = line.type ?? \"context\";\n return (\n <div\n key={line.id}\n className={cn(\n \"grid grid-cols-[2.25rem_2.25rem_1rem_minmax(0,1fr)]\",\n type === \"added\" && \"bg-emerald-500/[0.07]\",\n type === \"removed\" && \"bg-rose-500/[0.07]\",\n )}\n >\n <span className=\"select-none pr-2 text-right text-muted-foreground/40 tabular-nums\">\n {line.oldLine}\n </span>\n <span className=\"select-none pr-2 text-right text-muted-foreground/40 tabular-nums\">\n {line.newLine}\n </span>\n <span\n className={cn(\n \"select-none text-center text-muted-foreground/45\",\n type === \"added\" && \"text-emerald-600 dark:text-emerald-400\",\n type === \"removed\" && \"text-rose-600 dark:text-rose-400\",\n )}\n >\n {type === \"added\" ? \"+\" : type === \"removed\" ? \"−\" : \"\"}\n </span>\n <AgentCodeLine\n code={line.content}\n tokens={tokens?.[index]}\n className=\"min-w-0 whitespace-pre px-1.5\"\n />\n </div>\n );\n })}\n </div>\n </div>\n\n {canCopy ? (\n <div className=\"flex justify-end px-2 pt-1 pb-1.5\">\n <motion.button\n type=\"button\"\n aria-label={copied ? \"Copied\" : \"Copy diff\"}\n title={copied ? \"Copied\" : \"Copy diff\"}\n onClick={handleCopy}\n whileTap={reduce ? undefined : { scale: 0.9 }}\n transition={SPRING_PRESS}\n className=\"grid size-7 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-background/70 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {copied ? <Check className=\"size-3.5\" /> : <Copy className=\"size-3.5\" />}\n </motion.button>\n </div>\n ) : null}\n </div>\n </div>\n </AgentD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;WACX,QAAQ,SAAS;WACjB,WAAU;UACX,CAAA;SACE;QA3BE,GAAA,KAAK,EA2BP;OAET,CAAC,CACE;;KACF,CAAA,GAEJ,UACC,oBAAC,OAAD;MAAK,WAAU;MACb,UAAA,oBAAC,OAAO,QAAR;OACE,MAAK;OACL,cAAY,SAAS,WAAW;OAChC,OAAO,SAAS,WAAW;OAC3B,SAAS;OACT,UAAU,SAAS,KAAA,IAAY,EAAE,OAAO,GAAI;OAC5C,YAAY;OACZ,WAAU;OAET,UAAA,SAAS,oBAAC,OAAD,EAAO,WAAU,WAAY,CAAA,IAAI,oBAAC,MAAD,EAAM,WAAU,WAAY,CAAA;MAC1D,CAAA;KACZ,CAAA,IACH,IACD;;GACF,CAAA;EACU,CAAA,CACd;;AAET"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useHoverCapable } from "../../hooks/use-hover-capable.js";
|
|
3
3
|
import { EASE_IN_OUT, EASE_OUT, SPRING_PRESS } from "../../lib/ease.js";
|
|
4
4
|
import { useEffect, useRef } from "react";
|
|
5
|
-
import { cn } from "
|
|
5
|
+
import { cn } from "@kumix/utils";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
8
8
|
import { Check, CircleAlert, RotateCcw } from "lucide-react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-generation.js","names":[],"sources":["../../../src/components/agents/image-generation.tsx"],"sourcesContent":["\"use client\";\n\nimport type { CSSProperties, ReactNode } from \"react\";\nimport { useEffect, useRef } from \"react\";\nimport { cn } from \"cn\";\nimport { Check, CircleAlert, RotateCcw } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { useHoverCapable } from \"../../hooks/use-hover-capable\";\nimport { EASE_IN_OUT, EASE_OUT, SPRING_PRESS } from \"../../lib/ease\";\n\nexport type ImageGenerationStatus = \"queued\" | \"generating\" | \"refining\" | \"complete\" | \"error\";\n\nexport interface ImageGenerationProps {\n /** The completed media. Pass an img, Next Image, canvas, video, or custom preview. */\n children?: ReactNode;\n status?: ImageGenerationStatus;\n /** Accessible description. Defaults to a description derived from prompt. */\n label?: string;\n prompt?: string;\n resolution?: string;\n /** CSS aspect ratio reserved before generated media is available. */\n aspectRatio?: CSSProperties[\"aspectRatio\"];\n size?: \"compact\" | \"fluid\";\n /** Lets the active dither cluster follow fine-pointer movement. */\n interactive?: boolean;\n statusText?: string;\n showStatus?: boolean;\n onRetry?: () => void;\n className?: string;\n mediaClassName?: string;\n statusClassName?: string;\n}\n\nconst STATUS_TEXT: Record<ImageGenerationStatus, string> = {\n queued: \"Waiting to generate\",\n generating: \"Generating image\",\n refining: \"Refining details\",\n complete: \"Image ready\",\n error: \"Generation failed\",\n};\n\nconst MEDIA_STATE: Record<\n ImageGenerationStatus,\n { filter: string; opacity: number; scale: number }\n> = {\n queued: { filter: \"blur(4px) saturate(0.75)\", opacity: 0, scale: 1.02 },\n generating: { filter: \"blur(3px) saturate(0.85)\", opacity: 0, scale: 1.015 },\n refining: { filter: \"blur(1.5px) saturate(0.95)\", opacity: 0.62, scale: 1.005 },\n complete: { filter: \"blur(0px) saturate(1)\", opacity: 1, scale: 1 },\n error: { filter: \"blur(2px) saturate(0.5)\", opacity: 0.28, scale: 1 },\n};\n\nconst OVERLAY_OPACITY: Record<ImageGenerationStatus, number> = {\n queued: 1,\n generating: 1,\n refining: 0.48,\n complete: 0,\n error: 0,\n};\n\nconst DOT_GAP = 10;\nconst TWO_PI = Math.PI * 2;\n\nfunction DitherMark({ status, reduce }: { status: ImageGenerationStatus; reduce: boolean }) {\n if (status === \"complete\") {\n return <Check aria-hidden=\"true\" className=\"size-3.5\" />;\n }\n\n if (status === \"error\") {\n return <CircleAlert aria-hidden=\"true\" className=\"size-3.5\" />;\n }\n\n return (\n <motion.span\n aria-hidden=\"true\"\n animate={reduce ? undefined : { rotate: 360 }}\n transition={{\n duration: 2.4,\n ease: EASE_IN_OUT,\n repeat: Number.POSITIVE_INFINITY,\n }}\n className=\"grid size-3.5 grid-cols-2 place-items-center gap-0.5\"\n >\n <span className=\"size-1 rounded-[1px] bg-current\" />\n <span className=\"size-1 rounded-[1px] bg-current opacity-55\" />\n <span className=\"size-1 rounded-[1px] bg-current opacity-55\" />\n <span className=\"size-1 rounded-[1px] bg-current\" />\n </motion.span>\n );\n}\n\nfunction DitherField({\n interactive,\n reduce,\n status,\n}: {\n interactive: boolean;\n reduce: boolean;\n status: ImageGenerationStatus;\n}) {\n const canHover = useHoverCapable();\n const canvasRef = useRef<HTMLCanvasElement>(null);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n const context = canvas?.getContext(\"2d\");\n if (!canvas || !context) return;\n\n let frame = 0;\n let width = 0;\n let height = 0;\n let dotColor = \"currentColor\";\n const pointer = {\n x: 0,\n y: 0,\n targetX: 0,\n targetY: 0,\n inside: false,\n };\n const pointerEnabled = interactive && canHover && !reduce;\n\n const resize = () => {\n const rect = canvas.getBoundingClientRect();\n width = rect.width || canvas.clientWidth || 208;\n height = rect.height || canvas.clientHeight || 208;\n const dpr = Math.min(window.devicePixelRatio || 1, 2);\n\n canvas.width = Math.round(width * dpr);\n canvas.height = Math.round(height * dpr);\n context.setTransform(dpr, 0, 0, dpr, 0, 0);\n dotColor = window.getComputedStyle(canvas).color;\n pointer.x = width / 2;\n pointer.y = height / 2;\n pointer.targetX = pointer.x;\n pointer.targetY = pointer.y;\n };\n\n const draw = (time: number) => {\n context.clearRect(0, 0, width, height);\n\n if (!pointer.inside) {\n pointer.targetX = width / 2 + (reduce ? 0 : Math.sin(time / 1700) * width * 0.12);\n pointer.targetY = height / 2 + (reduce ? 0 : Math.cos(time / 2100) * height * 0.1);\n }\n\n const follow = reduce ? 1 : pointer.inside ? 0.16 : 0.045;\n pointer.x += (pointer.targetX - pointer.x) * follow;\n pointer.y += (pointer.targetY - pointer.y) * follow;\n\n const radius = Math.min(width, height) * 0.38;\n const columns = Math.ceil(width / DOT_GAP) + 1;\n const rows = Math.ceil(height / DOT_GAP) + 1;\n const offsetX = (width - (columns - 1) * DOT_GAP) / 2;\n const offsetY = (height - (rows - 1) * DOT_GAP) / 2;\n\n context.fillStyle = dotColor;\n\n for (let row = 0; row < rows; row += 1) {\n for (let column = 0; column < columns; column += 1) {\n const anchorX = offsetX + column * DOT_GAP;\n const anchorY = offsetY + row * DOT_GAP;\n const deltaX = anchorX - pointer.x;\n const deltaY = anchorY - pointer.y;\n const distance = Math.hypot(deltaX, deltaY);\n const proximity = Math.max(0, 1 - distance / radius);\n const influence = proximity * proximity * (3 - 2 * proximity);\n const displacement = influence * influence * 9;\n const directionX = distance > 0 ? deltaX / distance : 0;\n const directionY = distance > 0 ? deltaY / distance : 0;\n const x = anchorX + directionX * displacement;\n const y = anchorY + directionY * displacement;\n const dotRadius = 0.65 + influence * 0.85;\n\n context.globalAlpha = 0.17 + influence * 0.72;\n context.beginPath();\n context.arc(x, y, dotRadius, 0, TWO_PI);\n context.fill();\n }\n }\n\n context.globalAlpha = 1;\n if (!reduce) frame = window.requestAnimationFrame(draw);\n };\n\n const handlePointerMove = (event: PointerEvent) => {\n if (!pointerEnabled) return;\n const rect = canvas.getBoundingClientRect();\n pointer.inside = true;\n pointer.targetX = event.clientX - rect.left;\n pointer.targetY = event.clientY - rect.top;\n };\n\n const handlePointerLeave = () => {\n pointer.inside = false;\n };\n\n const resizeObserver =\n typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(resize);\n\n resize();\n resizeObserver?.observe(canvas);\n canvas.addEventListener(\"pointermove\", handlePointerMove, { passive: true });\n canvas.addEventListener(\"pointerleave\", handlePointerLeave);\n draw(0);\n\n return () => {\n if (frame) window.cancelAnimationFrame(frame);\n resizeObserver?.disconnect();\n canvas.removeEventListener(\"pointermove\", handlePointerMove);\n canvas.removeEventListener(\"pointerleave\", handlePointerLeave);\n };\n }, [canHover, interactive, reduce]);\n\n return (\n <motion.div\n aria-hidden=\"true\"\n initial={false}\n animate={{ opacity: OVERLAY_OPACITY[status] }}\n transition={{ duration: reduce ? 0 : 0.4, ease: EASE_OUT }}\n className=\"absolute inset-0 overflow-hidden bg-muted\"\n >\n <canvas ref={canvasRef} className=\"absolute inset-0 size-full text-foreground\" />\n </motion.div>\n );\n}\n\nexport function ImageGeneration({\n children,\n status = \"generating\",\n label,\n prompt,\n resolution = \"1024 × 1024\",\n aspectRatio = \"1 / 1\",\n size = \"compact\",\n interactive = true,\n statusText,\n showStatus = true,\n onRetry,\n className,\n mediaClassName,\n statusClassName,\n}: ImageGenerationProps) {\n const reduce = useReducedMotion() ?? false;\n const active = status === \"queued\" || status === \"generating\" || status === \"refining\";\n const mediaState = MEDIA_STATE[status];\n const resolvedStatusText = statusText ?? STATUS_TEXT[status];\n const resolvedLabel = label ?? (prompt ? `${resolvedStatusText}: ${prompt}` : resolvedStatusText);\n\n return (\n <div\n data-slot=\"image-generation\"\n data-state={status}\n aria-busy={active}\n className={cn(\"w-full\", className)}\n >\n <div className={cn(\"w-full\", size === \"compact\" && \"mx-auto max-w-52\")}>\n <div\n role=\"img\"\n aria-label={resolvedLabel}\n style={{ aspectRatio }}\n className=\"relative isolate w-full overflow-hidden rounded-xl bg-muted\"\n >\n <motion.div\n aria-hidden={children ? undefined : true}\n initial={false}\n animate={\n reduce\n ? { opacity: mediaState.opacity }\n : {\n filter: mediaState.filter,\n opacity: mediaState.opacity,\n scale: mediaState.scale,\n }\n }\n transition={reduce ? { duration: 0 } : { duration: 0.4, ease: EASE_OUT }}\n className={cn(\n \"absolute inset-0 *:size-full *:object-cover [&_img]:size-full [&_img]:object-cover\",\n mediaClassName,\n )}\n >\n {children}\n </motion.div>\n\n <AnimatePresence initial={false}>\n {active ? (\n <motion.div\n key=\"dither-field\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={{ duration: reduce ? 0 : 0.25, ease: EASE_OUT }}\n className=\"absolute inset-0\"\n >\n <DitherField interactive={interactive} reduce={reduce} status={status} />\n </motion.div>\n ) : null}\n </AnimatePresence>\n\n {resolution ? (\n <span className=\"absolute top-2 right-2 z-10 rounded-full bg-background/75 px-2 py-0.5 font-mono text-[10px] text-muted-foreground tabular-nums\">\n {resolution}\n </span>\n ) : null}\n </div>\n\n {showStatus || prompt ? (\n <div className=\"mt-3 text-left\">\n {showStatus ? (\n <div\n aria-live=\"polite\"\n className={cn(\n \"flex min-h-5 items-center gap-2 font-medium text-foreground text-sm\",\n status === \"error\" && \"text-destructive\",\n statusClassName,\n )}\n >\n <DitherMark status={status} reduce={reduce} />\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.span\n key={resolvedStatusText}\n initial={reduce ? false : { opacity: 0, y: 4 }}\n animate={{ opacity: 1, y: 0 }}\n exit={reduce ? undefined : { opacity: 0, y: -4 }}\n transition={{\n duration: reduce ? 0 : 0.15,\n ease: EASE_OUT,\n }}\n >\n {resolvedStatusText}\n </motion.span>\n </AnimatePresence>\n </div>\n ) : null}\n {prompt ? (\n <p className=\"mt-0.5 truncate text-muted-foreground text-xs\">“{prompt}”</p>\n ) : null}\n </div>\n ) : null}\n\n {status === \"error\" && onRetry ? (\n <motion.button\n type=\"button\"\n onClick={onRetry}\n whileTap={reduce ? undefined : { scale: 0.96 }}\n transition={SPRING_PRESS}\n className=\"mt-3 inline-flex min-h-10 items-center gap-2 rounded-full px-3 font-medium text-foreground text-sm outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <RotateCcw aria-hidden=\"true\" className=\"size-4\" />\n Try again\n </motion.button>\n ) : null}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAkCA,MAAM,cAAqD;CACzD,QAAQ;CACR,YAAY;CACZ,UAAU;CACV,UAAU;CACV,OAAO;AACT;AAEA,MAAM,cAGF;CACF,QAAQ;EAAE,QAAQ;EAA4B,SAAS;EAAG,OAAO;CAAK;CACtE,YAAY;EAAE,QAAQ;EAA4B,SAAS;E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AAK;KAC7C,YAAY;KACZ,WAAU;KALZ,UAAA,CAOE,oBAAC,WAAD;MAAW,eAAY;MAAO,WAAU;KAAU,CAAA,GAAC,WAEtC;IACb,CAAA,IAAA;GACD;;CACF,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"image-generation.js","names":[],"sources":["../../../src/components/agents/image-generation.tsx"],"sourcesContent":["\"use client\";\n\nimport type { CSSProperties, ReactNode } from \"react\";\nimport { useEffect, useRef } from \"react\";\nimport { Check, CircleAlert, RotateCcw } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../hooks/use-hover-capable\";\nimport { EASE_IN_OUT, EASE_OUT, SPRING_PRESS } from \"../../lib/ease\";\n\nexport type ImageGenerationStatus = \"queued\" | \"generating\" | \"refining\" | \"complete\" | \"error\";\n\nexport interface ImageGenerationProps {\n /** The completed media. Pass an img, Next Image, canvas, video, or custom preview. */\n children?: ReactNode;\n status?: ImageGenerationStatus;\n /** Accessible description. Defaults to a description derived from prompt. */\n label?: string;\n prompt?: string;\n resolution?: string;\n /** CSS aspect ratio reserved before generated media is available. */\n aspectRatio?: CSSProperties[\"aspectRatio\"];\n size?: \"compact\" | \"fluid\";\n /** Lets the active dither cluster follow fine-pointer movement. */\n interactive?: boolean;\n statusText?: string;\n showStatus?: boolean;\n onRetry?: () => void;\n className?: string;\n mediaClassName?: string;\n statusClassName?: string;\n}\n\nconst STATUS_TEXT: Record<ImageGenerationStatus, string> = {\n queued: \"Waiting to generate\",\n generating: \"Generating image\",\n refining: \"Refining details\",\n complete: \"Image ready\",\n error: \"Generation failed\",\n};\n\nconst MEDIA_STATE: Record<\n ImageGenerationStatus,\n { filter: string; opacity: number; scale: number }\n> = {\n queued: { filter: \"blur(4px) saturate(0.75)\", opacity: 0, scale: 1.02 },\n generating: { filter: \"blur(3px) saturate(0.85)\", opacity: 0, scale: 1.015 },\n refining: { filter: \"blur(1.5px) saturate(0.95)\", opacity: 0.62, scale: 1.005 },\n complete: { filter: \"blur(0px) saturate(1)\", opacity: 1, scale: 1 },\n error: { filter: \"blur(2px) saturate(0.5)\", opacity: 0.28, scale: 1 },\n};\n\nconst OVERLAY_OPACITY: Record<ImageGenerationStatus, number> = {\n queued: 1,\n generating: 1,\n refining: 0.48,\n complete: 0,\n error: 0,\n};\n\nconst DOT_GAP = 10;\nconst TWO_PI = Math.PI * 2;\n\nfunction DitherMark({ status, reduce }: { status: ImageGenerationStatus; reduce: boolean }) {\n if (status === \"complete\") {\n return <Check aria-hidden=\"true\" className=\"size-3.5\" />;\n }\n\n if (status === \"error\") {\n return <CircleAlert aria-hidden=\"true\" className=\"size-3.5\" />;\n }\n\n return (\n <motion.span\n aria-hidden=\"true\"\n animate={reduce ? undefined : { rotate: 360 }}\n transition={{\n duration: 2.4,\n ease: EASE_IN_OUT,\n repeat: Number.POSITIVE_INFINITY,\n }}\n className=\"grid size-3.5 grid-cols-2 place-items-center gap-0.5\"\n >\n <span className=\"size-1 rounded-[1px] bg-current\" />\n <span className=\"size-1 rounded-[1px] bg-current opacity-55\" />\n <span className=\"size-1 rounded-[1px] bg-current opacity-55\" />\n <span className=\"size-1 rounded-[1px] bg-current\" />\n </motion.span>\n );\n}\n\nfunction DitherField({\n interactive,\n reduce,\n status,\n}: {\n interactive: boolean;\n reduce: boolean;\n status: ImageGenerationStatus;\n}) {\n const canHover = useHoverCapable();\n const canvasRef = useRef<HTMLCanvasElement>(null);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n const context = canvas?.getContext(\"2d\");\n if (!canvas || !context) return;\n\n let frame = 0;\n let width = 0;\n let height = 0;\n let dotColor = \"currentColor\";\n const pointer = {\n x: 0,\n y: 0,\n targetX: 0,\n targetY: 0,\n inside: false,\n };\n const pointerEnabled = interactive && canHover && !reduce;\n\n const resize = () => {\n const rect = canvas.getBoundingClientRect();\n width = rect.width || canvas.clientWidth || 208;\n height = rect.height || canvas.clientHeight || 208;\n const dpr = Math.min(window.devicePixelRatio || 1, 2);\n\n canvas.width = Math.round(width * dpr);\n canvas.height = Math.round(height * dpr);\n context.setTransform(dpr, 0, 0, dpr, 0, 0);\n dotColor = window.getComputedStyle(canvas).color;\n pointer.x = width / 2;\n pointer.y = height / 2;\n pointer.targetX = pointer.x;\n pointer.targetY = pointer.y;\n };\n\n const draw = (time: number) => {\n context.clearRect(0, 0, width, height);\n\n if (!pointer.inside) {\n pointer.targetX = width / 2 + (reduce ? 0 : Math.sin(time / 1700) * width * 0.12);\n pointer.targetY = height / 2 + (reduce ? 0 : Math.cos(time / 2100) * height * 0.1);\n }\n\n const follow = reduce ? 1 : pointer.inside ? 0.16 : 0.045;\n pointer.x += (pointer.targetX - pointer.x) * follow;\n pointer.y += (pointer.targetY - pointer.y) * follow;\n\n const radius = Math.min(width, height) * 0.38;\n const columns = Math.ceil(width / DOT_GAP) + 1;\n const rows = Math.ceil(height / DOT_GAP) + 1;\n const offsetX = (width - (columns - 1) * DOT_GAP) / 2;\n const offsetY = (height - (rows - 1) * DOT_GAP) / 2;\n\n context.fillStyle = dotColor;\n\n for (let row = 0; row < rows; row += 1) {\n for (let column = 0; column < columns; column += 1) {\n const anchorX = offsetX + column * DOT_GAP;\n const anchorY = offsetY + row * DOT_GAP;\n const deltaX = anchorX - pointer.x;\n const deltaY = anchorY - pointer.y;\n const distance = Math.hypot(deltaX, deltaY);\n const proximity = Math.max(0, 1 - distance / radius);\n const influence = proximity * proximity * (3 - 2 * proximity);\n const displacement = influence * influence * 9;\n const directionX = distance > 0 ? deltaX / distance : 0;\n const directionY = distance > 0 ? deltaY / distance : 0;\n const x = anchorX + directionX * displacement;\n const y = anchorY + directionY * displacement;\n const dotRadius = 0.65 + influence * 0.85;\n\n context.globalAlpha = 0.17 + influence * 0.72;\n context.beginPath();\n context.arc(x, y, dotRadius, 0, TWO_PI);\n context.fill();\n }\n }\n\n context.globalAlpha = 1;\n if (!reduce) frame = window.requestAnimationFrame(draw);\n };\n\n const handlePointerMove = (event: PointerEvent) => {\n if (!pointerEnabled) return;\n const rect = canvas.getBoundingClientRect();\n pointer.inside = true;\n pointer.targetX = event.clientX - rect.left;\n pointer.targetY = event.clientY - rect.top;\n };\n\n const handlePointerLeave = () => {\n pointer.inside = false;\n };\n\n const resizeObserver =\n typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(resize);\n\n resize();\n resizeObserver?.observe(canvas);\n canvas.addEventListener(\"pointermove\", handlePointerMove, { passive: true });\n canvas.addEventListener(\"pointerleave\", handlePointerLeave);\n draw(0);\n\n return () => {\n if (frame) window.cancelAnimationFrame(frame);\n resizeObserver?.disconnect();\n canvas.removeEventListener(\"pointermove\", handlePointerMove);\n canvas.removeEventListener(\"pointerleave\", handlePointerLeave);\n };\n }, [canHover, interactive, reduce]);\n\n return (\n <motion.div\n aria-hidden=\"true\"\n initial={false}\n animate={{ opacity: OVERLAY_OPACITY[status] }}\n transition={{ duration: reduce ? 0 : 0.4, ease: EASE_OUT }}\n className=\"absolute inset-0 overflow-hidden bg-muted\"\n >\n <canvas ref={canvasRef} className=\"absolute inset-0 size-full text-foreground\" />\n </motion.div>\n );\n}\n\nexport function ImageGeneration({\n children,\n status = \"generating\",\n label,\n prompt,\n resolution = \"1024 × 1024\",\n aspectRatio = \"1 / 1\",\n size = \"compact\",\n interactive = true,\n statusText,\n showStatus = true,\n onRetry,\n className,\n mediaClassName,\n statusClassName,\n}: ImageGenerationProps) {\n const reduce = useReducedMotion() ?? false;\n const active = status === \"queued\" || status === \"generating\" || status === \"refining\";\n const mediaState = MEDIA_STATE[status];\n const resolvedStatusText = statusText ?? STATUS_TEXT[status];\n const resolvedLabel = label ?? (prompt ? `${resolvedStatusText}: ${prompt}` : resolvedStatusText);\n\n return (\n <div\n data-slot=\"image-generation\"\n data-state={status}\n aria-busy={active}\n className={cn(\"w-full\", className)}\n >\n <div className={cn(\"w-full\", size === \"compact\" && \"mx-auto max-w-52\")}>\n <div\n role=\"img\"\n aria-label={resolvedLabel}\n style={{ aspectRatio }}\n className=\"relative isolate w-full overflow-hidden rounded-xl bg-muted\"\n >\n <motion.div\n aria-hidden={children ? undefined : true}\n initial={false}\n animate={\n reduce\n ? { opacity: mediaState.opacity }\n : {\n filter: mediaState.filter,\n opacity: mediaState.opacity,\n scale: mediaState.scale,\n }\n }\n transition={reduce ? { duration: 0 } : { duration: 0.4, ease: EASE_OUT }}\n className={cn(\n \"absolute inset-0 *:size-full *:object-cover [&_img]:size-full [&_img]:object-cover\",\n mediaClassName,\n )}\n >\n {children}\n </motion.div>\n\n <AnimatePresence initial={false}>\n {active ? (\n <motion.div\n key=\"dither-field\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={{ duration: reduce ? 0 : 0.25, ease: EASE_OUT }}\n className=\"absolute inset-0\"\n >\n <DitherField interactive={interactive} reduce={reduce} status={status} />\n </motion.div>\n ) : null}\n </AnimatePresence>\n\n {resolution ? (\n <span className=\"absolute top-2 right-2 z-10 rounded-full bg-background/75 px-2 py-0.5 font-mono text-[10px] text-muted-foreground tabular-nums\">\n {resolution}\n </span>\n ) : null}\n </div>\n\n {showStatus || prompt ? (\n <div className=\"mt-3 text-left\">\n {showStatus ? (\n <div\n aria-live=\"polite\"\n className={cn(\n \"flex min-h-5 items-center gap-2 font-medium text-foreground text-sm\",\n status === \"error\" && \"text-destructive\",\n statusClassName,\n )}\n >\n <DitherMark status={status} reduce={reduce} />\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.span\n key={resolvedStatusText}\n initial={reduce ? false : { opacity: 0, y: 4 }}\n animate={{ opacity: 1, y: 0 }}\n exit={reduce ? undefined : { opacity: 0, y: -4 }}\n transition={{\n duration: reduce ? 0 : 0.15,\n ease: EASE_OUT,\n }}\n >\n {resolvedStatusText}\n </motion.span>\n </AnimatePresence>\n </div>\n ) : null}\n {prompt ? (\n <p className=\"mt-0.5 truncate text-muted-foreground text-xs\">“{prompt}”</p>\n ) : null}\n </div>\n ) : null}\n\n {status === \"error\" && onRetry ? (\n <motion.button\n type=\"button\"\n onClick={onRetry}\n whileTap={reduce ? undefined : { scale: 0.96 }}\n transition={SPRING_PRESS}\n className=\"mt-3 inline-flex min-h-10 items-center gap-2 rounded-full px-3 font-medium text-foreground text-sm outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <RotateCcw aria-hidden=\"true\" className=\"size-4\" />\n Try again\n </motion.button>\n ) : null}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAkCA,MAAM,cAAqD;CACzD,QAAQ;CACR,YAAY;CACZ,UAAU;CACV,UAAU;CACV,OAAO;AACT;AAEA,MAAM,cAGF;CACF,QAAQ;EAAE,QAAQ;EAA4B,SAAS;EAAG,OAAO;CAAK;CACtE,YAAY;EAAE,QAAQ;EAA4B,SAAS;EAAG,OAAO;CAAM;CAC3E,UAAU;EAAE,QAAQ;EAA8B,SAAS;EAAM,OAAO;CAAM;CAC9E,UAAU;EAAE,QAAQ;EAAyB,SAAS;EAAG,OAAO;CAAE;CAClE,OAAO;EAAE,QAAQ;EAA2B,SAAS;EAAM,OAAO;CAAE;AACtE;AAEA,MAAM,kBAAyD;CAC7D,QAAQ;CACR,YAAY;CACZ,UAAU;CACV,UAAU;CACV,OAAO;AACT;AAEA,MAAM,UAAU;AAChB,MAAM,SAAS,KAAK,KAAK;AAEzB,SAAS,WAAW,EAAE,QAAQ,UAA8D;CAC1F,IAAI,WAAW,YACb,OAAO,oBAAC,OAAD;EAAO,eAAY;EAAO,WAAU;CAAY,CAAA;CAGzD,IAAI,WAAW,SACb,OAAO,oBAAC,aAAD;EAAa,eAAY;EAAO,WAAU;CAAY,CAAA;CAG/D,OACE,qBAAC,OAAO,MAAR;EACE,eAAY;EACZ,SAAS,SAAS,KAAA,IAAY,EAAE,QAAQ,IAAI;EAC5C,YAAY;GACV,UAAU;GACV,MAAM;GACN,QAAQ,OAAO;EACjB;EACA,WAAU;EARZ,UAAA;G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SAAS;OACzC,UAAA,oBAAC,OAAO,MAAR;QAEE,SAAS,SAAS,QAAQ;SAAE,SAAS;SAAG,GAAG;QAAE;QAC7C,SAAS;SAAE,SAAS;SAAG,GAAG;QAAE;QAC5B,MAAM,SAAS,KAAA,IAAY;SAAE,SAAS;SAAG,GAAG;QAAG;QAC/C,YAAY;SACV,UAAU,SAAS,IAAI;SACvB,MAAM;QACR;QAEC,UAAA;OACU,GAVN,kBAUM;MACE,CAAA,CACd;KACH,CAAA,IAAA,MACH,SACC,qBAAC,KAAD;MAAG,WAAU;MAAb,UAAA;OAA6D;OAAE;OAAO;MAAI;KACxE,CAAA,IAAA,IACD;IACH,CAAA,IAAA;IAEH,WAAW,WAAW,UACrB,qBAAC,OAAO,QAAR;KACE,MAAK;KACL,SAAS;KACT,UAAU,SAAS,KAAA,IAAY,EAAE,OAAO,IAAK;KAC7C,YAAY;KACZ,WAAU;KALZ,UAAA,CAOE,oBAAC,WAAD;MAAW,eAAY;MAAO,WAAU;KAAU,CAAA,GAAC,WAEtC;IACb,CAAA,IAAA;GACD;;CACF,CAAA;AAET"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { EASE_IN_OUT } from "../../../lib/ease.js";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
-
import { cn } from "
|
|
4
|
+
import { cn } from "@kumix/utils";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { motion, useReducedMotion } from "motion/react";
|
|
7
7
|
//#region src/components/agents/loading-states/agent-progress.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-progress.js","names":[],"sources":["../../../../src/components/agents/loading-states/agent-progress.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"agent-progress.js","names":[],"sources":["../../../../src/components/agents/loading-states/agent-progress.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_IN_OUT } from \"../../../lib/ease\";\n\nconst GRID_CELLS = [\n { id: \"top-left\", delay: 0 },\n { id: \"top-center\", delay: 0.14 },\n { id: \"top-right\", delay: 0.28 },\n { id: \"middle-left\", delay: 0.42 },\n { id: \"middle-center\", delay: 0.56 },\n { id: \"middle-right\", delay: 0.7 },\n { id: \"bottom-left\", delay: 0.84 },\n { id: \"bottom-center\", delay: 0.98 },\n { id: \"bottom-right\", delay: 1.12 },\n];\n\nexport interface AgentProgressProps {\n /** Verb describing the agent's current activity. */\n label?: string;\n /** Controlled elapsed time in seconds. */\n elapsedSeconds?: number;\n /** Starting time for the internal timer, in seconds. */\n initialSeconds?: number;\n /** Whether the internal timer should advance. Ignored when elapsedSeconds is provided. */\n running?: boolean;\n className?: string;\n}\n\nfunction formatElapsed(totalSeconds: number) {\n const safeSeconds = Math.max(0, totalSeconds);\n const minutes = Math.floor(safeSeconds / 60);\n const seconds = (safeSeconds % 60).toFixed(1);\n return minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;\n}\n\nexport function AgentProgress({\n label = \"Churning\",\n elapsedSeconds,\n initialSeconds = 0,\n running = true,\n className,\n}: AgentProgressProps) {\n const reduce = useReducedMotion() ?? false;\n const [internalSeconds, setInternalSeconds] = useState(initialSeconds);\n\n useEffect(() => {\n if (elapsedSeconds !== undefined || !running) return;\n\n const startedAt = performance.now() - initialSeconds * 1000;\n const timer = window.setInterval(() => {\n setInternalSeconds((performance.now() - startedAt) / 1000);\n }, 100);\n\n return () => window.clearInterval(timer);\n }, [elapsedSeconds, initialSeconds, running]);\n\n const elapsed = elapsedSeconds ?? internalSeconds;\n\n return (\n <span\n role=\"status\"\n aria-label={`${label}, in progress`}\n className={cn(\n \"inline-flex items-center gap-3 font-mono text-muted-foreground text-sm\",\n className,\n )}\n >\n <span aria-hidden=\"true\" className=\"grid size-5 shrink-0 grid-cols-3 gap-[2px]\">\n {GRID_CELLS.map(({ id, delay }) => (\n <motion.span\n key={id}\n className=\"rounded-[1px] bg-current\"\n animate={\n reduce\n ? { opacity: [0.35, 0.8, 0.35] }\n : {\n opacity: [0.28, 1, 0.28],\n scale: [0.72, 1, 0.72],\n }\n }\n transition={{\n duration: 1.55,\n ease: EASE_IN_OUT,\n repeat: Infinity,\n delay,\n }}\n />\n ))}\n </span>\n <span className=\"font-medium font-sans\">{label}</span>\n <span aria-hidden=\"true\" className=\"text-muted-foreground/70 tabular-nums\">\n {formatElapsed(elapsed)}\n </span>\n </span>\n );\n}\n"],"mappings":";;;;;;;AAQA,MAAM,aAAa;CACjB;EAAE,IAAI;EAAY,OAAO;CAAE;CAC3B;EAAE,IAAI;EAAc,OAAO;CAAK;CAChC;EAAE,IAAI;EAAa,OAAO;CAAK;CAC/B;EAAE,IAAI;EAAe,OAAO;CAAK;CACjC;EAAE,IAAI;EAAiB,OAAO;CAAK;CACnC;EAAE,IAAI;EAAgB,OAAO;CAAI;CACjC;EAAE,IAAI;EAAe,OAAO;CAAK;CACjC;EAAE,IAAI;EAAiB,OAAO;CAAK;CACnC;EAAE,IAAI;EAAgB,OAAO;CAAK;AACpC;AAcA,SAAS,cAAc,cAAsB;CAC3C,MAAM,cAAc,KAAK,IAAI,GAAG,YAAY;CAC5C,MAAM,UAAU,KAAK,MAAM,cAAc,EAAE;CAC3C,MAAM,WAAW,cAAc,GAAA,CAAI,QAAQ,CAAC;CAC5C,OAAO,UAAU,IAAI,GAAG,QAAQ,IAAI,QAAQ,KAAK,GAAG,QAAQ;AAC9D;AAEA,SAAgB,cAAc,EAC5B,QAAQ,YACR,gBACA,iBAAiB,GACjB,UAAU,MACV,aACqB;CACrB,MAAM,SAAS,iBAAiB,KAAK;CACrC,MAAM,CAAC,iBAAiB,sBAAsB,SAAS,cAAc;CAErE,gBAAgB;EACd,IAAI,mBAAmB,KAAA,KAAa,CAAC,SAAS;EAE9C,MAAM,YAAY,YAAY,IAAI,IAAI,iBAAiB;EACvD,MAAM,QAAQ,OAAO,kBAAkB;GACrC,oBAAoB,YAAY,IAAI,IAAI,aAAa,GAAI;EAC3D,GAAG,GAAG;EAEN,aAAa,OAAO,cAAc,KAAK;CACzC,GAAG;EAAC;EAAgB;EAAgB;CAAO,CAAC;CAE5C,MAAM,UAAU,kBAAkB;CAElC,OACE,qBAAC,QAAD;EACE,MAAK;EACL,cAAY,GAAG,MAAM;EACrB,WAAW,GACT,0EACA,SACF;EANF,UAAA;GAQE,oBAAC,QAAD;IAAM,eAAY;IAAO,WAAU;IAChC,UAAA,WAAW,KAAK,EAAE,IAAI,YACrB,oBAAC,OAAO,MAAR;KAEE,WAAU;KACV,SACE,SACI,EAAE,SAAS;MAAC;MAAM;MAAK;KAAI,EAAE,IAC7B;MACE,SAAS;OAAC;OAAM;OAAG;MAAI;MACvB,OAAO;OAAC;OAAM;OAAG;MAAI;KACvB;KAEN,YAAY;MACV,UAAU;MACV,MAAM;MACN,QAAQ;MACR;KACF;IACD,GAhBM,EAgBN,CACF;GACG,CAAA;GACN,oBAAC,QAAD;IAAM,WAAU;IAAyB,UAAA;GAAY,CAAA;GACrD,oBAAC,QAAD;IAAM,eAAY;IAAO,WAAU;IAChC,UAAA,cAAc,OAAO;GAClB,CAAA;EACF;;AAEV"}
|
|
@@ -4,7 +4,7 @@ import { TEXT_SHIMMER_CLASS_NAME, TEXT_SHIMMER_KEYFRAMES, textShimmerStyle } fro
|
|
|
4
4
|
import { Loader } from "../../motion/loader.js";
|
|
5
5
|
import { TextScramble } from "../../motion/text-scramble.js";
|
|
6
6
|
import { useEffect, useId, useState } from "react";
|
|
7
|
-
import { cn } from "
|
|
7
|
+
import { cn } from "@kumix/utils";
|
|
8
8
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
10
10
|
//#region src/components/agents/loading-states/reasoning-text.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reasoning-text.js","names":[],"sources":["../../../../src/components/agents/loading-states/reasoning-text.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useEffect, useId, useState } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"reasoning-text.js","names":[],"sources":["../../../../src/components/agents/loading-states/reasoning-text.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useEffect, useId, useState } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_SWAP } from \"../../../lib/ease\";\nimport {\n TEXT_SHIMMER_CLASS_NAME,\n TEXT_SHIMMER_KEYFRAMES,\n textShimmerStyle,\n} from \"../../../lib/text-shimmer\";\nimport { Loader } from \"../../motion/loader\";\nimport { TextScramble } from \"../../motion/text-scramble\";\n\nconst DEFAULT_PHRASES = [\n \"Thinking\",\n \"Reading the context\",\n \"Connecting the details\",\n \"Forming a response\",\n];\n\nconst CASCADE_STAGGER = 0.025;\n\nexport type ReasoningTextVariant = \"cascade\" | \"swap\" | \"scramble\";\n\nexport interface ReasoningTextProps {\n /** Phrases cycled through while the agent works. */\n phrases?: string[];\n /** Animation used when the active phrase changes. */\n variant?: ReasoningTextVariant;\n /** Milliseconds each phrase remains visible. */\n interval?: number;\n /** Seconds taken for one shimmer pass. */\n shimmerDuration?: number;\n /** Optional leading visual. Defaults to a terminal-style ASCII loader. */\n indicator?: ReactNode;\n className?: string;\n}\n\ntype PhraseProps = {\n phrase: string;\n reduce: boolean;\n shimmerDuration: number;\n};\n\nfunction CascadePhrase({ phrase, reduce, shimmerDuration }: PhraseProps) {\n const text = `${phrase}…`;\n\n if (reduce) {\n return (\n <span\n className={cn(\n \"col-start-1 row-start-1 inline-block justify-self-start whitespace-pre\",\n TEXT_SHIMMER_CLASS_NAME,\n )}\n style={textShimmerStyle(shimmerDuration)}\n >\n {text}\n </span>\n );\n }\n\n return (\n <AnimatePresence initial={false}>\n <motion.span\n key={phrase}\n className=\"col-start-1 row-start-1 inline-block justify-self-start whitespace-pre\"\n initial=\"initial\"\n animate=\"animate\"\n exit=\"exit\"\n >\n {text.split(\"\").map((character, characterIndex) => (\n <motion.span\n key={characterIndex}\n custom={characterIndex * CASCADE_STAGGER}\n variants={{\n initial: { opacity: 0, y: \"100%\" },\n animate: (delay: number) => ({\n opacity: 1,\n y: \"0%\",\n transition: { ...SPRING_SWAP, delay },\n }),\n exit: (delay: number) => ({\n opacity: 0,\n y: \"-100%\",\n transition: {\n duration: 0.14,\n ease: EASE_OUT,\n delay: delay * 0.45,\n },\n }),\n }}\n className={cn(\n \"inline-block whitespace-pre will-change-[opacity,transform]\",\n TEXT_SHIMMER_CLASS_NAME,\n )}\n style={textShimmerStyle(shimmerDuration)}\n >\n {character}\n </motion.span>\n ))}\n </motion.span>\n </AnimatePresence>\n );\n}\n\nfunction SwapPhrase({ phrase, reduce, shimmerDuration }: PhraseProps) {\n return (\n <AnimatePresence initial={false}>\n <motion.span\n key={phrase}\n className={cn(\n \"col-start-1 row-start-1 inline-block justify-self-start whitespace-nowrap will-change-[opacity,transform]\",\n TEXT_SHIMMER_CLASS_NAME,\n )}\n style={textShimmerStyle(shimmerDuration)}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 3 }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -3 }}\n transition={{\n duration: reduce ? 0.12 : 0.2,\n ease: EASE_OUT,\n }}\n >\n {phrase}…\n </motion.span>\n </AnimatePresence>\n );\n}\n\nfunction ScramblePhrase({ phrase, shimmerDuration }: PhraseProps) {\n const target = `${phrase}…`;\n\n return (\n <TextScramble\n text={target}\n className={cn(\n \"col-start-1 row-start-1 justify-self-start tabular-nums\",\n TEXT_SHIMMER_CLASS_NAME,\n )}\n style={textShimmerStyle(shimmerDuration)}\n />\n );\n}\n\nexport function ReasoningText({\n phrases = DEFAULT_PHRASES,\n variant = \"cascade\",\n interval = 1800,\n shimmerDuration = 2.2,\n indicator,\n className,\n}: ReasoningTextProps) {\n const reduce = useReducedMotion() ?? false;\n const [index, setIndex] = useState(0);\n const statusId = useId();\n const safePhrases = phrases.length > 0 ? phrases : DEFAULT_PHRASES;\n const phrase = safePhrases[index % safePhrases.length];\n const longestPhrase = safePhrases.reduce((longest, current) =>\n current.length > longest.length ? current : longest,\n );\n const phraseProps = { phrase, reduce, shimmerDuration };\n\n useEffect(() => {\n if (safePhrases.length < 2) return;\n\n const timer = window.setInterval(\n () => {\n setIndex((current) => (current + 1) % safePhrases.length);\n },\n Math.max(600, interval),\n );\n\n return () => window.clearInterval(timer);\n }, [interval, safePhrases.length]);\n\n return (\n <>\n <style>{TEXT_SHIMMER_KEYFRAMES}</style>\n <span\n role=\"status\"\n aria-live=\"polite\"\n aria-labelledby={statusId}\n className={cn(\n \"inline-flex items-center gap-2 font-medium text-muted-foreground text-sm\",\n className,\n )}\n >\n <span\n aria-hidden=\"true\"\n className=\"inline-flex size-3 shrink-0 items-center justify-center\"\n >\n {indicator ?? <Loader variant=\"ascii-line\" size={14} speed={0.8} label=\"Reasoning\" />}\n </span>\n\n <span aria-hidden=\"true\" className=\"grid overflow-hidden text-left\">\n <span className=\"invisible col-start-1 row-start-1 whitespace-nowrap\">\n {longestPhrase}…\n </span>\n {variant === \"cascade\" ? (\n <CascadePhrase {...phraseProps} />\n ) : variant === \"scramble\" ? (\n <ScramblePhrase {...phraseProps} />\n ) : (\n <SwapPhrase {...phraseProps} />\n )}\n </span>\n\n <span id={statusId} className=\"sr-only\">\n {phrase}\n </span>\n </span>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;AAeA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;AACF;AAEA,MAAM,kBAAkB;AAwBxB,SAAS,cAAc,EAAE,QAAQ,QAAQ,mBAAgC;CACvE,MAAM,OAAO,GAAG,OAAO;CAEvB,IAAI,QACF,OACE,oBAAC,Q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AAe,GAAI,YAAc,CAAA,IAC/B,YAAY,aACd,oBAAC,gBAAD,EAAgB,GAAI,YAAc,CAAA,IAElC,oBAAC,YAAD,EAAY,GAAI,YAAc,CAAA,CAE5B;;GAEN,oBAAC,QAAD;IAAM,IAAI;IAAU,WAAU;IAC3B,UAAA;GACG,CAAA;EACF;CACN,CAAA,CAAA,EAAA,CAAA;AAEN"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { TextShimmer } from "../../motion/text-shimmer.js";
|
|
3
|
-
import { cn } from "
|
|
3
|
+
import { cn } from "@kumix/utils";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/agents/loading-states/thinking-shimmer.tsx
|
|
6
6
|
function ThinkingShimmer({ children = "Thinking…", duration = 1.8, className }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinking-shimmer.js","names":[],"sources":["../../../../src/components/agents/loading-states/thinking-shimmer.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport { cn } from \"
|
|
1
|
+
{"version":3,"file":"thinking-shimmer.js","names":[],"sources":["../../../../src/components/agents/loading-states/thinking-shimmer.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ReactNode } from \"react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { TextShimmer } from \"../../motion/text-shimmer\";\n\nexport interface ThinkingShimmerProps {\n /** Loading message shown to the user. */\n children?: ReactNode;\n /** Seconds taken for one shimmer pass. */\n duration?: number;\n className?: string;\n}\n\nexport function ThinkingShimmer({\n children = \"Thinking…\",\n duration = 1.8,\n className,\n}: ThinkingShimmerProps) {\n return (\n <TextShimmer as=\"span\" duration={duration} className={cn(\"font-medium\", className)}>\n {children}\n </TextShimmer>\n );\n}\n"],"mappings":";;;;;AAeA,SAAgB,gBAAgB,EAC9B,WAAW,aACX,WAAW,KACX,aACuB;CACvB,OACE,oBAAC,aAAD;EAAa,IAAG;EAAiB;EAAU,WAAW,GAAG,eAAe,SAAS;EAC9E;CACU,CAAA;AAEjB"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from "../../lib/ease.js";
|
|
3
3
|
import { MessageSideContext } from "./message-context.js";
|
|
4
4
|
import { cloneElement, createContext, useCallback, useContext, useId, useState } from "react";
|
|
5
|
-
import { cn } from "
|
|
5
|
+
import { cn } from "@kumix/utils";
|
|
6
6
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { motion, useReducedMotion } from "motion/react";
|
|
8
8
|
import { ChevronDown } from "lucide-react";
|