@brightlocal/ui-components 0.1.0

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 (320) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +349 -0
  3. package/dist/accordion.cjs +1 -0
  4. package/dist/accordion.d.ts +32 -0
  5. package/dist/accordion.d.ts.map +1 -0
  6. package/dist/accordion.js +107 -0
  7. package/dist/alert-dialog.cjs +1 -0
  8. package/dist/alert-dialog.d.ts +15 -0
  9. package/dist/alert-dialog.d.ts.map +1 -0
  10. package/dist/alert-dialog.js +146 -0
  11. package/dist/alert.cjs +1 -0
  12. package/dist/alert.d.ts +16 -0
  13. package/dist/alert.d.ts.map +1 -0
  14. package/dist/alert.js +174 -0
  15. package/dist/aspect-ratio.cjs +1 -0
  16. package/dist/aspect-ratio.d.ts +10 -0
  17. package/dist/aspect-ratio.d.ts.map +1 -0
  18. package/dist/aspect-ratio.js +22 -0
  19. package/dist/avatar.cjs +1 -0
  20. package/dist/avatar.d.ts +11 -0
  21. package/dist/avatar.d.ts.map +1 -0
  22. package/dist/avatar.js +46 -0
  23. package/dist/badge.cjs +1 -0
  24. package/dist/badge.d.ts +19 -0
  25. package/dist/badge.d.ts.map +1 -0
  26. package/dist/badge.js +50 -0
  27. package/dist/blocks/data-table.cjs +1 -0
  28. package/dist/blocks/data-table.d.ts +303 -0
  29. package/dist/blocks/data-table.d.ts.map +1 -0
  30. package/dist/blocks/data-table.js +555 -0
  31. package/dist/blocks/sidebar.cjs +1 -0
  32. package/dist/blocks/sidebar.d.ts +744 -0
  33. package/dist/blocks/sidebar.d.ts.map +1 -0
  34. package/dist/blocks/sidebar.js +839 -0
  35. package/dist/breadcrumb.cjs +1 -0
  36. package/dist/breadcrumb.d.ts +12 -0
  37. package/dist/breadcrumb.d.ts.map +1 -0
  38. package/dist/breadcrumb.js +102 -0
  39. package/dist/button.cjs +1 -0
  40. package/dist/button.d.ts +73 -0
  41. package/dist/button.d.ts.map +1 -0
  42. package/dist/button.js +195 -0
  43. package/dist/calendar.cjs +1 -0
  44. package/dist/calendar.d.ts +28 -0
  45. package/dist/calendar.d.ts.map +1 -0
  46. package/dist/calendar.js +191 -0
  47. package/dist/card.cjs +1 -0
  48. package/dist/card.d.ts +28 -0
  49. package/dist/card.d.ts.map +1 -0
  50. package/dist/card.js +131 -0
  51. package/dist/carousel.cjs +1 -0
  52. package/dist/carousel.d.ts +21 -0
  53. package/dist/carousel.d.ts.map +1 -0
  54. package/dist/carousel.js +185 -0
  55. package/dist/centred-layout.cjs +1 -0
  56. package/dist/centred-layout.d.ts +49 -0
  57. package/dist/centred-layout.d.ts.map +1 -0
  58. package/dist/centred-layout.js +35 -0
  59. package/dist/chart.cjs +10 -0
  60. package/dist/chart.d.ts +83 -0
  61. package/dist/chart.d.ts.map +1 -0
  62. package/dist/chart.js +254 -0
  63. package/dist/checkbox.cjs +1 -0
  64. package/dist/checkbox.d.ts +15 -0
  65. package/dist/checkbox.d.ts.map +1 -0
  66. package/dist/checkbox.js +96 -0
  67. package/dist/collapsible.cjs +1 -0
  68. package/dist/collapsible.d.ts +18 -0
  69. package/dist/collapsible.d.ts.map +1 -0
  70. package/dist/collapsible.js +58 -0
  71. package/dist/combobox.cjs +1 -0
  72. package/dist/combobox.d.ts +65 -0
  73. package/dist/combobox.d.ts.map +1 -0
  74. package/dist/combobox.js +203 -0
  75. package/dist/command.cjs +1 -0
  76. package/dist/command.d.ts +44 -0
  77. package/dist/command.d.ts.map +1 -0
  78. package/dist/command.js +166 -0
  79. package/dist/context-menu.cjs +1 -0
  80. package/dist/context-menu.d.ts +42 -0
  81. package/dist/context-menu.d.ts.map +1 -0
  82. package/dist/context-menu.js +226 -0
  83. package/dist/date-picker.cjs +1 -0
  84. package/dist/date-picker.d.ts +54 -0
  85. package/dist/date-picker.d.ts.map +1 -0
  86. package/dist/date-picker.js +95 -0
  87. package/dist/dialog.cjs +1 -0
  88. package/dist/dialog.d.ts +20 -0
  89. package/dist/dialog.d.ts.map +1 -0
  90. package/dist/dialog.js +130 -0
  91. package/dist/drawer.cjs +1 -0
  92. package/dist/drawer.d.ts +22 -0
  93. package/dist/drawer.d.ts.map +1 -0
  94. package/dist/drawer.js +149 -0
  95. package/dist/dropdown-menu.cjs +1 -0
  96. package/dist/dropdown-menu.d.ts +253 -0
  97. package/dist/dropdown-menu.d.ts.map +1 -0
  98. package/dist/dropdown-menu.js +325 -0
  99. package/dist/field.cjs +1 -0
  100. package/dist/field.d.ts +21 -0
  101. package/dist/field.d.ts.map +1 -0
  102. package/dist/field.js +148 -0
  103. package/dist/global-layout.cjs +1 -0
  104. package/dist/global-layout.d.ts +60 -0
  105. package/dist/global-layout.d.ts.map +1 -0
  106. package/dist/global-layout.js +87 -0
  107. package/dist/hooks/use-mobile.cjs +1 -0
  108. package/dist/hooks/use-mobile.d.ts +2 -0
  109. package/dist/hooks/use-mobile.d.ts.map +1 -0
  110. package/dist/hooks/use-mobile.js +16 -0
  111. package/dist/hover-card.cjs +1 -0
  112. package/dist/hover-card.d.ts +43 -0
  113. package/dist/hover-card.d.ts.map +1 -0
  114. package/dist/hover-card.js +71 -0
  115. package/dist/index.cjs +1 -0
  116. package/dist/index.d.ts +61 -0
  117. package/dist/index.d.ts.map +1 -0
  118. package/dist/index.js +412 -0
  119. package/dist/input-base.cjs +1 -0
  120. package/dist/input-base.d.ts +28 -0
  121. package/dist/input-base.d.ts.map +1 -0
  122. package/dist/input-base.js +56 -0
  123. package/dist/input-group.cjs +1 -0
  124. package/dist/input-group.d.ts +26 -0
  125. package/dist/input-group.d.ts.map +1 -0
  126. package/dist/input-group.js +116 -0
  127. package/dist/input-otp.cjs +1 -0
  128. package/dist/input-otp.d.ts +45 -0
  129. package/dist/input-otp.d.ts.map +1 -0
  130. package/dist/input-otp.js +186 -0
  131. package/dist/input-password.cjs +1 -0
  132. package/dist/input-password.d.ts +38 -0
  133. package/dist/input-password.d.ts.map +1 -0
  134. package/dist/input-password.js +101 -0
  135. package/dist/input.cjs +1 -0
  136. package/dist/input.d.ts +32 -0
  137. package/dist/input.d.ts.map +1 -0
  138. package/dist/input.js +146 -0
  139. package/dist/label.cjs +1 -0
  140. package/dist/label.d.ts +12 -0
  141. package/dist/label.d.ts.map +1 -0
  142. package/dist/label.js +34 -0
  143. package/dist/lib/utils.cjs +1 -0
  144. package/dist/lib/utils.d.ts +3 -0
  145. package/dist/lib/utils.d.ts.map +1 -0
  146. package/dist/lib/utils.js +8 -0
  147. package/dist/link.cjs +1 -0
  148. package/dist/link.d.ts +29 -0
  149. package/dist/link.d.ts.map +1 -0
  150. package/dist/link.figma.d.ts +2 -0
  151. package/dist/link.figma.d.ts.map +1 -0
  152. package/dist/link.js +71 -0
  153. package/dist/logo.cjs +1 -0
  154. package/dist/logo.d.ts +25 -0
  155. package/dist/logo.d.ts.map +1 -0
  156. package/dist/logo.js +71 -0
  157. package/dist/menubar.cjs +1 -0
  158. package/dist/menubar.d.ts +106 -0
  159. package/dist/menubar.d.ts.map +1 -0
  160. package/dist/menubar.js +270 -0
  161. package/dist/navigation-menu.cjs +1 -0
  162. package/dist/navigation-menu.d.ts +108 -0
  163. package/dist/navigation-menu.d.ts.map +1 -0
  164. package/dist/navigation-menu.js +175 -0
  165. package/dist/pagination.cjs +1 -0
  166. package/dist/pagination.d.ts +81 -0
  167. package/dist/pagination.d.ts.map +1 -0
  168. package/dist/pagination.js +216 -0
  169. package/dist/popover.cjs +1 -0
  170. package/dist/popover.d.ts +8 -0
  171. package/dist/popover.d.ts.map +1 -0
  172. package/dist/popover.js +44 -0
  173. package/dist/progress.cjs +1 -0
  174. package/dist/progress.d.ts +29 -0
  175. package/dist/progress.d.ts.map +1 -0
  176. package/dist/progress.js +64 -0
  177. package/dist/radio-group.cjs +1 -0
  178. package/dist/radio-group.d.ts +33 -0
  179. package/dist/radio-group.d.ts.map +1 -0
  180. package/dist/radio-group.js +193 -0
  181. package/dist/rating.cjs +1 -0
  182. package/dist/rating.d.ts +22 -0
  183. package/dist/rating.d.ts.map +1 -0
  184. package/dist/rating.js +51 -0
  185. package/dist/resizable.cjs +1 -0
  186. package/dist/resizable.d.ts +14 -0
  187. package/dist/resizable.d.ts.map +1 -0
  188. package/dist/resizable.js +46 -0
  189. package/dist/scroll-area.cjs +1 -0
  190. package/dist/scroll-area.d.ts +12 -0
  191. package/dist/scroll-area.d.ts.map +1 -0
  192. package/dist/scroll-area.js +67 -0
  193. package/dist/select.cjs +1 -0
  194. package/dist/select.d.ts +77 -0
  195. package/dist/select.d.ts.map +1 -0
  196. package/dist/select.js +259 -0
  197. package/dist/separator.cjs +1 -0
  198. package/dist/separator.d.ts +14 -0
  199. package/dist/separator.d.ts.map +1 -0
  200. package/dist/separator.js +43 -0
  201. package/dist/sheet.cjs +1 -0
  202. package/dist/sheet.d.ts +38 -0
  203. package/dist/sheet.d.ts.map +1 -0
  204. package/dist/sheet.js +190 -0
  205. package/dist/skeleton.cjs +1 -0
  206. package/dist/skeleton.d.ts +5 -0
  207. package/dist/skeleton.d.ts.map +1 -0
  208. package/dist/skeleton.js +15 -0
  209. package/dist/slider.cjs +1 -0
  210. package/dist/slider.d.ts +19 -0
  211. package/dist/slider.d.ts.map +1 -0
  212. package/dist/slider.js +69 -0
  213. package/dist/sonner.cjs +1 -0
  214. package/dist/sonner.d.ts +188 -0
  215. package/dist/sonner.d.ts.map +1 -0
  216. package/dist/sonner.js +150 -0
  217. package/dist/split-layout.cjs +1 -0
  218. package/dist/split-layout.d.ts +42 -0
  219. package/dist/split-layout.d.ts.map +1 -0
  220. package/dist/split-layout.js +108 -0
  221. package/dist/switch.cjs +1 -0
  222. package/dist/switch.d.ts +43 -0
  223. package/dist/switch.d.ts.map +1 -0
  224. package/dist/switch.figma.d.ts +2 -0
  225. package/dist/switch.figma.d.ts.map +1 -0
  226. package/dist/switch.js +110 -0
  227. package/dist/table.cjs +1 -0
  228. package/dist/table.d.ts +95 -0
  229. package/dist/table.d.ts.map +1 -0
  230. package/dist/table.js +164 -0
  231. package/dist/tabs.cjs +1 -0
  232. package/dist/tabs.d.ts +29 -0
  233. package/dist/tabs.d.ts.map +1 -0
  234. package/dist/tabs.js +96 -0
  235. package/dist/textarea.cjs +1 -0
  236. package/dist/textarea.d.ts +23 -0
  237. package/dist/textarea.d.ts.map +1 -0
  238. package/dist/textarea.js +47 -0
  239. package/dist/toggle-group.cjs +1 -0
  240. package/dist/toggle-group.d.ts +25 -0
  241. package/dist/toggle-group.d.ts.map +1 -0
  242. package/dist/toggle-group.js +74 -0
  243. package/dist/toggle.cjs +1 -0
  244. package/dist/toggle.d.ts +44 -0
  245. package/dist/toggle.d.ts.map +1 -0
  246. package/dist/toggle.figma.d.ts +2 -0
  247. package/dist/toggle.figma.d.ts.map +1 -0
  248. package/dist/toggle.js +57 -0
  249. package/dist/tooltip.cjs +1 -0
  250. package/dist/tooltip.d.ts +66 -0
  251. package/dist/tooltip.d.ts.map +1 -0
  252. package/dist/tooltip.js +78 -0
  253. package/package.json +184 -0
  254. package/src/blocks/data-table.tsx +1166 -0
  255. package/src/blocks/sidebar.tsx +1830 -0
  256. package/src/components/.gitkeep +0 -0
  257. package/src/components/accordion.tsx +142 -0
  258. package/src/components/alert-dialog.tsx +157 -0
  259. package/src/components/alert.tsx +199 -0
  260. package/src/components/aspect-ratio.tsx +30 -0
  261. package/src/components/avatar.tsx +56 -0
  262. package/src/components/badge.tsx +72 -0
  263. package/src/components/breadcrumb.tsx +109 -0
  264. package/src/components/button.tsx +296 -0
  265. package/src/components/calendar.tsx +234 -0
  266. package/src/components/card.tsx +158 -0
  267. package/src/components/carousel.tsx +256 -0
  268. package/src/components/centred-layout.tsx +91 -0
  269. package/src/components/chart.tsx +456 -0
  270. package/src/components/checkbox.tsx +132 -0
  271. package/src/components/collapsible.tsx +68 -0
  272. package/src/components/combobox.tsx +321 -0
  273. package/src/components/command.tsx +220 -0
  274. package/src/components/context-menu.tsx +305 -0
  275. package/src/components/date-picker.tsx +155 -0
  276. package/src/components/dialog.tsx +152 -0
  277. package/src/components/drawer.tsx +168 -0
  278. package/src/components/dropdown-menu.tsx +575 -0
  279. package/src/components/field.tsx +155 -0
  280. package/src/components/global-layout.tsx +153 -0
  281. package/src/components/hover-card.tsx +121 -0
  282. package/src/components/input-base.tsx +86 -0
  283. package/src/components/input-group.tsx +158 -0
  284. package/src/components/input-otp.tsx +327 -0
  285. package/src/components/input-password.tsx +191 -0
  286. package/src/components/input.tsx +220 -0
  287. package/src/components/label.tsx +42 -0
  288. package/src/components/link.figma.tsx +71 -0
  289. package/src/components/link.tsx +105 -0
  290. package/src/components/logo.tsx +97 -0
  291. package/src/components/menubar.tsx +379 -0
  292. package/src/components/navigation-menu.tsx +324 -0
  293. package/src/components/pagination.tsx +368 -0
  294. package/src/components/popover.tsx +46 -0
  295. package/src/components/progress.tsx +100 -0
  296. package/src/components/radio-group.tsx +281 -0
  297. package/src/components/rating.tsx +87 -0
  298. package/src/components/resizable.tsx +66 -0
  299. package/src/components/scroll-area.tsx +72 -0
  300. package/src/components/select.tsx +442 -0
  301. package/src/components/separator.tsx +53 -0
  302. package/src/components/sheet.tsx +220 -0
  303. package/src/components/skeleton.tsx +17 -0
  304. package/src/components/slider.tsx +86 -0
  305. package/src/components/sonner.tsx +396 -0
  306. package/src/components/split-layout.tsx +155 -0
  307. package/src/components/switch.figma.tsx +115 -0
  308. package/src/components/switch.tsx +173 -0
  309. package/src/components/table.tsx +277 -0
  310. package/src/components/tabs.tsx +142 -0
  311. package/src/components/textarea.tsx +77 -0
  312. package/src/components/toggle-group.tsx +109 -0
  313. package/src/components/toggle.figma.tsx +81 -0
  314. package/src/components/toggle.tsx +103 -0
  315. package/src/components/tooltip.tsx +156 -0
  316. package/src/hooks/.gitkeep +0 -0
  317. package/src/hooks/use-mobile.ts +21 -0
  318. package/src/index.ts +67 -0
  319. package/src/lib/utils.ts +6 -0
  320. package/src/types/external-modules.d.ts +16 -0
@@ -0,0 +1,158 @@
1
+ import * as React from "react";
2
+ import { cva } from "class-variance-authority";
3
+
4
+ import { cn } from "@brightlocal/ui-components/lib/utils";
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
+ const cardVariants = cva(
19
+ ["flex", "flex-col", "gap-8", "rounded-[14px]", "py-8", "transition-colors"],
20
+ {
21
+ variants: {
22
+ variant: {
23
+ default: [
24
+ "bg-card",
25
+ "text-card-foreground",
26
+ "border",
27
+ "border-card-border",
28
+ ],
29
+ transparent: ["bg-transparent", "text-foreground"],
30
+ border: [
31
+ "bg-transparent",
32
+ "text-foreground",
33
+ "border",
34
+ "border-border",
35
+ ],
36
+ },
37
+ },
38
+ defaultVariants: {
39
+ variant: CardVariant.DEFAULT,
40
+ },
41
+ }
42
+ );
43
+
44
+ type CardProps = React.ComponentProps<"div"> & {
45
+ variant?: CardVariant;
46
+ dataHook: string;
47
+ trackingEl?: string;
48
+ trackingLabel?: string;
49
+ };
50
+
51
+ const Card = React.forwardRef<HTMLDivElement, CardProps>(
52
+ (
53
+ {
54
+ className,
55
+ variant = CardVariant.DEFAULT,
56
+ dataHook,
57
+ trackingEl,
58
+ trackingLabel,
59
+ ...props
60
+ },
61
+ ref
62
+ ) => {
63
+ return (
64
+ <div
65
+ ref={ref}
66
+ className={cn(cardVariants({ variant }), className)}
67
+ data-hook={dataHook}
68
+ data-slot="card"
69
+ data-tracking-el={trackingEl || `card-${variant}`}
70
+ data-tracking-label={trackingLabel}
71
+ {...props}
72
+ />
73
+ );
74
+ }
75
+ );
76
+
77
+ Card.displayName = "Card";
78
+
79
+ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
80
+ return (
81
+ <div
82
+ className={cn(
83
+ "@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
+ className
85
+ )}
86
+ data-slot="card-header"
87
+ {...props}
88
+ />
89
+ );
90
+ }
91
+
92
+ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
93
+ return (
94
+ <div
95
+ className={cn("heading-sm", className)}
96
+ data-slot="card-title"
97
+ {...props}
98
+ />
99
+ );
100
+ }
101
+
102
+ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
103
+ return (
104
+ <div
105
+ className={cn(
106
+ "text-muted-foreground text-sm leading-normal font-normal",
107
+ className
108
+ )}
109
+ data-slot="card-description"
110
+ {...props}
111
+ />
112
+ );
113
+ }
114
+
115
+ function CardAction({ className, ...props }: React.ComponentProps<"div">) {
116
+ return (
117
+ <div
118
+ className={cn(
119
+ "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
120
+ className
121
+ )}
122
+ data-slot="card-action"
123
+ {...props}
124
+ />
125
+ );
126
+ }
127
+
128
+ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
129
+ return (
130
+ <div
131
+ className={cn("px-8", className)}
132
+ data-slot="card-content"
133
+ {...props}
134
+ />
135
+ );
136
+ }
137
+
138
+ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
139
+ return (
140
+ <div
141
+ className={cn("flex items-center px-8", className)}
142
+ data-slot="card-footer"
143
+ {...props}
144
+ />
145
+ );
146
+ }
147
+
148
+ export {
149
+ Card,
150
+ CardHeader,
151
+ CardFooter,
152
+ CardTitle,
153
+ CardAction,
154
+ CardDescription,
155
+ CardContent,
156
+ };
157
+
158
+ export type { CardProps };
@@ -0,0 +1,256 @@
1
+ import * as React from "react";
2
+ import useEmblaCarousel, {
3
+ type UseEmblaCarouselType,
4
+ } from "embla-carousel-react";
5
+ import { ArrowLeft, ArrowRight } from "lucide-react";
6
+
7
+ import { cn } from "@brightlocal/ui-components/lib/utils";
8
+ import {
9
+ Button,
10
+ ButtonVariant,
11
+ ButtonSize,
12
+ } from "@brightlocal/ui-components/button";
13
+
14
+ type CarouselApi = UseEmblaCarouselType[1];
15
+ type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
16
+ type CarouselOptions = UseCarouselParameters[0];
17
+ type CarouselPlugin = UseCarouselParameters[1];
18
+
19
+ type CarouselProps = {
20
+ opts?: CarouselOptions;
21
+ plugins?: CarouselPlugin;
22
+ orientation?: "horizontal" | "vertical";
23
+ setApi?: (api: CarouselApi) => void;
24
+ };
25
+
26
+ type CarouselContextProps = {
27
+ carouselRef: ReturnType<typeof useEmblaCarousel>[0];
28
+ api: ReturnType<typeof useEmblaCarousel>[1];
29
+ scrollPrev: () => void;
30
+ scrollNext: () => void;
31
+ canScrollPrev: boolean;
32
+ canScrollNext: boolean;
33
+ } & CarouselProps;
34
+
35
+ const CarouselContext = React.createContext<CarouselContextProps | null>(null);
36
+
37
+ function useCarousel() {
38
+ const context = React.useContext(CarouselContext);
39
+
40
+ if (!context) {
41
+ throw new Error("useCarousel must be used within a <Carousel />");
42
+ }
43
+
44
+ return context;
45
+ }
46
+
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(
57
+ {
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
+ }
92
+ },
93
+ [orientation, scrollPrev, scrollNext]
94
+ );
95
+
96
+ React.useEffect(() => {
97
+ if (!api || !setApi) return;
98
+ setApi(api);
99
+ }, [api, setApi]);
100
+
101
+ React.useEffect(() => {
102
+ if (!api) return;
103
+ onSelect(api);
104
+ api.on("reInit", onSelect);
105
+ api.on("select", onSelect);
106
+
107
+ return () => {
108
+ api?.off("reInit", onSelect);
109
+ api?.off("select", onSelect);
110
+ };
111
+ }, [api, onSelect]);
112
+
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}
134
+ >
135
+ {children}
136
+ </div>
137
+ </CarouselContext.Provider>
138
+ );
139
+ }
140
+
141
+ function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
142
+ const { carouselRef, orientation } = useCarousel();
143
+
144
+ return (
145
+ <div
146
+ ref={carouselRef}
147
+ className={cn(
148
+ "overflow-hidden",
149
+ orientation === "vertical" && "h-[400px]"
150
+ )}
151
+ data-slot="carousel-content"
152
+ >
153
+ <div
154
+ className={cn(
155
+ "flex gap-4",
156
+ orientation === "horizontal" ? "" : "h-full flex-col",
157
+ className
158
+ )}
159
+ {...props}
160
+ />
161
+ </div>
162
+ );
163
+ }
164
+
165
+ function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
166
+ const { orientation } = useCarousel();
167
+
168
+ return (
169
+ <div
170
+ aria-roledescription="slide"
171
+ className={cn(
172
+ "min-w-0 shrink-0 grow-0 basis-full",
173
+ orientation === "horizontal" ? "pl-1" : "pt-1",
174
+ className
175
+ )}
176
+ data-slot="carousel-item"
177
+ role="group"
178
+ {...props}
179
+ />
180
+ );
181
+ }
182
+
183
+ function CarouselPrevious({
184
+ className,
185
+ variant = ButtonVariant.OUTLINE,
186
+ size = ButtonSize.SM,
187
+ dataHook = "carousel-previous",
188
+ ...props
189
+ }: React.ComponentProps<typeof Button>) {
190
+ const { orientation, scrollPrev, canScrollPrev } = useCarousel();
191
+
192
+ return (
193
+ <Button
194
+ className={cn(
195
+ "absolute size-8 rounded-full",
196
+ orientation === "horizontal"
197
+ ? "top-1/2 -left-12 -translate-y-1/2"
198
+ : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
199
+ className
200
+ )}
201
+ data-slot="carousel-previous"
202
+ dataHook={dataHook}
203
+ disabled={!canScrollPrev}
204
+ size={size}
205
+ variant={variant}
206
+ onClick={scrollPrev}
207
+ {...props}
208
+ >
209
+ <ArrowLeft />
210
+ <span className="sr-only">Previous slide</span>
211
+ </Button>
212
+ );
213
+ }
214
+
215
+ function CarouselNext({
216
+ className,
217
+ variant = ButtonVariant.OUTLINE,
218
+ size = ButtonSize.SM,
219
+ dataHook = "carousel-next",
220
+ ...props
221
+ }: React.ComponentProps<typeof Button>) {
222
+ const { orientation, scrollNext, canScrollNext } = useCarousel();
223
+
224
+ return (
225
+ <Button
226
+ className={cn(
227
+ "absolute size-8 rounded-full",
228
+ orientation === "horizontal"
229
+ ? "top-1/2 -right-12 -translate-y-1/2"
230
+ : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
231
+ className
232
+ )}
233
+ data-slot="carousel-next"
234
+ dataHook={dataHook}
235
+ disabled={!canScrollNext}
236
+ size={size}
237
+ variant={variant}
238
+ onClick={scrollNext}
239
+ {...props}
240
+ >
241
+ <ArrowRight />
242
+ <span className="sr-only">Next slide</span>
243
+ </Button>
244
+ );
245
+ }
246
+
247
+ export {
248
+ type CarouselApi,
249
+ Carousel,
250
+ CarouselContent,
251
+ CarouselItem,
252
+ CarouselPrevious,
253
+ CarouselNext,
254
+ };
255
+
256
+ export type { CarouselProps };
@@ -0,0 +1,91 @@
1
+ import * as React from "react";
2
+
3
+ import { cn } from "@brightlocal/ui-components/lib/utils";
4
+
5
+ /**
6
+ * CentredLayout provides a responsive centered container with max-width constraints
7
+ * based on different breakpoint sizes.
8
+ *
9
+ * Breakpoints align with Tailwind's default breakpoints:
10
+ * - XL: 1280px (max-w-7xl)
11
+ * - LG: 1024px (max-w-5xl)
12
+ * - MD: 768px (max-w-3xl)
13
+ * - SM: 640px (max-w-2xl)
14
+ *
15
+ * The component centers content horizontally and applies consistent padding
16
+ * across all breakpoints.
17
+ */
18
+
19
+ /**
20
+ * Breakpoint variants for CentredLayout
21
+ */
22
+ export enum CentredLayoutBreakpoint {
23
+ /**
24
+ * Extra large breakpoint (1280px max-width)
25
+ */
26
+ XL = "xl",
27
+ /**
28
+ * Large breakpoint (1024px max-width)
29
+ */
30
+ LG = "lg",
31
+ /**
32
+ * Medium breakpoint (768px max-width)
33
+ */
34
+ MD = "md",
35
+ /**
36
+ * Small breakpoint (640px max-width)
37
+ */
38
+ SM = "sm",
39
+ }
40
+
41
+ interface CentredLayoutProps extends React.ComponentProps<"div"> {
42
+ /**
43
+ * Breakpoint size variant (default: xl)
44
+ */
45
+ breakpoint?: CentredLayoutBreakpoint;
46
+ /**
47
+ * Custom max-width value (overrides breakpoint)
48
+ */
49
+ maxWidth?: string | number;
50
+ }
51
+
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
+ };
66
+
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;
72
+
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
+ }
88
+
89
+ export { CentredLayout };
90
+
91
+ export type { CentredLayoutProps };