@brightlocal/ui-components 0.1.2 → 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 (236) 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 +177 -170
  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/package.json +8 -2
  184. package/src/blocks/data-table.tsx +42 -32
  185. package/src/blocks/sidebar.tsx +4 -12
  186. package/src/components/accordion.tsx +163 -77
  187. package/src/components/alert-dialog.tsx +156 -111
  188. package/src/components/alert.tsx +26 -13
  189. package/src/components/aspect-ratio.tsx +25 -16
  190. package/src/components/avatar.tsx +56 -8
  191. package/src/components/badge.tsx +65 -42
  192. package/src/components/breadcrumb.tsx +158 -82
  193. package/src/components/button.tsx +41 -62
  194. package/src/components/calendar.tsx +16 -2
  195. package/src/components/card.tsx +92 -40
  196. package/src/components/carousel.tsx +240 -115
  197. package/src/components/centred-layout.tsx +67 -35
  198. package/src/components/chart.tsx +118 -47
  199. package/src/components/checkbox.tsx +42 -78
  200. package/src/components/collapsible.tsx +95 -26
  201. package/src/components/combobox.tsx +242 -144
  202. package/src/components/command.tsx +295 -121
  203. package/src/components/context-menu.tsx +278 -81
  204. package/src/components/date-picker.tsx +281 -30
  205. package/src/components/description.tsx +60 -0
  206. package/src/components/dialog.tsx +162 -86
  207. package/src/components/drawer.tsx +76 -2
  208. package/src/components/dropdown-menu.tsx +143 -37
  209. package/src/components/field.tsx +36 -11
  210. package/src/components/global-layout.tsx +116 -77
  211. package/src/components/hover-card.tsx +54 -14
  212. package/src/components/input-group.tsx +56 -18
  213. package/src/components/input-password.tsx +3 -4
  214. package/src/components/input.tsx +93 -186
  215. package/src/components/label.tsx +56 -15
  216. package/src/components/logo.tsx +3 -0
  217. package/src/components/menubar.tsx +58 -4
  218. package/src/components/popover.tsx +103 -20
  219. package/src/components/progress.tsx +82 -60
  220. package/src/components/radio-group.tsx +40 -0
  221. package/src/components/rating.tsx +4 -0
  222. package/src/components/resizable.tsx +119 -31
  223. package/src/components/scroll-area.tsx +123 -56
  224. package/src/components/select.tsx +21 -1
  225. package/src/components/separator.tsx +97 -20
  226. package/src/components/sheet.tsx +180 -79
  227. package/src/components/skeleton.tsx +40 -10
  228. package/src/components/slider.tsx +83 -57
  229. package/src/components/sonner.tsx +10 -7
  230. package/src/components/split-layout.tsx +4 -1
  231. package/src/index.ts +1 -1
  232. package/dist/input-base.cjs +0 -1
  233. package/dist/input-base.d.ts +0 -28
  234. package/dist/input-base.d.ts.map +0 -1
  235. package/dist/input-base.js +0 -56
  236. package/src/components/input-base.tsx +0 -86
@@ -1,27 +1,53 @@
1
+ "use client";
2
+
1
3
  import * as React from "react";
2
4
  import useEmblaCarousel, {
3
5
  type UseEmblaCarouselType,
4
6
  } from "embla-carousel-react";
5
- import { ArrowLeft, ArrowRight } from "lucide-react";
7
+ import { ArrowLeft, ArrowRight } from "@brightlocal/icons";
6
8
 
7
9
  import { cn } from "@brightlocal/ui-components/lib/utils";
8
- import {
9
- Button,
10
- ButtonVariant,
11
- ButtonSize,
12
- } from "@brightlocal/ui-components/button";
10
+ import { Button, type ButtonProps } from "@brightlocal/ui-components/button";
13
11
 
14
12
  type CarouselApi = UseEmblaCarouselType[1];
15
13
  type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
16
14
  type CarouselOptions = UseCarouselParameters[0];
17
15
  type CarouselPlugin = UseCarouselParameters[1];
18
16
 
19
- type CarouselProps = {
17
+ /**
18
+ * Props for the Carousel component.
19
+ */
20
+ interface CarouselProps extends React.ComponentProps<"div"> {
21
+ /**
22
+ * Data hook for automated testing (required)
23
+ */
24
+ dataHook: string;
25
+ /**
26
+ * Tracking element identifier for analytics
27
+ */
28
+ trackingEl?: string;
29
+ /**
30
+ * Tracking label for analytics context
31
+ */
32
+ trackingLabel?: string;
33
+ /**
34
+ * Embla carousel options
35
+ */
20
36
  opts?: CarouselOptions;
37
+ /**
38
+ * Embla carousel plugins
39
+ */
21
40
  plugins?: CarouselPlugin;
41
+ /**
42
+ * Carousel orientation
43
+ * @default "horizontal"
44
+ */
22
45
  orientation?: "horizontal" | "vertical";
46
+ /**
47
+ * Callback to receive the carousel API instance
48
+ */
23
49
  setApi?: (api: CarouselApi) => void;
24
- };
50
+ }
25
51
 
26
52
  type CarouselContextProps = {
27
53
  carouselRef: ReturnType<typeof useEmblaCarousel>[0];
@@ -30,7 +56,11 @@ type CarouselContextProps = {
30
56
  scrollNext: () => void;
31
57
  canScrollPrev: boolean;
32
58
  canScrollNext: boolean;
33
- } & CarouselProps;
59
+ opts?: CarouselOptions;
60
+ plugins?: CarouselPlugin;
61
+ orientation?: "horizontal" | "vertical";
62
+ setApi?: (api: CarouselApi) => void;
63
+ };
34
64
 
35
65
  const CarouselContext = React.createContext<CarouselContextProps | null>(null);
36
66
 
@@ -44,133 +74,166 @@ function useCarousel() {
44
74
  return context;
45
75
  }
46
76
 
47
- function Carousel({
48
- orientation = "horizontal",
49
- opts,
50
- setApi,
51
- plugins,
52
- className,
53
- children,
54
- ...props
55
- }: React.ComponentProps<"div"> & CarouselProps) {
56
- const [carouselRef, api] = useEmblaCarousel(
77
+ /**
78
+ * Carousel component for displaying a scrollable series of content.
79
+ * Built on Embla Carousel for smooth touch-enabled sliding.
80
+ */
81
+ const Carousel = React.forwardRef<HTMLDivElement, CarouselProps>(
82
+ (
57
83
  {
58
- ...opts,
59
- axis: orientation === "horizontal" ? "x" : "y",
60
- },
61
- plugins
62
- );
63
- const [canScrollPrev, setCanScrollPrev] = React.useState(false);
64
- const [canScrollNext, setCanScrollNext] = React.useState(false);
65
-
66
- const onSelect = React.useCallback((api: CarouselApi) => {
67
- if (!api) return;
68
- setCanScrollPrev(api.canScrollPrev());
69
- setCanScrollNext(api.canScrollNext());
70
- }, []);
71
-
72
- const scrollPrev = React.useCallback(() => {
73
- api?.scrollPrev();
74
- }, [api]);
75
-
76
- const scrollNext = React.useCallback(() => {
77
- api?.scrollNext();
78
- }, [api]);
79
-
80
- const handleKeyDown = React.useCallback(
81
- (event: React.KeyboardEvent<HTMLDivElement>) => {
82
- const prevKey = orientation === "horizontal" ? "ArrowLeft" : "ArrowUp";
83
- const nextKey = orientation === "horizontal" ? "ArrowRight" : "ArrowDown";
84
-
85
- if (event.key === prevKey) {
86
- event.preventDefault();
87
- scrollPrev();
88
- } else if (event.key === nextKey) {
89
- event.preventDefault();
90
- scrollNext();
91
- }
84
+ orientation = "horizontal",
85
+ opts,
86
+ setApi,
87
+ plugins,
88
+ className,
89
+ children,
90
+ dataHook,
91
+ trackingEl,
92
+ trackingLabel,
93
+ ...props
92
94
  },
93
- [orientation, scrollPrev, scrollNext]
94
- );
95
+ ref
96
+ ) => {
97
+ const [carouselRef, api] = useEmblaCarousel(
98
+ {
99
+ ...opts,
100
+ axis: orientation === "horizontal" ? "x" : "y",
101
+ },
102
+ plugins
103
+ );
104
+ const [canScrollPrev, setCanScrollPrev] = React.useState(false);
105
+ const [canScrollNext, setCanScrollNext] = React.useState(false);
95
106
 
96
- React.useEffect(() => {
97
- if (!api || !setApi) return;
98
- setApi(api);
99
- }, [api, setApi]);
107
+ const onSelect = React.useCallback((api: CarouselApi) => {
108
+ if (!api) return;
109
+ setCanScrollPrev(api.canScrollPrev());
110
+ setCanScrollNext(api.canScrollNext());
111
+ }, []);
100
112
 
101
- React.useEffect(() => {
102
- if (!api) return;
103
- onSelect(api);
104
- api.on("reInit", onSelect);
105
- api.on("select", onSelect);
113
+ const scrollPrev = React.useCallback(() => {
114
+ api?.scrollPrev();
115
+ }, [api]);
106
116
 
107
- return () => {
108
- api?.off("reInit", onSelect);
109
- api?.off("select", onSelect);
110
- };
111
- }, [api, onSelect]);
117
+ const scrollNext = React.useCallback(() => {
118
+ api?.scrollNext();
119
+ }, [api]);
112
120
 
113
- return (
114
- <CarouselContext.Provider
115
- value={{
116
- carouselRef,
117
- api,
118
- opts,
119
- orientation:
120
- orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
121
- scrollPrev,
122
- scrollNext,
123
- canScrollPrev,
124
- canScrollNext,
125
- }}
126
- >
127
- <div
128
- aria-roledescription="carousel"
129
- className={cn("relative", className)}
130
- data-slot="carousel"
131
- role="region"
132
- onKeyDownCapture={handleKeyDown}
133
- {...props}
121
+ const handleKeyDown = React.useCallback(
122
+ (event: React.KeyboardEvent<HTMLDivElement>) => {
123
+ const prevKey = orientation === "horizontal" ? "ArrowLeft" : "ArrowUp";
124
+ const nextKey =
125
+ orientation === "horizontal" ? "ArrowRight" : "ArrowDown";
126
+
127
+ if (event.key === prevKey) {
128
+ event.preventDefault();
129
+ scrollPrev();
130
+ } else if (event.key === nextKey) {
131
+ event.preventDefault();
132
+ scrollNext();
133
+ }
134
+ },
135
+ [orientation, scrollPrev, scrollNext]
136
+ );
137
+
138
+ React.useEffect(() => {
139
+ if (!api || !setApi) return;
140
+ setApi(api);
141
+ }, [api, setApi]);
142
+
143
+ React.useEffect(() => {
144
+ if (!api) return;
145
+ onSelect(api);
146
+ api.on("reInit", onSelect);
147
+ api.on("select", onSelect);
148
+
149
+ return () => {
150
+ api?.off("reInit", onSelect);
151
+ api?.off("select", onSelect);
152
+ };
153
+ }, [api, onSelect]);
154
+
155
+ return (
156
+ <CarouselContext.Provider
157
+ value={{
158
+ carouselRef,
159
+ api,
160
+ opts,
161
+ orientation:
162
+ orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
163
+ scrollPrev,
164
+ scrollNext,
165
+ canScrollPrev,
166
+ canScrollNext,
167
+ }}
134
168
  >
135
- {children}
136
- </div>
137
- </CarouselContext.Provider>
138
- );
139
- }
169
+ <div
170
+ ref={ref}
171
+ aria-roledescription="carousel"
172
+ className={cn("relative", className)}
173
+ data-hook={dataHook}
174
+ data-slot="carousel"
175
+ data-tracking-el={trackingEl}
176
+ data-tracking-label={trackingLabel}
177
+ role="region"
178
+ onKeyDownCapture={handleKeyDown}
179
+ {...props}
180
+ >
181
+ {children}
182
+ </div>
183
+ </CarouselContext.Provider>
184
+ );
185
+ }
186
+ );
140
187
 
141
- function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
188
+ Carousel.displayName = "Carousel";
189
+
190
+ /**
191
+ * Container for carousel items with overflow handling.
192
+ */
193
+ const CarouselContent = React.forwardRef<
194
+ HTMLDivElement,
195
+ React.ComponentProps<"div">
196
+ >(({ className, ...props }, ref) => {
142
197
  const { carouselRef, orientation } = useCarousel();
198
+ const isVertical = orientation === "vertical";
143
199
 
144
200
  return (
145
201
  <div
146
202
  ref={carouselRef}
147
- className={cn(
148
- "overflow-hidden",
149
- orientation === "vertical" && "h-[400px]"
150
- )}
203
+ className={cn("overflow-hidden", isVertical && "w-full", className)}
151
204
  data-slot="carousel-content"
152
205
  >
206
+ {/* Negative margins offset the positive padding on CarouselItem children (pt-4/pl-4) to create consistent gaps */}
153
207
  <div
208
+ ref={ref}
154
209
  className={cn(
155
- "flex gap-4",
156
- orientation === "horizontal" ? "" : "h-full flex-col",
157
- className
210
+ "flex",
211
+ isVertical ? "-mt-4 h-full w-full flex-col" : "-ml-4"
158
212
  )}
159
213
  {...props}
160
214
  />
161
215
  </div>
162
216
  );
163
- }
217
+ });
218
+
219
+ CarouselContent.displayName = "CarouselContent";
164
220
 
165
- function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
221
+ /**
222
+ * Individual slide item within the carousel.
223
+ */
224
+ const CarouselItem = React.forwardRef<
225
+ HTMLDivElement,
226
+ React.ComponentProps<"div">
227
+ >(({ className, ...props }, ref) => {
166
228
  const { orientation } = useCarousel();
167
229
 
168
230
  return (
169
231
  <div
232
+ ref={ref}
170
233
  aria-roledescription="slide"
171
234
  className={cn(
172
235
  "min-w-0 shrink-0 grow-0 basis-full",
173
- orientation === "horizontal" ? "pl-1" : "pt-1",
236
+ orientation === "horizontal" ? "pl-4" : "w-full pt-4",
174
237
  className
175
238
  )}
176
239
  data-slot="carousel-item"
@@ -178,21 +241,51 @@ function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
178
241
  {...props}
179
242
  />
180
243
  );
244
+ });
245
+
246
+ CarouselItem.displayName = "CarouselItem";
247
+
248
+ /**
249
+ * Props for CarouselPrevious component.
250
+ */
251
+ interface CarouselPreviousProps extends Omit<
252
+ ButtonProps,
253
+ "variant" | "size" | "dataHook"
254
+ > {
255
+ /**
256
+ * Visual style variant of the button
257
+ * @default "outline"
258
+ */
259
+ variant?: ButtonProps["variant"];
260
+ /**
261
+ * Size variant of the button
262
+ * @default "default"
263
+ */
264
+ size?: ButtonProps["size"];
265
+ /**
266
+ * Data hook for automated testing
267
+ * @default "carousel-previous"
268
+ */
269
+ dataHook?: string;
181
270
  }
182
271
 
272
+ /**
273
+ * Button to navigate to the previous slide.
274
+ */
183
275
  function CarouselPrevious({
184
276
  className,
185
- variant = ButtonVariant.OUTLINE,
186
- size = ButtonSize.SM,
277
+ variant = "outline",
278
+ size = "default",
187
279
  dataHook = "carousel-previous",
188
280
  ...props
189
- }: React.ComponentProps<typeof Button>) {
281
+ }: CarouselPreviousProps) {
190
282
  const { orientation, scrollPrev, canScrollPrev } = useCarousel();
191
283
 
192
284
  return (
193
285
  <Button
286
+ iconOnly
194
287
  className={cn(
195
- "absolute size-8 rounded-full",
288
+ "absolute",
196
289
  orientation === "horizontal"
197
290
  ? "top-1/2 -left-12 -translate-y-1/2"
198
291
  : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
@@ -212,19 +305,49 @@ function CarouselPrevious({
212
305
  );
213
306
  }
214
307
 
308
+ CarouselPrevious.displayName = "CarouselPrevious";
309
+
310
+ /**
311
+ * Props for CarouselNext component.
312
+ */
313
+ interface CarouselNextProps extends Omit<
314
+ ButtonProps,
315
+ "variant" | "size" | "dataHook"
316
+ > {
317
+ /**
318
+ * Visual style variant of the button
319
+ * @default "outline"
320
+ */
321
+ variant?: ButtonProps["variant"];
322
+ /**
323
+ * Size variant of the button
324
+ * @default "default"
325
+ */
326
+ size?: ButtonProps["size"];
327
+ /**
328
+ * Data hook for automated testing
329
+ * @default "carousel-next"
330
+ */
331
+ dataHook?: string;
332
+ }
333
+
334
+ /**
335
+ * Button to navigate to the next slide.
336
+ */
215
337
  function CarouselNext({
216
338
  className,
217
- variant = ButtonVariant.OUTLINE,
218
- size = ButtonSize.SM,
339
+ variant = "outline",
340
+ size = "default",
219
341
  dataHook = "carousel-next",
220
342
  ...props
221
- }: React.ComponentProps<typeof Button>) {
343
+ }: CarouselNextProps) {
222
344
  const { orientation, scrollNext, canScrollNext } = useCarousel();
223
345
 
224
346
  return (
225
347
  <Button
348
+ iconOnly
226
349
  className={cn(
227
- "absolute size-8 rounded-full",
350
+ "absolute",
228
351
  orientation === "horizontal"
229
352
  ? "top-1/2 -right-12 -translate-y-1/2"
230
353
  : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
@@ -244,6 +367,8 @@ function CarouselNext({
244
367
  );
245
368
  }
246
369
 
370
+ CarouselNext.displayName = "CarouselNext";
371
+
247
372
  export {
248
373
  type CarouselApi,
249
374
  Carousel,
@@ -253,4 +378,4 @@ export {
253
378
  CarouselNext,
254
379
  };
255
380
 
256
- export type { CarouselProps };
381
+ export type { CarouselProps, CarouselPreviousProps, CarouselNextProps };
@@ -40,7 +40,20 @@ export enum CentredLayoutBreakpoint {
40
40
 
41
41
  interface CentredLayoutProps extends React.ComponentProps<"div"> {
42
42
  /**
43
- * Breakpoint size variant (default: xl)
43
+ * Data hook for automated testing (required)
44
+ */
45
+ dataHook: string;
46
+ /**
47
+ * Tracking element identifier for analytics
48
+ */
49
+ trackingEl?: string;
50
+ /**
51
+ * Tracking label for analytics context
52
+ */
53
+ trackingLabel?: string;
54
+ /**
55
+ * Breakpoint size variant
56
+ * @default "xl"
44
57
  */
45
58
  breakpoint?: CentredLayoutBreakpoint;
46
59
  /**
@@ -49,42 +62,61 @@ interface CentredLayoutProps extends React.ComponentProps<"div"> {
49
62
  maxWidth?: string | number;
50
63
  }
51
64
 
52
- function CentredLayout({
53
- className,
54
- breakpoint = CentredLayoutBreakpoint.XL,
55
- maxWidth,
56
- children,
57
- ...props
58
- }: CentredLayoutProps) {
59
- // Map breakpoints to Tailwind max-width utility classes
60
- const breakpointMaxWidthClass = {
61
- [CentredLayoutBreakpoint.XL]: "max-w-7xl",
62
- [CentredLayoutBreakpoint.LG]: "max-w-5xl",
63
- [CentredLayoutBreakpoint.MD]: "max-w-3xl",
64
- [CentredLayoutBreakpoint.SM]: "max-w-2xl",
65
- };
65
+ /**
66
+ * CentredLayout component for centering content with responsive max-width constraints.
67
+ */
68
+ const CentredLayout = React.forwardRef<HTMLDivElement, CentredLayoutProps>(
69
+ (
70
+ {
71
+ className,
72
+ breakpoint = CentredLayoutBreakpoint.XL,
73
+ maxWidth,
74
+ children,
75
+ dataHook,
76
+ trackingEl,
77
+ trackingLabel,
78
+ ...props
79
+ },
80
+ ref
81
+ ) => {
82
+ // Map breakpoints to Tailwind max-width utility classes
83
+ const breakpointMaxWidthClass = {
84
+ [CentredLayoutBreakpoint.XL]: "max-w-7xl",
85
+ [CentredLayoutBreakpoint.LG]: "max-w-5xl",
86
+ [CentredLayoutBreakpoint.MD]: "max-w-3xl",
87
+ [CentredLayoutBreakpoint.SM]: "max-w-2xl",
88
+ };
66
89
 
67
- // If custom maxWidth is provided, use inline style; otherwise use Tailwind class
68
- const maxWidthStyle =
69
- maxWidth !== undefined
70
- ? { maxWidth: typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth }
71
- : undefined;
90
+ // If custom maxWidth is provided, use inline style; otherwise use Tailwind class
91
+ const maxWidthStyle =
92
+ maxWidth !== undefined
93
+ ? {
94
+ maxWidth: typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth,
95
+ }
96
+ : undefined;
72
97
 
73
- return (
74
- <div
75
- className={cn(
76
- "bg-background flex min-h-screen items-center justify-center p-6",
77
- !maxWidth && breakpointMaxWidthClass[breakpoint],
78
- className
79
- )}
80
- data-slot="centred-layout"
81
- style={maxWidthStyle}
82
- {...props}
83
- >
84
- {children}
85
- </div>
86
- );
87
- }
98
+ return (
99
+ <div
100
+ ref={ref}
101
+ className={cn(
102
+ "bg-background flex min-h-screen items-center justify-center p-6",
103
+ !maxWidth && breakpointMaxWidthClass[breakpoint],
104
+ className
105
+ )}
106
+ data-hook={dataHook}
107
+ data-slot="centred-layout"
108
+ data-tracking-el={trackingEl}
109
+ data-tracking-label={trackingLabel}
110
+ style={maxWidthStyle}
111
+ {...props}
112
+ >
113
+ {children}
114
+ </div>
115
+ );
116
+ }
117
+ );
118
+
119
+ CentredLayout.displayName = "CentredLayout";
88
120
 
89
121
  export { CentredLayout };
90
122