@codefast/ui 0.5.0-canary.1 → 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.
Files changed (74) hide show
  1. package/CHANGELOG.md +39 -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/bubble.d.mts +67 -0
  6. package/dist/components/bubble.mjs +58 -0
  7. package/dist/components/card.mjs +2 -2
  8. package/dist/components/carousel.mjs +12 -3
  9. package/dist/components/chart.mjs +2 -1
  10. package/dist/components/empty.mjs +1 -1
  11. package/dist/components/form.mjs +2 -1
  12. package/dist/components/marker.d.mts +49 -0
  13. package/dist/components/marker.mjs +42 -0
  14. package/dist/components/message-scroller.d.mts +89 -0
  15. package/dist/components/message-scroller.mjs +77 -0
  16. package/dist/components/message.d.mts +86 -0
  17. package/dist/components/message.mjs +66 -0
  18. package/dist/components/sidebar.mjs +6 -3
  19. package/dist/hooks/use-animated-value.mjs +3 -1
  20. package/dist/hooks/use-message-scroller-commands.d.mts +39 -0
  21. package/dist/hooks/use-message-scroller-commands.mjs +165 -0
  22. package/dist/hooks/use-message-scroller-controller.d.mts +19 -0
  23. package/dist/hooks/use-message-scroller-controller.mjs +382 -0
  24. package/dist/hooks/use-message-scroller-refs.d.mts +60 -0
  25. package/dist/hooks/use-message-scroller-refs.mjs +77 -0
  26. package/dist/hooks/use-pagination.mjs +18 -12
  27. package/dist/index.d.mts +11 -1
  28. package/dist/index.mjs +11 -2
  29. package/dist/lib/message-scroller/geometry.d.mts +136 -0
  30. package/dist/lib/message-scroller/geometry.mjs +199 -0
  31. package/dist/lib/message-scroller/stores.d.mts +21 -0
  32. package/dist/lib/message-scroller/stores.mjs +52 -0
  33. package/dist/lib/message-scroller/types.d.mts +171 -0
  34. package/dist/lib/message-scroller/types.mjs +53 -0
  35. package/dist/lib/message-scroller/utils.d.mts +7 -0
  36. package/dist/lib/message-scroller/utils.mjs +12 -0
  37. package/dist/lib/use-render.d.mts +43 -0
  38. package/dist/lib/use-render.mjs +84 -0
  39. package/dist/primitives/checkbox-group.mjs +20 -10
  40. package/dist/primitives/message-scroller.d.mts +88 -0
  41. package/dist/primitives/message-scroller.mjs +240 -0
  42. package/dist/variants/attachment.d.mts +42 -0
  43. package/dist/variants/attachment.mjs +42 -0
  44. package/dist/variants/bubble.d.mts +45 -0
  45. package/dist/variants/bubble.mjs +45 -0
  46. package/dist/variants/marker.d.mts +21 -0
  47. package/dist/variants/marker.mjs +18 -0
  48. package/package.json +57 -11
  49. package/src/components/attachment.tsx +284 -0
  50. package/src/components/avatar.tsx +1 -1
  51. package/src/components/bubble.tsx +116 -0
  52. package/src/components/card.tsx +2 -2
  53. package/src/components/carousel.tsx +12 -3
  54. package/src/components/empty.tsx +1 -1
  55. package/src/components/marker.tsx +94 -0
  56. package/src/components/message-scroller.tsx +213 -0
  57. package/src/components/message.tsx +173 -0
  58. package/src/components/sidebar.tsx +11 -4
  59. package/src/css/foundation/tokens.css +6 -18
  60. package/src/css/foundation/utilities.css +451 -0
  61. package/src/css/preset.css +2 -1
  62. package/src/hooks/use-message-scroller-commands.ts +312 -0
  63. package/src/hooks/use-message-scroller-controller.ts +651 -0
  64. package/src/hooks/use-message-scroller-refs.ts +168 -0
  65. package/src/index.ts +72 -0
  66. package/src/lib/message-scroller/geometry.ts +398 -0
  67. package/src/lib/message-scroller/stores.ts +89 -0
  68. package/src/lib/message-scroller/types.ts +310 -0
  69. package/src/lib/message-scroller/utils.ts +15 -0
  70. package/src/lib/use-render.ts +202 -0
  71. package/src/primitives/message-scroller.tsx +399 -0
  72. package/src/variants/attachment.ts +73 -0
  73. package/src/variants/bubble.ts +81 -0
  74. package/src/variants/marker.ts +38 -0
@@ -0,0 +1,45 @@
1
+ import { VariantProps } from "../lib/utils.mjs";
2
+
3
+ //#region src/variants/bubble.d.ts
4
+ /**
5
+ * Chat bubble surface. Variants paint the nested `bubble-content`, so the color
6
+ * follows the message author regardless of alignment.
7
+ *
8
+ * @since 0.5.0-canary.3
9
+ */
10
+ declare const bubbleVariants: import("@codefast/tailwind-variants").VariantResolver<{
11
+ variant: {
12
+ default: string;
13
+ secondary: string;
14
+ muted: string;
15
+ tinted: string;
16
+ outline: string;
17
+ ghost: string;
18
+ destructive: string;
19
+ };
20
+ }, Record<string, never>>;
21
+ /**
22
+ * @since 0.5.0-canary.3
23
+ */
24
+ type BubbleVariants = VariantProps<typeof bubbleVariants>;
25
+ /**
26
+ * Reaction pill anchored to a bubble corner.
27
+ *
28
+ * @since 0.5.0-canary.3
29
+ */
30
+ declare const bubbleReactionsVariants: import("@codefast/tailwind-variants").VariantResolver<{
31
+ side: {
32
+ top: string;
33
+ bottom: string;
34
+ };
35
+ align: {
36
+ start: string;
37
+ end: string;
38
+ };
39
+ }, Record<string, never>>;
40
+ /**
41
+ * @since 0.5.0-canary.3
42
+ */
43
+ type BubbleReactionsVariants = VariantProps<typeof bubbleReactionsVariants>;
44
+ //#endregion
45
+ export { type BubbleReactionsVariants, type BubbleVariants, bubbleReactionsVariants, bubbleVariants };
@@ -0,0 +1,45 @@
1
+ import { tv } from "../lib/utils.mjs";
2
+ //#region src/variants/bubble.ts
3
+ /**
4
+ * Chat bubble surface. Variants paint the nested `bubble-content`, so the color
5
+ * follows the message author regardless of alignment.
6
+ *
7
+ * @since 0.5.0-canary.3
8
+ */
9
+ const bubbleVariants = tv({
10
+ base: "group/bubble relative flex w-fit max-w-[80%] min-w-0 flex-col gap-1 group-data-[align=end]/message:self-end data-[align=end]:self-end data-[variant=ghost]:max-w-full",
11
+ defaultVariants: { variant: "default" },
12
+ variants: { variant: {
13
+ default: "*:data-[slot=bubble-content]:bg-primary *:data-[slot=bubble-content]:text-primary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-primary/80",
14
+ secondary: "*:data-[slot=bubble-content]:bg-secondary *:data-[slot=bubble-content]:text-secondary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]",
15
+ muted: "*:data-[slot=bubble-content]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,var(--muted),var(--foreground)_5%)]",
16
+ tinted: "*:data-[slot=bubble-content]:bg-[oklch(from_var(--primary)_0.93_calc(c*0.4)_h)] *:data-[slot=bubble-content]:text-foreground dark:*:data-[slot=bubble-content]:bg-[oklch(from_var(--primary)_0.3_calc(c*0.4)_h)] [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_var(--primary)_0.88_calc(c*0.5)_h)] dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_var(--primary)_0.35_calc(c*0.5)_h)]",
17
+ outline: "*:data-[slot=bubble-content]:border-border *:data-[slot=bubble-content]:bg-background [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-input/30",
18
+ ghost: "border-none *:data-[slot=bubble-content]:rounded-none *:data-[slot=bubble-content]:bg-transparent *:data-[slot=bubble-content]:p-0 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted/50",
19
+ destructive: "*:data-[slot=bubble-content]:bg-destructive/10 *:data-[slot=bubble-content]:text-destructive dark:*:data-[slot=bubble-content]:bg-destructive/20 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/20 dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/30"
20
+ } }
21
+ });
22
+ /**
23
+ * Reaction pill anchored to a bubble corner.
24
+ *
25
+ * @since 0.5.0-canary.3
26
+ */
27
+ const bubbleReactionsVariants = tv({
28
+ base: "absolute z-10 flex w-fit shrink-0 items-center justify-center gap-1 rounded-full bg-muted px-1.5 py-0.5 text-sm ring-3 ring-card has-[button]:p-0",
29
+ defaultVariants: {
30
+ align: "end",
31
+ side: "bottom"
32
+ },
33
+ variants: {
34
+ side: {
35
+ top: "top-0 -translate-y-3/4",
36
+ bottom: "bottom-0 translate-y-3/4"
37
+ },
38
+ align: {
39
+ start: "start-3",
40
+ end: "end-3"
41
+ }
42
+ }
43
+ });
44
+ //#endregion
45
+ export { bubbleReactionsVariants, bubbleVariants };
@@ -0,0 +1,21 @@
1
+ import { VariantProps } from "../lib/utils.mjs";
2
+
3
+ //#region src/variants/marker.d.ts
4
+ /**
5
+ * Inline chat divider — plain label, centered separator rule, or bottom border.
6
+ *
7
+ * @since 0.5.0-canary.3
8
+ */
9
+ declare const markerVariants: import("@codefast/tailwind-variants").VariantResolver<{
10
+ variant: {
11
+ default: string;
12
+ separator: string;
13
+ border: string;
14
+ };
15
+ }, Record<string, never>>;
16
+ /**
17
+ * @since 0.5.0-canary.3
18
+ */
19
+ type MarkerVariants = VariantProps<typeof markerVariants>;
20
+ //#endregion
21
+ export { type MarkerVariants, markerVariants };
@@ -0,0 +1,18 @@
1
+ import { tv } from "../lib/utils.mjs";
2
+ //#region src/variants/marker.ts
3
+ /**
4
+ * Inline chat divider — plain label, centered separator rule, or bottom border.
5
+ *
6
+ * @since 0.5.0-canary.3
7
+ */
8
+ const markerVariants = tv({
9
+ base: "group/marker relative flex min-h-4 w-full items-center gap-2 text-start text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [a]:underline [a]:underline-offset-3 [a]:hover:text-foreground",
10
+ defaultVariants: { variant: "default" },
11
+ variants: { variant: {
12
+ default: "",
13
+ separator: "before:me-1 before:h-px before:min-w-0 before:flex-1 before:bg-border after:ms-1 after:h-px after:min-w-0 after:flex-1 after:bg-border",
14
+ border: "border-b border-border pb-2"
15
+ } }
16
+ });
17
+ //#endregion
18
+ export { markerVariants };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codefast/ui",
3
- "version": "0.5.0-canary.1",
3
+ "version": "0.5.0-canary.3",
4
4
  "description": "Core UI components library built with React and Tailwind CSS",
5
5
  "keywords": [
6
6
  "components",
@@ -80,6 +80,11 @@
80
80
  "types": "./dist/components/aspect-ratio.d.mts",
81
81
  "import": "./dist/components/aspect-ratio.mjs"
82
82
  },
83
+ "./attachment": {
84
+ "source": "./src/components/attachment.tsx",
85
+ "types": "./dist/components/attachment.d.mts",
86
+ "import": "./dist/components/attachment.mjs"
87
+ },
83
88
  "./avatar": {
84
89
  "source": "./src/components/avatar.tsx",
85
90
  "types": "./dist/components/avatar.d.mts",
@@ -105,6 +110,11 @@
105
110
  "types": "./dist/components/button-group.d.mts",
106
111
  "import": "./dist/components/button-group.mjs"
107
112
  },
113
+ "./bubble": {
114
+ "source": "./src/components/bubble.tsx",
115
+ "types": "./dist/components/bubble.d.mts",
116
+ "import": "./dist/components/bubble.mjs"
117
+ },
108
118
  "./calendar": {
109
119
  "source": "./src/components/calendar.tsx",
110
120
  "types": "./dist/components/calendar.d.mts",
@@ -240,11 +250,26 @@
240
250
  "types": "./dist/components/label.d.mts",
241
251
  "import": "./dist/components/label.mjs"
242
252
  },
253
+ "./marker": {
254
+ "source": "./src/components/marker.tsx",
255
+ "types": "./dist/components/marker.d.mts",
256
+ "import": "./dist/components/marker.mjs"
257
+ },
243
258
  "./menubar": {
244
259
  "source": "./src/components/menubar.tsx",
245
260
  "types": "./dist/components/menubar.d.mts",
246
261
  "import": "./dist/components/menubar.mjs"
247
262
  },
263
+ "./message": {
264
+ "source": "./src/components/message.tsx",
265
+ "types": "./dist/components/message.d.mts",
266
+ "import": "./dist/components/message.mjs"
267
+ },
268
+ "./message-scroller": {
269
+ "source": "./src/components/message-scroller.tsx",
270
+ "types": "./dist/components/message-scroller.d.mts",
271
+ "import": "./dist/components/message-scroller.mjs"
272
+ },
248
273
  "./native-select": {
249
274
  "source": "./src/components/native-select.tsx",
250
275
  "types": "./dist/components/native-select.d.mts",
@@ -425,6 +450,11 @@
425
450
  "types": "./dist/primitives/input-number.d.mts",
426
451
  "import": "./dist/primitives/input-number.mjs"
427
452
  },
453
+ "./primitives/message-scroller": {
454
+ "source": "./src/primitives/message-scroller.tsx",
455
+ "types": "./dist/primitives/message-scroller.d.mts",
456
+ "import": "./dist/primitives/message-scroller.mjs"
457
+ },
428
458
  "./primitives/progress-circle": {
429
459
  "source": "./src/primitives/progress-circle.tsx",
430
460
  "types": "./dist/primitives/progress-circle.d.mts",
@@ -435,11 +465,21 @@
435
465
  "types": "./dist/variants/alert.d.mts",
436
466
  "import": "./dist/variants/alert.mjs"
437
467
  },
468
+ "./variants/attachment": {
469
+ "source": "./src/variants/attachment.ts",
470
+ "types": "./dist/variants/attachment.d.mts",
471
+ "import": "./dist/variants/attachment.mjs"
472
+ },
438
473
  "./variants/badge": {
439
474
  "source": "./src/variants/badge.ts",
440
475
  "types": "./dist/variants/badge.d.mts",
441
476
  "import": "./dist/variants/badge.mjs"
442
477
  },
478
+ "./variants/bubble": {
479
+ "source": "./src/variants/bubble.ts",
480
+ "types": "./dist/variants/bubble.d.mts",
481
+ "import": "./dist/variants/bubble.mjs"
482
+ },
443
483
  "./variants/button": {
444
484
  "source": "./src/variants/button.ts",
445
485
  "types": "./dist/variants/button.d.mts",
@@ -475,6 +515,11 @@
475
515
  "types": "./dist/variants/item.d.mts",
476
516
  "import": "./dist/variants/item.mjs"
477
517
  },
518
+ "./variants/marker": {
519
+ "source": "./src/variants/marker.ts",
520
+ "types": "./dist/variants/marker.d.mts",
521
+ "import": "./dist/variants/marker.mjs"
522
+ },
478
523
  "./variants/navigation-menu": {
479
524
  "source": "./src/variants/navigation-menu.ts",
480
525
  "types": "./dist/variants/navigation-menu.d.mts",
@@ -526,30 +571,30 @@
526
571
  "cmdk": "^1.1.1",
527
572
  "embla-carousel-react": "^8.6.0",
528
573
  "input-otp": "^1.4.2",
529
- "lucide-react": "^1.22.0",
574
+ "lucide-react": "^1.23.0",
530
575
  "next-themes": "^0.4.6",
531
- "radix-ui": "^1.6.0",
576
+ "radix-ui": "^1.6.1",
532
577
  "react-hook-form": "^7.80.0",
533
- "react-resizable-panels": "^4.11.2",
534
- "recharts": "^3.9.0",
578
+ "react-resizable-panels": "^4.12.1",
579
+ "recharts": "^3.9.2",
535
580
  "sonner": "^2.0.7",
536
581
  "tw-animate-css": "^1.4.0",
537
582
  "vaul": "^1.1.2",
538
- "@codefast/tailwind-variants": "0.5.0-canary.1"
583
+ "@codefast/tailwind-variants": "0.5.0-canary.3"
539
584
  },
540
585
  "devDependencies": {
541
586
  "@storybook/addon-a11y": "^10.4.6",
542
587
  "@storybook/addon-docs": "^10.4.6",
543
588
  "@storybook/addon-vitest": "^10.4.6",
544
589
  "@storybook/react-vite": "^10.4.6",
545
- "@tailwindcss/postcss": "^4.3.1",
590
+ "@tailwindcss/postcss": "^4.3.2",
546
591
  "@testing-library/dom": "^10.4.1",
547
592
  "@testing-library/jest-dom": "^6.9.1",
548
593
  "@testing-library/react": "^16.3.2",
549
594
  "@testing-library/user-event": "^14.6.1",
550
595
  "@types/jest-axe": "^3.5.9",
551
- "@types/node": "^26.0.1",
552
- "@typescript/native-preview": "7.0.0-dev.20260624.1",
596
+ "@types/node": "^26.1.0",
597
+ "@typescript/native-preview": "7.0.0-dev.20260703.1",
553
598
  "@vitejs/plugin-react": "^6.0.3",
554
599
  "@vitest/browser": "^4.1.9",
555
600
  "@vitest/browser-playwright": "^4.1.9",
@@ -559,11 +604,11 @@
559
604
  "playwright": "^1.61.1",
560
605
  "postcss": "^8.5.16",
561
606
  "storybook": "^10.4.6",
562
- "tailwindcss": "^4.3.1",
607
+ "tailwindcss": "^4.3.2",
563
608
  "tsdown": "^0.22.3",
564
609
  "typescript": "^6.0.3",
565
610
  "vitest": "^4.1.9",
566
- "@codefast/typescript-config": "0.5.0-canary.1"
611
+ "@codefast/typescript-config": "0.5.0-canary.3"
567
612
  },
568
613
  "peerDependencies": {
569
614
  "@types/react": ">=19.0.0",
@@ -583,6 +628,7 @@
583
628
  "node": ">=24.0.0"
584
629
  },
585
630
  "scripts": {
631
+ "audit:rtl": "node scripts/audit-rtl.mjs",
586
632
  "build": "tsdown",
587
633
  "build-storybook": "storybook build",
588
634
  "check-types": "tsgo --noEmit",
@@ -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"