@swisper.ai/web-chat-ui 0.2.14 → 0.3.0
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 +1 -1
- package/dist/components/chat-artifact/chat-artifact.d.ts +7 -7
- package/dist/components/chat-artifact/chat-artifact.d.ts.map +1 -1
- package/dist/components/chat-artifact/chat-artifact.stories.d.ts +5 -3
- package/dist/components/chat-artifact/chat-artifact.stories.d.ts.map +1 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +22 -31
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +9 -11
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts.map +1 -1
- package/dist/components/chat-thinking-process/index.d.ts +1 -1
- package/dist/components/chat-thinking-process/index.d.ts.map +1 -1
- package/dist/docs/agent.stories.d.ts.map +1 -1
- package/dist/docs/chatbot-panel.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.js +991 -1027
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -2
- package/src/components/chat-artifact/chat-artifact.json +25 -16
- package/src/components/chat-artifact/chat-artifact.stories.tsx +116 -23
- package/src/components/chat-artifact/chat-artifact.tsx +64 -55
- package/src/components/chat-message/__stories__/tool-steps.tsx +1 -4
- package/src/components/chat-thinking-process/chat-thinking-process.json +27 -28
- package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +58 -124
- package/src/components/chat-thinking-process/chat-thinking-process.tsx +55 -116
- package/src/components/chat-thinking-process/index.ts +1 -0
- package/src/docs/agent.stories.tsx +2 -7
- package/src/docs/chatbot-panel.tsx +1 -4
- package/src/docs/chatbot.mdx +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swisper.ai/web-chat-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "React components for the Swisper chat: messages, composer and cards",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -80,7 +80,6 @@
|
|
|
80
80
|
"lexical": "^0.46.0",
|
|
81
81
|
"mdast": "^3.0.0",
|
|
82
82
|
"mime": "^4.1.0",
|
|
83
|
-
"motion": "^12.23.22",
|
|
84
83
|
"nanoid": "^5.1.16",
|
|
85
84
|
"react-intersection-observer": "9.16.0",
|
|
86
85
|
"rehype-sanitize": "^6.0.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "../../../../int-eslint-config/schemas/component.schema.json",
|
|
3
3
|
"component": "chat-artifact",
|
|
4
|
-
"purpose": "A message-row
|
|
4
|
+
"purpose": "A message-row button for a generated artifact, styled as a ui Card header: a round avatar icon slot (ChatArtifactIcon), a wrapping title over a one-line caption (ChatArtifactContent with ChatArtifactTitle and ChatArtifactCaption), and trailing consumer actions (ChatArtifactActions). Root supports asChild so the row can render as a link.",
|
|
5
5
|
"anatomy": [
|
|
6
6
|
"import {",
|
|
7
7
|
" ChatArtifact,",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"useWhen": [
|
|
25
25
|
"Showing a generated artifact (slides, doc, sheet) in an assistant message so the user can open or share it",
|
|
26
26
|
"Composing a row with a title, a secondary caption, and trailing action buttons",
|
|
27
|
-
"Wrapping the whole row as a link with asChild"
|
|
27
|
+
"Wrapping the whole row as a link with asChild (no actions inside)"
|
|
28
28
|
],
|
|
29
29
|
"avoidWhen": [
|
|
30
30
|
"A file the user attached to the prompt or sent with a question — use web-chat-ui/chat-message-attachment-card",
|
|
@@ -33,31 +33,35 @@
|
|
|
33
33
|
],
|
|
34
34
|
"uxPrinciples": [
|
|
35
35
|
"Name the artifact first; the caption carries source or visibility, not a second headline",
|
|
36
|
-
"Actions stay consumer-owned: the package does not ship Share or Open buttons"
|
|
36
|
+
"Actions stay consumer-owned: the package does not ship Share or Open buttons. Open is a secondary sm Button with RightPanelOpenIcon as startIcon"
|
|
37
37
|
],
|
|
38
38
|
"accessibility": {
|
|
39
39
|
"required": [
|
|
40
40
|
"Give each control in ChatArtifactActions an accessible name (aria-label on icon-only buttons, visible text on labelled buttons)",
|
|
41
|
-
"
|
|
41
|
+
"Controls in ChatArtifactActions set isSemantic={false} (ui Button / IconButton render a span with role=button), because the root is already a button",
|
|
42
|
+
"When asChild renders the root as a link, put no controls inside; the title text names the link"
|
|
42
43
|
],
|
|
43
44
|
"keyboard": [
|
|
44
|
-
"The root is
|
|
45
|
+
"The root is a button and is focusable; Enter and Space activate it",
|
|
46
|
+
"Each action is a separate tab stop; Enter and Space activate it without activating the root"
|
|
45
47
|
],
|
|
46
48
|
"aria": [
|
|
47
|
-
"The root
|
|
49
|
+
"The root has the native button role; the actions wrapper sets role=group without an accessible name",
|
|
48
50
|
"ChatArtifactIcon sets no role or label; ChatArtifactTitle and ChatArtifactCaption supply the text"
|
|
49
51
|
],
|
|
50
|
-
"focus": ["
|
|
52
|
+
"focus": ["The root shows a focus-visible ring; action controls use their own focus rings"]
|
|
51
53
|
},
|
|
52
54
|
"behaviour": {
|
|
53
|
-
"states": ["default"],
|
|
55
|
+
"states": ["default", "hover", "pressed", "focus-visible"],
|
|
54
56
|
"rules": [
|
|
55
|
-
"asChild=true merges the root props onto the single child via Radix Slot; false (default) renders a
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
57
|
+
"asChild=true merges the root props onto the single child via Radix Slot; false (default) renders a button with type=button",
|
|
58
|
+
"The root reuses ui Card (level 1: card background, border and lvl-1 radius) laid out as a card header row",
|
|
59
|
+
"Hover, pressed and focus-visible fill an inset card-header area (card-header-lvl-1 inset, card-header radius) with layout-accent-low-background hover/pressed tokens; it stays clear while the pointer is over ChatArtifactActions. Focus-visible also shows the primary focus ring",
|
|
60
|
+
"ChatArtifactContent stacks ChatArtifactTitle above ChatArtifactCaption, at least 60px tall to match the icon row",
|
|
61
|
+
"ChatArtifactTitle uses ui CardTitle (body-medium) in layout-foreground-base and wraps; ChatArtifactCaption uses ui CardDescription (body-small-high) in layout-foreground-light and truncates to one line",
|
|
62
|
+
"ChatArtifactActions uses ui CardAction and stops click propagation, so an action click does not also activate the root",
|
|
63
|
+
"ChatArtifactIcon uses ui CardIcon: a round 32px avatar-background slot with an 18px icon in avatar-foreground",
|
|
64
|
+
"Every part takes className, merged last"
|
|
61
65
|
]
|
|
62
66
|
},
|
|
63
67
|
"composition": {
|
|
@@ -112,7 +116,12 @@
|
|
|
112
116
|
],
|
|
113
117
|
"tokenReferences": {
|
|
114
118
|
"source": "packages/design-system/src/tailwind.css",
|
|
115
|
-
"categories": [
|
|
116
|
-
|
|
119
|
+
"categories": [
|
|
120
|
+
"card-* (background, border, radius)",
|
|
121
|
+
"card-header-* (padding, gap)",
|
|
122
|
+
"avatar-* (background, foreground)",
|
|
123
|
+
"layout-foreground-* (title, caption)"
|
|
124
|
+
],
|
|
125
|
+
"rule": "Reuse the ui Card parts (Card, CardIcon, CardTitle, CardDescription, CardAction) and their tokens; do not invent an artifact palette."
|
|
117
126
|
}
|
|
118
127
|
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { fn } from 'storybook/test';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
DocIcon,
|
|
6
|
+
FormatListBulletedIcon,
|
|
7
|
+
PptIcon,
|
|
8
|
+
RightPanelOpenIcon,
|
|
9
|
+
ShareIcon,
|
|
10
|
+
} from '@swisper.ai/icons';
|
|
5
11
|
import { Button, IconButton } from '@swisper.ai/ui';
|
|
6
12
|
|
|
7
13
|
import { ParentBlock } from '../../__storybook__/parent-block';
|
|
@@ -30,7 +36,7 @@ const meta: Meta<typeof ChatArtifact> = {
|
|
|
30
36
|
asChild: {
|
|
31
37
|
control: 'boolean',
|
|
32
38
|
description:
|
|
33
|
-
'Merges the root props onto the single child (e.g. an `a`
|
|
39
|
+
'Merges the root props onto the single child (e.g. an `a`) instead of rendering a `button`.',
|
|
34
40
|
table: { defaultValue: { summary: 'false' } },
|
|
35
41
|
},
|
|
36
42
|
children: {
|
|
@@ -47,17 +53,44 @@ const meta: Meta<typeof ChatArtifact> = {
|
|
|
47
53
|
args: {
|
|
48
54
|
asChild: false,
|
|
49
55
|
className: 'w-fit',
|
|
56
|
+
onClick: fn(),
|
|
50
57
|
},
|
|
51
58
|
};
|
|
52
59
|
|
|
53
60
|
export default meta;
|
|
54
61
|
type Story = StoryObj<typeof ChatArtifact>;
|
|
55
62
|
|
|
56
|
-
/** An artifact in a message:
|
|
63
|
+
/** An artifact in a message: icon, name, caption, and an open action. Clicking the row or Open opens it. */
|
|
57
64
|
export const Default: Story = {
|
|
58
65
|
render: (args) => (
|
|
59
66
|
<ChatArtifact {...args}>
|
|
60
|
-
<ChatArtifactIcon
|
|
67
|
+
<ChatArtifactIcon>
|
|
68
|
+
<FormatListBulletedIcon />
|
|
69
|
+
</ChatArtifactIcon>
|
|
70
|
+
<ChatArtifactContent>
|
|
71
|
+
<ChatArtifactTitle>3-Day Zurich & Winterthur Birthday trip</ChatArtifactTitle>
|
|
72
|
+
<ChatArtifactCaption>My trip summary</ChatArtifactCaption>
|
|
73
|
+
</ChatArtifactContent>
|
|
74
|
+
<ChatArtifactActions>
|
|
75
|
+
<Button
|
|
76
|
+
variant="secondary"
|
|
77
|
+
size="sm"
|
|
78
|
+
isSemantic={false}
|
|
79
|
+
startIcon={<RightPanelOpenIcon />}
|
|
80
|
+
onClick={fn()}
|
|
81
|
+
>
|
|
82
|
+
Open
|
|
83
|
+
</Button>
|
|
84
|
+
</ChatArtifactActions>
|
|
85
|
+
</ChatArtifact>
|
|
86
|
+
),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** Share and open actions side by side. */
|
|
90
|
+
export const WithShare: Story = {
|
|
91
|
+
render: (args) => (
|
|
92
|
+
<ChatArtifact {...args}>
|
|
93
|
+
<ChatArtifactIcon>
|
|
61
94
|
<PptIcon />
|
|
62
95
|
</ChatArtifactIcon>
|
|
63
96
|
<ChatArtifactContent>
|
|
@@ -65,10 +98,22 @@ export const Default: Story = {
|
|
|
65
98
|
<ChatArtifactCaption>Claude Slides · Only you</ChatArtifactCaption>
|
|
66
99
|
</ChatArtifactContent>
|
|
67
100
|
<ChatArtifactActions>
|
|
68
|
-
<IconButton
|
|
101
|
+
<IconButton
|
|
102
|
+
variant="tertiary"
|
|
103
|
+
size="sm"
|
|
104
|
+
isSemantic={false}
|
|
105
|
+
aria-label="Share"
|
|
106
|
+
onClick={fn()}
|
|
107
|
+
>
|
|
69
108
|
<ShareIcon />
|
|
70
109
|
</IconButton>
|
|
71
|
-
<Button
|
|
110
|
+
<Button
|
|
111
|
+
variant="secondary"
|
|
112
|
+
size="sm"
|
|
113
|
+
isSemantic={false}
|
|
114
|
+
startIcon={<RightPanelOpenIcon />}
|
|
115
|
+
onClick={fn()}
|
|
116
|
+
>
|
|
72
117
|
Open
|
|
73
118
|
</Button>
|
|
74
119
|
</ChatArtifactActions>
|
|
@@ -76,13 +121,13 @@ export const Default: Story = {
|
|
|
76
121
|
),
|
|
77
122
|
};
|
|
78
123
|
|
|
79
|
-
/** The whole row is a link via `asChild` (no
|
|
124
|
+
/** The whole row is a link via `asChild` (no actions inside — the link is the only control). */
|
|
80
125
|
export const AsChildLink: Story = {
|
|
81
126
|
args: { asChild: true, className: 'w-fit' },
|
|
82
127
|
render: (args) => (
|
|
83
128
|
<ChatArtifact {...args}>
|
|
84
129
|
<a href="#artifact-weather" className="no-underline text-inherit">
|
|
85
|
-
<ChatArtifactIcon
|
|
130
|
+
<ChatArtifactIcon>
|
|
86
131
|
<PptIcon />
|
|
87
132
|
</ChatArtifactIcon>
|
|
88
133
|
<ChatArtifactContent>
|
|
@@ -98,7 +143,7 @@ export const AsChildLink: Story = {
|
|
|
98
143
|
export const TitleOnly: Story = {
|
|
99
144
|
render: (args) => (
|
|
100
145
|
<ChatArtifact {...args}>
|
|
101
|
-
<ChatArtifactIcon
|
|
146
|
+
<ChatArtifactIcon>
|
|
102
147
|
<DocIcon />
|
|
103
148
|
</ChatArtifactIcon>
|
|
104
149
|
<ChatArtifactContent>
|
|
@@ -108,11 +153,11 @@ export const TitleOnly: Story = {
|
|
|
108
153
|
),
|
|
109
154
|
};
|
|
110
155
|
|
|
111
|
-
/** A name and caption longer than the row:
|
|
156
|
+
/** A name and caption longer than the row: the name wraps, the caption ellipsizes to one line, and the actions stay fully visible. */
|
|
112
157
|
export const LongTitle: Story = {
|
|
113
158
|
render: (args) => (
|
|
114
159
|
<ChatArtifact {...args}>
|
|
115
|
-
<ChatArtifactIcon
|
|
160
|
+
<ChatArtifactIcon>
|
|
116
161
|
<PptIcon />
|
|
117
162
|
</ChatArtifactIcon>
|
|
118
163
|
<ChatArtifactContent>
|
|
@@ -124,10 +169,22 @@ export const LongTitle: Story = {
|
|
|
124
169
|
</ChatArtifactCaption>
|
|
125
170
|
</ChatArtifactContent>
|
|
126
171
|
<ChatArtifactActions>
|
|
127
|
-
<IconButton
|
|
172
|
+
<IconButton
|
|
173
|
+
variant="tertiary"
|
|
174
|
+
size="sm"
|
|
175
|
+
isSemantic={false}
|
|
176
|
+
aria-label="Share"
|
|
177
|
+
onClick={fn()}
|
|
178
|
+
>
|
|
128
179
|
<ShareIcon />
|
|
129
180
|
</IconButton>
|
|
130
|
-
<Button
|
|
181
|
+
<Button
|
|
182
|
+
variant="secondary"
|
|
183
|
+
size="sm"
|
|
184
|
+
isSemantic={false}
|
|
185
|
+
startIcon={<RightPanelOpenIcon />}
|
|
186
|
+
onClick={fn()}
|
|
187
|
+
>
|
|
131
188
|
Open
|
|
132
189
|
</Button>
|
|
133
190
|
</ChatArtifactActions>
|
|
@@ -141,7 +198,7 @@ export const Mobile: Story = {
|
|
|
141
198
|
args: { className: 'w-full' },
|
|
142
199
|
render: (args) => (
|
|
143
200
|
<ChatArtifact {...args}>
|
|
144
|
-
<ChatArtifactIcon
|
|
201
|
+
<ChatArtifactIcon>
|
|
145
202
|
<PptIcon />
|
|
146
203
|
</ChatArtifactIcon>
|
|
147
204
|
<ChatArtifactContent>
|
|
@@ -149,10 +206,22 @@ export const Mobile: Story = {
|
|
|
149
206
|
<ChatArtifactCaption>Claude Slides · Only you</ChatArtifactCaption>
|
|
150
207
|
</ChatArtifactContent>
|
|
151
208
|
<ChatArtifactActions>
|
|
152
|
-
<IconButton
|
|
209
|
+
<IconButton
|
|
210
|
+
variant="tertiary"
|
|
211
|
+
size="sm"
|
|
212
|
+
isSemantic={false}
|
|
213
|
+
aria-label="Share"
|
|
214
|
+
onClick={fn()}
|
|
215
|
+
>
|
|
153
216
|
<ShareIcon />
|
|
154
217
|
</IconButton>
|
|
155
|
-
<Button
|
|
218
|
+
<Button
|
|
219
|
+
variant="secondary"
|
|
220
|
+
size="sm"
|
|
221
|
+
isSemantic={false}
|
|
222
|
+
startIcon={<RightPanelOpenIcon />}
|
|
223
|
+
onClick={fn()}
|
|
224
|
+
>
|
|
156
225
|
Open
|
|
157
226
|
</Button>
|
|
158
227
|
</ChatArtifactActions>
|
|
@@ -168,7 +237,7 @@ export const Examples: Story = {
|
|
|
168
237
|
<li>
|
|
169
238
|
<ParentBlock parent="assistant message">
|
|
170
239
|
<ChatArtifact className="w-fit">
|
|
171
|
-
<ChatArtifactIcon
|
|
240
|
+
<ChatArtifactIcon>
|
|
172
241
|
<PptIcon />
|
|
173
242
|
</ChatArtifactIcon>
|
|
174
243
|
<ChatArtifactContent>
|
|
@@ -176,10 +245,22 @@ export const Examples: Story = {
|
|
|
176
245
|
<ChatArtifactCaption>Claude Slides · Only you</ChatArtifactCaption>
|
|
177
246
|
</ChatArtifactContent>
|
|
178
247
|
<ChatArtifactActions>
|
|
179
|
-
<IconButton
|
|
248
|
+
<IconButton
|
|
249
|
+
variant="tertiary"
|
|
250
|
+
size="sm"
|
|
251
|
+
isSemantic={false}
|
|
252
|
+
aria-label="Share"
|
|
253
|
+
onClick={fn()}
|
|
254
|
+
>
|
|
180
255
|
<ShareIcon />
|
|
181
256
|
</IconButton>
|
|
182
|
-
<Button
|
|
257
|
+
<Button
|
|
258
|
+
variant="secondary"
|
|
259
|
+
size="sm"
|
|
260
|
+
isSemantic={false}
|
|
261
|
+
startIcon={<RightPanelOpenIcon />}
|
|
262
|
+
onClick={fn()}
|
|
263
|
+
>
|
|
183
264
|
Open
|
|
184
265
|
</Button>
|
|
185
266
|
</ChatArtifactActions>
|
|
@@ -201,7 +282,7 @@ export const Playground: Story = {
|
|
|
201
282
|
return (
|
|
202
283
|
<ChatArtifact {...args}>
|
|
203
284
|
<a href="#artifact-playground" className="no-underline text-inherit">
|
|
204
|
-
<ChatArtifactIcon
|
|
285
|
+
<ChatArtifactIcon>
|
|
205
286
|
<PptIcon />
|
|
206
287
|
</ChatArtifactIcon>
|
|
207
288
|
<ChatArtifactContent>
|
|
@@ -215,7 +296,7 @@ export const Playground: Story = {
|
|
|
215
296
|
|
|
216
297
|
return (
|
|
217
298
|
<ChatArtifact {...args}>
|
|
218
|
-
<ChatArtifactIcon
|
|
299
|
+
<ChatArtifactIcon>
|
|
219
300
|
<PptIcon />
|
|
220
301
|
</ChatArtifactIcon>
|
|
221
302
|
<ChatArtifactContent>
|
|
@@ -223,10 +304,22 @@ export const Playground: Story = {
|
|
|
223
304
|
<ChatArtifactCaption>Claude Slides · Only you</ChatArtifactCaption>
|
|
224
305
|
</ChatArtifactContent>
|
|
225
306
|
<ChatArtifactActions>
|
|
226
|
-
<IconButton
|
|
307
|
+
<IconButton
|
|
308
|
+
variant="tertiary"
|
|
309
|
+
size="sm"
|
|
310
|
+
isSemantic={false}
|
|
311
|
+
aria-label="Share"
|
|
312
|
+
onClick={fn()}
|
|
313
|
+
>
|
|
227
314
|
<ShareIcon />
|
|
228
315
|
</IconButton>
|
|
229
|
-
<Button
|
|
316
|
+
<Button
|
|
317
|
+
variant="secondary"
|
|
318
|
+
size="sm"
|
|
319
|
+
isSemantic={false}
|
|
320
|
+
startIcon={<RightPanelOpenIcon />}
|
|
321
|
+
onClick={fn()}
|
|
322
|
+
>
|
|
230
323
|
Open
|
|
231
324
|
</Button>
|
|
232
325
|
</ChatArtifactActions>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Slot } from '@radix-ui/react-slot';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ComponentProps, MouseEvent, ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Card, CardAction, CardDescription, CardIcon, CardTitle } from '@swisper.ai/ui';
|
|
5
5
|
import { cn } from '@swisper.ai/web-core';
|
|
6
6
|
|
|
7
|
-
export interface ChatArtifactProps extends
|
|
8
|
-
/** When true, merges props onto the single child instead of rendering a `
|
|
7
|
+
export interface ChatArtifactProps extends ComponentProps<'button'> {
|
|
8
|
+
/** When true, merges props onto the single child instead of rendering a `button`. */
|
|
9
9
|
asChild?: boolean;
|
|
10
10
|
/** Classes merged last onto the root. */
|
|
11
11
|
className?: string;
|
|
@@ -18,26 +18,37 @@ export function ChatArtifact({ asChild = false, className, children, ...rest }:
|
|
|
18
18
|
const Comp = asChild ? Slot : 'button';
|
|
19
19
|
|
|
20
20
|
return (
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
<Card asChild>
|
|
22
|
+
<Comp
|
|
23
|
+
{...(asChild ? {} : { type: 'button' as const })}
|
|
24
|
+
data-slot="chat-artifact"
|
|
25
|
+
data-testid="chat-artifact"
|
|
26
|
+
className={cn(
|
|
27
|
+
'cursor-pointer',
|
|
28
|
+
'w-full',
|
|
29
|
+
'flex-row items-start gap-card-header-gap',
|
|
30
|
+
// card-header padding plus the header's hover-area inset, flattened so asChild keeps one element
|
|
31
|
+
'py-card-header-lvl-1',
|
|
32
|
+
'px-[calc(var(--spacing-card-header-lvl-1)+var(--spacing-card-header-hover-area))]',
|
|
33
|
+
'text-left',
|
|
34
|
+
// the card-header hover area, drawn as an inset layer behind the content so asChild keeps one element
|
|
35
|
+
'isolate',
|
|
36
|
+
'before:absolute before:inset-card-header-lvl-1 before:-z-10 before:pointer-events-none',
|
|
37
|
+
'before:rounded-card-header before:transition-colors',
|
|
38
|
+
'hover:before:bg-layout-accent-low-background-hover-base',
|
|
39
|
+
'active:before:bg-layout-accent-low-background-pressed-base',
|
|
40
|
+
'focus-visible:before:bg-layout-accent-low-background-hover-base',
|
|
41
|
+
// an action click does not activate the row, so the row does not light up under one
|
|
42
|
+
'has-[[data-slot=chat-artifact-actions]:hover]:before:bg-transparent',
|
|
43
|
+
'outline-none',
|
|
44
|
+
'focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-primary-focus-visible',
|
|
45
|
+
className,
|
|
46
|
+
)}
|
|
47
|
+
{...rest}
|
|
48
|
+
>
|
|
49
|
+
{children}
|
|
50
|
+
</Comp>
|
|
51
|
+
</Card>
|
|
41
52
|
);
|
|
42
53
|
}
|
|
43
54
|
|
|
@@ -48,27 +59,16 @@ export interface ChatArtifactIconProps {
|
|
|
48
59
|
children?: ReactNode;
|
|
49
60
|
}
|
|
50
61
|
|
|
51
|
-
/**
|
|
62
|
+
/** Round 32px avatar slot for a consumer-supplied icon or thumbnail. */
|
|
52
63
|
export function ChatArtifactIcon({ className, children }: ChatArtifactIconProps) {
|
|
53
64
|
return (
|
|
54
|
-
<
|
|
65
|
+
<CardIcon
|
|
55
66
|
data-slot="chat-artifact-icon"
|
|
56
67
|
data-testid="chat-artifact-icon"
|
|
57
|
-
className={cn('
|
|
68
|
+
className={cn('text-avatar-foreground', '[&_svg]:size-4.5', className)}
|
|
58
69
|
>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
'size-full',
|
|
62
|
-
'inline-flex items-center justify-center',
|
|
63
|
-
'rounded-[8px] p-8 [&_svg]:size-16',
|
|
64
|
-
'bg-secondary-hover',
|
|
65
|
-
'text-icon-fill-inverse',
|
|
66
|
-
className,
|
|
67
|
-
)}
|
|
68
|
-
>
|
|
69
|
-
{children}
|
|
70
|
-
</span>
|
|
71
|
-
</span>
|
|
70
|
+
{children}
|
|
71
|
+
</CardIcon>
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -85,7 +85,14 @@ export function ChatArtifactContent({ className, children }: ChatArtifactContent
|
|
|
85
85
|
<div
|
|
86
86
|
data-slot="chat-artifact-content"
|
|
87
87
|
data-testid="chat-artifact-content"
|
|
88
|
-
className={cn(
|
|
88
|
+
className={cn(
|
|
89
|
+
'flex-1 min-w-0',
|
|
90
|
+
'flex flex-col items-start justify-center',
|
|
91
|
+
// matches the icon row height: 32px icon plus 14px margins
|
|
92
|
+
'min-h-15 py-1.5',
|
|
93
|
+
'text-left',
|
|
94
|
+
className,
|
|
95
|
+
)}
|
|
89
96
|
>
|
|
90
97
|
{children}
|
|
91
98
|
</div>
|
|
@@ -99,17 +106,16 @@ export interface ChatArtifactTitleProps {
|
|
|
99
106
|
children?: ReactNode;
|
|
100
107
|
}
|
|
101
108
|
|
|
102
|
-
/** The artifact name
|
|
109
|
+
/** The artifact name; wraps onto more lines when it is long. */
|
|
103
110
|
export function ChatArtifactTitle({ className, children }: ChatArtifactTitleProps) {
|
|
104
111
|
return (
|
|
105
|
-
<
|
|
106
|
-
variant="body-sm"
|
|
112
|
+
<CardTitle
|
|
107
113
|
data-slot="chat-artifact-title"
|
|
108
114
|
data-testid="chat-artifact-title"
|
|
109
|
-
className={cn('
|
|
115
|
+
className={cn('w-full wrap-break-word truncate', 'text-layout-foreground-base', className)}
|
|
110
116
|
>
|
|
111
117
|
{children}
|
|
112
|
-
</
|
|
118
|
+
</CardTitle>
|
|
113
119
|
);
|
|
114
120
|
}
|
|
115
121
|
|
|
@@ -123,34 +129,37 @@ export interface ChatArtifactCaptionProps {
|
|
|
123
129
|
/** A quieter secondary line under the title, truncated to one line. */
|
|
124
130
|
export function ChatArtifactCaption({ className, children }: ChatArtifactCaptionProps) {
|
|
125
131
|
return (
|
|
126
|
-
<
|
|
127
|
-
variant="caption-md"
|
|
132
|
+
<CardDescription
|
|
128
133
|
data-slot="chat-artifact-caption"
|
|
129
134
|
data-testid="chat-artifact-caption"
|
|
130
|
-
className={cn('min-w-0 w-full truncate', 'text-
|
|
135
|
+
className={cn('min-w-0 w-full truncate', 'text-layout-foreground-light', className)}
|
|
131
136
|
>
|
|
132
137
|
{children}
|
|
133
|
-
</
|
|
138
|
+
</CardDescription>
|
|
134
139
|
);
|
|
135
140
|
}
|
|
136
141
|
|
|
137
142
|
export interface ChatArtifactActionsProps {
|
|
138
143
|
/** Classes merged last onto the actions wrapper. */
|
|
139
144
|
className?: string;
|
|
140
|
-
/** Consumer-supplied controls, e.g. share and open buttons
|
|
145
|
+
/** Consumer-supplied controls, e.g. share and open buttons with `isSemantic={false}`. */
|
|
141
146
|
children?: ReactNode;
|
|
142
147
|
}
|
|
143
148
|
|
|
144
|
-
/** Trailing action slot on the right of the row. */
|
|
149
|
+
/** Trailing action slot on the right of the row; clicks here do not reach the root. */
|
|
145
150
|
export function ChatArtifactActions({ className, children }: ChatArtifactActionsProps) {
|
|
151
|
+
// the root is a button, so an action click must not also activate the row
|
|
152
|
+
const handleClick = (event: MouseEvent<HTMLDivElement>) => event.stopPropagation();
|
|
153
|
+
|
|
146
154
|
return (
|
|
147
|
-
<
|
|
155
|
+
<CardAction
|
|
148
156
|
role="group"
|
|
149
157
|
data-slot="chat-artifact-actions"
|
|
150
158
|
data-testid="chat-artifact-actions"
|
|
151
|
-
className={cn(
|
|
159
|
+
className={cn(className)}
|
|
160
|
+
onClick={handleClick}
|
|
152
161
|
>
|
|
153
162
|
{children}
|
|
154
|
-
</
|
|
163
|
+
</CardAction>
|
|
155
164
|
);
|
|
156
165
|
}
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
ChatThinkingProcessContent,
|
|
6
6
|
ChatThinkingProcessContentItem,
|
|
7
7
|
ChatThinkingProcessTrigger,
|
|
8
|
-
ChatThinkingProcessTriggerArrow,
|
|
9
8
|
ChatThinkingProcessTriggerIcon,
|
|
10
9
|
ChatThinkingProcessTriggerLabel,
|
|
11
10
|
} from '../../chat-thinking-process';
|
|
@@ -24,9 +23,7 @@ export function ToolSteps({ steps }: ToolStepsProps) {
|
|
|
24
23
|
</ChatThinkingProcessTriggerIcon>
|
|
25
24
|
<ChatThinkingProcessTriggerLabel>
|
|
26
25
|
{`Used ${steps.length} ${steps.length === 1 ? 'tool' : 'tools'}`}
|
|
27
|
-
</ChatThinkingProcessTriggerLabel>
|
|
28
|
-
<ChatThinkingProcessTriggerArrow />
|
|
29
|
-
</ChatThinkingProcessTrigger>
|
|
26
|
+
</ChatThinkingProcessTriggerLabel> </ChatThinkingProcessTrigger>
|
|
30
27
|
<ChatThinkingProcessContent>
|
|
31
28
|
{steps.map((step) => (
|
|
32
29
|
<ChatThinkingProcessContentItem key={step}>{step}</ChatThinkingProcessContentItem>
|