@swisper.ai/web-chat-ui 0.2.8 → 0.2.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swisper.ai/web-chat-ui",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "React components for the Swisper chat: messages, composer and cards",
5
5
  "keywords": [
6
6
  "react",
@@ -1,11 +1,10 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
2
  import { fn } from 'storybook/test';
3
3
 
4
- import { ShareIcon } from '@swisper.ai/icons';
4
+ import { DocIcon, PptIcon, ShareIcon } from '@swisper.ai/icons';
5
5
  import { Button, IconButton } from '@swisper.ai/ui';
6
6
 
7
7
  import { ParentBlock } from '../../__storybook__/parent-block';
8
- import { ChatMessageAttachmentCardIcon } from '../chat-message-attachment-card';
9
8
 
10
9
  import {
11
10
  ChatArtifact,
@@ -42,12 +41,12 @@ const meta: Meta<typeof ChatArtifact> = {
42
41
  className: {
43
42
  control: 'text',
44
43
  description:
45
- 'Extra classes merged onto the root, e.g. `w-fit max-w-80` to cap the row width.',
44
+ 'Extra classes merged onto the root, e.g. `w-fit` to fit the content or `w-full` on mobile. The row is 320px wide at least and never wider than its parent.',
46
45
  },
47
46
  },
48
47
  args: {
49
48
  asChild: false,
50
- className: 'w-fit max-w-80',
49
+ className: 'w-fit',
51
50
  },
52
51
  };
53
52
 
@@ -58,8 +57,8 @@ type Story = StoryObj<typeof ChatArtifact>;
58
57
  export const Default: Story = {
59
58
  render: (args) => (
60
59
  <ChatArtifact {...args}>
61
- <ChatArtifactIcon>
62
- <ChatMessageAttachmentCardIcon icon="presentation" />
60
+ <ChatArtifactIcon className="bg-data-e">
61
+ <PptIcon />
63
62
  </ChatArtifactIcon>
64
63
  <ChatArtifactContent>
65
64
  <ChatArtifactTitle>Weather</ChatArtifactTitle>
@@ -79,12 +78,12 @@ export const Default: Story = {
79
78
 
80
79
  /** The whole row is a link via `asChild` (no nested buttons — those belong on a `div` root). */
81
80
  export const AsChildLink: Story = {
82
- args: { asChild: true, className: 'w-fit max-w-80' },
81
+ args: { asChild: true, className: 'w-fit' },
83
82
  render: (args) => (
84
83
  <ChatArtifact {...args}>
85
84
  <a href="#artifact-weather" className="no-underline text-inherit">
86
- <ChatArtifactIcon>
87
- <ChatMessageAttachmentCardIcon icon="presentation" />
85
+ <ChatArtifactIcon className="bg-data-e">
86
+ <PptIcon />
88
87
  </ChatArtifactIcon>
89
88
  <ChatArtifactContent>
90
89
  <ChatArtifactTitle>Weather</ChatArtifactTitle>
@@ -99,8 +98,8 @@ export const AsChildLink: Story = {
99
98
  export const TitleOnly: Story = {
100
99
  render: (args) => (
101
100
  <ChatArtifact {...args}>
102
- <ChatArtifactIcon>
103
- <ChatMessageAttachmentCardIcon icon="document" />
101
+ <ChatArtifactIcon className="bg-data-c">
102
+ <DocIcon />
104
103
  </ChatArtifactIcon>
105
104
  <ChatArtifactContent>
106
105
  <ChatArtifactTitle>Q3 itinerary draft</ChatArtifactTitle>
@@ -113,8 +112,8 @@ export const TitleOnly: Story = {
113
112
  export const LongTitle: Story = {
114
113
  render: (args) => (
115
114
  <ChatArtifact {...args}>
116
- <ChatArtifactIcon>
117
- <ChatMessageAttachmentCardIcon icon="presentation" />
115
+ <ChatArtifactIcon className="bg-data-e">
116
+ <PptIcon />
118
117
  </ChatArtifactIcon>
119
118
  <ChatArtifactContent>
120
119
  <ChatArtifactTitle>
@@ -136,6 +135,31 @@ export const LongTitle: Story = {
136
135
  ),
137
136
  };
138
137
 
138
+ /** On mobile the row spans the full width (`w-full`) instead of fitting its content. */
139
+ export const Mobile: Story = {
140
+ globals: { viewport: { value: 'mobile1', isRotated: false } },
141
+ args: { className: 'w-full' },
142
+ render: (args) => (
143
+ <ChatArtifact {...args}>
144
+ <ChatArtifactIcon className="bg-data-e">
145
+ <PptIcon />
146
+ </ChatArtifactIcon>
147
+ <ChatArtifactContent>
148
+ <ChatArtifactTitle>Weather</ChatArtifactTitle>
149
+ <ChatArtifactCaption>Claude Slides · Only you</ChatArtifactCaption>
150
+ </ChatArtifactContent>
151
+ <ChatArtifactActions>
152
+ <IconButton variant="tertiary" size="sm" aria-label="Share" onClick={fn()}>
153
+ <ShareIcon />
154
+ </IconButton>
155
+ <Button size="sm" onClick={fn()}>
156
+ Open
157
+ </Button>
158
+ </ChatArtifactActions>
159
+ </ChatArtifact>
160
+ ),
161
+ };
162
+
139
163
  /** Inside an assistant message, as it appears in a thread. */
140
164
  export const Examples: Story = {
141
165
  parameters: { controls: { disable: true } },
@@ -143,9 +167,9 @@ export const Examples: Story = {
143
167
  <ul aria-label="ChatArtifact examples" className="flex flex-col gap-24">
144
168
  <li>
145
169
  <ParentBlock parent="assistant message">
146
- <ChatArtifact className="w-fit max-w-80">
147
- <ChatArtifactIcon>
148
- <ChatMessageAttachmentCardIcon icon="presentation" />
170
+ <ChatArtifact className="w-fit">
171
+ <ChatArtifactIcon className="bg-data-e">
172
+ <PptIcon />
149
173
  </ChatArtifactIcon>
150
174
  <ChatArtifactContent>
151
175
  <ChatArtifactTitle>Weather</ChatArtifactTitle>
@@ -170,15 +194,15 @@ export const Examples: Story = {
170
194
  export const Playground: Story = {
171
195
  args: {
172
196
  asChild: false,
173
- className: 'w-fit max-w-80',
197
+ className: 'w-fit',
174
198
  },
175
199
  render: (args) => {
176
200
  if (args.asChild) {
177
201
  return (
178
202
  <ChatArtifact {...args}>
179
203
  <a href="#artifact-playground" className="no-underline text-inherit">
180
- <ChatArtifactIcon>
181
- <ChatMessageAttachmentCardIcon icon="presentation" />
204
+ <ChatArtifactIcon className="bg-data-e">
205
+ <PptIcon />
182
206
  </ChatArtifactIcon>
183
207
  <ChatArtifactContent>
184
208
  <ChatArtifactTitle>Weather</ChatArtifactTitle>
@@ -191,8 +215,8 @@ export const Playground: Story = {
191
215
 
192
216
  return (
193
217
  <ChatArtifact {...args}>
194
- <ChatArtifactIcon>
195
- <ChatMessageAttachmentCardIcon icon="presentation" />
218
+ <ChatArtifactIcon className="bg-data-e">
219
+ <PptIcon />
196
220
  </ChatArtifactIcon>
197
221
  <ChatArtifactContent>
198
222
  <ChatArtifactTitle>Weather</ChatArtifactTitle>
@@ -24,7 +24,8 @@ export function ChatArtifact({ asChild = false, className, children, ...rest }:
24
24
  data-testid="chat-artifact"
25
25
  className={cn(
26
26
  'cursor-pointer',
27
- 'max-w-80',
27
+ 'w-full',
28
+ 'md:max-w-[min(400px,calc(var(--chat-window-width,100%)-var(--spacing-message)))]',
28
29
  'flex flex-row items-center gap-8',
29
30
  'p-8 rounded-promptbox-attachment',
30
31
  'bg-promptbox-attachment-background',
@@ -54,15 +55,20 @@ export function ChatArtifactIcon({ className, children }: ChatArtifactIconProps)
54
55
  <span
55
56
  data-slot="chat-artifact-icon"
56
57
  data-testid="chat-artifact-icon"
57
- className={cn(
58
- 'inline-flex shrink-0 items-center justify-center',
59
- 'text-icon-fill-inverse inline-flex size-promptbox-attachment-size-icon-container items-center justify-center',
60
- 'bg-secondary-hover',
61
- 'rounded-[8px] p-8 [&_svg]:size-[24px]',
62
- className,
63
- )}
58
+ className={cn('shrink-0', 'inline-flex items-center justify-center', 'size-32')}
64
59
  >
65
- {children}
60
+ <span
61
+ className={cn(
62
+ 'size-full',
63
+ 'inline-flex items-center justify-center',
64
+ 'rounded-[8px] p-8 [&_svg]:size-16',
65
+ 'bg-secondary-hover',
66
+ 'text-icon-fill-inverse',
67
+ className,
68
+ )}
69
+ >
70
+ {children}
71
+ </span>
66
72
  </span>
67
73
  );
68
74
  }