@swisper.ai/web-chat-ui 0.0.6 → 0.0.8

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.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "React components for the Swisper chat: messages, composer and cards",
5
5
  "keywords": [
6
6
  "react",
@@ -64,10 +64,10 @@
64
64
  "@radix-ui/react-scroll-area": "^1.2.10",
65
65
  "@radix-ui/react-slot": "^1.1.0",
66
66
  "@shadcn/react": "^0.3.1",
67
- "@swisper.ai/design-system": "0.0.3",
68
- "@swisper.ai/icons": "0.0.3",
69
- "@swisper.ai/tailwind-config": "0.0.3",
70
- "@swisper.ai/ui": "0.2.0",
67
+ "@swisper.ai/design-system": "0.0.4",
68
+ "@swisper.ai/icons": "0.0.4",
69
+ "@swisper.ai/tailwind-config": "0.0.4",
70
+ "@swisper.ai/ui": "0.3.1",
71
71
  "@swisper.ai/web-core": "0.0.3",
72
72
  "@tanstack/react-virtual": "^3.14.5",
73
73
  "chroma-js": "^3.2.0",
@@ -97,7 +97,7 @@
97
97
  "zustand": "^5.0.5"
98
98
  },
99
99
  "devDependencies": {
100
- "@fintama/swisper-int-storybook-theme": "0.0.1",
100
+ "@fintama/swisper-int-storybook-theme": "0.0.2",
101
101
  "@fintama/swisper-int-vite-config": "0.0.1",
102
102
  "@fintama/swisper-int-vitest-config": "0.0.1",
103
103
  "@storybook/addon-a11y": "10.6.0",
@@ -69,6 +69,7 @@
69
69
  "options menu open"
70
70
  ],
71
71
  "rules": [
72
+ "CanvasShell is built on ui/panel and keeps its own part names; it is never collapsible. For a panel that collapses to a rail, compose ui/panel directly",
72
73
  "CanvasShell is h-full with overflow hidden and a grid of auto / minmax(0,1fr) / auto rows: it takes its parent's height, and long content never grows the middle row past it",
73
74
  "CanvasShellHeader.hasBorder draws a bottom separator under the header; set it to false for a header that blends into the content",
74
75
  "CanvasShellTitle takes the free width of the header and truncates to one line, so a long title never pushes the buttons out",
@@ -136,6 +137,7 @@
136
137
  }
137
138
  ],
138
139
  "relatedComponents": [
140
+ "ui/panel",
139
141
  "ui/dialog",
140
142
  "web-chat-ui/chat-thread",
141
143
  "ui/scroll-area",
@@ -1,12 +1,20 @@
1
1
  import { useState, type ComponentProps, type ReactNode } from 'react';
2
2
 
3
- import { CloseIcon, OpenInFullIcon, MoreHorizontalIcon } from '@swisper.ai/icons';
3
+ import { MoreHorizontalIcon, OpenInFullIcon } from '@swisper.ai/icons';
4
4
  import {
5
- IconButton,
6
5
  Menu,
7
6
  MenuProvider,
8
7
  MenuTrigger,
9
- Typography,
8
+ Panel,
9
+ PanelActionButton,
10
+ PanelActionCloseButton,
11
+ PanelBody,
12
+ PanelContent,
13
+ PanelFooter,
14
+ PanelHeader,
15
+ PanelProvider,
16
+ PanelTitle,
17
+ panelBodyPadding,
10
18
  type IconButtonProps,
11
19
  type TypographyProps,
12
20
  } from '@swisper.ai/ui';
@@ -15,23 +23,16 @@ import { cn } from '@swisper.ai/web-core';
15
23
  export interface CanvasShellProps extends ComponentProps<'section'> {}
16
24
 
17
25
  /**
18
- * Three-row grid: header and footer size to their content, the content row takes the rest.
19
- * `minmax(0,1fr)` keeps a long list from growing the middle row past the shell's height.
20
- * The single column is `minmax(0,1fr)` too, so a long title truncates instead of widening the header.
26
+ * The `ui` Panel as the canvas beside the chat: a three-row grid where header and footer size to
27
+ * their content and the content row takes the rest of the shell's height. It does not collapse.
21
28
  */
22
29
  export function CanvasShell({ className, children, ...props }: CanvasShellProps) {
23
30
  return (
24
- <section
25
- data-slot="canvas-shell"
26
- className={cn(
27
- 'grid grid-cols-1 grid-rows-[auto_minmax(0,1fr)_auto]',
28
- 'h-full overflow-hidden',
29
- className,
30
- )}
31
- {...props}
32
- >
33
- {children}
34
- </section>
31
+ <PanelProvider isCollapsible={false}>
32
+ <Panel data-slot="canvas-shell" className={className} {...props}>
33
+ {children}
34
+ </Panel>
35
+ </PanelProvider>
35
36
  );
36
37
  }
37
38
 
@@ -50,20 +51,14 @@ export function CanvasShellHeader({
50
51
  ...props
51
52
  }: CanvasShellHeaderProps) {
52
53
  return (
53
- <header
54
+ <PanelHeader
54
55
  data-slot="canvas-shell-header"
55
- data-separator={hasBorder}
56
- className={cn(
57
- 'row-start-1',
58
- 'flex items-center gap-[8px]',
59
- 'p-[12px] md:p-[16px]',
60
- 'data-[separator=true]:border-b data-[separator=true]:border-brand-secondary-700',
61
- className,
62
- )}
56
+ hasBorder={hasBorder}
57
+ className={className}
63
58
  {...props}
64
59
  >
65
60
  {children}
66
- </header>
61
+ </PanelHeader>
67
62
  );
68
63
  }
69
64
 
@@ -74,15 +69,9 @@ export interface CanvasShellTitleProps extends Omit<TypographyProps, 'variant'>
74
69
  */
75
70
  export function CanvasShellTitle({ className, children, ...props }: CanvasShellTitleProps) {
76
71
  return (
77
- <Typography
78
- data-slot="canvas-shell-title"
79
- variant="label-xl"
80
- fontWeight="normal"
81
- className={cn('flex-1 min-w-0 truncate', className)}
82
- {...props}
83
- >
72
+ <PanelTitle data-slot="canvas-shell-title" className={className} {...props}>
84
73
  {children}
85
- </Typography>
74
+ </PanelTitle>
86
75
  );
87
76
  }
88
77
 
@@ -97,17 +86,9 @@ export function CanvasShellCloseTrigger({
97
86
  ...props
98
87
  }: CanvasShellCloseTriggerProps) {
99
88
  return (
100
- <IconButton
101
- data-slot="canvas-shell-close-trigger"
102
- type="button"
103
- variant="tertiary"
104
- size="md"
105
- aria-label="Close panel"
106
- className={cn('shrink-0', className)}
107
- {...props}
108
- >
109
- {children || <CloseIcon />}
110
- </IconButton>
89
+ <PanelActionCloseButton data-slot="canvas-shell-close-trigger" className={className} {...props}>
90
+ {children}
91
+ </PanelActionCloseButton>
111
92
  );
112
93
  }
113
94
 
@@ -133,20 +114,17 @@ export function CanvasShellFullScreenTrigger({
133
114
  ...props
134
115
  }: CanvasShellFullScreenTriggerProps) {
135
116
  return (
136
- <IconButton
117
+ <PanelActionButton
137
118
  data-slot="canvas-shell-full-screen-trigger"
138
- type="button"
139
- variant="tertiary"
140
- size="md"
141
119
  aria-pressed={isFullScreen}
142
120
  aria-label={
143
121
  isFullScreen ? (labels?.exit ?? 'Exit full screen') : (labels?.enter ?? 'Full screen')
144
122
  }
145
- className={cn('shrink-0 max-md:hidden', className)}
123
+ className={cn('max-md:hidden', className)}
146
124
  {...props}
147
125
  >
148
126
  {children || <OpenInFullIcon />}
149
- </IconButton>
127
+ </PanelActionButton>
150
128
  );
151
129
  }
152
130
 
@@ -179,18 +157,15 @@ export function CanvasShellOptionsButton({
179
157
  return (
180
158
  <MenuProvider modal={false} onOpenChange={handleOpenChange}>
181
159
  <MenuTrigger asChild>
182
- <IconButton
160
+ <PanelActionButton
183
161
  data-slot="canvas-shell-options-button"
184
- type="button"
185
- variant="tertiary"
186
- size="md"
187
162
  isActive={isOpen}
188
163
  aria-label="More options"
189
- className={cn('shrink-0', className)}
164
+ className={className}
190
165
  {...props}
191
166
  >
192
167
  <MoreHorizontalIcon />
193
- </IconButton>
168
+ </PanelActionButton>
194
169
  </MenuTrigger>
195
170
  <Menu className={cn('w-[200px]', menuClassName)}>{children}</Menu>
196
171
  </MenuProvider>
@@ -215,7 +190,7 @@ export interface CanvasShellContentProps extends ComponentProps<'div'> {
215
190
  /**
216
191
  * Horizontal padding of the content region; reuse it to align custom scroll areas with the shell.
217
192
  */
218
- export const canvasShellContentPadding = 'px-[12px] md:px-[16px]';
193
+ export const canvasShellContentPadding = panelBodyPadding;
219
194
 
220
195
  /**
221
196
  * Middle row, the only part that moves: it scrolls or clips its children inside the shell's height.
@@ -230,26 +205,21 @@ export function CanvasShellContent({
230
205
  ...props
231
206
  }: CanvasShellContentProps) {
232
207
  return (
233
- <div
208
+ <PanelContent
234
209
  data-slot="canvas-shell-content"
235
210
  data-has-scroll={hasScroll}
236
- className={cn('row-start-2', 'relative min-w-0 overflow-hidden', className)}
211
+ className={className}
237
212
  {...props}
238
213
  >
239
- <div
214
+ <PanelBody
240
215
  data-slot="canvas-shell-content-body"
241
- data-spacing={hasPadding}
242
- className={cn(
243
- 'size-full',
244
- 'py-[16px]',
245
- hasPadding && canvasShellContentPadding,
246
- hasScroll ? 'overflow-auto' : 'overflow-hidden',
247
- bodyClassName,
248
- )}
216
+ hasPadding={hasPadding}
217
+ hasScroll={hasScroll}
218
+ className={bodyClassName}
249
219
  >
250
220
  {children}
251
- </div>
252
- </div>
221
+ </PanelBody>
222
+ </PanelContent>
253
223
  );
254
224
  }
255
225
 
@@ -260,18 +230,8 @@ export interface CanvasShellFooterProps extends ComponentProps<'footer'> {}
260
230
  */
261
231
  export function CanvasShellFooter({ className, children, ...props }: CanvasShellFooterProps) {
262
232
  return (
263
- <footer
264
- data-slot="canvas-shell-footer"
265
- className={cn(
266
- 'row-start-3',
267
- 'flex items-center justify-end gap-[8px]',
268
- 'p-[12px] md:p-[16px]',
269
- 'pb-[20px]',
270
- className,
271
- )}
272
- {...props}
273
- >
233
+ <PanelFooter data-slot="canvas-shell-footer" className={className} {...props}>
274
234
  {children}
275
- </footer>
235
+ </PanelFooter>
276
236
  );
277
237
  }