@langchain/macaw-components 1.3.1 → 1.3.3
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/catalog.json +572 -497
- package/dist/components/ChatMessage/ChatMessage.d.ts +64 -0
- package/dist/components/ChatMessage/ChatMessage.js +216 -0
- package/dist/components/ChatMessage/ChatMessage.js.map +1 -0
- package/dist/components/ChatMessage/ChatMessage.types.d.ts +32 -0
- package/dist/components/ChatMessage/ChatMessage.types.js +0 -0
- package/dist/components/ChatMessage/index.d.ts +3 -0
- package/dist/components/ChatMessage/index.js +2 -0
- package/dist/components/Select/Select.js +1 -1
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +3 -2
- package/dist/index.js +3 -2
- package/dist/utilities.css +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef, type ReactNode } from 'react';
|
|
2
|
+
import { type AvatarProps } from '../Avatar/index.js';
|
|
3
|
+
import type { ChatMessageActionCapabilities, ChatMessageContentBlock, ChatMessageModel, ChatMessageStatus } from './ChatMessage.types.js';
|
|
4
|
+
export interface ChatMessageProps extends ComponentPropsWithRef<'div'> {
|
|
5
|
+
message: ChatMessageModel;
|
|
6
|
+
/** Metadata and actions share the message's footer layout and visibility. */
|
|
7
|
+
footer?: ReactNode;
|
|
8
|
+
/** `Avatar` shown before the name in the default header, sized to match it. */
|
|
9
|
+
avatar?: Omit<AvatarProps, 'size'>;
|
|
10
|
+
/**
|
|
11
|
+
* Name shown after the avatar in the default header. A string name also
|
|
12
|
+
* labels the message for screen readers; otherwise the avatar's label or
|
|
13
|
+
* the role label does.
|
|
14
|
+
*/
|
|
15
|
+
name?: ReactNode;
|
|
16
|
+
/** Defaults to end for user messages and start for other roles. */
|
|
17
|
+
align?: 'start' | 'end';
|
|
18
|
+
/** Keeps the footer visible; earlier messages reveal it on hover or focus. */
|
|
19
|
+
isLatest?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Fade in complete text blocks as they mount; keep their IDs stable. A
|
|
22
|
+
* message that mounts already settled, such as history, doesn't fade in.
|
|
23
|
+
*/
|
|
24
|
+
animateParagraphs?: boolean;
|
|
25
|
+
contentClassName?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* One message in a conversation. Renders a header and the message's content
|
|
29
|
+
* blocks, or `children` in their place for custom layouts. The footer is
|
|
30
|
+
* hidden, but keeps its space, while the message streams.
|
|
31
|
+
*/
|
|
32
|
+
export declare function ChatMessage({ message, footer, avatar, name, align, isLatest, animateParagraphs, className, contentClassName, children, ...props }: ChatMessageProps): import("react").JSX.Element;
|
|
33
|
+
export interface ChatMessageHeaderProps extends ComponentPropsWithRef<'div'> {
|
|
34
|
+
avatar?: Omit<AvatarProps, 'size'>;
|
|
35
|
+
name?: ReactNode;
|
|
36
|
+
status?: ChatMessageStatus;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Avatar, name, and status line. Renders nothing without any of them or
|
|
40
|
+
* children, unless it has shown a streaming status.
|
|
41
|
+
*/
|
|
42
|
+
export declare function ChatMessageHeader({ avatar, name, status, children, className, ...props }: ChatMessageHeaderProps): import("react").JSX.Element | null;
|
|
43
|
+
export interface ChatMessageBodyProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {
|
|
44
|
+
blocks: readonly ChatMessageContentBlock[];
|
|
45
|
+
/** Supply one complete paragraph per text block; existing blocks do not replay. */
|
|
46
|
+
animateParagraphs?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** Content blocks in order. Text blocks render as escaped plain text. */
|
|
49
|
+
export declare function ChatMessageBody({ blocks, animateParagraphs, className, ...props }: ChatMessageBodyProps): import("react").JSX.Element | null;
|
|
50
|
+
export interface ChatMessageActionsProps extends ComponentPropsWithRef<'div'> {
|
|
51
|
+
actions?: ChatMessageActionCapabilities;
|
|
52
|
+
status?: ChatMessageStatus;
|
|
53
|
+
readOnly?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Copy, edit, and retry buttons, plus any host actions in `children`. Edit
|
|
57
|
+
* and retry are hidden while the message is pending or read-only; copy stays
|
|
58
|
+
* available. Renders nothing when no actions remain.
|
|
59
|
+
*/
|
|
60
|
+
export declare function ChatMessageActions({ actions, status, readOnly, children, className, ...props }: ChatMessageActionsProps): import("react").JSX.Element | null;
|
|
61
|
+
export interface ChatTurnDividerProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {
|
|
62
|
+
label: string;
|
|
63
|
+
}
|
|
64
|
+
export declare function ChatTurnDivider({ label, className, ...props }: ChatTurnDividerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { Text } from "../Text/Text.js";
|
|
3
|
+
import { Avatar } from "../Avatar/Avatar.js";
|
|
4
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
5
|
+
import { Icon } from "../Icon/Icon.js";
|
|
6
|
+
import { Divider } from "../Divider/Divider.js";
|
|
7
|
+
import { ThinkingState } from "../ThinkingState/ThinkingState.js";
|
|
8
|
+
import { Fragment, useState } from "react";
|
|
9
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { WarningCircleIcon } from "@phosphor-icons/react/dist/ssr/WarningCircle";
|
|
11
|
+
import { ArrowClockwiseIcon } from "@phosphor-icons/react/dist/ssr/ArrowClockwise";
|
|
12
|
+
import { CopySimpleIcon } from "@phosphor-icons/react/dist/ssr/CopySimple";
|
|
13
|
+
import { PencilSimpleIcon } from "@phosphor-icons/react/dist/ssr/PencilSimple";
|
|
14
|
+
//#region packages/components/src/components/ChatMessage/ChatMessage.tsx
|
|
15
|
+
var roleLabels = {
|
|
16
|
+
user: "User",
|
|
17
|
+
assistant: "Assistant",
|
|
18
|
+
system: "System",
|
|
19
|
+
tool: "Tool"
|
|
20
|
+
};
|
|
21
|
+
var statusLabels = {
|
|
22
|
+
idle: null,
|
|
23
|
+
queued: "Queued",
|
|
24
|
+
submitting: "Sending",
|
|
25
|
+
streaming: "Responding",
|
|
26
|
+
interrupted: "Interrupted",
|
|
27
|
+
failed: "Failed",
|
|
28
|
+
stopped: "Stopped",
|
|
29
|
+
completed: null
|
|
30
|
+
};
|
|
31
|
+
var settledStatuses = /* @__PURE__ */ new Set([
|
|
32
|
+
"completed",
|
|
33
|
+
"failed",
|
|
34
|
+
"stopped",
|
|
35
|
+
"interrupted"
|
|
36
|
+
]);
|
|
37
|
+
/**
|
|
38
|
+
* One message in a conversation. Renders a header and the message's content
|
|
39
|
+
* blocks, or `children` in their place for custom layouts. The footer is
|
|
40
|
+
* hidden, but keeps its space, while the message streams.
|
|
41
|
+
*/
|
|
42
|
+
function ChatMessage({ message, footer, avatar, name, align, isLatest = false, animateParagraphs = false, className, contentClassName, children, ...props }) {
|
|
43
|
+
const alignment = align ?? (message.role === "user" ? "end" : "start");
|
|
44
|
+
const isStreaming = message.status === "streaming";
|
|
45
|
+
const isSettled = settledStatuses.has(message.status);
|
|
46
|
+
const [isHistory, setIsHistory] = useState(isSettled);
|
|
47
|
+
if (isHistory && !isSettled) setIsHistory(false);
|
|
48
|
+
return /* @__PURE__ */ jsx("div", {
|
|
49
|
+
role: "article",
|
|
50
|
+
"aria-label": `${typeof name === "string" ? name : avatar?.label || roleLabels[message.role]} message`,
|
|
51
|
+
"aria-busy": isStreaming || message.status === "submitting",
|
|
52
|
+
className: cn("group/chat-message flex w-full min-w-0 text-primary", alignment === "end" && "justify-end", className),
|
|
53
|
+
...props,
|
|
54
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
55
|
+
className: cn("flex min-w-0 max-w-full flex-col gap-space-2", alignment === "end" ? "w-fit max-w-[85%] items-end" : "w-full", contentClassName),
|
|
56
|
+
children: [children ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ChatMessageHeader, {
|
|
57
|
+
avatar,
|
|
58
|
+
name,
|
|
59
|
+
status: message.status
|
|
60
|
+
}), /* @__PURE__ */ jsx(ChatMessageBody, {
|
|
61
|
+
blocks: message.content,
|
|
62
|
+
animateParagraphs: animateParagraphs && !isHistory,
|
|
63
|
+
className: alignment === "end" ? "items-end" : void 0
|
|
64
|
+
})] }), footer != null && /* @__PURE__ */ jsx("div", {
|
|
65
|
+
inert: isStreaming,
|
|
66
|
+
className: cn("flex min-w-0 max-w-full flex-wrap items-center gap-space-2 [overflow-wrap:anywhere]", isStreaming && "invisible", !isLatest && "transition-opacity duration-fast focus-within:transition-none motion-reduce:transition-none pointer-fine:opacity-0 pointer-fine:focus-within:opacity-100 pointer-fine:group-hover/chat-message:opacity-100 pointer-fine:has-[[data-state=open]]:opacity-100"),
|
|
67
|
+
children: footer
|
|
68
|
+
})]
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Avatar, name, and status line. Renders nothing without any of them or
|
|
74
|
+
* children, unless it has shown a streaming status.
|
|
75
|
+
*/
|
|
76
|
+
function ChatMessageHeader({ avatar, name, status = "completed", children, className, ...props }) {
|
|
77
|
+
const [hasStreamed, setHasStreamed] = useState(status === "streaming");
|
|
78
|
+
if (status === "streaming" && !hasStreamed) setHasStreamed(true);
|
|
79
|
+
const statusLabel = statusLabels[status];
|
|
80
|
+
const isEmpty = avatar == null && name == null && !statusLabel && children == null;
|
|
81
|
+
if (isEmpty && !hasStreamed) return null;
|
|
82
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
83
|
+
className: cn("flex min-w-0 max-w-full flex-wrap items-center gap-space-2 [overflow-wrap:anywhere]", isEmpty && "min-h-lh text-xxs leading-snug", className),
|
|
84
|
+
...props,
|
|
85
|
+
children: [
|
|
86
|
+
avatar && /* @__PURE__ */ jsx("span", {
|
|
87
|
+
"aria-hidden": "true",
|
|
88
|
+
className: "inline-flex shrink-0",
|
|
89
|
+
children: /* @__PURE__ */ jsx(Avatar, {
|
|
90
|
+
size: "xs",
|
|
91
|
+
...avatar
|
|
92
|
+
})
|
|
93
|
+
}),
|
|
94
|
+
name != null && /* @__PURE__ */ jsx(Text, {
|
|
95
|
+
as: "span",
|
|
96
|
+
variant: "xs",
|
|
97
|
+
weight: "medium",
|
|
98
|
+
className: "leading-snug",
|
|
99
|
+
children: name
|
|
100
|
+
}),
|
|
101
|
+
status === "streaming" ? /* @__PURE__ */ jsx(ThinkingState, {
|
|
102
|
+
size: "xs",
|
|
103
|
+
label: statusLabel,
|
|
104
|
+
motion: "subtle"
|
|
105
|
+
}) : statusLabel ? /* @__PURE__ */ jsxs(Text, {
|
|
106
|
+
as: "span",
|
|
107
|
+
variant: "xs",
|
|
108
|
+
color: status === "failed" ? "error" : "secondary",
|
|
109
|
+
className: "flex items-center gap-space-2 leading-snug",
|
|
110
|
+
children: [status === "failed" && /* @__PURE__ */ jsx(Icon, {
|
|
111
|
+
icon: WarningCircleIcon,
|
|
112
|
+
size: "sm",
|
|
113
|
+
weight: "fill",
|
|
114
|
+
className: "text-icon-error",
|
|
115
|
+
"aria-hidden": "true"
|
|
116
|
+
}), statusLabel]
|
|
117
|
+
}) : null,
|
|
118
|
+
children
|
|
119
|
+
]
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/** Content blocks in order. Text blocks render as escaped plain text. */
|
|
123
|
+
function ChatMessageBody({ blocks, animateParagraphs = false, className, ...props }) {
|
|
124
|
+
if (blocks.length === 0) return null;
|
|
125
|
+
return /* @__PURE__ */ jsx("div", {
|
|
126
|
+
className: cn("flex w-full min-w-0 max-w-full flex-col gap-space-3 [overflow-wrap:anywhere]", "[&_img]:max-w-full [&_pre]:max-w-full [&_pre]:overflow-x-auto [&_table]:block [&_table]:max-w-full [&_table]:overflow-x-auto", className),
|
|
127
|
+
...props,
|
|
128
|
+
children: blocks.map((block) => {
|
|
129
|
+
const content = block.type === "text" ? /* @__PURE__ */ jsx(Text, {
|
|
130
|
+
as: "p",
|
|
131
|
+
variant: "sm",
|
|
132
|
+
weight: "normal",
|
|
133
|
+
className: cn("min-w-0 whitespace-pre-wrap leading-normal tracking-normal text-inherit", animateParagraphs && "animate-in fade-in duration-normal ease-out motion-reduce:animate-none"),
|
|
134
|
+
children: block.text
|
|
135
|
+
}) : block.content;
|
|
136
|
+
return block.appearance === "bubble" ? /* @__PURE__ */ jsx("div", {
|
|
137
|
+
className: "w-fit min-w-0 max-w-full rounded-xl bg-surface-level-2 px-space-3 py-space-2",
|
|
138
|
+
children: content
|
|
139
|
+
}, block.id) : /* @__PURE__ */ jsx(Fragment, { children: content }, block.id);
|
|
140
|
+
})
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
var actionDefinitions = [
|
|
144
|
+
{
|
|
145
|
+
name: "copy",
|
|
146
|
+
label: "Copy message",
|
|
147
|
+
icon: CopySimpleIcon
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "edit",
|
|
151
|
+
label: "Edit message",
|
|
152
|
+
icon: PencilSimpleIcon
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "retry",
|
|
156
|
+
label: "Retry message",
|
|
157
|
+
icon: ArrowClockwiseIcon
|
|
158
|
+
}
|
|
159
|
+
];
|
|
160
|
+
function canChangeMessage(status, readOnly) {
|
|
161
|
+
return !readOnly && status !== "queued" && status !== "submitting" && status !== "streaming";
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Copy, edit, and retry buttons, plus any host actions in `children`. Edit
|
|
165
|
+
* and retry are hidden while the message is pending or read-only; copy stays
|
|
166
|
+
* available. Renders nothing when no actions remain.
|
|
167
|
+
*/
|
|
168
|
+
function ChatMessageActions({ actions, status = "completed", readOnly = false, children, className, ...props }) {
|
|
169
|
+
const canChange = canChangeMessage(status, readOnly);
|
|
170
|
+
const visibleActions = actionDefinitions.flatMap((definition) => {
|
|
171
|
+
const action = actions?.[definition.name];
|
|
172
|
+
return action && (definition.name === "copy" || canChange) ? [{
|
|
173
|
+
...definition,
|
|
174
|
+
action
|
|
175
|
+
}] : [];
|
|
176
|
+
});
|
|
177
|
+
if (visibleActions.length === 0 && children == null) return null;
|
|
178
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
179
|
+
role: "group",
|
|
180
|
+
"aria-label": "Message actions",
|
|
181
|
+
className: cn("flex min-w-0 max-w-full flex-wrap items-center gap-space-1", className),
|
|
182
|
+
...props,
|
|
183
|
+
children: [visibleActions.map(({ name, label, icon, action }) => /* @__PURE__ */ jsx(IconButton, {
|
|
184
|
+
icon,
|
|
185
|
+
iconWeight: "regular",
|
|
186
|
+
label: action.label ?? label,
|
|
187
|
+
color: "secondary",
|
|
188
|
+
variant: "plain",
|
|
189
|
+
size: "xs",
|
|
190
|
+
onClick: action.onClick
|
|
191
|
+
}, name)), children]
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
function ChatTurnDivider({ label, className, ...props }) {
|
|
195
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
196
|
+
role: "separator",
|
|
197
|
+
"aria-label": label,
|
|
198
|
+
"aria-orientation": "horizontal",
|
|
199
|
+
className: cn("flex w-full min-w-0 items-center gap-space-3 py-space-3", className),
|
|
200
|
+
...props,
|
|
201
|
+
children: [
|
|
202
|
+
/* @__PURE__ */ jsx(Divider, { className: "min-w-space-4 flex-1" }),
|
|
203
|
+
/* @__PURE__ */ jsx(Text, {
|
|
204
|
+
variant: "xs",
|
|
205
|
+
color: "tertiary",
|
|
206
|
+
className: "min-w-0 text-center [overflow-wrap:anywhere]",
|
|
207
|
+
children: label
|
|
208
|
+
}),
|
|
209
|
+
/* @__PURE__ */ jsx(Divider, { className: "min-w-space-4 flex-1" })
|
|
210
|
+
]
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
//#endregion
|
|
214
|
+
export { ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider };
|
|
215
|
+
|
|
216
|
+
//# sourceMappingURL=ChatMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatMessage.js","names":[],"sources":["../../../src/components/ChatMessage/ChatMessage.tsx"],"sourcesContent":["import {\n Fragment,\n useState,\n type ComponentPropsWithRef,\n type ReactNode,\n} from 'react';\n\nimport { ArrowClockwiseIcon } from '@phosphor-icons/react/dist/ssr/ArrowClockwise';\nimport { CopySimpleIcon } from '@phosphor-icons/react/dist/ssr/CopySimple';\nimport { PencilSimpleIcon } from '@phosphor-icons/react/dist/ssr/PencilSimple';\nimport { WarningCircleIcon } from '@phosphor-icons/react/dist/ssr/WarningCircle';\n\nimport { cn } from '../../utils/cn';\nimport type { IconComponent } from '../../utils/icon-types';\nimport { Avatar, type AvatarProps } from '../Avatar';\nimport { Divider } from '../Divider';\nimport { Icon } from '../Icon';\nimport { IconButton } from '../IconButton';\nimport { Text } from '../Text';\nimport { ThinkingState } from '../ThinkingState';\nimport type {\n ChatMessageActionCapabilities,\n ChatMessageContentBlock,\n ChatMessageModel,\n ChatMessageRole,\n ChatMessageStatus,\n} from './ChatMessage.types';\n\nconst roleLabels: Record<ChatMessageRole, string> = {\n user: 'User',\n assistant: 'Assistant',\n system: 'System',\n tool: 'Tool',\n};\n\nconst statusLabels: Record<ChatMessageStatus, string | null> = {\n idle: null,\n queued: 'Queued',\n submitting: 'Sending',\n streaming: 'Responding',\n interrupted: 'Interrupted',\n failed: 'Failed',\n stopped: 'Stopped',\n completed: null,\n};\n\nconst settledStatuses = new Set<ChatMessageStatus>([\n 'completed',\n 'failed',\n 'stopped',\n 'interrupted',\n]);\n\nexport interface ChatMessageProps extends ComponentPropsWithRef<'div'> {\n message: ChatMessageModel;\n /** Metadata and actions share the message's footer layout and visibility. */\n footer?: ReactNode;\n /** `Avatar` shown before the name in the default header, sized to match it. */\n avatar?: Omit<AvatarProps, 'size'>;\n /**\n * Name shown after the avatar in the default header. A string name also\n * labels the message for screen readers; otherwise the avatar's label or\n * the role label does.\n */\n name?: ReactNode;\n /** Defaults to end for user messages and start for other roles. */\n align?: 'start' | 'end';\n /** Keeps the footer visible; earlier messages reveal it on hover or focus. */\n isLatest?: boolean;\n /**\n * Fade in complete text blocks as they mount; keep their IDs stable. A\n * message that mounts already settled, such as history, doesn't fade in.\n */\n animateParagraphs?: boolean;\n contentClassName?: string;\n}\n\n/**\n * One message in a conversation. Renders a header and the message's content\n * blocks, or `children` in their place for custom layouts. The footer is\n * hidden, but keeps its space, while the message streams.\n */\nexport function ChatMessage({\n message,\n footer,\n avatar,\n name,\n align,\n isLatest = false,\n animateParagraphs = false,\n className,\n contentClassName,\n children,\n ...props\n}: ChatMessageProps) {\n const alignment = align ?? (message.role === 'user' ? 'end' : 'start');\n const isStreaming = message.status === 'streaming';\n const isSettled = settledStatuses.has(message.status);\n const [isHistory, setIsHistory] = useState(isSettled);\n if (isHistory && !isSettled) setIsHistory(false);\n\n return (\n <div\n role=\"article\"\n aria-label={`${typeof name === 'string' ? name : avatar?.label || roleLabels[message.role]} message`}\n aria-busy={isStreaming || message.status === 'submitting'}\n className={cn(\n 'group/chat-message flex w-full min-w-0 text-primary',\n alignment === 'end' && 'justify-end',\n className\n )}\n {...props}\n >\n <div\n className={cn(\n 'flex min-w-0 max-w-full flex-col gap-space-2',\n alignment === 'end' ? 'w-fit max-w-[85%] items-end' : 'w-full',\n contentClassName\n )}\n >\n {children ?? (\n <>\n <ChatMessageHeader\n avatar={avatar}\n name={name}\n status={message.status}\n />\n <ChatMessageBody\n blocks={message.content}\n animateParagraphs={animateParagraphs && !isHistory}\n className={alignment === 'end' ? 'items-end' : undefined}\n />\n </>\n )}\n {footer != null && (\n <div\n // Reserve the footer's space while streaming so it doesn't pop in.\n inert={isStreaming}\n className={cn(\n 'flex min-w-0 max-w-full flex-wrap items-center gap-space-2 [overflow-wrap:anywhere]',\n isStreaming && 'invisible',\n // Earlier messages hide their footer until hovered or focused,\n // except on touch screens, which have no hover to reveal it.\n // Keyboard focus reveals it without a fade.\n !isLatest &&\n 'transition-opacity duration-fast focus-within:transition-none motion-reduce:transition-none pointer-fine:opacity-0 pointer-fine:focus-within:opacity-100 pointer-fine:group-hover/chat-message:opacity-100 pointer-fine:has-[[data-state=open]]:opacity-100'\n )}\n >\n {footer}\n </div>\n )}\n </div>\n </div>\n );\n}\n\nexport interface ChatMessageHeaderProps extends ComponentPropsWithRef<'div'> {\n avatar?: Omit<AvatarProps, 'size'>;\n name?: ReactNode;\n status?: ChatMessageStatus;\n}\n\n/**\n * Avatar, name, and status line. Renders nothing without any of them or\n * children, unless it has shown a streaming status.\n */\nexport function ChatMessageHeader({\n avatar,\n name,\n status = 'completed',\n children,\n className,\n ...props\n}: ChatMessageHeaderProps) {\n const [hasStreamed, setHasStreamed] = useState(status === 'streaming');\n if (status === 'streaming' && !hasStreamed) setHasStreamed(true);\n\n const statusLabel = statusLabels[status];\n const isEmpty =\n avatar == null && name == null && !statusLabel && children == null;\n\n if (isEmpty && !hasStreamed) return null;\n\n return (\n <div\n className={cn(\n 'flex min-w-0 max-w-full flex-wrap items-center gap-space-2 [overflow-wrap:anywhere]',\n // Keep the line the streaming status used so the text below doesn't\n // jump up when it ends.\n isEmpty && 'min-h-lh text-xxs leading-snug',\n className\n )}\n {...props}\n >\n {avatar && (\n // The name and the message label already identify the speaker; this\n // keeps the avatar's initial from being read out before the name.\n <span aria-hidden=\"true\" className=\"inline-flex shrink-0\">\n <Avatar size=\"xs\" {...avatar} />\n </span>\n )}\n {name != null && (\n <Text as=\"span\" variant=\"xs\" weight=\"medium\" className=\"leading-snug\">\n {name}\n </Text>\n )}\n {status === 'streaming' ? (\n <ThinkingState size=\"xs\" label={statusLabel} motion=\"subtle\" />\n ) : statusLabel ? (\n <Text\n as=\"span\"\n variant=\"xs\"\n color={status === 'failed' ? 'error' : 'secondary'}\n className=\"flex items-center gap-space-2 leading-snug\"\n >\n {status === 'failed' && (\n <Icon\n icon={WarningCircleIcon}\n size=\"sm\"\n weight=\"fill\"\n className=\"text-icon-error\"\n aria-hidden=\"true\"\n />\n )}\n {statusLabel}\n </Text>\n ) : null}\n {children}\n </div>\n );\n}\n\nexport interface ChatMessageBodyProps extends Omit<\n ComponentPropsWithRef<'div'>,\n 'children'\n> {\n blocks: readonly ChatMessageContentBlock[];\n /** Supply one complete paragraph per text block; existing blocks do not replay. */\n animateParagraphs?: boolean;\n}\n\n/** Content blocks in order. Text blocks render as escaped plain text. */\nexport function ChatMessageBody({\n blocks,\n animateParagraphs = false,\n className,\n ...props\n}: ChatMessageBodyProps) {\n if (blocks.length === 0) return null;\n\n return (\n <div\n className={cn(\n 'flex w-full min-w-0 max-w-full flex-col gap-space-3 [overflow-wrap:anywhere]',\n // Keep wide host content from stretching the message.\n '[&_img]:max-w-full [&_pre]:max-w-full [&_pre]:overflow-x-auto [&_table]:block [&_table]:max-w-full [&_table]:overflow-x-auto',\n className\n )}\n {...props}\n >\n {blocks.map((block) => {\n const content =\n block.type === 'text' ? (\n <Text\n as=\"p\"\n variant=\"sm\"\n weight=\"normal\"\n className={cn(\n 'min-w-0 whitespace-pre-wrap leading-normal tracking-normal text-inherit',\n animateParagraphs &&\n 'animate-in fade-in duration-normal ease-out motion-reduce:animate-none'\n )}\n >\n {block.text}\n </Text>\n ) : (\n block.content\n );\n\n return block.appearance === 'bubble' ? (\n <div\n key={block.id}\n className=\"w-fit min-w-0 max-w-full rounded-xl bg-surface-level-2 px-space-3 py-space-2\"\n >\n {content}\n </div>\n ) : (\n <Fragment key={block.id}>{content}</Fragment>\n );\n })}\n </div>\n );\n}\n\nconst actionDefinitions: {\n name: keyof ChatMessageActionCapabilities;\n label: string;\n icon: IconComponent;\n}[] = [\n { name: 'copy', label: 'Copy message', icon: CopySimpleIcon },\n { name: 'edit', label: 'Edit message', icon: PencilSimpleIcon },\n { name: 'retry', label: 'Retry message', icon: ArrowClockwiseIcon },\n];\n\nfunction canChangeMessage(status: ChatMessageStatus, readOnly: boolean) {\n return (\n !readOnly &&\n status !== 'queued' &&\n status !== 'submitting' &&\n status !== 'streaming'\n );\n}\n\nexport interface ChatMessageActionsProps extends ComponentPropsWithRef<'div'> {\n actions?: ChatMessageActionCapabilities;\n status?: ChatMessageStatus;\n readOnly?: boolean;\n}\n\n/**\n * Copy, edit, and retry buttons, plus any host actions in `children`. Edit\n * and retry are hidden while the message is pending or read-only; copy stays\n * available. Renders nothing when no actions remain.\n */\nexport function ChatMessageActions({\n actions,\n status = 'completed',\n readOnly = false,\n children,\n className,\n ...props\n}: ChatMessageActionsProps) {\n const canChange = canChangeMessage(status, readOnly);\n const visibleActions = actionDefinitions.flatMap((definition) => {\n const action = actions?.[definition.name];\n return action && (definition.name === 'copy' || canChange)\n ? [{ ...definition, action }]\n : [];\n });\n if (visibleActions.length === 0 && children == null) return null;\n\n return (\n <div\n role=\"group\"\n aria-label=\"Message actions\"\n className={cn(\n 'flex min-w-0 max-w-full flex-wrap items-center gap-space-1',\n className\n )}\n {...props}\n >\n {visibleActions.map(({ name, label, icon, action }) => (\n <IconButton\n key={name}\n icon={icon}\n iconWeight=\"regular\"\n label={action.label ?? label}\n color=\"secondary\"\n variant=\"plain\"\n size=\"xs\"\n onClick={action.onClick}\n />\n ))}\n {children}\n </div>\n );\n}\n\nexport interface ChatTurnDividerProps extends Omit<\n ComponentPropsWithRef<'div'>,\n 'children'\n> {\n label: string;\n}\n\nexport function ChatTurnDivider({\n label,\n className,\n ...props\n}: ChatTurnDividerProps) {\n return (\n <div\n role=\"separator\"\n aria-label={label}\n aria-orientation=\"horizontal\"\n className={cn(\n 'flex w-full min-w-0 items-center gap-space-3 py-space-3',\n className\n )}\n {...props}\n >\n <Divider className=\"min-w-space-4 flex-1\" />\n <Text\n variant=\"xs\"\n color=\"tertiary\"\n className=\"min-w-0 text-center [overflow-wrap:anywhere]\"\n >\n {label}\n </Text>\n <Divider className=\"min-w-space-4 flex-1\" />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA4BA,IAAM,aAA8C;CAClD,MAAM;CACN,WAAW;CACX,QAAQ;CACR,MAAM;AACR;A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EARN,UAAA;GAUE,oBAAC,SAAD,EAAS,WAAU,uBAAwB,CAAA;GAC3C,oBAAC,MAAD;IACE,SAAQ;IACR,OAAM;IACN,WAAU;IAET,UAAA;GACG,CAAA;GACN,oBAAC,SAAD,EAAS,WAAU,uBAAwB,CAAA;EACxC;;AAET"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type ChatMessageRole = 'user' | 'assistant' | 'system' | 'tool';
|
|
3
|
+
export type ChatMessageStatus = 'idle' | 'queued' | 'submitting' | 'streaming' | 'interrupted' | 'failed' | 'stopped' | 'completed';
|
|
4
|
+
export type ChatMessageContentBlock = {
|
|
5
|
+
/** Stable within a message, including while its content streams. */
|
|
6
|
+
id: string;
|
|
7
|
+
appearance?: 'plain' | 'bubble';
|
|
8
|
+
} & ({
|
|
9
|
+
type: 'text';
|
|
10
|
+
text: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: 'custom';
|
|
13
|
+
/** Host-rendered Markdown, attachments, tools, or rich content. */
|
|
14
|
+
content: ReactNode;
|
|
15
|
+
});
|
|
16
|
+
export interface ChatMessageAction {
|
|
17
|
+
onClick: () => void;
|
|
18
|
+
label?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ChatMessageActionCapabilities {
|
|
21
|
+
copy?: ChatMessageAction;
|
|
22
|
+
edit?: ChatMessageAction;
|
|
23
|
+
retry?: ChatMessageAction;
|
|
24
|
+
}
|
|
25
|
+
/** Render-ready presentation data; product payloads and parsing stay in adapters. */
|
|
26
|
+
export interface ChatMessageModel {
|
|
27
|
+
id: string;
|
|
28
|
+
role: ChatMessageRole;
|
|
29
|
+
status: ChatMessageStatus;
|
|
30
|
+
readOnly?: boolean;
|
|
31
|
+
content: readonly ChatMessageContentBlock[];
|
|
32
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider, } from './ChatMessage.js';
|
|
2
|
+
export type { ChatMessageActionsProps, ChatMessageBodyProps, ChatMessageHeaderProps, ChatMessageProps, ChatTurnDividerProps, } from './ChatMessage.js';
|
|
3
|
+
export type { ChatMessageAction, ChatMessageActionCapabilities, ChatMessageContentBlock, ChatMessageModel, ChatMessageRole, ChatMessageStatus, } from './ChatMessage.types.js';
|
|
@@ -88,7 +88,7 @@ function OptionSelect({ value, onChange, options, groups, placeholder = "Select.
|
|
|
88
88
|
variant,
|
|
89
89
|
color: "secondary",
|
|
90
90
|
size: triggerButtonSize,
|
|
91
|
-
className: cn("box-border justify-between py-0", CONTROL_SIZES[size].heightClassName, variant === "plain" ? cn("w-auto max-w-full gap-space-1 px-space-1", disabled && "bg-disabled text-disabled dark:bg-disabled") : cn("w-full", disabled ? "border-muted bg-input-disabled text-disabled dark:bg-input-disabled" : "bg-input border-input hover:bg-input-hover hover:border-input-hover focus-visible:border-focus focus-visible:shadow-[0_0_0_1px_var(--border-focus)] focus-visible:outline-none"), triggerClassName),
|
|
91
|
+
className: cn("box-border justify-between py-0", CONTROL_SIZES[size].heightClassName, variant === "plain" ? cn("w-auto max-w-full gap-space-1 px-space-1", disabled && "bg-disabled text-disabled dark:bg-disabled") : cn("w-full", disabled ? "border-muted bg-input-disabled text-disabled dark:bg-input-disabled" : "bg-input border-input shadow-none hover:bg-input-hover hover:border-input-hover focus-visible:border-focus focus-visible:shadow-[0_0_0_1px_var(--border-focus)] focus-visible:outline-none"), triggerClassName),
|
|
92
92
|
disabled,
|
|
93
93
|
"data-testid": dataTestId,
|
|
94
94
|
children: [triggerContent, /* @__PURE__ */ jsx(Icon, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","names":[],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { useCallback, useMemo, useState } from 'react';\n\nimport { CaretDownIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport {\n CONTROL_SIZES,\n type ControlSize,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { CONTROL_ICON_SIZES } from '../../utils/controlIconSizes';\nimport {\n type DataAttributes,\n pickDataAttributes,\n} from '../../utils/dataAttributes';\nimport { Button } from '../Button';\nimport { CommandMenu } from '../Command/CommandMenu';\nimport type { CommandMenuGroup, CommandMenuItem } from '../Command/CommandMenu';\nimport { Icon } from '../Icon';\nimport { Popover, PopoverContent, PopoverTrigger } from '../Popover';\nimport { Text } from '../Text';\n\nexport interface SelectOption<T extends string = string> {\n /** The value used for selection and filtering */\n value: T;\n /** Display label (defaults to value if not provided) */\n label?: string;\n /** Secondary description text displayed below the label */\n description?: string;\n /** Element displayed on the right side of the item (e.g. badge, shortcut) */\n rightDecorator?: ReactNode;\n /** Whether this option is disabled */\n disabled?: boolean;\n}\n\nexport interface SelectGroup<T extends string = string> {\n heading?: string;\n options: SelectOption<T>[];\n}\n\nexport type SelectSize = ControlSize;\n\nexport type SelectVariant = 'outlined' | 'plain';\n\ninterface SelectBaseProps<T extends string = string> extends DataAttributes {\n /** The currently selected value */\n value?: T;\n /** Callback when selection changes. Receives undefined when deselected. */\n onChange: (value: T | undefined) => void;\n /** Placeholder text when no value is selected */\n placeholder?: string;\n /** Placeholder text for the search input */\n searchPlaceholder?: string;\n /** Whether the select is disabled */\n disabled?: boolean;\n /** Exact trigger height: xs=20px, sm=24px, md=32px, lg=40px. */\n size?: SelectSize;\n /** Text to show when no options match the search */\n emptyText?: string;\n /** Allow deselecting the current value by clicking it again (default: false) */\n allowDeselect?: boolean;\n /** Hide the search input (default: true, search is hidden) */\n hideSearch?: boolean;\n /** Disable client-side filtering by cmdk (default: false). Set true for server-side filtering. */\n disableFilter?: boolean;\n /** Callback when the search input value changes. Useful for server-side filtering. */\n onSearchChange?: (query: string) => void;\n /** Whether more items are currently being loaded */\n loading?: boolean;\n /** Number of skeleton rows to show while loading (default: 5) */\n loadingRows?: number;\n /** Callback when the user scrolls near the end of the list. Use for infinite loading. */\n onEndReached?: () => void;\n /** Distance in pixels from the bottom to trigger onEndReached (default: 50) */\n endReachedThresholdPx?: number;\n /** Additional class name for the trigger button */\n triggerClassName?: string;\n /**\n * Trigger appearance. `outlined` (default) is a full-width form field.\n * `plain` drops the field fill and border and sizes the trigger to its\n * value, so it reads as text until hovered — for an inline setting in a row,\n * such as a member's role, where a field box would crowd it.\n */\n variant?: SelectVariant;\n /** Additional class name for the popover content */\n contentClassName?: string;\n /** Custom render function for the selected value in the trigger */\n renderValue?: (option: SelectOption<T>) => ReactNode;\n /** Custom render function for each option in the list */\n renderOption?: (option: SelectOption<T>, isSelected: boolean) => ReactNode;\n /** Side of the trigger to align the popover */\n side?: 'top' | 'bottom' | 'left' | 'right';\n /** Alignment of the popover relative to the trigger */\n align?: 'start' | 'center' | 'end';\n /** aria-label for the trigger button */\n 'aria-label'?: string;\n /** Test id for the trigger button */\n 'data-testid'?: string;\n}\n\nexport type SelectProps<T extends string = string> = SelectBaseProps<T> &\n (\n | {\n options: SelectOption<T>[];\n groups?: never;\n }\n | {\n groups: SelectGroup<T>[];\n options?: never;\n }\n ) &\n (\n | {\n /** Controlled open state */\n open: boolean;\n /** Callback when open state changes (required when `open` is provided) */\n onOpenChange: (open: boolean) => void;\n }\n | {\n open?: never;\n onOpenChange?: never;\n }\n );\n\nfunction optionToItem(opt: SelectOption): CommandMenuItem {\n return {\n value: opt.value,\n label: opt.label,\n description: opt.description,\n rightDecorator: opt.rightDecorator,\n disabled: opt.disabled,\n keywords: opt.label ? [opt.label] : undefined,\n };\n}\n\nfunction OptionSelect<T extends string = string>({\n value,\n onChange,\n options,\n groups,\n placeholder = 'Select...',\n searchPlaceholder = 'Search...',\n disabled = false,\n size = 'sm',\n emptyText = 'No results found.',\n open: controlledOpen,\n onOpenChange: controlledOnOpenChange,\n allowDeselect,\n hideSearch = true,\n disableFilter,\n onSearchChange,\n loading,\n loadingRows,\n onEndReached,\n endReachedThresholdPx,\n triggerClassName,\n variant = 'outlined',\n contentClassName,\n renderValue,\n renderOption,\n side,\n align = 'start',\n 'aria-label': ariaLabel,\n 'data-testid': dataTestId,\n ...rest\n}: SelectProps<T>) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(false);\n const isControlled = controlledOpen !== undefined;\n const open = isControlled ? controlledOpen : uncontrolledOpen;\n const setOpen = isControlled ? controlledOnOpenChange : setUncontrolledOpen;\n\n const allOptions = useMemo<SelectOption<T>[]>(\n () => (groups ? groups.flatMap((g) => g.options) : (options ?? [])),\n [groups, options]\n );\n\n const selectedOption = useMemo(\n () => allOptions.find((opt) => opt.value === value),\n [allOptions, value]\n );\n\n const handleSelect = useCallback(\n (optionValue: string) => {\n const match = allOptions.find((o) => o.value === optionValue);\n if (!match) return;\n if (allowDeselect && match.value === value) {\n onChange(undefined);\n } else {\n onChange(match.value);\n }\n setOpen(false);\n },\n [allowDeselect, value, onChange, setOpen, allOptions]\n );\n\n const items: CommandMenuItem[] = useMemo(\n () => (options ?? []).map(optionToItem),\n [options]\n );\n\n const commandGroups: CommandMenuGroup[] | undefined = useMemo(\n () =>\n groups?.map((g) => ({\n heading: g.heading,\n items: g.options.map(optionToItem),\n })),\n [groups]\n );\n\n const renderItem = renderOption\n ? (item: CommandMenuItem, isSelected: boolean) => {\n const option = allOptions.find((o) => o.value === item.value);\n return option ? renderOption(option, isSelected) : null;\n }\n : undefined;\n const searchInputSize = size === 'xs' ? 'sm' : size === 'lg' ? 'md' : size;\n const triggerButtonSize = size === 'lg' ? 'md' : size;\n const itemRowSize: OptionRowSize =\n size === 'xs' || size === 'sm' ? 'sm' : 'md';\n\n const commandMenuSharedProps = {\n value,\n onSelect: handleSelect,\n placeholder: searchPlaceholder,\n emptyText,\n hideSearch,\n disableFilter,\n onSearchChange,\n loading,\n loadingRows,\n onEndReached,\n endReachedThresholdPx,\n renderItem,\n inputSize: searchInputSize,\n itemRowSize,\n };\n\n const triggerContent =\n selectedOption && renderValue ? (\n renderValue(selectedOption)\n ) : (\n <Text\n as=\"span\"\n variant={triggerButtonSize}\n weight=\"normal\"\n className=\"min-w-0 truncate text-left\"\n >\n {selectedOption\n ? (selectedOption.label ?? selectedOption.value)\n : placeholder}\n </Text>\n );\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n {...pickDataAttributes(rest)}\n role=\"combobox\"\n aria-expanded={open}\n aria-label={ariaLabel ?? placeholder}\n variant={variant}\n color=\"secondary\"\n size={triggerButtonSize}\n className={cn(\n 'box-border justify-between py-0',\n CONTROL_SIZES[size].heightClassName,\n variant === 'plain'\n ? cn(\n 'w-auto max-w-full gap-space-1 px-space-1',\n // The shared disabled fill, in both themes.\n disabled && 'bg-disabled text-disabled dark:bg-disabled'\n )\n : cn(\n 'w-full',\n disabled\n ? 'border-muted bg-input-disabled text-disabled dark:bg-input-disabled'\n : 'bg-input border-input hover:bg-input-hover hover:border-input-hover focus-visible:border-focus focus-visible:shadow-[0_0_0_1px_var(--border-focus)] focus-visible:outline-none'\n ),\n triggerClassName\n )}\n disabled={disabled}\n data-testid={dataTestId}\n >\n {triggerContent}\n <Icon\n aria-hidden\n icon={CaretDownIcon}\n iconClassName={CONTROL_ICON_SIZES[size].iconClassName}\n className={disabled ? 'text-icon-disabled' : 'text-inherit'}\n weight=\"regular\"\n />\n </Button>\n </PopoverTrigger>\n <PopoverContent\n className={cn(\n 'w-max min-w-[var(--radix-popover-trigger-width)] max-w-[min(24rem,calc(100vw-1rem))] p-0 text-primary',\n contentClassName\n )}\n side={side}\n align={align}\n >\n {commandGroups ? (\n <CommandMenu groups={commandGroups} {...commandMenuSharedProps} />\n ) : (\n <CommandMenu items={items} {...commandMenuSharedProps} />\n )}\n </PopoverContent>\n </Popover>\n );\n}\n\nexport function Select<T extends string = string>(\n props: SelectProps<T>\n): React.ReactElement<unknown> {\n return <OptionSelect {...props} />;\n}\n"],"mappings":";;;;;;;;;;;;;AA4HA,SAAS,aAAa,KAAoC;CACxD,OAAO;EACL,OAAO,IAAI;EAC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IAAO,GAAI;GAAyB,CAAA;EAE5C,CAAA,CACT;;AAEb;AAEA,SAAgB,OACd,OAC6B;CAC7B,OAAO,oBAAC,cAAD,EAAc,GAAI,MAAQ,CAAA;AACnC"}
|
|
1
|
+
{"version":3,"file":"Select.js","names":[],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { useCallback, useMemo, useState } from 'react';\n\nimport { CaretDownIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport {\n CONTROL_SIZES,\n type ControlSize,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { CONTROL_ICON_SIZES } from '../../utils/controlIconSizes';\nimport {\n type DataAttributes,\n pickDataAttributes,\n} from '../../utils/dataAttributes';\nimport { Button } from '../Button';\nimport { CommandMenu } from '../Command/CommandMenu';\nimport type { CommandMenuGroup, CommandMenuItem } from '../Command/CommandMenu';\nimport { Icon } from '../Icon';\nimport { Popover, PopoverContent, PopoverTrigger } from '../Popover';\nimport { Text } from '../Text';\n\nexport interface SelectOption<T extends string = string> {\n /** The value used for selection and filtering */\n value: T;\n /** Display label (defaults to value if not provided) */\n label?: string;\n /** Secondary description text displayed below the label */\n description?: string;\n /** Element displayed on the right side of the item (e.g. badge, shortcut) */\n rightDecorator?: ReactNode;\n /** Whether this option is disabled */\n disabled?: boolean;\n}\n\nexport interface SelectGroup<T extends string = string> {\n heading?: string;\n options: SelectOption<T>[];\n}\n\nexport type SelectSize = ControlSize;\n\nexport type SelectVariant = 'outlined' | 'plain';\n\ninterface SelectBaseProps<T extends string = string> extends DataAttributes {\n /** The currently selected value */\n value?: T;\n /** Callback when selection changes. Receives undefined when deselected. */\n onChange: (value: T | undefined) => void;\n /** Placeholder text when no value is selected */\n placeholder?: string;\n /** Placeholder text for the search input */\n searchPlaceholder?: string;\n /** Whether the select is disabled */\n disabled?: boolean;\n /** Exact trigger height: xs=20px, sm=24px, md=32px, lg=40px. */\n size?: SelectSize;\n /** Text to show when no options match the search */\n emptyText?: string;\n /** Allow deselecting the current value by clicking it again (default: false) */\n allowDeselect?: boolean;\n /** Hide the search input (default: true, search is hidden) */\n hideSearch?: boolean;\n /** Disable client-side filtering by cmdk (default: false). Set true for server-side filtering. */\n disableFilter?: boolean;\n /** Callback when the search input value changes. Useful for server-side filtering. */\n onSearchChange?: (query: string) => void;\n /** Whether more items are currently being loaded */\n loading?: boolean;\n /** Number of skeleton rows to show while loading (default: 5) */\n loadingRows?: number;\n /** Callback when the user scrolls near the end of the list. Use for infinite loading. */\n onEndReached?: () => void;\n /** Distance in pixels from the bottom to trigger onEndReached (default: 50) */\n endReachedThresholdPx?: number;\n /** Additional class name for the trigger button */\n triggerClassName?: string;\n /**\n * Trigger appearance. `outlined` (default) is a full-width form field.\n * `plain` drops the field fill and border and sizes the trigger to its\n * value, so it reads as text until hovered — for an inline setting in a row,\n * such as a member's role, where a field box would crowd it.\n */\n variant?: SelectVariant;\n /** Additional class name for the popover content */\n contentClassName?: string;\n /** Custom render function for the selected value in the trigger */\n renderValue?: (option: SelectOption<T>) => ReactNode;\n /** Custom render function for each option in the list */\n renderOption?: (option: SelectOption<T>, isSelected: boolean) => ReactNode;\n /** Side of the trigger to align the popover */\n side?: 'top' | 'bottom' | 'left' | 'right';\n /** Alignment of the popover relative to the trigger */\n align?: 'start' | 'center' | 'end';\n /** aria-label for the trigger button */\n 'aria-label'?: string;\n /** Test id for the trigger button */\n 'data-testid'?: string;\n}\n\nexport type SelectProps<T extends string = string> = SelectBaseProps<T> &\n (\n | {\n options: SelectOption<T>[];\n groups?: never;\n }\n | {\n groups: SelectGroup<T>[];\n options?: never;\n }\n ) &\n (\n | {\n /** Controlled open state */\n open: boolean;\n /** Callback when open state changes (required when `open` is provided) */\n onOpenChange: (open: boolean) => void;\n }\n | {\n open?: never;\n onOpenChange?: never;\n }\n );\n\nfunction optionToItem(opt: SelectOption): CommandMenuItem {\n return {\n value: opt.value,\n label: opt.label,\n description: opt.description,\n rightDecorator: opt.rightDecorator,\n disabled: opt.disabled,\n keywords: opt.label ? [opt.label] : undefined,\n };\n}\n\nfunction OptionSelect<T extends string = string>({\n value,\n onChange,\n options,\n groups,\n placeholder = 'Select...',\n searchPlaceholder = 'Search...',\n disabled = false,\n size = 'sm',\n emptyText = 'No results found.',\n open: controlledOpen,\n onOpenChange: controlledOnOpenChange,\n allowDeselect,\n hideSearch = true,\n disableFilter,\n onSearchChange,\n loading,\n loadingRows,\n onEndReached,\n endReachedThresholdPx,\n triggerClassName,\n variant = 'outlined',\n contentClassName,\n renderValue,\n renderOption,\n side,\n align = 'start',\n 'aria-label': ariaLabel,\n 'data-testid': dataTestId,\n ...rest\n}: SelectProps<T>) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(false);\n const isControlled = controlledOpen !== undefined;\n const open = isControlled ? controlledOpen : uncontrolledOpen;\n const setOpen = isControlled ? controlledOnOpenChange : setUncontrolledOpen;\n\n const allOptions = useMemo<SelectOption<T>[]>(\n () => (groups ? groups.flatMap((g) => g.options) : (options ?? [])),\n [groups, options]\n );\n\n const selectedOption = useMemo(\n () => allOptions.find((opt) => opt.value === value),\n [allOptions, value]\n );\n\n const handleSelect = useCallback(\n (optionValue: string) => {\n const match = allOptions.find((o) => o.value === optionValue);\n if (!match) return;\n if (allowDeselect && match.value === value) {\n onChange(undefined);\n } else {\n onChange(match.value);\n }\n setOpen(false);\n },\n [allowDeselect, value, onChange, setOpen, allOptions]\n );\n\n const items: CommandMenuItem[] = useMemo(\n () => (options ?? []).map(optionToItem),\n [options]\n );\n\n const commandGroups: CommandMenuGroup[] | undefined = useMemo(\n () =>\n groups?.map((g) => ({\n heading: g.heading,\n items: g.options.map(optionToItem),\n })),\n [groups]\n );\n\n const renderItem = renderOption\n ? (item: CommandMenuItem, isSelected: boolean) => {\n const option = allOptions.find((o) => o.value === item.value);\n return option ? renderOption(option, isSelected) : null;\n }\n : undefined;\n const searchInputSize = size === 'xs' ? 'sm' : size === 'lg' ? 'md' : size;\n const triggerButtonSize = size === 'lg' ? 'md' : size;\n const itemRowSize: OptionRowSize =\n size === 'xs' || size === 'sm' ? 'sm' : 'md';\n\n const commandMenuSharedProps = {\n value,\n onSelect: handleSelect,\n placeholder: searchPlaceholder,\n emptyText,\n hideSearch,\n disableFilter,\n onSearchChange,\n loading,\n loadingRows,\n onEndReached,\n endReachedThresholdPx,\n renderItem,\n inputSize: searchInputSize,\n itemRowSize,\n };\n\n const triggerContent =\n selectedOption && renderValue ? (\n renderValue(selectedOption)\n ) : (\n <Text\n as=\"span\"\n variant={triggerButtonSize}\n weight=\"normal\"\n className=\"min-w-0 truncate text-left\"\n >\n {selectedOption\n ? (selectedOption.label ?? selectedOption.value)\n : placeholder}\n </Text>\n );\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n {...pickDataAttributes(rest)}\n role=\"combobox\"\n aria-expanded={open}\n aria-label={ariaLabel ?? placeholder}\n variant={variant}\n color=\"secondary\"\n size={triggerButtonSize}\n className={cn(\n 'box-border justify-between py-0',\n CONTROL_SIZES[size].heightClassName,\n variant === 'plain'\n ? cn(\n 'w-auto max-w-full gap-space-1 px-space-1',\n // The shared disabled fill, in both themes.\n disabled && 'bg-disabled text-disabled dark:bg-disabled'\n )\n : cn(\n 'w-full',\n disabled\n ? 'border-muted bg-input-disabled text-disabled dark:bg-input-disabled'\n : 'bg-input border-input shadow-none hover:bg-input-hover hover:border-input-hover focus-visible:border-focus focus-visible:shadow-[0_0_0_1px_var(--border-focus)] focus-visible:outline-none'\n ),\n triggerClassName\n )}\n disabled={disabled}\n data-testid={dataTestId}\n >\n {triggerContent}\n <Icon\n aria-hidden\n icon={CaretDownIcon}\n iconClassName={CONTROL_ICON_SIZES[size].iconClassName}\n className={disabled ? 'text-icon-disabled' : 'text-inherit'}\n weight=\"regular\"\n />\n </Button>\n </PopoverTrigger>\n <PopoverContent\n className={cn(\n 'w-max min-w-[var(--radix-popover-trigger-width)] max-w-[min(24rem,calc(100vw-1rem))] p-0 text-primary',\n contentClassName\n )}\n side={side}\n align={align}\n >\n {commandGroups ? (\n <CommandMenu groups={commandGroups} {...commandMenuSharedProps} />\n ) : (\n <CommandMenu items={items} {...commandMenuSharedProps} />\n )}\n </PopoverContent>\n </Popover>\n );\n}\n\nexport function Select<T extends string = string>(\n props: SelectProps<T>\n): React.ReactElement<unknown> {\n return <OptionSelect {...props} />;\n}\n"],"mappings":";;;;;;;;;;;;;AA4HA,SAAS,aAAa,KAAoC;CACxD,OAAO;EACL,OAAO,IAAI;EACX,OAAO,IAAI;EACX,aAAa,IAAI;EACjB,gBAAgB,IAAI;EACpB,UAAU,IAAI;EACd,UAAU,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,KAAA;CACtC;AACF;AAEA,SAAS,aAAwC,EAC/C,OACA,UACA,SACA,QACA,cAAc,aACd,oBAAoB,aACpB,WAAW,OACX,OAAO,MACP,YAAY,qBACZ,MAAM,gBACN,cAAc,wBACd,eACA,aAAa,MACb,eACA,gBACA,SACA,aACA,cACA,uBACA,kBACA,UAAU,YACV,kBACA,aACA,cACA,MACA,QAAQ,SACR,cAAc,WACd,eAAe,YACf,GAAG,QACc;CACjB,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,KAAK;CAC9D,MAAM,eAAe,mBAAmB,KAAA;CACxC,MAAM,OAAO,eAAe,iBAAiB;CAC7C,MAAM,UAAU,eAAe,yBAAyB;CAExD,MAAM,aAAa,cACV,SAAS,OAAO,SAAS,MAAM,EAAE,OAAO,IAAK,WAAW,CAAC,GAChE,CAAC,QAAQ,OAAO,CAClB;CAEA,MAAM,iBAAiB,cACf,WAAW,MAAM,QAAQ,IAAI,UAAU,KAAK,GAClD,CAAC,YAAY,KAAK,CACpB;CAEA,MAAM,eAAe,aAClB,gBAAwB;EACvB,MAAM,QAAQ,WAAW,MAAM,MAAM,EAAE,UAAU,WAAW;EAC5D,IAAI,CAAC,OAAO;EACZ,IAAI,iBAAiB,MAAM,UAAU,OACnC,SAAS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F;IACU;IACV,eAAa;IA1Bf,UAAA,CA4BG,gBACD,oBAAC,MAAD;KACE,eAAA;KACA,MAAM;KACN,eAAe,mBAAmB,KAAK,CAAC;KACxC,WAAW,WAAW,uBAAuB;KAC7C,QAAO;IACR,CAAA,CACK;;EACM,CAAA,GAChB,oBAAC,gBAAD;GACE,WAAW,GACT,yGACA,gBACF;GACM;GACC;GAEN,UAAA,gBACC,oBAAC,aAAD;IAAa,QAAQ;IAAe,GAAI;GAAyB,CAAA,IAEjE,oBAAC,aAAD;IAAoB;IAAO,GAAI;GAAyB,CAAA;EAE5C,CAAA,CACT;;AAEb;AAEA,SAAgB,OACd,OAC6B;CAC7B,OAAO,oBAAC,cAAD,EAAc,GAAI,MAAQ,CAAA;AACnC"}
|
|
@@ -26,6 +26,8 @@ export { StatusBadge } from './StatusBadge/index.js';
|
|
|
26
26
|
export type { StatusBadgeProps, StatusBadgeSize, StatusBadgeVariant, } from './StatusBadge/index.js';
|
|
27
27
|
export { Banner } from './Banner/Banner.js';
|
|
28
28
|
export type { BannerProps } from './Banner/Banner.js';
|
|
29
|
+
export { ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider, } from './ChatMessage/index.js';
|
|
30
|
+
export type { ChatMessageAction, ChatMessageActionCapabilities, ChatMessageActionsProps, ChatMessageBodyProps, ChatMessageContentBlock, ChatMessageHeaderProps, ChatMessageModel, ChatMessageProps, ChatMessageRole, ChatMessageStatus, ChatTurnDividerProps, } from './ChatMessage/index.js';
|
|
29
31
|
export { Checkbox, getCheckedState } from './Checkbox/index.js';
|
|
30
32
|
export type { CheckboxProps } from './Checkbox/index.js';
|
|
31
33
|
export { ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow, } from './ChartTooltip/index.js';
|
package/dist/components/index.js
CHANGED
|
@@ -16,9 +16,10 @@ import { Link } from "./Link/Link.js";
|
|
|
16
16
|
import { EmptyState } from "./EmptyState/EmptyState.js";
|
|
17
17
|
import { CircleSkeleton, Skeleton, SkeletonRows } from "./Skeleton/Skeleton.js";
|
|
18
18
|
import { ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow } from "./ChartTooltip/ChartTooltip.js";
|
|
19
|
+
import { Divider } from "./Divider/Divider.js";
|
|
20
|
+
import { ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider } from "./ChatMessage/ChatMessage.js";
|
|
19
21
|
import { Checkbox } from "./Checkbox/Checkbox.js";
|
|
20
22
|
import { getCheckedState } from "./Checkbox/getCheckedState.js";
|
|
21
|
-
import { Divider } from "./Divider/Divider.js";
|
|
22
23
|
import { t as ErrorState } from "../_chunks/ErrorState-BY6VBCRB.js";
|
|
23
24
|
import { GroupedTabs } from "./GroupedTabs/GroupedTabs.js";
|
|
24
25
|
import { HeatmapBlock } from "./HeatmapChart/HeatmapBlock.js";
|
|
@@ -39,4 +40,4 @@ import { Slider } from "./Slider/Slider.js";
|
|
|
39
40
|
import { StatusBadge } from "./StatusBadge/StatusBadge.js";
|
|
40
41
|
import { Switch } from "./Switch/Switch.js";
|
|
41
42
|
import { Textarea } from "./Textarea/Textarea.js";
|
|
42
|
-
export { Attachment, AttachmentList, Avatar, Badge, Banner, Button, ButtonGroup, Card, ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow, Checkbox, CircleSkeleton, Divider, EmptyState, ErrorState, GroupedTabs, HeatmapBlock, HeatmapChart, Icon, IconButton, ImagePreviewBlock, ImagePreviewDialog, Input, Kbd, KbdGroup, LinearProgress, Link, MetricChart, ProgressBar, RadioButton, RadioCard, RadioGroup, RadioGroupItem, Skeleton, SkeletonRows, Slider, Spinner, SpinnerIcon, StatusBadge, Switch, Text, Textarea, Tooltip, TooltipProvider, formatMetricCurrency, formatMetricDate, formatMetricDuration, formatMetricNumber, formatMetricTime, getCheckedState };
|
|
43
|
+
export { Attachment, AttachmentList, Avatar, Badge, Banner, Button, ButtonGroup, Card, ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow, ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider, Checkbox, CircleSkeleton, Divider, EmptyState, ErrorState, GroupedTabs, HeatmapBlock, HeatmapChart, Icon, IconButton, ImagePreviewBlock, ImagePreviewDialog, Input, Kbd, KbdGroup, LinearProgress, Link, MetricChart, ProgressBar, RadioButton, RadioCard, RadioGroup, RadioGroupItem, Skeleton, SkeletonRows, Slider, Spinner, SpinnerIcon, StatusBadge, Switch, Text, Textarea, Tooltip, TooltipProvider, formatMetricCurrency, formatMetricDate, formatMetricDuration, formatMetricNumber, formatMetricTime, getCheckedState };
|
package/dist/index.js
CHANGED
|
@@ -16,9 +16,10 @@ import { Link } from "./components/Link/Link.js";
|
|
|
16
16
|
import { EmptyState } from "./components/EmptyState/EmptyState.js";
|
|
17
17
|
import { CircleSkeleton, Skeleton, SkeletonRows } from "./components/Skeleton/Skeleton.js";
|
|
18
18
|
import { ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow } from "./components/ChartTooltip/ChartTooltip.js";
|
|
19
|
+
import { Divider } from "./components/Divider/Divider.js";
|
|
20
|
+
import { ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider } from "./components/ChatMessage/ChatMessage.js";
|
|
19
21
|
import { Checkbox } from "./components/Checkbox/Checkbox.js";
|
|
20
22
|
import { getCheckedState } from "./components/Checkbox/getCheckedState.js";
|
|
21
|
-
import { Divider } from "./components/Divider/Divider.js";
|
|
22
23
|
import { t as ErrorState } from "./_chunks/ErrorState-BY6VBCRB.js";
|
|
23
24
|
import { GroupedTabs } from "./components/GroupedTabs/GroupedTabs.js";
|
|
24
25
|
import { HeatmapBlock } from "./components/HeatmapChart/HeatmapBlock.js";
|
|
@@ -40,4 +41,4 @@ import { StatusBadge } from "./components/StatusBadge/StatusBadge.js";
|
|
|
40
41
|
import { Switch } from "./components/Switch/Switch.js";
|
|
41
42
|
import { Textarea } from "./components/Textarea/Textarea.js";
|
|
42
43
|
import "./components/index.js";
|
|
43
|
-
export { Attachment, AttachmentList, Avatar, Badge, Banner, Button, ButtonGroup, Card, ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow, Checkbox, CircleSkeleton, Divider, EmptyState, ErrorState, GroupedTabs, HeatmapBlock, HeatmapChart, Icon, IconButton, ImagePreviewBlock, ImagePreviewDialog, Input, Kbd, KbdGroup, LinearProgress, Link, MetricChart, ProgressBar, RadioButton, RadioCard, RadioGroup, RadioGroupItem, Skeleton, SkeletonRows, Slider, Spinner, SpinnerIcon, StatusBadge, Switch, Text, Textarea, Tooltip, TooltipProvider, formatMetricCurrency, formatMetricDate, formatMetricDuration, formatMetricNumber, formatMetricTime, getCheckedState };
|
|
44
|
+
export { Attachment, AttachmentList, Avatar, Badge, Banner, Button, ButtonGroup, Card, ChartTooltip, ChartTooltipBody, ChartTooltipHeader, ChartTooltipRow, ChatMessage, ChatMessageActions, ChatMessageBody, ChatMessageHeader, ChatTurnDivider, Checkbox, CircleSkeleton, Divider, EmptyState, ErrorState, GroupedTabs, HeatmapBlock, HeatmapChart, Icon, IconButton, ImagePreviewBlock, ImagePreviewDialog, Input, Kbd, KbdGroup, LinearProgress, Link, MetricChart, ProgressBar, RadioButton, RadioCard, RadioGroup, RadioGroupItem, Skeleton, SkeletonRows, Slider, Spinner, SpinnerIcon, StatusBadge, Switch, Text, Textarea, Tooltip, TooltipProvider, formatMetricCurrency, formatMetricDate, formatMetricDuration, formatMetricNumber, formatMetricTime, getCheckedState };
|