@brightlocal/ui-components 0.1.1 → 0.1.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 (244) hide show
  1. package/dist/accordion.cjs +1 -1
  2. package/dist/accordion.d.ts +74 -4
  3. package/dist/accordion.d.ts.map +1 -1
  4. package/dist/accordion.js +100 -105
  5. package/dist/alert-dialog.cjs +1 -1
  6. package/dist/alert-dialog.d.ts +30 -10
  7. package/dist/alert-dialog.d.ts.map +1 -1
  8. package/dist/alert-dialog.js +129 -132
  9. package/dist/alert.d.ts +22 -1
  10. package/dist/alert.d.ts.map +1 -1
  11. package/dist/aspect-ratio.cjs +1 -1
  12. package/dist/aspect-ratio.d.ts +11 -1
  13. package/dist/aspect-ratio.d.ts.map +1 -1
  14. package/dist/aspect-ratio.js +16 -20
  15. package/dist/avatar.cjs +1 -1
  16. package/dist/avatar.d.ts +43 -3
  17. package/dist/avatar.d.ts.map +1 -1
  18. package/dist/avatar.js +18 -16
  19. package/dist/badge.cjs +1 -1
  20. package/dist/badge.d.ts +24 -9
  21. package/dist/badge.d.ts.map +1 -1
  22. package/dist/badge.js +34 -32
  23. package/dist/blocks/data-table.cjs +1 -1
  24. package/dist/blocks/data-table.d.ts.map +1 -1
  25. package/dist/blocks/data-table.js +209 -202
  26. package/dist/blocks/sidebar.cjs +1 -1
  27. package/dist/blocks/sidebar.d.ts +1 -1
  28. package/dist/blocks/sidebar.d.ts.map +1 -1
  29. package/dist/blocks/sidebar.js +154 -154
  30. package/dist/breadcrumb.cjs +1 -1
  31. package/dist/breadcrumb.d.ts +63 -8
  32. package/dist/breadcrumb.d.ts.map +1 -1
  33. package/dist/breadcrumb.js +97 -93
  34. package/dist/button.cjs +1 -1
  35. package/dist/button.d.ts +17 -45
  36. package/dist/button.d.ts.map +1 -1
  37. package/dist/button.js +49 -50
  38. package/dist/calendar.cjs +1 -1
  39. package/dist/calendar.d.ts +12 -0
  40. package/dist/calendar.d.ts.map +1 -1
  41. package/dist/calendar.js +10 -8
  42. package/dist/card.cjs +1 -1
  43. package/dist/card.d.ts +58 -18
  44. package/dist/card.d.ts.map +1 -1
  45. package/dist/card.js +60 -51
  46. package/dist/carousel.cjs +1 -1
  47. package/dist/carousel.d.ts +99 -9
  48. package/dist/carousel.d.ts.map +1 -1
  49. package/dist/carousel.js +142 -128
  50. package/dist/centred-layout.cjs +1 -1
  51. package/dist/centred-layout.d.ts +18 -2
  52. package/dist/centred-layout.d.ts.map +1 -1
  53. package/dist/centred-layout.js +46 -33
  54. package/dist/chart.cjs +4 -4
  55. package/dist/chart.d.ts +70 -7
  56. package/dist/chart.d.ts.map +1 -1
  57. package/dist/chart.js +71 -66
  58. package/dist/checkbox.cjs +1 -1
  59. package/dist/checkbox.d.ts +9 -5
  60. package/dist/checkbox.d.ts.map +1 -1
  61. package/dist/checkbox.js +61 -82
  62. package/dist/collapsible.cjs +1 -1
  63. package/dist/collapsible.d.ts +65 -8
  64. package/dist/collapsible.d.ts.map +1 -1
  65. package/dist/collapsible.js +41 -55
  66. package/dist/combobox.cjs +1 -1
  67. package/dist/combobox.d.ts +29 -11
  68. package/dist/combobox.d.ts.map +1 -1
  69. package/dist/combobox.js +193 -159
  70. package/dist/command.cjs +1 -1
  71. package/dist/command.d.ts +115 -9
  72. package/dist/command.d.ts.map +1 -1
  73. package/dist/command.js +176 -152
  74. package/dist/context-menu.cjs +1 -1
  75. package/dist/context-menu.d.ts +188 -20
  76. package/dist/context-menu.d.ts.map +1 -1
  77. package/dist/context-menu.js +119 -121
  78. package/dist/date-picker.cjs +1 -1
  79. package/dist/date-picker.d.ts +75 -9
  80. package/dist/date-picker.d.ts.map +1 -1
  81. package/dist/date-picker.js +220 -81
  82. package/dist/description.cjs +1 -0
  83. package/dist/description.d.ts +37 -0
  84. package/dist/description.d.ts.map +1 -0
  85. package/dist/description.js +25 -0
  86. package/dist/dialog.cjs +1 -1
  87. package/dist/dialog.d.ts +73 -9
  88. package/dist/dialog.d.ts.map +1 -1
  89. package/dist/dialog.js +103 -112
  90. package/dist/drawer.cjs +1 -1
  91. package/dist/drawer.d.ts +92 -0
  92. package/dist/drawer.d.ts.map +1 -1
  93. package/dist/drawer.js +67 -52
  94. package/dist/dropdown-menu.cjs +1 -1
  95. package/dist/dropdown-menu.d.ts +95 -11
  96. package/dist/dropdown-menu.d.ts.map +1 -1
  97. package/dist/dropdown-menu.js +146 -106
  98. package/dist/field.cjs +1 -1
  99. package/dist/field.d.ts +23 -6
  100. package/dist/field.d.ts.map +1 -1
  101. package/dist/field.js +54 -53
  102. package/dist/global-layout.cjs +1 -1
  103. package/dist/global-layout.d.ts +27 -17
  104. package/dist/global-layout.d.ts.map +1 -1
  105. package/dist/global-layout.js +86 -79
  106. package/dist/hover-card.cjs +1 -1
  107. package/dist/hover-card.d.ts +36 -6
  108. package/dist/hover-card.d.ts.map +1 -1
  109. package/dist/hover-card.js +44 -42
  110. package/dist/index.cjs +1 -1
  111. package/dist/index.d.ts +1 -1
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +383 -387
  114. package/dist/input-group.cjs +1 -1
  115. package/dist/input-group.d.ts +21 -2
  116. package/dist/input-group.d.ts.map +1 -1
  117. package/dist/input-group.js +51 -41
  118. package/dist/input-password.cjs +1 -1
  119. package/dist/input-password.d.ts.map +1 -1
  120. package/dist/input-password.js +24 -25
  121. package/dist/input.cjs +1 -1
  122. package/dist/input.d.ts +38 -24
  123. package/dist/input.d.ts.map +1 -1
  124. package/dist/input.js +68 -136
  125. package/dist/label.cjs +1 -1
  126. package/dist/label.d.ts +20 -1
  127. package/dist/label.d.ts.map +1 -1
  128. package/dist/label.js +31 -18
  129. package/dist/logo.cjs +1 -1
  130. package/dist/logo.d.ts +3 -0
  131. package/dist/logo.d.ts.map +1 -1
  132. package/dist/logo.js +12 -10
  133. package/dist/menubar.cjs +1 -1
  134. package/dist/menubar.d.ts +40 -6
  135. package/dist/menubar.d.ts.map +1 -1
  136. package/dist/menubar.js +97 -76
  137. package/dist/popover.cjs +1 -1
  138. package/dist/popover.d.ts +59 -4
  139. package/dist/popover.d.ts.map +1 -1
  140. package/dist/popover.js +42 -34
  141. package/dist/progress.cjs +1 -1
  142. package/dist/progress.d.ts +9 -2
  143. package/dist/progress.d.ts.map +1 -1
  144. package/dist/progress.js +71 -59
  145. package/dist/radio-group.d.ts +40 -0
  146. package/dist/radio-group.d.ts.map +1 -1
  147. package/dist/rating.d.ts +4 -0
  148. package/dist/rating.d.ts.map +1 -1
  149. package/dist/resizable.cjs +1 -1
  150. package/dist/resizable.d.ts +65 -4
  151. package/dist/resizable.d.ts.map +1 -1
  152. package/dist/resizable.js +53 -36
  153. package/dist/scroll-area.cjs +1 -1
  154. package/dist/scroll-area.d.ts +46 -5
  155. package/dist/scroll-area.d.ts.map +1 -1
  156. package/dist/scroll-area.js +42 -38
  157. package/dist/select.cjs +1 -1
  158. package/dist/select.d.ts +30 -0
  159. package/dist/select.d.ts.map +1 -1
  160. package/dist/select.js +64 -54
  161. package/dist/separator.cjs +1 -1
  162. package/dist/separator.d.ts +49 -2
  163. package/dist/separator.d.ts.map +1 -1
  164. package/dist/separator.js +48 -36
  165. package/dist/sheet.cjs +1 -1
  166. package/dist/sheet.d.ts +80 -9
  167. package/dist/sheet.d.ts.map +1 -1
  168. package/dist/sheet.js +117 -113
  169. package/dist/skeleton.cjs +1 -1
  170. package/dist/skeleton.d.ts +24 -2
  171. package/dist/skeleton.d.ts.map +1 -1
  172. package/dist/skeleton.js +15 -9
  173. package/dist/slider.cjs +1 -1
  174. package/dist/slider.d.ts +18 -4
  175. package/dist/slider.d.ts.map +1 -1
  176. package/dist/slider.js +72 -66
  177. package/dist/sonner.cjs +1 -1
  178. package/dist/sonner.d.ts +4 -2
  179. package/dist/sonner.d.ts.map +1 -1
  180. package/dist/sonner.js +29 -28
  181. package/dist/split-layout.d.ts +4 -1
  182. package/dist/split-layout.d.ts.map +1 -1
  183. package/dist/table.cjs +1 -1
  184. package/dist/table.js +1 -1
  185. package/dist/toggle-group.cjs +1 -1
  186. package/dist/toggle-group.d.ts +3 -1
  187. package/dist/toggle-group.d.ts.map +1 -1
  188. package/dist/toggle-group.js +38 -36
  189. package/package.json +8 -2
  190. package/src/blocks/data-table.tsx +42 -32
  191. package/src/blocks/sidebar.tsx +4 -12
  192. package/src/components/accordion.tsx +163 -77
  193. package/src/components/alert-dialog.tsx +156 -111
  194. package/src/components/alert.tsx +26 -13
  195. package/src/components/aspect-ratio.tsx +25 -16
  196. package/src/components/avatar.tsx +56 -8
  197. package/src/components/badge.tsx +65 -42
  198. package/src/components/breadcrumb.tsx +158 -82
  199. package/src/components/button.tsx +41 -62
  200. package/src/components/calendar.tsx +16 -2
  201. package/src/components/card.tsx +92 -40
  202. package/src/components/carousel.tsx +240 -115
  203. package/src/components/centred-layout.tsx +67 -35
  204. package/src/components/chart.tsx +118 -47
  205. package/src/components/checkbox.tsx +42 -78
  206. package/src/components/collapsible.tsx +95 -26
  207. package/src/components/combobox.tsx +242 -144
  208. package/src/components/command.tsx +295 -121
  209. package/src/components/context-menu.tsx +278 -81
  210. package/src/components/date-picker.tsx +281 -30
  211. package/src/components/description.tsx +60 -0
  212. package/src/components/dialog.tsx +162 -86
  213. package/src/components/drawer.tsx +76 -2
  214. package/src/components/dropdown-menu.tsx +143 -37
  215. package/src/components/field.tsx +36 -11
  216. package/src/components/global-layout.tsx +116 -77
  217. package/src/components/hover-card.tsx +54 -14
  218. package/src/components/input-group.tsx +56 -18
  219. package/src/components/input-password.tsx +3 -4
  220. package/src/components/input.tsx +93 -186
  221. package/src/components/label.tsx +56 -15
  222. package/src/components/logo.tsx +3 -0
  223. package/src/components/menubar.tsx +58 -4
  224. package/src/components/popover.tsx +103 -20
  225. package/src/components/progress.tsx +82 -60
  226. package/src/components/radio-group.tsx +40 -0
  227. package/src/components/rating.tsx +4 -1
  228. package/src/components/resizable.tsx +119 -31
  229. package/src/components/scroll-area.tsx +123 -56
  230. package/src/components/select.tsx +21 -1
  231. package/src/components/separator.tsx +97 -20
  232. package/src/components/sheet.tsx +180 -79
  233. package/src/components/skeleton.tsx +40 -10
  234. package/src/components/slider.tsx +83 -57
  235. package/src/components/sonner.tsx +10 -7
  236. package/src/components/split-layout.tsx +4 -1
  237. package/src/components/table.tsx +1 -1
  238. package/src/components/toggle-group.tsx +4 -0
  239. package/src/index.ts +1 -1
  240. package/dist/input-base.cjs +0 -1
  241. package/dist/input-base.d.ts +0 -28
  242. package/dist/input-base.d.ts.map +0 -1
  243. package/dist/input-base.js +0 -56
  244. package/src/components/input-base.tsx +0 -86
@@ -5,60 +5,29 @@ import { Loader2 } from "lucide-react";
5
5
 
6
6
  import { cn } from "@brightlocal/ui-components/lib/utils";
7
7
 
8
- /**
9
- * Available button visual variants
10
- */
11
- export enum ButtonVariant {
12
- /** Primary action button with solid background */
13
- DEFAULT = "default",
14
- /** Destructive action button (delete, remove, etc.) */
15
- DESTRUCTIVE = "destructive",
16
- /** Button with border and transparent background */
17
- OUTLINE = "outline",
18
- /** Secondary action button with muted background */
19
- SECONDARY = "secondary",
20
- /** Subtle button with transparent background */
21
- GHOST = "ghost",
22
- }
23
-
24
- /**
25
- * Available button size variants
26
- */
27
- export enum ButtonSize {
28
- /** Standard button size (36px height) */
29
- DEFAULT = "default",
30
- /** Small button size (32px height) */
31
- SM = "sm",
32
- /** Large button size (40px height) */
33
- LG = "lg",
34
- }
35
-
36
- /**
37
- * Internal button state variants for styling
38
- */
39
- export enum ButtonState {
40
- /** Normal interactive state */
41
- Default = "default",
42
- /** Loading state with spinner */
43
- Loading = "loading",
44
- /** Disabled state with reduced opacity */
45
- Disabled = "disabled",
46
- }
47
-
48
- /**
49
- * Button types matching native button types
50
- */
51
- export enum ButtonType {
52
- BUTTON = "button",
53
- SUBMIT = "submit",
54
- }
55
-
56
8
  // Shared constants
57
9
  const BUTTON_SPINNER_SIZE = 16;
58
10
 
11
+ /**
12
+ * Variant props for CVA button styling
13
+ */
59
14
  type ButtonVariantProps = {
60
- variant?: ButtonVariant;
61
- size?: ButtonSize;
15
+ /**
16
+ * Visual style variant of the button
17
+ * @default "default"
18
+ */
19
+ variant?:
20
+ | "default"
21
+ | "destructive"
22
+ | "outline"
23
+ | "secondary"
24
+ | "ghost"
25
+ | "warning";
26
+ /**
27
+ * Size variant of the button
28
+ * @default "default"
29
+ */
30
+ size?: "default" | "sm" | "lg";
62
31
  };
63
32
 
64
33
  const ButtonVariants = cva(
@@ -70,7 +39,9 @@ const ButtonVariants = cva(
70
39
  "justify-center",
71
40
  "gap-2",
72
41
  "whitespace-nowrap",
73
- "transition-all",
42
+ "transition-[color,background-color,border-color,box-shadow]",
43
+ "duration-150",
44
+ "ease-in-out",
74
45
  "cursor-pointer",
75
46
  "disabled:pointer-events-none",
76
47
  "disabled:cursor-not-allowed",
@@ -114,6 +85,7 @@ const ButtonVariants = cva(
114
85
  "dark:hover:bg-input/80",
115
86
  "dark:hover:border-input",
116
87
  "focus-visible:shadow-default",
88
+ "focus-visible:border-ring",
117
89
  ],
118
90
  secondary: [
119
91
  "bg-secondary",
@@ -151,9 +123,9 @@ const ButtonVariants = cva(
151
123
  },
152
124
  },
153
125
  defaultVariants: {
154
- variant: ButtonVariant.DEFAULT,
155
- size: ButtonSize.DEFAULT,
156
- state: ButtonState.Default,
126
+ variant: "default",
127
+ size: "default",
128
+ state: "default",
157
129
  fullWidth: false,
158
130
  },
159
131
  }
@@ -169,8 +141,13 @@ type ButtonProps = NativeButtonProps &
169
141
  ariaLabel?: string;
170
142
  asChild?: boolean;
171
143
  dataHook: string;
172
- type?: ButtonType;
144
+ /**
145
+ * Button type attribute
146
+ * @default "button"
147
+ */
148
+ type?: "button" | "submit";
173
149
  fullWidth?: boolean;
150
+ iconOnly?: boolean;
174
151
  loading?: boolean;
175
152
  trackingEl?: string;
176
153
  trackingLabel?: string;
@@ -180,13 +157,14 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
180
157
  (
181
158
  {
182
159
  className,
183
- variant = ButtonVariant.DEFAULT,
184
- size = ButtonSize.DEFAULT,
160
+ variant = "default",
161
+ size = "default",
185
162
  fullWidth = false,
186
163
  asChild = false,
187
164
  dataHook,
188
165
  trackingEl,
189
166
  trackingLabel,
167
+ iconOnly = false,
190
168
  loading = false,
191
169
  ariaLabel,
192
170
  disabled = false,
@@ -202,8 +180,9 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
202
180
 
203
181
  // Determine content to display
204
182
  const displayChildren = children;
205
- let isSingleIconOnly = false;
183
+ let isSingleIconOnly = iconOnly;
206
184
  if (
185
+ !isSingleIconOnly &&
207
186
  React.Children.count(children) === 1 &&
208
187
  React.isValidElement(children)
209
188
  ) {
@@ -215,9 +194,9 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
215
194
  const showLoadingSpinner = loading && !asChild;
216
195
 
217
196
  // Compute visual state class via CVA
218
- let visualState: ButtonState = ButtonState.Default;
219
- if (loading) visualState = ButtonState.Loading;
220
- else if (disabled) visualState = ButtonState.Disabled;
197
+ let visualState: "default" | "loading" | "disabled" = "default";
198
+ if (loading) visualState = "loading";
199
+ else if (disabled) visualState = "disabled";
221
200
 
222
201
  // Ensure we always have an accessible label
223
202
  const effectiveAriaLabel =
@@ -272,7 +251,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
272
251
  data-tracking-el={trackingEl || `button-${variant}`}
273
252
  data-tracking-label={trackingLabel}
274
253
  disabled={isDisabled}
275
- type={props.type ?? ButtonType.BUTTON}
254
+ type={props.type ?? "button"}
276
255
  {...props}
277
256
  >
278
257
  {showLoadingSpinner && (
@@ -11,6 +11,9 @@ import {
11
11
 
12
12
  import { cn } from "@brightlocal/ui-components/lib/utils";
13
13
 
14
+ /**
15
+ * Props for the Calendar component
16
+ */
14
17
  export type CalendarProps = DayPickerProps & {
15
18
  /**
16
19
  * Number of months to display (1-3)
@@ -32,12 +35,17 @@ export type CalendarProps = DayPickerProps & {
32
35
  };
33
36
 
34
37
  const navButtonStyles = cn(
35
- "inline-flex items-center justify-center rounded-md bg-background",
38
+ "inline-flex items-center justify-center rounded-md",
39
+ "text-muted-foreground hover:text-foreground",
36
40
  "hover:bg-accent hover:text-accent-foreground",
37
41
  "focus-visible:outline-none focus-visible:shadow-default",
38
- "h-8 w-8 p-0 opacity-50 hover:opacity-100"
42
+ "h-8 w-8 p-0"
39
43
  );
40
44
 
45
+ /**
46
+ * Custom day button component for the Calendar.
47
+ * Renders individual day cells with proper styling and selection states.
48
+ */
41
49
  function CalendarDayButton({
42
50
  className,
43
51
  day,
@@ -82,6 +90,11 @@ function CalendarDayButton({
82
90
  );
83
91
  }
84
92
 
93
+ /**
94
+ * Calendar component for date and range selection.
95
+ * Supports single date, multiple dates, and date range selection modes.
96
+ * Built on top of react-day-picker with custom styling and navigation.
97
+ */
85
98
  function Calendar({
86
99
  className,
87
100
  classNames,
@@ -214,6 +227,7 @@ function Calendar({
214
227
  ...components,
215
228
  }}
216
229
  data-hook={dataHook}
230
+ data-slot="calendar"
217
231
  data-tracking-el={trackingEl}
218
232
  data-tracking-label={trackingLabel}
219
233
  fixedWeeks={fixedWeeks}
@@ -3,18 +3,6 @@ import { cva } from "class-variance-authority";
3
3
 
4
4
  import { cn } from "@brightlocal/ui-components/lib/utils";
5
5
 
6
- /**
7
- * Available card visual variants
8
- */
9
- export enum CardVariant {
10
- /** Default card with background, border */
11
- DEFAULT = "default",
12
- /** Transparent card with no background or border */
13
- TRANSPARENT = "transparent",
14
- /** Card with border only, no background or shadow */
15
- BORDER = "border",
16
- }
17
-
18
6
  const cardVariants = cva(
19
7
  ["flex", "flex-col", "gap-8", "rounded-[14px]", "py-8", "transition-colors"],
20
8
  {
@@ -36,23 +24,43 @@ const cardVariants = cva(
36
24
  },
37
25
  },
38
26
  defaultVariants: {
39
- variant: CardVariant.DEFAULT,
27
+ variant: "default",
40
28
  },
41
29
  }
42
30
  );
43
31
 
32
+ /**
33
+ * Props for the Card component
34
+ */
44
35
  type CardProps = React.ComponentProps<"div"> & {
45
- variant?: CardVariant;
36
+ /**
37
+ * Visual style variant of the card
38
+ * @default "default"
39
+ */
40
+ variant?: "default" | "transparent" | "border";
41
+ /**
42
+ * Data hook for automated testing (required)
43
+ */
46
44
  dataHook: string;
45
+ /**
46
+ * Tracking element identifier for analytics
47
+ */
47
48
  trackingEl?: string;
49
+ /**
50
+ * Tracking label for analytics context
51
+ */
48
52
  trackingLabel?: string;
49
53
  };
50
54
 
55
+ /**
56
+ * Container component for grouping related content with visual separation.
57
+ * Supports multiple visual variants for different contexts.
58
+ */
51
59
  const Card = React.forwardRef<HTMLDivElement, CardProps>(
52
60
  (
53
61
  {
54
62
  className,
55
- variant = CardVariant.DEFAULT,
63
+ variant = "default",
56
64
  dataHook,
57
65
  trackingEl,
58
66
  trackingLabel,
@@ -76,9 +84,27 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(
76
84
 
77
85
  Card.displayName = "Card";
78
86
 
79
- function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
80
- return (
87
+ /**
88
+ * Props for Card sub-components
89
+ */
90
+ type CardSubComponentProps = React.ComponentProps<"div"> & {
91
+ /**
92
+ * Additional CSS classes to apply
93
+ */
94
+ className?: string;
95
+ /**
96
+ * Content to render inside the component
97
+ */
98
+ children?: React.ReactNode;
99
+ };
100
+
101
+ /**
102
+ * Header section of the Card containing title and description.
103
+ */
104
+ const CardHeader = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
105
+ ({ className, ...props }, ref) => (
81
106
  <div
107
+ ref={ref}
82
108
  className={cn(
83
109
  "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-8 has-data-[slot=card-action]:grid-cols-[1fr_auto]",
84
110
  className
@@ -86,22 +112,32 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
86
112
  data-slot="card-header"
87
113
  {...props}
88
114
  />
89
- );
90
- }
115
+ )
116
+ );
117
+ CardHeader.displayName = "CardHeader";
91
118
 
92
- function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
93
- return (
119
+ /**
120
+ * Title element within the Card header.
121
+ */
122
+ const CardTitle = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
123
+ ({ className, ...props }, ref) => (
94
124
  <div
125
+ ref={ref}
95
126
  className={cn("heading-sm", className)}
96
127
  data-slot="card-title"
97
128
  {...props}
98
129
  />
99
- );
100
- }
130
+ )
131
+ );
132
+ CardTitle.displayName = "CardTitle";
101
133
 
102
- function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
103
- return (
134
+ /**
135
+ * Description text within the Card header.
136
+ */
137
+ const CardDescription = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
138
+ ({ className, ...props }, ref) => (
104
139
  <div
140
+ ref={ref}
105
141
  className={cn(
106
142
  "text-muted-foreground text-sm leading-normal font-normal",
107
143
  className
@@ -109,12 +145,17 @@ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
109
145
  data-slot="card-description"
110
146
  {...props}
111
147
  />
112
- );
113
- }
148
+ )
149
+ );
150
+ CardDescription.displayName = "CardDescription";
114
151
 
115
- function CardAction({ className, ...props }: React.ComponentProps<"div">) {
116
- return (
152
+ /**
153
+ * Action area within the Card header for buttons or controls.
154
+ */
155
+ const CardAction = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
156
+ ({ className, ...props }, ref) => (
117
157
  <div
158
+ ref={ref}
118
159
  className={cn(
119
160
  "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
120
161
  className
@@ -122,28 +163,39 @@ function CardAction({ className, ...props }: React.ComponentProps<"div">) {
122
163
  data-slot="card-action"
123
164
  {...props}
124
165
  />
125
- );
126
- }
166
+ )
167
+ );
168
+ CardAction.displayName = "CardAction";
127
169
 
128
- function CardContent({ className, ...props }: React.ComponentProps<"div">) {
129
- return (
170
+ /**
171
+ * Main content area of the Card.
172
+ */
173
+ const CardContent = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
174
+ ({ className, ...props }, ref) => (
130
175
  <div
176
+ ref={ref}
131
177
  className={cn("px-8", className)}
132
178
  data-slot="card-content"
133
179
  {...props}
134
180
  />
135
- );
136
- }
181
+ )
182
+ );
183
+ CardContent.displayName = "CardContent";
137
184
 
138
- function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
139
- return (
185
+ /**
186
+ * Footer section of the Card for actions or metadata.
187
+ */
188
+ const CardFooter = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
189
+ ({ className, ...props }, ref) => (
140
190
  <div
191
+ ref={ref}
141
192
  className={cn("flex items-center px-8", className)}
142
193
  data-slot="card-footer"
143
194
  {...props}
144
195
  />
145
- );
146
- }
196
+ )
197
+ );
198
+ CardFooter.displayName = "CardFooter";
147
199
 
148
200
  export {
149
201
  Card,
@@ -155,4 +207,4 @@ export {
155
207
  CardContent,
156
208
  };
157
209
 
158
- export type { CardProps };
210
+ export type { CardProps, CardSubComponentProps };