@codefast/ui 0.5.0-canary.2 → 0.5.0-canary.4
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 +51 -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/breadcrumb.d.mts +2 -4
- 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/progress-circle.d.mts +4 -4
- package/dist/components/progress-circle.mjs +7 -7
- package/dist/components/sidebar.mjs +6 -3
- package/dist/hooks/use-animated-value.d.mts +2 -2
- package/dist/hooks/use-animated-value.mjs +4 -4
- 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/hooks/use-pagination.d.mts +4 -4
- package/dist/hooks/use-pagination.mjs +1 -1
- package/dist/index.d.mts +12 -2
- 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 +93 -7
- package/src/components/attachment.tsx +284 -0
- package/src/components/avatar.tsx +1 -1
- package/src/components/breadcrumb.tsx +2 -4
- 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/progress-circle.tsx +11 -11
- 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-animated-value.ts +4 -4
- package/src/hooks/use-message-scroller-commands.ts +311 -0
- package/src/hooks/use-message-scroller-controller.ts +650 -0
- package/src/hooks/use-message-scroller-refs.ts +167 -0
- package/src/hooks/use-pagination.ts +3 -3
- package/src/index.ts +73 -1
- package/src/lib/message-scroller/geometry.ts +397 -0
- package/src/lib/message-scroller/stores.ts +88 -0
- package/src/lib/message-scroller/types.ts +309 -0
- package/src/lib/message-scroller/utils.ts +14 -0
- package/src/lib/use-render.ts +201 -0
- package/src/primitives/message-scroller.tsx +403 -0
- package/src/variants/attachment.ts +73 -0
- package/src/variants/bubble.ts +81 -0
- package/src/variants/marker.ts +38 -0
|
@@ -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, isScrollAnchor = 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
|
+
isScrollAnchor={isScrollAnchor}
|
|
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
|
+
};
|
|
@@ -18,7 +18,7 @@ interface ProgressCircleProps
|
|
|
18
18
|
/**
|
|
19
19
|
* Enables animation effect when value changes
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
animated?: boolean;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Duration of the animation in milliseconds
|
|
@@ -65,7 +65,7 @@ interface ProgressCircleProps
|
|
|
65
65
|
* @param value - Current value of the component
|
|
66
66
|
* @returns React element to display in the center of the circle
|
|
67
67
|
*/
|
|
68
|
-
|
|
68
|
+
renderLabel?: ({ value }: { value: number }) => JSX.Element;
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Display the numeric value in the center of the circle
|
|
@@ -83,11 +83,11 @@ interface ProgressCircleProps
|
|
|
83
83
|
* @since 0.3.16-canary.0
|
|
84
84
|
*/
|
|
85
85
|
function ProgressCircle({
|
|
86
|
-
|
|
86
|
+
animated = true,
|
|
87
87
|
animationDuration = 1000,
|
|
88
88
|
className,
|
|
89
89
|
classNames,
|
|
90
|
-
|
|
90
|
+
renderLabel,
|
|
91
91
|
showValue = false,
|
|
92
92
|
size,
|
|
93
93
|
sizeInPixels,
|
|
@@ -97,7 +97,7 @@ function ProgressCircle({
|
|
|
97
97
|
variant = "default",
|
|
98
98
|
...props
|
|
99
99
|
}: ProgressCircleProps): JSX.Element {
|
|
100
|
-
const displayValue = useAnimatedValue(value, animationDuration,
|
|
100
|
+
const displayValue = useAnimatedValue(value, animationDuration, animated);
|
|
101
101
|
|
|
102
102
|
const actualSize = useMemo(() => sizeInPixels ?? getActualSize(size), [sizeInPixels, size]);
|
|
103
103
|
|
|
@@ -108,15 +108,15 @@ function ProgressCircle({
|
|
|
108
108
|
|
|
109
109
|
const slots = useMemo(() => progressCircleVariants({ size, thickness, variant }), [variant, size, thickness]);
|
|
110
110
|
|
|
111
|
-
const shouldShowLabel = showValue || Boolean(
|
|
111
|
+
const shouldShowLabel = showValue || Boolean(renderLabel);
|
|
112
112
|
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
115
|
-
return
|
|
113
|
+
const labelContent = useCallback(() => {
|
|
114
|
+
if (renderLabel) {
|
|
115
|
+
return renderLabel({ value: displayValue });
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
return `${displayValue.toString()}%`;
|
|
119
|
-
}, [
|
|
119
|
+
}, [renderLabel, displayValue]);
|
|
120
120
|
|
|
121
121
|
return (
|
|
122
122
|
<ProgressCirclePrimitive.Provider size={actualSize} strokeWidth={actualThickness} value={value} {...props}>
|
|
@@ -135,7 +135,7 @@ function ProgressCircle({
|
|
|
135
135
|
</ProgressCirclePrimitive.SVG>
|
|
136
136
|
{shouldShowLabel ? (
|
|
137
137
|
<ProgressCirclePrimitive.Value className={slots.label({ className: classNames?.label })}>
|
|
138
|
-
{
|
|
138
|
+
{labelContent()}
|
|
139
139
|
</ProgressCirclePrimitive.Value>
|
|
140
140
|
) : null}
|
|
141
141
|
</ProgressCirclePrimitive.Root>
|
|
@@ -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
|
* ---------------------------------------------------------------------- */
|