@codefast/ui 0.5.0-canary.2 → 0.5.0-canary.3
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/CHANGELOG.md +32 -0
- package/dist/components/attachment.d.mts +136 -0
- package/dist/components/attachment.mjs +112 -0
- package/dist/components/avatar.mjs +1 -1
- package/dist/components/bubble.d.mts +67 -0
- package/dist/components/bubble.mjs +58 -0
- package/dist/components/card.mjs +2 -2
- package/dist/components/carousel.mjs +12 -3
- package/dist/components/empty.mjs +1 -1
- package/dist/components/marker.d.mts +49 -0
- package/dist/components/marker.mjs +42 -0
- package/dist/components/message-scroller.d.mts +89 -0
- package/dist/components/message-scroller.mjs +77 -0
- package/dist/components/message.d.mts +86 -0
- package/dist/components/message.mjs +66 -0
- package/dist/components/sidebar.mjs +6 -3
- package/dist/hooks/use-message-scroller-commands.d.mts +39 -0
- package/dist/hooks/use-message-scroller-commands.mjs +165 -0
- package/dist/hooks/use-message-scroller-controller.d.mts +19 -0
- package/dist/hooks/use-message-scroller-controller.mjs +382 -0
- package/dist/hooks/use-message-scroller-refs.d.mts +60 -0
- package/dist/hooks/use-message-scroller-refs.mjs +77 -0
- package/dist/index.d.mts +11 -1
- package/dist/index.mjs +11 -2
- package/dist/lib/message-scroller/geometry.d.mts +136 -0
- package/dist/lib/message-scroller/geometry.mjs +199 -0
- package/dist/lib/message-scroller/stores.d.mts +21 -0
- package/dist/lib/message-scroller/stores.mjs +52 -0
- package/dist/lib/message-scroller/types.d.mts +171 -0
- package/dist/lib/message-scroller/types.mjs +53 -0
- package/dist/lib/message-scroller/utils.d.mts +7 -0
- package/dist/lib/message-scroller/utils.mjs +12 -0
- package/dist/lib/use-render.d.mts +43 -0
- package/dist/lib/use-render.mjs +84 -0
- package/dist/primitives/message-scroller.d.mts +88 -0
- package/dist/primitives/message-scroller.mjs +240 -0
- package/dist/variants/attachment.d.mts +42 -0
- package/dist/variants/attachment.mjs +42 -0
- package/dist/variants/bubble.d.mts +45 -0
- package/dist/variants/bubble.mjs +45 -0
- package/dist/variants/marker.d.mts +21 -0
- package/dist/variants/marker.mjs +18 -0
- package/package.json +52 -6
- package/src/components/attachment.tsx +284 -0
- package/src/components/avatar.tsx +1 -1
- package/src/components/bubble.tsx +116 -0
- package/src/components/card.tsx +2 -2
- package/src/components/carousel.tsx +12 -3
- package/src/components/empty.tsx +1 -1
- package/src/components/marker.tsx +94 -0
- package/src/components/message-scroller.tsx +213 -0
- package/src/components/message.tsx +173 -0
- package/src/components/sidebar.tsx +11 -4
- package/src/css/foundation/tokens.css +6 -18
- package/src/css/foundation/utilities.css +451 -0
- package/src/css/preset.css +2 -1
- package/src/hooks/use-message-scroller-commands.ts +312 -0
- package/src/hooks/use-message-scroller-controller.ts +651 -0
- package/src/hooks/use-message-scroller-refs.ts +168 -0
- package/src/index.ts +72 -0
- package/src/lib/message-scroller/geometry.ts +398 -0
- package/src/lib/message-scroller/stores.ts +89 -0
- package/src/lib/message-scroller/types.ts +310 -0
- package/src/lib/message-scroller/utils.ts +15 -0
- package/src/lib/use-render.ts +202 -0
- package/src/primitives/message-scroller.tsx +399 -0
- package/src/variants/attachment.ts +73 -0
- package/src/variants/bubble.ts +81 -0
- package/src/variants/marker.ts +38 -0
|
@@ -6,6 +6,7 @@ import type { ComponentProps, JSX, KeyboardEvent } from "react";
|
|
|
6
6
|
import { useCallback, useEffect, useState } from "react";
|
|
7
7
|
|
|
8
8
|
import { Button } from "#/components/button";
|
|
9
|
+
import { useDirection } from "#/components/direction";
|
|
9
10
|
import { cn } from "#/lib/utils";
|
|
10
11
|
|
|
11
12
|
/* -----------------------------------------------------------------------------
|
|
@@ -66,8 +67,12 @@ function Carousel({
|
|
|
66
67
|
setApi,
|
|
67
68
|
...props
|
|
68
69
|
}: ScopedProps<CarouselProps>): JSX.Element {
|
|
70
|
+
const direction = useDirection();
|
|
71
|
+
|
|
69
72
|
const [carouselRef, api] = useEmblaCarousel(
|
|
70
73
|
{
|
|
74
|
+
// Mirror Embla's drag/snap physics under RTL; explicit opts.direction wins.
|
|
75
|
+
direction,
|
|
71
76
|
...opts,
|
|
72
77
|
axis: orientation === "vertical" ? "y" : "x",
|
|
73
78
|
},
|
|
@@ -96,15 +101,19 @@ function Carousel({
|
|
|
96
101
|
|
|
97
102
|
const handleKeyDown = useCallback(
|
|
98
103
|
(event: KeyboardEvent<HTMLDivElement>) => {
|
|
99
|
-
|
|
104
|
+
// Arrow keys follow reading direction: in RTL the left key advances.
|
|
105
|
+
const previousKey = direction === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
106
|
+
const nextKey = direction === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
107
|
+
|
|
108
|
+
if (event.key === previousKey) {
|
|
100
109
|
event.preventDefault();
|
|
101
110
|
scrollPrevious();
|
|
102
|
-
} else if (event.key ===
|
|
111
|
+
} else if (event.key === nextKey) {
|
|
103
112
|
event.preventDefault();
|
|
104
113
|
scrollNext();
|
|
105
114
|
}
|
|
106
115
|
},
|
|
107
|
-
[scrollPrevious, scrollNext],
|
|
116
|
+
[direction, scrollPrevious, scrollNext],
|
|
108
117
|
);
|
|
109
118
|
|
|
110
119
|
useEffect(() => {
|
package/src/components/empty.tsx
CHANGED
|
@@ -20,7 +20,7 @@ function Empty({ className, ...props }: EmptyProps): JSX.Element {
|
|
|
20
20
|
return (
|
|
21
21
|
<div
|
|
22
22
|
className={cn(
|
|
23
|
-
"flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-
|
|
23
|
+
"flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-12 text-center text-balance",
|
|
24
24
|
className,
|
|
25
25
|
)}
|
|
26
26
|
data-slot="empty"
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Slot } from "radix-ui";
|
|
2
|
+
import type { ComponentProps, JSX } from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "#/lib/utils";
|
|
5
|
+
import type { MarkerVariants } from "#/variants/marker";
|
|
6
|
+
import { markerVariants } from "#/variants/marker";
|
|
7
|
+
|
|
8
|
+
/* -----------------------------------------------------------------------------
|
|
9
|
+
* Component: Marker
|
|
10
|
+
* -------------------------------------------------------------------------- */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Inline divider for a message feed — a date, unread line, or section label.
|
|
14
|
+
*
|
|
15
|
+
* @since 0.5.0-canary.3
|
|
16
|
+
*/
|
|
17
|
+
interface MarkerProps extends ComponentProps<"div">, MarkerVariants {
|
|
18
|
+
asChild?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @since 0.5.0-canary.3
|
|
23
|
+
*/
|
|
24
|
+
function Marker({ asChild = false, className, variant = "default", ...props }: MarkerProps): JSX.Element {
|
|
25
|
+
const Component = asChild ? Slot.Root : "div";
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Component
|
|
29
|
+
className={markerVariants({ className, variant })}
|
|
30
|
+
data-slot="marker"
|
|
31
|
+
data-variant={variant}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* -----------------------------------------------------------------------------
|
|
38
|
+
* Component: MarkerIcon
|
|
39
|
+
* -------------------------------------------------------------------------- */
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Decorative leading icon for a marker.
|
|
43
|
+
*
|
|
44
|
+
* @since 0.5.0-canary.3
|
|
45
|
+
*/
|
|
46
|
+
type MarkerIconProps = ComponentProps<"span">;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @since 0.5.0-canary.3
|
|
50
|
+
*/
|
|
51
|
+
function MarkerIcon({ className, ...props }: MarkerIconProps): JSX.Element {
|
|
52
|
+
return (
|
|
53
|
+
<span
|
|
54
|
+
aria-hidden="true"
|
|
55
|
+
className={cn("size-4 shrink-0 [&_svg:not([class*='size-'])]:size-4", className)}
|
|
56
|
+
data-slot="marker-icon"
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* -----------------------------------------------------------------------------
|
|
63
|
+
* Component: MarkerContent
|
|
64
|
+
* -------------------------------------------------------------------------- */
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Marker label; centers between the rules in the `separator` variant.
|
|
68
|
+
*
|
|
69
|
+
* @since 0.5.0-canary.3
|
|
70
|
+
*/
|
|
71
|
+
type MarkerContentProps = ComponentProps<"span">;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @since 0.5.0-canary.3
|
|
75
|
+
*/
|
|
76
|
+
function MarkerContent({ className, ...props }: MarkerContentProps): JSX.Element {
|
|
77
|
+
return (
|
|
78
|
+
<span
|
|
79
|
+
className={cn(
|
|
80
|
+
"min-w-0 wrap-break-word group-data-[variant=separator]/marker:flex-none group-data-[variant=separator]/marker:text-center *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
|
81
|
+
className,
|
|
82
|
+
)}
|
|
83
|
+
data-slot="marker-content"
|
|
84
|
+
{...props}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* -----------------------------------------------------------------------------
|
|
90
|
+
* Exports
|
|
91
|
+
* -------------------------------------------------------------------------- */
|
|
92
|
+
|
|
93
|
+
export { Marker, MarkerContent, MarkerIcon };
|
|
94
|
+
export type { MarkerContentProps, MarkerIconProps, MarkerProps };
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { ArrowDownIcon } from "lucide-react";
|
|
2
|
+
import type { ComponentProps, JSX } from "react";
|
|
3
|
+
|
|
4
|
+
import { Button } from "#/components/button";
|
|
5
|
+
import { cn } from "#/lib/utils";
|
|
6
|
+
import {
|
|
7
|
+
MessageScroller as MessageScrollerPrimitive,
|
|
8
|
+
MessageScrollerButton as MessageScrollerButtonPrimitive,
|
|
9
|
+
MessageScrollerContent as MessageScrollerContentPrimitive,
|
|
10
|
+
MessageScrollerItem as MessageScrollerItemPrimitive,
|
|
11
|
+
MessageScrollerProvider as MessageScrollerProviderPrimitive,
|
|
12
|
+
MessageScrollerViewport as MessageScrollerViewportPrimitive,
|
|
13
|
+
useMessageScroller,
|
|
14
|
+
useMessageScrollerScrollable,
|
|
15
|
+
useMessageScrollerVisibility,
|
|
16
|
+
} from "#/primitives/message-scroller";
|
|
17
|
+
|
|
18
|
+
/* -----------------------------------------------------------------------------
|
|
19
|
+
* Component: MessageScrollerProvider
|
|
20
|
+
* -------------------------------------------------------------------------- */
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Owns scroll behavior for a transcript. Renders no DOM; wrap the frame.
|
|
24
|
+
*
|
|
25
|
+
* @since 0.5.0-canary.3
|
|
26
|
+
*/
|
|
27
|
+
type MessageScrollerProviderProps = ComponentProps<typeof MessageScrollerProviderPrimitive>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @since 0.5.0-canary.3
|
|
31
|
+
*/
|
|
32
|
+
function MessageScrollerProvider(props: MessageScrollerProviderProps): JSX.Element {
|
|
33
|
+
return <MessageScrollerProviderPrimitive {...props} />;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* -----------------------------------------------------------------------------
|
|
37
|
+
* Component: MessageScroller
|
|
38
|
+
* -------------------------------------------------------------------------- */
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Frame for a chat transcript scroller; must sit inside a provider.
|
|
42
|
+
*
|
|
43
|
+
* @since 0.5.0-canary.3
|
|
44
|
+
*/
|
|
45
|
+
type MessageScrollerProps = ComponentProps<typeof MessageScrollerPrimitive>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @since 0.5.0-canary.3
|
|
49
|
+
*/
|
|
50
|
+
function MessageScroller({ className, ...props }: MessageScrollerProps): JSX.Element {
|
|
51
|
+
return (
|
|
52
|
+
<MessageScrollerPrimitive
|
|
53
|
+
className={cn("group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden", className)}
|
|
54
|
+
data-slot="message-scroller"
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* -----------------------------------------------------------------------------
|
|
61
|
+
* Component: MessageScrollerViewport
|
|
62
|
+
* -------------------------------------------------------------------------- */
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Scrollable viewport; fades its bottom edge and hides the bar while autoscrolling.
|
|
66
|
+
*
|
|
67
|
+
* @since 0.5.0-canary.3
|
|
68
|
+
*/
|
|
69
|
+
type MessageScrollerViewportProps = ComponentProps<typeof MessageScrollerViewportPrimitive>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @since 0.5.0-canary.3
|
|
73
|
+
*/
|
|
74
|
+
function MessageScrollerViewport({ className, ...props }: MessageScrollerViewportProps): JSX.Element {
|
|
75
|
+
return (
|
|
76
|
+
<MessageScrollerViewportPrimitive
|
|
77
|
+
className={cn(
|
|
78
|
+
"size-full min-h-0 min-w-0 scroll-fade-b scrollbar-thin scrollbar-gutter-stable overflow-y-auto overscroll-contain contain-content data-autoscrolling:scrollbar-thumb-transparent data-autoscrolling:scrollbar-track-transparent",
|
|
79
|
+
className,
|
|
80
|
+
)}
|
|
81
|
+
data-slot="message-scroller-viewport"
|
|
82
|
+
{...props}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* -----------------------------------------------------------------------------
|
|
88
|
+
* Component: MessageScrollerContent
|
|
89
|
+
* -------------------------------------------------------------------------- */
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Column holding the transcript rows.
|
|
93
|
+
*
|
|
94
|
+
* @since 0.5.0-canary.3
|
|
95
|
+
*/
|
|
96
|
+
type MessageScrollerContentProps = ComponentProps<typeof MessageScrollerContentPrimitive>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @since 0.5.0-canary.3
|
|
100
|
+
*/
|
|
101
|
+
function MessageScrollerContent({ className, ...props }: MessageScrollerContentProps): JSX.Element {
|
|
102
|
+
return (
|
|
103
|
+
<MessageScrollerContentPrimitive
|
|
104
|
+
className={cn("flex h-max min-h-full flex-col gap-6", className)}
|
|
105
|
+
data-slot="message-scroller-content"
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* -----------------------------------------------------------------------------
|
|
112
|
+
* Component: MessageScrollerItem
|
|
113
|
+
* -------------------------------------------------------------------------- */
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* One transcript row; opts into content-visibility for long feeds.
|
|
117
|
+
*
|
|
118
|
+
* @since 0.5.0-canary.3
|
|
119
|
+
*/
|
|
120
|
+
type MessageScrollerItemProps = ComponentProps<typeof MessageScrollerItemPrimitive>;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @since 0.5.0-canary.3
|
|
124
|
+
*/
|
|
125
|
+
function MessageScrollerItem({ className, scrollAnchor = false, ...props }: MessageScrollerItemProps): JSX.Element {
|
|
126
|
+
return (
|
|
127
|
+
<MessageScrollerItemPrimitive
|
|
128
|
+
className={cn("min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]", className)}
|
|
129
|
+
data-slot="message-scroller-item"
|
|
130
|
+
scrollAnchor={scrollAnchor}
|
|
131
|
+
{...props}
|
|
132
|
+
/>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* -----------------------------------------------------------------------------
|
|
137
|
+
* Component: MessageScrollerButton
|
|
138
|
+
* -------------------------------------------------------------------------- */
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Scroll-to-edge control; hides itself when there is no overflow that way.
|
|
142
|
+
*
|
|
143
|
+
* @since 0.5.0-canary.3
|
|
144
|
+
*/
|
|
145
|
+
type MessageScrollerButtonProps = ComponentProps<typeof MessageScrollerButtonPrimitive> &
|
|
146
|
+
Pick<ComponentProps<typeof Button>, "size" | "variant">;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @since 0.5.0-canary.3
|
|
150
|
+
*/
|
|
151
|
+
function MessageScrollerButton({
|
|
152
|
+
children,
|
|
153
|
+
className,
|
|
154
|
+
direction = "end",
|
|
155
|
+
render,
|
|
156
|
+
size = "icon-sm",
|
|
157
|
+
variant = "secondary",
|
|
158
|
+
...props
|
|
159
|
+
}: MessageScrollerButtonProps): JSX.Element {
|
|
160
|
+
return (
|
|
161
|
+
<MessageScrollerButtonPrimitive
|
|
162
|
+
className={cn(
|
|
163
|
+
"absolute inset-s-1/2 -translate-x-1/2 border-border bg-background text-foreground transition-[translate,scale,opacity] duration-200 hover:bg-muted hover:text-foreground data-[active=false]:pointer-events-none data-[active=false]:scale-95 data-[active=false]:opacity-0 data-[active=false]:duration-400 data-[active=false]:ease-[cubic-bezier(0.7,0,0.84,0)] data-[active=true]:translate-y-0 data-[active=true]:scale-100 data-[active=true]:opacity-100 data-[active=true]:ease-[cubic-bezier(0.23,1,0.32,1)] data-[direction=end]:bottom-4 data-[direction=end]:data-[active=false]:translate-y-full data-[direction=start]:top-4 data-[direction=start]:data-[active=false]:-translate-y-full rtl:translate-x-1/2 data-[direction=start]:[&_svg]:rotate-180",
|
|
164
|
+
className,
|
|
165
|
+
)}
|
|
166
|
+
data-direction={direction}
|
|
167
|
+
data-size={size}
|
|
168
|
+
data-slot="message-scroller-button"
|
|
169
|
+
data-variant={variant}
|
|
170
|
+
direction={direction}
|
|
171
|
+
render={render ?? <Button size={size} variant={variant} />}
|
|
172
|
+
{...props}
|
|
173
|
+
>
|
|
174
|
+
{children ?? (
|
|
175
|
+
<>
|
|
176
|
+
<ArrowDownIcon />
|
|
177
|
+
<span className="sr-only">{direction === "end" ? "Scroll to end" : "Scroll to start"}</span>
|
|
178
|
+
</>
|
|
179
|
+
)}
|
|
180
|
+
</MessageScrollerButtonPrimitive>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* -----------------------------------------------------------------------------
|
|
185
|
+
* Exports
|
|
186
|
+
* -------------------------------------------------------------------------- */
|
|
187
|
+
|
|
188
|
+
export {
|
|
189
|
+
MessageScroller,
|
|
190
|
+
MessageScrollerButton,
|
|
191
|
+
MessageScrollerContent,
|
|
192
|
+
MessageScrollerItem,
|
|
193
|
+
MessageScrollerProvider,
|
|
194
|
+
MessageScrollerViewport,
|
|
195
|
+
useMessageScroller,
|
|
196
|
+
useMessageScrollerScrollable,
|
|
197
|
+
useMessageScrollerVisibility,
|
|
198
|
+
};
|
|
199
|
+
export type {
|
|
200
|
+
MessageScrollerButtonProps,
|
|
201
|
+
MessageScrollerContentProps,
|
|
202
|
+
MessageScrollerItemProps,
|
|
203
|
+
MessageScrollerProps,
|
|
204
|
+
MessageScrollerProviderProps,
|
|
205
|
+
MessageScrollerViewportProps,
|
|
206
|
+
};
|
|
207
|
+
export type {
|
|
208
|
+
MessageScrollerDefaultScrollPosition,
|
|
209
|
+
MessageScrollerScrollAlign,
|
|
210
|
+
MessageScrollerScrollable,
|
|
211
|
+
MessageScrollerScrollOptions,
|
|
212
|
+
MessageScrollerVisibilityState,
|
|
213
|
+
} from "#/lib/message-scroller/types";
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { ComponentProps, JSX } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "#/lib/utils";
|
|
4
|
+
|
|
5
|
+
/* -----------------------------------------------------------------------------
|
|
6
|
+
* Component: MessageGroup
|
|
7
|
+
* -------------------------------------------------------------------------- */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Vertical stack of related messages.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.5.0-canary.3
|
|
13
|
+
*/
|
|
14
|
+
type MessageGroupProps = ComponentProps<"div">;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @since 0.5.0-canary.3
|
|
18
|
+
*/
|
|
19
|
+
function MessageGroup({ className, ...props }: MessageGroupProps): JSX.Element {
|
|
20
|
+
return <div className={cn("flex min-w-0 flex-col gap-2", className)} data-slot="message-group" {...props} />;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* -----------------------------------------------------------------------------
|
|
24
|
+
* Component: Message
|
|
25
|
+
* -------------------------------------------------------------------------- */
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A single message row. `align="end"` mirrors the row for the current author.
|
|
29
|
+
*
|
|
30
|
+
* @since 0.5.0-canary.3
|
|
31
|
+
*/
|
|
32
|
+
interface MessageProps extends ComponentProps<"div"> {
|
|
33
|
+
align?: "start" | "end";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @since 0.5.0-canary.3
|
|
38
|
+
*/
|
|
39
|
+
function Message({ align = "start", className, ...props }: MessageProps): JSX.Element {
|
|
40
|
+
return (
|
|
41
|
+
<div
|
|
42
|
+
className={cn(
|
|
43
|
+
"group/message relative flex w-full min-w-0 gap-2 text-sm data-[align=end]:flex-row-reverse",
|
|
44
|
+
className,
|
|
45
|
+
)}
|
|
46
|
+
data-align={align}
|
|
47
|
+
data-slot="message"
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* -----------------------------------------------------------------------------
|
|
54
|
+
* Component: MessageAvatar
|
|
55
|
+
* -------------------------------------------------------------------------- */
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Author avatar; lifts above the footer when a message footer is present.
|
|
59
|
+
*
|
|
60
|
+
* @since 0.5.0-canary.3
|
|
61
|
+
*/
|
|
62
|
+
type MessageAvatarProps = ComponentProps<"div">;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @since 0.5.0-canary.3
|
|
66
|
+
*/
|
|
67
|
+
function MessageAvatar({ className, ...props }: MessageAvatarProps): JSX.Element {
|
|
68
|
+
return (
|
|
69
|
+
<div
|
|
70
|
+
className={cn(
|
|
71
|
+
"flex w-fit min-w-8 shrink-0 items-center justify-center self-end overflow-hidden rounded-full bg-muted group-has-data-[slot=message-footer]/message:-translate-y-8",
|
|
72
|
+
className,
|
|
73
|
+
)}
|
|
74
|
+
data-slot="message-avatar"
|
|
75
|
+
{...props}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* -----------------------------------------------------------------------------
|
|
81
|
+
* Component: MessageContent
|
|
82
|
+
* -------------------------------------------------------------------------- */
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Column holding the message bubbles and metadata.
|
|
86
|
+
*
|
|
87
|
+
* @since 0.5.0-canary.3
|
|
88
|
+
*/
|
|
89
|
+
type MessageContentProps = ComponentProps<"div">;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @since 0.5.0-canary.3
|
|
93
|
+
*/
|
|
94
|
+
function MessageContent({ className, ...props }: MessageContentProps): JSX.Element {
|
|
95
|
+
return (
|
|
96
|
+
<div
|
|
97
|
+
className={cn(
|
|
98
|
+
"flex w-full min-w-0 flex-col gap-2.5 wrap-break-word group-data-[align=end]/message:*:data-slot:self-end",
|
|
99
|
+
className,
|
|
100
|
+
)}
|
|
101
|
+
data-slot="message-content"
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* -----------------------------------------------------------------------------
|
|
108
|
+
* Component: MessageHeader
|
|
109
|
+
* -------------------------------------------------------------------------- */
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Metadata above the bubbles (author, timestamp).
|
|
113
|
+
*
|
|
114
|
+
* @since 0.5.0-canary.3
|
|
115
|
+
*/
|
|
116
|
+
type MessageHeaderProps = ComponentProps<"div">;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @since 0.5.0-canary.3
|
|
120
|
+
*/
|
|
121
|
+
function MessageHeader({ className, ...props }: MessageHeaderProps): JSX.Element {
|
|
122
|
+
return (
|
|
123
|
+
<div
|
|
124
|
+
className={cn(
|
|
125
|
+
"flex max-w-full min-w-0 items-center px-3 text-xs font-medium text-muted-foreground group-has-data-[variant=ghost]/message:px-0",
|
|
126
|
+
className,
|
|
127
|
+
)}
|
|
128
|
+
data-slot="message-header"
|
|
129
|
+
{...props}
|
|
130
|
+
/>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* -----------------------------------------------------------------------------
|
|
135
|
+
* Component: MessageFooter
|
|
136
|
+
* -------------------------------------------------------------------------- */
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Metadata below the bubbles (status, reactions); aligns with the row.
|
|
140
|
+
*
|
|
141
|
+
* @since 0.5.0-canary.3
|
|
142
|
+
*/
|
|
143
|
+
type MessageFooterProps = ComponentProps<"div">;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @since 0.5.0-canary.3
|
|
147
|
+
*/
|
|
148
|
+
function MessageFooter({ className, ...props }: MessageFooterProps): JSX.Element {
|
|
149
|
+
return (
|
|
150
|
+
<div
|
|
151
|
+
className={cn(
|
|
152
|
+
"flex max-w-full min-w-0 items-center px-3 text-xs font-medium text-muted-foreground group-has-data-[variant=ghost]/message:px-0 group-data-[align=end]/message:justify-end",
|
|
153
|
+
className,
|
|
154
|
+
)}
|
|
155
|
+
data-slot="message-footer"
|
|
156
|
+
{...props}
|
|
157
|
+
/>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/* -----------------------------------------------------------------------------
|
|
162
|
+
* Exports
|
|
163
|
+
* -------------------------------------------------------------------------- */
|
|
164
|
+
|
|
165
|
+
export { Message, MessageAvatar, MessageContent, MessageFooter, MessageGroup, MessageHeader };
|
|
166
|
+
export type {
|
|
167
|
+
MessageAvatarProps,
|
|
168
|
+
MessageContentProps,
|
|
169
|
+
MessageFooterProps,
|
|
170
|
+
MessageGroupProps,
|
|
171
|
+
MessageHeaderProps,
|
|
172
|
+
MessageProps,
|
|
173
|
+
};
|
|
@@ -2,7 +2,7 @@ import { PanelLeftIcon } from "lucide-react";
|
|
|
2
2
|
import { Slot } from "radix-ui";
|
|
3
3
|
import { Context } from "radix-ui/internal";
|
|
4
4
|
import type { ComponentProps, CSSProperties, Dispatch, JSX, SetStateAction } from "react";
|
|
5
|
-
import { useCallback, useEffect, useState } from "react";
|
|
5
|
+
import { useCallback, useEffect, useId, useState } from "react";
|
|
6
6
|
|
|
7
7
|
import { Button } from "#/components/button";
|
|
8
8
|
import { Input } from "#/components/input";
|
|
@@ -310,7 +310,7 @@ function SidebarRail({ className, ...props }: SidebarRailProps): JSX.Element {
|
|
|
310
310
|
return (
|
|
311
311
|
<button
|
|
312
312
|
className={cn(
|
|
313
|
-
"absolute inset-y-0 z-20 hidden w-4 transition-all ease-gentle group-data-[collapsible=offcanvas]:translate-x-0 group-data-side-right:left-0 group-data-side-left:-right-4 after:absolute after:inset-y-0 after:inset-s-1/2 after:w-0.5 group-data-[collapsible=offcanvas]:after:
|
|
313
|
+
"absolute inset-y-0 z-20 hidden w-4 transition-all ease-gentle group-data-[collapsible=offcanvas]:translate-x-0 group-data-side-right:left-0 group-data-side-left:-right-4 after:absolute after:inset-y-0 after:inset-s-1/2 after:w-0.5 group-data-[collapsible=offcanvas]:after:start-full hover:group-data-[collapsible=offcanvas]:bg-sidebar hover:after:bg-sidebar-border in-data-side-right:cursor-e-resize in-data-side-left:cursor-w-resize sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2 rtl:group-data-[collapsible=offcanvas]:translate-x-0 rtl:in-data-side-right:cursor-w-resize rtl:in-data-side-left:cursor-e-resize [[data-side=left][data-collapsible=offcanvas]_&]:-right-2 [[data-side=left][data-state=collapsed]_&]:cursor-e-resize rtl:[[data-side=left][data-state=collapsed]_&]:cursor-w-resize [[data-side=right][data-collapsible=offcanvas]_&]:-left-2 [[data-side=right][data-state=collapsed]_&]:cursor-w-resize rtl:[[data-side=right][data-state=collapsed]_&]:cursor-e-resize",
|
|
314
314
|
className,
|
|
315
315
|
)}
|
|
316
316
|
data-sidebar="rail"
|
|
@@ -756,8 +756,15 @@ interface SidebarMenuSkeletonProps extends ComponentProps<"div"> {
|
|
|
756
756
|
* @since 0.3.16-canary.0
|
|
757
757
|
*/
|
|
758
758
|
function SidebarMenuSkeleton({ className, showIcon = false, ...props }: SidebarMenuSkeletonProps): JSX.Element {
|
|
759
|
-
//
|
|
760
|
-
const
|
|
759
|
+
// Varied width in 50–90%, derived from a stable useId so it matches across SSR and client (no hydration mismatch).
|
|
760
|
+
const id = useId();
|
|
761
|
+
let sum = 0;
|
|
762
|
+
|
|
763
|
+
for (const char of id) {
|
|
764
|
+
sum += char.codePointAt(0) ?? 0;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
const width = `${String((sum % 41) + 50)}%`;
|
|
761
768
|
|
|
762
769
|
return (
|
|
763
770
|
<div
|
|
@@ -15,9 +15,12 @@
|
|
|
15
15
|
* Typography
|
|
16
16
|
* ---------------------------------------------------------------------- */
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
/* Bridge the app-owned raw vars into the font-* utilities; fall back to sane
|
|
19
|
+
stacks so a consumer that forgets one degrades gracefully instead of
|
|
20
|
+
silently inheriting the sans font. */
|
|
21
|
+
--font-sans: var(--font-sans, ui-sans-serif, system-ui, sans-serif);
|
|
22
|
+
--font-heading: var(--font-heading, var(--font-sans, ui-sans-serif, system-ui, sans-serif));
|
|
23
|
+
--font-mono: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
|
|
21
24
|
|
|
22
25
|
/* ----------------------------------------------------------------------
|
|
23
26
|
* Surfaces & semantic colors
|
|
@@ -77,21 +80,6 @@
|
|
|
77
80
|
--color-chart-4: var(--chart-4);
|
|
78
81
|
--color-chart-5: var(--chart-5);
|
|
79
82
|
|
|
80
|
-
/* ----------------------------------------------------------------------
|
|
81
|
-
* Code & selection
|
|
82
|
-
* ---------------------------------------------------------------------- */
|
|
83
|
-
|
|
84
|
-
--color-surface: var(--surface);
|
|
85
|
-
--color-surface-foreground: var(--surface-foreground);
|
|
86
|
-
|
|
87
|
-
--color-code: var(--code);
|
|
88
|
-
--color-code-foreground: var(--code-foreground);
|
|
89
|
-
--color-code-highlight: var(--code-highlight);
|
|
90
|
-
--color-code-number: var(--code-number);
|
|
91
|
-
|
|
92
|
-
--color-selection: var(--selection);
|
|
93
|
-
--color-selection-foreground: var(--selection-foreground);
|
|
94
|
-
|
|
95
83
|
/* ----------------------------------------------------------------------
|
|
96
84
|
* Radius scale — derived from --radius (6 = base unit)
|
|
97
85
|
* ---------------------------------------------------------------------- */
|