@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.
Files changed (80) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/components/attachment.d.mts +136 -0
  3. package/dist/components/attachment.mjs +112 -0
  4. package/dist/components/avatar.mjs +1 -1
  5. package/dist/components/breadcrumb.d.mts +2 -4
  6. package/dist/components/bubble.d.mts +67 -0
  7. package/dist/components/bubble.mjs +58 -0
  8. package/dist/components/card.mjs +2 -2
  9. package/dist/components/carousel.mjs +12 -3
  10. package/dist/components/empty.mjs +1 -1
  11. package/dist/components/marker.d.mts +49 -0
  12. package/dist/components/marker.mjs +42 -0
  13. package/dist/components/message-scroller.d.mts +89 -0
  14. package/dist/components/message-scroller.mjs +77 -0
  15. package/dist/components/message.d.mts +86 -0
  16. package/dist/components/message.mjs +66 -0
  17. package/dist/components/progress-circle.d.mts +4 -4
  18. package/dist/components/progress-circle.mjs +7 -7
  19. package/dist/components/sidebar.mjs +6 -3
  20. package/dist/hooks/use-animated-value.d.mts +2 -2
  21. package/dist/hooks/use-animated-value.mjs +4 -4
  22. package/dist/hooks/use-message-scroller-commands.d.mts +39 -0
  23. package/dist/hooks/use-message-scroller-commands.mjs +165 -0
  24. package/dist/hooks/use-message-scroller-controller.d.mts +19 -0
  25. package/dist/hooks/use-message-scroller-controller.mjs +382 -0
  26. package/dist/hooks/use-message-scroller-refs.d.mts +60 -0
  27. package/dist/hooks/use-message-scroller-refs.mjs +77 -0
  28. package/dist/hooks/use-pagination.d.mts +4 -4
  29. package/dist/hooks/use-pagination.mjs +1 -1
  30. package/dist/index.d.mts +12 -2
  31. package/dist/index.mjs +11 -2
  32. package/dist/lib/message-scroller/geometry.d.mts +136 -0
  33. package/dist/lib/message-scroller/geometry.mjs +199 -0
  34. package/dist/lib/message-scroller/stores.d.mts +21 -0
  35. package/dist/lib/message-scroller/stores.mjs +52 -0
  36. package/dist/lib/message-scroller/types.d.mts +171 -0
  37. package/dist/lib/message-scroller/types.mjs +53 -0
  38. package/dist/lib/message-scroller/utils.d.mts +7 -0
  39. package/dist/lib/message-scroller/utils.mjs +12 -0
  40. package/dist/lib/use-render.d.mts +43 -0
  41. package/dist/lib/use-render.mjs +84 -0
  42. package/dist/primitives/message-scroller.d.mts +88 -0
  43. package/dist/primitives/message-scroller.mjs +240 -0
  44. package/dist/variants/attachment.d.mts +42 -0
  45. package/dist/variants/attachment.mjs +42 -0
  46. package/dist/variants/bubble.d.mts +45 -0
  47. package/dist/variants/bubble.mjs +45 -0
  48. package/dist/variants/marker.d.mts +21 -0
  49. package/dist/variants/marker.mjs +18 -0
  50. package/package.json +93 -7
  51. package/src/components/attachment.tsx +284 -0
  52. package/src/components/avatar.tsx +1 -1
  53. package/src/components/breadcrumb.tsx +2 -4
  54. package/src/components/bubble.tsx +116 -0
  55. package/src/components/card.tsx +2 -2
  56. package/src/components/carousel.tsx +12 -3
  57. package/src/components/empty.tsx +1 -1
  58. package/src/components/marker.tsx +94 -0
  59. package/src/components/message-scroller.tsx +213 -0
  60. package/src/components/message.tsx +173 -0
  61. package/src/components/progress-circle.tsx +11 -11
  62. package/src/components/sidebar.tsx +11 -4
  63. package/src/css/foundation/tokens.css +6 -18
  64. package/src/css/foundation/utilities.css +451 -0
  65. package/src/css/preset.css +2 -1
  66. package/src/hooks/use-animated-value.ts +4 -4
  67. package/src/hooks/use-message-scroller-commands.ts +311 -0
  68. package/src/hooks/use-message-scroller-controller.ts +650 -0
  69. package/src/hooks/use-message-scroller-refs.ts +167 -0
  70. package/src/hooks/use-pagination.ts +3 -3
  71. package/src/index.ts +73 -1
  72. package/src/lib/message-scroller/geometry.ts +397 -0
  73. package/src/lib/message-scroller/stores.ts +88 -0
  74. package/src/lib/message-scroller/types.ts +309 -0
  75. package/src/lib/message-scroller/utils.ts +14 -0
  76. package/src/lib/use-render.ts +201 -0
  77. package/src/primitives/message-scroller.tsx +403 -0
  78. package/src/variants/attachment.ts +73 -0
  79. package/src/variants/bubble.ts +81 -0
  80. package/src/variants/marker.ts +38 -0
@@ -0,0 +1,284 @@
1
+ import { Slot } from "radix-ui";
2
+ import type { ComponentProps, JSX } from "react";
3
+
4
+ import { Button } from "#/components/button";
5
+ import { cn } from "#/lib/utils";
6
+ import type { AttachmentMediaVariants, AttachmentVariants } from "#/variants/attachment";
7
+ import { attachmentMediaVariants, attachmentVariants } from "#/variants/attachment";
8
+
9
+ /* -----------------------------------------------------------------------------
10
+ * Component: Attachment
11
+ * -------------------------------------------------------------------------- */
12
+
13
+ /**
14
+ * File/media attachment card. `state` drives the upload lifecycle styling.
15
+ *
16
+ * @since 0.5.0-canary.3
17
+ */
18
+ interface AttachmentProps extends ComponentProps<"div">, AttachmentVariants {
19
+ state?: "idle" | "uploading" | "processing" | "error" | "done";
20
+ }
21
+
22
+ /**
23
+ * @since 0.5.0-canary.3
24
+ */
25
+ function Attachment({
26
+ className,
27
+ orientation = "horizontal",
28
+ size = "default",
29
+ state = "done",
30
+ ...props
31
+ }: AttachmentProps): JSX.Element {
32
+ return (
33
+ <div
34
+ className={attachmentVariants({ className, orientation, size })}
35
+ data-orientation={orientation}
36
+ data-size={size}
37
+ data-slot="attachment"
38
+ data-state={state}
39
+ {...props}
40
+ />
41
+ );
42
+ }
43
+
44
+ /* -----------------------------------------------------------------------------
45
+ * Component: AttachmentMedia
46
+ * -------------------------------------------------------------------------- */
47
+
48
+ /**
49
+ * Thumbnail slot — an icon tile or a cover image.
50
+ *
51
+ * @since 0.5.0-canary.3
52
+ */
53
+ interface AttachmentMediaProps extends ComponentProps<"div">, AttachmentMediaVariants {}
54
+
55
+ /**
56
+ * @since 0.5.0-canary.3
57
+ */
58
+ function AttachmentMedia({ className, variant = "icon", ...props }: AttachmentMediaProps): JSX.Element {
59
+ return (
60
+ <div
61
+ className={attachmentMediaVariants({ className, variant })}
62
+ data-slot="attachment-media"
63
+ data-variant={variant}
64
+ {...props}
65
+ />
66
+ );
67
+ }
68
+
69
+ /* -----------------------------------------------------------------------------
70
+ * Component: AttachmentContent
71
+ * -------------------------------------------------------------------------- */
72
+
73
+ /**
74
+ * Text column holding the title and description.
75
+ *
76
+ * @since 0.5.0-canary.3
77
+ */
78
+ type AttachmentContentProps = ComponentProps<"div">;
79
+
80
+ /**
81
+ * @since 0.5.0-canary.3
82
+ */
83
+ function AttachmentContent({ className, ...props }: AttachmentContentProps): JSX.Element {
84
+ return (
85
+ <div
86
+ className={cn(
87
+ "max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1",
88
+ className,
89
+ )}
90
+ data-slot="attachment-content"
91
+ {...props}
92
+ />
93
+ );
94
+ }
95
+
96
+ /* -----------------------------------------------------------------------------
97
+ * Component: AttachmentTitle
98
+ * -------------------------------------------------------------------------- */
99
+
100
+ /**
101
+ * File name; shimmers while uploading or processing.
102
+ *
103
+ * @since 0.5.0-canary.3
104
+ */
105
+ type AttachmentTitleProps = ComponentProps<"span">;
106
+
107
+ /**
108
+ * @since 0.5.0-canary.3
109
+ */
110
+ function AttachmentTitle({ className, ...props }: AttachmentTitleProps): JSX.Element {
111
+ return (
112
+ <span
113
+ className={cn(
114
+ "block max-w-full min-w-0 truncate font-medium group-data-[state=processing]/attachment:shimmer group-data-[state=uploading]/attachment:shimmer",
115
+ className,
116
+ )}
117
+ data-slot="attachment-title"
118
+ {...props}
119
+ />
120
+ );
121
+ }
122
+
123
+ /* -----------------------------------------------------------------------------
124
+ * Component: AttachmentDescription
125
+ * -------------------------------------------------------------------------- */
126
+
127
+ /**
128
+ * Secondary line (size, type); turns destructive on error.
129
+ *
130
+ * @since 0.5.0-canary.3
131
+ */
132
+ type AttachmentDescriptionProps = ComponentProps<"span">;
133
+
134
+ /**
135
+ * @since 0.5.0-canary.3
136
+ */
137
+ function AttachmentDescription({ className, ...props }: AttachmentDescriptionProps): JSX.Element {
138
+ return (
139
+ <span
140
+ className={cn(
141
+ "mt-0.5 block max-w-full min-w-0 truncate text-xs text-muted-foreground group-data-[state=error]/attachment:text-destructive/80",
142
+ className,
143
+ )}
144
+ data-slot="attachment-description"
145
+ {...props}
146
+ />
147
+ );
148
+ }
149
+
150
+ /* -----------------------------------------------------------------------------
151
+ * Component: AttachmentActions
152
+ * -------------------------------------------------------------------------- */
153
+
154
+ /**
155
+ * Action cluster; floats to the top corner in the vertical orientation.
156
+ *
157
+ * @since 0.5.0-canary.3
158
+ */
159
+ type AttachmentActionsProps = ComponentProps<"div">;
160
+
161
+ /**
162
+ * @since 0.5.0-canary.3
163
+ */
164
+ function AttachmentActions({ className, ...props }: AttachmentActionsProps): JSX.Element {
165
+ return (
166
+ <div
167
+ className={cn(
168
+ "relative z-20 flex shrink-0 items-center group-data-[orientation=vertical]/attachment:absolute group-data-[orientation=vertical]/attachment:end-3 group-data-[orientation=vertical]/attachment:top-3 group-data-[orientation=vertical]/attachment:gap-1",
169
+ className,
170
+ )}
171
+ data-slot="attachment-actions"
172
+ {...props}
173
+ />
174
+ );
175
+ }
176
+
177
+ /* -----------------------------------------------------------------------------
178
+ * Component: AttachmentAction
179
+ * -------------------------------------------------------------------------- */
180
+
181
+ /**
182
+ * A single action button; defaults to a ghost icon button.
183
+ *
184
+ * @since 0.5.0-canary.3
185
+ */
186
+ interface AttachmentActionProps extends ComponentProps<typeof Button> {}
187
+
188
+ /**
189
+ * @since 0.5.0-canary.3
190
+ */
191
+ function AttachmentAction({ className, size = "icon-xs", variant, ...props }: AttachmentActionProps): JSX.Element {
192
+ return (
193
+ <Button
194
+ className={cn(className)}
195
+ data-slot="attachment-action"
196
+ size={size}
197
+ variant={variant ?? "ghost"}
198
+ {...props}
199
+ />
200
+ );
201
+ }
202
+
203
+ /* -----------------------------------------------------------------------------
204
+ * Component: AttachmentTrigger
205
+ * -------------------------------------------------------------------------- */
206
+
207
+ /**
208
+ * Full-card overlay trigger for opening/previewing the attachment.
209
+ *
210
+ * @since 0.5.0-canary.3
211
+ */
212
+ interface AttachmentTriggerProps extends ComponentProps<"button"> {
213
+ asChild?: boolean;
214
+ }
215
+
216
+ /**
217
+ * @since 0.5.0-canary.3
218
+ */
219
+ function AttachmentTrigger({ asChild = false, className, type, ...props }: AttachmentTriggerProps): JSX.Element {
220
+ const Component = asChild ? Slot.Root : "button";
221
+
222
+ return (
223
+ <Component
224
+ className={cn("absolute inset-0 z-10 outline-none", className)}
225
+ data-slot="attachment-trigger"
226
+ type={asChild ? undefined : (type ?? "button")}
227
+ {...props}
228
+ />
229
+ );
230
+ }
231
+
232
+ /* -----------------------------------------------------------------------------
233
+ * Component: AttachmentGroup
234
+ * -------------------------------------------------------------------------- */
235
+
236
+ /**
237
+ * Horizontally scrollable row of attachments with snap and edge fade.
238
+ *
239
+ * @since 0.5.0-canary.3
240
+ */
241
+ type AttachmentGroupProps = ComponentProps<"div">;
242
+
243
+ /**
244
+ * @since 0.5.0-canary.3
245
+ */
246
+ function AttachmentGroup({ className, ...props }: AttachmentGroupProps): JSX.Element {
247
+ return (
248
+ <div
249
+ className={cn(
250
+ "flex min-w-0 scroll-fade-x snap-x snap-mandatory scroll-px-1 scrollbar-none gap-3 overflow-x-auto overscroll-x-contain py-1 *:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start",
251
+ className,
252
+ )}
253
+ data-slot="attachment-group"
254
+ {...props}
255
+ />
256
+ );
257
+ }
258
+
259
+ /* -----------------------------------------------------------------------------
260
+ * Exports
261
+ * -------------------------------------------------------------------------- */
262
+
263
+ export {
264
+ Attachment,
265
+ AttachmentAction,
266
+ AttachmentActions,
267
+ AttachmentContent,
268
+ AttachmentDescription,
269
+ AttachmentGroup,
270
+ AttachmentMedia,
271
+ AttachmentTitle,
272
+ AttachmentTrigger,
273
+ };
274
+ export type {
275
+ AttachmentActionProps,
276
+ AttachmentActionsProps,
277
+ AttachmentContentProps,
278
+ AttachmentDescriptionProps,
279
+ AttachmentGroupProps,
280
+ AttachmentMediaProps,
281
+ AttachmentProps,
282
+ AttachmentTitleProps,
283
+ AttachmentTriggerProps,
284
+ };
@@ -122,7 +122,7 @@ function AvatarGroup({ className, ...props }: AvatarGroupProps): JSX.Element {
122
122
  return (
123
123
  <div
124
124
  className={cn(
125
- "group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background",
125
+ "group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background rtl:space-x-reverse",
126
126
  className,
127
127
  )}
128
128
  data-slot="avatar-group"
@@ -1,6 +1,6 @@
1
1
  import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react";
2
2
  import { Slot } from "radix-ui";
3
- import type { ComponentProps, JSX, ReactNode } from "react";
3
+ import type { ComponentProps, JSX } from "react";
4
4
 
5
5
  import { cn } from "#/lib/utils";
6
6
 
@@ -11,9 +11,7 @@ import { cn } from "#/lib/utils";
11
11
  /**
12
12
  * @since 0.3.16-canary.0
13
13
  */
14
- interface BreadcrumbProps extends ComponentProps<"nav"> {
15
- separator?: ReactNode;
16
- }
14
+ type BreadcrumbProps = ComponentProps<"nav">;
17
15
 
18
16
  /**
19
17
  * @since 0.3.16-canary.0
@@ -0,0 +1,116 @@
1
+ import { Slot } from "radix-ui";
2
+ import type { ComponentProps, JSX } from "react";
3
+
4
+ import { cn } from "#/lib/utils";
5
+ import type { BubbleReactionsVariants, BubbleVariants } from "#/variants/bubble";
6
+ import { bubbleReactionsVariants, bubbleVariants } from "#/variants/bubble";
7
+
8
+ /* -----------------------------------------------------------------------------
9
+ * Component: BubbleGroup
10
+ * -------------------------------------------------------------------------- */
11
+
12
+ /**
13
+ * Vertical stack of consecutive bubbles from one author.
14
+ *
15
+ * @since 0.5.0-canary.3
16
+ */
17
+ type BubbleGroupProps = ComponentProps<"div">;
18
+
19
+ /**
20
+ * @since 0.5.0-canary.3
21
+ */
22
+ function BubbleGroup({ className, ...props }: BubbleGroupProps): JSX.Element {
23
+ return <div className={cn("flex min-w-0 flex-col gap-2", className)} data-slot="bubble-group" {...props} />;
24
+ }
25
+
26
+ /* -----------------------------------------------------------------------------
27
+ * Component: Bubble
28
+ * -------------------------------------------------------------------------- */
29
+
30
+ /**
31
+ * Chat bubble wrapper. `variant` colors the content; `align` sets the side.
32
+ *
33
+ * @since 0.5.0-canary.3
34
+ */
35
+ interface BubbleProps extends ComponentProps<"div">, BubbleVariants {
36
+ align?: "start" | "end";
37
+ }
38
+
39
+ /**
40
+ * @since 0.5.0-canary.3
41
+ */
42
+ function Bubble({ align = "start", className, variant = "default", ...props }: BubbleProps): JSX.Element {
43
+ return (
44
+ <div
45
+ className={bubbleVariants({ className, variant })}
46
+ data-align={align}
47
+ data-slot="bubble"
48
+ data-variant={variant}
49
+ {...props}
50
+ />
51
+ );
52
+ }
53
+
54
+ /* -----------------------------------------------------------------------------
55
+ * Component: BubbleContent
56
+ * -------------------------------------------------------------------------- */
57
+
58
+ /**
59
+ * The bubble's colored surface; render as a button/link with `asChild`.
60
+ *
61
+ * @since 0.5.0-canary.3
62
+ */
63
+ interface BubbleContentProps extends ComponentProps<"div"> {
64
+ asChild?: boolean;
65
+ }
66
+
67
+ /**
68
+ * @since 0.5.0-canary.3
69
+ */
70
+ function BubbleContent({ asChild = false, className, ...props }: BubbleContentProps): JSX.Element {
71
+ const Component = asChild ? Slot.Root : "div";
72
+
73
+ return (
74
+ <Component
75
+ className={cn(
76
+ "w-fit max-w-full min-w-0 overflow-hidden rounded-xl border border-transparent px-3 py-2 text-sm leading-relaxed wrap-break-word group-data-[align=end]/bubble:self-end [button]:text-start [button,a]:transition-colors [button,a]:outline-none [button,a]:focus-visible:border-ring [button,a]:focus-visible:ring-3 [button,a]:focus-visible:ring-ring/50",
77
+ className,
78
+ )}
79
+ data-slot="bubble-content"
80
+ {...props}
81
+ />
82
+ );
83
+ }
84
+
85
+ /* -----------------------------------------------------------------------------
86
+ * Component: BubbleReactions
87
+ * -------------------------------------------------------------------------- */
88
+
89
+ /**
90
+ * Reaction pill overlapping a bubble corner.
91
+ *
92
+ * @since 0.5.0-canary.3
93
+ */
94
+ interface BubbleReactionsProps extends ComponentProps<"div">, BubbleReactionsVariants {}
95
+
96
+ /**
97
+ * @since 0.5.0-canary.3
98
+ */
99
+ function BubbleReactions({ align = "end", className, side = "bottom", ...props }: BubbleReactionsProps): JSX.Element {
100
+ return (
101
+ <div
102
+ className={bubbleReactionsVariants({ align, className, side })}
103
+ data-align={align}
104
+ data-side={side}
105
+ data-slot="bubble-reactions"
106
+ {...props}
107
+ />
108
+ );
109
+ }
110
+
111
+ /* -----------------------------------------------------------------------------
112
+ * Exports
113
+ * -------------------------------------------------------------------------- */
114
+
115
+ export { Bubble, BubbleContent, BubbleGroup, BubbleReactions };
116
+ export type { BubbleContentProps, BubbleGroupProps, BubbleProps, BubbleReactionsProps };
@@ -20,7 +20,7 @@ function Card({ className, size = "default", ...props }: CardProps): JSX.Element
20
20
  return (
21
21
  <div
22
22
  className={cn(
23
- "group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground shadow-xs ring-1 ring-foreground/10 [--card-spacing:--spacing(6)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(4)] *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
23
+ "group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground shadow-xs ring-1 ring-foreground/10 [--card-spacing:--spacing(6)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(4)] *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
24
24
  className,
25
25
  )}
26
26
  data-size={size}
@@ -124,7 +124,7 @@ type CardFooterProps = ComponentProps<"div">;
124
124
  function CardFooter({ className, ...props }: CardFooterProps): JSX.Element {
125
125
  return (
126
126
  <div
127
- className={cn("flex items-center rounded-b-xl px-(--card-spacing) [.border-t]:pt-(--card-spacing)", className)}
127
+ className={cn("flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)", className)}
128
128
  data-slot="card-footer"
129
129
  {...props}
130
130
  />
@@ -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
- if (event.key === "ArrowLeft") {
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 === "ArrowRight") {
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(() => {
@@ -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-lg border-dashed p-12 text-center text-balance",
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 };