@kumix/ui 0.3.1 → 0.3.2
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 +33 -17
- package/dist/components/agents/agent-activity/activity-row.d.ts +8 -0
- package/dist/components/agents/agent-activity/activity-row.d.ts.map +1 -0
- package/dist/components/agents/agent-activity/activity-row.js +228 -0
- package/dist/components/agents/agent-activity/activity-row.js.map +1 -0
- package/dist/components/agents/agent-activity/index.d.ts +6 -0
- package/dist/components/agents/agent-activity/index.d.ts.map +1 -0
- package/dist/components/agents/agent-activity/index.js +182 -0
- package/dist/components/agents/agent-activity/index.js.map +1 -0
- package/dist/components/agents/agent-code.d.ts +25 -0
- package/dist/components/agents/agent-code.d.ts.map +1 -0
- package/dist/components/agents/agent-code.js +117 -0
- package/dist/components/agents/agent-code.js.map +1 -0
- package/dist/components/agents/agent-disclosure.d.ts +12 -0
- package/dist/components/agents/agent-disclosure.d.ts.map +1 -0
- package/dist/components/agents/agent-disclosure.js +36 -0
- package/dist/components/agents/agent-disclosure.js.map +1 -0
- package/dist/components/agents/ai-sidebar.d.ts +41 -0
- package/dist/components/agents/ai-sidebar.d.ts.map +1 -0
- package/dist/components/agents/ai-sidebar.js +576 -0
- package/dist/components/agents/ai-sidebar.js.map +1 -0
- package/dist/components/agents/approval-card/index.d.ts +51 -0
- package/dist/components/agents/approval-card/index.d.ts.map +1 -0
- package/dist/components/agents/approval-card/index.js +317 -0
- package/dist/components/agents/approval-card/index.js.map +1 -0
- package/dist/components/agents/chat-app.d.ts +10 -0
- package/dist/components/agents/chat-app.d.ts.map +1 -0
- package/dist/components/agents/chat-app.js +20 -0
- package/dist/components/agents/chat-app.js.map +1 -0
- package/dist/components/agents/citations.d.ts +45 -0
- package/dist/components/agents/citations.d.ts.map +1 -0
- package/dist/components/agents/citations.js +175 -0
- package/dist/components/agents/citations.js.map +1 -0
- package/dist/components/agents/code-block.d.ts +21 -0
- package/dist/components/agents/code-block.d.ts.map +1 -0
- package/dist/components/agents/code-block.js +113 -0
- package/dist/components/agents/code-block.js.map +1 -0
- package/dist/components/agents/file-diff.d.ts +30 -0
- package/dist/components/agents/file-diff.d.ts.map +1 -0
- package/dist/components/agents/file-diff.js +186 -0
- package/dist/components/agents/file-diff.js.map +1 -0
- package/dist/components/agents/image-generation.d.ts +27 -0
- package/dist/components/agents/image-generation.d.ts.map +1 -0
- package/dist/components/agents/image-generation.js +308 -0
- package/dist/components/agents/image-generation.js.map +1 -0
- package/dist/components/agents/loading-states/agent-progress.d.ts +16 -0
- package/dist/components/agents/loading-states/agent-progress.d.ts.map +1 -0
- package/dist/components/agents/loading-states/agent-progress.js +117 -0
- package/dist/components/agents/loading-states/agent-progress.js.map +1 -0
- package/dist/components/agents/loading-states/reasoning-text.d.ts +20 -0
- package/dist/components/agents/loading-states/reasoning-text.d.ts.map +1 -0
- package/dist/components/agents/loading-states/reasoning-text.js +184 -0
- package/dist/components/agents/loading-states/reasoning-text.js.map +1 -0
- package/dist/components/agents/loading-states/thinking-shimmer.d.ts +13 -0
- package/dist/components/agents/loading-states/thinking-shimmer.d.ts.map +1 -0
- package/dist/components/agents/loading-states/thinking-shimmer.js +17 -0
- package/dist/components/agents/loading-states/thinking-shimmer.js.map +1 -0
- package/dist/components/agents/message-bubble.d.ts +38 -0
- package/dist/components/agents/message-bubble.d.ts.map +1 -0
- package/dist/components/agents/message-bubble.js +182 -0
- package/dist/components/agents/message-bubble.js.map +1 -0
- package/dist/components/agents/message-context.d.ts +6 -0
- package/dist/components/agents/message-context.d.ts.map +1 -0
- package/dist/components/agents/message-context.js +8 -0
- package/dist/components/agents/message-context.js.map +1 -0
- package/dist/components/agents/message-scroller.d.ts +30 -0
- package/dist/components/agents/message-scroller.d.ts.map +1 -0
- package/dist/components/agents/message-scroller.js +314 -0
- package/dist/components/agents/message-scroller.js.map +1 -0
- package/dist/components/agents/message.d.ts +37 -0
- package/dist/components/agents/message.d.ts.map +1 -0
- package/dist/components/agents/message.js +139 -0
- package/dist/components/agents/message.js.map +1 -0
- package/dist/components/agents/prompt-input.d.ts +37 -0
- package/dist/components/agents/prompt-input.d.ts.map +1 -0
- package/dist/components/agents/prompt-input.js +216 -0
- package/dist/components/agents/prompt-input.js.map +1 -0
- package/dist/components/agents/streaming-response.d.ts +35 -0
- package/dist/components/agents/streaming-response.d.ts.map +1 -0
- package/dist/components/agents/streaming-response.js +151 -0
- package/dist/components/agents/streaming-response.js.map +1 -0
- package/dist/components/agents/todo-list.d.ts +24 -0
- package/dist/components/agents/todo-list.d.ts.map +1 -0
- package/dist/components/agents/todo-list.js +334 -0
- package/dist/components/agents/todo-list.js.map +1 -0
- package/dist/components/agents/tool-approval.d.ts +33 -0
- package/dist/components/agents/tool-approval.d.ts.map +1 -0
- package/dist/components/agents/tool-approval.js +166 -0
- package/dist/components/agents/tool-approval.js.map +1 -0
- package/dist/components/agents/tool-result.d.ts +34 -0
- package/dist/components/agents/tool-result.d.ts.map +1 -0
- package/dist/components/agents/tool-result.js +220 -0
- package/dist/components/agents/tool-result.js.map +1 -0
- package/dist/components/custom/confirm-dialog.js +1 -1
- package/dist/components/motion/animated-badge.js +1 -1
- package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
- package/dist/components/motion/animated-sidebar.js +3 -3
- package/dist/components/motion/animated-sidebar.js.map +1 -1
- package/dist/components/motion/animated-toast-stack.js +3 -3
- package/dist/components/motion/animated-toast-stack.js.map +1 -1
- package/dist/components/motion/attachment-upload.js +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
- package/dist/components/motion/availability-scheduler/day-row.js +2 -2
- package/dist/components/motion/availability-scheduler/index.js +1 -1
- package/dist/components/motion/bloom-menu.js +2 -2
- package/dist/components/motion/bloom-menu.js.map +1 -1
- package/dist/components/motion/bouncy-accordion.js +1 -1
- package/dist/components/motion/button/stateful.js +1 -1
- package/dist/components/motion/center-morph-modal.js +3 -3
- package/dist/components/motion/center-morph-modal.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/command-palette.js +8 -4
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/context-menu.js +1 -1
- package/dist/components/motion/feedback-widget.js +1 -1
- package/dist/components/motion/file-upload.js +1 -1
- package/dist/components/motion/infinite-masonry.js +1 -1
- package/dist/components/motion/notification-stack.js +1 -1
- package/dist/components/motion/overflow-actions.js +1 -1
- package/dist/components/motion/preview-rail.d.ts +10 -2
- package/dist/components/motion/preview-rail.d.ts.map +1 -1
- package/dist/components/motion/preview-rail.js +58 -27
- package/dist/components/motion/preview-rail.js.map +1 -1
- package/dist/components/motion/select-morph.js +1 -1
- package/dist/components/motion/select.js +1 -1
- package/dist/components/motion/table/row-handle.js +1 -1
- package/dist/components/motion/table/table-header.js +1 -1
- package/dist/components/motion/text-shimmer.d.ts.map +1 -1
- package/dist/components/motion/text-shimmer.js +4 -3
- package/dist/components/motion/text-shimmer.js.map +1 -1
- package/dist/components/motion/theme-toggle.js +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/alert.js +1 -1
- package/dist/components/reui/autocomplete.js +1 -1
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.d.ts +4 -3
- package/dist/components/reui/data-grid/data-grid-column-filter.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -2
- package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts +15 -4
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +36 -8
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts +3 -2
- package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.js +0 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +3 -4
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +12 -7
- 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.d.ts +71 -4
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +147 -40
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +5 -6
- package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts +6 -5
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +9 -10
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.d.ts +60 -33
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +152 -68
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.d.ts +105 -20
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +83 -10
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.js +47 -44
- 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-dnd.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-dnd.js +20 -2
- package/dist/components/reui/event-calendar/event-calendar-dnd.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-recurrence.js +7 -5
- package/dist/components/reui/event-calendar/event-calendar-recurrence.js.map +1 -1
- package/dist/components/reui/filters.js +26 -21
- package/dist/components/reui/filters.js.map +1 -1
- package/dist/components/reui/frame.d.ts +1 -1
- package/dist/components/reui/frame.js +1 -1
- package/dist/components/reui/gantt/gantt-bar.js +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +1 -1
- package/dist/components/reui/gantt/gantt-view.js +1 -1
- package/dist/components/reui/icon-tile.d.ts +1 -1
- package/dist/components/reui/icon-tile.d.ts.map +1 -1
- package/dist/components/reui/icon-tile.js +8 -1
- package/dist/components/reui/icon-tile.js.map +1 -1
- package/dist/components/reui/number-field.js +1 -1
- package/dist/components/reui/phone-input.js +1 -1
- package/dist/components/reui/rating.js +1 -1
- package/dist/components/reui/sortable.js +13 -11
- package/dist/components/reui/sortable.js.map +1 -1
- package/dist/components/reui/tree.js +1 -1
- package/dist/components/ui/accordion.js +1 -1
- package/dist/components/ui/alert-dialog.js +1 -1
- package/dist/components/ui/alert.js +1 -1
- package/dist/components/ui/attachment.js +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/breadcrumb.js +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/bubble.js +1 -1
- package/dist/components/ui/button-group.js +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/calendar.js +1 -1
- package/dist/components/ui/carousel.js +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/combobox.js +1 -1
- package/dist/components/ui/command.js +1 -1
- package/dist/components/ui/context-menu.js +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/empty.js +1 -1
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/input-group.js +1 -1
- package/dist/components/ui/input-otp.js +1 -1
- package/dist/components/ui/item.d.ts +1 -1
- package/dist/components/ui/item.js +1 -1
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/marker.js +1 -1
- package/dist/components/ui/menubar.js +1 -1
- package/dist/components/ui/message-scroller.js +1 -1
- package/dist/components/ui/native-select.js +1 -1
- package/dist/components/ui/navigation-menu.js +1 -1
- package/dist/components/ui/pagination.js +1 -1
- package/dist/components/ui/questionnaire.d.ts +21 -0
- package/dist/components/ui/questionnaire.d.ts.map +1 -0
- package/dist/components/ui/questionnaire.js +164 -0
- package/dist/components/ui/questionnaire.js.map +1 -0
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/sheet.js +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/spinner.js +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/toast.js +1 -1
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/components/ui/toggle.js +1 -1
- package/dist/{copy-menu-BJ-MXnkN.js → copy-menu-Bk5GP9Gp.js} +3 -3
- package/dist/{copy-menu-BJ-MXnkN.js.map → copy-menu-Bk5GP9Gp.js.map} +1 -1
- package/dist/hooks/use-body-classes.d.ts +0 -3
- package/dist/hooks/use-body-classes.d.ts.map +1 -1
- package/dist/hooks/use-body-classes.js +0 -3
- package/dist/hooks/use-body-classes.js.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.d.ts +0 -3
- package/dist/hooks/use-copy-to-clipboard.d.ts.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.js +0 -3
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
- package/dist/hooks/use-file-upload.js +6 -4
- package/dist/hooks/use-file-upload.js.map +1 -1
- package/dist/hooks/use-hydrated.d.ts +0 -10
- package/dist/hooks/use-hydrated.d.ts.map +1 -1
- package/dist/hooks/use-hydrated.js +0 -10
- package/dist/hooks/use-hydrated.js.map +1 -1
- package/dist/hooks/use-intersection-observer.d.ts.map +1 -1
- package/dist/hooks/use-intersection-observer.js +0 -5
- package/dist/hooks/use-intersection-observer.js.map +1 -1
- package/dist/hooks/use-is-mac.d.ts +0 -5
- package/dist/hooks/use-is-mac.d.ts.map +1 -1
- package/dist/hooks/use-is-mac.js +0 -5
- package/dist/hooks/use-is-mac.js.map +1 -1
- package/dist/hooks/use-media-query.d.ts +0 -5
- package/dist/hooks/use-media-query.d.ts.map +1 -1
- package/dist/hooks/use-media-query.js +0 -5
- package/dist/hooks/use-media-query.js.map +1 -1
- package/dist/hooks/use-meta-color.d.ts.map +1 -1
- package/dist/hooks/use-meta-color.js +0 -3
- package/dist/hooks/use-meta-color.js.map +1 -1
- package/dist/hooks/use-mutation-observer.d.ts.map +1 -1
- package/dist/hooks/use-mutation-observer.js +0 -5
- package/dist/hooks/use-mutation-observer.js.map +1 -1
- package/dist/hooks/use-scroll-position.d.ts.map +1 -1
- package/dist/hooks/use-scroll-position.js +0 -5
- package/dist/hooks/use-scroll-position.js.map +1 -1
- package/dist/hooks/use-slider-input.d.ts.map +1 -1
- package/dist/hooks/use-slider-input.js +0 -5
- package/dist/hooks/use-slider-input.js.map +1 -1
- package/dist/hooks/use-viewport.d.ts +0 -5
- package/dist/hooks/use-viewport.d.ts.map +1 -1
- package/dist/hooks/use-viewport.js +0 -5
- package/dist/hooks/use-viewport.js.map +1 -1
- package/dist/lib/favicon.d.ts +5 -0
- package/dist/lib/favicon.d.ts.map +1 -0
- package/dist/lib/favicon.js +12 -0
- package/dist/lib/favicon.js.map +1 -0
- package/dist/lib/text-shimmer.d.ts +8 -0
- package/dist/lib/text-shimmer.d.ts.map +1 -0
- package/dist/lib/text-shimmer.js +10 -0
- package/dist/lib/text-shimmer.js.map +1 -0
- package/dist/types-j36vVGtZ.d.ts +78 -0
- package/dist/types-j36vVGtZ.d.ts.map +1 -0
- package/package.json +18 -13
- package/dist/components/ui/sonner.d.ts +0 -7
- package/dist/components/ui/sonner.d.ts.map +0 -1
- package/dist/components/ui/sonner.js +0 -32
- package/dist/components/ui/sonner.js.map +0 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { EASE_OUT, SPRING_SWAP } from "../../../lib/ease.js";
|
|
3
|
+
import { TEXT_SHIMMER_CLASS_NAME, TEXT_SHIMMER_KEYFRAMES, textShimmerStyle } from "../../../lib/text-shimmer.js";
|
|
4
|
+
import { Loader } from "../../motion/loader.js";
|
|
5
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
6
|
+
import { cn } from "@kumix/utils";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
9
|
+
//#region src/components/agents/loading-states/reasoning-text.tsx
|
|
10
|
+
const DEFAULT_PHRASES = [
|
|
11
|
+
"Thinking",
|
|
12
|
+
"Reading the context",
|
|
13
|
+
"Connecting the details",
|
|
14
|
+
"Forming a response"
|
|
15
|
+
];
|
|
16
|
+
const SCRAMBLE_GLYPHS = "ABCDEFGHJKLMNPQRSTUVWXYZ0123456789#%&@$?/";
|
|
17
|
+
const CASCADE_STAGGER = .025;
|
|
18
|
+
function CascadePhrase({ phrase, reduce, shimmerDuration }) {
|
|
19
|
+
const text = `${phrase}…`;
|
|
20
|
+
if (reduce) return /* @__PURE__ */ jsx("span", {
|
|
21
|
+
className: cn("col-start-1 row-start-1 inline-block justify-self-start whitespace-pre", TEXT_SHIMMER_CLASS_NAME),
|
|
22
|
+
style: textShimmerStyle(shimmerDuration),
|
|
23
|
+
children: text
|
|
24
|
+
});
|
|
25
|
+
return /* @__PURE__ */ jsx(AnimatePresence, {
|
|
26
|
+
initial: false,
|
|
27
|
+
children: /* @__PURE__ */ jsx(motion.span, {
|
|
28
|
+
className: "col-start-1 row-start-1 inline-block justify-self-start whitespace-pre",
|
|
29
|
+
initial: "initial",
|
|
30
|
+
animate: "animate",
|
|
31
|
+
exit: "exit",
|
|
32
|
+
children: text.split("").map((character, characterIndex) => /* @__PURE__ */ jsx(motion.span, {
|
|
33
|
+
custom: characterIndex * CASCADE_STAGGER,
|
|
34
|
+
variants: {
|
|
35
|
+
initial: {
|
|
36
|
+
opacity: 0,
|
|
37
|
+
y: "100%"
|
|
38
|
+
},
|
|
39
|
+
animate: (delay) => ({
|
|
40
|
+
opacity: 1,
|
|
41
|
+
y: "0%",
|
|
42
|
+
transition: {
|
|
43
|
+
...SPRING_SWAP,
|
|
44
|
+
delay
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
exit: (delay) => ({
|
|
48
|
+
opacity: 0,
|
|
49
|
+
y: "-100%",
|
|
50
|
+
transition: {
|
|
51
|
+
duration: .14,
|
|
52
|
+
ease: EASE_OUT,
|
|
53
|
+
delay: delay * .45
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
},
|
|
57
|
+
className: cn("inline-block whitespace-pre will-change-[opacity,transform]", TEXT_SHIMMER_CLASS_NAME),
|
|
58
|
+
style: textShimmerStyle(shimmerDuration),
|
|
59
|
+
children: character
|
|
60
|
+
}, characterIndex))
|
|
61
|
+
}, phrase)
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function SwapPhrase({ phrase, reduce, shimmerDuration }) {
|
|
65
|
+
return /* @__PURE__ */ jsx(AnimatePresence, {
|
|
66
|
+
initial: false,
|
|
67
|
+
children: /* @__PURE__ */ jsxs(motion.span, {
|
|
68
|
+
className: cn("col-start-1 row-start-1 inline-block justify-self-start whitespace-nowrap will-change-[opacity,transform]", TEXT_SHIMMER_CLASS_NAME),
|
|
69
|
+
style: textShimmerStyle(shimmerDuration),
|
|
70
|
+
initial: reduce ? { opacity: 0 } : {
|
|
71
|
+
opacity: 0,
|
|
72
|
+
y: 3
|
|
73
|
+
},
|
|
74
|
+
animate: reduce ? { opacity: 1 } : {
|
|
75
|
+
opacity: 1,
|
|
76
|
+
y: 0
|
|
77
|
+
},
|
|
78
|
+
exit: reduce ? { opacity: 0 } : {
|
|
79
|
+
opacity: 0,
|
|
80
|
+
y: -3
|
|
81
|
+
},
|
|
82
|
+
transition: {
|
|
83
|
+
duration: reduce ? .12 : .2,
|
|
84
|
+
ease: EASE_OUT
|
|
85
|
+
},
|
|
86
|
+
children: [phrase, "…"]
|
|
87
|
+
}, phrase)
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function ScramblePhrase({ phrase, reduce, shimmerDuration }) {
|
|
91
|
+
const target = `${phrase}…`;
|
|
92
|
+
const [display, setDisplay] = useState(target);
|
|
93
|
+
const mounted = useRef(false);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (!mounted.current) {
|
|
96
|
+
mounted.current = true;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (reduce) {
|
|
100
|
+
setDisplay(target);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const characters = target.split("");
|
|
104
|
+
const startedAt = performance.now();
|
|
105
|
+
const duration = Math.min(760, Math.max(420, characters.length * 32));
|
|
106
|
+
let frame = 0;
|
|
107
|
+
let lastUpdate = 0;
|
|
108
|
+
const animate = (now) => {
|
|
109
|
+
if (now - lastUpdate >= 40) {
|
|
110
|
+
lastUpdate = now;
|
|
111
|
+
const progress = Math.min((now - startedAt) / duration, 1);
|
|
112
|
+
const settled = Math.floor(progress * characters.length);
|
|
113
|
+
setDisplay(characters.map((character, characterIndex) => {
|
|
114
|
+
if (characterIndex < settled || character === " ") return character;
|
|
115
|
+
return SCRAMBLE_GLYPHS[Math.floor(Math.random() * 41)];
|
|
116
|
+
}).join(""));
|
|
117
|
+
}
|
|
118
|
+
if (now - startedAt < duration) frame = requestAnimationFrame(animate);
|
|
119
|
+
else setDisplay(target);
|
|
120
|
+
};
|
|
121
|
+
frame = requestAnimationFrame(animate);
|
|
122
|
+
return () => cancelAnimationFrame(frame);
|
|
123
|
+
}, [reduce, target]);
|
|
124
|
+
return /* @__PURE__ */ jsx("span", {
|
|
125
|
+
className: cn("col-start-1 row-start-1 inline-block justify-self-start whitespace-pre font-mono tabular-nums", TEXT_SHIMMER_CLASS_NAME),
|
|
126
|
+
style: textShimmerStyle(shimmerDuration),
|
|
127
|
+
children: display
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function ReasoningText({ phrases = DEFAULT_PHRASES, variant = "cascade", interval = 1800, shimmerDuration = 2.2, indicator, className }) {
|
|
131
|
+
const reduce = useReducedMotion() ?? false;
|
|
132
|
+
const [index, setIndex] = useState(0);
|
|
133
|
+
const statusId = useId();
|
|
134
|
+
const safePhrases = phrases.length > 0 ? phrases : DEFAULT_PHRASES;
|
|
135
|
+
const phrase = safePhrases[index % safePhrases.length];
|
|
136
|
+
const longestPhrase = safePhrases.reduce((longest, current) => current.length > longest.length ? current : longest);
|
|
137
|
+
const phraseProps = {
|
|
138
|
+
phrase,
|
|
139
|
+
reduce,
|
|
140
|
+
shimmerDuration
|
|
141
|
+
};
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (safePhrases.length < 2) return;
|
|
144
|
+
const timer = window.setInterval(() => {
|
|
145
|
+
setIndex((current) => (current + 1) % safePhrases.length);
|
|
146
|
+
}, Math.max(600, interval));
|
|
147
|
+
return () => window.clearInterval(timer);
|
|
148
|
+
}, [interval, safePhrases.length]);
|
|
149
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("style", { children: TEXT_SHIMMER_KEYFRAMES }), /* @__PURE__ */ jsxs("span", {
|
|
150
|
+
role: "status",
|
|
151
|
+
"aria-live": "polite",
|
|
152
|
+
"aria-labelledby": statusId,
|
|
153
|
+
className: cn("inline-flex items-center gap-2 font-medium text-muted-foreground text-sm", className),
|
|
154
|
+
children: [
|
|
155
|
+
/* @__PURE__ */ jsx("span", {
|
|
156
|
+
"aria-hidden": "true",
|
|
157
|
+
className: "inline-flex size-3 shrink-0 items-center justify-center",
|
|
158
|
+
children: indicator ?? /* @__PURE__ */ jsx(Loader, {
|
|
159
|
+
variant: "ascii-line",
|
|
160
|
+
size: 14,
|
|
161
|
+
speed: .8,
|
|
162
|
+
label: "Reasoning"
|
|
163
|
+
})
|
|
164
|
+
}),
|
|
165
|
+
/* @__PURE__ */ jsxs("span", {
|
|
166
|
+
"aria-hidden": "true",
|
|
167
|
+
className: "grid overflow-hidden text-left",
|
|
168
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
169
|
+
className: "invisible col-start-1 row-start-1 whitespace-nowrap",
|
|
170
|
+
children: [longestPhrase, "…"]
|
|
171
|
+
}), variant === "cascade" ? /* @__PURE__ */ jsx(CascadePhrase, { ...phraseProps }) : variant === "scramble" ? /* @__PURE__ */ jsx(ScramblePhrase, { ...phraseProps }) : /* @__PURE__ */ jsx(SwapPhrase, { ...phraseProps })]
|
|
172
|
+
}),
|
|
173
|
+
/* @__PURE__ */ jsx("span", {
|
|
174
|
+
id: statusId,
|
|
175
|
+
className: "sr-only",
|
|
176
|
+
children: phrase
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
})] });
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
export { ReasoningText };
|
|
183
|
+
|
|
184
|
+
//# sourceMappingURL=reasoning-text.js.map
|
|
@@ -0,0 +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, useRef, 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\";\n\nconst DEFAULT_PHRASES = [\n \"Thinking\",\n \"Reading the context\",\n \"Connecting the details\",\n \"Forming a response\",\n];\n\nconst SCRAMBLE_GLYPHS = \"ABCDEFGHJKLMNPQRSTUVWXYZ0123456789#%&@$?/\";\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, reduce, shimmerDuration }: PhraseProps) {\n const target = `${phrase}…`;\n const [display, setDisplay] = useState(target);\n const mounted = useRef(false);\n\n useEffect(() => {\n if (!mounted.current) {\n mounted.current = true;\n return;\n }\n\n if (reduce) {\n setDisplay(target);\n return;\n }\n\n const characters = target.split(\"\");\n const startedAt = performance.now();\n const duration = Math.min(760, Math.max(420, characters.length * 32));\n let frame = 0;\n let lastUpdate = 0;\n\n const animate = (now: number) => {\n if (now - lastUpdate >= 40) {\n lastUpdate = now;\n const progress = Math.min((now - startedAt) / duration, 1);\n const settled = Math.floor(progress * characters.length);\n\n setDisplay(\n characters\n .map((character, characterIndex) => {\n if (characterIndex < settled || character === \" \") {\n return character;\n }\n return SCRAMBLE_GLYPHS[Math.floor(Math.random() * SCRAMBLE_GLYPHS.length)];\n })\n .join(\"\"),\n );\n }\n\n if (now - startedAt < duration) {\n frame = requestAnimationFrame(animate);\n } else {\n setDisplay(target);\n }\n };\n\n frame = requestAnimationFrame(animate);\n return () => cancelAnimationFrame(frame);\n }, [reduce, target]);\n\n return (\n <span\n className={cn(\n \"col-start-1 row-start-1 inline-block justify-self-start whitespace-pre font-mono tabular-nums\",\n TEXT_SHIMMER_CLASS_NAME,\n )}\n style={textShimmerStyle(shimmerDuration)}\n >\n {display}\n </span>\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":";;;;;;;;;AAcA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;AACF;AAEA,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AAwBxB,SAAS,cAAc,EAAE,QAAQ,QAAQ,mBAAgC;CACvE,MAAM,OAAO,GAAG,OAAO;CAEvB,IAAI,QACF,OACE,oBAAC,QAAD;EACE,WAAW,GACT,0EACA,uBACF;EACA,OAAO,iBAAiB,eAAe;EAEtC,UAAA;CACG,CAAA;CAIV,OACE,oBAAC,iBAAD;EAAiB,SAAS;EACxB,UAAA,oBAAC,OAAO,MAAR;GAEE,WAAU;GACV,SAAQ;GACR,SAAQ;GACR,MAAK;GAEJ,UAAA,KAAK,MAAM,EAAE,CAAC,CAAC,KAAK,WAAW,mBAC9B,oBAAC,OAAO,MAAR;IAEE,QAAQ,iBAAiB;IACzB,UAAU;KACR,SAAS;MAAE,SAAS;MAAG,GAAG;KAAO;KACjC,UAAU,WAAmB;MAC3B,SAAS;MACT,GAAG;MACH,YAAY;OAAE,GAAG;OAAa;MAAM;KACtC;KACA,OAAO,WAAmB;MACxB,SAAS;MACT,GAAG;MACH,YAAY;OACV,UAAU;OACV,MAAM;OACN,OAAO,QAAQ;MACjB;KACF;IACF;IACA,WAAW,GACT,+DACA,uBACF;IACA,OAAO,iBAAiB,eAAe;IAEtC,UAAA;GACU,GA1BN,cA0BM,CACd;EACU,GApCN,MAoCM;CACE,CAAA;AAErB;AAEA,SAAS,WAAW,EAAE,QAAQ,QAAQ,mBAAgC;CACpE,OACE,oBAAC,iBAAD;EAAiB,SAAS;EACxB,UAAA,qBAAC,OAAO,MAAR;GAEE,WAAW,GACT,6GACA,uBACF;GACA,OAAO,iBAAiB,eAAe;GACvC,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;IAAE,SAAS;IAAG,GAAG;GAAE;GACt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AI,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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/components/agents/loading-states/thinking-shimmer.d.ts
|
|
3
|
+
interface ThinkingShimmerProps {
|
|
4
|
+
/** Loading message shown to the user. */
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
/** Seconds taken for one shimmer pass. */
|
|
7
|
+
duration?: number;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
declare function ThinkingShimmer({ children, duration, className }: ThinkingShimmerProps): import("react").JSX.Element;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { ThinkingShimmer, ThinkingShimmerProps };
|
|
13
|
+
//# sourceMappingURL=thinking-shimmer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinking-shimmer.d.ts","names":[],"sources":["../../../../src/components/agents/loading-states/thinking-shimmer.tsx"],"mappings":";;UAOiB;;EAEf,WAAW;;EAEX;EACA;;iBAGc,kBACd,UACA,UACA,aACC,uCAAoB,IAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { TextShimmer } from "../../motion/text-shimmer.js";
|
|
3
|
+
import { cn } from "@kumix/utils";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/agents/loading-states/thinking-shimmer.tsx
|
|
6
|
+
function ThinkingShimmer({ children = "Thinking…", duration = 1.8, className }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(TextShimmer, {
|
|
8
|
+
as: "span",
|
|
9
|
+
duration,
|
|
10
|
+
className: cn("font-medium", className),
|
|
11
|
+
children
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { ThinkingShimmer };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=thinking-shimmer.js.map
|
|
@@ -0,0 +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\";\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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactElement, ReactNode } from "react";
|
|
2
|
+
import { HTMLMotionProps } from "motion/react";
|
|
3
|
+
//#region src/components/agents/message-bubble.d.ts
|
|
4
|
+
type MessageBubbleVariant = "solid" | "soft" | "tint" | "outline" | "ghost" | "danger";
|
|
5
|
+
type MessageBubbleAlign = "start" | "end";
|
|
6
|
+
interface MessageBubbleProps extends Omit<HTMLMotionProps<"div">, "children"> {
|
|
7
|
+
variant?: MessageBubbleVariant;
|
|
8
|
+
/** Defaults to the surrounding Message alignment when omitted. */
|
|
9
|
+
align?: MessageBubbleAlign;
|
|
10
|
+
/** Plays the bubble entrance once when this component mounts. */
|
|
11
|
+
animateIn?: boolean;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
interface MessageBubbleContentProps extends ComponentPropsWithRef<"div"> {
|
|
15
|
+
/** Replaces the content element while preserving bubble styling. */
|
|
16
|
+
render?: ReactElement;
|
|
17
|
+
}
|
|
18
|
+
interface MessageBubbleGroupProps extends ComponentPropsWithRef<"div"> {
|
|
19
|
+
spacing?: "compact" | "default";
|
|
20
|
+
}
|
|
21
|
+
interface MessageBubbleCollapsibleProps extends ComponentPropsWithRef<"div"> {
|
|
22
|
+
open?: boolean;
|
|
23
|
+
defaultOpen?: boolean;
|
|
24
|
+
onOpenChange?: (open: boolean) => void;
|
|
25
|
+
collapsedLines?: 2 | 3 | 4 | 5 | 6;
|
|
26
|
+
moreLabel?: ReactNode;
|
|
27
|
+
lessLabel?: ReactNode;
|
|
28
|
+
contentClassName?: string;
|
|
29
|
+
triggerClassName?: string;
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
}
|
|
32
|
+
declare function MessageBubble({ variant, align, animateIn, className, children, initial, animate, exit, transition, layout, ...props }: MessageBubbleProps): import("react").JSX.Element;
|
|
33
|
+
declare function MessageBubbleContent({ render, className, children, ref, ...props }: MessageBubbleContentProps): import("react").JSX.Element;
|
|
34
|
+
declare function MessageBubbleGroup({ spacing, className, ...props }: MessageBubbleGroupProps): import("react").JSX.Element;
|
|
35
|
+
declare function MessageBubbleCollapsible({ open, defaultOpen, onOpenChange, collapsedLines, moreLabel, lessLabel, contentClassName, triggerClassName, className, children, ...props }: MessageBubbleCollapsibleProps): import("react").JSX.Element;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { MessageBubble, MessageBubbleAlign, MessageBubbleCollapsible, MessageBubbleCollapsibleProps, MessageBubbleContent, MessageBubbleContentProps, MessageBubbleGroup, MessageBubbleGroupProps, MessageBubbleProps, MessageBubbleVariant };
|
|
38
|
+
//# sourceMappingURL=message-bubble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-bubble.d.ts","names":[],"sources":["../../../src/components/agents/message-bubble.tsx"],"mappings":";;;KAqBY;KACA;UAcK,2BAA2B,KAAK;EAC/C,UAAU;;EAEV,QAAQ;;EAER;EACA,WAAW;;UAGI,kCAAkC;;EAEjD,SAAS;;UAGM,gCAAgC;EAC/C;;UAGe,sCAAsC;EACrD;EACA;EACA,gBAAgB;EAChB;EACA,YAAY;EACZ,YAAY;EACZ;EACA;EACA,WAAW;;iBA0BG,gBACd,SACA,OACA,WACA,WACA,UACA,SACA,SACA,MACA,YACA,WACG,SACF,qCAAkB,IAAA;iBAqDL,uBACd,QACA,WACA,UACA,QACG,SACF,4CAAyB,IAAA;iBAqEZ,qBACd,SACA,cACG,SACF,0CAAuB,IAAA;iBAkBV,2BACd,MACA,aACA,cACA,gBACA,WACA,WACA,kBACA,kBACA,WACA,aACG,SACF,gDAA6B,IAAA"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from "../../lib/ease.js";
|
|
3
|
+
import { MessageSideContext } from "./message-context.js";
|
|
4
|
+
import { cloneElement, createContext, useCallback, useContext, useId, useState } from "react";
|
|
5
|
+
import { cn } from "@kumix/utils";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { motion, useReducedMotion } from "motion/react";
|
|
8
|
+
import { ChevronDown } from "lucide-react";
|
|
9
|
+
//#region src/components/agents/message-bubble.tsx
|
|
10
|
+
const MessageBubbleContext = createContext({
|
|
11
|
+
animateIn: true,
|
|
12
|
+
variant: "soft"
|
|
13
|
+
});
|
|
14
|
+
const MessageBubbleLayoutContext = createContext(() => {});
|
|
15
|
+
function mergeRefs(...refs) {
|
|
16
|
+
return (node) => {
|
|
17
|
+
for (const ref of refs) if (typeof ref === "function") ref(node);
|
|
18
|
+
else if (ref) ref.current = node;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const BUBBLE_CONTENT_REVEAL = {
|
|
22
|
+
duration: .12,
|
|
23
|
+
ease: EASE_OUT,
|
|
24
|
+
delay: .04
|
|
25
|
+
};
|
|
26
|
+
const BUBBLE_POP = {
|
|
27
|
+
type: "spring",
|
|
28
|
+
stiffness: 520,
|
|
29
|
+
damping: 27,
|
|
30
|
+
mass: .52
|
|
31
|
+
};
|
|
32
|
+
function MessageBubble({ variant = "soft", align, animateIn = false, className, children, initial, animate, exit, transition, layout, ...props }) {
|
|
33
|
+
const reduce = useReducedMotion() ?? false;
|
|
34
|
+
const messageSide = useContext(MessageSideContext);
|
|
35
|
+
const resolvedAlign = align ?? messageSide ?? "start";
|
|
36
|
+
return /* @__PURE__ */ jsx(MessageBubbleContext.Provider, {
|
|
37
|
+
value: {
|
|
38
|
+
align: resolvedAlign,
|
|
39
|
+
animateIn,
|
|
40
|
+
variant
|
|
41
|
+
},
|
|
42
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
43
|
+
"data-slot": "message-bubble",
|
|
44
|
+
"data-align": resolvedAlign,
|
|
45
|
+
"data-variant": variant,
|
|
46
|
+
layout,
|
|
47
|
+
initial: initial ?? false,
|
|
48
|
+
animate,
|
|
49
|
+
exit: exit ?? (reduce ? { opacity: 0 } : {
|
|
50
|
+
opacity: 0,
|
|
51
|
+
y: -3,
|
|
52
|
+
scale: .99
|
|
53
|
+
}),
|
|
54
|
+
transition: transition ?? (reduce ? { duration: .12 } : SPRING_LAYOUT),
|
|
55
|
+
className: cn("group/bubble flex w-full flex-col", resolvedAlign === "end" ? "items-end" : "items-start", className),
|
|
56
|
+
...props,
|
|
57
|
+
children
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function bubbleContentClass(variant, interactive) {
|
|
62
|
+
return cn("relative z-0 min-w-9 max-w-[82%] rounded-2xl px-3.5 py-2.5 text-foreground text-sm leading-6", "[&_a]:font-medium [&_a]:underline [&_a]:underline-offset-4 [&_code]:rounded [&_code]:bg-background/60 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em] [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p+p]:mt-2 [&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-xl [&_pre]:bg-background/60 [&_pre]:p-3 [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5", variant === "solid" && "text-background", variant === "ghost" && "w-full max-w-none rounded-none px-0 py-0", variant === "danger" && "text-destructive", interactive && "cursor-pointer text-left outline-none transition-[background-color,color,transform] duration-150 hover:brightness-[0.98] focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.99]");
|
|
63
|
+
}
|
|
64
|
+
function bubbleSurfaceClass(variant, align) {
|
|
65
|
+
return cn("pointer-events-none absolute inset-0 -z-10 rounded-[inherit]", align === "end" ? "origin-bottom-right" : "origin-bottom-left", variant === "solid" && "bg-foreground", variant === "soft" && "bg-muted", variant === "tint" && "bg-primary/10", variant === "outline" && "border border-border/70 bg-background", variant === "danger" && "bg-destructive/10");
|
|
66
|
+
}
|
|
67
|
+
function MessageBubbleContent({ render, className, children, ref, ...props }) {
|
|
68
|
+
const reduce = useReducedMotion() ?? false;
|
|
69
|
+
const { align = "start", animateIn, variant } = useContext(MessageBubbleContext);
|
|
70
|
+
const [layoutVersion, setLayoutVersion] = useState(0);
|
|
71
|
+
const notifyLayout = useCallback(() => setLayoutVersion((version) => version + 1), []);
|
|
72
|
+
const interactive = render?.type === "button" || render?.type === "a";
|
|
73
|
+
const classes = cn(bubbleContentClass(variant, interactive), className);
|
|
74
|
+
const composedChildren = /* @__PURE__ */ jsxs(Fragment$1, { children: [variant !== "ghost" ? /* @__PURE__ */ jsx(motion.span, {
|
|
75
|
+
"aria-hidden": "true",
|
|
76
|
+
layout: reduce ? false : "size",
|
|
77
|
+
layoutDependency: layoutVersion,
|
|
78
|
+
initial: animateIn && !reduce ? {
|
|
79
|
+
opacity: 0,
|
|
80
|
+
scale: .92
|
|
81
|
+
} : false,
|
|
82
|
+
animate: {
|
|
83
|
+
opacity: 1,
|
|
84
|
+
scale: 1
|
|
85
|
+
},
|
|
86
|
+
transition: reduce ? { duration: 0 } : {
|
|
87
|
+
opacity: {
|
|
88
|
+
duration: .12,
|
|
89
|
+
ease: EASE_OUT
|
|
90
|
+
},
|
|
91
|
+
scale: BUBBLE_POP,
|
|
92
|
+
layout: SPRING_LAYOUT
|
|
93
|
+
},
|
|
94
|
+
className: bubbleSurfaceClass(variant, align)
|
|
95
|
+
}) : null, /* @__PURE__ */ jsx(MessageBubbleLayoutContext.Provider, {
|
|
96
|
+
value: notifyLayout,
|
|
97
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
98
|
+
initial: animateIn ? reduce ? { opacity: 0 } : { opacity: 0 } : false,
|
|
99
|
+
animate: { opacity: 1 },
|
|
100
|
+
transition: reduce ? {
|
|
101
|
+
duration: .12,
|
|
102
|
+
ease: EASE_OUT
|
|
103
|
+
} : BUBBLE_CONTENT_REVEAL,
|
|
104
|
+
className: "relative",
|
|
105
|
+
children
|
|
106
|
+
})
|
|
107
|
+
})] });
|
|
108
|
+
if (render) {
|
|
109
|
+
const child = render;
|
|
110
|
+
return cloneElement(child, {
|
|
111
|
+
...props,
|
|
112
|
+
ref: mergeRefs(child.props.ref, ref),
|
|
113
|
+
className: cn(classes, child.props.className),
|
|
114
|
+
children: composedChildren,
|
|
115
|
+
"data-slot": "message-bubble-content"
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return /* @__PURE__ */ jsx("div", {
|
|
119
|
+
ref,
|
|
120
|
+
"data-slot": "message-bubble-content",
|
|
121
|
+
className: classes,
|
|
122
|
+
...props,
|
|
123
|
+
children: composedChildren
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function MessageBubbleGroup({ spacing = "compact", className, ...props }) {
|
|
127
|
+
return /* @__PURE__ */ jsx("div", {
|
|
128
|
+
"data-slot": "message-bubble-group",
|
|
129
|
+
className: cn("flex w-full flex-col", spacing === "compact" ? "gap-1.5" : "gap-3", className),
|
|
130
|
+
...props
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const LINE_CLAMP_CLASS = {
|
|
134
|
+
2: "line-clamp-2",
|
|
135
|
+
3: "line-clamp-3",
|
|
136
|
+
4: "line-clamp-4",
|
|
137
|
+
5: "line-clamp-5",
|
|
138
|
+
6: "line-clamp-6"
|
|
139
|
+
};
|
|
140
|
+
function MessageBubbleCollapsible({ open, defaultOpen = false, onOpenChange, collapsedLines = 4, moreLabel = "Show more", lessLabel = "Show less", contentClassName, triggerClassName, className, children, ...props }) {
|
|
141
|
+
const reduce = useReducedMotion() ?? false;
|
|
142
|
+
const contentId = useId();
|
|
143
|
+
const notifyLayout = useContext(MessageBubbleLayoutContext);
|
|
144
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
145
|
+
const currentOpen = open ?? internalOpen;
|
|
146
|
+
const setOpen = useCallback((next) => {
|
|
147
|
+
notifyLayout();
|
|
148
|
+
if (open === void 0) setInternalOpen(next);
|
|
149
|
+
onOpenChange?.(next);
|
|
150
|
+
}, [
|
|
151
|
+
notifyLayout,
|
|
152
|
+
onOpenChange,
|
|
153
|
+
open
|
|
154
|
+
]);
|
|
155
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
156
|
+
"data-slot": "message-bubble-collapsible",
|
|
157
|
+
"data-state": currentOpen ? "open" : "closed",
|
|
158
|
+
className: cn("w-full", className),
|
|
159
|
+
...props,
|
|
160
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
161
|
+
id: contentId,
|
|
162
|
+
className: cn("transition-[mask-image] duration-200", !currentOpen && LINE_CLAMP_CLASS[collapsedLines], !currentOpen && "mask-[linear-gradient(to_bottom,#000_68%,transparent_100%)]", contentClassName),
|
|
163
|
+
children
|
|
164
|
+
}), /* @__PURE__ */ jsxs("button", {
|
|
165
|
+
type: "button",
|
|
166
|
+
"aria-expanded": currentOpen,
|
|
167
|
+
"aria-controls": contentId,
|
|
168
|
+
onClick: () => setOpen(!currentOpen),
|
|
169
|
+
className: cn("mt-2 inline-flex h-7 items-center gap-1 rounded-full px-2 font-medium text-muted-foreground text-xs outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring", triggerClassName),
|
|
170
|
+
children: [/* @__PURE__ */ jsx("span", { children: currentOpen ? lessLabel : moreLabel }), /* @__PURE__ */ jsx(motion.span, {
|
|
171
|
+
"aria-hidden": "true",
|
|
172
|
+
animate: { rotate: currentOpen ? 180 : 0 },
|
|
173
|
+
transition: reduce ? { duration: 0 } : SPRING_SWAP,
|
|
174
|
+
children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-3.5" })
|
|
175
|
+
})]
|
|
176
|
+
})]
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
export { MessageBubble, MessageBubbleCollapsible, MessageBubbleContent, MessageBubbleGroup };
|
|
181
|
+
|
|
182
|
+
//# sourceMappingURL=message-bubble.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-bubble.js","names":[],"sources":["../../../src/components/agents/message-bubble.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentPropsWithRef,\n cloneElement,\n createContext,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useContext,\n useId,\n useState,\n} from \"react\";\nimport { ChevronDown } from \"lucide-react\";\nimport { type HTMLMotionProps, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from \"../../lib/ease\";\nimport { MessageSideContext } from \"./message-context\";\n\nexport type MessageBubbleVariant = \"solid\" | \"soft\" | \"tint\" | \"outline\" | \"ghost\" | \"danger\";\nexport type MessageBubbleAlign = \"start\" | \"end\";\n\ninterface MessageBubbleContextValue {\n align?: MessageBubbleAlign;\n animateIn: boolean;\n variant: MessageBubbleVariant;\n}\n\nconst MessageBubbleContext = createContext<MessageBubbleContextValue>({\n animateIn: true,\n variant: \"soft\",\n});\nconst MessageBubbleLayoutContext = createContext<() => void>(() => {});\n\nexport interface MessageBubbleProps extends Omit<HTMLMotionProps<\"div\">, \"children\"> {\n variant?: MessageBubbleVariant;\n /** Defaults to the surrounding Message alignment when omitted. */\n align?: MessageBubbleAlign;\n /** Plays the bubble entrance once when this component mounts. */\n animateIn?: boolean;\n children?: ReactNode;\n}\n\nexport interface MessageBubbleContentProps extends ComponentPropsWithRef<\"div\"> {\n /** Replaces the content element while preserving bubble styling. */\n render?: ReactElement;\n}\n\nexport interface MessageBubbleGroupProps extends ComponentPropsWithRef<\"div\"> {\n spacing?: \"compact\" | \"default\";\n}\n\nexport interface MessageBubbleCollapsibleProps extends ComponentPropsWithRef<\"div\"> {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n collapsedLines?: 2 | 3 | 4 | 5 | 6;\n moreLabel?: ReactNode;\n lessLabel?: ReactNode;\n contentClassName?: string;\n triggerClassName?: string;\n children?: ReactNode;\n}\n\nfunction mergeRefs<T>(...refs: Array<Ref<T> | undefined>) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }\n };\n}\n\nconst BUBBLE_CONTENT_REVEAL = {\n duration: 0.12,\n ease: EASE_OUT,\n delay: 0.04,\n} as const;\n\n// Sent bubbles should pop into place quickly with one restrained overshoot.\nconst BUBBLE_POP = {\n type: \"spring\",\n stiffness: 520,\n damping: 27,\n mass: 0.52,\n} as const;\n\nexport function MessageBubble({\n variant = \"soft\",\n align,\n animateIn = false,\n className,\n children,\n initial,\n animate,\n exit,\n transition,\n layout,\n ...props\n}: MessageBubbleProps) {\n const reduce = useReducedMotion() ?? false;\n const messageSide = useContext(MessageSideContext);\n const resolvedAlign = align ?? messageSide ?? \"start\";\n\n return (\n <MessageBubbleContext.Provider value={{ align: resolvedAlign, animateIn, variant }}>\n <motion.div\n data-slot=\"message-bubble\"\n data-align={resolvedAlign}\n data-variant={variant}\n layout={layout}\n initial={initial ?? false}\n animate={animate}\n exit={exit ?? (reduce ? { opacity: 0 } : { opacity: 0, y: -3, scale: 0.99 })}\n transition={transition ?? (reduce ? { duration: 0.12 } : SPRING_LAYOUT)}\n className={cn(\n \"group/bubble flex w-full flex-col\",\n resolvedAlign === \"end\" ? \"items-end\" : \"items-start\",\n className,\n )}\n {...props}\n >\n {children}\n </motion.div>\n </MessageBubbleContext.Provider>\n );\n}\n\nfunction bubbleContentClass(variant: MessageBubbleVariant, interactive: boolean) {\n return cn(\n \"relative z-0 min-w-9 max-w-[82%] rounded-2xl px-3.5 py-2.5 text-foreground text-sm leading-6\",\n \"[&_a]:font-medium [&_a]:underline [&_a]:underline-offset-4 [&_code]:rounded [&_code]:bg-background/60 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em] [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p+p]:mt-2 [&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-xl [&_pre]:bg-background/60 [&_pre]:p-3 [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5\",\n variant === \"solid\" && \"text-background\",\n variant === \"ghost\" && \"w-full max-w-none rounded-none px-0 py-0\",\n variant === \"danger\" && \"text-destructive\",\n interactive &&\n \"cursor-pointer text-left outline-none transition-[background-color,color,transform] duration-150 hover:brightness-[0.98] focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.99]\",\n );\n}\n\nfunction bubbleSurfaceClass(variant: MessageBubbleVariant, align: MessageBubbleAlign) {\n return cn(\n \"pointer-events-none absolute inset-0 -z-10 rounded-[inherit]\",\n align === \"end\" ? \"origin-bottom-right\" : \"origin-bottom-left\",\n variant === \"solid\" && \"bg-foreground\",\n variant === \"soft\" && \"bg-muted\",\n variant === \"tint\" && \"bg-primary/10\",\n variant === \"outline\" && \"border border-border/70 bg-background\",\n variant === \"danger\" && \"bg-destructive/10\",\n );\n}\n\nexport function MessageBubbleContent({\n render,\n className,\n children,\n ref,\n ...props\n}: MessageBubbleContentProps) {\n const reduce = useReducedMotion() ?? false;\n const { align = \"start\", animateIn, variant } = useContext(MessageBubbleContext);\n const [layoutVersion, setLayoutVersion] = useState(0);\n const notifyLayout = useCallback(() => setLayoutVersion((version) => version + 1), []);\n const interactive = render?.type === \"button\" || render?.type === \"a\";\n const classes = cn(bubbleContentClass(variant, interactive), className);\n const composedChildren = (\n <>\n {variant !== \"ghost\" ? (\n <motion.span\n aria-hidden=\"true\"\n layout={reduce ? false : \"size\"}\n layoutDependency={layoutVersion}\n initial={\n animateIn && !reduce\n ? {\n opacity: 0,\n scale: 0.92,\n }\n : false\n }\n animate={{ opacity: 1, scale: 1 }}\n transition={\n reduce\n ? { duration: 0 }\n : {\n opacity: { duration: 0.12, ease: EASE_OUT },\n scale: BUBBLE_POP,\n layout: SPRING_LAYOUT,\n }\n }\n className={bubbleSurfaceClass(variant, align)}\n />\n ) : null}\n <MessageBubbleLayoutContext.Provider value={notifyLayout}>\n <motion.div\n initial={animateIn ? (reduce ? { opacity: 0 } : { opacity: 0 }) : false}\n animate={{ opacity: 1 }}\n transition={reduce ? { duration: 0.12, ease: EASE_OUT } : BUBBLE_CONTENT_REVEAL}\n className=\"relative\"\n >\n {children}\n </motion.div>\n </MessageBubbleLayoutContext.Provider>\n </>\n );\n\n if (render) {\n const child = render as ReactElement<\n Record<string, unknown> & { className?: string; ref?: Ref<HTMLElement> }\n >;\n\n return cloneElement(child, {\n ...props,\n ref: mergeRefs(child.props.ref, ref as Ref<HTMLElement> | undefined),\n className: cn(classes, child.props.className),\n children: composedChildren,\n \"data-slot\": \"message-bubble-content\",\n });\n }\n\n return (\n <div ref={ref} data-slot=\"message-bubble-content\" className={classes} {...props}>\n {composedChildren}\n </div>\n );\n}\n\nexport function MessageBubbleGroup({\n spacing = \"compact\",\n className,\n ...props\n}: MessageBubbleGroupProps) {\n return (\n <div\n data-slot=\"message-bubble-group\"\n className={cn(\"flex w-full flex-col\", spacing === \"compact\" ? \"gap-1.5\" : \"gap-3\", className)}\n {...props}\n />\n );\n}\n\nconst LINE_CLAMP_CLASS = {\n 2: \"line-clamp-2\",\n 3: \"line-clamp-3\",\n 4: \"line-clamp-4\",\n 5: \"line-clamp-5\",\n 6: \"line-clamp-6\",\n} as const;\n\nexport function MessageBubbleCollapsible({\n open,\n defaultOpen = false,\n onOpenChange,\n collapsedLines = 4,\n moreLabel = \"Show more\",\n lessLabel = \"Show less\",\n contentClassName,\n triggerClassName,\n className,\n children,\n ...props\n}: MessageBubbleCollapsibleProps) {\n const reduce = useReducedMotion() ?? false;\n const contentId = useId();\n const notifyLayout = useContext(MessageBubbleLayoutContext);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const currentOpen = open ?? internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n notifyLayout();\n if (open === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [notifyLayout, onOpenChange, open],\n );\n\n return (\n <div\n data-slot=\"message-bubble-collapsible\"\n data-state={currentOpen ? \"open\" : \"closed\"}\n className={cn(\"w-full\", className)}\n {...props}\n >\n <div\n id={contentId}\n className={cn(\n \"transition-[mask-image] duration-200\",\n !currentOpen && LINE_CLAMP_CLASS[collapsedLines],\n !currentOpen && \"mask-[linear-gradient(to_bottom,#000_68%,transparent_100%)]\",\n contentClassName,\n )}\n >\n {children}\n </div>\n <button\n type=\"button\"\n aria-expanded={currentOpen}\n aria-controls={contentId}\n onClick={() => setOpen(!currentOpen)}\n className={cn(\n \"mt-2 inline-flex h-7 items-center gap-1 rounded-full px-2 font-medium text-muted-foreground text-xs outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\",\n triggerClassName,\n )}\n >\n <span>{currentOpen ? lessLabel : moreLabel}</span>\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotate: currentOpen ? 180 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n >\n <ChevronDown className=\"size-3.5\" />\n </motion.span>\n </button>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AA8BA,MAAM,uBAAuB,cAAyC;CACpE,WAAW;CACX,SAAS;AACX,CAAC;AACD,MAAM,6BAA6B,oBAAgC,CAAC,CAAC;AAgCrE,SAAS,UAAa,GAAG,MAAiC;CACxD,QAAQ,SAAmB;EACzB,KAAK,MAAM,OAAO,MAChB,IAAI,OAAO,QAAQ,YAAY,IAAI,IAAI;OAClC,IAAI,KAAK,IAAI,UAAU;CAEhC;AACF;AAEA,MAAM,wBAAwB;CAC5B,UAAU;CACV,MAAM;CACN,OAAO;AACT;AAGA,MAAM,aAAa;CACjB,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,SAAgB,cAAc,EAC5B,UAAU,QACV,OACA,YAAY,OACZ,WACA,UACA,SACA,SACA,MACA,YACA,QACA,GAAG,SACkB;CACrB,MAAM,SAAS,iBAAiB,KAAK;CACrC,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,gBAAgB,SAAS,eAAe;CAE9C,OACE,oBAAC,qBAAqB,UAAtB;EAA+B,OAAO;GAAE,OAAO;GAAe;GAAW;EAAQ;EAC/E,UAAA,oBAAC,OAAO,KAAR;GACE,aAAU;GACV,cAAY;GACZ,gBAAc;GACN;GACR,SAAS,WAAW;GACX;GACT,MAAM,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;IAAE,SAAS;IAAG,GAAG;IAAI,OAAO;GAAK;GAC1E,YAAY,eAAe,SAAS,EAAE,UAAU,IAAK,IAAI;GACzD,WAAW,GACT,qCACA,kBAAkB,QAAQ,cAAc,eACxC,SACF;GACA,GAAI;GAEH;EACS,CAAA;CACiB,CAAA;AAEnC;AAEA,SAAS,mBAAmB,SAA+B,aAAsB;CAC/E,OAAO,GACL,gGACA,+WACA,YAAY,WAAW,mBACvB,YAAY,WAAW,4CACvB,YAAY,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gBACF;GAEC;EACE,CAAA,GACL,qBAAC,UAAD;GACE,MAAK;GACL,iBAAe;GACf,iBAAe;GACf,eAAe,QAAQ,CAAC,WAAW;GACnC,WAAW,GACT,wNACA,gBACF;GARF,UAAA,CAUE,oBAAC,QAAD,EAAA,UAAO,cAAc,YAAY,UAAgB,CAAA,GACjD,oBAAC,OAAO,MAAR;IACE,eAAY;IACZ,SAAS,EAAE,QAAQ,cAAc,MAAM,EAAE;IACzC,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;IAEvC,UAAA,oBAAC,aAAD,EAAa,WAAU,WAAY,CAAA;GACxB,CAAA,CACP;EACL,CAAA,CAAA;;AAET"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/components/agents/message-context.d.ts
|
|
2
|
+
type MessageSide = "start" | "end";
|
|
3
|
+
declare const MessageSideContext: import("react").Context<MessageSide | undefined>;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { MessageSide, MessageSideContext };
|
|
6
|
+
//# sourceMappingURL=message-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-context.d.ts","names":[],"sources":["../../../src/components/agents/message-context.tsx"],"mappings":";KAIY;cAEC,oCAAkB,QAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-context.js","names":[],"sources":["../../../src/components/agents/message-context.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\n\nexport type MessageSide = \"start\" | \"end\";\n\nexport const MessageSideContext = createContext<MessageSide | undefined>(undefined);\n"],"mappings":";;;AAMA,MAAa,qBAAqB,cAAuC,KAAA,CAAS"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, Ref } from "react";
|
|
2
|
+
//#region src/components/agents/message-scroller.d.ts
|
|
3
|
+
interface MessageScrollerProps extends ComponentPropsWithRef<"div"> {
|
|
4
|
+
/** Keep streamed output pinned while the reader remains near the end. */
|
|
5
|
+
followOutput?: boolean;
|
|
6
|
+
/** Distance from the end that still counts as following the output. */
|
|
7
|
+
followThreshold?: number;
|
|
8
|
+
/** Smoothly follow growing content. */
|
|
9
|
+
smooth?: boolean;
|
|
10
|
+
/** Reports when the reader leaves or returns to the live edge. */
|
|
11
|
+
onFollowChange?: (following: boolean) => void;
|
|
12
|
+
/** Accessible label for the scrollable transcript. */
|
|
13
|
+
label?: string;
|
|
14
|
+
/** Marks the transcript as waiting for more streamed content. */
|
|
15
|
+
busy?: boolean;
|
|
16
|
+
/** Adds a compact rail for navigating between rendered Message rows. */
|
|
17
|
+
navigation?: "rail";
|
|
18
|
+
/** Accessible label for the optional message navigation rail. */
|
|
19
|
+
navigationLabel?: string;
|
|
20
|
+
viewportClassName?: string;
|
|
21
|
+
contentClassName?: string;
|
|
22
|
+
railClassName?: string;
|
|
23
|
+
viewportRef?: Ref<HTMLElement>;
|
|
24
|
+
viewportProps?: Omit<ComponentPropsWithRef<"section">, "children" | "className" | "ref">;
|
|
25
|
+
contentProps?: Omit<ComponentPropsWithRef<"div">, "children" | "className" | "ref">;
|
|
26
|
+
}
|
|
27
|
+
declare function MessageScroller({ followOutput, followThreshold, smooth, onFollowChange, label, busy, navigation, navigationLabel, viewportClassName, contentClassName, railClassName, viewportRef: externalViewportRef, viewportProps, contentProps, className, children, ...props }: MessageScrollerProps): import("react").JSX.Element;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { MessageScroller, MessageScrollerProps };
|
|
30
|
+
//# sourceMappingURL=message-scroller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-scroller.d.ts","names":[],"sources":["../../../src/components/agents/message-scroller.tsx"],"mappings":";;UAkEiB,6BAA6B;;EAE5C;;EAEA;;EAEA;;EAEA,kBAAkB;;EAElB;;EAEA;;EAEA;;EAEA;EACA;EACA;EACA;EACA,cAAc,IAAI;EAClB,gBAAgB,KAAK;EACrB,eAAe,KAAK;;iBAGN,kBACd,cACA,iBACA,QACA,gBACA,OACA,MACA,YACA,iBACA,mBACA,kBACA,eACA,aAAa,qBACb,eACA,cACA,WACA,aACG,SACF,uCAAoB,IAAA"}
|