@swisper.ai/web-chat-ui 0.0.6 → 0.0.7
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/components/canvas-shell/canvas-shell.d.ts +2 -3
- package/dist/components/canvas-shell/canvas-shell.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.js +1282 -1290
- package/dist/index.es.js.map +1 -1
- package/package.json +4 -4
- package/src/components/canvas-shell/canvas-shell.json +2 -0
- package/src/components/canvas-shell/canvas-shell.tsx +44 -84
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swisper.ai/web-chat-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
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.
|
|
67
|
+
"@swisper.ai/design-system": "0.0.4",
|
|
68
68
|
"@swisper.ai/icons": "0.0.3",
|
|
69
|
-
"@swisper.ai/tailwind-config": "0.0.
|
|
70
|
-
"@swisper.ai/ui": "0.
|
|
69
|
+
"@swisper.ai/tailwind-config": "0.0.4",
|
|
70
|
+
"@swisper.ai/ui": "0.3.0",
|
|
71
71
|
"@swisper.ai/web-core": "0.0.3",
|
|
72
72
|
"@tanstack/react-virtual": "^3.14.5",
|
|
73
73
|
"chroma-js": "^3.2.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 {
|
|
3
|
+
import { MoreHorizontalIcon, OpenInFullIcon } from '@swisper.ai/icons';
|
|
4
4
|
import {
|
|
5
|
-
IconButton,
|
|
6
5
|
Menu,
|
|
7
6
|
MenuProvider,
|
|
8
7
|
MenuTrigger,
|
|
9
|
-
|
|
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
|
-
*
|
|
19
|
-
*
|
|
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
|
-
<
|
|
25
|
-
data-slot="canvas-shell"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
<
|
|
54
|
+
<PanelHeader
|
|
54
55
|
data-slot="canvas-shell-header"
|
|
55
|
-
|
|
56
|
-
className={
|
|
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
|
-
</
|
|
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
|
-
<
|
|
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
|
-
</
|
|
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
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
<
|
|
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('
|
|
123
|
+
className={cn('max-md:hidden', className)}
|
|
146
124
|
{...props}
|
|
147
125
|
>
|
|
148
126
|
{children || <OpenInFullIcon />}
|
|
149
|
-
</
|
|
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
|
-
<
|
|
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={
|
|
164
|
+
className={className}
|
|
190
165
|
{...props}
|
|
191
166
|
>
|
|
192
167
|
<MoreHorizontalIcon />
|
|
193
|
-
</
|
|
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 =
|
|
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
|
-
<
|
|
208
|
+
<PanelContent
|
|
234
209
|
data-slot="canvas-shell-content"
|
|
235
210
|
data-has-scroll={hasScroll}
|
|
236
|
-
className={
|
|
211
|
+
className={className}
|
|
237
212
|
{...props}
|
|
238
213
|
>
|
|
239
|
-
<
|
|
214
|
+
<PanelBody
|
|
240
215
|
data-slot="canvas-shell-content-body"
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
</
|
|
252
|
-
</
|
|
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
|
-
</
|
|
235
|
+
</PanelFooter>
|
|
276
236
|
);
|
|
277
237
|
}
|