@rise-x/apps-sdk 0.9.0 → 0.11.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.
Files changed (92) hide show
  1. package/README.md +116 -31
  2. package/build/rsbuild/index.d.ts +6 -1
  3. package/build/rsbuild/index.js +23 -2
  4. package/build/ui/classes.json +209 -0
  5. package/build/ui/components/ai.d.ts +33 -1
  6. package/build/ui/components/app-frame.d.ts +16 -10
  7. package/build/ui/components/chat-input.d.ts +28 -0
  8. package/build/ui/components/message-scroller.d.ts +34 -10
  9. package/build/ui/components/sheet.d.ts +10 -0
  10. package/build/ui/components/thinking-rings.d.ts +4 -0
  11. package/build/ui/demo.html +26794 -0
  12. package/build/ui/index.d.ts +2 -0
  13. package/build/ui/standalone.js +59 -58
  14. package/build/ui/styles.css +1 -1
  15. package/package.json +4 -3
  16. package/template/AGENTS.md +3 -3
  17. package/template/README.md +5 -5
  18. package/template/package.json +8 -9
  19. package/template/rsbuild.config.mts +17 -0
  20. package/template/src/App.tsx +4 -1
  21. package/template/tsconfig.json +3 -1
  22. package/build/ui/reference/README.md +0 -11
  23. package/build/ui/reference/components/accordion.tsx +0 -85
  24. package/build/ui/reference/components/ai.tsx +0 -293
  25. package/build/ui/reference/components/alert-dialog.tsx +0 -207
  26. package/build/ui/reference/components/alert.tsx +0 -112
  27. package/build/ui/reference/components/app-frame.tsx +0 -71
  28. package/build/ui/reference/components/aspect-ratio.tsx +0 -28
  29. package/build/ui/reference/components/avatar.tsx +0 -158
  30. package/build/ui/reference/components/badge.tsx +0 -160
  31. package/build/ui/reference/components/button-group.tsx +0 -77
  32. package/build/ui/reference/components/button.tsx +0 -109
  33. package/build/ui/reference/components/calendar.tsx +0 -119
  34. package/build/ui/reference/components/card.tsx +0 -144
  35. package/build/ui/reference/components/carousel.tsx +0 -248
  36. package/build/ui/reference/components/chart.tsx +0 -704
  37. package/build/ui/reference/components/checkbox.tsx +0 -44
  38. package/build/ui/reference/components/collapsible.tsx +0 -43
  39. package/build/ui/reference/components/combobox.tsx +0 -146
  40. package/build/ui/reference/components/command.tsx +0 -181
  41. package/build/ui/reference/components/context-menu.tsx +0 -243
  42. package/build/ui/reference/components/data-table.tsx +0 -650
  43. package/build/ui/reference/components/date-picker.tsx +0 -218
  44. package/build/ui/reference/components/dialog.tsx +0 -172
  45. package/build/ui/reference/components/direction.tsx +0 -22
  46. package/build/ui/reference/components/dropdown-menu.tsx +0 -245
  47. package/build/ui/reference/components/empty-state.tsx +0 -63
  48. package/build/ui/reference/components/field.tsx +0 -252
  49. package/build/ui/reference/components/file-upload.tsx +0 -116
  50. package/build/ui/reference/components/hover-card.tsx +0 -64
  51. package/build/ui/reference/components/input-group.tsx +0 -157
  52. package/build/ui/reference/components/input-otp.tsx +0 -106
  53. package/build/ui/reference/components/input.tsx +0 -86
  54. package/build/ui/reference/components/item.tsx +0 -188
  55. package/build/ui/reference/components/kbd.tsx +0 -43
  56. package/build/ui/reference/components/label.tsx +0 -19
  57. package/build/ui/reference/components/list.tsx +0 -191
  58. package/build/ui/reference/components/map.css +0 -251
  59. package/build/ui/reference/components/map.tsx +0 -294
  60. package/build/ui/reference/components/menubar.tsx +0 -275
  61. package/build/ui/reference/components/message-scroller.tsx +0 -141
  62. package/build/ui/reference/components/message.tsx +0 -177
  63. package/build/ui/reference/components/nav.tsx +0 -127
  64. package/build/ui/reference/components/navigation-menu.tsx +0 -191
  65. package/build/ui/reference/components/page-header.tsx +0 -245
  66. package/build/ui/reference/components/popover.tsx +0 -76
  67. package/build/ui/reference/components/progress.tsx +0 -31
  68. package/build/ui/reference/components/radio.tsx +0 -65
  69. package/build/ui/reference/components/resizable.tsx +0 -40
  70. package/build/ui/reference/components/scroll-area.tsx +0 -55
  71. package/build/ui/reference/components/segmented.tsx +0 -45
  72. package/build/ui/reference/components/select.tsx +0 -188
  73. package/build/ui/reference/components/separator.tsx +0 -26
  74. package/build/ui/reference/components/sheet.tsx +0 -184
  75. package/build/ui/reference/components/skeleton.tsx +0 -15
  76. package/build/ui/reference/components/slider.tsx +0 -161
  77. package/build/ui/reference/components/snackbar.tsx +0 -27
  78. package/build/ui/reference/components/sonner.tsx +0 -43
  79. package/build/ui/reference/components/spinner.tsx +0 -27
  80. package/build/ui/reference/components/statistic.tsx +0 -122
  81. package/build/ui/reference/components/stepper.tsx +0 -138
  82. package/build/ui/reference/components/switch.tsx +0 -47
  83. package/build/ui/reference/components/table.tsx +0 -246
  84. package/build/ui/reference/components/textarea.tsx +0 -28
  85. package/build/ui/reference/components/timeline.tsx +0 -101
  86. package/build/ui/reference/components/toggle-group.tsx +0 -86
  87. package/build/ui/reference/components/toggle.tsx +0 -46
  88. package/build/ui/reference/components/tooltip.tsx +0 -53
  89. package/build/ui/reference/index.ts +0 -69
  90. package/build/ui/reference/lib/utils.ts +0 -34
  91. package/template/webpack.config.js +0 -112
  92. package/template/webpack.local.config.js +0 -68
@@ -1,275 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import { Menubar as MenubarPrimitive } from 'radix-ui';
5
-
6
- import { cn } from '@rise-x/ui/lib/utils';
7
- import { CheckIcon, ChevronRightIcon } from 'lucide-react';
8
-
9
- /*
10
- * A desktop-application menu bar — File / Edit / View. Included for the few
11
- * surfaces that genuinely are applications (an editor, a modelling tool), and it
12
- * carries a warning with it:
13
- *
14
- * NOT FOR APP NAVIGATION, AND NEVER IN A FEDERATED APP. The host already renders
15
- * top-bar navigation above every app, and app navigation is a left rail. A menu
16
- * bar is for COMMANDS, not places — if the items would navigate somewhere, this is
17
- * the wrong component and `Nav` is the right one.
18
- *
19
- * The bar itself is a filled track with no border, matching Segmented: the fill is
20
- * the container, and a border around a filled track is the same statement twice.
21
- * The menus that drop out of it are DropdownMenu's surface exactly.
22
- */
23
- function Menubar({ className, ...props }: React.ComponentProps<typeof MenubarPrimitive.Root>) {
24
- return (
25
- <MenubarPrimitive.Root
26
- data-slot="menubar"
27
- className={cn(
28
- 'flex h-control items-center gap-0.5 rounded-lg border-0 bg-fill-1 p-0.5',
29
- className,
30
- )}
31
- {...props}
32
- />
33
- );
34
- }
35
-
36
- function MenubarMenu({ ...props }: React.ComponentProps<typeof MenubarPrimitive.Menu>) {
37
- return <MenubarPrimitive.Menu data-slot="menubar-menu" {...props} />;
38
- }
39
-
40
- function MenubarGroup({ ...props }: React.ComponentProps<typeof MenubarPrimitive.Group>) {
41
- return <MenubarPrimitive.Group data-slot="menubar-group" {...props} />;
42
- }
43
-
44
- function MenubarPortal({ ...props }: React.ComponentProps<typeof MenubarPrimitive.Portal>) {
45
- return <MenubarPrimitive.Portal data-slot="menubar-portal" {...props} />;
46
- }
47
-
48
- function MenubarRadioGroup({ ...props }: React.ComponentProps<typeof MenubarPrimitive.RadioGroup>) {
49
- return <MenubarPrimitive.RadioGroup data-slot="menubar-radio-group" {...props} />;
50
- }
51
-
52
- function MenubarSub({ ...props }: React.ComponentProps<typeof MenubarPrimitive.Sub>) {
53
- return <MenubarPrimitive.Sub data-slot="menubar-sub" {...props} />;
54
- }
55
-
56
- /* The open trigger takes the same white thumb as a selected Segmented item — one
57
- * grammar for "this is the active one in a filled track". */
58
- function MenubarTrigger({
59
- className,
60
- ...props
61
- }: React.ComponentProps<typeof MenubarPrimitive.Trigger>) {
62
- return (
63
- <MenubarPrimitive.Trigger
64
- data-slot="menubar-trigger"
65
- className={cn(
66
- 'inline-flex h-control-xs shrink-0 cursor-pointer items-center rounded-md border-0 bg-transparent px-2.5 text-xs text-muted-foreground transition-[background-color,color] duration-200 ease-decelerate outline-none select-none',
67
- 'focus-visible:ring-3 focus-visible:ring-ring-control/35',
68
- 'data-open:bg-card data-open:font-medium data-open:text-foreground data-open:shadow-[0_1px_3px_rgb(16_24_40/0.12),0_1px_1px_rgb(16_24_40/0.06)]',
69
- className,
70
- )}
71
- {...props}
72
- />
73
- );
74
- }
75
-
76
- function MenubarContent({
77
- className,
78
- align = 'start',
79
- alignOffset = -4,
80
- sideOffset = 6,
81
- ...props
82
- }: React.ComponentProps<typeof MenubarPrimitive.Content>) {
83
- return (
84
- <MenubarPrimitive.Portal>
85
- <MenubarPrimitive.Content
86
- data-slot="menubar-content"
87
- align={align}
88
- alignOffset={alignOffset}
89
- sideOffset={sideOffset}
90
- className={cn(
91
- 'z-50 min-w-48 origin-(--radix-menubar-content-transform-origin) overflow-hidden rounded-xl bg-popover p-1.5 text-popover-foreground shadow-pop duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
92
- className,
93
- )}
94
- {...props}
95
- />
96
- </MenubarPrimitive.Portal>
97
- );
98
- }
99
-
100
- function MenubarItem({
101
- className,
102
- inset,
103
- variant = 'default',
104
- ...props
105
- }: React.ComponentProps<typeof MenubarPrimitive.Item> & {
106
- inset?: boolean;
107
- variant?: 'default' | 'destructive';
108
- }) {
109
- return (
110
- <MenubarPrimitive.Item
111
- data-slot="menubar-item"
112
- data-inset={inset}
113
- data-variant={variant}
114
- className={cn(
115
- "group/menubar-item relative flex cursor-default items-center gap-2 rounded-md h-7 px-2 text-ui font-medium outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-9.5 data-[variant=destructive]:text-error-text data-[variant=destructive]:focus:bg-error/10 data-[variant=destructive]:focus:text-error-text dark:data-[variant=destructive]:focus:bg-error/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5 data-[variant=destructive]:*:[svg]:text-error-text",
116
- className,
117
- )}
118
- {...props}
119
- />
120
- );
121
- }
122
-
123
- function MenubarCheckboxItem({
124
- className,
125
- children,
126
- checked,
127
- ...props
128
- }: React.ComponentProps<typeof MenubarPrimitive.CheckboxItem>) {
129
- return (
130
- <MenubarPrimitive.CheckboxItem
131
- data-slot="menubar-checkbox-item"
132
- className={cn(
133
- "relative flex cursor-default items-center gap-2 rounded-md h-7 pr-8 pl-2 text-ui font-medium outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
134
- className,
135
- )}
136
- checked={checked}
137
- {...props}
138
- >
139
- <span
140
- className="pointer-events-none absolute right-2 flex items-center justify-center"
141
- data-slot="menubar-checkbox-item-indicator"
142
- >
143
- <MenubarPrimitive.ItemIndicator>
144
- <CheckIcon />
145
- </MenubarPrimitive.ItemIndicator>
146
- </span>
147
- {children}
148
- </MenubarPrimitive.CheckboxItem>
149
- );
150
- }
151
-
152
- function MenubarRadioItem({
153
- className,
154
- children,
155
- ...props
156
- }: React.ComponentProps<typeof MenubarPrimitive.RadioItem>) {
157
- return (
158
- <MenubarPrimitive.RadioItem
159
- data-slot="menubar-radio-item"
160
- className={cn(
161
- "relative flex cursor-default items-center gap-2 rounded-md h-7 pr-8 pl-2 text-ui font-medium outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
162
- className,
163
- )}
164
- {...props}
165
- >
166
- <span
167
- className="pointer-events-none absolute right-2 flex items-center justify-center"
168
- data-slot="menubar-radio-item-indicator"
169
- >
170
- <MenubarPrimitive.ItemIndicator>
171
- <CheckIcon />
172
- </MenubarPrimitive.ItemIndicator>
173
- </span>
174
- {children}
175
- </MenubarPrimitive.RadioItem>
176
- );
177
- }
178
-
179
- function MenubarLabel({
180
- className,
181
- inset,
182
- ...props
183
- }: React.ComponentProps<typeof MenubarPrimitive.Label> & { inset?: boolean }) {
184
- return (
185
- <MenubarPrimitive.Label
186
- data-slot="menubar-label"
187
- data-inset={inset}
188
- className={cn('px-3 py-2.5 text-xs text-muted-foreground data-inset:pl-9.5', className)}
189
- {...props}
190
- />
191
- );
192
- }
193
-
194
- function MenubarSeparator({
195
- className,
196
- ...props
197
- }: React.ComponentProps<typeof MenubarPrimitive.Separator>) {
198
- return (
199
- <MenubarPrimitive.Separator
200
- data-slot="menubar-separator"
201
- className={cn('-mx-1.5 my-1.5 h-px bg-border/50', className)}
202
- {...props}
203
- />
204
- );
205
- }
206
-
207
- function MenubarShortcut({ className, ...props }: React.ComponentProps<'span'>) {
208
- return (
209
- <span
210
- data-slot="menubar-shortcut"
211
- className={cn(
212
- 'ml-auto text-xs tracking-widest text-muted-foreground group-focus/menubar-item:text-accent-foreground',
213
- className,
214
- )}
215
- {...props}
216
- />
217
- );
218
- }
219
-
220
- function MenubarSubTrigger({
221
- className,
222
- inset,
223
- children,
224
- ...props
225
- }: React.ComponentProps<typeof MenubarPrimitive.SubTrigger> & { inset?: boolean }) {
226
- return (
227
- <MenubarPrimitive.SubTrigger
228
- data-slot="menubar-sub-trigger"
229
- data-inset={inset}
230
- className={cn(
231
- "flex cursor-default items-center gap-2 rounded-md h-7 px-2 text-ui font-medium outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-9.5 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
232
- className,
233
- )}
234
- {...props}
235
- >
236
- {children}
237
- <ChevronRightIcon className="ml-auto" />
238
- </MenubarPrimitive.SubTrigger>
239
- );
240
- }
241
-
242
- function MenubarSubContent({
243
- className,
244
- ...props
245
- }: React.ComponentProps<typeof MenubarPrimitive.SubContent>) {
246
- return (
247
- <MenubarPrimitive.SubContent
248
- data-slot="menubar-sub-content"
249
- className={cn(
250
- 'z-50 min-w-36 origin-(--radix-menubar-content-transform-origin) overflow-hidden rounded-xl bg-popover p-1.5 text-popover-foreground shadow-pop duration-100 dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
251
- className,
252
- )}
253
- {...props}
254
- />
255
- );
256
- }
257
-
258
- export {
259
- Menubar,
260
- MenubarMenu,
261
- MenubarTrigger,
262
- MenubarContent,
263
- MenubarGroup,
264
- MenubarPortal,
265
- MenubarLabel,
266
- MenubarItem,
267
- MenubarCheckboxItem,
268
- MenubarRadioGroup,
269
- MenubarRadioItem,
270
- MenubarSeparator,
271
- MenubarShortcut,
272
- MenubarSub,
273
- MenubarSubTrigger,
274
- MenubarSubContent,
275
- };
@@ -1,141 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import { ArrowDownIcon } from 'lucide-react';
5
-
6
- import { cn } from '@rise-x/ui/lib/utils';
7
-
8
- /*
9
- * The scroll container for a conversation. Sounds trivial; it is the piece every
10
- * chat surface rebuilds slightly wrong, in the same two ways:
11
- *
12
- * 1. IT PINS TO THE BOTTOM ONLY WHILE THE READER IS ALREADY THERE. Scrolling to
13
- * the newest message unconditionally yanks the view away from someone reading
14
- * back through history — which is exactly when they are least able to tell
15
- * what moved. So "stick" is a state, not an action: it is true while the
16
- * reader sits within a threshold of the bottom and false the moment they
17
- * leave, and only the sticky case auto-scrolls.
18
- * 2. WHEN NOT STUCK, NEW MESSAGES ANNOUNCE THEMSELVES INSTEAD OF ARRIVING.
19
- * Same rule the live-data guidance applies to tables: content may accumulate,
20
- * but it may not move under the cursor. The jump button carries the count, so
21
- * "3 new" is a decision the reader makes rather than a surprise.
22
- *
23
- * THE THRESHOLD IS NOT ZERO. Sub-pixel scroll heights, rubber-banding and a
24
- * growing last message all make an exact bottom comparison flicker between true
25
- * and false. 32px is far enough to be stable and near enough to read as "at the
26
- * bottom".
27
- */
28
- const STICK_THRESHOLD = 32;
29
-
30
- function atBottom(el: HTMLElement) {
31
- return el.scrollHeight - el.scrollTop - el.clientHeight <= STICK_THRESHOLD;
32
- }
33
-
34
- const MessageScroller = React.forwardRef<
35
- HTMLDivElement,
36
- React.ComponentProps<'div'> & {
37
- /** Bump this whenever a message is appended — it is what triggers the stick. */
38
- revision?: number | string;
39
- /** Shown on the jump affordance while the reader is away from the bottom. */
40
- unreadCount?: number;
41
- /** Label for the jump affordance when no count is given. */
42
- jumpLabel?: string;
43
- /** Label when `unreadCount` is set. Override to localise — the built-in
44
- * default is English with an English plural rule, and it is the form that
45
- * actually shows once a count exists, so `jumpLabel` alone cannot carry a
46
- * translation. */
47
- formatUnread?: (count: number) => string;
48
- }
49
- >(function MessageScroller(
50
- {
51
- className,
52
- children,
53
- revision,
54
- unreadCount,
55
- jumpLabel = 'New messages',
56
- formatUnread = (count) => `${count} ${count === 1 ? 'new message' : 'new messages'}`,
57
- onScroll: onScrollProp,
58
- ...props
59
- },
60
- ref,
61
- ) {
62
- const inner = React.useRef<HTMLDivElement | null>(null);
63
- // a ref, not state: the scroll handler and the append effect both read it, and
64
- // an effect that ran against a stale `stuck` would scroll when it must not
65
- const stuck = React.useRef(true);
66
- const [showJump, setShowJump] = React.useState(false);
67
-
68
- const setNode = React.useCallback(
69
- (node: HTMLDivElement | null) => {
70
- inner.current = node;
71
- if (typeof ref === 'function') ref(node);
72
- else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;
73
- },
74
- [ref],
75
- );
76
-
77
- const toBottom = React.useCallback((behavior: ScrollBehavior = 'auto') => {
78
- const el = inner.current;
79
- if (!el) return;
80
- el.scrollTo({ top: el.scrollHeight, behavior });
81
- stuck.current = true;
82
- setShowJump(false);
83
- }, []);
84
-
85
- /* A caller's onScroll runs ALONGSIDE the stick tracking, never instead of it:
86
- * this used to sit before `{...props}`, so passing onScroll — plausible for a
87
- * surface that reports read position — silently replaced the handler and left
88
- * `stuck` true forever, yanking the reader to the newest message. */
89
- const onScroll = React.useCallback(
90
- (event: React.UIEvent<HTMLDivElement>) => {
91
- const el = inner.current;
92
- if (el) {
93
- stuck.current = atBottom(el);
94
- setShowJump(!stuck.current);
95
- }
96
- onScrollProp?.(event);
97
- },
98
- [onScrollProp],
99
- );
100
-
101
- // start at the newest message rather than the oldest
102
- React.useEffect(() => {
103
- toBottom();
104
- // eslint-disable-next-line react-hooks/exhaustive-deps
105
- }, []);
106
-
107
- React.useEffect(() => {
108
- if (stuck.current) toBottom();
109
- }, [revision, toBottom]);
110
-
111
- return (
112
- <div data-slot="message-scroller" className={cn('relative min-h-0', className)}>
113
- <div
114
- ref={setNode}
115
- data-slot="message-scroller-viewport"
116
- onScroll={onScroll}
117
- className="h-full overflow-y-auto overscroll-contain"
118
- {...props}
119
- >
120
- {children}
121
- </div>
122
- {showJump ? (
123
- <div
124
- data-slot="message-scroller-jump"
125
- className="pointer-events-none absolute inset-x-0 bottom-2.5 flex justify-center"
126
- >
127
- <button
128
- type="button"
129
- onClick={() => toBottom('smooth')}
130
- className="pointer-events-auto inline-flex h-control-sm cursor-pointer items-center gap-1.5 rounded-full border-0 bg-foreground px-3 text-xs font-medium text-background shadow-pop outline-none transition-colors focus-visible:ring-3 focus-visible:ring-ring-control/35 [&>svg]:size-3"
131
- >
132
- <ArrowDownIcon aria-hidden />
133
- {unreadCount ? formatUnread(unreadCount) : jumpLabel}
134
- </button>
135
- </div>
136
- ) : null}
137
- </div>
138
- );
139
- });
140
-
141
- export { MessageScroller };
@@ -1,177 +0,0 @@
1
- import * as React from 'react';
2
-
3
- import { cn } from '@rise-x/ui/lib/utils';
4
- import { FileCard } from '@rise-x/ui/components/file-upload';
5
-
6
- /*
7
- * Chat message. Structure follows shadcn's Message primitive:
8
- * MessageGroup > Message > [MessageAvatar, MessageHeader/Bubble/Footer]
9
- *
10
- * GRID, not flex. The avatar has to bottom-align to the BUBBLE row and stay
11
- * clear of the footer actions; a flex row with align-items:flex-end sinks it
12
- * past the footer instead.
13
- *
14
- * THE ASYMMETRY IS THE POINT. A user turn is a bubble — short, quotable, and it
15
- * needs to be visibly *theirs*; it stops at 80% of the column so even a long
16
- * paste still reads as a bubble against the edge. An assistant turn is NOT: AI
17
- * answers run long, and a tinted block the height of the viewport is a wall. So
18
- * `variant="ai"` strips the bubble entirely — no background, no border, no
19
- * padding — and caps the measure at 68ch so it reads as prose. Colour on an AI
20
- * turn marks *activity* (see ai.tsx), never the finished answer.
21
- */
22
- function MessageGroup({ className, ...props }: React.ComponentProps<'div'>) {
23
- return (
24
- <div data-slot="message-group" className={cn('flex flex-col gap-3.5', className)} {...props} />
25
- );
26
- }
27
-
28
- function Message({
29
- className,
30
- align = 'start',
31
- ...props
32
- }: React.ComponentProps<'div'> & { align?: 'start' | 'end' }) {
33
- return (
34
- <div
35
- data-slot="message"
36
- data-align={align}
37
- className={cn(
38
- 'grid grid-cols-[26px_minmax(0,1fr)] gap-x-[9px] gap-y-[5px]',
39
- align === 'end' && 'grid-cols-[minmax(0,1fr)_26px]',
40
- className,
41
- )}
42
- {...props}
43
- />
44
- );
45
- }
46
-
47
- /* Row 2, bottom-aligned — sits level with the bubble, not the footer. */
48
- function MessageAvatar({
49
- className,
50
- align = 'start',
51
- ...props
52
- }: React.ComponentProps<'div'> & { align?: 'start' | 'end' }) {
53
- return (
54
- <div
55
- data-slot="message-avatar"
56
- className={cn(
57
- 'col-start-1 row-start-2 self-end',
58
- align === 'end' && 'col-start-2',
59
- className,
60
- )}
61
- {...props}
62
- />
63
- );
64
- }
65
-
66
- function MessageHeader({
67
- className,
68
- align = 'start',
69
- ...props
70
- }: React.ComponentProps<'div'> & { align?: 'start' | 'end' }) {
71
- return (
72
- <div
73
- data-slot="message-header"
74
- className={cn(
75
- 'col-start-2 row-start-1 flex items-center gap-[7px] text-micro text-subtle [&>b]:font-medium [&>b]:text-muted-foreground',
76
- align === 'end' && 'col-start-1 justify-self-start',
77
- className,
78
- )}
79
- {...props}
80
- />
81
- );
82
- }
83
-
84
- function MessageBody({
85
- className,
86
- align = 'start',
87
- ...props
88
- }: React.ComponentProps<'div'> & { align?: 'start' | 'end' }) {
89
- return (
90
- <div
91
- data-slot="message-body"
92
- className={cn(
93
- 'col-start-2 row-start-2 flex min-w-0 flex-col items-start gap-1.5',
94
- align === 'end' && 'col-start-1 items-end',
95
- className,
96
- )}
97
- {...props}
98
- />
99
- );
100
- }
101
-
102
- function MessageBubble({
103
- className,
104
- variant = 'default',
105
- ...props
106
- }: React.ComponentProps<'div'> & { variant?: 'default' | 'user' | 'ai' }) {
107
- return (
108
- <div
109
- data-slot="message-bubble"
110
- data-variant={variant}
111
- className={cn(
112
- 'w-fit max-w-full text-ui leading-[1.55]',
113
- variant === 'default' && 'rounded-xl bg-fill-1 px-3 py-[9px]',
114
- variant === 'user' &&
115
- // The raised surface, not --primary: a host that brands --primary pins
116
- // one colour across both themes, and a mid-grey brand left the bubble
117
- // almost invisible on a dark page. Card inverts with the theme, so the
118
- // bubble reads as a pill lifted off the canvas in both.
119
- 'max-w-[80%] rounded-xl border border-border/60 bg-card px-3 py-[9px] text-card-foreground shadow-pill',
120
- // no bubble at all — see the note at the top of this file
121
- variant === 'ai' && 'max-w-[68ch] border-0 bg-transparent px-0 pt-px pb-0',
122
- className,
123
- )}
124
- {...props}
125
- />
126
- );
127
- }
128
-
129
- function MessageFooter({
130
- className,
131
- align = 'start',
132
- ...props
133
- }: React.ComponentProps<'div'> & { align?: 'start' | 'end' }) {
134
- return (
135
- <div
136
- data-slot="message-footer"
137
- className={cn(
138
- 'col-start-2 row-start-3 flex items-center gap-0.5 text-micro text-subtle',
139
- align === 'end' && 'col-start-1 justify-self-end',
140
- className,
141
- )}
142
- {...props}
143
- />
144
- );
145
- }
146
-
147
- function MessageAttachments({ className, ...props }: React.ComponentProps<'div'>) {
148
- return (
149
- <div
150
- data-slot="message-attachments"
151
- className={cn('flex flex-wrap gap-1.5', className)}
152
- {...props}
153
- />
154
- );
155
- }
156
-
157
- /* An attachment IS a FileCard — same glyph/name/meta/action anatomy, and the
158
- * reasoning for it lives in file-upload.tsx. Only the minimum width differs: in
159
- * a chat the cards sit in a wrapping row and need a floor, in an upload list
160
- * they fill the column. */
161
- function MessageAttachment({ className, ...props }: React.ComponentProps<typeof FileCard>) {
162
- return (
163
- <FileCard data-slot="message-attachment" className={cn('min-w-52', className)} {...props} />
164
- );
165
- }
166
-
167
- export {
168
- MessageGroup,
169
- Message,
170
- MessageAvatar,
171
- MessageHeader,
172
- MessageBody,
173
- MessageBubble,
174
- MessageFooter,
175
- MessageAttachments,
176
- MessageAttachment,
177
- };