@springbrand/message-panel 0.1.0 → 0.1.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/dist/demo/camel-chat-showcase.d.ts +1 -0
- package/dist/demo/camel-chat-showcase.js +1007 -0
- package/dist/demo/fixtures.d.ts +32 -0
- package/dist/demo/fixtures.js +250 -0
- package/dist/demo/index.js +4 -0
- package/dist/demo/message-panel-chat-showcase.d.ts +1 -0
- package/dist/demo/message-panel-chat-showcase.js +114 -0
- package/dist/demo/message-panel-gallery.d.ts +1 -0
- package/dist/demo/message-panel-gallery.js +130 -0
- package/dist/src/adapters/ai-sdk.d.ts +4 -0
- package/dist/src/adapters/ai-sdk.js +25 -0
- package/dist/src/camel/camel-chat-messages.d.ts +44 -0
- package/dist/src/camel/camel-chat-messages.js +421 -0
- package/dist/src/camel/camel-model-select.d.ts +13 -0
- package/dist/src/camel/camel-model-select.js +7 -0
- package/dist/src/camel/camel-plan-bar.d.ts +5 -0
- package/dist/src/camel/camel-plan-bar.js +24 -0
- package/dist/src/camel/camel-prompt-input.d.ts +32 -0
- package/dist/src/camel/camel-prompt-input.js +182 -0
- package/dist/src/camel/camel-tool-presentation.d.ts +21 -0
- package/dist/src/camel/camel-tool-presentation.js +784 -0
- package/dist/src/camel/camel-turn.d.ts +57 -0
- package/dist/src/camel/camel-turn.js +203 -0
- package/dist/src/camel/index.js +7 -0
- package/dist/src/camel/turn-summary-bar.d.ts +8 -0
- package/dist/src/camel/turn-summary-bar.js +12 -0
- package/dist/src/chat-summary-panel.d.ts +22 -0
- package/dist/src/chat-summary-panel.js +26 -0
- package/dist/src/composer/chat-composer.d.ts +4 -0
- package/dist/src/composer/chat-composer.js +90 -0
- package/dist/src/composer/composer-attachments.d.ts +13 -0
- package/dist/src/composer/composer-attachments.js +47 -0
- package/dist/src/composer/composer-trigger-popover.d.ts +31 -0
- package/dist/src/composer/composer-trigger-popover.js +29 -0
- package/dist/src/composer/composer.d.ts +15 -0
- package/dist/src/composer/composer.js +180 -0
- package/dist/src/composer/drop-controller.d.ts +8 -0
- package/dist/src/composer/drop-controller.js +69 -0
- package/dist/src/composer/index.js +6 -0
- package/dist/src/composer/types.d.ts +62 -0
- package/dist/src/composer/types.js +1 -0
- package/dist/src/contracts.d.ts +94 -0
- package/dist/src/contracts.js +1 -0
- package/dist/src/conversation.d.ts +13 -0
- package/dist/src/conversation.js +18 -0
- package/dist/src/index.js +12 -0
- package/dist/src/internal/cn.d.ts +1 -0
- package/dist/src/internal/cn.js +3 -0
- package/dist/src/message-panel.d.ts +4 -0
- package/dist/src/message-panel.js +144 -0
- package/dist/src/message.d.ts +36 -0
- package/dist/src/message.js +83 -0
- package/dist/src/parts/index.d.ts +187 -0
- package/dist/src/parts/index.js +332 -0
- package/dist/src/parts/kind.d.ts +3 -0
- package/dist/src/parts/kind.js +69 -0
- package/dist/src/parts/plan.d.ts +10 -0
- package/dist/src/parts/plan.js +40 -0
- package/dist/src/parts/primitives.d.ts +70 -0
- package/dist/src/parts/primitives.js +153 -0
- package/dist/src/registry.d.ts +4 -0
- package/dist/src/registry.js +31 -0
- package/dist/src/status.d.ts +26 -0
- package/dist/src/status.js +74 -0
- package/package.json +17 -8
- package/demo/camel-chat-showcase.tsx +0 -1265
- package/demo/fixtures.ts +0 -292
- package/demo/message-panel-chat-showcase.tsx +0 -250
- package/demo/message-panel-gallery.tsx +0 -389
- package/src/adapters/ai-sdk.ts +0 -32
- package/src/camel/camel-chat-messages.tsx +0 -1420
- package/src/camel/camel-model-select.tsx +0 -88
- package/src/camel/camel-plan-bar.tsx +0 -115
- package/src/camel/camel-prompt-input.tsx +0 -540
- package/src/camel/camel-tool-presentation.tsx +0 -1270
- package/src/camel/camel-turn.ts +0 -315
- package/src/camel/turn-summary-bar.tsx +0 -81
- package/src/chat-summary-panel.tsx +0 -229
- package/src/composer/chat-composer.tsx +0 -216
- package/src/composer/composer-attachments.tsx +0 -138
- package/src/composer/composer-trigger-popover.tsx +0 -236
- package/src/composer/composer.tsx +0 -425
- package/src/composer/drop-controller.ts +0 -80
- package/src/composer/types.ts +0 -79
- package/src/contracts.ts +0 -139
- package/src/conversation.tsx +0 -76
- package/src/internal/cn.ts +0 -3
- package/src/message-panel.tsx +0 -368
- package/src/message.tsx +0 -254
- package/src/parts/index.tsx +0 -1149
- package/src/parts/kind.ts +0 -67
- package/src/parts/plan.ts +0 -63
- package/src/parts/primitives.tsx +0 -439
- package/src/registry.ts +0 -44
- package/src/status.tsx +0 -132
- /package/{demo/index.ts → dist/demo/index.d.ts} +0 -0
- /package/{src/camel/index.ts → dist/src/camel/index.d.ts} +0 -0
- /package/{src/composer/index.ts → dist/src/composer/index.d.ts} +0 -0
- /package/{src/index.ts → dist/src/index.d.ts} +0 -0
package/src/status.tsx
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { ThinkingOrb, type OrbState } from "thinking-orbs";
|
|
3
|
-
import type { MessagePanelStatus } from "./contracts";
|
|
4
|
-
import { cn } from "./internal/cn";
|
|
5
|
-
import { resolvePartKind, toolNameOfPart } from "./parts/kind";
|
|
6
|
-
|
|
7
|
-
export type PanelVisualState =
|
|
8
|
-
| "empty"
|
|
9
|
-
| "hydrating"
|
|
10
|
-
| "thinking"
|
|
11
|
-
| "streaming"
|
|
12
|
-
| "ready"
|
|
13
|
-
| "error"
|
|
14
|
-
| "recovering"
|
|
15
|
-
| "background";
|
|
16
|
-
|
|
17
|
-
export function derivePanelVisualState({
|
|
18
|
-
messageCount,
|
|
19
|
-
status,
|
|
20
|
-
isHydrating = false,
|
|
21
|
-
isRecovering = false,
|
|
22
|
-
isServerStreaming = false,
|
|
23
|
-
}: {
|
|
24
|
-
messageCount: number;
|
|
25
|
-
status: MessagePanelStatus;
|
|
26
|
-
isHydrating?: boolean;
|
|
27
|
-
isRecovering?: boolean;
|
|
28
|
-
isServerStreaming?: boolean;
|
|
29
|
-
}): PanelVisualState {
|
|
30
|
-
if (isHydrating) return "hydrating";
|
|
31
|
-
if (status === "error") return "error";
|
|
32
|
-
if (isRecovering) return "recovering";
|
|
33
|
-
if (isServerStreaming) return "background";
|
|
34
|
-
if (status === "submitted") return "thinking";
|
|
35
|
-
if (status === "streaming") return "streaming";
|
|
36
|
-
return messageCount === 0 ? "empty" : "ready";
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function ThinkingIndicator({
|
|
40
|
-
label = "Thinking…",
|
|
41
|
-
state = "solving",
|
|
42
|
-
className,
|
|
43
|
-
}: {
|
|
44
|
-
label?: string;
|
|
45
|
-
state?: OrbState;
|
|
46
|
-
className?: string;
|
|
47
|
-
}) {
|
|
48
|
-
return (
|
|
49
|
-
<div className={cn("sb-thinking", className)} role="status" aria-label={label}>
|
|
50
|
-
<ThinkingOrb state={state} size={20} aria-hidden="true" />
|
|
51
|
-
<span>{label}</span>
|
|
52
|
-
</div>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function deriveThinkingActivity(part?: unknown): {
|
|
57
|
-
state: OrbState;
|
|
58
|
-
label: string;
|
|
59
|
-
} {
|
|
60
|
-
const kind = resolvePartKind(part);
|
|
61
|
-
const toolName = toolNameOfPart(part);
|
|
62
|
-
if (kind === "reasoning") return { state: "solving", label: "Reasoning…" };
|
|
63
|
-
if (kind === "text") return { state: "composing", label: "Composing answer…" };
|
|
64
|
-
if (
|
|
65
|
-
["plan", "image", "chart", "dashboard"].includes(kind ?? "") ||
|
|
66
|
-
(toolName != null &&
|
|
67
|
-
/(?:^|[_-])(?:image|chart|artifact|render|write_file)(?:$|[_-])/i.test(
|
|
68
|
-
toolName,
|
|
69
|
-
))
|
|
70
|
-
) {
|
|
71
|
-
return { state: "shaping", label: "Shaping result…" };
|
|
72
|
-
}
|
|
73
|
-
if (
|
|
74
|
-
toolName != null &&
|
|
75
|
-
/(?:^|[_-])(?:search|fetch|browse|browser|web)(?:$|[_-])/i.test(toolName)
|
|
76
|
-
) {
|
|
77
|
-
return { state: "searching", label: "Searching…" };
|
|
78
|
-
}
|
|
79
|
-
if (toolName != null) {
|
|
80
|
-
return {
|
|
81
|
-
state: "working",
|
|
82
|
-
label: `Running ${toolName.replaceAll("_", " ")}…`,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
return part === undefined
|
|
86
|
-
? { state: "solving", label: "Thinking…" }
|
|
87
|
-
: { state: "working", label: "Working…" };
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
type LoadingPhase = "idle" | "loading" | "done";
|
|
91
|
-
|
|
92
|
-
export function TopLoadingBar({ status }: { status: MessagePanelStatus }) {
|
|
93
|
-
const [phase, setPhase] = useState<LoadingPhase>("idle");
|
|
94
|
-
const previous = useRef(status);
|
|
95
|
-
|
|
96
|
-
useEffect(() => {
|
|
97
|
-
const before = previous.current;
|
|
98
|
-
previous.current = status;
|
|
99
|
-
if (status === "submitted") {
|
|
100
|
-
setPhase("loading");
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (before === "submitted" && status === "streaming") {
|
|
104
|
-
setPhase("done");
|
|
105
|
-
const timeout = window.setTimeout(() => setPhase("idle"), 500);
|
|
106
|
-
return () => window.clearTimeout(timeout);
|
|
107
|
-
}
|
|
108
|
-
if (status !== "streaming") setPhase("idle");
|
|
109
|
-
}, [status]);
|
|
110
|
-
|
|
111
|
-
if (phase === "idle") return null;
|
|
112
|
-
return (
|
|
113
|
-
<div className="sb-top-loading" role="progressbar" aria-label="等待响应">
|
|
114
|
-
<span data-phase={phase} />
|
|
115
|
-
</div>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function PanelStatus({
|
|
120
|
-
kind,
|
|
121
|
-
children,
|
|
122
|
-
}: {
|
|
123
|
-
kind: "hydrating" | "recovering" | "background" | "error";
|
|
124
|
-
children: React.ReactNode;
|
|
125
|
-
}) {
|
|
126
|
-
return (
|
|
127
|
-
<div className="sb-panel-status" data-kind={kind} role={kind === "error" ? "alert" : "status"}>
|
|
128
|
-
<span aria-hidden="true" />
|
|
129
|
-
{children}
|
|
130
|
-
</div>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|